[Pkg-cmake-commits] [cmake] 01/08: Imported Upstream version 3.6.0

Felix Geyer fgeyer at moszumanska.debian.org
Sun Jul 10 09:26:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

fgeyer pushed a commit to branch experimental
in repository cmake.

commit ff2e460c0813935c2bbd053d448427913282bdc8
Author: Felix Geyer <fgeyer at debian.org>
Date:   Sat Jul 9 11:21:54 2016 +0200

    Imported Upstream version 3.6.0
---
 .clang-format                                      |    9 +
 .gitattributes                                     |    3 +-
 Auxiliary/bash-completion/cmake                    |    9 +-
 Auxiliary/bash-completion/cpack                    |   20 +
 Auxiliary/bash-completion/ctest                    |   26 +
 Auxiliary/cmake-mode.el                            |    7 +-
 CMakeLists.txt                                     |   10 +-
 CONTRIBUTING.rst                                   |   10 +
 CTestCustom.cmake.in                               |    4 +-
 Help/command/add_custom_command.rst                |    7 +-
 Help/command/add_custom_target.rst                 |    7 +-
 Help/command/add_executable.rst                    |    2 +-
 Help/command/add_library.rst                       |    2 +-
 Help/command/build_command.rst                     |    2 +-
 Help/command/cmake_minimum_required.rst            |   45 +-
 Help/command/ctest_update.rst                      |    4 +
 Help/command/file.rst                              |    5 +-
 Help/command/find_file.rst                         |    3 +-
 Help/command/find_library.rst                      |    3 +-
 Help/command/find_path.rst                         |    3 +-
 Help/command/include_external_msproject.rst        |    3 +-
 Help/command/install.rst                           |   23 +-
 Help/command/list.rst                              |   13 +-
 Help/command/string.rst                            |    1 +
 Help/command/try_compile.rst                       |    7 +
 Help/generator/Ninja.rst                           |    4 +
 Help/generator/Visual Studio 6.rst                 |   10 +-
 Help/generator/Visual Studio 7 .NET 2003.rst       |    8 +-
 Help/generator/Visual Studio 7.rst                 |   10 +-
 Help/manual/cmake-buildsystem.7.rst                |    2 +-
 Help/manual/cmake-compile-features.7.rst           |    1 +
 Help/manual/cmake-generator-expressions.7.rst      |    2 +-
 Help/manual/cmake-modules.7.rst                    |    1 +
 Help/manual/cmake-packages.7.rst                   |    2 +-
 Help/manual/cmake-policies.7.rst                   |  178 +-
 Help/manual/cmake-properties.7.rst                 |    5 +
 Help/manual/cmake-toolchains.7.rst                 |    7 +-
 Help/manual/cmake-variables.7.rst                  |   15 +-
 Help/manual/cmake.1.rst                            |   83 +-
 Help/manual/cpack.1.rst                            |    2 +-
 Help/manual/ctest.1.rst                            |   11 +
 Help/module/FindLTTngUST.rst                       |    1 +
 Help/policy/CMP0059.rst                            |    2 +-
 Help/prop_dir/COMPILE_DEFINITIONS.rst              |    3 +-
 Help/prop_dir/INCLUDE_DIRECTORIES.rst              |    2 +-
 Help/prop_dir/LISTFILE_STACK.rst                   |    5 +-
 Help/prop_dir/VS_STARTUP_PROJECT.rst               |   18 +
 Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst         |    2 +-
 Help/prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS.rst     |    9 +-
 .../FIND_LIBRARY_USE_OPENBSD_VERSIONING.rst        |   11 +-
 Help/prop_gbl/IN_TRY_COMPILE.rst                   |    3 +-
 Help/prop_gbl/PREDEFINED_TARGETS_FOLDER.rst        |    4 +-
 Help/prop_gbl/RULE_MESSAGES.rst                    |    6 +-
 Help/prop_gbl/USE_FOLDERS.rst                      |    7 +-
 Help/prop_sf/COMPILE_DEFINITIONS.rst               |    5 +-
 Help/prop_sf/COMPILE_FLAGS.rst                     |    4 +-
 Help/prop_test/ATTACHED_FILES_ON_FAIL.rst          |    4 +-
 Help/prop_test/TIMEOUT_AFTER_MATCH.rst             |   37 +
 Help/prop_tgt/AUTOMOC.rst                          |   45 +-
 Help/prop_tgt/COMPILE_DEFINITIONS.rst              |    3 +-
 Help/prop_tgt/COMPILE_FLAGS.rst                    |   10 +-
 Help/prop_tgt/COMPILE_OPTIONS.rst                  |    2 +-
 Help/prop_tgt/COMPILE_PDB_NOTE.txt                 |    3 -
 Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst          |    7 +-
 Help/prop_tgt/CXX_EXTENSIONS.rst                   |    3 +-
 Help/prop_tgt/CXX_STANDARD.rst                     |    2 +
 Help/prop_tgt/C_EXTENSIONS.rst                     |    3 +-
 Help/prop_tgt/C_STANDARD.rst                       |    2 +
 Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst      |   18 +
 Help/prop_tgt/FRAMEWORK.rst                        |    4 +
 Help/prop_tgt/JOB_POOL_LINK.rst                    |    2 +-
 Help/prop_tgt/LANG_CLANG_TIDY.rst                  |   13 +
 Help/prop_tgt/PDB_NOTE.txt                         |    3 -
 Help/prop_tgt/SOVERSION.rst                        |   25 +-
 Help/prop_tgt/VERSION.rst                          |   27 +-
 Help/prop_tgt/VS_CONFIGURATION_TYPE.rst            |   10 +
 Help/release/3.6.rst                               |  310 +
 Help/release/index.rst                             |    1 +
 Help/variable/CMAKE_CFG_INTDIR.rst                 |    1 -
 Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst    |   10 +
 .../CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES.rst    |   10 +
 .../CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT.rst      |   11 +
 Help/variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS.rst     |    9 +
 Help/variable/CMAKE_ECLIPSE_VERSION.rst            |   10 +
 Help/variable/CMAKE_GENERATOR.rst                  |    2 +-
 Help/variable/CMAKE_HOST_SOLARIS.rst               |    6 +
 Help/variable/CMAKE_LANG_CLANG_TIDY.rst            |    6 +
 .../CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst     |    2 +-
 Help/variable/CMAKE_LANG_COMPILER_ID.rst           |    1 +
 .../CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES.rst    |   14 +
 Help/variable/CMAKE_LANG_STANDARD_LIBRARIES.rst    |   12 +
 Help/variable/CMAKE_MAKE_PROGRAM.rst               |    9 +-
 Help/variable/CMAKE_MFC_FLAG.rst                   |    2 +-
 Help/variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX.rst   |   27 +
 Help/variable/CMAKE_STANDARD_LIBRARIES.rst         |    7 -
 .../CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst       |   26 +
 Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst    |   15 +
 Help/variable/CMAKE_VS_MSDEV_COMMAND.rst           |   10 -
 Help/variable/CTEST_COVERAGE_COMMAND.rst           |    2 +-
 Help/variable/CTEST_GIT_INIT_SUBMODULES.rst        |    5 +
 Modules/BundleUtilities.cmake                      |  154 +-
 Modules/CMakeBackwardCompatibilityC.cmake          |    4 -
 Modules/CMakeCCompilerABI.c                        |   13 +-
 Modules/CMakeCCompilerId.c.in                      |   26 +-
 Modules/CMakeCXXCompilerABI.cpp                    |    6 +-
 Modules/CMakeCheckCompilerFlagCommonPatterns.cmake |    1 +
 Modules/CMakeCompilerABI.h                         |   28 +-
 Modules/CMakeCompilerIdDetection.cmake             |    1 +
 Modules/CMakeDetermineCCompiler.cmake              |    3 +
 Modules/CMakeDetermineCompilerId.cmake             |   23 +-
 Modules/CMakeDetermineFortranCompiler.cmake        |   26 +-
 Modules/CMakeFindCodeBlocks.cmake                  |   15 +
 Modules/CMakeFindEclipseCDT4.cmake                 |    4 +
 Modules/CMakeForceCompiler.cmake                   |   20 +-
 Modules/CMakePackageConfigHelpers.cmake            |    4 +-
 Modules/CMakeParseImplicitLinkInfo.cmake           |    2 +-
 Modules/CMakePlatformId.h.in                       |    6 +-
 Modules/CMakePushCheckState.cmake                  |    7 +-
 Modules/CMakeTestCompilerCommon.cmake              |    6 +-
 Modules/CMakeTestWatcomVersion.c                   |    1 -
 Modules/CMakeVS6BackwardCompatibility.cmake        |   26 -
 Modules/CMakeVerifyManifest.cmake                  |    8 +-
 Modules/CPack.OSXX11.Info.plist.in                 |    2 -
 Modules/CPackComponent.cmake                       |   44 +-
 Modules/CPackDMG.cmake                             |    7 +-
 Modules/CPackDeb.cmake                             |  362 +-
 Modules/CPackIFW.cmake                             |  132 +-
 Modules/CPackRPM.cmake                             |  712 ++-
 Modules/CPackWIX.cmake                             |    6 +-
 Modules/CTest.cmake                                |    3 -
 Modules/CTestCoverageCollectGCOV.cmake             |  146 +-
 Modules/CheckForPthreads.c                         |   21 +-
 Modules/CheckFunctionExists.c                      |   20 +-
 Modules/CheckVariableExists.c                      |   16 +-
 Modules/Compiler/Bruce-C-DetermineCompiler.cmake   |    1 +
 Modules/Compiler/Bruce-C.cmake                     |    7 +
 Modules/Compiler/Clang-CXX-TestableFeatures.cmake  |    4 +-
 Modules/Compiler/GHS-C.cmake                       |    3 +
 Modules/Compiler/GHS-CXX.cmake                     |    3 +
 Modules/Compiler/GHS.cmake                         |    8 +
 Modules/Compiler/GNU.cmake                         |    4 +-
 Modules/Compiler/IAR-C.cmake                       |    3 +
 Modules/Compiler/IAR-CXX.cmake                     |    3 +-
 Modules/Compiler/Intel-C-FeatureTests.cmake        |   23 +
 Modules/Compiler/Intel-C.cmake                     |   58 +-
 Modules/Compiler/Intel-CXX-FeatureTests.cmake      |   96 +
 Modules/Compiler/Intel-CXX.cmake                   |   66 +-
 Modules/Compiler/MSVC-CXX-FeatureTests.cmake       |    5 +-
 Modules/Compiler/QCC.cmake                         |    2 +-
 Modules/Compiler/TI-C.cmake                        |    2 +-
 Modules/CompilerId/VS-6.dsp.in                     |   48 -
 Modules/DartConfiguration.tcl.in                   |    1 +
 Modules/ExternalProject-download.cmake.in          |  161 +
 Modules/ExternalProject-verify.cmake.in            |   48 +
 Modules/ExternalProject.cmake                      |  244 +-
 Modules/FindBISON.cmake                            |    8 +-
 Modules/FindBLAS.cmake                             |   31 +-
 Modules/FindBoost.cmake                            |  114 +-
 Modules/FindCUDA.cmake                             |   26 +-
 Modules/FindCUDA/make2cmake.cmake                  |   18 +-
 Modules/FindCUDA/run_nvcc.cmake                    |    1 +
 Modules/FindFLEX.cmake                             |    4 +-
 Modules/FindGTest.cmake                            |    4 +-
 Modules/FindGit.cmake                              |    6 +-
 Modules/FindHDF5.cmake                             |  657 +-
 Modules/FindJNI.cmake                              |   18 +-
 Modules/FindJava.cmake                             |    2 +-
 Modules/FindLAPACK.cmake                           |   36 +-
 Modules/FindLTTngUST.cmake                         |  111 +
 Modules/FindLibArchive.cmake                       |    9 +-
 Modules/FindLua.cmake                              |    1 +
 Modules/FindMPI.cmake                              |   42 +-
 Modules/FindMatlab.cmake                           |    3 +-
 Modules/FindOpenSSL.cmake                          |   10 +
 Modules/FindPNG.cmake                              |    4 +-
 Modules/FindPkgConfig.cmake                        |   86 +-
 Modules/FindProtobuf.cmake                         |  234 +-
 Modules/FindQt4.cmake                              |    2 +
 Modules/FindSDL_image.cmake                        |    4 +-
 Modules/FindSDL_mixer.cmake                        |    4 +-
 Modules/FindSDL_net.cmake                          |    4 +-
 Modules/FindSDL_ttf.cmake                          |    4 +-
 Modules/FindSubversion.cmake                       |    2 +-
 Modules/FindThreads.cmake                          |    2 +-
 Modules/FindwxWidgets.cmake                        |   30 +
 Modules/FortranCInterface.cmake                    |  313 +-
 Modules/FortranCInterface/my_module_.c             |    4 +-
 Modules/FortranCInterface/mymodule_.c              |    4 +-
 Modules/GenerateExportHeader.cmake                 |    4 +-
 Modules/GetPrerequisites.cmake                     |   22 +-
 Modules/InstallRequiredSystemLibraries.cmake       |   25 +-
 Modules/MacOSXBundleInfo.plist.in                  |    2 -
 Modules/Platform/AIX.cmake                         |    4 +-
 Modules/Platform/CYGWIN-Clang-C.cmake              |    1 +
 Modules/Platform/CYGWIN-Clang-CXX.cmake            |    1 +
 Modules/Platform/Darwin-Clang.cmake                |    2 +-
 Modules/Platform/Darwin-Initialize.cmake           |   10 -
 Modules/Platform/GHS-MULTI-Initialize.cmake        |    2 +-
 Modules/Platform/HP-UX.cmake                       |    4 +-
 Modules/Platform/SunOS-PathScale-C.cmake           |    2 +
 Modules/Platform/SunOS-PathScale-CXX.cmake         |    2 +
 Modules/Platform/SunOS-PathScale-Fortran.cmake     |    2 +
 Modules/Platform/SunOS-PathScale.cmake             |   31 +
 Modules/Platform/Windows-Intel-Fortran.cmake       |    6 +-
 Modules/Platform/Windows-MSVC.cmake                |   34 +-
 Modules/Platform/Windows-df.cmake                  |    3 -
 Modules/TestBigEndian.cmake                        |    2 +-
 Modules/TestForANSIStreamHeaders.cxx               |    2 +-
 Modules/TestForAnsiForScope.cxx                    |    5 +-
 Modules/TestForSSTREAM.cxx                         |    7 +-
 Modules/TestForSTDNamespace.cxx                    |    2 +-
 Modules/UseJava.cmake                              |    6 +-
 Modules/WriteCompilerDetectionHeader.cmake         |    5 +-
 Modules/exportheader.cmake.in                      |    7 +-
 Packaging/CMakeDMGSetup.scpt                       |   19 +-
 README.rst                                         |    2 +-
 Source/.gitattributes                              |    3 +
 Source/CMakeLists.txt                              |    5 +-
 Source/CMakeVersion.cmake                          |    4 +-
 Source/CPack/IFW/cmCPackIFWGenerator.cxx           |  604 +-
 Source/CPack/IFW/cmCPackIFWGenerator.h             |   47 +-
 Source/CPack/IFW/cmCPackIFWInstaller.cxx           |  499 +-
 Source/CPack/IFW/cmCPackIFWInstaller.h             |   35 +-
 Source/CPack/IFW/cmCPackIFWPackage.cxx             |  479 +-
 Source/CPack/IFW/cmCPackIFWPackage.h               |   52 +-
 Source/CPack/IFW/cmCPackIFWRepository.cxx          |  341 ++
 Source/CPack/IFW/cmCPackIFWRepository.h            |  105 +
 Source/CPack/OSXScriptLauncher.cxx                 |   96 +-
 Source/CPack/WiX/cmCPackWIXGenerator.cxx           |  843 ++-
 Source/CPack/WiX/cmCPackWIXGenerator.h             |   89 +-
 Source/CPack/WiX/cmWIXAccessControlList.cxx        |   77 +-
 Source/CPack/WiX/cmWIXAccessControlList.h          |   18 +-
 Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx  |   29 +-
 Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h    |    6 +-
 Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx     |   43 +-
 Source/CPack/WiX/cmWIXFeaturesSourceWriter.h       |    9 +-
 Source/CPack/WiX/cmWIXFilesSourceWriter.cxx        |   73 +-
 Source/CPack/WiX/cmWIXFilesSourceWriter.h          |   40 +-
 Source/CPack/WiX/cmWIXPatch.cxx                    |   88 +-
 Source/CPack/WiX/cmWIXPatch.h                      |    7 +-
 Source/CPack/WiX/cmWIXPatchParser.cxx              |  133 +-
 Source/CPack/WiX/cmWIXPatchParser.h                |   10 +-
 Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx     |  126 +-
 Source/CPack/WiX/cmWIXRichTextFormatWriter.h       |    2 +
 Source/CPack/WiX/cmWIXShortcut.cxx                 |   78 +-
 Source/CPack/WiX/cmWIXShortcut.h                   |   27 +-
 Source/CPack/WiX/cmWIXSourceWriter.cxx             |  178 +-
 Source/CPack/WiX/cmWIXSourceWriter.h               |   24 +-
 Source/CPack/cmCPack7zGenerator.cxx                |    5 +-
 Source/CPack/cmCPackArchiveGenerator.cxx           |  258 +-
 Source/CPack/cmCPackArchiveGenerator.h             |    7 +-
 Source/CPack/cmCPackBundleGenerator.cxx            |  195 +-
 Source/CPack/cmCPackComponentGroup.cxx             |   24 +-
 Source/CPack/cmCPackComponentGroup.h               |   29 +-
 Source/CPack/cmCPackCygwinBinaryGenerator.cxx      |   37 +-
 Source/CPack/cmCPackCygwinBinaryGenerator.h        |    1 +
 Source/CPack/cmCPackCygwinSourceGenerator.cxx      |   88 +-
 Source/CPack/cmCPackCygwinSourceGenerator.h        |    1 +
 Source/CPack/cmCPackDebGenerator.cxx               |  811 ++-
 Source/CPack/cmCPackDebGenerator.h                 |   15 +-
 Source/CPack/cmCPackDragNDropGenerator.cxx         |  794 +--
 Source/CPack/cmCPackDragNDropGenerator.h           |   14 +-
 Source/CPack/cmCPackGenerator.cxx                  | 1428 ++---
 Source/CPack/cmCPackGenerator.h                    |   55 +-
 Source/CPack/cmCPackGeneratorFactory.cxx           |  193 +-
 Source/CPack/cmCPackGeneratorFactory.h             |    8 +-
 Source/CPack/cmCPackLog.cxx                        |  185 +-
 Source/CPack/cmCPackLog.h                          |   47 +-
 Source/CPack/cmCPackNSISGenerator.cxx              |  903 ++-
 Source/CPack/cmCPackNSISGenerator.h                |   31 +-
 Source/CPack/cmCPackOSXX11Generator.cxx            |  211 +-
 Source/CPack/cmCPackOSXX11Generator.h              |    5 +-
 Source/CPack/cmCPackPackageMakerGenerator.cxx      |  791 +--
 Source/CPack/cmCPackPackageMakerGenerator.h        |   19 +-
 Source/CPack/cmCPackRPMGenerator.cxx               |  252 +-
 Source/CPack/cmCPackRPMGenerator.h                 |   13 +-
 Source/CPack/cmCPackSTGZGenerator.cxx              |   74 +-
 Source/CPack/cmCPackSTGZGenerator.h                |    1 -
 Source/CPack/cmCPackTGZGenerator.cxx               |    6 +-
 Source/CPack/cmCPackTGZGenerator.h                 |    1 +
 Source/CPack/cmCPackTXZGenerator.cxx               |    5 +-
 Source/CPack/cmCPackTXZGenerator.h                 |    1 +
 Source/CPack/cmCPackTarBZip2Generator.cxx          |    7 +-
 Source/CPack/cmCPackTarBZip2Generator.h            |    1 +
 Source/CPack/cmCPackTarCompressGenerator.cxx       |    6 +-
 Source/CPack/cmCPackZIPGenerator.cxx               |    6 +-
 Source/CPack/cpack.cxx                             |  401 +-
 Source/CTest/cmCTestBZR.cxx                        |  415 +-
 Source/CTest/cmCTestBZR.h                          |    2 +-
 Source/CTest/cmCTestBatchTestHandler.cxx           |   70 +-
 Source/CTest/cmCTestBatchTestHandler.h             |    4 +-
 Source/CTest/cmCTestBuildAndTestHandler.cxx        |  440 +-
 Source/CTest/cmCTestBuildAndTestHandler.h          |   39 +-
 Source/CTest/cmCTestBuildCommand.cxx               |  154 +-
 Source/CTest/cmCTestBuildCommand.h                 |   13 +-
 Source/CTest/cmCTestBuildHandler.cxx               |  970 ++-
 Source/CTest/cmCTestBuildHandler.h                 |   83 +-
 Source/CTest/cmCTestCVS.cxx                        |  205 +-
 Source/CTest/cmCTestCVS.h                          |    6 +-
 Source/CTest/cmCTestCommand.h                      |   12 +-
 Source/CTest/cmCTestConfigureCommand.cxx           |  107 +-
 Source/CTest/cmCTestConfigureCommand.h             |   10 +-
 Source/CTest/cmCTestConfigureHandler.cxx           |   92 +-
 Source/CTest/cmCTestConfigureHandler.h             |    2 +-
 Source/CTest/cmCTestCoverageCommand.cxx            |   33 +-
 Source/CTest/cmCTestCoverageCommand.h              |    9 +-
 Source/CTest/cmCTestCoverageHandler.cxx            | 2269 +++----
 Source/CTest/cmCTestCoverageHandler.h              |   40 +-
 Source/CTest/cmCTestCurl.cxx                       |  183 +-
 Source/CTest/cmCTestCurl.h                         |   15 +-
 .../CTest/cmCTestEmptyBinaryDirectoryCommand.cxx   |   16 +-
 Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h  |   18 +-
 Source/CTest/cmCTestGIT.cxx                        |  505 +-
 Source/CTest/cmCTestGIT.h                          |    5 +-
 Source/CTest/cmCTestGenericHandler.cxx             |  119 +-
 Source/CTest/cmCTestGenericHandler.h               |   32 +-
 Source/CTest/cmCTestGlobalVC.cxx                   |   67 +-
 Source/CTest/cmCTestGlobalVC.h                     |   11 +-
 Source/CTest/cmCTestHG.cxx                         |  239 +-
 Source/CTest/cmCTestHG.h                           |    2 +-
 Source/CTest/cmCTestHandlerCommand.cxx             |  171 +-
 Source/CTest/cmCTestHandlerCommand.h               |   12 +-
 Source/CTest/cmCTestLaunch.cxx                     |  459 +-
 Source/CTest/cmCTestLaunch.h                       |    5 +-
 Source/CTest/cmCTestMemCheckCommand.cxx            |   33 +-
 Source/CTest/cmCTestMemCheckCommand.h              |    9 +-
 Source/CTest/cmCTestMemCheckHandler.cxx            | 1122 ++--
 Source/CTest/cmCTestMemCheckHandler.h              |   55 +-
 Source/CTest/cmCTestMultiProcessHandler.cxx        |  742 +--
 Source/CTest/cmCTestMultiProcessHandler.h          |   56 +-
 Source/CTest/cmCTestP4.cxx                         |  367 +-
 Source/CTest/cmCTestP4.h                           |   19 +-
 Source/CTest/cmCTestReadCustomFilesCommand.cxx     |   20 +-
 Source/CTest/cmCTestReadCustomFilesCommand.h       |   11 +-
 Source/CTest/cmCTestRunScriptCommand.cxx           |   42 +-
 Source/CTest/cmCTestRunScriptCommand.h             |   10 +-
 Source/CTest/cmCTestRunTest.cxx                    |  646 +-
 Source/CTest/cmCTestRunTest.h                      |   62 +-
 Source/CTest/cmCTestSVN.cxx                        |  405 +-
 Source/CTest/cmCTestSVN.h                          |   15 +-
 Source/CTest/cmCTestScriptHandler.cxx              |  725 +--
 Source/CTest/cmCTestScriptHandler.h                |   18 +-
 Source/CTest/cmCTestSleepCommand.cxx               |   26 +-
 Source/CTest/cmCTestSleepCommand.h                 |   11 +-
 Source/CTest/cmCTestStartCommand.cxx               |  132 +-
 Source/CTest/cmCTestStartCommand.h                 |   20 +-
 Source/CTest/cmCTestSubmitCommand.cxx              |  251 +-
 Source/CTest/cmCTestSubmitCommand.h                |   15 +-
 Source/CTest/cmCTestSubmitHandler.cxx              | 1535 +++--
 Source/CTest/cmCTestSubmitHandler.h                |   31 +-
 Source/CTest/cmCTestTestCommand.cxx                |  107 +-
 Source/CTest/cmCTestTestCommand.h                  |   11 +-
 Source/CTest/cmCTestTestHandler.cxx                | 1788 +++---
 Source/CTest/cmCTestTestHandler.h                  |  115 +-
 Source/CTest/cmCTestUpdateCommand.cxx              |  126 +-
 Source/CTest/cmCTestUpdateCommand.h                |    8 +-
 Source/CTest/cmCTestUpdateHandler.cxx              |  355 +-
 Source/CTest/cmCTestUpdateHandler.h                |   14 +-
 Source/CTest/cmCTestUploadCommand.cxx              |   42 +-
 Source/CTest/cmCTestUploadCommand.h                |   13 +-
 Source/CTest/cmCTestUploadHandler.cxx              |   38 +-
 Source/CTest/cmCTestVC.cxx                         |   87 +-
 Source/CTest/cmCTestVC.h                           |   39 +-
 Source/CTest/cmParseBlanketJSCoverage.cxx          |  146 +-
 Source/CTest/cmParseBlanketJSCoverage.h            |    7 +-
 Source/CTest/cmParseCacheCoverage.cxx              |  199 +-
 Source/CTest/cmParseCacheCoverage.h                |    8 +-
 Source/CTest/cmParseCoberturaCoverage.cxx          |  164 +-
 Source/CTest/cmParseCoberturaCoverage.h            |    5 +-
 Source/CTest/cmParseDelphiCoverage.cxx             |  229 +-
 Source/CTest/cmParseDelphiCoverage.h               |   31 +-
 Source/CTest/cmParseGTMCoverage.cxx                |  219 +-
 Source/CTest/cmParseGTMCoverage.h                  |   15 +-
 Source/CTest/cmParseJacocoCoverage.cxx             |  296 +-
 Source/CTest/cmParseJacocoCoverage.h               |   14 +-
 Source/CTest/cmParseMumpsCoverage.cxx              |  124 +-
 Source/CTest/cmParseMumpsCoverage.h                |    9 +-
 Source/CTest/cmParsePHPCoverage.cxx                |  187 +-
 Source/CTest/cmParsePHPCoverage.h                  |    6 +-
 Source/CTest/cmProcess.cxx                         |  194 +-
 Source/CTest/cmProcess.h                           |   27 +-
 Source/Checks/cm_c11_thread_local.c                |    5 +-
 Source/Checks/cm_cxx11_unordered_map.cpp           |    3 +-
 Source/Checks/cm_cxx14_cstdio.cpp                  |    5 +-
 Source/CursesDialog/ccmake.cxx                     |  156 +-
 Source/CursesDialog/cmCursesBoolWidget.cxx         |   50 +-
 Source/CursesDialog/cmCursesBoolWidget.h           |    2 +-
 .../CursesDialog/cmCursesCacheEntryComposite.cxx   |   94 +-
 Source/CursesDialog/cmCursesCacheEntryComposite.h  |    5 +-
 Source/CursesDialog/cmCursesDummyWidget.cxx        |   10 +-
 Source/CursesDialog/cmCursesDummyWidget.h          |    1 -
 Source/CursesDialog/cmCursesFilePathWidget.cxx     |    7 +-
 Source/CursesDialog/cmCursesFilePathWidget.h       |    1 -
 Source/CursesDialog/cmCursesForm.cxx               |   15 +-
 Source/CursesDialog/cmCursesForm.h                 |    9 +-
 Source/CursesDialog/cmCursesLabelWidget.cxx        |   15 +-
 Source/CursesDialog/cmCursesLabelWidget.h          |    1 -
 Source/CursesDialog/cmCursesLongMessageForm.cxx    |  138 +-
 Source/CursesDialog/cmCursesLongMessageForm.h      |    5 +-
 Source/CursesDialog/cmCursesMainForm.cxx           | 1151 ++--
 Source/CursesDialog/cmCursesMainForm.h             |   22 +-
 Source/CursesDialog/cmCursesOptionsWidget.cxx      |   62 +-
 Source/CursesDialog/cmCursesOptionsWidget.h        |    4 +-
 Source/CursesDialog/cmCursesPathWidget.cxx         |   54 +-
 Source/CursesDialog/cmCursesStandardIncludes.h     |   12 +-
 Source/CursesDialog/cmCursesStringWidget.cxx       |  169 +-
 Source/CursesDialog/cmCursesWidget.cxx             |   23 +-
 Source/CursesDialog/cmCursesWidget.h               |   21 +-
 Source/CursesDialog/form/fld_def.c                 |    4 +-
 Source/CursesDialog/form/fld_ftlink.c              |    2 +-
 Source/CursesDialog/form/fld_newftyp.c             |    2 +-
 Source/CursesDialog/form/form.priv.h               |    2 +-
 Source/CursesDialog/form/frm_def.c                 |    4 +-
 Source/CursesDialog/form/frm_driver.c              |    4 +-
 Source/QtDialog/AddCacheEntry.cxx                  |   67 +-
 Source/QtDialog/AddCacheEntry.h                    |   10 +-
 Source/QtDialog/CMakeSetup.cxx                     |  219 +-
 Source/QtDialog/CMakeSetupDialog.cxx               |  822 ++-
 Source/QtDialog/CMakeSetupDialog.h                 |   17 +-
 Source/QtDialog/Compilers.h                        |    6 +-
 Source/QtDialog/FirstConfigure.cxx                 |  187 +-
 Source/QtDialog/FirstConfigure.h                   |  175 +-
 Source/QtDialog/QCMake.cxx                         |  238 +-
 Source/QtDialog/QCMake.h                           |   46 +-
 Source/QtDialog/QCMakeCacheView.cxx                |  402 +-
 Source/QtDialog/QCMakeCacheView.h                  |   62 +-
 Source/QtDialog/QCMakeWidgets.cxx                  |   62 +-
 Source/QtDialog/QCMakeWidgets.h                    |   12 +-
 Source/QtDialog/RegexExplorer.cxx                  |   80 +-
 Source/QtDialog/RegexExplorer.h                    |    4 +-
 Source/QtDialog/WarningMessagesDialog.cxx          |   27 +-
 Source/QtDialog/WarningMessagesDialog.h            |    2 +-
 Source/bindexplib.cxx                              |    6 +-
 Source/cmAddCompileOptionsCommand.cxx              |   16 +-
 Source/cmAddCompileOptionsCommand.h                |    9 +-
 Source/cmAddCustomCommandCommand.cxx               |  396 +-
 Source/cmAddCustomCommandCommand.h                 |   11 +-
 Source/cmAddCustomTargetCommand.cxx                |  167 +-
 Source/cmAddCustomTargetCommand.h                  |   10 +-
 Source/cmAddDefinitionsCommand.cxx                 |   17 +-
 Source/cmAddDefinitionsCommand.h                   |   11 +-
 Source/cmAddDependenciesCommand.cxx                |   28 +-
 Source/cmAddDependenciesCommand.h                  |   10 +-
 Source/cmAddExecutableCommand.cxx                  |  204 +-
 Source/cmAddExecutableCommand.h                    |   10 +-
 Source/cmAddLibraryCommand.cxx                     |  341 +-
 Source/cmAddLibraryCommand.h                       |   10 +-
 Source/cmAddSubDirectoryCommand.cxx                |   75 +-
 Source/cmAddSubDirectoryCommand.h                  |   11 +-
 Source/cmAddTestCommand.cxx                        |  102 +-
 Source/cmAddTestCommand.h                          |   11 +-
 Source/cmAlgorithms.h                              |  231 +-
 Source/cmArchiveWrite.cxx                          |  265 +-
 Source/cmArchiveWrite.h                            |   63 +-
 Source/cmAuxSourceDirectoryCommand.cxx             |   57 +-
 Source/cmAuxSourceDirectoryCommand.h               |   11 +-
 Source/cmBootstrapCommands1.cxx                    |    6 +-
 Source/cmBootstrapCommands2.cxx                    |    6 +-
 Source/cmBreakCommand.cxx                          |   37 +-
 Source/cmBreakCommand.h                            |   11 +-
 Source/cmBuildCommand.cxx                          |  120 +-
 Source/cmBuildCommand.h                            |   10 +-
 Source/cmBuildNameCommand.cxx                      |   71 +-
 Source/cmBuildNameCommand.h                        |    6 +-
 Source/cmCLocaleEnvironmentScope.cxx               |   25 +-
 Source/cmCMakeHostSystemInformationCommand.cxx     |   81 +-
 Source/cmCMakeHostSystemInformationCommand.h       |   28 +-
 Source/cmCMakeMinimumRequired.cxx                  |   89 +-
 Source/cmCMakeMinimumRequired.h                    |   11 +-
 Source/cmCMakePolicyCommand.cxx                    |  133 +-
 Source/cmCMakePolicyCommand.h                      |   24 +-
 Source/cmCPackPropertiesGenerator.cxx              |   42 +-
 Source/cmCPackPropertiesGenerator.h                |   14 +-
 Source/cmCPluginAPI.cxx                            |  639 +-
 Source/cmCPluginAPI.h                              |  237 +-
 Source/cmCTest.cxx                                 | 2754 ++++-----
 Source/cmCTest.h                                   |  251 +-
 Source/cmCacheManager.cxx                          |  498 +-
 Source/cmCacheManager.h                            |   93 +-
 Source/cmCallVisualStudioMacro.cxx                 |  335 +-
 Source/cmCallVisualStudioMacro.h                   |    4 +-
 Source/cmCommand.h                                 |   74 +-
 Source/cmCommandArgumentParserHelper.cxx           |  278 +-
 Source/cmCommandArgumentParserHelper.h             |   13 +-
 Source/cmCommandArgumentsHelper.cxx                |  210 +-
 Source/cmCommandArgumentsHelper.h                  |  237 +-
 Source/cmCommands.h                                |    2 +-
 Source/cmCommonTargetGenerator.cxx                 |  326 +-
 Source/cmCommonTargetGenerator.h                   |   15 +-
 Source/cmComputeComponentGraph.cxx                 |   65 +-
 Source/cmComputeComponentGraph.h                   |   18 +-
 Source/cmComputeLinkDepends.cxx                    |  486 +-
 Source/cmComputeLinkDepends.h                      |   42 +-
 Source/cmComputeLinkInformation.cxx                | 1147 ++--
 Source/cmComputeLinkInformation.h                  |   32 +-
 Source/cmComputeTargetDepends.cxx                  |  461 +-
 Source/cmComputeTargetDepends.h                    |   17 +-
 Source/cmConditionEvaluator.cxx                    |  799 +--
 Source/cmConditionEvaluator.h                      |  104 +-
 Source/cmConfigureFileCommand.cxx                  |  101 +-
 Source/cmConfigureFileCommand.h                    |   11 +-
 Source/cmContinueCommand.cxx                       |   14 +-
 Source/cmContinueCommand.h                         |    9 +-
 Source/cmCoreTryCompile.cxx                        |  704 +--
 Source/cmCoreTryCompile.h                          |   11 +-
 Source/cmCreateTestSourceList.cxx                  |  130 +-
 Source/cmCreateTestSourceList.h                    |   11 +-
 Source/cmCryptoHash.cxx                            |  102 +-
 Source/cmCryptoHash.h                              |   35 +-
 Source/cmCurl.cxx                                  |   59 +-
 Source/cmCurl.h                                    |    6 +-
 Source/cmCustomCommand.cxx                         |   58 +-
 Source/cmCustomCommand.h                           |   12 +-
 Source/cmCustomCommandGenerator.cxx                |  129 +-
 Source/cmCustomCommandGenerator.h                  |    5 +-
 Source/cmDefinePropertyCommand.cxx                 |  111 +-
 Source/cmDefinePropertyCommand.h                   |   12 +-
 Source/cmDefinitions.cxx                           |  101 +-
 Source/cmDefinitions.h                             |   51 +-
 Source/cmDepends.cxx                               |  212 +-
 Source/cmDepends.h                                 |   29 +-
 Source/cmDependsC.cxx                              |  456 +-
 Source/cmDependsC.h                                |   18 +-
 Source/cmDependsFortran.cxx                        |  535 +-
 Source/cmDependsFortran.h                          |   21 +-
 Source/cmDependsJava.cxx                           |   13 +-
 Source/cmDependsJava.h                             |   17 +-
 Source/cmDependsJavaParserHelper.cxx               |  335 +-
 Source/cmDependsJavaParserHelper.h                 |   44 +-
 Source/cmDocumentation.cxx                         |  654 +-
 Source/cmDocumentation.h                           |   51 +-
 Source/cmDocumentationFormatter.cxx                |  169 +-
 Source/cmDocumentationFormatter.h                  |   22 +-
 Source/cmDocumentationSection.cxx                  |   30 +-
 Source/cmDocumentationSection.h                    |   39 +-
 Source/cmDynamicLoader.cxx                         |   54 +-
 Source/cmDynamicLoader.h                           |    3 +-
 Source/cmELF.cxx                                   |  724 ++-
 Source/cmELF.h                                     |    7 +-
 Source/cmElseCommand.cxx                           |    2 +-
 Source/cmElseCommand.h                             |   10 +-
 Source/cmElseIfCommand.cxx                         |    2 +-
 Source/cmElseIfCommand.h                           |   10 +-
 Source/cmEnableLanguageCommand.cxx                 |   26 +-
 Source/cmEnableLanguageCommand.h                   |   11 +-
 Source/cmEnableTestingCommand.cxx                  |    4 +-
 Source/cmEnableTestingCommand.h                    |   11 +-
 Source/cmEndForEachCommand.cxx                     |    6 +-
 Source/cmEndForEachCommand.h                       |   16 +-
 Source/cmEndFunctionCommand.cxx                    |    6 +-
 Source/cmEndFunctionCommand.h                      |   16 +-
 Source/cmEndIfCommand.cxx                          |   13 +-
 Source/cmEndIfCommand.h                            |   10 +-
 Source/cmEndMacroCommand.cxx                       |    6 +-
 Source/cmEndMacroCommand.h                         |   16 +-
 Source/cmEndWhileCommand.cxx                       |   15 +-
 Source/cmEndWhileCommand.h                         |   16 +-
 Source/cmExecProgramCommand.cxx                    |  222 +-
 Source/cmExecProgramCommand.h                      |   16 +-
 Source/cmExecuteProcessCommand.cxx                 |  319 +-
 Source/cmExecuteProcessCommand.h                   |   10 +-
 Source/cmExecutionStatus.h                         |   22 +-
 Source/cmExpandedCommandArgument.cxx               |   15 +-
 Source/cmExpandedCommandArgument.h                 |    2 +-
 Source/cmExportBuildFileGenerator.cxx              |  293 +-
 Source/cmExportBuildFileGenerator.h                |   26 +-
 Source/cmExportCommand.cxx                         |  298 +-
 Source/cmExportCommand.h                           |   20 +-
 Source/cmExportFileGenerator.cxx                   |  986 ++-
 Source/cmExportFileGenerator.h                     |  121 +-
 Source/cmExportInstallFileGenerator.cxx            |  414 +-
 Source/cmExportInstallFileGenerator.h              |   23 +-
 Source/cmExportLibraryDependenciesCommand.cxx      |  130 +-
 Source/cmExportLibraryDependenciesCommand.h        |    5 +-
 Source/cmExportSet.cxx                             |    8 +-
 Source/cmExportSet.h                               |   14 +-
 Source/cmExportSetMap.cxx                          |    9 +-
 Source/cmExportSetMap.h                            |    4 +-
 Source/cmExportTryCompileFileGenerator.cxx         |  107 +-
 Source/cmExportTryCompileFileGenerator.h           |   20 +-
 Source/cmExprParserHelper.cxx                      |   63 +-
 Source/cmExprParserHelper.h                        |    6 +-
 Source/cmExternalMakefileProjectGenerator.cxx      |   50 +-
 Source/cmExternalMakefileProjectGenerator.h        |   15 +-
 Source/cmExtraCodeBlocksGenerator.cxx              |  793 ++-
 Source/cmExtraCodeBlocksGenerator.h                |   29 +-
 Source/cmExtraCodeLiteGenerator.cxx                |  515 +-
 Source/cmExtraCodeLiteGenerator.h                  |   15 +-
 Source/cmExtraEclipseCDT4Generator.cxx             | 1585 +++--
 Source/cmExtraEclipseCDT4Generator.h               |   82 +-
 Source/cmExtraKateGenerator.cxx                    |  283 +-
 Source/cmExtraKateGenerator.h                      |   20 +-
 Source/cmExtraSublimeTextGenerator.cxx             |  376 +-
 Source/cmExtraSublimeTextGenerator.h               |   36 +-
 Source/cmFLTKWrapUICommand.cxx                     |   75 +-
 Source/cmFLTKWrapUICommand.h                       |   13 +-
 Source/cmFileCommand.cxx                           | 3032 ++++-----
 Source/cmFileCommand.h                             |   17 +-
 Source/cmFileLock.cxx                              |   42 +-
 Source/cmFileLock.h                                |    6 +-
 Source/cmFileLockPool.cxx                          |  105 +-
 Source/cmFileLockPool.h                            |   28 +-
 Source/cmFileLockResult.cxx                        |   36 +-
 Source/cmFileLockResult.h                          |    6 +-
 Source/cmFileLockUnix.cxx                          |   65 +-
 Source/cmFileLockWin32.cxx                         |   85 +-
 Source/cmFileTimeComparison.cxx                    |  189 +-
 Source/cmFileTimeComparison.h                      |    3 -
 Source/cmFindBase.cxx                              |  280 +-
 Source/cmFindBase.h                                |    3 +-
 Source/cmFindCommon.cxx                            |  277 +-
 Source/cmFindCommon.h                              |   23 +-
 Source/cmFindFileCommand.cxx                       |    1 +
 Source/cmFindFileCommand.h                         |    9 +-
 Source/cmFindLibraryCommand.cxx                    |  341 +-
 Source/cmFindLibraryCommand.h                      |   16 +-
 Source/cmFindPackageCommand.cxx                    | 1787 +++---
 Source/cmFindPackageCommand.h                      |   34 +-
 Source/cmFindPathCommand.cxx                       |  148 +-
 Source/cmFindPathCommand.h                         |   13 +-
 Source/cmFindProgramCommand.cxx                    |  196 +-
 Source/cmFindProgramCommand.h                      |   12 +-
 Source/cmForEachCommand.cxx                        |  212 +-
 Source/cmForEachCommand.h                          |   20 +-
 Source/cmFortranLexer.cxx                          |    2 +-
 Source/cmFortranLexer.in.l                         |    2 +-
 Source/cmFortranParser.h                           |   73 +-
 Source/cmFortranParserImpl.cxx                     |  244 +-
 Source/cmFunctionBlocker.h                         |   21 +-
 Source/cmFunctionCommand.cxx                       |  113 +-
 Source/cmFunctionCommand.h                         |   20 +-
 Source/cmGeneratedFileStream.cxx                   |  134 +-
 Source/cmGeneratedFileStream.h                     |   11 +-
 Source/cmGeneratorExpression.cxx                   |  382 +-
 Source/cmGeneratorExpression.h                     |   72 +-
 Source/cmGeneratorExpressionContext.cxx            |   33 +-
 Source/cmGeneratorExpressionContext.h              |    8 +-
 Source/cmGeneratorExpressionDAGChecker.cxx         |  221 +-
 Source/cmGeneratorExpressionDAGChecker.h           |   64 +-
 Source/cmGeneratorExpressionEvaluationFile.cxx     |  164 +-
 Source/cmGeneratorExpressionEvaluationFile.h       |   19 +-
 Source/cmGeneratorExpressionEvaluator.cxx          |  264 +-
 Source/cmGeneratorExpressionEvaluator.h            |   76 +-
 Source/cmGeneratorExpressionLexer.cxx              |   48 +-
 Source/cmGeneratorExpressionLexer.h                |   12 +-
 Source/cmGeneratorExpressionNode.cxx               | 1621 +++--
 Source/cmGeneratorExpressionNode.h                 |   36 +-
 Source/cmGeneratorExpressionParser.cxx             |  241 +-
 Source/cmGeneratorExpressionParser.h               |   10 +-
 Source/cmGeneratorTarget.cxx                       | 4886 ++++++---------
 Source/cmGeneratorTarget.h                         |  250 +-
 Source/cmGetCMakePropertyCommand.cxx               |   50 +-
 Source/cmGetCMakePropertyCommand.h                 |   11 +-
 Source/cmGetDirectoryPropertyCommand.cxx           |   84 +-
 Source/cmGetDirectoryPropertyCommand.h             |    9 +-
 Source/cmGetFilenameComponentCommand.cxx           |  122 +-
 Source/cmGetFilenameComponentCommand.h             |   11 +-
 Source/cmGetPropertyCommand.cxx                    |  346 +-
 Source/cmGetPropertyCommand.h                      |   19 +-
 Source/cmGetSourceFilePropertyCommand.cxx          |   35 +-
 Source/cmGetSourceFilePropertyCommand.h            |   11 +-
 Source/cmGetTargetPropertyCommand.cxx              |   58 +-
 Source/cmGetTargetPropertyCommand.h                |   11 +-
 Source/cmGetTestPropertyCommand.cxx                |   29 +-
 Source/cmGetTestPropertyCommand.h                  |   11 +-
 Source/cmGhsMultiGpj.cxx                           |    9 +-
 Source/cmGhsMultiGpj.h                             |    4 +-
 Source/cmGhsMultiTargetGenerator.cxx               |  564 +-
 Source/cmGhsMultiTargetGenerator.h                 |   94 +-
 Source/cmGlobalBorlandMakefileGenerator.cxx        |   20 +-
 Source/cmGlobalBorlandMakefileGenerator.h          |   22 +-
 Source/cmGlobalCommonGenerator.cxx                 |    4 +-
 Source/cmGlobalGenerator.cxx                       | 2124 +++----
 Source/cmGlobalGenerator.h                         |  222 +-
 Source/cmGlobalGeneratorFactory.h                  |   29 +-
 Source/cmGlobalGhsMultiGenerator.cxx               |  316 +-
 Source/cmGlobalGhsMultiGenerator.h                 |   92 +-
 Source/cmGlobalJOMMakefileGenerator.cxx            |   25 +-
 Source/cmGlobalJOMMakefileGenerator.h              |   20 +-
 Source/cmGlobalKdevelopGenerator.cxx               |  846 ++-
 Source/cmGlobalKdevelopGenerator.h                 |   11 +-
 Source/cmGlobalMSYSMakefileGenerator.cxx           |   53 +-
 Source/cmGlobalMSYSMakefileGenerator.h             |   19 +-
 Source/cmGlobalMinGWMakefileGenerator.cxx          |   27 +-
 Source/cmGlobalMinGWMakefileGenerator.h            |   20 +-
 Source/cmGlobalNMakeMakefileGenerator.cxx          |   25 +-
 Source/cmGlobalNMakeMakefileGenerator.h            |   21 +-
 Source/cmGlobalNinjaGenerator.cxx                  | 1068 ++--
 Source/cmGlobalNinjaGenerator.h                    |  213 +-
 Source/cmGlobalUnixMakefileGenerator3.cxx          |  899 ++-
 Source/cmGlobalUnixMakefileGenerator3.h            |   98 +-
 Source/cmGlobalVisualStudio10Generator.cxx         |  414 +-
 Source/cmGlobalVisualStudio10Generator.h           |   55 +-
 Source/cmGlobalVisualStudio11Generator.cxx         |  257 +-
 Source/cmGlobalVisualStudio11Generator.h           |    7 +-
 Source/cmGlobalVisualStudio12Generator.cxx         |  202 +-
 Source/cmGlobalVisualStudio12Generator.h           |   12 +-
 Source/cmGlobalVisualStudio14Generator.cxx         |  211 +-
 Source/cmGlobalVisualStudio14Generator.h           |    6 +-
 Source/cmGlobalVisualStudio6Generator.cxx          |  451 --
 Source/cmGlobalVisualStudio6Generator.h            |  113 -
 Source/cmGlobalVisualStudio71Generator.cxx         |  190 +-
 Source/cmGlobalVisualStudio71Generator.h           |   37 +-
 Source/cmGlobalVisualStudio7Generator.cxx          |  828 +--
 Source/cmGlobalVisualStudio7Generator.h            |   90 +-
 Source/cmGlobalVisualStudio8Generator.cxx          |  462 +-
 Source/cmGlobalVisualStudio8Generator.h            |   26 +-
 Source/cmGlobalVisualStudio9Generator.cxx          |   95 +-
 Source/cmGlobalVisualStudio9Generator.h            |    7 +-
 Source/cmGlobalVisualStudioGenerator.cxx           |  715 +--
 Source/cmGlobalVisualStudioGenerator.h             |   62 +-
 Source/cmGlobalWatcomWMakeGenerator.cxx            |   12 +-
 Source/cmGlobalWatcomWMakeGenerator.h              |   19 +-
 Source/cmGlobalXCodeGenerator.cxx                  | 3376 ++++------
 Source/cmGlobalXCodeGenerator.h                    |  119 +-
 Source/cmGraphAdjacencyList.h                      |   36 +-
 Source/cmGraphVizWriter.cxx                        |  437 +-
 Source/cmGraphVizWriter.h                          |   10 +-
 Source/cmHexFileConverter.cxx                      |  205 +-
 Source/cmHexFileConverter.h                        |    9 +-
 Source/cmIDEFlagTable.h                            |   30 +-
 Source/cmIDEOptions.cxx                            |  132 +-
 Source/cmIDEOptions.h                              |   21 +-
 Source/cmIfCommand.cxx                             |  174 +-
 Source/cmIfCommand.h                               |   32 +-
 Source/cmIncludeCommand.cxx                        |  150 +-
 Source/cmIncludeCommand.h                          |   11 +-
 Source/cmIncludeDirectoryCommand.cxx               |  101 +-
 Source/cmIncludeDirectoryCommand.h                 |   15 +-
 Source/cmIncludeExternalMSProjectCommand.cxx       |   84 +-
 Source/cmIncludeExternalMSProjectCommand.h         |   11 +-
 Source/cmIncludeRegularExpressionCommand.cxx       |   15 +-
 Source/cmIncludeRegularExpressionCommand.h         |   11 +-
 Source/cmInstallCommand.cxx                        | 1183 ++--
 Source/cmInstallCommand.h                          |   10 +-
 Source/cmInstallCommandArguments.cxx               |  184 +-
 Source/cmInstallCommandArguments.h                 |  109 +-
 Source/cmInstallDirectoryGenerator.cxx             |  103 +-
 Source/cmInstallDirectoryGenerator.h               |   13 +-
 Source/cmInstallExportGenerator.cxx                |  144 +-
 Source/cmInstallExportGenerator.h                  |   18 +-
 Source/cmInstallFilesCommand.cxx                   |  113 +-
 Source/cmInstallFilesCommand.h                     |   12 +-
 Source/cmInstallFilesGenerator.cxx                 |  105 +-
 Source/cmInstallFilesGenerator.h                   |   10 +-
 Source/cmInstallGenerator.cxx                      |  248 +-
 Source/cmInstallGenerator.h                        |   29 +-
 Source/cmInstallProgramsCommand.cxx                |   82 +-
 Source/cmInstallProgramsCommand.h                  |   11 +-
 Source/cmInstallScriptGenerator.cxx                |   30 +-
 Source/cmInstallScriptGenerator.h                  |    4 +-
 Source/cmInstallTargetGenerator.cxx                |  623 +-
 Source/cmInstallTargetGenerator.h                  |   25 +-
 Source/cmInstallTargetsCommand.cxx                 |   38 +-
 Source/cmInstallTargetsCommand.h                   |   10 +-
 Source/cmInstalledFile.cxx                         |   56 +-
 Source/cmInstalledFile.h                           |   14 +-
 Source/cmLinkDirectoriesCommand.cxx                |   32 +-
 Source/cmLinkDirectoriesCommand.h                  |   12 +-
 Source/cmLinkItem.h                                |  108 +-
 Source/cmLinkLibrariesCommand.cxx                  |   40 +-
 Source/cmLinkLibrariesCommand.h                    |   11 +-
 Source/cmLinkedTree.h                              |   50 +-
 Source/cmListCommand.cxx                           |  433 +-
 Source/cmListCommand.h                             |   16 +-
 Source/cmListFileCache.cxx                         |  461 +-
 Source/cmListFileCache.h                           |  112 +-
 Source/cmListFileLexer.c                           | 2020 +++---
 Source/cmListFileLexer.h                           |    6 +-
 Source/cmListFileLexer.in.l                        |  273 +-
 Source/cmLoadCacheCommand.cxx                      |  140 +-
 Source/cmLoadCacheCommand.h                        |   12 +-
 Source/cmLoadCommandCommand.cxx                    |  198 +-
 Source/cmLoadCommandCommand.h                      |    6 +-
 Source/cmLocalCommonGenerator.cxx                  |   13 +-
 Source/cmLocalCommonGenerator.h                    |    2 +-
 Source/cmLocalGenerator.cxx                        | 2290 +++----
 Source/cmLocalGenerator.h                          |  129 +-
 Source/cmLocalGhsMultiGenerator.cxx                |   21 +-
 Source/cmLocalNinjaGenerator.cxx                   |  305 +-
 Source/cmLocalNinjaGenerator.h                     |   45 +-
 Source/cmLocalUnixMakefileGenerator3.cxx           | 1860 +++---
 Source/cmLocalUnixMakefileGenerator3.h             |  152 +-
 Source/cmLocalVisualStudio10Generator.cxx          |  113 +-
 Source/cmLocalVisualStudio10Generator.h            |    2 -
 Source/cmLocalVisualStudio6Generator.cxx           | 2002 ------
 Source/cmLocalVisualStudio6Generator.h             |  105 -
 Source/cmLocalVisualStudio7Generator.cxx           | 2314 ++++---
 Source/cmLocalVisualStudio7Generator.h             |   56 +-
 Source/cmLocalVisualStudioGenerator.cxx            |  113 +-
 Source/cmLocalVisualStudioGenerator.h              |   15 +-
 Source/cmLocalXCodeGenerator.cxx                   |   45 +-
 Source/cmLocalXCodeGenerator.h                     |   14 +-
 Source/cmLocale.h                                  |   15 +-
 Source/cmMachO.cxx                                 |  267 +-
 Source/cmMachO.h                                   |    2 +-
 Source/cmMacroCommand.cxx                          |  138 +-
 Source/cmMacroCommand.h                            |   20 +-
 Source/cmMakeDirectoryCommand.cxx                  |   25 +-
 Source/cmMakeDirectoryCommand.h                    |   11 +-
 Source/cmMakefile.cxx                              | 3564 +++++------
 Source/cmMakefile.h                                |  352 +-
 Source/cmMakefileExecutableTargetGenerator.cxx     |  418 +-
 Source/cmMakefileExecutableTargetGenerator.h       |    2 +-
 Source/cmMakefileLibraryTargetGenerator.cxx        |  807 ++-
 Source/cmMakefileLibraryTargetGenerator.h          |    9 +-
 Source/cmMakefileTargetGenerator.cxx               | 1388 ++---
 Source/cmMakefileTargetGenerator.h                 |   59 +-
 Source/cmMakefileUtilityTargetGenerator.cxx        |   64 +-
 Source/cmMakefileUtilityTargetGenerator.h          |    4 +-
 Source/cmMarkAsAdvancedCommand.cxx                 |   42 +-
 Source/cmMarkAsAdvancedCommand.h                   |   11 +-
 Source/cmMathCommand.cxx                           |   32 +-
 Source/cmMathCommand.h                             |   13 +-
 Source/cmMessageCommand.cxx                        |   82 +-
 Source/cmMessageCommand.h                          |   10 +-
 Source/cmNewLineStyle.cxx                          |   41 +-
 Source/cmNewLineStyle.h                            |   11 +-
 Source/cmNinjaNormalTargetGenerator.cxx            |  622 +-
 Source/cmNinjaNormalTargetGenerator.h              |   10 +-
 Source/cmNinjaTargetGenerator.cxx                  |  601 +-
 Source/cmNinjaTargetGenerator.h                    |   57 +-
 Source/cmNinjaTypes.h                              |    4 +-
 Source/cmNinjaUtilityTargetGenerator.cxx           |  101 +-
 Source/cmNinjaUtilityTargetGenerator.h             |    7 +-
 Source/cmOSXBundleGenerator.cxx                    |  112 +-
 Source/cmOSXBundleGenerator.h                      |   14 +-
 Source/cmObject.h                                  |    7 +-
 Source/cmOptionCommand.cxx                         |   39 +-
 Source/cmOptionCommand.h                           |   11 +-
 Source/cmOrderDirectories.cxx                      |  400 +-
 Source/cmOrderDirectories.h                        |    5 +-
 Source/cmOutputConverter.cxx                       |  750 +--
 Source/cmOutputConverter.h                         |   58 +-
 Source/cmOutputRequiredFilesCommand.cxx            |  430 +-
 Source/cmOutputRequiredFilesCommand.h              |   12 +-
 Source/cmParseArgumentsCommand.cxx                 |  130 +-
 Source/cmParseArgumentsCommand.h                   |   11 +-
 Source/cmPathLabel.cxx                             |   15 +-
 Source/cmPathLabel.h                               |    4 +-
 Source/cmPolicies.cxx                              |  307 +-
 Source/cmPolicies.h                                |  435 +-
 Source/cmProcessTools.cxx                          |   60 +-
 Source/cmProcessTools.h                            |   22 +-
 Source/cmProjectCommand.cxx                        |  192 +-
 Source/cmProjectCommand.h                          |   11 +-
 Source/cmProperty.cxx                              |   17 +-
 Source/cmProperty.h                                |   20 +-
 Source/cmPropertyDefinition.cxx                    |   22 +-
 Source/cmPropertyDefinition.h                      |   20 +-
 Source/cmPropertyDefinitionMap.cxx                 |   32 +-
 Source/cmPropertyDefinitionMap.h                   |   10 +-
 Source/cmPropertyMap.cxx                           |   43 +-
 Source/cmPropertyMap.h                             |   11 +-
 Source/cmQTWrapCPPCommand.cxx                      |   68 +-
 Source/cmQTWrapCPPCommand.h                        |   11 +-
 Source/cmQTWrapUICommand.cxx                       |   89 +-
 Source/cmQTWrapUICommand.h                         |   11 +-
 Source/cmQtAutoGeneratorInitializer.cxx            | 1021 ++--
 Source/cmQtAutoGeneratorInitializer.h              |    2 +-
 Source/cmQtAutoGenerators.cxx                      | 1761 +++---
 Source/cmQtAutoGenerators.h                        |   94 +-
 Source/cmRST.cxx                                   |  399 +-
 Source/cmRST.h                                     |    2 +
 Source/cmRemoveCommand.cxx                         |   39 +-
 Source/cmRemoveCommand.h                           |   11 +-
 Source/cmRemoveDefinitionsCommand.cxx              |   17 +-
 Source/cmRemoveDefinitionsCommand.h                |   11 +-
 Source/cmReturnCommand.cxx                         |    3 +-
 Source/cmReturnCommand.h                           |   11 +-
 Source/cmScriptGenerator.cxx                       |  145 +-
 Source/cmScriptGenerator.h                         |   22 +-
 Source/cmSearchPath.cxx                            |  178 +-
 Source/cmSearchPath.h                              |    8 +-
 Source/cmSeparateArgumentsCommand.cxx              |   89 +-
 Source/cmSeparateArgumentsCommand.h                |   11 +-
 Source/cmSetCommand.cxx                            |  122 +-
 Source/cmSetCommand.h                              |   11 +-
 Source/cmSetDirectoryPropertiesCommand.cxx         |   56 +-
 Source/cmSetDirectoryPropertiesCommand.h           |   15 +-
 Source/cmSetPropertyCommand.cxx                    |  408 +-
 Source/cmSetPropertyCommand.h                      |   11 +-
 Source/cmSetSourceFilesPropertiesCommand.cxx       |  136 +-
 Source/cmSetSourceFilesPropertiesCommand.h         |   15 +-
 Source/cmSetTargetPropertiesCommand.cxx            |   78 +-
 Source/cmSetTargetPropertiesCommand.h              |   15 +-
 Source/cmSetTestsPropertiesCommand.cxx             |   73 +-
 Source/cmSetTestsPropertiesCommand.h               |   16 +-
 Source/cmSiteNameCommand.cxx                       |   69 +-
 Source/cmSiteNameCommand.h                         |   11 +-
 Source/cmSourceFile.cxx                            |  231 +-
 Source/cmSourceFile.h                              |   16 +-
 Source/cmSourceFileLocation.cxx                    |  231 +-
 Source/cmSourceFileLocation.h                      |    2 +-
 Source/cmSourceGroup.cxx                           |   86 +-
 Source/cmSourceGroup.h                             |   12 +-
 Source/cmSourceGroupCommand.cxx                    |   63 +-
 Source/cmSourceGroupCommand.h                      |   11 +-
 Source/cmStandardIncludes.h                        |  101 +-
 Source/cmStandardLexer.h                           |   30 +-
 Source/cmState.cxx                                 | 1272 ++--
 Source/cmState.h                                   |  118 +-
 Source/cmStringCommand.cxx                         |  763 +--
 Source/cmStringCommand.h                           |   34 +-
 Source/cmSubdirCommand.cxx                         |   57 +-
 Source/cmSubdirCommand.h                           |   11 +-
 Source/cmSubdirDependsCommand.cxx                  |    7 +-
 Source/cmSubdirDependsCommand.h                    |    4 +-
 Source/cmSystemTools.cxx                           | 2389 +++-----
 Source/cmSystemTools.h                             |  139 +-
 Source/cmTarget.cxx                                | 1556 ++---
 Source/cmTarget.h                                  |  238 +-
 Source/cmTargetCompileDefinitionsCommand.cxx       |   46 +-
 Source/cmTargetCompileDefinitionsCommand.h         |   19 +-
 Source/cmTargetCompileFeaturesCommand.cxx          |   39 +-
 Source/cmTargetCompileFeaturesCommand.h            |   19 +-
 Source/cmTargetCompileOptionsCommand.cxx           |   29 +-
 Source/cmTargetCompileOptionsCommand.h             |   19 +-
 Source/cmTargetDepend.h                            |   26 +-
 Source/cmTargetIncludeDirectoriesCommand.cxx       |   90 +-
 Source/cmTargetIncludeDirectoriesCommand.h         |   26 +-
 Source/cmTargetLinkLibrariesCommand.cxx            |  435 +-
 Source/cmTargetLinkLibrariesCommand.h              |   15 +-
 Source/cmTargetPropCommandBase.cxx                 |  161 +-
 Source/cmTargetPropCommandBase.h                   |   31 +-
 Source/cmTargetSourcesCommand.cxx                  |   30 +-
 Source/cmTargetSourcesCommand.h                    |   20 +-
 Source/cmTest.cxx                                  |   32 +-
 Source/cmTest.h                                    |   22 +-
 Source/cmTestGenerator.cxx                         |  125 +-
 Source/cmTestGenerator.h                           |    6 +-
 Source/cmTimestamp.cxx                             |  136 +-
 Source/cmTimestamp.h                               |   17 +-
 Source/cmTryCompileCommand.cxx                     |   31 +-
 Source/cmTryCompileCommand.h                       |   11 +-
 Source/cmTryRunCommand.cxx                         |  294 +-
 Source/cmTryRunCommand.h                           |   11 +-
 Source/cmUnsetCommand.cxx                          |   39 +-
 Source/cmUnsetCommand.h                            |   11 +-
 Source/cmUseMangledMesaCommand.cxx                 |   84 +-
 Source/cmUseMangledMesaCommand.h                   |    7 +-
 Source/cmUtilitySourceCommand.cxx                  |  111 +-
 Source/cmUtilitySourceCommand.h                    |    4 +-
 Source/cmUuid.cxx                                  |  114 +-
 Source/cmUuid.h                                    |   14 +-
 Source/cmVS10CLFlagTable.h                         |  464 +-
 Source/cmVS10LibFlagTable.h                        |  154 +-
 Source/cmVS10LinkFlagTable.h                       |  531 +-
 Source/cmVS10MASMFlagTable.h                       |  144 +-
 Source/cmVS10RCFlagTable.h                         |    9 +-
 Source/cmVS11CLFlagTable.h                         |  497 +-
 Source/cmVS11LibFlagTable.h                        |  154 +-
 Source/cmVS11LinkFlagTable.h                       |  556 +-
 Source/cmVS11MASMFlagTable.h                       |  144 +-
 Source/cmVS11RCFlagTable.h                         |    9 +-
 Source/cmVS12CLFlagTable.h                         |  505 +-
 Source/cmVS12LibFlagTable.h                        |  154 +-
 Source/cmVS12LinkFlagTable.h                       |  556 +-
 Source/cmVS12MASMFlagTable.h                       |  144 +-
 Source/cmVS12RCFlagTable.h                         |    9 +-
 Source/cmVS14CLFlagTable.h                         |  523 +-
 Source/cmVS14LibFlagTable.h                        |  154 +-
 Source/cmVS14LinkFlagTable.h                       |  560 +-
 Source/cmVS14MASMFlagTable.h                       |  144 +-
 Source/cmVS14RCFlagTable.h                         |    9 +-
 Source/cmVariableRequiresCommand.cxx               |   55 +-
 Source/cmVariableRequiresCommand.h                 |    5 +-
 Source/cmVariableWatch.cxx                         |   80 +-
 Source/cmVariableWatch.h                           |   36 +-
 Source/cmVariableWatchCommand.cxx                  |  102 +-
 Source/cmVariableWatchCommand.h                    |   12 +-
 Source/cmVersion.cxx                               |   20 +-
 Source/cmVersion.h                                 |    9 +-
 Source/cmVersionMacros.h                           |    2 +-
 Source/cmVisualStudio10TargetGenerator.cxx         | 2988 ++++-----
 Source/cmVisualStudio10TargetGenerator.h           |   28 +-
 Source/cmVisualStudioGeneratorOptions.cxx          |  310 +-
 Source/cmVisualStudioGeneratorOptions.h            |   16 +-
 Source/cmVisualStudioSlnData.cxx                   |   26 +-
 Source/cmVisualStudioSlnData.h                     |   19 +-
 Source/cmVisualStudioSlnParser.cxx                 |  394 +-
 Source/cmVisualStudioSlnParser.h                   |   20 +-
 Source/cmVisualStudioWCEPlatformParser.cxx         |  115 +-
 Source/cmVisualStudioWCEPlatformParser.h           |   32 +-
 Source/cmWhileCommand.cxx                          |  127 +-
 Source/cmWhileCommand.h                            |   25 +-
 Source/cmWriteFileCommand.cxx                      |   58 +-
 Source/cmWriteFileCommand.h                        |   10 +-
 Source/cmXCode21Object.cxx                         |   57 +-
 Source/cmXCode21Object.h                           |    6 +-
 Source/cmXCodeObject.cxx                           |  280 +-
 Source/cmXCodeObject.h                             |  189 +-
 Source/cmXMLParser.cxx                             |  114 +-
 Source/cmXMLParser.h                               |   27 +-
 Source/cmXMLSafe.cxx                               |   79 +-
 Source/cmXMLSafe.h                                 |    4 +-
 Source/cmXMLWriter.cxx                             |   49 +-
 Source/cmXMLWriter.h                               |   41 +-
 Source/cm_get_date.h                               |    2 +-
 Source/cm_utf8.c                                   |   68 +-
 Source/cmake.cxx                                   | 2328 +++----
 Source/cmake.h                                     |  354 +-
 Source/cmakemain.cxx                               |  380 +-
 Source/cmakexbuild.cxx                             |   54 +-
 Source/cmcldeps.cxx                                |  136 +-
 Source/cmcmd.cxx                                   | 1376 ++---
 Source/cmcmd.h                                     |    3 +-
 Source/ctest.cxx                                   |  244 +-
 Source/kwsys/CommandLineArguments.cxx              |    1 +
 Source/kwsys/MD5.c                                 |    8 +-
 Source/kwsys/Process.h.in                          |    7 +
 Source/kwsys/ProcessUNIX.c                         |   13 +
 Source/kwsys/ProcessWin32.c                        |   15 +-
 Source/kwsys/RegularExpression.cxx                 |    2 +-
 Source/kwsys/RegularExpression.hxx.in              |    4 +-
 Source/kwsys/SystemInformation.cxx                 |   60 +-
 Source/kwsys/SystemTools.cxx                       |  113 +-
 Source/kwsys/testDynamicLoader.cxx                 |    2 +-
 Source/kwsys/testEncoding.cxx                      |    2 +-
 Source/kwsys/testHashSTL.cxx                       |    1 -
 Source/kwsys/testIOS.cxx                           |    6 +
 Templates/AppleInfo.plist                          |    2 -
 Templates/CMakeVisualStudio6Configurations.cmake   |    3 -
 Templates/DLLFooter.dsptemplate                    |    4 -
 Templates/DLLHeader.dsptemplate                    |  192 -
 Templates/EXEFooter.dsptemplate                    |    4 -
 Templates/EXEHeader.dsptemplate                    |  183 -
 Templates/EXEWinHeader.dsptemplate                 |  187 -
 Templates/UtilityFooter.dsptemplate                |    2 -
 Templates/UtilityHeader.dsptemplate                |   95 -
 Templates/staticLibFooter.dsptemplate              |    4 -
 Templates/staticLibHeader.dsptemplate              |  173 -
 Tests/AliasTarget/CMakeLists.txt                   |    7 +
 Tests/AliasTarget/bat.cpp                          |    2 +-
 Tests/AliasTarget/commandgenerator.cpp             |    2 +-
 Tests/AliasTarget/empty.cpp                        |    2 +-
 Tests/AliasTarget/object.h                         |    2 +-
 Tests/AliasTarget/subdir/empty.cpp                 |    2 +-
 Tests/AliasTarget/targetgenerator.cpp              |    2 +-
 Tests/Architecture/bar.c                           |    5 +-
 Tests/Architecture/foo.c                           |    5 +-
 Tests/Assembler/main.c                             |    8 +-
 Tests/BuildDepends/CMakeLists.txt                  |    5 +-
 Tests/BuildDepends/Project/bar.cxx                 |    9 +-
 Tests/BuildDepends/Project/generator.cxx           |   17 +-
 .../Project/link_depends_no_shared_exe.c           |    2 +-
 .../Project/link_depends_no_shared_lib.c           |    2 +-
 Tests/BuildDepends/Project/ninjadep.cpp            |    5 +-
 Tests/BuildDepends/Project/object_depends.cxx      |    5 +-
 Tests/BuildDepends/Project/zot.cxx                 |    6 +-
 Tests/BundleGeneratorTest/Executable.cxx           |    1 -
 Tests/BundleGeneratorTest/Library.cxx              |    1 -
 Tests/BundleTest/BundleLib.cxx                     |   33 +-
 Tests/BundleTest/BundleTest.cxx                    |    8 +-
 Tests/BundleUtilities/framework.h                  |   12 +-
 Tests/BundleUtilities/module.cpp                   |    2 +-
 Tests/BundleUtilities/shared.h                     |   12 +-
 Tests/BundleUtilities/shared2.h                    |   12 +-
 Tests/BundleUtilities/testbundleutils1.cpp         |    7 +-
 Tests/BundleUtilities/testbundleutils2.cpp         |    7 +-
 Tests/BundleUtilities/testbundleutils3.cpp         |    7 +-
 Tests/CFBundleTest/Localized.rsrc                  |  Bin 496 -> 472 bytes
 Tests/CFBundleTest/np_macmain.cpp                  |   17 +-
 Tests/CMakeCommands/add_compile_options/main.cpp   |    6 +-
 .../target_compile_definitions/consumer.c          |   25 +-
 .../target_compile_definitions/consumer.cpp        |   29 +-
 .../target_compile_definitions/main.cpp            |    5 +-
 .../target_compile_features/dummy.cpp              |    2 +-
 .../target_compile_features/lib_restrict.c         |    2 +-
 .../target_compile_features/lib_restrict.h         |    2 +-
 .../target_compile_features/lib_user.cpp           |    2 +-
 Tests/CMakeCommands/target_compile_features/main.c |    2 +-
 .../CMakeCommands/target_compile_features/main.cpp |    2 +-
 .../target_compile_features/restrict_user.c        |    2 +-
 .../target_compile_options/consumer.c              |   25 +-
 .../target_compile_options/consumer.cpp            |   47 +-
 .../CMakeCommands/target_compile_options/main.cpp  |   23 +-
 .../target_include_directories/consumer.c          |   13 +-
 .../target_include_directories/consumer.cpp        |   17 +-
 .../target_include_directories/main.cpp            |    5 +-
 .../cmp0022/onlyplainlib1.cpp                      |    1 -
 .../target_link_libraries/cmp0022/onlyplainlib1.h  |    4 +-
 .../target_link_libraries/cmp0022/onlyplainlib2.h  |    2 +-
 .../cmp0022/onlyplainlib_user.cpp                  |    2 +-
 .../target_link_libraries/cmp0022/staticlib1.cpp   |    5 +-
 .../target_link_libraries/cmp0022/staticlib1.h     |    2 +-
 .../target_link_libraries/cmp0022/staticlib2.cpp   |    5 +-
 .../target_link_libraries/cmp0022/staticlib2.h     |    2 +-
 Tests/CMakeCommands/target_link_libraries/depC.h   |    1 -
 .../target_link_libraries/newsignature1.cpp        |    2 +-
 .../target_link_libraries/targetA.cpp              |    2 +-
 .../target_link_libraries/targetB.cpp              |    2 +-
 .../target_link_libraries/targetC.cpp              |    4 +-
 Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in     |    2 +-
 Tests/CMakeLib/run_compile_commands.cxx            |   88 +-
 Tests/CMakeLib/testGeneratedFileStream.cxx         |  102 +-
 Tests/CMakeLib/testRST.cxx                         |   66 +-
 Tests/CMakeLib/testSystemTools.cxx                 |   15 +-
 Tests/CMakeLib/testUTF8.cxx                        |   73 +-
 Tests/CMakeLib/testVisualStudioSlnParser.cxx       |  216 +-
 Tests/CMakeLib/testXMLParser.cxx                   |    7 +-
 Tests/CMakeLib/testXMLSafe.cxx                     |   22 +-
 Tests/CMakeLists.txt                               |   44 +-
 Tests/CMakeOnly/AllFindModules/CMakeLists.txt      |    4 +-
 Tests/CMakeOnly/CheckStructHasMember/cm_cshm.h     |    5 +-
 Tests/CMakeOnly/CheckStructHasMember/cm_cshm.hxx   |    9 +-
 Tests/CMakeOnly/LinkInterfaceLoop/lib.c            |    5 +-
 Tests/CMakeOnly/LinkInterfaceLoop/main.c           |    5 +-
 Tests/CMakeTests/PushCheckStateTest.cmake.in       |   57 +-
 Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake   |   22 +
 Tests/CMakeTests/StringTest.cmake.in               |    6 +
 Tests/COnly/conly.c                                |   12 +-
 Tests/COnly/libc2.h                                |   12 +-
 Tests/COnly/testCModule.c                          |    9 +-
 Tests/CPackComponentsDEB/CMakeLists.txt            |    2 +
 .../MyLibCPackConfig-components-depend1.cmake.in   |    1 +
 .../MyLibCPackConfig-components-depend2.cmake.in   |    1 +
 .../RunCPackVerifyResult-components-depend1.cmake  |    6 +-
 .../RunCPackVerifyResult-components-depend2.cmake  |    6 +-
 ...CPackVerifyResult-components-description1.cmake |    2 +-
 ...CPackVerifyResult-components-description2.cmake |    2 +-
 ...yResult-components-lintian-dpkgdeb-checks.cmake |    2 +-
 ...unCPackVerifyResult-components-shlibdeps1.cmake |    2 +-
 .../RunCPackVerifyResult-components-source.cmake   |    2 +-
 .../RunCPackVerifyResult-compression.cmake         |    2 +-
 Tests/CPackComponentsForAll/CMakeLists.txt         |    6 +
 .../MyLibCPackConfig-IgnoreGroup.cmake.in          |   26 +-
 .../MyLibCPackConfig-OnePackPerGroup.cmake.in      |    2 +-
 .../RunCPackVerifyResult.cmake                     |   39 +-
 Tests/CPackWiXGenerator/myotherapp.cpp             |    4 +-
 Tests/CTestConfig/CTestConfig.cxx                  |    3 +-
 .../TestProject/3rdparty/foo.cpp                   |    4 +-
 .../TestProject/extra/extra.cpp                    |    4 +-
 .../TestProject/extra/uncovered1.cpp}              |    0
 .../CTestCoverageCollectGCOV/TestProject/main.cpp  |    4 +-
 .../TestProject/uncovered2.cpp}                    |    0
 Tests/CTestCoverageCollectGCOV/test.cmake.in       |    4 +
 Tests/CTestTest/SmallAndFast/echoargs.c            |    3 +-
 .../SmallAndFast/intentional_compile_warning.cxx   |    6 +-
 Tests/CTestTestCostSerial/sleep.c                  |    4 +-
 Tests/CTestTestCrash/crash.cxx                     |    2 +-
 Tests/CTestTestFailure/badCode.cxx                 |    2 +-
 Tests/CTestTestFdSetSize/sleep.c                   |    4 +-
 Tests/CTestTestParallel/lockFile.c                 |    5 +-
 Tests/CTestTestResourceLock/lockFile.c             |   16 +-
 Tests/CTestTestScheduler/sleep.c                   |    9 +-
 Tests/CTestTestStopTime/sleep.c                    |    9 +-
 Tests/CTestTestTimeout/sleep.c                     |    8 +-
 Tests/CTestTestUpload/sleep.c                      |    9 +-
 Tests/CTestTestZeroTimeout/sleep.c                 |    4 +-
 Tests/CompatibleInterface/bar.cpp                  |    2 +-
 Tests/CompatibleInterface/main.cpp                 |   15 +-
 .../compile_command_output.cxx                     |    2 +-
 .../CompileCommandOutput/file_with_underscores.cxx |    4 +-
 Tests/CompileCommandOutput/relative.cxx            |    4 +-
 Tests/CompileCommandOutput/relative.h              |   12 +-
 Tests/CompileDefinitions/CMakeLists.txt            |    5 -
 Tests/CompileDefinitions/compiletest.cpp           |   64 +-
 Tests/CompileDefinitions/compiletest_mixed_c.c     |    1 -
 Tests/CompileDefinitions/compiletest_mixed_cxx.cpp |    2 +-
 Tests/CompileDefinitions/runtest.c                 |   31 +-
 Tests/CompileDefinitions/target_prop/usetgt.c      |   11 +-
 Tests/CompileFeatures/CMakeLists.txt               |   82 +
 Tests/CompileFeatures/c_restrict.c                 |    2 +-
 .../cxx_aggregate_default_initializers.cpp         |    5 +-
 Tests/CompileFeatures/cxx_alias_templates.cpp      |    2 +-
 Tests/CompileFeatures/cxx_alignas.cpp              |    3 +-
 Tests/CompileFeatures/cxx_attribute_deprecated.cpp |    3 +-
 Tests/CompileFeatures/cxx_attributes.cpp           |    5 +-
 .../CompileFeatures/cxx_contextual_conversions.cpp |   37 +-
 .../cxx_decltype_incomplete_return_types.cpp       |   17 +-
 .../cxx_default_function_template_args.cpp         |    2 +-
 Tests/CompileFeatures/cxx_defaulted_functions.cpp  |    3 +-
 .../cxx_delegating_constructors.cpp                |    1 -
 Tests/CompileFeatures/cxx_digit_separators.cpp     |    3 +-
 Tests/CompileFeatures/cxx_explicit_conversions.cpp |    6 +-
 .../cxx_extended_friend_declarations.cpp           |    8 +-
 Tests/CompileFeatures/cxx_extern_templates.cpp     |    2 +-
 Tests/CompileFeatures/cxx_final.cpp                |    4 +-
 .../cxx_generalized_initializers.cpp               |   23 +-
 .../cxx_inheriting_constructors.cpp                |    5 +-
 Tests/CompileFeatures/cxx_inline_namespaces.cpp    |   25 +-
 Tests/CompileFeatures/cxx_lambda_init_captures.cpp |    3 +-
 Tests/CompileFeatures/cxx_lambdas.cpp              |    2 +-
 .../cxx_local_type_template_args.cpp               |   28 +-
 Tests/CompileFeatures/cxx_noexcept.cpp             |    1 -
 Tests/CompileFeatures/cxx_nullptr.cpp              |    1 -
 Tests/CompileFeatures/cxx_override.cpp             |    6 +-
 Tests/CompileFeatures/cxx_range_for.cpp            |    5 +-
 .../cxx_reference_qualified_functions.cpp          |   12 +-
 Tests/CompileFeatures/cxx_relaxed_constexpr.cpp    |   10 +-
 .../CompileFeatures/cxx_return_type_deduction.cpp  |    2 +-
 Tests/CompileFeatures/cxx_right_angle_brackets.cpp |    4 +-
 Tests/CompileFeatures/cxx_rvalue_references.cpp    |    1 -
 .../cxx_template_template_parameters.cpp           |    6 +-
 Tests/CompileFeatures/cxx_unicode_literals.cpp     |    2 +
 .../CompileFeatures/cxx_uniform_initialization.cpp |    9 +-
 Tests/CompileFeatures/cxx_unrestricted_unions.cpp  |   12 +-
 Tests/CompileFeatures/cxx_user_literals.cpp        |    2 +-
 Tests/CompileFeatures/cxx_variable_templates.cpp   |    2 +-
 Tests/CompileFeatures/cxx_variadic_templates.cpp   |   58 +-
 Tests/CompileFeatures/default_dialect.c            |   24 +-
 Tests/CompileFeatures/default_dialect.cpp          |   21 +-
 Tests/CompileFeatures/genex_test.c                 |   21 +-
 Tests/CompileFeatures/genex_test.cpp               |   47 +-
 Tests/CompileFeatures/main.cpp                     |    2 +-
 Tests/CompileOptions/main.cpp                      |   24 +-
 Tests/CompileOptions/other.cpp                     |    1 -
 Tests/Complex/CMakeLists.txt                       |    7 +
 Tests/Complex/Executable/A.h                       |    5 +-
 Tests/Complex/Executable/CMakeLists.txt            |    3 +-
 Tests/Complex/Executable/complex.cxx               |  442 +-
 Tests/Complex/Executable/complex.file.cxx          |    2 +-
 Tests/Complex/Executable/notInAllExe.cxx           |    2 +-
 Tests/Complex/Executable/testSystemDir.cxx         |    5 +-
 Tests/Complex/Executable/testcflags.c              |    4 +-
 Tests/Complex/Library/SystemDir/testSystemDir.h    |    5 +-
 Tests/Complex/Library/create_file.cxx              |   19 +-
 Tests/Complex/Library/notInAllLib.cxx              |    7 +-
 Tests/Complex/Library/sharedFile.h                 |    4 +-
 Tests/Complex/Library/testConly.h                  |    5 +-
 Tests/ComplexOneConfig/CMakeLists.txt              |    7 +
 Tests/ComplexOneConfig/Executable/A.h              |    5 +-
 Tests/ComplexOneConfig/Executable/CMakeLists.txt   |    3 +-
 Tests/ComplexOneConfig/Executable/complex.cxx      |  442 +-
 Tests/ComplexOneConfig/Executable/complex.file.cxx |    2 +-
 Tests/ComplexOneConfig/Executable/notInAllExe.cxx  |    2 +-
 .../ComplexOneConfig/Executable/testSystemDir.cxx  |    5 +-
 Tests/ComplexOneConfig/Executable/testcflags.c     |    4 +-
 .../Library/SystemDir/testSystemDir.h              |    5 +-
 Tests/ComplexOneConfig/Library/create_file.cxx     |   19 +-
 Tests/ComplexOneConfig/Library/notInAllLib.cxx     |    7 +-
 Tests/ComplexOneConfig/Library/sharedFile.h        |    4 +-
 Tests/ComplexOneConfig/Library/testConly.h         |    5 +-
 Tests/CustComDepend/bar.h                          |   12 +-
 Tests/CustComDepend/foo.cxx                        |    6 +-
 Tests/CustomCommand/gen_redirect_in.c              |    5 +-
 Tests/CustomCommand/generator.cxx                  |   15 +-
 Tests/CustomCommand/tcat.cxx                       |    5 +-
 Tests/CustomCommand/wrapper.cxx                    |   38 +-
 .../CustomCommandByproducts.c                      |   14 +-
 .../External/ExternalLibrary.c                     |    5 +-
 Tests/CustomCommandByproducts/ProducerExe.c        |    5 +-
 Tests/CxxOnly/cxxonly.cxx                          |   12 +-
 Tests/CxxOnly/libcxx2.h                            |   12 +-
 Tests/CxxOnly/testCxxModule.cxx                    |    9 +-
 Tests/CxxSubdirC/Cdir/Cobj.c                       |    5 +-
 Tests/CxxSubdirC/main.cxx                          |    5 +-
 Tests/Dependency/Case1/a.c                         |    3 +-
 Tests/Dependency/Case1/b.c                         |    2 +-
 Tests/Dependency/Case1/b2.c                        |    2 +-
 Tests/Dependency/Case1/c.c                         |    2 +-
 Tests/Dependency/Case1/c2.c                        |    2 +-
 Tests/Dependency/Case1/d.c                         |    3 +-
 Tests/Dependency/Case1/main.c                      |    6 +-
 Tests/Dependency/Case2/bar1.c                      |   10 +-
 Tests/Dependency/Case2/bar2.c                      |    5 +-
 Tests/Dependency/Case2/bar3.c                      |    5 +-
 Tests/Dependency/Case2/foo1.c                      |    5 +-
 Tests/Dependency/Case2/foo1b.c                     |    5 +-
 Tests/Dependency/Case2/foo1c.c                     |    5 +-
 Tests/Dependency/Case2/foo2.c                      |    5 +-
 Tests/Dependency/Case2/foo2b.c                     |    5 +-
 Tests/Dependency/Case2/foo2c.c                     |    5 +-
 Tests/Dependency/Case2/foo3.c                      |    5 +-
 Tests/Dependency/Case2/foo3b.c                     |    5 +-
 Tests/Dependency/Case2/foo3c.c                     |    5 +-
 Tests/Dependency/Case3/foo1.c                      |    5 +-
 Tests/Dependency/Case3/foo1b.c                     |    5 +-
 Tests/Dependency/Case3/foo2.c                      |    5 +-
 Tests/Dependency/Case4/bar.c                       |    5 +-
 Tests/Dependency/Case4/foo.c                       |    5 +-
 Tests/Dependency/Case5/bar.c                       |    2 +-
 Tests/Dependency/Case5/foo.c                       |    2 +-
 Tests/Dependency/Case5/main.c                      |    2 +-
 Tests/Dependency/Exec/ExecMain.c                   |    2 +-
 Tests/Dependency/Exec2/ExecMain.c                  |    2 +-
 Tests/Dependency/Exec3/ExecMain.c                  |    2 +-
 Tests/Dependency/Exec4/ExecMain.c                  |    2 +-
 Tests/Dependency/Four/FourSrc.c                    |    2 +-
 Tests/Dependency/Three/ThreeSrc.c                  |    2 +-
 Tests/Dependency/Two/TwoSrc.c                      |    2 +-
 Tests/EmptyProperty/EmptyProperty.cxx              |    5 +-
 Tests/Environment/main.cxx                         |    7 +-
 Tests/ExportImport/Export/CMakeLists.txt           |   10 +-
 .../Export/Interface/headeronly/headeronly.h       |    5 +-
 Tests/ExportImport/Export/empty.cpp                |    5 +-
 Tests/ExportImport/Export/systemlib.cpp            |    1 -
 Tests/ExportImport/Export/systemlib.h              |    4 +-
 Tests/ExportImport/Export/testExe1.c               |   22 +-
 Tests/ExportImport/Export/testExe1lib.c            |    5 +-
 Tests/ExportImport/Export/testExe2.c               |    9 +-
 Tests/ExportImport/Export/testExe2lib.c            |   13 +-
 Tests/ExportImport/Export/testExe2libImp.c         |    9 +-
 Tests/ExportImport/Export/testExe3.c               |   22 +-
 Tests/ExportImport/Export/testExe4.c               |   22 +-
 Tests/ExportImport/Export/testLib1.c               |    5 +-
 Tests/ExportImport/Export/testLib2.c               |    5 +-
 Tests/ExportImport/Export/testLib3.c               |   13 +-
 Tests/ExportImport/Export/testLib3Imp.c            |   13 +-
 Tests/ExportImport/Export/testLib3ImpDep.c         |    9 +-
 Tests/ExportImport/Export/testLib4.c               |    9 +-
 Tests/ExportImport/Export/testLib4libdbg1.c        |    1 -
 Tests/ExportImport/Export/testLib4libopt1.c        |    1 -
 Tests/ExportImport/Export/testLib5.c               |    9 +-
 Tests/ExportImport/Export/testLib7.c               |    5 +-
 Tests/ExportImport/Export/testLibAbs1.c            |    5 +-
 Tests/ExportImport/Export/testLibCycleA1.c         |    5 +-
 Tests/ExportImport/Export/testLibCycleA2.c         |    5 +-
 Tests/ExportImport/Export/testLibCycleA3.c         |    5 +-
 Tests/ExportImport/Export/testLibCycleB1.c         |    5 +-
 Tests/ExportImport/Export/testLibCycleB2.c         |    5 +-
 Tests/ExportImport/Export/testLibCycleB3.c         |    5 +-
 Tests/ExportImport/Export/testLibDepends.c         |    7 +-
 Tests/ExportImport/Export/testLibNoSONAME.c        |    9 +-
 Tests/ExportImport/Export/testLibPerConfigDest.c   |    5 +-
 Tests/ExportImport/Export/testLibRequired.c        |    5 +-
 Tests/ExportImport/Export/testSharedLibDepends.h   |    2 +-
 .../Export/testStaticLibRequiredPrivate.c          |    5 +-
 Tests/ExportImport/Import/A/deps_iface.c           |    1 -
 Tests/ExportImport/Import/A/deps_shared_iface.cpp  |    8 +-
 Tests/ExportImport/Import/A/imp_mod1.c             |    4 +-
 Tests/ExportImport/Import/A/imp_testExe1.c         |   12 +-
 Tests/ExportImport/Import/A/imp_testExeAbs1.c      |    8 +-
 Tests/ExportImport/Import/A/renamed_test.cpp       |    2 +-
 .../Import/Interface/headeronlytest.cpp            |    3 +-
 .../Import/Interface/interfacetest.cpp             |    2 +-
 Tests/ExternalProject/CMakeLists.txt               |   17 +
 Tests/ExternalProjectLocal/CMakeLists.txt          |   12 -
 Tests/ExternalProjectSubdir/CMakeLists.txt         |    7 +-
 Tests/ExternalProjectUpdate/CMakeLists.txt         |   12 +
 .../ExternalProjectUpdateTest.cmake                |    2 +-
 Tests/FindBoost/CMakeLists.txt                     |   11 +
 Tests/FindBoost/Test/main.cxx                      |   24 +-
 Tests/FindBoost/TestHeaders/CMakeLists.txt         |   10 +
 Tests/FindBoost/TestHeaders/main.cxx               |   10 +
 Tests/FindGSL/rng/main.cc                          |    8 +-
 Tests/FindGTK2/atk/main.c                          |    6 +-
 Tests/FindGTK2/atkmm/main.cpp                      |    6 +-
 Tests/FindGTK2/cairo/main.c                        |   86 +-
 Tests/FindGTK2/cairomm/main.cpp                    |   76 +-
 Tests/FindGTK2/gdk/main.c                          |    6 +-
 Tests/FindGTK2/gdk_pixbuf/main.c                   |   12 +-
 Tests/FindGTK2/gdkmm/main.cpp                      |    6 +-
 Tests/FindGTK2/gio/main.c                          |    8 +-
 Tests/FindGTK2/giomm/main.cpp                      |    6 +-
 Tests/FindGTK2/glib/main.c                         |   14 +-
 Tests/FindGTK2/glibmm/main.cpp                     |    4 +-
 Tests/FindGTK2/gmodule/main.c                      |    6 +-
 Tests/FindGTK2/gobject/main.c                      |   56 +-
 Tests/FindGTK2/gthread/main.c                      |    6 +-
 Tests/FindGTK2/gtk/main.c                          |   14 +-
 Tests/FindGTK2/gtkmm/CMakeLists.txt                |    5 +
 Tests/FindGTK2/gtkmm/helloworld.cpp                |   24 +-
 Tests/FindGTK2/gtkmm/helloworld.h                  |   12 +-
 Tests/FindGTK2/gtkmm/main.cpp                      |   14 +-
 Tests/FindGTK2/pango/main.c                        |    6 +-
 Tests/FindGTK2/pangocairo/main.c                   |  102 +-
 Tests/FindGTK2/pangoft2/main.c                     |    8 +-
 Tests/FindGTK2/pangomm/main.cpp                    |    6 +-
 Tests/FindGTK2/pangoxft/main.c                     |    6 +-
 Tests/FindGTK2/sigc++/main.cpp                     |   19 +-
 Tests/FindLTTngUST/CMakeLists.txt                  |   10 +
 Tests/FindLTTngUST/Test/CMakeLists.txt             |   18 +
 Tests/FindLTTngUST/Test/main.c                     |   31 +
 Tests/FindMatlab/matlab_wrapper1.cpp               |   15 +-
 Tests/FindModulesExecuteAll/main.c                 |    2 +-
 Tests/FindOpenSSL/rand/main.cc                     |    3 +-
 Tests/FindPNG/Test/main.c                          |   12 +-
 Tests/FindPackageModeMakefileTest/CMakeLists.txt   |    3 +-
 Tests/FindPackageModeMakefileTest/main.cpp         |    6 +-
 Tests/FindPackageTest/Exporter/dummy.c             |    5 +-
 Tests/FindTIFF/Test/main.c                         |    2 +-
 Tests/FindXalanC/Test/main.cxx                     |    2 +-
 Tests/ForceInclude/foo.c                           |    9 +-
 Tests/Fortran/CMakeLists.txt                       |    4 +-
 Tests/Fortran/include/test_preprocess.h            |    4 +-
 Tests/Framework/foo.cxx                            |    4 +-
 .../GeneratorExpression/CMP0044/cmp0044-check.cpp  |   18 +-
 Tests/GeneratorExpression/empty.cpp                |    5 +-
 Tests/GeneratorExpression/pwd.c                    |   12 +-
 Tests/GhsMulti/ReturnNum/App/Main.c                |    6 +-
 Tests/GhsMulti/ReturnNum/Lib/HelperFun.c           |    2 +-
 .../CMakeLists.txt                                 |   15 +
 Tests/GhsMultiDuplicateSourceFilenames/main.c      |   13 +
 .../subfolder/test.c                               |    5 +
 .../subfolder_test.c                               |    5 +
 .../subfolder_test_0.c                             |    5 +
 Tests/GhsMultiDuplicateSourceFilenames/test.c      |    5 +
 Tests/IncludeDirectories/CMP0021/main.cpp          |    2 +-
 Tests/IncludeDirectories/CMakeLists.txt            |    1 +
 .../StandardIncludeDirectories/CMakeLists.txt      |    5 +
 .../StandardIncludeDirectories/StdDir/StdIncDir.h} |    0
 .../StandardIncludeDirectories/main.c              |    5 +
 .../config_specific/config_iface.h                 |    2 +-
 .../SystemIncludeDirectories/systemlib.cpp         |    5 +-
 .../SystemIncludeDirectories/systemlib/systemlib.h |    4 +-
 .../SystemIncludeDirectories/upstream.cpp          |    5 +-
 .../SystemIncludeDirectories/upstream.h            |    2 +-
 .../TargetIncludeDirectories/empty.cpp             |    2 +-
 .../TargetIncludeDirectories/main.cpp              |   12 +-
 .../TargetIncludeDirectories/other.cpp             |    3 +-
 .../TargetIncludeDirectories/sing/ting/ting.h      |    2 +-
 Tests/IncludeDirectories/empty.cpp                 |    5 +-
 Tests/InterfaceLibrary/definetestexe.cpp           |    2 +-
 Tests/InterfaceLibrary/dummy.cpp                   |    2 +-
 Tests/InterfaceLibrary/ifacedir/sub.cpp            |    5 +-
 Tests/InterfaceLibrary/map_config.cpp              |    2 +-
 Tests/InterfaceLibrary/obj.cpp                     |    5 +-
 Tests/InterfaceLibrary/sharedlibtestexe.cpp        |    2 +-
 Tests/InterfaceLinkLibraries/bang.h                |    2 +-
 Tests/InterfaceLinkLibraries/bar.cpp               |   14 +-
 Tests/InterfaceLinkLibraries/bar.h                 |    2 +-
 Tests/InterfaceLinkLibraries/foo.h                 |    2 +-
 Tests/InterfaceLinkLibraries/zot.h                 |    2 +-
 Tests/JCTest/TestTime.cxx                          |    5 +-
 Tests/JavaJavah/B.cpp                              |    2 +-
 Tests/JavaJavah/C.cpp                              |    2 +-
 Tests/Jump/Executable/jumpExecutable.cxx           |    4 +-
 Tests/Jump/Library/Shared/jumpShared.cxx           |    9 +-
 Tests/Jump/Library/Static/jumpStatic.cxx           |    5 +-
 Tests/LibName/bar.c                                |    2 +-
 Tests/LibName/foo.c                                |    2 +-
 Tests/LibName/foobar.c                             |    2 +-
 Tests/LinkDirectory/External/myexe.c               |    5 +-
 Tests/LinkDirectory/mylibA.c                       |    5 +-
 Tests/LinkDirectory/mylibB.c                       |    5 +-
 Tests/LinkFlags/LinkFlags.c                        |    5 +-
 Tests/LinkFlags/LinkFlagsExe.c                     |    7 +-
 Tests/LinkFlags/LinkFlagsLib.c                     |    7 +-
 Tests/LinkLanguage/LinkLanguage.c                  |    1 -
 Tests/LinkLine/One.c                               |    2 +-
 Tests/LinkLine/Two.c                               |    2 +-
 Tests/LinkLineOrder/NoDepE.c                       |    2 +-
 Tests/LinkLineOrder/NoDepF.c                       |    2 +-
 Tests/LoadCommand/CMakeCommands/cmTestCommand.c    |  150 +-
 .../CMakeCommands/cmTestCommand.c                  |  150 +-
 Tests/MFC/mfc1/ChildFrm.cpp                        |   22 +-
 Tests/MFC/mfc1/ChildFrm.h                          |   28 +-
 Tests/MFC/mfc1/MainFrm.cpp                         |   81 +-
 Tests/MFC/mfc1/MainFrm.h                           |   35 +-
 Tests/MFC/mfc1/Resource.h                          |   18 +-
 Tests/MFC/mfc1/mfc1.cpp                            |  160 +-
 Tests/MFC/mfc1/mfc1.h                              |   18 +-
 Tests/MFC/mfc1/mfc1Doc.cpp                         |   38 +-
 Tests/MFC/mfc1/mfc1Doc.h                           |   32 +-
 Tests/MFC/mfc1/mfc1View.cpp                        |   48 +-
 Tests/MFC/mfc1/mfc1View.h                          |   45 +-
 Tests/MFC/mfc1/stdafx.h                            |   55 +-
 Tests/MSManifest/Subdir/main.c                     |    5 +-
 Tests/MacRuntimePath/A/framework.h                 |   12 +-
 Tests/MacRuntimePath/A/framework2.h                |   12 +-
 Tests/MacRuntimePath/A/shared.h                    |   12 +-
 Tests/MathTest/MathTestExec.cxx                    |   24 +-
 Tests/MissingInstall/mybin.cpp                     |    4 +-
 Tests/Module/CheckTypeSize/CheckTypeSize.c         |   81 +-
 Tests/Module/CheckTypeSize/CheckTypeSize.cxx       |   87 +-
 Tests/Module/CheckTypeSize/someclass.hxx           |   11 +-
 Tests/Module/CheckTypeSize/somestruct.h            |    9 +-
 Tests/Module/GenerateExportHeader/CMakeLists.txt   |   16 +-
 .../GenerateExportHeader/c_identifier/main.cpp     |    2 +-
 .../GenerateExportHeader/exportheader_test.cpp     |   53 +-
 .../lib_shared_and_static/libshared_and_static.cpp |   33 +-
 .../lib_shared_and_static/libshared_and_static.h   |   36 +-
 .../GenerateExportHeader/libshared/libshared.cpp   |   33 +-
 .../GenerateExportHeader/libshared/libshared.h     |    9 +-
 .../GenerateExportHeader/libstatic/libstatic.cpp   |   30 +-
 .../GenerateExportHeader/libstatic/libstatic.h     |    9 +-
 .../nodeprecated/src/someclass.cpp                 |    1 -
 .../reference/Empty/libshared_export.h             |    7 +-
 .../reference/Empty/libstatic_export.h             |    7 +-
 .../reference/MinGW/libshared_export.h             |    7 +-
 .../reference/MinGW/libstatic_export.h             |    7 +-
 .../reference/UNIX/libshared_export.h              |    7 +-
 .../reference/UNIX/libstatic_export.h              |    7 +-
 .../UNIX_DeprecatedOnly/libshared_export.h         |    7 +-
 .../UNIX_DeprecatedOnly/libstatic_export.h         |    7 +-
 .../reference/Win32-Clang/libshared_export.h       |   42 +
 .../reference/Win32-Clang/libstatic_export.h       |   42 +
 .../reference/Win32/libshared_export.h             |    7 +-
 .../reference/Win32/libstatic_export.h             |    7 +-
 .../reference/WinEmpty/libshared_export.h          |    7 +-
 .../reference/WinEmpty/libstatic_export.h          |    7 +-
 .../WriteCompilerDetectionHeader/CMakeLists.txt    |   14 +-
 .../WriteCompilerDetectionHeader/compile_tests.h   |    6 +-
 Tests/Module/WriteCompilerDetectionHeader/main.c   |   19 +-
 .../WriteCompilerDetectionHeader/main_multi.c      |   19 +-
 Tests/ModuleDefinition/example_dll.c               |    5 +-
 Tests/ModuleDefinition/example_dll_2.c             |    5 +-
 Tests/ModuleDefinition/example_dll_gen.c           |    5 +-
 Tests/ModuleDefinition/example_exe.c               |    9 +-
 Tests/ModuleDefinition/example_mod_1.c             |    7 +-
 Tests/NewlineArgs/cxxonly.cxx                      |    7 +-
 Tests/ObjectLibrary/A/CMakeLists.txt               |    7 +-
 Tests/ObjectLibrary/A/a.h                          |    4 +-
 Tests/ObjectLibrary/A/a2.c                         |    5 +-
 Tests/ObjectLibrary/B/CMakeLists.txt               |    6 +-
 Tests/ObjectLibrary/B/b.h                          |   12 +-
 Tests/ObjectLibrary/B/b1.c                         |    5 +-
 Tests/ObjectLibrary/B/b1_vs6.c                     |    1 -
 Tests/ObjectLibrary/B/b2.c                         |    5 +-
 Tests/ObjectLibrary/B/b2_vs6.c                     |    1 -
 Tests/ObjectLibrary/CMakeLists.txt                 |    4 +-
 Tests/ObjectLibrary/ExportLanguages/a.c            |    5 +-
 Tests/ObjectLibrary/ExportLanguages/a.cxx          |    5 +-
 Tests/ObjectLibrary/c.c                            |   11 +-
 Tests/ObjectLibrary/dummy.c                        |    5 +-
 Tests/ObjectLibrary/main.c                         |   10 +-
 Tests/ObjectLibrary/mainAB.c                       |    7 +-
 Tests/OutDir/OutDir.c                              |   14 +-
 Tests/OutOfBinary/outexe.c                         |    5 +-
 Tests/OutOfBinary/outlib.c                         |    6 +-
 Tests/OutOfSource/OutOfSourceSubdir/simple.cxx     |   31 +-
 Tests/OutOfSource/OutOfSourceSubdir/testlib.h      |   12 +-
 Tests/OutOfSource/SubDir/subdir.c                  |    5 +-
 Tests/OutOfSource/simple.cxx                       |    5 +-
 Tests/PDBDirectoryAndName/CMakeLists.txt           |   14 +-
 Tests/PDBDirectoryAndName/myexe.c                  |    5 +-
 Tests/PDBDirectoryAndName/myexe2.c                 |    5 +-
 Tests/PDBDirectoryAndName/mylibA.c                 |    5 +-
 Tests/PDBDirectoryAndName/mylibB.c                 |    5 +-
 Tests/PDBDirectoryAndName/mylibC.c                 |    5 +-
 Tests/PDBDirectoryAndName/mylibD.c                 |    5 +-
 Tests/PerConfig/pcShared.h                         |   12 +-
 Tests/Plugin/CMakeLists.txt                        |    7 +
 Tests/Plugin/include/example.h                     |   15 +-
 Tests/Plugin/src/example_exe.cxx                   |   38 +-
 Tests/Plugin/src/example_mod_1.c                   |    8 +-
 Tests/PositionIndependentTargets/main.cpp          |    5 +-
 Tests/PositionIndependentTargets/pic_main.cpp      |    5 +-
 Tests/PreOrder/simple.cxx                          |    2 +-
 Tests/PrecompiledHeader/CMakeLists.txt             |   10 +-
 Tests/PrecompiledHeader/foo1.c                     |    2 +-
 Tests/PrecompiledHeader/foo2.c                     |    4 +-
 Tests/Preprocess/CMakeLists.txt                    |   43 +-
 Tests/Preprocess/preprocess.c                      |  217 +-
 Tests/Preprocess/preprocess.cxx                    |  237 +-
 Tests/Preprocess/preprocess.h.in                   |    6 -
 Tests/Preprocess/preprocess_vs6.cxx                |    3 -
 Tests/Properties/SubDir/properties3.cxx            |    2 +-
 Tests/Qt4Deploy/testdeploy.cpp                     |   14 +-
 Tests/Qt4Targets/IncrementalMoc/foo.cpp            |    1 -
 Tests/Qt4Targets/activeqtexe.cpp                   |   23 +-
 Tests/Qt4Targets/interface/myinterface.h           |    1 -
 Tests/Qt4Targets/main.cpp                          |    2 +-
 Tests/Qt4Targets/main_gen_test.cpp                 |    7 +-
 Tests/Qt4Targets/main_wrap_test.cpp                |    2 +-
 Tests/Qt4Targets/mywrapobject.h                    |    5 +-
 Tests/QtAutoUicInterface/klocalizedstring.cpp      |    4 +-
 Tests/QtAutoUicInterface/klocalizedstring.h        |    4 +-
 Tests/QtAutoUicInterface/libwidget.cpp             |    6 +-
 Tests/QtAutoUicInterface/libwidget.h               |    2 +-
 Tests/QtAutoUicInterface/main.cpp                  |   70 +-
 Tests/QtAutoUicInterface/mywidget.cpp              |    6 +-
 Tests/QtAutoUicInterface/mywidget.h                |    2 +-
 Tests/QtAutogen/Adir/libA.cpp                      |    3 +-
 Tests/QtAutogen/Adir/libA.h                        |    2 +-
 Tests/QtAutogen/Bdir/libB.cpp                      |    3 +-
 Tests/QtAutogen/Bdir/libB.h                        |    5 +-
 Tests/QtAutogen/CMakeLists.txt                     |    4 +
 Tests/QtAutogen/abc.cpp                            |   15 +-
 Tests/QtAutogen/abc.h                              |    8 +-
 Tests/QtAutogen/abc_p.h                            |    8 +-
 Tests/QtAutogen/bar.cpp                            |    2 +-
 Tests/QtAutogen/blub.cpp                           |   12 +-
 Tests/QtAutogen/blub.h                             |    6 +-
 Tests/QtAutogen/calwidget.cpp                      |  787 ++-
 Tests/QtAutogen/calwidget.h                        |  219 +-
 Tests/QtAutogen/codeeditor.cpp                     |  215 +-
 Tests/QtAutogen/codeeditor.h                       |  199 +-
 Tests/QtAutogen/debug_class.cpp                    |    5 +-
 Tests/QtAutogen/debug_class.h                      |    7 +-
 Tests/QtAutogen/defines_test/defines_test.cpp      |    2 +-
 Tests/QtAutogen/empty.h                            |    2 +-
 Tests/QtAutogen/foo.cpp                            |   14 +-
 Tests/QtAutogen/foo.h                              |   10 +-
 Tests/QtAutogen/gadget.h                           |    3 +-
 Tests/QtAutogen/generated.cpp                      |    3 +-
 Tests/QtAutogen/generated.h                        |    2 +-
 Tests/QtAutogen/libC.cpp                           |    3 +-
 Tests/QtAutogen/libC.h                             |    6 +-
 Tests/QtAutogen/main.cpp                           |   13 +-
 Tests/QtAutogen/multiplewidgets.cpp                |   12 +-
 Tests/QtAutogen/multiplewidgets.h                  |   10 +-
 Tests/QtAutogen/private_slot.cpp                   |   13 +-
 Tests/QtAutogen/private_slot.h                     |    4 +-
 Tests/QtAutogen/resourcetester.cpp                 |   11 +-
 Tests/QtAutogen/resourcetester.h                   |    2 +-
 Tests/QtAutogen/same_name/CMakeLists.txt           |   20 +
 Tests/QtAutogen/same_name/aaa/bbb/data.qrc         |    6 +
 Tests/QtAutogen/same_name/aaa/bbb/item.cpp         |   10 +
 Tests/QtAutogen/same_name/aaa/bbb/item.hpp         |   18 +
 Tests/QtAutogen/same_name/aaa/data.qrc             |    6 +
 Tests/QtAutogen/same_name/aaa/item.cpp             |    8 +
 Tests/QtAutogen/same_name/aaa/item.hpp             |   16 +
 Tests/QtAutogen/same_name/bbb/aaa/data.qrc         |    6 +
 Tests/QtAutogen/same_name/bbb/aaa/item.cpp         |   10 +
 Tests/QtAutogen/same_name/bbb/aaa/item.hpp         |   18 +
 Tests/QtAutogen/same_name/bbb/data.qrc             |    6 +
 Tests/QtAutogen/same_name/bbb/item.cpp             |    8 +
 Tests/QtAutogen/same_name/bbb/item.hpp             |   16 +
 Tests/QtAutogen/same_name/ccc/data.qrc             |    6 +
 Tests/QtAutogen/same_name/ccc/item.cpp             |   23 +
 Tests/QtAutogen/same_name/ccc/item.hpp             |   16 +
 Tests/QtAutogen/same_name/data.qrc                 |    5 +
 Tests/QtAutogen/same_name/main.cpp                 |   16 +
 Tests/QtAutogen/second_widget.cpp                  |    5 +-
 Tests/QtAutogen/second_widget.h                    |    5 +-
 Tests/QtAutogen/sub/bar.h                          |    8 +-
 Tests/QtAutogen/sub/uiconly.cpp                    |    6 +-
 Tests/QtAutogen/sub/uiconly.h                      |    2 +-
 Tests/QtAutogen/xyz.cpp                            |    4 +-
 Tests/QtAutogen/xyz.h                              |    8 +-
 Tests/QtAutogen/yaf.cpp                            |    2 -
 Tests/QtAutogen/yaf.h                              |    9 +-
 Tests/QtAutogen/yaf_p.h                            |    8 +-
 Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake    |    4 +-
 Tests/RunCMake/AutoExportDll/hello.cxx             |    6 +-
 Tests/RunCMake/AutoExportDll/say.cxx               |    9 +-
 .../Custom-Symbolic-and-Byproduct.cmake            |    1 +
 Tests/RunCMake/BuildDepends/MakeInProjectOnly.c    |    5 +
 .../RunCMake/BuildDepends/MakeInProjectOnly.cmake  |   16 +
 .../BuildDepends/MakeInProjectOnly.step1.cmake     |    3 +
 .../BuildDepends/MakeInProjectOnly.step2.cmake     |    3 +
 Tests/RunCMake/BuildDepends/RunCMakeTest.cmake     |   49 +-
 Tests/RunCMake/BuildDepends/main.c                 |    5 +-
 Tests/RunCMake/CMP0022/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0026/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0037/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0038/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0040/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0041/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0042/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0043/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0045/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0046/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0049/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0050/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0051/empty.cpp                   |    2 +-
 Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt     |    4 +-
 Tests/RunCMake/CMP0065/subproject/main.c           |    2 +-
 Tests/RunCMake/CMakeLists.txt                      |   23 +-
 Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp     |    2 +-
 Tests/RunCMake/CPack/CPackTestHelpers.cmake        |   14 +
 Tests/RunCMake/CPack/CUSTOM_NAMES.cmake            |    7 +
 .../DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake   |    2 +-
 .../CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake |    1 +
 .../CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake     |    9 +
 .../CPack/DEB/CUSTOM_NAMES-specifics.cmake         |    6 +
 .../CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake        |    6 +-
 .../CPack/DEB/DEB_EXTRA-VerifyResult.cmake         |   13 +-
 .../DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake    |    6 +
 .../DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake  |    7 +
 .../DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake     |    4 +
 ...EB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake |    6 +
 ..._GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake |    7 +
 ...DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake |    8 +
 .../CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake     |   10 +-
 .../CPack/DEB/DEPENDENCIES-specifics.cmake         |    2 +
 .../CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake        |    2 +-
 Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake |    1 +
 Tests/RunCMake/CPack/DEB/Helpers.cmake             |   77 +-
 .../RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake |    2 +-
 Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake   |    1 +
 .../DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake   |    6 +-
 .../CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake |    1 +
 Tests/RunCMake/CPack/DEB_EXTRA.cmake               |    1 +
 Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake     |   18 +
 .../CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake       |   19 +
 Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake         |   26 +
 Tests/RunCMake/CPack/README.txt                    |   22 +
 .../CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake     |    9 +
 .../CPack/RPM/CUSTOM_NAMES-specifics.cmake         |    5 +
 Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt   |    3 +
 .../CPack/RPM/DEPENDENCIES-specifics.cmake         |   20 +-
 .../CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake  |    7 +
 .../CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake   |   29 +
 .../CPack/RPM/INSTALL_SCRIPTS-specifics.cmake      |   19 +
 .../CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake |    4 +-
 .../CPack/RPM/RPM_DIST-ExpectedFiles.cmake         |    5 +
 .../RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake |   11 +
 Tests/RunCMake/CPack/RPM_DIST.cmake                |    4 +
 Tests/RunCMake/CPack/RunCMakeTest.cmake            |    5 +
 Tests/RunCMake/CPackInstallProperties/test.cpp     |    4 +-
 .../CTestTimeoutAfterMatch/CMakeLists.txt.in       |    6 +
 .../CTestTimeoutAfterMatch/CTestConfig.cmake.in    |    1 +
 .../CTestTimeoutAfterMatch/MissingArg1-stderr.txt  |    1 +
 .../CTestTimeoutAfterMatch/MissingArg2-stderr.txt  |    1 +
 .../CTestTimeoutAfterMatch/RunCMakeTest.cmake      |   11 +
 .../CTestTimeoutAfterMatch/ShouldPass-stdout.txt   |    6 +
 .../ShouldTimeout-stdout.txt                       |    1 +
 .../CTestTimeoutAfterMatch/SleepFor1Second.cmake   |    4 +
 .../RunCMake/CTestTimeoutAfterMatch/test.cmake.in  |   21 +
 Tests/RunCMake/ClangTidy/C-Build-stdout.txt        |    1 +
 Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt |    1 +
 Tests/RunCMake/ClangTidy/C-launch.cmake            |    3 +
 Tests/RunCMake/ClangTidy/C.cmake                   |    3 +
 Tests/RunCMake/ClangTidy/CMakeLists.txt            |    3 +
 Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt      |    1 +
 .../RunCMake/ClangTidy/CXX-launch-Build-stdout.txt |    1 +
 Tests/RunCMake/ClangTidy/CXX-launch.cmake          |    3 +
 Tests/RunCMake/ClangTidy/CXX.cmake                 |    3 +
 Tests/RunCMake/ClangTidy/RunCMakeTest.cmake        |   22 +
 Tests/RunCMake/ClangTidy/main.c                    |    4 +
 Tests/RunCMake/ClangTidy/main.cxx                  |    4 +
 .../BuildDir--build-multiple-targets-result.txt    |    1 +
 .../BuildDir--build-multiple-targets-stderr.txt    |    3 +
 Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt |    2 +
 .../CommandLine/DeprecateVS6-WARN-ON-stderr.txt    |    5 -
 .../CommandLine/DeprecateVS70-WARN-ON-stderr.txt   |    5 -
 ...-WARN-ON.cmake => DeprecateVS71-WARN-OFF.cmake} |    0
 .../CommandLine/DeprecateVS71-WARN-ON-stderr.txt   |    5 +
 ...-WARN-OFF.cmake => DeprecateVS71-WARN-ON.cmake} |    0
 .../CommandLine/E___run_iwyu-no-iwyu-stderr.txt    |    2 +-
 Tests/RunCMake/CommandLine/RunCMakeTest.cmake      |   17 +-
 Tests/RunCMake/CommandLine/cmake_depends/test.h    |    4 +-
 Tests/RunCMake/CompatibleInterface/main.cpp        |    2 +-
 Tests/RunCMake/CompileFeatures/empty.c             |    2 +-
 Tests/RunCMake/CompileFeatures/empty.cpp           |    2 +-
 Tests/RunCMake/CompilerLauncher/main.c             |    3 +-
 Tests/RunCMake/CompilerLauncher/main.cxx           |    5 +-
 .../AddCustomCommand-build-check.cmake             |    5 +
 .../CrosscompilingEmulator/AddCustomCommand.cmake  |   38 +
 .../AddCustomTarget-build-check.cmake              |    1 +
 .../CrosscompilingEmulator/AddCustomTarget.cmake   |   30 +
 .../CrosscompilingEmulator/AddTest-check.cmake     |   24 +-
 .../RunCMake/CrosscompilingEmulator/AddTest.cmake  |   14 +-
 .../CrosscompilingEmulator/AddTest/CMakeLists.txt  |    5 +
 .../CrosscompilingEmulatorProperty.cmake           |    4 +-
 .../CrosscompilingEmulator/RunCMakeTest.cmake      |   15 +
 Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake |    4 +-
 .../RunCMake/CrosscompilingEmulator/simple_src.cxx |    4 -
 .../simple_src_exiterror.cxx                       |    4 +
 .../simple_src_exitsuccess.cxx                     |    4 +
 Tests/RunCMake/ExportWithoutLanguage/header.h      |    5 +-
 Tests/RunCMake/File_Generate/empty.c               |    2 +-
 Tests/RunCMake/File_Generate/empty.cpp             |    2 +-
 Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp      |   15 +-
 .../FindPkgConfig_IMPORTED_TARGET.cmake            |   26 +
 Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake    |    1 +
 Tests/RunCMake/Framework/foo.c                     |    5 +-
 .../GeneratorExpression/RunCMakeTest.cmake         |    1 +
 .../TARGET_PROPERTY-LOCATION-stderr.txt            |   10 +
 .../TARGET_PROPERTY-LOCATION.cmake                 |    3 +
 Tests/RunCMake/IncludeWhatYouUse/main.c            |    5 +-
 Tests/RunCMake/IncludeWhatYouUse/main.cxx          |    5 +-
 Tests/RunCMake/IncompatibleQt/main.cpp             |    2 +-
 Tests/RunCMake/Languages/empty.cpp                 |    2 +-
 Tests/RunCMake/Ninja/CheckNoPrefixSubDir.cmake     |    7 +
 .../RunCMake/Ninja/CheckNoPrefixSubDirScript.cmake |    8 +
 Tests/RunCMake/Ninja/CheckOutput.cmake             |   23 +
 .../Ninja/CustomCommandWorkingDirectory.cmake      |   13 +
 Tests/RunCMake/Ninja/Executable.cmake              |    5 +
 Tests/RunCMake/Ninja/RunCMakeTest.cmake            |  181 +
 Tests/RunCMake/Ninja/SharedLib.cmake               |    8 +
 Tests/RunCMake/Ninja/StaticLib.cmake               |    9 +
 Tests/RunCMake/Ninja/SubDir-build-stdout.txt       |    1 +
 Tests/RunCMake/Ninja/SubDir.cmake                  |    2 +
 Tests/RunCMake/Ninja/SubDir/CMakeLists.txt         |    2 +
 Tests/RunCMake/Ninja/SubDirPrefix.cmake            |    8 +
 Tests/RunCMake/Ninja/SubDirPrefix/CMakeLists.txt   |    2 +
 Tests/RunCMake/Ninja/SubDirPrefix/greeting.c       |    9 +
 Tests/RunCMake/Ninja/SubDirPrefix/greeting.h       |    4 +
 Tests/RunCMake/Ninja/TwoLibs.cmake                 |   17 +
 Tests/RunCMake/Ninja/greeting.c                    |    9 +
 Tests/RunCMake/Ninja/greeting.h                    |    4 +
 Tests/RunCMake/Ninja/greeting2.c                   |    6 +
 Tests/RunCMake/Ninja/greeting2.h                   |    1 +
 Tests/RunCMake/Ninja/hello.c                       |    7 +
 Tests/RunCMake/Ninja/hello_sub_greeting.c          |    7 +
 Tests/RunCMake/Ninja/hello_with_greeting.c         |    7 +
 Tests/RunCMake/Ninja/hello_with_two_greetings.c    |    9 +
 Tests/RunCMake/ObjectLibrary/a.c                   |    5 +-
 Tests/RunCMake/ObsoleteQtMacros/empty.cpp          |    2 +-
 Tests/RunCMake/PolicyScope/NotClosed-stderr.txt    |    2 +-
 Tests/RunCMake/PositionIndependentCode/main.cpp    |    2 +-
 Tests/RunCMake/RunCMake.cmake                      |    7 +-
 .../SolutionGlobalSections/RunCMakeTest.cmake      |   10 -
 .../SolutionGlobalSections/solution_parsing.cmake  |   60 -
 Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt |    6 +-
 Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt    |    6 +-
 Tests/RunCMake/TargetPolicies/empty.cpp            |    2 +-
 .../TargetPropertyGeneratorExpressions/empty.cpp   |    2 +-
 .../TargetSources/OriginDebugIDE-stderr.txt        |    2 +-
 Tests/RunCMake/TargetSources/empty_1.cpp           |    2 +-
 Tests/RunCMake/TargetSources/empty_2.cpp           |    2 +-
 Tests/RunCMake/TargetSources/empty_3.cpp           |    2 +-
 Tests/RunCMake/TargetSources/empty_4.cpp           |    2 +-
 Tests/RunCMake/ToolchainFile/CMakeLists.txt        |    3 +
 .../ToolchainFile/CallEnableLanguage-result.txt    |    1 +
 .../ToolchainFile/CallEnableLanguage-stderr.txt    |    5 +
 .../CallEnableLanguage-toolchain.cmake             |    1 +
 .../CallEnableLanguage.cmake}                      |    0
 .../RunCMake/ToolchainFile/CallProject-result.txt  |    1 +
 .../RunCMake/ToolchainFile/CallProject-stderr.txt  |    5 +
 .../ToolchainFile/CallProject-toolchain.cmake      |    1 +
 .../CallProject.cmake}                             |    0
 Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake    |    9 +
 Tests/RunCMake/VS10Project/CMakeLists.txt          |    3 +
 Tests/RunCMake/VS10Project/RunCMakeTest.cmake      |    2 +
 .../VS10Project/VsConfigurationType-check.cmake    |   24 +
 .../RunCMake/VS10Project/VsConfigurationType.cmake |    3 +
 Tests/RunCMake/VS10Project/foo.cpp                 |    3 +
 .../CMakeLists.txt                                 |    0
 .../MorePost-check.cmake                           |    0
 .../MorePost.cmake                                 |    0
 .../MorePre-check.cmake                            |    0
 .../MorePre.cmake                                  |    0
 .../OnePost-check.cmake                            |    0
 .../OnePost.cmake                                  |    0
 .../OnePre-check.cmake                             |    0
 .../OnePre.cmake                                   |    0
 .../Override1-check.cmake                          |    0
 .../Override1.cmake                                |    0
 .../Override2-check.cmake                          |    0
 .../Override2.cmake                                |    0
 .../PrePost-check.cmake                            |    0
 .../PrePost.cmake                                  |    0
 Tests/RunCMake/VSSolution/RunCMakeTest.cmake       |   16 +
 .../RunCMake/VSSolution/StartupProject-check.cmake |    5 +
 Tests/RunCMake/VSSolution/StartupProject.cmake     |    2 +
 .../VSSolution/StartupProjectMissing-check.cmake   |    5 +
 .../VSSolution/StartupProjectMissing-stderr.txt    |    4 +
 .../VSSolution/StartupProjectMissing.cmake         |    1 +
 .../StartupProjectUseFolders-check.cmake           |    9 +
 .../VSSolution/StartupProjectUseFolders.cmake      |    3 +
 Tests/RunCMake/VSSolution/solution_parsing.cmake   |   75 +
 Tests/RunCMake/XcodeProject/foo.cpp                |    4 +-
 Tests/RunCMake/XcodeProject/main.cpp               |    5 +-
 Tests/RunCMake/alias_targets/empty.cpp             |    2 +-
 .../cmake_parse_arguments/CornerCases.cmake        |   20 +
 .../cmake_parse_arguments/Initialization.cmake     |    9 +
 .../file/DOWNLOAD-hash-mismatch-result.txt         |    1 +
 .../file/DOWNLOAD-hash-mismatch-stderr.txt         |   12 +
 Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake   |    7 +
 .../DOWNLOAD-hash-mismatch.txt}                    |    0
 Tests/RunCMake/file/GLOB.cmake                     |    3 -
 .../file/GLOB_RECURSE-cyclic-recursion.cmake       |    3 -
 Tests/RunCMake/file/GLOB_RECURSE.cmake             |    3 -
 Tests/RunCMake/file/RunCMakeTest.cmake             |    1 +
 Tests/RunCMake/find_file/RunCMakeTest.cmake        |    4 +-
 Tests/RunCMake/find_library/RunCMakeTest.cmake     |    4 +-
 Tests/RunCMake/find_package/PolicyPush-stderr.txt  |    2 +-
 Tests/RunCMake/find_path/RunCMakeTest.cmake        |    4 +-
 Tests/RunCMake/include/empty.cpp                   |    2 +-
 .../install/FILES-EXCLUDE_FROM_ALL-all-check.cmake |    1 +
 .../install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake |    1 +
 .../install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake |    1 +
 .../RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake  |    3 +
 Tests/RunCMake/install/RunCMakeTest.cmake          |   45 +
 .../TARGETS-EXCLUDE_FROM_ALL-all-check.cmake       |    1 +
 .../TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake       |    1 +
 .../TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake       |    1 +
 .../install/TARGETS-EXCLUDE_FROM_ALL.cmake         |    5 +
 Tests/RunCMake/install/main.c                      |    4 +
 Tests/RunCMake/list/EmptyFilterRegex-result.txt    |    1 +
 .../EmptyFilterRegex-stderr.txt}                   |    0
 Tests/RunCMake/list/EmptyFilterRegex.cmake         |    2 +
 Tests/RunCMake/list/FILTER-NotList-result.txt      |    1 +
 Tests/RunCMake/list/FILTER-NotList-stderr.txt      |    4 +
 Tests/RunCMake/list/FILTER-NotList.cmake           |    2 +
 .../list/FILTER-REGEX-InvalidMode-result.txt       |    1 +
 .../list/FILTER-REGEX-InvalidMode-stderr.txt       |    4 +
 Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake |    2 +
 .../list/FILTER-REGEX-InvalidOperator-result.txt   |    1 +
 .../list/FILTER-REGEX-InvalidOperator-stderr.txt   |    4 +
 .../list/FILTER-REGEX-InvalidOperator.cmake        |    2 +
 .../list/FILTER-REGEX-InvalidRegex-result.txt      |    1 +
 .../list/FILTER-REGEX-InvalidRegex-stderr.txt      |    4 +
 .../RunCMake/list/FILTER-REGEX-InvalidRegex.cmake  |    2 +
 .../list/FILTER-REGEX-TooManyArguments-result.txt  |    1 +
 .../list/FILTER-REGEX-TooManyArguments-stderr.txt  |    4 +
 .../list/FILTER-REGEX-TooManyArguments.cmake       |    2 +
 Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt |    1 +
 Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt |    2 +
 Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake      |    4 +
 Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt |    1 +
 Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt |    2 +
 Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake      |    4 +
 Tests/RunCMake/list/RunCMakeTest.cmake             |    9 +
 Tests/RunCMake/pseudo_emulator.c                   |   17 +-
 Tests/RunCMake/pseudo_emulator_custom_command.c    |   31 +
 Tests/RunCMake/pseudo_tidy.c                       |   14 +
 Tests/RunCMake/target_compile_features/empty.c     |    2 +-
 Tests/RunCMake/target_compile_features/empty.cpp   |    2 +-
 Tests/RunCMake/target_link_libraries/empty.cpp     |    2 +-
 Tests/RunCMake/try_compile/PlatformVariables.cmake |   23 +
 Tests/RunCMake/try_compile/RunCMakeTest.cmake      |    8 +
 Tests/RunCMake/try_compile/TargetTypeExe.cmake     |   14 +
 .../try_compile/TargetTypeInvalid-result.txt       |    1 +
 .../try_compile/TargetTypeInvalid-stderr.txt       |    5 +
 Tests/RunCMake/try_compile/TargetTypeInvalid.cmake |    2 +
 Tests/RunCMake/try_compile/TargetTypeStatic.cmake  |   14 +
 Tests/RunCMake/try_compile/other.c                 |    4 +
 Tests/RunCMake/try_compile/src.c                   |    5 +-
 Tests/RunCMake/try_run/src.c                       |    5 +-
 Tests/RunCMake/while/EndMismatch-stderr.txt        |    2 +-
 Tests/RunCMake/while/EndMissing-stderr.txt         |    6 +-
 Tests/RuntimePath/bar1.c                           |    5 +-
 Tests/RuntimePath/bar2.c                           |    5 +-
 Tests/RuntimePath/foo1.c                           |    5 +-
 Tests/RuntimePath/foo2.c                           |    5 +-
 Tests/SBCS/SBCS.cxx                                |   15 +-
 Tests/SameName/Exe1/conly.c                        |    7 +-
 Tests/SetLang/bar.c                                |    7 +-
 Tests/SetLang/foo.c                                |    2 +-
 Tests/Simple/simple.cxx                            |    2 +-
 Tests/Simple/simpleCLib.c                          |    5 +-
 Tests/Simple/simpleWe.cpp                          |    5 +-
 Tests/SimpleCOnly/bar.c                            |    5 +-
 Tests/SimpleCOnly/foo.c                            |    5 +-
 Tests/SimpleCOnly/main.c                           |    8 +-
 Tests/SimpleExclude/dirC/dirA/t4.c                 |   18 +-
 Tests/SimpleExclude/dirC/dirB/t7.c                 |    5 +-
 Tests/SimpleExclude/dirD/t9.c                      |   26 +-
 Tests/SimpleInstall/CMakeLists.txt                 |    1 +
 Tests/SimpleInstall/TestSubDir/TSD_utils.cxx       |    5 +-
 Tests/SimpleInstall/foo.h                          |    1 -
 Tests/SimpleInstall/inst.cxx                       |   33 +-
 Tests/SimpleInstall/lib2.h                         |   12 +-
 Tests/SimpleInstall/lib3.h                         |   12 +-
 Tests/SimpleInstall/lib4.cxx                       |    1 -
 Tests/SimpleInstall/lib4.h                         |   13 +-
 Tests/SimpleInstallS2/CMakeLists.txt               |    1 +
 Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx     |    5 +-
 Tests/SimpleInstallS2/foo.h                        |    1 -
 Tests/SimpleInstallS2/inst.cxx                     |   33 +-
 Tests/SimpleInstallS2/lib2.h                       |   12 +-
 Tests/SimpleInstallS2/lib3.h                       |   12 +-
 Tests/SimpleInstallS2/lib4.cxx                     |    1 -
 Tests/SimpleInstallS2/lib4.h                       |   13 +-
 Tests/SourceGroups/main.c                          |    5 +-
 Tests/StagingPrefix/Consumer/main.cpp              |    4 +-
 Tests/StagingPrefix/Producer/bar.h                 |    4 +-
 Tests/StagingPrefix/Producer/foo.h                 |    4 +-
 Tests/StagingPrefix/main.cpp                       |    2 +-
 Tests/StringFileTest/StringFile.cxx                |    3 +-
 Tests/SubDir/Executable/test.cxx                   |   29 +-
 Tests/SubDirSpaces/Executable Sources/test.cxx     |   29 +-
 Tests/SubDirSpaces/Executable/test.cxx             |   29 +-
 Tests/SubProject/car.cxx                           |    4 +-
 Tests/SubProject/foo/foo.cxx                       |    5 +-
 Tests/SwiftMix/CMain.c                             |    3 +-
 Tests/SwigTest/example.cxx                         |   23 +-
 Tests/SwigTest/example.h                           |   36 +-
 Tests/SystemInformation/DumpInformation.cxx        |  102 +-
 Tests/TargetName/executables/hello_world.c         |    2 +-
 Tests/TestDriver/subdir/test3.cxx                  |    4 +-
 Tests/TestDriver/test1.cxx                         |   17 +-
 Tests/TestDriver/test2.cxx                         |    4 +-
 Tests/TestDriver/testArgs.h                        |   20 +-
 Tests/Testing/Sub/Sub2/testing2.cxx                |    2 +-
 Tests/Testing/testing.cxx                          |    2 +-
 Tests/TestsWorkingDirectory/main.c                 |   34 +-
 Tests/TryCompile/CMakeLists.txt                    |    4 +-
 Tests/TryCompile/Inner/innerexe.c                  |    5 +-
 Tests/TryCompile/Inner/innerlib.c                  |    5 +-
 Tests/TryCompile/expect_arg.c                      |   16 +-
 Tests/TryCompile/fail2a.c                          |    5 +-
 Tests/TryCompile/pass.c                            |    2 -
 Tests/TryCompile/pass2a.c                          |    5 +-
 Tests/TryCompile/pass2b.cxx                        |    5 +-
 Tests/TryCompile/testdef.c                         |    7 +-
 Tests/Tutorial/Step1/tutorial.cxx                  |   20 +-
 Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx      |   21 +-
 Tests/Tutorial/Step2/tutorial.cxx                  |   25 +-
 Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx      |   21 +-
 Tests/Tutorial/Step3/tutorial.cxx                  |   25 +-
 Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx      |   29 +-
 Tests/Tutorial/Step4/tutorial.cxx                  |   25 +-
 Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx   |   27 +-
 Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx      |   26 +-
 Tests/Tutorial/Step5/tutorial.cxx                  |   25 +-
 Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx   |   27 +-
 Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx      |   26 +-
 Tests/Tutorial/Step6/tutorial.cxx                  |   25 +-
 Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx   |   27 +-
 Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx      |   26 +-
 Tests/Tutorial/Step7/tutorial.cxx                  |   25 +-
 Tests/VSExternalInclude/CMakeLists.txt             |    7 +-
 Tests/VSExternalInclude/Lib1/lib1.h                |    1 -
 Tests/VSGNUFortran/c_code/main.c                   |    4 +-
 Tests/VSMASM/main.c                                |    5 +-
 Tests/VSMidl/src/CMakeLists.txt                    |    8 +-
 Tests/VSMidl/src/main.cpp                          |    6 +-
 Tests/VSNsightTegra/jni/first.c                    |    4 +-
 Tests/VSNsightTegra/jni/first.h                    |    2 +-
 Tests/VSNsightTegra/jni/second.c                   |    9 +-
 Tests/VSResource/lib.cpp                           |    5 +-
 Tests/VSResource/main.cpp                          |   43 +-
 Tests/VSResourceNinjaForceRSP/CMakeLists.txt       |    7 +
 Tests/VSResourceNinjaForceRSP/lib.cpp              |    4 +
 Tests/VSResourceNinjaForceRSP/main.cpp             |    6 +
 Tests/VSResourceNinjaForceRSP/test.rc              |    4 +
 Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h    |   25 +-
 .../VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp  |  284 +-
 .../VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp  |  104 +-
 Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h  |   47 +-
 .../VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp  |  302 +-
 Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h  |    8 +-
 Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h |   39 +-
 Tests/VSWinStorePhone/Direct3DApp1/pch.h           |    6 +-
 Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h |  127 +-
 .../VSWindowsFormsResx/WindowsFormsResx/Source.cpp |    2 +-
 Tests/VSXaml/App.xaml.cpp                          |  146 +-
 Tests/VSXaml/App.xaml.h                            |   32 +-
 Tests/VSXaml/MainPage.xaml.cpp                     |    6 +-
 Tests/VSXaml/MainPage.xaml.h                       |   19 +-
 Tests/Visibility/bar.c                             |    4 +-
 Tests/Visibility/foo.cpp                           |    6 +-
 Tests/Visibility/hidden.c                          |   11 +-
 Tests/Visibility/shared.c                          |    5 +-
 Tests/WarnUnusedCliUnused/empty.cpp                |    2 +-
 Tests/Wrapping/CMakeLists.txt                      |    2 +-
 Tests/Wrapping/Wrap.c                              |   18 +-
 Tests/Wrapping/fakefluid.cxx                       |   13 +-
 Tests/Wrapping/qtnoqtmain.cxx                      |    1 -
 Tests/Wrapping/qtwrappingmain.cxx                  |   22 +-
 Tests/Wrapping/wrapFLTK.c                          |    1 -
 Tests/Wrapping/wrapFLTK.cxx                        |    4 +
 Tests/Wrapping/wrapping.cxx                        |    2 +-
 Tests/X11/HelloWorldX11.cxx                        |  142 +-
 Tests/XCTest/CocoaExample/AppDelegate.h            |    3 +-
 Tests/XCTest/FrameworkExample/FrameworkExample.c   |    2 +-
 Tests/iOSNavApp/Classes/NavApp3AppDelegate.h       |   11 +-
 Tests/iOSNavApp/TotalFunction.c                    |    2 +-
 Tests/iOSNavApp/TotalFunction.h                    |    2 +-
 .../WiX/CustomAction/detect_nsis_overwrite.cpp     |   18 +-
 Utilities/Release/create-cmake-release.cmake       |    9 +-
 Utilities/Release/cygwin_release.cmake             |   32 +
 Utilities/Release/dash2win64_cygwin.cmake          |   33 -
 Utilities/Release/dash3win7_release.cmake          |   28 -
 Utilities/Release/dashmacmini5_release.cmake       |   27 -
 Utilities/Release/linux32_release.cmake            |   25 +
 Utilities/Release/linux64_release.cmake            |    6 +-
 Utilities/Release/magrathea_release.cmake          |   25 -
 Utilities/Release/osx_release.cmake                |   32 +
 Utilities/Release/upload_release.cmake             |    2 +-
 Utilities/Release/win32_release.cmake              |   32 +
 Utilities/Release/win64_release.cmake              |   33 +
 Utilities/Scripts/clang-format.bash                |  138 +
 Utilities/Scripts/update-expat.bash                |   49 +
 Utilities/Scripts/update-libarchive.bash           |   31 +
 Utilities/Scripts/update-third-party.bash          |   19 +-
 Utilities/cm_bzlib.h                               |    4 +-
 Utilities/cm_curl.h                                |    4 +-
 Utilities/cm_expat.h                               |    4 +-
 Utilities/cm_jsoncpp_reader.h                      |    4 +-
 Utilities/cm_jsoncpp_value.h                       |    4 +-
 Utilities/cm_jsoncpp_writer.h                      |    4 +-
 Utilities/cm_kwiml.h                               |    8 +-
 Utilities/cm_libarchive.h                          |    8 +-
 Utilities/cm_lzma.h                                |    4 +-
 Utilities/cm_xmlrpc.h                              |    4 +-
 Utilities/cm_zlib.h                                |    4 +-
 Utilities/cmcurl/lib/curl_sasl_gssapi.c            |    2 +-
 Utilities/cmcurl/lib/curl_sasl_sspi.c              |    2 +-
 Utilities/cmcurl/lib/ftp.c                         |    2 +-
 Utilities/cmexpat/.NoDartCoverage                  |    1 -
 Utilities/cmexpat/.gitattributes                   |    1 +
 Utilities/cmexpat/CMakeLists.txt                   |   51 +-
 Utilities/cmexpat/COPYING                          |    1 +
 Utilities/cmexpat/ConfigureChecks.cmake            |   44 +
 Utilities/cmexpat/README                           |  139 +
 Utilities/cmexpat/ascii.h                          |   86 -
 Utilities/cmexpat/asciitab.h                       |   37 -
 Utilities/cmexpat/cm_expat_mangle.h                |   87 -
 Utilities/cmexpat/expat.h                          |  740 ---
 Utilities/cmexpat/expatConfig.h.in                 |   43 -
 Utilities/cmexpat/expatDllConfig.h.in              |    6 -
 Utilities/cmexpat/expat_config.h.cmake             |   76 +
 Utilities/cmexpat/iasciitab.h                      |   38 -
 Utilities/cmexpat/latin1tab.h                      |   37 -
 Utilities/cmexpat/lib/ascii.h                      |   92 +
 Utilities/cmexpat/lib/asciitab.h                   |   36 +
 Utilities/cmexpat/lib/expat.h                      | 1050 ++++
 Utilities/cmexpat/lib/expat_external.h             |  131 +
 Utilities/cmexpat/lib/iasciitab.h                  |   37 +
 Utilities/cmexpat/lib/internal.h                   |   95 +
 Utilities/cmexpat/lib/latin1tab.h                  |   36 +
 Utilities/cmexpat/{ => lib}/nametab.h              |    0
 Utilities/cmexpat/lib/utf8tab.h                    |   37 +
 Utilities/cmexpat/lib/winconfig.h                  |   27 +
 Utilities/cmexpat/lib/xmlparse.c                   | 6466 ++++++++++++++++++++
 Utilities/cmexpat/lib/xmlrole.c                    | 1336 ++++
 Utilities/cmexpat/lib/xmlrole.h                    |  114 +
 Utilities/cmexpat/lib/xmltok.c                     | 1751 ++++++
 Utilities/cmexpat/lib/xmltok.h                     |  322 +
 Utilities/cmexpat/lib/xmltok_impl.c                | 1775 ++++++
 Utilities/cmexpat/{ => lib}/xmltok_impl.h          |    0
 Utilities/cmexpat/lib/xmltok_ns.c                  |  115 +
 Utilities/cmexpat/utf8tab.h                        |   38 -
 Utilities/cmexpat/xmlparse.c                       | 4622 --------------
 Utilities/cmexpat/xmlrole.c                        | 1401 -----
 Utilities/cmexpat/xmlrole.h                        |  100 -
 Utilities/cmexpat/xmltok.c                         | 1584 -----
 Utilities/cmexpat/xmltok.h                         |  299 -
 Utilities/cmexpat/xmltok_impl.c                    | 1775 ------
 Utilities/cmexpat/xmltok_ns.c                      |   98 -
 Utilities/cmlibarchive/CMakeLists.txt              |   34 +-
 Utilities/cmlibarchive/README-CMake.txt            |   66 -
 Utilities/cmlibarchive/build/cmake/config.h.in     |   34 +-
 Utilities/cmlibarchive/build/version               |    2 +-
 Utilities/cmlibarchive/libarchive/CMakeLists.txt   |    1 +
 Utilities/cmlibarchive/libarchive/archive.h        |   20 +-
 .../cmlibarchive/libarchive/archive_cryptor.c      |   15 +-
 .../libarchive/archive_cryptor_private.h           |   13 +-
 Utilities/cmlibarchive/libarchive/archive_entry.h  |    7 +-
 .../libarchive/archive_entry_copy_stat.c           |    4 +
 .../cmlibarchive/libarchive/archive_entry_xattr.c  |    9 +-
 .../cmlibarchive/libarchive/archive_getdate.c      |    4 +-
 .../cmlibarchive/libarchive/archive_getdate.h      |   39 +
 Utilities/cmlibarchive/libarchive/archive_hmac.c   |   16 +-
 .../cmlibarchive/libarchive/archive_hmac_private.h |   13 +-
 Utilities/cmlibarchive/libarchive/archive_match.c  |    2 +-
 .../cmlibarchive/libarchive/archive_options.c      |    6 +-
 .../cmlibarchive/libarchive/archive_platform.h     |   15 +
 Utilities/cmlibarchive/libarchive/archive_ppmd7.c  |    5 +
 Utilities/cmlibarchive/libarchive/archive_read.c   |    8 +-
 .../libarchive/archive_read_disk_entry_from_file.c |   30 +-
 .../libarchive/archive_read_disk_posix.c           |   35 +-
 .../libarchive/archive_read_disk_windows.c         |    2 +-
 .../cmlibarchive/libarchive/archive_read_filter.3  |    6 +
 .../libarchive/archive_read_open_file.c            |   10 +-
 .../libarchive/archive_read_open_filename.c        |    2 +-
 .../libarchive/archive_read_support_filter_lz4.c   |    9 +
 .../libarchive/archive_read_support_format_7zip.c  |    3 +
 .../libarchive/archive_read_support_format_cpio.c  |    5 +
 .../archive_read_support_format_iso9660.c          |    4 +-
 .../libarchive/archive_read_support_format_mtree.c |   79 +-
 .../libarchive/archive_read_support_format_rar.c   |   63 +-
 .../libarchive/archive_read_support_format_tar.c   |    6 +-
 .../libarchive/archive_read_support_format_warc.c  |   19 +-
 .../libarchive/archive_read_support_format_xar.c   |   23 +-
 .../libarchive/archive_read_support_format_zip.c   |  102 +-
 Utilities/cmlibarchive/libarchive/archive_string.c |    3 +-
 Utilities/cmlibarchive/libarchive/archive_util.c   |   76 +-
 .../libarchive/archive_write_add_filter_bzip2.c    |    2 +-
 .../libarchive/archive_write_add_filter_grzip.c    |    2 +-
 .../libarchive/archive_write_add_filter_gzip.c     |    2 +-
 .../libarchive/archive_write_add_filter_lrzip.c    |    2 +-
 .../libarchive/archive_write_add_filter_lz4.c      |  109 +-
 .../libarchive/archive_write_add_filter_lzop.c     |    2 +-
 .../libarchive/archive_write_add_filter_program.c  |   16 +-
 .../libarchive/archive_write_disk_posix.c          |    6 +
 .../libarchive/archive_write_disk_windows.c        |   14 +-
 .../cmlibarchive/libarchive/archive_write_filter.3 |   18 +-
 .../cmlibarchive/libarchive/archive_write_format.3 |  115 +-
 .../libarchive/archive_write_private.h             |    2 +-
 .../libarchive/archive_write_set_format_7zip.c     |    4 +
 .../libarchive/archive_write_set_format_gnutar.c   |   22 +-
 .../libarchive/archive_write_set_format_iso9660.c  |   18 +-
 .../libarchive/archive_write_set_format_pax.c      |   37 +-
 .../libarchive/archive_write_set_format_warc.c     |   28 +-
 .../libarchive/archive_write_set_format_xar.c      |    5 +
 .../libarchive/archive_write_set_format_zip.c      |   46 +-
 .../libarchive/archive_write_set_options.3         |   19 +-
 .../cmlibarchive/libarchive/libarchive-formats.5   |   56 +-
 .../cmlibarchive/libarchive/libarchive_changes.3   |    2 +-
 Utilities/cmlibarchive/libarchive/xxhash.c         |   22 +-
 Utilities/cmliblzma/liblzma/simple/x86.c           |    2 +-
 2161 files changed, 90346 insertions(+), 106766 deletions(-)

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..a8bde41
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,9 @@
+---
+# This configuration requires clang-format 3.8 or higher.
+BasedOnStyle: Mozilla
+AlignOperands: false
+AlwaysBreakAfterReturnType: None
+AlwaysBreakAfterDefinitionReturnType: None
+ColumnLimit: 79
+Standard: Cpp03
+...
diff --git a/.gitattributes b/.gitattributes
index d3f7280..d959918 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -10,7 +10,6 @@ configure        crlf=input
 *.bat           -crlf
 *.bat.in        -crlf
 *.dsp           -crlf
-*.dsptemplate   -crlf
 *.dsw           -crlf
 *.pfx           -crlf
 *.png           -crlf
@@ -22,3 +21,5 @@ configure        crlf=input
 *.cxx            whitespace=tab-in-indent
 *.txt            whitespace=tab-in-indent
 *.cmake          whitespace=tab-in-indent
+
+*.rst            whitespace=tab-in-indent conflict-marker-size=79
diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake
index 557f243..6061129 100644
--- a/Auxiliary/bash-completion/cmake
+++ b/Auxiliary/bash-completion/cmake
@@ -121,14 +121,19 @@ _cmake()
                 grep -v "^cmake version " )' -- "$cur" ) )
             return
             ;;
+        --help-manual)
+            COMPREPLY=( $( compgen -W '$( cmake --help-manual-list 2>/dev/null|
+                grep -v "^cmake version " | sed -e "s/([0-9])$//" )' -- "$cur" ) )
+            return
+            ;;
         --help-module)
             COMPREPLY=( $( compgen -W '$( cmake --help-module-list 2>/dev/null|
                 grep -v "^cmake version " )' -- "$cur" ) )
             return
             ;;
          --help-policy)
-            COMPREPLY=( $( compgen -W '$( cmake --help-policies 2>/dev/null |
-                grep "^  CMP" 2>/dev/null )' -- "$cur" ) )
+            COMPREPLY=( $( compgen -W '$( cmake --help-policy-list 2>/dev/null |
+                grep -v "^cmake version " )' -- "$cur" ) )
             return
             ;;
          --help-property)
diff --git a/Auxiliary/bash-completion/cpack b/Auxiliary/bash-completion/cpack
index 05e0e93..cf5751f 100644
--- a/Auxiliary/bash-completion/cpack
+++ b/Auxiliary/bash-completion/cpack
@@ -48,6 +48,26 @@ _cpack()
                 grep -v "^cpack version " )' -- "$cur" ) )
             return
             ;;
+        --help-manual)
+            COMPREPLY=( $( compgen -W '$( cpack --help-manual-list 2>/dev/null|
+                grep -v "^cpack version " | sed -e "s/([0-9])$//" )' -- "$cur" ) )
+            return
+            ;;
+        --help-module)
+            COMPREPLY=( $( compgen -W '$( cpack --help-module-list 2>/dev/null|
+                grep -v "^cpack version " )' -- "$cur" ) )
+            return
+            ;;
+        --help-policy)
+            COMPREPLY=( $( compgen -W '$( cpack --help-policy-list 2>/dev/null |
+                grep -v "^cpack version " )' -- "$cur" ) )
+            return
+            ;;
+        --help-property)
+            COMPREPLY=( $( compgen -W '$( cpack --help-property-list \
+                2>/dev/null | grep -v "^cpack version " )' -- "$cur" ) )
+            return
+            ;;
         --help-variable)
             COMPREPLY=( $( compgen -W '$( cpack --help-variable-list \
                 2>/dev/null | grep -v "^cpack version " )' -- "$cur" ) )
diff --git a/Auxiliary/bash-completion/ctest b/Auxiliary/bash-completion/ctest
index 387672a..49343bb 100644
--- a/Auxiliary/bash-completion/ctest
+++ b/Auxiliary/bash-completion/ctest
@@ -72,11 +72,37 @@ _ctest()
             COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
             return
             ;;
+
         --help-command)
             COMPREPLY=( $( compgen -W '$( ctest --help-command-list 2>/dev/null|
                 grep -v "^ctest version " )' -- "$cur" ) )
             return
             ;;
+        --help-manual)
+            COMPREPLY=( $( compgen -W '$( ctest --help-manual-list 2>/dev/null|
+                grep -v "^ctest version " | sed -e "s/([0-9])$//" )' -- "$cur" ) )
+            return
+            ;;
+        --help-module)
+            COMPREPLY=( $( compgen -W '$( ctest --help-module-list 2>/dev/null|
+                grep -v "^ctest version " )' -- "$cur" ) )
+            return
+            ;;
+        --help-policy)
+            COMPREPLY=( $( compgen -W '$( ctest --help-policy-list 2>/dev/null |
+                grep -v "^ctest version " )' -- "$cur" ) )
+            return
+            ;;
+        --help-property)
+            COMPREPLY=( $( compgen -W '$( ctest --help-property-list \
+                2>/dev/null | grep -v "^ctest version " )' -- "$cur" ) )
+            return
+            ;;
+        --help-variable)
+            COMPREPLY=( $( compgen -W '$( ctest --help-variable-list \
+                2>/dev/null | grep -v "^ctest version " )' -- "$cur" ) )
+            return
+            ;;
     esac
 
     if [[ "$cur" == -* ]]; then
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el
index 08ac490..20def8b 100644
--- a/Auxiliary/cmake-mode.el
+++ b/Auxiliary/cmake-mode.el
@@ -228,7 +228,9 @@ the indentation.  Otherwise it retains the same position on the line"
 ;;
 ;; Indentation increment.
 ;;
-(defvar cmake-tab-width 2)
+(defcustom cmake-tab-width 2
+  "Number of columns to indent cmake blocks"
+  :type 'integer)
 
 ;------------------------------------------------------------------------------
 
@@ -304,7 +306,8 @@ and store the result as a list in LISTVAR."
           (save-window-excursion
             (cmake-command-run (concat "--help-" listname "-list") nil temp-buffer-name)
             (with-current-buffer temp-buffer-name
-              (set listvar (cdr (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n" t))))))
+              ; FIXME: Ignore first line if it is "cmake version ..." from CMake < 3.0.
+              (set listvar (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n" t)))))
       (symbol-value listvar)
       ))
   )
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9381f35..787f319 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -327,7 +327,15 @@ macro (CMAKE_BUILD_UTILITIES)
     if(CMAKE_TESTS_CDASH_SERVER)
       set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php")
     endif()
-    option(CMAKE_USE_OPENSSL "Use OpenSSL." OFF)
+    set(_CMAKE_USE_OPENSSL_DEFAULT OFF)
+    if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE
+        AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)")
+      find_package(OpenSSL QUIET)
+      if(OPENSSL_FOUND)
+        set(_CMAKE_USE_OPENSSL_DEFAULT ON)
+      endif()
+    endif()
+    option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT})
     mark_as_advanced(CMAKE_USE_OPENSSL)
     if(CMAKE_USE_OPENSSL)
       set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle")
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 0e5c7e1..ddf8407 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -23,6 +23,16 @@ Please base all new work on the ``master`` branch.  Then use
 ``git format-patch`` to produce patches suitable to post to
 the mailing list.
 
+Code Style
+==========
+
+We use `clang-format`_ to define our style for C++ code in the CMake source
+tree.  See the `.clang-format`_ configuration file for our style settings.
+Use ``clang-format`` version 3.8 or higher to format source files.
+
+.. _`clang-format`: http://clang.llvm.org/docs/ClangFormat.html
+.. _`.clang-format`: .clang-format
+
 License
 =======
 
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index abef692..a39049b 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -53,7 +53,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
   "[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"
+  "cmake.version.manifest.*manifest authoring warning.*Unrecognized Element"
   "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast
   "ld: warning: directory not found for option .-(F|L)"
   "ld: warning .*/libgcc.a archive's cputype"
@@ -62,6 +62,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
   "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.*may return deterministic values"
   "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
 
@@ -80,6 +81,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
   "index.c.*warning: Access to field.*results in a dereference of a null pointer.*loaded from variable.*"
   "cm_sha2.*warning: Value stored to.*is never read"
   "testProcess.*warning: Dereference of null pointer .loaded from variable .invalidAddress.."
+  "liblzma/simple/x86.c:[0-9]+:[0-9]+: warning: The result of the '<<' expression is undefined"
   )
 
 if(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode")
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index 8726b70..d421364 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -76,9 +76,12 @@ The options are:
   The optional ``ARGS`` argument is for backward compatibility and
   will be ignored.
 
-  If ``COMMAND`` specifies an executable target (created by the
+  If ``COMMAND`` specifies an executable target name (created by the
   :command:`add_executable` command) it will automatically be replaced
-  by the location of the executable created at build time.
+  by the location of the executable created at build time. If set, the
+  :prop_tgt:`CROSSCOMPILING_EMULATOR` executable target property will
+  also be prepended to the command to allow the executable to run on
+  the host.
   (Use the ``TARGET_FILE``
   :manual:`generator expression <cmake-generator-expressions(7)>` to
   reference an executable later in the command line.)
diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst
index 82d69db..6980d61 100644
--- a/Help/command/add_custom_target.rst
+++ b/Help/command/add_custom_target.rst
@@ -58,9 +58,12 @@ The options are:
   :command:`file(GENERATE)` command to create it, and then specify
   a ``COMMAND`` to launch it.)
 
-  If ``COMMAND`` specifies an executable target (created by the
+  If ``COMMAND`` specifies an executable target name (created by the
   :command:`add_executable` command) it will automatically be replaced
-  by the location of the executable created at build time.
+  by the location of the executable created at build time. If set, the
+  :prop_tgt:`CROSSCOMPILING_EMULATOR` executable target property will
+  also be prepended to the command to allow the executable to run on
+  the host.
   Additionally a target-level dependency will be added so that the
   executable target will be built before this custom target.
 
diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst
index 8b3fb57..19ca658 100644
--- a/Help/command/add_executable.rst
+++ b/Help/command/add_executable.rst
@@ -73,7 +73,7 @@ does not appear in the generated buildsystem as a make target.  The
 ``<target>`` may not be an :ref:`Imported Target <Imported Targets>` or an
 ``ALIAS``.  ``ALIAS`` targets can be used as targets to read properties
 from, executables for custom commands and custom targets.  They can also be
-tested for existance with the regular :command:`if(TARGET)` subcommand.
+tested for existence with the regular :command:`if(TARGET)` subcommand.
 The ``<name>`` may not be used to modify properties of ``<target>``, that
 is, it may not be used as the operand of :command:`set_property`,
 :command:`set_target_properties`, :command:`target_link_libraries` etc.
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index 5033e18..36adcbe 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -123,7 +123,7 @@ used to refer to ``<target>`` in subsequent commands.  The ``<name>`` does
 not appear in the generatedbuildsystem as a make target.  The ``<target>``
 may not be an :ref:`Imported Target <Imported Targets>` or an ``ALIAS``.
 ``ALIAS`` targets can be used as linkable targets and as targets to
-read properties from.  They can also be tested for existance with the
+read properties from.  They can also be tested for existence with the
 regular :command:`if(TARGET)` subcommand.  The ``<name>`` may not be used
 to modify properties of ``<target>``, that is, it may not be used as the
 operand of :command:`set_property`, :command:`set_target_properties`,
diff --git a/Help/command/build_command.rst b/Help/command/build_command.rst
index 1298c1f..b83edaf 100644
--- a/Help/command/build_command.rst
+++ b/Help/command/build_command.rst
@@ -35,7 +35,7 @@ compatibility.  Use the first signature instead.
 It sets the given ``<cachevariable>`` to a command-line string as
 above but without the ``--target`` option.
 The ``<makecommand>`` is ignored but should be the full path to
-msdev, devenv, nmake, make or one of the end user build tools
+devenv, nmake, make or one of the end user build tools
 for legacy invocations.
 
 .. note::
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst
index dc65a9e..9535bf3 100644
--- a/Help/command/cmake_minimum_required.rst
+++ b/Help/command/cmake_minimum_required.rst
@@ -1,29 +1,14 @@
 cmake_minimum_required
 ----------------------
 
-Set the minimum required version of cmake for a project.
-
-::
+Set the minimum required version of cmake for a project and
+update `Policy Settings`_ to match the version given::
 
   cmake_minimum_required(VERSION major.minor[.patch[.tweak]]
                          [FATAL_ERROR])
 
 If the current version of CMake is lower than that required it will
-stop processing the project and report an error.  When a version
-higher than 2.4 is specified the command implicitly invokes
-
-::
-
-  cmake_policy(VERSION major[.minor[.patch[.tweak]]])
-
-which sets the cmake policy version level to the version specified.
-When version 2.4 or lower is given the command implicitly invokes
-
-::
-
-  cmake_policy(VERSION 2.4)
-
-which enables compatibility features for CMake 2.4 and lower.
+stop processing the project and report an error.
 
 The ``FATAL_ERROR`` option is accepted but ignored by CMake 2.6 and
 higher.  It should be specified so CMake versions 2.4 and lower fail
@@ -39,3 +24,27 @@ with an error instead of just a warning.
   Calling ``cmake_minimum_required()`` inside a :command:`function`
   limits some effects to the function scope when invoked.  Such calls
   should not be made with the intention of having global effects.
+
+Policy Settings
+^^^^^^^^^^^^^^^
+
+The ``cmake_minimum_required(VERSION)`` command implicitly invokes the
+:command:`cmake_policy(VERSION)` command to specify that the current
+project 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.  This effectively requests behavior preferred
+as of a given CMake version and tells newer CMake versions to warn
+about their new policies.
+
+When a version higher than 2.4 is specified the command implicitly
+invokes::
+
+  cmake_policy(VERSION major[.minor[.patch[.tweak]]])
+
+which sets the cmake policy version level to the version specified.
+When version 2.4 or lower is given the command implicitly invokes::
+
+  cmake_policy(VERSION 2.4)
+
+which enables compatibility features for CMake 2.4 and lower.
diff --git a/Help/command/ctest_update.rst b/Help/command/ctest_update.rst
index 74af1f7..b205bca 100644
--- a/Help/command/ctest_update.rst
+++ b/Help/command/ctest_update.rst
@@ -25,3 +25,7 @@ The options are:
   have otherwise printed to the console.  CTest will still report
   the new revision of the repository and any conflicting files
   that were found.
+
+The update always follows the version control branch currently checked
+out in the source directory.  See the :ref:`CTest Update Step`
+documentation for more information.
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 96ac6c7..256d16d 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -103,8 +103,9 @@ 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.  No specific order of results is defined.  If order is important then
-sort the list explicitly (e.g. using the :command:`list(SORT)` command).
+path.  No specific order of results is defined other than that it is
+deterministic.  If order is important then sort the list explicitly
+(e.g. using the :command:`list(SORT)` command).
 
 By default ``GLOB`` lists directories - directories are omited in result if
 ``LIST_DIRECTORIES`` is set to false.
diff --git a/Help/command/find_file.rst b/Help/command/find_file.rst
index bf7a919..e56097b 100644
--- a/Help/command/find_file.rst
+++ b/Help/command/find_file.rst
@@ -14,7 +14,8 @@ find_file
 .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_INCLUDE_PATH`
 .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
 
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``INCLUDE``,
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``INCLUDE``.
+   On Windows hosts:
    ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
    is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|, and the
    directories in ``PATH`` itself.
diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst
index 5d07574..31e6ec0 100644
--- a/Help/command/find_library.rst
+++ b/Help/command/find_library.rst
@@ -14,7 +14,8 @@ find_library
 .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_LIBRARY_PATH`
 .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
 
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``LIB``,
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``LIB``.
+   On Windows hosts:
    ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
    and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|,
    and the directories in ``PATH`` itself.
diff --git a/Help/command/find_path.rst b/Help/command/find_path.rst
index 4403cb5..76342d0 100644
--- a/Help/command/find_path.rst
+++ b/Help/command/find_path.rst
@@ -14,7 +14,8 @@ find_path
 .. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_INCLUDE_PATH`
 .. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
 
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``INCLUDE``,
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``INCLUDE``.
+   On Windows hosts:
    ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
    is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|, and the
    directories in ``PATH`` itself.
diff --git a/Help/command/include_external_msproject.rst b/Help/command/include_external_msproject.rst
index 595762d..18a2b50 100644
--- a/Help/command/include_external_msproject.rst
+++ b/Help/command/include_external_msproject.rst
@@ -19,5 +19,4 @@ command to make things depend on the external project.
 ``TYPE``, ``GUID`` and ``PLATFORM`` are optional parameters that allow one to
 specify the type of project, id (GUID) of the project and the name of
 the target platform.  This is useful for projects requiring values
-other than the default (e.g.  WIX projects).  These options are not
-supported by the Visual Studio 6 generator.
+other than the default (e.g.  WIX projects).
diff --git a/Help/command/install.rst b/Help/command/install.rst
index 45167bc..aaf12cc 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -45,11 +45,15 @@ signatures that specify them.  The common options are:
   is associated, such as "runtime" or "development".  During
   component-specific installation only install rules associated with
   the given component name will be executed.  During a full installation
-  all components are installed.  If ``COMPONENT`` is not provided a
-  default component "Unspecified" is created.  The default component
-  name may be controlled with the
+  all components are installed unless marked with ``EXCLUDE_FROM_ALL``.
+  If ``COMPONENT`` is not provided a default component "Unspecified" is
+  created.  The default component name may be controlled with the
   :variable:`CMAKE_INSTALL_DEFAULT_COMPONENT_NAME` variable.
 
+``EXCLUDE_FROM_ALL``
+  Specify that the file is excluded from a full installation and only
+  installed as part of a component-specific installation
+
 ``RENAME``
   Specify a name for an installed file that may be different from the
   original file.  Renaming is allowed only when a single file is
@@ -75,7 +79,8 @@ Installing Targets
            [PERMISSIONS permissions...]
            [CONFIGURATIONS [Debug|Release|...]]
            [COMPONENT <component>]
-           [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
+           [OPTIONAL] [EXCLUDE_FROM_ALL]
+           [NAMELINK_ONLY|NAMELINK_SKIP]
           ] [...]
           [INCLUDES DESTINATION [<dir> ...]]
           )
@@ -177,7 +182,7 @@ Installing Files
           [PERMISSIONS permissions...]
           [CONFIGURATIONS [Debug|Release|...]]
           [COMPONENT <component>]
-          [RENAME <name>] [OPTIONAL])
+          [RENAME <name>] [OPTIONAL] [EXCLUDE_FROM_ALL])
 
 The ``FILES`` form specifies rules for installing files for a project.
 File names given as relative paths are interpreted with respect to the
@@ -211,7 +216,8 @@ Installing Directories
           [DIRECTORY_PERMISSIONS permissions...]
           [USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
           [CONFIGURATIONS [Debug|Release|...]]
-          [COMPONENT <component>] [FILES_MATCHING]
+          [COMPONENT <component>] [EXCLUDE_FROM_ALL]
+          [FILES_MATCHING]
           [[PATTERN <pattern> | REGEX <regex>]
            [EXCLUDE] [PERMISSIONS permissions...]] [...])
 
@@ -287,7 +293,7 @@ Custom Installation Logic
 ::
 
   install([[SCRIPT <file>] [CODE <code>]]
-          [COMPONENT <component>] [...])
+          [COMPONENT <component>] [EXCLUDE_FROM_ALL] [...])
 
 The ``SCRIPT`` form will invoke the given CMake script files during
 installation.  If the script file name is a relative path it will be
@@ -312,7 +318,8 @@ Installing Exports
           [PERMISSIONS permissions...]
           [CONFIGURATIONS [Debug|Release|...]]
           [EXPORT_LINK_INTERFACE_LIBRARIES]
-          [COMPONENT <component>])
+          [COMPONENT <component>]
+          [EXCLUDE_FROM_ALL])
 
 The ``EXPORT`` form generates and installs a CMake file containing code to
 import targets from the installation tree into another project.
diff --git a/Help/command/list.rst b/Help/command/list.rst
index a7a05c7..f6b75bc 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -9,6 +9,7 @@ List operations.
   list(GET <list> <element index> [<element index> ...]
        <output variable>)
   list(APPEND <list> [<element> ...])
+  list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>)
   list(FIND <list> <value> <output variable>)
   list(INSERT <list> <element_index> <element> [<element> ...])
   list(REMOVE_ITEM <list> <value> [<value> ...])
@@ -23,6 +24,12 @@ List operations.
 
 ``APPEND`` will append elements to the list.
 
+``FILTER`` will include or remove items from the list that match the
+mode's pattern.
+In ``REGEX`` mode, items will be matched against the given regular expression.
+For more information on regular expressions see also the :command:`string`
+command.
+
 ``FIND`` will return the index of the element specified in the list or -1
 if it wasn't found.
 
@@ -38,9 +45,9 @@ difference is that ``REMOVE_ITEM`` will remove the given items, while
 
 ``SORT`` sorts the list in-place alphabetically.
 
-The list subcommands ``APPEND``, ``INSERT``, ``REMOVE_AT``, ``REMOVE_ITEM``,
-``REMOVE_DUPLICATES``, ``REVERSE`` and ``SORT`` may create new values for
-the list within the current CMake variable scope.  Similar to the
+The list subcommands ``APPEND``, ``INSERT``, ``FILTER``, ``REMOVE_AT``,
+``REMOVE_ITEM``, ``REMOVE_DUPLICATES``, ``REVERSE`` and ``SORT`` may create new
+values for the list within the current CMake variable scope.  Similar to the
 :command:`set` command, the LIST command creates new variable values in the
 current scope, even if the list itself is actually defined in a parent
 scope.  To propagate the results of these operations upwards, use
diff --git a/Help/command/string.rst b/Help/command/string.rst
index 0361c74..3f4050e 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -277,6 +277,7 @@ specifiers:
    %j        The day of the current year (001-366).
    %m        The month of the current year (01-12).
    %M        The minute of the current hour (00-59).
+   %s        Seconds since midnight (UTC) 1-Jan-1970 (UNIX time).
    %S        The second of the current minute.
              60 represents a leap second. (00-60)
    %U        The week number of the current year (00-53).
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst
index 28dae80..7830deb 100644
--- a/Help/command/try_compile.rst
+++ b/Help/command/try_compile.rst
@@ -112,3 +112,10 @@ The current setting of :policy:`CMP0065` is set in the generated project.
 
 Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose
 a build configuration.
+
+Set the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to specify
+the type of target used for the source file signature.
+
+Set the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify
+variables that must be propagated into the test project.  This variable is
+meant for use only in toolchain files.
diff --git a/Help/generator/Ninja.rst b/Help/generator/Ninja.rst
index 920abcb..d94e5f6 100644
--- a/Help/generator/Ninja.rst
+++ b/Help/generator/Ninja.rst
@@ -6,3 +6,7 @@ Generates build.ninja files.
 A build.ninja file is generated into the build tree.  Recent versions
 of the ninja program can build the project through the "all" target.
 An "install" target is also provided.
+
+For each subdirectory ``sub/dir`` of the project an additional target
+named ``sub/dir/all`` is generated that depends on all targets required
+by that subdirectory.
diff --git a/Help/generator/Visual Studio 6.rst b/Help/generator/Visual Studio 6.rst
index 855589c..2dd07e0 100644
--- a/Help/generator/Visual Studio 6.rst	
+++ b/Help/generator/Visual Studio 6.rst	
@@ -1,10 +1,6 @@
 Visual Studio 6
 ---------------
 
-Deprected.  Generates Visual Studio 6 project files.
-
-.. note::
-  This generator is deprecated and will be removed
-  in a future version of CMake.  It will still be
-  possible to build with VS 6 tools using the
-  :generator:`NMake Makefiles` generator.
+Removed.  This once generated Visual Studio 6 project files, but the
+generator has been removed since CMake 3.6.  It is still possible to
+build with VS 6 tools using the :generator:`NMake Makefiles` generator.
diff --git a/Help/generator/Visual Studio 7 .NET 2003.rst b/Help/generator/Visual Studio 7 .NET 2003.rst
index 2034140..1c086a0 100644
--- a/Help/generator/Visual Studio 7 .NET 2003.rst	
+++ b/Help/generator/Visual Studio 7 .NET 2003.rst	
@@ -1,4 +1,10 @@
 Visual Studio 7 .NET 2003
 -------------------------
 
-Generates Visual Studio .NET 2003 project files.
+Deprecated.  Generates Visual Studio .NET 2003 project files.
+
+.. note::
+  This generator is deprecated and will be removed
+  in a future version of CMake.  It will still be
+  possible to build with VS 7.1 tools using the
+  :generator:`NMake Makefiles` generator.
diff --git a/Help/generator/Visual Studio 7.rst b/Help/generator/Visual Studio 7.rst
index eb426f4..54d29df 100644
--- a/Help/generator/Visual Studio 7.rst	
+++ b/Help/generator/Visual Studio 7.rst	
@@ -1,10 +1,6 @@
 Visual Studio 7
 ---------------
 
-Deprected.  Generates Visual Studio .NET 2002 project files.
-
-.. note::
-  This generator is deprecated and will be removed
-  in a future version of CMake.  It will still be
-  possible to build with VS 7.0 tools using the
-  :generator:`NMake Makefiles` generator.
+Removed.  This once generated Visual Studio .NET 2002 project files, but
+the generator has been removed since CMake 3.6.  It is still possible to
+build with VS 7.0 tools using the :generator:`NMake Makefiles` generator.
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index 9004bb2..07bf33f 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -150,7 +150,7 @@ and :prop_tgt:`INTERFACE_COMPILE_OPTIONS` target properties.
 Each of the commands has a ``PRIVATE``, ``PUBLIC`` and ``INTERFACE`` mode.  The
 ``PRIVATE`` mode populates only the non-``INTERFACE_`` variant of the target
 property and the ``INTERFACE`` mode populates only the ``INTERFACE_`` variants.
-The ``PUBLIC`` mode populates both variants of the repective target property.
+The ``PUBLIC`` mode populates both variants of the respective target property.
 Each command may be invoked with multiple uses of each keyword:
 
 .. code-block:: cmake
diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst
index caf5bac..7289e61 100644
--- a/Help/manual/cmake-compile-features.7.rst
+++ b/Help/manual/cmake-compile-features.7.rst
@@ -309,3 +309,4 @@ versions specified for each:
 * ``GNU``: GNU compiler versions 4.4 through 5.0.
 * ``MSVC``: Microsoft Visual Studio versions 2010 through 2015.
 * ``SunPro``: Oracle SolarisStudio version 12.4.
+* ``Intel``: Intel compiler versions 12.1 through 16.0 on UNIX platforms.
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 13ee4bd..d4f47dd 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -225,7 +225,7 @@ comparison::
   -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I>
 
 generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target
-property with each entry preceeded by ``-I``. Note that a more-complete use
+property with each entry preceded by ``-I``. Note that a more-complete use
 in this situation would require first checking if the INCLUDE_DIRECTORIES
 property is non-empty::
 
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 10f05df..62910cf 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -135,6 +135,7 @@ All Modules
    /module/FindLibLZMA
    /module/FindLibXml2
    /module/FindLibXslt
+   /module/FindLTTngUST
    /module/FindLua50
    /module/FindLua51
    /module/FindLua
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
index aebc5d9..c27c612 100644
--- a/Help/manual/cmake-packages.7.rst
+++ b/Help/manual/cmake-packages.7.rst
@@ -645,7 +645,7 @@ Disabling the Package Registry
 ------------------------------
 
 In some cases using the Package Registries is not desirable. CMake
-allows to disable them using the following variables:
+allows one to disable them using the following variables:
 
  * :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` disables the
    :command:`export(PACKAGE)` command.
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index ae5354f..43f4637 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -51,75 +51,117 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
 to determine whether to report an error on use of deprecated macros or
 functions.
 
-All Policies
-============
+Policies Introduced by CMake 3.4
+================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0065: Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property. </policy/CMP0065>
+   CMP0064: Support new TEST if() operator. </policy/CMP0064>
+
+Policies Introduced by CMake 3.3
+================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0063: Honor visibility properties for all target types. </policy/CMP0063>
+   CMP0062: Disallow install() of export() result. </policy/CMP0062>
+   CMP0061: CTest does not by default tell make to ignore errors (-i). </policy/CMP0061>
+   CMP0060: Link libraries by full path even in implicit directories. </policy/CMP0060>
+   CMP0059: Do not treat DEFINITIONS as a built-in directory property. </policy/CMP0059>
+   CMP0058: Ninja requires custom command byproducts to be explicit. </policy/CMP0058>
+   CMP0057: Support new IN_LIST if() operator. </policy/CMP0057>
+
+Policies Introduced by CMake 3.2
+================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0056: Honor link flags in try_compile() source-file signature. </policy/CMP0056>
+   CMP0055: Strict checking for break() command. </policy/CMP0055>
+
+Policies Introduced by CMake 3.1
+================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0054: Only interpret if() arguments as variables or keywords when unquoted. </policy/CMP0054>
+   CMP0053: Simplify variable reference and escape sequence evaluation. </policy/CMP0053>
+   CMP0052: Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES. </policy/CMP0052>
+   CMP0051: List TARGET_OBJECTS in SOURCES target property. </policy/CMP0051>
+
+Policies Introduced by CMake 3.0
+================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0050: Disallow add_custom_command SOURCE signatures. </policy/CMP0050>
+   CMP0049: Do not expand variables in target source entries. </policy/CMP0049>
+   CMP0048: project() command manages VERSION variables. </policy/CMP0048>
+   CMP0047: Use QCC compiler id for the qcc drivers on QNX. </policy/CMP0047>
+   CMP0046: Error on non-existent dependency in add_dependencies. </policy/CMP0046>
+   CMP0045: Error on non-existent target in get_target_property. </policy/CMP0045>
+   CMP0044: Case sensitive Lang_COMPILER_ID generator expressions. </policy/CMP0044>
+   CMP0043: Ignore COMPILE_DEFINITIONS_Config properties. </policy/CMP0043>
+   CMP0042: MACOSX_RPATH is enabled by default. </policy/CMP0042>
+   CMP0041: Error on relative include with generator expression. </policy/CMP0041>
+   CMP0040: The target in the TARGET signature of add_custom_command() must exist. </policy/CMP0040>
+   CMP0039: Utility targets may not have link dependencies. </policy/CMP0039>
+   CMP0038: Targets may not link directly to themselves. </policy/CMP0038>
+   CMP0037: Target names should not be reserved and should match a validity pattern. </policy/CMP0037>
+   CMP0036: The build_name command should not be called. </policy/CMP0036>
+   CMP0035: The variable_requires command should not be called. </policy/CMP0035>
+   CMP0034: The utility_source command should not be called. </policy/CMP0034>
+   CMP0033: The export_library_dependencies command should not be called. </policy/CMP0033>
+   CMP0032: The output_required_files command should not be called. </policy/CMP0032>
+   CMP0031: The load_command command should not be called. </policy/CMP0031>
+   CMP0030: The use_mangled_mesa command should not be called. </policy/CMP0030>
+   CMP0029: The subdir_depends command should not be called. </policy/CMP0029>
+   CMP0028: Double colon in target name means ALIAS or IMPORTED target. </policy/CMP0028>
+   CMP0027: Conditionally linked imported targets with missing include directories. </policy/CMP0027>
+   CMP0026: Disallow use of the LOCATION target property. </policy/CMP0026>
+   CMP0025: Compiler id for Apple Clang is now AppleClang. </policy/CMP0025>
+   CMP0024: Disallow include export result. </policy/CMP0024>
+
+Policies Introduced by CMake 2.8
+================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0023: Plain and keyword target_link_libraries signatures cannot be mixed. </policy/CMP0023>
+   CMP0022: INTERFACE_LINK_LIBRARIES defines the link interface. </policy/CMP0022>
+   CMP0021: Fatal error on relative paths in INCLUDE_DIRECTORIES target property. </policy/CMP0021>
+   CMP0020: Automatically link Qt executables to qtmain target on Windows. </policy/CMP0020>
+   CMP0019: Do not re-expand variables in include and link information. </policy/CMP0019>
+   CMP0018: Ignore CMAKE_SHARED_LIBRARY_Lang_FLAGS variable. </policy/CMP0018>
+   CMP0017: Prefer files from the CMake module directory when including from there. </policy/CMP0017>
+   CMP0016: target_link_libraries() reports error if its only argument is not a target. </policy/CMP0016>
+   CMP0015: link_directories() treats paths relative to the source dir. </policy/CMP0015>
+   CMP0014: Input directories must have CMakeLists.txt. </policy/CMP0014>
+   CMP0013: Duplicate binary directories are not allowed. </policy/CMP0013>
+   CMP0012: if() recognizes numbers and boolean constants. </policy/CMP0012>
+
+Policies Introduced by CMake 2.6
+================================
 
 .. toctree::
    :maxdepth: 1
 
-   /policy/CMP0000
-   /policy/CMP0001
-   /policy/CMP0002
-   /policy/CMP0003
-   /policy/CMP0004
-   /policy/CMP0005
-   /policy/CMP0006
-   /policy/CMP0007
-   /policy/CMP0008
-   /policy/CMP0009
-   /policy/CMP0010
-   /policy/CMP0011
-   /policy/CMP0012
-   /policy/CMP0013
-   /policy/CMP0014
-   /policy/CMP0015
-   /policy/CMP0016
-   /policy/CMP0017
-   /policy/CMP0018
-   /policy/CMP0019
-   /policy/CMP0020
-   /policy/CMP0021
-   /policy/CMP0022
-   /policy/CMP0023
-   /policy/CMP0024
-   /policy/CMP0025
-   /policy/CMP0026
-   /policy/CMP0027
-   /policy/CMP0028
-   /policy/CMP0029
-   /policy/CMP0030
-   /policy/CMP0031
-   /policy/CMP0032
-   /policy/CMP0033
-   /policy/CMP0034
-   /policy/CMP0035
-   /policy/CMP0036
-   /policy/CMP0037
-   /policy/CMP0038
-   /policy/CMP0039
-   /policy/CMP0040
-   /policy/CMP0041
-   /policy/CMP0042
-   /policy/CMP0043
-   /policy/CMP0044
-   /policy/CMP0045
-   /policy/CMP0046
-   /policy/CMP0047
-   /policy/CMP0048
-   /policy/CMP0049
-   /policy/CMP0050
-   /policy/CMP0051
-   /policy/CMP0052
-   /policy/CMP0053
-   /policy/CMP0054
-   /policy/CMP0055
-   /policy/CMP0056
-   /policy/CMP0057
-   /policy/CMP0058
-   /policy/CMP0059
-   /policy/CMP0060
-   /policy/CMP0061
-   /policy/CMP0062
-   /policy/CMP0063
-   /policy/CMP0064
-   /policy/CMP0065
+   CMP0011: Included scripts do automatic cmake_policy PUSH and POP. </policy/CMP0011>
+   CMP0010: Bad variable reference syntax is an error. </policy/CMP0010>
+   CMP0009: FILE GLOB_RECURSE calls should not follow symlinks by default. </policy/CMP0009>
+   CMP0008: Libraries linked by full-path must have a valid library file name. </policy/CMP0008>
+   CMP0007: list command no longer ignores empty elements. </policy/CMP0007>
+   CMP0006: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. </policy/CMP0006>
+   CMP0005: Preprocessor definition values are now escaped automatically. </policy/CMP0005>
+   CMP0004: Libraries linked may not have leading or trailing whitespace. </policy/CMP0004>
+   CMP0003: Libraries linked via full path no longer produce linker search paths. </policy/CMP0003>
+   CMP0002: Logical target names must be globally unique. </policy/CMP0002>
+   CMP0001: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. </policy/CMP0001>
+   CMP0000: A minimum required CMake version must be specified. </policy/CMP0000>
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index a41d484..3403dcd 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -76,6 +76,7 @@ Properties on Directories
    /prop_dir/VARIABLES
    /prop_dir/VS_GLOBAL_SECTION_POST_section
    /prop_dir/VS_GLOBAL_SECTION_PRE_section
+   /prop_dir/VS_STARTUP_PROJECT
 
 .. _`Target Properties`:
 
@@ -141,6 +142,7 @@ Properties on Targets
    /prop_tgt/CXX_STANDARD_REQUIRED
    /prop_tgt/DEBUG_POSTFIX
    /prop_tgt/DEFINE_SYMBOL
+   /prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY
    /prop_tgt/EchoString
    /prop_tgt/ENABLE_EXPORTS
    /prop_tgt/EXCLUDE_FROM_ALL
@@ -195,6 +197,7 @@ Properties on Targets
    /prop_tgt/JOB_POOL_COMPILE
    /prop_tgt/JOB_POOL_LINK
    /prop_tgt/LABELS
+   /prop_tgt/LANG_CLANG_TIDY
    /prop_tgt/LANG_COMPILER_LAUNCHER
    /prop_tgt/LANG_INCLUDE_WHAT_YOU_USE
    /prop_tgt/LANG_VISIBILITY_PRESET
@@ -255,6 +258,7 @@ Properties on Targets
    /prop_tgt/TYPE
    /prop_tgt/VERSION
    /prop_tgt/VISIBILITY_INLINES_HIDDEN
+   /prop_tgt/VS_CONFIGURATION_TYPE
    /prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
    /prop_tgt/VS_DOTNET_REFERENCES
    /prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
@@ -302,6 +306,7 @@ Properties on Tests
    /prop_test/RUN_SERIAL
    /prop_test/SKIP_RETURN_CODE
    /prop_test/TIMEOUT
+   /prop_test/TIMEOUT_AFTER_MATCH
    /prop_test/WILL_FAIL
    /prop_test/WORKING_DIRECTORY
 
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index 7b294a8..390220c 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -138,9 +138,10 @@ a path on the host to install to. The :variable:`CMAKE_INSTALL_PREFIX` is always
 the runtime installation location, even when cross-compiling.
 
 The :variable:`CMAKE_<LANG>_COMPILER` variables may be set to full paths, or to
-names of compilers to search for in standard locations. In cases where CMake does
-not have enough information to extract information from the compiler, the
-:module:`CMakeForceCompiler` module can be used to bypass some of the checks.
+names of compilers to search for in standard locations.   For toolchains that
+do not support linking binaries without custom flags or scripts one may set
+the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to ``STATIC_LIBRARY``
+to tell CMake not to try to link executables during its checks.
 
 CMake ``find_*`` commands will look in the sysroot, and the :variable:`CMAKE_FIND_ROOT_PATH`
 entries by default in all cases, as well as looking in the host system root prefix.
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 15eaece..85b8eae 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -68,7 +68,6 @@ Variables that Provide Information
    /variable/CMAKE_SKIP_INSTALL_RULES
    /variable/CMAKE_SKIP_RPATH
    /variable/CMAKE_SOURCE_DIR
-   /variable/CMAKE_STANDARD_LIBRARIES
    /variable/CMAKE_STATIC_LIBRARY_PREFIX
    /variable/CMAKE_STATIC_LIBRARY_SUFFIX
    /variable/CMAKE_TOOLCHAIN_FILE
@@ -78,7 +77,6 @@ Variables that Provide Information
    /variable/CMAKE_VS_DEVENV_COMMAND
    /variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
    /variable/CMAKE_VS_MSBUILD_COMMAND
-   /variable/CMAKE_VS_MSDEV_COMMAND
    /variable/CMAKE_VS_NsightTegra_VERSION
    /variable/CMAKE_VS_PLATFORM_NAME
    /variable/CMAKE_VS_PLATFORM_TOOLSET
@@ -115,7 +113,12 @@ Variables that Change Behavior
    /variable/CMAKE_COLOR_MAKEFILE
    /variable/CMAKE_CONFIGURATION_TYPES
    /variable/CMAKE_DEBUG_TARGET_PROPERTIES
+   /variable/CMAKE_DEPENDS_IN_PROJECT_ONLY
    /variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName
+   /variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
+   /variable/CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
+   /variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS
+   /variable/CMAKE_ECLIPSE_VERSION
    /variable/CMAKE_ERROR_DEPRECATED
    /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
    /variable/CMAKE_EXPORT_COMPILE_COMMANDS
@@ -175,6 +178,7 @@ Variables that Describe the System
    /variable/CMAKE_CL_64
    /variable/CMAKE_COMPILER_2005
    /variable/CMAKE_HOST_APPLE
+   /variable/CMAKE_HOST_SOLARIS
    /variable/CMAKE_HOST_SYSTEM_NAME
    /variable/CMAKE_HOST_SYSTEM_PROCESSOR
    /variable/CMAKE_HOST_SYSTEM
@@ -259,6 +263,7 @@ Variables that Control the Build
    /variable/CMAKE_INSTALL_RPATH
    /variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH
    /variable/CMAKE_IOS_INSTALL_COMBINED
+   /variable/CMAKE_LANG_CLANG_TIDY
    /variable/CMAKE_LANG_COMPILER_LAUNCHER
    /variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE
    /variable/CMAKE_LANG_VISIBILITY_PRESET
@@ -275,6 +280,7 @@ Variables that Control the Build
    /variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG
    /variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG
    /variable/CMAKE_MODULE_LINKER_FLAGS
+   /variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX
    /variable/CMAKE_NO_BUILTIN_CHRPATH
    /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED
    /variable/CMAKE_OSX_ARCHITECTURES
@@ -292,6 +298,8 @@ Variables that Control the Build
    /variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG
    /variable/CMAKE_STATIC_LINKER_FLAGS
    /variable/CMAKE_TRY_COMPILE_CONFIGURATION
+   /variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
+   /variable/CMAKE_TRY_COMPILE_TARGET_TYPE
    /variable/CMAKE_USE_RELATIVE_PATHS
    /variable/CMAKE_VISIBILITY_INLINES_HIDDEN
    /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
@@ -358,6 +366,8 @@ Variables for Languages
    /variable/CMAKE_LANG_SIMULATE_VERSION
    /variable/CMAKE_LANG_SIZEOF_DATA_PTR
    /variable/CMAKE_LANG_SOURCE_FILE_EXTENSIONS
+   /variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES
+   /variable/CMAKE_LANG_STANDARD_LIBRARIES
    /variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG
 
 Variables for CTest
@@ -406,6 +416,7 @@ Variables for CTest
    /variable/CTEST_DROP_SITE_USER
    /variable/CTEST_EXTRA_COVERAGE_GLOB
    /variable/CTEST_GIT_COMMAND
+   /variable/CTEST_GIT_INIT_SUBMODULES
    /variable/CTEST_GIT_UPDATE_CUSTOM
    /variable/CTEST_GIT_UPDATE_OPTIONS
    /variable/CTEST_HG_COMMAND
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 92f5230..65153af 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -10,7 +10,7 @@ Synopsis
 
  cmake [<options>] (<path-to-source> | <path-to-existing-build>)
  cmake [(-D <var>=<value>)...] -P <cmake-script-file>
- cmake --build <dir> [<options>] [-- <build-tool-options>...]
+ cmake --build <dir> [<options>...] [-- <build-tool-options>...]
  cmake -E <command> [<options>...]
  cmake --find-package <options>...
 
@@ -49,22 +49,7 @@ Options
  display help for each variable.
 
 ``--build <dir>``
- Build a CMake-generated project binary tree.
-
- This abstracts a native build tool's command-line interface with the
- following options:
-
- ::
-
-   <dir>          = Project binary directory to be built.
-   --target <tgt> = Build <tgt> instead of default targets.
-   --config <cfg> = For multi-configuration tools, choose <cfg>.
-   --clean-first  = Build target 'clean' first, then build.
-                    (To clean only, use --target 'clean'.)
-   --use-stderr   = Ignored.  Behavior is default in CMake >= 3.0.
-   --             = Pass remaining options to the native tool.
-
- Run cmake --build with no options for quick help.
+ See `Build Tool Mode`_.
 
 ``-N``
  View mode only.
@@ -81,12 +66,7 @@ Options
  done before the -P argument.
 
 ``--find-package``
- Run in pkg-config like mode.
-
- Search a package using find_package() and print the resulting flags
- to stdout.  This can be used to use cmake instead of pkg-config to
- find installed libraries in plain Makefile-based projects or in
- autoconf-based projects (via share/aclocal/cmake.m4).
+ See `Find-Package Tool Mode`_.
 
 ``--graphviz=[file]``
  Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more.
@@ -153,6 +133,38 @@ Options
 
 .. include:: OPTIONS_HELP.txt
 
+Build Tool Mode
+===============
+
+CMake provides a command-line signature to build an already-generated
+project binary tree::
+
+ cmake --build <dir> [<options>...] [-- <build-tool-options>...]
+
+This abstracts a native build tool's command-line interface with the
+following options:
+
+``--build <dir>``
+  Project binary directory to be built.  This is required and must be first.
+
+``--target <tgt>``
+  Build ``<tgt>`` instead of default targets.  May only be specified once.
+
+``--config <cfg>``
+  For multi-configuration tools, choose configuration ``<cfg>``.
+
+``--clean-first``
+  Build target ``clean`` first, then build.
+  (To clean only, use ``--target clean``.)
+
+``--use-stderr``
+  Ignored.  Behavior is default in CMake >= 3.0.
+
+``--``
+  Pass remaining options to the native tool.
+
+Run ``cmake --build`` with no options for quick help.
+
 Command-Line Tool Mode
 ======================
 
@@ -168,7 +180,7 @@ Available commands are:
 
 ``compare_files <file1> <file2>``
   Check if ``<file1>`` is same as ``<file2>``. If files are the same,
-  then returns 0, if not itreturns 1.
+  then returns 0, if not it returns 1.
 
 ``copy <file>... <destination>``
   Copy files to ``<destination>`` (either file or directory).
@@ -203,7 +215,10 @@ Available commands are:
   silently ignored.
 
 ``md5sum <file>...``
-  Compute md5sum of files.
+  Create MD5 checksum of files in ``md5sum`` compatible format::
+
+     351abe79cd3800b38cdfb25d45015a15  file1.txt
+     052f86c15bbde68af55c7f7b340ab639  file2.txt
 
 ``remove [-f] <file>...``
   Remove the file(s), use ``-f`` to force it.  If a file does
@@ -274,6 +289,24 @@ The following ``cmake -E`` commands are available only on Windows:
 ``write_regv <key> <value>``
   Write Windows registry value.
 
+Find-Package Tool Mode
+======================
+
+CMake provides a helper for Makefile-based projects with the signature::
+
+  cmake --find-package <options>...
+
+This runs in a pkg-config like mode.
+
+Search a package using :command:`find_package()` and print the resulting flags
+to stdout.  This can be used to use cmake instead of pkg-config to find
+installed libraries in plain Makefile-based projects or in autoconf-based
+projects (via ``share/aclocal/cmake.m4``).
+
+.. note::
+  This mode is not well-supported due to some technical limitations.
+  It is kept for compatibility but should not be used in new projects.
+
 See Also
 ========
 
diff --git a/Help/manual/cpack.1.rst b/Help/manual/cpack.1.rst
index ba2086e..4f9f28d 100644
--- a/Help/manual/cpack.1.rst
+++ b/Help/manual/cpack.1.rst
@@ -65,7 +65,7 @@ Options
 ``-P <package name>``
  override/define CPACK_PACKAGE_NAME
 
- If the package name is not specified on cpack commmand line
+ If the package name is not specified on cpack command line
  thenCPack.cmake defines it as CMAKE_PROJECT_NAME
 
 ``-R <package version>``
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 2fdf7f3..e797333 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -589,6 +589,17 @@ Configuration settings to specify the version control tool include:
   * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
   * :module:`CTest` module variable: ``GITCOMMAND``
 
+  The source tree is updated by ``git fetch`` followed by
+  ``git reset --hard`` to the ``FETCH_HEAD``.  The result is the same
+  as ``git pull`` except that any local moficiations are overwritten.
+  Use ``GITUpdateCustom`` to specify a different approach.
+
+``GITInitSubmodules``
+  If set, CTest will update the repository's submodules before updating.
+
+  * `CTest Script`_ variable: :variable:`CTEST_GIT_INIT_SUBMODULES`
+  * :module:`CTest` module variable: ``CTEST_GIT_INIT_SUBMODULES``
+
 ``GITUpdateCustom``
   Specify a custom command line (as a semicolon-separated list) to run
   in the source tree (Git work tree) to update it instead of running
diff --git a/Help/module/FindLTTngUST.rst b/Help/module/FindLTTngUST.rst
new file mode 100644
index 0000000..a775462
--- /dev/null
+++ b/Help/module/FindLTTngUST.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindLTTngUST.cmake
diff --git a/Help/policy/CMP0059.rst b/Help/policy/CMP0059.rst
index 5da479a..bce982e 100644
--- a/Help/policy/CMP0059.rst
+++ b/Help/policy/CMP0059.rst
@@ -1,7 +1,7 @@
 CMP0059
 -------
 
-Don't treat ``DEFINITIONS`` as a built-in directory property.
+Do not treat ``DEFINITIONS`` as a built-in directory property.
 
 CMake 3.3 and above no longer make a list of definitions available through
 the :prop_dir:`DEFINITIONS` directory property.  The
diff --git a/Help/prop_dir/COMPILE_DEFINITIONS.rst b/Help/prop_dir/COMPILE_DEFINITIONS.rst
index ab7e7f0..85adcb5 100644
--- a/Help/prop_dir/COMPILE_DEFINITIONS.rst
+++ b/Help/prop_dir/COMPILE_DEFINITIONS.rst
@@ -17,8 +17,7 @@ This property will be initialized in each directory by its value in the
 directory's parent.
 
 CMake will automatically drop some definitions that are not supported
-by the native build tool.  The VS6 IDE does not support definition
-values with spaces (but NMake does).
+by the native build tool.
 
 .. include:: /include/COMPILE_DEFINITIONS_DISCLAIMER.txt
 
diff --git a/Help/prop_dir/INCLUDE_DIRECTORIES.rst b/Help/prop_dir/INCLUDE_DIRECTORIES.rst
index baba49b..6789a56 100644
--- a/Help/prop_dir/INCLUDE_DIRECTORIES.rst
+++ b/Help/prop_dir/INCLUDE_DIRECTORIES.rst
@@ -13,7 +13,7 @@ directories for the compiler.
 In addition to accepting values from that command, values may be set
 directly on any directory using the :command:`set_property` command.  A
 directory gets its initial value from its parent directory if it has one.
-The intial value of the :prop_tgt:`INCLUDE_DIRECTORIES` target property
+The initial value of the :prop_tgt:`INCLUDE_DIRECTORIES` target property
 comes from the value of this property.  Both directory and target property
 values are adjusted by calls to the :command:`include_directories` command.
 
diff --git a/Help/prop_dir/LISTFILE_STACK.rst b/Help/prop_dir/LISTFILE_STACK.rst
index f729c1e..22ec4b6 100644
--- a/Help/prop_dir/LISTFILE_STACK.rst
+++ b/Help/prop_dir/LISTFILE_STACK.rst
@@ -5,5 +5,6 @@ The current stack of listfiles being processed.
 
 This property is mainly useful when trying to debug errors in your
 CMake scripts.  It returns a list of what list files are currently
-being processed, in order.  So if one listfile does an INCLUDE command
-then that is effectively pushing the included listfile onto the stack.
+being processed, in order.  So if one listfile does an
+:command:`include` command then that is effectively pushing the
+included listfile onto the stack.
diff --git a/Help/prop_dir/VS_STARTUP_PROJECT.rst b/Help/prop_dir/VS_STARTUP_PROJECT.rst
new file mode 100644
index 0000000..04441b6
--- /dev/null
+++ b/Help/prop_dir/VS_STARTUP_PROJECT.rst
@@ -0,0 +1,18 @@
+VS_STARTUP_PROJECT
+------------------
+
+Specify the default startup project in a Visual Studio solution.
+
+The :ref:`Visual Studio Generators` create a ``.sln`` file for each directory
+whose ``CMakeLists.txt`` file calls the :command:`project` command.  Set this
+property in the same directory as a :command:`project` command call (e.g. in
+the top-level ``CMakeLists.txt`` file) to specify the default startup project
+for the correpsonding solution file.
+
+The property must be set to the name of an existing target.  This
+will cause that project to be listed first in the generated solution
+file causing Visual Studio to make it the startup project if the
+solution has never been opened before.
+
+If this property is not specified, then the ``ALL_BUILD`` project
+will be the default.
diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
index 3db4f18..e8f4d2a 100644
--- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
+++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
@@ -270,7 +270,7 @@ The features known to this version of CMake are:
   .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
 
 ``cxx_uniform_initialization``
-  Uniform intialization, as defined in N2640_.
+  Uniform initialization, as defined in N2640_.
 
   .. _N2640: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf
 
diff --git a/Help/prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS.rst b/Help/prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS.rst
index 185246c..e52f8eb 100644
--- a/Help/prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS.rst
+++ b/Help/prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS.rst
@@ -1,9 +1,10 @@
 FIND_LIBRARY_USE_LIB64_PATHS
 ----------------------------
 
-Whether FIND_LIBRARY should automatically search lib64 directories.
+Whether :command:`find_library` should automatically search lib64
+directories.
 
 FIND_LIBRARY_USE_LIB64_PATHS is a boolean specifying whether the
-FIND_LIBRARY command should automatically search the lib64 variant of
-directories called lib in the search path when building 64-bit
-binaries.
+:command:`find_library` command should automatically search the lib64
+variant of directories called lib in the search path when building
+64-bit binaries.
diff --git a/Help/prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING.rst b/Help/prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING.rst
index 9a3edd8..beb94ac 100644
--- a/Help/prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING.rst
+++ b/Help/prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING.rst
@@ -1,9 +1,10 @@
 FIND_LIBRARY_USE_OPENBSD_VERSIONING
 -----------------------------------
 
-Whether FIND_LIBRARY should find OpenBSD-style shared libraries.
+Whether :command:`find_library` should find OpenBSD-style shared
+libraries.
 
-This property is a boolean specifying whether the FIND_LIBRARY command
-should find shared libraries with OpenBSD-style versioned extension:
-".so.<major>.<minor>".  The property is set to true on OpenBSD and
-false on other platforms.
+This property is a boolean specifying whether the
+:command:`find_library` command should find shared libraries with
+OpenBSD-style versioned extension: ".so.<major>.<minor>".  The
+property is set to true on OpenBSD and false on other platforms.
diff --git a/Help/prop_gbl/IN_TRY_COMPILE.rst b/Help/prop_gbl/IN_TRY_COMPILE.rst
index 3a2ef5b..fd2d2e1 100644
--- a/Help/prop_gbl/IN_TRY_COMPILE.rst
+++ b/Help/prop_gbl/IN_TRY_COMPILE.rst
@@ -3,4 +3,5 @@ IN_TRY_COMPILE
 
 Read-only property that is true during a try-compile configuration.
 
-True when building a project inside a TRY_COMPILE or TRY_RUN command.
+True when building a project inside a :command:`try_compile` or
+:command:`try_run` command.
diff --git a/Help/prop_gbl/PREDEFINED_TARGETS_FOLDER.rst b/Help/prop_gbl/PREDEFINED_TARGETS_FOLDER.rst
index e85b823..bf8c9a3 100644
--- a/Help/prop_gbl/PREDEFINED_TARGETS_FOLDER.rst
+++ b/Help/prop_gbl/PREDEFINED_TARGETS_FOLDER.rst
@@ -5,5 +5,5 @@ Name of FOLDER for targets that are added automatically by CMake.
 
 If not set, CMake uses "CMakePredefinedTargets" as a default value for
 this property.  Targets such as INSTALL, PACKAGE and RUN_TESTS will be
-organized into this FOLDER.  See also the documentation for the FOLDER
-target property.
+organized into this FOLDER.  See also the documentation for the
+:prop_tgt:`FOLDER` target property.
diff --git a/Help/prop_gbl/RULE_MESSAGES.rst b/Help/prop_gbl/RULE_MESSAGES.rst
index 38d83a3..87a5ca6 100644
--- a/Help/prop_gbl/RULE_MESSAGES.rst
+++ b/Help/prop_gbl/RULE_MESSAGES.rst
@@ -8,6 +8,6 @@ progress message describing what each build rule does.  If the
 property is not set the default is ON.  Set the property to OFF to
 disable granular messages and report only as each target completes.
 This is intended to allow scripted builds to avoid the build time cost
-of detailed reports.  If a CMAKE_RULE_MESSAGES cache entry exists its
-value initializes the value of this property.  Non-Makefile generators
-currently ignore this property.
+of detailed reports.  If a ``CMAKE_RULE_MESSAGES`` cache entry exists
+its value initializes the value of this property.  Non-Makefile
+generators currently ignore this property.
diff --git a/Help/prop_gbl/USE_FOLDERS.rst b/Help/prop_gbl/USE_FOLDERS.rst
index fdbca9f..a1b4ccb 100644
--- a/Help/prop_gbl/USE_FOLDERS.rst
+++ b/Help/prop_gbl/USE_FOLDERS.rst
@@ -1,9 +1,10 @@
 USE_FOLDERS
 -----------
 
-Use the FOLDER target property to organize targets into folders.
+Use the :prop_tgt:`FOLDER` target property to organize targets into
+folders.
 
 If not set, CMake treats this property as OFF by default.  CMake
 generators that are capable of organizing into a hierarchy of folders
-use the values of the FOLDER target property to name those folders.
-See also the documentation for the FOLDER target property.
+use the values of the :prop_tgt:`FOLDER` target property to name those
+folders. See also the documentation for the FOLDER target property.
diff --git a/Help/prop_sf/COMPILE_DEFINITIONS.rst b/Help/prop_sf/COMPILE_DEFINITIONS.rst
index 7f7e7c7..1626825 100644
--- a/Help/prop_sf/COMPILE_DEFINITIONS.rst
+++ b/Help/prop_sf/COMPILE_DEFINITIONS.rst
@@ -13,8 +13,7 @@ the name COMPILE_DEFINITIONS_<CONFIG> where <CONFIG> is an upper-case
 name (ex.  "COMPILE_DEFINITIONS_DEBUG").
 
 CMake will automatically drop some definitions that are not supported
-by the native build tool.  The VS6 IDE does not support definition
-values with spaces (but NMake does).  Xcode does not support
-per-configuration definitions on source files.
+by the native build tool.  Xcode does not support per-configuration
+definitions on source files.
 
 .. include:: /include/COMPILE_DEFINITIONS_DISCLAIMER.txt
diff --git a/Help/prop_sf/COMPILE_FLAGS.rst b/Help/prop_sf/COMPILE_FLAGS.rst
index daba502..086a063 100644
--- a/Help/prop_sf/COMPILE_FLAGS.rst
+++ b/Help/prop_sf/COMPILE_FLAGS.rst
@@ -4,5 +4,5 @@ COMPILE_FLAGS
 Additional flags to be added when compiling this source file.
 
 These flags will be added to the list of compile flags when this
-source file builds.  Use COMPILE_DEFINITIONS to pass additional
-preprocessor definitions.
+source file builds.  Use :prop_sf:`COMPILE_DEFINITIONS` to pass
+additional preprocessor definitions.
diff --git a/Help/prop_test/ATTACHED_FILES_ON_FAIL.rst b/Help/prop_test/ATTACHED_FILES_ON_FAIL.rst
index 6819143..add54b2 100644
--- a/Help/prop_test/ATTACHED_FILES_ON_FAIL.rst
+++ b/Help/prop_test/ATTACHED_FILES_ON_FAIL.rst
@@ -3,5 +3,5 @@ ATTACHED_FILES_ON_FAIL
 
 Attach a list of files to a dashboard submission if the test fails.
 
-Same as ATTACHED_FILES, but these files will only be included if the
-test does not pass.
+Same as :prop_test:`ATTACHED_FILES`, but these files will only be
+included if the test does not pass.
diff --git a/Help/prop_test/TIMEOUT_AFTER_MATCH.rst b/Help/prop_test/TIMEOUT_AFTER_MATCH.rst
new file mode 100644
index 0000000..a191a9c
--- /dev/null
+++ b/Help/prop_test/TIMEOUT_AFTER_MATCH.rst
@@ -0,0 +1,37 @@
+TIMEOUT_AFTER_MATCH
+-------------------
+
+Change a test's timeout duration after a matching line is encountered
+in its output.
+
+Usage
+^^^^^
+
+.. code-block:: cmake
+
+ add_test(mytest ...)
+ set_property(TEST mytest PROPERTY TIMEOUT_AFTER_MATCH "${seconds}" "${regex}")
+
+Description
+^^^^^^^^^^^
+
+Allow a test ``seconds`` to complete after ``regex`` is encountered in
+its output.
+
+When the test outputs a line that matches ``regex`` its start time is
+reset to the current time and its timeout duration is changed to
+``seconds``.  Prior to this, the timeout duration is determined by the
+:prop_test:`TIMEOUT` property or the :variable:`CTEST_TEST_TIMEOUT`
+variable if either of these are set.
+
+:prop_test:`TIMEOUT_AFTER_MATCH` is useful for avoiding spurious
+timeouts when your test must wait for some system resource to become
+available before it can execute.  Set :prop_test:`TIMEOUT` to a longer
+duration that accounts for resource acquisition and use
+:prop_test:`TIMEOUT_AFTER_MATCH` to control how long the actual test
+is allowed to run.
+
+If the required resource can be controlled by CTest you should use
+:prop_test:`RESOURCE_LOCK` instead of :prop_test:`TIMEOUT_AFTER_MATCH`.
+This property should be used when only the test itself can determine
+when its required resources are available.
diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst
index 045ebb2..8143ba9 100644
--- a/Help/prop_tgt/AUTOMOC.rst
+++ b/Help/prop_tgt/AUTOMOC.rst
@@ -6,22 +6,35 @@ Should the target be processed with automoc (for Qt projects).
 AUTOMOC is a boolean specifying whether CMake will handle the Qt ``moc``
 preprocessor automatically, i.e.  without having to use the
 :module:`QT4_WRAP_CPP() <FindQt4>` or QT5_WRAP_CPP() macro.  Currently Qt4 and Qt5 are
-supported.  When this property is set ``ON``, CMake will scan the
-source files at build time and invoke moc accordingly.  If an ``#include``
-statement like ``#include "moc_foo.cpp"`` is found, the ``Q_OBJECT`` class
-declaration is expected in the header, and ``moc`` is run on the header
-file.  If an ``#include`` statement like ``#include "foo.moc"`` is found, then
-a ``Q_OBJECT`` is expected in the current source file and ``moc`` is run on
-the file itself.  Additionally, header files with the same base name (like
-``foo.h``) or ``_p`` appended to the base name (like ``foo_p.h``) are parsed
-for ``Q_OBJECT`` macros, and if found, ``moc`` is also executed on those files.
-``AUTOMOC`` checks multiple header alternative extensions, such as
-``hpp``, ``hxx`` etc when searching for headers.
-The resulting moc files, which are not included as shown above in any
-of the source files are included in a generated
-``<targetname>_automoc.cpp`` file, which is compiled as part of the
-target.  This property is initialized by the value of the
-:variable:`CMAKE_AUTOMOC` variable if it is set when a target is created.
+supported.
+
+When this property is set ``ON``, CMake will scan the
+source files at build time and invoke moc accordingly.
+
+* If an ``#include`` statement like ``#include "moc_foo.cpp"`` is found,
+  the ``Q_OBJECT`` class declaration is expected in the header, and
+  ``moc`` is run on the header file.  A ``moc_foo.cpp`` file will be
+  generated from the source's header into the
+  :variable:`CMAKE_CURRENT_BINARY_DIR` directory.  This allows the
+  compiler to find the included ``moc_foo.cpp`` file regardless of the
+  location the original source.  However, if multiple source files
+  in different directories do this then their generated moc files would
+  collide.  In this case a diagnostic will be issued.
+
+* If an ``#include`` statement like ``#include "foo.moc"`` is found,
+  then a ``Q_OBJECT`` is expected in the current source file and ``moc``
+  is run on the file itself.  Additionally, header files with the same
+  base name (like ``foo.h``) or ``_p`` appended to the base name (like
+  ``foo_p.h``) are parsed for ``Q_OBJECT`` macros, and if found, ``moc``
+  is also executed on those files.  ``AUTOMOC`` checks multiple header
+  alternative extensions, such as ``hpp``, ``hxx`` etc when searching
+  for headers.  The resulting moc files, which are not included as shown
+  above in any of the source files are included in a generated
+  ``<targetname>_automoc.cpp`` file, which is compiled as part of the
+  target.
+
+This property is initialized by the value of the :variable:`CMAKE_AUTOMOC`
+variable if it is set when a target is created.
 
 Additional command line options for moc can be set via the
 :prop_tgt:`AUTOMOC_MOC_OPTIONS` property.
diff --git a/Help/prop_tgt/COMPILE_DEFINITIONS.rst b/Help/prop_tgt/COMPILE_DEFINITIONS.rst
index 00c49c3..059f913 100644
--- a/Help/prop_tgt/COMPILE_DEFINITIONS.rst
+++ b/Help/prop_tgt/COMPILE_DEFINITIONS.rst
@@ -11,8 +11,7 @@ automatically escape the value correctly for the native build system
 values).
 
 CMake will automatically drop some definitions that are not supported
-by the native build tool.  The VS6 IDE does not support definition
-values with spaces (but NMake does).
+by the native build tool.
 
 .. include:: /include/COMPILE_DEFINITIONS_DISCLAIMER.txt
 
diff --git a/Help/prop_tgt/COMPILE_FLAGS.rst b/Help/prop_tgt/COMPILE_FLAGS.rst
index 6ee6c51..1a5389e 100644
--- a/Help/prop_tgt/COMPILE_FLAGS.rst
+++ b/Help/prop_tgt/COMPILE_FLAGS.rst
@@ -3,9 +3,9 @@ COMPILE_FLAGS
 
 Additional flags to use when compiling this target's sources.
 
-The COMPILE_FLAGS property sets additional compiler flags used to
-build sources within the target.  Use COMPILE_DEFINITIONS to pass
-additional preprocessor definitions.
+The ``COMPILE_FLAGS`` property sets additional compiler flags used to
+build sources within the target.  Use :prop_tgt:`COMPILE_DEFINITIONS`
+to pass additional preprocessor definitions.
 
-This property is deprecated.  Use the COMPILE_OPTIONS property or the
-target_compile_options command instead.
+This property is deprecated.  Use the :prop_tgt:`COMPILE_OPTIONS`
+property or the command:`target_compile_options` command instead.
diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst
index 36d786a..892ac23 100644
--- a/Help/prop_tgt/COMPILE_OPTIONS.rst
+++ b/Help/prop_tgt/COMPILE_OPTIONS.rst
@@ -7,7 +7,7 @@ This property holds a :ref:`;-list <CMake Language Lists>` of options
 specified so far for its target.  Use the :command:`target_compile_options`
 command to append more options.
 
-This property is intialized by the :prop_dir:`COMPILE_OPTIONS` directory
+This property is initialized by the :prop_dir:`COMPILE_OPTIONS` directory
 property when a target is created, and is used by the generators to set
 the options for the compiler.
 
diff --git a/Help/prop_tgt/COMPILE_PDB_NOTE.txt b/Help/prop_tgt/COMPILE_PDB_NOTE.txt
index 5941d72..43003d9 100644
--- a/Help/prop_tgt/COMPILE_PDB_NOTE.txt
+++ b/Help/prop_tgt/COMPILE_PDB_NOTE.txt
@@ -3,6 +3,3 @@
  ``/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/CROSSCOMPILING_EMULATOR.rst b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
index 3ef8e03..d30a2f2 100644
--- a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
+++ b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
@@ -1,6 +1,7 @@
 CROSSCOMPILING_EMULATOR
 -----------------------
 
-Use the given emulator to run executables created when crosscompiling.  This
-command will be added as a prefix to :command:`add_test` test commands for
-built target system executables.
+Use the given emulator to run executables created when crosscompiling.
+This command will be added as a prefix to :command:`add_test`,
+:command:`add_custom_command`, and :command:`add_custom_target` commands
+for built target system executables.
diff --git a/Help/prop_tgt/CXX_EXTENSIONS.rst b/Help/prop_tgt/CXX_EXTENSIONS.rst
index 0f547e2..280bb3a 100644
--- a/Help/prop_tgt/CXX_EXTENSIONS.rst
+++ b/Help/prop_tgt/CXX_EXTENSIONS.rst
@@ -6,7 +6,8 @@ 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.
+property is ``ON`` by default. The basic C++ standard level is
+controlled by the :prop_tgt:`CXX_STANDARD` target property.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst
index edc9ba5..5b186c1 100644
--- a/Help/prop_tgt/CXX_STANDARD.rst
+++ b/Help/prop_tgt/CXX_STANDARD.rst
@@ -22,6 +22,8 @@ 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.
+Additionally, the :prop_tgt:`CXX_EXTENSIONS` target property may be used to
+control whether compiler-specific extensions are enabled on a per-target basis.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Help/prop_tgt/C_EXTENSIONS.rst b/Help/prop_tgt/C_EXTENSIONS.rst
index fce67f4..05b14ce 100644
--- a/Help/prop_tgt/C_EXTENSIONS.rst
+++ b/Help/prop_tgt/C_EXTENSIONS.rst
@@ -6,7 +6,8 @@ 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.
+property is ``ON`` by default. The basic C standard level is
+controlled by the :prop_tgt:`C_STANDARD` target property.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Help/prop_tgt/C_STANDARD.rst b/Help/prop_tgt/C_STANDARD.rst
index 5e36821..815a686 100644
--- a/Help/prop_tgt/C_STANDARD.rst
+++ b/Help/prop_tgt/C_STANDARD.rst
@@ -22,6 +22,8 @@ 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.
+Additionally, the :prop_tgt:`C_EXTENSIONS` target property may be used to
+control whether compiler-specific extensions are enabled on a per-target basis.
 
 See the :manual:`cmake-compile-features(7)` manual for information on
 compile features and a list of supported compilers.
diff --git a/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst b/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst
new file mode 100644
index 0000000..1ff5bf0
--- /dev/null
+++ b/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst
@@ -0,0 +1,18 @@
+DEPLOYMENT_REMOTE_DIRECTORY
+---------------------------
+
+Set the WinCE project ``RemoteDirectory`` in ``DeploymentTool`` and
+``RemoteExecutable`` in ``DebuggerTool`` in ``.vcproj`` files generated
+by the :generator:`Visual Studio 9 2008` and :generator:`Visual Studio 8 2005`
+generators.  This is useful when you want to debug on remote WinCE device.
+For example:
+
+.. code-block:: cmake
+
+  set_property(TARGET ${TARGET} PROPERTY
+    DEPLOYMENT_REMOTE_DIRECTORY "\\FlashStorage")
+
+produces::
+
+  <DeploymentTool RemoteDirectory="\FlashStorage" ... />
+  <DebuggerTool RemoteExecutable="\FlashStorage\target_file" ... />
diff --git a/Help/prop_tgt/FRAMEWORK.rst b/Help/prop_tgt/FRAMEWORK.rst
index 6c212c3..8120c36 100644
--- a/Help/prop_tgt/FRAMEWORK.rst
+++ b/Help/prop_tgt/FRAMEWORK.rst
@@ -26,6 +26,10 @@ Example of creation ``dynamicFramework``:
     FRAMEWORK_VERSION C
     MACOSX_FRAMEWORK_IDENTIFIER com.cmake.dynamicFramework
     MACOSX_FRAMEWORK_INFO_PLIST Info.plist
+    # "current version" in semantic format in Mach-O binary file
+    VERSION 16.4.0
+    # "compatibility version" in semantic format in Mach-O binary file
+    SOVERSION 1.0.0
     PUBLIC_HEADER dynamicFramework.h
     XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
   )
diff --git a/Help/prop_tgt/JOB_POOL_LINK.rst b/Help/prop_tgt/JOB_POOL_LINK.rst
index 716f53f..6535333 100644
--- a/Help/prop_tgt/JOB_POOL_LINK.rst
+++ b/Help/prop_tgt/JOB_POOL_LINK.rst
@@ -5,7 +5,7 @@ Ninja only: Pool used for linking.
 
 The number of parallel link processes could be limited by defining
 pools with the global :prop_gbl:`JOB_POOLS`
-property and then specifing here the pool name.
+property and then specifying here the pool name.
 
 For instance:
 
diff --git a/Help/prop_tgt/LANG_CLANG_TIDY.rst b/Help/prop_tgt/LANG_CLANG_TIDY.rst
new file mode 100644
index 0000000..2887e23
--- /dev/null
+++ b/Help/prop_tgt/LANG_CLANG_TIDY.rst
@@ -0,0 +1,13 @@
+<LANG>_CLANG_TIDY
+-----------------
+
+This property is implemented only when ``<LANG>`` is ``C`` or ``CXX``.
+
+Specify a :ref:`;-list <CMake Language Lists>` containing a command
+line for the ``clang-tidy`` tool.  The :ref:`Makefile Generators`
+and the :generator:`Ninja` generator will run this tool along with the
+compiler and report a warning if the tool reports any problems.
+
+This property is initialized by the value of
+the :variable:`CMAKE_<LANG>_CLANG_TIDY` variable if it is set
+when a target is created.
diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt
index f90ea81..b5ada07 100644
--- a/Help/prop_tgt/PDB_NOTE.txt
+++ b/Help/prop_tgt/PDB_NOTE.txt
@@ -7,6 +7,3 @@
  ``/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/SOVERSION.rst b/Help/prop_tgt/SOVERSION.rst
index 672ff23..82b6b97 100644
--- a/Help/prop_tgt/SOVERSION.rst
+++ b/Help/prop_tgt/SOVERSION.rst
@@ -3,12 +3,25 @@ SOVERSION
 
 What version number is this target.
 
-For shared libraries VERSION and SOVERSION can be used to specify the
-build version and API version respectively.  When building or
+For shared libraries :prop_tgt:`VERSION` and ``SOVERSION`` can be used to
+specify the build version and API version respectively.  When building or
 installing appropriate symlinks are created if the platform supports
 symlinks and the linker supports so-names.  If only one of both is
 specified the missing is assumed to have the same version number.
-SOVERSION is ignored if NO_SONAME property is set.  For shared
-libraries and executables on Windows the VERSION attribute is parsed
-to extract a "major.minor" version number.  These numbers are used as
-the image version of the binary.
+``SOVERSION`` is ignored if :prop_tgt:`NO_SONAME` property is set.
+
+Windows Versions
+^^^^^^^^^^^^^^^^
+
+For shared libraries and executables on Windows the :prop_tgt:`VERSION`
+attribute is parsed to extract a ``<major>.<minor>`` version number.
+These numbers are used as the image version of the binary.
+
+Mach-O Versions
+^^^^^^^^^^^^^^^
+
+For shared libraries and executables on Mach-O systems (e.g. OS X, iOS),
+the ``SOVERSION`` property corresponds to *compatibility version* and
+:prop_tgt:`VERSION` to *current version*.  See the :prop_tgt:`FRAMEWORK` target
+property for an example.  Versions of Mach-O binaries may be checked with the
+``otool -L <binary>`` command.
diff --git a/Help/prop_tgt/VERSION.rst b/Help/prop_tgt/VERSION.rst
index 87f6c49..66e7bde 100644
--- a/Help/prop_tgt/VERSION.rst
+++ b/Help/prop_tgt/VERSION.rst
@@ -3,14 +3,27 @@ VERSION
 
 What version number is this target.
 
-For shared libraries VERSION and SOVERSION can be used to specify the
-build version and API version respectively.  When building or
+For shared libraries ``VERSION`` and :prop_tgt:`SOVERSION` can be used
+to specify the build version and API version respectively.  When building or
 installing appropriate symlinks are created if the platform supports
 symlinks and the linker supports so-names.  If only one of both is
 specified the missing is assumed to have the same version number.  For
-executables VERSION can be used to specify the build version.  When
+executables ``VERSION`` can be used to specify the build version.  When
 building or installing appropriate symlinks are created if the
-platform supports symlinks.  For shared libraries and executables on
-Windows the VERSION attribute is parsed to extract a "major.minor"
-version number.  These numbers are used as the image version of the
-binary.
+platform supports symlinks.
+
+Windows Versions
+^^^^^^^^^^^^^^^^
+
+For shared libraries and executables on Windows the ``VERSION``
+attribute is parsed to extract a ``<major>.<minor>`` version number.
+These numbers are used as the image version of the binary.
+
+Mach-O Versions
+^^^^^^^^^^^^^^^
+
+For shared libraries and executables on Mach-O systems (e.g. OS X, iOS),
+the :prop_tgt:`SOVERSION` property correspond to *compatibility version* and
+``VERSION`` to *current version*.  See the :prop_tgt:`FRAMEWORK` target
+property for an example.  Versions of Mach-O binaries may be checked with the
+``otool -L <binary>`` command.
diff --git a/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
new file mode 100644
index 0000000..ff987ff
--- /dev/null
+++ b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
@@ -0,0 +1,10 @@
+VS_CONFIGURATION_TYPE
+---------------------
+
+Visual Studio project configuration type.
+
+Sets the ``ConfigurationType`` attribute for a generated Visual Studio project.
+If this property is set, it overrides the default setting that is based on the
+target type (e.g. ``StaticLibrary``, ``Application``, ...).
+
+Supported on :ref:`Visual Studio Generators` for VS 2010 and higher.
diff --git a/Help/release/3.6.rst b/Help/release/3.6.rst
new file mode 100644
index 0000000..771c9dd
--- /dev/null
+++ b/Help/release/3.6.rst
@@ -0,0 +1,310 @@
+CMake 3.6 Release Notes
+***********************
+
+.. only:: html
+
+  .. contents::
+
+Changes made since CMake 3.5 include the following.
+
+New Features
+============
+
+Generators
+----------
+
+* The :generator:`Ninja` generator learned to produce phony targets
+  of the form ``sub/dir/all`` to drive the build of a subdirectory.
+  This is equivalent to ``cd sub/dir; make all`` with
+  :ref:`Makefile Generators`.
+
+* The :generator:`Ninja` generator now includes system header files in build
+  dependencies to ensure correct re-builds when system packages are updated.
+
+* The :generator:`Visual Studio 14 2015` generator learned to support the
+  Clang/C2 toolsets, e.g. with the ``-T v140_clang_3_7`` option.
+  This feature is experimental.
+
+Commands
+--------
+
+* The :command:`add_custom_command` and :command:`add_custom_target` commands
+  learned how to use the :prop_tgt:`CROSSCOMPILING_EMULATOR` executable
+  target property.
+
+* The :command:`install` command learned a new ``EXCLUDE_FROM_ALL`` option
+  to leave installation rules out of the default installation.
+
+* The :command:`list` command gained a ``FILTER`` sub-command to filter
+  list elements by regular expression.
+
+* The :command:`string(TIMESTAMP)` and :command:`file(TIMESTAMP)`
+  commands gained support for the ``%s`` placeholder.  This is
+  the number of seconds since the UNIX Epoch.
+
+Variables
+---------
+
+* A :variable:`CMAKE_DEPENDS_IN_PROJECT_ONLY` variable was introduced
+  to tell :ref:`Makefile Generators` to limit dependency scanning only
+  to files in the project source and build trees.
+
+* A new :variable:`CMAKE_HOST_SOLARIS` variable was introduced to
+  indicate when CMake is running on an Oracle Solaris host.
+
+* A :variable:`CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES` variable was
+  added for use by toolchain files to specify system include directories
+  to be appended to all compiler command lines.
+
+* The :variable:`CMAKE_<LANG>_STANDARD_LIBRARIES` variable is now documented.
+  It is intended for use by toolchain files to specify system libraries to be
+  added to all linker command lines.
+
+* A :variable:`CMAKE_NINJA_OUTPUT_PATH_PREFIX` variable was introduced
+  to tell the :generator:`Ninja` generator to configure the generated
+  ``build.ninja`` file for use as a ``subninja``.
+
+* A :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable was
+  added for use by toolchain files to specify platform-specific
+  variables that must be propagated by the :command:`try_compile`
+  command into test projects.
+
+* A :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable was added
+  to optionally tell the :command:`try_compile` command to build
+  a static library instead of an executable.  This is useful for
+  cross-compiling toolchains that cannot link binaries without
+  custom flags or scripts.
+
+Properties
+----------
+
+* A :prop_tgt:`DEPLOYMENT_REMOTE_DIRECTORY` target property was introduced
+  to tell the :generator:`Visual Studio 9 2008` and
+  :generator:`Visual Studio 8 2005` generators to generate the "remote
+  directory" for WinCE project deployment and debugger settings.
+
+* A :prop_tgt:`<LANG>_CLANG_TIDY` target property and supporting
+  :variable:`CMAKE_<LANG>_CLANG_TIDY` variable were introduced to tell the
+  :ref:`Makefile Generators` and the :generator:`Ninja` generator to run
+  ``clang-tidy`` along with the compiler for ``C`` and ``CXX`` languages.
+
+* A :prop_test:`TIMEOUT_AFTER_MATCH` test property was introduced to
+  optionally tell CTest to enforce a secondary timeout after matching
+  certain output from a test.
+
+* A :prop_tgt:`VS_CONFIGURATION_TYPE` target property was introduced
+  to specify a custom project file type for :ref:`Visual Studio Generators`
+  supporting VS 2010 and above.
+
+* A :prop_dir:`VS_STARTUP_PROJECT` directory property was introduced
+  to specify for :ref:`Visual Studio Generators` the default startup
+  project for generated solutions (``.sln`` files).
+
+Modules
+-------
+
+* The :module:`CMakePushCheckState` module now pushes/pops/resets the variable
+  ``CMAKE_EXTRA_INCLUDE_FILE`` used in :module:`CheckTypeSize`.
+
+* The :module:`ExternalProject` module leared the ``GIT_SHALLOW 1``
+  option to perform a shallow clone of a Git repository.
+
+* The :module:`ExternalProject` module learned to initialize Git submodules
+  recursively and also to initialize new submodules on updates.  Use the
+  ``GIT_SUBMODULES`` option to restrict which submodules are initalized and
+  updated.
+
+* The :module:`ExternalProject` module leared the ``DOWNLOAD_NO_EXTRACT 1``
+  argument to skip extracting the file that is downloaded (e.g., for
+  self-extracting shell installers or ``.msi`` files).
+
+* The :module:`ExternalProject` module now uses ``TLS_VERIFY`` when fetching
+  from git repositories.
+
+* The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to
+  support `OpenBLAS <http://www.openblas.net>`__.
+
+* The :module:`FindCUDA` module learned to find the ``cublas_device`` library.
+
+* The :module:`FindGTest` module ``gtest_add_tests`` function now causes
+  CMake to automatically re-run when test sources change so that they
+  can be re-scanned.
+
+* The :module:`FindLTTngUST` module was introduced to find the LTTng-UST
+  library.
+
+* The :module:`FindPkgConfig` module learned to optionally create imported
+  targets for the libraries it has found.
+
+* The :module:`FindProtobuf` module learned to provide a ``Protobuf_VERSION``
+  variable and check the version number requested in a :command:`find_package`
+  call.
+
+* The :module:`InstallRequiredSystemLibraries` module learned a new
+  ``CMAKE_INSTALL_UCRT_LIBRARIES`` option to enable app-local deployment
+  of the Windows Universal CRT libraries with Visual Studio 2015.
+
+Platforms
+---------
+
+* The Clang compiler is now supported on CYGWIN.
+
+* Support was added for the Bruce C Compiler with compiler id ``Bruce``.
+
+CTest
+-----
+
+* The :command:`ctest_update` command now looks at the
+  :variable:`CTEST_GIT_INIT_SUBMODULES` variable to determine whether
+  submodules should be updated or not before updating.
+
+* The :command:`ctest_update` command will now synchronize submodules on an
+  update. Updates which add submodules or change a submodule's URL will now be
+  pulled properly.
+
+CPack
+-----
+
+* The :module:`CPackDeb` module learned how to handle ``$ORIGIN``
+  in ``CMAKE_INSTALL_RPATH`` when :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS`
+  is used for dependency auto detection.
+
+* The :module:`CPackDeb` module learned how to generate ``DEBIAN/shlibs``
+  contorl file when package contains shared libraries.
+
+* The :module:`CPackDeb` module learned how to generate ``DEBIAN/postinst`` and
+  ``DEBIAN/postrm`` files if the package installs libraries in
+  ldconfig-controlled locations (e.g. ``/lib/``, ``/usr/lib/``).
+
+* The :module:`CPackDeb` module learned how to generate dependencies between
+  Debian packages if multi-component setup is used and
+  :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables are set.
+  For backward compatibility this feature is disabled by default.
+  See :variable:`CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS`.
+
+* The :module:`CPackDeb` module learned how to set custom package file names
+  including how to generate properly-named Debian packages::
+
+    <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
+
+  For backward compatibility this feature is disabled by default. See
+  :variable:`CPACK_DEBIAN_FILE_NAME` and
+  :variable:`CPACK_DEBIAN_<COMPONENT>_FILE_NAME`.
+
+* The :module:`CPackDeb` module learned how to set the package release number
+  (``DebianRevisionNumber`` in package file name when used in combination with
+  ``DEB-DEFAULT`` value set by :variable:`CPACK_DEBIAN_FILE_NAME`).  See
+  :variable:`CPACK_DEBIAN_PACKAGE_RELEASE`.
+
+* The :module:`CPackDeb` module learned how to set the package architecture
+  per-component.  See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`.
+
+* The :module:`CPackDMG` module learned a new option to tell the CPack
+  ``DragNDrop`` generaor to skip the ``/Applications`` symlink.
+  See the :variable:`CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK` variable.
+
+* The :module:`CPackIFW` module gained a new
+  :command:`cpack_ifw_update_repository` command to update a QtIFW-specific
+  repository from a remote repository.
+
+* The :module:`CPackRPM` module learned how to set RPM ``dist`` tag as part of
+  RPM ``Release:`` tag when enabled (mandatory on some Linux distributions for
+  e.g. on Fedora).
+  See :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
+
+* The :module:`CPackRPM` module learned how to set default values for owning
+  user/group and file/directory permissions of package content.
+  See :variable:`CPACK_RPM_DEFAULT_USER`, :variable:`CPACK_RPM_DEFAULT_GROUP`,
+  :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`,
+  :variable:`CPACK_RPM_DEFAULT_DIR_PERMISSIONS` and their per component
+  counterparts.
+
+* The :module:`CPackRPM` module learned how to set user defined package file
+  names, how to specify that rpmbuild should decide on file name format as
+  well as handling of multiple rpm packages generated by a single user defined
+  spec file.
+  See :variable:`CPACK_RPM_PACKAGE_NAME` and
+  :variable:`CPACK_RPM_<component>_PACKAGE_NAME`.
+
+* The :module:`CPackRPM` module learned how to correctly handle symlinks
+  that are pointing outside generated packages.
+
+Other
+-----
+
+* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
+  is now aware of features supported by Intel C++ compilers versions 12.1
+  through 16.0 on UNIX platforms.
+
+Deprecated and Removed Features
+===============================
+
+* The :module:`CMakeForceCompiler` module and its macros are now deprecated.
+  See module documentation for an explanation.
+
+* The :command:`find_library`, :command:`find_path`, and :command:`find_file`
+  commands no longer search in installation prefixes derived from the ``PATH``
+  environment variable on non-Windows platforms.  This behavior was added in
+  CMake 3.3 to support Windows hosts but has proven problematic on UNIX hosts.
+  Users that keep some ``<prefix>/bin`` directories in the ``PATH`` just for
+  their tools do not necessarily want any supporting ``<prefix>/lib``
+  directories searched.  One may set the ``CMAKE_PREFIX_PATH`` environment
+  variable with a :ref:`;-list <CMake Language Lists>` of prefixes that are
+  to be searched.
+
+* The :generator:`Visual Studio 7 .NET 2003` generator is now
+  deprecated and will be removed in a future version of CMake.
+
+* The :generator:`Visual Studio 7` generator (for VS .NET 2002) has been
+  removed.  It had been deprecated since CMake 3.3.
+
+* The :generator:`Visual Studio 6` generator has been removed.
+  It had been deprecated since CMake 3.3.
+
+Other Changes
+=============
+
+* The precompiled OS X binary provided on ``cmake.org`` now requires
+  OS X 10.7 or newer.
+
+* On Linux and FreeBSD platforms, when building CMake itself from source and
+  not using a system-provided libcurl, OpenSSL is now used by default if it is
+  found on the system.  This enables SSL/TLS support for commands supporting
+  network communication via ``https``, such as :command:`file(DOWNLOAD)`,
+  :command:`file(UPLOAD)`, and :command:`ctest_submit`.
+
+* The :manual:`cmake(1)` ``--build`` command-line tool now rejects multiple
+  ``--target`` options with an error instead of silently ignoring all but the
+  last one.
+
+* :prop_tgt:`AUTOMOC` now diagnoses name collisions when multiple source
+  files in different directories use ``#include <moc_foo.cpp>`` with the
+  same name (because the generated ``moc_foo.cpp`` files would collide).
+
+* The :module:`FindBISON` module ``BISON_TARGET`` macro now supports
+  special characters by passing the ``VERBATIM`` option to internal
+  :command:`add_custom_command` calls.  This may break clients that
+  added escaping manually to work around the bug.
+
+* The :module:`FindFLEX` module ``FLEX_TARGET`` macro now supports
+  special characters by passing the ``VERBATIM`` option to internal
+  :command:`add_custom_command` calls.  This may break clients that
+  added escaping manually to work around the bug.
+
+* The :module:`FindProtobuf` module input and output variables were all renamed
+  from ``PROTOBUF_`` to ``Protobuf_`` for consistency with other find modules.
+  Input variables of the old case will be honored if provided, and output
+  variables of the old case are always provided.
+
+* The :module:`CPackRPM` module now supports upper cased component
+  names in per component CPackRPM specific variables.
+  E.g. component named ``foo`` now expects component specific
+  variable to be ``CPACK_RPM_FOO_PACKAGE_NAME`` while before
+  it expected ``CPACK_RPM_foo_PACKAGE_NAME``.
+  Upper cased component name part in variables is compatible
+  with convention used for other CPack variables.
+  For back compatibility old format of variables is still valid
+  and preferred if both versions of variable are set, but the
+  preferred future use is upper cased component names in variables.
+  New variables that will be added to CPackRPM in later versions
+  will only support upper cased component variable format.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 6b7da3c..92c3b63 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -11,6 +11,7 @@ Releases
 .. toctree::
    :maxdepth: 1
 
+   3.6 <3.6>
    3.5 <3.5>
    3.4 <3.4>
    3.3 <3.3>
diff --git a/Help/variable/CMAKE_CFG_INTDIR.rst b/Help/variable/CMAKE_CFG_INTDIR.rst
index dcc1aed..ba25a35 100644
--- a/Help/variable/CMAKE_CFG_INTDIR.rst
+++ b/Help/variable/CMAKE_CFG_INTDIR.rst
@@ -12,7 +12,6 @@ Example values:
 
 ::
 
-  $(IntDir)            = Visual Studio 6
   $(ConfigurationName) = Visual Studio 7, 8, 9
   $(Configuration)     = Visual Studio 10
   $(CONFIGURATION)     = Xcode
diff --git a/Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst b/Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst
new file mode 100644
index 0000000..7179071
--- /dev/null
+++ b/Help/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY.rst
@@ -0,0 +1,10 @@
+CMAKE_DEPENDS_IN_PROJECT_ONLY
+-----------------------------
+
+When set to ``TRUE`` in a directory, the build system produced by the
+:ref:`Makefile Generators` is set up to only consider dependencies on source
+files that appear either in the source or in the binary directories.  Changes
+to source files outside of these directories will not cause rebuilds.
+
+This should be used carefully in cases where some source files are picked up
+through external headers during the build.
diff --git a/Help/variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES.rst b/Help/variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES.rst
new file mode 100644
index 0000000..331aae8
--- /dev/null
+++ b/Help/variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES.rst
@@ -0,0 +1,10 @@
+CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
+---------------------------------------
+
+This cache variable is used by the Eclipse project generator.  See
+:manual:`cmake-generators(7)`.
+
+The Eclipse project generator generates so-called linked resources
+e.g. to the subproject root dirs in the source tree or to the source files
+of targets.
+This can be disabled by setting this variable to FALSE.
diff --git a/Help/variable/CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT.rst b/Help/variable/CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT.rst
new file mode 100644
index 0000000..7b4367d
--- /dev/null
+++ b/Help/variable/CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT.rst
@@ -0,0 +1,11 @@
+CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
+-------------------------------------
+
+This cache variable is used by the Eclipse project generator.  See
+:manual:`cmake-generators(7)`.
+
+If this variable is set to TRUE, the Eclipse project generator will generate
+an Eclipse project in :variable:`CMAKE_SOURCE_DIR` . This project can then
+be used in Eclipse e.g. for the version control functionality.
+:variable:`CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT` defaults to FALSE; so
+nothing is written into the source directory.
diff --git a/Help/variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS.rst b/Help/variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS.rst
new file mode 100644
index 0000000..6e8a408
--- /dev/null
+++ b/Help/variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS.rst
@@ -0,0 +1,9 @@
+CMAKE_ECLIPSE_MAKE_ARGUMENTS
+----------------------------
+
+This cache variable is used by the Eclipse project generator.  See
+:manual:`cmake-generators(7)`.
+
+This variable holds arguments which are used when Eclipse invokes the make
+tool. By default it is initialized to hold flags to enable parallel builds
+(using -j typically).
diff --git a/Help/variable/CMAKE_ECLIPSE_VERSION.rst b/Help/variable/CMAKE_ECLIPSE_VERSION.rst
new file mode 100644
index 0000000..8cc7882
--- /dev/null
+++ b/Help/variable/CMAKE_ECLIPSE_VERSION.rst
@@ -0,0 +1,10 @@
+CMAKE_ECLIPSE_VERSION
+---------------------
+
+This cache variable is used by the Eclipse project generator.  See
+:manual:`cmake-generators(7)`.
+
+When using the Eclipse project generator, CMake tries to find the Eclipse
+executable and detect the version of it. Depending on the version it finds,
+some features are enabled or disabled. If CMake doesn't find
+Eclipse, it assumes the oldest supported version, Eclipse Callisto (3.2).
diff --git a/Help/variable/CMAKE_GENERATOR.rst b/Help/variable/CMAKE_GENERATOR.rst
index 3f6ebc1..cce04c1 100644
--- a/Help/variable/CMAKE_GENERATOR.rst
+++ b/Help/variable/CMAKE_GENERATOR.rst
@@ -4,4 +4,4 @@ CMAKE_GENERATOR
 The generator used to build the project.  See :manual:`cmake-generators(7)`.
 
 The name of the generator that is being used to generate the build
-files.  (e.g.  ``Unix Makefiles``, ``Visual Studio 6``, etc.)
+files.  (e.g.  ``Unix Makefiles``, ``Ninja``, etc.)
diff --git a/Help/variable/CMAKE_HOST_SOLARIS.rst b/Help/variable/CMAKE_HOST_SOLARIS.rst
new file mode 100644
index 0000000..82b5d69
--- /dev/null
+++ b/Help/variable/CMAKE_HOST_SOLARIS.rst
@@ -0,0 +1,6 @@
+CMAKE_HOST_SOLARIS
+------------------
+
+``True`` for Oracle Solaris operating systems.
+
+Set to ``true`` when the host system is Oracle Solaris.
diff --git a/Help/variable/CMAKE_LANG_CLANG_TIDY.rst b/Help/variable/CMAKE_LANG_CLANG_TIDY.rst
new file mode 100644
index 0000000..492c12c
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_CLANG_TIDY.rst
@@ -0,0 +1,6 @@
+CMAKE_<LANG>_CLANG_TIDY
+-----------------------
+
+Default value for :prop_tgt:`<LANG>_CLANG_TIDY` target property.
+This variable is used to initialize the property on each target as it is
+created.  This is done only when ``<LANG>`` is ``C`` or ``CXX``.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst
index 8bb7cc0..5be935b 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst
@@ -3,7 +3,7 @@ CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN
 
 The external toolchain for cross-compiling, if supported.
 
-Some compiler toolchains do not ship their own auxilliary utilities such as
+Some compiler toolchains do not ship their own auxiliary utilities such as
 archivers and linkers.  The compiler driver may support a command-line argument
 to specify the location of such tools.
 ``CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN`` may be set to a path to a path to
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index 81976a9..ebd616e 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -12,6 +12,7 @@ include:
   ADSP = Analog VisualDSP++ (analog.com)
   AppleClang = Apple Clang (apple.com)
   ARMCC = ARM Compiler (arm.com)
+  Bruce = Bruce C Compiler
   CCur = Concurrent Fortran (ccur.com)
   Clang = LLVM Clang (clang.llvm.org)
   Cray = Cray Compiler (cray.com)
diff --git a/Help/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES.rst
new file mode 100644
index 0000000..c8e3d57
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES.rst
@@ -0,0 +1,14 @@
+CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES
+-----------------------------------------
+
+Include directories to be used for every source file compiled with
+the ``<LANG>`` compiler.  This is meant for specification of system
+include directories needed by the language for the current platform.
+The directories always appear at the end of the include path passed
+to the compiler.
+
+This variable should not be set by project code.  It is meant to be set by
+CMake's platform information modules for the current toolchain, or by a
+toolchain file when used with :variable:`CMAKE_TOOLCHAIN_FILE`.
+
+See also :variable:`CMAKE_<LANG>_STANDARD_LIBRARIES`.
diff --git a/Help/variable/CMAKE_LANG_STANDARD_LIBRARIES.rst b/Help/variable/CMAKE_LANG_STANDARD_LIBRARIES.rst
new file mode 100644
index 0000000..ba6df93
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_STANDARD_LIBRARIES.rst
@@ -0,0 +1,12 @@
+CMAKE_<LANG>_STANDARD_LIBRARIES
+-------------------------------
+
+Libraries linked into every executable and shared library linked
+for language ``<LANG>``.  This is meant for specification of system
+libraries needed by the language for the current platform.
+
+This variable should not be set by project code.  It is meant to be set by
+CMake's platform information modules for the current toolchain, or by a
+toolchain file when used with :variable:`CMAKE_TOOLCHAIN_FILE`.
+
+See also :variable:`CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES`.
diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst
index edf2732..a3b997a 100644
--- a/Help/variable/CMAKE_MAKE_PROGRAM.rst
+++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst
@@ -34,12 +34,11 @@ to configure the project:
   the CMake cache then CMake will use the specified value.
 
 * The :ref:`Visual Studio Generators` set this to the full path to
-  ``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9),
-  ``VCExpress.exe`` (VS Express 8,9), or ``msdev.exe`` (VS 6).
+  ``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9), or
+  ``VCExpress.exe`` (VS Express 8,9).
   (See also variables
-  :variable:`CMAKE_VS_MSBUILD_COMMAND`,
-  :variable:`CMAKE_VS_DEVENV_COMMAND`, and
-  :variable:`CMAKE_VS_MSDEV_COMMAND`.)
+  :variable:`CMAKE_VS_MSBUILD_COMMAND` and
+  :variable:`CMAKE_VS_DEVENV_COMMAND`.
 
   These generators prefer to lookup the build tool at build time
   rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
diff --git a/Help/variable/CMAKE_MFC_FLAG.rst b/Help/variable/CMAKE_MFC_FLAG.rst
index f60e7a5..1543677 100644
--- a/Help/variable/CMAKE_MFC_FLAG.rst
+++ b/Help/variable/CMAKE_MFC_FLAG.rst
@@ -5,7 +5,7 @@ Tell cmake to use MFC for an executable or dll.
 
 This can be set in a ``CMakeLists.txt`` file and will enable MFC in the
 application.  It should be set to ``1`` for the static MFC library, and ``2``
-for the shared MFC library.  This is used in Visual Studio 6 and 7
+for the shared MFC library.  This is used in Visual Studio 7
 project files.  The CMakeSetup dialog used MFC and the ``CMakeLists.txt``
 looks like this:
 
diff --git a/Help/variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX.rst b/Help/variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX.rst
new file mode 100644
index 0000000..64091aa
--- /dev/null
+++ b/Help/variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX.rst
@@ -0,0 +1,27 @@
+CMAKE_NINJA_OUTPUT_PATH_PREFIX
+------------------------------
+
+Set output files path prefix for the :generator:`Ninja` generator.
+
+Every output files listed in the generated ``build.ninja`` will be
+prefixed by the contents of this variable (a trailing slash is
+appended if missing).  This is useful when the generated ninja file is
+meant to be embedded as a ``subninja`` file into a *super* ninja
+project.  For example, a ninja build file generated with a command
+like::
+
+  cd top-build-dir/sub &&
+  cmake -G Ninja -DCMAKE_NINJA_OUTPUT_PATH_PREFIX=sub/ path/to/source
+
+can be embedded in ``top-build-dir/build.ninja`` with a directive like
+this::
+
+  subninja sub/build.ninja
+
+The ``auto-regeneration`` rule in ``top-build-dir/build.ninja`` must have an
+order-only dependency on ``sub/build.ninja``.
+
+.. note::
+  When ``CMAKE_NINJA_OUTPUT_PATH_PREFIX`` is set, the project generated
+  by CMake cannot be used as a standalone project.  No default targets
+  are specified.
diff --git a/Help/variable/CMAKE_STANDARD_LIBRARIES.rst b/Help/variable/CMAKE_STANDARD_LIBRARIES.rst
deleted file mode 100644
index 9c728cd..0000000
--- a/Help/variable/CMAKE_STANDARD_LIBRARIES.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-CMAKE_STANDARD_LIBRARIES
-------------------------
-
-Libraries linked into every executable and shared library.
-
-This is the list of libraries that are linked into all executables and
-libraries.
diff --git a/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst b/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst
new file mode 100644
index 0000000..0f96787
--- /dev/null
+++ b/Help/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES.rst
@@ -0,0 +1,26 @@
+CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
+------------------------------------
+
+List of variables that the :command:`try_compile` command source file signature
+must propagate into the test project in order to target the same platform as
+the host project.
+
+This variable should not be set by project code.  It is meant to be set by
+CMake's platform information modules for the current toolchain, or by a
+toolchain file when used with :variable:`CMAKE_TOOLCHAIN_FILE`.
+
+Variables meaningful to CMake, such as :variable:`CMAKE_<LANG>_FLAGS`, are
+propagated automatically.  The ``CMAKE_TRY_COMPILE_PLATFORM_VARIABLES``
+variable may be set to pass custom variables meaningful to a toolchain file.
+For example, a toolchain file may contain:
+
+.. code-block:: cmake
+
+  set(CMAKE_SYSTEM_NAME ...)
+  set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES MY_CUSTOM_VARIABLE)
+  # ... use MY_CUSTOM_VARIABLE ...
+
+If a user passes ``-DMY_CUSTOM_VARIABLE=SomeValue`` to CMake then this
+setting will be made visible to the toolchain file both for the main
+project and for test projects generated by the :command:`try_compile`
+command source file signature.
diff --git a/Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst b/Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst
new file mode 100644
index 0000000..5fa8dfc
--- /dev/null
+++ b/Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst
@@ -0,0 +1,15 @@
+CMAKE_TRY_COMPILE_TARGET_TYPE
+-----------------------------
+
+Type of target generated for :command:`try_compile` calls using the
+source file signature.  Valid values are:
+
+``EXECUTABLE``
+  Use :command:`add_executable` to name the source file in the
+  generated project.  This is the default if no value is given.
+
+``STATIC_LIBRARY``
+  Use :command:`add_library` with the ``STATIC`` option to name the
+  source file in the generated project.  This avoids running the
+  linker and is intended for use with cross-compiling toolchains
+  that cannot link without custom flags or linker scripts.
diff --git a/Help/variable/CMAKE_VS_MSDEV_COMMAND.rst b/Help/variable/CMAKE_VS_MSDEV_COMMAND.rst
deleted file mode 100644
index 718baaf..0000000
--- a/Help/variable/CMAKE_VS_MSDEV_COMMAND.rst
+++ /dev/null
@@ -1,10 +0,0 @@
-CMAKE_VS_MSDEV_COMMAND
-----------------------
-
-The :generator:`Visual Studio 6` generator sets this variable to the
-``msdev.exe`` command installed with Visual Studio 6.
-
-This variable is not defined by other generators even if ``msdev.exe``
-is installed on the computer.
-
-See also the :variable:`CMAKE_MAKE_PROGRAM` variable.
diff --git a/Help/variable/CTEST_COVERAGE_COMMAND.rst b/Help/variable/CTEST_COVERAGE_COMMAND.rst
index 0491d42..a78792e 100644
--- a/Help/variable/CTEST_COVERAGE_COMMAND.rst
+++ b/Help/variable/CTEST_COVERAGE_COMMAND.rst
@@ -54,7 +54,7 @@ program requires some named arguments.
   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
+``/src/main/java`` directories of each module within the source tree. These
 directories are needed and should not be forgotten.
 
 .. _`Cobertura`: http://cobertura.github.io/cobertura/
diff --git a/Help/variable/CTEST_GIT_INIT_SUBMODULES.rst b/Help/variable/CTEST_GIT_INIT_SUBMODULES.rst
new file mode 100644
index 0000000..fd27003
--- /dev/null
+++ b/Help/variable/CTEST_GIT_INIT_SUBMODULES.rst
@@ -0,0 +1,5 @@
+CTEST_GIT_INIT_SUBMODULES
+-------------------------
+
+Specify the CTest ``GITInitSubmodules`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 45dda40..cfb6450 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -52,6 +52,9 @@
 # Then clear all the keys and call verify_app on the final bundle to
 # ensure that it is truly standalone.
 #
+# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
+# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
+#
 # ::
 #
 #   COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>)
@@ -67,6 +70,9 @@
 # analysis tools on it.  Calls "message(FATAL_ERROR" if the application
 # is not verified.
 #
+# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
+# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
+#
 # ::
 #
 #   GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>)
@@ -140,6 +146,9 @@
 # all of them and copy prerequisite libs into the bundle and then do
 # appropriate install_name_tool fixups.
 #
+# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
+# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
+#
 # ::
 #
 #   COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
@@ -196,6 +205,9 @@
 # bundle are contained within the bundle or are "system" libraries,
 # presumed to exist everywhere.
 #
+# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
+# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
+#
 # ::
 #
 #   VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>)
@@ -479,7 +491,7 @@ function(set_bundle_key_values keys_var context item exepath dirs copyflag)
 
     get_item_rpaths("${resolved_item}" item_rpaths)
 
-    if(item MATCHES "[^/]+\\.framework/")
+    if((NOT item MATCHES "\\.dylib$") AND (item MATCHES "[^/]+\\.framework/"))
       # For frameworks, construct the name under the embedded path from the
       # opening "${item_name}.framework/" to the closing "/${item_name}":
       #
@@ -525,6 +537,11 @@ endfunction()
 function(get_bundle_keys app libs dirs keys_var)
   set(${keys_var} PARENT_SCOPE)
 
+  set(options)
+  set(oneValueArgs)
+  set(multiValueArgs IGNORE_ITEM)
+  cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+
   get_bundle_and_executable("${app}" bundle executable valid)
   if(valid)
     # Always use the exepath of the main bundle executable for @executable_path
@@ -554,10 +571,24 @@ function(get_bundle_keys app libs dirs keys_var)
       set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
 
       set(prereqs "")
-      get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}")
-      foreach(pr ${prereqs})
-        set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}")
-      endforeach()
+      set(ignoreFile FALSE)
+      get_filename_component(prereq_filename ${lib} NAME)
+      if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
+        foreach(item ${CFG_IGNORE_ITEM})
+            if("${item}" STREQUAL "${prereq_filename}")
+              set(ignoreFile TRUE)
+            endif()
+        endforeach()
+      endif()
+
+      if(NOT ignoreFile)
+        get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}")
+        foreach(pr ${prereqs})
+          set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}")
+        endforeach()
+      else()
+        message(STATUS "Ignoring file: ${prereq_filename}")
+      endif()
     endforeach()
 
     # For each executable found in the bundle, accumulate keys as we go.
@@ -583,10 +614,24 @@ function(get_bundle_keys app libs dirs keys_var)
       # Add each prerequisite to the keys:
       #
       set(prereqs "")
-      get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}")
-      foreach(pr ${prereqs})
-        set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
-      endforeach()
+      set(ignoreFile FALSE)
+      get_filename_component(prereq_filename ${exe} NAME)
+      if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
+        foreach(item ${CFG_IGNORE_ITEM})
+            if("${item}" STREQUAL "${prereq_filename}")
+              set(ignoreFile TRUE)
+            endif()
+        endforeach()
+      endif()
+
+      if(NOT ignoreFile)
+        get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}")
+        foreach(pr ${prereqs})
+          set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
+        endforeach()
+      else()
+        message(STATUS "Ignoring file: ${prereq_filename}")
+      endif()
     endforeach()
 
     # Propagate values to caller's scope:
@@ -798,12 +843,19 @@ function(fixup_bundle app libs dirs)
   message(STATUS "  libs='${libs}'")
   message(STATUS "  dirs='${dirs}'")
 
+  set(options)
+  set(oneValueArgs)
+  set(multiValueArgs IGNORE_ITEM)
+  cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+
+  message(STATUS "  ignoreItems='${CFG_IGNORE_ITEM}'")
+
   get_bundle_and_executable("${app}" bundle executable valid)
   if(valid)
     get_filename_component(exepath "${executable}" PATH)
 
     message(STATUS "fixup_bundle: preparing...")
-    get_bundle_keys("${app}" "${libs}" "${dirs}" keys)
+    get_bundle_keys("${app}" "${libs}" "${dirs}" keys IGNORE_ITEM "${CFG_IGNORE_ITEM}")
 
     message(STATUS "fixup_bundle: copying...")
     list(LENGTH keys n)
@@ -857,7 +909,7 @@ function(fixup_bundle app libs dirs)
     clear_bundle_keys(keys)
 
     message(STATUS "fixup_bundle: verifying...")
-    verify_app("${app}")
+    verify_app("${app}" IGNORE_ITEM "${CFG_IGNORE_ITEM}")
   else()
     message(SEND_ERROR "error: fixup_bundle: not a valid bundle")
   endif()
@@ -877,6 +929,11 @@ function(verify_bundle_prerequisites bundle result_var info_var)
   set(info "")
   set(count 0)
 
+  set(options)
+  set(oneValueArgs)
+  set(multiValueArgs IGNORE_ITEM)
+  cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+
   get_bundle_main_executable("${bundle}" main_bundle_exe)
 
   get_bundle_all_executables("${bundle}" file_list)
@@ -887,37 +944,53 @@ function(verify_bundle_prerequisites bundle result_var info_var)
       message(STATUS "executable file ${count}: ${f}")
 
       set(prereqs "")
-      get_prerequisites("${f}" prereqs 1 1 "${exepath}" "")
+      set(ignoreFile FALSE)
+      get_filename_component(prereq_filename ${f} NAME)
+
+      if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
+        foreach(item ${CFG_IGNORE_ITEM})
+            if("${item}" STREQUAL "${prereq_filename}")
+              set(ignoreFile TRUE)
+            endif()
+        endforeach()
+      endif()
 
-      # On the Mac,
-      # "embedded" and "system" prerequisites are fine... anything else means
-      # the bundle's prerequisites are not verified (i.e., the bundle is not
-      # really "standalone")
-      #
-      # On Windows (and others? Linux/Unix/...?)
-      # "local" and "system" prereqs are fine...
-      #
-      set(external_prereqs "")
+      if(NOT ignoreFile)
+        get_prerequisites("${f}" prereqs 1 1 "${exepath}" "")
 
-      foreach(p ${prereqs})
-        set(p_type "")
-        gp_file_type("${f}" "${p}" p_type)
+        # On the Mac,
+        # "embedded" and "system" prerequisites are fine... anything else means
+        # the bundle's prerequisites are not verified (i.e., the bundle is not
+        # really "standalone")
+        #
+        # On Windows (and others? Linux/Unix/...?)
+        # "local" and "system" prereqs are fine...
+        #
 
-        if(APPLE)
-          if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system")
-            set(external_prereqs ${external_prereqs} "${p}")
-          endif()
-        else()
-          if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system")
-            set(external_prereqs ${external_prereqs} "${p}")
+        set(external_prereqs "")
+
+        foreach(p ${prereqs})
+          set(p_type "")
+          gp_file_type("${f}" "${p}" p_type)
+
+          if(APPLE)
+            if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system")
+              set(external_prereqs ${external_prereqs} "${p}")
+            endif()
+          else()
+            if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system")
+              set(external_prereqs ${external_prereqs} "${p}")
+            endif()
           endif()
-        endif()
-      endforeach()
+        endforeach()
 
-      if(external_prereqs)
-        # Found non-system/somehow-unacceptable prerequisites:
-        set(result 0)
-        set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n")
+        if(external_prereqs)
+          # Found non-system/somehow-unacceptable prerequisites:
+          set(result 0)
+          set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n")
+        endif()
+      else()
+        message(STATUS "Ignoring file: ${prereq_filename}")
       endif()
   endforeach()
 
@@ -947,6 +1020,11 @@ function(verify_app app)
   set(verified 0)
   set(info "")
 
+  set(options)
+  set(oneValueArgs)
+  set(multiValueArgs IGNORE_ITEM)
+  cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+
   get_bundle_and_executable("${app}" bundle executable valid)
 
   message(STATUS "===========================================================================")
@@ -957,7 +1035,7 @@ function(verify_app app)
 
   # Verify that the bundle does not have any "external" prerequisites:
   #
-  verify_bundle_prerequisites("${bundle}" verified info)
+  verify_bundle_prerequisites("${bundle}" verified info IGNORE_ITEM "${CFG_IGNORE_ITEM}")
   message(STATUS "verified='${verified}'")
   message(STATUS "info='${info}'")
   message(STATUS "")
diff --git a/Modules/CMakeBackwardCompatibilityC.cmake b/Modules/CMakeBackwardCompatibilityC.cmake
index 4783d68..685cd52 100644
--- a/Modules/CMakeBackwardCompatibilityC.cmake
+++ b/Modules/CMakeBackwardCompatibilityC.cmake
@@ -17,10 +17,6 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio 7")
   include(CMakeVS7BackwardCompatibility)
   set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
 endif()
-if(CMAKE_GENERATOR MATCHES "Visual Studio 6")
-  include(CMakeVS6BackwardCompatibility)
-  set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
-endif()
 
 if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
   # Old CMake versions did not support OS X universal binaries anyway,
diff --git a/Modules/CMakeCCompilerABI.c b/Modules/CMakeCCompilerABI.c
index e6a07f4..55f9a9b 100644
--- a/Modules/CMakeCCompilerABI.c
+++ b/Modules/CMakeCCompilerABI.c
@@ -1,21 +1,18 @@
 #ifdef __cplusplus
-# error "A C++ compiler has been selected for C."
+#error "A C++ compiler has been selected for C."
 #endif
 
 #ifdef __CLASSIC_C__
-# define const
+#define const
 #endif
 
-/*--------------------------------------------------------------------------*/
-
 #include "CMakeCompilerABI.h"
 
-/*--------------------------------------------------------------------------*/
-
 #ifdef __CLASSIC_C__
-int main(argc, argv) int argc; char *argv[];
+int main(argc, argv) int argc;
+char* argv[];
 #else
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 #endif
 {
   int require = 0;
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 5bfe0fd..95184c9 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -5,6 +5,11 @@
 #if defined(__18CXX)
 # define ID_VOID_MAIN
 #endif
+#if defined(__CLASSIC_C__)
+/* cv-qualifiers did not exist in K&R C */
+# define const
+# define volatile
+#endif
 
 @CMAKE_C_COMPILER_ID_CONTENT@
 
@@ -28,23 +33,32 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
 @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
 @CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@
 
-const char* info_language_dialect_default = "INFO" ":" "dialect_default["
-#if !defined(__STDC_VERSION__)
-  "90"
+#if !defined(__STDC__)
+# if defined(_MSC_VER) && !defined(__clang__)
+#  define C_DIALECT "90"
+# else
+#  define C_DIALECT
+# endif
 #elif __STDC_VERSION__ >= 201000L
-  "11"
+# define C_DIALECT "11"
 #elif __STDC_VERSION__ >= 199901L
-  "99"
+# define C_DIALECT "99"
 #else
+# define C_DIALECT "90"
 #endif
-"]";
+const char* info_language_dialect_default =
+  "INFO" ":" "dialect_default[" C_DIALECT "]";
 
 /*--------------------------------------------------------------------------*/
 
 #ifdef ID_VOID_MAIN
 void main() {}
 #else
+# if defined(__CLASSIC_C__)
+int main(argc, argv) int argc; char *argv[];
+# else
 int main(int argc, char* argv[])
+# endif
 {
   int require = 0;
   require += info_compiler[argc];
diff --git a/Modules/CMakeCXXCompilerABI.cpp b/Modules/CMakeCXXCompilerABI.cpp
index c9b0440..2dee883 100644
--- a/Modules/CMakeCXXCompilerABI.cpp
+++ b/Modules/CMakeCXXCompilerABI.cpp
@@ -1,13 +1,9 @@
 #ifndef __cplusplus
-# error "A C compiler has been selected for C++."
+#error "A C compiler has been selected for C++."
 #endif
 
-/*--------------------------------------------------------------------------*/
-
 #include "CMakeCompilerABI.h"
 
-/*--------------------------------------------------------------------------*/
-
 int main(int argc, char* argv[])
 {
   int require = 0;
diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
index 07d8b1e..a350a84 100644
--- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
+++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
@@ -24,6 +24,7 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR)
      FAIL_REGEX "[Uu]nrecogni[sz]ed .*option"               # GNU, NAG
      FAIL_REGEX "unknown .*option"                          # Clang
      FAIL_REGEX "optimization flag .* not supported"        # Clang
+     FAIL_REGEX "unknown argument ignored"                  # Clang (cl)
      FAIL_REGEX "ignoring unknown option"                   # MSVC, Intel
      FAIL_REGEX "warning D9002"                             # MSVC, any lang
      FAIL_REGEX "option.*not supported"                     # Intel
diff --git a/Modules/CMakeCompilerABI.h b/Modules/CMakeCompilerABI.h
index 26ae4db..f2714b4 100644
--- a/Modules/CMakeCompilerABI.h
+++ b/Modules/CMakeCompilerABI.h
@@ -1,34 +1,32 @@
-/*--------------------------------------------------------------------------*/
 
 /* Size of a pointer-to-data in bytes.  */
 #define SIZEOF_DPTR (sizeof(void*))
-const char info_sizeof_dptr[] =  {
-  'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't', 'r', '[',
-  ('0' + ((SIZEOF_DPTR / 10)%10)),
-  ('0' +  (SIZEOF_DPTR    % 10)),
-  ']','\0'};
-
-/*--------------------------------------------------------------------------*/
+const char info_sizeof_dptr[] = {
+  'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't',
+  'r', '[', ('0' + ((SIZEOF_DPTR / 10) % 10)), ('0' + (SIZEOF_DPTR % 10)), ']',
+  '\0'
+  /* clang-format needs this comment to break after the opening brace */
+};
 
 /* Application Binary Interface.  */
 #if defined(__sgi) && defined(_ABIO32)
-# define ABI_ID "ELF O32"
+#define ABI_ID "ELF O32"
 #elif defined(__sgi) && defined(_ABIN32)
-# define ABI_ID "ELF N32"
+#define ABI_ID "ELF N32"
 #elif defined(__sgi) && defined(_ABI64)
-# define ABI_ID "ELF 64"
+#define ABI_ID "ELF 64"
 
 /* Check for (some) ARM ABIs.
  * See e.g. http://wiki.debian.org/ArmEabiPort for some information on this. */
 #elif defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__)
-# define ABI_ID "ELF ARMEABI"
+#define ABI_ID "ELF ARMEABI"
 #elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEB__)
-# define ABI_ID "ELF ARM"
+#define ABI_ID "ELF ARM"
 #elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__)
-# define ABI_ID "ELF ARM"
+#define ABI_ID "ELF ARM"
 
 #elif defined(__ELF__)
-# define ABI_ID "ELF"
+#define ABI_ID "ELF"
 #endif
 
 #if defined(ABI_ID)
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake
index cbc0055..1d341e5 100644
--- a/Modules/CMakeCompilerIdDetection.cmake
+++ b/Modules/CMakeCompilerIdDetection.cmake
@@ -79,6 +79,7 @@ function(compiler_id_detection outvar lang)
     if (lang STREQUAL C)
       list(APPEND ordered_compilers
         TinyCC
+        Bruce
       )
     endif()
     list(APPEND ordered_compilers
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index e0b5468..f8c6303 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -87,6 +87,9 @@ else()
 
     # Try enabling ANSI mode on HP.
     "-Aa"
+
+    # Try compiling K&R-compatible code (needed by Bruce C Compiler).
+    "-D__CLASSIC_C__"
     )
 endif()
 
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index feae1c4..465989d 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -149,15 +149,15 @@ Id flags: ${testflags}
 ")
 
   # Compile the compiler identification source.
-  if(CMAKE_GENERATOR STREQUAL "Visual Studio 6" AND
-      lang STREQUAL "Fortran")
-    set(CMAKE_${lang}_COMPILER_ID_RESULT 1)
-    set(CMAKE_${lang}_COMPILER_ID_OUTPUT "No Intel Fortran in VS 6")
-  elseif("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
+  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
     set(vs_version ${CMAKE_MATCH_1})
     set(id_platform ${CMAKE_VS_PLATFORM_NAME})
     set(id_lang "${lang}")
-    set(id_cl cl.exe)
+    if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
+      set(id_cl clang.exe)
+    else()
+      set(id_cl cl.exe)
+    endif()
     if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
       set(v NsightTegra)
       set(ext vcxproj)
@@ -175,13 +175,10 @@ Id flags: ${testflags}
     elseif(NOT "${vs_version}" VERSION_LESS 10)
       set(v 10)
       set(ext vcxproj)
-    elseif(NOT "${vs_version}" VERSION_LESS 7)
+    else()
       set(id_version ${vs_version}.00)
       set(v 7)
       set(ext vcproj)
-    else()
-      set(v 6)
-      set(ext dsp)
     endif()
     if(CMAKE_VS_PLATFORM_TOOLSET)
       if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
@@ -235,8 +232,6 @@ Id flags: ${testflags}
         )
     elseif(CMAKE_VS_DEVENV_COMMAND)
       set(command "${CMAKE_VS_DEVENV_COMMAND}" "CompilerId${lang}.${ext}" "/build" "Debug")
-    elseif(CMAKE_VS_MSDEV_COMMAND)
-      set(command "${CMAKE_VS_MSDEV_COMMAND}" "CompilerId${lang}.${ext}" "/make")
     else()
       set(command "")
     endif()
@@ -669,8 +664,8 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang)
     ERROR_VARIABLE err
     RESULT_VARIABLE res
     )
-  if(res EQUAL 0 AND "${out}" MATCHES "\n([^:]*:[^:]*:[ \t]*)")
-    set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_MATCH_1}" PARENT_SCOPE)
+  if(res EQUAL 0 AND "${out}" MATCHES "(^|\n)([^:\n]*:[^:\n]*:[ \t]*)")
+    set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_MATCH_2}" PARENT_SCOPE)
   else()
     set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE)
   endif()
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index ccafb07..4f2a70c 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -185,11 +185,10 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
 
   # Fall back to old is-GNU test.
   if(NOT CMAKE_Fortran_COMPILER_ID)
-    exec_program(${CMAKE_Fortran_COMPILER}
-      ARGS ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\""
-      OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN)
+    execute_process(COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "${CMAKE_ROOT}/Modules/CMakeTestGNU.c"
+      OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RESULT_VARIABLE 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 "
@@ -200,16 +199,31 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
           "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()
     endif()
   endif()
 
+  # Fall back for GNU MINGW, which is not always detected correctly
+  # (__MINGW32__ is defined for the C language, but perhaps not for Fortran!)
+  if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortran_PLATFORM_ID)
+    execute_process(COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "${CMAKE_ROOT}/Modules/CMakeTestGNU.c"
+      OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RESULT_VARIABLE CMAKE_COMPILER_RETURN)
+    if(NOT CMAKE_COMPILER_RETURN)
+      if(CMAKE_COMPILER_OUTPUT MATCHES "THIS_IS_MINGW")
+        set(CMAKE_Fortran_PLATFORM_ID "MinGW")
+      endif()
+      if(CMAKE_COMPILER_OUTPUT MATCHES "THIS_IS_CYGWIN")
+        set(CMAKE_Fortran_PLATFORM_ID "Cygwin")
+      endif()
+    endif()
+  endif()
+
   # Set old compiler and platform id variables.
   if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
     set(CMAKE_COMPILER_IS_GNUG77 1)
diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake
index f8d8d59..bf85ea0 100644
--- a/Modules/CMakeFindCodeBlocks.cmake
+++ b/Modules/CMakeFindCodeBlocks.cmake
@@ -23,3 +23,18 @@ endif()
 
 # Determine builtin macros and include dirs:
 include(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)
+
+# Try to find out how many CPUs we have and set the -j argument for make accordingly
+set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "")
+
+include(ProcessorCount)
+processorcount(_CMAKE_CODEBLOCKS_PROCESSOR_COUNT)
+
+# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name
+# (we may also get here in the future e.g. for ninja)
+if("${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}" GREATER 1  AND  CMAKE_HOST_UNIX  AND  "${CMAKE_MAKE_PROGRAM}" MATCHES make)
+  set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "-j${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}")
+endif()
+
+# This variable is used by the CodeBlocks generator and appended to the make invocation commands.
+set(CMAKE_CODEBLOCKS_MAKE_ARGUMENTS "${_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when CodeBlocks invokes make. Enter e.g. -j<some_number> to get parallel builds")
diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake
index 85c1fdf..5bf738a 100644
--- a/Modules/CMakeFindEclipseCDT4.cmake
+++ b/Modules/CMakeFindEclipseCDT4.cmake
@@ -30,6 +30,8 @@ function(_FIND_ECLIPSE_VERSION)
   set(_ECLIPSE_VERSION_NAME_3.7 "Indigo" )
   set(_ECLIPSE_VERSION_NAME_4.2 "Juno" )
   set(_ECLIPSE_VERSION_NAME_4.3 "Kepler" )
+  set(_ECLIPSE_VERSION_NAME_4.4 "Luna" )
+  set(_ECLIPSE_VERSION_NAME_4.5 "Mars" )
 
   if(NOT DEFINED CMAKE_ECLIPSE_VERSION)
     if(CMAKE_ECLIPSE_EXECUTABLE)
@@ -65,6 +67,8 @@ function(_FIND_ECLIPSE_VERSION)
                                                             "3.7 (${_ECLIPSE_VERSION_NAME_3.7})"
                                                             "4.2 (${_ECLIPSE_VERSION_NAME_4.2})"
                                                             "4.3 (${_ECLIPSE_VERSION_NAME_4.3})"
+                                                            "4.4 (${_ECLIPSE_VERSION_NAME_4.4})"
+                                                            "4.5 (${_ECLIPSE_VERSION_NAME_4.5})"
               )
 endfunction()
 
diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake
index faa0dc5..d16d184 100644
--- a/Modules/CMakeForceCompiler.cmake
+++ b/Modules/CMakeForceCompiler.cmake
@@ -2,9 +2,7 @@
 # CMakeForceCompiler
 # ------------------
 #
-# Discouraged.  Avoid using this module if possible.  It will be deprecated
-# by a future version of CMake once alternatives have been provided for all
-# toolchain file use cases.
+# Deprecated.  Do not use.
 #
 # The macros provided by this module were once intended for use by
 # cross-compiling toolchain files when CMake was not able to automatically
@@ -14,11 +12,11 @@
 # CMake detects from a compiler is now too extensive to be provided by
 # toolchain files using these macros.
 #
-# The only known remaining use case for these macros is to write toolchain
-# files for cross-compilers that cannot link binaries without special flags or
-# custom linker scripts.  These macros cause CMake to skip checks it normally
-# performs as part of enabling a language and introspecting the toolchain.
-# However, skipping these checks may limit some generation functionality.
+# One common use case for this module was to skip CMake's checks for a
+# working compiler when using a cross-compiler that cannot link binaries
+# without special flags or custom linker scripts.  This case is now supported
+# by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the
+# toolchain file instead.
 #
 # -------------------------------------------------------------------------
 #
@@ -78,6 +76,8 @@
 #  License text for the above reference.)
 
 macro(CMAKE_FORCE_C_COMPILER compiler id)
+  message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated.  "
+    "Instead just set CMAKE_C_COMPILER and allow CMake to identify the compiler.")
   set(CMAKE_C_COMPILER "${compiler}")
   set(CMAKE_C_COMPILER_ID_RUN TRUE)
   set(CMAKE_C_COMPILER_ID ${id})
@@ -90,6 +90,8 @@ macro(CMAKE_FORCE_C_COMPILER compiler id)
 endmacro()
 
 macro(CMAKE_FORCE_CXX_COMPILER compiler id)
+  message(DEPRECATION "The CMAKE_FORCE_CXX_COMPILER macro is deprecated.  "
+    "Instead just set CMAKE_CXX_COMPILER and allow CMake to identify the compiler.")
   set(CMAKE_CXX_COMPILER "${compiler}")
   set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
   set(CMAKE_CXX_COMPILER_ID ${id})
@@ -102,6 +104,8 @@ macro(CMAKE_FORCE_CXX_COMPILER compiler id)
 endmacro()
 
 macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
+  message(DEPRECATION "The CMAKE_FORCE_Fortran_COMPILER macro is deprecated.  "
+    "Instead just set CMAKE_Fortran_COMPILER and allow CMake to identify the compiler.")
   set(CMAKE_Fortran_COMPILER "${compiler}")
   set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
   set(CMAKE_Fortran_COMPILER_ID ${id})
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index 206ea7a..5e5302f 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -241,8 +241,10 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
     else()
       message(FATAL_ERROR "INSTALL_PREFIX must be an absolute path")
     endif()
-  else()
+  elseif(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
     set(installPrefix "${CMAKE_INSTALL_PREFIX}")
+  else()
+    get_filename_component(installPrefix "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
   endif()
 
   if(IS_ABSOLUTE "${CCF_INSTALL_DESTINATION}")
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 59092bd..ef9a2eb 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -31,7 +31,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
   # Construct a regex to match linker lines.  It must match both the
   # whole line and just the command (argv[0]).
   set(linker_regex "^( *|.*[/\\])(${linker}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)")
-  set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=")
+  set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ")
   set(log "${log}  link line regex: [${linker_regex}]\n")
   string(REGEX REPLACE "\r?\n" ";" output_lines "${text}")
   foreach(line IN LISTS output_lines)
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index da99b9e..47eb00a 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -91,11 +91,11 @@
 #  define PLATFORM_ID "Windows3x"
 
 # else /* unknown platform */
-#  define PLATFORM_ID ""
+#  define PLATFORM_ID
 # endif
 
 #else /* unknown platform */
-# define PLATFORM_ID ""
+# define PLATFORM_ID
 
 #endif
 
@@ -145,7 +145,7 @@
 # endif
 
 #else
-#  define ARCHITECTURE_ID ""
+#  define ARCHITECTURE_ID
 #endif
 
 /* Convert integer to decimal digit literals.  */
diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake
index bf4ec0e..6958da1 100644
--- a/Modules/CMakePushCheckState.cmake
+++ b/Modules/CMakePushCheckState.cmake
@@ -8,8 +8,8 @@
 # CMAKE_POP_CHECK_STATE() and CMAKE_RESET_CHECK_STATE() These macros can
 # be used to save, restore and reset (i.e., clear contents) the state of
 # the variables CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS,
-# CMAKE_REQUIRED_LIBRARIES and CMAKE_REQUIRED_INCLUDES used by the
-# various Check-files coming with CMake, like e.g.
+# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_INCLUDES and CMAKE_EXTRA_INCLUDE_FILES
+# used by the various Check-files coming with CMake, like e.g.
 # check_function_exists() etc.  The variable contents are pushed on a
 # stack, pushing multiple times is supported.  This is useful e.g.  when
 # executing such tests in a Find-module, where they have to be set, but
@@ -49,6 +49,7 @@
 
 macro(CMAKE_RESET_CHECK_STATE)
 
+   set(CMAKE_EXTRA_INCLUDE_FILES)
    set(CMAKE_REQUIRED_INCLUDES)
    set(CMAKE_REQUIRED_DEFINITIONS)
    set(CMAKE_REQUIRED_LIBRARIES)
@@ -65,6 +66,7 @@ macro(CMAKE_PUSH_CHECK_STATE)
 
    math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
 
+   set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}  ${CMAKE_EXTRA_INCLUDE_FILES})
    set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}    ${CMAKE_REQUIRED_INCLUDES})
    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})
@@ -82,6 +84,7 @@ macro(CMAKE_POP_CHECK_STATE)
 # don't pop more than we pushed
    if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
 
+      set(CMAKE_EXTRA_INCLUDE_FILES  ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
       set(CMAKE_REQUIRED_INCLUDES    ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
       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}})
diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake
index d51b503..e0d45e7 100644
--- a/Modules/CMakeTestCompilerCommon.cmake
+++ b/Modules/CMakeTestCompilerCommon.cmake
@@ -13,9 +13,5 @@
 #  License text for the above reference.)
 
 function(PrintTestCompilerStatus LANG MSG)
-  if(CMAKE_GENERATOR MATCHES Make)
-    message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}")
-  else()
-    message(STATUS "Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG}")
-  endif()
+  message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}")
 endfunction()
diff --git a/Modules/CMakeTestWatcomVersion.c b/Modules/CMakeTestWatcomVersion.c
deleted file mode 100644
index 0343fb1..0000000
--- a/Modules/CMakeTestWatcomVersion.c
+++ /dev/null
@@ -1 +0,0 @@
-VERSION=__WATCOMC__
diff --git a/Modules/CMakeVS6BackwardCompatibility.cmake b/Modules/CMakeVS6BackwardCompatibility.cmake
deleted file mode 100644
index ca48b85..0000000
--- a/Modules/CMakeVS6BackwardCompatibility.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#=============================================================================
-# Copyright 2002-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.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-#  License text for the above reference.)
-
-# hard code these for fast backwards compatibility tests
-set (CMAKE_SIZEOF_INT       4   CACHE INTERNAL "Size of int data type")
-set (CMAKE_SIZEOF_LONG      4   CACHE INTERNAL "Size of long data type")
-set (CMAKE_SIZEOF_VOID_P    4   CACHE INTERNAL "Size of void* data type")
-set (CMAKE_SIZEOF_CHAR      1   CACHE INTERNAL "Size of char data type")
-set (CMAKE_SIZEOF_SHORT     2   CACHE INTERNAL "Size of short data type")
-set (CMAKE_SIZEOF_FLOAT     4   CACHE INTERNAL "Size of float data type")
-set (CMAKE_SIZEOF_DOUBLE    8   CACHE INTERNAL "Size of double data type")
-set (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL
-         "Does the compiler support ansi for scope.")
-set (CMAKE_USE_WIN32_THREADS  TRUE CACHE BOOL    "Use the win32 thread library.")
-set (CMAKE_WORDS_BIGENDIAN 0 CACHE INTERNAL "endianness of bytes")
diff --git a/Modules/CMakeVerifyManifest.cmake b/Modules/CMakeVerifyManifest.cmake
index bff4e1e..a54b9d2 100644
--- a/Modules/CMakeVerifyManifest.cmake
+++ b/Modules/CMakeVerifyManifest.cmake
@@ -6,18 +6,18 @@
 #
 # CMakeVerifyManifest.cmake
 #
-# This script is used to verify that embeded manifests and side by side
+# This script is used to verify that embedded manifests and side by side
 # manifests for a project match.  To run this script, cd to a directory
 # and run the script with cmake -P.  On the command line you can pass in
 # versions that are OK even if not found in the .manifest files.  For
 # example, cmake -Dallow_versions=8.0.50608.0
-# -PCmakeVerifyManifest.cmake could be used to allow an embeded manifest
+# -PCmakeVerifyManifest.cmake could be used to allow an embedded manifest
 # of 8.0.50608.0 to be used in a project even if that version was not
 # found in the .manifest file.
 
 # This script first recursively globs *.manifest files from
 # the current directory.  Then globs *.exe and *.dll.  Each
-# .exe and .dll is scanned for embeded manifests and the versions
+# .exe and .dll is scanned for embedded manifests and the versions
 # of CRT are compared to those found in the .manifest files
 # from the first glob.
 
@@ -54,7 +54,7 @@ function(crt_version file list_var)
     endif()
   endforeach()
   if(NOT DEFINED has_match)
-    message("Information: no embeded manifest in: ${file}")
+    message("Information: no embedded manifest in: ${file}")
     return()
   endif()
   list(APPEND version_list ${${list_var}})
diff --git a/Modules/CPack.OSXX11.Info.plist.in b/Modules/CPack.OSXX11.Info.plist.in
index 851b67b..23a1483 100644
--- a/Modules/CPack.OSXX11.Info.plist.in
+++ b/Modules/CPack.OSXX11.Info.plist.in
@@ -41,8 +41,6 @@
 	<string>@CPACK_APPLE_GUI_BUNDLE_VERSION@</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
-	<key>LSRequiresCarbon</key>
-	<true/>
 	<key>NSHumanReadableCopyright</key>
 	<string>@CPACK_APPLE_GUI_COPYRIGHT@</string>
 </dict>
diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake
index 96d5609..038a717 100644
--- a/Modules/CPackComponent.cmake
+++ b/Modules/CPackComponent.cmake
@@ -444,60 +444,60 @@ endmacro()
 
 # Macro that adds a component group to the CPack installer
 macro(cpack_add_component_group grpname)
-  string(TOUPPER ${grpname} CPACK_ADDGRP_UNAME)
-  cpack_parse_arguments(CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}
+  string(TOUPPER ${grpname} _CPACK_ADDGRP_UNAME)
+  cpack_parse_arguments(CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}
     "DISPLAY_NAME;DESCRIPTION;PARENT_GROUP"
     "EXPANDED;BOLD_TITLE"
     ${ARGN}
     )
 
-  set(CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n")
+  set(_CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n")
   cpack_append_string_variable_set_command(
-    CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DISPLAY_NAME
-    CPACK_ADDGRP_STR)
+    CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_DISPLAY_NAME
+    _CPACK_ADDGRP_STR)
   cpack_append_string_variable_set_command(
-    CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DESCRIPTION
-    CPACK_ADDGRP_STR)
+    CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_DESCRIPTION
+    _CPACK_ADDGRP_STR)
   cpack_append_string_variable_set_command(
-    CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_PARENT_GROUP
-    CPACK_ADDGRP_STR)
+    CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_PARENT_GROUP
+    _CPACK_ADDGRP_STR)
   cpack_append_option_set_command(
-    CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_EXPANDED
-    CPACK_ADDGRP_STR)
+    CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_EXPANDED
+    _CPACK_ADDGRP_STR)
   cpack_append_option_set_command(
-    CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_BOLD_TITLE
-    CPACK_ADDGRP_STR)
+    CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_BOLD_TITLE
+    _CPACK_ADDGRP_STR)
   # Backward compatibility issue.
   # Write to config iff the macros is used after CPack.cmake has been
   # included, other it's not necessary because the variables
   # will be encoded by cpack_encode_variables.
   if(CPack_CMake_INCLUDED)
-    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDGRP_STR}")
+    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_ADDGRP_STR}")
   endif()
 endmacro()
 
 # Macro that adds an installation type to the CPack installer
 macro(cpack_add_install_type insttype)
-  string(TOUPPER ${insttype} CPACK_INSTTYPE_UNAME)
-  cpack_parse_arguments(CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}
+  string(TOUPPER ${insttype} _CPACK_INSTTYPE_UNAME)
+  cpack_parse_arguments(CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME}
     "DISPLAY_NAME"
     ""
     ${ARGN}
     )
 
-  set(CPACK_INSTTYPE_STR
+  set(_CPACK_INSTTYPE_STR
     "\n# Configuration for installation type \"${insttype}\"\n")
-  set(CPACK_INSTTYPE_STR
-    "${CPACK_INSTTYPE_STR}list(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n")
+  set(_CPACK_INSTTYPE_STR
+    "${_CPACK_INSTTYPE_STR}list(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n")
   cpack_append_string_variable_set_command(
-    CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}_DISPLAY_NAME
-    CPACK_INSTTYPE_STR)
+    CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME}_DISPLAY_NAME
+    _CPACK_INSTTYPE_STR)
   # Backward compatibility issue.
   # Write to config iff the macros is used after CPack.cmake has been
   # included, other it's not necessary because the variables
   # will be encoded by cpack_encode_variables.
   if(CPack_CMake_INCLUDED)
-    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_INSTTYPE_STR}")
+    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_INSTTYPE_STR}")
   endif()
 endmacro()
 
diff --git a/Modules/CPackDMG.cmake b/Modules/CPackDMG.cmake
index e34f8cd..929b2f6 100644
--- a/Modules/CPackDMG.cmake
+++ b/Modules/CPackDMG.cmake
@@ -19,7 +19,7 @@
 #
 #  The disk image format. Common values are UDRO (UDIF read-only), UDZO (UDIF
 #  zlib-compressed) or UDBZ (UDIF bzip2-compressed). Refer to hdiutil(1) for
-#  more information on other available formats.
+#  more information on other available formats. Defaults to UDZO.
 #
 # .. variable:: CPACK_DMG_DS_STORE
 #
@@ -46,6 +46,11 @@
 #  CPACK_DMG_DS_STORE_SETUP_SCRIPT is executed or CPACK_DMG_DS_STORE is
 #  installed.  By default no background image is set.
 #
+# .. variable:: CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK
+#
+#  Default behaviour is to include a symlink to ``/Applications`` in the DMG.
+#  Set this option to ``ON`` to avoid adding the symlink.
+#
 # .. variable:: CPACK_DMG_SLA_DIR
 #
 #   Directory where license and menu files for different languages are stored.
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index 2aaef61..c9678d6 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -2,29 +2,44 @@
 # CPackDeb
 # --------
 #
-# The builtin (binary) CPack Deb generator (Unix only)
+# The built in (binary) CPack Deb generator (Unix only)
 #
 # Variables specific to CPack Debian (DEB) generator
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 #
-# CPackDeb may be used to create Deb package using CPack.
-# CPackDeb is a CPack generator thus it uses the ``CPACK_XXX`` variables
-# used by CPack : https://cmake.org/Wiki/CMake:CPackConfiguration.
-# CPackDeb generator should work on any linux host but it will produce
-# better deb package when Debian specific tools 'dpkg-xxx' are usable on
+# CPackDeb may be used to create Deb package using :module:`CPack`.
+# CPackDeb is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
+# variables used by :module:`CPack`.
+#
+# CPackDeb generator should work on any Linux host but it will produce
+# better deb package when Debian specific tools ``dpkg-xxx`` are usable on
 # the build system.
 #
 # CPackDeb has specific features which are controlled by the specifics
 # :code:`CPACK_DEBIAN_XXX` variables.
 #
 # :code:`CPACK_DEBIAN_<COMPONENT>_XXXX` variables may be used in order to have
-# **component** specific values.  Note however that ``<COMPONENT>`` refers to the
-# **grouping name** written in upper case. It may be either a component name or
-# a component GROUP name.
+# **component** specific values.  Note however that ``<COMPONENT>`` refers to
+# the **grouping name** written in upper case. It may be either a component name
+# or a component GROUP name.
+#
+# Here are some CPackDeb wiki resources that are here for historic reasons and
+# are no longer maintained but may still prove useful:
+#
+#  - https://cmake.org/Wiki/CMake:CPackConfiguration
+#  - https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
+#
+# List of CPackRPM specific variables:
+#
+# .. variable:: CPACK_DEB_PACKAGE_COMPONENT
+#
+#  Enable component packaging for CPackRPM
+#
+#  * Mandatory : NO
+#  * Default   : OFF
 #
-# You'll find a detailed usage on the wiki:
-# https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29 .
-# However as a handy reminder here comes the list of specific variables:
+#  If enabled (ON) multiple packages are generated. By default a single package
+#  containing files of all components is generated.
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_NAME
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
@@ -42,6 +57,32 @@
 #
 #  See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
 #
+# .. variable:: CPACK_DEBIAN_FILE_NAME
+#               CPACK_DEBIAN_<COMPONENT>_FILE_NAME
+#
+#  Package file name.
+#
+#  * Mandatory : YES
+#  * Default   : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb``
+#
+#  This may be set to ``DEB-DEFAULT`` to allow CPackDeb to generate package file
+#  name by itself in deb format::
+#
+#    <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
+#
+#  Alternatively provided package file name must end with ``.deb`` suffix.
+#
+#  .. note::
+#
+#    Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
+#    compatibility with CPackDeb in CMake prior to version 3.6 this feature
+#    is disabled by default.
+#
+#  .. note::
+#
+#    By using non default filenames duplicate names may occur. Duplicate files
+#    get overwritten and it is up to the packager to set the variables in a
+#    manner that will prevent such errors.
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_VERSION
 #
@@ -50,8 +91,21 @@
 #  * Mandatory : YES
 #  * Default   : :variable:`CPACK_PACKAGE_VERSION`
 #
+# .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
+#
+#  The Debian package release - Debian revision number.
+#
+#  * Mandatory : YES
+#  * Default   : 1
+#
+#  This is the numbering of the DEB package itself, i.e. the version of the
+#  packaging and not the version of the content (see
+#  :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
+#  if the previous packaging was buggy and/or you want to put here a fancy Linux
+#  distro specific numbering.
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
+#               CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
 #
 #  The Debian package architecture
 #
@@ -59,7 +113,6 @@
 #  * Default   : Output of :code:`dpkg --print-architecture` (or :code:`i386`
 #    if :code:`dpkg` is not found)
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
 #
@@ -87,6 +140,13 @@
 #
 #    set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
 #
+# .. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
+#
+#  Sets inter component dependencies if listed with
+#  :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
+#
+#  * Mandatory : NO
+#  * Default   : -
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER
 #
@@ -95,7 +155,6 @@
 #  * Mandatory : YES
 #  * Default   : :code:`CPACK_PACKAGE_CONTACT`
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION
 #               CPACK_COMPONENT_<COMPONENT>_DESCRIPTION
 #
@@ -114,19 +173,23 @@
 #  Set Section control field e.g. admin, devel, doc, ...
 #
 #  * Mandatory : YES
-#  * Default   : 'devel'
+#  * Default   : "devel"
 #
 #  See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
 #
-#
 # .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
 #
 #  The compression used for creating the Debian package.
-#  Possible values are: lzma, xz, bzip2 and gzip.
 #
 #  * Mandatory : YES
-#  * Default   : 'gzip'
+#  * Default   : "gzip"
+#
+#  Possible values are:
 #
+#  - lzma
+#  - xz
+#  - bzip2
+#  - gzip
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
@@ -135,11 +198,10 @@
 #  extra
 #
 #  * Mandatory : YES
-#  * Default   : 'optional'
+#  * Default   : "optional"
 #
 #  See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
 #
 #  The URL of the web site for this package, preferably (when applicable) the
@@ -154,7 +216,6 @@
 #    The content of this field is a simple URL without any surrounding
 #    characters such as <>.
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
 #
@@ -174,7 +235,6 @@
 #    may fail to find your own shared libs.
 #    See https://cmake.org/Wiki/CMake_RPATH_handling.
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
 #
 #  May be set when invoking cpack in order to trace debug information
@@ -238,7 +298,6 @@
 #
 #  See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
 #
@@ -280,7 +339,6 @@
 #
 #  See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
 #
@@ -297,7 +355,6 @@
 #
 #  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
 #
@@ -314,7 +371,6 @@
 #
 #  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #
-#
 # .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
 #
@@ -330,6 +386,31 @@
 #
 #  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #
+# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
+#
+#  * Mandatory : NO
+#  * Default   : OFF
+#
+#  Allows to generate shlibs control file automatically. Compatibility is defined by
+#  :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
+#
+#  .. note::
+#
+#    Libraries are only considered if they have both library name and version
+#    set. This can be done by setting SOVERSION property with
+#    :command:`set_target_properties` command.
+#
+# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
+#
+#  Compatibility policy for auto-generated shlibs control file.
+#
+#  * Mandatory : NO
+#  * Default   : "="
+#
+#  Defines compatibility policy for auto-generated shlibs control file.
+#  Possible values: "=", ">="
+#
+#  See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
 #               CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
@@ -399,6 +480,10 @@
 #=============================================================================
 # Copyright 2007-2009 Kitware, Inc.
 # Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre at gmail.com>
+# Copyright 2014-2016 Alexander Smorkalov <alexander.smorkalov at itseez.com>
+# Copyright 2014-2016 Roman Donchenko <roman.donchenko at itseez.com>
+# Copyright 2014-2016 Roman Kharitonov <roman.kharitonov at itseez.com>
+# Copyright 2014-2016 Ilya Lavrenov <ilya.lavrenov at itseez.com>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -423,6 +508,49 @@ if(NOT UNIX)
   message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
 endif()
 
+function(cpack_deb_variable_fallback OUTPUT_VAR_NAME)
+  set(FALLBACK_VAR_NAMES ${ARGN})
+
+  foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
+    if(${variable_name})
+      set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
+      break()
+    endif()
+  endforeach()
+endfunction()
+
+function(get_component_package_name var component)
+  string(TOUPPER "${component}" component_upcase)
+  if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME)
+    string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name)
+  else()
+    string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name)
+  endif()
+
+  set("${var}" "${package_name}" PARENT_SCOPE)
+endfunction()
+
+#extract library name and version for given shared object
+function(extract_so_info shared_object libname version)
+  if(READELF_EXECUTABLE)
+    execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}"
+      WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+      RESULT_VARIABLE result
+      OUTPUT_VARIABLE output
+      ERROR_QUIET
+      OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(result EQUAL 0)
+      string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
+      set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
+      set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
+    else()
+      message(WARNING "Error running readelf for \"${shared_object}\"")
+    endif()
+  else()
+    message(FATAL_ERROR "Readelf utility is not available.")
+  endif()
+endfunction()
+
 function(cpack_deb_prepare_package_vars)
   # CPACK_DEBIAN_PACKAGE_SHLIBDEPS
   # If specify OFF, only user depends are used
@@ -447,6 +575,39 @@ function(cpack_deb_prepare_package_vars)
     endif()
   endif()
 
+  if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
+    # Generating binary list - Get type of all install files
+    cmake_policy(PUSH)
+      # Tell file(GLOB_RECURSE) not to follow directory symlinks
+      # even if the project does not set this policy to NEW.
+      cmake_policy(SET CMP0009 NEW)
+      file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
+    cmake_policy(POP)
+
+    # get file info so that we can determine if file is executable or not
+    unset(CPACK_DEB_INSTALL_FILES)
+    foreach(FILE_ IN LISTS FILE_PATHS_)
+      execute_process(COMMAND file "./${FILE_}"
+        WORKING_DIRECTORY "${WDIR}"
+        OUTPUT_VARIABLE INSTALL_FILE_)
+      list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
+    endforeach()
+
+    # Only dynamically linked ELF files are included
+    # Extract only file name infront of ":"
+    foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
+      if(_FILE MATCHES "ELF.*dynamically linked")
+        string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
+        list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
+        set(CONTAINS_EXECUTABLE_FILES_ TRUE)
+      endif()
+      if(_FILE MATCHES "ELF.*shared object")
+        string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
+        list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
+      endif()
+    endforeach()
+  endif()
+
   if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
     # dpkg-shlibdeps is a Debian utility for generating dependency list
     find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
@@ -468,33 +629,6 @@ function(cpack_deb_prepare_package_vars)
         message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
       endif()
 
-      # Generating binary list - Get type of all install files
-      cmake_policy(PUSH)
-        # Tell file(GLOB_RECURSE) not to follow directory symlinks
-        # even if the project does not set this policy to NEW.
-        cmake_policy(SET CMP0009 NEW)
-        file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
-      cmake_policy(POP)
-
-      # get file info so that we can determine if file is executable or not
-      unset(CPACK_DEB_INSTALL_FILES)
-      foreach(FILE_ IN LISTS FILE_PATHS_)
-        execute_process(COMMAND file "./${FILE_}"
-          WORKING_DIRECTORY "${WDIR}"
-          OUTPUT_VARIABLE INSTALL_FILE_)
-        list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
-      endforeach()
-
-      # Only dynamically linked ELF files are included
-      # Extract only file name infront of ":"
-      foreach(_FILE ${CPACK_DEB_INSTALL_FILES})
-        if( ${_FILE} MATCHES "ELF.*dynamically linked")
-           string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
-           list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
-           set(CONTAINS_EXECUTABLE_FILES_ TRUE)
-        endif()
-      endforeach()
-
       if(CONTAINS_EXECUTABLE_FILES_)
         message("CPackDeb: - Generating dependency list")
 
@@ -504,6 +638,9 @@ function(cpack_deb_prepare_package_vars)
         file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian)
         file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "")
 
+        # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN.
+        file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
+
         # Add --ignore-missing-info if the tool supports it
         execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help
           OUTPUT_VARIABLE _TMP_HELP
@@ -544,6 +681,9 @@ function(cpack_deb_prepare_package_vars)
         # Remove blank control file
         # Might not be safe if package actual contain file or directory named debian
         file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian")
+
+        # remove temporary directory that was created only for dpkg-shlibdeps execution
+        file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
       else()
         if(CPACK_DEBIAN_PACKAGE_DEBUG)
           message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.")
@@ -580,7 +720,9 @@ function(cpack_deb_prepare_package_vars)
   endif()
 
   # Architecture: (mandatory)
-  if(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
+  if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE)
+    set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}")
+  elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
     # There is no such thing as i686 architecture on debian, you should use i386 instead
     # $ dpkg --print-architecture
     find_program(DPKG_CMD dpkg)
@@ -624,6 +766,25 @@ function(cpack_deb_prepare_package_vars)
         endif()
       endif()
     endforeach()
+
+    if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS)
+      set(COMPONENT_DEPENDS "")
+      foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS})
+        get_component_package_name(_PACK_NAME "${_PACK}")
+        if(COMPONENT_DEPENDS)
+          set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}")
+        else()
+          set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
+        endif()
+      endforeach()
+      if(COMPONENT_DEPENDS)
+        if(CPACK_DEBIAN_PACKAGE_DEPENDS)
+          set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
+        else()
+          set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}")
+        endif()
+      endif()
+    endif()
   endif()
 
   # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
@@ -631,7 +792,7 @@ function(cpack_deb_prepare_package_vars)
   # Append automatically discovered dependencies .
   if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "")
     if (CPACK_DEBIAN_PACKAGE_DEPENDS)
-      set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
+      set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
     else ()
       set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
     endif ()
@@ -712,14 +873,94 @@ function(cpack_deb_prepare_package_vars)
         set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
       endif()
     endforeach()
+    get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
+  endif()
+
+  set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
+
+  if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
+    set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
+  endif()
+
+  find_program(READELF_EXECUTABLE NAMES readelf)
 
-    if(CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME)
-      string(TOLOWER "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
+  if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
+    if(READELF_EXECUTABLE)
+      foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
+        extract_so_info("${_FILE}" libname soversion)
+        if(libname AND soversion)
+          list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
+               "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_PACKAGE_VERSION})")
+        else()
+          message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
+        endif()
+      endforeach()
+      if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
+        string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
+      endif()
     else()
-      string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEB_PACKAGE_COMPONENT}" CPACK_DEBIAN_PACKAGE_NAME)
+      message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
     endif()
   endif()
 
+  # add ldconfig call in default postrm and postint
+  set(CPACK_ADD_LDCONFIG_CALL 0)
+  foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
+    get_filename_component(_DIR ${_FILE} DIRECTORY)
+    # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
+    if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
+      set(CPACK_ADD_LDCONFIG_CALL 1)
+    endif()
+  endforeach()
+
+  if(CPACK_ADD_LDCONFIG_CALL)
+    set(CPACK_DEBIAN_GENERATE_POSTINST 1)
+    set(CPACK_DEBIAN_GENERATE_POSTRM 1)
+    foreach(f ${PACKAGE_CONTROL_EXTRA})
+      get_filename_component(n "${f}" NAME)
+      if("${n}" STREQUAL "postinst")
+        set(CPACK_DEBIAN_GENERATE_POSTINST 0)
+      endif()
+      if("${n}" STREQUAL "postrm")
+        set(CPACK_DEBIAN_GENERATE_POSTRM 0)
+      endif()
+    endforeach()
+  else()
+    set(CPACK_DEBIAN_GENERATE_POSTINST 0)
+    set(CPACK_DEBIAN_GENERATE_POSTRM 0)
+  endif()
+
+  if(NOT CPACK_DEBIAN_PACKAGE_RELEASE)
+    set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
+  endif()
+
+
+  cpack_deb_variable_fallback("CPACK_DEBIAN_FILE_NAME"
+    "CPACK_DEBIAN_${_local_component_name}_FILE_NAME"
+    "CPACK_DEBIAN_FILE_NAME")
+  if(CPACK_DEBIAN_FILE_NAME)
+    if(CPACK_DEBIAN_FILE_NAME STREQUAL "DEB-DEFAULT")
+      # Patch package file name to be in corrent debian format:
+      # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
+      set(CPACK_OUTPUT_FILE_NAME
+        "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
+    else()
+      cmake_policy(PUSH)
+        cmake_policy(SET CMP0010 NEW)
+        if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.deb")
+      cmake_policy(POP)
+          message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb'!")
+        endif()
+      cmake_policy(POP)
+
+      set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
+    endif()
+
+    set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
+    get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
+    set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
+  endif() # else() back compatibility - don't change the name
+
   # Print out some debug information if we were asked for that
   if(CPACK_DEBIAN_PACKAGE_DEBUG)
      message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY          = '${CPACK_TOPLEVEL_DIRECTORY}'")
@@ -749,6 +990,8 @@ function(cpack_deb_prepare_package_vars)
   #endif()
 
   # move variables to parent scope so that they may be used to create debian package
+  set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
+  set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
@@ -767,11 +1010,14 @@ function(cpack_deb_prepare_package_vars)
   set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
+  set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
       "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
   set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
      "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
+  set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
+  set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
   set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
 endfunction()
 
diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake
index 6649933..083fc28 100644
--- a/Modules/CPackIFW.cmake
+++ b/Modules/CPackIFW.cmake
@@ -4,8 +4,8 @@
 #
 # .. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html
 #
-# This module looks for the location of the command line utilities supplied with
-# the Qt Installer Framework (QtIFW_).
+# This module looks for the location of the command line utilities supplied
+# with the Qt Installer Framework (QtIFW_).
 #
 # The module also defines several commands to control the behavior of the
 # CPack ``IFW`` generator.
@@ -31,7 +31,8 @@
 # Variables
 # ^^^^^^^^^
 #
-# You can use the following variables to change behavior of CPack ``IFW`` generator.
+# You can use the following variables to change behavior of CPack ``IFW``
+# generator.
 #
 # Debug
 # """"""
@@ -65,7 +66,8 @@
 #
 # .. variable:: CPACK_IFW_PACKAGE_WINDOW_ICON
 #
-#  Filename for a custom window icon in PNG format for the Installer application.
+#  Filename for a custom window icon in PNG format for the Installer
+#  application.
 #
 # .. variable:: CPACK_IFW_PACKAGE_LOGO
 #
@@ -80,7 +82,8 @@
 # .. variable:: CPACK_IFW_TARGET_DIRECTORY
 #
 #  Default target directory for installation.
-#  By default used "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`"
+#  By default used
+#  "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`"
 #
 #  You can use predefined variables.
 #
@@ -134,6 +137,7 @@
 #
 #  The default value of this variable is computed by CPack and contains
 #  all repositories added with command :command:`cpack_ifw_add_repository`
+#  or updated with command :command:`cpack_ifw_update_repository`.
 #
 # .. variable:: CPACK_IFW_DOWNLOAD_ALL
 #
@@ -185,7 +189,7 @@
 #
 # ::
 #
-#   cpack_ifw_configure_component(<compname> [COMMON]
+#   cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL]
 #                       [NAME <name>]
 #                       [VERSION <version>]
 #                       [SCRIPT <script>]
@@ -193,20 +197,23 @@
 #                       [DEPENDS <com_id> ...]
 #                       [LICENSES <display_name> <file_path> ...])
 #
-# This command should be called after cpack_add_component command.
+# This command should be called after :command:`cpack_add_component` command.
 #
 # ``COMMON`` if set, then the component will be packaged and installed as part
 # of a group to which it belongs.
 #
+# ``ESSENTIAL`` if set, then the package manager stays disabled until that
+# component is updated.
+#
+# ``NAME`` is used to create domain-like identification for this component.
+# By default used origin component name.
+#
 # ``VERSION`` is version of component.
 # By default used :variable:`CPACK_PACKAGE_VERSION`.
 #
 # ``SCRIPT`` is a relative or absolute path to operations script
 # for this component.
 #
-# ``NAME`` is used to create domain-like identification for this component.
-# By default used origin component name.
-#
 # ``PRIORITY`` is priority of the component in the tree.
 #
 # ``DEPENDS`` list of dependency component identifiers in QtIFW_ style.
@@ -222,21 +229,23 @@
 #
 # ::
 #
-#   cpack_ifw_configure_component_group(<grpname>
-#                       [VERSION <version>]
+#   cpack_ifw_configure_component_group(<groupname>
 #                       [NAME <name>]
+#                       [VERSION <version>]
 #                       [SCRIPT <script>]
 #                       [PRIORITY <priority>]
 #                       [LICENSES <display_name> <file_path> ...])
 #
-# This command should be called after cpack_add_component_group command.
+# This command should be called after :command:`cpack_add_component_group`
+# command.
+#
+# ``NAME`` is used to create domain-like identification for this component
+# group.
+# By default used origin component group name.
 #
 # ``VERSION`` is version of component group.
 # By default used :variable:`CPACK_PACKAGE_VERSION`.
 #
-# ``NAME`` is used to create domain-like identification for this component group.
-# By default used origin component group name.
-#
 # ``SCRIPT`` is a relative or absolute path to operations script
 # for this component group.
 #
@@ -249,7 +258,7 @@
 #
 # .. command:: cpack_ifw_add_repository
 #
-# Add QtIFW_ specific remote repository.
+# Add QtIFW_ specific remote repository to binary installer.
 #
 # ::
 #
@@ -259,8 +268,8 @@
 #                       [PASSWORD <password>]
 #                       [DISPLAY_NAME <display_name>])
 #
-# This macro will also add the <reponame> repository
-# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`
+# This command will also add the <reponame> repository
+# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
 #
 # ``DISABLED`` if set, then the repository will be disabled by default.
 #
@@ -272,6 +281,37 @@
 #
 # ``DISPLAY_NAME`` is string to display instead of the URL.
 #
+#
+# --------------------------------------------------------------------------
+#
+# .. command:: cpack_ifw_update_repository
+#
+# Update QtIFW_ specific repository from remote repository.
+#
+# ::
+#
+#   cpack_ifw_update_repository(<reponame>
+#                       [[ADD|REMOVE] URL <url>]|
+#                        [REPLACE OLD_URL <old_url> NEW_URL <new_url>]]
+#                       [USERNAME <username>]
+#                       [PASSWORD <password>]
+#                       [DISPLAY_NAME <display_name>])
+#
+# This command will also add the <reponame> repository
+# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
+#
+# ``URL`` is points to a list of available components.
+#
+# ``OLD_URL`` is points to a list that will replaced.
+#
+# ``NEW_URL`` is points to a list that will replace to.
+#
+# ``USERNAME`` is used as user on a protected repository.
+#
+# ``PASSWORD`` is password to use on a protected repository.
+#
+# ``DISPLAY_NAME`` is string to display instead of the URL.
+#
 # Example usage
 # ^^^^^^^^^^^^^
 #
@@ -331,6 +371,9 @@
 #  Predefined Variables
 #   http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables
 #
+#  Promoting Updates
+#   http://doc.qt.io/qtinstallerframework/ifw-updates.html
+#
 # Download Qt Installer Framework for you platform from Qt site:
 #  http://download.qt.io/official_releases/qt-installer-framework
 #
@@ -377,6 +420,8 @@ set(_CPACK_IFW_SUFFIXES
   "QtIFW2.3.0/bin"
   "QtIFW2.2.0/bin"
   "QtIFW2.1.0/bin"
+  "QtIFW2.0.3/bin"
+  "QtIFW2.0.1/bin"
   "QtIFW2.0.0/bin"
 # First branch
   "QtIFW-1.6.0/bin"
@@ -503,8 +548,8 @@ macro(cpack_ifw_configure_component compname)
 
   string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME)
 
-  set(_IFW_OPT COMMON)
-  set(_IFW_ARGS VERSION SCRIPT NAME PRIORITY)
+  set(_IFW_OPT COMMON ESSENTIAL)
+  set(_IFW_ARGS NAME VERSION SCRIPT PRIORITY)
   set(_IFW_MULTI_ARGS DEPENDS LICENSES)
   cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
 
@@ -608,6 +653,51 @@ macro(cpack_ifw_add_repository reponame)
 
 endmacro()
 
+# Macro for updating repository
+macro(cpack_ifw_update_repository reponame)
+
+  string(TOUPPER ${reponame} _CPACK_IFWREPO_UNAME)
+
+  set(_IFW_OPT ADD REMOVE REPLACE DISABLED)
+  set(_IFW_ARGS URL OLD_URL NEW_URL USERNAME PASSWORD DISPLAY_NAME)
+  set(_IFW_MULTI_ARGS)
+  cmake_parse_arguments(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
+
+  set(_CPACK_IFWREPO_STR "\n# Configuration for IFW repository \"${reponame}\" update\n")
+
+  foreach(_IFW_ARG_NAME ${_IFW_OPT})
+  cpack_append_option_set_command(
+    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
+    _CPACK_IFWREPO_STR)
+  endforeach()
+
+  foreach(_IFW_ARG_NAME ${_IFW_ARGS})
+  cpack_append_string_variable_set_command(
+    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
+    _CPACK_IFWREPO_STR)
+  endforeach()
+
+  foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
+  cpack_append_variable_set_command(
+    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
+    _CPACK_IFWREPO_STR)
+  endforeach()
+
+  if(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_ADD
+    OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REMOVE
+    OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REPLACE)
+    list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})
+    set(_CPACK_IFWREPO_STR "${_CPACK_IFWREPO_STR}list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n")
+  else()
+    set(_CPACK_IFWREPO_STR)
+  endif()
+
+  if(CPack_CMake_INCLUDED AND _CPACK_IFWREPO_STR)
+    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWREPO_STR}")
+  endif()
+
+endmacro()
+
 # Resolve package control script
 _cpack_ifw_resolve_script(CPACK_IFW_PACKAGE_CONTROL_SCRIPT)
 
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 7fb11c3..d231ff0 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -2,31 +2,55 @@
 # CPackRPM
 # --------
 #
-# The builtin (binary) CPack RPM generator (Unix only)
+# The built in (binary) CPack RPM generator (Unix only)
 #
 # Variables specific to CPack RPM generator
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 #
-# CPackRPM may be used to create RPM package using CPack.  CPackRPM is a
-# CPack generator thus it uses the CPACK_XXX variables used by CPack :
-# https://cmake.org/Wiki/CMake:CPackConfiguration
+# CPackRPM may be used to create RPM packages using :module:`CPack`.
+# CPackRPM is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
+# variables used by :module:`CPack`.
 #
-# However CPackRPM has specific features which are controlled by the
-# specifics CPACK_RPM_XXX variables.  CPackRPM is a component aware
-# generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more
-# CPACK_RPM_<ComponentName>_XXXX variables may be used in order to have
-# component specific values.  Note however that <componentName> refers
-# to the **grouping name**.  This may be either a component name or a
-# component GROUP name.  Usually those vars correspond to RPM spec file
-# entities, one may find information about spec files here
-# http://www.rpm.org/wiki/Docs.  You'll find a detailed usage of
-# CPackRPM on the wiki:
+# CPackRPM has specific features which are controlled by the specifics
+# :code:`CPACK_RPM_XXX` variables.
 #
-# ::
+# :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have
+# **component** specific values.  Note however that ``<COMPONENT>`` refers to the
+# **grouping name** written in upper case. It may be either a component name or
+# a component GROUP name. Usually those variables correspond to RPM spec file
+# entities. One may find information about spec files here
+# http://www.rpm.org/wiki/Docs
 #
-#   https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
+# .. note::
 #
-# However as a handy reminder here comes the list of specific variables:
+#  `<COMPONENT>` part of variables is preferred to be in upper case (for e.g. if
+#  component is named `foo` then use `CPACK_RPM_FOO_XXXX` variable name format)
+#  as is with other `CPACK_<COMPONENT>_XXXX` variables.
+#  For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
+#  support for same cased component (e.g. `fOo` would be used as
+#  `CPACK_RPM_fOo_XXXX`) is still supported for variables defined in older
+#  versions of CMake/CPack but is not guaranteed for variables that
+#  will be added in the future. For the sake of back compatibility same cased
+#  component variables also override upper cased versions where both are
+#  present.
+#
+# Here are some CPackRPM wiki resources that are here for historic reasons and
+# are no longer maintained but may still prove useful:
+#
+#  - https://cmake.org/Wiki/CMake:CPackConfiguration
+#  - https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
+#
+# List of CPackRPM specific variables:
+#
+# .. variable:: CPACK_RPM_PACKAGE_COMPONENT
+#
+#  Enable component packaging for CPackRPM
+#
+#  * Mandatory : NO
+#  * Default   : OFF
+#
+#  If enabled (ON) multiple packages are generated. By default a single package
+#  containing files of all components is generated.
 #
 # .. variable:: CPACK_RPM_PACKAGE_SUMMARY
 #               CPACK_RPM_<component>_PACKAGE_SUMMARY
@@ -34,7 +58,7 @@
 #  The RPM package summary.
 #
 #  * Mandatory : YES
-#  * Default   : CPACK_PACKAGE_DESCRIPTION_SUMMARY
+#  * Default   : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
 #
 # .. variable:: CPACK_RPM_PACKAGE_NAME
 #               CPACK_RPM_<component>_PACKAGE_NAME
@@ -42,14 +66,38 @@
 #  The RPM package name.
 #
 #  * Mandatory : YES
-#  * Default   : CPACK_PACKAGE_NAME
+#  * Default   : :variable:`CPACK_PACKAGE_NAME`
+#
+# .. variable:: CPACK_RPM_FILE_NAME
+#               CPACK_RPM_<component>_FILE_NAME
+#
+#  Package file name.
+#
+#  * Mandatory : YES
+#  * Default   : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
+#                replaced by '-'
+#
+#  This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package
+#  file name by itself.
+#  Alternatively provided package file name must end with ``.rpm`` suffix.
+#
+#  .. note::
+#
+#    By using user provided spec file, rpm macro extensions such as for
+#    generating debuginfo packages or by simply using multiple components more
+#    than one rpm file may be generated, either from a single spec file or from
+#    multiple spec files (each component execution produces it's own spec file).
+#    In such cases duplicate file names may occur as a result of this variable
+#    setting or spec file content structure. Duplicate files get overwritten
+#    and it is up to the packager to set the variables in a manner that will
+#    prevent such errors.
 #
 # .. variable:: CPACK_RPM_PACKAGE_VERSION
 #
 #  The RPM package version.
 #
 #  * Mandatory : YES
-#  * Default   : CPACK_PACKAGE_VERSION
+#  * Default   : :variable:`CPACK_PACKAGE_VERSION`
 #
 # .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
 #               CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
@@ -57,9 +105,9 @@
 #  The RPM package architecture.
 #
 #  * Mandatory : YES
-#  * Default   : Native architecture output by "uname -m"
+#  * Default   : Native architecture output by ``uname -m``
 #
-#  This may be set to "noarch" if you know you are building a noarch package.
+#  This may be set to ``noarch`` if you know you are building a noarch package.
 #
 # .. variable:: CPACK_RPM_PACKAGE_RELEASE
 #
@@ -70,10 +118,27 @@
 #
 #  This is the numbering of the RPM package itself, i.e. the version of the
 #  packaging and not the version of the content (see
-#  CPACK_RPM_PACKAGE_VERSION). One may change the default value if the
-#  previous packaging was buggy and/or you want to put here a fancy Linux
+#  :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
+#  the previous packaging was buggy and/or you want to put here a fancy Linux
 #  distro specific numbering.
 #
+# .. note::
+#
+#  This is the string that goes into the RPM ``Release:`` field. Some distros
+#  (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
+#  ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
+#
+# .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
+#
+#  The dist tag that is added  RPM ``Release:`` field.
+#
+#  * Mandatory : NO
+#  * Default   : OFF
+#
+#  This is the reported ``%{dist}`` tag from the current distribution or empty
+#  ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
+#  ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
+#
 # .. variable:: CPACK_RPM_PACKAGE_LICENSE
 #
 #  The RPM package license policy.
@@ -110,9 +175,9 @@
 #  RPM package description.
 #
 #  * Mandatory : YES
-#  * Default : CPACK_COMPONENT_<compName>_DESCRIPTION (component based installers
-#    only) if set, CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package
-#    description available"
+#  * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
+#    based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
+#    if set or "no package description available"
 #
 # .. variable:: CPACK_RPM_COMPRESSION_TYPE
 #
@@ -123,8 +188,15 @@
 #
 #  May be used to override RPM compression type to be used to build the
 #  RPM. For example some Linux distribution now default to lzma or xz
-#  compression whereas older cannot use such RPM.  Using this one can enforce
-#  compression type to be used.  Possible value are: lzma, xz, bzip2 and gzip.
+#  compression whereas older cannot use such RPM. Using this one can enforce
+#  compression type to be used.
+#
+#  Possible values are:
+#
+#  - lzma
+#  - xz
+#  - bzip2
+#  - gzip
 #
 # .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
 #               CPACK_RPM_<component>_PACKAGE_AUTOREQ
@@ -139,7 +211,7 @@
 #
 #  .. note::
 #
-#    By defalut automatic dependency detection is enabled by rpm generator.
+#    By default automatic dependency detection is enabled by rpm generator.
 #
 # .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
 #               CPACK_RPM_<component>_PACKAGE_AUTOPROV
@@ -155,7 +227,7 @@
 #
 #  .. note::
 #
-#    By defalut automatic provides detection is enabled by rpm generator.
+#    By default automatic provides detection is enabled by rpm generator.
 #
 # .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
 #               CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
@@ -171,7 +243,7 @@
 #
 #  .. note::
 #
-#    By defalut automatic detection feature is enabled by rpm.
+#    By default automatic detection feature is enabled by rpm.
 #
 # .. variable:: CPACK_RPM_PACKAGE_REQUIRES
 #               CPACK_RPM_<component>_PACKAGE_REQUIRES
@@ -181,7 +253,7 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set RPM dependencies (requires).  Note that you must enclose
+#  May be used to set RPM dependencies (requires). Note that you must enclose
 #  the complete requires string between quotes, for example::
 #
 #   set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
@@ -198,8 +270,8 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set negative RPM dependencies (conflicts). Note that you must enclose
-#  the complete requires string between quotes, for example::
+#  May be used to set negative RPM dependencies (conflicts). Note that you must
+#  enclose the complete requires string between quotes, for example::
 #
 #   set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
 #
@@ -215,8 +287,8 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set RPM preinstall dependencies (requires(pre)).  Note that you must enclose
-#  the complete requires string between quotes, for example::
+#  May be used to set RPM preinstall dependencies (requires(pre)). Note that
+#  you must enclose the complete requires string between quotes, for example::
 #
 #   set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
 #
@@ -228,12 +300,11 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set RPM postinstall dependencies (requires(post)).  Note that you must enclose
-#  the complete requires string between quotes, for example::
+#  May be used to set RPM postinstall dependencies (requires(post)). Note that
+#  you must enclose the complete requires string between quotes, for example::
 #
 #   set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
 #
-#
 # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
 #               CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
 #
@@ -242,12 +313,12 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set RPM postuninstall dependencies (requires(postun)).  Note that you must enclose
-#  the complete requires string between quotes, for example::
+#  May be used to set RPM postuninstall dependencies (requires(postun)). Note
+#  that you must enclose the complete requires string between quotes, for
+#  example::
 #
 #   set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
 #
-#
 # .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
 #               CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
 #
@@ -256,8 +327,8 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set RPM preuninstall dependencies (requires(preun)).  Note that you must enclose
-#  the complete requires string between quotes, for example::
+#  May be used to set RPM preuninstall dependencies (requires(preun)). Note that
+#  you must enclose the complete requires string between quotes, for example::
 #
 #   set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
 #
@@ -269,7 +340,7 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set weak RPM dependencies (suggests).  Note that you must
+#  May be used to set weak RPM dependencies (suggests). Note that you must
 #  enclose the complete requires string between quotes.
 #
 # .. variable:: CPACK_RPM_PACKAGE_PROVIDES
@@ -280,7 +351,7 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to set RPM dependencies (provides).  The provided package list
+#  May be used to set RPM dependencies (provides). The provided package list
 #  of an RPM file could be printed with::
 #
 #   rpm -qp --provides file.rpm
@@ -308,21 +379,23 @@
 #
 #   rpm --prefix or --relocate
 #
-#  in order to install it at an alternate place see rpm(8).  Note that
-#  currently this may fail if CPACK_SET_DESTDIR is set to ON.  If
-#  CPACK_SET_DESTDIR is set then you will get a warning message but if there
-#  is file installed with absolute path you'll get unexpected behavior.
+#  in order to install it at an alternate place see rpm(8). Note that
+#  currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
+#  :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
+#  if there is file installed with absolute path you'll get unexpected behavior.
 #
 # .. variable:: CPACK_RPM_SPEC_INSTALL_POST
 #
+#  Deprecated - use :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
+#
 #  * Mandatory : NO
 #  * Default   : -
 #  * Deprecated: YES
 #
 #  This way of specifying post-install script is deprecated, use
-#  CPACK_RPM_POST_INSTALL_SCRIPT_FILE.
+#  :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE`.
 #  May be used to set an RPM post-install command inside the spec file.
-#  For example setting it to "/bin/true" may be used to prevent
+#  For example setting it to ``/bin/true`` may be used to prevent
 #  rpmbuild to strip binaries.
 #
 # .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
@@ -332,7 +405,7 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to add any %define lines to the generated spec file.
+#  May be used to add any ``%define`` lines to the generated spec file.
 #
 # .. variable:: CPACK_RPM_PACKAGE_DEBUG
 #
@@ -347,6 +420,7 @@
 #   cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
 #
 # .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
+#               CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
 #
 #  A user provided spec file.
 #
@@ -356,8 +430,6 @@
 #  May be set by the user in order to specify a USER binary spec file
 #  to be used by CPackRPM instead of generating the file.
 #  The specified file will be processed by configure_file( @ONLY).
-#  One can provide a component specific file by setting
-#  CPACK_RPM_<componentName>_USER_BINARY_SPECFILE.
 #
 # .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
 #
@@ -372,21 +444,24 @@
 #   cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
 #
 #  The user may then use this file in order to hand-craft is own
-#  binary spec file which may be used with CPACK_RPM_USER_BINARY_SPECFILE.
+#  binary spec file which may be used with
+#  :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
 #
 # .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
 #               CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
 #
+#  Path to file containing pre (un)install script.
+#
 #  * Mandatory : NO
 #  * Default   : -
 #
 #  May be used to embed a pre (un)installation script in the spec file.
-#  The refered script file(s) will be read and directly
-#  put after the %pre or %preun section
-#  If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
-#  each component can be overridden with
-#  CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE and
-#  CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE.
+#  The referred script file (or both) will be read and directly
+#  put after the ``%pre`` or ``%preun`` section
+#  If :variable:`CPACK_RPM_PACKAGE_COMPONENT` is set to ON the (un)install
+#  script for each component can be overridden with
+#  ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`` and
+#  ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``.
 #  One may verify which scriptlet has been included with::
 #
 #   rpm -qp --scripts  package.rpm
@@ -394,16 +469,18 @@
 # .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
 #               CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
 #
+#  Path to file containing post (un)install script.
+#
 #  * Mandatory : NO
 #  * Default   : -
 #
 #  May be used to embed a post (un)installation script in the spec file.
-#  The refered script file(s) will be read and directly
-#  put after the %post or %postun section.
-#  If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
-#  each component can be overridden with
-#  CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE and
-#  CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE.
+#  The referred script file (or both) will be read and directly
+#  put after the ``%post`` or ``%postun`` section.
+#  If :variable:`CPACK_RPM_PACKAGE_COMPONENT` is set to ON the (un)install
+#  script for each component can be overridden with
+#  ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`` and
+#  ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``.
 #  One may verify which scriptlet has been included with::
 #
 #   rpm -qp --scripts  package.rpm
@@ -414,11 +491,11 @@
 #  * Mandatory : NO
 #  * Default   : -
 #
-#  May be used to explicitly specify %(<directive>) file line
-#  in the spec file. Like %config(noreplace) or any other directive
-#  that be found in the %files section. Since CPackRPM is generating
+#  May be used to explicitly specify ``%(<directive>)`` file line
+#  in the spec file. Like ``%config(noreplace)`` or any other directive
+#  that be found in the ``%files`` section. Since CPackRPM is generating
 #  the list of files (and directories) the user specified files of
-#  the CPACK_RPM_<COMPONENT>_USER_FILELIST list will be removed from
+#  the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will be removed from
 #  the generated list.
 #
 # .. variable:: CPACK_RPM_CHANGELOG_FILE
@@ -429,7 +506,7 @@
 #  * Default   : -
 #
 #  May be used to embed a changelog in the spec file.
-#  The refered file will be read and directly put after the %changelog
+#  The referred file will be read and directly put after the ``%changelog``
 #  section.
 #
 # .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
@@ -443,8 +520,8 @@
 #  list of paths discovered by CPack RPM. The defaut value contains a
 #  reasonable set of values if the variable is not defined by the user. If the
 #  variable is defined by the user then CPackRPM will NOT any of the default
-#  path.  If you want to add some path to the default list then you can use
-#  CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION variable.
+#  path. If you want to add some path to the default list then you can use
+#  :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
 #
 # .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
 #
@@ -454,39 +531,47 @@
 #  * Default   : -
 #
 #  May be used to add more exclude path (directories or files) from the initial
-#  default list of excluded paths. See CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST.
+#  default list of excluded paths. See
+#  :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
 #
 # .. variable:: CPACK_RPM_RELOCATION_PATHS
 #
+#  Packages relocation paths list.
+#
 #  * Mandatory : NO
 #  * Default   : -
 #
 #  May be used to specify more than one relocation path per relocatable RPM.
 #  Variable contains a list of relocation paths that if relative are prefixed
-#  by the value of CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX or by the value of
-#  CPACK_PACKAGING_INSTALL_PREFIX if the component version is not provided.
+#  by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
+#  value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
+#  is not provided.
 #  Variable is not component based as its content can be used to set a different
 #  path prefix for e.g. binary dir and documentation dir at the same time.
 #  Only prefixes that are required by a certain component are added to that
 #  component - component must contain at least one file/directory/symbolic link
-#  with CPACK_RPM_RELOCATION_PATHS prefix for a certain relocation path
-#  to be added. Package will not contain any relocation paths if there are no
-#  files/directories/symbolic links on any of the provided prefix locations.
+#  with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
+#  path to be added. Package will not contain any relocation paths if there are
+#  no files/directories/symbolic links on any of the provided prefix locations.
 #  Packages that either do not contain any relocation paths or contain
 #  files/directories/symbolic links that are outside relocation paths print
-#  out an AUTHOR_WARNING that RPM will be partially relocatable.
+#  out an ``AUTHOR_WARNING`` that RPM will be partially relocatable.
 #
 # .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
 #
+#  Per component relocation path install prefix.
+#
 #  * Mandatory : NO
 #  * Default   : CPACK_PACKAGING_INSTALL_PREFIX
 #
-#  May be used to set per component CPACK_PACKAGING_INSTALL_PREFIX for
-#  relocatable RPM packages.
+#  May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
+#  for relocatable RPM packages.
 #
 # .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
 #               CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
 #
+#  Removal of default install prefix from relocation paths list.
+#
 #  * Mandatory : NO
 #  * Default   : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
 #                are treated as one of relocation paths
@@ -521,6 +606,63 @@
 #  - /usr/share/doc/.*/man/man.*
 #  - /usr/lib/.*/man/man.*
 #
+# .. variable:: CPACK_RPM_DEFAULT_USER
+#               CPACK_RPM_<compName>_DEFAULT_USER
+#
+#  default user ownership of RPM content
+#
+#  * Mandatory : NO
+#  * Default   : root
+#
+#  Value should be user name and not UID.
+#  Note that <compName> must be in upper-case.
+#
+# .. variable:: CPACK_RPM_DEFAULT_GROUP
+#               CPACK_RPM_<compName>_DEFAULT_GROUP
+#
+#  default group ownership of RPM content
+#
+#  * Mandatory : NO
+#  * Default   : root
+#
+#  Value should be group name and not GID.
+#  Note that <compName> must be in upper-case.
+#
+# .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
+#               CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
+#
+#  default permissions used for packaged files
+#
+#  * Mandatory : NO
+#  * Default   : - (system default)
+#
+#  Accepted values are lists with ``PERMISSIONS``. Valid permissions
+#  are:
+#
+#  - OWNER_READ
+#  - OWNER_WRITE
+#  - OWNER_EXECUTE
+#  - GROUP_READ
+#  - GROUP_WRITE
+#  - GROUP_EXECUTE
+#  - WORLD_READ
+#  - WORLD_WRITE
+#  - WORLD_EXECUTE
+#
+#  Note that <compName> must be in upper-case.
+#
+# .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
+#               CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
+#
+#  default permissions used for packaged directories
+#
+#  * Mandatory : NO
+#  * Default   : - (system default)
+#
+#  Accepted values are lists with PERMISSIONS. Valid permissions
+#  are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
+#  Note that <compName> must be in upper-case.
+#
 # Packaging of Symbolic Links
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 #
@@ -541,9 +683,10 @@
 # while determining if symlink should be either created or present in a
 # post install script - depending on relocation paths.
 #
-# Currenty there are a few limitations though:
+# Symbolic links that point to locations outside packaging path produce a
+# warning and are treated as non relocatable permanent symbolic links.
 #
-# * Only symbolic links with relative path can be packaged.
+# Currently there are a few limitations though:
 #
 # * For component based packaging component interdependency is not checked
 #   when processing symbolic links. Symbolic links pointing to content of
@@ -557,7 +700,7 @@
 #   invalid location.
 
 #=============================================================================
-# Copyright 2007-2009 Kitware, Inc.
+# Copyright 2007-2016 Kitware, Inc.
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -571,10 +714,41 @@
 
 # Author: Eric Noulard with the help of Alexander Neundorf.
 
+function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR)
+  set(PERMISSIONS ${${PERMISSIONS_VAR}})
+  list(LENGTH PERMISSIONS PERM_LEN_PRE)
+  list(REMOVE_DUPLICATES PERMISSIONS)
+  list(LENGTH PERMISSIONS PERM_LEN_POST)
+
+  if(NOT ${PERM_LEN_PRE} EQUAL ${PERM_LEN_POST})
+    message(FATAL_ERROR "${PERMISSIONS_VAR} contains duplicate values.")
+  endif()
+
+  foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
+    set(${PERMISSION_TYPE}_PERMISSIONS 0)
+
+    foreach(PERMISSION ${PERMISSIONS})
+      if("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_READ")
+        math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 4")
+      elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_WRITE")
+        math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 2")
+      elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_EXECUTE")
+        math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 1")
+      elseif(PERMISSION MATCHES "${PERMISSION_TYPE}.*")
+        message(FATAL_ERROR "${PERMISSIONS_VAR} contains invalid values.")
+      endif()
+    endforeach()
+  endforeach()
+
+  set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE)
+endfunction()
+
 function(cpack_rpm_prepare_relocation_paths)
   # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
   if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX)
     file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX)
+  elseif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX)
+    file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX)
   else()
     file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX)
   endif()
@@ -585,7 +759,8 @@ function(cpack_rpm_prepare_relocation_paths)
   # set base path prefix
   if(EXISTS "${WDIR}/${PATH_PREFIX}")
     if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND
-       NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION)
+       NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND
+       NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION)
       set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}Prefix: ${PATH_PREFIX}\n")
       list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}")
 
@@ -978,13 +1153,28 @@ function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXE
           get_filename_component(SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE)
         endif()
 
-        string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
+        # recalculate path length after conversion to canonical form
+        string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
+
+        if(SYMLINK_POINT_ MATCHES "${WDIR}/.*")
+          # only symlinks that are pointing inside the packaging structure should be checked for relocation
+          string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
+          cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS")
+          cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS")
 
-        cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS")
-        cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS")
+          list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT)
+          list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT)
+        else()
+          # location pointed to is ouside WDR so it should be treated as a permanent symlink
+          set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}")
 
-        list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT)
-        list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT)
+          unset(SYMLINK_RELOCATIONS)
+          unset(POINT_RELOCATIONS)
+          unset(SYMLINK_RELOCATIONS_COUNT)
+          unset(POINT_RELOCATIONS_COUNT)
+
+          message(AUTHOR_WARNING "CPackRPM:Warning: Symbolic link '${F}' points to location that is outside packaging path! Link will possibly not be relocatable.")
+        endif()
 
         if(SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT)
           # find matching
@@ -1044,6 +1234,17 @@ if(NOT UNIX)
   message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
 endif()
 
+function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME)
+  set(FALLBACK_VAR_NAMES ${ARGN})
+
+  foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
+    if(${variable_name})
+      set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
+      break()
+    endif()
+  endforeach()
+endfunction()
+
 function(cpack_rpm_generate_package)
   # rpmbuild is the basic command for building RPM package
   # it may be a simple (symbolic) link to rpm command.
@@ -1124,12 +1325,10 @@ function(cpack_rpm_generate_package)
 
   # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
 
-  #Check for component summary first.
-  #If not set, it will use regular package summary logic.
   if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY)
-      set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY})
-    endif()
+    cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY")
   endif()
 
   if(NOT CPACK_RPM_PACKAGE_SUMMARY)
@@ -1142,17 +1341,15 @@ function(cpack_rpm_generate_package)
   endif()
 
   # CPACK_RPM_PACKAGE_NAME (mandatory)
-
   if(NOT CPACK_RPM_PACKAGE_NAME)
     string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
   endif()
 
   if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME)
-      set(CPACK_RPM_PACKAGE_NAME ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME})
-    else()
-      set(CPACK_RPM_PACKAGE_NAME ${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT})
-    endif()
+    set(CPACK_RPM_PACKAGE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT}")
+    cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
   endif()
 
   # CPACK_RPM_PACKAGE_VERSION (mandatory)
@@ -1179,19 +1376,18 @@ function(cpack_rpm_generate_package)
     endif()
   endif()
 
-  set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE})
-
-  #prefer component architecture
   if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE)
-      set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE})
-      if(CPACK_RPM_PACKAGE_DEBUG)
-        message("CPackRPM:Debug: using component build arch = ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
-      endif()
+    cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE")
+
+    if(CPACK_RPM_PACKAGE_DEBUG)
+      message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
     endif()
   endif()
-  if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
-    set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
+
+  if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
+    set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
   else()
     set(TMP_RPM_BUILDARCH "")
   endif()
@@ -1205,7 +1401,11 @@ function(cpack_rpm_generate_package)
   # This is the case when the packaging is buggy (not) the software :=)
   # If not set, 1 is a good candidate
   if(NOT CPACK_RPM_PACKAGE_RELEASE)
-    set(CPACK_RPM_PACKAGE_RELEASE 1)
+    set(CPACK_RPM_PACKAGE_RELEASE "1")
+  endif()
+
+  if(CPACK_RPM_PACKAGE_RELEASE_DIST)
+    set(CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}%{?dist}")
   endif()
 
   # CPACK_RPM_PACKAGE_LICENSE
@@ -1214,13 +1414,10 @@ function(cpack_rpm_generate_package)
   endif()
 
   # CPACK_RPM_PACKAGE_GROUP
-
-  #Check for component group first.
-  #If not set, it will use regular package group logic.
   if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP)
-      set(CPACK_RPM_PACKAGE_GROUP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP})
-    endif()
+    cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP")
   endif()
 
   if(NOT CPACK_RPM_PACKAGE_GROUP)
@@ -1247,14 +1444,11 @@ function(cpack_rpm_generate_package)
   #   - set to a default value
   #
 
-  #Check for a component description first.
-  #If not set, it will use regular package description logic.
   if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION)
-      set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION})
-    elseif(CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION)
-      set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION})
-    endif()
+    cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION"
+      "CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION")
   endif()
 
   if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
@@ -1306,32 +1500,21 @@ function(cpack_rpm_generate_package)
   # If component specific var is not provided we use the global one
   # for each component
   foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
+    if(CPACK_RPM_PACKAGE_DEBUG)
+      message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
+    endif()
+    if(CPACK_RPM_PACKAGE_COMPONENT)
+      cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}"
+        "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}"
+        "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}")
+    endif()
+
+    if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
       if(CPACK_RPM_PACKAGE_DEBUG)
-        message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
-      endif()
-      if(CPACK_RPM_PACKAGE_COMPONENT)
-          if(DEFINED CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER})
-              if(CPACK_RPM_PACKAGE_DEBUG)
-                message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}")
-              endif()
-              set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}})
-          else()
-              if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
-                if(CPACK_RPM_PACKAGE_DEBUG)
-                  message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined")
-                  message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
-                endif()
-                set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
-              endif()
-          endif()
-      else()
-          if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
-            if(CPACK_RPM_PACKAGE_DEBUG)
-              message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
-            endif()
-            set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
-          endif()
+        message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
       endif()
+      set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
+    endif()
 
     # Treat the RPM Spec keyword iff it has been properly defined
     if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
@@ -1373,94 +1556,38 @@ function(cpack_rpm_generate_package)
   # May be used to embed a post (un)installation script in the spec file.
   # The refered script file(s) will be read and directly
   # put after the %post or %postun section
-  if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE)
-      set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE})
-    else()
-      set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE})
-    endif()
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE)
-      set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE})
-    else()
-      set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE})
-    endif()
-  else()
-    set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE})
-    set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE})
-  endif()
-
-  # Handle post-install file if it has been specified
-  if(CPACK_RPM_POST_INSTALL_READ_FILE)
-    if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE})
-      file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL)
-    else()
-      message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring")
-    endif()
-  else()
-    # reset SPEC var value if no post install file has been specified
-    # (either globally or component-wise)
-    set(CPACK_RPM_SPEC_POSTINSTALL "")
-  endif()
-
-  # Handle post-uninstall file if it has been specified
-  if(CPACK_RPM_POST_UNINSTALL_READ_FILE)
-    if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE})
-      file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL)
-    else()
-      message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring")
-    endif()
-  else()
-    # reset SPEC var value if no post uninstall file has been specified
-    # (either globally or component-wise)
-    set(CPACK_RPM_SPEC_POSTUNINSTALL "")
-  endif()
-
+  # ----------------------------------------------------------------
   # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
   # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE)
   # May be used to embed a pre (un)installation script in the spec file.
   # The refered script file(s) will be read and directly
   # put after the %pre or %preun section
-  if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE)
-      set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE})
-    else()
-      set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE})
-    endif()
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE)
-      set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE})
-    else()
-      set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE})
-    endif()
-  else()
-    set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE})
-    set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE})
-  endif()
+  foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL")
+    foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST")
+      set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
+        "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}")
 
-  # Handle pre-install file if it has been specified
-  if(CPACK_RPM_PRE_INSTALL_READ_FILE)
-    if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE})
-      file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL)
-    else()
-      message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring")
-    endif()
-  else()
-    # reset SPEC var value if no pre-install file has been specified
-    # (either globally or component-wise)
-    set(CPACK_RPM_SPEC_PREINSTALL "")
-  endif()
+      if(CPACK_RPM_PACKAGE_COMPONENT)
+        cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
+          "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE"
+          "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE")
+      endif()
 
-  # Handle pre-uninstall file if it has been specified
-  if(CPACK_RPM_PRE_UNINSTALL_READ_FILE)
-    if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE})
-      file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL)
-    else()
-      message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring")
-    endif()
-  else()
-    # reset SPEC var value if no pre-uninstall file has been specified
-    # (either globally or component-wise)
-    set(CPACK_RPM_SPEC_PREUNINSTALL "")
-  endif()
+      # Handle file if it has been specified
+      if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE)
+        if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE})
+          file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}
+            "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}")
+        else()
+          message("CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exists - ignoring")
+        endif()
+      else()
+        # reset SPEC var value if no file has been specified
+        # (either globally or component-wise)
+        set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "")
+      endif()
+    endforeach()
+  endforeach()
 
   # CPACK_RPM_CHANGELOG_FILE
   # May be used to embed a changelog in the spec file.
@@ -1495,8 +1622,6 @@ function(cpack_rpm_generate_package)
   file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
   file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
 
-  #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
-  set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
   # it seems rpmbuild can't handle spaces in the path
   # neither escaping (as below) nor putting quotes around the path seem to help
   #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
@@ -1510,12 +1635,14 @@ function(cpack_rpm_generate_package)
   # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling
   if(CPACK_RPM_PACKAGE_COMPONENT)
     if(CPACK_ABSOLUTE_DESTINATION_FILES)
-     set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}")
-     set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}")
-     if(CPACK_RPM_PACKAGE_DEBUG)
-       message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>")
-       message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
-     endif()
+      cpack_rpm_variable_fallback("COMPONENT_FILES_TAG"
+        "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}"
+        "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}")
+      set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}")
+      if(CPACK_RPM_PACKAGE_DEBUG)
+        message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>")
+        message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
+      endif()
     endif()
   else()
     if(CPACK_ABSOLUTE_DESTINATION_FILES)
@@ -1524,22 +1651,18 @@ function(cpack_rpm_generate_package)
   endif()
 
   # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST.
+  set(CPACK_RPM_USER_FILELIST_INTERNAL "")
   if(CPACK_RPM_PACKAGE_COMPONENT)
-    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST)
-      set(CPACK_RPM_USER_FILELIST_INTERNAL ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST})
-      if(CPACK_RPM_PACKAGE_DEBUG)
-        message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
-        message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
-      endif()
-    else()
-      set(CPACK_RPM_USER_FILELIST_INTERNAL "")
-    endif()
-  else()
-    if(CPACK_RPM_USER_FILELIST)
-      set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
-    else()
-      set(CPACK_RPM_USER_FILELIST_INTERNAL "")
+    cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST")
+
+    if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL)
+      message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
+      message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
     endif()
+  elseif(CPACK_RPM_USER_FILELIST)
+    set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
   endif()
 
   # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL
@@ -1578,7 +1701,6 @@ function(cpack_rpm_generate_package)
       if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
         list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH})
       endif()
-
     endforeach()
 
     # Rebuild CPACK_RPM_INSTALL_FILES
@@ -1629,6 +1751,30 @@ function(cpack_rpm_generate_package)
       "${CPACK_RPM_PACKAGE_RELOCATABLE}"
     )
 
+  # set default user and group
+  foreach(_PERM_TYPE "USER" "GROUP")
+    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE})
+      set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}}")
+    elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE})
+      set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_DEFAULT_${_PERM_TYPE}}")
+    else()
+      set(TMP_DEFAULT_${_PERM_TYPE} "root")
+    endif()
+  endforeach()
+
+  # set default file and dir permissions
+  foreach(_PERM_TYPE "FILE" "DIR")
+    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
+      get_unix_permissions_octal_notation("CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+      set(_PERMISSIONS_VAR "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+    elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
+      get_unix_permissions_octal_notation("CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+      set(_PERMISSIONS_VAR "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+    else()
+      set(TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS "-")
+    endif()
+  endforeach()
+
   # The name of the final spec file to be used by rpmbuild
   set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec")
 
@@ -1650,8 +1796,32 @@ function(cpack_rpm_generate_package)
   #
 
   # We can have a component specific spec file.
-  if(CPACK_RPM_PACKAGE_COMPONENT AND CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE)
-    set(CPACK_RPM_USER_BINARY_SPECFILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE})
+  if(CPACK_RPM_PACKAGE_COMPONENT)
+    cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE"
+      "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE")
+  endif()
+
+  cpack_rpm_variable_fallback("CPACK_RPM_FILE_NAME"
+    "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_FILE_NAME"
+    "CPACK_RPM_FILE_NAME")
+  if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
+    if(CPACK_RPM_FILE_NAME)
+      cmake_policy(PUSH)
+        cmake_policy(SET CMP0010 NEW)
+        if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm")
+      cmake_policy(POP)
+          message(FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!")
+        endif()
+      cmake_policy(POP)
+    else()
+      # old file name format for back compatibility
+      set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
+    endif()
+    # else example:
+    #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
+
+    set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}")
   endif()
 
   # We should generate a USER spec file template:
@@ -1684,7 +1854,7 @@ Vendor:         \@CPACK_RPM_PACKAGE_VENDOR\@
 \@TMP_RPM_PREFIXES\@
 
 %define _rpmdir \@CPACK_RPM_DIRECTORY\@
-%define _rpmfilename \@CPACK_RPM_FILE_NAME\@
+\@FILE_NAME_DEFINE\@
 %define _unpackaged_files_terminate_build 0
 %define _topdir \@CPACK_RPM_DIRECTORY\@
 \@TMP_RPM_SPEC_INSTALL_POST\@
@@ -1726,7 +1896,7 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT
 \@CPACK_RPM_SPEC_PREUNINSTALL\@
 
 %files
-%defattr(-,root,root,-)
+%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
 \@CPACK_RPM_INSTALL_FILES\@
 \@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
 \@CPACK_RPM_USER_INSTALL_FILES\@
@@ -1762,7 +1932,7 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT
       COMMAND "${RPMBUILD_EXECUTABLE}" -bb
               --define "_topdir ${CPACK_RPM_DIRECTORY}"
               --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
-              --target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}"
+              --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}"
               "${CPACK_RPM_BINARY_SPECFILE}"
       WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
       RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT
@@ -1782,6 +1952,24 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT
       message(FATAL_ERROR "RPM packaging through alien not done (yet)")
     endif()
   endif()
+
+  # find generated rpm files and take their names
+  cmake_policy(PUSH)
+    # Tell file(GLOB_RECURSE) not to follow directory symlinks
+    # even if the project does not set this policy to NEW.
+    cmake_policy(SET CMP0009 NEW)
+    file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/*.rpm")
+  cmake_policy(POP)
+
+  if(NOT GENERATED_FILES)
+    message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}")
+  endif()
+
+  set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE)
+
+  if(CPACK_RPM_PACKAGE_DEBUG)
+     message("CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}")
+  endif()
 endfunction()
 
 cpack_rpm_generate_package()
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake
index 4994005..3c90561 100644
--- a/Modules/CPackWIX.cmake
+++ b/Modules/CPackWIX.cmake
@@ -234,7 +234,7 @@
 #  * ARPCOMMENTS - Comments
 #  * ARPHELPLINK - Help and support information URL
 #  * ARPURLINFOABOUT - General information URL
-#  * URLUPDATEINFO - Update information URL
+#  * ARPURLUPDATEINFO - Update information URL
 #  * ARPHELPTELEPHONE - Help and support telephone number
 #  * ARPSIZE - Size (in kilobytes) of the application
 
@@ -256,14 +256,14 @@ if(NOT CPACK_WIX_ROOT)
 endif()
 
 find_program(CPACK_WIX_CANDLE_EXECUTABLE candle
-  PATHS "${CPACK_WIX_ROOT}/bin")
+  PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin")
 
 if(NOT CPACK_WIX_CANDLE_EXECUTABLE)
   message(FATAL_ERROR "Could not find the WiX candle executable.")
 endif()
 
 find_program(CPACK_WIX_LIGHT_EXECUTABLE light
-  PATHS "${CPACK_WIX_ROOT}/bin")
+  PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin")
 
 if(NOT CPACK_WIX_LIGHT_EXECUTABLE)
   message(FATAL_ERROR "Could not find the WiX light executable.")
diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake
index 8278c5c..a27eb4b 100644
--- a/Modules/CTest.cmake
+++ b/Modules/CTest.cmake
@@ -230,9 +230,6 @@ if(BUILD_TESTING)
       get_filename_component(DART_CXX_NAME
         "${CMAKE_MAKE_PROGRAM}" ${DART_NAME_COMPONENT})
     endif()
-    if(DART_CXX_NAME MATCHES "msdev")
-      set(DART_CXX_NAME "vs60")
-    endif()
     if(DART_CXX_NAME MATCHES "devenv")
       GET_VS_VERSION_STRING("${CMAKE_GENERATOR}" DART_CXX_NAME)
     endif()
diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake
index ef3aa76..a04d340 100644
--- a/Modules/CTestCoverageCollectGCOV.cmake
+++ b/Modules/CTestCoverageCollectGCOV.cmake
@@ -2,14 +2,19 @@
 # CTestCoverageCollectGCOV
 # ------------------------
 #
-# This module provides the function ``ctest_coverage_collect_gcov``.
-# The function will run gcov on the .gcda files in a binary tree and then
-# package all of the .gcov files into a tar file with a data.json that
-# contains the source and build directories for CDash to use in parsing
-# the coverage data. In addtion the Labels.json files for targets that
-# have coverage information are also put in the tar file for CDash to
-# asign the correct labels. This file can be sent to a CDash server for
-# display with the
+# This module provides the ``ctest_coverage_collect_gcov`` function.
+#
+# This function runs gcov on all .gcda files found in the binary tree
+# and packages the resulting .gcov files into a tar file.
+# This tarball also contains the following:
+#
+# * *data.json* defines the source and build directories for use by CDash.
+# * *Labels.json* indicates any :prop_sf:`LABELS` that have been set on the
+#   source files.
+# * The *uncovered* directory holds any uncovered files found by
+#   :variable:`CTEST_EXTRA_COVERAGE_GLOB`.
+#
+# After generating this tar file, it can be sent to CDash for display with the
 # :command:`ctest_submit(CDASH_UPLOAD)` command.
 #
 # .. command:: cdash_coverage_collect_gcov
@@ -46,6 +51,13 @@
 #     is run as ``gcov <options>... -o <gcov-dir> <file>.gcda``.
 #     If not specified, the default option is just ``-b``.
 #
+#   ``GLOB``
+#     Recursively search for .gcda files in build_dir rather than
+#     determining search locations by reading TargetDirectories.txt.
+#
+#   ``DELETE``
+#     Delete coverage files after they've been packaged into the .tar.
+#
 #   ``QUIET``
 #     Suppress non-error messages that otherwise would have been
 #     printed out by this function.
@@ -64,7 +76,7 @@
 #  License text for the above reference.)
 include(CMakeParseArguments)
 function(ctest_coverage_collect_gcov)
-  set(options QUIET)
+  set(options QUIET GLOB DELETE)
   set(oneValueArgs TARBALL SOURCE BUILD GCOV_COMMAND)
   set(multiValueArgs GCOV_OPTIONS)
   cmake_parse_arguments(GCOV  "${options}" "${oneValueArgs}"
@@ -91,22 +103,32 @@ function(ctest_coverage_collect_gcov)
   # run gcov on each gcda file in the binary tree
   set(gcda_files)
   set(label_files)
-  # look for gcda files in the target directories
-  # could do a glob from the top of the binary tree but
-  # this will be faster and only look where the files will be
-  file(STRINGS "${binary_dir}/CMakeFiles/TargetDirectories.txt" target_dirs
-       ENCODING UTF-8)
-  foreach(target_dir ${target_dirs})
-    file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${target_dir}/*.gcda")
-    list(LENGTH gfiles len)
-    # if we have gcda files then also grab the labels file for that target
-    if(${len} GREATER 0)
-      file(GLOB_RECURSE lfiles RELATIVE ${binary_dir}
-        "${target_dir}/Labels.json")
-      list(APPEND gcda_files ${gfiles})
-      list(APPEND label_files ${lfiles})
-    endif()
-  endforeach()
+  if (GCOV_GLOB)
+      file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${binary_dir}/*.gcda")
+      list(LENGTH gfiles len)
+      # if we have gcda files then also grab the labels file for that target
+      if(${len} GREATER 0)
+        file(GLOB_RECURSE lfiles RELATIVE ${binary_dir} "${binary_dir}/Labels.json")
+        list(APPEND gcda_files ${gfiles})
+        list(APPEND label_files ${lfiles})
+      endif()
+  else()
+    # look for gcda files in the target directories
+    # this will be faster and only look where the files will be
+    file(STRINGS "${binary_dir}/CMakeFiles/TargetDirectories.txt" target_dirs
+         ENCODING UTF-8)
+    foreach(target_dir ${target_dirs})
+      file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${target_dir}/*.gcda")
+      list(LENGTH gfiles len)
+      # if we have gcda files then also grab the labels file for that target
+      if(${len} GREATER 0)
+        file(GLOB_RECURSE lfiles RELATIVE ${binary_dir}
+          "${target_dir}/Labels.json")
+        list(APPEND gcda_files ${gfiles})
+        list(APPEND label_files ${lfiles})
+      endif()
+    endforeach()
+  endif()
   # return early if no coverage files were found
   list(LENGTH gcda_files len)
   if(len EQUAL 0)
@@ -134,6 +156,11 @@ function(ctest_coverage_collect_gcov)
       OUTPUT_VARIABLE out
       RESULT_VARIABLE res
       WORKING_DIRECTORY ${coverage_dir})
+
+    if (GCOV_DELETE)
+      file(REMOVE ${gcda_file})
+    endif()
+
   endforeach()
   if(NOT "${res}" EQUAL 0)
     if (NOT GCOV_QUIET)
@@ -150,6 +177,21 @@ function(ctest_coverage_collect_gcov)
   set(unfiltered_gcov_files)
   file(GLOB_RECURSE unfiltered_gcov_files RELATIVE ${binary_dir} "${coverage_dir}/*.gcov")
 
+  # if CTEST_EXTRA_COVERAGE_GLOB was specified we search for files
+  # that might be uncovered
+  if (DEFINED CTEST_EXTRA_COVERAGE_GLOB)
+    set(uncovered_files)
+    foreach(search_entry IN LISTS CTEST_EXTRA_COVERAGE_GLOB)
+      if(NOT GCOV_QUIET)
+        message("Add coverage glob: ${search_entry}")
+      endif()
+      file(GLOB_RECURSE matching_files "${source_dir}/${search_entry}")
+      if (matching_files)
+        list(APPEND uncovered_files "${matching_files}")
+      endif()
+    endforeach()
+  endif()
+
   set(gcov_files)
   foreach(gcov_file ${unfiltered_gcov_files})
     file(STRINGS ${binary_dir}/${gcov_file} first_line LIMIT_COUNT 1 ENCODING UTF-8)
@@ -173,20 +215,62 @@ function(ctest_coverage_collect_gcov)
       endif()
     endforeach()
 
+    get_filename_component(resolved_source_file "${source_file}" ABSOLUTE)
+    foreach(uncovered_file IN LISTS uncovered_files)
+      get_filename_component(resolved_uncovered_file "${uncovered_file}" ABSOLUTE)
+      if (resolved_uncovered_file STREQUAL resolved_source_file)
+        list(REMOVE_ITEM uncovered_files "${uncovered_file}")
+      endif()
+    endforeach()
+
     if(NOT is_excluded)
       list(APPEND gcov_files ${gcov_file})
     endif()
   endforeach()
 
+  foreach (uncovered_file ${uncovered_files})
+    # Check if this uncovered file should be excluded.
+    set(is_excluded false)
+    foreach(exclude_entry IN LISTS CTEST_CUSTOM_COVERAGE_EXCLUDE)
+      if(uncovered_file MATCHES "${exclude_entry}")
+        set(is_excluded true)
+        if(NOT GCOV_QUIET)
+          message("Excluding coverage for: ${uncovered_file} which matches ${exclude_entry}")
+        endif()
+        break()
+      endif()
+    endforeach()
+    if(is_excluded)
+      continue()
+    endif()
+
+    # Copy from source to binary dir, preserving any intermediate subdirectories.
+    get_filename_component(filename "${uncovered_file}" NAME)
+    get_filename_component(relative_path "${uncovered_file}" DIRECTORY)
+    string(REPLACE "${source_dir}" "" relative_path "${relative_path}")
+    if (relative_path)
+      # Strip leading slash.
+      string(SUBSTRING "${relative_path}" 1 -1 relative_path)
+    endif()
+    file(COPY ${uncovered_file} DESTINATION ${binary_dir}/uncovered/${relative_path})
+    if(relative_path)
+      list(APPEND uncovered_files_for_tar uncovered/${relative_path}/${filename})
+    else()
+      list(APPEND uncovered_files_for_tar uncovered/${filename})
+    endif()
+  endforeach()
+
   # tar up the coverage info with the same date so that the md5
   # sum will be the same for the tar file independent of file time
   # stamps
   string(REPLACE ";" "\n" gcov_files "${gcov_files}")
   string(REPLACE ";" "\n" label_files "${label_files}")
+  string(REPLACE ";" "\n" uncovered_files_for_tar "${uncovered_files_for_tar}")
   file(WRITE "${coverage_dir}/coverage_file_list.txt"
     "${gcov_files}
 ${coverage_dir}/data.json
 ${label_files}
+${uncovered_files_for_tar}
 ")
 
   if (GCOV_QUIET)
@@ -201,4 +285,16 @@ ${label_files}
     "--format=gnutar"
     --files-from=${coverage_dir}/coverage_file_list.txt
     WORKING_DIRECTORY ${binary_dir})
+
+  if (GCOV_DELETE)
+    foreach(gcov_file ${unfiltered_gcov_files})
+      file(REMOVE ${binary_dir}/${gcov_file})
+    endforeach()
+    file(REMOVE ${coverage_dir}/coverage_file_list.txt)
+    file(REMOVE ${coverage_dir}/data.json)
+    if (EXISTS ${binary_dir}/uncovered)
+      file(REMOVE ${binary_dir}/uncovered)
+    endif()
+  endif()
+
 endfunction()
diff --git a/Modules/CheckForPthreads.c b/Modules/CheckForPthreads.c
index 344c81b..6fc6f26 100644
--- a/Modules/CheckForPthreads.c
+++ b/Modules/CheckForPthreads.c
@@ -1,16 +1,18 @@
-#include <stdio.h>
 #include <pthread.h>
+#include <stdio.h>
 #include <unistd.h>
 
 void* runner(void*);
 
 int res = 0;
 #ifdef __CLASSIC_C__
-int main(){
+int main()
+{
   int ac;
-  char*av[];
+  char* av[];
 #else
-int main(int ac, char*av[]){
+int main(int ac, char* av[])
+{
 #endif
   pthread_t tid[2];
   pthread_create(&tid[0], 0, runner, (void*)1);
@@ -22,17 +24,18 @@ int main(int ac, char*av[]){
 
   pthread_join(tid[0], 0);
   pthread_join(tid[1], 0);
-  if(ac > 1000){return *av[0];}
+  if (ac > 1000) {
+    return *av[0];
+  }
   return res;
 }
 
 void* runner(void* args)
 {
   int cc;
-  for ( cc = 0; cc < 10; cc ++ )
-    {
+  for (cc = 0; cc < 10; cc++) {
     printf("%p CC: %d\n", args, cc);
-    }
-  res ++;
+  }
+  res++;
   return 0;
 }
diff --git a/Modules/CheckFunctionExists.c b/Modules/CheckFunctionExists.c
index fd29618..2304000 100644
--- a/Modules/CheckFunctionExists.c
+++ b/Modules/CheckFunctionExists.c
@@ -3,24 +3,26 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char CHECK_FUNCTION_EXISTS();
+  char
+  CHECK_FUNCTION_EXISTS();
 #ifdef __CLASSIC_C__
-int main(){
+int main()
+{
   int ac;
-  char*av[];
+  char* av[];
 #else
-int main(int ac, char*av[]){
+int main(int ac, char* av[])
+{
 #endif
   CHECK_FUNCTION_EXISTS();
-  if(ac > 1000)
-    {
+  if (ac > 1000) {
     return *av[0];
-    }
+  }
   return 0;
 }
 
-#else  /* CHECK_FUNCTION_EXISTS */
+#else /* CHECK_FUNCTION_EXISTS */
 
-#  error "CHECK_FUNCTION_EXISTS has to specify the function"
+#error "CHECK_FUNCTION_EXISTS has to specify the function"
 
 #endif /* CHECK_FUNCTION_EXISTS */
diff --git a/Modules/CheckVariableExists.c b/Modules/CheckVariableExists.c
index 752f6e4..6e94877 100644
--- a/Modules/CheckVariableExists.c
+++ b/Modules/CheckVariableExists.c
@@ -3,18 +3,22 @@
 extern int CHECK_VARIABLE_EXISTS;
 
 #ifdef __CLASSIC_C__
-int main(){
+int main()
+{
   int ac;
-  char*av[];
+  char* av[];
 #else
-int main(int ac, char*av[]){
+int main(int ac, char* av[])
+{
 #endif
-  if(ac > 1000){return *av[0];}
+  if (ac > 1000) {
+    return *av[0];
+  }
   return CHECK_VARIABLE_EXISTS;
 }
 
-#else  /* CHECK_VARIABLE_EXISTS */
+#else /* CHECK_VARIABLE_EXISTS */
 
-#  error "CHECK_VARIABLE_EXISTS has to specify the variable"
+#error "CHECK_VARIABLE_EXISTS has to specify the variable"
 
 #endif /* CHECK_VARIABLE_EXISTS */
diff --git a/Modules/Compiler/Bruce-C-DetermineCompiler.cmake b/Modules/Compiler/Bruce-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..bb9f4b9
--- /dev/null
+++ b/Modules/Compiler/Bruce-C-DetermineCompiler.cmake
@@ -0,0 +1 @@
+set(_compiler_id_pp_test "defined(__BCC__)")
diff --git a/Modules/Compiler/Bruce-C.cmake b/Modules/Compiler/Bruce-C.cmake
new file mode 100644
index 0000000..23676ec
--- /dev/null
+++ b/Modules/Compiler/Bruce-C.cmake
@@ -0,0 +1,7 @@
+# Bruce C Compiler ignores "-g" flag and optimization cannot be
+# enabled here (it is implemented only for 8086 target).
+set (CMAKE_C_FLAGS_INIT "-D__CLASSIC_C__")
+set (CMAKE_C_FLAGS_DEBUG_INIT "-g")
+set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG")
+set (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG")
+set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -DNDEBUG")
diff --git a/Modules/Compiler/Clang-CXX-TestableFeatures.cmake b/Modules/Compiler/Clang-CXX-TestableFeatures.cmake
index b39475c..69965a6 100644
--- a/Modules/Compiler/Clang-CXX-TestableFeatures.cmake
+++ b/Modules/Compiler/Clang-CXX-TestableFeatures.cmake
@@ -8,7 +8,6 @@ set(testable_features
   cxx_constexpr
   cxx_contextual_conversions
   cxx_decltype
-  cxx_decltype_incomplete_return_types
   cxx_default_function_template_args
   cxx_defaulted_functions
   cxx_delegating_constructors
@@ -36,6 +35,9 @@ set(testable_features
   cxx_variable_templates
   cxx_variadic_templates
 )
+if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+  list(APPEND testable_features cxx_decltype_incomplete_return_types)
+endif()
 
 foreach(feature ${testable_features})
   set(_cmake_feature_test_${feature} "${_cmake_oldestSupported} && __has_feature(${feature})")
diff --git a/Modules/Compiler/GHS-C.cmake b/Modules/Compiler/GHS-C.cmake
index e97d62c..3072715 100644
--- a/Modules/Compiler/GHS-C.cmake
+++ b/Modules/Compiler/GHS-C.cmake
@@ -1,4 +1,7 @@
+include(Compiler/GHS)
+
 set(CMAKE_C_VERBOSE_FLAG "-v")
+set(CMAKE_C_OUTPUT_EXTENSION ".o")
 
 set(CMAKE_C_FLAGS_INIT "")
 set(CMAKE_C_FLAGS_DEBUG_INIT "-Odebug -g")
diff --git a/Modules/Compiler/GHS-CXX.cmake b/Modules/Compiler/GHS-CXX.cmake
index 71a0dec..a51591b 100644
--- a/Modules/Compiler/GHS-CXX.cmake
+++ b/Modules/Compiler/GHS-CXX.cmake
@@ -1,4 +1,7 @@
+include(Compiler/GHS)
+
 set(CMAKE_CXX_VERBOSE_FLAG "-v")
+set(CMAKE_CXX_OUTPUT_EXTENSION ".o")
 
 set(CMAKE_CXX_FLAGS_INIT "")
 set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Odebug -g")
diff --git a/Modules/Compiler/GHS.cmake b/Modules/Compiler/GHS.cmake
new file mode 100644
index 0000000..e6a867d
--- /dev/null
+++ b/Modules/Compiler/GHS.cmake
@@ -0,0 +1,8 @@
+if(__COMPILER_GHS)
+  return()
+endif()
+set(__COMPILER_GHS 1)
+
+set(CMAKE_EXECUTABLE_SUFFIX ".as")
+set(CMAKE_LIBRARY_PATH_TERMINATOR "\n")
+set(CMAKE_LIBRARY_PATH_FLAG "  -L")
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 764fbf9..c2d393d 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -41,7 +41,7 @@ macro(__compiler_gnu lang)
     # distcc does not transform -o to -MT when invoking the preprocessor
     # internally, as it ought to.  Work around this bug by setting -MT here
     # even though it isn't strictly necessary.
-    set(CMAKE_DEPFILE_FLAGS_${lang} "-MMD -MT <OBJECT> -MF <DEPFILE>")
+    set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>")
   endif()
 
   # Initial configuration flags.
@@ -52,7 +52,7 @@ macro(__compiler_gnu lang)
   set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
   set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
-  if(NOT APPLE)
+  if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462
     set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
   endif()
 endmacro()
diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake
index d2c7df9..f1b6ff7 100644
--- a/Modules/Compiler/IAR-C.cmake
+++ b/Modules/Compiler/IAR-C.cmake
@@ -7,6 +7,9 @@ set(CMAKE_C_COMPILE_OBJECT             "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <I
 set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
 set(CMAKE_C_CREATE_ASSEMBLY_SOURCE     "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
 
+set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "-f")
+set(CMAKE_DEPFILE_FLAGS_C "--dependencies=ns <DEPFILE>")
+
 # The toolchains for ARM and AVR are quite different:
 if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
 
diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake
index 03ecdf1..ffb144f 100644
--- a/Modules/Compiler/IAR-CXX.cmake
+++ b/Modules/Compiler/IAR-CXX.cmake
@@ -7,7 +7,8 @@ set(CMAKE_CXX_COMPILE_OBJECT  "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES
 set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
 set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE     "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
 
-
+set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "-f")
+set(CMAKE_DEPFILE_FLAGS_CXX "--dependencies=ns <DEPFILE>")
 
 if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
 
diff --git a/Modules/Compiler/Intel-C-FeatureTests.cmake b/Modules/Compiler/Intel-C-FeatureTests.cmake
new file mode 100644
index 0000000..34175c8
--- /dev/null
+++ b/Modules/Compiler/Intel-C-FeatureTests.cmake
@@ -0,0 +1,23 @@
+# References:
+#   - https://software.intel.com/en-us/articles/iso-iec-standards-language-conformance-for-intel-c-compiler
+#   - https://software.intel.com/en-us/articles/c99-support-in-intel-c-compiler
+#   - https://software.intel.com/en-us/articles/c11-support-in-intel-c-compiler
+
+# FIXME: Intel C feature detection works only when simulating the GNU compiler.
+if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+  return()
+endif()
+
+set(DETECT_C99 "defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L")
+
+#static assert is only around in version 1500 update 2 and above
+set(_cmake_feature_test_c_static_assert "(__INTEL_COMPILER > 1500 || (__INTEL_COMPILER == 1500 && __INTEL_COMPILER_UPDATE > 1) ) && ${DETECT_C99}")
+
+set(_cmake_oldestSupported "__INTEL_COMPILER >= 1110")
+set(Intel_C99 "${_cmake_oldestSupported} && ${DETECT_C99}")
+set(_cmake_feature_test_c_restrict "${Intel_C99}")
+set(_cmake_feature_test_c_variadic_macros "${Intel_C99}")
+set(_cmake_feature_test_c_function_prototypes "${_cmake_oldestSupported}")
+unset(Intel_C99)
+
+unset(DETECT_C99)
diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake
index dfba4b2..eb9602a 100644
--- a/Modules/Compiler/Intel-C.cmake
+++ b/Modules/Compiler/Intel-C.cmake
@@ -6,7 +6,63 @@ set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
 set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
 
-set(CMAKE_DEPFILE_FLAGS_C "-MMD -MT <OBJECT> -MF <DEPFILE>")
+set(CMAKE_DEPFILE_FLAGS_C "-MD -MT <OBJECT> -MF <DEPFILE>")
+
+if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+  set(_std -Qstd)
+else()
+  set(_std -std)
+endif()
+
+if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
+  set(CMAKE_C11_STANDARD_COMPILE_OPTION "${_std}=c11")
+  set(CMAKE_C11_EXTENSION_COMPILE_OPTION "${_std}=c11")
+endif()
+
+if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
+  set(CMAKE_C90_STANDARD_COMPILE_OPTION "${_std}=c89")
+  set(CMAKE_C90_EXTENSION_COMPILE_OPTION "${_std}=c89")
+  set(CMAKE_C99_STANDARD_COMPILE_OPTION "${_std}=c99")
+  set(CMAKE_C99_EXTENSION_COMPILE_OPTION "${_std}=c99")
+endif()
+
+if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
+  if (NOT CMAKE_C_COMPILER_FORCED)
+    if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT)
+      message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
+    endif()
+    set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
+  elseif(NOT DEFINED CMAKE_C_STANDARD_DEFAULT)
+    # Compiler id was forced so just guess the default standard level.
+    if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
+      set(CMAKE_C_STANDARD_DEFAULT 11)
+    else()
+      set(CMAKE_C_STANDARD_DEFAULT 90)
+    endif()
+  endif()
+endif()
+
+unset(_std)
+
+macro(cmake_record_c_compile_features)
+  macro(_get_intel_c_features std_version list)
+    record_compiler_features(C "${std_version}" ${list})
+  endmacro()
+
+  set(_result 0)
+  if (NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
+      NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
+    if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
+      _get_intel_c_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_intel_c_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_intel_c_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES)
+    endif()
+  endif()
+endmacro()
 
 set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
 set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..e111c07
--- /dev/null
+++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
@@ -0,0 +1,96 @@
+# References:
+#   - https://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
+#   - https://software.intel.com/en-us/articles/c14-features-supported-by-intel-c-compiler
+
+# FIXME: Intel C++ feature detection works only when simulating the GNU compiler.
+# When simulating MSVC, Intel always sets __cplusplus to 199711L.
+if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+  return()
+endif()
+
+# these are not implemented in any version at time of writing
+#set(_cmake_feature_test_cxx_variable_templates "${Intel15_CXX14}")
+#set(_cmake_feature_test_cxx_relaxed_constexpr "${Intel15_CXX14}")
+
+set(_cmake_oldestSupported "__INTEL_COMPILER >= 1210")
+set(DETECT_CXX11 "((__cplusplus >= 201103L) || defined(__INTEL_CXX11_MODE__) || defined(__GXX_EXPERIMENTAL_CXX0X__))")
+#ICC version 15 update 1 has a bug where __cplusplus is defined as 1 no matter
+#if you are compiling as 98/11/14. So to properly detect C++14 with this version
+#we look for the existence of __GXX_EXPERIMENTAL_CXX0X__ but not __INTEL_CXX11_MODE__
+set(DETECT_BUGGY_ICC15 "((__INTEL_COMPILER == 1500) && (__INTEL_COMPILER_UPDATE == 1))")
+set(DETECT_CXX14 "((__cplusplus >= 201300L) || ((__cplusplus == 201103L) && !defined(__INTEL_CXX11_MODE__)) || ((${DETECT_BUGGY_ICC15}) && defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(__INTEL_CXX11_MODE__) ) )")
+
+set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}")
+set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}")
+set(_cmake_feature_test_cxx_contextual_conversions "${Intel16_CXX14}")
+set(_cmake_feature_test_cxx_generic_lambdas "${Intel16_CXX14}")
+set(_cmake_feature_test_cxx_digit_separators "${Intel16_CXX14}")
+# This test is supposed to work in Intel 14 but the compiler has a bug
+# in versions 14 and 15::
+# https://software.intel.com/en-us/forums/intel-c-compiler/topic/600514
+# It also appears to fail with an internal compiler error on Intel 16.
+#set(_cmake_feature_test_cxx_generalized_initializers "${Intel16_CXX14}")
+
+set(Intel15_CXX14 "__INTEL_COMPILER >= 1500 && ${DETECT_CXX14}")
+set(_cmake_feature_test_cxx_decltype_auto "${Intel15_CXX14}")
+set(_cmake_feature_test_cxx_lambda_init_captures "${Intel15_CXX14}")
+set(_cmake_feature_test_cxx_attribute_deprecated "${Intel15_CXX14}")
+set(_cmake_feature_test_cxx_return_type_deduction "${Intel15_CXX14}")
+
+set(Intel15_CXX11 "__INTEL_COMPILER >= 1500 && ${DETECT_CXX11}")
+set(_cmake_feature_test_cxx_alignas "${Intel15_CXX11}")
+set(_cmake_feature_test_cxx_alignof "${Intel15_CXX11}")
+set(_cmake_feature_test_cxx_inheriting_constructors "${Intel15_CXX11}")
+set(_cmake_feature_test_cxx_user_literals "${Intel15_CXX11}")
+set(_cmake_feature_test_cxx_thread_local "${Intel15_CXX11}")
+
+set(Intel14_CXX11 "${DETECT_CXX11} && (__INTEL_COMPILER > 1400 || (__INTEL_COMPILER == 1400 && __INTEL_COMPILER_UPDATE >= 2))")
+# Documented as 12.0+ but in testing it only works on 14.0.2+
+set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${Intel14_CXX11}")
+
+set(Intel14_CXX11 "__INTEL_COMPILER >= 1400 && ${DETECT_CXX11}")
+set(_cmake_feature_test_cxx_delegating_constructors "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_constexpr "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_sizeof_member "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_strong_enums "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_reference_qualified_functions "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_raw_string_literals "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_unicode_literals "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_inline_namespaces "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_unrestricted_unions "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_nonstatic_member_init "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_enum_forward_declarations "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_override "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_final "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_noexcept "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_move_initializers "${Intel14_CXX11}")
+
+set(Intel13_CXX11 "__INTEL_COMPILER >= 1300 && ${DETECT_CXX11}")
+set(_cmake_feature_test_cxx_explicit_conversions "${Intel13_CXX11}")
+set(_cmake_feature_test_cxx_range_for "${Intel13_CXX11}")
+# Cannot find Intel documentation for N2640: cxx_uniform_initialization
+set(_cmake_feature_test_cxx_uniform_initialization "${Intel13_CXX11}")
+
+set(Intel121_CXX11 "${_cmake_oldestSupported} && ${DETECT_CXX11}")
+set(_cmake_feature_test_cxx_variadic_templates "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_alias_templates "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_nullptr "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_trailing_return_types "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_attributes "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_default_function_template_args "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_extended_friend_declarations "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_rvalue_references "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_decltype "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_functions "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_deleted_functions "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_local_type_template_args "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_lambdas "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_binary_literals "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_static_assert "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_right_angle_brackets "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_auto_type "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_extern_templates "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_variadic_macros "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_long_long_type "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_func_identifier "${Intel121_CXX11}")
+set(_cmake_feature_test_cxx_template_template_parameters "${Intel121_CXX11}")
diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake
index 7947695..369e041 100644
--- a/Modules/Compiler/Intel-CXX.cmake
+++ b/Modules/Compiler/Intel-CXX.cmake
@@ -6,7 +6,71 @@ set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
 set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
 
-set(CMAKE_DEPFILE_FLAGS_CXX "-MMD -MT <OBJECT> -MF <DEPFILE>")
+set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT <OBJECT> -MF <DEPFILE>")
+
+if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+  set(_std -Qstd)
+else()
+  set(_std -std)
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.2)
+  set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "${_std}=c++14")
+  # todo: there is no gnu++14 value supported; figure out what to do
+  set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "${_std}=c++14")
+elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0)
+  set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "${_std}=c++1y")
+  # todo: there is no gnu++14 value supported; figure out what to do
+  set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "${_std}=c++1y")
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0)
+  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 12.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 12.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 12.1)
+  if (NOT CMAKE_CXX_COMPILER_FORCED)
+    if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT)
+      message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
+    else()
+      set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
+    endif()
+  elseif (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT)
+    # Compiler id was forced so just guess the default standard level.
+    set(CMAKE_CXX_STANDARD_DEFAULT 98)
+  endif()
+endif()
+
+unset(_std)
+
+macro(cmake_record_cxx_compile_features)
+  macro(_get_intel_features std_version list)
+    record_compiler_features(CXX "${std_version}" ${list})
+  endmacro()
+
+  set(_result 0)
+  if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" AND
+      NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
+    if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0)
+      _get_intel_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_intel_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_intel_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES)
+    endif()
+  endif()
+endmacro()
 
 set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
 set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
diff --git a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
index ad1d14b..79d5962 100644
--- a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
@@ -9,6 +9,10 @@
 
 set(_cmake_oldestSupported "_MSC_VER >= 1600")
 
+# VS 2015 Update 2 introduces support for variable templates.
+# https://www.visualstudio.com/en-us/news/vs2015-update2-vs.aspx
+set(_cmake_feature_test_cxx_variable_templates "_MSC_FULL_VER >= 190023918")
+
 set(MSVC_2015 "_MSC_VER >= 1900")
 set(_cmake_feature_test_cxx_alignas "${MSVC_2015}")
 set(_cmake_feature_test_cxx_alignof "${MSVC_2015}")
@@ -95,7 +99,6 @@ set(_cmake_feature_test_cxx_variadic_macros "${MSVC_2010}")
 # set(_cmake_feature_test_cxx_relaxed_constexpr )
 # 'NSDMIs for aggregates'
 # set(_cmake_feature_test_cxx_aggregate_default_initializers )
-# set(_cmake_feature_test_cxx_variable_templates )
 
 # In theory decltype incomplete return types was added in 2012
 # but without support for decltype_auto and return type deduction this
diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake
index 76477e4..f69c7bd 100644
--- a/Modules/Compiler/QCC.cmake
+++ b/Modules/Compiler/QCC.cmake
@@ -20,5 +20,5 @@ macro(__compiler_qcc lang)
   set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V")
 
   set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,")
-  set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MMD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>")
+  set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>")
 endmacro()
diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake
index 479666c..ebc79f4 100644
--- a/Modules/Compiler/TI-C.cmake
+++ b/Modules/Compiler/TI-C.cmake
@@ -7,4 +7,4 @@ set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> --preproc_only --c_fi
 
 set(CMAKE_C_COMPILE_OBJECT  "<CMAKE_C_COMPILER> --compile_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>")
 set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -r <TARGET> <OBJECTS>")
-set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_LIBRARIES> <LINK_FLAGS> <OBJECTS>")
+set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>")
diff --git a/Modules/CompilerId/VS-6.dsp.in b/Modules/CompilerId/VS-6.dsp.in
deleted file mode 100644
index 48c9a23..0000000
--- a/Modules/CompilerId/VS-6.dsp.in
+++ /dev/null
@@ -1,48 +0,0 @@
-# Microsoft Developer Studio Project File - Name="CompilerId at id_lang@" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=CompilerId at id_lang@ - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "CompilerId at id_lang@.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "CompilerId at id_lang@.mak" CFG="CompilerId at id_lang@ - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "CompilerId at id_lang@ - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-CPP=cl.exe
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "."
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD CPP /nologo /MDd /c
-LINK32=link.exe
-# ADD LINK32 /nologo /version:0.0 /subsystem:console /machine:x86 /out:"CompilerId at id_lang@.exe" /IGNORE:4089
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=for %%i in (@id_cl@) do @echo CMAKE_ at id_lang@_COMPILER=%%~$PATH:i
-# End Special Build Tool
-# Begin Target
-
-# Name "CompilerId at id_lang@ - Win32 Debug"
-# Begin Group "Source Files"
-
-# Begin Source File
-
-SOURCE="@id_src@"
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in
index 2da8354..0ff2eed 100644
--- a/Modules/DartConfiguration.tcl.in
+++ b/Modules/DartConfiguration.tcl.in
@@ -52,6 +52,7 @@ SVNUpdateOptions: @SVN_UPDATE_OPTIONS@
 
 # Git options
 GITCommand: @GITCOMMAND@
+GITInitSubmodules: @CTEST_GIT_INIT_SUBMODULES@
 GITUpdateOptions: @GIT_UPDATE_OPTIONS@
 GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@
 
diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in
new file mode 100644
index 0000000..5b73cd8
--- /dev/null
+++ b/Modules/ExternalProject-download.cmake.in
@@ -0,0 +1,161 @@
+#=============================================================================
+# Copyright 2008-2013 Kitware, Inc.
+# Copyright 2016 Ruslan Baratov
+#
+# 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.)
+
+cmake_minimum_required(VERSION 3.5)
+
+function(check_file_hash has_hash hash_is_good)
+  if("${has_hash}" STREQUAL "")
+    message(FATAL_ERROR "has_hash Can't be empty")
+  endif()
+
+  if("${hash_is_good}" STREQUAL "")
+    message(FATAL_ERROR "hash_is_good Can't be empty")
+  endif()
+
+  if("@ALGO@" STREQUAL "")
+    # No check
+    set("${has_hash}" FALSE PARENT_SCOPE)
+    set("${hash_is_good}" FALSE PARENT_SCOPE)
+    return()
+  endif()
+
+  set("${has_hash}" TRUE PARENT_SCOPE)
+
+  message(STATUS "verifying file...
+       file='@LOCAL@'")
+
+  file("@ALGO@" "@LOCAL@" actual_value)
+
+  if(NOT "${actual_value}" STREQUAL "@EXPECT_VALUE@")
+    set("${hash_is_good}" FALSE PARENT_SCOPE)
+    message(STATUS "@ALGO@ hash of
+    @LOCAL@
+  does not match expected value
+    expected: '@EXPECT_VALUE@'
+      actual: '${actual_value}'")
+  else()
+    set("${hash_is_good}" TRUE PARENT_SCOPE)
+  endif()
+endfunction()
+
+function(sleep_before_download attempt)
+  if(attempt EQUAL 0)
+    return()
+  endif()
+
+  if(attempt EQUAL 1)
+    message(STATUS "Retrying...")
+    return()
+  endif()
+
+  set(sleep_seconds 0)
+
+  if(attempt EQUAL 2)
+    set(sleep_seconds 5)
+  elseif(attempt EQUAL 3)
+    set(sleep_seconds 5)
+  elseif(attempt EQUAL 4)
+    set(sleep_seconds 15)
+  elseif(attempt EQUAL 5)
+    set(sleep_seconds 60)
+  elseif(attempt EQUAL 6)
+    set(sleep_seconds 90)
+  elseif(attempt EQUAL 7)
+    set(sleep_seconds 300)
+  else()
+    set(sleep_seconds 1200)
+  endif()
+
+  message(STATUS "Retry after ${sleep_seconds} seconds (attempt #${attempt}) ...")
+
+  execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep "${sleep_seconds}")
+endfunction()
+
+if("@LOCAL@" STREQUAL "")
+  message(FATAL_ERROR "LOCAL can't be empty")
+endif()
+
+if("@REMOTE@" STREQUAL "")
+  message(FATAL_ERROR "REMOTE can't be empty")
+endif()
+
+if(EXISTS "@LOCAL@")
+  check_file_hash(has_hash hash_is_good)
+  if(has_hash)
+    if(hash_is_good)
+      message(STATUS "File already exists and hash match (skip download):
+  file='@LOCAL@'
+  @ALGO@='@EXPECT_VALUE@'"
+      )
+      return()
+    else()
+      message(STATUS "File already exists but hash mismatch. Removing...")
+      file(REMOVE "@LOCAL@")
+    endif()
+  else()
+    message(STATUS "File already exists but no hash specified (use URL_HASH):
+  file='@LOCAL@'
+Old file will be removed and new file downloaded from URL."
+    )
+    file(REMOVE "@LOCAL@")
+  endif()
+endif()
+
+set(retry_number 5)
+
+foreach(i RANGE ${retry_number})
+  sleep_before_download(${i})
+
+  message(STATUS "downloading...
+       src='@REMOTE@'
+       dst='@LOCAL@'
+       timeout='@TIMEOUT_MSG@'")
+
+  @TLS_VERIFY_CODE@
+  @TLS_CAINFO_CODE@
+
+  file(
+      DOWNLOAD
+      "@REMOTE@" "@LOCAL@"
+      @SHOW_PROGRESS@
+      @TIMEOUT_ARGS@
+      STATUS status
+      LOG log
+  )
+
+  list(GET status 0 status_code)
+  list(GET status 1 status_string)
+
+  if(status_code EQUAL 0)
+    check_file_hash(has_hash hash_is_good)
+    if(has_hash AND NOT hash_is_good)
+      message(STATUS "Hash mismatch, removing...")
+      file(REMOVE "@LOCAL@")
+    else()
+      message(STATUS "Downloading... done")
+      return()
+    endif()
+  else()
+    message("error: downloading '@REMOTE@' failed
+  status_code: ${status_code}
+  status_string: ${status_string}
+  log:
+  --- LOG BEGIN ---
+  ${log}
+  --- LOG END ---"
+    )
+  endif()
+endforeach()
+
+message(FATAL_ERROR "Downloading failed")
diff --git a/Modules/ExternalProject-verify.cmake.in b/Modules/ExternalProject-verify.cmake.in
new file mode 100644
index 0000000..1d8db96
--- /dev/null
+++ b/Modules/ExternalProject-verify.cmake.in
@@ -0,0 +1,48 @@
+#=============================================================================
+# Copyright 2008-2013 Kitware, Inc.
+# Copyright 2016 Ruslan Baratov
+#
+# 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.)
+
+cmake_minimum_required(VERSION 3.5)
+
+if("@LOCAL@" STREQUAL "")
+  message(FATAL_ERROR "LOCAL can't be empty")
+endif()
+
+if(NOT EXISTS "@LOCAL@")
+  message(FATAL_ERROR "File not found: @LOCAL@")
+endif()
+
+if("@ALGO@" STREQUAL "")
+  message(WARNING "File will not be verified since no URL_HASH specified")
+  return()
+endif()
+
+if("@EXPECT_VALUE@" STREQUAL "")
+  message(FATAL_ERROR "EXPECT_VALUE can't be empty")
+endif()
+
+message(STATUS "verifying file...
+     file='@LOCAL@'")
+
+file("@ALGO@" "@LOCAL@" actual_value)
+
+if(NOT "${actual_value}" STREQUAL "@EXPECT_VALUE@")
+  message(FATAL_ERROR "error: @ALGO@ hash of
+  @LOCAL@
+does not match expected value
+  expected: '@EXPECT_VALUE@'
+    actual: '${actual_value}'
+")
+endif()
+
+message(STATUS "verifying file... done")
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 249658d..2ff18fc 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -61,6 +61,10 @@ Create custom targets to build projects in external trees
     The optional name of the remote, default to ``origin``
   ``GIT_SUBMODULES <module>...``
     Git submodules that shall be updated, all if empty
+  ``GIT_SHALLOW 1``
+    Tell Git to clone with ``--depth 1``.   Use when ``GIT_TAG`` is not
+    specified or when it names a branch in order to download only the
+    tip of the branch without the rest of its history.
   ``HG_REPOSITORY <url>``
     URL of mercurial repo
   ``HG_TAG <tag>``
@@ -77,6 +81,9 @@ Create custom targets to build projects in external trees
     Path to a certificate authority file
   ``TIMEOUT <seconds>``
     Time allowed for file download operations
+  ``DOWNLOAD_NO_EXTRACT 1``
+    Just download the file and do not extract it; the full path to the
+    downloaded file is available as ``<DOWNLOADED_FILE>``.
 
   Update/Patch step options are:
 
@@ -113,7 +120,7 @@ Create custom targets to build projects in external trees
   ``CMAKE_CACHE_ARGS <arg>...``
     Initial cache arguments, of the form ``-Dvar:string=on``.
     These arguments are written in a pre-load a script that populates
-    CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows to
+    CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows one to
     overcome command line length limits.
     These arguments are :command:`set` using the ``FORCE`` argument,
     and therefore cannot be changed by the user.
@@ -122,7 +129,7 @@ Create custom targets to build projects in external trees
   ``CMAKE_CACHE_DEFAULT_ARGS <arg>...``
     Initial default cache arguments, of the form ``-Dvar:string=on``.
     These arguments are written in a pre-load a script that populates
-    CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows to
+    CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows one to
     overcome command line length limits.
     These arguments can be used as default value that will be set if no
     previous value is found in the cache, and that the user can change
@@ -238,7 +245,7 @@ Create custom targets to build projects in external trees
   If ``UPDATE_DISCONNECTED`` is set, the update step is not executed
   automatically when building the main target. The update step can still
   be added as a step target and called manually. This is useful if you
-  want to allow to build the project when you are disconnected from the
+  want to allow one to build the project when you are disconnected from the
   network (you might still need the network for the download step).
   This is disabled by default.
   The directory property ``EP_UPDATE_DISCONNECTED`` can be used to change
@@ -370,6 +377,7 @@ file::
 
 #=============================================================================
 # Copyright 2008-2013 Kitware, Inc.
+# Copyright 2016 Ruslan Baratov
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -411,6 +419,9 @@ endif()
 set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512")
 set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$")
 
+set(_ExternalProject_SELF "${CMAKE_CURRENT_LIST_FILE}")
+get_filename_component(_ExternalProject_SELF_DIR "${_ExternalProject_SELF}" PATH)
+
 function(_ep_parse_arguments f name ns args)
   # Transfer the arguments to this function into target properties for the
   # new custom target we just added so that we can set up all the build steps
@@ -496,7 +507,12 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
   "ExternalProject module."
   )
 
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules src_name work_dir gitclone_infofile gitclone_stampfile)
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+  if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
+    set(git_clone_shallow_options "--depth 1 --no-single-branch")
+  else()
+    set(git_clone_shallow_options "--depth 1")
+  endif()
   file(WRITE ${script_filename}
 "if(\"${git_tag}\" STREQUAL \"\")
   message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
@@ -521,12 +537,28 @@ if(error_code)
   message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
 endif()
 
+set(git_options)
+
+# disable cert checking if explicitly told not to do it
+set(tls_verify \"${tls_verify}\")
+if(NOT \"x${tls_verify}\" STREQUAL \"x\" AND NOT tls_verify)
+  list(APPEND git_options
+    -c http.sslVerify=false)
+endif()
+
+set(git_clone_options)
+
+set(git_shallow \"${git_shallow}\")
+if(git_shallow)
+  list(APPEND git_clone_options ${git_clone_shallow_options})
+endif()
+
 # try the clone 3 times incase there is an odd git clone issue
 set(error_code 1)
 set(number_of_tries 0)
 while(error_code AND number_of_tries LESS 3)
   execute_process(
-    COMMAND \"${git_EXECUTABLE}\" clone --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
+    COMMAND \"${git_EXECUTABLE}\" \${git_options} clone \${git_clone_options} --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
     WORKING_DIRECTORY \"${work_dir}\"
     RESULT_VARIABLE error_code
     )
@@ -541,7 +573,7 @@ if(error_code)
 endif()
 
 execute_process(
-  COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
+  COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag}
   WORKING_DIRECTORY \"${work_dir}/${src_name}\"
   RESULT_VARIABLE error_code
   )
@@ -550,7 +582,7 @@ if(error_code)
 endif()
 
 execute_process(
-  COMMAND \"${git_EXECUTABLE}\" submodule init ${git_submodules}
+  COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule init ${git_submodules}
   WORKING_DIRECTORY \"${work_dir}/${src_name}\"
   RESULT_VARIABLE error_code
   )
@@ -559,7 +591,7 @@ if(error_code)
 endif()
 
 execute_process(
-  COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules}
+  COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule update --recursive --init ${git_submodules}
   WORKING_DIRECTORY \"${work_dir}/${src_name}\"
   RESULT_VARIABLE error_code
   )
@@ -805,7 +837,7 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
   endif()
 
   execute_process(
-    COMMAND \"${git_EXECUTABLE}\" submodule update --recursive ${git_submodules}
+    COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
     WORKING_DIRECTORY \"${work_dir}/${src_name}\"
     RESULT_VARIABLE error_code
     )
@@ -819,40 +851,38 @@ endif()
 
 endfunction(_ep_write_gitupdate_script)
 
-function(_ep_write_downloadfile_script script_filename remote local timeout no_progress 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")
+    set(TIMEOUT_ARGS TIMEOUT ${timeout})
+    set(TIMEOUT_MSG "${timeout} seconds")
   else()
-    set(timeout_args "# no TIMEOUT")
-    set(timeout_msg "none")
+    set(TIMEOUT_ARGS "# no TIMEOUT")
+    set(TIMEOUT_MSG "none")
   endif()
 
   if(no_progress)
-    set(show_progress "")
+    set(SHOW_PROGRESS "")
   else()
-    set(show_progress "SHOW_PROGRESS")
+    set(SHOW_PROGRESS "SHOW_PROGRESS")
   endif()
 
   if("${hash}" MATCHES "${_ep_hash_regex}")
-    string(CONCAT hash_check
-      "if(EXISTS \"${local}\")\n"
-      "  file(\"${CMAKE_MATCH_1}\" \"${local}\" hash_value)\n"
-      "  if(\"x\${hash_value}\" STREQUAL \"x${CMAKE_MATCH_2}\")\n"
-      "    return()\n"
-      "  endif()\n"
-      "endif()\n"
-      )
+    set(ALGO "${CMAKE_MATCH_1}")
+    set(EXPECT_VALUE "${CMAKE_MATCH_2}")
   else()
-    set(hash_check "")
+    set(ALGO "")
+    set(EXPECT_VALUE "")
   endif()
 
+  set(TLS_VERIFY_CODE "")
+  set(TLS_CAINFO_CODE "")
+
   # check for curl globals in the project
   if(DEFINED CMAKE_TLS_VERIFY)
-    set(tls_verify "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})")
+    set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})")
   endif()
   if(DEFINED CMAKE_TLS_CAINFO)
-    set(tls_cainfo "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")")
+    set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")")
   endif()
 
   # now check for curl locals so that the local values
@@ -861,91 +891,49 @@ function(_ep_write_downloadfile_script script_filename remote local timeout no_p
   # check for tls_verify argument
   string(LENGTH "${tls_verify}" tls_verify_len)
   if(tls_verify_len GREATER 0)
-    set(tls_verify "set(CMAKE_TLS_VERIFY ${tls_verify})")
+    set(TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${tls_verify})")
   endif()
   # check for tls_cainfo argument
   string(LENGTH "${tls_cainfo}" tls_cainfo_len)
   if(tls_cainfo_len GREATER 0)
-    set(tls_cainfo "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
-  endif()
-
-  file(WRITE ${script_filename}
-"${hash_check}message(STATUS \"downloading...
-     src='${remote}'
-     dst='${local}'
-     timeout='${timeout_msg}'\")
-
-${tls_verify}
-${tls_cainfo}
-
-file(DOWNLOAD
-  \"${remote}\"
-  \"${local}\"
-  ${show_progress}
-  ${timeout_args}
-  STATUS status
-  LOG log)
-
-list(GET status 0 status_code)
-list(GET status 1 status_string)
-
-if(NOT status_code EQUAL 0)
-  message(FATAL_ERROR \"error: downloading '${remote}' failed
-  status_code: \${status_code}
-  status_string: \${status_string}
-  log: \${log}
-\")
-endif()
-
-message(STATUS \"downloading... done\")
-"
-)
-
+    set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
+  endif()
+
+  # Used variables:
+  # * TLS_VERIFY_CODE
+  # * TLS_CAINFO_CODE
+  # * ALGO
+  # * EXPECT_VALUE
+  # * REMOTE
+  # * LOCAL
+  # * SHOW_PROGRESS
+  # * TIMEOUT_ARGS
+  # * TIMEOUT_MSG
+  configure_file(
+      "${_ExternalProject_SELF_DIR}/ExternalProject-download.cmake.in"
+      "${script_filename}"
+      @ONLY
+  )
 endfunction()
 
-
-function(_ep_write_verifyfile_script script_filename local hash retries download_script)
+function(_ep_write_verifyfile_script script_filename LOCAL hash)
   if("${hash}" MATCHES "${_ep_hash_regex}")
-    set(algo "${CMAKE_MATCH_1}")
-    string(TOLOWER "${CMAKE_MATCH_2}" expect_value)
-    set(script_content "set(expect_value \"${expect_value}\")
-set(attempt 0)
-set(succeeded 0)
-while(\${attempt} LESS ${retries} OR \${attempt} EQUAL ${retries} AND NOT \${succeeded})
-  file(${algo} \"\${file}\" actual_value)
-  if(\"\${actual_value}\" STREQUAL \"\${expect_value}\")
-    set(succeeded 1)
-  elseif(\${attempt} LESS ${retries})
-    message(STATUS \"${algo} hash of \${file}
-does not match expected value
-  expected: \${expect_value}
-    actual: \${actual_value}
-Retrying download.
-\")
-    file(REMOVE \"\${file}\")
-    execute_process(COMMAND \${CMAKE_COMMAND} -P \"${download_script}\")
-  endif()
-  math(EXPR attempt \"\${attempt} + 1\")
-endwhile()
-
-if(\${succeeded})
-  message(STATUS \"verifying file... done\")
-else()
-  message(FATAL_ERROR \"error: ${algo} hash of
-  \${file}
-does not match expected value
-  expected: \${expect_value}
-    actual: \${actual_value}
-\")
-endif()")
+    set(ALGO "${CMAKE_MATCH_1}")
+    string(TOLOWER "${CMAKE_MATCH_2}" EXPECT_VALUE)
   else()
-    set(script_content "message(STATUS \"verifying file... warning: did not verify file - no URL_HASH specified?\")")
+    set(ALGO "")
+    set(EXPECT_VALUE "")
   endif()
-  file(WRITE ${script_filename} "set(file \"${local}\")
-message(STATUS \"verifying file...
-     file='\${file}'\")
-${script_content}
-")
+
+  # Used variables:
+  # * ALGO
+  # * EXPECT_VALUE
+  # * LOCAL
+  configure_file(
+      "${_ExternalProject_SELF_DIR}/ExternalProject-verify.cmake.in"
+      "${script_filename}"
+      @ONLY
+  )
 endfunction()
 
 
@@ -1107,7 +1095,7 @@ macro(_ep_replace_location_tags target_name)
   set(vars ${ARGN})
   foreach(var ${vars})
     if(${var})
-      foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR)
+      foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOADED_FILE)
         get_property(val TARGET ${target_name} PROPERTY _EP_${dir})
         string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
       endforeach()
@@ -1774,6 +1762,12 @@ function(_ep_add_download_command name)
       set(git_remote_name "origin")
     endif()
 
+    get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
+    if("x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY)
+      set(tls_verify "${CMAKE_TLS_VERIFY}")
+    endif()
+    get_property(git_shallow TARGET ${name} PROPERTY _EP_GIT_SHALLOW)
+
     # For the download step, and the git clone operation, only the repository
     # should be recorded in a configured RepositoryInfo file. If the repo
     # changes, the clone script should be run again. But if only the tag
@@ -1797,8 +1791,8 @@ function(_ep_add_download_command name)
     # The script will delete the source directory and then call git clone.
     #
     _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
-      ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" ${src_name} ${work_dir}
-      ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt
+      ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" ${src_name} ${work_dir}
+      ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
       )
     set(comment "Performing download step (git clone) for '${name}'")
     set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake)
@@ -1861,8 +1855,6 @@ function(_ep_add_download_command name)
     set(repository "external project URL")
     set(module "${url}")
     set(tag "${hash}")
-    set(retries 0)
-    set(download_script "")
     configure_file(
       "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
       "${stamp_dir}/${name}-urlinfo.txt"
@@ -1875,6 +1867,7 @@ function(_ep_add_download_command name)
       set(cmd   ${CMAKE_COMMAND} -E remove_directory ${source_dir}
         COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir})
     else()
+      get_property(no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT SET)
       if("${url}" MATCHES "^[a-z]+://")
         # TODO: Should download and extraction be different steps?
         if("x${fname}" STREQUAL "x")
@@ -1884,7 +1877,9 @@ function(_ep_add_download_command name)
           string(REGEX MATCH "([^/\\?]+(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip))/.*$" match_result "${url}")
           set(fname "${CMAKE_MATCH_1}")
         endif()
-        if(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
+        if (no_extract)
+          get_filename_component(fname "${url}" NAME)
+        elseif(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
           message(FATAL_ERROR "Could not extract tarball filename from url:\n  ${url}")
         endif()
         string(REPLACE ";" "-" fname "${fname}")
@@ -1897,17 +1892,31 @@ function(_ep_add_download_command name)
         _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)
-        set(comment "Performing download step (download, verify and extract) for '${name}'")
+        if (no_extract)
+          set(steps "download and verify")
+        else ()
+          set(steps "download, verify and extract")
+        endif ()
+        set(comment "Performing download step (${steps}) for '${name}'")
+        file(WRITE "${stamp_dir}/verify-${name}.cmake" "") # already verified by 'download_script'
       else()
         set(file "${url}")
-        set(comment "Performing download step (verify and extract) for '${name}'")
+        if (no_extract)
+          set(steps "verify")
+        else ()
+          set(steps "verify and extract")
+        endif ()
+        set(comment "Performing download step (${steps}) for '${name}'")
+        _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}")
       endif()
-      _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}" "${retries}" "${download_script}")
       list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake
         COMMAND)
-      _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
-      list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
+      if (NOT no_extract)
+        _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
+        list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
+      else ()
+        set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file})
+      endif ()
     endif()
   else()
     _ep_is_dir_empty("${source_dir}" empty)
@@ -1976,6 +1985,9 @@ function(_ep_add_update_command name)
 
   if(cmd_set)
     set(work_dir ${source_dir})
+    if(NOT "x${cmd}" STREQUAL "x")
+      set(always 1)
+    endif()
   elseif(cvs_repository)
     if(NOT CVS_EXECUTABLE)
       message(FATAL_ERROR "error: could not find cvs for update of ${name}")
@@ -2009,6 +2021,8 @@ function(_ep_add_update_command name)
       --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args})
     set(always 1)
   elseif(git_repository)
+    unset(CMAKE_MODULE_PATH) # Use CMake builtin find module
+    find_package(Git QUIET)
     if(NOT GIT_EXECUTABLE)
       message(FATAL_ERROR "error: could not find git for fetch of ${name}")
     endif()
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index 7d81276..69293f5 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -125,10 +125,10 @@ if(BISON_EXECUTABLE)
     get_filename_component(BISON_TARGET_output_path "${BisonOutput}" PATH)
     get_filename_component(BISON_TARGET_output_name "${BisonOutput}" NAME_WE)
     add_custom_command(OUTPUT ${filename}
-      COMMAND ${CMAKE_COMMAND}
-      ARGS -E copy
+      COMMAND ${CMAKE_COMMAND} -E copy
       "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
       "${filename}"
+      VERBATIM
       DEPENDS
       "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
       COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
@@ -201,8 +201,8 @@ if(BISON_EXECUTABLE)
 
       add_custom_command(OUTPUT ${BISON_TARGET_outputs}
         ${BISON_TARGET_extraoutputs}
-        COMMAND ${BISON_EXECUTABLE}
-        ARGS ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput}
+        COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput}
+        VERBATIM
         DEPENDS ${BisonInput}
         COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}"
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 416b666..728494c 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -30,9 +30,9 @@
 #   BLA_F95     if set on tries to find the f95 interfaces for BLAS/LAPACK
 #
 # ######### ## List of vendors (BLA_VENDOR) valid in this module #
-# Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32
-# (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread
-# model, lp64 model), # Intel10_64lp_seq (intel mkl v10 64
+# Goto,OpenBLAS,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,
+# Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,
+# lp thread model, lp64 model), # Intel10_64lp_seq (intel mkl v10 64
 # bit,sequential code, lp64 model), # Intel( older versions of mkl 32
 # and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic C/CXX should be
 # enabled to use Intel mkl
@@ -59,12 +59,7 @@ set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
 set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
 
 # Check the language being used
-get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES )
-if( _LANGUAGES_ MATCHES Fortran )
-  set( _CHECK_FORTRAN TRUE )
-elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) )
-  set( _CHECK_FORTRAN FALSE )
-else()
+if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED) )
   if(BLAS_FIND_REQUIRED)
     message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
   else()
@@ -132,7 +127,7 @@ if(_libraries_work)
   # Test this combination of libraries.
   set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
 #  message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
-  if (_CHECK_FORTRAN)
+  if (CMAKE_Fortran_COMPILER_LOADED)
     check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
   else()
     check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
@@ -172,6 +167,20 @@ if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
  endif()
 endif ()
 
+if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
+ if(NOT BLAS_LIBRARIES)
+  # OpenBLAS (http://www.openblas.net)
+  check_fortran_libraries(
+  BLAS_LIBRARIES
+  BLAS
+  sgemm
+  ""
+  "openblas"
+  ""
+  )
+ endif()
+endif ()
+
 if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
  if(NOT BLAS_LIBRARIES)
   # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
@@ -469,7 +478,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
  if (NOT WIN32)
   set(LM "-lm")
  endif ()
- if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
+ if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
   if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
     find_package(Threads)
   else()
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 728dcdf..67d71d0 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -310,7 +310,7 @@ macro(_Boost_ADJUST_LIB_VARS basename)
       set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} )
     endif()
 
-    if(Boost_${basename}_LIBRARY)
+    if(Boost_${basename}_LIBRARY AND Boost_${basename}_HEADER)
       set(Boost_${basename}_FOUND ON)
     endif()
 
@@ -464,6 +464,8 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
     set(_boost_COMPILER "-bcb")
   elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
     set(_boost_COMPILER "-sw")
+  elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL")
+    set(_boost_COMPILER "-xlc")
   elseif (MINGW)
     if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
         set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
@@ -520,7 +522,9 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
   #
   # The output may be added in a new block below.  If it's the same as
   # the previous release, simply update the version range of the block
-  # for the previous release.
+  # for the previous release.  Also check if any new components have
+  # been added, and add any new components to
+  # _Boost_COMPONENT_HEADERS.
   #
   # This information was originally generated by running
   # BoostScanDeps.cmake against every boost release to date supported
@@ -707,7 +711,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
     set(_Boost_TIMER_DEPENDENCIES chrono system)
     set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
     set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
-  elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106200)
+  elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100)
     set(_Boost_CHRONO_DEPENDENCIES system)
     set(_Boost_COROUTINE_DEPENDENCIES context system)
     set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -721,6 +725,20 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
     set(_Boost_TIMER_DEPENDENCIES chrono system)
     set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
     set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+  elseif(NOT Boost_VERSION VERSION_LESS 106100 AND Boost_VERSION VERSION_LESS 106200)
+    set(_Boost_CHRONO_DEPENDENCIES system)
+    set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
+    set(_Boost_COROUTINE_DEPENDENCIES context system)
+    set(_Boost_FILESYSTEM_DEPENDENCIES system)
+    set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+    set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
+    set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
+    set(_Boost_MPI_DEPENDENCIES serialization)
+    set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+    set(_Boost_RANDOM_DEPENDENCIES system)
+    set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
+    set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
+    set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
   else()
     message(WARNING "Imported targets not available for Boost version ${Boost_VERSION}")
     set(_Boost_IMPORTED_TARGETS FALSE)
@@ -738,6 +756,67 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
 endfunction()
 
 #
+# Get component headers.  This is the primary header (or headers) for
+# a given component, and is used to check that the headers are present
+# as well as the library itself as an extra sanity check of the build
+# environment.
+#
+# component - the component to check
+# _hdrs
+#
+function(_Boost_COMPONENT_HEADERS component _hdrs)
+  # Note: new boost components will require adding here.  The header
+  # must be present in all versions of Boost providing a library.
+  set(_Boost_ATOMIC_HEADERS              "boost/atomic.hpp")
+  set(_Boost_CHRONO_HEADERS              "boost/chrono.hpp")
+  set(_Boost_CONTAINER_HEADERS           "boost/container/container_fwd.hpp")
+  set(_Boost_CONTEXT_HEADERS             "boost/context/all.hpp")
+  set(_Boost_COROUTINE_HEADERS           "boost/coroutine/all.hpp")
+  set(_Boost_EXCEPTION_HEADERS           "boost/exception/exception.hpp")
+  set(_Boost_DATE_TIME_HEADERS           "boost/date_time/date.hpp")
+  set(_Boost_FILESYSTEM_HEADERS          "boost/filesystem/path.hpp")
+  set(_Boost_GRAPH_HEADERS               "boost/graph/adjacency_list.hpp")
+  set(_Boost_GRAPH_PARALLEL_HEADERS      "boost/graph/adjacency_list.hpp")
+  set(_Boost_IOSTREAMS_HEADERS           "boost/iostreams/stream.hpp")
+  set(_Boost_LOCALE_HEADERS              "boost/locale.hpp")
+  set(_Boost_LOG_HEADERS                 "boost/log/core.hpp")
+  set(_Boost_LOG_SETUP_HEADERS           "boost/log/detail/setup_config.hpp")
+  set(_Boost_MATH_HEADERS                "boost/math_fwd.hpp")
+  set(_Boost_MATH_C99_HEADERS            "boost/math/tr1.hpp")
+  set(_Boost_MATH_C99F_HEADERS           "boost/math/tr1.hpp")
+  set(_Boost_MATH_C99L_HEADERS           "boost/math/tr1.hpp")
+  set(_Boost_MATH_TR1_HEADERS            "boost/math/tr1.hpp")
+  set(_Boost_MATH_TR1F_HEADERS           "boost/math/tr1.hpp")
+  set(_Boost_MATH_TR1L_HEADERS           "boost/math/tr1.hpp")
+  set(_Boost_MPI_HEADERS                 "boost/mpi.hpp")
+  set(_Boost_MPI_PYTHON_HEADERS          "boost/mpi/python/config.hpp")
+  set(_Boost_PRG_EXEC_MONITOR_HEADERS    "boost/test/prg_exec_monitor.hpp")
+  set(_Boost_PROGRAM_OPTIONS_HEADERS     "boost/program_options.hpp")
+  set(_Boost_PYTHON_HEADERS              "boost/python.hpp")
+  set(_Boost_RANDOM_HEADERS              "boost/random.hpp")
+  set(_Boost_REGEX_HEADERS               "boost/regex.hpp")
+  set(_Boost_SERIALIZATION_HEADERS       "boost/serialization/serialization.hpp")
+  set(_Boost_SIGNALS_HEADERS             "boost/signals.hpp")
+  set(_Boost_SYSTEM_HEADERS              "boost/system/config.hpp")
+  set(_Boost_TEST_EXEC_MONITOR_HEADERS   "boost/test/test_exec_monitor.hpp")
+  set(_Boost_THREAD_HEADERS              "boost/thread.hpp")
+  set(_Boost_TIMER_HEADERS               "boost/timer.hpp")
+  set(_Boost_TYPE_ERASURE_HEADERS        "boost/type_erasure/config.hpp")
+  set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp")
+  set(_Boost_WAVE_HEADERS                "boost/wave.hpp")
+  set(_Boost_WSERIALIZATION_HEADERS      "boost/archive/text_wiarchive.hpp")
+
+  string(TOUPPER ${component} uppercomponent)
+  set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE)
+
+  string(REGEX REPLACE ";" " " _boost_HDRS_STRING "${_Boost_${uppercomponent}_HEADERS}")
+  if (NOT _boost_HDRS_STRING)
+    set(_boost_HDRS_STRING "(none)")
+  endif()
+  # message(STATUS "Headers for Boost::${component}: ${_boost_HDRS_STRING}")
+endfunction()
+
+#
 # Determine if any missing dependencies require adding to the component list.
 #
 # Sets _Boost_${COMPONENT}_DEPENDENCIES for each required component,
@@ -824,8 +903,9 @@ else()
   # versions, find those that are acceptable to the user request.
   #
   # Note: When adding a new Boost release, also update the dependency
-  # information in _Boost_COMPONENT_DEPENDENCIES.  See the
-  # instructions at the top of _Boost_COMPONENT_DEPENDENCIES.
+  # information in _Boost_COMPONENT_DEPENDENCIES and
+  # _Boost_COMPONENT_HEADERS.  See the instructions at the top of
+  # _Boost_COMPONENT_DEPENDENCIES.
   set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
     "1.61.0" "1.61" "1.60.0" "1.60"
     "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
@@ -980,7 +1060,7 @@ if(NOT Boost_INCLUDE_DIR)
   endif()
 
   if( Boost_NO_SYSTEM_PATHS)
-    list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH)
+    list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
   else()
     list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS
       C:/boost/include
@@ -1249,7 +1329,7 @@ foreach(c DEBUG RELEASE)
       ${Boost_INCLUDE_DIR}/stage/lib
       )
     if( Boost_NO_SYSTEM_PATHS )
-      list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH)
+      list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
     else()
       list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} PATHS
         C:/boost/lib
@@ -1364,6 +1444,22 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
   endif()
 
   #
+  # Find headers
+  #
+  _Boost_COMPONENT_HEADERS("${COMPONENT}" Boost_${UPPERCOMPONENT}_HEADER_NAME)
+  # Look for a standard boost header file.
+  if(Boost_${UPPERCOMPONENT}_HEADER_NAME)
+    if(EXISTS "${Boost_INCLUDE_DIR}/${Boost_${UPPERCOMPONENT}_HEADER_NAME}")
+      set(Boost_${UPPERCOMPONENT}_HEADER ON)
+    else()
+      set(Boost_${UPPERCOMPONENT}_HEADER OFF)
+    endif()
+  else()
+    set(Boost_${UPPERCOMPONENT}_HEADER ON)
+    message(WARNING "No header defined for ${COMPONENT}; skipping header check")
+  endif()
+
+  #
   # Find RELEASE libraries
   #
   set(_boost_RELEASE_NAMES
@@ -1571,7 +1667,7 @@ endif()
 #  Add imported targets
 # ------------------------------------------------------------------------
 
-if(Boost_FOUND AND _Boost_IMPORTED_TARGETS)
+if(Boost_FOUND)
   # For header-only libraries
   if(NOT TARGET Boost::boost)
     add_library(Boost::boost INTERFACE IMPORTED)
@@ -1582,7 +1678,7 @@ if(Boost_FOUND AND _Boost_IMPORTED_TARGETS)
   endif()
 
   foreach(COMPONENT ${Boost_FIND_COMPONENTS})
-    if(NOT TARGET Boost::${COMPONENT})
+    if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT})
       string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
       if(Boost_${UPPERCOMPONENT}_FOUND)
         if(Boost_USE_STATIC_LIBS)
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index fe8b18e..48bb554 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -81,7 +81,7 @@
 #      --compiler-bindir is already present in the CUDA_NVCC_FLAGS or
 #      CUDA_NVCC_FLAGS_<CONFIG> variables.  For Visual Studio targets
 #      $(VCInstallDir)/bin is a special value that expands out to the path when
-#      the command is run from withing VS.
+#      the command is run from within VS.
 #
 #   CUDA_NVCC_FLAGS
 #   CUDA_NVCC_FLAGS_<CONFIG>
@@ -215,7 +215,7 @@
 #      The arguments passed in after OPTIONS are extra command line options to
 #      give to nvcc.  You can also specify per configuration options by
 #      specifying the name of the configuration followed by the options.  General
-#      options must preceed configuration specific options.  Not all
+#      options must precede configuration specific options.  Not all
 #      configurations need to be specified, only the ones provided will be used.
 #
 #         OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag"
@@ -264,6 +264,7 @@
 #   CUDA_VERSION_MINOR    -- The minor version.
 #   CUDA_VERSION
 #   CUDA_VERSION_STRING   -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR
+#   CUDA_HAS_FP16         -- Whether a short float (float16,fp16) is supported.
 #
 #   CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set).
 #   CUDA_SDK_ROOT_DIR     -- Path to the CUDA SDK.  Use this to find files in the
@@ -548,6 +549,7 @@ macro(cuda_unset_include_and_libraries)
   endif()
   unset(CUDA_cudart_static_LIBRARY CACHE)
   unset(CUDA_cublas_LIBRARY CACHE)
+  unset(CUDA_cublas_device_LIBRARY CACHE)
   unset(CUDA_cublasemu_LIBRARY CACHE)
   unset(CUDA_cufft_LIBRARY CACHE)
   unset(CUDA_cufftemu_LIBRARY CACHE)
@@ -683,6 +685,12 @@ find_path(CUDA_TOOLKIT_INCLUDE
 find_path(CUDA_TOOLKIT_INCLUDE device_functions.h)
 mark_as_advanced(CUDA_TOOLKIT_INCLUDE)
 
+if (CUDA_VERSION VERSION_GREATER "7.0" OR EXISTS "${CUDA_TOOLKIT_INCLUDE}/cuda_fp16.h")
+  set(CUDA_HAS_FP16 TRUE)
+else()
+  set(CUDA_HAS_FP16 FALSE)
+endif()
+
 # Set the user list of include dir to nothing to initialize it.
 set (CUDA_NVCC_INCLUDE_ARGS_USER "")
 set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE})
@@ -847,6 +855,7 @@ if(NOT CUDA_VERSION VERSION_LESS "3.2")
   endif()
 endif()
 if(CUDA_VERSION VERSION_GREATER "5.0")
+  find_cuda_helper_libs(cublas_device)
   # In CUDA 5.5 NPP was splitted onto 3 separate libraries.
   find_cuda_helper_libs(nppc)
   find_cuda_helper_libs(nppi)
@@ -865,7 +874,7 @@ if (CUDA_BUILD_EMULATION)
   set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublasemu_LIBRARY})
 else()
   set(CUDA_CUFFT_LIBRARIES ${CUDA_cufft_LIBRARY})
-  set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY})
+  set(CUDA_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY})
 endif()
 
 ########################
@@ -1388,7 +1397,8 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
       set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend")
       set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend")
       set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt")
-      set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake")
+      set(custom_target_script_pregen "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake.pre-gen")
+      set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}$<$<BOOL:$<CONFIG>>:.$<CONFIG>>.cmake")
 
       # Setup properties for obj files:
       if( NOT cuda_compile_to_external_module )
@@ -1429,7 +1439,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
       endif()
 
       # Configure the build script
-      configure_file("${CUDA_run_nvcc}" "${custom_target_script}" @ONLY)
+      configure_file("${CUDA_run_nvcc}" "${custom_target_script_pregen}" @ONLY)
+      file(GENERATE
+        OUTPUT "${custom_target_script}"
+        INPUT "${custom_target_script_pregen}"
+        )
 
       # So if a user specifies the same cuda file as input more than once, you
       # can have bad things happen with dependencies.  Here we check an option
@@ -1791,7 +1805,7 @@ macro(CUDA_ADD_CUBLAS_TO_TARGET target)
   if (CUDA_BUILD_EMULATION)
     target_link_libraries(${target} ${CUDA_cublasemu_LIBRARY})
   else()
-    target_link_libraries(${target} ${CUDA_cublas_LIBRARY})
+    target_link_libraries(${target} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY})
   endif()
 endmacro()
 
diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake
index c433fa8..802f93a 100644
--- a/Modules/FindCUDA/make2cmake.cmake
+++ b/Modules/FindCUDA/make2cmake.cmake
@@ -35,6 +35,16 @@
 # This converts a file written in makefile syntax into one that can be included
 # by CMake.
 
+# Input variables
+#
+# verbose:BOOL=<>          OFF: Be as quiet as possible (default)
+#                          ON : Extra output
+#
+# input_file:FILEPATH=<>   Path to dependecy file in makefile format
+#
+# output_file:FILEPATH=<>  Path to file with dependencies in CMake readable variable
+#
+
 file(READ ${input_file} depend_text)
 
 if (NOT "${depend_text}" STREQUAL "")
@@ -62,12 +72,16 @@ if (NOT "${depend_text}" STREQUAL "")
       if (EXISTS "/${file}")
         set(file "/${file}")
       else()
-        message(WARNING " Removing non-existent dependency file: ${file}")
+        if(verbose)
+          message(WARNING " Removing non-existent dependency file: ${file}")
+        endif()
         set(file "")
       endif()
     endif()
 
-    if(NOT IS_DIRECTORY "${file}")
+    # Make sure we check to see if we have a file, before asking if it is not a directory.
+    # if(NOT IS_DIRECTORY "") will return TRUE.
+    if(file AND NOT IS_DIRECTORY "${file}")
       # If softlinks start to matter, we should change this to REALPATH.  For now we need
       # to flatten paths, because nvcc can generate stuff like /bin/../include instead of
       # just /include.
diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake
index 8032309..12b83e0 100644
--- a/Modules/FindCUDA/run_nvcc.cmake
+++ b/Modules/FindCUDA/run_nvcc.cmake
@@ -207,6 +207,7 @@ cuda_execute_process(
   COMMAND "${CMAKE_COMMAND}"
   -D "input_file:FILEPATH=${NVCC_generated_dependency_file}"
   -D "output_file:FILEPATH=${cmake_dependency_file}.tmp"
+  -D "verbose=${verbose}"
   -P "${CUDA_make2cmake}"
   )
 
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index ca66493..b50c74a 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -185,8 +185,8 @@ if(FLEX_EXECUTABLE)
       endif()
 
       add_custom_command(OUTPUT ${FLEX_TARGET_outputs}
-        COMMAND ${FLEX_EXECUTABLE}
-        ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+        COMMAND ${FLEX_EXECUTABLE} ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+        VERBATIM
         DEPENDS ${Input}
         COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index ca49e4a..a7ffcfe 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -82,8 +82,7 @@
 #   ``AUTO`` to find them from executable target
 #
 # However, note that this macro will slow down your tests by running
-# an executable for each test and test fixture.  You will also have to
-# re-run CMake after adding or removing tests or test fixtures.
+# an executable for each test and test fixture.
 #
 # Example usage::
 #
@@ -119,6 +118,7 @@ function(GTEST_ADD_TESTS executable extra_args)
     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})
+        set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
         file(READ "${source}" contents)
         string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
         foreach(hit ${found_tests})
diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index d18f965..95188ce 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -45,8 +45,10 @@ if(WIN32)
   if(NOT CMAKE_GENERATOR MATCHES "MSYS")
     set(git_names git.cmd git eg.cmd eg)
     # GitHub search path for Windows
-    set(github_path "$ENV{LOCALAPPDATA}/Github/PortableGit*/bin")
-    file(GLOB github_path "${github_path}")
+    file(GLOB github_path
+      "$ENV{LOCALAPPDATA}/Github/PortableGit*/cmd"
+      "$ENV{LOCALAPPDATA}/Github/PortableGit*/bin"
+      )
     # SourceTree search path for Windows
     set(_git_sourcetree_path "$ENV{LOCALAPPDATA}/Atlassian/SourceTree/git_local/bin")
   endif()
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 9f6e666..b074f63 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -46,24 +46,47 @@
 #
 # ::
 #
+#   HDF5_FOUND - true if HDF5 was found on the system
+#   HDF5_VERSION - HDF5 version in format Major.Minor.Release
 #   HDF5_INCLUDE_DIRS - Location of the hdf5 includes
 #   HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated)
 #   HDF5_DEFINITIONS - Required compiler definitions for HDF5
-#   HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings.
+#   HDF5_LIBRARIES - Required libraries for all requested bindings
+#   HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all
+#                       bindings, if the HL component is enabled
+#
+# Available components are: C CXX Fortran and HL.  For each enabled language
+# binding, a corresponding HDF5_${LANG}_LIBRARIES variable will be defined.
+# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will
+# also be defined.  With all components enabled, the following variables will be defined:
+#
+# ::
+#
+#   HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings
 #   HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings
 #   HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings
-#   HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API
+#   HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings
+#   HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings
 #   HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran
 #                               bindings.
-#   HDF5_LIBRARIES - Required libraries for all requested bindings
-#   HDF5_FOUND - true if HDF5 was found on the system
-#   HDF5_VERSION - HDF5 version in format Major.Minor.Release
-#   HDF5_LIBRARY_DIRS - the full set of library directories
+#
 #   HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support
 #   HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler
 #   HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler
 #   HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler
+#   HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler
+#                                               which is also the HDF5 wrapper
+#   HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++
+#                                                 compiler which is also
+#                                                 the HDF5 wrapper
+#   HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary
+#                                                     Fortran compiler which
+#                                                     is also the HDF5 wrapper
 #   HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool
+#
+# The following variable can be set to guide the search for HDF5 libraries and includes:
+#
+# HDF5_ROOT
 
 #=============================================================================
 # Copyright 2015 Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf
@@ -85,28 +108,43 @@ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
 # List of the valid HDF5 components
-set( HDF5_VALID_COMPONENTS
-    C
-    CXX
-    Fortran
-    HL
-    Fortran_HL
-)
+set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran)
 
 # Validate the list of find components.
-if( NOT HDF5_FIND_COMPONENTS )
-    set( HDF5_LANGUAGE_BINDINGS "C" )
+set(HDF5_LANGUAGE_BINDINGS)
+if(NOT HDF5_FIND_COMPONENTS)
+  get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES)
+  foreach(__lang IN LISTS __langs)
+    if(__lang MATCHES "^(C|CXX|Fortran)$")
+      list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang})
+    endif()
+  endforeach()
+  set(FIND_HL ON)
 else()
-    # add the extra specified components, ensuring that they are valid.
-    foreach( component ${HDF5_FIND_COMPONENTS} )
-        list( FIND HDF5_VALID_COMPONENTS ${component} component_location )
-        if( ${component_location} EQUAL -1 )
-            message( FATAL_ERROR
-                "\"${component}\" is not a valid HDF5 component." )
-        else()
-            list( APPEND HDF5_LANGUAGE_BINDINGS ${component} )
-        endif()
+  # add the extra specified components, ensuring that they are valid.
+  set(FIND_HL OFF)
+  foreach(component IN LISTS HDF5_FIND_COMPONENTS)
+    list(FIND HDF5_VALID_LANGUAGE_BINDINGS ${component} component_location)
+    if(NOT component_location EQUAL -1)
+      list(APPEND HDF5_LANGUAGE_BINDINGS ${component})
+    elseif(component STREQUAL "HL")
+      set(FIND_HL ON)
+    elseif(component STREQUAL "Fortran_HL") # only for compatibility
+      list(APPEND HDF5_LANGUAGE_BINDINGS Fortran)
+      set(FIND_HL ON)
+    else()
+      message(FATAL_ERROR "${component} is not a valid HDF5 component.")
+    endif()
+  endforeach()
+  if(NOT HDF5_LANGUAGE_BINDINGS)
+    get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES)
+    foreach(__lang IN LISTS __langs)
+      if(__lang MATCHES "^(C|CXX|Fortran)$")
+        list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang})
+      endif()
     endforeach()
+  endif()
+  list(REMOVE_DUPLICATES HDF5_LANGUAGE_BINDINGS)
 endif()
 
 # Determine whether to search for serial or parallel executable first
@@ -120,54 +158,137 @@ else()
   set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc)
 endif()
 
-# try to find the HDF5 wrapper compilers
-find_program( HDF5_C_COMPILER_EXECUTABLE
-    NAMES ${HDF5_C_COMPILER_NAMES} NAMES_PER_DIR
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 Wrapper compiler.  Used only to detect HDF5 compile flags." )
-mark_as_advanced( HDF5_C_COMPILER_EXECUTABLE )
-
-find_program( HDF5_CXX_COMPILER_EXECUTABLE
-    NAMES ${HDF5_CXX_COMPILER_NAMES} NAMES_PER_DIR
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 C++ Wrapper compiler.  Used only to detect HDF5 compile flags." )
-mark_as_advanced( HDF5_CXX_COMPILER_EXECUTABLE )
-
-find_program( HDF5_Fortran_COMPILER_EXECUTABLE
-    NAMES ${HDF5_Fortran_COMPILER_NAMES} NAMES_PER_DIR
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 Fortran Wrapper compiler.  Used only to detect HDF5 compile flags." )
-mark_as_advanced( HDF5_Fortran_COMPILER_EXECUTABLE )
+# We may have picked up some duplicates in various lists during the above
+# process for the language bindings (both the C and C++ bindings depend on
+# libz for example).  Remove the duplicates. It appears that the default
+# CMake behavior is to remove duplicates from the end of a list. However,
+# for link lines, this is incorrect since unresolved symbols are searched
+# for down the link line. Therefore, we reverse the list, remove the
+# duplicates, and then reverse it again to get the duplicates removed from
+# the beginning.
+macro(_HDF5_remove_duplicates_from_beginning _list_name)
+  if(${_list_name})
+    list(REVERSE ${_list_name})
+    list(REMOVE_DUPLICATES ${_list_name})
+    list(REVERSE ${_list_name})
+  endif()
+endmacro()
 
-unset(HDF5_C_COMPILER_NAMES)
-unset(HDF5_CXX_COMPILER_NAMES)
-unset(HDF5_Fortran_COMPILER_NAMES)
 
-find_program( HDF5_DIFF_EXECUTABLE
-    NAMES h5diff
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 file differencing tool." )
-mark_as_advanced( HDF5_DIFF_EXECUTABLE )
+# Test first if the current compilers automatically wrap HDF5
+
+function(_HDF5_test_regular_compiler_C success version)
+  set(scratch_directory
+    ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5)
+  if(NOT ${success} OR
+     NOT EXISTS ${scratch_directory}/compiler_has_h5_c)
+    set(test_file ${scratch_directory}/cmake_hdf5_test.c)
+    file(WRITE ${test_file}
+      "#include <hdf5.h>\n"
+      "#include <hdf5_hl.h>\n"
+      "int main(void) {\n"
+      "  char const* info_ver = \"INFO\" \":\" H5_VERSION;\n"
+      "  hid_t fid;\n"
+      "  fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n"
+      "  return 0;\n"
+      "}")
+    try_compile(${success} ${scratch_directory} ${test_file}
+      COPY_FILE ${scratch_directory}/compiler_has_h5_c
+    )
+  endif()
+  if(${success})
+    file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_VER
+      REGEX "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
+    )
+    string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
+      INFO_VER "${INFO_VER}"
+    )
+    set(${version} ${CMAKE_MATCH_1})
+    if(CMAKE_MATCH_3)
+      set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3})
+    endif()
+    set(${version} ${${version}} PARENT_SCOPE)
+  endif()
+endfunction()
+
+function(_HDF5_test_regular_compiler_CXX success version)
+  set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5)
+  if(NOT ${success} OR
+     NOT EXISTS ${scratch_directory}/compiler_has_h5_cxx)
+    set(test_file ${scratch_directory}/cmake_hdf5_test.cxx)
+    file(WRITE ${test_file}
+      "#include <H5Cpp.h>\n"
+      "#ifndef H5_NO_NAMESPACE\n"
+      "using namespace H5;\n"
+      "#endif\n"
+      "int main(int argc, char **argv) {\n"
+      "  char const* info_ver = \"INFO\" \":\" H5_VERSION;\n"
+      "  H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n"
+      "  return 0;\n"
+      "}")
+    try_compile(${success} ${scratch_directory} ${test_file}
+      COPY_FILE ${scratch_directory}/compiler_has_h5_cxx
+    )
+  endif()
+  if(${success})
+    file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_VER
+      REGEX "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
+    )
+    string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
+      INFO_VER "${INFO_VER}"
+    )
+    set(${version} ${CMAKE_MATCH_1})
+    if(CMAKE_MATCH_3)
+      set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3})
+    endif()
+    set(${version} ${${version}} PARENT_SCOPE)
+  endif()
+endfunction()
+
+function(_HDF5_test_regular_compiler_Fortran success)
+  if(NOT ${success})
+    set(scratch_directory
+      ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5)
+    set(test_file ${scratch_directory}/cmake_hdf5_test.f90)
+    file(WRITE ${test_file}
+      "program hdf5_hello\n"
+      "  use hdf5\n"
+      "  use h5lt\n"
+      "  use h5ds\n"
+      "  integer error\n"
+      "  call h5open_f(error)\n"
+      "  call h5close_f(error)\n"
+      "end\n")
+    try_compile(${success} ${scratch_directory} ${test_file})
+  endif()
+endfunction()
 
 # Invoke the HDF5 wrapper compiler.  The compiler return value is stored to the
 # return_value argument, the text output is stored to the output variable.
-macro( _HDF5_invoke_compiler language output return_value )
-    if( HDF5_${language}_COMPILER_EXECUTABLE )
-        exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE}
-            ARGS -show
-            OUTPUT_VARIABLE ${output}
-            RETURN_VALUE ${return_value}
-        )
-        if( ${${return_value}} EQUAL 0 )
-            # do nothing
-        else()
-            message( STATUS
-              "Unable to determine HDF5 ${language} flags from HDF5 wrapper." )
-        endif()
+macro( _HDF5_invoke_compiler language output return_value version)
+    set(${version})
+    exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE}
+        ARGS -show
+        OUTPUT_VARIABLE ${output}
+        RETURN_VALUE ${return_value}
+    )
+    if(NOT ${${return_value}} EQUAL 0)
+        message(STATUS
+          "Unable to determine HDF5 ${language} flags from HDF5 wrapper.")
+    endif()
+    exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE}
+        ARGS -showconfig
+        OUTPUT_VARIABLE config_output
+        RETURN_VALUE config_return
+    )
+    if(NOT ${return_value} EQUAL 0)
+        message( STATUS
+          "Unable to determine HDF5 ${language} version from HDF5 wrapper.")
+    endif()
+    string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}")
+    if(version_match)
+        string(REPLACE "HDF5 Version: " "" ${version} "${version_match}")
+        string(REPLACE "-patch" "." ${version} "${${version}}")
     endif()
 endmacro()
 
@@ -177,7 +298,8 @@ macro( _HDF5_parse_compile_line
     include_paths
     definitions
     library_paths
-    libraries )
+    libraries
+    libraries_hl)
 
     # Match the include paths
     string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags
@@ -214,148 +336,322 @@ macro( _HDF5_parse_compile_line
     # strip the -l from all of the library flags and add to the search list
     foreach( LIB ${library_name_flags} )
         string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} )
-        list( APPEND ${libraries} ${LIB} )
+        if(LIB MATCHES ".*_hl")
+            list(APPEND ${libraries_hl} ${LIB})
+        else()
+            list(APPEND ${libraries} ${LIB})
+        endif()
     endforeach()
 endmacro()
 
 # Try to find HDF5 using an installed hdf5-config.cmake
-if( NOT HDF5_FOUND )
-    find_package( HDF5 QUIET NO_MODULE )
-    if( HDF5_FOUND )
-        set( HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} )
-        set( HDF5_LIBRARIES )
-        set( HDF5_C_TARGET hdf5 )
-        set( HDF5_CXX_TARGET hdf5_cpp )
-        set( HDF5_HL_TARGET hdf5_hl )
-        set( HDF5_Fortran_TARGET hdf5_fortran )
-        set( HDF5_Fortran_HL_TARGET hdf5_hl_fortran )
-        foreach( _component ${HDF5_LANGUAGE_BINDINGS} )
-            list( FIND HDF5_VALID_COMPONENTS ${_component} _component_location )
-            get_target_property( _comp_location ${HDF5_${_component}_TARGET} LOCATION )
-            if( _comp_location )
-                set( HDF5_${_component}_LIBRARY ${_comp_location} CACHE PATH
-                    "HDF5 ${_component} library" )
-                mark_as_advanced( HDF5_${_component}_LIBRARY )
-                list( APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY} )
+if(NOT HDF5_FOUND AND NOT HDF5_ROOT)
+    find_package(HDF5 QUIET NO_MODULE)
+    if( HDF5_FOUND)
+        set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR})
+        set(HDF5_LIBRARIES)
+        set(HDF5_C_TARGET hdf5)
+        set(HDF5_C_HL_TARGET hdf5_hl)
+        set(HDF5_CXX_TARGET hdf5_cpp)
+        set(HDF5_CXX_HL_TARGET hdf5_hl_cpp)
+        set(HDF5_Fortran_TARGET hdf5_fortran)
+        set(HDF5_Fortran_HL_TARGET hdf5_hl_fortran)
+        if(HDF5_USE_STATIC_LIBRARIES)
+            set(_suffix "-static")
+        else()
+            set(_suffix "-shared")
+        endif()
+        foreach(_lang ${HDF5_LANGUAGE_BINDINGS})
+
+            #Older versions of hdf5 don't have a static/shared suffix so
+            #if we detect that occurrence clear the suffix
+            if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix})
+              if(NOT TARGET ${HDF5_${_lang}_TARGET})
+                #cant find this component with our without the suffix
+                #so bail out, and let the following locate HDF5
+                set(HDF5_FOUND FALSE)
+                break()
+              endif()
+              set(_suffix "")
+            endif()
+
+            get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION)
+            if( _lang_location )
+                set(HDF5_${_lang}_LIBRARY ${_lang_location} CACHE PATH
+                    "HDF5 ${_lang} library" )
+                mark_as_advanced(HDF5_${_lang}_LIBRARY)
+                list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_LIBRARY})
+                set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_LIBRARY})
+            endif()
+            if(FIND_HL)
+                get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION)
+                if( _lang_hl_location )
+                    set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location} CACHE PATH
+                        "HDF5 ${_lang} HL library" )
+                    mark_as_advanced(HDF5_${_lang}_HL_LIBRARY)
+                    list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_LIBRARY})
+                    set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_HL_LIBRARY})
+                endif()
             endif()
         endforeach()
     endif()
 endif()
 
-if( NOT HDF5_FOUND )
-    _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE )
-    _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE )
-    _HDF5_invoke_compiler( Fortran HDF5_Fortran_COMPILE_LINE HDF5_Fortran_RETURN_VALUE )
-    set(HDF5_HL_COMPILE_LINE ${HDF5_C_COMPILE_LINE})
-    set(HDF5_Fortran_HL_COMPILE_LINE ${HDF5_Fortran_COMPILE_LINE})
+if(NOT HDF5_FOUND AND NOT HDF5_ROOT)
+  set(_HDF5_NEED_TO_SEARCH False)
+  set(HDF5_COMPILER_NO_INTERROGATE True)
+  # Only search for languages we've enabled
+  foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS)
+    # First check to see if our regular compiler is one of wrappers
+    if(__lang STREQUAL "C")
+      _HDF5_test_regular_compiler_C(
+        HDF5_${__lang}_COMPILER_NO_INTERROGATE
+        HDF5_${__lang}_VERSION)
+    elseif(__lang STREQUAL "CXX")
+      _HDF5_test_regular_compiler_CXX(
+        HDF5_${__lang}_COMPILER_NO_INTERROGATE
+        HDF5_${__lang}_VERSION)
+    elseif(__lang STREQUAL "Fortran")
+      _HDF5_test_regular_compiler_Fortran(
+        HDF5_${__lang}_COMPILER_NO_INTERROGATE)
+    else()
+      continue()
+    endif()
+    if(HDF5_${__lang}_COMPILER_NO_INTERROGATE)
+      message(STATUS "HDF5: Using hdf5 compiler wrapper for all ${__lang} compiling")
+      set(HDF5_${__lang}_FOUND True)
+      set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE
+          "${CMAKE_${__lang}_COMPILER}"
+          CACHE FILEPATH "HDF5 ${__lang} compiler wrapper")
+      set(HDF5_${__lang}_DEFINITIONS)
+      set(HDF5_${__lang}_INCLUDE_DIRS)
+      set(HDF5_${__lang}_LIBRARIES)
+      set(HDF5_${__lang}_HL_LIBRARIES)
+
+      mark_as_advanced(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE)
+      mark_as_advanced(HDF5_${__lang}_DEFINITIONS)
+      mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS)
+      mark_as_advanced(HDF5_${__lang}_LIBRARIES)
+      mark_as_advanced(HDF5_${__lang}_HL_LIBRARIES)
+    else()
+      set(HDF5_COMPILER_NO_INTERROGATE False)
+      # If this language isn't using the wrapper, then try to seed the
+      # search options with the wrapper
+      find_program(HDF5_${__lang}_COMPILER_EXECUTABLE
+        NAMES ${HDF5_${__lang}_COMPILER_NAMES} NAMES_PER_DIR
+        HINTS ENV HDF5_ROOT
+        PATH_SUFFIXES bin Bin
+        DOC "HDF5 ${__lang} Wrapper compiler.  Used only to detect HDF5 compile flags."
+      )
+      mark_as_advanced( HDF5_${__lang}_COMPILER_EXECUTABLE )
+      unset(HDF5_${__lang}_COMPILER_NAMES)
+
+      if(HDF5_${__lang}_COMPILER_EXECUTABLE)
+        _HDF5_invoke_compiler(${__lang} HDF5_${__lang}_COMPILE_LINE
+          HDF5_${__lang}_RETURN_VALUE HDF5_${__lang}_VERSION)
+        if(HDF5_${__lang}_RETURN_VALUE EQUAL 0)
+          message(STATUS "HDF5: Using hdf5 compiler wrapper to determine ${__lang} configuration")
+          _HDF5_parse_compile_line( HDF5_${__lang}_COMPILE_LINE
+            HDF5_${__lang}_INCLUDE_DIRS
+            HDF5_${__lang}_DEFINITIONS
+            HDF5_${__lang}_LIBRARY_DIRS
+            HDF5_${__lang}_LIBRARY_NAMES
+            HDF5_${__lang}_HL_LIBRARY_NAMES
+          )
+          set(HDF5_${__lang}_LIBRARIES)
+          foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES)
+            find_library(HDF5_${__lang}_LIBRARY_${L} ${L} ${HDF5_${__lang}_LIBRARY_DIRS})
+            if(HDF5_${__lang}_LIBRARY_${L})
+              list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}})
+            else()
+              list(APPEND HDF5_${__lang}_LIBRARIES ${L})
+            endif()
+          endforeach()
+          if(FIND_HL)
+            set(HDF5_${__lang}_HL_LIBRARIES)
+            foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES)
+              find_library(HDF5_${__lang}_LIBRARY_${L} ${L} ${HDF5_${__lang}_LIBRARY_DIRS})
+              if(HDF5_${__lang}_LIBRARY_${L})
+                list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}})
+              else()
+                list(APPEND HDF5_${__lang}_HL_LIBRARIES ${L})
+              endif()
+            endforeach()
+          endif()
+          set(HDF5_${__lang}_FOUND True)
+          mark_as_advanced(HDF5_${__lang}_DEFINITIONS)
+          mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS)
+          mark_as_advanced(HDF5_${__lang}_LIBRARIES)
+          _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS)
+          _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS)
+          _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES)
+          _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_HL_LIBRARIES)
+        else()
+          set(_HDF5_NEED_TO_SEARCH True)
+        endif()
+      else()
+        set(_HDF5_NEED_TO_SEARCH True)
+      endif()
+    endif()
+    if(HDF5_${__lang}_VERSION)
+      if(NOT HDF5_VERSION)
+        set(HDF5_VERSION ${HDF5_${__lang}_VERSION})
+      elseif(NOT HDF5_VERSION VERSION_EQUAL HDF5_${__lang}_VERSION)
+        message(WARNING "HDF5 Version found for language ${__lang}, ${HDF5_${__lang}_VERSION} is different than previously found version ${HDF5_VERSION}")
+      endif()
+    endif()
+  endforeach()
+else()
+  set(_HDF5_NEED_TO_SEARCH True)
+endif()
+
+if(NOT HDF5_FOUND AND HDF5_COMPILER_NO_INTERROGATE)
+  # No arguments necessary, all languages can use the compiler wrappers
+  set(HDF5_FOUND True)
+  set(HDF5_METHOD "Included by compiler wrappers")
+  set(HDF5_REQUIRED_VARS HDF5_METHOD)
+elseif(NOT HDF5_FOUND AND NOT _HDF5_NEED_TO_SEARCH)
+  # Compiler wrappers aren't being used by the build but were found and used
+  # to determine necessary include and library flags
+  set(HDF5_INCLUDE_DIRS)
+  set(HDF5_LIBRARIES)
+  set(HDF5_HL_LIBRARIES)
+  foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS)
+    if(HDF5_${__lang}_FOUND)
+      if(NOT HDF5_${__lang}_COMPILER_NO_INTERROGATE)
+        list(APPEND HDF5_DEFINITIONS ${HDF5_${__lang}_DEFINITIONS})
+        list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIRS})
+        list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES})
+        if(FIND_HL)
+          list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES})
+        endif()
+      endif()
+    endif()
+  endforeach()
+  _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS)
+  _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS)
+  _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES)
+  _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES)
+  set(HDF5_FOUND True)
+  set(HDF5_REQUIRED_VARS HDF5_LIBRARIES)
+  if(FIND_HL)
+    list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES)
+  endif()
+endif()
+
+find_program( HDF5_DIFF_EXECUTABLE
+    NAMES h5diff
+    HINTS ENV HDF5_ROOT
+    PATH_SUFFIXES bin Bin
+    DOC "HDF5 file differencing tool." )
+mark_as_advanced( HDF5_DIFF_EXECUTABLE )
 
+if( NOT HDF5_FOUND )
     # seed the initial lists of libraries to find with items we know we need
-    set( HDF5_C_LIBRARY_NAMES_INIT hdf5 )
-    set( HDF5_HL_LIBRARY_NAMES_INIT hdf5_hl ${HDF5_C_LIBRARY_NAMES_INIT} )
-    set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} )
-    set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran
-        ${HDF5_C_LIBRARY_NAMES_INIT} )
-    set( HDF5_Fortran_HL_LIBRARY_NAMES_INIT hdf5hl_fortran hdf5_hl
-        ${HDF5_Fortran_LIBRARY_NAMES_INIT} )
-
-    foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} )
-        if( HDF5_${LANGUAGE}_COMPILE_LINE )
-            _HDF5_parse_compile_line( HDF5_${LANGUAGE}_COMPILE_LINE
-                HDF5_${LANGUAGE}_INCLUDE_FLAGS
-                HDF5_${LANGUAGE}_DEFINITIONS
-                HDF5_${LANGUAGE}_LIBRARY_DIRS
-                HDF5_${LANGUAGE}_LIBRARY_NAMES
-            )
+    set(HDF5_C_LIBRARY_NAMES          hdf5)
+    set(HDF5_C_HL_LIBRARY_NAMES       hdf5_hl)
 
-            # take a guess that the includes may be in the 'include' sibling
-            # directory of a library directory.
-            foreach( dir ${HDF5_${LANGUAGE}_LIBRARY_DIRS} )
-                list( APPEND HDF5_${LANGUAGE}_INCLUDE_FLAGS ${dir}/../include )
-            endforeach()
-        endif()
+    set(HDF5_CXX_LIBRARY_NAMES        hdf5_cpp    ${HDF5_C_LIBRARY_NAMES})
+    set(HDF5_CXX_HL_LIBRARY_NAMES     hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES})
 
-        # set the definitions for the language bindings.
-        list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} )
+    set(HDF5_Fortran_LIBRARY_NAMES    hdf5_fortran   ${HDF5_C_LIBRARY_NAMES})
+    set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5_hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES})
 
+    if(HDF5_ROOT)
+        set(SEARCH_OPTS NO_DEFAULT_PATH)
+    endif()
+    foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS)
         # find the HDF5 include directories
-        if(${LANGUAGE} MATCHES "Fortran")
+        if(LANGUAGE STREQUAL "Fortran")
             set(HDF5_INCLUDE_FILENAME hdf5.mod)
+        elseif(LANGUAGE STREQUAL "CXX")
+            set(HDF5_INCLUDE_FILENAME H5Cpp.h)
         else()
             set(HDF5_INCLUDE_FILENAME hdf5.h)
         endif()
 
-        find_path( HDF5_${LANGUAGE}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME}
-            HINTS
-                ${HDF5_${LANGUAGE}_INCLUDE_FLAGS}
-                ENV
-                    HDF5_ROOT
-            PATHS
-                $ENV{HOME}/.local/include
-            PATH_SUFFIXES
-                include
-                Include
+        find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME}
+            HINTS ${HDF5_ROOT} ENV HDF5_ROOT
+            PATHS $ENV{HOME}/.local/include
+            PATH_SUFFIXES include Include
+            ${SEARCH_OPTS}
         )
-        mark_as_advanced( HDF5_${LANGUAGE}_INCLUDE_DIR )
-        list( APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR} )
-
-        set( HDF5_${LANGUAGE}_LIBRARY_NAMES
-            ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT}
-            ${HDF5_${LANGUAGE}_LIBRARY_NAMES} )
+        mark_as_advanced(HDF5_${LANGUAGE}_INCLUDE_DIR)
+        list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR})
 
         # find the HDF5 libraries
-        foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES} )
-            if( UNIX AND HDF5_USE_STATIC_LIBRARIES )
+        foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES)
+            if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
                 # According to bug 1643 on the CMake bug tracker, this is the
                 # preferred method for searching for a static library.
                 # See https://cmake.org/Bug/view.php?id=1643.  We search
                 # first for the full static library name, but fall back to a
                 # generic search on the name if the static search fails.
-                set( THIS_LIBRARY_SEARCH_DEBUG lib${LIB}d.a ${LIB}d )
-                set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} )
+                set( THIS_LIBRARY_SEARCH_DEBUG
+                    lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug
+                    lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_debug-static )
+                set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a ${LIB}-static)
             else()
-                set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d )
-                set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} )
+                set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ${LIB}d-shared ${LIB}_debug-shared)
+                set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared)
             endif()
-            find_library( HDF5_${LIB}_LIBRARY_DEBUG
+            find_library(HDF5_${LIB}_LIBRARY_DEBUG
                 NAMES ${THIS_LIBRARY_SEARCH_DEBUG}
-                HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS}
-                ENV HDF5_ROOT
-                PATH_SUFFIXES lib Lib )
+                HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib
+                ${SEARCH_OPTS}
+            )
             find_library( HDF5_${LIB}_LIBRARY_RELEASE
                 NAMES ${THIS_LIBRARY_SEARCH_RELEASE}
-                HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS}
-                ENV HDF5_ROOT
-                PATH_SUFFIXES lib Lib )
+                HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib
+                ${SEARCH_OPTS}
+            )
             select_library_configurations( HDF5_${LIB} )
-            list(APPEND HDF5_${LANGUAGE}_LIBRARIES ${HDF5_${LIB}_LIBRARY})
-        endforeach()
-        list( APPEND HDF5_LIBRARY_DIRS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} )
+            list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY})
+        eNdforeach()
 
         # Append the libraries for this language binding to the list of all
         # required libraries.
-        list(APPEND HDF5_LIBRARIES ${HDF5_${LANGUAGE}_LIBRARIES})
-    endforeach()
+        list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES})
+
+        if(FIND_HL)
+            foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES)
+                if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
+                    # According to bug 1643 on the CMake bug tracker, this is the
+                    # preferred method for searching for a static library.
+                    # See https://cmake.org/Bug/view.php?id=1643.  We search
+                    # first for the full static library name, but fall back to a
+                    # generic search on the name if the static search fails.
+                    set( THIS_LIBRARY_SEARCH_DEBUG
+                        lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug
+                        lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_debug-static )
+                    set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a ${LIB}-static)
+                else()
+                    set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ${LIB}d-shared ${LIB}_debug-shared)
+                    set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared)
+                endif()
+                find_library(HDF5_${LIB}_LIBRARY_DEBUG
+                    NAMES ${THIS_LIBRARY_SEARCH_DEBUG}
+                    HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib
+                    ${SEARCH_OPTS}
+                )
+                find_library( HDF5_${LIB}_LIBRARY_RELEASE
+                    NAMES ${THIS_LIBRARY_SEARCH_RELEASE}
+                    HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib
+                    ${SEARCH_OPTS}
+                )
+                select_library_configurations( HDF5_${LIB} )
+                list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY})
+            endforeach()
 
-    # We may have picked up some duplicates in various lists during the above
-    # process for the language bindings (both the C and C++ bindings depend on
-    # libz for example).  Remove the duplicates. It appears that the default
-    # CMake behavior is to remove duplicates from the end of a list. However,
-    # for link lines, this is incorrect since unresolved symbols are searched
-    # for down the link line. Therefore, we reverse the list, remove the
-    # duplicates, and then reverse it again to get the duplicates removed from
-    # the beginning.
-    macro( _remove_duplicates_from_beginning _list_name )
-        list( REVERSE ${_list_name} )
-        list( REMOVE_DUPLICATES ${_list_name} )
-        list( REVERSE ${_list_name} )
-    endmacro()
+            # Append the libraries for this language binding to the list of all
+            # required libraries.
+            list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES})
+        endif()
+    endforeach()
 
-    if( HDF5_INCLUDE_DIRS )
-        _remove_duplicates_from_beginning( HDF5_INCLUDE_DIRS )
-    endif()
-    if( HDF5_LIBRARY_DIRS )
-        _remove_duplicates_from_beginning( HDF5_LIBRARY_DIRS )
-    endif()
+    _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS)
+    _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES)
+    _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES)
 
     # If the HDF5 include directory was found, open H5pubconf.h to determine if
     # HDF5 was compiled with parallel IO support
@@ -376,8 +672,11 @@ if( NOT HDF5_FOUND )
                 HDF5_VERSION_DEFINE
                 REGEX "^[ \t]*#[ \t]*define[ \t]+H5_VERSION[ \t]+" )
             if( "${HDF5_VERSION_DEFINE}" MATCHES
-                "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+).*\"" )
+                "H5_VERSION[ \t]+\"([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?\"" )
                 set( HDF5_VERSION "${CMAKE_MATCH_1}" )
+                if( CMAKE_MATCH_3 )
+                  set( HDF5_VERSION ${HDF5_VERSION}.${CMAKE_MATCH_3})
+                endif()
             endif()
             unset(HDF5_VERSION_DEFINE)
         endif()
@@ -392,10 +691,20 @@ if( NOT HDF5_FOUND )
     if( HDF5_INCLUDE_DIRS )
         set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" )
     endif()
+    set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS)
+    if(FIND_HL)
+        list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES)
+    endif()
+endif()
 
+# If HDF5_REQUIRED_VARS is empty at this point, then it's likely that
+# something external is trying to explicitly pass already found
+# locations
+if(NOT HDF5_REQUIRED_VARS)
+    set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS)
 endif()
 
-find_package_handle_standard_args( HDF5
-    REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS
+find_package_handle_standard_args(HDF5
+    REQUIRED_VARS ${HDF5_REQUIRED_VARS}
     VERSION_VAR   HDF5_VERSION
 )
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake
index 135038c..3ceab39 100644
--- a/Modules/FindJNI.cmake
+++ b/Modules/FindJNI.cmake
@@ -92,10 +92,14 @@ macro(java_append_library_directories _var)
         if(_path MATCHES "{libarch}")
             foreach(_libarch ${_java_libarch})
                 string(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
-                list(APPEND ${_var} "${_newpath}")
+                if(EXISTS ${_newpath})
+                    list(APPEND ${_var} "${_newpath}")
+                endif()
             endforeach()
         else()
-            list(APPEND ${_var} "${_path}")
+            if(EXISTS ${_path})
+                list(APPEND ${_var} "${_path}")
+            endif()
         endif()
     endforeach()
 endmacro()
@@ -151,6 +155,10 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
   /usr/lib/jvm/default-java/jre/lib/{libarch}
   /usr/lib/jvm/default-java/jre/lib
   /usr/lib/jvm/default-java/lib
+  # Ubuntu specific paths for default JVM
+  /usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
+  /usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
+  /usr/lib/jvm/java-6-openjdk-{libarch}/jre/lib/{libarch}     # Ubuntu 15.10
   # OpenBSD specific paths for default JVM
   /usr/local/jdk-1.7.0/jre/lib/{libarch}
   /usr/local/jre-1.7.0/lib/{libarch}
@@ -181,6 +189,9 @@ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+)
+
+JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
   /usr/include
   /usr/local/include
   /usr/lib/java/include
@@ -190,6 +201,9 @@ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
   /usr/lib/jvm/java-1.5.0-sun/include
   /usr/lib/jvm/java-6-sun-1.6.0.00/include       # can this one be removed according to #8821 ? Alex
   /usr/lib/jvm/java-6-openjdk/include
+  /usr/lib/jvm/java-8-openjdk-{libarch}/include  # ubuntu 15.10
+  /usr/lib/jvm/java-7-openjdk-{libarch}/include  # ubuntu 15.10
+  /usr/lib/jvm/java-6-openjdk-{libarch}/include  # ubuntu 15.10
   /usr/local/share/java/include
   /usr/lib/j2sdk1.4-sun/include
   /usr/lib/j2sdk1.5-sun/include
diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake
index cc67df6..c643d9b 100644
--- a/Modules/FindJava.cmake
+++ b/Modules/FindJava.cmake
@@ -26,7 +26,7 @@
 #   Java_JAVA_EXECUTABLE      = the full path to the Java runtime
 #   Java_JAVAC_EXECUTABLE     = the full path to the Java compiler
 #   Java_JAVAH_EXECUTABLE     = the full path to the Java header generator
-#   Java_JAVADOC_EXECUTABLE   = the full path to the Java documention generator
+#   Java_JAVADOC_EXECUTABLE   = the full path to the Java documentation generator
 #   Java_IDLJ_EXECUTABLE      = the full path to the Java idl compiler
 #   Java_JAR_EXECUTABLE       = the full path to the Java archiver
 #   Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index b11edc3..a6bf89f 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -31,7 +31,7 @@
 #   BLA_F95     if set on tries to find the f95 interfaces for BLAS/LAPACK
 #
 # ## List of vendors (BLA_VENDOR) valid in this module # Intel(mkl),
-# ACML,Apple, NAS, Generic
+# OpenBLAS, ACML,Apple, NAS, Generic
 
 #=============================================================================
 # Copyright 2007-2009 Kitware, Inc.
@@ -48,11 +48,20 @@
 
 set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
 
-get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
-if (NOT _LANGUAGES_ MATCHES Fortran)
-include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
-else ()
+# Check the language being used
+if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED) )
+  if(LAPACK_FIND_REQUIRED)
+    message(FATAL_ERROR "FindLAPACK requires Fortran, C, or C++ to be enabled.")
+  else()
+    message(STATUS "Looking for LAPACK... - NOT found (Unsupported languages)")
+    return()
+  endif()
+endif()
+
+if (CMAKE_Fortran_COMPILER_LOADED)
 include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
+else ()
+include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
 endif ()
 include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
 
@@ -125,7 +134,7 @@ if(_libraries_work)
     set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads})
   endif()
 #  message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
-  if (NOT _LANGUAGES_ MATCHES Fortran)
+  if (NOT CMAKE_Fortran_COMPILER_LOADED)
     check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
   else ()
     check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
@@ -181,6 +190,19 @@ if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
  endif()
 endif ()
 
+if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
+ if(NOT LAPACK_LIBRARIES)
+  check_lapack_libraries(
+  LAPACK_LIBRARIES
+  LAPACK
+  cheev
+  ""
+  "openblas"
+  "${BLAS_LIBRARIES}"
+  ""
+  )
+ endif()
+endif ()
 
 #acml lapack
  if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
@@ -237,7 +259,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
   if (NOT WIN32)
     set(LM "-lm")
   endif ()
-  if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
+  if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
     if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
       find_PACKAGE(Threads)
     else()
diff --git a/Modules/FindLTTngUST.cmake b/Modules/FindLTTngUST.cmake
new file mode 100644
index 0000000..e3220ac
--- /dev/null
+++ b/Modules/FindLTTngUST.cmake
@@ -0,0 +1,111 @@
+#.rst:
+# FindLTTngUST
+# ------------
+#
+# This module finds the `LTTng-UST <http://lttng.org/>`__ library.
+#
+# Imported target
+# ^^^^^^^^^^^^^^^
+#
+# This module defines the following :prop_tgt:`IMPORTED` target:
+#
+# ``LTTng::UST``
+#   The LTTng-UST library, if found
+#
+# Result variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module sets the following
+#
+# ``LTTNGUST_FOUND``
+#   ``TRUE`` if system has LTTng-UST
+# ``LTTNGUST_INCLUDE_DIRS``
+#   The LTTng-UST include directories
+# ``LTTNGUST_LIBRARIES``
+#   The libraries needed to use LTTng-UST
+# ``LTTNGUST_VERSION_STRING``
+#   The LTTng-UST version
+# ``LTTNGUST_HAS_TRACEF``
+#   ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST
+# ``LTTNGUST_HAS_TRACELOG``
+#   ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST
+
+#=============================================================================
+# Copyright 2016 Kitware, Inc.
+# Copyright 2016 Philippe Proulx <pproulx at efficios.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.)
+
+find_path(LTTNGUST_INCLUDE_DIRS NAMES lttng/tracepoint.h)
+find_library(LTTNGUST_LIBRARIES NAMES lttng-ust)
+
+if(LTTNGUST_INCLUDE_DIRS AND LTTNGUST_LIBRARIES)
+  # find tracef() and tracelog() support
+  set(LTTNGUST_HAS_TRACEF 0)
+  set(LTTNGUST_HAS_TRACELOG 0)
+
+  if(EXISTS "${LTTNGUST_INCLUDE_DIRS}/lttng/tracef.h")
+    set(LTTNGUST_HAS_TRACEF TRUE)
+  endif()
+
+  if(EXISTS "${LTTNGUST_INCLUDE_DIRS}/lttng/tracelog.h")
+    set(LTTNGUST_HAS_TRACELOG TRUE)
+  endif()
+
+  # get version
+  set(lttngust_version_file "${LTTNGUST_INCLUDE_DIRS}/lttng/ust-version.h")
+
+  if(EXISTS "${lttngust_version_file}")
+    file(STRINGS "${lttngust_version_file}" lttngust_version_major_string
+         REGEX "^[\t ]*#define[\t ]+LTTNG_UST_MAJOR_VERSION[\t ]+[0-9]+[\t ]*$")
+    file(STRINGS "${lttngust_version_file}" lttngust_version_minor_string
+         REGEX "^[\t ]*#define[\t ]+LTTNG_UST_MINOR_VERSION[\t ]+[0-9]+[\t ]*$")
+    file(STRINGS "${lttngust_version_file}" lttngust_version_patch_string
+         REGEX "^[\t ]*#define[\t ]+LTTNG_UST_PATCHLEVEL_VERSION[\t ]+[0-9]+[\t ]*$")
+    string(REGEX REPLACE ".*([0-9]+).*" "\\1"
+           lttngust_v_major "${lttngust_version_major_string}")
+    string(REGEX REPLACE ".*([0-9]+).*" "\\1"
+           lttngust_v_minor "${lttngust_version_minor_string}")
+    string(REGEX REPLACE ".*([0-9]+).*" "\\1"
+           lttngust_v_patch "${lttngust_version_patch_string}")
+    set(LTTNGUST_VERSION_STRING
+        "${lttngust_v_major}.${lttngust_v_minor}.${lttngust_v_patch}")
+    unset(lttngust_version_major_string)
+    unset(lttngust_version_minor_string)
+    unset(lttngust_version_patch_string)
+    unset(lttngust_v_major)
+    unset(lttngust_v_minor)
+    unset(lttngust_v_patch)
+  endif()
+
+  unset(lttngust_version_file)
+
+  if(NOT TARGET LTTng::UST)
+    add_library(LTTng::UST UNKNOWN IMPORTED)
+    set_target_properties(LTTng::UST PROPERTIES
+      INTERFACE_INCLUDE_DIRECTORIES "${LTTNGUST_INCLUDE_DIRS}"
+      INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}
+      IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+      IMPORTED_LOCATION "${LTTNGUST_LIBRARIES}")
+  endif()
+
+  # add libdl to required libraries
+  set(LTTNGUST_LIBRARIES ${LTTNGUST_LIBRARIES} ${CMAKE_DL_LIBS})
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set LTTNGUST_FOUND to
+# TRUE if all listed variables are TRUE
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(LTTngUST FOUND_VAR LTTNGUST_FOUND
+                                  REQUIRED_VARS LTTNGUST_LIBRARIES
+                                                LTTNGUST_INCLUDE_DIRS
+                                  VERSION_VAR LTTNGUST_VERSION_STRING)
+mark_as_advanced(LTTNGUST_LIBRARIES LTTNGUST_INCLUDE_DIRS)
diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake
index 471a4f1..dd93041 100644
--- a/Modules/FindLibArchive.cmake
+++ b/Modules/FindLibArchive.cmake
@@ -42,14 +42,15 @@ mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY)
 
 # Extract the version number from the header.
 if(LibArchive_INCLUDE_DIR AND EXISTS "${LibArchive_INCLUDE_DIR}/archive.h")
-  # The version string appears in one of two known formats in the header:
+  # The version string appears in one of three known formats in the header:
   #  #define ARCHIVE_LIBRARY_VERSION "libarchive 2.4.12"
   #  #define ARCHIVE_VERSION_STRING "libarchive 2.8.4"
-  # Match either format.
-  set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"libarchive +([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$")
+  #  #define ARCHIVE_VERSION_ONLY_STRING "3.2.0"
+  # Match any format.
+  set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"(libarchive +)?([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$")
   file(STRINGS "${LibArchive_INCLUDE_DIR}/archive.h" _LibArchive_VERSION_STRING LIMIT_COUNT 1 REGEX "${_LibArchive_VERSION_REGEX}")
   if(_LibArchive_VERSION_STRING)
-    string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\1.\\2.\\3" LibArchive_VERSION "${_LibArchive_VERSION_STRING}")
+    string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\2.\\3.\\4" LibArchive_VERSION "${_LibArchive_VERSION_STRING}")
   endif()
   unset(_LibArchive_VERSION_REGEX)
   unset(_LibArchive_VERSION_STRING)
diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake
index 731f5f2..4e00a92 100644
--- a/Modules/FindLua.cmake
+++ b/Modules/FindLua.cmake
@@ -87,6 +87,7 @@ function(set_lua_version_vars)
              lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
              lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
              lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
+             lua.${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
         )
     endforeach ()
 
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 48adf3c..fbc6795 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -11,7 +11,8 @@
 # of them have somewhat different include paths, libraries to link
 # against, etc., and this module tries to smooth out those differences.
 #
-# === Variables ===
+# Variables
+# ^^^^^^^^^
 #
 # This module will set the following variables per language in your
 # project, where <lang> is one of C, CXX, or Fortran:
@@ -37,11 +38,12 @@
 #                               before the executable to run.
 #    MPIEXEC_POSTFLAGS          Flags to pass to MPIEXEC after other flags
 #
-# === Usage ===
+# Usage
+# ^^^^^
 #
 # To use this module, simply call FindMPI from a CMakeLists.txt file, or
-# run find_package(MPI), then run CMake.  If you are happy with the
-# auto- detected configuration for your language, then you're done.  If
+# run ``find_package(MPI)``, then run CMake.  If you are happy with the
+# auto-detected configuration for your language, then you're done.  If
 # not, you have two options:
 #
 # ::
@@ -55,24 +57,25 @@
 #       listed above, but these two are required.  This will circumvent
 #       autodetection entirely.
 #
-# When configuration is successful, MPI_<lang>_COMPILER will be set to
-# the compiler wrapper for <lang>, if it was found.  MPI_<lang>_FOUND
+# When configuration is successful, ``MPI_<lang>_COMPILER`` will be set to
+# the compiler wrapper for <lang>, if it was found.  ``MPI_<lang>_FOUND``
 # and other variables above will be set if any MPI implementation was
 # found for <lang>, regardless of whether a compiler was found.
 #
-# When using MPIEXEC to execute MPI applications, you should typically
-# use all of the MPIEXEC flags as follows:
+# When using ``MPIEXEC`` to execute MPI applications, you should typically
+# use all of the ``MPIEXEC`` flags as follows:
 #
 # ::
 #
 #    ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS
 #      ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
 #
-# where PROCS is the number of processors on which to execute the
-# program, EXECUTABLE is the MPI program, and ARGS are the arguments to
+# where ``PROCS`` is the number of processors on which to execute the
+# program, ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to
 # pass to the MPI program.
 #
-# === Backward Compatibility ===
+# Backward Compatibility
+# ^^^^^^^^^^^^^^^^^^^^^^
 #
 # For backward compatibility with older versions of FindMPI, these
 # variables are set, but deprecated:
@@ -83,7 +86,7 @@
 #    MPI_COMPILE_FLAGS   MPI_INCLUDE_PATH    MPI_EXTRA_LIBRARY
 #    MPI_LINK_FLAGS      MPI_LIBRARIES
 #
-# In new projects, please use the MPI_<lang>_XXX equivalents.
+# In new projects, please use the ``MPI_<lang>_XXX`` equivalents.
 
 #=============================================================================
 # Copyright 2001-2011 Kitware, Inc.
@@ -354,10 +357,10 @@ function (interrogate_mpi_compiler lang try_libs)
         endif()
 
         # Extract linker paths from the link command line
-        string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}")
+        string(REGEX MATCHALL "(^| |-Wl,)(-L|/LIBPATH:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}")
         set(MPI_LINK_PATH)
         foreach(LPATH ${MPI_ALL_LINK_PATHS})
-          string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH})
+          string(REGEX REPLACE "^(| |-Wl,)(-L|/LIBPATH:)" "" LPATH ${LPATH})
           string(REPLACE "//" "/" LPATH ${LPATH})
           list(APPEND MPI_LINK_PATH ${LPATH})
         endforeach()
@@ -382,6 +385,13 @@ function (interrogate_mpi_compiler lang try_libs)
         # Extract the set of libraries to link against from the link command
         # line
         string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
+        if(WIN32)
+          # The intel wrappers on windows link against static versions of the MPI libraries.
+          # The static libraries are simply listed on the command line without -l.
+          # For instance: " icl ... impi.lib "
+          string(REGEX MATCHALL "(^| )([^\" ]+)\\.lib" tmp "${MPI_LINK_CMDLINE}")
+          list(APPEND MPI_LIBNAMES ${tmp})
+        endif()
 
         # add the compiler implicit directories because some compilers
         # such as the intel compiler have libraries that show up
@@ -396,6 +406,10 @@ function (interrogate_mpi_compiler lang try_libs)
         # to link against in an MPI program
         foreach(LIB ${MPI_LIBNAMES})
           string(REGEX REPLACE "^ ?-l" "" LIB ${LIB})
+          if(WIN32)
+            string(REGEX REPLACE "\\.lib$" "" LIB ${LIB})
+          endif()
+          string(STRIP ${LIB} LIB)
           # MPI_LIB is cached by find_library, but we don't want that.  Clear it first.
           set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
           find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH})
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 7a36719..956dad2 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -132,7 +132,7 @@
 #   useful for the searching all possible Matlab installation.
 # :command:`matlab_get_mex_suffix`
 #   returns the suffix to be used for the mex files
-#   (platform/architecture dependant)
+#   (platform/architecture dependent)
 # :command:`matlab_get_version_from_matlab_run`
 #   returns the version of Matlab, given the full directory of the Matlab
 #   program.
@@ -229,6 +229,7 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS)
 endif()
 
 set(MATLAB_VERSIONS_MAPPING
+  "R2016a=9.0"
   "R2015b=8.6"
   "R2015a=8.5"
   "R2014b=8.4"
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index 8b4b988..8dbaf11 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -151,6 +151,7 @@ if(WIN32 AND NOT CYGWIN)
       NAMES
         libeay32${_OPENSSL_MSVC_RT_MODE}d
         libeay32d
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
         ${_OPENSSL_PATH_SUFFIXES}
@@ -160,6 +161,7 @@ if(WIN32 AND NOT CYGWIN)
       NAMES
         libeay32${_OPENSSL_MSVC_RT_MODE}
         libeay32
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
         ${_OPENSSL_PATH_SUFFIXES}
@@ -169,6 +171,7 @@ if(WIN32 AND NOT CYGWIN)
       NAMES
         ssleay32${_OPENSSL_MSVC_RT_MODE}d
         ssleay32d
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
         ${_OPENSSL_PATH_SUFFIXES}
@@ -179,6 +182,7 @@ if(WIN32 AND NOT CYGWIN)
         ssleay32${_OPENSSL_MSVC_RT_MODE}
         ssleay32
         ssl
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
         ${_OPENSSL_PATH_SUFFIXES}
@@ -205,6 +209,7 @@ if(WIN32 AND NOT CYGWIN)
     find_library(LIB_EAY
       NAMES
         ${LIB_EAY_NAMES}
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
         "lib"
@@ -214,6 +219,7 @@ if(WIN32 AND NOT CYGWIN)
     find_library(SSL_EAY
       NAMES
         ${SSL_EAY_NAMES}
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
         "lib"
@@ -231,6 +237,7 @@ if(WIN32 AND NOT CYGWIN)
     find_library(LIB_EAY
       NAMES
         libeay32
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       HINTS
         ${_OPENSSL_LIBDIR}
@@ -241,6 +248,7 @@ if(WIN32 AND NOT CYGWIN)
     find_library(SSL_EAY
       NAMES
         ssleay32
+      NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       HINTS
         ${_OPENSSL_LIBDIR}
@@ -260,6 +268,7 @@ else()
       ssl
       ssleay32
       ssleay32MD
+    NAMES_PER_DIR
     ${_OPENSSL_ROOT_HINTS_AND_PATHS}
     HINTS
       ${_OPENSSL_LIBDIR}
@@ -270,6 +279,7 @@ else()
   find_library(OPENSSL_CRYPTO_LIBRARY
     NAMES
       crypto
+    NAMES_PER_DIR
     ${_OPENSSL_ROOT_HINTS_AND_PATHS}
     HINTS
       ${_OPENSSL_LIBDIR}
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index cae41ac..5050d91 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -85,7 +85,7 @@ if(ZLIB_FOUND)
     list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d)
   endforeach()
   unset(_PNG_VERSION_SUFFIXES)
-  # For compatiblity with versions prior to this multi-config search, honor
+  # For compatibility with versions prior to this multi-config search, honor
   # any PNG_LIBRARY that is already specified and skip the search.
   if(NOT PNG_LIBRARY)
     find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES})
@@ -104,7 +104,7 @@ if(ZLIB_FOUND)
   if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
       # png.h includes zlib.h. Sigh.
       set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
-      set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity
+      set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatibility
       set(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
 
       if (CYGWIN)
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 447c526..b79e9df 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -16,6 +16,7 @@
 # Copyright 2006-2014 Kitware, Inc.
 # Copyright 2014      Christoph Grüninger <foss at grueninger.de>
 # Copyright 2006      Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
+# Copyright 2016      Rolf Eike Beer <eike at sf-mail.de>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -119,11 +120,12 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
 endmacro()
 
 # Splits given arguments into options and a package list
-macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path)
+macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target)
   set(${_is_req} 0)
   set(${_is_silent} 0)
   set(${_no_cmake_path} 0)
   set(${_no_cmake_environment_path} 0)
+  set(${_imp_target} 0)
   if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
     if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
       set(${_no_cmake_path} 1)
@@ -147,6 +149,9 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma
     if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH")
       set(${_no_cmake_environment_path} 1)
     endif()
+    if (_pkg STREQUAL "IMPORTED_TARGET")
+      set(${_imp_target} 1)
+    endif()
   endforeach()
 
   set(${_result} ${ARGN})
@@ -154,6 +159,7 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma
   list(REMOVE_ITEM ${_result} "QUIET")
   list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH")
   list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH")
+  list(REMOVE_ITEM ${_result} "IMPORTED_TARGET")
 endmacro()
 
 # Add the content of a variable or an environment variable to a list of
@@ -181,8 +187,63 @@ function(_pkgconfig_add_extra_path _extra_paths_var _var)
   set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE)
 endfunction()
 
+# scan the LDFLAGS returned by pkg-config for library directories and
+# libraries, figure out the absolute paths of that libraries in the
+# given directories, and create an imported target from them
+function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_path)
+  unset(_libs)
+  unset(_find_opts)
+
+  # set the options that are used as long as the .pc file does not provide a library
+  # path to look into
+  if(_no_cmake_path)
+    set(_find_opts "NO_CMAKE_PATH")
+  endif()
+  if(_no_cmake_environment_path)
+    set(_find_opts "${_find_opts} NO_CMAKE_ENVIRONMENT_PATH")
+  endif()
+
+  foreach (flag IN LISTS ${_prefix}_LDFLAGS)
+    if (flag MATCHES "^-L(.*)")
+      # only look into the given paths from now on
+      set(_find_opts "HINTS ${${CMAKE_MATCH_1}} NO_DEFAULT_PATH")
+      continue()
+    endif()
+    if (flag MATCHES "^-l(.*)")
+      set(_pkg_search "${CMAKE_MATCH_1}")
+    else()
+      continue()
+    endif()
+
+    find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
+                 NAMES ${_pkg_search}
+                 ${_find_opts})
+    list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
+  endforeach()
+
+  # only create the target if it is linkable, i.e. no executables
+  if (NOT TARGET PkgConfig::${_prefix}
+      AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER ))
+    add_library(PkgConfig::${_prefix} INTERFACE IMPORTED)
+
+    unset(_props)
+    if(${_prefix}_INCLUDE_DIRS)
+      set_property(TARGET PkgConfig::${_prefix} PROPERTY
+                   INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
+    endif()
+    if(_libs)
+      set_property(TARGET PkgConfig::${_prefix} PROPERTY
+                   INTERFACE_LINK_LIBRARIES "${_libs}")
+    endif()
+    if(${_prefix}_CFLAGS_OTHER)
+      set_property(TARGET PkgConfig::${_prefix} PROPERTY
+                   INTERFACE_COMPILE_OPTIONS "${${_prefix}_CFLAGS_OTHER}")
+    endif()
+  endif()
+endfunction()
+
 ###
-macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix)
+macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix)
   _pkgconfig_unset(${_prefix}_FOUND)
   _pkgconfig_unset(${_prefix}_VERSION)
   _pkgconfig_unset(${_prefix}_PREFIX)
@@ -400,6 +461,10 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS        "(^| )-I" --cflags-only-I )
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
+
+      if (_imp_target)
+        _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path)
+      endif()
     endif()
 
     if(NOT "${_extra_paths}" STREQUAL "")
@@ -427,6 +492,7 @@ endmacro()
 
     pkg_check_modules(<PREFIX> [REQUIRED] [QUIET]
                       [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
+                      [IMPORTED_TARGET]
                       <MODULE> [<MODULE>]*)
 
 
@@ -443,6 +509,9 @@ endmacro()
  The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments
  disable this behavior for the cache variables and the environment
  variables, respectively.
+ The ``IMPORTED_TARGET`` argument will create an imported target named
+ PkgConfig::<PREFIX>> that can be passed directly as an argument to
+ :command:`target_link_libraries`.
 
  It sets the following variables: ::
 
@@ -522,12 +591,14 @@ endmacro()
    XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
 #]========================================]
 macro(pkg_check_modules _prefix _module0)
+  _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN})
   # 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 _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})
+    _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" ${_pkg_modules})
 
     _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+  elseif (${_prefix}_FOUND AND ${_imp_target})
+    _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path)
   endif()
 endmacro()
 
@@ -540,6 +611,7 @@ endmacro()
 
     pkg_search_module(<PREFIX> [REQUIRED] [QUIET]
                       [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
+                      [IMPORTED_TARGET]
                       <MODULE> [<MODULE>]*)
 
  Examples
@@ -549,10 +621,10 @@ endmacro()
     pkg_search_module (BAR     libxml-2.0 libxml2 libxml>=2)
 #]========================================]
 macro(pkg_search_module _prefix _module0)
+  _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN})
   # 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 _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}'")
@@ -561,7 +633,7 @@ macro(pkg_search_module _prefix _module0)
     # 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 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}")
+        _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" "${_pkg_alt}")
       endif()
 
       if (${_prefix}_FOUND)
@@ -576,6 +648,8 @@ macro(pkg_search_module _prefix _module0)
     endif()
 
     _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+  elseif (${_prefix}_FOUND AND ${_imp_target})
+    _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path)
   endif()
 endmacro()
 
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 2f13b09..8042073 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -6,47 +6,51 @@
 #
 # The following variables can be set and are optional:
 #
-# ``PROTOBUF_SRC_ROOT_FOLDER``
+# ``Protobuf_SRC_ROOT_FOLDER``
 #   When compiling with MSVC, if this cache variable is set
 #   the protobuf-default VS project build locations
 #   (vsprojects/Debug and vsprojects/Release
 #   or vsprojects/x64/Debug and vsprojects/x64/Release)
 #   will be searched for libraries and binaries.
-# ``PROTOBUF_IMPORT_DIRS``
+# ``Protobuf_IMPORT_DIRS``
 #   List of additional directories to be searched for
 #   imported .proto files.
+# ``Protobuf_DEBUG``
+#   Show debug messages.
 #
 # Defines the following variables:
 #
-# ``PROTOBUF_FOUND``
+# ``Protobuf_FOUND``
 #   Found the Google Protocol Buffers library
 #   (libprotobuf & header files)
-# ``PROTOBUF_INCLUDE_DIRS``
+# ``Protobuf_VERSION``
+#   Version of package found.
+# ``Protobuf_INCLUDE_DIRS``
 #   Include directories for Google Protocol Buffers
-# ``PROTOBUF_LIBRARIES``
+# ``Protobuf_LIBRARIES``
 #   The protobuf libraries
-# ``PROTOBUF_PROTOC_LIBRARIES``
+# ``Protobuf_PROTOC_LIBRARIES``
 #   The protoc libraries
-# ``PROTOBUF_LITE_LIBRARIES``
+# ``Protobuf_LITE_LIBRARIES``
 #   The protobuf-lite libraries
 #
 # The following cache variables are also available to set or use:
 #
-# ``PROTOBUF_LIBRARY``
+# ``Protobuf_LIBRARY``
 #   The protobuf library
-# ``PROTOBUF_PROTOC_LIBRARY``
+# ``Protobuf_PROTOC_LIBRARY``
 #   The protoc library
-# ``PROTOBUF_INCLUDE_DIR``
+# ``Protobuf_INCLUDE_DIR``
 #   The include directory for protocol buffers
-# ``PROTOBUF_PROTOC_EXECUTABLE``
+# ``Protobuf_PROTOC_EXECUTABLE``
 #   The protoc compiler
-# ``PROTOBUF_LIBRARY_DEBUG``
+# ``Protobuf_LIBRARY_DEBUG``
 #   The protobuf library (debug)
-# ``PROTOBUF_PROTOC_LIBRARY_DEBUG``
+# ``Protobuf_PROTOC_LIBRARY_DEBUG``
 #   The protoc library (debug)
-# ``PROTOBUF_LITE_LIBRARY``
+# ``Protobuf_LITE_LIBRARY``
 #   The protobuf lite library
-# ``PROTOBUF_LITE_LIBRARY_DEBUG``
+# ``Protobuf_LITE_LIBRARY_DEBUG``
 #   The protobuf lite library (debug)
 #
 # Example:
@@ -54,12 +58,12 @@
 # .. code-block:: cmake
 #
 #   find_package(Protobuf REQUIRED)
-#   include_directories(${PROTOBUF_INCLUDE_DIRS})
+#   include_directories(${Protobuf_INCLUDE_DIRS})
 #   include_directories(${CMAKE_CURRENT_BINARY_DIR})
 #   protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto)
 #   protobuf_generate_python(PROTO_PY foo.proto)
 #   add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
-#   target_link_libraries(bar ${PROTOBUF_LIBRARIES})
+#   target_link_libraries(bar ${Protobuf_LIBRARIES})
 #
 # .. note::
 #   The ``protobuf_generate_cpp`` and ``protobuf_generate_python``
@@ -125,8 +129,8 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
     set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
   endif()
 
-  if(DEFINED PROTOBUF_IMPORT_DIRS)
-    foreach(DIR ${PROTOBUF_IMPORT_DIRS})
+  if(DEFINED Protobuf_IMPORT_DIRS)
+    foreach(DIR ${Protobuf_IMPORT_DIRS})
       get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
       list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
       if(${_contains_already} EQUAL -1)
@@ -147,9 +151,9 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
     add_custom_command(
       OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
              "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
-      COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE}
+      COMMAND  ${Protobuf_PROTOC_EXECUTABLE}
       ARGS --cpp_out  ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
-      DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
+      DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
       COMMENT "Running C++ protocol buffer compiler on ${FIL}"
       VERBATIM )
   endforeach()
@@ -179,8 +183,8 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
     set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
   endif()
 
-  if(DEFINED PROTOBUF_IMPORT_DIRS)
-    foreach(DIR ${PROTOBUF_IMPORT_DIRS})
+  if(DEFINED Protobuf_IMPORT_DIRS)
+    foreach(DIR ${Protobuf_IMPORT_DIRS})
       get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
       list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
       if(${_contains_already} EQUAL -1)
@@ -197,8 +201,8 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
     list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")
     add_custom_command(
       OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py"
-      COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
-      DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
+      COMMAND  ${Protobuf_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
+      DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
       COMMENT "Running Python protocol buffer compiler on ${FIL}"
       VERBATIM )
   endforeach()
@@ -206,36 +210,60 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
   set(${SRCS} ${${SRCS}} PARENT_SCOPE)
 endfunction()
 
+# Backwards compatibility
+# Define camel case versions of input variables
+foreach(UPPER
+    PROTOBUF_SRC_ROOT_FOLDER
+    PROTOBUF_IMPORT_DIRS
+    PROTOBUF_DEBUG
+    PROTOBUF_LIBRARY
+    PROTOBUF_PROTOC_LIBRARY
+    PROTOBUF_INCLUDE_DIR
+    PROTOBUF_PROTOC_EXECUTABLE
+    PROTOBUF_LIBRARY_DEBUG
+    PROTOBUF_PROTOC_LIBRARY_DEBUG
+    PROTOBUF_LITE_LIBRARY
+    PROTOBUF_LITE_LIBRARY_DEBUG
+    )
+    if (DEFINED ${UPPER})
+        string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER})
+        if (NOT DEFINED ${Camel})
+            set(${Camel} ${${UPPER}})
+        endif()
+    endif()
+endforeach()
+
 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
   set(_PROTOBUF_ARCH_DIR x64/)
 endif()
 
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+
 # Internal function: search for normal library as well as a debug one
 #    if the debug one is specified also include debug/optimized keywords
 #    in *_LIBRARIES variable
 function(_protobuf_find_libraries name filename)
-   find_library(${name}_LIBRARY
-       NAMES ${filename}
-       PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release)
-   mark_as_advanced(${name}_LIBRARY)
-
-   find_library(${name}_LIBRARY_DEBUG
-       NAMES ${filename}
-       PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug)
-   mark_as_advanced(${name}_LIBRARY_DEBUG)
-
-   if(NOT ${name}_LIBRARY_DEBUG)
-      # There is no debug library
-      set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE)
-      set(${name}_LIBRARIES     ${${name}_LIBRARY} PARENT_SCOPE)
-   else()
-      # There IS a debug library
-      set(${name}_LIBRARIES
-          optimized ${${name}_LIBRARY}
-          debug     ${${name}_LIBRARY_DEBUG}
-          PARENT_SCOPE
-      )
-   endif()
+  if(${name}_LIBRARIES)
+    # Use result recorded by a previous call.
+    return()
+  elseif(${name}_LIBRARY)
+    # Honor cache entry used by CMake 3.5 and lower.
+    set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
+  else()
+    find_library(${name}_LIBRARY_RELEASE
+      NAMES ${filename}
+      PATHS ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release)
+    mark_as_advanced(${name}_LIBRARY_RELEASE)
+
+    find_library(${name}_LIBRARY_DEBUG
+      NAMES ${filename}
+      PATHS ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug)
+    mark_as_advanced(${name}_LIBRARY_DEBUG)
+
+    select_library_configurations(${name})
+    set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE)
+    set(${name}_LIBRARIES "${${name}_LIBRARIES}" PARENT_SCOPE)
+  endif()
 endfunction()
 
 # Internal function: find threads library
@@ -243,8 +271,8 @@ function(_protobuf_find_threads)
     set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
     find_package(Threads)
     if(Threads_FOUND)
-        list(APPEND PROTOBUF_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
-        set(PROTOBUF_LIBRARIES "${PROTOBUF_LIBRARIES}" PARENT_SCOPE)
+        list(APPEND Protobuf_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+        set(Protobuf_LIBRARIES "${Protobuf_LIBRARIES}" PARENT_SCOPE)
     endif()
 endfunction()
 
@@ -262,24 +290,24 @@ endif()
 # Google's provided vcproj files generate libraries with a "lib"
 # prefix on Windows
 if(MSVC)
-    set(PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
+    set(Protobuf_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
     set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
 
-    find_path(PROTOBUF_SRC_ROOT_FOLDER protobuf.pc.in)
+    find_path(Protobuf_SRC_ROOT_FOLDER protobuf.pc.in)
 endif()
 
 # The Protobuf library
-_protobuf_find_libraries(PROTOBUF protobuf)
+_protobuf_find_libraries(Protobuf protobuf)
 #DOC "The Google Protocol Buffers RELEASE Library"
 
-_protobuf_find_libraries(PROTOBUF_LITE protobuf-lite)
+_protobuf_find_libraries(Protobuf_LITE protobuf-lite)
 
 # The Protobuf Protoc Library
-_protobuf_find_libraries(PROTOBUF_PROTOC protoc)
+_protobuf_find_libraries(Protobuf_PROTOC protoc)
 
 # Restore original find library prefixes
 if(MSVC)
-    set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}")
+    set(CMAKE_FIND_LIBRARY_PREFIXES "${Protobuf_ORIG_FIND_LIBRARY_PREFIXES}")
 endif()
 
 if(UNIX)
@@ -287,27 +315,101 @@ if(UNIX)
 endif()
 
 # Find the include directory
-find_path(PROTOBUF_INCLUDE_DIR
+find_path(Protobuf_INCLUDE_DIR
     google/protobuf/service.h
-    PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/src
+    PATHS ${Protobuf_SRC_ROOT_FOLDER}/src
 )
-mark_as_advanced(PROTOBUF_INCLUDE_DIR)
+mark_as_advanced(Protobuf_INCLUDE_DIR)
 
 # Find the protoc Executable
-find_program(PROTOBUF_PROTOC_EXECUTABLE
+find_program(Protobuf_PROTOC_EXECUTABLE
     NAMES protoc
     DOC "The Google Protocol Buffers Compiler"
     PATHS
-    ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release
-    ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug
+    ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Release
+    ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug
 )
-mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE)
+mark_as_advanced(Protobuf_PROTOC_EXECUTABLE)
+
+if(Protobuf_DEBUG)
+    message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
+        "requested version of Google Protobuf is ${Protobuf_FIND_VERSION}")
+endif()
+
+if(Protobuf_INCLUDE_DIR)
+  set(_PROTOBUF_COMMON_HEADER ${Protobuf_INCLUDE_DIR}/google/protobuf/stubs/common.h)
+
+  if(Protobuf_DEBUG)
+    message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
+                   "location of common.h: ${_PROTOBUF_COMMON_HEADER}")
+  endif()
+
+  set(Protobuf_VERSION "")
+  set(Protobuf_LIB_VERSION "")
+  file(STRINGS ${_PROTOBUF_COMMON_HEADER} _PROTOBUF_COMMON_H_CONTENTS REGEX "#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+")
+  if(_PROTOBUF_COMMON_H_CONTENTS MATCHES "#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+([0-9]+)")
+      set(Protobuf_LIB_VERSION "${CMAKE_MATCH_1}")
+  endif()
+  unset(_PROTOBUF_COMMON_H_CONTENTS)
 
+  math(EXPR _PROTOBUF_MAJOR_VERSION "${Protobuf_LIB_VERSION} / 1000000")
+  math(EXPR _PROTOBUF_MINOR_VERSION "${Protobuf_LIB_VERSION} / 1000 % 1000")
+  math(EXPR _PROTOBUF_SUBMINOR_VERSION "${Protobuf_LIB_VERSION} % 1000")
+  set(Protobuf_VERSION "${_PROTOBUF_MAJOR_VERSION}.${_PROTOBUF_MINOR_VERSION}.${_PROTOBUF_SUBMINOR_VERSION}")
+
+  if(Protobuf_DEBUG)
+    message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
+        "${_PROTOBUF_COMMON_HEADER} reveals protobuf ${Protobuf_VERSION}")
+  endif()
+
+  # Check Protobuf compiler version to be aligned with libraries version
+  execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --version
+                  OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION)
+
+  if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)")
+    set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
+  endif()
+
+  if(Protobuf_DEBUG)
+    message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
+        "${Protobuf_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}")
+  endif()
+
+  if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}")
+      message(WARNING "Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}"
+          " doesn't match library version ${Protobuf_VERSION}")
+  endif()
+endif()
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf DEFAULT_MSG
-    PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf
+    REQUIRED_VARS Protobuf_LIBRARIES Protobuf_INCLUDE_DIR
+    VERSION_VAR Protobuf_VERSION
+)
 
-if(PROTOBUF_FOUND)
-    set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
+if(Protobuf_FOUND)
+    set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
 endif()
+
+# Backwards compatibility
+# Define upper case versions of output variables
+foreach(Camel
+    Protobuf_SRC_ROOT_FOLDER
+    Protobuf_IMPORT_DIRS
+    Protobuf_DEBUG
+    Protobuf_INCLUDE_DIRS
+    Protobuf_LIBRARIES
+    Protobuf_PROTOC_LIBRARIES
+    Protobuf_LITE_LIBRARIES
+    Protobuf_LIBRARY
+    Protobuf_PROTOC_LIBRARY
+    Protobuf_INCLUDE_DIR
+    Protobuf_PROTOC_EXECUTABLE
+    Protobuf_LIBRARY_DEBUG
+    Protobuf_PROTOC_LIBRARY_DEBUG
+    Protobuf_LITE_LIBRARY
+    Protobuf_LITE_LIBRARY_DEBUG
+    )
+    string(TOUPPER ${Camel} UPPER)
+    set(${UPPER} ${${Camel}})
+endforeach()
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index 11091b5..d167a13 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -240,6 +240,8 @@
 #  The QAxServer target (Windows only)
 # ``Qt4::QtDBus``
 #  The QtDBus target
+# ``Qt4::QtDeclarative``
+#  The QtDeclarative target
 # ``Qt4::QtDesigner``
 #  The QtDesigner target
 # ``Qt4::QtDesignerComponents``
diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake
index 49b5e40..e7517c5 100644
--- a/Modules/FindSDL_image.cmake
+++ b/Modules/FindSDL_image.cmake
@@ -16,7 +16,7 @@
 #
 #
 #
-# For backward compatiblity the following variables are also set:
+# For backward compatibility the following variables are also set:
 #
 # ::
 #
@@ -103,7 +103,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_image
                                   REQUIRED_VARS SDL_IMAGE_LIBRARIES SDL_IMAGE_INCLUDE_DIRS
                                   VERSION_VAR SDL_IMAGE_VERSION_STRING)
 
-# for backward compatiblity
+# for backward compatibility
 set(SDLIMAGE_LIBRARY ${SDL_IMAGE_LIBRARIES})
 set(SDLIMAGE_INCLUDE_DIR ${SDL_IMAGE_INCLUDE_DIRS})
 set(SDLIMAGE_FOUND ${SDL_IMAGE_FOUND})
diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake
index 9e11796..72ec654 100644
--- a/Modules/FindSDL_mixer.cmake
+++ b/Modules/FindSDL_mixer.cmake
@@ -16,7 +16,7 @@
 #
 #
 #
-# For backward compatiblity the following variables are also set:
+# For backward compatibility the following variables are also set:
 #
 # ::
 #
@@ -103,7 +103,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_mixer
                                   REQUIRED_VARS SDL_MIXER_LIBRARIES SDL_MIXER_INCLUDE_DIRS
                                   VERSION_VAR SDL_MIXER_VERSION_STRING)
 
-# for backward compatiblity
+# for backward compatibility
 set(SDLMIXER_LIBRARY ${SDL_MIXER_LIBRARIES})
 set(SDLMIXER_INCLUDE_DIR ${SDL_MIXER_INCLUDE_DIRS})
 set(SDLMIXER_FOUND ${SDL_MIXER_FOUND})
diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake
index ef23573..11c250c 100644
--- a/Modules/FindSDL_net.cmake
+++ b/Modules/FindSDL_net.cmake
@@ -15,7 +15,7 @@
 #
 #
 #
-# For backward compatiblity the following variables are also set:
+# For backward compatibility the following variables are also set:
 #
 # ::
 #
@@ -102,7 +102,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_net
                                   REQUIRED_VARS SDL_NET_LIBRARIES SDL_NET_INCLUDE_DIRS
                                   VERSION_VAR SDL_NET_VERSION_STRING)
 
-# for backward compatiblity
+# for backward compatibility
 set(SDLNET_LIBRARY ${SDL_NET_LIBRARIES})
 set(SDLNET_INCLUDE_DIR ${SDL_NET_INCLUDE_DIRS})
 set(SDLNET_FOUND ${SDL_NET_FOUND})
diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake
index 4b527fa..38f6e1d 100644
--- a/Modules/FindSDL_ttf.cmake
+++ b/Modules/FindSDL_ttf.cmake
@@ -15,7 +15,7 @@
 #
 #
 #
-# For backward compatiblity the following variables are also set:
+# For backward compatibility the following variables are also set:
 #
 # ::
 #
@@ -102,7 +102,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_ttf
                                   REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS
                                   VERSION_VAR SDL_TTF_VERSION_STRING)
 
-# for backward compatiblity
+# for backward compatibility
 set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})
 set(SDLTTF_INCLUDE_DIR ${SDL_TTF_INCLUDE_DIRS})
 set(SDLTTF_FOUND ${SDL_TTF_FOUND})
diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake
index 0d13318..804f44c 100644
--- a/Modules/FindSubversion.cmake
+++ b/Modules/FindSubversion.cmake
@@ -11,7 +11,7 @@
 #   Subversion_SVN_EXECUTABLE - path to svn command line client
 #   Subversion_VERSION_SVN - version of svn command line client
 #   Subversion_FOUND - true if the command line client was found
-#   SUBVERSION_FOUND - same as Subversion_FOUND, set for compatiblity reasons
+#   SUBVERSION_FOUND - same as Subversion_FOUND, set for compatibility reasons
 #
 #
 #
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index c607923..719dace 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -26,7 +26,7 @@
 #
 #   CMAKE_THREAD_PREFER_PTHREAD
 #
-# If the use of the -pthread compiler and linker flag is prefered then the
+# If the use of the -pthread compiler and linker flag is preferred then the
 # caller can set
 #
 # ::
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
index 49ce57e..8c07e6c 100644
--- a/Modules/FindwxWidgets.cmake
+++ b/Modules/FindwxWidgets.cmake
@@ -835,6 +835,36 @@ else()
       endif()
     endif()
 
+    # When using wx-config in MSYS, the include paths are UNIX style paths which may or may
+    # not work correctly depending on you MSYS/MinGW configuration.  CMake expects native
+    # paths internally.
+    if(wxWidgets_FOUND AND MSYS)
+      find_program(_cygpath_exe cygpath ONLY_CMAKE_FIND_ROOT_PATH)
+      DBG_MSG_V("_cygpath_exe:  ${_cygpath_exe}")
+      if(_cygpath_exe)
+        set(_tmp_path "")
+        foreach(_path ${wxWidgets_INCLUDE_DIRS})
+          execute_process(
+            COMMAND cygpath -w ${_path}
+            OUTPUT_VARIABLE _native_path
+            RESULT_VARIABLE _retv
+            OUTPUT_STRIP_TRAILING_WHITESPACE
+            ERROR_QUIET
+            )
+          if(_retv EQUAL 0)
+            file(TO_CMAKE_PATH ${_native_path} _native_path)
+            DBG_MSG_V("Path ${_path} converted to ${_native_path}")
+            set(_tmp_path "${_tmp_path} ${_native_path}")
+          endif()
+        endforeach()
+        DBG_MSG("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}")
+        set(wxWidgets_INCLUDE_DIRS ${_tmp_path})
+        separate_arguments(wxWidgets_INCLUDE_DIRS)
+        list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "")
+      endif()
+      unset(_cygpath_exe CACHE)
+    endif()
+
 #=====================================================================
 # Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE
 #=====================================================================
diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake
index 70c3fd7..c12dd4c 100644
--- a/Modules/FortranCInterface.cmake
+++ b/Modules/FortranCInterface.cmake
@@ -1,129 +1,190 @@
-#.rst:
-# FortranCInterface
-# -----------------
-#
-# Fortran/C Interface Detection
-#
-# This module automatically detects the API by which C and Fortran
-# languages interact.  Variables indicate if the mangling is found:
-#
-# ::
-#
-#    FortranCInterface_GLOBAL_FOUND = Global subroutines and functions
-#    FortranCInterface_MODULE_FOUND = Module subroutines and functions
-#                                     (declared by "MODULE PROCEDURE")
-#
-# A function is provided to generate a C header file containing macros
-# to mangle symbol names:
-#
-# ::
-#
-#    FortranCInterface_HEADER(<file>
-#                             [MACRO_NAMESPACE <macro-ns>]
-#                             [SYMBOL_NAMESPACE <ns>]
-#                             [SYMBOLS [<module>:]<function> ...])
-#
-# It generates in <file> definitions of the following macros:
-#
-# ::
-#
-#    #define FortranCInterface_GLOBAL (name,NAME) ...
-#    #define FortranCInterface_GLOBAL_(name,NAME) ...
-#    #define FortranCInterface_MODULE (mod,name, MOD,NAME) ...
-#    #define FortranCInterface_MODULE_(mod,name, MOD,NAME) ...
-#
-# These macros mangle four categories of Fortran symbols, respectively:
-#
-# ::
-#
-#    - Global symbols without '_': call mysub()
-#    - Global symbols with '_'   : call my_sub()
-#    - Module symbols without '_': use mymod; call mysub()
-#    - Module symbols with '_'   : use mymod; call my_sub()
-#
-# If mangling for a category is not known, its macro is left undefined.
-# All macros require raw names in both lower case and upper case.  The
-# MACRO_NAMESPACE option replaces the default "FortranCInterface_"
-# prefix with a given namespace "<macro-ns>".
-#
-# The SYMBOLS option lists symbols to mangle automatically with C
-# preprocessor definitions:
-#
-# ::
-#
-#    <function>          ==> #define <ns><function> ...
-#    <module>:<function> ==> #define <ns><module>_<function> ...
-#
-# If the mangling for some symbol is not known then no preprocessor
-# definition is created, and a warning is displayed.  The
-# SYMBOL_NAMESPACE option prefixes all preprocessor definitions
-# generated by the SYMBOLS option with a given namespace "<ns>".
-#
-# Example usage:
-#
-# ::
-#
-#    include(FortranCInterface)
-#    FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_")
-#
-# This creates a "FC.h" header that defines mangling macros FC_GLOBAL(),
-# FC_GLOBAL_(), FC_MODULE(), and FC_MODULE_().
-#
-# Example usage:
-#
-# ::
-#
-#    include(FortranCInterface)
-#    FortranCInterface_HEADER(FCMangle.h
-#                             MACRO_NAMESPACE "FC_"
-#                             SYMBOL_NAMESPACE "FC_"
-#                             SYMBOLS mysub mymod:my_sub)
-#
-# This creates a "FCMangle.h" header that defines the same FC_*()
-# mangling macros as the previous example plus preprocessor symbols
-# FC_mysub and FC_mymod_my_sub.
-#
-# Another function is provided to verify that the Fortran and C/C++
-# compilers work together:
-#
-# ::
-#
-#    FortranCInterface_VERIFY([CXX] [QUIET])
-#
-# It tests whether a simple test executable using Fortran and C (and C++
-# when the CXX option is given) compiles and links successfully.  The
-# result is stored in the cache entry FortranCInterface_VERIFIED_C (or
-# FortranCInterface_VERIFIED_CXX if CXX is given) as a boolean.  If the
-# check fails and QUIET is not given the function terminates with a
-# FATAL_ERROR message describing the problem.  The purpose of this check
-# is to stop a build early for incompatible compiler combinations.  The
-# test is built in the Release configuration.
-#
-# FortranCInterface is aware of possible GLOBAL and MODULE manglings for
-# many Fortran compilers, but it also provides an interface to specify
-# new possible manglings.  Set the variables
-#
-# ::
-#
-#    FortranCInterface_GLOBAL_SYMBOLS
-#    FortranCInterface_MODULE_SYMBOLS
-#
-# before including FortranCInterface to specify manglings of the symbols
-# "MySub", "My_Sub", "MyModule:MySub", and "My_Module:My_Sub".  For
-# example, the code:
-#
-# ::
-#
-#    set(FortranCInterface_GLOBAL_SYMBOLS mysub_ my_sub__ MYSUB_)
-#      #                                  ^^^^^  ^^^^^^   ^^^^^
-#    set(FortranCInterface_MODULE_SYMBOLS
-#        __mymodule_MOD_mysub __my_module_MOD_my_sub)
-#      #   ^^^^^^^^     ^^^^^   ^^^^^^^^^     ^^^^^^
-#    include(FortranCInterface)
-#
-# tells FortranCInterface to try given GLOBAL and MODULE manglings.
-# (The carets point at raw symbol names for clarity in this example but
-# are not needed.)
+#[=======================================================================[.rst:
+FortranCInterface
+-----------------
+
+Fortran/C Interface Detection
+
+This module automatically detects the API by which C and Fortran
+languages interact.
+
+Module Variables
+^^^^^^^^^^^^^^^^
+
+Variables that indicate if the mangling is found:
+
+``FortranCInterface_GLOBAL_FOUND``
+  Global subroutines and functions.
+
+``FortranCInterface_MODULE_FOUND``
+  Module subroutines and functions (declared by "MODULE PROCEDURE").
+
+This module also provides the following variables to specify
+the detected mangling, though a typical use case does not need
+to reference them and can use the `Module Functions`_ below.
+
+``FortranCInterface_GLOBAL_PREFIX``
+  Prefix for a global symbol without an underscore.
+
+``FortranCInterface_GLOBAL_SUFFIX``
+  Suffix for a global symbol without an underscore.
+
+``FortranCInterface_GLOBAL_CASE``
+  The case for a global symbol without an underscore,
+  either ``UPPER`` or ``LOWER``.
+
+``FortranCInterface_GLOBAL__PREFIX``
+  Prefix for a global symbol with an underscore.
+
+``FortranCInterface_GLOBAL__SUFFIX``
+  Suffix for a global symbol with an underscore.
+
+``FortranCInterface_GLOBAL__CASE``
+  The case for a global symbol with an underscore,
+  either ``UPPER`` or ``LOWER``.
+
+``FortranCInterface_MODULE_PREFIX``
+  Prefix for a module symbol without an underscore.
+
+``FortranCInterface_MODULE_MIDDLE``
+  Middle of a module symbol without an underscore that appears
+  between the name of the module and the name of the symbol.
+
+``FortranCInterface_MODULE_SUFFIX``
+  Suffix for a module symbol without an underscore.
+
+``FortranCInterface_MODULE_CASE``
+  The case for a module symbol without an underscore,
+  either ``UPPER`` or ``LOWER``.
+
+``FortranCInterface_MODULE__PREFIX``
+  Prefix for a module symbol with an underscore.
+
+``FortranCInterface_MODULE__MIDDLE``
+  Middle of a module symbol with an underscore that appears
+  between the name of the module and the name of the symbol.
+
+``FortranCInterface_MODULE__SUFFIX``
+  Suffix for a module symbol with an underscore.
+
+``FortranCInterface_MODULE__CASE``
+  The case for a module symbol with an underscore,
+  either ``UPPER`` or ``LOWER``.
+
+Module Functions
+^^^^^^^^^^^^^^^^
+
+.. command:: FortranCInterface_HEADER
+
+  The ``FortranCInterface_HEADER`` function is provided to generate a
+  C header file containing macros to mangle symbol names::
+
+    FortranCInterface_HEADER(<file>
+                             [MACRO_NAMESPACE <macro-ns>]
+                             [SYMBOL_NAMESPACE <ns>]
+                             [SYMBOLS [<module>:]<function> ...])
+
+  It generates in ``<file>`` definitions of the following macros::
+
+     #define FortranCInterface_GLOBAL (name,NAME) ...
+     #define FortranCInterface_GLOBAL_(name,NAME) ...
+     #define FortranCInterface_MODULE (mod,name, MOD,NAME) ...
+     #define FortranCInterface_MODULE_(mod,name, MOD,NAME) ...
+
+  These macros mangle four categories of Fortran symbols, respectively:
+
+  * Global symbols without '_': ``call mysub()``
+  * Global symbols with '_'   : ``call my_sub()``
+  * Module symbols without '_': ``use mymod; call mysub()``
+  * Module symbols with '_'   : ``use mymod; call my_sub()``
+
+  If mangling for a category is not known, its macro is left undefined.
+  All macros require raw names in both lower case and upper case.
+
+  The options are:
+
+  ``MACRO_NAMESPACE``
+    Replace the default ``FortranCInterface_`` prefix with a given
+    namespace ``<macro-ns>``.
+
+  ``SYMBOLS``
+    List symbols to mangle automatically with C preprocessor definitions::
+
+      <function>          ==> #define <ns><function> ...
+      <module>:<function> ==> #define <ns><module>_<function> ...
+
+    If the mangling for some symbol is not known then no preprocessor
+    definition is created, and a warning is displayed.
+
+  ``SYMBOL_NAMESPACE``
+    Prefix all preprocessor definitions generated by the ``SYMBOLS``
+    option with a given namespace ``<ns>``.
+
+.. command:: FortranCInterface_VERIFY
+
+  The ``FortranCInterface_VERIFY`` function is provided to verify
+  that the Fortran and C/C++ compilers work together::
+
+    FortranCInterface_VERIFY([CXX] [QUIET])
+
+  It tests whether a simple test executable using Fortran and C (and C++
+  when the CXX option is given) compiles and links successfully.  The
+  result is stored in the cache entry ``FortranCInterface_VERIFIED_C``
+  (or ``FortranCInterface_VERIFIED_CXX`` if ``CXX`` is given) as a boolean.
+  If the check fails and ``QUIET`` is not given the function terminates with a
+  fatal error message describing the problem.  The purpose of this check
+  is to stop a build early for incompatible compiler combinations.  The
+  test is built in the ``Release`` configuration.
+
+Example Usage
+^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+   include(FortranCInterface)
+   FortranCInterface_HEADER(FC.h MACRO_NAMESPACE "FC_")
+
+This creates a "FC.h" header that defines mangling macros ``FC_GLOBAL()``,
+``FC_GLOBAL_()``, ``FC_MODULE()``, and ``FC_MODULE_()``.
+
+.. code-block:: cmake
+
+   include(FortranCInterface)
+   FortranCInterface_HEADER(FCMangle.h
+                            MACRO_NAMESPACE "FC_"
+                            SYMBOL_NAMESPACE "FC_"
+                            SYMBOLS mysub mymod:my_sub)
+
+This creates a "FCMangle.h" header that defines the same ``FC_*()``
+mangling macros as the previous example plus preprocessor symbols
+``FC_mysub`` and ``FC_mymod_my_sub``.
+
+Additional Manglings
+^^^^^^^^^^^^^^^^^^^^
+
+FortranCInterface is aware of possible ``GLOBAL`` and ``MODULE`` manglings
+for many Fortran compilers, but it also provides an interface to specify
+new possible manglings.  Set the variables::
+
+   FortranCInterface_GLOBAL_SYMBOLS
+   FortranCInterface_MODULE_SYMBOLS
+
+before including FortranCInterface to specify manglings of the symbols
+``MySub``, ``My_Sub``, ``MyModule:MySub``, and ``My_Module:My_Sub``.
+For example, the code:
+
+.. code-block:: cmake
+
+   set(FortranCInterface_GLOBAL_SYMBOLS mysub_ my_sub__ MYSUB_)
+     #                                  ^^^^^  ^^^^^^   ^^^^^
+   set(FortranCInterface_MODULE_SYMBOLS
+       __mymodule_MOD_mysub __my_module_MOD_my_sub)
+     #   ^^^^^^^^     ^^^^^   ^^^^^^^^^     ^^^^^^
+   include(FortranCInterface)
+
+tells FortranCInterface to try given ``GLOBAL`` and ``MODULE`` manglings.
+(The carets point at raw symbol names for clarity in this example but
+are not needed.)
+#]=======================================================================]
 
 #=============================================================================
 # Copyright 2008-2009 Kitware, Inc.
diff --git a/Modules/FortranCInterface/my_module_.c b/Modules/FortranCInterface/my_module_.c
index 6510ae9..6fa89d1 100644
--- a/Modules/FortranCInterface/my_module_.c
+++ b/Modules/FortranCInterface/my_module_.c
@@ -1 +1,3 @@
-void my_module_(void) {}
+void my_module_(void)
+{
+}
diff --git a/Modules/FortranCInterface/mymodule_.c b/Modules/FortranCInterface/mymodule_.c
index 5270605..444953b 100644
--- a/Modules/FortranCInterface/mymodule_.c
+++ b/Modules/FortranCInterface/mymodule_.c
@@ -1 +1,3 @@
-void mymodule_(void) {}
+void mymodule_(void)
+{
+}
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index 4f4efbc..6389d30 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -341,7 +341,9 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
   string(MAKE_C_IDENTIFIER ${STATIC_DEFINE} STATIC_DEFINE)
 
   if(_GEH_DEFINE_NO_DEPRECATED)
-    set(DEFINE_NO_DEPRECATED TRUE)
+    set(DEFINE_NO_DEPRECATED 1)
+  else()
+    set(DEFINE_NO_DEPRECATED 0)
   endif()
 
   if(_GEH_NO_DEPRECATED_MACRO_NAME)
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index 391e7f8..aa5bf28 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -500,6 +500,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var)
   if(NOT IS_ABSOLUTE "${original_file}")
     message(STATUS "warning: gp_resolved_file_type expects absolute full path for first arg original_file")
   endif()
+  get_filename_component(original_file "${original_file}" ABSOLUTE) # canonicalize path
 
   set(is_embedded 0)
   set(is_local 0)
@@ -515,6 +516,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var)
     if(NOT IS_ABSOLUTE "${file}")
       gp_resolve_item("${original_file}" "${file}" "${exepath}" "${dirs}" resolved_file "${rpaths}")
     endif()
+    get_filename_component(resolved_file "${resolved_file}" ABSOLUTE) # canonicalize path
 
     string(TOLOWER "${original_file}" original_lower)
     string(TOLOWER "${resolved_file}" lower)
@@ -661,10 +663,28 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
   endif()
 
   set(gp_cmd_paths ${gp_cmd_paths}
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]/../../VC/bin"
+    "$ENV{VS140COMNTOOLS}/../../VC/bin"
+    "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]/../../VC/bin"
+    "$ENV{VS120COMNTOOLS}/../../VC/bin"
+    "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]/../../VC/bin"
+    "$ENV{VS110COMNTOOLS}/../../VC/bin"
+    "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/../../VC/bin"
+    "$ENV{VS100COMNTOOLS}/../../VC/bin"
+    "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]/../../VC/bin"
+    "$ENV{VS90COMNTOOLS}/../../VC/bin"
     "C:/Program Files/Microsoft Visual Studio 9.0/VC/bin"
     "C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]/../../VC/bin"
+    "$ENV{VS80COMNTOOLS}/../../VC/bin"
     "C:/Program Files/Microsoft Visual Studio 8/VC/BIN"
     "C:/Program Files (x86)/Microsoft Visual Studio 8/VC/BIN"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]/../../VC7/bin"
+    "$ENV{VS71COMNTOOLS}/../../VC7/bin"
     "C:/Program Files/Microsoft Visual Studio .NET 2003/VC7/BIN"
     "C:/Program Files (x86)/Microsoft Visual Studio .NET 2003/VC7/BIN"
     "/usr/local/bin"
@@ -726,7 +746,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
     set(gp_regex_error "")
     set(gp_regex_fallback "")
     set(gp_regex_cmp_count 1)
-    # objdump generaates copious output so we create a grep filter to pre-filter results
+    # objdump generates copious output so we create a grep filter to pre-filter results
     find_program(gp_grep_cmd grep)
     if(gp_grep_cmd)
       set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "^[[:blank:]]*DLL Name: ")
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index 2ff9aed..1c6e751 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -23,6 +23,11 @@
 #   Set to TRUE to install only the debug runtime libraries with MSVC
 #   tools even if the release runtime libraries are also available.
 #
+# ``CMAKE_INSTALL_UCRT_LIBRARIES``
+#   Set to TRUE to install the Windows Universal CRT libraries for
+#   app-local deployment (e.g. to Windows XP).  This is meaningful
+#   only with MSVC from Visual Studio 2015 or higher.
+#
 # ``CMAKE_INSTALL_MFC_LIBRARIES``
 #   Set to TRUE to install the MSVC MFC runtime libraries.
 #
@@ -171,12 +176,12 @@ if(MSVC)
     # Find the runtime library redistribution directory.
     get_filename_component(msvc_install_dir
       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE)
+    set(programfilesx86 "ProgramFiles(x86)")
     find_path(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT
       PATHS
         "${msvc_install_dir}/../../VC/redist"
         "${base_dir}/VC/redist"
         "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist"
-        set(programfilesx86 "ProgramFiles(x86)")
         "$ENV{${programfilesx86}}/Microsoft Visual Studio ${v}.0/VC/redist"
       )
     mark_as_advanced(MSVC${v}_REDIST_DIR)
@@ -207,6 +212,24 @@ if(MSVC)
         list(APPEND __install__libs "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll")
       endif()
     endif()
+
+    if(CMAKE_INSTALL_UCRT_LIBRARIES AND NOT v VERSION_LESS 14)
+      # Find the Windows Universal CRT redistribution directory.
+      get_filename_component(windows_kits_dir
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE)
+      set(programfilesx86 "ProgramFiles(x86)")
+      find_path(WINDOWS_KITS_REDIST_DIR NAMES ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
+        PATHS
+        "${windows_kits_dir}/Redist"
+        "$ENV{ProgramFiles}/Windows Kits/10/Redist"
+        "$ENV{${programfilesx86}}/Windows Kits/10/Redist"
+        )
+      mark_as_advanced(WINDOWS_KITS_REDIST_DIR)
+
+      # Glob the list of UCRT DLLs.
+      file(GLOB __ucrt_dlls "${WINDOWS_KITS_REDIST_DIR}/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
+      list(APPEND __install__libs ${__ucrt_dlls})
+    endif()
   endmacro()
 
   if(MSVC10)
diff --git a/Modules/MacOSXBundleInfo.plist.in b/Modules/MacOSXBundleInfo.plist.in
index a466dc7..a4009bc 100644
--- a/Modules/MacOSXBundleInfo.plist.in
+++ b/Modules/MacOSXBundleInfo.plist.in
@@ -28,8 +28,6 @@
 	<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
-	<key>LSRequiresCarbon</key>
-	<true/>
 	<key>NSHumanReadableCopyright</key>
 	<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
 </dict>
diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake
index 58c6483..551a995 100644
--- a/Modules/Platform/AIX.cmake
+++ b/Modules/Platform/AIX.cmake
@@ -8,7 +8,9 @@ set(CMAKE_DL_LIBS "-lld")
 # -Wl,-blibpath:/usr/lib:/lib whether RPATH support is on or not.
 # When our own RPATH is to be added it may be inserted before the
 # "always" paths.
-set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib /lib)
+if(NOT DEFINED CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH)
+  set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib /lib)
+endif()
 
 # Files named "libfoo.a" may actually be shared libraries.
 set_property(GLOBAL PROPERTY TARGET_ARCHIVES_MAY_BE_SHARED_LIBS 1)
diff --git a/Modules/Platform/CYGWIN-Clang-C.cmake b/Modules/Platform/CYGWIN-Clang-C.cmake
new file mode 100644
index 0000000..e8343a4
--- /dev/null
+++ b/Modules/Platform/CYGWIN-Clang-C.cmake
@@ -0,0 +1 @@
+include(Platform/CYGWIN-GNU-C)
diff --git a/Modules/Platform/CYGWIN-Clang-CXX.cmake b/Modules/Platform/CYGWIN-Clang-CXX.cmake
new file mode 100644
index 0000000..67775de
--- /dev/null
+++ b/Modules/Platform/CYGWIN-Clang-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/CYGWIN-GNU-CXX)
diff --git a/Modules/Platform/Darwin-Clang.cmake b/Modules/Platform/Darwin-Clang.cmake
index 4cded47..61a5e0c 100644
--- a/Modules/Platform/Darwin-Clang.cmake
+++ b/Modules/Platform/Darwin-Clang.cmake
@@ -24,7 +24,7 @@ macro(__darwin_compiler_clang lang)
   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)
+  if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.2)
     set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
   endif()
 endmacro()
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index a08411b..91c2cf3 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -90,16 +90,6 @@ elseif("${CMAKE_GENERATOR}" MATCHES Xcode
       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()
     if(NOT CMAKE_OSX_DEPLOYMENT_TARGET AND _CURRENT_OSX_VERSION VERSION_LESS _CMAKE_OSX_DEPLOYMENT_TARGET)
       set(CMAKE_OSX_DEPLOYMENT_TARGET ${_CURRENT_OSX_VERSION} CACHE STRING
         "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value." FORCE)
diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake
index 9eb7a8a..6e6b4ff 100644
--- a/Modules/Platform/GHS-MULTI-Initialize.cmake
+++ b/Modules/Platform/GHS-MULTI-Initialize.cmake
@@ -15,7 +15,7 @@
 #Setup Greenhills MULTI specific compilation information
 
 if (NOT GHS_INT_DIRECTORY)
-  #Assume the C:/ghs/int#### directory that is latest is prefered
+  #Assume the C:/ghs/int#### directory that is latest is preferred
   set(GHS_EXPECTED_ROOT "C:/ghs")
   if (EXISTS ${GHS_EXPECTED_ROOT})
     FILE(GLOB GHS_CANDIDATE_INT_DIRS RELATIVE
diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake
index 88932ad..9572a7e 100644
--- a/Modules/Platform/HP-UX.cmake
+++ b/Modules/Platform/HP-UX.cmake
@@ -1,4 +1,6 @@
-set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib)
+if(NOT DEFINED CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH)
+  set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib)
+endif()
 
 if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "ia64")
   set(CMAKE_SHARED_LIBRARY_SUFFIX ".sl")          # .so
diff --git a/Modules/Platform/SunOS-PathScale-C.cmake b/Modules/Platform/SunOS-PathScale-C.cmake
new file mode 100644
index 0000000..2f78da1
--- /dev/null
+++ b/Modules/Platform/SunOS-PathScale-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/SunOS-PathScale)
+__sunos_compiler_pathscale(C)
diff --git a/Modules/Platform/SunOS-PathScale-CXX.cmake b/Modules/Platform/SunOS-PathScale-CXX.cmake
new file mode 100644
index 0000000..bb79d86
--- /dev/null
+++ b/Modules/Platform/SunOS-PathScale-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/SunOS-PathScale)
+__sunos_compiler_pathscale(CXX)
diff --git a/Modules/Platform/SunOS-PathScale-Fortran.cmake b/Modules/Platform/SunOS-PathScale-Fortran.cmake
new file mode 100644
index 0000000..3c202f7
--- /dev/null
+++ b/Modules/Platform/SunOS-PathScale-Fortran.cmake
@@ -0,0 +1,2 @@
+include(Platform/SunOS-PathScale)
+__sunos_compiler_pathscale(Fortran)
diff --git a/Modules/Platform/SunOS-PathScale.cmake b/Modules/Platform/SunOS-PathScale.cmake
new file mode 100644
index 0000000..1afe56a
--- /dev/null
+++ b/Modules/Platform/SunOS-PathScale.cmake
@@ -0,0 +1,31 @@
+
+#=============================================================================
+# Copyright 2016 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 module is shared by multiple languages; use include blocker.
+if(__SUNOS_COMPILER_PATHSCALE)
+  return()
+endif()
+set(__SUNOS_COMPILER_PATHSCALE 1)
+
+macro(__sunos_compiler_pathscale lang)
+  # Shared library compile and link flags.
+  set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
+  set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+  set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
+  set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
+
+  set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-R")
+  set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
+  set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-h")
+endmacro()
diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake
index 0f9a10a..1b93db8 100644
--- a/Modules/Platform/Windows-Intel-Fortran.cmake
+++ b/Modules/Platform/Windows-Intel-Fortran.cmake
@@ -6,6 +6,6 @@ set(CMAKE_Fortran_STANDARD_LIBRARIES_INIT "user32.lib")
 __windows_compiler_intel(Fortran)
 set (CMAKE_Fortran_FLAGS_INIT "/W1 /nologo /fpp /libs:dll /threads")
 set (CMAKE_Fortran_FLAGS_DEBUG_INIT "/Od /debug:full /dbglibs")
-set (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O1 /D NDEBUG")
-set (CMAKE_Fortran_FLAGS_RELEASE_INIT "/O2 /D NDEBUG")
-set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O2 /debug:full /D NDEBUG")
+set (CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O1 /DNDEBUG")
+set (CMAKE_Fortran_FLAGS_RELEASE_INIT "/O2 /DNDEBUG")
+set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O2 /debug:full /DNDEBUG")
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index a61413a..6c254ed 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -47,10 +47,6 @@ else()
 endif()
 
 set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1)
-if(CMAKE_GENERATOR MATCHES "Visual Studio 6")
-   set (CMAKE_NO_BUILD_TYPE 1)
-   set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 0) # not implemented for VS6
-endif()
 if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio")
   set (CMAKE_NO_BUILD_TYPE 1)
 endif()
@@ -194,8 +190,14 @@ else()
   if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
     set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
   elseif(MSVC_VERSION GREATER 1310)
-    set(_RTC1 "/RTC1")
-    set(_FLAGS_CXX " /GR /EHsc")
+    if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
+      # Clang/C2 in MSVC14 Update 1 seems to not support -fsantinize (yet?)
+      # set(_RTC1 "-fsantinize=memory,safe-stack")
+      set(_FLAGS_CXX " -frtti -fexceptions")
+    else()
+      set(_RTC1 "/RTC1")
+      set(_FLAGS_CXX " /GR /EHsc")
+    endif()
     set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib")
   else()
     set(_RTC1 "/GZ")
@@ -296,11 +298,21 @@ macro(__windows_compiler_msvc lang)
   set(CMAKE_${lang}_LINK_EXECUTABLE
     "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
 
-  set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}")
-  set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}")
-  set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG")
-  set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG")
-  set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG")
+  if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
+    # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects
+    # that include MS's own headers. CMake itself is affected project too.
+    set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}")
+    set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-D_DEBUG /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}")
+    set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD -O2 -DNDEBUG")
+    set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD -gline-tables-only -O2 -fno-inline -DNDEBUG")
+    set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang
+  else()
+    set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}")
+    set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}")
+    set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /DNDEBUG")
+    set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /DNDEBUG")
+    set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /DNDEBUG")
+  endif()
   set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON)
   set(CMAKE_NINJA_DEPTYPE_${lang} msvc)
 
diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake
index 0beba73..b31cb11 100644
--- a/Modules/Platform/Windows-df.cmake
+++ b/Modules/Platform/Windows-df.cmake
@@ -30,9 +30,6 @@ set(CMAKE_Fortran_LINK_EXECUTABLE
 set(CMAKE_CREATE_WIN32_EXE /winapp)
 set(CMAKE_CREATE_CONSOLE_EXE )
 
-if(CMAKE_GENERATOR MATCHES "Visual Studio 6")
-   set (CMAKE_NO_BUILD_TYPE 1)
-endif()
 if(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8")
   set (CMAKE_NO_BUILD_TYPE 1)
 endif()
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake
index fcb41ab..fdc3adb 100644
--- a/Modules/TestBigEndian.cmake
+++ b/Modules/TestBigEndian.cmake
@@ -104,7 +104,7 @@ macro(TEST_BIG_ENDIAN VARIABLE)
           message(SEND_ERROR "TEST_BIG_ENDIAN found no result!")
         endif()
 
-        file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+        file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
           "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
 
       else()
diff --git a/Modules/TestForANSIStreamHeaders.cxx b/Modules/TestForANSIStreamHeaders.cxx
index cfb7686..d314d58 100644
--- a/Modules/TestForANSIStreamHeaders.cxx
+++ b/Modules/TestForANSIStreamHeaders.cxx
@@ -1,6 +1,6 @@
 #include <iostream>
 
-int main(int,char *[])
+int main(int, char* [])
 {
   return 0;
 }
diff --git a/Modules/TestForAnsiForScope.cxx b/Modules/TestForAnsiForScope.cxx
index e8807ab..4bc2c67 100644
--- a/Modules/TestForAnsiForScope.cxx
+++ b/Modules/TestForAnsiForScope.cxx
@@ -1,7 +1,8 @@
-int main(int, char*[])
+int main(int, char* [])
 {
   int i;
-  for(int i=0; i < 1; ++i);
+  for (int i = 0; i < 1; ++i)
+    ;
   (void)i;
   return 0;
 }
diff --git a/Modules/TestForSSTREAM.cxx b/Modules/TestForSSTREAM.cxx
index 1c939da..83a75e4 100644
--- a/Modules/TestForSSTREAM.cxx
+++ b/Modules/TestForSSTREAM.cxx
@@ -1,11 +1,10 @@
 #include <sstream>
-int main(int, char*[])
+int main(int, char* [])
 {
   std::ostringstream os;
   os << "12345";
-  if(os.str().size() == 5)
-    {
+  if (os.str().size() == 5) {
     return 0;
-    }
+  }
   return -1;
 }
diff --git a/Modules/TestForSTDNamespace.cxx b/Modules/TestForSTDNamespace.cxx
index b537d44..62951ff 100644
--- a/Modules/TestForSTDNamespace.cxx
+++ b/Modules/TestForSTDNamespace.cxx
@@ -1,5 +1,5 @@
 #include <list>
-int main(int, char*[])
+int main(int, char* [])
 {
   std::list<int>();
   return 0;
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 475ad5e..7b3416e 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -169,7 +169,7 @@
 #
 # ::
 #
-#    The add_jar() functions sets some target properties. You can get these
+#    The add_jar() function sets some target properties. You can get these
 #    properties with the
 #       get_property(TARGET <target_name> PROPERTY <propery_name>)
 #    command.
@@ -324,7 +324,7 @@
 # that allow your Java and C code to interact.
 #
 # There are two main signatures for create_javah.  The first signature
-# returns generated files throught variable specified by GENERATED_FILES option:
+# returns generated files through variable specified by GENERATED_FILES option:
 #
 # ::
 #
@@ -389,7 +389,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
 function (__java_copy_file src dest comment)
     add_custom_command(
         OUTPUT  ${dest}
-        COMMAND cmake -E copy_if_different
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different
         ARGS    ${src}
                 ${dest}
         DEPENDS ${src}
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index a3b73bb..2669a84 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -36,7 +36,7 @@
 #      PREFIX ClimbingStats
 #      OUTPUT_FILES_VAR support_files
 #      OUTPUT_DIR compilers
-#      COMPILERS GNU Clang MSVC
+#      COMPILERS GNU Clang MSVC Intel
 #      FEATURES cxx_variadic_templates
 #    )
 #    install(FILES
@@ -100,7 +100,7 @@
 #    write_compiler_detection_header(
 #      FILE climbingstats_compiler_detection.h
 #      PREFIX ClimbingStats
-#      COMPILERS GNU Clang AppleClang MSVC
+#      COMPILERS GNU Clang AppleClang MSVC Intel
 #      FEATURES cxx_variadic_templates
 #    )
 #
@@ -323,6 +323,7 @@ function(write_compiler_detection_header
     AppleClang
     MSVC
     SunPro
+    Intel
   )
 
   set(_hex_compilers ADSP Borland Embarcadero SunPro)
diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in
index 118de16..7cfbcbd 100644
--- a/Modules/exportheader.cmake.in
+++ b/Modules/exportheader.cmake.in
@@ -33,9 +33,10 @@
 #  define @DEPRECATED_MACRO_NAME at _NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEPRECATED_MACRO_NAME@
 #endif
 
-#cmakedefine01 DEFINE_NO_DEPRECATED
-#if DEFINE_NO_DEPRECATED
-# define @NO_DEPRECATED_MACRO_NAME@
+#if @DEFINE_NO_DEPRECATED@ /* DEFINE_NO_DEPRECATED */
+#  ifndef @NO_DEPRECATED_MACRO_NAME@
+#    define @NO_DEPRECATED_MACRO_NAME@
+#  endif
 #endif
 
 #endif
diff --git a/Packaging/CMakeDMGSetup.scpt b/Packaging/CMakeDMGSetup.scpt
index c7ddcfb..37e7bd1 100644
--- a/Packaging/CMakeDMGSetup.scpt
+++ b/Packaging/CMakeDMGSetup.scpt
@@ -4,6 +4,21 @@ on run argv
   tell application "Finder"
   tell disk image_name
 
+    -- wait for the image to finish mounting
+    set open_attempts to 0
+    repeat while open_attempts < 4
+      try
+        open
+          delay 1
+          set open_attempts to 5
+        close
+      on error errStr number errorNumber
+        set open_attempts to open_attempts + 1
+        delay 10
+      end try
+    end repeat
+    delay 5
+
     -- open the image the first time and save a DS_Store with just
     -- background and icon setup
     open
@@ -12,7 +27,7 @@ on run argv
       set background picture of theViewOptions to file ".background:background.tif"
       set arrangement of theViewOptions to not arranged
       set icon size of theViewOptions to 128
-      delay 1
+      delay 5
     close
 
     -- next setup the position of the app and Applications symlink
@@ -28,7 +43,7 @@ on run argv
         set position of item "Applications" to { 378, 200 }
       end tell
       update without registering applications
-      delay 1
+      delay 5
     close
 
     -- one last open and close so you can see everything looks correct
diff --git a/README.rst b/README.rst
index 9599a04..4188ea0 100644
--- a/README.rst
+++ b/README.rst
@@ -89,7 +89,7 @@ If you have found a bug:
 3. Finally, if the issue is not resolved by the above steps, open
    an entry in the `CMake Issue Tracker`_.
 
-.. _`CMake Issue Tracker`: https://cmake.org/Bug
+.. _`CMake Issue Tracker`: https://gitlab.kitware.com/cmake/cmake/issues
 
 Contributing
 ============
diff --git a/Source/.gitattributes b/Source/.gitattributes
index cf4dabd..bd25ea8 100644
--- a/Source/.gitattributes
+++ b/Source/.gitattributes
@@ -1,2 +1,5 @@
 # Preserve upstream indentation style.
 cm_sha2.*        whitespace=indent-with-non-tab
+
+# Preserve indentation style in generated code.
+cmListFileLexer.c       whitespace=-tab-in-indent,-indent-with-non-tab
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 4ef0e80..3223831 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -452,8 +452,6 @@ if (WIN32)
       cmGlobalNMakeMakefileGenerator.h
       cmGlobalJOMMakefileGenerator.cxx
       cmGlobalJOMMakefileGenerator.h
-      cmGlobalVisualStudio6Generator.cxx
-      cmGlobalVisualStudio6Generator.h
       cmGlobalVisualStudio71Generator.cxx
       cmGlobalVisualStudio71Generator.h
       cmGlobalVisualStudio7Generator.cxx
@@ -481,8 +479,6 @@ if (WIN32)
       cmIDEFlagTable.h
       cmIDEOptions.cxx
       cmIDEOptions.h
-      cmLocalVisualStudio6Generator.cxx
-      cmLocalVisualStudio6Generator.h
       cmLocalVisualStudio7Generator.cxx
       cmLocalVisualStudio7Generator.h
       cmLocalVisualStudioGenerator.cxx
@@ -666,6 +662,7 @@ set(CPACK_SRCS
   CPack/cmCPackNSISGenerator.cxx
   CPack/IFW/cmCPackIFWPackage.cxx
   CPack/IFW/cmCPackIFWInstaller.cxx
+  CPack/IFW/cmCPackIFWRepository.cxx
   CPack/IFW/cmCPackIFWGenerator.cxx
   CPack/cmCPackSTGZGenerator.cxx
   CPack/cmCPackTGZGenerator.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index dea1541..99ed63b 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 5)
-set(CMake_VERSION_PATCH 2)
+set(CMake_VERSION_MINOR 6)
+set(CMake_VERSION_PATCH 0)
 #set(CMake_VERSION_RC 0)
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index 4eb23c1..c1ff526 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -12,57 +12,48 @@
 
 #include "cmCPackIFWGenerator.h"
 
-#include "cmCPackIFWPackage.h"
-#include "cmCPackIFWInstaller.h"
-
-#include <CPack/cmCPackLog.h>
 #include <CPack/cmCPackComponentGroup.h>
+#include <CPack/cmCPackLog.h>
 
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/Directory.hxx>
+#include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
+#include <cmsys/SystemTools.hxx>
 
+#include <cmGeneratedFileStream.h>
 #include <cmGlobalGenerator.h>
-#include <cmSystemTools.h>
 #include <cmMakefile.h>
-#include <cmGeneratedFileStream.h>
-#include <cmXMLSafe.h>
-#include <cmVersionConfig.h>
+#include <cmSystemTools.h>
 #include <cmTimestamp.h>
+#include <cmVersionConfig.h>
+#include <cmXMLWriter.h>
 
-//----------------------------------------------------------------------------
 cmCPackIFWGenerator::cmCPackIFWGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
 cmCPackIFWGenerator::~cmCPackIFWGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWGenerator::IsVersionLess(const char *version)
+bool cmCPackIFWGenerator::IsVersionLess(const char* version)
 {
   return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
-    FrameworkVersion.data(), version);
+                                       FrameworkVersion.data(), version);
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWGenerator::IsVersionGreater(const char *version)
+bool cmCPackIFWGenerator::IsVersionGreater(const char* version)
 {
   return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
-    FrameworkVersion.data(), version);
+                                       FrameworkVersion.data(), version);
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWGenerator::IsVersionEqual(const char *version)
+bool cmCPackIFWGenerator::IsVersionEqual(const char* version)
 {
   return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
-    FrameworkVersion.data(), version);
+                                       FrameworkVersion.data(), version);
 }
 
-//----------------------------------------------------------------------------
 int cmCPackIFWGenerator::PackageFiles()
 {
   cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Configuration" << std::endl);
@@ -78,175 +69,153 @@ int cmCPackIFWGenerator::PackageFiles()
   ifwTmpFile += "/IFWOutput.log";
 
   // Run repogen
-  if (!Installer.Repositories.empty())
-    {
+  if (!Installer.RemoteRepositories.empty()) {
     std::string ifwCmd = RepoGen;
 
-    if(IsVersionLess("2.0.0"))
-      {
+    if (IsVersionLess("2.0.0")) {
       ifwCmd += " -c " + this->toplevel + "/config/config.xml";
-      }
+    }
 
     ifwCmd += " -p " + this->toplevel + "/packages";
 
-    if(!PkgsDirsVector.empty())
-      {
-      for(std::vector<std::string>::iterator it = PkgsDirsVector.begin();
-          it != PkgsDirsVector.end(); ++it)
-        {
+    if (!PkgsDirsVector.empty()) {
+      for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
+           it != PkgsDirsVector.end(); ++it) {
         ifwCmd += " -p " + *it;
-        }
       }
+    }
 
-    if (!OnlineOnly && !DownloadedPackages.empty())
-      {
+    if (!OnlineOnly && !DownloadedPackages.empty()) {
       ifwCmd += " -i ";
-      std::set<cmCPackIFWPackage*>::iterator it
-        = DownloadedPackages.begin();
+      std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
       ifwCmd += (*it)->Name;
       ++it;
-      while(it != DownloadedPackages.end())
-        {
+      while (it != DownloadedPackages.end()) {
         ifwCmd += "," + (*it)->Name;
         ++it;
-        }
       }
+    }
     ifwCmd += " " + this->toplevel + "/repository";
-    cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd
-                  << std::endl);
+    cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
     std::string output;
     int retVal = 1;
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-                  "- Generate repository" << std::endl);
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository"
+                    << std::endl);
     bool res = cmSystemTools::RunSingleCommand(
-      ifwCmd.c_str(), &output, &output,
-      &retVal, 0, this->GeneratorVerbose, 0);
-    if ( !res || retVal )
-      {
+      ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+    if (!res || retVal) {
       cmGeneratedFileStream ofs(ifwTmpFile.c_str());
       ofs << "# Run command: " << ifwCmd << std::endl
           << "# Output:" << std::endl
           << output << std::endl;
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
-                    << ifwCmd << std::endl
-                    << "Please check " << ifwTmpFile << " for errors"
-                    << std::endl);
+                      << ifwCmd << std::endl
+                      << "Please check " << ifwTmpFile << " for errors"
+                      << std::endl);
       return 0;
-      }
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " << this->toplevel
-                  << "/repository generated" << std::endl);
     }
 
+    if (!Repository.RepositoryUpdate.empty() &&
+        !Repository.PatchUpdatesXml()) {
+      cmCPackLogger(cmCPackLog::LOG_WARNING, "Problem patch IFW \"Updates\" "
+                      << "file: " << this->toplevel + "/repository/Updates.xml"
+                      << std::endl);
+    }
+
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: "
+                    << this->toplevel << "/repository generated" << std::endl);
+  }
+
   // Run binary creator
   {
-  std::string ifwCmd = BinCreator;
-  ifwCmd += " -c " + this->toplevel + "/config/config.xml";
-  ifwCmd += " -p " + this->toplevel + "/packages";
-
-  if(!PkgsDirsVector.empty())
-    {
-    for(std::vector<std::string>::iterator it = PkgsDirsVector.begin();
-        it != PkgsDirsVector.end(); ++it)
-      {
-      ifwCmd += " -p " + *it;
+    std::string ifwCmd = BinCreator;
+    ifwCmd += " -c " + this->toplevel + "/config/config.xml";
+    ifwCmd += " -p " + this->toplevel + "/packages";
+
+    if (!PkgsDirsVector.empty()) {
+      for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
+           it != PkgsDirsVector.end(); ++it) {
+        ifwCmd += " -p " + *it;
       }
     }
 
-  if (OnlineOnly)
-    {
-    ifwCmd += " --online-only";
-    }
-  else if (!DownloadedPackages.empty() && !Installer.Repositories.empty())
-    {
-    ifwCmd += " -e ";
-    std::set<cmCPackIFWPackage*>::iterator it
-      = DownloadedPackages.begin();
-    ifwCmd += (*it)->Name;
-    ++it;
-    while(it != DownloadedPackages.end())
-      {
-      ifwCmd += "," + (*it)->Name;
+    if (OnlineOnly) {
+      ifwCmd += " --online-only";
+    } else if (!DownloadedPackages.empty() &&
+               !Installer.RemoteRepositories.empty()) {
+      ifwCmd += " -e ";
+      std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
+      ifwCmd += (*it)->Name;
       ++it;
+      while (it != DownloadedPackages.end()) {
+        ifwCmd += "," + (*it)->Name;
+        ++it;
       }
-    }
-  else if (!DependentPackages.empty())
-    {
-    ifwCmd += " -i ";
-    // Binary
-    std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
-    while(bit != BinaryPackages.end())
-      {
-      ifwCmd += (*bit)->Name + ",";
-      ++bit;
+    } else if (!DependentPackages.empty()) {
+      ifwCmd += " -i ";
+      // Binary
+      std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
+      while (bit != BinaryPackages.end()) {
+        ifwCmd += (*bit)->Name + ",";
+        ++bit;
       }
-    // Depend
-    DependenceMap::iterator it = DependentPackages.begin();
-    ifwCmd += it->second.Name;
-    ++it;
-    while(it != DependentPackages.end())
-      {
-      ifwCmd += "," + it->second.Name;
+      // Depend
+      DependenceMap::iterator it = DependentPackages.begin();
+      ifwCmd += it->second.Name;
       ++it;
+      while (it != DependentPackages.end()) {
+        ifwCmd += "," + it->second.Name;
+        ++it;
       }
     }
-  // TODO: set correct name for multipackages
-  if (!this->packageFileNames.empty())
-    {
-    ifwCmd += " " + packageFileNames[0];
-    }
-  else
-    {
-    ifwCmd += " installer";
+    // TODO: set correct name for multipackages
+    if (!this->packageFileNames.empty()) {
+      ifwCmd += " " + packageFileNames[0];
+    } else {
+      ifwCmd += " installer";
     }
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd
-                << std::endl);
-  std::string output;
-  int retVal = 1;
-  cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
-  bool res = cmSystemTools::RunSingleCommand(
-    ifwCmd.c_str(), &output, &output,
-    &retVal, 0, this->GeneratorVerbose, 0);
-  if ( !res || retVal )
-    {
-    cmGeneratedFileStream ofs(ifwTmpFile.c_str());
-    ofs << "# Run command: " << ifwCmd << std::endl
-        << "# Output:" << std::endl
-        << output << std::endl;
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
-                  << ifwCmd << std::endl
-                  << "Please check " << ifwTmpFile << " for errors"
-                  << std::endl);
-    return 0;
+    cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
+    std::string output;
+    int retVal = 1;
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
+    bool res = cmSystemTools::RunSingleCommand(
+      ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+    if (!res || retVal) {
+      cmGeneratedFileStream ofs(ifwTmpFile.c_str());
+      ofs << "# Run command: " << ifwCmd << std::endl
+          << "# Output:" << std::endl
+          << output << std::endl;
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: "
+                      << ifwCmd << std::endl
+                      << "Please check " << ifwTmpFile << " for errors"
+                      << std::endl);
+      return 0;
     }
   }
 
   return 1;
 }
 
-//----------------------------------------------------------------------------
-const char *cmCPackIFWGenerator::GetPackagingInstallPrefix()
+const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
 {
-  const char *defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
+  const char* defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
 
   std::string tmpPref = defPrefix ? defPrefix : "";
 
-  if(this->Components.empty())
-    {
+  if (this->Components.empty()) {
     tmpPref += "packages/" + GetRootPackageName() + "/data";
-    }
+  }
 
   this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str());
 
   return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX");
 }
 
-//----------------------------------------------------------------------------
-const char *cmCPackIFWGenerator::GetOutputExtension()
+const char* cmCPackIFWGenerator::GetOutputExtension()
 {
   return ExecutableSuffix.c_str();
 }
 
-//----------------------------------------------------------------------------
 int cmCPackIFWGenerator::InitializeInternal()
 {
   // Search Qt Installer Framework tools
@@ -255,56 +224,43 @@ int cmCPackIFWGenerator::InitializeInternal()
   const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE";
   const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION";
 
-  if(!this->IsSet(BinCreatorOpt) ||
-     !this->IsSet(RepoGenOpt) ||
-     !this->IsSet(FrameworkVersionOpt))
-    {
+  if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) ||
+      !this->IsSet(FrameworkVersionOpt)) {
     this->ReadListFile("CPackIFW.cmake");
-    }
+  }
 
   // Look 'binarycreator' executable (needs)
 
-  const char *BinCreatorStr = this->GetOption(BinCreatorOpt);
-  if(!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr))
-    {
+  const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
+  if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) {
     BinCreator = "";
-    }
-  else
-    {
+  } else {
     BinCreator = BinCreatorStr;
-    }
+  }
 
-  if (BinCreator.empty())
-    {
+  if (BinCreator.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "Cannot find QtIFW compiler \"binarycreator\": "
                   "likely it is not installed, or not in your PATH"
-                  << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
 
   // Look 'repogen' executable (optional)
 
-  const char *RepoGenStr = this->GetOption(RepoGenOpt);
-  if(!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr))
-    {
+  const char* RepoGenStr = this->GetOption(RepoGenOpt);
+  if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) {
     RepoGen = "";
-    }
-  else
-    {
+  } else {
     RepoGen = RepoGenStr;
-    }
+  }
 
   // Framework version
-  if(const char* FrameworkVersionSrt =
-      this->GetOption(FrameworkVersionOpt))
-    {
+  if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) {
     FrameworkVersion = FrameworkVersionSrt;
-    }
-  else
-    {
+  } else {
     FrameworkVersion = "1.9.9";
-    }
+  }
 
   // Variables that Change Behavior
 
@@ -313,316 +269,304 @@ int cmCPackIFWGenerator::InitializeInternal()
 
   // Additional packages dirs
   PkgsDirsVector.clear();
-  if(const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES"))
-    {
-    cmSystemTools::ExpandListArgument(dirs,
-                                      PkgsDirsVector);
-    }
+  if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
+    cmSystemTools::ExpandListArgument(dirs, PkgsDirsVector);
+  }
 
   // Installer
   Installer.Generator = this;
   Installer.ConfigureFromOptions();
 
-  if (const char* ifwDownloadAll =
-      this->GetOption("CPACK_IFW_DOWNLOAD_ALL"))
-    {
-    OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
+  // Repository
+  Repository.Generator = this;
+  Repository.Name = "Unspecified";
+  if (const char* site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
+    Repository.Url = site;
+    Installer.RemoteRepositories.push_back(&Repository);
+  }
+
+  // Repositories
+  if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
+    std::vector<std::string> RepoAllVector;
+    cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector);
+    for (std::vector<std::string>::iterator rit = RepoAllVector.begin();
+         rit != RepoAllVector.end(); ++rit) {
+      GetRepository(*rit);
     }
-  else if (const char* cpackDownloadAll =
-           this->GetOption("CPACK_DOWNLOAD_ALL"))
-    {
+  }
+
+  if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
+    OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
+  } else if (const char* cpackDownloadAll =
+               this->GetOption("CPACK_DOWNLOAD_ALL")) {
     OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll);
-    }
-  else
-    {
+  } else {
     OnlineOnly = false;
-    }
+  }
 
-  if (!Installer.Repositories.empty() && RepoGen.empty()) {
-  cmCPackLogger(cmCPackLog::LOG_ERROR,
-                "Cannot find QtIFW repository generator \"repogen\": "
-                "likely it is not installed, or not in your PATH"
-                << std::endl);
-  return 0;
+  if (!Installer.RemoteRepositories.empty() && RepoGen.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Cannot find QtIFW repository generator \"repogen\": "
+                  "likely it is not installed, or not in your PATH"
+                    << std::endl);
+    return 0;
   }
 
   // Executable suffix
-  if(const char *optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX"))
-    {
+  if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) {
     ExecutableSuffix = optExeSuffix;
-    if(ExecutableSuffix.empty())
-      {
+    if (ExecutableSuffix.empty()) {
       std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
-      if(sysName == "Linux")
-        {
+      if (sysName == "Linux") {
         ExecutableSuffix = ".run";
-        }
       }
     }
-  else
-    {
+  } else {
     ExecutableSuffix = cmCPackGenerator::GetOutputExtension();
-    }
+  }
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
+std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
   const std::string& componentName)
 {
   const std::string prefix = "packages/";
   const std::string suffix = "/data";
 
   if (componentPackageMethod == ONE_PACKAGE) {
-  return std::string(prefix + GetRootPackageName() + suffix);
+    return std::string(prefix + GetRootPackageName() + suffix);
   }
 
-  return prefix
-    + GetComponentPackageName(&Components[componentName])
-    + suffix;
+  return prefix + GetComponentPackageName(&Components[componentName]) + suffix;
 }
 
-//----------------------------------------------------------------------------
-cmCPackComponent*
-cmCPackIFWGenerator::GetComponent(const std::string &projectName,
-                                  const std::string &componentName)
+cmCPackComponent* cmCPackIFWGenerator::GetComponent(
+  const std::string& projectName, const std::string& componentName)
 {
   ComponentsMap::iterator cit = Components.find(componentName);
-  if ( cit != Components.end() ) return &(cit->second);
+  if (cit != Components.end())
+    return &(cit->second);
 
-  cmCPackComponent* component
-    = cmCPackGenerator::GetComponent(projectName, componentName);
-  if(!component) return component;
+  cmCPackComponent* component =
+    cmCPackGenerator::GetComponent(projectName, componentName);
+  if (!component)
+    return component;
 
   std::string name = GetComponentPackageName(component);
   PackagesMap::iterator pit = Packages.find(name);
-  if(pit != Packages.end()) return component;
+  if (pit != Packages.end())
+    return component;
 
-  cmCPackIFWPackage *package = &Packages[name];
+  cmCPackIFWPackage* package = &Packages[name];
   package->Name = name;
   package->Generator = this;
-  if(package->ConfigureFromComponent(component))
-    {
+  if (package->ConfigureFromComponent(component)) {
     package->Installer = &Installer;
     Installer.Packages.insert(
-      std::pair<std::string, cmCPackIFWPackage*>(
-        name, package));
+      std::pair<std::string, cmCPackIFWPackage*>(name, package));
     ComponentPackages.insert(
-      std::pair<cmCPackComponent*, cmCPackIFWPackage*>(
-        component, package));
-    if(component->IsDownloaded)
-      {
+      std::pair<cmCPackComponent*, cmCPackIFWPackage*>(component, package));
+    if (component->IsDownloaded) {
       DownloadedPackages.insert(package);
-      }
-    else
-      {
+    } else {
       BinaryPackages.insert(package);
-      }
     }
-  else
-    {
+  } else {
     Packages.erase(name);
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-                  "Cannot configure package \"" << name <<
-                  "\" for component \"" << component->Name << "\""
-                  << std::endl);
-    }
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
+                    << name << "\" for component \"" << component->Name << "\""
+                    << std::endl);
+  }
 
   return component;
 }
 
-//----------------------------------------------------------------------------
-cmCPackComponentGroup*
-cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName,
-                                       const std::string &groupName)
+cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
+  const std::string& projectName, const std::string& groupName)
 {
-  cmCPackComponentGroup* group
-    = cmCPackGenerator::GetComponentGroup(projectName, groupName);
-  if(!group) return group;
+  cmCPackComponentGroup* group =
+    cmCPackGenerator::GetComponentGroup(projectName, groupName);
+  if (!group)
+    return group;
 
   std::string name = GetGroupPackageName(group);
   PackagesMap::iterator pit = Packages.find(name);
-  if(pit != Packages.end()) return group;
+  if (pit != Packages.end())
+    return group;
 
-  cmCPackIFWPackage *package = &Packages[name];
+  cmCPackIFWPackage* package = &Packages[name];
   package->Name = name;
   package->Generator = this;
-  if(package->ConfigureFromGroup(group))
-    {
+  if (package->ConfigureFromGroup(group)) {
     package->Installer = &Installer;
     Installer.Packages.insert(
-      std::pair<std::string, cmCPackIFWPackage*>(
-        name, package));
+      std::pair<std::string, cmCPackIFWPackage*>(name, package));
     GroupPackages.insert(
-      std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(
-        group, package));
+      std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(group, package));
     BinaryPackages.insert(package);
-    }
-  else
-    {
+  } else {
     Packages.erase(name);
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-                  "Cannot configure package \"" << name <<
-                  "\" for component group \"" << group->Name << "\""
-                  << std::endl);
-    }
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
+                    << name << "\" for component group \"" << group->Name
+                    << "\"" << std::endl);
+  }
   return group;
 }
 
-//----------------------------------------------------------------------------
 enum cmCPackGenerator::CPackSetDestdirSupport
 cmCPackIFWGenerator::SupportsSetDestdir() const
 {
   return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED;
 }
 
-//----------------------------------------------------------------------------
 bool cmCPackIFWGenerator::SupportsAbsoluteDestination() const
 {
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmCPackIFWGenerator::SupportsComponentInstallation() const
 {
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmCPackIFWGenerator::IsOnePackage() const
 {
   return componentPackageMethod == ONE_PACKAGE;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCPackIFWGenerator::GetRootPackageName()
 {
   // Default value
   std::string name = "root";
   if (const char* optIFW_PACKAGE_GROUP =
-      this->GetOption("CPACK_IFW_PACKAGE_GROUP"))
-    {
+        this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
     // Configure from root group
     cmCPackIFWPackage package;
     package.Generator = this;
     package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
     name = package.Name;
-    }
-  else if (const char* optIFW_PACKAGE_NAME =
-           this->GetOption("CPACK_IFW_PACKAGE_NAME"))
-    {
+  } else if (const char* optIFW_PACKAGE_NAME =
+               this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
     // Configure from root package name
     name = optIFW_PACKAGE_NAME;
-    }
-  else if (const char* optPACKAGE_NAME =
-           this->GetOption("CPACK_PACKAGE_NAME"))
-    {
+  } else if (const char* optPACKAGE_NAME =
+               this->GetOption("CPACK_PACKAGE_NAME")) {
     // Configure from package name
     name = optPACKAGE_NAME;
-    }
+  }
   return name;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmCPackIFWGenerator::GetGroupPackageName(cmCPackComponentGroup *group) const
+std::string cmCPackIFWGenerator::GetGroupPackageName(
+  cmCPackComponentGroup* group) const
 {
   std::string name;
-  if (!group) return name;
-  if (cmCPackIFWPackage* package = GetGroupPackage(group))
-    {
+  if (!group)
+    return name;
+  if (cmCPackIFWPackage* package = GetGroupPackage(group)) {
     return package->Name;
-    }
-  const char* option = GetOption(
-    "CPACK_IFW_COMPONENT_GROUP_"
-    + cmsys::SystemTools::UpperCase(group->Name)
-    + "_NAME");
+  }
+  const char* option =
+    GetOption("CPACK_IFW_COMPONENT_GROUP_" +
+              cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
   name = option ? option : group->Name;
-  if(group->ParentGroup)
-    {
+  if (group->ParentGroup) {
     cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup);
     bool dot = !ResolveDuplicateNames;
-    if(dot && name.substr(0, package->Name.size()) == package->Name)
-      {
+    if (dot && name.substr(0, package->Name.size()) == package->Name) {
       dot = false;
-      }
-    if(dot)
-      {
+    }
+    if (dot) {
       name = package->Name + "." + name;
-      }
     }
+  }
   return name;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCPackIFWGenerator::GetComponentPackageName(
-  cmCPackComponent *component) const
+  cmCPackComponent* component) const
 {
   std::string name;
-  if (!component) return name;
-  if (cmCPackIFWPackage* package = GetComponentPackage(component))
-    {
+  if (!component)
+    return name;
+  if (cmCPackIFWPackage* package = GetComponentPackage(component)) {
     return package->Name;
-    }
-  std::string prefix = "CPACK_IFW_COMPONENT_"
-    + cmsys::SystemTools::UpperCase(component->Name)
-    + "_";
+  }
+  std::string prefix = "CPACK_IFW_COMPONENT_" +
+    cmsys::SystemTools::UpperCase(component->Name) + "_";
   const char* option = GetOption(prefix + "NAME");
   name = option ? option : component->Name;
-  if(component->Group)
-    {
+  if (component->Group) {
     cmCPackIFWPackage* package = GetGroupPackage(component->Group);
-    if((componentPackageMethod == ONE_PACKAGE_PER_GROUP)
-       || IsOn(prefix + "COMMON"))
-      {
+    if ((componentPackageMethod == ONE_PACKAGE_PER_GROUP) ||
+        IsOn(prefix + "COMMON")) {
       return package->Name;
-      }
+    }
     bool dot = !ResolveDuplicateNames;
-    if(dot && name.substr(0, package->Name.size()) == package->Name)
-      {
+    if (dot && name.substr(0, package->Name.size()) == package->Name) {
       dot = false;
-      }
-    if(dot)
-      {
+    }
+    if (dot) {
       name = package->Name + "." + name;
-      }
     }
+  }
   return name;
 }
 
-//----------------------------------------------------------------------------
 cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage(
-  cmCPackComponentGroup *group) const
+  cmCPackComponentGroup* group) const
 {
-  std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit
-    = GroupPackages.find(group);
+  std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit =
+    GroupPackages.find(group);
   return pit != GroupPackages.end() ? pit->second : 0;
 }
 
-//----------------------------------------------------------------------------
 cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
-  cmCPackComponent *component) const
+  cmCPackComponent* component) const
 {
-  std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit
-    = ComponentPackages.find(component);
+  std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit =
+    ComponentPackages.find(component);
   return pit != ComponentPackages.end() ? pit->second : 0;
 }
 
-//----------------------------------------------------------------------------
-void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
+cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository(
+  const std::string& repositoryName)
 {
-  xout << "<!-- Generated by CPack " << CMake_VERSION << " IFW generator "
-       << "for QtIFW ";
-  if(IsVersionLess("2.0"))
-    {
-    xout << "less 2.0";
-    }
-  else
-    {
-    xout << FrameworkVersion;
-    }
-  xout << " tools at " << cmTimestamp().CurrentTime("", true) << " -->"
-       << std::endl;
+  RepositoriesMap::iterator rit = Repositories.find(repositoryName);
+  if (rit != Repositories.end())
+    return &(rit->second);
+
+  cmCPackIFWRepository* repository = &Repositories[repositoryName];
+  repository->Name = repositoryName;
+  repository->Generator = this;
+  if (repository->ConfigureFromOptions()) {
+    if (repository->Update == cmCPackIFWRepository::None) {
+      Installer.RemoteRepositories.push_back(repository);
+    } else {
+      Repository.RepositoryUpdate.push_back(repository);
+    }
+  } else {
+    Repositories.erase(repositoryName);
+    repository = 0;
+    cmCPackLogger(cmCPackLog::LOG_WARNING, "Invalid repository \""
+                    << repositoryName << "\""
+                    << " configuration. Repository will be skipped."
+                    << std::endl);
+  }
+  return repository;
+}
+
+void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout)
+{
+  std::stringstream comment;
+  comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
+          << "for QtIFW ";
+  if (IsVersionLess("2.0")) {
+    comment << "less 2.0";
+  } else {
+    comment << FrameworkVersion;
+  }
+  comment << " tools at " << cmTimestamp().CurrentTime("", true);
+  xout.Comment(comment.str().c_str());
 }
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h
index 3246861..2b35749 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.h
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.h
@@ -13,11 +13,13 @@
 #ifndef cmCPackIFWGenerator_h
 #define cmCPackIFWGenerator_h
 
-#include <cmGeneratedFileStream.h>
 #include <CPack/cmCPackGenerator.h>
 
-#include "cmCPackIFWPackage.h"
 #include "cmCPackIFWInstaller.h"
+#include "cmCPackIFWPackage.h"
+#include "cmCPackIFWRepository.h"
+
+class cmXMLWriter;
 
 /** \class cmCPackIFWGenerator
  * \brief A generator for Qt Installer Framework tools
@@ -30,6 +32,7 @@ public:
   cmCPackTypeMacro(cmCPackIFWGenerator, cmCPackGenerator);
 
   typedef std::map<std::string, cmCPackIFWPackage> PackagesMap;
+  typedef std::map<std::string, cmCPackIFWRepository> RepositoriesMap;
   typedef std::map<std::string, cmCPackComponent> ComponentsMap;
   typedef std::map<std::string, cmCPackComponentGroup> ComponentGoupsMap;
   typedef std::map<std::string, cmCPackIFWPackage::DependenceStruct>
@@ -48,19 +51,20 @@ public:
   /**
    * Compare \a version with QtIFW framework version
    */
-  bool IsVersionLess(const char *version);
+  bool IsVersionLess(const char* version);
 
   /**
    * Compare \a version with QtIFW framework version
    */
-  bool IsVersionGreater(const char *version);
+  bool IsVersionGreater(const char* version);
 
   /**
    * Compare \a version with QtIFW framework version
    */
-  bool IsVersionEqual(const char *version);
+  bool IsVersionEqual(const char* version);
 
-protected: // cmCPackGenerator reimplementation
+protected:
+  // cmCPackGenerator reimplementation
 
   /**
    * @brief Initialize generator
@@ -88,9 +92,8 @@ protected: // cmCPackGenerator reimplementation
    *
    * @return Pointer to component
    */
-  virtual cmCPackComponent* GetComponent(
-    const std::string& projectName,
-    const std::string& componentName);
+  virtual cmCPackComponent* GetComponent(const std::string& projectName,
+                                         const std::string& componentName);
 
   /**
    * @brief Get group of component
@@ -102,36 +105,44 @@ protected: // cmCPackGenerator reimplementation
    * @return Pointer to component group
    */
   virtual cmCPackComponentGroup* GetComponentGroup(
-    const std::string& projectName,
-    const std::string& groupName);
+    const std::string& projectName, const std::string& groupName);
 
   enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const;
   virtual bool SupportsAbsoluteDestination() const;
   virtual bool SupportsComponentInstallation() const;
 
-protected: // Methods
+protected:
+  // Methods
 
   bool IsOnePackage() const;
 
   std::string GetRootPackageName();
 
-  std::string GetGroupPackageName(cmCPackComponentGroup *group) const;
-  std::string GetComponentPackageName(cmCPackComponent *component) const;
+  std::string GetGroupPackageName(cmCPackComponentGroup* group) const;
+  std::string GetComponentPackageName(cmCPackComponent* component) const;
+
+  cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup* group) const;
+  cmCPackIFWPackage* GetComponentPackage(cmCPackComponent* component) const;
 
-  cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const;
-  cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const;
+  cmCPackIFWRepository* GetRepository(const std::string& repositoryName);
 
-  void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
+  void WriteGeneratedByToStrim(cmXMLWriter& xout);
 
-protected: // Data
+protected:
+  // Data
 
   friend class cmCPackIFWPackage;
   friend class cmCPackIFWInstaller;
+  friend class cmCPackIFWRepository;
 
   // Installer
   cmCPackIFWInstaller Installer;
+  // Repository
+  cmCPackIFWRepository Repository;
   // Collection of packages
   PackagesMap Packages;
+  // Collection of repositories
+  RepositoriesMap Repositories;
   // Collection of binary packages
   std::set<cmCPackIFWPackage*> BinaryPackages;
   // Collection of downloaded packages
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 8c77a2c..dfc509b 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -17,525 +17,332 @@
 #include <CPack/cmCPackLog.h>
 
 #include <cmGeneratedFileStream.h>
-#include <cmXMLSafe.h>
+#include <cmXMLWriter.h>
 
 #ifdef cmCPackLogger
-# undef cmCPackLogger
+#undef cmCPackLogger
 #endif
-#define cmCPackLogger(logType, msg)                                     \
-  do {                                                                  \
-  std::ostringstream cmCPackLog_msg;                                    \
-  cmCPackLog_msg << msg;                                                \
-  if(Generator) {                                                       \
-  Generator->Logger->Log(logType, __FILE__, __LINE__,                   \
-                         cmCPackLog_msg.str().c_str());                 \
-  }                                                                     \
-  } while ( 0 )
-
-//----------------------------------------------------------------------------
-cmCPackIFWInstaller::cmCPackIFWInstaller() :
-  Generator(0)
+#define cmCPackLogger(logType, msg)                                           \
+  do {                                                                        \
+    std::ostringstream cmCPackLog_msg;                                        \
+    cmCPackLog_msg << msg;                                                    \
+    if (Generator) {                                                          \
+      Generator->Logger->Log(logType, __FILE__, __LINE__,                     \
+                             cmCPackLog_msg.str().c_str());                   \
+    }                                                                         \
+  } while (0)
+
+cmCPackIFWInstaller::cmCPackIFWInstaller()
+  : Generator(0)
 {
 }
 
-//----------------------------------------------------------------------------
-const char *cmCPackIFWInstaller::GetOption(const std::string &op) const
+const char* cmCPackIFWInstaller::GetOption(const std::string& op) const
 {
   return Generator ? Generator->GetOption(op) : 0;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWInstaller::IsOn(const std::string &op) const
+bool cmCPackIFWInstaller::IsOn(const std::string& op) const
 {
   return Generator ? Generator->IsOn(op) : false;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWInstaller::IsVersionLess(const char *version)
+bool cmCPackIFWInstaller::IsVersionLess(const char* version)
 {
   return Generator ? Generator->IsVersionLess(version) : false;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWInstaller::IsVersionGreater(const char *version)
+bool cmCPackIFWInstaller::IsVersionGreater(const char* version)
 {
   return Generator ? Generator->IsVersionGreater(version) : false;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWInstaller::IsVersionEqual(const char *version)
+bool cmCPackIFWInstaller::IsVersionEqual(const char* version)
 {
   return Generator ? Generator->IsVersionEqual(version) : false;
 }
 
-
-//----------------------------------------------------------------------------
 void cmCPackIFWInstaller::ConfigureFromOptions()
 {
   // Name;
   if (const char* optIFW_PACKAGE_NAME =
-      this->GetOption("CPACK_IFW_PACKAGE_NAME"))
-    {
+        this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
     Name = optIFW_PACKAGE_NAME;
-    }
-  else if (const char* optPACKAGE_NAME =
-           this->GetOption("CPACK_PACKAGE_NAME"))
-    {
+  } else if (const char* optPACKAGE_NAME =
+               this->GetOption("CPACK_PACKAGE_NAME")) {
     Name = optPACKAGE_NAME;
-    }
-  else
-    {
+  } else {
     Name = "Your package";
-    }
+  }
 
   // Title;
   if (const char* optIFW_PACKAGE_TITLE =
-      GetOption("CPACK_IFW_PACKAGE_TITLE"))
-    {
+        GetOption("CPACK_IFW_PACKAGE_TITLE")) {
     Title = optIFW_PACKAGE_TITLE;
-    }
-  else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
-           GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"))
-    {
+  } else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
+               GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
     Title = optPACKAGE_DESCRIPTION_SUMMARY;
-    }
-  else
-    {
+  } else {
     Title = "Your package description";
-    }
+  }
 
   // Version;
-  if (const char* option = GetOption("CPACK_PACKAGE_VERSION"))
-    {
+  if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
     Version = option;
-    }
-  else
-    {
+  } else {
     Version = "1.0.0";
-    }
+  }
 
   // Publisher
-  if(const char* optIFW_PACKAGE_PUBLISHER =
-     GetOption("CPACK_IFW_PACKAGE_PUBLISHER"))
-    {
+  if (const char* optIFW_PACKAGE_PUBLISHER =
+        GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) {
     Publisher = optIFW_PACKAGE_PUBLISHER;
-    }
-  else if(const char* optPACKAGE_VENDOR = GetOption("CPACK_PACKAGE_VENDOR"))
-    {
+  } else if (const char* optPACKAGE_VENDOR =
+               GetOption("CPACK_PACKAGE_VENDOR")) {
     Publisher = optPACKAGE_VENDOR;
-    }
+  }
 
   // ProductUrl
-  if(const char* option = GetOption("CPACK_IFW_PRODUCT_URL"))
-    {
+  if (const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) {
     ProductUrl = option;
-    }
+  }
 
   // ApplicationIcon
-  if(const char* option = GetOption("CPACK_IFW_PACKAGE_ICON"))
-    {
-    if(cmSystemTools::FileExists(option))
-      {
+  if (const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) {
+    if (cmSystemTools::FileExists(option)) {
       InstallerApplicationIcon = option;
-      }
-    else
-      {
+    } else {
       // TODO: implement warning
-      }
     }
+  }
 
   // WindowIcon
-  if(const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON"))
-    {
-    if(cmSystemTools::FileExists(option))
-      {
+  if (const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
+    if (cmSystemTools::FileExists(option)) {
       InstallerWindowIcon = option;
-      }
-    else
-      {
+    } else {
       // TODO: implement warning
-      }
     }
+  }
 
   // Logo
-  if(const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO"))
-    {
-    if(cmSystemTools::FileExists(option))
-      {
+  if (const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) {
+    if (cmSystemTools::FileExists(option)) {
       Logo = option;
-      }
-    else
-      {
+    } else {
       // TODO: implement warning
-      }
     }
+  }
 
   // Start menu
   if (const char* optIFW_START_MENU_DIR =
-      this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY"))
-    {
+        this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
     StartMenuDir = optIFW_START_MENU_DIR;
-    }
-  else
-    {
+  } else {
     StartMenuDir = Name;
-    }
+  }
 
   // Default target directory for installation
   if (const char* optIFW_TARGET_DIRECTORY =
-      GetOption("CPACK_IFW_TARGET_DIRECTORY"))
-    {
+        GetOption("CPACK_IFW_TARGET_DIRECTORY")) {
     TargetDir = optIFW_TARGET_DIRECTORY;
-    }
-  else if (const char *optPACKAGE_INSTALL_DIRECTORY =
-           GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY"))
-    {
+  } else if (const char* optPACKAGE_INSTALL_DIRECTORY =
+               GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
     TargetDir = "@ApplicationsDir@/";
     TargetDir += optPACKAGE_INSTALL_DIRECTORY;
-    }
-  else
-    {
+  } else {
     TargetDir = "@RootDir@/usr/local";
-    }
+  }
 
   // Default target directory for installation with administrator rights
-  if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY"))
-    {
+  if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
     AdminTargetDir = option;
-    }
-
-  // Repositories
-  Repositories.clear();
-  RepositoryStruct Repo;
-  if(const char *site = this->GetOption("CPACK_DOWNLOAD_SITE"))
-    {
-    Repo.Url = site;
-    Repositories.push_back(Repo);
-    }
-  if(const char *RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL"))
-    {
-    std::vector<std::string> RepoAllVector;
-    cmSystemTools::ExpandListArgument(RepoAllStr,
-                                      RepoAllVector);
-    for(std::vector<std::string>::iterator
-          rit = RepoAllVector.begin(); rit != RepoAllVector.end(); ++rit)
-      {
-        std::string prefix = "CPACK_IFW_REPOSITORY_"
-          + cmsys::SystemTools::UpperCase(*rit)
-          + "_";
-        // Url
-        if (const char* url = GetOption(prefix + "URL"))
-          {
-          Repo.Url = url;
-          }
-        else
-          {
-          Repo.Url = "";
-          }
-        // Enabled
-        if (IsOn(prefix + "DISABLED"))
-          {
-          Repo.Enabled = "0";
-          }
-        else
-          {
-          Repo.Enabled = "";
-          }
-        // Username
-        if (const char* username = GetOption(prefix + "USERNAME"))
-          {
-          Repo.Username = username;
-          }
-        else
-          {
-          Repo.Username = "";
-          }
-        // Password
-        if (const char* password = GetOption(prefix + "PASSWORD"))
-          {
-          Repo.Password = password;
-          }
-        else
-          {
-          Repo.Password = "";
-          }
-        // DisplayName
-        if (const char* displayName = GetOption(prefix + "DISPLAY_NAME"))
-          {
-          Repo.DisplayName = displayName;
-          }
-        else
-          {
-          Repo.DisplayName = "";
-          }
-
-        if(!Repo.Url.empty())
-          {
-          Repositories.push_back(Repo);
-          }
-      }
-    }
+  }
 
   // Maintenance tool
-  if(const char* optIFW_MAINTENANCE_TOOL =
-      this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME"))
-    {
+  if (const char* optIFW_MAINTENANCE_TOOL =
+        this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) {
     MaintenanceToolName = optIFW_MAINTENANCE_TOOL;
-    }
+  }
 
   // Maintenance tool ini file
-  if(const char* optIFW_MAINTENANCE_TOOL_INI =
-      this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE"))
-    {
+  if (const char* optIFW_MAINTENANCE_TOOL_INI =
+        this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) {
     MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI;
-    }
+  }
 
   // Allow non-ASCII characters
-  if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS"))
-    {
-    if(IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS"))
-      {
+  if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
+    if (IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
       AllowNonAsciiCharacters = "true";
-      }
-    else
-      {
+    } else {
       AllowNonAsciiCharacters = "false";
-      }
     }
+  }
 
   // Space in path
-  if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH"))
-    {
-    if(IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH"))
-      {
+  if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
+    if (IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
       AllowSpaceInPath = "true";
-      }
-    else
-      {
+    } else {
       AllowSpaceInPath = "false";
-      }
     }
+  }
 
   // Control script
-  if(const char* optIFW_CONTROL_SCRIPT =
-      this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT"))
-    {
+  if (const char* optIFW_CONTROL_SCRIPT =
+        this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
     ControlScript = optIFW_CONTROL_SCRIPT;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCPackIFWInstaller::GenerateInstallerFile()
 {
   // Lazy directory initialization
-  if(Directory.empty() && Generator)
-    {
+  if (Directory.empty() && Generator) {
     Directory = Generator->toplevel;
-    }
+  }
 
   // Output stream
-  cmGeneratedFileStream xout((Directory + "/config/config.xml").data());
+  cmGeneratedFileStream fout((Directory + "/config/config.xml").data());
+  cmXMLWriter xout(fout);
 
-  xout << "<?xml version=\"1.0\"?>" << std::endl;
+  xout.StartDocument();
 
   WriteGeneratedByToStrim(xout);
 
-  xout << "<Installer>" << std::endl;
-
-  xout << "    <Name>" << cmXMLSafe(Name).str() << "</Name>" << std::endl;
+  xout.StartElement("Installer");
 
-  xout << "    <Version>" << Version << "</Version>" << std::endl;
+  xout.Element("Name", Name);
+  xout.Element("Version", Version);
+  xout.Element("Title", Title);
 
-  xout << "    <Title>" << cmXMLSafe(Title).str() << "</Title>"
-       << std::endl;
-
-  if(!Publisher.empty())
-    {
-    xout << "    <Publisher>" << cmXMLSafe(Publisher).str()
-         << "</Publisher>" << std::endl;
-    }
+  if (!Publisher.empty()) {
+    xout.Element("Publisher", Publisher);
+  }
 
-  if(!ProductUrl.empty())
-    {
-    xout << "    <ProductUrl>" << ProductUrl << "</ProductUrl>" << std::endl;
-    }
+  if (!ProductUrl.empty()) {
+    xout.Element("ProductUrl", ProductUrl);
+  }
 
   // ApplicationIcon
-  if(!InstallerApplicationIcon.empty())
-    {
+  if (!InstallerApplicationIcon.empty()) {
     std::string name =
       cmSystemTools::GetFilenameName(InstallerApplicationIcon);
     std::string path = Directory + "/config/" + name;
     name = cmSystemTools::GetFilenameWithoutExtension(name);
-    cmsys::SystemTools::CopyFileIfDifferent(
-      InstallerApplicationIcon.data(), path.data());
-    xout << "    <InstallerApplicationIcon>" << name
-         << "</InstallerApplicationIcon>" << std::endl;
-    }
+    cmsys::SystemTools::CopyFileIfDifferent(InstallerApplicationIcon.data(),
+                                            path.data());
+    xout.Element("InstallerApplicationIcon", name);
+  }
 
   // WindowIcon
-  if(!InstallerWindowIcon.empty())
-    {
+  if (!InstallerWindowIcon.empty()) {
     std::string name = cmSystemTools::GetFilenameName(InstallerWindowIcon);
     std::string path = Directory + "/config/" + name;
-    cmsys::SystemTools::CopyFileIfDifferent(
-      InstallerWindowIcon.data(), path.data());
-    xout << "    <InstallerWindowIcon>" << name
-         << "</InstallerWindowIcon>" << std::endl;
-    }
+    cmsys::SystemTools::CopyFileIfDifferent(InstallerWindowIcon.data(),
+                                            path.data());
+    xout.Element("InstallerWindowIcon", name);
+  }
 
   // Logo
-  if(!Logo.empty())
-    {
+  if (!Logo.empty()) {
     std::string name = cmSystemTools::GetFilenameName(Logo);
     std::string path = Directory + "/config/" + name;
     cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data());
-    xout << "    <Logo>" << name << "</Logo>" << std::endl;
-    }
+    xout.Element("Logo", name);
+  }
 
   // Start menu
-  if(!IsVersionLess("2.0"))
-    {
-    xout << "    <StartMenuDir>" << StartMenuDir
-         << "</StartMenuDir>" << std::endl;
-    }
+  if (!IsVersionLess("2.0")) {
+    xout.Element("StartMenuDir", StartMenuDir);
+  }
 
   // Target dir
-  if(!TargetDir.empty())
-    {
-    xout << "    <TargetDir>" << TargetDir << "</TargetDir>" << std::endl;
-    }
+  if (!TargetDir.empty()) {
+    xout.Element("TargetDir", TargetDir);
+  }
 
   // Admin target dir
-  if(!AdminTargetDir.empty())
-    {
-    xout << "    <AdminTargetDir>" << AdminTargetDir
-         << "</AdminTargetDir>" << std::endl;
-    }
+  if (!AdminTargetDir.empty()) {
+    xout.Element("AdminTargetDir", AdminTargetDir);
+  }
 
   // Remote repositories
-  if (!Repositories.empty())
-    {
-    xout << "    <RemoteRepositories>" << std::endl;
-    for(std::vector<RepositoryStruct>::iterator
-        rit = Repositories.begin(); rit != Repositories.end(); ++rit)
-      {
-      xout << "        <Repository>" << std::endl;
-      // Url
-      xout << "            <Url>" << rit->Url
-           << "</Url>" << std::endl;
-      // Enabled
-      if(!rit->Enabled.empty())
-        {
-        xout << "            <Enabled>" << rit->Enabled
-             << "</Enabled>" << std::endl;
-        }
-      // Username
-      if(!rit->Username.empty())
-        {
-        xout << "            <Username>" << rit->Username
-             << "</Username>" << std::endl;
-        }
-      // Password
-      if(!rit->Password.empty())
-        {
-        xout << "            <Password>" << rit->Password
-             << "</Password>" << std::endl;
-        }
-      // DisplayName
-      if(!rit->DisplayName.empty())
-        {
-        xout << "            <DisplayName>" << rit->DisplayName
-             << "</DisplayName>" << std::endl;
-        }
-      xout << "        </Repository>" << std::endl;
-      }
-    xout << "    </RemoteRepositories>" << std::endl;
+  if (!RemoteRepositories.empty()) {
+    xout.StartElement("RemoteRepositories");
+    for (RepositoriesVector::iterator rit = RemoteRepositories.begin();
+         rit != RemoteRepositories.end(); ++rit) {
+      (*rit)->WriteRepositoryConfig(xout);
     }
+    xout.EndElement();
+  }
 
   // Maintenance tool
-  if(!IsVersionLess("2.0") && !MaintenanceToolName.empty())
-    {
-    xout << "    <MaintenanceToolName>" << MaintenanceToolName
-         << "</MaintenanceToolName>" << std::endl;
-    }
+  if (!IsVersionLess("2.0") && !MaintenanceToolName.empty()) {
+    xout.Element("MaintenanceToolName", MaintenanceToolName);
+  }
 
   // Maintenance tool ini file
-  if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty())
-    {
-    xout << "    <MaintenanceToolIniFile>" << MaintenanceToolIniFile
-         << "</MaintenanceToolIniFile>" << std::endl;
-    }
+  if (!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) {
+    xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile);
+  }
 
   // Different allows
-  if(IsVersionLess("2.0"))
-    {
+  if (IsVersionLess("2.0")) {
     // CPack IFW default policy
-    xout << "    <!-- CPack IFW default policy for QtIFW less 2.0 -->"
-         << std::endl;
-    xout << "    <AllowNonAsciiCharacters>true</AllowNonAsciiCharacters>"
-         << std::endl;
-    xout << "    <AllowSpaceInPath>true</AllowSpaceInPath>" << std::endl;
+    xout.Comment("CPack IFW default policy for QtIFW less 2.0");
+    xout.Element("AllowNonAsciiCharacters", "true");
+    xout.Element("AllowSpaceInPath", "true");
+  } else {
+    if (!AllowNonAsciiCharacters.empty()) {
+      xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters);
     }
-  else
-    {
-      if(!AllowNonAsciiCharacters.empty())
-        {
-        xout << "    <AllowNonAsciiCharacters>" << AllowNonAsciiCharacters
-             << "</AllowNonAsciiCharacters>" << std::endl;
-        }
-      if(!AllowSpaceInPath.empty())
-        {
-        xout << "    <AllowAllowSpaceInPath>" << AllowSpaceInPath
-             << "</AllowSpaceInPath>" << std::endl;
-        }
+    if (!AllowSpaceInPath.empty()) {
+      xout.Element("AllowSpaceInPath", AllowSpaceInPath);
     }
+  }
 
   // Control script (copy to config dir)
-  if(!IsVersionLess("2.0") && !ControlScript.empty())
-    {
+  if (!IsVersionLess("2.0") && !ControlScript.empty()) {
     std::string name = cmSystemTools::GetFilenameName(ControlScript);
     std::string path = Directory + "/config/" + name;
     cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data());
-    xout << "    <ControlScript>" << name << "</ControlScript>" << std::endl;
-    }
+    xout.Element("ControlScript", name);
+  }
 
-  xout << "</Installer>" << std::endl;
+  xout.EndElement();
+  xout.EndDocument();
 }
 
-//----------------------------------------------------------------------------
 void cmCPackIFWInstaller::GeneratePackageFiles()
 {
-  if (Packages.empty() || Generator->IsOnePackage())
-    {
+  if (Packages.empty() || Generator->IsOnePackage()) {
     // Generate default package
     cmCPackIFWPackage package;
     package.Generator = Generator;
     package.Installer = this;
     // Check package group
-    if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP"))
-      {
+    if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) {
       package.ConfigureFromGroup(option);
       package.ForcedInstallation = "true";
-      }
-    else
-      {
+    } else {
       package.ConfigureFromOptions();
-      }
+    }
     package.GeneratePackageFile();
     return;
-    }
+  }
 
   // Generate packages meta information
-  for(PackagesMap::iterator pit = Packages.begin();
-      pit != Packages.end(); ++pit)
-    {
+  for (PackagesMap::iterator pit = Packages.begin(); pit != Packages.end();
+       ++pit) {
     cmCPackIFWPackage* package = pit->second;
     package->GeneratePackageFile();
   }
 }
 
-void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
+void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout)
 {
-  if(Generator) Generator->WriteGeneratedByToStrim(xout);
+  if (Generator)
+    Generator->WriteGeneratedByToStrim(xout);
 }
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h
index 4cba5b2..3170116 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.h
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.h
@@ -13,38 +13,34 @@
 #ifndef cmCPackIFWInstaller_h
 #define cmCPackIFWInstaller_h
 
-#include <cmGeneratedFileStream.h>
 #include <cmStandardIncludes.h>
 
 class cmCPackIFWPackage;
 class cmCPackIFWGenerator;
+class cmCPackIFWRepository;
+class cmXMLWriter;
 
 /** \class cmCPackIFWInstaller
  * \brief A binary installer to be created CPack IFW generator
  */
 class cmCPackIFWInstaller
 {
-public: // Types
+public:
+  // Types
 
   typedef std::map<std::string, cmCPackIFWPackage*> PackagesMap;
+  typedef std::vector<cmCPackIFWRepository*> RepositoriesVector;
 
-  struct RepositoryStruct
-  {
-    std::string Url;
-    std::string Enabled;
-    std::string Username;
-    std::string Password;
-    std::string DisplayName;
-  };
-
-public: // Constructor
+public:
+  // Constructor
 
   /**
    * Construct installer
    */
   cmCPackIFWInstaller();
 
-public: // Configuration
+public:
+  // Configuration
 
   /// Name of the product being installed
   std::string Name;
@@ -94,14 +90,15 @@ public: // Configuration
   /// Filename for a custom installer control script
   std::string ControlScript;
 
-public: // Internal implementation
+public:
+  // Internal implementation
 
   const char* GetOption(const std::string& op) const;
   bool IsOn(const std::string& op) const;
 
-  bool IsVersionLess(const char *version);
-  bool IsVersionGreater(const char *version);
-  bool IsVersionEqual(const char *version);
+  bool IsVersionLess(const char* version);
+  bool IsVersionGreater(const char* version);
+  bool IsVersionEqual(const char* version);
 
   void ConfigureFromOptions();
 
@@ -111,11 +108,11 @@ public: // Internal implementation
 
   cmCPackIFWGenerator* Generator;
   PackagesMap Packages;
-  std::vector<RepositoryStruct> Repositories;
+  RepositoriesVector RemoteRepositories;
   std::string Directory;
 
 protected:
-  void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
+  void WriteGeneratedByToStrim(cmXMLWriter& xout);
 };
 
 #endif // cmCPackIFWInstaller_h
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index 5474ad1..ad153d1 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -18,24 +18,25 @@
 
 #include <cmGeneratedFileStream.h>
 #include <cmTimestamp.h>
+#include <cmXMLWriter.h>
 
 //----------------------------------------------------------------- Logger ---
 #ifdef cmCPackLogger
-# undef cmCPackLogger
+#undef cmCPackLogger
 #endif
-#define cmCPackLogger(logType, msg)                                     \
-  do {                                                                  \
-  std::ostringstream cmCPackLog_msg;                                    \
-  cmCPackLog_msg << msg;                                                \
-  if(Generator) {                                                       \
-  Generator->Logger->Log(logType, __FILE__, __LINE__,                   \
-                         cmCPackLog_msg.str().c_str());                 \
-  }                                                                     \
-  } while ( 0 )
+#define cmCPackLogger(logType, msg)                                           \
+  do {                                                                        \
+    std::ostringstream cmCPackLog_msg;                                        \
+    cmCPackLog_msg << msg;                                                    \
+    if (Generator) {                                                          \
+      Generator->Logger->Log(logType, __FILE__, __LINE__,                     \
+                             cmCPackLog_msg.str().c_str());                   \
+    }                                                                         \
+  } while (0)
 
 //---------------------------------------------------------- CompareStruct ---
-cmCPackIFWPackage::CompareStruct::CompareStruct() :
-  Type(CompareNone)
+cmCPackIFWPackage::CompareStruct::CompareStruct()
+  : Type(CompareNone)
 {
 }
 
@@ -44,67 +45,48 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct()
 {
 }
 
-//----------------------------------------------------------------------------
 cmCPackIFWPackage::DependenceStruct::DependenceStruct(
-  const std::string &dependence)
+  const std::string& dependence)
 {
   // Search compare section
   size_t pos = std::string::npos;
-  if((pos = dependence.find("<=")) != std::string::npos)
-    {
+  if ((pos = dependence.find("<=")) != std::string::npos) {
     Compare.Type = CompareLessOrEqual;
     Compare.Value = dependence.substr(pos + 2);
-    }
-  else if((pos = dependence.find(">=")) != std::string::npos)
-    {
+  } else if ((pos = dependence.find(">=")) != std::string::npos) {
     Compare.Type = CompareGreaterOrEqual;
     Compare.Value = dependence.substr(pos + 2);
-    }
-  else if((pos = dependence.find("<")) != std::string::npos)
-    {
+  } else if ((pos = dependence.find('<')) != std::string::npos) {
     Compare.Type = CompareLess;
     Compare.Value = dependence.substr(pos + 1);
-    }
-  else if((pos = dependence.find("=")) != std::string::npos)
-    {
+  } else if ((pos = dependence.find('=')) != std::string::npos) {
     Compare.Type = CompareEqual;
     Compare.Value = dependence.substr(pos + 1);
-    }
-  else if((pos = dependence.find(">")) != std::string::npos)
-    {
+  } else if ((pos = dependence.find('>')) != std::string::npos) {
     Compare.Type = CompareGreater;
     Compare.Value = dependence.substr(pos + 1);
-    }
+  }
   Name = pos == std::string::npos ? dependence : dependence.substr(0, pos);
 }
 
-//----------------------------------------------------------------------------
 std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
 {
-  if (Compare.Type == CompareNone) return Name;
+  if (Compare.Type == CompareNone)
+    return Name;
 
   std::string result = Name;
 
-  if (Compare.Type == CompareLessOrEqual)
-    {
+  if (Compare.Type == CompareLessOrEqual) {
     result += "<=";
-    }
-  else if (Compare.Type == CompareGreaterOrEqual)
-    {
+  } else if (Compare.Type == CompareGreaterOrEqual) {
     result += ">=";
-    }
-  else if (Compare.Type == CompareLess)
-    {
+  } else if (Compare.Type == CompareLess) {
     result += "<";
-    }
-  else if (Compare.Type == CompareEqual)
-    {
+  } else if (Compare.Type == CompareEqual) {
     result += "=";
-    }
-  else if (Compare.Type == CompareGreater)
-    {
+  } else if (Compare.Type == CompareGreater) {
     result += ">";
-    }
+  }
 
   result += Compare.Value;
 
@@ -112,55 +94,48 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
 }
 
 //------------------------------------------------------ cmCPackIFWPackage ---
-cmCPackIFWPackage::cmCPackIFWPackage() :
-  Generator(0),
-  Installer(0)
+cmCPackIFWPackage::cmCPackIFWPackage()
+  : Generator(0)
+  , Installer(0)
 {
 }
 
-//----------------------------------------------------------------------------
-const char *cmCPackIFWPackage::GetOption(const std::string &op) const
+const char* cmCPackIFWPackage::GetOption(const std::string& op) const
 {
-  const char *option = Generator ? Generator->GetOption(op) : 0;
+  const char* option = Generator ? Generator->GetOption(op) : 0;
   return option && *option ? option : 0;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWPackage::IsOn(const std::string &op) const
+bool cmCPackIFWPackage::IsOn(const std::string& op) const
 {
   return Generator ? Generator->IsOn(op) : false;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWPackage::IsVersionLess(const char *version)
+bool cmCPackIFWPackage::IsVersionLess(const char* version)
 {
   return Generator ? Generator->IsVersionLess(version) : false;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWPackage::IsVersionGreater(const char *version)
+bool cmCPackIFWPackage::IsVersionGreater(const char* version)
 {
   return Generator ? Generator->IsVersionGreater(version) : false;
 }
 
-//----------------------------------------------------------------------------
-bool cmCPackIFWPackage::IsVersionEqual(const char *version)
+bool cmCPackIFWPackage::IsVersionEqual(const char* version)
 {
   return Generator ? Generator->IsVersionEqual(version) : false;
 }
 
-//----------------------------------------------------------------------------
-std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent *component)
+std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
 {
-  if (!component) return "";
-  const char* option = GetOption(
-    "CPACK_IFW_COMPONENT_"
-    + cmsys::SystemTools::UpperCase(component->Name)
-    + "_NAME");
+  if (!component)
+    return "";
+  const char* option =
+    GetOption("CPACK_IFW_COMPONENT_" +
+              cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
   return option ? option : component->Name;
 }
 
-//----------------------------------------------------------------------------
 void cmCPackIFWPackage::DefaultConfiguration()
 {
   DisplayName = "";
@@ -171,11 +146,11 @@ void cmCPackIFWPackage::DefaultConfiguration()
   Licenses.clear();
   SortingPriority = "";
   Default = "";
+  Essential = "";
   Virtual = "";
   ForcedInstallation = "";
 }
 
-//----------------------------------------------------------------------------
 // Defaul configuration (all in one package)
 int cmCPackIFWPackage::ConfigureFromOptions()
 {
@@ -186,52 +161,42 @@ int cmCPackIFWPackage::ConfigureFromOptions()
   Name = Generator->GetRootPackageName();
 
   // Display name
-  if (const char *option = this->GetOption("CPACK_PACKAGE_NAME"))
-    {
+  if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
     DisplayName = option;
-    }
-  else
-    {
+  } else {
     DisplayName = "Your package";
-    }
+  }
 
   // Description
   if (const char* option =
-      this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"))
-    {
+        this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
     Description = option;
-    }
-  else
-    {
+  } else {
     Description = "Your package description";
-    }
+  }
 
   // Version
-  if(const char* option = GetOption("CPACK_PACKAGE_VERSION"))
-    {
+  if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
     Version = option;
-    }
-  else
-    {
+  } else {
     Version = "1.0.0";
-    }
+  }
 
   ForcedInstallation = "true";
 
   return 1;
 }
 
-//----------------------------------------------------------------------------
-int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
+int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
 {
-  if(!component) return 0;
+  if (!component)
+    return 0;
 
   // Restore defaul configuration
   DefaultConfiguration();
 
-  std::string prefix = "CPACK_IFW_COMPONENT_"
-    + cmsys::SystemTools::UpperCase(component->Name)
-    + "_";
+  std::string prefix = "CPACK_IFW_COMPONENT_" +
+    cmsys::SystemTools::UpperCase(component->Name) + "_";
 
   // Display name
   DisplayName = component->DisplayName;
@@ -240,85 +205,74 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
   Description = component->Description;
 
   // Version
-  if(const char* optVERSION = GetOption(prefix + "VERSION"))
-    {
+  if (const char* optVERSION = GetOption(prefix + "VERSION")) {
     Version = optVERSION;
-    }
-  else if(const char* optPACKAGE_VERSION =
-          GetOption("CPACK_PACKAGE_VERSION"))
-    {
+  } else if (const char* optPACKAGE_VERSION =
+               GetOption("CPACK_PACKAGE_VERSION")) {
     Version = optPACKAGE_VERSION;
-    }
-  else
-    {
+  } else {
     Version = "1.0.0";
-    }
+  }
 
   // Script
-  if (const char* option = GetOption(prefix + "SCRIPT"))
-    {
+  if (const char* option = GetOption(prefix + "SCRIPT")) {
     Script = option;
-    }
+  }
 
   // CMake dependencies
-  if (!component->Dependencies.empty())
-    {
+  if (!component->Dependencies.empty()) {
     std::vector<cmCPackComponent*>::iterator dit;
-    for(dit = component->Dependencies.begin();
-        dit != component->Dependencies.end();
-        ++dit)
-      {
+    for (dit = component->Dependencies.begin();
+         dit != component->Dependencies.end(); ++dit) {
       Dependencies.insert(Generator->ComponentPackages[*dit]);
-      }
     }
+  }
 
   // QtIFW dependencies
-  if(const char* option = this->GetOption(prefix + "DEPENDS"))
-    {
+  if (const char* option = this->GetOption(prefix + "DEPENDS")) {
     std::vector<std::string> deps;
-    cmSystemTools::ExpandListArgument(option,
-                                      deps);
-    for(std::vector<std::string>::iterator
-          dit = deps.begin(); dit != deps.end(); ++dit)
-      {
+    cmSystemTools::ExpandListArgument(option, deps);
+    for (std::vector<std::string>::iterator dit = deps.begin();
+         dit != deps.end(); ++dit) {
       DependenceStruct dep(*dit);
-      if (!Generator->Packages.count(dep.Name))
-        {
+      if (!Generator->Packages.count(dep.Name)) {
         bool hasDep = Generator->DependentPackages.count(dep.Name) > 0;
-        DependenceStruct &depRef =
-          Generator->DependentPackages[dep.Name];
-        if(!hasDep)
-          {
+        DependenceStruct& depRef = Generator->DependentPackages[dep.Name];
+        if (!hasDep) {
           depRef = dep;
-          }
-        AlienDependencies.insert(&depRef);
         }
+        AlienDependencies.insert(&depRef);
       }
     }
+  }
 
   // Licenses
-  if (const char* option = this->GetOption(prefix + "LICENSES"))
-    {
+  if (const char* option = this->GetOption(prefix + "LICENSES")) {
     Licenses.clear();
-    cmSystemTools::ExpandListArgument( option, Licenses );
-    if ( Licenses.size() % 2 != 0 )
-      {
-      cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES"
-        << " should contain pairs of <display_name> and <file_path>."
-        << std::endl);
+    cmSystemTools::ExpandListArgument(option, Licenses);
+    if (Licenses.size() % 2 != 0) {
+      cmCPackLogger(
+        cmCPackLog::LOG_WARNING, prefix
+          << "LICENSES"
+          << " should contain pairs of <display_name> and <file_path>."
+          << std::endl);
       Licenses.clear();
-      }
     }
+  }
 
   // Priority
-  if(const char* option = this->GetOption(prefix + "PRIORITY"))
-    {
+  if (const char* option = this->GetOption(prefix + "PRIORITY")) {
     SortingPriority = option;
-    }
+  }
 
   // Default
   Default = component->IsDisabledByDefault ? "false" : "true";
 
+  // Essential
+  if (this->IsOn(prefix + "ESSENTIAL")) {
+    Essential = "true";
+  }
+
   // Virtual
   Virtual = component->IsHidden ? "true" : "";
 
@@ -328,89 +282,74 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
   return 1;
 }
 
-//----------------------------------------------------------------------------
-int
-cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group)
+int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
 {
-  if(!group) return 0;
+  if (!group)
+    return 0;
 
   // Restore defaul configuration
   DefaultConfiguration();
 
-  std::string prefix = "CPACK_IFW_COMPONENT_GROUP_"
-    + cmsys::SystemTools::UpperCase(group->Name)
-    + "_";
+  std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
+    cmsys::SystemTools::UpperCase(group->Name) + "_";
 
   DisplayName = group->DisplayName;
   Description = group->Description;
 
   // Version
-  if(const char* optVERSION = GetOption(prefix + "VERSION"))
-    {
+  if (const char* optVERSION = GetOption(prefix + "VERSION")) {
     Version = optVERSION;
-    }
-  else if(const char* optPACKAGE_VERSION =
-          GetOption("CPACK_PACKAGE_VERSION"))
-    {
+  } else if (const char* optPACKAGE_VERSION =
+               GetOption("CPACK_PACKAGE_VERSION")) {
     Version = optPACKAGE_VERSION;
-    }
-  else
-    {
+  } else {
     Version = "1.0.0";
-    }
+  }
 
   // Script
-  if (const char* option = GetOption(prefix + "SCRIPT"))
-    {
+  if (const char* option = GetOption(prefix + "SCRIPT")) {
     Script = option;
-    }
+  }
 
   // Licenses
-  if (const char* option = this->GetOption(prefix + "LICENSES"))
-    {
+  if (const char* option = this->GetOption(prefix + "LICENSES")) {
     Licenses.clear();
-    cmSystemTools::ExpandListArgument( option, Licenses );
-    if ( Licenses.size() % 2 != 0 )
-      {
-      cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES"
-        << " should contain pairs of <display_name> and <file_path>."
-        << std::endl);
+    cmSystemTools::ExpandListArgument(option, Licenses);
+    if (Licenses.size() % 2 != 0) {
+      cmCPackLogger(
+        cmCPackLog::LOG_WARNING, prefix
+          << "LICENSES"
+          << " should contain pairs of <display_name> and <file_path>."
+          << std::endl);
       Licenses.clear();
-      }
     }
+  }
 
   // Priority
-  if(const char* option = this->GetOption(prefix + "PRIORITY"))
-    {
+  if (const char* option = this->GetOption(prefix + "PRIORITY")) {
     SortingPriority = option;
-    }
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------------
-int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
+int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
 {
   // Group configuration
 
   cmCPackComponentGroup group;
-  std::string prefix = "CPACK_COMPONENT_GROUP_"
-      + cmsys::SystemTools::UpperCase(groupName)
-      + "_";
+  std::string prefix =
+    "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_";
 
-  if (const char *option = GetOption(prefix + "DISPLAY_NAME"))
-    {
+  if (const char* option = GetOption(prefix + "DISPLAY_NAME")) {
     group.DisplayName = option;
-    }
-  else
-    {
+  } else {
     group.DisplayName = group.Name;
-    }
+  }
 
-  if (const char* option = GetOption(prefix + "DESCRIPTION"))
-    {
+  if (const char* option = GetOption(prefix + "DESCRIPTION")) {
     group.Description = option;
-    }
+  }
   group.IsBold = IsOn(prefix + "BOLD_TITLE");
   group.IsExpandedByDefault = IsOn(prefix + "EXPANDED");
 
@@ -418,149 +357,123 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
 
   group.Name = groupName;
 
-  if(Generator)
-    {
+  if (Generator) {
     Name = Generator->GetGroupPackageName(&group);
-    }
-  else
-    {
+  } else {
     Name = group.Name;
-    }
+  }
 
   return ConfigureFromGroup(&group);
 }
 
-//----------------------------------------------------------------------------
 void cmCPackIFWPackage::GeneratePackageFile()
 {
   // Lazy directory initialization
-  if (Directory.empty())
-    {
-    if(Installer)
-      {
+  if (Directory.empty()) {
+    if (Installer) {
       Directory = Installer->Directory + "/packages/" + Name;
-      }
-    else if (Generator)
-      {
+    } else if (Generator) {
       Directory = Generator->toplevel + "/packages/" + Name;
-      }
     }
+  }
 
   // Output stream
-  cmGeneratedFileStream xout((Directory + "/meta/package.xml").data());
+  cmGeneratedFileStream fout((Directory + "/meta/package.xml").data());
+  cmXMLWriter xout(fout);
 
-  xout << "<?xml version=\"1.0\"?>" << std::endl;
+  xout.StartDocument();
 
   WriteGeneratedByToStrim(xout);
 
-  xout << "<Package>" << std::endl;
-
-  xout << "    <DisplayName>" << DisplayName
-       << "</DisplayName>" << std::endl;
+  xout.StartElement("Package");
 
-  xout << "    <Description>" << Description
-       << "</Description>" << std::endl;
+  xout.Element("DisplayName", DisplayName);
+  xout.Element("Description", Description);
+  xout.Element("Name", Name);
+  xout.Element("Version", Version);
 
-  xout << "    <Name>" << Name << "</Name>" << std::endl;
-
-  xout << "    <Version>" <<  Version
-       << "</Version>" << std::endl;
-
-  xout << "    <ReleaseDate>";
-  if(ReleaseDate.empty())
-    {
-    xout << cmTimestamp().CurrentTime("%Y-%m-%d", true);
-    }
-  else
-    {
-    xout << ReleaseDate;
-    }
-  xout << "</ReleaseDate>" << std::endl;
+  if (!ReleaseDate.empty()) {
+    xout.Element("ReleaseDate", ReleaseDate);
+  } else {
+    xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
+  }
 
   // Script (copy to meta dir)
-  if(!Script.empty())
-    {
+  if (!Script.empty()) {
     std::string name = cmSystemTools::GetFilenameName(Script);
     std::string path = Directory + "/meta/" + name;
     cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data());
-    xout << "    <Script>" << name << "</Script>" << std::endl;
-    }
+    xout.Element("Script", name);
+  }
 
   // Dependencies
   std::set<DependenceStruct> compDepSet;
-  for(std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
-      ait != AlienDependencies.end(); ++ait)
-    {
+  for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
+       ait != AlienDependencies.end(); ++ait) {
     compDepSet.insert(*(*ait));
-    }
-  for(std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
-      it != Dependencies.end(); ++it)
-    {
+  }
+  for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
+       it != Dependencies.end(); ++it) {
     compDepSet.insert(DependenceStruct((*it)->Name));
-    }
+  }
   // Write dependencies
-  if  (!compDepSet.empty())
-    {
-    xout << "    <Dependencies>";
+  if (!compDepSet.empty()) {
+    std::stringstream dependencies;
     std::set<DependenceStruct>::iterator it = compDepSet.begin();
-    xout << it->NameWithCompare();
+    dependencies << it->NameWithCompare();
     ++it;
-    while(it != compDepSet.end())
-      {
-      xout << "," << it->NameWithCompare();
+    while (it != compDepSet.end()) {
+      dependencies << "," << it->NameWithCompare();
       ++it;
-      }
-    xout << "</Dependencies>" << std::endl;
     }
+    xout.Element("Dependencies", dependencies.str());
+  }
 
   // Licenses (copy to meta dir)
   std::vector<std::string> licenses = Licenses;
-  for(size_t i = 1; i < licenses.size(); i += 2)
-    {
+  for (size_t i = 1; i < licenses.size(); i += 2) {
     std::string name = cmSystemTools::GetFilenameName(licenses[i]);
     std::string path = Directory + "/meta/" + name;
     cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data());
     licenses[i] = name;
-    }
-  if(!licenses.empty())
-    {
-    xout << "    <Licenses>" << std::endl;
-    for(size_t i = 0; i < licenses.size(); i += 2)
-      {
-      xout << "        <License "
-           << "name=\"" << licenses[i] << "\" "
-           << "file=\"" << licenses[i + 1] << "\" "
-           << "/>" <<std::endl;
-      }
-    xout << "    </Licenses>" << std::endl;
-    }
-
-  if (!ForcedInstallation.empty())
-    {
-    xout << "    <ForcedInstallation>" << ForcedInstallation
-         << "</ForcedInstallation>" << std::endl;
-    }
-
-  if (!Virtual.empty())
-    {
-    xout << "    <Virtual>" << Virtual << "</Virtual>" << std::endl;
-    }
-  else if (!Default.empty())
-    {
-    xout << "    <Default>" << Default << "</Default>" << std::endl;
-    }
+  }
+  if (!licenses.empty()) {
+    xout.StartElement("Licenses");
+    for (size_t i = 0; i < licenses.size(); i += 2) {
+      xout.StartElement("License");
+      xout.Attribute("name", licenses[i]);
+      xout.Attribute("file", licenses[i + 1]);
+      xout.EndElement();
+    }
+    xout.EndElement();
+  }
+
+  if (!ForcedInstallation.empty()) {
+    xout.Element("ForcedInstallation", ForcedInstallation);
+  }
+
+  if (!Virtual.empty()) {
+    xout.Element("Virtual", Virtual);
+  } else if (!Default.empty()) {
+    xout.Element("Default", Default);
+  }
+
+  // Essential
+  if (!Essential.empty()) {
+    xout.Element("Essential", Essential);
+  }
 
   // Priority
-  if(!SortingPriority.empty())
-    {
-    xout << "    <SortingPriority>" << SortingPriority
-         << "</SortingPriority>" << std::endl;
-    }
+  if (!SortingPriority.empty()) {
+    xout.Element("SortingPriority", SortingPriority);
+  }
 
-  xout << "</Package>" << std::endl;
+  xout.EndElement();
+  xout.EndDocument();
 }
 
-void cmCPackIFWPackage::WriteGeneratedByToStrim(cmGeneratedFileStream &xout)
+void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout)
 {
-  if(Generator) Generator->WriteGeneratedByToStrim(xout);
+  if (Generator)
+    Generator->WriteGeneratedByToStrim(xout);
 }
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h
index d2f7927..55b07ec 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.h
+++ b/Source/CPack/IFW/cmCPackIFWPackage.h
@@ -14,26 +14,28 @@
 #define cmCPackIFWPackage_h
 
 #include <cmStandardIncludes.h>
-#include <cmGeneratedFileStream.h>
 
 class cmCPackComponent;
 class cmCPackComponentGroup;
 class cmCPackIFWInstaller;
 class cmCPackIFWGenerator;
+class cmXMLWriter;
 
 /** \class cmCPackIFWPackage
  * \brief A single component to be installed by CPack IFW generator
  */
 class cmCPackIFWPackage
 {
-public: // Types
+public:
+  // Types
+
   enum CompareTypes
   {
-    CompareNone           = 0x0,
-    CompareEqual          = 0x1,
-    CompareLess           = 0x2,
-    CompareLessOrEqual    = 0x3,
-    CompareGreater        = 0x4,
+    CompareNone = 0x0,
+    CompareEqual = 0x1,
+    CompareLess = 0x2,
+    CompareLessOrEqual = 0x3,
+    CompareGreater = 0x4,
     CompareGreaterOrEqual = 0x5
   };
 
@@ -48,27 +50,29 @@ public: // Types
   struct DependenceStruct
   {
     DependenceStruct();
-    DependenceStruct(const std::string &dependence);
+    DependenceStruct(const std::string& dependence);
 
     std::string Name;
     CompareStruct Compare;
 
     std::string NameWithCompare() const;
 
-    bool operator < (const DependenceStruct &other) const
-      {
+    bool operator<(const DependenceStruct& other) const
+    {
       return Name < other.Name;
-      }
+    }
   };
 
-public: // [Con|De]structor
+public:
+  // [Con|De]structor
 
   /**
    * Construct package
    */
   cmCPackIFWPackage();
 
-public: // Configuration
+public:
+  // Configuration
 
   /// Human-readable name of the component
   std::string DisplayName;
@@ -97,29 +101,33 @@ public: // Configuration
   /// Set to true to preselect the component in the installer
   std::string Default;
 
+  /// Marks the package as essential to force a restart of the MaintenanceTool
+  std::string Essential;
+
   /// Set to true to hide the component from the installer
   std::string Virtual;
 
   /// Determines that the package must always be installed
   std::string ForcedInstallation;
 
-public: // Internal implementation
+public:
+  // Internal implementation
 
   const char* GetOption(const std::string& op) const;
   bool IsOn(const std::string& op) const;
 
-  bool IsVersionLess(const char *version);
-  bool IsVersionGreater(const char *version);
-  bool IsVersionEqual(const char *version);
+  bool IsVersionLess(const char* version);
+  bool IsVersionGreater(const char* version);
+  bool IsVersionEqual(const char* version);
 
-  std::string GetComponentName(cmCPackComponent *component);
+  std::string GetComponentName(cmCPackComponent* component);
 
   void DefaultConfiguration();
 
   int ConfigureFromOptions();
-  int ConfigureFromComponent(cmCPackComponent *component);
-  int ConfigureFromGroup(cmCPackComponentGroup *group);
-  int ConfigureFromGroup(const std::string &groupName);
+  int ConfigureFromComponent(cmCPackComponent* component);
+  int ConfigureFromGroup(cmCPackComponentGroup* group);
+  int ConfigureFromGroup(const std::string& groupName);
 
   void GeneratePackageFile();
 
@@ -135,7 +143,7 @@ public: // Internal implementation
   std::string Directory;
 
 protected:
-  void WriteGeneratedByToStrim(cmGeneratedFileStream& xout);
+  void WriteGeneratedByToStrim(cmXMLWriter& xout);
 };
 
 #endif // cmCPackIFWPackage_h
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
new file mode 100644
index 0000000..45b47cd
--- /dev/null
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -0,0 +1,341 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "cmCPackIFWRepository.h"
+
+#include "cmCPackIFWGenerator.h"
+
+#include <CPack/cmCPackLog.h>
+
+#include <cmGeneratedFileStream.h>
+#include <cmXMLParser.h>
+#include <cmXMLWriter.h>
+
+#ifdef cmCPackLogger
+#undef cmCPackLogger
+#endif
+#define cmCPackLogger(logType, msg)                                           \
+  do {                                                                        \
+    std::ostringstream cmCPackLog_msg;                                        \
+    cmCPackLog_msg << msg;                                                    \
+    if (Generator) {                                                          \
+      Generator->Logger->Log(logType, __FILE__, __LINE__,                     \
+                             cmCPackLog_msg.str().c_str());                   \
+    }                                                                         \
+  } while (0)
+
+cmCPackIFWRepository::cmCPackIFWRepository()
+  : Update(None)
+  , Generator(0)
+{
+}
+
+bool cmCPackIFWRepository::IsValid() const
+{
+  bool valid = true;
+
+  switch (Update) {
+    case None:
+      valid = Url.empty() ? false : true;
+      break;
+    case Add:
+      valid = Url.empty() ? false : true;
+      break;
+    case Remove:
+      valid = Url.empty() ? false : true;
+      break;
+    case Replace:
+      valid = (OldUrl.empty() || NewUrl.empty()) ? false : true;
+      break;
+  }
+
+  return valid;
+}
+
+const char* cmCPackIFWRepository::GetOption(const std::string& op) const
+{
+  return Generator ? Generator->GetOption(op) : 0;
+}
+
+bool cmCPackIFWRepository::IsOn(const std::string& op) const
+{
+  return Generator ? Generator->IsOn(op) : false;
+}
+
+bool cmCPackIFWRepository::IsVersionLess(const char* version)
+{
+  return Generator ? Generator->IsVersionLess(version) : false;
+}
+
+bool cmCPackIFWRepository::IsVersionGreater(const char* version)
+{
+  return Generator ? Generator->IsVersionGreater(version) : false;
+}
+
+bool cmCPackIFWRepository::IsVersionEqual(const char* version)
+{
+  return Generator ? Generator->IsVersionEqual(version) : false;
+}
+
+bool cmCPackIFWRepository::ConfigureFromOptions()
+{
+  // Name;
+  if (Name.empty())
+    return false;
+
+  std::string prefix =
+    "CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(Name) + "_";
+
+  // Update
+  if (IsOn(prefix + "ADD")) {
+    Update = Add;
+  } else if (IsOn(prefix + "REMOVE")) {
+    Update = Remove;
+  } else if (IsOn(prefix + "REPLACE")) {
+    Update = Replace;
+  } else {
+    Update = None;
+  }
+
+  // Url
+  if (const char* url = GetOption(prefix + "URL")) {
+    Url = url;
+  } else {
+    Url = "";
+  }
+
+  // Old url
+  if (const char* oldUrl = GetOption(prefix + "OLD_URL")) {
+    OldUrl = oldUrl;
+  } else {
+    OldUrl = "";
+  }
+
+  // New url
+  if (const char* newUrl = GetOption(prefix + "NEW_URL")) {
+    NewUrl = newUrl;
+  } else {
+    NewUrl = "";
+  }
+
+  // Enabled
+  if (IsOn(prefix + "DISABLED")) {
+    Enabled = "0";
+  } else {
+    Enabled = "";
+  }
+
+  // Username
+  if (const char* username = GetOption(prefix + "USERNAME")) {
+    Username = username;
+  } else {
+    Username = "";
+  }
+
+  // Password
+  if (const char* password = GetOption(prefix + "PASSWORD")) {
+    Password = password;
+  } else {
+    Password = "";
+  }
+
+  // DisplayName
+  if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) {
+    DisplayName = displayName;
+  } else {
+    DisplayName = "";
+  }
+
+  return IsValid();
+}
+
+/** \class cmCPackeIFWUpdatesPatcher
+ * \brief Helper class that parses and patch Updates.xml file (QtIFW)
+ */
+class cmCPackeIFWUpdatesPatcher : public cmXMLParser
+{
+public:
+  cmCPackeIFWUpdatesPatcher(cmCPackIFWRepository* r, cmXMLWriter& x)
+    : repository(r)
+    , xout(x)
+    , patched(false)
+  {
+  }
+
+  cmCPackIFWRepository* repository;
+  cmXMLWriter& xout;
+  bool patched;
+
+protected:
+  virtual void StartElement(const std::string& name, const char** atts)
+  {
+    xout.StartElement(name);
+    StartFragment(atts);
+  }
+
+  void StartFragment(const char** atts)
+  {
+    for (size_t i = 0; atts[i]; i += 2) {
+      const char* key = atts[i];
+      const char* value = atts[i + 1];
+      xout.Attribute(key, value);
+    }
+  }
+
+  virtual void EndElement(const std::string& name)
+  {
+    if (name == "Updates" && !patched) {
+      repository->WriteRepositoryUpdates(xout);
+      patched = true;
+    }
+    xout.EndElement();
+    if (patched)
+      return;
+    if (name == "Checksum") {
+      repository->WriteRepositoryUpdates(xout);
+      patched = true;
+    }
+  }
+
+  virtual void CharacterDataHandler(const char* data, int length)
+  {
+    std::string content(data, data + length);
+    if (content == "" || content == " " || content == "  " || content == "\n")
+      return;
+    xout.Content(content);
+  }
+};
+
+bool cmCPackIFWRepository::PatchUpdatesXml()
+{
+  // Lazy directory initialization
+  if (Directory.empty() && Generator) {
+    Directory = Generator->toplevel;
+  }
+
+  // Filenames
+  std::string updatesXml = Directory + "/repository/Updates.xml";
+  std::string updatesPatchXml = Directory + "/repository/UpdatesPatch.xml";
+
+  // Output stream
+  cmGeneratedFileStream fout(updatesPatchXml.data());
+  cmXMLWriter xout(fout);
+
+  xout.StartDocument();
+
+  WriteGeneratedByToStrim(xout);
+
+  // Patch
+  {
+    cmCPackeIFWUpdatesPatcher patcher(this, xout);
+    patcher.ParseFile(updatesXml.data());
+  }
+
+  xout.EndDocument();
+
+  fout.Close();
+
+  if (!cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data())) {
+    return false;
+  }
+
+  return true;
+}
+
+void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout)
+{
+  xout.StartElement("Repository");
+
+  // Url
+  xout.Element("Url", Url);
+  // Enabled
+  if (!Enabled.empty()) {
+    xout.Element("Enabled", Enabled);
+  }
+  // Username
+  if (!Username.empty()) {
+    xout.Element("Username", Username);
+  }
+  // Password
+  if (!Password.empty()) {
+    xout.Element("Password", Password);
+  }
+  // DisplayName
+  if (!DisplayName.empty()) {
+    xout.Element("DisplayName", DisplayName);
+  }
+
+  xout.EndElement();
+}
+
+void cmCPackIFWRepository::WriteRepositoryUpdate(cmXMLWriter& xout)
+{
+  xout.StartElement("Repository");
+
+  switch (Update) {
+    case None:
+      break;
+    case Add:
+      xout.Attribute("action", "add");
+      break;
+    case Remove:
+      xout.Attribute("action", "remove");
+      break;
+    case Replace:
+      xout.Attribute("action", "replace");
+      break;
+  }
+
+  // Url
+  if (Update == Add || Update == Remove) {
+    xout.Attribute("url", Url);
+  } else if (Update == Replace) {
+    xout.Attribute("oldUrl", OldUrl);
+    xout.Attribute("newUrl", NewUrl);
+  }
+  // Enabled
+  if (!Enabled.empty()) {
+    xout.Attribute("enabled", Enabled);
+  }
+  // Username
+  if (!Username.empty()) {
+    xout.Attribute("username", Username);
+  }
+  // Password
+  if (!Password.empty()) {
+    xout.Attribute("password", Password);
+  }
+  // DisplayName
+  if (!DisplayName.empty()) {
+    xout.Attribute("displayname", DisplayName);
+  }
+
+  xout.EndElement();
+}
+
+void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout)
+{
+  if (!RepositoryUpdate.empty()) {
+    xout.StartElement("RepositoryUpdate");
+    for (RepositoriesVector::iterator rit = RepositoryUpdate.begin();
+         rit != RepositoryUpdate.end(); ++rit) {
+      (*rit)->WriteRepositoryUpdate(xout);
+    }
+    xout.EndElement();
+  }
+}
+
+void cmCPackIFWRepository::WriteGeneratedByToStrim(cmXMLWriter& xout)
+{
+  if (Generator)
+    Generator->WriteGeneratedByToStrim(xout);
+}
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.h b/Source/CPack/IFW/cmCPackIFWRepository.h
new file mode 100644
index 0000000..5ffb775
--- /dev/null
+++ b/Source/CPack/IFW/cmCPackIFWRepository.h
@@ -0,0 +1,105 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmCPackIFWRepository_h
+#define cmCPackIFWRepository_h
+
+#include <cmStandardIncludes.h>
+
+class cmCPackIFWGenerator;
+class cmXMLWriter;
+
+/** \class cmCPackIFWRepository
+ * \brief A remote repository to be created CPack IFW generator
+ */
+class cmCPackIFWRepository
+{
+public:
+  // Types
+
+  enum Action
+  {
+    None,
+    Add,
+    Remove,
+    Replace
+  };
+
+  typedef std::vector<cmCPackIFWRepository*> RepositoriesVector;
+
+public:
+  // Constructor
+
+  /**
+   * Construct repository
+   */
+  cmCPackIFWRepository();
+
+public:
+  // Configuration
+
+  /// Internal repository name
+  std::string Name;
+
+  /// Optional update action
+  Action Update;
+
+  /// Is points to a list of available components
+  std::string Url;
+
+  /// Is points to a list that will replaced
+  std::string OldUrl;
+
+  /// Is points to a list that will replace to
+  std::string NewUrl;
+
+  /// With "0" disabling this repository
+  std::string Enabled;
+
+  /// Is used as user on a protected repository
+  std::string Username;
+
+  /// Is password to use on a protected repository
+  std::string Password;
+
+  /// Is optional string to display instead of the URL
+  std::string DisplayName;
+
+public:
+  // Internal implementation
+
+  bool IsValid() const;
+
+  const char* GetOption(const std::string& op) const;
+  bool IsOn(const std::string& op) const;
+
+  bool IsVersionLess(const char* version);
+  bool IsVersionGreater(const char* version);
+  bool IsVersionEqual(const char* version);
+
+  bool ConfigureFromOptions();
+
+  bool PatchUpdatesXml();
+
+  void WriteRepositoryConfig(cmXMLWriter& xout);
+  void WriteRepositoryUpdate(cmXMLWriter& xout);
+  void WriteRepositoryUpdates(cmXMLWriter& xout);
+
+  cmCPackIFWGenerator* Generator;
+  RepositoriesVector RepositoryUpdate;
+  std::string Directory;
+
+protected:
+  void WriteGeneratedByToStrim(cmXMLWriter& xout);
+};
+
+#endif // cmCPackIFWRepository_h
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index c271517..19204a2 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -9,9 +9,9 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/Process.h>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Process.h>
+#include <cmsys/SystemTools.hxx>
 
 #include <iostream>
 
@@ -20,72 +20,65 @@
 // For the PATH_MAX constant
 #include <sys/syslimits.h>
 
-#define DebugError(x) \
-  ofs << x << std::endl; \
+#define DebugError(x)                                                         \
+  ofs << x << std::endl;                                                      \
   std::cout << x << std::endl
 
 int main(int argc, char* argv[])
 {
-  //if ( cmsys::SystemTools::FileExists(
+  // if ( cmsys::SystemTools::FileExists(
   std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
   cmsys::ofstream ofs("/tmp/output.txt");
 
   CFStringRef fileName;
   CFBundleRef appBundle;
   CFURLRef scriptFileURL;
-  UInt8 *path;
+  UInt8* path;
 
-  //get CF URL for script
-  if (! (appBundle = CFBundleGetMainBundle()))
-    {
+  // get CF URL for script
+  if (!(appBundle = CFBundleGetMainBundle())) {
     DebugError("Cannot get main bundle");
     return 1;
-    }
+  }
   fileName = CFSTR("RuntimeScript");
-  if (! (scriptFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL,
-        NULL)))
-    {
+  if (!(scriptFileURL =
+          CFBundleCopyResourceURL(appBundle, fileName, NULL, NULL))) {
     DebugError("CFBundleCopyResourceURL failed");
     return 1;
-    }
+  }
 
-  //create path string
-  if (! (path = new UInt8[PATH_MAX]))
-    {
+  // create path string
+  if (!(path = new UInt8[PATH_MAX])) {
     return 1;
-    }
+  }
 
-  //get the file system path of the url as a cstring
-  //in an encoding suitable for posix apis
-  if ( CFURLGetFileSystemRepresentation(scriptFileURL, true, path,
-        PATH_MAX) == false)
-    {
+  // get the file system path of the url as a cstring
+  // in an encoding suitable for posix apis
+  if (CFURLGetFileSystemRepresentation(scriptFileURL, true, path, PATH_MAX) ==
+      false) {
     DebugError("CFURLGetFileSystemRepresentation failed");
     return 1;
-    }
+  }
 
-  //dispose of the CF variable
+  // dispose of the CF variable
   CFRelease(scriptFileURL);
 
   std::string fullScriptPath = reinterpret_cast<char*>(path);
-  delete [] path;
-
+  delete[] path;
 
-  if (! cmsys::SystemTools::FileExists(fullScriptPath.c_str()))
-    {
+  if (!cmsys::SystemTools::FileExists(fullScriptPath.c_str())) {
     return 1;
-    }
+  }
 
-  std::string scriptDirectory = cmsys::SystemTools::GetFilenamePath(
-    fullScriptPath);
+  std::string scriptDirectory =
+    cmsys::SystemTools::GetFilenamePath(fullScriptPath);
   ofs << fullScriptPath.c_str() << std::endl;
   std::vector<const char*> args;
   args.push_back(fullScriptPath.c_str());
   int cc;
-  for ( cc = 1; cc < argc; ++ cc )
-    {
+  for (cc = 1; cc < argc; ++cc) {
     args.push_back(argv[cc]);
-    }
+  }
   args.push_back(0);
 
   cmsysProcess* cp = cmsysProcess_New();
@@ -98,49 +91,38 @@ int main(int argc, char* argv[])
   std::vector<char> tempOutput;
   char* data;
   int length;
-  while(cmsysProcess_WaitForData(cp, &data, &length, 0))
-    {
+  while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
     // Translate NULL characters in the output into valid text.
     // Visual Studio 7 puts these characters in the output of its
     // build process.
-    for(int i=0; i < length; ++i)
-      {
-      if(data[i] == '\0')
-        {
+    for (int i = 0; i < length; ++i) {
+      if (data[i] == '\0') {
         data[i] = ' ';
-        }
       }
-    std::cout.write(data, length);
     }
+    std::cout.write(data, length);
+  }
 
   cmsysProcess_WaitForExit(cp, 0);
 
   bool result = true;
-  if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
-    {
-    if ( cmsysProcess_GetExitValue(cp) !=  0 )
-      {
+  if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
+    if (cmsysProcess_GetExitValue(cp) != 0) {
       result = false;
-      }
     }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
     const char* exception_str = cmsysProcess_GetExceptionString(cp);
     std::cerr << exception_str << std::endl;
     result = false;
-    }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
     const char* error_str = cmsysProcess_GetErrorString(cp);
     std::cerr << error_str << std::endl;
     result = false;
-    }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
     const char* error_str = "Process terminated due to timeout\n";
     std::cerr << error_str << std::endl;
     result = false;
-    }
+  }
 
   cmsysProcess_Delete(cp);
 
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index ece327a..8777296 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -12,38 +12,36 @@
 
 #include "cmCPackWIXGenerator.h"
 
-#include <cmSystemTools.h>
-#include <cmGeneratedFileStream.h>
+#include <CPack/cmCPackComponentGroup.h>
+#include <CPack/cmCPackLog.h>
 #include <cmCryptoHash.h>
+#include <cmGeneratedFileStream.h>
 #include <cmInstalledFile.h>
-#include <CPack/cmCPackLog.h>
-#include <CPack/cmCPackComponentGroup.h>
+#include <cmSystemTools.h>
 
-#include "cmWIXSourceWriter.h"
 #include "cmWIXDirectoriesSourceWriter.h"
 #include "cmWIXFeaturesSourceWriter.h"
 #include "cmWIXFilesSourceWriter.h"
 #include "cmWIXRichTextFormatWriter.h"
+#include "cmWIXSourceWriter.h"
 
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Directory.hxx>
 #include <cmsys/Encoding.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/SystemTools.hxx>
 
 #include <rpc.h> // for GUID generation
 
-cmCPackWIXGenerator::cmCPackWIXGenerator():
-  Patch(0)
+cmCPackWIXGenerator::cmCPackWIXGenerator()
+  : Patch(0)
 {
-
 }
 
 cmCPackWIXGenerator::~cmCPackWIXGenerator()
 {
-  if(this->Patch)
-    {
+  if (this->Patch) {
     delete this->Patch;
-    }
+  }
 }
 
 int cmCPackWIXGenerator::InitializeInternal()
@@ -58,41 +56,39 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
 {
   std::string logFileName = this->CPackTopLevel + "/wix.log";
 
-  cmCPackLogger(cmCPackLog::LOG_DEBUG,
-    "Running WiX command: " << command << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Running WiX command: " << command
+                                                               << std::endl);
 
   std::string output;
 
   int returnValue = 0;
-  bool status = cmSystemTools::RunSingleCommand(
-    command.c_str(), &output, &output,
-    &returnValue, 0, cmSystemTools::OUTPUT_NONE);
+  bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output,
+                                                &output, &returnValue, 0,
+                                                cmSystemTools::OUTPUT_NONE);
 
   cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
   logFile << command << std::endl;
   logFile << output;
   logFile.close();
 
-  if(!status || returnValue)
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Problem running WiX candle. "
-      "Please check '" << logFileName << "' for errors." << std::endl);
+  if (!status || returnValue) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running WiX candle. "
+                                         "Please check '"
+                    << logFileName << "' for errors." << std::endl);
 
     return false;
-    }
+  }
 
   return true;
 }
 
-bool cmCPackWIXGenerator::RunCandleCommand(
-  std::string const& sourceFile, std::string const& objectFile)
+bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
+                                           std::string const& objectFile)
 {
   std::string executable;
-  if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable))
-    {
+  if (!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable)) {
     return false;
-    }
+  }
 
   std::stringstream command;
   command << QuotePath(executable);
@@ -100,11 +96,10 @@ bool cmCPackWIXGenerator::RunCandleCommand(
   command << " -arch " << GetArchitecture();
   command << " -out " << QuotePath(objectFile);
 
-  for(extension_set_t::const_iterator i = CandleExtensions.begin();
-      i != CandleExtensions.end(); ++i)
-    {
+  for (extension_set_t::const_iterator i = CandleExtensions.begin();
+       i != CandleExtensions.end(); ++i) {
     command << " -ext " << QuotePath(*i);
-    }
+  }
 
   AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command);
 
@@ -116,27 +111,24 @@ bool cmCPackWIXGenerator::RunCandleCommand(
 bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
 {
   std::string executable;
-  if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable))
-    {
+  if (!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable)) {
     return false;
-    }
+  }
 
   std::stringstream command;
   command << QuotePath(executable);
   command << " -nologo";
   command << " -out " << QuotePath(packageFileNames.at(0));
 
-  for(extension_set_t::const_iterator i = this->LightExtensions.begin();
-      i != this->LightExtensions.end(); ++i)
-    {
+  for (extension_set_t::const_iterator i = this->LightExtensions.begin();
+       i != this->LightExtensions.end(); ++i) {
     command << " -ext " << QuotePath(*i);
-    }
+  }
 
   const char* const cultures = GetOption("CPACK_WIX_CULTURES");
-  if(cultures)
-    {
+  if (cultures) {
     command << " -cultures:" << cultures;
-    }
+  }
 
   AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command);
 
@@ -147,90 +139,80 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
 
 int cmCPackWIXGenerator::PackageFiles()
 {
-  if(!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Fatal WiX Generator Error" << std::endl);
+  if (!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Fatal WiX Generator Error"
+                    << std::endl);
     return false;
-    }
+  }
 
   return true;
 }
 
 bool cmCPackWIXGenerator::InitializeWiXConfiguration()
 {
-  if(!ReadListFile("CPackWIX.cmake"))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Error while executing CPackWIX.cmake" << std::endl);
+  if (!ReadListFile("CPackWIX.cmake")) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while executing CPackWIX.cmake"
+                    << std::endl);
     return false;
-    }
+  }
 
-  if(GetOption("CPACK_WIX_PRODUCT_GUID") == 0)
-    {
+  if (GetOption("CPACK_WIX_PRODUCT_GUID") == 0) {
     std::string guid = GenerateGUID();
     SetOption("CPACK_WIX_PRODUCT_GUID", guid.c_str());
 
     cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-      "CPACK_WIX_PRODUCT_GUID implicitly set to " << guid << " . "
-      << std::endl);
-    }
+                  "CPACK_WIX_PRODUCT_GUID implicitly set to " << guid << " . "
+                                                              << std::endl);
+  }
 
-  if(GetOption("CPACK_WIX_UPGRADE_GUID") == 0)
-    {
+  if (GetOption("CPACK_WIX_UPGRADE_GUID") == 0) {
     std::string guid = GenerateGUID();
     SetOption("CPACK_WIX_UPGRADE_GUID", guid.c_str());
 
-    cmCPackLogger(cmCPackLog::LOG_WARNING,
-      "CPACK_WIX_UPGRADE_GUID implicitly set to " << guid << " . "
-      "Please refer to the documentation on how and why "
-      "you might want to set this explicitly." << std::endl);
-    }
+    cmCPackLogger(
+      cmCPackLog::LOG_WARNING, "CPACK_WIX_UPGRADE_GUID implicitly set to "
+        << guid << " . "
+                   "Please refer to the documentation on how and why "
+                   "you might want to set this explicitly."
+        << std::endl);
+  }
 
-  if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel))
-    {
+  if (!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel)) {
     return false;
-    }
+  }
 
-  if(GetOption("CPACK_WIX_LICENSE_RTF") == 0)
-    {
+  if (GetOption("CPACK_WIX_LICENSE_RTF") == 0) {
     std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
     SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
 
-    if(!CreateLicenseFile())
-      {
+    if (!CreateLicenseFile()) {
       return false;
-      }
     }
+  }
 
-  if(GetOption("CPACK_PACKAGE_VENDOR") == 0)
-    {
+  if (GetOption("CPACK_PACKAGE_VENDOR") == 0) {
     std::string defaultVendor = "Humanity";
     SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str());
 
     cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-      "CPACK_PACKAGE_VENDOR implicitly set to " << defaultVendor << " . "
-      << std::endl);
-    }
+                  "CPACK_PACKAGE_VENDOR implicitly set to "
+                    << defaultVendor << " . " << std::endl);
+  }
 
-  if(GetOption("CPACK_WIX_UI_REF") == 0)
-    {
+  if (GetOption("CPACK_WIX_UI_REF") == 0) {
     std::string defaultRef = "WixUI_InstallDir";
 
-    if(!this->Components.empty())
-      {
+    if (!this->Components.empty()) {
       defaultRef = "WixUI_FeatureTree";
-      }
+    }
 
     SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
-    }
+  }
 
   const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
-  if(packageContact != 0 &&
-     GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0)
-    {
+  if (packageContact != 0 && GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0) {
     SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
-    }
+  }
 
   CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
   CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions);
@@ -240,46 +222,40 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
   CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
 
   const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
-  if(patchFilePath)
-    {
+  if (patchFilePath) {
     std::vector<std::string> patchFilePaths;
     cmSystemTools::ExpandListArgument(patchFilePath, patchFilePaths);
 
-    for(size_t i = 0; i < patchFilePaths.size(); ++i)
-      {
-      if(!this->Patch->LoadFragments(patchFilePaths[i]))
-        {
+    for (size_t i = 0; i < patchFilePaths.size(); ++i) {
+      if (!this->Patch->LoadFragments(patchFilePaths[i])) {
         return false;
-        }
       }
     }
+  }
 
   return true;
 }
 
 bool cmCPackWIXGenerator::PackageFilesImpl()
 {
-  if(!InitializeWiXConfiguration())
-    {
+  if (!InitializeWiXConfiguration()) {
     return false;
-    }
+  }
 
   CreateWiXVariablesIncludeFile();
   CreateWiXPropertiesIncludeFile();
   CreateWiXProductFragmentIncludeFile();
 
-  if(!CreateWiXSourceFiles())
-    {
+  if (!CreateWiXSourceFiles()) {
     return false;
-    }
+  }
 
   AppendUserSuppliedExtraSources();
 
   std::set<std::string> usedBaseNames;
 
   std::stringstream objectFiles;
-  for(size_t i = 0; i < this->WixSources.size(); ++i)
-    {
+  for (size_t i = 0; i < this->WixSources.size(); ++i) {
     std::string const& sourceFilename = this->WixSources[i];
 
     std::string baseName =
@@ -288,25 +264,23 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
     unsigned int counter = 0;
     std::string uniqueBaseName = baseName;
 
-    while(usedBaseNames.find(uniqueBaseName) != usedBaseNames.end())
-      {
+    while (usedBaseNames.find(uniqueBaseName) != usedBaseNames.end()) {
       std::stringstream tmp;
       tmp << baseName << ++counter;
       uniqueBaseName = tmp.str();
-      }
+    }
 
     usedBaseNames.insert(uniqueBaseName);
 
     std::string objectFilename =
       this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj";
 
-    if(!RunCandleCommand(sourceFilename, objectFilename))
-      {
+    if (!RunCandleCommand(sourceFilename, objectFilename)) {
       return false;
-      }
+    }
 
     objectFiles << " " << QuotePath(objectFilename);
-    }
+  }
 
   AppendUserSuppliedExtraObjects(objectFiles);
 
@@ -315,35 +289,34 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
 
 void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
 {
-  const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
-  if(!cpackWixExtraSources) return;
+  const char* cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
+  if (!cpackWixExtraSources)
+    return;
 
   cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
 }
 
 void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
 {
-  const char *cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
-  if(!cpackWixExtraObjects) return;
+  const char* cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
+  if (!cpackWixExtraObjects)
+    return;
 
   std::vector<std::string> expandedExtraObjects;
 
-  cmSystemTools::ExpandListArgument(
-    cpackWixExtraObjects, expandedExtraObjects);
+  cmSystemTools::ExpandListArgument(cpackWixExtraObjects,
+                                    expandedExtraObjects);
 
-  for(size_t i = 0; i < expandedExtraObjects.size(); ++i)
-    {
+  for (size_t i = 0; i < expandedExtraObjects.size(); ++i) {
     stream << " " << QuotePath(expandedExtraObjects[i]);
-    }
+  }
 }
 
 void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
 {
-  std::string includeFilename =
-    this->CPackTopLevel + "/cpack_variables.wxi";
+  std::string includeFilename = this->CPackTopLevel + "/cpack_variables.wxi";
 
-  cmWIXSourceWriter includeFile(
-    this->Logger, includeFilename, true);
+  cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
 
   CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
   CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
@@ -355,29 +328,25 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
   CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER");
   CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG");
   SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER",
-    GetOption("CPACK_PACKAGE_NAME"));
+                    GetOption("CPACK_PACKAGE_NAME"));
   CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
   CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
 }
 
 void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
 {
-  std::string includeFilename =
-    this->CPackTopLevel + "/properties.wxi";
+  std::string includeFilename = this->CPackTopLevel + "/properties.wxi";
 
-  cmWIXSourceWriter includeFile(
-    this->Logger, includeFilename, true);
+  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)
-    {
+  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)
-      {
+    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());
 
@@ -385,11 +354,10 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
       includeFile.AddAttribute("Id", id);
       includeFile.AddAttribute("Value", value);
       includeFile.EndElement("Property");
-      }
     }
+  }
 
-  if(GetOption("CPACK_WIX_PROPERTY_ARPINSTALLLOCATION") == 0)
-    {
+  if (GetOption("CPACK_WIX_PROPERTY_ARPINSTALLLOCATION") == 0) {
     includeFile.BeginElement("Property");
     includeFile.AddAttribute("Id", "INSTALL_ROOT");
     includeFile.AddAttribute("Secure", "yes");
@@ -397,8 +365,9 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
     includeFile.BeginElement("RegistrySearch");
     includeFile.AddAttribute("Id", "FindInstallLocation");
     includeFile.AddAttribute("Root", "HKLM");
-    includeFile.AddAttribute("Key", "Software\\Microsoft\\Windows\\"
-      "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]");
+    includeFile.AddAttribute(
+      "Key", "Software\\Microsoft\\Windows\\"
+             "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]");
     includeFile.AddAttribute("Name", "InstallLocation");
     includeFile.AddAttribute("Type", "raw");
     includeFile.EndElement("RegistrySearch");
@@ -409,38 +378,36 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
     includeFile.AddAttribute("Value", "[INSTALL_ROOT]");
     includeFile.AddAttribute("After", "CostFinalize");
     includeFile.EndElement("SetProperty");
-    }
+  }
 }
 
 void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile()
 {
-    std::string includeFilename =
-      this->CPackTopLevel + "/product_fragment.wxi";
+  std::string includeFilename = this->CPackTopLevel + "/product_fragment.wxi";
 
-    cmWIXSourceWriter includeFile(
-      this->Logger, includeFilename, true);
+  cmWIXSourceWriter includeFile(this->Logger, includeFilename, true);
 
-    this->Patch->ApplyFragment("#PRODUCT", includeFile);
+  this->Patch->ApplyFragment("#PRODUCT", includeFile);
 }
 
-void cmCPackWIXGenerator::CopyDefinition(
-  cmWIXSourceWriter &source, std::string const& name)
+void cmCPackWIXGenerator::CopyDefinition(cmWIXSourceWriter& source,
+                                         std::string const& name)
 {
   const char* value = GetOption(name.c_str());
-  if(value)
-    {
+  if (value) {
     AddDefinition(source, name, value);
-    }
+  }
 }
 
 void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
-  std::string const& name, std::string const& value)
+                                        std::string const& name,
+                                        std::string const& value)
 {
   std::stringstream tmp;
   tmp << name << "=\"" << value << '"';
 
-  source.AddProcessingInstruction("define",
-    cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str()));
+  source.AddProcessingInstruction(
+    "define", cmWIXSourceWriter::CMakeEncodingToUtf8(tmp.str()));
 }
 
 bool cmCPackWIXGenerator::CreateWiXSourceFiles()
@@ -455,10 +422,9 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
   directoryDefinitions.BeginElement("Fragment");
 
   std::string installRoot;
-  if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot))
-    {
+  if (!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot)) {
     return false;
-    }
+  }
 
   directoryDefinitions.BeginElement("Directory");
   directoryDefinitions.AddAttribute("Id", "TARGETDIR");
@@ -468,23 +434,22 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
     directoryDefinitions.BeginInstallationPrefixDirectory(
       GetProgramFilesFolderId(), installRoot);
 
-  std::string fileDefinitionsFilename =
-    this->CPackTopLevel + "/files.wxs";
+  std::string fileDefinitionsFilename = this->CPackTopLevel + "/files.wxs";
 
   this->WixSources.push_back(fileDefinitionsFilename);
 
-  cmWIXFilesSourceWriter fileDefinitions(
-    this->Logger, fileDefinitionsFilename);
+  cmWIXFilesSourceWriter fileDefinitions(this->Logger,
+                                         fileDefinitionsFilename);
 
   fileDefinitions.BeginElement("Fragment");
 
   std::string featureDefinitionsFilename =
-      this->CPackTopLevel +"/features.wxs";
+    this->CPackTopLevel + "/features.wxs";
 
   this->WixSources.push_back(featureDefinitionsFilename);
 
-  cmWIXFeaturesSourceWriter featureDefinitions(
-    this->Logger, featureDefinitionsFilename);
+  cmWIXFeaturesSourceWriter featureDefinitions(this->Logger,
+                                               featureDefinitionsFilename);
 
   featureDefinitions.BeginElement("Fragment");
 
@@ -495,45 +460,39 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
   featureDefinitions.AddAttribute("ConfigurableDirectory", "INSTALL_ROOT");
 
   std::string cpackPackageName;
-  if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName))
-    {
+  if (!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) {
     return false;
-    }
+  }
 
   featureDefinitions.AddAttribute("Title", cpackPackageName);
   featureDefinitions.AddAttribute("Level", "1");
   this->Patch->ApplyFragment("#PRODUCTFEATURE", featureDefinitions);
 
   const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
-  if(package)
-    {
+  if (package) {
     featureDefinitions.CreateCMakePackageRegistryEntry(
-        package, GetOption("CPACK_WIX_UPGRADE_GUID"));
-    }
+      package, GetOption("CPACK_WIX_UPGRADE_GUID"));
+  }
 
-  if(!CreateFeatureHierarchy(featureDefinitions))
-    {
+  if (!CreateFeatureHierarchy(featureDefinitions)) {
     return false;
-    }
+  }
 
   featureDefinitions.EndElement("Feature");
 
   std::set<cmWIXShortcuts::Type> emittedShortcutTypes;
 
   cmWIXShortcuts globalShortcuts;
-  if(Components.empty())
-    {
-    AddComponentsToFeature(toplevel, "ProductFeature",
-      directoryDefinitions, fileDefinitions, featureDefinitions,
-      globalShortcuts);
+  if (Components.empty()) {
+    AddComponentsToFeature(toplevel, "ProductFeature", directoryDefinitions,
+                           fileDefinitions, featureDefinitions,
+                           globalShortcuts);
 
     globalShortcuts.AddShortcutTypes(emittedShortcutTypes);
-    }
-  else
-    {
-    for(std::map<std::string, cmCPackComponent>::const_iterator
-      i = this->Components.begin(); i != this->Components.end(); ++i)
-      {
+  } else {
+    for (std::map<std::string, cmCPackComponent>::const_iterator i =
+           this->Components.begin();
+         i != this->Components.end(); ++i) {
       cmCPackComponent const& component = i->second;
 
       std::string componentPath = toplevel;
@@ -544,102 +503,91 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
 
       cmWIXShortcuts featureShortcuts;
       AddComponentsToFeature(componentPath, componentFeatureId,
-        directoryDefinitions, fileDefinitions,
-        featureDefinitions, featureShortcuts);
+                             directoryDefinitions, fileDefinitions,
+                             featureDefinitions, featureShortcuts);
 
       featureShortcuts.AddShortcutTypes(emittedShortcutTypes);
 
-      if(!CreateShortcuts(component.Name, componentFeatureId,
-        featureShortcuts, false, fileDefinitions, featureDefinitions))
-        {
+      if (!CreateShortcuts(component.Name, componentFeatureId,
+                           featureShortcuts, false, fileDefinitions,
+                           featureDefinitions)) {
         return false;
-        }
       }
     }
+  }
 
-  bool emitUninstallShortcut = emittedShortcutTypes.find(
-    cmWIXShortcuts::START_MENU) != emittedShortcutTypes.end();
+  bool emitUninstallShortcut =
+    emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
+    emittedShortcutTypes.end();
 
-  if(!CreateShortcuts(std::string(), "ProductFeature",
-      globalShortcuts, emitUninstallShortcut,
-      fileDefinitions, featureDefinitions))
-    {
+  if (!CreateShortcuts(std::string(), "ProductFeature", globalShortcuts,
+                       emitUninstallShortcut, fileDefinitions,
+                       featureDefinitions)) {
     return false;
-    }
+  }
 
   featureDefinitions.EndElement("Fragment");
   fileDefinitions.EndElement("Fragment");
 
-  directoryDefinitions.EndInstallationPrefixDirectory(
-    installRootSize);
+  directoryDefinitions.EndInstallationPrefixDirectory(installRootSize);
 
-  if(emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
-      emittedShortcutTypes.end())
-    {
+  if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
+      emittedShortcutTypes.end()) {
     directoryDefinitions.EmitStartMenuFolder(
       GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"));
-    }
+  }
 
-  if(emittedShortcutTypes.find(cmWIXShortcuts::DESKTOP) !=
-      emittedShortcutTypes.end())
-    {
+  if (emittedShortcutTypes.find(cmWIXShortcuts::DESKTOP) !=
+      emittedShortcutTypes.end()) {
     directoryDefinitions.EmitDesktopFolder();
-    }
+  }
 
-  if(emittedShortcutTypes.find(cmWIXShortcuts::STARTUP) !=
-      emittedShortcutTypes.end())
-    {
+  if (emittedShortcutTypes.find(cmWIXShortcuts::STARTUP) !=
+      emittedShortcutTypes.end()) {
     directoryDefinitions.EmitStartupFolder();
-    }
+  }
 
   directoryDefinitions.EndElement("Directory");
   directoryDefinitions.EndElement("Fragment");
 
-  if(!GenerateMainSourceFileFromTemplate())
-    {
+  if (!GenerateMainSourceFileFromTemplate()) {
     return false;
-    }
+  }
 
   return this->Patch->CheckForUnappliedFragments();
 }
 
 std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
 {
-  if(GetArchitecture() == "x86")
-    {
+  if (GetArchitecture() == "x86") {
     return "ProgramFilesFolder";
-    }
-  else
-    {
+  } else {
     return "ProgramFiles64Folder";
-    }
+  }
 }
 
 bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
 {
   std::string wixTemplate = FindTemplate("WIX.template.in");
-  if(GetOption("CPACK_WIX_TEMPLATE") != 0)
-    {
+  if (GetOption("CPACK_WIX_TEMPLATE") != 0) {
     wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
-    }
+  }
 
-  if(wixTemplate.empty())
-    {
+  if (wixTemplate.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Could not find CPack WiX template file WIX.template.in" << std::endl);
+                  "Could not find CPack WiX template file WIX.template.in"
+                    << std::endl);
     return false;
-    }
+  }
 
   std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
 
-  if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str()))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Failed creating '" << mainSourceFilePath  <<
-      "'' from template." << std::endl);
+  if (!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath.c_str())) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed creating '"
+                    << mainSourceFilePath << "'' from template." << std::endl);
 
     return false;
-    }
+  }
 
   this->WixSources.push_back(mainSourceFilePath);
 
@@ -649,70 +597,64 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
 bool cmCPackWIXGenerator::CreateFeatureHierarchy(
   cmWIXFeaturesSourceWriter& featureDefinitions)
 {
-  for(std::map<std::string, cmCPackComponentGroup>::const_iterator
-    i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i)
-    {
+  for (std::map<std::string, cmCPackComponentGroup>::const_iterator i =
+         ComponentGroups.begin();
+       i != ComponentGroups.end(); ++i) {
     cmCPackComponentGroup const& group = i->second;
-    if(group.ParentGroup == 0)
-      {
+    if (group.ParentGroup == 0) {
       featureDefinitions.EmitFeatureForComponentGroup(group);
-      }
     }
+  }
 
-  for(std::map<std::string, cmCPackComponent>::const_iterator
-    i = this->Components.begin(); i != this->Components.end(); ++i)
-    {
+  for (std::map<std::string, cmCPackComponent>::const_iterator i =
+         this->Components.begin();
+       i != this->Components.end(); ++i) {
     cmCPackComponent const& component = i->second;
 
-    if(!component.Group)
-      {
+    if (!component.Group) {
       featureDefinitions.EmitFeatureForComponent(component);
-      }
     }
+  }
 
   return true;
 }
 
 bool cmCPackWIXGenerator::AddComponentsToFeature(
-  std::string const& rootPath,
-  std::string const& featureId,
+  std::string const& rootPath, std::string const& featureId,
   cmWIXDirectoriesSourceWriter& directoryDefinitions,
   cmWIXFilesSourceWriter& fileDefinitions,
-  cmWIXFeaturesSourceWriter& featureDefinitions,
-  cmWIXShortcuts& shortcuts)
+  cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXShortcuts& shortcuts)
 {
   featureDefinitions.BeginElement("FeatureRef");
   featureDefinitions.AddAttribute("Id", featureId);
 
   std::vector<std::string> cpackPackageExecutablesList;
-  const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
-  if(cpackPackageExecutables)
-    {
-      cmSystemTools::ExpandListArgument(cpackPackageExecutables,
-        cpackPackageExecutablesList);
-      if(cpackPackageExecutablesList.size() % 2 != 0 )
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
-          "<text label>." << std::endl);
-        return false;
-        }
+  const char* cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
+  if (cpackPackageExecutables) {
+    cmSystemTools::ExpandListArgument(cpackPackageExecutables,
+                                      cpackPackageExecutablesList);
+    if (cpackPackageExecutablesList.size() % 2 != 0) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR,
+        "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
+        "<text label>."
+          << std::endl);
+      return false;
     }
+  }
 
   std::vector<std::string> cpackPackageDesktopLinksList;
-  const char *cpackPackageDesktopLinks =
+  const char* cpackPackageDesktopLinks =
     GetOption("CPACK_CREATE_DESKTOP_LINKS");
-  if(cpackPackageDesktopLinks)
-    {
-      cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks,
-        cpackPackageDesktopLinksList);
-    }
+  if (cpackPackageDesktopLinks) {
+    cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks,
+                                      cpackPackageDesktopLinksList);
+  }
 
-  AddDirectoryAndFileDefinitons(
-    rootPath, "INSTALL_ROOT",
-    directoryDefinitions, fileDefinitions, featureDefinitions,
-    cpackPackageExecutablesList, cpackPackageDesktopLinksList,
-    shortcuts);
+  AddDirectoryAndFileDefinitons(rootPath, "INSTALL_ROOT", directoryDefinitions,
+                                fileDefinitions, featureDefinitions,
+                                cpackPackageExecutablesList,
+                                cpackPackageDesktopLinksList, shortcuts);
 
   featureDefinitions.EndElement("FeatureRef");
 
@@ -720,62 +662,48 @@ bool cmCPackWIXGenerator::AddComponentsToFeature(
 }
 
 bool cmCPackWIXGenerator::CreateShortcuts(
-  std::string const& cpackComponentName,
-  std::string const& featureId,
-  cmWIXShortcuts const& shortcuts,
-  bool emitUninstallShortcut,
+  std::string const& cpackComponentName, std::string const& featureId,
+  cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
   cmWIXFilesSourceWriter& fileDefinitions,
   cmWIXFeaturesSourceWriter& featureDefinitions)
 {
-  if(!shortcuts.empty(cmWIXShortcuts::START_MENU))
-    {
-    if(!this->CreateShortcutsOfSpecificType(cmWIXShortcuts::START_MENU,
-      cpackComponentName, featureId, "",
-      shortcuts, emitUninstallShortcut,
-      fileDefinitions, featureDefinitions))
-      {
+  if (!shortcuts.empty(cmWIXShortcuts::START_MENU)) {
+    if (!this->CreateShortcutsOfSpecificType(
+          cmWIXShortcuts::START_MENU, cpackComponentName, featureId, "",
+          shortcuts, emitUninstallShortcut, fileDefinitions,
+          featureDefinitions)) {
       return false;
-      }
     }
+  }
 
-  if(!shortcuts.empty(cmWIXShortcuts::DESKTOP))
-    {
-    if(!this->CreateShortcutsOfSpecificType(cmWIXShortcuts::DESKTOP,
-      cpackComponentName, featureId, "DESKTOP",
-      shortcuts, false,
-      fileDefinitions, featureDefinitions))
-      {
+  if (!shortcuts.empty(cmWIXShortcuts::DESKTOP)) {
+    if (!this->CreateShortcutsOfSpecificType(
+          cmWIXShortcuts::DESKTOP, cpackComponentName, featureId, "DESKTOP",
+          shortcuts, false, fileDefinitions, featureDefinitions)) {
       return false;
-      }
     }
+  }
 
-  if(!shortcuts.empty(cmWIXShortcuts::STARTUP))
-    {
-    if(!this->CreateShortcutsOfSpecificType(cmWIXShortcuts::STARTUP,
-      cpackComponentName, featureId, "STARTUP",
-      shortcuts, false,
-      fileDefinitions, featureDefinitions))
-      {
+  if (!shortcuts.empty(cmWIXShortcuts::STARTUP)) {
+    if (!this->CreateShortcutsOfSpecificType(
+          cmWIXShortcuts::STARTUP, cpackComponentName, featureId, "STARTUP",
+          shortcuts, false, fileDefinitions, featureDefinitions)) {
       return false;
-      }
     }
+  }
 
   return true;
 }
 
 bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
-  cmWIXShortcuts::Type type,
-  std::string const& cpackComponentName,
-  std::string const& featureId,
-  std::string const& idPrefix,
-  cmWIXShortcuts const& shortcuts,
-  bool emitUninstallShortcut,
+  cmWIXShortcuts::Type type, std::string const& cpackComponentName,
+  std::string const& featureId, std::string const& idPrefix,
+  cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
   cmWIXFilesSourceWriter& fileDefinitions,
   cmWIXFeaturesSourceWriter& featureDefinitions)
 {
   std::string directoryId;
-  switch(type)
-    {
+  switch (type) {
     case cmWIXShortcuts::START_MENU:
       directoryId = "PROGRAM_MENU_FOLDER";
       break;
@@ -787,35 +715,31 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
       break;
     default:
       return false;
-    }
+  }
 
   featureDefinitions.BeginElement("FeatureRef");
   featureDefinitions.AddAttribute("Id", featureId);
 
   std::string cpackVendor;
-  if(!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor))
-    {
+  if (!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor)) {
     return false;
-    }
+  }
 
   std::string cpackPackageName;
-  if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName))
-    {
+  if (!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) {
     return false;
-    }
+  }
 
   std::string idSuffix;
-  if(!cpackComponentName.empty())
-    {
-      idSuffix += "_";
-      idSuffix += cpackComponentName;
-    }
+  if (!cpackComponentName.empty()) {
+    idSuffix += "_";
+    idSuffix += cpackComponentName;
+  }
 
   std::string componentId = "CM_SHORTCUT";
-  if(idPrefix.size())
-    {
+  if (idPrefix.size()) {
     componentId += "_" + idPrefix;
-    }
+  }
 
   componentId += idSuffix;
 
@@ -828,22 +752,20 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
 
   this->Patch->ApplyFragment(componentId, fileDefinitions);
 
-  std::string registryKey = std::string("Software\\") +
-    cpackVendor + "\\" + cpackPackageName;
+  std::string registryKey =
+    std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
 
-  shortcuts.EmitShortcuts(type, registryKey,
-    cpackComponentName, fileDefinitions);
+  shortcuts.EmitShortcuts(type, registryKey, cpackComponentName,
+                          fileDefinitions);
 
-  if(type == cmWIXShortcuts::START_MENU)
-    {
-    fileDefinitions.EmitRemoveFolder(
-      "CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix);
-    }
+  if (type == cmWIXShortcuts::START_MENU) {
+    fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
+                                     idSuffix);
+  }
 
-  if(emitUninstallShortcut)
-    {
+  if (emitUninstallShortcut) {
     fileDefinitions.EmitUninstallShortcut(cpackPackageName);
-    }
+  }
 
   fileDefinitions.EndElement("Component");
   fileDefinitions.EndElement("DirectoryRef");
@@ -857,53 +779,43 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
 bool cmCPackWIXGenerator::CreateLicenseFile()
 {
   std::string licenseSourceFilename;
-  if(!RequireOption("CPACK_RESOURCE_FILE_LICENSE", licenseSourceFilename))
-    {
+  if (!RequireOption("CPACK_RESOURCE_FILE_LICENSE", licenseSourceFilename)) {
     return false;
-    }
+  }
 
   std::string licenseDestinationFilename;
-  if(!RequireOption("CPACK_WIX_LICENSE_RTF", licenseDestinationFilename))
-    {
+  if (!RequireOption("CPACK_WIX_LICENSE_RTF", licenseDestinationFilename)) {
     return false;
-    }
+  }
 
   std::string extension = GetRightmostExtension(licenseSourceFilename);
 
-  if(extension == ".rtf")
-    {
-    cmSystemTools::CopyAFile(
-      licenseSourceFilename.c_str(),
-      licenseDestinationFilename.c_str());
-    }
-  else if(extension == ".txt")
-    {
+  if (extension == ".rtf") {
+    cmSystemTools::CopyAFile(licenseSourceFilename.c_str(),
+                             licenseDestinationFilename.c_str());
+  } else if (extension == ".txt") {
     cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename);
 
     cmsys::ifstream licenseSource(licenseSourceFilename.c_str());
 
     std::string line;
-    while(std::getline(licenseSource, line))
-      {
+    while (std::getline(licenseSource, line)) {
       rtfWriter.AddText(line);
       rtfWriter.AddText("\n");
-      }
     }
-  else
-    {
+  } else {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "unsupported WiX License file extension '" <<
-      extension << "'" << std::endl);
+                  "unsupported WiX License file extension '"
+                    << extension << "'" << std::endl);
 
     return false;
-    }
+  }
 
   return true;
 }
 
 void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
-  std::string const& topdir,
-  std::string const& directoryId,
+  std::string const& topdir, std::string const& directoryId,
   cmWIXDirectoriesSourceWriter& directoryDefinitions,
   cmWIXFilesSourceWriter& fileDefinitions,
   cmWIXFeaturesSourceWriter& featureDefinitions,
@@ -917,61 +829,51 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
   std::string relativeDirectoryPath =
     cmSystemTools::RelativePath(toplevel.c_str(), topdir.c_str());
 
-  if(relativeDirectoryPath.empty())
-    {
+  if (relativeDirectoryPath.empty()) {
     relativeDirectoryPath = ".";
-    }
+  }
 
   cmInstalledFile const* directoryInstalledFile = this->GetInstalledFile(
-      this->RelativePathWithoutComponentPrefix(relativeDirectoryPath)
-  );
+    this->RelativePathWithoutComponentPrefix(relativeDirectoryPath));
 
   bool emptyDirectory = dir.GetNumberOfFiles() == 2;
   bool createDirectory = false;
 
-  if(emptyDirectory)
-    {
+  if (emptyDirectory) {
     createDirectory = true;
-    }
+  }
 
-  if(directoryInstalledFile)
-    {
-    if(directoryInstalledFile->HasProperty("CPACK_WIX_ACL"))
-      {
+  if (directoryInstalledFile) {
+    if (directoryInstalledFile->HasProperty("CPACK_WIX_ACL")) {
       createDirectory = true;
-      }
     }
+  }
 
-  if(createDirectory)
-    {
+  if (createDirectory) {
     std::string componentId = fileDefinitions.EmitComponentCreateFolder(
       directoryId, GenerateGUID(), directoryInstalledFile);
     featureDefinitions.EmitComponentRef(componentId);
-    }
+  }
 
-  if(emptyDirectory)
-    {
+  if (emptyDirectory) {
     return;
-    }
+  }
 
-  for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i)
-    {
+  for (size_t i = 0; i < dir.GetNumberOfFiles(); ++i) {
     std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
 
-    if(fileName == "." || fileName == "..")
-      {
+    if (fileName == "." || fileName == "..") {
       continue;
-      }
+    }
 
     std::string fullPath = topdir + "/" + fileName;
 
-    std::string relativePath = cmSystemTools::RelativePath(
-      toplevel.c_str(), fullPath.c_str());
+    std::string relativePath =
+      cmSystemTools::RelativePath(toplevel.c_str(), fullPath.c_str());
 
     std::string id = PathToId(relativePath);
 
-    if(cmSystemTools::FileIsDirectory(fullPath.c_str()))
-      {
+    if (cmSystemTools::FileIsDirectory(fullPath.c_str())) {
       std::string subDirectoryId = std::string("CM_D") + id;
 
       directoryDefinitions.BeginElement("Directory");
@@ -979,77 +881,60 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
       directoryDefinitions.AddAttribute("Name", fileName);
 
       AddDirectoryAndFileDefinitons(
-        fullPath, subDirectoryId,
-        directoryDefinitions,
-        fileDefinitions,
-        featureDefinitions,
-        packageExecutables,
-        desktopExecutables,
-        shortcuts);
+        fullPath, subDirectoryId, directoryDefinitions, fileDefinitions,
+        featureDefinitions, packageExecutables, desktopExecutables, shortcuts);
 
       this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions);
       directoryDefinitions.EndElement("Directory");
-      }
-    else
-      {
+    } else {
       cmInstalledFile const* installedFile = this->GetInstalledFile(
-        this->RelativePathWithoutComponentPrefix(relativePath)
-      );
+        this->RelativePathWithoutComponentPrefix(relativePath));
 
-      if(installedFile)
-        {
+      if (installedFile) {
         shortcuts.CreateFromProperties(id, directoryId, *installedFile);
-        }
+      }
 
       std::string componentId = fileDefinitions.EmitComponentFile(
         directoryId, id, fullPath, *(this->Patch), installedFile);
 
       featureDefinitions.EmitComponentRef(componentId);
 
-      for(size_t j = 0; j < packageExecutables.size(); ++j)
-        {
+      for (size_t j = 0; j < packageExecutables.size(); ++j) {
         std::string const& executableName = packageExecutables[j++];
         std::string const& textLabel = packageExecutables[j];
 
-        if(cmSystemTools::LowerCase(fileName) ==
-            cmSystemTools::LowerCase(executableName) + ".exe")
-          {
+        if (cmSystemTools::LowerCase(fileName) ==
+            cmSystemTools::LowerCase(executableName) + ".exe") {
           cmWIXShortcut shortcut;
-          shortcut.label= textLabel;
+          shortcut.label = textLabel;
           shortcut.workingDirectoryId = directoryId;
           shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut);
 
-          if(!desktopExecutables.empty() &&
-             std::find(desktopExecutables.begin(),
-                       desktopExecutables.end(),
-                       executableName)
-             != desktopExecutables.end())
-            {
-              shortcuts.insert(cmWIXShortcuts::DESKTOP, id, shortcut);
-            }
+          if (!desktopExecutables.empty() &&
+              std::find(desktopExecutables.begin(), desktopExecutables.end(),
+                        executableName) != desktopExecutables.end()) {
+            shortcuts.insert(cmWIXShortcuts::DESKTOP, id, shortcut);
           }
         }
       }
     }
+  }
 }
 
-bool cmCPackWIXGenerator::RequireOption(
-  std::string const& name, std::string &value) const
+bool cmCPackWIXGenerator::RequireOption(std::string const& name,
+                                        std::string& value) const
 {
   const char* tmp = GetOption(name.c_str());
-  if(tmp)
-    {
+  if (tmp) {
     value = tmp;
 
     return true;
-    }
-  else
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Required variable " << name << " not set" << std::endl);
+  } else {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Required variable "
+                    << name << " not set" << std::endl);
 
     return false;
-    }
+  }
 }
 
 std::string cmCPackWIXGenerator::GetArchitecture() const
@@ -1057,14 +942,11 @@ std::string cmCPackWIXGenerator::GetArchitecture() const
   std::string void_p_size;
   RequireOption("CPACK_WIX_SIZEOF_VOID_P", void_p_size);
 
-  if(void_p_size == "8")
-    {
+  if (void_p_size == "8") {
     return "x64";
-    }
-  else
-    {
+  } else {
     return "x86";
-    }
+  }
 }
 
 std::string cmCPackWIXGenerator::GenerateGUID()
@@ -1072,7 +954,7 @@ std::string cmCPackWIXGenerator::GenerateGUID()
   UUID guid;
   UuidCreate(&guid);
 
-  unsigned short *tmp = 0;
+  unsigned short* tmp = 0;
   UuidToStringW(&guid, &tmp);
 
   std::string result =
@@ -1093,10 +975,9 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
   std::string extension;
 
   std::string::size_type i = filename.rfind(".");
-  if(i != std::string::npos)
-    {
+  if (i != std::string::npos) {
     extension = filename.substr(i);
-    }
+  }
 
   return cmSystemTools::LowerCase(extension);
 }
@@ -1104,7 +985,8 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
 std::string cmCPackWIXGenerator::PathToId(std::string const& path)
 {
   id_map_t::const_iterator i = PathToIdMap.find(path);
-  if(i != PathToIdMap.end()) return i->second;
+  if (i != PathToIdMap.end())
+    return i->second;
 
   std::string id = CreateNewIdForPath(path);
   return id;
@@ -1120,41 +1002,37 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
   std::string identifier;
   std::string currentComponent;
 
-  for(size_t i = 1; i < components.size(); ++i)
-    {
-    if(i != 1) identifier += '.';
+  for (size_t i = 1; i < components.size(); ++i) {
+    if (i != 1)
+      identifier += '.';
 
-    currentComponent = NormalizeComponentForId(
-      components[i], replacementCount);
+    currentComponent =
+      NormalizeComponentForId(components[i], replacementCount);
 
     identifier += currentComponent;
-    }
+  }
 
   std::string idPrefix = "P";
   size_t replacementPercent = replacementCount * 100 / identifier.size();
-  if(replacementPercent > 33 || identifier.size() > 60)
-    {
+  if (replacementPercent > 33 || identifier.size() > 60) {
     identifier = CreateHashedId(path, currentComponent);
     idPrefix = "H";
-    }
+  }
 
   std::stringstream result;
   result << idPrefix << "_" << identifier;
 
   size_t ambiguityCount = ++IdAmbiguityCounter[identifier];
 
-  if(ambiguityCount > 999)
-    {
+  if (ambiguityCount > 999) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Error while trying to generate a unique Id for '" <<
-      path << "'" << std::endl);
+                  "Error while trying to generate a unique Id for '"
+                    << path << "'" << std::endl);
 
     return std::string();
-    }
-  else if(ambiguityCount > 1)
-    {
+  } else if (ambiguityCount > 1) {
     result << "_" << ambiguityCount;
-    }
+  }
 
   std::string resultString = result.str();
 
@@ -1173,15 +1051,12 @@ std::string cmCPackWIXGenerator::CreateHashedId(
   identifier += hash.substr(0, 7) + "_";
 
   const size_t maxFileNameLength = 52;
-  if(normalizedFilename.length() > maxFileNameLength)
-    {
+  if (normalizedFilename.length() > maxFileNameLength) {
     identifier += normalizedFilename.substr(0, maxFileNameLength - 3);
     identifier += "...";
-    }
-  else
-    {
+  } else {
     identifier += normalizedFilename;
-    }
+  }
 
   return identifier;
 }
@@ -1192,65 +1067,59 @@ std::string cmCPackWIXGenerator::NormalizeComponentForId(
   std::string result;
   result.resize(component.size());
 
-  for(size_t i = 0; i < component.size(); ++i)
-    {
+  for (size_t i = 0; i < component.size(); ++i) {
     char c = component[i];
-    if(IsLegalIdCharacter(c))
-      {
+    if (IsLegalIdCharacter(c)) {
       result[i] = c;
-      }
-    else
-      {
+    } else {
       result[i] = '_';
-      ++ replacementCount;
-      }
+      ++replacementCount;
     }
+  }
 
   return result;
 }
 
 bool cmCPackWIXGenerator::IsLegalIdCharacter(char c)
 {
-  return (c >= '0' && c <= '9') ||
-      (c >= 'a' && c <= 'z') ||
-      (c >= 'A' && c <= 'Z') ||
-      c == '_' || c == '.';
+  return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
+    (c >= 'A' && c <= 'Z') || c == '_' || c == '.';
 }
 
-void cmCPackWIXGenerator::CollectExtensions(
-     std::string const& variableName, extension_set_t& extensions)
+void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName,
+                                            extension_set_t& extensions)
 {
-  const char *variableContent = GetOption(variableName.c_str());
-  if(!variableContent) return;
+  const char* variableContent = GetOption(variableName.c_str());
+  if (!variableContent)
+    return;
 
   std::vector<std::string> list;
   cmSystemTools::ExpandListArgument(variableContent, list);
   extensions.insert(list.begin(), list.end());
 }
 
-void cmCPackWIXGenerator::AddCustomFlags(
-  std::string const& variableName, std::ostream& stream)
+void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
+                                         std::ostream& stream)
 {
-  const char *variableContent = GetOption(variableName.c_str());
-  if(!variableContent) return;
+  const char* variableContent = GetOption(variableName.c_str());
+  if (!variableContent)
+    return;
 
   std::vector<std::string> list;
   cmSystemTools::ExpandListArgument(variableContent, list);
 
-  for(std::vector<std::string>::const_iterator i = list.begin();
-    i != list.end(); ++i)
-    {
-      stream << " " << QuotePath(*i);
-    }
+  for (std::vector<std::string>::const_iterator i = list.begin();
+       i != list.end(); ++i) {
+    stream << " " << QuotePath(*i);
+  }
 }
 
 std::string cmCPackWIXGenerator::RelativePathWithoutComponentPrefix(
   std::string const& path)
 {
-  if(this->Components.empty())
-    {
+  if (this->Components.empty()) {
     return path;
-    }
+  }
 
   std::string::size_type pos = path.find('/');
 
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 3f66b2c..9d3a522 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -13,13 +13,13 @@
 #ifndef cmCPackWIXGenerator_h
 #define cmCPackWIXGenerator_h
 
+#include <CPack/cmCPackGenerator.h>
+
 #include "cmWIXPatch.h"
 #include "cmWIXShortcut.h"
 
-#include <CPack/cmCPackGenerator.h>
-
-#include <string>
 #include <map>
+#include <string>
 
 class cmWIXSourceWriter;
 class cmWIXDirectoriesSourceWriter;
@@ -42,25 +42,16 @@ protected:
 
   virtual int PackageFiles();
 
-  virtual const char* GetOutputExtension()
-    {
-    return ".msi";
-    }
+  virtual const char* GetOutputExtension() { return ".msi"; }
 
   virtual enum CPackSetDestdirSupport SupportsSetDestdir() const
-    {
+  {
     return SETDESTDIR_UNSUPPORTED;
-    }
+  }
 
-  virtual bool SupportsAbsoluteDestination() const
-    {
-    return false;
-    }
+  virtual bool SupportsAbsoluteDestination() const { return false; }
 
-  virtual bool SupportsComponentInstallation() const
-    {
-    return true;
-    }
+  virtual bool SupportsComponentInstallation() const { return true; }
 
 private:
   typedef std::map<std::string, std::string> id_map_t;
@@ -77,11 +68,10 @@ private:
 
   void CreateWiXProductFragmentIncludeFile();
 
-  void CopyDefinition(
-    cmWIXSourceWriter &source, std::string const& name);
+  void CopyDefinition(cmWIXSourceWriter& source, std::string const& name);
 
-  void AddDefinition(cmWIXSourceWriter& source,
-    std::string const& name, std::string const& value);
+  void AddDefinition(cmWIXSourceWriter& source, std::string const& name,
+                     std::string const& value);
 
   bool CreateWiXSourceFiles();
 
@@ -89,32 +79,25 @@ private:
 
   bool GenerateMainSourceFileFromTemplate();
 
-  bool CreateFeatureHierarchy(
-    cmWIXFeaturesSourceWriter& featureDefinitions);
+  bool CreateFeatureHierarchy(cmWIXFeaturesSourceWriter& featureDefinitions);
 
   bool AddComponentsToFeature(
-    std::string const& rootPath,
-    std::string const& featureId,
+    std::string const& rootPath, std::string const& featureId,
     cmWIXDirectoriesSourceWriter& directoryDefinitions,
     cmWIXFilesSourceWriter& fileDefinitions,
-    cmWIXFeaturesSourceWriter& featureDefinitions,
-    cmWIXShortcuts& shortcuts);
+    cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXShortcuts& shortcuts);
 
-  bool CreateShortcuts(
-    std::string const& cpackComponentName,
-    std::string const& featureId,
-    cmWIXShortcuts const& shortcuts,
-    bool emitUninstallShortcut,
-    cmWIXFilesSourceWriter& fileDefinitions,
-    cmWIXFeaturesSourceWriter& featureDefinitions);
+  bool CreateShortcuts(std::string const& cpackComponentName,
+                       std::string const& featureId,
+                       cmWIXShortcuts const& shortcuts,
+                       bool emitUninstallShortcut,
+                       cmWIXFilesSourceWriter& fileDefinitions,
+                       cmWIXFeaturesSourceWriter& featureDefinitions);
 
   bool CreateShortcutsOfSpecificType(
-    cmWIXShortcuts::Type type,
-    std::string const& cpackComponentName,
-    std::string const& featureId,
-    std::string const& idPrefix,
-    cmWIXShortcuts const& shortcuts,
-    bool emitUninstallShortcut,
+    cmWIXShortcuts::Type type, std::string const& cpackComponentName,
+    std::string const& featureId, std::string const& idPrefix,
+    cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
     cmWIXFilesSourceWriter& fileDefinitions,
     cmWIXFeaturesSourceWriter& featureDefinitions);
 
@@ -126,13 +109,13 @@ private:
 
   bool RunWiXCommand(std::string const& command);
 
-  bool RunCandleCommand(
-    std::string const& sourceFile, std::string const& objectFile);
+  bool RunCandleCommand(std::string const& sourceFile,
+                        std::string const& objectFile);
 
   bool RunLightCommand(std::string const& objectFiles);
 
-  void AddDirectoryAndFileDefinitons(std::string const& topdir,
-    std::string const& directoryId,
+  void AddDirectoryAndFileDefinitons(
+    std::string const& topdir, std::string const& directoryId,
     cmWIXDirectoriesSourceWriter& directoryDefinitions,
     cmWIXFilesSourceWriter& fileDefinitions,
     cmWIXFeaturesSourceWriter& featureDefinitions,
@@ -154,22 +137,20 @@ private:
 
   std::string CreateNewIdForPath(std::string const& path);
 
-  static std::string CreateHashedId(
-    std::string const& path, std::string const& normalizedFilename);
+  static std::string CreateHashedId(std::string const& path,
+                                    std::string const& normalizedFilename);
 
-  std::string NormalizeComponentForId(
-    std::string const& component, size_t& replacementCount);
+  std::string NormalizeComponentForId(std::string const& component,
+                                      size_t& replacementCount);
 
   static bool IsLegalIdCharacter(char c);
 
-  void CollectExtensions(
-       std::string const& variableName, extension_set_t& extensions);
+  void CollectExtensions(std::string const& variableName,
+                         extension_set_t& extensions);
 
-  void AddCustomFlags(
-    std::string const& variableName, std::ostream& stream);
+  void AddCustomFlags(std::string const& variableName, std::ostream& stream);
 
-  std::string RelativePathWithoutComponentPrefix(
-    std::string const& path);
+  std::string RelativePathWithoutComponentPrefix(std::string const& path);
 
   std::vector<std::string> WixSources;
   id_map_t PathToIdMap;
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx
index fc0d3d3..043cdff 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.cxx
+++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx
@@ -17,14 +17,12 @@
 #include <cmSystemTools.h>
 
 cmWIXAccessControlList::cmWIXAccessControlList(
-      cmCPackLog *logger,
-      cmInstalledFile const& installedFile,
-      cmWIXSourceWriter &sourceWriter):
-        Logger(logger),
-        InstalledFile(installedFile),
-        SourceWriter(sourceWriter)
+  cmCPackLog* logger, cmInstalledFile const& installedFile,
+  cmWIXSourceWriter& sourceWriter)
+  : Logger(logger)
+  , InstalledFile(installedFile)
+  , SourceWriter(sourceWriter)
 {
-
 }
 
 bool cmWIXAccessControlList::Apply()
@@ -32,23 +30,20 @@ bool cmWIXAccessControlList::Apply()
   std::vector<std::string> entries;
   this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries);
 
-  for(size_t i = 0; i < entries.size(); ++i)
-    {
+  for (size_t i = 0; i < entries.size(); ++i) {
     this->CreatePermissionElement(entries[i]);
-    }
+  }
 
   return true;
 }
 
-void cmWIXAccessControlList::CreatePermissionElement(
-  std::string const& entry)
+void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
 {
   std::string::size_type pos = entry.find('=');
-  if(pos == std::string::npos)
-    {
+  if (pos == std::string::npos) {
     this->ReportError(entry, "Did not find mandatory '='");
     return;
-    }
+  }
 
   std::string user_and_domain = entry.substr(0, pos);
   std::string permission_string = entry.substr(pos + 1);
@@ -56,46 +51,39 @@ void cmWIXAccessControlList::CreatePermissionElement(
   pos = user_and_domain.find('@');
   std::string user;
   std::string domain;
-  if(pos != std::string::npos)
-    {
+  if (pos != std::string::npos) {
     user = user_and_domain.substr(0, pos);
     domain = user_and_domain.substr(pos + 1);
-    }
-  else
-    {
+  } else {
     user = user_and_domain;
-    }
+  }
 
   std::vector<std::string> permissions =
     cmSystemTools::tokenize(permission_string, ",");
 
   this->SourceWriter.BeginElement("Permission");
   this->SourceWriter.AddAttribute("User", user);
-  if(!domain.empty())
-    {
+  if (!domain.empty()) {
     this->SourceWriter.AddAttribute("Domain", domain);
-    }
-  for(size_t i = 0; i < permissions.size(); ++i)
-    {
+  }
+  for (size_t i = 0; i < permissions.size(); ++i) {
     this->EmitBooleanAttribute(entry,
-      cmSystemTools::TrimWhitespace(permissions[i]));
-    }
+                               cmSystemTools::TrimWhitespace(permissions[i]));
+  }
   this->SourceWriter.EndElement("Permission");
 }
 
-void cmWIXAccessControlList::ReportError(
-  std::string const& entry,
-  std::string const& message)
+void cmWIXAccessControlList::ReportError(std::string const& entry,
+                                         std::string const& message)
 {
-  cmCPackLogger(cmCPackLog::LOG_ERROR,
-    "Failed processing ACL entry '" << entry <<
-    "': " << message << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed processing ACL entry '"
+                  << entry << "': " << message << std::endl);
 }
 
 bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
 {
-  static const char* validAttributes[] =
-  {
+  static const char* validAttributes[] = {
+    /* clang-format needs this comment to break after the opening brace */
     "Append",
     "ChangePermission",
     "CreateChild",
@@ -127,23 +115,22 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
   };
 
   size_t i = 0;
-  while(validAttributes[i])
-    {
-    if(name == validAttributes[i++]) return true;
-    }
+  while (validAttributes[i]) {
+    if (name == validAttributes[i++])
+      return true;
+  }
 
   return false;
 }
 
-void cmWIXAccessControlList::EmitBooleanAttribute(
-  std::string const& entry, std::string const& name)
+void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry,
+                                                  std::string const& name)
 {
-  if(!this->IsBooleanAttribute(name))
-    {
+  if (!this->IsBooleanAttribute(name)) {
     std::stringstream message;
     message << "Unknown boolean attribute '" << name << "'";
     this->ReportError(entry, message.str());
-    }
+  }
 
   this->SourceWriter.AddAttribute(name, "yes");
 }
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.h b/Source/CPack/WiX/cmWIXAccessControlList.h
index 20902f7..a1ac593 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.h
+++ b/Source/CPack/WiX/cmWIXAccessControlList.h
@@ -13,18 +13,17 @@
 #ifndef cmWIXAccessControlList_h
 #define cmWIXAccessControlList_h
 
-#include <cmInstalledFile.h>
-#include <CPack/cmCPackLog.h>
-
 #include "cmWIXSourceWriter.h"
 
+#include <CPack/cmCPackLog.h>
+#include <cmInstalledFile.h>
+
 class cmWIXAccessControlList
 {
 public:
-  cmWIXAccessControlList(
-        cmCPackLog *logger,
-        cmInstalledFile const& installedFile,
-        cmWIXSourceWriter &sourceWriter);
+  cmWIXAccessControlList(cmCPackLog* logger,
+                         cmInstalledFile const& installedFile,
+                         cmWIXSourceWriter& sourceWriter);
 
   bool Apply();
 
@@ -35,12 +34,11 @@ private:
 
   bool IsBooleanAttribute(std::string const& name);
 
-  void EmitBooleanAttribute(
-    std::string const& entry, std::string const& name);
+  void EmitBooleanAttribute(std::string const& entry, std::string const& name);
 
   cmCPackLog* Logger;
   cmInstalledFile const& InstalledFile;
-  cmWIXSourceWriter &SourceWriter;
+  cmWIXSourceWriter& SourceWriter;
 };
 
 #endif
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 7bd4315..60ecae6 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -12,11 +12,10 @@
 
 #include "cmWIXDirectoriesSourceWriter.h"
 
-cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
-  std::string const& filename):
-    cmWIXSourceWriter(logger, filename)
+cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
+  cmCPackLog* logger, std::string const& filename)
+  : cmWIXSourceWriter(logger, filename)
 {
-
 }
 
 void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
@@ -60,25 +59,20 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
 
   cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
 
-  if(!installRoot.empty() && installRoot.back().empty())
-    {
+  if (!installRoot.empty() && installRoot.back().empty()) {
     installRoot.pop_back();
-    }
+  }
 
-  for(size_t i = 1; i < installRoot.size(); ++i)
-    {
+  for (size_t i = 1; i < installRoot.size(); ++i) {
     BeginElement("Directory");
 
-    if(i == installRoot.size() - 1)
-      {
+    if (i == installRoot.size() - 1) {
       AddAttribute("Id", "INSTALL_ROOT");
-      }
-    else
-      {
+    } else {
       std::stringstream tmp;
       tmp << "INSTALL_PREFIX_" << i;
       AddAttribute("Id", tmp.str());
-      }
+    }
 
     AddAttribute("Name", installRoot[i]);
   }
@@ -88,8 +82,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
 
 void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
 {
-  for(size_t i = 0; i < size; ++i)
-    {
+  for (size_t i = 0; i < size; ++i) {
     EndElement("Directory");
-    }
+  }
 }
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
index f8c8166..023f4b8 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -26,7 +26,7 @@ class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
 {
 public:
   cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
-    std::string const& filename);
+                               std::string const& filename);
 
   void EmitStartMenuFolder(std::string const& startMenuFolder);
 
@@ -35,8 +35,8 @@ public:
   void EmitStartupFolder();
 
   size_t BeginInstallationPrefixDirectory(
-      std::string const& programFilesFolderId,
-      std::string const& installRootString);
+    std::string const& programFilesFolderId,
+    std::string const& installRootString);
 
   void EndInstallationPrefixDirectory(size_t size);
 };
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index 0bcfc38..16dd0ab 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -12,16 +12,14 @@
 
 #include "cmWIXFeaturesSourceWriter.h"
 
-cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger,
-  std::string const& filename):
-    cmWIXSourceWriter(logger, filename)
+cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
+  cmCPackLog* logger, std::string const& filename)
+  : cmWIXSourceWriter(logger, filename)
 {
-
 }
 
 void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
-    std::string const& package,
-    std::string const& upgradeGuid)
+  std::string const& package, std::string const& upgradeGuid)
 {
   BeginElement("Component");
   AddAttribute("Id", "CM_PACKAGE_REGISTRY");
@@ -29,7 +27,7 @@ void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
   AddAttribute("Guid", "*");
 
   std::string registryKey =
-      std::string("Software\\Kitware\\CMake\\Packages\\") + package;
+    std::string("Software\\Kitware\\CMake\\Packages\\") + package;
 
   BeginElement("RegistryValue");
   AddAttribute("Root", "HKLM");
@@ -49,25 +47,24 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
   BeginElement("Feature");
   AddAttribute("Id", "CM_G_" + group.Name);
 
-  if(group.IsExpandedByDefault)
-    {
+  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)
-    {
+  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)
-    {
+  for (std::vector<cmCPackComponent*>::const_iterator i =
+         group.Components.begin();
+       i != group.Components.end(); ++i) {
     EmitFeatureForComponent(**i);
-    }
+  }
 
   EndElement("Feature");
 }
@@ -81,15 +78,13 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
   AddAttributeUnlessEmpty("Title", component.DisplayName);
   AddAttributeUnlessEmpty("Description", component.Description);
 
-  if(component.IsRequired)
-    {
+  if (component.IsRequired) {
     AddAttribute("Absent", "disallow");
-    }
+  }
 
-  if(component.IsHidden)
-    {
+  if (component.IsHidden) {
     AddAttribute("Display", "hidden");
-    }
+  }
 
   EndElement("Feature");
 }
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
index 7670417..ee9c17a 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -14,6 +14,7 @@
 #define cmWIXFeaturesSourceWriter_h
 
 #include "cmWIXSourceWriter.h"
+
 #include <CPack/cmCPackGenerator.h>
 
 /** \class cmWIXFeaturesSourceWriter
@@ -22,12 +23,10 @@
 class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
 {
 public:
-  cmWIXFeaturesSourceWriter(cmCPackLog* logger,
-    std::string const& filename);
+  cmWIXFeaturesSourceWriter(cmCPackLog* logger, std::string const& filename);
 
-  void CreateCMakePackageRegistryEntry(
-    std::string const& package,
-    std::string const& upgradeGuid);
+  void CreateCMakePackageRegistryEntry(std::string const& package,
+                                       std::string const& upgradeGuid);
 
   void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
 
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
index d4698a7..1341fa5 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -11,33 +11,32 @@
 ============================================================================*/
 
 #include "cmWIXFilesSourceWriter.h"
+
 #include "cmWIXAccessControlList.h"
 
 #include <cmInstalledFile.h>
 
 #include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h>
 
 cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
-  std::string const& filename):
-    cmWIXSourceWriter(logger, filename)
+                                               std::string const& filename)
+  : cmWIXSourceWriter(logger, filename)
 {
-
 }
 
-void cmWIXFilesSourceWriter::EmitShortcut(
-  std::string const& id,
-  cmWIXShortcut const& shortcut,
-  std::string const& shortcutPrefix,
-  size_t shortcutIndex)
+void cmWIXFilesSourceWriter::EmitShortcut(std::string const& id,
+                                          cmWIXShortcut const& shortcut,
+                                          std::string const& shortcutPrefix,
+                                          size_t shortcutIndex)
 {
   std::stringstream shortcutId;
   shortcutId << shortcutPrefix << id;
 
-  if(shortcutIndex > 0)
-    {
-    shortcutId << "_"  << shortcutIndex;
-    }
+  if (shortcutIndex > 0) {
+    shortcutId << "_" << shortcutIndex;
+  }
 
   std::string fileId = std::string("CM_F") + id;
 
@@ -59,15 +58,13 @@ void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
 }
 
 void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
-  std::string const& registryKey,
-  std::string const& cpackComponentName,
+  std::string const& registryKey, std::string const& cpackComponentName,
   std::string const& suffix)
 {
   std::string valueName;
-  if(!cpackComponentName.empty())
-    {
-      valueName = cpackComponentName + "_";
-    }
+  if (!cpackComponentName.empty()) {
+    valueName = cpackComponentName + "_";
+  }
 
   valueName += "installed";
   valueName += suffix;
@@ -95,12 +92,10 @@ void cmWIXFilesSourceWriter::EmitUninstallShortcut(
 }
 
 std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
-  std::string const& directoryId,
-  std::string const& guid,
+  std::string const& directoryId, std::string const& guid,
   cmInstalledFile const* installedFile)
 {
-  std::string componentId =
-    std::string("CM_C_EMPTY_") + directoryId;
+  std::string componentId = std::string("CM_C_EMPTY_") + directoryId;
 
   BeginElement("DirectoryRef");
   AddAttribute("Id", directoryId);
@@ -111,11 +106,10 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
 
   BeginElement("CreateFolder");
 
-  if(installedFile)
-    {
+  if (installedFile) {
     cmWIXAccessControlList acl(Logger, *installedFile, *this);
     acl.Apply();
-    }
+  }
 
   EndElement("CreateFolder");
   EndElement("Component");
@@ -125,10 +119,8 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
 }
 
 std::string cmWIXFilesSourceWriter::EmitComponentFile(
-  std::string const& directoryId,
-  std::string const& id,
-  std::string const& filePath,
-  cmWIXPatch &patch,
+  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;
@@ -141,17 +133,14 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
   AddAttribute("Id", componentId);
   AddAttribute("Guid", "*");
 
-  if(installedFile)
-    {
-    if(installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE"))
-      {
+  if (installedFile) {
+    if (installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE")) {
       AddAttribute("NeverOverwrite", "yes");
-      }
-    if(installedFile->GetPropertyAsBool("CPACK_PERMANENT"))
-      {
+    }
+    if (installedFile->GetPropertyAsBool("CPACK_PERMANENT")) {
       AddAttribute("Permanent", "yes");
-      }
     }
+  }
 
   BeginElement("File");
   AddAttribute("Id", fileId);
@@ -161,16 +150,14 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
   mode_t fileMode = 0;
   cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
 
-  if(!(fileMode & S_IWRITE))
-    {
+  if (!(fileMode & S_IWRITE)) {
     AddAttribute("ReadOnly", "yes");
-    }
+  }
 
-  if(installedFile)
-    {
+  if (installedFile) {
     cmWIXAccessControlList acl(Logger, *installedFile, *this);
     acl.Apply();
-    }
+  }
 
   patch.ApplyFragment(fileId, *this);
   EndElement("File");
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
index c48bc15..c577e5b 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -14,8 +14,9 @@
 #define cmWIXFilesSourceWriter_h
 
 #include "cmWIXSourceWriter.h"
-#include "cmWIXShortcut.h"
+
 #include "cmWIXPatch.h"
+#include "cmWIXShortcut.h"
 
 #include <CPack/cmCPackGenerator.h>
 
@@ -25,36 +26,27 @@
 class cmWIXFilesSourceWriter : public cmWIXSourceWriter
 {
 public:
-  cmWIXFilesSourceWriter(cmCPackLog* logger,
-    std::string const& filename);
+  cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename);
 
-  void EmitShortcut(
-      std::string const& id,
-      cmWIXShortcut const& shortcut,
-      std::string const& shortcutPrefix,
-      size_t shortcutIndex);
+  void EmitShortcut(std::string const& id, cmWIXShortcut const& shortcut,
+                    std::string const& shortcutPrefix, size_t shortcutIndex);
 
   void EmitRemoveFolder(std::string const& id);
 
-  void EmitInstallRegistryValue(
-    std::string const& registryKey,
-    std::string const& cpackComponentName,
-    std::string const& suffix);
+  void EmitInstallRegistryValue(std::string const& registryKey,
+                                std::string const& cpackComponentName,
+                                std::string const& suffix);
 
   void EmitUninstallShortcut(std::string const& packageName);
 
-  std::string EmitComponentCreateFolder(
-    std::string const& directoryId,
-    std::string const& guid,
-    cmInstalledFile const* installedFile);
-
-  std::string EmitComponentFile(
-    std::string const& directoryId,
-    std::string const& id,
-    std::string const& filePath,
-    cmWIXPatch &patch,
-    cmInstalledFile const* installedFile);
-};
+  std::string EmitComponentCreateFolder(std::string const& directoryId,
+                                        std::string const& guid,
+                                        cmInstalledFile const* installedFile);
 
+  std::string EmitComponentFile(std::string const& directoryId,
+                                std::string const& id,
+                                std::string const& filePath, cmWIXPatch& patch,
+                                cmInstalledFile const* installedFile);
+};
 
 #endif
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
index 07375da..c9d010e 100644
--- a/Source/CPack/WiX/cmWIXPatch.cxx
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -14,31 +14,29 @@
 
 #include <CPack/cmCPackGenerator.h>
 
-cmWIXPatch::cmWIXPatch(cmCPackLog* logger):
-  Logger(logger)
+cmWIXPatch::cmWIXPatch(cmCPackLog* logger)
+  : Logger(logger)
 {
-
 }
 
 bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
 {
   cmWIXPatchParser parser(Fragments, Logger);
-  if(!parser.ParseFile(patchFilePath.c_str()))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Failed parsing XML patch file: '" <<
-      patchFilePath << "'" << std::endl);
+  if (!parser.ParseFile(patchFilePath.c_str())) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed parsing XML patch file: '"
+                    << patchFilePath << "'" << std::endl);
     return false;
-    }
+  }
 
   return true;
 }
 
-void cmWIXPatch::ApplyFragment(
-  std::string const& id, cmWIXSourceWriter& writer)
+void cmWIXPatch::ApplyFragment(std::string const& id,
+                               cmWIXSourceWriter& writer)
 {
   cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
-  if(i == Fragments.end()) return;
+  if (i == Fragments.end())
+    return;
 
   const cmWIXPatchElement& fragment = i->second;
 
@@ -47,36 +45,35 @@ void cmWIXPatch::ApplyFragment(
   Fragments.erase(i);
 }
 
-void cmWIXPatch::ApplyElementChildren(
-  const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+void cmWIXPatch::ApplyElementChildren(const cmWIXPatchElement& element,
+                                      cmWIXSourceWriter& writer)
 {
-  for(cmWIXPatchElement::child_list_t::const_iterator
-    j = element.children.begin(); j != element.children.end(); ++j)
-  {
-  cmWIXPatchNode *node = *j;
-
-  switch(node->type())
-    {
-    case cmWIXPatchNode::ELEMENT:
-      ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
-      break;
-    case cmWIXPatchNode::TEXT:
-      writer.AddTextNode(dynamic_cast<const cmWIXPatchText&>(*node).text);
-      break;
+  for (cmWIXPatchElement::child_list_t::const_iterator j =
+         element.children.begin();
+       j != element.children.end(); ++j) {
+    cmWIXPatchNode* node = *j;
+
+    switch (node->type()) {
+      case cmWIXPatchNode::ELEMENT:
+        ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
+        break;
+      case cmWIXPatchNode::TEXT:
+        writer.AddTextNode(dynamic_cast<const cmWIXPatchText&>(*node).text);
+        break;
     }
   }
 }
 
-void cmWIXPatch::ApplyElement(
-  const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+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)
-    {
+  for (cmWIXPatchElement::attributes_t::const_iterator i =
+         element.attributes.begin();
+       i != element.attributes.end(); ++i) {
     writer.AddAttribute(i->first, i->second);
-    }
+  }
 
   this->ApplyElementChildren(element, writer);
 
@@ -86,26 +83,23 @@ void cmWIXPatch::ApplyElement(
 bool cmWIXPatch::CheckForUnappliedFragments()
 {
   std::string fragmentList;
-  for(cmWIXPatchParser::fragment_map_t::const_iterator
-    i = Fragments.begin(); i != Fragments.end(); ++i)
-    {
-    if(!fragmentList.empty())
-      {
+  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.empty())
-    {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Some XML patch fragments did not have matching IDs: " <<
-        fragmentList << std::endl);
-      return false;
-    }
+  if (!fragmentList.empty()) {
+    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
index 2f31a01..57b74cd 100644
--- a/Source/CPack/WiX/cmWIXPatch.h
+++ b/Source/CPack/WiX/cmWIXPatch.h
@@ -13,8 +13,8 @@
 #ifndef cmWIXPatch_h
 #define cmWIXPatch_h
 
-#include "cmWIXSourceWriter.h"
 #include "cmWIXPatchParser.h"
+#include "cmWIXSourceWriter.h"
 
 #include <string>
 
@@ -34,15 +34,14 @@ public:
 
 private:
   void ApplyElementChildren(const cmWIXPatchElement& element,
-    cmWIXSourceWriter& writer);
+                            cmWIXSourceWriter& writer);
 
   void ApplyElement(const cmWIXPatchElement& element,
-    cmWIXSourceWriter& writer);
+                    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 14c5413..b750dcf 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -28,149 +28,124 @@ cmWIXPatchNode::Type cmWIXPatchElement::type()
 
 cmWIXPatchNode::~cmWIXPatchNode()
 {
-
 }
 
 cmWIXPatchElement::~cmWIXPatchElement()
 {
-  for(child_list_t::iterator i = children.begin(); i != children.end(); ++i)
-    {
+  for (child_list_t::iterator i = children.begin(); i != children.end(); ++i) {
     delete *i;
-    }
+  }
 }
 
-cmWIXPatchParser::cmWIXPatchParser(
-  fragment_map_t& fragments, cmCPackLog* logger):
-    Logger(logger),
-    State(BEGIN_DOCUMENT),
-    Valid(true),
-    Fragments(fragments)
+cmWIXPatchParser::cmWIXPatchParser(fragment_map_t& fragments,
+                                   cmCPackLog* logger)
+  : Logger(logger)
+  , State(BEGIN_DOCUMENT)
+  , Valid(true)
+  , Fragments(fragments)
 {
-
 }
 
-void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
+void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
 {
-  if(State == BEGIN_DOCUMENT)
-    {
-    if(name == "CPackWiXPatch")
-      {
+  if (State == BEGIN_DOCUMENT) {
+    if (name == "CPackWiXPatch") {
       State = BEGIN_FRAGMENTS;
-      }
-    else
-      {
+    } else {
       ReportValidationError("Expected root element 'CPackWiXPatch'");
-      }
     }
-  else if(State == BEGIN_FRAGMENTS)
-    {
-      if(name == "CPackWiXFragment")
-        {
-        State = INSIDE_FRAGMENT;
-        StartFragment(atts);
-        }
-      else
-        {
-        ReportValidationError("Expected 'CPackWixFragment' element");
-        }
+  } else if (State == BEGIN_FRAGMENTS) {
+    if (name == "CPackWiXFragment") {
+      State = INSIDE_FRAGMENT;
+      StartFragment(atts);
+    } else {
+      ReportValidationError("Expected 'CPackWixFragment' element");
     }
-  else if(State == INSIDE_FRAGMENT)
-    {
-      cmWIXPatchElement &parent = *ElementStack.back();
-
-      cmWIXPatchElement *element = new cmWIXPatchElement;
-      parent.children.push_back(element);
+  } else if (State == INSIDE_FRAGMENT) {
+    cmWIXPatchElement& parent = *ElementStack.back();
 
-      element->name = name;
+    cmWIXPatchElement* element = new cmWIXPatchElement;
+    parent.children.push_back(element);
 
-      for(size_t i = 0; atts[i]; i += 2)
-        {
-        std::string key = atts[i];
-        std::string value = atts[i+1];
+    element->name = name;
 
-        element->attributes[key] = value;
-        }
+    for (size_t i = 0; atts[i]; i += 2) {
+      std::string key = atts[i];
+      std::string value = atts[i + 1];
 
-      ElementStack.push_back(element);
+      element->attributes[key] = value;
     }
+
+    ElementStack.push_back(element);
+  }
 }
 
-void cmWIXPatchParser::StartFragment(const char **attributes)
+void cmWIXPatchParser::StartFragment(const char** attributes)
 {
-  for(size_t i = 0; attributes[i]; i += 2)
-    {
+  for (size_t i = 0; attributes[i]; i += 2) {
     std::string key = attributes[i];
-    std::string value = attributes[i+1];
+    std::string value = attributes[i + 1];
 
-    if(key == "Id")
-      {
-      if(Fragments.find(value) != Fragments.end())
-        {
+    if (key == "Id") {
+      if (Fragments.find(value) != Fragments.end()) {
         std::stringstream tmp;
         tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
         ReportValidationError(tmp.str());
-        }
+      }
 
       ElementStack.push_back(&Fragments[value]);
-      }
-    else
-      {
+    } else {
       ReportValidationError(
         "The only allowed 'CPackWixFragment' attribute is 'Id'");
-      }
     }
+  }
 }
 
 void cmWIXPatchParser::EndElement(const std::string& name)
 {
-  if(State == INSIDE_FRAGMENT)
-    {
-      if(name == "CPackWiXFragment")
-        {
-        State = BEGIN_FRAGMENTS;
-        ElementStack.clear();
-        }
-      else
-        {
-        ElementStack.pop_back();
-        }
+  if (State == INSIDE_FRAGMENT) {
+    if (name == "CPackWiXFragment") {
+      State = BEGIN_FRAGMENTS;
+      ElementStack.clear();
+    } else {
+      ElementStack.pop_back();
     }
+  }
 }
 
 void cmWIXPatchParser::CharacterDataHandler(const char* data, int length)
 {
   const char* whitespace = "\x20\x09\x0d\x0a";
 
-  if(State == INSIDE_FRAGMENT)
-    {
-    cmWIXPatchElement &parent = *ElementStack.back();
+  if (State == INSIDE_FRAGMENT) {
+    cmWIXPatchElement& parent = *ElementStack.back();
 
     std::string text(data, length);
 
     std::string::size_type first = text.find_first_not_of(whitespace);
     std::string::size_type last = text.find_last_not_of(whitespace);
 
-    if(first != std::string::npos && last != std::string::npos)
-      {
-      cmWIXPatchText *text_node = new cmWIXPatchText;
+    if (first != std::string::npos && last != std::string::npos) {
+      cmWIXPatchText* text_node = new cmWIXPatchText;
       text_node->text = text.substr(first, last - first + 1);
 
       parent.children.push_back(text_node);
-      }
     }
+  }
 }
 
 void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
 {
   cmCPackLogger(cmCPackLog::LOG_ERROR,
-    "Error while processing XML patch file at " << line << ":" << column <<
-      ":  "<< msg << std::endl);
+                "Error while processing XML patch file at "
+                  << line << ":" << column << ":  " << msg << std::endl);
   Valid = false;
 }
 
 void cmWIXPatchParser::ReportValidationError(std::string const& message)
 {
-  ReportError(XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)),
+  ReportError(
+    XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)),
     XML_GetCurrentColumnNumber(static_cast<XML_Parser>(this->Parser)),
     message.c_str());
 }
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
index acaeae3..f9b85bd 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.h
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -13,12 +13,12 @@
 #ifndef cmCPackWIXPatchParser_h
 #define cmCPackWIXPatchParser_h
 
-#include <cmXMLParser.h>
-
 #include <CPack/cmCPackLog.h>
 
-#include <map>
+#include <cmXMLParser.h>
+
 #include <list>
+#include <map>
 
 struct cmWIXPatchNode
 {
@@ -65,9 +65,9 @@ public:
   cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
 
 private:
-  virtual void StartElement(const std::string& name, const char **atts);
+  virtual void StartElement(const std::string& name, const char** atts);
 
-  void StartFragment(const char **attributes);
+  void StartFragment(const char** attributes);
 
   virtual void EndElement(const std::string& name);
 
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index f27caa9..f3dbcb9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -15,8 +15,8 @@
 #include <cmVersion.h>
 
 cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
-  std::string const& filename):
-    File(filename.c_str(), std::ios::binary)
+  std::string const& filename)
+  : File(filename.c_str(), std::ios::binary)
 {
   StartGroup();
   WriteHeader();
@@ -37,74 +37,50 @@ void cmWIXRichTextFormatWriter::AddText(std::string const& text)
 {
   typedef unsigned char rtf_byte_t;
 
-  for(size_t i = 0; i < text.size(); ++i)
-    {
+  for (size_t i = 0; i < text.size(); ++i) {
     rtf_byte_t c = rtf_byte_t(text[i]);
 
-    switch(c)
-      {
-    case '\\':
-      File << "\\\\";
-      break;
-    case '{':
-      File << "\\{";
-      break;
-    case '}':
-      File << "\\}";
-      break;
-    case '\n':
-      File << "\\par\r\n";
-      break;
-    case '\r':
-      continue;
-    default:
-        {
-        if(c <= 0x7F)
-          {
+    switch (c) {
+      case '\\':
+        File << "\\\\";
+        break;
+      case '{':
+        File << "\\{";
+        break;
+      case '}':
+        File << "\\}";
+        break;
+      case '\n':
+        File << "\\par\r\n";
+        break;
+      case '\r':
+        continue;
+      default: {
+        if (c <= 0x7F) {
           File << c;
-          }
-        else
-          {
-            if(c <= 0xC0)
-              {
-              EmitInvalidCodepoint(c);
-              }
-            else if(c < 0xE0 && i+1 < text.size())
-              {
-              EmitUnicodeCodepoint(
-                (text[i+1] & 0x3F) |
-                ((c & 0x1F) << 6)
-              );
-              i+= 1;
-              }
-            else if(c < 0xF0 && i+2 < text.size())
-              {
-              EmitUnicodeCodepoint(
-                (text[i+2] & 0x3F) |
-                ((text[i+1] & 0x3F) << 6) |
-                ((c & 0xF) << 12)
-              );
-              i += 2;
-              }
-            else if(c < 0xF8 && i+3 < text.size())
-              {
-              EmitUnicodeCodepoint(
-                (text[i+3] & 0x3F) |
-                ((text[i+2] & 0x3F) << 6) |
-                ((text[i+1] & 0x3F) << 12) |
-                ((c & 0x7) << 18)
-              );
-              i += 3;
-              }
-            else
-              {
-              EmitInvalidCodepoint(c);
-              }
+        } else {
+          if (c <= 0xC0) {
+            EmitInvalidCodepoint(c);
+          } else if (c < 0xE0 && i + 1 < text.size()) {
+            EmitUnicodeCodepoint((text[i + 1] & 0x3F) | ((c & 0x1F) << 6));
+            i += 1;
+          } else if (c < 0xF0 && i + 2 < text.size()) {
+            EmitUnicodeCodepoint((text[i + 2] & 0x3F) |
+                                 ((text[i + 1] & 0x3F) << 6) |
+                                 ((c & 0xF) << 12));
+            i += 2;
+          } else if (c < 0xF8 && i + 3 < text.size()) {
+            EmitUnicodeCodepoint(
+              (text[i + 3] & 0x3F) | ((text[i + 2] & 0x3F) << 6) |
+              ((text[i + 1] & 0x3F) << 12) | ((c & 0x7) << 18));
+            i += 3;
+          } else {
+            EmitInvalidCodepoint(c);
           }
         }
-      break;
-      }
+      } break;
     }
+  }
 }
 
 void cmWIXRichTextFormatWriter::WriteHeader()
@@ -190,33 +166,25 @@ void cmWIXRichTextFormatWriter::EndGroup()
 void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
 {
   // Do not emit byte order mark (BOM)
-  if(c == 0xFEFF)
-    {
+  if (c == 0xFEFF) {
     return;
-    }
-  else if(c <= 0xFFFF)
-    {
+  } else if (c <= 0xFFFF) {
     EmitUnicodeSurrogate(c);
-    }
-  else
-    {
+  } else {
     c -= 0x10000;
     EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800);
     EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00);
-    }
+  }
 }
 
 void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
 {
   ControlWord("u");
-  if(c <= 32767)
-    {
+  if (c <= 32767) {
     File << c;
-    }
-  else
-    {
+  } else {
     File << (c - 65536);
-    }
+  }
   File << "?";
 }
 
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index f6327fb..acf1fa6 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -13,6 +13,8 @@
 #ifndef cmWIXRichTextFormatWriter_h
 #define cmWIXRichTextFormatWriter_h
 
+#include "cmStandardIncludes.h"
+
 #include <cmsys/FStream.hxx>
 
 /** \class cmWIXRichtTextFormatWriter
diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx
index d721872..2685a23 100644
--- a/Source/CPack/WiX/cmWIXShortcut.cxx
+++ b/Source/CPack/WiX/cmWIXShortcut.cxx
@@ -14,8 +14,8 @@
 
 #include "cmWIXFilesSourceWriter.h"
 
-void cmWIXShortcuts::insert(
-  Type type, std::string const& id, cmWIXShortcut const& shortcut)
+void cmWIXShortcuts::insert(Type type, std::string const& id,
+                            cmWIXShortcut const& shortcut)
 {
   this->Shortcuts[type][id].push_back(shortcut);
 }
@@ -26,25 +26,22 @@ bool cmWIXShortcuts::empty(Type type) const
 }
 
 bool cmWIXShortcuts::EmitShortcuts(
-  Type type,
-  std::string const& registryKey,
+  Type type, std::string const& registryKey,
   std::string const& cpackComponentName,
   cmWIXFilesSourceWriter& fileDefinitions) const
 {
   shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type);
 
-  if(i == this->Shortcuts.end())
-    {
+  if (i == this->Shortcuts.end()) {
     return false;
-    }
+  }
 
   shortcut_id_map_t const& id_map = i->second;
 
   std::string shortcutPrefix;
   std::string registrySuffix;
 
-  switch(type)
-    {
+  switch (type) {
     case START_MENU:
       shortcutPrefix = "CM_S";
       break;
@@ -58,68 +55,61 @@ bool cmWIXShortcuts::EmitShortcuts(
       break;
     default:
       return false;
-    }
+  }
 
-  for(shortcut_id_map_t::const_iterator j = id_map.begin();
-    j != id_map.end(); ++j)
-    {
+  for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end();
+       ++j) {
     std::string const& id = j->first;
     shortcut_list_t const& shortcutList = j->second;
 
-    for(size_t shortcutListIndex = 0;
-      shortcutListIndex < shortcutList.size(); ++shortcutListIndex)
-      {
+    for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size();
+         ++shortcutListIndex) {
       cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex];
-      fileDefinitions.EmitShortcut(id, shortcut,
-        shortcutPrefix, shortcutListIndex);
-      }
+      fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix,
+                                   shortcutListIndex);
     }
+  }
 
-  fileDefinitions.EmitInstallRegistryValue(
-    registryKey, cpackComponentName, registrySuffix);
+  fileDefinitions.EmitInstallRegistryValue(registryKey, cpackComponentName,
+                                           registrySuffix);
 
   return true;
 }
 
 void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
 {
-  for(shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
-    i != this->Shortcuts.end(); ++i)
-    {
+  for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
+       i != this->Shortcuts.end(); ++i) {
     types.insert(i->first);
-    }
+  }
 }
 
-void cmWIXShortcuts::CreateFromProperties(
-  std::string const& id,
-  std::string const& directoryId,
-  cmInstalledFile const& installedFile)
+void cmWIXShortcuts::CreateFromProperties(std::string const& id,
+                                          std::string const& directoryId,
+                                          cmInstalledFile const& installedFile)
 {
-  CreateFromProperty("CPACK_START_MENU_SHORTCUTS",
-    START_MENU, id, directoryId, installedFile);
+  CreateFromProperty("CPACK_START_MENU_SHORTCUTS", START_MENU, id, directoryId,
+                     installedFile);
 
-  CreateFromProperty("CPACK_DESKTOP_SHORTCUTS",
-    DESKTOP, id, directoryId, installedFile);
+  CreateFromProperty("CPACK_DESKTOP_SHORTCUTS", DESKTOP, id, directoryId,
+                     installedFile);
 
-  CreateFromProperty("CPACK_STARTUP_SHORTCUTS",
-    STARTUP, id, directoryId, installedFile);
+  CreateFromProperty("CPACK_STARTUP_SHORTCUTS", STARTUP, id, directoryId,
+                     installedFile);
 }
 
-void cmWIXShortcuts::CreateFromProperty(
-  std::string const& propertyName,
-  Type type,
-  std::string const& id,
-  std::string const& directoryId,
-  cmInstalledFile const& installedFile)
+void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName,
+                                        Type type, std::string const& id,
+                                        std::string const& directoryId,
+                                        cmInstalledFile const& installedFile)
 {
   std::vector<std::string> list;
   installedFile.GetPropertyAsList(propertyName, list);
 
-  for(size_t i = 0; i < list.size(); ++i)
-    {
+  for (size_t i = 0; i < list.size(); ++i) {
     cmWIXShortcut shortcut;
     shortcut.label = list[i];
     shortcut.workingDirectoryId = directoryId;
     insert(type, id, shortcut);
-    }
+  }
 }
diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h
index 5945e43..593ba34 100644
--- a/Source/CPack/WiX/cmWIXShortcut.h
+++ b/Source/CPack/WiX/cmWIXShortcut.h
@@ -13,13 +13,13 @@
 #ifndef cmWIXShortcut_h
 #define cmWIXShortcut_h
 
-#include <string>
+#include <cmInstalledFile.h>
+
 #include <map>
 #include <set>
+#include <string>
 #include <vector>
 
-#include <cmInstalledFile.h>
-
 class cmWIXFilesSourceWriter;
 
 struct cmWIXShortcut
@@ -45,26 +45,23 @@ public:
 
   bool empty(Type type) const;
 
-  bool EmitShortcuts(
-    Type type,
-    std::string const& registryKey,
-    std::string const& cpackComponentName,
-    cmWIXFilesSourceWriter& fileDefinitions) const;
+  bool EmitShortcuts(Type type, std::string const& registryKey,
+                     std::string const& cpackComponentName,
+                     cmWIXFilesSourceWriter& fileDefinitions) const;
 
   void AddShortcutTypes(std::set<Type>& types);
 
   void CreateFromProperties(std::string const& id,
-    std::string const& directoryId, cmInstalledFile const& installedFile);
+                            std::string const& directoryId,
+                            cmInstalledFile const& installedFile);
 
 private:
   typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t;
 
-  void CreateFromProperty(
-    std::string const& propertyName,
-    Type type,
-    std::string const& id,
-    std::string const& directoryId,
-    cmInstalledFile const& installedFile);
+  void CreateFromProperty(std::string const& propertyName, Type type,
+                          std::string const& id,
+                          std::string const& directoryId,
+                          cmInstalledFile const& installedFile);
 
   shortcut_type_map_t Shortcuts;
   shortcut_id_map_t EmptyIdMap;
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index 63acb27..2c0384e 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -10,8 +10,6 @@
   See the License for more information.
 ============================================================================*/
 
-#include "cmStandardIncludes.h"
-
 #include "cmWIXSourceWriter.h"
 
 #include <CPack/cmCPackGenerator.h>
@@ -19,46 +17,41 @@
 #include <windows.h>
 
 cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
-  std::string const& filename,
-  bool isIncludeFile):
-    Logger(logger),
-    File(filename.c_str()),
-    State(DEFAULT),
-    SourceFilename(filename)
+                                     std::string const& filename,
+                                     bool isIncludeFile)
+  : Logger(logger)
+  , File(filename.c_str())
+  , State(DEFAULT)
+  , SourceFilename(filename)
 {
   WriteXMLDeclaration();
 
-  if(isIncludeFile)
-    {
+  if (isIncludeFile) {
     BeginElement("Include");
-    }
-  else
-    {
+  } else {
     BeginElement("Wix");
-    }
+  }
 
   AddAttribute("xmlns", "http://schemas.microsoft.com/wix/2006/wi");
 }
 
 cmWIXSourceWriter::~cmWIXSourceWriter()
 {
-  if(Elements.size() > 1)
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      Elements.size() - 1 << " WiX elements were still open when closing '" <<
-      SourceFilename << "'" << std::endl);
+  if (Elements.size() > 1) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, Elements.size() - 1
+                    << " WiX elements were still open when closing '"
+                    << SourceFilename << "'" << std::endl);
     return;
-    }
+  }
 
   EndElement(Elements.back());
 }
 
 void cmWIXSourceWriter::BeginElement(std::string const& name)
 {
-  if(State == BEGIN)
-    {
+  if (State == BEGIN) {
     File << ">";
-    }
+  }
 
   File << "\n";
   Indent(Elements.size());
@@ -70,33 +63,27 @@ void cmWIXSourceWriter::BeginElement(std::string const& name)
 
 void cmWIXSourceWriter::EndElement(std::string const& name)
 {
-  if(Elements.empty())
-    {
+  if (Elements.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "can not end WiX element with no open elements in '" <<
-      SourceFilename << "'" << std::endl);
+                  "can not end WiX element with no open elements in '"
+                    << SourceFilename << "'" << std::endl);
     return;
-    }
+  }
 
-  if(Elements.back() != name)
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "WiX element <" << Elements.back() <<
-      "> can not be closed by </" << name << "> in '" <<
-      SourceFilename << "'" << std::endl);
+  if (Elements.back() != name) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "WiX element <"
+                    << Elements.back() << "> can not be closed by </" << name
+                    << "> in '" << SourceFilename << "'" << std::endl);
     return;
-    }
+  }
 
-  if(State == DEFAULT)
-    {
+  if (State == DEFAULT) {
     File << "\n";
-    Indent(Elements.size()-1);
+    Indent(Elements.size() - 1);
     File << "</" << Elements.back() << ">";
-    }
-  else
-    {
+  } else {
     File << "/>";
-    }
+  }
 
   Elements.pop_back();
   State = DEFAULT;
@@ -104,30 +91,27 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
 
 void cmWIXSourceWriter::AddTextNode(std::string const& text)
 {
-  if(State == BEGIN)
-    {
+  if (State == BEGIN) {
     File << ">";
-    }
+  }
 
-  if(Elements.empty())
-    {
+  if (Elements.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "can not add text without open WiX element in '" <<
-      SourceFilename << "'" << std::endl);
+                  "can not add text without open WiX element in '"
+                    << SourceFilename << "'" << std::endl);
     return;
-    }
+  }
 
   File << this->EscapeAttributeValue(text);
   State = DEFAULT;
 }
 
-void cmWIXSourceWriter::AddProcessingInstruction(
-  std::string const& target, std::string const& content)
+void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
+                                                 std::string const& content)
 {
-  if(State == BEGIN)
-    {
+  if (State == BEGIN) {
     File << ">";
-    }
+  }
 
   File << "\n";
   Indent(Elements.size());
@@ -136,21 +120,20 @@ void cmWIXSourceWriter::AddProcessingInstruction(
   State = DEFAULT;
 }
 
-void cmWIXSourceWriter::AddAttribute(
-  std::string const& key, std::string const& value)
+void cmWIXSourceWriter::AddAttribute(std::string const& key,
+                                     std::string const& value)
 {
   std::string utf8 = CMakeEncodingToUtf8(value);
 
   File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
 }
 
-void cmWIXSourceWriter::AddAttributeUnlessEmpty(
-    std::string const& key, std::string const& value)
+void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,
+                                                std::string const& value)
 {
-  if(!value.empty())
-    {
+  if (!value.empty()) {
     AddAttribute(key, value);
-    }
+  }
 }
 
 std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
@@ -158,43 +141,38 @@ std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
 #ifdef CMAKE_ENCODING_UTF8
   return value;
 #else
-  if(value.empty())
-    {
+  if (value.empty()) {
     return std::string();
-    }
+  }
 
   int characterCount = MultiByteToWideChar(
     CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0);
 
-  if(characterCount == 0)
-    {
+  if (characterCount == 0) {
     return std::string();
-    }
+  }
 
   std::vector<wchar_t> utf16(characterCount);
 
-  MultiByteToWideChar(
-    CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
-    &utf16[0], static_cast<int>(utf16.size()));
+  MultiByteToWideChar(CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
+                      &utf16[0], static_cast<int>(utf16.size()));
 
   int utf8ByteCount = WideCharToMultiByte(
     CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0);
 
-  if(utf8ByteCount == 0)
-    {
+  if (utf8ByteCount == 0) {
     return std::string();
-    }
+  }
 
   std::vector<char> utf8(utf8ByteCount);
 
   WideCharToMultiByte(CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()),
-    &utf8[0], static_cast<int>(utf8.size()), 0, 0);
+                      &utf8[0], static_cast<int>(utf8.size()), 0, 0);
 
   return std::string(&utf8[0], utf8.size());
 #endif
 }
 
-
 void cmWIXSourceWriter::WriteXMLDeclaration()
 {
   File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
@@ -202,41 +180,37 @@ void cmWIXSourceWriter::WriteXMLDeclaration()
 
 void cmWIXSourceWriter::Indent(size_t count)
 {
-  for(size_t i = 0; i < count; ++i)
-    {
+  for (size_t i = 0; i < count; ++i) {
     File << "    ";
-    }
+  }
 }
 
-std::string cmWIXSourceWriter::EscapeAttributeValue(
-  std::string const& value)
+std::string cmWIXSourceWriter::EscapeAttributeValue(std::string const& value)
 {
   std::string result;
   result.reserve(value.size());
 
   char c = 0;
-  for(size_t i = 0 ; i < value.size(); ++i)
-    {
+  for (size_t i = 0; i < value.size(); ++i) {
     c = value[i];
-    switch(c)
-      {
-    case '<':
-      result += "<";
-      break;
-    case '>':
-      result += ">";
-      break;
-    case '&':
-      result +="&";
-      break;
-    case '"':
-      result += """;
-      break;
-    default:
-      result += c;
-      break;
-      }
-    }
+    switch (c) {
+      case '<':
+        result += "<";
+        break;
+      case '>':
+        result += ">";
+        break;
+      case '&':
+        result += "&";
+        break;
+      case '"':
+        result += """;
+        break;
+      default:
+        result += c;
+        break;
+    }
+  }
 
   return result;
 }
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 9e303f0..4efc026 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -13,11 +13,12 @@
 #ifndef cmWIXSourceWriter_h
 #define cmWIXSourceWriter_h
 
-#include <vector>
-#include <string>
+#include <CPack/cmCPackLog.h>
+
 #include <cmsys/FStream.hxx>
 
-#include <CPack/cmCPackLog.h>
+#include <string>
+#include <vector>
 
 /** \class cmWIXSourceWriter
  * \brief Helper class to generate XML WiX source files
@@ -25,8 +26,8 @@
 class cmWIXSourceWriter
 {
 public:
-  cmWIXSourceWriter(cmCPackLog* logger,
-    std::string const& filename, bool isIncludeFile = false);
+  cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
+                    bool isIncludeFile = false);
 
   ~cmWIXSourceWriter();
 
@@ -36,19 +37,18 @@ public:
 
   void AddTextNode(std::string const& text);
 
-  void AddProcessingInstruction(
-    std::string const& target, std::string const& content);
+  void AddProcessingInstruction(std::string const& target,
+                                std::string const& content);
 
-  void AddAttribute(
-    std::string const& key, std::string const& value);
+  void AddAttribute(std::string const& key, std::string const& value);
 
-  void AddAttributeUnlessEmpty(
-    std::string const& key, std::string const& value);
+  void AddAttributeUnlessEmpty(std::string const& key,
+                               std::string const& value);
 
   static std::string CMakeEncodingToUtf8(std::string const& value);
 
 protected:
-   cmCPackLog* Logger;
+  cmCPackLog* Logger;
 
 private:
   enum State
diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx
index 2809e56..b01c216 100644
--- a/Source/CPack/cmCPack7zGenerator.cxx
+++ b/Source/CPack/cmCPack7zGenerator.cxx
@@ -12,14 +12,11 @@
 
 #include "cmCPack7zGenerator.h"
 
-//----------------------------------------------------------------------
 cmCPack7zGenerator::cmCPack7zGenerator()
-  :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone,
-                           "7zip")
+  : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip")
 {
 }
 
-//----------------------------------------------------------------------
 cmCPack7zGenerator::~cmCPack7zGenerator()
 {
 }
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index db985db..7db20a4 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -12,80 +12,69 @@
 
 #include "cmCPackArchiveGenerator.h"
 
-#include "cmake.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCPackLog.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 #include <errno.h>
 
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/Directory.hxx>
 #include <cm_libarchive.h>
+#include <cmsys/Directory.hxx>
+#include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------
 cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t,
-  std::string const& format)
+                                                 std::string const& format)
 {
   this->Compress = t;
   this->ArchiveFormat = format;
 }
 
-//----------------------------------------------------------------------
 cmCPackArchiveGenerator::~cmCPackArchiveGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackArchiveGenerator::InitializeInternal()
 {
   this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
   return this->Superclass::InitializeInternal();
 }
-//----------------------------------------------------------------------
-int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
-                             cmCPackComponent* component)
+int cmCPackArchiveGenerator::addOneComponentToArchive(
+  cmArchiveWrite& archive, cmCPackComponent* component)
 {
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "   - packaging component: "
-      << component->Name
-      << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+                "   - packaging component: " << component->Name << std::endl);
   // Add the files of this component to the archive
   std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
-  localToplevel += "/"+ component->Name;
+  localToplevel += "/" + component->Name;
   std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
   // Change to local toplevel
   cmSystemTools::ChangeDirectory(localToplevel);
   std::string filePrefix;
-  if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
-    {
+  if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
     filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
     filePrefix += "/";
-    }
+  }
   const char* installPrefix =
     this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
-  if(installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0)
-    {
+  if (installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0) {
     // add to file prefix and remove the leading '/'
-    filePrefix += installPrefix+1;
+    filePrefix += installPrefix + 1;
     filePrefix += "/";
-    }
+  }
   std::vector<std::string>::const_iterator fileIt;
   for (fileIt = component->Files.begin(); fileIt != component->Files.end();
-       ++fileIt )
-    {
+       ++fileIt) {
     std::string rp = filePrefix + *fileIt;
-    cmCPackLogger(cmCPackLog::LOG_DEBUG,"Adding file: "
-                  << rp << std::endl);
+    cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl);
     archive.Add(rp, 0, 0, false);
-    if (!archive)
-      {
+    if (!archive) {
       cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: "
-            << archive.GetError()
-            << std::endl);
+                      << archive.GetError() << std::endl);
       return 0;
-      }
     }
+  }
   // Go back to previous dir
   cmSystemTools::ChangeDirectory(dir);
   return 1;
@@ -96,226 +85,193 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
  * an declare and open the associated
  * cmArchiveWrite 'archive' object.
  */
-#define DECLARE_AND_OPEN_ARCHIVE(filename,archive) \
-cmGeneratedFileStream gf; \
-gf.Open(filename.c_str(), false, true); \
-if (!GenerateHeader(&gf)) \
-  { \
-   cmCPackLogger(cmCPackLog::LOG_ERROR, \
-    "Problem to generate Header for archive < "     \
-            << filename \
-            << ">." << std::endl); \
-    return 0; \
-  } \
-cmArchiveWrite archive(gf,this->Compress, this->ArchiveFormat); \
-if (!archive) \
-  { \
-  cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \
-     << filename \
-     << ">. ERROR =" \
-     << archive.GetError() \
-     << std::endl); \
-  return 0; \
+#define DECLARE_AND_OPEN_ARCHIVE(filename, archive)                           \
+  cmGeneratedFileStream gf;                                                   \
+  gf.Open(filename.c_str(), false, true);                                     \
+  if (!GenerateHeader(&gf)) {                                                 \
+    cmCPackLogger(cmCPackLog::LOG_ERROR,                                      \
+                  "Problem to generate Header for archive < "                 \
+                    << filename << ">." << std::endl);                        \
+    return 0;                                                                 \
+  }                                                                           \
+  cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat);            \
+  if (!archive) {                                                             \
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < "       \
+                    << filename << ">. ERROR =" << archive.GetError()         \
+                    << std::endl);                                            \
+    return 0;                                                                 \
   }
 
-//----------------------------------------------------------------------
 int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
 {
   packageFileNames.clear();
   // The default behavior is to have one package by component group
   // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
-  if (!ignoreGroup)
-    {
+  if (!ignoreGroup) {
     std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
-    for (compGIt=this->ComponentGroups.begin();
-        compGIt!=this->ComponentGroups.end(); ++compGIt)
-      {
+    for (compGIt = this->ComponentGroups.begin();
+         compGIt != this->ComponentGroups.end(); ++compGIt) {
       cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
-          << compGIt->first
-          << std::endl);
+                      << compGIt->first << std::endl);
       // Begin the archive for this group
-      std::string packageFileName= std::string(toplevel);
-      packageFileName += "/"+
-       GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
-                                   compGIt->first,
-                                   true)
-         + this->GetOutputExtension();
+      std::string packageFileName = std::string(toplevel);
+      packageFileName += "/" +
+        GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+                                    compGIt->first, true) +
+        this->GetOutputExtension();
       // open a block in order to automatically close archive
       // at the end of the block
       {
-        DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
+        DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
         // now iterate over the component of this group
         std::vector<cmCPackComponent*>::iterator compIt;
-        for (compIt=(compGIt->second).Components.begin();
-            compIt!=(compGIt->second).Components.end();
-            ++compIt)
-          {
+        for (compIt = (compGIt->second).Components.begin();
+             compIt != (compGIt->second).Components.end(); ++compIt) {
           // Add the files of this component to the archive
-          addOneComponentToArchive(archive,*compIt);
-          }
+          addOneComponentToArchive(archive, *compIt);
+        }
       }
       // add the generated package to package file names list
       packageFileNames.push_back(packageFileName);
-      }
+    }
     // Handle Orphan components (components not belonging to any groups)
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt=this->Components.begin();
-         compIt!=this->Components.end(); ++compIt )
-      {
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
       // Does the component belong to a group?
-      if (compIt->second.Group==NULL)
-        {
-        cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-            "Component <"
-              << compIt->second.Name
-              << "> does not belong to any group, package it separately."
-              << std::endl);
+      if (compIt->second.Group == NULL) {
+        cmCPackLogger(
+          cmCPackLog::LOG_VERBOSE, "Component <"
+            << compIt->second.Name
+            << "> does not belong to any group, package it separately."
+            << std::endl);
         std::string localToplevel(
-          this->GetOption("CPACK_TEMPORARY_DIRECTORY")
-                                 );
+          this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
         std::string packageFileName = std::string(toplevel);
 
-        localToplevel += "/"+ compIt->first;
-        packageFileName += "/"+
-        GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
-                                    compIt->first,
-                                    false)
-                              + this->GetOutputExtension();
+        localToplevel += "/" + compIt->first;
+        packageFileName += "/" + GetComponentPackageFileName(
+                                   this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+                                   compIt->first, false) +
+          this->GetOutputExtension();
         {
-          DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
+          DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
           // Add the files of this component to the archive
-          addOneComponentToArchive(archive,&(compIt->second));
+          addOneComponentToArchive(archive, &(compIt->second));
         }
         // add the generated package to package file names list
         packageFileNames.push_back(packageFileName);
-        }
       }
     }
+  }
   // CPACK_COMPONENTS_IGNORE_GROUPS is set
   // We build 1 package per component
-  else
-    {
+  else {
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt=this->Components.begin();
-         compIt!=this->Components.end(); ++compIt )
-      {
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
       std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
       std::string packageFileName = std::string(toplevel);
 
-      localToplevel += "/"+ compIt->first;
-      packageFileName += "/"+
-       GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
-                                   compIt->first,
-                                   false)
-        + this->GetOutputExtension();
+      localToplevel += "/" + compIt->first;
+      packageFileName += "/" +
+        GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+                                    compIt->first, false) +
+        this->GetOutputExtension();
       {
-        DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive);
+        DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
         // Add the files of this component to the archive
-        addOneComponentToArchive(archive,&(compIt->second));
+        addOneComponentToArchive(archive, &(compIt->second));
       }
       // add the generated package to package file names list
       packageFileNames.push_back(packageFileName);
-      }
     }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackArchiveGenerator::PackageComponentsAllInOne()
 {
   // reset the package file names
   packageFileNames.clear();
   packageFileNames.push_back(std::string(toplevel));
-  packageFileNames[0] += "/"
-    +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
-    + this->GetOutputExtension();
+  packageFileNames[0] += "/" +
+    std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+    this->GetOutputExtension();
   cmCPackLogger(cmCPackLog::LOG_VERBOSE,
                 "Packaging all groups in one package..."
                 "(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)"
-      << std::endl);
-  DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
+                  << std::endl);
+  DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
 
   // The ALL COMPONENTS in ONE package case
   std::map<std::string, cmCPackComponent>::iterator compIt;
-  for (compIt=this->Components.begin();compIt!=this->Components.end();
-      ++compIt )
-    {
+  for (compIt = this->Components.begin(); compIt != this->Components.end();
+       ++compIt) {
     // Add the files of this component to the archive
-    addOneComponentToArchive(archive,&(compIt->second));
-    }
+    addOneComponentToArchive(archive, &(compIt->second));
+  }
 
   // archive goes out of scope so it will finalized and closed.
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackArchiveGenerator::PackageFiles()
 {
-  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
-                << toplevel << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
 
   if (WantsComponentInstallation()) {
     // CASE 1 : COMPONENT ALL-IN-ONE package
     // If ALL COMPONENTS in ONE package has been requested
     // then the package file is unique and should be open here.
-    if (componentPackageMethod == ONE_PACKAGE)
-      {
+    if (componentPackageMethod == ONE_PACKAGE) {
       return PackageComponentsAllInOne();
-      }
+    }
     // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
     // There will be 1 package for each component group
     // however one may require to ignore component group and
     // in this case you'll get 1 package for each component.
-    else
-      {
+    else {
       return PackageComponents(componentPackageMethod ==
                                ONE_PACKAGE_PER_COMPONENT);
-      }
+    }
   }
 
   // CASE 3 : NON COMPONENT package.
-  DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
+  DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
   std::vector<std::string>::const_iterator fileIt;
   std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
   cmSystemTools::ChangeDirectory(toplevel);
-  for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
-    {
+  for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     // Get the relative path to the file
-    std::string rp = cmSystemTools::RelativePath(toplevel.c_str(),
-                                                 fileIt->c_str());
+    std::string rp =
+      cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str());
     archive.Add(rp, 0, 0, false);
-    if(!archive)
-      {
+    if (!archive) {
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "
-          << *fileIt
-          << "> to archive <"
-          << packageFileNames[0] << "> .ERROR ="
-          << archive.GetError()
-          << std::endl);
+                      << *fileIt << "> to archive <" << packageFileNames[0]
+                      << "> .ERROR =" << archive.GetError() << std::endl);
       return 0;
-      }
     }
+  }
   cmSystemTools::ChangeDirectory(dir);
   // The destructor of cmArchiveWrite will close and finish the write
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackArchiveGenerator::GenerateHeader(std::ostream*)
 {
   return 1;
 }
 
-bool cmCPackArchiveGenerator::SupportsComponentInstallation() const {
+bool cmCPackArchiveGenerator::SupportsComponentInstallation() const
+{
   // The Component installation support should only
   // be activated if explicitly requested by the user
   // (for backward compatibility reason)
-  if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL"))
-    {
+  if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL")) {
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h
index 16e7632..9eb38b1 100644
--- a/Source/CPack/cmCPackArchiveGenerator.h
+++ b/Source/CPack/cmCPackArchiveGenerator.h
@@ -13,9 +13,9 @@
 #ifndef cmCPackArchiveGenerator_h
 #define cmCPackArchiveGenerator_h
 
-#include "cmArchiveWrite.h"
 #include "cmCPackGenerator.h"
 
+#include "cmArchiveWrite.h"
 
 /** \class cmCPackArchiveGenerator
  * \brief A generator base for libarchive generation.
@@ -24,7 +24,7 @@
  *
  */
 class cmCPackArchiveGenerator : public cmCPackGenerator
-  {
+{
 public:
   cmTypeMacro(cmCPackArchiveGenerator, cmCPackGenerator);
 
@@ -37,6 +37,7 @@ public:
   virtual int GenerateHeader(std::ostream* os);
   // component support
   virtual bool SupportsComponentInstallation() const;
+
 protected:
   virtual int InitializeInternal();
   /**
@@ -69,6 +70,6 @@ protected:
   virtual const char* GetOutputExtension() = 0;
   cmArchiveWrite::Compress Compress;
   std::string ArchiveFormat;
-  };
+};
 
 #endif
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx
index b2d7019..1164021 100644
--- a/Source/CPack/cmCPackBundleGenerator.cxx
+++ b/Source/CPack/cmCPackBundleGenerator.cxx
@@ -11,53 +11,46 @@
 ============================================================================*/
 
 #include "cmCPackBundleGenerator.h"
+
 #include "cmCPackLog.h"
 #include "cmSystemTools.h"
 
 #include <cmsys/RegularExpression.hxx>
 
-//----------------------------------------------------------------------
 cmCPackBundleGenerator::cmCPackBundleGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackBundleGenerator::~cmCPackBundleGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackBundleGenerator::InitializeInternal()
 {
   const char* name = this->GetOption("CPACK_BUNDLE_NAME");
-  if(0 == name)
-    {
+  if (0 == name) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "CPACK_BUNDLE_NAME must be set to use the Bundle generator."
-      << std::endl);
+                  "CPACK_BUNDLE_NAME must be set to use the Bundle generator."
+                    << std::endl);
 
     return 0;
-    }
+  }
 
-  if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP"))
-    {
-    const std::string codesign_path = cmSystemTools::FindProgram("codesign",
-       std::vector<std::string>(), false);
+  if (this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) {
+    const std::string codesign_path = cmSystemTools::FindProgram(
+      "codesign", std::vector<std::string>(), false);
 
-    if(codesign_path.empty())
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Cannot locate codesign command"
-        << std::endl);
+    if (codesign_path.empty()) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate codesign command"
+                      << std::endl);
       return 0;
-      }
-    this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
     }
+    this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
+  }
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
 {
   this->InstallPrefix = "/";
@@ -67,48 +60,45 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
   return this->InstallPrefix.c_str();
 }
 
-//----------------------------------------------------------------------
 int cmCPackBundleGenerator::ConstructBundle()
 {
 
   // Get required arguments ...
   const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME")
-    ? this->GetOption("CPACK_BUNDLE_NAME") : "";
-  if(cpack_bundle_name.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "CPACK_BUNDLE_NAME must be set."
-      << std::endl);
+    ? this->GetOption("CPACK_BUNDLE_NAME")
+    : "";
+  if (cpack_bundle_name.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_NAME must be set."
+                    << std::endl);
 
     return 0;
-    }
+  }
 
   const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST")
-    ? this->GetOption("CPACK_BUNDLE_PLIST") : "";
-  if(cpack_bundle_plist.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "CPACK_BUNDLE_PLIST must be set."
-      << std::endl);
+    ? this->GetOption("CPACK_BUNDLE_PLIST")
+    : "";
+  if (cpack_bundle_plist.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_PLIST must be set."
+                    << std::endl);
 
     return 0;
-    }
+  }
 
   const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON")
-    ? this->GetOption("CPACK_BUNDLE_ICON") : "";
-  if(cpack_bundle_icon.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "CPACK_BUNDLE_ICON must be set."
-      << std::endl);
+    ? this->GetOption("CPACK_BUNDLE_ICON")
+    : "";
+  if (cpack_bundle_icon.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_ICON must be set."
+                    << std::endl);
 
     return 0;
-    }
+  }
 
   // Get optional arguments ...
   const std::string cpack_bundle_startup_command =
     this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
-    ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") : "";
+    ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
+    : "";
 
   // The staging directory contains everything that will end-up inside the
   // final disk image ...
@@ -116,30 +106,33 @@ int cmCPackBundleGenerator::ConstructBundle()
   staging << toplevel;
 
   std::ostringstream contents;
-  contents << staging.str() << "/" << cpack_bundle_name
-    << ".app/" << "Contents";
+  contents << staging.str() << "/" << cpack_bundle_name << ".app/"
+           << "Contents";
 
   std::ostringstream application;
-  application << contents.str() << "/" << "MacOS";
+  application << contents.str() << "/"
+              << "MacOS";
 
   std::ostringstream resources;
-  resources << contents.str() << "/" << "Resources";
+  resources << contents.str() << "/"
+            << "Resources";
 
   // Install a required, user-provided bundle metadata file ...
   std::ostringstream plist_source;
   plist_source << cpack_bundle_plist;
 
   std::ostringstream plist_target;
-  plist_target << contents.str() << "/" << "Info.plist";
+  plist_target << contents.str() << "/"
+               << "Info.plist";
 
-  if(!this->CopyFile(plist_source, plist_target))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
+  if (!this->CopyFile(plist_source, plist_target)) {
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR,
       "Error copying plist.  Check the value of CPACK_BUNDLE_PLIST."
-      << std::endl);
+        << std::endl);
 
     return 0;
-    }
+  }
 
   // Install a user-provided bundle icon ...
   std::ostringstream icon_source;
@@ -148,53 +141,48 @@ int cmCPackBundleGenerator::ConstructBundle()
   std::ostringstream icon_target;
   icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
 
-  if(!this->CopyFile(icon_source, icon_target))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
+  if (!this->CopyFile(icon_source, icon_target)) {
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR,
       "Error copying bundle icon.  Check the value of CPACK_BUNDLE_ICON."
-      << std::endl);
+        << std::endl);
 
     return 0;
-    }
+  }
 
   // Optionally a user-provided startup command (could be an
   // executable or a script) ...
-  if(!cpack_bundle_startup_command.empty())
-    {
+  if (!cpack_bundle_startup_command.empty()) {
     std::ostringstream command_source;
     command_source << cpack_bundle_startup_command;
 
     std::ostringstream command_target;
     command_target << application.str() << "/" << cpack_bundle_name;
 
-    if(!this->CopyFile(command_source, command_target))
-      {
+    if (!this->CopyFile(command_source, command_target)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Error copying startup command. "
                     " Check the value of CPACK_BUNDLE_STARTUP_COMMAND."
-        << std::endl);
+                      << std::endl);
 
       return 0;
-      }
+    }
 
     cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
-    }
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackBundleGenerator::PackageFiles()
 {
-  if(!this->ConstructBundle())
-    {
+  if (!this->ConstructBundle()) {
     return 0;
-    }
+  }
 
-  if(!this->SignBundle(toplevel))
-    {
+  if (!this->SignBundle(toplevel)) {
     return 0;
-    }
+  }
 
   return this->CreateDMG(toplevel, packageFileNames[0]);
 }
@@ -204,16 +192,15 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const
   return false;
 }
 
-
 int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
 {
   const std::string cpack_apple_cert_app =
     this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
-    ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : "";
+    ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
+    : "";
 
   // codesign the application.
-  if(!cpack_apple_cert_app.empty())
-    {
+  if (!cpack_apple_cert_app.empty()) {
     std::string output;
     std::string bundle_path;
     bundle_path = src_dir + "/";
@@ -228,15 +215,15 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
 
     const std::string sign_files =
       this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
-      ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : "";
+      ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
+      : "";
 
     std::vector<std::string> relFiles;
     cmSystemTools::ExpandListArgument(sign_files, relFiles);
 
     // sign the files supplied by the user, ie. frameworks.
-    for(std::vector<std::string>::iterator it = relFiles.begin();
-      it != relFiles.end(); ++it)
-      {
+    for (std::vector<std::string>::iterator it = relFiles.begin();
+         it != relFiles.end(); ++it) {
       std::ostringstream temp_sign_file_cmd;
       temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
       temp_sign_file_cmd << " " << sign_parameter << " -s \""
@@ -247,15 +234,14 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
       temp_sign_file_cmd << bundle_path;
       temp_sign_file_cmd << it->c_str() << "\"";
 
-      if(!this->RunCommand(temp_sign_file_cmd, &output))
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Error signing file:"
-          << bundle_path << it->c_str() << std::endl << output << std::endl);
+      if (!this->RunCommand(temp_sign_file_cmd, &output)) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Error signing file:"
+                        << bundle_path << it->c_str() << std::endl
+                        << output << std::endl);
 
         return 0;
-        }
       }
+    }
 
     // sign main binary
     std::ostringstream temp_sign_binary_cmd;
@@ -264,43 +250,42 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
                          << cpack_apple_cert_app;
     temp_sign_binary_cmd << "\" \"" << bundle_path << "\"";
 
-    if(!this->RunCommand(temp_sign_binary_cmd, &output))
-      {
+    if (!this->RunCommand(temp_sign_binary_cmd, &output)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error signing the application binary."
-        << std::endl << output << std::endl);
+                    "Error signing the application binary." << std::endl
+                                                            << output
+                                                            << std::endl);
 
       return 0;
-      }
+    }
 
     // sign app bundle
     std::ostringstream temp_codesign_cmd;
     temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
     temp_codesign_cmd << " " << sign_parameter << " -s \""
                       << cpack_apple_cert_app << "\"";
-    if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"))
-      {
+    if (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) {
       temp_codesign_cmd << " --entitlements ";
       temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS");
-      }
+    }
     temp_codesign_cmd << " \"" << bundle_path << "\"";
 
-    if(!this->RunCommand(temp_codesign_cmd, &output))
-      {
+    if (!this->RunCommand(temp_codesign_cmd, &output)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error signing the application package."
-        << std::endl << output << std::endl);
+                    "Error signing the application package." << std::endl
+                                                             << output
+                                                             << std::endl);
 
       return 0;
-      }
+    }
 
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-      "- Application has been codesigned"
-      << std::endl);
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Application has been codesigned"
+                    << std::endl);
     cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-       (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
-         ? "with entitlement sandboxing" : "without entitlement sandboxing")
-       << std::endl);
+                  (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
+                     ? "with entitlement sandboxing"
+                     : "without entitlement sandboxing")
+                    << std::endl);
   }
 
   return 1;
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index fd20e9b..d262ac9 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -11,35 +11,33 @@
 ============================================================================*/
 
 #include "cmCPackComponentGroup.h"
+
 #include "cmSystemTools.h"
-#include <vector>
+
 #include <string>
+#include <vector>
 
-//----------------------------------------------------------------------
 unsigned long cmCPackComponent::GetInstalledSize(
-    const std::string& installDir) const
+  const std::string& installDir) const
 {
-  if (this->TotalSize != 0)
-    {
+  if (this->TotalSize != 0) {
     return this->TotalSize;
-    }
+  }
 
   std::vector<std::string>::const_iterator fileIt;
-  for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt)
-    {
+  for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
     std::string path = installDir;
     path += '/';
     path += *fileIt;
     this->TotalSize += cmSystemTools::FileLength(path);
-    }
+  }
 
   return this->TotalSize;
 }
 
-//----------------------------------------------------------------------
-unsigned long
-cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const
+unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
+  const std::string& installDir) const
 {
   unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
-  return result? result : 1;
+  return result ? result : 1;
 }
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h
index 0679638..5361d95 100644
--- a/Source/CPack/cmCPackComponentGroup.h
+++ b/Source/CPack/cmCPackComponentGroup.h
@@ -42,9 +42,15 @@ public:
 class cmCPackComponent
 {
 public:
- cmCPackComponent() : Group(0), IsRequired(true), IsHidden(false),
-                      IsDisabledByDefault(false), IsDownloaded(false),
-                      TotalSize(0) { }
+  cmCPackComponent()
+    : Group(0)
+    , IsRequired(true)
+    , IsHidden(false)
+    , IsDisabledByDefault(false)
+    , IsDownloaded(false)
+    , TotalSize(0)
+  {
+  }
 
   /// The name of the component (used to reference the component).
   std::string Name;
@@ -53,7 +59,7 @@ public:
   std::string DisplayName;
 
   /// The component group that contains this component (if any).
-  cmCPackComponentGroup *Group;
+  cmCPackComponentGroup* Group;
 
   /// Whether this component group must always be installed.
   bool IsRequired : 1;
@@ -73,17 +79,17 @@ public:
   std::string Description;
 
   /// The installation types that this component is a part of.
-  std::vector<cmCPackInstallationType *> InstallationTypes;
+  std::vector<cmCPackInstallationType*> InstallationTypes;
 
   /// If IsDownloaded is true, the name of the archive file that
   /// contains the files that are part of this component.
   std::string ArchiveFile;
 
   /// The components that this component depends on.
-  std::vector<cmCPackComponent *> Dependencies;
+  std::vector<cmCPackComponent*> Dependencies;
 
   /// The components that depend on this component.
-  std::vector<cmCPackComponent *> ReverseDependencies;
+  std::vector<cmCPackComponent*> ReverseDependencies;
 
   /// The list of installed files that are part of this component.
   std::vector<std::string> Files;
@@ -100,7 +106,7 @@ public:
   /// kilobytes.
   unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const;
 
- private:
+private:
   mutable unsigned long TotalSize;
 };
 
@@ -110,7 +116,10 @@ public:
 class cmCPackComponentGroup
 {
 public:
- cmCPackComponentGroup() : ParentGroup(0) { }
+  cmCPackComponentGroup()
+    : ParentGroup(0)
+  {
+  }
 
   /// The name of the group (used to reference the group).
   std::string Name;
@@ -131,7 +140,7 @@ public:
   std::vector<cmCPackComponent*> Components;
 
   /// The parent group of this component group (if any).
-  cmCPackComponentGroup *ParentGroup;
+  cmCPackComponentGroup* ParentGroup;
 
   /// The subgroups of this group.
   std::vector<cmCPackComponentGroup*> Subgroups;
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
index 1f905c0..83af89e 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
@@ -12,26 +12,23 @@
 
 #include "cmCPackCygwinBinaryGenerator.h"
 
-#include "cmake.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCPackLog.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 
 #include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------
 cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackCygwinBinaryGenerator::~cmCPackCygwinBinaryGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackCygwinBinaryGenerator::InitializeInternal()
 {
   this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
@@ -39,7 +36,6 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal()
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 int cmCPackCygwinBinaryGenerator::PackageFiles()
 {
   std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
@@ -49,8 +45,7 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
   std::string manifest = "/usr/share/doc/";
   manifest += packageName;
   manifest += "/MANIFEST";
-  std::string manifestFile
-    = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  std::string manifestFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
   // Create a MANIFEST file that contains all of the files in
   // the tar file
   std::string tempdir = manifestFile;
@@ -58,14 +53,13 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
   // create an extra scope to force the stream
   // to create the file before the super class is called
   {
-  cmGeneratedFileStream ofs(manifestFile.c_str());
-  for(std::vector<std::string>::const_iterator i = files.begin();
-      i != files.end(); ++i)
-    {
-    // remove the temp dir and replace with /usr
-    ofs << (*i).substr(tempdir.size()) << "\n";
+    cmGeneratedFileStream ofs(manifestFile.c_str());
+    for (std::vector<std::string>::const_iterator i = files.begin();
+         i != files.end(); ++i) {
+      // remove the temp dir and replace with /usr
+      ofs << (*i).substr(tempdir.size()) << "\n";
     }
-  ofs << manifest << "\n";
+    ofs << manifest << "\n";
   }
   // add the manifest file to the list of all files
   files.push_back(manifestFile);
@@ -77,14 +71,13 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
 const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
 {
   this->OutputExtension = "-";
-  const char* patchNumber =this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
-  if(!patchNumber)
-    {
+  const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
+  if (!patchNumber) {
     patchNumber = "1";
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
-                  << std::endl);
-    }
+                    << std::endl);
+  }
   this->OutputExtension += patchNumber;
   this->OutputExtension += ".tar.bz2";
   return this->OutputExtension.c_str();
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h
index 38f6df1..8de4bae 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.h
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h
@@ -28,6 +28,7 @@ public:
    */
   cmCPackCygwinBinaryGenerator();
   virtual ~cmCPackCygwinBinaryGenerator();
+
 protected:
   virtual int InitializeInternal();
   int PackageFiles();
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
index f5cb53c..5fcfaf4 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
@@ -12,12 +12,12 @@
 
 #include "cmCPackCygwinSourceGenerator.h"
 
-#include "cmake.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCPackLog.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 
 #include <cmsys/SystemTools.hxx>
 
@@ -25,33 +25,29 @@
 // system tools because it is not implemented robustly enough to move
 // files across directories.
 #ifdef _WIN32
-# include <windows.h>
-# include <sys/stat.h>
+#include <sys/stat.h>
+#include <windows.h>
 #endif
 
-//----------------------------------------------------------------------
 cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackCygwinSourceGenerator::~cmCPackCygwinSourceGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackCygwinSourceGenerator::InitializeInternal()
 {
   this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 int cmCPackCygwinSourceGenerator::PackageFiles()
 {
   // Create a tar file of the sources
-  std::string packageDirFileName
-    = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  std::string packageDirFileName =
+    this->GetOption("CPACK_TEMPORARY_DIRECTORY");
   packageDirFileName += ".tar.bz2";
   packageFileNames[0] = packageDirFileName;
   std::string output;
@@ -59,10 +55,9 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
   // to create tar.bz2 file with the list of source
   // files
   this->Compress = cmArchiveWrite::CompressBZip2;
-  if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
-    {
+  if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
     return 0;
-    }
+  }
   // Now create a tar file that contains the above .tar.bz2 file
   // and the CPACK_CYGWIN_PATCH_FILE and CPACK_TOPLEVEL_DIRECTORY
   // files
@@ -80,47 +75,41 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
   // to the toplevel cpack temp dir
 
   // copy the patch file into place
-  if(!this->GetOption("CPACK_CYGWIN_PATCH_FILE"))
-    {
+  if (!this->GetOption("CPACK_CYGWIN_PATCH_FILE")) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "No patch file specified for cygwin sources.");
     return 0;
-    }
-  if(!cmSystemTools::CopyFileAlways(
-       this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
-       this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
-    {
+  }
+  if (!cmSystemTools::CopyFileAlways(
+        this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
+        this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: ["
-                  << this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
-                  << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
+                    << this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
+                    << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
     return 0;
-    }
-  if(!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"))
-    {
+  }
+  if (!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "No build script specified for cygwin sources.");
     return 0;
-    }
+  }
   // copy the build script into place
-  if(!cmSystemTools::CopyFileAlways(
-       this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
-       this->GetOption("CPACK_TOPLEVEL_DIRECTORY")))
-    {
+  if (!cmSystemTools::CopyFileAlways(
+        this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
+        this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: "
-                  << this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
-                  << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
+                    << this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
+                    << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
     return 0;
-    }
-  std::string outerTarFile
-    = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  }
+  std::string outerTarFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
   outerTarFile += "-";
   const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
-  if(!patch)
-    {
+  if (!patch) {
     cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
-                  << " not specified, defaulting to 1\n");
+                    << " not specified, defaulting to 1\n");
     patch = "1";
-    }
+  }
   outerTarFile += patch;
   outerTarFile += "-src.tar.bz2";
   std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -130,8 +119,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
     this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
   std::string patchFile = tmpDir;
   patchFile += "/";
-  patchFile += cmSystemTools::GetFilenameName(
-    this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
+  patchFile +=
+    cmSystemTools::GetFilenameName(this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
 
   std::string file = cmSystemTools::GetFilenameName(compressOutFile);
   std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
@@ -150,10 +139,9 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
   packageFileNames[0] = outerTarFile;
   /* update the toplevel dir */
   toplevel = tmpDir;
-  if ( !this->cmCPackTarBZip2Generator::PackageFiles() )
-    {
+  if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
     return 0;
-    }
+  }
   return 1;
 }
 
@@ -168,14 +156,12 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
 {
   this->OutputExtension = "-";
   const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
-  if(!patch)
-    {
+  if (!patch) {
     cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
-                  << " not specified, defaulting to 1\n");
+                    << " not specified, defaulting to 1\n");
     patch = "1";
-    }
+  }
   this->OutputExtension += patch;
   this->OutputExtension += "-src.tar.bz2";
   return this->OutputExtension.c_str();
 }
-
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h
index 9d98a9b..4aba8b9 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.h
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.h
@@ -28,6 +28,7 @@ public:
    */
   cmCPackCygwinSourceGenerator();
   virtual ~cmCPackCygwinSourceGenerator();
+
 protected:
   const char* GetPackagingInstallPrefix();
   virtual int InitializeInternal();
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 13c8d8f..1ad4152 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -9,16 +9,17 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+
 #include "cmCPackDebGenerator.h"
 
-#include "cmSystemTools.h"
-#include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCPackLog.h"
 #include "cmArchiveWrite.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
+#include "cmMakefile.h"
+#include "cmSystemTools.h"
 
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Glob.hxx>
+#include <cmsys/SystemTools.hxx>
 
 #include <limits.h> // USHRT_MAX
 #include <sys/stat.h>
@@ -29,92 +30,85 @@
 // a GNU ar.
 // See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
 // Therefore we provide our own implementation of a BSD-ar:
-static int ar_append(const char*archive,const std::vector<std::string>& files);
+static int ar_append(const char* archive,
+                     const std::vector<std::string>& files);
 
-//----------------------------------------------------------------------
 cmCPackDebGenerator::cmCPackDebGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackDebGenerator::~cmCPackDebGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackDebGenerator::InitializeInternal()
 {
   this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
-  if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
-    {
+  if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
     this->SetOption("CPACK_SET_DESTDIR", "I_ON");
-    }
+  }
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
-int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
-                                        std::string packageName)
-  {
+int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
+                                        std::string const& packageName)
+{
   int retval = 1;
   // Begin the archive for this pack
   std::string localToplevel(initialTopLevel);
-  std::string packageFileName(
-      cmSystemTools::GetParentDirectory(toplevel)
-  );
-  std::string outputFileName(
-      std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
-  +"-"+packageName + this->GetOutputExtension()
-  );
-
-  localToplevel += "/"+ packageName;
+  std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
+  std::string outputFileName(std::string(
+                               this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+                             "-" + packageName + this->GetOutputExtension());
+
+  localToplevel += "/" + packageName;
   /* replace the TEMP DIRECTORY with the component one */
-  this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
-  packageFileName += "/"+ outputFileName;
+  this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+  packageFileName += "/" + outputFileName;
   /* replace proposed CPACK_OUTPUT_FILE_NAME */
-  this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+  this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
   /* replace the TEMPORARY package file name */
   this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
-      packageFileName.c_str());
+                  packageFileName.c_str());
   // Tell CPackDeb.cmake the name of the component GROUP.
-  this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",packageName.c_str());
+  this->SetOption("CPACK_DEB_PACKAGE_COMPONENT", packageName.c_str());
   // Tell CPackDeb.cmake the path where the component is.
   std::string component_path = "/";
   component_path += packageName;
   this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
                   component_path.c_str());
-  if (!this->ReadListFile("CPackDeb.cmake"))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error while execution CPackDeb.cmake" << std::endl);
+  if (!this->ReadListFile("CPackDeb.cmake")) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
+                    << std::endl);
     retval = 0;
     return retval;
-    }
+  }
 
   cmsys::Glob gl;
   std::string findExpr(this->GetOption("GEN_WDIR"));
   findExpr += "/*";
   gl.RecurseOn();
   gl.SetRecurseListDirs(true);
-  if ( !gl.FindFiles(findExpr) )
-    {
+  if (!gl.FindFiles(findExpr)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Cannot find any files in the installed directory" << std::endl);
+                  "Cannot find any files in the installed directory"
+                    << std::endl);
     return 0;
-    }
+  }
   packageFiles = gl.GetFiles();
 
   int res = createDeb();
-  if (res != 1)
-    {
+  if (res != 1) {
     retval = 0;
-    }
+  }
   // add the generated package to package file names list
+  packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+  packageFileName += "/";
+  packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
   packageFileNames.push_back(packageFileName);
   return retval;
 }
 
-//----------------------------------------------------------------------
 int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
 {
   int retval = 1;
@@ -125,339 +119,322 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
 
   // The default behavior is to have one package by component group
   // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
-  if (!ignoreGroup)
-    {
+  if (!ignoreGroup) {
     std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
-    for (compGIt=this->ComponentGroups.begin();
-        compGIt!=this->ComponentGroups.end(); ++compGIt)
-      {
+    for (compGIt = this->ComponentGroups.begin();
+         compGIt != this->ComponentGroups.end(); ++compGIt) {
       cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
-          << compGIt->first
-          << std::endl);
+                      << compGIt->first << std::endl);
       // Begin the archive for this group
-      retval &= PackageOnePack(initialTopLevel,compGIt->first);
-      }
+      retval &= PackageOnePack(initialTopLevel, compGIt->first);
+    }
     // Handle Orphan components (components not belonging to any groups)
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt=this->Components.begin();
-        compIt!=this->Components.end(); ++compIt )
-      {
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
       // Does the component belong to a group?
-      if (compIt->second.Group==NULL)
-        {
-        cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-            "Component <"
+      if (compIt->second.Group == NULL) {
+        cmCPackLogger(
+          cmCPackLog::LOG_VERBOSE, "Component <"
             << compIt->second.Name
             << "> does not belong to any group, package it separately."
             << std::endl);
         // Begin the archive for this orphan component
-        retval &= PackageOnePack(initialTopLevel,compIt->first);
-        }
+        retval &= PackageOnePack(initialTopLevel, compIt->first);
       }
     }
+  }
   // CPACK_COMPONENTS_IGNORE_GROUPS is set
   // We build 1 package per component
-  else
-    {
+  else {
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt=this->Components.begin();
-         compIt!=this->Components.end(); ++compIt )
-      {
-      retval &= PackageOnePack(initialTopLevel,compIt->first);
-      }
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
+      retval &= PackageOnePack(initialTopLevel, compIt->first);
     }
+  }
   return retval;
 }
 
 //----------------------------------------------------------------------
-int cmCPackDebGenerator::PackageComponentsAllInOne()
+int cmCPackDebGenerator::PackageComponentsAllInOne(
+  const std::string& compInstDirName)
 {
   int retval = 1;
-  std::string compInstDirName;
   /* Reset package file name list it will be populated during the
    * component packaging run*/
   packageFileNames.clear();
   std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
 
-  compInstDirName = "ALL_COMPONENTS_IN_ONE";
-
   cmCPackLogger(cmCPackLog::LOG_VERBOSE,
                 "Packaging all groups in one package..."
                 "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
-      << std::endl);
+                  << std::endl);
 
   // The ALL GROUPS in ONE package case
   std::string localToplevel(initialTopLevel);
-  std::string packageFileName(
-      cmSystemTools::GetParentDirectory(toplevel)
-                             );
-  std::string outputFileName(
-            std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
-            + this->GetOutputExtension()
-                            );
+  std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
+  std::string outputFileName(std::string(
+                               this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+                             this->GetOutputExtension());
   // all GROUP in one vs all COMPONENT in one
-  localToplevel += "/"+compInstDirName;
+  localToplevel += "/" + compInstDirName;
 
   /* replace the TEMP DIRECTORY with the component one */
-  this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
-  packageFileName += "/"+ outputFileName;
+  this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+  packageFileName += "/" + outputFileName;
   /* replace proposed CPACK_OUTPUT_FILE_NAME */
-  this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+  this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
   /* replace the TEMPORARY package file name */
   this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
-      packageFileName.c_str());
-  // Tell CPackDeb.cmake the path where the component is.
-  std::string component_path = "/";
-  component_path += compInstDirName;
-  this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
-                  component_path.c_str());
-  if (!this->ReadListFile("CPackDeb.cmake"))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error while execution CPackDeb.cmake" << std::endl);
+                  packageFileName.c_str());
+
+  if (!compInstDirName.empty()) {
+    // Tell CPackDeb.cmake the path where the component is.
+    std::string component_path = "/";
+    component_path += compInstDirName;
+    this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
+                    component_path.c_str());
+  }
+  if (!this->ReadListFile("CPackDeb.cmake")) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
+                    << std::endl);
     retval = 0;
     return retval;
-    }
+  }
 
   cmsys::Glob gl;
   std::string findExpr(this->GetOption("GEN_WDIR"));
   findExpr += "/*";
   gl.RecurseOn();
   gl.SetRecurseListDirs(true);
-  if ( !gl.FindFiles(findExpr) )
-    {
+  if (!gl.FindFiles(findExpr)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-    "Cannot find any files in the installed directory" << std::endl);
+                  "Cannot find any files in the installed directory"
+                    << std::endl);
     return 0;
-    }
+  }
   packageFiles = gl.GetFiles();
 
   int res = createDeb();
-  if (res != 1)
-    {
+  if (res != 1) {
     retval = 0;
-    }
+  }
   // add the generated package to package file names list
+  packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+  packageFileName += "/";
+  packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
   packageFileNames.push_back(packageFileName);
   return retval;
 }
 
-//----------------------------------------------------------------------
 int cmCPackDebGenerator::PackageFiles()
 {
-  int retval = -1;
-
   /* Are we in the component packaging case */
   if (WantsComponentInstallation()) {
     // CASE 1 : COMPONENT ALL-IN-ONE package
     // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
     // then the package file is unique and should be open here.
-    if (componentPackageMethod == ONE_PACKAGE)
-      {
-      return PackageComponentsAllInOne();
-      }
+    if (componentPackageMethod == ONE_PACKAGE) {
+      return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
+    }
     // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
     // There will be 1 package for each component group
     // however one may require to ignore component group and
     // in this case you'll get 1 package for each component.
-    else
-      {
+    else {
       return PackageComponents(componentPackageMethod ==
                                ONE_PACKAGE_PER_COMPONENT);
-      }
+    }
   }
   // CASE 3 : NON COMPONENT package.
-  else
-    {
-    if (!this->ReadListFile("CPackDeb.cmake"))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-                    "Error while execution CPackDeb.cmake" << std::endl);
-      retval = 0;
-      }
-    else
-      {
-      packageFiles = files;
-      return createDeb();
-      }
-    }
-  return retval;
+  else {
+    return PackageComponentsAllInOne("");
+  }
 }
 
 int cmCPackDebGenerator::createDeb()
 {
   // debian-binary file
-  std::string dbfilename;
-    dbfilename += this->GetOption("GEN_WDIR");
-  dbfilename += "/debian-binary";
-    { // the scope is needed for cmGeneratedFileStream
+  const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
+  const std::string dbfilename = strGenWDIR + "/debian-binary";
+  { // the scope is needed for cmGeneratedFileStream
     cmGeneratedFileStream out(dbfilename.c_str());
     out << "2.0";
     out << std::endl; // required for valid debian package
-    }
+  }
 
   // control file
-  std::string ctlfilename;
-    ctlfilename = this->GetOption("GEN_WDIR");
-  ctlfilename += "/control";
+  std::string ctlfilename = strGenWDIR + "/control";
 
   // debian policy enforce lower case for package name
   // mandatory entries:
   std::string debian_pkg_name = cmsys::SystemTools::LowerCase(
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") );
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
   const char* debian_pkg_version =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
   const char* debian_pkg_section =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
   const char* debian_pkg_priority =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
   const char* debian_pkg_arch =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
   const char* maintainer =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
-  const char* desc =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
+  const char* desc = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
 
   // optional entries
   const char* debian_pkg_dep =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
   const char* debian_pkg_rec =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
   const char* debian_pkg_sug =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
   const char* debian_pkg_url =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
   const char* debian_pkg_predep =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
   const char* debian_pkg_enhances =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
   const char* debian_pkg_breaks =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
   const char* debian_pkg_conflicts =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
   const char* debian_pkg_provides =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
   const char* debian_pkg_replaces =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
   const char* debian_pkg_source =
-      this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
 
-
-    { // the scope is needed for cmGeneratedFileStream
+  { // the scope is needed for cmGeneratedFileStream
     cmGeneratedFileStream out(ctlfilename.c_str());
     out << "Package: " << debian_pkg_name << "\n";
     out << "Version: " << debian_pkg_version << "\n";
     out << "Section: " << debian_pkg_section << "\n";
     out << "Priority: " << debian_pkg_priority << "\n";
     out << "Architecture: " << debian_pkg_arch << "\n";
-    if(debian_pkg_source && *debian_pkg_source)
-      {
+    if (debian_pkg_source && *debian_pkg_source) {
       out << "Source: " << debian_pkg_source << "\n";
-      }
-    if(debian_pkg_dep && *debian_pkg_dep)
-      {
+    }
+    if (debian_pkg_dep && *debian_pkg_dep) {
       out << "Depends: " << debian_pkg_dep << "\n";
-      }
-    if(debian_pkg_rec && *debian_pkg_rec)
-      {
+    }
+    if (debian_pkg_rec && *debian_pkg_rec) {
       out << "Recommends: " << debian_pkg_rec << "\n";
-      }
-    if(debian_pkg_sug && *debian_pkg_sug)
-      {
+    }
+    if (debian_pkg_sug && *debian_pkg_sug) {
       out << "Suggests: " << debian_pkg_sug << "\n";
-      }
-    if(debian_pkg_url && *debian_pkg_url)
-      {
+    }
+    if (debian_pkg_url && *debian_pkg_url) {
       out << "Homepage: " << debian_pkg_url << "\n";
-      }
-    if (debian_pkg_predep && *debian_pkg_predep)
-      {
+    }
+    if (debian_pkg_predep && *debian_pkg_predep) {
       out << "Pre-Depends: " << debian_pkg_predep << "\n";
-      }
-    if (debian_pkg_enhances && *debian_pkg_enhances)
-      {
+    }
+    if (debian_pkg_enhances && *debian_pkg_enhances) {
       out << "Enhances: " << debian_pkg_enhances << "\n";
-      }
-    if (debian_pkg_breaks && *debian_pkg_breaks)
-      {
+    }
+    if (debian_pkg_breaks && *debian_pkg_breaks) {
       out << "Breaks: " << debian_pkg_breaks << "\n";
-      }
-    if (debian_pkg_conflicts && *debian_pkg_conflicts)
-      {
+    }
+    if (debian_pkg_conflicts && *debian_pkg_conflicts) {
       out << "Conflicts: " << debian_pkg_conflicts << "\n";
-      }
-    if (debian_pkg_provides && *debian_pkg_provides)
-      {
+    }
+    if (debian_pkg_provides && *debian_pkg_provides) {
       out << "Provides: " << debian_pkg_provides << "\n";
-      }
-    if (debian_pkg_replaces && *debian_pkg_replaces)
-      {
+    }
+    if (debian_pkg_replaces && *debian_pkg_replaces) {
       out << "Replaces: " << debian_pkg_replaces << "\n";
-      }
+    }
     unsigned long totalSize = 0;
     {
       std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
       dirName += '/';
       for (std::vector<std::string>::const_iterator fileIt =
-           packageFiles.begin();
-           fileIt != packageFiles.end(); ++ fileIt )
-        {
+             packageFiles.begin();
+           fileIt != packageFiles.end(); ++fileIt) {
         totalSize += cmSystemTools::FileLength(*fileIt);
-        }
+      }
     }
     out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
     out << "Maintainer: " << maintainer << "\n";
     out << "Description: " << desc << "\n";
     out << std::endl;
-    }
+  }
 
-  const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
+  const std::string shlibsfilename = strGenWDIR + "/shlibs";
+
+  const char* debian_pkg_shlibs =
+    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
+  const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
+    debian_pkg_shlibs && *debian_pkg_shlibs;
+  if (gen_shibs) {
+    cmGeneratedFileStream out(shlibsfilename.c_str());
+    out << debian_pkg_shlibs;
+    out << std::endl;
+  }
+
+  const std::string postinst = strGenWDIR + "/postinst";
+  const std::string postrm = strGenWDIR + "/postrm";
+  if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
+    cmGeneratedFileStream out(postinst.c_str());
+    out << "#!/bin/sh\n\n"
+           "set -e\n\n"
+           "if [ \"$1\" = \"configure\" ]; then\n"
+           "\tldconfig\n"
+           "fi\n";
+  }
+  if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
+    cmGeneratedFileStream out(postrm.c_str());
+    out << "#!/bin/sh\n\n"
+           "set -e\n\n"
+           "if [ \"$1\" = \"remove\" ]; then\n"
+           "\tldconfig\n"
+           "fi\n";
+  }
 
   cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
   const char* debian_compression_type =
-      this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
-  if(!debian_compression_type)
-    {
+    this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
+  if (!debian_compression_type) {
     debian_compression_type = "gzip";
-    }
+  }
 
   std::string compression_suffix;
-  if(!strcmp(debian_compression_type, "lzma")) {
-      compression_suffix = ".lzma";
-      tar_compression_type = cmArchiveWrite::CompressLZMA;
-  } else if(!strcmp(debian_compression_type, "xz")) {
-      compression_suffix = ".xz";
-      tar_compression_type = cmArchiveWrite::CompressXZ;
-  } else if(!strcmp(debian_compression_type, "bzip2")) {
-      compression_suffix = ".bz2";
-      tar_compression_type = cmArchiveWrite::CompressBZip2;
-  } else if(!strcmp(debian_compression_type, "gzip")) {
-      compression_suffix = ".gz";
-      tar_compression_type = cmArchiveWrite::CompressGZip;
-  } else if(!strcmp(debian_compression_type, "none")) {
-      compression_suffix = "";
-      tar_compression_type = cmArchiveWrite::CompressNone;
+  if (!strcmp(debian_compression_type, "lzma")) {
+    compression_suffix = ".lzma";
+    tar_compression_type = cmArchiveWrite::CompressLZMA;
+  } else if (!strcmp(debian_compression_type, "xz")) {
+    compression_suffix = ".xz";
+    tar_compression_type = cmArchiveWrite::CompressXZ;
+  } else if (!strcmp(debian_compression_type, "bzip2")) {
+    compression_suffix = ".bz2";
+    tar_compression_type = cmArchiveWrite::CompressBZip2;
+  } else if (!strcmp(debian_compression_type, "gzip")) {
+    compression_suffix = ".gz";
+    tar_compression_type = cmArchiveWrite::CompressGZip;
+  } else if (!strcmp(debian_compression_type, "none")) {
+    compression_suffix = "";
+    tar_compression_type = cmArchiveWrite::CompressNone;
   } else {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-                    "Error unrecognized compression type: "
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Error unrecognized compression type: "
                     << debian_compression_type << std::endl);
   }
 
-
-  std::string filename_data_tar = strGenWDIR
-      + "/data.tar" + compression_suffix;
+  std::string filename_data_tar =
+    strGenWDIR + "/data.tar" + compression_suffix;
 
   // atomic file generation for data.tar
   {
     cmGeneratedFileStream fileStream_data_tar;
     fileStream_data_tar.Open(filename_data_tar.c_str(), false, true);
-    if(!fileStream_data_tar)
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Error opening the file \"" << filename_data_tar << "\" for writing"
-          << std::endl);
+    if (!fileStream_data_tar) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
+                      << filename_data_tar << "\" for writing" << std::endl);
       return 0;
-      }
+    }
     cmArchiveWrite data_tar(fileStream_data_tar, tar_compression_type, "paxr");
 
     // uid/gid should be the one of the root user, and this root user has
@@ -471,81 +448,69 @@ int cmCPackDebGenerator::createDeb()
     // give /usr and /opt
     size_t topLevelLength = strGenWDIR.length();
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \""
-            << strGenWDIR
-            << "\", length = " << topLevelLength
-            << std::endl);
+                    << strGenWDIR << "\", length = " << topLevelLength
+                    << std::endl);
     std::set<std::string> orderedFiles;
 
     // we have to reconstruct the parent folders as well
 
     for (std::vector<std::string>::const_iterator fileIt =
-         packageFiles.begin();
-         fileIt != packageFiles.end(); ++ fileIt )
-      {
+           packageFiles.begin();
+         fileIt != packageFiles.end(); ++fileIt) {
       std::string currentPath = *fileIt;
-      while(currentPath != strGenWDIR)
-        {
+      while (currentPath != strGenWDIR) {
         // the last one IS strGenWDIR, but we do not want this one:
         // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
         // should not add XXX/application
         orderedFiles.insert(currentPath);
         currentPath = cmSystemTools::CollapseCombinedPath(currentPath, "..");
-        }
       }
+    }
 
-
-    for (std::set<std::string>::const_iterator fileIt =
-         orderedFiles.begin();
-         fileIt != orderedFiles.end(); ++ fileIt )
-      {
+    for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin();
+         fileIt != orderedFiles.end(); ++fileIt) {
       cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\""
-                    << std::endl);
-      std::string::size_type slashPos = fileIt->find('/', topLevelLength+1);
-      std::string relativeDir = fileIt->substr(topLevelLength,
-                                               slashPos - topLevelLength);
-      cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir
-                    << "\"" << std::endl);
+                                                        << std::endl);
+      std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1);
+      std::string relativeDir =
+        fileIt->substr(topLevelLength, slashPos - topLevelLength);
+      cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
+                      << relativeDir << "\"" << std::endl);
 
       // do not recurse because the loop will do it
-      if(!data_tar.Add(*fileIt, topLevelLength, ".", false))
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-                      "Problem adding file to tar:" << std::endl
-                      << "#top level directory: "
-                      << strGenWDIR << std::endl
-                      << "#file: " << *fileIt << std::endl
-                      << "#error:" << data_tar.GetError() << std::endl);
+      if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
+                        << std::endl
+                        << "#top level directory: " << strGenWDIR << std::endl
+                        << "#file: " << *fileIt << std::endl
+                        << "#error:" << data_tar.GetError() << std::endl);
         return 0;
-        }
       }
+    }
   } // scope for file generation
 
-
   std::string md5filename = strGenWDIR + "/md5sums";
   {
     // the scope is needed for cmGeneratedFileStream
     cmGeneratedFileStream out(md5filename.c_str());
 
     std::string topLevelWithTrailingSlash =
-        this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+      this->GetOption("CPACK_TEMPORARY_DIRECTORY");
     topLevelWithTrailingSlash += '/';
     for (std::vector<std::string>::const_iterator fileIt =
            packageFiles.begin();
-         fileIt != packageFiles.end(); ++ fileIt )
-      {
+         fileIt != packageFiles.end(); ++fileIt) {
       // hash only regular files
-      if(   cmSystemTools::FileIsDirectory(*fileIt)
-         || cmSystemTools::FileIsSymlink(*fileIt))
-        {
+      if (cmSystemTools::FileIsDirectory(*fileIt) ||
+          cmSystemTools::FileIsSymlink(*fileIt)) {
         continue;
-        }
+      }
 
       char md5sum[33];
-      if(!cmSystemTools::ComputeFileMD5(*fileIt, md5sum))
-        {
+      if (!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
-                      << *fileIt << std::endl);
-        }
+                        << *fileIt << std::endl);
+      }
 
       md5sum[32] = 0;
 
@@ -554,31 +519,27 @@ int cmCPackDebGenerator::createDeb()
       // debian md5sums entries are like this:
       // 014f3604694729f3bf19263bac599765  usr/bin/ccmake
       // thus strip the full path (with the trailing slash)
-      cmSystemTools::ReplaceString(output,
-                                   topLevelWithTrailingSlash.c_str(), "");
+      cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
+                                   "");
       out << output;
-      }
+    }
     // each line contains a eol.
     // Do not end the md5sum file with yet another (invalid)
   }
 
-
-
   std::string filename_control_tar = strGenWDIR + "/control.tar.gz";
   // atomic file generation for control.tar
   {
     cmGeneratedFileStream fileStream_control_tar;
     fileStream_control_tar.Open(filename_control_tar.c_str(), false, true);
-    if(!fileStream_control_tar)
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Error opening the file \"" << filename_control_tar
-          << "\" for writing" << std::endl);
+    if (!fileStream_control_tar) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
+                      << filename_control_tar << "\" for writing"
+                      << std::endl);
       return 0;
-      }
+    }
     cmArchiveWrite control_tar(fileStream_control_tar,
-                               cmArchiveWrite::CompressGZip,
-                               "paxr");
+                               cmArchiveWrite::CompressGZip, "paxr");
 
     // sets permissions and uid/gid for the files
     control_tar.SetUIDAndGID(0u, 0u);
@@ -599,65 +560,96 @@ int cmCPackDebGenerator::createDeb()
     control_tar.SetPermissions(permission644);
 
     // adds control and md5sums
-    if(   !control_tar.Add(md5filename, strGenWDIR.length(), ".")
-       || !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), "."))
-      {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-            "Error adding file to tar:" << std::endl
-            << "#top level directory: "
-               << strGenWDIR << std::endl
-            << "#file: \"control\" or \"md5sums\"" << std::endl
-            << "#error:" << control_tar.GetError() << std::endl);
+    if (!control_tar.Add(md5filename, strGenWDIR.length(), ".") ||
+        !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+                      << std::endl
+                      << "#top level directory: " << strGenWDIR << std::endl
+                      << "#file: \"control\" or \"md5sums\"" << std::endl
+                      << "#error:" << control_tar.GetError() << std::endl);
+      return 0;
+    }
+
+    // adds generated shlibs file
+    if (gen_shibs) {
+      if (!control_tar.Add(shlibsfilename, strGenWDIR.length(), ".")) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+                        << std::endl
+                        << "#top level directory: " << strGenWDIR << std::endl
+                        << "#file: \"shlibs\"" << std::endl
+                        << "#error:" << control_tar.GetError() << std::endl);
+        return 0;
+      }
+    }
+
+    // adds LDCONFIG related files
+    if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
+      control_tar.SetPermissions(permission755);
+      if (!control_tar.Add(postinst, strGenWDIR.length(), ".")) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+                        << std::endl
+                        << "#top level directory: " << strGenWDIR << std::endl
+                        << "#file: \"postinst\"" << std::endl
+                        << "#error:" << control_tar.GetError() << std::endl);
+        return 0;
+      }
+      control_tar.SetPermissions(permission644);
+    }
+
+    if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
+      control_tar.SetPermissions(permission755);
+      if (!control_tar.Add(postrm, strGenWDIR.length(), ".")) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
+                        << std::endl
+                        << "#top level directory: " << strGenWDIR << std::endl
+                        << "#file: \"postinst\"" << std::endl
+                        << "#error:" << control_tar.GetError() << std::endl);
         return 0;
       }
+      control_tar.SetPermissions(permission644);
+    }
 
     // for the other files, we use
     // -either the original permission on the files
     // -either a permission strictly defined by the Debian policies
     const char* controlExtra =
       this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
-    if( controlExtra )
-      {
+    if (controlExtra) {
       // permissions are now controlled by the original file permissions
 
       const bool permissionStrictPolicy =
         this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION");
 
-      static const char* strictFiles[] = {
-        "config", "postinst", "postrm", "preinst", "prerm"
-        };
+      static const char* strictFiles[] = { "config", "postinst", "postrm",
+                                           "preinst", "prerm" };
       std::set<std::string> setStrictFiles(
         strictFiles,
-        strictFiles + sizeof(strictFiles)/sizeof(strictFiles[0]));
+        strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
 
       // default
       control_tar.ClearPermissions();
 
       std::vector<std::string> controlExtraList;
       cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
-      for(std::vector<std::string>::iterator i = controlExtraList.begin();
-          i != controlExtraList.end(); ++i)
-        {
-        std::string filenamename =
-          cmsys::SystemTools::GetFilenameName(*i);
+      for (std::vector<std::string>::iterator i = controlExtraList.begin();
+           i != controlExtraList.end(); ++i) {
+        std::string filenamename = cmsys::SystemTools::GetFilenameName(*i);
         std::string localcopy = strGenWDIR + "/" + filenamename;
 
-        if(permissionStrictPolicy)
-          {
-          control_tar.SetPermissions(setStrictFiles.count(filenamename) ?
-            permission755 : permission644);
-          }
+        if (permissionStrictPolicy) {
+          control_tar.SetPermissions(setStrictFiles.count(filenamename)
+                                       ? permission755
+                                       : permission644);
+        }
 
         // if we can copy the file, it means it does exist, let's add it:
-        if( cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy) )
-          {
+        if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) {
           control_tar.Add(localcopy, strGenWDIR.length(), ".");
-          }
         }
       }
+    }
   }
 
-
   // 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.
@@ -668,34 +660,31 @@ int cmCPackDebGenerator::createDeb()
   arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
   std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   outputFileName += "/";
-  outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME");
+  outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
   int res = ar_append(outputFileName.c_str(), arFiles);
-  if ( res!=0 )
-    {
-    std::string tmpFile = this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
+  if (res != 0) {
+    std::string tmpFile =
+      this->GetOption("GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
     tmpFile += "/Deb.log";
     cmGeneratedFileStream ofs(tmpFile.c_str());
     ofs << "# Problem creating archive using: " << res << std::endl;
     return 0;
-    }
+  }
   return 1;
 }
 
 bool cmCPackDebGenerator::SupportsComponentInstallation() const
-  {
-  if (IsOn("CPACK_DEB_COMPONENT_INSTALL"))
-    {
-      return true;
-    }
-  else
-    {
-      return false;
-    }
+{
+  if (IsOn("CPACK_DEB_COMPONENT_INSTALL")) {
+    return true;
+  } else {
+    return false;
   }
+}
 
 std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
-    const std::string& componentName)
-  {
+  const std::string& componentName)
+{
   if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
     return componentName;
   }
@@ -705,18 +694,14 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
   }
   // We have to find the name of the COMPONENT GROUP
   // the current COMPONENT belongs to.
-  std::string groupVar = "CPACK_COMPONENT_" +
-        cmSystemTools::UpperCase(componentName) + "_GROUP";
-    if (NULL != GetOption(groupVar))
-      {
-      return std::string(GetOption(groupVar));
-      }
-    else
-      {
-      return componentName;
-      }
+  std::string groupVar =
+    "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
+  if (NULL != GetOption(groupVar)) {
+    return std::string(GetOption(groupVar));
+  } else {
+    return componentName;
   }
-
+}
 
 // The following code is taken from OpenBSD ar:
 // http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/
@@ -760,64 +745,68 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
  */
 
 #include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h>
 
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 
-#define ARMAG           "!<arch>\n"        /* ar "magic number" */
-#define SARMAG          8                  /* strlen(ARMAG); */
+#define ARMAG "!<arch>\n" /* ar "magic number" */
+#define SARMAG 8          /* strlen(ARMAG); */
 
-#define AR_EFMT1        "#1/"              /* extended format #1 */
-#define ARFMAG          "`\n"
+#define AR_EFMT1 "#1/" /* extended format #1 */
+#define ARFMAG "`\n"
 
 /* Header format strings. */
-#define HDR1            "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
-#define HDR2             "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
-
-struct ar_hdr {
-  char ar_name[16];                        /* name */
-  char ar_date[12];                        /* modification time */
-  char ar_uid[6];                          /* user id */
-  char ar_gid[6];                          /* group id */
-  char ar_mode[8];                         /* octal file permissions */
-  char ar_size[10];                        /* size in bytes */
-  char ar_fmag[2];                         /* consistency check */
+#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
+#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
+
+struct ar_hdr
+{
+  char ar_name[16]; /* name */
+  char ar_date[12]; /* modification time */
+  char ar_uid[6];   /* user id */
+  char ar_gid[6];   /* group id */
+  char ar_mode[8];  /* octal file permissions */
+  char ar_size[10]; /* size in bytes */
+  char ar_fmag[2];  /* consistency check */
 };
 
 /* Set up file copy. */
-#define SETCF(from, fromname, to, toname, pad) { \
-        cf.rFile = from; \
-        cf.rname = fromname; \
-        cf.wFile = to; \
-        cf.wname = toname; \
-        cf.flags = pad; \
-}
+#define SETCF(from, fromname, to, toname, pad)                                \
+  {                                                                           \
+    cf.rFile = from;                                                          \
+    cf.rname = fromname;                                                      \
+    cf.wFile = to;                                                            \
+    cf.wname = toname;                                                        \
+    cf.flags = pad;                                                           \
+  }
 
 /* File copy structure. */
-typedef struct {
-        FILE* rFile;                       /* read file descriptor */
-        const char *rname;                 /* read name */
-        FILE* wFile;                       /* write file descriptor */
-        const char *wname;                 /* write name */
-#define NOPAD        0x00                  /* don't pad */
-#define WPAD        0x02                   /* pad on writes */
-        unsigned int flags;                       /* pad flags */
+typedef struct
+{
+  FILE* rFile;        /* read file descriptor */
+  const char* rname;  /* read name */
+  FILE* wFile;        /* write file descriptor */
+  const char* wname;  /* write name */
+#define NOPAD 0x00    /* don't pad */
+#define WPAD 0x02     /* pad on writes */
+  unsigned int flags; /* pad flags */
 } CF;
 
 /* misc.c */
 
-static const char * ar_rname(const char *path)
+static const char* ar_rname(const char* path)
 {
-  const char *ind = strrchr(path, '/');
-  return (ind ) ? ind + 1 : path;
+  const char* ind = strrchr(path, '/');
+  return (ind) ? ind + 1 : path;
 }
 
 /* archive.c */
 
 typedef struct ar_hdr HDR;
-static char ar_hb[sizeof(HDR) + 1];        /* real header */
+static char ar_hb[sizeof(HDR) + 1]; /* real header */
 
 static size_t ar_already_written;
 
@@ -834,12 +823,12 @@ static size_t ar_already_written;
  *      because 16-bit word addressed copies were faster?)  Anyhow, it should
  *      have been ripped out long ago.
  */
-static int copy_ar(CF *cfp, off_t size)
+static int copy_ar(CF* cfp, off_t size)
 {
   static char pad = '\n';
   off_t sz = size;
   size_t nr, nw;
-  char buf[8*1024];
+  char buf[8 * 1024];
 
   if (sz == 0)
     return 0;
@@ -847,60 +836,59 @@ static int copy_ar(CF *cfp, off_t size)
   FILE* from = cfp->rFile;
   FILE* to = cfp->wFile;
   while (sz &&
-        (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
-                    ? static_cast<size_t>(sz) : sizeof(buf), from ))
-               > 0) {
+         (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
+                       ? static_cast<size_t>(sz)
+                       : sizeof(buf),
+                     from)) > 0) {
     sz -= nr;
     for (size_t off = 0; off < nr; nr -= off, off += nw)
       if ((nw = fwrite(buf + off, 1, nr, to)) < nr)
         return -1;
-    }
+  }
   if (sz)
     return -2;
 
-  if (cfp->flags & WPAD && (size + ar_already_written) & 1
-      && fwrite(&pad, 1, 1, to) != 1)
+  if (cfp->flags & WPAD && (size + ar_already_written) & 1 &&
+      fwrite(&pad, 1, 1, to) != 1)
     return -4;
 
   return 0;
 }
 
 /* put_arobj --  Write an archive member to a file. */
-static int put_arobj(CF *cfp, struct stat *sb)
+static int put_arobj(CF* cfp, struct stat* sb)
 {
   int result = 0;
-  struct ar_hdr *hdr;
+  struct ar_hdr* hdr;
 
- /* If passed an sb structure, reading a file from disk.  Get stat(2)
-  * information, build a name and construct a header.  (Files are named
-  * by their last component in the archive.) */
+  /* If passed an sb structure, reading a file from disk.  Get stat(2)
+   * information, build a name and construct a header.  (Files are named
+   * by their last component in the archive.) */
   const char* name = ar_rname(cfp->rname);
   (void)stat(cfp->rname, sb);
 
- /* If not truncating names and the name is too long or contains
-  * a space, use extended format 1.   */
+  /* If not truncating names and the name is too long or contains
+   * a space, use extended format 1.   */
   size_t lname = strlen(name);
   uid_t uid = sb->st_uid;
   gid_t gid = sb->st_gid;
   if (uid > USHRT_MAX) {
     uid = USHRT_MAX;
-    }
+  }
   if (gid > USHRT_MAX) {
     gid = USHRT_MAX;
-    }
+  }
   if (lname > sizeof(hdr->ar_name) || strchr(name, ' '))
-    (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname,
-                  (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid,
-                  (unsigned)sb->st_mode, (long long)sb->st_size + lname,
+    (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime,
+                  (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode,
+                  (long long)sb->st_size + lname, ARFMAG);
+  else {
+    lname = 0;
+    (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid,
+                  (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size,
                   ARFMAG);
-    else {
-      lname = 0;
-      (void)sprintf(ar_hb, HDR2, name,
-                    (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid,
-                    (unsigned)sb->st_mode, (long long)sb->st_size,
-                    ARFMAG);
-      }
-    off_t size = sb->st_size;
+  }
+  off_t size = sb->st_size;
 
   if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR))
     return -1;
@@ -909,7 +897,7 @@ static int put_arobj(CF *cfp, struct stat *sb)
     if (fwrite(name, 1, lname, cfp->wFile) != lname)
       return -2;
     ar_already_written = lname;
-    }
+  }
   result = copy_ar(cfp, size);
   ar_already_written = 0;
   return result;
@@ -921,42 +909,41 @@ static int put_arobj(CF *cfp, struct stat *sb)
  *      Append files to the archive - modifies original archive or creates
  *      a new archive if named archive does not exist.
  */
-static int ar_append(const char* archive,const std::vector<std::string>& files)
+static int ar_append(const char* archive,
+                     const std::vector<std::string>& files)
 {
   int eval = 0;
   FILE* aFile = cmSystemTools::Fopen(archive, "wb+");
-  if (aFile!=NULL) {
+  if (aFile != NULL) {
     fwrite(ARMAG, SARMAG, 1, aFile);
     if (fseek(aFile, 0, SEEK_END) != -1) {
       CF cf;
       struct stat sb;
       /* Read from disk, write to an archive; pad on write. */
       SETCF(NULL, 0, aFile, archive, WPAD);
-      for(std::vector<std::string>::const_iterator fileIt = files.begin();
-          fileIt!=files.end(); ++fileIt) {
+      for (std::vector<std::string>::const_iterator fileIt = files.begin();
+           fileIt != files.end(); ++fileIt) {
         const char* filename = fileIt->c_str();
         FILE* file = cmSystemTools::Fopen(filename, "rb");
         if (file == NULL) {
           eval = -1;
           continue;
-          }
+        }
         cf.rFile = file;
         cf.rname = filename;
         int result = put_arobj(&cf, &sb);
         (void)fclose(file);
-        if (result!=0) {
+        if (result != 0) {
           eval = -2;
           break;
-          }
         }
       }
-      else {
-        eval = -3;
-      }
-    fclose(aFile);
+    } else {
+      eval = -3;
     }
-  else {
+    fclose(aFile);
+  } else {
     eval = -4;
-    }
+  }
   return eval;
 }
diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h
index d678cfa..ff34ca5 100644
--- a/Source/CPack/cmCPackDebGenerator.h
+++ b/Source/CPack/cmCPackDebGenerator.h
@@ -13,7 +13,6 @@
 #ifndef cmCPackDebGenerator_h
 #define cmCPackDebGenerator_h
 
-
 #include "cmCPackGenerator.h"
 
 /** \class cmCPackDebGenerator
@@ -32,25 +31,26 @@ public:
   virtual ~cmCPackDebGenerator();
 
   static bool CanGenerate()
-    {
+  {
 #ifdef __APPLE__
     // on MacOS enable CPackDeb iff dpkg is found
     std::vector<std::string> locations;
     locations.push_back("/sw/bin");        // Fink
     locations.push_back("/opt/local/bin"); // MacPorts
-    return cmSystemTools::FindProgram("dpkg",locations) != "" ? true : false;
+    return cmSystemTools::FindProgram("dpkg", locations) != "" ? true : false;
 #else
     // legacy behavior on other systems
     return true;
 #endif
-    }
+  }
 
 protected:
   virtual int InitializeInternal();
   /**
    * This method factors out the work done in component packaging case.
    */
-  int PackageOnePack(std::string initialToplevel, std::string packageName);
+  int PackageOnePack(std::string const& initialToplevel,
+                     std::string const& packageName);
   /**
    * The method used to package files when component
    * install is used. This will create one
@@ -61,17 +61,16 @@ protected:
    * Special case of component install where all
    * components will be put in a single installer.
    */
-  int PackageComponentsAllInOne();
+  int PackageComponentsAllInOne(const std::string& compInstDirName);
   virtual int PackageFiles();
   virtual const char* GetOutputExtension() { return ".deb"; }
   virtual bool SupportsComponentInstallation() const;
   virtual std::string GetComponentInstallDirNameSuffix(
-      const std::string& componentName);
+    const std::string& componentName);
 
 private:
   int createDeb();
   std::vector<std::string> packageFiles;
-
 };
 
 #endif
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index d6de77d..f4379c1 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -11,12 +11,13 @@
 ============================================================================*/
 
 #include "cmCPackDragNDropGenerator.h"
+
 #include "cmCPackLog.h"
-#include "cmSystemTools.h"
 #include "cmGeneratedFileStream.h"
+#include "cmSystemTools.h"
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
 
 #include <iomanip>
 
@@ -30,37 +31,36 @@
 #endif
 
 static const char* SLAHeader =
-"data 'LPic' (5000) {\n"
-"    $\"0002 0011 0003 0001 0000 0000 0002 0000\"\n"
-"    $\"0008 0003 0000 0001 0004 0000 0004 0005\"\n"
-"    $\"0000 000E 0006 0001 0005 0007 0000 0007\"\n"
-"    $\"0008 0000 0047 0009 0000 0034 000A 0001\"\n"
-"    $\"0035 000B 0001 0020 000C 0000 0011 000D\"\n"
-"    $\"0000 005B 0004 0000 0033 000F 0001 000C\"\n"
-"    $\"0010 0000 000B 000E 0000\"\n"
-"};\n"
-"\n";
+  "data 'LPic' (5000) {\n"
+  "    $\"0002 0011 0003 0001 0000 0000 0002 0000\"\n"
+  "    $\"0008 0003 0000 0001 0004 0000 0004 0005\"\n"
+  "    $\"0000 000E 0006 0001 0005 0007 0000 0007\"\n"
+  "    $\"0008 0000 0047 0009 0000 0034 000A 0001\"\n"
+  "    $\"0035 000B 0001 0020 000C 0000 0011 000D\"\n"
+  "    $\"0000 005B 0004 0000 0033 000F 0001 000C\"\n"
+  "    $\"0010 0000 000B 000E 0000\"\n"
+  "};\n"
+  "\n";
 
 static const char* SLASTREnglish =
-"resource 'STR#' (5002, \"English\") {\n"
-"    {\n"
-"        \"English\",\n"
-"        \"Agree\",\n"
-"        \"Disagree\",\n"
-"        \"Print\",\n"
-"        \"Save...\",\n"
-"        \"You agree to the License Agreement terms when you click \"\n"
-"        \"the \\\"Agree\\\" button.\",\n"
-"        \"Software License Agreement\",\n"
-"        \"This text cannot be saved.  This disk may be full or locked, "
-"or the \"\n"
-"        \"file may be locked.\",\n"
-"        \"Unable to print.  Make sure you have selected a printer.\"\n"
-"    }\n"
-"};\n"
-"\n";
-
-//----------------------------------------------------------------------
+  "resource 'STR#' (5002, \"English\") {\n"
+  "    {\n"
+  "        \"English\",\n"
+  "        \"Agree\",\n"
+  "        \"Disagree\",\n"
+  "        \"Print\",\n"
+  "        \"Save...\",\n"
+  "        \"You agree to the License Agreement terms when you click \"\n"
+  "        \"the \\\"Agree\\\" button.\",\n"
+  "        \"Software License Agreement\",\n"
+  "        \"This text cannot be saved.  This disk may be full or locked, "
+  "or the \"\n"
+  "        \"file may be locked.\",\n"
+  "        \"Unable to print.  Make sure you have selected a printer.\"\n"
+  "    }\n"
+  "};\n"
+  "\n";
+
 cmCPackDragNDropGenerator::cmCPackDragNDropGenerator()
   : singleLicense(false)
 {
@@ -68,12 +68,10 @@ cmCPackDragNDropGenerator::cmCPackDragNDropGenerator()
   this->componentPackageMethod = ONE_PACKAGE;
 }
 
-//----------------------------------------------------------------------
 cmCPackDragNDropGenerator::~cmCPackDragNDropGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackDragNDropGenerator::InitializeInternal()
 {
   // Starting with Xcode 4.3, look in "/Applications/Xcode.app" first:
@@ -82,153 +80,125 @@ int cmCPackDragNDropGenerator::InitializeInternal()
   paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools");
   paths.push_back("/Developer/Tools");
 
-  const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil",
-    std::vector<std::string>(), false);
-  if(hdiutil_path.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Cannot locate hdiutil command"
-      << std::endl);
+  const std::string hdiutil_path =
+    cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
+  if (hdiutil_path.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command"
+                    << std::endl);
     return 0;
-    }
+  }
   this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
 
-  const std::string setfile_path = cmSystemTools::FindProgram("SetFile",
-    paths, false);
-  if(setfile_path.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Cannot locate SetFile command"
-      << std::endl);
+  const std::string setfile_path =
+    cmSystemTools::FindProgram("SetFile", paths, false);
+  if (setfile_path.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command"
+                    << std::endl);
     return 0;
-    }
+  }
   this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
 
-  const std::string rez_path = cmSystemTools::FindProgram("Rez",
-    paths, false);
-  if(rez_path.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Cannot locate Rez command"
-      << std::endl);
+  const std::string rez_path = cmSystemTools::FindProgram("Rez", paths, false);
+  if (rez_path.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate Rez command"
+                    << std::endl);
     return 0;
-    }
+  }
   this->SetOptionIfNotSet("CPACK_COMMAND_REZ", rez_path.c_str());
 
-  if(this->IsSet("CPACK_DMG_SLA_DIR"))
-    {
+  if (this->IsSet("CPACK_DMG_SLA_DIR")) {
     slaDirectory = this->GetOption("CPACK_DMG_SLA_DIR");
-    if(!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE"))
-      {
+    if (!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE")) {
       std::string license_file =
         this->GetOption("CPACK_RESOURCE_FILE_LICENSE");
-      if(!license_file.empty() &&
-         (license_file.find("CPack.GenericLicense.txt") == std::string::npos))
-        {
-        cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+      if (!license_file.empty() &&
+          (license_file.find("CPack.GenericLicense.txt") ==
+           std::string::npos)) {
+        cmCPackLogger(
+          cmCPackLog::LOG_OUTPUT,
           "Both CPACK_DMG_SLA_DIR and CPACK_RESOURCE_FILE_LICENSE specified, "
           "using CPACK_RESOURCE_FILE_LICENSE as a license for all languages."
-          << std::endl);
+            << std::endl);
         singleLicense = true;
-        }
       }
-    if(!this->IsSet("CPACK_DMG_SLA_LANGUAGES"))
-      {
+    }
+    if (!this->IsSet("CPACK_DMG_SLA_LANGUAGES")) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "CPACK_DMG_SLA_DIR set but no languages defined "
-        "(set CPACK_DMG_SLA_LANGUAGES)"
-        << std::endl);
+                    "CPACK_DMG_SLA_DIR set but no languages defined "
+                    "(set CPACK_DMG_SLA_LANGUAGES)"
+                      << std::endl);
       return 0;
-      }
-    if(!cmSystemTools::FileExists(slaDirectory, false))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "CPACK_DMG_SLA_DIR does not exist"
-        << std::endl);
+    }
+    if (!cmSystemTools::FileExists(slaDirectory, false)) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_DMG_SLA_DIR does not exist"
+                      << std::endl);
       return 0;
-      }
+    }
 
     std::vector<std::string> languages;
     cmSystemTools::ExpandListArgument(
       this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages);
-    if(languages.empty())
-      {
+    if (languages.empty()) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "CPACK_DMG_SLA_LANGUAGES set but empty"
-        << std::endl);
+                    "CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl);
       return 0;
-      }
-    for(size_t i = 0; i < languages.size(); ++i)
-      {
+    }
+    for (size_t i = 0; i < languages.size(); ++i) {
       std::string license = slaDirectory + "/" + languages[i] + ".license.txt";
-      if (!singleLicense && !cmSystemTools::FileExists(license))
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Missing license file " << languages[i] << ".license.txt"
-          << std::endl);
+      if (!singleLicense && !cmSystemTools::FileExists(license)) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file "
+                        << languages[i] << ".license.txt" << std::endl);
         return 0;
-        }
+      }
       std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt";
-      if (!cmSystemTools::FileExists(menu))
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Missing menu file " << languages[i] << ".menu.txt"
-          << std::endl);
+      if (!cmSystemTools::FileExists(menu)) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file "
+                        << languages[i] << ".menu.txt" << std::endl);
         return 0;
-        }
       }
     }
+  }
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 const char* cmCPackDragNDropGenerator::GetOutputExtension()
 {
   return ".dmg";
 }
 
-//----------------------------------------------------------------------
 int cmCPackDragNDropGenerator::PackageFiles()
 {
   // gather which directories to make dmg files for
   // multiple directories occur if packaging components or groups separately
 
   // monolith
-  if(this->Components.empty())
-    {
+  if (this->Components.empty()) {
     return this->CreateDMG(toplevel, packageFileNames[0]);
-    }
+  }
 
   // component install
   std::vector<std::string> package_files;
 
   std::map<std::string, cmCPackComponent>::iterator compIt;
-  for (compIt=this->Components.begin();
-       compIt!=this->Components.end(); ++compIt )
-    {
+  for (compIt = this->Components.begin(); compIt != this->Components.end();
+       ++compIt) {
     std::string name = GetComponentInstallDirNameSuffix(compIt->first);
     package_files.push_back(name);
-    }
+  }
   std::sort(package_files.begin(), package_files.end());
-  package_files.erase(std::unique(package_files.begin(),
-                      package_files.end()),
+  package_files.erase(std::unique(package_files.begin(), package_files.end()),
                       package_files.end());
 
-
   // loop to create dmg files
   packageFileNames.clear();
-  for(size_t i=0; i<package_files.size(); i++)
-    {
+  for (size_t i = 0; i < package_files.size(); i++) {
     std::string full_package_name = std::string(toplevel) + std::string("/");
-    if(package_files[i] == "ALL_IN_ONE")
-      {
+    if (package_files[i] == "ALL_IN_ONE") {
       full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
-      }
-    else
-      {
+    } else {
       full_package_name += package_files[i];
-      }
+    }
     full_package_name += std::string(GetOutputExtension());
     packageFileNames.push_back(full_package_name);
 
@@ -236,135 +206,119 @@ int cmCPackDragNDropGenerator::PackageFiles()
     src_dir += "/";
     src_dir += package_files[i];
 
-    if(0 == this->CreateDMG(src_dir, full_package_name))
-      {
+    if (0 == this->CreateDMG(src_dir, full_package_name)) {
       return 0;
-      }
     }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
-  std::ostringstream& target)
+                                         std::ostringstream& target)
 {
-  if(!cmSystemTools::CopyFileIfDifferent(
-    source.str().c_str(),
-    target.str().c_str()))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Error copying "
-      << source.str()
-      << " to "
-      << target.str()
-      << std::endl);
+  if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
+                                          target.str().c_str())) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error copying "
+                    << source.str() << " to " << target.str() << std::endl);
 
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
                                                 size_t size)
 {
-  cmsys::ofstream fout(target.str().c_str(),
-                       std::ios::out | std::ios::binary);
-  if(!fout)
-    {
+  cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
+  if (!fout) {
     return false;
-    }
-  else
-    {
+  } else {
     // Seek to desired size - 1 byte
     fout.seekp(size - 1, std::ios_base::beg);
     char byte = 0;
     // Write one byte to ensure file grows
     fout.write(&byte, 1);
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
-  std::string* output)
+                                           std::string* output)
 {
   int exit_code = 1;
 
-  bool result = cmSystemTools::RunSingleCommand(
-    command.str().c_str(),
-    output, output,
-    &exit_code,
-    0,
-    this->GeneratorVerbose,
-    0);
+  bool result =
+    cmSystemTools::RunSingleCommand(command.str().c_str(), output, output,
+                                    &exit_code, 0, this->GeneratorVerbose, 0);
 
-  if(!result || exit_code)
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Error executing: "
-      << command.str()
-      << std::endl);
+  if (!result || exit_code) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error executing: " << command.str()
+                                                             << std::endl);
 
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------
 int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
                                          const std::string& output_file)
 {
   // Get optional arguments ...
   const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON")
-    ? this->GetOption("CPACK_PACKAGE_ICON") : "";
+    ? this->GetOption("CPACK_PACKAGE_ICON")
+    : "";
 
   const std::string cpack_dmg_volume_name =
     this->GetOption("CPACK_DMG_VOLUME_NAME")
     ? this->GetOption("CPACK_DMG_VOLUME_NAME")
-        : this->GetOption("CPACK_PACKAGE_FILE_NAME");
+    : this->GetOption("CPACK_PACKAGE_FILE_NAME");
 
-  const std::string cpack_dmg_format =
-    this->GetOption("CPACK_DMG_FORMAT")
-    ? this->GetOption("CPACK_DMG_FORMAT") : "UDZO";
+  const std::string cpack_dmg_format = this->GetOption("CPACK_DMG_FORMAT")
+    ? this->GetOption("CPACK_DMG_FORMAT")
+    : "UDZO";
 
   // Get optional arguments ...
   std::string cpack_license_file =
-    this->GetOption("CPACK_RESOURCE_FILE_LICENSE") ?
-    this->GetOption("CPACK_RESOURCE_FILE_LICENSE") : "";
+    this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
+    ? this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
+    : "";
 
   const std::string cpack_dmg_background_image =
     this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
-    ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE") : "";
+    ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
+    : "";
 
-  const std::string cpack_dmg_ds_store =
-    this->GetOption("CPACK_DMG_DS_STORE")
-    ? this->GetOption("CPACK_DMG_DS_STORE") : "";
+  const std::string cpack_dmg_ds_store = this->GetOption("CPACK_DMG_DS_STORE")
+    ? this->GetOption("CPACK_DMG_DS_STORE")
+    : "";
 
   const std::string cpack_dmg_languages =
     this->GetOption("CPACK_DMG_SLA_LANGUAGES")
-      ? this->GetOption("CPACK_DMG_SLA_LANGUAGES") : "";
+    ? this->GetOption("CPACK_DMG_SLA_LANGUAGES")
+    : "";
 
   const std::string cpack_dmg_ds_store_setup_script =
     this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
-    ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT") : "";
+    ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
+    : "";
+
+  const bool cpack_dmg_disable_applications_symlink =
+    this->IsOn("CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK");
 
   // only put license on dmg if is user provided
-  if(!cpack_license_file.empty() &&
-      cpack_license_file.find("CPack.GenericLicense.txt") != std::string::npos)
-    {
+  if (!cpack_license_file.empty() &&
+      cpack_license_file.find("CPack.GenericLicense.txt") !=
+        std::string::npos) {
     cpack_license_file = "";
-    }
+  }
 
   // use sla_dir if both sla_dir and license_file are set
-  if(!cpack_license_file.empty() &&
-     !slaDirectory.empty() && !singleLicense)
-    {
+  if (!cpack_license_file.empty() && !slaDirectory.empty() && !singleLicense) {
     cpack_license_file = "";
-    }
+  }
 
   // The staging directory contains everything that will end-up inside the
   // final disk image ...
@@ -372,60 +326,58 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   staging << src_dir;
 
   // Add a symlink to /Applications so users can drag-and-drop the bundle
-  // into it
-  std::ostringstream application_link;
-  application_link << staging.str() << "/Applications";
-  cmSystemTools::CreateSymlink("/Applications",
-    application_link.str().c_str());
+  // into it unless this behaviour was disabled
+  if (!cpack_dmg_disable_applications_symlink) {
+    std::ostringstream application_link;
+    application_link << staging.str() << "/Applications";
+    cmSystemTools::CreateSymlink("/Applications",
+                                 application_link.str().c_str());
+  }
 
   // Optionally add a custom volume icon ...
-  if(!cpack_package_icon.empty())
-    {
+  if (!cpack_package_icon.empty()) {
     std::ostringstream package_icon_source;
     package_icon_source << cpack_package_icon;
 
     std::ostringstream package_icon_destination;
     package_icon_destination << staging.str() << "/.VolumeIcon.icns";
 
-    if(!this->CopyFile(package_icon_source, package_icon_destination))
-      {
+    if (!this->CopyFile(package_icon_source, package_icon_destination)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error copying disk volume icon.  "
+                    "Error copying disk volume icon.  "
                     "Check the value of CPACK_PACKAGE_ICON."
-        << std::endl);
+                      << std::endl);
 
       return 0;
-      }
     }
+  }
 
   // Optionally add a custom .DS_Store file
   // (e.g. for setting background/layout) ...
-  if(!cpack_dmg_ds_store.empty())
-    {
+  if (!cpack_dmg_ds_store.empty()) {
     std::ostringstream package_settings_source;
     package_settings_source << cpack_dmg_ds_store;
 
     std::ostringstream package_settings_destination;
     package_settings_destination << staging.str() << "/.DS_Store";
 
-    if(!this->CopyFile(package_settings_source, package_settings_destination))
-      {
+    if (!this->CopyFile(package_settings_source,
+                        package_settings_destination)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error copying disk volume settings file.  "
+                    "Error copying disk volume settings file.  "
                     "Check the value of CPACK_DMG_DS_STORE."
-        << std::endl);
+                      << std::endl);
 
       return 0;
-      }
     }
+  }
 
   // Optionally add a custom background image ...
   // Make sure the background file type is the same as the custom image
   // and that the file is hidden so it doesn't show up.
-  if(!cpack_dmg_background_image.empty())
-    {
+  if (!cpack_dmg_background_image.empty()) {
     const std::string extension =
-        cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
+      cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
     std::ostringstream package_background_source;
     package_background_source << cpack_dmg_background_image;
 
@@ -433,36 +385,32 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     package_background_destination << staging.str()
                                    << "/.background/background" << extension;
 
-    if(!this->CopyFile(package_background_source,
-        package_background_destination))
-      {
+    if (!this->CopyFile(package_background_source,
+                        package_background_destination)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error copying disk volume background image.  "
+                    "Error copying disk volume background image.  "
                     "Check the value of CPACK_DMG_BACKGROUND_IMAGE."
-        << std::endl);
+                      << std::endl);
 
       return 0;
-      }
     }
+  }
 
-  bool remount_image = !cpack_package_icon.empty() ||
-                       !cpack_dmg_ds_store_setup_script.empty();
+  bool remount_image =
+    !cpack_package_icon.empty() || !cpack_dmg_ds_store_setup_script.empty();
 
   // Create 1 MB dummy padding file in staging area when we need to remount
   // image, so we have enough space for storing changes ...
-  if(remount_image)
-    {
+  if (remount_image) {
     std::ostringstream dummy_padding;
     dummy_padding << staging.str() << "/.dummy-padding-file";
-    if(!this->CreateEmptyFile(dummy_padding, 1048576))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error creating dummy padding file."
-        << std::endl);
+    if (!this->CreateEmptyFile(dummy_padding, 1048576)) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating dummy padding file."
+                      << std::endl);
 
       return 0;
-      }
     }
+  }
 
   // Create a temporary read-write disk image ...
   std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -473,22 +421,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   temp_image_command << " create";
   temp_image_command << " -ov";
   temp_image_command << " -srcfolder \"" << staging.str() << "\"";
-  temp_image_command << " -volname \""
-    << cpack_dmg_volume_name << "\"";
+  temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
   temp_image_command << " -format UDRW";
   temp_image_command << " \"" << temp_image << "\"";
 
-  if(!this->RunCommand(temp_image_command))
-    {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error generating temporary disk image."
-        << std::endl);
+  if (!this->RunCommand(temp_image_command)) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Error generating temporary disk image." << std::endl);
 
     return 0;
-    }
+  }
 
-  if(remount_image)
-    {
+  if (remount_image) {
     // Store that we have a failure so that we always unmount the image
     // before we exit.
     bool had_error = false;
@@ -499,112 +443,95 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     attach_command << " \"" << temp_image << "\"";
 
     std::string attach_output;
-    if(!this->RunCommand(attach_command, &attach_output))
-      {
+    if (!this->RunCommand(attach_command, &attach_output)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error attaching temporary disk image."
-        << std::endl);
+                    "Error attaching temporary disk image." << std::endl);
 
       return 0;
-      }
+    }
 
     cmsys::RegularExpression mountpoint_regex(".*(/Volumes/[^\n]+)\n.*");
     mountpoint_regex.find(attach_output.c_str());
-    std::ostringstream temp_mount;
-    temp_mount << mountpoint_regex.match(1);
+    std::string const temp_mount = mountpoint_regex.match(1);
 
     // Remove dummy padding file so we have enough space on RW image ...
     std::ostringstream dummy_padding;
-    dummy_padding << temp_mount.str() << "/.dummy-padding-file";
-    if(!cmSystemTools::RemoveFile(dummy_padding.str()))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error removing dummy padding file."
-        << std::endl);
+    dummy_padding << temp_mount << "/.dummy-padding-file";
+    if (!cmSystemTools::RemoveFile(dummy_padding.str())) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error removing dummy padding file."
+                      << std::endl);
 
       had_error = true;
-      }
+    }
 
     // Optionally set the custom icon flag for the image ...
-    if(!had_error && !cpack_package_icon.empty())
-      {
+    if (!had_error && !cpack_package_icon.empty()) {
       std::ostringstream setfile_command;
       setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
       setfile_command << " -a C";
-      setfile_command << " \"" << temp_mount.str() << "\"";
+      setfile_command << " \"" << temp_mount << "\"";
 
-      if(!this->RunCommand(setfile_command))
-        {
+      if (!this->RunCommand(setfile_command)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Error assigning custom icon to temporary disk image."
-          << std::endl);
+                      "Error assigning custom icon to temporary disk image."
+                        << std::endl);
 
         had_error = true;
-        }
       }
+    }
 
     // Optionally we can execute a custom apple script to generate
     // the .DS_Store for the volume folder ...
-    if(!had_error && !cpack_dmg_ds_store_setup_script.empty())
-      {
+    if (!had_error && !cpack_dmg_ds_store_setup_script.empty()) {
       std::ostringstream setup_script_command;
       setup_script_command << "osascript"
                            << " \"" << cpack_dmg_ds_store_setup_script << "\""
                            << " \"" << cpack_dmg_volume_name << "\"";
       std::string error;
-      if(!this->RunCommand(setup_script_command, &error))
-        {
+      if (!this->RunCommand(setup_script_command, &error)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Error executing custom script on disk image." << std::endl
-          << error
-          << std::endl);
+                      "Error executing custom script on disk image."
+                        << std::endl
+                        << error << std::endl);
 
         had_error = true;
-        }
       }
+    }
 
     std::ostringstream detach_command;
     detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
     detach_command << " detach";
-    detach_command << " \"" << temp_mount.str() << "\"";
+    detach_command << " \"" << temp_mount << "\"";
 
-    if(!this->RunCommand(detach_command))
-      {
+    if (!this->RunCommand(detach_command)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error detaching temporary disk image."
-        << std::endl);
+                    "Error detaching temporary disk image." << std::endl);
 
       return 0;
-      }
+    }
 
-    if(had_error)
-      {
+    if (had_error) {
       return 0;
-      }
     }
+  }
 
-  if(!cpack_license_file.empty() || !slaDirectory.empty())
-    {
+  if (!cpack_license_file.empty() || !slaDirectory.empty()) {
     // Use old hardcoded style if sla_dir is not set
     bool oldStyle = slaDirectory.empty();
     std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     sla_r += "/sla.r";
 
     std::vector<std::string> languages;
-    if(!oldStyle)
-      {
+    if (!oldStyle) {
       cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages);
-      }
+    }
 
     cmGeneratedFileStream ofs(sla_r.c_str());
     ofs << "#include <CoreServices/CoreServices.r>\n\n";
-    if(oldStyle)
-      {
+    if (oldStyle) {
       ofs << SLAHeader;
       ofs << "\n";
-      }
-    else
-      {
+    } else {
       /*
        * LPic Layout
        * (https://github.com/pypt/dmg-add-license/blob/master/main.c)
@@ -627,111 +554,92 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
       std::vector<uint16_t> header_data;
       header_data.push_back(0);
       header_data.push_back(languages.size());
-      for(size_t i = 0; i < languages.size(); ++i)
-        {
+      for (size_t i = 0; i < languages.size(); ++i) {
         CFStringRef language_cfstring = CFStringCreateWithCString(
           NULL, languages[i].c_str(), kCFStringEncodingUTF8);
         CFStringRef iso_language =
           CFLocaleCreateCanonicalLanguageIdentifierFromString(
             NULL, language_cfstring);
-        if (!iso_language)
-          {
-          cmCPackLogger(cmCPackLog::LOG_ERROR,
-            languages[i] << " is not a recognized language"
-            << std::endl);
-          }
-        char *iso_language_cstr = (char *) malloc(65);
+        if (!iso_language) {
+          cmCPackLogger(cmCPackLog::LOG_ERROR, languages[i]
+                          << " is not a recognized language" << std::endl);
+        }
+        char* iso_language_cstr = (char*)malloc(65);
         CFStringGetCString(iso_language, iso_language_cstr, 64,
                            kCFStringEncodingMacRoman);
         LangCode lang = 0;
         RegionCode region = 0;
 #ifdef HAVE_CoreServices
-        OSStatus err = LocaleStringToLangAndRegionCodes(iso_language_cstr,
-                                                        &lang, &region);
+        OSStatus err =
+          LocaleStringToLangAndRegionCodes(iso_language_cstr, &lang, &region);
         if (err != noErr)
 #endif
-          {
+        {
           cmCPackLogger(cmCPackLog::LOG_ERROR,
-            "No language/region code available for " << iso_language_cstr
-            << std::endl);
+                        "No language/region code available for "
+                          << iso_language_cstr << std::endl);
           free(iso_language_cstr);
           return 0;
-          }
+        }
 #ifdef HAVE_CoreServices
         free(iso_language_cstr);
         header_data.push_back(region);
         header_data.push_back(i);
         header_data.push_back(0);
 #endif
-        }
+      }
       ofs << "data 'LPic' (5000) {\n";
       ofs << std::hex << std::uppercase << std::setfill('0');
 
-      for(size_t i = 0; i < header_data.size(); ++i)
-        {
-        if(i % 8 == 0)
-          {
+      for (size_t i = 0; i < header_data.size(); ++i) {
+        if (i % 8 == 0) {
           ofs << "    $\"";
-          }
+        }
 
         ofs << std::setw(4) << header_data[i];
 
-        if(i % 8 == 7 || i == header_data.size() - 1)
-          {
+        if (i % 8 == 7 || i == header_data.size() - 1) {
           ofs << "\"\n";
-          }
-        else
-          {
+        } else {
           ofs << " ";
-          }
         }
+      }
       ofs << "};\n\n";
       // Reset ofs options
       ofs << std::dec << std::nouppercase << std::setfill(' ');
-      }
+    }
 
     bool have_write_license_error = false;
     std::string error;
 
-    if(oldStyle)
-      {
-      if(!this->WriteLicense(ofs, 0, "", cpack_license_file, &error))
-        {
+    if (oldStyle) {
+      if (!this->WriteLicense(ofs, 0, "", cpack_license_file, &error)) {
         have_write_license_error = true;
-        }
       }
-    else
-      {
-      for(size_t i = 0; i < languages.size() && !have_write_license_error; ++i)
-        {
-        if(singleLicense)
-          {
-          if(!this->WriteLicense(ofs, i + 5000, languages[i],
-                                 cpack_license_file, &error))
-            {
+    } else {
+      for (size_t i = 0; i < languages.size() && !have_write_license_error;
+           ++i) {
+        if (singleLicense) {
+          if (!this->WriteLicense(ofs, i + 5000, languages[i],
+                                  cpack_license_file, &error)) {
             have_write_license_error = true;
-            }
           }
-        else
-          {
-          if(!this->WriteLicense(ofs, i + 5000, languages[i], "", &error))
-            {
+        } else {
+          if (!this->WriteLicense(ofs, i + 5000, languages[i], "", &error)) {
             have_write_license_error = true;
-            }
           }
         }
       }
+    }
 
     ofs.Close();
 
-    if(have_write_license_error)
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error writing license file to SLA." << std::endl
-        << error
-        << std::endl);
+    if (have_write_license_error) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error writing license file to SLA."
+                      << std::endl
+                      << error << std::endl);
       return 0;
-      }
+    }
 
     // convert to UDCO
     std::string temp_udco = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -743,14 +651,13 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     udco_image_command << " -format UDCO";
     udco_image_command << " -ov -o \"" << temp_udco << "\"";
 
-    if(!this->RunCommand(udco_image_command, &error))
-      {
+    if (!this->RunCommand(udco_image_command, &error)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error converting to UDCO dmg for adding SLA." << std::endl
-        << error
-        << std::endl);
+                    "Error converting to UDCO dmg for adding SLA."
+                      << std::endl
+                      << error << std::endl);
       return 0;
-      }
+    }
 
     // unflatten dmg
     std::ostringstream unflatten_command;
@@ -758,35 +665,31 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     unflatten_command << " unflatten ";
     unflatten_command << "\"" << temp_udco << "\"";
 
-    if(!this->RunCommand(unflatten_command, &error))
-      {
+    if (!this->RunCommand(unflatten_command, &error)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error unflattening dmg for adding SLA." << std::endl
-        << error
-        << std::endl);
+                    "Error unflattening dmg for adding SLA." << std::endl
+                                                             << error
+                                                             << std::endl);
       return 0;
-      }
+    }
 
     // Rez the SLA
     std::ostringstream embed_sla_command;
     embed_sla_command << this->GetOption("CPACK_COMMAND_REZ");
     const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT");
-    if(sysroot && sysroot[0] != '\0')
-      {
+    if (sysroot && sysroot[0] != '\0') {
       embed_sla_command << " -isysroot \"" << sysroot << "\"";
-      }
+    }
     embed_sla_command << " \"" << sla_r << "\"";
     embed_sla_command << " -a -o ";
     embed_sla_command << "\"" << temp_udco << "\"";
 
-    if(!this->RunCommand(embed_sla_command, &error))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error adding SLA." << std::endl
-        << error
-        << std::endl);
+    if (!this->RunCommand(embed_sla_command, &error)) {
+      cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl
+                                                               << error
+                                                               << std::endl);
       return 0;
-      }
+    }
 
     // flatten dmg
     std::ostringstream flatten_command;
@@ -794,18 +697,16 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     flatten_command << " flatten ";
     flatten_command << "\"" << temp_udco << "\"";
 
-    if(!this->RunCommand(flatten_command, &error))
-      {
+    if (!this->RunCommand(flatten_command, &error)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error flattening dmg for adding SLA." << std::endl
-        << error
-        << std::endl);
+                    "Error flattening dmg for adding SLA." << std::endl
+                                                           << error
+                                                           << std::endl);
       return 0;
-      }
-
-    temp_image = temp_udco;
     }
 
+    temp_image = temp_udco;
+  }
 
   // Create the final compressed read-only disk image ...
   std::ostringstream final_image_command;
@@ -817,14 +718,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   final_image_command << " zlib-level=9";
   final_image_command << " -o \"" << output_file << "\"";
 
-  if(!this->RunCommand(final_image_command))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Error compressing disk image."
-      << std::endl);
+  if (!this->RunCommand(final_image_command)) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error compressing disk image."
+                    << std::endl);
 
     return 0;
-    }
+  }
 
   return 1;
 }
@@ -834,9 +733,8 @@ bool cmCPackDragNDropGenerator::SupportsComponentInstallation() const
   return true;
 }
 
-std::string
-cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
-                           const std::string& componentName)
+std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
+  const std::string& componentName)
 {
   // we want to group components together that go in the same dmg package
   std::string package_file_name = this->GetOption("CPACK_PACKAGE_FILE_NAME");
@@ -848,179 +746,153 @@ cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
   // 3. ignore groups - if grouping is defined, it is ignored
   //    and each component goes in its own package
 
-  if(this->componentPackageMethod == ONE_PACKAGE)
-    {
+  if (this->componentPackageMethod == ONE_PACKAGE) {
     return "ALL_IN_ONE";
-    }
+  }
 
-  if(this->componentPackageMethod == ONE_PACKAGE_PER_GROUP)
-    {
+  if (this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) {
     // We have to find the name of the COMPONENT GROUP
     // the current COMPONENT belongs to.
-    std::string groupVar = "CPACK_COMPONENT_" +
-                         cmSystemTools::UpperCase(componentName) + "_GROUP";
+    std::string groupVar =
+      "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
     const char* _groupName = GetOption(groupVar.c_str());
-    if (_groupName)
-      {
+    if (_groupName) {
       std::string groupName = _groupName;
 
-      groupName = GetComponentPackageFileName(package_file_name,
-                                              groupName, true);
+      groupName =
+        GetComponentPackageFileName(package_file_name, groupName, true);
       return groupName;
-      }
     }
+  }
 
   return GetComponentPackageFileName(package_file_name, componentName, false);
 }
 
-bool
-cmCPackDragNDropGenerator::WriteLicense(cmGeneratedFileStream& outputStream,
-  int licenseNumber, std::string licenseLanguage, std::string licenseFile,
-  std::string *error)
+bool cmCPackDragNDropGenerator::WriteLicense(
+  cmGeneratedFileStream& outputStream, int licenseNumber,
+  std::string licenseLanguage, std::string licenseFile, std::string* error)
 {
-  if(!licenseFile.empty() && !singleLicense)
-    {
+  if (!licenseFile.empty() && !singleLicense) {
     licenseNumber = 5002;
     licenseLanguage = "English";
-    }
+  }
 
   // License header
-  outputStream << "data 'TEXT' (" << licenseNumber << ", \""
-    << licenseLanguage << "\") {\n";
+  outputStream << "data 'TEXT' (" << licenseNumber << ", \"" << licenseLanguage
+               << "\") {\n";
   // License body
-  std::string actual_license = !licenseFile.empty() ? licenseFile :
-    (slaDirectory + "/" + licenseLanguage + ".license.txt");
+  std::string actual_license = !licenseFile.empty()
+    ? licenseFile
+    : (slaDirectory + "/" + licenseLanguage + ".license.txt");
   cmsys::ifstream license_ifs;
   license_ifs.open(actual_license.c_str());
-  if(license_ifs.is_open())
-    {
-    while(license_ifs.good())
-      {
+  if (license_ifs.is_open()) {
+    while (license_ifs.good()) {
       std::string line;
       std::getline(license_ifs, line);
-      if(!line.empty())
-        {
+      if (!line.empty()) {
         EscapeQuotesAndBackslashes(line);
         std::vector<std::string> lines;
-        if(!this->BreakLongLine(line, lines, error))
-          {
+        if (!this->BreakLongLine(line, lines, error)) {
           return false;
-          }
-        for(size_t i = 0; i < lines.size(); ++i)
-          {
+        }
+        for (size_t i = 0; i < lines.size(); ++i) {
           outputStream << "        \"" << lines[i] << "\"\n";
-          }
         }
-      outputStream << "        \"\\n\"\n";
       }
-    license_ifs.close();
+      outputStream << "        \"\\n\"\n";
     }
+    license_ifs.close();
+  }
 
   // End of License
   outputStream << "};\n\n";
-  if(!licenseFile.empty() && !singleLicense)
-    {
+  if (!licenseFile.empty() && !singleLicense) {
     outputStream << SLASTREnglish;
-    }
-  else
-    {
+  } else {
     // Menu header
     outputStream << "resource 'STR#' (" << licenseNumber << ", \""
-      << licenseLanguage << "\") {\n";
+                 << licenseLanguage << "\") {\n";
     outputStream << "    {\n";
 
     // Menu body
     cmsys::ifstream menu_ifs;
-    menu_ifs.open((slaDirectory+"/"+licenseLanguage+".menu.txt").c_str());
-    if(menu_ifs.is_open())
-      {
+    menu_ifs.open(
+      (slaDirectory + "/" + licenseLanguage + ".menu.txt").c_str());
+    if (menu_ifs.is_open()) {
       size_t lines_written = 0;
-      while(menu_ifs.good())
-        {
+      while (menu_ifs.good()) {
         // Lines written from original file, not from broken up lines
         std::string line;
         std::getline(menu_ifs, line);
-        if(!line.empty())
-          {
+        if (!line.empty()) {
           EscapeQuotesAndBackslashes(line);
           std::vector<std::string> lines;
-          if(!this->BreakLongLine(line, lines, error))
-            {
+          if (!this->BreakLongLine(line, lines, error)) {
             return false;
-            }
-          for(size_t i = 0; i < lines.size(); ++i)
-            {
+          }
+          for (size_t i = 0; i < lines.size(); ++i) {
             std::string comma;
             // We need a comma after every complete string,
             // but not on the very last line
-            if(lines_written != 8 && i == lines.size() - 1)
-              {
+            if (lines_written != 8 && i == lines.size() - 1) {
               comma = ",";
-              }
-            else
-              {
+            } else {
               comma = "";
-              }
-            outputStream << "        \"" << lines[i] << "\"" << comma << "\n";
             }
-          ++lines_written;
+            outputStream << "        \"" << lines[i] << "\"" << comma << "\n";
           }
+          ++lines_written;
         }
-      menu_ifs.close();
       }
+      menu_ifs.close();
+    }
 
-    //End of menu
+    // End of menu
     outputStream << "    }\n";
     outputStream << "};\n";
     outputStream << "\n";
-    }
+  }
 
   return true;
 }
 
-bool
-cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
-  std::vector<std::string>& lines, std::string *error)
+bool cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
+                                              std::vector<std::string>& lines,
+                                              std::string* error)
 {
   const size_t max_line_length = 512;
-  for(size_t i = 0; i < line.size(); i += max_line_length)
-    {
+  for (size_t i = 0; i < line.size(); i += max_line_length) {
     size_t line_length = max_line_length;
-    if(i + line_length > line.size())
-      {
+    if (i + line_length > line.size()) {
       line_length = line.size() - i;
-      }
-    else while(line_length > 0 && line[i + line_length - 1] != ' ')
-      {
-      line_length = line_length - 1;
+    } else
+      while (line_length > 0 && line[i + line_length - 1] != ' ') {
+        line_length = line_length - 1;
       }
 
-    if(line_length == 0)
-      {
+    if (line_length == 0) {
       *error = "Please make sure there are no words "
                "(or character sequences not broken up by spaces or newlines) "
                "in your license file which are more than 512 characters long.";
       return false;
-      }
-    lines.push_back(line.substr(i, line_length));
     }
+    lines.push_back(line.substr(i, line_length));
+  }
   return true;
 }
 
-void
-cmCPackDragNDropGenerator::EscapeQuotesAndBackslashes(std::string& line)
+void cmCPackDragNDropGenerator::EscapeQuotesAndBackslashes(std::string& line)
 {
   std::string::size_type backslash_pos = line.find('\\');
-  while(backslash_pos != std::string::npos)
-    {
+  while (backslash_pos != std::string::npos) {
     line.replace(backslash_pos, 1, "\\\\");
     backslash_pos = line.find('\\', backslash_pos + 2);
-    }
+  }
 
   std::string::size_type quote_pos = line.find('\"');
-  while(quote_pos != std::string::npos)
-    {
+  while (quote_pos != std::string::npos) {
     line.replace(quote_pos, 1, "\\\"");
     quote_pos = line.find('\"', quote_pos + 2);
-    }
+  }
 }
diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h
index 604cdf5..1392b21 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.h
+++ b/Source/CPack/cmCPackDragNDropGenerator.h
@@ -34,13 +34,12 @@ protected:
   int PackageFiles();
   bool SupportsComponentInstallation() const;
 
-
   bool CopyFile(std::ostringstream& source, std::ostringstream& target);
   bool CreateEmptyFile(std::ostringstream& target, size_t size);
   bool RunCommand(std::ostringstream& command, std::string* output = 0);
 
-  std::string
-  GetComponentInstallDirNameSuffix(const std::string& componentName);
+  std::string GetComponentInstallDirNameSuffix(
+    const std::string& componentName);
 
   int CreateDMG(const std::string& src_dir, const std::string& output_file);
 
@@ -51,11 +50,10 @@ private:
   bool singleLicense;
 
   bool WriteLicense(cmGeneratedFileStream& outputStream, int licenseNumber,
-    std::string licenseLanguage, std::string licenseFile,
-    std::string *error);
-  bool BreakLongLine(const std::string& line,
-    std::vector<std::string>& lines,
-    std::string *error);
+                    std::string licenseLanguage, std::string licenseFile,
+                    std::string* error);
+  bool BreakLongLine(const std::string& line, std::vector<std::string>& lines,
+                     std::string* error);
   void EscapeQuotesAndBackslashes(std::string& line);
 };
 
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 22d4bf0..c8b075d 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -12,18 +12,18 @@
 
 #include "cmCPackGenerator.h"
 
-#include "cmMakefile.h"
+#include "cmCPackComponentGroup.h"
 #include "cmCPackLog.h"
-#include "cmake.h"
-#include "cmGlobalGenerator.h"
 #include "cmGeneratedFileStream.h"
-#include "cmCPackComponentGroup.h"
+#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
 #include "cmXMLSafe.h"
+#include "cmake.h"
 
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/Glob.hxx>
-#include <cmsys/FStream.hxx>
 #include <algorithm>
+#include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/SystemTools.hxx>
 #include <list>
 
 #if defined(__HAIKU__)
@@ -31,7 +31,6 @@
 #include <StorageDefs.h>
 #endif
 
-//----------------------------------------------------------------------
 cmCPackGenerator::cmCPackGenerator()
 {
   this->GeneratorVerbose = cmSystemTools::OUTPUT_NONE;
@@ -40,87 +39,71 @@ cmCPackGenerator::cmCPackGenerator()
   this->componentPackageMethod = ONE_PACKAGE_PER_GROUP;
 }
 
-//----------------------------------------------------------------------
 cmCPackGenerator::~cmCPackGenerator()
 {
   this->MakefileMap = 0;
 }
 
-//----------------------------------------------------------------------
-void cmCPackGeneratorProgress(const char *msg, float prog, void* ptr)
+void cmCPackGeneratorProgress(const char* msg, float prog, void* ptr)
 {
   cmCPackGenerator* self = static_cast<cmCPackGenerator*>(ptr);
   self->DisplayVerboseOutput(msg, prog);
 }
 
-//----------------------------------------------------------------------
-void cmCPackGenerator::DisplayVerboseOutput(const char* msg,
-  float progress)
+void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress)
 {
   (void)progress;
   cmCPackLogger(cmCPackLog::LOG_VERBOSE, "" << msg << std::endl);
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::PrepareNames()
 {
-  cmCPackLogger(cmCPackLog::LOG_DEBUG,
-    "Create temp directory." << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Create temp directory." << std::endl);
 
   // checks CPACK_SET_DESTDIR support
-  if (IsOn("CPACK_SET_DESTDIR"))
-    {
-      if (SETDESTDIR_UNSUPPORTED==SupportsSetDestdir())
-        {
-          cmCPackLogger(cmCPackLog::LOG_ERROR,
-                        "CPACK_SET_DESTDIR is set to ON but the '"
-                        << Name << "' generator does NOT support it."
-                        << std::endl);
-          return 0;
-        }
-      else if (SETDESTDIR_SHOULD_NOT_BE_USED==SupportsSetDestdir())
-        {
-          cmCPackLogger(cmCPackLog::LOG_WARNING,
-                        "CPACK_SET_DESTDIR is set to ON but it is "
-                        << "usually a bad idea to do that with '"
-                        << Name << "' generator. Use at your own risk."
-                        << std::endl);
-        }
+  if (IsOn("CPACK_SET_DESTDIR")) {
+    if (SETDESTDIR_UNSUPPORTED == SupportsSetDestdir()) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '"
+          << Name << "' generator does NOT support it." << std::endl);
+      return 0;
+    } else if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
+      cmCPackLogger(cmCPackLog::LOG_WARNING,
+                    "CPACK_SET_DESTDIR is set to ON but it is "
+                      << "usually a bad idea to do that with '" << Name
+                      << "' generator. Use at your own risk." << std::endl);
+    }
   }
 
   std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
   tempDirectory += "/_CPack_Packages/";
   const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
-  if ( toplevelTag )
-    {
+  if (toplevelTag) {
     tempDirectory += toplevelTag;
     tempDirectory += "/";
-    }
+  }
   tempDirectory += this->GetOption("CPACK_GENERATOR");
   std::string topDirectory = tempDirectory;
   const char* pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME");
-  if(!pfname)
-    {
+  if (!pfname) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_PACKAGE_FILE_NAME not specified" << std::endl);
     return 0;
-    }
+  }
   std::string outName = pfname;
   tempDirectory += "/" + outName;
-  if(!this->GetOutputExtension())
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-                  "No output extension specified" << std::endl);
+  if (!this->GetOutputExtension()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "No output extension specified"
+                    << std::endl);
     return 0;
-    }
+  }
   outName += this->GetOutputExtension();
   const char* pdir = this->GetOption("CPACK_PACKAGE_DIRECTORY");
-  if(!pdir)
-    {
+  if (!pdir) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_PACKAGE_DIRECTORY not specified" << std::endl);
     return 0;
-    }
+  }
 
   std::string destFile = pdir;
   this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile.c_str());
@@ -133,185 +116,161 @@ int cmCPackGenerator::PrepareNames()
   this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
                           outFile.c_str());
   this->SetOptionIfNotSet("CPACK_INSTALL_DIRECTORY", this->GetInstallPath());
-  this->SetOptionIfNotSet("CPACK_NATIVE_INSTALL_DIRECTORY",
+  this->SetOptionIfNotSet(
+    "CPACK_NATIVE_INSTALL_DIRECTORY",
     cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str());
   this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY",
                           tempDirectory.c_str());
 
   cmCPackLogger(cmCPackLog::LOG_DEBUG,
-    "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
-  const char* descFileName
-    = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
-  if ( descFileName )
-    {
-    cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                  "Look for: " << descFileName << std::endl);
-    if ( !cmSystemTools::FileExists(descFileName) )
-      {
+                "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
+  const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
+  if (descFileName) {
+    cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName
+                                                      << std::endl);
+    if (!cmSystemTools::FileExists(descFileName)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Cannot find description file name: ["
-                    << descFileName << "]" << std::endl);
+                      << descFileName << "]" << std::endl);
       return 0;
-      }
+    }
     cmsys::ifstream ifs(descFileName);
-    if ( !ifs )
-      {
+    if (!ifs) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Cannot open description file name: " << descFileName << std::endl);
+                    "Cannot open description file name: " << descFileName
+                                                          << std::endl);
       return 0;
-      }
+    }
     std::ostringstream ostr;
     std::string line;
 
     cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-      "Read description file: " << descFileName << std::endl);
-    while ( ifs && cmSystemTools::GetLineFromStream(ifs, line) )
-      {
+                  "Read description file: " << descFileName << std::endl);
+    while (ifs && cmSystemTools::GetLineFromStream(ifs, line)) {
       ostr << cmXMLSafe(line) << std::endl;
-      }
-    this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
     }
-  if ( !this->GetOption("CPACK_PACKAGE_DESCRIPTION") )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
+    this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
+  }
+  if (!this->GetOption("CPACK_PACKAGE_DESCRIPTION")) {
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR,
       "Project description not specified. Please specify "
       "CPACK_PACKAGE_DESCRIPTION or CPACK_PACKAGE_DESCRIPTION_FILE."
-      << std::endl);
+        << std::endl);
     return 0;
-    }
+  }
 
   this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::InstallProject()
 {
   cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install projects" << std::endl);
   this->CleanTemporaryDirectory();
 
-  std::string bareTempInstallDirectory
-    = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
+  std::string bareTempInstallDirectory =
+    this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
   std::string tempInstallDirectoryStr = bareTempInstallDirectory;
-  bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR"))
-                  | cmSystemTools::IsInternallyOn(
-                    this->GetOption("CPACK_SET_DESTDIR"));
-  if (!setDestDir)
-    {
+  bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")) |
+    cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
+  if (!setDestDir) {
     tempInstallDirectoryStr += this->GetPackagingInstallPrefix();
-    }
+  }
 
   const char* tempInstallDirectory = tempInstallDirectoryStr.c_str();
   int res = 1;
-  if ( !cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str()))
-    {
+  if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Problem creating temporary directory: "
-                  << (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
-                  << std::endl);
+                  "Problem creating temporary directory: "
+                    << (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
+                    << std::endl);
     return 0;
-    }
+  }
 
-  if ( setDestDir )
-    {
+  if (setDestDir) {
     std::string destDir = "DESTDIR=";
     destDir += tempInstallDirectory;
     cmSystemTools::PutEnv(destDir);
-    }
-  else
-    {
+  } else {
     // Make sure there is no destdir
     cmSystemTools::PutEnv("DESTDIR=");
-    }
+  }
 
   // If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them
   // as listed
-  if ( !this->InstallProjectViaInstallCommands(
-      setDestDir, tempInstallDirectory) )
-    {
+  if (!this->InstallProjectViaInstallCommands(setDestDir,
+                                              tempInstallDirectory)) {
     return 0;
-    }
+  }
 
   // If the CPackConfig file sets CPACK_INSTALL_SCRIPT then run them
   // as listed
-  if ( !this->InstallProjectViaInstallScript(
-      setDestDir, tempInstallDirectory) )
-    {
+  if (!this->InstallProjectViaInstallScript(setDestDir,
+                                            tempInstallDirectory)) {
     return 0;
-    }
+  }
 
   // If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES
   // then glob it and copy it to CPACK_TEMPORARY_DIRECTORY
   // This is used in Source packaging
-  if ( !this->InstallProjectViaInstalledDirectories(
-      setDestDir, tempInstallDirectory) )
-    {
+  if (!this->InstallProjectViaInstalledDirectories(setDestDir,
+                                                   tempInstallDirectory)) {
     return 0;
-    }
-
+  }
 
   // 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) )
-    {
+  if (!this->InstallProjectViaInstallCMakeProjects(setDestDir,
+                                                   bareTempInstallDirectory)) {
     return 0;
-    }
+  }
 
-  if ( setDestDir )
-    {
+  if (setDestDir) {
     cmSystemTools::PutEnv("DESTDIR=");
-    }
+  }
 
   return res;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstallCommands(
   bool setDestDir, const std::string& tempInstallDirectory)
 {
-  (void) setDestDir;
+  (void)setDestDir;
   const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
-  if ( installCommands && *installCommands )
-    {
+  if (installCommands && *installCommands) {
     std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX=";
     tempInstallDirectoryEnv += tempInstallDirectory;
     cmSystemTools::PutEnv(tempInstallDirectoryEnv);
     std::vector<std::string> installCommandsVector;
-    cmSystemTools::ExpandListArgument(installCommands,installCommandsVector);
+    cmSystemTools::ExpandListArgument(installCommands, installCommandsVector);
     std::vector<std::string>::iterator it;
-    for ( it = installCommandsVector.begin();
-      it != installCommandsVector.end();
-      ++it )
-      {
-      cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it
-        << std::endl);
+    for (it = installCommandsVector.begin(); it != installCommandsVector.end();
+         ++it) {
+      cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl);
       std::string output;
       int retVal = 1;
       bool resB = cmSystemTools::RunSingleCommand(
-        it->c_str(), &output, &output,
-        &retVal, 0, this->GeneratorVerbose, 0);
-      if ( !resB || retVal )
-        {
+        it->c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+      if (!resB || retVal) {
         std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
         tmpFile += "/InstallOutput.log";
         cmGeneratedFileStream ofs(tmpFile.c_str());
         ofs << "# Run command: " << *it << std::endl
-          << "# Output:" << std::endl
-          << output << std::endl;
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Problem running install command: " << *it << std::endl
-          << "Please check " << tmpFile << " for errors"
-          << std::endl);
+            << "# Output:" << std::endl
+            << output << std::endl;
+        cmCPackLogger(
+          cmCPackLog::LOG_ERROR, "Problem running install command: "
+            << *it << std::endl
+            << "Please check " << tmpFile << " for errors" << std::endl);
         return 0;
-        }
       }
     }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstalledDirectories(
   bool setDestDir, const std::string& tempInstallDirectory)
 {
@@ -319,267 +278,230 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
   (void)tempInstallDirectory;
   std::vector<cmsys::RegularExpression> ignoreFilesRegex;
   const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES");
-  if ( cpackIgnoreFiles )
-    {
+  if (cpackIgnoreFiles) {
     std::vector<std::string> ignoreFilesRegexString;
     cmSystemTools::ExpandListArgument(cpackIgnoreFiles,
                                       ignoreFilesRegexString);
     std::vector<std::string>::iterator it;
-    for ( it = ignoreFilesRegexString.begin();
-      it != ignoreFilesRegexString.end();
-      ++it )
-      {
+    for (it = ignoreFilesRegexString.begin();
+         it != ignoreFilesRegexString.end(); ++it) {
       cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-        "Create ignore files regex for: " << *it << std::endl);
+                    "Create ignore files regex for: " << *it << std::endl);
       ignoreFilesRegex.push_back(it->c_str());
-      }
     }
-  const char* installDirectories
-    = this->GetOption("CPACK_INSTALLED_DIRECTORIES");
-  if ( installDirectories && *installDirectories )
-    {
+  }
+  const char* installDirectories =
+    this->GetOption("CPACK_INSTALLED_DIRECTORIES");
+  if (installDirectories && *installDirectories) {
     std::vector<std::string> installDirectoriesVector;
     cmSystemTools::ExpandListArgument(installDirectories,
-      installDirectoriesVector);
-    if ( installDirectoriesVector.size() % 2 != 0 )
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
+                                      installDirectoriesVector);
+    if (installDirectoriesVector.size() % 2 != 0) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR,
         "CPACK_INSTALLED_DIRECTORIES should contain pairs of <directory> and "
         "<subdirectory>. The <subdirectory> can be '.' to be installed in "
-        "the toplevel directory of installation." << std::endl);
+        "the toplevel directory of installation."
+          << std::endl);
       return 0;
-      }
+    }
     std::vector<std::string>::iterator it;
     const std::string& tempDir = tempInstallDirectory;
-    for ( it = installDirectoriesVector.begin();
-      it != installDirectoriesVector.end();
-      ++it )
-      {
-      std::list<std::pair<std::string,std::string> > symlinkedFiles;
+    for (it = installDirectoriesVector.begin();
+         it != installDirectoriesVector.end(); ++it) {
+      std::list<std::pair<std::string, std::string> > symlinkedFiles;
       cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
       cmsys::Glob gl;
       std::string top = *it;
-      it ++;
+      it++;
       std::string subdir = *it;
       std::string findExpr = top;
       findExpr += "/*";
       cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-        "- Install directory: " << top << std::endl);
+                    "- Install directory: " << top << std::endl);
       gl.RecurseOn();
       gl.SetRecurseListDirs(true);
-      if ( !gl.FindFiles(findExpr) )
-        {
+      if (!gl.FindFiles(findExpr)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Cannot find any files in the installed directory" << std::endl);
+                      "Cannot find any files in the installed directory"
+                        << std::endl);
         return 0;
-        }
+      }
       files = gl.GetFiles();
       std::vector<std::string>::iterator gfit;
       std::vector<cmsys::RegularExpression>::iterator regIt;
-      for ( gfit = files.begin(); gfit != files.end(); ++ gfit )
-        {
+      for (gfit = files.begin(); gfit != files.end(); ++gfit) {
         bool skip = false;
         std::string inFile = *gfit;
-        if(cmSystemTools::FileIsDirectory(*gfit))
-          {
+        if (cmSystemTools::FileIsDirectory(*gfit)) {
           inFile += '/';
-          }
-        for ( regIt= ignoreFilesRegex.begin();
-          regIt!= ignoreFilesRegex.end();
-          ++ regIt)
-          {
-          if ( regIt->find(inFile.c_str()) )
-            {
-            cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: "
-              << inFile << std::endl);
+        }
+        for (regIt = ignoreFilesRegex.begin(); regIt != ignoreFilesRegex.end();
+             ++regIt) {
+          if (regIt->find(inFile.c_str())) {
+            cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+                          "Ignore file: " << inFile << std::endl);
             skip = true;
-            }
           }
-        if ( skip )
-          {
+        }
+        if (skip) {
           continue;
-          }
+        }
         std::string filePath = tempDir;
-        filePath += "/" + subdir + "/"
-          + cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
+        filePath += "/" + subdir + "/" +
+          cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
         cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
-          << inFile << " -> " << filePath << std::endl);
+                        << inFile << " -> " << filePath << std::endl);
         /* If the file is a symlink we will have to re-create it */
-        if ( cmSystemTools::FileIsSymlink(inFile))
-          {
+        if (cmSystemTools::FileIsSymlink(inFile)) {
           std::string targetFile;
           std::string inFileRelative =
-             cmSystemTools::RelativePath(top.c_str(),inFile.c_str());
-          cmSystemTools::ReadSymlink(inFile,targetFile);
-          symlinkedFiles.push_back(std::pair<std::string,
-                                   std::string>(targetFile,inFileRelative));
-          }
+            cmSystemTools::RelativePath(top.c_str(), inFile.c_str());
+          cmSystemTools::ReadSymlink(inFile, targetFile);
+          symlinkedFiles.push_back(
+            std::pair<std::string, std::string>(targetFile, inFileRelative));
+        }
         /* If it is not a symlink then do a plain copy */
-        else if (!(
-            cmSystemTools::CopyFileIfDifferent(inFile.c_str(),filePath.c_str())
-            &&
-            cmSystemTools::CopyFileTime(inFile.c_str(),filePath.c_str())
-                ) )
-          {
+        else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
+                                                      filePath.c_str()) &&
+                   cmSystemTools::CopyFileTime(inFile.c_str(),
+                                               filePath.c_str()))) {
           cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
-            << inFile << " -> " << filePath << std::endl);
+                          << inFile << " -> " << filePath << std::endl);
           return 0;
-          }
         }
+      }
       /* rebuild symlinks in the installed tree */
-      if (!symlinkedFiles.empty())
-        {
-        std::list< std::pair<std::string,std::string> >::iterator symlinkedIt;
+      if (!symlinkedFiles.empty()) {
+        std::list<std::pair<std::string, std::string> >::iterator symlinkedIt;
         std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
         std::string goToDir = tempDir;
-        goToDir  += "/"+subdir;
-        cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                      "Change dir to: " << goToDir <<std::endl);
+        goToDir += "/" + subdir;
+        cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
+                                                               << std::endl);
         cmSystemTools::ChangeDirectory(goToDir);
-        for (symlinkedIt=symlinkedFiles.begin();
-             symlinkedIt != symlinkedFiles.end();
-             ++symlinkedIt)
-          {
+        for (symlinkedIt = symlinkedFiles.begin();
+             symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
           cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
-                         << symlinkedIt->second << "--> "
-                         << symlinkedIt->first << std::endl);
+                          << symlinkedIt->second << "--> "
+                          << symlinkedIt->first << std::endl);
           // make sure directory exists for symlink
           std::string destDir =
             cmSystemTools::GetFilenamePath(symlinkedIt->second);
-          if(!destDir.empty() && !cmSystemTools::MakeDirectory(destDir))
-            {
+          if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) {
             cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: "
-                          << destDir
-                          << "\nTrying to create symlink: "
-                          << symlinkedIt->second << "--> "
-                          << symlinkedIt->first
-                          << std::endl);
-            }
+                            << destDir << "\nTrying to create symlink: "
+                            << symlinkedIt->second << "--> "
+                            << symlinkedIt->first << std::endl);
+          }
           if (!cmSystemTools::CreateSymlink(symlinkedIt->first,
-                                            symlinkedIt->second))
-            {
+                                            symlinkedIt->second)) {
             cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
                             << symlinkedIt->second << "--> "
                             << symlinkedIt->first << std::endl);
             return 0;
-            }
           }
-        cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: "
-                      << curDir <<std::endl);
-        cmSystemTools::ChangeDirectory(curDir);
         }
+        cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir
+                                                               << std::endl);
+        cmSystemTools::ChangeDirectory(curDir);
       }
     }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstallScript(
   bool setDestDir, const std::string& tempInstallDirectory)
 {
-  const char* cmakeScripts
-    = this->GetOption("CPACK_INSTALL_SCRIPT");
-  if ( cmakeScripts && *cmakeScripts )
-    {
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-                  "- Install scripts: " << cmakeScripts << std::endl);
+  const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT");
+  if (cmakeScripts && *cmakeScripts) {
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install scripts: " << cmakeScripts
+                                                                << std::endl);
     std::vector<std::string> cmakeScriptsVector;
-    cmSystemTools::ExpandListArgument(cmakeScripts,
-      cmakeScriptsVector);
+    cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector);
     std::vector<std::string>::iterator it;
-    for ( it = cmakeScriptsVector.begin();
-      it != cmakeScriptsVector.end();
-      ++it )
-      {
+    for (it = cmakeScriptsVector.begin(); it != cmakeScriptsVector.end();
+         ++it) {
       std::string installScript = *it;
 
       cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-        "- Install script: " << installScript << std::endl);
+                    "- Install script: " << installScript << std::endl);
 
-      if ( setDestDir )
-        {
+      if (setDestDir) {
         // For DESTDIR based packaging, use the *project* CMAKE_INSTALL_PREFIX
         // underneath the tempInstallDirectory. The value of the project's
         // CMAKE_INSTALL_PREFIX is sent in here as the value of the
         // CPACK_INSTALL_PREFIX variable.
 
         std::string dir;
-        if (this->GetOption("CPACK_INSTALL_PREFIX"))
-          {
+        if (this->GetOption("CPACK_INSTALL_PREFIX")) {
           dir += this->GetOption("CPACK_INSTALL_PREFIX");
-          }
+        }
         this->SetOption("CMAKE_INSTALL_PREFIX", dir.c_str());
-        cmCPackLogger(cmCPackLog::LOG_DEBUG,
+        cmCPackLogger(
+          cmCPackLog::LOG_DEBUG,
           "- Using DESTDIR + CPACK_INSTALL_PREFIX... (this->SetOption)"
-          << std::endl);
+            << std::endl);
         cmCPackLogger(cmCPackLog::LOG_DEBUG,
-          "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'" << std::endl);
-        }
-      else
-        {
+                      "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
+                                                            << std::endl);
+      } else {
         this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
 
         cmCPackLogger(cmCPackLog::LOG_DEBUG,
-          "- Using non-DESTDIR install... (this->SetOption)" << std::endl);
+                      "- Using non-DESTDIR install... (this->SetOption)"
+                        << std::endl);
         cmCPackLogger(cmCPackLog::LOG_DEBUG,
-          "- Setting CMAKE_INSTALL_PREFIX to '" << tempInstallDirectory
-          << "'" << std::endl);
-        }
+                      "- Setting CMAKE_INSTALL_PREFIX to '"
+                        << tempInstallDirectory << "'" << std::endl);
+      }
 
       this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR",
-        tempInstallDirectory.c_str());
+                              tempInstallDirectory.c_str());
       this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
-        tempInstallDirectory.c_str());
+                              tempInstallDirectory.c_str());
       int res = this->MakefileMap->ReadListFile(installScript.c_str());
-      if ( cmSystemTools::GetErrorOccuredFlag() || !res )
-        {
+      if (cmSystemTools::GetErrorOccuredFlag() || !res) {
         return 0;
-        }
       }
     }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
   bool setDestDir, const std::string& baseTempInstallDirectory)
 {
-  const char* cmakeProjects
-    = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
-  const char* cmakeGenerator
-    = this->GetOption("CPACK_CMAKE_GENERATOR");
+  const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
+  const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR");
   std::string absoluteDestFiles;
-  if ( cmakeProjects && *cmakeProjects )
-    {
-    if ( !cmakeGenerator )
-      {
+  if (cmakeProjects && *cmakeProjects) {
+    if (!cmakeGenerator) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "CPACK_INSTALL_CMAKE_PROJECTS is specified, but "
                     "CPACK_CMAKE_GENERATOR is not. CPACK_CMAKE_GENERATOR "
                     "is required to install the project."
-                    << std::endl);
+                      << std::endl);
       return 0;
-      }
+    }
     std::vector<std::string> cmakeProjectsVector;
-    cmSystemTools::ExpandListArgument(cmakeProjects,
-      cmakeProjectsVector);
+    cmSystemTools::ExpandListArgument(cmakeProjects, cmakeProjectsVector);
     std::vector<std::string>::iterator it;
-    for ( it = cmakeProjectsVector.begin();
-      it != cmakeProjectsVector.end();
-      ++it )
-      {
-      if ( it+1 == cmakeProjectsVector.end() ||
-        it+2 == cmakeProjectsVector.end() ||
-        it+3 == cmakeProjectsVector.end() )
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
+    for (it = cmakeProjectsVector.begin(); it != cmakeProjectsVector.end();
+         ++it) {
+      if (it + 1 == cmakeProjectsVector.end() ||
+          it + 2 == cmakeProjectsVector.end() ||
+          it + 3 == cmakeProjectsVector.end()) {
+        cmCPackLogger(
+          cmCPackLog::LOG_ERROR,
           "Not enough items on list: CPACK_INSTALL_CMAKE_PROJECTS. "
           "CPACK_INSTALL_CMAKE_PROJECTS should hold quadruplet of install "
           "directory, install project name, install component, and install "
           "subdirectory."
-          << std::endl);
+            << std::endl);
         return 0;
-        }
+      }
       std::string installDirectory = *it;
       ++it;
       std::string installProjectName = *it;
@@ -599,60 +521,50 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
        *      (this works at CPack time too)
        */
       if (this->SupportsComponentInstallation() &
-          !(this->IsOn("CPACK_MONOLITHIC_INSTALL")))
-        {
+          !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) {
         // Determine the installation types for this project (if provided).
-        std::string installTypesVar = "CPACK_"
-          + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
-        const char *installTypes = this->GetOption(installTypesVar);
-        if (installTypes && *installTypes)
-          {
+        std::string installTypesVar = "CPACK_" +
+          cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
+        const char* installTypes = this->GetOption(installTypesVar);
+        if (installTypes && *installTypes) {
           std::vector<std::string> installTypesVector;
           cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
           std::vector<std::string>::iterator installTypeIt;
           for (installTypeIt = installTypesVector.begin();
-               installTypeIt != installTypesVector.end();
-               ++installTypeIt)
-            {
-            this->GetInstallationType(installProjectName,
-                                      *installTypeIt);
-            }
+               installTypeIt != installTypesVector.end(); ++installTypeIt) {
+            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);
-        if (components && *components)
-          {
+        std::string componentsVar =
+          "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
+        const char* components = this->GetOption(componentsVar);
+        if (components && *components) {
           cmSystemTools::ExpandListArgument(components, componentsVector);
           std::vector<std::string>::iterator compIt;
           for (compIt = componentsVector.begin();
-               compIt != componentsVector.end();
-               ++compIt)
-            {
+               compIt != componentsVector.end(); ++compIt) {
             GetComponent(installProjectName, *compIt);
-            }
-          componentInstall = true;
           }
+          componentInstall = true;
         }
-      if (componentsVector.empty())
-        {
+      }
+      if (componentsVector.empty()) {
         componentsVector.push_back(installComponent);
-        }
+      }
 
       const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
       std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
-      cmGlobalGenerator* globalGenerator
-        = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
+      cmGlobalGenerator* globalGenerator =
+        this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
           cmakeGenerator);
-      if ( !globalGenerator )
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-                    "Specified package generator not found. "
-                    "CPACK_CMAKE_GENERATOR value is invalid."
-                    << std::endl);
-      return 0;
+      if (!globalGenerator) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR,
+                      "Specified package generator not found. "
+                      "CPACK_CMAKE_GENERATOR value is invalid."
+                        << std::endl);
+        return 0;
       }
       // set the global flag for unix style paths on cmSystemTools as
       // soon as the generator is set.  This allows gmake to be used
@@ -660,59 +572,49 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
       cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
 
       // Does this generator require pre-install?
-      if (const char* preinstall = globalGenerator->GetPreinstallTargetName())
-        {
-        std::string buildCommand =
-          globalGenerator->GenerateCMakeBuildCommand(
-            preinstall, buildConfig, "", false);
+      if (const char* preinstall =
+            globalGenerator->GetPreinstallTargetName()) {
+        std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
+          preinstall, buildConfig, "", false);
         cmCPackLogger(cmCPackLog::LOG_DEBUG,
-          "- Install command: " << buildCommand << std::endl);
-        cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-          "- Run preinstall target for: " << installProjectName << std::endl);
+                      "- Install command: " << buildCommand << std::endl);
+        cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: "
+                        << installProjectName << std::endl);
         std::string output;
         int retVal = 1;
-        bool resB =
-          cmSystemTools::RunSingleCommand(buildCommand.c_str(),
-                                          &output, &output,
-                                          &retVal,
-                                          installDirectory.c_str(),
-                                          this->GeneratorVerbose, 0);
-        if ( !resB || retVal )
-          {
+        bool resB = cmSystemTools::RunSingleCommand(
+          buildCommand.c_str(), &output, &output, &retVal,
+          installDirectory.c_str(), this->GeneratorVerbose, 0);
+        if (!resB || retVal) {
           std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
           tmpFile += "/PreinstallOutput.log";
           cmGeneratedFileStream ofs(tmpFile.c_str());
           ofs << "# Run command: " << buildCommand << std::endl
-            << "# Directory: " << installDirectory << std::endl
-            << "# Output:" << std::endl
-            << output << std::endl;
-          cmCPackLogger(cmCPackLog::LOG_ERROR,
-            "Problem running install command: " << buildCommand
-            << std::endl
-            << "Please check " << tmpFile << " for errors"
-            << std::endl);
+              << "# Directory: " << installDirectory << std::endl
+              << "# Output:" << std::endl
+              << output << std::endl;
+          cmCPackLogger(
+            cmCPackLog::LOG_ERROR, "Problem running install command: "
+              << buildCommand << std::endl
+              << "Please check " << tmpFile << " for errors" << std::endl);
           return 0;
-          }
         }
+      }
       delete globalGenerator;
 
       cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-        "- Install project: " << installProjectName << std::endl);
+                    "- Install project: " << installProjectName << std::endl);
 
       // Run the installation for each component
       std::vector<std::string>::iterator componentIt;
       for (componentIt = componentsVector.begin();
-           componentIt != componentsVector.end();
-           ++componentIt)
-        {
+           componentIt != componentsVector.end(); ++componentIt) {
         std::string tempInstallDirectory = baseTempInstallDirectory;
         installComponent = *componentIt;
-        if (componentInstall)
-          {
-          cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-                        "-   Install component: " << installComponent
-                        << std::endl);
-          }
+        if (componentInstall) {
+          cmCPackLogger(cmCPackLog::LOG_OUTPUT, "-   Install component: "
+                          << installComponent << std::endl);
+        }
 
         cmake cm;
         cm.SetHomeDirectory("");
@@ -722,14 +624,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
         cm.SetProgressCallback(cmCPackGeneratorProgress, this);
         cmGlobalGenerator gg(&cm);
         cmsys::auto_ptr<cmMakefile> mf(
-              new cmMakefile(&gg, cm.GetCurrentSnapshot()));
-        std::string realInstallDirectory = tempInstallDirectory;
-        if ( !installSubDirectory.empty() && installSubDirectory != "/" )
-          {
-          realInstallDirectory += installSubDirectory;
-          }
-        if (componentInstall)
-          {
+          new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+        if (!installSubDirectory.empty() && installSubDirectory != "/") {
+          tempInstallDirectory += installSubDirectory;
+        }
+        if (componentInstall) {
           tempInstallDirectory += "/";
           // Some CPack generators would rather chose
           // the local installation directory suffix.
@@ -739,20 +638,17 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
           //  one install directory for each component.
           tempInstallDirectory +=
             GetComponentInstallDirNameSuffix(installComponent);
-          if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
-            {
+          if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
             tempInstallDirectory += "/";
             tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
-            }
           }
+        }
 
-        if (!setDestDir)
-          {
+        if (!setDestDir) {
           tempInstallDirectory += this->GetPackagingInstallPrefix();
-          }
+        }
 
-        if ( setDestDir )
-          {
+        if (setDestDir) {
           // For DESTDIR based packaging, use the *project*
           // CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
           // value of the project's CMAKE_INSTALL_PREFIX is sent in here as
@@ -765,37 +661,32 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
           // I know this is tricky and awkward but it's the price for
           // CPACK_SET_DESTDIR backward compatibility.
           if (cmSystemTools::IsInternallyOn(
-                this->GetOption("CPACK_SET_DESTDIR")))
-            {
+                this->GetOption("CPACK_SET_DESTDIR"))) {
             this->SetOption("CPACK_INSTALL_PREFIX",
                             this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
-            }
+          }
           std::string dir;
-          if (this->GetOption("CPACK_INSTALL_PREFIX"))
-            {
+          if (this->GetOption("CPACK_INSTALL_PREFIX")) {
             dir += this->GetOption("CPACK_INSTALL_PREFIX");
-            }
+          }
           mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
 
           cmCPackLogger(
             cmCPackLog::LOG_DEBUG,
             "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)"
-            << std::endl);
+              << std::endl);
           cmCPackLogger(cmCPackLog::LOG_DEBUG,
                         "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
-                        << std::endl);
+                                                              << std::endl);
 
           // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
           // exists:
           //
-          if (cmSystemTools::StringStartsWith(dir.c_str(), "/"))
-            {
+          if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) {
             dir = tempInstallDirectory + dir;
-            }
-          else
-            {
+          } else {
             dir = tempInstallDirectory + "/" + dir;
-            }
+          }
           /*
            *  We must re-set DESTDIR for each component
            *  We must not add the CPACK_INSTALL_PREFIX part because
@@ -807,271 +698,235 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
            *     - Because it was already used for component install
            *       in order to put things in subdirs...
            */
-          cmSystemTools::PutEnv(
-              std::string("DESTDIR=")+tempInstallDirectory
-                               );
-          cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                        "- Creating directory: '" << dir << "'" << std::endl);
-
-          if ( !cmsys::SystemTools::MakeDirectory(dir.c_str()))
-            {
-            cmCPackLogger(cmCPackLog::LOG_ERROR,
-                          "Problem creating temporary directory: "
-                          << dir << std::endl);
+          cmSystemTools::PutEnv(std::string("DESTDIR=") +
+                                tempInstallDirectory);
+          cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '"
+                          << dir << "'" << std::endl);
+
+          if (!cmsys::SystemTools::MakeDirectory(dir.c_str())) {
+            cmCPackLogger(
+              cmCPackLog::LOG_ERROR,
+              "Problem creating temporary directory: " << dir << std::endl);
             return 0;
-            }
           }
-        else
-          {
+        } else {
           mf->AddDefinition("CMAKE_INSTALL_PREFIX",
                             tempInstallDirectory.c_str());
 
-          if ( !cmsys::SystemTools::MakeDirectory(
-                 tempInstallDirectory.c_str()))
-            {
+          if (!cmsys::SystemTools::MakeDirectory(
+                tempInstallDirectory.c_str())) {
             cmCPackLogger(cmCPackLog::LOG_ERROR,
                           "Problem creating temporary directory: "
-                          << tempInstallDirectory << std::endl);
+                            << tempInstallDirectory << std::endl);
             return 0;
-            }
+          }
 
           cmCPackLogger(cmCPackLog::LOG_DEBUG,
                         "- Using non-DESTDIR install... (mf->AddDefinition)"
-                        << std::endl);
+                          << std::endl);
           cmCPackLogger(cmCPackLog::LOG_DEBUG,
                         "- Setting CMAKE_INSTALL_PREFIX to '"
-                        << tempInstallDirectory
-                        << "'" << std::endl);
-          }
+                          << tempInstallDirectory << "'" << std::endl);
+        }
 
-        if (!buildConfig.empty())
-          {
+        if (!buildConfig.empty()) {
           mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
-          }
-        std::string installComponentLowerCase
-          = cmSystemTools::LowerCase(installComponent);
-        if ( installComponentLowerCase != "all" )
-          {
+        }
+        std::string installComponentLowerCase =
+          cmSystemTools::LowerCase(installComponent);
+        if (installComponentLowerCase != "all") {
           mf->AddDefinition("CMAKE_INSTALL_COMPONENT",
                             installComponent.c_str());
-          }
+        }
 
         // strip on TRUE, ON, 1, one or several file names, but not on
         // FALSE, OFF, 0 and an empty string
-        if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES")))
-          {
+        if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
           mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
-          }
+        }
         // Remember the list of files before installation
         // of the current component (if we are in component install)
         const char* InstallPrefix = tempInstallDirectory.c_str();
         std::vector<std::string> filesBefore;
         std::string findExpr(InstallPrefix);
-        if (componentInstall)
-          {
+        if (componentInstall) {
           cmsys::Glob glB;
           findExpr += "/*";
           glB.RecurseOn();
           glB.SetRecurseListDirs(true);
           glB.FindFiles(findExpr);
           filesBefore = glB.GetFiles();
-          std::sort(filesBefore.begin(),filesBefore.end());
-          }
+          std::sort(filesBefore.begin(), filesBefore.end());
+        }
 
         // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
         // then forward request to cmake_install.cmake script
-        if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION"))
-          {
-            mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION",
-                              "1");
-          }
+        if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+          mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+        }
         // If current CPack generator does support
         // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
         // then ask cmake_install.cmake script to error out
         // as soon as it occurs (before installing file)
         if (!SupportsAbsoluteDestination() ||
-            this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION"))
-          {
-            mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
-                              "1");
-          }
+            this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+          mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
+                            "1");
+        }
         // do installation
         int res = mf->ReadListFile(installFile.c_str());
         // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
         // to CPack (may be used by generators like CPack RPM or DEB)
         // in order to transparently handle ABSOLUTE PATH
-        if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"))
-          {
-            mf->AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES",
-                mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
-          }
+        if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
+          mf->AddDefinition(
+            "CPACK_ABSOLUTE_DESTINATION_FILES",
+            mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
+        }
 
         // Now rebuild the list of files after installation
         // of the current component (if we are in component install)
-        if (componentInstall)
-          {
+        if (componentInstall) {
           cmsys::Glob glA;
           glA.RecurseOn();
           glA.SetRecurseListDirs(true);
           glA.FindFiles(findExpr);
           std::vector<std::string> filesAfter = glA.GetFiles();
-          std::sort(filesAfter.begin(),filesAfter.end());
+          std::sort(filesAfter.begin(), filesAfter.end());
           std::vector<std::string>::iterator diff;
           std::vector<std::string> result(filesAfter.size());
-          diff = std::set_difference (
-                  filesAfter.begin(),filesAfter.end(),
-                  filesBefore.begin(),filesBefore.end(),
-                  result.begin());
+          diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
+                                     filesBefore.begin(), filesBefore.end(),
+                                     result.begin());
 
           std::vector<std::string>::iterator fit;
           std::string localFileName;
           // Populate the File field of each component
-          for (fit=result.begin();fit!=diff;++fit)
-            {
-            localFileName =
-                cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
+          for (fit = result.begin(); fit != diff; ++fit) {
             localFileName =
-                localFileName.substr(localFileName.find_first_not_of('/'),
-                                     std::string::npos);
+              cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
+            localFileName = localFileName.substr(
+              localFileName.find_first_not_of('/'), std::string::npos);
             Components[installComponent].Files.push_back(localFileName);
             cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <"
-                                <<localFileName<<"> to component <"
-                                <<installComponent<<">"<<std::endl);
-            }
+                            << localFileName << "> to component <"
+                            << installComponent << ">" << std::endl);
           }
+        }
 
-        if (NULL !=mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+        if (NULL != mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
           if (!absoluteDestFiles.empty()) {
-            absoluteDestFiles +=";";
+            absoluteDestFiles += ";";
           }
           absoluteDestFiles +=
             mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
           cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                                    "Got some ABSOLUTE DESTINATION FILES: "
-                                    << absoluteDestFiles << std::endl);
+                        "Got some ABSOLUTE DESTINATION FILES: "
+                          << absoluteDestFiles << std::endl);
           // define component specific var
-          if (componentInstall)
-            {
+          if (componentInstall) {
             std::string absoluteDestFileComponent =
-                std::string("CPACK_ABSOLUTE_DESTINATION_FILES")
-                + "_" + GetComponentInstallDirNameSuffix(installComponent);
-            if (NULL != this->GetOption(absoluteDestFileComponent))
-              {
-                std::string absoluteDestFilesListComponent =
-                    this->GetOption(absoluteDestFileComponent);
-                absoluteDestFilesListComponent +=";";
-                absoluteDestFilesListComponent +=
-                    mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
-                this->SetOption(absoluteDestFileComponent,
-                    absoluteDestFilesListComponent.c_str());
-              }
-            else
-              {
+              std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
+              GetComponentInstallDirNameSuffix(installComponent);
+            if (NULL != this->GetOption(absoluteDestFileComponent)) {
+              std::string absoluteDestFilesListComponent =
+                this->GetOption(absoluteDestFileComponent);
+              absoluteDestFilesListComponent += ";";
+              absoluteDestFilesListComponent +=
+                mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
               this->SetOption(absoluteDestFileComponent,
-                  mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
-              }
+                              absoluteDestFilesListComponent.c_str());
+            } else {
+              this->SetOption(
+                absoluteDestFileComponent,
+                mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
             }
+          }
         }
-        if ( cmSystemTools::GetErrorOccuredFlag() || !res )
-          {
+        if (cmSystemTools::GetErrorOccuredFlag() || !res) {
           return 0;
-          }
         }
       }
     }
+  }
   this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
                   absoluteDestFiles.c_str());
   return 1;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::ReadListFile(const char* moduleName)
 {
   bool retval;
   std::string fullPath = this->MakefileMap->GetModulesFile(moduleName);
   retval = this->MakefileMap->ReadListFile(fullPath.c_str());
   // include FATAL_ERROR and ERROR in the return status
-  retval = retval && (! cmSystemTools::GetErrorOccuredFlag());
+  retval = retval && (!cmSystemTools::GetErrorOccuredFlag());
   return retval;
 }
 
-//----------------------------------------------------------------------
 void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
-  const char* value)
+                                         const char* value)
 {
   const char* def = this->MakefileMap->GetDefinition(op);
-  if ( def && *def )
-    {
+  if (def && *def) {
     return;
-    }
+  }
   this->SetOption(op, value);
 }
 
-//----------------------------------------------------------------------
 void cmCPackGenerator::SetOption(const std::string& op, const char* value)
 {
-  if ( !value )
-    {
+  if (!value) {
     this->MakefileMap->RemoveDefinition(op);
     return;
-    }
+  }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
-    << "::SetOption(" << op << ", " << value << ")" << std::endl);
+                  << "::SetOption(" << op << ", " << value << ")"
+                  << std::endl);
   this->MakefileMap->AddDefinition(op, value);
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::DoPackage()
 {
-  cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-    "Create package using " << this->Name << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package using " << this->Name
+                                                                << std::endl);
 
   // Prepare CPack internal name and check
   // values for many CPACK_xxx vars
-  if ( !this->PrepareNames() )
-    {
+  if (!this->PrepareNames()) {
     return 0;
-    }
+  }
 
   // Digest Component grouping specification
-  if ( !this->PrepareGroupingKind() )
-    {
+  if (!this->PrepareGroupingKind()) {
     return 0;
-    }
+  }
 
-  if ( cmSystemTools::IsOn(
-      this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY")) )
-    {
-    const char* toplevelDirectory
-      = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
-    if ( cmSystemTools::FileExists(toplevelDirectory) )
-      {
-      cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-                    "Remove toplevel directory: "
-        << toplevelDirectory << std::endl);
-      if ( !cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory) )
-        {
+  if (cmSystemTools::IsOn(
+        this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) {
+    const char* toplevelDirectory =
+      this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+    if (cmSystemTools::FileExists(toplevelDirectory)) {
+      cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove toplevel directory: "
+                      << toplevelDirectory << std::endl);
+      if (!cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Problem removing toplevel directory: "
-          << toplevelDirectory
-          << std::endl);
+                      "Problem removing toplevel directory: "
+                        << toplevelDirectory << std::endl);
         return 0;
-        }
       }
     }
-  cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                "About to install project " << std::endl);
+  }
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "About to install project "
+                  << std::endl);
 
-  if ( !this->InstallProject() )
-    {
+  if (!this->InstallProject()) {
     return 0;
-    }
-  cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                "Done install project " << std::endl);
-
+  }
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Done install project " << std::endl);
 
-  const char* tempPackageFileName = this->GetOption(
-    "CPACK_TEMPORARY_PACKAGE_FILE_NAME");
+  const char* tempPackageFileName =
+    this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
   const char* tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
 
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
@@ -1081,27 +936,25 @@ int cmCPackGenerator::DoPackage()
   gl.RecurseOn();
   gl.SetRecurseListDirs(true);
   gl.SetRecurseThroughSymlinks(false);
-  if ( !gl.FindFiles(findExpr) )
-    {
+  if (!gl.FindFiles(findExpr)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Cannot find any files in the packaging tree" << std::endl);
+                  "Cannot find any files in the packaging tree" << std::endl);
     return 0;
-    }
+  }
 
   cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
   cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Package files to: "
-    << (tempPackageFileName ? tempPackageFileName : "(NULL)") << std::endl);
-  if ( cmSystemTools::FileExists(tempPackageFileName) )
-    {
+                  << (tempPackageFileName ? tempPackageFileName : "(NULL)")
+                  << std::endl);
+  if (cmSystemTools::FileExists(tempPackageFileName)) {
     cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file"
-      << std::endl);
+                    << std::endl);
     cmSystemTools::RemoveFile(tempPackageFileName);
-    }
-  if ( cmSystemTools::IsOn(this->GetOption(
-        "CPACK_INCLUDE_TOPLEVEL_DIRECTORY")) )
-    {
+  }
+  if (cmSystemTools::IsOn(
+        this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
     tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
-    }
+  }
 
   // The files to be installed
   files = gl.GetFiles();
@@ -1114,12 +967,11 @@ int cmCPackGenerator::DoPackage()
    */
   packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
   toplevel = tempDirectory;
-  if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (!this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
-      << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
 
   /*
    * Copy the generated packages to final destination
@@ -1128,40 +980,33 @@ int cmCPackGenerator::DoPackage()
    *    (because the specific generator did 'normalize' it)
    */
   cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) ["
-                   <<packageFileNames.size()
-                   <<"]:"<<std::endl);
+                  << packageFileNames.size() << "]:" << std::endl);
   std::vector<std::string>::iterator it;
   /* now copy package one by one */
-  for (it=packageFileNames.begin();it!=packageFileNames.end();++it)
-    {
+  for (it = packageFileNames.begin(); it != packageFileNames.end(); ++it) {
     std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
     tempPackageFileName = it->c_str();
-    tmpPF += "/"+cmSystemTools::GetFilenameName(*it);
+    tmpPF += "/" + cmSystemTools::GetFilenameName(*it);
     const char* packageFileName = tmpPF.c_str();
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): "
-        << (tempPackageFileName ? tempPackageFileName : "(NULL)" )
-        << " to "
-        << (packageFileName ? packageFileName : "(NULL)")
-        << std::endl);
-    if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
-        packageFileName) )
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: "
-          << (tempPackageFileName ? tempPackageFileName : "(NULL)" )
-          << " to "
-          << (packageFileName ? packageFileName : "(NULL)")
-          << std::endl);
+                    << (tempPackageFileName ? tempPackageFileName : "(NULL)")
+                    << " to " << (packageFileName ? packageFileName : "(NULL)")
+                    << std::endl);
+    if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
+                                            packageFileName)) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR, "Problem copying the package: "
+          << (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to "
+          << (packageFileName ? packageFileName : "(NULL)") << std::endl);
       return 0;
-      }
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
-        << packageFileName
-        << " generated." << std::endl);
     }
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
+                    << packageFileName << " generated." << std::endl);
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
 {
   this->MakefileMap = mf;
@@ -1169,17 +1014,14 @@ int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
   // set the running generator name
   this->SetOption("CPACK_GENERATOR", this->Name.c_str());
   // Load the project specific config file
-  const char* config =
-    this->GetOption("CPACK_PROJECT_CONFIG_FILE");
-  if(config)
-    {
+  const char* config = this->GetOption("CPACK_PROJECT_CONFIG_FILE");
+  if (config) {
     mf->ReadListFile(config);
-    }
+  }
   int result = this->InitializeInternal();
-  if (cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return 0;
-    }
+  }
 
   // If a generator subclass did not already set this option in its
   // InitializeInternal implementation, and the project did not already set
@@ -1189,154 +1031,126 @@ int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
   return result;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::InitializeInternal()
 {
   return 1;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::IsSet(const std::string& name) const
 {
   return this->MakefileMap->IsSet(name);
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::IsOn(const std::string& name) const
 {
   return cmSystemTools::IsOn(GetOption(name));
 }
 
-//----------------------------------------------------------------------
 const char* cmCPackGenerator::GetOption(const std::string& op) const
 {
   const char* ret = this->MakefileMap->GetDefinition(op);
-  if(!ret)
-    {
+  if (!ret) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                  "Warning, GetOption return NULL for: "
-                  << op
-                  << std::endl);
-    }
+                  "Warning, GetOption return NULL for: " << op << std::endl);
+  }
   return ret;
 }
 
-//----------------------------------------------------------------------
 std::vector<std::string> cmCPackGenerator::GetOptions() const
 {
   return this->MakefileMap->GetDefinitions();
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::PackageFiles()
 {
   return 0;
 }
 
-//----------------------------------------------------------------------
 const char* cmCPackGenerator::GetInstallPath()
 {
-  if ( !this->InstallPath.empty() )
-    {
+  if (!this->InstallPath.empty()) {
     return this->InstallPath.c_str();
-    }
+  }
 #if defined(_WIN32) && !defined(__CYGWIN__)
   const char* prgfiles = cmsys::SystemTools::GetEnv("ProgramFiles");
   const char* sysDrive = cmsys::SystemTools::GetEnv("SystemDrive");
-  if ( prgfiles )
-    {
+  if (prgfiles) {
     this->InstallPath = prgfiles;
-    }
-  else if ( sysDrive )
-    {
+  } else if (sysDrive) {
     this->InstallPath = sysDrive;
     this->InstallPath += "/Program Files";
-    }
-  else
-    {
+  } else {
     this->InstallPath = "c:/Program Files";
-    }
+  }
   this->InstallPath += "/";
   this->InstallPath += this->GetOption("CPACK_PACKAGE_NAME");
   this->InstallPath += "-";
   this->InstallPath += this->GetOption("CPACK_PACKAGE_VERSION");
 #elif defined(__HAIKU__)
   char dir[B_PATH_NAME_LENGTH];
-  if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) == B_OK)
-    {
+  if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) ==
+      B_OK) {
     this->InstallPath = dir;
-    }
-  else
-    {
+  } else {
     this->InstallPath = "/boot/system";
-    }
+  }
 #else
   this->InstallPath = "/usr/local/";
 #endif
   return this->InstallPath.c_str();
 }
 
-//----------------------------------------------------------------------
 const char* cmCPackGenerator::GetPackagingInstallPrefix()
 {
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "GetPackagingInstallPrefix: '"
-    << this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'" << std::endl);
+                  << this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'"
+                  << std::endl);
 
   return this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
 }
 
-//----------------------------------------------------------------------
 std::string cmCPackGenerator::FindTemplate(const char* name)
 {
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
-    << (name ? name : "(NULL)") << std::endl);
+                  << (name ? name : "(NULL)") << std::endl);
   std::string ffile = this->MakefileMap->GetModulesFile(name);
-  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
-    << ffile << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile
+                                                          << std::endl);
   return ffile;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::ConfigureString(const std::string& inString,
-  std::string& outString)
+                                       std::string& outString)
 {
-  this->MakefileMap->ConfigureString(inString,
-    outString, true, false);
+  this->MakefileMap->ConfigureString(inString, outString, true, false);
   return true;
 }
 
-//----------------------------------------------------------------------
-bool cmCPackGenerator::ConfigureFile(const char* inName,
-  const char* outName, bool copyOnly /* = false */)
+bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName,
+                                     bool copyOnly /* = false */)
 {
-  return this->MakefileMap->ConfigureFile(inName, outName,
-    copyOnly, true, false) == 1;
+  return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true,
+                                          false) == 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::CleanTemporaryDirectory()
 {
-  std::string tempInstallDirectoryWithPostfix
-    = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
+  std::string tempInstallDirectoryWithPostfix =
+    this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
   const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str();
-  if(cmsys::SystemTools::FileExists(tempInstallDirectory))
-    {
+  if (cmsys::SystemTools::FileExists(tempInstallDirectory)) {
     cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-                  "- Clean temporary : "
-                  << tempInstallDirectory << std::endl);
-    if(!cmSystemTools::RepeatedRemoveDirectory(tempInstallDirectory))
-      {
+                  "- Clean temporary : " << tempInstallDirectory << std::endl);
+    if (!cmSystemTools::RepeatedRemoveDirectory(tempInstallDirectory)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-                    "Problem removing temporary directory: " <<
-                    tempInstallDirectory
-                    << std::endl);
+                    "Problem removing temporary directory: "
+                      << tempInstallDirectory << std::endl);
       return 0;
-      }
     }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 cmInstalledFile const* cmCPackGenerator::GetInstalledFile(
   std::string const& name) const
 {
@@ -1344,351 +1158,273 @@ cmInstalledFile const* cmCPackGenerator::GetInstalledFile(
   return cm->GetInstalledFile(name);
 }
 
-//----------------------------------------------------------------------
 int cmCPackGenerator::PrepareGroupingKind()
 {
   // find a component package method specified by the user
   ComponentPackageMethod method = UNKNOWN_COMPONENT_PACKAGE_METHOD;
 
-  if(this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))
-    {
+  if (this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE")) {
     method = ONE_PACKAGE;
-    }
+  }
 
-  if(this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS"))
-    {
+  if (this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS")) {
     method = ONE_PACKAGE_PER_COMPONENT;
-    }
+  }
 
-  if(this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP"))
-    {
+  if (this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP")) {
     method = ONE_PACKAGE_PER_GROUP;
-    }
+  }
 
   std::string groupingType;
 
   // Second way to specify grouping
   if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
-     groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
+    groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
   }
 
-  if (!groupingType.empty())
-    {
-    cmCPackLogger(cmCPackLog::LOG_VERBOSE,  "["
-        << this->Name << "]"
-        << " requested component grouping = "<< groupingType <<std::endl);
-    if (groupingType == "ALL_COMPONENTS_IN_ONE")
-      {
+  if (!groupingType.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
+                    << this->Name << "]"
+                    << " requested component grouping = " << groupingType
+                    << std::endl);
+    if (groupingType == "ALL_COMPONENTS_IN_ONE") {
       method = ONE_PACKAGE;
-      }
-    else if (groupingType == "IGNORE")
-      {
+    } else if (groupingType == "IGNORE") {
       method = ONE_PACKAGE_PER_COMPONENT;
-      }
-    else if (groupingType == "ONE_PER_GROUP")
-      {
+    } else if (groupingType == "ONE_PER_GROUP") {
       method = ONE_PACKAGE_PER_GROUP;
-      }
-    else
-      {
-      cmCPackLogger(cmCPackLog::LOG_WARNING, "["
+    } else {
+      cmCPackLogger(
+        cmCPackLog::LOG_WARNING, "["
           << this->Name << "]"
-          << " requested component grouping type <"<< groupingType
+          << " requested component grouping type <" << groupingType
           << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)"
           << std::endl);
-      }
     }
+  }
 
   // Some components were defined but NO group
   // fallback to default if not group based
-  if(method == ONE_PACKAGE_PER_GROUP &&
-     this->ComponentGroups.empty() && !this->Components.empty())
-    {
-    if(componentPackageMethod == ONE_PACKAGE)
-      {
+  if (method == ONE_PACKAGE_PER_GROUP && this->ComponentGroups.empty() &&
+      !this->Components.empty()) {
+    if (componentPackageMethod == ONE_PACKAGE) {
       method = ONE_PACKAGE;
-      }
-    else
-      {
+    } else {
       method = ONE_PACKAGE_PER_COMPONENT;
-      }
-    cmCPackLogger(cmCPackLog::LOG_WARNING, "["
-         << this->Name << "]"
-         << " One package per component group requested, "
-         << "but NO component groups exist: Ignoring component group."
-         << std::endl);
     }
+    cmCPackLogger(
+      cmCPackLog::LOG_WARNING, "["
+        << this->Name << "]"
+        << " One package per component group requested, "
+        << "but NO component groups exist: Ignoring component group."
+        << std::endl);
+  }
 
   // if user specified packaging method, override the default packaging method
-  if(method != UNKNOWN_COMPONENT_PACKAGE_METHOD)
-    {
+  if (method != UNKNOWN_COMPONENT_PACKAGE_METHOD) {
     componentPackageMethod = method;
-    }
+  }
 
-  const char* method_names[] =
-    {
-    "ALL_COMPONENTS_IN_ONE",
-    "IGNORE_GROUPS",
-    "ONE_PER_GROUP"
-    };
+  const char* method_names[] = { "ALL_COMPONENTS_IN_ONE", "IGNORE_GROUPS",
+                                 "ONE_PER_GROUP" };
 
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE,  "["
-        << this->Name << "]"
-        << " requested component grouping = "
-        << method_names[componentPackageMethod]
-        << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
+                  << this->Name << "]"
+                  << " requested component grouping = "
+                  << method_names[componentPackageMethod] << std::endl);
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 std::string cmCPackGenerator::GetComponentInstallDirNameSuffix(
-    const std::string& componentName) {
+  const std::string& componentName)
+{
   return componentName;
 }
-//----------------------------------------------------------------------
 std::string cmCPackGenerator::GetComponentPackageFileName(
-    const std::string& initialPackageFileName,
-    const std::string& groupOrComponentName,
-    bool isGroupName) {
+  const std::string& initialPackageFileName,
+  const std::string& groupOrComponentName, bool isGroupName)
+{
 
   /*
    * the default behavior is to use the
    * component [group] name as a suffix
    */
-  std::string suffix="-"+groupOrComponentName;
+  std::string suffix = "-" + groupOrComponentName;
   /* check if we should use DISPLAY name */
-  std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME";
-  if (IsOn(dispNameVar))
-    {
+  std::string dispNameVar = "CPACK_" + Name + "_USE_DISPLAY_NAME_IN_FILENAME";
+  if (IsOn(dispNameVar)) {
     /* the component Group case */
-    if (isGroupName)
-      {
-      std::string groupDispVar = "CPACK_COMPONENT_GROUP_"
-          + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
+    if (isGroupName) {
+      std::string groupDispVar = "CPACK_COMPONENT_GROUP_" +
+        cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
       const char* groupDispName = GetOption(groupDispVar);
-      if (groupDispName)
-        {
-        suffix = "-"+std::string(groupDispName);
-        }
+      if (groupDispName) {
+        suffix = "-" + std::string(groupDispName);
       }
+    }
     /* the [single] component case */
-    else
-      {
-      std::string dispVar = "CPACK_COMPONENT_"
-           + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
-            const char* dispName = GetOption(dispVar);
-            if(dispName)
-              {
-              suffix = "-"+std::string(dispName);
-              }
-            }
+    else {
+      std::string dispVar = "CPACK_COMPONENT_" +
+        cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
+      const char* dispName = GetOption(dispVar);
+      if (dispName) {
+        suffix = "-" + std::string(dispName);
       }
+    }
+  }
   return initialPackageFileName + suffix;
 }
 
-//----------------------------------------------------------------------
 enum cmCPackGenerator::CPackSetDestdirSupport
 cmCPackGenerator::SupportsSetDestdir() const
 {
   return cmCPackGenerator::SETDESTDIR_SUPPORTED;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::SupportsAbsoluteDestination() const
 {
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::SupportsComponentInstallation() const
 {
   return false;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackGenerator::WantsComponentInstallation() const
 {
-  return (!IsOn("CPACK_MONOLITHIC_INSTALL")
-        && SupportsComponentInstallation()
-        // check that we have at least one group or component
-        && (!this->ComponentGroups.empty() || !this->Components.empty()));
+  return (!IsOn("CPACK_MONOLITHIC_INSTALL") && SupportsComponentInstallation()
+          // check that we have at least one group or component
+          && (!this->ComponentGroups.empty() || !this->Components.empty()));
 }
 
-//----------------------------------------------------------------------
-cmCPackInstallationType*
-cmCPackGenerator::GetInstallationType(const std::string& projectName,
-                                      const std::string& name)
+cmCPackInstallationType* cmCPackGenerator::GetInstallationType(
+  const std::string& projectName, const std::string& name)
 {
-  (void) projectName;
+  (void)projectName;
   bool hasInstallationType = this->InstallationTypes.count(name) != 0;
-  cmCPackInstallationType *installType = &this->InstallationTypes[name];
-  if (!hasInstallationType)
-    {
+  cmCPackInstallationType* installType = &this->InstallationTypes[name];
+  if (!hasInstallationType) {
     // Define the installation type
-    std::string macroPrefix = "CPACK_INSTALL_TYPE_"
-      + cmsys::SystemTools::UpperCase(name);
+    std::string macroPrefix =
+      "CPACK_INSTALL_TYPE_" + cmsys::SystemTools::UpperCase(name);
     installType->Name = name;
 
-    const char* displayName
-      = this->GetOption(macroPrefix + "_DISPLAY_NAME");
-    if (displayName && *displayName)
-      {
+    const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+    if (displayName && *displayName) {
       installType->DisplayName = displayName;
-      }
-    else
-      {
+    } else {
       installType->DisplayName = installType->Name;
-      }
-
-    installType->Index = static_cast<unsigned>(
-      this->InstallationTypes.size());
     }
+
+    installType->Index = static_cast<unsigned>(this->InstallationTypes.size());
+  }
   return installType;
 }
 
-//----------------------------------------------------------------------
-cmCPackComponent*
-cmCPackGenerator::GetComponent(const std::string& projectName,
-                               const std::string& name)
+cmCPackComponent* cmCPackGenerator::GetComponent(
+  const std::string& projectName, const std::string& name)
 {
   bool hasComponent = this->Components.count(name) != 0;
-  cmCPackComponent *component = &this->Components[name];
-  if (!hasComponent)
-    {
+  cmCPackComponent* component = &this->Components[name];
+  if (!hasComponent) {
     // Define the component
-    std::string macroPrefix = "CPACK_COMPONENT_"
-      + cmsys::SystemTools::UpperCase(name);
+    std::string macroPrefix =
+      "CPACK_COMPONENT_" + cmsys::SystemTools::UpperCase(name);
     component->Name = name;
-    const char* displayName
-      = this->GetOption(macroPrefix + "_DISPLAY_NAME");
-    if (displayName && *displayName)
-      {
+    const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+    if (displayName && *displayName) {
       component->DisplayName = displayName;
-      }
-    else
-      {
+    } else {
       component->DisplayName = component->Name;
-      }
-    component->IsHidden
-      = this->IsOn(macroPrefix + "_HIDDEN");
-    component->IsRequired
-      = this->IsOn(macroPrefix + "_REQUIRED");
-    component->IsDisabledByDefault
-      = this->IsOn(macroPrefix + "_DISABLED");
-    component->IsDownloaded
-      = this->IsOn(macroPrefix + "_DOWNLOADED")
-        || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
-
-    const char* archiveFile = this->GetOption(macroPrefix +
-                                               "_ARCHIVE_FILE");
-    if (archiveFile && *archiveFile)
-      {
+    }
+    component->IsHidden = this->IsOn(macroPrefix + "_HIDDEN");
+    component->IsRequired = this->IsOn(macroPrefix + "_REQUIRED");
+    component->IsDisabledByDefault = this->IsOn(macroPrefix + "_DISABLED");
+    component->IsDownloaded = this->IsOn(macroPrefix + "_DOWNLOADED") ||
+      cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
+
+    const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE");
+    if (archiveFile && *archiveFile) {
       component->ArchiveFile = archiveFile;
-      }
+    }
 
     const char* groupName = this->GetOption(macroPrefix + "_GROUP");
-    if (groupName && *groupName)
-      {
+    if (groupName && *groupName) {
       component->Group = GetComponentGroup(projectName, groupName);
       component->Group->Components.push_back(component);
-      }
-    else
-      {
+    } else {
       component->Group = 0;
-      }
+    }
 
-    const char* description
-      = this->GetOption(macroPrefix + "_DESCRIPTION");
-    if (description && *description)
-      {
+    const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
+    if (description && *description) {
       component->Description = description;
-      }
+    }
 
     // Determine the installation types.
-    const char *installTypes
-      = this->GetOption(macroPrefix + "_INSTALL_TYPES");
-    if (installTypes && *installTypes)
-      {
+    const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES");
+    if (installTypes && *installTypes) {
       std::vector<std::string> installTypesVector;
       cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
       std::vector<std::string>::iterator installTypesIt;
       for (installTypesIt = installTypesVector.begin();
-           installTypesIt != installTypesVector.end();
-           ++installTypesIt)
-        {
+           installTypesIt != installTypesVector.end(); ++installTypesIt) {
         component->InstallationTypes.push_back(
           this->GetInstallationType(projectName, *installTypesIt));
-        }
       }
+    }
 
     // Determine the component dependencies.
-    const char *depends = this->GetOption(macroPrefix + "_DEPENDS");
-    if (depends && *depends)
-      {
+    const char* depends = this->GetOption(macroPrefix + "_DEPENDS");
+    if (depends && *depends) {
       std::vector<std::string> dependsVector;
       cmSystemTools::ExpandListArgument(depends, dependsVector);
       std::vector<std::string>::iterator dependIt;
-      for (dependIt = dependsVector.begin();
-           dependIt != dependsVector.end();
-           ++dependIt)
-        {
-        cmCPackComponent *child = GetComponent(projectName,
-                                               *dependIt);
+      for (dependIt = dependsVector.begin(); dependIt != dependsVector.end();
+           ++dependIt) {
+        cmCPackComponent* child = GetComponent(projectName, *dependIt);
         component->Dependencies.push_back(child);
         child->ReverseDependencies.push_back(component);
-        }
       }
     }
+  }
   return component;
 }
 
-//----------------------------------------------------------------------
-cmCPackComponentGroup*
-cmCPackGenerator::GetComponentGroup(const std::string& projectName,
-                                    const std::string& name)
+cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup(
+  const std::string& projectName, const std::string& name)
 {
-  (void) projectName;
-  std::string macroPrefix = "CPACK_COMPONENT_GROUP_"
-        + cmsys::SystemTools::UpperCase(name);
+  (void)projectName;
+  std::string macroPrefix =
+    "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(name);
   bool hasGroup = this->ComponentGroups.count(name) != 0;
-  cmCPackComponentGroup *group = &this->ComponentGroups[name];
-  if (!hasGroup)
-    {
+  cmCPackComponentGroup* group = &this->ComponentGroups[name];
+  if (!hasGroup) {
     // Define the group
     group->Name = name;
-    const char* displayName
-      = this->GetOption(macroPrefix + "_DISPLAY_NAME");
-    if (displayName && *displayName)
-      {
+    const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+    if (displayName && *displayName) {
       group->DisplayName = displayName;
-      }
-    else
-      {
+    } else {
       group->DisplayName = group->Name;
-      }
+    }
 
-    const char* description
-      = this->GetOption(macroPrefix + "_DESCRIPTION");
-    if (description && *description)
-      {
+    const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
+    if (description && *description) {
       group->Description = description;
-      }
-    group->IsBold
-      = this->IsOn(macroPrefix + "_BOLD_TITLE");
-    group->IsExpandedByDefault
-      = this->IsOn(macroPrefix + "_EXPANDED");
-    const char* parentGroupName
-      = this->GetOption(macroPrefix + "_PARENT_GROUP");
-    if (parentGroupName && *parentGroupName)
-      {
+    }
+    group->IsBold = this->IsOn(macroPrefix + "_BOLD_TITLE");
+    group->IsExpandedByDefault = this->IsOn(macroPrefix + "_EXPANDED");
+    const char* parentGroupName =
+      this->GetOption(macroPrefix + "_PARENT_GROUP");
+    if (parentGroupName && *parentGroupName) {
       group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
       group->ParentGroup->Subgroups.push_back(group);
-      }
-    else
-      {
+    } else {
       group->ParentGroup = 0;
-      }
     }
+  }
   return group;
 }
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index 907bb1e..ce93715 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -14,34 +14,35 @@
 #define cmCPackGenerator_h
 
 #include "cmObject.h"
+
 #include "cmSystemTools.h"
 #include <map>
 #include <vector>
 
 #include "cmCPackComponentGroup.h" // cmCPackComponent and friends
-  // Forward declarations are insufficient since we use them in
-  // std::map data members below...
+// Forward declarations are insufficient since we use them in
+// std::map data members below...
 
-#define cmCPackTypeMacro(klass, superclass) \
-  cmTypeMacro(klass, superclass); \
-  static cmCPackGenerator* CreateGenerator() { return new klass; } \
+#define cmCPackTypeMacro(klass, superclass)                                   \
+  cmTypeMacro(klass, superclass);                                             \
+  static cmCPackGenerator* CreateGenerator() { return new klass; }            \
   class cmCPackTypeMacro_UseTrailingSemicolon
 
-#define cmCPackLogger(logType, msg) \
-  do { \
-    std::ostringstream cmCPackLog_msg; \
-    cmCPackLog_msg << msg; \
-    this->Logger->Log(logType, __FILE__, __LINE__,\
-                      cmCPackLog_msg.str().c_str());\
-  } while ( 0 )
+#define cmCPackLogger(logType, msg)                                           \
+  do {                                                                        \
+    std::ostringstream cmCPackLog_msg;                                        \
+    cmCPackLog_msg << msg;                                                    \
+    this->Logger->Log(logType, __FILE__, __LINE__,                            \
+                      cmCPackLog_msg.str().c_str());                          \
+  } while (0)
 
 #ifdef cerr
-#  undef cerr
+#undef cerr
 #endif
 #define cerr no_cerr_use_cmCPack_Log
 
 #ifdef cout
-#  undef cout
+#undef cout
 #endif
 #define cout no_cout_use_cmCPack_Log
 
@@ -61,8 +62,10 @@ public:
    * If verbose then more information is printed out
    */
   void SetVerbose(bool val)
-    { this->GeneratorVerbose = val ?
-      cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
+  {
+    this->GeneratorVerbose =
+      val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
+  }
 
   /**
    * Returns true if the generator may work on this system.
@@ -156,7 +159,7 @@ protected:
    *         default is "componentName"
    */
   virtual std::string GetComponentInstallDirNameSuffix(
-      const std::string& componentName);
+    const std::string& componentName);
 
   /**
    * CPack specific generator may mangle CPACK_PACKAGE_FILE_NAME
@@ -168,9 +171,8 @@ protected:
    *            false otherwise
    */
   virtual std::string GetComponentPackageFileName(
-      const std::string& initialPackageFileName,
-      const std::string& groupOrComponentName,
-      bool isGroupName);
+    const std::string& initialPackageFileName,
+    const std::string& groupOrComponentName, bool isGroupName);
 
   /**
    * Package the list of files and/or components which
@@ -187,11 +189,10 @@ protected:
 
   virtual std::string FindTemplate(const char* name);
   virtual bool ConfigureFile(const char* inName, const char* outName,
-    bool copyOnly = false);
+                             bool copyOnly = false);
   virtual bool ConfigureString(const std::string& input, std::string& output);
   virtual int InitializeInternal();
 
-
   //! Run install commands if specified
   virtual int InstallProjectViaInstallCommands(
     bool setDestDir, const std::string& tempInstallDirectory);
@@ -206,7 +207,8 @@ protected:
    * The various level of support of
    * CPACK_SET_DESTDIR used by the generator.
    */
-  enum CPackSetDestdirSupport {
+  enum CPackSetDestdirSupport
+  {
     /* the generator works with or without it */
     SETDESTDIR_SUPPORTED,
     /* the generator works best if automatically handled */
@@ -250,13 +252,11 @@ protected:
    */
   virtual bool WantsComponentInstallation() const;
   virtual cmCPackInstallationType* GetInstallationType(
-                                                const std::string& projectName,
-                                                const std::string& name);
+    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);
+    const std::string& projectName, const std::string& name);
 
   cmSystemTools::OutputOption GeneratorVerbose;
   std::string Name;
@@ -323,6 +323,7 @@ protected:
   ComponentPackageMethod componentPackageMethod;
 
   cmCPackLog* Logger;
+
 private:
   cmMakefile* MakefileMap;
 };
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index 4626142..b17f52e 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -12,194 +12,167 @@
 
 #include "cmCPackGeneratorFactory.h"
 
+#include "IFW/cmCPackIFWGenerator.h"
+#include "cmCPack7zGenerator.h"
 #include "cmCPackGenerator.h"
+#include "cmCPackNSISGenerator.h"
+#include "cmCPackSTGZGenerator.h"
 #include "cmCPackTGZGenerator.h"
 #include "cmCPackTXZGenerator.h"
 #include "cmCPackTarBZip2Generator.h"
 #include "cmCPackTarCompressGenerator.h"
 #include "cmCPackZIPGenerator.h"
-#include "cmCPack7zGenerator.h"
-#include "cmCPackSTGZGenerator.h"
-#include "cmCPackNSISGenerator.h"
-#include "IFW/cmCPackIFWGenerator.h"
 
 #ifdef __APPLE__
-#  include "cmCPackDragNDropGenerator.h"
-#  include "cmCPackBundleGenerator.h"
-#  include "cmCPackPackageMakerGenerator.h"
-#  include "cmCPackOSXX11Generator.h"
+#include "cmCPackBundleGenerator.h"
+#include "cmCPackDragNDropGenerator.h"
+#include "cmCPackOSXX11Generator.h"
+#include "cmCPackPackageMakerGenerator.h"
 #endif
 
 #ifdef __CYGWIN__
-#  include "cmCPackCygwinBinaryGenerator.h"
-#  include "cmCPackCygwinSourceGenerator.h"
+#include "cmCPackCygwinBinaryGenerator.h"
+#include "cmCPackCygwinSourceGenerator.h"
 #endif
 
-#if !defined(_WIN32) \
- && !defined(__QNXNTO__) && !defined(__BEOS__) && !defined(__HAIKU__)
-#  include "cmCPackDebGenerator.h"
-#  include "cmCPackRPMGenerator.h"
+#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) &&         \
+  !defined(__HAIKU__)
+#include "cmCPackDebGenerator.h"
+#include "cmCPackRPMGenerator.h"
 #endif
 
 #ifdef _WIN32
-#  include "WiX/cmCPackWIXGenerator.h"
+#include "WiX/cmCPackWIXGenerator.h"
 #endif
 
-#include "cmCPackLog.h"
 #include "cmAlgorithms.h"
+#include "cmCPackLog.h"
 
-
-//----------------------------------------------------------------------
 cmCPackGeneratorFactory::cmCPackGeneratorFactory()
 {
-  if (cmCPackTGZGenerator::CanGenerate())
-    {
+  if (cmCPackTGZGenerator::CanGenerate()) {
     this->RegisterGenerator("TGZ", "Tar GZip compression",
-      cmCPackTGZGenerator::CreateGenerator);
-    }
-  if (cmCPackTXZGenerator::CanGenerate())
-    {
+                            cmCPackTGZGenerator::CreateGenerator);
+  }
+  if (cmCPackTXZGenerator::CanGenerate()) {
     this->RegisterGenerator("TXZ", "Tar XZ compression",
-      cmCPackTXZGenerator::CreateGenerator);
-    }
-  if (cmCPackSTGZGenerator::CanGenerate())
-    {
+                            cmCPackTXZGenerator::CreateGenerator);
+  }
+  if (cmCPackSTGZGenerator::CanGenerate()) {
     this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression",
-      cmCPackSTGZGenerator::CreateGenerator);
-    }
-  if (cmCPackNSISGenerator::CanGenerate())
-    {
+                            cmCPackSTGZGenerator::CreateGenerator);
+  }
+  if (cmCPackNSISGenerator::CanGenerate()) {
     this->RegisterGenerator("NSIS", "Null Soft Installer",
-      cmCPackNSISGenerator::CreateGenerator);
+                            cmCPackNSISGenerator::CreateGenerator);
     this->RegisterGenerator("NSIS64", "Null Soft Installer (64-bit)",
-      cmCPackNSISGenerator::CreateGenerator64);
-    }
-  if (cmCPackIFWGenerator::CanGenerate())
-    {
+                            cmCPackNSISGenerator::CreateGenerator64);
+  }
+  if (cmCPackIFWGenerator::CanGenerate()) {
     this->RegisterGenerator("IFW", "Qt Installer Framework",
-      cmCPackIFWGenerator::CreateGenerator);
-    }
+                            cmCPackIFWGenerator::CreateGenerator);
+  }
 #ifdef __CYGWIN__
-  if (cmCPackCygwinBinaryGenerator::CanGenerate())
-    {
+  if (cmCPackCygwinBinaryGenerator::CanGenerate()) {
     this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer",
                             cmCPackCygwinBinaryGenerator::CreateGenerator);
-    }
-  if (cmCPackCygwinSourceGenerator::CanGenerate())
-    {
+  }
+  if (cmCPackCygwinSourceGenerator::CanGenerate()) {
     this->RegisterGenerator("CygwinSource", "Cygwin Source Installer",
                             cmCPackCygwinSourceGenerator::CreateGenerator);
-    }
+  }
 #endif
 
-  if (cmCPackZIPGenerator::CanGenerate())
-    {
+  if (cmCPackZIPGenerator::CanGenerate()) {
     this->RegisterGenerator("ZIP", "ZIP file format",
-      cmCPackZIPGenerator::CreateGenerator);
-    }
-  if (cmCPack7zGenerator::CanGenerate())
-    {
+                            cmCPackZIPGenerator::CreateGenerator);
+  }
+  if (cmCPack7zGenerator::CanGenerate()) {
     this->RegisterGenerator("7Z", "7-Zip file format",
-      cmCPack7zGenerator::CreateGenerator);
-    }
+                            cmCPack7zGenerator::CreateGenerator);
+  }
 #ifdef _WIN32
-  if (cmCPackWIXGenerator::CanGenerate())
-    {
+  if (cmCPackWIXGenerator::CanGenerate()) {
     this->RegisterGenerator("WIX", "MSI file format via WiX tools",
-      cmCPackWIXGenerator::CreateGenerator);
-    }
+                            cmCPackWIXGenerator::CreateGenerator);
+  }
 #endif
-  if (cmCPackTarBZip2Generator::CanGenerate())
-    {
+  if (cmCPackTarBZip2Generator::CanGenerate()) {
     this->RegisterGenerator("TBZ2", "Tar BZip2 compression",
-      cmCPackTarBZip2Generator::CreateGenerator);
-    }
-  if (cmCPackTarCompressGenerator::CanGenerate())
-    {
+                            cmCPackTarBZip2Generator::CreateGenerator);
+  }
+  if (cmCPackTarCompressGenerator::CanGenerate()) {
     this->RegisterGenerator("TZ", "Tar Compress compression",
-      cmCPackTarCompressGenerator::CreateGenerator);
-    }
+                            cmCPackTarCompressGenerator::CreateGenerator);
+  }
 #ifdef __APPLE__
-  if (cmCPackDragNDropGenerator::CanGenerate())
-    {
+  if (cmCPackDragNDropGenerator::CanGenerate()) {
     this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop",
-      cmCPackDragNDropGenerator::CreateGenerator);
-    }
-  if (cmCPackBundleGenerator::CanGenerate())
-    {
+                            cmCPackDragNDropGenerator::CreateGenerator);
+  }
+  if (cmCPackBundleGenerator::CanGenerate()) {
     this->RegisterGenerator("Bundle", "Mac OSX bundle",
-      cmCPackBundleGenerator::CreateGenerator);
-    }
-  if (cmCPackPackageMakerGenerator::CanGenerate())
-    {
+                            cmCPackBundleGenerator::CreateGenerator);
+  }
+  if (cmCPackPackageMakerGenerator::CanGenerate()) {
     this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer",
-      cmCPackPackageMakerGenerator::CreateGenerator);
-    }
-  if (cmCPackOSXX11Generator::CanGenerate())
-    {
+                            cmCPackPackageMakerGenerator::CreateGenerator);
+  }
+  if (cmCPackOSXX11Generator::CanGenerate()) {
     this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
-      cmCPackOSXX11Generator::CreateGenerator);
-    }
+                            cmCPackOSXX11Generator::CreateGenerator);
+  }
 #endif
-#if !defined(_WIN32) \
-  && !defined(__QNXNTO__) && !defined(__BEOS__) && !defined(__HAIKU__)
-  if (cmCPackDebGenerator::CanGenerate())
-    {
+#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) &&         \
+  !defined(__HAIKU__)
+  if (cmCPackDebGenerator::CanGenerate()) {
     this->RegisterGenerator("DEB", "Debian packages",
-      cmCPackDebGenerator::CreateGenerator);
-    }
-  if (cmCPackRPMGenerator::CanGenerate())
-    {
+                            cmCPackDebGenerator::CreateGenerator);
+  }
+  if (cmCPackRPMGenerator::CanGenerate()) {
     this->RegisterGenerator("RPM", "RPM packages",
-      cmCPackRPMGenerator::CreateGenerator);
-    }
+                            cmCPackRPMGenerator::CreateGenerator);
+  }
 #endif
 }
 
-//----------------------------------------------------------------------
 cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
 {
   cmDeleteAll(this->Generators);
 }
 
-//----------------------------------------------------------------------
 cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
-                                                const std::string& name)
+  const std::string& name)
 {
   cmCPackGenerator* gen = this->NewGeneratorInternal(name);
-  if ( !gen )
-    {
+  if (!gen) {
     return 0;
-    }
+  }
   this->Generators.push_back(gen);
   gen->SetLogger(this->Logger);
   return gen;
 }
 
-//----------------------------------------------------------------------
 cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
   const std::string& name)
 {
-  cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it
-    = this->GeneratorCreators.find(name);
-  if ( it == this->GeneratorCreators.end() )
-    {
+  cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it =
+    this->GeneratorCreators.find(name);
+  if (it == this->GeneratorCreators.end()) {
     return 0;
-    }
+  }
   return (it->second)();
 }
 
-//----------------------------------------------------------------------
-void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name,
-  const char* generatorDescription,
+void cmCPackGeneratorFactory::RegisterGenerator(
+  const std::string& name, const char* generatorDescription,
   CreateGeneratorCall* createGenerator)
 {
-  if ( !createGenerator )
-    {
+  if (!createGenerator) {
     cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
-      "Cannot register generator" << std::endl);
+                "Cannot register generator" << std::endl);
     return;
-    }
+  }
   this->GeneratorCreators[name] = createGenerator;
   this->GeneratorDescriptions[name] = generatorDescription;
 }
diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h
index 010777f..a55ec6e 100644
--- a/Source/CPack/cmCPackGeneratorFactory.h
+++ b/Source/CPack/cmCPackGeneratorFactory.h
@@ -37,14 +37,16 @@ public:
   typedef cmCPackGenerator* CreateGeneratorCall();
 
   void RegisterGenerator(const std::string& name,
-    const char* generatorDescription,
-    CreateGeneratorCall* createGenerator);
+                         const char* generatorDescription,
+                         CreateGeneratorCall* createGenerator);
 
   void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
 
   typedef std::map<std::string, std::string> DescriptionsMap;
   const DescriptionsMap& GetGeneratorsList() const
-    { return this->GeneratorDescriptions; }
+  {
+    return this->GeneratorDescriptions;
+  }
 
 private:
   cmCPackGenerator* NewGeneratorInternal(const std::string& name);
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index 7633ac2..ff06eb8 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -15,7 +15,6 @@
 #include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
 
-//----------------------------------------------------------------------
 cmCPackLog::cmCPackLog()
 {
   this->Verbose = false;
@@ -33,48 +32,40 @@ cmCPackLog::cmCPackLog()
   this->LogOutputCleanup = false;
 }
 
-//----------------------------------------------------------------------
 cmCPackLog::~cmCPackLog()
 {
   this->SetLogOutputStream(0);
 }
 
-//----------------------------------------------------------------------
 void cmCPackLog::SetLogOutputStream(std::ostream* os)
 {
-  if ( this->LogOutputCleanup && this->LogOutput )
-    {
+  if (this->LogOutputCleanup && this->LogOutput) {
     delete this->LogOutput;
-    }
+  }
   this->LogOutputCleanup = false;
   this->LogOutput = os;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackLog::SetLogOutputFile(const char* fname)
 {
-  cmGeneratedFileStream *cg = 0;
-  if ( fname )
-    {
+  cmGeneratedFileStream* cg = 0;
+  if (fname) {
     cg = new cmGeneratedFileStream(fname);
-    }
-  if ( cg && !*cg )
-    {
+  }
+  if (cg && !*cg) {
     delete cg;
     cg = 0;
-    }
+  }
   this->SetLogOutputStream(cg);
-  if ( !cg )
-    {
+  if (!cg) {
     return false;
-    }
+  }
   this->LogOutputCleanup = true;
   return true;
 }
 
-//----------------------------------------------------------------------
-void cmCPackLog::Log(int tag, const char* file, int line,
-  const char* msg, size_t length)
+void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
+                     size_t length)
 {
   // By default no logging
   bool display = false;
@@ -82,144 +73,118 @@ void cmCPackLog::Log(int tag, const char* file, int line,
   // Display file and line number if debug
   bool useFileAndLine = this->Debug;
 
-  bool output  = false;
-  bool debug   = false;
+  bool output = false;
+  bool debug = false;
   bool warning = false;
-  bool error   = false;
+  bool error = false;
   bool verbose = false;
 
   // When writing in file, add list of tags whenever tag changes.
   std::string tagString;
   bool needTagString = false;
-  if ( this->LogOutput && this->LastTag != tag )
-    {
+  if (this->LogOutput && this->LastTag != tag) {
     needTagString = true;
-    }
+  }
 
-  if ( tag & LOG_OUTPUT )
-    {
+  if (tag & LOG_OUTPUT) {
     output = true;
     display = true;
-    if ( needTagString )
-      {
-      if (!tagString.empty()) { tagString += ","; }
-      tagString = "VERBOSE";
+    if (needTagString) {
+      if (!tagString.empty()) {
+        tagString += ",";
       }
+      tagString = "VERBOSE";
     }
-  if ( tag & LOG_WARNING )
-    {
+  }
+  if (tag & LOG_WARNING) {
     warning = true;
     display = true;
-    if ( needTagString )
-      {
-      if (!tagString.empty()) { tagString += ","; }
-      tagString = "WARNING";
+    if (needTagString) {
+      if (!tagString.empty()) {
+        tagString += ",";
       }
+      tagString = "WARNING";
     }
-  if ( tag & LOG_ERROR )
-    {
+  }
+  if (tag & LOG_ERROR) {
     error = true;
     display = true;
-    if ( needTagString )
-      {
-      if (!tagString.empty()) { tagString += ","; }
-      tagString = "ERROR";
+    if (needTagString) {
+      if (!tagString.empty()) {
+        tagString += ",";
       }
+      tagString = "ERROR";
     }
-  if ( tag & LOG_DEBUG && this->Debug )
-    {
+  }
+  if (tag & LOG_DEBUG && this->Debug) {
     debug = true;
     display = true;
-    if ( needTagString )
-      {
-      if (!tagString.empty()) { tagString += ","; }
-      tagString = "DEBUG";
+    if (needTagString) {
+      if (!tagString.empty()) {
+        tagString += ",";
       }
-    useFileAndLine = true;
+      tagString = "DEBUG";
     }
-  if ( tag & LOG_VERBOSE && this->Verbose )
-    {
+    useFileAndLine = true;
+  }
+  if (tag & LOG_VERBOSE && this->Verbose) {
     verbose = true;
     display = true;
-    if ( needTagString )
-      {
-      if (!tagString.empty()) { tagString += ","; }
-      tagString = "VERBOSE";
+    if (needTagString) {
+      if (!tagString.empty()) {
+        tagString += ",";
       }
+      tagString = "VERBOSE";
     }
-  if ( this->Quiet )
-    {
+  }
+  if (this->Quiet) {
     display = false;
+  }
+  if (this->LogOutput) {
+    if (needTagString) {
+      *this->LogOutput << "[" << file << ":" << line << " " << tagString
+                       << "] ";
     }
-  if ( this->LogOutput )
-    {
-    if ( needTagString )
-      {
-      *this->LogOutput << "[" << file << ":" << line << " "
-        << tagString << "] ";
-      }
     this->LogOutput->write(msg, length);
-    }
+  }
   this->LastTag = tag;
-  if ( !display )
-    {
+  if (!display) {
     return;
-    }
-  if ( this->NewLine )
-    {
-    if ( error && !this->ErrorPrefix.empty() )
-      {
+  }
+  if (this->NewLine) {
+    if (error && !this->ErrorPrefix.empty()) {
       *this->DefaultError << this->ErrorPrefix;
-      }
-    else if ( warning && !this->WarningPrefix.empty() )
-      {
+    } else if (warning && !this->WarningPrefix.empty()) {
       *this->DefaultError << this->WarningPrefix;
-      }
-    else if ( output && !this->OutputPrefix.empty() )
-      {
+    } else if (output && !this->OutputPrefix.empty()) {
       *this->DefaultOutput << this->OutputPrefix;
-      }
-    else if ( verbose && !this->VerbosePrefix.empty() )
-      {
+    } else if (verbose && !this->VerbosePrefix.empty()) {
       *this->DefaultOutput << this->VerbosePrefix;
-      }
-    else if ( debug && !this->DebugPrefix.empty() )
-      {
+    } else if (debug && !this->DebugPrefix.empty()) {
       *this->DefaultOutput << this->DebugPrefix;
-      }
-    else if ( !this->Prefix.empty() )
-      {
+    } else if (!this->Prefix.empty()) {
       *this->DefaultOutput << this->Prefix;
-      }
-    if ( useFileAndLine )
-      {
-      if ( error || warning )
-        {
+    }
+    if (useFileAndLine) {
+      if (error || warning) {
         *this->DefaultError << file << ":" << line << " ";
-        }
-      else
-        {
+      } else {
         *this->DefaultOutput << file << ":" << line << " ";
-        }
       }
     }
-  if ( error || warning )
-    {
+  }
+  if (error || warning) {
     this->DefaultError->write(msg, length);
     this->DefaultError->flush();
-    }
-  else
-    {
+  } else {
     this->DefaultOutput->write(msg, length);
     this->DefaultOutput->flush();
-    }
-  if ( msg[length-1] == '\n' || length > 2 )
-    {
+  }
+  if (msg[length - 1] == '\n' || length > 2) {
     this->NewLine = true;
-    }
+  }
 
-  if ( error )
-    {
+  if (error) {
     cmSystemTools::SetErrorOccured();
-    }
+  }
 }
diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h
index 7a7ff58..41871cc 100644
--- a/Source/CPack/cmCPackLog.h
+++ b/Source/CPack/cmCPackLog.h
@@ -15,24 +15,23 @@
 
 #include "cmObject.h"
 
-#define cmCPack_Log(ctSelf, logType, msg) \
-  do { \
-  std::ostringstream cmCPackLog_msg; \
-  cmCPackLog_msg << msg; \
-  (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str());\
-  } while ( 0 )
+#define cmCPack_Log(ctSelf, logType, msg)                                     \
+  do {                                                                        \
+    std::ostringstream cmCPackLog_msg;                                        \
+    cmCPackLog_msg << msg;                                                    \
+    (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str()); \
+  } while (0)
 
 #ifdef cerr
-#  undef cerr
+#undef cerr
 #endif
 #define cerr no_cerr_use_cmCPack_Log
 
 #ifdef cout
-#  undef cout
+#undef cout
 #endif
 #define cout no_cout_use_cmCPack_Log
 
-
 /** \class cmCPackLog
  * \brief A container for CPack generators
  *
@@ -45,7 +44,8 @@ public:
   cmCPackLog();
   ~cmCPackLog();
 
-  enum __log_tags {
+  enum __log_tags
+  {
     NOTAG = 0,
     LOG_OUTPUT = 0x1,
     LOG_VERBOSE = 0x2,
@@ -56,19 +56,19 @@ public:
 
   //! Various signatures for logging.
   void Log(const char* file, int line, const char* msg)
-    {
+  {
     this->Log(LOG_OUTPUT, file, line, msg);
-    }
+  }
   void Log(const char* file, int line, const char* msg, size_t length)
-    {
+  {
     this->Log(LOG_OUTPUT, file, line, msg, length);
-    }
+  }
   void Log(int tag, const char* file, int line, const char* msg)
-    {
+  {
     this->Log(tag, file, line, msg, strlen(msg));
-    }
+  }
   void Log(int tag, const char* file, int line, const char* msg,
-    size_t length);
+           size_t length);
 
   //! Set Verbose
   void VerboseOn() { this->SetVerbose(true); }
@@ -126,11 +126,11 @@ private:
   std::string WarningPrefix;
   std::string ErrorPrefix;
 
-  std::ostream *DefaultOutput;
-  std::ostream *DefaultError;
+  std::ostream* DefaultOutput;
+  std::ostream* DefaultError;
 
   std::string LogOutputFileName;
-  std::ostream *LogOutput;
+  std::ostream* LogOutput;
   // Do we need to cleanup log output stream
   bool LogOutputCleanup;
 };
@@ -139,13 +139,16 @@ class cmCPackLogWrite
 {
 public:
   cmCPackLogWrite(const char* data, size_t length)
-    : Data(data), Length(length) {}
+    : Data(data)
+    , Length(length)
+  {
+  }
 
   const char* Data;
   size_t Length;
 };
 
-inline std::ostream& operator<< (std::ostream& os, const cmCPackLogWrite& c)
+inline std::ostream& operator<<(std::ostream& os, const cmCPackLogWrite& c)
 {
   os.write(c.Data, c.Length);
   os.flush();
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 5ba639f..9fa588d 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -12,58 +12,53 @@
 
 #include "cmCPackNSISGenerator.h"
 
+#include "cmCPackComponentGroup.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCPackLog.h"
-#include "cmCPackComponentGroup.h"
+#include "cmSystemTools.h"
 
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/Directory.hxx>
+#include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
+#include <cmsys/SystemTools.hxx>
 
 /* NSIS uses different command line syntax on Windows and others */
 #ifdef _WIN32
-# define NSIS_OPT "/"
+#define NSIS_OPT "/"
 #else
-# define NSIS_OPT "-"
+#define NSIS_OPT "-"
 #endif
 
-//----------------------------------------------------------------------
 cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64)
 {
   Nsis64 = nsis64;
 }
 
-//----------------------------------------------------------------------
 cmCPackNSISGenerator::~cmCPackNSISGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackNSISGenerator::PackageFiles()
 {
   // TODO: Fix nsis to force out file name
 
   std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
-  if (nsisInFileName.empty())
-    {
+  if (nsisInFileName.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "CPack error: Could not find NSIS installer template file."
-      << std::endl);
+                  "CPack error: Could not find NSIS installer template file."
+                    << std::endl);
     return false;
-    }
-  std::string nsisInInstallOptions
-    = this->FindTemplate("NSIS.InstallOptions.ini.in");
-  if (nsisInInstallOptions.empty())
-    {
+  }
+  std::string nsisInInstallOptions =
+    this->FindTemplate("NSIS.InstallOptions.ini.in");
+  if (nsisInInstallOptions.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "CPack error: Could not find NSIS installer options file."
-      << std::endl);
+                  "CPack error: Could not find NSIS installer options file."
+                    << std::endl);
     return false;
-    }
+  }
 
   std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   std::string tmpFile = nsisFileName;
@@ -72,93 +67,80 @@ int cmCPackNSISGenerator::PackageFiles()
   nsisFileName += "/project.nsi";
   std::ostringstream str;
   std::vector<std::string>::const_iterator it;
-  for ( it = files.begin(); it != files.end(); ++ it )
-    {
-    std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(),
-                                                    it->c_str());
-    if (!this->Components.empty())
-      {
+  for (it = files.begin(); it != files.end(); ++it) {
+    std::string fileN =
+      cmSystemTools::RelativePath(toplevel.c_str(), it->c_str());
+    if (!this->Components.empty()) {
       // Strip off the component part of the path.
-      fileN = fileN.substr(fileN.find('/')+1, std::string::npos);
-      }
-    cmSystemTools::ReplaceString(fileN, "/", "\\");
-    str << "  Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
+      fileN = fileN.substr(fileN.find('/') + 1, std::string::npos);
     }
-  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
-    << str.str() << std::endl);
+    std::replace(fileN.begin(), fileN.end(), '/', '\\');
+    str << "  Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
+  }
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << 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);
   std::vector<std::string>::const_iterator sit;
   std::ostringstream dstr;
-  for ( sit = dirs.begin(); sit != dirs.end(); ++ sit )
-    {
+  for (sit = dirs.begin(); sit != dirs.end(); ++sit) {
     std::string componentName;
-    std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(),
-                                                    sit->c_str());
-    if ( fileN.empty() )
-      {
+    std::string fileN =
+      cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str());
+    if (fileN.empty()) {
       continue;
-      }
-    if (!Components.empty())
-      {
+    }
+    if (!Components.empty()) {
       // If this is a component installation, strip off the component
       // part of the path.
       std::string::size_type slash = fileN.find('/');
-      if (slash != std::string::npos)
-        {
+      if (slash != std::string::npos) {
         // If this is a component installation, determine which component it
         // is.
         componentName = fileN.substr(0, slash);
 
         // Strip off the component part of the path.
-        fileN = fileN.substr(slash+1, std::string::npos);
-        }
+        fileN = fileN.substr(slash + 1, std::string::npos);
       }
-    cmSystemTools::ReplaceString(fileN, "/", "\\");
+    }
+    std::replace(fileN.begin(), fileN.end(), '/', '\\');
     dstr << "  RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
-    if (!componentName.empty())
-      {
+    if (!componentName.empty()) {
       this->Components[componentName].Directories.push_back(fileN);
-      }
     }
-  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
-    << dstr.str() << std::endl);
-  this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES",
-                          dstr.str().c_str());
-
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName
-    << " to " << nsisFileName << std::endl);
-  if(this->IsSet("CPACK_NSIS_MUI_ICON")
-     || this->IsSet("CPACK_NSIS_MUI_UNIICON"))
-    {
+  }
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str()
+                                                          << std::endl);
+  this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
+
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
+                  << nsisInFileName << " to " << nsisFileName << std::endl);
+  if (this->IsSet("CPACK_NSIS_MUI_ICON") ||
+      this->IsSet("CPACK_NSIS_MUI_UNIICON")) {
     std::string installerIconCode;
-    if(this->IsSet("CPACK_NSIS_MUI_ICON"))
-      {
+    if (this->IsSet("CPACK_NSIS_MUI_ICON")) {
       installerIconCode += "!define MUI_ICON \"";
       installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON");
       installerIconCode += "\"\n";
-      }
-    if(this->IsSet("CPACK_NSIS_MUI_UNIICON"))
-      {
+    }
+    if (this->IsSet("CPACK_NSIS_MUI_UNIICON")) {
       installerIconCode += "!define MUI_UNICON \"";
       installerIconCode += this->GetOption("CPACK_NSIS_MUI_UNIICON");
       installerIconCode += "\"\n";
-      }
+    }
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE",
                             installerIconCode.c_str());
-    }
-  if(this->IsSet("CPACK_PACKAGE_ICON"))
-    {
+  }
+  if (this->IsSet("CPACK_PACKAGE_ICON")) {
     std::string installerIconCode = "!define MUI_HEADERIMAGE_BITMAP \"";
     installerIconCode += this->GetOption("CPACK_PACKAGE_ICON");
     installerIconCode += "\"\n";
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE",
                             installerIconCode.c_str());
-    }
+  }
 
-  if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP"))
-    {
+  if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP")) {
     std::string installerBitmapCode =
       "!define MUI_WELCOMEFINISHPAGE_BITMAP \"";
     installerBitmapCode +=
@@ -166,10 +148,9 @@ int cmCPackNSISGenerator::PackageFiles()
     installerBitmapCode += "\"\n";
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE",
                             installerBitmapCode.c_str());
-    }
+  }
 
-  if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP"))
-    {
+  if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP")) {
     std::string installerBitmapCode =
       "!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"";
     installerBitmapCode +=
@@ -177,10 +158,9 @@ int cmCPackNSISGenerator::PackageFiles()
     installerBitmapCode += "\"\n";
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE",
                             installerBitmapCode.c_str());
-    }
+  }
 
-  if(this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN"))
-    {
+  if (this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN")) {
     std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\";
     installerRunCode += this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
     installerRunCode += "\\";
@@ -188,11 +168,10 @@ int cmCPackNSISGenerator::PackageFiles()
     installerRunCode += "\"\n";
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE",
                             installerRunCode.c_str());
-    }
+  }
 
   // Setup all of the component sections
-  if (this->Components.empty())
-    {
+  if (this->Components.empty()) {
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", "");
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", "");
     this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", "");
@@ -201,9 +180,7 @@ int cmCPackNSISGenerator::PackageFiles()
     this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", "");
     this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", "");
     this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", "");
-    }
-  else
-    {
+  } else {
     std::string componentCode;
     std::string sectionList;
     std::string selectedVarsList;
@@ -216,66 +193,54 @@ int cmCPackNSISGenerator::PackageFiles()
 
     // Create installation types. The order is significant, so we first fill
     // in a vector based on the indices, and print them in that order.
-    std::vector<cmCPackInstallationType *>
-      installTypes(this->InstallationTypes.size());
+    std::vector<cmCPackInstallationType*> installTypes(
+      this->InstallationTypes.size());
     std::map<std::string, cmCPackInstallationType>::iterator installTypeIt;
     for (installTypeIt = this->InstallationTypes.begin();
-         installTypeIt != this->InstallationTypes.end();
-         ++installTypeIt)
-      {
-      installTypes[installTypeIt->second.Index-1] = &installTypeIt->second;
-      }
-    std::vector<cmCPackInstallationType *>::iterator installTypeIt2;
+         installTypeIt != this->InstallationTypes.end(); ++installTypeIt) {
+      installTypes[installTypeIt->second.Index - 1] = &installTypeIt->second;
+    }
+    std::vector<cmCPackInstallationType*>::iterator installTypeIt2;
     for (installTypeIt2 = installTypes.begin();
-         installTypeIt2 != installTypes.end();
-         ++installTypeIt2)
-      {
+         installTypeIt2 != installTypes.end(); ++installTypeIt2) {
       installTypesCode += "InstType \"";
       installTypesCode += (*installTypeIt2)->DisplayName;
       installTypesCode += "\"\n";
-      }
+    }
 
     // Create installation groups first
     std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
     for (groupIt = this->ComponentGroups.begin();
-         groupIt != this->ComponentGroups.end();
-         ++groupIt)
-      {
-      if (groupIt->second.ParentGroup == 0)
-        {
+         groupIt != this->ComponentGroups.end(); ++groupIt) {
+      if (groupIt->second.ParentGroup == 0) {
         componentCode +=
           this->CreateComponentGroupDescription(&groupIt->second, macrosOut);
-        }
+      }
 
       // Add the group description, if any.
-      if (!groupIt->second.Description.empty())
-        {
-        groupDescriptions += "  !insertmacro MUI_DESCRIPTION_TEXT ${"
-          + groupIt->first + "} \""
-          + this->TranslateNewlines(groupIt->second.Description) + "\"\n";
-        }
+      if (!groupIt->second.Description.empty()) {
+        groupDescriptions += "  !insertmacro MUI_DESCRIPTION_TEXT ${" +
+          groupIt->first + "} \"" +
+          this->TranslateNewlines(groupIt->second.Description) + "\"\n";
       }
+    }
 
     // Create the remaining components, which aren't associated with groups.
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt = this->Components.begin();
-         compIt != this->Components.end();
-         ++compIt)
-      {
-      if (compIt->second.Files.empty())
-        {
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
+      if (compIt->second.Files.empty()) {
         // NSIS cannot cope with components that have no files.
         continue;
-        }
+      }
 
       anyDownloadedComponents =
         anyDownloadedComponents || compIt->second.IsDownloaded;
 
-      if (!compIt->second.Group)
-        {
-        componentCode
-          += this->CreateComponentDescription(&compIt->second, macrosOut);
-        }
+      if (!compIt->second.Group) {
+        componentCode +=
+          this->CreateComponentDescription(&compIt->second, macrosOut);
+      }
 
       // Add this component to the various section lists.
       sectionList += "  !insertmacro \"${MacroName}\" \"";
@@ -285,41 +250,33 @@ int cmCPackNSISGenerator::PackageFiles()
       selectedVarsList += "Var " + compIt->first + "_was_installed\n";
 
       // Add the component description, if any.
-      if (!compIt->second.Description.empty())
-        {
-        componentDescriptions += "  !insertmacro MUI_DESCRIPTION_TEXT ${"
-          + compIt->first + "} \""
-          + this->TranslateNewlines(compIt->second.Description) + "\"\n";
-        }
+      if (!compIt->second.Description.empty()) {
+        componentDescriptions += "  !insertmacro MUI_DESCRIPTION_TEXT ${" +
+          compIt->first + "} \"" +
+          this->TranslateNewlines(compIt->second.Description) + "\"\n";
       }
+    }
 
     componentCode += macrosOut.str();
 
-    if (componentDescriptions.empty() && groupDescriptions.empty())
-      {
+    if (componentDescriptions.empty() && groupDescriptions.empty()) {
       // Turn off the "Description" box
       this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC",
                               "!define MUI_COMPONENTSPAGE_NODESC");
-      }
-    else
-      {
-      componentDescriptions =
-        "!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN\n"
-        + componentDescriptions
-        + groupDescriptions
-        + "!insertmacro MUI_FUNCTION_DESCRIPTION_END\n";
+    } else {
+      componentDescriptions = "!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN\n" +
+        componentDescriptions + groupDescriptions +
+        "!insertmacro MUI_FUNCTION_DESCRIPTION_END\n";
       this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC",
                               componentDescriptions.c_str());
-      }
+    }
 
-    if (anyDownloadedComponents)
-      {
+    if (anyDownloadedComponents) {
       defines += "!define CPACK_USES_DOWNLOAD\n";
-      if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE")))
-        {
+      if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE"))) {
         defines += "!define CPACK_NSIS_ADD_REMOVE\n";
-        }
       }
+    }
 
     this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES",
                             installTypesCode.c_str());
@@ -333,7 +290,7 @@ int cmCPackNSISGenerator::PackageFiles()
     this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS",
                             selectedVarsList.c_str());
     this->SetOption("CPACK_NSIS_DEFINES", defines.c_str());
-    }
+  }
 
   this->ConfigureFile(nsisInInstallOptions.c_str(),
                       nsisInstallOptions.c_str());
@@ -341,479 +298,409 @@ int cmCPackNSISGenerator::PackageFiles()
   std::string nsisCmd = "\"";
   nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
   nsisCmd += "\" \"" + nsisFileName + "\"";
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd
-    << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl);
   std::string output;
   int retVal = 1;
-  bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output,
-    &retVal, 0, this->GeneratorVerbose, 0);
-  if ( !res || retVal )
-    {
+  bool res = cmSystemTools::RunSingleCommand(
+    nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
+  if (!res || retVal) {
     cmGeneratedFileStream ofs(tmpFile.c_str());
     ofs << "# Run command: " << nsisCmd << std::endl
-      << "# Output:" << std::endl
-      << output << std::endl;
+        << "# Output:" << std::endl
+        << output << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
-      << nsisCmd << std::endl
-      << "Please check " << tmpFile << " for errors" << std::endl);
+                    << nsisCmd << std::endl
+                    << "Please check " << tmpFile << " for errors"
+                    << std::endl);
     return 0;
-    }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackNSISGenerator::InitializeInternal()
 {
-  if ( cmSystemTools::IsOn(this->GetOption(
-        "CPACK_INCLUDE_TOPLEVEL_DIRECTORY")) )
-    {
-    cmCPackLogger(cmCPackLog::LOG_WARNING,
+  if (cmSystemTools::IsOn(
+        this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
+    cmCPackLogger(
+      cmCPackLog::LOG_WARNING,
       "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. "
       "This option will be reset to 0 (for this generator only)."
-      << std::endl);
+        << std::endl);
     this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", 0);
-    }
+  }
 
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()"
-    << std::endl);
+                  << std::endl);
   std::vector<std::string> path;
   std::string nsisPath;
   bool gotRegValue = false;
 
 #ifdef _WIN32
-  if (Nsis64)
-    {
-    if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
-      "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath,
-      cmsys::SystemTools::KeyWOW64_64) )
-      {
+  if (Nsis64) {
+    if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+                          "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode",
+                          nsisPath, cmsys::SystemTools::KeyWOW64_64)) {
       gotRegValue = true;
-      }
-    if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
-      "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
-      cmsys::SystemTools::KeyWOW64_64) )
-      {
+    }
+    if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+                          "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
+                          cmsys::SystemTools::KeyWOW64_64)) {
       gotRegValue = true;
-      }
     }
-  if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
-      "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath,
-      cmsys::SystemTools::KeyWOW64_32) )
-    {
+  }
+  if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+                        "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode",
+                        nsisPath, cmsys::SystemTools::KeyWOW64_32)) {
     gotRegValue = true;
-    }
-  if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
-      "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath) )
-    {
+  }
+  if (!gotRegValue &&
+      cmsys::SystemTools::ReadRegistryValue(
+        "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath)) {
     gotRegValue = true;
-    }
-  if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
-      "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
-      cmsys::SystemTools::KeyWOW64_32) )
-    {
+  }
+  if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+                        "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
+                        cmsys::SystemTools::KeyWOW64_32)) {
     gotRegValue = true;
-    }
-  if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue(
-      "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath) )
-    {
+  }
+  if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
+                        "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath)) {
     gotRegValue = true;
-    }
+  }
 
-  if (gotRegValue)
-    {
+  if (gotRegValue) {
     path.push_back(nsisPath);
-    }
+  }
 #endif
 
   nsisPath = cmSystemTools::FindProgram("makensis", path, false);
 
-  if ( nsisPath.empty() )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
+  if (nsisPath.empty()) {
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR,
       "Cannot find NSIS compiler makensis: likely it is not installed, "
       "or not in your PATH"
-      << std::endl);
-
-    if (!gotRegValue)
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-         "Could not read NSIS registry value. This is usually caused by "
-         "NSIS not being installed. Please install NSIS from "
-         "http://nsis.sourceforge.net"
-         << std::endl);
-      }
+        << std::endl);
+
+    if (!gotRegValue) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR,
+        "Could not read NSIS registry value. This is usually caused by "
+        "NSIS not being installed. Please install NSIS from "
+        "http://nsis.sourceforge.net"
+          << std::endl);
+    }
 
     return 0;
-    }
+  }
 
   std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION";
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: "
-    << nsisCmd << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " << nsisCmd
+                                                               << std::endl);
   std::string output;
   int retVal = 1;
   bool resS = cmSystemTools::RunSingleCommand(
     nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
   cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
   cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
-  if ( !resS || retVal ||
-      (!versionRex.find(output) && !versionRexCVS.find(output))
-     )
-    {
+  if (!resS || retVal ||
+      (!versionRex.find(output) && !versionRexCVS.find(output))) {
     const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     std::string tmpFile = topDir ? topDir : ".";
     tmpFile += "/NSISOutput.log";
     cmGeneratedFileStream ofs(tmpFile.c_str());
     ofs << "# Run command: " << nsisCmd << std::endl
-      << "# Output:" << std::endl
-      << output << std::endl;
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Problem checking NSIS version with command: "
-      << nsisCmd << std::endl
-      << "Please check " << tmpFile << " for errors" << std::endl);
+        << "# Output:" << std::endl
+        << output << std::endl;
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: "
+        << nsisCmd << std::endl
+        << "Please check " << tmpFile << " for errors" << std::endl);
     return 0;
-    }
-  if ( versionRex.find(output))
-    {
+  }
+  if (versionRex.find(output)) {
     double nsisVersion = atof(versionRex.match(1).c_str());
     double minNSISVersion = 2.09;
-    cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: "
-      << nsisVersion << std::endl);
-    if ( nsisVersion < minNSISVersion )
-      {
+    cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " << nsisVersion
+                                                          << std::endl);
+    if (nsisVersion < minNSISVersion) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "CPack requires NSIS Version 2.09 or greater.  "
-        "NSIS found on the system was: "
-        << nsisVersion << std::endl);
+                    "CPack requires NSIS Version 2.09 or greater.  "
+                    "NSIS found on the system was: "
+                      << nsisVersion << std::endl);
       return 0;
-      }
     }
-  if ( versionRexCVS.find(output))
-    {
+  }
+  if (versionRexCVS.find(output)) {
     // No version check for NSIS cvs build
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS "
-      << versionRexCVS.match(1) << std::endl);
-    }
+                    << versionRexCVS.match(1) << std::endl);
+  }
   this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
   this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
-  const char* cpackPackageExecutables
-    = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
-  const char* cpackPackageDeskTopLinks
-    = this->GetOption("CPACK_CREATE_DESKTOP_LINKS");
-  const char* cpackNsisExecutablesDirectory
-    = this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
+  const char* cpackPackageExecutables =
+    this->GetOption("CPACK_PACKAGE_EXECUTABLES");
+  const char* cpackPackageDeskTopLinks =
+    this->GetOption("CPACK_CREATE_DESKTOP_LINKS");
+  const char* cpackNsisExecutablesDirectory =
+    this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
   std::vector<std::string> cpackPackageDesktopLinksVector;
-  if(cpackPackageDeskTopLinks)
-    {
+  if (cpackPackageDeskTopLinks) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
-                << cpackPackageDeskTopLinks << std::endl);
-
-    cmSystemTools::
-      ExpandListArgument(cpackPackageDeskTopLinks,
-                         cpackPackageDesktopLinksVector);
-    for(std::vector<std::string>::iterator i =
-          cpackPackageDesktopLinksVector.begin(); i !=
-          cpackPackageDesktopLinksVector.end(); ++i)
-      {
-       cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
-                << *i << std::endl);
-      }
+                    << cpackPackageDeskTopLinks << std::endl);
+
+    cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks,
+                                      cpackPackageDesktopLinksVector);
+    for (std::vector<std::string>::iterator i =
+           cpackPackageDesktopLinksVector.begin();
+         i != cpackPackageDesktopLinksVector.end(); ++i) {
+      cmCPackLogger(cmCPackLog::LOG_DEBUG,
+                    "CPACK_CREATE_DESKTOP_LINKS: " << *i << std::endl);
     }
-  else
-    {
+  } else {
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
-                  << "not set" << std::endl);
-    }
+                    << "not set" << std::endl);
+  }
 
   std::ostringstream str;
   std::ostringstream deleteStr;
 
-  if ( cpackPackageExecutables )
-    {
+  if (cpackPackageExecutables) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
-      << cpackPackageExecutables << "." << std::endl);
+                    << cpackPackageExecutables << "." << std::endl);
     std::vector<std::string> cpackPackageExecutablesVector;
     cmSystemTools::ExpandListArgument(cpackPackageExecutables,
-      cpackPackageExecutablesVector);
-    if ( cpackPackageExecutablesVector.size() % 2 != 0 )
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
+                                      cpackPackageExecutablesVector);
+    if (cpackPackageExecutablesVector.size() % 2 != 0) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR,
         "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
-        "<icon name>." << std::endl);
+        "<icon name>."
+          << std::endl);
       return 0;
-      }
+    }
     std::vector<std::string>::iterator it;
-    for ( it = cpackPackageExecutablesVector.begin();
-          it != cpackPackageExecutablesVector.end();
-          ++it )
-      {
+    for (it = cpackPackageExecutablesVector.begin();
+         it != cpackPackageExecutablesVector.end(); ++it) {
       std::string execName = *it;
-      ++ it;
+      ++it;
       std::string linkName = *it;
-      str << "  CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
-        << linkName << ".lnk\" \"$INSTDIR\\"
-        << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\""
-        << std::endl;
+      str << "  CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
+          << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\"
+          << execName << ".exe\"" << std::endl;
       deleteStr << "  Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
-        << ".lnk\"" << std::endl;
+                << ".lnk\"" << std::endl;
       // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
       // if so add a desktop link
-      if(!cpackPackageDesktopLinksVector.empty() &&
-         std::find(cpackPackageDesktopLinksVector.begin(),
-                   cpackPackageDesktopLinksVector.end(),
-                   execName)
-         != cpackPackageDesktopLinksVector.end())
-        {
+      if (!cpackPackageDesktopLinksVector.empty() &&
+          std::find(cpackPackageDesktopLinksVector.begin(),
+                    cpackPackageDesktopLinksVector.end(),
+                    execName) != cpackPackageDesktopLinksVector.end()) {
         str << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
-        str << "    CreateShortCut \"$DESKTOP\\"
-            << linkName << ".lnk\" \"$INSTDIR\\"
-            << cpackNsisExecutablesDirectory << "\\" << execName << ".exe\""
-            << std::endl;
+        str << "    CreateShortCut \"$DESKTOP\\" << linkName
+            << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\"
+            << execName << ".exe\"" << std::endl;
         deleteStr << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
-        deleteStr << "    Delete \"$DESKTOP\\" << linkName
-                  << ".lnk\"" << std::endl;
-        }
+        deleteStr << "    Delete \"$DESKTOP\\" << linkName << ".lnk\""
+                  << std::endl;
       }
     }
+  }
 
   this->CreateMenuLinks(str, deleteStr);
   this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
-  this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS",
-                          deleteStr.str().c_str());
+  this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str());
 
   this->SetOptionIfNotSet("CPACK_NSIS_COMPRESSOR", "lzma");
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
-void cmCPackNSISGenerator::CreateMenuLinks( std::ostringstream& str,
-                                            std::ostringstream& deleteStr)
+void cmCPackNSISGenerator::CreateMenuLinks(std::ostringstream& str,
+                                           std::ostringstream& deleteStr)
 {
-  const char* cpackMenuLinks
-    = this->GetOption("CPACK_NSIS_MENU_LINKS");
-  if(!cpackMenuLinks)
-    {
+  const char* cpackMenuLinks = this->GetOption("CPACK_NSIS_MENU_LINKS");
+  if (!cpackMenuLinks) {
     return;
-    }
-  cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackMenuLinks: "
-                << cpackMenuLinks << "." << std::endl);
+  }
+  cmCPackLogger(cmCPackLog::LOG_DEBUG,
+                "The cpackMenuLinks: " << cpackMenuLinks << "." << std::endl);
   std::vector<std::string> cpackMenuLinksVector;
-  cmSystemTools::ExpandListArgument(cpackMenuLinks,
-                                    cpackMenuLinksVector);
-  if ( cpackMenuLinksVector.size() % 2 != 0 )
-    {
+  cmSystemTools::ExpandListArgument(cpackMenuLinks, cpackMenuLinksVector);
+  if (cpackMenuLinksVector.size() % 2 != 0) {
     cmCPackLogger(
       cmCPackLog::LOG_ERROR,
       "CPACK_NSIS_MENU_LINKS should contain pairs of <shortcut target> and "
-      "<shortcut label>." << std::endl);
+      "<shortcut label>."
+        << std::endl);
     return;
-    }
+  }
 
-  static cmsys::RegularExpression
-    urlRegex("^(mailto:|(ftps?|https?|news)://).*$");
+  static cmsys::RegularExpression urlRegex(
+    "^(mailto:|(ftps?|https?|news)://).*$");
 
   std::vector<std::string>::iterator it;
-  for ( it = cpackMenuLinksVector.begin();
-        it != cpackMenuLinksVector.end();
-        ++it )
-    {
+  for (it = cpackMenuLinksVector.begin(); it != cpackMenuLinksVector.end();
+       ++it) {
     std::string sourceName = *it;
     const bool url = urlRegex.find(sourceName);
 
     // Convert / to \ in filenames, but not in urls:
     //
-    if(!url)
-      {
-      cmSystemTools::ReplaceString(sourceName, "/", "\\");
-      }
+    if (!url) {
+      std::replace(sourceName.begin(), sourceName.end(), '/', '\\');
+    }
 
-    ++ it;
+    ++it;
     std::string linkName = *it;
-    if(!url)
-      {
-      str << "  CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
-          << linkName << ".lnk\" \"$INSTDIR\\" << sourceName << "\""
-          << std::endl;
+    if (!url) {
+      str << "  CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
+          << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl;
       deleteStr << "  Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
                 << ".lnk\"" << std::endl;
-      }
-    else
-      {
-      str << "  WriteINIStr \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
-          << linkName << ".url\" \"InternetShortcut\" \"URL\" \""
-          << sourceName << "\""
+    } else {
+      str << "  WriteINIStr \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
+          << ".url\" \"InternetShortcut\" \"URL\" \"" << sourceName << "\""
           << std::endl;
       deleteStr << "  Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
                 << ".url\"" << std::endl;
-      }
+    }
     // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
     // if so add a desktop link
     std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
     desktop += linkName;
-    if(this->IsSet(desktop))
-      {
+    if (this->IsSet(desktop)) {
       str << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
-      str << "    CreateShortCut \"$DESKTOP\\"
-          << linkName << ".lnk\" \"$INSTDIR\\" << sourceName << "\""
-          << std::endl;
+      str << "    CreateShortCut \"$DESKTOP\\" << linkName
+          << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl;
       deleteStr << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
-      deleteStr << "    Delete \"$DESKTOP\\" << linkName
-                << ".lnk\"" << std::endl;
-      }
+      deleteStr << "    Delete \"$DESKTOP\\" << linkName << ".lnk\""
+                << std::endl;
     }
+  }
 }
 
-//----------------------------------------------------------------------
-bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
-  std::vector<std::string>& dirs)
+bool cmCPackNSISGenerator::GetListOfSubdirectories(
+  const char* topdir, std::vector<std::string>& dirs)
 {
   cmsys::Directory dir;
   dir.Load(topdir);
   size_t fileNum;
-  for (fileNum = 0; fileNum <  dir.GetNumberOfFiles(); ++fileNum)
-    {
-    if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
-        strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
-      {
+  for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
+    if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
+        strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
       std::string fullPath = topdir;
       fullPath += "/";
       fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
-      if(cmsys::SystemTools::FileIsDirectory(fullPath) &&
-        !cmsys::SystemTools::FileIsSymlink(fullPath))
-        {
-        if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs))
-          {
+      if (cmsys::SystemTools::FileIsDirectory(fullPath) &&
+          !cmsys::SystemTools::FileIsSymlink(fullPath)) {
+        if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs)) {
           return false;
-          }
         }
       }
     }
+  }
   dirs.push_back(topdir);
   return true;
 }
 
-//----------------------------------------------------------------------
 enum cmCPackGenerator::CPackSetDestdirSupport
 cmCPackNSISGenerator::SupportsSetDestdir() const
 {
   return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackNSISGenerator::SupportsAbsoluteDestination() const
 {
-        return false;
+  return false;
 }
 
-//----------------------------------------------------------------------
 bool cmCPackNSISGenerator::SupportsComponentInstallation() const
 {
-        return true;
+  return true;
 }
 
-//----------------------------------------------------------------------
-std::string
-cmCPackNSISGenerator::
-CreateComponentDescription(cmCPackComponent *component,
-                           std::ostringstream& macrosOut)
+std::string cmCPackNSISGenerator::CreateComponentDescription(
+  cmCPackComponent* component, std::ostringstream& macrosOut)
 {
   // Basic description of the component
   std::string componentCode = "Section ";
-  if (component->IsDisabledByDefault)
-    {
+  if (component->IsDisabledByDefault) {
     componentCode += "/o ";
-    }
+  }
   componentCode += "\"";
-  if (component->IsHidden)
-    {
+  if (component->IsHidden) {
     componentCode += "-";
-    }
+  }
   componentCode += component->DisplayName + "\" " + component->Name + "\n";
-  if (component->IsRequired)
-    {
+  if (component->IsRequired) {
     componentCode += "  SectionIn RO\n";
-    }
-  else if (!component->InstallationTypes.empty())
-    {
+  } else if (!component->InstallationTypes.empty()) {
     std::ostringstream out;
-    std::vector<cmCPackInstallationType *>::iterator installTypeIter;
+    std::vector<cmCPackInstallationType*>::iterator installTypeIter;
     for (installTypeIter = component->InstallationTypes.begin();
          installTypeIter != component->InstallationTypes.end();
-         ++installTypeIter)
-      {
+         ++installTypeIter) {
       out << " " << (*installTypeIter)->Index;
-      }
-    componentCode += "  SectionIn" + out.str() + "\n";
     }
+    componentCode += "  SectionIn" + out.str() + "\n";
+  }
   componentCode += "  SetOutPath \"$INSTDIR\"\n";
 
   // Create the actual installation commands
-  if (component->IsDownloaded)
-    {
-    if (component->ArchiveFile.empty())
-      {
+  if (component->IsDownloaded) {
+    if (component->ArchiveFile.empty()) {
       // Compute the name of the archive.
       std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
       packagesDir += ".dummy";
       std::ostringstream out;
-      out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
-        << "-" << component->Name << ".zip";
+      out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
+          << component->Name << ".zip";
       component->ArchiveFile = out.str();
-      }
+    }
 
     // Create the directory for the upload area
     const char* userUploadDirectory =
       this->GetOption("CPACK_UPLOAD_DIRECTORY");
     std::string uploadDirectory;
-    if (userUploadDirectory && *userUploadDirectory)
-      {
+    if (userUploadDirectory && *userUploadDirectory) {
       uploadDirectory = userUploadDirectory;
-      }
-    else
-      {
-      uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY");
+    } else {
+      uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
       uploadDirectory += "/CPackUploads";
-      }
-    if(!cmSystemTools::FileExists(uploadDirectory.c_str()))
-      {
-      if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
-        {
+    }
+    if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
+      if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Unable to create NSIS upload directory " << uploadDirectory
-          << std::endl);
+                      "Unable to create NSIS upload directory "
+                        << uploadDirectory << std::endl);
         return "";
-        }
       }
+    }
 
     // Remove the old archive, if one exists
     std::string archiveFile = uploadDirectory + '/' + component->ArchiveFile;
     cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-                  "-   Building downloaded component archive: "
-                  << archiveFile << std::endl);
-    if (cmSystemTools::FileExists(archiveFile.c_str(), true))
-      {
-        if (!cmSystemTools::RemoveFile(archiveFile))
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Unable to remove archive file " << archiveFile
-          << std::endl);
+                  "-   Building downloaded component archive: " << archiveFile
+                                                                << std::endl);
+    if (cmSystemTools::FileExists(archiveFile.c_str(), true)) {
+      if (!cmSystemTools::RemoveFile(archiveFile)) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file "
+                        << archiveFile << std::endl);
         return "";
-        }
       }
+    }
 
     // Find a ZIP program
-    if (!this->IsSet("ZIP_EXECUTABLE"))
-      {
+    if (!this->IsSet("ZIP_EXECUTABLE")) {
       this->ReadListFile("CPackZIP.cmake");
 
-      if (!this->IsSet("ZIP_EXECUTABLE"))
-        {
-        cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Unable to find ZIP program"
-          << std::endl);
+      if (!this->IsSet("ZIP_EXECUTABLE")) {
+        cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to find ZIP program"
+                        << std::endl);
         return "";
-        }
       }
+    }
 
     // The directory where this component's files reside
     std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
@@ -825,29 +712,25 @@ CreateComponentDescription(cmCPackComponent *component,
     // size of the installed component.
     std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
     zipListFileName += "/winZip.filelist";
-    bool needQuotesInFile
-      = cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
+    bool needQuotesInFile =
+      cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
     unsigned long totalSize = 0;
     { // the scope is needed for cmGeneratedFileStream
       cmGeneratedFileStream out(zipListFileName.c_str());
       std::vector<std::string>::iterator fileIt;
-      for (fileIt = component->Files.begin();
-           fileIt != component->Files.end();
-           ++fileIt)
-        {
-        if ( needQuotesInFile )
-          {
+      for (fileIt = component->Files.begin(); fileIt != component->Files.end();
+           ++fileIt) {
+        if (needQuotesInFile) {
           out << "\"";
-          }
+        }
         out << *fileIt;
-        if ( needQuotesInFile )
-          {
+        if (needQuotesInFile) {
           out << "\"";
-          }
+        }
         out << std::endl;
 
         totalSize += cmSystemTools::FileLength(dirName + *fileIt);
-        }
+      }
     }
 
     // Build the archive in the upload area
@@ -857,30 +740,30 @@ CreateComponentDescription(cmCPackComponent *component,
                                       zipListFileName.c_str());
     std::string output;
     int retVal = -1;
-    int res = cmSystemTools::RunSingleCommand(
-      cmd.c_str(), &output, &output,
-      &retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, 0);
-    if ( !res || retVal )
-    {
+    int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
+                                              &retVal, dirName.c_str(),
+                                              cmSystemTools::OUTPUT_NONE, 0);
+    if (!res || retVal) {
       std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
       tmpFile += "/CompressZip.log";
       cmGeneratedFileStream ofs(tmpFile.c_str());
       ofs << "# Run command: " << cmd << std::endl
-        << "# Output:" << std::endl
-        << output << std::endl;
+          << "# Output:" << std::endl
+          << output << std::endl;
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
-        << cmd << std::endl
-        << "Please check " << tmpFile << " for errors" << std::endl);
+                      << cmd << std::endl
+                      << "Please check " << tmpFile << " for errors"
+                      << std::endl);
       return "";
     }
 
     // Create the NSIS code to download this file on-the-fly.
     unsigned long totalSizeInKbytes = (totalSize + 512) / 1024;
-    if (totalSizeInKbytes == 0)
-      {
+    if (totalSizeInKbytes == 0) {
       totalSizeInKbytes = 1;
-      }
+    }
     std::ostringstream out;
+    /* clang-format off */
     out << "  AddSize " << totalSizeInKbytes << "\n"
         << "  Push \"" << component->ArchiveFile << "\"\n"
         << "  Call DownloadFile\n"
@@ -890,13 +773,12 @@ CreateComponentDescription(cmCPackComponent *component,
                      "  StrCmp $2 \"success\" +2 0\n"
                      "  MessageBox MB_OK \"Failed to unzip $2\"\n"
                      "  Delete $INSTDIR\\$0\n";
+    /* clang-format on */
     componentCode += out.str();
-    }
-  else
-    {
-    componentCode += "  File /r \"${INST_DIR}\\" +
-      component->Name + "\\*.*\"\n";
-    }
+  } else {
+    componentCode +=
+      "  File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n";
+  }
   componentCode += "SectionEnd\n";
 
   // Macro used to remove the component
@@ -905,32 +787,24 @@ CreateComponentDescription(cmCPackComponent *component,
             << component->Name << "\n";
   std::vector<std::string>::iterator pathIt;
   std::string path;
-  for (pathIt = component->Files.begin();
-       pathIt != component->Files.end();
-       ++pathIt)
-    {
+  for (pathIt = component->Files.begin(); pathIt != component->Files.end();
+       ++pathIt) {
     path = *pathIt;
-    cmSystemTools::ReplaceString(path, "/", "\\");
-    macrosOut << "  Delete \"$INSTDIR\\"
-              << path
-              << "\"\n";
-    }
+    std::replace(path.begin(), path.end(), '/', '\\');
+    macrosOut << "  Delete \"$INSTDIR\\" << path << "\"\n";
+  }
   for (pathIt = component->Directories.begin();
-       pathIt != component->Directories.end();
-       ++pathIt)
-    {
+       pathIt != component->Directories.end(); ++pathIt) {
     path = *pathIt;
-    cmSystemTools::ReplaceString(path, "/", "\\");
-    macrosOut << "  RMDir \"$INSTDIR\\"
-              << path
-              << "\"\n";
-    }
+    std::replace(path.begin(), path.end(), '/', '\\');
+    macrosOut << "  RMDir \"$INSTDIR\\" << path << "\"\n";
+  }
   macrosOut << "  noremove_" << component->Name << ":\n";
   macrosOut << "!macroend\n";
 
   // Macro used to select each of the components that this component
   // depends on.
-  std::set<cmCPackComponent *> visited;
+  std::set<cmCPackComponent*> visited;
   macrosOut << "!macro Select_" << component->Name << "_depends\n";
   macrosOut << CreateSelectionDependenciesDescription(component, visited);
   macrosOut << "!macroend\n";
@@ -944,24 +818,19 @@ CreateComponentDescription(cmCPackComponent *component,
   return componentCode;
 }
 
-//----------------------------------------------------------------------
-std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
-              (cmCPackComponent *component,
-               std::set<cmCPackComponent *>& visited)
+std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription(
+  cmCPackComponent* component, std::set<cmCPackComponent*>& visited)
 {
   // Don't visit a component twice
-  if (visited.count(component))
-    {
+  if (visited.count(component)) {
     return std::string();
-    }
+  }
   visited.insert(component);
 
   std::ostringstream out;
-  std::vector<cmCPackComponent *>::iterator dependIt;
+  std::vector<cmCPackComponent*>::iterator dependIt;
   for (dependIt = component->Dependencies.begin();
-       dependIt != component->Dependencies.end();
-       ++dependIt)
-    {
+       dependIt != component->Dependencies.end(); ++dependIt) {
     // Write NSIS code to select this dependency
     out << "  SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
     out << "  IntOp $0 $0 | ${SF_SELECTED}\n";
@@ -970,30 +839,24 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
         << "_selected 0 + ${SF_SELECTED}\n";
     // Recurse
     out << CreateSelectionDependenciesDescription(*dependIt, visited).c_str();
-    }
+  }
 
   return out.str();
 }
 
-
-//----------------------------------------------------------------------
-std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
-              (cmCPackComponent *component,
-                   std::set<cmCPackComponent *>& visited)
+std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription(
+  cmCPackComponent* component, std::set<cmCPackComponent*>& visited)
 {
   // Don't visit a component twice
-  if (visited.count(component))
-    {
+  if (visited.count(component)) {
     return std::string();
-    }
+  }
   visited.insert(component);
 
   std::ostringstream out;
-  std::vector<cmCPackComponent *>::iterator dependIt;
+  std::vector<cmCPackComponent*>::iterator dependIt;
   for (dependIt = component->ReverseDependencies.begin();
-       dependIt != component->ReverseDependencies.end();
-       ++dependIt)
-    {
+       dependIt != component->ReverseDependencies.end(); ++dependIt) {
     // Write NSIS code to deselect this dependency
     out << "  SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
     out << "  IntOp $1 ${SF_SELECTED} ~\n";
@@ -1002,58 +865,46 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
     out << "  IntOp $" << (*dependIt)->Name << "_selected 0 + 0\n";
 
     // Recurse
-    out <<
-      CreateDeselectionDependenciesDescription(*dependIt, visited).c_str();
-    }
+    out
+      << CreateDeselectionDependenciesDescription(*dependIt, visited).c_str();
+  }
 
   return out.str();
 }
 
-//----------------------------------------------------------------------
-std::string
-cmCPackNSISGenerator::
-CreateComponentGroupDescription(cmCPackComponentGroup *group,
-                                std::ostringstream& macrosOut)
+std::string cmCPackNSISGenerator::CreateComponentGroupDescription(
+  cmCPackComponentGroup* group, std::ostringstream& macrosOut)
 {
-  if (group->Components.empty() && group->Subgroups.empty())
-    {
+  if (group->Components.empty() && group->Subgroups.empty()) {
     // Silently skip empty groups. NSIS doesn't support them.
     return std::string();
-    }
+  }
 
   std::string code = "SectionGroup ";
-  if (group->IsExpandedByDefault)
-    {
+  if (group->IsExpandedByDefault) {
     code += "/e ";
-    }
-  if (group->IsBold)
-    {
+  }
+  if (group->IsBold) {
     code += "\"!" + group->DisplayName + "\" " + group->Name + "\n";
-    }
-  else
-    {
+  } else {
     code += "\"" + group->DisplayName + "\" " + group->Name + "\n";
-    }
+  }
 
   std::vector<cmCPackComponentGroup*>::iterator groupIt;
   for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end();
-       ++groupIt)
-    {
+       ++groupIt) {
     code += this->CreateComponentGroupDescription(*groupIt, macrosOut);
-    }
+  }
 
   std::vector<cmCPackComponent*>::iterator comp;
-  for (comp = group->Components.begin();
-       comp != group->Components.end();
-       ++comp)
-    {
-    if ((*comp)->Files.empty())
-      {
+  for (comp = group->Components.begin(); comp != group->Components.end();
+       ++comp) {
+    if ((*comp)->Files.empty()) {
       continue;
-      }
+    }
 
     code += this->CreateComponentDescription(*comp, macrosOut);
-    }
+  }
   code += "SectionGroupEnd\n";
   return code;
 }
diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h
index c7b2ce1..fa52902 100644
--- a/Source/CPack/cmCPackNSISGenerator.h
+++ b/Source/CPack/cmCPackNSISGenerator.h
@@ -13,8 +13,8 @@
 #ifndef cmCPackNSISGenerator_h
 #define cmCPackNSISGenerator_h
 
-
 #include "cmCPackGenerator.h"
+
 #include <set>
 
 /** \class cmCPackNSISGenerator
@@ -28,7 +28,9 @@ public:
   cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenerator);
 
   static cmCPackGenerator* CreateGenerator64()
-    { return new cmCPackNSISGenerator(true); }
+  {
+    return new cmCPackNSISGenerator(true);
+  }
 
   /**
    * Construct generator
@@ -38,14 +40,13 @@ public:
 
 protected:
   virtual int InitializeInternal();
-  void CreateMenuLinks( std::ostringstream& str,
-                        std::ostringstream& deleteStr);
+  void CreateMenuLinks(std::ostringstream& str, std::ostringstream& deleteStr);
   int PackageFiles();
   virtual const char* GetOutputExtension() { return ".exe"; }
   virtual const char* GetOutputPostfix() { return "win32"; }
 
   bool GetListOfSubdirectories(const char* dir,
-    std::vector<std::string>& dirs);
+                               std::vector<std::string>& dirs);
 
   enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const;
   virtual bool SupportsAbsoluteDestination() const;
@@ -54,28 +55,24 @@ protected:
   /// Produce a string that contains the NSIS code to describe a
   /// particular component. Any added macros will be emitted via
   /// macrosOut.
-  std::string
-  CreateComponentDescription(cmCPackComponent *component,
-                             std::ostringstream& macrosOut);
+  std::string CreateComponentDescription(cmCPackComponent* component,
+                                         std::ostringstream& macrosOut);
 
   /// Produce NSIS code that selects all of the components that this component
   /// depends on, recursively.
-  std::string CreateSelectionDependenciesDescription
-                (cmCPackComponent *component,
-                 std::set<cmCPackComponent *>& visited);
+  std::string CreateSelectionDependenciesDescription(
+    cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
 
   /// Produce NSIS code that de-selects all of the components that are
   /// dependent on this component, recursively.
-  std::string CreateDeselectionDependenciesDescription
-                (cmCPackComponent *component,
-                 std::set<cmCPackComponent *>& visited);
+  std::string CreateDeselectionDependenciesDescription(
+    cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
 
   /// Produce a string that contains the NSIS code to describe a
   /// particular component group, including its components. Any
   /// added macros will be emitted via macrosOut.
-  std::string
-  CreateComponentGroupDescription(cmCPackComponentGroup *group,
-                                  std::ostringstream& macrosOut);
+  std::string CreateComponentGroupDescription(cmCPackComponentGroup* group,
+                                              std::ostringstream& macrosOut);
 
   /// Translations any newlines found in the string into \\r\\n, so that the
   /// resulting string can be used within NSIS.
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 8940f54..d5691be 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -9,70 +9,65 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+
 #include "cmCPackOSXX11Generator.h"
 
-#include "cmake.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCPackLog.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Glob.hxx>
+#include <cmsys/SystemTools.hxx>
 #include <sys/stat.h>
 
-//----------------------------------------------------------------------
 cmCPackOSXX11Generator::cmCPackOSXX11Generator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackOSXX11Generator::~cmCPackOSXX11Generator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackOSXX11Generator::PackageFiles()
 {
   // TODO: Use toplevel ?
   //       It is used! Is this an obsolete comment?
 
-  const char* cpackPackageExecutables
-    = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
-  if ( cpackPackageExecutables )
-    {
+  const char* cpackPackageExecutables =
+    this->GetOption("CPACK_PACKAGE_EXECUTABLES");
+  if (cpackPackageExecutables) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
-      << cpackPackageExecutables << "." << std::endl);
+                    << cpackPackageExecutables << "." << std::endl);
     std::ostringstream str;
     std::ostringstream deleteStr;
     std::vector<std::string> cpackPackageExecutablesVector;
     cmSystemTools::ExpandListArgument(cpackPackageExecutables,
-      cpackPackageExecutablesVector);
-    if ( cpackPackageExecutablesVector.size() % 2 != 0 )
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
+                                      cpackPackageExecutablesVector);
+    if (cpackPackageExecutablesVector.size() % 2 != 0) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR,
         "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
-        "<icon name>." << std::endl);
+        "<icon name>."
+          << std::endl);
       return 0;
-      }
+    }
     std::vector<std::string>::iterator it;
-    for ( it = cpackPackageExecutablesVector.begin();
-      it != cpackPackageExecutablesVector.end();
-      ++it )
-      {
+    for (it = cpackPackageExecutablesVector.begin();
+         it != cpackPackageExecutablesVector.end(); ++it) {
       std::string cpackExecutableName = *it;
-      ++ it;
+      ++it;
       this->SetOptionIfNotSet("CPACK_EXECUTABLE_NAME",
-        cpackExecutableName.c_str());
-      }
+                              cpackExecutableName.c_str());
     }
+  }
 
   // Disk image directories
   std::string diskImageDirectory = toplevel;
-  std::string diskImageBackgroundImageDir
-    = diskImageDirectory + "/.background";
-
+  std::string diskImageBackgroundImageDir =
+    diskImageDirectory + "/.background";
 
   // App bundle directories
   std::string packageDirFileName = toplevel;
@@ -92,48 +87,45 @@ int cmCPackOSXX11Generator::PackageFiles()
   const char* contDir = contentsDirectory.c_str();
   const char* rsrcFile = resourceFileName.c_str();
   const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
-  if ( iconFile )
-    {
-    std::string iconFileName = cmsys::SystemTools::GetFilenameName(
-      iconFile);
-    if ( !cmSystemTools::FileExists(iconFile) )
-      {
+  if (iconFile) {
+    std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile);
+    if (!cmSystemTools::FileExists(iconFile)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: "
-        << iconFile << ". Please check CPACK_PACKAGE_ICON setting."
-        << std::endl);
+                      << iconFile
+                      << ". Please check CPACK_PACKAGE_ICON setting."
+                      << std::endl);
       return 0;
-      }
+    }
     std::string destFileName = resourcesDirectory + "/" + iconFileName;
     this->ConfigureFile(iconFile, destFileName.c_str(), true);
     this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str());
-    }
+  }
 
   std::string applicationsLinkName = diskImageDirectory + "/Applications";
   cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str());
 
-  if (
-    !this->CopyResourcePlistFile("VolumeIcon.icns",
-                                 diskImageDirectory.c_str(),
-                                 ".VolumeIcon.icns", true ) ||
-    !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
-      ".DS_Store", true ) ||
-    !this->CopyResourcePlistFile("background.png",
-      diskImageBackgroundImageDir.c_str(), "background.png", true ) ||
-    !this->CopyResourcePlistFile("RuntimeScript", dir) ||
-    !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
-      "Info.plist" ) ||
-    !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir,
-      "main.scpt", true ) ||
-    !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir,
-      rsrcFile, true) ||
-    !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
-      this->GetOption("CPACK_PACKAGE_FILE_NAME"), true)
-  )
-    {
+  if (!this->CopyResourcePlistFile("VolumeIcon.icns",
+                                   diskImageDirectory.c_str(),
+                                   ".VolumeIcon.icns", true) ||
+      !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
+                                   ".DS_Store", true) ||
+      !this->CopyResourcePlistFile("background.png",
+                                   diskImageBackgroundImageDir.c_str(),
+                                   "background.png", true) ||
+      !this->CopyResourcePlistFile("RuntimeScript", dir) ||
+      !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
+                                   "Info.plist") ||
+      !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir, "main.scpt",
+                                   true) ||
+      !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, rsrcFile,
+                                   true) ||
+      !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
+                                   this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+                                   true)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
-      << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
 
   // Two of the files need to have execute permission, so ensure they do:
   std::string runTimeScript = dir;
@@ -145,21 +137,21 @@ int cmCPackOSXX11Generator::PackageFiles()
   appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
 
   mode_t mode;
-  if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode))
-    {
+  if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) {
     mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
     cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode);
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << runTimeScript
-      << " to permission: " << mode << std::endl);
-    }
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+                  "Setting: " << runTimeScript << " to permission: " << mode
+                              << std::endl);
+  }
 
-  if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode))
-    {
+  if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode)) {
     mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
     cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode);
-    cmCPackLogger(cmCPackLog::LOG_OUTPUT,  "Setting: " << appScriptName
-      << " to permission: " << mode << std::endl);
-    }
+    cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+                  "Setting: " << appScriptName << " to permission: " << mode
+                              << std::endl);
+  }
 
   std::string output;
   std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -167,64 +159,58 @@ int cmCPackOSXX11Generator::PackageFiles()
   std::ostringstream dmgCmd;
   dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
          << "\" create -ov -format UDZO -srcfolder \""
-         << diskImageDirectory.c_str()
-         << "\" \"" << packageFileNames[0] << "\"";
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-                "Compress disk image using command: "
-                << dmgCmd.str().c_str() << std::endl);
+         << diskImageDirectory.c_str() << "\" \"" << packageFileNames[0]
+         << "\"";
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: "
+                  << dmgCmd.str().c_str() << std::endl);
   // since we get random dashboard failures with this one
   // try running it more than once
   int retVal = 1;
   int numTries = 10;
   bool res = false;
-  while(numTries > 0)
-    {
-    res = cmSystemTools::RunSingleCommand(
-      dmgCmd.str().c_str(), &output, &output,
-      &retVal, 0, this->GeneratorVerbose, 0);
-    if ( res && !retVal )
-      {
+  while (numTries > 0) {
+    res =
+      cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
+                                      &retVal, 0, this->GeneratorVerbose, 0);
+    if (res && !retVal) {
       numTries = -1;
       break;
-      }
+    }
     cmSystemTools::Delay(500);
     numTries--;
-    }
-  if ( !res || retVal )
-    {
+  }
+  if (!res || retVal) {
     cmGeneratedFileStream ofs(tmpFile.c_str());
     ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
-      << "# Output:" << std::endl
-      << output.c_str() << std::endl;
+        << "# Output:" << std::endl
+        << output.c_str() << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
-      << dmgCmd.str().c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+                    << dmgCmd.str().c_str() << std::endl
+                    << "Please check " << tmpFile.c_str() << " for errors"
+                    << std::endl);
     return 0;
-    }
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackOSXX11Generator::InitializeInternal()
 {
-  cmCPackLogger(cmCPackLog::LOG_DEBUG,
-    "cmCPackOSXX11Generator::Initialize()" << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()"
+                  << std::endl);
   std::vector<std::string> path;
   std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
-  if ( pkgPath.empty() )
-    {
+  if (pkgPath.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
-      << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
   this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
                           pkgPath.c_str());
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 /*
 bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
 {
@@ -269,38 +255,35 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
 }
 */
 
-//----------------------------------------------------------------------
-bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
-  const std::string& dir, const char* outputFileName /* = 0 */,
-  bool copyOnly /* = false */)
+bool cmCPackOSXX11Generator::CopyResourcePlistFile(
+  const std::string& name, const std::string& dir,
+  const char* outputFileName /* = 0 */, bool copyOnly /* = false */)
 {
   std::string inFName = "CPack.";
   inFName += name;
   inFName += ".in";
   std::string inFileName = this->FindTemplate(inFName.c_str());
-  if ( inFileName.empty() )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
-      << inFName << std::endl);
+  if (inFileName.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Cannot find input file: " << inFName << std::endl);
     return false;
-    }
+  }
 
-  if ( !outputFileName )
-    {
+  if (!outputFileName) {
     outputFileName = name.c_str();
-    }
+  }
 
   std::string destFileName = dir;
   destFileName += "/";
   destFileName += outputFileName;
 
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
-    << inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+                "Configure file: " << inFileName.c_str() << " to "
+                                   << destFileName.c_str() << std::endl);
   this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly);
   return true;
 }
 
-//----------------------------------------------------------------------
 const char* cmCPackOSXX11Generator::GetPackagingInstallPrefix()
 {
   this->InstallPrefix = "/";
diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h
index 9d0a6d1..adc05d2 100644
--- a/Source/CPack/cmCPackOSXX11Generator.h
+++ b/Source/CPack/cmCPackOSXX11Generator.h
@@ -37,10 +37,11 @@ protected:
   virtual const char* GetPackagingInstallPrefix();
   virtual const char* GetOutputExtension() { return ".dmg"; }
 
-  //bool CopyCreateResourceFile(const std::string& name,
+  // 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);
+                             const char* outputFileName = 0,
+                             bool copyOnly = false);
   std::string InstallPrefix;
 };
 
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 8fdc036..5ca3ff7 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -11,46 +11,41 @@
 ============================================================================*/
 #include "cmCPackPackageMakerGenerator.h"
 
-#include "cmake.h"
-#include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
-#include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
 #include "cmCPackComponentGroup.h"
 #include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/SystemTools.hxx>
 
 #include <assert.h>
 
-static inline
-unsigned int getVersion(unsigned int major, unsigned int minor)
+static inline unsigned int getVersion(unsigned int major, unsigned int minor)
 {
   assert(major < 256 && minor < 256);
   return ((major & 0xFF) << 16 | minor);
 }
 
-//----------------------------------------------------------------------
 cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator()
 {
   this->PackageMakerVersion = 0.0;
   this->PackageCompatibilityVersion = getVersion(10, 4);
 }
 
-//----------------------------------------------------------------------
 cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
 {
   return this->PackageCompatibilityVersion >= getVersion(10, 4);
 }
 
-//----------------------------------------------------------------------
 int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
                                                     const std::string& script,
                                                     const std::string& name)
@@ -59,117 +54,93 @@ int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
   dst += "/";
   dst += name;
   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() <<
-                std::endl);
+  cmSystemTools::SetPermissions(dst.c_str(), 0777);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : "
+                  << script << "\ninto " << dst.c_str() << std::endl);
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackPackageMakerGenerator::PackageFiles()
 {
   // TODO: Use toplevel
   //       It is used! Is this an obsolete comment?
 
   std::string resDir; // Where this package's resources will go.
-  std::string packageDirFileName
-    = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
-  if (this->Components.empty())
-    {
+  std::string packageDirFileName =
+    this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  if (this->Components.empty()) {
     packageDirFileName += ".pkg";
     resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     resDir += "/Resources";
-    }
-  else
-    {
+  } else {
     packageDirFileName += ".mpkg";
-    if ( !cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str()))
-      {
+    if (!cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
-                    "unable to create package directory "
-                    << packageDirFileName << std::endl);
-        return 0;
-      }
+                    "unable to create package directory " << packageDirFileName
+                                                          << std::endl);
+      return 0;
+    }
 
     resDir = packageDirFileName;
     resDir += "/Contents";
-    if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str()))
-      {
+    if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "unable to create package subdirectory " << resDir
-                    << std::endl);
-        return 0;
-      }
+                                                             << std::endl);
+      return 0;
+    }
 
     resDir += "/Resources";
-    if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str()))
-      {
+    if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "unable to create package subdirectory " << resDir
-                    << std::endl);
-        return 0;
-      }
+                                                             << std::endl);
+      return 0;
+    }
 
     resDir += "/en.lproj";
-    }
+  }
 
   const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT");
   const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT");
   const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT");
 
-  if(this->Components.empty())
-    {
+  if (this->Components.empty()) {
     // Create directory structure
     std::string preflightDirName = resDir + "/PreFlight";
     std::string postflightDirName = resDir + "/PostFlight";
     // if preflight or postflight scripts not there create directories
     // of the same name, I think this makes it work
-    if(!preflight)
-      {
-      if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str()))
-        {
+    if (!preflight) {
+      if (!cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
                       "Problem creating installer directory: "
-                      << preflightDirName.c_str() << std::endl);
+                        << preflightDirName.c_str() << std::endl);
         return 0;
-        }
       }
-    if(!postflight)
-      {
-      if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str()))
-        {
+    }
+    if (!postflight) {
+      if (!cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
                       "Problem creating installer directory: "
-                      << postflightDirName.c_str() << std::endl);
+                        << postflightDirName.c_str() << std::endl);
         return 0;
-        }
       }
+    }
     // if preflight, postflight, or postupgrade are set
     // then copy them into the resource directory and make
     // them executable
-    if(preflight)
-      {
-      this->CopyInstallScript(resDir.c_str(),
-                              preflight,
-                              "preflight");
-      }
-    if(postflight)
-      {
-      this->CopyInstallScript(resDir.c_str(),
-                              postflight,
-                              "postflight");
-      }
-    if(postupgrade)
-      {
-      this->CopyInstallScript(resDir.c_str(),
-                              postupgrade,
-                              "postupgrade");
-      }
+    if (preflight) {
+      this->CopyInstallScript(resDir.c_str(), preflight, "preflight");
+    }
+    if (postflight) {
+      this->CopyInstallScript(resDir.c_str(), postflight, "postflight");
     }
-  else if(postflight)
-    {
+    if (postupgrade) {
+      this->CopyInstallScript(resDir.c_str(), postupgrade, "postupgrade");
+    }
+  } else if (postflight) {
     // create a postflight component to house the script
     this->PostFlightComponent.Name = "PostFlight";
     this->PostFlightComponent.DisplayName = "PostFlight";
@@ -178,121 +149,101 @@ int cmCPackPackageMakerGenerator::PackageFiles()
 
     // empty directory for pkg contents
     std::string packageDir = toplevel + "/" + PostFlightComponent.Name;
-    if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str()))
-      {
+    if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Problem creating component packages directory: "
-                    << packageDir.c_str() << std::endl);
+                      << packageDir.c_str() << std::endl);
       return 0;
-      }
+    }
 
     // create package
     std::string packageFileDir = packageDirFileName + "/Contents/Packages/";
-    if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str()))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-                   "Problem creating component PostFlight Packages directory: "
-                    << packageFileDir.c_str() << std::endl);
+    if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) {
+      cmCPackLogger(
+        cmCPackLog::LOG_ERROR,
+        "Problem creating component PostFlight Packages directory: "
+          << packageFileDir.c_str() << std::endl);
       return 0;
-      }
-    std::string packageFile = packageFileDir +
-      this->GetPackageName(PostFlightComponent);
-    if (!this->GenerateComponentPackage(packageFile.c_str(),
-                                        packageDir.c_str(),
-                                        PostFlightComponent))
-      {
+    }
+    std::string packageFile =
+      packageFileDir + this->GetPackageName(PostFlightComponent);
+    if (!this->GenerateComponentPackage(
+          packageFile.c_str(), packageDir.c_str(), PostFlightComponent)) {
       return 0;
-      }
+    }
 
     // copy postflight script into resource directory of .pkg
     std::string resourceDir = packageFile + "/Contents/Resources";
-    this->CopyInstallScript(resourceDir.c_str(),
-                            postflight,
-                            "postflight");
-    }
+    this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight");
+  }
 
-  if (!this->Components.empty())
-    {
+  if (!this->Components.empty()) {
     // Create the directory where component packages will be built.
     std::string basePackageDir = packageDirFileName;
     basePackageDir += "/Contents/Packages";
-    if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str()))
-      {
+    if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Problem creating component packages directory: "
-                    << basePackageDir.c_str() << std::endl);
+                      << basePackageDir.c_str() << std::endl);
       return 0;
-      }
+    }
 
     // Create the directory where downloaded component packages will
     // be placed.
     const char* userUploadDirectory =
       this->GetOption("CPACK_UPLOAD_DIRECTORY");
     std::string uploadDirectory;
-    if (userUploadDirectory && *userUploadDirectory)
-      {
+    if (userUploadDirectory && *userUploadDirectory) {
       uploadDirectory = userUploadDirectory;
-      }
-    else
-      {
-      uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY");
+    } else {
+      uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
       uploadDirectory += "/CPackUploads";
-      }
+    }
 
     // Create packages for each component
     bool warnedAboutDownloadCompatibility = false;
 
     std::map<std::string, cmCPackComponent>::iterator compIt;
     for (compIt = this->Components.begin(); compIt != this->Components.end();
-         ++compIt)
-      {
+         ++compIt) {
       std::string packageFile;
-      if (compIt->second.IsDownloaded)
-        {
+      if (compIt->second.IsDownloaded) {
         if (this->PackageCompatibilityVersion >= getVersion(10, 5) &&
-            this->PackageMakerVersion >= 3.0)
-          {
+            this->PackageMakerVersion >= 3.0) {
           // Build this package within the upload directory.
           packageFile = uploadDirectory;
 
-          if(!cmSystemTools::FileExists(uploadDirectory.c_str()))
-            {
-            if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
-              {
+          if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
+            if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
               cmCPackLogger(cmCPackLog::LOG_ERROR,
                             "Unable to create package upload directory "
-                            << uploadDirectory << std::endl);
+                              << uploadDirectory << std::endl);
               return 0;
-              }
             }
           }
-        else if (!warnedAboutDownloadCompatibility)
-          {
-            if (this->PackageCompatibilityVersion < getVersion(10, 5))
-            {
+        } else if (!warnedAboutDownloadCompatibility) {
+          if (this->PackageCompatibilityVersion < getVersion(10, 5)) {
             cmCPackLogger(
               cmCPackLog::LOG_WARNING,
               "CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 "
               "or greater enable downloaded packages. CPack will build a "
               "non-downloaded package."
-              << std::endl);
-            }
+                << std::endl);
+          }
 
-          if (this->PackageMakerVersion < 3)
-            {
+          if (this->PackageMakerVersion < 3) {
             cmCPackLogger(cmCPackLog::LOG_WARNING,
-                        "CPack warning: unable to build downloaded "
+                          "CPack warning: unable to build downloaded "
                           "packages with PackageMaker versions prior "
                           "to 3.0. CPack will build a non-downloaded package."
-                          << std::endl);
-            }
+                            << std::endl);
+          }
 
           warnedAboutDownloadCompatibility = true;
-          }
         }
+      }
 
-      if (packageFile.empty())
-        {
+      if (packageFile.empty()) {
         // Build this package within the overall distribution
         // metapackage.
         packageFile = basePackageDir;
@@ -300,7 +251,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
         // We're not downloading this component, even if the user
         // requested it.
         compIt->second.IsDownloaded = false;
-        }
+      }
 
       packageFile += '/';
       packageFile += GetPackageName(compIt->second);
@@ -308,106 +259,93 @@ int cmCPackPackageMakerGenerator::PackageFiles()
       std::string packageDir = toplevel;
       packageDir += '/';
       packageDir += compIt->first;
-      if (!this->GenerateComponentPackage(packageFile.c_str(),
-                                          packageDir.c_str(),
-                                          compIt->second))
-        {
+      if (!this->GenerateComponentPackage(
+            packageFile.c_str(), packageDir.c_str(), compIt->second)) {
         return 0;
-        }
       }
     }
+  }
   this->SetOption("CPACK_MODULE_VERSION_SUFFIX", "");
 
   // Copy or create all of the resource files we need.
-  if ( !this->CopyCreateResourceFile("License", resDir.c_str())
-       || !this->CopyCreateResourceFile("ReadMe", resDir.c_str())
-       || !this->CopyCreateResourceFile("Welcome", resDir.c_str())
-       || !this->CopyResourcePlistFile("Info.plist")
-       || !this->CopyResourcePlistFile("Description.plist") )
-    {
+  if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
+      !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
+      !this->CopyCreateResourceFile("Welcome", resDir.c_str()) ||
+      !this->CopyResourcePlistFile("Info.plist") ||
+      !this->CopyResourcePlistFile("Description.plist")) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
-      << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
 
-  if (this->Components.empty())
-    {
+  if (this->Components.empty()) {
     // Use PackageMaker to build the package.
     std::ostringstream pkgCmd;
     pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
            << "\" -build -p \"" << packageDirFileName << "\"";
-    if (this->Components.empty())
-      {
+    if (this->Components.empty()) {
       pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY");
-      }
-    else
-      {
+    } else {
       pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
              << "/packages/";
-      }
+    }
     pkgCmd << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
            << "/Resources\" -i \""
            << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
            << "/Info.plist\" -d \""
            << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
            << "/Description.plist\"";
-    if ( this->PackageMakerVersion > 2.0 )
-      {
+    if (this->PackageMakerVersion > 2.0) {
       pkgCmd << " -v";
-      }
+    }
     if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
       return 0;
-    }
-  else
-    {
+  } else {
     // We have built the package in place. Generate the
     // distribution.dist file to describe it for the installer.
     WriteDistributionFile(packageDirFileName.c_str());
-    }
+  }
 
   std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   tmpFile += "/hdiutilOutput.log";
   std::ostringstream dmgCmd;
   dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
-    << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
-    << "\" \"" << packageFileNames[0] << "\"";
+         << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
+         << "\" \"" << packageFileNames[0] << "\"";
   std::string output;
   int retVal = 1;
   int numTries = 10;
   bool res = false;
-  while(numTries > 0)
-    {
-    res = cmSystemTools::RunSingleCommand(
-      dmgCmd.str().c_str(), &output, &output,
-      &retVal, 0, this->GeneratorVerbose, 0);
-    if ( res && !retVal )
-      {
+  while (numTries > 0) {
+    res =
+      cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
+                                      &retVal, 0, this->GeneratorVerbose, 0);
+    if (res && !retVal) {
       numTries = -1;
       break;
-      }
+    }
     cmSystemTools::Delay(500);
     numTries--;
-    }
-  if ( !res || retVal )
-    {
+  }
+  if (!res || retVal) {
     cmGeneratedFileStream ofs(tmpFile.c_str());
     ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
-      << "# Output:" << std::endl
-      << output.c_str() << std::endl;
+        << "# Output:" << std::endl
+        << output.c_str() << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
-      << dmgCmd.str().c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+                    << dmgCmd.str().c_str() << std::endl
+                    << "Please check " << tmpFile.c_str() << " for errors"
+                    << std::endl);
     return 0;
-    }
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCPackPackageMakerGenerator::InitializeInternal()
 {
   cmCPackLogger(cmCPackLog::LOG_DEBUG,
-    "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
+                "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
   this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
 
   // Starting with Xcode 4.3, PackageMaker is a separate app, and you
@@ -424,39 +362,30 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
   // If found, save result in the CPACK_INSTALLER_PROGRAM variable.
 
   std::vector<std::string> paths;
-  paths.push_back(
-    "/Applications/Xcode.app/Contents/Applications"
-    "/PackageMaker.app/Contents/MacOS");
-  paths.push_back(
-    "/Applications/Utilities"
-    "/PackageMaker.app/Contents/MacOS");
-  paths.push_back(
-    "/Applications"
-    "/PackageMaker.app/Contents/MacOS");
-  paths.push_back(
-    "/Developer/Applications/Utilities"
-    "/PackageMaker.app/Contents/MacOS");
-  paths.push_back(
-    "/Developer/Applications"
-    "/PackageMaker.app/Contents/MacOS");
+  paths.push_back("/Applications/Xcode.app/Contents/Applications"
+                  "/PackageMaker.app/Contents/MacOS");
+  paths.push_back("/Applications/Utilities"
+                  "/PackageMaker.app/Contents/MacOS");
+  paths.push_back("/Applications"
+                  "/PackageMaker.app/Contents/MacOS");
+  paths.push_back("/Developer/Applications/Utilities"
+                  "/PackageMaker.app/Contents/MacOS");
+  paths.push_back("/Developer/Applications"
+                  "/PackageMaker.app/Contents/MacOS");
 
   std::string pkgPath;
-  const char *inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
-  if (inst_program && *inst_program)
-    {
+  const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
+  if (inst_program && *inst_program) {
     pkgPath = inst_program;
-    }
-  else
-    {
+  } else {
     pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
-    if ( pkgPath.empty() )
-      {
+    if (pkgPath.empty()) {
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
-        << std::endl);
+                      << std::endl);
       return 0;
-      }
-    this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
     }
+    this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
+  }
 
   // Get path to the real PackageMaker, not a symlink:
   pkgPath = cmSystemTools::GetRealPath(pkgPath.c_str());
@@ -467,138 +396,120 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
 
   std::string versionFile = contents_dir + "/version.plist";
 
-  if ( !cmSystemTools::FileExists(versionFile.c_str()) )
-    {
+  if (!cmSystemTools::FileExists(versionFile.c_str())) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Cannot find PackageMaker compiler version file: "
-      << versionFile.c_str()
-      << std::endl);
+                  "Cannot find PackageMaker compiler version file: "
+                    << versionFile.c_str() << std::endl);
     return 0;
-    }
+  }
 
   cmsys::ifstream ifs(versionFile.c_str());
-  if ( !ifs )
-    {
+  if (!ifs) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Cannot open PackageMaker compiler version file" << std::endl);
+                  "Cannot open PackageMaker compiler version file"
+                    << std::endl);
     return 0;
-    }
+  }
 
   // Check the PackageMaker version
   cmsys::RegularExpression rexKey("<key>CFBundleShortVersionString</key>");
   cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
   std::string line;
   bool foundKey = false;
-  while ( cmSystemTools::GetLineFromStream(ifs, line) )
-    {
-    if ( rexKey.find(line) )
-      {
+  while (cmSystemTools::GetLineFromStream(ifs, line)) {
+    if (rexKey.find(line)) {
       foundKey = true;
       break;
-      }
     }
-  if ( !foundKey )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
+  }
+  if (!foundKey) {
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR,
       "Cannot find CFBundleShortVersionString in the PackageMaker compiler "
-      "version file" << std::endl);
+      "version file"
+        << std::endl);
     return 0;
-    }
-  if ( !cmSystemTools::GetLineFromStream(ifs, line) ||
-    !rexVersion.find(line) )
-    {
+  }
+  if (!cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Problem reading the PackageMaker compiler version file: "
-      << versionFile.c_str() << std::endl);
+                  "Problem reading the PackageMaker compiler version file: "
+                    << versionFile.c_str() << std::endl);
     return 0;
-    }
+  }
   this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
-  if ( this->PackageMakerVersion < 1.0 )
-    {
+  if (this->PackageMakerVersion < 1.0) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
-      << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: "
-    << this->PackageMakerVersion << std::endl);
+                  << this->PackageMakerVersion << std::endl);
 
   // Determine the package compatibility version. If it wasn't
   // specified by the user, we define it based on which features the
   // user requested.
-  const char *packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
-  if (packageCompat && *packageCompat)
-    {
+  const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
+  if (packageCompat && *packageCompat) {
     unsigned int majorVersion = 10;
     unsigned int minorVersion = 5;
     int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion);
-    if (res == 2)
-      {
+    if (res == 2) {
       this->PackageCompatibilityVersion =
         getVersion(majorVersion, minorVersion);
-      }
     }
-  else if (this->GetOption("CPACK_DOWNLOAD_SITE"))
-    {
+  } else if (this->GetOption("CPACK_DOWNLOAD_SITE")) {
     this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5");
     this->PackageCompatibilityVersion = getVersion(10, 5);
-    }
-  else if (this->GetOption("CPACK_COMPONENTS_ALL"))
-    {
+  } else if (this->GetOption("CPACK_COMPONENTS_ALL")) {
     this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4");
     this->PackageCompatibilityVersion = getVersion(10, 4);
-    }
-  else
-    {
+  } else {
     this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3");
     this->PackageCompatibilityVersion = getVersion(10, 3);
-    }
+  }
 
   std::vector<std::string> no_paths;
   pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
-  if ( pkgPath.empty() )
-    {
+  if (pkgPath.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
-      << std::endl);
+                    << std::endl);
     return 0;
-    }
+  }
   this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
                           pkgPath.c_str());
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
-                                            const std::string& name,
-                                            const std::string& dirName)
+  const std::string& name, const std::string& dirName)
 {
   std::string uname = cmSystemTools::UpperCase(name);
   std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
   const char* inFileName = this->GetOption(cpackVar.c_str());
-  if ( !inFileName )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
-                  << " not specified. It should point to "
-                  << (!name.empty() ? name : "<empty>")
-                  << ".rtf, " << name
-                  << ".html, or " << name << ".txt file" << std::endl);
+  if (!inFileName) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
+                    << cpackVar.c_str()
+                    << " not specified. It should point to "
+                    << (!name.empty() ? name : "<empty>") << ".rtf, " << name
+                    << ".html, or " << name << ".txt file" << std::endl);
     return false;
-    }
-  if ( !cmSystemTools::FileExists(inFileName) )
-    {
+  }
+  if (!cmSystemTools::FileExists(inFileName)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
-                  << (!name.empty() ? name : "<empty>")
-                  << " resource file: " << inFileName << std::endl);
+                    << (!name.empty() ? name : "<empty>")
+                    << " resource file: " << inFileName << std::endl);
     return false;
-    }
+  }
   std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
-  if ( ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt" )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Bad file extension specified: "
-      << ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
-      << std::endl);
+  if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR, "Bad file extension specified: "
+        << ext
+        << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
+        << std::endl);
     return false;
-    }
+  }
 
   std::string destFileName = dirName;
   destFileName += '/';
@@ -610,45 +521,42 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
                   (name + ext).c_str());
 
   cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
-                << (inFileName ? inFileName : "(NULL)")
-                << " to " << destFileName.c_str() << std::endl);
+                  << (inFileName ? inFileName : "(NULL)") << " to "
+                  << destFileName.c_str() << std::endl);
   this->ConfigureFile(inFileName, destFileName.c_str());
   return true;
 }
 
 bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
-                                                const std::string& name,
-                                                const char* outName)
+  const std::string& name, const char* outName)
 {
-  if (!outName)
-    {
+  if (!outName) {
     outName = name.c_str();
-    }
+  }
 
   std::string inFName = "CPack.";
   inFName += name;
   inFName += ".in";
   std::string inFileName = this->FindTemplate(inFName.c_str());
-  if ( inFileName.empty() )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
-      << inFName << std::endl);
+  if (inFileName.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Cannot find input file: " << inFName << std::endl);
     return false;
-    }
+  }
 
   std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   destFileName += "/";
   destFileName += outName;
 
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
-    << inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+                "Configure file: " << inFileName.c_str() << " to "
+                                   << destFileName.c_str() << std::endl);
   this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------
-bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command,
-                                                   const char *packageFile)
+bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
+                                                   const char* packageFile)
 {
   std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   tmpFile += "/PackageMakerOutput.log";
@@ -657,80 +565,65 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command,
   std::string output;
   int retVal = 1;
   bool res = cmSystemTools::RunSingleCommand(
-    command, &output, &output,
-    &retVal, 0, this->GeneratorVerbose, 0);
+    command, &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
   cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
-    << std::endl);
-  if ( !res || retVal )
-    {
+                  << std::endl);
+  if (!res || retVal) {
     cmGeneratedFileStream ofs(tmpFile.c_str());
     ofs << "# Run command: " << command << std::endl
-      << "# Output:" << std::endl
-      << output.c_str() << std::endl;
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "Problem running PackageMaker command: " << command
-      << std::endl << "Please check " << tmpFile.c_str() << " for errors"
-      << std::endl);
+        << "# Output:" << std::endl
+        << output.c_str() << std::endl;
+    cmCPackLogger(
+      cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: "
+        << command << std::endl
+        << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
     return false;
-    }
+  }
   // sometimes the command finishes but the directory is not yet
   // created, so try 10 times to see if it shows up
   int tries = 10;
-  while(tries > 0 &&
-        !cmSystemTools::FileExists(packageFile))
-    {
+  while (tries > 0 && !cmSystemTools::FileExists(packageFile)) {
     cmSystemTools::Delay(500);
     tries--;
-    }
-  if(!cmSystemTools::FileExists(packageFile))
-    {
-    cmCPackLogger(
-      cmCPackLog::LOG_ERROR,
-      "Problem running PackageMaker command: " << command
-      << std::endl << "Package not created: " << packageFile
-      << std::endl);
+  }
+  if (!cmSystemTools::FileExists(packageFile)) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Problem running PackageMaker command: "
+                    << command << std::endl
+                    << "Package not created: " << packageFile << std::endl);
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------
-std::string
-cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component)
+std::string cmCPackPackageMakerGenerator::GetPackageName(
+  const cmCPackComponent& component)
 {
-  if (component.ArchiveFile.empty())
-    {
+  if (component.ArchiveFile.empty()) {
     std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
     packagesDir += ".dummy";
     std::ostringstream out;
-    out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
-        << "-" << component.Name << ".pkg";
+    out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
+        << component.Name << ".pkg";
     return out.str();
-    }
-  else
-    {
+  } else {
     return component.ArchiveFile + ".pkg";
-    }
+  }
 }
 
-//----------------------------------------------------------------------
-bool
-cmCPackPackageMakerGenerator::
-GenerateComponentPackage(const char *packageFile,
-                         const char *packageDir,
-                         const cmCPackComponent& component)
+bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
+  const char* packageFile, const char* packageDir,
+  const cmCPackComponent& component)
 {
-  cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-                "-   Building component package: " <<
-                packageFile << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_OUTPUT, "-   Building component package: "
+                  << packageFile << std::endl);
 
   // The command that will be used to run PackageMaker
   std::ostringstream pkgCmd;
 
   if (this->PackageCompatibilityVersion < getVersion(10, 5) ||
-      this->PackageMakerVersion < 3.0)
-    {
+      this->PackageMakerVersion < 3.0) {
     // Create Description.plist and Info.plist files for normal Mac OS
     // X packages, which work on Mac OS X 10.3 and newer.
     std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@@ -760,20 +653,17 @@ GenerateComponentPackage(const char *packageFile,
                     moduleVersionSuffix.c_str());
     std::string infoFileName = component.Name;
     infoFileName += "-Info.plist";
-    if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str()))
-      {
+    if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) {
       return false;
-      }
+    }
 
     pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
            << "\" -build -p \"" << packageFile << "\""
            << " -f \"" << packageDir << "\""
-           << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
-           << "/" << infoFileName << "\""
+           << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/"
+           << infoFileName << "\""
            << " -d \"" << descriptionFile << "\"";
-    }
-  else
-    {
+  } else {
     // Create a "flat" package on Mac OS X 10.5 and newer. Flat
     // packages are stored in a single file, rather than a directory
     // like normal packages, and can be downloaded by the installer
@@ -788,28 +678,25 @@ GenerateComponentPackage(const char *packageFile,
 
     pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
            << "\" --root \"" << packageDir << "\""
-           << " --id " << pkgId
-           << " --target " << this->GetOption("CPACK_OSX_PACKAGE_VERSION")
-           << " --out \"" << packageFile << "\"";
-    }
+           << " --id " << pkgId << " --target "
+           << this->GetOption("CPACK_OSX_PACKAGE_VERSION") << " --out \""
+           << packageFile << "\"";
+  }
 
   // Run PackageMaker
   return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
 }
 
-//----------------------------------------------------------------------
-void
-cmCPackPackageMakerGenerator::
-WriteDistributionFile(const char* metapackageFile)
+void cmCPackPackageMakerGenerator::WriteDistributionFile(
+  const char* metapackageFile)
 {
-  std::string distributionTemplate
-    = this->FindTemplate("CPack.distribution.dist.in");
-  if ( distributionTemplate.empty() )
-    {
+  std::string distributionTemplate =
+    this->FindTemplate("CPack.distribution.dist.in");
+  if (distributionTemplate.empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
-      << distributionTemplate << std::endl);
+                    << distributionTemplate << std::endl);
     return;
-    }
+  }
 
   std::string distributionFile = metapackageFile;
   distributionFile += "/Contents/distribution.dist";
@@ -822,105 +709,83 @@ WriteDistributionFile(const char* metapackageFile)
   // Emit the outline for the groups
   std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
   for (groupIt = this->ComponentGroups.begin();
-       groupIt != this->ComponentGroups.end();
-       ++groupIt)
-    {
-    if (groupIt->second.ParentGroup == 0)
-      {
+       groupIt != this->ComponentGroups.end(); ++groupIt) {
+    if (groupIt->second.ParentGroup == 0) {
       CreateChoiceOutline(groupIt->second, choiceOut);
-      }
     }
+  }
 
   // Emit the outline for the non-grouped components
   std::map<std::string, cmCPackComponent>::iterator compIt;
   for (compIt = this->Components.begin(); compIt != this->Components.end();
-       ++compIt)
-    {
-    if (!compIt->second.Group)
-      {
+       ++compIt) {
+    if (!compIt->second.Group) {
       choiceOut << "<line choice=\"" << compIt->first << "Choice\"></line>"
                 << std::endl;
-      }
-    }
-  if(!this->PostFlightComponent.Name.empty())
-    {
-      choiceOut << "<line choice=\"" << PostFlightComponent.Name
-                << "Choice\"></line>" << std::endl;
     }
+  }
+  if (!this->PostFlightComponent.Name.empty()) {
+    choiceOut << "<line choice=\"" << PostFlightComponent.Name
+              << "Choice\"></line>" << std::endl;
+  }
   choiceOut << "</choices-outline>" << std::endl;
 
   // Create the actual choices
   for (groupIt = this->ComponentGroups.begin();
-       groupIt != this->ComponentGroups.end();
-       ++groupIt)
-    {
+       groupIt != this->ComponentGroups.end(); ++groupIt) {
     CreateChoice(groupIt->second, choiceOut);
-    }
+  }
   for (compIt = this->Components.begin(); compIt != this->Components.end();
-       ++compIt)
-    {
+       ++compIt) {
     CreateChoice(compIt->second, choiceOut);
-    }
+  }
 
-  if(!this->PostFlightComponent.Name.empty())
-    {
+  if (!this->PostFlightComponent.Name.empty()) {
     CreateChoice(PostFlightComponent, choiceOut);
-    }
+  }
 
   this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str());
 
   // Create the distribution.dist file in the metapackage to turn it
   // into a distribution package.
-  this->ConfigureFile(distributionTemplate.c_str(),
-                      distributionFile.c_str());
+  this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str());
 }
 
-//----------------------------------------------------------------------
-void
-cmCPackPackageMakerGenerator::
-CreateChoiceOutline(const cmCPackComponentGroup& group,
-                    std::ostringstream& out)
+void cmCPackPackageMakerGenerator::CreateChoiceOutline(
+  const cmCPackComponentGroup& group, std::ostringstream& out)
 {
   out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
   std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
   for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
-       ++groupIt)
-    {
+       ++groupIt) {
     CreateChoiceOutline(**groupIt, out);
-    }
+  }
 
   std::vector<cmCPackComponent*>::const_iterator compIt;
   for (compIt = group.Components.begin(); compIt != group.Components.end();
-       ++compIt)
-    {
+       ++compIt) {
     out << "  <line choice=\"" << (*compIt)->Name << "Choice\"></line>"
         << std::endl;
-    }
+  }
   out << "</line>" << std::endl;
 }
 
-//----------------------------------------------------------------------
-void
-cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group,
-                                           std::ostringstream& out)
+void cmCPackPackageMakerGenerator::CreateChoice(
+  const cmCPackComponentGroup& group, std::ostringstream& out)
 {
   out << "<choice id=\"" << group.Name << "Choice\" "
       << "title=\"" << group.DisplayName << "\" "
       << "start_selected=\"true\" "
       << "start_enabled=\"true\" "
       << "start_visible=\"true\" ";
-  if (!group.Description.empty())
-    {
-    out << "description=\"" << EscapeForXML(group.Description)
-        << "\"";
-    }
+  if (!group.Description.empty()) {
+    out << "description=\"" << EscapeForXML(group.Description) << "\"";
+  }
   out << "></choice>" << std::endl;
 }
 
-//----------------------------------------------------------------------
-void
-cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
-                                           std::ostringstream& out)
+void cmCPackPackageMakerGenerator::CreateChoice(
+  const cmCPackComponent& component, std::ostringstream& out)
 {
   std::string packageId = "com.";
   packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
@@ -932,21 +797,18 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
   out << "<choice id=\"" << component.Name << "Choice\" "
       << "title=\"" << component.DisplayName << "\" "
       << "start_selected=\""
-      << (component.IsDisabledByDefault &&
-          !component.IsRequired? "false" : "true")
+      << (component.IsDisabledByDefault && !component.IsRequired ? "false"
+                                                                 : "true")
       << "\" "
-      << "start_enabled=\""
-      << (component.IsRequired? "false" : "true")
+      << "start_enabled=\"" << (component.IsRequired ? "false" : "true")
       << "\" "
-      << "start_visible=\"" << (component.IsHidden? "false" : "true") << "\" ";
-  if (!component.Description.empty())
-    {
-    out << "description=\"" << EscapeForXML(component.Description)
-        << "\" ";
-    }
+      << "start_visible=\"" << (component.IsHidden ? "false" : "true")
+      << "\" ";
+  if (!component.Description.empty()) {
+    out << "description=\"" << EscapeForXML(component.Description) << "\" ";
+  }
   if (!component.Dependencies.empty() ||
-      !component.ReverseDependencies.empty())
-    {
+      !component.ReverseDependencies.empty()) {
     // The "selected" expression is evaluated each time any choice is
     // selected, for all choices *except* the one that the user
     // selected. A component is marked selected if it has been
@@ -962,12 +824,12 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
     // on (B and A), while selecting something that depends on C--either D
     // or E--will automatically cause C to get selected.
     out << "selected=\"my.choice.selected";
-    std::set<const cmCPackComponent *> visited;
+    std::set<const cmCPackComponent*> visited;
     AddDependencyAttributes(component, visited, out);
     visited.clear();
     AddReverseDependencyAttributes(component, visited, out);
     out << "\"";
-    }
+  }
   out << ">" << std::endl;
   out << "  <pkg-ref id=\"" << packageId << "\"></pkg-ref>" << std::endl;
   out << "</choice>" << std::endl;
@@ -982,73 +844,56 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
   dirName += '/';
   dirName += component.Name;
   dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
-  unsigned long installedSize
-    = component.GetInstalledSizeInKbytes(dirName.c_str());
+  unsigned long installedSize =
+    component.GetInstalledSizeInKbytes(dirName.c_str());
 
   out << "<pkg-ref id=\"" << packageId << "\" "
       << "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
       << "installKBytes=\"" << installedSize << "\" "
       << "auth=\"Admin\" onConclusion=\"None\">";
-  if (component.IsDownloaded)
-    {
+  if (component.IsDownloaded) {
     out << this->GetOption("CPACK_DOWNLOAD_SITE")
         << this->GetPackageName(component);
-    }
-  else
-    {
+  } else {
     out << "file:./" << relativePackageLocation;
-    }
+  }
   out << "</pkg-ref>" << std::endl;
 }
 
-//----------------------------------------------------------------------
-void
-cmCPackPackageMakerGenerator::
-AddDependencyAttributes(const cmCPackComponent& component,
-                        std::set<const cmCPackComponent *>& visited,
-                        std::ostringstream& out)
+void cmCPackPackageMakerGenerator::AddDependencyAttributes(
+  const cmCPackComponent& component,
+  std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
 {
-  if (visited.find(&component) != visited.end())
-    {
+  if (visited.find(&component) != visited.end()) {
     return;
-    }
+  }
   visited.insert(&component);
 
-  std::vector<cmCPackComponent *>::const_iterator dependIt;
+  std::vector<cmCPackComponent*>::const_iterator dependIt;
   for (dependIt = component.Dependencies.begin();
-       dependIt != component.Dependencies.end();
-       ++dependIt)
-    {
-    out << " && choices['" <<
-      (*dependIt)->Name << "Choice'].selected";
+       dependIt != component.Dependencies.end(); ++dependIt) {
+    out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
     AddDependencyAttributes(**dependIt, visited, out);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
-void
-cmCPackPackageMakerGenerator::
-AddReverseDependencyAttributes(const cmCPackComponent& component,
-                               std::set<const cmCPackComponent *>& visited,
-                               std::ostringstream& out)
+void cmCPackPackageMakerGenerator::AddReverseDependencyAttributes(
+  const cmCPackComponent& component,
+  std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
 {
-  if (visited.find(&component) != visited.end())
-    {
+  if (visited.find(&component) != visited.end()) {
     return;
-    }
+  }
   visited.insert(&component);
 
-  std::vector<cmCPackComponent *>::const_iterator dependIt;
+  std::vector<cmCPackComponent*>::const_iterator dependIt;
   for (dependIt = component.ReverseDependencies.begin();
-       dependIt != component.ReverseDependencies.end();
-       ++dependIt)
-    {
+       dependIt != component.ReverseDependencies.end(); ++dependIt) {
     out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
     AddReverseDependencyAttributes(**dependIt, visited, out);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 std::string cmCPackPackageMakerGenerator::EscapeForXML(std::string str)
 {
   cmSystemTools::ReplaceString(str, "&", "&");
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index 7d349c6..2b8d253 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -13,7 +13,6 @@
 #ifndef cmCPackPackageMakerGenerator_h
 #define cmCPackPackageMakerGenerator_h
 
-
 #include "cmCPackGenerator.h"
 
 class cmCPackComponent;
@@ -38,8 +37,7 @@ public:
   virtual bool SupportsComponentInstallation() const;
 
 protected:
-  int CopyInstallScript(const std::string& resdir,
-                        const std::string& script,
+  int CopyInstallScript(const std::string& resdir, const std::string& script,
                         const std::string& name);
   virtual int InitializeInternal();
   int PackageFiles();
@@ -58,7 +56,7 @@ protected:
   // Run PackageMaker with the given command line, which will (if
   // successful) produce the given package file. Returns true if
   // PackageMaker succeeds, false otherwise.
-  bool RunPackageMaker(const char *command, const char *packageFile);
+  bool RunPackageMaker(const char* command, const char* packageFile);
 
   // Retrieve the name of package file that will be generated for this
   // component. The name is just the file name with extension, and
@@ -69,8 +67,8 @@ protected:
   // component.  All of the files within this component are stored in
   // the directory packageDir. Returns true if successful, false
   // otherwise.
-  bool GenerateComponentPackage(const char *packageFile,
-                                const char *packageDir,
+  bool GenerateComponentPackage(const char* packageFile,
+                                const char* packageDir,
                                 const cmCPackComponent& component);
 
   // Writes a distribution.dist file, which turns a metapackage into a
@@ -83,15 +81,14 @@ protected:
   // Subroutine of WriteDistributionFile that writes out the
   // dependency attributes for inter-component dependencies.
   void AddDependencyAttributes(const cmCPackComponent& component,
-                               std::set<const cmCPackComponent *>& visited,
+                               std::set<const cmCPackComponent*>& visited,
                                std::ostringstream& out);
 
   // Subroutine of WriteDistributionFile that writes out the
   // reverse dependency attributes for inter-component dependencies.
-  void
-  AddReverseDependencyAttributes(const cmCPackComponent& component,
-                                 std::set<const cmCPackComponent *>& visited,
-                                 std::ostringstream& out);
+  void AddReverseDependencyAttributes(
+    const cmCPackComponent& component,
+    std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
 
   // Generates XML that encodes the hierarchy of component groups and
   // their components in a form that can be used by distribution
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 71ab3a0..9827b70 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -10,90 +10,94 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCPackRPMGenerator.h"
+
 #include "cmCPackLog.h"
 #include "cmSystemTools.h"
 
-//----------------------------------------------------------------------
 cmCPackRPMGenerator::cmCPackRPMGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackRPMGenerator::~cmCPackRPMGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackRPMGenerator::InitializeInternal()
 {
   this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
-  if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
-    {
+  if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
     this->SetOption("CPACK_SET_DESTDIR", "I_ON");
-    }
+  }
   /* Replace space in CPACK_PACKAGE_NAME in order to avoid
    * rpmbuild scream on unwanted space in filename issue
    * Moreover RPM file do not usually embed space in filename
    */
   if (this->GetOption("CPACK_PACKAGE_NAME")) {
-    std::string packageName=this->GetOption("CPACK_PACKAGE_NAME");
-    cmSystemTools::ReplaceString(packageName," ","-");
-    this->SetOption("CPACK_PACKAGE_NAME",packageName.c_str());
+    std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
+    std::replace(packageName.begin(), packageName.end(), ' ', '-');
+    this->SetOption("CPACK_PACKAGE_NAME", packageName.c_str());
   }
   /* same for CPACK_PACKAGE_FILE_NAME */
   if (this->GetOption("CPACK_PACKAGE_FILE_NAME")) {
-    std::string packageName=this->GetOption("CPACK_PACKAGE_FILE_NAME");
-    cmSystemTools::ReplaceString(packageName," ","-");
-    this->SetOption("CPACK_PACKAGE_FILE_NAME",packageName.c_str());
+    std::string packageName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+    std::replace(packageName.begin(), packageName.end(), ' ', '-');
+    this->SetOption("CPACK_PACKAGE_FILE_NAME", packageName.c_str());
   }
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
-int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
-                                        std::string packageName)
+void cmCPackRPMGenerator::AddGeneratedPackageNames()
+{
+  // add the generated packages to package file names list
+  std::string fileNames(this->GetOption("GEN_CPACK_OUTPUT_FILES"));
+  const char sep = ';';
+  std::string::size_type pos1 = 0;
+  std::string::size_type pos2 = fileNames.find(sep, pos1 + 1);
+  while (pos2 != std::string::npos) {
+    packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
+    pos1 = pos2 + 1;
+    pos2 = fileNames.find(sep, pos1 + 1);
+  }
+  packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
+}
+
+int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel,
+                                        std::string const& packageName)
 {
   int retval = 1;
   // Begin the archive for this pack
   std::string localToplevel(initialToplevel);
-  std::string packageFileName(
-      cmSystemTools::GetParentDirectory(toplevel)
-                             );
+  std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
   std::string outputFileName(
-   GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
-                               packageName,
-                               true)
-                               + this->GetOutputExtension()
-                            );
+    GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+                                packageName, true) +
+    this->GetOutputExtension());
 
-  localToplevel += "/"+ packageName;
+  localToplevel += "/" + packageName;
   /* replace the TEMP DIRECTORY with the component one */
-  this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
-  packageFileName += "/"+ outputFileName;
+  this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+  packageFileName += "/" + outputFileName;
   /* replace proposed CPACK_OUTPUT_FILE_NAME */
-  this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+  this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
   /* replace the TEMPORARY package file name */
   this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
                   packageFileName.c_str());
   // Tell CPackRPM.cmake the name of the component NAME.
-  this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",packageName.c_str());
+  this->SetOption("CPACK_RPM_PACKAGE_COMPONENT", packageName.c_str());
   // Tell CPackRPM.cmake the path where the component is.
   std::string component_path = "/";
   component_path += packageName;
   this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
                   component_path.c_str());
-  if (!this->ReadListFile("CPackRPM.cmake"))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error while execution CPackRPM.cmake" << std::endl);
+  if (!this->ReadListFile("CPackRPM.cmake")) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
+                    << std::endl);
     retval = 0;
-    }
-  // add the generated package to package file names list
-  packageFileNames.push_back(packageFileName);
+  }
+
   return retval;
 }
 
-//----------------------------------------------------------------------
 int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
 {
   int retval = 1;
@@ -104,163 +108,136 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
 
   // The default behavior is to have one package by component group
   // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
-  if (!ignoreGroup)
-    {
+  if (!ignoreGroup) {
     std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
-    for (compGIt=this->ComponentGroups.begin();
-        compGIt!=this->ComponentGroups.end(); ++compGIt)
-      {
+    for (compGIt = this->ComponentGroups.begin();
+         compGIt != this->ComponentGroups.end(); ++compGIt) {
       cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
-          << compGIt->first
-          << std::endl);
-      retval &= PackageOnePack(initialTopLevel,compGIt->first);
-      }
+                      << compGIt->first << std::endl);
+      retval &= PackageOnePack(initialTopLevel, compGIt->first);
+    }
     // Handle Orphan components (components not belonging to any groups)
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt=this->Components.begin();
-        compIt!=this->Components.end(); ++compIt )
-      {
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
       // Does the component belong to a group?
-      if (compIt->second.Group==NULL)
-        {
-        cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-            "Component <"
+      if (compIt->second.Group == NULL) {
+        cmCPackLogger(
+          cmCPackLog::LOG_VERBOSE, "Component <"
             << compIt->second.Name
             << "> does not belong to any group, package it separately."
             << std::endl);
-        retval &= PackageOnePack(initialTopLevel,compIt->first);
-        }
+        retval &= PackageOnePack(initialTopLevel, compIt->first);
       }
     }
+  }
   // CPACK_COMPONENTS_IGNORE_GROUPS is set
   // We build 1 package per component
-  else
-    {
+  else {
     std::map<std::string, cmCPackComponent>::iterator compIt;
-    for (compIt=this->Components.begin();
-         compIt!=this->Components.end(); ++compIt )
-      {
-      retval &= PackageOnePack(initialTopLevel,compIt->first);
-      }
+    for (compIt = this->Components.begin(); compIt != this->Components.end();
+         ++compIt) {
+      retval &= PackageOnePack(initialTopLevel, compIt->first);
     }
+  }
+
+  if (retval) {
+    AddGeneratedPackageNames();
+  }
+
   return retval;
 }
 
-//----------------------------------------------------------------------
-int cmCPackRPMGenerator::PackageComponentsAllInOne()
+int cmCPackRPMGenerator::PackageComponentsAllInOne(
+  const std::string& compInstDirName)
 {
   int retval = 1;
-  std::string compInstDirName;
   /* Reset package file name list it will be populated during the
    * component packaging run*/
   packageFileNames.clear();
   std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
 
-  compInstDirName = "ALL_COMPONENTS_IN_ONE";
-
   cmCPackLogger(cmCPackLog::LOG_VERBOSE,
                 "Packaging all groups in one package..."
                 "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)"
-      << std::endl);
+                  << std::endl);
 
   // The ALL GROUPS in ONE package case
   std::string localToplevel(initialTopLevel);
-  std::string packageFileName(
-      cmSystemTools::GetParentDirectory(toplevel)
-                             );
+  std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
   std::string outputFileName(
-            std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
-            + this->GetOutputExtension()
-                            );
+    std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+    this->GetOutputExtension());
   // all GROUP in one vs all COMPONENT in one
-  localToplevel += "/"+compInstDirName;
+  localToplevel += "/" + compInstDirName;
 
   /* replace the TEMP DIRECTORY with the component one */
-  this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str());
-  packageFileName += "/"+ outputFileName;
+  this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel.c_str());
+  packageFileName += "/" + outputFileName;
   /* replace proposed CPACK_OUTPUT_FILE_NAME */
-  this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str());
+  this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName.c_str());
   /* replace the TEMPORARY package file name */
   this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
-      packageFileName.c_str());
-  // Tell CPackRPM.cmake the path where the component is.
-  std::string component_path = "/";
-  component_path += compInstDirName;
-  this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
-                  component_path.c_str());
-  if (!this->ReadListFile("CPackRPM.cmake"))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Error while execution CPackRPM.cmake" << std::endl);
+                  packageFileName.c_str());
+
+  if (!compInstDirName.empty()) {
+    // Tell CPackRPM.cmake the path where the component is.
+    std::string component_path = "/";
+    component_path += compInstDirName;
+    this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
+                    component_path.c_str());
+  }
+
+  if (this->ReadListFile("CPackRPM.cmake")) {
+    AddGeneratedPackageNames();
+  } else {
+    cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
+                    << std::endl);
     retval = 0;
-    }
-  // add the generated package to package file names list
-  packageFileNames.push_back(packageFileName);
+  }
 
   return retval;
 }
 
-//----------------------------------------------------------------------
 int cmCPackRPMGenerator::PackageFiles()
 {
-  int retval = 1;
-
-  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: "
-                  << toplevel << std::endl);
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
 
   /* Are we in the component packaging case */
   if (WantsComponentInstallation()) {
     // CASE 1 : COMPONENT ALL-IN-ONE package
     // If ALL COMPONENTS in ONE package has been requested
     // then the package file is unique and should be open here.
-    if (componentPackageMethod == ONE_PACKAGE)
-      {
-      return PackageComponentsAllInOne();
-      }
+    if (componentPackageMethod == ONE_PACKAGE) {
+      return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
+    }
     // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
     // There will be 1 package for each component group
     // however one may require to ignore component group and
     // in this case you'll get 1 package for each component.
-    else
-      {
+    else {
       return PackageComponents(componentPackageMethod ==
                                ONE_PACKAGE_PER_COMPONENT);
-      }
+    }
   }
   // CASE 3 : NON COMPONENT package.
-  else
-    {
-    if (!this->ReadListFile("CPackRPM.cmake"))
-      {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-                    "Error while execution CPackRPM.cmake" << std::endl);
-      retval = 0;
-      }
-    }
-
-  if (!this->IsSet("RPMBUILD_EXECUTABLE"))
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find rpmbuild" << std::endl);
-    retval = 0;
-    }
-  return retval;
+  else {
+    return PackageComponentsAllInOne("");
+  }
 }
 
 bool cmCPackRPMGenerator::SupportsComponentInstallation() const
-  {
-  if (IsOn("CPACK_RPM_COMPONENT_INSTALL"))
-    {
-      return true;
-    }
-  else
-    {
-      return false;
-    }
+{
+  if (IsOn("CPACK_RPM_COMPONENT_INSTALL")) {
+    return true;
+  } else {
+    return false;
   }
+}
 
 std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
-    const std::string& componentName)
-  {
+  const std::string& componentName)
+{
   if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) {
     return componentName;
   }
@@ -270,14 +247,11 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
   }
   // We have to find the name of the COMPONENT GROUP
   // the current COMPONENT belongs to.
-  std::string groupVar = "CPACK_COMPONENT_" +
-        cmSystemTools::UpperCase(componentName) + "_GROUP";
-    if (NULL != GetOption(groupVar))
-      {
-      return std::string(GetOption(groupVar));
-      }
-    else
-      {
-      return componentName;
-      }
+  std::string groupVar =
+    "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
+  if (NULL != GetOption(groupVar)) {
+    return std::string(GetOption(groupVar));
+  } else {
+    return componentName;
   }
+}
diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h
index a7722bc..b39f2c2 100644
--- a/Source/CPack/cmCPackRPMGenerator.h
+++ b/Source/CPack/cmCPackRPMGenerator.h
@@ -13,7 +13,6 @@
 #ifndef cmCPackRPMGenerator_h
 #define cmCPackRPMGenerator_h
 
-
 #include "cmCPackGenerator.h"
 
 /** \class cmCPackRPMGenerator
@@ -36,7 +35,7 @@ public:
   virtual ~cmCPackRPMGenerator();
 
   static bool CanGenerate()
-    {
+  {
 #ifdef __APPLE__
     // on MacOS enable CPackRPM iff rpmbuild is found
     std::vector<std::string> locations;
@@ -47,7 +46,7 @@ public:
     // legacy behavior on other systems
     return true;
 #endif
-    }
+  }
 
 protected:
   virtual int InitializeInternal();
@@ -55,7 +54,8 @@ protected:
   /**
    * This method factors out the work done in component packaging case.
    */
-  int PackageOnePack(std::string initialToplevel, std::string packageName);
+  int PackageOnePack(std::string const& initialToplevel,
+                     std::string const& packageName);
   /**
    * The method used to package files when component
    * install is used. This will create one
@@ -66,12 +66,13 @@ protected:
    * Special case of component install where all
    * components will be put in a single installer.
    */
-  int PackageComponentsAllInOne();
+  int PackageComponentsAllInOne(const std::string& compInstDirName);
   virtual const char* GetOutputExtension() { return ".rpm"; }
   virtual bool SupportsComponentInstallation() const;
   virtual std::string GetComponentInstallDirNameSuffix(
-      const std::string& componentName);
+    const std::string& componentName);
 
+  void AddGeneratedPackageNames();
 };
 
 #endif
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 68b893f..4d07a7e 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -12,74 +12,68 @@
 
 #include "cmCPackSTGZGenerator.h"
 
-#include "cmake.h"
+#include "cmCPackLog.h"
 #include "cmGlobalGenerator.h"
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmCPackLog.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 
 #include <cmsys/FStream.hxx>
+
 #include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h>
 
-//----------------------------------------------------------------------
 cmCPackSTGZGenerator::cmCPackSTGZGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackSTGZGenerator::~cmCPackSTGZGenerator()
 {
 }
 
-//----------------------------------------------------------------------
 int cmCPackSTGZGenerator::InitializeInternal()
 {
   this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
 
   std::string inFile = this->FindTemplate("CPack.STGZ_Header.sh.in");
-  if ( inFile.empty() )
-    {
-    cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: "
-      << inFile << std::endl);
+  if (inFile.empty()) {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "Cannot find template file: " << inFile << std::endl);
     return 0;
-    }
+  }
   this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str());
   this->SetOptionIfNotSet("CPACK_AT_SIGN", "@");
 
   return this->Superclass::InitializeInternal();
 }
 
-//----------------------------------------------------------------------
 int cmCPackSTGZGenerator::PackageFiles()
 {
- bool retval = true;
-  if ( !this->Superclass::PackageFiles() )
-    {
+  bool retval = true;
+  if (!this->Superclass::PackageFiles()) {
     return 0;
-    }
+  }
 
   /* TGZ generator (our Superclass) may
    * have generated several packages (component packaging)
    * so we must iterate over generated packages.
    */
-  for (std::vector<std::string>::iterator it=packageFileNames.begin();
-       it != packageFileNames.end(); ++it)
-  {
+  for (std::vector<std::string>::iterator it = packageFileNames.begin();
+       it != packageFileNames.end(); ++it) {
     retval &= cmSystemTools::SetPermissions((*it).c_str(),
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
-      S_IREAD | S_IWRITE | S_IEXEC
+#if defined(_MSC_VER) || defined(__MINGW32__)
+                                            S_IREAD | S_IWRITE | S_IEXEC
 #else
-      S_IRUSR | S_IWUSR | S_IXUSR |
-      S_IRGRP | S_IWGRP | S_IXGRP |
-      S_IROTH | S_IWOTH | S_IXOTH
+                                            S_IRUSR | S_IWUSR | S_IXUSR |
+                                              S_IRGRP | S_IWGRP | S_IXGRP |
+                                              S_IROTH | S_IWOTH | S_IXOTH
 #endif
-    );
+                                            );
   }
   return retval;
 }
 
-//----------------------------------------------------------------------
 int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
 {
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Writing header" << std::endl);
@@ -90,10 +84,9 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
   std::string line;
   cmsys::ifstream ilfs(inLicFile.c_str());
   std::string licenseText;
-  while ( cmSystemTools::GetLineFromStream(ilfs, line) )
-    {
+  while (cmSystemTools::GetLineFromStream(ilfs, line)) {
     licenseText += line + "\n";
-    }
+  }
   this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT",
                           licenseText.c_str());
 
@@ -103,10 +96,9 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
   std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE");
   cmsys::ifstream ifs(inFile.c_str());
   std::string packageHeaderText;
-  while ( cmSystemTools::GetLineFromStream(ifs, line) )
-    {
+  while (cmSystemTools::GetLineFromStream(ifs, line)) {
     packageHeaderText += line + "\n";
-    }
+  }
 
   // Configure in the values
   std::string res;
@@ -114,17 +106,15 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
 
   // Count the lines
   const char* ptr = res.c_str();
-  while ( *ptr )
-    {
-    if ( *ptr == '\n' )
-      {
-      counter ++;
-      }
-    ++ptr;
+  while (*ptr) {
+    if (*ptr == '\n') {
+      counter++;
     }
-  counter ++;
-  cmCPackLogger(cmCPackLog::LOG_DEBUG,
-                "Number of lines: " << counter << std::endl);
+    ++ptr;
+  }
+  counter++;
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "Number of lines: " << counter
+                                                           << std::endl);
   char buffer[1024];
   sprintf(buffer, "%d", counter);
   cmSystemTools::ReplaceString(res, headerLengthTag, buffer);
diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h
index ccceec8..08152b5 100644
--- a/Source/CPack/cmCPackSTGZGenerator.h
+++ b/Source/CPack/cmCPackSTGZGenerator.h
@@ -13,7 +13,6 @@
 #ifndef cmCPackSTGZGenerator_h
 #define cmCPackSTGZGenerator_h
 
-
 #include "cmCPackTGZGenerator.h"
 
 /** \class cmCPackSTGZGenerator
diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx
index 3fa2b64..7c5c245 100644
--- a/Source/CPack/cmCPackTGZGenerator.cxx
+++ b/Source/CPack/cmCPackTGZGenerator.cxx
@@ -12,15 +12,11 @@
 
 #include "cmCPackTGZGenerator.h"
 
-//----------------------------------------------------------------------
 cmCPackTGZGenerator::cmCPackTGZGenerator()
-  :cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip,
-                           "paxr")
+  : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr")
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackTGZGenerator::~cmCPackTGZGenerator()
 {
 }
-
diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h
index 3a9fc6b..408422b 100644
--- a/Source/CPack/cmCPackTGZGenerator.h
+++ b/Source/CPack/cmCPackTGZGenerator.h
@@ -28,6 +28,7 @@ public:
    */
   cmCPackTGZGenerator();
   virtual ~cmCPackTGZGenerator();
+
 protected:
   virtual const char* GetOutputExtension() { return ".tar.gz"; }
 };
diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx
index 6d4ede1..d17a164 100644
--- a/Source/CPack/cmCPackTXZGenerator.cxx
+++ b/Source/CPack/cmCPackTXZGenerator.cxx
@@ -12,14 +12,11 @@
 
 #include "cmCPackTXZGenerator.h"
 
-//----------------------------------------------------------------------
 cmCPackTXZGenerator::cmCPackTXZGenerator()
-  :cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ,
-                           "paxr")
+  : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr")
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackTXZGenerator::~cmCPackTXZGenerator()
 {
 }
diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h
index bf8152f..05052a1 100644
--- a/Source/CPack/cmCPackTXZGenerator.h
+++ b/Source/CPack/cmCPackTXZGenerator.h
@@ -28,6 +28,7 @@ public:
    */
   cmCPackTXZGenerator();
   virtual ~cmCPackTXZGenerator();
+
 protected:
   virtual const char* GetOutputExtension() { return ".tar.xz"; }
 };
diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx
index 9ff588b..694d392 100644
--- a/Source/CPack/cmCPackTarBZip2Generator.cxx
+++ b/Source/CPack/cmCPackTarBZip2Generator.cxx
@@ -11,15 +11,12 @@
 ============================================================================*/
 
 #include "cmCPackTarBZip2Generator.h"
-//----------------------------------------------------------------------
+
 cmCPackTarBZip2Generator::cmCPackTarBZip2Generator()
- :cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2,
-                          "paxr")
+  : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr")
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator()
 {
 }
-
diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h
index 74c244e..4033197 100644
--- a/Source/CPack/cmCPackTarBZip2Generator.h
+++ b/Source/CPack/cmCPackTarBZip2Generator.h
@@ -27,6 +27,7 @@ public:
    */
   cmCPackTarBZip2Generator();
   virtual ~cmCPackTarBZip2Generator();
+
 protected:
   virtual const char* GetOutputExtension() { return ".tar.bz2"; }
 };
diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx
index 1c8311b..aec6893 100644
--- a/Source/CPack/cmCPackTarCompressGenerator.cxx
+++ b/Source/CPack/cmCPackTarCompressGenerator.cxx
@@ -12,15 +12,11 @@
 
 #include "cmCPackTarCompressGenerator.h"
 
-//----------------------------------------------------------------------
 cmCPackTarCompressGenerator::cmCPackTarCompressGenerator()
-  :cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress,
-                           "paxr")
+  : cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr")
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator()
 {
 }
-
diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx
index 7ef7729..9b42e6d 100644
--- a/Source/CPack/cmCPackZIPGenerator.cxx
+++ b/Source/CPack/cmCPackZIPGenerator.cxx
@@ -12,15 +12,11 @@
 
 #include "cmCPackZIPGenerator.h"
 
-//----------------------------------------------------------------------
 cmCPackZIPGenerator::cmCPackZIPGenerator()
-  :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone,
-                           "zip")
+  : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip")
 {
 }
 
-//----------------------------------------------------------------------
 cmCPackZIPGenerator::~cmCPackZIPGenerator()
 {
 }
-
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index c08897f..94e1615 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -12,92 +12,78 @@
 #include "cmSystemTools.h"
 
 // Need these for documentation support.
-#include "cmake.h"
-#include "cmDocumentation.h"
-#include "cmCPackGeneratorFactory.h"
 #include "cmCPackGenerator.h"
-#include "cmake.h"
+#include "cmCPackGeneratorFactory.h"
+#include "cmDocumentation.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
+#include "cmake.h"
+#include "cmake.h"
 
 #include "cmCPackLog.h"
 
 #include <cmsys/CommandLineArguments.hxx>
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Encoding.hxx>
+#include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationName[][2] =
-{
-  {0,
-   "  cpack - Packaging driver provided by CMake."},
-  {0,0}
+static const char* cmDocumentationName[][2] = {
+  { 0, "  cpack - Packaging driver provided by CMake." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsage[][2] =
-{
-  {0,
-   "  cpack -G <generator> [options]"},
-  {0,0}
+static const char* cmDocumentationUsage[][2] = {
+  { 0, "  cpack -G <generator> [options]" },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationOptions[][2] =
-{
-    {"-G <generator>", "Use the specified generator to generate package."},
-    {"-C <Configuration>", "Specify the project configuration"},
-    {"-D <var>=<value>", "Set a CPack variable."},
-    {"--config <config file>", "Specify the config file."},
-    {"--verbose,-V","enable verbose output"},
-    {"--debug","enable debug output (for CPack developers)"},
-    {"-P <package name>","override/define CPACK_PACKAGE_NAME"},
-    {"-R <package version>","override/define CPACK_PACKAGE_VERSION"},
-    {"-B <package directory>","override/define CPACK_PACKAGE_DIRECTORY"},
-    {"--vendor <vendor name>","override/define CPACK_PACKAGE_VENDOR"},
-    {0,0}
+static const char* cmDocumentationOptions[][2] = {
+  { "-G <generator>", "Use the specified generator to generate package." },
+  { "-C <Configuration>", "Specify the project configuration" },
+  { "-D <var>=<value>", "Set a CPack variable." },
+  { "--config <config file>", "Specify the config file." },
+  { "--verbose,-V", "enable verbose output" },
+  { "--debug", "enable debug output (for CPack developers)" },
+  { "-P <package name>", "override/define CPACK_PACKAGE_NAME" },
+  { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" },
+  { "-B <package directory>", "override/define CPACK_PACKAGE_DIRECTORY" },
+  { "--vendor <vendor name>", "override/define CPACK_PACKAGE_VENDOR" },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
 int cpackUnknownArgument(const char*, void*)
 {
   return 1;
 }
 
-//----------------------------------------------------------------------------
 struct cpackDefinitions
 {
   typedef std::map<std::string, std::string> MapType;
   MapType Map;
-  cmCPackLog *Log;
+  cmCPackLog* Log;
 };
 
-//----------------------------------------------------------------------------
 int cpackDefinitionArgument(const char* argument, const char* cValue,
-  void* call_data)
+                            void* call_data)
 {
   (void)argument;
   cpackDefinitions* def = static_cast<cpackDefinitions*>(call_data);
   std::string value = cValue;
-  size_t pos = value.find_first_of("=");
-  if ( pos == std::string::npos )
-    {
+  size_t pos = value.find_first_of('=');
+  if (pos == std::string::npos) {
     cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
-      "Please specify CPack definitions as: KEY=VALUE" << std::endl);
+                "Please specify CPack definitions as: KEY=VALUE" << std::endl);
     return 0;
-    }
+  }
   std::string key = value.substr(0, pos);
   value = value.c_str() + pos + 1;
   def->Map[key] = value;
   cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
-    << key << " to \"" << value << "\"" << std::endl);
+                << key << " to \"" << value << "\"" << std::endl);
   return 1;
 }
 
-
-//----------------------------------------------------------------------------
 // this is CPack.
-int main (int argc, char const* const* argv)
+int main(int argc, char const* const* argv)
 {
   cmsys::Encoding::CommandLineArguments args =
     cmsys::Encoding::CommandLineArguments::Main(argc, argv);
@@ -114,12 +100,12 @@ int main (int argc, char const* const* argv)
 
   cmSystemTools::EnableMSVCDebugHook();
 
-  if (cmSystemTools::GetCurrentWorkingDirectory().empty())
-    {
+  if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
     cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-      "Current working directory cannot be established." << std::endl);
+                "Current working directory cannot be established."
+                  << std::endl);
     return 1;
-    }
+  }
 
   std::string generator;
   bool help = false;
@@ -149,9 +135,9 @@ int main (int argc, char const* const* argv)
   // Help arguments
   arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help");
   arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull,
-    "CPack help");
+                  "CPack help");
   arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML,
-    "CPack help");
+                  "CPack help");
   arg.AddArgument("--help-man", argT::SPACE_ARGUMENT, &helpMAN, "CPack help");
   arg.AddArgument("--version", argT::NO_ARGUMENT, &helpVersion, "CPack help");
 
@@ -159,42 +145,39 @@ int main (int argc, char const* const* argv)
   arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V");
   arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
   arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
-    "CPack configuration file");
+                  "CPack configuration file");
   arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
-    "CPack build configuration");
-  arg.AddArgument("-G", argT::SPACE_ARGUMENT,
-    &generator, "CPack generator");
-  arg.AddArgument("-P", argT::SPACE_ARGUMENT,
-    &cpackProjectName, "CPack project name");
-  arg.AddArgument("-R", argT::SPACE_ARGUMENT,
-    &cpackProjectVersion, "CPack project version");
-  arg.AddArgument("-B", argT::SPACE_ARGUMENT,
-    &cpackProjectDirectory, "CPack project directory");
-  arg.AddArgument("--patch", argT::SPACE_ARGUMENT,
-    &cpackProjectPatch, "CPack project patch");
-  arg.AddArgument("--vendor", argT::SPACE_ARGUMENT,
-    &cpackProjectVendor, "CPack project vendor");
-  arg.AddCallback("-D", argT::SPACE_ARGUMENT,
-    cpackDefinitionArgument, &definitions, "CPack Definitions");
+                  "CPack build configuration");
+  arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
+  arg.AddArgument("-P", argT::SPACE_ARGUMENT, &cpackProjectName,
+                  "CPack project name");
+  arg.AddArgument("-R", argT::SPACE_ARGUMENT, &cpackProjectVersion,
+                  "CPack project version");
+  arg.AddArgument("-B", argT::SPACE_ARGUMENT, &cpackProjectDirectory,
+                  "CPack project directory");
+  arg.AddArgument("--patch", argT::SPACE_ARGUMENT, &cpackProjectPatch,
+                  "CPack project patch");
+  arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, &cpackProjectVendor,
+                  "CPack project vendor");
+  arg.AddCallback("-D", argT::SPACE_ARGUMENT, cpackDefinitionArgument,
+                  &definitions, "CPack Definitions");
   arg.SetUnknownArgumentCallback(cpackUnknownArgument);
 
   // Parse command line
   int parsed = arg.Parse();
 
   // Setup logging
-  if ( verbose )
-    {
+  if (verbose) {
     log.SetVerbose(verbose);
     cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
-    }
-  if ( debug )
-    {
+  }
+  if (debug) {
     log.SetDebug(debug);
     cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
-    }
+  }
 
   cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
-    "Read CPack config file: " << cpackConfigFile << std::endl);
+              "Read CPack config file: " << cpackConfigFile << std::endl);
 
   cmake cminst;
   cminst.SetHomeDirectory("");
@@ -203,18 +186,17 @@ int main (int argc, char const* const* argv)
   cminst.GetState()->RemoveUnscriptableCommands();
   cmGlobalGenerator cmgg(&cminst);
   cmsys::auto_ptr<cmMakefile> globalMF(
-        new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
+    new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
 #if defined(__CYGWIN__)
   globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
 #endif
 
   bool cpackConfigFileSpecified = true;
-  if ( cpackConfigFile.empty() )
-    {
+  if (cpackConfigFile.empty()) {
     cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
     cpackConfigFile += "/CPackConfig.cmake";
     cpackConfigFileSpecified = false;
-    }
+  }
 
   cmCPackGeneratorFactory generators;
   generators.SetLogger(&log);
@@ -227,262 +209,225 @@ int main (int argc, char const* const* argv)
    * should launch cpack using "cpackConfigFile" if it exists
    * in the current directory.
    */
-  if((doc.CheckOptions(argc, argv,"-G")) && !(argc==1))
-    {
-      help = true;
-    }
-  else
-    {
-      help = false;
-    }
+  if ((doc.CheckOptions(argc, argv, "-G")) && !(argc == 1)) {
+    help = true;
+  } else {
+    help = false;
+  }
 
   // This part is used for cpack documentation lookup as well.
   cminst.AddCMakePaths();
 
-  if ( parsed && !help )
-    {
+  if (parsed && !help) {
     // find out which system cpack is running on, so it can setup the search
     // paths, so FIND_XXX() commands can be used in scripts
     std::string systemFile =
       globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
-    if (!globalMF->ReadListFile(systemFile.c_str()))
-      {
+    if (!globalMF->ReadListFile(systemFile.c_str())) {
       cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-        "Error reading CMakeDetermineSystem.cmake" << std::endl);
+                  "Error reading CMakeDetermineSystem.cmake" << std::endl);
       return 1;
-      }
+    }
 
     systemFile =
       globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
-    if (!globalMF->ReadListFile(systemFile.c_str()))
-      {
+    if (!globalMF->ReadListFile(systemFile.c_str())) {
       cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-        "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
+                  "Error reading CMakeSystemSpecificInformation.cmake"
+                    << std::endl);
       return 1;
-      }
+    }
 
-    if ( !cpackBuildConfig.empty() )
-      {
+    if (!cpackBuildConfig.empty()) {
       globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
-      }
+    }
 
-    if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
-      {
-      cpackConfigFile =
-        cmSystemTools::CollapseFullPath(cpackConfigFile);
+    if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
+      cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
       cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
-        "Read CPack configuration file: " << cpackConfigFile
-        << std::endl);
-      if ( !globalMF->ReadListFile(cpackConfigFile.c_str()) )
-        {
+                  "Read CPack configuration file: " << cpackConfigFile
+                                                    << std::endl);
+      if (!globalMF->ReadListFile(cpackConfigFile.c_str())) {
         cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-          "Problem reading CPack config file: \""
-          << cpackConfigFile << "\"" << std::endl);
+                    "Problem reading CPack config file: \""
+                      << cpackConfigFile << "\"" << std::endl);
         return 1;
-        }
       }
-    else if ( cpackConfigFileSpecified )
-      {
+    } else if (cpackConfigFileSpecified) {
       cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-        "Cannot find CPack config file: \"" <<
-         cpackConfigFile << "\"" << std::endl);
+                  "Cannot find CPack config file: \"" << cpackConfigFile
+                                                      << "\"" << std::endl);
       return 1;
-      }
+    }
 
-    if ( !generator.empty() )
-      {
+    if (!generator.empty()) {
       globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
-      }
-    if ( !cpackProjectName.empty() )
-      {
+    }
+    if (!cpackProjectName.empty()) {
       globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
-      }
-    if ( !cpackProjectVersion.empty() )
-      {
+    }
+    if (!cpackProjectVersion.empty()) {
       globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
-        cpackProjectVersion.c_str());
-      }
-    if ( !cpackProjectVendor.empty() )
-      {
+                              cpackProjectVersion.c_str());
+    }
+    if (!cpackProjectVendor.empty()) {
       globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
-        cpackProjectVendor.c_str());
-      }
+                              cpackProjectVendor.c_str());
+    }
     // if this is not empty it has been set on the command line
     // go for it. Command line override values set in config file.
-    if ( !cpackProjectDirectory.empty() )
-      {
+    if (!cpackProjectDirectory.empty()) {
       globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
                               cpackProjectDirectory.c_str());
-      }
+    }
     // The value has not been set on the command line
-    else
-      {
+    else {
       // get a default value (current working directory)
       cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
       // use default value iff no value has been provided by the config file
-      if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY"))
-        {
+      if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) {
         globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
                                 cpackProjectDirectory.c_str());
-        }
       }
+    }
     cpackDefinitions::MapType::iterator cdit;
-    for ( cdit = definitions.Map.begin();
-      cdit != definitions.Map.end();
-      ++cdit )
-      {
+    for (cdit = definitions.Map.begin(); cdit != definitions.Map.end();
+         ++cdit) {
       globalMF->AddDefinition(cdit->first, cdit->second.c_str());
-      }
+    }
 
     const char* cpackModulesPath =
       globalMF->GetDefinition("CPACK_MODULE_PATH");
-    if ( cpackModulesPath )
-      {
+    if (cpackModulesPath) {
       globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
-      }
+    }
     const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
-    if ( !genList )
-      {
-      cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-        "CPack generator not specified" << std::endl);
-      }
-    else
-      {
+    if (!genList) {
+      cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
+                    << std::endl);
+    } else {
       std::vector<std::string> generatorsVector;
-      cmSystemTools::ExpandListArgument(genList,
-        generatorsVector);
+      cmSystemTools::ExpandListArgument(genList, generatorsVector);
       std::vector<std::string>::iterator it;
-      for ( it = generatorsVector.begin();
-        it != generatorsVector.end();
-        ++it )
-        {
+      for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) {
         const char* gen = it->c_str();
         cmMakefile::ScopePushPop raii(globalMF.get());
         cmMakefile* mf = globalMF.get();
         cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
-          "Specified generator: " << gen << std::endl);
-        if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
-          {
+                    "Specified generator: " << gen << std::endl);
+        if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {
           cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-            "CPack project name not specified" << std::endl);
+                      "CPack project name not specified" << std::endl);
           parsed = 0;
-          }
+        }
         if (parsed &&
             !(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
               (mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
                mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
-               mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"))))
-          {
+               mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
           cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-            "CPack project version not specified" << std::endl
-            << "Specify CPACK_PACKAGE_VERSION, or "
-            "CPACK_PACKAGE_VERSION_MAJOR, "
-            "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
-            << std::endl);
+                      "CPack project version not specified"
+                        << std::endl
+                        << "Specify CPACK_PACKAGE_VERSION, or "
+                           "CPACK_PACKAGE_VERSION_MAJOR, "
+                           "CPACK_PACKAGE_VERSION_MINOR, and "
+                           "CPACK_PACKAGE_VERSION_PATCH."
+                        << std::endl);
           parsed = 0;
-          }
-        if ( parsed )
-          {
+        }
+        if (parsed) {
           cpackGenerator = generators.NewGenerator(gen);
-          if ( !cpackGenerator )
-            {
+          if (!cpackGenerator) {
             cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-              "Cannot initialize CPack generator: "
-              << gen << std::endl);
+                        "Cannot initialize CPack generator: " << gen
+                                                              << std::endl);
             parsed = 0;
-            }
-          if ( parsed && !cpackGenerator->Initialize(gen, mf) )
-            {
+          }
+          if (parsed && !cpackGenerator->Initialize(gen, mf)) {
             cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-              "Cannot initialize the generator " << gen << std::endl);
+                        "Cannot initialize the generator " << gen
+                                                           << std::endl);
             parsed = 0;
-            }
+          }
 
-          if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
-            !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
-            !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
-            {
-            cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+          if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
+              !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
+              !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
+            cmCPack_Log(
+              &log, cmCPackLog::LOG_ERROR,
               "Please specify build tree of the project that uses CMake "
               "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
               "CPACK_INSTALL_COMMANDS, or specify "
               "CPACK_INSTALLED_DIRECTORIES."
-              << std::endl);
+                << std::endl);
             parsed = 0;
-            }
-          if ( parsed )
-            {
+          }
+          if (parsed) {
             const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
             cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
-              << cpackGenerator->GetNameOfClass() << std::endl);
-            cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
-              << projName << std::endl);
+                          << cpackGenerator->GetNameOfClass() << std::endl);
+            cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
+                        "For project: " << projName << std::endl);
 
             const char* projVersion =
               mf->GetDefinition("CPACK_PACKAGE_VERSION");
-            if ( !projVersion )
-              {
-              const char* projVersionMajor
-                = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
-              const char* projVersionMinor
-                = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
-              const char* projVersionPatch
-                = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
+            if (!projVersion) {
+              const char* projVersionMajor =
+                mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
+              const char* projVersionMinor =
+                mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
+              const char* projVersionPatch =
+                mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
               std::ostringstream ostr;
               ostr << projVersionMajor << "." << projVersionMinor << "."
-                << projVersionPatch;
-              mf->AddDefinition("CPACK_PACKAGE_VERSION",
-                                ostr.str().c_str());
-              }
+                   << projVersionPatch;
+              mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
+            }
 
             int res = cpackGenerator->DoPackage();
-            if ( !res )
-              {
+            if (!res) {
               cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-                "Error when generating package: " << projName << std::endl);
+                          "Error when generating package: " << projName
+                                                            << std::endl);
               return 1;
-              }
             }
           }
         }
       }
     }
+  }
 
   /* In this case we are building the documentation object
    * instance in order to create appropriate structure
    * in order to satisfy the appropriate --help-xxx request
    */
-  if ( help )
-    {
+  if (help) {
     // Construct and print requested documentation.
 
     doc.SetName("cpack");
-    doc.SetSection("Name",cmDocumentationName);
-    doc.SetSection("Usage",cmDocumentationUsage);
-    doc.PrependSection("Options",cmDocumentationOptions);
+    doc.SetSection("Name", cmDocumentationName);
+    doc.SetSection("Usage", cmDocumentationUsage);
+    doc.PrependSection("Options", cmDocumentationOptions);
 
     std::vector<cmDocumentationEntry> v;
     cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
-    for( generatorIt = generators.GetGeneratorsList().begin();
-      generatorIt != generators.GetGeneratorsList().end();
-      ++ generatorIt )
-      {
+    for (generatorIt = generators.GetGeneratorsList().begin();
+         generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
       cmDocumentationEntry e;
-      e.Name = generatorIt->first.c_str();
-      e.Brief = generatorIt->second.c_str();
+      e.Name = generatorIt->first;
+      e.Brief = generatorIt->second;
       v.push_back(e);
-      }
-    doc.SetSection("Generators",v);
+    }
+    doc.SetSection("Generators", v);
 
 #undef cout
-    return doc.PrintRequestedDocumentation(std::cout)? 0:1;
+    return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
 #define cout no_cout_use_cmCPack_Log
-    }
+  }
 
-  if (cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return 1;
-    }
+  }
 
   return 0;
 }
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 587b583..dd53be8 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -19,144 +19,132 @@
 
 #include <cm_expat.h>
 
-//----------------------------------------------------------------------------
-extern "C"
-int cmBZRXMLParserUnknownEncodingHandler(void*,
-                                         const XML_Char *name,
-                                         XML_Encoding *info)
+extern "C" int cmBZRXMLParserUnknownEncodingHandler(void*,
+                                                    const XML_Char* name,
+                                                    XML_Encoding* info)
 {
-  static const int latin1[]=
-    {
-      0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
-      0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
-      0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
-      0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
-      0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
-      0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
-      0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
-      0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
-      0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
-      0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
-      0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
-      0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
-      0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
-      0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
-      0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
-      0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F,
-      0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
-      0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
-      0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
-      0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178,
-      0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
-      0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
-      0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
-      0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
-      0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
-      0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
-      0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
-      0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
-      0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
-      0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
-      0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
-      0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
-    };
+  static const int latin1[] = {
+    0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
+    0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011,
+    0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A,
+    0x001B, 0x001C, 0x001D, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023,
+    0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C,
+    0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
+    0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
+    0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+    0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
+    0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
+    0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062,
+    0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B,
+    0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074,
+    0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D,
+    0x007E, 0x007F, 0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020,
+    0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
+    0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC,
+    0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178, 0x00A0, 0x00A1,
+    0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA,
+    0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3,
+    0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC,
+    0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5,
+    0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE,
+    0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+    0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0,
+    0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9,
+    0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2,
+    0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB,
+    0x00FC, 0x00FD, 0x00FE, 0x00FF
+  };
 
   // The BZR xml output plugin can use some encodings that are not
   // recognized by expat.  This will lead to an error, e.g. "Error
   // parsing bzr log xml: unknown encoding", the following is a
   // workaround for these unknown encodings.
-  if(name == std::string("ascii") || name == std::string("cp1252") ||
-     name == std::string("ANSI_X3.4-1968"))
-    {
-    for(unsigned int i=0;i<256;++i) info->map[i] = latin1[i];
+  if (name == std::string("ascii") || name == std::string("cp1252") ||
+      name == std::string("ANSI_X3.4-1968")) {
+    for (unsigned int i = 0; i < 256; ++i)
+      info->map[i] = latin1[i];
     return 1;
-    }
+  }
 
   return 0;
 }
 
-//----------------------------------------------------------------------------
-cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log):
-  cmCTestGlobalVC(ct, log)
+cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log)
+  : cmCTestGlobalVC(ct, log)
 {
   this->PriorRev = this->Unknown;
-  // Even though it is specified in the documention, with bzr 1.13
+  // Even though it is specified in the documentation, with bzr 1.13
   // BZR_PROGRESS_BAR has no effect. In the future this bug might be fixed.
   // Since it doesn't hurt, we specify this environment variable.
   cmSystemTools::PutEnv("BZR_PROGRESS_BAR=none");
 }
 
-//----------------------------------------------------------------------------
 cmCTestBZR::~cmCTestBZR()
 {
 }
 
-//----------------------------------------------------------------------------
-class cmCTestBZR::InfoParser: public cmCTestVC::LineParser
+class cmCTestBZR::InfoParser : public cmCTestVC::LineParser
 {
 public:
-  InfoParser(cmCTestBZR* bzr, const char* prefix):
-    BZR(bzr), CheckOutFound(false)
-    {
+  InfoParser(cmCTestBZR* bzr, const char* prefix)
+    : BZR(bzr)
+    , CheckOutFound(false)
+  {
     this->SetLog(&bzr->Log, prefix);
     this->RegexCheckOut.compile("checkout of branch: *([^\t\r\n]+)$");
     this->RegexParent.compile("parent branch: *([^\t\r\n]+)$");
-    }
+  }
+
 private:
   cmCTestBZR* BZR;
   bool CheckOutFound;
   cmsys::RegularExpression RegexCheckOut;
   cmsys::RegularExpression RegexParent;
   virtual bool ProcessLine()
-    {
-    if(this->RegexCheckOut.find(this->Line))
-      {
+  {
+    if (this->RegexCheckOut.find(this->Line)) {
       this->BZR->URL = this->RegexCheckOut.match(1);
       CheckOutFound = true;
-      }
-    else if(!CheckOutFound && this->RegexParent.find(this->Line))
-      {
+    } else if (!CheckOutFound && this->RegexParent.find(this->Line)) {
       this->BZR->URL = this->RegexParent.match(1);
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
-class cmCTestBZR::RevnoParser: public cmCTestVC::LineParser
+class cmCTestBZR::RevnoParser : public cmCTestVC::LineParser
 {
 public:
-  RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev):
-    Rev(rev)
-    {
+  RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev)
+    : Rev(rev)
+  {
     this->SetLog(&bzr->Log, prefix);
     this->RegexRevno.compile("^([0-9]+)$");
-    }
+  }
+
 private:
   std::string& Rev;
   cmsys::RegularExpression RegexRevno;
   virtual bool ProcessLine()
-    {
-    if(this->RegexRevno.find(this->Line))
-      {
+  {
+    if (this->RegexRevno.find(this->Line)) {
       this->Rev = this->RegexRevno.match(1);
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
 std::string cmCTestBZR::LoadInfo()
 {
   // Run "bzr info" to get the repository info from the work tree.
   const char* bzr = this->CommandLineTool.c_str();
-  const char* bzr_info[] = {bzr, "info", 0};
+  const char* bzr_info[] = { bzr, "info", 0 };
   InfoParser iout(this, "info-out> ");
   OutputLogger ierr(this->Log, "info-err> ");
   this->RunChild(bzr_info, &iout, &ierr);
 
   // Run "bzr revno" to get the repository revision number from the work tree.
-  const char* bzr_revno[] = {bzr, "revno", 0};
+  const char* bzr_revno[] = { bzr, "revno", 0 };
   std::string rev;
   RevnoParser rout(this, "revno-out> ", rev);
   OutputLogger rerr(this->Log, "revno-err> ");
@@ -170,46 +158,47 @@ void cmCTestBZR::NoteOldRevision()
   this->OldRevision = this->LoadInfo();
   this->Log << "Revision before update: " << this->OldRevision << "\n";
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Old revision of repository is: "
-             << this->OldRevision << "\n");
+               << this->OldRevision << "\n");
   this->PriorRev.Rev = this->OldRevision;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestBZR::NoteNewRevision()
 {
   this->NewRevision = this->LoadInfo();
   this->Log << "Revision after update: " << this->NewRevision << "\n";
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   New revision of repository is: "
-             << this->NewRevision << "\n");
+               << this->NewRevision << "\n");
   this->Log << "URL = " << this->URL << "\n";
 }
 
-//----------------------------------------------------------------------------
-class cmCTestBZR::LogParser: public cmCTestVC::OutputLogger,
-                             private cmXMLParser
+class cmCTestBZR::LogParser : public cmCTestVC::OutputLogger,
+                              private cmXMLParser
 {
 public:
-  LogParser(cmCTestBZR* bzr, const char* prefix):
-    OutputLogger(bzr->Log, prefix), BZR(bzr),
-    EmailRegex("(.*) <([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+)>")
-    { this->InitializeParser(); }
+  LogParser(cmCTestBZR* bzr, const char* prefix)
+    : OutputLogger(bzr->Log, prefix)
+    , BZR(bzr)
+    , EmailRegex("(.*) <([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+)>")
+  {
+    this->InitializeParser();
+  }
   ~LogParser() { this->CleanupParser(); }
 
   virtual int InitializeParser()
-     {
-     int res = cmXMLParser::InitializeParser();
-     if (res)
-       {
-       XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser),
-                                     cmBZRXMLParserUnknownEncodingHandler, 0);
-       }
-     return res;
-     }
+  {
+    int res = cmXMLParser::InitializeParser();
+    if (res) {
+      XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser),
+                                    cmBZRXMLParserUnknownEncodingHandler, 0);
+    }
+    return res;
+  }
+
 private:
   cmCTestBZR* BZR;
 
   typedef cmCTestBZR::Revision Revision;
-  typedef cmCTestBZR::Change   Change;
+  typedef cmCTestBZR::Change Change;
   Revision Rev;
   std::vector<Change> Changes;
   Change CurChange;
@@ -218,196 +207,161 @@ private:
   cmsys::RegularExpression EmailRegex;
 
   virtual bool ProcessChunk(const char* data, int length)
-    {
+  {
     this->OutputLogger::ProcessChunk(data, length);
     this->ParseChunk(data, length);
     return true;
-    }
+  }
 
   virtual void StartElement(const std::string& name, const char**)
-    {
+  {
     this->CData.clear();
-    if(name == "log")
-      {
+    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(name == "modified"
-            || name == "renamed"
-            || name == "kind-changed")
-      {
+    else if (name == "modified" || name == "renamed" ||
+             name == "kind-changed") {
       this->CurChange = Change();
       this->CurChange.Action = 'M';
-      }
-    else if(name == "added")
-      {
+    } else if (name == "added") {
       this->CurChange = Change();
       this->CurChange = 'A';
-      }
-    else if(name == "removed")
-      {
+    } else if (name == "removed") {
       this->CurChange = Change();
       this->CurChange = 'D';
-      }
-    else if(name == "unknown"
-            || name == "conflicts")
-      {
+    } else if (name == "unknown" || name == "conflicts") {
       // Should not happen here
       this->CurChange = Change();
-      }
     }
+  }
 
   virtual void CharacterDataHandler(const char* data, int length)
-    {
-    this->CData.insert(this->CData.end(), data, data+length);
-    }
+  {
+    this->CData.insert(this->CData.end(), data, data + length);
+  }
 
   virtual void EndElement(const std::string& name)
-    {
-    if(name == "log")
-      {
+  {
+    if (name == "log") {
       this->BZR->DoRevision(this->Rev, this->Changes);
-      }
-    else if(!this->CData.empty() &&
-            (name == "file" || name == "directory"))
-      {
+    } 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(!this->CData.empty() && name == "symlink")
-      {
+    } 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);
+      this->CurChange.Path.assign(&this->CData[0], this->CData.size() - 1);
       cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
       this->Changes.push_back(this->CurChange);
-      }
-    else if(!this->CData.empty() && name == "committer")
-      {
+    } else if (!this->CData.empty() && name == "committer") {
       this->Rev.Author.assign(&this->CData[0], this->CData.size());
-      if(this->EmailRegex.find(this->Rev.Author))
-        {
+      if (this->EmailRegex.find(this->Rev.Author)) {
         this->Rev.Author = this->EmailRegex.match(1);
         this->Rev.EMail = this->EmailRegex.match(2);
-        }
       }
-    else if(!this->CData.empty() && name == "timestamp")
-      {
+    } else if (!this->CData.empty() && name == "timestamp") {
       this->Rev.Date.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "message")
-      {
+    } else if (!this->CData.empty() && name == "message") {
       this->Rev.Log.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "revno")
-      {
+    } else if (!this->CData.empty() && name == "revno") {
       this->Rev.Rev.assign(&this->CData[0], this->CData.size());
-      }
-    this->CData.clear();
     }
+    this->CData.clear();
+  }
 
   virtual void ReportError(int, int, const char* msg)
-    {
+  {
     this->BZR->Log << "Error parsing bzr log xml: " << msg << "\n";
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
-class cmCTestBZR::UpdateParser: public cmCTestVC::LineParser
+class cmCTestBZR::UpdateParser : public cmCTestVC::LineParser
 {
 public:
-  UpdateParser(cmCTestBZR* bzr, const char* prefix): BZR(bzr)
-    {
+  UpdateParser(cmCTestBZR* bzr, const char* prefix)
+    : BZR(bzr)
+  {
     this->SetLog(&bzr->Log, prefix);
     this->RegexUpdate.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$");
-    }
+  }
+
 private:
   cmCTestBZR* BZR;
   cmsys::RegularExpression RegexUpdate;
 
   virtual bool ProcessChunk(const char* first, int length)
-    {
+  {
     bool last_is_new_line = (*first == '\r' || *first == '\n');
 
     const char* const last = first + length;
-    for(const char* c = first; c != last; ++c)
-      {
-      if(*c == '\r' || *c == '\n')
-        {
-        if(!last_is_new_line)
-          {
+    for (const char* c = first; c != last; ++c) {
+      if (*c == '\r' || *c == '\n') {
+        if (!last_is_new_line) {
           // Log this line.
-          if(this->Log && this->Prefix)
-            {
+          if (this->Log && this->Prefix) {
             *this->Log << this->Prefix << this->Line << "\n";
-            }
+          }
 
           // Hand this line to the subclass implementation.
-          if(!this->ProcessLine())
-            {
+          if (!this->ProcessLine()) {
             this->Line = "";
             return false;
-            }
+          }
 
           this->Line = "";
           last_is_new_line = true;
-          }
         }
-      else
-        {
+      } else {
         // Append this character to the line under construction.
         this->Line.append(1, *c);
         last_is_new_line = false;
-        }
       }
-    return true;
     }
+    return true;
+  }
 
   bool ProcessLine()
-    {
-    if(this->RegexUpdate.find(this->Line))
-      {
+  {
+    if (this->RegexUpdate.find(this->Line)) {
       this->DoPath(this->RegexUpdate.match(1)[0],
                    this->RegexUpdate.match(2)[0],
-                   this->RegexUpdate.match(3)[0],
-                   this->RegexUpdate.match(4));
-      }
-    return true;
+                   this->RegexUpdate.match(3)[0], this->RegexUpdate.match(4));
     }
+    return true;
+  }
 
   void DoPath(char c0, char c1, char c2, std::string path)
-    {
-    if(path.empty()) return;
+  {
+    if (path.empty())
+      return;
     cmSystemTools::ConvertToUnixSlashes(path);
 
     const std::string dir = cmSystemTools::GetFilenamePath(path);
     const std::string name = cmSystemTools::GetFilenameName(path);
 
-    if ( c0=='C' )
-      {
+    if (c0 == 'C') {
       this->BZR->Dirs[dir][name].Status = PathConflicting;
       return;
-      }
+    }
 
-    if ( c1=='M' || c1=='K' || c1=='N' || c1=='D' || c2 =='*' )
-      {
+    if (c1 == 'M' || c1 == 'K' || c1 == 'N' || c1 == 'D' || c2 == '*') {
       this->BZR->Dirs[dir][name].Status = PathUpdated;
       return;
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
 bool cmCTestBZR::UpdateImpl()
 {
   // Get user-specified update options.
   std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
-  if(opts.empty())
-    {
+  if (opts.empty()) {
     opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
-    }
+  }
   std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
 
   // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -417,11 +371,10 @@ bool cmCTestBZR::UpdateImpl()
   bzr_update.push_back(this->CommandLineTool.c_str());
   bzr_update.push_back("pull");
 
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     bzr_update.push_back(ai->c_str());
-    }
+  }
 
   bzr_update.push_back(this->URL.c_str());
 
@@ -433,89 +386,83 @@ bool cmCTestBZR::UpdateImpl()
   return this->RunUpdateCommand(&bzr_update[0], &out, &err);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestBZR::LoadRevisions()
 {
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              "   Gathering version information (one . per revision):\n"
-             "    " << std::flush);
+             "    "
+               << std::flush);
 
   // We are interested in every revision included in the update.
   this->Revisions.clear();
   std::string revs;
-  if(atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str()))
-    {
+  if (atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) {
     // DoRevision takes care of discarding the information about OldRevision
     revs = this->OldRevision + ".." + this->NewRevision;
-    }
-  else
-    {
+  } else {
     return;
-    }
+  }
 
   // Run "bzr log" to get all global revisions of interest.
   const char* bzr = this->CommandLineTool.c_str();
-  const char* bzr_log[] = {bzr, "log", "-v", "-r", revs.c_str(), "--xml",
-                           this->URL.c_str(), 0};
+  const char* bzr_log[] = {
+    bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(), 0
+  };
   {
-  LogParser out(this, "log-out> ");
-  OutputLogger err(this->Log, "log-err> ");
-  this->RunChild(bzr_log, &out, &err);
+    LogParser out(this, "log-out> ");
+    OutputLogger err(this->Log, "log-err> ");
+    this->RunChild(bzr_log, &out, &err);
   }
   cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
 }
 
-//----------------------------------------------------------------------------
-class cmCTestBZR::StatusParser: public cmCTestVC::LineParser
+class cmCTestBZR::StatusParser : public cmCTestVC::LineParser
 {
 public:
-  StatusParser(cmCTestBZR* bzr, const char* prefix): BZR(bzr)
-    {
+  StatusParser(cmCTestBZR* bzr, const char* prefix)
+    : BZR(bzr)
+  {
     this->SetLog(&bzr->Log, prefix);
     this->RegexStatus.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$");
-    }
+  }
+
 private:
   cmCTestBZR* BZR;
   cmsys::RegularExpression RegexStatus;
   bool ProcessLine()
-    {
-    if(this->RegexStatus.find(this->Line))
-      {
+  {
+    if (this->RegexStatus.find(this->Line)) {
       this->DoPath(this->RegexStatus.match(1)[0],
                    this->RegexStatus.match(2)[0],
-                   this->RegexStatus.match(3)[0],
-                   this->RegexStatus.match(4));
-      }
-    return true;
+                   this->RegexStatus.match(3)[0], this->RegexStatus.match(4));
     }
+    return true;
+  }
 
   void DoPath(char c0, char c1, char c2, std::string path)
-    {
-    if(path.empty()) return;
+  {
+    if (path.empty())
+      return;
     cmSystemTools::ConvertToUnixSlashes(path);
 
-    if ( c0=='C' )
-      {
+    if (c0 == 'C') {
       this->BZR->DoModification(PathConflicting, path);
       return;
-      }
+    }
 
-    if ( c0 == '+' || c0 == 'R' || c0 == 'P'
-         || c1=='M' || c1=='K' || c1=='N' || c1=='D'
-         || c2 =='*' )
-      {
+    if (c0 == '+' || c0 == 'R' || c0 == 'P' || c1 == 'M' || c1 == 'K' ||
+        c1 == 'N' || c1 == 'D' || c2 == '*') {
       this->BZR->DoModification(PathModified, path);
       return;
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmCTestBZR::LoadModifications()
 {
   // Run "bzr status" which reports local modifications.
   const char* bzr = this->CommandLineTool.c_str();
-  const char* bzr_status[] = {bzr, "status", "-SV", 0};
+  const char* bzr_status[] = { bzr, "status", "-SV", 0 };
   StatusParser out(this, "status-out> ");
   OutputLogger err(this->Log, "status-err> ");
   this->RunChild(bzr_status, &out, &err);
diff --git a/Source/CTest/cmCTestBZR.h b/Source/CTest/cmCTestBZR.h
index df688e1..4f44136 100644
--- a/Source/CTest/cmCTestBZR.h
+++ b/Source/CTest/cmCTestBZR.h
@@ -18,7 +18,7 @@
  * \brief Interaction with bzr command-line tool
  *
  */
-class cmCTestBZR: public cmCTestGlobalVC
+class cmCTestBZR : public cmCTestGlobalVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx
index d62c260..386c8d5 100644
--- a/Source/CTest/cmCTestBatchTestHandler.cxx
+++ b/Source/CTest/cmCTestBatchTestHandler.cxx
@@ -11,9 +11,10 @@
 ============================================================================*/
 
 #include "cmCTestBatchTestHandler.h"
+
+#include "cmCTest.h"
 #include "cmProcess.h"
 #include "cmStandardIncludes.h"
-#include "cmCTest.h"
 #include "cmSystemTools.h"
 #include <stdlib.h>
 
@@ -21,43 +22,39 @@ cmCTestBatchTestHandler::~cmCTestBatchTestHandler()
 {
 }
 
-//---------------------------------------------------------
 void cmCTestBatchTestHandler::RunTests()
 {
   this->WriteBatchScript();
   this->SubmitBatchScript();
 }
 
-//---------------------------------------------------------
 void cmCTestBatchTestHandler::WriteBatchScript()
 {
-  this->Script = this->CTest->GetBinaryDir()
-    + "/Testing/CTestBatch.txt";
+  this->Script = this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt";
   cmsys::ofstream fout;
   fout.open(this->Script.c_str());
   fout << "#!/bin/sh\n";
 
-  for(TestMap::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i)
-    {
+  for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
+       ++i) {
     this->WriteSrunArgs(i->first, fout);
     this->WriteTestCommand(i->first, fout);
     fout << "\n";
-    }
+  }
   fout.flush();
   fout.close();
 }
 
-//---------------------------------------------------------
 void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
 {
   cmCTestTestHandler::cmCTestTestProperties* properties =
-      this->Properties[test];
+    this->Properties[test];
 
   fout << "srun ";
-  //fout << "--jobid=" << test << " ";
+  // fout << "--jobid=" << test << " ";
   fout << "-J=" << properties->Name << " ";
 
-  //Write dependency information
+  // Write dependency information
   /*if(!this->Tests[test].empty())
     {
       fout << "-P=afterany";
@@ -68,17 +65,14 @@ void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
         }
       fout << " ";
     }*/
-  if(properties->RunSerial)
-    {
+  if (properties->RunSerial) {
     fout << "--exclusive ";
-    }
-  if(properties->Processors > 1)
-    {
+  }
+  if (properties->Processors > 1) {
     fout << "-n" << properties->Processors << " ";
-    }
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout)
 {
   std::vector<std::string> args = this->Properties[test]->Args;
@@ -88,47 +82,41 @@ void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout)
   command = this->TestHandler->FindTheExecutable(args[1].c_str());
   command = cmSystemTools::ConvertToOutputPath(command.c_str());
 
-  //Prepends memcheck args to our command string if this is a memcheck
+  // Prepends memcheck args to our command string if this is a memcheck
   this->TestHandler->GenerateTestCommand(processArgs, test);
   processArgs.push_back(command);
 
-  for(std::vector<std::string>::iterator arg = processArgs.begin();
-      arg != processArgs.end(); ++arg)
-    {
+  for (std::vector<std::string>::iterator arg = processArgs.begin();
+       arg != processArgs.end(); ++arg) {
     fout << *arg << " ";
-    }
+  }
 
   std::vector<std::string>::iterator i = args.begin();
-  ++i; //the test name
-  ++i; //the executable (command)
-  if(args.size() > 2)
-    {
+  ++i; // the test name
+  ++i; // the executable (command)
+  if (args.size() > 2) {
     fout << "'";
-    }
-  while(i != args.end())
-    {
-    fout << "\"" << *i << "\""; //args to the test executable
+  }
+  while (i != args.end()) {
+    fout << "\"" << *i << "\""; // args to the test executable
     ++i;
 
-    if(i == args.end() && args.size() > 2)
-      {
+    if (i == args.end() && args.size() > 2) {
       fout << "'";
-      }
-    fout << " ";
     }
-  //TODO ZACH build TestResult.FullCommandLine
-  //this->TestResult.FullCommandLine = this->TestCommand;
+    fout << " ";
+  }
+  // TODO ZACH build TestResult.FullCommandLine
+  // this->TestResult.FullCommandLine = this->TestCommand;
 }
 
-//---------------------------------------------------------
 void cmCTestBatchTestHandler::SubmitBatchScript()
 {
   cmProcess sbatch;
   std::vector<std::string> args;
   args.push_back(this->Script);
   args.push_back("-o");
-  args.push_back(this->CTest->GetBinaryDir()
-                 + "/Testing/CTestBatch.txt");
+  args.push_back(this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt");
 
   sbatch.SetCommand("sbatch");
   sbatch.SetCommandArguments(args);
diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h
index e0c6e48..7a2a4a2 100644
--- a/Source/CTest/cmCTestBatchTestHandler.h
+++ b/Source/CTest/cmCTestBatchTestHandler.h
@@ -14,9 +14,10 @@
 #define cmCTestBatchTestHandler_h
 
 #include <cmStandardIncludes.h>
-#include <cmCTestTestHandler.h>
+
 #include <cmCTestMultiProcessHandler.h>
 #include <cmCTestRunTest.h>
+#include <cmCTestTestHandler.h>
 #include <cmsys/FStream.hxx>
 
 /** \class cmCTestBatchTestHandler
@@ -29,6 +30,7 @@ class cmCTestBatchTestHandler : public cmCTestMultiProcessHandler
 public:
   ~cmCTestBatchTestHandler();
   virtual void RunTests();
+
 protected:
   void WriteBatchScript();
   void WriteSrunArgs(int test, cmsys::ofstream& fout);
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 20d303d..0cba8b2 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -12,35 +12,31 @@
 
 #include "cmCTestBuildAndTestHandler.h"
 
-#include "cmSystemTools.h"
 #include "cmCTest.h"
-#include "cmake.h"
+#include "cmCTestTestHandler.h"
 #include "cmGlobalGenerator.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
 #include <cmsys/Process.h>
-#include "cmCTestTestHandler.h"
 
-//----------------------------------------------------------------------
 cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
 {
-  this->BuildTwoConfig         = false;
-  this->BuildNoClean           = false;
-  this->BuildNoCMake           = false;
+  this->BuildTwoConfig = false;
+  this->BuildNoClean = false;
+  this->BuildNoCMake = false;
   this->Timeout = 0;
 }
 
-//----------------------------------------------------------------------
 void cmCTestBuildAndTestHandler::Initialize()
 {
   this->BuildTargets.clear();
   this->Superclass::Initialize();
 }
 
-//----------------------------------------------------------------------
 const char* cmCTestBuildAndTestHandler::GetOutput()
 {
   return this->Output.c_str();
 }
-//----------------------------------------------------------------------
 int cmCTestBuildAndTestHandler::ProcessHandler()
 {
   this->Output = "";
@@ -51,100 +47,82 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
   return retv;
 }
 
-//----------------------------------------------------------------------
 int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
-  std::ostringstream &out, std::string &cmakeOutString, std::string &cwd,
-  cmake *cm)
+                                         std::ostringstream& out,
+                                         std::string& cmakeOutString,
+                                         std::string& cwd, cmake* cm)
 {
   unsigned int k;
   std::vector<std::string> args;
   args.push_back(cmSystemTools::GetCMakeCommand());
   args.push_back(this->SourceDir);
-  if(!this->BuildGenerator.empty())
-    {
+  if (!this->BuildGenerator.empty()) {
     std::string generator = "-G";
     generator += this->BuildGenerator;
     args.push_back(generator);
-    }
-  if(!this->BuildGeneratorPlatform.empty())
-    {
+  }
+  if (!this->BuildGeneratorPlatform.empty()) {
     std::string platform = "-A";
     platform += this->BuildGeneratorPlatform;
     args.push_back(platform);
-    }
-  if(!this->BuildGeneratorToolset.empty())
-    {
+  }
+  if (!this->BuildGeneratorToolset.empty()) {
     std::string toolset = "-T";
     toolset += this->BuildGeneratorToolset;
     args.push_back(toolset);
-    }
+  }
 
   const char* config = 0;
-  if (!this->CTest->GetConfigType().empty())
-    {
+  if (!this->CTest->GetConfigType().empty()) {
     config = this->CTest->GetConfigType().c_str();
-    }
+  }
 #ifdef CMAKE_INTDIR
-  if(!config)
-    {
+  if (!config) {
     config = CMAKE_INTDIR;
-    }
+  }
 #endif
 
-  if ( config )
-    {
-    std::string btype
-      = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
+  if (config) {
+    std::string btype = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
     args.push_back(btype);
-    }
+  }
 
-  for(k=0; k < this->BuildOptions.size(); ++k)
-    {
+  for (k = 0; k < this->BuildOptions.size(); ++k) {
     args.push_back(this->BuildOptions[k]);
-    }
-  if (cm->Run(args) != 0)
-    {
+  }
+  if (cm->Run(args) != 0) {
     out << "Error: cmake execution failed\n";
     out << cmakeOutString << "\n";
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd);
-    if(outstring)
-      {
+    if (outstring) {
       *outstring = out.str();
-      }
-    else
-      {
+    } else {
       cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl);
-      }
-    return 1;
     }
+    return 1;
+  }
   // do another config?
-  if(this->BuildTwoConfig)
-    {
-    if (cm->Run(args) != 0)
-      {
+  if (this->BuildTwoConfig) {
+    if (cm->Run(args) != 0) {
       out << "Error: cmake execution failed\n";
       out << cmakeOutString << "\n";
       // return to the original directory
       cmSystemTools::ChangeDirectory(cwd);
-      if(outstring)
-        {
+      if (outstring) {
         *outstring = out.str();
-        }
-      else
-        {
+      } else {
         cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl);
-        }
-      return 1;
       }
+      return 1;
     }
+  }
   out << "======== CMake output     ======\n";
   out << cmakeOutString;
   out << "======== End CMake output ======\n";
   return 0;
 }
 
-//----------------------------------------------------------------------
 void CMakeMessageCallback(const char* m, const char*, bool&, void* s)
 {
   std::string* out = (std::string*)s;
@@ -152,56 +130,52 @@ void CMakeMessageCallback(const char* m, const char*, bool&, void* s)
   *out += "\n";
 }
 
-void CMakeProgressCallback(const char*msg, float , void * s)
+void CMakeProgressCallback(const char* msg, float, void* s)
 {
   std::string* out = (std::string*)s;
   *out += msg;
   *out += "\n";
 }
 
-//----------------------------------------------------------------------
 void CMakeOutputCallback(const char* m, size_t len, void* s)
 {
   std::string* out = (std::string*)s;
   out->append(m, len);
 }
 
-//----------------------------------------------------------------------
 class cmCTestBuildAndTestCaptureRAII
 {
   cmake& CM;
+
 public:
-  cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm)
-    {
+  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)
 {
   // if the generator and make program are not specified then it is an error
-  if (this->BuildGenerator.empty())
-    {
-    if(outstring)
-      {
-      *outstring =
-        "--build-and-test requires that the generator "
-        "be provided using the --build-generator "
-        "command line option. ";
-      }
-    return 1;
+  if (this->BuildGenerator.empty()) {
+    if (outstring) {
+      *outstring = "--build-and-test requires that the generator "
+                   "be provided using the --build-generator "
+                   "command line option. ";
     }
+    return 1;
+  }
 
   cmake cm;
   cm.SetHomeDirectory("");
@@ -211,27 +185,21 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
   static_cast<void>(captureRAII);
   std::ostringstream out;
 
-  if ( this->CTest->GetConfigType().empty() &&
-       !this->ConfigSample.empty())
-    {
+  if (this->CTest->GetConfigType().empty() && !this->ConfigSample.empty()) {
     // use the config sample to set the ConfigType
     std::string fullPath;
     std::string resultingConfig;
     std::vector<std::string> extraPaths;
     std::vector<std::string> failed;
-    fullPath =
-      cmCTestTestHandler::FindExecutable(this->CTest,
-                                         this->ConfigSample.c_str(),
-                                         resultingConfig,
-                                         extraPaths,
-                                         failed);
-    if (!fullPath.empty() && !resultingConfig.empty())
-      {
+    fullPath = cmCTestTestHandler::FindExecutable(
+      this->CTest, this->ConfigSample.c_str(), resultingConfig, extraPaths,
+      failed);
+    if (!fullPath.empty() && !resultingConfig.empty()) {
       this->CTest->SetConfigType(resultingConfig.c_str());
-      }
-    out << "Using config sample with results: "
-        << fullPath << " and " << resultingConfig << std::endl;
     }
+    out << "Using config sample with results: " << fullPath << " and "
+        << resultingConfig << std::endl;
+  }
 
   // we need to honor the timeout specified, the timeout include cmake, build
   // and test time
@@ -239,100 +207,79 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
 
   // make sure the binary dir is there
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  out << "Internal cmake changing into directory: "
-    << this->BinaryDir << std::endl;
-  if (!cmSystemTools::FileIsDirectory(this->BinaryDir))
-    {
+  out << "Internal cmake changing into directory: " << this->BinaryDir
+      << std::endl;
+  if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
     cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
-    }
+  }
   cmSystemTools::ChangeDirectory(this->BinaryDir);
 
-  if(this->BuildNoCMake)
-    {
+  if (this->BuildNoCMake) {
     // Make the generator available for the Build call below.
-    cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
-                            this->BuildGenerator));
+    cm.SetGlobalGenerator(cm.CreateGlobalGenerator(this->BuildGenerator));
     cm.SetGeneratorPlatform(this->BuildGeneratorPlatform);
     cm.SetGeneratorToolset(this->BuildGeneratorToolset);
 
     // Load the cache to make CMAKE_MAKE_PROGRAM available.
     cm.LoadCache(this->BinaryDir);
-    }
-  else
-    {
+  } else {
     // do the cmake step, no timeout here since it is not a sub process
-    if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm))
-      {
+    if (this->RunCMake(outstring, out, cmakeOutString, cwd, &cm)) {
       return 1;
-      }
     }
+  }
 
   // do the build
   std::vector<std::string>::iterator tarIt;
-  if (this->BuildTargets.empty())
-    {
+  if (this->BuildTargets.empty()) {
     this->BuildTargets.push_back("");
-    }
-  for ( tarIt = this->BuildTargets.begin();
-        tarIt != this->BuildTargets.end(); ++ tarIt )
-    {
+  }
+  for (tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
+       ++tarIt) {
     double remainingTime = 0;
-    if (this->Timeout > 0)
-      {
+    if (this->Timeout > 0) {
       remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
-      if (remainingTime <= 0)
-        {
-        if(outstring)
-          {
+      if (remainingTime <= 0) {
+        if (outstring) {
           *outstring = "--build-and-test timeout exceeded. ";
-          }
-        return 1;
         }
+        return 1;
       }
+    }
     std::string output;
     const char* config = 0;
-    if (!this->CTest->GetConfigType().empty())
-      {
+    if (!this->CTest->GetConfigType().empty()) {
       config = this->CTest->GetConfigType().c_str();
-      }
+    }
 #ifdef CMAKE_INTDIR
-    if(!config)
-      {
+    if (!config) {
       config = CMAKE_INTDIR;
-      }
+    }
 #endif
-    if(!config)
-      {
+    if (!config) {
       config = "Debug";
-      }
+    }
     int retVal = cm.GetGlobalGenerator()->Build(
-      this->SourceDir, this->BinaryDir,
-      this->BuildProject, *tarIt,
-      output, this->BuildMakeProgram,
-      config,
-      !this->BuildNoClean,
-      false, false, remainingTime);
+      this->SourceDir, this->BinaryDir, this->BuildProject, *tarIt, output,
+      this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
+      remainingTime);
     out << output;
     // if the build failed then return
-    if (retVal)
-      {
-      if(outstring)
-        {
-        *outstring =  out.str();
-        }
-      return 1;
+    if (retVal) {
+      if (outstring) {
+        *outstring = out.str();
       }
+      return 1;
     }
-  if(outstring)
-    {
-    *outstring =  out.str();
-    }
+  }
+  if (outstring) {
+    *outstring = out.str();
+  }
 
   // if no test was specified then we are done
-  if (this->TestCommand.empty())
-    {
+  if (this->TestCommand.empty()) {
     return 0;
-    }
+  }
 
   // now run the compiled test if we can find it
   // store the final location in fullPath
@@ -340,216 +287,171 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
   std::string resultingConfig;
   std::vector<std::string> extraPaths;
   // if this->ExecutableDirectory is set try that as well
-  if (!this->ExecutableDirectory.empty())
-    {
+  if (!this->ExecutableDirectory.empty()) {
     std::string tempPath = this->ExecutableDirectory;
     tempPath += "/";
     tempPath += this->TestCommand;
     extraPaths.push_back(tempPath);
-    }
+  }
   std::vector<std::string> failed;
   fullPath =
-    cmCTestTestHandler::FindExecutable(this->CTest,
-                                       this->TestCommand.c_str(),
-                                       resultingConfig,
-                                       extraPaths,
-                                       failed);
-
-  if(!cmSystemTools::FileExists(fullPath.c_str()))
-    {
+    cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(),
+                                       resultingConfig, extraPaths, failed);
+
+  if (!cmSystemTools::FileExists(fullPath.c_str())) {
     out << "Could not find path to executable, perhaps it was not built: "
-      << this->TestCommand << "\n";
+        << this->TestCommand << "\n";
     out << "tried to find it in these places:\n";
     out << fullPath.c_str() << "\n";
-    for(unsigned int i=0; i < failed.size(); ++i)
-      {
+    for (unsigned int i = 0; i < failed.size(); ++i) {
       out << failed[i] << "\n";
-      }
-    if(outstring)
-      {
-      *outstring =  out.str();
-      }
-    else
-      {
+    }
+    if (outstring) {
+      *outstring = out.str();
+    } else {
       cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
-      }
+    }
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd);
     return 1;
-    }
+  }
 
   std::vector<const char*> testCommand;
   testCommand.push_back(fullPath.c_str());
-  for(size_t 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());
-    }
+  }
   testCommand.push_back(0);
   std::string outs;
   int retval = 0;
   // run the test from the this->BuildRunDir if set
-  if(!this->BuildRunDir.empty())
-    {
+  if (!this->BuildRunDir.empty()) {
     out << "Run test in directory: " << this->BuildRunDir << "\n";
     cmSystemTools::ChangeDirectory(this->BuildRunDir);
-    }
+  }
   out << "Running test command: \"" << fullPath << "\"";
-  for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
-    {
+  for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
     out << " \"" << this->TestCommandArgs[k] << "\"";
-    }
+  }
   out << "\n";
 
   // how much time is remaining
   double remainingTime = 0;
-  if (this->Timeout > 0)
-    {
+  if (this->Timeout > 0) {
     remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
-    if (remainingTime <= 0)
-      {
-      if(outstring)
-        {
+    if (remainingTime <= 0) {
+      if (outstring) {
         *outstring = "--build-and-test timeout exceeded. ";
-        }
-      return 1;
       }
+      return 1;
     }
+  }
 
-  int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0,
-                                        remainingTime, 0);
+  int runTestRes =
+    this->CTest->RunTest(testCommand, &outs, &retval, 0, remainingTime, 0);
 
-  if(runTestRes != cmsysProcess_State_Exited || retval != 0)
-    {
+  if (runTestRes != cmsysProcess_State_Exited || retval != 0) {
     out << "Test command failed: " << testCommand[0] << "\n";
     retval = 1;
-    }
+  }
 
   out << outs << "\n";
-  if(outstring)
-    {
+  if (outstring) {
     *outstring = out.str();
-    }
-  else
-    {
+  } else {
     cmCTestLog(this->CTest, OUTPUT, out.str() << std::endl);
-    }
+  }
   return retval;
 }
 
-//----------------------------------------------------------------------
 int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
   const std::string& currentArg, size_t& idx,
   const std::vector<std::string>& allArgs)
 {
   // --build-and-test options
-  if(currentArg.find("--build-and-test",0) == 0 && idx < allArgs.size() - 1)
-    {
-    if(idx+2 < allArgs.size())
-      {
+  if (currentArg.find("--build-and-test", 0) == 0 &&
+      idx < allArgs.size() - 1) {
+    if (idx + 2 < allArgs.size()) {
       idx++;
       this->SourceDir = allArgs[idx];
       idx++;
       this->BinaryDir = allArgs[idx];
       // dir must exist before CollapseFullPath is called
       cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
-      this->BinaryDir
-        = cmSystemTools::CollapseFullPath(this->BinaryDir);
-      this->SourceDir
-        = cmSystemTools::CollapseFullPath(this->SourceDir);
-      }
-    else
-      {
+      this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir);
+      this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir);
+    } else {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "--build-and-test must have source and binary dir" << std::endl);
+                 "--build-and-test must have source and binary dir"
+                   << std::endl);
       return 0;
-      }
     }
-  if(currentArg.find("--build-target",0) == 0 && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--build-target", 0) == 0 && idx < allArgs.size() - 1) {
     idx++;
     this->BuildTargets.push_back(allArgs[idx]);
-    }
-  if(currentArg.find("--build-nocmake",0) == 0)
-    {
+  }
+  if (currentArg.find("--build-nocmake", 0) == 0) {
     this->BuildNoCMake = true;
-    }
-  if(currentArg.find("--build-run-dir",0) == 0 && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--build-run-dir", 0) == 0 && idx < allArgs.size() - 1) {
     idx++;
     this->BuildRunDir = allArgs[idx];
-    }
-  if(currentArg.find("--build-two-config",0) == 0)
-    {
+  }
+  if (currentArg.find("--build-two-config", 0) == 0) {
     this->BuildTwoConfig = true;
-    }
-  if(currentArg.find("--build-exe-dir",0) == 0 && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--build-exe-dir", 0) == 0 && idx < allArgs.size() - 1) {
     idx++;
     this->ExecutableDirectory = allArgs[idx];
-    }
-  if(currentArg.find("--test-timeout",0) == 0 && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--test-timeout", 0) == 0 && idx < allArgs.size() - 1) {
     idx++;
     this->Timeout = atof(allArgs[idx].c_str());
-    }
-  if(currentArg == "--build-generator" && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg == "--build-generator" && idx < allArgs.size() - 1) {
     idx++;
     this->BuildGenerator = allArgs[idx];
-    }
-  if(currentArg == "--build-generator-platform" &&
-     idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg == "--build-generator-platform" && idx < allArgs.size() - 1) {
     idx++;
     this->BuildGeneratorPlatform = allArgs[idx];
-    }
-  if(currentArg == "--build-generator-toolset" &&
-     idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg == "--build-generator-toolset" && idx < allArgs.size() - 1) {
     idx++;
     this->BuildGeneratorToolset = allArgs[idx];
-    }
-  if(currentArg.find("--build-project",0) == 0 && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--build-project", 0) == 0 && idx < allArgs.size() - 1) {
     idx++;
     this->BuildProject = allArgs[idx];
-    }
-  if(currentArg.find("--build-makeprogram",0) == 0 &&
-    idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--build-makeprogram", 0) == 0 &&
+      idx < allArgs.size() - 1) {
     idx++;
     this->BuildMakeProgram = allArgs[idx];
-    }
-  if(currentArg.find("--build-config-sample",0) == 0 &&
-    idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--build-config-sample", 0) == 0 &&
+      idx < allArgs.size() - 1) {
     idx++;
     this->ConfigSample = allArgs[idx];
-    }
-  if(currentArg.find("--build-noclean",0) == 0)
-    {
+  }
+  if (currentArg.find("--build-noclean", 0) == 0) {
     this->BuildNoClean = true;
-    }
-  if(currentArg.find("--build-options",0) == 0)
-    {
-    while(idx+1 < allArgs.size() &&
-          allArgs[idx+1] != "--build-target" &&
-          allArgs[idx+1] != "--test-command")
-      {
+  }
+  if (currentArg.find("--build-options", 0) == 0) {
+    while (idx + 1 < allArgs.size() && allArgs[idx + 1] != "--build-target" &&
+           allArgs[idx + 1] != "--test-command") {
       ++idx;
       this->BuildOptions.push_back(allArgs[idx]);
-      }
     }
-  if(currentArg.find("--test-command",0) == 0 && idx < allArgs.size() - 1)
-    {
+  }
+  if (currentArg.find("--test-command", 0) == 0 && idx < allArgs.size() - 1) {
     ++idx;
     this->TestCommand = allArgs[idx];
-    while(idx+1 < allArgs.size())
-      {
+    while (idx + 1 < allArgs.size()) {
       ++idx;
       this->TestCommandArgs.push_back(allArgs[idx]);
-      }
     }
+  }
   return 1;
 }
-
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index a75c631..d0443ae 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -13,7 +13,6 @@
 #ifndef cmCTestBuildAndTestHandler_h
 #define cmCTestBuildAndTestHandler_h
 
-
 #include "cmCTestGenericHandler.h"
 #include "cmListFileCache.h"
 
@@ -50,31 +49,29 @@ public:
 protected:
   ///! Run CMake and build a test and then run it as a single test.
   int RunCMakeAndTest(std::string* output);
-  int RunCMake(std::string* outstring, std::ostringstream &out,
-               std::string &cmakeOutString,
-               std::string &cwd, cmake *cm);
+  int RunCMake(std::string* outstring, std::ostringstream& out,
+               std::string& cmakeOutString, std::string& cwd, cmake* cm);
 
-  std::string  Output;
+  std::string Output;
 
-  std::string              BuildGenerator;
-  std::string              BuildGeneratorPlatform;
-  std::string              BuildGeneratorToolset;
+  std::string BuildGenerator;
+  std::string BuildGeneratorPlatform;
+  std::string BuildGeneratorToolset;
   std::vector<std::string> BuildOptions;
-  bool                     BuildTwoConfig;
-  std::string              BuildMakeProgram;
-  std::string              ConfigSample;
-  std::string              SourceDir;
-  std::string              BinaryDir;
-  std::string              BuildProject;
-  std::string              TestCommand;
-  bool                     BuildNoClean;
-  std::string              BuildRunDir;
-  std::string              ExecutableDirectory;
+  bool BuildTwoConfig;
+  std::string BuildMakeProgram;
+  std::string ConfigSample;
+  std::string SourceDir;
+  std::string BinaryDir;
+  std::string BuildProject;
+  std::string TestCommand;
+  bool BuildNoClean;
+  std::string BuildRunDir;
+  std::string ExecutableDirectory;
   std::vector<std::string> TestCommandArgs;
   std::vector<std::string> BuildTargets;
-  bool                     BuildNoCMake;
-  double                   Timeout;
+  bool BuildNoCMake;
+  double Timeout;
 };
 
 #endif
-
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index 27e22c4..05cccbf 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -12,13 +12,11 @@
 #include "cmCTestBuildCommand.h"
 
 #include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
 #include "cmCTestBuildHandler.h"
-#include "cmake.h"
+#include "cmCTestGenericHandler.h"
 #include "cmGlobalGenerator.h"
+#include "cmake.h"
 
-
-//----------------------------------------------------------------------------
 cmCTestBuildCommand::cmCTestBuildCommand()
 {
   this->GlobalGenerator = 0;
@@ -32,41 +30,33 @@ cmCTestBuildCommand::cmCTestBuildCommand()
   this->Last = ctb_LAST;
 }
 
-//----------------------------------------------------------------------------
 cmCTestBuildCommand::~cmCTestBuildCommand()
 {
-  if ( this->GlobalGenerator )
-    {
+  if (this->GlobalGenerator) {
     delete this->GlobalGenerator;
     this->GlobalGenerator = 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
 {
-  cmCTestGenericHandler* handler
-    = this->CTest->GetInitializedHandler("build");
-  if ( !handler )
-    {
+  cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build");
+  if (!handler) {
     this->SetError("internal CTest error. Cannot instantiate build handler");
     return 0;
-    }
-  this->Handler =  (cmCTestBuildHandler*)handler;
+  }
+  this->Handler = (cmCTestBuildHandler*)handler;
 
-  const char* ctestBuildCommand
-    = this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
-  if ( ctestBuildCommand && *ctestBuildCommand )
-    {
+  const char* ctestBuildCommand =
+    this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
+  if (ctestBuildCommand && *ctestBuildCommand) {
     this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand,
-      this->Quiet);
-    }
-  else
-    {
-    const char* cmakeGeneratorName
-      = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
-    const char* cmakeProjectName
-      = (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
+                                       this->Quiet);
+  } else {
+    const char* cmakeGeneratorName =
+      this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
+    const char* cmakeProjectName =
+      (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
       ? this->Values[ctb_PROJECT_NAME]
       : this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
 
@@ -75,82 +65,73 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
     // CTEST_CONFIGURATION_TYPE script variable, or ctest -C command
     // line argument... in that order.
     //
-    const char* ctestBuildConfiguration
-      = this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
-    const char* cmakeBuildConfiguration
-      = (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION])
+    const char* ctestBuildConfiguration =
+      this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
+    const char* cmakeBuildConfiguration =
+      (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION])
       ? this->Values[ctb_CONFIGURATION]
       : ((ctestBuildConfiguration && *ctestBuildConfiguration)
-        ? ctestBuildConfiguration
-        : this->CTest->GetConfigType().c_str());
+           ? ctestBuildConfiguration
+           : this->CTest->GetConfigType().c_str());
 
-    const char* cmakeBuildAdditionalFlags
-      = (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS])
+    const char* cmakeBuildAdditionalFlags =
+      (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS])
       ? this->Values[ctb_FLAGS]
       : this->Makefile->GetDefinition("CTEST_BUILD_FLAGS");
-    const char* cmakeBuildTarget
-      = (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET])
+    const char* cmakeBuildTarget =
+      (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET])
       ? this->Values[ctb_TARGET]
       : this->Makefile->GetDefinition("CTEST_BUILD_TARGET");
 
-    if ( cmakeGeneratorName && *cmakeGeneratorName &&
-      cmakeProjectName && *cmakeProjectName )
-      {
-      if ( !cmakeBuildConfiguration )
-        {
+    if (cmakeGeneratorName && *cmakeGeneratorName && cmakeProjectName &&
+        *cmakeProjectName) {
+      if (!cmakeBuildConfiguration) {
         cmakeBuildConfiguration = "Release";
-        }
-      if ( this->GlobalGenerator )
-        {
-        if ( this->GlobalGenerator->GetName() != cmakeGeneratorName )
-          {
+      }
+      if (this->GlobalGenerator) {
+        if (this->GlobalGenerator->GetName() != cmakeGeneratorName) {
           delete this->GlobalGenerator;
           this->GlobalGenerator = 0;
-          }
         }
-      if ( !this->GlobalGenerator )
-        {
+      }
+      if (!this->GlobalGenerator) {
         this->GlobalGenerator =
           this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
             cmakeGeneratorName);
-        if(!this->GlobalGenerator)
-          {
+        if (!this->GlobalGenerator) {
           std::string e = "could not create generator named \"";
           e += cmakeGeneratorName;
           e += "\"";
           this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
           cmSystemTools::SetFatalErrorOccured();
           return 0;
-          }
         }
-      if(strlen(cmakeBuildConfiguration) == 0)
-        {
+      }
+      if (strlen(cmakeBuildConfiguration) == 0) {
         const char* config = 0;
 #ifdef CMAKE_INTDIR
         config = CMAKE_INTDIR;
 #endif
-        if(!config)
-          {
+        if (!config) {
           config = "Debug";
-          }
-        cmakeBuildConfiguration = config;
         }
+        cmakeBuildConfiguration = config;
+      }
 
       std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
-      std::string buildCommand
-        = this->GlobalGenerator->
-        GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
-          cmakeBuildConfiguration,
+      std::string buildCommand =
+        this->GlobalGenerator->GenerateCMakeBuildCommand(
+          cmakeBuildTarget ? cmakeBuildTarget : "", cmakeBuildConfiguration,
           cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "",
           this->Makefile->IgnoreErrorsCMP0061());
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "SetMakeCommand:" << buildCommand << "\n", this->Quiet);
+                         "SetMakeCommand:" << buildCommand << "\n",
+                         this->Quiet);
       this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(),
-        this->Quiet);
-      }
-    else
-      {
+                                         this->Quiet);
+    } else {
       std::ostringstream ostr;
+      /* clang-format off */
       ostr << "has no project to build. If this is a "
         "\"built with CMake\" project, verify that CTEST_CMAKE_GENERATOR "
         "and CTEST_PROJECT_NAME are set."
@@ -162,41 +143,38 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
         "\n"
         "Alternatively, set CTEST_BUILD_COMMAND to build the project "
         "with a custom command line.";
+      /* clang-format on */
       this->SetError(ostr.str());
       return 0;
-      }
     }
+  }
 
-  if(const char* useLaunchers =
-     this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS"))
-    {
+  if (const char* useLaunchers =
+        this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) {
     this->CTest->SetCTestConfiguration("UseLaunchers", useLaunchers,
-      this->Quiet);
-    }
+                                       this->Quiet);
+  }
 
   handler->SetQuiet(this->Quiet);
   return handler;
 }
 
-
 bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
-                                      cmExecutionStatus &status)
+                                      cmExecutionStatus& status)
 {
-  bool ret =  cmCTestHandlerCommand::InitialPass(args, status);
-  if ( this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS])
-    {
+  bool ret = cmCTestHandlerCommand::InitialPass(args, status);
+  if (this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS]) {
     std::ostringstream str;
     str << this->Handler->GetTotalErrors();
-    this->Makefile->AddDefinition(
-      this->Values[ctb_NUMBER_ERRORS], str.str().c_str());
-    }
-  if ( this->Values[ctb_NUMBER_WARNINGS]
-       && *this->Values[ctb_NUMBER_WARNINGS])
-    {
+    this->Makefile->AddDefinition(this->Values[ctb_NUMBER_ERRORS],
+                                  str.str().c_str());
+  }
+  if (this->Values[ctb_NUMBER_WARNINGS] &&
+      *this->Values[ctb_NUMBER_WARNINGS]) {
     std::ostringstream str;
     str << this->Handler->GetTotalWarnings();
-    this->Makefile->AddDefinition(
-      this->Values[ctb_NUMBER_WARNINGS], str.str().c_str());
-    }
+    this->Makefile->AddDefinition(this->Values[ctb_NUMBER_WARNINGS],
+                                  str.str().c_str());
+  }
   return ret;
 }
diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h
index 2632ebc..f420c2f 100644
--- a/Source/CTest/cmCTestBuildCommand.h
+++ b/Source/CTest/cmCTestBuildCommand.h
@@ -25,7 +25,6 @@ class cmCTestBuildHandler;
 class cmCTestBuildCommand : public cmCTestHandlerCommand
 {
 public:
-
   cmCTestBuildCommand();
   ~cmCTestBuildCommand();
 
@@ -33,20 +32,20 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestBuildCommand* ni = new cmCTestBuildCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_build";}
+  virtual std::string GetName() const { return "ctest_build"; }
 
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   cmTypeMacro(cmCTestBuildCommand, cmCTestHandlerCommand);
 
@@ -54,7 +53,8 @@ public:
 
 protected:
   cmCTestBuildHandler* Handler;
-  enum {
+  enum
+  {
     ctb_BUILD = ct_LAST,
     ctb_NUMBER_ERRORS,
     ctb_NUMBER_WARNINGS,
@@ -68,5 +68,4 @@ protected:
   cmCTestGenericHandler* InitializeHandler();
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 0d74f48..7141daf 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -12,30 +12,29 @@
 
 #include "cmCTestBuildHandler.h"
 
+#include "cmAlgorithms.h"
 #include "cmCTest.h"
-#include "cmake.h"
-#include "cmMakefile.h"
-#include "cmGlobalGenerator.h"
+#include "cmFileTimeComparison.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
 #include "cmXMLWriter.h"
-#include "cmFileTimeComparison.h"
-#include "cmAlgorithms.h"
+#include "cmake.h"
 
 //#include <cmsys/RegularExpression.hxx>
-#include <cmsys/Process.h>
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Process.h>
 
 // used for sleep
 #ifdef _WIN32
 #include "windows.h"
 #endif
 
+#include <float.h>
+#include <math.h>
 #include <stdlib.h>
 #include <time.h>
-#include <math.h>
-#include <float.h>
-
 
 static const char* cmCTestErrorMatches[] = {
   "^[Bb]us [Ee]rror",
@@ -102,6 +101,7 @@ static const char* cmCTestErrorExceptions[] = {
   ": warning",
   ": \\(Warning\\)",
   ": note",
+  "Note:",
   "makefile:",
   "Makefile:",
   ":[ \\t]+Where:",
@@ -162,19 +162,17 @@ struct cmCTestBuildCompileErrorWarningRex
   int LineIndex;
 };
 
-static cmCTestBuildCompileErrorWarningRex
-cmCTestWarningErrorFileLine[] = {
-    { "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
-    { "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
-    { "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
-    { "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
-    { "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
-    { "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
-    { "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
-    { 0, 0, 0 }
+static cmCTestBuildCompileErrorWarningRex cmCTestWarningErrorFileLine[] = {
+  { "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
+  { "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
+  { "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+  { "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+  { "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+  { "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
+  { "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
+  { 0, 0, 0 }
 };
 
-//----------------------------------------------------------------------
 cmCTestBuildHandler::cmCTestBuildHandler()
 {
   this->MaxPreContext = 10;
@@ -188,7 +186,6 @@ cmCTestBuildHandler::cmCTestBuildHandler()
   this->UseCTestLaunch = false;
 }
 
-//----------------------------------------------------------------------
 void cmCTestBuildHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -234,134 +231,113 @@ void cmCTestBuildHandler::Initialize()
   this->UseCTestLaunch = false;
 }
 
-//----------------------------------------------------------------------
-void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf)
 {
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_MATCH",
-                             this->CustomErrorMatches);
+                                    this->CustomErrorMatches);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_ERROR_EXCEPTION",
-                             this->CustomErrorExceptions);
+                                    this->CustomErrorExceptions);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_MATCH",
-                             this->CustomWarningMatches);
+                                    this->CustomWarningMatches);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_WARNING_EXCEPTION",
-                             this->CustomWarningExceptions);
-  this->CTest->PopulateCustomInteger(mf,
-                          "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS",
-                          this->MaxErrors);
-  this->CTest->PopulateCustomInteger(mf,
-                             "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS",
-                             this->MaxWarnings);
+                                    this->CustomWarningExceptions);
+  this->CTest->PopulateCustomInteger(
+    mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS", this->MaxErrors);
+  this->CTest->PopulateCustomInteger(
+    mf, "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings);
 
   int n = -1;
   this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_PRE_CONTEXT", n);
-  if (n != -1)
-    {
+  if (n != -1) {
     this->MaxPreContext = static_cast<size_t>(n);
-    }
+  }
 
   n = -1;
   this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_POST_CONTEXT", n);
-  if (n != -1)
-    {
+  if (n != -1) {
     this->MaxPostContext = static_cast<size_t>(n);
-    }
+  }
 
   // Record the user-specified custom warning rules.
-  if(const char* customWarningMatchers =
-     mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH"))
-    {
+  if (const char* customWarningMatchers =
+        mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) {
     cmSystemTools::ExpandListArgument(customWarningMatchers,
                                       this->ReallyCustomWarningMatches);
-    }
-  if(const char* customWarningExceptions =
-     mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION"))
-    {
+  }
+  if (const char* customWarningExceptions =
+        mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) {
     cmSystemTools::ExpandListArgument(customWarningExceptions,
                                       this->ReallyCustomWarningExceptions);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 std::string cmCTestBuildHandler::GetMakeCommand()
 {
-  std::string makeCommand
-    = this->CTest->GetCTestConfiguration("MakeCommand");
-  cmCTestOptionalLog(this->CTest,
-    HANDLER_VERBOSE_OUTPUT, "MakeCommand:" << makeCommand << "\n",
-    this->Quiet);
+  std::string makeCommand = this->CTest->GetCTestConfiguration("MakeCommand");
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "MakeCommand:" << makeCommand << "\n", this->Quiet);
 
   std::string configType = this->CTest->GetConfigType();
-  if (configType == "")
-    {
-    configType
-      = this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
-    }
-  if (configType == "")
-    {
+  if (configType == "") {
+    configType =
+      this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
+  }
+  if (configType == "") {
     configType = "Release";
-    }
+  }
 
-  cmSystemTools::ReplaceString(makeCommand,
-    "${CTEST_CONFIGURATION_TYPE}", configType.c_str());
+  cmSystemTools::ReplaceString(makeCommand, "${CTEST_CONFIGURATION_TYPE}",
+                               configType.c_str());
 
   return makeCommand;
 }
 
-//----------------------------------------------------------------------
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
 int cmCTestBuildHandler::ProcessHandler()
 {
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Build project" << std::endl,
-    this->Quiet);
+                     this->Quiet);
 
   // do we have time for this
-  if (this->CTest->GetRemainingTimeAllowed() < 120)
-    {
+  if (this->CTest->GetRemainingTimeAllowed() < 120) {
     return 0;
-    }
+  }
 
   int entry;
-  for ( entry = 0;
-    cmCTestWarningErrorFileLine[entry].RegularExpressionString;
-    ++ entry )
-    {
+  for (entry = 0; cmCTestWarningErrorFileLine[entry].RegularExpressionString;
+       ++entry) {
     cmCTestBuildHandler::cmCTestCompileErrorWarningRex r;
-    if ( r.RegularExpression.compile(
-        cmCTestWarningErrorFileLine[entry].RegularExpressionString) )
-      {
+    if (r.RegularExpression.compile(
+          cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
       r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
       r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
       this->ErrorWarningFileLineRegex.push_back(r);
-      }
-    else
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Problem Compiling regular expression: "
-       << cmCTestWarningErrorFileLine[entry].RegularExpressionString
-       << std::endl);
-      }
+    } else {
+      cmCTestLog(
+        this->CTest, ERROR_MESSAGE, "Problem Compiling regular expression: "
+          << cmCTestWarningErrorFileLine[entry].RegularExpressionString
+          << std::endl);
     }
+  }
 
   // Determine build command and build directory
   std::string makeCommand = this->GetMakeCommand();
-  if (makeCommand.empty())
-    {
+  if (makeCommand.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot find MakeCommand key in the DartConfiguration.tcl"
-      << std::endl);
+               "Cannot find MakeCommand key in the DartConfiguration.tcl"
+                 << std::endl);
     return -1;
-    }
+  }
 
-  const std::string &buildDirectory
-    = this->CTest->GetCTestConfiguration("BuildDirectory");
-  if (buildDirectory.empty())
-    {
+  const std::string& buildDirectory =
+    this->CTest->GetCTestConfiguration("BuildDirectory");
+  if (buildDirectory.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot find BuildDirectory  key in the DartConfiguration.tcl"
-      << std::endl);
+               "Cannot find BuildDirectory  key in the DartConfiguration.tcl"
+                 << std::endl);
     return -1;
-    }
+  }
 
   std::string const& useLaunchers =
     this->CTest->GetCTestConfiguration("UseLaunchers");
@@ -370,94 +346,81 @@ int cmCTestBuildHandler::ProcessHandler()
   // Create a last build log
   cmGeneratedFileStream ofs;
   double elapsed_time_start = cmSystemTools::GetTime();
-  if ( !this->StartLogFile("Build", ofs) )
-    {
+  if (!this->StartLogFile("Build", ofs)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
-      << std::endl);
-    }
+                 << std::endl);
+  }
 
   // Create lists of regular expression strings for errors, error exceptions,
   // warnings and warning exceptions.
   std::vector<std::string>::size_type cc;
-  for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
-    {
+  for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
     this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
-    }
-  for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ )
-    {
+  }
+  for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
     this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
-    }
-  for ( cc = 0; cmCTestWarningMatches[cc]; cc ++ )
-    {
+  }
+  for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
     this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
-    }
+  }
 
-  for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ )
-    {
+  for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
     this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
-    }
+  }
 
   // Pre-compile regular expressions objects for all regular expressions
   std::vector<std::string>::iterator it;
 
-#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
-  regexes.clear(); \
-    cmCTestOptionalLog(this->CTest, DEBUG, this << "Add " #regexes \
-    << std::endl, this->Quiet); \
-  for ( it = strings.begin(); it != strings.end(); ++it ) \
-    { \
-    cmCTestOptionalLog(this->CTest, DEBUG, "Add " #strings ": " \
-    << *it << std::endl, this->Quiet); \
-    regexes.push_back(it->c_str()); \
-    }
-  cmCTestBuildHandlerPopulateRegexVector(
-    this->CustomErrorMatches, this->ErrorMatchRegex);
-  cmCTestBuildHandlerPopulateRegexVector(
-    this->CustomErrorExceptions, this->ErrorExceptionRegex);
-  cmCTestBuildHandlerPopulateRegexVector(
-    this->CustomWarningMatches, this->WarningMatchRegex);
-  cmCTestBuildHandlerPopulateRegexVector(
-    this->CustomWarningExceptions, this->WarningExceptionRegex);
-
+#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes)              \
+  regexes.clear();                                                            \
+  cmCTestOptionalLog(this->CTest, DEBUG,                                      \
+                     this << "Add " #regexes << std::endl, this->Quiet);      \
+  for (it = strings.begin(); it != strings.end(); ++it) {                     \
+    cmCTestOptionalLog(this->CTest, DEBUG,                                    \
+                       "Add " #strings ": " << *it << std::endl,              \
+                       this->Quiet);                                          \
+    regexes.push_back(it->c_str());                                           \
+  }
+  cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
+                                         this->ErrorMatchRegex);
+  cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
+                                         this->ErrorExceptionRegex);
+  cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningMatches,
+                                         this->WarningMatchRegex);
+  cmCTestBuildHandlerPopulateRegexVector(this->CustomWarningExceptions,
+                                         this->WarningExceptionRegex);
 
   // Determine source and binary tree substitutions to simplify the output.
   this->SimplifySourceDir = "";
   this->SimplifyBuildDir = "";
-  if ( this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20 )
-    {
-    std::string srcdir
-      = this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
+  if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
+    std::string srcdir =
+      this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
     std::string srcdirrep;
-    for ( cc = srcdir.size()-2; cc > 0; cc -- )
-      {
-      if ( srcdir[cc] == '/' )
-        {
+    for (cc = srcdir.size() - 2; cc > 0; cc--) {
+      if (srcdir[cc] == '/') {
         srcdirrep = srcdir.c_str() + cc;
         srcdirrep = "/..." + srcdirrep;
-        srcdir = srcdir.substr(0, cc+1);
+        srcdir = srcdir.substr(0, cc + 1);
         break;
-        }
       }
-    this->SimplifySourceDir = srcdir;
     }
-  if ( this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20 )
-    {
-    std::string bindir
-      = this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
+    this->SimplifySourceDir = srcdir;
+  }
+  if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
+    std::string bindir =
+      this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
     std::string bindirrep;
-    for ( cc = bindir.size()-2; cc > 0; cc -- )
-      {
-      if ( bindir[cc] == '/' )
-        {
+    for (cc = bindir.size() - 2; cc > 0; cc--) {
+      if (bindir[cc] == '/') {
         bindirrep = bindir.c_str() + cc;
         bindirrep = "/..." + bindirrep;
-        bindir = bindir.substr(0, cc+1);
+        bindir = bindir.substr(0, cc + 1);
         break;
-        }
       }
-    this->SimplifyBuildDir = bindir;
     }
-
+    this->SimplifyBuildDir = bindir;
+  }
 
   // Ok, let's do the build
 
@@ -466,16 +429,14 @@ int cmCTestBuildHandler::ProcessHandler()
   this->StartBuildTime = cmSystemTools::GetTime();
   int retVal = 0;
   int res = cmsysProcess_State_Exited;
-  if ( !this->CTest->GetShowOnly() )
-    {
+  if (!this->CTest->GetShowOnly()) {
     res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
-      buildDirectory.c_str(), 0, ofs);
-    }
-  else
-    {
-    cmCTestOptionalLog(this->CTest, DEBUG, "Build with command: " <<
-      makeCommand << std::endl, this->Quiet);
-    }
+                               buildDirectory.c_str(), 0, ofs);
+  } else {
+    cmCTestOptionalLog(this->CTest, DEBUG,
+                       "Build with command: " << makeCommand << std::endl,
+                       this->Quiet);
+  }
 
   // Remember end build time and calculate elapsed time
   this->EndBuild = this->CTest->CurrentTime();
@@ -484,116 +445,107 @@ int cmCTestBuildHandler::ProcessHandler()
 
   // Cleanups strings in the errors and warnings list.
   t_ErrorsAndWarningsVector::iterator evit;
-  if ( !this->SimplifySourceDir.empty() )
-    {
-    for ( evit = this->ErrorsAndWarnings.begin();
-      evit != this->ErrorsAndWarnings.end();
-      ++ evit )
-      {
-      cmSystemTools::ReplaceString(
-        evit->Text, this->SimplifySourceDir.c_str(), "/.../");
-      cmSystemTools::ReplaceString(
-        evit->PreContext, this->SimplifySourceDir.c_str(), "/.../");
-      cmSystemTools::ReplaceString(
-        evit->PostContext, this->SimplifySourceDir.c_str(), "/.../");
-      }
+  if (!this->SimplifySourceDir.empty()) {
+    for (evit = this->ErrorsAndWarnings.begin();
+         evit != this->ErrorsAndWarnings.end(); ++evit) {
+      cmSystemTools::ReplaceString(evit->Text, this->SimplifySourceDir.c_str(),
+                                   "/.../");
+      cmSystemTools::ReplaceString(evit->PreContext,
+                                   this->SimplifySourceDir.c_str(), "/.../");
+      cmSystemTools::ReplaceString(evit->PostContext,
+                                   this->SimplifySourceDir.c_str(), "/.../");
     }
-
-  if ( !this->SimplifyBuildDir.empty() )
-    {
-    for ( evit = this->ErrorsAndWarnings.begin();
-      evit != this->ErrorsAndWarnings.end();
-      ++ evit )
-      {
-      cmSystemTools::ReplaceString(
-        evit->Text, this->SimplifyBuildDir.c_str(), "/.../");
-      cmSystemTools::ReplaceString(
-        evit->PreContext, this->SimplifyBuildDir.c_str(), "/.../");
-      cmSystemTools::ReplaceString(
-        evit->PostContext, this->SimplifyBuildDir.c_str(), "/.../");
-      }
+  }
+
+  if (!this->SimplifyBuildDir.empty()) {
+    for (evit = this->ErrorsAndWarnings.begin();
+         evit != this->ErrorsAndWarnings.end(); ++evit) {
+      cmSystemTools::ReplaceString(evit->Text, this->SimplifyBuildDir.c_str(),
+                                   "/.../");
+      cmSystemTools::ReplaceString(evit->PreContext,
+                                   this->SimplifyBuildDir.c_str(), "/.../");
+      cmSystemTools::ReplaceString(evit->PostContext,
+                                   this->SimplifyBuildDir.c_str(), "/.../");
     }
+  }
 
   // Generate XML output
   cmGeneratedFileStream xofs;
-  if(!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs))
-    {
+  if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build XML file"
-      << std::endl);
+                 << std::endl);
     return -1;
-    }
+  }
   cmXMLWriter xml(xofs);
   this->GenerateXMLHeader(xml);
-  if(this->UseCTestLaunch)
-    {
+  if (this->UseCTestLaunch) {
     this->GenerateXMLLaunched(xml);
-    }
-  else
-    {
+  } else {
     this->GenerateXMLLogScraped(xml);
-    }
+  }
   this->GenerateXMLFooter(xml, elapsed_build_time);
 
-  if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0)
-    {
+  if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Error(s) when building project"
-      << std::endl);
-    }
+                 << std::endl);
+  }
 
   // Display message about number of errors and warnings
-  cmCTestLog(this->CTest, HANDLER_OUTPUT, "   " << this->TotalErrors
-    << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
-    << " Compiler errors" << std::endl);
-  cmCTestLog(this->CTest, HANDLER_OUTPUT, "   " << this->TotalWarnings
-    << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
-    << " Compiler warnings" << std::endl);
+  cmCTestLog(this->CTest, HANDLER_OUTPUT, "   "
+               << this->TotalErrors
+               << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
+               << " Compiler errors" << std::endl);
+  cmCTestLog(this->CTest, HANDLER_OUTPUT, "   "
+               << this->TotalWarnings
+               << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
+               << " Compiler warnings" << std::endl);
 
   return retVal;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
 {
   this->CTest->StartXML(xml, this->AppendXML);
   xml.StartElement("Build");
   xml.Element("StartDateTime", this->StartBuild);
   xml.Element("StartBuildTime",
-    static_cast<unsigned int>(this->StartBuildTime));
+              static_cast<unsigned int>(this->StartBuildTime));
   xml.Element("BuildCommand", this->GetMakeCommand());
 }
 
-//----------------------------------------------------------------------------
 class cmCTestBuildHandler::FragmentCompare
 {
 public:
-  FragmentCompare(cmFileTimeComparison* ftc): FTC(ftc) {}
-  FragmentCompare(): FTC(0) {}
+  FragmentCompare(cmFileTimeComparison* ftc)
+    : FTC(ftc)
+  {
+  }
+  FragmentCompare()
+    : FTC(0)
+  {
+  }
   bool operator()(std::string const& l, std::string const& r)
-    {
+  {
     // Order files by modification time.  Use lexicographic order
     // among files with the same time.
     int result;
-    if(this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
-       result != 0)
-      {
+    if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
+        result != 0) {
       return result < 0;
-      }
-    else
-      {
+    } else {
       return l < r;
-      }
     }
+  }
+
 private:
   cmFileTimeComparison* FTC;
 };
 
-//----------------------------------------------------------------------------
 void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
 {
-  if(this->CTestLaunchDir.empty())
-    {
+  if (this->CTestLaunchDir.empty()) {
     return;
-    }
+  }
 
   // Sort XML fragments in chronological order.
   cmFileTimeComparison ftc;
@@ -608,32 +560,26 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
   cmsys::Directory launchDir;
   launchDir.Load(this->CTestLaunchDir);
   unsigned long n = launchDir.GetNumberOfFiles();
-  for(unsigned long i=0; i < n; ++i)
-    {
+  for (unsigned long i = 0; i < n; ++i) {
     const char* fname = launchDir.GetFile(i);
-    if(this->IsLaunchedErrorFile(fname) && numErrorsAllowed)
-      {
+    if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
       numErrorsAllowed--;
       fragments.insert(this->CTestLaunchDir + "/" + fname);
       ++this->TotalErrors;
-      }
-    else if(this->IsLaunchedWarningFile(fname) && numWarningsAllowed)
-      {
+    } else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
       numWarningsAllowed--;
       fragments.insert(this->CTestLaunchDir + "/" + fname);
       ++this->TotalWarnings;
-      }
     }
+  }
 
   // Copy the fragments into the final XML file.
-  for(Fragments::const_iterator fi = fragments.begin();
-      fi != fragments.end(); ++fi)
-    {
+  for (Fragments::const_iterator fi = fragments.begin(); fi != fragments.end();
+       ++fi) {
     xml.FragmentFile(fi->c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
 {
   std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
@@ -647,90 +593,71 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
   // via a call to collapse full path.
   srcdir = cmSystemTools::CollapseFullPath(srcdir);
   srcdir += "/";
-  for ( it = ew.begin();
-        it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ )
-    {
-    cmCTestBuildErrorWarning *cm = &(*it);
+  for (it = ew.begin();
+       it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
+    cmCTestBuildErrorWarning* cm = &(*it);
     if ((cm->Error && numErrorsAllowed) ||
-        (!cm->Error && numWarningsAllowed))
-      {
-      if (cm->Error)
-        {
+        (!cm->Error && numWarningsAllowed)) {
+      if (cm->Error) {
         numErrorsAllowed--;
-        }
-      else
-        {
+      } else {
         numWarningsAllowed--;
-        }
+      }
       xml.StartElement(cm->Error ? "Error" : "Warning");
       xml.Element("BuildLogLine", cm->LogLine);
       xml.Element("Text", cm->Text);
       std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
-      for ( rit = this->ErrorWarningFileLineRegex.begin();
-            rit != this->ErrorWarningFileLineRegex.end(); ++ rit )
-        {
+      for (rit = this->ErrorWarningFileLineRegex.begin();
+           rit != this->ErrorWarningFileLineRegex.end(); ++rit) {
         cmsys::RegularExpression* re = &rit->RegularExpression;
-        if ( re->find(cm->Text.c_str() ) )
-          {
+        if (re->find(cm->Text.c_str())) {
           cm->SourceFile = re->match(rit->FileIndex);
           // At this point we need to make this->SourceFile relative to
           // the source root of the project, so cvs links will work
           cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
-          if(cm->SourceFile.find("/.../") != cm->SourceFile.npos)
-            {
+          if (cm->SourceFile.find("/.../") != cm->SourceFile.npos) {
             cmSystemTools::ReplaceString(cm->SourceFile, "/.../", "");
-            std::string::size_type p = cm->SourceFile.find("/");
-            if(p != cm->SourceFile.npos)
-              {
-              cm->SourceFile = cm->SourceFile.substr(
-                p+1, cm->SourceFile.size()-p);
-              }
+            std::string::size_type p = cm->SourceFile.find('/');
+            if (p != cm->SourceFile.npos) {
+              cm->SourceFile =
+                cm->SourceFile.substr(p + 1, cm->SourceFile.size() - p);
             }
-          else
-            {
+          } else {
             // make sure it is a full path with the correct case
-            cm->SourceFile = cmSystemTools::CollapseFullPath(
-              cm->SourceFile);
-            cmSystemTools::ReplaceString(
-              cm->SourceFile, srcdir.c_str(), "");
-            }
+            cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
+            cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
+          }
           cm->LineNumber = atoi(re->match(rit->LineIndex).c_str());
           break;
-          }
         }
-      if ( !cm->SourceFile.empty() && cm->LineNumber >= 0 )
-        {
-        if (!cm->SourceFile.empty())
-          {
+      }
+      if (!cm->SourceFile.empty() && cm->LineNumber >= 0) {
+        if (!cm->SourceFile.empty()) {
           xml.Element("SourceFile", cm->SourceFile);
-          }
-        if (!cm->SourceFileTail.empty())
-          {
+        }
+        if (!cm->SourceFileTail.empty()) {
           xml.Element("SourceFileTail", cm->SourceFileTail);
-          }
-        if ( cm->LineNumber >= 0 )
-          {
+        }
+        if (cm->LineNumber >= 0) {
           xml.Element("SourceLineNumber", cm->LineNumber);
-          }
         }
+      }
       xml.Element("PreContext", cm->PreContext);
       xml.StartElement("PostContext");
       xml.Content(cm->PostContext);
       // is this the last warning or error, if so notify
       if ((cm->Error && !numErrorsAllowed) ||
-          (!cm->Error && !numWarningsAllowed))
-        {
+          (!cm->Error && !numWarningsAllowed)) {
         xml.Content("\nThe maximum number of reported warnings or errors "
-          "has been reached!!!\n");
-        }
+                    "has been reached!!!\n");
+      }
       xml.EndElement(); // PostContext
       xml.Element("RepeatCount", "0");
       xml.EndElement(); // "Error" / "Warning"
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
                                             double elapsed_build_time)
 {
@@ -741,25 +668,24 @@ void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
 
   xml.Element("EndDateTime", this->EndBuild);
   xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
-  xml.Element("ElapsedMinutes", static_cast<int>(elapsed_build_time/6)/10.0);
+  xml.Element("ElapsedMinutes",
+              static_cast<int>(elapsed_build_time / 6) / 10.0);
   xml.EndElement(); // Build
   this->CTest->EndXML(xml);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname)
 {
   // error-{hash}.xml
   return (cmHasLiteralPrefix(fname, "error-") &&
-          strcmp(fname+strlen(fname)-4, ".xml") == 0);
+          strcmp(fname + strlen(fname) - 4, ".xml") == 0);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
 {
   // warning-{hash}.xml
   return (cmHasLiteralPrefix(fname, "warning-") &&
-          strcmp(fname+strlen(fname)-4, ".xml") == 0);
+          strcmp(fname + strlen(fname) - 4, ".xml") == 0);
 }
 
 //######################################################################
@@ -767,12 +693,12 @@ bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname)
 //######################################################################
 //######################################################################
 
-//----------------------------------------------------------------------------
 class cmCTestBuildHandler::LaunchHelper
 {
 public:
   LaunchHelper(cmCTestBuildHandler* handler);
   ~LaunchHelper();
+
 private:
   cmCTestBuildHandler* Handler;
   cmCTest* CTest;
@@ -782,19 +708,16 @@ private:
                            std::vector<std::string> const& matchers);
 };
 
-//----------------------------------------------------------------------------
-cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler):
-  Handler(handler), CTest(handler->CTest)
+cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
+  : Handler(handler)
+  , CTest(handler->CTest)
 {
   std::string tag = this->CTest->GetCurrentTag();
-  if(tag.empty())
-    {
+  if (tag.empty()) {
     // This is not for a dashboard submission, so there is no XML.
     // Skip enabling the launchers.
     this->Handler->UseCTestLaunch = false;
-    }
-  else
-    {
+  } else {
     // Compute a directory in which to store launcher fragments.
     std::string& launchDir = this->Handler->CTestLaunchDir;
     launchDir = this->CTest->GetBinaryDir();
@@ -805,34 +728,29 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler):
     // Clean out any existing launcher fragments.
     cmSystemTools::RemoveADirectory(launchDir);
 
-    if(this->Handler->UseCTestLaunch)
-      {
+    if (this->Handler->UseCTestLaunch) {
       // Enable launcher fragments.
       cmSystemTools::MakeDirectory(launchDir.c_str());
       this->WriteLauncherConfig();
       std::string launchEnv = "CTEST_LAUNCH_LOGS=";
       launchEnv += launchDir;
       cmSystemTools::PutEnv(launchEnv);
-      }
     }
+  }
 
   // If not using launchers, make sure they passthru.
-  if(!this->Handler->UseCTestLaunch)
-    {
+  if (!this->Handler->UseCTestLaunch) {
     cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmCTestBuildHandler::LaunchHelper::~LaunchHelper()
 {
-  if(this->Handler->UseCTestLaunch)
-    {
+  if (this->Handler->UseCTestLaunch) {
     cmSystemTools::UnsetEnv("CTEST_LAUNCH_LOGS");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
 {
   this->WriteScrapeMatchers("Warning",
@@ -848,58 +766,50 @@ void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
   fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmCTestBuildHandler::LaunchHelper
-::WriteScrapeMatchers(const char* purpose,
-                      std::vector<std::string> const& matchers)
+void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
+  const char* purpose, std::vector<std::string> const& matchers)
 {
-  if(matchers.empty())
-    {
+  if (matchers.empty()) {
     return;
-    }
+  }
   std::string fname = this->Handler->CTestLaunchDir;
   fname += "/Custom";
   fname += purpose;
   fname += ".txt";
   cmGeneratedFileStream fout(fname.c_str());
-  for(std::vector<std::string>::const_iterator mi = matchers.begin();
-      mi != matchers.end(); ++mi)
-    {
+  for (std::vector<std::string>::const_iterator mi = matchers.begin();
+       mi != matchers.end(); ++mi) {
     fout << *mi << "\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------
-int cmCTestBuildHandler::RunMakeCommand(const char* command,
-  int* retVal, const char* dir, int timeout, std::ostream& ofs)
+int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
+                                        const char* dir, int timeout,
+                                        std::ostream& ofs)
 {
   // First generate the command and arguments
   std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     return false;
-    }
+  }
 
   std::vector<const char*> argv;
-  for(std::vector<std::string>::const_iterator a = args.begin();
-    a != args.end(); ++a)
-    {
+  for (std::vector<std::string>::const_iterator a = args.begin();
+       a != args.end(); ++a) {
     argv.push_back(a->c_str());
-    }
+  }
   argv.push_back(0);
 
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:",
-    this->Quiet);
+                     this->Quiet);
   std::vector<const char*>::iterator ait;
-  for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait )
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " \"" << *ait <<
-      "\"", this->Quiet);
-    }
+  for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       " \"" << *ait << "\"", this->Quiet);
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
-    this->Quiet);
+                     this->Quiet);
 
   // Optionally use make rule launchers to record errors and warnings.
   LaunchHelper launchHelper(this);
@@ -919,12 +829,14 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
 
   char* data;
   int length;
-  cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
-    "   Each symbol represents " << tick_len << " bytes of output."
-    << std::endl
-    << (this->UseCTestLaunch? "" :
-        "   '!' represents an error and '*' a warning.\n")
-    << "    " << std::flush, this->Quiet);
+  cmCTestOptionalLog(
+    this->CTest, HANDLER_PROGRESS_OUTPUT, "   Each symbol represents "
+      << tick_len << " bytes of output." << std::endl
+      << (this->UseCTestLaunch
+            ? ""
+            : "   '!' represents an error and '*' a warning.\n")
+      << "    " << std::flush,
+    this->Quiet);
 
   // Initialize building structures
   this->BuildProcessingQueue.clear();
@@ -939,96 +851,84 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
 
   // For every chunk of data
   int res;
-  while((res = cmsysProcess_WaitForData(cp, &data, &length, 0)))
-    {
+  while ((res = cmsysProcess_WaitForData(cp, &data, &length, 0))) {
     // Replace '\0' with '\n', since '\0' does not really make sense. This is
     // for Visual Studio output
-    for(int cc =0; cc < length; ++cc)
-      {
-      if(data[cc] == 0)
-        {
+    for (int cc = 0; cc < length; ++cc) {
+      if (data[cc] == 0) {
         data[cc] = '\n';
-        }
       }
+    }
 
     // Process the chunk of data
-    if ( res == cmsysProcess_Pipe_STDERR )
-      {
+    if (res == cmsysProcess_Pipe_STDERR) {
       this->ProcessBuffer(data, length, tick, tick_len, ofs,
-        &this->BuildProcessingErrorQueue);
-      }
-    else
-      {
+                          &this->BuildProcessingErrorQueue);
+    } else {
       this->ProcessBuffer(data, length, tick, tick_len, ofs,
-        &this->BuildProcessingQueue);
-      }
+                          &this->BuildProcessingQueue);
     }
+  }
 
   this->ProcessBuffer(0, 0, tick, tick_len, ofs, &this->BuildProcessingQueue);
   this->ProcessBuffer(0, 0, tick, tick_len, ofs,
-    &this->BuildProcessingErrorQueue);
+                      &this->BuildProcessingErrorQueue);
   cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: "
-    << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl,
-    this->Quiet);
+                       << ((this->BuildOutputLogSize + 512) / 1024) << "K"
+                       << std::endl,
+                     this->Quiet);
 
   // Properly handle output of the build command
   cmsysProcess_WaitForExit(cp, 0);
   int result = cmsysProcess_GetState(cp);
 
-  if(result == cmsysProcess_State_Exited)
-    {
-    if (retVal)
-      {
+  if (result == cmsysProcess_State_Exited) {
+    if (retVal) {
       *retVal = cmsysProcess_GetExitValue(cp);
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Command exited with the value: " << *retVal << std::endl, this->Quiet);
+                         "Command exited with the value: " << *retVal
+                                                           << std::endl,
+                         this->Quiet);
       // if a non zero return value
-      if (*retVal)
-        {
+      if (*retVal) {
         // If there was an error running command, report that on the
         // dashboard.
         cmCTestBuildErrorWarning errorwarning;
-        errorwarning.LogLine     = 1;
-        errorwarning.Text
-          = "*** WARNING non-zero return value in ctest from: ";
-        errorwarning.Text        += argv[0];
-        errorwarning.PreContext  = "";
+        errorwarning.LogLine = 1;
+        errorwarning.Text =
+          "*** WARNING non-zero return value in ctest from: ";
+        errorwarning.Text += argv[0];
+        errorwarning.PreContext = "";
         errorwarning.PostContext = "";
-        errorwarning.Error       = false;
+        errorwarning.Error = false;
         this->ErrorsAndWarnings.push_back(errorwarning);
-        this->TotalWarnings ++;
-        }
+        this->TotalWarnings++;
       }
     }
-  else if(result == cmsysProcess_State_Exception)
-    {
-    if (retVal)
-      {
+  } else if (result == cmsysProcess_State_Exception) {
+    if (retVal) {
       *retVal = cmsysProcess_GetExitException(cp);
-      cmCTestOptionalLog(this->CTest, WARNING, "There was an exception: " <<
-        *retVal << std::endl, this->Quiet);
-      }
-    }
-  else if(result == cmsysProcess_State_Expired)
-    {
-    cmCTestOptionalLog(this->CTest, WARNING, "There was a timeout" <<
-      std::endl, this->Quiet);
+      cmCTestOptionalLog(this->CTest, WARNING,
+                         "There was an exception: " << *retVal << std::endl,
+                         this->Quiet);
     }
-  else if(result == cmsysProcess_State_Error)
-    {
+  } else if (result == cmsysProcess_State_Expired) {
+    cmCTestOptionalLog(this->CTest, WARNING,
+                       "There was a timeout" << std::endl, this->Quiet);
+  } else if (result == cmsysProcess_State_Error) {
     // If there was an error running command, report that on the dashboard.
     cmCTestBuildErrorWarning errorwarning;
-    errorwarning.LogLine     = 1;
-    errorwarning.Text        = "*** ERROR executing: ";
-    errorwarning.Text        += cmsysProcess_GetErrorString(cp);
-    errorwarning.PreContext  = "";
+    errorwarning.LogLine = 1;
+    errorwarning.Text = "*** ERROR executing: ";
+    errorwarning.Text += cmsysProcess_GetErrorString(cp);
+    errorwarning.PreContext = "";
     errorwarning.PostContext = "";
-    errorwarning.Error       = true;
+    errorwarning.Error = true;
     this->ErrorsAndWarnings.push_back(errorwarning);
-    this->TotalErrors ++;
+    this->TotalErrors++;
     cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
-      << cmsysProcess_GetErrorString(cp) << std::endl);
-    }
+                 << cmsysProcess_GetErrorString(cp) << std::endl);
+  }
 
   cmsysProcess_Delete(cp);
   return result;
@@ -1039,48 +939,39 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
 //######################################################################
 //######################################################################
 
-//----------------------------------------------------------------------
 void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
-  size_t& tick, size_t tick_len, std::ostream& ofs,
-  t_BuildProcessingQueueType* queue)
+                                        size_t& tick, size_t tick_len,
+                                        std::ostream& ofs,
+                                        t_BuildProcessingQueueType* queue)
 {
   const std::string::size_type tick_line_len = 50;
   const char* ptr;
-  for ( ptr = data; ptr < data+length; ptr ++ )
-    {
+  for (ptr = data; ptr < data + length; ptr++) {
     queue->push_back(*ptr);
-    }
+  }
   this->BuildOutputLogSize += length;
 
   // until there are any lines left in the buffer
-  while ( 1 )
-    {
+  while (1) {
     // Find the end of line
     t_BuildProcessingQueueType::iterator it;
-    for ( it = queue->begin();
-      it != queue->end();
-      ++ it )
-      {
-      if ( *it == '\n' )
-        {
+    for (it = queue->begin(); it != queue->end(); ++it) {
+      if (*it == '\n') {
         break;
-        }
       }
+    }
 
     // Once certain number of errors or warnings reached, ignore future errors
     // or warnings.
-    if ( this->TotalWarnings >= this->MaxWarnings )
-      {
+    if (this->TotalWarnings >= this->MaxWarnings) {
       this->WarningQuotaReached = true;
-      }
-    if ( this->TotalErrors >= this->MaxErrors )
-      {
+    }
+    if (this->TotalErrors >= this->MaxErrors) {
       this->ErrorQuotaReached = true;
-      }
+    }
 
     // If the end of line was found
-    if ( it != queue->end() )
-      {
+    if (it != queue->end()) {
       // Create a contiguous array for the line
       this->CurrentProcessingLine.clear();
       this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
@@ -1092,122 +983,107 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
       int lineType = this->ProcessSingleLine(line);
 
       // Erase the line from the queue
-      queue->erase(queue->begin(), it+1);
+      queue->erase(queue->begin(), it + 1);
 
       // Depending on the line type, produce error or warning, or nothing
       cmCTestBuildErrorWarning errorwarning;
       bool found = false;
-      switch ( lineType )
-        {
-      case b_WARNING_LINE:
-        this->LastTickChar = '*';
-        errorwarning.Error = false;
-        found = true;
-        this->TotalWarnings ++;
-        break;
-      case b_ERROR_LINE:
-        this->LastTickChar = '!';
-        errorwarning.Error = true;
-        found = true;
-        this->TotalErrors ++;
-        break;
-        }
-      if ( found )
-        {
+      switch (lineType) {
+        case b_WARNING_LINE:
+          this->LastTickChar = '*';
+          errorwarning.Error = false;
+          found = true;
+          this->TotalWarnings++;
+          break;
+        case b_ERROR_LINE:
+          this->LastTickChar = '!';
+          errorwarning.Error = true;
+          found = true;
+          this->TotalErrors++;
+          break;
+      }
+      if (found) {
         // This is an error or warning, so generate report
-        errorwarning.LogLine   = static_cast<int>(this->OutputLineCounter+1);
-        errorwarning.Text        = line;
-        errorwarning.PreContext  = "";
+        errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
+        errorwarning.Text = line;
+        errorwarning.PreContext = "";
         errorwarning.PostContext = "";
 
         // Copy pre-context to report
         std::deque<std::string>::iterator pcit;
-        for ( pcit = this->PreContext.begin();
-          pcit != this->PreContext.end();
-          ++pcit )
-          {
+        for (pcit = this->PreContext.begin(); pcit != this->PreContext.end();
+             ++pcit) {
           errorwarning.PreContext += *pcit + "\n";
-          }
+        }
         this->PreContext.clear();
 
         // Store report
         this->ErrorsAndWarnings.push_back(errorwarning);
-        this->LastErrorOrWarning = this->ErrorsAndWarnings.end()-1;
+        this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
         this->PostContextCount = 0;
-        }
-      else
-        {
+      } else {
         // This is not an error or warning.
         // So, figure out if this is a post-context line
-        if ( !this->ErrorsAndWarnings.empty() &&
-             this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
-             this->PostContextCount < this->MaxPostContext )
-          {
-          this->PostContextCount ++;
+        if (!this->ErrorsAndWarnings.empty() &&
+            this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
+            this->PostContextCount < this->MaxPostContext) {
+          this->PostContextCount++;
           this->LastErrorOrWarning->PostContext += line;
-          if ( this->PostContextCount < this->MaxPostContext )
-            {
+          if (this->PostContextCount < this->MaxPostContext) {
             this->LastErrorOrWarning->PostContext += "\n";
-            }
           }
-        else
-          {
+        } else {
           // Otherwise store pre-context for the next error
           this->PreContext.push_back(line);
-          if ( this->PreContext.size() > this->MaxPreContext )
-            {
+          if (this->PreContext.size() > this->MaxPreContext) {
             this->PreContext.erase(this->PreContext.begin(),
-              this->PreContext.end()-this->MaxPreContext);
-            }
+                                   this->PreContext.end() -
+                                     this->MaxPreContext);
           }
         }
-      this->OutputLineCounter ++;
       }
-    else
-      {
+      this->OutputLineCounter++;
+    } else {
       break;
-      }
     }
+  }
 
   // Now that the buffer is processed, display missing ticks
   int tickDisplayed = false;
-  while ( this->BuildOutputLogSize > (tick * tick_len) )
-    {
-    tick ++;
+  while (this->BuildOutputLogSize > (tick * tick_len)) {
+    tick++;
     cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
-      this->LastTickChar, this->Quiet);
+                       this->LastTickChar, this->Quiet);
     tickDisplayed = true;
-    if ( tick % tick_line_len == 0 && tick > 0 )
-      {
+    if (tick % tick_line_len == 0 && tick > 0) {
       cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, "  Size: "
-        << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl
-        << "    ", this->Quiet);
-      }
+                           << ((this->BuildOutputLogSize + 512) / 1024) << "K"
+                           << std::endl
+                           << "    ",
+                         this->Quiet);
     }
-  if ( tickDisplayed )
-    {
+  }
+  if (tickDisplayed) {
     this->LastTickChar = '.';
-    }
+  }
 
   // And if this is verbose output, display the content of the chunk
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    cmCTestLogWrite(data, length));
+             cmCTestLogWrite(data, length));
 
   // Always store the chunk to the file
   ofs << cmCTestLogWrite(data, length);
 }
 
-//----------------------------------------------------------------------
 int cmCTestBuildHandler::ProcessSingleLine(const char* data)
 {
-  if(this->UseCTestLaunch)
-    {
+  if (this->UseCTestLaunch) {
     // No log scraping when using launchers.
     return b_REGULAR_LINE;
-    }
+  }
 
-  cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" <<
-    std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
+                     this->Quiet);
 
   std::vector<cmsys::RegularExpression>::iterator it;
 
@@ -1216,86 +1092,76 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
 
   // Check for regular expressions
 
-  if ( !this->ErrorQuotaReached )
-    {
+  if (!this->ErrorQuotaReached) {
     // Errors
     int wrxCnt = 0;
-    for ( it = this->ErrorMatchRegex.begin();
-      it != this->ErrorMatchRegex.end();
-      ++ it )
-      {
-      if ( it->find(data) )
-        {
+    for (it = this->ErrorMatchRegex.begin(); it != this->ErrorMatchRegex.end();
+         ++it) {
+      if (it->find(data)) {
         errorLine = 1;
-        cmCTestOptionalLog(this->CTest, DEBUG, "  Error Line: " << data
-          << " (matches: " << this->CustomErrorMatches[wrxCnt] << ")"
-          << std::endl, this->Quiet);
+        cmCTestOptionalLog(this->CTest, DEBUG,
+                           "  Error Line: " << data << " (matches: "
+                                            << this->CustomErrorMatches[wrxCnt]
+                                            << ")" << std::endl,
+                           this->Quiet);
         break;
-        }
-      wrxCnt ++;
       }
+      wrxCnt++;
+    }
     // Error exceptions
     wrxCnt = 0;
-    for ( it = this->ErrorExceptionRegex.begin();
-      it != this->ErrorExceptionRegex.end();
-      ++ it )
-      {
-      if ( it->find(data) )
-        {
+    for (it = this->ErrorExceptionRegex.begin();
+         it != this->ErrorExceptionRegex.end(); ++it) {
+      if (it->find(data)) {
         errorLine = 0;
-        cmCTestOptionalLog(this->CTest, DEBUG, "  Not an error Line: " << data
-          << " (matches: " << this->CustomErrorExceptions[wrxCnt] << ")"
-          << std::endl, this->Quiet);
+        cmCTestOptionalLog(this->CTest, DEBUG, "  Not an error Line: "
+                             << data << " (matches: "
+                             << this->CustomErrorExceptions[wrxCnt] << ")"
+                             << std::endl,
+                           this->Quiet);
         break;
-        }
-      wrxCnt ++;
       }
+      wrxCnt++;
     }
-  if ( !this->WarningQuotaReached )
-    {
+  }
+  if (!this->WarningQuotaReached) {
     // Warnings
     int wrxCnt = 0;
-    for ( it = this->WarningMatchRegex.begin();
-      it != this->WarningMatchRegex.end();
-      ++ it )
-      {
-      if ( it->find(data) )
-        {
+    for (it = this->WarningMatchRegex.begin();
+         it != this->WarningMatchRegex.end(); ++it) {
+      if (it->find(data)) {
         warningLine = 1;
-        cmCTestOptionalLog(this->CTest, DEBUG,
-          "  Warning Line: " << data
-          << " (matches: " << this->CustomWarningMatches[wrxCnt] << ")"
-          << std::endl, this->Quiet);
+        cmCTestOptionalLog(this->CTest, DEBUG, "  Warning Line: "
+                             << data << " (matches: "
+                             << this->CustomWarningMatches[wrxCnt] << ")"
+                             << std::endl,
+                           this->Quiet);
         break;
-        }
-      wrxCnt ++;
       }
+      wrxCnt++;
+    }
 
     wrxCnt = 0;
     // Warning exceptions
-    for ( it = this->WarningExceptionRegex.begin();
-      it != this->WarningExceptionRegex.end();
-      ++ it )
-      {
-      if ( it->find(data) )
-        {
+    for (it = this->WarningExceptionRegex.begin();
+         it != this->WarningExceptionRegex.end(); ++it) {
+      if (it->find(data)) {
         warningLine = 0;
-        cmCTestOptionalLog(this->CTest, DEBUG, "  Not a warning Line: " << data
-          << " (matches: " << this->CustomWarningExceptions[wrxCnt] << ")"
-          << std::endl, this->Quiet);
+        cmCTestOptionalLog(this->CTest, DEBUG, "  Not a warning Line: "
+                             << data << " (matches: "
+                             << this->CustomWarningExceptions[wrxCnt] << ")"
+                             << std::endl,
+                           this->Quiet);
         break;
-        }
-      wrxCnt ++;
       }
+      wrxCnt++;
     }
-  if ( errorLine )
-    {
+  }
+  if (errorLine) {
     return b_ERROR_LINE;
-    }
-  if ( warningLine )
-    {
+  }
+  if (warningLine) {
     return b_WARNING_LINE;
-    }
+  }
   return b_REGULAR_LINE;
 }
-
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index 2e9b92a..48a37b7 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestBuildHandler_h
 #define cmCTestBuildHandler_h
 
-
 #include "cmCTestGenericHandler.h"
+
 #include "cmListFileCache.h"
 
 #include <cmsys/RegularExpression.hxx>
@@ -40,48 +40,48 @@ public:
 
   cmCTestBuildHandler();
 
-  void PopulateCustomVectors(cmMakefile *mf);
+  void PopulateCustomVectors(cmMakefile* mf);
 
   /**
    * Initialize handler
    */
   virtual void Initialize();
 
-  int GetTotalErrors() { return this->TotalErrors;}
-  int GetTotalWarnings() { return this->TotalWarnings;}
+  int GetTotalErrors() { return this->TotalErrors; }
+  int GetTotalWarnings() { return this->TotalWarnings; }
 
 private:
   std::string GetMakeCommand();
 
   //! Run command specialized for make and configure. Returns process status
   // and retVal is return value or exception.
-  int RunMakeCommand(const char* command,
-    int* retVal, const char* dir, int timeout,
-    std::ostream& ofs);
+  int RunMakeCommand(const char* command, int* retVal, const char* dir,
+                     int timeout, std::ostream& ofs);
 
-  enum {
+  enum
+  {
     b_REGULAR_LINE,
     b_WARNING_LINE,
     b_ERROR_LINE
   };
 
   class cmCTestCompileErrorWarningRex
-    {
+  {
   public:
     cmCTestCompileErrorWarningRex() {}
     int FileIndex;
     int LineIndex;
     cmsys::RegularExpression RegularExpression;
-    };
+  };
 
   struct cmCTestBuildErrorWarning
   {
-    bool        Error;
-    int         LogLine;
+    bool Error;
+    int LogLine;
     std::string Text;
     std::string SourceFile;
     std::string SourceFileTail;
-    int         LineNumber;
+    int LineNumber;
     std::string PreContext;
     std::string PostContext;
   };
@@ -94,10 +94,10 @@ private:
   bool IsLaunchedErrorFile(const char* fname);
   bool IsLaunchedWarningFile(const char* fname);
 
-  std::string             StartBuild;
-  std::string             EndBuild;
-  double                  StartBuildTime;
-  double                  EndBuildTime;
+  std::string StartBuild;
+  std::string EndBuild;
+  double StartBuildTime;
+  double EndBuildTime;
 
   std::vector<std::string> CustomErrorMatches;
   std::vector<std::string> CustomErrorExceptions;
@@ -115,34 +115,35 @@ private:
   typedef std::deque<char> t_BuildProcessingQueueType;
 
   void ProcessBuffer(const char* data, int length, size_t& tick,
-    size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue);
+                     size_t tick_len, std::ostream& ofs,
+                     t_BuildProcessingQueueType* queue);
   int ProcessSingleLine(const char* data);
 
-  t_BuildProcessingQueueType            BuildProcessingQueue;
-  t_BuildProcessingQueueType            BuildProcessingErrorQueue;
-  size_t                                BuildOutputLogSize;
-  std::vector<char>                     CurrentProcessingLine;
+  t_BuildProcessingQueueType BuildProcessingQueue;
+  t_BuildProcessingQueueType BuildProcessingErrorQueue;
+  size_t BuildOutputLogSize;
+  std::vector<char> CurrentProcessingLine;
 
-  std::string                           SimplifySourceDir;
-  std::string                           SimplifyBuildDir;
-  size_t                                OutputLineCounter;
+  std::string SimplifySourceDir;
+  std::string SimplifyBuildDir;
+  size_t OutputLineCounter;
   typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
-  t_ErrorsAndWarningsVector             ErrorsAndWarnings;
-  t_ErrorsAndWarningsVector::iterator   LastErrorOrWarning;
-  size_t                                PostContextCount;
-  size_t                                MaxPreContext;
-  size_t                                MaxPostContext;
-  std::deque<std::string>               PreContext;
-
-  int                                   TotalErrors;
-  int                                   TotalWarnings;
-  char                                  LastTickChar;
-
-  bool                                  ErrorQuotaReached;
-  bool                                  WarningQuotaReached;
-
-  int                                   MaxErrors;
-  int                                   MaxWarnings;
+  t_ErrorsAndWarningsVector ErrorsAndWarnings;
+  t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
+  size_t PostContextCount;
+  size_t MaxPreContext;
+  size_t MaxPostContext;
+  std::deque<std::string> PreContext;
+
+  int TotalErrors;
+  int TotalWarnings;
+  char LastTickChar;
+
+  bool ErrorQuotaReached;
+  bool WarningQuotaReached;
+
+  int MaxErrors;
+  int MaxWarnings;
 
   bool UseCTestLaunch;
   std::string CTestLaunchDir;
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 0fb3fec..5ddafbb 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -15,25 +15,24 @@
 #include "cmSystemTools.h"
 #include "cmXMLWriter.h"
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
 
-//----------------------------------------------------------------------------
-cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log)
+cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log)
+  : cmCTestVC(ct, log)
 {
 }
 
-//----------------------------------------------------------------------------
 cmCTestCVS::~cmCTestCVS()
 {
 }
 
-//----------------------------------------------------------------------------
-class cmCTestCVS::UpdateParser: public cmCTestVC::LineParser
+class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser
 {
 public:
-  UpdateParser(cmCTestCVS* cvs, const char* prefix): CVS(cvs)
-    {
+  UpdateParser(cmCTestCVS* cvs, const char* prefix)
+    : CVS(cvs)
+  {
     this->SetLog(&cvs->Log, prefix);
     // See "man cvs", section "update output".
     this->RegexFileUpdated.compile("^([UP])  *(.*)");
@@ -44,7 +43,8 @@ public:
     this->RegexFileRemoved2.compile(
       "cvs[^ ]* update: "
       "warning: `?([^']*)'? is not \\(any longer\\) pertinent");
-    }
+  }
+
 private:
   cmCTestCVS* CVS;
   cmsys::RegularExpression RegexFileUpdated;
@@ -54,69 +54,55 @@ private:
   cmsys::RegularExpression RegexFileRemoved2;
 
   virtual bool ProcessLine()
-    {
-    if(this->RegexFileUpdated.find(this->Line))
-      {
+  {
+    if (this->RegexFileUpdated.find(this->Line)) {
       this->DoFile(PathUpdated, this->RegexFileUpdated.match(2));
-      }
-    else if(this->RegexFileModified.find(this->Line))
-      {
+    } else if (this->RegexFileModified.find(this->Line)) {
       this->DoFile(PathModified, this->RegexFileModified.match(2));
-      }
-    else if(this->RegexFileConflicting.find(this->Line))
-      {
+    } else if (this->RegexFileConflicting.find(this->Line)) {
       this->DoFile(PathConflicting, this->RegexFileConflicting.match(2));
-      }
-    else if(this->RegexFileRemoved1.find(this->Line))
-      {
+    } else if (this->RegexFileRemoved1.find(this->Line)) {
       this->DoFile(PathUpdated, this->RegexFileRemoved1.match(1));
-      }
-    else if(this->RegexFileRemoved2.find(this->Line))
-      {
+    } else if (this->RegexFileRemoved2.find(this->Line)) {
       this->DoFile(PathUpdated, this->RegexFileRemoved2.match(1));
-      }
-    return true;
     }
+    return true;
+  }
 
   void DoFile(PathStatus status, std::string const& file)
-    {
+  {
     std::string dir = cmSystemTools::GetFilenamePath(file);
     std::string name = cmSystemTools::GetFilenameName(file);
     this->CVS->Dirs[dir][name] = status;
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 bool cmCTestCVS::UpdateImpl()
 {
   // Get user-specified update options.
   std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
-  if(opts.empty())
-    {
+  if (opts.empty()) {
     opts = this->CTest->GetCTestConfiguration("CVSUpdateOptions");
-    if(opts.empty())
-      {
+    if (opts.empty()) {
       opts = "-dP";
-      }
     }
+  }
   std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
 
   // Specify the start time for nightly testing.
-  if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
-    {
+  if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
     args.push_back("-D" + this->GetNightlyTime() + " UTC");
-    }
+  }
 
   // Run "cvs update" to update the work tree.
   std::vector<char const*> cvs_update;
   cvs_update.push_back(this->CommandLineTool.c_str());
   cvs_update.push_back("-z3");
   cvs_update.push_back("update");
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     cvs_update.push_back(ai->c_str());
-    }
+  }
   cvs_update.push_back(0);
 
   UpdateParser out(this, "up-out> ");
@@ -124,153 +110,136 @@ bool cmCTestCVS::UpdateImpl()
   return this->RunUpdateCommand(&cvs_update[0], &out, &err);
 }
 
-//----------------------------------------------------------------------------
-class cmCTestCVS::LogParser: public cmCTestVC::LineParser
+class cmCTestCVS::LogParser : public cmCTestVC::LineParser
 {
 public:
   typedef cmCTestCVS::Revision Revision;
-  LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs):
-    CVS(cvs), Revisions(revs), Section(SectionHeader)
-    {
+  LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs)
+    : CVS(cvs)
+    , Revisions(revs)
+    , Section(SectionHeader)
+  {
     this->SetLog(&cvs->Log, prefix),
-    this->RegexRevision.compile("^revision +([^ ]*) *$");
+      this->RegexRevision.compile("^revision +([^ ]*) *$");
     this->RegexBranches.compile("^branches: .*$");
     this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);");
-    }
+  }
+
 private:
   cmCTestCVS* CVS;
   std::vector<Revision>& Revisions;
   cmsys::RegularExpression RegexRevision;
   cmsys::RegularExpression RegexBranches;
   cmsys::RegularExpression RegexPerson;
-  enum SectionType { SectionHeader, SectionRevisions, SectionEnd };
+  enum SectionType
+  {
+    SectionHeader,
+    SectionRevisions,
+    SectionEnd
+  };
   SectionType Section;
   Revision Rev;
 
   virtual bool ProcessLine()
-    {
-    if(this->Line == ("======================================="
-                      "======================================"))
-      {
+  {
+    if (this->Line == ("======================================="
+                       "======================================")) {
       // This line ends the revision list.
-      if(this->Section == SectionRevisions)
-        {
+      if (this->Section == SectionRevisions) {
         this->FinishRevision();
-        }
-      this->Section = SectionEnd;
       }
-    else if(this->Line == "----------------------------")
-      {
+      this->Section = SectionEnd;
+    } else if (this->Line == "----------------------------") {
       // This line divides revisions from the header and each other.
-      if(this->Section == SectionHeader)
-        {
+      if (this->Section == SectionHeader) {
         this->Section = SectionRevisions;
-        }
-      else if(this->Section == SectionRevisions)
-        {
+      } else if (this->Section == SectionRevisions) {
         this->FinishRevision();
-        }
       }
-    else if(this->Section == SectionRevisions)
-      {
-      if(!this->Rev.Log.empty())
-        {
+    } else if (this->Section == SectionRevisions) {
+      if (!this->Rev.Log.empty()) {
         // Continue the existing log.
         this->Rev.Log += this->Line;
         this->Rev.Log += "\n";
-        }
-      else if(this->Rev.Rev.empty() && this->RegexRevision.find(this->Line))
-        {
+      } else if (this->Rev.Rev.empty() &&
+                 this->RegexRevision.find(this->Line)) {
         this->Rev.Rev = this->RegexRevision.match(1);
-        }
-      else if(this->Rev.Date.empty() && this->RegexPerson.find(this->Line))
-        {
+      } else if (this->Rev.Date.empty() &&
+                 this->RegexPerson.find(this->Line)) {
         this->Rev.Date = this->RegexPerson.match(1);
         this->Rev.Author = this->RegexPerson.match(2);
-        }
-      else if(!this->RegexBranches.find(this->Line))
-        {
+      } else if (!this->RegexBranches.find(this->Line)) {
         // Start the log.
         this->Rev.Log += this->Line;
         this->Rev.Log += "\n";
-        }
       }
-    return this->Section != SectionEnd;
     }
+    return this->Section != SectionEnd;
+  }
 
   void FinishRevision()
-    {
-    if(!this->Rev.Rev.empty())
-      {
+  {
+    if (!this->Rev.Rev.empty()) {
       // Record this revision.
+      /* clang-format off */
       this->CVS->Log << "Found revision " << this->Rev.Rev << "\n"
                      << "  author = " << this->Rev.Author << "\n"
                      << "  date = " << this->Rev.Date << "\n";
+      /* clang-format on */
       this->Revisions.push_back(this->Rev);
 
       // We only need two revisions.
-      if(this->Revisions.size() >= 2)
-        {
+      if (this->Revisions.size() >= 2) {
         this->Section = SectionEnd;
-        }
       }
-    this->Rev = Revision();
     }
+    this->Rev = Revision();
+  }
 };
 
-//----------------------------------------------------------------------------
 std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
 {
   // Compute the tag file location for this directory.
   std::string tagFile = this->SourceDirectory;
-  if(!dir.empty())
-    {
+  if (!dir.empty()) {
     tagFile += "/";
     tagFile += dir;
-    }
+  }
   tagFile += "/CVS/Tag";
 
   // Lookup the branch in the tag file, if any.
   std::string tagLine;
   cmsys::ifstream tagStream(tagFile.c_str());
-  if(tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
-     tagLine.size() > 1 && tagLine[0] == 'T')
-    {
+  if (tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
+      tagLine.size() > 1 && tagLine[0] == 'T') {
     // Use the branch specified in the tag file.
     std::string flag = "-r";
     flag += tagLine.substr(1);
     return flag;
-    }
-  else
-    {
+  } else {
     // Use the default branch.
     return "-b";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmCTestCVS::LoadRevisions(std::string const& file,
-                               const char* branchFlag,
+void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag,
                                std::vector<Revision>& revisions)
 {
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
 
   // Run "cvs log" to get revisions of this file on this branch.
   const char* cvs = this->CommandLineTool.c_str();
-  const char* cvs_log[] =
-    {cvs, "log", "-N", branchFlag, file.c_str(), 0};
+  const char* cvs_log[] = { cvs, "log", "-N", branchFlag, file.c_str(), 0 };
 
   LogParser out(this, "log-out> ", revisions);
   OutputLogger err(this->Log, "log-err> ");
   this->RunChild(cvs_log, &out, &err);
 }
 
-//----------------------------------------------------------------------------
-void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
-                                   std::string const& path,
+void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
                                    Directory const& dir)
 {
-  const char* slash = path.empty()? "":"/";
+  const char* slash = path.empty() ? "" : "/";
   xml.StartElement("Directory");
   xml.Element("Name", path);
 
@@ -279,40 +248,38 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
 
   // Load revisions and write an entry for each file in this directory.
   std::vector<Revision> revisions;
-  for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
-    {
+  for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
     std::string full = path + slash + fi->first;
 
     // Load two real or unknown revisions.
     revisions.clear();
-    if(fi->second != PathUpdated)
-      {
+    if (fi->second != PathUpdated) {
       // For local modifications the current rev is unknown and the
       // prior rev is the latest from cvs.
       revisions.push_back(this->Unknown);
-      }
+    }
     this->LoadRevisions(full, branchFlag.c_str(), revisions);
     revisions.resize(2, this->Unknown);
 
     // Write the entry for this file with these revisions.
     File f(fi->second, &revisions[0], &revisions[1]);
     this->WriteXMLEntry(xml, path, fi->first, full, f);
-    }
+  }
   xml.EndElement(); // Directory
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
 {
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              "   Gathering version information (one . per updated file):\n"
-             "    " << std::flush);
+             "    "
+               << std::flush);
 
-  for(std::map<std::string, Directory>::const_iterator
-        di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
-    {
+  for (std::map<std::string, Directory>::const_iterator di =
+         this->Dirs.begin();
+       di != this->Dirs.end(); ++di) {
     this->WriteXMLDirectory(xml, di->first, di->second);
-    }
+  }
 
   cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
 
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index f2c0a73..62fe01b 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -18,7 +18,7 @@
  * \brief Interaction with cvs command-line tool
  *
  */
-class cmCTestCVS: public cmCTestVC
+class cmCTestCVS : public cmCTestVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
@@ -32,7 +32,9 @@ private:
   virtual bool WriteXMLUpdates(cmXMLWriter& xml);
 
   // Update status for files in each directory.
-  class Directory: public std::map<std::string, PathStatus> {};
+  class Directory : public std::map<std::string, PathStatus>
+  {
+  };
   std::map<std::string, Directory> Dirs;
 
   std::string ComputeBranchFlag(std::string const& dir);
diff --git a/Source/CTest/cmCTestCommand.h b/Source/CTest/cmCTestCommand.h
index e2ebba8..22a2c8e 100644
--- a/Source/CTest/cmCTestCommand.h
+++ b/Source/CTest/cmCTestCommand.h
@@ -27,14 +27,16 @@ class cmCTestScriptHandler;
 class cmCTestCommand : public cmCommand
 {
 public:
+  cmCTestCommand()
+  {
+    this->CTest = 0;
+    this->CTestScriptHandler = 0;
+  }
 
-  cmCTestCommand() {this->CTest = 0; this->CTestScriptHandler = 0;}
-
-  cmCTest *CTest;
-  cmCTestScriptHandler *CTestScriptHandler;
+  cmCTest* CTest;
+  cmCTestScriptHandler* CTestScriptHandler;
 
   cmTypeMacro(cmCTestCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index ba4dab2..a90f27a 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -11,9 +11,9 @@
 ============================================================================*/
 #include "cmCTestConfigureCommand.h"
 
-#include "cmGlobalGenerator.h"
 #include "cmCTest.h"
 #include "cmCTestGenericHandler.h"
+#include "cmGlobalGenerator.h"
 
 cmCTestConfigureCommand::cmCTestConfigureCommand()
 {
@@ -26,64 +26,56 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
 {
   std::vector<std::string> options;
 
-  if (this->Values[ctc_OPTIONS])
-    {
+  if (this->Values[ctc_OPTIONS]) {
     cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options);
-    }
+  }
 
-  if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() )
-    {
-    this->SetError("Build directory not specified. Either use BUILD "
+  if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) {
+    this->SetError(
+      "Build directory not specified. Either use BUILD "
       "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
       "variable");
     return 0;
-    }
+  }
 
-  const char* ctestConfigureCommand
-    = this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
+  const char* ctestConfigureCommand =
+    this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
 
-  if ( ctestConfigureCommand && *ctestConfigureCommand )
-    {
+  if (ctestConfigureCommand && *ctestConfigureCommand) {
     this->CTest->SetCTestConfiguration("ConfigureCommand",
-      ctestConfigureCommand, this->Quiet);
-    }
-  else
-    {
-    const char* cmakeGeneratorName
-      = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
-    if ( cmakeGeneratorName && *cmakeGeneratorName )
-      {
-      const std::string& source_dir
-        = this->CTest->GetCTestConfiguration("SourceDirectory");
-      if ( source_dir.empty() )
-        {
-        this->SetError("Source directory not specified. Either use SOURCE "
+                                       ctestConfigureCommand, this->Quiet);
+  } else {
+    const char* cmakeGeneratorName =
+      this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
+    if (cmakeGeneratorName && *cmakeGeneratorName) {
+      const std::string& source_dir =
+        this->CTest->GetCTestConfiguration("SourceDirectory");
+      if (source_dir.empty()) {
+        this->SetError(
+          "Source directory not specified. Either use SOURCE "
           "argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY "
           "variable");
         return 0;
-        }
+      }
 
       const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
-      if ( !cmSystemTools::FileExists(cmakelists_file.c_str()) )
-        {
+      if (!cmSystemTools::FileExists(cmakelists_file.c_str())) {
         std::ostringstream e;
-        e << "CMakeLists.txt file does not exist ["
-          << cmakelists_file << "]";
+        e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
         this->SetError(e.str());
         return 0;
-        }
+      }
 
       bool multiConfig = false;
       bool cmakeBuildTypeInOptions = false;
 
-      cmGlobalGenerator *gg =
+      cmGlobalGenerator* gg =
         this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
           cmakeGeneratorName);
-      if(gg)
-        {
+      if (gg) {
         multiConfig = gg->IsMultiConfig();
         delete gg;
-        }
+      }
 
       std::string cmakeConfigureCommand = "\"";
       cmakeConfigureCommand += cmSystemTools::GetCMakeCommand();
@@ -91,8 +83,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
 
       std::vector<std::string>::const_iterator it;
       std::string option;
-      for (it= options.begin(); it!=options.end(); ++it)
-        {
+      for (it = options.begin(); it != options.end(); ++it) {
         option = *it;
 
         cmakeConfigureCommand += " \"";
@@ -100,19 +91,17 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
         cmakeConfigureCommand += "\"";
 
         if ((0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) ||
-           (0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING=")))
-          {
+            (0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) {
           cmakeBuildTypeInOptions = true;
-          }
         }
+      }
 
       if (!multiConfig && !cmakeBuildTypeInOptions &&
-          !this->CTest->GetConfigType().empty())
-        {
+          !this->CTest->GetConfigType().empty()) {
         cmakeConfigureCommand += " \"-DCMAKE_BUILD_TYPE:STRING=";
         cmakeConfigureCommand += this->CTest->GetConfigType();
         cmakeConfigureCommand += "\"";
-        }
+      }
 
       cmakeConfigureCommand += " \"-G";
       cmakeConfigureCommand += cmakeGeneratorName;
@@ -120,46 +109,42 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
 
       const char* cmakeGeneratorPlatform =
         this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
-      if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform)
-        {
+      if (cmakeGeneratorPlatform && *cmakeGeneratorPlatform) {
         cmakeConfigureCommand += " \"-A";
         cmakeConfigureCommand += cmakeGeneratorPlatform;
         cmakeConfigureCommand += "\"";
-        }
+      }
 
       const char* cmakeGeneratorToolset =
         this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
-      if(cmakeGeneratorToolset && *cmakeGeneratorToolset)
-        {
+      if (cmakeGeneratorToolset && *cmakeGeneratorToolset) {
         cmakeConfigureCommand += " \"-T";
         cmakeConfigureCommand += cmakeGeneratorToolset;
         cmakeConfigureCommand += "\"";
-        }
+      }
 
       cmakeConfigureCommand += " \"";
       cmakeConfigureCommand += source_dir;
       cmakeConfigureCommand += "\"";
 
-      this->CTest->SetCTestConfiguration("ConfigureCommand",
-        cmakeConfigureCommand.c_str(), this->Quiet);
-      }
-    else
-      {
-      this->SetError("Configure command is not specified. If this is a "
+      this->CTest->SetCTestConfiguration(
+        "ConfigureCommand", cmakeConfigureCommand.c_str(), this->Quiet);
+    } else {
+      this->SetError(
+        "Configure command is not specified. If this is a "
         "\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, "
         "set CTEST_CONFIGURE_COMMAND.");
       return 0;
-      }
     }
+  }
 
-  cmCTestGenericHandler* handler
-    = this->CTest->GetInitializedHandler("configure");
-  if ( !handler )
-    {
+  cmCTestGenericHandler* handler =
+    this->CTest->GetInitializedHandler("configure");
+  if (!handler) {
     this->SetError(
       "internal CTest error. Cannot instantiate configure handler");
     return 0;
-    }
+  }
   handler->SetQuiet(this->Quiet);
   return handler;
 }
diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h
index 7941d4e..9ff3d4a 100644
--- a/Source/CTest/cmCTestConfigureCommand.h
+++ b/Source/CTest/cmCTestConfigureCommand.h
@@ -28,29 +28,29 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestConfigureCommand* ni = new cmCTestConfigureCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_configure";}
+  virtual std::string GetName() const { return "ctest_configure"; }
 
   cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
 
 protected:
   cmCTestGenericHandler* InitializeHandler();
 
-  enum {
+  enum
+  {
     ctc_FIRST = ct_LAST,
     ctc_OPTIONS,
     ctc_LAST
   };
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index 2e8aeb9..b99455f 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -14,81 +14,71 @@
 
 #include "cmCTest.h"
 #include "cmGeneratedFileStream.h"
-#include "cmake.h"
 #include "cmXMLWriter.h"
+#include "cmake.h"
 #include <cmsys/Process.h>
 
-
-//----------------------------------------------------------------------
 cmCTestConfigureHandler::cmCTestConfigureHandler()
 {
 }
 
-//----------------------------------------------------------------------
 void cmCTestConfigureHandler::Initialize()
 {
   this->Superclass::Initialize();
 }
 
-//----------------------------------------------------------------------
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
 int cmCTestConfigureHandler::ProcessHandler()
 {
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-    "Configure project" << std::endl, this->Quiet);
-  std::string cCommand
-    = this->CTest->GetCTestConfiguration("ConfigureCommand");
-  if (cCommand.empty())
-    {
+                     "Configure project" << std::endl, this->Quiet);
+  std::string cCommand =
+    this->CTest->GetCTestConfiguration("ConfigureCommand");
+  if (cCommand.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
-      << std::endl);
+               "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
+                 << std::endl);
     return -1;
-    }
+  }
 
-  std::string buildDirectory
-    = this->CTest->GetCTestConfiguration("BuildDirectory");
-  if (buildDirectory.empty())
-    {
+  std::string buildDirectory =
+    this->CTest->GetCTestConfiguration("BuildDirectory");
+  if (buildDirectory.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot find BuildDirectory  key in the DartConfiguration.tcl"
-      << std::endl);
+               "Cannot find BuildDirectory  key in the DartConfiguration.tcl"
+                 << std::endl);
     return -1;
-    }
+  }
 
   double elapsed_time_start = cmSystemTools::GetTime();
   std::string output;
   int retVal = 0;
   int res = 0;
-  if ( !this->CTest->GetShowOnly() )
-    {
+  if (!this->CTest->GetShowOnly()) {
     cmGeneratedFileStream os;
-    if(!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os))
-      {
+    if (!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file"
-        << std::endl);
+                   << std::endl);
       return 1;
-      }
+    }
     std::string start_time = this->CTest->CurrentTime();
-    unsigned int start_time_time = static_cast<unsigned int>(
-      cmSystemTools::GetTime());
+    unsigned int start_time_time =
+      static_cast<unsigned int>(cmSystemTools::GetTime());
 
     cmGeneratedFileStream ofs;
     this->StartLogFile("Configure", ofs);
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Configure with command: " << cCommand << std::endl, this->Quiet);
-    res = this->CTest->RunMakeCommand(cCommand.c_str(), output,
-      &retVal, buildDirectory.c_str(),
-      0, ofs);
+                       "Configure with command: " << cCommand << std::endl,
+                       this->Quiet);
+    res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
+                                      buildDirectory.c_str(), 0, ofs);
 
-    if ( ofs )
-      {
+    if (ofs) {
       ofs.close();
-      }
+    }
 
-    if ( os )
-      {
+    if (os) {
       cmXMLWriter xml(os);
       this->CTest->StartXML(xml, this->AppendXML);
       xml.StartElement("Configure");
@@ -100,23 +90,23 @@ int cmCTestConfigureHandler::ProcessHandler()
       xml.Element("ConfigureStatus", retVal);
       xml.Element("EndDateTime", this->CTest->CurrentTime());
       xml.Element("EndConfigureTime",
-        static_cast<unsigned int>(cmSystemTools::GetTime()));
-      xml.Element("ElapsedMinutes", static_cast<int>(
-        (cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+                  static_cast<unsigned int>(cmSystemTools::GetTime()));
+      xml.Element(
+        "ElapsedMinutes",
+        static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+          10.0);
       xml.EndElement(); // Configure
       this->CTest->EndXML(xml);
-      }
     }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this->CTest, DEBUG,
-      "Configure with command: " << cCommand << std::endl, this->Quiet);
-    }
-  if (! res || retVal )
-    {
+                       "Configure with command: " << cCommand << std::endl,
+                       this->Quiet);
+  }
+  if (!res || retVal) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Error(s) when configuring the project" << std::endl);
+               "Error(s) when configuring the project" << std::endl);
     return -1;
-    }
+  }
   return 0;
 }
diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h
index d880bd7..4c1a96b 100644
--- a/Source/CTest/cmCTestConfigureHandler.h
+++ b/Source/CTest/cmCTestConfigureHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestConfigureHandler_h
 #define cmCTestConfigureHandler_h
 
-
 #include "cmCTestGenericHandler.h"
+
 #include "cmListFileCache.h"
 
 /** \class cmCTestConfigureHandler
diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx
index f1f935b..223d010 100644
--- a/Source/CTest/cmCTestCoverageCommand.cxx
+++ b/Source/CTest/cmCTestCoverageCommand.cxx
@@ -14,61 +14,54 @@
 #include "cmCTest.h"
 #include "cmCTestCoverageHandler.h"
 
-//----------------------------------------------------------------------------
 cmCTestCoverageCommand::cmCTestCoverageCommand()
 {
   this->LabelsMentioned = false;
 }
 
-//----------------------------------------------------------------------------
 cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
 {
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
+    this->Quiet);
   cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
     this->CTest->GetInitializedHandler("coverage"));
-  if ( !handler )
-    {
+  if (!handler) {
     this->SetError("internal CTest error. Cannot instantiate test handler");
     return 0;
-    }
+  }
 
   // If a LABELS option was given, select only files with the labels.
-  if(this->LabelsMentioned)
-    {
+  if (this->LabelsMentioned) {
     handler->SetLabelFilter(this->Labels);
-    }
+  }
 
   handler->SetQuiet(this->Quiet);
   return handler;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
 {
   // Look for arguments specific to this command.
-  if(arg == "LABELS")
-    {
+  if (arg == "LABELS") {
     this->ArgumentDoing = ArgumentDoingLabels;
     this->LabelsMentioned = true;
     return true;
-    }
+  }
 
   // Look for other arguments.
   return this->Superclass::CheckArgumentKeyword(arg);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
 {
   // Handle states specific to this command.
-  if(this->ArgumentDoing == ArgumentDoingLabels)
-    {
+  if (this->ArgumentDoing == ArgumentDoingLabels) {
     this->Labels.insert(arg);
     return true;
-    }
+  }
 
   // Look for other arguments.
   return this->Superclass::CheckArgumentValue(arg);
diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h
index 5762e07..f60ffd5 100644
--- a/Source/CTest/cmCTestCoverageCommand.h
+++ b/Source/CTest/cmCTestCoverageCommand.h
@@ -22,24 +22,23 @@
 class cmCTestCoverageCommand : public cmCTestHandlerCommand
 {
 public:
-
   cmCTestCoverageCommand();
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestCoverageCommand* ni = new cmCTestCoverageCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_coverage";}
+  virtual std::string GetName() const { return "ctest_coverage"; }
 
   cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand);
 
@@ -59,6 +58,4 @@ protected:
   std::set<std::string> Labels;
 };
 
-
 #endif
-
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 2c2cd48..daefb59 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -10,118 +10,106 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCTestCoverageHandler.h"
-#include "cmParsePHPCoverage.h"
+
+#include "cmCTest.h"
+#include "cmGeneratedFileStream.h"
+#include "cmMakefile.h"
+#include "cmParseBlanketJSCoverage.h"
+#include "cmParseCacheCoverage.h"
 #include "cmParseCoberturaCoverage.h"
+#include "cmParseDelphiCoverage.h"
 #include "cmParseGTMCoverage.h"
-#include "cmParseCacheCoverage.h"
 #include "cmParseJacocoCoverage.h"
-#include "cmParseDelphiCoverage.h"
-#include "cmParseBlanketJSCoverage.h"
-#include "cmCTest.h"
-#include "cmake.h"
-#include "cmMakefile.h"
+#include "cmParsePHPCoverage.h"
 #include "cmSystemTools.h"
-#include "cmGeneratedFileStream.h"
 #include "cmXMLWriter.h"
+#include "cmake.h"
 
+#include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
 #include <cmsys/Process.h>
 #include <cmsys/RegularExpression.hxx>
-#include <cmsys/Glob.hxx>
-#include <cmsys/FStream.hxx>
 
-#include <stdlib.h>
-#include <math.h>
 #include <float.h>
+#include <math.h>
+#include <stdlib.h>
 
-#define SAFEDIV(x,y) (((y)!=0)?((x)/(y)):(0))
+#define SAFEDIV(x, y) (((y) != 0) ? ((x) / (y)) : (0))
 
 class cmCTestRunProcess
 {
 public:
   cmCTestRunProcess()
-    {
-      this->Process = cmsysProcess_New();
-      this->PipeState = -1;
-      this->TimeOut = -1;
-    }
+  {
+    this->Process = cmsysProcess_New();
+    this->PipeState = -1;
+    this->TimeOut = -1;
+  }
   ~cmCTestRunProcess()
-    {
-      if(!(this->PipeState == -1)
-         && !(this->PipeState == cmsysProcess_Pipe_None )
-         && !(this->PipeState == cmsysProcess_Pipe_Timeout))
-        {
-        this->WaitForExit();
-        }
-      cmsysProcess_Delete(this->Process);
+  {
+    if (!(this->PipeState == -1) &&
+        !(this->PipeState == cmsysProcess_Pipe_None) &&
+        !(this->PipeState == cmsysProcess_Pipe_Timeout)) {
+      this->WaitForExit();
     }
+    cmsysProcess_Delete(this->Process);
+  }
   void SetCommand(const char* command)
-    {
-      this->CommandLineStrings.clear();
-      this->CommandLineStrings.push_back(command);;
-    }
+  {
+    this->CommandLineStrings.clear();
+    this->CommandLineStrings.push_back(command);
+    ;
+  }
   void AddArgument(const char* arg)
-    {
-      if(arg)
-        {
-        this->CommandLineStrings.push_back(arg);
-        }
-    }
-  void SetWorkingDirectory(const char* dir)
-    {
-      this->WorkingDirectory = dir;
-    }
-  void SetTimeout(double t)
-    {
-      this->TimeOut = t;
+  {
+    if (arg) {
+      this->CommandLineStrings.push_back(arg);
     }
+  }
+  void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
+  void SetTimeout(double t) { this->TimeOut = t; }
   bool StartProcess()
-    {
-      std::vector<const char*> args;
-      for(std::vector<std::string>::iterator i =
-            this->CommandLineStrings.begin();
-          i != this->CommandLineStrings.end(); ++i)
-        {
-        args.push_back(i->c_str());
-        }
-      args.push_back(0); // null terminate
-      cmsysProcess_SetCommand(this->Process, &*args.begin());
-      if(!this->WorkingDirectory.empty())
-        {
-        cmsysProcess_SetWorkingDirectory(this->Process,
-                                         this->WorkingDirectory.c_str());
-        }
-
-      cmsysProcess_SetOption(this->Process,
-                             cmsysProcess_Option_HideWindow, 1);
-      if(this->TimeOut != -1)
-        {
-        cmsysProcess_SetTimeout(this->Process, this->TimeOut);
-        }
-      cmsysProcess_Execute(this->Process);
-      this->PipeState = cmsysProcess_GetState(this->Process);
-      // if the process is running or exited return true
-      if(this->PipeState == cmsysProcess_State_Executing
-         || this->PipeState == cmsysProcess_State_Exited)
-        {
-        return true;
-        }
-      return false;
+  {
+    std::vector<const char*> args;
+    for (std::vector<std::string>::iterator i =
+           this->CommandLineStrings.begin();
+         i != this->CommandLineStrings.end(); ++i) {
+      args.push_back(i->c_str());
+    }
+    args.push_back(0); // null terminate
+    cmsysProcess_SetCommand(this->Process, &*args.begin());
+    if (!this->WorkingDirectory.empty()) {
+      cmsysProcess_SetWorkingDirectory(this->Process,
+                                       this->WorkingDirectory.c_str());
+    }
+
+    cmsysProcess_SetOption(this->Process, cmsysProcess_Option_HideWindow, 1);
+    if (this->TimeOut != -1) {
+      cmsysProcess_SetTimeout(this->Process, this->TimeOut);
+    }
+    cmsysProcess_Execute(this->Process);
+    this->PipeState = cmsysProcess_GetState(this->Process);
+    // if the process is running or exited return true
+    if (this->PipeState == cmsysProcess_State_Executing ||
+        this->PipeState == cmsysProcess_State_Exited) {
+      return true;
     }
+    return false;
+  }
   void SetStdoutFile(const char* fname)
-    {
+  {
     cmsysProcess_SetPipeFile(this->Process, cmsysProcess_Pipe_STDOUT, fname);
-    }
+  }
   void SetStderrFile(const char* fname)
-    {
+  {
     cmsysProcess_SetPipeFile(this->Process, cmsysProcess_Pipe_STDERR, fname);
-    }
-  int WaitForExit(double* timeout =0)
-    {
-      this->PipeState = cmsysProcess_WaitForExit(this->Process,
-                                                 timeout);
-      return this->PipeState;
-    }
-  int GetProcessState() { return this->PipeState;}
+  }
+  int WaitForExit(double* timeout = 0)
+  {
+    this->PipeState = cmsysProcess_WaitForExit(this->Process, timeout);
+    return this->PipeState;
+  }
+  int GetProcessState() { return this->PipeState; }
 private:
   int PipeState;
   cmsysProcess* Process;
@@ -130,15 +118,10 @@ private:
   double TimeOut;
 };
 
-
-//----------------------------------------------------------------------
-
-//----------------------------------------------------------------------
 cmCTestCoverageHandler::cmCTestCoverageHandler()
 {
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -150,7 +133,6 @@ void cmCTestCoverageHandler::Initialize()
   this->LabelFilter.clear();
 }
 
-//----------------------------------------------------------------------------
 void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
 {
   std::string logGlob = this->CTest->GetCTestConfiguration("BuildDirectory");
@@ -160,54 +142,50 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
   cmsys::Glob gl;
   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)
-    {
+  for (std::vector<std::string>::const_iterator fi = files.begin();
+       fi != files.end(); ++fi) {
     log << "Removing old coverage log: " << *fi << "\n";
     cmSystemTools::RemoveFile(*fi);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 bool cmCTestCoverageHandler::StartCoverageLogFile(
   cmGeneratedFileStream& covLogFile, int logFileCount)
 {
   char covLogFilename[1024];
   sprintf(covLogFilename, "CoverageLog-%d", logFileCount);
-  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Open file: "
-    << covLogFilename << std::endl, this->Quiet);
-  if(!this->StartResultingXML(cmCTest::PartCoverage,
-                              covLogFilename, covLogFile))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file: "
-      << covLogFilename << std::endl);
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "Open file: " << covLogFilename << std::endl,
+                     this->Quiet);
+  if (!this->StartResultingXML(cmCTest::PartCoverage, covLogFilename,
+                               covLogFile)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+               "Cannot open log file: " << covLogFilename << std::endl);
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::EndCoverageLogFile(cmGeneratedFileStream& ostr,
-  int logFileCount)
+                                                int logFileCount)
 {
   char covLogFilename[1024];
   sprintf(covLogFilename, "CoverageLog-%d.xml", logFileCount);
-  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Close file: "
-    << covLogFilename << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "Close file: " << covLogFilename << std::endl,
+                     this->Quiet);
   ostr.Close();
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::StartCoverageLogXML(cmXMLWriter& xml)
 {
   this->CTest->StartXML(xml, this->AppendXML);
   xml.StartElement("CoverageLog");
   xml.Element("StartDateTime", this->CTest->CurrentTime());
   xml.Element("StartTime",
-    static_cast<unsigned int>(cmSystemTools::GetTime()));
+              static_cast<unsigned int>(cmSystemTools::GetTime()));
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml)
 {
   xml.Element("EndDateTime", this->CTest->CurrentTime());
@@ -216,141 +194,118 @@ void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml)
   this->CTest->EndXML(xml);
 }
 
-//----------------------------------------------------------------------
 bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
-  const char* srcDir,
-  const char* binDir)
+                                               const char* srcDir,
+                                               const char* binDir)
 {
-  if(this->IsFilteredOut(file))
-    {
+  if (this->IsFilteredOut(file)) {
     return false;
-    }
+  }
 
   std::vector<cmsys::RegularExpression>::iterator sit;
-  for ( sit = this->CustomCoverageExcludeRegex.begin();
-    sit != this->CustomCoverageExcludeRegex.end(); ++ sit )
-    {
-    if ( sit->find(file) )
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "  File " << file
-        << " is excluded in CTestCustom.ctest" << std::endl;, this->Quiet);
+  for (sit = this->CustomCoverageExcludeRegex.begin();
+       sit != this->CustomCoverageExcludeRegex.end(); ++sit) {
+    if (sit->find(file)) {
+      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "  File "
+                           << file << " is excluded in CTestCustom.ctest"
+                           << std::endl;
+                         , this->Quiet);
       return false;
-      }
     }
+  }
 
   std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir);
   std::string fBinDir = cmSystemTools::CollapseFullPath(binDir);
   std::string fFile = cmSystemTools::CollapseFullPath(file);
-  bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile,
-    fSrcDir);
-  bool buildSubDir = cmSystemTools::IsSubDirectory(fFile,
-    fBinDir);
+  bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile, fSrcDir);
+  bool buildSubDir = cmSystemTools::IsSubDirectory(fFile, fBinDir);
   // Always check parent directory of the file.
   std::string fileDir = cmSystemTools::GetFilenamePath(fFile);
   std::string checkDir;
 
   // We also need to check the binary/source directory pair.
-  if ( sourceSubDir && buildSubDir )
-    {
-    if ( fSrcDir.size() > fBinDir.size() )
-      {
+  if (sourceSubDir && buildSubDir) {
+    if (fSrcDir.size() > fBinDir.size()) {
       checkDir = fSrcDir;
-      }
-    else
-      {
+    } else {
       checkDir = fBinDir;
-      }
     }
-  else if ( sourceSubDir )
-    {
+  } else if (sourceSubDir) {
     checkDir = fSrcDir;
-    }
-  else if ( buildSubDir )
-    {
+  } else if (buildSubDir) {
     checkDir = fBinDir;
-    }
-  std::string ndc
-    = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage",
-      fFile.c_str(), checkDir.c_str());
-  if (!ndc.empty())
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
-      << " so skip coverage of " << file << std::endl, this->Quiet);
+  }
+  std::string ndc = cmSystemTools::FileExistsInParentDirectories(
+    ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+  if (!ndc.empty()) {
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "Found: " << ndc << " so skip coverage of " << file
+                                 << std::endl,
+                       this->Quiet);
     return false;
-    }
+  }
 
   // By now checkDir should be set to parent directory of the file.
   // Get the relative path to the file an apply it to the opposite directory.
   // If it is the same as fileDir, then ignore, otherwise check.
   std::string relPath;
-  if(!checkDir.empty())
-    {
-    relPath = cmSystemTools::RelativePath(checkDir.c_str(),
-                                          fFile.c_str());
-    }
-  else
-    {
+  if (!checkDir.empty()) {
+    relPath = cmSystemTools::RelativePath(checkDir.c_str(), fFile.c_str());
+  } else {
     relPath = fFile;
-    }
-  if ( checkDir == fSrcDir )
-    {
+  }
+  if (checkDir == fSrcDir) {
     checkDir = fBinDir;
-    }
-  else
-    {
+  } else {
     checkDir = fSrcDir;
-    }
+  }
   fFile = checkDir + "/" + relPath;
   fFile = cmSystemTools::GetFilenamePath(fFile);
 
-  if ( fileDir == fFile )
-    {
+  if (fileDir == fFile) {
     // This is in-source build, so we trust the previous check.
     return true;
-    }
+  }
 
-  ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage",
-    fFile.c_str(), checkDir.c_str());
-  if (!ndc.empty())
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
-      << " so skip coverage of: " << file << std::endl, this->Quiet);
+  ndc = cmSystemTools::FileExistsInParentDirectories(
+    ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+  if (!ndc.empty()) {
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "Found: " << ndc << " so skip coverage of: " << file
+                                 << std::endl,
+                       this->Quiet);
     return false;
-    }
+  }
   // Ok, nothing in source tree, nothing in binary tree
   return true;
 }
 
-//----------------------------------------------------------------------
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
 int cmCTestCoverageHandler::ProcessHandler()
 {
   this->CTest->ClearSubmitFiles(cmCTest::PartCoverage);
   int error = 0;
   // do we have time for this
-  if (this->CTest->GetRemainingTimeAllowed() < 120)
-    {
+  if (this->CTest->GetRemainingTimeAllowed() < 120) {
     return error;
-    }
+  }
 
   std::string coverage_start_time = this->CTest->CurrentTime();
-  unsigned int coverage_start_time_time = static_cast<unsigned int>(
-    cmSystemTools::GetTime());
-  std::string sourceDir
-    = this->CTest->GetCTestConfiguration("SourceDirectory");
-  std::string binaryDir
-    = this->CTest->GetCTestConfiguration("BuildDirectory");
+  unsigned int coverage_start_time_time =
+    static_cast<unsigned int>(cmSystemTools::GetTime());
+  std::string sourceDir =
+    this->CTest->GetCTestConfiguration("SourceDirectory");
+  std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
 
   this->LoadLabels();
 
   cmGeneratedFileStream ofs;
   double elapsed_time_start = cmSystemTools::GetTime();
-  if ( !this->StartLogFile("Coverage", ofs) )
-    {
+  if (!this->StartLogFile("Coverage", ofs)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot create LastCoverage.log file" << std::endl);
-    }
+               "Cannot create LastCoverage.log file" << std::endl);
+  }
 
   ofs << "Performing coverage: " << elapsed_time_start << std::endl;
   this->CleanCoverageLogFiles(ofs);
@@ -359,7 +314,7 @@ int cmCTestCoverageHandler::ProcessHandler()
   cmSystemTools::ConvertToUnixSlashes(binaryDir);
 
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-    "Performing coverage" << std::endl, this->Quiet);
+                     "Performing coverage" << std::endl, this->Quiet);
 
   cmCTestCoverageHandlerContainer cont;
   cont.Error = error;
@@ -371,97 +326,86 @@ int cmCTestCoverageHandler::ProcessHandler()
   // setup the regex exclude stuff
   this->CustomCoverageExcludeRegex.clear();
   std::vector<std::string>::iterator rexIt;
-  for ( rexIt = this->CustomCoverageExclude.begin();
-    rexIt != this->CustomCoverageExclude.end();
-    ++ rexIt )
-    {
+  for (rexIt = this->CustomCoverageExclude.begin();
+       rexIt != this->CustomCoverageExclude.end(); ++rexIt) {
     this->CustomCoverageExcludeRegex.push_back(
       cmsys::RegularExpression(rexIt->c_str()));
-    }
+  }
 
-  if(this->HandleBullseyeCoverage(&cont))
-    {
+  if (this->HandleBullseyeCoverage(&cont)) {
     return cont.Error;
-    }
+  }
   int file_count = 0;
   file_count += this->HandleGCovCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
   file_count += this->HandleLCovCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
   file_count += this->HandleTracePyCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
   file_count += this->HandlePHPCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
   file_count += this->HandleCoberturaCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
 
   file_count += this->HandleMumpsCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
 
   file_count += this->HandleJacocoCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
 
   file_count += this->HandleBlanketJSCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
 
-    file_count += this->HandleDelphiCoverage(&cont);
+  file_count += this->HandleDelphiCoverage(&cont);
   error = cont.Error;
-  if ( file_count < 0 )
-    {
+  if (file_count < 0) {
     return error;
-    }
+  }
   std::set<std::string> uncovered = this->FindUncoveredFiles(&cont);
 
-  if (file_count == 0 && this->ExtraCoverageGlobs.empty())
-    {
-    cmCTestOptionalLog(this->CTest, WARNING,
+  if (file_count == 0 && this->ExtraCoverageGlobs.empty()) {
+    cmCTestOptionalLog(
+      this->CTest, WARNING,
       " Cannot find any coverage files. Ignoring Coverage request."
-      << std::endl, this->Quiet);
+        << std::endl,
+      this->Quiet);
     return error;
-    }
+  }
   cmGeneratedFileStream covSumFile;
   cmGeneratedFileStream covLogFile;
   cmXMLWriter covSumXML(covSumFile);
   cmXMLWriter covLogXML(covLogFile);
 
-  if(!this->StartResultingXML(cmCTest::PartCoverage, "Coverage", covSumFile))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot open coverage summary file." << std::endl);
+  if (!this->StartResultingXML(cmCTest::PartCoverage, "Coverage",
+                               covSumFile)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
+                 << std::endl);
     return -1;
-    }
+  }
   covSumFile.setf(std::ios::fixed, std::ios::floatfield);
   covSumFile.precision(2);
 
@@ -472,19 +416,19 @@ int cmCTestCoverageHandler::ProcessHandler()
   covSumXML.Element("StartDateTime", coverage_start_time);
   covSumXML.Element("StartTime", coverage_start_time_time);
   int logFileCount = 0;
-  if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
-    {
+  if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
     return -1;
-    }
+  }
   this->StartCoverageLogXML(covLogXML);
   cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator fileIterator;
   int cnt = 0;
   long total_tested = 0;
   long total_untested = 0;
-  //std::string fullSourceDir = sourceDir + "/";
-  //std::string fullBinaryDir = binaryDir + "/";
+  // std::string fullSourceDir = sourceDir + "/";
+  // std::string fullBinaryDir = binaryDir + "/";
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+  cmCTestOptionalLog(
+    this->CTest, HANDLER_OUTPUT,
     "   Accumulating results (each . represents one file):" << std::endl,
     this->Quiet);
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "    ", this->Quiet);
@@ -492,77 +436,68 @@ int cmCTestCoverageHandler::ProcessHandler()
   std::vector<std::string> errorsWhileAccumulating;
 
   file_count = 0;
-  for ( fileIterator = cont.TotalCoverage.begin();
-    fileIterator != cont.TotalCoverage.end();
-    ++fileIterator )
-    {
+  for (fileIterator = cont.TotalCoverage.begin();
+       fileIterator != cont.TotalCoverage.end(); ++fileIterator) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
-      this->Quiet);
-    file_count ++;
-    if ( file_count % 50 == 0 )
-      {
+                       this->Quiet);
+    file_count++;
+    if (file_count % 50 == 0) {
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " processed: "
-        << file_count
-        << " out of "
-        << cont.TotalCoverage.size() << std::endl, this->Quiet);
+                           << file_count << " out of "
+                           << cont.TotalCoverage.size() << std::endl,
+                         this->Quiet);
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "    ", this->Quiet);
-      }
+    }
 
     const std::string fullFileName = fileIterator->first;
-    bool shouldIDoCoverage
-      = this->ShouldIDoCoverage(fullFileName.c_str(),
-        sourceDir.c_str(), binaryDir.c_str());
-    if ( !shouldIDoCoverage )
-      {
+    bool shouldIDoCoverage = this->ShouldIDoCoverage(
+      fullFileName.c_str(), sourceDir.c_str(), binaryDir.c_str());
+    if (!shouldIDoCoverage) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        ".NoDartCoverage found, so skip coverage check for: "
-        << fullFileName
-        << std::endl, this->Quiet);
+                         ".NoDartCoverage found, so skip coverage check for: "
+                           << fullFileName << std::endl,
+                         this->Quiet);
       continue;
-      }
+    }
 
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Process file: " << fullFileName << std::endl, this->Quiet);
+                       "Process file: " << fullFileName << std::endl,
+                       this->Quiet);
 
-    if ( !cmSystemTools::FileExists(fullFileName.c_str()) )
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
-        << fullFileName << std::endl);
+    if (!cmSystemTools::FileExists(fullFileName.c_str())) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "Cannot find file: " << fullFileName << std::endl);
       continue;
-      }
+    }
 
-    if ( ++cnt % 100 == 0 )
-      {
+    if (++cnt % 100 == 0) {
       this->EndCoverageLogXML(covLogXML);
       this->EndCoverageLogFile(covLogFile, logFileCount);
-      logFileCount ++;
-      if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
-        {
+      logFileCount++;
+      if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
         return -1;
-        }
-      this->StartCoverageLogXML(covLogXML);
       }
+      this->StartCoverageLogXML(covLogXML);
+    }
 
-    const std::string fileName
-      = cmSystemTools::GetFilenameName(fullFileName);
+    const std::string fileName = cmSystemTools::GetFilenameName(fullFileName);
     std::string shortFileName =
       this->CTest->GetShortPathToFile(fullFileName.c_str());
-    const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov
-      = fileIterator->second;
+    const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov =
+      fileIterator->second;
     covLogXML.StartElement("File");
     covLogXML.Attribute("Name", fileName);
     covLogXML.Attribute("FullPath", shortFileName);
     covLogXML.StartElement("Report");
 
     cmsys::ifstream ifs(fullFileName.c_str());
-    if ( !ifs)
-      {
+    if (!ifs) {
       std::ostringstream ostr;
-      ostr <<  "Cannot open source file: " << fullFileName;
+      ostr << "Cannot open source file: " << fullFileName;
       errorsWhileAccumulating.push_back(ostr.str());
-      error ++;
+      error++;
       continue;
-      }
+    }
 
     int tested = 0;
     int untested = 0;
@@ -570,49 +505,43 @@ int cmCTestCoverageHandler::ProcessHandler()
     cmCTestCoverageHandlerContainer::SingleFileCoverageVector::size_type cc;
     std::string line;
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Actually performing coverage for: " << fullFileName << std::endl,
-      this->Quiet);
-    for ( cc= 0; cc < fcov.size(); cc ++ )
-      {
-      if ( !cmSystemTools::GetLineFromStream(ifs, line) &&
-        cc != fcov.size() -1 )
-        {
+                       "Actually performing coverage for: " << fullFileName
+                                                            << std::endl,
+                       this->Quiet);
+    for (cc = 0; cc < fcov.size(); cc++) {
+      if (!cmSystemTools::GetLineFromStream(ifs, line) &&
+          cc != fcov.size() - 1) {
         std::ostringstream ostr;
         ostr << "Problem reading source file: " << fullFileName
-             << " line:" << cc << "  out total: " << fcov.size()-1;
+             << " line:" << cc << "  out total: " << fcov.size() - 1;
         errorsWhileAccumulating.push_back(ostr.str());
-        error ++;
+        error++;
         break;
-        }
+      }
       covLogXML.StartElement("Line");
       covLogXML.Attribute("Number", cc);
       covLogXML.Attribute("Count", fcov[cc]);
       covLogXML.Content(line);
       covLogXML.EndElement(); // Line
-      if ( fcov[cc] == 0 )
-        {
-        untested ++;
-        }
-      else if ( fcov[cc] > 0 )
-        {
-        tested ++;
-        }
+      if (fcov[cc] == 0) {
+        untested++;
+      } else if (fcov[cc] > 0) {
+        tested++;
       }
-    if ( cmSystemTools::GetLineFromStream(ifs, line) )
-      {
+    }
+    if (cmSystemTools::GetLineFromStream(ifs, line)) {
       std::ostringstream ostr;
-      ostr <<  "Looks like there are more lines in the file: " << fullFileName;
+      ostr << "Looks like there are more lines in the file: " << fullFileName;
       errorsWhileAccumulating.push_back(ostr.str());
-      }
+    }
     float cper = 0;
     float cmet = 0;
-    if ( tested + untested > 0 )
-      {
+    if (tested + untested > 0) {
       cper = (100 * SAFEDIV(static_cast<float>(tested),
-          static_cast<float>(tested + untested)));
-      cmet = ( SAFEDIV(static_cast<float>(tested + 10),
-          static_cast<float>(tested + untested + 10)));
-      }
+                            static_cast<float>(tested + untested)));
+      cmet = (SAFEDIV(static_cast<float>(tested + 10),
+                      static_cast<float>(tested + untested + 10)));
+    }
     total_tested += tested;
     total_untested += untested;
     covLogXML.EndElement(); // Report
@@ -620,7 +549,7 @@ int cmCTestCoverageHandler::ProcessHandler()
     covSumXML.StartElement("File");
     covSumXML.Attribute("Name", fileName);
     covSumXML.Attribute("FullPath",
-      this->CTest->GetShortPathToFile(fullFileName.c_str()));
+                        this->CTest->GetShortPathToFile(fullFileName.c_str()));
     covSumXML.Attribute("Covered", tested + untested > 0 ? "true" : "false");
     covSumXML.Element("LOCTested", tested);
     covSumXML.Element("LOCUnTested", untested);
@@ -628,12 +557,11 @@ int cmCTestCoverageHandler::ProcessHandler()
     covSumXML.Element("CoverageMetric", cmet);
     this->WriteXMLLabels(covSumXML, shortFileName);
     covSumXML.EndElement(); // File
-    }
+  }
 
-  //Handle all the files in the extra coverage globs that have no cov data
-  for(std::set<std::string>::iterator i = uncovered.begin();
-      i != uncovered.end(); ++i)
-    {
+  // Handle all the files in the extra coverage globs that have no cov data
+  for (std::set<std::string>::iterator i = uncovered.begin();
+       i != uncovered.end(); ++i) {
     std::string fileName = cmSystemTools::GetFilenameName(*i);
     std::string fullPath = cont.SourceDir + "/" + *i;
 
@@ -643,27 +571,26 @@ int cmCTestCoverageHandler::ProcessHandler()
     covLogXML.StartElement("Report");
 
     cmsys::ifstream ifs(fullPath.c_str());
-    if (!ifs)
-      {
+    if (!ifs) {
       std::ostringstream ostr;
-      ostr <<  "Cannot open source file: " << fullPath;
+      ostr << "Cannot open source file: " << fullPath;
       errorsWhileAccumulating.push_back(ostr.str());
-      error ++;
+      error++;
       continue;
-      }
+    }
     int untested = 0;
     std::string line;
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Actually performing coverage for: " << *i << std::endl, this->Quiet);
-    while (cmSystemTools::GetLineFromStream(ifs, line))
-      {
+                       "Actually performing coverage for: " << *i << std::endl,
+                       this->Quiet);
+    while (cmSystemTools::GetLineFromStream(ifs, line)) {
       covLogXML.StartElement("Line");
       covLogXML.Attribute("Number", untested);
       covLogXML.Attribute("Count", 0);
       covLogXML.Content(line);
       covLogXML.EndElement(); // Line
-      untested ++;
-      }
+      untested++;
+    }
     covLogXML.EndElement(); // Report
     covLogXML.EndElement(); // File
 
@@ -678,33 +605,28 @@ int cmCTestCoverageHandler::ProcessHandler()
     covSumXML.Element("CoverageMetric", 0);
     this->WriteXMLLabels(covSumXML, *i);
     covSumXML.EndElement(); // File
-    }
+  }
 
   this->EndCoverageLogXML(covLogXML);
   this->EndCoverageLogFile(covLogFile, logFileCount);
 
-  if (!errorsWhileAccumulating.empty())
-    {
+  if (!errorsWhileAccumulating.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl);
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Error(s) while accumulating results:" << std::endl);
+               "Error(s) while accumulating results:" << std::endl);
     std::vector<std::string>::iterator erIt;
-    for ( erIt = errorsWhileAccumulating.begin();
-      erIt != errorsWhileAccumulating.end();
-      ++ erIt )
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "  " << *erIt << std::endl);
-      }
+    for (erIt = errorsWhileAccumulating.begin();
+         erIt != errorsWhileAccumulating.end(); ++erIt) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "  " << *erIt << std::endl);
     }
+  }
 
   long total_lines = total_tested + total_untested;
-  float percent_coverage = 100 * SAFEDIV(static_cast<float>(total_tested),
-    static_cast<float>(total_lines));
-  if ( total_lines == 0 )
-    {
+  float percent_coverage = 100 *
+    SAFEDIV(static_cast<float>(total_tested), static_cast<float>(total_lines));
+  if (total_lines == 0) {
     percent_coverage = 0;
-    }
+  }
 
   std::string end_time = this->CTest->CurrentTime();
 
@@ -714,64 +636,59 @@ int cmCTestCoverageHandler::ProcessHandler()
   covSumXML.Element("PercentCoverage", percent_coverage);
   covSumXML.Element("EndDateTime", end_time);
   covSumXML.Element("EndTime",
-    static_cast<unsigned int>(cmSystemTools::GetTime()));
-  covSumXML.Element("ElapsedMinutes",
-    static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+                    static_cast<unsigned int>(cmSystemTools::GetTime()));
+  covSumXML.Element(
+    "ElapsedMinutes",
+    static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+      10.0);
   covSumXML.EndElement(); // Coverage
   this->CTest->EndXML(covSumXML);
 
-  cmCTestLog(this->CTest, HANDLER_OUTPUT, "" << std::endl
-    << "\tCovered LOC:         "
-    << total_tested << std::endl
-    << "\tNot covered LOC:     " << total_untested << std::endl
-    << "\tTotal LOC:           " << total_lines << std::endl
-    << "\tPercentage Coverage: "
-    << std::setiosflags(std::ios::fixed)
-    << std::setprecision(2)
-    << (percent_coverage) << "%" << std::endl);
+  cmCTestLog(this->CTest, HANDLER_OUTPUT, ""
+               << std::endl
+               << "\tCovered LOC:         " << total_tested << std::endl
+               << "\tNot covered LOC:     " << total_untested << std::endl
+               << "\tTotal LOC:           " << total_lines << std::endl
+               << "\tPercentage Coverage: "
+               << std::setiosflags(std::ios::fixed) << std::setprecision(2)
+               << (percent_coverage) << "%" << std::endl);
 
   ofs << "\tCovered LOC:         " << total_tested << std::endl
-    << "\tNot covered LOC:     " << total_untested << std::endl
-    << "\tTotal LOC:           " << total_lines << std::endl
-    << "\tPercentage Coverage: "
-    << std::setiosflags(std::ios::fixed)
-    << std::setprecision(2)
-    << (percent_coverage) << "%" << std::endl;
+      << "\tNot covered LOC:     " << total_untested << std::endl
+      << "\tTotal LOC:           " << total_lines << std::endl
+      << "\tPercentage Coverage: " << std::setiosflags(std::ios::fixed)
+      << std::setprecision(2) << (percent_coverage) << "%" << std::endl;
 
-
-  if ( error )
-    {
+  if (error) {
     return -1;
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------
-void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile* mf)
 {
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    " Add coverage exclude regular expressions." << std::endl, this->Quiet);
+                     " Add coverage exclude regular expressions." << std::endl,
+                     this->Quiet);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE",
-                                this->CustomCoverageExclude);
+                                    this->CustomCoverageExclude);
   this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB",
-                                this->ExtraCoverageGlobs);
+                                    this->ExtraCoverageGlobs);
   std::vector<std::string>::iterator it;
-  for ( it = this->CustomCoverageExclude.begin();
-    it != this->CustomCoverageExclude.end();
-    ++ it )
-    {
+  for (it = this->CustomCoverageExclude.begin();
+       it != this->CustomCoverageExclude.end(); ++it) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Add coverage exclude: " << *it << std::endl, this->Quiet);
-    }
-  for ( it = this->ExtraCoverageGlobs.begin();
-    it != this->ExtraCoverageGlobs.end(); ++it)
-    {
+                       " Add coverage exclude: " << *it << std::endl,
+                       this->Quiet);
+  }
+  for (it = this->ExtraCoverageGlobs.begin();
+       it != this->ExtraCoverageGlobs.end(); ++it) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Add coverage glob: " << *it << std::endl, this->Quiet);
-    }
+                       " Add coverage glob: " << *it << std::endl,
+                       this->Quiet);
+  }
 }
 
-//----------------------------------------------------------------------
 // Fix for issue #4971 where the case of the drive letter component of
 // the filenames might be different when analyzing gcov output.
 //
@@ -783,38 +700,31 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
 #define fnc(s) s
 #endif
 
-//----------------------------------------------------------------------
-bool IsFileInDir(const std::string &infile, const std::string &indir)
+bool IsFileInDir(const std::string& infile, const std::string& indir)
 {
   std::string file = cmSystemTools::CollapseFullPath(infile);
   std::string dir = cmSystemTools::CollapseFullPath(indir);
 
-  if (
-    file.size() > dir.size() &&
-    (fnc(file.substr(0, dir.size())) == fnc(dir)) &&
-    file[dir.size()] == '/'
-    )
-    {
+  if (file.size() > dir.size() &&
+      (fnc(file.substr(0, dir.size())) == fnc(dir)) &&
+      file[dir.size()] == '/') {
     return true;
-    }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandlePHPCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
   cmParsePHPCoverage cov(*cont, this->CTest);
   std::string coverageDir = this->CTest->GetBinaryDir() + "/xdebugCoverage";
-  if(cmSystemTools::FileIsDirectory(coverageDir))
-    {
+  if (cmSystemTools::FileIsDirectory(coverageDir)) {
     cov.ReadPHPCoverageDirectory(coverageDir.c_str());
-    }
+  }
   return static_cast<int>(cont->TotalCoverage.size());
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleCoberturaCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
@@ -826,117 +736,100 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
   // binary directory is used.
   std::string coverageXMLFile;
   const char* covDir = cmSystemTools::GetEnv("COBERTURADIR");
-  if(covDir && strlen(covDir) != 0)
-    {
-      coverageXMLFile = std::string(covDir);
-    }
-  else
-    {
-      coverageXMLFile = this->CTest->GetBinaryDir();
-    }
+  if (covDir && strlen(covDir) != 0) {
+    coverageXMLFile = std::string(covDir);
+  } else {
+    coverageXMLFile = this->CTest->GetBinaryDir();
+  }
   // build the find file string with the directory from above
   coverageXMLFile += "/coverage.xml";
 
-  if(cmSystemTools::FileExists(coverageXMLFile.c_str()))
-    {
+  if (cmSystemTools::FileExists(coverageXMLFile.c_str())) {
     // If file exists, parse it
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Parsing Cobertura XML file: " << coverageXMLFile
-               << std::endl, this->Quiet);
+                       "Parsing Cobertura XML file: " << coverageXMLFile
+                                                      << std::endl,
+                       this->Quiet);
     cov.ReadCoverageXML(coverageXMLFile.c_str());
-    }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               " Cannot find Cobertura XML file: " << coverageXMLFile
-               << std::endl, this->Quiet);
-    }
+                       " Cannot find Cobertura XML file: " << coverageXMLFile
+                                                           << std::endl,
+                       this->Quiet);
+  }
   return static_cast<int>(cont->TotalCoverage.size());
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleMumpsCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
   // try gtm coverage
   cmParseGTMCoverage cov(*cont, this->CTest);
-  std::string coverageFile = this->CTest->GetBinaryDir() +
-    "/gtm_coverage.mcov";
-  if(cmSystemTools::FileExists(coverageFile.c_str()))
-    {
+  std::string coverageFile =
+    this->CTest->GetBinaryDir() + "/gtm_coverage.mcov";
+  if (cmSystemTools::FileExists(coverageFile.c_str())) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Parsing Cache Coverage: " << coverageFile
-               << std::endl, this->Quiet);
+                       "Parsing Cache Coverage: " << coverageFile << std::endl,
+                       this->Quiet);
     cov.ReadCoverageFile(coverageFile.c_str());
     return static_cast<int>(cont->TotalCoverage.size());
-    }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               " Cannot find GTM coverage file: " << coverageFile
-               << std::endl, this->Quiet);
-    }
+                       " Cannot find GTM coverage file: " << coverageFile
+                                                          << std::endl,
+                       this->Quiet);
+  }
   cmParseCacheCoverage ccov(*cont, this->CTest);
-  coverageFile = this->CTest->GetBinaryDir() +
-    "/cache_coverage.cmcov";
-  if(cmSystemTools::FileExists(coverageFile.c_str()))
-    {
+  coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
+  if (cmSystemTools::FileExists(coverageFile.c_str())) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Parsing Cache Coverage: " << coverageFile
-               << std::endl, this->Quiet);
+                       "Parsing Cache Coverage: " << coverageFile << std::endl,
+                       this->Quiet);
     ccov.ReadCoverageFile(coverageFile.c_str());
-    }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               " Cannot find Cache coverage file: " << coverageFile
-               << std::endl, this->Quiet);
-    }
+                       " Cannot find Cache coverage file: " << coverageFile
+                                                            << std::endl,
+                       this->Quiet);
+  }
   return static_cast<int>(cont->TotalCoverage.size());
 }
 
 struct cmCTestCoverageHandlerLocale
 {
   cmCTestCoverageHandlerLocale()
-    {
-    if(const char* l = cmSystemTools::GetEnv("LC_ALL"))
-      {
+  {
+    if (const char* l = cmSystemTools::GetEnv("LC_ALL")) {
       lc_all = l;
-      }
-    if(lc_all != "C")
-      {
+    }
+    if (lc_all != "C") {
       cmSystemTools::PutEnv("LC_ALL=C");
-      }
     }
+  }
   ~cmCTestCoverageHandlerLocale()
-    {
-    if(!lc_all.empty())
-      {
+  {
+    if (!lc_all.empty()) {
       cmSystemTools::PutEnv("LC_ALL=" + lc_all);
-      }
-    else
-      {
+    } else {
       cmSystemTools::UnsetEnv("LC_ALL");
-      }
     }
+  }
   std::string lc_all;
 };
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleJacocoCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
-  cmParseJacocoCoverage cov =
-   cmParseJacocoCoverage(*cont, this->CTest);
+  cmParseJacocoCoverage cov = cmParseJacocoCoverage(*cont, this->CTest);
 
   // Search in the source directory.
   cmsys::Glob g1;
   std::vector<std::string> files;
   g1.SetRecurse(true);
 
-  std::string SourceDir
-    = this->CTest->GetCTestConfiguration("SourceDirectory");
-  std::string coverageFile = SourceDir+ "/*jacoco.xml";
+  std::string SourceDir =
+    this->CTest->GetCTestConfiguration("SourceDirectory");
+  std::string coverageFile = SourceDir + "/*jacoco.xml";
 
   g1.FindFiles(coverageFile);
   files = g1.GetFiles();
@@ -945,134 +838,132 @@ int cmCTestCoverageHandler::HandleJacocoCoverage(
   cmsys::Glob g2;
   std::vector<std::string> binFiles;
   g2.SetRecurse(true);
-  std::string binaryDir
-    = this->CTest->GetCTestConfiguration("BuildDirectory");
-  std::string binCoverageFile = binaryDir+ "/*jacoco.xml";
+  std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
+  std::string binCoverageFile = binaryDir + "/*jacoco.xml";
   g2.FindFiles(binCoverageFile);
   binFiles = g2.GetFiles();
-  if (!binFiles.empty())
-    {
+  if (!binFiles.empty()) {
     files.insert(files.end(), binFiles.begin(), binFiles.end());
-    }
+  }
 
-  if (!files.empty())
-    {
+  if (!files.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Found Jacoco Files, Performing Coverage" << std::endl, this->Quiet);
+                       "Found Jacoco Files, Performing Coverage" << std::endl,
+                       this->Quiet);
     cov.LoadCoverageData(files);
-    }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Cannot find Jacoco coverage files: " << coverageFile
-      << std::endl, this->Quiet);
-    }
+                       " Cannot find Jacoco coverage files: " << coverageFile
+                                                              << std::endl,
+                       this->Quiet);
+  }
   return static_cast<int>(cont->TotalCoverage.size());
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleDelphiCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
-  cmParseDelphiCoverage cov =
-   cmParseDelphiCoverage(*cont, this->CTest);
+  cmParseDelphiCoverage cov = cmParseDelphiCoverage(*cont, this->CTest);
   cmsys::Glob g;
   std::vector<std::string> files;
   g.SetRecurse(true);
 
-
-  std::string BinDir
-    = this->CTest->GetBinaryDir();
-  std::string coverageFile = BinDir+ "/*.html";
-
+  std::string BinDir = this->CTest->GetBinaryDir();
+  std::string coverageFile = BinDir + "/*(*.pas).html";
 
   g.FindFiles(coverageFile);
-  files=g.GetFiles();
-  if (!files.empty())
-    {
+  files = g.GetFiles();
+  if (!files.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Found Delphi HTML Files, Performing Coverage" << std::endl,
-      this->Quiet);
+                       "Found Delphi HTML Files, Performing Coverage"
+                         << std::endl,
+                       this->Quiet);
     cov.LoadCoverageData(files);
-    }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Cannot find Delphi coverage files: " << coverageFile
-      << std::endl, this->Quiet);
-    }
+                       " Cannot find Delphi coverage files: " << coverageFile
+                                                              << std::endl,
+                       this->Quiet);
+  }
   return static_cast<int>(cont->TotalCoverage.size());
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleBlanketJSCoverage(
   cmCTestCoverageHandlerContainer* cont)
-  {
-  cmParseBlanketJSCoverage cov =
-   cmParseBlanketJSCoverage(*cont, this->CTest);
-  std::string SourceDir
-    = this->CTest->GetCTestConfiguration("SourceDirectory");
+{
+  cmParseBlanketJSCoverage cov = cmParseBlanketJSCoverage(*cont, this->CTest);
+  std::string SourceDir =
+    this->CTest->GetCTestConfiguration("SourceDirectory");
 
-  //Look for something other than output.json, still JSON extension.
-  std::string coverageFile = SourceDir+ "/*.json";
+  // Look for something other than output.json, still JSON extension.
+  std::string coverageFile = SourceDir + "/*.json";
   cmsys::Glob g;
   std::vector<std::string> files;
+  std::vector<std::string> blanketFiles;
   g.FindFiles(coverageFile);
-  files=g.GetFiles();
-  if (!files.empty())
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Found BlanketJS output JSON, Performing Coverage" << std::endl,
-      this->Quiet);
-    cov.LoadCoverageData(files);
+  files = g.GetFiles();
+  // Ensure that the JSON files found are the result of the
+  // Blanket.js output. Check for the "node-jscoverage"
+  // string on the second line
+  std::string line;
+  for (unsigned int fileEntry = 0; fileEntry < files.size(); fileEntry++) {
+    cmsys::ifstream in(files[fileEntry].c_str());
+    cmSystemTools::GetLineFromStream(in, line);
+    cmSystemTools::GetLineFromStream(in, line);
+    if (line.find("node-jscoverage") != line.npos) {
+      blanketFiles.push_back(files[fileEntry]);
     }
-  else
-    {
+  }
+  //  Take all files with the node-jscoverage string and parse those
+  if (!blanketFiles.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-       " Cannot find BlanketJS coverage files: " << coverageFile
-       << std::endl, this->Quiet);
-    }
-  return static_cast<int>(cont->TotalCoverage.size());
+                       "Found BlanketJS output JSON, Performing Coverage"
+                         << std::endl,
+                       this->Quiet);
+    cov.LoadCoverageData(files);
+  } else {
+    cmCTestOptionalLog(
+      this->CTest, HANDLER_VERBOSE_OUTPUT,
+      " Cannot find BlanketJS coverage files: " << coverageFile << std::endl,
+      this->Quiet);
   }
-//----------------------------------------------------------------------
+  return static_cast<int>(cont->TotalCoverage.size());
+}
 int cmCTestCoverageHandler::HandleGCovCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
-  std::string gcovCommand
-    = this->CTest->GetCTestConfiguration("CoverageCommand");
-  if (gcovCommand.empty())
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Could not find gcov." << std::endl);
+  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");
+  }
+  std::string gcovExtraFlags =
+    this->CTest->GetCTestConfiguration("CoverageExtraFlags");
 
   // Immediately skip to next coverage option since codecov is only for Intel
   // compiler
-  if ( gcovCommand == "codecov" )
-    {
+  if (gcovCommand == "codecov") {
     return 0;
-    }
+  }
 
   // Style 1
-  std::string st1gcovOutputRex1
-    = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
+  std::string st1gcovOutputRex1 =
+    "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
   std::string st1gcovOutputRex2 = "^Creating (.*\\.gcov)\\.";
   cmsys::RegularExpression st1re1(st1gcovOutputRex1.c_str());
   cmsys::RegularExpression st1re2(st1gcovOutputRex2.c_str());
 
-
   // Style 2
   std::string st2gcovOutputRex1 = "^File *[`'](.*)'$";
-  std::string st2gcovOutputRex2
-    = "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$";
+  std::string st2gcovOutputRex2 =
+    "Lines executed: *[0-9]+\\.[0-9]+% of [0-9]+$";
   std::string st2gcovOutputRex3 = "^(.*)reating [`'](.*\\.gcov)'";
   std::string st2gcovOutputRex4 = "^(.*):unexpected EOF *$";
   std::string st2gcovOutputRex5 = "^(.*):cannot open source file*$";
-  std::string st2gcovOutputRex6
-    = "^(.*):source file is newer than graph file `(.*)'$";
+  std::string st2gcovOutputRex6 =
+    "^(.*):source file is newer than graph file `(.*)'$";
   cmsys::RegularExpression st2re1(st2gcovOutputRex1.c_str());
   cmsys::RegularExpression st2re2(st2gcovOutputRex2.c_str());
   cmsys::RegularExpression st2re3(st2gcovOutputRex3.c_str());
@@ -1084,14 +975,13 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
   this->FindGCovFiles(files);
   std::vector<std::string>::iterator it;
 
-  if (files.empty())
-    {
+  if (files.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Cannot find any GCov coverage files."
-      << std::endl, this->Quiet);
+                       " Cannot find any GCov coverage files." << std::endl,
+                       this->Quiet);
     // No coverage files is a valid thing, so the exit code is 0
     return 0;
-    }
+  }
 
   std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
   std::string tempDir = testingDir + "/CoverageInfo";
@@ -1104,7 +994,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
   std::set<std::string> missingFiles;
 
   std::string actualSourceFile = "";
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+  cmCTestOptionalLog(
+    this->CTest, HANDLER_OUTPUT,
     "   Processing coverage (each . represents one file):" << std::endl,
     this->Quiet);
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "    ", this->Quiet);
@@ -1118,259 +1009,216 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
   // These are binary files that you give as input to gcov so that it will
   // give us text output we can analyze to summarize coverage.
   //
-  for ( it = files.begin(); it != files.end(); ++ it )
-    {
+  for (it = files.begin(); it != files.end(); ++it) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
-      this->Quiet);
+                       this->Quiet);
 
     // Call gcov to get coverage data for this *.gcda file:
     //
     std::string fileDir = cmSystemTools::GetFilenamePath(*it);
-    std::string command = "\"" + gcovCommand + "\" " +
-      gcovExtraFlags + " " +
-      "-o \"" + fileDir + "\" " +
-      "\"" + *it + "\"";
+    std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " +
+      "-o \"" + fileDir + "\" " + "\"" + *it + "\"";
 
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str()
-      << std::endl, this->Quiet);
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       command.c_str() << std::endl, this->Quiet);
 
     std::string output = "";
     std::string errors = "";
     int retVal = 0;
     *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*/);
+    int res =
+      this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal,
+                              tempDir.c_str(), 0 /*this->TimeOut*/);
 
     *cont->OFS << "  Output: " << output << std::endl;
     *cont->OFS << "  Errors: " << errors << std::endl;
-    if ( ! res )
-      {
+    if (!res) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Problem running coverage on file: " << *it << std::endl);
+                 "Problem running coverage on file: " << *it << std::endl);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Command produced error: " << errors << std::endl);
-      cont->Error ++;
+                 "Command produced error: " << errors << std::endl);
+      cont->Error++;
       continue;
-      }
-    if ( retVal != 0 )
-      {
+    }
+    if (retVal != 0) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
-        << retVal << " while processing: " << *it << std::endl);
+                   << retVal << " while processing: " << *it << std::endl);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Command produced error: " << cont->Error << std::endl);
-      }
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                 "Command produced error: " << cont->Error << std::endl);
+    }
+    cmCTestOptionalLog(
+      this->CTest, HANDLER_VERBOSE_OUTPUT,
       "--------------------------------------------------------------"
-      << std::endl
-      << output << std::endl
-      << "--------------------------------------------------------------"
-      << std::endl, this->Quiet);
+        << std::endl
+        << output << std::endl
+        << "--------------------------------------------------------------"
+        << std::endl,
+      this->Quiet);
 
     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)
-      {
+    for (line = lines.begin(); line != lines.end(); ++line) {
       std::string sourceFile;
       std::string gcovFile;
 
-      cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << *line << "]"
-        << std::endl, this->Quiet);
+      cmCTestOptionalLog(this->CTest, DEBUG,
+                         "Line: [" << *line << "]" << std::endl, this->Quiet);
 
-      if (line->empty())
-        {
+      if (line->empty()) {
         // Ignore empty line; probably style 2
-        }
-      else if ( st1re1.find(line->c_str()) )
-        {
-        if ( gcovStyle == 0 )
-          {
+      } else if (st1re1.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 1;
-          }
-        if ( gcovStyle != 1 )
-          {
+        }
+        if (gcovStyle != 1) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e1"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
+        }
 
         actualSourceFile = "";
         sourceFile = st1re1.match(2);
-        }
-      else if ( st1re2.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+      } else if (st1re2.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 1;
-          }
-        if ( gcovStyle != 1 )
-          {
+        }
+        if (gcovStyle != 1) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e2"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
+        }
 
         gcovFile = st1re2.match(1);
-        }
-      else if ( st2re1.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+      } else if (st2re1.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 2;
-          }
-        if ( gcovStyle != 2 )
-          {
+        }
+        if (gcovStyle != 2) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e3"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
+        }
 
         actualSourceFile = "";
         sourceFile = st2re1.match(1);
-        }
-      else if ( st2re2.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+      } else if (st2re2.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 2;
-          }
-        if ( gcovStyle != 2 )
-          {
+        }
+        if (gcovStyle != 2) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e4"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
         }
-      else if ( st2re3.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+      } else if (st2re3.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 2;
-          }
-        if ( gcovStyle != 2 )
-          {
+        }
+        if (gcovStyle != 2) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e5"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
+        }
 
         gcovFile = st2re3.match(2);
-        }
-      else if ( st2re4.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+      } else if (st2re4.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 2;
-          }
-        if ( gcovStyle != 2 )
-          {
+        }
+        if (gcovStyle != 2) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e6"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
-
-        cmCTestOptionalLog(this->CTest, WARNING, "Warning: " << st2re4.match(1)
-          << " had unexpected EOF" << std::endl, this->Quiet);
         }
-      else if ( st2re5.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+
+        cmCTestOptionalLog(this->CTest, WARNING,
+                           "Warning: " << st2re4.match(1)
+                                       << " had unexpected EOF" << std::endl,
+                           this->Quiet);
+      } else if (st2re5.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 2;
-          }
-        if ( gcovStyle != 2 )
-          {
+        }
+        if (gcovStyle != 2) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e7"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
+        }
 
         cmCTestOptionalLog(this->CTest, WARNING, "Warning: Cannot open file: "
-          << st2re5.match(1) << std::endl, this->Quiet);
-        }
-      else if ( st2re6.find(line->c_str() ) )
-        {
-        if ( gcovStyle == 0 )
-          {
+                             << st2re5.match(1) << std::endl,
+                           this->Quiet);
+      } else if (st2re6.find(line->c_str())) {
+        if (gcovStyle == 0) {
           gcovStyle = 2;
-          }
-        if ( gcovStyle != 2 )
-          {
+        }
+        if (gcovStyle != 2) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e8"
-            << std::endl);
-          cont->Error ++;
+                       << std::endl);
+          cont->Error++;
           break;
-          }
+        }
 
         cmCTestOptionalLog(this->CTest, WARNING, "Warning: File: "
-          << st2re6.match(1)
-          << " is newer than " << st2re6.match(2) << std::endl, this->Quiet);
-        }
-      else
-        {
+                             << st2re6.match(1) << " is newer than "
+                             << st2re6.match(2) << std::endl,
+                           this->Quiet);
+      } else {
         // gcov 4.7 can have output lines saying "No executable lines" and
         // "Removing 'filename.gcov'"... Don't log those as "errors."
-        if(*line != "No executable lines" &&
-           !cmSystemTools::StringStartsWith(line->c_str(), "Removing "))
-          {
-          cmCTestLog(this->CTest, ERROR_MESSAGE,
-            "Unknown gcov output line: [" << *line << "]"
-            << std::endl);
-          cont->Error ++;
-          //abort();
-          }
+        if (*line != "No executable lines" &&
+            !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) {
+          cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output line: ["
+                       << *line << "]" << std::endl);
+          cont->Error++;
+          // abort();
         }
-
+      }
 
       // If the last line of gcov output gave us a valid value for gcovFile,
       // and we have an actualSourceFile, then insert a (or add to existing)
       // SingleFileCoverageVector for actualSourceFile:
       //
-      if ( !gcovFile.empty() && !actualSourceFile.empty() )
-        {
-        cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec
-          = cont->TotalCoverage[actualSourceFile];
+      if (!gcovFile.empty() && !actualSourceFile.empty()) {
+        cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec =
+          cont->TotalCoverage[actualSourceFile];
 
         cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-          "   in gcovFile: " << gcovFile << std::endl, this->Quiet);
+                           "   in gcovFile: " << gcovFile << std::endl,
+                           this->Quiet);
 
         cmsys::ifstream ifile(gcovFile.c_str());
-        if ( ! ifile )
-          {
-          cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
-            << gcovFile << std::endl);
-          }
-        else
-          {
+        if (!ifile) {
+          cmCTestLog(this->CTest, ERROR_MESSAGE,
+                     "Cannot open file: " << gcovFile << std::endl);
+        } else {
           long cnt = -1;
           std::string nl;
-          while ( cmSystemTools::GetLineFromStream(ifile, nl) )
-            {
-            cnt ++;
+          while (cmSystemTools::GetLineFromStream(ifile, nl)) {
+            cnt++;
 
-            //TODO: Handle gcov 3.0 non-coverage lines
+            // TODO: Handle gcov 3.0 non-coverage lines
 
             // Skip empty lines
-            if (nl.empty())
-              {
+            if (nl.empty()) {
               continue;
-              }
+            }
 
             // Skip unused lines
-            if ( nl.size() < 12 )
-              {
+            if (nl.size() < 12) {
               continue;
-              }
+            }
 
             // Read the coverage count from the beginning of the gcov output
             // line
@@ -1381,153 +1229,140 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
             // output line
             std::string lineNumber = nl.substr(10, 5);
 
-            int lineIdx = atoi(lineNumber.c_str())-1;
-            if ( lineIdx >= 0 )
-              {
-              while ( vec.size() <= static_cast<size_t>(lineIdx) )
-                {
+            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 )
-                  {
+              if (vec[lineIdx] < 0) {
+                if (cov > 0 || prefix.find('#') != prefix.npos) {
                   vec[lineIdx] = 0;
-                  }
                 }
+              }
 
               vec[lineIdx] += cov;
-              }
             }
           }
-
-        actualSourceFile = "";
         }
 
+        actualSourceFile = "";
+      }
 
-      if ( !sourceFile.empty() && actualSourceFile.empty() )
-        {
+      if (!sourceFile.empty() && actualSourceFile.empty()) {
         gcovFile = "";
 
         // Is it in the source dir or the binary dir?
         //
-        if ( IsFileInDir(sourceFile, cont->SourceDir) )
-          {
+        if (IsFileInDir(sourceFile, cont->SourceDir)) {
           cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-            "   produced s: " << sourceFile << std::endl, this->Quiet);
+                             "   produced s: " << sourceFile << std::endl,
+                             this->Quiet);
           *cont->OFS << "  produced in source dir: " << sourceFile
-            << std::endl;
-          actualSourceFile
-            = cmSystemTools::CollapseFullPath(sourceFile);
-          }
-        else if ( IsFileInDir(sourceFile, cont->BinaryDir) )
-          {
+                     << std::endl;
+          actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile);
+        } else if (IsFileInDir(sourceFile, cont->BinaryDir)) {
           cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-            "   produced b: " << sourceFile << std::endl, this->Quiet);
+                             "   produced b: " << sourceFile << std::endl,
+                             this->Quiet);
           *cont->OFS << "  produced in binary dir: " << sourceFile
-            << std::endl;
-          actualSourceFile
-            = cmSystemTools::CollapseFullPath(sourceFile);
-          }
+                     << std::endl;
+          actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile);
+        }
 
-        if ( actualSourceFile.empty() )
-          {
-          if ( missingFiles.find(sourceFile) == missingFiles.end() )
-            {
+        if (actualSourceFile.empty()) {
+          if (missingFiles.find(sourceFile) == missingFiles.end()) {
             cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-              "Something went wrong" << std::endl, this->Quiet);
+                               "Something went wrong" << std::endl,
+                               this->Quiet);
             cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-              "Cannot find file: ["
-              << sourceFile << "]" << std::endl, this->Quiet);
+                               "Cannot find file: [" << sourceFile << "]"
+                                                     << std::endl,
+                               this->Quiet);
             cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-              " in source dir: ["
-              << cont->SourceDir << "]"
-              << std::endl, this->Quiet);
+                               " in source dir: [" << cont->SourceDir << "]"
+                                                   << std::endl,
+                               this->Quiet);
             cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-              " or binary dir: ["
-              << cont->BinaryDir.size() << "]"
-              << std::endl, this->Quiet);
+                               " or binary dir: [" << cont->BinaryDir.size()
+                                                   << "]" << std::endl,
+                               this->Quiet);
             *cont->OFS << "  Something went wrong. Cannot find file: "
-              << sourceFile
-              << " in source dir: " << cont->SourceDir
-              << " or binary dir: " << cont->BinaryDir << std::endl;
+                       << sourceFile << " in source dir: " << cont->SourceDir
+                       << " or binary dir: " << cont->BinaryDir << std::endl;
 
             missingFiles.insert(sourceFile);
-            }
           }
         }
       }
+    }
 
     file_count++;
 
-    if ( file_count % 50 == 0 )
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " processed: "
-        << file_count
-        << " out of " << files.size() << std::endl, this->Quiet);
+    if (file_count % 50 == 0) {
+      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                         " processed: " << file_count << " out of "
+                                        << files.size() << std::endl,
+                         this->Quiet);
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "    ", this->Quiet);
-      }
     }
+  }
 
   cmSystemTools::ChangeDirectory(currentDirectory);
   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" )
-    {
+  std::string lcovCommand =
+    this->CTest->GetCTestConfiguration("CoverageCommand");
+  std::string lcovExtraFlags =
+    this->CTest->GetCTestConfiguration("CoverageExtraFlags");
+  if (lcovCommand != "codecov") {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               " Not a valid Intel Coverage command."
-               << std::endl, this->Quiet);
+                       " Not a valid Intel Coverage command." << std::endl,
+                       this->Quiet);
     return 0;
-    }
+  }
   // There is only percentage completed output from LCOV
   std::string st2lcovOutputRex3 = "[0-9]+%";
   cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str());
 
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    " This is coverage command: " << lcovCommand
-    << std::endl, this->Quiet);
+                     " This is coverage command: " << lcovCommand << std::endl,
+                     this->Quiet);
 
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    " These are coverage command flags: " << lcovExtraFlags
-    << std::endl, this->Quiet);
+                     " These are coverage command flags: " << lcovExtraFlags
+                                                           << std::endl,
+                     this->Quiet);
 
   std::vector<std::string> files;
-  if (!this->FindLCovFiles(files))
-    {
+  if (!this->FindLCovFiles(files)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Error while finding LCov files.\n");
     return 0;
-    }
+  }
   std::vector<std::string>::iterator it;
 
-  if (files.empty())
-    {
+  if (files.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Cannot find any LCov coverage files."
-      << std::endl, this->Quiet);
+                       " Cannot find any LCov coverage files." << std::endl,
+                       this->Quiet);
     // 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 = "";
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+  cmCTestOptionalLog(
+    this->CTest, HANDLER_OUTPUT,
     "   Processing coverage (each . represents one file):" << std::endl,
     this->Quiet);
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "    ", this->Quiet);
@@ -1539,67 +1374,65 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
 
   // 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 )
-    {
+  for (it = files.begin(); it != files.end(); ++it) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
-      this->Quiet);
+                       this->Quiet);
     std::string fileDir = cmSystemTools::GetFilenamePath(*it);
     cmSystemTools::ChangeDirectory(fileDir);
-    std::string command = "\"" + lcovCommand + "\" " +
-      lcovExtraFlags + " ";
+    std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
 
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Current coverage dir: " << fileDir << std::endl, this->Quiet);
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str()
-      << std::endl, this->Quiet);
+                       "Current coverage dir: " << fileDir << std::endl,
+                       this->Quiet);
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       command.c_str() << std::endl, this->Quiet);
 
     std::string output = "";
     std::string errors = "";
     int retVal = 0;
     *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, fileDir.c_str(), 0 /*this->TimeOut*/);
+    int res =
+      this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal,
+                              fileDir.c_str(), 0 /*this->TimeOut*/);
 
     *cont->OFS << "  Output: " << output << std::endl;
     *cont->OFS << "  Errors: " << errors << std::endl;
-    if ( ! res )
-      {
+    if (!res) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Problem running coverage on file: " << *it << std::endl);
+                 "Problem running coverage on file: " << *it << std::endl);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Command produced error: " << errors << std::endl);
-      cont->Error ++;
+                 "Command produced error: " << errors << std::endl);
+      cont->Error++;
       continue;
-      }
-    if ( retVal != 0 )
-      {
+    }
+    if (retVal != 0) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
-        << retVal << " while processing: " << *it << std::endl);
+                   << retVal << " while processing: " << *it << std::endl);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Command produced error: " << cont->Error << std::endl);
-      }
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                 "Command produced error: " << cont->Error << std::endl);
+    }
+    cmCTestOptionalLog(
+      this->CTest, HANDLER_VERBOSE_OUTPUT,
       "--------------------------------------------------------------"
-      << std::endl
-      << output << std::endl
-      << "--------------------------------------------------------------"
-      << std::endl, this->Quiet);
+        << std::endl
+        << output << std::endl
+        << "--------------------------------------------------------------"
+        << std::endl,
+      this->Quiet);
 
     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)
-      {
+    for (line = lines.begin(); line != lines.end(); ++line) {
       std::string sourceFile;
       std::string lcovFile;
 
-      if (line->empty())
-        {
+      if (line->empty()) {
         // 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
@@ -1612,89 +1445,84 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
       std::string daGlob;
       daGlob = dir;
       daGlob += "/*.LCOV";
-      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+      cmCTestOptionalLog(
+        this->CTest, HANDLER_VERBOSE_OUTPUT,
         "   looking for LCOV files in: " << daGlob << std::endl, this->Quiet);
       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)
-        {
+      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);
-          }
+        if (!srcead) {
+          cmCTestLog(this->CTest, ERROR_MESSAGE,
+                     "Cannot open file: " << lcovFile << std::endl);
+        }
         std::string srcname;
 
         int success = cmSystemTools::GetLineFromStream(srcead, srcname);
-        if ( !success )
-          {
+        if (!success) {
           cmCTestLog(this->CTest, ERROR_MESSAGE,
-                     "Error while parsing lcov file '" << lcovFile << "':"
-                     << " No source file name found!" << std::endl);
+                     "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)
-          {
+        for (std::vector<std::string>::iterator t = lcovFiles.begin();
+             t != lcovFiles.end(); ++t) {
           cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-            "Found LCOV File: " << *t << std::endl, this->Quiet);
-          }
-        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: "
-          << sourceFile << std::endl, this->Quiet);
-        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: "
-        << lcovFile << std::endl, this->Quiet);
+                             "Found LCOV File: " << *t << std::endl,
+                             this->Quiet);
+        }
+        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                           "SourceFile: " << sourceFile << std::endl,
+                           this->Quiet);
+        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                           "lCovFile: " << lcovFile << std::endl, this->Quiet);
 
         // If we have some LCOV files to process
-        if ( !lcovFile.empty() && !actualSourceFile.empty() )
-          {
-          cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec
-            = cont->TotalCoverage[actualSourceFile];
+        if (!lcovFile.empty() && !actualSourceFile.empty()) {
+          cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec =
+            cont->TotalCoverage[actualSourceFile];
 
           cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-            "   in lcovFile: " << lcovFile << std::endl, this->Quiet);
+                             "   in lcovFile: " << lcovFile << std::endl,
+                             this->Quiet);
 
           cmsys::ifstream ifile(lcovFile.c_str());
-          if ( ! ifile )
-            {
-            cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
-                       << lcovFile << std::endl);
-            }
-          else
-            {
+          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);
             cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-              "File is ready, start reading." << std::endl, this->Quiet);
-            while ( cmSystemTools::GetLineFromStream(ifile, nl) )
-              {
-              cnt ++;
+                               "File is ready, start reading." << std::endl,
+                               this->Quiet);
+            while (cmSystemTools::GetLineFromStream(ifile, nl)) {
+              cnt++;
 
               // Skip empty lines
-              if (nl.empty())
-                {
+              if (nl.empty()) {
                 continue;
-                }
+              }
 
               // Skip unused lines
-              if ( nl.size() < 12 )
-                {
+              if (nl.size() < 12) {
                 continue;
-                }
+              }
 
               // Read the coverage count from the beginning of the lcov
               // output line
@@ -1705,68 +1533,62 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
               // 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) )
-                  {
+              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 )
-                    {
+                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 )
-      {
+    if (file_count % 50 == 0) {
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        " processed: " << file_count << " out of " << files.size()
-        << std::endl, this->Quiet);
+                         " processed: " << file_count << " out of "
+                                        << files.size() << std::endl,
+                         this->Quiet);
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "    ", this->Quiet);
-      }
     }
+  }
 
   cmSystemTools::ChangeDirectory(currentDirectory);
   return file_count;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
 {
   cmsys::Glob gl;
   gl.RecurseOn();
   gl.RecurseThroughSymlinksOff();
 
-  for(LabelMapType::const_iterator lmi = this->TargetDirs.begin();
-      lmi != this->TargetDirs.end(); ++lmi)
-    {
+  for (LabelMapType::const_iterator lmi = this->TargetDirs.begin();
+       lmi != this->TargetDirs.end(); ++lmi) {
     // Skip targets containing no interesting labels.
-    if(!this->IntersectsFilter(lmi->second))
-      {
+    if (!this->IntersectsFilter(lmi->second)) {
       continue;
-      }
+    }
 
     // Coverage files appear next to their object files in the target
     // support directory.
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+    cmCTestOptionalLog(
+      this->CTest, HANDLER_VERBOSE_OUTPUT,
       "   globbing for coverage in: " << lmi->first << std::endl, this->Quiet);
     std::string daGlob = lmi->first;
     daGlob += "/*.da";
@@ -1776,10 +1598,9 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
     daGlob += "/*.gcda";
     gl.FindFiles(daGlob);
     files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
 {
   cmsys::Glob gl;
@@ -1788,42 +1609,38 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
   gl.RecurseThroughSymlinksOff();
   std::string prevBinaryDir;
   std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory");
-  if (cmSystemTools::ChangeDirectory(buildDir))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Error changing directory to " << buildDir << std::endl);
+  if (cmSystemTools::ChangeDirectory(buildDir)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error changing directory to "
+                 << buildDir << std::endl);
     return false;
-    }
+  }
 
   // Run profmerge to merge all *.dyn files into dpi files
-  if (!cmSystemTools::RunSingleCommand("profmerge"))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Error while running profmerge.\n");
+  if (!cmSystemTools::RunSingleCommand("profmerge")) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error while running profmerge.\n");
     return false;
-    }
+  }
 
-  prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str();
+  prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory();
 
   // DPI file should appear in build directory
   std::string daGlob;
   daGlob = prevBinaryDir;
   daGlob += "/*.dpi";
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "   looking for dpi files in: " << daGlob << std::endl, this->Quiet);
-  if (!gl.FindFiles(daGlob))
-    {
+                     "   looking for dpi files in: " << daGlob << std::endl,
+                     this->Quiet);
+  if (!gl.FindFiles(daGlob)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Error while finding files matching " << daGlob << std::endl);
     return false;
-    }
+  }
   files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "Now searching in: " << daGlob << std::endl, this->Quiet);
+                     "Now searching in: " << daGlob << std::endl, this->Quiet);
   return true;
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleTracePyCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
@@ -1834,14 +1651,14 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
   gl.FindFiles(daGlob);
   std::vector<std::string> files = gl.GetFiles();
 
-  if (files.empty())
-    {
+  if (files.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " Cannot find any Python Trace.py coverage files."
-      << std::endl, this->Quiet);
+                       " Cannot find any Python Trace.py coverage files."
+                         << std::endl,
+                       this->Quiet);
     // No coverage files is a valid thing, so the exit code is 0
     return 0;
-    }
+  }
 
   std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
   std::string tempDir = testingDir + "/CoverageInfo";
@@ -1853,322 +1670,276 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
 
   std::vector<std::string>::iterator fileIt;
   int file_count = 0;
-  for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
-    {
+  for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     std::string fileName = this->FindFile(cont, *fileIt);
-    if ( fileName.empty() )
-      {
+    if (fileName.empty()) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Cannot find source Python file corresponding to: "
-        << *fileIt << std::endl);
+                 "Cannot find source Python file corresponding to: "
+                   << *fileIt << std::endl);
       continue;
-      }
+    }
 
-    std::string actualSourceFile
-      = cmSystemTools::CollapseFullPath(fileName);
+    std::string actualSourceFile = cmSystemTools::CollapseFullPath(fileName);
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "   Check coverage for file: " << actualSourceFile
-      << std::endl, this->Quiet);
-    cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec
-      = &cont->TotalCoverage[actualSourceFile];
+                       "   Check coverage for file: " << actualSourceFile
+                                                      << std::endl,
+                       this->Quiet);
+    cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec =
+      &cont->TotalCoverage[actualSourceFile];
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "   in file: " << *fileIt << std::endl, this->Quiet);
+                       "   in file: " << *fileIt << std::endl, this->Quiet);
     cmsys::ifstream ifile(fileIt->c_str());
-    if ( ! ifile )
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
-        << *fileIt << std::endl);
-      }
-    else
-      {
+    if (!ifile) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "Cannot open file: " << *fileIt << std::endl);
+    } else {
       long cnt = -1;
       std::string nl;
-      while ( cmSystemTools::GetLineFromStream(ifile, nl) )
-        {
-        cnt ++;
+      while (cmSystemTools::GetLineFromStream(ifile, nl)) {
+        cnt++;
 
         // Skip empty lines
-        if (nl.empty())
-          {
+        if (nl.empty()) {
           continue;
-          }
+        }
 
         // Skip unused lines
-        if ( nl.size() < 12 )
-          {
+        if (nl.size() < 12) {
           continue;
-          }
+        }
 
         // Read the coverage count from the beginning of the Trace.py output
         // line
         std::string prefix = nl.substr(0, 6);
-        if ( prefix[5] != ' ' && prefix[5] != ':' )
-          {
+        if (prefix[5] != ' ' && prefix[5] != ':') {
           // This is a hack. We should really do something more elaborate
           prefix = nl.substr(0, 7);
-          if ( prefix[6] != ' ' && prefix[6] != ':' )
-            {
+          if (prefix[6] != ' ' && prefix[6] != ':') {
             prefix = nl.substr(0, 8);
-            if ( prefix[7] != ' ' && prefix[7] != ':' )
-              {
+            if (prefix[7] != ' ' && prefix[7] != ':') {
               cmCTestLog(this->CTest, ERROR_MESSAGE,
-                "Currently the limit is maximum coverage of 999999"
-                << std::endl);
-              }
+                         "Currently the limit is maximum coverage of 999999"
+                           << std::endl);
             }
           }
+        }
         int cov = atoi(prefix.c_str());
-        if ( prefix[prefix.size()-1] != ':' )
-          {
+        if (prefix[prefix.size() - 1] != ':') {
           // This line does not have ':' so no coverage here. That said,
           // Trace.py does not handle not covered lines versus comments etc.
           // So, this will be set to 0.
           cov = 0;
-          }
-        cmCTestOptionalLog(this->CTest, DEBUG, "Prefix: " << prefix
-          << " cov: " << cov
-          << std::endl, this->Quiet);
+        }
+        cmCTestOptionalLog(
+          this->CTest, DEBUG,
+          "Prefix: " << prefix << " cov: " << cov << std::endl, this->Quiet);
         // Read the line number starting at the 10th character of the gcov
         // output line
         long lineIdx = cnt;
-        if ( lineIdx >= 0 )
-          {
-          while ( vec->size() <=
-            static_cast<size_t>(lineIdx) )
-            {
+        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 )
-              {
+          if ((*vec)[lineIdx] < 0) {
+            if (cov >= 0) {
               (*vec)[lineIdx] = 0;
-              }
             }
-          (*vec)[lineIdx] += cov;
           }
+          (*vec)[lineIdx] += cov;
         }
       }
-    ++ file_count;
     }
+    ++file_count;
+  }
   cmSystemTools::ChangeDirectory(currentDirectory);
   return file_count;
 }
 
-//----------------------------------------------------------------------
 std::string cmCTestCoverageHandler::FindFile(
-  cmCTestCoverageHandlerContainer* cont,
-  std::string fileName)
+  cmCTestCoverageHandlerContainer* cont, std::string const& fileName)
 {
-  std::string fileNameNoE
-    = cmSystemTools::GetFilenameWithoutLastExtension(fileName);
+  std::string fileNameNoE =
+    cmSystemTools::GetFilenameWithoutLastExtension(fileName);
   // First check in source and binary directory
   std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py";
-  if ( cmSystemTools::FileExists(fullName.c_str()) )
-    {
+  if (cmSystemTools::FileExists(fullName.c_str())) {
     return fullName;
-    }
+  }
   fullName = cont->BinaryDir + "/" + fileNameNoE + ".py";
-  if ( cmSystemTools::FileExists(fullName.c_str()) )
-    {
+  if (cmSystemTools::FileExists(fullName.c_str())) {
     return fullName;
-    }
+  }
   return "";
 }
 
 // This is a header put on each marked up source file
-namespace
-{
-  const char* bullseyeHelp[] =
-  {"    Coverage produced by bullseye covbr tool: ",
-   "      www.bullseye.com/help/ref_covbr.html",
-   "    * An arrow --> indicates incomplete coverage.",
-   "    * An X indicates a function that was invoked, a switch label that ",
-   "      was exercised, a try-block that finished, or an exception handler ",
-   "      that was invoked.",
-   "    * A T or F indicates a boolean decision that evaluated true or false,",
-   "      respectively.",
-   "    * A t or f indicates a boolean condition within a decision if the ",
-   "      condition evaluated true or false, respectively.",
-   "    * A k indicates a constant decision or condition.",
-   "    * The slash / means this probe is excluded from summary results. ",
-   0};
+namespace {
+const char* bullseyeHelp[] = {
+  "    Coverage produced by bullseye covbr tool: ",
+  "      www.bullseye.com/help/ref_covbr.html",
+  "    * An arrow --> indicates incomplete coverage.",
+  "    * An X indicates a function that was invoked, a switch label that ",
+  "      was exercised, a try-block that finished, or an exception handler ",
+  "      that was invoked.",
+  "    * A T or F indicates a boolean decision that evaluated true or false,",
+  "      respectively.",
+  "    * A t or f indicates a boolean condition within a decision if the ",
+  "      condition evaluated true or false, respectively.",
+  "    * A k indicates a constant decision or condition.",
+  "    * The slash / means this probe is excluded from summary results. ",
+  0
+};
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
   cmCTestCoverageHandlerContainer* cont,
-  std::set<std::string>& coveredFileNames,
-  std::vector<std::string>& files,
+  std::set<std::string>& coveredFileNames, std::vector<std::string>& files,
   std::vector<std::string>& filesFullPath)
 {
-  if(files.size() != filesFullPath.size())
-    {
+  if (files.size() != filesFullPath.size()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Files and full path files not the same size?:\n");
     return 0;
-    }
+  }
   // create the output stream for the CoverageLog-N.xml file
   cmGeneratedFileStream covLogFile;
   cmXMLWriter covLogXML(covLogFile);
   int logFileCount = 0;
-  if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
-    {
+  if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
     return -1;
-    }
+  }
   this->StartCoverageLogXML(covLogXML);
   // for each file run covbr on that file to get the coverage
   // information for that file
   std::string outputFile;
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "run covbr: " << std::endl, this->Quiet);
+                     "run covbr: " << std::endl, this->Quiet);
 
-  if(!this->RunBullseyeCommand(cont, "covbr", 0, outputFile))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for." << "\n");
+  if (!this->RunBullseyeCommand(cont, "covbr", 0, outputFile)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for."
+                 << "\n");
     return -1;
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "covbr output in  " << outputFile << std::endl, this->Quiet);
+                     "covbr output in  " << outputFile << std::endl,
+                     this->Quiet);
   // open the output file
   cmsys::ifstream fin(outputFile.c_str());
-  if(!fin)
-    {
+  if (!fin) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Cannot open coverage file: " <<
-               outputFile << std::endl);
+               "Cannot open coverage file: " << outputFile << std::endl);
     return 0;
-    }
+  }
   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)
-    {
+  for (std::vector<std::string>::iterator f = files.begin(); f != files.end();
+       ++f, ++fp) {
     fileMap[*f] = *fp;
-    }
+  }
 
-  int count =0; // keep count of the number of files
+  int count = 0; // keep count of the number of files
   // Now parse each line from the bullseye cov log file
   std::string lineIn;
   bool valid = false; // are we in a valid output file
-  int line = 0; // line of the current file
+  int line = 0;       // line of the current file
   std::string file;
-  while(cmSystemTools::GetLineFromStream(fin, lineIn))
-    {
+  while (cmSystemTools::GetLineFromStream(fin, lineIn)) {
     bool startFile = false;
-    if(lineIn.size() > 1 && lineIn[lineIn.size()-1] == ':')
-      {
-      file = lineIn.substr(0, lineIn.size()-1);
-      if(coveredFileNames.find(file) != coveredFileNames.end())
-        {
+    if (lineIn.size() > 1 && lineIn[lineIn.size() - 1] == ':') {
+      file = lineIn.substr(0, lineIn.size() - 1);
+      if (coveredFileNames.find(file) != coveredFileNames.end()) {
         startFile = true;
-        }
       }
-    if(startFile)
-      {
+    }
+    if (startFile) {
       // if we are in a valid file close it because a new one started
-      if(valid)
-        {
+      if (valid) {
         covLogXML.EndElement(); // Report
         covLogXML.EndElement(); // File
-        }
+      }
       // only allow 100 files in each log file
-      if ( count != 0 && count % 100 == 0 )
-        {
+      if (count != 0 && count % 100 == 0) {
         cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-          "start a new log file: " << count << std::endl, this->Quiet);
+                           "start a new log file: " << count << std::endl,
+                           this->Quiet);
         this->EndCoverageLogXML(covLogXML);
         this->EndCoverageLogFile(covLogFile, logFileCount);
-        logFileCount ++;
-        if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
-          {
+        logFileCount++;
+        if (!this->StartCoverageLogFile(covLogFile, logFileCount)) {
           return -1;
-          }
+        }
         this->StartCoverageLogXML(covLogXML);
         count++; // move on one
-        }
-      std::map<std::string, std::string>::iterator
-        i = fileMap.find(file);
+      }
+      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())
-        {
+      if (i != fileMap.end()) {
         // we have a new file so count it in the output
         count++;
         cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-          "Produce coverage for file: " << file << " " << count
-          << std::endl, this->Quiet);
+                           "Produce coverage for file: " << file << " "
+                                                         << count << std::endl,
+                           this->Quiet);
         // start the file output
         covLogXML.StartElement("File");
         covLogXML.Attribute("Name", i->first);
-        covLogXML.Attribute("FullPath",
-          this->CTest->GetShortPathToFile(i->second.c_str()));
+        covLogXML.Attribute(
+          "FullPath", this->CTest->GetShortPathToFile(i->second.c_str()));
         covLogXML.StartElement("Report");
         // write the bullseye header
-        line =0;
-        for(int k =0; bullseyeHelp[k] != 0; ++k)
-          {
+        line = 0;
+        for (int k = 0; bullseyeHelp[k] != 0; ++k) {
           covLogXML.StartElement("Line");
           covLogXML.Attribute("Number", line);
           covLogXML.Attribute("Count", -1);
           covLogXML.Content(bullseyeHelp[k]);
           covLogXML.EndElement(); // Line
           line++;
-          }
-        valid = true; // we are in a valid file section
         }
-      else
-        {
+        valid = true; // we are in a valid file section
+      } else {
         // this is not a file that we want coverage for
         valid = false;
-        }
       }
+    }
     // we are not at a start file, and we are in a valid file output the line
-    else if(valid)
-      {
+    else if (valid) {
       covLogXML.StartElement("Line");
       covLogXML.Attribute("Number", line);
       covLogXML.Attribute("Count", -1);
       covLogXML.Content(lineIn);
       covLogXML.EndElement(); // Line
       line++;
-      }
     }
+  }
   // if we ran out of lines a valid file then close that file
-  if(valid)
-    {
+  if (valid) {
     covLogXML.EndElement(); // Report
     covLogXML.EndElement(); // File
-    }
+  }
   this->EndCoverageLogXML(covLogXML);
   this->EndCoverageLogFile(covLogFile, logFileCount);
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::RunBullseyeCommand(
-  cmCTestCoverageHandlerContainer* cont,
-  const char* cmd,
-  const char* arg,
+  cmCTestCoverageHandlerContainer* cont, const char* cmd, const char* arg,
   std::string& outputFile)
 {
   std::string program = cmSystemTools::FindProgram(cmd);
-  if(program.empty())
-    {
+  if (program.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find :" << cmd << "\n");
     return 0;
-    }
-  if(arg)
-    {
+  }
+  if (arg) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Run : " << program << " " << arg << "\n", this->Quiet);
-    }
-  else
-    {
+                       "Run : " << program << " " << arg << "\n", this->Quiet);
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Run : " << program << "\n", this->Quiet);
-    }
+                       "Run : " << program << "\n", this->Quiet);
+  }
   // create a process object and start it
   cmCTestRunProcess runCoverageSrc;
   runCoverageSrc.SetCommand(program.c_str());
@@ -2182,49 +1953,46 @@ int cmCTestCoverageHandler::RunBullseyeCommand(
   stderrFile += ".stderr";
   runCoverageSrc.SetStdoutFile(stdoutFile.c_str());
   runCoverageSrc.SetStderrFile(stderrFile.c_str());
-  if(!runCoverageSrc.StartProcess())
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : "
-               << program << " " << arg << "\n"
-               << "kwsys process state : "
-               << runCoverageSrc.GetProcessState());
+  if (!runCoverageSrc.StartProcess()) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+               "Could not run : " << program << " " << arg << "\n"
+                                  << "kwsys process state : "
+                                  << runCoverageSrc.GetProcessState());
     return 0;
-    }
+  }
   // since we set the output file names wait for it to end
   runCoverageSrc.WaitForExit();
   outputFile = stdoutFile;
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::RunBullseyeSourceSummary(
   cmCTestCoverageHandlerContainer* cont)
 {
   // Run the covsrc command and create a temp outputfile
   std::string outputFile;
-  if(!this->RunBullseyeCommand(cont, "covsrc", "-c", outputFile))
-    {
+  if (!this->RunBullseyeCommand(cont, "covsrc", "-c", outputFile)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covsrc:\n");
     return 0;
-    }
+  }
 
   std::ostream& tmpLog = *cont->OFS;
   // copen the Coverage.xml file in the Testing directory
   cmGeneratedFileStream covSumFile;
   cmXMLWriter xml(covSumFile);
-  if(!this->StartResultingXML(cmCTest::PartCoverage, "Coverage", covSumFile))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot open coverage summary file." << std::endl);
+  if (!this->StartResultingXML(cmCTest::PartCoverage, "Coverage",
+                               covSumFile)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
+                 << std::endl);
     return 0;
-    }
+  }
   this->CTest->StartXML(xml, this->AppendXML);
   double elapsed_time_start = cmSystemTools::GetTime();
   std::string coverage_start_time = this->CTest->CurrentTime();
   xml.StartElement("Coverage");
   xml.Element("StartDateTime", coverage_start_time);
   xml.Element("StartTime",
-    static_cast<unsigned int>(cmSystemTools::GetTime()));
+              static_cast<unsigned int>(cmSystemTools::GetTime()));
   std::string stdline;
   std::string errline;
   // expected output:
@@ -2241,66 +2009,53 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
   double total_tested = 0;
   double total_untested = 0;
   double total_functions = 0;
-  double percent_coverage =0;
-  double number_files  = 0;
+  double percent_coverage = 0;
+  double number_files = 0;
   std::vector<std::string> coveredFiles;
   std::vector<std::string> coveredFilesFullPath;
   // Read and parse the summary output file
   cmsys::ifstream fin(outputFile.c_str());
-  if(!fin)
-    {
+  if (!fin) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Cannot open coverage summary file: " <<
-               outputFile << std::endl);
+               "Cannot open coverage summary file: " << outputFile
+                                                     << std::endl);
     return 0;
-    }
+  }
   std::set<std::string> coveredFileNames;
-  while(cmSystemTools::GetLineFromStream(fin, stdline))
-    {
+  while (cmSystemTools::GetLineFromStream(fin, stdline)) {
     // if we have a line of output from stdout
-    if(!stdline.empty())
-      {
+    if (!stdline.empty()) {
       // parse the comma separated output
-      this->ParseBullsEyeCovsrcLine(stdline,
-                                    sourceFile,
-                                    functionsCalled,
-                                    totalFunctions,
-                                    percentFunction,
-                                    branchCovered,
-                                    totalBranches,
-                                    percentBranch);
+      this->ParseBullsEyeCovsrcLine(
+        stdline, sourceFile, functionsCalled, totalFunctions, percentFunction,
+        branchCovered, totalBranches, percentBranch);
       // The first line is the header
-      if(sourceFile == "Source" || sourceFile == "Total")
-        {
+      if (sourceFile == "Source" || sourceFile == "Total") {
         continue;
-        }
+      }
       std::string file = sourceFile;
       coveredFileNames.insert(file);
-      if(!cmSystemTools::FileIsFullPath(sourceFile.c_str()))
-        {
+      if (!cmSystemTools::FileIsFullPath(sourceFile.c_str())) {
         // file will be relative to the binary dir
         file = cont->BinaryDir;
         file += "/";
         file += sourceFile;
-        }
+      }
       file = cmSystemTools::CollapseFullPath(file);
-      bool shouldIDoCoverage
-        = this->ShouldIDoCoverage(file.c_str(),
-                                  cont->SourceDir.c_str(),
-                                  cont->BinaryDir.c_str());
-      if ( !shouldIDoCoverage )
-        {
-        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-          ".NoDartCoverage found, so skip coverage check for: "
-          << file
-          << std::endl, this->Quiet);
+      bool shouldIDoCoverage = this->ShouldIDoCoverage(
+        file.c_str(), cont->SourceDir.c_str(), cont->BinaryDir.c_str());
+      if (!shouldIDoCoverage) {
+        cmCTestOptionalLog(
+          this->CTest, HANDLER_VERBOSE_OUTPUT,
+          ".NoDartCoverage found, so skip coverage check for: " << file
+                                                                << std::endl,
+          this->Quiet);
         continue;
-        }
+      }
 
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "Doing coverage for: "
-        << file
-        << std::endl, this->Quiet);
+                         "Doing coverage for: " << file << std::endl,
+                         this->Quiet);
 
       coveredFiles.push_back(sourceFile);
       coveredFilesFullPath.push_back(file);
@@ -2315,21 +2070,19 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
         this->CTest->GetShortPathToFile(file.c_str());
 
       float cper = static_cast<float>(percentBranch + percentFunction);
-      if(totalBranches > 0)
-        {
+      if (totalBranches > 0) {
         cper /= 2.0f;
-        }
+      }
       percent_coverage += static_cast<double>(cper);
       float cmet = static_cast<float>(percentFunction + percentBranch);
-      if(totalBranches > 0)
-        {
+      if (totalBranches > 0) {
         cmet /= 2.0f;
-        }
+      }
       cmet /= 100.0f;
       tmpLog << stdline << "\n";
       tmpLog << fileName << "\n";
-      tmpLog << "functionsCalled: " << functionsCalled/100 << "\n";
-      tmpLog << "totalFunctions: " << totalFunctions/100 << "\n";
+      tmpLog << "functionsCalled: " << functionsCalled / 100 << "\n";
+      tmpLog << "totalFunctions: " << totalFunctions / 100 << "\n";
       tmpLog << "percentFunction: " << percentFunction << "\n";
       tmpLog << "branchCovered: " << branchCovered << "\n";
       tmpLog << "totalBranches: " << totalBranches << "\n";
@@ -2352,8 +2105,8 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
       xml.Element("CoverageMetric", cmet);
       this->WriteXMLLabels(xml, shortFileName);
       xml.EndElement(); // File
-      }
     }
+  }
   std::string end_time = this->CTest->CurrentTime();
   xml.Element("LOCTested", total_tested);
   xml.Element("LOCUntested", total_untested);
@@ -2361,42 +2114,40 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
   xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files));
   xml.Element("EndDateTime", end_time);
   xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
-  xml.Element("ElapsedMinutes",
-    static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+  xml.Element(
+    "ElapsedMinutes",
+    static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+      10.0);
   xml.EndElement(); // Coverage
   this->CTest->EndXML(xml);
 
   // Now create the coverage information for each file
-  return this->RunBullseyeCoverageBranch(cont,
-                                         coveredFileNames,
-                                         coveredFiles,
+  return this->RunBullseyeCoverageBranch(cont, coveredFileNames, coveredFiles,
                                          coveredFilesFullPath);
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleBullseyeCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
   const char* covfile = cmSystemTools::GetEnv("COVFILE");
-  if(!covfile || strlen(covfile) == 0)
-    {
+  if (!covfile || strlen(covfile) == 0) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      " COVFILE environment variable not found, not running "
-      " bullseye\n", this->Quiet);
+                       " COVFILE environment variable not found, not running "
+                       " bullseye\n",
+                       this->Quiet);
     return 0;
-    }
-  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    " run covsrc with COVFILE=["
-    << covfile
-    << "]" << std::endl, this->Quiet);
-  if(!this->RunBullseyeSourceSummary(cont))
-    {
+  }
+  cmCTestOptionalLog(
+    this->CTest, HANDLER_VERBOSE_OUTPUT,
+    " run covsrc with COVFILE=[" << covfile << "]" << std::endl, this->Quiet);
+  if (!this->RunBullseyeSourceSummary(cont)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Error running bullseye summary.\n");
     return 0;
-    }
-  cmCTestOptionalLog(this->CTest, DEBUG, "HandleBullseyeCoverage return 1 "
-  << std::endl, this->Quiet);
+  }
+  cmCTestOptionalLog(this->CTest, DEBUG,
+                     "HandleBullseyeCoverage return 1 " << std::endl,
+                     this->Quiet);
   return 1;
 }
 
@@ -2407,141 +2158,112 @@ bool cmCTestCoverageHandler::GetNextInt(std::string const& inputLine,
   std::string::size_type start = pos;
   pos = inputLine.find(',', start);
   value = atoi(inputLine.substr(start, pos).c_str());
-  if(pos == inputLine.npos)
-    {
+  if (pos == inputLine.npos) {
     return true;
-    }
+  }
   pos++;
   return true;
 }
 
 bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
-  std::string const& inputLine,
-  std::string& sourceFile,
-  int& functionsCalled,
-  int& totalFunctions,
-  int& percentFunction,
-  int& branchCovered,
-  int& totalBranches,
-  int& percentBranch)
+  std::string const& inputLine, std::string& sourceFile, int& functionsCalled,
+  int& totalFunctions, int& percentFunction, int& branchCovered,
+  int& totalBranches, int& percentBranch)
 {
   // find the first comma
   std::string::size_type pos = inputLine.find(',');
-  if(pos == inputLine.npos)
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : "
-               << inputLine << "\n");
+  if (pos == inputLine.npos) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+               "Error parsing string : " << inputLine << "\n");
     return false;
-    }
+  }
   // the source file has "" around it so extract out the file name
-  sourceFile = inputLine.substr(1,pos-2);
+  sourceFile = inputLine.substr(1, pos - 2);
   pos++;
-  if(!this->GetNextInt(inputLine, pos, functionsCalled))
-    {
+  if (!this->GetNextInt(inputLine, pos, functionsCalled)) {
     return false;
-    }
-  if(!this->GetNextInt(inputLine, pos, totalFunctions))
-    {
+  }
+  if (!this->GetNextInt(inputLine, pos, totalFunctions)) {
     return false;
-    }
-  if(!this->GetNextInt(inputLine, pos, percentFunction))
-    {
+  }
+  if (!this->GetNextInt(inputLine, pos, percentFunction)) {
     return false;
-    }
-  if(!this->GetNextInt(inputLine, pos, branchCovered))
-    {
+  }
+  if (!this->GetNextInt(inputLine, pos, branchCovered)) {
     return false;
-    }
-  if(!this->GetNextInt(inputLine, pos, totalBranches))
-    {
+  }
+  if (!this->GetNextInt(inputLine, pos, totalBranches)) {
     return false;
-    }
-  if(!this->GetNextInt(inputLine, pos, percentBranch))
-    {
+  }
+  if (!this->GetNextInt(inputLine, pos, percentBranch)) {
     return false;
-    }
+  }
   // should be at the end now
-  if(pos != inputLine.npos)
-    {
+  if (pos != inputLine.npos) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : "
-               << inputLine << " last pos not npos =  " << pos <<
-               "\n");
-    }
+                 << inputLine << " last pos not npos =  " << pos << "\n");
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 int cmCTestCoverageHandler::GetLabelId(std::string const& label)
 {
   LabelIdMapType::iterator i = this->LabelIdMap.find(label);
-  if(i == this->LabelIdMap.end())
-    {
+  if (i == this->LabelIdMap.end()) {
     int n = int(this->Labels.size());
     this->Labels.push_back(label);
     LabelIdMapType::value_type entry(label, n);
     i = this->LabelIdMap.insert(entry).first;
-    }
+  }
   return i->second;
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::LoadLabels()
 {
   std::string fileList = this->CTest->GetBinaryDir();
   fileList += cmake::GetCMakeFilesDirectory();
   fileList += "/TargetDirectories.txt";
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    " target directory list [" << fileList << "]\n", this->Quiet);
+                     " target directory list [" << fileList << "]\n",
+                     this->Quiet);
   cmsys::ifstream finList(fileList.c_str());
   std::string line;
-  while(cmSystemTools::GetLineFromStream(finList, line))
-    {
+  while (cmSystemTools::GetLineFromStream(finList, line)) {
     this->LoadLabels(line.c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::LoadLabels(const char* dir)
 {
   LabelSet& dirLabels = this->TargetDirs[dir];
   std::string fname = dir;
   fname += "/Labels.txt";
   cmsys::ifstream fin(fname.c_str());
-  if(!fin)
-    {
+  if (!fin) {
     return;
-    }
+  }
 
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    " loading labels from [" << fname << "]\n", this->Quiet);
+                     " loading labels from [" << fname << "]\n", this->Quiet);
   bool inTarget = true;
   std::string source;
   std::string line;
   std::vector<int> targetLabels;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if(line.empty() || line[0] == '#')
-      {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (line.empty() || line[0] == '#') {
       // Ignore blank and comment lines.
       continue;
-      }
-    else if(line[0] == ' ')
-      {
+    } else if (line[0] == ' ') {
       // Label lines appear indented by one space.
       std::string label = line.substr(1);
       int id = this->GetLabelId(label);
       dirLabels.insert(id);
-      if(inTarget)
-        {
+      if (inTarget) {
         targetLabels.push_back(id);
-        }
-      else
-        {
+      } else {
         this->SourceLabels[source].insert(id);
-        }
       }
-    else
-      {
+    } else {
       // Non-indented lines specify a source file name.  The first one
       // is the end of the target-wide labels.
       inTarget = false;
@@ -2551,112 +2273,95 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
       // Label the source with the target labels.
       LabelSet& labelSet = this->SourceLabels[source];
       labelSet.insert(targetLabels.begin(), targetLabels.end());
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml,
                                             std::string const& source)
 {
   LabelMapType::const_iterator li = this->SourceLabels.find(source);
-  if(li != this->SourceLabels.end() && !li->second.empty())
-    {
+  if (li != this->SourceLabels.end() && !li->second.empty()) {
     xml.StartElement("Labels");
-    for(LabelSet::const_iterator lsi = li->second.begin();
-        lsi != li->second.end(); ++lsi)
-      {
+    for (LabelSet::const_iterator lsi = li->second.begin();
+         lsi != li->second.end(); ++lsi) {
       xml.Element("Label", this->Labels[*lsi]);
-      }
-    xml.EndElement(); // Labels
     }
+    xml.EndElement(); // Labels
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmCTestCoverageHandler::SetLabelFilter(std::set<std::string> const& labels)
+void cmCTestCoverageHandler::SetLabelFilter(
+  std::set<std::string> const& labels)
 {
   this->LabelFilter.clear();
-  for(std::set<std::string>::const_iterator li = labels.begin();
-      li != labels.end(); ++li)
-    {
+  for (std::set<std::string>::const_iterator li = labels.begin();
+       li != labels.end(); ++li) {
     this->LabelFilter.insert(this->GetLabelId(*li));
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 bool cmCTestCoverageHandler::IntersectsFilter(LabelSet const& labels)
 {
   // If there is no label filter then nothing is filtered out.
-  if(this->LabelFilter.empty())
-    {
+  if (this->LabelFilter.empty()) {
     return true;
-    }
+  }
 
   std::vector<int> ids;
-  std::set_intersection
-    (labels.begin(), labels.end(),
-     this->LabelFilter.begin(), this->LabelFilter.end(),
-     std::back_inserter(ids));
+  std::set_intersection(labels.begin(), labels.end(),
+                        this->LabelFilter.begin(), this->LabelFilter.end(),
+                        std::back_inserter(ids));
   return !ids.empty();
 }
 
-//----------------------------------------------------------------------
 bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source)
 {
   // If there is no label filter then nothing is filtered out.
-  if(this->LabelFilter.empty())
-    {
+  if (this->LabelFilter.empty()) {
     return false;
-    }
+  }
 
   // The source is filtered out if it does not have any labels in
   // common with the filter set.
   std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str());
   LabelMapType::const_iterator li = this->SourceLabels.find(shortSrc);
-  if(li != this->SourceLabels.end())
-    {
+  if (li != this->SourceLabels.end()) {
     return !this->IntersectsFilter(li->second);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
   cmCTestCoverageHandlerContainer* cont)
 {
   std::set<std::string> extraMatches;
 
-  for(std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
-      i != this->ExtraCoverageGlobs.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
+       i != this->ExtraCoverageGlobs.end(); ++i) {
     cmsys::Glob gl;
     gl.RecurseOn();
     gl.RecurseThroughSymlinksOff();
     std::string glob = cont->SourceDir + "/" + *i;
     gl.FindFiles(glob);
     std::vector<std::string> files = gl.GetFiles();
-    for(std::vector<std::string>::iterator f = files.begin();
-        f != files.end(); ++f)
-      {
-      if(this->ShouldIDoCoverage(f->c_str(),
-         cont->SourceDir.c_str(), cont->BinaryDir.c_str()))
-        {
-        extraMatches.insert(this->CTest->GetShortPathToFile(
-          f->c_str()));
-        }
+    for (std::vector<std::string>::iterator f = files.begin();
+         f != files.end(); ++f) {
+      if (this->ShouldIDoCoverage(f->c_str(), cont->SourceDir.c_str(),
+                                  cont->BinaryDir.c_str())) {
+        extraMatches.insert(this->CTest->GetShortPathToFile(f->c_str()));
       }
     }
+  }
 
-  if(!extraMatches.empty())
-    {
-    for(cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
-        cont->TotalCoverage.begin(); i != cont->TotalCoverage.end(); ++i)
-      {
-      std::string shortPath = this->CTest->GetShortPathToFile(
-        i->first.c_str());
+  if (!extraMatches.empty()) {
+    for (cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
+           cont->TotalCoverage.begin();
+         i != cont->TotalCoverage.end(); ++i) {
+      std::string shortPath =
+        this->CTest->GetShortPathToFile(i->first.c_str());
       extraMatches.erase(shortPath);
-      }
     }
+  }
   return extraMatches;
 }
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index 7102d1e..1773218 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestCoverageHandler_h
 #define cmCTestCoverageHandler_h
 
-
 #include "cmCTestGenericHandler.h"
+
 #include "cmListFileCache.h"
 
 #include <cmsys/RegularExpression.hxx>
@@ -54,14 +54,14 @@ public:
   /**
    * This method is called when reading CTest custom file
    */
-  void PopulateCustomVectors(cmMakefile *mf);
+  void PopulateCustomVectors(cmMakefile* mf);
 
   /** Report coverage only for sources with these labels.  */
   void SetLabelFilter(std::set<std::string> const& labels);
 
 private:
   bool ShouldIDoCoverage(const char* file, const char* srcDir,
-    const char* binDir);
+                         const char* binDir);
   void CleanCoverageLogFiles(std::ostream& log);
   bool StartCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
   void EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
@@ -95,7 +95,7 @@ private:
   //! Handle coverage for Jacoco
   int HandleBlanketJSCoverage(cmCTestCoverageHandlerContainer* cont);
 
-//! Handle coverage using Bullseye
+  //! Handle coverage using Bullseye
   int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont);
   int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont);
   int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont,
@@ -103,22 +103,15 @@ private:
                                 std::vector<std::string>& files,
                                 std::vector<std::string>& filesFullPath);
 
-  int RunBullseyeCommand(
-    cmCTestCoverageHandlerContainer* cont,
-    const char* cmd,
-    const char* arg,
-    std::string& outputFile);
-  bool ParseBullsEyeCovsrcLine(
-    std::string const& inputLine,
-    std::string& sourceFile,
-    int& functionsCalled,
-    int& totalFunctions,
-    int& percentFunction,
-    int& branchCovered,
-    int& totalBranches,
-    int& percentBranch);
-  bool GetNextInt(std::string const& inputLine,
-                  std::string::size_type& pos,
+  int RunBullseyeCommand(cmCTestCoverageHandlerContainer* cont,
+                         const char* cmd, const char* arg,
+                         std::string& outputFile);
+  bool ParseBullsEyeCovsrcLine(std::string const& inputLine,
+                               std::string& sourceFile, int& functionsCalled,
+                               int& totalFunctions, int& percentFunction,
+                               int& branchCovered, int& totalBranches,
+                               int& percentBranch);
+  bool GetNextInt(std::string const& inputLine, std::string::size_type& pos,
                   int& value);
   //! Handle Python coverage using Python's Trace.py
   int HandleTracePyCoverage(cmCTestCoverageHandlerContainer* cont);
@@ -126,7 +119,7 @@ private:
   // Find the source file based on the source and build tree. This is used for
   // Trace.py mode, since that one does not tell us where the source file is.
   std::string FindFile(cmCTestCoverageHandlerContainer* cont,
-    std::string fileName);
+                       std::string const& fileName);
 
   std::set<std::string> FindUncoveredFiles(
     cmCTestCoverageHandlerContainer* cont);
@@ -134,9 +127,10 @@ private:
   std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex;
   std::vector<std::string> ExtraCoverageGlobs;
 
-
   // Map from source file to label ids.
-  class LabelSet: public std::set<int> {};
+  class LabelSet : public std::set<int>
+  {
+  };
   typedef std::map<std::string, LabelSet> LabelMapType;
   LabelMapType SourceLabels;
   LabelMapType TargetDirs;
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index fb6cc00..59675dd 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -11,8 +11,8 @@
 ============================================================================*/
 #include "cmCTestCurl.h"
 
-#include "cmSystemTools.h"
 #include "cmCTest.h"
+#include "cmSystemTools.h"
 
 cmCTestCurl::cmCTestCurl(cmCTest* ctest)
 {
@@ -42,115 +42,95 @@ std::string cmCTestCurl::Escape(std::string const& source)
   return ret;
 }
 
-namespace
-{
-static size_t
-curlWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
-  void *data)
+namespace {
+static size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
+                                      void* data)
 {
   int realsize = (int)(size * nmemb);
 
-  std::vector<char> *vec
-    = static_cast<std::vector<char>* >(data);
+  std::vector<char>* vec = static_cast<std::vector<char>*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   vec->insert(vec->end(), chPtr, chPtr + realsize);
   return realsize;
 }
 
-static size_t
-curlDebugCallback(CURL *, curl_infotype, char *chPtr,
-  size_t size, void *data)
+static size_t curlDebugCallback(CURL*, curl_infotype, char* chPtr, size_t size,
+                                void* data)
 {
-  std::vector<char> *vec
-    = static_cast<std::vector<char>* >(data);
+  std::vector<char>* vec = static_cast<std::vector<char>*>(data);
   vec->insert(vec->end(), chPtr, chPtr + size);
 
   return size;
 }
-
 }
 
 void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
 {
-  for( std::vector<std::string>::const_iterator i = args.begin();
-       i != args.end(); ++i)
-    {
-    if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
-      {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
+    if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
       this->VerifyPeerOff = true;
-      }
-    if(*i == "CURLOPT_SSL_VERIFYHOST_OFF")
-      {
+    }
+    if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
       this->VerifyHostOff = true;
-      }
     }
+  }
 }
 
 bool cmCTestCurl::InitCurl()
 {
-  if(!this->Curl)
-    {
+  if (!this->Curl) {
     return false;
-    }
-  if(this->VerifyPeerOff)
-    {
+  }
+  if (this->VerifyPeerOff) {
     curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYPEER, 0);
-    }
-  if(this->VerifyHostOff)
-    {
+  }
+  if (this->VerifyHostOff) {
     curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYHOST, 0);
-    }
-  if(this->HTTPProxy.size())
-    {
+  }
+  if (this->HTTPProxy.size()) {
     curl_easy_setopt(this->Curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
     curl_easy_setopt(this->Curl, CURLOPT_PROXYTYPE, this->HTTPProxyType);
-    if (this->HTTPProxyAuth.size() > 0)
-      {
+    if (this->HTTPProxyAuth.size() > 0) {
       curl_easy_setopt(this->Curl, CURLOPT_PROXYUSERPWD,
                        this->HTTPProxyAuth.c_str());
-      }
     }
-  if(this->UseHttp10)
-    {
+  }
+  if (this->UseHttp10) {
     curl_easy_setopt(this->Curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
-    }
+  }
   // enable HTTP ERROR parsing
   curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
   return true;
 }
 
-
 bool cmCTestCurl::UploadFile(std::string const& local_file,
-                             std::string const& url,
-                             std::string const& fields,
+                             std::string const& url, std::string const& fields,
                              std::string& response)
 {
   response = "";
-  if(!this->InitCurl())
-    {
+  if (!this->InitCurl()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
     return false;
-    }
+  }
   /* enable uploading */
   curl_easy_setopt(this->Curl, CURLOPT_UPLOAD, 1);
   // if there is little to no activity for too long stop submitting
-  if(this->TimeOutSeconds)
-    {
+  if (this->TimeOutSeconds) {
     ::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_LIMIT, 1);
     ::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_TIME,
                        this->TimeOutSeconds);
-    }
+  }
   /* HTTP PUT please */
   ::curl_easy_setopt(this->Curl, CURLOPT_PUT, 1);
   ::curl_easy_setopt(this->Curl, CURLOPT_VERBOSE, 1);
 
   FILE* ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
-  if(!ftpfile)
-    {
+  if (!ftpfile) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Could not open file for upload: " << local_file << "\n");
     return false;
-    }
+  }
   // set the url
   std::string upload_url = url;
   upload_url += "?";
@@ -164,16 +144,15 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
                      static_cast<long>(filelen));
   ::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
                      curlWriteMemoryCallback);
-  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
-                     curlDebugCallback);
+  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
   // Be sure to set Content-Type to satisfy fussy modsecurity rules
-  struct curl_slist *headers = ::curl_slist_append(NULL,
-                                                   "Content-Type: text/xml");
+  struct curl_slist* headers =
+    ::curl_slist_append(NULL, "Content-Type: text/xml");
   ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
   std::vector<char> responseData;
   std::vector<char> debugData;
-  ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
-  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void *)&debugData);
+  ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
+  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
   ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
   // Now run off and do what you've been told!
   ::curl_easy_perform(this->Curl);
@@ -181,108 +160,90 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
   ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL);
   ::curl_slist_free_all(headers);
 
-  if ( responseData.size() > 0 )
-    {
+  if (responseData.size() > 0) {
     response = std::string(responseData.begin(), responseData.end());
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Curl response: [" << response << "]\n");
-    }
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Curl response: ["
+                 << response << "]\n");
+  }
   std::string curlDebug;
-  if ( debugData.size() > 0 )
-    {
+  if (debugData.size() > 0) {
     curlDebug = std::string(debugData.begin(), debugData.end());
     cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
-    }
-  if(response.size() == 0)
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n" <<
-      curlDebug);
+  }
+  if (response.size() == 0) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n"
+                 << curlDebug);
     return false;
-    }
+  }
   return true;
 }
 
 bool cmCTestCurl::HttpRequest(std::string const& url,
-                              std::string const& fields,
-                              std::string& response)
+                              std::string const& fields, std::string& response)
 {
   response = "";
   cmCTestLog(this->CTest, DEBUG, "HttpRequest\n"
-             << "url: " << url << "\n"
-             << "fields " << fields << "\n");
-  if(!this->InitCurl())
-    {
+               << "url: " << url << "\n"
+               << "fields " << fields << "\n");
+  if (!this->InitCurl()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
     return false;
-    }
+  }
   curl_easy_setopt(this->Curl, CURLOPT_POST, 1);
   curl_easy_setopt(this->Curl, CURLOPT_POSTFIELDS, fields.c_str());
   ::curl_easy_setopt(this->Curl, CURLOPT_URL, url.c_str());
   ::curl_easy_setopt(this->Curl, CURLOPT_FOLLOWLOCATION, 1);
-  //set response options
+  // set response options
   ::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
                      curlWriteMemoryCallback);
-  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
-        curlDebugCallback);
+  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
   std::vector<char> responseData;
   std::vector<char> debugData;
-  ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
-  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void *)&debugData);
+  ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
+  ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
   ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
 
   CURLcode res = ::curl_easy_perform(this->Curl);
 
-  if ( responseData.size() > 0 )
-    {
+  if (responseData.size() > 0) {
     response = std::string(responseData.begin(), responseData.end());
     cmCTestLog(this->CTest, DEBUG, "Curl response: [" << response << "]\n");
-    }
-  if ( debugData.size() > 0 )
-    {
+  }
+  if (debugData.size() > 0) {
     std::string curlDebug = std::string(debugData.begin(), debugData.end());
     cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
-    }
+  }
   cmCTestLog(this->CTest, DEBUG, "Curl res: " << res << "\n");
   return (res == 0);
 }
 
 void cmCTestCurl::SetProxyType()
 {
-  if ( cmSystemTools::GetEnv("HTTP_PROXY") )
-    {
+  if (cmSystemTools::GetEnv("HTTP_PROXY")) {
     this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY");
-    if ( cmSystemTools::GetEnv("HTTP_PROXY_PORT") )
-      {
+    if (cmSystemTools::GetEnv("HTTP_PROXY_PORT")) {
       this->HTTPProxy += ":";
       this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT");
-      }
-    if ( cmSystemTools::GetEnv("HTTP_PROXY_TYPE") )
-      {
+    }
+    if (cmSystemTools::GetEnv("HTTP_PROXY_TYPE")) {
       // this is the default
       this->HTTPProxyType = CURLPROXY_HTTP;
       std::string type = cmSystemTools::GetEnv("HTTP_PROXY_TYPE");
       // HTTP/SOCKS4/SOCKS5
-      if ( type == "HTTP" )
-        {
+      if (type == "HTTP") {
         this->HTTPProxyType = CURLPROXY_HTTP;
-        }
-      else if ( type == "SOCKS4" )
-        {
+      } else if (type == "SOCKS4") {
         this->HTTPProxyType = CURLPROXY_SOCKS4;
-        }
-      else if ( type == "SOCKS5" )
-        {
+      } else if (type == "SOCKS5") {
         this->HTTPProxyType = CURLPROXY_SOCKS5;
-        }
       }
-    if ( cmSystemTools::GetEnv("HTTP_PROXY_USER") )
-      {
+    }
+    if (cmSystemTools::GetEnv("HTTP_PROXY_USER")) {
       this->HTTPProxyAuth = cmSystemTools::GetEnv("HTTP_PROXY_USER");
-      }
-    if ( cmSystemTools::GetEnv("HTTP_PROXY_PASSWD") )
-      {
+    }
+    if (cmSystemTools::GetEnv("HTTP_PROXY_PASSWD")) {
       this->HTTPProxyAuth += ":";
       this->HTTPProxyAuth += cmSystemTools::GetEnv("HTTP_PROXY_PASSWD");
-      }
     }
+  }
 }
diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h
index 0737bb6..82601e3 100644
--- a/Source/CTest/cmCTestCurl.h
+++ b/Source/CTest/cmCTestCurl.h
@@ -23,22 +23,21 @@ class cmCTestCurl
 public:
   cmCTestCurl(cmCTest*);
   ~cmCTestCurl();
-  bool UploadFile(std::string const& url,
-                  std::string const& file,
-                  std::string const& fields,
-                  std::string& response);
-  bool HttpRequest(std::string const& url,
-                   std::string const& fields,
+  bool UploadFile(std::string const& url, std::string const& file,
+                  std::string const& fields, std::string& response);
+  bool HttpRequest(std::string const& url, std::string const& fields,
                    std::string& response);
   // currently only supports CURLOPT_SSL_VERIFYPEER_OFF
   // and CURLOPT_SSL_VERIFYHOST_OFF
   void SetCurlOptions(std::vector<std::string> const& args);
-  void SetUseHttp10On() { this->UseHttp10 = true;}
-  void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s;}
+  void SetUseHttp10On() { this->UseHttp10 = true; }
+  void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
   std::string Escape(std::string const& source);
+
 protected:
   void SetProxyType();
   bool InitCurl();
+
 private:
   cmCTest* CTest;
   CURL* Curl;
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
index e175592..1bda9be 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -13,24 +13,20 @@
 
 #include "cmCTestScriptHandler.h"
 
-bool cmCTestEmptyBinaryDirectoryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestEmptyBinaryDirectoryCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() != 1 )
-    {
+  if (args.size() != 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
-  if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) )
-    {
+  if (!cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str())) {
     std::ostringstream ostr;
     ostr << "problem removing the binary directory: " << args[0];
     this->SetError(ostr.str());
     return false;
-    }
+  }
 
   return true;
 }
-
-
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
index d182d17..e904d19 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
@@ -23,36 +23,36 @@
 class cmCTestEmptyBinaryDirectoryCommand : public cmCTestCommand
 {
 public:
-
   cmCTestEmptyBinaryDirectoryCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
-    cmCTestEmptyBinaryDirectoryCommand* ni
-      = new cmCTestEmptyBinaryDirectoryCommand;
+  {
+    cmCTestEmptyBinaryDirectoryCommand* ni =
+      new cmCTestEmptyBinaryDirectoryCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_empty_binary_directory";}
+  virtual std::string GetName() const
+  {
+    return "ctest_empty_binary_directory";
+  }
 
   cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand);
-
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index bbb3b9d..8b392f2 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -11,64 +11,60 @@
 ============================================================================*/
 #include "cmCTestGIT.h"
 
+#include "cmAlgorithms.h"
 #include "cmCTest.h"
 #include "cmSystemTools.h"
-#include "cmAlgorithms.h"
 
-#include <cmsys/RegularExpression.hxx>
-#include <cmsys/Process.h>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Process.h>
+#include <cmsys/RegularExpression.hxx>
 
+#include <ctype.h>
 #include <sys/types.h>
 #include <time.h>
-#include <ctype.h>
 
-//----------------------------------------------------------------------------
 static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major,
                                       unsigned int minor, unsigned int fix)
 {
   // 1.6.5.0 maps to 10605000
-  return fix + minor*1000 + major*100000 + epic*10000000;
+  return fix + minor * 1000 + major * 100000 + epic * 10000000;
 }
 
-//----------------------------------------------------------------------------
-cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log):
-  cmCTestGlobalVC(ct, log)
+cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log)
+  : cmCTestGlobalVC(ct, log)
 {
   this->PriorRev = this->Unknown;
   this->CurrentGitVersion = 0;
 }
 
-//----------------------------------------------------------------------------
 cmCTestGIT::~cmCTestGIT()
 {
 }
 
-//----------------------------------------------------------------------------
-class cmCTestGIT::OneLineParser: public cmCTestVC::LineParser
+class cmCTestGIT::OneLineParser : public cmCTestVC::LineParser
 {
 public:
-  OneLineParser(cmCTestGIT* git, const char* prefix,
-                std::string& l): Line1(l)
-    {
+  OneLineParser(cmCTestGIT* git, const char* prefix, std::string& l)
+    : Line1(l)
+  {
     this->SetLog(&git->Log, prefix);
-    }
+  }
+
 private:
   std::string& Line1;
   virtual bool ProcessLine()
-    {
+  {
     // Only the first line is of interest.
     this->Line1 = this->Line;
     return false;
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 std::string cmCTestGIT::GetWorkingRevision()
 {
   // Run plumbing "git rev-list" to get work tree revision.
   const char* git = this->CommandLineTool.c_str();
-  const char* git_rev_list[] = {git, "rev-list", "-n", "1", "HEAD", "--", 0};
+  const char* git_rev_list[] = { git, "rev-list", "-n", "1", "HEAD", "--", 0 };
   std::string rev;
   OneLineParser out(this, "rl-out> ", rev);
   OutputLogger err(this->Log, "rl-err> ");
@@ -76,93 +72,82 @@ std::string cmCTestGIT::GetWorkingRevision()
   return rev;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGIT::NoteOldRevision()
 {
   this->OldRevision = this->GetWorkingRevision();
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Old revision of repository is: "
-             << this->OldRevision << "\n");
+               << this->OldRevision << "\n");
   this->PriorRev.Rev = this->OldRevision;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGIT::NoteNewRevision()
 {
   this->NewRevision = this->GetWorkingRevision();
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   New revision of repository is: "
-             << this->NewRevision << "\n");
+               << this->NewRevision << "\n");
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestGIT::FindGitDir()
 {
   std::string git_dir;
 
   // Run "git rev-parse --git-dir" to locate the real .git directory.
   const char* git = this->CommandLineTool.c_str();
-  char const* git_rev_parse[] = {git, "rev-parse", "--git-dir", 0};
+  char const* git_rev_parse[] = { git, "rev-parse", "--git-dir", 0 };
   std::string git_dir_line;
   OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line);
   OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
-  if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err))
-    {
+  if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) {
     git_dir = git_dir_line;
-    }
-  if(git_dir.empty())
-    {
+  }
+  if (git_dir.empty()) {
     git_dir = ".git";
-    }
+  }
 
   // Git reports a relative path only when the .git directory is in
   // the current directory.
-  if(git_dir[0] == '.')
-    {
+  if (git_dir[0] == '.') {
     git_dir = this->SourceDirectory + "/" + git_dir;
-    }
+  }
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  else if(git_dir[0] == '/')
-    {
+  else if (git_dir[0] == '/') {
     // Cygwin Git reports a full path that Cygwin understands, but we
     // are a Windows application.  Run "cygpath" to get Windows path.
     std::string cygpath_exe = cmSystemTools::GetFilenamePath(git);
     cygpath_exe += "/cygpath.exe";
-    if(cmSystemTools::FileExists(cygpath_exe.c_str()))
-      {
-      char const* cygpath[] = {cygpath_exe.c_str(), "-w", git_dir.c_str(), 0};
+    if (cmSystemTools::FileExists(cygpath_exe.c_str())) {
+      char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(),
+                                0 };
       OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line);
       OutputLogger cygpath_err(this->Log, "cygpath-err> ");
-      if(this->RunChild(cygpath, &cygpath_out, &cygpath_err))
-        {
+      if (this->RunChild(cygpath, &cygpath_out, &cygpath_err)) {
         git_dir = git_dir_line;
-        }
       }
     }
+  }
 #endif
   return git_dir;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestGIT::FindTopDir()
 {
   std::string top_dir = this->SourceDirectory;
 
   // Run "git rev-parse --show-cdup" to locate the top of the tree.
   const char* git = this->CommandLineTool.c_str();
-  char const* git_rev_parse[] = {git, "rev-parse", "--show-cdup", 0};
+  char const* git_rev_parse[] = { git, "rev-parse", "--show-cdup", 0 };
   std::string cdup;
   OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup);
   OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
-  if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) &&
-     !cdup.empty())
-    {
+  if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) &&
+      !cdup.empty()) {
     top_dir += "/";
     top_dir += cdup;
     top_dir = cmSystemTools::CollapseFullPath(top_dir);
-    }
+  }
   return top_dir;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestGIT::UpdateByFetchAndReset()
 {
   const char* git = this->CommandLineTool.c_str();
@@ -174,16 +159,14 @@ bool cmCTestGIT::UpdateByFetchAndReset()
 
   // Add user-specified update options.
   std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
-  if(opts.empty())
-    {
+  if (opts.empty()) {
     opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
-    }
+  }
   std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     git_fetch.push_back(ai->c_str());
-    }
+  }
 
   // Sentinel argument.
   git_fetch.push_back(0);
@@ -191,59 +174,51 @@ bool cmCTestGIT::UpdateByFetchAndReset()
   // Fetch upstream refs.
   OutputLogger fetch_out(this->Log, "fetch-out> ");
   OutputLogger fetch_err(this->Log, "fetch-err> ");
-  if(!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err))
-    {
+  if (!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err)) {
     return false;
-    }
+  }
 
   // Identify the merge head that would be used by "git pull".
   std::string sha1;
   {
-  std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD";
-  cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
-  if(!fin)
-    {
-    this->Log << "Unable to open " << fetch_head << "\n";
-    return false;
+    std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD";
+    cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
+    if (!fin) {
+      this->Log << "Unable to open " << fetch_head << "\n";
+      return false;
     }
-  std::string line;
-  while(sha1.empty() && cmSystemTools::GetLineFromStream(fin, line))
-    {
-    this->Log << "FETCH_HEAD> " << line << "\n";
-    if(line.find("\tnot-for-merge\t") == line.npos)
-      {
-      std::string::size_type pos = line.find('\t');
-      if(pos != line.npos)
-        {
-        sha1 = line.substr(0, pos);
+    std::string line;
+    while (sha1.empty() && cmSystemTools::GetLineFromStream(fin, line)) {
+      this->Log << "FETCH_HEAD> " << line << "\n";
+      if (line.find("\tnot-for-merge\t") == line.npos) {
+        std::string::size_type pos = line.find('\t');
+        if (pos != line.npos) {
+          sha1 = line.substr(0, pos);
         }
       }
     }
-  if(sha1.empty())
-    {
-    this->Log << "FETCH_HEAD has no upstream branch candidate!\n";
-    return false;
+    if (sha1.empty()) {
+      this->Log << "FETCH_HEAD has no upstream branch candidate!\n";
+      return false;
     }
   }
 
   // Reset the local branch to point at that tracked from upstream.
-  char const* git_reset[] = {git, "reset", "--hard", sha1.c_str(), 0};
+  char const* git_reset[] = { git, "reset", "--hard", sha1.c_str(), 0 };
   OutputLogger reset_out(this->Log, "reset-out> ");
   OutputLogger reset_err(this->Log, "reset-err> ");
   return this->RunChild(&git_reset[0], &reset_out, &reset_err);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestGIT::UpdateByCustom(std::string const& custom)
 {
   std::vector<std::string> git_custom_command;
   cmSystemTools::ExpandListArgument(custom, git_custom_command, true);
   std::vector<char const*> git_custom;
-  for(std::vector<std::string>::const_iterator
-        i = git_custom_command.begin(); i != git_custom_command.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = git_custom_command.begin();
+       i != git_custom_command.end(); ++i) {
     git_custom.push_back(i->c_str());
-    }
+  }
   git_custom.push_back(0);
 
   OutputLogger custom_out(this->Log, "custom-out> ");
@@ -251,69 +226,93 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
   return this->RunUpdateCommand(&git_custom[0], &custom_out, &custom_err);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestGIT::UpdateInternal()
 {
   std::string custom = this->CTest->GetCTestConfiguration("GITUpdateCustom");
-  if(!custom.empty())
-    {
+  if (!custom.empty()) {
     return this->UpdateByCustom(custom);
-    }
+  }
   return this->UpdateByFetchAndReset();
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestGIT::UpdateImpl()
 {
-  if(!this->UpdateInternal())
-    {
+  if (!this->UpdateInternal()) {
     return false;
-    }
+  }
 
   std::string top_dir = this->FindTopDir();
   const char* git = this->CommandLineTool.c_str();
   const char* recursive = "--recursive";
+  const char* sync_recursive = "--recursive";
 
-  // Git < 1.6.5.0 did not support --recursive
-  if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0))
-    {
+  // Git < 1.6.5 did not support submodule --recursive
+  if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) {
     recursive = 0;
-    // No need to require >= 1.6.5.0 if there are no submodules.
-    if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str()))
-      {
-      this->Log << "Git < 1.6.5.0 cannot update submodules recursively\n";
-      }
+    // No need to require >= 1.6.5 if there are no submodules.
+    if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
+      this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
     }
+  }
+
+  // Git < 1.8.1 did not support sync --recursive
+  if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) {
+    sync_recursive = 0;
+    // No need to require >= 1.8.1 if there are no submodules.
+    if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
+      this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
+    }
+  }
 
-  char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
   OutputLogger submodule_out(this->Log, "submodule-out> ");
   OutputLogger submodule_err(this->Log, "submodule-err> ");
+
+  bool ret;
+
+  std::string init_submodules =
+    this->CTest->GetCTestConfiguration("GITInitSubmodules");
+  if (cmSystemTools::IsOn(init_submodules.c_str())) {
+    char const* git_submodule_init[] = { git, "submodule", "init", 0 };
+    ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err,
+                         top_dir.c_str());
+
+    if (!ret) {
+      return false;
+    }
+  }
+
+  char const* git_submodule_sync[] = { git, "submodule", "sync",
+                                       sync_recursive, 0 };
+  ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err,
+                       top_dir.c_str());
+
+  if (!ret) {
+    return false;
+  }
+
+  char const* git_submodule[] = { git, "submodule", "update", recursive, 0 };
   return this->RunChild(git_submodule, &submodule_out, &submodule_err,
                         top_dir.c_str());
 }
 
-//----------------------------------------------------------------------------
 unsigned int cmCTestGIT::GetGitVersion()
 {
-  if(!this->CurrentGitVersion)
-    {
+  if (!this->CurrentGitVersion) {
     const char* git = this->CommandLineTool.c_str();
-    char const* git_version[] = {git, "--version", 0};
+    char const* git_version[] = { git, "--version", 0 };
     std::string version;
     OneLineParser version_out(this, "version-out> ", version);
     OutputLogger version_err(this->Log, "version-err> ");
-    unsigned int v[4] = {0,0,0,0};
-    if(this->RunChild(git_version, &version_out, &version_err) &&
-       sscanf(version.c_str(), "git version %u.%u.%u.%u",
-              &v[0], &v[1], &v[2], &v[3]) >= 3)
-      {
+    unsigned int v[4] = { 0, 0, 0, 0 };
+    if (this->RunChild(git_version, &version_out, &version_err) &&
+        sscanf(version.c_str(), "git version %u.%u.%u.%u", &v[0], &v[1], &v[2],
+               &v[3]) >= 3) {
       this->CurrentGitVersion = cmCTestGITVersion(v[0], v[1], v[2], v[3]);
-      }
     }
+  }
   return this->CurrentGitVersion;
 }
 
-//----------------------------------------------------------------------------
 /* Diff format:
 
    :src-mode dst-mode src-sha1 dst-sha1 status\0
@@ -324,76 +323,73 @@ unsigned int cmCTestGIT::GetGitVersion()
    line appears only for lines with status 'C' or 'R'.  See 'git help
    diff-tree' for details.
 */
-class cmCTestGIT::DiffParser: public cmCTestVC::LineParser
+class cmCTestGIT::DiffParser : public cmCTestVC::LineParser
 {
 public:
-  DiffParser(cmCTestGIT* git, const char* prefix):
-    LineParser('\0', false), GIT(git), DiffField(DiffFieldNone)
-    {
+  DiffParser(cmCTestGIT* git, const char* prefix)
+    : LineParser('\0', false)
+    , GIT(git)
+    , DiffField(DiffFieldNone)
+  {
     this->SetLog(&git->Log, prefix);
-    }
+  }
 
   typedef cmCTestGIT::Change Change;
   std::vector<Change> Changes;
+
 protected:
   cmCTestGIT* GIT;
-  enum DiffFieldType { DiffFieldNone, DiffFieldChange,
-                       DiffFieldSrc, DiffFieldDst };
+  enum DiffFieldType
+  {
+    DiffFieldNone,
+    DiffFieldChange,
+    DiffFieldSrc,
+    DiffFieldDst
+  };
   DiffFieldType DiffField;
   Change CurChange;
 
   void DiffReset()
-    {
+  {
     this->DiffField = DiffFieldNone;
     this->Changes.clear();
-    }
+  }
 
   virtual bool ProcessLine()
-    {
-    if(this->Line[0] == ':')
-      {
+  {
+    if (this->Line[0] == ':') {
       this->DiffField = DiffFieldChange;
       this->CurChange = Change();
-      }
-    if(this->DiffField == DiffFieldChange)
-      {
+    }
+    if (this->DiffField == DiffFieldChange) {
       // :src-mode dst-mode src-sha1 dst-sha1 status
-      if(this->Line[0] != ':')
-        {
+      if (this->Line[0] != ':') {
         this->DiffField = DiffFieldNone;
         return true;
-        }
-      const char* src_mode_first = this->Line.c_str()+1;
-      const char* src_mode_last  = this->ConsumeField(src_mode_first);
+      }
+      const char* src_mode_first = this->Line.c_str() + 1;
+      const char* src_mode_last = this->ConsumeField(src_mode_first);
       const char* dst_mode_first = this->ConsumeSpace(src_mode_last);
-      const char* dst_mode_last  = this->ConsumeField(dst_mode_first);
+      const char* dst_mode_last = this->ConsumeField(dst_mode_first);
       const char* src_sha1_first = this->ConsumeSpace(dst_mode_last);
-      const char* src_sha1_last  = this->ConsumeField(src_sha1_first);
+      const char* src_sha1_last = this->ConsumeField(src_sha1_first);
       const char* dst_sha1_first = this->ConsumeSpace(src_sha1_last);
-      const char* dst_sha1_last  = this->ConsumeField(dst_sha1_first);
-      const char* status_first   = this->ConsumeSpace(dst_sha1_last);
-      const char* status_last    = this->ConsumeField(status_first);
-      if(status_first != status_last)
-        {
+      const char* dst_sha1_last = this->ConsumeField(dst_sha1_first);
+      const char* status_first = this->ConsumeSpace(dst_sha1_last);
+      const char* status_last = this->ConsumeField(status_first);
+      if (status_first != status_last) {
         this->CurChange.Action = *status_first;
         this->DiffField = DiffFieldSrc;
-        }
-      else
-        {
+      } else {
         this->DiffField = DiffFieldNone;
-        }
       }
-    else if(this->DiffField == DiffFieldSrc)
-      {
+    } else if (this->DiffField == DiffFieldSrc) {
       // src-path
-      if(this->CurChange.Action == 'C')
-        {
+      if (this->CurChange.Action == 'C') {
         // Convert copy to addition of destination.
         this->CurChange.Action = 'A';
         this->DiffField = DiffFieldDst;
-        }
-      else if(this->CurChange.Action == 'R')
-        {
+      } else if (this->CurChange.Action == 'R') {
         // Convert rename to deletion of source and addition of destination.
         this->CurChange.Action = 'D';
         this->CurChange.Path = this->Line;
@@ -401,37 +397,36 @@ protected:
 
         this->CurChange = Change('A');
         this->DiffField = DiffFieldDst;
-        }
-      else
-        {
+      } else {
         this->CurChange.Path = this->Line;
         this->Changes.push_back(this->CurChange);
         this->DiffField = this->DiffFieldNone;
-        }
       }
-    else if(this->DiffField == DiffFieldDst)
-      {
+    } else if (this->DiffField == DiffFieldDst) {
       // dst-path
       this->CurChange.Path = this->Line;
       this->Changes.push_back(this->CurChange);
       this->DiffField = this->DiffFieldNone;
-      }
-    return true;
     }
+    return true;
+  }
 
   const char* ConsumeSpace(const char* c)
-    {
-    while(*c && isspace(*c)) { ++c; }
-    return c;
+  {
+    while (*c && isspace(*c)) {
+      ++c;
     }
-  const char* ConsumeField(const char* c)
-    {
-    while(*c && !isspace(*c)) { ++c; }
     return c;
+  }
+  const char* ConsumeField(const char* c)
+  {
+    while (*c && !isspace(*c)) {
+      ++c;
     }
+    return c;
+  }
 };
 
-//----------------------------------------------------------------------------
 /* Commit format:
 
    commit ...\n
@@ -451,18 +446,25 @@ protected:
 
    The header may have more fields.  See 'git help diff-tree'.
 */
-class cmCTestGIT::CommitParser: public cmCTestGIT::DiffParser
+class cmCTestGIT::CommitParser : public cmCTestGIT::DiffParser
 {
 public:
-  CommitParser(cmCTestGIT* git, const char* prefix):
-    DiffParser(git, prefix), Section(SectionHeader)
-    {
+  CommitParser(cmCTestGIT* git, const char* prefix)
+    : DiffParser(git, prefix)
+    , Section(SectionHeader)
+  {
     this->Separator = SectionSep[this->Section];
-    }
+  }
 
 private:
   typedef cmCTestGIT::Revision Revision;
-  enum SectionType { SectionHeader, SectionBody, SectionDiff, SectionCount };
+  enum SectionType
+  {
+    SectionHeader,
+    SectionBody,
+    SectionDiff,
+    SectionCount
+  };
   static char const SectionSep[SectionCount];
   SectionType Section;
   Revision Rev;
@@ -473,142 +475,147 @@ private:
     std::string EMail;
     unsigned long Time;
     long TimeZone;
-    Person(): Name(), EMail(), Time(0), TimeZone(0) {}
+    Person()
+      : Name()
+      , EMail()
+      , Time(0)
+      , TimeZone(0)
+    {
+    }
   };
 
   void ParsePerson(const char* str, Person& person)
-    {
+  {
     // Person Name <person at domain.com> 1234567890 +0000
     const char* c = str;
-    while(*c && isspace(*c)) { ++c; }
+    while (*c && isspace(*c)) {
+      ++c;
+    }
 
     const char* name_first = c;
-    while(*c && *c != '<') { ++c; }
+    while (*c && *c != '<') {
+      ++c;
+    }
     const char* name_last = c;
-    while(name_last != name_first && isspace(*(name_last-1))) { --name_last; }
-    person.Name.assign(name_first, name_last-name_first);
+    while (name_last != name_first && isspace(*(name_last - 1))) {
+      --name_last;
+    }
+    person.Name.assign(name_first, name_last - name_first);
 
-    const char* email_first = *c? ++c : c;
-    while(*c && *c != '>') { ++c; }
-    const char* email_last = *c? c++ : c;
-    person.EMail.assign(email_first, email_last-email_first);
+    const char* email_first = *c ? ++c : c;
+    while (*c && *c != '>') {
+      ++c;
+    }
+    const char* email_last = *c ? c++ : c;
+    person.EMail.assign(email_first, email_last - email_first);
 
     person.Time = strtoul(c, (char**)&c, 10);
     person.TimeZone = strtol(c, (char**)&c, 10);
-    }
+  }
 
   virtual bool ProcessLine()
-    {
-    if(this->Line.empty())
-      {
-      if(this->Section == SectionBody && this->LineEnd == '\0')
-        {
+  {
+    if (this->Line.empty()) {
+      if (this->Section == SectionBody && this->LineEnd == '\0') {
         // Skip SectionDiff
         this->NextSection();
-        }
-      this->NextSection();
       }
-    else
-      {
-      switch(this->Section)
-        {
-        case SectionHeader: this->DoHeaderLine(); break;
-        case SectionBody:   this->DoBodyLine(); break;
-        case SectionDiff:   this->DiffParser::ProcessLine(); break;
-        case SectionCount:  break; // never happens
-        }
+      this->NextSection();
+    } else {
+      switch (this->Section) {
+        case SectionHeader:
+          this->DoHeaderLine();
+          break;
+        case SectionBody:
+          this->DoBodyLine();
+          break;
+        case SectionDiff:
+          this->DiffParser::ProcessLine();
+          break;
+        case SectionCount:
+          break; // never happens
       }
-    return true;
     }
+    return true;
+  }
 
   void NextSection()
-    {
-    this->Section = SectionType((this->Section+1) % SectionCount);
+  {
+    this->Section = SectionType((this->Section + 1) % SectionCount);
     this->Separator = SectionSep[this->Section];
-    if(this->Section == SectionHeader)
-      {
+    if (this->Section == SectionHeader) {
       this->GIT->DoRevision(this->Rev, this->Changes);
       this->Rev = Revision();
       this->DiffReset();
-      }
     }
+  }
 
   void DoHeaderLine()
-    {
+  {
     // Look for header fields that we need.
-    if(cmHasLiteralPrefix(this->Line.c_str(), "commit "))
-      {
-      this->Rev.Rev = this->Line.c_str()+7;
-      }
-    else if(cmHasLiteralPrefix(this->Line.c_str(), "author "))
-      {
+    if (cmHasLiteralPrefix(this->Line.c_str(), "commit ")) {
+      this->Rev.Rev = this->Line.c_str() + 7;
+    } else if (cmHasLiteralPrefix(this->Line.c_str(), "author ")) {
       Person author;
-      this->ParsePerson(this->Line.c_str()+7, author);
+      this->ParsePerson(this->Line.c_str() + 7, author);
       this->Rev.Author = author.Name;
       this->Rev.EMail = author.EMail;
       this->Rev.Date = this->FormatDateTime(author);
-      }
-    else if(cmHasLiteralPrefix(this->Line.c_str(), "committer "))
-      {
+    } else if (cmHasLiteralPrefix(this->Line.c_str(), "committer ")) {
       Person committer;
-      this->ParsePerson(this->Line.c_str()+10, committer);
+      this->ParsePerson(this->Line.c_str() + 10, committer);
       this->Rev.Committer = committer.Name;
       this->Rev.CommitterEMail = committer.EMail;
       this->Rev.CommitDate = this->FormatDateTime(committer);
-      }
     }
+  }
 
   void DoBodyLine()
-    {
+  {
     // Commit log lines are indented by 4 spaces.
-    if(this->Line.size() >= 4)
-      {
+    if (this->Line.size() >= 4) {
       this->Rev.Log += this->Line.substr(4);
-      }
-    this->Rev.Log += "\n";
     }
+    this->Rev.Log += "\n";
+  }
 
   std::string FormatDateTime(Person const& person)
-    {
+  {
     // Convert the time to a human-readable format that is also easy
     // to machine-parse: "CCYY-MM-DD hh:mm:ss".
     time_t seconds = static_cast<time_t>(person.Time);
     struct tm* t = gmtime(&seconds);
     char dt[1024];
-    sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d",
-            t->tm_year+1900, t->tm_mon+1, t->tm_mday,
-            t->tm_hour, t->tm_min, t->tm_sec);
+    sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900,
+            t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
     std::string out = dt;
 
     // Add the time-zone field "+zone" or "-zone".
     char tz[32];
-    if(person.TimeZone >= 0)
-      {
+    if (person.TimeZone >= 0) {
       sprintf(tz, " +%04ld", person.TimeZone);
-      }
-    else
-      {
+    } else {
       sprintf(tz, " -%04ld", -person.TimeZone);
-      }
+    }
     out += tz;
     return out;
-    }
+  }
 };
 
-char const cmCTestGIT::CommitParser::SectionSep[SectionCount] =
-{'\n', '\n', '\0'};
+char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n',
+                                                                  '\0' };
 
-//----------------------------------------------------------------------------
 void cmCTestGIT::LoadRevisions()
 {
   // Use 'git rev-list ... | git diff-tree ...' to get revisions.
   std::string range = this->OldRevision + ".." + this->NewRevision;
   const char* git = this->CommandLineTool.c_str();
-  const char* git_rev_list[] =
-    {git, "rev-list", "--reverse", range.c_str(), "--", 0};
-  const char* git_diff_tree[] =
-    {git, "diff-tree", "--stdin", "--always", "-z", "-r", "--pretty=raw",
-     "--encoding=utf-8", 0};
+  const char* git_rev_list[] = { git,           "rev-list", "--reverse",
+                                 range.c_str(), "--",       0 };
+  const char* git_diff_tree[] = {
+    git,  "diff-tree",    "--stdin",          "--always", "-z",
+    "-r", "--pretty=raw", "--encoding=utf-8", 0
+  };
   this->Log << this->ComputeCommandLine(git_rev_list) << " | "
             << this->ComputeCommandLine(git_diff_tree) << "\n";
 
@@ -627,26 +634,24 @@ void cmCTestGIT::LoadRevisions()
   cmsysProcess_Delete(cp);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGIT::LoadModifications()
 {
   const char* git = this->CommandLineTool.c_str();
 
   // Use 'git update-index' to refresh the index w.r.t. the work tree.
-  const char* git_update_index[] = {git, "update-index", "--refresh", 0};
+  const char* git_update_index[] = { git, "update-index", "--refresh", 0 };
   OutputLogger ui_out(this->Log, "ui-out> ");
   OutputLogger ui_err(this->Log, "ui-err> ");
   this->RunChild(git_update_index, &ui_out, &ui_err);
 
   // Use 'git diff-index' to get modified files.
-  const char* git_diff_index[] = {git, "diff-index", "-z", "HEAD", "--", 0};
+  const char* git_diff_index[] = { git, "diff-index", "-z", "HEAD", "--", 0 };
   DiffParser out(this, "di-out> ");
   OutputLogger err(this->Log, "di-err> ");
   this->RunChild(git_diff_index, &out, &err);
 
-  for(std::vector<Change>::const_iterator ci = out.Changes.begin();
-      ci != out.Changes.end(); ++ci)
-    {
+  for (std::vector<Change>::const_iterator ci = out.Changes.begin();
+       ci != out.Changes.end(); ++ci) {
     this->DoModification(PathModified, ci->Path);
-    }
+  }
 }
diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h
index f4fae8f..685cc31 100644
--- a/Source/CTest/cmCTestGIT.h
+++ b/Source/CTest/cmCTestGIT.h
@@ -18,7 +18,7 @@
  * \brief Interaction with git command-line tool
  *
  */
-class cmCTestGIT: public cmCTestGlobalVC
+class cmCTestGIT : public cmCTestGlobalVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
@@ -44,7 +44,8 @@ private:
   void LoadRevisions();
   void LoadModifications();
 
-public: // needed by older Sun compilers
+  // "public" needed by older Sun compilers
+public:
   // Parsing helper classes.
   class OneLineParser;
   class DiffParser;
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index ad79ba2..18caabe 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -11,11 +11,11 @@
 ============================================================================*/
 
 #include "cmCTestGenericHandler.h"
+
 #include "cmSystemTools.h"
 
 #include "cmCTest.h"
 
-//----------------------------------------------------------------------
 cmCTestGenericHandler::cmCTestGenericHandler()
 {
   this->HandlerVerbose = cmSystemTools::OUTPUT_NONE;
@@ -26,141 +26,120 @@ cmCTestGenericHandler::cmCTestGenericHandler()
   this->TestLoad = 0;
 }
 
-//----------------------------------------------------------------------
 cmCTestGenericHandler::~cmCTestGenericHandler()
 {
 }
 
-//----------------------------------------------------------------------
 void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
 {
-  if ( !value )
-    {
-    cmCTestGenericHandler::t_StringToString::iterator remit
-      = this->Options.find(op);
-    if ( remit != this->Options.end() )
-      {
+  if (!value) {
+    cmCTestGenericHandler::t_StringToString::iterator remit =
+      this->Options.find(op);
+    if (remit != this->Options.end()) {
       this->Options.erase(remit);
-      }
-    return;
     }
+    return;
+  }
 
   this->Options[op] = value;
 }
 
-//----------------------------------------------------------------------
 void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
                                                 const char* value)
 {
   this->SetOption(op, value);
-  if ( !value )
-    {
-    cmCTestGenericHandler::t_StringToString::iterator remit
-      = this->PersistentOptions.find(op);
-    if ( remit != this->PersistentOptions.end() )
-      {
+  if (!value) {
+    cmCTestGenericHandler::t_StringToString::iterator remit =
+      this->PersistentOptions.find(op);
+    if (remit != this->PersistentOptions.end()) {
       this->PersistentOptions.erase(remit);
-      }
-    return;
     }
+    return;
+  }
 
   this->PersistentOptions[op] = value;
 }
 
-//----------------------------------------------------------------------
 void cmCTestGenericHandler::Initialize()
 {
   this->AppendXML = false;
   this->TestLoad = 0;
   this->Options.clear();
   t_StringToString::iterator it;
-  for ( it = this->PersistentOptions.begin();
-    it != this->PersistentOptions.end();
-    ++ it )
-    {
-    this->Options[it->first] = it->second.c_str();
-    }
+  for (it = this->PersistentOptions.begin();
+       it != this->PersistentOptions.end(); ++it) {
+    this->Options[it->first] = it->second;
+  }
 }
 
-//----------------------------------------------------------------------
 const char* cmCTestGenericHandler::GetOption(const std::string& op)
 {
-  cmCTestGenericHandler::t_StringToString::iterator remit
-    = this->Options.find(op);
-  if ( remit == this->Options.end() )
-    {
+  cmCTestGenericHandler::t_StringToString::iterator remit =
+    this->Options.find(op);
+  if (remit == this->Options.end()) {
     return 0;
-    }
+  }
   return remit->second.c_str();
 }
 
-//----------------------------------------------------------------------
 bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
                                               const char* name,
                                               cmGeneratedFileStream& xofs)
 {
-  if ( !name )
-    {
+  if (!name) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot create resulting XML file without providing the name"
-      << std::endl;);
+               "Cannot create resulting XML file without providing the name"
+                 << std::endl;);
     return false;
-    }
+  }
   std::ostringstream ostr;
   ostr << name;
-  if ( this->SubmitIndex > 0 )
-    {
+  if (this->SubmitIndex > 0) {
     ostr << "_" << this->SubmitIndex;
-    }
+  }
   ostr << ".xml";
-  if(this->CTest->GetCurrentTag().empty())
-    {
+  if (this->CTest->GetCurrentTag().empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Current Tag empty, this may mean NightlyStartTime / "
                "CTEST_NIGHTLY_START_TIME was not set correctly. Or "
                "maybe you forgot to call ctest_start() before calling "
-               "ctest_configure()." << std::endl);
+               "ctest_configure()."
+                 << std::endl);
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
-  if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
-      ostr.str(), xofs, true) )
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot create resulting XML file: " << ostr.str()
-      << std::endl);
+  }
+  if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), ostr.str(),
+                                   xofs, true)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create resulting XML file: "
+                 << ostr.str() << std::endl);
     return false;
-    }
+  }
   this->CTest->AddSubmitFile(part, ostr.str().c_str());
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTestGenericHandler::StartLogFile(const char* name,
-  cmGeneratedFileStream& xofs)
+                                         cmGeneratedFileStream& xofs)
 {
-  if ( !name )
-    {
+  if (!name) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot create log file without providing the name" << std::endl;);
+               "Cannot create log file without providing the name"
+                 << std::endl;);
     return false;
-    }
+  }
   std::ostringstream ostr;
   ostr << "Last" << name;
-  if ( this->SubmitIndex > 0 )
-    {
+  if (this->SubmitIndex > 0) {
     ostr << "_" << this->SubmitIndex;
-    }
-  if ( !this->CTest->GetCurrentTag().empty() )
-    {
+  }
+  if (!this->CTest->GetCurrentTag().empty()) {
     ostr << "_" << this->CTest->GetCurrentTag();
-    }
+  }
   ostr << ".log";
-  if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) )
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: "
-      << ostr.str() << std::endl);
+  if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+               "Cannot create log file: " << ostr.str() << std::endl);
     return false;
-    }
+  }
   return true;
 }
diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h
index 4b7ae79..ad349ac 100644
--- a/Source/CTest/cmCTestGenericHandler.h
+++ b/Source/CTest/cmCTestGenericHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestGenericHandler_h
 #define cmCTestGenericHandler_h
 
-
 #include "cmObject.h"
+
 #include "cmCTest.h"
 #include "cmSystemTools.h" //OutputOption
 
@@ -33,13 +33,15 @@ public:
    * If verbose then more informaiton is printed out
    */
   void SetVerbose(bool val)
-    { this->HandlerVerbose = val ?
-      cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
+  {
+    this->HandlerVerbose =
+      val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
+  }
 
   /**
    * Populate internals from CTest custom scripts
    */
-  virtual void PopulateCustomVectors(cmMakefile *) {}
+  virtual void PopulateCustomVectors(cmMakefile*) {}
 
   /**
    * Do the actual processing. Subclass has to override it.
@@ -52,7 +54,10 @@ public:
    */
   virtual int ProcessCommandLineArguments(
     const std::string& /*currentArg*/, size_t& /*idx*/,
-    const std::vector<std::string>& /*allArgs*/) { return 1; }
+    const std::vector<std::string>& /*allArgs*/)
+  {
+    return 1;
+  }
 
   /**
    * Initialize handler
@@ -71,17 +76,13 @@ public:
   cmCTestGenericHandler();
   virtual ~cmCTestGenericHandler();
 
-  typedef std::map<std::string,std::string> t_StringToString;
-
+  typedef std::map<std::string, std::string> t_StringToString;
 
   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)
-    {
-    this->Command = command;
-    }
+  void SetCommand(cmCTestCommand* command) { this->Command = command; }
 
   void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
   int GetSubmitIndex() { return this->SubmitIndex; }
@@ -90,18 +91,18 @@ public:
   void SetQuiet(bool b) { this->Quiet = b; }
   bool GetQuiet() { return this->Quiet; }
   void SetTestLoad(unsigned long load) { this->TestLoad = load; }
-  unsigned long GetTestLoad() const { return this->TestLoad;  }
+  unsigned long GetTestLoad() const { return this->TestLoad; }
 
 protected:
-  bool StartResultingXML(cmCTest::Part part,
-                         const char* name, cmGeneratedFileStream& xofs);
+  bool StartResultingXML(cmCTest::Part part, const char* name,
+                         cmGeneratedFileStream& xofs);
   bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
 
   bool AppendXML;
   bool Quiet;
   unsigned long TestLoad;
   cmSystemTools::OutputOption HandlerVerbose;
-  cmCTest *CTest;
+  cmCTest* CTest;
   t_StringToString Options;
   t_StringToString PersistentOptions;
 
@@ -110,4 +111,3 @@ protected:
 };
 
 #endif
-
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index c091ec4..0c7ca4d 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -17,34 +17,29 @@
 
 #include <cmsys/RegularExpression.hxx>
 
-//----------------------------------------------------------------------------
-cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log):
-  cmCTestVC(ct, log)
+cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log)
+  : cmCTestVC(ct, log)
 {
   this->PriorRev = this->Unknown;
 }
 
-//----------------------------------------------------------------------------
 cmCTestGlobalVC::~cmCTestGlobalVC()
 {
 }
 
-//----------------------------------------------------------------------------
 const char* cmCTestGlobalVC::LocalPath(std::string const& path)
 {
   return path.c_str();
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGlobalVC::DoRevision(Revision const& revision,
                                  std::vector<Change> const& changes)
 {
   // Ignore changes in the old revision.
-  if(revision.Rev == this->OldRevision)
-    {
+  if (revision.Rev == this->OldRevision) {
     this->PriorRev = revision;
     return;
-    }
+  }
 
   // Indicate we found a revision.
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
@@ -54,27 +49,27 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
 
   // Report this revision.
   Revision const& rev = this->Revisions.back();
+  /* clang-format off */
   this->Log << "Found revision " << rev.Rev << "\n"
             << "  author = " << rev.Author << "\n"
             << "  date = " << rev.Date << "\n";
+  /* clang-format on */
 
   // Update information about revisions of the changed files.
-  for(std::vector<Change>::const_iterator ci = changes.begin();
-      ci != changes.end(); ++ci)
-    {
-    if(const char* local = this->LocalPath(ci->Path))
-      {
+  for (std::vector<Change>::const_iterator ci = changes.begin();
+       ci != changes.end(); ++ci) {
+    if (const char* local = this->LocalPath(ci->Path)) {
       std::string dir = cmSystemTools::GetFilenamePath(local);
       std::string name = cmSystemTools::GetFilenameName(local);
       File& file = this->Dirs[dir][name];
-      file.PriorRev = file.Rev? file.Rev : &this->PriorRev;
+      file.PriorRev = file.Rev ? file.Rev : &this->PriorRev;
       file.Rev = &rev;
-      this->Log << "  " << ci->Action << " " << local << " " << "\n";
-      }
+      this->Log << "  " << ci->Action << " " << local << " "
+                << "\n";
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGlobalVC::DoModification(PathStatus status,
                                      std::string const& path)
 {
@@ -84,47 +79,41 @@ void cmCTestGlobalVC::DoModification(PathStatus status,
   file.Status = status;
   // For local modifications the current rev is unknown and the
   // prior rev is the latest from svn.
-  if(!file.Rev && !file.PriorRev)
-    {
+  if (!file.Rev && !file.PriorRev) {
     file.PriorRev = &this->PriorRev;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
                                         std::string const& path,
                                         Directory const& dir)
 {
-  const char* slash = path.empty()? "":"/";
+  const char* slash = path.empty() ? "" : "/";
   xml.StartElement("Directory");
   xml.Element("Name", path);
-  for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
-    {
+  for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
     std::string full = path + slash + fi->first;
     this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
-    }
+  }
   xml.EndElement(); // Directory
 }
 
-//----------------------------------------------------------------------------
 void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
 {
-  if(!this->NewRevision.empty())
-    {
+  if (!this->NewRevision.empty()) {
     xml.Element("Revision", this->NewRevision);
-    }
-  if(!this->OldRevision.empty() && this->OldRevision != this->NewRevision)
-    {
+  }
+  if (!this->OldRevision.empty() && this->OldRevision != this->NewRevision) {
     xml.Element("PriorRevision", this->OldRevision);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
 {
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              "   Gathering version information (one . per revision):\n"
-             "    " << std::flush);
+             "    "
+               << std::flush);
   this->LoadRevisions();
   cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
 
@@ -132,11 +121,11 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
 
   this->WriteXMLGlobal(xml);
 
-  for(std::map<std::string, Directory>::const_iterator
-        di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
-    {
+  for (std::map<std::string, Directory>::const_iterator di =
+         this->Dirs.begin();
+       di != this->Dirs.end(); ++di) {
     this->WriteXMLDirectory(xml, di->first, di->second);
-    }
+  }
 
   return true;
 }
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index d0e9410..9a5357f 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -20,7 +20,7 @@
  * \brief Base class for handling globally-versioned trees
  *
  */
-class cmCTestGlobalVC: public cmCTestVC
+class cmCTestGlobalVC : public cmCTestVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
@@ -37,11 +37,16 @@ protected:
   {
     char Action;
     std::string Path;
-    Change(char a = '?'): Action(a) {}
+    Change(char a = '?')
+      : Action(a)
+    {
+    }
   };
 
   // Update status for files in each directory.
-  class Directory: public std::map<std::string, File> {};
+  class Directory : public std::map<std::string, File>
+  {
+  };
   std::map<std::string, Directory> Dirs;
 
   // Old and new repository revisions.
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 0f79d68..c6cfa44 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -17,89 +17,90 @@
 
 #include <cmsys/RegularExpression.hxx>
 
-//----------------------------------------------------------------------------
-cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log):
-  cmCTestGlobalVC(ct, log)
+cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log)
+  : cmCTestGlobalVC(ct, log)
 {
   this->PriorRev = this->Unknown;
 }
 
-//----------------------------------------------------------------------------
 cmCTestHG::~cmCTestHG()
 {
 }
 
-//----------------------------------------------------------------------------
-class cmCTestHG::IdentifyParser: public cmCTestVC::LineParser
+class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser
 {
 public:
-  IdentifyParser(cmCTestHG* hg, const char* prefix,
-                 std::string& rev): Rev(rev)
-    {
+  IdentifyParser(cmCTestHG* hg, const char* prefix, std::string& rev)
+    : Rev(rev)
+  {
     this->SetLog(&hg->Log, prefix);
     this->RegexIdentify.compile("^([0-9a-f]+)");
-    }
+  }
+
 private:
   std::string& Rev;
   cmsys::RegularExpression RegexIdentify;
 
   bool ProcessLine()
-    {
-    if(this->RegexIdentify.find(this->Line))
-      {
+  {
+    if (this->RegexIdentify.find(this->Line)) {
       this->Rev = this->RegexIdentify.match(1);
       return false;
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
-class cmCTestHG::StatusParser: public cmCTestVC::LineParser
+class cmCTestHG::StatusParser : public cmCTestVC::LineParser
 {
 public:
-  StatusParser(cmCTestHG* hg, const char* prefix): HG(hg)
-    {
+  StatusParser(cmCTestHG* hg, const char* prefix)
+    : HG(hg)
+  {
     this->SetLog(&hg->Log, prefix);
     this->RegexStatus.compile("([MARC!?I]) (.*)");
-    }
+  }
 
 private:
   cmCTestHG* HG;
   cmsys::RegularExpression RegexStatus;
 
   bool ProcessLine()
-    {
-    if(this->RegexStatus.find(this->Line))
-      {
-      this->DoPath(this->RegexStatus.match(1)[0],
-                   this->RegexStatus.match(2));
-      }
-    return true;
+  {
+    if (this->RegexStatus.find(this->Line)) {
+      this->DoPath(this->RegexStatus.match(1)[0], this->RegexStatus.match(2));
     }
+    return true;
+  }
 
   void DoPath(char status, std::string const& path)
-    {
-    if(path.empty()) return;
+  {
+    if (path.empty())
+      return;
 
     // See "hg help status".  Note that there is no 'conflict' status.
-    switch(status)
-      {
-      case 'M': case 'A': case '!': case 'R':
+    switch (status) {
+      case 'M':
+      case 'A':
+      case '!':
+      case 'R':
         this->HG->DoModification(PathModified, path);
         break;
-      case 'I': case '?': case 'C': case ' ': default:
+      case 'I':
+      case '?':
+      case 'C':
+      case ' ':
+      default:
         break;
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
 std::string cmCTestHG::GetWorkingRevision()
 {
   // Run plumbing "hg identify" to get work tree revision.
   const char* hg = this->CommandLineTool.c_str();
-  const char* hg_identify[] = {hg, "identify","-i", 0};
+  const char* hg_identify[] = { hg, "identify", "-i", 0 };
   std::string rev;
   IdentifyParser out(this, "rev-out> ", rev);
   OutputLogger err(this->Log, "rev-err> ");
@@ -107,33 +108,30 @@ std::string cmCTestHG::GetWorkingRevision()
   return rev;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestHG::NoteOldRevision()
 {
   this->OldRevision = this->GetWorkingRevision();
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Old revision of repository is: "
-             << this->OldRevision << "\n");
+               << this->OldRevision << "\n");
   this->PriorRev.Rev = this->OldRevision;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestHG::NoteNewRevision()
 {
   this->NewRevision = this->GetWorkingRevision();
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   New revision of repository is: "
-             << this->NewRevision << "\n");
+               << this->NewRevision << "\n");
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestHG::UpdateImpl()
 {
   // Use "hg pull" followed by "hg update" to update the working tree.
   {
-  const char* hg = this->CommandLineTool.c_str();
-  const char* hg_pull[] = {hg, "pull","-v", 0};
-  OutputLogger out(this->Log, "pull-out> ");
-  OutputLogger err(this->Log, "pull-err> ");
-  this->RunChild(&hg_pull[0], &out, &err);
+    const char* hg = this->CommandLineTool.c_str();
+    const char* hg_pull[] = { hg, "pull", "-v", 0 };
+    OutputLogger out(this->Log, "pull-out> ");
+    OutputLogger err(this->Log, "pull-err> ");
+    this->RunChild(&hg_pull[0], &out, &err);
   }
 
   // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -145,16 +143,14 @@ bool cmCTestHG::UpdateImpl()
 
   // Add user-specified update options.
   std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
-  if(opts.empty())
-    {
+  if (opts.empty()) {
     opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
-    }
+  }
   std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     hg_update.push_back(ai->c_str());
-    }
+  }
 
   // Sentinel argument.
   hg_update.push_back(0);
@@ -164,13 +160,16 @@ bool cmCTestHG::UpdateImpl()
   return this->RunUpdateCommand(&hg_update[0], &out, &err);
 }
 
-//----------------------------------------------------------------------------
-class cmCTestHG::LogParser: public cmCTestVC::OutputLogger,
-                            private cmXMLParser
+class cmCTestHG::LogParser : public cmCTestVC::OutputLogger,
+                             private cmXMLParser
 {
 public:
-  LogParser(cmCTestHG* hg, const char* prefix):
-    OutputLogger(hg->Log, prefix), HG(hg) { this->InitializeParser(); }
+  LogParser(cmCTestHG* hg, const char* prefix)
+    : OutputLogger(hg->Log, prefix)
+    , HG(hg)
+  {
+    this->InitializeParser();
+  }
   ~LogParser() { this->CleanupParser(); }
 private:
   cmCTestHG* HG;
@@ -183,117 +182,90 @@ private:
   std::vector<char> CData;
 
   virtual bool ProcessChunk(const char* data, int length)
-    {
+  {
     this->OutputLogger::ProcessChunk(data, length);
     this->ParseChunk(data, length);
     return true;
-    }
+  }
 
   virtual void StartElement(const std::string& name, const char** atts)
-    {
+  {
     this->CData.clear();
-    if(name == "logentry")
-      {
+    if (name == "logentry") {
       this->Rev = Revision();
-      if(const char* rev = this->FindAttribute(atts, "revision"))
-        {
+      if (const char* rev = this->FindAttribute(atts, "revision")) {
         this->Rev.Rev = rev;
-        }
-      this->Changes.clear();
       }
+      this->Changes.clear();
     }
+  }
 
   virtual void CharacterDataHandler(const char* data, int length)
-    {
-    this->CData.insert(this->CData.end(), data, data+length);
-    }
+  {
+    this->CData.insert(this->CData.end(), data, data + length);
+  }
 
   virtual void EndElement(const std::string& name)
-    {
-    if(name == "logentry")
-      {
+  {
+    if (name == "logentry") {
       this->HG->DoRevision(this->Rev, this->Changes);
-      }
-    else if(!this->CData.empty() && name == "author")
-      {
+    } else if (!this->CData.empty() && name == "author") {
       this->Rev.Author.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "email")
-      {
+    } else if (!this->CData.empty() && name == "email") {
       this->Rev.EMail.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "date")
-      {
+    } else if (!this->CData.empty() && name == "date") {
       this->Rev.Date.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "msg")
-      {
+    } else if (!this->CData.empty() && name == "msg") {
       this->Rev.Log.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "files")
-      {
+    } else if (!this->CData.empty() && name == "files") {
       std::vector<std::string> paths = this->SplitCData();
-      for(unsigned int i = 0; i < paths.size(); ++i)
-        {
+      for (unsigned int i = 0; i < paths.size(); ++i) {
         // Updated by default, will be modified using file_adds and
         // file_dels.
         this->CurChange = Change('U');
         this->CurChange.Path = paths[i];
         this->Changes.push_back(this->CurChange);
-        }
       }
-    else if(!this->CData.empty() && name == "file_adds")
-      {
+    } 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)
-        {
-        if(added_paths.find(this->Changes[i].Path) != std::string::npos)
-          {
+      for (unsigned int i = 0; i < this->Changes.size(); ++i) {
+        if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
           this->Changes[i].Action = 'A';
-          }
         }
       }
-     else if(!this->CData.empty() && name == "file_dels")
-      {
+    } 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)
-        {
-        if(added_paths.find(this->Changes[i].Path) != std::string::npos)
-          {
+      for (unsigned int i = 0; i < this->Changes.size(); ++i) {
+        if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
           this->Changes[i].Action = 'D';
-          }
         }
       }
-    this->CData.clear();
     }
+    this->CData.clear();
+  }
 
   std::vector<std::string> SplitCData()
-    {
+  {
     std::vector<std::string> output;
     std::string currPath;
-    for(unsigned int i=0; i < this->CData.size(); ++i)
-      {
-      if(this->CData[i] != ' ')
-        {
+    for (unsigned int i = 0; i < this->CData.size(); ++i) {
+      if (this->CData[i] != ' ') {
         currPath += this->CData[i];
-        }
-      else
-        {
+      } else {
         output.push_back(currPath);
         currPath = "";
-        }
       }
+    }
     output.push_back(currPath);
     return output;
-    }
+  }
 
   virtual void ReportError(int, int, const char* msg)
-    {
+  {
     this->HG->Log << "Error parsing hg log xml: " << msg << "\n";
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmCTestHG::LoadRevisions()
 {
   // Use 'hg log' to get revisions in a xml format.
@@ -304,19 +276,19 @@ void cmCTestHG::LoadRevisions()
   // proper XML escapes.
   std::string range = this->OldRevision + ":" + this->NewRevision;
   const char* hg = this->CommandLineTool.c_str();
-  const char* hgXMLTemplate =
-    "<logentry\n"
-    "   revision=\"{node|short}\">\n"
-    "  <author>{author|person}</author>\n"
-    "  <email>{author|email}</email>\n"
-    "  <date>{date|isodate}</date>\n"
-    "  <msg>{desc}</msg>\n"
-    "  <files>{files}</files>\n"
-    "  <file_adds>{file_adds}</file_adds>\n"
-    "  <file_dels>{file_dels}</file_dels>\n"
-    "</logentry>\n";
-  const char* hg_log[] = {hg, "log","--removed", "-r", range.c_str(),
-                          "--template", hgXMLTemplate, 0};
+  const char* hgXMLTemplate = "<logentry\n"
+                              "   revision=\"{node|short}\">\n"
+                              "  <author>{author|person}</author>\n"
+                              "  <email>{author|email}</email>\n"
+                              "  <date>{date|isodate}</date>\n"
+                              "  <msg>{desc}</msg>\n"
+                              "  <files>{files}</files>\n"
+                              "  <file_adds>{file_adds}</file_adds>\n"
+                              "  <file_dels>{file_dels}</file_dels>\n"
+                              "</logentry>\n";
+  const char* hg_log[] = {
+    hg, "log", "--removed", "-r", range.c_str(), "--template", hgXMLTemplate, 0
+  };
 
   LogParser out(this, "log-out> ");
   out.Process("<?xml version=\"1.0\"?>\n"
@@ -326,12 +298,11 @@ void cmCTestHG::LoadRevisions()
   out.Process("</log>\n");
 }
 
-//----------------------------------------------------------------------------
 void cmCTestHG::LoadModifications()
 {
   // Use 'hg status' to get modified files.
   const char* hg = this->CommandLineTool.c_str();
-  const char* hg_status[] = {hg, "status", 0};
+  const char* hg_status[] = { hg, "status", 0 };
   StatusParser out(this, "status-out> ");
   OutputLogger err(this->Log, "status-err> ");
   this->RunChild(hg_status, &out, &err);
diff --git a/Source/CTest/cmCTestHG.h b/Source/CTest/cmCTestHG.h
index 1eaf933..8cc8c7a 100644
--- a/Source/CTest/cmCTestHG.h
+++ b/Source/CTest/cmCTestHG.h
@@ -18,7 +18,7 @@
  * \brief Interaction with Mercurial command-line tool
  *
  */
-class cmCTestHG: public cmCTestGlobalVC
+class cmCTestHG : public cmCTestGlobalVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 3579aee..76f971d 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -19,10 +19,9 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
   const size_t INIT_SIZE = 100;
   size_t cc;
   this->Arguments.reserve(INIT_SIZE);
-  for ( cc = 0; cc < INIT_SIZE; ++ cc )
-    {
+  for (cc = 0; cc < INIT_SIZE; ++cc) {
     this->Arguments.push_back(0);
-    }
+  }
   this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
   this->Arguments[ct_SOURCE] = "SOURCE";
   this->Arguments[ct_BUILD] = "BUILD";
@@ -32,8 +31,8 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
   this->Quiet = false;
 }
 
-bool cmCTestHandlerCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
+                                        cmExecutionStatus&)
 {
   // Allocate space for argument values.
   this->Values.clear();
@@ -41,24 +40,21 @@ bool cmCTestHandlerCommand
 
   // Process input arguments.
   this->ArgumentDoing = ArgumentDoingNone;
-  for(unsigned int i=0; i < args.size(); ++i)
-    {
+  for (unsigned int i = 0; i < args.size(); ++i) {
     // Check this argument.
-    if(!this->CheckArgumentKeyword(args[i]) &&
-       !this->CheckArgumentValue(args[i]))
-      {
+    if (!this->CheckArgumentKeyword(args[i]) &&
+        !this->CheckArgumentValue(args[i])) {
       std::ostringstream e;
       e << "called with unknown argument \"" << args[i] << "\".";
       this->SetError(e.str());
       return false;
-      }
+    }
 
     // Quit if an argument is invalid.
-    if(this->ArgumentDoing == ArgumentDoingError)
-      {
+    if (this->ArgumentDoing == ArgumentDoingError) {
       return false;
-      }
     }
+  }
 
   // Set the config type of this ctest to the current value of the
   // CTEST_CONFIGURATION_TYPE script variable if it is defined.
@@ -66,147 +62,128 @@ bool cmCTestHandlerCommand
   // line.
   const char* ctestConfigType =
     this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE");
-  if (ctestConfigType)
-    {
+  if (ctestConfigType) {
     this->CTest->SetConfigType(ctestConfigType);
-    }
+  }
 
-  if ( this->Values[ct_BUILD] )
-    {
-    this->CTest->SetCTestConfiguration("BuildDirectory",
-      cmSystemTools::CollapseFullPath(
-        this->Values[ct_BUILD]).c_str(), this->Quiet);
-    }
-  else
-    {
+  if (this->Values[ct_BUILD]) {
+    this->CTest->SetCTestConfiguration(
+      "BuildDirectory",
+      cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(),
+      this->Quiet);
+  } else {
     const char* bdir =
       this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
-    if(bdir)
-      {
-      this->
-        CTest->SetCTestConfiguration("BuildDirectory",
-          cmSystemTools::CollapseFullPath(bdir).c_str(), this->Quiet);
-      }
-    else
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-                 "CTEST_BINARY_DIRECTORY not set" << std::endl;);
-      }
-    }
-  if ( this->Values[ct_SOURCE] )
-    {
-    cmCTestLog(this->CTest, DEBUG,
-      "Set source directory to: " << this->Values[ct_SOURCE] << std::endl);
-    this->CTest->SetCTestConfiguration("SourceDirectory",
-      cmSystemTools::CollapseFullPath(
-        this->Values[ct_SOURCE]).c_str(), this->Quiet);
+    if (bdir) {
+      this->CTest->SetCTestConfiguration(
+        "BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(),
+        this->Quiet);
+    } else {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "CTEST_BINARY_DIRECTORY not set"
+                   << std::endl;);
     }
-  else
-    {
-    this->CTest->SetCTestConfiguration("SourceDirectory",
+  }
+  if (this->Values[ct_SOURCE]) {
+    cmCTestLog(this->CTest, DEBUG, "Set source directory to: "
+                 << this->Values[ct_SOURCE] << std::endl);
+    this->CTest->SetCTestConfiguration(
+      "SourceDirectory",
+      cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
+      this->Quiet);
+  } else {
+    this->CTest->SetCTestConfiguration(
+      "SourceDirectory",
       cmSystemTools::CollapseFullPath(
-        this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")).c_str(),
+        this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"))
+        .c_str(),
       this->Quiet);
-    }
+  }
 
-  if(const char* changeId =
-     this->Makefile->GetDefinition("CTEST_CHANGE_ID"))
-    {
+  if (const char* changeId =
+        this->Makefile->GetDefinition("CTEST_CHANGE_ID")) {
     this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet);
-    }
+  }
 
   cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
   cmCTestGenericHandler* handler = this->InitializeHandler();
-  if ( !handler )
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Cannot instantiate test handler " << this->GetName()
-               << std::endl);
+  if (!handler) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot instantiate test handler "
+                 << this->GetName() << std::endl);
     return false;
-    }
+  }
 
   handler->SetAppendXML(this->AppendXML);
 
   handler->PopulateCustomVectors(this->Makefile);
-  if ( this->Values[ct_SUBMIT_INDEX] )
-    {
-    if(!this->CTest->GetDropSiteCDash() && this->CTest->GetDartVersion() <= 1)
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
+  if (this->Values[ct_SUBMIT_INDEX]) {
+    if (!this->CTest->GetDropSiteCDash() &&
+        this->CTest->GetDartVersion() <= 1) {
+      cmCTestLog(
+        this->CTest, ERROR_MESSAGE,
         "Dart before version 2.0 does not support collecting submissions."
-        << std::endl
-        << "Please upgrade the server to Dart 2 or higher, or do not use "
-        "SUBMIT_INDEX." << std::endl);
-      }
-    else
-      {
+          << std::endl
+          << "Please upgrade the server to Dart 2 or higher, or do not use "
+             "SUBMIT_INDEX."
+          << std::endl);
+    } else {
       handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
-      }
     }
+  }
   std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
   cmSystemTools::ChangeDirectory(
     this->CTest->GetCTestConfiguration("BuildDirectory"));
   int res = handler->ProcessHandler();
-  if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE])
-    {
+  if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
     std::ostringstream str;
     str << res;
-    this->Makefile->AddDefinition(
-      this->Values[ct_RETURN_VALUE], str.str().c_str());
-    }
+    this->Makefile->AddDefinition(this->Values[ct_RETURN_VALUE],
+                                  str.str().c_str());
+  }
   cmSystemTools::ChangeDirectory(current_dir);
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg)
 {
   // Look for non-value arguments common to all commands.
-  if(arg == "APPEND")
-    {
+  if (arg == "APPEND") {
     this->ArgumentDoing = ArgumentDoingNone;
     this->AppendXML = true;
     return true;
-    }
-  if(arg == "QUIET")
-    {
+  }
+  if (arg == "QUIET") {
     this->ArgumentDoing = ArgumentDoingNone;
     this->Quiet = true;
     return true;
-    }
+  }
 
   // Check for a keyword in our argument/value table.
-  for(unsigned int k=0; k < this->Arguments.size(); ++k)
-    {
-    if(this->Arguments[k] && arg == this->Arguments[k])
-      {
+  for (unsigned int k = 0; k < this->Arguments.size(); ++k) {
+    if (this->Arguments[k] && arg == this->Arguments[k]) {
       this->ArgumentDoing = ArgumentDoingKeyword;
       this->ArgumentIndex = k;
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg)
 {
-  if(this->ArgumentDoing == ArgumentDoingKeyword)
-    {
+  if (this->ArgumentDoing == ArgumentDoingKeyword) {
     this->ArgumentDoing = ArgumentDoingNone;
     unsigned int k = this->ArgumentIndex;
-    if(this->Values[k])
-      {
+    if (this->Values[k]) {
       std::ostringstream e;
       e << "Called with more than one value for " << this->Arguments[k];
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       this->ArgumentDoing = ArgumentDoingError;
       return true;
-      }
+    }
     this->Values[k] = arg.c_str();
-    cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k]
-               << " to " << arg << "\n");
+    cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k] << " to "
+                                          << arg << "\n");
     return true;
-    }
+  }
   return false;
 }
diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h
index 87b2cd8..7248832 100644
--- a/Source/CTest/cmCTestHandlerCommand.h
+++ b/Source/CTest/cmCTestHandlerCommand.h
@@ -31,19 +31,19 @@ public:
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   cmTypeMacro(cmCTestHandlerCommand, cmCTestCommand);
 
   enum
-    {
+  {
     ct_NONE,
     ct_RETURN_VALUE,
     ct_BUILD,
     ct_SOURCE,
     ct_SUBMIT_INDEX,
     ct_LAST
-    };
+  };
 
 protected:
   virtual cmCTestGenericHandler* InitializeHandler() = 0;
@@ -70,9 +70,9 @@ protected:
   size_t Last;
 };
 
-#define CTEST_COMMAND_APPEND_OPTION_DOCS \
-  "The APPEND option marks results for append to those previously " \
-  "submitted to a dashboard server since the last ctest_start.  " \
+#define CTEST_COMMAND_APPEND_OPTION_DOCS                                      \
+  "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."
 
 #endif
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 749a5be..4a408a2 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -16,18 +16,17 @@
 #include "cmXMLWriter.h"
 #include "cmake.h"
 
+#include <cmsys/FStream.hxx>
 #include <cmsys/MD5.h>
 #include <cmsys/Process.h>
 #include <cmsys/RegularExpression.hxx>
-#include <cmsys/FStream.hxx>
 
 #ifdef _WIN32
-#include <io.h> // for _setmode
 #include <fcntl.h> // for _O_BINARY
+#include <io.h>    // for _setmode
 #include <stdio.h> // for std{out,err} and fileno
 #endif
 
-//----------------------------------------------------------------------------
 cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
 {
   this->Passthru = true;
@@ -35,10 +34,9 @@ cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
   this->ExitCode = 1;
   this->CWD = cmSystemTools::GetCurrentWorkingDirectory();
 
-  if(!this->ParseArguments(argc, argv))
-    {
+  if (!this->ParseArguments(argc, argv)) {
     return;
-    }
+  }
 
   this->ComputeFileNames();
 
@@ -48,158 +46,118 @@ cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
   this->Process = cmsysProcess_New();
 }
 
-//----------------------------------------------------------------------------
 cmCTestLaunch::~cmCTestLaunch()
 {
   cmsysProcess_Delete(this->Process);
-  if(!this->Passthru)
-    {
+  if (!this->Passthru) {
     cmSystemTools::RemoveFile(this->LogOut);
     cmSystemTools::RemoveFile(this->LogErr);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv)
 {
   // Launcher options occur first and are separated from the real
   // command line by a '--' option.
-  enum Doing { DoingNone,
-               DoingOutput,
-               DoingSource,
-               DoingLanguage,
-               DoingTargetName,
-               DoingTargetType,
-               DoingBuildDir,
-               DoingCount,
-               DoingFilterPrefix };
+  enum Doing
+  {
+    DoingNone,
+    DoingOutput,
+    DoingSource,
+    DoingLanguage,
+    DoingTargetName,
+    DoingTargetType,
+    DoingBuildDir,
+    DoingCount,
+    DoingFilterPrefix
+  };
   Doing doing = DoingNone;
   int arg0 = 0;
-  for(int i=1; !arg0 && i < argc; ++i)
-    {
+  for (int i = 1; !arg0 && i < argc; ++i) {
     const char* arg = argv[i];
-    if(strcmp(arg, "--") == 0)
-      {
-      arg0 = i+1;
-      }
-    else if(strcmp(arg, "--output") == 0)
-      {
+    if (strcmp(arg, "--") == 0) {
+      arg0 = i + 1;
+    } else if (strcmp(arg, "--output") == 0) {
       doing = DoingOutput;
-      }
-    else if(strcmp(arg, "--source") == 0)
-      {
+    } else if (strcmp(arg, "--source") == 0) {
       doing = DoingSource;
-      }
-    else if(strcmp(arg, "--language") == 0)
-      {
+    } else if (strcmp(arg, "--language") == 0) {
       doing = DoingLanguage;
-      }
-    else if(strcmp(arg, "--target-name") == 0)
-      {
+    } else if (strcmp(arg, "--target-name") == 0) {
       doing = DoingTargetName;
-      }
-    else if(strcmp(arg, "--target-type") == 0)
-      {
+    } else if (strcmp(arg, "--target-type") == 0) {
       doing = DoingTargetType;
-      }
-    else if(strcmp(arg, "--build-dir") == 0)
-      {
+    } else if (strcmp(arg, "--build-dir") == 0) {
       doing = DoingBuildDir;
-      }
-    else if(strcmp(arg, "--filter-prefix") == 0)
-      {
+    } else if (strcmp(arg, "--filter-prefix") == 0) {
       doing = DoingFilterPrefix;
-      }
-    else if(doing == DoingOutput)
-      {
+    } else if (doing == DoingOutput) {
       this->OptionOutput = arg;
       doing = DoingNone;
-      }
-    else if(doing == DoingSource)
-      {
+    } else if (doing == DoingSource) {
       this->OptionSource = arg;
       doing = DoingNone;
-      }
-    else if(doing == DoingLanguage)
-      {
+    } else if (doing == DoingLanguage) {
       this->OptionLanguage = arg;
-      if(this->OptionLanguage == "CXX")
-        {
+      if (this->OptionLanguage == "CXX") {
         this->OptionLanguage = "C++";
-        }
-      doing = DoingNone;
       }
-    else if(doing == DoingTargetName)
-      {
+      doing = DoingNone;
+    } else if (doing == DoingTargetName) {
       this->OptionTargetName = arg;
       doing = DoingNone;
-      }
-    else if(doing == DoingTargetType)
-      {
+    } else if (doing == DoingTargetType) {
       this->OptionTargetType = arg;
       doing = DoingNone;
-      }
-    else if(doing == DoingBuildDir)
-      {
+    } else if (doing == DoingBuildDir) {
       this->OptionBuildDir = arg;
       doing = DoingNone;
-      }
-    else if(doing == DoingFilterPrefix)
-      {
+    } else if (doing == DoingFilterPrefix) {
       this->OptionFilterPrefix = arg;
       doing = DoingNone;
-      }
     }
+  }
 
   // Extract the real command line.
-  if(arg0)
-    {
+  if (arg0) {
     this->RealArgC = argc - arg0;
     this->RealArgV = argv + arg0;
-    for(int i=0; i < this->RealArgC; ++i)
-      {
+    for (int i = 0; i < this->RealArgC; ++i) {
       this->HandleRealArg(this->RealArgV[i]);
-      }
-    return true;
     }
-  else
-    {
+    return true;
+  } else {
     this->RealArgC = 0;
     this->RealArgV = 0;
     std::cerr << "No launch/command separator ('--') found!\n";
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::HandleRealArg(const char* arg)
 {
 #ifdef _WIN32
   // Expand response file arguments.
-  if(arg[0] == '@' && cmSystemTools::FileExists(arg+1))
-    {
-    cmsys::ifstream fin(arg+1);
+  if (arg[0] == '@' && cmSystemTools::FileExists(arg + 1)) {
+    cmsys::ifstream fin(arg + 1);
     std::string line;
-    while(cmSystemTools::GetLineFromStream(fin, line))
-      {
+    while (cmSystemTools::GetLineFromStream(fin, line)) {
       cmSystemTools::ParseWindowsCommandLine(line.c_str(), this->RealArgs);
-      }
-    return;
     }
+    return;
+  }
 #endif
   this->RealArgs.push_back(arg);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::ComputeFileNames()
 {
   // We just passthru the behavior of the real command unless the
   // CTEST_LAUNCH_LOGS environment variable is set.
   const char* d = getenv("CTEST_LAUNCH_LOGS");
-  if(!(d && *d))
-    {
+  if (!(d && *d)) {
     return;
-    }
+  }
   this->Passthru = false;
 
   // The environment variable specifies the directory into which we
@@ -214,11 +172,10 @@ void cmCTestLaunch::ComputeFileNames()
   cmsysMD5* md5 = cmsysMD5_New();
   cmsysMD5_Initialize(md5);
   cmsysMD5_Append(md5, (unsigned char const*)(this->CWD.c_str()), -1);
-  for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
-      ai != this->RealArgs.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
+       ai != this->RealArgs.end(); ++ai) {
     cmsysMD5_Append(md5, (unsigned char const*)ai->c_str(), -1);
-    }
+  }
   cmsysMD5_FinalizeHex(md5, hash);
   cmsysMD5_Delete(md5);
   this->LogHash.assign(hash, 32);
@@ -234,15 +191,13 @@ void cmCTestLaunch::ComputeFileNames()
   this->LogErr += "-err.txt";
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::RunChild()
 {
   // Ignore noopt make rules
-  if(this->RealArgs.empty() || this->RealArgs[0] == ":")
-    {
+  if (this->RealArgs.empty() || this->RealArgs[0] == ":") {
     this->ExitCode = 0;
     return;
-    }
+  }
 
   // Prepare to run the real command.
   cmsysProcess* cp = this->Process;
@@ -250,20 +205,15 @@ void cmCTestLaunch::RunChild()
 
   cmsys::ofstream fout;
   cmsys::ofstream ferr;
-  if(this->Passthru)
-    {
+  if (this->Passthru) {
     // In passthru mode we just share the output pipes.
     cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
     cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
-    }
-  else
-    {
+  } else {
     // In full mode we record the child output pipes to log files.
-    fout.open(this->LogOut.c_str(),
-              std::ios::out | std::ios::binary);
-    ferr.open(this->LogErr.c_str(),
-              std::ios::out | std::ios::binary);
-    }
+    fout.open(this->LogOut.c_str(), std::ios::out | std::ios::binary);
+    ferr.open(this->LogErr.c_str(), std::ios::out | std::ios::binary);
+  }
 
 #ifdef _WIN32
   // Do this so that newline transformation is not done when writing to cout
@@ -276,47 +226,39 @@ void cmCTestLaunch::RunChild()
   cmsysProcess_Execute(cp);
 
   // Record child stdout and stderr if necessary.
-  if(!this->Passthru)
-    {
+  if (!this->Passthru) {
     char* data = 0;
     int length = 0;
-    while(int p = cmsysProcess_WaitForData(cp, &data, &length, 0))
-      {
-      if(p == cmsysProcess_Pipe_STDOUT)
-        {
+    while (int p = cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+      if (p == cmsysProcess_Pipe_STDOUT) {
         fout.write(data, length);
         std::cout.write(data, length);
         this->HaveOut = true;
-        }
-      else if(p == cmsysProcess_Pipe_STDERR)
-        {
+      } else if (p == cmsysProcess_Pipe_STDERR) {
         ferr.write(data, length);
         std::cerr.write(data, length);
         this->HaveErr = true;
-        }
       }
     }
+  }
 
   // Wait for the real command to finish.
   cmsysProcess_WaitForExit(cp, 0);
   this->ExitCode = cmsysProcess_GetExitValue(cp);
 }
 
-//----------------------------------------------------------------------------
 int cmCTestLaunch::Run()
 {
-  if(!this->Process)
-    {
+  if (!this->Process) {
     std::cerr << "Could not allocate cmsysProcess instance!\n";
     return -1;
-    }
+  }
 
   this->RunChild();
 
-  if(this->CheckResults())
-    {
+  if (this->CheckResults()) {
     return this->ExitCode;
-    }
+  }
 
   this->LoadConfig();
   this->WriteXML();
@@ -324,13 +266,11 @@ int cmCTestLaunch::Run()
   return this->ExitCode;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::LoadLabels()
 {
-  if(this->OptionBuildDir.empty() || this->OptionTargetName.empty())
-    {
+  if (this->OptionBuildDir.empty() || this->OptionTargetName.empty()) {
     return;
-    }
+  }
 
   // Labels are listed in per-target files.
   std::string fname = this->OptionBuildDir;
@@ -345,41 +285,33 @@ void cmCTestLaunch::LoadLabels()
 
   // Load the labels file.
   cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
-  if(!fin) { return; }
+  if (!fin) {
+    return;
+  }
   bool inTarget = true;
   bool inSource = false;
   std::string line;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if(line.empty() || line[0] == '#')
-      {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (line.empty() || line[0] == '#') {
       // Ignore blank and comment lines.
       continue;
-      }
-    else if(line[0] == ' ')
-      {
+    } else if (line[0] == ' ') {
       // Label lines appear indented by one space.
-      if(inTarget || inSource)
-        {
-        this->Labels.insert(line.c_str()+1);
-        }
+      if (inTarget || inSource) {
+        this->Labels.insert(line.c_str() + 1);
       }
-    else if(!this->OptionSource.empty() && !inSource)
-      {
+    } else if (!this->OptionSource.empty() && !inSource) {
       // Non-indented lines specify a source file name.  The first one
       // is the end of the target-wide labels.  Use labels following a
       // matching source.
       inTarget = false;
       inSource = this->SourceMatches(line, source);
-      }
-    else
-      {
+    } else {
       return;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::SourceMatches(std::string const& lhs,
                                   std::string const& rhs)
 {
@@ -390,18 +322,16 @@ bool cmCTestLaunch::SourceMatches(std::string const& lhs,
   return lhs == rhs;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::IsError() const
 {
   return this->ExitCode != 0;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::WriteXML()
 {
   // Name the xml file.
   std::string logXML = this->LogDir;
-  logXML += this->IsError()? "error-" : "warning-";
+  logXML += this->IsError() ? "error-" : "warning-";
   logXML += this->LogHash;
   logXML += ".xml";
 
@@ -417,100 +347,78 @@ void cmCTestLaunch::WriteXML()
   xml.EndElement(); // Failure
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
 {
   xml.Comment("Meta-information about the build action");
   xml.StartElement("Action");
 
   // TargetName
-  if(!this->OptionTargetName.empty())
-    {
+  if (!this->OptionTargetName.empty()) {
     xml.Element("TargetName", this->OptionTargetName);
-    }
+  }
 
   // Language
-  if(!this->OptionLanguage.empty())
-    {
+  if (!this->OptionLanguage.empty()) {
     xml.Element("Language", this->OptionLanguage);
-    }
+  }
 
   // SourceFile
-  if(!this->OptionSource.empty())
-    {
+  if (!this->OptionSource.empty()) {
     std::string source = this->OptionSource;
     cmSystemTools::ConvertToUnixSlashes(source);
 
     // If file is in source tree use its relative location.
-    if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
-       cmSystemTools::FileIsFullPath(source.c_str()) &&
-       cmSystemTools::IsSubDirectory(source,
-                                     this->SourceDir))
-      {
-      source = cmSystemTools::RelativePath(this->SourceDir.c_str(),
-                                           source.c_str());
-      }
+    if (cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
+        cmSystemTools::FileIsFullPath(source.c_str()) &&
+        cmSystemTools::IsSubDirectory(source, this->SourceDir)) {
+      source =
+        cmSystemTools::RelativePath(this->SourceDir.c_str(), source.c_str());
+    }
 
     xml.Element("SourceFile", source);
-    }
+  }
 
   // OutputFile
-  if(!this->OptionOutput.empty())
-    {
+  if (!this->OptionOutput.empty()) {
     xml.Element("OutputFile", this->OptionOutput);
-    }
+  }
 
   // OutputType
   const char* outputType = 0;
-  if(!this->OptionTargetType.empty())
-    {
-    if(this->OptionTargetType == "EXECUTABLE")
-      {
+  if (!this->OptionTargetType.empty()) {
+    if (this->OptionTargetType == "EXECUTABLE") {
       outputType = "executable";
-      }
-    else if(this->OptionTargetType == "SHARED_LIBRARY")
-      {
+    } else if (this->OptionTargetType == "SHARED_LIBRARY") {
       outputType = "shared library";
-      }
-    else if(this->OptionTargetType == "MODULE_LIBRARY")
-      {
+    } else if (this->OptionTargetType == "MODULE_LIBRARY") {
       outputType = "module library";
-      }
-    else if(this->OptionTargetType == "STATIC_LIBRARY")
-      {
+    } else if (this->OptionTargetType == "STATIC_LIBRARY") {
       outputType = "static library";
-      }
     }
-  else if(!this->OptionSource.empty())
-    {
+  } else if (!this->OptionSource.empty()) {
     outputType = "object file";
-    }
-  if(outputType)
-    {
+  }
+  if (outputType) {
     xml.Element("OutputType", outputType);
-    }
+  }
 
   xml.EndElement(); // Action
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::WriteXMLCommand(cmXMLWriter& xml)
 {
   xml.Comment("Details of command");
   xml.StartElement("Command");
-  if(!this->CWD.empty())
-    {
+  if (!this->CWD.empty()) {
     xml.Element("WorkingDirectory", this->CWD);
-    }
-  for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
-      ai != this->RealArgs.end(); ++ai)
-    {
+  }
+  for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
+       ai != this->RealArgs.end(); ++ai) {
     xml.Element("Argument", *ai);
-    }
+  }
   xml.EndElement(); // Command
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml)
 {
   xml.Comment("Result of command");
@@ -529,103 +437,97 @@ void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml)
   // ExitCondition
   xml.StartElement("ExitCondition");
   cmsysProcess* cp = this->Process;
-  switch (cmsysProcess_GetState(cp))
-    {
+  switch (cmsysProcess_GetState(cp)) {
     case cmsysProcess_State_Starting:
-      xml.Content("No process has been executed"); break;
+      xml.Content("No process has been executed");
+      break;
     case cmsysProcess_State_Executing:
-      xml.Content("The process is still executing"); break;
+      xml.Content("The process is still executing");
+      break;
     case cmsysProcess_State_Disowned:
-      xml.Content("Disowned"); break;
+      xml.Content("Disowned");
+      break;
     case cmsysProcess_State_Killed:
-      xml.Content("Killed by parent"); break;
+      xml.Content("Killed by parent");
+      break;
 
     case cmsysProcess_State_Expired:
-      xml.Content("Killed when timeout expired"); break;
+      xml.Content("Killed when timeout expired");
+      break;
     case cmsysProcess_State_Exited:
-      xml.Content(this->ExitCode); break;
+      xml.Content(this->ExitCode);
+      break;
     case cmsysProcess_State_Exception:
       xml.Content("Terminated abnormally: ");
-      xml.Content(cmsysProcess_GetExceptionString(cp)); break;
+      xml.Content(cmsysProcess_GetExceptionString(cp));
+      break;
     case cmsysProcess_State_Error:
       xml.Content("Error administrating child process: ");
-      xml.Content(cmsysProcess_GetErrorString(cp)); break;
-    };
+      xml.Content(cmsysProcess_GetErrorString(cp));
+      break;
+  };
   xml.EndElement(); // ExitCondition
 
   xml.EndElement(); // Result
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::WriteXMLLabels(cmXMLWriter& xml)
 {
   this->LoadLabels();
-  if(!this->Labels.empty())
-    {
+  if (!this->Labels.empty()) {
     xml.Comment("Interested parties");
     xml.StartElement("Labels");
-    for(std::set<std::string>::const_iterator li = this->Labels.begin();
-        li != this->Labels.end(); ++li)
-      {
+    for (std::set<std::string>::const_iterator li = this->Labels.begin();
+         li != this->Labels.end(); ++li) {
       xml.Element("Label", *li);
-      }
-    xml.EndElement(); // Labels
     }
+    xml.EndElement(); // Labels
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml,
-                                  std::string const& fname)
+void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml, std::string const& fname)
 {
   cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
 
   std::string line;
   const char* sep = "";
 
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if(MatchesFilterPrefix(line))
-      {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (MatchesFilterPrefix(line)) {
       continue;
-      }
+    }
 
     xml.Content(sep);
     xml.Content(line);
     sep = "\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::CheckResults()
 {
   // Skip XML in passthru mode.
-  if(this->Passthru)
-    {
+  if (this->Passthru) {
     return true;
-    }
+  }
 
   // We always report failure for error conditions.
-  if(this->IsError())
-    {
+  if (this->IsError()) {
     return false;
-    }
+  }
 
   // Scrape the output logs to look for warnings.
-  if((this->HaveErr && this->ScrapeLog(this->LogErr)) ||
-     (this->HaveOut && this->ScrapeLog(this->LogOut)))
-    {
+  if ((this->HaveErr && this->ScrapeLog(this->LogErr)) ||
+      (this->HaveOut && this->ScrapeLog(this->LogOut))) {
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestLaunch::LoadScrapeRules()
 {
-  if(this->ScrapeRulesLoaded)
-    {
+  if (this->ScrapeRulesLoaded) {
     return;
-    }
+  }
   this->ScrapeRulesLoaded = true;
 
   // Common compiler warning formats.  These are much simpler than the
@@ -640,11 +542,8 @@ void cmCTestLaunch::LoadScrapeRules()
   this->LoadScrapeRules("WarningSuppress", this->RegexWarningSuppress);
 }
 
-//----------------------------------------------------------------------------
-void
-cmCTestLaunch
-::LoadScrapeRules(const char* purpose,
-                  std::vector<cmsys::RegularExpression>& regexps)
+void cmCTestLaunch::LoadScrapeRules(
+  const char* purpose, std::vector<cmsys::RegularExpression>& regexps)
 {
   std::string fname = this->LogDir;
   fname += "Custom";
@@ -653,16 +552,13 @@ cmCTestLaunch
   cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
   std::string line;
   cmsys::RegularExpression rex;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if(rex.compile(line.c_str()))
-      {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (rex.compile(line.c_str())) {
       regexps.push_back(rex);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::ScrapeLog(std::string const& fname)
 {
   this->LoadScrapeRules();
@@ -671,62 +567,52 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname)
   // suppression expressions.
   cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
   std::string line;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if(MatchesFilterPrefix(line))
-      {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (MatchesFilterPrefix(line)) {
       continue;
-      }
+    }
 
-    if(this->Match(line, this->RegexWarning) &&
-       !this->Match(line, this->RegexWarningSuppress))
-      {
+    if (this->Match(line, this->RegexWarning) &&
+        !this->Match(line, this->RegexWarningSuppress)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::Match(std::string const& line,
                           std::vector<cmsys::RegularExpression>& regexps)
 {
-  for(std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
-      ri != regexps.end(); ++ri)
-    {
-    if(ri->find(line.c_str()))
-      {
+  for (std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
+       ri != regexps.end(); ++ri) {
+    if (ri->find(line.c_str())) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const
 {
-  if(!this->OptionFilterPrefix.empty() && cmSystemTools::StringStartsWith(
-      line.c_str(), this->OptionFilterPrefix.c_str()))
-    {
+  if (!this->OptionFilterPrefix.empty() &&
+      cmSystemTools::StringStartsWith(line.c_str(),
+                                      this->OptionFilterPrefix.c_str())) {
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 int cmCTestLaunch::Main(int argc, const char* const argv[])
 {
-  if(argc == 2)
-    {
+  if (argc == 2) {
     std::cerr << "ctest --launch: this mode is for internal CTest use only"
               << std::endl;
     return 1;
-    }
+  }
   cmCTestLaunch self(argc, argv);
   return self.Run();
 }
 
-//----------------------------------------------------------------------------
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmake.h"
@@ -741,10 +627,9 @@ void cmCTestLaunch::LoadConfig()
   cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
   std::string fname = this->LogDir;
   fname += "CTestLaunchConfig.cmake";
-  if(cmSystemTools::FileExists(fname.c_str()) &&
-     mf->ReadListFile(fname.c_str()))
-    {
+  if (cmSystemTools::FileExists(fname.c_str()) &&
+      mf->ReadListFile(fname.c_str())) {
     this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
     cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
-    }
+  }
 }
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index b13e484..cbcc9ec 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -13,6 +13,7 @@
 #define cmCTestLaunch_h
 
 #include "cmStandardIncludes.h"
+
 #include <cmsys/RegularExpression.hxx>
 
 class cmXMLWriter;
@@ -27,6 +28,7 @@ class cmCTestLaunch
 public:
   /** Entry point from ctest executable main().  */
   static int Main(int argc, const char* const argv[]);
+
 private:
   // Initialize the launcher from its command line.
   cmCTestLaunch(int argc, const char* const* argv);
@@ -77,8 +79,7 @@ private:
   // Labels associated with the build rule.
   std::set<std::string> Labels;
   void LoadLabels();
-  bool SourceMatches(std::string const& lhs,
-                     std::string const& rhs);
+  bool SourceMatches(std::string const& lhs, std::string const& rhs);
 
   // Regular expressions to match warnings and their exceptions.
   bool ScrapeRulesLoaded;
diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx
index b379d32..d53dcd0 100644
--- a/Source/CTest/cmCTestMemCheckCommand.cxx
+++ b/Source/CTest/cmCTestMemCheckCommand.cxx
@@ -14,27 +14,26 @@
 #include "cmCTest.h"
 #include "cmCTestGenericHandler.h"
 
-
 cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
 {
-  cmCTestGenericHandler* handler
-    = this->CTest->GetInitializedHandler("memcheck");
-
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "MemoryCheckSanitizerOptions", "CTEST_MEMORYCHECK_SANITIZER_OPTIONS",
-    this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "MemoryCheckCommandOptions", "CTEST_MEMORYCHECK_COMMAND_OPTIONS",
-    this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "MemoryCheckSuppressionFile", "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE",
+  cmCTestGenericHandler* handler =
+    this->CTest->GetInitializedHandler("memcheck");
+
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "MemoryCheckSanitizerOptions",
+    "CTEST_MEMORYCHECK_SANITIZER_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "MemoryCheckCommand", "CTEST_MEMORYCHECK_COMMAND",
     this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "MemoryCheckCommandOptions",
+    "CTEST_MEMORYCHECK_COMMAND_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "MemoryCheckSuppressionFile",
+    "CTEST_MEMORYCHECK_SUPPRESSIONS_FILE", this->Quiet);
 
   handler->SetQuiet(this->Quiet);
   return handler;
 }
-
diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h
index e239d46..245892c 100644
--- a/Source/CTest/cmCTestMemCheckCommand.h
+++ b/Source/CTest/cmCTestMemCheckCommand.h
@@ -24,24 +24,23 @@ class cmCTestGenericHandler;
 class cmCTestMemCheckCommand : public cmCTestTestCommand
 {
 public:
-
   cmCTestMemCheckCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_memcheck";}
+  virtual std::string GetName() const { return "ctest_memcheck"; }
 
   cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand);
 
@@ -49,6 +48,4 @@ protected:
   cmCTestGenericHandler* InitializeActualHandler();
 };
 
-
 #endif
-
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index acf527a..5ae98af 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -11,21 +11,22 @@
 ============================================================================*/
 
 #include "cmCTestMemCheckHandler.h"
-#include "cmXMLParser.h"
+
 #include "cmCTest.h"
-#include "cmake.h"
 #include "cmGeneratedFileStream.h"
-#include <cmsys/Process.h>
-#include <cmsys/RegularExpression.hxx>
-#include <cmsys/Base64.h>
-#include <cmsys/Glob.hxx>
-#include <cmsys/FStream.hxx>
 #include "cmMakefile.h"
+#include "cmXMLParser.h"
 #include "cmXMLWriter.h"
+#include "cmake.h"
+#include <cmsys/Base64.h>
+#include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/Process.h>
+#include <cmsys/RegularExpression.hxx>
 
-#include <stdlib.h>
-#include <math.h>
 #include <float.h>
+#include <math.h>
+#include <stdlib.h>
 
 struct CatToErrorType
 {
@@ -33,24 +34,22 @@ struct CatToErrorType
   int ErrorCode;
 };
 
-
 static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
   // Error tags
-  {"Write Overrun", cmCTestMemCheckHandler::ABW},
-  {"Read Overrun",  cmCTestMemCheckHandler::ABR},
-  {"Memory Overrun", cmCTestMemCheckHandler::ABW},
-  {"Allocation Conflict",  cmCTestMemCheckHandler::FMM},
-  {"Bad Pointer Use", cmCTestMemCheckHandler::FMW},
-  {"Dangling Pointer", cmCTestMemCheckHandler::FMR},
-  {0,0}
+  { "Write Overrun", cmCTestMemCheckHandler::ABW },
+  { "Read Overrun", cmCTestMemCheckHandler::ABR },
+  { "Memory Overrun", cmCTestMemCheckHandler::ABW },
+  { "Allocation Conflict", cmCTestMemCheckHandler::FMM },
+  { "Bad Pointer Use", cmCTestMemCheckHandler::FMW },
+  { "Dangling Pointer", cmCTestMemCheckHandler::FMR },
+  { 0, 0 }
 };
 
 static void xmlReportError(int line, const char* msg, void* data)
 {
   cmCTest* ctest = (cmCTest*)data;
-  cmCTestLog(ctest, ERROR_MESSAGE,
-             "Error parsing XML in stream at line "
-             << line << ": " << msg << std::endl);
+  cmCTestLog(ctest, ERROR_MESSAGE, "Error parsing XML in stream at line "
+               << line << ": " << msg << std::endl);
 }
 
 // parse the xml file containing the results of last BoundsChecker run
@@ -58,89 +57,71 @@ class cmBoundsCheckerParser : public cmXMLParser
 {
 public:
   cmBoundsCheckerParser(cmCTest* c)
-    {
-      this->CTest = c;
-      this->SetErrorCallback(xmlReportError, (void*)c);
-    }
+  {
+    this->CTest = c;
+    this->SetErrorCallback(xmlReportError, (void*)c);
+  }
   void StartElement(const std::string& name, const char** atts)
-    {
-      if(name == "MemoryLeak" ||
-         name == "ResourceLeak")
-        {
-        this->Errors.push_back(cmCTestMemCheckHandler::MLK);
-        }
-      else if(name == "Error" ||
-              name == "Dangling Pointer")
-        {
-        this->ParseError(atts);
-        }
-      // Create the log
-      std::ostringstream ostr;
-      ostr << name << ":\n";
-      int i = 0;
-      for(; atts[i] != 0; i+=2)
-        {
-        ostr << "   " << atts[i]
-             << " - " << atts[i+1] << "\n";
-        }
-      ostr << "\n";
-      this->Log += ostr.str();
+  {
+    if (name == "MemoryLeak" || name == "ResourceLeak") {
+      this->Errors.push_back(cmCTestMemCheckHandler::MLK);
+    } else if (name == "Error" || name == "Dangling Pointer") {
+      this->ParseError(atts);
     }
-  void EndElement(const std::string& )
-    {
+    // Create the log
+    std::ostringstream ostr;
+    ostr << name << ":\n";
+    int i = 0;
+    for (; atts[i] != 0; i += 2) {
+      ostr << "   " << atts[i] << " - " << atts[i + 1] << "\n";
     }
+    ostr << "\n";
+    this->Log += ostr.str();
+  }
+  void EndElement(const std::string&) {}
 
   const char* GetAttribute(const char* name, const char** atts)
-    {
-      int i = 0;
-      for(; atts[i] != 0; ++i)
-        {
-        if(strcmp(name, atts[i]) == 0)
-          {
-          return atts[i+1];
-          }
-        }
-      return 0;
+  {
+    int i = 0;
+    for (; atts[i] != 0; ++i) {
+      if (strcmp(name, atts[i]) == 0) {
+        return atts[i + 1];
+      }
     }
+    return 0;
+  }
   void ParseError(const char** atts)
-    {
-      CatToErrorType* ptr = cmCTestMemCheckBoundsChecker;
-      const char* cat = this->GetAttribute("ErrorCategory", atts);
-      if(!cat)
-        {
-        this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
-        cmCTestLog(this->CTest, ERROR_MESSAGE,
-                   "No Category found in Bounds checker XML\n" );
-        return;
-        }
-      while(ptr->ErrorCategory && cat)
-        {
-        if(strcmp(ptr->ErrorCategory, cat) == 0)
-          {
-          this->Errors.push_back(ptr->ErrorCode);
-          return; // found it we are done
-          }
-        ptr++;
-        }
-      if(ptr->ErrorCategory)
-        {
-        this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
-        cmCTestLog(this->CTest, ERROR_MESSAGE,
-                   "Found unknown Bounds Checker error "
-                   << ptr->ErrorCategory << std::endl);
-        }
+  {
+    CatToErrorType* ptr = cmCTestMemCheckBoundsChecker;
+    const char* cat = this->GetAttribute("ErrorCategory", atts);
+    if (!cat) {
+      this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "No Category found in Bounds checker XML\n");
+      return;
     }
+    while (ptr->ErrorCategory && cat) {
+      if (strcmp(ptr->ErrorCategory, cat) == 0) {
+        this->Errors.push_back(ptr->ErrorCode);
+        return; // found it we are done
+      }
+      ptr++;
+    }
+    if (ptr->ErrorCategory) {
+      this->Errors.push_back(cmCTestMemCheckHandler::ABW); // do not know
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "Found unknown Bounds Checker error " << ptr->ErrorCategory
+                                                       << std::endl);
+    }
+  }
   cmCTest* CTest;
   std::vector<int> Errors;
   std::string Log;
 };
 
-#define BOUNDS_CHECKER_MARKER \
-"******######*****Begin BOUNDS CHECKER XML******######******"
+#define BOUNDS_CHECKER_MARKER                                                 \
+  "******######*****Begin BOUNDS CHECKER XML******######******"
 
-
-
-//----------------------------------------------------------------------
 cmCTestMemCheckHandler::cmCTestMemCheckHandler()
 {
   this->MemCheck = true;
@@ -149,7 +130,6 @@ cmCTestMemCheckHandler::cmCTestMemCheckHandler()
   this->LogWithPID = false;
 }
 
-//----------------------------------------------------------------------
 void cmCTestMemCheckHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -163,143 +143,108 @@ void cmCTestMemCheckHandler::Initialize()
   this->MemoryTesterOutputFile = "";
 }
 
-//----------------------------------------------------------------------
 int cmCTestMemCheckHandler::PreProcessHandler()
 {
-  if ( !this->InitializeMemoryChecking() )
-    {
+  if (!this->InitializeMemoryChecking()) {
     return 0;
-    }
+  }
 
-  if ( !this->ExecuteCommands(this->CustomPreMemCheck) )
-    {
+  if (!this->ExecuteCommands(this->CustomPreMemCheck)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Problem executing pre-memcheck command(s)." << std::endl);
+               "Problem executing pre-memcheck command(s)." << std::endl);
     return 0;
-    }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCTestMemCheckHandler::PostProcessHandler()
 {
-  if ( !this->ExecuteCommands(this->CustomPostMemCheck) )
-    {
+  if (!this->ExecuteCommands(this->CustomPostMemCheck)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Problem executing post-memcheck command(s)." << std::endl);
+               "Problem executing post-memcheck command(s)." << std::endl);
     return 0;
-    }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 void cmCTestMemCheckHandler::GenerateTestCommand(
   std::vector<std::string>& args, int test)
 {
   std::vector<std::string>::size_type pp;
   std::string index;
   std::ostringstream stream;
-  std::string memcheckcommand
-    = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
+  std::string memcheckcommand =
+    cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
   stream << test;
   index = stream.str();
-  for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ )
-    {
+  for (pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp++) {
     std::string arg = this->MemoryTesterDynamicOptions[pp];
     std::string::size_type pos = arg.find("??");
-    if (pos != std::string::npos)
-      {
+    if (pos != std::string::npos) {
       arg.replace(pos, 2, index);
-      }
+    }
     args.push_back(arg);
     memcheckcommand += " \"";
     memcheckcommand += arg;
     memcheckcommand += "\"";
-    }
+  }
   // Create a copy of the memory tester environment variable.
   // This is used for memory testing programs that pass options
   // via environment varaibles.
   std::string memTesterEnvironmentVariable =
     this->MemoryTesterEnvironmentVariable;
-  for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
-    {
-    if(!memTesterEnvironmentVariable.empty())
-      {
+  for (pp = 0; pp < this->MemoryTesterOptions.size(); pp++) {
+    if (!memTesterEnvironmentVariable.empty()) {
       // If we are using env to pass options, append all the options to
       // this string with space separation.
       memTesterEnvironmentVariable += " " + this->MemoryTesterOptions[pp];
-      }
+    }
     // for regular options just add them to args and memcheckcommand
     // which is just used for display
-    else
-      {
+    else {
       args.push_back(this->MemoryTesterOptions[pp]);
       memcheckcommand += " \"";
       memcheckcommand += this->MemoryTesterOptions[pp];
       memcheckcommand += "\"";
-      }
     }
+  }
   // if this is an env option type, then add the env string as a single
   // argument.
-  if(!memTesterEnvironmentVariable.empty())
-    {
+  if (!memTesterEnvironmentVariable.empty()) {
     std::string::size_type pos = memTesterEnvironmentVariable.find("??");
-    if (pos != std::string::npos)
-      {
+    if (pos != std::string::npos) {
       memTesterEnvironmentVariable.replace(pos, 2, index);
-      }
+    }
     memcheckcommand += " " + memTesterEnvironmentVariable;
     args.push_back(memTesterEnvironmentVariable);
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "Memory check command: " << memcheckcommand << std::endl, this->Quiet);
+                     "Memory check command: " << memcheckcommand << std::endl,
+                     this->Quiet);
 }
 
-//----------------------------------------------------------------------
 void cmCTestMemCheckHandler::InitializeResultsVectors()
 {
   // fill these members
-//  cmsys::vector<std::string> ResultStrings;
-//  cmsys::vector<std::string> ResultStringsLong;
-//  cmsys::vector<int>         GlobalResults;
+  //  cmsys::vector<std::string> ResultStrings;
+  //  cmsys::vector<std::string> ResultStringsLong;
+  //  cmsys::vector<int>         GlobalResults;
   this->ResultStringsLong.clear();
   this->ResultStrings.clear();
   this->GlobalResults.clear();
   // If we are working with style checkers that dynamically fill
   // the results strings then return.
-  if(this->MemoryTesterStyle > cmCTestMemCheckHandler::BOUNDS_CHECKER)
-    {
+  if (this->MemoryTesterStyle > cmCTestMemCheckHandler::BOUNDS_CHECKER) {
     return;
-    }
+  }
 
   // define the standard set of errors
   //----------------------------------------------------------------------
   static const char* cmCTestMemCheckResultStrings[] = {
-    "ABR",
-    "ABW",
-    "ABWL",
-    "COR",
-    "EXU",
-    "FFM",
-    "FIM",
-    "FMM",
-    "FMR",
-    "FMW",
-    "FUM",
-    "IPR",
-    "IPW",
-    "MAF",
-    "MLK",
-    "MPK",
-    "NPR",
-    "ODS",
-    "PAR",
-    "PLK",
-    "UMC",
-    "UMR",
-    0
+    "ABR", "ABW", "ABWL", "COR", "EXU", "FFM", "FIM", "FMM",
+    "FMR", "FMW", "FUM",  "IPR", "IPW", "MAF", "MLK", "MPK",
+    "NPR", "ODS", "PAR",  "PLK", "UMC", "UMR", 0
   };
-//----------------------------------------------------------------------
   static const char* cmCTestMemCheckResultLongStrings[] = {
     "Threading Problem",
     "ABW",
@@ -326,42 +271,36 @@ void cmCTestMemCheckHandler::InitializeResultsVectors()
     0
   };
   this->GlobalResults.clear();
-  for(int i =0; cmCTestMemCheckResultStrings[i] != 0; ++i)
-    {
+  for (int i = 0; cmCTestMemCheckResultStrings[i] != 0; ++i) {
     this->ResultStrings.push_back(cmCTestMemCheckResultStrings[i]);
     this->ResultStringsLong.push_back(cmCTestMemCheckResultLongStrings[i]);
     this->GlobalResults.push_back(0);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
-void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestMemCheckHandler::PopulateCustomVectors(cmMakefile* mf)
 {
   this->cmCTestTestHandler::PopulateCustomVectors(mf);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_MEMCHECK",
-                                this->CustomPreMemCheck);
+                                    this->CustomPreMemCheck);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_MEMCHECK",
-                                this->CustomPostMemCheck);
+                                    this->CustomPostMemCheck);
 
-  this->CTest->PopulateCustomVector(mf,
-                             "CTEST_CUSTOM_MEMCHECK_IGNORE",
-                             this->CustomTestsIgnore);
+  this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_MEMCHECK_IGNORE",
+                                    this->CustomTestsIgnore);
   std::string cmake = cmSystemTools::GetCMakeCommand();
   this->CTest->SetCTestConfiguration("CMakeCommand", cmake.c_str(),
-    this->Quiet);
+                                     this->Quiet);
 }
 
-//----------------------------------------------------------------------
 void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
 {
-  if ( !this->CTest->GetProduceXML() )
-    {
+  if (!this->CTest->GetProduceXML()) {
     return;
-    }
+  }
   this->CTest->StartXML(xml, this->AppendXML);
   xml.StartElement("DynamicAnalysis");
-  switch ( this->MemoryTesterStyle )
-    {
+  switch (this->MemoryTesterStyle) {
     case cmCTestMemCheckHandler::VALGRIND:
       xml.Attribute("Checker", "Valgrind");
       break;
@@ -385,290 +324,245 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
       break;
     default:
       xml.Attribute("Checker", "Unknown");
-    }
+  }
 
   xml.Element("StartDateTime", this->StartTest);
   xml.Element("StartTestTime", this->StartTestTime);
   xml.StartElement("TestList");
   cmCTestMemCheckHandler::TestResultsVector::size_type cc;
-  for ( cc = 0; cc < this->TestResults.size(); cc ++ )
-    {
-    cmCTestTestResult *result = &this->TestResults[cc];
+  for (cc = 0; cc < this->TestResults.size(); cc++) {
+    cmCTestTestResult* result = &this->TestResults[cc];
     std::string testPath = result->Path + "/" + result->Name;
     xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
-    }
+  }
   xml.EndElement(); // TestList
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-    "-- Processing memory checking output: ", this->Quiet);
+                     "-- Processing memory checking output: ", this->Quiet);
   size_t total = this->TestResults.size();
   size_t step = total / 10;
   size_t current = 0;
-  for ( cc = 0; cc < this->TestResults.size(); cc ++ )
-    {
-    cmCTestTestResult *result = &this->TestResults[cc];
+  for (cc = 0; cc < this->TestResults.size(); cc++) {
+    cmCTestTestResult* result = &this->TestResults[cc];
     std::string memcheckstr;
     std::vector<int> memcheckresults(this->ResultStrings.size(), 0);
     bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr,
-      memcheckresults);
-    if ( res && result->Status == cmCTestMemCheckHandler::COMPLETED )
-      {
+                                           memcheckresults);
+    if (res && result->Status == cmCTestMemCheckHandler::COMPLETED) {
       continue;
-      }
-    this->CleanTestOutput(memcheckstr,
+    }
+    this->CleanTestOutput(
+      memcheckstr,
       static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
     this->WriteTestResultHeader(xml, result);
     xml.StartElement("Results");
-    for(std::vector<int>::size_type kk = 0;
-        kk < memcheckresults.size(); ++kk)
-      {
-      if ( memcheckresults[kk] )
-        {
+    for (std::vector<int>::size_type kk = 0; kk < memcheckresults.size();
+         ++kk) {
+      if (memcheckresults[kk]) {
         xml.StartElement("Defect");
         xml.Attribute("type", this->ResultStringsLong[kk]);
         xml.Content(memcheckresults[kk]);
         xml.EndElement(); // Defect
-        }
-      this->GlobalResults[kk] += memcheckresults[kk];
       }
+      this->GlobalResults[kk] += memcheckresults[kk];
+    }
     xml.EndElement(); // Results
 
     xml.StartElement("Log");
-    if(this->CTest->ShouldCompressMemCheckOutput())
-      {
+    if (this->CTest->ShouldCompressMemCheckOutput()) {
       this->CTest->CompressString(memcheckstr);
       xml.Attribute("compression", "gzip");
       xml.Attribute("encoding", "base64");
-      }
+    }
     xml.Content(memcheckstr);
     xml.EndElement(); // Log
 
     this->WriteTestResultFooter(xml, result);
-    if ( current < cc )
-      {
+    if (current < cc) {
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush,
-        this->Quiet);
+                         this->Quiet);
       current += step;
-      }
     }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Memory checking results:"
-    << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                     "Memory checking results:" << std::endl, this->Quiet);
   xml.StartElement("DefectList");
-  for ( cc = 0; cc < this->GlobalResults.size(); cc ++ )
-    {
-    if ( this->GlobalResults[cc] )
-      {
+  for (cc = 0; cc < this->GlobalResults.size(); cc++) {
+    if (this->GlobalResults[cc]) {
 #ifdef cerr
-#  undef cerr
+#undef cerr
 #endif
       std::cerr.width(35);
 #define cerr no_cerr
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        this->ResultStringsLong[cc] << " - "
-        << this->GlobalResults[cc] << std::endl, this->Quiet);
+                         this->ResultStringsLong[cc]
+                           << " - " << this->GlobalResults[cc] << std::endl,
+                         this->Quiet);
       xml.StartElement("Defect");
       xml.Attribute("Type", this->ResultStringsLong[cc]);
       xml.EndElement();
-      }
     }
+  }
   xml.EndElement(); // DefectList
 
   xml.Element("EndDateTime", this->EndTest);
   xml.Element("EndTestTime", this->EndTestTime);
   xml.Element("ElapsedMinutes",
-    static_cast<int>(this->ElapsedTestingTime/6)/10.0);
+              static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
 
   xml.EndElement(); // DynamicAnalysis
   this->CTest->EndXML(xml);
 }
 
-//----------------------------------------------------------------------
 bool cmCTestMemCheckHandler::InitializeMemoryChecking()
 {
   this->MemoryTesterEnvironmentVariable = "";
   this->MemoryTester = "";
   // Setup the command
-  if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
-        "MemoryCheckCommand").c_str()) )
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str();
+  if (cmSystemTools::FileExists(
+        this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) {
+    this->MemoryTester =
+      this->CTest->GetCTestConfiguration("MemoryCheckCommand");
     std::string testerName =
       cmSystemTools::GetFilenameName(this->MemoryTester);
     // determine the checker type
-    if ( testerName.find("valgrind") != std::string::npos ||
-         this->CTest->GetCTestConfiguration("MemoryCheckType")
-         == "Valgrind")
-      {
-        this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
-      }
-    else if ( testerName.find("purify") != std::string::npos )
-      {
+    if (testerName.find("valgrind") != std::string::npos ||
+        this->CTest->GetCTestConfiguration("MemoryCheckType") == "Valgrind") {
+      this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
+    } else if (testerName.find("purify") != std::string::npos) {
       this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
-      }
-    else if ( testerName.find("BC") != std::string::npos )
-      {
+    } else if (testerName.find("BC") != std::string::npos) {
       this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
-      }
-    else
-      {
+    } else {
       this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
-      }
     }
-  else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
-        "PurifyCommand").c_str()) )
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("PurifyCommand").c_str();
+  } else if (cmSystemTools::FileExists(
+               this->CTest->GetCTestConfiguration("PurifyCommand").c_str())) {
+    this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
-    }
-  else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
-        "ValgrindCommand").c_str()) )
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("ValgrindCommand").c_str();
+  } else if (cmSystemTools::FileExists(
+               this->CTest->GetCTestConfiguration("ValgrindCommand")
+                 .c_str())) {
+    this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
-    }
-  else if ( cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
-        "BoundsCheckerCommand").c_str()) )
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("BoundsCheckerCommand").c_str();
+  } else if (cmSystemTools::FileExists(
+               this->CTest->GetCTestConfiguration("BoundsCheckerCommand")
+                 .c_str())) {
+    this->MemoryTester =
+      this->CTest->GetCTestConfiguration("BoundsCheckerCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
-    }
-  if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
-       == "AddressSanitizer")
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+  }
+  if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+      "AddressSanitizer") {
+    this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::ADDRESS_SANITIZER;
     this->LogWithPID = true; // even if we give the log file the pid is added
-    }
-  if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
-       == "ThreadSanitizer")
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+  }
+  if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+      "ThreadSanitizer") {
+    this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::THREAD_SANITIZER;
     this->LogWithPID = true; // even if we give the log file the pid is added
-    }
-  if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
-       == "MemorySanitizer")
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+  }
+  if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+      "MemorySanitizer") {
+    this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::MEMORY_SANITIZER;
     this->LogWithPID = true; // even if we give the log file the pid is added
-    }
-  if ( this->CTest->GetCTestConfiguration("MemoryCheckType")
-       == "UndefinedBehaviorSanitizer")
-    {
-    this->MemoryTester
-      = this->CTest->GetCTestConfiguration("CMakeCommand").c_str();
+  }
+  if (this->CTest->GetCTestConfiguration("MemoryCheckType") ==
+      "UndefinedBehaviorSanitizer") {
+    this->MemoryTester = this->CTest->GetCTestConfiguration("CMakeCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::UB_SANITIZER;
     this->LogWithPID = true; // even if we give the log file the pid is added
-    }
+  }
   // Check the MemoryCheckType
-  if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UNKNOWN)
-    {
+  if (this->MemoryTesterStyle == cmCTestMemCheckHandler::UNKNOWN) {
     std::string checkType =
       this->CTest->GetCTestConfiguration("MemoryCheckType");
-    if(checkType == "Purify")
-      {
+    if (checkType == "Purify") {
       this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
-      }
-    else if(checkType == "BoundsChecker")
-      {
+    } else if (checkType == "BoundsChecker") {
       this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
-      }
-    else if(checkType == "Valgrind")
-      {
+    } else if (checkType == "Valgrind") {
       this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
-      }
     }
-  if(this->MemoryTester.empty())
-    {
+  }
+  if (this->MemoryTester.empty()) {
     cmCTestOptionalLog(this->CTest, WARNING,
-               "Memory checker (MemoryCheckCommand) "
-               "not set, or cannot find the specified program."
-               << std::endl, this->Quiet);
+                       "Memory checker (MemoryCheckCommand) "
+                       "not set, or cannot find the specified program."
+                         << std::endl,
+                       this->Quiet);
     return false;
-    }
+  }
 
   // Setup the options
   std::string memoryTesterOptions;
-  if ( this->CTest->GetCTestConfiguration(
-      "MemoryCheckCommandOptions").size() )
-    {
-    memoryTesterOptions = this->CTest->GetCTestConfiguration(
-      "MemoryCheckCommandOptions");
-    }
-  else if ( this->CTest->GetCTestConfiguration(
-      "ValgrindCommandOptions").size() )
-    {
-    memoryTesterOptions = this->CTest->GetCTestConfiguration(
-      "ValgrindCommandOptions");
-    }
-  this->MemoryTesterOptions
-    = cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
+  if (this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions").size()) {
+    memoryTesterOptions =
+      this->CTest->GetCTestConfiguration("MemoryCheckCommandOptions");
+  } else if (this->CTest->GetCTestConfiguration("ValgrindCommandOptions")
+               .size()) {
+    memoryTesterOptions =
+      this->CTest->GetCTestConfiguration("ValgrindCommandOptions");
+  }
+  this->MemoryTesterOptions =
+    cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
 
-  this->MemoryTesterOutputFile
-    = this->CTest->GetBinaryDir()
-    + "/Testing/Temporary/MemoryChecker.??.log";
+  this->MemoryTesterOutputFile =
+    this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log";
 
-  switch ( this->MemoryTesterStyle )
-    {
-    case cmCTestMemCheckHandler::VALGRIND:
-      {
-      if ( this->MemoryTesterOptions.empty() )
-        {
+  switch (this->MemoryTesterStyle) {
+    case cmCTestMemCheckHandler::VALGRIND: {
+      if (this->MemoryTesterOptions.empty()) {
         this->MemoryTesterOptions.push_back("-q");
         this->MemoryTesterOptions.push_back("--tool=memcheck");
         this->MemoryTesterOptions.push_back("--leak-check=yes");
         this->MemoryTesterOptions.push_back("--show-reachable=yes");
         this->MemoryTesterOptions.push_back("--num-callers=50");
-        }
-      if ( this->CTest->GetCTestConfiguration(
-          "MemoryCheckSuppressionFile").size() )
-        {
-        if ( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
-              "MemoryCheckSuppressionFile").c_str()) )
-          {
+      }
+      if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+            .size()) {
+        if (!cmSystemTools::FileExists(
+              this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+                .c_str())) {
           cmCTestLog(this->CTest, ERROR_MESSAGE,
-            "Cannot find memory checker suppression file: "
-            << this->CTest->GetCTestConfiguration(
-              "MemoryCheckSuppressionFile") << std::endl);
+                     "Cannot find memory checker suppression file: "
+                       << this->CTest->GetCTestConfiguration(
+                            "MemoryCheckSuppressionFile")
+                       << std::endl);
           return false;
-          }
-        std::string suppressions = "--suppressions="
-          + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
-        this->MemoryTesterOptions.push_back(suppressions);
         }
-      std::string outputFile = "--log-file="
-        + this->MemoryTesterOutputFile;
+        std::string suppressions = "--suppressions=" +
+          this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
+        this->MemoryTesterOptions.push_back(suppressions);
+      }
+      std::string outputFile = "--log-file=" + this->MemoryTesterOutputFile;
       this->MemoryTesterDynamicOptions.push_back(outputFile);
       break;
-      }
-    case cmCTestMemCheckHandler::PURIFY:
-      {
+    }
+    case cmCTestMemCheckHandler::PURIFY: {
       std::string outputFile;
 #ifdef _WIN32
-      if( this->CTest->GetCTestConfiguration(
-            "MemoryCheckSuppressionFile").size() )
-        {
-        if( !cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
-                                       "MemoryCheckSuppressionFile").c_str()) )
-          {
-          cmCTestLog(this->CTest, ERROR_MESSAGE,
-                     "Cannot find memory checker suppression file: "
-                     << this->CTest->GetCTestConfiguration(
-                       "MemoryCheckSuppressionFile").c_str() << std::endl);
+      if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+            .size()) {
+        if (!cmSystemTools::FileExists(
+              this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
+                .c_str())) {
+          cmCTestLog(
+            this->CTest, ERROR_MESSAGE,
+            "Cannot find memory checker suppression file: "
+              << this->CTest
+                   ->GetCTestConfiguration("MemoryCheckSuppressionFile")
+                   .c_str()
+              << std::endl);
           return false;
-          }
-        std::string filterFiles = "/FilterFiles="
-          + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
-        this->MemoryTesterOptions.push_back(filterFiles);
         }
+        std::string filterFiles = "/FilterFiles=" +
+          this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
+        this->MemoryTesterOptions.push_back(filterFiles);
+      }
       outputFile = "/SAVETEXTDATA=";
 #else
       outputFile = "-log-file=";
@@ -676,12 +570,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
       outputFile += this->MemoryTesterOutputFile;
       this->MemoryTesterDynamicOptions.push_back(outputFile);
       break;
-      }
-    case cmCTestMemCheckHandler::BOUNDS_CHECKER:
-      {
+    }
+    case cmCTestMemCheckHandler::BOUNDS_CHECKER: {
       this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile;
-      std::string dpbdFile = this->CTest->GetBinaryDir()
-        + "/Testing/Temporary/MemoryChecker.??.DPbd";
+      std::string dpbdFile = this->CTest->GetBinaryDir() +
+        "/Testing/Temporary/MemoryChecker.??.DPbd";
       this->BoundsCheckerDPBDFile = dpbdFile;
       this->MemoryTesterDynamicOptions.push_back("/B");
       this->MemoryTesterDynamicOptions.push_back(dpbdFile);
@@ -689,13 +582,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
       this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile);
       this->MemoryTesterOptions.push_back("/M");
       break;
-      }
-      // these are almost the same but the env var used is different
+    }
+    // these are almost the same but the env var used is different
     case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
     case cmCTestMemCheckHandler::THREAD_SANITIZER:
     case cmCTestMemCheckHandler::MEMORY_SANITIZER:
-    case cmCTestMemCheckHandler::UB_SANITIZER:
-      {
+    case cmCTestMemCheckHandler::UB_SANITIZER: {
       // To pass arguments to ThreadSanitizer the environment variable
       // TSAN_OPTIONS is used. This is done with the cmake -E env command.
       // The MemoryTesterDynamicOptions is setup with the -E env
@@ -706,36 +598,31 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
       std::string envVar;
       std::string extraOptions =
         this->CTest->GetCTestConfiguration("MemoryCheckSanitizerOptions");
-      if(this->MemoryTesterStyle == cmCTestMemCheckHandler::ADDRESS_SANITIZER)
-        {
+      if (this->MemoryTesterStyle ==
+          cmCTestMemCheckHandler::ADDRESS_SANITIZER) {
         envVar = "ASAN_OPTIONS";
         extraOptions += " detect_leaks=1";
-        }
-      else if(this->MemoryTesterStyle ==
-              cmCTestMemCheckHandler::THREAD_SANITIZER)
-        {
+      } else if (this->MemoryTesterStyle ==
+                 cmCTestMemCheckHandler::THREAD_SANITIZER) {
         envVar = "TSAN_OPTIONS";
-        }
-      else if(this->MemoryTesterStyle ==
-              cmCTestMemCheckHandler::MEMORY_SANITIZER)
-        {
+      } else if (this->MemoryTesterStyle ==
+                 cmCTestMemCheckHandler::MEMORY_SANITIZER) {
         envVar = "MSAN_OPTIONS";
-        }
-      else if(this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER)
-        {
+      } else if (this->MemoryTesterStyle ==
+                 cmCTestMemCheckHandler::UB_SANITIZER) {
         envVar = "UBSAN_OPTIONS";
-        }
-      std::string outputFile = envVar + "=log_path=\""
-        + this->MemoryTesterOutputFile + "\" ";
+      }
+      std::string outputFile =
+        envVar + "=log_path=\"" + this->MemoryTesterOutputFile + "\" ";
       this->MemoryTesterEnvironmentVariable = outputFile + extraOptions;
       break;
-      }
+    }
     default:
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Do not understand memory checker: " << this->MemoryTester
-        << std::endl);
+                 "Do not understand memory checker: " << this->MemoryTester
+                                                      << std::endl);
       return false;
-    }
+  }
 
   this->InitializeResultsVectors();
   // std::vector<std::string>::size_type cc;
@@ -746,68 +633,52 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
   return true;
 }
 
-//----------------------------------------------------------------------
-bool cmCTestMemCheckHandler::
-ProcessMemCheckOutput(const std::string& str,
-                      std::string& log, std::vector<int>& results)
+bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
+                                                   std::string& log,
+                                                   std::vector<int>& results)
 {
-  if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND )
-    {
+  if (this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND) {
     return this->ProcessMemCheckValgrindOutput(str, log, results);
-    }
-  else if ( this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY )
-    {
+  } else if (this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY) {
     return this->ProcessMemCheckPurifyOutput(str, log, results);
-    }
-  else if ( this->MemoryTesterStyle ==
-            cmCTestMemCheckHandler::ADDRESS_SANITIZER ||
-            this->MemoryTesterStyle ==
-            cmCTestMemCheckHandler::THREAD_SANITIZER ||
-            this->MemoryTesterStyle ==
-            cmCTestMemCheckHandler::MEMORY_SANITIZER ||
-            this->MemoryTesterStyle ==
-            cmCTestMemCheckHandler::UB_SANITIZER)
-    {
+  } else if (this->MemoryTesterStyle ==
+               cmCTestMemCheckHandler::ADDRESS_SANITIZER ||
+             this->MemoryTesterStyle ==
+               cmCTestMemCheckHandler::THREAD_SANITIZER ||
+             this->MemoryTesterStyle ==
+               cmCTestMemCheckHandler::MEMORY_SANITIZER ||
+             this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) {
     return this->ProcessMemCheckSanitizerOutput(str, log, results);
-    }
-  else if ( this->MemoryTesterStyle ==
-    cmCTestMemCheckHandler::BOUNDS_CHECKER )
-    {
+  } else if (this->MemoryTesterStyle ==
+             cmCTestMemCheckHandler::BOUNDS_CHECKER) {
     return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
-    }
-  else
-    {
+  } else {
     log.append("\nMemory checking style used was: ");
     log.append("None that I know");
     log = str;
-    }
+  }
   return true;
 }
 
 std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning(
   const std::string& warning)
 {
-  for(std::vector<std::string>::size_type i =0;
-      i < this->ResultStrings.size(); ++i)
-    {
-    if(this->ResultStrings[i] == warning)
-      {
+  for (std::vector<std::string>::size_type i = 0;
+       i < this->ResultStrings.size(); ++i) {
+    if (this->ResultStrings[i] == warning) {
       return i;
-      }
     }
+  }
   this->GlobalResults.push_back(0); // this must stay the same size
   this->ResultStrings.push_back(warning);
   this->ResultStringsLong.push_back(warning);
-  return this->ResultStrings.size()-1;
+  return this->ResultStrings.size() - 1;
 }
-//----------------------------------------------------------------------
 bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
-  const std::string& str, std::string& log,
-  std::vector<int>& result)
+  const std::string& str, std::string& log, std::vector<int>& result)
 {
   std::string regex;
-  switch ( this->MemoryTesterStyle )
-    {
+  switch (this->MemoryTesterStyle) {
     case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
       regex = "ERROR: AddressSanitizer: (.*) on.*";
       break;
@@ -822,7 +693,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
       break;
     default:
       break;
-    }
+  }
   cmsys::RegularExpression sanitizerWarning(regex);
   cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*");
   int defects = 0;
@@ -830,45 +701,34 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
   cmSystemTools::Split(str.c_str(), lines);
   std::ostringstream ostr;
   log = "";
-  for( std::vector<std::string>::iterator i = lines.begin();
-       i != lines.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
+       ++i) {
     std::string resultFound;
-    if(leakWarning.find(*i))
-      {
-      resultFound = leakWarning.match(1)+" leak";
-      }
-    else if (sanitizerWarning.find(*i))
-      {
+    if (leakWarning.find(*i)) {
+      resultFound = leakWarning.match(1) + " leak";
+    } else if (sanitizerWarning.find(*i)) {
       resultFound = sanitizerWarning.match(1);
-      }
-    if(!resultFound.empty())
-      {
+    }
+    if (!resultFound.empty()) {
       std::vector<int>::size_type idx = this->FindOrAddWarning(resultFound);
-      if(result.empty() || idx > result.size()-1)
-        {
+      if (result.empty() || idx > result.size() - 1) {
         result.push_back(1);
-        }
-      else
-        {
+      } else {
         result[idx]++;
-        }
-      defects++;
-      ostr << "<b>" <<  this->ResultStrings[idx] << "</b> ";
       }
-    ostr << *i << std::endl;
+      defects++;
+      ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
     }
+    ostr << *i << std::endl;
+  }
   log = ostr.str();
-  if(defects)
-    {
+  if (defects) {
     return false;
-    }
+  }
   return true;
 }
-//----------------------------------------------------------------------
 bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
-  const std::string& str, std::string& log,
-  std::vector<int>& results)
+  const std::string& str, std::string& log, std::vector<int>& results)
 {
   std::vector<std::string> lines;
   cmSystemTools::Split(str.c_str(), lines);
@@ -879,59 +739,49 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
 
   int defects = 0;
 
-  for( std::vector<std::string>::iterator i = lines.begin();
-       i != lines.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
+       ++i) {
     std::vector<int>::size_type failure = this->ResultStrings.size();
-    if ( pfW.find(*i) )
-      {
+    if (pfW.find(*i)) {
       std::vector<int>::size_type cc;
-      for ( cc = 0; cc < this->ResultStrings.size(); cc ++ )
-        {
-        if ( pfW.match(1) == this->ResultStrings[cc] )
-          {
+      for (cc = 0; cc < this->ResultStrings.size(); cc++) {
+        if (pfW.match(1) == this->ResultStrings[cc]) {
           failure = cc;
           break;
-          }
         }
-      if ( cc == this->ResultStrings.size() )
-        {
+      }
+      if (cc == this->ResultStrings.size()) {
         cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown Purify memory fault: "
-          << pfW.match(1) << std::endl);
+                     << pfW.match(1) << std::endl);
         ostr << "*** Unknown Purify memory fault: " << pfW.match(1)
-          << std::endl;
-        }
-      }
-    if ( failure != this->ResultStrings.size() )
-      {
-      ostr << "<b>" <<  this->ResultStrings[failure] << "</b> ";
-      results[failure] ++;
-      defects ++;
+             << std::endl;
       }
-    ostr << *i << std::endl;
     }
+    if (failure != this->ResultStrings.size()) {
+      ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
+      results[failure]++;
+      defects++;
+    }
+    ostr << *i << std::endl;
+  }
 
   log = ostr.str();
-  if ( defects )
-    {
+  if (defects) {
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
-  const std::string& str, std::string& log,
-  std::vector<int>& results)
+  const std::string& str, std::string& log, std::vector<int>& results)
 {
   std::vector<std::string> lines;
   cmSystemTools::Split(str.c_str(), lines);
   bool unlimitedOutput = false;
-  if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
-    this->CustomMaximumFailedTestOutputSize == 0)
-    {
+  if (str.find("CTEST_FULL_OUTPUT") != str.npos ||
+      this->CustomMaximumFailedTestOutputSize == 0) {
     unlimitedOutput = true;
-    }
+  }
 
   std::string::size_type cc;
 
@@ -948,7 +798,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
     "== .*Mismatched free\\(\\) / delete / delete \\[\\]");
   cmsys::RegularExpression vgMLK1(
     "== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost"
-   " in loss record [0-9,]+ of [0-9,]+");
+    " in loss record [0-9,]+ of [0-9,]+");
   cmsys::RegularExpression vgMLK2(
     "== .*[0-9,]+ \\([0-9,]+ direct, [0-9,]+ indirect\\)"
     " bytes in [0-9,]+ blocks are definitely lost"
@@ -967,299 +817,239 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
     "== .*Use of uninitialised value of size [0-9,]+");
   cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9,]+");
   cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address ");
-  cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains "
+  cmsys::RegularExpression vgUMR4(
+    "== .*Syscall param .* contains "
     "uninitialised or unaddressable byte\\(s\\)");
   cmsys::RegularExpression vgUMR5("== .*Syscall param .* uninitialised");
   cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9,]+");
   cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
-    "locked by a different thread");
+                                 "locked by a different thread");
   std::vector<std::string::size_type> nonValGrindOutput;
   double sttime = cmSystemTools::GetTime();
   cmCTestOptionalLog(this->CTest, DEBUG,
-    "Start test: " << lines.size() << std::endl, this->Quiet);
+                     "Start test: " << lines.size() << std::endl, this->Quiet);
   std::string::size_type totalOutputSize = 0;
-  for ( cc = 0; cc < lines.size(); cc ++ )
-    {
-    cmCTestOptionalLog(this->CTest, DEBUG, "test line "
-               << lines[cc] << std::endl, this->Quiet);
+  for (cc = 0; cc < lines.size(); cc++) {
+    cmCTestOptionalLog(this->CTest, DEBUG,
+                       "test line " << lines[cc] << std::endl, this->Quiet);
 
-    if ( valgrindLine.find(lines[cc]) )
-      {
-      cmCTestOptionalLog(this->CTest, DEBUG, "valgrind  line "
-                 << lines[cc] << std::endl, this->Quiet);
+    if (valgrindLine.find(lines[cc])) {
+      cmCTestOptionalLog(this->CTest, DEBUG,
+                         "valgrind  line " << lines[cc] << std::endl,
+                         this->Quiet);
       int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
-      if ( vgFIM.find(lines[cc]) )
-        {
+      if (vgFIM.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::FIM;
-        }
-      else if ( vgFMM.find(lines[cc]) )
-        {
+      } else if (vgFMM.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::FMM;
-        }
-      else if ( vgMLK1.find(lines[cc]) )
-        {
+      } else if (vgMLK1.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::MLK;
-        }
-      else if ( vgMLK2.find(lines[cc]) )
-        {
+      } else if (vgMLK2.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::MLK;
-        }
-      else if ( vgPAR.find(lines[cc]) )
-        {
+      } else if (vgPAR.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::PAR;
-        }
-      else if ( vgMPK1.find(lines[cc]) )
-        {
+      } else if (vgMPK1.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::MPK;
-        }
-      else if ( vgMPK2.find(lines[cc]) )
-        {
+      } else if (vgMPK2.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::MPK;
-        }
-      else if ( vgUMC.find(lines[cc]) )
-        {
+      } else if (vgUMC.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::UMC;
-        }
-      else if ( vgUMR1.find(lines[cc]) )
-        {
+      } else if (vgUMR1.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::UMR;
-        }
-      else if ( vgUMR2.find(lines[cc]) )
-        {
+      } else if (vgUMR2.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::UMR;
-        }
-      else if ( vgUMR3.find(lines[cc]) )
-        {
+      } else if (vgUMR3.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::UMR;
-        }
-      else if ( vgUMR4.find(lines[cc]) )
-        {
+      } else if (vgUMR4.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::UMR;
-        }
-      else if ( vgUMR5.find(lines[cc]) )
-        {
+      } else if (vgUMR5.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::UMR;
-        }
-      else if ( vgIPW.find(lines[cc]) )
-        {
+      } else if (vgIPW.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::IPW;
-        }
-      else if ( vgABR.find(lines[cc]) )
-        {
+      } else if (vgABR.find(lines[cc])) {
         failure = cmCTestMemCheckHandler::ABR;
-        }
+      }
 
-      if ( failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT )
-        {
+      if (failure != cmCTestMemCheckHandler::NO_MEMORY_FAULT) {
         ostr << "<b>" << this->ResultStrings[failure] << "</b> ";
-        results[failure] ++;
-        defects ++;
-        }
+        results[failure]++;
+        defects++;
+      }
       totalOutputSize += lines[cc].size();
       ostr << lines[cc] << std::endl;
-      }
-    else
-      {
+    } else {
       nonValGrindOutput.push_back(cc);
-      }
     }
+  }
   // Now put all all the non valgrind output into the test output
   // This should be last in case it gets truncated by the output
   // limiting code
-  for(std::vector<std::string::size_type>::iterator i =
-        nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
-    {
+  for (std::vector<std::string::size_type>::iterator i =
+         nonValGrindOutput.begin();
+       i != nonValGrindOutput.end(); ++i) {
     totalOutputSize += lines[*i].size();
     ostr << lines[*i] << std::endl;
-    if(!unlimitedOutput && totalOutputSize >
-       static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
-      {
+    if (!unlimitedOutput &&
+        totalOutputSize >
+          static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)) {
       ostr << "....\n";
       ostr << "Test Output for this test has been truncated see testing"
-        " machine logs for full output,\n";
+              " machine logs for full output,\n";
       ostr << "or put CTEST_FULL_OUTPUT in the output of "
-        "this test program.\n";
-      break;  // stop the copy of output if we are full
-      }
+              "this test program.\n";
+      break; // stop the copy of output if we are full
     }
+  }
   cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
-             << (cmSystemTools::GetTime() - sttime) << std::endl, this->Quiet);
+                       << (cmSystemTools::GetTime() - sttime) << std::endl,
+                     this->Quiet);
   log = ostr.str();
-  if ( defects )
-    {
+  if (defects) {
     return false;
-    }
+  }
   return true;
 }
 
-
-
-//----------------------------------------------------------------------
 bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
-  const std::string& str, std::string& log,
-  std::vector<int>& results)
+  const std::string& str, std::string& log, std::vector<int>& results)
 {
   log = "";
   double sttime = cmSystemTools::GetTime();
   std::vector<std::string> lines;
   cmSystemTools::Split(str.c_str(), lines);
   cmCTestOptionalLog(this->CTest, DEBUG,
-    "Start test: " << lines.size() << std::endl, this->Quiet);
+                     "Start test: " << lines.size() << std::endl, this->Quiet);
   std::vector<std::string>::size_type cc;
-  for ( cc = 0; cc < lines.size(); cc ++ )
-    {
-    if(lines[cc] == BOUNDS_CHECKER_MARKER)
-      {
+  for (cc = 0; cc < lines.size(); cc++) {
+    if (lines[cc] == BOUNDS_CHECKER_MARKER) {
       break;
-      }
     }
+  }
   cmBoundsCheckerParser parser(this->CTest);
   parser.InitializeParser();
-  if(cc < lines.size())
-    {
-    for(cc++; cc < lines.size(); ++cc)
-      {
+  if (cc < lines.size()) {
+    for (cc++; cc < lines.size(); ++cc) {
       std::string& theLine = lines[cc];
       // check for command line arguments that are not escaped
       // correctly by BC
-      if(theLine.find("TargetArgs=") != theLine.npos)
-        {
+      if (theLine.find("TargetArgs=") != theLine.npos) {
         // skip this because BC gets it wrong and we can't parse it
-        }
-      else if(!parser.ParseChunk(theLine.c_str(), theLine.size()))
-        {
+      } else if (!parser.ParseChunk(theLine.c_str(), theLine.size())) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-                   "Error in ParseChunk: " << theLine
-                   << std::endl);
-        }
+                   "Error in ParseChunk: " << theLine << std::endl);
       }
     }
+  }
   int defects = 0;
-  for(cc =0; cc < parser.Errors.size(); ++cc)
-    {
+  for (cc = 0; cc < parser.Errors.size(); ++cc) {
     results[parser.Errors[cc]]++;
     defects++;
-    }
+  }
   cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
-    << (cmSystemTools::GetTime() - sttime) << std::endl, this->Quiet);
-  if(defects)
-    {
+                       << (cmSystemTools::GetTime() - sttime) << std::endl,
+                     this->Quiet);
+  if (defects) {
     // only put the output of Bounds Checker if there were
     // errors or leaks detected
     log = parser.Log;
     return false;
-    }
+  }
   return true;
 }
 
 // PostProcessTest memcheck results
-void
-cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res,
-                                        int test)
+void cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res, int test)
 {
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-             "PostProcessTest memcheck results for : "
-             << res.Name << std::endl, this->Quiet);
-  if(this->MemoryTesterStyle
-     == cmCTestMemCheckHandler::BOUNDS_CHECKER)
-    {
+                     "PostProcessTest memcheck results for : " << res.Name
+                                                               << std::endl,
+                     this->Quiet);
+  if (this->MemoryTesterStyle == cmCTestMemCheckHandler::BOUNDS_CHECKER) {
     this->PostProcessBoundsCheckerTest(res, test);
-    }
-  else
-    {
+  } else {
     std::vector<std::string> files;
     this->TestOutputFileNames(test, files);
-    for(std::vector<std::string>::iterator i = files.begin();
-        i != files.end(); ++i)
-      {
+    for (std::vector<std::string>::iterator i = files.begin();
+         i != files.end(); ++i) {
       this->AppendMemTesterOutput(res, *i);
-      }
     }
+  }
 }
 
-
 // This method puts the bounds checker output file into the output
 // for the test
-void
-cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
-                                                     int test)
+void cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(
+  cmCTestTestResult& res, int test)
 {
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-             "PostProcessBoundsCheckerTest for : "
-             << res.Name << std::endl, this->Quiet);
+                     "PostProcessBoundsCheckerTest for : " << res.Name
+                                                           << std::endl,
+                     this->Quiet);
   std::vector<std::string> files;
   this->TestOutputFileNames(test, files);
-  if (files.empty())
-    {
+  if (files.empty()) {
     return;
-    }
+  }
   std::string ofile = files[0];
-  if ( ofile.empty() )
-    {
+  if (ofile.empty()) {
     return;
-    }
+  }
   // put a scope around this to close ifs so the file can be removed
   {
-  cmsys::ifstream ifs(ofile.c_str());
-  if ( !ifs )
-    {
-    std::string log = "Cannot read memory tester output file: " + ofile;
-    cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
-    return;
+    cmsys::ifstream ifs(ofile.c_str());
+    if (!ifs) {
+      std::string log = "Cannot read memory tester output file: " + ofile;
+      cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
+      return;
     }
-  res.Output += BOUNDS_CHECKER_MARKER;
-  res.Output += "\n";
-  std::string line;
-  while ( cmSystemTools::GetLineFromStream(ifs, line) )
-    {
-    res.Output += line;
+    res.Output += BOUNDS_CHECKER_MARKER;
     res.Output += "\n";
+    std::string line;
+    while (cmSystemTools::GetLineFromStream(ifs, line)) {
+      res.Output += line;
+      res.Output += "\n";
     }
   }
   cmSystemTools::Delay(1000);
   cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile);
-  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
-    << this->BoundsCheckerDPBDFile << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "Remove: " << this->BoundsCheckerDPBDFile << std::endl,
+                     this->Quiet);
   cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile);
-  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
-    << this->BoundsCheckerXMLFile << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "Remove: " << this->BoundsCheckerXMLFile << std::endl,
+                     this->Quiet);
 }
 
-void
-cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
-                                              std::string const& ofile)
+void cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
+                                                   std::string const& ofile)
 {
-  if ( ofile.empty() )
-    {
+  if (ofile.empty()) {
     return;
-    }
+  }
   // put ifs in scope so file can be deleted if needed
   {
-  cmsys::ifstream ifs(ofile.c_str());
-  if ( !ifs )
-    {
-    std::string log = "Cannot read memory tester output file: " + ofile;
-    cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
-    return;
+    cmsys::ifstream ifs(ofile.c_str());
+    if (!ifs) {
+      std::string log = "Cannot read memory tester output file: " + ofile;
+      cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
+      return;
     }
-  std::string line;
-  while ( cmSystemTools::GetLineFromStream(ifs, line) )
-    {
-    res.Output += line;
-    res.Output += "\n";
+    std::string line;
+    while (cmSystemTools::GetLineFromStream(ifs, line)) {
+      res.Output += line;
+      res.Output += "\n";
     }
   }
-  if(this->LogWithPID)
-    {
+  if (this->LogWithPID) {
     cmSystemTools::RemoveFile(ofile);
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Remove: "<< ofile <<"\n", this->Quiet);
-    }
+                       "Remove: " << ofile << "\n", this->Quiet);
+  }
 }
 
-void cmCTestMemCheckHandler::TestOutputFileNames(int test,
-                                                 std::vector<std::string>&
-                                                 files)
+void cmCTestMemCheckHandler::TestOutputFileNames(
+  int test, std::vector<std::string>& files)
 {
   std::string index;
   std::ostringstream stream;
@@ -1268,30 +1058,22 @@ void cmCTestMemCheckHandler::TestOutputFileNames(int test,
   std::string ofile = this->MemoryTesterOutputFile;
   std::string::size_type pos = ofile.find("??");
   ofile.replace(pos, 2, index);
-  if(this->LogWithPID)
-    {
+  if (this->LogWithPID) {
     ofile += ".*";
     cmsys::Glob g;
     g.FindFiles(ofile);
-    if(g.GetFiles().empty())
-      {
-      std::string log = "Cannot find memory tester output file: "
-        + ofile;
+    if (g.GetFiles().empty()) {
+      std::string log = "Cannot find memory tester output file: " + ofile;
       cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
       ofile = "";
-      }
-    else
-      {
+    } else {
       files = g.GetFiles();
       return;
-      }
     }
-  else if ( !cmSystemTools::FileExists(ofile.c_str()) )
-    {
-    std::string log = "Cannot find memory tester output file: "
-      + ofile;
+  } else if (!cmSystemTools::FileExists(ofile.c_str())) {
+    std::string log = "Cannot find memory tester output file: " + ofile;
     cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl);
     ofile = "";
-    }
+  }
   files.push_back(ofile);
 }
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index f1ac794..8f0cc47 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -13,12 +13,11 @@
 #ifndef cmCTestMemCheckHandler_h
 #define cmCTestMemCheckHandler_h
 
-
 #include "cmCTestTestHandler.h"
-#include "cmStandardIncludes.h"
+
 #include "cmListFileCache.h"
-#include <vector>
 #include <string>
+#include <vector>
 
 class cmMakefile;
 class cmXMLWriter;
@@ -30,22 +29,24 @@ class cmXMLWriter;
 class cmCTestMemCheckHandler : public cmCTestTestHandler
 {
   friend class cmCTestRunTest;
+
 public:
   cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler);
 
-  void PopulateCustomVectors(cmMakefile *mf);
+  void PopulateCustomVectors(cmMakefile* mf);
 
   cmCTestMemCheckHandler();
 
   void Initialize();
+
 protected:
   virtual int PreProcessHandler();
   virtual int PostProcessHandler();
   virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
 
 private:
-
-  enum { // Memory checkers
+  enum
+  { // Memory checkers
     UNKNOWN = 0,
     VALGRIND,
     PURIFY,
@@ -56,8 +57,10 @@ private:
     MEMORY_SANITIZER,
     UB_SANITIZER
   };
+
 public:
-  enum { // Memory faults
+  enum
+  { // Memory faults
     ABR = 0,
     ABW,
     ABWL,
@@ -82,8 +85,10 @@ public:
     UMR,
     NO_MEMORY_FAULT
   };
+
 private:
-  enum { // Program statuses
+  enum
+  { // Program statuses
     NOT_RUN = 0,
     TIMEOUT,
     SEGFAULT,
@@ -95,19 +100,19 @@ private:
     BAD_COMMAND,
     COMPLETED
   };
-  std::string              BoundsCheckerDPBDFile;
-  std::string              BoundsCheckerXMLFile;
-  std::string              MemoryTester;
+  std::string BoundsCheckerDPBDFile;
+  std::string BoundsCheckerXMLFile;
+  std::string MemoryTester;
   std::vector<std::string> MemoryTesterDynamicOptions;
   std::vector<std::string> MemoryTesterOptions;
-  int                      MemoryTesterStyle;
-  std::string              MemoryTesterOutputFile;
-  std::string              MemoryTesterEnvironmentVariable;
+  int MemoryTesterStyle;
+  std::string MemoryTesterOutputFile;
+  std::string MemoryTesterEnvironmentVariable;
   // these are used to store the types of errors that can show up
   std::vector<std::string> ResultStrings;
   std::vector<std::string> ResultStringsLong;
-  std::vector<int>         GlobalResults;
-  bool                     LogWithPID; // does log file add pid
+  std::vector<int> GlobalResults;
+  bool LogWithPID; // does log file add pid
 
   std::vector<int>::size_type FindOrAddWarning(const std::string& warning);
   // initialize the ResultStrings and ResultStringsLong for
@@ -126,18 +131,15 @@ private:
   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
-  //different memmory errors.
-  bool ProcessMemCheckOutput(const std::string& str,
-                             std::string& log, std::vector<int>& results);
-  bool ProcessMemCheckValgrindOutput(const std::string& str,
-                                     std::string& log,
+  // string. After running, log holds the output and results hold the
+  // different memmory errors.
+  bool ProcessMemCheckOutput(const std::string& str, std::string& log,
+                             std::vector<int>& results);
+  bool ProcessMemCheckValgrindOutput(const std::string& str, std::string& log,
                                      std::vector<int>& results);
-  bool ProcessMemCheckPurifyOutput(const std::string& str,
-                                   std::string& log,
+  bool ProcessMemCheckPurifyOutput(const std::string& str, std::string& log,
                                    std::vector<int>& results);
-  bool ProcessMemCheckSanitizerOutput(const std::string& str,
-                                      std::string& log,
+  bool ProcessMemCheckSanitizerOutput(const std::string& str, std::string& log,
                                       std::vector<int>& results);
   bool ProcessMemCheckBoundsCheckerOutput(const std::string& str,
                                           std::string& log,
@@ -155,4 +157,3 @@ private:
 };
 
 #endif
-
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 7c7f5df..6f19b32 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -10,31 +10,35 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCTestMultiProcessHandler.h"
-#include "cmProcess.h"
-#include "cmStandardIncludes.h"
+
 #include "cmCTest.h"
 #include "cmCTestScriptHandler.h"
+#include "cmProcess.h"
+#include "cmStandardIncludes.h"
 #include "cmSystemTools.h"
-#include <stdlib.h>
-#include <stack>
-#include <list>
-#include <float.h>
-#include <math.h>
 #include <cmsys/FStream.hxx>
 #include <cmsys/SystemInformation.hxx>
+#include <float.h>
+#include <list>
+#include <math.h>
+#include <stack>
+#include <stdlib.h>
 
 class TestComparator
 {
 public:
-  TestComparator(cmCTestMultiProcessHandler* handler) : Handler(handler) {}
+  TestComparator(cmCTestMultiProcessHandler* handler)
+    : Handler(handler)
+  {
+  }
   ~TestComparator() {}
 
   // Sorts tests in descending order of cost
-  bool operator() (int index1, int index2) const
-    {
+  bool operator()(int index1, int index2) const
+  {
     return Handler->Properties[index1]->Cost >
       Handler->Properties[index2]->Cost;
-    }
+  }
 
 private:
   cmCTestMultiProcessHandler* Handler;
@@ -55,34 +59,30 @@ cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler()
 {
 }
 
-  // Set the tests
-void
-cmCTestMultiProcessHandler::SetTests(TestMap& tests,
-                                     PropertiesMap& properties)
+// Set the tests
+void cmCTestMultiProcessHandler::SetTests(TestMap& tests,
+                                          PropertiesMap& properties)
 {
   this->Tests = tests;
   this->Properties = properties;
   this->Total = this->Tests.size();
   // set test run map to false for all
-  for(TestMap::iterator i = this->Tests.begin();
-      i != this->Tests.end(); ++i)
-    {
+  for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
+       ++i) {
     this->TestRunningMap[i->first] = false;
     this->TestFinishMap[i->first] = false;
-    }
-  if(!this->CTest->GetShowOnly())
-    {
+  }
+  if (!this->CTest->GetShowOnly()) {
     this->ReadCostData();
     this->HasCycles = !this->CheckCycles();
-    if(this->HasCycles)
-      {
+    if (this->HasCycles) {
       return;
-      }
-    this->CreateTestCostList();
     }
+    this->CreateTestCostList();
+  }
 }
 
-  // Set the max number of tests that can be run at the same time.
+// Set the max number of tests that can be run at the same time.
 void cmCTestMultiProcessHandler::SetParallelLevel(size_t level)
 {
   this->ParallelLevel = level < 1 ? 1 : level;
@@ -93,49 +93,42 @@ void cmCTestMultiProcessHandler::SetTestLoad(unsigned long load)
   this->TestLoad = load;
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::RunTests()
 {
   this->CheckResume();
-  if(this->HasCycles)
-    {
+  if (this->HasCycles) {
     return;
-    }
+  }
   this->TestHandler->SetMaxIndex(this->FindMaxIndex());
   this->StartNextTests();
-  while(!this->Tests.empty())
-    {
-    if(this->StopTimePassed)
-      {
+  while (!this->Tests.empty()) {
+    if (this->StopTimePassed) {
       return;
-      }
+    }
     this->CheckOutput();
     this->StartNextTests();
-    }
+  }
   // let all running tests finish
-  while(this->CheckOutput())
-    {
-    }
+  while (this->CheckOutput()) {
+  }
   this->MarkFinished();
   this->UpdateCostData();
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::StartTestProcess(int test)
 {
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "test " << test << "\n", this->Quiet);
+                     "test " << test << "\n", this->Quiet);
   this->TestRunningMap[test] = true; // mark the test as running
   // now remove the test itself
   this->EraseTest(test);
   this->RunningCount += GetProcessorsUsed(test);
 
   cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler);
-  if(this->CTest->GetRepeatUntilFail())
-    {
+  if (this->CTest->GetRepeatUntilFail()) {
     testRun->SetRunUntilFailOn();
     testRun->SetNumberOfRuns(this->CTest->GetTestRepeat());
-    }
+  }
   testRun->SetIndex(test);
   testRun->SetTestProperties(this->Properties[test]);
 
@@ -145,24 +138,18 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
   // Lock the resources we'll be using
   this->LockResources(test);
 
-  if(testRun->StartTest(this->Total))
-    {
+  if (testRun->StartTest(this->Total)) {
     this->RunningTests.insert(testRun);
-    }
-  else if(testRun->IsStopTimePassed())
-    {
+  } else if (testRun->IsStopTimePassed()) {
     this->StopTimePassed = true;
     delete testRun;
     return;
-    }
-  else
-    {
+  } else {
 
-    for(TestMap::iterator j = this->Tests.begin();
-      j != this->Tests.end(); ++j)
-      {
+    for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
+         ++j) {
       j->second.erase(test);
-      }
+    }
 
     this->UnlockResources(test);
     this->Completed++;
@@ -172,39 +159,33 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
     testRun->EndTest(this->Completed, this->Total, false);
     this->Failed->push_back(this->Properties[test]->Name);
     delete testRun;
-    }
+  }
   cmSystemTools::ChangeDirectory(current_dir);
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::LockResources(int index)
 {
   this->LockedResources.insert(
-      this->Properties[index]->LockedResources.begin(),
-      this->Properties[index]->LockedResources.end());
+    this->Properties[index]->LockedResources.begin(),
+    this->Properties[index]->LockedResources.end());
 
-  if (this->Properties[index]->RunSerial)
-    {
+  if (this->Properties[index]->RunSerial) {
     this->SerialTestRunning = true;
-    }
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::UnlockResources(int index)
 {
-  for(std::set<std::string>::iterator i =
-      this->Properties[index]->LockedResources.begin();
-      i != this->Properties[index]->LockedResources.end(); ++i)
-    {
+  for (std::set<std::string>::iterator i =
+         this->Properties[index]->LockedResources.begin();
+       i != this->Properties[index]->LockedResources.end(); ++i) {
     this->LockedResources.erase(*i);
-    }
-  if (this->Properties[index]->RunSerial)
-    {
+  }
+  if (this->Properties[index]->RunSerial) {
     this->SerialTestRunning = false;
-    }
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::EraseTest(int test)
 {
   this->Tests.erase(test);
@@ -212,17 +193,14 @@ void cmCTestMultiProcessHandler::EraseTest(int test)
     std::find(this->SortedTests.begin(), this->SortedTests.end(), test));
 }
 
-//---------------------------------------------------------
 inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test)
 {
-  size_t processors =
-    static_cast<int>(this->Properties[test]->Processors);
-  //If processors setting is set higher than the -j
-  //setting, we default to using all of the process slots.
-  if (processors > this->ParallelLevel)
-    {
+  size_t processors = static_cast<int>(this->Properties[test]->Processors);
+  // If processors setting is set higher than the -j
+  // setting, we default to using all of the process slots.
+  if (processors > this->ParallelLevel) {
     processors = this->ParallelLevel;
-    }
+  }
   return processors;
 }
 
@@ -231,51 +209,43 @@ std::string cmCTestMultiProcessHandler::GetName(int test)
   return this->Properties[test]->Name;
 }
 
-//---------------------------------------------------------
 bool cmCTestMultiProcessHandler::StartTest(int test)
 {
-  //Check for locked resources
-  for(std::set<std::string>::iterator i =
-      this->Properties[test]->LockedResources.begin();
-      i != this->Properties[test]->LockedResources.end(); ++i)
-    {
-    if(this->LockedResources.find(*i) != this->LockedResources.end())
-      {
+  // Check for locked resources
+  for (std::set<std::string>::iterator i =
+         this->Properties[test]->LockedResources.begin();
+       i != this->Properties[test]->LockedResources.end(); ++i) {
+    if (this->LockedResources.find(*i) != this->LockedResources.end()) {
       return false;
-      }
     }
+  }
 
   // if there are no depends left then run this test
-  if(this->Tests[test].empty())
-    {
+  if (this->Tests[test].empty()) {
     this->StartTestProcess(test);
     return true;
-    }
+  }
   // This test was not able to start because it is waiting
   // on depends to run
   return false;
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::StartNextTests()
 {
   size_t numToStart = 0;
-  if(this->RunningCount < this->ParallelLevel)
-    {
+  if (this->RunningCount < this->ParallelLevel) {
     numToStart = this->ParallelLevel - this->RunningCount;
-    }
+  }
 
-  if(numToStart == 0)
-    {
+  if (numToStart == 0) {
     return;
-    }
+  }
 
   // Don't start any new tests if one with the RUN_SERIAL property
   // is already running.
-  if (this->SerialTestRunning)
-    {
+  if (this->SerialTestRunning) {
     return;
-    }
+  }
 
   bool allTestsFailedTestLoadCheck = false;
   bool usedFakeLoadForTesting = false;
@@ -286,169 +256,137 @@ void cmCTestMultiProcessHandler::StartNextTests()
 
   unsigned long systemLoad = 0;
   size_t spareLoad = 0;
-  if (this->TestLoad > 0)
-    {
+  if (this->TestLoad > 0) {
     // Activate possible wait.
     allTestsFailedTestLoadCheck = true;
 
     // Check for a fake load average value used in testing.
     if (const char* fake_load_value =
-        cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING"))
-      {
+          cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING")) {
       usedFakeLoadForTesting = true;
-      if (!cmSystemTools::StringToULong(fake_load_value, &systemLoad))
-        {
+      if (!cmSystemTools::StringToULong(fake_load_value, &systemLoad)) {
         cmSystemTools::Error("Failed to parse fake load value: ",
                              fake_load_value);
-        }
       }
+    }
     // If it's not set, look up the true load average.
-    else
-      {
+    else {
       systemLoad = static_cast<unsigned long>(ceil(info.GetLoadAverage()));
-      }
-    spareLoad = (this->TestLoad > systemLoad ?
-                 this->TestLoad - systemLoad : 0);
+    }
+    spareLoad =
+      (this->TestLoad > systemLoad ? this->TestLoad - systemLoad : 0);
 
     // Don't start more tests than the spare load can support.
-    if (numToStart > spareLoad)
-      {
+    if (numToStart > spareLoad) {
       numToStart = spareLoad;
-      }
     }
+  }
 
   TestList copy = this->SortedTests;
-  for(TestList::iterator test = copy.begin(); test != copy.end(); ++test)
-    {
+  for (TestList::iterator test = copy.begin(); test != copy.end(); ++test) {
     // Take a nap if we're currently performing a RUN_SERIAL test.
-    if (this->SerialTestRunning)
-      {
+    if (this->SerialTestRunning) {
       break;
-      }
+    }
     // We can only start a RUN_SERIAL test if no other tests are also running.
-    if (this->Properties[*test]->RunSerial && this->RunningCount > 0)
-      {
+    if (this->Properties[*test]->RunSerial && this->RunningCount > 0) {
       continue;
-      }
+    }
 
     size_t processors = GetProcessorsUsed(*test);
     bool testLoadOk = true;
-    if (this->TestLoad > 0)
-      {
-      if (processors <= spareLoad)
-        {
-        cmCTestLog(this->CTest, DEBUG,
-                    "OK to run " << GetName(*test) <<
-                    ", it requires " << processors <<
-                    " procs & system load is: " <<
-                    systemLoad << std::endl);
+    if (this->TestLoad > 0) {
+      if (processors <= spareLoad) {
+        cmCTestLog(this->CTest, DEBUG, "OK to run "
+                     << GetName(*test) << ", it requires " << processors
+                     << " procs & system load is: " << systemLoad
+                     << std::endl);
         allTestsFailedTestLoadCheck = false;
-        }
-      else
-        {
+      } else {
         testLoadOk = false;
-        }
       }
+    }
 
-    if (processors <= minProcessorsRequired)
-      {
+    if (processors <= minProcessorsRequired) {
       minProcessorsRequired = processors;
       testWithMinProcessors = GetName(*test);
-      }
+    }
 
-    if(testLoadOk && processors <= numToStart && this->StartTest(*test))
-      {
-      if(this->StopTimePassed)
-        {
+    if (testLoadOk && processors <= numToStart && this->StartTest(*test)) {
+      if (this->StopTimePassed) {
         return;
-        }
+      }
 
       numToStart -= processors;
-      }
-    else if(numToStart == 0)
-      {
+    } else if (numToStart == 0) {
       break;
-      }
     }
+  }
 
-  if (allTestsFailedTestLoadCheck)
-    {
+  if (allTestsFailedTestLoadCheck) {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***** WAITING, ");
-    if (this->SerialTestRunning)
-      {
+    if (this->SerialTestRunning) {
       cmCTestLog(this->CTest, HANDLER_OUTPUT,
                  "Waiting for RUN_SERIAL test to finish.");
-      }
-    else
-      {
+    } else {
+      /* clang-format off */
       cmCTestLog(this->CTest, HANDLER_OUTPUT,
                  "System Load: " << systemLoad << ", "
                  "Max Allowed Load: " << this->TestLoad << ", "
                  "Smallest test " << testWithMinProcessors <<
                  " requires " << minProcessorsRequired);
-      }
+      /* clang-format on */
+    }
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "*****" << std::endl);
 
-    if (usedFakeLoadForTesting)
-      {
+    if (usedFakeLoadForTesting) {
       // Break out of the infinite loop of waiting for our fake load
       // to come down.
       this->StopTimePassed = true;
-      }
-    else
-      {
+    } else {
       // Wait between 1 and 5 seconds before trying again.
-      cmCTestScriptHandler::SleepInSeconds(
-        cmSystemTools::RandomSeed() % 5 + 1);
-      }
+      cmCTestScriptHandler::SleepInSeconds(cmSystemTools::RandomSeed() % 5 +
+                                           1);
     }
+  }
 }
 
-//---------------------------------------------------------
 bool cmCTestMultiProcessHandler::CheckOutput()
 {
   // no more output we are done
-  if(this->RunningTests.empty())
-    {
+  if (this->RunningTests.empty()) {
     return false;
-    }
+  }
   std::vector<cmCTestRunTest*> finished;
   std::string out, err;
-  for(std::set<cmCTestRunTest*>::const_iterator i = this->RunningTests.begin();
-      i != this->RunningTests.end(); ++i)
-    {
+  for (std::set<cmCTestRunTest*>::const_iterator i =
+         this->RunningTests.begin();
+       i != this->RunningTests.end(); ++i) {
     cmCTestRunTest* p = *i;
-    if(!p->CheckOutput())
-      {
+    if (!p->CheckOutput()) {
       finished.push_back(p);
-      }
     }
-  for( std::vector<cmCTestRunTest*>::iterator i = finished.begin();
-       i != finished.end(); ++i)
-    {
+  }
+  for (std::vector<cmCTestRunTest*>::iterator i = finished.begin();
+       i != finished.end(); ++i) {
     this->Completed++;
     cmCTestRunTest* p = *i;
     int test = p->GetIndex();
 
     bool testResult = p->EndTest(this->Completed, this->Total, true);
-    if(p->StartAgain())
-      {
+    if (p->StartAgain()) {
       this->Completed--; // remove the completed test because run again
       continue;
-      }
-    if(testResult)
-      {
+    }
+    if (testResult) {
       this->Passed->push_back(p->GetTestProperties()->Name);
-      }
-    else
-      {
+    } else {
       this->Failed->push_back(p->GetTestProperties()->Name);
-      }
-    for(TestMap::iterator j = this->Tests.begin();
-        j != this->Tests.end(); ++j)
-      {
+    }
+    for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
+         ++j) {
       j->second.erase(test);
-      }
+    }
     this->TestFinishMap[test] = true;
     this->TestRunningMap[test] = false;
     this->RunningTests.erase(p);
@@ -456,11 +394,10 @@ bool cmCTestMultiProcessHandler::CheckOutput()
     this->UnlockResources(test);
     this->RunningCount -= GetProcessorsUsed(test);
     delete p;
-    }
+  }
   return true;
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::UpdateCostData()
 {
   std::string fname = this->CTest->GetCostDataFile();
@@ -470,423 +407,368 @@ void cmCTestMultiProcessHandler::UpdateCostData()
 
   PropertiesMap temp = this->Properties;
 
-  if(cmSystemTools::FileExists(fname.c_str()))
-    {
+  if (cmSystemTools::FileExists(fname.c_str())) {
     cmsys::ifstream fin;
     fin.open(fname.c_str());
 
     std::string line;
-    while(std::getline(fin, line))
-      {
-      if(line == "---") break;
-      std::vector<cmsys::String> parts =
-        cmSystemTools::SplitString(line, ' ');
-      //Format: <name> <previous_runs> <avg_cost>
-      if(parts.size() < 3) break;
+    while (std::getline(fin, line)) {
+      if (line == "---")
+        break;
+      std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
+      // Format: <name> <previous_runs> <avg_cost>
+      if (parts.size() < 3)
+        break;
 
       std::string name = parts[0];
       int prev = atoi(parts[1].c_str());
       float cost = static_cast<float>(atof(parts[2].c_str()));
 
       int index = this->SearchByName(name);
-      if(index == -1)
-        {
+      if (index == -1) {
         // This test is not in memory. We just rewrite the entry
         fout << name << " " << prev << " " << cost << "\n";
-        }
-      else
-        {
+      } else {
         // Update with our new average cost
         fout << name << " " << this->Properties[index]->PreviousRuns << " "
-          << this->Properties[index]->Cost << "\n";
+             << this->Properties[index]->Cost << "\n";
         temp.erase(index);
-        }
       }
+    }
     fin.close();
     cmSystemTools::RemoveFile(fname);
-    }
+  }
 
   // Add all tests not previously listed in the file
-  for(PropertiesMap::iterator i = temp.begin(); i != temp.end(); ++i)
-    {
+  for (PropertiesMap::iterator i = temp.begin(); i != temp.end(); ++i) {
     fout << i->second->Name << " " << i->second->PreviousRuns << " "
-      << i->second->Cost << "\n";
-    }
+         << i->second->Cost << "\n";
+  }
 
   // Write list of failed tests
   fout << "---\n";
-  for(std::vector<std::string>::iterator i = this->Failed->begin();
-      i != this->Failed->end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = this->Failed->begin();
+       i != this->Failed->end(); ++i) {
     fout << i->c_str() << "\n";
-    }
+  }
   fout.close();
   cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str());
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::ReadCostData()
 {
   std::string fname = this->CTest->GetCostDataFile();
 
-  if(cmSystemTools::FileExists(fname.c_str(), true))
-    {
+  if (cmSystemTools::FileExists(fname.c_str(), true)) {
     cmsys::ifstream fin;
     fin.open(fname.c_str());
     std::string line;
-    while(std::getline(fin, line))
-      {
-      if(line == "---") break;
+    while (std::getline(fin, line)) {
+      if (line == "---")
+        break;
 
-      std::vector<cmsys::String> parts =
-        cmSystemTools::SplitString(line, ' ');
+      std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
 
       // Probably an older version of the file, will be fixed next run
-      if(parts.size() < 3)
-        {
+      if (parts.size() < 3) {
         fin.close();
         return;
-        }
+      }
 
       std::string name = parts[0];
       int prev = atoi(parts[1].c_str());
       float cost = static_cast<float>(atof(parts[2].c_str()));
 
       int index = this->SearchByName(name);
-      if(index == -1) continue;
+      if (index == -1)
+        continue;
 
       this->Properties[index]->PreviousRuns = prev;
       // When not running in parallel mode, don't use cost data
-      if(this->ParallelLevel > 1 &&
-         this->Properties[index] &&
-         this->Properties[index]->Cost == 0)
-        {
+      if (this->ParallelLevel > 1 && this->Properties[index] &&
+          this->Properties[index]->Cost == 0) {
         this->Properties[index]->Cost = cost;
-        }
       }
+    }
     // Next part of the file is the failed tests
-    while(std::getline(fin, line))
-      {
-      if(line != "")
-        {
+    while (std::getline(fin, line)) {
+      if (line != "") {
         this->LastTestsFailed.push_back(line);
-        }
       }
-    fin.close();
     }
+    fin.close();
+  }
 }
 
-//---------------------------------------------------------
-int cmCTestMultiProcessHandler::SearchByName(std::string name)
+int cmCTestMultiProcessHandler::SearchByName(std::string const& name)
 {
   int index = -1;
 
-  for(PropertiesMap::iterator i = this->Properties.begin();
-      i != this->Properties.end(); ++i)
-    {
-    if(i->second->Name == name)
-      {
+  for (PropertiesMap::iterator i = this->Properties.begin();
+       i != this->Properties.end(); ++i) {
+    if (i->second->Name == name) {
       index = i->first;
-      }
     }
+  }
   return index;
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::CreateTestCostList()
 {
-  if(this->ParallelLevel > 1)
-    {
+  if (this->ParallelLevel > 1) {
     CreateParallelTestCostList();
-    }
-  else
-    {
+  } else {
     CreateSerialTestCostList();
-    }
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::CreateParallelTestCostList()
 {
   TestSet alreadySortedTests;
 
   std::list<TestSet> priorityStack;
   priorityStack.push_back(TestSet());
-  TestSet &topLevel = priorityStack.back();
+  TestSet& topLevel = priorityStack.back();
 
   // In parallel test runs add previously failed tests to the front
   // of the cost list and queue other tests for further sorting
-  for(TestMap::const_iterator i = this->Tests.begin();
-    i != this->Tests.end(); ++i)
-    {
-    if(std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
-       this->Properties[i->first]->Name) != this->LastTestsFailed.end())
-      {
-      //If the test failed last time, it should be run first.
+  for (TestMap::const_iterator i = this->Tests.begin(); i != this->Tests.end();
+       ++i) {
+    if (std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
+                  this->Properties[i->first]->Name) !=
+        this->LastTestsFailed.end()) {
+      // If the test failed last time, it should be run first.
       this->SortedTests.push_back(i->first);
       alreadySortedTests.insert(i->first);
-      }
-    else
-      {
+    } else {
       topLevel.insert(i->first);
-      }
     }
+  }
 
   // In parallel test runs repeatedly move dependencies of the tests on
   // the current dependency level to the next level until no
   // further dependencies exist.
-  while(priorityStack.back().size())
-    {
-    TestSet &previousSet = priorityStack.back();
+  while (priorityStack.back().size()) {
+    TestSet& previousSet = priorityStack.back();
     priorityStack.push_back(TestSet());
-    TestSet &currentSet = priorityStack.back();
+    TestSet& currentSet = priorityStack.back();
 
-    for(TestSet::const_iterator i = previousSet.begin();
-      i != previousSet.end(); ++i)
-      {
+    for (TestSet::const_iterator i = previousSet.begin();
+         i != previousSet.end(); ++i) {
       TestSet const& dependencies = this->Tests[*i];
       currentSet.insert(dependencies.begin(), dependencies.end());
-      }
+    }
 
-    for(TestSet::const_iterator i = currentSet.begin();
-      i != currentSet.end(); ++i)
-      {
+    for (TestSet::const_iterator i = currentSet.begin(); i != currentSet.end();
+         ++i) {
       previousSet.erase(*i);
-      }
     }
+  }
 
   // Remove the empty dependency level
   priorityStack.pop_back();
 
   // Reverse iterate over the different dependency levels (deepest first).
   // Sort tests within each level by COST and append them to the cost list.
-  for(std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
-    i != priorityStack.rend(); ++i)
-    {
+  for (std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
+       i != priorityStack.rend(); ++i) {
     TestSet const& currentSet = *i;
     TestComparator comp(this);
 
     TestList sortedCopy;
 
-    sortedCopy.insert(sortedCopy.end(),
-                      currentSet.begin(), currentSet.end());
+    sortedCopy.insert(sortedCopy.end(), currentSet.begin(), currentSet.end());
 
     std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp);
 
-    for(TestList::const_iterator j = sortedCopy.begin();
-      j != sortedCopy.end(); ++j)
-      {
-      if(alreadySortedTests.find(*j) == alreadySortedTests.end())
-        {
+    for (TestList::const_iterator j = sortedCopy.begin();
+         j != sortedCopy.end(); ++j) {
+      if (alreadySortedTests.find(*j) == alreadySortedTests.end()) {
         this->SortedTests.push_back(*j);
         alreadySortedTests.insert(*j);
-        }
       }
     }
+  }
 }
 
-//---------------------------------------------------------
-void cmCTestMultiProcessHandler::GetAllTestDependencies(
-    int test, TestList& dependencies)
+void cmCTestMultiProcessHandler::GetAllTestDependencies(int test,
+                                                        TestList& dependencies)
 {
   TestSet const& dependencySet = this->Tests[test];
-  for(TestSet::const_iterator i = dependencySet.begin();
-    i != dependencySet.end(); ++i)
-    {
+  for (TestSet::const_iterator i = dependencySet.begin();
+       i != dependencySet.end(); ++i) {
     GetAllTestDependencies(*i, dependencies);
     dependencies.push_back(*i);
-    }
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::CreateSerialTestCostList()
 {
   TestList presortedList;
 
-  for(TestMap::iterator i = this->Tests.begin();
-    i != this->Tests.end(); ++i)
-    {
+  for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
+       ++i) {
     presortedList.push_back(i->first);
-    }
+  }
 
   TestComparator comp(this);
   std::stable_sort(presortedList.begin(), presortedList.end(), comp);
 
   TestSet alreadySortedTests;
 
-  for(TestList::const_iterator i = presortedList.begin();
-    i != presortedList.end(); ++i)
-    {
-      int test = *i;
-
-      if(alreadySortedTests.find(test) != alreadySortedTests.end())
-        {
-        continue;
-        }
+  for (TestList::const_iterator i = presortedList.begin();
+       i != presortedList.end(); ++i) {
+    int test = *i;
 
-      TestList dependencies;
-      GetAllTestDependencies(test, dependencies);
+    if (alreadySortedTests.find(test) != alreadySortedTests.end()) {
+      continue;
+    }
 
-      for(TestList::const_iterator j = dependencies.begin();
-        j != dependencies.end(); ++j)
-        {
-        int testDependency = *j;
+    TestList dependencies;
+    GetAllTestDependencies(test, dependencies);
 
-        if(alreadySortedTests.find(testDependency) == alreadySortedTests.end())
-          {
-          alreadySortedTests.insert(testDependency);
-          this->SortedTests.push_back(testDependency);
-          }
-        }
+    for (TestList::const_iterator j = dependencies.begin();
+         j != dependencies.end(); ++j) {
+      int testDependency = *j;
 
-      alreadySortedTests.insert(test);
-      this->SortedTests.push_back(test);
+      if (alreadySortedTests.find(testDependency) ==
+          alreadySortedTests.end()) {
+        alreadySortedTests.insert(testDependency);
+        this->SortedTests.push_back(testDependency);
+      }
     }
+
+    alreadySortedTests.insert(test);
+    this->SortedTests.push_back(test);
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
 {
-  std::string fname = this->CTest->GetBinaryDir()
-    + "/Testing/Temporary/CTestCheckpoint.txt";
+  std::string fname =
+    this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
   cmsys::ofstream fout;
   fout.open(fname.c_str(), std::ios::app);
   fout << index << "\n";
   fout.close();
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::MarkFinished()
 {
-  std::string fname = this->CTest->GetBinaryDir()
-    + "/Testing/Temporary/CTestCheckpoint.txt";
+  std::string fname =
+    this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
   cmSystemTools::RemoveFile(fname);
 }
 
-//---------------------------------------------------------
-//For ShowOnly mode
+// For ShowOnly mode
 void cmCTestMultiProcessHandler::PrintTestList()
 {
   this->TestHandler->SetMaxIndex(this->FindMaxIndex());
   int count = 0;
 
   for (PropertiesMap::iterator it = this->Properties.begin();
-       it != this->Properties.end(); ++it)
-    {
+       it != this->Properties.end(); ++it) {
     count++;
     cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
 
-    //push working dir
+    // push working dir
     std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
     cmSystemTools::ChangeDirectory(p.Directory);
 
     cmCTestRunTest testRun(this->TestHandler);
     testRun.SetIndex(p.Index);
     testRun.SetTestProperties(&p);
-    testRun.ComputeArguments(); //logs the command in verbose mode
+    testRun.ComputeArguments(); // logs the command in verbose mode
 
-    if(!p.Labels.empty()) //print the labels
-      {
+    if (!p.Labels.empty()) // print the labels
+    {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:",
-        this->Quiet);
-      }
-    for(std::vector<std::string>::iterator label = p.Labels.begin();
-        label != p.Labels.end(); ++label)
-      {
+                         this->Quiet);
+    }
+    for (std::vector<std::string>::iterator label = p.Labels.begin();
+         label != p.Labels.end(); ++label) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label,
-        this->Quiet);
-      }
-    if(!p.Labels.empty()) //print the labels
-      {
+                         this->Quiet);
+    }
+    if (!p.Labels.empty()) // print the labels
+    {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
-        this->Quiet);
-      }
+                         this->Quiet);
+    }
 
-    if (this->TestHandler->MemCheck)
-      {
+    if (this->TestHandler->MemCheck) {
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "  Memory Check",
-        this->Quiet);
-      }
-     else
-      {
+                         this->Quiet);
+    } else {
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "  Test", this->Quiet);
-      }
+    }
     std::ostringstream indexStr;
     indexStr << " #" << p.Index << ":";
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+    cmCTestOptionalLog(
+      this->CTest, HANDLER_OUTPUT,
       std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
-      << indexStr.str(), this->Quiet);
+        << indexStr.str(),
+      this->Quiet);
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      p.Name.c_str() << std::endl, this->Quiet);
-    //pop working dir
+                       p.Name.c_str() << std::endl, this->Quiet);
+    // pop working dir
     cmSystemTools::ChangeDirectory(current_dir);
-    }
+  }
 
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: "
-    << this->Total << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl
+                       << "Total Tests: " << this->Total << std::endl,
+                     this->Quiet);
 }
 
 void cmCTestMultiProcessHandler::PrintLabels()
 {
   std::set<std::string> allLabels;
   for (PropertiesMap::iterator it = this->Properties.begin();
-       it != this->Properties.end(); ++it)
-    {
+       it != this->Properties.end(); ++it) {
     cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
     allLabels.insert(p.Labels.begin(), p.Labels.end());
-    }
+  }
 
-  if(!allLabels.empty())
-    {
+  if (!allLabels.empty()) {
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "All Labels:" << std::endl,
+                       this->Quiet);
+  } else {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "All Labels:" << std::endl, this->Quiet);
-    }
-  else
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "No Labels Exist" << std::endl, this->Quiet);
-    }
-  for(std::set<std::string>::iterator label = allLabels.begin();
-      label != allLabels.end(); ++label)
-    {
+                       "No Labels Exist" << std::endl, this->Quiet);
+  }
+  for (std::set<std::string>::iterator label = allLabels.begin();
+       label != allLabels.end(); ++label) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "  " << *label << std::endl, this->Quiet);
-    }
+                       "  " << *label << std::endl, this->Quiet);
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::CheckResume()
 {
-  std::string fname = this->CTest->GetBinaryDir()
-      + "/Testing/Temporary/CTestCheckpoint.txt";
-  if(this->CTest->GetFailover())
-    {
-    if(cmSystemTools::FileExists(fname.c_str(), true))
-      {
-      *this->TestHandler->LogFile << "Resuming previously interrupted test set"
-        << std::endl
+  std::string fname =
+    this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
+  if (this->CTest->GetFailover()) {
+    if (cmSystemTools::FileExists(fname.c_str(), true)) {
+      *this->TestHandler->LogFile
+        << "Resuming previously interrupted test set" << std::endl
         << "----------------------------------------------------------"
         << std::endl;
 
       cmsys::ifstream fin;
       fin.open(fname.c_str());
       std::string line;
-      while(std::getline(fin, line))
-        {
+      while (std::getline(fin, line)) {
         int index = atoi(line.c_str());
         this->RemoveTest(index);
-        }
-      fin.close();
       }
+      fin.close();
     }
-  else if(cmSystemTools::FileExists(fname.c_str(), true))
-    {
+  } else if (cmSystemTools::FileExists(fname.c_str(), true)) {
     cmSystemTools::RemoveFile(fname);
-    }
+  }
 }
 
-//---------------------------------------------------------
 void cmCTestMultiProcessHandler::RemoveTest(int index)
 {
   this->EraseTest(index);
@@ -896,61 +778,55 @@ void cmCTestMultiProcessHandler::RemoveTest(int index)
   this->Completed++;
 }
 
-//---------------------------------------------------------
 int cmCTestMultiProcessHandler::FindMaxIndex()
 {
   int max = 0;
   cmCTestMultiProcessHandler::TestMap::iterator i = this->Tests.begin();
-  for(; i != this->Tests.end(); ++i)
-    {
-    if(i->first > max)
-      {
+  for (; i != this->Tests.end(); ++i) {
+    if (i->first > max) {
       max = i->first;
-      }
     }
+  }
   return max;
 }
 
-//Returns true if no cycles exist in the dependency graph
+// Returns true if no cycles exist in the dependency graph
 bool cmCTestMultiProcessHandler::CheckCycles()
 {
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-             "Checking test dependency graph..." << std::endl, this->Quiet);
-  for(TestMap::iterator it = this->Tests.begin();
-      it != this->Tests.end(); ++it)
-    {
-    //DFS from each element to itself
+                     "Checking test dependency graph..." << std::endl,
+                     this->Quiet);
+  for (TestMap::iterator it = this->Tests.begin(); it != this->Tests.end();
+       ++it) {
+    // DFS from each element to itself
     int root = it->first;
     std::set<int> visited;
     std::stack<int> s;
     s.push(root);
-    while(!s.empty())
-      {
+    while (!s.empty()) {
       int test = s.top();
       s.pop();
-      if(visited.insert(test).second)
-        {
-        for(TestSet::iterator d = this->Tests[test].begin();
-            d != this->Tests[test].end(); ++d)
-          {
-          if(*d == root)
-            {
-            //cycle exists
-            cmCTestLog(this->CTest, ERROR_MESSAGE,
-                       "Error: a cycle exists in the test dependency graph "
-                       "for the test \"" << this->Properties[root]->Name <<
-                       "\".\nPlease fix the cycle and run ctest again.\n");
+      if (visited.insert(test).second) {
+        for (TestSet::iterator d = this->Tests[test].begin();
+             d != this->Tests[test].end(); ++d) {
+          if (*d == root) {
+            // cycle exists
+            cmCTestLog(
+              this->CTest, ERROR_MESSAGE,
+              "Error: a cycle exists in the test dependency graph "
+              "for the test \""
+                << this->Properties[root]->Name
+                << "\".\nPlease fix the cycle and run ctest again.\n");
             return false;
-            }
-          else
-            {
+          } else {
             s.push(*d);
-            }
           }
         }
       }
     }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-             "Checking test dependency graph end" << std::endl, this->Quiet);
+                     "Checking test dependency graph end" << std::endl,
+                     this->Quiet);
   return true;
 }
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index ed3e155..9ec1528 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -12,8 +12,8 @@
 #ifndef cmCTestMultiProcessHandler_h
 #define cmCTestMultiProcessHandler_h
 
-#include <cmStandardIncludes.h>
 #include <cmCTestTestHandler.h>
+
 #include <cmCTestRunTest.h>
 
 /** \class cmCTestMultiProcessHandler
@@ -24,12 +24,21 @@
 class cmCTestMultiProcessHandler
 {
   friend class TestComparator;
+
 public:
-  struct TestSet : public std::set<int> {};
-  struct TestMap : public std::map<int, TestSet> {};
-  struct TestList : public std::vector<int> {};
-  struct PropertiesMap : public
-     std::map<int, cmCTestTestHandler::cmCTestTestProperties*> {};
+  struct TestSet : public std::set<int>
+  {
+  };
+  struct TestMap : public std::map<int, TestSet>
+  {
+  };
+  struct TestList : public std::vector<int>
+  {
+  };
+  struct PropertiesMap
+    : public std::map<int, cmCTestTestHandler::cmCTestTestProperties*>
+  {
+  };
 
   cmCTestMultiProcessHandler();
   virtual ~cmCTestMultiProcessHandler();
@@ -44,20 +53,23 @@ public:
 
   void SetPassFailVectors(std::vector<std::string>* passed,
                           std::vector<std::string>* failed)
-    {
+  {
     this->Passed = passed;
     this->Failed = failed;
-    }
+  }
   void SetTestResults(std::vector<cmCTestTestHandler::cmCTestTestResult>* r)
-  { this->TestResults = r; }
+  {
+    this->TestResults = r;
+  }
 
-  void SetCTest(cmCTest* ctest) { this->CTest = ctest;}
+  void SetCTest(cmCTest* ctest) { this->CTest = ctest; }
 
-  void SetTestHandler(cmCTestTestHandler * handler)
-  { this->TestHandler = handler; }
+  void SetTestHandler(cmCTestTestHandler* handler)
+  {
+    this->TestHandler = handler;
+  }
 
-  cmCTestTestHandler * GetTestHandler()
-  { return this->TestHandler; }
+  cmCTestTestHandler* GetTestHandler() { return this->TestHandler; }
 
   void SetQuiet(bool b) { this->Quiet = b; }
 protected:
@@ -72,7 +84,7 @@ protected:
   void UpdateCostData();
   void ReadCostData();
   // Return index of a test based on its name
-  int SearchByName(std::string name);
+  int SearchByName(std::string const& name);
 
   void CreateTestCostList();
 
@@ -88,9 +100,9 @@ protected:
   // check all running processes for output and exit case
   bool CheckOutput();
   void RemoveTest(int index);
-  //Check if we need to resume an interrupted test set
+  // Check if we need to resume an interrupted test set
   void CheckResume();
-  //Check if there are any circular dependencies
+  // Check if there are any circular dependencies
   bool CheckCycles();
   int FindMaxIndex();
   inline size_t GetProcessorsUsed(int index);
@@ -101,13 +113,13 @@ protected:
   // map from test number to set of depend tests
   TestMap Tests;
   TestList SortedTests;
-  //Total number of tests we'll be running
+  // Total number of tests we'll be running
   size_t Total;
-  //Number of tests that are complete
+  // Number of tests that are complete
   size_t Completed;
   size_t RunningCount;
   bool StopTimePassed;
-  //list of test properties (indices concurrent to the test map)
+  // list of test properties (indices concurrent to the test map)
   PropertiesMap Properties;
   std::map<int, bool> TestRunningMap;
   std::map<int, bool> TestFinishMap;
@@ -119,8 +131,8 @@ protected:
   std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
   size_t ParallelLevel; // max number of process that can be run at once
   unsigned long TestLoad;
-  std::set<cmCTestRunTest*> RunningTests;  // current running tests
-  cmCTestTestHandler * TestHandler;
+  std::set<cmCTestRunTest*> RunningTests; // current running tests
+  cmCTestTestHandler* TestHandler;
   cmCTest* CTest;
   bool HasCycles;
   bool Quiet;
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 5e0c54a..07f9dad 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -14,90 +14,87 @@
 #include "cmCTest.h"
 #include "cmSystemTools.h"
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/Process.h>
+#include <cmsys/RegularExpression.hxx>
 
+#include <ctype.h>
 #include <sys/types.h>
 #include <time.h>
-#include <ctype.h>
 
-//----------------------------------------------------------------------------
-cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log):
-  cmCTestGlobalVC(ct, log)
+cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log)
+  : cmCTestGlobalVC(ct, log)
 {
   this->PriorRev = this->Unknown;
 }
 
-//----------------------------------------------------------------------------
 cmCTestP4::~cmCTestP4()
 {
 }
 
-//----------------------------------------------------------------------------
-class cmCTestP4::IdentifyParser: public cmCTestVC::LineParser
+class cmCTestP4::IdentifyParser : public cmCTestVC::LineParser
 {
 public:
-  IdentifyParser(cmCTestP4* p4, const char* prefix,
-                 std::string& rev): Rev(rev)
-    {
+  IdentifyParser(cmCTestP4* p4, const char* prefix, std::string& rev)
+    : Rev(rev)
+  {
     this->SetLog(&p4->Log, prefix);
     this->RegexIdentify.compile("^Change ([0-9]+) on");
-    }
+  }
+
 private:
   std::string& Rev;
   cmsys::RegularExpression RegexIdentify;
 
   bool ProcessLine()
-    {
-    if(this->RegexIdentify.find(this->Line))
-      {
+  {
+    if (this->RegexIdentify.find(this->Line)) {
       this->Rev = this->RegexIdentify.match(1);
       return false;
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
-class cmCTestP4::ChangesParser: public cmCTestVC::LineParser
+class cmCTestP4::ChangesParser : public cmCTestVC::LineParser
 {
 public:
-  ChangesParser(cmCTestP4* p4, const char* prefix) : P4(p4)
-    {
+  ChangesParser(cmCTestP4* p4, const char* prefix)
+    : P4(p4)
+  {
     this->SetLog(&P4->Log, prefix);
     this->RegexIdentify.compile("^Change ([0-9]+) on");
-    }
+  }
+
 private:
   cmsys::RegularExpression RegexIdentify;
   cmCTestP4* P4;
 
   bool ProcessLine()
-    {
-    if(this->RegexIdentify.find(this->Line))
-      {
+  {
+    if (this->RegexIdentify.find(this->Line)) {
       P4->ChangeLists.push_back(this->RegexIdentify.match(1));
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
-class cmCTestP4::UserParser: public cmCTestVC::LineParser
+class cmCTestP4::UserParser : public cmCTestVC::LineParser
 {
 public:
-  UserParser(cmCTestP4* p4, const char* prefix) : P4(p4)
-    {
+  UserParser(cmCTestP4* p4, const char* prefix)
+    : P4(p4)
+  {
     this->SetLog(&P4->Log, prefix);
     this->RegexUser.compile("^(.+) <(.*)> \\((.*)\\) accessed (.*)$");
-    }
+  }
+
 private:
   cmsys::RegularExpression RegexUser;
   cmCTestP4* P4;
 
   bool ProcessLine()
-    {
-    if(this->RegexUser.find(this->Line))
-      {
+  {
+    if (this->RegexUser.find(this->Line)) {
       User NewUser;
 
       NewUser.UserName = this->RegexUser.match(1);
@@ -107,12 +104,11 @@ private:
       P4->Users[this->RegexUser.match(1)] = NewUser;
 
       return false;
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
 /* Diff format:
 ==== //depot/file#rev - /absolute/path/to/file ====
 (diff data)
@@ -122,15 +118,17 @@ private:
 ==== //depot/file4#rev - /absolute/path/to/file4 ====
 (diff data)
 */
-class cmCTestP4::DiffParser: public cmCTestVC::LineParser
+class cmCTestP4::DiffParser : public cmCTestVC::LineParser
 {
 public:
   DiffParser(cmCTestP4* p4, const char* prefix)
-             : P4(p4), AlreadyNotified(false)
-    {
+    : P4(p4)
+    , AlreadyNotified(false)
+  {
     this->SetLog(&P4->Log, prefix);
     this->RegexDiff.compile("^==== (.*)#[0-9]+ - (.*)");
-    }
+  }
+
 private:
   cmCTestP4* P4;
   bool AlreadyNotified;
@@ -138,33 +136,27 @@ private:
   cmsys::RegularExpression RegexDiff;
 
   bool ProcessLine()
-    {
-    if(!this->Line.empty() && this->Line[0] == '='
-       && this->RegexDiff.find(this->Line))
-      {
-        CurrentPath = this->RegexDiff.match(1);
-        AlreadyNotified = false;
-      }
-    else
-      {
-      if(!AlreadyNotified)
-        {
+  {
+    if (!this->Line.empty() && this->Line[0] == '=' &&
+        this->RegexDiff.find(this->Line)) {
+      CurrentPath = this->RegexDiff.match(1);
+      AlreadyNotified = false;
+    } else {
+      if (!AlreadyNotified) {
         P4->DoModification(PathModified, CurrentPath);
         AlreadyNotified = true;
-        }
       }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
 cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
 {
   std::map<std::string, cmCTestP4::User>::const_iterator it =
-          Users.find(username);
+    Users.find(username);
 
-  if(it == Users.end())
-    {
+  if (it == Users.end()) {
     std::vector<char const*> p4_users;
     SetP4Options(p4_users);
     p4_users.push_back("users");
@@ -179,16 +171,14 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
 
     // The user should now be added to the map. Search again.
     it = Users.find(username);
-    if(it == Users.end())
-      {
+    if (it == Users.end()) {
       return cmCTestP4::User();
-      }
     }
+  }
 
   return it->second;
 }
 
-//----------------------------------------------------------------------------
 /* Commit format:
 
 Change 1111111 by user at client on 2013/09/26 11:50:36
@@ -203,16 +193,19 @@ Affected files ...
 ... //path/to/file#rev delete
 ... //path/to/file#rev integrate
 */
-class cmCTestP4::DescribeParser: public cmCTestVC::LineParser
+class cmCTestP4::DescribeParser : public cmCTestVC::LineParser
 {
 public:
-  DescribeParser(cmCTestP4* p4, const char* prefix):
-      LineParser('\n', false), P4(p4), Section(SectionHeader)
-    {
+  DescribeParser(cmCTestP4* p4, const char* prefix)
+    : LineParser('\n', false)
+    , P4(p4)
+    , Section(SectionHeader)
+  {
     this->SetLog(&P4->Log, prefix);
     this->RegexHeader.compile("^Change ([0-9]+) by (.+)@(.+) on (.*)$");
     this->RegexDiff.compile("^\\.\\.\\. (.*)#[0-9]+ ([^ ]+)$");
-    }
+  }
+
 private:
   cmsys::RegularExpression RegexHeader;
   cmsys::RegularExpression RegexDiff;
@@ -221,46 +214,54 @@ private:
   typedef cmCTestP4::Revision Revision;
   typedef cmCTestP4::Change Change;
   std::vector<Change> Changes;
-  enum SectionType { SectionHeader, SectionBody, SectionDiffHeader,
-                     SectionDiff, SectionCount };
+  enum SectionType
+  {
+    SectionHeader,
+    SectionBody,
+    SectionDiffHeader,
+    SectionDiff,
+    SectionCount
+  };
   SectionType Section;
   Revision Rev;
 
   virtual bool ProcessLine()
-    {
-    if(this->Line.empty())
-      {
+  {
+    if (this->Line.empty()) {
       this->NextSection();
+    } else {
+      switch (this->Section) {
+        case SectionHeader:
+          this->DoHeaderLine();
+          break;
+        case SectionBody:
+          this->DoBodyLine();
+          break;
+        case SectionDiffHeader:
+          break; // nothing to do
+        case SectionDiff:
+          this->DoDiffLine();
+          break;
+        case SectionCount:
+          break; // never happens
       }
-    else
-      {
-      switch(this->Section)
-        {
-        case SectionHeader:     this->DoHeaderLine(); break;
-        case SectionBody:       this->DoBodyLine(); break;
-        case SectionDiffHeader: break; // nothing to do
-        case SectionDiff:       this->DoDiffLine(); break;
-        case SectionCount:      break; // never happens
-        }
-      }
-      return true;
-      }
+    }
+    return true;
+  }
 
   void NextSection()
-    {
-    if(this->Section == SectionDiff)
-    {
+  {
+    if (this->Section == SectionDiff) {
       this->P4->DoRevision(this->Rev, this->Changes);
       this->Rev = Revision();
     }
 
-    this->Section = SectionType((this->Section+1) % SectionCount);
-    }
+    this->Section = SectionType((this->Section + 1) % SectionCount);
+  }
 
   void DoHeaderLine()
-    {
-    if(this->RegexHeader.find(this->Line))
-      {
+  {
+    if (this->RegexHeader.find(this->Line)) {
       this->Rev.Rev = this->RegexHeader.match(1);
       this->Rev.Date = this->RegexHeader.match(4);
 
@@ -271,94 +272,80 @@ private:
       this->Rev.Committer = this->Rev.Author;
       this->Rev.CommitterEMail = this->Rev.EMail;
       this->Rev.CommitDate = this->Rev.Date;
-      }
     }
+  }
 
   void DoBodyLine()
-    {
-    if(this->Line[0] == '\t')
-      {
+  {
+    if (this->Line[0] == '\t') {
       this->Rev.Log += this->Line.substr(1);
-      }
-    this->Rev.Log += "\n";
     }
+    this->Rev.Log += "\n";
+  }
 
   void DoDiffLine()
-    {
-    if(this->RegexDiff.find(this->Line))
-    {
-    Change change;
-    std::string Path = this->RegexDiff.match(1);
-    if(Path.length() > 2 && Path[0] == '/' && Path[1] == '/')
-      {
-      size_t found = Path.find('/', 2);
-      if(found != std::string::npos)
-        {
-        Path = Path.substr(found + 1);
+  {
+    if (this->RegexDiff.find(this->Line)) {
+      Change change;
+      std::string Path = this->RegexDiff.match(1);
+      if (Path.length() > 2 && Path[0] == '/' && Path[1] == '/') {
+        size_t found = Path.find('/', 2);
+        if (found != std::string::npos) {
+          Path = Path.substr(found + 1);
         }
       }
 
-    change.Path = Path;
-    std::string action = this->RegexDiff.match(2);
+      change.Path = Path;
+      std::string action = this->RegexDiff.match(2);
 
-    if(action == "add")
-      {
-      change.Action = 'A';
-      }
-    else if(action == "delete")
-      {
-      change.Action = 'D';
-      }
-    else if(action == "edit" || action == "integrate")
-      {
-      change.Action = 'M';
+      if (action == "add") {
+        change.Action = 'A';
+      } else if (action == "delete") {
+        change.Action = 'D';
+      } else if (action == "edit" || action == "integrate") {
+        change.Action = 'M';
       }
 
-    Changes.push_back(change);
+      Changes.push_back(change);
     }
   }
 };
 
-//----------------------------------------------------------------------------
-void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions)
+void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
 {
-  if(P4Options.empty())
-    {
+  if (P4Options.empty()) {
     const char* p4 = this->CommandLineTool.c_str();
     P4Options.push_back(p4);
 
-    //The CTEST_P4_CLIENT variable sets the P4 client used when issuing
-    //Perforce commands, if it's different from the default one.
+    // The CTEST_P4_CLIENT variable sets the P4 client used when issuing
+    // Perforce commands, if it's different from the default one.
     std::string client = this->CTest->GetCTestConfiguration("P4Client");
-    if(!client.empty())
-      {
+    if (!client.empty()) {
       P4Options.push_back("-c");
       P4Options.push_back(client);
-      }
+    }
 
-    //Set the message language to be English, in case the P4 admin
-    //has localized them
+    // Set the message language to be English, in case the P4 admin
+    // has localized them
     P4Options.push_back("-L");
     P4Options.push_back("en");
 
-    //The CTEST_P4_OPTIONS variable adds additional Perforce command line
-    //options before the main command
+    // The CTEST_P4_OPTIONS variable adds additional Perforce command line
+    // options before the main command
     std::string opts = this->CTest->GetCTestConfiguration("P4Options");
     std::vector<std::string> args =
-            cmSystemTools::ParseArguments(opts.c_str());
+      cmSystemTools::ParseArguments(opts.c_str());
 
     P4Options.insert(P4Options.end(), args.begin(), args.end());
-    }
+  }
 
   CommandOptions.clear();
-  for(std::vector<std::string>::iterator i = P4Options.begin();
-      i != P4Options.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = P4Options.begin();
+       i != P4Options.end(); ++i) {
     CommandOptions.push_back(i->c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestP4::GetWorkingRevision()
 {
   std::vector<char const*> p4_identify;
@@ -380,41 +367,34 @@ std::string cmCTestP4::GetWorkingRevision()
   bool result = RunChild(&p4_identify[0], &out, &err);
 
   // If there was a problem contacting the server return "<unknown>"
-  if(!result)
-    {
+  if (!result) {
     return "<unknown>";
-    }
+  }
 
-  if(rev.empty())
-    {
+  if (rev.empty()) {
     return "0";
-    }
-  else
-    {
+  } else {
     return rev;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestP4::NoteOldRevision()
 {
   this->OldRevision = this->GetWorkingRevision();
 
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Old revision of repository is: "
-             << this->OldRevision << "\n");
+               << this->OldRevision << "\n");
   this->PriorRev.Rev = this->OldRevision;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestP4::NoteNewRevision()
 {
   this->NewRevision = this->GetWorkingRevision();
 
   cmCTestLog(this->CTest, HANDLER_OUTPUT, "   New revision of repository is: "
-             << this->NewRevision << "\n");
+               << this->NewRevision << "\n");
 }
 
-//----------------------------------------------------------------------------
 void cmCTestP4::LoadRevisions()
 {
   std::vector<char const*> p4_changes;
@@ -425,15 +405,16 @@ void cmCTestP4::LoadRevisions()
 
   // If any revision is unknown it means we couldn't contact the server.
   // Do not process updates
-  if(this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>")
-    {
+  if (this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>") {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "   At least one of the revisions "
-               << "is unknown. No repository changes will be reported.\n");
+                 << "is unknown. No repository changes will be reported.\n");
     return;
-    }
+  }
 
-  range.append("@").append(this->OldRevision)
-       .append(",").append(this->NewRevision);
+  range.append("@")
+    .append(this->OldRevision)
+    .append(",")
+    .append(this->NewRevision);
 
   p4_changes.push_back("changes");
   p4_changes.push_back(range.c_str());
@@ -445,14 +426,13 @@ void cmCTestP4::LoadRevisions()
   ChangeLists.clear();
   this->RunChild(&p4_changes[0], &out, &err);
 
-  if(ChangeLists.empty())
-      return;
+  if (ChangeLists.empty())
+    return;
 
-  //p4 describe -s ... at 1111111,2222222
+  // p4 describe -s ... at 1111111,2222222
   std::vector<char const*> p4_describe;
-  for(std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
-      i != ChangeLists.rend(); ++i)
-    {
+  for (std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
+       i != ChangeLists.rend(); ++i) {
     SetP4Options(p4_describe);
     p4_describe.push_back("describe");
     p4_describe.push_back("-s");
@@ -462,10 +442,9 @@ void cmCTestP4::LoadRevisions()
     DescribeParser outDescribe(this, "p4_describe-out> ");
     OutputLogger errDescribe(this->Log, "p4_describe-err> ");
     this->RunChild(&p4_describe[0], &outDescribe, &errDescribe);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestP4::LoadModifications()
 {
   std::vector<char const*> p4_diff;
@@ -473,7 +452,7 @@ void cmCTestP4::LoadModifications()
 
   p4_diff.push_back("diff");
 
-  //Ideally we would use -Od but not all clients support it
+  // Ideally we would use -Od but not all clients support it
   p4_diff.push_back("-dn");
   std::string source = this->SourceDirectory + "/...";
   p4_diff.push_back(source.c_str());
@@ -484,18 +463,16 @@ void cmCTestP4::LoadModifications()
   this->RunChild(&p4_diff[0], &out, &err);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestP4::UpdateCustom(const std::string& custom)
 {
   std::vector<std::string> p4_custom_command;
   cmSystemTools::ExpandListArgument(custom, p4_custom_command, true);
 
   std::vector<char const*> p4_custom;
-  for(std::vector<std::string>::const_iterator
-        i = p4_custom_command.begin(); i != p4_custom_command.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = p4_custom_command.begin();
+       i != p4_custom_command.end(); ++i) {
     p4_custom.push_back(i->c_str());
-    }
+  }
   p4_custom.push_back(0);
 
   OutputLogger custom_out(this->Log, "p4_customsync-out> ");
@@ -504,22 +481,19 @@ bool cmCTestP4::UpdateCustom(const std::string& custom)
   return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestP4::UpdateImpl()
 {
   std::string custom = this->CTest->GetCTestConfiguration("P4UpdateCustom");
-  if(!custom.empty())
-    {
+  if (!custom.empty()) {
     return this->UpdateCustom(custom);
-    }
+  }
 
   // If we couldn't get a revision number before updating, abort.
-  if(this->OldRevision == "<unknown>")
-    {
+  if (this->OldRevision == "<unknown>") {
     this->UpdateCommandLine = "Unknown current revision";
     cmCTestLog(this->CTest, ERROR_MESSAGE, "   Unknown current revision\n");
     return false;
-    }
+  }
 
   std::vector<char const*> p4_sync;
   SetP4Options(p4_sync);
@@ -528,29 +502,26 @@ bool cmCTestP4::UpdateImpl()
 
   // Get user-specified update options.
   std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
-  if(opts.empty())
-    {
+  if (opts.empty()) {
     opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
-    }
+  }
   std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     p4_sync.push_back(ai->c_str());
-    }
+  }
 
   std::string source = this->SourceDirectory + "/...";
 
   // Specify the start time for nightly testing.
-  if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
-    {
+  if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
     std::string date = this->GetNightlyTime();
-    //CTest reports the date as YYYY-MM-DD, Perforce needs it as YYYY/MM/DD
+    // CTest reports the date as YYYY-MM-DD, Perforce needs it as YYYY/MM/DD
     std::replace(date.begin(), date.end(), '-', '/');
 
-    //Revision specification: /...@"YYYY/MM/DD HH:MM:SS"
+    // Revision specification: /...@"YYYY/MM/DD HH:MM:SS"
     source.append("@\"").append(date).append("\"");
-    }
+  }
 
   p4_sync.push_back(source.c_str());
   p4_sync.push_back(0);
diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h
index 7a53475..917751e 100644
--- a/Source/CTest/cmCTestP4.h
+++ b/Source/CTest/cmCTestP4.h
@@ -13,14 +13,15 @@
 #define cmCTestP4_h
 
 #include "cmCTestGlobalVC.h"
-#include <vector>
+
 #include <map>
+#include <vector>
 
 /** \class cmCTestP4
  * \brief Interaction with the Perforce command-line tool
  *
  */
-class cmCTestP4: public cmCTestGlobalVC
+class cmCTestP4 : public cmCTestGlobalVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
@@ -32,19 +33,25 @@ private:
   std::vector<std::string> ChangeLists;
 
   struct User
-    {
+  {
     std::string UserName;
     std::string Name;
     std::string EMail;
     std::string AccessTime;
 
-    User(): UserName(), Name(), EMail(), AccessTime() {}
-    };
+    User()
+      : UserName()
+      , Name()
+      , EMail()
+      , AccessTime()
+    {
+    }
+  };
   std::map<std::string, User> Users;
   std::vector<std::string> P4Options;
 
   User GetUserData(const std::string& username);
-  void SetP4Options(std::vector<char const*> &options);
+  void SetP4Options(std::vector<char const*>& options);
 
   std::string GetWorkingRevision();
   virtual void NoteOldRevision();
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
index 3b9d552..2613c1c 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
@@ -10,25 +10,21 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCTestReadCustomFilesCommand.h"
+
 #include "cmCTest.h"
 
-bool cmCTestReadCustomFilesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestReadCustomFilesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if (args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::vector<std::string>::const_iterator dit;
-  for ( dit = args.begin(); dit != args.end(); ++ dit )
-    {
-    this->CTest->ReadCustomConfigurationFileTree(dit->c_str(),
-      this->Makefile);
-    }
+  for (dit = args.begin(); dit != args.end(); ++dit) {
+    this->CTest->ReadCustomConfigurationFileTree(dit->c_str(), this->Makefile);
+  }
 
   return true;
 }
-
-
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h
index c95694a..713fc66 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.h
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.h
@@ -23,34 +23,31 @@
 class cmCTestReadCustomFilesCommand : public cmCTestCommand
 {
 public:
-
   cmCTestReadCustomFilesCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestReadCustomFilesCommand* ni = new cmCTestReadCustomFilesCommand;
     ni->CTest = this->CTest;
     return ni;
-    }
+  }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_read_custom_files";}
+  virtual std::string GetName() const { return "ctest_read_custom_files"; }
 
   cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand);
-
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index 7afbe04..e143d50 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -13,53 +13,41 @@
 
 #include "cmCTestScriptHandler.h"
 
-bool cmCTestRunScriptCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->CTestScriptHandler->RunCurrentScript();
     return true;
-    }
+  }
 
   bool np = false;
   unsigned int i = 0;
-  if (args[i] == "NEW_PROCESS")
-    {
+  if (args[i] == "NEW_PROCESS") {
     np = true;
     i++;
-    }
+  }
   int start = i;
   // run each script
   std::string returnVariable;
-  for (i = start; i < args.size(); ++i)
-    {
-    if(args[i] == "RETURN_VALUE")
-      {
+  for (i = start; i < args.size(); ++i) {
+    if (args[i] == "RETURN_VALUE") {
       ++i;
-      if(i < args.size())
-        {
+      if (i < args.size()) {
         returnVariable = args[i];
-        }
       }
     }
-  for (i = start; i < args.size(); ++i)
-    {
-    if(args[i] == "RETURN_VALUE")
-      {
+  }
+  for (i = start; i < args.size(); ++i) {
+    if (args[i] == "RETURN_VALUE") {
       ++i;
-      }
-    else
-      {
+    } else {
       int ret;
-      cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np,
-        &ret);
+      cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret);
       std::ostringstream str;
       str << ret;
       this->Makefile->AddDefinition(returnVariable, str.str().c_str());
-      }
     }
+  }
   return true;
 }
-
-
diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h
index 0998e5c..c503516 100644
--- a/Source/CTest/cmCTestRunScriptCommand.h
+++ b/Source/CTest/cmCTestRunScriptCommand.h
@@ -23,34 +23,32 @@
 class cmCTestRunScriptCommand : public cmCTestCommand
 {
 public:
-
   cmCTestRunScriptCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestRunScriptCommand* ni = new cmCTestRunScriptCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_run_script";}
+  virtual std::string GetName() const { return "ctest_run_script"; }
 
   cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand);
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index d108592..9dda865 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -11,8 +11,9 @@
 ============================================================================*/
 
 #include "cmCTestRunTest.h"
-#include "cmCTestMemCheckHandler.h"
+
 #include "cmCTest.h"
+#include "cmCTestMemCheckHandler.h"
 #include "cmSystemTools.h"
 #include "cm_curl.h"
 
@@ -24,7 +25,7 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
   this->CTest = handler->CTest;
   this->TestHandler = handler;
   this->TestProcess = 0;
-  this->TestResult.ExecutionTime =0;
+  this->TestResult.ExecutionTime = 0;
   this->TestResult.ReturnValue = 0;
   this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
   this->TestResult.TestCount = 0;
@@ -35,45 +36,60 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
   this->StopTimePassed = false;
   this->NumberOfRunsLeft = 1; // default to 1 run of the test
   this->RunUntilFail = false; // default to run the test once
-  this->RunAgain = false;   // default to not having to run again
+  this->RunAgain = false;     // default to not having to run again
 }
 
 cmCTestRunTest::~cmCTestRunTest()
 {
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestRunTest::CheckOutput()
 {
   // Read lines for up to 0.1 seconds of total time.
   double timeout = 0.1;
   double timeEnd = cmSystemTools::GetTime() + timeout;
   std::string line;
-  while((timeout = timeEnd - cmSystemTools::GetTime(), timeout > 0))
-    {
+  while ((timeout = timeEnd - cmSystemTools::GetTime(), timeout > 0)) {
     int p = this->TestProcess->GetNextOutputLine(line, timeout);
-    if(p == cmsysProcess_Pipe_None)
-      {
+    if (p == cmsysProcess_Pipe_None) {
       // Process has terminated and all output read.
       return false;
-      }
-    else if(p == cmsysProcess_Pipe_STDOUT)
-      {
+    } else if (p == cmsysProcess_Pipe_STDOUT) {
       // Store this line of output.
-      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-                 this->GetIndex() << ": " << line << std::endl);
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
+                   << ": " << line << std::endl);
       this->ProcessOutput += line;
       this->ProcessOutput += "\n";
+
+      // Check for TIMEOUT_AFTER_MATCH property.
+      if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
+        std::vector<
+          std::pair<cmsys::RegularExpression, std::string> >::iterator regIt;
+        for (regIt = this->TestProperties->TimeoutRegularExpressions.begin();
+             regIt != this->TestProperties->TimeoutRegularExpressions.end();
+             ++regIt) {
+          if (regIt->first.find(this->ProcessOutput.c_str())) {
+            cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
+                         << ": "
+                         << "Test timeout changed to "
+                         << this->TestProperties->AlternateTimeout
+                         << std::endl);
+            this->TestProcess->ResetStartTime();
+            this->TestProcess->ChangeTimeout(
+              this->TestProperties->AlternateTimeout);
+            this->TestProperties->TimeoutRegularExpressions.clear();
+            break;
+          }
+        }
       }
-    else // if(p == cmsysProcess_Pipe_Timeout)
-      {
+    } else // if(p == cmsysProcess_Pipe_Timeout)
+    {
       break;
-      }
     }
+  }
   return true;
 }
 
-//---------------------------------------------------------
 // Streamed compression of test output.  The compressed data
 // is appended to this->CompressedOutput
 void cmCTestRunTest::CompressOutput()
@@ -81,10 +97,9 @@ void cmCTestRunTest::CompressOutput()
   int ret;
   z_stream strm;
 
-  unsigned char* in =
-    reinterpret_cast<unsigned char*>(
+  unsigned char* in = reinterpret_cast<unsigned char*>(
     const_cast<char*>(this->ProcessOutput.c_str()));
-  //zlib makes the guarantee that this is the maximum output size
+  // zlib makes the guarantee that this is the maximum output size
   int outSize = static_cast<int>(
     static_cast<double>(this->ProcessOutput.size()) * 1.001 + 13.0);
   unsigned char* out = new unsigned char[outSize];
@@ -92,12 +107,11 @@ void cmCTestRunTest::CompressOutput()
   strm.zalloc = Z_NULL;
   strm.zfree = Z_NULL;
   strm.opaque = Z_NULL;
-  ret = deflateInit(&strm, -1); //default compression level
-  if (ret != Z_OK)
-    {
+  ret = deflateInit(&strm, -1); // default compression level
+  if (ret != Z_OK) {
     delete[] out;
     return;
-    }
+  }
 
   strm.avail_in = static_cast<uInt>(this->ProcessOutput.size());
   strm.next_in = in;
@@ -105,140 +119,116 @@ void cmCTestRunTest::CompressOutput()
   strm.next_out = out;
   ret = deflate(&strm, Z_FINISH);
 
-  if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END)
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output "
-      "compression. Sending uncompressed output." << std::endl);
+  if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+               "Error during output "
+               "compression. Sending uncompressed output."
+                 << std::endl);
     delete[] out;
     return;
-    }
+  }
 
   (void)deflateEnd(&strm);
 
-  unsigned char *encoded_buffer
-    = new unsigned char[static_cast<int>(outSize * 1.5)];
+  unsigned char* encoded_buffer =
+    new unsigned char[static_cast<int>(outSize * 1.5)];
 
-  size_t rlen
-    = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
+  size_t rlen = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
 
-  for(size_t i = 0; i < rlen; i++)
-    {
+  for (size_t i = 0; i < rlen; i++) {
     this->CompressedOutput += encoded_buffer[i];
-    }
+  }
 
-  if(strm.total_in)
-    {
-    this->CompressionRatio = static_cast<double>(strm.total_out) /
-                             static_cast<double>(strm.total_in);
-    }
+  if (strm.total_in) {
+    this->CompressionRatio =
+      static_cast<double>(strm.total_out) / static_cast<double>(strm.total_in);
+  }
 
-  delete [] encoded_buffer;
-  delete [] out;
+  delete[] encoded_buffer;
+  delete[] out;
 }
 
-//---------------------------------------------------------
 bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
 {
   if ((!this->TestHandler->MemCheck &&
-      this->CTest->ShouldCompressTestOutput()) ||
+       this->CTest->ShouldCompressTestOutput()) ||
       (this->TestHandler->MemCheck &&
-      this->CTest->ShouldCompressMemCheckOutput()))
-    {
+       this->CTest->ShouldCompressMemCheckOutput())) {
     this->CompressOutput();
-    }
+  }
 
   this->WriteLogOutputTop(completed, total);
   std::string reason;
   bool passed = true;
-  int res = started ? this->TestProcess->GetProcessStatus()
-                    : cmsysProcess_State_Error;
+  int res =
+    started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error;
   int retVal = this->TestProcess->GetExitValue();
-  std::vector<std::pair<cmsys::RegularExpression,
-    std::string> >::iterator passIt;
+  std::vector<std::pair<cmsys::RegularExpression, std::string> >::iterator
+    passIt;
   bool forceFail = false;
   bool outputTestErrorsToConsole = false;
-  if (!this->TestProperties->RequiredRegularExpressions.empty())
-    {
+  if (!this->TestProperties->RequiredRegularExpressions.empty()) {
     bool found = false;
-    for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
-          passIt != this->TestProperties->RequiredRegularExpressions.end();
-          ++ passIt )
-      {
-      if ( passIt->first.find(this->ProcessOutput.c_str()) )
-        {
+    for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
+         passIt != this->TestProperties->RequiredRegularExpressions.end();
+         ++passIt) {
+      if (passIt->first.find(this->ProcessOutput.c_str())) {
         found = true;
         reason = "Required regular expression found.";
         break;
-        }
       }
-    if ( !found )
-      {
+    }
+    if (!found) {
       reason = "Required regular expression not found.";
       forceFail = true;
-      }
-    reason +=  "Regex=[";
-    for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
-          passIt != this->TestProperties->RequiredRegularExpressions.end();
-          ++ passIt )
-      {
+    }
+    reason += "Regex=[";
+    for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
+         passIt != this->TestProperties->RequiredRegularExpressions.end();
+         ++passIt) {
       reason += passIt->second;
       reason += "\n";
-      }
-    reason += "]";
     }
-  if (!this->TestProperties->ErrorRegularExpressions.empty())
-    {
-    for ( passIt = this->TestProperties->ErrorRegularExpressions.begin();
-          passIt != this->TestProperties->ErrorRegularExpressions.end();
-          ++ passIt )
-      {
-      if ( passIt->first.find(this->ProcessOutput.c_str()) )
-        {
+    reason += "]";
+  }
+  if (!this->TestProperties->ErrorRegularExpressions.empty()) {
+    for (passIt = this->TestProperties->ErrorRegularExpressions.begin();
+         passIt != this->TestProperties->ErrorRegularExpressions.end();
+         ++passIt) {
+      if (passIt->first.find(this->ProcessOutput.c_str())) {
         reason = "Error regular expression found in output.";
         reason += " Regex=[";
         reason += passIt->second;
         reason += "]";
         forceFail = true;
         break;
-        }
       }
     }
-  if (res == cmsysProcess_State_Exited)
-    {
-    bool success =
-      !forceFail &&  (retVal == 0 ||
-      this->TestProperties->RequiredRegularExpressions.size());
-    if(this->TestProperties->SkipReturnCode >= 0
-      && this->TestProperties->SkipReturnCode == retVal)
-      {
+  }
+  if (res == cmsysProcess_State_Exited) {
+    bool success = !forceFail &&
+      (retVal == 0 || this->TestProperties->RequiredRegularExpressions.size());
+    if (this->TestProperties->SkipReturnCode >= 0 &&
+        this->TestProperties->SkipReturnCode == retVal) {
       this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
       cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped ");
-      }
-    else if((success && !this->TestProperties->WillFail)
-      || (!success && this->TestProperties->WillFail))
-      {
+    } else if ((success && !this->TestProperties->WillFail) ||
+               (!success && this->TestProperties->WillFail)) {
       this->TestResult.Status = cmCTestTestHandler::COMPLETED;
-      cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Passed  " );
-      }
-    else
-      {
+      cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Passed  ");
+    } else {
       this->TestResult.Status = cmCTestTestHandler::FAILED;
-      cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed  " << reason );
+      cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed  " << reason);
       outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
-      }
     }
-  else if ( res == cmsysProcess_State_Expired )
-    {
+  } else if (res == cmsysProcess_State_Expired) {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout ");
     this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
     outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
-    }
-  else if ( res == cmsysProcess_State_Exception )
-    {
+  } else if (res == cmsysProcess_State_Exception) {
     outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
-    switch(this->TestProcess->GetExitException())
-      {
+    switch (this->TestProcess->GetExitException()) {
       case cmsysProcess_Exception_Fault:
         cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault");
         this->TestResult.Status = cmCTestTestHandler::SEGFAULT;
@@ -258,27 +248,24 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
       default:
         cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other");
         this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT;
-      }
     }
-  else //cmsysProcess_State_Error
-    {
+  } else // cmsysProcess_State_Error
+  {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run ");
-    }
+  }
 
   passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
   char buf[1024];
   sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime());
-  cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n" );
+  cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n");
 
-  if ( outputTestErrorsToConsole )
-    {
-    cmCTestLog(this->CTest, HANDLER_OUTPUT, this->ProcessOutput << std::endl );
-    }
+  if (outputTestErrorsToConsole) {
+    cmCTestLog(this->CTest, HANDLER_OUTPUT, this->ProcessOutput << std::endl);
+  }
 
-  if ( this->TestHandler->LogFile )
-    {
+  if (this->TestHandler->LogFile) {
     *this->TestHandler->LogFile << "Test time = " << buf << std::endl;
-    }
+  }
 
   // Set the working directory to the tests directory
   std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
@@ -289,28 +276,25 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
   // restore working directory
   cmSystemTools::ChangeDirectory(oldpath);
 
-
   // if this is doing MemCheck then all the output needs to be put into
   // Output since that is what is parsed by cmCTestMemCheckHandler
-  if(!this->TestHandler->MemCheck && started)
-    {
-    this->TestHandler->CleanTestOutput(this->ProcessOutput,
-      static_cast<size_t>
-      (this->TestResult.Status == cmCTestTestHandler::COMPLETED ?
-      this->TestHandler->CustomMaximumPassedTestOutputSize :
-      this->TestHandler->CustomMaximumFailedTestOutputSize));
-    }
+  if (!this->TestHandler->MemCheck && started) {
+    this->TestHandler->CleanTestOutput(
+      this->ProcessOutput,
+      static_cast<size_t>(
+        this->TestResult.Status == cmCTestTestHandler::COMPLETED
+          ? this->TestHandler->CustomMaximumPassedTestOutputSize
+          : this->TestHandler->CustomMaximumFailedTestOutputSize));
+  }
   this->TestResult.Reason = reason;
-  if (this->TestHandler->LogFile)
-    {
+  if (this->TestHandler->LogFile) {
     bool pass = true;
     const char* reasonType = "Test Pass Reason";
-    if(this->TestResult.Status != cmCTestTestHandler::COMPLETED &&
-       this->TestResult.Status != cmCTestTestHandler::NOT_RUN)
-      {
+    if (this->TestResult.Status != cmCTestTestHandler::COMPLETED &&
+        this->TestResult.Status != cmCTestTestHandler::NOT_RUN) {
       reasonType = "Test Fail Reason";
       pass = false;
-      }
+    }
     double ttime = this->TestProcess->GetTotalTime();
     int hours = static_cast<int>(ttime / (60 * 60));
     int minutes = static_cast<int>(ttime / 60) % 60;
@@ -320,61 +304,53 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
     *this->TestHandler->LogFile
       << "----------------------------------------------------------"
       << std::endl;
-    if(!this->TestResult.Reason.empty())
-      {
+    if (!this->TestResult.Reason.empty()) {
       *this->TestHandler->LogFile << reasonType << ":\n"
-        << this->TestResult.Reason << "\n";
-      }
-    else
-      {
-      if(pass)
-        {
+                                  << this->TestResult.Reason << "\n";
+    } else {
+      if (pass) {
         *this->TestHandler->LogFile << "Test Passed.\n";
-        }
-      else
-        {
+      } else {
         *this->TestHandler->LogFile << "Test Failed.\n";
-        }
       }
-    *this->TestHandler->LogFile << "\"" << this->TestProperties->Name
+    }
+    *this->TestHandler->LogFile
+      << "\"" << this->TestProperties->Name
       << "\" end time: " << this->CTest->CurrentTime() << std::endl
-      << "\"" << this->TestProperties->Name << "\" time elapsed: "
-      << buffer << std::endl
+      << "\"" << this->TestProperties->Name << "\" time elapsed: " << buffer
+      << std::endl
       << "----------------------------------------------------------"
-      << std::endl << std::endl;
-    }
+      << std::endl
+      << std::endl;
+  }
   // if the test actually started and ran
   // record the results in TestResult
-  if(started)
-    {
+  if (started) {
     bool compress = !this->TestHandler->MemCheck &&
-      this->CompressionRatio < 1 &&
-      this->CTest->ShouldCompressTestOutput();
-    this->TestResult.Output = compress ? this->CompressedOutput
-      : this->ProcessOutput;
+      this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput();
+    this->TestResult.Output =
+      compress ? this->CompressedOutput : this->ProcessOutput;
     this->TestResult.CompressOutput = compress;
     this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
     this->TestResult.CompletionStatus = "Completed";
     this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
     this->MemCheckPostProcess();
     this->ComputeWeightedCost();
-    }
+  }
   // If the test does not need to rerun push the current TestResult onto the
   // TestHandler vector
-  if(!this->NeedsToRerun())
-    {
+  if (!this->NeedsToRerun()) {
     this->TestHandler->TestResults.push_back(this->TestResult);
-    }
+  }
   delete this->TestProcess;
   return passed;
 }
 
 bool cmCTestRunTest::StartAgain()
 {
-  if(!this->RunAgain)
-    {
+  if (!this->RunAgain) {
     return false;
-    }
+  }
   this->RunAgain = false; // reset
   // change to tests directory
   std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
@@ -388,63 +364,56 @@ bool cmCTestRunTest::StartAgain()
 bool cmCTestRunTest::NeedsToRerun()
 {
   this->NumberOfRunsLeft--;
-  if(this->NumberOfRunsLeft == 0)
-    {
+  if (this->NumberOfRunsLeft == 0) {
     return false;
-    }
+  }
   // if number of runs left is not 0, and we are running until
   // we find a failed test, then return true so the test can be
   // restarted
-  if(this->RunUntilFail
-     && this->TestResult.Status == cmCTestTestHandler::COMPLETED)
-    {
+  if (this->RunUntilFail &&
+      this->TestResult.Status == cmCTestTestHandler::COMPLETED) {
     this->RunAgain = true;
     return true;
-    }
+  }
   return false;
 }
-//----------------------------------------------------------------------
 void cmCTestRunTest::ComputeWeightedCost()
 {
   double prev = static_cast<double>(this->TestProperties->PreviousRuns);
   double avgcost = static_cast<double>(this->TestProperties->Cost);
   double current = this->TestResult.ExecutionTime;
 
-  if(this->TestResult.Status == cmCTestTestHandler::COMPLETED)
-    {
+  if (this->TestResult.Status == cmCTestTestHandler::COMPLETED) {
     this->TestProperties->Cost =
       static_cast<float>(((prev * avgcost) + current) / (prev + 1.0));
     this->TestProperties->PreviousRuns++;
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestRunTest::MemCheckPostProcess()
 {
-  if(!this->TestHandler->MemCheck)
-    {
+  if (!this->TestHandler->MemCheck) {
     return;
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
-    << ": process test output now: "
-    << this->TestProperties->Name << " "
-    << this->TestResult.Name << std::endl,
-    this->TestHandler->GetQuiet());
-  cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
-    (this->TestHandler);
+                       << ": process test output now: "
+                       << this->TestProperties->Name << " "
+                       << this->TestResult.Name << std::endl,
+                     this->TestHandler->GetQuiet());
+  cmCTestMemCheckHandler* handler =
+    static_cast<cmCTestMemCheckHandler*>(this->TestHandler);
   handler->PostProcessTest(this->TestResult, this->Index);
 }
 
-//----------------------------------------------------------------------
 // Starts the execution of a test.  Returns once it has started
 bool cmCTestRunTest::StartTest(size_t total)
 {
   this->TotalNumberOfTests = total; // save for rerun case
-  cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2*getNumWidth(total) + 8)
-    << "Start "
-    << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
-    << this->TestProperties->Index << ": "
-    << this->TestProperties->Name << std::endl);
+  cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2 * getNumWidth(total) + 8)
+               << "Start "
+               << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
+               << this->TestProperties->Index << ": "
+               << this->TestProperties->Name << std::endl);
   this->ComputeArguments();
   std::vector<std::string>& args = this->TestProperties->Args;
   this->TestResult.Properties = this->TestProperties;
@@ -455,23 +424,19 @@ bool cmCTestRunTest::StartTest(size_t total)
   this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
   this->TestResult.TestCount = this->TestProperties->Index;
   this->TestResult.Name = this->TestProperties->Name;
-  this->TestResult.Path = this->TestProperties->Directory.c_str();
+  this->TestResult.Path = this->TestProperties->Directory;
 
-  if(args.size() >= 2 && args[1] == "NOT_AVAILABLE")
-    {
+  if (args.size() >= 2 && args[1] == "NOT_AVAILABLE") {
     this->TestProcess = new cmProcess;
     std::string msg;
-    if(this->CTest->GetConfigType().empty())
-      {
+    if (this->CTest->GetConfigType().empty()) {
       msg = "Test not available without configuration.";
       msg += "  (Missing \"-C <config>\"?)";
-      }
-    else
-      {
+    } else {
       msg = "Test not available in configuration \"";
       msg += this->CTest->GetConfigType();
       msg += "\".";
-      }
+    }
     *this->TestHandler->LogFile << msg << std::endl;
     cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl);
     this->TestResult.Output = msg;
@@ -479,59 +444,54 @@ bool cmCTestRunTest::StartTest(size_t total)
     this->TestResult.CompletionStatus = "Not Run";
     this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
     return false;
-    }
+  }
 
   // Check if all required files exist
-  for(std::vector<std::string>::iterator i =
-    this->TestProperties->RequiredFiles.begin();
-    i != this->TestProperties->RequiredFiles.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i =
+         this->TestProperties->RequiredFiles.begin();
+       i != this->TestProperties->RequiredFiles.end(); ++i) {
     std::string file = *i;
 
-    if(!cmSystemTools::FileExists(file.c_str()))
-      {
-      //Required file was not found
+    if (!cmSystemTools::FileExists(file.c_str())) {
+      // Required file was not found
       this->TestProcess = new cmProcess;
-      *this->TestHandler->LogFile << "Unable to find required file: "
-               << file << std::endl;
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: "
-               << file << std::endl);
+      *this->TestHandler->LogFile << "Unable to find required file: " << file
+                                  << std::endl;
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "Unable to find required file: " << file << std::endl);
       this->TestResult.Output = "Unable to find required file: " + file;
       this->TestResult.FullCommandLine = "";
       this->TestResult.CompletionStatus = "Not Run";
       this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
       return false;
-      }
     }
+  }
   // log and return if we did not find the executable
-  if (this->ActualCommand == "")
-    {
+  if (this->ActualCommand == "") {
     // if the command was not found create a TestResult object
     // that has that information
     this->TestProcess = new cmProcess;
-    *this->TestHandler->LogFile << "Unable to find executable: "
-                   << args[1] << std::endl;
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
-               << args[1] << std::endl);
+    *this->TestHandler->LogFile << "Unable to find executable: " << args[1]
+                                << std::endl;
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+               "Unable to find executable: " << args[1] << std::endl);
     this->TestResult.Output = "Unable to find executable: " + args[1];
     this->TestResult.FullCommandLine = "";
     this->TestResult.CompletionStatus = "Not Run";
     this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
     return false;
-    }
+  }
   this->StartTime = this->CTest->CurrentTime();
 
   double timeout = this->ResolveTimeout();
 
-  if(this->StopTimePassed)
-    {
+  if (this->StopTimePassed) {
     return false;
-    }
+  }
   return this->ForkProcess(timeout, this->TestProperties->ExplicitTimeout,
                            &this->TestProperties->Environment);
 }
 
-//----------------------------------------------------------------------
 void cmCTestRunTest::ComputeArguments()
 {
   this->Arguments.clear(); // reset becaue this might be a rerun
@@ -539,94 +499,82 @@ void cmCTestRunTest::ComputeArguments()
     this->TestProperties->Args.begin();
   ++j; // skip test name
   // find the test executable
-  if(this->TestHandler->MemCheck)
-    {
-    cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
-      (this->TestHandler);
-    this->ActualCommand = handler->MemoryTester.c_str();
+  if (this->TestHandler->MemCheck) {
+    cmCTestMemCheckHandler* handler =
+      static_cast<cmCTestMemCheckHandler*>(this->TestHandler);
+    this->ActualCommand = handler->MemoryTester;
     this->TestProperties->Args[1] = this->TestHandler->FindTheExecutable(
       this->TestProperties->Args[1].c_str());
-    }
-  else
-    {
-    this->ActualCommand =
-      this->TestHandler->FindTheExecutable(
+  } else {
+    this->ActualCommand = this->TestHandler->FindTheExecutable(
       this->TestProperties->Args[1].c_str());
-    ++j; //skip the executable (it will be actualCommand)
-    }
-  std::string testCommand
-    = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
+    ++j; // skip the executable (it will be actualCommand)
+  }
+  std::string testCommand =
+    cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
 
-  //Prepends memcheck args to our command string
+  // Prepends memcheck args to our command string
   this->TestHandler->GenerateTestCommand(this->Arguments, this->Index);
-  for(std::vector<std::string>::iterator i = this->Arguments.begin();
-      i != this->Arguments.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = this->Arguments.begin();
+       i != this->Arguments.end(); ++i) {
     testCommand += " \"";
     testCommand += *i;
     testCommand += "\"";
-    }
+  }
 
-  for(;j != this->TestProperties->Args.end(); ++j)
-    {
+  for (; j != this->TestProperties->Args.end(); ++j) {
     testCommand += " \"";
     testCommand += *j;
     testCommand += "\"";
     this->Arguments.push_back(*j);
-    }
+  }
   this->TestResult.FullCommandLine = testCommand;
 
   // Print the test command in verbose mode
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
-             << this->Index << ": "
-             << (this->TestHandler->MemCheck?"MemCheck":"Test")
-             << " command: " << testCommand
-             << std::endl);
+               << this->Index << ": "
+               << (this->TestHandler->MemCheck ? "MemCheck" : "Test")
+               << " command: " << testCommand << std::endl);
 
   // Print any test-specific env vars in verbose mode
-  if (this->TestProperties->Environment.size())
-    {
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
-               << "Environment variables: " << std::endl);
-    }
-  for(std::vector<std::string>::const_iterator e =
-      this->TestProperties->Environment.begin();
-      e != this->TestProperties->Environment.end(); ++e)
-    {
+  if (this->TestProperties->Environment.size()) {
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
+                 << ": "
+                 << "Environment variables: " << std::endl);
+  }
+  for (std::vector<std::string>::const_iterator e =
+         this->TestProperties->Environment.begin();
+       e != this->TestProperties->Environment.end(); ++e) {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ":  " << *e
-               << std::endl);
-    }
+                                                                << std::endl);
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestRunTest::DartProcessing()
 {
   if (!this->ProcessOutput.empty() &&
-     this->ProcessOutput.find("<DartMeasurement") != this->ProcessOutput.npos)
-    {
-    if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str()))
-      {
+      this->ProcessOutput.find("<DartMeasurement") !=
+        this->ProcessOutput.npos) {
+    if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str())) {
       this->TestResult.DartString = this->TestHandler->DartStuff.match(1);
       // keep searching and replacing until none are left
-      while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str()))
-        {
+      while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str())) {
         // replace the exact match for the string
-        cmSystemTools::ReplaceString(this->ProcessOutput,
-                         this->TestHandler->DartStuff1.match(1).c_str(), "");
-        }
+        cmSystemTools::ReplaceString(
+          this->ProcessOutput, this->TestHandler->DartStuff1.match(1).c_str(),
+          "");
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------
 double cmCTestRunTest::ResolveTimeout()
 {
   double timeout = this->TestProperties->Timeout;
 
-  if(this->CTest->GetStopTime() == "")
-    {
+  if (this->CTest->GetStopTime() == "") {
     return timeout;
-    }
+  }
   struct tm* lctime;
   time_t current_time = time(0);
   lctime = gmtime(&current_time);
@@ -636,88 +584,77 @@ double cmCTestRunTest::ResolveTimeout()
   int local_hour = lctime->tm_hour;
 
   int tzone_offset = local_hour - gm_hour;
-  if(gm_time > current_time && gm_hour < local_hour)
-    {
+  if (gm_time > current_time && gm_hour < local_hour) {
     // this means gm_time is on the next day
     tzone_offset -= 24;
-    }
-  else if(gm_time < current_time && gm_hour > local_hour)
-    {
+  } else if (gm_time < current_time && gm_hour > local_hour) {
     // this means gm_time is on the previous day
     tzone_offset += 24;
-    }
+  }
 
   tzone_offset *= 100;
   char buf[1024];
   // add todays year day and month to the time in str because
   // curl_getdate no longer assumes the day is today
-  sprintf(buf, "%d%02d%02d %s %+05i",
-          lctime->tm_year + 1900,
-          lctime->tm_mon + 1,
-          lctime->tm_mday,
-          this->CTest->GetStopTime().c_str(),
-          tzone_offset);
+  sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+          lctime->tm_mon + 1, lctime->tm_mday,
+          this->CTest->GetStopTime().c_str(), tzone_offset);
 
   time_t stop_time = curl_getdate(buf, &current_time);
-  if(stop_time == -1)
-    {
+  if (stop_time == -1) {
     return timeout;
-    }
-
-  //the stop time refers to the next day
-  if(this->CTest->NextDayStopTime)
-    {
-    stop_time += 24*60*60;
-    }
-  int stop_timeout = static_cast<int>(stop_time - current_time) % (24*60*60);
+  }
+
+  // the stop time refers to the next day
+  if (this->CTest->NextDayStopTime) {
+    stop_time += 24 * 60 * 60;
+  }
+  int stop_timeout =
+    static_cast<int>(stop_time - current_time) % (24 * 60 * 60);
   this->CTest->LastStopTimeout = stop_timeout;
 
-  if(stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout)
-    {
+  if (stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
-      "Stopping all tests." << std::endl);
+                                           "Stopping all tests."
+                 << std::endl);
     this->StopTimePassed = true;
     return 0;
-    }
-  return timeout == 0 ? stop_timeout :
-    (timeout < stop_timeout ? timeout : stop_timeout);
+  }
+  return timeout == 0 ? stop_timeout
+                      : (timeout < stop_timeout ? timeout : stop_timeout);
 }
 
-//----------------------------------------------------------------------
 bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
-                     std::vector<std::string>* environment)
+                                 std::vector<std::string>* environment)
 {
   this->TestProcess = new cmProcess;
   this->TestProcess->SetId(this->Index);
   this->TestProcess->SetWorkingDirectory(
-        this->TestProperties->Directory.c_str());
+    this->TestProperties->Directory.c_str());
   this->TestProcess->SetCommand(this->ActualCommand.c_str());
   this->TestProcess->SetCommandArguments(this->Arguments);
 
   // determine how much time we have
   double timeout = this->CTest->GetRemainingTimeAllowed() - 120;
-  if (this->CTest->GetTimeOut() > 0 && this->CTest->GetTimeOut() < timeout)
-    {
+  if (this->CTest->GetTimeOut() > 0 && this->CTest->GetTimeOut() < timeout) {
     timeout = this->CTest->GetTimeOut();
-    }
-  if (testTimeOut > 0
-      && testTimeOut < this->CTest->GetRemainingTimeAllowed())
-    {
+  }
+  if (testTimeOut > 0 &&
+      testTimeOut < this->CTest->GetRemainingTimeAllowed()) {
     timeout = testTimeOut;
-    }
+  }
   // always have at least 1 second if we got to here
-  if (timeout <= 0)
-    {
+  if (timeout <= 0) {
     timeout = 1;
-    }
+  }
   // handle timeout explicitly set to 0
-  if (testTimeOut == 0 && explicitTimeout)
-    {
+  if (testTimeOut == 0 && explicitTimeout) {
     timeout = 0;
-    }
-  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
-    << "Test timeout computed to be: " << timeout << "\n",
-    this->TestHandler->GetQuiet());
+  }
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
+                       << ": "
+                       << "Test timeout computed to be: " << timeout << "\n",
+                     this->TestHandler->GetQuiet());
 
   this->TestProcess->SetTimeout(timeout);
 
@@ -725,10 +662,9 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
   cmSystemTools::SaveRestoreEnvironment sre;
 #endif
 
-  if (environment && !environment->empty())
-    {
+  if (environment && !environment->empty()) {
     cmSystemTools::AppendEnv(*environment);
-    }
+  }
 
   return this->TestProcess->StartProcess();
 }
@@ -741,69 +677,67 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
   // then it will never print out the completed / total, same would
   // got for run until pass.  Trick is when this is called we don't
   // yet know if we are passing or failing.
-  if(this->NumberOfRunsLeft == 1)
-    {
+  if (this->NumberOfRunsLeft == 1) {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
-               << completed << "/");
+                 << completed << "/");
     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
-               << total << " ");
-    }
+                 << total << " ");
+  }
   // if this is one of several runs of a test just print blank space
   // to keep things neat
-  else
-    {
+  else {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
-               << " " << " ");
+                 << " "
+                 << " ");
     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
-               << " " << " ");
-    }
+                 << " "
+                 << " ");
+  }
 
-  if ( this->TestHandler->MemCheck )
-    {
+  if (this->TestHandler->MemCheck) {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "MemCheck");
-    }
-  else
-    {
+  } else {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "Test");
-    }
+  }
 
   std::ostringstream indexStr;
   indexStr << " #" << this->Index << ":";
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
-             << indexStr.str());
+               << indexStr.str());
   cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
   const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
   std::string outname = this->TestProperties->Name + " ";
   outname.resize(maxTestNameWidth + 4, '.');
 
   *this->TestHandler->LogFile << this->TestProperties->Index << "/"
-    << this->TestHandler->TotalNumberOfTests << " Testing: "
-    << this->TestProperties->Name << std::endl;
+                              << this->TestHandler->TotalNumberOfTests
+                              << " Testing: " << this->TestProperties->Name
+                              << std::endl;
   *this->TestHandler->LogFile << this->TestProperties->Index << "/"
-    << this->TestHandler->TotalNumberOfTests
-    << " Test: " << this->TestProperties->Name << std::endl;
+                              << this->TestHandler->TotalNumberOfTests
+                              << " 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 << "\"";
-    }
-  *this->TestHandler->LogFile << std::endl
+       i != this->Arguments.end(); ++i) {
+    *this->TestHandler->LogFile << " \"" << *i << "\"";
+  }
+  *this->TestHandler->LogFile
+    << std::endl
     << "Directory: " << this->TestProperties->Directory << std::endl
-    << "\"" << this->TestProperties->Name << "\" start time: "
-    << this->StartTime << std::endl;
+    << "\"" << this->TestProperties->Name
+    << "\" start time: " << this->StartTime << std::endl;
 
   *this->TestHandler->LogFile
     << "Output:" << std::endl
     << "----------------------------------------------------------"
     << std::endl;
-  *this->TestHandler->LogFile
-    << this->ProcessOutput << "<end of output>" << std::endl;
+  *this->TestHandler->LogFile << this->ProcessOutput << "<end of output>"
+                              << std::endl;
 
   cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
-  cmCTestLog(this->CTest, DEBUG, "Testing "
-             << this->TestProperties->Name << " ... ");
+  cmCTestLog(this->CTest, DEBUG, "Testing " << this->TestProperties->Name
+                                            << " ... ");
 }
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index 3b5c831..3dcc026 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -12,8 +12,8 @@
 #ifndef cmCTestRunTest_h
 #define cmCTestRunTest_h
 
-#include <cmStandardIncludes.h>
 #include <cmCTestTestHandler.h>
+
 #include <cmProcess.h>
 
 /** \class cmRunTest
@@ -27,13 +27,17 @@ public:
   cmCTestRunTest(cmCTestTestHandler* handler);
   ~cmCTestRunTest();
 
-  void SetNumberOfRuns(int n) {this->NumberOfRunsLeft = n;}
-  void SetRunUntilFailOn() { this->RunUntilFail = true;}
-  void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties * prop)
-  { this->TestProperties = prop; }
+  void SetNumberOfRuns(int n) { this->NumberOfRunsLeft = n; }
+  void SetRunUntilFailOn() { this->RunUntilFail = true; }
+  void SetTestProperties(cmCTestTestHandler::cmCTestTestProperties* prop)
+  {
+    this->TestProperties = prop;
+  }
 
-  cmCTestTestHandler::cmCTestTestProperties * GetTestProperties()
-  { return this->TestProperties; }
+  cmCTestTestHandler::cmCTestTestProperties* GetTestProperties()
+  {
+    return this->TestProperties;
+  }
 
   void SetIndex(int i) { this->Index = i; }
 
@@ -44,7 +48,9 @@ public:
   bool IsStopTimePassed() { return this->StopTimePassed; }
 
   cmCTestTestHandler::cmCTestTestResult GetTestResults()
-  { return this->TestResult; }
+  {
+    return this->TestResult;
+  }
 
   // Read and store output.  Returns true if it must be called again.
   bool CheckOutput();
@@ -52,16 +58,17 @@ public:
   // Compresses the output, writing to CompressedOutput
   void CompressOutput();
 
-  //launch the test process, return whether it started correctly
+  // launch the test process, return whether it started correctly
   bool StartTest(size_t total);
-  //capture and report the test results
+  // capture and report the test results
   bool EndTest(size_t completed, size_t total, bool started);
-  //Called by ctest -N to log the command string
+  // Called by ctest -N to log the command string
   void ComputeArguments();
 
   void ComputeWeightedCost();
 
   bool StartAgain();
+
 private:
   bool NeedsToRerun();
   void DartProcessing();
@@ -71,18 +78,18 @@ private:
   bool ForkProcess(double testTimeOut, bool explicitTimeout,
                    std::vector<std::string>* environment);
   void WriteLogOutputTop(size_t completed, size_t total);
-  //Run post processing of the process output for MemCheck
+  // Run post processing of the process output for MemCheck
   void MemCheckPostProcess();
 
-  cmCTestTestHandler::cmCTestTestProperties * TestProperties;
-  //Pointer back to the "parent"; the handler that invoked this test run
-  cmCTestTestHandler * TestHandler;
-  cmCTest * CTest;
-  cmProcess * TestProcess;
-  //If the executable to run is ctest, don't create a new process;
-  //just instantiate a new cmTest.  (Can be disabled for a single test
-  //if this option is set to false.)
-  //bool OptimizeForCTest;
+  cmCTestTestHandler::cmCTestTestProperties* TestProperties;
+  // Pointer back to the "parent"; the handler that invoked this test run
+  cmCTestTestHandler* TestHandler;
+  cmCTest* CTest;
+  cmProcess* TestProcess;
+  // If the executable to run is ctest, don't create a new process;
+  // just instantiate a new cmTest.  (Can be disabled for a single test
+  // if this option is set to false.)
+  // bool OptimizeForCTest;
 
   bool UsePrefixCommand;
   std::string PrefixCommand;
@@ -90,7 +97,7 @@ private:
   std::string ProcessOutput;
   std::string CompressedOutput;
   double CompressionRatio;
-  //The test results
+  // The test results
   cmCTestTestHandler::cmCTestTestResult TestResult;
   int Index;
   std::string StartTime;
@@ -106,16 +113,13 @@ private:
 inline int getNumWidth(size_t n)
 {
   int numWidth = 1;
-  if(n >= 10)
-    {
+  if (n >= 10) {
     numWidth = 2;
-    }
-  if(n >= 100)
-    {
+  }
+  if (n >= 100) {
     numWidth = 3;
-    }
+  }
   return numWidth;
 }
 
 #endif
-
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index f7bd1f9..a6885aa 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -18,24 +18,21 @@
 
 #include <cmsys/RegularExpression.hxx>
 
-struct cmCTestSVN::Revision: public cmCTestVC::Revision
+struct cmCTestSVN::Revision : public cmCTestVC::Revision
 {
   cmCTestSVN::SVNInfo* SVNInfo;
 };
 
-//----------------------------------------------------------------------------
-cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log):
-  cmCTestGlobalVC(ct, log)
+cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log)
+  : cmCTestGlobalVC(ct, log)
 {
   this->PriorRev = this->Unknown;
 }
 
-//----------------------------------------------------------------------------
 cmCTestSVN::~cmCTestSVN()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::CleanupImpl()
 {
   std::vector<const char*> svn_cleanup;
@@ -45,21 +42,20 @@ void cmCTestSVN::CleanupImpl()
   this->RunSVNCommand(svn_cleanup, &out, &err);
 }
 
-//----------------------------------------------------------------------------
-class cmCTestSVN::InfoParser: public cmCTestVC::LineParser
+class cmCTestSVN::InfoParser : public cmCTestVC::LineParser
 {
 public:
-  InfoParser(cmCTestSVN* svn,
-             const char* prefix,
-             std::string& rev,
-             SVNInfo& svninfo):
-      Rev(rev), SVNRepo(svninfo)
-    {
+  InfoParser(cmCTestSVN* svn, const char* prefix, std::string& rev,
+             SVNInfo& svninfo)
+    : Rev(rev)
+    , SVNRepo(svninfo)
+  {
     this->SetLog(&svn->Log, prefix);
     this->RegexRev.compile("^Revision: ([0-9]+)");
     this->RegexURL.compile("^URL: +([^ ]+) *$");
     this->RegexRoot.compile("^Repository Root: +([^ ]+) *$");
-    }
+  }
+
 private:
   std::string& Rev;
   cmCTestSVN::SVNInfo& SVNRepo;
@@ -67,42 +63,30 @@ private:
   cmsys::RegularExpression RegexURL;
   cmsys::RegularExpression RegexRoot;
   virtual bool ProcessLine()
-    {
-    if(this->RegexRev.find(this->Line))
-      {
+  {
+    if (this->RegexRev.find(this->Line)) {
       this->Rev = this->RegexRev.match(1);
-      }
-    else if(this->RegexURL.find(this->Line))
-      {
+    } else if (this->RegexURL.find(this->Line)) {
       this->SVNRepo.URL = this->RegexURL.match(1);
-      }
-    else if(this->RegexRoot.find(this->Line))
-      {
+    } else if (this->RegexRoot.find(this->Line)) {
       this->SVNRepo.Root = this->RegexRoot.match(1);
-      }
-    return true;
     }
+    return true;
+  }
 };
 
-//----------------------------------------------------------------------------
 static bool cmCTestSVNPathStarts(std::string const& p1, std::string const& p2)
 {
   // Does path p1 start with path p2?
-  if(p1.size() == p2.size())
-    {
+  if (p1.size() == p2.size()) {
     return p1 == p2;
-    }
-  else if(p1.size() > p2.size() && p1[p2.size()] == '/')
-    {
+  } else if (p1.size() > p2.size() && p1[p2.size()] == '/') {
     return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
 {
   // Run "svn info" to get the repository info from the work tree.
@@ -116,11 +100,10 @@ std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
   return rev;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::NoteOldRevision()
 {
   // Info for root repository
-  this->Repositories.push_back( SVNInfo("") );
+  this->Repositories.push_back(SVNInfo(""));
   this->RootInfo = &(this->Repositories.back());
   // Info for the external repositories
   this->LoadExternals();
@@ -128,39 +111,34 @@ void cmCTestSVN::NoteOldRevision()
   // Get info for all the repositories
   std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
   std::list<SVNInfo>::iterator itend = this->Repositories.end();
-  for( ; itbeg != itend ; itbeg++)
-    {
+  for (; itbeg != itend; itbeg++) {
     SVNInfo& svninfo = *itbeg;
     svninfo.OldRevision = this->LoadInfo(svninfo);
     this->Log << "Revision for repository '" << svninfo.LocalPath
               << "' before update: " << svninfo.OldRevision << "\n";
-    cmCTestLog(this->CTest, HANDLER_OUTPUT,
-               "   Old revision of external repository '"
-               << svninfo.LocalPath << "' is: "
-               << svninfo.OldRevision << "\n");
-    }
+    cmCTestLog(
+      this->CTest, HANDLER_OUTPUT, "   Old revision of external repository '"
+        << svninfo.LocalPath << "' is: " << svninfo.OldRevision << "\n");
+  }
 
   // Set the global old revision to the one of the root
   this->OldRevision = this->RootInfo->OldRevision;
   this->PriorRev.Rev = this->OldRevision;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::NoteNewRevision()
 {
   // Get info for the external repositories
   std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
   std::list<SVNInfo>::iterator itend = this->Repositories.end();
-  for( ; itbeg != itend ; itbeg++)
-    {
+  for (; itbeg != itend; itbeg++) {
     SVNInfo& svninfo = *itbeg;
     svninfo.NewRevision = this->LoadInfo(svninfo);
     this->Log << "Revision for repository '" << svninfo.LocalPath
               << "' after update: " << svninfo.NewRevision << "\n";
-    cmCTestLog(this->CTest, HANDLER_OUTPUT,
-               "   New revision of external repository '"
-               << svninfo.LocalPath << "' is: "
-               << svninfo.NewRevision << "\n");
+    cmCTestLog(
+      this->CTest, HANDLER_OUTPUT, "   New revision of external repository '"
+        << svninfo.LocalPath << "' is: " << svninfo.NewRevision << "\n");
 
     // svninfo.Root = ""; // uncomment to test GuessBase
     this->Log << "Repository '" << svninfo.LocalPath
@@ -170,23 +148,20 @@ void cmCTestSVN::NoteNewRevision()
 
     // Compute the base path the working tree has checked out under
     // the repository root.
-    if(!svninfo.Root.empty()
-       && cmCTestSVNPathStarts(svninfo.URL, svninfo.Root))
-      {
-      svninfo.Base = cmCTest::DecodeURL(
-            svninfo.URL.substr(svninfo.Root.size()));
+    if (!svninfo.Root.empty() &&
+        cmCTestSVNPathStarts(svninfo.URL, svninfo.Root)) {
+      svninfo.Base =
+        cmCTest::DecodeURL(svninfo.URL.substr(svninfo.Root.size()));
       svninfo.Base += "/";
-      }
+    }
     this->Log << "Repository '" << svninfo.LocalPath
               << "' Base = " << svninfo.Base << "\n";
-
   }
 
   // Set the global new revision to the one of the root
   this->NewRevision = this->RootInfo->NewRevision;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::GuessBase(SVNInfo& svninfo,
                            std::vector<Change> const& changes)
 {
@@ -195,21 +170,18 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo,
   // changes under it.
 
   // Consider each possible URL suffix from longest to shortest.
-  for(std::string::size_type slash = svninfo.URL.find('/');
-      svninfo.Base.empty() && slash != std::string::npos;
-      slash = svninfo.URL.find('/', slash+1))
-    {
+  for (std::string::size_type slash = svninfo.URL.find('/');
+       svninfo.Base.empty() && slash != std::string::npos;
+       slash = svninfo.URL.find('/', slash + 1)) {
     // If the URL suffix is a prefix of at least one path then it is the base.
     std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash));
-    for(std::vector<Change>::const_iterator ci = changes.begin();
-        svninfo.Base.empty() && ci != changes.end(); ++ci)
-      {
-      if(cmCTestSVNPathStarts(ci->Path, base))
-        {
+    for (std::vector<Change>::const_iterator ci = changes.begin();
+         svninfo.Base.empty() && ci != changes.end(); ++ci) {
+      if (cmCTestSVNPathStarts(ci->Path, base)) {
         svninfo.Base = base;
-        }
       }
     }
+  }
 
   // We always append a slash so that we know paths beginning in the
   // base lie under its path.  If no base was found then the working
@@ -220,89 +192,87 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo,
   this->Log << "Guessed Base = " << svninfo.Base << "\n";
 }
 
-//----------------------------------------------------------------------------
-class cmCTestSVN::UpdateParser: public cmCTestVC::LineParser
+class cmCTestSVN::UpdateParser : public cmCTestVC::LineParser
 {
 public:
-  UpdateParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
-    {
+  UpdateParser(cmCTestSVN* svn, const char* prefix)
+    : SVN(svn)
+  {
     this->SetLog(&svn->Log, prefix);
     this->RegexUpdate.compile("^([ADUCGE ])([ADUCGE ])[B ] +(.+)$");
-    }
+  }
+
 private:
   cmCTestSVN* SVN;
   cmsys::RegularExpression RegexUpdate;
 
   bool ProcessLine()
-    {
-    if(this->RegexUpdate.find(this->Line))
-      {
+  {
+    if (this->RegexUpdate.find(this->Line)) {
       this->DoPath(this->RegexUpdate.match(1)[0],
-                   this->RegexUpdate.match(2)[0],
-                   this->RegexUpdate.match(3));
-      }
-    return true;
+                   this->RegexUpdate.match(2)[0], this->RegexUpdate.match(3));
     }
+    return true;
+  }
 
   void DoPath(char path_status, char prop_status, std::string const& path)
-    {
-    char status = (path_status != ' ')? path_status : prop_status;
+  {
+    char status = (path_status != ' ') ? path_status : prop_status;
     std::string dir = cmSystemTools::GetFilenamePath(path);
     std::string name = cmSystemTools::GetFilenameName(path);
     // See "svn help update".
-    switch(status)
-      {
+    switch (status) {
       case 'G':
         this->SVN->Dirs[dir][name].Status = PathModified;
         break;
       case 'C':
         this->SVN->Dirs[dir][name].Status = PathConflicting;
         break;
-      case 'A': case 'D': case 'U':
+      case 'A':
+      case 'D':
+      case 'U':
         this->SVN->Dirs[dir][name].Status = PathUpdated;
         break;
       case 'E': // TODO?
-      case '?': case ' ': default:
+      case '?':
+      case ' ':
+      default:
         break;
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
 bool cmCTestSVN::UpdateImpl()
 {
   // Get user-specified update options.
   std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
-  if(opts.empty())
-    {
+  if (opts.empty()) {
     opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
-    }
+  }
   std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
 
   // Specify the start time for nightly testing.
-  if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
-    {
+  if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
     args.push_back("-r{" + this->GetNightlyTime() + " +0000}");
-    }
+  }
 
   std::vector<char const*> svn_update;
   svn_update.push_back("update");
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     svn_update.push_back(ai->c_str());
-    }
+  }
 
   UpdateParser out(this, "up-out> ");
   OutputLogger err(this->Log, "up-err> ");
   return this->RunSVNCommand(svn_update, &out, &err);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
-    OutputParser* out, OutputParser* err)
+                               OutputParser* out, OutputParser* err)
 {
-  if(parameters.empty()) return false;
+  if (parameters.empty())
+    return false;
 
   std::vector<char const*> args;
   args.push_back(this->CommandLineTool.c_str());
@@ -311,37 +281,35 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
 
   args.push_back("--non-interactive");
 
-  std::string userOptions =
-    this->CTest->GetCTestConfiguration("SVNOptions");
+  std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
 
   std::vector<std::string> parsedUserOptions =
     cmSystemTools::ParseArguments(userOptions.c_str());
-  for(std::vector<std::string>::iterator i = parsedUserOptions.begin();
-      i != parsedUserOptions.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = parsedUserOptions.begin();
+       i != parsedUserOptions.end(); ++i) {
     args.push_back(i->c_str());
-    }
+  }
 
   args.push_back(0);
 
-  if(strcmp(parameters[0], "update") == 0)
-    {
+  if (strcmp(parameters[0], "update") == 0) {
     return RunUpdateCommand(&args[0], out, err);
-    }
-  else
-    {
+  } else {
     return RunChild(&args[0], out, err);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-class cmCTestSVN::LogParser: public cmCTestVC::OutputLogger,
-                             private cmXMLParser
+class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger,
+                              private cmXMLParser
 {
 public:
-  LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo):
-    OutputLogger(svn->Log, prefix), SVN(svn), SVNRepo(svninfo)
-  { this->InitializeParser(); }
+  LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo)
+    : OutputLogger(svn->Log, prefix)
+    , SVN(svn)
+    , SVNRepo(svninfo)
+  {
+    this->InitializeParser();
+  }
   ~LogParser() { this->CleanupParser(); }
 private:
   cmCTestSVN* SVN;
@@ -355,100 +323,80 @@ private:
   std::vector<char> CData;
 
   virtual bool ProcessChunk(const char* data, int length)
-    {
+  {
     this->OutputLogger::ProcessChunk(data, length);
     this->ParseChunk(data, length);
     return true;
-    }
+  }
 
   virtual void StartElement(const std::string& name, const char** atts)
-    {
+  {
     this->CData.clear();
-    if(name == "logentry")
-      {
+    if (name == "logentry") {
       this->Rev = Revision();
       this->Rev.SVNInfo = &SVNRepo;
-      if(const char* rev = this->FindAttribute(atts, "revision"))
-        {
+      if (const char* rev = this->FindAttribute(atts, "revision")) {
         this->Rev.Rev = rev;
-        }
-      this->Changes.clear();
       }
-    else if(name == "path")
-      {
+      this->Changes.clear();
+    } else if (name == "path") {
       this->CurChange = Change();
-      if(const char* action = this->FindAttribute(atts, "action"))
-        {
+      if (const char* action = this->FindAttribute(atts, "action")) {
         this->CurChange.Action = action[0];
-        }
       }
     }
+  }
 
   virtual void CharacterDataHandler(const char* data, int length)
-    {
-    this->CData.insert(this->CData.end(), data, data+length);
-    }
+  {
+    this->CData.insert(this->CData.end(), data, data + length);
+  }
 
   virtual void EndElement(const std::string& name)
-    {
-    if(name == "logentry")
-      {
+  {
+    if (name == "logentry") {
       this->SVN->DoRevisionSVN(this->Rev, this->Changes);
-      }
-    else if(!this->CData.empty() && name == "path")
-      {
+    } 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 );
+      std::string new_path = SVNRepo.BuildLocalPath(orig_path);
       this->CurChange.Path.assign(new_path);
       this->Changes.push_back(this->CurChange);
-      }
-    else if(!this->CData.empty() && name == "author")
-      {
+    } else if (!this->CData.empty() && name == "author") {
       this->Rev.Author.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "date")
-      {
+    } else if (!this->CData.empty() && name == "date") {
       this->Rev.Date.assign(&this->CData[0], this->CData.size());
-      }
-    else if(!this->CData.empty() && name == "msg")
-      {
+    } else if (!this->CData.empty() && name == "msg") {
       this->Rev.Log.assign(&this->CData[0], this->CData.size());
-      }
-    this->CData.clear();
     }
+    this->CData.clear();
+  }
 
   virtual void ReportError(int, int, const char* msg)
-    {
+  {
     this->SVN->Log << "Error parsing svn log xml: " << msg << "\n";
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::LoadRevisions()
 {
   // Get revisions for all the external repositories
   std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
   std::list<SVNInfo>::iterator itend = this->Repositories.end();
-  for( ; itbeg != itend ; itbeg++)
-    {
+  for (; itbeg != itend; itbeg++) {
     SVNInfo& svninfo = *itbeg;
     LoadRevisions(svninfo);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmCTestSVN::LoadRevisions(SVNInfo &svninfo)
+void cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
 {
   // We are interested in every revision included in the update.
   std::string revs;
-  if(atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str()))
-    {
+  if (atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) {
     revs = "-r" + svninfo.OldRevision + ":" + svninfo.NewRevision;
-    }
-  else
-    {
+  } else {
     revs = "-r" + svninfo.NewRevision;
-    }
+  }
 
   // Run "svn log" to get all global revisions of interest.
   std::vector<const char*> svn_log;
@@ -462,68 +410,71 @@ void cmCTestSVN::LoadRevisions(SVNInfo &svninfo)
   this->RunSVNCommand(svn_log, &out, &err);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::DoRevisionSVN(Revision const& revision,
                                std::vector<Change> const& changes)
 {
   // Guess the base checkout path from the changes if necessary.
-  if(this->RootInfo->Base.empty() && !changes.empty())
-    {
+  if (this->RootInfo->Base.empty() && !changes.empty()) {
     this->GuessBase(*this->RootInfo, changes);
-    }
+  }
 
   // Ignore changes in the old revision for external repositories
-  if(revision.Rev == revision.SVNInfo->OldRevision
-     && revision.SVNInfo->LocalPath != "")
-    {
+  if (revision.Rev == revision.SVNInfo->OldRevision &&
+      revision.SVNInfo->LocalPath != "") {
     return;
-    }
+  }
 
   this->cmCTestGlobalVC::DoRevision(revision, changes);
 }
 
-//----------------------------------------------------------------------------
-class cmCTestSVN::StatusParser: public cmCTestVC::LineParser
+class cmCTestSVN::StatusParser : public cmCTestVC::LineParser
 {
 public:
-  StatusParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
-    {
+  StatusParser(cmCTestSVN* svn, const char* prefix)
+    : SVN(svn)
+  {
     this->SetLog(&svn->Log, prefix);
     this->RegexStatus.compile("^([ACDIMRX?!~ ])([CM ])[ L]... +(.+)$");
-    }
+  }
+
 private:
   cmCTestSVN* SVN;
   cmsys::RegularExpression RegexStatus;
   bool ProcessLine()
-    {
-    if(this->RegexStatus.find(this->Line))
-      {
+  {
+    if (this->RegexStatus.find(this->Line)) {
       this->DoPath(this->RegexStatus.match(1)[0],
-                   this->RegexStatus.match(2)[0],
-                   this->RegexStatus.match(3));
-      }
-    return true;
+                   this->RegexStatus.match(2)[0], this->RegexStatus.match(3));
     }
+    return true;
+  }
 
   void DoPath(char path_status, char prop_status, std::string const& path)
-    {
-    char status = (path_status != ' ')? path_status : prop_status;
+  {
+    char status = (path_status != ' ') ? path_status : prop_status;
     // See "svn help status".
-    switch(status)
-      {
-      case 'M': case '!': case 'A': case 'D': case 'R':
+    switch (status) {
+      case 'M':
+      case '!':
+      case 'A':
+      case 'D':
+      case 'R':
         this->SVN->DoModification(PathModified, path);
         break;
-      case 'C': case '~':
+      case 'C':
+      case '~':
         this->SVN->DoModification(PathConflicting, path);
         break;
-      case 'X': case 'I': case '?': case ' ': default:
+      case 'X':
+      case 'I':
+      case '?':
+      case ' ':
+      default:
         break;
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::LoadModifications()
 {
   // Run "svn status" which reports local modifications.
@@ -534,7 +485,6 @@ void cmCTestSVN::LoadModifications()
   this->RunSVNCommand(svn_status, &out, &err);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
 {
   this->cmCTestGlobalVC::WriteXMLGlobal(xml);
@@ -542,46 +492,42 @@ void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
   xml.Element("SVNPath", this->RootInfo->Base);
 }
 
-//----------------------------------------------------------------------------
-class cmCTestSVN::ExternalParser: public cmCTestVC::LineParser
+class cmCTestSVN::ExternalParser : public cmCTestVC::LineParser
 {
 public:
-  ExternalParser(cmCTestSVN* svn, const char* prefix): SVN(svn)
-    {
+  ExternalParser(cmCTestSVN* svn, const char* prefix)
+    : SVN(svn)
+  {
     this->SetLog(&svn->Log, prefix);
     this->RegexExternal.compile("^X..... +(.+)$");
-    }
+  }
+
 private:
   cmCTestSVN* SVN;
   cmsys::RegularExpression RegexExternal;
   bool ProcessLine()
-    {
-    if(this->RegexExternal.find(this->Line))
-      {
+  {
+    if (this->RegexExternal.find(this->Line)) {
       this->DoPath(this->RegexExternal.match(1));
-      }
-    return true;
     }
+    return true;
+  }
 
   void DoPath(std::string const& path)
-    {
+  {
     // Get local path relative to the source directory
     std::string local_path;
-    if(path.size() > this->SVN->SourceDirectory.size() &&
-       strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(),
-               this->SVN->SourceDirectory.size()) == 0)
-      {
+    if (path.size() > this->SVN->SourceDirectory.size() &&
+        strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(),
+                this->SVN->SourceDirectory.size()) == 0) {
       local_path = path.c_str() + this->SVN->SourceDirectory.size() + 1;
-      }
-    else
-      {
+    } else {
       local_path = path;
-      }
-    this->SVN->Repositories.push_back( SVNInfo(local_path.c_str()) );
     }
+    this->SVN->Repositories.push_back(SVNInfo(local_path.c_str()));
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmCTestSVN::LoadExternals()
 {
   // Run "svn status" to get the list of external repositories
@@ -592,26 +538,21 @@ void cmCTestSVN::LoadExternals()
   this->RunSVNCommand(svn_status, &out, &err);
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const
 {
   std::string local_path;
 
   // Add local path prefix if not empty
-  if (!this->LocalPath.empty())
-    {
+  if (!this->LocalPath.empty()) {
     local_path += this->LocalPath;
     local_path += "/";
-    }
+  }
 
   // Add path with base prefix removed
-  if(path.size() > this->Base.size() &&
-     strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0)
-    {
+  if (path.size() > this->Base.size() &&
+      strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0) {
     local_path += (path.c_str() + this->Base.size());
-    }
-  else
-    {
+  } else {
     local_path += path;
   }
 
diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h
index f9febc5..e596bdc 100644
--- a/Source/CTest/cmCTestSVN.h
+++ b/Source/CTest/cmCTestSVN.h
@@ -20,7 +20,7 @@
  * \brief Interaction with subversion command-line tool
  *
  */
-class cmCTestSVN: public cmCTestGlobalVC
+class cmCTestSVN : public cmCTestGlobalVC
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
@@ -36,12 +36,16 @@ private:
   virtual bool UpdateImpl();
 
   bool RunSVNCommand(std::vector<char const*> const& parameters,
-    OutputParser* out, OutputParser* err);
+                     OutputParser* out, OutputParser* err);
 
   // Information about an SVN repository (root repository or external)
-  struct SVNInfo {
+  struct SVNInfo
+  {
 
-    SVNInfo(const char* path) : LocalPath(path) {}
+    SVNInfo(const char* path)
+      : LocalPath(path)
+    {
+    }
     // Remove base from the filename
     std::string BuildLocalPath(std::string const& path) const;
 
@@ -60,7 +64,6 @@ private:
     // Old and new repository revisions.
     std::string OldRevision;
     std::string NewRevision;
-
   };
 
   // Extended revision structure to include info about external it refers to.
@@ -79,7 +82,7 @@ private:
   void LoadRevisions();
   void LoadRevisions(SVNInfo& svninfo);
 
-  void GuessBase(SVNInfo &svninfo, std::vector<Change> const& changes);
+  void GuessBase(SVNInfo& svninfo, std::vector<Change> const& changes);
 
   void DoRevisionSVN(Revision const& revision,
                      std::vector<Change> const& changes);
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index ee15271..6389a9d 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -13,29 +13,29 @@
 #include "cmCTestScriptHandler.h"
 
 #include "cmCTest.h"
-#include "cmake.h"
 #include "cmFunctionBlocker.h"
-#include "cmMakefile.h"
-#include "cmGlobalGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
+#include "cmake.h"
 
 //#include <cmsys/RegularExpression.hxx>
-#include <cmsys/Process.h>
 #include <cmsys/Directory.hxx>
+#include <cmsys/Process.h>
 
 // used for sleep
 #ifdef _WIN32
 #include "windows.h"
 #endif
 
+#include <float.h>
+#include <math.h>
 #include <stdlib.h>
 #include <time.h>
-#include <math.h>
-#include <float.h>
 
 // needed for sleep
 #if !defined(_WIN32)
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 #include "cmCTestBuildCommand.h"
@@ -60,25 +60,23 @@ class cmCTestScriptFunctionBlocker : public cmFunctionBlocker
 public:
   cmCTestScriptFunctionBlocker() {}
   virtual ~cmCTestScriptFunctionBlocker() {}
-  virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
-                                 cmMakefile &mf,
-                                 cmExecutionStatus &);
-  //virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
-  //virtual void ScopeEnded(cmMakefile &mf);
+  virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
+                                 cmExecutionStatus&);
+  // virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
+  // virtual void ScopeEnded(cmMakefile &mf);
 
   cmCTestScriptHandler* CTestScriptHandler;
 };
 
 // simply update the time and don't block anything
-bool cmCTestScriptFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& , cmMakefile &,
-                  cmExecutionStatus &)
+bool cmCTestScriptFunctionBlocker::IsFunctionBlocked(const cmListFileFunction&,
+                                                     cmMakefile&,
+                                                     cmExecutionStatus&)
 {
   this->CTestScriptHandler->UpdateElapsedTime();
   return false;
 }
 
-//----------------------------------------------------------------------
 cmCTestScriptHandler::cmCTestScriptHandler()
 {
   this->Backup = false;
@@ -91,11 +89,10 @@ cmCTestScriptHandler::cmCTestScriptHandler()
   this->ScriptStartTime = 0;
 
   // the *60 is becuase the settings are in minutes but GetTime is seconds
-  this->MinimumInterval = 30*60;
+  this->MinimumInterval = 30 * 60;
   this->ContinuousDuration = -1;
 }
 
-//----------------------------------------------------------------------
 void cmCTestScriptHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -117,7 +114,7 @@ void cmCTestScriptHandler::Initialize()
   this->CMOutFile = "";
   this->ExtraUpdates.clear();
 
-  this->MinimumInterval = 20*60;
+  this->MinimumInterval = 20 * 60;
   this->ContinuousDuration = -1;
 
   // what time in seconds did this script start running
@@ -132,7 +129,6 @@ void cmCTestScriptHandler::Initialize()
   delete this->CMake;
 }
 
-//----------------------------------------------------------------------
 cmCTestScriptHandler::~cmCTestScriptHandler()
 {
   delete this->Makefile;
@@ -140,51 +136,43 @@ cmCTestScriptHandler::~cmCTestScriptHandler()
   delete this->CMake;
 }
 
-
-//----------------------------------------------------------------------
 // just adds an argument to the vector
-void cmCTestScriptHandler::AddConfigurationScript(const char *script,
+void cmCTestScriptHandler::AddConfigurationScript(const char* script,
                                                   bool pscope)
 {
   this->ConfigurationScripts.push_back(script);
   this->ScriptProcessScope.push_back(pscope);
 }
 
-
-//----------------------------------------------------------------------
 // the generic entry point for handling scripts, this routine will run all
 // the scripts provides a -S arguments
 int cmCTestScriptHandler::ProcessHandler()
 {
   int res = 0;
-  for (size_t i=0; i <  this->ConfigurationScripts.size(); ++i)
-    {
+  for (size_t i = 0; i < this->ConfigurationScripts.size(); ++i) {
     // for each script run it
-    res |= this->RunConfigurationScript
-      (cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
-       this->ScriptProcessScope[i]);
-    }
-  if ( res )
-    {
+    res |= this->RunConfigurationScript(
+      cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
+      this->ScriptProcessScope[i]);
+  }
+  if (res) {
     return -1;
-    }
+  }
   return 0;
 }
 
 void cmCTestScriptHandler::UpdateElapsedTime()
 {
-  if (this->Makefile)
-    {
+  if (this->Makefile) {
     // set the current elapsed time
     char timeString[20];
-    int itime = static_cast<unsigned int>(cmSystemTools::GetTime()
-                                          - this->ScriptStartTime);
-    sprintf(timeString,"%i",itime);
+    int itime = static_cast<unsigned int>(cmSystemTools::GetTime() -
+                                          this->ScriptStartTime);
+    sprintf(timeString, "%i", itime);
     this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command)
 {
   cmCTestCommand* newCom = command;
@@ -202,115 +190,97 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
   argv.push_back("-SR");
   argv.push_back(total_script_arg.c_str());
 
-  cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-             "Executable for CTest is: " <<
-             cmSystemTools::GetCTestCommand() << "\n");
+  cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: "
+               << cmSystemTools::GetCTestCommand() << "\n");
 
   // now pass through all the other arguments
-  std::vector<std::string> &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)
-    {
+  for (size_t i = 1; i < initArgs.size(); ++i) {
     argv.push_back(initArgs[i].c_str());
-    }
+  }
   argv.push_back(0);
 
   // Now create process object
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetCommand(cp, &*argv.begin());
-  //cmsysProcess_SetWorkingDirectory(cp, dir);
+  // cmsysProcess_SetWorkingDirectory(cp, dir);
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
-  //cmsysProcess_SetTimeout(cp, timeout);
+  // cmsysProcess_SetTimeout(cp, timeout);
   cmsysProcess_Execute(cp);
 
   std::vector<char> out;
   std::vector<char> err;
   std::string line;
   int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
-  while(pipe != cmsysProcess_Pipe_None)
-    {
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: "
-               << line << "\n");
-    if(pipe == cmsysProcess_Pipe_STDERR)
-      {
+  while (pipe != cmsysProcess_Pipe_None) {
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " << line
+                                                               << "\n");
+    if (pipe == cmsysProcess_Pipe_STDERR) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, line << "\n");
-      }
-    else if(pipe == cmsysProcess_Pipe_STDOUT)
-      {
+    } else if (pipe == cmsysProcess_Pipe_STDOUT) {
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, line << "\n");
-      }
-    pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
     }
+    pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
+  }
 
   // Properly handle output of the build command
   cmsysProcess_WaitForExit(cp, 0);
   int result = cmsysProcess_GetState(cp);
   int retVal = 0;
   bool failed = false;
-  if(result == cmsysProcess_State_Exited)
-    {
+  if (result == cmsysProcess_State_Exited) {
     retVal = cmsysProcess_GetExitValue(cp);
-    }
-  else if(result == cmsysProcess_State_Exception)
-    {
+  } else if (result == cmsysProcess_State_Exception) {
     retVal = cmsysProcess_GetExitException(cp);
     cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
-               << cmsysProcess_GetExceptionString(cp) << " " <<
-               retVal << std::endl);
+                 << cmsysProcess_GetExceptionString(cp) << " " << retVal
+                 << std::endl);
     failed = true;
-    }
-  else if(result == cmsysProcess_State_Expired)
-    {
+  } else if (result == cmsysProcess_State_Expired) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
-               << std::endl);
+                 << std::endl);
     failed = true;
-    }
-  else if(result == cmsysProcess_State_Error)
-    {
+  } else if (result == cmsysProcess_State_Error) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing ctest: "
-               << cmsysProcess_GetErrorString(cp) << std::endl);
+                 << cmsysProcess_GetErrorString(cp) << std::endl);
     failed = true;
-    }
+  }
   cmsysProcess_Delete(cp);
-  if(failed)
-    {
+  if (failed) {
     std::ostringstream message;
     message << "Error running command: [";
     message << result << "] ";
-    for(std::vector<const char*>::iterator i = argv.begin();
-        i != argv.end(); ++i)
-      {
-      if(*i)
-        {
-        message  << *i << " ";
-        }
+    for (std::vector<const char*>::iterator i = argv.begin(); i != argv.end();
+         ++i) {
+      if (*i) {
+        message << *i << " ";
       }
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               message.str() << argv[0] << std::endl);
-    return -1;
     }
+    cmCTestLog(this->CTest, ERROR_MESSAGE, message.str() << argv[0]
+                                                         << std::endl);
+    return -1;
+  }
   return retVal;
 }
 
-static void ctestScriptProgressCallback(const char *m, float, void* cd)
+static void ctestScriptProgressCallback(const char* m, float, void* cd)
 {
   cmCTest* ctest = static_cast<cmCTest*>(cd);
-  if(m && *m)
-    {
+  if (m && *m) {
     cmCTestLog(ctest, HANDLER_OUTPUT, "-- " << m << std::endl);
-    }
+  }
 }
 
 void cmCTestScriptHandler::CreateCMake()
 {
   // create a cmake instance to read the configuration script
-  if (this->CMake)
-    {
+  if (this->CMake) {
     delete this->CMake;
     delete this->GlobalGenerator;
     delete this->Makefile;
-    }
+  }
   this->CMake = new cmake;
   this->CMake->SetHomeDirectory("");
   this->CMake->SetHomeOutputDirectory("");
@@ -348,7 +318,6 @@ void cmCTestScriptHandler::CreateCMake()
   this->AddCTestCommand(new cmCTestUploadCommand);
 }
 
-//----------------------------------------------------------------------
 // this sets up some variables for the script to use, creates the required
 // cmake instance and generators, and then reads in the script
 int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
@@ -361,27 +330,26 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
   // passed into the scripts as S_ARG
   std::string script = total_script_arg;
   std::string script_arg;
-  if (total_script_arg.find(",") != std::string::npos)
-    {
-    script = total_script_arg.substr(0,total_script_arg.find(","));
-    script_arg = total_script_arg.substr(total_script_arg.find(",")+1);
-    }
+  const std::string::size_type comma_pos = total_script_arg.find(',');
+  if (comma_pos != std::string::npos) {
+    script = total_script_arg.substr(0, comma_pos);
+    script_arg = total_script_arg.substr(comma_pos + 1);
+  }
   // make sure the file exists
-  if (!cmSystemTools::FileExists(script.c_str()))
-    {
+  if (!cmSystemTools::FileExists(script.c_str())) {
     cmSystemTools::Error("Cannot find file: ", script.c_str());
     return 1;
-    }
+  }
 
   // read in the list file to fill the cache
   // create a cmake instance to read the configuration script
   this->CreateCMake();
 
   // set a variable with the path to the current script
-  this->Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY",
-                            cmSystemTools::GetFilenamePath(script).c_str());
-  this->Makefile->AddDefinition("CTEST_SCRIPT_NAME",
-                            cmSystemTools::GetFilenameName(script).c_str());
+  this->Makefile->AddDefinition(
+    "CTEST_SCRIPT_DIRECTORY", cmSystemTools::GetFilenamePath(script).c_str());
+  this->Makefile->AddDefinition(
+    "CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str());
   this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME",
                                 cmSystemTools::GetCTestCommand().c_str());
   this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
@@ -390,60 +358,53 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
   this->UpdateElapsedTime();
 
   // add the script arg if defined
-  if (!script_arg.empty())
-    {
+  if (!script_arg.empty()) {
     this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str());
-    }
+  }
 
 #if defined(__CYGWIN__)
   this->Makefile->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
 #endif
 
   // always add a function blocker to update the elapsed time
-  cmCTestScriptFunctionBlocker *f = new cmCTestScriptFunctionBlocker();
+  cmCTestScriptFunctionBlocker* f = new cmCTestScriptFunctionBlocker();
   f->CTestScriptHandler = this;
   this->Makefile->AddFunctionBlocker(f);
 
-
   /* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and
   CMakeSystemSpecificInformation, so
   that variables like CMAKE_SYSTEM and also the search paths for libraries,
   header and executables are set correctly and can be used. Makes new-style
   ctest scripting easier. */
   std::string systemFile =
-      this->Makefile->GetModulesFile("CTestScriptMode.cmake");
+    this->Makefile->GetModulesFile("CTestScriptMode.cmake");
   if (!this->Makefile->ReadListFile(systemFile.c_str()) ||
-      cmSystemTools::GetErrorOccuredFlag())
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:"
-               << systemFile << "\n");
+      cmSystemTools::GetErrorOccuredFlag()) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile
+                                                            << "\n");
     return 2;
-    }
+  }
 
   // Add definitions of variables passed in on the command line:
-  const std::map<std::string, std::string> &defs =
+  const std::map<std::string, std::string>& defs =
     this->CTest->GetDefinitions();
   for (std::map<std::string, std::string>::const_iterator it = defs.begin();
-       it != defs.end(); ++it)
-    {
+       it != defs.end(); ++it) {
     this->Makefile->AddDefinition(it->first, it->second.c_str());
-    }
+  }
 
   // finally read in the script
   if (!this->Makefile->ReadListFile(script.c_str()) ||
-    cmSystemTools::GetErrorOccuredFlag())
-    {
+      cmSystemTools::GetErrorOccuredFlag()) {
     // Reset the error flag so that it can run more than
     // one script with an error when you use ctest_run_script.
     cmSystemTools::ResetErrorOccuredFlag();
     return 2;
-    }
+  }
 
   return 0;
 }
 
-
-//----------------------------------------------------------------------
 // extract variabels from the script to set ivars
 int cmCTestScriptHandler::ExtractVariables()
 {
@@ -451,80 +412,64 @@ int cmCTestScriptHandler::ExtractVariables()
   const char* minInterval;
   const char* contDuration;
 
-  this->SourceDir
-    = this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
-  this->BinaryDir
-    = this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
+  this->SourceDir =
+    this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
+  this->BinaryDir =
+    this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
 
   // add in translations for src and bin
   cmSystemTools::AddKeepPath(this->SourceDir);
   cmSystemTools::AddKeepPath(this->BinaryDir);
 
-  this->CTestCmd
-    = this->Makefile->GetSafeDefinition("CTEST_COMMAND");
-  this->CVSCheckOut
-    = this->Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT");
-  this->CTestRoot
-    = this->Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT");
-  this->UpdateCmd
-    = this->Makefile->GetSafeDefinition("CTEST_UPDATE_COMMAND");
-  if ( this->UpdateCmd.empty() )
-    {
-    this->UpdateCmd
-      = this->Makefile->GetSafeDefinition("CTEST_CVS_COMMAND");
-    }
-  this->CTestEnv
-    = this->Makefile->GetSafeDefinition("CTEST_ENVIRONMENT");
-  this->InitialCache
-    = this->Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE");
-  this->CMakeCmd
-    = this->Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND");
-  this->CMOutFile
-    = this->Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME");
-
-  this->Backup
-    = this->Makefile->IsOn("CTEST_BACKUP_AND_RESTORE");
-  this->EmptyBinDir
-    = this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY");
-  this->EmptyBinDirOnce
-    = this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE");
-
-  minInterval
-    = this->Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL");
-  contDuration
-    = this->Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION");
+  this->CTestCmd = this->Makefile->GetSafeDefinition("CTEST_COMMAND");
+  this->CVSCheckOut = this->Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT");
+  this->CTestRoot = this->Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT");
+  this->UpdateCmd = this->Makefile->GetSafeDefinition("CTEST_UPDATE_COMMAND");
+  if (this->UpdateCmd.empty()) {
+    this->UpdateCmd = this->Makefile->GetSafeDefinition("CTEST_CVS_COMMAND");
+  }
+  this->CTestEnv = this->Makefile->GetSafeDefinition("CTEST_ENVIRONMENT");
+  this->InitialCache =
+    this->Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE");
+  this->CMakeCmd = this->Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND");
+  this->CMOutFile =
+    this->Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME");
+
+  this->Backup = this->Makefile->IsOn("CTEST_BACKUP_AND_RESTORE");
+  this->EmptyBinDir =
+    this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY");
+  this->EmptyBinDirOnce =
+    this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE");
+
+  minInterval =
+    this->Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL");
+  contDuration = this->Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION");
 
   char updateVar[40];
   int i;
-  for (i = 1; i < 10; ++i)
-    {
-    sprintf(updateVar,"CTEST_EXTRA_UPDATES_%i",i);
-    const char *updateVal = this->Makefile->GetDefinition(updateVar);
-    if ( updateVal )
-      {
-      if ( this->UpdateCmd.empty() )
-        {
-        cmSystemTools::Error(updateVar,
-          " specified without specifying CTEST_CVS_COMMAND.");
+  for (i = 1; i < 10; ++i) {
+    sprintf(updateVar, "CTEST_EXTRA_UPDATES_%i", i);
+    const char* updateVal = this->Makefile->GetDefinition(updateVar);
+    if (updateVal) {
+      if (this->UpdateCmd.empty()) {
+        cmSystemTools::Error(
+          updateVar, " specified without specifying CTEST_CVS_COMMAND.");
         return 12;
-        }
-      this->ExtraUpdates.push_back(updateVal);
       }
+      this->ExtraUpdates.push_back(updateVal);
     }
+  }
 
   // in order to backup and restore we also must have the cvs root
-  if (this->Backup && this->CVSCheckOut.empty())
-    {
+  if (this->Backup && this->CVSCheckOut.empty()) {
     cmSystemTools::Error(
       "Backup was requested without specifying CTEST_CVS_CHECKOUT.");
     return 3;
-    }
+  }
 
   // make sure the required info is here
-  if (this->SourceDir.empty() ||
-      this->BinaryDir.empty() ||
-      this->CTestCmd.empty())
-    {
+  if (this->SourceDir.empty() || this->BinaryDir.empty() ||
+      this->CTestCmd.empty()) {
     std::string msg = "CTEST_SOURCE_DIRECTORY = ";
     msg += (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)";
     msg += "\nCTEST_BINARY_DIRECTORY = ";
@@ -535,45 +480,39 @@ int cmCTestScriptHandler::ExtractVariables()
       "Some required settings in the configuration file were missing:\n",
       msg.c_str());
     return 4;
-    }
+  }
 
   // if the dashboard root isn't specified then we can compute it from the
   // this->SourceDir
-  if (this->CTestRoot.empty() )
-    {
-    this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir).c_str();
-    }
+  if (this->CTestRoot.empty()) {
+    this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir);
+  }
 
   // the script may override the minimum continuous interval
-  if (minInterval)
-    {
+  if (minInterval) {
     this->MinimumInterval = 60 * atof(minInterval);
-    }
-  if (contDuration)
-    {
+  }
+  if (contDuration) {
     this->ContinuousDuration = 60.0 * atof(contDuration);
-    }
-
+  }
 
   this->UpdateElapsedTime();
 
   return 0;
 }
 
-//----------------------------------------------------------------------
 void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
 {
 #if defined(_WIN32)
-        Sleep(1000*secondsToWait);
+  Sleep(1000 * secondsToWait);
 #else
-        sleep(secondsToWait);
+  sleep(secondsToWait);
 #endif
 }
 
-//----------------------------------------------------------------------
 // run a specific script
-int cmCTestScriptHandler::RunConfigurationScript
-(const std::string& total_script_arg, bool pscope)
+int cmCTestScriptHandler::RunConfigurationScript(
+  const std::string& total_script_arg, bool pscope)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmSystemTools::SaveRestoreEnvironment sre;
@@ -581,36 +520,29 @@ int cmCTestScriptHandler::RunConfigurationScript
 
   int result;
 
-  this->ScriptStartTime =
-    cmSystemTools::GetTime();
+  this->ScriptStartTime = cmSystemTools::GetTime();
 
   // read in the script
-  if (pscope)
-    {
+  if (pscope) {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Reading Script: " << total_script_arg << std::endl);
+               "Reading Script: " << total_script_arg << std::endl);
     result = this->ReadInScript(total_script_arg);
-    }
-  else
-    {
+  } else {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Executing Script: " << total_script_arg << std::endl);
+               "Executing Script: " << total_script_arg << std::endl);
     result = this->ExecuteScript(total_script_arg);
-    }
-  if (result)
-    {
+  }
+  if (result) {
     return result;
-    }
+  }
 
   // only run the curent script if we should
-  if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT"))
-    {
+  if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) {
     return this->RunCurrentScript();
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------
 int cmCTestScriptHandler::RunCurrentScript()
 {
   int result;
@@ -623,57 +555,47 @@ int cmCTestScriptHandler::RunCurrentScript()
 
   // extract the vars from the cache and store in ivars
   result = this->ExtractVariables();
-  if (result)
-    {
+  if (result) {
     return result;
-    }
+  }
 
   // set any environment variables
-  if (!this->CTestEnv.empty())
-    {
+  if (!this->CTestEnv.empty()) {
     std::vector<std::string> envArgs;
-    cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs);
+    cmSystemTools::ExpandListArgument(this->CTestEnv, envArgs);
     cmSystemTools::AppendEnv(envArgs);
-    }
+  }
 
   // now that we have done most of the error checking finally run the
   // dashboard, we may be asked to repeatedly run this dashboard, such as
   // for a continuous, do we ned to run it more than once?
-  if ( this->ContinuousDuration >= 0 )
-    {
+  if (this->ContinuousDuration >= 0) {
     this->UpdateElapsedTime();
-    double ending_time  = cmSystemTools::GetTime() + this->ContinuousDuration;
-    if (this->EmptyBinDirOnce)
-      {
+    double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration;
+    if (this->EmptyBinDirOnce) {
       this->EmptyBinDir = true;
-      }
-    do
-      {
+    }
+    do {
       double interval = cmSystemTools::GetTime();
       result = this->RunConfigurationDashboard();
       interval = cmSystemTools::GetTime() - interval;
-      if (interval < this->MinimumInterval)
-        {
+      if (interval < this->MinimumInterval) {
         this->SleepInSeconds(
           static_cast<unsigned int>(this->MinimumInterval - interval));
-        }
-      if (this->EmptyBinDirOnce)
-        {
+      }
+      if (this->EmptyBinDirOnce) {
         this->EmptyBinDir = false;
-        }
       }
-    while (cmSystemTools::GetTime() < ending_time);
-    }
+    } while (cmSystemTools::GetTime() < ending_time);
+  }
   // otherwise just run it once
-  else
-    {
+  else {
     result = this->RunConfigurationDashboard();
-    }
+  }
 
   return result;
 }
 
-//----------------------------------------------------------------------
 int cmCTestScriptHandler::CheckOutSourceDir()
 {
   std::string command;
@@ -682,27 +604,23 @@ int cmCTestScriptHandler::CheckOutSourceDir()
   bool res;
 
   if (!cmSystemTools::FileExists(this->SourceDir.c_str()) &&
-      !this->CVSCheckOut.empty())
-    {
+      !this->CVSCheckOut.empty()) {
     // we must now checkout the src dir
     output = "";
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Run cvs: " << this->CVSCheckOut << std::endl);
+               "Run cvs: " << this->CVSCheckOut << std::endl);
     res = cmSystemTools::RunSingleCommand(
-      this->CVSCheckOut.c_str(), &output, &output,
-      &retVal, this->CTestRoot.c_str(), this->HandlerVerbose,
-      0 /*this->TimeOut*/);
-    if (!res || retVal != 0)
-      {
+      this->CVSCheckOut.c_str(), &output, &output, &retVal,
+      this->CTestRoot.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/);
+    if (!res || retVal != 0) {
       cmSystemTools::Error("Unable to perform cvs checkout:\n",
                            output.c_str());
       return 6;
-      }
     }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------
 int cmCTestScriptHandler::BackupDirectories()
 {
   int retVal;
@@ -714,17 +632,14 @@ int cmCTestScriptHandler::BackupDirectories()
   this->BackupBinaryDir += "_CMakeBackup";
 
   // backup the binary and src directories if requested
-  if (this->Backup)
-    {
+  if (this->Backup) {
     // if for some reason those directories exist then first delete them
-    if (cmSystemTools::FileExists(this->BackupSourceDir.c_str()))
-      {
+    if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) {
       cmSystemTools::RemoveADirectory(this->BackupSourceDir);
-      }
-    if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str()))
-      {
+    }
+    if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) {
       cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
-      }
+    }
 
     // first rename the src and binary directories
     rename(this->SourceDir.c_str(), this->BackupSourceDir.c_str());
@@ -732,18 +647,15 @@ int cmCTestScriptHandler::BackupDirectories()
 
     // we must now checkout the src dir
     retVal = this->CheckOutSourceDir();
-    if (retVal)
-      {
+    if (retVal) {
       this->RestoreBackupDirectories();
       return retVal;
-      }
     }
+  }
 
   return 0;
 }
 
-
-//----------------------------------------------------------------------
 int cmCTestScriptHandler::PerformExtraUpdates()
 {
   std::string command;
@@ -754,39 +666,30 @@ int cmCTestScriptHandler::PerformExtraUpdates()
   // do an initial cvs update as required
   command = this->UpdateCmd;
   std::vector<std::string>::iterator it;
-  for (it = this->ExtraUpdates.begin();
-    it != this->ExtraUpdates.end();
-    ++ it )
-    {
+  for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++it) {
     std::vector<std::string> cvsArgs;
-    cmSystemTools::ExpandListArgument(*it,cvsArgs);
-    if (cvsArgs.size() == 2)
-      {
+    cmSystemTools::ExpandListArgument(*it, cvsArgs);
+    if (cvsArgs.size() == 2) {
       std::string fullCommand = command;
       fullCommand += " update ";
       fullCommand += cvsArgs[1];
       output = "";
       retVal = 0;
-      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: "
-        << fullCommand << std::endl);
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                 "Run Update: " << fullCommand << std::endl);
       res = cmSystemTools::RunSingleCommand(
-        fullCommand.c_str(), &output, &output,
-        &retVal, cvsArgs[0].c_str(),
+        fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
         this->HandlerVerbose, 0 /*this->TimeOut*/);
-      if (!res || retVal != 0)
-        {
-        cmSystemTools::Error("Unable to perform extra updates:\n",
-          it->c_str(), "\nWith output:\n",
-          output.c_str());
+      if (!res || retVal != 0) {
+        cmSystemTools::Error("Unable to perform extra updates:\n", it->c_str(),
+                             "\nWith output:\n", output.c_str());
         return 0;
-        }
       }
     }
+  }
   return 0;
 }
 
-
-//----------------------------------------------------------------------
 // run a single dashboard entry
 int cmCTestScriptHandler::RunConfigurationDashboard()
 {
@@ -799,200 +702,170 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
   // make sure the src directory is there, if it isn't then we might be able
   // to check it out from cvs
   retVal = this->CheckOutSourceDir();
-  if (retVal)
-    {
+  if (retVal) {
     return retVal;
-    }
+  }
 
   // backup the dirs if requested
   retVal = this->BackupDirectories();
-  if (retVal)
-    {
+  if (retVal) {
     return retVal;
-    }
+  }
 
   // clear the binary directory?
-  if (this->EmptyBinDir)
-    {
-    if ( !cmCTestScriptHandler::EmptyBinaryDirectory(
-        this->BinaryDir.c_str()) )
-      {
+  if (this->EmptyBinDir) {
+    if (!cmCTestScriptHandler::EmptyBinaryDirectory(this->BinaryDir.c_str())) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Problem removing the binary directory" << std::endl);
-      }
+                 "Problem removing the binary directory" << std::endl);
     }
+  }
 
   // make sure the binary directory exists if it isn't the srcdir
   if (!cmSystemTools::FileExists(this->BinaryDir.c_str()) &&
-      this->SourceDir != this->BinaryDir)
-    {
-    if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str()))
-      {
+      this->SourceDir != this->BinaryDir) {
+    if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str())) {
       cmSystemTools::Error("Unable to create the binary directory:\n",
                            this->BinaryDir.c_str());
       this->RestoreBackupDirectories();
       return 7;
-      }
     }
+  }
 
   // if the binary directory and the source directory are the same,
   // and we are starting with an empty binary directory, then that means
   // we must check out the source tree
-  if (this->EmptyBinDir && this->SourceDir == this->BinaryDir)
-    {
+  if (this->EmptyBinDir && this->SourceDir == this->BinaryDir) {
     // make sure we have the required info
-    if (this->CVSCheckOut.empty())
-      {
-      cmSystemTools::Error("You have specified the source and binary "
+    if (this->CVSCheckOut.empty()) {
+      cmSystemTools::Error(
+        "You have specified the source and binary "
         "directories to be the same (an in source build). You have also "
         "specified that the binary directory is to be erased. This means "
         "that the source will have to be checked out from CVS. But you have "
         "not specified CTEST_CVS_CHECKOUT");
       return 8;
-      }
+    }
 
     // we must now checkout the src dir
     retVal = this->CheckOutSourceDir();
-    if (retVal)
-      {
+    if (retVal) {
       this->RestoreBackupDirectories();
       return retVal;
-      }
     }
+  }
 
   // backup the dirs if requested
   retVal = this->PerformExtraUpdates();
-  if (retVal)
-    {
+  if (retVal) {
     return retVal;
-    }
+  }
 
   // put the initial cache into the bin dir
-  if (!this->InitialCache.empty())
-    {
+  if (!this->InitialCache.empty()) {
     if (!this->WriteInitialCache(this->BinaryDir.c_str(),
-         this->InitialCache.c_str()))
-      {
+                                 this->InitialCache.c_str())) {
       this->RestoreBackupDirectories();
       return 9;
-      }
     }
+  }
 
   // do an initial cmake to setup the DartConfig file
   int cmakeFailed = 0;
   std::string cmakeFailedOuput;
-  if (!this->CMakeCmd.empty())
-    {
+  if (!this->CMakeCmd.empty()) {
     command = this->CMakeCmd;
     command += " \"";
     command += this->SourceDir;
     output = "";
     command += "\"";
     retVal = 0;
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
-      << command << std::endl);
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+               "Run cmake command: " << command << std::endl);
     res = cmSystemTools::RunSingleCommand(
-      command.c_str(), &output, &output,
-      &retVal, this->BinaryDir.c_str(),
+      command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
       this->HandlerVerbose, 0 /*this->TimeOut*/);
 
-    if ( !this->CMOutFile.empty() )
-      {
+    if (!this->CMOutFile.empty()) {
       std::string cmakeOutputFile = this->CMOutFile;
-      if ( !cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str()) )
-        {
+      if (!cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str())) {
         cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile;
-        }
+      }
 
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "Write CMake output to file: " << cmakeOutputFile
-        << std::endl);
+                 "Write CMake output to file: " << cmakeOutputFile
+                                                << std::endl);
       cmGeneratedFileStream fout(cmakeOutputFile.c_str());
-      if ( fout )
-        {
+      if (fout) {
         fout << output.c_str();
-        }
-      else
-        {
+      } else {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-          "Cannot open CMake output file: "
-          << cmakeOutputFile << " for writing" << std::endl);
-        }
+                   "Cannot open CMake output file: "
+                     << cmakeOutputFile << " for writing" << std::endl);
       }
-    if (!res || retVal != 0)
-      {
+    }
+    if (!res || retVal != 0) {
       // even if this fails continue to the next step
       cmakeFailed = 1;
       cmakeFailedOuput = output;
-      }
     }
+  }
 
   // run ctest, it may be more than one command in here
   std::vector<std::string> ctestCommands;
-  cmSystemTools::ExpandListArgument(this->CTestCmd,ctestCommands);
+  cmSystemTools::ExpandListArgument(this->CTestCmd, ctestCommands);
   // for each variable/argument do a putenv
-  for (unsigned i = 0; i < ctestCommands.size(); ++i)
-    {
+  for (unsigned i = 0; i < ctestCommands.size(); ++i) {
     command = ctestCommands[i];
     output = "";
     retVal = 0;
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
-      << command << std::endl);
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+               "Run ctest command: " << command << std::endl);
     res = cmSystemTools::RunSingleCommand(
-      command.c_str(), &output, &output,
-      &retVal, this->BinaryDir.c_str(), this->HandlerVerbose,
-      0 /*this->TimeOut*/);
+      command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
+      this->HandlerVerbose, 0 /*this->TimeOut*/);
 
     // did something critical fail in ctest
-    if (!res || cmakeFailed ||
-        retVal & cmCTest::BUILD_ERRORS)
-      {
+    if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) {
       this->RestoreBackupDirectories();
-      if (cmakeFailed)
-        {
+      if (cmakeFailed) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-          "Unable to run cmake:" << std::endl
-          << cmakeFailedOuput << std::endl);
+                   "Unable to run cmake:" << std::endl
+                                          << cmakeFailedOuput << std::endl);
         return 10;
-        }
+      }
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Unable to run ctest:" << std::endl
-        << "command: " << command << std::endl
-        << "output: " << output << std::endl);
-      if (!res)
-        {
+                 "Unable to run ctest:" << std::endl
+                                        << "command: " << command << std::endl
+                                        << "output: " << output << std::endl);
+      if (!res) {
         return 11;
-        }
-      return retVal * 100;
       }
+      return retVal * 100;
     }
+  }
 
   // if all was succesful, delete the backup dirs to free up disk space
-  if (this->Backup)
-    {
+  if (this->Backup) {
     cmSystemTools::RemoveADirectory(this->BackupSourceDir);
     cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
-    }
+  }
 
   return 0;
 }
 
-//-------------------------------------------------------------------------
 bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
                                              const char* text)
 {
   std::string cacheFile = directory;
   cacheFile += "/CMakeCache.txt";
   cmGeneratedFileStream fout(cacheFile.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return false;
-    }
+  }
 
-  if (text!=0)
-    {
+  if (text != 0) {
     fout.write(text, strlen(text));
-    }
+  }
 
   // Make sure the operating system has finished writing the file
   // before closing it.  This will ensure the file is finished before
@@ -1002,133 +875,111 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
   return true;
 }
 
-//-------------------------------------------------------------------------
 void cmCTestScriptHandler::RestoreBackupDirectories()
 {
   // if we backed up the dirs and the build failed, then restore
   // the backed up dirs
-  if (this->Backup)
-    {
+  if (this->Backup) {
     // if for some reason those directories exist then first delete them
-    if (cmSystemTools::FileExists(this->SourceDir.c_str()))
-      {
+    if (cmSystemTools::FileExists(this->SourceDir.c_str())) {
       cmSystemTools::RemoveADirectory(this->SourceDir);
-      }
-    if (cmSystemTools::FileExists(this->BinaryDir.c_str()))
-      {
+    }
+    if (cmSystemTools::FileExists(this->BinaryDir.c_str())) {
       cmSystemTools::RemoveADirectory(this->BinaryDir);
-      }
+    }
     // rename the src and binary directories
     rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str());
     rename(this->BackupBinaryDir.c_str(), this->BinaryDir.c_str());
-    }
+  }
 }
 
-bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname,
+bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname,
                                      bool InProcess, int* returnValue)
 {
   cmCTestScriptHandler* sh = new cmCTestScriptHandler();
   sh->SetCTestInstance(ctest);
-  sh->AddConfigurationScript(sname,InProcess);
+  sh->AddConfigurationScript(sname, InProcess);
   int res = sh->ProcessHandler();
-  if(returnValue)
-    {
+  if (returnValue) {
     *returnValue = res;
-    }
+  }
   delete sh;
   return true;
 }
 
-bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname)
+bool cmCTestScriptHandler::EmptyBinaryDirectory(const char* sname)
 {
   // try to avoid deleting root
-  if (!sname || strlen(sname) < 2)
-    {
+  if (!sname || strlen(sname) < 2) {
     return false;
-    }
+  }
 
   // consider non existing target directory a success
-  if(!cmSystemTools::FileExists(sname))
-    {
+  if (!cmSystemTools::FileExists(sname)) {
     return true;
-    }
+  }
 
   // try to avoid deleting directories that we shouldn't
   std::string check = sname;
   check += "/CMakeCache.txt";
 
-  if(!cmSystemTools::FileExists(check.c_str()))
-    {
+  if (!cmSystemTools::FileExists(check.c_str())) {
     return false;
-    }
+  }
 
-  for(int i = 0; i < 5; ++i)
-    {
-    if(TryToRemoveBinaryDirectoryOnce(sname))
-      {
+  for (int i = 0; i < 5; ++i) {
+    if (TryToRemoveBinaryDirectoryOnce(sname)) {
       return true;
-      }
-    cmSystemTools::Delay(100);
     }
+    cmSystemTools::Delay(100);
+  }
 
   return false;
 }
 
-//-------------------------------------------------------------------------
 bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
   const std::string& directoryPath)
 {
   cmsys::Directory directory;
   directory.Load(directoryPath);
 
-  for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i)
-    {
+  for (unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i) {
     std::string path = directory.GetFile(i);
 
-    if(path == "." || path == ".." || path == "CMakeCache.txt")
-      {
+    if (path == "." || path == ".." || path == "CMakeCache.txt") {
       continue;
-      }
+    }
 
     std::string fullPath = directoryPath + std::string("/") + path;
 
     bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) &&
       !cmSystemTools::FileIsSymlink(fullPath);
 
-    if(isDirectory)
-      {
-      if(!cmSystemTools::RemoveADirectory(fullPath))
-        {
+    if (isDirectory) {
+      if (!cmSystemTools::RemoveADirectory(fullPath)) {
         return false;
-        }
       }
-    else
-      {
-      if(!cmSystemTools::RemoveFile(fullPath))
-        {
+    } else {
+      if (!cmSystemTools::RemoveFile(fullPath)) {
         return false;
-        }
       }
+    }
   }
 
   return cmSystemTools::RemoveADirectory(directoryPath);
 }
 
-//-------------------------------------------------------------------------
 double cmCTestScriptHandler::GetRemainingTimeAllowed()
 {
-  if (!this->Makefile)
-    {
+  if (!this->Makefile) {
     return 1.0e7;
-    }
+  }
 
-  const char *timelimitS
-    = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
+  const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
 
-  if (!timelimitS)
-    {
+  if (!timelimitS) {
     return 1.0e7;
-    }
+  }
 
   double timelimit = atof(timelimitS);
 
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index c9d0b6a..e09e040 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestScriptHandler_h
 #define cmCTestScriptHandler_h
 
-
 #include "cmCTestGenericHandler.h"
+
 #include "cmListFileCache.h"
 
 class cmMakefile;
@@ -66,7 +66,7 @@ public:
   /**
    * Add a script to run, and if is should run in the current process
    */
-  void AddConfigurationScript(const char *, bool pscope);
+  void AddConfigurationScript(const char*, bool pscope);
 
   /**
    * Run a dashboard using a specified confiuration script
@@ -76,14 +76,14 @@ public:
   /*
    * Run a script
    */
-  static bool RunScript(cmCTest* ctest, const char *script, bool InProcess,
-    int* returnValue);
+  static bool RunScript(cmCTest* ctest, const char* script, bool InProcess,
+                        int* returnValue);
   int RunCurrentScript();
 
   /*
    * Empty Binary Directory
    */
-  static bool EmptyBinaryDirectory(const char *dir);
+  static bool EmptyBinaryDirectory(const char* dir);
 
   /*
    * Write an initial CMakeCache.txt from the given contents.
@@ -109,7 +109,7 @@ public:
   void Initialize();
 
   void CreateCMake();
-  cmake* GetCMake() { return this->CMake;}
+  cmake* GetCMake() { return this->CMake; }
 private:
   // reads in a script
   int ReadInScript(const std::string& total_script_arg);
@@ -164,9 +164,9 @@ private:
   // what time in seconds did this script start running
   double ScriptStartTime;
 
-  cmMakefile *Makefile;
-  cmGlobalGenerator *GlobalGenerator;
-  cmake *CMake;
+  cmMakefile* Makefile;
+  cmGlobalGenerator* GlobalGenerator;
+  cmake* CMake;
 };
 
 #endif
diff --git a/Source/CTest/cmCTestSleepCommand.cxx b/Source/CTest/cmCTestSleepCommand.cxx
index 7e87550..102a303 100644
--- a/Source/CTest/cmCTestSleepCommand.cxx
+++ b/Source/CTest/cmCTestSleepCommand.cxx
@@ -14,42 +14,36 @@
 #include "cmCTestScriptHandler.h"
 #include <stdlib.h> // required for atoi
 
-bool cmCTestSleepCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestSleepCommand::InitialPass(std::vector<std::string> const& args,
+                                      cmExecutionStatus&)
 {
-  if (args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // sleep for specified seconds
   unsigned int time1 = atoi(args[0].c_str());
-  if(args.size() == 1 )
-    {
+  if (args.size() == 1) {
     cmCTestScriptHandler::SleepInSeconds(time1);
     // update the elapsed time since it could have slept for a while
     this->CTestScriptHandler->UpdateElapsedTime();
     return true;
-    }
+  }
 
   // sleep up to a duration
-  if(args.size() == 3 )
-    {
+  if (args.size() == 3) {
     unsigned int duration = atoi(args[1].c_str());
     unsigned int time2 = atoi(args[2].c_str());
-    if (time1 + duration > time2)
-      {
+    if (time1 + duration > time2) {
       duration = (time1 + duration - time2);
       cmCTestScriptHandler::SleepInSeconds(duration);
       // update the elapsed time since it could have slept for a while
       this->CTestScriptHandler->UpdateElapsedTime();
-      }
-    return true;
     }
+    return true;
+  }
 
   this->SetError("called with incorrect number of arguments");
   return false;
 }
-
-
diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h
index 740a7e1..ff7f146 100644
--- a/Source/CTest/cmCTestSleepCommand.h
+++ b/Source/CTest/cmCTestSleepCommand.h
@@ -23,35 +23,32 @@
 class cmCTestSleepCommand : public cmCTestCommand
 {
 public:
-
   cmCTestSleepCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestSleepCommand* ni = new cmCTestSleepCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_sleep";}
+  virtual std::string GetName() const { return "ctest_sleep"; }
 
   cmTypeMacro(cmCTestSleepCommand, cmCTestCommand);
-
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index 36576c5..d561393 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -12,9 +12,9 @@
 #include "cmCTestStartCommand.h"
 
 #include "cmCTest.h"
-#include "cmGlobalGenerator.h"
 #include "cmCTestVC.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
 
 cmCTestStartCommand::cmCTestStartCommand()
 {
@@ -22,14 +22,13 @@ cmCTestStartCommand::cmCTestStartCommand()
   this->Quiet = false;
 }
 
-bool cmCTestStartCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
+                                      cmExecutionStatus&)
 {
-  if (args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   size_t cnt = 0;
   const char* smodel = args[cnt].c_str();
@@ -39,62 +38,50 @@ bool cmCTestStartCommand
   cnt++;
 
   this->CTest->SetSpecificTrack(0);
-  if ( cnt < args.size() -1 )
-    {
-    if ( args[cnt] == "TRACK" )
-      {
-      cnt ++;
+  if (cnt < args.size() - 1) {
+    if (args[cnt] == "TRACK") {
+      cnt++;
       this->CTest->SetSpecificTrack(args[cnt].c_str());
-      cnt ++;
-      }
+      cnt++;
     }
+  }
 
-  if (cnt < args.size())
-    {
-    if (args[cnt] == "APPEND")
-      {
-      cnt ++;
+  if (cnt < args.size()) {
+    if (args[cnt] == "APPEND") {
+      cnt++;
       this->CreateNewTag = false;
-      }
     }
-  if (cnt < args.size())
-    {
-    if (args[cnt] == "QUIET")
-      {
-      cnt ++;
+  }
+  if (cnt < args.size()) {
+    if (args[cnt] == "QUIET") {
+      cnt++;
       this->Quiet = true;
-      }
     }
+  }
 
-  if ( cnt < args.size() )
-    {
+  if (cnt < args.size()) {
     src_dir = args[cnt].c_str();
-    cnt ++;
-    if ( cnt < args.size() )
-      {
+    cnt++;
+    if (cnt < args.size()) {
       bld_dir = args[cnt].c_str();
-      }
     }
-  if ( !src_dir )
-    {
+  }
+  if (!src_dir) {
     src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
-    }
-  if ( !bld_dir)
-    {
+  }
+  if (!bld_dir) {
     bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
-    }
-  if ( !src_dir )
-    {
+  }
+  if (!src_dir) {
     this->SetError("source directory not specified. Specify source directory "
-      "as an argument or set CTEST_SOURCE_DIRECTORY");
+                   "as an argument or set CTEST_SOURCE_DIRECTORY");
     return false;
-    }
-  if ( !bld_dir)
-    {
+  }
+  if (!bld_dir) {
     this->SetError("binary directory not specified. Specify binary directory "
-      "as an argument or set CTEST_BINARY_DIRECTORY");
+                   "as an argument or set CTEST_BINARY_DIRECTORY");
     return false;
-    }
+  }
 
   cmSystemTools::AddKeepPath(src_dir);
   cmSystemTools::AddKeepPath(bld_dir);
@@ -104,38 +91,35 @@ bool cmCTestStartCommand
   std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir);
   std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir);
   this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(),
-    this->Quiet);
+                                     this->Quiet);
   this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(),
-    this->Quiet);
+                                     this->Quiet);
 
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
-    << smodel << std::endl
-    << "   Source directory: " << src_dir << std::endl
-    << "   Build directory: " << bld_dir << std::endl, this->Quiet);
+                       << smodel << std::endl
+                       << "   Source directory: " << src_dir << std::endl
+                       << "   Build directory: " << bld_dir << std::endl,
+                     this->Quiet);
   const char* track = this->CTest->GetSpecificTrack();
-  if ( track )
-    {
+  if (track) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "   Track: " << track << std::endl, this->Quiet);
-    }
+                       "   Track: " << track << std::endl, this->Quiet);
+  }
 
   // Log startup actions.
   std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
   cmGeneratedFileStream ofs(startLogFile.c_str());
-  if(!ofs)
-    {
+  if (!ofs) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot create log file: LastStart.log" << std::endl);
     return false;
-    }
+  }
 
   // Make sure the source directory exists.
-  if(!this->InitialCheckout(ofs, sourceDir))
-    {
+  if (!this->InitialCheckout(ofs, sourceDir)) {
     return false;
-    }
-  if(!cmSystemTools::FileIsDirectory(sourceDir))
-    {
+  }
+  if (!cmSystemTools::FileIsDirectory(sourceDir)) {
     std::ostringstream e;
     e << "given source path\n"
       << "  " << sourceDir << "\n"
@@ -143,7 +127,7 @@ bool cmCTestStartCommand
       << "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
   this->CTest->SetSuppressUpdatingCTestConfiguration(true);
@@ -154,27 +138,23 @@ bool cmCTestStartCommand
   return this->CTest->InitializeFromCommand(this);
 }
 
-//----------------------------------------------------------------------------
-bool cmCTestStartCommand::InitialCheckout(
-  std::ostream& ofs, std::string const& sourceDir)
+bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs,
+                                          std::string const& sourceDir)
 {
   // Use the user-provided command to create the source tree.
-  const char* initialCheckoutCommand
-    = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
-  if(!initialCheckoutCommand)
-    {
+  const char* initialCheckoutCommand =
+    this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
+  if (!initialCheckoutCommand) {
     initialCheckoutCommand =
       this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
-    }
-  if(initialCheckoutCommand)
-    {
+  }
+  if (initialCheckoutCommand) {
     // Use a generic VC object to run and log the command.
     cmCTestVC vc(this->CTest, ofs);
     vc.SetSourceDirectory(sourceDir);
-    if(!vc.InitialCheckout(initialCheckoutCommand))
-      {
+    if (!vc.InitialCheckout(initialCheckoutCommand)) {
       return false;
-      }
     }
+  }
   return true;
 }
diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h
index eed1962..2aa6281 100644
--- a/Source/CTest/cmCTestStartCommand.h
+++ b/Source/CTest/cmCTestStartCommand.h
@@ -22,49 +22,42 @@
 class cmCTestStartCommand : public cmCTestCommand
 {
 public:
-
   cmCTestStartCommand();
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestStartCommand* ni = new cmCTestStartCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     ni->CreateNewTag = this->CreateNewTag;
     ni->Quiet = this->Quiet;
     return ni;
-    }
+  }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * Will this invocation of ctest_start create a new TAG file?
    */
-  bool ShouldCreateNewTag()
-    {
-    return this->CreateNewTag;
-    }
+  bool ShouldCreateNewTag() { return this->CreateNewTag; }
 
   /**
    * Should this invocation of ctest_start output non-error messages?
    */
-  bool ShouldBeQuiet()
-    {
-    return this->Quiet;
-    }
+  bool ShouldBeQuiet() { return this->Quiet; }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_start";}
+  virtual std::string GetName() const { return "ctest_start"; }
 
   cmTypeMacro(cmCTestStartCommand, cmCTestCommand);
 
@@ -74,5 +67,4 @@ private:
   bool Quiet;
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 5a8090c..664552a 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -17,96 +17,87 @@
 
 cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
 {
-  const char* ctestDropMethod
-    = this->Makefile->GetDefinition("CTEST_DROP_METHOD");
-  const char* ctestDropSite
-    = this->Makefile->GetDefinition("CTEST_DROP_SITE");
-  const char* ctestDropLocation
-    = this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
-  const char* ctestTriggerSite
-    = this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
-  bool ctestDropSiteCDash
-    = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
-  const char* ctestProjectName
-    = this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
-  if ( !ctestDropMethod )
-    {
+  const char* ctestDropMethod =
+    this->Makefile->GetDefinition("CTEST_DROP_METHOD");
+  const char* ctestDropSite = this->Makefile->GetDefinition("CTEST_DROP_SITE");
+  const char* ctestDropLocation =
+    this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
+  const char* ctestTriggerSite =
+    this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
+  bool ctestDropSiteCDash = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
+  const char* ctestProjectName =
+    this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
+  if (!ctestDropMethod) {
     ctestDropMethod = "http";
-    }
+  }
 
-  if ( !ctestDropSite )
-    {
+  if (!ctestDropSite) {
     // error: CDash requires CTEST_DROP_SITE definition
     // in CTestConfig.cmake
-    }
-  if ( !ctestDropLocation )
-    {
+  }
+  if (!ctestDropLocation) {
     // error: CDash requires CTEST_DROP_LOCATION definition
     // in CTestConfig.cmake
-    }
+  }
   this->CTest->SetCTestConfiguration("ProjectName", ctestProjectName,
-    this->Quiet);
+                                     this->Quiet);
   this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod,
-    this->Quiet);
+                                     this->Quiet);
   this->CTest->SetCTestConfiguration("DropSite", ctestDropSite, this->Quiet);
   this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation,
-    this->Quiet);
+                                     this->Quiet);
 
-  this->CTest->SetCTestConfiguration("IsCDash",
-    ctestDropSiteCDash ? "TRUE" : "FALSE", this->Quiet);
+  this->CTest->SetCTestConfiguration(
+    "IsCDash", ctestDropSiteCDash ? "TRUE" : "FALSE", this->Quiet);
 
   // Only propagate TriggerSite for non-CDash projects:
   //
-  if ( !ctestDropSiteCDash )
-    {
-    this->CTest->SetCTestConfiguration("TriggerSite",  ctestTriggerSite,
-      this->Quiet);
-    }
+  if (!ctestDropSiteCDash) {
+    this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite,
+                                       this->Quiet);
+  }
+
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "ScpCommand", "CTEST_SCP_COMMAND", this->Quiet);
 
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "DropSitePassword", "CTEST_DROP_SITE_PASSWORD", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "ScpCommand", "CTEST_SCP_COMMAND", this->Quiet);
-
-  const char* notesFilesVariable
-    = this->Makefile->GetDefinition("CTEST_NOTES_FILES");
-  if (notesFilesVariable)
-    {
+  const char* notesFilesVariable =
+    this->Makefile->GetDefinition("CTEST_NOTES_FILES");
+  if (notesFilesVariable) {
     std::vector<std::string> notesFiles;
     cmCTest::VectorOfStrings newNotesFiles;
-    cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
-    newNotesFiles.insert(newNotesFiles.end(),
-                         notesFiles.begin(), notesFiles.end());
+    cmSystemTools::ExpandListArgument(notesFilesVariable, notesFiles);
+    newNotesFiles.insert(newNotesFiles.end(), notesFiles.begin(),
+                         notesFiles.end());
     this->CTest->GenerateNotesFile(newNotesFiles);
-    }
+  }
 
-  const char* extraFilesVariable
-    = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
-  if (extraFilesVariable)
-    {
+  const char* extraFilesVariable =
+    this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
+  if (extraFilesVariable) {
     std::vector<std::string> extraFiles;
     cmCTest::VectorOfStrings newExtraFiles;
-    cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
-    newExtraFiles.insert(newExtraFiles.end(),
-                         extraFiles.begin(), extraFiles.end());
-    if ( !this->CTest->SubmitExtraFiles(newExtraFiles))
-      {
+    cmSystemTools::ExpandListArgument(extraFilesVariable, extraFiles);
+    newExtraFiles.insert(newExtraFiles.end(), extraFiles.begin(),
+                         extraFiles.end());
+    if (!this->CTest->SubmitExtraFiles(newExtraFiles)) {
       this->SetError("problem submitting extra files.");
       return 0;
-      }
     }
+  }
 
-  cmCTestGenericHandler* handler
-    = this->CTest->GetInitializedHandler("submit");
-  if ( !handler )
-    {
+  cmCTestGenericHandler* handler =
+    this->CTest->GetInitializedHandler("submit");
+  if (!handler) {
     this->SetError("internal CTest error. Cannot instantiate submit handler");
     return 0;
-    }
+  }
 
   // If no FILES or PARTS given, *all* PARTS are submitted by default.
   //
@@ -122,8 +113,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
 
   // If given explicit FILES to submit, pass them to the handler.
   //
-  if(this->FilesMentioned)
-    {
+  if (this->FilesMentioned) {
     // Intentionally select *no* PARTS. (Pass an empty set.) If PARTS
     // were also explicitly mentioned, they will be selected below...
     // But FILES with no PARTS mentioned should just submit the FILES
@@ -133,35 +123,32 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
     static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts);
 
     static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
-    }
+  }
 
   // If a PARTS option was given, select only the named parts for submission.
   //
-  if(this->PartsMentioned)
-    {
+  if (this->PartsMentioned) {
     static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
-    }
+  }
 
-  static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryDelay",
-    this->RetryDelay.c_str());
-  static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryCount",
-    this->RetryCount.c_str());
-  static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
-    this->InternalTest ? "ON" : "OFF");
+  static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+    "RetryDelay", this->RetryDelay.c_str());
+  static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+    "RetryCount", this->RetryCount.c_str());
+  static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+    "InternalTest", this->InternalTest ? "ON" : "OFF");
 
   handler->SetQuiet(this->Quiet);
 
-  if (this->CDashUpload)
-    {
-    static_cast<cmCTestSubmitHandler*>(handler)->
-      SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
-    static_cast<cmCTestSubmitHandler*>(handler)->
-      SetOption("CDashUploadType", this->CDashUploadType.c_str());
-    }
+  if (this->CDashUpload) {
+    static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+      "CDashUploadFile", this->CDashUploadFile.c_str());
+    static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
+      "CDashUploadType", this->CDashUploadType.c_str());
+  }
   return handler;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
                                        cmExecutionStatus& status)
 {
@@ -169,128 +156,102 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
   return this->cmCTestHandlerCommand::InitialPass(args, status);
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
 {
-  if (this->CDashUpload)
-    {
-    if(arg == "CDASH_UPLOAD")
-      {
+  if (this->CDashUpload) {
+    if (arg == "CDASH_UPLOAD") {
       this->ArgumentDoing = ArgumentDoingCDashUpload;
       return true;
-      }
+    }
 
-    if(arg == "CDASH_UPLOAD_TYPE")
-      {
+    if (arg == "CDASH_UPLOAD_TYPE") {
       this->ArgumentDoing = ArgumentDoingCDashUploadType;
       return true;
-      }
     }
-  else
-    {
+  } else {
     // Look for arguments specific to this command.
-    if(arg == "PARTS")
-      {
+    if (arg == "PARTS") {
       this->ArgumentDoing = ArgumentDoingParts;
       this->PartsMentioned = true;
       return true;
-      }
+    }
 
-    if(arg == "FILES")
-      {
+    if (arg == "FILES") {
       this->ArgumentDoing = ArgumentDoingFiles;
       this->FilesMentioned = true;
       return true;
-      }
+    }
 
-    if(arg == "RETRY_COUNT")
-      {
+    if (arg == "RETRY_COUNT") {
       this->ArgumentDoing = ArgumentDoingRetryCount;
       return true;
-      }
+    }
 
-    if(arg == "RETRY_DELAY")
-      {
+    if (arg == "RETRY_DELAY") {
       this->ArgumentDoing = ArgumentDoingRetryDelay;
       return true;
-      }
+    }
 
-    if(arg == "INTERNAL_TEST_CHECKSUM")
-      {
+    if (arg == "INTERNAL_TEST_CHECKSUM") {
       this->InternalTest = true;
       return true;
-      }
     }
+  }
 
   // Look for other arguments.
   return this->Superclass::CheckArgumentKeyword(arg);
 }
 
-
-//----------------------------------------------------------------------------
 bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
 {
   // Handle states specific to this command.
-  if(this->ArgumentDoing == ArgumentDoingParts)
-    {
+  if (this->ArgumentDoing == ArgumentDoingParts) {
     cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
-    if(p != cmCTest::PartCount)
-      {
+    if (p != cmCTest::PartCount) {
       this->Parts.insert(p);
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "Part name \"" << arg << "\" is invalid.";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       this->ArgumentDoing = ArgumentDoingError;
-      }
-    return true;
     }
+    return true;
+  }
 
-  if(this->ArgumentDoing == ArgumentDoingFiles)
-    {
-    std::string filename(arg);
-    if(cmSystemTools::FileExists(filename.c_str()))
-      {
-      this->Files.insert(filename);
-      }
-    else
-      {
+  if (this->ArgumentDoing == ArgumentDoingFiles) {
+    if (cmSystemTools::FileExists(arg.c_str())) {
+      this->Files.insert(arg);
+    } else {
       std::ostringstream e;
-      e << "File \"" << filename << "\" does not exist. Cannot submit "
-          << "a non-existent file.";
+      e << "File \"" << arg << "\" does not exist. Cannot submit "
+        << "a non-existent file.";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       this->ArgumentDoing = ArgumentDoingError;
-      }
-    return true;
     }
+    return true;
+  }
 
-  if(this->ArgumentDoing == ArgumentDoingRetryCount)
-    {
+  if (this->ArgumentDoing == ArgumentDoingRetryCount) {
     this->RetryCount = arg;
     return true;
-    }
+  }
 
-  if(this->ArgumentDoing == ArgumentDoingRetryDelay)
-    {
+  if (this->ArgumentDoing == ArgumentDoingRetryDelay) {
     this->RetryDelay = arg;
     return true;
-    }
+  }
 
-  if(this->ArgumentDoing == ArgumentDoingCDashUpload)
-    {
+  if (this->ArgumentDoing == ArgumentDoingCDashUpload) {
     this->ArgumentDoing = ArgumentDoingNone;
     this->CDashUploadFile = arg;
     return true;
-    }
+  }
 
-  if(this->ArgumentDoing == ArgumentDoingCDashUploadType)
-    {
+  if (this->ArgumentDoing == ArgumentDoingCDashUploadType) {
     this->ArgumentDoing = ArgumentDoingNone;
     this->CDashUploadType = arg;
     return true;
-    }
+  }
 
   // Look for other arguments.
   return this->Superclass::CheckArgumentValue(arg);
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index 19e8eaf..6323d8c 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -13,6 +13,7 @@
 #define cmCTestSubmitCommand_h
 
 #include "cmCTestHandlerCommand.h"
+
 #include "cmCTest.h"
 
 /** \class cmCTestSubmit
@@ -24,35 +25,34 @@
 class cmCTestSubmitCommand : public cmCTestHandlerCommand
 {
 public:
-
   cmCTestSubmitCommand()
-    {
+  {
     this->PartsMentioned = false;
     this->FilesMentioned = false;
     this->InternalTest = false;
     this->RetryCount = "";
     this->RetryDelay = "";
     this->CDashUpload = false;
-    }
+  }
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_submit";}
+  virtual std::string GetName() const { return "ctest_submit"; }
 
   cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand);
 
@@ -85,5 +85,4 @@ protected:
   std::string CDashUploadType;
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 833cad6..f373348 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -10,25 +10,26 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCTestSubmitHandler.h"
+
+#include "cmCTest.h"
 #include "cmCTestScriptHandler.h"
-#include "cmake.h"
+#include "cmGeneratedFileStream.h"
+#include "cmState.h"
 #include "cmSystemTools.h"
 #include "cmVersion.h"
-#include "cmGeneratedFileStream.h"
-#include "cmCTest.h"
 #include "cmXMLParser.h"
-#include "cmState.h"
+#include "cmake.h"
 
-#include <cmsys/Process.h>
 #include <cmsys/Base64.h>
+#include <cmsys/Process.h>
 
 // For XML-RPC submission
 #include "cm_xmlrpc.h"
 
 #include <cm_jsoncpp_reader.h>
 // For curl submission
-#include "cmCurl.h"
 #include "cmCTestCurl.h"
+#include "cmCurl.h"
 
 #include <sys/stat.h>
 
@@ -36,21 +37,19 @@
 
 typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
 
-//----------------------------------------------------------------------------
-class cmCTestSubmitHandler::ResponseParser: public cmXMLParser
+class cmCTestSubmitHandler::ResponseParser : public cmXMLParser
 {
 public:
   ResponseParser() { this->Status = STATUS_OK; }
   ~ResponseParser() {}
 
 public:
-
   enum StatusType
-    {
+  {
     STATUS_OK,
     STATUS_WARNING,
     STATUS_ERROR
-    };
+  };
 
   StatusType Status;
   std::string CDashVersion;
@@ -59,107 +58,89 @@ public:
   std::string Message;
 
 private:
-
   std::vector<char> CurrentValue;
 
   std::string GetCurrentValue()
-    {
+  {
     std::string val;
-    if(!this->CurrentValue.empty())
-      {
+    if (!this->CurrentValue.empty()) {
       val.assign(&this->CurrentValue[0], this->CurrentValue.size());
-      }
-    return val;
     }
+    return val;
+  }
 
   virtual void StartElement(const std::string& name, const char** atts)
-    {
+  {
     this->CurrentValue.clear();
-    if(name == "cdash")
-      {
+    if (name == "cdash") {
       this->CDashVersion = this->FindAttribute(atts, "version");
-      }
     }
+  }
 
   virtual void CharacterDataHandler(const char* data, int length)
-    {
-    this->CurrentValue.insert(this->CurrentValue.end(), data, data+length);
-    }
+  {
+    this->CurrentValue.insert(this->CurrentValue.end(), data, data + length);
+  }
 
   virtual void EndElement(const std::string& name)
-    {
-    if(name == "status")
-      {
+  {
+    if (name == "status") {
       std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
-      if(status == "OK" || status == "SUCCESS")
-        {
+      if (status == "OK" || status == "SUCCESS") {
         this->Status = STATUS_OK;
-        }
-      else if(status == "WARNING")
-        {
+      } else if (status == "WARNING") {
         this->Status = STATUS_WARNING;
-        }
-      else
-        {
+      } else {
         this->Status = STATUS_ERROR;
-        }
       }
-    else if(name == "filename")
-      {
+    } else if (name == "filename") {
       this->Filename = this->GetCurrentValue();
-      }
-    else if(name == "md5")
-      {
+    } else if (name == "md5") {
       this->MD5 = this->GetCurrentValue();
-      }
-    else if(name == "message")
-      {
+    } else if (name == "message") {
       this->Message = this->GetCurrentValue();
-      }
     }
+  }
 };
 
-
-static size_t
-cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
-  void *data)
+static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
+                                                      size_t nmemb, void* data)
 {
   int realsize = (int)(size * nmemb);
 
-  cmCTestSubmitHandlerVectorOfChar *vec
-    = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
+  cmCTestSubmitHandlerVectorOfChar* vec =
+    static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   vec->insert(vec->end(), chPtr, chPtr + realsize);
 
   return realsize;
 }
 
-static size_t
-cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
-  size_t size, void *data)
+static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL*, curl_infotype,
+                                                    char* chPtr, size_t size,
+                                                    void* data)
 {
-  cmCTestSubmitHandlerVectorOfChar *vec
-    = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
+  cmCTestSubmitHandlerVectorOfChar* vec =
+    static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
   vec->insert(vec->end(), chPtr, chPtr + size);
 
   return size;
 }
 
-//----------------------------------------------------------------------------
-cmCTestSubmitHandler::cmCTestSubmitHandler() : HTTPProxy(), FTPProxy()
+cmCTestSubmitHandler::cmCTestSubmitHandler()
+  : HTTPProxy()
+  , FTPProxy()
 {
   this->Initialize();
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSubmitHandler::Initialize()
 {
   // We submit all available parts by default.
-  for(cmCTest::Part p = cmCTest::PartStart;
-      p != cmCTest::PartCount; p = cmCTest::Part(p+1))
-    {
+  for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
+       p = cmCTest::Part(p + 1)) {
     this->SubmitPart[p] = true;
-    }
+  }
   this->CDash = false;
   this->HasWarnings = false;
   this->HasErrors = false;
@@ -173,13 +154,12 @@ void cmCTestSubmitHandler::Initialize()
   this->Files.clear();
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
-  const std::set<std::string>& files,
-  const std::string& remoteprefix,
-  const std::string& url)
+                                          const std::set<std::string>& files,
+                                          const std::string& remoteprefix,
+                                          const std::string& url)
 {
-  CURL *curl;
+  CURL* curl;
   CURLcode res;
   FILE* ftpfile;
   char error_buffer[1024];
@@ -188,28 +168,24 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
   ::curl_global_init(CURL_GLOBAL_ALL);
 
   cmCTest::SetOfStrings::const_iterator file;
-  for ( file = files.begin(); file != files.end(); ++file )
-    {
+  for (file = files.begin(); file != files.end(); ++file) {
     /* get a curl handle */
     curl = curl_easy_init();
-    if(curl)
-      {
+    if (curl) {
       // Using proxy
-      if ( this->FTPProxyType > 0 )
-        {
+      if (this->FTPProxyType > 0) {
         curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str());
-        switch (this->FTPProxyType)
-          {
-        case 2:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
-          break;
-        case 3:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
-          break;
-        default:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
-          }
+        switch (this->FTPProxyType) {
+          case 2:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+            break;
+          case 3:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+            break;
+          default:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
         }
+      }
 
       // enable uploading
       ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
@@ -217,129 +193,122 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
       // if there is little to no activity for too long stop submitting
       ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
       ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
-        SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
+                         SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
 
       ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
 
       std::string local_file = *file;
-      if ( !cmSystemTools::FileExists(local_file.c_str()) )
-        {
+      if (!cmSystemTools::FileExists(local_file.c_str())) {
         local_file = localprefix + "/" + *file;
-        }
-      std::string upload_as
-        = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
-
+      }
+      std::string upload_as =
+        url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
 
-      if ( !cmSystemTools::FileExists(local_file.c_str()) )
-        {
-        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Cannot find file: "
-          << local_file << std::endl);
+      if (!cmSystemTools::FileExists(local_file.c_str())) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE,
+                   "   Cannot find file: " << local_file << std::endl);
         ::curl_easy_cleanup(curl);
         ::curl_global_cleanup();
         return false;
-        }
+      }
       unsigned long filelen = cmSystemTools::FileLength(local_file);
 
       ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
-      *this->LogFile << "\tUpload file: " << local_file << " to "
-          << upload_as << std::endl;
+      *this->LogFile << "\tUpload file: " << local_file << " to " << upload_as
+                     << std::endl;
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "   Upload file: " << local_file << " to " << upload_as << std::endl,
-        this->Quiet);
+                         "   Upload file: " << local_file << " to "
+                                            << upload_as << std::endl,
+                         this->Quiet);
 
       ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
 
       // specify target
-      ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
+      ::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
 
       // now specify which file to upload
       ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
 
       // and give the size of the upload (optional)
-      ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
-        static_cast<long>(filelen));
+      ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
 
       // and give curl the buffer for errors
       ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
 
       // specify handler for output
       ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
-        cmCTestSubmitHandlerWriteMemoryCallback);
+                         cmCTestSubmitHandlerWriteMemoryCallback);
       ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
-        cmCTestSubmitHandlerCurlDebugCallback);
+                         cmCTestSubmitHandlerCurlDebugCallback);
 
       /* we pass our 'chunk' struct to the callback function */
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunkDebug;
-      ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
-      ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+      ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
+      ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
 
       // Now run off and do what you've been told!
       res = ::curl_easy_perform(curl);
 
-      if (!chunk.empty())
-        {
+      if (!chunk.empty()) {
         cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
-          << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-          << std::endl, this->Quiet);
-        }
-      if (!chunkDebug.empty())
-        {
-        cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
-          << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
-          << std::endl, this->Quiet);
-        }
+                             << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+                             << "]" << std::endl,
+                           this->Quiet);
+      }
+      if (!chunkDebug.empty()) {
+        cmCTestOptionalLog(
+          this->CTest, DEBUG, "CURL debug output: ["
+            << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+            << std::endl,
+          this->Quiet);
+      }
 
       fclose(ftpfile);
-      if ( res )
-        {
+      if (res) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error when uploading file: "
+                     << local_file << std::endl);
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-          "   Error when uploading file: "
-          << local_file << std::endl);
-        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error message was: "
-          << error_buffer << std::endl);
-        *this->LogFile << "   Error when uploading file: "
-                       << local_file
+                   "   Error message was: " << error_buffer << std::endl);
+        *this->LogFile << "   Error when uploading file: " << local_file
                        << std::endl
-                       << "   Error message was: "
-                       << error_buffer << std::endl
+                       << "   Error message was: " << error_buffer << std::endl
                        << "   Curl output was: ";
         // avoid dereference of empty vector
-        if(!chunk.empty())
-          {
+        if (!chunk.empty()) {
           *this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
           cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
-                     << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-                     << std::endl);
-          }
+                       << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+                       << std::endl);
+        }
         *this->LogFile << std::endl;
         ::curl_easy_cleanup(curl);
         ::curl_global_cleanup();
         return false;
-        }
+      }
       // always cleanup
       ::curl_easy_cleanup(curl);
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        "   Uploaded: " + local_file << std::endl, this->Quiet);
-      }
+                         "   Uploaded: " + local_file << std::endl,
+                         this->Quiet);
     }
+  }
   ::curl_global_cleanup();
   return true;
 }
 
-//----------------------------------------------------------------------------
 // Uploading files is simpler
 bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
-  const std::set<std::string>& files,
-  const std::string& remoteprefix,
-  const std::string& url)
+                                           const std::set<std::string>& files,
+                                           const std::string& remoteprefix,
+                                           const std::string& url)
 {
-  CURL *curl;
+  CURL* curl;
   CURLcode res;
   FILE* ftpfile;
   char error_buffer[1024];
-  struct curl_slist *headers = ::curl_slist_append(NULL,
-                                                   "Content-Type: text/xml");
+  struct curl_slist* headers =
+    ::curl_slist_append(NULL, "Content-Type: text/xml");
 
   /* In windows, this will init the winsock stuff */
   ::curl_global_init(CURL_GLOBAL_ALL);
@@ -349,65 +318,56 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
   cmSystemTools::ExpandListArgument(curlopt, args);
   bool verifyPeerOff = false;
   bool verifyHostOff = false;
-  for( std::vector<std::string>::iterator i = args.begin();
-       i != args.end(); ++i)
-    {
-    if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
-      {
+  for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
+       ++i) {
+    if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
       verifyPeerOff = true;
-      }
-    if(*i == "CURLOPT_SSL_VERIFYHOST_OFF")
-      {
+    }
+    if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
       verifyHostOff = true;
-      }
     }
+  }
   std::string::size_type kk;
   cmCTest::SetOfStrings::const_iterator file;
-  for ( file = files.begin(); file != files.end(); ++file )
-    {
+  for (file = files.begin(); file != files.end(); ++file) {
     /* get a curl handle */
     curl = curl_easy_init();
-    if(curl)
-      {
+    if (curl) {
       cmCurlSetCAInfo(curl);
-      if(verifyPeerOff)
-        {
+      if (verifyPeerOff) {
         cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-                   "  Set CURLOPT_SSL_VERIFYPEER to off\n", this->Quiet);
+                           "  Set CURLOPT_SSL_VERIFYPEER to off\n",
+                           this->Quiet);
         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
-        }
-      if(verifyHostOff)
-        {
+      }
+      if (verifyHostOff) {
         cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-                   "  Set CURLOPT_SSL_VERIFYHOST to off\n", this->Quiet);
+                           "  Set CURLOPT_SSL_VERIFYHOST to off\n",
+                           this->Quiet);
         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
-        }
+      }
 
       // Using proxy
-      if ( this->HTTPProxyType > 0 )
-        {
+      if (this->HTTPProxyType > 0) {
         curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
-        switch (this->HTTPProxyType)
-          {
-        case 2:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
-          break;
-        case 3:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
-          break;
-        default:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
-          if (!this->HTTPProxyAuth.empty())
-            {
-            curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
-              this->HTTPProxyAuth.c_str());
+        switch (this->HTTPProxyType) {
+          case 2:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+            break;
+          case 3:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+            break;
+          default:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+            if (!this->HTTPProxyAuth.empty()) {
+              curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
+                               this->HTTPProxyAuth.c_str());
             }
-          }
         }
-      if(this->CTest->ShouldUseHTTP10())
-        {
+      }
+      if (this->CTest->ShouldUseHTTP10()) {
         curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
-        }
+      }
       // enable HTTP ERROR parsing
       curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
       /* enable uploading */
@@ -416,7 +376,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
       // if there is little to no activity for too long stop submitting
       ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
       ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
-        SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
+                         SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
 
       /* HTTP PUT please */
       ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
@@ -426,157 +386,158 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
       ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
 
       std::string local_file = *file;
-      if ( !cmSystemTools::FileExists(local_file.c_str()) )
-        {
+      if (!cmSystemTools::FileExists(local_file.c_str())) {
         local_file = localprefix + "/" + *file;
-        }
-      std::string remote_file
-        = remoteprefix + cmSystemTools::GetFilenameName(*file);
+      }
+      std::string remote_file =
+        remoteprefix + cmSystemTools::GetFilenameName(*file);
 
       *this->LogFile << "\tUpload file: " << local_file << " to "
-          << remote_file << std::endl;
+                     << remote_file << std::endl;
 
       std::string ofile = "";
-      for ( kk = 0; kk < remote_file.size(); kk ++ )
-        {
+      for (kk = 0; kk < remote_file.size(); kk++) {
         char c = remote_file[kk];
         char hexCh[4] = { 0, 0, 0, 0 };
         hexCh[0] = c;
-        switch ( c )
-          {
-        case '+':
-        case '?':
-        case '/':
-        case '\\':
-        case '&':
-        case ' ':
-        case '=':
-        case '%':
-          sprintf(hexCh, "%%%02X", (int)c);
-          ofile.append(hexCh);
-          break;
-        default:
-          ofile.append(hexCh);
-          }
+        switch (c) {
+          case '+':
+          case '?':
+          case '/':
+          case '\\':
+          case '&':
+          case ' ':
+          case '=':
+          case '%':
+            sprintf(hexCh, "%%%02X", (int)c);
+            ofile.append(hexCh);
+            break;
+          default:
+            ofile.append(hexCh);
         }
-      std::string upload_as
-        = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
-        + "FileName=" + ofile;
+      }
+      std::string upload_as = url +
+        ((url.find('?') == std::string::npos) ? '?' : '&') + "FileName=" +
+        ofile;
 
       upload_as += "&MD5=";
 
-      if(cmSystemTools::IsOn(this->GetOption("InternalTest")))
-        {
+      if (cmSystemTools::IsOn(this->GetOption("InternalTest"))) {
         upload_as += "bad_md5sum";
-        }
-      else
-        {
+      } else {
         char md5[33];
         cmSystemTools::ComputeFileMD5(local_file, md5);
         md5[32] = 0;
         upload_as += md5;
-        }
+      }
 
-      if( !cmSystemTools::FileExists(local_file.c_str()) )
-        {
-        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Cannot find file: "
-          << local_file << std::endl);
+      if (!cmSystemTools::FileExists(local_file.c_str())) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE,
+                   "   Cannot find file: " << local_file << std::endl);
         ::curl_easy_cleanup(curl);
         ::curl_slist_free_all(headers);
         ::curl_global_cleanup();
         return false;
-        }
+      }
       unsigned long filelen = cmSystemTools::FileLength(local_file);
 
       ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "   Upload file: " << local_file << " to "
-        << upload_as << " Size: " << filelen << std::endl, this->Quiet);
+                         "   Upload file: " << local_file << " to "
+                                            << upload_as << " Size: "
+                                            << filelen << std::endl,
+                         this->Quiet);
 
       // specify target
-      ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
+      ::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
 
       // now specify which file to upload
       ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
 
       // and give the size of the upload (optional)
-      ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
-        static_cast<long>(filelen));
+      ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
 
       // and give curl the buffer for errors
       ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
 
       // specify handler for output
       ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
-        cmCTestSubmitHandlerWriteMemoryCallback);
+                         cmCTestSubmitHandlerWriteMemoryCallback);
       ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
-        cmCTestSubmitHandlerCurlDebugCallback);
+                         cmCTestSubmitHandlerCurlDebugCallback);
 
       /* we pass our 'chunk' struct to the callback function */
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunkDebug;
-      ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
-      ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+      ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
+      ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
 
       // Now run off and do what you've been told!
       res = ::curl_easy_perform(curl);
 
-      if(cmSystemTools::IsOn(this->GetOption("InternalTest")) &&
-         cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
-         this->CTest->GetCDashVersion().c_str(), "1.7"))
-        {
+      if (cmSystemTools::IsOn(this->GetOption("InternalTest")) &&
+          cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
+                                        this->CTest->GetCDashVersion().c_str(),
+                                        "1.7")) {
         // mock failure output for internal test case
-        std::string mock_output = "<cdash version=\"1.7.0\">\n"
+        std::string mock_output =
+          "<cdash version=\"1.7.0\">\n"
           "  <status>ERROR</status>\n"
           "  <message>Checksum failed for file.</message>\n"
           "</cdash>\n";
         chunk.clear();
         chunk.assign(mock_output.begin(), mock_output.end());
-        }
+      }
 
-      if (!chunk.empty())
-        {
+      if (!chunk.empty()) {
         cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
-          << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-          << std::endl, this->Quiet);
+                             << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+                             << "]" << std::endl,
+                           this->Quiet);
         this->ParseResponse(chunk);
-        }
-      if (!chunkDebug.empty())
-        {
-        cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
-          << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
-          << std::endl, this->Quiet);
-        }
+      }
+      if (!chunkDebug.empty()) {
+        cmCTestOptionalLog(
+          this->CTest, DEBUG, "CURL debug output: ["
+            << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+            << std::endl,
+          this->Quiet);
+      }
 
       // If curl failed for any reason, or checksum fails, wait and retry
       //
-      if(res != CURLE_OK || this->HasErrors)
-        {
-        std::string retryDelay = this->GetOption("RetryDelay") == NULL ?
-          "" : this->GetOption("RetryDelay");
-        std::string retryCount = this->GetOption("RetryCount") == NULL ?
-          "" : this->GetOption("RetryCount");
-
-        int delay = retryDelay == "" ? atoi(this->CTest->GetCTestConfiguration(
-          "CTestSubmitRetryDelay").c_str()) : atoi(retryDelay.c_str());
-        int count = retryCount == "" ? atoi(this->CTest->GetCTestConfiguration(
-          "CTestSubmitRetryCount").c_str()) : atoi(retryCount.c_str());
-
-        for(int i = 0; i < count; i++)
-          {
+      if (res != CURLE_OK || this->HasErrors) {
+        std::string retryDelay = this->GetOption("RetryDelay") == NULL
+          ? ""
+          : this->GetOption("RetryDelay");
+        std::string retryCount = this->GetOption("RetryCount") == NULL
+          ? ""
+          : this->GetOption("RetryCount");
+
+        int delay = retryDelay == ""
+          ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
+                   .c_str())
+          : atoi(retryDelay.c_str());
+        int count = retryCount == ""
+          ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
+                   .c_str())
+          : atoi(retryCount.c_str());
+
+        for (int i = 0; i < count; i++) {
           cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-            "   Submit failed, waiting " << delay << " seconds...\n",
-            this->Quiet);
+                             "   Submit failed, waiting " << delay
+                                                          << " seconds...\n",
+                             this->Quiet);
 
           double stop = cmSystemTools::GetTime() + delay;
-          while(cmSystemTools::GetTime() < stop)
-            {
+          while (cmSystemTools::GetTime() < stop) {
             cmSystemTools::Delay(100);
-            }
+          }
 
           cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-            "   Retry submission: Attempt " << (i + 1) << " of "
-            << count << std::endl, this->Quiet);
+                             "   Retry submission: Attempt "
+                               << (i + 1) << " of " << count << std::endl,
+                             this->Quiet);
 
           ::fclose(ftpfile);
           ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
@@ -588,137 +549,121 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
 
           res = ::curl_easy_perform(curl);
 
-          if (!chunk.empty())
-            {
-            cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
-              << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-              << std::endl, this->Quiet);
+          if (!chunk.empty()) {
+            cmCTestOptionalLog(
+              this->CTest, DEBUG, "CURL output: ["
+                << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+                << std::endl,
+              this->Quiet);
             this->ParseResponse(chunk);
-            }
+          }
 
-          if(res == CURLE_OK && !this->HasErrors)
-            {
+          if (res == CURLE_OK && !this->HasErrors) {
             break;
-            }
           }
         }
+      }
 
       fclose(ftpfile);
-      if ( res )
-        {
+      if (res) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error when uploading file: "
+                     << local_file << std::endl);
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-          "   Error when uploading file: "
-          << local_file << std::endl);
-        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error message was: "
-          << error_buffer << std::endl);
-        *this->LogFile << "   Error when uploading file: "
-                       << local_file
+                   "   Error message was: " << error_buffer << std::endl);
+        *this->LogFile << "   Error when uploading file: " << local_file
                        << std::endl
                        << "   Error message was: " << error_buffer
                        << std::endl;
         // avoid deref of begin for zero size array
-        if(!chunk.empty())
-          {
+        if (!chunk.empty()) {
           *this->LogFile << "   Curl output was: "
                          << cmCTestLogWrite(&*chunk.begin(), chunk.size())
                          << std::endl;
           cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
-                     << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-                     << std::endl);
-          }
+                       << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+                       << std::endl);
+        }
         ::curl_easy_cleanup(curl);
         ::curl_slist_free_all(headers);
         ::curl_global_cleanup();
         return false;
-        }
+      }
       // always cleanup
       ::curl_easy_cleanup(curl);
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        "   Uploaded: " + local_file << std::endl, this->Quiet);
-      }
+                         "   Uploaded: " + local_file << std::endl,
+                         this->Quiet);
     }
+  }
   ::curl_slist_free_all(headers);
   ::curl_global_cleanup();
   return true;
 }
 
-//----------------------------------------------------------------------------
-void cmCTestSubmitHandler
-::ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk)
+void cmCTestSubmitHandler::ParseResponse(
+  cmCTestSubmitHandlerVectorOfChar chunk)
 {
   std::string output = "";
   output.append(chunk.begin(), chunk.end());
 
-  if(output.find("<cdash") != output.npos)
-    {
+  if (output.find("<cdash") != output.npos) {
     ResponseParser parser;
     parser.Parse(output.c_str());
 
-    if(parser.Status != ResponseParser::STATUS_OK)
-      {
+    if (parser.Status != ResponseParser::STATUS_OK) {
       this->HasErrors = true;
-      cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Submission failed: " <<
-        parser.Message << std::endl);
+      cmCTestLog(this->CTest, HANDLER_OUTPUT,
+                 "   Submission failed: " << parser.Message << std::endl);
       return;
-      }
     }
+  }
   output = cmSystemTools::UpperCase(output);
-  if(output.find("WARNING") != std::string::npos)
-    {
+  if (output.find("WARNING") != std::string::npos) {
     this->HasWarnings = true;
-    }
-  if(output.find("ERROR") != std::string::npos)
-    {
+  }
+  if (output.find("ERROR") != std::string::npos) {
     this->HasErrors = true;
-    }
+  }
 
-  if(this->HasWarnings || this->HasErrors)
-    {
-    cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Server Response:\n" <<
-          cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
-    }
+  if (this->HasWarnings || this->HasErrors) {
+    cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Server Response:\n"
+                 << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
+  }
 }
 
-//----------------------------------------------------------------------------
-bool cmCTestSubmitHandler::TriggerUsingHTTP(
-  const std::set<std::string>& files,
-  const std::string& remoteprefix,
-  const std::string& url)
+bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
+                                            const std::string& remoteprefix,
+                                            const std::string& url)
 {
-  CURL *curl;
+  CURL* curl;
   char error_buffer[1024];
 
   /* In windows, this will init the winsock stuff */
   ::curl_global_init(CURL_GLOBAL_ALL);
 
   cmCTest::SetOfStrings::const_iterator file;
-  for ( file = files.begin(); file != files.end(); ++file )
-    {
+  for (file = files.begin(); file != files.end(); ++file) {
     /* get a curl handle */
     curl = curl_easy_init();
-    if(curl)
-      {
+    if (curl) {
       // Using proxy
-      if ( this->HTTPProxyType > 0 )
-        {
+      if (this->HTTPProxyType > 0) {
         curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
-        switch (this->HTTPProxyType)
-          {
-        case 2:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
-          break;
-        case 3:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
-          break;
-        default:
-          curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
-          if (!this->HTTPProxyAuth.empty())
-            {
-            curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
-              this->HTTPProxyAuth.c_str());
+        switch (this->HTTPProxyType) {
+          case 2:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+            break;
+          case 3:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+            break;
+          default:
+            curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+            if (!this->HTTPProxyAuth.empty()) {
+              curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
+                               this->HTTPProxyAuth.c_str());
             }
-          }
         }
+      }
 
       ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
 
@@ -727,112 +672,105 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
 
       // specify handler for output
       ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
-        cmCTestSubmitHandlerWriteMemoryCallback);
+                         cmCTestSubmitHandlerWriteMemoryCallback);
       ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
-        cmCTestSubmitHandlerCurlDebugCallback);
+                         cmCTestSubmitHandlerCurlDebugCallback);
 
       /* we pass our 'chunk' struct to the callback function */
       cmCTestSubmitHandlerVectorOfChar chunk;
       cmCTestSubmitHandlerVectorOfChar chunkDebug;
-      ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
-      ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+      ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
+      ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
 
-      std::string rfile
-        = remoteprefix + cmSystemTools::GetFilenameName(*file);
+      std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
       std::string ofile = "";
       std::string::iterator kk;
-      for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
-        {
+      for (kk = rfile.begin(); kk < rfile.end(); ++kk) {
         char c = *kk;
         char hexCh[4] = { 0, 0, 0, 0 };
         hexCh[0] = c;
-        switch ( c )
-          {
-        case '+':
-        case '?':
-        case '/':
-        case '\\':
-        case '&':
-        case ' ':
-        case '=':
-        case '%':
-          sprintf(hexCh, "%%%02X", (int)c);
-          ofile.append(hexCh);
-          break;
-        default:
-          ofile.append(hexCh);
-          }
+        switch (c) {
+          case '+':
+          case '?':
+          case '/':
+          case '\\':
+          case '&':
+          case ' ':
+          case '=':
+          case '%':
+            sprintf(hexCh, "%%%02X", (int)c);
+            ofile.append(hexCh);
+            break;
+          default:
+            ofile.append(hexCh);
         }
-      std::string turl
-        = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
-        + "xmlfile=" + ofile;
+      }
+      std::string turl = url +
+        ((url.find('?') == std::string::npos) ? '?' : '&') + "xmlfile=" +
+        ofile;
       *this->LogFile << "Trigger url: " << turl << std::endl;
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "   Trigger url: " << turl << std::endl, this->Quiet);
+                         "   Trigger url: " << turl << std::endl, this->Quiet);
       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 << std::endl);
-        cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error message was: "
-          << error_buffer << std::endl);
+      if (curl_easy_perform(curl)) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE,
+                   "   Error when triggering: " << turl << std::endl);
+        cmCTestLog(this->CTest, ERROR_MESSAGE,
+                   "   Error message was: " << error_buffer << std::endl);
         *this->LogFile << "\tTriggering failed with error: " << error_buffer
                        << std::endl
                        << "   Error message was: " << error_buffer
                        << std::endl;
-        if(!chunk.empty())
-          {
-          *this->LogFile
-            << "   Curl output was: "
-            << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
+        if (!chunk.empty()) {
+          *this->LogFile << "   Curl output was: "
+                         << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+                         << std::endl;
           cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
-                     << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-                     << std::endl);
-          }
+                       << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+                       << std::endl);
+        }
         ::curl_easy_cleanup(curl);
         ::curl_global_cleanup();
         return false;
-        }
+      }
 
-      if (!chunk.empty())
-        {
+      if (!chunk.empty()) {
         cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
-          << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
-          << std::endl, this->Quiet);
-        }
-      if (!chunkDebug.empty())
-        {
-        cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
-          << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size())
-          << "]" << std::endl, this->Quiet);
-        }
+                             << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+                             << "]" << std::endl,
+                           this->Quiet);
+      }
+      if (!chunkDebug.empty()) {
+        cmCTestOptionalLog(
+          this->CTest, DEBUG, "CURL debug output: ["
+            << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+            << std::endl,
+          this->Quiet);
+      }
 
       // always cleanup
       ::curl_easy_cleanup(curl);
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
-        this->Quiet);
-      }
+                         this->Quiet);
     }
+  }
   ::curl_global_cleanup();
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Dart server triggered..."
-    << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                     "   Dart server triggered..." << std::endl, this->Quiet);
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmCTestSubmitHandler::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 cmCTestSubmitHandler::SubmitUsingSCP(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.empty() || localprefix.empty() ||
-    files.empty() || remoteprefix.empty() || url.empty() )
-    {
+  if (scp_command.empty() || localprefix.empty() || files.empty() ||
+      remoteprefix.empty() || url.empty()) {
     return 0;
-    }
+  }
 
   std::vector<const char*> argv;
   argv.push_back(scp_command.c_str()); // Scp command
@@ -842,13 +780,12 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
-  //cmsysProcess_SetTimeout(cp, timeout);
+  // cmsysProcess_SetTimeout(cp, timeout);
 
   int problems = 0;
 
   cmCTest::SetOfStrings::const_iterator file;
-  for ( file = files.begin(); file != files.end(); ++file )
-    {
+  for (file = files.begin(); file != files.end(); ++file) {
     int retVal;
 
     std::string lfname = localprefix;
@@ -858,118 +795,104 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
     argv[1] = lfname.c_str();
     std::string rfname = url + "/" + remoteprefix + *file;
     argv[2] = rfname.c_str();
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
-      << argv[2] << "\"" << std::endl, this->Quiet);
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \""
+                         << argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2]
+                         << "\"" << std::endl,
+                       this->Quiet);
     *this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
-      << argv[2] << "\"" << std::endl;
+                   << argv[2] << "\"" << std::endl;
 
     cmsysProcess_SetCommand(cp, &*argv.begin());
     cmsysProcess_Execute(cp);
     char* data;
     int length;
 
-    while(cmsysProcess_WaitForData(cp, &data, &length, 0))
-      {
+    while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        cmCTestLogWrite(data, length), this->Quiet);
-      }
+                         cmCTestLogWrite(data, length), this->Quiet);
+    }
 
     cmsysProcess_WaitForExit(cp, 0);
 
     int result = cmsysProcess_GetState(cp);
 
-    if(result == cmsysProcess_State_Exited)
-      {
+    if (result == cmsysProcess_State_Exited) {
       retVal = cmsysProcess_GetExitValue(cp);
-      if ( retVal != 0 )
-        {
+      if (retVal != 0) {
         cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-          "\tSCP returned: " << retVal << std::endl, this->Quiet);
+                           "\tSCP returned: " << retVal << std::endl,
+                           this->Quiet);
         *this->LogFile << "\tSCP returned: " << retVal << std::endl;
-        problems ++;
-        }
+        problems++;
       }
-    else if(result == cmsysProcess_State_Exception)
-      {
+    } else if (result == cmsysProcess_State_Exception) {
       retVal = cmsysProcess_GetExitException(cp);
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
-        << retVal << std::endl);
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "\tThere was an exception: " << retVal << std::endl);
       *this->LogFile << "\tThere was an exception: " << retVal << std::endl;
-      problems ++;
-      }
-    else if(result == cmsysProcess_State_Expired)
-      {
+      problems++;
+    } else if (result == cmsysProcess_State_Expired) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
-        << std::endl);
+                   << std::endl);
       *this->LogFile << "\tThere was a timeout" << std::endl;
-      problems ++;
-      }
-    else if(result == cmsysProcess_State_Error)
-      {
+      problems++;
+    } else if (result == cmsysProcess_State_Error) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: "
-        << cmsysProcess_GetErrorString(cp) << std::endl);
+                   << cmsysProcess_GetErrorString(cp) << std::endl);
       *this->LogFile << "\tError executing SCP: "
-        << cmsysProcess_GetErrorString(cp) << std::endl;
-      problems ++;
-      }
+                     << cmsysProcess_GetErrorString(cp) << std::endl;
+      problems++;
     }
+  }
   cmsysProcess_Delete(cp);
-  if ( problems )
-    {
+  if (problems) {
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmCTestSubmitHandler::SubmitUsingCP(
-  const std::string& localprefix,
-  const std::set<std::string>& files,
-  const std::string& remoteprefix,
-  const std::string& destination)
+bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
+                                         const std::set<std::string>& files,
+                                         const std::string& remoteprefix,
+                                         const std::string& destination)
 {
-  if ( localprefix.empty() ||
-    files.empty() || remoteprefix.empty() || destination.empty() )
-    {
+  if (localprefix.empty() || files.empty() || remoteprefix.empty() ||
+      destination.empty()) {
+    /* clang-format off */
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Missing arguments for submit via cp:\n"
                << "\tlocalprefix: " << localprefix << "\n"
                << "\tNumber of files: " << files.size() << "\n"
                << "\tremoteprefix: " << remoteprefix << "\n"
                << "\tdestination: " << destination << std::endl);
+    /* clang-format on */
     return 0;
-    }
+  }
 
   cmCTest::SetOfStrings::const_iterator file;
   bool problems = false;
-  for ( file = files.begin(); file != files.end(); ++file )
-    {
+  for (file = files.begin(); file != files.end(); ++file) {
     std::string lfname = localprefix;
     cmSystemTools::ConvertToUnixSlashes(lfname);
     lfname += "/" + *file;
     std::string rfname = destination + "/" + remoteprefix + *file;
     cmSystemTools::CopyFileAlways(lfname, rfname);
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   Copy file: "
-        << lfname << " to "
-        << rfname << std::endl, this->Quiet);
-    }
+                         << lfname << " to " << rfname << std::endl,
+                       this->Quiet);
+  }
   std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
   cmSystemTools::Touch(tagDoneFile, true);
-  if ( problems )
-    {
+  if (problems) {
     return false;
-    }
+  }
   return true;
 }
 
-
-//----------------------------------------------------------------------------
 #if defined(CTEST_USE_XMLRPC)
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
-  const std::set<std::string>& files,
-  const std::string& remoteprefix,
-  const std::string& 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";
@@ -986,76 +909,72 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
 
   /* Call the famous server at UserLand. */
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Submitting to: "
-    << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl,
-    this->Quiet);
+                       << realURL.c_str() << " (" << remoteprefix.c_str()
+                       << ")" << std::endl,
+                     this->Quiet);
   cmCTest::SetOfStrings::const_iterator file;
-  for ( file = files.begin(); file != files.end(); ++file )
-    {
-    xmlrpc_value *result;
+  for (file = files.begin(); file != files.end(); ++file) {
+    xmlrpc_value* result;
 
     std::string local_file = *file;
-    if ( !cmSystemTools::FileExists(local_file.c_str()) )
-      {
+    if (!cmSystemTools::FileExists(local_file.c_str())) {
       local_file = localprefix + "/" + *file;
-      }
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Submit file: "
-      << local_file.c_str() << std::endl, this->Quiet);
+    }
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Submit file: " << local_file.c_str() << std::endl,
+                       this->Quiet);
     struct stat st;
-    if ( ::stat(local_file.c_str(), &st) )
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "  Cannot find file: "
-        << local_file.c_str() << std::endl);
+    if (::stat(local_file.c_str(), &st)) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "  Cannot find file: " << local_file.c_str() << std::endl);
       return false;
-      }
+    }
 
     // off_t can be bigger than size_t.  fread takes size_t.
     // make sure the file is not too big.
-    if(static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
-       static_cast<off_t>(st.st_size))
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "  File too big: "
-        << local_file.c_str() << std::endl);
+    if (static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
+        static_cast<off_t>(st.st_size)) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "  File too big: " << local_file.c_str() << std::endl);
       return false;
-      }
+    }
     size_t fileSize = static_cast<size_t>(st.st_size);
     FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
-    if ( !fp )
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "  Cannot open file: "
-        << local_file.c_str() << std::endl);
+    if (!fp) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "  Cannot open file: " << local_file.c_str() << std::endl);
       return false;
-      }
+    }
 
-    unsigned char *fileBuffer = new unsigned char[fileSize];
-    if ( fread(fileBuffer, 1, fileSize, fp) != fileSize )
-      {
-      delete [] fileBuffer;
+    unsigned char* fileBuffer = new unsigned char[fileSize];
+    if (fread(fileBuffer, 1, fileSize, fp) != fileSize) {
+      delete[] fileBuffer;
       fclose(fp);
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "  Cannot read file: "
-        << local_file.c_str() << std::endl);
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "  Cannot read file: " << local_file.c_str() << std::endl);
       return false;
-      }
+    }
     fclose(fp);
 
     char remoteCommand[] = "Submit.put";
     char* pRealURL = const_cast<char*>(realURL.c_str());
-    result = xmlrpc_client_call(&env, pRealURL, remoteCommand,
-      "(6)", fileBuffer, (xmlrpc_int32)fileSize );
+    result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)",
+                                fileBuffer, (xmlrpc_int32)fileSize);
 
-    delete [] fileBuffer;
+    delete[] fileBuffer;
 
-    if ( env.fault_occurred )
-      {
+    if (env.fault_occurred) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: "
-        << env.fault_string << " (" << env.fault_code << ")" << std::endl);
+                   << env.fault_string << " (" << env.fault_code << ")"
+                   << std::endl);
       xmlrpc_env_clean(&env);
       xmlrpc_client_cleanup();
       return false;
-      }
+    }
 
     /* Dispose of our result value. */
     xmlrpc_DECREF(result);
-    }
+  }
 
   /* Clean up our error-handling environment. */
   xmlrpc_env_clean(&env);
@@ -1080,40 +999,33 @@ void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
   dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
   url = dropMethod;
   url += "://";
-  if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
-    {
+  if (this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0) {
     url += this->CTest->GetCTestConfiguration("DropSiteUser");
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
-      this->Quiet);
-    if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
-      {
+    cmCTestOptionalLog(
+      this->CTest, HANDLER_OUTPUT,
+      this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), this->Quiet);
+    if (this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0) {
       url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
-        this->Quiet);
-      }
-    url += "@";
+      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", this->Quiet);
     }
+    url += "@";
+  }
   url += this->CTest->GetCTestConfiguration("DropSite") +
     this->CTest->GetCTestConfiguration("DropLocation");
 }
 
-
 int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
                                                 std::string const& typeString)
 {
-  if (file.empty())
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Upload file not specified\n");
+  if (file.empty()) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not specified\n");
     return -1;
-    }
-  if (!cmSystemTools::FileExists(file))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Upload file not found: '" << file << "'\n");
+  }
+  if (!cmSystemTools::FileExists(file)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not found: '"
+                 << file << "'\n");
     return -1;
-    }
+  }
   cmCTestCurl curl(this->CTest);
   std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
   std::vector<std::string> args;
@@ -1124,13 +1036,12 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
   std::string url;
   this->ConstructCDashURL(dropMethod, url);
   std::string::size_type pos = url.find("submit.php?");
-  url = url.substr(0, pos+10);
-  if ( ! (dropMethod == "http" || dropMethod == "https" ) )
-    {
+  url = url.substr(0, pos + 10);
+  if (!(dropMethod == "http" || dropMethod == "https")) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Only http and https are supported for CDASH_UPLOAD\n");
     return -1;
-    }
+  }
   char md5sum[33];
   md5sum[32] = 0;
   cmSystemTools::ComputeFileMD5(file, md5sum);
@@ -1140,75 +1051,68 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
   // a "&subproject=subprojectname" to the first POST.
   cmCTestScriptHandler* ch =
     static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
-  cmake* cm =  ch->GetCMake();
+  cmake* cm = ch->GetCMake();
   const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
   // TODO: Encode values for a URL instead of trusting caller.
   std::ostringstream str;
   str << "project="
       << curl.Escape(this->CTest->GetCTestConfiguration("ProjectName")) << "&";
-  if(subproject)
-    {
+  if (subproject) {
     str << "subproject=" << curl.Escape(subproject) << "&";
-    }
+  }
   str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-"
       << curl.Escape(this->CTest->GetTestModelString()) << "&"
       << "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
       << "build="
       << curl.Escape(this->CTest->GetCTestConfiguration("BuildName")) << "&"
-      << "site="
-      << curl.Escape(this->CTest->GetCTestConfiguration("Site")) << "&"
-      << "track="
-      << curl.Escape(this->CTest->GetTestModelString()) << "&"
+      << "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
+      << "&"
+      << "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
       << "starttime=" << (int)cmSystemTools::GetTime() << "&"
       << "endtime=" << (int)cmSystemTools::GetTime() << "&"
       << "datafilesmd5[0]=" << md5sum << "&"
       << "type=" << curl.Escape(typeString);
   std::string fields = str.str();
-  cmCTestOptionalLog(this->CTest, DEBUG, "fields: " << fields << "\nurl:"
-             << url << "\nfile: " << file << "\n", this->Quiet);
+  cmCTestOptionalLog(this->CTest, DEBUG,
+                     "fields: " << fields << "\nurl:" << url
+                                << "\nfile: " << file << "\n",
+                     this->Quiet);
   std::string response;
-  if(!curl.HttpRequest(url, fields, response))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Error in HttpRequest\n" << response);
+  if (!curl.HttpRequest(url, fields, response)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in HttpRequest\n"
+                 << response);
     return -1;
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "Request upload response: [" << response << "]\n", this->Quiet);
+                     "Request upload response: [" << response << "]\n",
+                     this->Quiet);
   Json::Value json;
   Json::Reader reader;
-  if(!reader.parse(response, json))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "error parsing json string [" << response << "]\n"
-               << reader.getFormattedErrorMessages() << "\n");
+  if (!reader.parse(response, json)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
+                 << response << "]\n"
+                 << reader.getFormattedErrorMessages() << "\n");
     return -1;
-    }
-  if(json["status"].asInt() != 0)
-    {
+  }
+  if (json["status"].asInt() != 0) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Bad status returned from CDash: "
-               << json["status"].asInt());
+               "Bad status returned from CDash: " << json["status"].asInt());
     return -1;
-    }
-  if(json["datafilesmd5"].isArray())
-    {
+  }
+  if (json["datafilesmd5"].isArray()) {
     int datares = json["datafilesmd5"][0].asInt();
-    if(datares == 1)
-      {
+    if (datares == 1) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "File already exists on CDash, skip upload " << file << "\n",
-        this->Quiet);
+                         "File already exists on CDash, skip upload " << file
+                                                                      << "\n",
+                         this->Quiet);
       return 0;
-      }
     }
-  else
-    {
+  } else {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "bad datafilesmd5 value in response "
-               << response << "\n");
+               "bad datafilesmd5 value in response " << response << "\n");
     return -1;
-    }
+  }
 
   std::string upload_as = cmSystemTools::GetFilenameName(file);
   std::ostringstream fstr;
@@ -1216,138 +1120,113 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
        << "md5=" << md5sum << "&"
        << "filename=" << curl.Escape(upload_as) << "&"
        << "buildid=" << json["buildid"].asString();
-  if(!curl.UploadFile(file, url, fstr.str(), response))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "error uploading to CDash. "
-               << file << " " << url << " " << fstr.str());
+  if (!curl.UploadFile(file, url, fstr.str(), response)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "error uploading to CDash. "
+                 << file << " " << url << " " << fstr.str());
     return -1;
-    }
-  if(!reader.parse(response, json))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "error parsing json string [" << response << "]\n"
-               << reader.getFormattedErrorMessages() << "\n");
+  }
+  if (!reader.parse(response, json)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
+                 << response << "]\n"
+                 << reader.getFormattedErrorMessages() << "\n");
     return -1;
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "Upload file response: [" << response << "]\n", this->Quiet );
+                     "Upload file response: [" << response << "]\n",
+                     this->Quiet);
   return 0;
 }
 
-//----------------------------------------------------------------------------
 int cmCTestSubmitHandler::ProcessHandler()
 {
   const char* cdashUploadFile = this->GetOption("CDashUploadFile");
   const char* cdashUploadType = this->GetOption("CDashUploadType");
-  if(cdashUploadFile && cdashUploadType)
-    {
+  if (cdashUploadFile && cdashUploadType) {
     return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
-    }
+  }
   std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
   // cdash does not need to trigger so just return true
-  if(!iscdash.empty())
-    {
+  if (!iscdash.empty()) {
     this->CDash = true;
-    }
+  }
 
-  const std::string &buildDirectory
-    = this->CTest->GetCTestConfiguration("BuildDirectory");
-  if (buildDirectory.empty())
-    {
+  const std::string& buildDirectory =
+    this->CTest->GetCTestConfiguration("BuildDirectory");
+  if (buildDirectory.empty()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot find BuildDirectory  key in the DartConfiguration.tcl"
-      << std::endl);
+               "Cannot find BuildDirectory  key in the DartConfiguration.tcl"
+                 << std::endl);
     return -1;
-    }
+  }
 
-  if ( getenv("HTTP_PROXY") )
-    {
+  if (getenv("HTTP_PROXY")) {
     this->HTTPProxyType = 1;
     this->HTTPProxy = getenv("HTTP_PROXY");
-    if ( getenv("HTTP_PROXY_PORT") )
-      {
+    if (getenv("HTTP_PROXY_PORT")) {
       this->HTTPProxy += ":";
       this->HTTPProxy += getenv("HTTP_PROXY_PORT");
-      }
-    if ( getenv("HTTP_PROXY_TYPE") )
-      {
+    }
+    if (getenv("HTTP_PROXY_TYPE")) {
       std::string type = getenv("HTTP_PROXY_TYPE");
       // HTTP/SOCKS4/SOCKS5
-      if ( type == "HTTP" )
-        {
+      if (type == "HTTP") {
         this->HTTPProxyType = 1;
-        }
-      else if ( type == "SOCKS4" )
-        {
+      } else if (type == "SOCKS4") {
         this->HTTPProxyType = 2;
-        }
-      else if ( type == "SOCKS5" )
-        {
+      } else if (type == "SOCKS5") {
         this->HTTPProxyType = 3;
-        }
       }
-    if ( getenv("HTTP_PROXY_USER") )
-      {
+    }
+    if (getenv("HTTP_PROXY_USER")) {
       this->HTTPProxyAuth = getenv("HTTP_PROXY_USER");
-      }
-    if ( getenv("HTTP_PROXY_PASSWD") )
-      {
+    }
+    if (getenv("HTTP_PROXY_PASSWD")) {
       this->HTTPProxyAuth += ":";
       this->HTTPProxyAuth += getenv("HTTP_PROXY_PASSWD");
-      }
     }
+  }
 
-  if ( getenv("FTP_PROXY") )
-    {
+  if (getenv("FTP_PROXY")) {
     this->FTPProxyType = 1;
     this->FTPProxy = getenv("FTP_PROXY");
-    if ( getenv("FTP_PROXY_PORT") )
-      {
+    if (getenv("FTP_PROXY_PORT")) {
       this->FTPProxy += ":";
       this->FTPProxy += getenv("FTP_PROXY_PORT");
-      }
-    if ( getenv("FTP_PROXY_TYPE") )
-      {
+    }
+    if (getenv("FTP_PROXY_TYPE")) {
       std::string type = getenv("FTP_PROXY_TYPE");
       // HTTP/SOCKS4/SOCKS5
-      if ( type == "HTTP" )
-        {
+      if (type == "HTTP") {
         this->FTPProxyType = 1;
-        }
-      else if ( type == "SOCKS4" )
-        {
+      } else if (type == "SOCKS4") {
         this->FTPProxyType = 2;
-        }
-      else if ( type == "SOCKS5" )
-        {
+      } else if (type == "SOCKS5") {
         this->FTPProxyType = 3;
-        }
       }
     }
+  }
 
-  if (!this->HTTPProxy.empty())
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Use HTTP Proxy: "
-      << this->HTTPProxy << std::endl, this->Quiet);
-    }
-  if (!this->FTPProxy.empty())
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Use FTP Proxy: "
-      << this->FTPProxy << std::endl, this->Quiet);
-    }
+  if (!this->HTTPProxy.empty()) {
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Use HTTP Proxy: " << this->HTTPProxy << std::endl,
+                       this->Quiet);
+  }
+  if (!this->FTPProxy.empty()) {
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Use FTP Proxy: " << this->FTPProxy << std::endl,
+                       this->Quiet);
+  }
   cmGeneratedFileStream ofs;
   this->StartLogFile("Submit", ofs);
 
   cmCTest::SetOfStrings files;
   std::string prefix = this->GetSubmitResultsPrefix();
 
-  if (!this->Files.empty())
-    {
+  if (!this->Files.empty()) {
     // Submit the explicitly selected files:
     //
     files.insert(this->Files.begin(), this->Files.end());
-    }
+  }
 
   // Add to the list of files to submit from any selected, existing parts:
   //
@@ -1359,244 +1238,225 @@ int cmCTestSubmitHandler::ProcessHandler()
   this->CTest->AddIfExists(cmCTest::PartConfigure, "Configure.xml");
   this->CTest->AddIfExists(cmCTest::PartBuild, "Build.xml");
   this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml");
-  if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml"))
-    {
+  if (this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml")) {
     std::vector<std::string> gfiles;
-    std::string gpath
-      = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
+    std::string gpath =
+      buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
     std::string::size_type glen = gpath.size() + 1;
     gpath = gpath + "/CoverageLog*";
-    cmCTestOptionalLog(this->CTest, DEBUG, "Globbing for: " << gpath
-      << std::endl, this->Quiet);
-    if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
-      {
+    cmCTestOptionalLog(this->CTest, DEBUG,
+                       "Globbing for: " << gpath << std::endl, this->Quiet);
+    if (cmSystemTools::SimpleGlob(gpath, gfiles, 1)) {
       size_t cc;
-      for ( cc = 0; cc < gfiles.size(); cc ++ )
-        {
+      for (cc = 0; cc < gfiles.size(); cc++) {
         gfiles[cc] = gfiles[cc].substr(glen);
-        cmCTestOptionalLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc]
-          << std::endl, this->Quiet);
+        cmCTestOptionalLog(this->CTest, DEBUG,
+                           "Glob file: " << gfiles[cc] << std::endl,
+                           this->Quiet);
         this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
-        }
       }
-    else
-      {
+    } else {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl);
-      }
     }
+  }
   this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis.xml");
   this->CTest->AddIfExists(cmCTest::PartMemCheck, "Purify.xml");
   this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml");
   this->CTest->AddIfExists(cmCTest::PartUpload, "Upload.xml");
 
   // Query parts for files to submit.
-  for(cmCTest::Part p = cmCTest::PartStart;
-      p != cmCTest::PartCount; p = cmCTest::Part(p+1))
-    {
+  for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
+       p = cmCTest::Part(p + 1)) {
     // Skip parts we are not submitting.
-    if(!this->SubmitPart[p])
-      {
+    if (!this->SubmitPart[p]) {
       continue;
-      }
+    }
 
     // Submit files from this part.
     std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p);
     files.insert(pfiles.begin(), pfiles.end());
-    }
+  }
 
-  if ( ofs )
-    {
+  if (ofs) {
     ofs << "Upload files:" << std::endl;
     int cnt = 0;
     cmCTest::SetOfStrings::iterator it;
-    for ( it = files.begin(); it != files.end(); ++ it )
-      {
+    for (it = files.begin(); it != files.end(); ++it) {
       ofs << cnt << "\t" << *it << std::endl;
-      cnt ++;
-      }
+      cnt++;
     }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
-    << this->CTest->GetCTestConfiguration("DropMethod") << ")"
-    << std::endl, this->Quiet);
+                       << this->CTest->GetCTestConfiguration("DropMethod")
+                       << ")" << std::endl,
+                     this->Quiet);
   const char* specificTrack = this->CTest->GetSpecificTrack();
-  if ( specificTrack )
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Send to track: "
-      << specificTrack << std::endl, this->Quiet);
-    }
+  if (specificTrack) {
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Send to track: " << specificTrack << std::endl,
+                       this->Quiet);
+  }
   this->SetLogFile(&ofs);
 
   std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
 
-  if ( dropMethod == "" || dropMethod == "ftp" )
-    {
+  if (dropMethod == "" || dropMethod == "ftp") {
     ofs << "Using drop method: FTP" << std::endl;
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "   Using FTP submit method" << std::endl << "   Drop site: ftp://",
-      this->Quiet);
+                       "   Using FTP submit method" << std::endl
+                                                    << "   Drop site: ftp://",
+                       this->Quiet);
     std::string url = "ftp://";
     url += cmCTest::MakeURLSafe(
-      this->CTest->GetCTestConfiguration("DropSiteUser")) + ":" +
-      cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration(
-          "DropSitePassword")) + "@" +
-      this->CTest->GetCTestConfiguration("DropSite") +
-      cmCTest::MakeURLSafe(
-        this->CTest->GetCTestConfiguration("DropLocation"));
-    if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        this->CTest->GetCTestConfiguration(
-          "DropSiteUser").c_str(), this->Quiet);
-      if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
-        {
+             this->CTest->GetCTestConfiguration("DropSiteUser")) +
+      ":" + cmCTest::MakeURLSafe(
+              this->CTest->GetCTestConfiguration("DropSitePassword")) +
+      "@" + this->CTest->GetCTestConfiguration("DropSite") +
+      cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration("DropLocation"));
+    if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
+      cmCTestOptionalLog(
+        this->CTest, HANDLER_OUTPUT,
+        this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
+        this->Quiet);
+      if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
         cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
-          this->Quiet);
-        }
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
+                           this->Quiet);
       }
+      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
+    }
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      this->CTest->GetCTestConfiguration("DropSite")
-      << this->CTest->GetCTestConfiguration("DropLocation") << std::endl,
-      this->Quiet);
-    if ( !this->SubmitUsingFTP(buildDirectory + "/Testing/"
-        + this->CTest->GetCurrentTag(),
-        files, prefix, url) )
-      {
+                       this->CTest->GetCTestConfiguration("DropSite")
+                         << this->CTest->GetCTestConfiguration("DropLocation")
+                         << std::endl,
+                       this->Quiet);
+    if (!this->SubmitUsingFTP(buildDirectory + "/Testing/" +
+                                this->CTest->GetCurrentTag(),
+                              files, prefix, url)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "   Problems when submitting via FTP"
-        << std::endl);
+                 "   Problems when submitting via FTP" << std::endl);
       ofs << "   Problems when submitting via FTP" << std::endl;
       return -1;
-      }
-    if(!this->CDash)
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-                 "   Using HTTP trigger method"
-                 << std::endl
-                 << "   Trigger site: "
-                 << this->CTest->GetCTestConfiguration("TriggerSite")
-                 << std::endl, this->Quiet);
-      if ( !this->
-           TriggerUsingHTTP(files, prefix,
-                            this->CTest->GetCTestConfiguration("TriggerSite")))
-        {
+    }
+    if (!this->CDash) {
+      cmCTestOptionalLog(
+        this->CTest, HANDLER_OUTPUT, "   Using HTTP trigger method"
+          << std::endl
+          << "   Trigger site: "
+          << this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
+        this->Quiet);
+      if (!this->TriggerUsingHTTP(
+            files, prefix,
+            this->CTest->GetCTestConfiguration("TriggerSite"))) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
                    "   Problems when triggering via HTTP" << std::endl);
         ofs << "   Problems when triggering via HTTP" << std::endl;
         return -1;
-        }
+      }
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        "   Submission successful" << std::endl, this->Quiet);
+                         "   Submission successful" << std::endl, this->Quiet);
       ofs << "   Submission successful" << std::endl;
       return 0;
-      }
     }
-  else if ( dropMethod == "http" || dropMethod == "https" )
-    {
+  } else if (dropMethod == "http" || dropMethod == "https") {
     std::string url = dropMethod;
     url += "://";
     ofs << "Using drop method: " << dropMethod << std::endl;
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "   Using HTTP submit method" << std::endl << "   Drop site:" << url,
-      this->Quiet);
-     if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
-      {
+                       "   Using HTTP submit method" << std::endl
+                                                     << "   Drop site:" << url,
+                       this->Quiet);
+    if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
       url += this->CTest->GetCTestConfiguration("DropSiteUser");
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+      cmCTestOptionalLog(
+        this->CTest, HANDLER_OUTPUT,
         this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
         this->Quiet);
-      if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
-        {
+      if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
         url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
         cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
-          this->Quiet);
-        }
+                           this->Quiet);
+      }
       url += "@";
       cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
-      }
+    }
     url += this->CTest->GetCTestConfiguration("DropSite") +
       this->CTest->GetCTestConfiguration("DropLocation");
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      this->CTest->GetCTestConfiguration("DropSite")
-      << this->CTest->GetCTestConfiguration("DropLocation") << std::endl,
-      this->Quiet);
-    if ( !this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
-        this->CTest->GetCurrentTag(), files, prefix, url) )
-      {
+                       this->CTest->GetCTestConfiguration("DropSite")
+                         << this->CTest->GetCTestConfiguration("DropLocation")
+                         << std::endl,
+                       this->Quiet);
+    if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
+                                 this->CTest->GetCurrentTag(),
+                               files, prefix, url)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "   Problems when submitting via HTTP" << std::endl);
+                 "   Problems when submitting via HTTP" << std::endl);
       ofs << "   Problems when submitting via HTTP" << std::endl;
       return -1;
-      }
-    if(!this->CDash)
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        "   Using HTTP trigger method" << std::endl << "   Trigger site: "
-                 << this->CTest->GetCTestConfiguration("TriggerSite")
-                 << std::endl, this->Quiet);
-      if ( !this->
-           TriggerUsingHTTP(files, prefix,
-                            this->CTest->GetCTestConfiguration("TriggerSite")))
-        {
+    }
+    if (!this->CDash) {
+      cmCTestOptionalLog(
+        this->CTest, HANDLER_OUTPUT, "   Using HTTP trigger method"
+          << std::endl
+          << "   Trigger site: "
+          << this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
+        this->Quiet);
+      if (!this->TriggerUsingHTTP(
+            files, prefix,
+            this->CTest->GetCTestConfiguration("TriggerSite"))) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
                    "   Problems when triggering via HTTP" << std::endl);
         ofs << "   Problems when triggering via HTTP" << std::endl;
         return -1;
-        }
       }
-    if(this->HasErrors)
-      {
+    }
+    if (this->HasErrors) {
       cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Errors occurred during "
-        "submission." << std::endl);
+                                              "submission."
+                   << std::endl);
       ofs << "   Errors occurred during submission. " << std::endl;
-      }
-    else
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-        "   Submission successful" <<
-        (this->HasWarnings ? ", with warnings." : "") << std::endl,
+    } else {
+      cmCTestOptionalLog(
+        this->CTest, HANDLER_OUTPUT, "   Submission successful"
+          << (this->HasWarnings ? ", with warnings." : "") << std::endl,
         this->Quiet);
-      ofs << "   Submission successful" <<
-        (this->HasWarnings ? ", with warnings." : "") << std::endl;
-      }
+      ofs << "   Submission successful"
+          << (this->HasWarnings ? ", with warnings." : "") << std::endl;
+    }
 
     return 0;
-    }
-  else if ( dropMethod == "xmlrpc" )
-    {
+  } else if (dropMethod == "xmlrpc") {
 #if defined(CTEST_USE_XMLRPC)
     ofs << "Using drop method: XML-RPC" << std::endl;
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "   Using XML-RPC submit method" << std::endl, this->Quiet);
+                       "   Using XML-RPC submit method" << std::endl,
+                       this->Quiet);
     std::string url = this->CTest->GetCTestConfiguration("DropSite");
     prefix = this->CTest->GetCTestConfiguration("DropLocation");
-    if ( !this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
-        this->CTest->GetCurrentTag(), files, prefix, url) )
-      {
+    if (!this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
+                                   this->CTest->GetCurrentTag(),
+                                 files, prefix, url)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "   Problems when submitting via XML-RPC" << std::endl);
+                 "   Problems when submitting via XML-RPC" << std::endl);
       ofs << "   Problems when submitting via XML-RPC" << std::endl;
       return -1;
-      }
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Submission successful"
-      << std::endl, this->Quiet);
+    }
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Submission successful" << std::endl, this->Quiet);
     ofs << "   Submission successful" << std::endl;
     return 0;
 #else
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "   Submission method \"xmlrpc\" not compiled into CTest!"
-               << std::endl);
+                 << std::endl);
     return -1;
 #endif
-    }
-  else if ( dropMethod == "scp" )
-    {
+  } else if (dropMethod == "scp") {
     std::string url;
     std::string oldWorkingDirectory;
-    if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
-      {
+    if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
       url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
-      }
+    }
     url += this->CTest->GetCTestConfiguration("DropSite") + ":" +
       this->CTest->GetCTestConfiguration("DropLocation");
 
@@ -1605,87 +1465,72 @@ int cmCTestSubmitHandler::ProcessHandler()
     oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
     cmSystemTools::ChangeDirectory(buildDirectory);
 
-    if ( !this->SubmitUsingSCP(
-        this->CTest->GetCTestConfiguration("ScpCommand"),
-        "Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) )
-      {
+    if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"),
+                              "Testing/" + this->CTest->GetCurrentTag(), files,
+                              prefix, url)) {
       cmSystemTools::ChangeDirectory(oldWorkingDirectory);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "   Problems when submitting via SCP"
-        << std::endl);
+                 "   Problems when submitting via SCP" << std::endl);
       ofs << "   Problems when submitting via SCP" << std::endl;
       return -1;
-      }
+    }
     cmSystemTools::ChangeDirectory(oldWorkingDirectory);
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Submission successful"
-      << std::endl, this->Quiet);
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Submission successful" << std::endl, this->Quiet);
     ofs << "   Submission successful" << std::endl;
     return 0;
-    }
-  else if ( dropMethod == "cp" )
-    {
-    std::string location
-      = this->CTest->GetCTestConfiguration("DropLocation");
-
+  } else if (dropMethod == "cp") {
+    std::string location = this->CTest->GetCTestConfiguration("DropLocation");
 
     // change to the build directory so that we can uses a relative path
     // on windows since scp dosn't support "c:" a drive in the path
-    std::string
-      oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
+    std::string oldWorkingDirectory =
+      cmSystemTools::GetCurrentWorkingDirectory();
     cmSystemTools::ChangeDirectory(buildDirectory);
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "   Change directory: " << buildDirectory << std::endl, this->Quiet);
-
-    if ( !this->SubmitUsingCP(
-           "Testing/"+this->CTest->GetCurrentTag(),
-           files,
-           prefix,
-           location) )
-      {
+                       "   Change directory: " << buildDirectory << std::endl,
+                       this->Quiet);
+
+    if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files,
+                             prefix, location)) {
       cmSystemTools::ChangeDirectory(oldWorkingDirectory);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "   Problems when submitting via CP"
-        << std::endl);
+                 "   Problems when submitting via CP" << std::endl);
       ofs << "   Problems when submitting via cp" << std::endl;
       return -1;
-      }
+    }
     cmSystemTools::ChangeDirectory(oldWorkingDirectory);
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Submission successful"
-      << std::endl, this->Quiet);
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+                       "   Submission successful" << std::endl, this->Quiet);
     ofs << "   Submission successful" << std::endl;
     return 0;
-    }
+  }
 
   cmCTestLog(this->CTest, ERROR_MESSAGE, "   Unknown submission method: \""
-    << dropMethod << "\"" << std::endl);
+               << dropMethod << "\"" << std::endl);
   return -1;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestSubmitHandler::GetSubmitResultsPrefix()
 {
-  std::string buildname = cmCTest::SafeBuildIdField(
-    this->CTest->GetCTestConfiguration("BuildName"));
-  std::string name = this->CTest->GetCTestConfiguration("Site") +
-    "___" + buildname +
-    "___" + this->CTest->GetCurrentTag() + "-" +
+  std::string buildname =
+    cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
+  std::string name = this->CTest->GetCTestConfiguration("Site") + "___" +
+    buildname + "___" + this->CTest->GetCurrentTag() + "-" +
     this->CTest->GetTestModelString() + "___XML___";
   return name;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
 {
   // Check whether each part is selected.
-  for(cmCTest::Part p = cmCTest::PartStart;
-      p != cmCTest::PartCount; p = cmCTest::Part(p+1))
-    {
+  for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
+       p = cmCTest::Part(p + 1)) {
     this->SubmitPart[p] =
       (std::set<cmCTest::Part>::const_iterator(parts.find(p)) != parts.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
 {
   this->Files.insert(files.begin(), files.end());
diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h
index f9cd894..87fa142 100644
--- a/Source/CTest/cmCTestSubmitHandler.h
+++ b/Source/CTest/cmCTestSubmitHandler.h
@@ -54,8 +54,7 @@ private:
    */
   bool SubmitUsingFTP(const std::string& localprefix,
                       const std::set<std::string>& files,
-                      const std::string& remoteprefix,
-                      const std::string& url);
+                      const std::string& remoteprefix, const std::string& url);
   bool SubmitUsingHTTP(const std::string& localprefix,
                        const std::set<std::string>& files,
                        const std::string& remoteprefix,
@@ -63,22 +62,20 @@ private:
   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);
+                      const std::string& remoteprefix, const std::string& url);
 
-  bool SubmitUsingCP( const std::string& localprefix,
-                      const std::set<std::string>& files,
-                      const std::string& remoteprefix,
-                      const std::string& 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<std::string>& files,
                         const std::string& remoteprefix,
                         const std::string& url);
 
   bool SubmitUsingXMLRPC(const std::string& localprefix,
-                       const std::set<std::string>& files,
-                       const std::string& remoteprefix,
-                       const std::string& url);
+                         const std::set<std::string>& files,
+                         const std::string& remoteprefix,
+                         const std::string& url);
 
   typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
 
@@ -86,12 +83,12 @@ private:
 
   std::string GetSubmitResultsPrefix();
 
-  class         ResponseParser;
-  std::string   HTTPProxy;
-  int           HTTPProxyType;
-  std::string   HTTPProxyAuth;
-  std::string   FTPProxy;
-  int           FTPProxyType;
+  class ResponseParser;
+  std::string HTTPProxy;
+  int HTTPProxyType;
+  std::string HTTPProxyAuth;
+  std::string FTPProxy;
+  int FTPProxyType;
   std::ostream* LogFile;
   bool SubmitPart[cmCTest::PartCount];
   bool CDash;
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index b7d8318..7b437c6 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -37,103 +37,78 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
     this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
 
   double timeout = this->CTest->GetTimeOut();
-  if ( ctestTimeout )
-    {
+  if (ctestTimeout) {
     timeout = atof(ctestTimeout);
-    }
-  else
-    {
-    if ( timeout <= 0 )
-      {
+  } else {
+    if (timeout <= 0) {
       // By default use timeout of 10 minutes
       timeout = 600;
-      }
     }
+  }
   this->CTest->SetTimeOut(timeout);
   cmCTestGenericHandler* handler = this->InitializeActualHandler();
-  if ( this->Values[ctt_START] || this->Values[ctt_END] ||
-    this->Values[ctt_STRIDE] )
-    {
+  if (this->Values[ctt_START] || this->Values[ctt_END] ||
+      this->Values[ctt_STRIDE]) {
     std::ostringstream testsToRunString;
-    if ( this->Values[ctt_START] )
-      {
+    if (this->Values[ctt_START]) {
       testsToRunString << this->Values[ctt_START];
-      }
+    }
     testsToRunString << ",";
-    if ( this->Values[ctt_END] )
-      {
+    if (this->Values[ctt_END]) {
       testsToRunString << this->Values[ctt_END];
-      }
+    }
     testsToRunString << ",";
-    if ( this->Values[ctt_STRIDE] )
-      {
+    if (this->Values[ctt_STRIDE]) {
       testsToRunString << this->Values[ctt_STRIDE];
-      }
-    handler->SetOption("TestsToRunInformation",
-      testsToRunString.str().c_str());
     }
-  if(this->Values[ctt_EXCLUDE])
-    {
+    handler->SetOption("TestsToRunInformation",
+                       testsToRunString.str().c_str());
+  }
+  if (this->Values[ctt_EXCLUDE]) {
     handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
-    }
-  if(this->Values[ctt_INCLUDE])
-    {
+  }
+  if (this->Values[ctt_INCLUDE]) {
     handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
-    }
-  if(this->Values[ctt_EXCLUDE_LABEL])
-    {
+  }
+  if (this->Values[ctt_EXCLUDE_LABEL]) {
     handler->SetOption("ExcludeLabelRegularExpression",
                        this->Values[ctt_EXCLUDE_LABEL]);
-    }
-  if(this->Values[ctt_INCLUDE_LABEL])
-    {
+  }
+  if (this->Values[ctt_INCLUDE_LABEL]) {
     handler->SetOption("LabelRegularExpression",
                        this->Values[ctt_INCLUDE_LABEL]);
-    }
-  if(this->Values[ctt_PARALLEL_LEVEL])
-    {
-    handler->SetOption("ParallelLevel",
-                       this->Values[ctt_PARALLEL_LEVEL]);
-    }
-  if(this->Values[ctt_SCHEDULE_RANDOM])
-    {
-    handler->SetOption("ScheduleRandom",
-                       this->Values[ctt_SCHEDULE_RANDOM]);
-    }
-  if(this->Values[ctt_STOP_TIME])
-    {
+  }
+  if (this->Values[ctt_PARALLEL_LEVEL]) {
+    handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]);
+  }
+  if (this->Values[ctt_SCHEDULE_RANDOM]) {
+    handler->SetOption("ScheduleRandom", this->Values[ctt_SCHEDULE_RANDOM]);
+  }
+  if (this->Values[ctt_STOP_TIME]) {
     this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
-    }
+  }
 
   // Test load is determined by: TEST_LOAD argument,
   // or CTEST_TEST_LOAD script variable, or ctest --test-load
   // command line argument... in that order.
   unsigned long testLoad;
-  const char* ctestTestLoad
-    = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
-  if(this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD])
-    {
-    if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD], &testLoad))
-      {
+  const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
+  if (this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD]) {
+    if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD],
+                                      &testLoad)) {
       testLoad = 0;
       cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : "
-          << this->Values[ctt_TEST_LOAD] << std::endl);
-      }
+                   << this->Values[ctt_TEST_LOAD] << std::endl);
     }
-  else if(ctestTestLoad && *ctestTestLoad)
-    {
-    if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad))
-      {
+  } else if (ctestTestLoad && *ctestTestLoad) {
+    if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad)) {
       testLoad = 0;
-      cmCTestLog(this->CTest, WARNING,
-        "Invalid value for 'CTEST_TEST_LOAD' : " <<
-        ctestTestLoad << std::endl);
-      }
+      cmCTestLog(this->CTest, WARNING, "Invalid value for 'CTEST_TEST_LOAD' : "
+                   << ctestTestLoad << std::endl);
     }
-  else
-    {
+  } else {
     testLoad = this->CTest->GetTestLoad();
-    }
+  }
   handler->SetTestLoad(testLoad);
 
   handler->SetQuiet(this->Quiet);
diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h
index 0dfca97..212213e 100644
--- a/Source/CTest/cmCTestTestCommand.h
+++ b/Source/CTest/cmCTestTestCommand.h
@@ -22,24 +22,23 @@
 class cmCTestTestCommand : public cmCTestHandlerCommand
 {
 public:
-
   cmCTestTestCommand();
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestTestCommand* ni = new cmCTestTestCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_test";}
+  virtual std::string GetName() const { return "ctest_test"; }
 
   cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand);
 
@@ -47,7 +46,8 @@ protected:
   virtual cmCTestGenericHandler* InitializeActualHandler();
   cmCTestGenericHandler* InitializeHandler();
 
-  enum {
+  enum
+  {
     ctt_BUILD = ct_LAST,
     ctt_RETURN_VALUE,
     ctt_START,
@@ -65,5 +65,4 @@ protected:
   };
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index b6a4819..20ef693 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -11,31 +11,31 @@
 ============================================================================*/
 
 #include "cmCTestTestHandler.h"
-#include "cmCTestMultiProcessHandler.h"
-#include "cmCTestBatchTestHandler.h"
+
 #include "cmCTest.h"
+#include "cmCTestBatchTestHandler.h"
+#include "cmCTestMultiProcessHandler.h"
 #include "cmCTestRunTest.h"
-#include "cmake.h"
+#include "cmCommand.h"
 #include "cmGeneratedFileStream.h"
-#include <cmsys/Process.h>
-#include <cmsys/RegularExpression.hxx>
-#include <cmsys/Base64.h>
-#include <cmsys/Directory.hxx>
-#include <cmsys/FStream.hxx>
-#include "cmMakefile.h"
 #include "cmGlobalGenerator.h"
-#include "cmCommand.h"
+#include "cmMakefile.h"
 #include "cmSystemTools.h"
 #include "cmXMLWriter.h"
 #include "cm_utf8.h"
+#include "cmake.h"
+#include <cmsys/Base64.h>
+#include <cmsys/Directory.hxx>
+#include <cmsys/FStream.hxx>
+#include <cmsys/Process.h>
+#include <cmsys/RegularExpression.hxx>
 
-#include <stdlib.h>
-#include <math.h>
 #include <float.h>
+#include <math.h>
+#include <stdlib.h>
 
 #include <set>
 
-//----------------------------------------------------------------------
 class cmCTestSubdirCommand : public cmCommand
 {
 public:
@@ -43,94 +43,80 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestSubdirCommand* c = new cmCTestSubdirCommand;
     c->TestHandler = this->TestHandler;
     return c;
-    }
+  }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &);
+                           cmExecutionStatus&);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "subdirs";}
+  virtual std::string GetName() const { return "subdirs"; }
 
   cmTypeMacro(cmCTestSubdirCommand, cmCommand);
 
   cmCTestTestHandler* TestHandler;
 };
 
-//----------------------------------------------------------------------
-bool cmCTestSubdirCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::vector<std::string>::const_iterator it;
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  for ( it = args.begin(); it != args.end(); ++ it )
-    {
+  for (it = args.begin(); it != args.end(); ++it) {
     std::string fname;
 
-    if(cmSystemTools::FileIsFullPath(it->c_str()))
-      {
+    if (cmSystemTools::FileIsFullPath(it->c_str())) {
       fname = *it;
-      }
-    else
-      {
+    } else {
       fname = cwd;
       fname += "/";
       fname += *it;
-      }
+    }
 
-    if ( !cmSystemTools::FileIsDirectory(fname) )
-      {
+    if (!cmSystemTools::FileIsDirectory(fname)) {
       // No subdirectory? So what...
       continue;
-      }
+    }
     cmSystemTools::ChangeDirectory(fname);
     const char* testFilename;
-    if( cmSystemTools::FileExists("CTestTestfile.cmake") )
-      {
+    if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
       // does the CTestTestfile.cmake exist ?
       testFilename = "CTestTestfile.cmake";
-      }
-    else if( cmSystemTools::FileExists("DartTestfile.txt") )
-      {
+    } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
       // does the DartTestfile.txt exist ?
       testFilename = "DartTestfile.txt";
-      }
-    else
-      {
+    } else {
       // No CTestTestfile? Who cares...
       continue;
-      }
+    }
     fname += "/";
     fname += testFilename;
     bool readit = this->Makefile->ReadDependentFile(fname.c_str());
     cmSystemTools::ChangeDirectory(cwd);
-    if(!readit)
-      {
+    if (!readit) {
       std::string m = "Could not find include file: ";
       m += fname;
       this->SetError(m);
       return false;
-      }
     }
+  }
   cmSystemTools::ChangeDirectory(cwd);
   return true;
 }
 
-//----------------------------------------------------------------------
 class cmCTestAddSubdirectoryCommand : public cmCommand
 {
 public:
@@ -138,38 +124,36 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestAddSubdirectoryCommand* c = new cmCTestAddSubdirectoryCommand;
     c->TestHandler = this->TestHandler;
     return c;
-    }
+  }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &);
+                           cmExecutionStatus&);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_subdirectory";}
+  virtual std::string GetName() const { return "add_subdirectory"; }
 
   cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand);
 
   cmCTestTestHandler* TestHandler;
 };
 
-//----------------------------------------------------------------------
-bool cmCTestAddSubdirectoryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestAddSubdirectoryCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
   cmSystemTools::ChangeDirectory(cwd);
@@ -177,44 +161,36 @@ bool cmCTestAddSubdirectoryCommand
   fname += "/";
   fname += args[0];
 
-  if ( !cmSystemTools::FileExists(fname.c_str()) )
-    {
+  if (!cmSystemTools::FileExists(fname.c_str())) {
     // No subdirectory? So what...
     return true;
-    }
+  }
   cmSystemTools::ChangeDirectory(fname);
   const char* testFilename;
-  if( cmSystemTools::FileExists("CTestTestfile.cmake") )
-    {
+  if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
     // does the CTestTestfile.cmake exist ?
     testFilename = "CTestTestfile.cmake";
-    }
-  else if( cmSystemTools::FileExists("DartTestfile.txt") )
-    {
+  } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
     // does the DartTestfile.txt exist ?
     testFilename = "DartTestfile.txt";
-    }
-  else
-    {
+  } else {
     // No CTestTestfile? Who cares...
     cmSystemTools::ChangeDirectory(cwd);
     return true;
-    }
+  }
   fname += "/";
   fname += testFilename;
   bool readit = this->Makefile->ReadDependentFile(fname.c_str());
   cmSystemTools::ChangeDirectory(cwd);
-  if(!readit)
-    {
+  if (!readit) {
     std::string m = "Could not find include file: ";
     m += fname;
     this->SetError(m);
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 class cmCTestAddTestCommand : public cmCommand
 {
 public:
@@ -222,42 +198,39 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestAddTestCommand* c = new cmCTestAddTestCommand;
     c->TestHandler = this->TestHandler;
     return c;
-    }
+  }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &);
+                           cmExecutionStatus&);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_test";}
+  virtual std::string GetName() const { return "add_test"; }
 
   cmTypeMacro(cmCTestAddTestCommand, cmCommand);
 
   cmCTestTestHandler* TestHandler;
 };
 
-//----------------------------------------------------------------------
-bool cmCTestAddTestCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestAddTestCommand::InitialPass(std::vector<std::string> const& args,
+                                        cmExecutionStatus&)
 {
-  if ( args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   return this->TestHandler->AddTest(args);
 }
 
-//----------------------------------------------------------------------
 class cmCTestSetTestsPropertiesCommand : public cmCommand
 {
 public:
@@ -265,124 +238,98 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
-    cmCTestSetTestsPropertiesCommand* c
-      = new cmCTestSetTestsPropertiesCommand;
+  {
+    cmCTestSetTestsPropertiesCommand* c = new cmCTestSetTestsPropertiesCommand;
     c->TestHandler = this->TestHandler;
     return c;
-    }
+  }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
   */
   virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &);
+                           cmExecutionStatus&);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "set_tests_properties";}
+  virtual std::string GetName() const { return "set_tests_properties"; }
 
   cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand);
 
   cmCTestTestHandler* TestHandler;
 };
 
-//----------------------------------------------------------------------
-bool cmCTestSetTestsPropertiesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCTestSetTestsPropertiesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   return this->TestHandler->SetTestsProperties(args);
 }
 
-//----------------------------------------------------------------------
 // get the next number in a string with numbers separated by ,
 // pos is the start of the search and pos2 is the end of the search
 // pos becomes pos2 after a call to GetNextNumber.
 // -1 is returned at the end of the list.
-inline int GetNextNumber(std::string const& in,
-                         int& val,
+inline int GetNextNumber(std::string const& in, int& val,
                          std::string::size_type& pos,
                          std::string::size_type& pos2)
 {
   pos2 = in.find(',', pos);
-  if(pos2 != in.npos)
-    {
-    if(pos2-pos == 0)
-      {
+  if (pos2 != in.npos) {
+    if (pos2 - pos == 0) {
       val = -1;
-      }
-    else
-      {
-      val = atoi(in.substr(pos, pos2-pos).c_str());
-      }
-    pos = pos2+1;
+    } else {
+      val = atoi(in.substr(pos, pos2 - pos).c_str());
+    }
+    pos = pos2 + 1;
     return 1;
+  } else {
+    if (in.size() - pos == 0) {
+      val = -1;
+    } else {
+      val = atoi(in.substr(pos, in.size() - pos).c_str());
     }
-  else
-    {
-    if(in.size()-pos == 0)
-      {
-       val = -1;
-      }
-    else
-      {
-      val = atoi(in.substr(pos, in.size()-pos).c_str());
-      }
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 // get the next number in a string with numbers separated by ,
 // pos is the start of the search and pos2 is the end of the search
 // pos becomes pos2 after a call to GetNextNumber.
 // -1 is returned at the end of the list.
-inline int GetNextRealNumber(std::string const& in,
-                             double& val,
+inline int GetNextRealNumber(std::string const& in, double& val,
                              std::string::size_type& pos,
                              std::string::size_type& pos2)
 {
   pos2 = in.find(',', pos);
-  if(pos2 != in.npos)
-    {
-    if(pos2-pos == 0)
-      {
+  if (pos2 != in.npos) {
+    if (pos2 - pos == 0) {
       val = -1;
-      }
-    else
-      {
-      val = atof(in.substr(pos, pos2-pos).c_str());
-      }
-    pos = pos2+1;
+    } else {
+      val = atof(in.substr(pos, pos2 - pos).c_str());
+    }
+    pos = pos2 + 1;
     return 1;
+  } else {
+    if (in.size() - pos == 0) {
+      val = -1;
+    } else {
+      val = atof(in.substr(pos, in.size() - pos).c_str());
     }
-  else
-    {
-    if(in.size()-pos == 0)
-      {
-       val = -1;
-      }
-    else
-      {
-      val = atof(in.substr(pos, in.size()-pos).c_str());
-      }
     return 0;
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------
 cmCTestTestHandler::cmCTestTestHandler()
 {
   this->UseUnion = false;
 
-  this->UseIncludeLabelRegExpFlag   = false;
-  this->UseExcludeLabelRegExpFlag   = false;
-  this->UseIncludeRegExpFlag   = false;
-  this->UseExcludeRegExpFlag   = false;
-  this->UseExcludeRegExpFirst  = false;
+  this->UseIncludeLabelRegExpFlag = false;
+  this->UseExcludeLabelRegExpFlag = false;
+  this->UseIncludeRegExpFlag = false;
+  this->UseExcludeRegExpFlag = false;
+  this->UseExcludeRegExpFirst = false;
 
   this->CustomMaximumPassedTestOutputSize = 1 * 1024;
   this->CustomMaximumFailedTestOutputSize = 300 * 1024;
@@ -392,14 +339,12 @@ cmCTestTestHandler::cmCTestTestHandler()
   this->LogFile = 0;
 
   // regex to detect <DartMeasurement>...</DartMeasurement>
-  this->DartStuff.compile(
-    "(<DartMeasurement.*/DartMeasurement[a-zA-Z]*>)");
+  this->DartStuff.compile("(<DartMeasurement.*/DartMeasurement[a-zA-Z]*>)");
   // regex to detect each individual <DartMeasurement>...</DartMeasurement>
   this->DartStuff1.compile(
     "(<DartMeasurement[^<]*</DartMeasurement[a-zA-Z]*>)");
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -434,102 +379,89 @@ void cmCTestTestHandler::Initialize()
   this->TestList.clear();
 }
 
-//----------------------------------------------------------------------
-void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf)
+void cmCTestTestHandler::PopulateCustomVectors(cmMakefile* mf)
 {
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_PRE_TEST",
-                                this->CustomPreTest);
+                                    this->CustomPreTest);
   this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_POST_TEST",
-                                this->CustomPostTest);
-  this->CTest->PopulateCustomVector(mf,
-                             "CTEST_CUSTOM_TESTS_IGNORE",
-                             this->CustomTestsIgnore);
-  this->CTest->PopulateCustomInteger(mf,
-                             "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE",
-                             this->CustomMaximumPassedTestOutputSize);
-  this->CTest->PopulateCustomInteger(mf,
-                             "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE",
-                             this->CustomMaximumFailedTestOutputSize);
+                                    this->CustomPostTest);
+  this->CTest->PopulateCustomVector(mf, "CTEST_CUSTOM_TESTS_IGNORE",
+                                    this->CustomTestsIgnore);
+  this->CTest->PopulateCustomInteger(
+    mf, "CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE",
+    this->CustomMaximumPassedTestOutputSize);
+  this->CTest->PopulateCustomInteger(
+    mf, "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE",
+    this->CustomMaximumFailedTestOutputSize);
 }
 
-//----------------------------------------------------------------------
 int cmCTestTestHandler::PreProcessHandler()
 {
-  if ( !this->ExecuteCommands(this->CustomPreTest) )
-    {
+  if (!this->ExecuteCommands(this->CustomPreTest)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Problem executing pre-test command(s)." << std::endl);
+               "Problem executing pre-test command(s)." << std::endl);
     return 0;
-    }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
 int cmCTestTestHandler::PostProcessHandler()
 {
-  if ( !this->ExecuteCommands(this->CustomPostTest) )
-    {
+  if (!this->ExecuteCommands(this->CustomPostTest)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Problem executing post-test command(s)." << std::endl);
+               "Problem executing post-test command(s)." << std::endl);
     return 0;
-    }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
 int cmCTestTestHandler::ProcessHandler()
 {
   // Update internal data structure from generic one
   this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation"));
   this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion")));
-  if(cmSystemTools::IsOn(this->GetOption("ScheduleRandom")))
-    {
+  if (cmSystemTools::IsOn(this->GetOption("ScheduleRandom"))) {
     this->CTest->SetScheduleType("Random");
-    }
-  if(this->GetOption("ParallelLevel"))
-    {
+  }
+  if (this->GetOption("ParallelLevel")) {
     this->CTest->SetParallelLevel(atoi(this->GetOption("ParallelLevel")));
-    }
+  }
 
   const char* val;
   val = this->GetOption("LabelRegularExpression");
-  if ( val )
-    {
+  if (val) {
     this->UseIncludeLabelRegExpFlag = true;
     this->IncludeLabelRegExp = val;
-    }
+  }
   val = this->GetOption("ExcludeLabelRegularExpression");
-  if ( val )
-    {
+  if (val) {
     this->UseExcludeLabelRegExpFlag = true;
     this->ExcludeLabelRegExp = val;
-    }
+  }
   val = this->GetOption("IncludeRegularExpression");
-  if ( val )
-    {
+  if (val) {
     this->UseIncludeRegExp();
     this->SetIncludeRegExp(val);
-    }
+  }
   val = this->GetOption("ExcludeRegularExpression");
-  if ( val )
-    {
+  if (val) {
     this->UseExcludeRegExp();
     this->SetExcludeRegExp(val);
-    }
+  }
   this->SetRerunFailed(cmSystemTools::IsOn(this->GetOption("RerunFailed")));
 
   this->TestResults.clear();
 
-  cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-             (this->MemCheck ? "Memory check" : "Test")
-             << " project " << cmSystemTools::GetCurrentWorkingDirectory()
-             << std::endl, this->Quiet);
-  if ( ! this->PreProcessHandler() )
-    {
+  cmCTestOptionalLog(
+    this->CTest, HANDLER_OUTPUT, (this->MemCheck ? "Memory check" : "Test")
+      << " project " << cmSystemTools::GetCurrentWorkingDirectory()
+      << std::endl,
+    this->Quiet);
+  if (!this->PreProcessHandler()) {
     return -1;
-    }
+  }
 
   cmGeneratedFileStream mLogFile;
   this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile);
@@ -539,7 +471,7 @@ int cmCTestTestHandler::ProcessHandler()
   std::vector<std::string> failed;
   int total;
 
-  //start the real time clock
+  // start the real time clock
   double clock_start, clock_finish;
   clock_start = cmSystemTools::GetTime();
 
@@ -549,109 +481,95 @@ int cmCTestTestHandler::ProcessHandler()
 
   total = int(passed.size()) + int(failed.size());
 
-  if (total == 0)
-    {
-    if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
-      {
+  if (total == 0) {
+    if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!"
-        << std::endl);
-      }
+                   << std::endl);
     }
-  else
-    {
+  } else {
     if (this->HandlerVerbose && !passed.empty() &&
-      (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag))
-      {
+        (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag)) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
-        << "The following tests passed:" << std::endl, this->Quiet);
-      for(std::vector<std::string>::iterator j = passed.begin();
-          j != passed.end(); ++j)
-        {
-        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j
-          << std::endl, this->Quiet);
-        }
+                           << "The following tests passed:" << std::endl,
+                         this->Quiet);
+      for (std::vector<std::string>::iterator j = passed.begin();
+           j != passed.end(); ++j) {
+        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                           "\t" << *j << std::endl, this->Quiet);
       }
+    }
 
     float percent = float(passed.size()) * 100.0f / float(total);
-    if (!failed.empty() && percent > 99)
-      {
+    if (!failed.empty() && percent > 99) {
       percent = 99;
-      }
+    }
 
     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
-               << static_cast<int>(percent + .5f) << "% tests passed, "
-               << failed.size() << " tests failed out of "
-               << total << std::endl);
-    if(this->CTest->GetLabelSummary())
-      {
+                 << static_cast<int>(percent + .5f) << "% tests passed, "
+                 << failed.size() << " tests failed out of " << total
+                 << std::endl);
+    if (this->CTest->GetLabelSummary()) {
       this->PrintLabelSummary();
-      }
+    }
     char realBuf[1024];
     sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "\nTotal Test time (real) = " << realBuf << "\n", this->Quiet );
+                       "\nTotal Test time (real) = " << realBuf << "\n",
+                       this->Quiet);
 
-    if (!failed.empty())
-      {
+    if (!failed.empty()) {
       cmGeneratedFileStream ofs;
       cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
-                 << "The following tests FAILED:" << std::endl);
+                   << "The following tests FAILED:" << std::endl);
       this->StartLogFile("TestsFailed", ofs);
 
       typedef std::set<cmCTestTestHandler::cmCTestTestResult,
-                       cmCTestTestResultLess> SetOfTests;
+                       cmCTestTestResultLess>
+        SetOfTests;
       SetOfTests resultsSet(this->TestResults.begin(),
                             this->TestResults.end());
 
-      for(SetOfTests::iterator ftit = resultsSet.begin();
-          ftit != resultsSet.end(); ++ftit)
-        {
-        if ( ftit->Status != cmCTestTestHandler::COMPLETED )
-          {
+      for (SetOfTests::iterator ftit = resultsSet.begin();
+           ftit != resultsSet.end(); ++ftit) {
+        if (ftit->Status != cmCTestTestHandler::COMPLETED) {
           ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
-          cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
-                     << ftit->TestCount << " - "
-                     << ftit->Name << " ("
-                     << this->GetTestStatus(ftit->Status) << ")"
-                     << std::endl);
-          }
+          cmCTestLog(
+            this->CTest, HANDLER_OUTPUT, "\t"
+              << std::setw(3) << ftit->TestCount << " - " << ftit->Name << " ("
+              << this->GetTestStatus(ftit->Status) << ")" << std::endl);
         }
       }
     }
+  }
 
-  if ( this->CTest->GetProduceXML() )
-    {
+  if (this->CTest->GetProduceXML()) {
     cmGeneratedFileStream xmlfile;
-    if( !this->StartResultingXML(
+    if (!this->StartResultingXML(
           (this->MemCheck ? cmCTest::PartMemCheck : cmCTest::PartTest),
-        (this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile) )
-      {
+          (this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create "
-        << (this->MemCheck ? "memory check" : "testing")
-        << " XML file" << std::endl);
+                   << (this->MemCheck ? "memory check" : "testing")
+                   << " XML file" << std::endl);
       this->LogFile = 0;
       return 1;
-      }
+    }
     cmXMLWriter xml(xmlfile);
     this->GenerateDartOutput(xml);
-    }
+  }
 
-  if ( ! this->PostProcessHandler() )
-    {
+  if (!this->PostProcessHandler()) {
     this->LogFile = 0;
     return -1;
-    }
+  }
 
-  if ( !failed.empty() )
-    {
+  if (!failed.empty()) {
     this->LogFile = 0;
     return -1;
-    }
+  }
   this->LogFile = 0;
   return 0;
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::PrintLabelSummary()
 {
   cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
@@ -660,227 +578,186 @@ void cmCTestTestHandler::PrintLabelSummary()
   std::set<std::string> labels;
   // initialize maps
   std::string::size_type maxlen = 0;
-  for(; it != this->TestList.end(); ++it)
-    {
+  for (; it != this->TestList.end(); ++it) {
     cmCTestTestProperties& p = *it;
-    if(!p.Labels.empty())
-      {
-      for(std::vector<std::string>::iterator l = p.Labels.begin();
-          l !=  p.Labels.end(); ++l)
-        {
-        if((*l).size() > maxlen)
-          {
+    if (!p.Labels.empty()) {
+      for (std::vector<std::string>::iterator l = p.Labels.begin();
+           l != p.Labels.end(); ++l) {
+        if ((*l).size() > maxlen) {
           maxlen = (*l).size();
-          }
+        }
         labels.insert(*l);
         labelTimes[*l] = 0;
         labelCounts[*l] = 0;
-        }
       }
     }
+  }
   cmCTestTestHandler::TestResultsVector::iterator ri =
-      this->TestResults.begin();
+    this->TestResults.begin();
   // fill maps
-  for(; ri != this->TestResults.end(); ++ri)
-    {
-    cmCTestTestResult &result = *ri;
+  for (; ri != this->TestResults.end(); ++ri) {
+    cmCTestTestResult& result = *ri;
     cmCTestTestProperties& p = *result.Properties;
-    if(!p.Labels.empty())
-      {
-      for(std::vector<std::string>::iterator l = p.Labels.begin();
-          l !=  p.Labels.end(); ++l)
-        {
+    if (!p.Labels.empty()) {
+      for (std::vector<std::string>::iterator l = p.Labels.begin();
+           l != p.Labels.end(); ++l) {
         labelTimes[*l] += result.ExecutionTime;
         ++labelCounts[*l];
-        }
       }
     }
+  }
   // now print times
-  if(!labels.empty())
-    {
+  if (!labels.empty()) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:",
-      this->Quiet);
-    }
-  for(std::set<std::string>::const_iterator i = labels.begin();
-      i != labels.end(); ++i)
-    {
+                       this->Quiet);
+  }
+  for (std::set<std::string>::const_iterator i = labels.begin();
+       i != labels.end(); ++i) {
     std::string label = *i;
-    label.resize(maxlen +3, ' ');
+    label.resize(maxlen + 3, ' ');
 
     char buf[1024];
     sprintf(buf, "%6.2f sec", labelTimes[*i]);
 
     std::ostringstream labelCountStr;
     labelCountStr << "(" << labelCounts[*i] << " test";
-    if (labelCounts[*i] > 1)
-      {
+    if (labelCounts[*i] > 1) {
       labelCountStr << "s";
-      }
+    }
     labelCountStr << ")";
 
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n"
-               << label << " = " << buf << " " << labelCountStr.str(),
-               this->Quiet );
-    if ( this->LogFile )
-      {
-      *this->LogFile << "\n" << *i << " = "
-                     << buf << "\n";
-      }
-    }
-  if(!labels.empty())
-    {
-    if(this->LogFile)
-      {
+                         << label << " = " << buf << " "
+                         << labelCountStr.str(),
+                       this->Quiet);
+    if (this->LogFile) {
+      *this->LogFile << "\n" << *i << " = " << buf << "\n";
+    }
+  }
+  if (!labels.empty()) {
+    if (this->LogFile) {
       *this->LogFile << "\n";
-      }
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet);
     }
-
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet);
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
 {
   // if not using Labels to filter then return
-  if (!this->UseIncludeLabelRegExpFlag )
-    {
+  if (!this->UseIncludeLabelRegExpFlag) {
     return;
-    }
+  }
   // if there are no labels and we are filtering by labels
   // then exclude the test as it does not have the label
-  if(it.Labels.empty())
-    {
+  if (it.Labels.empty()) {
     it.IsInBasedOnREOptions = false;
     return;
-    }
+  }
   // check to see if the label regular expression matches
-  bool found = false;  // assume it does not match
+  bool found = false; // assume it does not match
   // loop over all labels and look for match
-  for(std::vector<std::string>::iterator l = it.Labels.begin();
-      l !=  it.Labels.end(); ++l)
-    {
-    if(this->IncludeLabelRegularExpression.find(*l))
-      {
+  for (std::vector<std::string>::iterator l = it.Labels.begin();
+       l != it.Labels.end(); ++l) {
+    if (this->IncludeLabelRegularExpression.find(*l)) {
       found = true;
-      }
     }
+  }
   // if no match was found, exclude the test
-  if(!found)
-    {
+  if (!found) {
     it.IsInBasedOnREOptions = false;
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------
 void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it)
 {
   // if not using Labels to filter then return
-  if (!this->UseExcludeLabelRegExpFlag )
-    {
+  if (!this->UseExcludeLabelRegExpFlag) {
     return;
-    }
+  }
   // if there are no labels and we are excluding by labels
   // then do nothing as a no label can not be a match
-  if(it.Labels.empty())
-    {
+  if (it.Labels.empty()) {
     return;
-    }
+  }
   // check to see if the label regular expression matches
-  bool found = false;  // assume it does not match
+  bool found = false; // assume it does not match
   // loop over all labels and look for match
-  for(std::vector<std::string>::iterator l = it.Labels.begin();
-      l !=  it.Labels.end(); ++l)
-    {
-    if(this->ExcludeLabelRegularExpression.find(*l))
-      {
+  for (std::vector<std::string>::iterator l = it.Labels.begin();
+       l != it.Labels.end(); ++l) {
+    if (this->ExcludeLabelRegularExpression.find(*l)) {
       found = true;
-      }
     }
+  }
   // if match was found, exclude the test
-  if(found)
-    {
+  if (found) {
     it.IsInBasedOnREOptions = false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::CheckLabelFilter(cmCTestTestProperties& it)
 {
   this->CheckLabelFilterInclude(it);
   this->CheckLabelFilterExclude(it);
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::ComputeTestList()
 {
   this->TestList.clear(); // clear list of test
   this->GetListOfTests();
 
-  if (this->RerunFailed)
-    {
+  if (this->RerunFailed) {
     this->ComputeTestListForRerunFailed();
     return;
-    }
+  }
 
   cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
   // how many tests are in based on RegExp?
   int inREcnt = 0;
   cmCTestTestHandler::ListOfTests::iterator it;
-  for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
-    {
+  for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
     this->CheckLabelFilter(*it);
-    if (it->IsInBasedOnREOptions)
-      {
-      inREcnt ++;
-      }
+    if (it->IsInBasedOnREOptions) {
+      inREcnt++;
     }
+  }
   // expand the test list based on the union flag
-  if (this->UseUnion)
-    {
+  if (this->UseUnion) {
     this->ExpandTestsToRunInformation((int)tmsize);
-    }
-  else
-    {
+  } else {
     this->ExpandTestsToRunInformation(inREcnt);
-    }
+  }
   // Now create a final list of tests to run
   int cnt = 0;
   inREcnt = 0;
   std::string last_directory = "";
   ListOfTests finalList;
-  for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
-    {
-    cnt ++;
-    if (it->IsInBasedOnREOptions)
-      {
+  for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+    cnt++;
+    if (it->IsInBasedOnREOptions) {
       inREcnt++;
-      }
+    }
 
-    if (this->UseUnion)
-      {
+    if (this->UseUnion) {
       // if it is not in the list and not in the regexp then skip
       if ((!this->TestsToRun.empty() &&
-           std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt)
-           == this->TestsToRun.end()) && !it->IsInBasedOnREOptions)
-        {
+           std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
+             this->TestsToRun.end()) &&
+          !it->IsInBasedOnREOptions) {
         continue;
-        }
       }
-    else
-      {
+    } else {
       // is this test in the list of tests to run? If not then skip it
       if ((!this->TestsToRun.empty() &&
-           std::find(this->TestsToRun.begin(),
-                     this->TestsToRun.end(), inREcnt)
-           == this->TestsToRun.end()) || !it->IsInBasedOnREOptions)
-        {
+           std::find(this->TestsToRun.begin(), this->TestsToRun.end(),
+                     inREcnt) == this->TestsToRun.end()) ||
+          !it->IsInBasedOnREOptions) {
         continue;
-        }
       }
-    it->Index = cnt;  // save the index into the test list for this test
-    finalList.push_back(*it);
     }
+    it->Index = cnt; // save the index into the test list for this test
+    finalList.push_back(*it);
+  }
   // Save the total number of tests before exclusions
   this->TotalNumberOfTests = this->TestList.size();
   // Set the TestList to the final list of all test
@@ -896,21 +773,19 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
   cmCTestTestHandler::ListOfTests::iterator it;
   ListOfTests finalList;
   int cnt = 0;
-  for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ )
-    {
-    cnt ++;
+  for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+    cnt++;
 
     // if this test is not in our list of tests to run, then skip it.
     if ((!this->TestsToRun.empty() &&
-         std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt)
-         == this->TestsToRun.end()))
-      {
+         std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
+           this->TestsToRun.end())) {
       continue;
-      }
+    }
 
     it->Index = cnt;
     finalList.push_back(*it);
-    }
+  }
 
   // Save the total number of tests before exclusions
   this->TotalNumberOfTests = this->TestList.size();
@@ -924,167 +799,135 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
 void cmCTestTestHandler::UpdateMaxTestNameWidth()
 {
   std::string::size_type max = this->CTest->GetMaxTestNameWidth();
-  for ( cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
-        it != this->TestList.end(); it ++ )
-    {
+  for (cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
+       it != this->TestList.end(); it++) {
     cmCTestTestProperties& p = *it;
-    if(max < p.Name.size())
-      {
+    if (max < p.Name.size()) {
       max = p.Name.size();
-      }
     }
-  if(static_cast<std::string::size_type>(this->CTest->GetMaxTestNameWidth())
-     != max)
-    {
+  }
+  if (static_cast<std::string::size_type>(
+        this->CTest->GetMaxTestNameWidth()) != max) {
     this->CTest->SetMaxTestNameWidth(static_cast<int>(max));
-    }
+  }
 }
 
-bool cmCTestTestHandler::GetValue(const char* tag,
-                                  int& value,
+bool cmCTestTestHandler::GetValue(const char* tag, int& value,
                                   std::istream& fin)
 {
   std::string line;
   bool ret = true;
   cmSystemTools::GetLineFromStream(fin, line);
-  if(line == tag)
-    {
+  if (line == tag) {
     fin >> value;
     ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
-    }
-  else
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "parse error: missing tag: "
-               << tag << " found [" << line << "]" << std::endl);
+  } else {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+                 << tag << " found [" << line << "]" << std::endl);
     ret = false;
-    }
+  }
   return ret;
 }
 
-bool cmCTestTestHandler::GetValue(const char* tag,
-                                  double& value,
+bool cmCTestTestHandler::GetValue(const char* tag, double& value,
                                   std::istream& fin)
 {
   std::string line;
   cmSystemTools::GetLineFromStream(fin, line);
   bool ret = true;
-  if(line == tag)
-    {
+  if (line == tag) {
     fin >> value;
     ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
-    }
-  else
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "parse error: missing tag: "
-               << tag << " found [" << line << "]" << std::endl);
+  } else {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+                 << tag << " found [" << line << "]" << std::endl);
     ret = false;
-    }
+  }
   return ret;
 }
 
-bool cmCTestTestHandler::GetValue(const char* tag,
-                                  bool& value,
+bool cmCTestTestHandler::GetValue(const char* tag, bool& value,
                                   std::istream& fin)
 {
   std::string line;
   cmSystemTools::GetLineFromStream(fin, line);
   bool ret = true;
-  if(line == tag)
-    {
+  if (line == tag) {
 #ifdef __HAIKU__
     int tmp = 0;
     fin >> tmp;
     value = false;
-    if(tmp)
-      {
+    if (tmp) {
       value = true;
-      }
+    }
 #else
     fin >> value;
 #endif
     ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
-    }
-  else
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "parse error: missing tag: "
-               << tag << " found [" << line << "]" << std::endl);
+  } else {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+                 << tag << " found [" << line << "]" << std::endl);
     ret = false;
-    }
+  }
   return ret;
 }
 
-bool cmCTestTestHandler::GetValue(const char* tag,
-                                  size_t& value,
+bool cmCTestTestHandler::GetValue(const char* tag, size_t& value,
                                   std::istream& fin)
 {
   std::string line;
   cmSystemTools::GetLineFromStream(fin, line);
   bool ret = true;
-  if(line == tag)
-    {
+  if (line == tag) {
     fin >> value;
     ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
-    }
-  else
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "parse error: missing tag: "
-               << tag << " found [" << line << "]" << std::endl);
+  } else {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+                 << tag << " found [" << line << "]" << std::endl);
     ret = false;
-    }
+  }
   return ret;
 }
 
-bool cmCTestTestHandler::GetValue(const char* tag,
-                                  std::string& value,
+bool cmCTestTestHandler::GetValue(const char* tag, std::string& value,
                                   std::istream& fin)
 {
   std::string line;
   cmSystemTools::GetLineFromStream(fin, line);
   bool ret = true;
-  if(line == tag)
-    {
-    ret =  cmSystemTools::GetLineFromStream(fin, value);
-    }
-  else
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "parse error: missing tag: "
-               << tag << " found [" << line << "]" << std::endl);
+  if (line == tag) {
+    ret = cmSystemTools::GetLineFromStream(fin, value);
+  } else {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
+                 << tag << " found [" << line << "]" << std::endl);
     ret = false;
-    }
+  }
   return ret;
 }
 
-//---------------------------------------------------------------------
-void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
-                                         std::vector<std::string> &failed)
+void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
+                                          std::vector<std::string>& failed)
 {
   this->ComputeTestList();
   this->StartTest = this->CTest->CurrentTime();
   this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
   double elapsed_time_start = cmSystemTools::GetTime();
 
-  cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs() ?
-    new cmCTestBatchTestHandler : new cmCTestMultiProcessHandler;
+  cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs()
+    ? new cmCTestBatchTestHandler
+    : new cmCTestMultiProcessHandler;
   parallel->SetCTest(this->CTest);
   parallel->SetParallelLevel(this->CTest->GetParallelLevel());
   parallel->SetTestHandler(this);
   parallel->SetQuiet(this->Quiet);
-  if(this->TestLoad > 0)
-    {
+  if (this->TestLoad > 0) {
     parallel->SetTestLoad(this->TestLoad);
-    }
-  else
-    {
+  } else {
     parallel->SetTestLoad(this->CTest->GetTestLoad());
-    }
+  }
 
-  *this->LogFile << "Start testing: "
-    << this->CTest->CurrentTime() << std::endl
+  *this->LogFile
+    << "Start testing: " << this->CTest->CurrentTime() << std::endl
     << "----------------------------------------------------------"
     << std::endl;
 
@@ -1092,83 +935,66 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
   cmCTestMultiProcessHandler::PropertiesMap properties;
 
   bool randomSchedule = this->CTest->GetScheduleType() == "Random";
-  if(randomSchedule)
-    {
+  if (randomSchedule) {
     srand((unsigned)time(0));
-    }
+  }
 
   for (ListOfTests::iterator it = this->TestList.begin();
-       it != this->TestList.end(); ++it)
-    {
+       it != this->TestList.end(); ++it) {
     cmCTestTestProperties& p = *it;
     cmCTestMultiProcessHandler::TestSet depends;
 
-    if(randomSchedule)
-      {
+    if (randomSchedule) {
       p.Cost = static_cast<float>(rand());
-      }
+    }
 
-    if(p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0)
-      {
+    if (p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0) {
       p.Timeout = this->CTest->GetGlobalTimeout();
-      }
+    }
 
-    if(!p.Depends.empty())
-      {
-      for(std::vector<std::string>::iterator i = p.Depends.begin();
-          i != p.Depends.end(); ++i)
-        {
-        for(ListOfTests::iterator it2 = this->TestList.begin();
-            it2 != this->TestList.end(); ++it2)
-          {
-          if(it2->Name == *i)
-            {
+    if (!p.Depends.empty()) {
+      for (std::vector<std::string>::iterator i = p.Depends.begin();
+           i != p.Depends.end(); ++i) {
+        for (ListOfTests::iterator it2 = this->TestList.begin();
+             it2 != this->TestList.end(); ++it2) {
+          if (it2->Name == *i) {
             depends.insert(it2->Index);
             break; // break out of test loop as name can only match 1
-            }
           }
         }
       }
+    }
     tests[it->Index] = depends;
     properties[it->Index] = &*it;
-    }
+  }
   parallel->SetTests(tests, properties);
   parallel->SetPassFailVectors(&passed, &failed);
   this->TestResults.clear();
   parallel->SetTestResults(&this->TestResults);
 
-  if(this->CTest->ShouldPrintLabels())
-    {
+  if (this->CTest->ShouldPrintLabels()) {
     parallel->PrintLabels();
-    }
-  else if(this->CTest->GetShowOnly())
-    {
+  } else if (this->CTest->GetShowOnly()) {
     parallel->PrintTestList();
-    }
-  else
-    {
+  } else {
     parallel->RunTests();
-    }
+  }
   delete parallel;
   this->EndTest = this->CTest->CurrentTime();
   this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
   this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start;
-  *this->LogFile << "End testing: "
-     << this->CTest->CurrentTime() << std::endl;
+  *this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl;
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::GenerateTestCommand(std::vector<std::string>&, int)
 {
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
 {
-  if ( !this->CTest->GetProduceXML() )
-    {
+  if (!this->CTest->GetProduceXML()) {
     return;
-    }
+  }
 
   this->CTest->StartXML(xml, this->AppendXML);
   xml.StartElement("Testing");
@@ -1176,23 +1002,19 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
   xml.Element("StartTestTime", this->StartTestTime);
   xml.StartElement("TestList");
   cmCTestTestHandler::TestResultsVector::size_type cc;
-  for ( cc = 0; cc < this->TestResults.size(); cc ++ )
-    {
-    cmCTestTestResult *result = &this->TestResults[cc];
+  for (cc = 0; cc < this->TestResults.size(); cc++) {
+    cmCTestTestResult* result = &this->TestResults[cc];
     std::string testPath = result->Path + "/" + result->Name;
     xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
-    }
+  }
   xml.EndElement(); // TestList
-  for ( cc = 0; cc < this->TestResults.size(); cc ++ )
-    {
-    cmCTestTestResult *result = &this->TestResults[cc];
+  for (cc = 0; cc < this->TestResults.size(); cc++) {
+    cmCTestTestResult* result = &this->TestResults[cc];
     this->WriteTestResultHeader(xml, result);
     xml.StartElement("Results");
-    if ( result->Status != cmCTestTestHandler::NOT_RUN )
-      {
-      if ( result->Status != cmCTestTestHandler::COMPLETED ||
-        result->ReturnValue )
-        {
+    if (result->Status != cmCTestTestHandler::NOT_RUN) {
+      if (result->Status != cmCTestTestHandler::COMPLETED ||
+          result->ReturnValue) {
         xml.StartElement("NamedMeasurement");
         xml.Attribute("type", "text/string");
         xml.Attribute("name", "Exit Code");
@@ -1203,56 +1025,51 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
         xml.Attribute("name", "Exit Value");
         xml.Element("Value", result->ReturnValue);
         xml.EndElement(); // NamedMeasurement
-        }
+      }
       this->GenerateRegressionImages(xml, result->DartString);
       xml.StartElement("NamedMeasurement");
       xml.Attribute("type", "numeric/double");
       xml.Attribute("name", "Execution Time");
       xml.Element("Value", result->ExecutionTime);
       xml.EndElement(); // NamedMeasurement
-      if(!result->Reason.empty())
-        {
+      if (!result->Reason.empty()) {
         const char* reasonType = "Pass Reason";
-        if(result->Status != cmCTestTestHandler::COMPLETED &&
-           result->Status != cmCTestTestHandler::NOT_RUN)
-          {
+        if (result->Status != cmCTestTestHandler::COMPLETED &&
+            result->Status != cmCTestTestHandler::NOT_RUN) {
           reasonType = "Fail Reason";
-          }
+        }
         xml.StartElement("NamedMeasurement");
         xml.Attribute("type", "text/string");
         xml.Attribute("name", reasonType);
         xml.Element("Value", result->Reason);
         xml.EndElement(); // NamedMeasurement
-        }
+      }
       xml.StartElement("NamedMeasurement");
       xml.Attribute("type", "text/string");
       xml.Attribute("name", "Completion Status");
       xml.Element("Value", result->CompletionStatus);
       xml.EndElement(); // NamedMeasurement
-      }
+    }
     xml.StartElement("NamedMeasurement");
     xml.Attribute("type", "text/string");
     xml.Attribute("name", "Command Line");
     xml.Element("Value", result->FullCommandLine);
     xml.EndElement(); // NamedMeasurement
-    std::map<std::string,std::string>::iterator measureIt;
-    for ( measureIt = result->Properties->Measurements.begin();
-      measureIt != result->Properties->Measurements.end();
-      ++ measureIt )
-      {
+    std::map<std::string, std::string>::iterator measureIt;
+    for (measureIt = result->Properties->Measurements.begin();
+         measureIt != result->Properties->Measurements.end(); ++measureIt) {
       xml.StartElement("NamedMeasurement");
       xml.Attribute("type", "text/string");
       xml.Attribute("name", measureIt->first);
       xml.Element("Value", measureIt->second);
       xml.EndElement(); // NamedMeasurement
-      }
+    }
     xml.StartElement("Measurement");
     xml.StartElement("Value");
-    if (result->CompressOutput)
-      {
+    if (result->CompressOutput) {
       xml.Attribute("encoding", "base64");
       xml.Attribute("compression", "gzip");
-      }
+    }
     xml.Content(result->Output);
     xml.EndElement(); // Value
     xml.EndElement(); // Measurement
@@ -1260,33 +1077,27 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
 
     this->AttachFiles(xml, result);
     this->WriteTestResultFooter(xml, result);
-    }
+  }
 
   xml.Element("EndDateTime", this->EndTest);
   xml.Element("EndTestTime", this->EndTestTime);
   xml.Element("ElapsedMinutes",
-    static_cast<int>(this->ElapsedTestingTime/6)/10.0);
+              static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
   xml.EndElement(); // Testing
   this->CTest->EndXML(xml);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
                                                cmCTestTestResult* result)
 {
   xml.StartElement("Test");
-  if ( result->Status == cmCTestTestHandler::COMPLETED )
-    {
+  if (result->Status == cmCTestTestHandler::COMPLETED) {
     xml.Attribute("Status", "passed");
-    }
-  else if ( result->Status == cmCTestTestHandler::NOT_RUN )
-    {
+  } else if (result->Status == cmCTestTestHandler::NOT_RUN) {
     xml.Attribute("Status", "notrun");
-    }
-  else
-    {
+  } else {
     xml.Attribute("Status", "failed");
-    }
+  }
   std::string testPath = result->Path + "/" + result->Name;
   xml.Element("Name", result->Name);
   xml.Element("Path", this->CTest->GetShortPathToFile(result->Path.c_str()));
@@ -1294,42 +1105,36 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
   xml.Element("FullCommandLine", result->FullCommandLine);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
                                                cmCTestTestResult* result)
 {
-  if(!result->Properties->Labels.empty())
-    {
+  if (!result->Properties->Labels.empty()) {
     xml.StartElement("Labels");
     std::vector<std::string> const& labels = result->Properties->Labels;
-    for(std::vector<std::string>::const_iterator li = labels.begin();
-        li != labels.end(); ++li)
-      {
+    for (std::vector<std::string>::const_iterator li = labels.begin();
+         li != labels.end(); ++li) {
       xml.Element("Label", *li);
-      }
-    xml.EndElement(); // Labels
     }
+    xml.EndElement(); // Labels
+  }
 
   xml.EndElement(); // Test
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
                                      cmCTestTestResult* result)
 {
-  if(result->Status != cmCTestTestHandler::COMPLETED
-     && result->Properties->AttachOnFail.size())
-    {
+  if (result->Status != cmCTestTestHandler::COMPLETED &&
+      result->Properties->AttachOnFail.size()) {
     result->Properties->AttachedFiles.insert(
       result->Properties->AttachedFiles.end(),
       result->Properties->AttachOnFail.begin(),
       result->Properties->AttachOnFail.end());
-    }
-  for(std::vector<std::string>::const_iterator file =
-      result->Properties->AttachedFiles.begin();
-      file != result->Properties->AttachedFiles.end(); ++file)
-    {
-    const std::string &base64 = this->CTest->Base64GzipEncodeFile(*file);
+  }
+  for (std::vector<std::string>::const_iterator file =
+         result->Properties->AttachedFiles.begin();
+       file != result->Properties->AttachedFiles.end(); ++file) {
+    const std::string& base64 = this->CTest->Base64GzipEncodeFile(*file);
     std::string fname = cmSystemTools::GetFilenameName(*file);
     xml.StartElement("NamedMeasurement");
     xml.Attribute("name", "Attached File");
@@ -1339,69 +1144,57 @@ void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
     xml.Attribute("type", "file");
     xml.Element("Value", base64);
     xml.EndElement(); // NamedMeasurement
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
 {
   std::vector<std::string>::iterator it;
-  for ( it = vec.begin(); it != vec.end(); ++it )
-    {
+  for (it = vec.begin(); it != vec.end(); ++it) {
     int retVal = 0;
-    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " <<
-      *it << std::endl, this->Quiet);
-    if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, 0, &retVal, 0,
-                                          cmSystemTools::OUTPUT_MERGE
-        /*this->Verbose*/) || retVal != 0 )
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem running command: "
-        << *it << std::endl);
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "Run command: " << *it << std::endl, this->Quiet);
+    if (!cmSystemTools::RunSingleCommand(it->c_str(), 0, 0, &retVal, 0,
+                                         cmSystemTools::OUTPUT_MERGE
+                                         /*this->Verbose*/) ||
+        retVal != 0) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+                 "Problem running command: " << *it << std::endl);
       return 0;
-      }
     }
+  }
   return 1;
 }
 
-
-//----------------------------------------------------------------------
 // Find the appropriate executable to run for a test
-std::string cmCTestTestHandler::FindTheExecutable(const char *exe)
+std::string cmCTestTestHandler::FindTheExecutable(const char* exe)
 {
   std::string resConfig;
   std::vector<std::string> extraPaths;
   std::vector<std::string> failedPaths;
-  if(strcmp(exe, "NOT_AVAILABLE") == 0)
-    {
+  if (strcmp(exe, "NOT_AVAILABLE") == 0) {
     return exe;
-    }
-  return cmCTestTestHandler::FindExecutable(this->CTest,
-                                            exe, resConfig,
-                                            extraPaths,
-                                            failedPaths);
+  }
+  return cmCTestTestHandler::FindExecutable(this->CTest, exe, resConfig,
+                                            extraPaths, failedPaths);
 }
 
 // add additional configurations to the search path
-void cmCTestTestHandler
-::AddConfigurations(cmCTest *ctest,
-                    std::vector<std::string> &attempted,
-                    std::vector<std::string> &attemptedConfigs,
-                    std::string filepath,
-                    std::string &filename)
+void cmCTestTestHandler::AddConfigurations(
+  cmCTest* ctest, std::vector<std::string>& attempted,
+  std::vector<std::string>& attemptedConfigs, std::string filepath,
+  std::string& filename)
 {
   std::string tempPath;
 
-  if (!filepath.empty() &&
-      filepath[filepath.size()-1] != '/')
-    {
+  if (!filepath.empty() && filepath[filepath.size() - 1] != '/') {
     filepath += "/";
-    }
+  }
   tempPath = filepath + filename;
   attempted.push_back(tempPath);
   attemptedConfigs.push_back("");
 
-  if(!ctest->GetConfigType().empty())
-    {
+  if (!ctest->GetConfigType().empty()) {
     tempPath = filepath;
     tempPath += ctest->GetConfigType();
     tempPath += "/";
@@ -1416,9 +1209,7 @@ void cmCTestTestHandler
     tempPath += filename;
     attempted.push_back(tempPath);
     attemptedConfigs.push_back(ctest->GetConfigType());
-    }
-  else
-    {
+  } else {
     // no config specified - try some options...
     tempPath = filepath;
     tempPath += "Release/";
@@ -1450,143 +1241,111 @@ void cmCTestTestHandler
     tempPath += filename;
     attempted.push_back(tempPath);
     attemptedConfigs.push_back("Deployment");
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------
 // Find the appropriate executable to run for a test
-std::string cmCTestTestHandler
-::FindExecutable(cmCTest *ctest,
-                 const char *testCommand,
-                 std::string &resultingConfig,
-                 std::vector<std::string> &extraPaths,
-                 std::vector<std::string> &failed)
+std::string cmCTestTestHandler::FindExecutable(
+  cmCTest* ctest, const char* testCommand, std::string& resultingConfig,
+  std::vector<std::string>& extraPaths, std::vector<std::string>& failed)
 {
   // now run the compiled test if we can find it
   std::vector<std::string> attempted;
   std::vector<std::string> attemptedConfigs;
   std::string tempPath;
-  std::string filepath =
-    cmSystemTools::GetFilenamePath(testCommand);
-  std::string filename =
-    cmSystemTools::GetFilenameName(testCommand);
+  std::string filepath = cmSystemTools::GetFilenamePath(testCommand);
+  std::string filename = cmSystemTools::GetFilenameName(testCommand);
 
-  cmCTestTestHandler::AddConfigurations(ctest, attempted,
-                                        attemptedConfigs,
-                                        filepath,filename);
+  cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
+                                        filepath, filename);
 
   // even if a fullpath was specified also try it relative to the current
   // directory
-  if (!filepath.empty() && filepath[0] == '/')
-    {
-    std::string localfilepath = filepath.substr(1,filepath.size()-1);
-    cmCTestTestHandler::AddConfigurations(ctest, attempted,
-                                          attemptedConfigs,
-                                          localfilepath,filename);
-    }
-
+  if (!filepath.empty() && filepath[0] == '/') {
+    std::string localfilepath = filepath.substr(1, filepath.size() - 1);
+    cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
+                                          localfilepath, filename);
+  }
 
   // if extraPaths are provided and we were not passed a full path, try them,
   // try any extra paths
-  if (filepath.empty())
-    {
-    for (unsigned int i = 0; i < extraPaths.size(); ++i)
-      {
+  if (filepath.empty()) {
+    for (unsigned int i = 0; i < extraPaths.size(); ++i) {
       std::string filepathExtra =
         cmSystemTools::GetFilenamePath(extraPaths[i]);
       std::string filenameExtra =
         cmSystemTools::GetFilenameName(extraPaths[i]);
-      cmCTestTestHandler::AddConfigurations(ctest,attempted,
-                                            attemptedConfigs,
-                                            filepathExtra,
-                                            filenameExtra);
-      }
+      cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
+                                            filepathExtra, filenameExtra);
     }
+  }
 
   // store the final location in fullPath
   std::string fullPath;
 
   // now look in the paths we specified above
-  for(unsigned int ai=0;
-      ai < attempted.size() && fullPath.empty(); ++ai)
-    {
+  for (unsigned int ai = 0; ai < attempted.size() && fullPath.empty(); ++ai) {
     // first check without exe extension
-    if(cmSystemTools::FileExists(attempted[ai].c_str())
-       && !cmSystemTools::FileIsDirectory(attempted[ai]))
-      {
+    if (cmSystemTools::FileExists(attempted[ai].c_str()) &&
+        !cmSystemTools::FileIsDirectory(attempted[ai])) {
       fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
       resultingConfig = attemptedConfigs[ai];
-      }
+    }
     // then try with the exe extension
-    else
-      {
+    else {
       failed.push_back(attempted[ai]);
       tempPath = attempted[ai];
       tempPath += cmSystemTools::GetExecutableExtension();
-      if(cmSystemTools::FileExists(tempPath.c_str())
-         && !cmSystemTools::FileIsDirectory(tempPath))
-        {
+      if (cmSystemTools::FileExists(tempPath.c_str()) &&
+          !cmSystemTools::FileIsDirectory(tempPath)) {
         fullPath = cmSystemTools::CollapseFullPath(tempPath);
         resultingConfig = attemptedConfigs[ai];
-        }
-      else
-        {
+      } else {
         failed.push_back(tempPath);
-        }
       }
     }
+  }
 
   // if everything else failed, check the users path, but only if a full path
   // wasn't specified
-  if (fullPath.empty() && filepath.empty())
-    {
+  if (fullPath.empty() && filepath.empty()) {
     std::string path = cmSystemTools::FindProgram(filename.c_str());
-    if (path != "")
-      {
+    if (path != "") {
       resultingConfig = "";
       return path;
-      }
     }
-  if(fullPath.empty())
-    {
-    cmCTestLog(ctest, HANDLER_OUTPUT,
-               "Could not find executable " << testCommand << "\n"
-               << "Looked in the following places:\n");
-    for(std::vector<std::string>::iterator i = failed.begin();
-        i != failed.end(); ++i)
-      {
+  }
+  if (fullPath.empty()) {
+    cmCTestLog(ctest, HANDLER_OUTPUT, "Could not find executable "
+                 << testCommand << "\n"
+                 << "Looked in the following places:\n");
+    for (std::vector<std::string>::iterator i = failed.begin();
+         i != failed.end(); ++i) {
       cmCTestLog(ctest, HANDLER_OUTPUT, i->c_str() << "\n");
-      }
     }
+  }
 
   return fullPath;
 }
 
-
-//----------------------------------------------------------------------
 void cmCTestTestHandler::GetListOfTests()
 {
-  if ( !this->IncludeLabelRegExp.empty() )
-    {
-    this->IncludeLabelRegularExpression.
-      compile(this->IncludeLabelRegExp.c_str());
-    }
-  if ( !this->ExcludeLabelRegExp.empty() )
-    {
-    this->ExcludeLabelRegularExpression.
-      compile(this->ExcludeLabelRegExp.c_str());
-    }
-  if ( !this->IncludeRegExp.empty() )
-    {
+  if (!this->IncludeLabelRegExp.empty()) {
+    this->IncludeLabelRegularExpression.compile(
+      this->IncludeLabelRegExp.c_str());
+  }
+  if (!this->ExcludeLabelRegExp.empty()) {
+    this->ExcludeLabelRegularExpression.compile(
+      this->ExcludeLabelRegExp.c_str());
+  }
+  if (!this->IncludeRegExp.empty()) {
     this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str());
-    }
-  if ( !this->ExcludeRegExp.empty() )
-    {
+  }
+  if (!this->ExcludeRegExp.empty()) {
     this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp.c_str());
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "Constructing a list of tests" << std::endl, this->Quiet);
+                     "Constructing a list of tests" << std::endl, this->Quiet);
   cmake cm;
   cm.SetHomeDirectory("");
   cm.SetHomeOutputDirectory("");
@@ -1594,7 +1353,7 @@ void cmCTestTestHandler::GetListOfTests()
   cmGlobalGenerator gg(&cm);
   cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
   mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
-    this->CTest->GetConfigType().c_str());
+                    this->CTest->GetConfigType().c_str());
 
   // Add handler for ADD_TEST
   cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
@@ -1602,95 +1361,73 @@ void cmCTestTestHandler::GetListOfTests()
   cm.GetState()->AddCommand(newCom1);
 
   // Add handler for SUBDIRS
-  cmCTestSubdirCommand* newCom2 =
-    new cmCTestSubdirCommand;
+  cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand;
   newCom2->TestHandler = this;
   cm.GetState()->AddCommand(newCom2);
 
   // Add handler for ADD_SUBDIRECTORY
-  cmCTestAddSubdirectoryCommand* newCom3 =
-    new cmCTestAddSubdirectoryCommand;
+  cmCTestAddSubdirectoryCommand* newCom3 = new cmCTestAddSubdirectoryCommand;
   newCom3->TestHandler = this;
   cm.GetState()->AddCommand(newCom3);
 
   // Add handler for SET_SOURCE_FILES_PROPERTIES
-  cmCTestSetTestsPropertiesCommand* newCom4
-    = new cmCTestSetTestsPropertiesCommand;
+  cmCTestSetTestsPropertiesCommand* newCom4 =
+    new cmCTestSetTestsPropertiesCommand;
   newCom4->TestHandler = this;
   cm.GetState()->AddCommand(newCom4);
 
   const char* testFilename;
-  if( cmSystemTools::FileExists("CTestTestfile.cmake") )
-    {
+  if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
     // does the CTestTestfile.cmake exist ?
     testFilename = "CTestTestfile.cmake";
-    }
-  else if( cmSystemTools::FileExists("DartTestfile.txt") )
-    {
+  } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
     // does the DartTestfile.txt exist ?
     testFilename = "DartTestfile.txt";
-    }
-  else
-    {
+  } else {
     return;
-    }
+  }
 
-  if ( !mf->ReadListFile(testFilename) )
-    {
+  if (!mf->ReadListFile(testFilename)) {
     return;
-    }
-  if ( cmSystemTools::GetErrorOccuredFlag() )
-    {
+  }
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return;
-    }
+  }
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-    "Done constructing a list of tests" << std::endl, this->Quiet);
+                     "Done constructing a list of tests" << std::endl,
+                     this->Quiet);
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::UseIncludeRegExp()
 {
   this->UseIncludeRegExpFlag = true;
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::UseExcludeRegExp()
 {
   this->UseExcludeRegExpFlag = true;
   this->UseExcludeRegExpFirst = this->UseIncludeRegExpFlag ? false : true;
 }
 
-//----------------------------------------------------------------------
 const char* cmCTestTestHandler::GetTestStatus(int status)
 {
   static const char statuses[][100] = {
-    "Not Run",
-    "Timeout",
-    "SEGFAULT",
-    "ILLEGAL",
-    "INTERRUPT",
-    "NUMERICAL",
-    "OTHER_FAULT",
-    "Failed",
-    "BAD_COMMAND",
-    "Completed"
+    "Not Run",   "Timeout",     "SEGFAULT", "ILLEGAL",     "INTERRUPT",
+    "NUMERICAL", "OTHER_FAULT", "Failed",   "BAD_COMMAND", "Completed"
   };
 
-  if ( status < cmCTestTestHandler::NOT_RUN ||
-       status > cmCTestTestHandler::COMPLETED )
-    {
+  if (status < cmCTestTestHandler::NOT_RUN ||
+      status > cmCTestTestHandler::COMPLETED) {
     return "No Status";
-    }
+  }
   return statuses[status];
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
 {
-  if (this->TestsToRunString.empty())
-    {
+  if (this->TestsToRunString.empty()) {
     return;
-    }
+  }
 
   int start;
   int end = -1;
@@ -1698,57 +1435,48 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
   std::string::size_type pos = 0;
   std::string::size_type pos2;
   // read start
-  if(GetNextNumber(this->TestsToRunString, start, pos, pos2))
-    {
+  if (GetNextNumber(this->TestsToRunString, start, pos, pos2)) {
     // read end
-    if(GetNextNumber(this->TestsToRunString, end, pos, pos2))
-      {
+    if (GetNextNumber(this->TestsToRunString, end, pos, pos2)) {
       // read stride
-      if(GetNextRealNumber(this->TestsToRunString, stride, pos, pos2))
-        {
-        int val =0;
+      if (GetNextRealNumber(this->TestsToRunString, stride, pos, pos2)) {
+        int val = 0;
         // now read specific numbers
-        while(GetNextNumber(this->TestsToRunString, val, pos, pos2))
-          {
+        while (GetNextNumber(this->TestsToRunString, val, pos, pos2)) {
           this->TestsToRun.push_back(val);
-          }
-        this->TestsToRun.push_back(val);
         }
+        this->TestsToRun.push_back(val);
       }
     }
+  }
 
   // if start is not specified then we assume we start at 1
-  if(start == -1)
-    {
+  if (start == -1) {
     start = 1;
-    }
+  }
 
   // if end isnot specified then we assume we end with the last test
-  if(end == -1)
-    {
+  if (end == -1) {
     end = static_cast<int>(numTests);
-    }
+  }
 
   // if the stride wasn't specified then it defaults to 1
-  if(stride == -1)
-    {
+  if (stride == -1) {
     stride = 1;
-    }
+  }
 
   // if we have a range then add it
-  if(end != -1 && start != -1 && stride > 0)
-    {
+  if (end != -1 && start != -1 && stride > 0) {
     int i = 0;
-    while (i*stride + start <= end)
-      {
-      this->TestsToRun.push_back(static_cast<int>(i*stride+start));
+    while (i * stride + start <= end) {
+      this->TestsToRun.push_back(static_cast<int>(i * stride + start));
       ++i;
-      }
     }
+  }
 
   // sort the array
   std::sort(this->TestsToRun.begin(), this->TestsToRun.end(),
-    std::less<int>());
+            std::less<int>());
   // remove duplicates
   std::vector<int>::iterator new_end =
     std::unique(this->TestsToRun.begin(), this->TestsToRun.end());
@@ -1761,143 +1489,120 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
   std::string dirName = this->CTest->GetBinaryDir() + "/Testing/Temporary";
 
   cmsys::Directory directory;
-  if (directory.Load(dirName) == 0)
-    {
+  if (directory.Load(dirName) == 0) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of "
-      << dirName << std::endl);
+                 << dirName << std::endl);
     return;
-    }
+  }
 
-  int numFiles = static_cast<int>
-    (cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
+  int numFiles =
+    static_cast<int>(cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
   std::string pattern = "LastTestsFailed";
   std::string logName = "";
 
-  for (int i = 0; i < numFiles; ++i)
-    {
+  for (int i = 0; i < numFiles; ++i) {
     std::string fileName = directory.GetFile(i);
     // bcc crashes if we attempt a normal substring comparison,
     // hence the following workaround
     std::string fileNameSubstring = fileName.substr(0, pattern.length());
-    if (fileNameSubstring.compare(pattern) != 0)
-      {
+    if (fileNameSubstring.compare(pattern) != 0) {
       continue;
-      }
-    if (logName == "")
-      {
+    }
+    if (logName == "") {
       logName = fileName;
-      }
-    else
-      {
+    } else {
       // if multiple matching logs were found we use the most recently
       // modified one.
       int res;
       cmSystemTools::FileTimeCompare(logName, fileName, &res);
-      if (res == -1)
-        {
+      if (res == -1) {
         logName = fileName;
-        }
       }
     }
+  }
 
-  std::string lastTestsFailedLog = this->CTest->GetBinaryDir()
-    + "/Testing/Temporary/" + logName;
+  std::string lastTestsFailedLog =
+    this->CTest->GetBinaryDir() + "/Testing/Temporary/" + logName;
 
-  if ( !cmSystemTools::FileExists(lastTestsFailedLog.c_str()) )
-    {
-    if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
-      {
+  if (!cmSystemTools::FileExists(lastTestsFailedLog.c_str())) {
+    if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, lastTestsFailedLog
-        << " does not exist!" << std::endl);
-      }
-    return;
+                   << " does not exist!" << std::endl);
     }
+    return;
+  }
 
   // parse the list of tests to rerun from LastTestsFailed.log
   cmsys::ifstream ifs(lastTestsFailedLog.c_str());
-  if ( ifs )
-    {
+  if (ifs) {
     std::string line;
     std::string::size_type pos;
-    while ( cmSystemTools::GetLineFromStream(ifs, line) )
-      {
+    while (cmSystemTools::GetLineFromStream(ifs, line)) {
       pos = line.find(':', 0);
-      if (pos == line.npos)
-        {
+      if (pos == line.npos) {
         continue;
-        }
+      }
 
       int val = atoi(line.substr(0, pos).c_str());
       this->TestsToRun.push_back(val);
-      }
-    ifs.close();
     }
-  else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
-    {
+    ifs.close();
+  } else if (!this->CTest->GetShowOnly() &&
+             !this->CTest->ShouldPrintLabels()) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: "
-      << lastTestsFailedLog <<
-      " while generating list of previously failed tests." << std::endl);
-    }
+                 << lastTestsFailedLog
+                 << " while generating list of previously failed tests."
+                 << std::endl);
+  }
 }
 
-//----------------------------------------------------------------------
 // Just for convenience
 #define SPACE_REGEX "[ \t\r\n]"
-//----------------------------------------------------------------------
-void cmCTestTestHandler::GenerateRegressionImages(
-  cmXMLWriter& xml, const std::string& dart)
+void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml,
+                                                  const std::string& dart)
 {
   cmsys::RegularExpression twoattributes(
-    "<DartMeasurement"
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*>([^<]*)</DartMeasurement>");
+    "<DartMeasurement" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*>([^<]*)</DartMeasurement>");
   cmsys::RegularExpression threeattributes(
-    "<DartMeasurement"
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*>([^<]*)</DartMeasurement>");
+    "<DartMeasurement" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*>([^<]*)</DartMeasurement>");
   cmsys::RegularExpression fourattributes(
-    "<DartMeasurement"
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*>([^<]*)</DartMeasurement>");
+    "<DartMeasurement" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*>([^<]*)</DartMeasurement>");
   cmsys::RegularExpression cdatastart(
-    "<DartMeasurement"
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*>"
-    SPACE_REGEX "*<!\\[CDATA\\[");
-  cmsys::RegularExpression cdataend(
-    "]]>"
-    SPACE_REGEX "*</DartMeasurement>");
+    "<DartMeasurement" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*>" SPACE_REGEX "*<!\\[CDATA\\[");
+  cmsys::RegularExpression cdataend("]]>" SPACE_REGEX "*</DartMeasurement>");
   cmsys::RegularExpression measurementfile(
-    "<DartMeasurementFile"
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
-    SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
+    "<DartMeasurementFile" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX
+    "*>([^<]*)</DartMeasurementFile>");
 
   bool done = false;
   std::string cxml = dart;
-  while ( ! done )
-    {
-    if ( twoattributes.find(cxml) )
-      {
+  while (!done) {
+    if (twoattributes.find(cxml)) {
       xml.StartElement("NamedMeasurement");
-      xml.Attribute(twoattributes.match(1).c_str(),
-                    twoattributes.match(2));
-      xml.Attribute(twoattributes.match(3).c_str(),
-                    twoattributes.match(4));
+      xml.Attribute(twoattributes.match(1).c_str(), twoattributes.match(2));
+      xml.Attribute(twoattributes.match(3).c_str(), twoattributes.match(4));
       xml.Element("Value", twoattributes.match(5));
       xml.EndElement();
       cxml.erase(twoattributes.start(),
-        twoattributes.end() - twoattributes.start());
-      }
-    else if ( threeattributes.find(cxml) )
-      {
+                 twoattributes.end() - twoattributes.start());
+    } else if (threeattributes.find(cxml)) {
       xml.StartElement("NamedMeasurement");
       xml.Attribute(threeattributes.match(1).c_str(),
                     threeattributes.match(2));
@@ -1908,58 +1613,43 @@ void cmCTestTestHandler::GenerateRegressionImages(
       xml.Element("Value", twoattributes.match(7));
       xml.EndElement();
       cxml.erase(threeattributes.start(),
-        threeattributes.end() - threeattributes.start());
-      }
-    else if ( fourattributes.find(cxml) )
-      {
+                 threeattributes.end() - threeattributes.start());
+    } else if (fourattributes.find(cxml)) {
       xml.StartElement("NamedMeasurement");
-      xml.Attribute(fourattributes.match(1).c_str(),
-                    fourattributes.match(2));
-      xml.Attribute(fourattributes.match(3).c_str(),
-                    fourattributes.match(4));
-      xml.Attribute(fourattributes.match(5).c_str(),
-                    fourattributes.match(6));
-      xml.Attribute(fourattributes.match(7).c_str(),
-                    fourattributes.match(8));
+      xml.Attribute(fourattributes.match(1).c_str(), fourattributes.match(2));
+      xml.Attribute(fourattributes.match(3).c_str(), fourattributes.match(4));
+      xml.Attribute(fourattributes.match(5).c_str(), fourattributes.match(6));
+      xml.Attribute(fourattributes.match(7).c_str(), fourattributes.match(8));
       xml.Element("Value", twoattributes.match(9));
       xml.EndElement();
       cxml.erase(fourattributes.start(),
-        fourattributes.end() - fourattributes.start());
-      }
-    else if ( cdatastart.find(cxml) && cdataend.find(cxml) )
-      {
+                 fourattributes.end() - fourattributes.start());
+    } else if (cdatastart.find(cxml) && cdataend.find(cxml)) {
       xml.StartElement("NamedMeasurement");
       xml.Attribute(cdatastart.match(1).c_str(), cdatastart.match(2));
       xml.Attribute(cdatastart.match(3).c_str(), cdatastart.match(4));
       xml.StartElement("Value");
       xml.CData(
-          cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end()));
+        cxml.substr(cdatastart.end(), cdataend.start() - cdatastart.end()));
       xml.EndElement(); // Value
       xml.EndElement(); // NamedMeasurement
-      cxml.erase(cdatastart.start(),
-        cdataend.end() - cdatastart.start());
-      }
-    else if ( measurementfile.find(cxml) )
-      {
+      cxml.erase(cdatastart.start(), cdataend.end() - cdatastart.start());
+    } else if (measurementfile.find(cxml)) {
       const std::string& filename =
         cmCTest::CleanString(measurementfile.match(5));
-      if ( cmSystemTools::FileExists(filename.c_str()) )
-        {
+      if (cmSystemTools::FileExists(filename.c_str())) {
         long len = cmSystemTools::FileLength(filename);
-        if ( len == 0 )
-          {
+        if (len == 0) {
           std::string k1 = measurementfile.match(1);
           std::string v1 = measurementfile.match(2);
           std::string k2 = measurementfile.match(3);
           std::string v2 = measurementfile.match(4);
-          if ( cmSystemTools::LowerCase(k1) == "type" )
-            {
+          if (cmSystemTools::LowerCase(k1) == "type") {
             v1 = "text/string";
-            }
-          if ( cmSystemTools::LowerCase(k2) == "type" )
-            {
+          }
+          if (cmSystemTools::LowerCase(k2) == "type") {
             v2 = "text/string";
-            }
+          }
 
           xml.StartElement("NamedMeasurement");
           xml.Attribute(k1.c_str(), v1);
@@ -1967,22 +1657,19 @@ void cmCTestTestHandler::GenerateRegressionImages(
           xml.Attribute("encoding", "none");
           xml.Element("Value", "Image " + filename + " is empty");
           xml.EndElement();
-          }
-        else
-          {
+        } else {
           cmsys::ifstream ifs(filename.c_str(), std::ios::in
 #ifdef _WIN32
-                            | std::ios::binary
+                                | std::ios::binary
 #endif
-            );
-          unsigned char *file_buffer = new unsigned char [ len + 1 ];
+                              );
+          unsigned char* file_buffer = new unsigned char[len + 1];
           ifs.read(reinterpret_cast<char*>(file_buffer), len);
-          unsigned char *encoded_buffer
-            = new unsigned char [ static_cast<int>(
-                static_cast<double>(len) * 1.5 + 5.0) ];
+          unsigned char* encoded_buffer = new unsigned char[static_cast<int>(
+            static_cast<double>(len) * 1.5 + 5.0)];
 
-          size_t rlen
-            = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
+          size_t rlen =
+            cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
 
           xml.StartElement("NamedMeasurement");
           xml.Attribute(measurementfile.match(1).c_str(),
@@ -1991,87 +1678,74 @@ void cmCTestTestHandler::GenerateRegressionImages(
                         measurementfile.match(4));
           xml.Attribute("encoding", "base64");
           std::stringstream ostr;
-          for (size_t cc = 0; cc < rlen; cc ++ )
-            {
+          for (size_t cc = 0; cc < rlen; cc++) {
             ostr << encoded_buffer[cc];
-            if ( cc % 60 == 0 && cc )
-              {
+            if (cc % 60 == 0 && cc) {
               ostr << std::endl;
-              }
             }
+          }
           xml.Element("Value", ostr.str());
           xml.EndElement(); // NamedMeasurement
-          delete [] file_buffer;
-          delete [] encoded_buffer;
-          }
+          delete[] file_buffer;
+          delete[] encoded_buffer;
         }
-      else
-        {
+      } else {
         int idx = 4;
-        if ( measurementfile.match(1) == "name" )
-          {
+        if (measurementfile.match(1) == "name") {
           idx = 2;
-          }
+        }
         xml.StartElement("NamedMeasurement");
         xml.Attribute("name", measurementfile.match(idx));
         xml.Attribute("text", "text/string");
         xml.Element("Value", "File " + filename + " not found");
         xml.EndElement();
-        cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
-          << "\" not found." << std::endl, this->Quiet);
-        }
-      cxml.erase(measurementfile.start(),
-        measurementfile.end() - measurementfile.start());
+        cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \""
+                             << filename << "\" not found." << std::endl,
+                           this->Quiet);
       }
-    else
-      {
+      cxml.erase(measurementfile.start(),
+                 measurementfile.end() - measurementfile.start());
+    } else {
       done = true;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------
-void cmCTestTestHandler::SetIncludeRegExp(const char *arg)
+void cmCTestTestHandler::SetIncludeRegExp(const char* arg)
 {
   this->IncludeRegExp = arg;
 }
 
-//----------------------------------------------------------------------
-void cmCTestTestHandler::SetExcludeRegExp(const char *arg)
+void cmCTestTestHandler::SetExcludeRegExp(const char* arg)
 {
   this->ExcludeRegExp = arg;
 }
 
-//----------------------------------------------------------------------
 void cmCTestTestHandler::SetTestsToRunInformation(const char* in)
 {
-  if ( !in )
-    {
+  if (!in) {
     return;
-    }
+  }
   this->TestsToRunString = in;
   // if the argument is a file, then read it and use the contents as the
   // string
-  if(cmSystemTools::FileExists(in))
-    {
+  if (cmSystemTools::FileExists(in)) {
     cmsys::ifstream fin(in);
     unsigned long filelen = cmSystemTools::FileLength(in);
-    char* buff = new char[filelen+1];
+    char* buff = new char[filelen + 1];
     fin.getline(buff, filelen);
     buff[fin.gcount()] = 0;
     this->TestsToRunString = buff;
-    delete [] buff;
-    }
+    delete[] buff;
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
 {
-  if(!length || length >= output.size() ||
-     output.find("CTEST_FULL_OUTPUT") != output.npos)
-    {
+  if (!length || length >= output.size() ||
+      output.find("CTEST_FULL_OUTPUT") != output.npos) {
     return true;
-    }
+  }
 
   // Truncate at given length but do not break in the middle of a multi-byte
   // UTF-8 encoding.
@@ -2079,248 +1753,221 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
   char const* const end = begin + output.size();
   char const* const truncate = begin + length;
   char const* current = begin;
-  while(current < truncate)
-    {
+  while (current < truncate) {
     unsigned int ch;
-    if(const char* next = cm_utf8_decode_character(current, end, &ch))
-      {
-      if(next > truncate)
-        {
+    if (const char* next = cm_utf8_decode_character(current, end, &ch)) {
+      if (next > truncate) {
         break;
-        }
-      current = next;
       }
-    else // Bad byte will be handled by cmXMLWriter.
-      {
+      current = next;
+    } else // Bad byte will be handled by cmXMLWriter.
+    {
       ++current;
-      }
     }
+  }
   output = output.substr(0, current - begin);
 
   // Append truncation message.
   std::ostringstream msg;
   msg << "...\n"
-    "The rest of the test output was removed since it exceeds the threshold "
-    "of " << length << " bytes.\n";
+         "The rest of the test output was removed since it exceeds the "
+         "threshold "
+         "of "
+      << length << " bytes.\n";
   output += msg.str();
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTestTestHandler::SetTestsProperties(
   const std::vector<std::string>& args)
 {
   std::vector<std::string>::const_iterator it;
   std::vector<std::string> tests;
   bool found = false;
-  for ( it = args.begin(); it != args.end(); ++ it )
-    {
-    if ( *it == "PROPERTIES" )
-      {
+  for (it = args.begin(); it != args.end(); ++it) {
+    if (*it == "PROPERTIES") {
       found = true;
       break;
-      }
-    tests.push_back(*it);
     }
-  if ( !found )
-    {
+    tests.push_back(*it);
+  }
+  if (!found) {
     return false;
-    }
-  ++ it; // skip PROPERTIES
-  for ( ; it != args.end(); ++ it )
-    {
+  }
+  ++it; // skip PROPERTIES
+  for (; it != args.end(); ++it) {
     std::string key = *it;
-    ++ it;
-    if ( it == args.end() )
-      {
+    ++it;
+    if (it == args.end()) {
       break;
-      }
+    }
     std::string val = *it;
     std::vector<std::string>::const_iterator tit;
-    for ( tit = tests.begin(); tit != tests.end(); ++ tit )
-      {
+    for (tit = tests.begin(); tit != tests.end(); ++tit) {
       cmCTestTestHandler::ListOfTests::iterator rtit;
-      for ( rtit = this->TestList.begin();
-        rtit != this->TestList.end();
-        ++ rtit )
-        {
-        if ( *tit == rtit->Name )
-          {
-          if ( key == "WILL_FAIL" )
-            {
+      for (rtit = this->TestList.begin(); rtit != this->TestList.end();
+           ++rtit) {
+        if (*tit == rtit->Name) {
+          if (key == "WILL_FAIL") {
             rtit->WillFail = cmSystemTools::IsOn(val.c_str());
-            }
-          if ( key == "ATTACHED_FILES" )
-            {
+          }
+          if (key == "ATTACHED_FILES") {
             cmSystemTools::ExpandListArgument(val, rtit->AttachedFiles);
-            }
-          if ( key == "ATTACHED_FILES_ON_FAIL" )
-            {
+          }
+          if (key == "ATTACHED_FILES_ON_FAIL") {
             cmSystemTools::ExpandListArgument(val, rtit->AttachOnFail);
-            }
-          if ( key == "RESOURCE_LOCK" )
-            {
+          }
+          if (key == "RESOURCE_LOCK") {
             std::vector<std::string> lval;
             cmSystemTools::ExpandListArgument(val, lval);
 
             rtit->LockedResources.insert(lval.begin(), lval.end());
-            }
-          if ( key == "TIMEOUT" )
-            {
+          }
+          if (key == "TIMEOUT") {
             rtit->Timeout = atof(val.c_str());
             rtit->ExplicitTimeout = true;
-            }
-          if ( key == "COST" )
-            {
+          }
+          if (key == "COST") {
             rtit->Cost = static_cast<float>(atof(val.c_str()));
-            }
-          if ( key == "REQUIRED_FILES" )
-            {
+          }
+          if (key == "REQUIRED_FILES") {
             cmSystemTools::ExpandListArgument(val, rtit->RequiredFiles);
-            }
-          if ( key == "RUN_SERIAL" )
-            {
+          }
+          if (key == "RUN_SERIAL") {
             rtit->RunSerial = cmSystemTools::IsOn(val.c_str());
-            }
-          if ( key == "FAIL_REGULAR_EXPRESSION" )
-            {
+          }
+          if (key == "FAIL_REGULAR_EXPRESSION") {
             std::vector<std::string> lval;
             cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
-            for ( crit = lval.begin(); crit != lval.end(); ++ 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)));
-              }
             }
-          if ( key == "PROCESSORS" )
-            {
+          }
+          if (key == "PROCESSORS") {
             rtit->Processors = atoi(val.c_str());
-            if(rtit->Processors < 1)
-              {
+            if (rtit->Processors < 1) {
               rtit->Processors = 1;
-              }
             }
-          if ( key == "SKIP_RETURN_CODE" )
-            {
+          }
+          if (key == "SKIP_RETURN_CODE") {
             rtit->SkipReturnCode = atoi(val.c_str());
-            if(rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255)
-              {
+            if (rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255) {
               rtit->SkipReturnCode = -1;
-              }
             }
-          if ( key == "DEPENDS" )
-            {
+          }
+          if (key == "DEPENDS") {
             cmSystemTools::ExpandListArgument(val, rtit->Depends);
-            }
-          if ( key == "ENVIRONMENT" )
-            {
+          }
+          if (key == "ENVIRONMENT") {
             cmSystemTools::ExpandListArgument(val, rtit->Environment);
-            }
-          if ( key == "LABELS" )
-            {
+          }
+          if (key == "LABELS") {
             cmSystemTools::ExpandListArgument(val, rtit->Labels);
-            }
-          if ( key == "MEASUREMENT" )
-            {
-            size_t pos = val.find_first_of("=");
-            if ( pos != val.npos )
-              {
+          }
+          if (key == "MEASUREMENT") {
+            size_t pos = val.find_first_of('=');
+            if (pos != val.npos) {
               std::string mKey = val.substr(0, pos);
               const char* mVal = val.c_str() + pos + 1;
               rtit->Measurements[mKey] = mVal;
-              }
-            else
-              {
+            } else {
               rtit->Measurements[val] = "1";
-              }
             }
-          if ( key == "PASS_REGULAR_EXPRESSION" )
-            {
+          }
+          if (key == "PASS_REGULAR_EXPRESSION") {
             std::vector<std::string> lval;
             cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
-            for ( crit = lval.begin(); crit != lval.end(); ++ 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)));
-              }
             }
-          if ( key == "WORKING_DIRECTORY" )
-            {
+          }
+          if (key == "WORKING_DIRECTORY") {
             rtit->Directory = val;
+          }
+          if (key == "TIMEOUT_AFTER_MATCH") {
+            std::vector<std::string> propArgs;
+            cmSystemTools::ExpandListArgument(val, propArgs);
+            if (propArgs.size() != 2) {
+              cmCTestLog(this->CTest, WARNING,
+                         "TIMEOUT_AFTER_MATCH expects two arguments, found "
+                           << propArgs.size() << std::endl);
+            } else {
+              rtit->AlternateTimeout = atof(propArgs[0].c_str());
+              std::vector<std::string> lval;
+              cmSystemTools::ExpandListArgument(propArgs[1], lval);
+              std::vector<std::string>::iterator crit;
+              for (crit = lval.begin(); crit != lval.end(); ++crit) {
+                rtit->TimeoutRegularExpressions.push_back(
+                  std::pair<cmsys::RegularExpression, std::string>(
+                    cmsys::RegularExpression(crit->c_str()),
+                    std::string(*crit)));
+              }
             }
           }
         }
       }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
 {
   const std::string& testname = args[0];
   cmCTestOptionalLog(this->CTest, DEBUG, "Add test: " << args[0] << std::endl,
-    this->Quiet);
+                     this->Quiet);
 
-  if (this->UseExcludeRegExpFlag &&
-    this->UseExcludeRegExpFirst &&
-    this->ExcludeTestsRegularExpression.find(testname.c_str()))
-    {
+  if (this->UseExcludeRegExpFlag && this->UseExcludeRegExpFirst &&
+      this->ExcludeTestsRegularExpression.find(testname.c_str())) {
     return true;
-    }
-  if ( this->MemCheck )
-    {
+  }
+  if (this->MemCheck) {
     std::vector<std::string>::iterator it;
     bool found = false;
-    for ( it = this->CustomTestsIgnore.begin();
-      it != this->CustomTestsIgnore.end(); ++ it )
-      {
-      if ( *it == testname )
-        {
+    for (it = this->CustomTestsIgnore.begin();
+         it != this->CustomTestsIgnore.end(); ++it) {
+      if (*it == testname) {
         found = true;
         break;
-        }
       }
-    if ( found )
-      {
+    }
+    if (found) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "Ignore memcheck: " << *it << std::endl, this->Quiet);
+                         "Ignore memcheck: " << *it << std::endl, this->Quiet);
       return true;
-      }
     }
-  else
-    {
+  } else {
     std::vector<std::string>::iterator it;
     bool found = false;
-    for ( it = this->CustomTestsIgnore.begin();
-      it != this->CustomTestsIgnore.end(); ++ it )
-      {
-      if ( *it == testname )
-        {
+    for (it = this->CustomTestsIgnore.begin();
+         it != this->CustomTestsIgnore.end(); ++it) {
+      if (*it == testname) {
         found = true;
         break;
-        }
       }
-    if ( found )
-      {
-      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Ignore test: "
-        << *it << std::endl, this->Quiet);
+    }
+    if (found) {
+      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                         "Ignore test: " << *it << std::endl, this->Quiet);
       return true;
-      }
     }
+  }
 
   cmCTestTestProperties test;
   test.Name = testname;
   test.Args = args;
   test.Directory = cmSystemTools::GetCurrentWorkingDirectory();
-  cmCTestOptionalLog(this->CTest, DEBUG, "Set test directory: "
-    << test.Directory << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, DEBUG,
+                     "Set test directory: " << test.Directory << std::endl,
+                     this->Quiet);
 
   test.IsInBasedOnREOptions = true;
   test.WillFail = false;
@@ -2332,17 +1979,12 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
   test.SkipReturnCode = -1;
   test.PreviousRuns = 0;
   if (this->UseIncludeRegExpFlag &&
-    !this->IncludeTestsRegularExpression.find(testname.c_str()))
-    {
+      !this->IncludeTestsRegularExpression.find(testname.c_str())) {
     test.IsInBasedOnREOptions = false;
-    }
-  else if (this->UseExcludeRegExpFlag &&
-    !this->UseExcludeRegExpFirst &&
-    this->ExcludeTestsRegularExpression.find(testname.c_str()))
-    {
+  } else if (this->UseExcludeRegExpFlag && !this->UseExcludeRegExpFirst &&
+             this->ExcludeTestsRegularExpression.find(testname.c_str())) {
     test.IsInBasedOnREOptions = false;
-    }
+  }
   this->TestList.push_back(test);
   return true;
 }
-
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index c635430..4b74ce0 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestTestHandler_h
 #define cmCTestTestHandler_h
 
-
 #include "cmCTestGenericHandler.h"
+
 #include <cmsys/RegularExpression.hxx>
 
 class cmMakefile;
@@ -29,6 +29,7 @@ class cmCTestTestHandler : public cmCTestGenericHandler
   friend class cmCTestRunTest;
   friend class cmCTestMultiProcessHandler;
   friend class cmCTestBatchTestHandler;
+
 public:
   cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler);
 
@@ -53,22 +54,26 @@ public:
   /**
    * This method is called when reading CTest custom file
    */
-  void PopulateCustomVectors(cmMakefile *mf);
+  void PopulateCustomVectors(cmMakefile* mf);
 
   ///! Control the use of the regular expresisons, call these methods to turn
-  ///them on
+  /// them on
   void UseIncludeRegExp();
   void UseExcludeRegExp();
-  void SetIncludeRegExp(const char *);
-  void SetExcludeRegExp(const char *);
+  void SetIncludeRegExp(const char*);
+  void SetExcludeRegExp(const char*);
 
-  void SetMaxIndex(int n) {this->MaxIndex = n;}
-  int GetMaxIndex() {return this->MaxIndex;}
+  void SetMaxIndex(int n) { this->MaxIndex = n; }
+  int GetMaxIndex() { return this->MaxIndex; }
 
   void SetTestOutputSizePassed(int n)
-    { this->CustomMaximumPassedTestOutputSize = n; }
+  {
+    this->CustomMaximumPassedTestOutputSize = n;
+  }
   void SetTestOutputSizeFailed(int n)
-    { this->CustomMaximumFailedTestOutputSize = n; }
+  {
+    this->CustomMaximumFailedTestOutputSize = n;
+  }
 
   ///! pass the -I argument down
   void SetTestsToRunInformation(const char*);
@@ -100,10 +105,12 @@ public:
     std::vector<std::string> Depends;
     std::vector<std::string> AttachedFiles;
     std::vector<std::string> AttachOnFail;
-    std::vector<std::pair<cmsys::RegularExpression,
-                          std::string> > ErrorRegularExpressions;
-    std::vector<std::pair<cmsys::RegularExpression,
-                          std::string> > RequiredRegularExpressions;
+    std::vector<std::pair<cmsys::RegularExpression, std::string> >
+      ErrorRegularExpressions;
+    std::vector<std::pair<cmsys::RegularExpression, std::string> >
+      RequiredRegularExpressions;
+    std::vector<std::pair<cmsys::RegularExpression, std::string> >
+      TimeoutRegularExpressions;
     std::map<std::string, std::string> Measurements;
     bool IsInBasedOnREOptions;
     bool WillFail;
@@ -112,8 +119,9 @@ public:
     bool RunSerial;
     double Timeout;
     bool ExplicitTimeout;
+    double AlternateTimeout;
     int Index;
-    //Requested number of process slots
+    // Requested number of process slots
     int Processors;
     // return code of test which will mark test as "not run"
     int SkipReturnCode;
@@ -128,41 +136,40 @@ public:
     std::string Path;
     std::string Reason;
     std::string FullCommandLine;
-    double      ExecutionTime;
-    int         ReturnValue;
-    int         Status;
-    bool        CompressOutput;
+    double ExecutionTime;
+    int ReturnValue;
+    int Status;
+    bool CompressOutput;
     std::string CompletionStatus;
     std::string Output;
     std::string DartString;
-    int         TestCount;
+    int TestCount;
     cmCTestTestProperties* Properties;
   };
 
   struct cmCTestTestResultLess
   {
-    bool operator() (const cmCTestTestResult &lhs,
-                     const cmCTestTestResult &rhs) const
+    bool operator()(const cmCTestTestResult& lhs,
+                    const cmCTestTestResult& rhs) const
     {
-    return lhs.TestCount < rhs.TestCount;
+      return lhs.TestCount < rhs.TestCount;
     }
   };
 
   // add configurations to a search path for an executable
-  static void AddConfigurations(cmCTest *ctest,
-                                std::vector<std::string> &attempted,
-                                std::vector<std::string> &attemptedConfigs,
-                                std::string filepath,
-                                std::string &filename);
+  static void AddConfigurations(cmCTest* ctest,
+                                std::vector<std::string>& attempted,
+                                std::vector<std::string>& attemptedConfigs,
+                                std::string filepath, std::string& filename);
 
   // full signature static method to find an executable
-  static std::string FindExecutable(cmCTest *ctest,
-                                    const char *testCommand,
-                                    std::string &resultingConfig,
-                                    std::vector<std::string> &extraPaths,
-                                    std::vector<std::string> &failed);
+  static std::string FindExecutable(cmCTest* ctest, const char* testCommand,
+                                    std::string& resultingConfig,
+                                    std::vector<std::string>& extraPaths,
+                                    std::vector<std::string>& failed);
 
   typedef std::vector<cmCTestTestProperties> ListOfTests;
+
 protected:
   // compute a final test list
   virtual int PreProcessHandler();
@@ -178,22 +185,24 @@ protected:
   //! Clean test output to specified length
   bool CleanTestOutput(std::string& output, size_t length);
 
-  double                  ElapsedTestingTime;
+  double ElapsedTestingTime;
 
   typedef std::vector<cmCTestTestResult> TestResultsVector;
-  TestResultsVector    TestResults;
+  TestResultsVector TestResults;
 
   std::vector<std::string> CustomTestsIgnore;
-  std::string             StartTest;
-  std::string             EndTest;
-  unsigned int            StartTestTime;
-  unsigned int            EndTestTime;
+  std::string StartTest;
+  std::string EndTest;
+  unsigned int StartTestTime;
+  unsigned int EndTestTime;
   bool MemCheck;
   int CustomMaximumPassedTestOutputSize;
   int CustomMaximumFailedTestOutputSize;
   int MaxIndex;
+
 public:
-  enum { // Program statuses
+  enum
+  { // Program statuses
     NOT_RUN = 0,
     TIMEOUT,
     SEGFAULT,
@@ -216,8 +225,8 @@ private:
   /**
    * Run the tests for a directory and any subdirectories
    */
-  void ProcessDirectory(std::vector<std::string> &passed,
-                        std::vector<std::string> &failed);
+  void ProcessDirectory(std::vector<std::string>& passed,
+                        std::vector<std::string>& failed);
 
   /**
    * Get the list of tests in directory and subdirectories.
@@ -233,25 +242,15 @@ private:
 
   void UpdateMaxTestNameWidth();
 
-  bool GetValue(const char* tag,
-                std::string& value,
-                std::istream& fin);
-  bool GetValue(const char* tag,
-                int& value,
-                std::istream& fin);
-  bool GetValue(const char* tag,
-                size_t& value,
-                std::istream& fin);
-  bool GetValue(const char* tag,
-                bool& value,
-                std::istream& fin);
-  bool GetValue(const char* tag,
-                double& value,
-                std::istream& fin);
+  bool GetValue(const char* tag, std::string& value, std::istream& fin);
+  bool GetValue(const char* tag, int& value, std::istream& fin);
+  bool GetValue(const char* tag, size_t& value, std::istream& fin);
+  bool GetValue(const char* tag, bool& value, std::istream& fin);
+  bool GetValue(const char* tag, double& value, std::istream& fin);
   /**
    * Find the executable for a test
    */
-  std::string FindTheExecutable(const char *exe);
+  std::string FindTheExecutable(const char* exe);
 
   const char* GetTestStatus(int status);
   void ExpandTestsToRunInformation(size_t numPossibleTests);
@@ -260,7 +259,7 @@ private:
   std::vector<std::string> CustomPreTest;
   std::vector<std::string> CustomPostTest;
 
-  std::vector<int>        TestsToRun;
+  std::vector<int> TestsToRun;
 
   bool UseIncludeLabelRegExpFlag;
   bool UseExcludeLabelRegExpFlag;
diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx
index dfda9f1..f1bae5d 100644
--- a/Source/CTest/cmCTestUpdateCommand.cxx
+++ b/Source/CTest/cmCTestUpdateCommand.cxx
@@ -16,77 +16,81 @@
 
 cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
 {
-  if ( this->Values[ct_SOURCE] )
-    {
-    this->CTest->SetCTestConfiguration("SourceDirectory",
-      cmSystemTools::CollapseFullPath(
-        this->Values[ct_SOURCE]).c_str(), this->Quiet);
-    }
-  else
-    {
-    this->CTest->SetCTestConfiguration("SourceDirectory",
+  if (this->Values[ct_SOURCE]) {
+    this->CTest->SetCTestConfiguration(
+      "SourceDirectory",
+      cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
+      this->Quiet);
+  } else {
+    this->CTest->SetCTestConfiguration(
+      "SourceDirectory",
       cmSystemTools::CollapseFullPath(
-        this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str(),
+        this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"))
+        .c_str(),
       this->Quiet);
-    }
-  std::string source_dir
-    = this->CTest->GetCTestConfiguration("SourceDirectory");
+  }
+  std::string source_dir =
+    this->CTest->GetCTestConfiguration("SourceDirectory");
 
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "UpdateCommand", "CTEST_UPDATE_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "UpdateOptions", "CTEST_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "CVSCommand", "CTEST_CVS_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "SVNCommand", "CTEST_SVN_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "SVNOptions", "CTEST_SVN_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "BZRCommand", "CTEST_BZR_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "P4Command", "CTEST_P4_COMMAND", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "P4Client", "CTEST_P4_CLIENT", this->Quiet);
-  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
-    "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "UpdateOptions", "CTEST_UPDATE_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "CVSCommand", "CTEST_CVS_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "SVNCommand", "CTEST_SVN_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "SVNOptions", "CTEST_SVN_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "BZRCommand", "CTEST_BZR_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY",
+    this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "P4Command", "CTEST_P4_COMMAND", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "P4Client", "CTEST_P4_CLIENT", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(
+    this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
 
-  cmCTestGenericHandler* handler
-    = this->CTest->GetInitializedHandler("update");
-  if ( !handler )
-    {
+  cmCTestGenericHandler* handler =
+    this->CTest->GetInitializedHandler("update");
+  if (!handler) {
     this->SetError("internal CTest error. Cannot instantiate update handler");
     return 0;
-    }
+  }
   handler->SetCommand(this);
-  if ( source_dir.empty() )
-    {
+  if (source_dir.empty()) {
     this->SetError("source directory not specified. Please use SOURCE tag");
     return 0;
-    }
+  }
   handler->SetOption("SourceDirectory", source_dir.c_str());
   handler->SetQuiet(this->Quiet);
   return handler;
 }
-
-
diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h
index fb80333..e807193 100644
--- a/Source/CTest/cmCTestUpdateCommand.h
+++ b/Source/CTest/cmCTestUpdateCommand.h
@@ -22,24 +22,23 @@
 class cmCTestUpdateCommand : public cmCTestHandlerCommand
 {
 public:
-
   cmCTestUpdateCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestUpdateCommand* ni = new cmCTestUpdateCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_update";}
+  virtual std::string GetName() const { return "ctest_update"; }
 
   cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand);
 
@@ -47,5 +46,4 @@ protected:
   cmCTestGenericHandler* InitializeHandler();
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index bf2f34a..4eaa16b 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -12,23 +12,23 @@
 
 #include "cmCTestUpdateHandler.h"
 
+#include "cmCLocaleEnvironmentScope.h"
 #include "cmCTest.h"
-#include "cmake.h"
-#include "cmMakefile.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
 #include "cmVersion.h"
-#include "cmGeneratedFileStream.h"
 #include "cmXMLParser.h"
 #include "cmXMLWriter.h"
-#include "cmCLocaleEnvironmentScope.h"
+#include "cmake.h"
 
-#include "cmCTestVC.h"
-#include "cmCTestCVS.h"
-#include "cmCTestSVN.h"
 #include "cmCTestBZR.h"
+#include "cmCTestCVS.h"
 #include "cmCTestGIT.h"
 #include "cmCTestHG.h"
 #include "cmCTestP4.h"
+#include "cmCTestSVN.h"
+#include "cmCTestVC.h"
 
 #include <cmsys/auto_ptr.hxx>
 
@@ -40,38 +40,27 @@
 #include "windows.h"
 #endif
 
-#include <stdlib.h>
-#include <math.h>
 #include <float.h>
+#include <math.h>
+#include <stdlib.h>
 
-//----------------------------------------------------------------------
-static const char* cmCTestUpdateHandlerUpdateStrings[] =
-{
-  "Unknown",
-  "CVS",
-  "SVN",
-  "BZR",
-  "GIT",
-  "HG",
-  "P4"
+static const char* cmCTestUpdateHandlerUpdateStrings[] = {
+  "Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
 };
 
 static const char* cmCTestUpdateHandlerUpdateToString(int type)
 {
-  if ( type < cmCTestUpdateHandler::e_UNKNOWN ||
-    type >= cmCTestUpdateHandler::e_LAST )
-    {
+  if (type < cmCTestUpdateHandler::e_UNKNOWN ||
+      type >= cmCTestUpdateHandler::e_LAST) {
     return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN];
-    }
+  }
   return cmCTestUpdateHandlerUpdateStrings[type];
 }
 
-//----------------------------------------------------------------------
 cmCTestUpdateHandler::cmCTestUpdateHandler()
 {
 }
 
-//----------------------------------------------------------------------
 void cmCTestUpdateHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -79,78 +68,62 @@ void cmCTestUpdateHandler::Initialize()
   this->UpdateType = e_CVS;
 }
 
-//----------------------------------------------------------------------
 int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
 {
-  cmCTestOptionalLog(this->CTest, DEBUG,
-    "Determine update type from command: " << cmd << " and type: " << type <<
-    std::endl, this->Quiet);
-  if ( type && *type )
-    {
-    cmCTestOptionalLog(this->CTest, DEBUG, "Type specified: " << type <<
-      std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, DEBUG, "Determine update type from command: "
+                       << cmd << " and type: " << type << std::endl,
+                     this->Quiet);
+  if (type && *type) {
+    cmCTestOptionalLog(this->CTest, DEBUG,
+                       "Type specified: " << type << std::endl, this->Quiet);
     std::string stype = cmSystemTools::LowerCase(type);
-    if ( stype.find("cvs") != std::string::npos )
-      {
+    if (stype.find("cvs") != std::string::npos) {
       return cmCTestUpdateHandler::e_CVS;
-      }
-    if ( stype.find("svn") != std::string::npos )
-      {
+    }
+    if (stype.find("svn") != std::string::npos) {
       return cmCTestUpdateHandler::e_SVN;
-      }
-    if ( stype.find("bzr") != std::string::npos )
-      {
+    }
+    if (stype.find("bzr") != std::string::npos) {
       return cmCTestUpdateHandler::e_BZR;
-      }
-    if ( stype.find("git") != std::string::npos )
-      {
+    }
+    if (stype.find("git") != std::string::npos) {
       return cmCTestUpdateHandler::e_GIT;
-      }
-    if ( stype.find("hg") != std::string::npos )
-      {
+    }
+    if (stype.find("hg") != std::string::npos) {
       return cmCTestUpdateHandler::e_HG;
-      }
-    if ( stype.find("p4") != std::string::npos )
-      {
+    }
+    if (stype.find("p4") != std::string::npos) {
       return cmCTestUpdateHandler::e_P4;
-      }
     }
-  else
-    {
-    cmCTestOptionalLog(this->CTest, DEBUG,
+  } else {
+    cmCTestOptionalLog(
+      this->CTest, DEBUG,
       "Type not specified, check command: " << cmd << std::endl, this->Quiet);
     std::string stype = cmSystemTools::LowerCase(cmd);
-    if ( stype.find("cvs") != std::string::npos )
-      {
+    if (stype.find("cvs") != std::string::npos) {
       return cmCTestUpdateHandler::e_CVS;
-      }
-    if ( stype.find("svn") != std::string::npos )
-      {
+    }
+    if (stype.find("svn") != std::string::npos) {
       return cmCTestUpdateHandler::e_SVN;
-      }
-    if ( stype.find("bzr") != std::string::npos )
-      {
+    }
+    if (stype.find("bzr") != std::string::npos) {
       return cmCTestUpdateHandler::e_BZR;
-      }
-    if ( stype.find("git") != std::string::npos )
-      {
+    }
+    if (stype.find("git") != std::string::npos) {
       return cmCTestUpdateHandler::e_GIT;
-      }
-    if ( stype.find("hg") != std::string::npos )
-      {
+    }
+    if (stype.find("hg") != std::string::npos) {
       return cmCTestUpdateHandler::e_HG;
-      }
-    if ( stype.find("p4") != std::string::npos )
-      {
+    }
+    if (stype.find("p4") != std::string::npos) {
       return cmCTestUpdateHandler::e_P4;
-      }
     }
+  }
   return cmCTestUpdateHandler::e_UNKNOWN;
 }
 
-//----------------------------------------------------------------------
-//clearly it would be nice if this were broken up into a few smaller
-//functions and commented...
+// clearly it would be nice if this were broken up into a few smaller
+// functions and commented...
 int cmCTestUpdateHandler::ProcessHandler()
 {
   // Make sure VCS tool messages are in English so we can parse them.
@@ -159,46 +132,57 @@ int cmCTestUpdateHandler::ProcessHandler()
 
   // Get source dir
   const char* sourceDirectory = this->GetOption("SourceDirectory");
-  if ( !sourceDirectory )
-    {
+  if (!sourceDirectory) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot find SourceDirectory  key in the DartConfiguration.tcl"
-      << std::endl);
+               "Cannot find SourceDirectory  key in the DartConfiguration.tcl"
+                 << std::endl);
     return -1;
-    }
+  }
 
   cmGeneratedFileStream ofs;
-  if ( !this->CTest->GetShowOnly() )
-    {
+  if (!this->CTest->GetShowOnly()) {
     this->StartLogFile("Update", ofs);
-    }
+  }
 
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-    "   Updating the repository: " << sourceDirectory << std::endl,
-    this->Quiet);
+                     "   Updating the repository: " << sourceDirectory
+                                                    << std::endl,
+                     this->Quiet);
 
-  if(!this->SelectVCS())
-    {
+  if (!this->SelectVCS()) {
     return -1;
-    }
+  }
 
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Use "
-    << cmCTestUpdateHandlerUpdateToString(this->UpdateType)
-    << " repository type"
-    << std::endl;, this->Quiet);
+                       << cmCTestUpdateHandlerUpdateToString(this->UpdateType)
+                       << " repository type" << std::endl;
+                     , this->Quiet);
 
   // Create an object to interact with the VCS tool.
   cmsys::auto_ptr<cmCTestVC> vc;
-  switch (this->UpdateType)
-    {
-    case e_CVS: vc.reset(new cmCTestCVS(this->CTest, ofs)); break;
-    case e_SVN: vc.reset(new cmCTestSVN(this->CTest, ofs)); break;
-    case e_BZR: vc.reset(new cmCTestBZR(this->CTest, ofs)); break;
-    case e_GIT: vc.reset(new cmCTestGIT(this->CTest, ofs)); break;
-    case e_HG:  vc.reset(new cmCTestHG(this->CTest, ofs)); break;
-    case e_P4:  vc.reset(new cmCTestP4(this->CTest, ofs)); break;
-    default:    vc.reset(new cmCTestVC(this->CTest, ofs));  break;
-    }
+  switch (this->UpdateType) {
+    case e_CVS:
+      vc.reset(new cmCTestCVS(this->CTest, ofs));
+      break;
+    case e_SVN:
+      vc.reset(new cmCTestSVN(this->CTest, ofs));
+      break;
+    case e_BZR:
+      vc.reset(new cmCTestBZR(this->CTest, ofs));
+      break;
+    case e_GIT:
+      vc.reset(new cmCTestGIT(this->CTest, ofs));
+      break;
+    case e_HG:
+      vc.reset(new cmCTestHG(this->CTest, ofs));
+      break;
+    case e_P4:
+      vc.reset(new cmCTestP4(this->CTest, ofs));
+      break;
+    default:
+      vc.reset(new cmCTestVC(this->CTest, ofs));
+      break;
+  }
   vc->SetCommandLineTool(this->UpdateCommand);
   vc->SetSourceDirectory(sourceDirectory);
 
@@ -209,139 +193,130 @@ int cmCTestUpdateHandler::ProcessHandler()
   // Now update repository and remember what files were updated
   //
   cmGeneratedFileStream os;
-  if(!this->StartResultingXML(cmCTest::PartUpdate, "Update", os))
-    {
+  if (!this->StartResultingXML(cmCTest::PartUpdate, "Update", os)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file"
-      << std::endl);
+                 << std::endl);
     return -1;
-    }
+  }
   std::string start_time = this->CTest->CurrentTime();
   unsigned int start_time_time =
     static_cast<unsigned int>(cmSystemTools::GetTime());
   double elapsed_time_start = cmSystemTools::GetTime();
 
   bool updated = vc->Update();
-  std::string buildname = cmCTest::SafeBuildIdField(
-    this->CTest->GetCTestConfiguration("BuildName"));
+  std::string buildname =
+    cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
 
   cmXMLWriter xml(os);
   xml.StartDocument();
   xml.StartElement("Update");
   xml.Attribute("mode", "Client");
   xml.Attribute("Generator",
-    std::string("ctest-") + cmVersion::GetCMakeVersion());
+                std::string("ctest-") + cmVersion::GetCMakeVersion());
   xml.Element("Site", this->CTest->GetCTestConfiguration("Site"));
   xml.Element("BuildName", buildname);
   xml.Element("BuildStamp", this->CTest->GetCurrentTag() + "-" +
-    this->CTest->GetTestModelString());
+                this->CTest->GetTestModelString());
   xml.Element("StartDateTime", start_time);
   xml.Element("StartTime", start_time_time);
   xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
   xml.Element("UpdateType",
-    cmCTestUpdateHandlerUpdateToString(this->UpdateType));
+              cmCTestUpdateHandlerUpdateToString(this->UpdateType));
 
   vc->WriteXML(xml);
 
   int localModifications = 0;
   int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated);
-  if(numUpdated)
-    {
+  if (numUpdated) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "   Found " << numUpdated << " updated files\n", this->Quiet);
-    }
-  if(int numModified = vc->GetPathCount(cmCTestVC::PathModified))
-    {
-    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-      "   Found " << numModified << " locally modified files\n", this->Quiet);
+                       "   Found " << numUpdated << " updated files\n",
+                       this->Quiet);
+  }
+  if (int numModified = vc->GetPathCount(cmCTestVC::PathModified)) {
+    cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "   Found "
+                         << numModified << " locally modified files\n",
+                       this->Quiet);
     localModifications += numModified;
-    }
-  if(int numConflicting = vc->GetPathCount(cmCTestVC::PathConflicting))
-    {
+  }
+  if (int numConflicting = vc->GetPathCount(cmCTestVC::PathConflicting)) {
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
-    "   Found " << numConflicting << " conflicting files\n", this->Quiet);
+                       "   Found " << numConflicting << " conflicting files\n",
+                       this->Quiet);
     localModifications += numConflicting;
-    }
+  }
 
   cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
   std::string end_time = this->CTest->CurrentTime();
   xml.Element("EndDateTime", end_time);
   xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
-  xml.Element("ElapsedMinutes",
-    static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+  xml.Element(
+    "ElapsedMinutes",
+    static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
+      10.0);
 
   xml.StartElement("UpdateReturnStatus");
-  if(localModifications)
-    {
+  if (localModifications) {
     xml.Content("Update error: "
-      "There are modified or conflicting files in the repository");
+                "There are modified or conflicting files in the repository");
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "   There are modified or conflicting files in the repository"
-      << std::endl);
-    }
-  if(!updated)
-    {
+               "   There are modified or conflicting files in the repository"
+                 << std::endl);
+  }
+  if (!updated) {
     xml.Content("Update command failed:\n");
     xml.Content(vc->GetUpdateCommandLine());
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Update command failed: "
-               << vc->GetUpdateCommandLine() << "\n");
-    }
+                 << vc->GetUpdateCommandLine() << "\n");
+  }
   xml.EndElement(); // UpdateReturnStatus
   xml.EndElement(); // Update
   xml.EndDocument();
-  return updated? numUpdated : -1;
+  return updated ? numUpdated : -1;
 }
 
-//----------------------------------------------------------------------
 int cmCTestUpdateHandler::DetectVCS(const char* dir)
 {
   std::string sourceDirectory = dir;
-  cmCTestOptionalLog(this->CTest, DEBUG, "Check directory: "
-    << sourceDirectory << std::endl, this->Quiet);
+  cmCTestOptionalLog(this->CTest, DEBUG,
+                     "Check directory: " << sourceDirectory << std::endl,
+                     this->Quiet);
   sourceDirectory += "/.svn";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_SVN;
-    }
+  }
   sourceDirectory = dir;
   sourceDirectory += "/CVS";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_CVS;
-    }
+  }
   sourceDirectory = dir;
   sourceDirectory += "/.bzr";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_BZR;
-    }
+  }
   sourceDirectory = dir;
   sourceDirectory += "/.git";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_GIT;
-    }
+  }
   sourceDirectory = dir;
   sourceDirectory += "/.hg";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_HG;
-    }
+  }
   sourceDirectory = dir;
   sourceDirectory += "/.p4";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_P4;
-    }
+  }
   sourceDirectory = dir;
   sourceDirectory += "/.p4config";
-  if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
-    {
+  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
     return cmCTestUpdateHandler::e_P4;
-    }
+  }
   return cmCTestUpdateHandler::e_UNKNOWN;
 }
 
-//----------------------------------------------------------------------
 bool cmCTestUpdateHandler::SelectVCS()
 {
   // Get update command
@@ -349,45 +324,53 @@ bool cmCTestUpdateHandler::SelectVCS()
 
   // Detect the VCS managing the source tree.
   this->UpdateType = this->DetectVCS(this->GetOption("SourceDirectory"));
-  if (this->UpdateType == e_UNKNOWN)
-    {
+  if (this->UpdateType == e_UNKNOWN) {
     // The source tree does not have a recognized VCS.  Check the
     // configuration value or command name.
-    this->UpdateType = this->DetermineType(this->UpdateCommand.c_str(),
+    this->UpdateType = this->DetermineType(
+      this->UpdateCommand.c_str(),
       this->CTest->GetCTestConfiguration("UpdateType").c_str());
-    }
+  }
 
   // If no update command was specified, lookup one for this VCS tool.
-  if (this->UpdateCommand.empty())
-    {
+  if (this->UpdateCommand.empty()) {
     const char* key = 0;
-    switch (this->UpdateType)
-      {
-      case e_CVS: key = "CVSCommand"; break;
-      case e_SVN: key = "SVNCommand"; break;
-      case e_BZR: key = "BZRCommand"; break;
-      case e_GIT: key = "GITCommand"; break;
-      case e_HG:  key = "HGCommand";  break;
-      case e_P4:  key = "P4Command";  break;
-      default: break;
-      }
-    if (key)
-      {
+    switch (this->UpdateType) {
+      case e_CVS:
+        key = "CVSCommand";
+        break;
+      case e_SVN:
+        key = "SVNCommand";
+        break;
+      case e_BZR:
+        key = "BZRCommand";
+        break;
+      case e_GIT:
+        key = "GITCommand";
+        break;
+      case e_HG:
+        key = "HGCommand";
+        break;
+      case e_P4:
+        key = "P4Command";
+        break;
+      default:
+        break;
+    }
+    if (key) {
       this->UpdateCommand = this->CTest->GetCTestConfiguration(key);
-      }
-    if (this->UpdateCommand.empty())
-      {
+    }
+    if (this->UpdateCommand.empty()) {
       std::ostringstream e;
       e << "Cannot find UpdateCommand ";
-      if (key)
-        {
+      if (key) {
         e << "or " << key;
-        }
+      }
       e << " configuration key.";
       cmCTestLog(this->CTest, ERROR_MESSAGE, e.str() << std::endl);
       return false;
-      }
     }
+  }
 
   return true;
 }
diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h
index d2423c0..d44e619 100644
--- a/Source/CTest/cmCTestUpdateHandler.h
+++ b/Source/CTest/cmCTestUpdateHandler.h
@@ -13,8 +13,8 @@
 #ifndef cmCTestUpdateHandler_h
 #define cmCTestUpdateHandler_h
 
-
 #include "cmCTestGenericHandler.h"
+
 #include "cmListFileCache.h"
 
 /** \class cmCTestUpdateHandler
@@ -33,7 +33,8 @@ public:
 
   cmCTestUpdateHandler();
 
-  enum {
+  enum
+  {
     e_UNKNOWN = 0,
     e_CVS,
     e_SVN,
@@ -51,9 +52,12 @@ public:
 
 private:
   // Some structures needed for update
-  struct StringPair :
-    public std::pair<std::string, std::string>{};
-  struct UpdateFiles : public std::vector<StringPair>{};
+  struct StringPair : public std::pair<std::string, std::string>
+  {
+  };
+  struct UpdateFiles : public std::vector<StringPair>
+  {
+  };
 
   // Determine the type of version control
   int DetermineType(const char* cmd, const char* type);
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index f5000dd..c85db02 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -17,59 +17,47 @@
 
 cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
 {
-  cmCTestGenericHandler* handler
-    = this->CTest->GetInitializedHandler("upload");
-  if ( !handler )
-    {
+  cmCTestGenericHandler* handler =
+    this->CTest->GetInitializedHandler("upload");
+  if (!handler) {
     this->SetError("internal CTest error. Cannot instantiate upload handler");
     return 0;
-    }
+  }
   static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
 
   handler->SetQuiet(this->Quiet);
   return handler;
 }
 
-
-//----------------------------------------------------------------------------
 bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
 {
-  if(arg == "FILES")
-    {
+  if (arg == "FILES") {
     this->ArgumentDoing = ArgumentDoingFiles;
     return true;
-    }
-  if(arg == "QUIET")
-    {
+  }
+  if (arg == "QUIET") {
     this->ArgumentDoing = ArgumentDoingNone;
     this->Quiet = true;
     return true;
-    }
+  }
   return false;
 }
 
-
-//----------------------------------------------------------------------------
 bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
 {
-  if(this->ArgumentDoing == ArgumentDoingFiles)
-    {
-    std::string filename(arg);
-    if(cmSystemTools::FileExists(filename.c_str()))
-      {
-      this->Files.insert(filename);
+  if (this->ArgumentDoing == ArgumentDoingFiles) {
+    if (cmSystemTools::FileExists(arg.c_str())) {
+      this->Files.insert(arg);
       return true;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
-      e << "File \"" << filename << "\" does not exist. Cannot submit "
-          << "a non-existent file.";
+      e << "File \"" << arg << "\" does not exist. Cannot submit "
+        << "a non-existent file.";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       this->ArgumentDoing = ArgumentDoingError;
       return false;
-      }
     }
+  }
 
   // Look for other arguments.
   return this->Superclass::CheckArgumentValue(arg);
diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h
index 4a07608..551be2b 100644
--- a/Source/CTest/cmCTestUploadCommand.h
+++ b/Source/CTest/cmCTestUploadCommand.h
@@ -13,6 +13,7 @@
 #define cmCTestUploadCommand_h
 
 #include "cmCTestHandlerCommand.h"
+
 #include "cmCTest.h"
 
 /** \class cmCTestUpload
@@ -24,26 +25,23 @@
 class cmCTestUploadCommand : public cmCTestHandlerCommand
 {
 public:
-
-  cmCTestUploadCommand()
-    {
-    }
+  cmCTestUploadCommand() {}
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     cmCTestUploadCommand* ni = new cmCTestUploadCommand;
     ni->CTest = this->CTest;
     ni->CTestScriptHandler = this->CTestScriptHandler;
     return ni;
-    }
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "ctest_upload";}
+  virtual std::string GetName() const { return "ctest_upload"; }
 
   cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand);
 
@@ -62,5 +60,4 @@ protected:
   cmCTest::SetOfStrings Files;
 };
 
-
 #endif
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index 5c6b229..6a3b830 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -15,13 +15,11 @@
 #include "cmVersion.h"
 #include "cmXMLWriter.h"
 
-//----------------------------------------------------------------------------
 cmCTestUploadHandler::cmCTestUploadHandler()
 {
   this->Initialize();
 }
 
-//----------------------------------------------------------------------------
 void cmCTestUploadHandler::Initialize()
 {
   this->Superclass::Initialize();
@@ -33,40 +31,38 @@ void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files)
   this->Files = files;
 }
 
-//----------------------------------------------------------------------------
 int cmCTestUploadHandler::ProcessHandler()
 {
   cmGeneratedFileStream ofs;
-  if ( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
-                                    "Upload.xml", ofs))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot open Upload.xml file" << std::endl);
+  if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), "Upload.xml",
+                                   ofs)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open Upload.xml file"
+                 << std::endl);
     return -1;
-    }
-  std::string buildname = cmCTest::SafeBuildIdField(
-    this->CTest->GetCTestConfiguration("BuildName"));
+  }
+  std::string buildname =
+    cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
   cmCTest::SetOfStrings::const_iterator it;
 
   cmXMLWriter xml(ofs);
   xml.StartDocument();
-  xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
-    "href=\"Dart/Source/Server/XSL/Build.xsl "
-    "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
+  xml.ProcessingInstruction("xml-stylesheet",
+                            "type=\"text/xsl\" "
+                            "href=\"Dart/Source/Server/XSL/Build.xsl "
+                            "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
   xml.StartElement("Site");
   xml.Attribute("BuildName", buildname);
-  xml.Attribute("BuildStamp",
-    this->CTest->GetCurrentTag() + "-" + this->CTest->GetTestModelString());
+  xml.Attribute("BuildStamp", this->CTest->GetCurrentTag() + "-" +
+                  this->CTest->GetTestModelString());
   xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
   xml.Attribute("Generator",
-    std::string("ctest") + cmVersion::GetCMakeVersion());
+                std::string("ctest") + cmVersion::GetCMakeVersion());
   this->CTest->AddSiteProperties(xml);
   xml.StartElement("Upload");
 
-  for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
-    {
+  for (it = this->Files.begin(); it != this->Files.end(); it++) {
     cmCTestOptionalLog(this->CTest, OUTPUT,
-      "\tUpload file: " << *it << std::endl, this->Quiet);
+                       "\tUpload file: " << *it << std::endl, this->Quiet);
     xml.StartElement("File");
     xml.Attribute("filename", *it);
     xml.StartElement("Content");
@@ -74,7 +70,7 @@ int cmCTestUploadHandler::ProcessHandler()
     xml.Content(this->CTest->Base64EncodeFile(*it));
     xml.EndElement(); // Content
     xml.EndElement(); // File
-    }
+  }
   xml.EndElement(); // Upload
   xml.EndElement(); // Site
   xml.EndDocument();
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 8eff4d6..e9934e5 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -17,8 +17,9 @@
 
 #include <cmsys/Process.h>
 
-//----------------------------------------------------------------------------
-cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
+cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log)
+  : CTest(ct)
+  , Log(log)
 {
   this->PathCount[PathUpdated] = 0;
   this->PathCount[PathModified] = 0;
@@ -28,24 +29,20 @@ cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
   this->Unknown.Rev = "Unknown";
 }
 
-//----------------------------------------------------------------------------
 cmCTestVC::~cmCTestVC()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmCTestVC::SetCommandLineTool(std::string const& tool)
 {
   this->CommandLineTool = tool;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestVC::SetSourceDirectory(std::string const& dir)
 {
   this->SourceDirectory = dir;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestVC::InitialCheckout(const char* command)
 {
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
@@ -55,21 +52,19 @@ bool cmCTestVC::InitialCheckout(const char* command)
   std::string parent = cmSystemTools::GetFilenamePath(this->SourceDirectory);
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              "   Perform checkout in directory: " << parent << "\n");
-  if(!cmSystemTools::MakeDirectory(parent.c_str()))
-    {
+  if (!cmSystemTools::MakeDirectory(parent.c_str())) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot create directory: " << parent << std::endl);
     return false;
-    }
+  }
 
   // Construct the initial checkout command line.
   std::vector<std::string> args = cmSystemTools::ParseArguments(command);
   std::vector<char const*> vc_co;
-  for(std::vector<std::string>::const_iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai) {
     vc_co.push_back(ai->c_str());
-    }
+  }
   vc_co.push_back(0);
 
   // Run the initial checkout command and log its output.
@@ -78,15 +73,13 @@ bool cmCTestVC::InitialCheckout(const char* command)
   OutputLogger err(this->Log, "co-err> ");
   bool result = this->RunChild(&vc_co[0], &out, &err, parent.c_str());
   this->Log << "--- End Initial Checkout ---\n";
-  if(!result)
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Initial checkout failed!" << std::endl);
-    }
+  if (!result) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Initial checkout failed!"
+                 << std::endl);
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
                          OutputParser* err, const char* workDir)
 {
@@ -94,7 +87,7 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetCommand(cp, cmd);
-  workDir = workDir? workDir : this->SourceDirectory.c_str();
+  workDir = workDir ? workDir : this->SourceDirectory.c_str();
   cmsysProcess_SetWorkingDirectory(cp, workDir);
   this->RunProcess(cp, out, err);
   int result = cmsysProcess_GetExitValue(cp);
@@ -102,36 +95,31 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
   return result == 0;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
 {
   std::ostringstream line;
   const char* sep = "";
-  for(const char* const* arg = cmd; *arg; ++arg)
-    {
+  for (const char* const* arg = cmd; *arg; ++arg) {
     line << sep << "\"" << *arg << "\"";
     sep = " ";
-    }
+  }
   return line.str();
 }
 
-//----------------------------------------------------------------------------
-bool cmCTestVC::RunUpdateCommand(char const* const* cmd,
-                                 OutputParser* out, OutputParser* err)
+bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out,
+                                 OutputParser* err)
 {
   // Report the command line.
   this->UpdateCommandLine = this->ComputeCommandLine(cmd);
-  if(this->CTest->GetShowOnly())
-    {
+  if (this->CTest->GetShowOnly()) {
     this->Log << this->UpdateCommandLine << "\n";
     return true;
-    }
+  }
 
   // Run the command.
   return this->RunChild(cmd, out, err);
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTestVC::GetNightlyTime()
 {
   // Get the nightly start time corresponding to the current dau.
@@ -139,17 +127,11 @@ std::string cmCTestVC::GetNightlyTime()
     this->CTest->GetCTestConfiguration("NightlyStartTime"),
     this->CTest->GetTomorrowTag());
   char current_time[1024];
-  sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d",
-          t->tm_year + 1900,
-          t->tm_mon + 1,
-          t->tm_mday,
-          t->tm_hour,
-          t->tm_min,
-          t->tm_sec);
+  sprintf(current_time, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900,
+          t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
   return std::string(current_time);
 }
 
-//----------------------------------------------------------------------------
 void cmCTestVC::Cleanup()
 {
   this->Log << "--- Begin Cleanup ---\n";
@@ -157,43 +139,37 @@ void cmCTestVC::Cleanup()
   this->Log << "--- End Cleanup ---\n";
 }
 
-//----------------------------------------------------------------------------
 void cmCTestVC::CleanupImpl()
 {
   // We do no cleanup by default.
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestVC::Update()
 {
   bool result = true;
   // if update version only is on then do not actually update,
   // just note the current version and finish
-  if(!cmSystemTools::IsOn(
-       this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str()))
-    {
+  if (!cmSystemTools::IsOn(
+        this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str())) {
     this->NoteOldRevision();
     this->Log << "--- Begin Update ---\n";
     result = this->UpdateImpl();
     this->Log << "--- End Update ---\n";
-    }
+  }
   this->NoteNewRevision();
   return result;
 }
 
-//----------------------------------------------------------------------------
 void cmCTestVC::NoteOldRevision()
 {
   // We do nothing by default.
 }
 
-//----------------------------------------------------------------------------
 void cmCTestVC::NoteNewRevision()
 {
   // We do nothing by default.
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestVC::UpdateImpl()
 {
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -201,7 +177,6 @@ bool cmCTestVC::UpdateImpl()
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestVC::WriteXML(cmXMLWriter& xml)
 {
   this->Log << "--- Begin Revisions ---\n";
@@ -210,7 +185,6 @@ bool cmCTestVC::WriteXML(cmXMLWriter& xml)
   return result;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTestVC::WriteXMLUpdates(cmXMLWriter&)
 {
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -218,16 +192,13 @@ bool cmCTestVC::WriteXMLUpdates(cmXMLWriter&)
   return true;
 }
 
-//----------------------------------------------------------------------------
-void cmCTestVC::WriteXMLEntry(cmXMLWriter& xml,
-                              std::string const& path,
-                              std::string const& name,
-                              std::string const& full,
+void cmCTestVC::WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
+                              std::string const& name, std::string const& full,
                               File const& f)
 {
-  static const char* desc[3] = { "Updated", "Modified", "Conflicting"};
-  Revision const& rev = f.Rev? *f.Rev : this->Unknown;
-  std::string prior = f.PriorRev? f.PriorRev->Rev : std::string("Unknown");
+  static const char* desc[3] = { "Updated", "Modified", "Conflicting" };
+  Revision const& rev = f.Rev ? *f.Rev : this->Unknown;
+  std::string prior = f.PriorRev ? f.PriorRev->Rev : std::string("Unknown");
   xml.StartElement(desc[f.Status]);
   xml.Element("File", name);
   xml.Element("Directory", path);
diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h
index bc89302..4ae38eb 100644
--- a/Source/CTest/cmCTestVC.h
+++ b/Source/CTest/cmCTestVC.h
@@ -21,7 +21,7 @@ class cmXMLWriter;
  * \brief Base class for version control system handlers
  *
  */
-class cmCTestVC: public cmProcessTools
+class cmCTestVC : public cmProcessTools
 {
 public:
   /** Construct with a CTest instance and update log stream.  */
@@ -49,13 +49,20 @@ public:
 
   /** Get the command line used by the Update method.  */
   std::string const& GetUpdateCommandLine() const
-    { return this->UpdateCommandLine; }
+  {
+    return this->UpdateCommandLine;
+  }
 
   /** Write Update.xml entries for the updates found.  */
   bool WriteXML(cmXMLWriter& xml);
 
   /** Enumerate non-trivial working tree states during update.  */
-  enum PathStatus { PathUpdated, PathModified, PathConflicting };
+  enum PathStatus
+  {
+    PathUpdated,
+    PathModified,
+    PathConflicting
+  };
 
   /** Get the number of working tree paths in each state after update.  */
   int GetPathCount(PathStatus s) const { return this->PathCount[s]; }
@@ -69,7 +76,8 @@ protected:
   virtual bool WriteXMLUpdates(cmXMLWriter& xml);
 
 #if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510
-public: // Sun CC 5.1 needs help to allow cmCTestSVN::Revision to see this
+  // Sun CC 5.1 needs help to allow cmCTestSVN::Revision to see this
+public:
 #endif
   /** Basic information about one revision of a tree or file.  */
   struct Revision
@@ -94,21 +102,30 @@ protected:
     PathStatus Status;
     Revision const* Rev;
     Revision const* PriorRev;
-    File(): Status(PathUpdated), Rev(0), PriorRev(0) {}
-    File(PathStatus status, Revision const* rev, Revision const* priorRev):
-      Status(status), Rev(rev), PriorRev(priorRev) {}
+    File()
+      : Status(PathUpdated)
+      , Rev(0)
+      , PriorRev(0)
+    {
+    }
+    File(PathStatus status, Revision const* rev, Revision const* priorRev)
+      : Status(status)
+      , Rev(rev)
+      , PriorRev(priorRev)
+    {
+    }
   };
 
   /** Convert a list of arguments to a human-readable command line.  */
   static std::string ComputeCommandLine(char const* const* cmd);
 
   /** Run a command line and send output to given parsers.  */
-  bool RunChild(char const* const* cmd, OutputParser* out,
-                OutputParser* err, const char* workDir = 0);
+  bool RunChild(char const* const* cmd, OutputParser* out, OutputParser* err,
+                const char* workDir = 0);
 
   /** Run VC update command line and send output to given parsers.  */
-  bool RunUpdateCommand(char const* const* cmd,
-                        OutputParser* out, OutputParser* err = 0);
+  bool RunUpdateCommand(char const* const* cmd, OutputParser* out,
+                        OutputParser* err = 0);
 
   /** Write xml element for one file.  */
   void WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx
index 1edd01f..fa539e4 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.cxx
+++ b/Source/CTest/cmParseBlanketJSCoverage.cxx
@@ -9,85 +9,74 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include "cmStandardIncludes.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include "cmSystemTools.h"
 #include "cmParseBlanketJSCoverage.h"
+
+#include "cmSystemTools.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
-
+#include <cmsys/Glob.hxx>
+#include <stdio.h>
+#include <stdlib.h>
 
 class cmParseBlanketJSCoverage::JSONParser
-  {
+{
 public:
-  typedef cmCTestCoverageHandlerContainer::
-      SingleFileCoverageVector FileLinesType;
+  typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+    FileLinesType;
   JSONParser(cmCTestCoverageHandlerContainer& cont)
-      : Coverage(cont)
-    {
-    }
+    : Coverage(cont)
+  {
+  }
 
-  virtual ~JSONParser()
-    {
-    }
+  virtual ~JSONParser() {}
 
   std::string getValue(std::string line, int type)
-    {
+  {
     size_t begIndex;
     size_t endIndex;
     endIndex = line.rfind(',');
     begIndex = line.find_first_of(':');
-    if(type == 0)
-      {
+    if (type == 0) {
       //  A unique substring to remove the extra characters
       //  around the files name in the JSON (extra " and ,)
       std::string foundFileName =
-          line.substr(begIndex+3,endIndex-(begIndex+4));
+        line.substr(begIndex + 3, endIndex - (begIndex + 4));
       return foundFileName;
-      }
-    else
-      {
-      return line.substr(begIndex,line.npos);
-      }
+    } else {
+      return line.substr(begIndex, line.npos);
     }
-  bool ParseFile(std::string file)
-    {
+  }
+  bool ParseFile(std::string const& file)
+  {
     FileLinesType localCoverageVector;
     std::string filename;
     bool foundFile = false;
-    bool inSource  = false;
+    bool inSource = false;
     std::string covResult;
     std::string line;
 
     cmsys::ifstream in(file.c_str());
-    if(!in)
-      {
+    if (!in) {
       return false;
-      }
-    while(  cmSystemTools::GetLineFromStream(in, line))
-      {
-      if(line.find("filename") != line.npos)
-        {
-        if(foundFile)
-          {
+    }
+    while (cmSystemTools::GetLineFromStream(in, line)) {
+      if (line.find("filename") != line.npos) {
+        if (foundFile) {
           /*
           * Upon finding a second file name, generate a
           * vector within the total coverage to capture the
           * information in the local vector
           */
           FileLinesType& CoverageVector =
-              this->Coverage.TotalCoverage[filename];
+            this->Coverage.TotalCoverage[filename];
           CoverageVector = localCoverageVector;
           localCoverageVector.clear();
-          }
-        foundFile= true;
-        inSource = false;
-        filename = getValue(line,0).c_str();
         }
-      else if((line.find("coverage") != line.npos) && foundFile && inSource )
-        {
+        foundFile = true;
+        inSource = false;
+        filename = getValue(line, 0);
+      } else if ((line.find("coverage") != line.npos) && foundFile &&
+                 inSource) {
         /*
         *  two types of "coverage" in the JSON structure
         *
@@ -97,68 +86,63 @@ public:
         *  FoundFile and foundSource ensure that
         *  only the value of the line coverage is captured
         */
-        std::string result = getValue(line,1);
-        result = result.substr(2,result.npos);
-        if(result == "\"\"")
-          {
+        std::string result = getValue(line, 1);
+        result = result.substr(2, result.npos);
+        if (result == "\"\"") {
           // Empty quotation marks indicate that the
           // line is not executable
           localCoverageVector.push_back(-1);
-          }
-        else
-          {
+        } else {
           // Else, it contains the number of time executed
           localCoverageVector.push_back(atoi(result.c_str()));
-          }
-        }
-      else if(line.find("source") != line.npos)
-        {
-        inSource=true;
         }
+      } else if (line.find("source") != line.npos) {
+        inSource = true;
       }
+    }
 
     // On exit, capture end of last file covered.
-    FileLinesType& CoverageVector =
-        this->Coverage.TotalCoverage[filename];
+    FileLinesType& CoverageVector = this->Coverage.TotalCoverage[filename];
     CoverageVector = localCoverageVector;
     localCoverageVector.clear();
     return true;
-    }
+  }
+
 private:
   cmCTestCoverageHandlerContainer& Coverage;
 };
 
 cmParseBlanketJSCoverage::cmParseBlanketJSCoverage(
-  cmCTestCoverageHandlerContainer& cont,  cmCTest* ctest)
-  :Coverage(cont), CTest(ctest)
-  {
-  }
+  cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+  : Coverage(cont)
+  , CTest(ctest)
+{
+}
 
 bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files)
-  {
-  size_t i=0;
+{
+  size_t i = 0;
   std::string path;
-      cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-       "Found " << files.size() <<" Files" << std::endl, this->Coverage.Quiet);
-  for(i=0;i<files.size();i++)
-    {
-    cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-       "Reading JSON File " << files[i]  << std::endl, this->Coverage.Quiet);
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "Found " << files.size() << " Files" << std::endl,
+                     this->Coverage.Quiet);
+  for (i = 0; i < files.size(); i++) {
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "Reading JSON File " << files[i] << std::endl,
+                       this->Coverage.Quiet);
 
-    if(!this->ReadJSONFile(files[i]))
-      {
+    if (!this->ReadJSONFile(files[i])) {
       return false;
-      }
     }
-  return true;
   }
+  return true;
+}
 
-bool cmParseBlanketJSCoverage::ReadJSONFile(std::string file)
-  {
-  cmParseBlanketJSCoverage::JSONParser parser
-     (this->Coverage);
-  cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-       "Parsing " << file << std::endl, this->Coverage.Quiet);
+bool cmParseBlanketJSCoverage::ReadJSONFile(std::string const& file)
+{
+  cmParseBlanketJSCoverage::JSONParser parser(this->Coverage);
+  cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                     "Parsing " << file << std::endl, this->Coverage.Quiet);
   parser.ParseFile(file);
   return true;
-  }
+}
diff --git a/Source/CTest/cmParseBlanketJSCoverage.h b/Source/CTest/cmParseBlanketJSCoverage.h
index fc1d477..a4f6670 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.h
+++ b/Source/CTest/cmParseBlanketJSCoverage.h
@@ -13,10 +13,8 @@
 #ifndef cmParseBlanketJSCoverage_h
 #define cmParseBlanketJSCoverage_h
 
-#include "cmStandardIncludes.h"
 #include "cmCTestCoverageHandler.h"
 
-
 /** \class cmParseBlanketJSCoverage
  * \brief Parse BlanketJS coverage information
  *
@@ -34,13 +32,12 @@ class cmParseBlanketJSCoverage
 {
 public:
   cmParseBlanketJSCoverage(cmCTestCoverageHandlerContainer& cont,
-       cmCTest* ctest);
+                           cmCTest* ctest);
   bool LoadCoverageData(std::vector<std::string> files);
   //  Read the JSON output
-  bool ReadJSONFile(std::string file);
+  bool ReadJSONFile(std::string const& file);
 
 protected:
-
   class JSONParser;
   cmCTestCoverageHandlerContainer& Coverage;
   cmCTest* CTest;
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index 92bf88e..0916da2 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -1,50 +1,41 @@
-#include "cmStandardIncludes.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include "cmSystemTools.h"
 #include "cmParseCacheCoverage.h"
+
+#include "cmSystemTools.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
-
+#include <cmsys/Glob.hxx>
+#include <stdio.h>
+#include <stdlib.h>
 
 cmParseCacheCoverage::cmParseCacheCoverage(
-  cmCTestCoverageHandlerContainer& cont,
-  cmCTest* ctest)
-  :cmParseMumpsCoverage(cont, ctest)
+  cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+  : cmParseMumpsCoverage(cont, ctest)
 {
 }
 
-
 bool cmParseCacheCoverage::LoadCoverageData(const char* d)
 {
   // load all the .mcov files in the specified directory
   cmsys::Directory dir;
-  if(!dir.Load(d))
-    {
+  if (!dir.Load(d)) {
     return false;
-    }
+  }
   size_t numf;
   unsigned int i;
   numf = dir.GetNumberOfFiles();
-  for (i = 0; i < numf; i++)
-    {
+  for (i = 0; i < numf; i++) {
     std::string file = dir.GetFile(i);
-    if(file != "." && file != ".."
-       && !cmSystemTools::FileIsDirectory(file))
-      {
+    if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
       std::string path = d;
       path += "/";
       path += file;
-      if(cmSystemTools::GetFilenameLastExtension(path) == ".cmcov")
-        {
-        if(!this->ReadCMCovFile(path.c_str()))
-          {
+      if (cmSystemTools::GetFilenameLastExtension(path) == ".cmcov") {
+        if (!this->ReadCMCovFile(path.c_str())) {
           return false;
-          }
         }
       }
     }
+  }
   return true;
 }
 
@@ -55,32 +46,26 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles()
   // that only have -1 or 0 for the lines.
   cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator ci =
     this->Coverage.TotalCoverage.begin();
-  while(ci != this->Coverage.TotalCoverage.end())
-    {
-    cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v =
-      ci->second;
+  while (ci != this->Coverage.TotalCoverage.end()) {
+    cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v = ci->second;
     bool nothing = true;
-    for(cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator i=
-          v.begin(); i != v.end(); ++i)
-      {
-      if(*i > 0)
-        {
+    for (cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator
+           i = v.begin();
+         i != v.end(); ++i) {
+      if (*i > 0) {
         nothing = false;
         break;
-        }
       }
-    if(nothing)
-      {
+    }
+    if (nothing) {
       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-                 "No coverage found in: " << ci->first
-                 << std::endl, this->Coverage.Quiet);
+                         "No coverage found in: " << ci->first << std::endl,
+                         this->Coverage.Quiet);
       this->Coverage.TotalCoverage.erase(ci++);
-      }
-    else
-      {
+    } else {
       ++ci;
-      }
     }
+  }
 }
 
 bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
@@ -88,18 +73,16 @@ bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
 {
   std::string::size_type pos1 = 0;
   std::string::size_type pos2 = line.find(',', 0);
-  if(pos2 == std::string::npos)
-    {
+  if (pos2 == std::string::npos) {
     return false;
-    }
+  }
   std::string arg;
-  while(pos2 != std::string::npos)
-    {
-    arg = line.substr(pos1, pos2-pos1);
+  while (pos2 != std::string::npos) {
+    arg = line.substr(pos1, pos2 - pos1);
     args.push_back(arg);
-    pos1 = pos2+1;
-    pos2 = line.find(',',pos1);
-    }
+    pos1 = pos2 + 1;
+    pos2 = line.find(',', pos1);
+  }
   arg = line.substr(pos1);
   args.push_back(arg);
   return true;
@@ -108,126 +91,106 @@ bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
 bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
 {
   cmsys::ifstream in(file);
-  if(!in)
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Can not open : "
-               << file << "\n");
+  if (!in) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not open : " << file << "\n");
     return false;
-    }
+  }
   std::string line;
   std::vector<std::string> separateLine;
-  if(!cmSystemTools::GetLineFromStream(in, line))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Empty file : "
-               << file << "  referenced in this line of cmcov data:\n"
-               "[" << line << "]\n");
+  if (!cmSystemTools::GetLineFromStream(in, line)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Empty file : "
+                 << file << "  referenced in this line of cmcov data:\n"
+                            "["
+                 << line << "]\n");
     return false;
-    }
+  }
   separateLine.clear();
   this->SplitString(separateLine, line);
-  if(separateLine.size() !=4 || separateLine[0] != "Routine"
-     || separateLine[1] != "Line" || separateLine[2] != "RtnLine"
-     || separateLine[3] != "Code")
-    {
+  if (separateLine.size() != 4 || separateLine[0] != "Routine" ||
+      separateLine[1] != "Line" || separateLine[2] != "RtnLine" ||
+      separateLine[3] != "Code") {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Bad first line of cmcov file : "
-               << file << "  line:\n"
-               "[" << line << "]\n");
-    }
+               "Bad first line of cmcov file : " << file << "  line:\n"
+                                                            "["
+                                                 << line << "]\n");
+  }
   std::string routine;
   std::string filepath;
-  while(cmSystemTools::GetLineFromStream(in, line))
-    {
+  while (cmSystemTools::GetLineFromStream(in, line)) {
     // clear out line argument vector
     separateLine.clear();
     // parse the comma separated line
     this->SplitString(separateLine, line);
     // might have more because code could have a quoted , in it
     // but we only care about the first 3 args anyway
-    if(separateLine.size() < 4)
-      {
+    if (separateLine.size() < 4) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  "Bad line of cmcov file expected at least 4 found: "
-                 << separateLine.size() << " "
-                 << file << "  line:\n"
-                 "[" << line << "]\n");
-      for(std::string::size_type i = 0; i < separateLine.size(); ++i)
-        {
-        cmCTestLog(this->CTest, ERROR_MESSAGE,""
-                   << separateLine[1] << " ");
-        }
+                   << separateLine.size() << " " << file << "  line:\n"
+                                                            "["
+                   << line << "]\n");
+      for (std::string::size_type i = 0; i < separateLine.size(); ++i) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE, "" << separateLine[1] << " ");
+      }
       cmCTestLog(this->CTest, ERROR_MESSAGE, "\n");
       return false;
-      }
+    }
     // if we do not have a routine yet, then it should be
     // the first argument in the vector
-    if(routine.empty())
-      {
+    if (routine.empty()) {
       routine = separateLine[0];
       // Find the full path to the file
-      if(!this->FindMumpsFile(routine, filepath))
-        {
+      if (!this->FindMumpsFile(routine, filepath)) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-                   "Could not find mumps file for routine: "
-                   << routine << "\n");
+                   "Could not find mumps file for routine: " << routine
+                                                             << "\n");
         filepath = "";
         continue; // move to next line
-        }
       }
+    }
     // if we have a routine name, check for end of routine
-    else
-      {
+    else {
       // Totals in arg 0 marks the end of a routine
-      if(separateLine[0].substr(0, 6) == "Totals")
-        {
+      if (separateLine[0].substr(0, 6) == "Totals") {
         routine = ""; // at the end of this routine
         filepath = "";
         continue; // move to next line
-        }
       }
+    }
     // if the file path was not found for the routine
     // move to next line. We should have already warned
     // after the call to FindMumpsFile that we did not find
     // it, so don't report again to cut down on output
-    if(filepath.empty())
-      {
+    if (filepath.empty()) {
       continue;
-      }
+    }
     // now we are ready to set the coverage from the line of data
-    cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
-      coverageVector = this->Coverage.TotalCoverage[filepath];
-    std::string::size_type linenumber = atoi(separateLine[1].c_str()) -1;
+    cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector =
+      this->Coverage.TotalCoverage[filepath];
+    std::string::size_type linenumber = atoi(separateLine[1].c_str()) - 1;
     int count = atoi(separateLine[2].c_str());
-    if(linenumber > coverageVector.size())
-      {
+    if (linenumber > coverageVector.size()) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  "Parse error line is greater than number of lines in file: "
-                 << linenumber << " " << filepath << "\n");
+                   << linenumber << " " << filepath << "\n");
       continue; // skip setting count to avoid crash
-      }
+    }
     // now add to count for linenumber
     // for some reason the cache coverage adds extra lines to the
     // end of the file in some cases. Since they do not exist, we will
     // mark them as non executable
-    while(linenumber >= coverageVector.size())
-      {
+    while (linenumber >= coverageVector.size()) {
       coverageVector.push_back(-1);
-      }
+    }
     // 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;
-      }
+    if (coverageVector[linenumber] == -1 && count > 0) {
+      coverageVector[linenumber] += count + 1;
+    } else {
+      coverageVector[linenumber] += count;
     }
+  }
   return true;
 }
diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h
index 114eb92..bd331d0 100644
--- a/Source/CTest/cmParseCacheCoverage.h
+++ b/Source/CTest/cmParseCacheCoverage.h
@@ -24,8 +24,8 @@
 class cmParseCacheCoverage : public cmParseMumpsCoverage
 {
 public:
-  cmParseCacheCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
+  cmParseCacheCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+
 protected:
   // implement virtual from parent
   bool LoadCoverageData(const char* dir);
@@ -34,9 +34,7 @@ protected:
   // Read a single mcov file
   bool ReadCMCovFile(const char* f);
   // split a string based on ,
-  bool SplitString(std::vector<std::string>& args,
-                   std::string const& line);
+  bool SplitString(std::vector<std::string>& args, std::string const& line);
 };
 
-
 #endif
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index 3ed5cb0..3bdae17 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -1,122 +1,101 @@
-#include "cmStandardIncludes.h"
+#include "cmParseCoberturaCoverage.h"
+
 #include "cmSystemTools.h"
 #include "cmXMLParser.h"
-#include "cmParseCoberturaCoverage.h"
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
 
-//----------------------------------------------------------------------------
-class cmParseCoberturaCoverage::XMLParser: public cmXMLParser
+class cmParseCoberturaCoverage::XMLParser : public cmXMLParser
 {
 public:
   XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
-    : CTest(ctest), Coverage(cont)
+    : CTest(ctest)
+    , Coverage(cont)
   {
-   this->InSources     = false;
-   this->InSource      = false;
-   this->SkipThisClass = false;
-   this->FilePaths.push_back(this->Coverage.SourceDir);
-   this->FilePaths.push_back(this->Coverage.BinaryDir);
-   this->CurFileName = "";
+    this->InSources = false;
+    this->InSource = false;
+    this->SkipThisClass = false;
+    this->FilePaths.push_back(this->Coverage.SourceDir);
+    this->FilePaths.push_back(this->Coverage.BinaryDir);
+    this->CurFileName = "";
   }
 
-  virtual ~XMLParser()
-  {
-  }
+  virtual ~XMLParser() {}
 
 protected:
-
-
   virtual void EndElement(const std::string& name)
   {
-   if(name == "source")
-     {
-     this->InSource=false;
-     }
-   else if (name == "sources")
-     {
-     this->InSources=false;
-     }
-    else if(name == "class")
-      {
+    if (name == "source") {
+      this->InSource = false;
+    } else if (name == "sources") {
+      this->InSources = false;
+    } else if (name == "class") {
       this->SkipThisClass = 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);
-       cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-         "Adding Source: " << tmp << std::endl, this->Coverage.Quiet);
-       }
+    std::string tmp;
+    tmp.insert(0, data, length);
+    if (this->InSources && this->InSource) {
+      this->FilePaths.push_back(tmp);
+      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                         "Adding Source: " << tmp << std::endl,
+                         this->Coverage.Quiet);
+    }
   }
 
   virtual void StartElement(const std::string& name, const char** atts)
   {
     std::string FoundSource;
     std::string finalpath = "";
-    if(name == "source")
-    {
+    if (name == "source") {
       this->InSource = true;
-    }
-    else if(name == "sources")
-      {
+    } else if (name == "sources") {
       this->InSources = true;
-      }
-    else if(name == "class")
-    {
+    } else if (name == "class") {
       int tagCount = 0;
-      while(true)
-      {
-        if(strcmp(atts[tagCount], "filename") == 0)
-        {
+      while (true) {
+        if (strcmp(atts[tagCount], "filename") == 0) {
           cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-            "Reading file: " << atts[tagCount+1]<< std::endl,
-            this->Coverage.Quiet);
-          std::string filename = atts[tagCount+1];
+                             "Reading file: " << atts[tagCount + 1]
+                                              << std::endl,
+                             this->Coverage.Quiet);
+          std::string filename = atts[tagCount + 1];
           this->CurFileName = "";
 
           // Check if this is an absolute path that falls within our
           // source or binary directories.
-          for(size_t i=0;i < FilePaths.size();i++)
-            {
-            if (filename.find(FilePaths[i]) == 0)
-              {
+          for (size_t i = 0; i < FilePaths.size(); i++) {
+            if (filename.find(FilePaths[i]) == 0) {
               this->CurFileName = filename;
               break;
-              }
             }
+          }
 
-          if (this->CurFileName == "")
-            {
+          if (this->CurFileName == "") {
             // Check if this is a path that is relative to our source or
             // binary directories.
-            for(size_t i=0;i < FilePaths.size();i++)
-              {
+            for (size_t i = 0; i < FilePaths.size(); i++) {
               finalpath = FilePaths[i] + "/" + filename;
-              if(cmSystemTools::FileExists(finalpath.c_str()))
-                {
+              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];
+          if (this->CurFileName == "" || !fin) {
+            this->CurFileName =
+              this->Coverage.BinaryDir + "/" + atts[tagCount + 1];
             fin.open(this->CurFileName.c_str());
-            if (!fin)
-            {
+            if (!fin) {
               cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-                "Skipping system file " << filename << std::endl,
-                this->Coverage.Quiet);
+                                 "Skipping system file " << filename
+                                                         << std::endl,
+                                 this->Coverage.Quiet);
 
               this->SkipThisClass = true;
               break;
@@ -125,9 +104,7 @@ protected:
           std::string line;
           FileLinesType& curFileLines =
             this->Coverage.TotalCoverage[this->CurFileName];
-          curFileLines.push_back(-1);
-          while(cmSystemTools::GetLineFromStream(fin, line))
-          {
+          while (cmSystemTools::GetLineFromStream(fin, line)) {
             curFileLines.push_back(-1);
           }
 
@@ -135,34 +112,26 @@ protected:
         }
         ++tagCount;
       }
-    }
-    else if(name == "line")
-    {
+    } else if (name == "line") {
       int tagCount = 0;
       int curNumber = -1;
       int curHits = -1;
-      while(true)
-      {
-        if(this->SkipThisClass)
-          {
+      while (true) {
+        if (this->SkipThisClass) {
           break;
-          }
-        if(strcmp(atts[tagCount], "hits") == 0)
-        {
-          curHits = atoi(atts[tagCount+1]);
         }
-        else if(strcmp(atts[tagCount], "number") == 0)
-        {
-          curNumber = atoi(atts[tagCount+1]);
+        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)
-        {
+        if (curHits > -1 && curNumber > 0) {
           FileLinesType& curFileLines =
             this->Coverage.TotalCoverage[this->CurFileName];
-            {
-            curFileLines[curNumber-1] = curHits;
-            }
+          {
+            curFileLines[curNumber - 1] = curHits;
+          }
           break;
         }
         ++tagCount;
@@ -171,24 +140,21 @@ protected:
   }
 
 private:
-
   bool InSources;
   bool InSource;
   bool SkipThisClass;
   std::vector<std::string> FilePaths;
   typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
-     FileLinesType;
+    FileLinesType;
   cmCTest* CTest;
   cmCTestCoverageHandlerContainer& Coverage;
   std::string CurFileName;
-
 };
 
-
 cmParseCoberturaCoverage::cmParseCoberturaCoverage(
-    cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest)
-    :Coverage(cont), CTest(ctest)
+  cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+  : Coverage(cont)
+  , CTest(ctest)
 {
 }
 
diff --git a/Source/CTest/cmParseCoberturaCoverage.h b/Source/CTest/cmParseCoberturaCoverage.h
index ff5954d..4fa6d10 100644
--- a/Source/CTest/cmParseCoberturaCoverage.h
+++ b/Source/CTest/cmParseCoberturaCoverage.h
@@ -13,7 +13,6 @@
 #ifndef cmParseCoberturaCoverage_h
 #define cmParseCoberturaCoverage_h
 
-#include "cmStandardIncludes.h"
 #include "cmCTestCoverageHandler.h"
 
 /** \class cmParsePythonCoverage
@@ -28,11 +27,10 @@
 class cmParseCoberturaCoverage
 {
 public:
-
   //! Create the coverage parser by passing in the coverage handler
   //! container and the cmCTest object
   cmParseCoberturaCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
+                           cmCTest* ctest);
 
   bool inSources;
   bool inSource;
@@ -41,7 +39,6 @@ public:
   bool ReadCoverageXML(const char* xmlFile);
 
 private:
-
   class XMLParser;
   cmCTestCoverageHandlerContainer& Coverage;
   cmCTest* CTest;
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index e453fe1..9d86ce9 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -1,100 +1,83 @@
-#include "cmStandardIncludes.h"
-#include <stdio.h>
-#include <stdlib.h>
+#include "cmParseDelphiCoverage.h"
+
 #include "cmSystemTools.h"
 #include "cmXMLParser.h"
-#include "cmParseDelphiCoverage.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
-
+#include <cmsys/Glob.hxx>
+#include <stdio.h>
+#include <stdlib.h>
 
 class cmParseDelphiCoverage::HTMLParser
 {
 public:
   typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
-  FileLinesType;
+    FileLinesType;
   HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
-     : CTest(ctest), Coverage(cont)
-    {
-    }
+    : CTest(ctest)
+    , Coverage(cont)
+  {
+  }
 
-  virtual ~HTMLParser()
-    {
-    }
+  virtual ~HTMLParser() {}
 
-  bool initializeDelphiFile(const std::string filename,
-     cmParseDelphiCoverage::HTMLParser::FileLinesType &coverageVector)
-    {
+  bool initializeDelphiFile(
+    std::string const& filename,
+    cmParseDelphiCoverage::HTMLParser::FileLinesType& coverageVector)
+  {
     std::string line;
     size_t comPos;
     size_t semiPos;
-    bool blockComFlag= false;
-    bool lineComFlag= false;
+    bool blockComFlag = false;
+    bool lineComFlag = false;
     std::vector<std::string> beginSet;
     cmsys::ifstream in(filename.c_str());
-    if(!in)
-      {
+    if (!in) {
       return false;
-      }
-    while(cmSystemTools::GetLineFromStream(in, line))
-      {
-      lineComFlag=false;
+    }
+    while (cmSystemTools::GetLineFromStream(in, line)) {
+      lineComFlag = false;
       // Unique cases found in lines.
       size_t beginPos = line.find("begin");
 
-      //Check that the begin is the first non-space string on the line
-      if( (beginPos == line.find_first_not_of(' ')) && beginPos != line.npos )
-        {
+      // Check that the begin is the first non-space string on the line
+      if ((beginPos == line.find_first_not_of(' ')) && beginPos != line.npos) {
         beginSet.push_back("begin");
         coverageVector.push_back(-1);
         continue;
-        }
-      else if(line.find('{') != line.npos)
-        {
-        blockComFlag=true;
-        }
-      else if(line.find('}') != line.npos)
-        {
-        blockComFlag=false;
+      } else if (line.find('{') != line.npos) {
+        blockComFlag = true;
+      } else if (line.find('}') != line.npos) {
+        blockComFlag = false;
         coverageVector.push_back(-1);
         continue;
-        }
-      else if((line.find("end;") != line.npos)
-         && !beginSet.empty())
-        {
+      } else if ((line.find("end;") != line.npos) && !beginSet.empty()) {
         beginSet.pop_back();
         coverageVector.push_back(-1);
         continue;
-        }
+      }
 
       //  This checks for comments after lines of code, finding the
       //  comment symbol after the ending semicolon.
       comPos = line.find("//");
-      if(comPos != line.npos)
-        {
-        semiPos= line.find(';');
-        if(comPos < semiPos)
-          {
-          lineComFlag=true;
-          }
+      if (comPos != line.npos) {
+        semiPos = line.find(';');
+        if (comPos < semiPos) {
+          lineComFlag = true;
         }
-      //Based up what was found, add a line to the coverageVector
-      if(!beginSet.empty() && line != ""  && !blockComFlag
-         && !lineComFlag)
-        {
+      }
+      // Based up what was found, add a line to the coverageVector
+      if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) {
         coverageVector.push_back(0);
-        }
-      else
-        {
+      } else {
         coverageVector.push_back(-1);
-        }
       }
-      return true;
     }
+    return true;
+  }
   bool ParseFile(const char* file)
-    {
-    std::string line=file;
+  {
+    std::string line = file;
     std::string lineresult;
     std::string lastroutine;
     std::string filename;
@@ -117,28 +100,25 @@ public:
     *   to see if it ends in '.pas'.  If it can't be found,
     *   exit the function.
     */
-    while(true)
-      {
-      lastoffset = line.find('(',pos);
-      if(lastoffset==line.npos)
-        {
-        cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-           endnamepos << "File not found  " << lastoffset  << std::endl,
-           this->Coverage.Quiet);
+    while (true) {
+      lastoffset = line.find('(', pos);
+      if (lastoffset == line.npos) {
+        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, endnamepos
+                             << "File not found  " << lastoffset << std::endl,
+                           this->Coverage.Quiet);
         return false;
-        }
-      endnamepos = line.find(')',lastoffset);
-      filename = line.substr(lastoffset+1,
-         (endnamepos-1)-lastoffset);
-      if(filename.find(".pas") != filename.npos)
-        {
-        cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-           "Coverage found for file:  " << filename  << std::endl,
-           this->Coverage.Quiet);
+      }
+      endnamepos = line.find(')', lastoffset);
+      filename = line.substr(lastoffset + 1, (endnamepos - 1) - lastoffset);
+      if (filename.find(".pas") != filename.npos) {
+        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                           "Coverage found for file:  " << filename
+                                                        << std::endl,
+                           this->Coverage.Quiet);
         break;
-        }
-      pos = lastoffset+1;
       }
+      pos = lastoffset + 1;
+    }
     /*
     *  Glob through the source directory for the
     *  file found above
@@ -149,32 +129,29 @@ public:
     std::string glob = Coverage.SourceDir + "*/" + filename;
     gl.FindFiles(glob);
     std::vector<std::string> const& files = gl.GetFiles();
-    if(files.empty())
-      {
+    if (files.empty()) {
       /*
       *  If that doesn't find any matching files
       *  return a failure.
       */
-      cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-         "Unable to find file matching" << glob << std::endl,
-         this->Coverage.Quiet);
+      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                         "Unable to find file matching" << glob << std::endl,
+                         this->Coverage.Quiet);
       return false;
-      }
-    FileLinesType&  coverageVector =
-       this->Coverage.TotalCoverage[files[0]];
+    }
+    FileLinesType& coverageVector = this->Coverage.TotalCoverage[files[0]];
 
     /*
     *  Initialize the file to have all code between 'begin' and
     *  'end' tags marked as executable
     */
 
-    this->initializeDelphiFile(files[0],coverageVector);
+    this->initializeDelphiFile(files[0], coverageVector);
 
     cmsys::ifstream in(file);
-    if(!in)
-      {
+    if (!in) {
       return false;
-      }
+    }
 
     /*
     *  Now read the HTML file, looking for the lines that have an
@@ -188,67 +165,61 @@ public:
     *
     */
 
-    while(  cmSystemTools::GetLineFromStream(in, line))
-      {
-      if(line.find("inline") == line.npos)
-        {
+    while (cmSystemTools::GetLineFromStream(in, line)) {
+      if (line.find("inline") == line.npos) {
         continue;
-        }
+      }
 
       lastoffset = line.find("class=");
-      endcovpos = line.find(">",lastoffset);
-      lineresult = line.substr(lastoffset+7,(endcovpos-8)-lastoffset);
-
-      if(lineresult == "covered")
-        {
-        afterLineNum = line.find('<',endcovpos+5);
-        filelineoffset= line.substr(endcovpos+5,
-        afterLineNum-(endcovpos+5));
-        coverageVector[atoi(filelineoffset.c_str())-1] = 1;
-        }
+      endcovpos = line.find('>', lastoffset);
+      lineresult = line.substr(lastoffset + 7, (endcovpos - 8) - lastoffset);
+
+      if (lineresult == "covered") {
+        afterLineNum = line.find('<', endcovpos + 5);
+        filelineoffset =
+          line.substr(endcovpos + 5, afterLineNum - (endcovpos + 5));
+        coverageVector[atoi(filelineoffset.c_str()) - 1] = 1;
       }
-      return true;
     }
+    return true;
+  }
 
-
-  private:
-    cmCTest* CTest;
-    cmCTestCoverageHandlerContainer& Coverage;
+private:
+  cmCTest* CTest;
+  cmCTestCoverageHandlerContainer& Coverage;
 };
 
 cmParseDelphiCoverage::cmParseDelphiCoverage(
-   cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
-   :Coverage(cont), CTest(ctest)
-  {
-  }
+  cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+  : Coverage(cont)
+  , CTest(ctest)
+{
+}
 
 bool cmParseDelphiCoverage::LoadCoverageData(
-  const std::vector<std::string> files)
-  {
+  std::vector<std::string> const& files)
+{
   size_t i;
   std::string path;
   size_t numf = files.size();
-  for (i = 0; i < numf; i++)
-    {
+  for (i = 0; i < numf; i++) {
     path = files[i];
 
-    cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-       "Reading HTML File " << path  << std::endl, this->Coverage.Quiet);
-    if(cmSystemTools::GetFilenameLastExtension(path) == ".html")
-      {
-      if(!this->ReadDelphiHTML(path.c_str()))
-        {
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "Reading HTML File " << path << std::endl,
+                       this->Coverage.Quiet);
+    if (cmSystemTools::GetFilenameLastExtension(path) == ".html") {
+      if (!this->ReadDelphiHTML(path.c_str())) {
         return false;
-        }
       }
     }
-  return true;
   }
+  return true;
+}
 
 bool cmParseDelphiCoverage::ReadDelphiHTML(const char* file)
-  {
-  cmParseDelphiCoverage::HTMLParser
-     parser(this->CTest, this->Coverage);
+{
+  cmParseDelphiCoverage::HTMLParser parser(this->CTest, this->Coverage);
   parser.ParseFile(file);
   return true;
-  }
+}
diff --git a/Source/CTest/cmParseDelphiCoverage.h b/Source/CTest/cmParseDelphiCoverage.h
index 018340b..c1c495c 100644
--- a/Source/CTest/cmParseDelphiCoverage.h
+++ b/Source/CTest/cmParseDelphiCoverage.h
@@ -13,10 +13,8 @@
 #ifndef cmParseDelphiCoverage_h
 #define cmParseDelphiCoverage_h
 
-#include "cmStandardIncludes.h"
 #include "cmCTestCoverageHandler.h"
 
-
 /** \class cmParseDelphiCoverage
  * \brief Parse Delphi coverage information
  *
@@ -27,20 +25,17 @@
  */
 
 class cmParseDelphiCoverage
-  {
-  public:
-    cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont,
-        cmCTest* ctest);
-    bool LoadCoverageData(const std::vector<std::string> files);
-    bool ReadDelphiHTML(const char* file);
-    // Read a single HTML file from output
-    bool ReadHTMLFile(const char* f);
-
-
-  protected:
-
-    class HTMLParser;
-    cmCTestCoverageHandlerContainer& Coverage;
-    cmCTest* CTest;
-  };
+{
+public:
+  cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+  bool LoadCoverageData(std::vector<std::string> const& files);
+  bool ReadDelphiHTML(const char* file);
+  // Read a single HTML file from output
+  bool ReadHTMLFile(const char* f);
+
+protected:
+  class HTMLParser;
+  cmCTestCoverageHandlerContainer& Coverage;
+  cmCTest* CTest;
+};
 #endif
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index f3f8008..33ad839 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -1,71 +1,60 @@
-#include "cmStandardIncludes.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include "cmSystemTools.h"
 #include "cmParseGTMCoverage.h"
+
+#include "cmSystemTools.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
-
+#include <cmsys/Glob.hxx>
+#include <stdio.h>
+#include <stdlib.h>
 
 cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
                                        cmCTest* ctest)
-  :cmParseMumpsCoverage(cont, ctest)
+  : cmParseMumpsCoverage(cont, ctest)
 {
 }
 
-
 bool cmParseGTMCoverage::LoadCoverageData(const char* d)
 {
   // load all the .mcov files in the specified directory
   cmsys::Directory dir;
-  if(!dir.Load(d))
-    {
+  if (!dir.Load(d)) {
     return false;
-    }
+  }
   size_t numf;
   unsigned int i;
   numf = dir.GetNumberOfFiles();
-  for (i = 0; i < numf; i++)
-    {
+  for (i = 0; i < numf; i++) {
     std::string file = dir.GetFile(i);
-    if(file != "." && file != ".."
-       && !cmSystemTools::FileIsDirectory(file))
-      {
+    if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
       std::string path = d;
       path += "/";
       path += file;
-      if(cmSystemTools::GetFilenameLastExtension(path) == ".mcov")
-        {
-        if(!this->ReadMCovFile(path.c_str()))
-          {
+      if (cmSystemTools::GetFilenameLastExtension(path) == ".mcov") {
+        if (!this->ReadMCovFile(path.c_str())) {
           return false;
-          }
         }
       }
     }
+  }
   return true;
 }
 
 bool cmParseGTMCoverage::ReadMCovFile(const char* file)
 {
   cmsys::ifstream in(file);
-  if(!in)
-    {
+  if (!in) {
     return false;
-    }
+  }
   std::string line;
   std::string lastfunction;
   std::string lastroutine;
   std::string lastpath;
   int lastoffset = 0;
-  while(  cmSystemTools::GetLineFromStream(in, line))
-    {
+  while (cmSystemTools::GetLineFromStream(in, line)) {
     // only look at lines that have coverage data
-    if(line.find("^ZZCOVERAGE") == line.npos)
-      {
+    if (line.find("^ZZCOVERAGE") == line.npos) {
       continue;
-      }
+    }
     std::string filepath;
     std::string function;
     std::string routine;
@@ -73,66 +62,51 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
     int count = 0;
     this->ParseMCOVLine(line, routine, function, linenumber, count);
     // skip this one
-    if(routine == "RSEL")
-      {
+    if (routine == "RSEL") {
       continue;
-      }
+    }
     // no need to search the file if we just did it
-    if(function == lastfunction && lastroutine == routine)
-      {
-      if(!lastpath.empty())
-        {
-        this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber]
-          += count;
-        }
-      else
-        {
-        cmCTestLog(this->CTest, ERROR_MESSAGE,
-                   "Can not find mumps file : "
-                   << lastroutine <<
-                   "  referenced in this line of mcov data:\n"
-                   "[" << line << "]\n");
-        }
-      continue;
+    if (function == lastfunction && lastroutine == routine) {
+      if (!lastpath.empty()) {
+        this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber] +=
+          count;
+      } else {
+        cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : "
+                     << lastroutine
+                     << "  referenced in this line of mcov data:\n"
+                        "["
+                     << line << "]\n");
       }
+      continue;
+    }
     // Find the full path to the file
     bool found = this->FindMumpsFile(routine, filepath);
-    if(found)
-      {
+    if (found) {
       int lineoffset = 0;
-      if(this->FindFunctionInMumpsFile(filepath,
-                                       function,
-                                       lineoffset))
-        {
+      if (this->FindFunctionInMumpsFile(filepath, function, lineoffset)) {
         cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
           coverageVector = this->Coverage.TotalCoverage[filepath];
         // 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
-          {
+        if (coverageVector[lineoffset + linenumber] == -1 && count > 0) {
+          coverageVector[lineoffset + linenumber] += count + 1;
+        } else {
           coverageVector[lineoffset + linenumber] += count;
-          }
-        lastoffset = lineoffset;
         }
+        lastoffset = lineoffset;
       }
-    else
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Can not find mumps file : "
-               << routine << "  referenced in this line of mcov data:\n"
-                 "[" << line << "]\n");
-      }
+    } else {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : "
+                   << routine << "  referenced in this line of mcov data:\n"
+                                 "["
+                   << line << "]\n");
+    }
     lastfunction = function;
     lastroutine = routine;
     lastpath = filepath;
-    }
+  }
   return true;
 }
 
@@ -141,47 +115,39 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath,
                                                  int& lineoffset)
 {
   cmsys::ifstream in(filepath.c_str());
-  if(!in)
-    {
+  if (!in) {
     return false;
-    }
+  }
   std::string line;
   int linenum = 0;
-  while(  cmSystemTools::GetLineFromStream(in, line))
-    {
-    std::string::size_type pos = line.find(function.c_str());
-    if(pos == 0)
-      {
+  while (cmSystemTools::GetLineFromStream(in, line)) {
+    std::string::size_type pos = line.find(function);
+    if (pos == 0) {
       char nextchar = line[function.size()];
-      if(nextchar == ' ' || nextchar == '('|| nextchar == '\t')
-        {
+      if (nextchar == ' ' || nextchar == '(' || nextchar == '\t') {
         lineoffset = linenum;
         return true;
-        }
       }
-    if(pos == 1)
-      {
+    }
+    if (pos == 1) {
       char prevchar = line[0];
-      char nextchar = line[function.size()+1];
-      if(prevchar == '%' && (nextchar == ' ' || nextchar == '('))
-        {
+      char nextchar = line[function.size() + 1];
+      if (prevchar == '%' && (nextchar == ' ' || nextchar == '(')) {
         lineoffset = linenum;
         return true;
-        }
       }
-    linenum++; // move to next line count
     }
+    linenum++; // move to next line count
+  }
   lineoffset = 0;
-  cmCTestLog(this->CTest, ERROR_MESSAGE,
-             "Could not find entry point : "
-             << function << " in " << filepath << "\n");
+  cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not find entry point : "
+               << function << " in " << filepath << "\n");
   return false;
 }
 
 bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
                                        std::string& routine,
-                                       std::string& function,
-                                       int& linenumber,
+                                       std::string& function, int& linenumber,
                                        int& count)
 {
   // this method parses lines from the .mcov file
@@ -197,60 +163,49 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
   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)
-    {
+  if (pos == std::string::npos) {
     return false;
-    }
+  }
   std::string arg;
   bool done = false;
   // separate out all of the comma separated arguments found
   // in the COVERAGE(...) line
-  while(line[pos] && !done)
-    {
+  while (line[pos] && !done) {
     // save the char we are looking at
     char cur = line[pos];
     // , or ) means end of argument
-    if(cur == ',' || cur == ')')
-      {
+    if (cur == ',' || cur == ')') {
       // save the argument into the argument vector
       args.push_back(arg);
       // start on a new argument
       arg = "";
       // if we are at the end of the ), then finish while loop
-      if(cur == ')')
-        {
+      if (cur == ')') {
         done = true;
-        }
       }
-    else
-      {
+    } else {
       // all chars except ", (, and % get stored in the arg string
-      if(cur != '\"' && cur != '(' && cur != '%')
-        {
+      if (cur != '\"' && cur != '(' && cur != '%') {
         arg.append(1, line[pos]);
-        }
       }
+    }
     // move to next char
     pos++;
-    }
+  }
   // now parse the right hand side of the =
   pos = line.find('=');
   // no = found, this is an error
-  if(pos == line.npos)
-    {
+  if (pos == line.npos) {
     return false;
-    }
+  }
   pos++; // move past =
 
   // if the next positing is not a ", then this is a
   // COVERAGE(..)=count line and turn the rest of the string
   // past the = into an integer and set it to count
-  if(line[pos] != '\"')
-    {
+  if (line[pos] != '\"') {
     count = atoi(line.substr(pos).c_str());
-    }
-  else
-    {
+  } else {
     // this means line[pos] is a ", and we have a
     // COVERAGE(...)="1:0:0:0" type of line
     pos++; // move past "
@@ -258,32 +213,28 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
     std::string::size_type pos2 = line.find(':', pos);
     // turn the string between the " and the first : into an integer
     // and set it to count
-    count = atoi(line.substr(pos, pos2-pos).c_str());
-    }
+    count = atoi(line.substr(pos, pos2 - pos).c_str());
+  }
   // less then two arguments is an error
-  if(args.size() < 2)
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "Error parsing mcov line: [" << line << "]\n");
+  if (args.size() < 2) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing mcov line: ["
+                 << line << "]\n");
     return false;
-    }
-  routine = args[0]; // the routine is the first argument
+  }
+  routine = args[0];  // the routine is the first argument
   function = args[1]; // the function in the routine is the second
   // in the two argument only format
   // ^COVERAGE("%RSEL","SRC"), the line offset is 0
-  if(args.size() == 2)
-    {
+  if (args.size() == 2) {
     // 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
-    {
+    routine = "";
+    function = "";
+  } else {
     // this is the format for this line
     // ^COVERAGE("%RSEL","SRC",count)
     linenumber = atoi(args[2].c_str());
-    }
+  }
   return true;
 }
diff --git a/Source/CTest/cmParseGTMCoverage.h b/Source/CTest/cmParseGTMCoverage.h
index c6d7ef9..bc2f2ec 100644
--- a/Source/CTest/cmParseGTMCoverage.h
+++ b/Source/CTest/cmParseGTMCoverage.h
@@ -24,8 +24,8 @@
 class cmParseGTMCoverage : public cmParseMumpsCoverage
 {
 public:
-  cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
+  cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+
 protected:
   // implement virtual from parent
   bool LoadCoverageData(const char* dir);
@@ -34,16 +34,11 @@ protected:
   // find out what line in a mumps file (filepath) the given entry point
   // or function is.  lineoffset is set by this method.
   bool FindFunctionInMumpsFile(std::string const& filepath,
-                               std::string const& function,
-                               int& lineoffset);
+                               std::string const& function, int& lineoffset);
   // parse a line from a .mcov file, and fill in the
   // routine, function, linenumber and coverage count
-  bool ParseMCOVLine(std::string const& line,
-                 std::string& routine,
-                 std::string& function,
-                 int& linenumber,
-                 int& count);
+  bool ParseMCOVLine(std::string const& line, std::string& routine,
+                     std::string& function, int& linenumber, int& count);
 };
 
-
 #endif
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index 47e3b32..335535d 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -1,209 +1,179 @@
-#include "cmStandardIncludes.h"
-#include <stdio.h>
-#include <stdlib.h>
+#include "cmParseJacocoCoverage.h"
+
 #include "cmSystemTools.h"
 #include "cmXMLParser.h"
-#include "cmParseJacocoCoverage.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
+#include <stdio.h>
+#include <stdlib.h>
 
-
-class cmParseJacocoCoverage::XMLParser: public cmXMLParser
+class cmParseJacocoCoverage::XMLParser : public cmXMLParser
 {
-  public:
-    XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
-      : CTest(ctest), Coverage(cont)
-      {
-      this->FilePath = "";
-      this->PackagePath = "";
-      this->PackageName = "";
-      }
+public:
+  XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
+    : CTest(ctest)
+    , Coverage(cont)
+  {
+    this->FilePath = "";
+    this->PackagePath = "";
+    this->PackageName = "";
+  }
 
-    virtual ~XMLParser()
-      {
-      }
+  virtual ~XMLParser() {}
 
-  protected:
+protected:
+  virtual void EndElement(const std::string&) {}
 
-    virtual void EndElement(const std::string&)
-      {
+  virtual void StartElement(const std::string& name, const char** atts)
+  {
+    if (name == "package") {
+      this->PackageName = atts[1];
+      this->PackagePath = "";
+    } else if (name == "sourcefile") {
+      std::string fileName = atts[1];
+
+      if (this->PackagePath == "") {
+        if (!this->FindPackagePath(fileName)) {
+          cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
+                       << this->PackageName << "/" << fileName << std::endl);
+          this->Coverage.Error++;
+          return;
+        }
       }
 
-    virtual void StartElement(const std::string& name,
-      const char** atts)
-      {
-      if(name == "package")
-        {
-        this->PackageName = atts[1];
-        this->PackagePath = "";
-        }
-      else if(name == "sourcefile")
-        {
-        std::string fileName = atts[1];
-
-        if (this->PackagePath == "")
-          {
-          if(!this->FindPackagePath(fileName))
-            {
-            cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
-              << this->PackageName << "/" << fileName << std::endl);
-            this->Coverage.Error++;
-            return;
-            }
-          }
+      cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                         "Reading file: " << fileName << std::endl,
+                         this->Coverage.Quiet);
 
-        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-          "Reading file: " << fileName << std::endl,
-          this->Coverage.Quiet);
-
-        this->FilePath = this->PackagePath + "/" + fileName;
-        cmsys::ifstream fin(this->FilePath.c_str());
-        if (!fin)
-          {
-          cmCTestLog(this->CTest, ERROR_MESSAGE,
-                     "Jacoco Coverage: Error opening " << this->FilePath
-                     << std::endl);
-          }
-        std::string line;
-        FileLinesType& curFileLines =
-          this->Coverage.TotalCoverage[this->FilePath];
-        if(fin)
-          {
-          curFileLines.push_back(-1);
-          }
-        while(cmSystemTools::GetLineFromStream(fin, line))
-          {
-          curFileLines.push_back(-1);
-          }
+      this->FilePath = this->PackagePath + "/" + fileName;
+      cmsys::ifstream fin(this->FilePath.c_str());
+      if (!fin) {
+        cmCTestLog(this->CTest, ERROR_MESSAGE,
+                   "Jacoco Coverage: Error opening " << this->FilePath
+                                                     << std::endl);
+      }
+      std::string line;
+      FileLinesType& curFileLines =
+        this->Coverage.TotalCoverage[this->FilePath];
+      if (fin) {
+        curFileLines.push_back(-1);
+      }
+      while (cmSystemTools::GetLineFromStream(fin, line)) {
+        curFileLines.push_back(-1);
+      }
+    } else if (name == "line") {
+      int tagCount = 0;
+      int nr = -1;
+      int ci = -1;
+      while (true) {
+        if (strcmp(atts[tagCount], "ci") == 0) {
+          ci = atoi(atts[tagCount + 1]);
+        } else if (strcmp(atts[tagCount], "nr") == 0) {
+          nr = atoi(atts[tagCount + 1]);
         }
-      else if(name == "line")
-        {
-        int tagCount = 0;
-        int nr = -1;
-        int ci = -1;
-        while(true)
-          {
-          if(strcmp(atts[tagCount],"ci") == 0)
-            {
-            ci = atoi(atts[tagCount+1]);
-            }
-          else if (strcmp(atts[tagCount],"nr") == 0)
-            {
-            nr = atoi(atts[tagCount+1]);
-            }
-          if (ci > -1 && nr > 0)
-            {
-            FileLinesType& curFileLines=
-              this->Coverage.TotalCoverage[this->FilePath];
-            if(!curFileLines.empty())
-               {
-               curFileLines[nr-1] = ci;
-               }
-            break;
-            }
-          ++tagCount;
+        if (ci > -1 && nr > 0) {
+          FileLinesType& curFileLines =
+            this->Coverage.TotalCoverage[this->FilePath];
+          if (!curFileLines.empty()) {
+            curFileLines[nr - 1] = ci;
           }
+          break;
         }
+        ++tagCount;
       }
+    }
+  }
 
-    virtual bool FindPackagePath(const std::string fileName)
-      {
-      // Search for the source file in the source directory.
-      if (this->PackagePathFound(fileName, this->Coverage.SourceDir))
-        {
-        return true;
-        }
-
-      // If not found there, check the binary directory.
-      if (this->PackagePathFound(fileName, this->Coverage.BinaryDir))
-        {
-        return true;
-        }
-      return false;
-      }
+  virtual bool FindPackagePath(std::string const& fileName)
+  {
+    // Search for the source file in the source directory.
+    if (this->PackagePathFound(fileName, this->Coverage.SourceDir)) {
+      return true;
+    }
 
-    virtual bool PackagePathFound(const std::string fileName,
-                                  const std::string baseDir)
-      {
-      // Search for the file in the baseDir and its subdirectories.
-      std::string packageGlob = baseDir;
-      packageGlob += "/";
-      packageGlob += fileName;
-      cmsys::Glob gl;
-      gl.RecurseOn();
-      gl.RecurseThroughSymlinksOn();
-      gl.FindFiles(packageGlob);
-      std::vector<std::string> const& files = gl.GetFiles();
-      if (files.size() == 0)
-        {
-        return false;
-        }
+    // If not found there, check the binary directory.
+    if (this->PackagePathFound(fileName, this->Coverage.BinaryDir)) {
+      return true;
+    }
+    return false;
+  }
 
-      // Check if any of the locations found match our package.
-      for(std::vector<std::string>::const_iterator fi = files.begin();
-          fi != files.end(); ++fi)
-        {
-        std::string dir = cmsys::SystemTools::GetParentDirectory(*fi);
-        if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str()))
-          {
-          cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-                             "Found package directory for " << fileName <<
-                             ": " << dir << std::endl,
-                             this->Coverage.Quiet);
-          this->PackagePath = dir;
-          return true;
-          }
-        }
+  virtual bool PackagePathFound(std::string const& fileName,
+                                std::string const& baseDir)
+  {
+    // Search for the file in the baseDir and its subdirectories.
+    std::string packageGlob = baseDir;
+    packageGlob += "/";
+    packageGlob += fileName;
+    cmsys::Glob gl;
+    gl.RecurseOn();
+    gl.RecurseThroughSymlinksOn();
+    gl.FindFiles(packageGlob);
+    std::vector<std::string> const& files = gl.GetFiles();
+    if (files.size() == 0) {
       return false;
+    }
+
+    // Check if any of the locations found match our package.
+    for (std::vector<std::string>::const_iterator fi = files.begin();
+         fi != files.end(); ++fi) {
+      std::string dir = cmsys::SystemTools::GetParentDirectory(*fi);
+      if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) {
+        cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                           "Found package directory for " << fileName << ": "
+                                                          << dir << std::endl,
+                           this->Coverage.Quiet);
+        this->PackagePath = dir;
+        return true;
       }
+    }
+    return false;
+  }
 
-  private:
-    std::string FilePath;
-    std::string PackagePath;
-    std::string PackageName;
-    typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
-     FileLinesType;
-    cmCTest* CTest;
-    cmCTestCoverageHandlerContainer& Coverage;
+private:
+  std::string FilePath;
+  std::string PackagePath;
+  std::string PackageName;
+  typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+    FileLinesType;
+  cmCTest* CTest;
+  cmCTestCoverageHandlerContainer& Coverage;
 };
 
 cmParseJacocoCoverage::cmParseJacocoCoverage(
-  cmCTestCoverageHandlerContainer& cont,
-  cmCTest* ctest)
-  :Coverage(cont), CTest(ctest)
-  {
-  }
+  cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+  : Coverage(cont)
+  , CTest(ctest)
+{
+}
 
 bool cmParseJacocoCoverage::LoadCoverageData(
-  const std::vector<std::string> files)
+  std::vector<std::string> const& files)
 {
   // load all the jacoco.xml files in the source directory
   cmsys::Directory dir;
   size_t i;
   std::string path;
   size_t numf = files.size();
-  for (i = 0; i < numf; i++)
-    {
+  for (i = 0; i < numf; i++) {
     path = files[i];
 
-    cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
-      "Reading XML File " << path  << std::endl, this->Coverage.Quiet);
-    if(cmSystemTools::GetFilenameLastExtension(path) == ".xml")
-      {
-      if(!this->ReadJacocoXML(path.c_str()))
-        {
+    cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "Reading XML File " << path << std::endl,
+                       this->Coverage.Quiet);
+    if (cmSystemTools::GetFilenameLastExtension(path) == ".xml") {
+      if (!this->ReadJacocoXML(path.c_str())) {
         return false;
-        }
       }
     }
+  }
   return true;
 }
 
 bool cmParseJacocoCoverage::ReadJacocoXML(const char* file)
 {
-  cmParseJacocoCoverage::XMLParser
-    parser(this->CTest, this->Coverage);
+  cmParseJacocoCoverage::XMLParser parser(this->CTest, this->Coverage);
   parser.ParseFile(file);
   return true;
 }
diff --git a/Source/CTest/cmParseJacocoCoverage.h b/Source/CTest/cmParseJacocoCoverage.h
index dad05a3..bcd472e 100644
--- a/Source/CTest/cmParseJacocoCoverage.h
+++ b/Source/CTest/cmParseJacocoCoverage.h
@@ -13,10 +13,8 @@
 #ifndef cmParseJacocoCoverage_h
 #define cmParseJacocoCoverage_h
 
-#include "cmStandardIncludes.h"
 #include "cmCTestCoverageHandler.h"
 
-
 /** \class cmParseJacocoCoverage
  * \brief Parse JaCoCO coverage information
  *
@@ -28,14 +26,14 @@
 class cmParseJacocoCoverage
 {
 public:
-  cmParseJacocoCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
-  bool LoadCoverageData(const std::vector<std::string> files);
+  cmParseJacocoCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
+  bool LoadCoverageData(std::vector<std::string> const& files);
 
   std::string PackageName;
   std::string FileName;
   std::string ModuleName;
   std::string CurFileName;
+
 private:
   // implement virtual from parent
   // remove files with no coverage
@@ -43,10 +41,8 @@ private:
   // Read a single mcov file
   bool ReadJacocoXML(const char* f);
   // split a string based on ,
-  bool SplitString(std::vector<std::string>& args,
-    std::string const& line);
-  bool FindJavaFile(std::string const& routine,
-    std::string& filepath);
+  bool SplitString(std::vector<std::string>& args, std::string const& line);
+  bool FindJavaFile(std::string const& routine, std::string& filepath);
   void InitializeJavaFile(std::string& file);
   bool LoadSource(std::string d);
 
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index 225e704..e5dd74a 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -1,17 +1,16 @@
-#include "cmStandardIncludes.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include "cmSystemTools.h"
 #include "cmParseGTMCoverage.h"
+
+#include "cmSystemTools.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
-
+#include <cmsys/Glob.hxx>
+#include <stdio.h>
+#include <stdlib.h>
 
 cmParseMumpsCoverage::cmParseMumpsCoverage(
-  cmCTestCoverageHandlerContainer& cont,
-  cmCTest* ctest)
-  :Coverage(cont), CTest(ctest)
+  cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+  : Coverage(cont)
+  , CTest(ctest)
 {
 }
 
@@ -25,37 +24,30 @@ bool cmParseMumpsCoverage::ReadCoverageFile(const char* file)
   // packages:/full/path/to/Vista/Packages
   // coverage_dir:/full/path/to/dir/with/*.mcov
   cmsys::ifstream in(file);
-  if(!in)
-    {
+  if (!in) {
     return false;
-    }
+  }
   std::string line;
-  while(cmSystemTools::GetLineFromStream(in, line))
-    {
+  while (cmSystemTools::GetLineFromStream(in, line)) {
     std::string::size_type pos = line.find(':', 0);
     std::string packages;
-    if(pos != std::string::npos)
-      {
+    if (pos != std::string::npos) {
       std::string type = line.substr(0, pos);
-      std::string path = line.substr(pos+1);
-      if(type == "packages")
-        {
+      std::string path = line.substr(pos + 1);
+      if (type == "packages") {
         this->LoadPackages(path.c_str());
-        }
-      else if(type == "coverage_dir")
-        {
+      } else if (type == "coverage_dir") {
         this->LoadCoverageData(path.c_str());
-        }
-      else
-        {
+      } else {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
                    "Parse Error in Mumps coverage file :\n"
-                   << file <<
-                   "\ntype: [" << type << "]\npath:[" << path << "]\n"
-                   "input line: [" << line << "]\n");
-        }
+                     << file << "\ntype: [" << type << "]\npath:[" << path
+                     << "]\n"
+                        "input line: ["
+                     << line << "]\n");
       }
     }
+  }
   return true;
 }
 
@@ -63,59 +55,50 @@ void cmParseMumpsCoverage::InitializeMumpsFile(std::string& file)
 {
   // initialize the coverage information for a given mumps file
   cmsys::ifstream in(file.c_str());
-  if(!in)
-    {
+  if (!in) {
     return;
-    }
+  }
   std::string line;
-  cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
-    coverageVector = this->Coverage.TotalCoverage[file];
-  if(!cmSystemTools::GetLineFromStream(in, line))
-    {
+  cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector =
+    this->Coverage.TotalCoverage[file];
+  if (!cmSystemTools::GetLineFromStream(in, line)) {
     return;
-    }
+  }
   // first line of a .m file can never be run
   coverageVector.push_back(-1);
-  while( cmSystemTools::GetLineFromStream(in, line) )
-    {
+  while (cmSystemTools::GetLineFromStream(in, line)) {
     // putting in a 0 for a line means it is executable code
     // putting in a -1 for a line means it is not executable code
     int val = -1; // assume line is not executable
     bool found = false;
     std::string::size_type i = 0;
     // (1) Search for the first whitespace or semicolon character on a line.
-    //This will skip over labels if the line starts with one, or will simply
-    //be the first character on the line for non-label lines.
-    for(; i < line.size(); ++i)
-      {
-      if(line[i] == ' ' || line[i] == '\t' || line[i] == ';')
-        {
+    // This will skip over labels if the line starts with one, or will simply
+    // be the first character on the line for non-label lines.
+    for (; i < line.size(); ++i) {
+      if (line[i] == ' ' || line[i] == '\t' || line[i] == ';') {
         found = true;
         break;
-        }
       }
-    if(found)
-      {
+    }
+    if (found) {
       // (2) If the first character found above is whitespace or a period
       // then continue the search for the first following non-whitespace
       // character.
-      if(line[i] == ' ' || line[i] == '\t')
-        {
-        while(i < line.size() && (line[i] == ' ' || line[i] == '\t'
-          || line[i] == '.'))
-          {
+      if (line[i] == ' ' || line[i] == '\t') {
+        while (i < line.size() &&
+               (line[i] == ' ' || line[i] == '\t' || line[i] == '.')) {
           i++;
-          }
         }
+      }
       // (3) If the character found is not a semicolon then the line counts for
       // coverage.
-      if(i < line.size() && line[i] != ';')
-        {
+      if (i < line.size() && line[i] != ';') {
         val = 0;
-        }
       }
-    coverageVector.push_back(val);
     }
+    coverageVector.push_back(val);
+  }
 }
 
 bool cmParseMumpsCoverage::LoadPackages(const char* d)
@@ -127,15 +110,13 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
   glob.FindFiles(pat);
   std::vector<std::string>& files = glob.GetFiles();
   std::vector<std::string>::iterator fileIt;
-  for ( fileIt = files.begin(); fileIt != files.end();
-        ++ fileIt )
-    {
+  for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     std::string name = cmSystemTools::GetFilenameName(*fileIt);
-    this->RoutineToDirectory[name.substr(0, name.size()-2)] = *fileIt;
+    this->RoutineToDirectory[name.substr(0, name.size() - 2)] = *fileIt;
     // initialze each file, this is left out until CDash is fixed
     // to handle large numbers of files
     this->InitializeMumpsFile(*fileIt);
-    }
+  }
   return true;
 }
 
@@ -144,25 +125,20 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
 {
   std::map<std::string, std::string>::iterator i =
     this->RoutineToDirectory.find(routine);
-  if(i != this->RoutineToDirectory.end())
-    {
+  if (i != this->RoutineToDirectory.end()) {
     filepath = i->second;
     return true;
-    }
-  else
-    {
+  } else {
     // try some alternate names
-    const char* tryname[] = {"GUX", "GTM", "ONT", 0};
-    for(int k=0; tryname[k] != 0; k++)
-      {
+    const char* tryname[] = { "GUX", "GTM", "ONT", 0 };
+    for (int k = 0; tryname[k] != 0; k++) {
       std::string routine2 = routine + tryname[k];
       i = this->RoutineToDirectory.find(routine2);
-      if(i != this->RoutineToDirectory.end())
-        {
+      if (i != this->RoutineToDirectory.end()) {
         filepath = i->second;
         return true;
-        }
       }
     }
+  }
   return false;
 }
diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h
index bc71891..3761ba6 100644
--- a/Source/CTest/cmParseMumpsCoverage.h
+++ b/Source/CTest/cmParseMumpsCoverage.h
@@ -13,7 +13,6 @@
 #ifndef cmParseMumpsCoverage_h
 #define cmParseMumpsCoverage_h
 
-#include "cmStandardIncludes.h"
 #include "cmCTestCoverageHandler.h"
 
 /** \class cmParseMumpsCoverage
@@ -25,12 +24,12 @@
 class cmParseMumpsCoverage
 {
 public:
-  cmParseMumpsCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
+  cmParseMumpsCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
   virtual ~cmParseMumpsCoverage();
   // This is the toplevel coverage file locating the coverage files
   // and the mumps source code package tree.
   bool ReadCoverageFile(const char* file);
+
 protected:
   // sub classes will use this to
   // load all coverage files found in the given directory
@@ -41,8 +40,8 @@ protected:
   // initialize the coverage information for a single mumps file
   void InitializeMumpsFile(std::string& file);
   // Find mumps file for routine
-  bool FindMumpsFile(std::string const& routine,
-                     std::string& filepath);
+  bool FindMumpsFile(std::string const& routine, std::string& filepath);
+
 protected:
   std::map<std::string, std::string> RoutineToDirectory;
   cmCTestCoverageHandlerContainer& Coverage;
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index c7f5a68..eb0d962 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -1,6 +1,6 @@
-#include "cmStandardIncludes.h"
-#include "cmSystemTools.h"
 #include "cmParsePHPCoverage.h"
+
+#include "cmSystemTools.h"
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
 
@@ -16,55 +16,48 @@
 */
 
 cmParsePHPCoverage::cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest)
-    :Coverage(cont), CTest(ctest)
+                                       cmCTest* ctest)
+  : Coverage(cont)
+  , CTest(ctest)
 {
 }
 
 bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until)
 {
   char c = 0;
-  while(in.get(c) && c != until)
-    {
-    }
-  if(c != until)
-    {
+  while (in.get(c) && c != until) {
+  }
+  if (c != until) {
     return false;
-    }
+  }
   return true;
 }
 bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
                                            std::string const& fileName)
 {
-  cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector
-    = this->Coverage.TotalCoverage[fileName];
+  cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector =
+    this->Coverage.TotalCoverage[fileName];
 
   char c;
   char buf[4];
   in.read(buf, 3);
   buf[3] = 0;
-  if(strcmp(buf, ";a:") != 0)
-    {
+  if (strcmp(buf, ";a:") != 0) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "failed to read start of coverage array, found : "
-               << buf << "\n");
+               "failed to read start of coverage array, found : " << buf
+                                                                  << "\n");
     return false;
-    }
+  }
   int size = 0;
-  if(!this->ReadInt(in, size))
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "failed to read size ");
+  if (!this->ReadInt(in, size)) {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read size ");
     return false;
-    }
-  if(!in.get(c) && c == '{')
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "failed to read open {\n");
+  }
+  if (!in.get(c) && c == '{') {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read open {\n");
     return false;
-    }
-  for(int i =0; i < size; i++)
-    {
+  }
+  for (int i = 0; i < size; i++) {
     this->ReadUntil(in, ':');
     int line = 0;
     this->ReadInt(in, line);
@@ -72,19 +65,17 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
     // it seems to be 1 based but often times
     // seems to have a 0'th line.
     line--;
-    if(line < 0)
-      {
+    if (line < 0) {
       line = 0;
-      }
+    }
     this->ReadUntil(in, ':');
     int value = 0;
     this->ReadInt(in, value);
     // make sure the vector is the right size and is
     // initialized with -1 for each line
-    while(coverageVector.size() <= static_cast<size_t>(line) )
-      {
+    while (coverageVector.size() <= static_cast<size_t>(line)) {
       coverageVector.push_back(-1);
-      }
+    }
     // if value is less than 0, set it to zero
     // TODO figure out the difference between
     // -1 and -2 in xdebug coverage??  For now
@@ -92,21 +83,18 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
     // CDash expects -1 for non executable code (like comments)
     // and 0 for uncovered code, and a positive value
     // for number of times a line was executed
-    if(value < 0)
-      {
+    if (value < 0) {
       value = 0;
-      }
+    }
     // if unset then set it to value
-    if(coverageVector[line] == -1)
-      {
+    if (coverageVector[line] == -1) {
       coverageVector[line] = value;
-      }
+    }
     // otherwise increment by value
-    else
-      {
+    else {
       coverageVector[line] += value;
-      }
     }
+  }
   return true;
 }
 
@@ -114,10 +102,9 @@ bool cmParsePHPCoverage::ReadInt(std::istream& in, int& v)
 {
   std::string s;
   char c = 0;
-  while(in.get(c) && c != ':' && c != ';')
-    {
+  while (in.get(c) && c != ':' && c != ';') {
     s += c;
-    }
+  }
   v = atoi(s.c_str());
   return true;
 }
@@ -126,17 +113,14 @@ bool cmParsePHPCoverage::ReadArraySize(std::istream& in, int& size)
 {
   char c = 0;
   in.get(c);
-  if(c != 'a')
-    {
+  if (c != 'a') {
     return false;
-    }
-  if(in.get(c) && c == ':')
-    {
-    if(this->ReadInt(in, size))
-      {
+  }
+  if (in.get(c) && c == ':') {
+    if (this->ReadInt(in, size)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
@@ -145,110 +129,91 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in)
   char buf[4];
   in.read(buf, 2);
   buf[2] = 0;
-  if(strcmp(buf, "s:") != 0)
-    {
+  if (strcmp(buf, "s:") != 0) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "failed to read start of file info found: [" << buf << "]\n");
     return false;
-    }
+  }
   char c;
   int size = 0;
-  if(this->ReadInt(in, size))
-    {
+  if (this->ReadInt(in, size)) {
     size++; // add one for null termination
-    char* s = new char[size+1];
+    char* s = new char[size + 1];
     // read open quote
-    if(in.get(c) && c != '"')
-      {
+    if (in.get(c) && c != '"') {
       delete[] s;
       return false;
-      }
+    }
     // read the string data
-    in.read(s, size-1);
-    s[size-1] = 0;
+    in.read(s, size - 1);
+    s[size - 1] = 0;
     std::string fileName = s;
-    delete [] s;
+    delete[] s;
     // read close quote
-    if(in.get(c) && c != '"')
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-                 "failed to read close quote\n"
-                 << "read [" << c << "]\n");
+    if (in.get(c) && c != '"') {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close quote\n"
+                   << "read [" << c << "]\n");
       return false;
-      }
-    if(!this->ReadCoverageArray(in, fileName) )
-      {
+    }
+    if (!this->ReadCoverageArray(in, fileName)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-                 "failed to read coverage array for file: "
-                 << fileName << "\n");
+                 "failed to read coverage array for file: " << fileName
+                                                            << "\n");
       return false;
-      }
-    return true;
     }
+    return true;
+  }
   return false;
 }
 
-
 bool cmParsePHPCoverage::ReadPHPData(const char* file)
 {
   cmsys::ifstream in(file);
-  if(!in)
-    {
+  if (!in) {
     return false;
-    }
+  }
   int size = 0;
   this->ReadArraySize(in, size);
   char c = 0;
   in.get(c);
-  if(c != '{')
-    {
-    cmCTestLog(this->CTest, ERROR_MESSAGE,
-               "failed to read open array\n");
+  if (c != '{') {
+    cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read open array\n");
     return false;
-    }
-  for(int i =0; i < size; i++)
-    {
-    if(!this->ReadFileInformation(in))
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-                 "Failed to read file #" << i << "\n");
+  }
+  for (int i = 0; i < size; i++) {
+    if (!this->ReadFileInformation(in)) {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "Failed to read file #" << i
+                                                                     << "\n");
       return false;
-      }
+    }
     in.get(c);
-    if(c != '}')
-      {
-      cmCTestLog(this->CTest, ERROR_MESSAGE,
-                 "failed to read close array\n");
+    if (c != '}') {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close array\n");
       return false;
-      }
     }
+  }
   return true;
 }
 
 bool cmParsePHPCoverage::ReadPHPCoverageDirectory(const char* d)
 {
   cmsys::Directory dir;
-  if(!dir.Load(d))
-    {
+  if (!dir.Load(d)) {
     return false;
-    }
+  }
   size_t numf;
   unsigned int i;
   numf = dir.GetNumberOfFiles();
-  for (i = 0; i < numf; i++)
-    {
+  for (i = 0; i < numf; i++) {
     std::string file = dir.GetFile(i);
-    if(file != "." && file != ".."
-       && !cmSystemTools::FileIsDirectory(file))
-      {
+    if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
       std::string path = d;
       path += "/";
       path += file;
-      if(!this->ReadPHPData(path.c_str()))
-        {
+      if (!this->ReadPHPData(path.c_str())) {
         return false;
-        }
       }
     }
+  }
   return true;
 }
diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h
index 92a7634..72f9129 100644
--- a/Source/CTest/cmParsePHPCoverage.h
+++ b/Source/CTest/cmParsePHPCoverage.h
@@ -13,7 +13,6 @@
 #ifndef cmParsePHPCoverage_h
 #define cmParsePHPCoverage_h
 
-#include "cmStandardIncludes.h"
 #include "cmCTestCoverageHandler.h"
 
 /** \class cmParsePHPCoverage
@@ -26,10 +25,10 @@
 class cmParsePHPCoverage
 {
 public:
-  cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
+  cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest);
   bool ReadPHPCoverageDirectory(const char* dir);
   void PrintCoverage();
+
 private:
   bool ReadPHPData(const char* file);
   bool ReadArraySize(std::istream& in, int& size);
@@ -41,5 +40,4 @@ private:
   cmCTest* CTest;
 };
 
-
 #endif
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 0c25f40..db5151c 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -11,6 +11,7 @@
 ============================================================================*/
 
 #include <cmProcess.h>
+
 #include <cmSystemTools.h>
 
 cmProcess::cmProcess()
@@ -39,50 +40,43 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
 
 bool cmProcess::StartProcess()
 {
-  if(this->Command.empty())
-    {
+  if (this->Command.empty()) {
     return false;
-    }
+  }
   this->StartTime = cmSystemTools::GetTime();
   this->ProcessArgs.clear();
   // put the command as arg0
   this->ProcessArgs.push_back(this->Command.c_str());
   // now put the command arguments in
-  for(std::vector<std::string>::iterator i = this->Arguments.begin();
-      i != this->Arguments.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = this->Arguments.begin();
+       i != this->Arguments.end(); ++i) {
     this->ProcessArgs.push_back(i->c_str());
-    }
+  }
   this->ProcessArgs.push_back(0); // null terminate the list
   this->Process = cmsysProcess_New();
   cmsysProcess_SetCommand(this->Process, &*this->ProcessArgs.begin());
-  if(!this->WorkingDirectory.empty())
-    {
+  if (!this->WorkingDirectory.empty()) {
     cmsysProcess_SetWorkingDirectory(this->Process,
                                      this->WorkingDirectory.c_str());
-    }
+  }
   cmsysProcess_SetTimeout(this->Process, this->Timeout);
   cmsysProcess_SetOption(this->Process, cmsysProcess_Option_MergeOutput, 1);
   cmsysProcess_Execute(this->Process);
-  return (cmsysProcess_GetState(this->Process)
-          == cmsysProcess_State_Executing);
+  return (cmsysProcess_GetState(this->Process) ==
+          cmsysProcess_State_Executing);
 }
 
-//----------------------------------------------------------------------------
 bool cmProcess::Buffer::GetLine(std::string& line)
 {
   // Scan for the next newline.
-  for(size_type sz = this->size(); this->Last != sz; ++this->Last)
-    {
-    if((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0')
-      {
+  for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
+    if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
       // Extract the range first..last as a line.
       const char* text = &*this->begin() + this->First;
       size_type length = this->Last - this->First;
-      while(length && text[length-1] == '\r')
-        {
-        length --;
-        }
+      while (length && text[length - 1] == '\r') {
+        length--;
+      }
       line.assign(text, length);
 
       // Start a new range for the next line.
@@ -91,75 +85,63 @@ bool cmProcess::Buffer::GetLine(std::string& line)
 
       // Return the line extracted.
       return true;
-      }
     }
+  }
 
   // Available data have been exhausted without a newline.
-  if(this->First != 0)
-    {
+  if (this->First != 0) {
     // Move the partial line to the beginning of the buffer.
     this->erase(this->begin(), this->begin() + this->First);
     this->First = 0;
     this->Last = this->size();
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmProcess::Buffer::GetLast(std::string& line)
 {
   // Return the partial last line, if any.
-  if(!this->empty())
-    {
+  if (!this->empty()) {
     line.assign(&*this->begin(), this->size());
     this->First = this->Last = 0;
     this->clear();
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 int cmProcess::GetNextOutputLine(std::string& line, double timeout)
 {
-  for(;;)
-    {
+  for (;;) {
     // Look for lines already buffered.
-    if(this->Output.GetLine(line))
-      {
+    if (this->Output.GetLine(line)) {
       return cmsysProcess_Pipe_STDOUT;
-      }
+    }
 
     // Check for more data from the process.
     char* data;
     int length;
     int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout);
-    if(p == cmsysProcess_Pipe_Timeout)
-      {
+    if (p == cmsysProcess_Pipe_Timeout) {
       return cmsysProcess_Pipe_Timeout;
-      }
-    else if(p == cmsysProcess_Pipe_STDOUT)
-      {
-      this->Output.insert(this->Output.end(), data, data+length);
-      }
-    else // p == cmsysProcess_Pipe_None
-      {
+    } else if (p == cmsysProcess_Pipe_STDOUT) {
+      this->Output.insert(this->Output.end(), data, data + length);
+    } else // p == cmsysProcess_Pipe_None
+    {
       // The process will provide no more data.
       break;
-      }
     }
+  }
 
   // Look for partial last lines.
-  if(this->Output.GetLast(line))
-    {
+  if (this->Output.GetLast(line)) {
     return cmsysProcess_Pipe_STDOUT;
-    }
+  }
 
   // No more data.  Wait for process exit.
-  if(!cmsysProcess_WaitForExit(this->Process, &timeout))
-    {
+  if (!cmsysProcess_WaitForExit(this->Process, &timeout)) {
     return cmsysProcess_Pipe_Timeout;
-    }
+  }
 
   // Record exit information.
   this->ExitValue = cmsysProcess_GetExitValue(this->Process);
@@ -168,10 +150,9 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
   // negative. If someone changed the system clock while the process was
   // running this may be even more. Make sure not to report a negative
   // duration here.
-  if (this->TotalTime <= 0.0)
-    {
+  if (this->TotalTime <= 0.0) {
     this->TotalTime = 0.0;
-    }
+  }
   //  std::cerr << "Time to run: " << this->TotalTime << "\n";
   return cmsysProcess_Pipe_None;
 }
@@ -179,89 +160,80 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
 // return the process status
 int cmProcess::GetProcessStatus()
 {
-  if(!this->Process)
-    {
+  if (!this->Process) {
     return cmsysProcess_State_Exited;
-    }
+  }
   return cmsysProcess_GetState(this->Process);
 }
 
 int cmProcess::ReportStatus()
 {
   int result = 1;
-  switch(cmsysProcess_GetState(this->Process))
-    {
-    case cmsysProcess_State_Starting:
-      {
-      std::cerr << "cmProcess: Never started "
-           << this->Command << " process.\n";
-      } break;
-    case cmsysProcess_State_Error:
-      {
+  switch (cmsysProcess_GetState(this->Process)) {
+    case cmsysProcess_State_Starting: {
+      std::cerr << "cmProcess: Never started " << this->Command
+                << " process.\n";
+    } break;
+    case cmsysProcess_State_Error: {
       std::cerr << "cmProcess: Error executing " << this->Command
-                << " process: "
-                << cmsysProcess_GetErrorString(this->Process)
+                << " process: " << cmsysProcess_GetErrorString(this->Process)
                 << "\n";
-      } break;
-    case cmsysProcess_State_Exception:
-      {
+    } break;
+    case cmsysProcess_State_Exception: {
       std::cerr << "cmProcess: " << this->Command
-                      << " process exited with an exception: ";
-      switch(cmsysProcess_GetExitException(this->Process))
-        {
-        case cmsysProcess_Exception_None:
-          {
+                << " process exited with an exception: ";
+      switch (cmsysProcess_GetExitException(this->Process)) {
+        case cmsysProcess_Exception_None: {
           std::cerr << "None";
-          } break;
-        case cmsysProcess_Exception_Fault:
-          {
+        } break;
+        case cmsysProcess_Exception_Fault: {
           std::cerr << "Segmentation fault";
-          } break;
-        case cmsysProcess_Exception_Illegal:
-          {
+        } break;
+        case cmsysProcess_Exception_Illegal: {
           std::cerr << "Illegal instruction";
-          } break;
-        case cmsysProcess_Exception_Interrupt:
-          {
+        } break;
+        case cmsysProcess_Exception_Interrupt: {
           std::cerr << "Interrupted by user";
-          } break;
-        case cmsysProcess_Exception_Numerical:
-          {
+        } break;
+        case cmsysProcess_Exception_Numerical: {
           std::cerr << "Numerical exception";
-          } break;
-        case cmsysProcess_Exception_Other:
-          {
+        } break;
+        case cmsysProcess_Exception_Other: {
           std::cerr << "Unknown";
-          } break;
-        }
+        } break;
+      }
       std::cerr << "\n";
-      } break;
-    case cmsysProcess_State_Executing:
-      {
-      std::cerr << "cmProcess: Never terminated " <<
-        this->Command << " process.\n";
-      } break;
-    case cmsysProcess_State_Exited:
-      {
+    } break;
+    case cmsysProcess_State_Executing: {
+      std::cerr << "cmProcess: Never terminated " << this->Command
+                << " process.\n";
+    } break;
+    case cmsysProcess_State_Exited: {
       result = cmsysProcess_GetExitValue(this->Process);
       std::cerr << "cmProcess: " << this->Command
-                << " process exited with code "
-                << result << "\n";
-      } break;
-    case cmsysProcess_State_Expired:
-      {
+                << " process exited with code " << result << "\n";
+    } break;
+    case cmsysProcess_State_Expired: {
       std::cerr << "cmProcess: killed " << this->Command
                 << " process due to timeout.\n";
-      } break;
-    case cmsysProcess_State_Killed:
-      {
+    } break;
+    case cmsysProcess_State_Killed: {
       std::cerr << "cmProcess: killed " << this->Command << " process.\n";
-      } break;
-    }
+    } break;
+  }
   return result;
+}
 
+void cmProcess::ChangeTimeout(double t)
+{
+  this->Timeout = t;
+  cmsysProcess_SetTimeout(this->Process, this->Timeout);
 }
 
+void cmProcess::ResetStartTime()
+{
+  cmsysProcess_ResetStartTime(this->Process);
+}
 
 int cmProcess::GetExitException()
 {
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index eddeeab..d5e2721 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -12,10 +12,9 @@
 #ifndef cmProcess_h
 #define cmProcess_h
 
-
 #include "cmStandardIncludes.h"
-#include <cmsys/Process.h>
 
+#include <cmsys/Process.h>
 
 /** \class cmProcess
  * \brief run a process with c++
@@ -27,11 +26,13 @@ class cmProcess
 public:
   cmProcess();
   ~cmProcess();
-  const char* GetCommand() { return this->Command.c_str();}
+  const char* GetCommand() { return this->Command.c_str(); }
   void SetCommand(const char* command);
   void SetCommandArguments(std::vector<std::string> const& arg);
-  void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir;}
-  void SetTimeout(double t) { this->Timeout = t;}
+  void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
+  void SetTimeout(double t) { this->Timeout = t; }
+  void ChangeTimeout(double t);
+  void ResetStartTime();
   // Return true if the process starts
   bool StartProcess();
 
@@ -40,9 +41,9 @@ public:
   // Report the status of the program
   int ReportStatus();
   int GetId() { return this->Id; }
-  void SetId(int id) { this->Id = id;}
-  int GetExitValue() { return this->ExitValue;}
-  double GetTotalTime() { return this->TotalTime;}
+  void SetId(int id) { this->Id = id; }
+  int GetExitValue() { return this->ExitValue; }
+  double GetTotalTime() { return this->TotalTime; }
   int GetExitException();
   /**
    * Read one line of output but block for no more than timeout.
@@ -52,18 +53,24 @@ public:
    *   cmsysProcess_Pipe_Timeout = Timeout expired while waiting
    */
   int GetNextOutputLine(std::string& line, double timeout);
+
 private:
   double Timeout;
   double StartTime;
   double TotalTime;
   cmsysProcess* Process;
-  class Buffer: public std::vector<char>
+  class Buffer : public std::vector<char>
   {
     // Half-open index range of partial line already scanned.
     size_type First;
     size_type Last;
+
   public:
-    Buffer(): First(0), Last(0) {}
+    Buffer()
+      : First(0)
+      , Last(0)
+    {
+    }
     bool GetLine(std::string& line);
     bool GetLast(std::string& line);
   };
diff --git a/Source/Checks/cm_c11_thread_local.c b/Source/Checks/cm_c11_thread_local.c
index ab780f2..bdf91aa 100644
--- a/Source/Checks/cm_c11_thread_local.c
+++ b/Source/Checks/cm_c11_thread_local.c
@@ -1,2 +1,5 @@
 _Thread_local int i = 42;
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Source/Checks/cm_cxx11_unordered_map.cpp b/Source/Checks/cm_cxx11_unordered_map.cpp
index beeb31b..be3de25 100644
--- a/Source/Checks/cm_cxx11_unordered_map.cpp
+++ b/Source/Checks/cm_cxx11_unordered_map.cpp
@@ -1,5 +1,6 @@
 #include <unordered_map>
-int main() {
+int main()
+{
   std::unordered_map<int, int> map;
   map[0] = 0;
   return 0;
diff --git a/Source/Checks/cm_cxx14_cstdio.cpp b/Source/Checks/cm_cxx14_cstdio.cpp
index 3a6a699..f5806a9 100644
--- a/Source/Checks/cm_cxx14_cstdio.cpp
+++ b/Source/Checks/cm_cxx14_cstdio.cpp
@@ -1,2 +1,5 @@
 #include <cstdio>
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 5236e57..be8751c 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -9,85 +9,70 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+#include "cmCursesStandardIncludes.h"
+
+#include "../cmDocumentation.h"
 #include "../cmSystemTools.h"
 #include "../cmake.h"
-#include "../cmDocumentation.h"
 
 #include <signal.h>
 #include <sys/ioctl.h>
 
 #include "cmCursesMainForm.h"
-#include "cmCursesStandardIncludes.h"
 #include <cmsys/Encoding.hxx>
 
 #include <form.h>
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationName[][2] =
-{
-  {0,
-   "  ccmake - Curses Interface for CMake."},
-  {0,0}
+static const char* cmDocumentationName[][2] = {
+  { 0, "  ccmake - Curses Interface for CMake." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsage[][2] =
-{
-  {0,
-   "  ccmake <path-to-source>\n"
-   "  ccmake <path-to-existing-build>"},
-  {0,
-   "Specify a source directory to (re-)generate a build system for "
-   "it in the current working directory.  Specify an existing build "
-   "directory to re-generate its build system."},
-  {0,0}
+static const char* cmDocumentationUsage[][2] = {
+  { 0, "  ccmake <path-to-source>\n"
+       "  ccmake <path-to-existing-build>" },
+  { 0, "Specify a source directory to (re-)generate a build system for "
+       "it in the current working directory.  Specify an existing build "
+       "directory to re-generate its build system." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsageNote[][2] =
-{
-  {0,
-   "Run 'ccmake --help' for more information."},
-  {0,0}
+static const char* cmDocumentationUsageNote[][2] = {
+  { 0, "Run 'ccmake --help' for more information." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationOptions[][2] =
-{
-  CMAKE_STANDARD_OPTIONS_TABLE,
-  {0,0}
-};
+static const char* cmDocumentationOptions[]
+                                         [2] = { CMAKE_STANDARD_OPTIONS_TABLE,
+                                                 { 0, 0 } };
 
-cmCursesForm* cmCursesForm::CurrentForm=0;
+cmCursesForm* cmCursesForm::CurrentForm = 0;
 
-extern "C"
-{
+extern "C" {
 
 void onsig(int)
 {
-  if (cmCursesForm::CurrentForm)
-    {
+  if (cmCursesForm::CurrentForm) {
     endwin();
-    initscr(); /* Initialization */
-    noecho(); /* Echo off */
-    cbreak(); /* nl- or cr not needed */
-    keypad(stdscr,TRUE); /* Use key symbols as
-                            KEY_DOWN*/
+    initscr();            /* Initialization */
+    noecho();             /* Echo off */
+    cbreak();             /* nl- or cr not needed */
+    keypad(stdscr, TRUE); /* Use key symbols as
+                             KEY_DOWN*/
     refresh();
-    int x,y;
+    int x, y;
     getmaxyx(stdscr, y, x);
-    cmCursesForm::CurrentForm->Render(1,1,x,y);
+    cmCursesForm::CurrentForm->Render(1, 1, x, y);
     cmCursesForm::CurrentForm->UpdateStatusBar();
-    }
+  }
   signal(SIGWINCH, onsig);
 }
-
 }
 
 void CMakeMessageHandler(const char* message, const char* title, bool&,
                          void* clientData)
 {
-  cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
+  cmCursesForm* self = static_cast<cmCursesForm*>(clientData);
   self->AddError(message, title);
 }
 
@@ -101,8 +86,7 @@ int main(int argc, char const* const* argv)
   cmSystemTools::FindCMakeResources(argv[0]);
   cmDocumentation doc;
   doc.addCMakeStandardDocSections();
-  if(doc.CheckOptions(argc, argv))
-    {
+  if (doc.CheckOptions(argc, argv)) {
     cmake hcm;
     hcm.SetHomeDirectory("");
     hcm.SetHomeOutputDirectory("");
@@ -110,95 +94,82 @@ int main(int argc, char const* const* argv)
     std::vector<cmDocumentationEntry> generators;
     hcm.GetGeneratorDocumentation(generators);
     doc.SetName("ccmake");
-    doc.SetSection("Name",cmDocumentationName);
-    doc.SetSection("Usage",cmDocumentationUsage);
-    if ( argc == 1 )
-      {
-      doc.AppendSection("Usage",cmDocumentationUsageNote);
-      }
-    doc.SetSection("Generators",generators);
-    doc.PrependSection("Options",cmDocumentationOptions);
-    return doc.PrintRequestedDocumentation(std::cout)? 0:1;
+    doc.SetSection("Name", cmDocumentationName);
+    doc.SetSection("Usage", cmDocumentationUsage);
+    if (argc == 1) {
+      doc.AppendSection("Usage", cmDocumentationUsageNote);
     }
+    doc.SetSection("Generators", generators);
+    doc.PrependSection("Options", cmDocumentationOptions);
+    return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
+  }
 
   bool debug = false;
   unsigned int i;
   int j;
   std::vector<std::string> args;
-  for(j =0; j < argc; ++j)
-    {
-    if(strcmp(argv[j], "-debug") == 0)
-      {
+  for (j = 0; j < argc; ++j) {
+    if (strcmp(argv[j], "-debug") == 0) {
       debug = true;
-      }
-    else
-      {
+    } else {
       args.push_back(argv[j]);
-      }
     }
+  }
 
   std::string cacheDir = cmSystemTools::GetCurrentWorkingDirectory();
-  for(i=1; i < args.size(); ++i)
-    {
+  for (i = 1; i < args.size(); ++i) {
     std::string arg = args[i];
-    if(arg.find("-B",0) == 0)
-      {
+    if (arg.find("-B", 0) == 0) {
       cacheDir = arg.substr(2);
-      }
     }
+  }
 
   cmSystemTools::DisableRunCommandOutput();
 
-  if (debug)
-    {
+  if (debug) {
     cmCursesForm::DebugStart();
-    }
+  }
 
-  initscr(); /* Initialization */
-  noecho(); /* Echo off */
-  cbreak(); /* nl- or cr not needed */
-  keypad(stdscr,TRUE); /* Use key symbols as
-                          KEY_DOWN*/
+  initscr();            /* Initialization */
+  noecho();             /* Echo off */
+  cbreak();             /* nl- or cr not needed */
+  keypad(stdscr, TRUE); /* Use key symbols as
+                           KEY_DOWN*/
 
   signal(SIGWINCH, onsig);
 
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
-  if ( x < cmCursesMainForm::MIN_WIDTH  ||
-       y < cmCursesMainForm::MIN_HEIGHT )
-    {
+  if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
     endwin();
     std::cerr << "Window is too small. A size of at least "
               << cmCursesMainForm::MIN_WIDTH << " x "
-              <<  cmCursesMainForm::MIN_HEIGHT
-              << " is required to run ccmake." <<  std::endl;
+              << cmCursesMainForm::MIN_HEIGHT << " is required to run ccmake."
+              << std::endl;
     return 1;
-    }
-
+  }
 
   cmCursesMainForm* myform;
 
   myform = new cmCursesMainForm(args, x);
-  if(myform->LoadCache(cacheDir.c_str()))
-    {
+  if (myform->LoadCache(cacheDir.c_str())) {
     curses_clear();
     touchwin(stdscr);
     endwin();
     delete myform;
     std::cerr << "Error running cmake::LoadCache().  Aborting.\n";
     return 1;
-    }
+  }
 
   cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
 
   cmCursesForm::CurrentForm = myform;
 
   myform->InitializeUI();
-  if ( myform->Configure(1) == 0 )
-    {
+  if (myform->Configure(1) == 0) {
     myform->Render(1, 1, x, y);
     myform->HandleInput();
-    }
+  }
 
   // Need to clean-up better
   curses_clear();
@@ -210,5 +181,4 @@ int main(int argc, char const* const* argv)
   std::cout << std::endl << std::endl;
 
   return 0;
-
 }
diff --git a/Source/CursesDialog/cmCursesBoolWidget.cxx b/Source/CursesDialog/cmCursesBoolWidget.cxx
index 29d9cb2..0055e88 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.cxx
+++ b/Source/CursesDialog/cmCursesBoolWidget.cxx
@@ -10,16 +10,17 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCursesBoolWidget.h"
+
 #include "cmCursesMainForm.h"
 
-cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
-                                       int left, int top) :
-  cmCursesWidget(width, height, left, top)
+cmCursesBoolWidget::cmCursesBoolWidget(int width, int height, int left,
+                                       int top)
+  : cmCursesWidget(width, height, left, top)
 {
   this->Type = cmState::BOOL;
-  set_field_fore(this->Field,  A_NORMAL);
-  set_field_back(this->Field,  A_STANDOUT);
-  field_opts_off(this->Field,  O_STATIC);
+  set_field_fore(this->Field, A_NORMAL);
+  set_field_back(this->Field, A_STANDOUT);
+  field_opts_off(this->Field, O_STATIC);
   this->SetValueAsBool(false);
 }
 
@@ -27,48 +28,35 @@ bool cmCursesBoolWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
 {
 
   // 10 == enter
-  if (key == 10 || key == KEY_ENTER)
-    {
-    if (this->GetValueAsBool())
-      {
+  if (key == 10 || key == KEY_ENTER) {
+    if (this->GetValueAsBool()) {
       this->SetValueAsBool(false);
-      }
-    else
-      {
+    } else {
       this->SetValueAsBool(true);
-      }
+    }
 
     touchwin(w);
     wrefresh(w);
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
-
+  }
 }
 
 void cmCursesBoolWidget::SetValueAsBool(bool value)
 {
-  if (value)
-    {
+  if (value) {
     this->SetValue("ON");
-    }
-  else
-    {
+  } else {
     this->SetValue("OFF");
-    }
+  }
 }
 
 bool cmCursesBoolWidget::GetValueAsBool()
 {
-  if (this->Value == "ON")
-    {
+  if (this->Value == "ON") {
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
diff --git a/Source/CursesDialog/cmCursesBoolWidget.h b/Source/CursesDialog/cmCursesBoolWidget.h
index 8a57c73..49be45a 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.h
+++ b/Source/CursesDialog/cmCursesBoolWidget.h
@@ -13,6 +13,7 @@
 #define cmCursesBoolWidget_h
 
 #include "cmCursesWidget.h"
+
 class cmCursesMainForm;
 
 class cmCursesBoolWidget : public cmCursesWidget
@@ -34,7 +35,6 @@ public:
 protected:
   cmCursesBoolWidget(const cmCursesBoolWidget& from);
   void operator=(const cmCursesBoolWidget&);
-
 };
 
 #endif // cmCursesBoolWidget_h
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index 7e09242..bdfc8e9 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -10,24 +10,25 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCursesCacheEntryComposite.h"
-#include "cmCursesOptionsWidget.h"
-#include "cmCursesStringWidget.h"
-#include "cmCursesLabelWidget.h"
-#include "cmCursesBoolWidget.h"
-#include "cmCursesPathWidget.h"
-#include "cmCursesFilePathWidget.h"
-#include "cmCursesDummyWidget.h"
+
+#include "../cmState.h"
 #include "../cmSystemTools.h"
 #include "../cmake.h"
-#include "../cmState.h"
+#include "cmCursesBoolWidget.h"
+#include "cmCursesDummyWidget.h"
+#include "cmCursesFilePathWidget.h"
+#include "cmCursesLabelWidget.h"
+#include "cmCursesOptionsWidget.h"
+#include "cmCursesPathWidget.h"
+#include "cmCursesStringWidget.h"
 
 #include <assert.h>
 
 cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
-                                                        const std::string& key,
-                                                        int labelwidth,
-                                                        int entrywidth) :
-  Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
+  const std::string& key, int labelwidth, int entrywidth)
+  : Key(key)
+  , LabelWidth(labelwidth)
+  , EntryWidth(entrywidth)
 {
   this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
   this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
@@ -36,35 +37,30 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
 }
 
 cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
-  const std::string& key, cmake *cm, bool isNew,
-  int labelwidth, int entrywidth)
-  : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
+  const std::string& key, cmake* cm, bool isNew, int labelwidth,
+  int entrywidth)
+  : Key(key)
+  , LabelWidth(labelwidth)
+  , EntryWidth(entrywidth)
 {
   this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
-  if (isNew)
-    {
+  if (isNew) {
     this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*");
-    }
-  else
-    {
+  } else {
     this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
-    }
+  }
 
   this->Entry = 0;
   const char* value = cm->GetState()->GetCacheEntryValue(key);
   assert(value);
-  switch (cm->GetState()->GetCacheEntryType(key))
-    {
+  switch (cm->GetState()->GetCacheEntryType(key)) {
     case cmState::BOOL:
       this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
-      if (cmSystemTools::IsOn(value))
-        {
+      if (cmSystemTools::IsOn(value)) {
         static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
-        }
-      else
-        {
+      } else {
         static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false);
-        }
+      }
       break;
     case cmState::PATH:
       this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
@@ -74,40 +70,33 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
       this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
       static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
       break;
-    case cmState::STRING:
-      {
-      const char* stringsProp = cm->GetState()
-                                  ->GetCacheEntryProperty(key, "STRINGS");
-      if(stringsProp)
-        {
+    case cmState::STRING: {
+      const char* stringsProp =
+        cm->GetState()->GetCacheEntryProperty(key, "STRINGS");
+      if (stringsProp) {
         cmCursesOptionsWidget* ow =
           new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1);
         this->Entry = ow;
         std::vector<std::string> options;
         cmSystemTools::ExpandListArgument(stringsProp, options);
-        for(std::vector<std::string>::iterator
-              si = options.begin(); si != options.end(); ++si)
-          {
+        for (std::vector<std::string>::iterator si = options.begin();
+             si != options.end(); ++si) {
           ow->AddOption(*si);
-          }
-        ow->SetOption(value);
         }
-      else
-        {
+        ow->SetOption(value);
+      } else {
         this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
         static_cast<cmCursesStringWidget*>(this->Entry)->SetString(value);
-        }
-      break;
       }
+      break;
+    }
     case cmState::UNINITIALIZED:
-      cmSystemTools::Error("Found an undefined variable: ",
-                           key.c_str());
+      cmSystemTools::Error("Found an undefined variable: ", key.c_str());
       break;
     default:
       // TODO : put warning message here
       break;
-    }
-
+  }
 }
 
 cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
@@ -119,12 +108,9 @@ cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
 
 const char* cmCursesCacheEntryComposite::GetValue()
 {
-  if (this->Label)
-    {
+  if (this->Label) {
     return this->Label->GetValue();
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h
index f280897..8ed3902 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.h
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h
@@ -19,9 +19,8 @@ class cmCursesCacheEntryComposite
 public:
   cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
                               int entrywidth);
-  cmCursesCacheEntryComposite(const std::string& key,
-                              cmake *cm,
-                              bool isNew, int labelwidth, int entrywidth);
+  cmCursesCacheEntryComposite(const std::string& key, cmake* cm, bool isNew,
+                              int labelwidth, int entrywidth);
   ~cmCursesCacheEntryComposite();
   const char* GetValue();
 
diff --git a/Source/CursesDialog/cmCursesDummyWidget.cxx b/Source/CursesDialog/cmCursesDummyWidget.cxx
index 9801e4d..3cd36af 100644
--- a/Source/CursesDialog/cmCursesDummyWidget.cxx
+++ b/Source/CursesDialog/cmCursesDummyWidget.cxx
@@ -11,16 +11,14 @@
 ============================================================================*/
 #include "cmCursesDummyWidget.h"
 
-cmCursesDummyWidget::cmCursesDummyWidget(int width, int height,
-                                           int left, int top) :
-  cmCursesWidget(width, height, left, top)
+cmCursesDummyWidget::cmCursesDummyWidget(int width, int height, int left,
+                                         int top)
+  : cmCursesWidget(width, height, left, top)
 {
   this->Type = cmState::INTERNAL;
 }
 
-
-bool cmCursesDummyWidget::HandleInput(int&, cmCursesMainForm*, WINDOW* )
+bool cmCursesDummyWidget::HandleInput(int&, cmCursesMainForm*, WINDOW*)
 {
   return false;
 }
-
diff --git a/Source/CursesDialog/cmCursesDummyWidget.h b/Source/CursesDialog/cmCursesDummyWidget.h
index 2b3b9b5..9a3df29 100644
--- a/Source/CursesDialog/cmCursesDummyWidget.h
+++ b/Source/CursesDialog/cmCursesDummyWidget.h
@@ -30,7 +30,6 @@ public:
 protected:
   cmCursesDummyWidget(const cmCursesDummyWidget& from);
   void operator=(const cmCursesDummyWidget&);
-
 };
 
 #endif // cmCursesDummyWidget_h
diff --git a/Source/CursesDialog/cmCursesFilePathWidget.cxx b/Source/CursesDialog/cmCursesFilePathWidget.cxx
index 51ed670..28a74a9 100644
--- a/Source/CursesDialog/cmCursesFilePathWidget.cxx
+++ b/Source/CursesDialog/cmCursesFilePathWidget.cxx
@@ -11,10 +11,9 @@
 ============================================================================*/
 #include "cmCursesFilePathWidget.h"
 
-cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height,
-                                           int left, int top) :
-  cmCursesPathWidget(width, height, left, top)
+cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height, int left,
+                                               int top)
+  : cmCursesPathWidget(width, height, left, top)
 {
   this->Type = cmState::FILEPATH;
 }
-
diff --git a/Source/CursesDialog/cmCursesFilePathWidget.h b/Source/CursesDialog/cmCursesFilePathWidget.h
index 6c50dd4..72adc77 100644
--- a/Source/CursesDialog/cmCursesFilePathWidget.h
+++ b/Source/CursesDialog/cmCursesFilePathWidget.h
@@ -22,7 +22,6 @@ public:
 protected:
   cmCursesFilePathWidget(const cmCursesFilePathWidget& from);
   void operator=(const cmCursesFilePathWidget&);
-
 };
 
 #endif // cmCursesFilePathWidget_h
diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx
index d1b470c..aa4710f 100644
--- a/Source/CursesDialog/cmCursesForm.cxx
+++ b/Source/CursesDialog/cmCursesForm.cxx
@@ -21,12 +21,11 @@ cmCursesForm::cmCursesForm()
 
 cmCursesForm::~cmCursesForm()
 {
-  if (this->Form)
-    {
+  if (this->Form) {
     unpost_form(this->Form);
     free_form(this->Form);
     this->Form = 0;
-    }
+  }
 }
 
 void cmCursesForm::DebugStart()
@@ -37,10 +36,9 @@ void cmCursesForm::DebugStart()
 
 void cmCursesForm::DebugEnd()
 {
-  if (!cmCursesForm::Debug)
-    {
+  if (!cmCursesForm::Debug) {
     return;
-    }
+  }
 
   cmCursesForm::Debug = false;
   cmCursesForm::DebugFile.close();
@@ -48,10 +46,9 @@ void cmCursesForm::DebugEnd()
 
 void cmCursesForm::LogMessage(const char* msg)
 {
-  if (!cmCursesForm::Debug)
-    {
+  if (!cmCursesForm::Debug) {
     return;
-    }
+  }
 
   cmCursesForm::DebugFile << msg << std::endl;
 }
diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h
index 9837f5a..c0192fc 100644
--- a/Source/CursesDialog/cmCursesForm.h
+++ b/Source/CursesDialog/cmCursesForm.h
@@ -12,8 +12,8 @@
 #ifndef cmCursesForm_h
 #define cmCursesForm_h
 
-#include "../cmStandardIncludes.h"
 #include "cmCursesStandardIncludes.h"
+
 #include <cmsys/FStream.hxx>
 
 class cmCursesForm
@@ -54,16 +54,11 @@ public:
 
   // Description:
   // Return the FORM. Should be only used by low-level methods.
-  FORM* GetForm()
-    {
-      return this->Form;
-    }
+  FORM* GetForm() { return this->Form; }
 
   static cmCursesForm* CurrentForm;
 
-
 protected:
-
   static cmsys::ofstream DebugFile;
   static bool Debug;
 
diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx
index b50eb64..e9da71e 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.cxx
+++ b/Source/CursesDialog/cmCursesLabelWidget.cxx
@@ -11,14 +11,13 @@
 ============================================================================*/
 #include "cmCursesLabelWidget.h"
 
-cmCursesLabelWidget::cmCursesLabelWidget(int width, int height,
-                                         int left, int top,
-                                         const std::string& name) :
-  cmCursesWidget(width, height, left, top)
+cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, int left,
+                                         int top, const std::string& name)
+  : cmCursesWidget(width, height, left, top)
 {
-  field_opts_off(this->Field,  O_EDIT);
-  field_opts_off(this->Field,  O_ACTIVE);
-  field_opts_off(this->Field,  O_STATIC);
+  field_opts_off(this->Field, O_EDIT);
+  field_opts_off(this->Field, O_ACTIVE);
+  field_opts_off(this->Field, O_STATIC);
   this->SetValue(name);
 }
 
@@ -26,7 +25,7 @@ cmCursesLabelWidget::~cmCursesLabelWidget()
 {
 }
 
-bool cmCursesLabelWidget::HandleInput(int&, cmCursesMainForm*, WINDOW* )
+bool cmCursesLabelWidget::HandleInput(int&, cmCursesMainForm*, WINDOW*)
 {
   // Static text. No input is handled here.
   return false;
diff --git a/Source/CursesDialog/cmCursesLabelWidget.h b/Source/CursesDialog/cmCursesLabelWidget.h
index 98170f5..c31a58c 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.h
+++ b/Source/CursesDialog/cmCursesLabelWidget.h
@@ -13,7 +13,6 @@
 #define cmCursesLabelWidget_h
 
 #include "cmCursesWidget.h"
-#include "cmCursesStandardIncludes.h"
 
 class cmCursesMainForm;
 
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index 6144ddc..84672ae 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -9,29 +9,28 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+#include "cmCursesLongMessageForm.h"
+
 #include "../cmSystemTools.h"
-#include "../cmake.h"
 #include "../cmVersion.h"
-#include "cmCursesLongMessageForm.h"
+#include "../cmake.h"
 #include "cmCursesMainForm.h"
 
 inline int ctrl(int z)
 {
-    return (z&037);
+  return (z & 037);
 }
 
-cmCursesLongMessageForm::cmCursesLongMessageForm(std::vector<std::string>
-                                                 const& messages, const char*
-                                                 title)
+cmCursesLongMessageForm::cmCursesLongMessageForm(
+  std::vector<std::string> const& messages, const char* title)
 {
   // Append all messages into on big string
   std::vector<std::string>::const_iterator it;
-  for(it=messages.begin(); it != messages.end(); it++)
-    {
+  for (it = messages.begin(); it != messages.end(); it++) {
     this->Messages += (*it);
     // Add one blank line after each message
     this->Messages += "\n\n";
-    }
+  }
   this->Title = title;
   this->Fields[0] = 0;
   this->Fields[1] = 0;
@@ -39,170 +38,145 @@ cmCursesLongMessageForm::cmCursesLongMessageForm(std::vector<std::string>
 
 cmCursesLongMessageForm::~cmCursesLongMessageForm()
 {
-  if (this->Fields[0])
-    {
+  if (this->Fields[0]) {
     free_field(this->Fields[0]);
-    }
+  }
 }
 
-
 void cmCursesLongMessageForm::UpdateStatusBar()
 {
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
 
   char bar[cmCursesMainForm::MAX_WIDTH];
   size_t size = strlen(this->Title.c_str());
-  if ( size >= cmCursesMainForm::MAX_WIDTH )
-    {
-    size = cmCursesMainForm::MAX_WIDTH-1;
-    }
+  if (size >= cmCursesMainForm::MAX_WIDTH) {
+    size = cmCursesMainForm::MAX_WIDTH - 1;
+  }
   strncpy(bar, this->Title.c_str(), size);
-  for(size_t i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' ';
+  for (size_t i = size - 1; i < cmCursesMainForm::MAX_WIDTH; i++)
+    bar[i] = ' ';
 
   int width;
-  if (x < cmCursesMainForm::MAX_WIDTH )
-    {
+  if (x < cmCursesMainForm::MAX_WIDTH) {
     width = x;
-    }
-  else
-    {
-    width = cmCursesMainForm::MAX_WIDTH-1;
-    }
+  } else {
+    width = cmCursesMainForm::MAX_WIDTH - 1;
+  }
 
   bar[width] = '\0';
 
   char version[cmCursesMainForm::MAX_WIDTH];
   char vertmp[128];
-  sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
-  size_t sideSpace = (width-strlen(vertmp));
-  for(size_t i=0; i<sideSpace; i++) { version[i] = ' '; }
-  sprintf(version+sideSpace, "%s", vertmp);
+  sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
+  size_t sideSpace = (width - strlen(vertmp));
+  for (size_t i = 0; i < sideSpace; i++) {
+    version[i] = ' ';
+  }
+  sprintf(version + sideSpace, "%s", vertmp);
   version[width] = '\0';
 
   char fmt_s[] = "%s";
-  curses_move(y-4,0);
+  curses_move(y - 4, 0);
   attron(A_STANDOUT);
   printw(fmt_s, bar);
   attroff(A_STANDOUT);
-  curses_move(y-3,0);
+  curses_move(y - 3, 0);
   printw(fmt_s, version);
   pos_form_cursor(this->Form);
 }
 
 void cmCursesLongMessageForm::PrintKeys()
 {
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
-  if ( x < cmCursesMainForm::MIN_WIDTH  ||
-       y < cmCursesMainForm::MIN_HEIGHT )
-    {
+  if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
     return;
-    }
+  }
   char firstLine[512];
-  sprintf(firstLine,  "Press [e] to exit help");
+  sprintf(firstLine, "Press [e] to exit help");
 
   char fmt_s[] = "%s";
-  curses_move(y-2,0);
+  curses_move(y - 2, 0);
   printw(fmt_s, firstLine);
   pos_form_cursor(this->Form);
-
 }
 
 void cmCursesLongMessageForm::Render(int, int, int, int)
 {
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
 
-  if (this->Form)
-    {
+  if (this->Form) {
     unpost_form(this->Form);
     free_form(this->Form);
     this->Form = 0;
-    }
+  }
 
   const char* msg = this->Messages.c_str();
 
   curses_clear();
 
-  if (this->Fields[0])
-    {
+  if (this->Fields[0]) {
     free_field(this->Fields[0]);
     this->Fields[0] = 0;
-    }
+  }
 
-  this->Fields[0] = new_field(y-6, x-2, 1, 1, 0, 0);
+  this->Fields[0] = new_field(y - 6, x - 2, 1, 1, 0, 0);
 
-  field_opts_off(this->Fields[0],  O_STATIC);
+  field_opts_off(this->Fields[0], O_STATIC);
 
   this->Form = new_form(this->Fields);
   post_form(this->Form);
 
-  int i=0;
+  int i = 0;
   form_driver(this->Form, REQ_BEG_FIELD);
-  while(msg[i] != '\0' && i < 60000)
-    {
-    if (msg[i] == '\n' && msg[i+1] != '\0')
-      {
+  while (msg[i] != '\0' && i < 60000) {
+    if (msg[i] == '\n' && msg[i + 1] != '\0') {
       form_driver(this->Form, REQ_NEW_LINE);
-      }
-    else
-      {
+    } else {
       form_driver(this->Form, msg[i]);
-      }
-    i++;
     }
+    i++;
+  }
   form_driver(this->Form, REQ_BEG_FIELD);
 
   this->UpdateStatusBar();
   this->PrintKeys();
   touchwin(stdscr);
   refresh();
-
 }
 
 void cmCursesLongMessageForm::HandleInput()
 {
-  if (!this->Form)
-    {
+  if (!this->Form) {
     return;
-    }
+  }
 
   char debugMessage[128];
 
-  for(;;)
-    {
+  for (;;) {
     int key = getch();
 
     sprintf(debugMessage, "Message widget handling input, key: %d", key);
     cmCursesForm::LogMessage(debugMessage);
 
     // quit
-    if ( key == 'o' || key == 'e' )
-      {
+    if (key == 'o' || key == 'e') {
       break;
-      }
-    else if ( key == KEY_DOWN || key == ctrl('n') )
-      {
+    } else if (key == KEY_DOWN || key == ctrl('n')) {
       form_driver(this->Form, REQ_SCR_FLINE);
-      }
-    else if ( key == KEY_UP  || key == ctrl('p') )
-      {
+    } else if (key == KEY_UP || key == ctrl('p')) {
       form_driver(this->Form, REQ_SCR_BLINE);
-      }
-    else if ( key == KEY_NPAGE || key == ctrl('d') )
-      {
+    } else if (key == KEY_NPAGE || key == ctrl('d')) {
       form_driver(this->Form, REQ_SCR_FPAGE);
-      }
-    else if ( key == KEY_PPAGE || key == ctrl('u') )
-      {
+    } else if (key == KEY_PPAGE || key == ctrl('u')) {
       form_driver(this->Form, REQ_SCR_BPAGE);
-      }
+    }
 
     this->UpdateStatusBar();
     this->PrintKeys();
     touchwin(stdscr);
     wrefresh(stdscr);
-    }
-
+  }
 }
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h
index 6e37eea..73ccfc4 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.h
+++ b/Source/CursesDialog/cmCursesLongMessageForm.h
@@ -12,10 +12,10 @@
 #ifndef cmCursesLongMessageForm_h
 #define cmCursesLongMessageForm_h
 
-#include "../cmStandardIncludes.h"
-#include "cmCursesForm.h"
 #include "cmCursesStandardIncludes.h"
 
+#include "cmCursesForm.h"
+
 class cmCursesCacheEntryComposite;
 
 class cmCursesLongMessageForm : public cmCursesForm
@@ -52,7 +52,6 @@ protected:
   std::string Title;
 
   FIELD* Fields[2];
-
 };
 
 #endif // cmCursesLongMessageForm_h
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index a2fc2c0..b740eb0 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -9,30 +9,31 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+#include "cmCursesMainForm.h"
+
 #include "../cmSystemTools.h"
 #include "../cmVersion.h"
 #include "../cmake.h"
-#include "cmCursesMainForm.h"
-#include "cmCursesStringWidget.h"
-#include "cmCursesLabelWidget.h"
+#include "cmAlgorithms.h"
 #include "cmCursesBoolWidget.h"
-#include "cmCursesPathWidget.h"
-#include "cmCursesFilePathWidget.h"
-#include "cmCursesDummyWidget.h"
 #include "cmCursesCacheEntryComposite.h"
+#include "cmCursesDummyWidget.h"
+#include "cmCursesFilePathWidget.h"
+#include "cmCursesLabelWidget.h"
 #include "cmCursesLongMessageForm.h"
-#include "cmAlgorithms.h"
+#include "cmCursesPathWidget.h"
+#include "cmCursesStringWidget.h"
 #include "cmState.h"
 
-
 inline int ctrl(int z)
 {
-    return (z&037);
+  return (z & 037);
 }
 
 cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
-                                   int initWidth) :
-  Args(args), InitialWidth(initWidth)
+                                   int initWidth)
+  : Args(args)
+  , InitialWidth(initWidth)
 {
   this->NumberOfPages = 0;
   this->Fields = 0;
@@ -40,7 +41,8 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
   this->AdvancedMode = false;
   this->NumberOfVisibleEntries = 0;
   this->OkToGenerate = false;
-  this->HelpMessage.push_back("Welcome to ccmake, curses based user interface for CMake.");
+  this->HelpMessage.push_back(
+    "Welcome to ccmake, curses based user interface for CMake.");
   this->HelpMessage.push_back("");
   this->HelpMessage.push_back(s_ConstHelpMessage);
   this->CMakeInstance = new cmake;
@@ -59,43 +61,37 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
 
 cmCursesMainForm::~cmCursesMainForm()
 {
-  if (this->Form)
-    {
+  if (this->Form) {
     unpost_form(this->Form);
     free_form(this->Form);
     this->Form = 0;
-    }
+  }
   delete[] this->Fields;
 
   // Clean-up composites
-  if (this->Entries)
-    {
+  if (this->Entries) {
     cmDeleteAll(*this->Entries);
-    }
+  }
   delete this->Entries;
-  if (this->CMakeInstance)
-    {
+  if (this->CMakeInstance) {
     delete this->CMakeInstance;
     this->CMakeInstance = 0;
-    }
+  }
 }
 
 // See if a cache entry is in the list of entries in the ui.
 bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
 {
-  if (!this->Entries)
-    {
+  if (!this->Entries) {
     return false;
-    }
+  }
 
   std::vector<cmCursesCacheEntryComposite*>::iterator it;
-  for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-    {
-    if (key == (*it)->Key)
-      {
+  for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
+    if (key == (*it)->Key) {
       return true;
-      }
     }
+  }
 
   return false;
 }
@@ -108,93 +104,74 @@ void cmCursesMainForm::InitializeUI()
   std::vector<cmCursesCacheEntryComposite*>* newEntries =
     new std::vector<cmCursesCacheEntryComposite*>;
   std::vector<std::string> cacheKeys =
-      this->CMakeInstance->GetState()->GetCacheEntryKeys();
+    this->CMakeInstance->GetState()->GetCacheEntryKeys();
   newEntries->reserve(cacheKeys.size());
 
   // Count non-internal and non-static entries
-  int count=0;
-
-  for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
-      it != cacheKeys.end(); ++it)
-    {
-    cmState::CacheEntryType t = this->CMakeInstance->GetState()
-        ->GetCacheEntryType(*it);
-    if (t != cmState::INTERNAL &&
-        t != cmState::STATIC &&
-        t != cmState::UNINITIALIZED)
-      {
+  int count = 0;
+
+  for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+       it != cacheKeys.end(); ++it) {
+    cmState::CacheEntryType t =
+      this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+    if (t != cmState::INTERNAL && t != cmState::STATIC &&
+        t != cmState::UNINITIALIZED) {
       ++count;
-      }
     }
+  }
 
   int entrywidth = this->InitialWidth - 35;
 
   cmCursesCacheEntryComposite* comp;
-  if ( count == 0 )
-    {
+  if (count == 0) {
     // If cache is empty, display a label saying so and a
     // dummy entry widget (does not respond to input)
     comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30);
     comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
     newEntries->push_back(comp);
-    }
-  else
-    {
+  } else {
     // Create the composites.
 
     // First add entries which are new
-    for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
-        it != cacheKeys.end(); ++it)
-      {
+    for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+         it != cacheKeys.end(); ++it) {
       std::string key = *it;
-      cmState::CacheEntryType t = this->CMakeInstance->GetState()
-          ->GetCacheEntryType(*it);
-      if (t == cmState::INTERNAL ||
-          t == cmState::STATIC ||
-          t == cmState::UNINITIALIZED )
-        {
+      cmState::CacheEntryType t =
+        this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+      if (t == cmState::INTERNAL || t == cmState::STATIC ||
+          t == cmState::UNINITIALIZED) {
         continue;
-        }
+      }
 
-      if (!this->LookForCacheEntry(key))
-        {
-        newEntries->push_back(new cmCursesCacheEntryComposite(key,
-                                                          this->CMakeInstance,
-                                                          true, 30,
-                                                          entrywidth));
+      if (!this->LookForCacheEntry(key)) {
+        newEntries->push_back(new cmCursesCacheEntryComposite(
+          key, this->CMakeInstance, true, 30, entrywidth));
         this->OkToGenerate = false;
-        }
       }
+    }
 
     // then add entries which are old
-    for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
-        it != cacheKeys.end(); ++it)
-      {
+    for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+         it != cacheKeys.end(); ++it) {
       std::string key = *it;
-      cmState::CacheEntryType t = this->CMakeInstance->GetState()
-          ->GetCacheEntryType(*it);
-      if (t == cmState::INTERNAL ||
-          t == cmState::STATIC ||
-          t == cmState::UNINITIALIZED )
-        {
+      cmState::CacheEntryType t =
+        this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+      if (t == cmState::INTERNAL || t == cmState::STATIC ||
+          t == cmState::UNINITIALIZED) {
         continue;
-        }
+      }
 
-      if (this->LookForCacheEntry(key))
-        {
-        newEntries->push_back(new cmCursesCacheEntryComposite(key,
-                                                          this->CMakeInstance,
-                                                          false, 30,
-                                                          entrywidth));
-        }
+      if (this->LookForCacheEntry(key)) {
+        newEntries->push_back(new cmCursesCacheEntryComposite(
+          key, this->CMakeInstance, false, 30, entrywidth));
       }
     }
+  }
 
   // Clean old entries
-  if (this->Entries)
-    {
+  if (this->Entries) {
     cmDeleteAll(*this->Entries);
-    }
+  }
   delete this->Entries;
   this->Entries = newEntries;
 
@@ -202,180 +179,150 @@ void cmCursesMainForm::InitializeUI()
   this->RePost();
 }
 
-
 void cmCursesMainForm::RePost()
 {
   // Create the fields to be passed to the form.
-  if (this->Form)
-    {
+  if (this->Form) {
     unpost_form(this->Form);
     free_form(this->Form);
     this->Form = 0;
-    }
+  }
   delete[] this->Fields;
-  if (this->AdvancedMode)
-    {
+  if (this->AdvancedMode) {
     this->NumberOfVisibleEntries = this->Entries->size();
-    }
-  else
-    {
+  } else {
     // If normal mode, count only non-advanced entries
     this->NumberOfVisibleEntries = 0;
     std::vector<cmCursesCacheEntryComposite*>::iterator it;
-    for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-      {
+    for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
       const char* existingValue =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryValue((*it)->GetValue());
+        this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
       bool advanced =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
-      if (!existingValue || (!this->AdvancedMode && advanced))
-        {
+        this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+          (*it)->GetValue(), "ADVANCED");
+      if (!existingValue || (!this->AdvancedMode && advanced)) {
         continue;
-        }
-      this->NumberOfVisibleEntries++;
       }
+      this->NumberOfVisibleEntries++;
     }
+  }
   // there is always one even if it is the dummy one
-  if(this->NumberOfVisibleEntries == 0)
-    {
+  if (this->NumberOfVisibleEntries == 0) {
     this->NumberOfVisibleEntries = 1;
-    }
+  }
   // Assign the fields: 3 for each entry: label, new entry marker
   // ('*' or ' ') and entry widget
-  this->Fields = new FIELD*[3*this->NumberOfVisibleEntries+1];
+  this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1];
   size_t cc;
-  for ( cc = 0; cc < 3 * this->NumberOfVisibleEntries+1; cc ++ )
-    {
+  for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) {
     this->Fields[cc] = 0;
-    }
+  }
 
   // Assign fields
-  int j=0;
+  int j = 0;
   std::vector<cmCursesCacheEntryComposite*>::iterator it;
-  for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-    {
+  for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
     const char* existingValue =
-        this->CMakeInstance->GetState()
-            ->GetCacheEntryValue((*it)->GetValue());
+      this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
     bool advanced =
-        this->CMakeInstance->GetState()
-            ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
-    if (!existingValue || (!this->AdvancedMode && advanced))
-      {
+      this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+        (*it)->GetValue(), "ADVANCED");
+    if (!existingValue || (!this->AdvancedMode && advanced)) {
       continue;
-      }
-    this->Fields[3*j]    = (*it)->Label->Field;
-    this->Fields[3*j+1]  = (*it)->IsNewLabel->Field;
-    this->Fields[3*j+2]  = (*it)->Entry->Field;
-    j++;
     }
+    this->Fields[3 * j] = (*it)->Label->Field;
+    this->Fields[3 * j + 1] = (*it)->IsNewLabel->Field;
+    this->Fields[3 * j + 2] = (*it)->Entry->Field;
+    j++;
+  }
   // if no cache entries there should still be one dummy field
-  if(j == 0)
-    {
+  if (j == 0) {
     it = this->Entries->begin();
-    this->Fields[0]    = (*it)->Label->Field;
-    this->Fields[1]  = (*it)->IsNewLabel->Field;
-    this->Fields[2]  = (*it)->Entry->Field;
+    this->Fields[0] = (*it)->Label->Field;
+    this->Fields[1] = (*it)->IsNewLabel->Field;
+    this->Fields[2] = (*it)->Entry->Field;
     this->NumberOfVisibleEntries = 1;
-    }
+  }
   // Has to be null terminated.
-  this->Fields[3*this->NumberOfVisibleEntries] = 0;
+  this->Fields[3 * this->NumberOfVisibleEntries] = 0;
 }
 
 void cmCursesMainForm::Render(int left, int top, int width, int height)
 {
 
-  if (this->Form)
-    {
+  if (this->Form) {
     FIELD* currentField = current_field(this->Form);
-    cmCursesWidget* cw = reinterpret_cast<cmCursesWidget*>
-      (field_userptr(currentField));
+    cmCursesWidget* cw =
+      reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
     // If in edit mode, get out of it
-    if ( cw->GetType() == cmState::STRING ||
-         cw->GetType() == cmState::PATH   ||
-         cw->GetType() == cmState::FILEPATH )
-      {
+    if (cw->GetType() == cmState::STRING || cw->GetType() == cmState::PATH ||
+        cw->GetType() == cmState::FILEPATH) {
       cmCursesStringWidget* sw = static_cast<cmCursesStringWidget*>(cw);
       sw->SetInEdit(false);
-      }
+    }
     // Delete the previous form
     unpost_form(this->Form);
     free_form(this->Form);
     this->Form = 0;
-    }
+  }
 
   // Wrong window size
-  if ( width < cmCursesMainForm::MIN_WIDTH  ||
-       width < this->InitialWidth               ||
-       height < cmCursesMainForm::MIN_HEIGHT )
-    {
+  if (width < cmCursesMainForm::MIN_WIDTH || width < this->InitialWidth ||
+      height < cmCursesMainForm::MIN_HEIGHT) {
     return;
-    }
+  }
 
   // Leave room for toolbar
   height -= 7;
 
-  if (this->AdvancedMode)
-    {
+  if (this->AdvancedMode) {
     this->NumberOfVisibleEntries = this->Entries->size();
-    }
-  else
-    {
+  } else {
     // If normal, display only non-advanced entries
     this->NumberOfVisibleEntries = 0;
     std::vector<cmCursesCacheEntryComposite*>::iterator it;
-    for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-      {
+    for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
       const char* existingValue =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryValue((*it)->GetValue());
+        this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
       bool advanced =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
-      if (!existingValue || (!this->AdvancedMode && advanced))
-        {
+        this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+          (*it)->GetValue(), "ADVANCED");
+      if (!existingValue || (!this->AdvancedMode && advanced)) {
         continue;
-        }
-      this->NumberOfVisibleEntries++;
       }
+      this->NumberOfVisibleEntries++;
     }
+  }
 
   // Re-adjust the fields according to their place
   this->NumberOfPages = 1;
-  if (height > 0)
-    {
+  if (height > 0) {
     bool isNewPage;
-    int i=0;
+    int i = 0;
     std::vector<cmCursesCacheEntryComposite*>::iterator it;
-    for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-      {
+    for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
       const char* existingValue =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryValue((*it)->GetValue());
+        this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
       bool advanced =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryPropertyAsBool((*it)->GetValue(), "ADVANCED");
-      if (!existingValue || (!this->AdvancedMode && advanced))
-        {
+        this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
+          (*it)->GetValue(), "ADVANCED");
+      if (!existingValue || (!this->AdvancedMode && advanced)) {
         continue;
-        }
+      }
       int row = (i % height) + 1;
       int page = (i / height) + 1;
-      isNewPage = ( page > 1 ) && ( row == 1 );
+      isNewPage = (page > 1) && (row == 1);
 
-      if (isNewPage)
-        {
+      if (isNewPage) {
         this->NumberOfPages++;
-        }
-      (*it)->Label->Move(left, top+row-1, isNewPage);
-      (*it)->IsNewLabel->Move(left+32, top+row-1, false);
-      (*it)->Entry->Move(left+33, top+row-1, false);
+      }
+      (*it)->Label->Move(left, top + row - 1, isNewPage);
+      (*it)->IsNewLabel->Move(left + 32, top + row - 1, false);
+      (*it)->Entry->Move(left + 33, top + row - 1, false);
       (*it)->Entry->SetPage(this->NumberOfPages);
       i++;
-      }
     }
+  }
 
   // Post the form
   this->Form = new_form(this->Fields);
@@ -390,153 +337,130 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
 
 void cmCursesMainForm::PrintKeys(int process /* = 0 */)
 {
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
-  if ( x < cmCursesMainForm::MIN_WIDTH  ||
-       x < this->InitialWidth               ||
-       y < cmCursesMainForm::MIN_HEIGHT )
-    {
+  if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
+      y < cmCursesMainForm::MIN_HEIGHT) {
     return;
-    }
+  }
 
   // Give the current widget (if it exists), a chance to print keys
   cmCursesWidget* cw = 0;
-  if (this->Form)
-    {
+  if (this->Form) {
     FIELD* currentField = current_field(this->Form);
     cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
-    }
+  }
 
-  if (cw)
-    {
+  if (cw) {
     cw->PrintKeys();
-    }
-
-//    {
-//    }
-//  else
-//    {
-  char firstLine[512]="";
-  char secondLine[512]="";
-  char thirdLine[512]="";
-  if (process)
-    {
+  }
+
+  //    {
+  //    }
+  //  else
+  //    {
+  char firstLine[512] = "";
+  char secondLine[512] = "";
+  char thirdLine[512] = "";
+  if (process) {
     const char* clearLine =
       "                                                                    ";
     strcpy(firstLine, clearLine);
     strcpy(secondLine, clearLine);
     strcpy(thirdLine, clearLine);
-    }
-  else
-    {
-    if (this->OkToGenerate)
-      {
+  } else {
+    if (this->OkToGenerate) {
       sprintf(firstLine,
               "Press [c] to configure       Press [g] to generate and exit");
-      }
-    else
-      {
-      sprintf(firstLine,  "Press [c] to configure                                   ");
-      }
+    } else {
+      sprintf(firstLine,
+              "Press [c] to configure                                   ");
+    }
     {
       const char* toggleKeyInstruction =
         "Press [t] to toggle advanced mode (Currently %s)";
-      sprintf(thirdLine,
-              toggleKeyInstruction,
+      sprintf(thirdLine, toggleKeyInstruction,
               this->AdvancedMode ? "On" : "Off");
     }
-    sprintf(secondLine,
-            "Press [h] for help           "
-            "Press [q] to quit without generating");
-    }
+    sprintf(secondLine, "Press [h] for help           "
+                        "Press [q] to quit without generating");
+  }
 
-  curses_move(y-4,0);
+  curses_move(y - 4, 0);
   char fmt_s[] = "%s";
   char fmt[512] = "Press [enter] to edit option";
-  if ( process )
-    {
+  if (process) {
     strcpy(fmt, "                           ");
-    }
+  }
   printw(fmt_s, fmt);
-  curses_move(y-3,0);
+  curses_move(y - 3, 0);
   printw(fmt_s, firstLine);
-  curses_move(y-2,0);
+  curses_move(y - 2, 0);
   printw(fmt_s, secondLine);
-  curses_move(y-1,0);
+  curses_move(y - 1, 0);
   printw(fmt_s, thirdLine);
 
-  if (cw)
-    {
+  if (cw) {
     sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages);
-    curses_move(0,65-static_cast<unsigned int>(strlen(firstLine))-1);
+    curses_move(0, 65 - static_cast<unsigned int>(strlen(firstLine)) - 1);
     printw(fmt_s, firstLine);
-    }
-//    }
+  }
+  //    }
 
   pos_form_cursor(this->Form);
-
 }
 
 // Print the key of the current entry and the CMake version
 // on the status bar. Designed for a width of 80 chars.
 void cmCursesMainForm::UpdateStatusBar(const char* message)
 {
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
   // If window size is too small, display error and return
-  if ( x < cmCursesMainForm::MIN_WIDTH  ||
-       x < this->InitialWidth               ||
-       y < cmCursesMainForm::MIN_HEIGHT )
-    {
+  if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
+      y < cmCursesMainForm::MIN_HEIGHT) {
     curses_clear();
-    curses_move(0,0);
+    curses_move(0, 0);
     char fmt[] = "Window is too small. A size of at least %dx%d is required.";
-    printw(fmt,
-           (cmCursesMainForm::MIN_WIDTH < this->InitialWidth ?
-            this->InitialWidth : cmCursesMainForm::MIN_WIDTH),
+    printw(fmt, (cmCursesMainForm::MIN_WIDTH < this->InitialWidth
+                   ? this->InitialWidth
+                   : cmCursesMainForm::MIN_WIDTH),
            cmCursesMainForm::MIN_HEIGHT);
     touchwin(stdscr);
     wrefresh(stdscr);
     return;
-    }
+  }
 
   // Get the key of the current entry
   FIELD* cur = current_field(this->Form);
   int findex = field_index(cur);
   cmCursesWidget* lbl = 0;
-  if ( findex >= 0 )
-    {
-    lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(this->Fields[findex-2]));
-    }
+  if (findex >= 0) {
+    lbl = reinterpret_cast<cmCursesWidget*>(
+      field_userptr(this->Fields[findex - 2]));
+  }
   char help[128] = "";
   const char* curField = "";
-  if ( lbl )
-    {
+  if (lbl) {
     curField = lbl->GetValue();
 
     // Get the help string of the current entry
     // and add it to the help string
     const char* existingValue =
-        this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
-    if (existingValue)
-      {
-      const char* hs = this->CMakeInstance->GetState()
-                           ->GetCacheEntryProperty(curField, "HELPSTRING");
-      if ( hs )
-        {
+      this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
+    if (existingValue) {
+      const char* hs = this->CMakeInstance->GetState()->GetCacheEntryProperty(
+        curField, "HELPSTRING");
+      if (hs) {
         strncpy(help, hs, 127);
         help[127] = '\0';
-        }
-      else
-        {
+      } else {
         help[0] = 0;
-        }
-      }
-    else
-      {
-      sprintf(help," ");
       }
+    } else {
+      sprintf(help, " ");
     }
+  }
 
   // Join the key, help string and pad with spaces
   // (or truncate) as necessary
@@ -545,119 +469,98 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
   size_t helpLen = strlen(help);
 
   size_t width;
-  if (x < cmCursesMainForm::MAX_WIDTH )
-    {
+  if (x < cmCursesMainForm::MAX_WIDTH) {
     width = x;
-    }
-  else
-    {
+  } else {
     width = cmCursesMainForm::MAX_WIDTH;
-    }
+  }
 
-  if ( message )
-    {
+  if (message) {
     curField = message;
     curFieldLen = strlen(message);
-    if ( curFieldLen < width )
-      {
+    if (curFieldLen < width) {
       strcpy(bar, curField);
-      for(i=curFieldLen; i < width; ++i)
-        {
+      for (i = curFieldLen; i < width; ++i) {
         bar[i] = ' ';
-        }
       }
-    else
-      {
+    } else {
       strncpy(bar, curField, width);
-      }
-   }
-  else
-    {
-    if (curFieldLen >= width)
-      {
+    }
+  } else {
+    if (curFieldLen >= width) {
       strncpy(bar, curField, width);
-      }
-    else
-      {
+    } else {
       strcpy(bar, curField);
       bar[curFieldLen] = ':';
-      bar[curFieldLen+1] = ' ';
-      if (curFieldLen + helpLen + 2 >= width)
-        {
-        strncpy(bar+curFieldLen+2, help, width
-                - curFieldLen - 2);
-        }
-      else
-        {
-        strcpy(bar+curFieldLen+2, help);
-        for(i=curFieldLen+helpLen+2; i < width; ++i)
-          {
+      bar[curFieldLen + 1] = ' ';
+      if (curFieldLen + helpLen + 2 >= width) {
+        strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2);
+      } else {
+        strcpy(bar + curFieldLen + 2, help);
+        for (i = curFieldLen + helpLen + 2; i < width; ++i) {
           bar[i] = ' ';
-          }
         }
       }
     }
-
+  }
 
   bar[width] = '\0';
 
-
   // Display CMake version info on the next line
   // We want to display this on the right
   char version[cmCursesMainForm::MAX_WIDTH];
   char vertmp[128];
-  sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
-  size_t sideSpace = (width-strlen(vertmp));
-  for(i=0; i<sideSpace; i++) { version[i] = ' '; }
-  sprintf(version+sideSpace, "%s", vertmp);
+  sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
+  size_t sideSpace = (width - strlen(vertmp));
+  for (i = 0; i < sideSpace; i++) {
+    version[i] = ' ';
+  }
+  sprintf(version + sideSpace, "%s", vertmp);
   version[width] = '\0';
 
   // Now print both lines
   char fmt_s[] = "%s";
-  curses_move(y-5,0);
+  curses_move(y - 5, 0);
   attron(A_STANDOUT);
   printw(fmt_s, bar);
   attroff(A_STANDOUT);
-  curses_move(y-4,0);
+  curses_move(y - 4, 0);
   printw(fmt_s, version);
   pos_form_cursor(this->Form);
 }
 
-void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void* vp)
+void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
 {
   cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp);
-  if ( !cm )
-    {
+  if (!cm) {
     return;
-    }
+  }
   char tmp[1024];
-  const char *cmsg = tmp;
-  if ( prog >= 0 )
-    {
-    sprintf(tmp, "%s %i%%",msg,(int)(100*prog));
-    }
-  else
-    {
+  const char* cmsg = tmp;
+  if (prog >= 0) {
+    sprintf(tmp, "%s %i%%", msg, (int)(100 * prog));
+  } else {
     cmsg = msg;
-    }
+  }
   cm->UpdateStatusBar(cmsg);
   cm->PrintKeys(1);
-  curses_move(1,1);
+  curses_move(1, 1);
   touchwin(stdscr);
   refresh();
 }
 
 int cmCursesMainForm::Configure(int noconfigure)
 {
-  int xi,yi;
+  int xi, yi;
   getmaxyx(stdscr, yi, xi);
 
-  curses_move(1,1);
+  curses_move(1, 1);
   this->UpdateStatusBar("Configuring, please wait...");
   this->PrintKeys(1);
   touchwin(stdscr);
   refresh();
-  this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
+  this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
+                                           this);
 
   // always save the current gui values to disk
   this->FillCacheManagerFromUI();
@@ -671,52 +574,44 @@ int cmCursesMainForm::Configure(int noconfigure)
   // run the generate process
   this->OkToGenerate = true;
   int retVal;
-  if ( noconfigure )
-    {
+  if (noconfigure) {
     retVal = this->CMakeInstance->DoPreConfigureChecks();
     this->OkToGenerate = false;
-    if ( retVal > 0 )
-      {
+    if (retVal > 0) {
       retVal = 0;
-      }
     }
-  else
-    {
+  } else {
     retVal = this->CMakeInstance->Configure();
-    }
+  }
   this->CMakeInstance->SetProgressCallback(0, 0);
 
-  keypad(stdscr,TRUE); /* Use key symbols as
-                          KEY_DOWN*/
+  keypad(stdscr, TRUE); /* Use key symbols as
+                           KEY_DOWN*/
 
-  if( retVal != 0 || !this->Errors.empty())
-    {
+  if (retVal != 0 || !this->Errors.empty()) {
     // see if there was an error
-    if(cmSystemTools::GetErrorOccuredFlag())
-      {
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       this->OkToGenerate = false;
-      }
-    int xx,yy;
+    }
+    int xx, yy;
     getmaxyx(stdscr, yy, xx);
     cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
-      this->Errors,
-      cmSystemTools::GetErrorOccuredFlag()
-      ? "Errors occurred during the last pass." :
-      "CMake produced the following output.");
+      this->Errors, cmSystemTools::GetErrorOccuredFlag()
+        ? "Errors occurred during the last pass."
+        : "CMake produced the following output.");
     // reset error condition
     cmSystemTools::ResetErrorOccuredFlag();
     CurrentForm = msgs;
-    msgs->Render(1,1,xx,yy);
+    msgs->Render(1, 1, xx, yy);
     msgs->HandleInput();
     // If they typed the wrong source directory, we report
     // an error and exit
-    if ( retVal == -2 )
-      {
+    if (retVal == -2) {
       return retVal;
-      }
-    CurrentForm = this;
-    this->Render(1,1,xx,yy);
     }
+    CurrentForm = this;
+    this->Render(1, 1, xx, yy);
+  }
 
   this->InitializeUI();
   this->Render(1, 1, xi, yi);
@@ -726,15 +621,16 @@ int cmCursesMainForm::Configure(int noconfigure)
 
 int cmCursesMainForm::Generate()
 {
-  int xi,yi;
+  int xi, yi;
   getmaxyx(stdscr, yi, xi);
 
-  curses_move(1,1);
+  curses_move(1, 1);
   this->UpdateStatusBar("Generating, please wait...");
   this->PrintKeys(1);
   touchwin(stdscr);
   refresh();
-  this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this);
+  this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
+                                           this);
 
   // Get rid of previous errors
   this->Errors = std::vector<std::string>();
@@ -743,39 +639,35 @@ int cmCursesMainForm::Generate()
   int retVal = this->CMakeInstance->Generate();
 
   this->CMakeInstance->SetProgressCallback(0, 0);
-  keypad(stdscr,TRUE); /* Use key symbols as
-                          KEY_DOWN*/
+  keypad(stdscr, TRUE); /* Use key symbols as
+                           KEY_DOWN*/
 
-  if( retVal != 0 || !this->Errors.empty())
-    {
+  if (retVal != 0 || !this->Errors.empty()) {
     // see if there was an error
-    if(cmSystemTools::GetErrorOccuredFlag())
-      {
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       this->OkToGenerate = false;
-      }
+    }
     // reset error condition
     cmSystemTools::ResetErrorOccuredFlag();
-    int xx,yy;
+    int xx, yy;
     getmaxyx(stdscr, yy, xx);
     const char* title = "Messages during last pass.";
-    if(cmSystemTools::GetErrorOccuredFlag())
-      {
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       title = "Errors occurred during the last pass.";
-      }
-    cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->Errors,
-                                                                title);
+    }
+    cmCursesLongMessageForm* msgs =
+      new cmCursesLongMessageForm(this->Errors, title);
     CurrentForm = msgs;
-    msgs->Render(1,1,xx,yy);
+    msgs->Render(1, 1, xx, yy);
     msgs->HandleInput();
     // If they typed the wrong source directory, we report
     // an error and exit
-    if ( retVal == -2 )
-      {
+    if (retVal == -2) {
       return retVal;
-      }
-    CurrentForm = this;
-    this->Render(1,1,xx,yy);
     }
+    CurrentForm = this;
+    this->Render(1, 1, xx, yy);
+  }
 
   this->InitializeUI();
   this->Render(1, 1, xi, yi);
@@ -790,346 +682,286 @@ void cmCursesMainForm::AddError(const char* message, const char*)
 
 void cmCursesMainForm::RemoveEntry(const char* value)
 {
-  if (!value)
-    {
+  if (!value) {
     return;
-    }
+  }
 
   std::vector<cmCursesCacheEntryComposite*>::iterator it;
-  for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-    {
+  for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
     const char* val = (*it)->GetValue();
-    if (  val && !strcmp(value, val) )
-      {
+    if (val && !strcmp(value, val)) {
       this->CMakeInstance->UnwatchUnusedCli(value);
       this->Entries->erase(it);
       break;
-      }
     }
+  }
 }
 
 // copy from the list box to the cache manager
 void cmCursesMainForm::FillCacheManagerFromUI()
 {
   size_t size = this->Entries->size();
-  for(size_t i=0; i < size; i++)
-    {
+  for (size_t i = 0; i < size; i++) {
     std::string cacheKey = (*this->Entries)[i]->Key;
-      const char* existingValue = this->CMakeInstance->GetState()
-        ->GetCacheEntryValue(cacheKey);
-    if (existingValue)
-      {
+    const char* existingValue =
+      this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
+    if (existingValue) {
       std::string oldValue = existingValue;
       std::string newValue = (*this->Entries)[i]->Entry->GetValue();
       std::string fixedOldValue;
       std::string fixedNewValue;
       cmState::CacheEntryType t =
-          this->CMakeInstance->GetState()
-              ->GetCacheEntryType(cacheKey);
+        this->CMakeInstance->GetState()->GetCacheEntryType(cacheKey);
       this->FixValue(t, oldValue, fixedOldValue);
       this->FixValue(t, newValue, fixedNewValue);
 
-      if(!(fixedOldValue == fixedNewValue))
-        {
+      if (!(fixedOldValue == fixedNewValue)) {
         // The user has changed the value.  Mark it as modified.
-        this->CMakeInstance->GetState()
-            ->SetCacheEntryBoolProperty(cacheKey, "MODIFIED", true);
-        this->CMakeInstance->GetState()
-            ->SetCacheEntryValue(cacheKey, fixedNewValue);
-        }
+        this->CMakeInstance->GetState()->SetCacheEntryBoolProperty(
+          cacheKey, "MODIFIED", true);
+        this->CMakeInstance->GetState()->SetCacheEntryValue(cacheKey,
+                                                            fixedNewValue);
       }
     }
+  }
 }
 
 void cmCursesMainForm::FixValue(cmState::CacheEntryType type,
                                 const std::string& in, std::string& out) const
 {
-  out = in.substr(0,in.find_last_not_of(" ")+1);
-  if(type == cmState::PATH || type == cmState::FILEPATH)
-    {
+  out = in.substr(0, in.find_last_not_of(' ') + 1);
+  if (type == cmState::PATH || type == cmState::FILEPATH) {
     cmSystemTools::ConvertToUnixSlashes(out);
-    }
-  if(type == cmState::BOOL)
-    {
-    if(cmSystemTools::IsOff(out.c_str()))
-      {
+  }
+  if (type == cmState::BOOL) {
+    if (cmSystemTools::IsOff(out.c_str())) {
       out = "OFF";
-      }
-    else
-      {
+    } else {
       out = "ON";
-      }
     }
+  }
 }
 
 #include <unistd.h>
 
 void cmCursesMainForm::HandleInput()
 {
-  int x=0,y=0;
+  int x = 0, y = 0;
 
-  if (!this->Form)
-    {
+  if (!this->Form) {
     return;
-    }
+  }
 
   FIELD* currentField;
   cmCursesWidget* currentWidget;
 
   char debugMessage[128];
 
-  for(;;)
-    {
+  for (;;) {
     this->UpdateStatusBar();
     this->PrintKeys();
-    if ( this->SearchMode )
-      {
+    if (this->SearchMode) {
       std::string searchstr = "Search: " + this->SearchString;
-      this->UpdateStatusBar( searchstr.c_str() );
+      this->UpdateStatusBar(searchstr.c_str());
       this->PrintKeys(1);
-      curses_move(y-5,static_cast<unsigned int>(searchstr.size()));
-      //curses_move(1,1);
+      curses_move(y - 5, static_cast<unsigned int>(searchstr.size()));
+      // curses_move(1,1);
       touchwin(stdscr);
       refresh();
-      }
+    }
     int key = getch();
 
     getmaxyx(stdscr, y, x);
     // If window too small, handle 'q' only
-    if ( x < cmCursesMainForm::MIN_WIDTH  ||
-         y < cmCursesMainForm::MIN_HEIGHT )
-      {
+    if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
       // quit
-      if ( key == 'q' )
-        {
+      if (key == 'q') {
         break;
-        }
-      else
-        {
+      } else {
         continue;
-        }
       }
+    }
 
     currentField = current_field(this->Form);
-    currentWidget = reinterpret_cast<cmCursesWidget*>(field_userptr(
-      currentField));
+    currentWidget =
+      reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
 
-    bool widgetHandled=false;
+    bool widgetHandled = false;
 
-    if ( this->SearchMode )
-      {
-      if ( key == 10 || key == KEY_ENTER )
-        {
+    if (this->SearchMode) {
+      if (key == 10 || key == KEY_ENTER) {
         this->SearchMode = false;
-        if (!this->SearchString.empty())
-          {
+        if (!this->SearchString.empty()) {
           this->JumpToCacheEntry(this->SearchString.c_str());
           this->OldSearchString = this->SearchString;
-          }
-        this->SearchString = "";
         }
+        this->SearchString = "";
+      }
       /*
       else if ( key == KEY_ESCAPE )
         {
         this->SearchMode = false;
         }
       */
-      else if ((key >= 'a' && key <= 'z') ||
-               (key >= 'A' && key <= 'Z') ||
-               (key >= '0' && key <= '9') ||
-               (key == '_' ))
-        {
-        if ( this->SearchString.size() < static_cast<std::string::size_type>(x-10) )
-          {
+      else if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') ||
+               (key >= '0' && key <= '9') || (key == '_')) {
+        if (this->SearchString.size() <
+            static_cast<std::string::size_type>(x - 10)) {
           this->SearchString += static_cast<char>(key);
-          }
         }
-      else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC )
-        {
-        if (!this->SearchString.empty())
-          {
-          this->SearchString.resize(this->SearchString.size()-1);
-          }
+      } else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) {
+        if (!this->SearchString.empty()) {
+          this->SearchString.resize(this->SearchString.size() - 1);
         }
       }
-    else if (currentWidget && !this->SearchMode)
-      {
+    } else if (currentWidget && !this->SearchMode) {
       // Ask the current widget if it wants to handle input
       widgetHandled = currentWidget->HandleInput(key, this, stdscr);
-      if (widgetHandled)
-        {
+      if (widgetHandled) {
         this->OkToGenerate = false;
         this->UpdateStatusBar();
         this->PrintKeys();
-        }
       }
-    if ((!currentWidget || !widgetHandled) && !this->SearchMode)
-      {
+    }
+    if ((!currentWidget || !widgetHandled) && !this->SearchMode) {
       // If the current widget does not want to handle input,
       // we handle it.
       sprintf(debugMessage, "Main form handling input, key: %d", key);
       cmCursesForm::LogMessage(debugMessage);
       // quit
-      if ( key == 'q' )
-        {
+      if (key == 'q') {
         break;
-        }
+      }
       // if not end of page, next field otherwise next page
       // each entry consists of fields: label, isnew, value
       // therefore, the label field for the prev. entry is index-5
       // and the label field for the next entry is index+1
       // (index always corresponds to the value field)
-      else if ( key == KEY_DOWN || key == ctrl('n') )
-        {
+      else if (key == KEY_DOWN || key == ctrl('n')) {
         FIELD* cur = current_field(this->Form);
         size_t findex = field_index(cur);
-        if ( findex == 3*this->NumberOfVisibleEntries-1 )
-          {
+        if (findex == 3 * this->NumberOfVisibleEntries - 1) {
           continue;
-          }
-        if (new_page(this->Fields[findex+1]))
-          {
+        }
+        if (new_page(this->Fields[findex + 1])) {
           form_driver(this->Form, REQ_NEXT_PAGE);
-          }
-        else
-          {
+        } else {
           form_driver(this->Form, REQ_NEXT_FIELD);
-          }
         }
+      }
       // if not beginning of page, previous field, otherwise previous page
       // each entry consists of fields: label, isnew, value
       // therefore, the label field for the prev. entry is index-5
       // and the label field for the next entry is index+1
       // (index always corresponds to the value field)
-      else if ( key == KEY_UP || key == ctrl('p') )
-        {
+      else if (key == KEY_UP || key == ctrl('p')) {
         FIELD* cur = current_field(this->Form);
         int findex = field_index(cur);
-        if ( findex == 2 )
-          {
+        if (findex == 2) {
           continue;
-          }
-        if ( new_page(this->Fields[findex-2]) )
-          {
+        }
+        if (new_page(this->Fields[findex - 2])) {
           form_driver(this->Form, REQ_PREV_PAGE);
-          set_current_field(this->Form, this->Fields[findex-3]);
-          }
-        else
-          {
+          set_current_field(this->Form, this->Fields[findex - 3]);
+        } else {
           form_driver(this->Form, REQ_PREV_FIELD);
-          }
         }
+      }
       // pg down
-      else if ( key == KEY_NPAGE || key == ctrl('d') )
-        {
+      else if (key == KEY_NPAGE || key == ctrl('d')) {
         form_driver(this->Form, REQ_NEXT_PAGE);
-        }
+      }
       // pg up
-      else if ( key == KEY_PPAGE || key == ctrl('u') )
-        {
+      else if (key == KEY_PPAGE || key == ctrl('u')) {
         form_driver(this->Form, REQ_PREV_PAGE);
-        }
+      }
       // configure
-      else if ( key == 'c' )
-        {
+      else if (key == 'c') {
         this->Configure();
-        }
+      }
       // display help
-      else if ( key == 'h' )
-        {
+      else if (key == 'h') {
         getmaxyx(stdscr, y, x);
 
         FIELD* cur = current_field(this->Form);
         int findex = field_index(cur);
-        cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(
-          this->Fields[findex-2]));
+        cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
+          field_userptr(this->Fields[findex - 2]));
         const char* curField = lbl->GetValue();
         const char* helpString = 0;
 
         const char* existingValue =
-            this->CMakeInstance->GetState()
-                ->GetCacheEntryValue(curField);
-        if (existingValue)
-          {
-          helpString = this->CMakeInstance->GetState()
-                           ->GetCacheEntryProperty(curField, "HELPSTRING");
-          }
-        if (helpString)
-          {
-          char* message = new char[strlen(curField)+strlen(helpString)
-                                  +strlen("Current option is: \n Help string for this option is: \n")+10];
-          sprintf(message,"Current option is: %s\nHelp string for this option is: %s\n", curField, helpString);
+          this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
+        if (existingValue) {
+          helpString = this->CMakeInstance->GetState()->GetCacheEntryProperty(
+            curField, "HELPSTRING");
+        }
+        if (helpString) {
+          char* message = new char
+            [strlen(curField) + strlen(helpString) +
+             strlen(
+               "Current option is: \n Help string for this option is: \n") +
+             10];
+          sprintf(
+            message,
+            "Current option is: %s\nHelp string for this option is: %s\n",
+            curField, helpString);
           this->HelpMessage[1] = message;
           delete[] message;
-          }
-        else
-          {
+        } else {
           this->HelpMessage[1] = "";
-          }
+        }
 
-        cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->HelpMessage,
-                                                                    "Help.");
+        cmCursesLongMessageForm* msgs =
+          new cmCursesLongMessageForm(this->HelpMessage, "Help.");
         CurrentForm = msgs;
-        msgs->Render(1,1,x,y);
+        msgs->Render(1, 1, x, y);
         msgs->HandleInput();
         CurrentForm = this;
-        this->Render(1,1,x,y);
+        this->Render(1, 1, x, y);
         set_current_field(this->Form, cur);
-        }
+      }
       // display last errors
-      else if ( key == 'l' )
-        {
+      else if (key == 'l') {
         getmaxyx(stdscr, y, x);
-        cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(this->Errors,
-                                                                    "Errors occurred during the last pass.");
+        cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
+          this->Errors, "Errors occurred during the last pass.");
         CurrentForm = msgs;
-        msgs->Render(1,1,x,y);
+        msgs->Render(1, 1, x, y);
         msgs->HandleInput();
         CurrentForm = this;
-        this->Render(1,1,x,y);
-        }
-      else if ( key == '/' )
-        {
+        this->Render(1, 1, x, y);
+      } else if (key == '/') {
         this->SearchMode = true;
         this->UpdateStatusBar("Search");
         this->PrintKeys(1);
         touchwin(stdscr);
         refresh();
-        }
-      else if ( key == 'n' )
-        {
-        if (!this->OldSearchString.empty())
-          {
+      } else if (key == 'n') {
+        if (!this->OldSearchString.empty()) {
           this->JumpToCacheEntry(this->OldSearchString.c_str());
-          }
         }
+      }
       // switch advanced on/off
-      else if ( key == 't' )
-        {
-        if (this->AdvancedMode)
-          {
+      else if (key == 't') {
+        if (this->AdvancedMode) {
           this->AdvancedMode = false;
-          }
-        else
-          {
+        } else {
           this->AdvancedMode = true;
-          }
+        }
         getmaxyx(stdscr, y, x);
         this->RePost();
         this->Render(1, 1, x, y);
-        }
+      }
       // generate and exit
-      else if ( key == 'g' )
-        {
-        if ( this->OkToGenerate )
-          {
+      else if (key == 'g') {
+        if (this->OkToGenerate) {
           this->Generate();
           break;
-          }
         }
+      }
       // delete cache entry
-      else if ( key == 'd' && this->NumberOfVisibleEntries )
-        {
+      else if (key == 'd' && this->NumberOfVisibleEntries) {
         this->OkToGenerate = false;
         FIELD* cur = current_field(this->Form);
         size_t findex = field_index(cur);
@@ -1140,76 +972,66 @@ void cmCursesMainForm::HandleInput()
         // and the label field for the next entry is findex+1
         // (findex always corresponds to the value field)
         FIELD* nextCur;
-        if ( findex == 2 )
-          {
-          nextCur=0;
-          }
-        else if ( findex == 3*this->NumberOfVisibleEntries-1 )
-          {
-          nextCur = this->Fields[findex-5];
-          }
-        else
-          {
-          nextCur = this->Fields[findex+1];
-          }
+        if (findex == 2) {
+          nextCur = 0;
+        } else if (findex == 3 * this->NumberOfVisibleEntries - 1) {
+          nextCur = this->Fields[findex - 5];
+        } else {
+          nextCur = this->Fields[findex + 1];
+        }
 
         // Get the label widget
         // each entry consists of fields: label, isnew, value
         // therefore, the label field for the is findex-2
         // (findex always corresponds to the value field)
-        cmCursesWidget* lbl
-          = reinterpret_cast<cmCursesWidget*>(
-            field_userptr(this->Fields[findex-2]));
-        if ( lbl )
-          {
+        cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
+          field_userptr(this->Fields[findex - 2]));
+        if (lbl) {
           this->CMakeInstance->GetState()->RemoveCacheEntry(lbl->GetValue());
 
           std::string nextVal;
-          if (nextCur)
-            {
-            nextVal = (reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))->GetValue());
-            }
+          if (nextCur) {
+            nextVal =
+              (reinterpret_cast<cmCursesWidget*>(field_userptr(nextCur))
+                 ->GetValue());
+          }
 
           getmaxyx(stdscr, y, x);
           this->RemoveEntry(lbl->GetValue());
           this->RePost();
           this->Render(1, 1, x, y);
 
-          if (nextCur)
-            {
+          if (nextCur) {
             // make the next or prev. current field after deletion
             nextCur = 0;
             std::vector<cmCursesCacheEntryComposite*>::iterator it;
-            for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
-              {
-              if (nextVal == (*it)->Key)
-                {
+            for (it = this->Entries->begin(); it != this->Entries->end();
+                 ++it) {
+              if (nextVal == (*it)->Key) {
                 nextCur = (*it)->Entry->Field;
-                }
               }
+            }
 
-            if (nextCur)
-              {
+            if (nextCur) {
               set_current_field(this->Form, nextCur);
-              }
             }
           }
         }
       }
+    }
 
     touchwin(stdscr);
     wrefresh(stdscr);
-    }
+  }
 }
 
-int cmCursesMainForm::LoadCache(const char *)
+int cmCursesMainForm::LoadCache(const char*)
 
 {
   int r = this->CMakeInstance->LoadCache();
-  if(r < 0)
-    {
+  if (r < 0) {
     return r;
-    }
+  }
   this->CMakeInstance->SetCacheArgs(this->Args);
   this->CMakeInstance->PreLoadCMakeFiles();
   return r;
@@ -1218,55 +1040,44 @@ int cmCursesMainForm::LoadCache(const char *)
 void cmCursesMainForm::JumpToCacheEntry(const char* astr)
 {
   std::string str;
-  if ( astr )
-    {
+  if (astr) {
     str = cmSystemTools::LowerCase(astr);
-    }
+  }
 
-  if(str.empty())
-    {
+  if (str.empty()) {
     return;
-    }
+  }
   FIELD* cur = current_field(this->Form);
   int start_index = field_index(cur);
   int findex = start_index;
-  for(;;)
-    {
-    if (!str.empty())
-      {
+  for (;;) {
+    if (!str.empty()) {
       cmCursesWidget* lbl = 0;
-      if ( findex >= 0 )
-        {
-        lbl = reinterpret_cast<cmCursesWidget*>(field_userptr(this->Fields[findex-2]));
-        }
-      if ( lbl )
-        {
+      if (findex >= 0) {
+        lbl = reinterpret_cast<cmCursesWidget*>(
+          field_userptr(this->Fields[findex - 2]));
+      }
+      if (lbl) {
         const char* curField = lbl->GetValue();
-        if ( curField )
-          {
+        if (curField) {
           std::string cfld = cmSystemTools::LowerCase(curField);
-          if ( cfld.find(str) != cfld.npos && findex != start_index )
-            {
+          if (cfld.find(str) != cfld.npos && findex != start_index) {
             break;
-            }
           }
         }
       }
-    if ( size_t(findex) >= 3* this->NumberOfVisibleEntries-1 )
-      {
+    }
+    if (size_t(findex) >= 3 * this->NumberOfVisibleEntries - 1) {
       set_current_field(this->Form, this->Fields[2]);
-      }
-    else if (new_page(this->Fields[findex+1]))
-      {
+    } else if (new_page(this->Fields[findex + 1])) {
       form_driver(this->Form, REQ_NEXT_PAGE);
-      }
-    else
-      {
+    } else {
       form_driver(this->Form, REQ_NEXT_FIELD);
-      }
+    }
     /*
     char buffer[1024];
-    sprintf(buffer, "Line: %d != %d / %d\n", findex, idx, this->NumberOfVisibleEntries);
+    sprintf(buffer, "Line: %d != %d / %d\n", findex, idx,
+    this->NumberOfVisibleEntries);
     touchwin(stdscr);
     refresh();
     this->UpdateStatusBar( buffer );
@@ -1274,52 +1085,70 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr)
     */
     cur = current_field(this->Form);
     findex = field_index(cur);
-    if ( findex == start_index )
-      {
+    if (findex == start_index) {
       break;
-      }
     }
+  }
 }
 
-
 const char* cmCursesMainForm::s_ConstHelpMessage =
-"CMake is used to configure and generate build files for software projects. "
-"The basic steps for configuring a project with ccmake are as follows:\n\n"
-"1. Run ccmake in the directory where you want the object and executable files to be placed (build directory). If the source directory is not the same as this build directory, you have to specify it as an argument on the command line.\n\n"
-"2. When ccmake is run, it will read the configuration files and display the current build options. "
-"If you have run CMake before and have updated the configuration files since then, any new entries will be displayed on top and will be marked with a *. "
-"On the other hand, the first time you run ccmake, all build options will be new and will be marked as such. "
-"At this point, you can modify any options (see keys below) you want to change. "
-"When you are satisfied with your changes, press 'c' to have CMake process the configuration files. "
-"Please note that changing some options may cause new ones to appear. These will be shown on top and will be marked with *. "
-"Repeat this procedure until you are satisfied with all the options and there are no new entries. "
-"At this point, a new command will appear: G)enerate and Exit. You can now hit 'g' to have CMake generate all the build files (i.e. makefiles or project files) and exit. "
-"At any point during the process, you can exit ccmake with 'q'. However, this will not generate/change any build files.\n\n"
-"ccmake KEYS:\n\n"
-"Navigation: "
-"You can use the arrow keys and page up, down to navigate the options. Alternatively, you can use the following keys: \n"
-" C-n : next option\n"
-" C-p : previous options\n"
-" C-d : down one page\n"
-" C-u : up one page\n\n"
-"Editing options: "
-"To change an option  press enter or return. If the current options is a boolean, this will toggle it's value. "
-"Otherwise, ccmake will enter edit mode. In this mode you can edit an option using arrow keys and backspace. Alternatively, you can use the following keys:\n"
-" C-b : back one character\n"
-" C-f : forward one character\n"
-" C-a : go to the beginning of the field\n"
-" C-e : go to the end of the field\n"
-" C-d : delete previous character\n"
-" C-k : kill the rest of the field\n"
-" Esc : Restore field (discard last changes)\n"
-" Enter : Leave edit mode\n"
-"You can also delete an option by pressing 'd'\n\n"
-"Commands:\n"
-" q : quit ccmake without generating build files\n"
-" h : help, shows this screen\n"
-" c : process the configuration files with the current options\n"
-" g : generate build files and exit, only available when there are no "
-"new options and no errors have been detected during last configuration.\n"
-" l : shows last errors\n"
-" t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using normal mode unless you are an expert.\n"
-" / : search for a variable name.\n";
+  "CMake is used to configure and generate build files for software projects. "
+  "The basic steps for configuring a project with ccmake are as follows:\n\n"
+  "1. Run ccmake in the directory where you want the object and executable "
+  "files to be placed (build directory). If the source directory is not the "
+  "same as this build directory, you have to specify it as an argument on the "
+  "command line.\n\n"
+  "2. When ccmake is run, it will read the configuration files and display "
+  "the current build options. "
+  "If you have run CMake before and have updated the configuration files "
+  "since then, any new entries will be displayed on top and will be marked "
+  "with a *. "
+  "On the other hand, the first time you run ccmake, all build options will "
+  "be new and will be marked as such. "
+  "At this point, you can modify any options (see keys below) you want to "
+  "change. "
+  "When you are satisfied with your changes, press 'c' to have CMake process "
+  "the configuration files. "
+  "Please note that changing some options may cause new ones to appear. These "
+  "will be shown on top and will be marked with *. "
+  "Repeat this procedure until you are satisfied with all the options and "
+  "there are no new entries. "
+  "At this point, a new command will appear: G)enerate and Exit. You can now "
+  "hit 'g' to have CMake generate all the build files (i.e. makefiles or "
+  "project files) and exit. "
+  "At any point during the process, you can exit ccmake with 'q'. However, "
+  "this will not generate/change any build files.\n\n"
+  "ccmake KEYS:\n\n"
+  "Navigation: "
+  "You can use the arrow keys and page up, down to navigate the options. "
+  "Alternatively, you can use the following keys: \n"
+  " C-n : next option\n"
+  " C-p : previous options\n"
+  " C-d : down one page\n"
+  " C-u : up one page\n\n"
+  "Editing options: "
+  "To change an option  press enter or return. If the current options is a "
+  "boolean, this will toggle it's value. "
+  "Otherwise, ccmake will enter edit mode. In this mode you can edit an "
+  "option using arrow keys and backspace. Alternatively, you can use the "
+  "following keys:\n"
+  " C-b : back one character\n"
+  " C-f : forward one character\n"
+  " C-a : go to the beginning of the field\n"
+  " C-e : go to the end of the field\n"
+  " C-d : delete previous character\n"
+  " C-k : kill the rest of the field\n"
+  " Esc : Restore field (discard last changes)\n"
+  " Enter : Leave edit mode\n"
+  "You can also delete an option by pressing 'd'\n\n"
+  "Commands:\n"
+  " q : quit ccmake without generating build files\n"
+  " h : help, shows this screen\n"
+  " c : process the configuration files with the current options\n"
+  " g : generate build files and exit, only available when there are no "
+  "new options and no errors have been detected during last configuration.\n"
+  " l : shows last errors\n"
+  " t : toggles advanced mode. In normal mode, only the most important "
+  "options are shown. In advanced mode, all options are shown. We recommend "
+  "using normal mode unless you are an expert.\n"
+  " / : search for a variable name.\n";
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 255c823..9aa0f67 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -12,10 +12,11 @@
 #ifndef cmCursesMainForm_h
 #define cmCursesMainForm_h
 
-#include "../cmStandardIncludes.h"
-#include "cmCursesForm.h"
 #include "cmCursesStandardIncludes.h"
 
+#include "../cmState.h"
+#include "cmCursesForm.h"
+
 class cmCursesCacheEntryComposite;
 class cmCursesWidget;
 class cmake;
@@ -53,7 +54,8 @@ public:
    */
   bool LookForCacheEntry(const std::string& key);
 
-  enum {
+  enum
+  {
     MIN_WIDTH = 65,
     MIN_HEIGHT = 6,
     IDEAL_WIDTH = 80,
@@ -87,7 +89,7 @@ public:
    * Used to do a configure. If argument is specified, it does only the check
    * and not configure.
    */
-  int Configure(int noconfigure=0);
+  int Configure(int noconfigure = 0);
 
   /**
    * Used to generate
@@ -97,13 +99,13 @@ public:
   /**
    * Used by main program
    */
-  int LoadCache(const char *dir);
+  int LoadCache(const char* dir);
 
   /**
    * Progress callback
    */
-  static void UpdateProgressOld(const char *msg, float prog, void*);
-  static void UpdateProgress(const char *msg, float prog, void*);
+  static void UpdateProgressOld(const char* msg, float prog, void*);
+  static void UpdateProgress(const char* msg, float prog, void*);
 
 protected:
   cmCursesMainForm(const cmCursesMainForm& from);
@@ -113,8 +115,8 @@ protected:
   // cache.
   void FillCacheManagerFromUI();
   // Fix formatting of values to a consistent form.
-  void FixValue(cmState::CacheEntryType type,
-                const std::string& in, std::string& out) const;
+  void FixValue(cmState::CacheEntryType type, const std::string& in,
+                std::string& out) const;
   // Re-post the existing fields. Used to toggle between
   // normal and advanced modes. Render() should be called
   // afterwards.
@@ -154,7 +156,7 @@ protected:
   int NumberOfPages;
 
   int InitialWidth;
-  cmake *CMakeInstance;
+  cmake* CMakeInstance;
 
   std::string SearchString;
   std::string OldSearchString;
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx
index 30110a4..1a3a8c2 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.cxx
+++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx
@@ -10,58 +10,52 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCursesOptionsWidget.h"
+
 #include "cmCursesMainForm.h"
 
 inline int ctrl(int z)
 {
-    return (z&037);
+  return (z & 037);
 }
 
-cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height,
-                                       int left, int top) :
-  cmCursesWidget(width, height, left, top)
+cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left,
+                                             int top)
+  : cmCursesWidget(width, height, left, top)
 {
   this->Type = cmState::BOOL; // this is a bit of a hack
   // there is no option type, and string type causes ccmake to cast
   // the widget into a string widget at some point.  BOOL is safe for
   // now.
-  set_field_fore(this->Field,  A_NORMAL);
-  set_field_back(this->Field,  A_STANDOUT);
-  field_opts_off(this->Field,  O_STATIC);
+  set_field_fore(this->Field, A_NORMAL);
+  set_field_back(this->Field, A_STANDOUT);
+  field_opts_off(this->Field, O_STATIC);
 }
 
 bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
 {
 
   // 10 == enter
-  if (key == 10 || key == KEY_ENTER)
-    {
+  if (key == 10 || key == KEY_ENTER) {
     this->NextOption();
     touchwin(w);
     wrefresh(w);
     return true;
-    }
-  else if (key == KEY_LEFT || key == ctrl('b'))
-    {
+  } else if (key == KEY_LEFT || key == ctrl('b')) {
     touchwin(w);
     wrefresh(w);
     this->PreviousOption();
     return true;
-    }
-  else if (key == KEY_RIGHT || key == ctrl('f'))
-    {
+  } else if (key == KEY_RIGHT || key == ctrl('f')) {
     this->NextOption();
     touchwin(w);
     wrefresh(w);
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
 
-void cmCursesOptionsWidget::AddOption(std::string const & option )
+void cmCursesOptionsWidget::AddOption(std::string const& option)
 {
   this->Options.push_back(option);
 }
@@ -69,22 +63,18 @@ void cmCursesOptionsWidget::AddOption(std::string const & option )
 void cmCursesOptionsWidget::NextOption()
 {
   this->CurrentOption++;
-  if(this->CurrentOption > this->Options.size()-1)
-    {
+  if (this->CurrentOption > this->Options.size() - 1) {
     this->CurrentOption = 0;
-    }
+  }
   this->SetValue(this->Options[this->CurrentOption]);
 }
 void cmCursesOptionsWidget::PreviousOption()
 {
-  if(this->CurrentOption == 0)
-    {
-    this->CurrentOption = this->Options.size()-1;
-    }
-  else
-    {
+  if (this->CurrentOption == 0) {
+    this->CurrentOption = this->Options.size() - 1;
+  } else {
     this->CurrentOption--;
-    }
+  }
   this->SetValue(this->Options[this->CurrentOption]);
 }
 
@@ -93,13 +83,11 @@ void cmCursesOptionsWidget::SetOption(const std::string& value)
   this->CurrentOption = 0; // default to 0 index
   this->SetValue(value);
   int index = 0;
-  for(std::vector<std::string>::iterator i = this->Options.begin();
-      i != this->Options.end(); ++i)
-    {
-    if(*i == value)
-      {
+  for (std::vector<std::string>::iterator i = this->Options.begin();
+       i != this->Options.end(); ++i) {
+    if (*i == value) {
       this->CurrentOption = index;
-      }
-    index++;
     }
+    index++;
+  }
 }
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h
index 324014e..a17f2d5 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.h
+++ b/Source/CursesDialog/cmCursesOptionsWidget.h
@@ -13,6 +13,7 @@
 #define cmCursesOptionsWidget_h
 
 #include "cmCursesWidget.h"
+
 class cmCursesMainForm;
 
 class cmCursesOptionsWidget : public cmCursesWidget
@@ -26,9 +27,10 @@ public:
   // handled.
   virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w);
   void SetOption(const std::string&);
-  void AddOption(std::string const &);
+  void AddOption(std::string const&);
   void NextOption();
   void PreviousOption();
+
 protected:
   cmCursesOptionsWidget(const cmCursesOptionsWidget& from);
   void operator=(const cmCursesOptionsWidget&);
diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx
index 6116823..33fffd1 100644
--- a/Source/CursesDialog/cmCursesPathWidget.cxx
+++ b/Source/CursesDialog/cmCursesPathWidget.cxx
@@ -14,9 +14,9 @@
 #include "cmCursesMainForm.h"
 #include "cmSystemTools.h"
 
-cmCursesPathWidget::cmCursesPathWidget(int width, int height,
-                                           int left, int top) :
-  cmCursesStringWidget(width, height, left, top)
+cmCursesPathWidget::cmCursesPathWidget(int width, int height, int left,
+                                       int top)
+  : cmCursesStringWidget(width, height, left, top)
 {
   this->Type = cmState::PATH;
   this->Cycle = false;
@@ -33,46 +33,39 @@ void cmCursesPathWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW* w)
 
 void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
 {
-  if ( !this->GetString() )
-    {
+  if (!this->GetString()) {
     return;
-    }
+  }
   FORM* form = fm->GetForm();
   form_driver(form, REQ_NEXT_FIELD);
   form_driver(form, REQ_PREV_FIELD);
   std::string cstr = this->GetString();
-  cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r")+1);
-  if ( this->LastString != cstr )
-    {
+  cstr = cstr.substr(0, cstr.find_last_not_of(" \t\n\r") + 1);
+  if (this->LastString != cstr) {
     this->Cycle = false;
     this->CurrentIndex = 0;
     this->LastGlob = "";
-    }
+  }
   std::string glob;
-  if ( this->Cycle )
-    {
+  if (this->Cycle) {
     glob = this->LastGlob;
-    }
-  else
-    {
+  } else {
     glob = cstr + "*";
-    }
+  }
   std::vector<std::string> dirs;
 
-  cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmState::PATH?-1:0));
-  if ( this->CurrentIndex < dirs.size() )
-    {
+  cmSystemTools::SimpleGlob(glob, dirs,
+                            (this->Type == cmState::PATH ? -1 : 0));
+  if (this->CurrentIndex < dirs.size()) {
     cstr = dirs[this->CurrentIndex];
-    }
-  if ( cstr[cstr.size()-1] == '*' )
-    {
-    cstr = cstr.substr(0, cstr.size()-1);
-    }
+  }
+  if (cstr[cstr.size() - 1] == '*') {
+    cstr = cstr.substr(0, cstr.size() - 1);
+  }
 
-  if ( cmSystemTools::FileIsDirectory(cstr) )
-    {
+  if (cmSystemTools::FileIsDirectory(cstr)) {
     cstr += "/";
-    }
+  }
 
   this->SetString(cstr);
   touchwin(w);
@@ -81,11 +74,10 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
   this->LastGlob = glob;
   this->LastString = cstr;
   this->Cycle = true;
-  this->CurrentIndex ++;
-  if ( this->CurrentIndex >= dirs.size() )
-    {
+  this->CurrentIndex++;
+  if (this->CurrentIndex >= dirs.size()) {
     this->CurrentIndex = 0;
-    }
+  }
 }
 
 void cmCursesPathWidget::OnReturn(cmCursesMainForm* fm, WINDOW* w)
diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h
index 6047ec5..7b44df9 100644
--- a/Source/CursesDialog/cmCursesStandardIncludes.h
+++ b/Source/CursesDialog/cmCursesStandardIncludes.h
@@ -11,13 +11,16 @@
 ============================================================================*/
 #ifndef cmCursesStandardIncludes_h
 #define cmCursesStandardIncludes_h
+
+#include "../cmStandardIncludes.h"
+
 #if defined(__sun__) && defined(__GNUC__)
- #define _MSE_INT_H
+#define _MSE_INT_H
 #endif
 
 #if defined(__hpux)
-# define _BOOL_DEFINED
-# include <sys/time.h>
+#define _BOOL_DEFINED
+#include <sys/time.h>
 #endif
 
 #include <form.h>
@@ -26,7 +29,7 @@
 // so remove them from the namespace
 inline void curses_move(unsigned int x, unsigned int y)
 {
-  move(x,y);
+  move(x, y);
 }
 
 inline void curses_clear()
@@ -39,5 +42,4 @@ inline void curses_clear()
 #undef erase
 #undef clear
 
-
 #endif // cmCursesStandardIncludes_h
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index 6eb15c1..3707d0d 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -10,34 +10,34 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCursesStringWidget.h"
+
 #include "cmCursesMainForm.h"
 
 inline int ctrl(int z)
 {
-    return (z&037);
+  return (z & 037);
 }
 
-cmCursesStringWidget::cmCursesStringWidget(int width, int height,
-                                           int left, int top) :
-  cmCursesWidget(width, height, left, top)
+cmCursesStringWidget::cmCursesStringWidget(int width, int height, int left,
+                                           int top)
+  : cmCursesWidget(width, height, left, top)
 {
   this->InEdit = false;
   this->Type = cmState::STRING;
-  set_field_fore(this->Field,  A_NORMAL);
-  set_field_back(this->Field,  A_STANDOUT);
-  field_opts_off(this->Field,  O_STATIC);
+  set_field_fore(this->Field, A_NORMAL);
+  set_field_back(this->Field, A_STANDOUT);
+  field_opts_off(this->Field, O_STATIC);
 }
 
 void cmCursesStringWidget::OnTab(cmCursesMainForm*, WINDOW*)
 {
-  //FORM* form = fm->GetForm();
+  // FORM* form = fm->GetForm();
 }
 
 void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW*)
 {
   FORM* form = fm->GetForm();
-  if (this->InEdit)
-    {
+  if (this->InEdit) {
     cmCursesForm::LogMessage("String widget leaving edit.");
     this->InEdit = false;
     fm->PrintKeys();
@@ -46,16 +46,14 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW*)
     form_driver(form, REQ_NEXT_FIELD);
     form_driver(form, REQ_PREV_FIELD);
     this->Done = true;
-    }
-  else
-    {
+  } else {
     cmCursesForm::LogMessage("String widget entering edit.");
     this->InEdit = true;
     fm->PrintKeys();
     char* buf = field_buffer(this->Field, 0);
-    this->OriginalString = new char[strlen(buf)+1];
+    this->OriginalString = new char[strlen(buf) + 1];
     strcpy(this->OriginalString, buf);
-    }
+  }
 }
 
 void cmCursesStringWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW*)
@@ -66,23 +64,21 @@ void cmCursesStringWidget::OnType(int& key, cmCursesMainForm* fm, WINDOW*)
 bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
                                        WINDOW* w)
 {
-  int x,y;
+  int x, y;
 
   FORM* form = fm->GetForm();
   // 10 == enter
-  if (!this->InEdit && ( key != 10 && key != KEY_ENTER ) )
-    {
+  if (!this->InEdit && (key != 10 && key != KEY_ENTER)) {
     return false;
-    }
+  }
 
-  this->OriginalString=0;
+  this->OriginalString = 0;
   this->Done = false;
 
   char debugMessage[128];
 
   // <Enter> is used to change edit mode (like <Esc> in vi).
-  while(!this->Done)
-    {
+  while (!this->Done) {
     sprintf(debugMessage, "String widget handling input, key: %d", key);
     cmCursesForm::LogMessage(debugMessage);
 
@@ -90,48 +86,36 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
 
     getmaxyx(stdscr, y, x);
     // If window too small, handle 'q' only
-    if ( x < cmCursesMainForm::MIN_WIDTH  ||
-         y < cmCursesMainForm::MIN_HEIGHT )
-      {
+    if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
       // quit
-      if ( key == 'q' )
-        {
+      if (key == 'q') {
         return false;
-        }
-      else
-        {
-        key=getch();
+      } else {
+        key = getch();
         continue;
-        }
       }
+    }
 
-    // If resize occured during edit, move out of edit mode
-    if (!this->InEdit && ( key != 10 && key != KEY_ENTER ) )
-      {
+    // If resize occurred during edit, move out of edit mode
+    if (!this->InEdit && (key != 10 && key != KEY_ENTER)) {
       return false;
-      }
+    }
     // 10 == enter
-    if (key == 10 || key == KEY_ENTER)
-      {
+    if (key == 10 || key == KEY_ENTER) {
       this->OnReturn(fm, w);
-      }
-    else if ( key == KEY_DOWN || key == ctrl('n') ||
-              key == KEY_UP || key == ctrl('p') ||
-              key == KEY_NPAGE || key == ctrl('d') ||
-              key == KEY_PPAGE || key == ctrl('u'))
-      {
+    } else if (key == KEY_DOWN || key == ctrl('n') || key == KEY_UP ||
+               key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') ||
+               key == KEY_PPAGE || key == ctrl('u')) {
       this->InEdit = false;
       delete[] this->OriginalString;
       // trick to force forms to update the field buffer
       form_driver(form, REQ_NEXT_FIELD);
       form_driver(form, REQ_PREV_FIELD);
       return false;
-      }
+    }
     // esc
-    else if (key == 27)
-      {
-      if (this->InEdit)
-        {
+    else if (key == 27) {
+      if (this->InEdit) {
         this->InEdit = false;
         fm->PrintKeys();
         this->SetString(this->OriginalString);
@@ -139,58 +123,37 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
         touchwin(w);
         wrefresh(w);
         return true;
-        }
       }
-    else if ( key == 9 )
-      {
+    } else if (key == 9) {
       this->OnTab(fm, w);
-      }
-    else if ( key == KEY_LEFT || key == ctrl('b') )
-      {
+    } else if (key == KEY_LEFT || key == ctrl('b')) {
       form_driver(form, REQ_PREV_CHAR);
-      }
-    else if ( key == KEY_RIGHT || key == ctrl('f') )
-      {
+    } else if (key == KEY_RIGHT || key == ctrl('f')) {
       form_driver(form, REQ_NEXT_CHAR);
-      }
-    else if ( key == ctrl('k') )
-      {
+    } else if (key == ctrl('k')) {
       form_driver(form, REQ_CLR_EOL);
-      }
-    else if ( key == ctrl('a') || key == KEY_HOME )
-      {
+    } else if (key == ctrl('a') || key == KEY_HOME) {
       form_driver(form, REQ_BEG_FIELD);
-      }
-    else if ( key == ctrl('e') || key == KEY_END )
-      {
+    } else if (key == ctrl('e') || key == KEY_END) {
       form_driver(form, REQ_END_FIELD);
+    } else if (key == 127 || key == KEY_BACKSPACE) {
+      FIELD* cur = current_field(form);
+      form_driver(form, REQ_DEL_PREV);
+      if (current_field(form) != cur) {
+        set_current_field(form, cur);
       }
-    else if ( key == 127 ||
-              key == KEY_BACKSPACE )
-      {
-        FIELD *cur = current_field(form);
-        form_driver(form, REQ_DEL_PREV);
-        if (current_field(form) != cur)
-          {
-          set_current_field(form, cur);
-          }
-      }
-    else if ( key == ctrl('d') ||key == KEY_DC )
-      {
+    } else if (key == ctrl('d') || key == KEY_DC) {
       form_driver(form, REQ_DEL_CHAR);
-      }
-    else
-      {
+    } else {
       this->OnType(key, fm, w);
-      }
-    if ( !this->Done )
-      {
+    }
+    if (!this->Done) {
       touchwin(w);
       wrefresh(w);
 
-      key=getch();
-      }
+      key = getch();
     }
+  }
   return true;
 }
 
@@ -211,38 +174,32 @@ const char* cmCursesStringWidget::GetValue()
 
 bool cmCursesStringWidget::PrintKeys()
 {
-  int x,y;
+  int x, y;
   getmaxyx(stdscr, y, x);
-  if ( x < cmCursesMainForm::MIN_WIDTH  ||
-       y < cmCursesMainForm::MIN_HEIGHT )
-    {
+  if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
     return false;
-    }
-  if (this->InEdit)
-    {
+  }
+  if (this->InEdit) {
     char fmt_s[] = "%s";
     char firstLine[512];
     // Clean the toolbar
-    for(int i=0; i<512; i++)
-      {
+    for (int i = 0; i < 512; i++) {
       firstLine[i] = ' ';
-      }
+    }
     firstLine[511] = '\0';
-    curses_move(y-4,0);
+    curses_move(y - 4, 0);
     printw(fmt_s, firstLine);
-    curses_move(y-3,0);
+    curses_move(y - 3, 0);
     printw(fmt_s, firstLine);
-    curses_move(y-2,0);
+    curses_move(y - 2, 0);
     printw(fmt_s, firstLine);
-    curses_move(y-1,0);
+    curses_move(y - 1, 0);
     printw(fmt_s, firstLine);
 
-    curses_move(y-3,0);
+    curses_move(y - 3, 0);
     printw(fmt_s, "Editing option, press [enter] to leave edit.");
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx
index a12e4c2..100ed1d 100644
--- a/Source/CursesDialog/cmCursesWidget.cxx
+++ b/Source/CursesDialog/cmCursesWidget.cxx
@@ -15,41 +15,36 @@ cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
 {
   this->Field = new_field(height, width, top, left, 0, 0);
   set_field_userptr(this->Field, reinterpret_cast<char*>(this));
-  field_opts_off(this->Field,  O_AUTOSKIP);
+  field_opts_off(this->Field, O_AUTOSKIP);
   this->Page = 0;
 }
 
 cmCursesWidget::~cmCursesWidget()
 {
-  if (this->Field)
-    {
+  if (this->Field) {
     free_field(this->Field);
     this->Field = 0;
-    }
+  }
 }
 
 void cmCursesWidget::Move(int x, int y, bool isNewPage)
 {
-  if (!this->Field)
-    {
+  if (!this->Field) {
     return;
-    }
+  }
 
   move_field(this->Field, y, x);
-  if (isNewPage)
-    {
+  if (isNewPage) {
     set_new_page(this->Field, TRUE);
-    }
-  else
-    {
+  } else {
     set_new_page(this->Field, FALSE);
-    }
+  }
 }
 
 void cmCursesWidget::SetValue(const std::string& value)
 {
   this->Value = value;
-  set_field_buffer(this->Field, 0, const_cast<char *>(value.c_str()));
+  set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
 }
 
 const char* cmCursesWidget::GetValue()
diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h
index 7bbdff1..2ac5bb8 100644
--- a/Source/CursesDialog/cmCursesWidget.h
+++ b/Source/CursesDialog/cmCursesWidget.h
@@ -12,9 +12,10 @@
 #ifndef cmCursesWidget_h
 #define cmCursesWidget_h
 
-#include "../cmState.h"
 #include "cmCursesStandardIncludes.h"
 
+#include "../cmState.h"
+
 class cmCursesMainForm;
 
 class cmCursesWidget
@@ -46,30 +47,20 @@ public:
   /**
    * Get the type of the widget (STRING, PATH etc...)
    */
-  cmState::CacheEntryType GetType()
-    { return this->Type; }
+  cmState::CacheEntryType GetType() { return this->Type; }
 
   /**
    * If there are any, print the widget specific commands
    * in the toolbar and return true. Otherwise, return false
    * and the parent widget will print.
    */
-  virtual bool PrintKeys()
-    {
-      return false;
-    }
+  virtual bool PrintKeys() { return false; }
 
   /**
    * Set/Get the page this widget is in.
    */
-  void SetPage(int page)
-    {
-      this->Page = page;
-    }
-  int GetPage()
-    {
-      return this->Page;
-    }
+  void SetPage(int page) { this->Page = page; }
+  int GetPage() { return this->Page; }
 
   friend class cmCursesMainForm;
 
diff --git a/Source/CursesDialog/form/fld_def.c b/Source/CursesDialog/form/fld_def.c
index 4a49a25..00da3b4 100644
--- a/Source/CursesDialog/form/fld_def.c
+++ b/Source/CursesDialog/form/fld_def.c
@@ -73,7 +73,7 @@ FIELD *_nc_Default_Field = &default_field;
 |                              int *err )
 |   
 |   Description   :  Create an argument structure for the specified type.
-|                    Use the type-dependant argument list to construct
+|                    Use the type-dependent argument list to construct
 |                    it.
 |
 |   Return Values :  Pointer to argument structure. Maybe NULL.
@@ -193,7 +193,7 @@ _nc_Free_Argument(const FIELDTYPE * typ, TypeArgument * argp)
 |   Description   :  Copy argument structure of field src to field dst
 |
 |   Return Values :  TRUE       - copy worked
-|                    FALSE      - error occured
+|                    FALSE      - error occurred
 +--------------------------------------------------------------------------*/
 bool
 _nc_Copy_Type(FIELD *dst, FIELD const *src)
diff --git a/Source/CursesDialog/form/fld_ftlink.c b/Source/CursesDialog/form/fld_ftlink.c
index 1cb80d1..e98a4ca 100644
--- a/Source/CursesDialog/form/fld_ftlink.c
+++ b/Source/CursesDialog/form/fld_ftlink.c
@@ -46,7 +46,7 @@ MODULE_ID("$Id$")
 |                       E_BAD_ARGUMENT  - invalid arguments
 |                       E_SYSTEM_ERROR  - system error (no memory)
 |
-|   Return Values :  Fieldtype pointer or NULL if error occured.
+|   Return Values :  Fieldtype pointer or NULL if error occurred.
 +--------------------------------------------------------------------------*/
 FIELDTYPE *link_fieldtype(FIELDTYPE * type1, FIELDTYPE * type2)
 {
diff --git a/Source/CursesDialog/form/fld_newftyp.c b/Source/CursesDialog/form/fld_newftyp.c
index b45ebd8..b839f19 100644
--- a/Source/CursesDialog/form/fld_newftyp.c
+++ b/Source/CursesDialog/form/fld_newftyp.c
@@ -63,7 +63,7 @@ const FIELDTYPE* _nc_Default_FieldType = &default_fieldtype;
 |                       E_BAD_ARGUMENT  - invalid arguments
 |                       E_SYSTEM_ERROR  - system error (no memory)
 |
-|   Return Values :  Fieldtype pointer or NULL if error occured
+|   Return Values :  Fieldtype pointer or NULL if error occurred
 +--------------------------------------------------------------------------*/
 FIELDTYPE *new_fieldtype(
  bool (* const field_check)(FIELD *,const void *),
diff --git a/Source/CursesDialog/form/form.priv.h b/Source/CursesDialog/form/form.priv.h
index 8516a6f..6e00af6 100644
--- a/Source/CursesDialog/form/form.priv.h
+++ b/Source/CursesDialog/form/form.priv.h
@@ -40,7 +40,7 @@
 
 /* field status values */
 #define _CHANGED         (0x01) /* Field has been changed                 */
-#define _NEWTOP          (0x02) /* Vertical scrolling occured             */
+#define _NEWTOP          (0x02) /* Vertical scrolling occurred             */
 #define _NEWPAGE         (0x04) /* field begins new page of form          */
 #define _MAY_GROW        (0x08) /* dynamic field may still grow           */
 
diff --git a/Source/CursesDialog/form/frm_def.c b/Source/CursesDialog/form/frm_def.c
index 0b28f5f..645b3ba 100644
--- a/Source/CursesDialog/form/frm_def.c
+++ b/Source/CursesDialog/form/frm_def.c
@@ -240,7 +240,7 @@ static int Connect_Fields(FORM  * form, FIELD ** fields)
 |                    If there are fields, position to first active field.
 |
 |   Return Values :  E_OK            - success
-|                    any other       - error occured
+|                    any other       - error occurred
 +--------------------------------------------------------------------------*/
 INLINE static int Associate_Fields(FORM  *form, FIELD **fields)
 {
@@ -267,7 +267,7 @@ INLINE static int Associate_Fields(FORM  *form, FIELD **fields)
 |   
 |   Description   :  Create new form with given array of fields.
 |
-|   Return Values :  Pointer to form. NULL if error occured.
+|   Return Values :  Pointer to form. NULL if error occurred.
 +--------------------------------------------------------------------------*/
 FORM *new_form(FIELD ** fields)
 {	
diff --git a/Source/CursesDialog/form/frm_driver.c b/Source/CursesDialog/form/frm_driver.c
index 26f580e..e4e72aa 100644
--- a/Source/CursesDialog/form/frm_driver.c
+++ b/Source/CursesDialog/form/frm_driver.c
@@ -1676,7 +1676,7 @@ static int VSC_Generic(FORM *form, int lines)
 |   
 |   Description   :  Performs the generic vertical scrolling routines. 
 |                    This has to check for a multi-line field and to set
-|                    the _NEWTOP flag if scrolling really occured.
+|                    the _NEWTOP flag if scrolling really occurred.
 |
 |   Return Values :  Propagated error code from low-level driver calls
 +--------------------------------------------------------------------------*/
@@ -2159,7 +2159,7 @@ static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
 |   
 |   Description   :  Generic routine for field editing requests. The driver
 |                    routines are only called for editable fields, the
-|                    _WINDOW_MODIFIED flag is set if editing occured.
+|                    _WINDOW_MODIFIED flag is set if editing occurred.
 |                    This is somewhat special due to the overload semantics
 |                    of the NEW_LINE and DEL_PREV requests.
 |
diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx
index 3881045..dc7a4b0 100644
--- a/Source/QtDialog/AddCacheEntry.cxx
+++ b/Source/QtDialog/AddCacheEntry.cxx
@@ -11,26 +11,29 @@
 ============================================================================*/
 
 #include "AddCacheEntry.h"
-#include <QMetaProperty>
+
 #include <QCompleter>
+#include <QMetaProperty>
 
 static const int NumTypes = 4;
 static const int DefaultTypeIndex = 0;
-static const QByteArray TypeStrings[NumTypes] =
-  { "BOOL", "PATH", "FILEPATH", "STRING" };
-static const QCMakeProperty::PropertyType Types[NumTypes] =
-  { QCMakeProperty::BOOL, QCMakeProperty::PATH,
-    QCMakeProperty::FILEPATH, QCMakeProperty::STRING};
+static const QByteArray TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH",
+                                                  "STRING" };
+static const QCMakeProperty::PropertyType Types[NumTypes] = {
+  QCMakeProperty::BOOL, QCMakeProperty::PATH, QCMakeProperty::FILEPATH,
+  QCMakeProperty::STRING
+};
 
 AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
-                                         const QStringList& varTypes)
-  : QWidget(p), VarNames(varNames), VarTypes(varTypes)
+                             const QStringList& varTypes)
+  : QWidget(p)
+  , VarNames(varNames)
+  , VarTypes(varTypes)
 {
   this->setupUi(this);
-  for(int i=0; i<NumTypes; i++)
-    {
+  for (int i = 0; i < NumTypes; i++) {
     this->Type->addItem(TypeStrings[i]);
-    }
+  }
   QWidget* cb = new QCheckBox();
   QWidget* path = new QCMakePathEditor();
   QWidget* filepath = new QCMakeFilePathEditor();
@@ -45,10 +48,10 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
   this->setTabOrder(path, filepath);
   this->setTabOrder(filepath, string);
   this->setTabOrder(string, this->Description);
-  QCompleter *completer = new QCompleter(this->VarNames, this);
+  QCompleter* completer = new QCompleter(this->VarNames, this);
   this->Name->setCompleter(completer);
-  connect(completer, SIGNAL(activated(const QString&)),
-          this, SLOT(onCompletionActivated(const QString&)));
+  connect(completer, SIGNAL(activated(const QString&)), this,
+          SLOT(onCompletionActivated(const QString&)));
 }
 
 QString AddCacheEntry::name() const
@@ -59,14 +62,11 @@ QString AddCacheEntry::name() const
 QVariant AddCacheEntry::value() const
 {
   QWidget* w = this->StackedWidget->currentWidget();
-  if(qobject_cast<QLineEdit*>(w))
-    {
+  if (qobject_cast<QLineEdit*>(w)) {
     return static_cast<QLineEdit*>(w)->text();
-    }
-  else if(qobject_cast<QCheckBox*>(w))
-    {
+  } else if (qobject_cast<QCheckBox*>(w)) {
     return static_cast<QCheckBox*>(w)->isChecked();
-    }
+  }
   return QVariant();
 }
 
@@ -78,36 +78,31 @@ QString AddCacheEntry::description() const
 QCMakeProperty::PropertyType AddCacheEntry::type() const
 {
   int idx = this->Type->currentIndex();
-  if(idx >= 0 && idx < NumTypes)
-    {
+  if (idx >= 0 && idx < NumTypes) {
     return Types[idx];
-    }
+  }
   return Types[DefaultTypeIndex];
 }
 
 QString AddCacheEntry::typeString() const
 {
   int idx = this->Type->currentIndex();
-  if(idx >= 0 && idx < NumTypes)
-    {
+  if (idx >= 0 && idx < NumTypes) {
     return TypeStrings[idx];
-    }
+  }
   return TypeStrings[DefaultTypeIndex];
 }
 
-void AddCacheEntry::onCompletionActivated(const QString &text)
+void AddCacheEntry::onCompletionActivated(const QString& text)
 {
   int idx = this->VarNames.indexOf(text);
-  if (idx != -1)
-    {
+  if (idx != -1) {
     QString vartype = this->VarTypes[idx];
-    for (int i = 0; i < NumTypes; i++)
-      {
-        if (TypeStrings[i] == vartype)
-          {
-          this->Type->setCurrentIndex(i);
-          break;
-          }
+    for (int i = 0; i < NumTypes; i++) {
+      if (TypeStrings[i] == vartype) {
+        this->Type->setCurrentIndex(i);
+        break;
       }
     }
+  }
 }
diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h
index 38c3a74..05469af 100644
--- a/Source/QtDialog/AddCacheEntry.h
+++ b/Source/QtDialog/AddCacheEntry.h
@@ -13,11 +13,12 @@
 #ifndef AddCacheEntry_h
 #define AddCacheEntry_h
 
-#include <QWidget>
+#include "QCMake.h"
+
 #include <QCheckBox>
 #include <QStringList>
+#include <QWidget>
 
-#include "QCMake.h"
 #include "ui_AddCacheEntry.h"
 
 class AddCacheEntry : public QWidget, public Ui::AddCacheEntry
@@ -25,7 +26,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry
   Q_OBJECT
 public:
   AddCacheEntry(QWidget* p, const QStringList& varNames,
-                            const QStringList& varTypes);
+                const QStringList& varTypes);
 
   QString name() const;
   QVariant value() const;
@@ -34,7 +35,7 @@ public:
   QString typeString() const;
 
 private slots:
-  void onCompletionActivated(const QString &text);
+  void onCompletionActivated(const QString& text);
 
 private:
   const QStringList& VarNames;
@@ -42,4 +43,3 @@ private:
 };
 
 #endif
-
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 4f93a77..c849d52 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -9,47 +9,39 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include "QCMake.h"  // include to disable MS warnings
+#include "QCMake.h" // include to disable MS warnings
+
+#include "CMakeSetupDialog.h"
+#include "cmAlgorithms.h"
+#include "cmDocumentation.h"
+#include "cmVersion.h"
+#include "cmake.h"
 #include <QApplication>
 #include <QDir>
-#include <QTranslator>
 #include <QLocale>
+#include <QString>
 #include <QTextCodec>
-#include "CMakeSetupDialog.h"
-#include "cmDocumentation.h"
-#include "cmake.h"
-#include "cmVersion.h"
-#include "cmAlgorithms.h"
+#include <QTranslator>
 #include <cmsys/CommandLineArguments.hxx>
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Encoding.hxx>
+#include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationName[][2] =
-{
-  {0,
-   "  cmake-gui - CMake GUI."},
-  {0,0}
-};
+static const char* cmDocumentationName[][2] = { { 0,
+                                                  "  cmake-gui - CMake GUI." },
+                                                { 0, 0 } };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsage[][2] =
-{
-  {0,
-   "  cmake-gui [options]\n"
-   "  cmake-gui [options] <path-to-source>\n"
-   "  cmake-gui [options] <path-to-existing-build>"},
-  {0,0}
+static const char* cmDocumentationUsage[][2] = {
+  { 0, "  cmake-gui [options]\n"
+       "  cmake-gui [options] <path-to-source>\n"
+       "  cmake-gui [options] <path-to-existing-build>" },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationOptions[][2] =
-{
-  {0,0}
-};
+static const char* cmDocumentationOptions[][2] = { { 0, 0 } };
 
 #if defined(Q_OS_MAC)
 static int cmOSXInstall(std::string dir);
+static void cmAddPluginPath();
 #endif
 
 int main(int argc, char** argv)
@@ -64,8 +56,7 @@ int main(int argc, char** argv)
   // do docs, if args were given
   cmDocumentation doc;
   doc.addCMakeStandardDocSections();
-  if(argc2 >1 && doc.CheckOptions(argc2, argv2))
-    {
+  if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) {
     // Construct and print requested documentation.
     cmake hcm;
     hcm.SetHomeDirectory("");
@@ -75,27 +66,36 @@ int main(int argc, char** argv)
     std::vector<cmDocumentationEntry> generators;
     hcm.GetGeneratorDocumentation(generators);
     doc.SetName("cmake");
-    doc.SetSection("Name",cmDocumentationName);
-    doc.SetSection("Usage",cmDocumentationUsage);
-    doc.AppendSection("Generators",generators);
-    doc.PrependSection("Options",cmDocumentationOptions);
+    doc.SetSection("Name", cmDocumentationName);
+    doc.SetSection("Usage", cmDocumentationUsage);
+    doc.AppendSection("Generators", generators);
+    doc.PrependSection("Options", cmDocumentationOptions);
 
-    return (doc.PrintRequestedDocumentation(std::cout)? 0:1);
-    }
+    return (doc.PrintRequestedDocumentation(std::cout) ? 0 : 1);
+  }
 
 #if defined(Q_OS_MAC)
-  if (argc2 == 2 && strcmp(argv2[1], "--install") == 0)
-    {
+  if (argc2 == 2 && strcmp(argv2[1], "--install") == 0) {
     return cmOSXInstall("/usr/local/bin");
-    }
-  if (argc2 == 2 && cmHasLiteralPrefix(argv2[1], "--install="))
-    {
-    return cmOSXInstall(argv2[1]+10);
-    }
+  }
+  if (argc2 == 2 && cmHasLiteralPrefix(argv2[1], "--install=")) {
+    return cmOSXInstall(argv2[1] + 10);
+  }
+#endif
+
+// When we are on OSX and we are launching cmake-gui from a symlink, the
+// application will fail to launch as it can't find the qt.conf file which
+// tells it what the name of the plugin folder is. We need to add this path
+// BEFORE the application is constructed as that is what triggers the
+// searching for the platform plugins
+#if defined(Q_OS_MAC)
+  cmAddPluginPath();
 #endif
 
   QApplication app(argc, argv);
 
+  setlocale(LC_NUMERIC, "C");
+
 #if defined(CMAKE_ENCODING_UTF8)
   QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
   QTextCodec::setCodecForLocale(utf8_codec);
@@ -103,10 +103,9 @@ int main(int argc, char** argv)
 
   // 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())
-    {
+  foreach (QString p, QApplication::libraryPaths()) {
     QApplication::removeLibraryPath(p);
-    }
+  }
 
   // tell the cmake library where cmake is
   QDir cmExecDir(QApplication::applicationDirPath());
@@ -139,109 +138,115 @@ int main(int argc, char** argv)
   std::string binaryDirectory;
   std::string sourceDirectory;
   typedef cmsys::CommandLineArguments argT;
-  arg.AddArgument("-B", argT::CONCAT_ARGUMENT,
-                  &binaryDirectory, "Binary Directory");
-  arg.AddArgument("-H", argT::CONCAT_ARGUMENT,
-                  &sourceDirectory, "Source Directory");
+  arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory,
+                  "Binary Directory");
+  arg.AddArgument("-H", argT::CONCAT_ARGUMENT, &sourceDirectory,
+                  "Source Directory");
   // do not complain about unknown options
   arg.StoreUnusedArguments(true);
   arg.Parse();
-  if(!sourceDirectory.empty() && !binaryDirectory.empty())
-    {
+  if (!sourceDirectory.empty() && !binaryDirectory.empty()) {
     dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
     dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str()));
-    }
-  else
-    {
+  } else {
     QStringList args = app.arguments();
-    if(args.count() == 2)
-      {
-      std::string filePath = cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
+    if (args.count() == 2) {
+      std::string filePath =
+        cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
 
       // check if argument is a directory containing CMakeCache.txt
       std::string buildFilePath =
         cmSystemTools::CollapseFullPath("CMakeCache.txt", filePath.c_str());
 
       // check if argument is a CMakeCache.txt file
-      if(cmSystemTools::GetFilenameName(filePath) == "CMakeCache.txt" &&
-         cmSystemTools::FileExists(filePath.c_str()))
-        {
+      if (cmSystemTools::GetFilenameName(filePath) == "CMakeCache.txt" &&
+          cmSystemTools::FileExists(filePath.c_str())) {
         buildFilePath = filePath;
-        }
+      }
 
       // check if argument is a directory containing CMakeLists.txt
       std::string srcFilePath =
         cmSystemTools::CollapseFullPath("CMakeLists.txt", filePath.c_str());
 
-      if(cmSystemTools::FileExists(buildFilePath.c_str()))
-        {
-        dialog.setBinaryDirectory(
-          QString::fromLocal8Bit(
-            cmSystemTools::GetFilenamePath(buildFilePath).c_str()
-            )
-          );
-        }
-      else if(cmSystemTools::FileExists(srcFilePath.c_str()))
-        {
+      if (cmSystemTools::FileExists(buildFilePath.c_str())) {
+        dialog.setBinaryDirectory(QString::fromLocal8Bit(
+          cmSystemTools::GetFilenamePath(buildFilePath).c_str()));
+      } else if (cmSystemTools::FileExists(srcFilePath.c_str())) {
         dialog.setSourceDirectory(QString::fromLocal8Bit(filePath.c_str()));
-        dialog.setBinaryDirectory(
-          QString::fromLocal8Bit(cmSystemTools::CollapseFullPath(".").c_str())
-          );
-        }
+        dialog.setBinaryDirectory(QString::fromLocal8Bit(
+          cmSystemTools::CollapseFullPath(".").c_str()));
       }
     }
+  }
 
   return app.exec();
 }
 
 #if defined(Q_OS_MAC)
-# include <errno.h>
-# include <string.h>
-# include <sys/stat.h>
-# include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
 static bool cmOSXInstall(std::string const& dir, std::string const& tool)
 {
-  if (tool.empty())
-    {
+  if (tool.empty()) {
     return true;
-    }
+  }
   std::string link = dir + cmSystemTools::GetFilenameName(tool);
   struct stat st;
-  if (lstat(link.c_str(), &st) == 0 && S_ISLNK(st.st_mode))
-    {
+  if (lstat(link.c_str(), &st) == 0 && S_ISLNK(st.st_mode)) {
     char buf[4096];
-    ssize_t s = readlink(link.c_str(), buf, sizeof(buf)-1);
-    if (s >= 0 && std::string(buf, s) == tool)
-      {
+    ssize_t s = readlink(link.c_str(), buf, sizeof(buf) - 1);
+    if (s >= 0 && std::string(buf, s) == tool) {
       std::cerr << "Exists: '" << link << "' -> '" << tool << "'\n";
       return true;
-      }
     }
-  if (symlink(tool.c_str(), link.c_str()) == 0)
-    {
+  }
+  cmSystemTools::MakeDirectory(dir);
+  if (symlink(tool.c_str(), link.c_str()) == 0) {
     std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n";
     return true;
-    }
-  else
-    {
+  } else {
     int err = errno;
-    std::cerr << "Failed: '" << link << "' -> '" << tool << "': "
-              << strerror(err) << "\n";
+    std::cerr << "Failed: '" << link << "' -> '" << tool
+              << "': " << strerror(err) << "\n";
     return false;
-    }
+  }
 }
 static int cmOSXInstall(std::string dir)
 {
-  if (!cmHasLiteralSuffix(dir, "/"))
-    {
+  if (!cmHasLiteralSuffix(dir, "/")) {
     dir += "/";
-    }
-  return (
-    cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) &&
-    cmOSXInstall(dir, cmSystemTools::GetCTestCommand()) &&
-    cmOSXInstall(dir, cmSystemTools::GetCPackCommand()) &&
-    cmOSXInstall(dir, cmSystemTools::GetCMakeGUICommand()) &&
-    cmOSXInstall(dir, cmSystemTools::GetCMakeCursesCommand())
-    ) ? 0 : 1;
+  }
+  return (cmOSXInstall(dir, cmSystemTools::GetCMakeCommand()) &&
+          cmOSXInstall(dir, cmSystemTools::GetCTestCommand()) &&
+          cmOSXInstall(dir, cmSystemTools::GetCPackCommand()) &&
+          cmOSXInstall(dir, cmSystemTools::GetCMakeGUICommand()) &&
+          cmOSXInstall(dir, cmSystemTools::GetCMakeCursesCommand()))
+    ? 0
+    : 1;
 }
+
+// Locate the PlugIns directory and add it to the QApplication library paths.
+// We need to resolve all symlinks so we have a known relative path between
+// MacOS/CMake and the PlugIns directory.
+//
+// Note we are using cmSystemTools since Qt can't provide the path to the
+// executable before the QApplication is created, and that is when plugin
+// searching occurs.
+static void cmAddPluginPath()
+{
+  std::string const& path = cmSystemTools::GetCMakeGUICommand();
+  if (path.empty()) {
+    return;
+  }
+  std::string const& realPath = cmSystemTools::GetRealPath(path);
+  QFileInfo appPath(QString::fromLocal8Bit(realPath.c_str()));
+  QDir pluginDir = appPath.dir();
+  bool const foundPluginDir = pluginDir.cd("../PlugIns");
+  if (foundPluginDir) {
+    QApplication::addLibraryPath(pluginDir.path());
+  }
+}
+
 #endif
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 2fc4faf..712611d 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -11,35 +11,37 @@
 ============================================================================*/
 
 #include "CMakeSetupDialog.h"
-#include <QFileDialog>
-#include <QProgressBar>
-#include <QMessageBox>
-#include <QStatusBar>
-#include <QToolButton>
-#include <QDialogButtonBox>
+
 #include <QCloseEvent>
 #include <QCoreApplication>
-#include <QSettings>
+#include <QDialogButtonBox>
+#include <QDragEnterEvent>
+#include <QFileDialog>
+#include <QInputDialog>
+#include <QKeySequence>
 #include <QMenu>
 #include <QMenuBar>
-#include <QDragEnterEvent>
+#include <QMessageBox>
 #include <QMimeData>
-#include <QUrl>
+#include <QProgressBar>
+#include <QSettings>
 #include <QShortcut>
-#include <QKeySequence>
-#include <QInputDialog>
+#include <QStatusBar>
+#include <QToolButton>
+#include <QUrl>
 
-#include "QCMake.h"
-#include "QCMakeCacheView.h"
 #include "AddCacheEntry.h"
 #include "FirstConfigure.h"
+#include "QCMake.h"
+#include "QCMakeCacheView.h"
 #include "RegexExplorer.h"
 #include "WarningMessagesDialog.h"
 #include "cmSystemTools.h"
 #include "cmVersion.h"
 
 QCMakeThread::QCMakeThread(QObject* p)
-  : QThread(p), CMakeInstance(NULL)
+  : QThread(p)
+  , CMakeInstance(NULL)
 {
 }
 
@@ -59,7 +61,10 @@ void QCMakeThread::run()
 }
 
 CMakeSetupDialog::CMakeSetupDialog()
-  : ExitAfterGenerate(true), CacheModified(false), ConfigureNeeded(true), CurrentState(Interrupting)
+  : ExitAfterGenerate(true)
+  , CacheModified(false)
+  , ConfigureNeeded(true)
+  , CurrentState(Interrupting)
 {
   QString title = QString(tr("CMake %1"));
   title = title.arg(cmVersion::GetCMakeVersion());
@@ -71,10 +76,11 @@ CMakeSetupDialog::CMakeSetupDialog()
   restoreGeometry(settings.value("geometry").toByteArray());
   restoreState(settings.value("windowState").toByteArray());
 
-  this->AddVariableNames = settings.value("AddVariableNames",
-                           QStringList("CMAKE_INSTALL_PREFIX")).toStringList();
-  this->AddVariableTypes = settings.value("AddVariableTypes",
-                                           QStringList("PATH")).toStringList();
+  this->AddVariableNames =
+    settings.value("AddVariableNames", QStringList("CMAKE_INSTALL_PREFIX"))
+      .toStringList();
+  this->AddVariableTypes =
+    settings.value("AddVariableTypes", QStringList("PATH")).toStringList();
 
   QWidget* cont = new QWidget(this);
   this->setupUi(cont);
@@ -94,60 +100,57 @@ CMakeSetupDialog::CMakeSetupDialog()
 
   bool advancedView = settings.value("AdvancedView", false).toBool();
   this->setAdvancedView(advancedView);
-  this->advancedCheck->setCheckState(advancedView?Qt::Checked : Qt::Unchecked);
+  this->advancedCheck->setCheckState(advancedView ? Qt::Checked
+                                                  : Qt::Unchecked);
 
   QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
   this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache"));
-  QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)),
-                   this, SLOT(doReloadCache()));
+  QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), this,
+                   SLOT(doReloadCache()));
   this->DeleteCacheAction = FileMenu->addAction(tr("&Delete Cache"));
-  QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)),
-                   this, SLOT(doDeleteCache()));
+  QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), this,
+                   SLOT(doDeleteCache()));
   this->ExitAction = FileMenu->addAction(tr("E&xit"));
   this->ExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
-  QObject::connect(this->ExitAction, SIGNAL(triggered(bool)),
-                   this, SLOT(close()));
+  QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), this,
+                   SLOT(close()));
 
   QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
   this->ConfigureAction = ToolsMenu->addAction(tr("&Configure"));
   // prevent merging with Preferences menu item on Mac OS X
   this->ConfigureAction->setMenuRole(QAction::NoRole);
-  QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)),
-                   this, SLOT(doConfigure()));
+  QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), this,
+                   SLOT(doConfigure()));
   this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
-  QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)),
-                   this, SLOT(doGenerate()));
+  QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), this,
+                   SLOT(doGenerate()));
   QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes"));
-  QObject::connect(showChangesAction, SIGNAL(triggered(bool)),
-                   this, SLOT(showUserChanges()));
+  QObject::connect(showChangesAction, SIGNAL(triggered(bool)), this,
+                   SLOT(showUserChanges()));
 #if defined(Q_WS_MAC) || defined(Q_OS_MAC)
-  this->InstallForCommandLineAction
-    = ToolsMenu->addAction(tr("&How to Install For Command Line Use"));
+  this->InstallForCommandLineAction =
+    ToolsMenu->addAction(tr("&How to Install For Command Line Use"));
   QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)),
                    this, SLOT(doInstallForCommandLine()));
 #endif
   ToolsMenu->addSeparator();
-  ToolsMenu->addAction(tr("Regular Expression Explorer..."),
-                       this, SLOT(doRegexExplorerDialog()));
+  ToolsMenu->addAction(tr("Regular Expression Explorer..."), this,
+                       SLOT(doRegexExplorerDialog()));
   ToolsMenu->addSeparator();
-  ToolsMenu->addAction(tr("&Find in Output..."),
-                       this, SLOT(doOutputFindDialog()),
-                       QKeySequence::Find);
-  ToolsMenu->addAction(tr("Find Next"),
-                       this, SLOT(doOutputFindNext()),
+  ToolsMenu->addAction(tr("&Find in Output..."), this,
+                       SLOT(doOutputFindDialog()), QKeySequence::Find);
+  ToolsMenu->addAction(tr("Find Next"), this, SLOT(doOutputFindNext()),
                        QKeySequence::FindNext);
-  ToolsMenu->addAction(tr("Find Previous"),
-                       this, SLOT(doOutputFindPrev()),
+  ToolsMenu->addAction(tr("Find Previous"), this, SLOT(doOutputFindPrev()),
                        QKeySequence::FindPrevious);
-  ToolsMenu->addAction(tr("Goto Next Error"),
-                       this, SLOT(doOutputErrorNext()),
-                       QKeySequence(Qt::Key_F8));  // in Visual Studio
-  new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Period),
-                       this, SLOT(doOutputErrorNext()));  // in Eclipse
+  ToolsMenu->addAction(tr("Goto Next Error"), this, SLOT(doOutputErrorNext()),
+                       QKeySequence(Qt::Key_F8)); // in Visual Studio
+  new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Period), this,
+                SLOT(doOutputErrorNext())); // in Eclipse
 
   QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
-  OptionsMenu->addAction(tr("Warning Messages..."),
-                         this, SLOT(doWarningMessagesDialog()));
+  OptionsMenu->addAction(tr("Warning Messages..."), this,
+                         SLOT(doWarningMessagesDialog()));
   this->WarnUninitializedAction =
     OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)"));
   this->WarnUninitializedAction->setCheckable(true);
@@ -157,24 +160,24 @@ CMakeSetupDialog::CMakeSetupDialog()
 
   QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
   debugAction->setCheckable(true);
-  QObject::connect(debugAction, SIGNAL(toggled(bool)),
-                   this, SLOT(setDebugOutput(bool)));
+  QObject::connect(debugAction, SIGNAL(toggled(bool)), this,
+                   SLOT(setDebugOutput(bool)));
 
   OptionsMenu->addSeparator();
-  QAction* expandAction = OptionsMenu->addAction(tr("&Expand Grouped Entries"));
-  QObject::connect(expandAction, SIGNAL(triggered(bool)),
-                   this->CacheValues, SLOT(expandAll()));
-  QAction* collapseAction = OptionsMenu->addAction(tr("&Collapse Grouped Entries"));
-  QObject::connect(collapseAction, SIGNAL(triggered(bool)),
-                   this->CacheValues, SLOT(collapseAll()));
+  QAction* expandAction =
+    OptionsMenu->addAction(tr("&Expand Grouped Entries"));
+  QObject::connect(expandAction, SIGNAL(triggered(bool)), this->CacheValues,
+                   SLOT(expandAll()));
+  QAction* collapseAction =
+    OptionsMenu->addAction(tr("&Collapse Grouped Entries"));
+  QObject::connect(collapseAction, SIGNAL(triggered(bool)), this->CacheValues,
+                   SLOT(collapseAll()));
 
   QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
   QAction* a = HelpMenu->addAction(tr("About"));
-  QObject::connect(a, SIGNAL(triggered(bool)),
-                   this, SLOT(doAbout()));
+  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doAbout()));
   a = HelpMenu->addAction(tr("Help"));
-  QObject::connect(a, SIGNAL(triggered(bool)),
-                   this, SLOT(doHelp()));
+  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doHelp()));
 
   this->setAcceptDrops(true);
 
@@ -192,12 +195,12 @@ CMakeSetupDialog::CMakeSetupDialog()
 
   this->Output->setContextMenuPolicy(Qt::CustomContextMenu);
   connect(this->Output, SIGNAL(customContextMenuRequested(const QPoint&)),
-          this, SLOT(doOutputContextMenu(const QPoint &)));
+          this, SLOT(doOutputContextMenu(const QPoint&)));
 
   // start the cmake worker thread
   this->CMakeThread = new QCMakeThread(this);
-  QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()),
-                   this, SLOT(initialize()), Qt::QueuedConnection);
+  QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), this,
+                   SLOT(initialize()), Qt::QueuedConnection);
   this->CMakeThread->start();
 
   this->enterState(ReadyConfigure);
@@ -210,20 +213,20 @@ void CMakeSetupDialog::initialize()
 {
   // now the cmake worker thread is running, lets make our connections to it
   QObject::connect(this->CMakeThread->cmakeInstance(),
-      SIGNAL(propertiesChanged(const QCMakePropertyList&)),
-      this->CacheValues->cacheModel(),
-      SLOT(setProperties(const QCMakePropertyList&)));
+                   SIGNAL(propertiesChanged(const QCMakePropertyList&)),
+                   this->CacheValues->cacheModel(),
+                   SLOT(setProperties(const QCMakePropertyList&)));
 
-  QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)),
-                   this, SLOT(doConfigure()));
+  QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)), this,
+                   SLOT(doConfigure()));
 
-  QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(configureDone(int)),
-                   this, SLOT(exitLoop(int)));
-  QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(generateDone(int)),
-                   this, SLOT(exitLoop(int)));
+  QObject::connect(this->CMakeThread->cmakeInstance(),
+                   SIGNAL(configureDone(int)), this, SLOT(exitLoop(int)));
+  QObject::connect(this->CMakeThread->cmakeInstance(),
+                   SIGNAL(generateDone(int)), this, SLOT(exitLoop(int)));
 
-  QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)),
-                   this, SLOT(doGenerate()));
+  QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)), this,
+                   SLOT(doGenerate()));
 
   QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)),
                    this, SLOT(doSourceBrowse()));
@@ -232,51 +235,50 @@ void CMakeSetupDialog::initialize()
 
   QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)),
                    this, SLOT(onBinaryDirectoryChanged(QString)));
-  QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)),
-                   this, SLOT(onSourceDirectoryChanged(QString)));
+  QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)), this,
+                   SLOT(onSourceDirectoryChanged(QString)));
 
   QObject::connect(this->CMakeThread->cmakeInstance(),
-                   SIGNAL(sourceDirChanged(QString)),
-                   this, SLOT(updateSourceDirectory(QString)));
+                   SIGNAL(sourceDirChanged(QString)), this,
+                   SLOT(updateSourceDirectory(QString)));
   QObject::connect(this->CMakeThread->cmakeInstance(),
-                   SIGNAL(binaryDirChanged(QString)),
-                   this, SLOT(updateBinaryDirectory(QString)));
+                   SIGNAL(binaryDirChanged(QString)), this,
+                   SLOT(updateBinaryDirectory(QString)));
 
   QObject::connect(this->CMakeThread->cmakeInstance(),
-                   SIGNAL(progressChanged(QString, float)),
-                   this, SLOT(showProgress(QString,float)));
+                   SIGNAL(progressChanged(QString, float)), this,
+                   SLOT(showProgress(QString, float)));
 
   QObject::connect(this->CMakeThread->cmakeInstance(),
-                   SIGNAL(errorMessage(QString)),
-                   this, SLOT(error(QString)));
+                   SIGNAL(errorMessage(QString)), this, SLOT(error(QString)));
 
   QObject::connect(this->CMakeThread->cmakeInstance(),
-                   SIGNAL(outputMessage(QString)),
-                   this, SLOT(message(QString)));
+                   SIGNAL(outputMessage(QString)), this,
+                   SLOT(message(QString)));
 
-  QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)),
-                   this, SLOT(setGroupedView(bool)));
-  QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)),
-                   this, SLOT(setAdvancedView(bool)));
-  QObject::connect(this->Search, SIGNAL(textChanged(QString)),
-                   this, SLOT(setSearchFilter(QString)));
+  QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)), this,
+                   SLOT(setGroupedView(bool)));
+  QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)), this,
+                   SLOT(setAdvancedView(bool)));
+  QObject::connect(this->Search, SIGNAL(textChanged(QString)), this,
+                   SLOT(setSearchFilter(QString)));
 
   QObject::connect(this->CMakeThread->cmakeInstance(),
-                   SIGNAL(generatorChanged(QString)),
-                   this, SLOT(updateGeneratorLabel(QString)));
+                   SIGNAL(generatorChanged(QString)), this,
+                   SLOT(updateGeneratorLabel(QString)));
   this->updateGeneratorLabel(QString());
 
   QObject::connect(this->CacheValues->cacheModel(),
-                   SIGNAL(dataChanged(QModelIndex,QModelIndex)),
-                   this, SLOT(setCacheModified()));
+                   SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
+                   SLOT(setCacheModified()));
 
   QObject::connect(this->CacheValues->selectionModel(),
-                   SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+                   SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
                    this, SLOT(selectionChanged()));
-  QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)),
-                   this, SLOT(removeSelectedCacheEntries()));
-  QObject::connect(this->AddEntry, SIGNAL(clicked(bool)),
-                   this, SLOT(addCacheEntry()));
+  QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)), this,
+                   SLOT(removeSelectedCacheEntries()));
+  QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), this,
+                   SLOT(addCacheEntry()));
 
   QObject::connect(this->WarnUninitializedAction, SIGNAL(triggered(bool)),
                    this->CMakeThread->cmakeInstance(),
@@ -285,16 +287,13 @@ void CMakeSetupDialog::initialize()
                    this->CMakeThread->cmakeInstance(),
                    SLOT(setWarnUnusedMode(bool)));
 
-  if(!this->SourceDirectory->text().isEmpty() ||
-     !this->BinaryDirectory->lineEdit()->text().isEmpty())
-    {
+  if (!this->SourceDirectory->text().isEmpty() ||
+      !this->BinaryDirectory->lineEdit()->text().isEmpty()) {
     this->onSourceDirectoryChanged(this->SourceDirectory->text());
     this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
-    }
-  else
-    {
+  } else {
     this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
-    }
+  }
 }
 
 CMakeSetupDialog::~CMakeSetupDialog()
@@ -315,38 +314,34 @@ bool CMakeSetupDialog::prepareConfigure()
   // make sure build directory exists
   QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
   QDir dir(bindir);
-  if(!dir.exists())
-    {
+  if (!dir.exists()) {
     QString msg = tr("Build directory does not exist, "
-                         "should I create it?\n\n"
-                      "Directory: ");
+                     "should I create it?\n\n"
+                     "Directory: ");
     msg += bindir;
     QString title = tr("Create Directory");
     QMessageBox::StandardButton btn;
     btn = QMessageBox::information(this, title, msg,
                                    QMessageBox::Yes | QMessageBox::No);
-    if(btn == QMessageBox::No)
-      {
+    if (btn == QMessageBox::No) {
       return false;
-      }
-    if(!dir.mkpath("."))
-      {
-      QMessageBox::information(this, tr("Create Directory Failed"),
+    }
+    if (!dir.mkpath(".")) {
+      QMessageBox::information(
+        this, tr("Create Directory Failed"),
         QString(tr("Failed to create directory %1")).arg(dir.path()),
         QMessageBox::Ok);
 
       return false;
-      }
     }
+  }
 
   // if no generator, prompt for it and other setup stuff
-  if(this->CMakeThread->cmakeInstance()->generator().isEmpty())
-    {
-    if(!this->setupFirstConfigure())
-      {
+  if (this->CMakeThread->cmakeInstance()->generator().isEmpty()) {
+    if (!this->setupFirstConfigure()) {
       return false;
-      }
     }
+  }
 
   // remember path
   this->addBinaryPath(dir.absolutePath());
@@ -361,36 +356,30 @@ void CMakeSetupDialog::exitLoop(int err)
 
 void CMakeSetupDialog::doConfigure()
 {
-  if(this->CurrentState == Configuring)
-    {
+  if (this->CurrentState == Configuring) {
     // stop configure
     doInterrupt();
     return;
-    }
+  }
 
-  if(!prepareConfigure())
-    {
+  if (!prepareConfigure()) {
     return;
-    }
+  }
 
   this->enterState(Configuring);
 
   bool ret = doConfigureInternal();
 
-  if(ret)
-    {
+  if (ret) {
     this->ConfigureNeeded = false;
-    }
+  }
 
-  if(ret && !this->CacheValues->cacheModel()->newPropertyCount())
-    {
+  if (ret && !this->CacheValues->cacheModel()->newPropertyCount()) {
     this->enterState(ReadyGenerate);
-    }
-  else
-    {
+  } else {
     this->enterState(ReadyConfigure);
     this->CacheValues->scrollToTop();
-    }
+  }
   this->ProgressBar->reset();
 }
 
@@ -399,21 +388,20 @@ bool CMakeSetupDialog::doConfigureInternal()
   this->Output->clear();
   this->CacheValues->selectionModel()->clear();
 
-  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "setProperties", Qt::QueuedConnection,
-    Q_ARG(QCMakePropertyList,
-      this->CacheValues->cacheModel()->properties()));
-  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "configure", Qt::QueuedConnection);
+  QMetaObject::invokeMethod(
+    this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection,
+    Q_ARG(QCMakePropertyList, this->CacheValues->cacheModel()->properties()));
+  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "configure",
+                            Qt::QueuedConnection);
 
   int err = this->LocalLoop.exec();
 
-  if(err != 0)
-    {
-    QMessageBox::critical(this, tr("Error"),
+  if (err != 0) {
+    QMessageBox::critical(
+      this, tr("Error"),
       tr("Error in configuration process, project files may be invalid"),
       QMessageBox::Ok);
-    }
+  }
 
   return 0 == err;
 }
@@ -421,21 +409,19 @@ bool CMakeSetupDialog::doConfigureInternal()
 void CMakeSetupDialog::doInstallForCommandLine()
 {
   QString title = tr("How to Install For Command Line Use");
-  QString msg = tr(
-    "One may add CMake to the PATH:\n"
-    "\n"
-    " PATH=\"%1\":\"$PATH\"\n"
-    "\n"
-    "Or, to install symlinks to '/usr/local/bin', run:\n"
-    "\n"
-    " sudo \"%2\" --install\n"
-    "\n"
-    "Or, to install symlinks to another directory, run:\n"
-    "\n"
-    " sudo \"%3\" --install=/path/to/bin\n"
-    );
-  msg = msg.arg(cmSystemTools::GetFilenamePath(
-                  cmSystemTools::GetCMakeCommand()).c_str());
+  QString msg = tr("One may add CMake to the PATH:\n"
+                   "\n"
+                   " PATH=\"%1\":\"$PATH\"\n"
+                   "\n"
+                   "Or, to install symlinks to '/usr/local/bin', run:\n"
+                   "\n"
+                   " sudo \"%2\" --install\n"
+                   "\n"
+                   "Or, to install symlinks to another directory, run:\n"
+                   "\n"
+                   " sudo \"%3\" --install=/path/to/bin\n");
+  msg = msg.arg(
+    cmSystemTools::GetFilenamePath(cmSystemTools::GetCMakeCommand()).c_str());
   msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str());
   msg = msg.arg(cmSystemTools::GetCMakeGUICommand().c_str());
 
@@ -447,8 +433,8 @@ void CMakeSetupDialog::doInstallForCommandLine()
   lab->setText(msg);
   lab->setWordWrap(false);
   lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
-  QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
-                                                Qt::Horizontal, &dialog);
+  QDialogButtonBox* btns =
+    new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
   l->addWidget(btns);
   dialog.exec();
@@ -456,57 +442,52 @@ void CMakeSetupDialog::doInstallForCommandLine()
 
 bool CMakeSetupDialog::doGenerateInternal()
 {
-  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "generate", Qt::QueuedConnection);
+  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "generate",
+                            Qt::QueuedConnection);
 
   int err = this->LocalLoop.exec();
 
-  if(err != 0)
-    {
-    QMessageBox::critical(this, tr("Error"),
+  if (err != 0) {
+    QMessageBox::critical(
+      this, tr("Error"),
       tr("Error in generation process, project files may be invalid"),
       QMessageBox::Ok);
-    }
+  }
 
   return 0 == err;
 }
 
 void CMakeSetupDialog::doGenerate()
 {
-  if(this->CurrentState == Generating)
-    {
+  if (this->CurrentState == Generating) {
     // stop generate
     doInterrupt();
     return;
-    }
+  }
 
   // see if we need to configure
   // we'll need to configure if:
   //   the configure step hasn't been done yet
   //   generate was the last step done
-  if(this->ConfigureNeeded)
-    {
-    if(!prepareConfigure())
-      {
+  if (this->ConfigureNeeded) {
+    if (!prepareConfigure()) {
       return;
-      }
     }
+  }
 
   this->enterState(Generating);
 
   bool config_passed = true;
-  if(this->ConfigureNeeded)
-    {
+  if (this->ConfigureNeeded) {
     this->CacheValues->cacheModel()->setShowNewProperties(false);
     this->ProgressFactor = 0.5;
     config_passed = doConfigureInternal();
     this->ProgressOffset = 0.5;
-    }
+  }
 
-  if(config_passed)
-    {
+  if (config_passed) {
     doGenerateInternal();
-    }
+  }
 
   this->ProgressOffset = 0.0;
   this->ProgressFactor = 1.0;
@@ -521,78 +502,83 @@ void CMakeSetupDialog::doGenerate()
 void CMakeSetupDialog::closeEvent(QCloseEvent* e)
 {
   // prompt for close if there are unsaved changes, and we're not busy
-  if(this->CacheModified)
-    {
+  if (this->CacheModified) {
     QString msg = tr("You have changed options but not rebuilt, "
-                    "are you sure you want to exit?");
+                     "are you sure you want to exit?");
     QString title = tr("Confirm Exit");
     QMessageBox::StandardButton btn;
     btn = QMessageBox::critical(this, title, msg,
                                 QMessageBox::Yes | QMessageBox::No);
-    if(btn == QMessageBox::No)
-      {
+    if (btn == QMessageBox::No) {
       e->ignore();
-      }
     }
+  }
 
   // don't close if we're busy, unless the user really wants to
-  if(this->CurrentState == Configuring)
-    {
-    QString msg = tr("You are in the middle of a Configure.\n"
-                   "If you Exit now the configure information will be lost.\n"
-                   "Are you sure you want to Exit?");
+  if (this->CurrentState == Configuring) {
+    QString msg =
+      tr("You are in the middle of a Configure.\n"
+         "If you Exit now the configure information will be lost.\n"
+         "Are you sure you want to Exit?");
     QString title = tr("Confirm Exit");
     QMessageBox::StandardButton btn;
     btn = QMessageBox::critical(this, title, msg,
                                 QMessageBox::Yes | QMessageBox::No);
-    if(btn == QMessageBox::No)
-      {
+    if (btn == QMessageBox::No) {
       e->ignore();
-      }
-    else
-      {
+    } else {
       this->doInterrupt();
-      }
     }
+  }
 
   // let the generate finish
-  if(this->CurrentState == Generating)
-    {
+  if (this->CurrentState == Generating) {
     e->ignore();
-    }
+  }
 }
 
 void CMakeSetupDialog::doHelp()
 {
-  QString msg = tr("CMake is used to configure and generate build files for "
+  QString msg = tr(
+    "CMake is used to configure and generate build files for "
     "software projects.   The basic steps for configuring a project are as "
-    "follows:\r\n\r\n1. Select the source directory for the project.  This should "
-    "contain the CMakeLists.txt files for the project.\r\n\r\n2. Select the build "
-    "directory for the project.   This is the directory where the project will be "
+    "follows:\r\n\r\n1. Select the source directory for the project.  This "
+    "should "
+    "contain the CMakeLists.txt files for the project.\r\n\r\n2. Select the "
+    "build "
+    "directory for the project.   This is the directory where the project "
+    "will be "
     "built.  It can be the same or a different directory than the source "
-    "directory.   For easy clean up, a separate build directory is recommended. "
+    "directory.   For easy clean up, a separate build directory is "
+    "recommended. "
     "CMake will create the directory if it does not exist.\r\n\r\n3. Once the "
     "source and binary directories are selected, it is time to press the "
-    "Configure button.  This will cause CMake to read all of the input files and "
-    "discover all the variables used by the project.   The first time a variable "
-    "is displayed it will be in Red.   Users should inspect red variables making "
-    "sure the values are correct.   For some projects the Configure process can "
-    "be iterative, so continue to press the Configure button until there are no "
+    "Configure button.  This will cause CMake to read all of the input files "
+    "and "
+    "discover all the variables used by the project.   The first time a "
+    "variable "
+    "is displayed it will be in Red.   Users should inspect red variables "
+    "making "
+    "sure the values are correct.   For some projects the Configure process "
+    "can "
+    "be iterative, so continue to press the Configure button until there are "
+    "no "
     "longer red entries.\r\n\r\n4. Once there are no longer red entries, you "
-    "should click the Generate button.  This will write the build files to the build "
+    "should click the Generate button.  This will write the build files to "
+    "the build "
     "directory.");
 
   QDialog dialog;
   QFontMetrics met(this->font());
   int msgWidth = met.width(msg);
-  dialog.setMinimumSize(msgWidth/15,20);
+  dialog.setMinimumSize(msgWidth / 15, 20);
   dialog.setWindowTitle(tr("Help"));
   QVBoxLayout* l = new QVBoxLayout(&dialog);
   QLabel* lab = new QLabel(&dialog);
   lab->setText(msg);
   lab->setWordWrap(true);
-  QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
-                                                Qt::Horizontal, &dialog);
+  QDialogButtonBox* btns =
+    new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
   l->addWidget(lab);
   l->addWidget(btns);
@@ -607,44 +593,40 @@ void CMakeSetupDialog::doInterrupt()
 
 void CMakeSetupDialog::doSourceBrowse()
 {
-  QString dir = QFileDialog::getExistingDirectory(this,
-    tr("Enter Path to Source"), this->SourceDirectory->text(),
+  QString dir = QFileDialog::getExistingDirectory(
+    this, tr("Enter Path to Source"), this->SourceDirectory->text(),
     QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
-  if(!dir.isEmpty())
-    {
+  if (!dir.isEmpty()) {
     this->setSourceDirectory(dir);
-    }
+  }
 }
 
 void CMakeSetupDialog::updateSourceDirectory(const QString& dir)
 {
-  if(this->SourceDirectory->text() != dir)
-    {
+  if (this->SourceDirectory->text() != dir) {
     this->SourceDirectory->blockSignals(true);
     this->SourceDirectory->setText(dir);
     this->SourceDirectory->blockSignals(false);
-    }
+  }
 }
 
 void CMakeSetupDialog::updateBinaryDirectory(const QString& dir)
 {
-  if(this->BinaryDirectory->currentText() != dir)
-    {
+  if (this->BinaryDirectory->currentText() != dir) {
     this->BinaryDirectory->blockSignals(true);
     this->BinaryDirectory->setEditText(dir);
     this->BinaryDirectory->blockSignals(false);
-    }
+  }
 }
 
 void CMakeSetupDialog::doBinaryBrowse()
 {
-  QString dir = QFileDialog::getExistingDirectory(this,
-    tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
+  QString dir = QFileDialog::getExistingDirectory(
+    this, tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
     QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
-  if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText())
-    {
+  if (!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) {
     this->setBinaryDirectory(dir);
-    }
+  }
 }
 
 void CMakeSetupDialog::setBinaryDirectory(const QString& dir)
@@ -656,7 +638,8 @@ void CMakeSetupDialog::onSourceDirectoryChanged(const QString& dir)
 {
   this->Output->clear();
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "setSourceDirectory", Qt::QueuedConnection, Q_ARG(QString, dir));
+                            "setSourceDirectory", Qt::QueuedConnection,
+                            Q_ARG(QString, dir));
 }
 
 void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir)
@@ -668,10 +651,12 @@ void CMakeSetupDialog::onBinaryDirectoryChanged(const QString& dir)
 
   this->CacheModified = false;
   this->CacheValues->cacheModel()->clear();
-  qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())->clearChanges();
+  qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())
+    ->clearChanges();
   this->Output->clear();
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "setBinaryDirectory", Qt::QueuedConnection, Q_ARG(QString, dir));
+                            "setBinaryDirectory", Qt::QueuedConnection,
+                            Q_ARG(QString, dir));
 }
 
 void CMakeSetupDialog::setSourceDirectory(const QString& dir)
@@ -688,13 +673,14 @@ void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent)
 void CMakeSetupDialog::error(const QString& msg)
 {
   this->Output->setCurrentCharFormat(this->ErrorFormat);
-  //QTextEdit will terminate the msg with a ParagraphSeparator, but it also replaces
-  //all newlines with ParagraphSeparators. By replacing the newlines by ourself, one
-  //error msg will be one paragraph.
+  // QTextEdit will terminate the msg with a ParagraphSeparator, but it also
+  // replaces
+  // all newlines with ParagraphSeparators. By replacing the newlines by
+  // ourself, one
+  // error msg will be one paragraph.
   QString paragraph(msg);
   paragraph.replace(QLatin1Char('\n'), QChar::LineSeparator);
   this->Output->append(paragraph);
-
 }
 
 void CMakeSetupDialog::message(const QString& msg)
@@ -716,7 +702,7 @@ void CMakeSetupDialog::setEnabledState(bool enabled)
   this->ExitAction->setEnabled(enabled);
   this->ConfigureAction->setEnabled(enabled);
   this->AddEntry->setEnabled(enabled);
-  this->RemoveEntry->setEnabled(false);  // let selection re-enable it
+  this->RemoveEntry->setEnabled(false); // let selection re-enable it
 }
 
 bool CMakeSetupDialog::setupFirstConfigure()
@@ -726,58 +712,54 @@ bool CMakeSetupDialog::setupFirstConfigure()
   // initialize dialog and restore saved settings
 
   // add generators
-  dialog.setGenerators(this->CMakeThread->cmakeInstance()->availableGenerators());
+  dialog.setGenerators(
+    this->CMakeThread->cmakeInstance()->availableGenerators());
 
   // restore from settings
   dialog.loadFromSettings();
 
-  if(dialog.exec() == QDialog::Accepted)
-    {
+  if (dialog.exec() == QDialog::Accepted) {
     dialog.saveToSettings();
     this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
     this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset());
 
     QCMakeCacheModel* m = this->CacheValues->cacheModel();
 
-    if(dialog.compilerSetup())
-      {
+    if (dialog.compilerSetup()) {
       QString fortranCompiler = dialog.getFortranCompiler();
-      if(!fortranCompiler.isEmpty())
-        {
+      if (!fortranCompiler.isEmpty()) {
         m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
                           "Fortran compiler.", fortranCompiler, false);
-        }
+      }
       QString cxxCompiler = dialog.getCXXCompiler();
-      if(!cxxCompiler.isEmpty())
-        {
+      if (!cxxCompiler.isEmpty()) {
         m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
                           "CXX compiler.", cxxCompiler, false);
-        }
+      }
 
       QString cCompiler = dialog.getCCompiler();
-      if(!cCompiler.isEmpty())
-        {
+      if (!cCompiler.isEmpty()) {
         m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
                           "C compiler.", cCompiler, false);
-        }
       }
-    else if(dialog.crossCompilerSetup())
-      {
+    } else if (dialog.crossCompilerSetup()) {
       QString fortranCompiler = dialog.getFortranCompiler();
-      if(!fortranCompiler.isEmpty())
-        {
+      if (!fortranCompiler.isEmpty()) {
         m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
                           "Fortran compiler.", fortranCompiler, false);
-        }
+      }
 
       QString mode = dialog.getCrossIncludeMode();
-      m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
+      m->insertProperty(QCMakeProperty::STRING,
+                        "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
                         tr("CMake Find Include Mode"), mode, false);
       mode = dialog.getCrossLibraryMode();
-      m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
+      m->insertProperty(QCMakeProperty::STRING,
+                        "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
                         tr("CMake Find Library Mode"), mode, false);
       mode = dialog.getCrossProgramMode();
-      m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
+      m->insertProperty(QCMakeProperty::STRING,
+                        "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
                         tr("CMake Find Program Mode"), mode, false);
 
       QString rootPath = dialog.getCrossRoot();
@@ -796,15 +778,14 @@ bool CMakeSetupDialog::setupFirstConfigure()
       QString cCompiler = dialog.getCCompiler();
       m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
                         tr("C compiler."), cCompiler, false);
-      }
-    else if(dialog.crossCompilerToolChainFile())
-      {
+    } else if (dialog.crossCompilerToolChainFile()) {
       QString toolchainFile = dialog.getCrossCompilerToolChainFile();
       m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE",
-                        tr("Cross Compile ToolChain File"), toolchainFile, false);
-      }
-    return true;
+                        tr("Cross Compile ToolChain File"), toolchainFile,
+                        false);
     }
+    return true;
+  }
 
   return false;
 }
@@ -812,21 +793,18 @@ bool CMakeSetupDialog::setupFirstConfigure()
 void CMakeSetupDialog::updateGeneratorLabel(const QString& gen)
 {
   QString str = tr("Current Generator: ");
-  if(gen.isEmpty())
-    {
+  if (gen.isEmpty()) {
     str += tr("None");
-    }
-  else
-    {
+  } else {
     str += gen;
-    }
+  }
   this->Generator->setText(str);
 }
 
 void CMakeSetupDialog::doReloadCache()
 {
-  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "reloadCache", Qt::QueuedConnection);
+  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "reloadCache",
+                            Qt::QueuedConnection);
 }
 
 void CMakeSetupDialog::doDeleteCache()
@@ -836,12 +814,11 @@ void CMakeSetupDialog::doDeleteCache()
   QMessageBox::StandardButton btn;
   btn = QMessageBox::information(this, title, msg,
                                  QMessageBox::Yes | QMessageBox::No);
-  if(btn == QMessageBox::No)
-    {
+  if (btn == QMessageBox::No) {
     return;
-    }
-  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-                            "deleteCache", Qt::QueuedConnection);
+  }
+  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "deleteCache",
+                            Qt::QueuedConnection);
 }
 
 void CMakeSetupDialog::doAbout()
@@ -863,7 +840,7 @@ void CMakeSetupDialog::doAbout()
   msg = msg.arg(cmVersion::GetCMakeVersion());
   msg = msg.arg(qVersion());
 #ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL
-  std::string lgpl = cmSystemTools::GetCMakeRoot()+"/Licenses/LGPLv2.1.txt";
+  std::string lgpl = cmSystemTools::GetCMakeRoot() + "/Licenses/LGPLv2.1.txt";
   msg = msg.arg(lgpl.c_str());
 #endif
 
@@ -874,8 +851,8 @@ void CMakeSetupDialog::doAbout()
   l->addWidget(lab);
   lab->setText(msg);
   lab->setWordWrap(true);
-  QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok,
-                                                Qt::Horizontal, &dialog);
+  QDialogButtonBox* btns =
+    new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
   l->addWidget(btns);
   dialog.exec();
@@ -893,10 +870,9 @@ void CMakeSetupDialog::addBinaryPath(const QString& path)
   // update UI
   this->BinaryDirectory->blockSignals(true);
   int idx = this->BinaryDirectory->findText(cleanpath);
-  if(idx != -1)
-    {
+  if (idx != -1) {
     this->BinaryDirectory->removeItem(idx);
-    }
+  }
   this->BinaryDirectory->insertItem(0, cleanpath);
   this->BinaryDirectory->setCurrentIndex(0);
   this->BinaryDirectory->blockSignals(false);
@@ -910,56 +886,48 @@ void CMakeSetupDialog::addBinaryPath(const QString& path)
 
 void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e)
 {
-  if(!(this->CurrentState == ReadyConfigure ||
-     this->CurrentState == ReadyGenerate))
-    {
+  if (!(this->CurrentState == ReadyConfigure ||
+        this->CurrentState == ReadyGenerate)) {
     e->ignore();
     return;
-    }
+  }
 
   const QMimeData* dat = e->mimeData();
   QList<QUrl> urls = dat->urls();
   QString file = urls.count() ? urls[0].toLocalFile() : QString();
-  if(!file.isEmpty() &&
-    (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) ||
-    file.endsWith("CMakeLists.txt", Qt::CaseInsensitive) ) )
-    {
+  if (!file.isEmpty() &&
+      (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) ||
+       file.endsWith("CMakeLists.txt", Qt::CaseInsensitive))) {
     e->accept();
-    }
-  else
-    {
+  } else {
     e->ignore();
-    }
+  }
 }
 
 void CMakeSetupDialog::dropEvent(QDropEvent* e)
 {
-  if(!(this->CurrentState == ReadyConfigure ||
-     this->CurrentState == ReadyGenerate))
-    {
+  if (!(this->CurrentState == ReadyConfigure ||
+        this->CurrentState == ReadyGenerate)) {
     return;
-    }
+  }
 
   const QMimeData* dat = e->mimeData();
   QList<QUrl> urls = dat->urls();
   QString file = urls.count() ? urls[0].toLocalFile() : QString();
-  if(file.endsWith("CMakeCache.txt", Qt::CaseInsensitive))
-    {
+  if (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive)) {
     QFileInfo info(file);
-    if(this->CMakeThread->cmakeInstance()->binaryDirectory() != info.absolutePath())
-      {
+    if (this->CMakeThread->cmakeInstance()->binaryDirectory() !=
+        info.absolutePath()) {
       this->setBinaryDirectory(info.absolutePath());
-      }
     }
-  else if(file.endsWith("CMakeLists.txt", Qt::CaseInsensitive))
-    {
+  } else if (file.endsWith("CMakeLists.txt", Qt::CaseInsensitive)) {
     QFileInfo info(file);
-    if(this->CMakeThread->cmakeInstance()->binaryDirectory() != info.absolutePath())
-      {
+    if (this->CMakeThread->cmakeInstance()->binaryDirectory() !=
+        info.absolutePath()) {
       this->setSourceDirectory(info.absolutePath());
       this->setBinaryDirectory(info.absolutePath());
-      }
     }
+  }
 }
 
 QStringList CMakeSetupDialog::loadBuildPaths()
@@ -968,14 +936,12 @@ QStringList CMakeSetupDialog::loadBuildPaths()
   settings.beginGroup("Settings/StartPath");
 
   QStringList buildPaths;
-  for(int i=0; i<10; i++)
-    {
-      QString p = settings.value(QString("WhereBuild%1").arg(i)).toString();
-      if(!p.isEmpty())
-        {
-        buildPaths.append(p);
-        }
+  for (int i = 0; i < 10; i++) {
+    QString p = settings.value(QString("WhereBuild%1").arg(i)).toString();
+    if (!p.isEmpty()) {
+      buildPaths.append(p);
     }
+  }
   return buildPaths;
 }
 
@@ -985,15 +951,13 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths)
   settings.beginGroup("Settings/StartPath");
 
   int num = paths.count();
-  if(num > 10)
-    {
+  if (num > 10) {
     num = 10;
-    }
+  }
 
-  for(int i=0; i<num; i++)
-    {
+  for (int i = 0; i < num; i++) {
     settings.setValue(QString("WhereBuild%1").arg(i), paths[i]);
-    }
+  }
 }
 
 void CMakeSetupDialog::setCacheModified()
@@ -1007,78 +971,62 @@ void CMakeSetupDialog::removeSelectedCacheEntries()
 {
   QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
   QList<QPersistentModelIndex> pidxs;
-  foreach(QModelIndex i, idxs)
-    {
+  foreach (QModelIndex i, idxs) {
     pidxs.append(i);
-    }
-  foreach(QPersistentModelIndex pi, pidxs)
-    {
+  }
+  foreach (QPersistentModelIndex pi, pidxs) {
     this->CacheValues->model()->removeRow(pi.row(), pi.parent());
-    }
+  }
 }
 
 void CMakeSetupDialog::selectionChanged()
 {
   QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
-  if(idxs.count() &&
-      (this->CurrentState == ReadyConfigure ||
-       this->CurrentState == ReadyGenerate) )
-    {
+  if (idxs.count() && (this->CurrentState == ReadyConfigure ||
+                       this->CurrentState == ReadyGenerate)) {
     this->RemoveEntry->setEnabled(true);
-    }
-  else
-    {
+  } else {
     this->RemoveEntry->setEnabled(false);
-    }
+  }
 }
 
 void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
 {
-  if(s == this->CurrentState)
-    {
+  if (s == this->CurrentState) {
     return;
-    }
+  }
 
   this->CurrentState = s;
 
-  if(s == Interrupting)
-    {
+  if (s == Interrupting) {
     this->ConfigureButton->setEnabled(false);
     this->GenerateButton->setEnabled(false);
-    }
-  else if(s == Configuring)
-    {
+  } else if (s == Configuring) {
     this->setEnabledState(false);
     this->GenerateButton->setEnabled(false);
     this->GenerateAction->setEnabled(false);
     this->ConfigureButton->setText(tr("&Stop"));
-    }
-  else if(s == Generating)
-    {
+  } else if (s == Generating) {
     this->CacheModified = false;
     this->setEnabledState(false);
     this->ConfigureButton->setEnabled(false);
     this->GenerateAction->setEnabled(false);
     this->GenerateButton->setText(tr("&Stop"));
-    }
-  else if(s == ReadyConfigure)
-    {
+  } else if (s == ReadyConfigure) {
     this->setEnabledState(true);
     this->GenerateButton->setEnabled(true);
     this->GenerateAction->setEnabled(true);
     this->ConfigureButton->setEnabled(true);
     this->ConfigureButton->setText(tr("&Configure"));
     this->GenerateButton->setText(tr("&Generate"));
-    }
-  else if(s == ReadyGenerate)
-    {
+  } else if (s == ReadyGenerate) {
     this->setEnabledState(true);
     this->GenerateButton->setEnabled(true);
     this->GenerateAction->setEnabled(true);
     this->ConfigureButton->setEnabled(true);
     this->ConfigureButton->setText(tr("&Configure"));
     this->GenerateButton->setText(tr("&Generate"));
-    }
+  }
 }
 
 void CMakeSetupDialog::addCacheEntry()
@@ -1087,44 +1035,40 @@ void CMakeSetupDialog::addCacheEntry()
   dialog.resize(400, 200);
   dialog.setWindowTitle(tr("Add Cache Entry"));
   QVBoxLayout* l = new QVBoxLayout(&dialog);
-  AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableNames,
-                                                this->AddVariableTypes);
+  AddCacheEntry* w =
+    new AddCacheEntry(&dialog, this->AddVariableNames, this->AddVariableTypes);
   QDialogButtonBox* btns = new QDialogButtonBox(
-      QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
-      Qt::Horizontal, &dialog);
+    QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
   QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject()));
   l->addWidget(w);
   l->addStretch();
   l->addWidget(btns);
-  if(QDialog::Accepted == dialog.exec())
-    {
+  if (QDialog::Accepted == dialog.exec()) {
     QCMakeCacheModel* m = this->CacheValues->cacheModel();
-    m->insertProperty(w->type(), w->name(), w->description(), w->value(), false);
+    m->insertProperty(w->type(), w->name(), w->description(), w->value(),
+                      false);
 
     // only add variable names to the completion which are new
-    if (!this->AddVariableNames.contains(w->name()))
-      {
+    if (!this->AddVariableNames.contains(w->name())) {
       this->AddVariableNames << w->name();
       this->AddVariableTypes << w->typeString();
       // limit to at most 100 completion items
-      if (this->AddVariableNames.size() > 100)
-        {
+      if (this->AddVariableNames.size() > 100) {
         this->AddVariableNames.removeFirst();
         this->AddVariableTypes.removeFirst();
-        }
+      }
       // make sure CMAKE_INSTALL_PREFIX is always there
-      if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX"))
-        {
+      if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX")) {
         this->AddVariableNames << "CMAKE_INSTALL_PREFIX";
         this->AddVariableTypes << "PATH";
-        }
+      }
       QSettings settings;
       settings.beginGroup("Settings/StartPath");
       settings.setValue("AddVariableNames", this->AddVariableNames);
       settings.setValue("AddVariableTypes", this->AddVariableTypes);
-      }
     }
+  }
 }
 
 void CMakeSetupDialog::startSearch()
@@ -1136,18 +1080,19 @@ void CMakeSetupDialog::startSearch()
 void CMakeSetupDialog::setDebugOutput(bool flag)
 {
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "setDebugOutput", Qt::QueuedConnection, Q_ARG(bool, flag));
+                            "setDebugOutput", Qt::QueuedConnection,
+                            Q_ARG(bool, flag));
 }
 
 void CMakeSetupDialog::setGroupedView(bool v)
 {
-  this->CacheValues->cacheModel()->setViewType(v ? QCMakeCacheModel::GroupView : QCMakeCacheModel::FlatView);
+  this->CacheValues->cacheModel()->setViewType(v ? QCMakeCacheModel::GroupView
+                                                 : QCMakeCacheModel::FlatView);
   this->CacheValues->setRootIsDecorated(v);
 
   QSettings settings;
   settings.beginGroup("Settings/StartPath");
   settings.setValue("GroupView", v);
-
 }
 
 void CMakeSetupDialog::setAdvancedView(bool v)
@@ -1161,7 +1106,8 @@ void CMakeSetupDialog::setAdvancedView(bool v)
 void CMakeSetupDialog::showUserChanges()
 {
   QSet<QCMakeProperty> changes =
-    qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())->changes();
+    qobject_cast<QCMakeCacheModelDelegate*>(this->CacheValues->itemDelegate())
+      ->changes();
 
   QDialog dialog(this);
   dialog.setWindowTitle(tr("My Changes"));
@@ -1170,19 +1116,17 @@ void CMakeSetupDialog::showUserChanges()
   QTextEdit* textedit = new QTextEdit(&dialog);
   textedit->setReadOnly(true);
   l->addWidget(textedit);
-  QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Close,
-                                                Qt::Horizontal, &dialog);
+  QDialogButtonBox* btns =
+    new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(accept()));
   l->addWidget(btns);
 
   QString command;
   QString cache;
 
-  foreach(QCMakeProperty prop, changes)
-    {
+  foreach (QCMakeProperty prop, changes) {
     QString type;
-    switch(prop.Type)
-      {
+    switch (prop.Type) {
       case QCMakeProperty::BOOL:
         type = "BOOL";
         break;
@@ -1195,16 +1139,13 @@ void CMakeSetupDialog::showUserChanges()
       case QCMakeProperty::STRING:
         type = "STRING";
         break;
-      }
+    }
     QString value;
-    if(prop.Type == QCMakeProperty::BOOL)
-      {
+    if (prop.Type == QCMakeProperty::BOOL) {
       value = prop.Value.toBool() ? "1" : "0";
-      }
-    else
-      {
+    } else {
       value = prop.Value.toString();
-      }
+    }
 
     QString line("%1:%2=");
     line = line.arg(prop.Key);
@@ -1212,7 +1153,7 @@ void CMakeSetupDialog::showUserChanges()
 
     command += QString("-D%1\"%2\" ").arg(line).arg(value);
     cache += QString("%1%2\n").arg(line).arg(value);
-    }
+  }
 
   textedit->append(tr("Commandline options:"));
   textedit->append(command);
@@ -1229,20 +1170,20 @@ void CMakeSetupDialog::setSearchFilter(const QString& str)
   this->CacheValues->setSearchFilter(str);
 }
 
-void CMakeSetupDialog::doOutputContextMenu(const QPoint &pt)
+void CMakeSetupDialog::doOutputContextMenu(const QPoint& pt)
 {
-  QMenu *menu = this->Output->createStandardContextMenu();
+  QMenu* menu = this->Output->createStandardContextMenu();
 
   menu->addSeparator();
-  menu->addAction(tr("Find..."),
-                  this, SLOT(doOutputFindDialog()), QKeySequence::Find);
-  menu->addAction(tr("Find Next"),
-                  this, SLOT(doOutputFindNext()), QKeySequence::FindNext);
-  menu->addAction(tr("Find Previous"),
-                  this, SLOT(doOutputFindPrev()), QKeySequence::FindPrevious);
+  menu->addAction(tr("Find..."), this, SLOT(doOutputFindDialog()),
+                  QKeySequence::Find);
+  menu->addAction(tr("Find Next"), this, SLOT(doOutputFindNext()),
+                  QKeySequence::FindNext);
+  menu->addAction(tr("Find Previous"), this, SLOT(doOutputFindPrev()),
+                  QKeySequence::FindPrevious);
   menu->addSeparator();
-  menu->addAction(tr("Goto Next Error"),
-                  this, SLOT(doOutputErrorNext()), QKeySequence(Qt::Key_F8));
+  menu->addAction(tr("Goto Next Error"), this, SLOT(doOutputErrorNext()),
+                  QKeySequence(Qt::Key_F8));
 
   menu->exec(this->Output->mapToGlobal(pt));
   delete menu;
@@ -1253,24 +1194,20 @@ void CMakeSetupDialog::doOutputFindDialog()
   QStringList strings(this->FindHistory);
 
   QString selection = this->Output->textCursor().selectedText();
-  if (!selection.isEmpty() &&
-      !selection.contains(QChar::ParagraphSeparator) &&
-      !selection.contains(QChar::LineSeparator))
-    {
+  if (!selection.isEmpty() && !selection.contains(QChar::ParagraphSeparator) &&
+      !selection.contains(QChar::LineSeparator)) {
     strings.push_front(selection);
-    }
+  }
 
   bool ok;
   QString search = QInputDialog::getItem(this, tr("Find in Output"),
                                          tr("Find:"), strings, 0, true, &ok);
-  if (ok && !search.isEmpty())
-    {
-    if (!this->FindHistory.contains(search))
-      {
+  if (ok && !search.isEmpty()) {
+    if (!this->FindHistory.contains(search)) {
       this->FindHistory.push_front(search);
-      }
-    doOutputFindNext();
     }
+    doOutputFindNext();
+  }
 }
 
 void CMakeSetupDialog::doRegexExplorerDialog()
@@ -1286,37 +1223,33 @@ void CMakeSetupDialog::doOutputFindPrev()
 
 void CMakeSetupDialog::doOutputFindNext(bool directionForward)
 {
-  if (this->FindHistory.isEmpty())
-    {
-    doOutputFindDialog(); //will re-call this function again
+  if (this->FindHistory.isEmpty()) {
+    doOutputFindDialog(); // will re-call this function again
     return;
-    }
+  }
 
   QString search = this->FindHistory.front();
 
   QTextCursor textCursor = this->Output->textCursor();
   QTextDocument* document = this->Output->document();
   QTextDocument::FindFlags flags;
-  if (!directionForward)
-    {
+  if (!directionForward) {
     flags |= QTextDocument::FindBackward;
-    }
+  }
 
   textCursor = document->find(search, textCursor, flags);
 
-  if (textCursor.isNull())
-    {
+  if (textCursor.isNull()) {
     // first search found nothing, wrap around and search again
     textCursor = this->Output->textCursor();
     textCursor.movePosition(directionForward ? QTextCursor::Start
                                              : QTextCursor::End);
     textCursor = document->find(search, textCursor, flags);
-    }
+  }
 
-  if (textCursor.hasSelection())
-    {
+  if (textCursor.hasSelection()) {
     this->Output->setTextCursor(textCursor);
-    }
+  }
 }
 
 void CMakeSetupDialog::doOutputErrorNext()
@@ -1325,36 +1258,31 @@ void CMakeSetupDialog::doOutputErrorNext()
   bool atEnd = false;
 
   // move cursor out of current error-block
-  if (textCursor.blockCharFormat() == this->ErrorFormat)
-    {
+  if (textCursor.blockCharFormat() == this->ErrorFormat) {
     atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
-    }
+  }
 
   // move cursor to next error-block
-  while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd)
-    {
+  while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) {
     atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
-    }
+  }
 
-  if (atEnd)
-    {
+  if (atEnd) {
     // first search found nothing, wrap around and search again
     atEnd = !textCursor.movePosition(QTextCursor::Start);
 
     // move cursor to next error-block
-    while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd)
-      {
+    while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) {
       atEnd = !textCursor.movePosition(QTextCursor::NextBlock);
-      }
     }
+  }
 
-  if (!atEnd)
-    {
+  if (!atEnd) {
     textCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
 
     QTextCharFormat selectionFormat;
     selectionFormat.setBackground(Qt::yellow);
-    QTextEdit::ExtraSelection extraSelection = {textCursor, selectionFormat};
+    QTextEdit::ExtraSelection extraSelection = { textCursor, selectionFormat };
     this->Output->setExtraSelections(QList<QTextEdit::ExtraSelection>()
                                      << extraSelection);
 
@@ -1364,7 +1292,7 @@ void CMakeSetupDialog::doOutputErrorNext()
     // remove the selection to see the extraSelection
     textCursor.setPosition(textCursor.anchor());
     this->Output->setTextCursor(textCursor);
-    }
+  }
 }
 
 void CMakeSetupDialog::doWarningMessagesDialog()
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 4b53b1c..2a4ea7a 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -14,10 +14,11 @@
 #define CMakeSetupDialog_h
 
 #include "QCMake.h"
+
+#include "ui_CMakeSetupDialog.h"
+#include <QEventLoop>
 #include <QMainWindow>
 #include <QThread>
-#include <QEventLoop>
-#include "ui_CMakeSetupDialog.h"
 
 class QCMakeThread;
 class CMakeCacheModel;
@@ -77,7 +78,7 @@ protected slots:
   bool doConfigureInternal();
   bool doGenerateInternal();
   void exitLoop(int);
-  void doOutputContextMenu(const QPoint &);
+  void doOutputContextMenu(const QPoint&);
   void doOutputFindDialog();
   void doOutputFindNext(bool directionForward = true);
   void doOutputFindPrev();
@@ -87,8 +88,14 @@ protected slots:
   void doWarningMessagesDialog();
 
 protected:
-
-  enum State { Interrupting, ReadyConfigure, ReadyGenerate, Configuring, Generating };
+  enum State
+  {
+    Interrupting,
+    ReadyConfigure,
+    ReadyGenerate,
+    Configuring,
+    Generating
+  };
   void enterState(State s);
 
   void closeEvent(QCloseEvent*);
diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h
index 3f7b834..bdb1962 100644
--- a/Source/QtDialog/Compilers.h
+++ b/Source/QtDialog/Compilers.h
@@ -4,18 +4,18 @@
 #define COMPILERS_HPP
 
 #include <QWidget>
+
 #include <ui_Compilers.h>
 
 class Compilers : public QWidget, public Ui::Compilers
 {
   Q_OBJECT
 public:
-  Compilers(QWidget* p=NULL) :
-    QWidget(p)
+  Compilers(QWidget* p = NULL)
+    : QWidget(p)
   {
     this->setupUi(this);
   }
 };
 
 #endif
-
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index 61aad72..ca5e3b5 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -1,13 +1,13 @@
 
 #include "FirstConfigure.h"
+
 #include "Compilers.h"
 
-#include <QSettings>
-#include <QRadioButton>
 #include <QComboBox>
+#include <QRadioButton>
+#include <QSettings>
 #include <QVBoxLayout>
 
-
 StartCompilerSetup::StartCompilerSetup(QWidget* p)
   : QWizardPage(p)
 {
@@ -22,10 +22,14 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
 
   l->addSpacing(6);
 
-  this->CompilerSetupOptions[0] = new QRadioButton(tr("Use default native compilers"), this);
-  this->CompilerSetupOptions[1] = new QRadioButton(tr("Specify native compilers"), this);
-  this->CompilerSetupOptions[2] = new QRadioButton(tr("Specify toolchain file for cross-compiling"), this);
-  this->CompilerSetupOptions[3] = new QRadioButton(tr("Specify options for cross-compiling"), this);
+  this->CompilerSetupOptions[0] =
+    new QRadioButton(tr("Use default native compilers"), this);
+  this->CompilerSetupOptions[1] =
+    new QRadioButton(tr("Specify native compilers"), this);
+  this->CompilerSetupOptions[2] =
+    new QRadioButton(tr("Specify toolchain file for cross-compiling"), this);
+  this->CompilerSetupOptions[3] =
+    new QRadioButton(tr("Specify options for cross-compiling"), this);
   l->addWidget(this->CompilerSetupOptions[0]);
   l->addWidget(this->CompilerSetupOptions[1]);
   l->addWidget(this->CompilerSetupOptions[2]);
@@ -33,17 +37,17 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
 
   this->CompilerSetupOptions[0]->setChecked(true);
 
-  QObject::connect(this->CompilerSetupOptions[0], SIGNAL(toggled(bool)),
-                   this, SLOT(onSelectionChanged(bool)));
-  QObject::connect(this->CompilerSetupOptions[1], SIGNAL(toggled(bool)),
-                   this, SLOT(onSelectionChanged(bool)));
-  QObject::connect(this->CompilerSetupOptions[2], SIGNAL(toggled(bool)),
-                   this, SLOT(onSelectionChanged(bool)));
-  QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)),
-                   this, SLOT(onSelectionChanged(bool)));
+  QObject::connect(this->CompilerSetupOptions[0], SIGNAL(toggled(bool)), this,
+                   SLOT(onSelectionChanged(bool)));
+  QObject::connect(this->CompilerSetupOptions[1], SIGNAL(toggled(bool)), this,
+                   SLOT(onSelectionChanged(bool)));
+  QObject::connect(this->CompilerSetupOptions[2], SIGNAL(toggled(bool)), this,
+                   SLOT(onSelectionChanged(bool)));
+  QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this,
+                   SLOT(onSelectionChanged(bool)));
   QObject::connect(GeneratorOptions,
-                   SIGNAL(currentIndexChanged(QString const&)),
-                   this, SLOT(onGeneratorChanged(QString const&)));
+                   SIGNAL(currentIndexChanged(QString const&)), this,
+                   SLOT(onGeneratorChanged(QString const&)));
 }
 
 QFrame* StartCompilerSetup::CreateToolsetWidgets()
@@ -73,16 +77,14 @@ void StartCompilerSetup::setGenerators(
   QStringList generator_list;
 
   std::vector<cmake::GeneratorInfo>::const_iterator it;
-  for (it = gens.begin(); it != gens.end(); ++it)
-    {
+  for (it = gens.begin(); it != gens.end(); ++it) {
     generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
 
-    if (it->supportsToolset)
-      {
+    if (it->supportsToolset) {
       this->GeneratorsSupportingToolset.append(
         QString::fromLocal8Bit(it->name.c_str()));
-      }
     }
+  }
 
   this->GeneratorOptions->addItems(generator_list);
 }
@@ -90,8 +92,7 @@ void StartCompilerSetup::setGenerators(
 void StartCompilerSetup::setCurrentGenerator(const QString& gen)
 {
   int idx = this->GeneratorOptions->findText(gen);
-  if(idx != -1)
-  {
+  if (idx != -1) {
     this->GeneratorOptions->setCurrentIndex(idx);
   }
 }
@@ -128,29 +129,26 @@ bool StartCompilerSetup::crossCompilerSetup() const
 
 void StartCompilerSetup::onSelectionChanged(bool on)
 {
-  if(on)
+  if (on)
     selectionChanged();
 }
 
 void StartCompilerSetup::onGeneratorChanged(QString const& name)
 {
-  if (GeneratorsSupportingToolset.contains(name))
-    {
+  if (GeneratorsSupportingToolset.contains(name)) {
     ToolsetFrame->show();
-    }
-  else
-    {
+  } else {
     ToolsetFrame->hide();
-    }
+  }
 }
 
 int StartCompilerSetup::nextId() const
 {
-  if(compilerSetup())
+  if (compilerSetup())
     return NativeSetup;
-  if(crossCompilerSetup())
+  if (crossCompilerSetup())
     return CrossSetup;
-  if(crossCompilerToolChainFile())
+  if (crossCompilerToolChainFile())
     return ToolchainSetup;
   return -1;
 }
@@ -198,7 +196,6 @@ void NativeCompilerSetup::setFortranCompiler(const QString& s)
   this->FortranCompiler->setText(s);
 }
 
-
 CrossCompilerSetup::CrossCompilerSetup(QWidget* p)
   : QWizardPage(p)
 {
@@ -207,7 +204,8 @@ CrossCompilerSetup::CrossCompilerSetup(QWidget* p)
   QWidget::setTabOrder(systemVersion, systemProcessor);
   QWidget::setTabOrder(systemProcessor, CrossCompilers->CCompiler);
   QWidget::setTabOrder(CrossCompilers->CCompiler, CrossCompilers->CXXCompiler);
-  QWidget::setTabOrder(CrossCompilers->CXXCompiler, CrossCompilers->FortranCompiler);
+  QWidget::setTabOrder(CrossCompilers->CXXCompiler,
+                       CrossCompilers->FortranCompiler);
   QWidget::setTabOrder(CrossCompilers->FortranCompiler, crossFindRoot);
   QWidget::setTabOrder(crossFindRoot, crossProgramMode);
   QWidget::setTabOrder(crossProgramMode, crossLibraryMode);
@@ -272,7 +270,6 @@ void CrossCompilerSetup::setSystem(const QString& t)
   this->systemName->setText(t);
 }
 
-
 QString CrossCompilerSetup::getVersion() const
 {
   return this->systemVersion->text();
@@ -283,7 +280,6 @@ void CrossCompilerSetup::setVersion(const QString& t)
   this->systemVersion->setText(t);
 }
 
-
 QString CrossCompilerSetup::getProcessor() const
 {
   return this->systemProcessor->text();
@@ -357,11 +353,9 @@ void ToolchainCompilerSetup::setToolchainFile(const QString& t)
   this->ToolchainFile->setText(t);
 }
 
-
-
 FirstConfigure::FirstConfigure()
 {
-  //this->setOption(QWizard::HaveFinishButtonOnEarlyPages, true);
+  // this->setOption(QWizard::HaveFinishButtonOnEarlyPages, true);
   this->mStartCompilerSetupPage = new StartCompilerSetup(this);
   this->setPage(Start, this->mStartCompilerSetupPage);
   QObject::connect(this->mStartCompilerSetupPage, SIGNAL(selectionChanged()),
@@ -408,24 +402,38 @@ void FirstConfigure::loadFromSettings()
 
   // restore compiler setup
   settings.beginGroup("Settings/Compiler");
-  this->mNativeCompilerSetupPage->setCCompiler(settings.value("CCompiler").toString());
-  this->mNativeCompilerSetupPage->setCXXCompiler(settings.value("CXXCompiler").toString());
-  this->mNativeCompilerSetupPage->setFortranCompiler(settings.value("FortranCompiler").toString());
+  this->mNativeCompilerSetupPage->setCCompiler(
+    settings.value("CCompiler").toString());
+  this->mNativeCompilerSetupPage->setCXXCompiler(
+    settings.value("CXXCompiler").toString());
+  this->mNativeCompilerSetupPage->setFortranCompiler(
+    settings.value("FortranCompiler").toString());
   settings.endGroup();
 
   // restore cross compiler setup
   settings.beginGroup("Settings/CrossCompiler");
-  this->mCrossCompilerSetupPage->setCCompiler(settings.value("CCompiler").toString());
-  this->mCrossCompilerSetupPage->setCXXCompiler(settings.value("CXXCompiler").toString());
-  this->mCrossCompilerSetupPage->setFortranCompiler(settings.value("FortranCompiler").toString());
-  this->mToolchainCompilerSetupPage->setToolchainFile(settings.value("ToolChainFile").toString());
-  this->mCrossCompilerSetupPage->setSystem(settings.value("SystemName").toString());
-  this->mCrossCompilerSetupPage->setVersion(settings.value("SystemVersion").toString());
-  this->mCrossCompilerSetupPage->setProcessor(settings.value("SystemProcessor").toString());
-  this->mCrossCompilerSetupPage->setFindRoot(settings.value("FindRoot").toString());
-  this->mCrossCompilerSetupPage->setProgramMode(settings.value("ProgramMode", 0).toInt());
-  this->mCrossCompilerSetupPage->setLibraryMode(settings.value("LibraryMode", 0).toInt());
-  this->mCrossCompilerSetupPage->setIncludeMode(settings.value("IncludeMode", 0).toInt());
+  this->mCrossCompilerSetupPage->setCCompiler(
+    settings.value("CCompiler").toString());
+  this->mCrossCompilerSetupPage->setCXXCompiler(
+    settings.value("CXXCompiler").toString());
+  this->mCrossCompilerSetupPage->setFortranCompiler(
+    settings.value("FortranCompiler").toString());
+  this->mToolchainCompilerSetupPage->setToolchainFile(
+    settings.value("ToolChainFile").toString());
+  this->mCrossCompilerSetupPage->setSystem(
+    settings.value("SystemName").toString());
+  this->mCrossCompilerSetupPage->setVersion(
+    settings.value("SystemVersion").toString());
+  this->mCrossCompilerSetupPage->setProcessor(
+    settings.value("SystemProcessor").toString());
+  this->mCrossCompilerSetupPage->setFindRoot(
+    settings.value("FindRoot").toString());
+  this->mCrossCompilerSetupPage->setProgramMode(
+    settings.value("ProgramMode", 0).toInt());
+  this->mCrossCompilerSetupPage->setLibraryMode(
+    settings.value("LibraryMode", 0).toInt());
+  this->mCrossCompilerSetupPage->setIncludeMode(
+    settings.value("IncludeMode", 0).toInt());
   settings.endGroup();
 }
 
@@ -441,24 +449,35 @@ void FirstConfigure::saveToSettings()
 
   // save compiler setup
   settings.beginGroup("Settings/Compiler");
-  settings.setValue("CCompiler", this->mNativeCompilerSetupPage->getCCompiler());
-  settings.setValue("CXXCompiler", this->mNativeCompilerSetupPage->getCXXCompiler());
-  settings.setValue("FortranCompiler", this->mNativeCompilerSetupPage->getFortranCompiler());
+  settings.setValue("CCompiler",
+                    this->mNativeCompilerSetupPage->getCCompiler());
+  settings.setValue("CXXCompiler",
+                    this->mNativeCompilerSetupPage->getCXXCompiler());
+  settings.setValue("FortranCompiler",
+                    this->mNativeCompilerSetupPage->getFortranCompiler());
   settings.endGroup();
 
   // save cross compiler setup
   settings.beginGroup("Settings/CrossCompiler");
-  settings.setValue("CCompiler", this->mCrossCompilerSetupPage->getCCompiler());
-  settings.setValue("CXXCompiler", this->mCrossCompilerSetupPage->getCXXCompiler());
-  settings.setValue("FortranCompiler", this->mCrossCompilerSetupPage->getFortranCompiler());
+  settings.setValue("CCompiler",
+                    this->mCrossCompilerSetupPage->getCCompiler());
+  settings.setValue("CXXCompiler",
+                    this->mCrossCompilerSetupPage->getCXXCompiler());
+  settings.setValue("FortranCompiler",
+                    this->mCrossCompilerSetupPage->getFortranCompiler());
   settings.setValue("ToolChainFile", this->getCrossCompilerToolChainFile());
   settings.setValue("SystemName", this->mCrossCompilerSetupPage->getSystem());
-  settings.setValue("SystemVersion", this->mCrossCompilerSetupPage->getVersion());
-  settings.setValue("SystemProcessor", this->mCrossCompilerSetupPage->getProcessor());
+  settings.setValue("SystemVersion",
+                    this->mCrossCompilerSetupPage->getVersion());
+  settings.setValue("SystemProcessor",
+                    this->mCrossCompilerSetupPage->getProcessor());
   settings.setValue("FindRoot", this->mCrossCompilerSetupPage->getFindRoot());
-  settings.setValue("ProgramMode", this->mCrossCompilerSetupPage->getProgramMode());
-  settings.setValue("LibraryMode", this->mCrossCompilerSetupPage->getLibraryMode());
-  settings.setValue("IncludeMode", this->mCrossCompilerSetupPage->getIncludeMode());
+  settings.setValue("ProgramMode",
+                    this->mCrossCompilerSetupPage->getProgramMode());
+  settings.setValue("LibraryMode",
+                    this->mCrossCompilerSetupPage->getLibraryMode());
+  settings.setValue("IncludeMode",
+                    this->mCrossCompilerSetupPage->getIncludeMode());
   settings.endGroup();
 }
 
@@ -494,44 +513,34 @@ QString FirstConfigure::getSystemName() const
 
 QString FirstConfigure::getCCompiler() const
 {
-  if(this->compilerSetup())
-    {
+  if (this->compilerSetup()) {
     return this->mNativeCompilerSetupPage->getCCompiler();
-    }
-  else if(this->crossCompilerSetup())
-    {
+  } else if (this->crossCompilerSetup()) {
     return this->mCrossCompilerSetupPage->getCCompiler();
-    }
+  }
   return QString();
 }
 
 QString FirstConfigure::getCXXCompiler() const
 {
-  if(this->compilerSetup())
-    {
+  if (this->compilerSetup()) {
     return this->mNativeCompilerSetupPage->getCXXCompiler();
-    }
-  else if(this->crossCompilerSetup())
-    {
+  } else if (this->crossCompilerSetup()) {
     return this->mCrossCompilerSetupPage->getCXXCompiler();
-    }
+  }
   return QString();
 }
 
 QString FirstConfigure::getFortranCompiler() const
 {
-  if(this->compilerSetup())
-    {
+  if (this->compilerSetup()) {
     return this->mNativeCompilerSetupPage->getFortranCompiler();
-    }
-  else if(this->crossCompilerSetup())
-    {
+  } else if (this->crossCompilerSetup()) {
     return this->mCrossCompilerSetupPage->getFortranCompiler();
-    }
+  }
   return QString();
 }
 
-
 QString FirstConfigure::getSystemVersion() const
 {
   return this->mCrossCompilerSetupPage->getVersion();
@@ -547,12 +556,7 @@ QString FirstConfigure::getCrossRoot() const
   return this->mCrossCompilerSetupPage->getFindRoot();
 }
 
-const QString CrossModes[] =
-{
-  "BOTH",
-  "ONLY",
-  "NEVER"
-};
+const QString CrossModes[] = { "BOTH", "ONLY", "NEVER" };
 
 QString FirstConfigure::getCrossProgramMode() const
 {
@@ -568,4 +572,3 @@ QString FirstConfigure::getCrossIncludeMode() const
 {
   return CrossModes[this->mCrossCompilerSetupPage->getIncludeMode()];
 }
-
diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h
index 09952b6..c467ddb 100644
--- a/Source/QtDialog/FirstConfigure.h
+++ b/Source/QtDialog/FirstConfigure.h
@@ -4,7 +4,9 @@
 
 #include <QWizard>
 #include <QWizardPage>
+
 #include "cmake.h"
+
 #include "ui_Compilers.h"
 #include "ui_CrossCompiler.h"
 
@@ -21,125 +23,126 @@ enum FirstConfigurePages
   Done
 };
 
-//! the first page that gives basic options for what compilers setup to choose from
+//! the first page that gives basic options for what compilers setup to choose
+//! from
 class StartCompilerSetup : public QWizardPage
 {
   Q_OBJECT
-  public:
-    StartCompilerSetup(QWidget* p);
-    ~StartCompilerSetup();
-    void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
-    void setCurrentGenerator(const QString& gen);
-    QString getGenerator() const;
-    QString getToolset() const;
-
-    bool defaultSetup() const;
-    bool compilerSetup() const;
-    bool crossCompilerSetup() const;
-    bool crossCompilerToolChainFile() const;
-
-    int nextId() const;
-
-  signals:
-    void selectionChanged();
-
-  protected slots:
-    void onSelectionChanged(bool);
-    void onGeneratorChanged(QString const& name);
-
-  protected:
-    QComboBox* GeneratorOptions;
-    QRadioButton* CompilerSetupOptions[4];
-    QFrame* ToolsetFrame;
-    QLineEdit* Toolset;
-    QLabel* ToolsetLabel;
-    QStringList GeneratorsSupportingToolset;
-
-  private:
-    QFrame* CreateToolsetWidgets();
+public:
+  StartCompilerSetup(QWidget* p);
+  ~StartCompilerSetup();
+  void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
+  void setCurrentGenerator(const QString& gen);
+  QString getGenerator() const;
+  QString getToolset() const;
+
+  bool defaultSetup() const;
+  bool compilerSetup() const;
+  bool crossCompilerSetup() const;
+  bool crossCompilerToolChainFile() const;
+
+  int nextId() const;
+
+signals:
+  void selectionChanged();
+
+protected slots:
+  void onSelectionChanged(bool);
+  void onGeneratorChanged(QString const& name);
+
+protected:
+  QComboBox* GeneratorOptions;
+  QRadioButton* CompilerSetupOptions[4];
+  QFrame* ToolsetFrame;
+  QLineEdit* Toolset;
+  QLabel* ToolsetLabel;
+  QStringList GeneratorsSupportingToolset;
+
+private:
+  QFrame* CreateToolsetWidgets();
 };
 
 //! the page that gives basic options for native compilers
 class NativeCompilerSetup : public QWizardPage, protected Ui::Compilers
 {
   Q_OBJECT
-  public:
-    NativeCompilerSetup(QWidget* p);
-    ~NativeCompilerSetup();
+public:
+  NativeCompilerSetup(QWidget* p);
+  ~NativeCompilerSetup();
 
-    QString getCCompiler() const;
-    void setCCompiler(const QString&);
+  QString getCCompiler() const;
+  void setCCompiler(const QString&);
 
-    QString getCXXCompiler() const;
-    void setCXXCompiler(const QString&);
+  QString getCXXCompiler() const;
+  void setCXXCompiler(const QString&);
 
-    QString getFortranCompiler() const;
-    void setFortranCompiler(const QString&);
+  QString getFortranCompiler() const;
+  void setFortranCompiler(const QString&);
 
-    int nextId() const { return -1; }
+  int nextId() const { return -1; }
 };
 
 //! the page that gives options for cross compilers
 class CrossCompilerSetup : public QWizardPage, protected Ui::CrossCompiler
 {
   Q_OBJECT
-  public:
-    CrossCompilerSetup(QWidget* p);
-    ~CrossCompilerSetup();
-
-    QString getSystem() const;
-    void setSystem(const QString&);
-
-    QString getVersion() const;
-    void setVersion(const QString&);
-
-    QString getProcessor() const;
-    void setProcessor(const QString&);
-
-    QString getCCompiler() const;
-    void setCCompiler(const QString&);
+public:
+  CrossCompilerSetup(QWidget* p);
+  ~CrossCompilerSetup();
 
-    QString getCXXCompiler() const;
-    void setCXXCompiler(const QString&);
+  QString getSystem() const;
+  void setSystem(const QString&);
 
-    QString getFortranCompiler() const;
-    void setFortranCompiler(const QString&);
+  QString getVersion() const;
+  void setVersion(const QString&);
 
-    QString getFindRoot() const;
-    void setFindRoot(const QString&);
+  QString getProcessor() const;
+  void setProcessor(const QString&);
 
-    enum CrossMode
-      {
-        BOTH,
-        ONLY,
-        NEVER
-      };
+  QString getCCompiler() const;
+  void setCCompiler(const QString&);
 
-    int getProgramMode() const;
-    void setProgramMode(int);
-    int getLibraryMode() const;
-    void setLibraryMode(int);
-    int getIncludeMode() const;
-    void setIncludeMode(int);
+  QString getCXXCompiler() const;
+  void setCXXCompiler(const QString&);
 
-    int nextId() const { return -1; }
+  QString getFortranCompiler() const;
+  void setFortranCompiler(const QString&);
+
+  QString getFindRoot() const;
+  void setFindRoot(const QString&);
+
+  enum CrossMode
+  {
+    BOTH,
+    ONLY,
+    NEVER
+  };
+
+  int getProgramMode() const;
+  void setProgramMode(int);
+  int getLibraryMode() const;
+  void setLibraryMode(int);
+  int getIncludeMode() const;
+  void setIncludeMode(int);
+
+  int nextId() const { return -1; }
 };
 
 //! the page that gives options for a toolchain file
 class ToolchainCompilerSetup : public QWizardPage
 {
   Q_OBJECT
-  public:
-    ToolchainCompilerSetup(QWidget* p);
-    ~ToolchainCompilerSetup();
+public:
+  ToolchainCompilerSetup(QWidget* p);
+  ~ToolchainCompilerSetup();
 
-    QString toolchainFile() const;
-    void setToolchainFile(const QString&);
+  QString toolchainFile() const;
+  void setToolchainFile(const QString&);
 
-    int nextId() const { return -1; }
+  int nextId() const { return -1; }
 
-  protected:
-    QCMakeFilePathEditor* ToolchainFile;
+protected:
+  QCMakeFilePathEditor* ToolchainFile;
 };
 
 //! the wizard with the pages
@@ -181,8 +184,6 @@ protected:
   NativeCompilerSetup* mNativeCompilerSetupPage;
   CrossCompilerSetup* mCrossCompilerSetupPage;
   ToolchainCompilerSetup* mToolchainCompilerSetupPage;
-
 };
 
 #endif // FirstConfigure_h
-
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index dd7c138..c84e153 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -12,15 +12,15 @@
 
 #include "QCMake.h"
 
-#include <QDir>
 #include <QCoreApplication>
+#include <QDir>
 
+#include "cmExternalMakefileProjectGenerator.h"
 #include "cmState.h"
 #include "cmSystemTools.h"
-#include "cmExternalMakefileProjectGenerator.h"
 
 #ifdef Q_OS_WIN
-#include "qt_windows.h"  // For SetErrorMode
+#include "qt_windows.h" // For SetErrorMode
 #endif
 
 QCMake::QCMake(QObject* p)
@@ -48,26 +48,24 @@ QCMake::QCMake(QObject* p)
   this->CMakeInstance->GetRegisteredGenerators(generators);
 
   std::vector<cmake::GeneratorInfo>::const_iterator it;
-  for(it = generators.begin(); it != generators.end(); ++it)
-    {
+  for (it = generators.begin(); it != generators.end(); ++it) {
     // Skip the generator "KDevelop3", since there is also
     // "KDevelop3 - Unix Makefiles", which is the full and official name.
     // The short name is actually only still there since this was the name
     // in CMake 2.4, to keep "command line argument compatibility", but
     // this is not necessary in the GUI.
-    if (it->name == "KDevelop3")
-      {
+    if (it->name == "KDevelop3") {
       continue;
-      }
+    }
 
     this->AvailableGenerators.push_back(*it);
-    }
+  }
 }
 
 QCMake::~QCMake()
 {
   delete this->CMakeInstance;
-  //cmDynamicLoader::FlushCache();
+  // cmDynamicLoader::FlushCache();
 }
 
 void QCMake::loadCache(const QString& dir)
@@ -77,80 +75,73 @@ void QCMake::loadCache(const QString& dir)
 
 void QCMake::setSourceDirectory(const QString& _dir)
 {
-  QString dir =
-    QString::fromLocal8Bit(cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
-  if(this->SourceDirectory != dir)
-    {
+  QString dir = QString::fromLocal8Bit(
+    cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
+  if (this->SourceDirectory != dir) {
     this->SourceDirectory = QDir::fromNativeSeparators(dir);
     emit this->sourceDirChanged(this->SourceDirectory);
-    }
+  }
 }
 
 void QCMake::setBinaryDirectory(const QString& _dir)
 {
-  QString dir =
-    QString::fromLocal8Bit(cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
-  if(this->BinaryDirectory != dir)
-    {
+  QString dir = QString::fromLocal8Bit(
+    cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
+  if (this->BinaryDirectory != dir) {
     this->BinaryDirectory = QDir::fromNativeSeparators(dir);
     emit this->binaryDirChanged(this->BinaryDirectory);
     cmState* state = this->CMakeInstance->GetState();
     this->setGenerator(QString());
     this->setToolset(QString());
-    if(!this->CMakeInstance->LoadCache(
-      this->BinaryDirectory.toLocal8Bit().data()))
-      {
+    if (!this->CMakeInstance->LoadCache(
+          this->BinaryDirectory.toLocal8Bit().data())) {
       QDir testDir(this->BinaryDirectory);
-      if(testDir.exists("CMakeCache.txt"))
-        {
-        cmSystemTools::Error("There is a CMakeCache.txt file for the current binary "
-            "tree but cmake does not have permission to read it.  "
-            "Please check the permissions of the directory you are trying to run CMake on.");
-        }
+      if (testDir.exists("CMakeCache.txt")) {
+        cmSystemTools::Error(
+          "There is a CMakeCache.txt file for the current binary "
+          "tree but cmake does not have permission to read it.  "
+          "Please check the permissions of the directory you are trying to "
+          "run CMake on.");
       }
+    }
 
     QCMakePropertyList props = this->properties();
     emit this->propertiesChanged(props);
     const char* homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
-    if (homeDir)
-      {
+    if (homeDir) {
       setSourceDirectory(QString::fromLocal8Bit(homeDir));
-      }
+    }
     const char* gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
-    if (gen)
-      {
-      const char* extraGen = state
-                        ->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
-      std::string curGen = cmExternalMakefileProjectGenerator::
-        CreateFullGeneratorName(gen, extraGen? extraGen : "");
+    if (gen) {
+      const char* extraGen =
+        state->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
+      std::string curGen =
+        cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
+          gen, extraGen ? extraGen : "");
       this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
-      }
+    }
 
     const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
-    if (toolset)
-      {
+    if (toolset) {
       this->setToolset(QString::fromLocal8Bit(toolset));
-      }
     }
+  }
 }
 
-
 void QCMake::setGenerator(const QString& gen)
 {
-  if(this->Generator != gen)
-    {
+  if (this->Generator != gen) {
     this->Generator = gen;
     emit this->generatorChanged(this->Generator);
-    }
+  }
 }
 
 void QCMake::setToolset(const QString& toolset)
 {
-  if(this->Toolset != toolset)
-    {
+  if (this->Toolset != toolset) {
     this->Toolset = toolset;
     emit this->toolsetChanged(this->Toolset);
-    }
+  }
 }
 
 void QCMake::configure()
@@ -159,10 +150,13 @@ void QCMake::configure()
   UINT lastErrorMode = SetErrorMode(0);
 #endif
 
-  this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toLocal8Bit().data());
-  this->CMakeInstance->SetHomeOutputDirectory(this->BinaryDirectory.toLocal8Bit().data());
+  this->CMakeInstance->SetHomeDirectory(
+    this->SourceDirectory.toLocal8Bit().data());
+  this->CMakeInstance->SetHomeOutputDirectory(
+    this->BinaryDirectory.toLocal8Bit().data());
   this->CMakeInstance->SetGlobalGenerator(
-    this->CMakeInstance->CreateGlobalGenerator(this->Generator.toLocal8Bit().data()));
+    this->CMakeInstance->CreateGlobalGenerator(
+      this->Generator.toLocal8Bit().data()));
   this->CMakeInstance->SetGeneratorPlatform("");
   this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data());
   this->CMakeInstance->LoadCache();
@@ -210,82 +204,59 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
   // set the value of properties
   cmState* state = this->CMakeInstance->GetState();
   std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
-  for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
-      it != cacheKeys.end(); ++it)
-    {
+  for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
+       it != cacheKeys.end(); ++it) {
     cmState::CacheEntryType t = state->GetCacheEntryType(*it);
-    if(t == cmState::INTERNAL ||
-       t == cmState::STATIC)
-      {
+    if (t == cmState::INTERNAL || t == cmState::STATIC) {
       continue;
-      }
+    }
 
     QCMakeProperty prop;
     prop.Key = QString::fromLocal8Bit(it->c_str());
     int idx = props.indexOf(prop);
-    if(idx == -1)
-      {
+    if (idx == -1) {
       toremove.append(QString::fromLocal8Bit(it->c_str()));
-      }
-    else
-      {
+    } else {
       prop = props[idx];
-      if(prop.Value.type() == QVariant::Bool)
-        {
+      if (prop.Value.type() == QVariant::Bool) {
         state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
-        }
-      else
-        {
+      } else {
         state->SetCacheEntryValue(*it,
-                                   prop.Value.toString().toLocal8Bit().data());
-        }
-      props.removeAt(idx);
+                                  prop.Value.toString().toLocal8Bit().data());
       }
-
+      props.removeAt(idx);
     }
+  }
 
   // remove some properites
-  foreach(QString s, toremove)
-    {
+  foreach (QString s, toremove) {
     this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
 
     state->RemoveCacheEntry(s.toLocal8Bit().data());
-    }
+  }
 
   // add some new properites
-  foreach(QCMakeProperty s, props)
-    {
+  foreach (QCMakeProperty s, props) {
     this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data());
 
-    if(s.Type == QCMakeProperty::BOOL)
-      {
-      this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
-                            s.Value.toBool() ? "ON" : "OFF",
-                            s.Help.toLocal8Bit().data(),
-                            cmState::BOOL);
-      }
-    else if(s.Type == QCMakeProperty::STRING)
-      {
-      this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
-                            s.Value.toString().toLocal8Bit().data(),
-                            s.Help.toLocal8Bit().data(),
-                            cmState::STRING);
-      }
-    else if(s.Type == QCMakeProperty::PATH)
-      {
-      this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
-                            s.Value.toString().toLocal8Bit().data(),
-                            s.Help.toLocal8Bit().data(),
-                            cmState::PATH);
-      }
-    else if(s.Type == QCMakeProperty::FILEPATH)
-      {
-      this->CMakeInstance->AddCacheEntry(s.Key.toLocal8Bit().data(),
-                            s.Value.toString().toLocal8Bit().data(),
-                            s.Help.toLocal8Bit().data(),
-                            cmState::FILEPATH);
-      }
+    if (s.Type == QCMakeProperty::BOOL) {
+      this->CMakeInstance->AddCacheEntry(
+        s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF",
+        s.Help.toLocal8Bit().data(), cmState::BOOL);
+    } else if (s.Type == QCMakeProperty::STRING) {
+      this->CMakeInstance->AddCacheEntry(
+        s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
+        s.Help.toLocal8Bit().data(), cmState::STRING);
+    } else if (s.Type == QCMakeProperty::PATH) {
+      this->CMakeInstance->AddCacheEntry(
+        s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
+        s.Help.toLocal8Bit().data(), cmState::PATH);
+    } else if (s.Type == QCMakeProperty::FILEPATH) {
+      this->CMakeInstance->AddCacheEntry(
+        s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
+        s.Help.toLocal8Bit().data(), cmState::FILEPATH);
     }
+  }
 
   this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
 }
@@ -297,50 +268,39 @@ QCMakePropertyList QCMake::properties() const
   cmState* state = this->CMakeInstance->GetState();
   std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
   for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
-        i != cacheKeys.end(); ++i)
-    {
+       i != cacheKeys.end(); ++i) {
     cmState::CacheEntryType t = state->GetCacheEntryType(*i);
-    if(t == cmState::INTERNAL ||
-       t == cmState::STATIC ||
-       t == cmState::UNINITIALIZED)
-      {
+    if (t == cmState::INTERNAL || t == cmState::STATIC ||
+        t == cmState::UNINITIALIZED) {
       continue;
-      }
+    }
 
     const char* cachedValue = state->GetCacheEntryValue(*i);
 
     QCMakeProperty prop;
     prop.Key = QString::fromLocal8Bit(i->c_str());
-    prop.Help = QString::fromLocal8Bit(
-                            state->GetCacheEntryProperty(*i, "HELPSTRING"));
+    prop.Help =
+      QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING"));
     prop.Value = QString::fromLocal8Bit(cachedValue);
     prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
-    if(t == cmState::BOOL)
-      {
+    if (t == cmState::BOOL) {
       prop.Type = QCMakeProperty::BOOL;
       prop.Value = cmSystemTools::IsOn(cachedValue);
-      }
-    else if(t == cmState::PATH)
-      {
+    } else if (t == cmState::PATH) {
       prop.Type = QCMakeProperty::PATH;
-      }
-    else if(t == cmState::FILEPATH)
-      {
+    } else if (t == cmState::FILEPATH) {
       prop.Type = QCMakeProperty::FILEPATH;
-      }
-    else if(t == cmState::STRING)
-      {
+    } else if (t == cmState::STRING) {
       prop.Type = QCMakeProperty::STRING;
       const char* stringsProperty =
-                                state->GetCacheEntryProperty(*i, "STRINGS");
-      if (stringsProperty)
-        {
+        state->GetCacheEntryProperty(*i, "STRINGS");
+      if (stringsProperty) {
         prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
-        }
       }
+    }
 
     ret.append(prop);
-    }
+  }
 
   return ret;
 }
@@ -363,14 +323,11 @@ bool QCMake::interruptCallback(void* cd)
 void QCMake::progressCallback(const char* msg, float percent, void* cd)
 {
   QCMake* self = reinterpret_cast<QCMake*>(cd);
-  if(percent >= 0)
-    {
+  if (percent >= 0) {
     emit self->progressChanged(QString::fromLocal8Bit(msg), percent);
-    }
-  else
-    {
+  } else {
     emit self->outputMessage(QString::fromLocal8Bit(msg));
-    }
+  }
   QCoreApplication::processEvents();
 }
 
@@ -385,14 +342,14 @@ void QCMake::messageCallback(const char* msg, const char* /*title*/,
 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)));
+  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)));
+  emit self->outputMessage(QString::fromLocal8Bit(msg, int(len)));
   QCoreApplication::processEvents();
 }
 
@@ -443,11 +400,10 @@ void QCMake::reloadCache()
 
 void QCMake::setDebugOutput(bool flag)
 {
-  if(flag != this->CMakeInstance->GetDebugOutput())
-    {
+  if (flag != this->CMakeInstance->GetDebugOutput()) {
     this->CMakeInstance->SetDebugOutputOn(flag);
     emit this->debugOutputChanged(flag);
-    }
+  }
 }
 
 bool QCMake::getDebugOutput() const
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 8942e7c..a818c6b 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -12,28 +12,35 @@
 
 #ifndef QCMake_h
 #define QCMake_h
+
+#include "cmake.h"
+
 #ifdef _MSC_VER
-#pragma warning ( disable : 4127 )
-#pragma warning ( disable : 4512 )
+#pragma warning(disable : 4127)
+#pragma warning(disable : 4512)
 #endif
 
 #include <vector>
 
+#include <QAtomicInt>
+#include <QList>
+#include <QMetaType>
 #include <QObject>
 #include <QString>
-#include <QVariant>
-#include <QList>
 #include <QStringList>
-#include <QMetaType>
-#include <QAtomicInt>
-
-#include "cmake.h"
+#include <QVariant>
 
 /// struct to represent cmake properties in Qt
 /// Value is of type String or Bool
 struct QCMakeProperty
 {
-  enum PropertyType { BOOL, PATH, FILEPATH, STRING };
+  enum PropertyType
+  {
+    BOOL,
+    PATH,
+    FILEPATH,
+    STRING
+  };
   QString Key;
   QVariant Value;
   QStringList Strings;
@@ -41,13 +48,13 @@ struct QCMakeProperty
   PropertyType Type;
   bool Advanced;
   bool operator==(const QCMakeProperty& other) const
-    {
+  {
     return this->Key == other.Key;
-    }
+  }
   bool operator<(const QCMakeProperty& other) const
-    {
+  {
     return this->Key < other.Key;
-    }
+  }
 };
 
 // list of properties
@@ -64,7 +71,7 @@ class QCMake : public QObject
 {
   Q_OBJECT
 public:
-  QCMake(QObject* p=0);
+  QCMake(QObject* p = 0);
   ~QCMake();
 public slots:
   /// load the cache file in a directory
@@ -83,7 +90,8 @@ public slots:
   void generate();
   /// set the property values
   void setProperties(const QCMakePropertyList&);
-  /// interrupt the configure or generate process (if connecting, make a direct connection)
+  /// interrupt the configure or generate process (if connecting, make a direct
+  /// connection)
   void interrupt();
   /// delete the cache in binary directory
   void deleteCache();
@@ -127,7 +135,8 @@ public:
   bool getDebugOutput() const;
 
 signals:
-  /// signal when properties change (during read from disk or configure process)
+  /// signal when properties change (during read from disk or configure
+  /// process)
   void propertiesChanged(const QCMakePropertyList& vars);
   /// signal when the generator changes
   void generatorChanged(const QString& gen);
@@ -156,8 +165,8 @@ protected:
 
   static bool interruptCallback(void*);
   static void progressCallback(const char* msg, float percent, void* cd);
-  static void messageCallback(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 WarnUninitializedMode;
@@ -173,4 +182,3 @@ protected:
 };
 
 #endif // QCMake_h
-
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index bae6a30..cc1f4aa 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -12,14 +12,14 @@
 
 #include "QCMakeCacheView.h"
 
+#include <QApplication>
+#include <QEvent>
 #include <QHBoxLayout>
 #include <QHeaderView>
-#include <QEvent>
-#include <QStyle>
 #include <QKeyEvent>
-#include <QSortFilterProxyModel>
 #include <QMetaProperty>
-#include <QApplication>
+#include <QSortFilterProxyModel>
+#include <QStyle>
 
 #include "QCMakeWidgets.h"
 
@@ -27,46 +27,44 @@
 class QCMakeSearchFilter : public QSortFilterProxyModel
 {
 public:
-  QCMakeSearchFilter(QObject* o) : QSortFilterProxyModel(o) {}
+  QCMakeSearchFilter(QObject* o)
+    : QSortFilterProxyModel(o)
+  {
+  }
+
 protected:
   bool filterAcceptsRow(int row, const QModelIndex& p) const
-    {
+  {
     QStringList strs;
     const QAbstractItemModel* m = this->sourceModel();
     QModelIndex idx = m->index(row, 0, p);
 
     // if there are no children, get strings for column 0 and 1
-    if(!m->hasChildren(idx))
-      {
+    if (!m->hasChildren(idx)) {
       strs.append(m->data(idx).toString());
       idx = m->index(row, 1, p);
       strs.append(m->data(idx).toString());
-      }
-    else
-      {
+    } else {
       // get strings for children entries to compare with
       // instead of comparing with the parent
       int num = m->rowCount(idx);
-      for(int i=0; i<num; i++)
-        {
+      for (int i = 0; i < num; i++) {
         QModelIndex tmpidx = m->index(i, 0, idx);
         strs.append(m->data(tmpidx).toString());
         tmpidx = m->index(i, 1, idx);
         strs.append(m->data(tmpidx).toString());
-        }
       }
+    }
 
     // check all strings for a match
-    foreach(QString str, strs)
-      {
-      if(str.contains(this->filterRegExp()))
-        {
+    foreach (QString str, strs) {
+      if (str.contains(this->filterRegExp())) {
         return true;
-        }
       }
+    }
 
     return false;
-    }
+  }
 };
 
 // filter for searches
@@ -74,7 +72,10 @@ class QCMakeAdvancedFilter : public QSortFilterProxyModel
 {
 public:
   QCMakeAdvancedFilter(QObject* o)
-    : QSortFilterProxyModel(o), ShowAdvanced(false) {}
+    : QSortFilterProxyModel(o)
+    , ShowAdvanced(false)
+  {
+  }
 
   void setShowAdvanced(bool f)
   {
@@ -84,37 +85,32 @@ public:
   bool showAdvanced() const { return this->ShowAdvanced; }
 
 protected:
-
   bool ShowAdvanced;
 
   bool filterAcceptsRow(int row, const QModelIndex& p) const
-    {
+  {
     const QAbstractItemModel* m = this->sourceModel();
     QModelIndex idx = m->index(row, 0, p);
 
     // if there are no children
-    if(!m->hasChildren(idx))
-      {
+    if (!m->hasChildren(idx)) {
       bool adv = m->data(idx, QCMakeCacheModel::AdvancedRole).toBool();
-      if(!adv || (adv && this->ShowAdvanced))
-        {
+      if (!adv || (adv && this->ShowAdvanced)) {
         return true;
-        }
-      return false;
       }
+      return false;
+    }
 
     // check children
     int num = m->rowCount(idx);
-    for(int i=0; i<num; i++)
-      {
+    for (int i = 0; i < num; i++) {
       bool accept = this->filterAcceptsRow(i, idx);
-      if(accept)
-        {
+      if (accept) {
         return true;
-        }
       }
-    return false;
     }
+    return false;
+  }
 };
 
 QCMakeCacheView::QCMakeCacheView(QWidget* p)
@@ -147,10 +143,9 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p)
 
 bool QCMakeCacheView::event(QEvent* e)
 {
-  if(e->type() == QEvent::Show)
-    {
-    this->header()->setDefaultSectionSize(this->viewport()->width()/2);
-    }
+  if (e->type() == QEvent::Show) {
+    this->header()->setDefaultSectionSize(this->viewport()->width() / 2);
+  }
   return QTreeView::event(e);
 }
 
@@ -160,17 +155,14 @@ QCMakeCacheModel* QCMakeCacheView::cacheModel() const
 }
 
 QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
-  Qt::KeyboardModifiers mod)
+                                        Qt::KeyboardModifiers mod)
 {
   // want home/end to go to begin/end of rows, not columns
-  if(act == MoveHome)
-    {
+  if (act == MoveHome) {
     return this->model()->index(0, 1);
-    }
-  else if(act == MoveEnd)
-    {
-    return this->model()->index(this->model()->rowCount()-1, 1);
-    }
+  } else if (act == MoveEnd) {
+    return this->model()->index(this->model()->rowCount() - 1, 1);
+  }
   return QTreeView::moveCursor(act, mod);
 }
 
@@ -195,10 +187,10 @@ void QCMakeCacheView::setSearchFilter(const QString& s)
 }
 
 QCMakeCacheModel::QCMakeCacheModel(QObject* p)
-  : QStandardItemModel(p),
-    EditEnabled(true),
-    NewPropertyCount(0),
-    View(FlatView)
+  : QStandardItemModel(p)
+  , EditEnabled(true)
+  , NewPropertyCount(0)
+  , View(FlatView)
 {
   this->ShowNewProperties = true;
   QStringList labels;
@@ -234,47 +226,39 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
 {
   QSet<QCMakeProperty> newProps, newProps2;
 
-  if(this->ShowNewProperties)
-    {
+  if (this->ShowNewProperties) {
     newProps = props.toSet();
     newProps2 = newProps;
     QSet<QCMakeProperty> oldProps = this->properties().toSet();
     oldProps.intersect(newProps);
     newProps.subtract(oldProps);
     newProps2.subtract(newProps);
-    }
-  else
-    {
+  } else {
     newProps2 = props.toSet();
-    }
+  }
 
   bool b = this->blockSignals(true);
 
   this->clear();
   this->NewPropertyCount = newProps.size();
 
-  if(View == FlatView)
-  {
+  if (View == FlatView) {
     QCMakePropertyList newP = newProps.toList();
     QCMakePropertyList newP2 = newProps2.toList();
     qSort(newP);
     qSort(newP2);
     int row_count = 0;
-    foreach(QCMakeProperty p, newP)
-    {
+    foreach (QCMakeProperty p, newP) {
       this->insertRow(row_count);
       this->setPropertyData(this->index(row_count, 0), p, true);
       row_count++;
     }
-    foreach(QCMakeProperty p, newP2)
-    {
+    foreach (QCMakeProperty p, newP2) {
       this->insertRow(row_count);
       this->setPropertyData(this->index(row_count, 0), p, false);
       row_count++;
     }
-  }
-  else if(this->View == GroupView)
-  {
+  } else if (this->View == GroupView) {
     QMap<QString, QCMakePropertyList> newPropsTree;
     this->breakProperties(newProps, newPropsTree);
     QMap<QString, QCMakePropertyList> newPropsTree2;
@@ -282,35 +266,33 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
 
     QStandardItem* root = this->invisibleRootItem();
 
-    foreach(QString key, newPropsTree.keys())
-      {
+    foreach (QString key, newPropsTree.keys()) {
       QCMakePropertyList props2 = newPropsTree[key];
 
       QList<QStandardItem*> parentItems;
       parentItems.append(
-        new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key)
-        );
+        new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key));
       parentItems.append(new QStandardItem());
-      parentItems[0]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
-      parentItems[1]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
+      parentItems[0]->setData(QBrush(QColor(255, 100, 100)),
+                              Qt::BackgroundColorRole);
+      parentItems[1]->setData(QBrush(QColor(255, 100, 100)),
+                              Qt::BackgroundColorRole);
       parentItems[0]->setData(1, GroupRole);
       parentItems[1]->setData(1, GroupRole);
       root->appendRow(parentItems);
 
       int num = props2.size();
-      for(int i=0; i<num; i++)
-        {
+      for (int i = 0; i < num; i++) {
         QCMakeProperty prop = props2[i];
         QList<QStandardItem*> items;
         items.append(new QStandardItem());
         items.append(new QStandardItem());
         parentItems[0]->appendRow(items);
         this->setPropertyData(this->indexFromItem(items[0]), prop, true);
-        }
       }
+    }
 
-    foreach(QString key, newPropsTree2.keys())
-      {
+    foreach (QString key, newPropsTree2.keys()) {
       QCMakePropertyList props2 = newPropsTree2[key];
 
       QStandardItem* parentItem =
@@ -319,16 +301,15 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
       parentItem->setData(1, GroupRole);
 
       int num = props2.size();
-      for(int i=0; i<num; i++)
-        {
+      for (int i = 0; i < num; i++) {
         QCMakeProperty prop = props2[i];
         QList<QStandardItem*> items;
         items.append(new QStandardItem());
         items.append(new QStandardItem());
         parentItem->appendRow(items);
         this->setPropertyData(this->indexFromItem(items[0]), prop, false);
-        }
       }
+    }
   }
 
   this->blockSignals(b);
@@ -348,8 +329,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
   QCMakePropertyList oldProps;
   int numNew = this->NewPropertyCount;
   int numTotal = props.count();
-  for(int i=numNew; i<numTotal; i++)
-  {
+  for (int i = numNew; i < numTotal; i++) {
     oldProps.append(props[i]);
   }
 
@@ -362,7 +342,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
 }
 
 void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
-    const QCMakeProperty& prop, bool isNew)
+                                       const QCMakeProperty& prop, bool isNew)
 {
   QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
 
@@ -371,46 +351,42 @@ void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
   this->setData(idx1, prop.Type, QCMakeCacheModel::TypeRole);
   this->setData(idx1, prop.Advanced, QCMakeCacheModel::AdvancedRole);
 
-  if(prop.Type == QCMakeProperty::BOOL)
-  {
+  if (prop.Type == QCMakeProperty::BOOL) {
     int check = prop.Value.toBool() ? Qt::Checked : Qt::Unchecked;
     this->setData(idx2, check, Qt::CheckStateRole);
-  }
-  else
-  {
+  } else {
     this->setData(idx2, prop.Value, Qt::DisplayRole);
   }
   this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole);
 
-  if (!prop.Strings.isEmpty())
-  {
+  if (!prop.Strings.isEmpty()) {
     this->setData(idx1, prop.Strings, QCMakeCacheModel::StringsRole);
   }
 
-  if(isNew)
-  {
-    this->setData(idx1, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
-    this->setData(idx2, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
+  if (isNew) {
+    this->setData(idx1, QBrush(QColor(255, 100, 100)),
+                  Qt::BackgroundColorRole);
+    this->setData(idx2, QBrush(QColor(255, 100, 100)),
+                  Qt::BackgroundColorRole);
   }
 }
 
 void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
-    QCMakeProperty& prop) const
+                                       QCMakeProperty& prop) const
 {
   QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
 
   prop.Key = this->data(idx1, Qt::DisplayRole).toString();
   prop.Help = this->data(idx1, HelpRole).toString();
-  prop.Type = static_cast<QCMakeProperty::PropertyType>(this->data(idx1, TypeRole).toInt());
+  prop.Type = static_cast<QCMakeProperty::PropertyType>(
+    this->data(idx1, TypeRole).toInt());
   prop.Advanced = this->data(idx1, AdvancedRole).toBool();
-  prop.Strings = this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
-  if(prop.Type == QCMakeProperty::BOOL)
-  {
+  prop.Strings =
+    this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
+  if (prop.Type == QCMakeProperty::BOOL) {
     int check = this->data(idx2, Qt::CheckStateRole).toInt();
     prop.Value = check == Qt::Checked;
-  }
-  else
-  {
+  } else {
     prop.Value = this->data(idx2, Qt::DisplayRole).toString();
   }
 }
@@ -418,43 +394,36 @@ void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
 QString QCMakeCacheModel::prefix(const QString& s)
 {
   QString prefix = s.section('_', 0, 0);
-  if(prefix == s)
-    {
+  if (prefix == s) {
     prefix = QString();
-    }
+  }
   return prefix;
 }
 
-void QCMakeCacheModel::breakProperties(const QSet<QCMakeProperty>& props,
-                     QMap<QString, QCMakePropertyList>& result)
+void QCMakeCacheModel::breakProperties(
+  const QSet<QCMakeProperty>& props, QMap<QString, QCMakePropertyList>& result)
 {
   QMap<QString, QCMakePropertyList> tmp;
   // return a map of properties grouped by prefixes, and sorted
-  foreach(QCMakeProperty p, props)
-    {
+  foreach (QCMakeProperty p, props) {
     QString prefix = QCMakeCacheModel::prefix(p.Key);
     tmp[prefix].append(p);
-    }
+  }
   // sort it and re-org any properties with only one sub item
   QCMakePropertyList reorgProps;
   QMap<QString, QCMakePropertyList>::iterator iter;
-  for(iter = tmp.begin(); iter != tmp.end();)
-    {
-    if(iter->count() == 1)
-      {
+  for (iter = tmp.begin(); iter != tmp.end();) {
+    if (iter->count() == 1) {
       reorgProps.append((*iter)[0]);
       iter = tmp.erase(iter);
-      }
-    else
-      {
+    } else {
       qSort(*iter);
       ++iter;
-      }
     }
-  if(reorgProps.count())
-    {
+  }
+  if (reorgProps.count()) {
     tmp[QString()] += reorgProps;
-    }
+  }
   result = tmp;
 }
 
@@ -462,27 +431,21 @@ QCMakePropertyList QCMakeCacheModel::properties() const
 {
   QCMakePropertyList props;
 
-  if(!this->rowCount())
-    {
+  if (!this->rowCount()) {
     return props;
-    }
+  }
 
   QList<QModelIndex> idxs;
-  idxs.append(this->index(0,0));
+  idxs.append(this->index(0, 0));
 
   // walk the entire model for property entries
   // this works regardless of a flat view or a tree view
-  while(!idxs.isEmpty())
-  {
+  while (!idxs.isEmpty()) {
     QModelIndex idx = idxs.last();
-    if(this->hasChildren(idx) && this->rowCount(idx))
-    {
-      idxs.append(this->index(0,0, idx));
-    }
-    else
-    {
-      if(!data(idx, GroupRole).toInt())
-      {
+    if (this->hasChildren(idx) && this->rowCount(idx)) {
+      idxs.append(this->index(0, 0, idx));
+    } else {
+      if (!data(idx, GroupRole).toInt()) {
         // get data
         QCMakeProperty prop;
         this->getPropertyData(idx, prop);
@@ -490,17 +453,17 @@ QCMakePropertyList QCMakeCacheModel::properties() const
       }
 
       // go to the next in the tree
-      while(!idxs.isEmpty() && (
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
-        (idxs.last().row()+1) >= rowCount(idxs.last().parent()) ||
+      while (!idxs.isEmpty() &&
+             (
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) &&                                \
+  QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
+               (idxs.last().row() + 1) >= rowCount(idxs.last().parent()) ||
 #endif
-        !idxs.last().sibling(idxs.last().row()+1, 0).isValid()))
-      {
+               !idxs.last().sibling(idxs.last().row() + 1, 0).isValid())) {
         idxs.removeLast();
       }
-      if(!idxs.isEmpty())
-      {
-        idxs.last() = idxs.last().sibling(idxs.last().row()+1, 0);
+      if (!idxs.isEmpty()) {
+        idxs.last() = idxs.last().sibling(idxs.last().row() + 1, 0);
       }
     }
   }
@@ -509,8 +472,9 @@ QCMakePropertyList QCMakeCacheModel::properties() const
 }
 
 bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
-                      const QString& name, const QString& description,
-                      const QVariant& value, bool advanced)
+                                      const QString& name,
+                                      const QString& description,
+                                      const QVariant& value, bool advanced)
 {
   QCMakeProperty prop;
   prop.Key = name;
@@ -519,9 +483,9 @@ bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
   prop.Type = t;
   prop.Advanced = advanced;
 
-  //insert at beginning
+  // insert at beginning
   this->insertRow(0);
-  this->setPropertyData(this->index(0,0), prop, true);
+  this->setPropertyData(this->index(0, 0), prop, true);
   this->NewPropertyCount++;
   return true;
 }
@@ -541,33 +505,31 @@ int QCMakeCacheModel::newPropertyCount() const
   return this->NewPropertyCount;
 }
 
-Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const
+Qt::ItemFlags QCMakeCacheModel::flags(const QModelIndex& idx) const
 {
   Qt::ItemFlags f = QStandardItemModel::flags(idx);
-  if(!this->EditEnabled)
-    {
+  if (!this->EditEnabled) {
     f &= ~Qt::ItemIsEditable;
     return f;
-    }
-  if(QCMakeProperty::BOOL == this->data(idx, TypeRole).toInt())
-    {
+  }
+  if (QCMakeProperty::BOOL == this->data(idx, TypeRole).toInt()) {
     f |= Qt::ItemIsUserCheckable;
-    }
+  }
   return f;
 }
 
 QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const
 {
-  if(!this->hasChildren(idx) &&
-     this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL)
-  {
+  if (!this->hasChildren(idx) &&
+      this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL) {
     return this->index(idx.row(), 1, idx.parent());
   }
   return idx;
 }
 
 QCMakeCacheModelDelegate::QCMakeCacheModelDelegate(QObject* p)
-  : QItemDelegate(p), FileDialogFlag(false)
+  : QItemDelegate(p)
+  , FileDialogFlag(false)
 {
 }
 
@@ -577,91 +539,77 @@ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f)
 }
 
 QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p,
-    const QStyleOptionViewItem&, const QModelIndex& idx) const
+                                                const QStyleOptionViewItem&,
+                                                const QModelIndex& idx) const
 {
   QModelIndex var = idx.sibling(idx.row(), 0);
   int type = var.data(QCMakeCacheModel::TypeRole).toInt();
-  if(type == QCMakeProperty::BOOL)
-    {
+  if (type == QCMakeProperty::BOOL) {
     return NULL;
-    }
-  else if(type == QCMakeProperty::PATH)
-    {
+  } else if (type == QCMakeProperty::PATH) {
     QCMakePathEditor* editor =
-      new QCMakePathEditor(p,
-      var.data(Qt::DisplayRole).toString());
+      new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString());
     QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
-        SLOT(setFileDialogFlag(bool)));
+                     SLOT(setFileDialogFlag(bool)));
     return editor;
-    }
-  else if(type == QCMakeProperty::FILEPATH)
-    {
+  } else if (type == QCMakeProperty::FILEPATH) {
     QCMakeFilePathEditor* editor =
-      new QCMakeFilePathEditor(p,
-      var.data(Qt::DisplayRole).toString());
+      new QCMakeFilePathEditor(p, var.data(Qt::DisplayRole).toString());
     QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
-        SLOT(setFileDialogFlag(bool)));
+                     SLOT(setFileDialogFlag(bool)));
     return editor;
-    }
-  else if(type == QCMakeProperty::STRING &&
-          var.data(QCMakeCacheModel::StringsRole).isValid())
-    {
-    QCMakeComboBox* editor =
-      new QCMakeComboBox(p, var.data(QCMakeCacheModel::StringsRole).toStringList());
+  } else if (type == QCMakeProperty::STRING &&
+             var.data(QCMakeCacheModel::StringsRole).isValid()) {
+    QCMakeComboBox* editor = new QCMakeComboBox(
+      p, var.data(QCMakeCacheModel::StringsRole).toStringList());
     editor->setFrame(false);
     return editor;
-    }
+  }
 
   QLineEdit* editor = new QLineEdit(p);
   editor->setFrame(false);
   return editor;
 }
 
-bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model,
-       const QStyleOptionViewItem& option, const QModelIndex& index)
+bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
+                                           QAbstractItemModel* model,
+                                           const QStyleOptionViewItem& option,
+                                           const QModelIndex& index)
 {
   Qt::ItemFlags flags = model->flags(index);
-  if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled)
-      || !(flags & Qt::ItemIsEnabled))
-    {
+  if (!(flags & Qt::ItemIsUserCheckable) ||
+      !(option.state & QStyle::State_Enabled) ||
+      !(flags & Qt::ItemIsEnabled)) {
     return false;
-    }
+  }
 
   QVariant value = index.data(Qt::CheckStateRole);
-  if (!value.isValid())
-    {
+  if (!value.isValid()) {
     return false;
-    }
+  }
 
-  if ((e->type() == QEvent::MouseButtonRelease)
-      || (e->type() == QEvent::MouseButtonDblClick))
-    {
+  if ((e->type() == QEvent::MouseButtonRelease) ||
+      (e->type() == QEvent::MouseButtonDblClick)) {
     // eat the double click events inside the check rect
-    if (e->type() == QEvent::MouseButtonDblClick)
-      {
+    if (e->type() == QEvent::MouseButtonDblClick) {
       return true;
-      }
     }
-  else if (e->type() == QEvent::KeyPress)
-    {
-    if(static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
-       static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select)
-      {
+  } else if (e->type() == QEvent::KeyPress) {
+    if (static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
+        static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select) {
       return false;
-      }
     }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 
-  Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
-                          ? Qt::Unchecked : Qt::Checked);
+  Qt::CheckState state =
+    (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked
+                                                               : Qt::Checked);
   bool success = model->setData(index, state, Qt::CheckStateRole);
-  if(success)
-    {
+  if (success) {
     this->recordChange(model, index);
-    }
+  }
   return success;
 }
 
@@ -673,29 +621,32 @@ bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
   // where it doesn't create a QWidget wrapper for the native file dialog
   // so the Qt library ends up assuming the focus was lost to something else
 
-  if(evt->type() == QEvent::FocusOut && this->FileDialogFlag)
-    {
+  if (evt->type() == QEvent::FocusOut && this->FileDialogFlag) {
     return false;
-    }
+  }
   return QItemDelegate::eventFilter(object, evt);
 }
 
 void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
-  QAbstractItemModel* model, const QModelIndex& index ) const
+                                            QAbstractItemModel* model,
+                                            const QModelIndex& index) const
 {
   QItemDelegate::setModelData(editor, model, index);
   const_cast<QCMakeCacheModelDelegate*>(this)->recordChange(model, index);
 }
 
-QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option,
+                                         const QModelIndex& index) const
 {
   QSize sz = QItemDelegate::sizeHint(option, index);
-  QStyle *style = QApplication::style();
+  QStyle* style = QApplication::style();
 
   // increase to checkbox size
   QStyleOptionButton opt;
   opt.QStyleOption::operator=(option);
-  sz = sz.expandedTo(style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL).size());
+  sz = sz.expandedTo(
+    style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL)
+      .size());
 
   return sz;
 }
@@ -710,30 +661,27 @@ void QCMakeCacheModelDelegate::clearChanges()
   mChanges.clear();
 }
 
-void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model, const QModelIndex& index)
+void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model,
+                                            const QModelIndex& index)
 {
   QModelIndex idx = index;
   QAbstractItemModel* mymodel = model;
-  while(qobject_cast<QAbstractProxyModel*>(mymodel))
-    {
+  while (qobject_cast<QAbstractProxyModel*>(mymodel)) {
     idx = static_cast<QAbstractProxyModel*>(mymodel)->mapToSource(idx);
     mymodel = static_cast<QAbstractProxyModel*>(mymodel)->sourceModel();
-    }
+  }
   QCMakeCacheModel* cache_model = qobject_cast<QCMakeCacheModel*>(mymodel);
-  if(cache_model && idx.isValid())
-    {
+  if (cache_model && idx.isValid()) {
     QCMakeProperty prop;
     idx = idx.sibling(idx.row(), 0);
     cache_model->getPropertyData(idx, prop);
 
     // clean out an old one
     QSet<QCMakeProperty>::iterator iter = mChanges.find(prop);
-    if(iter != mChanges.end())
-      {
+    if (iter != mChanges.end()) {
       mChanges.erase(iter);
-      }
+    }
     // now add the new item
     mChanges.insert(prop);
-    }
+  }
 }
-
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index 41f0bd8..6ad56fb 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -14,10 +14,11 @@
 #define QCMakeCacheView_h
 
 #include "QCMake.h"
-#include <QTreeView>
+
+#include <QItemDelegate>
 #include <QSet>
 #include <QStandardItemModel>
-#include <QItemDelegate>
+#include <QTreeView>
 
 class QSortFilterProxyModel;
 class QCMakeCacheModel;
@@ -37,7 +38,7 @@ public:
   // get whether to show advanced entries
   bool showAdvanced() const;
 
-  QSize sizeHint() const { return QSize(200,200); }
+  QSize sizeHint() const { return QSize(200, 200); }
 
 public slots:
   // set whether to show advanced entries
@@ -64,14 +65,20 @@ public:
 
   // roles used to retrieve extra data such has help strings, types of
   // properties, and the advanced flag
-  enum { HelpRole = Qt::ToolTipRole,
-         TypeRole = Qt::UserRole,
-         AdvancedRole,
-         StringsRole,
-         GroupRole
-       };
-
-  enum ViewType { FlatView, GroupView };
+  enum
+  {
+    HelpRole = Qt::ToolTipRole,
+    TypeRole = Qt::UserRole,
+    AdvancedRole,
+    StringsRole,
+    GroupRole
+  };
+
+  enum ViewType
+  {
+    FlatView,
+    GroupView
+  };
 
 public slots:
   // set a list of properties.  This list will be sorted and grouped according
@@ -91,9 +98,9 @@ public slots:
 
   // insert a new property at a row specifying all the information about the
   // property
-  bool insertProperty(QCMakeProperty::PropertyType t,
-                      const QString& name, const QString& description,
-                      const QVariant& value, bool advanced);
+  bool insertProperty(QCMakeProperty::PropertyType t, const QString& name,
+                      const QString& description, const QVariant& value,
+                      bool advanced);
 
   // set the view type
   void setViewType(ViewType t);
@@ -110,12 +117,11 @@ public:
   int newPropertyCount() const;
 
   // return flags (overloaded to modify flag based on EditEnabled flag)
-  Qt::ItemFlags flags (const QModelIndex& index) const;
+  Qt::ItemFlags flags(const QModelIndex& index) const;
   QModelIndex buddy(const QModelIndex& idx) const;
 
   // get the data in the model for this property
-  void getPropertyData(const QModelIndex& idx1,
-                       QCMakeProperty& prop) const;
+  void getPropertyData(const QModelIndex& idx1, QCMakeProperty& prop) const;
 
 protected:
   bool EditEnabled;
@@ -124,17 +130,16 @@ protected:
   ViewType View;
 
   // set the data in the model for this property
-  void setPropertyData(const QModelIndex& idx1,
-                       const QCMakeProperty& p, bool isNew);
+  void setPropertyData(const QModelIndex& idx1, const QCMakeProperty& p,
+                       bool isNew);
 
   // breaks up he property list into groups
   // where each group has the same prefix up to the first underscore
   static void breakProperties(const QSet<QCMakeProperty>& props,
-                       QMap<QString, QCMakePropertyList>& result);
+                              QMap<QString, QCMakePropertyList>& result);
 
   // gets the prefix of a string up to the first _
   static QString prefix(const QString& s);
-
 };
 
 /// Qt delegate class for interaction (or other customization)
@@ -146,18 +151,22 @@ public:
   QCMakeCacheModelDelegate(QObject* p);
   /// create our own editors for cache properties
   QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
-      const QModelIndex& index ) const;
-  bool editorEvent (QEvent* event, QAbstractItemModel* model,
-       const QStyleOptionViewItem& option, const QModelIndex& index);
+                        const QModelIndex& index) const;
+  bool editorEvent(QEvent* event, QAbstractItemModel* model,
+                   const QStyleOptionViewItem& option,
+                   const QModelIndex& index);
   bool eventFilter(QObject* object, QEvent* event);
-  void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const;
-  QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
+  void setModelData(QWidget* editor, QAbstractItemModel* model,
+                    const QModelIndex& index) const;
+  QSize sizeHint(const QStyleOptionViewItem& option,
+                 const QModelIndex& index) const;
 
   QSet<QCMakeProperty> changes() const;
   void clearChanges();
 
 protected slots:
   void setFileDialogFlag(bool);
+
 protected:
   bool FileDialogFlag;
   // record a change to an item in the model.
@@ -169,4 +178,3 @@ protected:
 };
 
 #endif
-
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index 41f98b5..4b3eb34 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -13,29 +13,30 @@
 #include "QCMakeWidgets.h"
 
 #include <QDirModel>
-#include <QFileInfo>
 #include <QFileDialog>
-#include <QToolButton>
+#include <QFileInfo>
 #include <QResizeEvent>
+#include <QToolButton>
 
 QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var)
-  : QLineEdit(p), Variable(var)
+  : QLineEdit(p)
+  , Variable(var)
 {
   this->ToolButton = new QToolButton(this);
   this->ToolButton->setText("...");
   this->ToolButton->setCursor(QCursor(Qt::ArrowCursor));
-  QObject::connect(this->ToolButton, SIGNAL(clicked(bool)),
-                   this, SLOT(chooseFile()));
+  QObject::connect(this->ToolButton, SIGNAL(clicked(bool)), this,
+                   SLOT(chooseFile()));
 }
 
 QCMakeFilePathEditor::QCMakeFilePathEditor(QWidget* p, const QString& var)
- : QCMakeFileEditor(p, var)
+  : QCMakeFileEditor(p, var)
 {
   this->setCompleter(new QCMakeFileCompleter(this, false));
 }
 
 QCMakePathEditor::QCMakePathEditor(QWidget* p, const QString& var)
- : QCMakeFileEditor(p, var)
+  : QCMakeFileEditor(p, var)
 {
   this->setCompleter(new QCMakeFileCompleter(this, true));
 }
@@ -57,24 +58,21 @@ void QCMakeFilePathEditor::chooseFile()
   QString path;
   QFileInfo info(this->text());
   QString title;
-  if(this->Variable.isEmpty())
-    {
+  if (this->Variable.isEmpty()) {
     title = tr("Select File");
-    }
-  else
-    {
+  } else {
     title = tr("Select File for %1");
     title = title.arg(this->Variable);
-    }
+  }
   this->fileDialogExists(true);
-  path = QFileDialog::getOpenFileName(this, title, info.absolutePath(),
-    QString(), NULL, QFileDialog::DontResolveSymlinks);
+  path =
+    QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(),
+                                 NULL, QFileDialog::DontResolveSymlinks);
   this->fileDialogExists(false);
 
-  if(!path.isEmpty())
-    {
+  if (!path.isEmpty()) {
     this->setText(QDir::fromNativeSeparators(path));
-    }
+  }
 }
 
 void QCMakePathEditor::chooseFile()
@@ -82,43 +80,38 @@ void QCMakePathEditor::chooseFile()
   // choose a file and set it
   QString path;
   QString title;
-  if(this->Variable.isEmpty())
-    {
+  if (this->Variable.isEmpty()) {
     title = tr("Select Path");
-    }
-  else
-    {
+  } else {
     title = tr("Select Path for %1");
     title = title.arg(this->Variable);
-    }
+  }
   this->fileDialogExists(true);
   path = QFileDialog::getExistingDirectory(this, title, this->text(),
-    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+                                           QFileDialog::ShowDirsOnly |
+                                             QFileDialog::DontResolveSymlinks);
   this->fileDialogExists(false);
-  if(!path.isEmpty())
-    {
+  if (!path.isEmpty()) {
     this->setText(QDir::fromNativeSeparators(path));
-    }
+  }
 }
 
 // use same QDirModel for all completers
 static QDirModel* fileDirModel()
 {
   static QDirModel* m = NULL;
-  if(!m)
-    {
+  if (!m) {
     m = new QDirModel();
-    }
+  }
   return m;
 }
 static QDirModel* pathDirModel()
 {
   static QDirModel* m = NULL;
-  if(!m)
-    {
+  if (!m) {
     m = new QDirModel();
     m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);
-    }
+  }
   return m;
 }
 
@@ -133,4 +126,3 @@ QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const
 {
   return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx));
 }
-
diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h
index 8f58df2..f1e87ce 100644
--- a/Source/QtDialog/QCMakeWidgets.h
+++ b/Source/QtDialog/QCMakeWidgets.h
@@ -13,9 +13,10 @@
 #ifndef QCMakeWidgets_h
 #define QCMakeWidgets_h
 
-#include <QLineEdit>
 #include <QComboBox>
 #include <QCompleter>
+#include <QLineEdit>
+
 class QToolButton;
 
 // common widgets for Qt based CMake
@@ -30,6 +31,7 @@ protected slots:
   virtual void chooseFile() = 0;
 signals:
   void fileDialogExists(bool);
+
 protected:
   void resizeEvent(QResizeEvent* e);
   QToolButton* ToolButton;
@@ -68,20 +70,20 @@ class QCMakeComboBox : public QComboBox
 {
   Q_OBJECT
   Q_PROPERTY(QString value READ currentText WRITE setValue USER true);
+
 public:
-  QCMakeComboBox(QWidget* p, QStringList strings) : QComboBox(p)
+  QCMakeComboBox(QWidget* p, QStringList strings)
+    : QComboBox(p)
   {
     this->addItems(strings);
   }
   void setValue(const QString& v)
   {
     int i = this->findText(v);
-    if(i != -1)
-    {
+    if (i != -1) {
       this->setCurrentIndex(i);
     }
   }
 };
 
 #endif
-
diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx
index dfcf048..d23a08c 100644
--- a/Source/QtDialog/RegexExplorer.cxx
+++ b/Source/QtDialog/RegexExplorer.cxx
@@ -12,16 +12,16 @@
 
 #include "RegexExplorer.h"
 
-RegexExplorer::RegexExplorer(QWidget* p) : QDialog(p), m_matched(false)
+RegexExplorer::RegexExplorer(QWidget* p)
+  : QDialog(p)
+  , m_matched(false)
 {
   this->setupUi(this);
 
-  for(int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i)
-    {
-    matchNumber->addItem(
-      QString("Match %1").arg(QString::number(i)),
-      QVariant(i));
-    }
+  for (int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i) {
+    matchNumber->addItem(QString("Match %1").arg(QString::number(i)),
+                         QVariant(i));
+  }
   matchNumber->setCurrentIndex(0);
 }
 
@@ -44,10 +44,9 @@ void RegexExplorer::on_regularExpression_textChanged(const QString& text)
 
   bool validExpression =
     stripEscapes(m_regex) && m_regexParser.compile(m_regex);
-  if(!validExpression)
-    {
+  if (!validExpression) {
     m_regexParser.set_invalid();
-    }
+  }
 
   setStatusColor(labelRegexValid, validExpression);
 
@@ -56,8 +55,7 @@ void RegexExplorer::on_regularExpression_textChanged(const QString& text)
 
 void RegexExplorer::on_inputText_textChanged()
 {
-  if(m_regexParser.is_valid())
-    {
+  if (m_regexParser.is_valid()) {
     QString plainText = inputText->toPlainText();
 #ifdef QT_NO_STL
     m_text = plainText.toAscii().constData();
@@ -65,19 +63,16 @@ void RegexExplorer::on_inputText_textChanged()
     m_text = plainText.toStdString();
 #endif
     m_matched = m_regexParser.find(m_text);
-    }
-  else
-    {
+  } else {
     m_matched = false;
-    }
+  }
 
   setStatusColor(labelRegexMatch, m_matched);
 
-  if(!m_matched)
-    {
+  if (!m_matched) {
     clearMatch();
     return;
-    }
+  }
 
 #ifdef QT_NO_STL
   QString matchText = m_regexParser.match(0).c_str();
@@ -91,18 +86,16 @@ void RegexExplorer::on_inputText_textChanged()
 
 void RegexExplorer::on_matchNumber_currentIndexChanged(int index)
 {
-  if(!m_matched)
-    {
+  if (!m_matched) {
     return;
-    }
+  }
 
   QVariant itemData = matchNumber->itemData(index);
   int idx = itemData.toInt();
 
-  if(idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP)
-    {
+  if (idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP) {
     return;
-    }
+  }
 
 #ifdef QT_NO_STL
   QString match = m_regexParser.match(idx).c_str();
@@ -125,42 +118,29 @@ bool RegexExplorer::stripEscapes(std::string& source)
   std::string result;
   result.reserve(source.size());
 
-  for(char inc = *in; inc != '\0'; inc = *++in)
-    {
-    if(inc == '\\')
-      {
+  for (char inc = *in; inc != '\0'; inc = *++in) {
+    if (inc == '\\') {
       char nextc = in[1];
-      if(nextc == 't')
-        {
+      if (nextc == 't') {
         result.append(1, '\t');
         in++;
-        }
-      else if(nextc == 'n')
-        {
+      } else if (nextc == 'n') {
         result.append(1, '\n');
         in++;
-        }
-      else if(nextc == 't')
-        {
+      } else if (nextc == 't') {
         result.append(1, '\t');
         in++;
-        }
-      else if(isalnum(nextc) || nextc == '\0')
-        {
+      } else if (isalnum(nextc) || nextc == '\0') {
         return false;
-        }
-      else
-        {
+      } else {
         result.append(1, nextc);
         in++;
-        }
-      }
-    else
-      {
-        result.append(1, inc);
       }
+    } else {
+      result.append(1, inc);
     }
+  }
 
-    source = result;
-    return true;
+  source = result;
+  return true;
 }
diff --git a/Source/QtDialog/RegexExplorer.h b/Source/QtDialog/RegexExplorer.h
index 2ac9c3e..3ac8a24 100644
--- a/Source/QtDialog/RegexExplorer.h
+++ b/Source/QtDialog/RegexExplorer.h
@@ -13,9 +13,9 @@
 #ifndef RegexExplorer_h
 #define RegexExplorer_h
 
-#include <string>
-#include <cmsys/RegularExpression.hxx>
 #include <QDialog>
+#include <cmsys/RegularExpression.hxx>
+#include <string>
 
 #include "ui_RegexExplorer.h"
 
diff --git a/Source/QtDialog/WarningMessagesDialog.cxx b/Source/QtDialog/WarningMessagesDialog.cxx
index 4bd541f..3be6798 100644
--- a/Source/QtDialog/WarningMessagesDialog.cxx
+++ b/Source/QtDialog/WarningMessagesDialog.cxx
@@ -13,7 +13,8 @@
 #include "WarningMessagesDialog.h"
 
 WarningMessagesDialog::WarningMessagesDialog(QWidget* prnt, QCMake* instance)
-  : QDialog(prnt), cmakeInstance(instance)
+  : QDialog(prnt)
+  , cmakeInstance(instance)
 {
   this->setupUi(this);
   this->setInitialValues();
@@ -35,8 +36,8 @@ void WarningMessagesDialog::setInitialValues()
 
 void WarningMessagesDialog::setupSignals()
 {
-  QObject::connect(this->buttonBox, SIGNAL(accepted()),
-                   this, SLOT(doAccept()));
+  QObject::connect(this->buttonBox, SIGNAL(accepted()), this,
+                   SLOT(doAccept()));
 
   QObject::connect(this->suppressDeveloperWarnings, SIGNAL(stateChanged(int)),
                    this, SLOT(doSuppressDeveloperWarningsChanged(int)));
@@ -65,35 +66,31 @@ void WarningMessagesDialog::doAccept()
 void WarningMessagesDialog::doSuppressDeveloperWarningsChanged(int state)
 {
   // no warnings implies no errors either
-  if (state)
-    {
+  if (state) {
     this->developerWarningsAsErrors->setChecked(false);
-    }
+  }
 }
 
 void WarningMessagesDialog::doSuppressDeprecatedWarningsChanged(int state)
 {
   // no warnings implies no errors either
-  if (state)
-    {
+  if (state) {
     this->deprecatedWarningsAsErrors->setChecked(false);
-    }
+  }
 }
 
 void WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged(int state)
 {
   // warnings as errors implies warnings are not suppressed
-  if (state)
-    {
+  if (state) {
     this->suppressDeveloperWarnings->setChecked(false);
-    }
+  }
 }
 
 void WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged(int state)
 {
   // warnings as errors implies warnings are not suppressed
-  if (state)
-    {
+  if (state) {
     this->suppressDeprecatedWarnings->setChecked(false);
-    }
+  }
 }
diff --git a/Source/QtDialog/WarningMessagesDialog.h b/Source/QtDialog/WarningMessagesDialog.h
index 6c274a7..4bb739c 100644
--- a/Source/QtDialog/WarningMessagesDialog.h
+++ b/Source/QtDialog/WarningMessagesDialog.h
@@ -16,8 +16,8 @@
 #include <QDialog>
 #include <QWidget>
 
-#include "ui_WarningMessagesDialog.h"
 #include "QCMake.h"
+#include "ui_WarningMessagesDialog.h"
 
 /**
  * Dialog window for setting the warning message related options.
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index e7263ae..b179f83 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -72,11 +72,11 @@
 */
 #include "bindexplib.h"
 #include <cmsys/Encoding.hxx>
-#include <windows.h>
-#include <stdio.h>
-#include <string>
 #include <fstream>
 #include <iostream>
+#include <stdio.h>
+#include <string>
+#include <windows.h>
 
 typedef struct cmANON_OBJECT_HEADER_BIGOBJ {
    /* same as ANON_OBJECT_HEADER_V2 */
diff --git a/Source/cmAddCompileOptionsCommand.cxx b/Source/cmAddCompileOptionsCommand.cxx
index a6c3c00..2223cf4 100644
--- a/Source/cmAddCompileOptionsCommand.cxx
+++ b/Source/cmAddCompileOptionsCommand.cxx
@@ -11,18 +11,16 @@
 ============================================================================*/
 #include "cmAddCompileOptionsCommand.h"
 
-bool cmAddCompileOptionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddCompileOptionsCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
 
-  for(std::vector<std::string>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
     this->Makefile->AddCompileOption(i->c_str());
-    }
+  }
   return true;
 }
diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h
index f147ec0..5c073c8 100644
--- a/Source/cmAddCompileOptionsCommand.h
+++ b/Source/cmAddCompileOptionsCommand.h
@@ -20,22 +20,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddCompileOptionsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddCompileOptionsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string 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 fe516ea..d8fd1d8 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -16,18 +16,17 @@
 #include "cmSourceFile.h"
 
 // cmAddCustomCommandCommand
-bool cmAddCustomCommandCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddCustomCommandCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   /* Let's complain at the end of this function about the lack of a particular
      arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
      are required.
   */
-  if (args.size() < 4)
-    {
-      this->SetError("called with wrong number of arguments.");
-      return false;
-    }
+  if (args.size() < 4) {
+    this->SetError("called with wrong number of arguments.");
+    return false;
+  }
 
   std::string source, target, main_dependency, working;
   std::string comment_buffer;
@@ -47,7 +46,8 @@ bool cmAddCustomCommandCommand
 
   cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
 
-  enum tdoing {
+  enum tdoing
+  {
     doing_source,
     doing_command,
     doing_target,
@@ -65,99 +65,58 @@ bool cmAddCustomCommandCommand
 
   tdoing doing = doing_nothing;
 
-  for (unsigned int j = 0; j < args.size(); ++j)
-    {
+  for (unsigned int j = 0; j < args.size(); ++j) {
     std::string const& copy = args[j];
 
-    if(copy == "SOURCE")
-      {
+    if (copy == "SOURCE") {
       doing = doing_source;
-      }
-    else if(copy == "COMMAND")
-      {
+    } else if (copy == "COMMAND") {
       doing = doing_command;
 
       // Save the current command before starting the next command.
-      if(!currentLine.empty())
-        {
+      if (!currentLine.empty()) {
         commandLines.push_back(currentLine);
         currentLine.clear();
-        }
       }
-    else if(copy == "PRE_BUILD")
-      {
+    } else if (copy == "PRE_BUILD") {
       cctype = cmTarget::PRE_BUILD;
-      }
-    else if(copy == "PRE_LINK")
-      {
+    } else if (copy == "PRE_LINK") {
       cctype = cmTarget::PRE_LINK;
-      }
-    else if(copy == "POST_BUILD")
-      {
+    } else if (copy == "POST_BUILD") {
       cctype = cmTarget::POST_BUILD;
-      }
-    else if(copy == "VERBATIM")
-      {
+    } else if (copy == "VERBATIM") {
       verbatim = true;
-      }
-    else if(copy == "APPEND")
-      {
+    } else if (copy == "APPEND") {
       append = true;
-      }
-    else if(copy == "USES_TERMINAL")
-      {
+    } else if (copy == "USES_TERMINAL") {
       uses_terminal = true;
-      }
-    else if(copy == "TARGET")
-      {
+    } else if (copy == "TARGET") {
       doing = doing_target;
-      }
-    else if(copy == "ARGS")
-      {
+    } else if (copy == "ARGS") {
       // Ignore this old keyword.
-      }
-    else if (copy == "DEPENDS")
-      {
+    } else if (copy == "DEPENDS") {
       doing = doing_depends;
-      }
-    else if (copy == "OUTPUTS")
-      {
+    } else if (copy == "OUTPUTS") {
       doing = doing_outputs;
-      }
-    else if (copy == "OUTPUT")
-      {
+    } else if (copy == "OUTPUT") {
       doing = doing_output;
-      }
-    else if (copy == "BYPRODUCTS")
-      {
+    } else if (copy == "BYPRODUCTS") {
       doing = doing_byproducts;
-      }
-    else if (copy == "WORKING_DIRECTORY")
-      {
+    } else if (copy == "WORKING_DIRECTORY") {
       doing = doing_working_directory;
-      }
-    else if (copy == "MAIN_DEPENDENCY")
-      {
+    } else if (copy == "MAIN_DEPENDENCY") {
       doing = doing_main_dependency;
-      }
-    else if (copy == "IMPLICIT_DEPENDS")
-      {
+    } else if (copy == "IMPLICIT_DEPENDS") {
       doing = doing_implicit_depends_lang;
-      }
-    else if (copy == "COMMENT")
-      {
+    } else if (copy == "COMMENT") {
       doing = doing_comment;
-      }
-    else
-      {
+    } else {
       std::string filename;
-      switch (doing)
-        {
+      switch (doing) {
         case doing_output:
         case doing_outputs:
         case doing_byproducts:
-          if (!cmSystemTools::FileIsFullPath(copy.c_str()))
-            {
+          if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
             // This is an output to be generated, so it should be
             // under the build tree.  CMake 2.4 placed this under the
             // source tree.  However the only case that this change
@@ -170,139 +129,124 @@ bool cmAddCustomCommandCommand
             // complain.
             filename = this->Makefile->GetCurrentBinaryDirectory();
             filename += "/";
-            }
+          }
           filename += copy;
           cmSystemTools::ConvertToUnixSlashes(filename);
           break;
         case doing_source:
-          // We do not want to convert the argument to SOURCE because
-          // that option is only available for backward compatibility.
-          // Old-style use of this command may use the SOURCE==TARGET
-          // trick which we must preserve.  If we convert the source
-          // to a full path then it will no longer equal the target.
+        // We do not want to convert the argument to SOURCE because
+        // that option is only available for backward compatibility.
+        // Old-style use of this command may use the SOURCE==TARGET
+        // trick which we must preserve.  If we convert the source
+        // to a full path then it will no longer equal the target.
         default:
           break;
-        }
+      }
 
-      if (cmSystemTools::FileIsFullPath(filename.c_str()))
-        {
+      if (cmSystemTools::FileIsFullPath(filename.c_str())) {
         filename = cmSystemTools::CollapseFullPath(filename);
-        }
-       switch (doing)
-         {
-         case doing_working_directory:
-           working = copy;
-           break;
-         case doing_source:
-           source = copy;
-           break;
-         case doing_output:
-           output.push_back(filename);
-           break;
-         case doing_main_dependency:
-           main_dependency = copy;
-           break;
-         case doing_implicit_depends_lang:
-           implicit_depends_lang = copy;
-           doing = doing_implicit_depends_file;
-           break;
-         case doing_implicit_depends_file:
-           {
-           // An implicit dependency starting point is also an
-           // explicit dependency.
-           std::string dep = copy;
-           cmSystemTools::ConvertToUnixSlashes(dep);
-           depends.push_back(dep);
+      }
+      switch (doing) {
+        case doing_working_directory:
+          working = copy;
+          break;
+        case doing_source:
+          source = copy;
+          break;
+        case doing_output:
+          output.push_back(filename);
+          break;
+        case doing_main_dependency:
+          main_dependency = copy;
+          break;
+        case doing_implicit_depends_lang:
+          implicit_depends_lang = copy;
+          doing = doing_implicit_depends_file;
+          break;
+        case doing_implicit_depends_file: {
+          // An implicit dependency starting point is also an
+          // explicit dependency.
+          std::string dep = copy;
+          cmSystemTools::ConvertToUnixSlashes(dep);
+          depends.push_back(dep);
 
-           // Add the implicit dependency language and file.
-           cmCustomCommand::ImplicitDependsPair
-             entry(implicit_depends_lang, dep);
-           implicit_depends.push_back(entry);
+          // Add the implicit dependency language and file.
+          cmCustomCommand::ImplicitDependsPair entry(implicit_depends_lang,
+                                                     dep);
+          implicit_depends.push_back(entry);
 
-           // Switch back to looking for a language.
-           doing = doing_implicit_depends_lang;
-           }
-           break;
-         case doing_command:
-           currentLine.push_back(copy);
-           break;
-         case doing_target:
-           target = copy;
-           break;
-         case doing_depends:
-           {
-           std::string dep = copy;
-           cmSystemTools::ConvertToUnixSlashes(dep);
-           depends.push_back(dep);
-           }
-           break;
-         case doing_outputs:
-           outputs.push_back(filename);
-           break;
-         case doing_byproducts:
-           byproducts.push_back(filename);
-           break;
-         case doing_comment:
-           comment_buffer = copy;
-           comment = comment_buffer.c_str();
-           break;
-         default:
-           this->SetError("Wrong syntax. Unknown type of argument.");
-           return false;
-         }
+          // Switch back to looking for a language.
+          doing = doing_implicit_depends_lang;
+        } break;
+        case doing_command:
+          currentLine.push_back(copy);
+          break;
+        case doing_target:
+          target = copy;
+          break;
+        case doing_depends: {
+          std::string dep = copy;
+          cmSystemTools::ConvertToUnixSlashes(dep);
+          depends.push_back(dep);
+        } break;
+        case doing_outputs:
+          outputs.push_back(filename);
+          break;
+        case doing_byproducts:
+          byproducts.push_back(filename);
+          break;
+        case doing_comment:
+          comment_buffer = copy;
+          comment = comment_buffer.c_str();
+          break;
+        default:
+          this->SetError("Wrong syntax. Unknown type of argument.");
+          return false;
       }
     }
+  }
 
   // Store the last command line finished.
-  if(!currentLine.empty())
-    {
+  if (!currentLine.empty()) {
     commandLines.push_back(currentLine);
     currentLine.clear();
-    }
+  }
 
   // At this point we could complain about the lack of arguments.  For
   // the moment, let's say that COMMAND, TARGET are always required.
-  if(output.empty() && target.empty())
-    {
+  if (output.empty() && target.empty()) {
     this->SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
     return false;
-    }
+  }
 
-  if(source.empty() && !target.empty() && !output.empty())
-    {
+  if (source.empty() && !target.empty() && !output.empty()) {
     this->SetError(
       "Wrong syntax. A TARGET and OUTPUT can not both be specified.");
     return false;
-    }
-  if(append && output.empty())
-    {
+  }
+  if (append && output.empty()) {
     this->SetError("given APPEND option with no OUTPUT.");
     return false;
-    }
+  }
 
   // Make sure the output names and locations are safe.
-  if(!this->CheckOutputs(output) ||
-     !this->CheckOutputs(outputs) ||
-     !this->CheckOutputs(byproducts))
-    {
+  if (!this->CheckOutputs(output) || !this->CheckOutputs(outputs) ||
+      !this->CheckOutputs(byproducts)) {
     return false;
-    }
+  }
 
   // Check for an append request.
-  if(append)
-    {
+  if (append) {
     // Lookup an existing command.
-    if(cmSourceFile* sf =
-       this->Makefile->GetSourceFileWithOutput(output[0]))
-      {
-      if(cmCustomCommand* cc = sf->GetCustomCommand())
-        {
+    if (cmSourceFile* sf =
+          this->Makefile->GetSourceFileWithOutput(output[0])) {
+      if (cmCustomCommand* cc = sf->GetCustomCommand()) {
         cc->AppendCommands(commandLines);
         cc->AppendDepends(depends);
         cc->AppendImplicitDepends(implicit_depends);
         return true;
-        }
       }
+    }
 
     // No command for this output exists.
     std::ostringstream e;
@@ -310,137 +254,111 @@ bool cmAddCustomCommandCommand
       << "\" which is not already a custom command output.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Convert working directory to a full path.
-  if(!working.empty())
-    {
+  if (!working.empty()) {
     const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
     working = cmSystemTools::CollapseFullPath(working, build_dir);
-    }
+  }
 
   // Choose which mode of the command to use.
   bool escapeOldStyle = !verbatim;
-  if(source.empty() && output.empty())
-    {
+  if (source.empty() && output.empty()) {
     // Source is empty, use the target.
     std::vector<std::string> no_depends;
-    this->Makefile->AddCustomCommandToTarget(target, byproducts, no_depends,
-                                             commandLines, cctype,
-                                             comment, working.c_str(),
-                                             escapeOldStyle, uses_terminal);
-    }
-  else if(target.empty())
-    {
+    this->Makefile->AddCustomCommandToTarget(
+      target, byproducts, no_depends, commandLines, cctype, comment,
+      working.c_str(), escapeOldStyle, uses_terminal);
+  } else if (target.empty()) {
     // Target is empty, use the output.
-    this->Makefile->AddCustomCommandToOutput(output, byproducts,
-                                             depends, main_dependency,
-                                             commandLines, comment,
-                                             working.c_str(), false,
-                                             escapeOldStyle, uses_terminal);
+    this->Makefile->AddCustomCommandToOutput(
+      output, byproducts, depends, main_dependency, commandLines, comment,
+      working.c_str(), false, escapeOldStyle, uses_terminal);
 
     // Add implicit dependency scanning requests if any were given.
-    if(!implicit_depends.empty())
-      {
+    if (!implicit_depends.empty()) {
       bool okay = false;
-      if(cmSourceFile* sf =
-         this->Makefile->GetSourceFileWithOutput(output[0]))
-        {
-        if(cmCustomCommand* cc = sf->GetCustomCommand())
-          {
+      if (cmSourceFile* sf =
+            this->Makefile->GetSourceFileWithOutput(output[0])) {
+        if (cmCustomCommand* cc = sf->GetCustomCommand()) {
           okay = true;
           cc->SetImplicitDepends(implicit_depends);
-          }
         }
-      if(!okay)
-        {
+      }
+      if (!okay) {
         std::ostringstream 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());
         return false;
-        }
       }
     }
-  else if (!byproducts.empty())
-    {
+  } else if (!byproducts.empty()) {
     this->SetError("BYPRODUCTS may not be specified with SOURCE signatures");
     return false;
-    }
-  else if (uses_terminal)
-    {
+  } else if (uses_terminal) {
     this->SetError("USES_TERMINAL may not be used with SOURCE signatures");
     return false;
-    }
-  else
-    {
+  } else {
     bool issueMessage = true;
     std::ostringstream e;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050))
-    {
-    case cmPolicies::WARN:
-      e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
-      break;
-    case cmPolicies::OLD:
-      issueMessage = false;
-      break;
-    case cmPolicies::REQUIRED_ALWAYS:
-    case cmPolicies::REQUIRED_IF_USED:
-    case cmPolicies::NEW:
-      messageType = cmake::FATAL_ERROR;
-      break;
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) {
+      case cmPolicies::WARN:
+        e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
+        break;
+      case cmPolicies::OLD:
+        issueMessage = false;
+        break;
+      case cmPolicies::REQUIRED_ALWAYS:
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::NEW:
+        messageType = cmake::FATAL_ERROR;
+        break;
     }
 
-    if (issueMessage)
-      {
+    if (issueMessage) {
       e << "The SOURCE signatures of add_custom_command are no longer "
            "supported.";
       this->Makefile->IssueMessage(messageType, e.str());
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
+    }
 
     // Use the old-style mode for backward compatibility.
-    this->Makefile->AddCustomCommandOldStyle(target, outputs, depends,
-                                             source, commandLines,
-                                             comment);
-    }
+    this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, source,
+                                             commandLines, comment);
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmAddCustomCommandCommand
-::CheckOutputs(const std::vector<std::string>& outputs)
+bool cmAddCustomCommandCommand::CheckOutputs(
+  const std::vector<std::string>& outputs)
 {
-  for(std::vector<std::string>::const_iterator o = outputs.begin();
-      o != outputs.end(); ++o)
-    {
+  for (std::vector<std::string>::const_iterator o = outputs.begin();
+       o != outputs.end(); ++o) {
     // Make sure the file will not be generated into the source
     // directory during an out of source build.
-    if(!this->Makefile->CanIWriteThisFile(o->c_str()))
-      {
+    if (!this->Makefile->CanIWriteThisFile(o->c_str())) {
       std::string e = "attempted to have a file \"" + *o +
         "\" in a source directory as an output of custom command.";
       this->SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
-      }
+    }
 
     // Make sure the output file name has no invalid characters.
     std::string::size_type pos = o->find_first_of("#<>");
-    if(pos != o->npos)
-      {
+    if (pos != o->npos) {
       std::ostringstream msg;
       msg << "called with OUTPUT containing a \"" << (*o)[pos]
           << "\".  This character is not allowed.";
       this->SetError(msg.str());
       return false;
-      }
     }
+  }
   return true;
 }
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index 1d6ddb2..ccbd50c 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -26,27 +26,24 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddCustomCommandCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddCustomCommandCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "add_custom_command";}
+  virtual std::string GetName() const { return "add_custom_command"; }
 
   cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
+
 protected:
   bool CheckOutputs(const std::vector<std::string>& outputs);
 };
 
-
 #endif
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 42bd71c..ac08cb2 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -15,28 +15,25 @@
 #include "cmGlobalGenerator.h"
 
 // cmAddCustomTargetCommand
-bool cmAddCustomTargetCommand
-::InitialPass(std::vector<std::string> const& args,
-              cmExecutionStatus&)
+bool cmAddCustomTargetCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string targetName = args[0];
 
   // Check the target name.
-  if(targetName.find_first_of("/\\") != targetName.npos)
-    {
+  if (targetName.find_first_of("/\\") != targetName.npos) {
     std::ostringstream e;
     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());
     return false;
-    }
+  }
 
   // Accumulate one command line at a time.
   cmCustomCommandLine currentLine;
@@ -54,7 +51,8 @@ bool cmAddCustomTargetCommand
   std::vector<std::string> sources;
 
   // Keep track of parser state.
-  enum tdoing {
+  enum tdoing
+  {
     doing_command,
     doing_depends,
     doing_byproducts,
@@ -68,131 +66,100 @@ bool cmAddCustomTargetCommand
   // Look for the ALL option.
   bool excludeFromAll = true;
   unsigned int start = 1;
-  if(args.size() > 1)
-    {
-    if(args[1] == "ALL")
-      {
+  if (args.size() > 1) {
+    if (args[1] == "ALL") {
       excludeFromAll = false;
       start = 2;
-      }
     }
+  }
 
   // Parse the rest of the arguments.
-  for(unsigned int j = start; j < args.size(); ++j)
-    {
+  for (unsigned int j = start; j < args.size(); ++j) {
     std::string const& copy = args[j];
 
-    if(copy == "DEPENDS")
-      {
+    if (copy == "DEPENDS") {
       doing = doing_depends;
-      }
-    else if(copy == "BYPRODUCTS")
-      {
+    } else if (copy == "BYPRODUCTS") {
       doing = doing_byproducts;
-      }
-    else if(copy == "WORKING_DIRECTORY")
-      {
+    } else if (copy == "WORKING_DIRECTORY") {
       doing = doing_working_directory;
-      }
-    else if(copy == "VERBATIM")
-      {
+    } else if (copy == "VERBATIM") {
       doing = doing_nothing;
       verbatim = true;
-      }
-    else if(copy == "USES_TERMINAL")
-      {
+    } else if (copy == "USES_TERMINAL") {
       doing = doing_nothing;
       uses_terminal = true;
-      }
-    else if (copy == "COMMENT")
-      {
+    } else if (copy == "COMMENT") {
       doing = doing_comment;
-      }
-    else if(copy == "COMMAND")
-      {
+    } else if (copy == "COMMAND") {
       doing = doing_command;
 
       // Save the current command before starting the next command.
-      if(!currentLine.empty())
-        {
+      if (!currentLine.empty()) {
         commandLines.push_back(currentLine);
         currentLine.clear();
-        }
       }
-    else if(copy == "SOURCES")
-      {
+    } else if (copy == "SOURCES") {
       doing = doing_source;
-      }
-    else
-      {
-      switch (doing)
-        {
+    } else {
+      switch (doing) {
         case doing_working_directory:
           working_directory = copy;
           break;
         case doing_command:
           currentLine.push_back(copy);
           break;
-        case doing_byproducts:
-          {
+        case doing_byproducts: {
           std::string filename;
-          if (!cmSystemTools::FileIsFullPath(copy.c_str()))
-            {
+          if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
             filename = this->Makefile->GetCurrentBinaryDirectory();
             filename += "/";
-            }
+          }
           filename += copy;
           cmSystemTools::ConvertToUnixSlashes(filename);
           byproducts.push_back(filename);
-          }
-          break;
-        case doing_depends:
-          {
+        } break;
+        case doing_depends: {
           std::string dep = copy;
           cmSystemTools::ConvertToUnixSlashes(dep);
           depends.push_back(dep);
-          }
+        } break;
+        case doing_comment:
+          comment_buffer = copy;
+          comment = comment_buffer.c_str();
           break;
-         case doing_comment:
-           comment_buffer = copy;
-           comment = comment_buffer.c_str();
-           break;
         case doing_source:
           sources.push_back(copy);
           break;
         default:
           this->SetError("Wrong syntax. Unknown type of argument.");
           return false;
-        }
       }
     }
+  }
 
   std::string::size_type pos = targetName.find_first_of("#<>");
-  if(pos != targetName.npos)
-    {
+  if (pos != targetName.npos) {
     std::ostringstream msg;
     msg << "called with target name containing a \"" << targetName[pos]
         << "\".  This character is not allowed.";
     this->SetError(msg.str());
     return false;
-    }
+  }
 
   // Some requirements on custom target names already exist
   // and have been checked at this point.
   // The following restrictions overlap but depend on policy CMP0037.
   bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) &&
     !cmGlobalGenerator::IsReservedTarget(targetName);
-  if (nameOk)
-    {
+  if (nameOk) {
     nameOk = targetName.find(":") == std::string::npos;
-    }
-  if (!nameOk)
-    {
+  }
+  if (!nameOk) {
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
     std::ostringstream e;
     bool issueMessage = false;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
         issueMessage = true;
@@ -203,68 +170,62 @@ bool cmAddCustomTargetCommand
       case cmPolicies::REQUIRED_ALWAYS:
         issueMessage = true;
         messageType = cmake::FATAL_ERROR;
-      }
-    if (issueMessage)
-      {
+    }
+    if (issueMessage) {
+      /* clang-format off */
       e << "The target name \"" << targetName <<
           "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
+      /* clang-format on */
       this->Makefile->IssueMessage(messageType, e.str());
 
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
+  }
 
   // Store the last command line finished.
-  if(!currentLine.empty())
-    {
+  if (!currentLine.empty()) {
     commandLines.push_back(currentLine);
     currentLine.clear();
-    }
+  }
 
   // Enforce name uniqueness.
   {
-  std::string msg;
-  if(!this->Makefile->EnforceUniqueName(targetName, msg, true))
-    {
-    this->SetError(msg);
-    return false;
+    std::string msg;
+    if (!this->Makefile->EnforceUniqueName(targetName, msg, true)) {
+      this->SetError(msg);
+      return false;
     }
   }
 
   // Convert working directory to a full path.
-  if(!working_directory.empty())
-    {
+  if (!working_directory.empty()) {
     const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
     working_directory =
       cmSystemTools::CollapseFullPath(working_directory, build_dir);
-    }
+  }
 
-  if (commandLines.empty() && !byproducts.empty())
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+  if (commandLines.empty() && !byproducts.empty()) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
       "BYPRODUCTS may not be specified without any COMMAND");
     return true;
-    }
-  if (commandLines.empty() && uses_terminal)
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+  }
+  if (commandLines.empty() && uses_terminal) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
       "USES_TERMINAL may not be specified without any COMMAND");
     return true;
-    }
+  }
 
   // Add the utility target to the makefile.
   bool escapeOldStyle = !verbatim;
-  cmTarget* target =
-    this->Makefile->AddUtilityCommand(targetName, excludeFromAll,
-                                      working_directory.c_str(),
-                                      byproducts, depends,
-                                      commandLines, escapeOldStyle, comment,
-                                      uses_terminal);
+  cmTarget* target = this->Makefile->AddUtilityCommand(
+    targetName, excludeFromAll, working_directory.c_str(), byproducts, depends,
+    commandLines, escapeOldStyle, comment, uses_terminal);
 
   // Add additional user-specified source files to the target.
   target->AddSources(sources);
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index d2b00ad..9c376c0 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -27,23 +27,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddCustomTargetCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddCustomTargetCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const
-    {return "add_custom_target";}
+  virtual std::string GetName() const { return "add_custom_target"; }
 
   cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
 };
diff --git a/Source/cmAddDefinitionsCommand.cxx b/Source/cmAddDefinitionsCommand.cxx
index b813e3e..2d0d026 100644
--- a/Source/cmAddDefinitionsCommand.cxx
+++ b/Source/cmAddDefinitionsCommand.cxx
@@ -12,20 +12,17 @@
 #include "cmAddDefinitionsCommand.h"
 
 // cmAddDefinitionsCommand
-bool cmAddDefinitionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
   // it is OK to have no arguments
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
 
-  for(std::vector<std::string>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
     this->Makefile->AddDefineFlag(i->c_str());
-    }
+  }
   return true;
 }
-
diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h
index 9800fd2..959ed64 100644
--- a/Source/cmAddDefinitionsCommand.h
+++ b/Source/cmAddDefinitionsCommand.h
@@ -26,26 +26,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddDefinitionsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddDefinitionsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "add_definitions";}
+  virtual std::string GetName() const { return "add_definitions"; }
 
   cmTypeMacro(cmAddDefinitionsCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 01e5253..5cf9d3b 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -10,37 +10,32 @@
   See the License for more information.
 ============================================================================*/
 #include "cmAddDependenciesCommand.h"
+
 #include "cmGlobalGenerator.h"
 
 // cmDependenciesCommand
-bool cmAddDependenciesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddDependenciesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string target_name = args[0];
-  if(this->Makefile->IsAlias(target_name))
-    {
+  if (this->Makefile->IsAlias(target_name)) {
     std::ostringstream e;
     e << "Cannot add target-level dependencies to alias target \""
       << target_name << "\".\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
-  if(cmTarget* target = this->Makefile->FindTargetToUse(target_name))
-    {
+  }
+  if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) {
     std::vector<std::string>::const_iterator s = args.begin();
     ++s; // skip over target_name
-    for (; s != args.end(); ++s)
-      {
+    for (; s != args.end(); ++s) {
       target->AddUtility(*s, this->Makefile);
-      }
     }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << "Cannot add target-level dependencies to non-existent target \""
       << target_name << "\".\n"
@@ -49,8 +44,7 @@ bool cmAddDependenciesCommand
       << "If you want to add file-level dependencies see the DEPENDS option "
       << "of the add_custom_target and add_custom_command commands.";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
+  }
 
   return true;
 }
-
diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h
index db3712a..202d072 100644
--- a/Source/cmAddDependenciesCommand.h
+++ b/Source/cmAddDependenciesCommand.h
@@ -25,25 +25,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddDependenciesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddDependenciesCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_dependencies";}
+  virtual std::string GetName() const { return "add_dependencies"; }
 
   cmTypeMacro(cmAddDependenciesCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index a84bb9d..fec5eb8 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -12,14 +12,13 @@
 #include "cmAddExecutableCommand.h"
 
 // cmExecutableCommand
-bool cmAddExecutableCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::vector<std::string>::const_iterator s = args.begin();
 
   std::string exename = *s;
@@ -31,58 +30,41 @@ bool cmAddExecutableCommand
   bool importTarget = false;
   bool importGlobal = false;
   bool isAlias = false;
-  while ( s != args.end() )
-    {
-    if (*s == "WIN32")
-      {
+  while (s != args.end()) {
+    if (*s == "WIN32") {
       ++s;
       use_win32 = true;
-      }
-    else if ( *s == "MACOSX_BUNDLE" )
-      {
+    } else if (*s == "MACOSX_BUNDLE") {
       ++s;
       use_macbundle = true;
-      }
-    else if(*s == "EXCLUDE_FROM_ALL")
-      {
+    } else if (*s == "EXCLUDE_FROM_ALL") {
       ++s;
       excludeFromAll = true;
-      }
-    else if(*s == "IMPORTED")
-     {
-     ++s;
-     importTarget = true;
-     }
-    else if(importTarget && *s == "GLOBAL")
-      {
+    } else if (*s == "IMPORTED") {
+      ++s;
+      importTarget = true;
+    } else if (importTarget && *s == "GLOBAL") {
       ++s;
       importGlobal = true;
-      }
-    else if(*s == "ALIAS")
-      {
+    } else if (*s == "ALIAS") {
       ++s;
       isAlias = true;
-      }
-    else
-      {
+    } else {
       break;
-      }
     }
+  }
 
   bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) &&
     !cmGlobalGenerator::IsReservedTarget(exename);
 
-  if (nameOk && !importTarget && !isAlias)
-    {
+  if (nameOk && !importTarget && !isAlias) {
     nameOk = exename.find(":") == std::string::npos;
-    }
-  if (!nameOk)
-    {
+  }
+  if (!nameOk) {
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
     std::ostringstream e;
     bool issueMessage = false;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
         issueMessage = true;
@@ -93,156 +75,134 @@ bool cmAddExecutableCommand
       case cmPolicies::REQUIRED_ALWAYS:
         issueMessage = true;
         messageType = cmake::FATAL_ERROR;
-      }
-    if (issueMessage)
-      {
+    }
+    if (issueMessage) {
+      /* clang-format off */
       e << "The target name \"" << exename <<
           "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
+      /* clang-format on */
       this->Makefile->IssueMessage(messageType, e.str());
 
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
+  }
 
   // Special modifiers are not allowed with IMPORTED signature.
-  if(importTarget
-      && (use_win32 || use_macbundle || excludeFromAll))
-    {
-    if(use_win32)
-      {
+  if (importTarget && (use_win32 || use_macbundle || excludeFromAll)) {
+    if (use_win32) {
       this->SetError("may not be given WIN32 for an IMPORTED target.");
-      }
-    else if(use_macbundle)
-      {
-      this->SetError(
-        "may not be given MACOSX_BUNDLE for an IMPORTED target.");
-      }
-    else // if(excludeFromAll)
-      {
+    } else if (use_macbundle) {
+      this->SetError("may not be given MACOSX_BUNDLE for an IMPORTED target.");
+    } else // if(excludeFromAll)
+    {
       this->SetError(
         "may not be given EXCLUDE_FROM_ALL for an IMPORTED target.");
-      }
-    return false;
     }
-  if (isAlias)
-    {
-    if(!cmGeneratorExpression::IsValidTargetName(exename))
-      {
+    return false;
+  }
+  if (isAlias) {
+    if (!cmGeneratorExpression::IsValidTargetName(exename)) {
       this->SetError("Invalid name for ALIAS: " + exename);
       return false;
-      }
-    if(excludeFromAll)
-      {
+    }
+    if (excludeFromAll) {
       this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
       return false;
-      }
-    if(importTarget || importGlobal)
-      {
+    }
+    if (importTarget || importGlobal) {
       this->SetError("IMPORTED with ALIAS is not allowed.");
       return false;
-      }
-    if(args.size() != 3)
-      {
+    }
+    if (args.size() != 3) {
       std::ostringstream e;
       e << "ALIAS requires exactly one target argument.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
-    const char *aliasedName = s->c_str();
-    if(this->Makefile->IsAlias(aliasedName))
-      {
+    const char* aliasedName = s->c_str();
+    if (this->Makefile->IsAlias(aliasedName)) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << exename
-        << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+      e << "cannot create ALIAS target \"" << exename << "\" because target \""
+        << aliasedName << "\" is itself an ALIAS.";
       this->SetError(e.str());
       return false;
-      }
-    cmTarget *aliasedTarget =
-                    this->Makefile->FindTargetToUse(aliasedName, true);
-    if(!aliasedTarget)
-      {
+    }
+    cmTarget* aliasedTarget =
+      this->Makefile->FindTargetToUse(aliasedName, true);
+    if (!aliasedTarget) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << exename
-        << "\" because target \"" << aliasedName << "\" does not already "
-        "exist.";
+      e << "cannot create ALIAS target \"" << exename << "\" because target \""
+        << aliasedName << "\" does not already "
+                          "exist.";
       this->SetError(e.str());
       return false;
-      }
+    }
     cmState::TargetType type = aliasedTarget->GetType();
-    if(type != cmState::EXECUTABLE)
-      {
+    if (type != cmState::EXECUTABLE) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << exename
-        << "\" because target \"" << aliasedName << "\" is not an "
-        "executable.";
+      e << "cannot create ALIAS target \"" << exename << "\" because target \""
+        << aliasedName << "\" is not an "
+                          "executable.";
       this->SetError(e.str());
       return false;
-      }
-    if(aliasedTarget->IsImported())
-      {
+    }
+    if (aliasedTarget->IsImported()) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << exename
-        << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+      e << "cannot create ALIAS target \"" << exename << "\" because target \""
+        << aliasedName << "\" is IMPORTED.";
       this->SetError(e.str());
       return false;
-      }
+    }
     this->Makefile->AddAlias(exename, aliasedName);
     return true;
-    }
+  }
 
   // Handle imported target creation.
-  if(importTarget)
-    {
+  if (importTarget) {
     // Make sure the target does not already exist.
-    if(this->Makefile->FindTargetToUse(exename))
-      {
+    if (this->Makefile->FindTargetToUse(exename)) {
       std::ostringstream e;
       e << "cannot create imported target \"" << exename
         << "\" because another target with the same name already exists.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
     // Create the imported target.
     this->Makefile->AddImportedTarget(exename, cmState::EXECUTABLE,
                                       importGlobal);
     return true;
-    }
+  }
 
   // Enforce name uniqueness.
   {
-  std::string msg;
-  if(!this->Makefile->EnforceUniqueName(exename, msg))
-    {
-    this->SetError(msg);
-    return false;
+    std::string msg;
+    if (!this->Makefile->EnforceUniqueName(exename, msg)) {
+      this->SetError(msg);
+      return false;
     }
   }
 
-  if (s == args.end())
-    {
-    this->SetError
-      ("called with incorrect number of arguments, no sources provided");
+  if (s == args.end()) {
+    this->SetError(
+      "called with incorrect number of arguments, no sources provided");
     return false;
-    }
+  }
 
   std::vector<std::string> srclists(s, args.end());
-  cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists,
-                                                excludeFromAll);
-  if ( use_win32 )
-    {
+  cmTarget* tgt =
+    this->Makefile->AddExecutable(exename.c_str(), srclists, excludeFromAll);
+  if (use_win32) {
     tgt->SetProperty("WIN32_EXECUTABLE", "ON");
-    }
-  if ( use_macbundle)
-    {
+  }
+  if (use_macbundle) {
     tgt->SetProperty("MACOSX_BUNDLE", "ON");
-    }
+  }
 
   return true;
 }
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index e134077..1e3181f 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -26,25 +26,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddExecutableCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddExecutableCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_executable";}
+  virtual std::string GetName() const { return "add_executable"; }
 
   cmTypeMacro(cmAddExecutableCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 5296cbb..4516ed2 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -11,25 +11,24 @@
 ============================================================================*/
 #include "cmAddLibraryCommand.h"
 
-#include "cmake.h"
 #include "cmState.h"
+#include "cmake.h"
 
 // cmLibraryCommand
-bool cmAddLibraryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
+                                      cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   // Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
   // otherwise it defaults to static library.
   cmState::TargetType type = cmState::SHARED_LIBRARY;
-  if (cmSystemTools::IsOff(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
-    {
+  if (cmSystemTools::IsOff(
+        this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
     type = cmState::STATIC_LIBRARY;
-    }
+  }
   bool excludeFromAll = false;
   bool importTarget = false;
   bool importGlobal = false;
@@ -45,186 +44,145 @@ bool cmAddLibraryCommand
   // source list name. There may be two keyword arguments, check for them
   bool haveSpecifiedType = false;
   bool isAlias = false;
-  while ( s != args.end() )
-    {
+  while (s != args.end()) {
     std::string libType = *s;
-    if(libType == "STATIC")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    if (libType == "STATIC") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting STATIC type.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       type = cmState::STATIC_LIBRARY;
       haveSpecifiedType = true;
-      }
-    else if(libType == "SHARED")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    } else if (libType == "SHARED") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting SHARED type.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       type = cmState::SHARED_LIBRARY;
       haveSpecifiedType = true;
-      }
-    else if(libType == "MODULE")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    } else if (libType == "MODULE") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting MODULE type.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       type = cmState::MODULE_LIBRARY;
       haveSpecifiedType = true;
-      }
-    else if(libType == "OBJECT")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    } else if (libType == "OBJECT") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting OBJECT type.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       type = cmState::OBJECT_LIBRARY;
       haveSpecifiedType = true;
-      }
-    else if(libType == "UNKNOWN")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    } else if (libType == "UNKNOWN") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting UNKNOWN type.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       type = cmState::UNKNOWN_LIBRARY;
       haveSpecifiedType = true;
-      }
-    else if(libType == "ALIAS")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    } else if (libType == "ALIAS") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting ALIAS type.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       isAlias = true;
-      }
-    else if(libType == "INTERFACE")
-      {
-      if (haveSpecifiedType)
-        {
+    } else if (libType == "INTERFACE") {
+      if (haveSpecifiedType) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting/multiple types.";
         this->SetError(e.str());
         return false;
-        }
-      if (isAlias)
-        {
+      }
+      if (isAlias) {
         std::ostringstream e;
         e << "INTERFACE library specified with conflicting ALIAS type.";
         this->SetError(e.str());
         return false;
-        }
-      if (excludeFromAll)
-        {
+      }
+      if (excludeFromAll) {
         std::ostringstream e;
         e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       type = cmState::INTERFACE_LIBRARY;
       haveSpecifiedType = true;
-      }
-    else if(*s == "EXCLUDE_FROM_ALL")
-      {
-      if (type == cmState::INTERFACE_LIBRARY)
-        {
+    } else if (*s == "EXCLUDE_FROM_ALL") {
+      if (type == cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
         this->SetError(e.str());
         return false;
-        }
+      }
       ++s;
       excludeFromAll = true;
-      }
-    else if(*s == "IMPORTED")
-      {
+    } else if (*s == "IMPORTED") {
       ++s;
       importTarget = true;
-      }
-    else if(importTarget && *s == "GLOBAL")
-      {
+    } else if (importTarget && *s == "GLOBAL") {
       ++s;
       importGlobal = true;
-      }
-    else if(type == cmState::INTERFACE_LIBRARY && *s == "GLOBAL")
-      {
+    } else if (type == cmState::INTERFACE_LIBRARY && *s == "GLOBAL") {
       std::ostringstream e;
       e << "GLOBAL option may only be used with IMPORTED libraries.";
       this->SetError(e.str());
       return false;
-      }
-    else
-      {
+    } else {
       break;
-      }
     }
+  }
 
-  if (type == cmState::INTERFACE_LIBRARY)
-    {
-    if (s != args.end())
-      {
+  if (type == cmState::INTERFACE_LIBRARY) {
+    if (s != args.end()) {
       std::ostringstream e;
       e << "INTERFACE library requires no source arguments.";
       this->SetError(e.str());
       return false;
-      }
-    if (importGlobal && !importTarget)
-      {
+    }
+    if (importGlobal && !importTarget) {
       std::ostringstream e;
       e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) &&
     !cmGlobalGenerator::IsReservedTarget(libName);
 
-  if (nameOk && !importTarget && !isAlias)
-    {
+  if (nameOk && !importTarget && !isAlias) {
     nameOk = libName.find(":") == std::string::npos;
-    }
-  if (!nameOk)
-    {
+  }
+  if (!nameOk) {
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
     std::ostringstream e;
     bool issueMessage = false;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
       case cmPolicies::WARN:
-        if(type != cmState::INTERFACE_LIBRARY)
-          {
+        if (type != cmState::INTERFACE_LIBRARY) {
           e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
           issueMessage = true;
-          }
+        }
       case cmPolicies::OLD:
         break;
       case cmPolicies::NEW:
@@ -232,208 +190,177 @@ bool cmAddLibraryCommand
       case cmPolicies::REQUIRED_ALWAYS:
         issueMessage = true;
         messageType = cmake::FATAL_ERROR;
-      }
-    if (issueMessage)
-      {
-      e << "The target name \"" << libName <<
-          "\" is reserved or not valid for certain "
-          "CMake features, such as generator expressions, and may result "
-          "in undefined behavior.";
+    }
+    if (issueMessage) {
+      e << "The target name \"" << libName
+        << "\" 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());
 
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
+  }
 
-  if (isAlias)
-    {
-    if(!cmGeneratorExpression::IsValidTargetName(libName))
-      {
+  if (isAlias) {
+    if (!cmGeneratorExpression::IsValidTargetName(libName)) {
       this->SetError("Invalid name for ALIAS: " + libName);
       return false;
-      }
-    if(excludeFromAll)
-      {
+    }
+    if (excludeFromAll) {
       this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
       return false;
-      }
-    if(importTarget || importGlobal)
-      {
+    }
+    if (importTarget || importGlobal) {
       this->SetError("IMPORTED with ALIAS is not allowed.");
       return false;
-      }
-    if(args.size() != 3)
-      {
+    }
+    if (args.size() != 3) {
       std::ostringstream e;
       e << "ALIAS requires exactly one target argument.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
-    const char *aliasedName = s->c_str();
-    if(this->Makefile->IsAlias(aliasedName))
-      {
+    const char* aliasedName = s->c_str();
+    if (this->Makefile->IsAlias(aliasedName)) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << libName
-        << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
+      e << "cannot create ALIAS target \"" << libName << "\" because target \""
+        << aliasedName << "\" is itself an ALIAS.";
       this->SetError(e.str());
       return false;
-      }
-    cmTarget *aliasedTarget =
-                    this->Makefile->FindTargetToUse(aliasedName, true);
-    if(!aliasedTarget)
-      {
+    }
+    cmTarget* aliasedTarget =
+      this->Makefile->FindTargetToUse(aliasedName, true);
+    if (!aliasedTarget) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << libName
-        << "\" because target \"" << aliasedName << "\" does not already "
-        "exist.";
+      e << "cannot create ALIAS target \"" << libName << "\" because target \""
+        << aliasedName << "\" does not already "
+                          "exist.";
       this->SetError(e.str());
       return false;
-      }
+    }
     cmState::TargetType aliasedType = aliasedTarget->GetType();
-    if(aliasedType != cmState::SHARED_LIBRARY
-        && aliasedType != cmState::STATIC_LIBRARY
-        && aliasedType != cmState::MODULE_LIBRARY
-        && aliasedType != cmState::OBJECT_LIBRARY
-        && aliasedType != cmState::INTERFACE_LIBRARY)
-      {
+    if (aliasedType != cmState::SHARED_LIBRARY &&
+        aliasedType != cmState::STATIC_LIBRARY &&
+        aliasedType != cmState::MODULE_LIBRARY &&
+        aliasedType != cmState::OBJECT_LIBRARY &&
+        aliasedType != cmState::INTERFACE_LIBRARY) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << libName
-        << "\" because target \"" << aliasedName << "\" is not a library.";
+      e << "cannot create ALIAS target \"" << libName << "\" because target \""
+        << aliasedName << "\" is not a library.";
       this->SetError(e.str());
       return false;
-      }
-    if(aliasedTarget->IsImported())
-      {
+    }
+    if (aliasedTarget->IsImported()) {
       std::ostringstream e;
-      e << "cannot create ALIAS target \"" << libName
-        << "\" because target \"" << aliasedName << "\" is IMPORTED.";
+      e << "cannot create ALIAS target \"" << libName << "\" because target \""
+        << aliasedName << "\" is IMPORTED.";
       this->SetError(e.str());
       return false;
-      }
+    }
     this->Makefile->AddAlias(libName, aliasedName);
     return true;
-    }
+  }
 
-  if(importTarget && excludeFromAll)
-    {
+  if (importTarget && excludeFromAll) {
     this->SetError("excludeFromAll with IMPORTED target makes no sense.");
     return false;
-    }
+  }
 
   /* ideally we should check whether for the linker language of the target
     CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
     STATIC. But at this point we know only the name of the target, but not
     yet its linker language. */
-  if ((type == cmState::SHARED_LIBRARY ||
-       type == cmState::MODULE_LIBRARY) &&
-       (this->Makefile->GetState()->GetGlobalPropertyAsBool(
-                                      "TARGET_SUPPORTS_SHARED_LIBS") == false))
-    {
+  if ((type == cmState::SHARED_LIBRARY || type == cmState::MODULE_LIBRARY) &&
+      (this->Makefile->GetState()->GetGlobalPropertyAsBool(
+         "TARGET_SUPPORTS_SHARED_LIBS") == false)) {
     std::ostringstream w;
-    w <<
-      "ADD_LIBRARY called with " <<
-      (type==cmState::SHARED_LIBRARY ? "SHARED" : "MODULE") <<
-      " option but the target platform does not support dynamic linking. "
-      "Building a STATIC library instead. This may lead to problems.";
+    w << "ADD_LIBRARY called with "
+      << (type == cmState::SHARED_LIBRARY ? "SHARED" : "MODULE")
+      << " option but the target platform does not support dynamic linking. "
+         "Building a STATIC library instead. This may lead to problems.";
     this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
     type = cmState::STATIC_LIBRARY;
-    }
+  }
 
   // Handle imported target creation.
-  if(importTarget)
-    {
+  if (importTarget) {
     // The IMPORTED signature requires a type to be specified explicitly.
-    if (!haveSpecifiedType)
-      {
+    if (!haveSpecifiedType) {
       this->SetError("called with IMPORTED argument but no library type.");
       return false;
-      }
-    if(type == cmState::OBJECT_LIBRARY)
-      {
+    }
+    if (type == cmState::OBJECT_LIBRARY) {
       this->Makefile->IssueMessage(
         cmake::FATAL_ERROR,
-        "The OBJECT library type may not be used for IMPORTED libraries."
-        );
+        "The OBJECT library type may not be used for IMPORTED libraries.");
       return true;
-      }
-    if(type == cmState::INTERFACE_LIBRARY)
-      {
-      if (!cmGeneratorExpression::IsValidTargetName(libName))
-        {
+    }
+    if (type == cmState::INTERFACE_LIBRARY) {
+      if (!cmGeneratorExpression::IsValidTargetName(libName)) {
         std::ostringstream e;
         e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
         this->SetError(e.str());
         return false;
-        }
       }
+    }
 
     // Make sure the target does not already exist.
-    if(this->Makefile->FindTargetToUse(libName))
-      {
+    if (this->Makefile->FindTargetToUse(libName)) {
       std::ostringstream e;
       e << "cannot create imported target \"" << libName
         << "\" because another target with the same name already exists.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
     // Create the imported target.
     this->Makefile->AddImportedTarget(libName, type, importGlobal);
     return true;
-    }
+  }
 
   // A non-imported target may not have UNKNOWN type.
-  if(type == cmState::UNKNOWN_LIBRARY)
-    {
+  if (type == cmState::UNKNOWN_LIBRARY) {
     this->Makefile->IssueMessage(
       cmake::FATAL_ERROR,
-      "The UNKNOWN library type may be used only for IMPORTED libraries."
-      );
+      "The UNKNOWN library type may be used only for IMPORTED libraries.");
     return true;
-    }
+  }
 
   // Enforce name uniqueness.
   {
-  std::string msg;
-  if(!this->Makefile->EnforceUniqueName(libName, msg))
-    {
-    this->SetError(msg);
-    return false;
+    std::string msg;
+    if (!this->Makefile->EnforceUniqueName(libName, msg)) {
+      this->SetError(msg);
+      return false;
     }
   }
 
   std::vector<std::string> srclists;
 
-  if(type == cmState::INTERFACE_LIBRARY)
-    {
-    if (!cmGeneratorExpression::IsValidTargetName(libName)
-        || libName.find("::") != std::string::npos)
-      {
+  if (type == cmState::INTERFACE_LIBRARY) {
+    if (!cmGeneratorExpression::IsValidTargetName(libName) ||
+        libName.find("::") != std::string::npos) {
       std::ostringstream e;
       e << "Invalid name for INTERFACE library target: " << libName;
       this->SetError(e.str());
       return false;
-      }
+    }
 
-    this->Makefile->AddLibrary(libName,
-                               type,
-                               srclists,
-                               excludeFromAll);
+    this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
     return true;
-    }
+  }
 
-  if (s == args.end())
-    {
+  if (s == args.end()) {
     std::string msg = "You have called ADD_LIBRARY for library ";
     msg += args[0];
     msg += " without any source files. This typically indicates a problem ";
     msg += "with your CMakeLists.txt file";
-    cmSystemTools::Message(msg.c_str() ,"Warning");
-    }
+    cmSystemTools::Message(msg.c_str(), "Warning");
+  }
 
   srclists.insert(srclists.end(), s, args.end());
 
@@ -441,5 +368,3 @@ bool cmAddLibraryCommand
 
   return true;
 }
-
-
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index 350708b..0f0f768 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -26,25 +26,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddLibraryCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddLibraryCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_library";}
+  virtual std::string GetName() const { return "add_library"; }
 
   cmTypeMacro(cmAddLibraryCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 69c6a14..63a9051 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -12,14 +12,13 @@
 #include "cmAddSubDirectoryCommand.h"
 
 // cmAddSubDirectoryCommand
-bool cmAddSubDirectoryCommand::InitialPass
-(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddSubDirectoryCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // store the binpath
   std::string srcArg = args[0];
@@ -30,57 +29,45 @@ bool cmAddSubDirectoryCommand::InitialPass
   // process the rest of the arguments looking for optional args
   std::vector<std::string>::const_iterator i = args.begin();
   ++i;
-  for(;i != args.end(); ++i)
-    {
-    if(*i == "EXCLUDE_FROM_ALL")
-      {
+  for (; i != args.end(); ++i) {
+    if (*i == "EXCLUDE_FROM_ALL") {
       excludeFromAll = true;
       continue;
-      }
-    else if (binArg.empty())
-      {
+    } else if (binArg.empty()) {
       binArg = *i;
-      }
-    else
-      {
+    } else {
       this->SetError("called with incorrect number of arguments");
       return false;
-      }
     }
+  }
 
   // Compute the full path to the specified source directory.
   // Interpret a relative path with respect to the current source directory.
   std::string srcPath;
-  if(cmSystemTools::FileIsFullPath(srcArg.c_str()))
-    {
+  if (cmSystemTools::FileIsFullPath(srcArg.c_str())) {
     srcPath = srcArg;
-    }
-  else
-    {
+  } else {
     srcPath = this->Makefile->GetCurrentSourceDirectory();
     srcPath += "/";
     srcPath += srcArg;
-    }
-  if(!cmSystemTools::FileIsDirectory(srcPath))
-    {
+  }
+  if (!cmSystemTools::FileIsDirectory(srcPath)) {
     std::string error = "given source \"";
     error += srcArg;
     error += "\" which is not an existing directory.";
     this->SetError(error);
     return false;
-    }
+  }
   srcPath = cmSystemTools::CollapseFullPath(srcPath);
 
   // Compute the full path to the binary directory.
   std::string binPath;
-  if(binArg.empty())
-    {
+  if (binArg.empty()) {
     // No binary directory was specified.  If the source directory is
     // not a subdirectory of the current directory then it is an
     // error.
-    if(!cmSystemTools::IsSubDirectory(srcPath,
-          this->Makefile->GetCurrentSourceDirectory()))
-      {
+    if (!cmSystemTools::IsSubDirectory(
+          srcPath, this->Makefile->GetCurrentSourceDirectory())) {
       std::ostringstream e;
       e << "not given a binary directory but the given source directory "
         << "\"" << srcPath << "\" is not a subdirectory of \""
@@ -89,7 +76,7 @@ bool cmAddSubDirectoryCommand::InitialPass
         << "must be explicitly specified.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
     // Remove the CurrentDirectory from the srcPath and replace it
     // with the CurrentOutputDirectory.
@@ -97,32 +84,28 @@ bool cmAddSubDirectoryCommand::InitialPass
     const char* bin = this->Makefile->GetCurrentBinaryDirectory();
     size_t srcLen = strlen(src);
     size_t binLen = strlen(bin);
-    if(srcLen > 0 && src[srcLen-1] == '/')
-      { --srcLen; }
-    if(binLen > 0 && bin[binLen-1] == '/')
-      { --binLen; }
-    binPath = std::string(bin, binLen) + srcPath.substr(srcLen);
+    if (srcLen > 0 && src[srcLen - 1] == '/') {
+      --srcLen;
     }
-  else
-    {
+    if (binLen > 0 && bin[binLen - 1] == '/') {
+      --binLen;
+    }
+    binPath = std::string(bin, binLen) + srcPath.substr(srcLen);
+  } else {
     // Use the binary directory specified.
     // Interpret a relative path with respect to the current binary directory.
-    if(cmSystemTools::FileIsFullPath(binArg.c_str()))
-      {
+    if (cmSystemTools::FileIsFullPath(binArg.c_str())) {
       binPath = binArg;
-      }
-    else
-      {
+    } else {
       binPath = this->Makefile->GetCurrentBinaryDirectory();
       binPath += "/";
       binPath += binArg;
-      }
     }
+  }
   binPath = cmSystemTools::CollapseFullPath(binPath);
 
   // Add the subdirectory using the computed full paths.
-  this->Makefile->AddSubDirectory(srcPath, binPath,
-                                  excludeFromAll, true);
+  this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, true);
 
   return true;
 }
diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h
index abf3efc..786c8b0 100644
--- a/Source/cmAddSubDirectoryCommand.h
+++ b/Source/cmAddSubDirectoryCommand.h
@@ -27,26 +27,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddSubDirectoryCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddSubDirectoryCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_subdirectory";}
+  virtual std::string GetName() const { return "add_subdirectory"; }
 
   cmTypeMacro(cmAddSubDirectoryCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index 3472b98..204dd97 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -15,24 +15,21 @@
 
 #include "cmTest.h"
 
-
 // cmExecutableCommand
-bool cmAddTestCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args,
+                                   cmExecutionStatus&)
 {
-  if(!args.empty() && args[0] == "NAME")
-    {
+  if (!args.empty() && args[0] == "NAME") {
     return this->HandleNameMode(args);
-    }
+  }
 
   // First argument is the name of the test Second argument is the name of
   // the executable to run (a target or external program) Remaining arguments
   // are the arguments to pass to the executable
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Collect the command with arguments.
   std::vector<std::string> command;
@@ -41,31 +38,26 @@ bool cmAddTestCommand
   // 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]);
-  if(test)
-    {
+  if (test) {
     // If the test was already added by a new-style signature do not
     // allow it to be duplicated.
-    if(!test->GetOldStyle())
-      {
+    if (!test->GetOldStyle()) {
       std::ostringstream e;
       e << " given test name \"" << args[0]
         << "\" which already exists in this directory.";
       this->SetError(e.str());
       return false;
-      }
     }
-  else
-    {
+  } else {
     test = this->Makefile->CreateTest(args[0]);
     test->SetOldStyle(true);
     this->Makefile->AddTestGenerator(new cmTestGenerator(test));
-    }
+  }
   test->SetCommand(command);
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
 {
   std::string name;
@@ -74,7 +66,8 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
   std::vector<std::string> command;
 
   // Read the arguments.
-  enum Doing {
+  enum Doing
+  {
     DoingName,
     DoingCommand,
     DoingConfigs,
@@ -82,94 +75,71 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
     DoingNone
   };
   Doing doing = DoingName;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "COMMAND")
-      {
-      if(!command.empty())
-        {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "COMMAND") {
+      if (!command.empty()) {
         this->SetError(" may be given at most one COMMAND.");
         return false;
-        }
-      doing = DoingCommand;
       }
-    else if(args[i] == "CONFIGURATIONS")
-      {
-      if(!configurations.empty())
-        {
+      doing = DoingCommand;
+    } else if (args[i] == "CONFIGURATIONS") {
+      if (!configurations.empty()) {
         this->SetError(" may be given at most one set of CONFIGURATIONS.");
         return false;
-        }
-      doing = DoingConfigs;
       }
-    else if(args[i] == "WORKING_DIRECTORY")
-      {
-      if(!working_directory.empty())
-        {
+      doing = DoingConfigs;
+    } else if (args[i] == "WORKING_DIRECTORY") {
+      if (!working_directory.empty()) {
         this->SetError(" may be given at most one WORKING_DIRECTORY.");
         return false;
-        }
-      doing = DoingWorkingDirectory;
       }
-    else if(doing == DoingName)
-      {
+      doing = DoingWorkingDirectory;
+    } else if (doing == DoingName) {
       name = args[i];
       doing = DoingNone;
-      }
-    else if(doing == DoingCommand)
-      {
+    } else if (doing == DoingCommand) {
       command.push_back(args[i]);
-      }
-    else if(doing == DoingConfigs)
-      {
+    } else if (doing == DoingConfigs) {
       configurations.push_back(args[i]);
-      }
-    else if(doing == DoingWorkingDirectory)
-      {
+    } else if (doing == DoingWorkingDirectory) {
       working_directory = args[i];
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << " given unknown argument:\n  " << args[i] << "\n";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Require a test name.
-  if(name.empty())
-    {
+  if (name.empty()) {
     this->SetError(" must be given non-empty NAME.");
     return false;
-    }
+  }
 
   // Require a command.
-  if(command.empty())
-    {
+  if (command.empty()) {
     this->SetError(" must be given non-empty COMMAND.");
     return false;
-    }
+  }
 
   // Require a unique test name within the directory.
-  if(this->Makefile->GetTest(name))
-    {
+  if (this->Makefile->GetTest(name)) {
     std::ostringstream e;
     e << " given test NAME \"" << name
       << "\" which already exists in this directory.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Add the test.
   cmTest* test = this->Makefile->CreateTest(name);
   test->SetOldStyle(false);
   test->SetCommand(command);
-  if(!working_directory.empty())
-    {
+  if (!working_directory.empty()) {
     test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
-    }
+  }
   this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations));
 
   return true;
diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h
index 624288f..295fb78 100644
--- a/Source/cmAddTestCommand.h
+++ b/Source/cmAddTestCommand.h
@@ -25,27 +25,24 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAddTestCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAddTestCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "add_test";}
+  virtual std::string GetName() const { return "add_test"; }
 
   cmTypeMacro(cmAddTestCommand, cmCommand);
+
 private:
   bool HandleNameMode(std::vector<std::string> const& args);
 };
 
-
 #endif
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index bb65ea5..ee803c8 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -14,65 +14,74 @@
 
 #include "cmStandardIncludes.h"
 
-inline bool cmHasLiteralPrefixImpl(const std::string &str1,
-                                 const char *str2,
-                                 size_t N)
+inline bool cmHasLiteralPrefixImpl(const std::string& str1, const char* str2,
+                                   size_t N)
 {
   return strncmp(str1.c_str(), str2, N) == 0;
 }
 
-inline bool cmHasLiteralPrefixImpl(const char* str1,
-                                 const char *str2,
-                                 size_t N)
+inline bool cmHasLiteralPrefixImpl(const char* str1, const char* str2,
+                                   size_t N)
 {
   return strncmp(str1, str2, N) == 0;
 }
 
-inline bool cmHasLiteralSuffixImpl(const std::string &str1,
-                                   const char *str2,
+inline bool cmHasLiteralSuffixImpl(const std::string& str1, const char* str2,
                                    size_t N)
 {
   size_t len = str1.size();
   return len >= N && strcmp(str1.c_str() + len - N, str2) == 0;
 }
 
-inline bool cmHasLiteralSuffixImpl(const char* str1,
-                                   const char* str2,
+inline bool cmHasLiteralSuffixImpl(const char* str1, const char* str2,
                                    size_t N)
 {
   size_t len = strlen(str1);
   return len >= N && strcmp(str1 + len - N, str2) == 0;
 }
 
-template<typename T, size_t N>
-const T* cmArrayBegin(const T (&a)[N]) { return a; }
-template<typename T, size_t N>
-const T* cmArrayEnd(const T (&a)[N]) { return a + N; }
-template<typename T, size_t N>
-size_t cmArraySize(const T (&)[N]) { return N; }
+template <typename T, size_t N>
+const T* cmArrayBegin(const T (&a)[N])
+{
+  return a;
+}
+template <typename T, size_t N>
+const T* cmArrayEnd(const T (&a)[N])
+{
+  return a + N;
+}
+template <typename T, size_t N>
+size_t cmArraySize(const T (&)[N])
+{
+  return N;
+}
 
-template<typename T, size_t N>
+template <typename T, size_t N>
 bool cmHasLiteralPrefix(const T& str1, const char (&str2)[N])
 {
   return cmHasLiteralPrefixImpl(str1, str2, N - 1);
 }
 
-template<typename T, size_t N>
+template <typename T, size_t N>
 bool cmHasLiteralSuffix(const T& str1, const char (&str2)[N])
 {
   return cmHasLiteralSuffixImpl(str1, str2, N - 1);
 }
 
-struct cmStrCmp {
-  cmStrCmp(const char *test) : m_test(test) {}
-  cmStrCmp(const std::string &test) : m_test(test) {}
-
-  bool operator()(const std::string& input) const
+struct cmStrCmp
+{
+  cmStrCmp(const char* test)
+    : m_test(test)
+  {
+  }
+  cmStrCmp(const std::string& test)
+    : m_test(test)
   {
-    return m_test == input;
   }
 
-  bool operator()(const char * input) const
+  bool operator()(const std::string& input) const { return m_test == input; }
+
+  bool operator()(const char* input) const
   {
     return strcmp(input, m_test.c_str()) == 0;
   }
@@ -81,11 +90,11 @@ private:
   const std::string m_test;
 };
 
-template<typename FwdIt>
+template <typename FwdIt>
 FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
 {
   const typename std::iterator_traits<FwdIt>::difference_type dist =
-      std::distance(middle, last);
+    std::distance(middle, last);
   std::rotate(first, middle, last);
   std::advance(first, dist);
   return first;
@@ -93,36 +102,41 @@ FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
 
 namespace ContainerAlgorithms {
 
-template<typename T>
+template <typename T>
 struct cmIsPair
 {
-  enum { value = false };
+  enum
+  {
+    value = false
+  };
 };
 
-template<typename K, typename V>
+template <typename K, typename V>
 struct cmIsPair<std::pair<K, V> >
 {
-  enum { value = true };
+  enum
+  {
+    value = true
+  };
 };
 
-template<typename Range,
-    bool valueTypeIsPair = cmIsPair<typename Range::value_type>::value>
+template <typename Range,
+          bool valueTypeIsPair = cmIsPair<typename Range::value_type>::value>
 struct DefaultDeleter
 {
-  void operator()(typename Range::value_type value) const {
-    delete value;
-  }
+  void operator()(typename Range::value_type value) const { delete value; }
 };
 
-template<typename Range>
+template <typename Range>
 struct DefaultDeleter<Range, /* valueTypeIsPair = */ true>
 {
-  void operator()(typename Range::value_type value) const {
+  void operator()(typename Range::value_type value) const
+  {
     delete value.second;
   }
 };
 
-template<typename FwdIt>
+template <typename FwdIt>
 FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
 {
   FwdIt m = i1;
@@ -130,7 +144,7 @@ FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
   return cmRotate(i1, m, i2);
 }
 
-template<typename Range>
+template <typename Range>
 struct BinarySearcher
 {
   typedef typename Range::value_type argument_type;
@@ -143,13 +157,13 @@ struct BinarySearcher
   {
     return std::binary_search(m_range.begin(), m_range.end(), item);
   }
+
 private:
   Range const& m_range;
 };
-
 }
 
-template<typename const_iterator_>
+template <typename const_iterator_>
 struct cmRange
 {
   typedef const_iterator_ const_iterator;
@@ -157,7 +171,10 @@ struct cmRange
   typedef typename std::iterator_traits<const_iterator>::difference_type
     difference_type;
   cmRange(const_iterator begin_, const_iterator end_)
-    : Begin(begin_), End(end_) {}
+    : Begin(begin_)
+    , End(end_)
+  {
+  }
   const_iterator begin() const { return Begin; }
   const_iterator end() const { return End; }
   bool empty() const { return std::distance(Begin, End) == 0; }
@@ -173,6 +190,7 @@ struct cmRange
     std::advance(End, -amount);
     return *this;
   }
+
 private:
   const_iterator Begin;
   const_iterator End;
@@ -181,73 +199,68 @@ private:
 typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange;
 
 class cmListFileBacktrace;
-typedef
-cmRange<std::vector<cmListFileBacktrace>::const_iterator> cmBacktraceRange;
+typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator>
+  cmBacktraceRange;
 
-template<typename Iter1, typename Iter2>
+template <typename Iter1, typename Iter2>
 cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
 {
   return cmRange<Iter1>(begin, end);
 }
 
-template<typename Range>
-cmRange<typename Range::const_iterator>
-cmMakeRange(Range const& range)
+template <typename Range>
+cmRange<typename Range::const_iterator> cmMakeRange(Range const& range)
 {
-  return cmRange<typename Range::const_iterator>(
-      range.begin(), range.end());
+  return cmRange<typename Range::const_iterator>(range.begin(), range.end());
 }
 
-template<typename Range>
+template <typename Range>
 void cmDeleteAll(Range const& r)
 {
   std::for_each(r.begin(), r.end(),
                 ContainerAlgorithms::DefaultDeleter<Range>());
 }
 
-template<typename Range>
+template <typename Range>
 std::string cmJoin(Range const& r, const char* delimiter)
 {
-  if (r.empty())
-    {
+  if (r.empty()) {
     return std::string();
-    }
+  }
   std::ostringstream os;
   typedef typename Range::value_type ValueType;
   typedef typename Range::const_iterator InputIt;
   const InputIt first = r.begin();
   InputIt last = r.end();
   --last;
-  std::copy(first, last,
-      std::ostream_iterator<ValueType>(os, delimiter));
+  std::copy(first, last, std::ostream_iterator<ValueType>(os, delimiter));
 
   os << *last;
 
   return os.str();
 }
 
-template<typename Range>
+template <typename Range>
 std::string cmJoin(Range const& r, std::string delimiter)
 {
   return cmJoin(r, delimiter.c_str());
 }
 
-template<typename Range>
+template <typename Range>
 typename Range::const_iterator cmRemoveN(Range& r, size_t n)
 {
   return ContainerAlgorithms::RemoveN(r.begin(), r.end(), n);
 }
 
-template<typename Range, typename InputRange>
+template <typename Range, typename InputRange>
 typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
 {
   typename InputRange::const_iterator remIt = rem.begin();
   typename InputRange::const_iterator remEnd = rem.end();
   const typename Range::iterator rangeEnd = r.end();
-  if (remIt == remEnd)
-    {
+  if (remIt == remEnd) {
     return rangeEnd;
-    }
+  }
 
   typename Range::iterator writer = r.begin();
   std::advance(writer, *remIt);
@@ -255,17 +268,16 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
   typename InputRange::value_type prevRem = *remIt;
   ++remIt;
   size_t count = 1;
-  for ( ; writer != rangeEnd && remIt != remEnd; ++count, ++remIt)
-    {
+  for (; writer != rangeEnd && remIt != remEnd; ++count, ++remIt) {
     std::advance(pivot, *remIt - prevRem);
     prevRem = *remIt;
     writer = ContainerAlgorithms::RemoveN(writer, pivot, count);
-    }
+  }
   return ContainerAlgorithms::RemoveN(writer, rangeEnd, count);
 }
 
-template<typename Range, typename MatchRange>
-typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
+template <typename Range, typename MatchRange>
+typename Range::const_iterator cmRemoveMatching(Range& r, MatchRange const& m)
 {
   return std::remove_if(r.begin(), r.end(),
                         ContainerAlgorithms::BinarySearcher<MatchRange>(m));
@@ -273,7 +285,7 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
 
 namespace ContainerAlgorithms {
 
-template<typename Range, typename T = typename Range::value_type>
+template <typename Range, typename T = typename Range::value_type>
 struct RemoveDuplicatesAPI
 {
   typedef typename Range::const_iterator const_iterator;
@@ -281,11 +293,14 @@ struct RemoveDuplicatesAPI
 
   static bool lessThan(value_type a, value_type b) { return *a < *b; }
   static value_type uniqueValue(const_iterator a) { return a; }
-  template<typename It>
-  static bool valueCompare(It it, const_iterator it2) { return **it != *it2; }
+  template <typename It>
+  static bool valueCompare(It it, const_iterator it2)
+  {
+    return **it != *it2;
+  }
 };
 
-template<typename Range, typename T>
+template <typename Range, typename T>
 struct RemoveDuplicatesAPI<Range, T*>
 {
   typedef typename Range::const_iterator const_iterator;
@@ -293,13 +308,15 @@ struct RemoveDuplicatesAPI<Range, T*>
 
   static bool lessThan(value_type a, value_type b) { return a < b; }
   static value_type uniqueValue(const_iterator a) { return *a; }
-  template<typename It>
-  static bool valueCompare(It it, const_iterator it2) { return *it != *it2; }
+  template <typename It>
+  static bool valueCompare(It it, const_iterator it2)
+  {
+    return *it != *it2;
+  }
 };
-
 }
 
-template<typename Range>
+template <typename Range>
 typename Range::const_iterator cmRemoveDuplicates(Range& r)
 {
   typedef typename ContainerAlgorithms::RemoveDuplicatesAPI<Range> API;
@@ -309,58 +326,51 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r)
   std::vector<size_t> indices;
   size_t count = 0;
   const typename Range::const_iterator end = r.end();
-  for(typename Range::const_iterator it = r.begin();
-      it != end; ++it, ++count)
-    {
-    const typename std::vector<T>::iterator low =
-        std::lower_bound(unique.begin(), unique.end(),
-                         API::uniqueValue(it), API::lessThan);
-    if (low == unique.end() || API::valueCompare(low, it))
-      {
+  for (typename Range::const_iterator it = r.begin(); it != end;
+       ++it, ++count) {
+    const typename std::vector<T>::iterator low = std::lower_bound(
+      unique.begin(), unique.end(), API::uniqueValue(it), API::lessThan);
+    if (low == unique.end() || API::valueCompare(low, it)) {
       unique.insert(low, API::uniqueValue(it));
-      }
-    else
-      {
+    } else {
       indices.push_back(count);
-      }
     }
-  if (indices.empty())
-    {
+  }
+  if (indices.empty()) {
     return end;
-    }
+  }
   return cmRemoveIndices(r, indices);
 }
 
-template<typename Range>
+template <typename Range>
 std::string cmWrap(std::string prefix, Range const& r, std::string suffix,
                    std::string sep)
 {
-  if (r.empty())
-    {
+  if (r.empty()) {
     return std::string();
-    }
+  }
   return prefix + cmJoin(r, (suffix + sep + prefix).c_str()) + suffix;
 }
 
-template<typename Range>
+template <typename Range>
 std::string cmWrap(char prefix, Range const& r, char suffix, std::string sep)
 {
   return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep);
 }
 
-template<typename Range, typename T>
+template <typename Range, typename T>
 typename Range::const_iterator cmFindNot(Range const& r, T const& t)
 {
   return std::find_if(r.begin(), r.end(),
                       std::bind1st(std::not_equal_to<T>(), t));
 }
 
-template<typename Range>
-cmRange<typename Range::const_reverse_iterator>
-cmReverseRange(Range const& range)
+template <typename Range>
+cmRange<typename Range::const_reverse_iterator> cmReverseRange(
+  Range const& range)
 {
-  return cmRange<typename Range::const_reverse_iterator>(
-      range.rbegin(), range.rend());
+  return cmRange<typename Range::const_reverse_iterator>(range.rbegin(),
+                                                         range.rend());
 }
 
 template <class Iter>
@@ -369,4 +379,19 @@ std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
   return std::reverse_iterator<Iter>(it);
 }
 
+inline bool cmHasSuffix(const std::string& str, const std::string& suffix)
+{
+  if (str.size() < suffix.size()) {
+    return false;
+  }
+  return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
+}
+
+inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix)
+{
+  if (cmHasSuffix(str, suffix)) {
+    str.resize(str.size() - suffix.size());
+  }
+}
+
 #endif
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index e62a2ed..a0150ec 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -11,27 +11,25 @@
 ============================================================================*/
 #include "cmArchiveWrite.h"
 
-#include "cmSystemTools.h"
 #include "cmLocale.h"
+#include "cmSystemTools.h"
+#include "cm_get_date.h"
+#include <cm_libarchive.h>
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
-#include <cm_libarchive.h>
-#include "cm_get_date.h"
 
 #ifndef __LA_SSIZE_T
-# define __LA_SSIZE_T la_ssize_t
+#define __LA_SSIZE_T la_ssize_t
 #endif
 
-//----------------------------------------------------------------------------
 static std::string cm_archive_error_string(struct archive* a)
 {
   const char* e = archive_error_string(a);
-  return e? e : "unknown error";
+  return e ? e : "unknown error";
 }
 
-//----------------------------------------------------------------------------
 static void cm_archive_entry_copy_pathname(struct archive_entry* e,
-  const std::string& dest)
+                                           const std::string& dest)
 {
 #if cmsys_STL_HAS_WSTRING
   archive_entry_copy_pathname_w(e, cmsys::Encoding::ToWide(dest).c_str());
@@ -40,9 +38,8 @@ static void cm_archive_entry_copy_pathname(struct archive_entry* e,
 #endif
 }
 
-//----------------------------------------------------------------------------
 static void cm_archive_entry_copy_sourcepath(struct archive_entry* e,
-  const std::string& file)
+                                             const std::string& file)
 {
 #if cmsys_STL_HAS_WSTRING
   archive_entry_copy_sourcepath_w(e, cmsys::Encoding::ToWide(file).c_str());
@@ -51,342 +48,292 @@ static void cm_archive_entry_copy_sourcepath(struct archive_entry* e,
 #endif
 }
 
-//----------------------------------------------------------------------------
 class cmArchiveWrite::Entry
 {
   struct archive_entry* Object;
+
 public:
-  Entry(): Object(archive_entry_new()) {}
+  Entry()
+    : Object(archive_entry_new())
+  {
+  }
   ~Entry() { archive_entry_free(this->Object); }
   operator struct archive_entry*() { return this->Object; }
 };
 
-//----------------------------------------------------------------------------
 struct cmArchiveWrite::Callback
 {
   // archive_write_callback
-  static __LA_SSIZE_T Write(struct archive*, void *cd,
-                            const void *b, size_t n)
-    {
+  static __LA_SSIZE_T Write(struct archive*, void* cd, const void* b, size_t n)
+  {
     cmArchiveWrite* self = static_cast<cmArchiveWrite*>(cd);
-    if(self->Stream.write(static_cast<const char*>(b),
-                          static_cast<std::streamsize>(n)))
-      {
+    if (self->Stream.write(static_cast<const char*>(b),
+                           static_cast<std::streamsize>(n))) {
       return static_cast<__LA_SSIZE_T>(n);
-      }
-    else
-      {
+    } else {
       return static_cast<__LA_SSIZE_T>(-1);
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
-cmArchiveWrite::cmArchiveWrite(
-  std::ostream& os, Compress c, std::string const& format):
-    Stream(os),
-    Archive(archive_write_new()),
-    Disk(archive_read_disk_new()),
-    Verbose(false),
-    Format(format)
+cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
+                               std::string const& format)
+  : Stream(os)
+  , Archive(archive_write_new())
+  , Disk(archive_read_disk_new())
+  , Verbose(false)
+  , Format(format)
 {
-  switch (c)
-    {
+  switch (c) {
     case CompressNone:
-      if(archive_write_add_filter_none(this->Archive) != ARCHIVE_OK)
-        {
+      if (archive_write_add_filter_none(this->Archive) != ARCHIVE_OK) {
         this->Error = "archive_write_add_filter_none: ";
         this->Error += cm_archive_error_string(this->Archive);
         return;
-        }
+      }
       break;
     case CompressCompress:
-      if(archive_write_add_filter_compress(this->Archive) != ARCHIVE_OK)
-        {
+      if (archive_write_add_filter_compress(this->Archive) != ARCHIVE_OK) {
         this->Error = "archive_write_add_filter_compress: ";
         this->Error += cm_archive_error_string(this->Archive);
         return;
-        }
+      }
       break;
     case CompressGZip:
-      if(archive_write_add_filter_gzip(this->Archive) != ARCHIVE_OK)
-        {
+      if (archive_write_add_filter_gzip(this->Archive) != ARCHIVE_OK) {
         this->Error = "archive_write_add_filter_gzip: ";
         this->Error += cm_archive_error_string(this->Archive);
         return;
-        }
+      }
       break;
     case CompressBZip2:
-      if(archive_write_add_filter_bzip2(this->Archive) != ARCHIVE_OK)
-        {
+      if (archive_write_add_filter_bzip2(this->Archive) != ARCHIVE_OK) {
         this->Error = "archive_write_add_filter_bzip2: ";
         this->Error += cm_archive_error_string(this->Archive);
         return;
-        }
+      }
       break;
     case CompressLZMA:
-      if(archive_write_add_filter_lzma(this->Archive) != ARCHIVE_OK)
-        {
+      if (archive_write_add_filter_lzma(this->Archive) != ARCHIVE_OK) {
         this->Error = "archive_write_add_filter_lzma: ";
         this->Error += cm_archive_error_string(this->Archive);
         return;
-        }
+      }
       break;
     case CompressXZ:
-      if(archive_write_add_filter_xz(this->Archive) != ARCHIVE_OK)
-        {
+      if (archive_write_add_filter_xz(this->Archive) != ARCHIVE_OK) {
         this->Error = "archive_write_add_filter_xz: ";
         this->Error += cm_archive_error_string(this->Archive);
         return;
-        }
+      }
       break;
-    };
+  };
 #if !defined(_WIN32) || defined(__CYGWIN__)
-  if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK)
-    {
+  if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) {
     this->Error = "archive_read_disk_set_standard_lookup: ";
     this->Error += cm_archive_error_string(this->Archive);
     return;
-    }
+  }
 #endif
 
-  if(archive_write_set_format_by_name(this->Archive, format.c_str())
-    != ARCHIVE_OK)
-    {
+  if (archive_write_set_format_by_name(this->Archive, format.c_str()) !=
+      ARCHIVE_OK) {
     this->Error = "archive_write_set_format_by_name: ";
     this->Error += cm_archive_error_string(this->Archive);
     return;
-    }
+  }
 
   // do not pad the last block!!
-  if (archive_write_set_bytes_in_last_block(this->Archive, 1))
-    {
+  if (archive_write_set_bytes_in_last_block(this->Archive, 1)) {
     this->Error = "archive_write_set_bytes_in_last_block: ";
     this->Error += cm_archive_error_string(this->Archive);
     return;
-    }
+  }
 
-  if(archive_write_open(
-       this->Archive, this, 0,
-       reinterpret_cast<archive_write_callback*>(&Callback::Write),
-       0) != ARCHIVE_OK)
-    {
+  if (archive_write_open(
+        this->Archive, this, 0,
+        reinterpret_cast<archive_write_callback*>(&Callback::Write),
+        0) != ARCHIVE_OK) {
     this->Error = "archive_write_open: ";
     this->Error += cm_archive_error_string(this->Archive);
     return;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmArchiveWrite::~cmArchiveWrite()
 {
   archive_read_free(this->Disk);
   archive_write_free(this->Archive);
 }
 
-//----------------------------------------------------------------------------
-bool cmArchiveWrite::Add(std::string path,
-                         size_t skip,
-                         const char* prefix,
+bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
                          bool recursive)
 {
-  if(this->Okay())
-    {
-    if(!path.empty() && path[path.size()-1] == '/')
-      {
-      path.erase(path.size()-1);
-      }
-    this->AddPath(path.c_str(), skip, prefix, recursive);
+  if (this->Okay()) {
+    if (!path.empty() && path[path.size() - 1] == '/') {
+      path.erase(path.size() - 1);
     }
+    this->AddPath(path.c_str(), skip, prefix, recursive);
+  }
   return this->Okay();
 }
 
-//----------------------------------------------------------------------------
-bool cmArchiveWrite::AddPath(const char* path,
-                             size_t skip, const char* prefix,
+bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
                              bool recursive)
 {
-  if(!this->AddFile(path, skip, prefix))
-    {
+  if (!this->AddFile(path, skip, prefix)) {
     return false;
-    }
-  if((!cmSystemTools::FileIsDirectory(path) || !recursive) ||
-    cmSystemTools::FileIsSymlink(path))
-    {
+  }
+  if ((!cmSystemTools::FileIsDirectory(path) || !recursive) ||
+      cmSystemTools::FileIsSymlink(path)) {
     return true;
-    }
+  }
   cmsys::Directory d;
-  if(d.Load(path))
-    {
+  if (d.Load(path)) {
     std::string next = path;
     next += "/";
     std::string::size_type end = next.size();
     unsigned long n = d.GetNumberOfFiles();
-    for(unsigned long i = 0; i < n; ++i)
-      {
+    for (unsigned long i = 0; i < n; ++i) {
       const char* file = d.GetFile(i);
-      if(strcmp(file, ".") != 0 && strcmp(file, "..") != 0)
-        {
+      if (strcmp(file, ".") != 0 && strcmp(file, "..") != 0) {
         next.erase(end);
         next += file;
-        if(!this->AddPath(next.c_str(), skip, prefix))
-          {
+        if (!this->AddPath(next.c_str(), skip, prefix)) {
           return false;
-          }
         }
       }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmArchiveWrite::AddFile(const char* file,
-                             size_t skip, const char* prefix)
+bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
 {
   // Skip the file if we have no name for it.  This may happen on a
   // top-level directory, which does not need to be included anyway.
-  if(skip >= strlen(file))
-    {
+  if (skip >= strlen(file)) {
     return true;
-    }
+  }
   const char* out = file + skip;
 
   cmLocaleRAII localeRAII;
   static_cast<void>(localeRAII);
 
   // Meta-data.
-  std::string dest = prefix? prefix : "";
+  std::string dest = prefix ? prefix : "";
   dest += out;
-  if(this->Verbose)
-    {
+  if (this->Verbose) {
     std::cout << dest << "\n";
-    }
+  }
   Entry e;
   cm_archive_entry_copy_sourcepath(e, file);
   cm_archive_entry_copy_pathname(e, dest);
-  if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK)
-    {
+  if (archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK) {
     this->Error = "archive_read_disk_entry_from_file '";
     this->Error += file;
     this->Error += "': ";
     this->Error += cm_archive_error_string(this->Disk);
     return false;
-    }
-  if (!this->MTime.empty())
-    {
+  }
+  if (!this->MTime.empty()) {
     time_t now;
     time(&now);
     time_t t = cm_get_date(now, this->MTime.c_str());
-    if (t == -1)
-      {
+    if (t == -1) {
       this->Error = "unable to parse mtime '";
       this->Error += this->MTime;
       this->Error += "'";
       return false;
-      }
-    archive_entry_set_mtime(e, t, 0);
     }
+    archive_entry_set_mtime(e, t, 0);
+  }
 
   // manages the uid/guid of the entry (if any)
-  if (this->Uid.IsSet() && this->Gid.IsSet())
-    {
+  if (this->Uid.IsSet() && this->Gid.IsSet()) {
     archive_entry_set_uid(e, this->Uid.Get());
     archive_entry_set_gid(e, this->Gid.Get());
-    }
+  }
 
-  if (this->Uname.size() && this->Gname.size())
-    {
+  if (this->Uname.size() && this->Gname.size()) {
     archive_entry_set_uname(e, this->Uname.c_str());
     archive_entry_set_gname(e, this->Gname.c_str());
-    }
-
+  }
 
   // manages the permissions
-  if (this->Permissions.IsSet())
-    {
+  if (this->Permissions.IsSet()) {
     archive_entry_set_perm(e, this->Permissions.Get());
-    }
+  }
 
-  if (this->PermissionsMask.IsSet())
-    {
+  if (this->PermissionsMask.IsSet()) {
     mode_t perm = archive_entry_perm(e);
     archive_entry_set_perm(e, perm & this->PermissionsMask.Get());
-    }
+  }
 
   // Clear acl and xattr fields not useful for distribution.
   archive_entry_acl_clear(e);
   archive_entry_xattr_clear(e);
   archive_entry_set_fflags(e, 0, 0);
 
-  if (this->Format == "pax" || this->Format == "paxr")
-    {
+  if (this->Format == "pax" || this->Format == "paxr") {
     // Sparse files are a GNU tar extension.
     // Do not use them in standard tar files.
     archive_entry_sparse_clear(e);
-    }
+  }
 
-  if(archive_write_header(this->Archive, e) != ARCHIVE_OK)
-    {
+  if (archive_write_header(this->Archive, e) != ARCHIVE_OK) {
     this->Error = "archive_write_header: ";
     this->Error += cm_archive_error_string(this->Archive);
     return false;
-    }
+  }
 
   // do not copy content of symlink
-  if (!archive_entry_symlink(e))
-    {
+  if (!archive_entry_symlink(e)) {
     // Content.
-    if(size_t size = static_cast<size_t>(archive_entry_size(e)))
-      {
+    if (size_t size = static_cast<size_t>(archive_entry_size(e))) {
       return this->AddData(file, size);
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmArchiveWrite::AddData(const char* file, size_t size)
 {
   cmsys::ifstream fin(file, std::ios::in | std::ios::binary);
-  if(!fin)
-    {
+  if (!fin) {
     this->Error = "Error opening \"";
     this->Error += file;
     this->Error += "\": ";
     this->Error += cmSystemTools::GetLastSystemError();
     return false;
-    }
+  }
 
   char buffer[16384];
   size_t nleft = size;
-  while(nleft > 0)
-    {
+  while (nleft > 0) {
     typedef std::streamsize ssize_type;
-    size_t const nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft;
+    size_t const nnext = nleft > sizeof(buffer) ? sizeof(buffer) : nleft;
     ssize_type const nnext_s = static_cast<ssize_type>(nnext);
     fin.read(buffer, nnext_s);
     // Some stream libraries (older HPUX) return failure at end of
     // file on the last read even if some data were read.  Check
     // gcount instead of trusting the stream error status.
-    if(static_cast<size_t>(fin.gcount()) != nnext)
-      {
+    if (static_cast<size_t>(fin.gcount()) != nnext) {
       break;
-      }
-    if(archive_write_data(this->Archive, buffer, nnext) != nnext_s)
-      {
+    }
+    if (archive_write_data(this->Archive, buffer, nnext) != nnext_s) {
       this->Error = "archive_write_data: ";
       this->Error += cm_archive_error_string(this->Archive);
       return false;
-      }
-    nleft -= nnext;
     }
-  if(nleft > 0)
-    {
+    nleft -= nnext;
+  }
+  if (nleft > 0) {
     this->Error = "Error reading \"";
     this->Error += file;
     this->Error += "\": ";
     this->Error += cmSystemTools::GetLastSystemError();
     return false;
-    }
+  }
   return true;
 }
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index 8dbbb83..72d8f3a 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -15,20 +15,24 @@
 #include "cmStandardIncludes.h"
 
 #if !defined(CMAKE_BUILD_WITH_CMAKE)
-# error "cmArchiveWrite not allowed during bootstrap build!"
+#error "cmArchiveWrite not allowed during bootstrap build!"
 #endif
 
-template<typename T>
+template <typename T>
 class cmArchiveWriteOptional
 {
 public:
-  cmArchiveWriteOptional() {this->Clear();}
-  explicit cmArchiveWriteOptional(T val) {this->Set(val);}
+  cmArchiveWriteOptional() { this->Clear(); }
+  explicit cmArchiveWriteOptional(T val) { this->Set(val); }
 
-  void Set(T val) {this->IsValueSet = true; this->Value=val;}
-  void Clear() {this->IsValueSet = false;}
-  bool IsSet() const {return this->IsValueSet;}
-  T Get() const {return Value;}
+  void Set(T val)
+  {
+    this->IsValueSet = true;
+    this->Value = val;
+  }
+  void Clear() { this->IsValueSet = false; }
+  bool IsSet() const { return this->IsValueSet; }
+  T Get() const { return Value; }
 private:
   T Value;
   bool IsValueSet;
@@ -40,7 +44,7 @@ private:
  */
 class cmArchiveWrite
 {
-  typedef void (cmArchiveWrite::* safe_bool)();
+  typedef void (cmArchiveWrite::*safe_bool)();
   void safe_bool_true() {}
 public:
   /** Compression type.  */
@@ -56,7 +60,7 @@ public:
 
   /** Construct with output stream to which to write archive.  */
   cmArchiveWrite(std::ostream& os, Compress c = CompressNone,
-    std::string const& format = "paxr");
+                 std::string const& format = "paxr");
 
   ~cmArchiveWrite();
 
@@ -68,14 +72,14 @@ public:
    * skip.  The remaining part of the input path is appended to the
    * "prefix" value to construct the final name in the archive.
    */
-  bool Add(std::string path,
-     size_t skip = 0,
-     const char* prefix = 0,
-     bool recursive = true);
+  bool Add(std::string path, size_t skip = 0, const char* prefix = 0,
+           bool recursive = true);
 
   /** Returns true if there has been no error.  */
   operator safe_bool() const
-    { return this->Okay()? &cmArchiveWrite::safe_bool_true : 0; }
+  {
+    return this->Okay() ? &cmArchiveWrite::safe_bool_true : 0;
+  }
 
   /** Returns true if there has been an error.  */
   bool operator!() const { return !this->Okay(); }
@@ -91,9 +95,9 @@ public:
 
   //! Sets the permissions of the added files/folders
   void SetPermissions(mode_t permissions_)
-    {
+  {
     this->Permissions.Set(permissions_);
-    }
+  }
 
   //! Clears permissions - default is used instead
   void ClearPermissions() { this->Permissions.Clear(); }
@@ -104,44 +108,41 @@ public:
   //! or folder. The mask will then be applied to unset
   //! some of them
   void SetPermissionsMask(mode_t permissionsMask_)
-    {
+  {
     this->PermissionsMask.Set(permissionsMask_);
-    }
+  }
 
   //! Clears permissions mask - default is used instead
-  void ClearPermissionsMask()
-    {
-    this->PermissionsMask.Clear();
-    }
+  void ClearPermissionsMask() { this->PermissionsMask.Clear(); }
 
   //! Sets UID and GID to be used in the tar file
   void SetUIDAndGID(int uid_, int gid_)
-    {
+  {
     this->Uid.Set(uid_);
     this->Gid.Set(gid_);
-    }
+  }
 
   //! Clears UID and GID to be used in the tar file - default is used instead
   void ClearUIDAndGID()
-    {
+  {
     this->Uid.Clear();
     this->Gid.Clear();
-    }
+  }
 
   //! Sets UNAME and GNAME to be used in the tar file
   void SetUNAMEAndGNAME(const std::string& uname_, const std::string& gname_)
-    {
+  {
     this->Uname = uname_;
     this->Gname = gname_;
-    }
+  }
 
   //! Clears UNAME and GNAME to be used in the tar file
   //! default is used instead
   void ClearUNAMEAndGNAME()
-    {
+  {
     this->Uname = "";
     this->Gname = "";
-    }
+  }
 
 private:
   bool Okay() const { return this->Error.empty(); }
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 92ac07d..78f67a4 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -10,79 +10,68 @@
   See the License for more information.
 ============================================================================*/
 #include "cmAuxSourceDirectoryCommand.h"
+
 #include "cmSourceFile.h"
 
 #include <cmsys/Directory.hxx>
 
 // cmAuxSourceDirectoryCommand
-bool cmAuxSourceDirectoryCommand::InitialPass
-(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmAuxSourceDirectoryCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2 || args.size() > 2)
-    {
+  if (args.size() < 2 || args.size() > 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string sourceListValue;
   std::string templateDirectory = args[0];
   std::string tdir;
-  if(!cmSystemTools::FileIsFullPath(templateDirectory.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(templateDirectory.c_str())) {
     tdir = this->Makefile->GetCurrentSourceDirectory();
     tdir += "/";
     tdir += templateDirectory;
-    }
-  else
-    {
+  } else {
     tdir = templateDirectory;
-    }
+  }
 
   // was the list already populated
-  const char *def = this->Makefile->GetDefinition(args[1]);
-  if (def)
-    {
+  const char* def = this->Makefile->GetDefinition(args[1]);
+  if (def) {
     sourceListValue = def;
-    }
+  }
 
   // Load all the files in the directory
   cmsys::Directory dir;
-  if(dir.Load(tdir.c_str()))
-    {
+  if (dir.Load(tdir.c_str())) {
     size_t numfiles = dir.GetNumberOfFiles();
-    for(size_t i =0; i < numfiles; ++i)
-      {
+    for (size_t i = 0; i < numfiles; ++i) {
       std::string file = dir.GetFile(static_cast<unsigned long>(i));
       // Split the filename into base and extension
       std::string::size_type dotpos = file.rfind(".");
-      if( dotpos != std::string::npos )
-        {
-        std::string ext = file.substr(dotpos+1);
+      if (dotpos != std::string::npos) {
+        std::string ext = file.substr(dotpos + 1);
         std::string base = file.substr(0, dotpos);
         // Process only source files
         std::vector<std::string> srcExts =
-            this->Makefile->GetCMakeInstance()->GetSourceExtensions();
-        if(!base.empty() &&
-           std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
-          {
+          this->Makefile->GetCMakeInstance()->GetSourceExtensions();
+        if (!base.empty() &&
+            std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) {
           std::string fullname = templateDirectory;
           fullname += "/";
           fullname += file;
           // add the file as a class file so
           // depends can be done
-          cmSourceFile* sf =
-            this->Makefile->GetOrCreateSource(fullname);
-          sf->SetProperty("ABSTRACT","0");
-          if(!sourceListValue.empty())
-            {
+          cmSourceFile* sf = this->Makefile->GetOrCreateSource(fullname);
+          sf->SetProperty("ABSTRACT", "0");
+          if (!sourceListValue.empty()) {
             sourceListValue += ";";
-            }
-          sourceListValue += fullname;
           }
+          sourceListValue += fullname;
         }
       }
     }
+  }
   this->Makefile->AddDefinition(args[1], sourceListValue.c_str());
   return true;
 }
-
diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h
index 6615273..b5943f5 100644
--- a/Source/cmAuxSourceDirectoryCommand.h
+++ b/Source/cmAuxSourceDirectoryCommand.h
@@ -29,26 +29,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmAuxSourceDirectoryCommand;
-    }
+  virtual cmCommand* Clone() { return new cmAuxSourceDirectoryCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "aux_source_directory";}
+  virtual std::string GetName() const { return "aux_source_directory"; }
 
   cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx
index 0782b3b..2de8770 100644
--- a/Source/cmBootstrapCommands1.cxx
+++ b/Source/cmBootstrapCommands1.cxx
@@ -13,7 +13,6 @@
 // that CMake knows about at compile time.
 // This is sort of a boot strapping approach since you would
 // like to have CMake to build CMake.
-#include "cmCommands.h"
 #include "cmAddCustomCommandCommand.cxx"
 #include "cmAddCustomTargetCommand.cxx"
 #include "cmAddDefinitionsCommand.cxx"
@@ -27,6 +26,7 @@
 #include "cmCMakeMinimumRequired.cxx"
 #include "cmCMakePolicyCommand.cxx"
 #include "cmCommandArgumentsHelper.cxx"
+#include "cmCommands.h"
 #include "cmConfigureFileCommand.cxx"
 #include "cmContinueCommand.cxx"
 #include "cmCoreTryCompile.cxx"
@@ -42,9 +42,9 @@
 #include "cmEndWhileCommand.cxx"
 #include "cmExecProgramCommand.cxx"
 #include "cmExecuteProcessCommand.cxx"
+#include "cmFileCommand.cxx"
 #include "cmFindBase.cxx"
 #include "cmFindCommon.cxx"
-#include "cmFileCommand.cxx"
 #include "cmFindFileCommand.cxx"
 #include "cmFindLibraryCommand.cxx"
 #include "cmFindPackageCommand.cxx"
@@ -52,9 +52,9 @@
 #include "cmFindProgramCommand.cxx"
 #include "cmForEachCommand.cxx"
 #include "cmFunctionCommand.cxx"
+#include "cmParseArgumentsCommand.cxx"
 #include "cmPathLabel.cxx"
 #include "cmSearchPath.cxx"
-#include "cmParseArgumentsCommand.cxx"
 
 void GetBootstrapCommands1(std::vector<cmCommand*>& commands)
 {
diff --git a/Source/cmBootstrapCommands2.cxx b/Source/cmBootstrapCommands2.cxx
index e522d8c..38d008d 100644
--- a/Source/cmBootstrapCommands2.cxx
+++ b/Source/cmBootstrapCommands2.cxx
@@ -22,14 +22,15 @@
 #include "cmGetPropertyCommand.cxx"
 #include "cmGetSourceFilePropertyCommand.cxx"
 #include "cmGetTargetPropertyCommand.cxx"
+#include "cmGetTestPropertyCommand.cxx"
 #include "cmHexFileConverter.cxx"
 #include "cmIfCommand.cxx"
 #include "cmIncludeCommand.cxx"
 #include "cmIncludeDirectoryCommand.cxx"
 #include "cmIncludeRegularExpressionCommand.cxx"
-#include "cmInstallFilesCommand.cxx"
-#include "cmInstallCommandArguments.cxx"
 #include "cmInstallCommand.cxx"
+#include "cmInstallCommandArguments.cxx"
+#include "cmInstallFilesCommand.cxx"
 #include "cmInstallTargetsCommand.cxx"
 #include "cmLinkDirectoriesCommand.cxx"
 #include "cmListCommand.cxx"
@@ -48,7 +49,6 @@
 #include "cmSetSourceFilesPropertiesCommand.cxx"
 #include "cmSetTargetPropertiesCommand.cxx"
 #include "cmSetTestsPropertiesCommand.cxx"
-#include "cmGetTestPropertyCommand.cxx"
 #include "cmSiteNameCommand.cxx"
 #include "cmStringCommand.cxx"
 #include "cmSubdirCommand.cxx"
diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx
index fc0c3f5..fd57705 100644
--- a/Source/cmBreakCommand.cxx
+++ b/Source/cmBreakCommand.cxx
@@ -12,16 +12,14 @@
 #include "cmBreakCommand.h"
 
 // cmBreakCommand
-bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
-                                  cmExecutionStatus &status)
+bool cmBreakCommand::InitialPass(std::vector<std::string> const& args,
+                                 cmExecutionStatus& status)
 {
-  if(!this->Makefile->IsLoopBlock())
-    {
+  if (!this->Makefile->IsLoopBlock()) {
     bool issueMessage = true;
     std::ostringstream e;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
         break;
@@ -33,29 +31,25 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
       case cmPolicies::NEW:
         messageType = cmake::FATAL_ERROR;
         break;
-      }
+    }
 
-    if(issueMessage)
-      {
+    if (issueMessage) {
       e << "A BREAK command was found outside of a proper "
            "FOREACH or WHILE loop scope.";
       this->Makefile->IssueMessage(messageType, e.str());
-       if(messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
+  }
 
   status.SetBreakInvoked(true);
 
-  if(!args.empty())
-    {
+  if (!args.empty()) {
     bool issueMessage = true;
     std::ostringstream e;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
         break;
@@ -67,19 +61,16 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
       case cmPolicies::NEW:
         messageType = cmake::FATAL_ERROR;
         break;
-      }
+    }
 
-    if(issueMessage)
-      {
+    if (issueMessage) {
       e << "The BREAK command does not accept any arguments.";
       this->Makefile->IssueMessage(messageType, e.str());
-       if(messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
+  }
 
   return true;
 }
-
diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h
index 1fcae50..270d3e6 100644
--- a/Source/cmBreakCommand.h
+++ b/Source/cmBreakCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmBreakCommand;
-    }
+  virtual cmCommand* Clone() { return new cmBreakCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "break";}
+  virtual std::string GetName() const { return "break"; }
 
   cmTypeMacro(cmBreakCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index 64d4fca..586e8a8 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -13,29 +13,24 @@
 
 #include "cmGlobalGenerator.h"
 
-//----------------------------------------------------------------------
-bool cmBuildCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmBuildCommand::InitialPass(std::vector<std::string> const& args,
+                                 cmExecutionStatus&)
 {
   // Support the legacy signature of the command:
   //
-  if(2 == args.size())
-    {
+  if (2 == args.size()) {
     return this->TwoArgsSignature(args);
-    }
+  }
 
   return this->MainSignature(args);
 }
 
-//----------------------------------------------------------------------
-bool cmBuildCommand
-::MainSignature(std::vector<std::string> const& args)
+bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("requires at least one argument naming a CMake variable");
     return false;
-    }
+  }
 
   // The cmake variable in which to store the result.
   const char* variable = args[0].c_str();
@@ -44,108 +39,91 @@ bool cmBuildCommand
   const char* configuration = 0;
   const char* project_name = 0;
   std::string target;
-  enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
+  enum Doing
+  {
+    DoingNone,
+    DoingConfiguration,
+    DoingProjectName,
+    DoingTarget
+  };
   Doing doing = DoingNone;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "CONFIGURATION")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "CONFIGURATION") {
       doing = DoingConfiguration;
-      }
-    else if(args[i] == "PROJECT_NAME")
-      {
+    } else if (args[i] == "PROJECT_NAME") {
       doing = DoingProjectName;
-      }
-    else if(args[i] == "TARGET")
-      {
+    } else if (args[i] == "TARGET") {
       doing = DoingTarget;
-      }
-    else if(doing == DoingConfiguration)
-      {
+    } else if (doing == DoingConfiguration) {
       doing = DoingNone;
       configuration = args[i].c_str();
-      }
-    else if(doing == DoingProjectName)
-      {
+    } else if (doing == DoingProjectName) {
       doing = DoingNone;
       project_name = args[i].c_str();
-      }
-    else if(doing == DoingTarget)
-      {
+    } else if (doing == DoingTarget) {
       doing = DoingNone;
       target = args[i];
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "unknown argument \"" << args[i] << "\"";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // If null/empty CONFIGURATION argument, cmake --build uses 'Debug'
   // in the currently implemented multi-configuration global generators...
   // so we put this code here to end up with the same default configuration
   // as the original 2-arg build_command signature:
   //
-  if(!configuration || !*configuration)
-    {
+  if (!configuration || !*configuration) {
     configuration = getenv("CMAKE_CONFIG_TYPE");
-    }
-  if(!configuration || !*configuration)
-    {
+  }
+  if (!configuration || !*configuration) {
     configuration = "Release";
-    }
+  }
 
-  if(project_name && *project_name)
-    {
-    this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
+  if (project_name && *project_name) {
+    this->Makefile->IssueMessage(
+      cmake::AUTHOR_WARNING,
       "Ignoring PROJECT_NAME option because it has no effect.");
-    }
+  }
 
-  std::string makecommand = this->Makefile->GetGlobalGenerator()
-    ->GenerateCMakeBuildCommand(target, configuration, "",
-                                this->Makefile->IgnoreErrorsCMP0061());
+  std::string makecommand =
+    this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
+      target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
 
   this->Makefile->AddDefinition(variable, makecommand.c_str());
 
   return true;
 }
 
-//----------------------------------------------------------------------
-bool cmBuildCommand
-::TwoArgsSignature(std::vector<std::string> const& args)
+bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with less than two arguments");
     return false;
-    }
+  }
 
   const char* define = args[0].c_str();
-  const char* cacheValue
-    = this->Makefile->GetDefinition(define);
+  const char* cacheValue = this->Makefile->GetDefinition(define);
 
   std::string configType = "Release";
   const char* cfg = getenv("CMAKE_CONFIG_TYPE");
-  if ( cfg && *cfg )
-    {
+  if (cfg && *cfg) {
     configType = cfg;
-    }
+  }
 
-  std::string makecommand = this->Makefile->GetGlobalGenerator()
-    ->GenerateCMakeBuildCommand("", configType, "",
-                                this->Makefile->IgnoreErrorsCMP0061());
+  std::string makecommand =
+    this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
+      "", configType, "", this->Makefile->IgnoreErrorsCMP0061());
 
-  if(cacheValue)
-    {
+  if (cacheValue) {
     return true;
-    }
-  this->Makefile->AddCacheDefinition(define,
-                                 makecommand.c_str(),
-                                 "Command used to build entire project "
-                                 "from the command line.",
-                                 cmState::STRING);
+  }
+  this->Makefile->AddCacheDefinition(define, makecommand.c_str(),
+                                     "Command used to build entire project "
+                                     "from the command line.",
+                                     cmState::STRING);
   return true;
 }
diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h
index 979abc0..6cbf3ca 100644
--- a/Source/cmBuildCommand.h
+++ b/Source/cmBuildCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmBuildCommand;
-    }
+  virtual cmCommand* Clone() { return new cmBuildCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The primary command signature with optional, KEYWORD-based args.
@@ -50,9 +47,10 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "build_command";}
+  virtual std::string GetName() const { return "build_command"; }
 
   cmTypeMacro(cmBuildCommand, cmCommand);
+
 private:
   bool IgnoreErrors() const;
 };
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 2733d76..27234d7 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -14,67 +14,54 @@
 #include <cmsys/RegularExpression.hxx>
 
 // cmBuildNameCommand
-bool cmBuildNameCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
+                                     cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0036,
-      "The build_name command should not be called; see CMP0036."))
-    { return true; }
-  if(args.size() < 1 )
-    {
+  if (this->Disallowed(
+        cmPolicies::CMP0036,
+        "The build_name command should not be called; see CMP0036.")) {
+    return true;
+  }
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   const char* cacheValue = this->Makefile->GetDefinition(args[0]);
-  if(cacheValue)
-    {
+  if (cacheValue) {
     // do we need to correct the value?
     cmsys::RegularExpression reg("[()/]");
-    if (reg.find(cacheValue))
-      {
+    if (reg.find(cacheValue)) {
       std::string cv = cacheValue;
-      cmSystemTools::ReplaceString(cv,"/", "_");
-      cmSystemTools::ReplaceString(cv,"(", "_");
-      cmSystemTools::ReplaceString(cv,")", "_");
-      this->Makefile->AddCacheDefinition(args[0],
-                                     cv.c_str(),
-                                     "Name of build.",
-                                     cmState::STRING);
-      }
-    return true;
+      std::replace(cv.begin(), cv.end(), '/', '_');
+      std::replace(cv.begin(), cv.end(), '(', '_');
+      std::replace(cv.begin(), cv.end(), ')', '_');
+      this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
+                                         cmState::STRING);
     }
-
+    return true;
+  }
 
   std::string buildname = "WinNT";
-  if(this->Makefile->GetDefinition("UNIX"))
-    {
+  if (this->Makefile->GetDefinition("UNIX")) {
     buildname = "";
     cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
-    if(!buildname.empty())
-      {
+    if (!buildname.empty()) {
       std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
-      cmsys::RegularExpression reg( RegExp.c_str() );
-      if(reg.find(buildname.c_str()))
-        {
+      cmsys::RegularExpression reg(RegExp.c_str());
+      if (reg.find(buildname.c_str())) {
         buildname = reg.match(1) + "-" + reg.match(2);
-        }
       }
     }
+  }
   std::string compiler = "${CMAKE_CXX_COMPILER}";
-  this->Makefile->ExpandVariablesInString ( compiler );
+  this->Makefile->ExpandVariablesInString(compiler);
   buildname += "-";
   buildname += cmSystemTools::GetFilenameName(compiler);
-  cmSystemTools::ReplaceString(buildname,
-                               "/", "_");
-  cmSystemTools::ReplaceString(buildname,
-                               "(", "_");
-  cmSystemTools::ReplaceString(buildname,
-                               ")", "_");
+  std::replace(buildname.begin(), buildname.end(), '/', '_');
+  std::replace(buildname.begin(), buildname.end(), '(', '_');
+  std::replace(buildname.begin(), buildname.end(), ')', '_');
 
-  this->Makefile->AddCacheDefinition(args[0],
-                                 buildname.c_str(),
-                                 "Name of build.",
-                                 cmState::STRING);
+  this->Makefile->AddCacheDefinition(args[0], buildname.c_str(),
+                                     "Name of build.", cmState::STRING);
   return true;
 }
-
diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h
index 47455f8..43c24b0 100644
--- a/Source/cmBuildNameCommand.h
+++ b/Source/cmBuildNameCommand.h
@@ -20,11 +20,9 @@ public:
   cmTypeMacro(cmBuildNameCommand, cmCommand);
   virtual cmCommand* Clone() { return new cmBuildNameCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const {return "build_name";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "build_name"; }
   virtual bool IsScriptable() const { return true; }
 };
 
-
-
 #endif
diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx
index 5792302..ee9acde 100644
--- a/Source/cmCLocaleEnvironmentScope.cxx
+++ b/Source/cmCLocaleEnvironmentScope.cxx
@@ -23,11 +23,10 @@ cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
 
   std::string lcAll = this->GetEnv("LC_ALL");
 
-  if(!lcAll.empty())
-    {
+  if (!lcAll.empty()) {
     this->SetEnv("LC_ALL", "");
     this->SetEnv("LC_CTYPE", lcAll);
-    }
+  }
 }
 
 std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
@@ -36,32 +35,28 @@ std::string cmCLocaleEnvironmentScope::GetEnv(std::string const& key)
   return value ? value : std::string();
 }
 
-void cmCLocaleEnvironmentScope::SetEnv(
-  std::string const& key, std::string const& value)
+void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
+                                       std::string const& value)
 {
   std::string oldValue = this->GetEnv(key);
 
   this->EnvironmentBackup.insert(std::make_pair(key, oldValue));
 
-  if(value.empty())
-    {
+  if (value.empty()) {
     cmSystemTools::UnsetEnv(key.c_str());
-    }
-  else
-    {
+  } else {
     std::stringstream tmp;
     tmp << key << "=" << value;
     cmSystemTools::PutEnv(tmp.str());
-    }
+  }
 }
 
 cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
 {
-  for(backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
-    i != this->EnvironmentBackup.end(); ++i)
-    {
+  for (backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
+       i != this->EnvironmentBackup.end(); ++i) {
     std::stringstream tmp;
     tmp << i->first << "=" << i->second;
     cmSystemTools::PutEnv(tmp.str());
-    }
+  }
 }
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 6ff7c0d..fbec6fd 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -12,25 +12,23 @@
 #include "cmCMakeHostSystemInformationCommand.h"
 
 // cmCMakeHostSystemInformation
-bool cmCMakeHostSystemInformationCommand
-::InitialPass(std::vector<std::string> const &args, cmExecutionStatus &)
+bool cmCMakeHostSystemInformationCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   size_t current_index = 0;
 
-  if(args.size() < (current_index + 2) || args[current_index] != "RESULT")
-    {
+  if (args.size() < (current_index + 2) || args[current_index] != "RESULT") {
     this->SetError("missing RESULT specification.");
     return false;
-    }
+  }
 
   std::string variable = args[current_index + 1];
   current_index += 2;
 
-  if(args.size() < (current_index + 2) || args[current_index] != "QUERY")
-    {
+  if (args.size() < (current_index + 2) || args[current_index] != "QUERY") {
     this->SetError("missing QUERY specification");
     return false;
-    }
+  }
 
   cmsys::SystemInformation info;
   info.RunCPUCheck();
@@ -38,87 +36,68 @@ bool cmCMakeHostSystemInformationCommand
   info.RunMemoryCheck();
 
   std::string result_list;
-  for(size_t i = current_index + 1; i < args.size(); ++i)
-    {
+  for (size_t i = current_index + 1; i < args.size(); ++i) {
     std::string key = args[i];
-    if(i != current_index + 1)
-      {
+    if (i != current_index + 1) {
       result_list += ";";
-      }
+    }
     std::string value;
-    if(!this->GetValue(info, key, value)) return false;
+    if (!this->GetValue(info, key, value))
+      return false;
 
     result_list += value;
-    }
+  }
 
   this->Makefile->AddDefinition(variable, result_list.c_str());
 
   return true;
 }
 
-bool cmCMakeHostSystemInformationCommand
-::GetValue(cmsys::SystemInformation &info,
-           std::string const& key, std::string &value)
+bool cmCMakeHostSystemInformationCommand::GetValue(
+  cmsys::SystemInformation& info, std::string const& key, std::string& value)
 {
-  if(key == "NUMBER_OF_LOGICAL_CORES")
-    {
+  if (key == "NUMBER_OF_LOGICAL_CORES") {
     value = this->ValueToString(info.GetNumberOfLogicalCPU());
-    }
-  else if(key == "NUMBER_OF_PHYSICAL_CORES")
-    {
+  } else if (key == "NUMBER_OF_PHYSICAL_CORES") {
     value = this->ValueToString(info.GetNumberOfPhysicalCPU());
-    }
-  else if(key == "HOSTNAME")
-    {
+  } else if (key == "HOSTNAME") {
     value = this->ValueToString(info.GetHostname());
-    }
-  else if(key == "FQDN")
-    {
+  } else if (key == "FQDN") {
     value = this->ValueToString(info.GetFullyQualifiedDomainName());
-    }
-  else if(key == "TOTAL_VIRTUAL_MEMORY")
-    {
+  } else if (key == "TOTAL_VIRTUAL_MEMORY") {
     value = this->ValueToString(info.GetTotalVirtualMemory());
-    }
-  else if(key == "AVAILABLE_VIRTUAL_MEMORY")
-    {
+  } else if (key == "AVAILABLE_VIRTUAL_MEMORY") {
     value = this->ValueToString(info.GetAvailableVirtualMemory());
-    }
-  else if(key == "TOTAL_PHYSICAL_MEMORY")
-    {
+  } else if (key == "TOTAL_PHYSICAL_MEMORY") {
     value = this->ValueToString(info.GetTotalPhysicalMemory());
-    }
-  else if(key == "AVAILABLE_PHYSICAL_MEMORY")
-    {
+  } else if (key == "AVAILABLE_PHYSICAL_MEMORY") {
     value = this->ValueToString(info.GetAvailablePhysicalMemory());
-    }
-  else
-    {
+  } else {
     std::string e = "does not recognize <key> " + key;
     this->SetError(e);
     return false;
-    }
+  }
 
   return true;
 }
 
-std::string cmCMakeHostSystemInformationCommand
-::ValueToString(size_t value) const
+std::string cmCMakeHostSystemInformationCommand::ValueToString(
+  size_t value) const
 {
   std::stringstream tmp;
   tmp << value;
   return tmp.str();
 }
 
-std::string cmCMakeHostSystemInformationCommand
-::ValueToString(const char *value) const
+std::string cmCMakeHostSystemInformationCommand::ValueToString(
+  const char* value) const
 {
   std::string safe_string = value ? value : "";
   return safe_string;
 }
 
-std::string cmCMakeHostSystemInformationCommand
-::ValueToString(std::string const& value) const
+std::string cmCMakeHostSystemInformationCommand::ValueToString(
+  std::string const& value) const
 {
   return value;
 }
diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h
index 463b180..6981ea9 100644
--- a/Source/cmCMakeHostSystemInformationCommand.h
+++ b/Source/cmCMakeHostSystemInformationCommand.h
@@ -29,38 +29,38 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
+  {
     return new cmCMakeHostSystemInformationCommand;
-    }
+  }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
-   /**
-   * This determines if the command is invoked when in script mode.
-   */
+  /**
+  * This determines if the command is invoked when in script mode.
+  */
   virtual bool IsScriptable() const { return true; }
 
-   /**
-   * The name of the command as specified in CMakeList.txt.
-   */
+  /**
+  * The name of the command as specified in CMakeList.txt.
+  */
   virtual std::string GetName() const
-    {
+  {
     return "cmake_host_system_information";
-    }
+  }
 
   cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand);
 
 private:
-  bool GetValue(cmsys::SystemInformation &info,
-    std::string const& key, std::string &value);
+  bool GetValue(cmsys::SystemInformation& info, std::string const& key,
+                std::string& value);
 
   std::string ValueToString(size_t value) const;
-  std::string ValueToString(const char *value) const;
+  std::string ValueToString(const char* value) const;
   std::string ValueToString(std::string const& value) const;
 };
 
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 8591ed6..1376845 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -14,54 +14,42 @@
 #include "cmVersion.h"
 
 // cmCMakeMinimumRequired
-bool cmCMakeMinimumRequired
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
   // Process arguments.
   std::string version_string;
   bool doing_version = false;
-  for(unsigned int i=0; i < args.size(); ++i)
-    {
-    if(args[i] == "VERSION")
-      {
+  for (unsigned int i = 0; i < args.size(); ++i) {
+    if (args[i] == "VERSION") {
       doing_version = true;
-      }
-    else if(args[i] == "FATAL_ERROR")
-      {
-      if(doing_version)
-        {
+    } else if (args[i] == "FATAL_ERROR") {
+      if (doing_version) {
         this->SetError("called with no value for VERSION.");
         return false;
-        }
-      doing_version = false;
       }
-    else if(doing_version)
-      {
+      doing_version = false;
+    } else if (doing_version) {
       doing_version = false;
       version_string = args[i];
-      }
-    else
-      {
+    } else {
       this->UnknownArguments.push_back(args[i]);
-      }
     }
-  if(doing_version)
-    {
+  }
+  if (doing_version) {
     this->SetError("called with no value for VERSION.");
     return false;
-    }
+  }
 
   // Make sure there was a version to check.
-  if(version_string.empty())
-    {
+  if (version_string.empty()) {
     return this->EnforceUnknownArguments();
-    }
+  }
 
   // Save the required version string.
   this->Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION",
                                 version_string.c_str());
 
-
   // Get the current version number.
   unsigned int current_major = cmVersion::GetMajorVersion();
   unsigned int current_minor = cmVersion::GetMinorVersion();
@@ -74,28 +62,21 @@ bool cmCMakeMinimumRequired
   unsigned int required_minor = 0;
   unsigned int required_patch = 0;
   unsigned int required_tweak = 0;
-  if(sscanf(version_string.c_str(), "%u.%u.%u.%u",
-            &required_major, &required_minor,
-            &required_patch, &required_tweak) < 2)
-    {
+  if (sscanf(version_string.c_str(), "%u.%u.%u.%u", &required_major,
+             &required_minor, &required_patch, &required_tweak) < 2) {
     std::ostringstream e;
     e << "could not parse VERSION \"" << version_string << "\".";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Compare the version numbers.
-  if((current_major < required_major) ||
-     (current_major == required_major &&
-      current_minor < required_minor) ||
-     (current_major == required_major &&
-      current_minor == required_minor &&
-      current_patch < required_patch) ||
-     (current_major == required_major &&
-      current_minor == required_minor &&
-      current_patch == required_patch &&
-      current_tweak < required_tweak))
-    {
+  if ((current_major < required_major) ||
+      (current_major == required_major && current_minor < required_minor) ||
+      (current_major == required_major && current_minor == required_minor &&
+       current_patch < required_patch) ||
+      (current_major == required_major && current_minor == required_minor &&
+       current_patch == required_patch && current_tweak < required_tweak)) {
     // The current version is too low.
     std::ostringstream e;
     e << "CMake " << version_string
@@ -104,39 +85,33 @@ bool cmCMakeMinimumRequired
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     cmSystemTools::SetFatalErrorOccured();
     return true;
-    }
+  }
 
   // The version is not from the future, so enforce unknown arguments.
-  if(!this->EnforceUnknownArguments())
-    {
+  if (!this->EnforceUnknownArguments()) {
     return false;
-    }
+  }
 
-  if (required_major < 2 || (required_major == 2 && required_minor < 4))
-  {
+  if (required_major < 2 || (required_major == 2 && required_minor < 4)) {
     this->Makefile->IssueMessage(
       cmake::AUTHOR_WARNING,
       "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.");
     this->Makefile->SetPolicyVersion("2.4");
-  }
-  else
-  {
+  } else {
     this->Makefile->SetPolicyVersion(version_string.c_str());
   }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmCMakeMinimumRequired::EnforceUnknownArguments()
 {
-  if(!this->UnknownArguments.empty())
-    {
+  if (!this->UnknownArguments.empty()) {
     std::ostringstream e;
-    e << "called with unknown argument \""
-      << this->UnknownArguments[0] << "\".";
+    e << "called with unknown argument \"" << this->UnknownArguments[0]
+      << "\".";
     this->SetError(e.str());
     return false;
-    }
+  }
   return true;
 }
diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h
index 31b7271..fc73e87 100644
--- a/Source/cmCMakeMinimumRequired.h
+++ b/Source/cmCMakeMinimumRequired.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmCMakeMinimumRequired;
-    }
+  virtual cmCommand* Clone() { return new cmCMakeMinimumRequired; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,7 +42,7 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "cmake_minimum_required";}
+  virtual std::string GetName() const { return "cmake_minimum_required"; }
 
   cmTypeMacro(cmCMakeMinimumRequired, cmCommand);
 
@@ -54,6 +51,4 @@ private:
   bool EnforceUnknownArguments();
 };
 
-
-
 #endif
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 3ef6d35..07e0885 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -14,47 +14,35 @@
 #include "cmVersion.h"
 
 // cmCMakePolicyCommand
-bool cmCMakePolicyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("requires at least one argument.");
     return false;
-    }
+  }
 
-  if(args[0] == "SET")
-    {
+  if (args[0] == "SET") {
     return this->HandleSetMode(args);
-    }
-  else if(args[0] == "GET")
-    {
+  } else if (args[0] == "GET") {
     return this->HandleGetMode(args);
-    }
-  else if(args[0] == "PUSH")
-    {
-    if(args.size() > 1)
-      {
+  } else if (args[0] == "PUSH") {
+    if (args.size() > 1) {
       this->SetError("PUSH may not be given additional arguments.");
       return false;
-      }
+    }
     this->Makefile->PushPolicy();
     return true;
-    }
-  else if(args[0] == "POP")
-    {
-    if(args.size() > 1)
-      {
+  } else if (args[0] == "POP") {
+    if (args.size() > 1) {
       this->SetError("POP may not be given additional arguments.");
       return false;
-      }
+    }
     this->Makefile->PopPolicy();
     return true;
-    }
-  else if(args[0] == "VERSION")
-    {
+  } else if (args[0] == "VERSION") {
     return this->HandleVersionMode(args);
-    }
+  }
 
   std::ostringstream e;
   e << "given unknown first argument \"" << args[0] << "\"";
@@ -62,64 +50,52 @@ bool cmCMakePolicyCommand
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("SET must be given exactly 2 additional arguments.");
     return false;
-    }
+  }
 
   cmPolicies::PolicyStatus status;
-  if(args[2] == "OLD")
-    {
+  if (args[2] == "OLD") {
     status = cmPolicies::OLD;
-    }
-  else if(args[2] == "NEW")
-    {
+  } else if (args[2] == "NEW") {
     status = cmPolicies::NEW;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << "SET given unrecognized policy status \"" << args[2] << "\"";
     this->SetError(e.str());
     return false;
-    }
+  }
 
-  if(!this->Makefile->SetPolicy(args[1].c_str(), status))
-    {
+  if (!this->Makefile->SetPolicy(args[1].c_str(), status)) {
     this->SetError("SET failed to set policy.");
     return false;
-    }
-  if(args[1] == "CMP0001" &&
-     (status == cmPolicies::WARN || status == cmPolicies::OLD))
-    {
-    if(!(this->Makefile->GetState()
-         ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
-      {
+  }
+  if (args[1] == "CMP0001" &&
+      (status == cmPolicies::WARN || status == cmPolicies::OLD)) {
+    if (!(this->Makefile->GetState()->GetInitializedCacheValue(
+          "CMAKE_BACKWARDS_COMPATIBILITY"))) {
       // Set it to 2.4 because that is the last version where the
       // variable had meaning.
-      this->Makefile->AddCacheDefinition
-        ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
-         "For backwards compatibility, what version of CMake "
-         "commands and "
-         "syntax should this version of CMake try to support.",
-         cmState::STRING);
-      }
-    }
+      this->Makefile->AddCacheDefinition(
+        "CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
+        "For backwards compatibility, what version of CMake "
+        "commands and "
+        "syntax should this version of CMake try to support.",
+        cmState::STRING);
+    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("GET must be given exactly 2 additional arguments.");
     return false;
-    }
+  }
 
   // Get arguments.
   std::string const& id = args[1];
@@ -127,19 +103,17 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
 
   // Lookup the policy number.
   cmPolicies::PolicyID pid;
-  if(!cmPolicies::GetPolicyID(id.c_str(), pid))
-    {
+  if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
     std::ostringstream e;
     e << "GET given policy \"" << id << "\" which is not known to this "
       << "version of CMake.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Lookup the policy setting.
   cmPolicies::PolicyStatus status = this->Makefile->GetPolicyStatus(pid);
-  switch (status)
-    {
+  switch (status) {
     case cmPolicies::OLD:
       // Report that the policy is set to OLD.
       this->Makefile->AddDefinition(var, "OLD");
@@ -156,33 +130,28 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
     case cmPolicies::REQUIRED_ALWAYS:
       // The policy is required to be set before anything needs it.
       {
-      std::ostringstream e;
-      e << cmPolicies::GetRequiredPolicyError(pid)
-        << "\n"
-        << "The call to cmake_policy(GET " << id << " ...) at which this "
-        << "error appears requests the policy, and this version of CMake "
-        << "requires that the policy be set to NEW before it is checked.";
-      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+        std::ostringstream e;
+        e << cmPolicies::GetRequiredPolicyError(pid) << "\n"
+          << "The call to cmake_policy(GET " << id << " ...) at which this "
+          << "error appears requests the policy, and this version of CMake "
+          << "requires that the policy be set to NEW before it is checked.";
+        this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       }
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmCMakePolicyCommand::HandleVersionMode(std::vector<std::string> const& args)
+bool cmCMakePolicyCommand::HandleVersionMode(
+  std::vector<std::string> const& args)
 {
-  if(args.size() <= 1)
-    {
+  if (args.size() <= 1) {
     this->SetError("VERSION not given an argument");
     return false;
-    }
-  else if(args.size() >= 3)
-    {
+  } else if (args.size() >= 3) {
     this->SetError("VERSION given too many arguments");
     return false;
-    }
+  }
   this->Makefile->SetPolicyVersion(args[1].c_str());
   return true;
 }
diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h
index 8dc8fbe..dbb91d5 100644
--- a/Source/cmCMakePolicyCommand.h
+++ b/Source/cmCMakePolicyCommand.h
@@ -26,35 +26,31 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmCMakePolicyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmCMakePolicyCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
- /**
-   * This determines if the command is invoked when in script mode.
-   */
+  /**
+    * This determines if the command is invoked when in script mode.
+    */
   virtual bool IsScriptable() const { return true; }
 
- /**
-   * The name of the command as specified in CMakeList.txt.
-   */
-  virtual std::string GetName() const {return "cmake_policy";}
+  /**
+    * The name of the command as specified in CMakeList.txt.
+    */
+  virtual std::string GetName() const { return "cmake_policy"; }
 
   cmTypeMacro(cmCMakePolicyCommand, cmCommand);
+
 private:
   bool HandleSetMode(std::vector<std::string> const& args);
   bool HandleGetMode(std::vector<std::string> const& args);
   bool HandleVersionMode(std::vector<std::string> const& args);
 };
 
-
-
 #endif
diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx
index 35b3d59..af01c7d 100644
--- a/Source/cmCPackPropertiesGenerator.cxx
+++ b/Source/cmCPackPropertiesGenerator.cxx
@@ -1,47 +1,43 @@
 #include "cmCPackPropertiesGenerator.h"
 
-#include "cmOutputConverter.h"
 #include "cmLocalGenerator.h"
+#include "cmOutputConverter.h"
 
 cmCPackPropertiesGenerator::cmCPackPropertiesGenerator(
-  cmLocalGenerator* lg,
-  cmInstalledFile const& installedFile,
-  std::vector<std::string> const& configurations):
-    cmScriptGenerator("CPACK_BUILD_CONFIG", configurations),
-    LG(lg),
-    InstalledFile(installedFile)
+  cmLocalGenerator* lg, cmInstalledFile const& installedFile,
+  std::vector<std::string> const& configurations)
+  : cmScriptGenerator("CPACK_BUILD_CONFIG", configurations)
+  , LG(lg)
+  , InstalledFile(installedFile)
 {
   this->ActionsPerConfig = true;
 }
 
-void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os,
-  const std::string& config, Indent const& indent)
+void cmCPackPropertiesGenerator::GenerateScriptForConfig(
+  std::ostream& os, const std::string& config, Indent const& indent)
 {
   std::string const& expandedFileName =
-      this->InstalledFile.GetNameExpression().Evaluate(this->LG,
-                                                       config);
+    this->InstalledFile.GetNameExpression().Evaluate(this->LG, config);
 
   cmInstalledFile::PropertyMapType const& properties =
     this->InstalledFile.GetProperties();
 
-  for(cmInstalledFile::PropertyMapType::const_iterator i = properties.begin();
-    i != properties.end(); ++i)
-    {
+  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 " <<
-      cmOutputConverter::EscapeForCMake(expandedFileName) << " PROPERTY " <<
-      cmOutputConverter::EscapeForCMake(name);
+    os << indent << "set_property(INSTALL "
+       << cmOutputConverter::EscapeForCMake(expandedFileName) << " PROPERTY "
+       << cmOutputConverter::EscapeForCMake(name);
 
-    for(cmInstalledFile::ExpressionVectorType::const_iterator
-      j = property.ValueExpressions.begin();
-      j != property.ValueExpressions.end(); ++j)
-      {
+    for (cmInstalledFile::ExpressionVectorType::const_iterator j =
+           property.ValueExpressions.begin();
+         j != property.ValueExpressions.end(); ++j) {
       std::string value = (*j)->Evaluate(this->LG, config);
       os << " " << cmOutputConverter::EscapeForCMake(value);
-      }
+    }
 
     os << ")\n";
-    }
+  }
 }
diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h
index eec3df0..4372b87 100644
--- a/Source/cmCPackPropertiesGenerator.h
+++ b/Source/cmCPackPropertiesGenerator.h
@@ -12,8 +12,8 @@
 #ifndef cmCPackPropertiesGenerator_h
 #define cmCPackPropertiesGenerator_h
 
-#include "cmScriptGenerator.h"
 #include "cmInstalledFile.h"
+#include "cmScriptGenerator.h"
 
 class cmLocalGenerator;
 
@@ -21,17 +21,17 @@ class cmLocalGenerator;
  * \brief Support class for generating CPackProperties.cmake.
  *
  */
-class cmCPackPropertiesGenerator: public cmScriptGenerator
+class cmCPackPropertiesGenerator : public cmScriptGenerator
 {
 public:
-  cmCPackPropertiesGenerator(
-     cmLocalGenerator* lg,
-     cmInstalledFile const& installedFile,
-     std::vector<std::string> const& configurations);
+  cmCPackPropertiesGenerator(cmLocalGenerator* lg,
+                             cmInstalledFile const& installedFile,
+                             std::vector<std::string> const& configurations);
 
 protected:
   virtual void GenerateScriptForConfig(std::ostream& os,
-    const std::string& config, Indent const& indent);
+                                       const std::string& config,
+                                       Indent const& indent);
 
   cmLocalGenerator* LG;
   cmInstalledFile const& InstalledFile;
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index fb78446..a78300c 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -14,8 +14,9 @@
    these routines just manipulate arguments and then call the associated
    methods on the CMake classes. */
 
-#include "cmMakefile.h"
 #include "cmCPluginAPI.h"
+
+#include "cmMakefile.h"
 #include "cmVersion.h"
 
 #include "cmSourceFile.h"
@@ -23,191 +24,175 @@
 #include <stdlib.h>
 
 #ifdef __QNX__
-# include <malloc.h> /* for malloc/free on QNX */
+#include <malloc.h> /* for malloc/free on QNX */
 #endif
 
-extern "C"
-{
+extern "C" {
 
-void CCONV *cmGetClientData(void *info)
+void CCONV* cmGetClientData(void* info)
 {
-  return ((cmLoadedCommandInfo *)info)->ClientData;
+  return ((cmLoadedCommandInfo*)info)->ClientData;
 }
 
-void CCONV cmSetClientData(void *info, void *cd)
+void CCONV cmSetClientData(void* info, void* cd)
 {
-  ((cmLoadedCommandInfo *)info)->ClientData = cd;
+  ((cmLoadedCommandInfo*)info)->ClientData = cd;
 }
 
-void CCONV cmSetError(void *info, const char *err)
+void CCONV cmSetError(void* info, const char* err)
 {
-  if (((cmLoadedCommandInfo *)info)->Error)
-    {
-    free(((cmLoadedCommandInfo *)info)->Error);
-    }
-  ((cmLoadedCommandInfo *)info)->Error = strdup(err);
+  if (((cmLoadedCommandInfo*)info)->Error) {
+    free(((cmLoadedCommandInfo*)info)->Error);
+  }
+  ((cmLoadedCommandInfo*)info)->Error = strdup(err);
 }
 
-unsigned int CCONV  cmGetCacheMajorVersion(void *arg)
+unsigned int CCONV cmGetCacheMajorVersion(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
-  cmState *state = mf->GetState();
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
+  cmState* state = mf->GetState();
   return state->GetCacheMajorVersion();
 }
-unsigned int CCONV cmGetCacheMinorVersion(void *arg)
+unsigned int CCONV cmGetCacheMinorVersion(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
-  cmState *state = mf->GetState();
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
+  cmState* state = mf->GetState();
   return state->GetCacheMinorVersion();
 }
 
-unsigned int CCONV cmGetMajorVersion(void *)
+unsigned int CCONV cmGetMajorVersion(void*)
 {
   return cmVersion::GetMajorVersion();
 }
 
-unsigned int CCONV cmGetMinorVersion(void *)
+unsigned int CCONV cmGetMinorVersion(void*)
 {
   return cmVersion::GetMinorVersion();
 }
 
-void CCONV cmAddDefinition(void *arg, const char* name, const char* value)
+void CCONV cmAddDefinition(void* arg, const char* name, const char* value)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
-  mf->AddDefinition(name,value);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
+  mf->AddDefinition(name, value);
 }
 
 /* Add a definition to this makefile and the global cmake cache. */
-void CCONV cmAddCacheDefinition(void *arg, const char* name,
-  const char* value, const char* doc, int type)
+void CCONV cmAddCacheDefinition(void* arg, const char* name, const char* value,
+                                const char* doc, int type)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
 
-  switch (type)
-    {
+  switch (type) {
     case CM_CACHE_BOOL:
-      mf->AddCacheDefinition(name,value,doc,
-                             cmState::BOOL);
+      mf->AddCacheDefinition(name, value, doc, cmState::BOOL);
       break;
     case CM_CACHE_PATH:
-      mf->AddCacheDefinition(name,value,doc,
-                             cmState::PATH);
+      mf->AddCacheDefinition(name, value, doc, cmState::PATH);
       break;
     case CM_CACHE_FILEPATH:
-      mf->AddCacheDefinition(name,value,doc,
-                             cmState::FILEPATH);
+      mf->AddCacheDefinition(name, value, doc, cmState::FILEPATH);
       break;
     case CM_CACHE_STRING:
-      mf->AddCacheDefinition(name,value,doc,
-                             cmState::STRING);
+      mf->AddCacheDefinition(name, value, doc, cmState::STRING);
       break;
     case CM_CACHE_INTERNAL:
-      mf->AddCacheDefinition(name,value,doc,
-                             cmState::INTERNAL);
+      mf->AddCacheDefinition(name, value, doc, cmState::INTERNAL);
       break;
     case CM_CACHE_STATIC:
-      mf->AddCacheDefinition(name,value,doc,
-                             cmState::STATIC);
+      mf->AddCacheDefinition(name, value, doc, cmState::STATIC);
       break;
-    }
+  }
 }
 
-const char* CCONV cmGetProjectName(void *arg)
+const char* CCONV cmGetProjectName(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   static std::string name;
   name = mf->GetStateSnapshot().GetProjectName();
   return name.c_str();
 }
 
-const char* CCONV cmGetHomeDirectory(void *arg)
+const char* CCONV cmGetHomeDirectory(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetHomeDirectory();
 }
-const char* CCONV cmGetHomeOutputDirectory(void *arg)
+const char* CCONV cmGetHomeOutputDirectory(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetHomeOutputDirectory();
 }
-const char* CCONV cmGetStartDirectory(void *arg)
+const char* CCONV cmGetStartDirectory(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetCurrentSourceDirectory();
 }
-const char* CCONV cmGetStartOutputDirectory(void *arg)
+const char* CCONV cmGetStartOutputDirectory(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetCurrentBinaryDirectory();
 }
-const char* CCONV cmGetCurrentDirectory(void *arg)
+const char* CCONV cmGetCurrentDirectory(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetCurrentSourceDirectory();
 }
-const char* CCONV cmGetCurrentOutputDirectory(void *arg)
+const char* CCONV cmGetCurrentOutputDirectory(void* arg)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetCurrentBinaryDirectory();
 }
-const char* CCONV cmGetDefinition(void *arg,const char*def)
+const char* CCONV cmGetDefinition(void* arg, const char* def)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return mf->GetDefinition(def);
 }
 
-int CCONV cmIsOn(void *arg, const char* name)
+int CCONV cmIsOn(void* arg, const char* name)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return static_cast<int>(mf->IsOn(name));
 }
 
 /** Check if a command exists. */
-int CCONV cmCommandExists(void *arg, const char* name)
+int CCONV cmCommandExists(void* arg, const char* name)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   return static_cast<int>(mf->GetState()->GetCommand(name) ? 1 : 0);
 }
 
-void CCONV cmAddDefineFlag(void *arg, const char* definition)
+void CCONV cmAddDefineFlag(void* arg, const char* definition)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   mf->AddDefineFlag(definition);
 }
 
-void CCONV cmAddLinkDirectoryForTarget(void *arg, const char *tgt,
-  const char* d)
+void CCONV cmAddLinkDirectoryForTarget(void* arg, const char* tgt,
+                                       const char* d)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
-  mf->AddLinkDirectoryForTarget(tgt,d);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
+  mf->AddLinkDirectoryForTarget(tgt, d);
 }
 
-
-void CCONV cmAddExecutable(void *arg, const char *exename,
-                     int numSrcs, const char **srcs, int win32)
+void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs,
+                           const char** srcs, int win32)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   std::vector<std::string> srcs2;
   int i;
-  for (i = 0; i < numSrcs; ++i)
-    {
+  for (i = 0; i < numSrcs; ++i) {
     srcs2.push_back(srcs[i]);
-    }
- cmTarget* tg =  mf->AddExecutable(exename, srcs2);
- if ( win32 )
-   {
-   tg->SetProperty("WIN32_EXECUTABLE", "ON");
-   }
-}
-
-void CCONV cmAddUtilityCommand(void *arg, const char* utilityName,
-                         const char* command,
-                         const char* arguments,
-                         int all,
-                         int numDepends,
-                         const char **depends,
-                         int,
-                         const char **)
+  }
+  cmTarget* tg = mf->AddExecutable(exename, srcs2);
+  if (win32) {
+    tg->SetProperty("WIN32_EXECUTABLE", "ON");
+  }
+}
+
+void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
+                               const char* command, const char* arguments,
+                               int all, int numDepends, const char** depends,
+                               int, const char**)
 {
   // Get the makefile instance.  Perform an extra variable expansion
   // now because the API caller expects it.
@@ -217,33 +202,30 @@ void CCONV cmAddUtilityCommand(void *arg, const char* utilityName,
   cmCustomCommandLine commandLine;
   std::string expand = command;
   commandLine.push_back(mf->ExpandVariablesInString(expand));
-  if(arguments && arguments[0])
-    {
+  if (arguments && arguments[0]) {
     // TODO: Parse arguments!
     expand = arguments;
     commandLine.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
   cmCustomCommandLines commandLines;
   commandLines.push_back(commandLine);
 
   // Accumulate the list of dependencies.
   std::vector<std::string> depends2;
-  for(int i = 0; i < numDepends; ++i)
-    {
+  for (int i = 0; i < numDepends; ++i) {
     expand = depends[i];
     depends2.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
 
   // Pass the call to the makefile instance.
-  mf->AddUtilityCommand(utilityName, (all ? false : true),
-                        0, depends2, commandLines);
+  mf->AddUtilityCommand(utilityName, (all ? false : true), 0, depends2,
+                        commandLines);
 }
-void CCONV cmAddCustomCommand(void *arg, const char* source,
-                        const char* command,
-                        int numArgs, const char **args,
-                        int numDepends, const char **depends,
-                        int numOutputs, const char **outputs,
-                        const char *target)
+void CCONV cmAddCustomCommand(void* arg, const char* source,
+                              const char* command, int numArgs,
+                              const char** args, int numDepends,
+                              const char** depends, int numOutputs,
+                              const char** outputs, const char* target)
 {
   // Get the makefile instance.  Perform an extra variable expansion
   // now because the API caller expects it.
@@ -253,29 +235,26 @@ void CCONV cmAddCustomCommand(void *arg, const char* source,
   cmCustomCommandLine commandLine;
   std::string expand = command;
   commandLine.push_back(mf->ExpandVariablesInString(expand));
-  for(int i=0; i < numArgs; ++i)
-    {
+  for (int i = 0; i < numArgs; ++i) {
     expand = args[i];
     commandLine.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
   cmCustomCommandLines commandLines;
   commandLines.push_back(commandLine);
 
   // Accumulate the list of dependencies.
   std::vector<std::string> depends2;
-  for(int i = 0; i < numDepends; ++i)
-    {
+  for (int i = 0; i < numDepends; ++i) {
     expand = depends[i];
     depends2.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
 
   // Accumulate the list of outputs.
   std::vector<std::string> outputs2;
-  for(int i = 0; i < numOutputs; ++i)
-    {
+  for (int i = 0; i < numOutputs; ++i) {
     expand = outputs[i];
     outputs2.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
 
   // Pass the call to the makefile instance.
   const char* no_comment = 0;
@@ -283,11 +262,11 @@ void CCONV cmAddCustomCommand(void *arg, const char* source,
                                commandLines, no_comment);
 }
 
-void CCONV cmAddCustomCommandToOutput(void *arg, const char* output,
-                                const char* command,
-                                int numArgs, const char **args,
-                                const char* main_dependency,
-                                int numDepends, const char **depends)
+void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
+                                      const char* command, int numArgs,
+                                      const char** args,
+                                      const char* main_dependency,
+                                      int numDepends, const char** depends)
 {
   // Get the makefile instance.  Perform an extra variable expansion
   // now because the API caller expects it.
@@ -297,33 +276,30 @@ void CCONV cmAddCustomCommandToOutput(void *arg, const char* output,
   cmCustomCommandLine commandLine;
   std::string expand = command;
   commandLine.push_back(mf->ExpandVariablesInString(expand));
-  for(int i=0; i < numArgs; ++i)
-    {
+  for (int i = 0; i < numArgs; ++i) {
     expand = args[i];
     commandLine.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
   cmCustomCommandLines commandLines;
   commandLines.push_back(commandLine);
 
   // Accumulate the list of dependencies.
   std::vector<std::string> depends2;
-  for(int i = 0; i < numDepends; ++i)
-    {
+  for (int i = 0; i < numDepends; ++i) {
     expand = depends[i];
     depends2.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
 
   // Pass the call to the makefile instance.
   const char* no_comment = 0;
   const char* no_working_dir = 0;
-  mf->AddCustomCommandToOutput(output, depends2, main_dependency,
-                               commandLines, no_comment, no_working_dir);
+  mf->AddCustomCommandToOutput(output, depends2, main_dependency, commandLines,
+                               no_comment, no_working_dir);
 }
 
-void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
-                                const char* command,
-                                int numArgs, const char **args,
-                                int commandType)
+void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
+                                      const char* command, int numArgs,
+                                      const char** args, int commandType)
 {
   // Get the makefile instance.
   cmMakefile* mf = static_cast<cmMakefile*>(arg);
@@ -333,18 +309,16 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
   cmCustomCommandLine commandLine;
   std::string expand = command;
   commandLine.push_back(mf->ExpandVariablesInString(expand));
-  for(int i=0; i < numArgs; ++i)
-    {
+  for (int i = 0; i < numArgs; ++i) {
     expand = args[i];
     commandLine.push_back(mf->ExpandVariablesInString(expand));
-    }
+  }
   cmCustomCommandLines commandLines;
   commandLines.push_back(commandLine);
 
   // Select the command type.
   cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
-  switch (commandType)
-    {
+  switch (commandType) {
     case CM_PRE_BUILD:
       cctype = cmTarget::PRE_BUILD;
       break;
@@ -354,7 +328,7 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
     case CM_POST_BUILD:
       cctype = cmTarget::POST_BUILD;
       break;
-    }
+  }
 
   // Pass the call to the makefile instance.
   std::vector<std::string> no_byproducts;
@@ -365,128 +339,112 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
                                cctype, no_comment, no_working_dir);
 }
 
-void CCONV cmAddLinkLibraryForTarget(void *arg, const char *tgt,
-  const char*value, int libtype)
+void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt,
+                                     const char* value, int libtype)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
 
-  switch (libtype)
-    {
+  switch (libtype) {
     case CM_LIBRARY_GENERAL:
-      mf->AddLinkLibraryForTarget(tgt,value, GENERAL_LibraryType);
+      mf->AddLinkLibraryForTarget(tgt, value, GENERAL_LibraryType);
       break;
     case CM_LIBRARY_DEBUG:
-      mf->AddLinkLibraryForTarget(tgt,value, DEBUG_LibraryType);
+      mf->AddLinkLibraryForTarget(tgt, value, DEBUG_LibraryType);
       break;
     case CM_LIBRARY_OPTIMIZED:
-      mf->AddLinkLibraryForTarget(tgt,value, OPTIMIZED_LibraryType);
+      mf->AddLinkLibraryForTarget(tgt, value, OPTIMIZED_LibraryType);
       break;
-    }
+  }
 }
 
-void CCONV cmAddLibrary(void *arg, const char *libname, int shared,
-                  int numSrcs, const char **srcs)
+void CCONV cmAddLibrary(void* arg, const char* libname, int shared,
+                        int numSrcs, const char** srcs)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   std::vector<std::string> srcs2;
   int i;
-  for (i = 0; i < numSrcs; ++i)
-    {
+  for (i = 0; i < numSrcs; ++i) {
     srcs2.push_back(srcs[i]);
-    }
+  }
   mf->AddLibrary(libname,
-                 (shared? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY),
-                  srcs2);
+                 (shared ? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY),
+                 srcs2);
 }
 
-char CCONV *cmExpandVariablesInString(void *arg, const char *source,
-                                int escapeQuotes, int atOnly)
+char CCONV* cmExpandVariablesInString(void* arg, const char* source,
+                                      int escapeQuotes, int atOnly)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   std::string barf = source;
-  std::string result =
-    mf->ExpandVariablesInString(barf,
-                                (escapeQuotes ? true : false),
-                                (atOnly ? true : false));
-  char *res = static_cast<char *>(malloc(result.size() + 1));
-  if (result.size())
-    {
-    strcpy(res,result.c_str());
-    }
+  std::string result = mf->ExpandVariablesInString(
+    barf, (escapeQuotes ? true : false), (atOnly ? true : false));
+  char* res = static_cast<char*>(malloc(result.size() + 1));
+  if (result.size()) {
+    strcpy(res, result.c_str());
+  }
   res[result.size()] = '\0';
   return res;
 }
 
-
-int CCONV cmExecuteCommand(void *arg, const char *name,
-                     int numArgs, const char **args)
+int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
+                           const char** args)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   cmListFileFunction lff;
   lff.Name = name;
-  for(int i = 0; i < numArgs; ++i)
-    {
+  for (int i = 0; i < numArgs; ++i) {
     // Assume all arguments are quoted.
     lff.Arguments.push_back(
       cmListFileArgument(args[i], cmListFileArgument::Quoted, 0));
-    }
+  }
   cmExecutionStatus status;
-  return mf->ExecuteCommand(lff,status);
+  return mf->ExecuteCommand(lff, status);
 }
 
-void CCONV cmExpandSourceListArguments(void *arg,
-                                 int numArgs,
-                                 const char **args,
-                                 int *resArgc,
-                                 char ***resArgv,
-                                 unsigned int startArgumentIndex)
+void CCONV cmExpandSourceListArguments(void* arg, int numArgs,
+                                       const char** args, int* resArgc,
+                                       char*** resArgv,
+                                       unsigned int startArgumentIndex)
 {
   (void)arg;
   (void)startArgumentIndex;
   std::vector<std::string> result;
   int i;
-  for (i = 0; i < numArgs; ++i)
-    {
+  for (i = 0; i < numArgs; ++i) {
     result.push_back(args[i]);
-    }
+  }
   int resargc = static_cast<int>(result.size());
-  char **resargv = 0;
-  if (resargc)
-    {
-    resargv = (char **)malloc(resargc*sizeof(char *));
-    }
-  for (i = 0; i < resargc; ++i)
-    {
+  char** resargv = 0;
+  if (resargc) {
+    resargv = (char**)malloc(resargc * sizeof(char*));
+  }
+  for (i = 0; i < resargc; ++i) {
     resargv[i] = strdup(result[i].c_str());
-    }
+  }
   *resArgc = resargc;
   *resArgv = resargv;
 }
 
-void CCONV cmFreeArguments(int argc, char **argv)
+void CCONV cmFreeArguments(int argc, char** argv)
 {
   int i;
-  for (i = 0; i < argc; ++i)
-    {
+  for (i = 0; i < argc; ++i) {
     free(argv[i]);
-    }
-  if (argv)
-    {
+  }
+  if (argv) {
     free(argv);
-    }
+  }
 }
 
-int CCONV cmGetTotalArgumentSize(int argc, char **argv)
+int CCONV cmGetTotalArgumentSize(int argc, char** argv)
 {
   int i;
   int result = 0;
-  for (i = 0; i < argc; ++i)
-    {
-    if (argv[i])
-      {
+  for (i = 0; i < argc; ++i) {
+    if (argv[i]) {
       result = result + static_cast<int>(strlen(argv[i]));
-      }
     }
+  }
   return result;
 }
 
@@ -494,7 +452,10 @@ int CCONV cmGetTotalArgumentSize(int argc, char **argv)
 // API for source files.
 struct cmCPluginAPISourceFile
 {
-  cmCPluginAPISourceFile(): RealSourceFile(0) {}
+  cmCPluginAPISourceFile()
+    : RealSourceFile(0)
+  {
+  }
   cmSourceFile* RealSourceFile;
   std::string SourceName;
   std::string SourceExtension;
@@ -505,54 +466,50 @@ struct cmCPluginAPISourceFile
 
 // Keep a map from real cmSourceFile instances stored in a makefile to
 // the CPluginAPI proxy source file.
-class cmCPluginAPISourceFileMap:
-  public std::map<cmSourceFile*, cmCPluginAPISourceFile*>
+class cmCPluginAPISourceFileMap
+  : public std::map<cmSourceFile*, cmCPluginAPISourceFile*>
 {
 public:
   typedef std::map<cmSourceFile*, cmCPluginAPISourceFile*> derived;
   typedef derived::iterator iterator;
   typedef derived::value_type value_type;
   ~cmCPluginAPISourceFileMap()
-    {
-    for(iterator i=this->begin(); i != this->end(); ++i)
-      {
+  {
+    for (iterator i = this->begin(); i != this->end(); ++i) {
       delete i->second;
-      }
     }
+  }
 };
 cmCPluginAPISourceFileMap cmCPluginAPISourceFiles;
 
-void * CCONV cmCreateSourceFile(void)
+void* CCONV cmCreateSourceFile(void)
 {
   return (void*)new cmCPluginAPISourceFile;
 }
 
-void * CCONV cmCreateNewSourceFile(void *)
+void* CCONV cmCreateNewSourceFile(void*)
 {
-  cmCPluginAPISourceFile *sf = new cmCPluginAPISourceFile;
+  cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
   return (void*)sf;
 }
 
-void CCONV cmDestroySourceFile(void *arg)
+void CCONV cmDestroySourceFile(void* arg)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
   // Only delete if it was created by cmCreateSourceFile or
   // cmCreateNewSourceFile and is therefore not in the map.
-  if(!sf->RealSourceFile)
-    {
+  if (!sf->RealSourceFile) {
     delete sf;
-    }
+  }
 }
 
-void CCONV *cmGetSource(void *arg, const char *name)
+void CCONV* cmGetSource(void* arg, const char* name)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
-  if(cmSourceFile* rsf = mf->GetSource(name))
-    {
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
+  if (cmSourceFile* rsf = mf->GetSource(name)) {
     // Lookup the proxy source file object for this source.
     cmCPluginAPISourceFileMap::iterator i = cmCPluginAPISourceFiles.find(rsf);
-    if(i == cmCPluginAPISourceFiles.end())
-      {
+    if (i == cmCPluginAPISourceFiles.end()) {
       // Create a proxy source file object for this source.
       cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
       sf->RealSourceFile = rsf;
@@ -565,32 +522,28 @@ void CCONV *cmGetSource(void *arg, const char *name)
       // Store the proxy in the map so it can be re-used and deleted later.
       cmCPluginAPISourceFileMap::value_type entry(rsf, sf);
       i = cmCPluginAPISourceFiles.insert(entry).first;
-      }
-    return (void *)i->second;
     }
-  else
-    {
+    return (void*)i->second;
+  } else {
     return 0;
-    }
+  }
 }
 
-void * CCONV cmAddSource(void *arg, void *arg2)
+void* CCONV cmAddSource(void* arg, void* arg2)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   cmCPluginAPISourceFile* osf = static_cast<cmCPluginAPISourceFile*>(arg2);
-  if(osf->FullPath.empty())
-    {
+  if (osf->FullPath.empty()) {
     return 0;
-    }
+  }
 
   // Create the real cmSourceFile instance and copy over saved information.
   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)
-    {
+  for (std::vector<std::string>::iterator i = osf->Depends.begin();
+       i != osf->Depends.end(); ++i) {
     rsf->AddDepend(i->c_str());
-    }
+  }
 
   // Create the proxy for the real source file.
   cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
@@ -601,103 +554,89 @@ void * CCONV cmAddSource(void *arg, void *arg2)
 
   // Store the proxy in the map so it can be re-used and deleted later.
   cmCPluginAPISourceFiles[rsf] = sf;
-  return (void *)sf;
+  return (void*)sf;
 }
 
-const char * CCONV cmSourceFileGetSourceName(void *arg)
+const char* CCONV cmSourceFileGetSourceName(void* arg)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
   return sf->SourceName.c_str();
 }
 
-const char * CCONV  cmSourceFileGetFullPath(void *arg)
+const char* CCONV cmSourceFileGetFullPath(void* arg)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
   return sf->FullPath.c_str();
 }
 
-const char * CCONV  cmSourceFileGetProperty(void *arg,const char *prop)
+const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
-  if(cmSourceFile* rsf = sf->RealSourceFile)
-    {
+  if (cmSourceFile* rsf = sf->RealSourceFile) {
     return rsf->GetProperty(prop);
-    }
-  else
-    {
-    if(!strcmp(prop,"LOCATION"))
-      {
+  } else {
+    if (!strcmp(prop, "LOCATION")) {
       return sf->FullPath.c_str();
-      }
-    return sf->Properties.GetPropertyValue(prop);
     }
+    return sf->Properties.GetPropertyValue(prop);
+  }
 }
 
-int CCONV cmSourceFileGetPropertyAsBool(void *arg,const char *prop)
+int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
-  if(cmSourceFile* rsf = sf->RealSourceFile)
-    {
-    return rsf->GetPropertyAsBool(prop) ? 1:0;
-    }
-  else
-    {
-    return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop))? 1:0;
-    }
+  if (cmSourceFile* rsf = sf->RealSourceFile) {
+    return rsf->GetPropertyAsBool(prop) ? 1 : 0;
+  } else {
+    return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
+  }
 }
 
-void CCONV cmSourceFileSetProperty(void *arg,const char *prop,
-                                   const char *value)
+void CCONV cmSourceFileSetProperty(void* arg, const char* prop,
+                                   const char* value)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
-  if(cmSourceFile* rsf = sf->RealSourceFile)
-    {
+  if (cmSourceFile* rsf = sf->RealSourceFile) {
     rsf->SetProperty(prop, value);
+  } else if (prop) {
+    if (!value) {
+      value = "NOTFOUND";
     }
-  else if(prop)
-    {
-    if(!value) { value = "NOTFOUND"; }
     sf->Properties.SetProperty(prop, value);
-    }
+  }
 }
 
-void CCONV cmSourceFileAddDepend(void *arg, const char *depend)
+void CCONV cmSourceFileAddDepend(void* arg, const char* depend)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
-  if(cmSourceFile* rsf = sf->RealSourceFile)
-    {
+  if (cmSourceFile* rsf = sf->RealSourceFile) {
     rsf->AddDepend(depend);
-    }
-  else
-    {
+  } else {
     sf->Depends.push_back(depend);
-    }
+  }
 }
 
-void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
+void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
                                int numSourceExtensions,
-                               const char **sourceExtensions,
+                               const char** sourceExtensions,
                                int numHeaderExtensions,
-                               const char **headerExtensions)
+                               const char** headerExtensions)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
-  if(sf->RealSourceFile)
-    {
+  if (sf->RealSourceFile) {
     // SetName is allowed only on temporary source files created by
     // the command for building and passing to AddSource.
     return;
-    }
+  }
   std::vector<std::string> sourceExts;
   std::vector<std::string> headerExts;
   int i;
-  for (i = 0; i < numSourceExtensions; ++i)
-    {
+  for (i = 0; i < numSourceExtensions; ++i) {
     sourceExts.push_back(sourceExtensions[i]);
-    }
-  for (i = 0; i < numHeaderExtensions; ++i)
-    {
+  }
+  for (i = 0; i < numHeaderExtensions; ++i) {
     headerExts.push_back(headerExtensions[i]);
-    }
+  }
 
   // Save the original name given.
   sf->SourceName = name;
@@ -709,167 +648,150 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
   // First try and see whether the listed file can be found
   // as is without extensions added on.
   std::string hname = pathname;
-  if(cmSystemTools::FileExists(hname.c_str()))
-    {
+  if (cmSystemTools::FileExists(hname.c_str())) {
     sf->SourceName = cmSystemTools::GetFilenamePath(name);
-    if ( sf->SourceName.size() > 0 )
-      {
+    if (sf->SourceName.size() > 0) {
       sf->SourceName += "/";
-      }
+    }
     sf->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
     std::string::size_type pos = hname.rfind('.');
-    if(pos != std::string::npos)
-      {
-      sf->SourceExtension = hname.substr(pos+1, hname.size()-pos);
-      if ( cmSystemTools::FileIsFullPath(name) )
-        {
+    if (pos != std::string::npos) {
+      sf->SourceExtension = hname.substr(pos + 1, hname.size() - pos);
+      if (cmSystemTools::FileIsFullPath(name)) {
         std::string::size_type pos2 = hname.rfind('/');
-        if(pos2 != std::string::npos)
-          {
-          sf->SourceName = hname.substr(pos2+1, pos - pos2-1);
-          }
+        if (pos2 != std::string::npos) {
+          sf->SourceName = hname.substr(pos2 + 1, pos - pos2 - 1);
         }
       }
+    }
 
     sf->FullPath = hname;
     return;
-    }
+  }
 
   // Next, try the various source extensions
-  for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
-       ext != sourceExts.end(); ++ext )
-    {
+  for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
+       ext != sourceExts.end(); ++ext) {
     hname = pathname;
     hname += ".";
     hname += *ext;
-    if(cmSystemTools::FileExists(hname.c_str()))
-      {
+    if (cmSystemTools::FileExists(hname.c_str())) {
       sf->SourceExtension = *ext;
       sf->FullPath = hname;
       return;
-      }
     }
+  }
 
   // Finally, try the various header extensions
-  for( std::vector<std::string>::const_iterator ext = headerExts.begin();
-       ext != headerExts.end(); ++ext )
-    {
+  for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+       ext != headerExts.end(); ++ext) {
     hname = pathname;
     hname += ".";
     hname += *ext;
-    if(cmSystemTools::FileExists(hname.c_str()))
-      {
+    if (cmSystemTools::FileExists(hname.c_str())) {
       sf->SourceExtension = *ext;
       sf->FullPath = hname;
       return;
-      }
     }
+  }
 
   std::ostringstream e;
   e << "Cannot find source file \"" << pathname << "\"";
   e << "\n\nTried extensions";
-  for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
-       ext != sourceExts.end(); ++ext )
-    {
+  for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
+       ext != sourceExts.end(); ++ext) {
     e << " ." << *ext;
-    }
-  for( std::vector<std::string>::const_iterator ext = headerExts.begin();
-       ext != headerExts.end(); ++ext )
-    {
+  }
+  for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+       ext != headerExts.end(); ++ext) {
     e << " ." << *ext;
-    }
+  }
   cmSystemTools::Error(e.str().c_str());
   return;
 }
 
-void CCONV cmSourceFileSetName2(void *arg, const char* name, const char* dir,
-                                const char *ext, int headerFileOnly)
+void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
+                                const char* ext, int headerFileOnly)
 {
   cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
-  if(sf->RealSourceFile)
-    {
+  if (sf->RealSourceFile) {
     // SetName is allowed only on temporary source files created by
     // the command for building and passing to AddSource.
     return;
-    }
+  }
 
   // Implement the old SetName method code here.
-  if(headerFileOnly)
-    {
+  if (headerFileOnly) {
     sf->Properties.SetProperty("HEADER_FILE_ONLY", "1");
-    }
+  }
   sf->SourceName = name;
   std::string fname = sf->SourceName;
-  if(ext && strlen(ext))
-    {
+  if (ext && strlen(ext)) {
     fname += ".";
     fname += ext;
-    }
+  }
   sf->FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir);
   cmSystemTools::ConvertToUnixSlashes(sf->FullPath);
   sf->SourceExtension = ext;
 }
 
-char * CCONV cmGetFilenameWithoutExtension(const char *name)
+char* CCONV cmGetFilenameWithoutExtension(const char* name)
 {
   std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
-  char *result = (char *)malloc(sres.size()+1);
-  strcpy(result,sres.c_str());
+  char* result = (char*)malloc(sres.size() + 1);
+  strcpy(result, sres.c_str());
   return result;
 }
 
-char * CCONV cmGetFilenamePath(const char *name)
+char* CCONV cmGetFilenamePath(const char* name)
 {
   std::string sres = cmSystemTools::GetFilenamePath(name);
-  char *result = (char *)malloc(sres.size()+1);
-  strcpy(result,sres.c_str());
+  char* result = (char*)malloc(sres.size() + 1);
+  strcpy(result, sres.c_str());
   return result;
 }
 
-char * CCONV cmCapitalized(const char *name)
+char* CCONV cmCapitalized(const char* name)
 {
   std::string sres = cmSystemTools::Capitalized(name);
-  char *result = (char *)malloc(sres.size()+1);
-  strcpy(result,sres.c_str());
+  char* result = (char*)malloc(sres.size() + 1);
+  strcpy(result, sres.c_str());
   return result;
 }
 
-void CCONV cmCopyFileIfDifferent(const char *name1, const char *name2)
+void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)
 {
-  cmSystemTools::CopyFileIfDifferent(name1,name2);
+  cmSystemTools::CopyFileIfDifferent(name1, name2);
 }
 
-void CCONV cmRemoveFile(const char *name)
+void CCONV cmRemoveFile(const char* name)
 {
   cmSystemTools::RemoveFile(name);
 }
 
-void CCONV cmDisplayStatus(void *arg, const char* message)
+void CCONV cmDisplayStatus(void* arg, const char* message)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
   mf->DisplayStatus(message, -1);
 }
 
-void CCONV cmFree(void *data)
+void CCONV cmFree(void* data)
 {
   free(data);
 }
 
-void CCONV DefineSourceFileProperty (void *arg, const char *name,
-  const char *briefDocs,
-  const char *longDocs,
-  int chained)
+void CCONV DefineSourceFileProperty(void* arg, const char* name,
+                                    const char* briefDocs,
+                                    const char* longDocs, int chained)
 {
-  cmMakefile *mf = static_cast<cmMakefile *>(arg);
-  mf->GetState()->DefineProperty(name,cmProperty::SOURCE_FILE,
-                                         briefDocs, longDocs,
-                                         chained != 0);
+  cmMakefile* mf = static_cast<cmMakefile*>(arg);
+  mf->GetState()->DefineProperty(name, cmProperty::SOURCE_FILE, briefDocs,
+                                 longDocs, chained != 0);
 }
 
 } // close the extern "C" scope
 
-cmCAPI cmStaticCAPI =
-{
+cmCAPI cmStaticCAPI = {
   cmGetClientData,
   cmGetTotalArgumentSize,
   cmFreeArguments,
@@ -928,4 +850,3 @@ cmCAPI cmStaticCAPI =
   cmCreateNewSourceFile,
   DefineSourceFileProperty,
 };
-
diff --git a/Source/cmCPluginAPI.h b/Source/cmCPluginAPI.h
index 5c832c3..4d9a9a7 100644
--- a/Source/cmCPluginAPI.h
+++ b/Source/cmCPluginAPI.h
@@ -23,7 +23,7 @@
 #define CMAKE_VERSION_MAJOR 2
 #define CMAKE_VERSION_MINOR 5
 
-#ifdef  __cplusplus
+#ifdef __cplusplus
 extern "C" {
 #endif
 
@@ -46,141 +46,131 @@ typedef struct
   /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
      information is passed from the InitialPass to FInalPass for commands
      that need a FinalPass and need information from the InitialPass */
-  void *(CCONV *GetClientData) (void *info);
+  void*(CCONV* GetClientData)(void* info);
   /* return the summed size in characters of all the arguments */
-  int   (CCONV *GetTotalArgumentSize) (int argc, char **argv);
+  int(CCONV* GetTotalArgumentSize)(int argc, char** argv);
   /* free all the memory associated with an argc, argv pair */
-  void  (CCONV *FreeArguments) (int argc, char **argv);
+  void(CCONV* FreeArguments)(int argc, char** argv);
   /* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
      information is passed from the InitialPass to FInalPass for commands
      that need a FinalPass and need information from the InitialPass */
-  void  (CCONV *SetClientData) (void *info, void *cd);
+  void(CCONV* SetClientData)(void* info, void* cd);
   /* when an error occurs, call this function to set the error string */
-  void  (CCONV *SetError) (void *info, const char *err);
+  void(CCONV* SetError)(void* info, const char* err);
 
   /*=========================================================================
   The following functions all directly map to methods in the cmMakefile
   class. See cmMakefile.h for descriptions of what each method does. All of
   these methods take the void * makefile pointer as their first argument.
   =========================================================================*/
-  void  (CCONV *AddCacheDefinition) (void *mf, const char* name,
-                               const char* value,
-                               const char* doc, int cachetype);
-  void  (CCONV *AddCustomCommand) (void *mf, const char* source,
-                             const char* command,
-                             int numArgs, const char **args,
-                             int numDepends, const char **depends,
-                             int numOutputs, const char **outputs,
-                             const char *target);
-  void  (CCONV *AddDefineFlag) (void *mf, const char* definition);
-  void  (CCONV *AddDefinition) (void *mf, const char* name,
-                                const char* value);
-  void  (CCONV *AddExecutable) (void *mf, const char *exename,
-                         int numSrcs, const char **srcs, int win32);
-  void  (CCONV *AddLibrary) (void *mf, const char *libname,
-                       int shared, int numSrcs, const char **srcs);
-  void  (CCONV *AddLinkDirectoryForTarget) (void *mf, const char *tgt,
-                                      const char* d);
-  void  (CCONV *AddLinkLibraryForTarget) (void *mf, const char *tgt,
-                                    const char *libname, int libtype);
-  void  (CCONV *AddUtilityCommand) (void *mf, const char* utilityName,
-                              const char *command, const char *arguments,
-                              int all, int numDepends, const char **depends,
-                              int numOutputs, const char **outputs);
-  int   (CCONV *CommandExists) (void *mf, const char* name);
-  int  (CCONV *ExecuteCommand) (void *mf, const char *name,
-                          int numArgs, const char **args);
-  void  (CCONV *ExpandSourceListArguments) (void *mf,int argc,
-                                      const char **argv,
-                                      int *resArgc, char ***resArgv,
-                                      unsigned int startArgumentIndex);
-  char *(CCONV *ExpandVariablesInString) (void *mf, const char *source,
-                                    int escapeQuotes, int atOnly);
-  unsigned int (CCONV *GetCacheMajorVersion) (void *mf);
-  unsigned int (CCONV *GetCacheMinorVersion) (void *mf);
-  const char*  (CCONV *GetCurrentDirectory) (void *mf);
-  const char*  (CCONV *GetCurrentOutputDirectory) (void *mf);
-  const char*  (CCONV *GetDefinition) (void *mf, const char *def);
-  const char*  (CCONV *GetHomeDirectory) (void *mf);
-  const char*  (CCONV *GetHomeOutputDirectory) (void *mf);
-  unsigned int (CCONV *GetMajorVersion) (void *mf);
-  unsigned int (CCONV *GetMinorVersion) (void *mf);
-  const char*  (CCONV *GetProjectName) (void *mf);
-  const char*  (CCONV *GetStartDirectory) (void *mf);
-  const char*  (CCONV *GetStartOutputDirectory) (void *mf);
-  int          (CCONV *IsOn) (void *mf, const char* name);
-
+  void(CCONV* AddCacheDefinition)(void* mf, const char* name,
+                                  const char* value, const char* doc,
+                                  int cachetype);
+  void(CCONV* AddCustomCommand)(void* mf, const char* source,
+                                const char* command, int numArgs,
+                                const char** args, int numDepends,
+                                const char** depends, int numOutputs,
+                                const char** outputs, const char* target);
+  void(CCONV* AddDefineFlag)(void* mf, const char* definition);
+  void(CCONV* AddDefinition)(void* mf, const char* name, const char* value);
+  void(CCONV* AddExecutable)(void* mf, const char* exename, int numSrcs,
+                             const char** srcs, int win32);
+  void(CCONV* AddLibrary)(void* mf, const char* libname, int shared,
+                          int numSrcs, const char** srcs);
+  void(CCONV* AddLinkDirectoryForTarget)(void* mf, const char* tgt,
+                                         const char* d);
+  void(CCONV* AddLinkLibraryForTarget)(void* mf, const char* tgt,
+                                       const char* libname, int libtype);
+  void(CCONV* AddUtilityCommand)(void* mf, const char* utilityName,
+                                 const char* command, const char* arguments,
+                                 int all, int numDepends, const char** depends,
+                                 int numOutputs, const char** outputs);
+  int(CCONV* CommandExists)(void* mf, const char* name);
+  int(CCONV* ExecuteCommand)(void* mf, const char* name, int numArgs,
+                             const char** args);
+  void(CCONV* ExpandSourceListArguments)(void* mf, int argc, const char** argv,
+                                         int* resArgc, char*** resArgv,
+                                         unsigned int startArgumentIndex);
+  char*(CCONV* ExpandVariablesInString)(void* mf, const char* source,
+                                        int escapeQuotes, int atOnly);
+  unsigned int(CCONV* GetCacheMajorVersion)(void* mf);
+  unsigned int(CCONV* GetCacheMinorVersion)(void* mf);
+  const char*(CCONV* GetCurrentDirectory)(void* mf);
+  const char*(CCONV* GetCurrentOutputDirectory)(void* mf);
+  const char*(CCONV* GetDefinition)(void* mf, const char* def);
+  const char*(CCONV* GetHomeDirectory)(void* mf);
+  const char*(CCONV* GetHomeOutputDirectory)(void* mf);
+  unsigned int(CCONV* GetMajorVersion)(void* mf);
+  unsigned int(CCONV* GetMinorVersion)(void* mf);
+  const char*(CCONV* GetProjectName)(void* mf);
+  const char*(CCONV* GetStartDirectory)(void* mf);
+  const char*(CCONV* GetStartOutputDirectory)(void* mf);
+  int(CCONV* IsOn)(void* mf, const char* name);
 
   /*=========================================================================
   The following functions are designed to operate or manipulate
   cmSourceFiles. Please see cmSourceFile.h for additional information on many
   of these methods. Some of these methods are in cmMakefile.h.
   =========================================================================*/
-  void *(CCONV *AddSource) (void *mf, void *sf);
-  void *(CCONV *CreateSourceFile) ();
-  void  (CCONV *DestroySourceFile) (void *sf);
-  void *(CCONV *GetSource) (void *mf, const char* sourceName);
-  void  (CCONV *SourceFileAddDepend) (void *sf, const char *depend);
-  const char *(CCONV *SourceFileGetProperty) (void *sf, const char *prop);
-  int   (CCONV *SourceFileGetPropertyAsBool) (void *sf, const char *prop);
-  const char *(CCONV *SourceFileGetSourceName) (void *sf);
-  const char *(CCONV *SourceFileGetFullPath) (void *sf);
-  void  (CCONV *SourceFileSetName) (void *sf, const char* name,
-                             const char* dir,
-                             int numSourceExtensions,
-                             const char **sourceExtensions,
-                             int numHeaderExtensions,
-                             const char **headerExtensions);
-  void  (CCONV *SourceFileSetName2) (void *sf, const char* name,
-                               const char* dir,
-                               const char *ext, int headerFileOnly);
-  void  (CCONV *SourceFileSetProperty) (void *sf, const char *prop,
-                                  const char *value);
-
+  void*(CCONV* AddSource)(void* mf, void* sf);
+  void*(CCONV* CreateSourceFile)();
+  void(CCONV* DestroySourceFile)(void* sf);
+  void*(CCONV* GetSource)(void* mf, const char* sourceName);
+  void(CCONV* SourceFileAddDepend)(void* sf, const char* depend);
+  const char*(CCONV* SourceFileGetProperty)(void* sf, const char* prop);
+  int(CCONV* SourceFileGetPropertyAsBool)(void* sf, const char* prop);
+  const char*(CCONV* SourceFileGetSourceName)(void* sf);
+  const char*(CCONV* SourceFileGetFullPath)(void* sf);
+  void(CCONV* SourceFileSetName)(void* sf, const char* name, const char* dir,
+                                 int numSourceExtensions,
+                                 const char** sourceExtensions,
+                                 int numHeaderExtensions,
+                                 const char** headerExtensions);
+  void(CCONV* SourceFileSetName2)(void* sf, const char* name, const char* dir,
+                                  const char* ext, int headerFileOnly);
+  void(CCONV* SourceFileSetProperty)(void* sf, const char* prop,
+                                     const char* value);
 
   /*=========================================================================
   The following methods are from cmSystemTools.h see that file for specific
   documentation on each method.
   =========================================================================*/
-  char  *(CCONV *Capitalized)(const char *);
-  void   (CCONV *CopyFileIfDifferent)(const char *f1, const char *f2);
-  char  *(CCONV *GetFilenameWithoutExtension)(const char *);
-  char  *(CCONV *GetFilenamePath)(const char *);
-  void   (CCONV *RemoveFile)(const char *f1);
-  void   (CCONV *Free)(void *);
+  char*(CCONV* Capitalized)(const char*);
+  void(CCONV* CopyFileIfDifferent)(const char* f1, const char* f2);
+  char*(CCONV* GetFilenameWithoutExtension)(const char*);
+  char*(CCONV* GetFilenamePath)(const char*);
+  void(CCONV* RemoveFile)(const char* f1);
+  void(CCONV* Free)(void*);
 
   /*=========================================================================
     The following are new functions added after 1.6
   =========================================================================*/
-  void  (CCONV *AddCustomCommandToOutput) (void *mf, const char* output,
-                                     const char* command,
-                                     int numArgs, const char **args,
-                                     const char* main_dependency,
-                                     int numDepends, const char **depends);
-  void  (CCONV *AddCustomCommandToTarget) (void *mf, const char* target,
-                                     const char* command,
-                                     int numArgs, const char **args,
-                                     int commandType);
+  void(CCONV* AddCustomCommandToOutput)(void* mf, const char* output,
+                                        const char* command, int numArgs,
+                                        const char** args,
+                                        const char* main_dependency,
+                                        int numDepends, const char** depends);
+  void(CCONV* AddCustomCommandToTarget)(void* mf, const char* target,
+                                        const char* command, int numArgs,
+                                        const char** args, int commandType);
 
   /* display status information */
-  void  (CCONV *DisplaySatus) (void *info, const char *message);
+  void(CCONV* DisplaySatus)(void* info, const char* message);
 
   /* new functions added after 2.4 */
-  void *(CCONV *CreateNewSourceFile) (void *mf);
-  void (CCONV *DefineSourceFileProperty) (void *mf, const char *name,
-                                          const char *briefDocs,
-                                          const char *longDocs,
-                                          int chained);
+  void*(CCONV* CreateNewSourceFile)(void* mf);
+  void(CCONV* DefineSourceFileProperty)(void* mf, const char* name,
+                                        const char* briefDocs,
+                                        const char* longDocs, int chained);
 
   /* this is the end of the C function stub API structure */
 } cmCAPI;
 
-
 /*=========================================================================
 CM_PLUGIN_EXPORT should be used by plugins
 =========================================================================*/
 #ifdef _WIN32
-#define CM_PLUGIN_EXPORT  __declspec( dllexport )
+#define CM_PLUGIN_EXPORT __declspec(dllexport)
 #else
 #define CM_PLUGIN_EXPORT
 #endif
@@ -206,37 +196,38 @@ define the different types of compiles a library may be
 /*=========================================================================
 define the different types of custom commands for a target
 =========================================================================*/
-#define CM_PRE_BUILD  0
-#define CM_PRE_LINK   1
+#define CM_PRE_BUILD 0
+#define CM_PRE_LINK 1
 #define CM_POST_BUILD 2
 
 /*=========================================================================
 Finally we define the key data structures and function prototypes
 =========================================================================*/
-  typedef const char* (CCONV *CM_DOC_FUNCTION)();
-  typedef int (CCONV *CM_INITIAL_PASS_FUNCTION)(void *info, void *mf,
-                                          int argc, char *[]);
-  typedef void (CCONV *CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
-  typedef void (CCONV *CM_DESTRUCTOR_FUNCTION)(void *info);
-
-  typedef struct {
-    unsigned long reserved1; /* Reserved for future use.  DO NOT USE.  */
-    unsigned long reserved2; /* Reserved for future use.  DO NOT USE.  */
-    cmCAPI *CAPI;
-    int m_Inherited; /* this ivar is no longer used in CMake 2.2 or later */
-    CM_INITIAL_PASS_FUNCTION InitialPass;
-    CM_FINAL_PASS_FUNCTION FinalPass;
-    CM_DESTRUCTOR_FUNCTION Destructor;
-    CM_DOC_FUNCTION GetTerseDocumentation;
-    CM_DOC_FUNCTION GetFullDocumentation;
-    const char *Name;
-    char *Error;
-    void *ClientData;
-  } cmLoadedCommandInfo;
-
-  typedef void (CCONV *CM_INIT_FUNCTION)(cmLoadedCommandInfo *);
-
-#ifdef  __cplusplus
+typedef const char*(CCONV* CM_DOC_FUNCTION)();
+typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc,
+                                             char* []);
+typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf);
+typedef void(CCONV* CM_DESTRUCTOR_FUNCTION)(void* info);
+
+typedef struct
+{
+  unsigned long reserved1; /* Reserved for future use.  DO NOT USE.  */
+  unsigned long reserved2; /* Reserved for future use.  DO NOT USE.  */
+  cmCAPI* CAPI;
+  int m_Inherited; /* this ivar is no longer used in CMake 2.2 or later */
+  CM_INITIAL_PASS_FUNCTION InitialPass;
+  CM_FINAL_PASS_FUNCTION FinalPass;
+  CM_DESTRUCTOR_FUNCTION Destructor;
+  CM_DOC_FUNCTION GetTerseDocumentation;
+  CM_DOC_FUNCTION GetFullDocumentation;
+  const char* Name;
+  char* Error;
+  void* ClientData;
+} cmLoadedCommandInfo;
+
+typedef void(CCONV* CM_INIT_FUNCTION)(cmLoadedCommandInfo*);
+
+#ifdef __cplusplus
 }
 #endif
 
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index f3e7121..bc36c5a 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -12,24 +12,25 @@
 #include "cmCurl.h" // include before anything that includes windows.h
 
 #include "cmCTest.h"
-#include "cmake.h"
-#include "cmMakefile.h"
-#include "cmGlobalGenerator.h"
-#include <cmsys/Base64.h>
-#include <cmsys/Directory.hxx>
-#include <cmsys/SystemInformation.hxx>
-#include <cmsys/FStream.hxx>
-#include "cmDynamicLoader.h"
-#include "cmGeneratedFileStream.h"
-#include "cmVersionMacros.h"
+
+#include "cmAlgorithms.h"
 #include "cmCTestCommand.h"
 #include "cmCTestStartCommand.h"
-#include "cmAlgorithms.h"
+#include "cmDynamicLoader.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
 #include "cmState.h"
+#include "cmVersionMacros.h"
 #include "cmXMLWriter.h"
+#include "cmake.h"
+#include <cmsys/Base64.h>
+#include <cmsys/Directory.hxx>
+#include <cmsys/FStream.hxx>
+#include <cmsys/SystemInformation.hxx>
 
-#include "cmCTestBuildHandler.h"
 #include "cmCTestBuildAndTestHandler.h"
+#include "cmCTestBuildHandler.h"
 #include "cmCTestConfigureHandler.h"
 #include "cmCTestCoverageHandler.h"
 #include "cmCTestMemCheckHandler.h"
@@ -41,14 +42,14 @@
 
 #include "cmVersion.h"
 
-#include <cmsys/RegularExpression.hxx>
-#include <cmsys/Process.h>
 #include <cmsys/Glob.hxx>
+#include <cmsys/Process.h>
+#include <cmsys/RegularExpression.hxx>
 
-#include <stdlib.h>
-#include <math.h>
-#include <float.h>
 #include <ctype.h>
+#include <float.h>
+#include <math.h>
+#include <stdlib.h>
 
 #include <cmsys/auto_ptr.hxx>
 
@@ -56,16 +57,17 @@
 #include <cmsys/Base64.h>
 
 #if defined(__BEOS__) || defined(__HAIKU__)
-#include <be/kernel/OS.h>   /* disable_debugger() API. */
+#include <be/kernel/OS.h> /* disable_debugger() API. */
 #endif
 
+#define DEBUGOUT                                                              \
+  std::cout << __LINE__ << " ";                                               \
+  std::cout
+#define DEBUGERR                                                              \
+  std::cerr << __LINE__ << " ";                                               \
+  std::cerr
 
-#define DEBUGOUT std::cout << __LINE__ << " "; std::cout
-#define DEBUGERR std::cerr << __LINE__ << " "; std::cerr
-
-//----------------------------------------------------------------------
-struct tm* cmCTest::GetNightlyTime(std::string str,
-                                   bool tomorrowtag)
+struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
 {
   struct tm* lctime;
   time_t tctime = time(0);
@@ -73,19 +75,17 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
   char buf[1024];
   // add todays year day and month to the time in str because
   // curl_getdate no longer assumes the day is today
-  sprintf(buf, "%d%02d%02d %s",
-          lctime->tm_year+1900,
-          lctime->tm_mon +1,
-          lctime->tm_mday,
-          str.c_str());
-  cmCTestLog(this, OUTPUT, "Determine Nightly Start Time" << 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
-  //is the time at which the nightly dashboard was opened or
-  //will be opened on the date of the current client machine.
-  //As such, this time may be in the past or in the future.
+  sprintf(buf, "%d%02d%02d %s", lctime->tm_year + 1900, lctime->tm_mon + 1,
+          lctime->tm_mday, str.c_str());
+  cmCTestLog(this, OUTPUT, "Determine Nightly Start Time"
+               << 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
+  // is the time at which the nightly dashboard was opened or
+  // will be opened on the date of the current client machine.
+  // As such, this time may be in the past or in the future.
   time_t ntime = curl_getdate(buf, &tctime);
   cmCTestLog(this, DEBUG, "   Get curl time: " << ntime << std::endl);
   tctime = time(0);
@@ -93,8 +93,7 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
 
   const int dayLength = 24 * 60 * 60;
   cmCTestLog(this, DEBUG, "Seconds: " << tctime << std::endl);
-  while ( ntime > tctime )
-    {
+  while (ntime > tctime) {
     // If nightlySeconds is in the past, this is the current
     // open dashboard, then return nightlySeconds.  If
     // nightlySeconds is in the future, this is the next
@@ -103,91 +102,76 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
     ntime -= dayLength;
     cmCTestLog(this, DEBUG, "Pick yesterday" << std::endl);
     cmCTestLog(this, DEBUG, "   Future time, subtract day: " << ntime
-      << std::endl);
-    }
-  while ( tctime > (ntime + dayLength) )
-    {
+                                                             << std::endl);
+  }
+  while (tctime > (ntime + dayLength)) {
     ntime += dayLength;
     cmCTestLog(this, DEBUG, "   Past time, add day: " << ntime << std::endl);
-    }
+  }
   cmCTestLog(this, DEBUG, "nightlySeconds: " << ntime << std::endl);
-  cmCTestLog(this, DEBUG, "   Current time: " << tctime
-    << " Nightly time: " << ntime << std::endl);
-  if ( tomorrowtag )
-    {
+  cmCTestLog(this, DEBUG, "   Current time: " << tctime << " Nightly time: "
+                                              << ntime << std::endl);
+  if (tomorrowtag) {
     cmCTestLog(this, OUTPUT, "   Use future tag, Add a day" << std::endl);
     ntime += dayLength;
-    }
+  }
   lctime = gmtime(&ntime);
   return lctime;
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::CleanString(const std::string& str)
 {
   std::string::size_type spos = str.find_first_not_of(" \n\t\r\f\v");
   std::string::size_type epos = str.find_last_not_of(" \n\t\r\f\v");
-  if ( spos == str.npos )
-    {
+  if (spos == str.npos) {
     return std::string();
-    }
-  if ( epos != str.npos )
-    {
+  }
+  if (epos != str.npos) {
     epos = epos - spos + 1;
-    }
+  }
   return str.substr(spos, epos);
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::CurrentTime()
 {
   time_t currenttime = time(0);
   struct tm* t = localtime(&currenttime);
-  //return ::CleanString(ctime(&currenttime));
+  // return ::CleanString(ctime(&currenttime));
   char current_time[1024];
-  if ( this->ShortDateFormat )
-    {
+  if (this->ShortDateFormat) {
     strftime(current_time, 1000, "%b %d %H:%M %Z", t);
-    }
-  else
-    {
+  } else {
     strftime(current_time, 1000, "%a %b %d %H:%M:%S %Z %Y", t);
-    }
+  }
   cmCTestLog(this, DEBUG, "   Current_Time: " << current_time << std::endl);
   return cmCTest::CleanString(current_time);
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::GetCostDataFile()
 {
   std::string fname = this->GetCTestConfiguration("CostDataFile");
-  if(fname == "")
-    {
-    fname= this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
-    }
+  if (fname == "") {
+    fname = this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
+  }
   return fname;
 }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
-//----------------------------------------------------------------------------
-static size_t
-HTTPResponseCallback(void *ptr, size_t size, size_t nmemb, void *data)
+static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
+                                   void* data)
 {
   int realsize = (int)(size * nmemb);
 
-  std::string *response
-    = static_cast<std::string*>(data);
+  std::string* response = static_cast<std::string*>(data);
   const char* chPtr = static_cast<char*>(ptr);
   *response += chPtr;
 
   return realsize;
 }
 
-//----------------------------------------------------------------------------
 int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
-                                       std::string& response,
-                                       std::string fields,
-                                       std::string putFile, int timeout)
+                         std::string& response, std::string const& fields,
+                         std::string const& putFile, int timeout)
 {
   CURL* curl;
   FILE* file;
@@ -195,39 +179,36 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
   curl = ::curl_easy_init();
   cmCurlSetCAInfo(curl);
 
-  //set request options based on method
-  switch(method)
-    {
+  // set request options based on method
+  switch (method) {
     case cmCTest::HTTP_POST:
       ::curl_easy_setopt(curl, CURLOPT_POST, 1);
       ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
       break;
     case cmCTest::HTTP_PUT:
-      if(!cmSystemTools::FileExists(putFile.c_str()))
-        {
+      if (!cmSystemTools::FileExists(putFile.c_str())) {
         response = "Error: File ";
         response += putFile + " does not exist.\n";
         return -1;
-        }
+      }
       ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
       file = cmsys::SystemTools::Fopen(putFile, "rb");
       ::curl_easy_setopt(curl, CURLOPT_INFILE, file);
-      //fall through to append GET fields
+    // fall through to append GET fields
     case cmCTest::HTTP_GET:
-      if(!fields.empty())
-        {
+      if (!fields.empty()) {
         url += "?" + fields;
-        }
+      }
       break;
-    }
+  }
 
   ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
   ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
   ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
 
-  //set response options
+  // set response options
   ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback);
-  ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&response);
+  ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&response);
   ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
 
   CURLcode res = ::curl_easy_perform(curl);
@@ -239,103 +220,88 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
 }
 #endif
 
-//----------------------------------------------------------------------
 std::string cmCTest::MakeURLSafe(const std::string& str)
 {
   std::ostringstream ost;
   char buffer[10];
-  for ( std::string::size_type pos = 0; pos < str.size(); pos ++ )
-    {
+  for (std::string::size_type pos = 0; pos < str.size(); pos++) {
     unsigned char ch = str[pos];
-    if ( ( ch > 126 || ch < 32 ||
-           ch == '&' ||
-           ch == '%' ||
-           ch == '+' ||
-           ch == '=' ||
-           ch == '@'
-          ) && ch != 9 )
-      {
+    if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
+         ch == '=' || ch == '@') &&
+        ch != 9) {
       sprintf(buffer, "%02x;", (unsigned int)ch);
       ost << buffer;
-      }
-    else
-      {
+    } else {
       ost << ch;
-      }
     }
+  }
   return ost.str();
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTest::DecodeURL(const std::string& in)
 {
   std::string out;
-  for(const char* c = in.c_str(); *c; ++c)
-    {
-    if(*c == '%' && isxdigit(*(c+1)) && isxdigit(*(c+2)))
-      {
-      char buf[3] = {*(c+1), *(c+2), 0};
+  for (const char* c = in.c_str(); *c; ++c) {
+    if (*c == '%' && isxdigit(*(c + 1)) && isxdigit(*(c + 2))) {
+      char buf[3] = { *(c + 1), *(c + 2), 0 };
       out.append(1, char(strtoul(buf, 0, 16)));
       c += 2;
-      }
-    else
-      {
+    } else {
       out.append(1, *c);
-      }
     }
+  }
   return out;
 }
 
-//----------------------------------------------------------------------
 cmCTest::cmCTest()
 {
-  this->LabelSummary           = true;
-  this->ParallelLevel          = 1;
-  this->ParallelLevelSetInCli  = false;
-  this->TestLoad               = 0;
-  this->SubmitIndex            = 0;
-  this->Failover               = false;
-  this->BatchJobs              = false;
-  this->ForceNewCTestProcess   = false;
-  this->TomorrowTag            = false;
-  this->Verbose                = false;
-
-  this->Debug                  = false;
-  this->ShowLineNumbers        = false;
-  this->Quiet                  = false;
-  this->ExtraVerbose           = false;
-  this->ProduceXML             = false;
-  this->ShowOnly               = false;
+  this->LabelSummary = true;
+  this->ParallelLevel = 1;
+  this->ParallelLevelSetInCli = false;
+  this->TestLoad = 0;
+  this->SubmitIndex = 0;
+  this->Failover = false;
+  this->BatchJobs = false;
+  this->ForceNewCTestProcess = false;
+  this->TomorrowTag = false;
+  this->Verbose = false;
+
+  this->Debug = false;
+  this->ShowLineNumbers = false;
+  this->Quiet = false;
+  this->ExtraVerbose = false;
+  this->ProduceXML = false;
+  this->ShowOnly = false;
   this->RunConfigurationScript = false;
-  this->UseHTTP10              = false;
-  this->PrintLabels            = false;
-  this->CompressTestOutput     = true;
+  this->UseHTTP10 = false;
+  this->PrintLabels = false;
+  this->CompressTestOutput = true;
   this->CompressMemCheckOutput = true;
-  this->TestModel              = cmCTest::EXPERIMENTAL;
-  this->MaxTestNameWidth       = 30;
-  this->InteractiveDebugMode   = true;
-  this->TimeOut                = 0;
-  this->GlobalTimeout          = 0;
-  this->LastStopTimeout        = 24 * 60 * 60;
-  this->CompressXMLFiles       = false;
-  this->CTestConfigFile        = "";
-  this->ScheduleType           = "";
-  this->StopTime               = "";
-  this->NextDayStopTime        = false;
-  this->OutputLogFile          = 0;
-  this->OutputLogFileLastTag   = -1;
+  this->TestModel = cmCTest::EXPERIMENTAL;
+  this->MaxTestNameWidth = 30;
+  this->InteractiveDebugMode = true;
+  this->TimeOut = 0;
+  this->GlobalTimeout = 0;
+  this->LastStopTimeout = 24 * 60 * 60;
+  this->CompressXMLFiles = false;
+  this->CTestConfigFile = "";
+  this->ScheduleType = "";
+  this->StopTime = "";
+  this->NextDayStopTime = false;
+  this->OutputLogFile = 0;
+  this->OutputLogFileLastTag = -1;
   this->SuppressUpdatingCTestConfiguration = false;
-  this->DartVersion            = 1;
-  this->DropSiteCDash          = false;
+  this->DartVersion = 1;
+  this->DropSiteCDash = false;
   this->OutputTestOutputOnTestFailure = false;
   this->ComputedCompressTestOutput = false;
   this->ComputedCompressMemCheckOutput = false;
   this->RepeatTests = 1; // default to run each test once
   this->RepeatUntilFail = false;
-  if(const char* outOnFail = cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE"))
-    {
+  if (const char* outOnFail =
+        cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE")) {
     this->OutputTestOutputOnTestFailure = !cmSystemTools::IsOff(outOnFail);
-    }
+  }
   this->InitStreams();
 
   this->Parts[PartStart].SetName("Start");
@@ -351,36 +317,33 @@ cmCTest::cmCTest()
   this->Parts[PartUpload].SetName("Upload");
 
   // Fill the part name-to-id map.
-  for(Part p = PartStart; p != PartCount; p = Part(p+1))
-    {
+  for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
     this->PartMap[cmSystemTools::LowerCase(this->Parts[p].GetName())] = p;
-    }
+  }
 
-  this->ShortDateFormat        = true;
+  this->ShortDateFormat = true;
 
-  this->TestingHandlers["build"]     = new cmCTestBuildHandler;
+  this->TestingHandlers["build"] = new cmCTestBuildHandler;
   this->TestingHandlers["buildtest"] = new cmCTestBuildAndTestHandler;
-  this->TestingHandlers["coverage"]  = new cmCTestCoverageHandler;
-  this->TestingHandlers["script"]    = new cmCTestScriptHandler;
-  this->TestingHandlers["test"]      = new cmCTestTestHandler;
-  this->TestingHandlers["update"]    = new cmCTestUpdateHandler;
+  this->TestingHandlers["coverage"] = new cmCTestCoverageHandler;
+  this->TestingHandlers["script"] = new cmCTestScriptHandler;
+  this->TestingHandlers["test"] = new cmCTestTestHandler;
+  this->TestingHandlers["update"] = new cmCTestUpdateHandler;
   this->TestingHandlers["configure"] = new cmCTestConfigureHandler;
-  this->TestingHandlers["memcheck"]  = new cmCTestMemCheckHandler;
-  this->TestingHandlers["submit"]    = new cmCTestSubmitHandler;
-  this->TestingHandlers["upload"]    = new cmCTestUploadHandler;
+  this->TestingHandlers["memcheck"] = new cmCTestMemCheckHandler;
+  this->TestingHandlers["submit"] = new cmCTestSubmitHandler;
+  this->TestingHandlers["upload"] = new cmCTestUploadHandler;
 
   cmCTest::t_TestingHandlers::iterator it;
-  for ( it = this->TestingHandlers.begin();
-    it != this->TestingHandlers.end(); ++ it )
-    {
+  for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
+       ++it) {
     it->second->SetCTestInstance(this);
-    }
+  }
 
   // Make sure we can capture the build tool output.
   cmSystemTools::EnableVSConsoleOutput();
 }
 
-//----------------------------------------------------------------------
 cmCTest::~cmCTest()
 {
   cmDeleteAll(this->TestingHandlers);
@@ -397,43 +360,39 @@ void cmCTest::SetTestLoad(unsigned long load)
   this->TestLoad = load;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTest::ShouldCompressTestOutput()
 {
-  if(!this->ComputedCompressTestOutput)
-    {
+  if (!this->ComputedCompressTestOutput) {
     std::string cdashVersion = this->GetCDashVersion();
-    //version >= 1.6?
-    bool cdashSupportsGzip = cmSystemTools::VersionCompare(
-      cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.6") ||
+    // version >= 1.6?
+    bool cdashSupportsGzip =
+      cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
+                                    cdashVersion.c_str(), "1.6") ||
       cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
-      cdashVersion.c_str(), "1.6");
+                                    cdashVersion.c_str(), "1.6");
     this->CompressTestOutput &= cdashSupportsGzip;
     this->ComputedCompressTestOutput = true;
-    }
+  }
   return this->CompressTestOutput;
 }
 
-//----------------------------------------------------------------------------
 bool cmCTest::ShouldCompressMemCheckOutput()
 {
-  if(!this->ComputedCompressMemCheckOutput)
-    {
+  if (!this->ComputedCompressMemCheckOutput) {
     std::string cdashVersion = this->GetCDashVersion();
 
     bool compressionSupported = cmSystemTools::VersionCompare(
       cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.9.0");
     this->CompressMemCheckOutput &= compressionSupported;
     this->ComputedCompressMemCheckOutput = true;
-    }
+  }
   return this->CompressMemCheckOutput;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCTest::GetCDashVersion()
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
-  //First query the server.  If that fails, fall back to the local setting
+  // First query the server.  If that fails, fall back to the local setting
   std::string response;
   std::string url = "http://";
   url += this->GetCTestConfiguration("DropSite");
@@ -442,8 +401,7 @@ std::string cmCTest::GetCDashVersion()
   cdashUri = cdashUri.substr(0, cdashUri.find("/submit.php"));
 
   int res = 1;
-  if ( ! cdashUri.empty() )
-  {
+  if (!cdashUri.empty()) {
     url += cdashUri + "/api/getversion.php";
     res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3);
   }
@@ -454,39 +412,32 @@ std::string cmCTest::GetCDashVersion()
 #endif
 }
 
-//----------------------------------------------------------------------------
 cmCTest::Part cmCTest::GetPartFromName(const char* name)
 {
   // Look up by lower-case to make names case-insensitive.
   std::string lower_name = cmSystemTools::LowerCase(name);
   PartMapType::const_iterator i = this->PartMap.find(lower_name);
-  if(i != this->PartMap.end())
-    {
+  if (i != this->PartMap.end()) {
     return i->second;
-    }
+  }
 
   // The string does not name a valid part.
   return PartCount;
 }
 
-//----------------------------------------------------------------------
 int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
 {
   bool quiet = false;
-  if (command && command->ShouldBeQuiet())
-    {
+  if (command && command->ShouldBeQuiet()) {
     quiet = true;
-    }
+  }
 
   cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
-  if(!this->InteractiveDebugMode)
-    {
+  if (!this->InteractiveDebugMode) {
     this->BlockTestErrorDiagnostics();
-    }
-  else
-    {
+  } else {
     cmSystemTools::PutEnv("CTEST_INTERACTIVE_DEBUG_MODE=1");
-    }
+  }
 
   this->BinaryDir = binary_dir;
   cmSystemTools::ConvertToUnixSlashes(this->BinaryDir);
@@ -494,25 +445,29 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
   this->UpdateCTestConfiguration();
 
   cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
-  if ( this->ProduceXML )
-    {
+  if (this->ProduceXML) {
     cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
-    cmCTestOptionalLog(this, OUTPUT,
-      "   Site: " << this->GetCTestConfiguration("Site") << std::endl <<
-      "   Build name: " << cmCTest::SafeBuildIdField(
-      this->GetCTestConfiguration("BuildName")) << std::endl, quiet);
+    cmCTestOptionalLog(
+      this, OUTPUT, "   Site: "
+        << this->GetCTestConfiguration("Site") << std::endl
+        << "   Build name: "
+        << cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"))
+        << std::endl,
+      quiet);
     cmCTestOptionalLog(this, DEBUG, "Produce XML is on" << std::endl, quiet);
-    if ( this->TestModel == cmCTest::NIGHTLY &&
-         this->GetCTestConfiguration("NightlyStartTime").empty() )
-      {
-      cmCTestOptionalLog(this, WARNING,
+    if (this->TestModel == cmCTest::NIGHTLY &&
+        this->GetCTestConfiguration("NightlyStartTime").empty()) {
+      cmCTestOptionalLog(
+        this, WARNING,
         "WARNING: No nightly start time found please set in CTestConfig.cmake"
-        " or DartConfig.cmake" << std::endl, quiet);
-      cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl,
+        " or DartConfig.cmake"
+          << std::endl,
         quiet);
+      cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl,
+                         quiet);
       return 0;
-      }
     }
+  }
 
   cmake cm;
   cm.SetHomeDirectory("");
@@ -520,155 +475,133 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator gg(&cm);
   cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
-  if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
-                                              mf.get()) )
-    {
-    cmCTestOptionalLog(this, DEBUG,
-      "Cannot find custom configuration file tree" << std::endl, quiet);
+  if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
+                                             mf.get())) {
+    cmCTestOptionalLog(
+      this, DEBUG, "Cannot find custom configuration file tree" << std::endl,
+      quiet);
     return 0;
-    }
+  }
 
-  if ( this->ProduceXML )
-    {
+  if (this->ProduceXML) {
     // Verify "Testing" directory exists:
     //
     std::string testingDir = this->BinaryDir + "/Testing";
-    if ( cmSystemTools::FileExists(testingDir.c_str()) )
-      {
-      if ( !cmSystemTools::FileIsDirectory(testingDir) )
-        {
-        cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir
-          << " is in the place of the testing directory" << std::endl);
+    if (cmSystemTools::FileExists(testingDir.c_str())) {
+      if (!cmSystemTools::FileIsDirectory(testingDir)) {
+        cmCTestLog(this, ERROR_MESSAGE, "File "
+                     << testingDir
+                     << " is in the place of the testing directory"
+                     << std::endl);
         return 0;
-        }
       }
-    else
-      {
-      if ( !cmSystemTools::MakeDirectory(testingDir.c_str()) )
-        {
+    } else {
+      if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
         cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory "
-          << testingDir << std::endl);
+                     << testingDir << std::endl);
         return 0;
-        }
       }
+    }
 
     // Create new "TAG" file or read existing one:
     //
     bool createNewTag = true;
-    if (command)
-      {
+    if (command) {
       createNewTag = command->ShouldCreateNewTag();
-      }
+    }
 
     std::string tagfile = testingDir + "/TAG";
     cmsys::ifstream tfin(tagfile.c_str());
     std::string tag;
 
-    if (createNewTag)
-      {
+    if (createNewTag) {
       time_t tctime = time(0);
-      if ( this->TomorrowTag )
-        {
-        tctime += ( 24 * 60 * 60 );
-        }
-      struct tm *lctime = gmtime(&tctime);
-      if ( tfin && cmSystemTools::GetLineFromStream(tfin, tag) )
-        {
+      if (this->TomorrowTag) {
+        tctime += (24 * 60 * 60);
+      }
+      struct tm* lctime = gmtime(&tctime);
+      if (tfin && cmSystemTools::GetLineFromStream(tfin, tag)) {
         int year = 0;
         int mon = 0;
         int day = 0;
         int hour = 0;
         int min = 0;
-        sscanf(tag.c_str(), "%04d%02d%02d-%02d%02d",
-               &year, &mon, &day, &hour, &min);
-        if ( year != lctime->tm_year + 1900 ||
-             mon != lctime->tm_mon+1 ||
-             day != lctime->tm_mday )
-          {
+        sscanf(tag.c_str(), "%04d%02d%02d-%02d%02d", &year, &mon, &day, &hour,
+               &min);
+        if (year != lctime->tm_year + 1900 || mon != lctime->tm_mon + 1 ||
+            day != lctime->tm_mday) {
           tag = "";
-          }
+        }
         std::string tagmode;
-        if ( cmSystemTools::GetLineFromStream(tfin, tagmode) )
-          {
-          if (tagmode.size() > 4 && !this->Parts[PartStart])
-            {
+        if (cmSystemTools::GetLineFromStream(tfin, tagmode)) {
+          if (tagmode.size() > 4 && !this->Parts[PartStart]) {
             this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str());
-            }
           }
-        tfin.close();
         }
-      if (tag.empty() || (0 != command) || this->Parts[PartStart])
-        {
-        cmCTestOptionalLog(this, DEBUG, "TestModel: " <<
-          this->GetTestModelString() << std::endl, quiet);
-        cmCTestOptionalLog(this, DEBUG, "TestModel: " <<
-          this->TestModel << std::endl, quiet);
-        if ( this->TestModel == cmCTest::NIGHTLY )
-          {
+        tfin.close();
+      }
+      if (tag.empty() || (0 != command) || this->Parts[PartStart]) {
+        cmCTestOptionalLog(
+          this, DEBUG,
+          "TestModel: " << this->GetTestModelString() << std::endl, quiet);
+        cmCTestOptionalLog(
+          this, DEBUG, "TestModel: " << this->TestModel << std::endl, quiet);
+        if (this->TestModel == cmCTest::NIGHTLY) {
           lctime = this->GetNightlyTime(
             this->GetCTestConfiguration("NightlyStartTime"),
             this->TomorrowTag);
-          }
+        }
         char datestring[100];
-        sprintf(datestring, "%04d%02d%02d-%02d%02d",
-                lctime->tm_year + 1900,
-                lctime->tm_mon+1,
-                lctime->tm_mday,
-                lctime->tm_hour,
+        sprintf(datestring, "%04d%02d%02d-%02d%02d", lctime->tm_year + 1900,
+                lctime->tm_mon + 1, lctime->tm_mday, lctime->tm_hour,
                 lctime->tm_min);
         tag = datestring;
         cmsys::ofstream ofs(tagfile.c_str());
-        if ( ofs )
-          {
+        if (ofs) {
           ofs << tag << std::endl;
           ofs << this->GetTestModelString() << std::endl;
-          }
+        }
         ofs.close();
-        if ( 0 == command )
-          {
-          cmCTestOptionalLog(this, OUTPUT, "Create new tag: " << tag << " - "
-            << this->GetTestModelString() << std::endl, quiet);
-          }
+        if (0 == command) {
+          cmCTestOptionalLog(this, OUTPUT, "Create new tag: "
+                               << tag << " - " << this->GetTestModelString()
+                               << std::endl,
+                             quiet);
         }
       }
-    else
-      {
-      if ( tfin )
-        {
+    } else {
+      if (tfin) {
         cmSystemTools::GetLineFromStream(tfin, tag);
         tfin.close();
-        }
+      }
 
-      if ( tag.empty() )
-        {
-        cmCTestLog(this, ERROR_MESSAGE,
-          "Cannot read existing TAG file in " << testingDir
-          << std::endl);
+      if (tag.empty()) {
+        cmCTestLog(this, ERROR_MESSAGE, "Cannot read existing TAG file in "
+                     << testingDir << std::endl);
         return 0;
-        }
-
-      cmCTestOptionalLog(this, OUTPUT, "  Use existing tag: " << tag << " - "
-        << this->GetTestModelString() << std::endl, quiet);
       }
 
-    this->CurrentTag = tag;
+      cmCTestOptionalLog(this, OUTPUT, "  Use existing tag: "
+                           << tag << " - " << this->GetTestModelString()
+                           << std::endl,
+                         quiet);
     }
 
+    this->CurrentTag = tag;
+  }
+
   return 1;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
 {
-  std::string src_dir
-    = this->GetCTestConfiguration("SourceDirectory");
+  std::string src_dir = 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))
-    {
+  for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
     this->Parts[p].SubmitFiles.clear();
-    }
+  }
 
   cmMakefile* mf = command->GetMakefile();
   std::string fname;
@@ -681,173 +614,146 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
   bld_dir_fname += "/CTestConfig.cmake";
   cmSystemTools::ConvertToUnixSlashes(bld_dir_fname);
 
-  if ( cmSystemTools::FileExists(bld_dir_fname.c_str()) )
-    {
+  if (cmSystemTools::FileExists(bld_dir_fname.c_str())) {
     fname = bld_dir_fname;
-    }
-  else if ( cmSystemTools::FileExists(src_dir_fname.c_str()) )
-    {
+  } else if (cmSystemTools::FileExists(src_dir_fname.c_str())) {
     fname = src_dir_fname;
-    }
+  }
 
-  if ( !fname.empty() )
-    {
+  if (!fname.empty()) {
     cmCTestOptionalLog(this, OUTPUT, "   Reading ctest configuration file: "
-      << fname << std::endl, command->ShouldBeQuiet());
+                         << fname << std::endl,
+                       command->ShouldBeQuiet());
     bool readit = mf->ReadDependentFile(fname.c_str());
-    if(!readit)
-      {
+    if (!readit) {
       std::string m = "Could not find include file: ";
       m += fname;
       command->SetError(m);
       return false;
-      }
     }
-  else
-    {
+  } else {
     cmCTestOptionalLog(this, WARNING,
-      "Cannot locate CTest configuration: in BuildDirectory: "
-      << bld_dir_fname << std::endl, command->ShouldBeQuiet());
-    cmCTestOptionalLog(this, WARNING,
-      "Cannot locate CTest configuration: in SourceDirectory: "
-      << src_dir_fname << std::endl, command->ShouldBeQuiet());
-    }
+                       "Cannot locate CTest configuration: in BuildDirectory: "
+                         << bld_dir_fname << std::endl,
+                       command->ShouldBeQuiet());
+    cmCTestOptionalLog(
+      this, WARNING, "Cannot locate CTest configuration: in SourceDirectory: "
+        << src_dir_fname << std::endl,
+      command->ShouldBeQuiet());
+  }
 
   this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
-    "CTEST_NIGHTLY_START_TIME", command->ShouldBeQuiet());
+                                               "CTEST_NIGHTLY_START_TIME",
+                                               command->ShouldBeQuiet());
   this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE",
-    command->ShouldBeQuiet());
-  this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName",
-    "CTEST_BUILD_NAME", command->ShouldBeQuiet());
+                                               command->ShouldBeQuiet());
+  this->SetCTestConfigurationFromCMakeVariable(
+    mf, "BuildName", "CTEST_BUILD_NAME", command->ShouldBeQuiet());
   const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION");
-  if ( dartVersion )
-    {
+  if (dartVersion) {
     this->DartVersion = atoi(dartVersion);
-    if ( this->DartVersion < 0 )
-      {
+    if (this->DartVersion < 0) {
       cmCTestLog(this, ERROR_MESSAGE, "Invalid Dart server version: "
-        << dartVersion << ". Please specify the version number."
-        << std::endl);
+                   << dartVersion << ". Please specify the version number."
+                   << std::endl);
       return false;
-      }
     }
+  }
   this->DropSiteCDash = mf->IsOn("CTEST_DROP_SITE_CDASH");
 
-  if ( !this->Initialize(bld_dir.c_str(), command) )
-    {
+  if (!this->Initialize(bld_dir.c_str(), command)) {
     return false;
-    }
-  cmCTestOptionalLog(this, OUTPUT, "   Use " << this->GetTestModelString()
-    << " tag: " << this->GetCurrentTag() << std::endl,
-    command->ShouldBeQuiet());
+  }
+  cmCTestOptionalLog(this, OUTPUT, "   Use "
+                       << this->GetTestModelString()
+                       << " tag: " << this->GetCurrentTag() << std::endl,
+                     command->ShouldBeQuiet());
   return true;
 }
 
-
-//----------------------------------------------------------------------
 bool cmCTest::UpdateCTestConfiguration()
 {
-  if ( this->SuppressUpdatingCTestConfiguration )
-    {
+  if (this->SuppressUpdatingCTestConfiguration) {
     return true;
-    }
+  }
   std::string fileName = this->CTestConfigFile;
-  if ( fileName.empty() )
-    {
+  if (fileName.empty()) {
     fileName = this->BinaryDir + "/CTestConfiguration.ini";
-    if ( !cmSystemTools::FileExists(fileName.c_str()) )
-      {
+    if (!cmSystemTools::FileExists(fileName.c_str())) {
       fileName = this->BinaryDir + "/DartConfiguration.tcl";
-      }
     }
-  cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "UpdateCTestConfiguration  from :"
-             << fileName << "\n");
-  if ( !cmSystemTools::FileExists(fileName.c_str()) )
-    {
+  }
+  cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
+             "UpdateCTestConfiguration  from :" << fileName << "\n");
+  if (!cmSystemTools::FileExists(fileName.c_str())) {
     // No need to exit if we are not producing XML
-    if ( this->ProduceXML )
-      {
+    if (this->ProduceXML) {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName
-        << std::endl);
+                                                           << std::endl);
       return false;
-      }
     }
-  else
-    {
-    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
-               << fileName << "\n");
+  } else {
+    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" << fileName
+                                                                  << "\n");
     // parse the dart test file
     cmsys::ifstream fin(fileName.c_str());
 
-    if(!fin)
-      {
+    if (!fin) {
       return false;
-      }
+    }
 
     char buffer[1024];
-    while ( fin )
-      {
+    while (fin) {
       buffer[0] = 0;
       fin.getline(buffer, 1023);
       buffer[1023] = 0;
       std::string line = cmCTest::CleanString(buffer);
-      if(line.empty())
-        {
+      if (line.empty()) {
         continue;
-        }
-      while ( fin && (line[line.size()-1] == '\\') )
-        {
-        line = line.substr(0, line.size()-1);
+      }
+      while (fin && (line[line.size() - 1] == '\\')) {
+        line = line.substr(0, line.size() - 1);
         buffer[0] = 0;
         fin.getline(buffer, 1023);
         buffer[1023] = 0;
         line += cmCTest::CleanString(buffer);
-        }
-      if ( line[0] == '#' )
-        {
+      }
+      if (line[0] == '#') {
         continue;
-        }
-      std::string::size_type cpos = line.find_first_of(":");
-      if ( cpos == line.npos )
-        {
+      }
+      std::string::size_type cpos = line.find_first_of(':');
+      if (cpos == line.npos) {
         continue;
-        }
+      }
       std::string key = line.substr(0, cpos);
-      std::string value
-        = cmCTest::CleanString(line.substr(cpos+1, line.npos));
+      std::string value =
+        cmCTest::CleanString(line.substr(cpos + 1, line.npos));
       this->CTestConfiguration[key] = value;
-      }
-    fin.close();
     }
-  if ( !this->GetCTestConfiguration("BuildDirectory").empty() )
-    {
+    fin.close();
+  }
+  if (!this->GetCTestConfiguration("BuildDirectory").empty()) {
     this->BinaryDir = this->GetCTestConfiguration("BuildDirectory");
     cmSystemTools::ChangeDirectory(this->BinaryDir);
-    }
+  }
   this->TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str());
   std::string const& testLoad = this->GetCTestConfiguration("TestLoad");
-  if (!testLoad.empty())
-    {
+  if (!testLoad.empty()) {
     unsigned long load;
-    if (cmSystemTools::StringToULong(testLoad.c_str(), &load))
-      {
+    if (cmSystemTools::StringToULong(testLoad.c_str(), &load)) {
       this->SetTestLoad(load);
-      }
-    else
-      {
-      cmCTestLog(this, WARNING, "Invalid value for 'Test Load' : "
-          << testLoad << std::endl);
-      }
+    } else {
+      cmCTestLog(this, WARNING,
+                 "Invalid value for 'Test Load' : " << testLoad << std::endl);
     }
-  if ( this->ProduceXML )
-    {
+  }
+  if (this->ProduceXML) {
     this->CompressXMLFiles = cmSystemTools::IsOn(
       this->GetCTestConfiguration("CompressSubmission").c_str());
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::BlockTestErrorDiagnostics()
 {
   cmSystemTools::PutEnv("DART_TEST_FROM_DART=1");
@@ -859,314 +765,246 @@ void cmCTest::BlockTestErrorDiagnostics()
 #endif
 }
 
-//----------------------------------------------------------------------
 void cmCTest::SetTestModel(int mode)
 {
   this->InteractiveDebugMode = false;
   this->TestModel = mode;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::SetTest(const char* ttype, bool report)
 {
-  if ( cmSystemTools::LowerCase(ttype) == "all" )
-    {
-    for(Part p = PartStart; p != PartCount; p = Part(p+1))
-      {
+  if (cmSystemTools::LowerCase(ttype) == "all") {
+    for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
       this->Parts[p].Enable();
-      }
-    return true;
     }
+    return true;
+  }
   Part p = this->GetPartFromName(ttype);
-  if(p != PartCount)
-    {
+  if (p != PartCount) {
     this->Parts[p].Enable();
     return true;
+  } else {
+    if (report) {
+      cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \""
+                   << ttype << "\" yet..." << std::endl);
     }
-  else
-    {
-    if ( report )
-      {
-      cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \"" << ttype
-        << "\" yet..." << std::endl);
-      }
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTest::Finalize()
 {
 }
 
-//----------------------------------------------------------------------
-bool cmCTest::OpenOutputFile(const std::string& path,
-                     const std::string& name, cmGeneratedFileStream& stream,
-                     bool compress)
+bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
+                             cmGeneratedFileStream& stream, bool compress)
 {
   std::string testingDir = this->BinaryDir + "/Testing";
-  if (!path.empty())
-    {
+  if (!path.empty()) {
     testingDir += "/" + path;
-    }
-  if ( cmSystemTools::FileExists(testingDir.c_str()) )
-    {
-    if ( !cmSystemTools::FileIsDirectory(testingDir) )
-      {
-      cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir
-                << " is in the place of the testing directory"
-                << std::endl);
+  }
+  if (cmSystemTools::FileExists(testingDir.c_str())) {
+    if (!cmSystemTools::FileIsDirectory(testingDir)) {
+      cmCTestLog(this, ERROR_MESSAGE, "File "
+                   << testingDir << " is in the place of the testing directory"
+                   << std::endl);
       return false;
-      }
     }
-  else
-    {
-    if ( !cmSystemTools::MakeDirectory(testingDir.c_str()) )
-      {
+  } else {
+    if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory " << testingDir
-                << std::endl);
+                                                                 << std::endl);
       return false;
-      }
     }
+  }
   std::string filename = testingDir + "/" + name;
   stream.Open(filename.c_str());
-  if( !stream )
-    {
+  if (!stream) {
     cmCTestLog(this, ERROR_MESSAGE, "Problem opening file: " << filename
-      << std::endl);
+                                                             << std::endl);
     return false;
-    }
-  if ( compress )
-    {
-    if ( this->CompressXMLFiles )
-      {
+  }
+  if (compress) {
+    if (this->CompressXMLFiles) {
       stream.SetCompression(true);
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::AddIfExists(Part part, const char* file)
 {
-  if ( this->CTestFileExists(file) )
-    {
+  if (this->CTestFileExists(file)) {
     this->AddSubmitFile(part, file);
-    }
-  else
-    {
+  } else {
     std::string name = file;
     name += ".gz";
-    if ( this->CTestFileExists(name) )
-      {
+    if (this->CTestFileExists(name)) {
       this->AddSubmitFile(part, file);
-      }
-    else
-      {
+    } else {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::CTestFileExists(const std::string& filename)
 {
-  std::string testingDir = this->BinaryDir + "/Testing/" +
-    this->CurrentTag + "/" + filename;
+  std::string testingDir =
+    this->BinaryDir + "/Testing/" + this->CurrentTag + "/" + filename;
   return cmSystemTools::FileExists(testingDir.c_str());
 }
 
-//----------------------------------------------------------------------
 cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler)
 {
   cmCTest::t_TestingHandlers::iterator it =
     this->TestingHandlers.find(handler);
-  if ( it == this->TestingHandlers.end() )
-    {
+  if (it == this->TestingHandlers.end()) {
     return 0;
-    }
+  }
   it->second->Initialize();
   return it->second;
 }
 
-//----------------------------------------------------------------------
 cmCTestGenericHandler* cmCTest::GetHandler(const char* handler)
 {
   cmCTest::t_TestingHandlers::iterator it =
     this->TestingHandlers.find(handler);
-  if ( it == this->TestingHandlers.end() )
-    {
+  if (it == this->TestingHandlers.end()) {
     return 0;
-    }
+  }
   return it->second;
 }
 
-//----------------------------------------------------------------------
 int cmCTest::ExecuteHandler(const char* shandler)
 {
   cmCTestGenericHandler* handler = this->GetHandler(shandler);
-  if ( !handler )
-    {
+  if (!handler) {
     return -1;
-    }
+  }
   handler->Initialize();
   return handler->ProcessHandler();
 }
 
-//----------------------------------------------------------------------
 int cmCTest::ProcessTests()
 {
   int res = 0;
   bool notest = true;
   int update_count = 0;
 
-  for(Part p = PartStart; notest && p != PartCount; p = Part(p+1))
-    {
+  for (Part p = PartStart; notest && p != PartCount; p = Part(p + 1)) {
     notest = !this->Parts[p];
-    }
-  if (this->Parts[PartUpdate] &&
-      (this->GetRemainingTimeAllowed() - 120 > 0))
-    {
+  }
+  if (this->Parts[PartUpdate] && (this->GetRemainingTimeAllowed() - 120 > 0)) {
     cmCTestGenericHandler* uphandler = this->GetHandler("update");
-    uphandler->SetPersistentOption("SourceDirectory",
+    uphandler->SetPersistentOption(
+      "SourceDirectory",
       this->GetCTestConfiguration("SourceDirectory").c_str());
     update_count = uphandler->ProcessHandler();
-    if ( update_count < 0 )
-      {
+    if (update_count < 0) {
       res |= cmCTest::UPDATE_ERRORS;
-      }
     }
-  if ( this->TestModel == cmCTest::CONTINUOUS && !update_count )
-    {
+  }
+  if (this->TestModel == cmCTest::CONTINUOUS && !update_count) {
     return 0;
-    }
+  }
   if (this->Parts[PartConfigure] &&
-      (this->GetRemainingTimeAllowed() - 120 > 0))
-    {
-    if (this->GetHandler("configure")->ProcessHandler() < 0)
-      {
+      (this->GetRemainingTimeAllowed() - 120 > 0)) {
+    if (this->GetHandler("configure")->ProcessHandler() < 0) {
       res |= cmCTest::CONFIGURE_ERRORS;
-      }
     }
-  if (this->Parts[PartBuild] &&
-      (this->GetRemainingTimeAllowed() - 120 > 0))
-    {
+  }
+  if (this->Parts[PartBuild] && (this->GetRemainingTimeAllowed() - 120 > 0)) {
     this->UpdateCTestConfiguration();
-    if (this->GetHandler("build")->ProcessHandler() < 0)
-      {
+    if (this->GetHandler("build")->ProcessHandler() < 0) {
       res |= cmCTest::BUILD_ERRORS;
-      }
     }
+  }
   if ((this->Parts[PartTest] || notest) &&
-      (this->GetRemainingTimeAllowed() - 120 > 0))
-    {
+      (this->GetRemainingTimeAllowed() - 120 > 0)) {
     this->UpdateCTestConfiguration();
-    if (this->GetHandler("test")->ProcessHandler() < 0)
-      {
+    if (this->GetHandler("test")->ProcessHandler() < 0) {
       res |= cmCTest::TEST_ERRORS;
-      }
     }
+  }
   if (this->Parts[PartCoverage] &&
-      (this->GetRemainingTimeAllowed() - 120 > 0))
-    {
+      (this->GetRemainingTimeAllowed() - 120 > 0)) {
     this->UpdateCTestConfiguration();
-    if (this->GetHandler("coverage")->ProcessHandler() < 0)
-      {
+    if (this->GetHandler("coverage")->ProcessHandler() < 0) {
       res |= cmCTest::COVERAGE_ERRORS;
-      }
     }
+  }
   if (this->Parts[PartMemCheck] &&
-      (this->GetRemainingTimeAllowed() - 120 > 0))
-    {
+      (this->GetRemainingTimeAllowed() - 120 > 0)) {
     this->UpdateCTestConfiguration();
-    if (this->GetHandler("memcheck")->ProcessHandler() < 0)
-      {
+    if (this->GetHandler("memcheck")->ProcessHandler() < 0) {
       res |= cmCTest::MEMORY_ERRORS;
-      }
     }
-  if ( !notest )
-    {
+  }
+  if (!notest) {
     std::string notes_dir = this->BinaryDir + "/Testing/Notes";
-    if ( cmSystemTools::FileIsDirectory(notes_dir) )
-      {
+    if (cmSystemTools::FileIsDirectory(notes_dir)) {
       cmsys::Directory d;
       d.Load(notes_dir);
       unsigned long kk;
-      for ( kk = 0; kk < d.GetNumberOfFiles(); kk ++ )
-        {
+      for (kk = 0; kk < d.GetNumberOfFiles(); kk++) {
         const char* file = d.GetFile(kk);
         std::string fullname = notes_dir + "/" + file;
-        if ( cmSystemTools::FileExists(fullname.c_str()) &&
-          !cmSystemTools::FileIsDirectory(fullname) )
-          {
-          if (!this->NotesFiles.empty())
-            {
+        if (cmSystemTools::FileExists(fullname.c_str()) &&
+            !cmSystemTools::FileIsDirectory(fullname)) {
+          if (!this->NotesFiles.empty()) {
             this->NotesFiles += ";";
-            }
+          }
           this->NotesFiles += fullname;
           this->Parts[PartNotes].Enable();
-          }
         }
       }
     }
-  if (this->Parts[PartNotes])
-    {
+  }
+  if (this->Parts[PartNotes]) {
     this->UpdateCTestConfiguration();
-    if (!this->NotesFiles.empty())
-      {
+    if (!this->NotesFiles.empty()) {
       this->GenerateNotesFile(this->NotesFiles.c_str());
-      }
     }
-  if (this->Parts[PartSubmit])
-    {
+  }
+  if (this->Parts[PartSubmit]) {
     this->UpdateCTestConfiguration();
-    if (this->GetHandler("submit")->ProcessHandler() < 0)
-      {
+    if (this->GetHandler("submit")->ProcessHandler() < 0) {
       res |= cmCTest::SUBMIT_ERRORS;
-      }
-    }
-  if ( res != 0 )
-    {
-    cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest"
-                 << std::endl);
     }
+  }
+  if (res != 0) {
+    cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest" << std::endl);
+  }
   return res;
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::GetTestModelString()
 {
-  if ( !this->SpecificTrack.empty() )
-    {
+  if (!this->SpecificTrack.empty()) {
     return this->SpecificTrack;
-    }
-  switch ( this->TestModel )
-    {
-  case cmCTest::NIGHTLY:
-    return "Nightly";
-  case cmCTest::CONTINUOUS:
-    return "Continuous";
-    }
+  }
+  switch (this->TestModel) {
+    case cmCTest::NIGHTLY:
+      return "Nightly";
+    case cmCTest::CONTINUOUS:
+      return "Continuous";
+  }
   return "Experimental";
 }
 
-//----------------------------------------------------------------------
 int cmCTest::GetTestModelFromString(const char* str)
 {
-  if ( !str )
-    {
+  if (!str) {
     return cmCTest::EXPERIMENTAL;
-    }
+  }
   std::string rstr = cmSystemTools::LowerCase(str);
-  if ( cmHasLiteralPrefix(rstr.c_str(), "cont") )
-    {
+  if (cmHasLiteralPrefix(rstr.c_str(), "cont")) {
     return cmCTest::CONTINUOUS;
-    }
-  if ( cmHasLiteralPrefix(rstr.c_str(), "nigh") )
-    {
+  }
+  if (cmHasLiteralPrefix(rstr.c_str(), "nigh")) {
     return cmCTest::NIGHTLY;
-    }
+  }
   return cmCTest::EXPERIMENTAL;
 }
 
@@ -1175,33 +1013,30 @@ int cmCTest::GetTestModelFromString(const char* str)
 //######################################################################
 //######################################################################
 
-//----------------------------------------------------------------------
 int cmCTest::RunMakeCommand(const char* command, std::string& output,
-  int* retVal, const char* dir, int timeout, std::ostream& ofs)
+                            int* retVal, const char* dir, int timeout,
+                            std::ostream& ofs)
 {
   // First generate the command and arguments
   std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     return false;
-    }
+  }
 
   std::vector<const char*> argv;
-  for(std::vector<std::string>::const_iterator a = args.begin();
-    a != args.end(); ++a)
-    {
+  for (std::vector<std::string>::const_iterator a = args.begin();
+       a != args.end(); ++a) {
     argv.push_back(a->c_str());
-    }
+  }
   argv.push_back(0);
 
   output = "";
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:");
   std::vector<const char*>::iterator ait;
-  for ( ait = argv.begin(); ait != argv.end() && *ait; ++ ait )
-    {
+  for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
     cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\"");
-    }
+  }
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, std::endl);
 
   // Now create process object
@@ -1219,69 +1054,55 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
 
   char* data;
   int length;
-  cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
-    "   Each . represents " << tick_len << " bytes of output" << std::endl
-    << "    " << std::flush);
-  while(cmsysProcess_WaitForData(cp, &data, &length, 0))
-    {
-    for(int cc =0; cc < length; ++cc)
-      {
-      if(data[cc] == 0)
-        {
+  cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "   Each . represents "
+               << tick_len << " bytes of output" << std::endl
+               << "    " << std::flush);
+  while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+    for (int cc = 0; cc < length; ++cc) {
+      if (data[cc] == 0) {
         data[cc] = '\n';
-        }
       }
+    }
     output.append(data, length);
-    while ( output.size() > (tick * tick_len) )
-      {
-      tick ++;
+    while (output.size() > (tick * tick_len)) {
+      tick++;
       cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "." << std::flush);
-      if ( tick % tick_line_len == 0 && tick > 0 )
-        {
+      if (tick % tick_line_len == 0 && tick > 0) {
         cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
-                   "  Size: "
-                   << int((double(output.size()) / 1024.0) + 1)
-                   << "K" << std::endl
-                   << "    " << std::flush);
-        }
+                   "  Size: " << int((double(output.size()) / 1024.0) + 1)
+                              << "K" << std::endl
+                              << "    " << std::flush);
       }
+    }
     cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length));
-    if ( ofs )
-      {
+    if (ofs) {
       ofs << cmCTestLogWrite(data, length);
-      }
     }
+  }
   cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: "
-    << int(double(output.size()) / 1024.0) << "K" << std::endl);
+               << int(double(output.size()) / 1024.0) << "K" << std::endl);
 
   cmsysProcess_WaitForExit(cp, 0);
 
   int result = cmsysProcess_GetState(cp);
 
-  if(result == cmsysProcess_State_Exited)
-    {
+  if (result == cmsysProcess_State_Exited) {
     *retVal = cmsysProcess_GetExitValue(cp);
-    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Command exited with the value: "
-      << *retVal << std::endl);
-    }
-  else if(result == cmsysProcess_State_Exception)
-    {
+    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
+               "Command exited with the value: " << *retVal << std::endl);
+  } else if (result == cmsysProcess_State_Exception) {
     *retVal = cmsysProcess_GetExitException(cp);
     cmCTestLog(this, WARNING, "There was an exception: " << *retVal
-      << std::endl);
-    }
-  else if(result == cmsysProcess_State_Expired)
-    {
+                                                         << std::endl);
+  } else if (result == cmsysProcess_State_Expired) {
     cmCTestLog(this, WARNING, "There was a timeout" << std::endl);
-    }
-  else if(result == cmsysProcess_State_Error)
-    {
+  } else if (result == cmsysProcess_State_Error) {
     output += "\n*** ERROR executing: ";
     output += cmsysProcess_GetErrorString(cp);
     output += "\n***The build process failed.";
     cmCTestLog(this, ERROR_MESSAGE, "There was an error: "
-      << cmsysProcess_GetErrorString(cp) << std::endl);
-    }
+                 << cmsysProcess_GetErrorString(cp) << std::endl);
+  }
 
   cmsysProcess_Delete(cp);
 
@@ -1293,37 +1114,29 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
 //######################################################################
 //######################################################################
 
-//----------------------------------------------------------------------
-int cmCTest::RunTest(std::vector<const char*> argv,
-                     std::string* output, int *retVal,
-                     std::ostream* log, double testTimeOut,
+int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
+                     int* retVal, std::ostream* log, double testTimeOut,
                      std::vector<std::string>* environment)
 {
   bool modifyEnv = (environment && !environment->empty());
 
   // determine how much time we have
   double timeout = this->GetRemainingTimeAllowed() - 120;
-  if (this->TimeOut > 0 && this->TimeOut < timeout)
-    {
+  if (this->TimeOut > 0 && this->TimeOut < timeout) {
     timeout = this->TimeOut;
-    }
-  if (testTimeOut > 0
-      && testTimeOut < this->GetRemainingTimeAllowed())
-    {
+  }
+  if (testTimeOut > 0 && testTimeOut < this->GetRemainingTimeAllowed()) {
     timeout = testTimeOut;
-    }
+  }
 
   // always have at least 1 second if we got to here
-  if (timeout <= 0)
-    {
+  if (timeout <= 0) {
     timeout = 1;
-    }
+  }
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
              "Test timeout computed to be: " << timeout << "\n");
-  if(cmSystemTools::SameFile(
-       argv[0], cmSystemTools::GetCTestCommand()) &&
-     !this->ForceNewCTestProcess)
-    {
+  if (cmSystemTools::SameFile(argv[0], cmSystemTools::GetCTestCommand()) &&
+      !this->ForceNewCTestProcess) {
     cmCTest inst;
     inst.ConfigType = this->ConfigType;
     inst.TimeOut = timeout;
@@ -1333,189 +1146,159 @@ int cmCTest::RunTest(std::vector<const char*> argv,
     inst.SetStreams(&oss, &oss);
 
     std::vector<std::string> args;
-    for(unsigned int i =0; i < argv.size(); ++i)
-      {
-      if(argv[i])
-        {
+    for (unsigned int i = 0; i < argv.size(); ++i) {
+      if (argv[i]) {
         // make sure we pass the timeout in for any build and test
         // invocations. Since --build-generator is required this is a
         // good place to check for it, and to add the arguments in
-        if (strcmp(argv[i],"--build-generator") == 0 && timeout > 0)
-          {
+        if (strcmp(argv[i], "--build-generator") == 0 && timeout > 0) {
           args.push_back("--test-timeout");
           std::ostringstream msg;
           msg << timeout;
           args.push_back(msg.str());
-          }
-        args.push_back(argv[i]);
         }
+        args.push_back(argv[i]);
       }
-    if ( log )
-      {
+    }
+    if (log) {
       *log << "* Run internal CTest" << std::endl;
-      }
+    }
     std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
 
     cmsys::auto_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
-    if (modifyEnv)
-      {
+    if (modifyEnv) {
       saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
       cmSystemTools::AppendEnv(*environment);
-      }
+    }
 
     *retVal = inst.Run(args, output);
-    if(output)
-      {
+    if (output) {
       *output += oss.str();
-      }
-    if ( log && output)
-      {
+    }
+    if (log && output) {
       *log << *output;
-      }
+    }
     cmSystemTools::ChangeDirectory(oldpath);
-    if(output)
-      {
+    if (output) {
       cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
                  "Internal cmCTest object used to run test." << std::endl
-                 <<  *output << std::endl);
-      }
+                                                             << *output
+                                                             << std::endl);
+    }
 
     return cmsysProcess_State_Exited;
-    }
+  }
   std::vector<char> tempOutput;
-  if ( output )
-    {
+  if (output) {
     *output = "";
-    }
+  }
 
   cmsys::auto_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
-  if (modifyEnv)
-    {
+  if (modifyEnv) {
     saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
     cmSystemTools::AppendEnv(*environment);
-    }
+  }
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetCommand(cp, &*argv.begin());
   cmCTestLog(this, DEBUG, "Command is: " << argv[0] << std::endl);
-  if(cmSystemTools::GetRunCommandHideConsole())
-    {
+  if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
-    }
+  }
 
   cmsysProcess_SetTimeout(cp, timeout);
   cmsysProcess_Execute(cp);
 
   char* data;
   int length;
-  while(cmsysProcess_WaitForData(cp, &data, &length, 0))
-    {
-    if ( output )
-      {
-      tempOutput.insert(tempOutput.end(), data, data+length);
-      }
+  while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+    if (output) {
+      tempOutput.insert(tempOutput.end(), data, data + length);
+    }
     cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, cmCTestLogWrite(data, length));
-    if ( log )
-      {
+    if (log) {
       log->write(data, length);
-      }
     }
+  }
 
   cmsysProcess_WaitForExit(cp, 0);
-  if(output && tempOutput.begin() != tempOutput.end())
-    {
+  if (output && tempOutput.begin() != tempOutput.end()) {
     output->append(&*tempOutput.begin(), tempOutput.size());
-    }
+  }
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "-- Process completed"
-    << std::endl);
+               << std::endl);
 
   int result = cmsysProcess_GetState(cp);
 
-  if(result == cmsysProcess_State_Exited)
-    {
+  if (result == cmsysProcess_State_Exited) {
     *retVal = cmsysProcess_GetExitValue(cp);
-    if(*retVal != 0 && this->OutputTestOutputOnTestFailure)
-      {
-        OutputTestErrors(tempOutput);
-      }
+    if (*retVal != 0 && this->OutputTestOutputOnTestFailure) {
+      OutputTestErrors(tempOutput);
+    }
+  } else if (result == cmsysProcess_State_Exception) {
+    if (this->OutputTestOutputOnTestFailure) {
+      OutputTestErrors(tempOutput);
     }
-  else if(result == cmsysProcess_State_Exception)
-    {
-    if(this->OutputTestOutputOnTestFailure)
-      {
-        OutputTestErrors(tempOutput);
-      }
     *retVal = cmsysProcess_GetExitException(cp);
     std::string outerr = "\n*** Exception executing: ";
     outerr += cmsysProcess_GetExceptionString(cp);
-    if(output)
-      {
+    if (output) {
       *output += outerr;
-      }
-    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
-      << std::flush);
     }
-  else if(result == cmsysProcess_State_Error)
-    {
+    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
+                                                            << std::flush);
+  } else if (result == cmsysProcess_State_Error) {
     std::string outerr = "\n*** ERROR executing: ";
     outerr += cmsysProcess_GetErrorString(cp);
-    if(output)
-      {
+    if (output) {
       *output += outerr;
-      }
-    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
-      << std::flush);
     }
+    cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr.c_str() << std::endl
+                                                            << std::flush);
+  }
   cmsysProcess_Delete(cp);
 
   return result;
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::SafeBuildIdField(const std::string& value)
 {
   std::string safevalue(value);
 
-  if (safevalue != "")
-    {
+  if (safevalue != "") {
     // Disallow non-filename and non-space whitespace characters.
     // If they occur, replace them with ""
     //
-    const char *disallowed = "\\:*?\"<>|\n\r\t\f\v";
+    const char* disallowed = "\\:*?\"<>|\n\r\t\f\v";
 
-    if (safevalue.find_first_of(disallowed) != value.npos)
-      {
+    if (safevalue.find_first_of(disallowed) != value.npos) {
       std::string::size_type i = 0;
       std::string::size_type n = strlen(disallowed);
       char replace[2];
       replace[1] = 0;
 
-      for (i= 0; i<n; ++i)
-        {
+      for (i = 0; i < n; ++i) {
         replace[0] = disallowed[i];
         cmSystemTools::ReplaceString(safevalue, replace, "");
-        }
       }
     }
+  }
 
-  if (safevalue == "")
-    {
+  if (safevalue == "") {
     safevalue = "(empty)";
-    }
+  }
 
   return safevalue;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::StartXML(cmXMLWriter& xml, bool append)
 {
-  if(this->CurrentTag.empty())
-    {
-    cmCTestLog(this, ERROR_MESSAGE,
-               "Current Tag empty, this may mean"
-               " NightlStartTime was not set correctly." << std::endl);
+  if (this->CurrentTag.empty()) {
+    cmCTestLog(this, ERROR_MESSAGE, "Current Tag empty, this may mean"
+                                    " NightlStartTime was not set correctly."
+                 << std::endl);
     cmSystemTools::SetFatalErrorOccured();
-    }
+  }
 
   // find out about the system
   cmsys::SystemInformation info;
@@ -1523,12 +1306,12 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
   info.RunOSCheck();
   info.RunMemoryCheck();
 
-  std::string buildname = cmCTest::SafeBuildIdField(
-    this->GetCTestConfiguration("BuildName"));
-  std::string stamp = cmCTest::SafeBuildIdField(
-    this->CurrentTag + "-" + this->GetTestModelString());
-  std::string site = cmCTest::SafeBuildIdField(
-    this->GetCTestConfiguration("Site"));
+  std::string buildname =
+    cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
+  std::string stamp = cmCTest::SafeBuildIdField(this->CurrentTag + "-" +
+                                                this->GetTestModelString());
+  std::string site =
+    cmCTest::SafeBuildIdField(this->GetCTestConfiguration("Site"));
 
   xml.StartDocument();
   xml.StartElement("Site");
@@ -1537,14 +1320,13 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
   xml.Attribute("BuildStamp", stamp);
   xml.Attribute("Name", site);
   xml.Attribute("Generator",
-                     std::string("ctest-") + cmVersion::GetCMakeVersion());
-  if(append)
-    {
+                std::string("ctest-") + cmVersion::GetCMakeVersion());
+  if (append) {
     xml.Attribute("Append", "true");
-    }
+  }
   xml.Attribute("CompilerName", this->GetCTestConfiguration("Compiler"));
   xml.Attribute("CompilerVersion",
-    this->GetCTestConfiguration("CompilerVersion"));
+                this->GetCTestConfiguration("CompilerVersion"));
   xml.Attribute("OSName", info.GetOSName());
   xml.Attribute("Hostname", info.GetHostname());
   xml.Attribute("OSRelease", info.GetOSRelease());
@@ -1561,94 +1343,85 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
   xml.Attribute("TotalVirtualMemory", info.GetTotalVirtualMemory());
   xml.Attribute("TotalPhysicalMemory", info.GetTotalPhysicalMemory());
   xml.Attribute("LogicalProcessorsPerPhysical",
-                     info.GetLogicalProcessorsPerPhysical());
+                info.GetLogicalProcessorsPerPhysical());
   xml.Attribute("ProcessorClockFrequency", info.GetProcessorClockFrequency());
 
   std::string changeId = this->GetCTestConfiguration("ChangeId");
-  if(!changeId.empty())
-    {
+  if (!changeId.empty()) {
     xml.Attribute("ChangeId", changeId);
-    }
+  }
 
   this->AddSiteProperties(xml);
 }
 
-//----------------------------------------------------------------------
 void cmCTest::AddSiteProperties(cmXMLWriter& xml)
 {
   cmCTestScriptHandler* ch =
     static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
-  cmake* cm =  ch->GetCMake();
+  cmake* cm = ch->GetCMake();
   // if no CMake then this is the old style script and props like
   // this will not work anyway.
-  if(!cm)
-    {
+  if (!cm) {
     return;
-    }
+  }
   // This code should go when cdash is changed to use labels only
-  const char* subproject = cm->GetState()
-                             ->GetGlobalProperty("SubProject");
-  if(subproject)
-    {
+  const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
+  if (subproject) {
     xml.StartElement("Subproject");
     xml.Attribute("name", subproject);
     const char* labels =
-      ch->GetCMake()->GetState()
-                    ->GetGlobalProperty("SubProjectLabels");
-    if(labels)
-      {
+      ch->GetCMake()->GetState()->GetGlobalProperty("SubProjectLabels");
+    if (labels) {
       xml.StartElement("Labels");
       std::string l = labels;
       std::vector<std::string> args;
       cmSystemTools::ExpandListArgument(l, args);
-      for(std::vector<std::string>::iterator i = args.begin();
-          i != args.end(); ++i)
-        {
+      for (std::vector<std::string>::iterator i = args.begin();
+           i != args.end(); ++i) {
         xml.Element("Label", *i);
-        }
-      xml.EndElement();
       }
-    xml.EndElement();
+      xml.EndElement();
     }
+    xml.EndElement();
+  }
 
   // This code should stay when cdash only does label based sub-projects
   const char* label = cm->GetState()->GetGlobalProperty("Label");
-  if(label)
-    {
+  if (label) {
     xml.StartElement("Labels");
     xml.Element("Label", label);
     xml.EndElement();
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTest::EndXML(cmXMLWriter& xml)
 {
   xml.EndElement(); // Site
   xml.EndDocument();
 }
 
-//----------------------------------------------------------------------
 int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
-  const cmCTest::VectorOfStrings& files)
+                                      const cmCTest::VectorOfStrings& files)
 {
-  std::string buildname = cmCTest::SafeBuildIdField(
-    this->GetCTestConfiguration("BuildName"));
+  std::string buildname =
+    cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
   cmCTest::VectorOfStrings::const_iterator it;
   xml.StartDocument();
-  xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
-    "href=\"Dart/Source/Server/XSL/Build.xsl "
-    "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
+  xml.ProcessingInstruction("xml-stylesheet",
+                            "type=\"text/xsl\" "
+                            "href=\"Dart/Source/Server/XSL/Build.xsl "
+                            "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
   xml.StartElement("Site");
   xml.Attribute("BuildName", buildname);
-  xml.Attribute("BuildStamp", this->CurrentTag+"-"+this->GetTestModelString());
+  xml.Attribute("BuildStamp",
+                this->CurrentTag + "-" + this->GetTestModelString());
   xml.Attribute("Name", this->GetCTestConfiguration("Site"));
-  xml.Attribute("Generator",std::string("ctest")+cmVersion::GetCMakeVersion());
+  xml.Attribute("Generator",
+                std::string("ctest") + cmVersion::GetCMakeVersion());
   this->AddSiteProperties(xml);
   xml.StartElement("Notes");
 
-  for ( it = files.begin(); it != files.end(); it ++ )
-    {
+  for (it = files.begin(); it != files.end(); it++) {
     cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
     std::string note_time = this->CurrentTime();
     xml.StartElement("Note");
@@ -1657,165 +1430,138 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
     xml.Element("DateTime", note_time);
     xml.StartElement("Text");
     cmsys::ifstream ifs(it->c_str());
-    if ( ifs )
-      {
+    if (ifs) {
       std::string line;
-      while ( cmSystemTools::GetLineFromStream(ifs, line) )
-        {
+      while (cmSystemTools::GetLineFromStream(ifs, line)) {
         xml.Content(line);
         xml.Content("\n");
-        }
-      ifs.close();
       }
-    else
-      {
+      ifs.close();
+    } else {
       xml.Content("Problem reading file: " + *it + "\n");
-      cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it
-        << " while creating notes" << std::endl);
-      }
+      cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: "
+                   << *it << " while creating notes" << std::endl);
+    }
     xml.EndElement(); // Text
     xml.EndElement(); // Note
-    }
+  }
   xml.EndElement(); // Notes
   xml.EndElement(); // Site
   xml.EndDocument();
   return 1;
 }
 
-//----------------------------------------------------------------------
-int cmCTest::GenerateNotesFile(const VectorOfStrings &files)
+int cmCTest::GenerateNotesFile(const VectorOfStrings& files)
 {
   cmGeneratedFileStream ofs;
-  if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) )
-    {
+  if (!this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs)) {
     cmCTestLog(this, ERROR_MESSAGE, "Cannot open notes file" << std::endl);
     return 1;
-    }
+  }
   cmXMLWriter xml(ofs);
   this->GenerateCTestNotesOutput(xml, files);
   return 0;
 }
 
-//----------------------------------------------------------------------
 int cmCTest::GenerateNotesFile(const char* cfiles)
 {
-  if ( !cfiles )
-    {
+  if (!cfiles) {
     return 1;
-    }
+  }
 
   VectorOfStrings files;
 
   cmCTestLog(this, OUTPUT, "Create notes file" << std::endl);
 
   files = cmSystemTools::SplitString(cfiles, ';');
-  if (files.empty())
-    {
+  if (files.empty()) {
     return 1;
-    }
+  }
 
   return this->GenerateNotesFile(files);
 }
 
-//----------------------------------------------------------------------
-std::string cmCTest::Base64GzipEncodeFile(std::string file)
+std::string cmCTest::Base64GzipEncodeFile(std::string const& file)
 {
   std::string tarFile = file + "_temp.tar.gz";
   std::vector<std::string> files;
   files.push_back(file);
 
-  if(!cmSystemTools::CreateTar(tarFile.c_str(), files,
-                               cmSystemTools::TarCompressGZip, false))
-    {
+  if (!cmSystemTools::CreateTar(tarFile.c_str(), files,
+                                cmSystemTools::TarCompressGZip, false)) {
     cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while "
-      "encoding file: " << file << std::endl);
+                                    "encoding file: "
+                 << file << std::endl);
     return "";
-    }
+  }
   std::string base64 = this->Base64EncodeFile(tarFile);
   cmSystemTools::RemoveFile(tarFile);
   return base64;
 }
 
-//----------------------------------------------------------------------
-std::string cmCTest::Base64EncodeFile(std::string file)
+std::string cmCTest::Base64EncodeFile(std::string const& file)
 {
   size_t const len = cmSystemTools::FileLength(file);
   cmsys::ifstream ifs(file.c_str(), std::ios::in
 #ifdef _WIN32
-    | std::ios::binary
+                        | std::ios::binary
 #endif
-    );
-  unsigned char *file_buffer = new unsigned char [ len + 1 ];
+                      );
+  unsigned char* file_buffer = new unsigned char[len + 1];
   ifs.read(reinterpret_cast<char*>(file_buffer), len);
   ifs.close();
 
-  unsigned char *encoded_buffer
-    = new unsigned char [ (len * 3) / 2 + 5 ];
+  unsigned char* encoded_buffer = new unsigned char[(len * 3) / 2 + 5];
 
-  size_t const rlen
-    = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
+  size_t const rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
 
   std::string base64 = "";
-  for(size_t i = 0; i < rlen; i++)
-    {
+  for (size_t i = 0; i < rlen; i++) {
     base64 += encoded_buffer[i];
-    }
-  delete [] file_buffer;
-  delete [] encoded_buffer;
+  }
+  delete[] file_buffer;
+  delete[] encoded_buffer;
 
   return base64;
 }
 
-
-//----------------------------------------------------------------------
-bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files)
+bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files)
 {
   VectorOfStrings::const_iterator it;
-  for ( it = files.begin();
-    it != files.end();
-    ++ it )
-    {
-    if ( !cmSystemTools::FileExists(it->c_str()) )
-      {
+  for (it = files.begin(); it != files.end(); ++it) {
+    if (!cmSystemTools::FileExists(it->c_str())) {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
-        << *it << " to submit."
-        << std::endl;);
+                   << *it << " to submit." << std::endl;);
       return false;
-      }
-    this->AddSubmitFile(PartExtraFiles, it->c_str());
     }
+    this->AddSubmitFile(PartExtraFiles, it->c_str());
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::SubmitExtraFiles(const char* cfiles)
 {
-  if ( !cfiles )
-    {
+  if (!cfiles) {
     return 1;
-    }
+  }
 
   VectorOfStrings files;
 
   cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl);
 
   files = cmSystemTools::SplitString(cfiles, ';');
-  if (files.empty())
-    {
+  if (files.empty()) {
     return 1;
-    }
+  }
 
   return this->SubmitExtraFiles(files);
 }
 
-
-//-------------------------------------------------------
 // for a -D argument convert the next argument into
 // the proper list of dashboard steps via SetTest
-bool cmCTest::AddTestsForDashboardType(std::string &targ)
+bool cmCTest::AddTestsForDashboardType(std::string& targ)
 {
-  if ( targ == "Experimental" )
-    {
+  if (targ == "Experimental") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Start");
     this->SetTest("Configure");
@@ -1823,50 +1569,31 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
     this->SetTest("Test");
     this->SetTest("Coverage");
     this->SetTest("Submit");
-    }
-  else if ( targ == "ExperimentalStart" )
-    {
+  } else if (targ == "ExperimentalStart") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Start");
-    }
-  else if ( targ == "ExperimentalUpdate" )
-    {
+  } else if (targ == "ExperimentalUpdate") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Update");
-    }
-  else if ( targ == "ExperimentalConfigure" )
-    {
+  } else if (targ == "ExperimentalConfigure") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Configure");
-    }
-  else if ( targ == "ExperimentalBuild" )
-    {
+  } else if (targ == "ExperimentalBuild") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Build");
-    }
-  else if ( targ == "ExperimentalTest" )
-    {
+  } else if (targ == "ExperimentalTest") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Test");
-    }
-  else if ( targ == "ExperimentalMemCheck"
-            || targ == "ExperimentalPurify" )
-    {
+  } else if (targ == "ExperimentalMemCheck" || targ == "ExperimentalPurify") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("MemCheck");
-    }
-  else if ( targ == "ExperimentalCoverage" )
-    {
+  } else if (targ == "ExperimentalCoverage") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Coverage");
-    }
-  else if ( targ == "ExperimentalSubmit" )
-    {
+  } else if (targ == "ExperimentalSubmit") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Submit");
-    }
-  else if ( targ == "Continuous" )
-    {
+  } else if (targ == "Continuous") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Start");
     this->SetTest("Update");
@@ -1875,50 +1602,31 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
     this->SetTest("Test");
     this->SetTest("Coverage");
     this->SetTest("Submit");
-    }
-  else if ( targ == "ContinuousStart" )
-    {
+  } else if (targ == "ContinuousStart") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Start");
-    }
-  else if ( targ == "ContinuousUpdate" )
-    {
+  } else if (targ == "ContinuousUpdate") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Update");
-    }
-  else if ( targ == "ContinuousConfigure" )
-    {
+  } else if (targ == "ContinuousConfigure") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Configure");
-    }
-  else if ( targ == "ContinuousBuild" )
-    {
+  } else if (targ == "ContinuousBuild") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Build");
-    }
-  else if ( targ == "ContinuousTest" )
-    {
+  } else if (targ == "ContinuousTest") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Test");
-    }
-  else if ( targ == "ContinuousMemCheck"
-        || targ == "ContinuousPurify" )
-    {
+  } else if (targ == "ContinuousMemCheck" || targ == "ContinuousPurify") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("MemCheck");
-    }
-  else if ( targ == "ContinuousCoverage" )
-    {
+  } else if (targ == "ContinuousCoverage") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Coverage");
-    }
-  else if ( targ == "ContinuousSubmit" )
-    {
+  } else if (targ == "ContinuousSubmit") {
     this->SetTestModel(cmCTest::CONTINUOUS);
     this->SetTest("Submit");
-    }
-  else if ( targ == "Nightly" )
-    {
+  } else if (targ == "Nightly") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Start");
     this->SetTest("Update");
@@ -1927,50 +1635,31 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
     this->SetTest("Test");
     this->SetTest("Coverage");
     this->SetTest("Submit");
-    }
-  else if ( targ == "NightlyStart" )
-    {
+  } else if (targ == "NightlyStart") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Start");
-    }
-  else if ( targ == "NightlyUpdate" )
-    {
+  } else if (targ == "NightlyUpdate") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Update");
-    }
-  else if ( targ == "NightlyConfigure" )
-    {
+  } else if (targ == "NightlyConfigure") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Configure");
-    }
-  else if ( targ == "NightlyBuild" )
-    {
+  } else if (targ == "NightlyBuild") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Build");
-    }
-  else if ( targ == "NightlyTest" )
-    {
+  } else if (targ == "NightlyTest") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Test");
-    }
-  else if ( targ == "NightlyMemCheck"
-            || targ == "NightlyPurify" )
-    {
+  } else if (targ == "NightlyMemCheck" || targ == "NightlyPurify") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("MemCheck");
-    }
-  else if ( targ == "NightlyCoverage" )
-    {
+  } else if (targ == "NightlyCoverage") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Coverage");
-    }
-  else if ( targ == "NightlySubmit" )
-    {
+  } else if (targ == "NightlySubmit") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Submit");
-    }
-  else if ( targ == "MemoryCheck" )
-    {
+  } else if (targ == "MemoryCheck") {
     this->SetTestModel(cmCTest::EXPERIMENTAL);
     this->SetTest("Start");
     this->SetTest("Configure");
@@ -1978,9 +1667,7 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
     this->SetTest("MemCheck");
     this->SetTest("Coverage");
     this->SetTest("Submit");
-    }
-  else if ( targ == "NightlyMemoryCheck" )
-    {
+  } else if (targ == "NightlyMemoryCheck") {
     this->SetTestModel(cmCTest::NIGHTLY);
     this->SetTest("Start");
     this->SetTest("Update");
@@ -1989,397 +1676,326 @@ bool cmCTest::AddTestsForDashboardType(std::string &targ)
     this->SetTest("MemCheck");
     this->SetTest("Coverage");
     this->SetTest("Submit");
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
   return true;
 }
 
-
-//----------------------------------------------------------------------
-void cmCTest::ErrorMessageUnknownDashDValue(std::string &val)
+void cmCTest::ErrorMessageUnknownDashDValue(std::string& val)
 {
   cmCTestLog(this, ERROR_MESSAGE,
-    "CTest -D called with incorrect option: " << val << std::endl);
+             "CTest -D called with incorrect option: " << val << std::endl);
 
-  cmCTestLog(this, ERROR_MESSAGE,
-    "Available options are:" << std::endl
-    << "  ctest -D Continuous" << std::endl
-    << "  ctest -D Continuous(Start|Update|Configure|Build)" << std::endl
-    << "  ctest -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl
-    << "  ctest -D Experimental" << std::endl
-    << "  ctest -D Experimental(Start|Update|Configure|Build)" << std::endl
-    << "  ctest -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl
-    << "  ctest -D Nightly" << std::endl
-    << "  ctest -D Nightly(Start|Update|Configure|Build)" << std::endl
-    << "  ctest -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl
-    << "  ctest -D NightlyMemoryCheck" << std::endl);
+  cmCTestLog(
+    this, ERROR_MESSAGE, "Available options are:"
+      << std::endl
+      << "  ctest -D Continuous" << std::endl
+      << "  ctest -D Continuous(Start|Update|Configure|Build)" << std::endl
+      << "  ctest -D Continuous(Test|Coverage|MemCheck|Submit)" << std::endl
+      << "  ctest -D Experimental" << std::endl
+      << "  ctest -D Experimental(Start|Update|Configure|Build)" << std::endl
+      << "  ctest -D Experimental(Test|Coverage|MemCheck|Submit)" << std::endl
+      << "  ctest -D Nightly" << std::endl
+      << "  ctest -D Nightly(Start|Update|Configure|Build)" << std::endl
+      << "  ctest -D Nightly(Test|Coverage|MemCheck|Submit)" << std::endl
+      << "  ctest -D NightlyMemoryCheck" << std::endl);
 }
 
-
-//----------------------------------------------------------------------
 bool cmCTest::CheckArgument(const std::string& arg, const char* varg1,
-  const char* varg2)
+                            const char* varg2)
 {
   return (varg1 && arg == varg1) || (varg2 && arg == varg2);
 }
 
-
-//----------------------------------------------------------------------
 // Processes one command line argument (and its arguments if any)
 // for many simple options and then returns
-bool cmCTest::HandleCommandLineArguments(size_t &i,
-                                         std::vector<std::string> &args,
+bool cmCTest::HandleCommandLineArguments(size_t& i,
+                                         std::vector<std::string>& args,
                                          std::string& errormsg)
 {
   std::string arg = args[i];
-  if(this->CheckArgument(arg, "-F"))
-    {
+  if (this->CheckArgument(arg, "-F")) {
     this->Failover = true;
-    }
-  if(this->CheckArgument(arg, "-j", "--parallel") && i < args.size() - 1)
-    {
+  }
+  if (this->CheckArgument(arg, "-j", "--parallel") && i < args.size() - 1) {
     i++;
     int plevel = atoi(args[i].c_str());
     this->SetParallelLevel(plevel);
     this->ParallelLevelSetInCli = true;
-    }
-  else if(arg.find("-j") == 0)
-    {
+  } else if (arg.find("-j") == 0) {
     int plevel = atoi(arg.substr(2).c_str());
     this->SetParallelLevel(plevel);
     this->ParallelLevelSetInCli = true;
-    }
-  if(this->CheckArgument(arg, "--repeat-until-fail"))
-    {
-    if( i >= args.size() - 1)
-      {
+  }
+  if (this->CheckArgument(arg, "--repeat-until-fail")) {
+    if (i >= args.size() - 1) {
       errormsg = "'--repeat-until-fail' requires an argument";
       return false;
-      }
+    }
     i++;
     long repeat = 1;
-    if(!cmSystemTools::StringToLong(args[i].c_str(), &repeat))
-      {
-      errormsg = "'--repeat-until-fail' given non-integer value '"
-        + args[i] + "'";
+    if (!cmSystemTools::StringToLong(args[i].c_str(), &repeat)) {
+      errormsg =
+        "'--repeat-until-fail' given non-integer value '" + args[i] + "'";
       return false;
-      }
+    }
     this->RepeatTests = static_cast<int>(repeat);
-    if(repeat > 1)
-      {
+    if (repeat > 1) {
       this->RepeatUntilFail = true;
-      }
     }
+  }
 
-  if(this->CheckArgument(arg, "--test-load") && i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "--test-load") && i < args.size() - 1) {
     i++;
     unsigned long load;
-    if (cmSystemTools::StringToULong(args[i].c_str(), &load))
-      {
+    if (cmSystemTools::StringToULong(args[i].c_str(), &load)) {
       this->SetTestLoad(load);
-      }
-    else
-      {
+    } else {
       cmCTestLog(this, WARNING,
                  "Invalid value for 'Test Load' : " << args[i] << std::endl);
-      }
     }
+  }
 
-  if(this->CheckArgument(arg, "--no-compress-output"))
-    {
+  if (this->CheckArgument(arg, "--no-compress-output")) {
     this->CompressTestOutput = false;
     this->CompressMemCheckOutput = false;
-    }
+  }
 
-  if(this->CheckArgument(arg, "--print-labels"))
-    {
+  if (this->CheckArgument(arg, "--print-labels")) {
     this->PrintLabels = true;
-    }
+  }
 
-  if(this->CheckArgument(arg, "--http1.0"))
-    {
+  if (this->CheckArgument(arg, "--http1.0")) {
     this->UseHTTP10 = true;
-    }
+  }
 
-  if(this->CheckArgument(arg, "--timeout") && i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
     i++;
     double timeout = (double)atof(args[i].c_str());
     this->GlobalTimeout = timeout;
-    }
+  }
 
-  if(this->CheckArgument(arg, "--stop-time") && i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "--stop-time") && i < args.size() - 1) {
     i++;
     this->SetStopTime(args[i]);
-    }
+  }
 
-  if(this->CheckArgument(arg, "-C", "--build-config") &&
-     i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "-C", "--build-config") &&
+      i < args.size() - 1) {
     i++;
     this->SetConfigType(args[i].c_str());
-    }
+  }
 
-  if(this->CheckArgument(arg, "--debug"))
-    {
+  if (this->CheckArgument(arg, "--debug")) {
     this->Debug = true;
     this->ShowLineNumbers = true;
-    }
-  if(this->CheckArgument(arg, "--track") && i < args.size() - 1)
-    {
+  }
+  if (this->CheckArgument(arg, "--track") && i < args.size() - 1) {
     i++;
     this->SpecificTrack = args[i];
-    }
-  if(this->CheckArgument(arg, "--show-line-numbers"))
-    {
+  }
+  if (this->CheckArgument(arg, "--show-line-numbers")) {
     this->ShowLineNumbers = true;
-    }
-  if(this->CheckArgument(arg, "--no-label-summary"))
-    {
+  }
+  if (this->CheckArgument(arg, "--no-label-summary")) {
     this->LabelSummary = false;
-    }
-  if(this->CheckArgument(arg, "-Q", "--quiet"))
-    {
+  }
+  if (this->CheckArgument(arg, "-Q", "--quiet")) {
     this->Quiet = true;
-    }
-  if(this->CheckArgument(arg, "-V", "--verbose"))
-    {
+  }
+  if (this->CheckArgument(arg, "-V", "--verbose")) {
     this->Verbose = true;
-    }
-  if(this->CheckArgument(arg, "-B"))
-    {
+  }
+  if (this->CheckArgument(arg, "-B")) {
     this->BatchJobs = true;
-    }
-  if(this->CheckArgument(arg, "-VV", "--extra-verbose"))
-    {
+  }
+  if (this->CheckArgument(arg, "-VV", "--extra-verbose")) {
     this->ExtraVerbose = true;
     this->Verbose = true;
-    }
-  if(this->CheckArgument(arg, "--output-on-failure"))
-    {
+  }
+  if (this->CheckArgument(arg, "--output-on-failure")) {
     this->OutputTestOutputOnTestFailure = true;
-    }
+  }
   if (this->CheckArgument(arg, "--test-output-size-passed") &&
-      i < args.size() - 1)
-    {
+      i < args.size() - 1) {
     i++;
     long outputSize;
-    if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize))
-      {
-      if (cmCTestTestHandler *pCTestTestHandler =
-          static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"]))
-        {
+    if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) {
+      if (cmCTestTestHandler* pCTestTestHandler =
+            static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) {
         pCTestTestHandler->SetTestOutputSizePassed(int(outputSize));
-        }
       }
-    else
-      {
+    } else {
       cmCTestLog(this, WARNING,
-                 "Invalid value for '--test-output-size-passed': " <<
-                 args[i] << "\n");
-      }
+                 "Invalid value for '--test-output-size-passed': " << args[i]
+                                                                   << "\n");
     }
+  }
   if (this->CheckArgument(arg, "--test-output-size-failed") &&
-      i < args.size() - 1)
-    {
+      i < args.size() - 1) {
     i++;
     long outputSize;
-    if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize))
-      {
-      if (cmCTestTestHandler *pCTestTestHandler =
-          static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"]))
-        {
+    if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) {
+      if (cmCTestTestHandler* pCTestTestHandler =
+            static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) {
         pCTestTestHandler->SetTestOutputSizeFailed(int(outputSize));
-        }
       }
-    else
-      {
+    } else {
       cmCTestLog(this, WARNING,
-                 "Invalid value for '--test-output-size-failed': " <<
-                 args[i] << "\n");
-      }
+                 "Invalid value for '--test-output-size-failed': " << args[i]
+                                                                   << "\n");
     }
-  if(this->CheckArgument(arg, "-N", "--show-only"))
-    {
+  }
+  if (this->CheckArgument(arg, "-N", "--show-only")) {
     this->ShowOnly = true;
-    }
+  }
 
-  if(this->CheckArgument(arg, "-O", "--output-log") && i < args.size() - 1 )
-    {
+  if (this->CheckArgument(arg, "-O", "--output-log") && i < args.size() - 1) {
     i++;
     this->SetOutputLogFileName(args[i].c_str());
-    }
+  }
 
-  if(this->CheckArgument(arg, "--tomorrow-tag"))
-    {
+  if (this->CheckArgument(arg, "--tomorrow-tag")) {
     this->TomorrowTag = true;
-    }
-  if(this->CheckArgument(arg, "--force-new-ctest-process"))
-    {
+  }
+  if (this->CheckArgument(arg, "--force-new-ctest-process")) {
     this->ForceNewCTestProcess = true;
-    }
-  if(this->CheckArgument(arg, "-W", "--max-width") && i < args.size() - 1)
-    {
+  }
+  if (this->CheckArgument(arg, "-W", "--max-width") && i < args.size() - 1) {
     i++;
     this->MaxTestNameWidth = atoi(args[i].c_str());
-    }
-  if(this->CheckArgument(arg, "--interactive-debug-mode") &&
-     i < args.size() - 1 )
-    {
+  }
+  if (this->CheckArgument(arg, "--interactive-debug-mode") &&
+      i < args.size() - 1) {
     i++;
     this->InteractiveDebugMode = cmSystemTools::IsOn(args[i].c_str());
-    }
-  if(this->CheckArgument(arg, "--submit-index") && i < args.size() - 1 )
-    {
+  }
+  if (this->CheckArgument(arg, "--submit-index") && i < args.size() - 1) {
     i++;
     this->SubmitIndex = atoi(args[i].c_str());
-    if ( this->SubmitIndex < 0 )
-      {
+    if (this->SubmitIndex < 0) {
       this->SubmitIndex = 0;
-      }
     }
+  }
 
-  if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "--overwrite") && i < args.size() - 1) {
     i++;
     this->AddCTestConfigurationOverwrite(args[i]);
-    }
-  if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1)
-    {
+  }
+  if (this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) {
     this->ProduceXML = true;
     this->SetTest("Notes");
     i++;
     this->SetNotesFiles(args[i].c_str());
-    }
+  }
 
   // options that control what tests are run
-  if(this->CheckArgument(arg, "-I", "--tests-information") &&
-     i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "-I", "--tests-information") &&
+      i < args.size() - 1) {
     i++;
     this->GetHandler("test")->SetPersistentOption("TestsToRunInformation",
                                                   args[i].c_str());
-    this->GetHandler("memcheck")->
-      SetPersistentOption("TestsToRunInformation",args[i].c_str());
-    }
-  if(this->CheckArgument(arg, "-U", "--union"))
-    {
+    this->GetHandler("memcheck")
+      ->SetPersistentOption("TestsToRunInformation", args[i].c_str());
+  }
+  if (this->CheckArgument(arg, "-U", "--union")) {
     this->GetHandler("test")->SetPersistentOption("UseUnion", "true");
     this->GetHandler("memcheck")->SetPersistentOption("UseUnion", "true");
-    }
-  if(this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1)
-    {
+  }
+  if (this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) {
     i++;
-    this->GetHandler("test")->
-      SetPersistentOption("IncludeRegularExpression", args[i].c_str());
-    this->GetHandler("memcheck")->
-      SetPersistentOption("IncludeRegularExpression", args[i].c_str());
-    }
-  if(this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1)
-    {
+    this->GetHandler("test")->SetPersistentOption("IncludeRegularExpression",
+                                                  args[i].c_str());
+    this->GetHandler("memcheck")
+      ->SetPersistentOption("IncludeRegularExpression", args[i].c_str());
+  }
+  if (this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1) {
     i++;
-    this->GetHandler("test")->
-      SetPersistentOption("LabelRegularExpression", args[i].c_str());
-    this->GetHandler("memcheck")->
-      SetPersistentOption("LabelRegularExpression", args[i].c_str());
-    }
-  if(this->CheckArgument(arg, "-LE", "--label-exclude") && i < args.size() - 1)
-    {
+    this->GetHandler("test")->SetPersistentOption("LabelRegularExpression",
+                                                  args[i].c_str());
+    this->GetHandler("memcheck")
+      ->SetPersistentOption("LabelRegularExpression", args[i].c_str());
+  }
+  if (this->CheckArgument(arg, "-LE", "--label-exclude") &&
+      i < args.size() - 1) {
     i++;
-    this->GetHandler("test")->
-      SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
-    this->GetHandler("memcheck")->
-      SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
-    }
+    this->GetHandler("test")->SetPersistentOption(
+      "ExcludeLabelRegularExpression", args[i].c_str());
+    this->GetHandler("memcheck")
+      ->SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
+  }
 
-  if(this->CheckArgument(arg, "-E", "--exclude-regex") &&
-     i < args.size() - 1)
-    {
+  if (this->CheckArgument(arg, "-E", "--exclude-regex") &&
+      i < args.size() - 1) {
     i++;
-    this->GetHandler("test")->
-      SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
-    this->GetHandler("memcheck")->
-      SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
-    }
+    this->GetHandler("test")->SetPersistentOption("ExcludeRegularExpression",
+                                                  args[i].c_str());
+    this->GetHandler("memcheck")
+      ->SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
+  }
 
-  if(this->CheckArgument(arg, "--rerun-failed"))
-    {
+  if (this->CheckArgument(arg, "--rerun-failed")) {
     this->GetHandler("test")->SetPersistentOption("RerunFailed", "true");
     this->GetHandler("memcheck")->SetPersistentOption("RerunFailed", "true");
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------
 // handle the -S -SR and -SP arguments
-void cmCTest::HandleScriptArguments(size_t &i,
-                                    std::vector<std::string> &args,
-                                    bool &SRArgumentSpecified)
+void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
+                                    bool& SRArgumentSpecified)
 {
   std::string arg = args[i];
-  if(this->CheckArgument(arg, "-SP", "--script-new-process") &&
-     i < args.size() - 1 )
-    {
+  if (this->CheckArgument(arg, "-SP", "--script-new-process") &&
+      i < args.size() - 1) {
     this->RunConfigurationScript = true;
     i++;
-    cmCTestScriptHandler* ch
-      = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+    cmCTestScriptHandler* ch =
+      static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
     // -SR is an internal argument, -SP should be ignored when it is passed
-    if (!SRArgumentSpecified)
-      {
-      ch->AddConfigurationScript(args[i].c_str(),false);
-      }
+    if (!SRArgumentSpecified) {
+      ch->AddConfigurationScript(args[i].c_str(), false);
     }
+  }
 
-  if(this->CheckArgument(arg, "-SR", "--script-run") &&
-     i < args.size() - 1 )
-    {
+  if (this->CheckArgument(arg, "-SR", "--script-run") && i < args.size() - 1) {
     SRArgumentSpecified = true;
     this->RunConfigurationScript = true;
     i++;
-    cmCTestScriptHandler* ch
-      = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
-    ch->AddConfigurationScript(args[i].c_str(),true);
-    }
+    cmCTestScriptHandler* ch =
+      static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+    ch->AddConfigurationScript(args[i].c_str(), true);
+  }
 
-  if(this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1 )
-    {
+  if (this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1) {
     this->RunConfigurationScript = true;
     i++;
-    cmCTestScriptHandler* ch
-      = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+    cmCTestScriptHandler* ch =
+      static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
     // -SR is an internal argument, -S should be ignored when it is passed
-    if (!SRArgumentSpecified)
-      {
-      ch->AddConfigurationScript(args[i].c_str(),true);
-      }
+    if (!SRArgumentSpecified) {
+      ch->AddConfigurationScript(args[i].c_str(), true);
     }
+  }
 }
 
-//----------------------------------------------------------------------
-bool cmCTest::AddVariableDefinition(const std::string &arg)
+bool cmCTest::AddVariableDefinition(const std::string& arg)
 {
   std::string name;
   std::string value;
   cmState::CacheEntryType type = cmState::UNINITIALIZED;
 
-  if (cmake::ParseCacheEntry(arg, name, value, type))
-    {
+  if (cmake::ParseCacheEntry(arg, name, value, type)) {
     this->Definitions[name] = value;
     return true;
-    }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------
 // the main entry point of ctest, called from main
-int cmCTest::Run(std::vector<std::string> &args, std::string* output)
+int cmCTest::Run(std::vector<std::string>& args, std::string* output)
 {
   const char* ctestExec = "ctest";
   bool cmakeAndTest = false;
@@ -2388,161 +2004,136 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
 
   // copy the command line
   this->InitialCommandLineArguments.insert(
-      this->InitialCommandLineArguments.end(),
-      args.begin(), args.end());
+    this->InitialCommandLineArguments.end(), args.begin(), args.end());
 
   // process the command line arguments
-  for(size_t i=1; i < args.size(); ++i)
-    {
+  for (size_t i = 1; i < args.size(); ++i) {
     // handle the simple commandline arguments
     std::string errormsg;
-    if(!this->HandleCommandLineArguments(i,args, errormsg))
-      {
+    if (!this->HandleCommandLineArguments(i, args, errormsg)) {
       cmSystemTools::Error(errormsg.c_str());
       return 1;
-      }
+    }
 
     // handle the script arguments -S -SR -SP
-    this->HandleScriptArguments(i,args,SRArgumentSpecified);
+    this->HandleScriptArguments(i, args, SRArgumentSpecified);
 
     // handle a request for a dashboard
     std::string arg = args[i];
-    if(this->CheckArgument(arg, "-D", "--dashboard") && i < args.size() - 1 )
-      {
+    if (this->CheckArgument(arg, "-D", "--dashboard") && i < args.size() - 1) {
       this->ProduceXML = true;
       i++;
       std::string targ = args[i];
       // AddTestsForDashboard parses the dashboard type and converts it
       // into the separate stages
-      if (!this->AddTestsForDashboardType(targ))
-        {
-        if (!this->AddVariableDefinition(targ))
-          {
+      if (!this->AddTestsForDashboardType(targ)) {
+        if (!this->AddVariableDefinition(targ)) {
           this->ErrorMessageUnknownDashDValue(targ);
           executeTests = false;
-          }
         }
       }
+    }
 
     // If it's not exactly -D, but it starts with -D, then try to parse out
     // a variable definition from it, same as CMake does. Unsuccessful
     // attempts are simply ignored since previous ctest versions ignore
     // this too. (As well as many other unknown command line args.)
     //
-    if(arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D"))
-      {
+    if (arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D")) {
       std::string input = arg.substr(2);
       this->AddVariableDefinition(input);
-      }
+    }
 
-    if(this->CheckArgument(arg, "-T", "--test-action") &&
-      (i < args.size() -1) )
-      {
+    if (this->CheckArgument(arg, "-T", "--test-action") &&
+        (i < args.size() - 1)) {
       this->ProduceXML = true;
       i++;
-      if ( !this->SetTest(args[i].c_str(), false) )
-        {
+      if (!this->SetTest(args[i].c_str(), false)) {
         executeTests = false;
         cmCTestLog(this, ERROR_MESSAGE,
-          "CTest -T called with incorrect option: "
-          << args[i] << std::endl);
-        cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
-          << "  " << ctestExec << " -T all" << std::endl
-          << "  " << ctestExec << " -T start" << std::endl
-          << "  " << ctestExec << " -T update" << std::endl
-          << "  " << ctestExec << " -T configure" << std::endl
-          << "  " << ctestExec << " -T build" << std::endl
-          << "  " << ctestExec << " -T test" << std::endl
-          << "  " << ctestExec << " -T coverage" << std::endl
-          << "  " << ctestExec << " -T memcheck" << std::endl
-          << "  " << ctestExec << " -T notes" << std::endl
-          << "  " << ctestExec << " -T submit" << std::endl);
-        }
+                   "CTest -T called with incorrect option: " << args[i]
+                                                             << std::endl);
+        cmCTestLog(this, ERROR_MESSAGE, "Available options are:"
+                     << std::endl
+                     << "  " << ctestExec << " -T all" << std::endl
+                     << "  " << ctestExec << " -T start" << std::endl
+                     << "  " << ctestExec << " -T update" << std::endl
+                     << "  " << ctestExec << " -T configure" << std::endl
+                     << "  " << ctestExec << " -T build" << std::endl
+                     << "  " << ctestExec << " -T test" << std::endl
+                     << "  " << ctestExec << " -T coverage" << std::endl
+                     << "  " << ctestExec << " -T memcheck" << std::endl
+                     << "  " << ctestExec << " -T notes" << std::endl
+                     << "  " << ctestExec << " -T submit" << std::endl);
       }
+    }
 
     // what type of test model
-    if(this->CheckArgument(arg, "-M", "--test-model") &&
-      (i < args.size() -1) )
-      {
+    if (this->CheckArgument(arg, "-M", "--test-model") &&
+        (i < args.size() - 1)) {
       i++;
       std::string const& str = args[i];
-      if ( cmSystemTools::LowerCase(str) == "nightly" )
-        {
+      if (cmSystemTools::LowerCase(str) == "nightly") {
         this->SetTestModel(cmCTest::NIGHTLY);
-        }
-      else if ( cmSystemTools::LowerCase(str) == "continuous" )
-        {
+      } else if (cmSystemTools::LowerCase(str) == "continuous") {
         this->SetTestModel(cmCTest::CONTINUOUS);
-        }
-      else if ( cmSystemTools::LowerCase(str) == "experimental" )
-        {
+      } else if (cmSystemTools::LowerCase(str) == "experimental") {
         this->SetTestModel(cmCTest::EXPERIMENTAL);
-        }
-      else
-        {
+      } else {
         executeTests = false;
         cmCTestLog(this, ERROR_MESSAGE,
-          "CTest -M called with incorrect option: " << str
-          << std::endl);
-        cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
-          << "  " << ctestExec << " -M Continuous" << std::endl
-          << "  " << ctestExec << " -M Experimental" << std::endl
-                   << "  " << ctestExec << " -M Nightly" << std::endl);
-        }
+                   "CTest -M called with incorrect option: " << str
+                                                             << std::endl);
+        cmCTestLog(this, ERROR_MESSAGE, "Available options are:"
+                     << std::endl
+                     << "  " << ctestExec << " -M Continuous" << std::endl
+                     << "  " << ctestExec << " -M Experimental" << std::endl
+                     << "  " << ctestExec << " -M Nightly" << std::endl);
       }
+    }
 
-    if(this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1)
-      {
+    if (this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1) {
       this->ProduceXML = true;
       this->SetTest("Submit");
       i++;
-      if ( !this->SubmitExtraFiles(args[i].c_str()) )
-        {
+      if (!this->SubmitExtraFiles(args[i].c_str())) {
         return 0;
-        }
       }
+    }
 
     // --build-and-test options
-    if(this->CheckArgument(arg, "--build-and-test") && i < args.size() - 1)
-      {
+    if (this->CheckArgument(arg, "--build-and-test") && i < args.size() - 1) {
       cmakeAndTest = true;
-      }
+    }
 
-    if(this->CheckArgument(arg, "--schedule-random"))
-      {
+    if (this->CheckArgument(arg, "--schedule-random")) {
       this->ScheduleType = "Random";
-      }
+    }
 
     // pass the argument to all the handlers as well, but i may no longer be
     // set to what it was originally so I'm not sure this is working as
     // intended
     cmCTest::t_TestingHandlers::iterator it;
-    for ( it = this->TestingHandlers.begin();
-      it != this->TestingHandlers.end();
-      ++ it )
-      {
-      if ( !it->second->ProcessCommandLineArguments(arg, i, args) )
-        {
+    for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
+         ++it) {
+      if (!it->second->ProcessCommandLineArguments(arg, i, args)) {
         cmCTestLog(this, ERROR_MESSAGE,
-          "Problem parsing command line arguments within a handler");
+                   "Problem parsing command line arguments within a handler");
         return 0;
-        }
       }
-    } // the close of the for argument loop
+    }
+  } // the close of the for argument loop
 
-  if (!this->ParallelLevelSetInCli)
-    {
-    if (const char *parallel = cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL"))
-      {
+  if (!this->ParallelLevelSetInCli) {
+    if (const char* parallel = cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL")) {
       int plevel = atoi(parallel);
       this->SetParallelLevel(plevel);
-      }
     }
+  }
 
   // now what sould cmake do? if --build-and-test was specified then
   // we run the build and test handler and return
-  if(cmakeAndTest)
-    {
+  if (cmakeAndTest) {
     this->Verbose = true;
     cmCTestBuildAndTestHandler* handler =
       static_cast<cmCTestBuildAndTestHandler*>(this->GetHandler("buildtest"));
@@ -2551,222 +2142,183 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
 #ifdef CMAKE_BUILD_WITH_CMAKE
     cmDynamicLoader::FlushCache();
 #endif
-    if(retv != 0)
-      {
-      cmCTestLog(this, DEBUG, "build and test failing returning: " << retv
-                 << std::endl);
-      }
-    return retv;
+    if (retv != 0) {
+      cmCTestLog(this, DEBUG,
+                 "build and test failing returning: " << retv << std::endl);
     }
+    return retv;
+  }
 
-  if(executeTests)
-    {
+  if (executeTests) {
     int res;
     // call process directory
-    if (this->RunConfigurationScript)
-      {
-      if ( this->ExtraVerbose )
-        {
+    if (this->RunConfigurationScript) {
+      if (this->ExtraVerbose) {
         cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl);
-        }
+      }
       cmCTest::t_TestingHandlers::iterator it;
-      for ( it = this->TestingHandlers.begin();
-        it != this->TestingHandlers.end();
-        ++ it )
-        {
+      for (it = this->TestingHandlers.begin();
+           it != this->TestingHandlers.end(); ++it) {
         it->second->SetVerbose(this->ExtraVerbose);
         it->second->SetSubmitIndex(this->SubmitIndex);
-        }
+      }
       this->GetHandler("script")->SetVerbose(this->Verbose);
       res = this->GetHandler("script")->ProcessHandler();
-      if(res != 0)
-        {
-        cmCTestLog(this, DEBUG, "running script failing returning: " << res
-                   << std::endl);
-        }
-
+      if (res != 0) {
+        cmCTestLog(this, DEBUG,
+                   "running script failing returning: " << res << std::endl);
       }
-    else
-      {
+
+    } else {
       // What is this?  -V seems to be the same as -VV,
       // and Verbose is always on in this case
       this->ExtraVerbose = this->Verbose;
       this->Verbose = true;
       cmCTest::t_TestingHandlers::iterator it;
-      for ( it = this->TestingHandlers.begin();
-        it != this->TestingHandlers.end();
-        ++ it )
-        {
+      for (it = this->TestingHandlers.begin();
+           it != this->TestingHandlers.end(); ++it) {
         it->second->SetVerbose(this->Verbose);
         it->second->SetSubmitIndex(this->SubmitIndex);
-        }
+      }
       std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-      if(!this->Initialize(cwd.c_str(), 0))
-        {
+      if (!this->Initialize(cwd.c_str(), 0)) {
         res = 12;
         cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard."
-          << std::endl);
-        }
-      else
-        {
+                     << std::endl);
+      } else {
         res = this->ProcessTests();
-        }
-      this->Finalize();
-      }
-    if(res != 0)
-      {
-      cmCTestLog(this, DEBUG, "Running a test(s) failed returning : " << res
-                 << std::endl);
       }
-    return res;
+      this->Finalize();
     }
+    if (res != 0) {
+      cmCTestLog(this, DEBUG,
+                 "Running a test(s) failed returning : " << res << std::endl);
+    }
+    return res;
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::SetNotesFiles(const char* notes)
 {
-  if ( !notes )
-    {
+  if (!notes) {
     return;
-    }
+  }
   this->NotesFiles = notes;
 }
 
-//----------------------------------------------------------------------
-void cmCTest::SetStopTime(std::string time)
+void cmCTest::SetStopTime(std::string const& time)
 {
   this->StopTime = time;
   this->DetermineNextDayStop();
 }
 
-//----------------------------------------------------------------------
 int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
 {
   bool found = false;
   VectorOfStrings dirs;
   VectorOfStrings ndirs;
   cmCTestLog(this, DEBUG, "* Read custom CTest configuration directory: "
-    << dir << std::endl);
+               << dir << std::endl);
 
   std::string fname = dir;
   fname += "/CTestCustom.cmake";
-  cmCTestLog(this, DEBUG, "* Check for file: "
-    << fname << std::endl);
-  if ( cmSystemTools::FileExists(fname.c_str()) )
-    {
+  cmCTestLog(this, DEBUG, "* Check for file: " << fname << std::endl);
+  if (cmSystemTools::FileExists(fname.c_str())) {
     cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
-      << fname << std::endl);
+                 << fname << std::endl);
     bool erroroc = cmSystemTools::GetErrorOccuredFlag();
     cmSystemTools::ResetErrorOccuredFlag();
 
-    if ( !mf->ReadListFile(fname.c_str()) ||
-      cmSystemTools::GetErrorOccuredFlag() )
-      {
-      cmCTestLog(this, ERROR_MESSAGE,
-        "Problem reading custom configuration: "
-        << fname << std::endl);
-      }
+    if (!mf->ReadListFile(fname.c_str()) ||
+        cmSystemTools::GetErrorOccuredFlag()) {
+      cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: "
+                   << fname << std::endl);
+    }
     found = true;
-    if ( erroroc )
-      {
+    if (erroroc) {
       cmSystemTools::SetErrorOccured();
-      }
     }
+  }
 
   std::string rexpr = dir;
   rexpr += "/CTestCustom.ctest";
-  cmCTestLog(this, DEBUG, "* Check for file: "
-    << rexpr << std::endl);
-  if ( !found && cmSystemTools::FileExists(rexpr.c_str()) )
-    {
+  cmCTestLog(this, DEBUG, "* Check for file: " << rexpr << std::endl);
+  if (!found && cmSystemTools::FileExists(rexpr.c_str())) {
     cmsys::Glob gl;
     gl.RecurseOn();
     gl.FindFiles(rexpr);
     std::vector<std::string>& files = gl.GetFiles();
     std::vector<std::string>::iterator fileIt;
-    for ( fileIt = files.begin(); fileIt != files.end();
-      ++ fileIt )
-      {
+    for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
       cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
-        << *fileIt << std::endl);
-      if ( !mf->ReadListFile(fileIt->c_str()) ||
-        cmSystemTools::GetErrorOccuredFlag() )
-        {
+                   << *fileIt << std::endl);
+      if (!mf->ReadListFile(fileIt->c_str()) ||
+          cmSystemTools::GetErrorOccuredFlag()) {
         cmCTestLog(this, ERROR_MESSAGE,
-          "Problem reading custom configuration: "
-          << *fileIt << std::endl);
-        }
+                   "Problem reading custom configuration: " << *fileIt
+                                                            << std::endl);
       }
-    found = true;
     }
+    found = true;
+  }
 
-  if ( found )
-    {
+  if (found) {
     cmCTest::t_TestingHandlers::iterator it;
-    for ( it = this->TestingHandlers.begin();
-      it != this->TestingHandlers.end(); ++ it )
-      {
+    for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
+         ++it) {
       cmCTestLog(this, DEBUG,
-        "* Read custom CTest configuration vectors for handler: "
-        << it->first << " (" << it->second << ")" << std::endl);
+                 "* Read custom CTest configuration vectors for handler: "
+                   << it->first << " (" << it->second << ")" << std::endl);
       it->second->PopulateCustomVectors(mf);
-      }
     }
+  }
 
   return 1;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
-  std::vector<std::string>& vec)
+                                   std::vector<std::string>& vec)
 {
   const char* dval = mf->GetDefinition(def);
-  if ( !dval )
-    {
+  if (!dval) {
     return;
-    }
+  }
   cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl);
 
   vec.clear();
   cmSystemTools::ExpandListArgument(dval, vec);
 
   for (std::vector<std::string>::const_iterator it = vec.begin();
-       it != vec.end(); ++it )
-    {
+       it != vec.end(); ++it) {
     cmCTestLog(this, DEBUG, "  -- " << *it << std::endl);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def,
-  int& val)
+                                    int& val)
 {
   const char* dval = mf->GetDefinition(def);
-  if ( !dval )
-    {
+  if (!dval) {
     return;
-    }
+  }
   val = atoi(dval);
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::GetShortPathToFile(const char* cfname)
 {
-  const std::string& sourceDir
-    = cmSystemTools::CollapseFullPath(
-        this->GetCTestConfiguration("SourceDirectory"));
-  const std::string& buildDir
-    = cmSystemTools::CollapseFullPath(
-        this->GetCTestConfiguration("BuildDirectory"));
+  const std::string& sourceDir = cmSystemTools::CollapseFullPath(
+    this->GetCTestConfiguration("SourceDirectory"));
+  const std::string& buildDir = cmSystemTools::CollapseFullPath(
+    this->GetCTestConfiguration("BuildDirectory"));
   std::string fname = cmSystemTools::CollapseFullPath(cfname);
 
   // Find relative paths to both directories
-  std::string srcRelpath
-    = cmSystemTools::RelativePath(sourceDir.c_str(), fname.c_str());
-  std::string bldRelpath
-    = cmSystemTools::RelativePath(buildDir.c_str(), fname.c_str());
+  std::string srcRelpath =
+    cmSystemTools::RelativePath(sourceDir.c_str(), fname.c_str());
+  std::string bldRelpath =
+    cmSystemTools::RelativePath(buildDir.c_str(), fname.c_str());
 
   // If any contains "." it is not parent directory
   bool inSrc = srcRelpath.find("..") == srcRelpath.npos;
@@ -2775,67 +2327,51 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
 
   std::string* res = 0;
 
-  if ( inSrc && inBld )
-    {
+  if (inSrc && inBld) {
     // If both have relative path with no dots, pick the shorter one
-    if ( srcRelpath.size() < bldRelpath.size() )
-      {
+    if (srcRelpath.size() < bldRelpath.size()) {
       res = &srcRelpath;
-      }
-    else
-      {
+    } else {
       res = &bldRelpath;
-      }
     }
-  else if ( inSrc )
-    {
+  } else if (inSrc) {
     res = &srcRelpath;
-    }
-  else if ( inBld )
-    {
+  } else if (inBld) {
     res = &bldRelpath;
-    }
+  }
 
   std::string path;
 
-  if ( !res )
-    {
+  if (!res) {
     path = fname;
-    }
-  else
-    {
+  } else {
     cmSystemTools::ConvertToUnixSlashes(*res);
 
     path = "./" + *res;
-    if ( path[path.size()-1] == '/' )
-      {
-      path = path.substr(0, path.size()-1);
-      }
+    if (path[path.size() - 1] == '/') {
+      path = path.substr(0, path.size() - 1);
     }
+  }
 
   cmsys::SystemTools::ReplaceString(path, ":", "_");
   cmsys::SystemTools::ReplaceString(path, " ", "_");
   return path;
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::GetCTestConfiguration(const std::string& name)
 {
-  if ( this->CTestConfigurationOverwrites.find(name) !=
-    this->CTestConfigurationOverwrites.end() )
-    {
+  if (this->CTestConfigurationOverwrites.find(name) !=
+      this->CTestConfigurationOverwrites.end()) {
     return this->CTestConfigurationOverwrites[name];
-    }
+  }
   return this->CTestConfiguration[name];
 }
 
-//----------------------------------------------------------------------
 void cmCTest::EmptyCTestConfiguration()
 {
   this->CTestConfiguration.clear();
 }
 
-//----------------------------------------------------------------------
 void cmCTest::DetermineNextDayStop()
 {
   struct tm* lctime;
@@ -2847,189 +2383,157 @@ void cmCTest::DetermineNextDayStop()
   int local_hour = lctime->tm_hour;
 
   int tzone_offset = local_hour - gm_hour;
-  if(gm_time > current_time && gm_hour < local_hour)
-    {
+  if (gm_time > current_time && gm_hour < local_hour) {
     // this means gm_time is on the next day
     tzone_offset -= 24;
-    }
-  else if(gm_time < current_time && gm_hour > local_hour)
-    {
+  } else if (gm_time < current_time && gm_hour > local_hour) {
     // this means gm_time is on the previous day
     tzone_offset += 24;
-    }
+  }
 
   tzone_offset *= 100;
   char buf[1024];
-  sprintf(buf, "%d%02d%02d %s %+05i",
-          lctime->tm_year + 1900,
-          lctime->tm_mon + 1,
-          lctime->tm_mday,
-          this->StopTime.c_str(),
+  sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+          lctime->tm_mon + 1, lctime->tm_mday, this->StopTime.c_str(),
           tzone_offset);
 
   time_t stop_time = curl_getdate(buf, &current_time);
 
-  if(stop_time < current_time)
-    {
+  if (stop_time < current_time) {
     this->NextDayStopTime = true;
-    }
+  }
 }
 
-//----------------------------------------------------------------------
-void cmCTest::SetCTestConfiguration(const char *name, const char* value,
+void cmCTest::SetCTestConfiguration(const char* name, const char* value,
                                     bool suppress)
 {
   cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfiguration:"
-    << name << ":" << (value ? value : "(null)") << "\n", suppress);
+                       << name << ":" << (value ? value : "(null)") << "\n",
+                     suppress);
 
-  if ( !name )
-    {
+  if (!name) {
     return;
-    }
-  if ( !value )
-    {
+  }
+  if (!value) {
     this->CTestConfiguration.erase(name);
     return;
-    }
+  }
   this->CTestConfiguration[name] = value;
 }
 
-
-//----------------------------------------------------------------------
 std::string cmCTest::GetCurrentTag()
 {
   return this->CurrentTag;
 }
 
-//----------------------------------------------------------------------
 std::string cmCTest::GetBinaryDir()
 {
   return this->BinaryDir;
 }
 
-//----------------------------------------------------------------------
 std::string const& cmCTest::GetConfigType()
 {
   return this->ConfigType;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::GetShowOnly()
 {
   return this->ShowOnly;
 }
 
-//----------------------------------------------------------------------
 int cmCTest::GetMaxTestNameWidth() const
 {
   return this->MaxTestNameWidth;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::SetProduceXML(bool v)
 {
   this->ProduceXML = v;
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::GetProduceXML()
 {
   return this->ProduceXML;
 }
 
-//----------------------------------------------------------------------
 const char* cmCTest::GetSpecificTrack()
 {
-  if ( this->SpecificTrack.empty() )
-    {
+  if (this->SpecificTrack.empty()) {
     return 0;
-    }
+  }
   return this->SpecificTrack.c_str();
 }
 
-//----------------------------------------------------------------------
 void cmCTest::SetSpecificTrack(const char* track)
 {
-  if ( !track )
-    {
+  if (!track) {
     this->SpecificTrack = "";
     return;
-    }
+  }
   this->SpecificTrack = track;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::AddSubmitFile(Part part, const char* name)
 {
   this->Parts[part].SubmitFiles.push_back(name);
 }
 
-//----------------------------------------------------------------------
 void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
 {
-  size_t epos = overStr.find("=");
-  if ( epos == overStr.npos )
-    {
+  size_t epos = overStr.find('=');
+  if (epos == overStr.npos) {
     cmCTestLog(this, ERROR_MESSAGE,
-      "CTest configuration overwrite specified in the wrong format."
-      << std::endl
-      << "Valid format is: --overwrite key=value" << std::endl
-      << "The specified was: --overwrite " << overStr << std::endl);
+               "CTest configuration overwrite specified in the wrong format."
+                 << std::endl
+                 << "Valid format is: --overwrite key=value" << std::endl
+                 << "The specified was: --overwrite " << overStr << std::endl);
     return;
-    }
+  }
   std::string key = overStr.substr(0, epos);
-  std::string value = overStr.substr(epos+1, overStr.npos);
+  std::string value = overStr.substr(epos + 1, overStr.npos);
   this->CTestConfigurationOverwrites[key] = value;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::SetConfigType(const char* ct)
 {
-  this->ConfigType = ct?ct:"";
+  this->ConfigType = ct ? ct : "";
   cmSystemTools::ReplaceString(this->ConfigType, ".\\", "");
-  std::string confTypeEnv
-    = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
+  std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
   cmSystemTools::PutEnv(confTypeEnv);
 }
 
-//----------------------------------------------------------------------
-bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
-  const char* dconfig, const std::string& cmake_var, bool suppress)
+bool cmCTest::SetCTestConfigurationFromCMakeVariable(
+  cmMakefile* mf, const char* dconfig, const std::string& cmake_var,
+  bool suppress)
 {
   const char* ctvar;
   ctvar = mf->GetDefinition(cmake_var);
-  if ( !ctvar )
-    {
+  if (!ctvar) {
     return false;
-    }
+  }
   cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT,
-    "SetCTestConfigurationFromCMakeVariable:" << dconfig << ":" <<
-    cmake_var << std::endl, suppress);
+                     "SetCTestConfigurationFromCMakeVariable:"
+                       << dconfig << ":" << cmake_var << std::endl,
+                     suppress);
   this->SetCTestConfiguration(dconfig, ctvar, suppress);
   return true;
 }
 
-bool cmCTest::RunCommand(
-  const char* command,
-  std::string* stdOut,
-  std::string* stdErr,
-  int *retVal,
-  const char* dir,
-  double timeout)
+bool cmCTest::RunCommand(const char* command, std::string* stdOut,
+                         std::string* stdErr, int* retVal, const char* dir,
+                         double timeout)
 {
   std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     return false;
-    }
+  }
 
   std::vector<const char*> argv;
-  for(std::vector<std::string>::const_iterator a = args.begin();
-      a != args.end(); ++a)
-    {
+  for (std::vector<std::string>::const_iterator a = args.begin();
+       a != args.end(); ++a) {
     argv.push_back(a->c_str());
-    }
+  }
   argv.push_back(0);
 
   *stdOut = "";
@@ -3038,10 +2542,9 @@ bool cmCTest::RunCommand(
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetCommand(cp, &*argv.begin());
   cmsysProcess_SetWorkingDirectory(cp, dir);
-  if(cmSystemTools::GetRunCommandHideConsole())
-    {
+  if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
-    }
+  }
   cmsysProcess_SetTimeout(cp, timeout);
   cmsysProcess_Execute(cp);
 
@@ -3051,118 +2554,93 @@ bool cmCTest::RunCommand(
   int length;
   int res;
   bool done = false;
-  while(!done)
-    {
+  while (!done) {
     res = cmsysProcess_WaitForData(cp, &data, &length, 0);
-    switch ( res )
-      {
-    case cmsysProcess_Pipe_STDOUT:
-      tempOutput.insert(tempOutput.end(), data, data+length);
-      break;
-    case cmsysProcess_Pipe_STDERR:
-      tempError.insert(tempError.end(), data, data+length);
-      break;
-    default:
-      done = true;
-      }
-    if ( (res == cmsysProcess_Pipe_STDOUT ||
-        res == cmsysProcess_Pipe_STDERR) && this->ExtraVerbose )
-      {
+    switch (res) {
+      case cmsysProcess_Pipe_STDOUT:
+        tempOutput.insert(tempOutput.end(), data, data + length);
+        break;
+      case cmsysProcess_Pipe_STDERR:
+        tempError.insert(tempError.end(), data, data + length);
+        break;
+      default:
+        done = true;
+    }
+    if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) &&
+        this->ExtraVerbose) {
       cmSystemTools::Stdout(data, length);
-      }
     }
+  }
 
   cmsysProcess_WaitForExit(cp, 0);
-  if (!tempOutput.empty())
-    {
+  if (!tempOutput.empty()) {
     stdOut->append(&*tempOutput.begin(), tempOutput.size());
-    }
-  if (!tempError.empty())
-    {
+  }
+  if (!tempError.empty()) {
     stdErr->append(&*tempError.begin(), tempError.size());
-    }
+  }
 
   bool result = true;
-  if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
-    {
-    if ( retVal )
-      {
+  if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
+    if (retVal) {
       *retVal = cmsysProcess_GetExitValue(cp);
-      }
-    else
-      {
-      if ( cmsysProcess_GetExitValue(cp) !=  0 )
-        {
+    } else {
+      if (cmsysProcess_GetExitValue(cp) != 0) {
         result = false;
-        }
       }
     }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
     const char* exception_str = cmsysProcess_GetExceptionString(cp);
     cmCTestLog(this, ERROR_MESSAGE, exception_str << std::endl);
     stdErr->append(exception_str, strlen(exception_str));
     result = false;
-    }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
     const char* error_str = cmsysProcess_GetErrorString(cp);
     cmCTestLog(this, ERROR_MESSAGE, error_str << std::endl);
     stdErr->append(error_str, strlen(error_str));
     result = false;
-    }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
     const char* error_str = "Process terminated due to timeout\n";
     cmCTestLog(this, ERROR_MESSAGE, error_str << std::endl);
     stdErr->append(error_str, strlen(error_str));
     result = false;
-    }
+  }
 
   cmsysProcess_Delete(cp);
   return result;
 }
 
-//----------------------------------------------------------------------
 void cmCTest::SetOutputLogFileName(const char* name)
 {
-  if ( this->OutputLogFile)
-    {
+  if (this->OutputLogFile) {
     delete this->OutputLogFile;
-    this->OutputLogFile= 0;
-    }
-  if ( name )
-    {
+    this->OutputLogFile = 0;
+  }
+  if (name) {
     this->OutputLogFile = new cmGeneratedFileStream(name);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
-static const char* cmCTestStringLogType[] =
-{
-  "DEBUG",
-  "OUTPUT",
-  "HANDLER_OUTPUT",
-  "HANDLER_PROGRESS_OUTPUT",
-  "HANDLER_VERBOSE_OUTPUT",
-  "WARNING",
-  "ERROR_MESSAGE",
-  0
-};
+static const char* cmCTestStringLogType[] = { "DEBUG",
+                                              "OUTPUT",
+                                              "HANDLER_OUTPUT",
+                                              "HANDLER_PROGRESS_OUTPUT",
+                                              "HANDLER_VERBOSE_OUTPUT",
+                                              "WARNING",
+                                              "ERROR_MESSAGE",
+                                              0 };
 
-//----------------------------------------------------------------------
 #ifdef cerr
-#  undef cerr
+#undef cerr
 #endif
 #ifdef cout
-#  undef cout
+#undef cout
 #endif
 
-#define cmCTestLogOutputFileLine(stream) \
-  if ( this->ShowLineNumbers ) \
-    { \
-    (stream) << std::endl << file << ":" << line << " "; \
-    }
+#define cmCTestLogOutputFileLine(stream)                                      \
+  if (this->ShowLineNumbers) {                                                \
+    (stream) << std::endl << file << ":" << line << " ";                      \
+  }
 
 void cmCTest::InitStreams()
 {
@@ -3174,145 +2652,129 @@ void cmCTest::InitStreams()
 void cmCTest::Log(int logType, const char* file, int line, const char* msg,
                   bool suppress)
 {
-  if ( !msg || !*msg )
-    {
+  if (!msg || !*msg) {
     return;
-    }
-  if ( suppress && logType != cmCTest::ERROR_MESSAGE )
-    {
+  }
+  if (suppress && logType != cmCTest::ERROR_MESSAGE) {
     return;
-    }
-  if ( logType == cmCTest::HANDLER_PROGRESS_OUTPUT &&
-      ( this->Debug || this->ExtraVerbose ) )
-    {
+  }
+  if (logType == cmCTest::HANDLER_PROGRESS_OUTPUT &&
+      (this->Debug || this->ExtraVerbose)) {
     return;
-    }
-  if ( this->OutputLogFile )
-    {
+  }
+  if (this->OutputLogFile) {
     bool display = true;
-    if ( logType == cmCTest::DEBUG && !this->Debug ) { display = false; }
-    if ( logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Debug &&
-      !this->ExtraVerbose ) { display = false; }
-    if ( display )
-      {
+    if (logType == cmCTest::DEBUG && !this->Debug) {
+      display = false;
+    }
+    if (logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Debug &&
+        !this->ExtraVerbose) {
+      display = false;
+    }
+    if (display) {
       cmCTestLogOutputFileLine(*this->OutputLogFile);
-      if ( logType != this->OutputLogFileLastTag )
-        {
+      if (logType != this->OutputLogFileLastTag) {
         *this->OutputLogFile << "[";
-        if ( logType >= OTHER || logType < 0 )
-          {
+        if (logType >= OTHER || logType < 0) {
           *this->OutputLogFile << "OTHER";
-          }
-        else
-          {
+        } else {
           *this->OutputLogFile << cmCTestStringLogType[logType];
-          }
-        *this->OutputLogFile << "] " << std::endl << std::flush;
         }
+        *this->OutputLogFile << "] " << std::endl << std::flush;
+      }
       *this->OutputLogFile << msg << std::flush;
-      if ( logType != this->OutputLogFileLastTag )
-        {
+      if (logType != this->OutputLogFileLastTag) {
         *this->OutputLogFile << std::endl << std::flush;
         this->OutputLogFileLastTag = logType;
-        }
       }
     }
-  if ( !this->Quiet )
-    {
+  }
+  if (!this->Quiet) {
     std::ostream& out = *this->StreamOut;
     std::ostream& err = *this->StreamErr;
-    switch ( logType )
-      {
-    case DEBUG:
-      if ( this->Debug )
-        {
-        cmCTestLogOutputFileLine(out);
-        out << msg;
-        out.flush();
+    switch (logType) {
+      case DEBUG:
+        if (this->Debug) {
+          cmCTestLogOutputFileLine(out);
+          out << msg;
+          out.flush();
         }
-      break;
-    case OUTPUT: case HANDLER_OUTPUT:
-      if ( this->Debug || this->Verbose )
-        {
-        cmCTestLogOutputFileLine(out);
-        out << msg;
-        out.flush();
+        break;
+      case OUTPUT:
+      case HANDLER_OUTPUT:
+        if (this->Debug || this->Verbose) {
+          cmCTestLogOutputFileLine(out);
+          out << msg;
+          out.flush();
         }
-      break;
-    case HANDLER_VERBOSE_OUTPUT:
-      if ( this->Debug || this->ExtraVerbose )
-        {
+        break;
+      case HANDLER_VERBOSE_OUTPUT:
+        if (this->Debug || this->ExtraVerbose) {
+          cmCTestLogOutputFileLine(out);
+          out << msg;
+          out.flush();
+        }
+        break;
+      case WARNING:
+        cmCTestLogOutputFileLine(err);
+        err << msg;
+        err.flush();
+        break;
+      case ERROR_MESSAGE:
+        cmCTestLogOutputFileLine(err);
+        err << msg;
+        err.flush();
+        cmSystemTools::SetErrorOccured();
+        break;
+      default:
         cmCTestLogOutputFileLine(out);
         out << msg;
         out.flush();
-        }
-      break;
-    case WARNING:
-      cmCTestLogOutputFileLine(err);
-      err << msg;
-      err.flush();
-      break;
-    case ERROR_MESSAGE:
-      cmCTestLogOutputFileLine(err);
-      err << msg;
-      err.flush();
-      cmSystemTools::SetErrorOccured();
-      break;
-    default:
-      cmCTestLogOutputFileLine(out);
-      out << msg;
-      out.flush();
-      }
     }
+  }
 }
 
-//-------------------------------------------------------------------------
 double cmCTest::GetRemainingTimeAllowed()
 {
-  if (!this->GetHandler("script"))
-    {
+  if (!this->GetHandler("script")) {
     return 1.0e7;
-    }
+  }
 
-  cmCTestScriptHandler* ch
-    = static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+  cmCTestScriptHandler* ch =
+    static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
 
   return ch->GetRemainingTimeAllowed();
 }
 
-//----------------------------------------------------------------------
-void cmCTest::OutputTestErrors(std::vector<char> const &process_output)
+void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
 {
   std::string test_outputs("\n*** Test Failed:\n");
-  if(!process_output.empty())
-    {
+  if (!process_output.empty()) {
     test_outputs.append(&*process_output.begin(), process_output.size());
-    }
+  }
   cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
 }
 
-//----------------------------------------------------------------------
 bool cmCTest::CompressString(std::string& str)
 {
   int ret;
   z_stream strm;
 
-  unsigned char* in = reinterpret_cast<unsigned char*>(
-    const_cast<char*>(str.c_str()));
-  //zlib makes the guarantee that this is the maximum output size
-  int outSize = static_cast<int>(
-    static_cast<double>(str.size()) * 1.001 + 13.0);
+  unsigned char* in =
+    reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str()));
+  // zlib makes the guarantee that this is the maximum output size
+  int outSize =
+    static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
   unsigned char* out = new unsigned char[outSize];
 
   strm.zalloc = Z_NULL;
   strm.zfree = Z_NULL;
   strm.opaque = Z_NULL;
-  ret = deflateInit(&strm, -1); //default compression level
-  if (ret != Z_OK)
-    {
+  ret = deflateInit(&strm, -1); // default compression level
+  if (ret != Z_OK) {
     delete[] out;
     return false;
-    }
+  }
 
   strm.avail_in = static_cast<uInt>(str.size());
   strm.next_in = in;
@@ -3320,28 +2782,26 @@ bool cmCTest::CompressString(std::string& str)
   strm.next_out = out;
   ret = deflate(&strm, Z_FINISH);
 
-  if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END)
-    {
+  if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) {
     cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression."
-      << std::endl);
+                 << std::endl);
     delete[] out;
     return false;
-    }
+  }
 
   (void)deflateEnd(&strm);
 
   // Now base64 encode the resulting binary string
-  unsigned char* base64EncodedBuffer
-    = new unsigned char[(outSize * 3) / 2];
+  unsigned char* base64EncodedBuffer = new unsigned char[(outSize * 3) / 2];
 
-  size_t rlen
-    = cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
+  size_t rlen =
+    cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
 
   str = "";
   str.append(reinterpret_cast<char*>(base64EncodedBuffer), rlen);
 
-  delete [] base64EncodedBuffer;
-  delete [] out;
+  delete[] base64EncodedBuffer;
+  delete[] out;
 
   return true;
 }
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 73c2807..65ecaa4 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -14,6 +14,7 @@
 #define cmCTest_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmListFileCache.h"
 #include <time.h>
 
@@ -26,29 +27,29 @@ class cmCTestScriptHandler;
 class cmCTestStartCommand;
 class cmXMLWriter;
 
-#define cmCTestLog(ctSelf, logType, msg) \
-  do { \
-  std::ostringstream cmCTestLog_msg; \
-  cmCTestLog_msg << msg; \
-  (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,\
-                cmCTestLog_msg.str().c_str());\
-  } while ( 0 )
-
-#define cmCTestOptionalLog(ctSelf, logType, msg, suppress) \
-  do { \
-  std::ostringstream cmCTestLog_msg; \
-  cmCTestLog_msg << msg; \
-  (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,\
-                cmCTestLog_msg.str().c_str(), suppress);\
-  } while ( 0 )
+#define cmCTestLog(ctSelf, logType, msg)                                      \
+  do {                                                                        \
+    std::ostringstream cmCTestLog_msg;                                        \
+    cmCTestLog_msg << msg;                                                    \
+    (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,                       \
+                  cmCTestLog_msg.str().c_str());                              \
+  } while (0)
+
+#define cmCTestOptionalLog(ctSelf, logType, msg, suppress)                    \
+  do {                                                                        \
+    std::ostringstream cmCTestLog_msg;                                        \
+    cmCTestLog_msg << msg;                                                    \
+    (ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,                       \
+                  cmCTestLog_msg.str().c_str(), suppress);                    \
+  } while (0)
 
 #ifdef cerr
-#  undef cerr
+#undef cerr
 #endif
 #define cerr no_cerr_use_cmCTestLog
 
 #ifdef cout
-#  undef cout
+#undef cout
 #endif
 #define cout no_cout_use_cmCTestLog
 
@@ -56,6 +57,7 @@ class cmCTest
 {
   friend class cmCTestRunTest;
   friend class cmCTestMultiProcessHandler;
+
 public:
   /** Enumerate parts of the testing and submission process.  */
   enum Part
@@ -77,7 +79,10 @@ public:
   /** Representation of one part.  */
   struct PartInfo
   {
-    PartInfo(): Enabled(false) {}
+    PartInfo()
+      : Enabled(false)
+    {
+    }
 
     void SetName(const std::string& name) { this->Name = name; }
     const std::string& GetName() const { return this->Name; }
@@ -86,12 +91,14 @@ public:
     operator bool() const { return this->Enabled; }
 
     std::vector<std::string> SubmitFiles;
+
   private:
     bool Enabled;
     std::string Name;
   };
 #ifdef CMAKE_BUILD_WITH_CMAKE
-  enum HTTPMethod {
+  enum HTTPMethod
+  {
     HTTP_GET,
     HTTP_POST,
     HTTP_PUT
@@ -101,9 +108,8 @@ public:
    * Perform an HTTP request.
    */
   static int HTTPRequest(std::string url, HTTPMethod method,
-                          std::string& response,
-                          std::string fields = "",
-                          std::string putFile = "", int timeout = 0);
+                         std::string& response, std::string const& fields = "",
+                         std::string const& putFile = "", int timeout = 0);
 #endif
 
   /** Get a testing part id from its string name.  Returns PartCount
@@ -114,7 +120,7 @@ public:
   typedef std::set<std::string> SetOfStrings;
 
   ///! Process Command line arguments
-  int Run(std::vector<std::string> &, std::string* output = 0);
+  int Run(std::vector<std::string>&, std::string* output = 0);
 
   /**
    * Initialize and finalize testing
@@ -137,8 +143,7 @@ public:
   /*
    * A utility function that returns the nightly time
    */
-  struct tm* GetNightlyTime(std::string str,
-    bool tomorrowtag);
+  struct tm* GetNightlyTime(std::string const& str, bool tomorrowtag);
 
   /*
    * Is the tomorrow tag set?
@@ -185,8 +190,8 @@ public:
   static int GetTestModelFromString(const char* str);
   static std::string CleanString(const std::string& str);
   std::string GetCTestConfiguration(const std::string& name);
-  void SetCTestConfiguration(const char *name, const char* value,
-    bool suppress=false);
+  void SetCTestConfiguration(const char* name, const char* value,
+                             bool suppress = false);
   void EmptyCTestConfiguration();
 
   /**
@@ -199,17 +204,16 @@ public:
   void SetNotesFiles(const char* notes);
 
   void PopulateCustomVector(cmMakefile* mf, const std::string& definition,
-    std::vector<std::string>& vec);
-  void PopulateCustomInteger(cmMakefile* mf, const std::string& def,
-    int& val);
+                            std::vector<std::string>& vec);
+  void PopulateCustomInteger(cmMakefile* mf, const std::string& def, int& val);
 
   ///! Get the current time as string
   std::string CurrentTime();
 
   //! tar/gzip and then base 64 encode a file
-  std::string Base64GzipEncodeFile(std::string file);
+  std::string Base64GzipEncodeFile(std::string const& file);
   //! base64 encode a file
-  std::string Base64EncodeFile(std::string file);
+  std::string Base64EncodeFile(std::string const& file);
 
   /**
    * Return the time remaining that the script is allowed to run in
@@ -219,10 +223,8 @@ public:
   double GetRemainingTimeAllowed();
 
   ///! Open file in the output directory and set the stream
-  bool OpenOutputFile(const std::string& path,
-                      const std::string& name,
-                      cmGeneratedFileStream& stream,
-                      bool compress = false);
+  bool OpenOutputFile(const std::string& path, const std::string& name,
+                      cmGeneratedFileStream& stream, bool compress = false);
 
   ///! Should we only show what we would do?
   bool GetShowOnly();
@@ -238,15 +240,15 @@ public:
   std::string GetCDashVersion();
 
   std::string GetStopTime() { return this->StopTime; }
-  void SetStopTime(std::string time);
+  void SetStopTime(std::string const& time);
 
-  //Used for parallel ctest job scheduling
+  // Used for parallel ctest job scheduling
   std::string GetScheduleType() { return this->ScheduleType; }
   void SetScheduleType(std::string type) { this->ScheduleType = type; }
 
   ///! The max output width
   int GetMaxTestNameWidth() const;
-  void SetMaxTestNameWidth(int w) { this->MaxTestNameWidth = w;}
+  void SetMaxTestNameWidth(int w) { this->MaxTestNameWidth = w; }
 
   /**
    * Run a single executable command and put the stdout and stderr
@@ -268,9 +270,9 @@ public:
    * it into this function or it will not work.  The command must be correctly
    * escaped for this to with spaces.
    */
-  bool RunCommand(const char* command,
-    std::string* stdOut, std::string* stdErr,
-    int* retVal = 0, const char* dir = 0, double timeout = 0.0);
+  bool RunCommand(const char* command, std::string* stdOut,
+                  std::string* stdErr, int* retVal = 0, const char* dir = 0,
+                  double timeout = 0.0);
 
   //! Clean/make safe for xml the given value such that it may be used as
   // one of the key fields by CDash when computing the buildid.
@@ -284,9 +286,8 @@ public:
 
   //! Run command specialized for make and configure. Returns process status
   // and retVal is return value or exception.
-  int RunMakeCommand(const char* command, std::string& output,
-    int* retVal, const char* dir, int timeout,
-    std::ostream& ofs);
+  int RunMakeCommand(const char* command, std::string& output, int* retVal,
+                     const char* dir, int timeout, std::ostream& ofs);
 
   /*
    * return the current tag
@@ -297,24 +298,26 @@ public:
   std::string GetBinaryDir();
 
   //! Get the short path to the file. This means if the file is in binary or
-  //source directory, it will become /.../relative/path/to/file
+  // source directory, it will become /.../relative/path/to/file
   std::string GetShortPathToFile(const char* fname);
 
-  enum {
+  enum
+  {
     EXPERIMENTAL,
     NIGHTLY,
     CONTINUOUS
   };
 
   // provide some more detailed info on the return code for ctest
-  enum {
-    UPDATE_ERRORS    = 0x01,
+  enum
+  {
+    UPDATE_ERRORS = 0x01,
     CONFIGURE_ERRORS = 0x02,
-    BUILD_ERRORS     = 0x04,
-    TEST_ERRORS      = 0x08,
-    MEMORY_ERRORS    = 0x10,
-    COVERAGE_ERRORS  = 0x20,
-    SUBMIT_ERRORS    = 0x40
+    BUILD_ERRORS = 0x04,
+    TEST_ERRORS = 0x08,
+    MEMORY_ERRORS = 0x10,
+    COVERAGE_ERRORS = 0x20,
+    SUBMIT_ERRORS = 0x40
   };
 
   ///! Are we producing XML
@@ -325,9 +328,9 @@ public:
   // return value or exception. If environment is non-null, it is used to set
   // environment variables prior to running the test. After running the test,
   // environment variables are restored to their previous values.
-  int RunTest(std::vector<const char*> args, std::string* output, int *retVal,
-    std::ostream* logfile, double testTimeOut,
-    std::vector<std::string>* environment);
+  int RunTest(std::vector<const char*> args, std::string* output, int* retVal,
+              std::ostream* logfile, double testTimeOut,
+              std::vector<std::string>* environment);
 
   /**
    * Execute handler and return its result. If the handler fails, it returns
@@ -345,7 +348,9 @@ public:
    * Set the CTest variable from CMake variable
    */
   bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
-    const char* dconfig, const std::string& cmake_var, bool suppress=false);
+                                              const char* dconfig,
+                                              const std::string& cmake_var,
+                                              bool suppress = false);
 
   //! Make string safe to be send as an URL
   static std::string MakeURLSafe(const std::string&);
@@ -356,20 +361,20 @@ public:
   //! Should ctect configuration be updated. When using new style ctest
   // script, this should be true.
   void SetSuppressUpdatingCTestConfiguration(bool val)
-    {
+  {
     this->SuppressUpdatingCTestConfiguration = val;
-    }
+  }
 
   //! Add overwrite to ctest configuration.
   // The format is key=value
   void AddCTestConfigurationOverwrite(const std::string& encstr);
 
   //! Create XML file that contains all the notes specified
-  int GenerateNotesFile(const VectorOfStrings &files);
+  int GenerateNotesFile(const VectorOfStrings& files);
 
   //! Submit extra files to the server
   bool SubmitExtraFiles(const char* files);
-  bool SubmitExtraFiles(const VectorOfStrings &files);
+  bool SubmitExtraFiles(const VectorOfStrings& files);
 
   //! Set the output log file name
   void SetOutputLogFileName(const char* name);
@@ -378,7 +383,8 @@ public:
   void SetConfigType(const char* ct);
 
   //! Various log types
-  enum {
+  enum
+  {
     DEBUG = 0,
     OUTPUT,
     HANDLER_OUTPUT,
@@ -391,7 +397,7 @@ public:
 
   //! Add log to the output
   void Log(int logType, const char* file, int line, const char* msg,
-           bool suppress=false);
+           bool suppress = false);
 
   //! Get the version of dart server
   int GetDartVersion() { return this->DartVersion; }
@@ -400,14 +406,18 @@ public:
   //! Add file to be submitted
   void AddSubmitFile(Part part, const char* name);
   std::vector<std::string> const& GetSubmitFiles(Part part)
-    { return this->Parts[part].SubmitFiles; }
+  {
+    return this->Parts[part].SubmitFiles;
+  }
   void ClearSubmitFiles(Part part) { this->Parts[part].SubmitFiles.clear(); }
 
   //! Read the custom configuration files and apply them to the current ctest
   int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf);
 
-  std::vector<std::string> &GetInitialCommandLineArguments()
-  { return this->InitialCommandLineArguments; }
+  std::vector<std::string>& GetInitialCommandLineArguments()
+  {
+    return this->InitialCommandLineArguments;
+  }
 
   //! Set the track to submit to
   void SetSpecificTrack(const char* track);
@@ -419,25 +429,28 @@ public:
   void SetBatchJobs(bool batch = true) { this->BatchJobs = batch; }
   bool GetBatchJobs() { return this->BatchJobs; }
 
-  bool GetVerbose() { return this->Verbose;}
-  bool GetExtraVerbose() { return this->ExtraVerbose;}
+  bool GetVerbose() { return this->Verbose; }
+  bool GetExtraVerbose() { return this->ExtraVerbose; }
 
   /** Direct process output to given streams.  */
   void SetStreams(std::ostream* out, std::ostream* err)
-    { this->StreamOut = out; this->StreamErr = err; }
+  {
+    this->StreamOut = out;
+    this->StreamErr = err;
+  }
   void AddSiteProperties(cmXMLWriter& xml);
-  bool GetLabelSummary() { return this->LabelSummary;}
+  bool GetLabelSummary() { return this->LabelSummary; }
 
   std::string GetCostDataFile();
 
-  const std::map<std::string, std::string> &GetDefinitions()
-    {
+  const std::map<std::string, std::string>& GetDefinitions()
+  {
     return this->Definitions;
-    }
+  }
   // return the number of times a test should be run
-  int GetTestRepeat() { return this->RepeatTests;}
+  int GetTestRepeat() { return this->RepeatTests; }
   // return true if test should run until fail
-  bool GetRepeatUntilFail() { return this->RepeatUntilFail;}
+  bool GetRepeatUntilFail() { return this->RepeatUntilFail; }
 private:
   int RepeatTests;
   bool RepeatUntilFail;
@@ -458,7 +471,7 @@ private:
 
   bool RunConfigurationScript;
 
-  //flag for lazy getter (optimization)
+  // flag for lazy getter (optimization)
   bool ComputedCompressTestOutput;
   bool ComputedCompressMemCheckOutput;
 
@@ -467,7 +480,7 @@ private:
   void DetermineNextDayStop();
 
   // these are helper classes
-  typedef std::map<std::string,cmCTestGenericHandler*> t_TestingHandlers;
+  typedef std::map<std::string, cmCTestGenericHandler*> t_TestingHandlers;
   t_TestingHandlers TestingHandlers;
 
   bool ShowOnly;
@@ -475,51 +488,50 @@ private:
   //! Map of configuration properties
   typedef std::map<std::string, std::string> CTestConfigurationMap;
 
-  std::string             CTestConfigFile;
+  std::string CTestConfigFile;
   // TODO: The ctest configuration should be a hierarchy of
   // configuration option sources: command-line, script, ini file.
   // Then the ini file can get re-loaded whenever it changes without
   // affecting any higher-precedence settings.
   CTestConfigurationMap CTestConfiguration;
   CTestConfigurationMap CTestConfigurationOverwrites;
-  PartInfo                Parts[PartCount];
+  PartInfo Parts[PartCount];
   typedef std::map<std::string, Part> PartMapType;
-  PartMapType             PartMap;
+  PartMapType PartMap;
 
-  std::string             CurrentTag;
-  bool                    TomorrowTag;
+  std::string CurrentTag;
+  bool TomorrowTag;
 
-  int                     TestModel;
-  std::string             SpecificTrack;
+  int TestModel;
+  std::string SpecificTrack;
 
-  double                  TimeOut;
+  double TimeOut;
 
-  double                  GlobalTimeout;
+  double GlobalTimeout;
 
-  int                     LastStopTimeout;
+  int LastStopTimeout;
 
-  int                     MaxTestNameWidth;
+  int MaxTestNameWidth;
 
-  int                     ParallelLevel;
-  bool                    ParallelLevelSetInCli;
+  int ParallelLevel;
+  bool ParallelLevelSetInCli;
 
-  unsigned long           TestLoad;
+  unsigned long TestLoad;
 
-  int                     CompatibilityMode;
+  int CompatibilityMode;
 
   // information for the --build-and-test options
-  std::string              BinaryDir;
-
-  std::string              NotesFiles;
+  std::string BinaryDir;
 
+  std::string NotesFiles;
 
-  bool                     InteractiveDebugMode;
+  bool InteractiveDebugMode;
 
-  bool                     ShortDateFormat;
+  bool ShortDateFormat;
 
-  bool                     CompressXMLFiles;
-  bool                     CompressTestOutput;
-  bool                     CompressMemCheckOutput;
+  bool CompressXMLFiles;
+  bool CompressTestOutput;
+  bool CompressMemCheckOutput;
 
   void InitStreams();
   std::ostream* StreamOut;
@@ -538,45 +550,42 @@ private:
   int Initialize(const char* binary_dir, cmCTestStartCommand* command);
 
   //! parse the option after -D and convert it into the appropriate steps
-  bool AddTestsForDashboardType(std::string &targ);
+  bool AddTestsForDashboardType(std::string& targ);
 
   //! read as "emit an error message for an unknown -D value"
-  void ErrorMessageUnknownDashDValue(std::string &val);
+  void ErrorMessageUnknownDashDValue(std::string& val);
 
   //! add a variable definition from a command line -D value
-  bool AddVariableDefinition(const std::string &arg);
+  bool AddVariableDefinition(const std::string& arg);
 
   //! parse and process most common command line arguments
-  bool HandleCommandLineArguments(size_t &i,
-                                  std::vector<std::string> &args,
+  bool HandleCommandLineArguments(size_t& i, std::vector<std::string>& args,
                                   std::string& errormsg);
 
   //! hande the -S -SP and -SR arguments
-  void HandleScriptArguments(size_t &i,
-                             std::vector<std::string> &args,
-                             bool &SRArgumentSpecified);
+  void HandleScriptArguments(size_t& i, std::vector<std::string>& args,
+                             bool& SRArgumentSpecified);
 
   //! Reread the configuration file
   bool UpdateCTestConfiguration();
 
   //! Create note from files.
-  int GenerateCTestNotesOutput(cmXMLWriter& xml,
-    const VectorOfStrings& files);
+  int GenerateCTestNotesOutput(cmXMLWriter& xml, const VectorOfStrings& files);
 
   //! Check if the argument is the one specified
   bool CheckArgument(const std::string& arg, const char* varg1,
-    const char* varg2 = 0);
+                     const char* varg2 = 0);
 
   //! Output errors from a test
-  void OutputTestErrors(std::vector<char> const &process_output);
+  void OutputTestErrors(std::vector<char> const& process_output);
 
-  bool                      SuppressUpdatingCTestConfiguration;
+  bool SuppressUpdatingCTestConfiguration;
 
   bool Debug;
   bool ShowLineNumbers;
   bool Quiet;
 
-  int  DartVersion;
+  int DartVersion;
   bool DropSiteCDash;
 
   std::vector<std::string> InitialCommandLineArguments;
@@ -595,18 +604,20 @@ class cmCTestLogWrite
 {
 public:
   cmCTestLogWrite(const char* data, size_t length)
-    : Data(data), Length(length) {}
+    : Data(data)
+    , Length(length)
+  {
+  }
 
   const char* Data;
   size_t Length;
 };
 
-inline std::ostream& operator<< (std::ostream& os, const cmCTestLogWrite& c)
+inline std::ostream& operator<<(std::ostream& os, const cmCTestLogWrite& c)
 {
-  if (!c.Length)
-    {
+  if (!c.Length) {
     return os;
-    }
+  }
   os.write(c.Data, c.Length);
   os.flush();
   return os;
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 7466c29..d143193 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -9,16 +9,16 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-
 #include "cmCacheManager.h"
-#include "cmSystemTools.h"
+
 #include "cmGeneratedFileStream.h"
-#include "cmake.h"
+#include "cmSystemTools.h"
 #include "cmVersion.h"
+#include "cmake.h"
 
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
 
 cmCacheManager::cmCacheManager()
@@ -38,226 +38,183 @@ void cmCacheManager::CleanCMakeFiles(const std::string& path)
   std::for_each(files.begin(), files.end(), cmSystemTools::RemoveFile);
 }
 
-bool cmCacheManager::LoadCache(const std::string& path,
-                               bool internal,
+bool cmCacheManager::LoadCache(const std::string& path, bool internal,
                                std::set<std::string>& excludes,
                                std::set<std::string>& includes)
 {
   std::string cacheFile = path;
   cacheFile += "/CMakeCache.txt";
   // clear the old cache, if we are reading in internal values
-  if ( internal )
-    {
+  if (internal) {
     this->Cache.clear();
-    }
-  if(!cmSystemTools::FileExists(cacheFile.c_str()))
-    {
+  }
+  if (!cmSystemTools::FileExists(cacheFile.c_str())) {
     this->CleanCMakeFiles(path);
     return false;
-    }
+  }
 
   cmsys::ifstream fin(cacheFile.c_str());
-  if(!fin)
-    {
+  if (!fin) {
     return false;
-    }
-  const char *realbuffer;
+  }
+  const char* realbuffer;
   std::string buffer;
   std::string entryKey;
   unsigned int lineno = 0;
-  while(fin)
-    {
+  while (fin) {
     // Format is key:type=value
     std::string helpString;
     CacheEntry e;
     cmSystemTools::GetLineFromStream(fin, buffer);
     lineno++;
     realbuffer = buffer.c_str();
-    while(*realbuffer != '0' &&
-          (*realbuffer == ' ' ||
-           *realbuffer == '\t' ||
-           *realbuffer == '\r' ||
-           *realbuffer == '\n'))
-      {
-      if (*realbuffer == '\n') lineno++;
+    while (*realbuffer != '0' &&
+           (*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' ||
+            *realbuffer == '\n')) {
+      if (*realbuffer == '\n')
+        lineno++;
       realbuffer++;
-      }
+    }
     // skip blank lines and comment lines
-    if(realbuffer[0] == '#' || realbuffer[0] == 0)
-      {
+    if (realbuffer[0] == '#' || realbuffer[0] == 0) {
       continue;
-      }
-    while(realbuffer[0] == '/' && realbuffer[1] == '/')
-      {
-      if ((realbuffer[2] == '\\') && (realbuffer[3]=='n'))
-        {
+    }
+    while (realbuffer[0] == '/' && realbuffer[1] == '/') {
+      if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) {
         helpString += "\n";
         helpString += &realbuffer[4];
-        }
-      else
-        {
+      } else {
         helpString += &realbuffer[2];
-        }
+      }
       cmSystemTools::GetLineFromStream(fin, buffer);
       lineno++;
       realbuffer = buffer.c_str();
-      if(!fin)
-        {
+      if (!fin) {
         continue;
-        }
       }
+    }
     e.SetProperty("HELPSTRING", helpString.c_str());
-    if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type))
-      {
-      if ( excludes.find(entryKey) == excludes.end() )
-        {
+    if (cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) {
+      if (excludes.find(entryKey) == excludes.end()) {
         // Load internal values if internal is set.
         // If the entry is not internal to the cache being loaded
         // or if it is in the list of internal entries to be
         // imported, load it.
-        if ( internal || (e.Type != cmState::INTERNAL) ||
-             (includes.find(entryKey) != includes.end()) )
-          {
+        if (internal || (e.Type != cmState::INTERNAL) ||
+            (includes.find(entryKey) != includes.end())) {
           // If we are loading the cache from another project,
           // make all loaded entries internal so that it is
           // not visible in the gui
-          if (!internal)
-            {
+          if (!internal) {
             e.Type = cmState::INTERNAL;
             helpString = "DO NOT EDIT, ";
             helpString += entryKey;
             helpString += " loaded from external file.  "
-              "To change this value edit this file: ";
+                          "To change this value edit this file: ";
             helpString += path;
-            helpString += "/CMakeCache.txt"   ;
+            helpString += "/CMakeCache.txt";
             e.SetProperty("HELPSTRING", helpString.c_str());
-            }
-          if(!this->ReadPropertyEntry(entryKey, e))
-            {
+          }
+          if (!this->ReadPropertyEntry(entryKey, e)) {
             e.Initialized = true;
             this->Cache[entryKey] = e;
-            }
           }
         }
       }
-    else
-      {
+    } else {
       std::ostringstream error;
       error << "Parse error in cache file " << cacheFile;
       error << " on line " << lineno << ". Offending entry: " << realbuffer;
       cmSystemTools::Error(error.str().c_str());
-      }
     }
+  }
   this->CacheMajorVersion = 0;
   this->CacheMinorVersion = 0;
-  if(const char* cmajor =
-                  this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION"))
-    {
-    unsigned int v=0;
-    if(sscanf(cmajor, "%u", &v) == 1)
-      {
+  if (const char* cmajor =
+        this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
+    unsigned int v = 0;
+    if (sscanf(cmajor, "%u", &v) == 1) {
       this->CacheMajorVersion = v;
-      }
-    if(const char* cminor =
-                  this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION"))
-      {
-      if(sscanf(cminor, "%u", &v) == 1)
-        {
+    }
+    if (const char* cminor =
+          this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
+      if (sscanf(cminor, "%u", &v) == 1) {
         this->CacheMinorVersion = v;
-        }
       }
     }
-  else
-    {
+  } else {
     // CMake version not found in the list file.
     // Set as version 0.0
     this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", "0",
                         "Minor version of cmake used to create the "
-                        "current loaded cache", cmState::INTERNAL);
+                        "current loaded cache",
+                        cmState::INTERNAL);
     this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0",
                         "Major version of cmake used to create the "
-                        "current loaded cache", cmState::INTERNAL);
-
-    }
+                        "current loaded cache",
+                        cmState::INTERNAL);
+  }
   // check to make sure the cache directory has not
   // been moved
   const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
-  if (internal && oldDir)
-    {
+  if (internal && oldDir) {
     std::string currentcwd = path;
     std::string oldcwd = oldDir;
     cmSystemTools::ConvertToUnixSlashes(currentcwd);
     currentcwd += "/CMakeCache.txt";
     oldcwd += "/CMakeCache.txt";
-    if(!cmSystemTools::SameFile(oldcwd, currentcwd))
-      {
+    if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
       std::string message =
-        std::string("The current CMakeCache.txt directory ") +
-        currentcwd + std::string(" is different than the directory ") +
+        std::string("The current CMakeCache.txt directory ") + currentcwd +
+        std::string(" is different than the directory ") +
         std::string(this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) +
         std::string(" where CMakeCache.txt was created. This may result "
                     "in binaries being created in the wrong place. If you "
                     "are not sure, reedit the CMakeCache.txt");
       cmSystemTools::Error(message.c_str());
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-const char* cmCacheManager::PersistentProperties[] =
-{
-  "ADVANCED",
-  "MODIFIED",
-  "STRINGS",
-  0
-};
+const char* cmCacheManager::PersistentProperties[] = { "ADVANCED", "MODIFIED",
+                                                       "STRINGS", 0 };
 
-//----------------------------------------------------------------------------
 bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey,
                                        CacheEntry& e)
 {
   // All property entries are internal.
-  if(e.Type != cmState::INTERNAL)
-    {
+  if (e.Type != cmState::INTERNAL) {
     return false;
-    }
+  }
 
   const char* end = entryKey.c_str() + entryKey.size();
-  for(const char** p = this->PersistentProperties; *p; ++p)
-    {
+  for (const char** p = this->PersistentProperties; *p; ++p) {
     std::string::size_type plen = strlen(*p) + 1;
-    if(entryKey.size() > plen && *(end-plen) == '-' &&
-       strcmp(end-plen+1, *p) == 0)
-      {
+    if (entryKey.size() > plen && *(end - plen) == '-' &&
+        strcmp(end - plen + 1, *p) == 0) {
       std::string key = entryKey.substr(0, entryKey.size() - plen);
       cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
-      if(it.IsAtEnd())
-        {
+      if (it.IsAtEnd()) {
         // Create an entry and store the property.
         CacheEntry& ne = this->Cache[key];
         ne.Type = cmState::UNINITIALIZED;
         ne.SetProperty(*p, e.Value.c_str());
-        }
-      else
-        {
+      } else {
         // Store this property on its entry.
         it.SetProperty(*p, e.Value.c_str());
-        }
-      return true;
       }
+      return true;
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmCacheManager::WritePropertyEntries(std::ostream& os,
                                           CacheIterator const& i)
 {
-  for(const char** p = this->PersistentProperties; *p; ++p)
-    {
-    if(const char* value = i.GetProperty(*p))
-      {
+  for (const char** p = this->PersistentProperties; *p; ++p) {
+    if (const char* value = i.GetProperty(*p)) {
       std::string helpstring = *p;
       helpstring += " property for variable: ";
       helpstring += i.GetName();
@@ -270,8 +227,8 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os,
       os << ":INTERNAL=";
       this->OutputValue(os, value);
       os << "\n";
-      }
     }
+  }
 }
 
 bool cmCacheManager::SaveCache(const std::string& path)
@@ -280,49 +237,53 @@ bool cmCacheManager::SaveCache(const std::string& path)
   cacheFile += "/CMakeCache.txt";
   cmGeneratedFileStream fout(cacheFile.c_str());
   fout.SetCopyIfDifferent(true);
-  if(!fout)
-    {
+  if (!fout) {
     cmSystemTools::Error("Unable to open cache file for save. ",
                          cacheFile.c_str());
     cmSystemTools::ReportLastSystemError("");
     return false;
-    }
+  }
   // before writing the cache, update the version numbers
   // to the
   char temp[1024];
   sprintf(temp, "%d", cmVersion::GetMinorVersion());
   this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp,
                       "Minor version of cmake used to create the "
-                      "current loaded cache", cmState::INTERNAL);
+                      "current loaded cache",
+                      cmState::INTERNAL);
   sprintf(temp, "%d", cmVersion::GetMajorVersion());
   this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
                       "Major version of cmake used to create the "
-                      "current loaded cache", cmState::INTERNAL);
+                      "current loaded cache",
+                      cmState::INTERNAL);
   sprintf(temp, "%d", cmVersion::GetPatchVersion());
   this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION", temp,
                       "Patch version of cmake used to create the "
-                      "current loaded cache", cmState::INTERNAL);
+                      "current loaded cache",
+                      cmState::INTERNAL);
 
   // Let us store the current working directory so that if somebody
   // Copies it, he will not be surprised
   std::string currentcwd = path;
-  if ( currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' &&
-       currentcwd[1] == ':' )
-    {
+  if (currentcwd[0] >= 'A' && currentcwd[0] <= 'Z' && currentcwd[1] == ':') {
     // Cast added to avoid compiler warning. Cast is ok because
     // value is guaranteed to fit in char by the above if...
     currentcwd[0] = static_cast<char>(currentcwd[0] - 'A' + 'a');
-    }
+  }
   cmSystemTools::ConvertToUnixSlashes(currentcwd);
   this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd.c_str(),
                       "This is the directory where this CMakeCache.txt"
-                      " was created", cmState::INTERNAL);
+                      " was created",
+                      cmState::INTERNAL);
 
+  /* clang-format off */
   fout << "# This is the CMakeCache file.\n"
        << "# For build in directory: " << currentcwd << "\n"
        << "# It was generated by CMake: "
        << cmSystemTools::GetCMakeCommand() << std::endl;
+  /* clang-format on */
 
+  /* clang-format off */
   fout << "# You can edit this file to change values found and used by cmake."
        << std::endl
        << "# If you do not want to change any of the values, simply exit the "
@@ -335,42 +296,37 @@ bool cmCacheManager::SaveCache(const std::string& path)
        << "# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT "
        "TYPE!." << std::endl
        << "# VALUE is the current value for the KEY.\n\n";
+  /* clang-format on */
 
   fout << "########################\n";
   fout << "# EXTERNAL cache entries\n";
   fout << "########################\n";
   fout << "\n";
 
-  for( std::map<std::string, CacheEntry>::const_iterator i =
-         this->Cache.begin(); i != this->Cache.end(); ++i)
-    {
+  for (std::map<std::string, CacheEntry>::const_iterator i =
+         this->Cache.begin();
+       i != this->Cache.end(); ++i) {
     const CacheEntry& ce = (*i).second;
     cmState::CacheEntryType t = ce.Type;
-    if(!ce.Initialized)
-      {
+    if (!ce.Initialized) {
       /*
         // This should be added in, but is not for now.
       cmSystemTools::Error("Cache entry \"", (*i).first.c_str(),
                            "\" is uninitialized");
       */
-      }
-    else if(t != cmState::INTERNAL)
-      {
+    } else if (t != cmState::INTERNAL) {
       // Format is key:type=value
-      if(const char* help = ce.GetProperty("HELPSTRING"))
-        {
+      if (const char* help = ce.GetProperty("HELPSTRING")) {
         cmCacheManager::OutputHelpString(fout, help);
-        }
-      else
-        {
+      } else {
         cmCacheManager::OutputHelpString(fout, "Missing description");
-        }
+      }
       this->OutputKey(fout, i->first);
       fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
       this->OutputValue(fout, ce.Value);
       fout << "\n\n";
-      }
     }
+  }
 
   fout << "\n";
   fout << "########################\n";
@@ -378,29 +334,25 @@ bool cmCacheManager::SaveCache(const std::string& path)
   fout << "########################\n";
   fout << "\n";
 
-  for( cmCacheManager::CacheIterator i = this->NewIterator();
-       !i.IsAtEnd(); i.Next())
-    {
-    if ( !i.Initialized() )
-      {
+  for (cmCacheManager::CacheIterator i = this->NewIterator(); !i.IsAtEnd();
+       i.Next()) {
+    if (!i.Initialized()) {
       continue;
-      }
+    }
 
     cmState::CacheEntryType t = i.GetType();
     this->WritePropertyEntries(fout, i);
-    if(t == cmState::INTERNAL)
-      {
+    if (t == cmState::INTERNAL) {
       // Format is key:type=value
-      if(const char* help = i.GetProperty("HELPSTRING"))
-        {
+      if (const char* help = i.GetProperty("HELPSTRING")) {
         this->OutputHelpString(fout, help);
-        }
+      }
       this->OutputKey(fout, i.GetName());
       fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
       this->OutputValue(fout, i.GetValue());
       fout << "\n";
-      }
     }
+  }
   fout << "\n";
   fout.Close();
   std::string checkCacheFile = path;
@@ -408,14 +360,13 @@ bool cmCacheManager::SaveCache(const std::string& path)
   cmSystemTools::MakeDirectory(checkCacheFile.c_str());
   checkCacheFile += "/cmake.check_cache";
   cmsys::ofstream checkCache(checkCacheFile.c_str());
-  if(!checkCache)
-    {
+  if (!checkCache) {
     cmSystemTools::Error("Unable to open check cache file for write. ",
                          checkCacheFile.c_str());
     return false;
-    }
+  }
   checkCache << "# This file is generated by cmake for dependency checking "
-    "of the CMakeCache.txt file\n";
+                "of the CMakeCache.txt file\n";
   return true;
 }
 
@@ -425,25 +376,23 @@ bool cmCacheManager::DeleteCache(const std::string& path)
   cmSystemTools::ConvertToUnixSlashes(cacheFile);
   std::string cmakeFiles = cacheFile;
   cacheFile += "/CMakeCache.txt";
-  if(cmSystemTools::FileExists(cacheFile.c_str()))
-    {
+  if (cmSystemTools::FileExists(cacheFile.c_str())) {
     cmSystemTools::RemoveFile(cacheFile);
     // now remove the files in the CMakeFiles directory
     // this cleans up language cache files
     cmakeFiles += cmake::GetCMakeFilesDirectory();
-    if(cmSystemTools::FileIsDirectory(cmakeFiles))
-      {
+    if (cmSystemTools::FileIsDirectory(cmakeFiles)) {
       cmSystemTools::RemoveADirectory(cmakeFiles);
-      }
     }
+  }
   return true;
 }
 
 void cmCacheManager::OutputKey(std::ostream& fout, std::string const& key)
 {
   // support : in key name by double quoting
-  const char* q = (key.find(':') != key.npos ||
-                   key.find("//") == 0)? "\"" : "";
+  const char* q =
+    (key.find(':') != key.npos || key.find("//") == 0) ? "\"" : "";
   fout << q << key << q;
 }
 
@@ -451,147 +400,120 @@ void cmCacheManager::OutputValue(std::ostream& fout, std::string const& value)
 {
   // if value has trailing space or tab, enclose it in single quotes
   if (!value.empty() &&
-      (value[value.size() - 1] == ' ' ||
-       value[value.size() - 1] == '\t'))
-    {
+      (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t')) {
     fout << '\'' << value << '\'';
-    }
-  else
-    {
+  } else {
     fout << value;
-    }
+  }
 }
 
 void cmCacheManager::OutputHelpString(std::ostream& fout,
                                       const std::string& helpString)
 {
   std::string::size_type end = helpString.size();
-  if(end == 0)
-    {
+  if (end == 0) {
     return;
-    }
+  }
   std::string oneLine;
   std::string::size_type pos = 0;
-  for (std::string::size_type i=0; i<=end; i++)
-    {
-    if ((i==end)
-        || (helpString[i]=='\n')
-        || ((i-pos >= 60) && (helpString[i]==' ')))
-      {
+  for (std::string::size_type i = 0; i <= end; i++) {
+    if ((i == end) || (helpString[i] == '\n') ||
+        ((i - pos >= 60) && (helpString[i] == ' '))) {
       fout << "//";
-      if (helpString[pos] == '\n')
-        {
+      if (helpString[pos] == '\n') {
         pos++;
         fout << "\\n";
-        }
+      }
       oneLine = helpString.substr(pos, i - pos);
       fout << oneLine << "\n";
       pos = i;
-      }
     }
+  }
 }
 
 void cmCacheManager::RemoveCacheEntry(const std::string& key)
 {
   CacheEntryMap::iterator i = this->Cache.find(key);
-  if(i != this->Cache.end())
-    {
+  if (i != this->Cache.end()) {
     this->Cache.erase(i);
-    }
+  }
 }
 
-
-cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(
-    const std::string& key)
+cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
+  const std::string& key)
 {
   CacheEntryMap::iterator i = this->Cache.find(key);
-  if(i != this->Cache.end())
-    {
+  if (i != this->Cache.end()) {
     return &i->second;
-    }
+  }
   return 0;
 }
 
-cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(
-  const char *key)
+cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key)
 {
   return CacheIterator(*this, key);
 }
 
-const char*
-cmCacheManager::GetInitializedCacheValue(const std::string& key) const
+const char* cmCacheManager::GetInitializedCacheValue(
+  const std::string& key) const
 {
   CacheEntryMap::const_iterator i = this->Cache.find(key);
-  if(i != this->Cache.end() &&
-    i->second.Initialized)
-    {
+  if (i != this->Cache.end() && i->second.Initialized) {
     return i->second.Value.c_str();
-    }
+  }
   return 0;
 }
 
-
 void cmCacheManager::PrintCache(std::ostream& out) const
 {
   out << "=================================================" << std::endl;
   out << "CMakeCache Contents:" << std::endl;
-  for(std::map<std::string, CacheEntry>::const_iterator i =
-        this->Cache.begin(); i != this->Cache.end(); ++i)
-    {
-    if((*i).second.Type != cmState::INTERNAL)
-      {
-      out << (*i).first << " = " << (*i).second.Value
-          << std::endl;
-      }
+  for (std::map<std::string, CacheEntry>::const_iterator i =
+         this->Cache.begin();
+       i != this->Cache.end(); ++i) {
+    if ((*i).second.Type != cmState::INTERNAL) {
+      out << (*i).first << " = " << (*i).second.Value << std::endl;
     }
+  }
   out << "\n\n";
-  out << "To change values in the CMakeCache, "
-    << std::endl << "edit CMakeCache.txt in your output directory.\n";
+  out << "To change values in the CMakeCache, " << std::endl
+      << "edit CMakeCache.txt in your output directory.\n";
   out << "=================================================" << std::endl;
 }
 
-
-void cmCacheManager::AddCacheEntry(const std::string& key,
-                                   const char* value,
+void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
                                    const char* helpString,
                                    cmState::CacheEntryType type)
 {
   CacheEntry& e = this->Cache[key];
-  if ( value )
-    {
+  if (value) {
     e.Value = value;
     e.Initialized = true;
-    }
-  else
-    {
+  } else {
     e.Value = "";
-    }
+  }
   e.Type = type;
   // make sure we only use unix style paths
-  if(type == cmState::FILEPATH || type == cmState::PATH)
-    {
-    if(e.Value.find(';') != e.Value.npos)
-      {
+  if (type == cmState::FILEPATH || type == cmState::PATH) {
+    if (e.Value.find(';') != e.Value.npos) {
       std::vector<std::string> paths;
       cmSystemTools::ExpandListArgument(e.Value, paths);
       const char* sep = "";
       e.Value = "";
-      for(std::vector<std::string>::iterator i = paths.begin();
-          i != paths.end(); ++i)
-        {
+      for (std::vector<std::string>::iterator i = paths.begin();
+           i != paths.end(); ++i) {
         cmSystemTools::ConvertToUnixSlashes(*i);
         e.Value += sep;
         e.Value += *i;
         sep = ";";
-        }
       }
-    else
-      {
+    } else {
       cmSystemTools::ConvertToUnixSlashes(e.Value);
-      }
     }
-  e.SetProperty("HELPSTRING", helpString? helpString :
-                "(This variable does not exist and should not be used)");
+  }
+  e.SetProperty("HELPSTRING", helpString
+                  ? helpString
+                  : "(This variable does not exist and should not be used)");
 }
 
 bool cmCacheManager::CacheIterator::IsAtEnd() const
@@ -612,147 +534,113 @@ bool cmCacheManager::CacheIterator::Find(const std::string& key)
 
 void cmCacheManager::CacheIterator::Next()
 {
-  if (!this->IsAtEnd())
-    {
+  if (!this->IsAtEnd()) {
     ++this->Position;
-    }
+  }
 }
 
 void cmCacheManager::CacheIterator::SetValue(const char* value)
 {
-  if (this->IsAtEnd())
-    {
+  if (this->IsAtEnd()) {
     return;
-    }
+  }
   CacheEntry* entry = &this->GetEntry();
-  if ( value )
-    {
+  if (value) {
     entry->Value = value;
     entry->Initialized = true;
-    }
-  else
-    {
+  } else {
     entry->Value = "";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCacheManager::CacheIterator::GetValueAsBool() const
 {
   return cmSystemTools::IsOn(this->GetEntry().Value.c_str());
 }
 
-//----------------------------------------------------------------------------
-const char*
-cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
+const char* cmCacheManager::CacheEntry::GetProperty(
+  const std::string& prop) const
 {
-  if(prop == "TYPE")
-    {
+  if (prop == "TYPE") {
     return cmState::CacheEntryTypeToString(this->Type);
-    }
-  else if(prop == "VALUE")
-    {
+  } else if (prop == "VALUE") {
     return this->Value.c_str();
-    }
+  }
   return this->Properties.GetPropertyValue(prop);
 }
 
-//----------------------------------------------------------------------------
 void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
                                              const char* value)
 {
-  if(prop == "TYPE")
-    {
-    this->Type = cmState::StringToCacheEntryType(value? value : "STRING");
-    }
-  else if(prop == "VALUE")
-    {
-    this->Value = value? value : "";
-    }
-  else
-    {
+  if (prop == "TYPE") {
+    this->Type = cmState::StringToCacheEntryType(value ? value : "STRING");
+  } else if (prop == "VALUE") {
+    this->Value = value ? value : "";
+  } else {
     this->Properties.SetProperty(prop, value);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
                                                 const char* value,
                                                 bool asString)
 {
-  if(prop == "TYPE")
-    {
-    this->Type = cmState::StringToCacheEntryType(value? value : "STRING");
-    }
-  else if(prop == "VALUE")
-    {
-    if(value)
-      {
-      if(!this->Value.empty() && *value && !asString)
-        {
+  if (prop == "TYPE") {
+    this->Type = cmState::StringToCacheEntryType(value ? value : "STRING");
+  } else if (prop == "VALUE") {
+    if (value) {
+      if (!this->Value.empty() && *value && !asString) {
         this->Value += ";";
-        }
-      this->Value += value;
       }
+      this->Value += value;
     }
-  else
-    {
+  } else {
     this->Properties.AppendProperty(prop, value, asString);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 const char* cmCacheManager::CacheIterator::GetProperty(
-    const std::string& prop) const
+  const std::string& prop) const
 {
-  if(!this->IsAtEnd())
-    {
+  if (!this->IsAtEnd()) {
     return this->GetEntry().GetProperty(prop);
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 void cmCacheManager::CacheIterator::SetProperty(const std::string& p,
                                                 const char* v)
 {
-  if(!this->IsAtEnd())
-    {
+  if (!this->IsAtEnd()) {
     this->GetEntry().SetProperty(p, v);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCacheManager::CacheIterator::AppendProperty(const std::string& p,
                                                    const char* v,
                                                    bool asString)
 {
-  if(!this->IsAtEnd())
-    {
+  if (!this->IsAtEnd()) {
     this->GetEntry().AppendProperty(p, v, asString);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmCacheManager::CacheIterator::GetPropertyAsBool(
-    const std::string& prop) const
+  const std::string& prop) const
 {
-  if(const char* value = this->GetProperty(prop))
-    {
+  if (const char* value = this->GetProperty(prop)) {
     return cmSystemTools::IsOn(value);
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
 {
   this->SetProperty(p, v ? "ON" : "OFF");
 }
 
-//----------------------------------------------------------------------------
 bool cmCacheManager::CacheIterator::PropertyExists(
-    const std::string& prop) const
+  const std::string& prop) const
 {
-  return this->GetProperty(prop)? true:false;
+  return this->GetProperty(prop) ? true : false;
 }
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index 6f063eb..e9b80cb 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -13,6 +13,7 @@
 #define cmCacheManager_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmPropertyMap.h"
 #include "cmState.h"
 
@@ -40,13 +41,14 @@ private:
     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 asString = false);
     bool Initialized;
     CacheEntry()
-      : Value(""),
-        Type(cmState::UNINITIALIZED),
-        Initialized(false)
-      {}
+      : Value("")
+      , Type(cmState::UNINITIALIZED)
+      , Initialized(false)
+    {
+    }
   };
 
 public:
@@ -57,45 +59,42 @@ public:
     bool Find(const std::string&);
     bool IsAtEnd() const;
     void Next();
-    std::string GetName() const {
-      return this->Position->first; }
-    const char* GetProperty(const std::string&) const ;
-    bool GetPropertyAsBool(const std::string&) const ;
+    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);
+                        bool asString = false);
     void SetProperty(const std::string& property, bool value);
     const char* GetValue() const { return this->GetEntry().Value.c_str(); }
     bool GetValueAsBool() const;
     void SetValue(const char*);
-    cmState::CacheEntryType GetType() const
-    { return this->GetEntry().Type; }
-    void SetType(cmState::CacheEntryType ty)
-    { this->GetEntry().Type = ty; }
+    cmState::CacheEntryType GetType() const { return this->GetEntry().Type; }
+    void SetType(cmState::CacheEntryType ty) { this->GetEntry().Type = ty; }
     bool Initialized() { return this->GetEntry().Initialized; }
-    cmCacheManager &Container;
+    cmCacheManager& Container;
     std::map<std::string, CacheEntry>::iterator Position;
-    CacheIterator(cmCacheManager &cm) : Container(cm) {
+    CacheIterator(cmCacheManager& cm)
+      : Container(cm)
+    {
       this->Begin();
     }
-    CacheIterator(cmCacheManager &cm, const char* key) : Container(cm)
-      {
-      if ( key )
-        {
+    CacheIterator(cmCacheManager& cm, const char* key)
+      : Container(cm)
+    {
+      if (key) {
         this->Find(key);
-        }
       }
+    }
+
   private:
     CacheEntry const& GetEntry() const { return this->Position->second; }
     CacheEntry& GetEntry() { return this->Position->second; }
   };
 
   ///! return an iterator to iterate through the cache map
-  cmCacheManager::CacheIterator NewIterator()
-    {
-      return CacheIterator(*this);
-    }
+  cmCacheManager::CacheIterator NewIterator() { return CacheIterator(*this); }
 
   ///! Load a cache for given makefile.  Loads from path/CMakeCache.txt.
   bool LoadCache(const std::string& path, bool internal,
@@ -103,7 +102,7 @@ public:
                  std::set<std::string>& includes);
 
   ///! Save cache for given makefile.  Saves to ouput path/CMakeCache.txt
-  bool SaveCache(const std::string& path) ;
+  bool SaveCache(const std::string& path);
 
   ///! Delete the cache given
   bool DeleteCache(const std::string& path);
@@ -112,14 +111,13 @@ public:
   void PrintCache(std::ostream&) const;
 
   ///! Get the iterator for an entry with a given key.
-  cmCacheManager::CacheIterator GetCacheIterator(const char *key=0);
+  cmCacheManager::CacheIterator GetCacheIterator(const char* key = 0);
 
   ///! Remove an entry from the cache
   void RemoveCacheEntry(const std::string& key);
 
   ///! Get the number of entries in the cache
-  int GetSize() {
-    return static_cast<int>(this->Cache.size()); }
+  int GetSize() { return static_cast<int>(this->Cache.size()); }
 
   ///! Get a value from the cache given a key
   const char* GetInitializedCacheValue(const std::string& key) const;
@@ -127,10 +125,9 @@ public:
   const char* GetCacheEntryValue(const std::string& key)
   {
     cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
-    if (it.IsAtEnd())
-      {
+    if (it.IsAtEnd()) {
       return 0;
-      }
+    }
     return it.GetValue();
   }
 
@@ -159,14 +156,12 @@ public:
   }
 
   void SetCacheEntryBoolProperty(std::string const& key,
-                                 std::string const& propName,
-                                 bool value)
+                                 std::string const& propName, bool value)
   {
     this->GetCacheIterator(key.c_str()).SetProperty(propName, value);
   }
 
-  void SetCacheEntryValue(std::string const& key,
-                          std::string const& value)
+  void SetCacheEntryValue(std::string const& key, std::string const& value)
   {
     this->GetCacheIterator(key.c_str()).SetValue(value.c_str());
   }
@@ -182,9 +177,8 @@ public:
                                 std::string const& value,
                                 bool asString = false)
   {
-    this->GetCacheIterator(key.c_str()).AppendProperty(propName,
-                                                       value.c_str(),
-                                                       asString);
+    this->GetCacheIterator(key.c_str())
+      .AppendProperty(propName, value.c_str(), asString);
   }
 
   std::vector<std::string> GetCacheEntryKeys()
@@ -192,36 +186,33 @@ public:
     std::vector<std::string> definitions;
     definitions.reserve(this->GetSize());
     cmCacheManager::CacheIterator cit = this->GetCacheIterator();
-    for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
-      {
+    for (cit.Begin(); !cit.IsAtEnd(); cit.Next()) {
       definitions.push_back(cit.GetName());
-      }
+    }
     return definitions;
   }
 
   /** Get the version of CMake that wrote the cache.  */
-  unsigned int GetCacheMajorVersion() const
-    { return this->CacheMajorVersion; }
-  unsigned int GetCacheMinorVersion() const
-    { return this->CacheMinorVersion; }
+  unsigned int GetCacheMajorVersion() const { return this->CacheMajorVersion; }
+  unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; }
 
 protected:
   ///! Add an entry into the cache
   void AddCacheEntry(const std::string& key, const char* value,
-                     const char* helpString,
-                     cmState::CacheEntryType type);
+                     const char* helpString, cmState::CacheEntryType type);
 
   ///! Get a cache entry object for a key
-  CacheEntry *GetCacheEntry(const std::string& key);
+  CacheEntry* GetCacheEntry(const std::string& key);
   ///! Clean out the CMakeFiles directory if no CMakeCache.txt
   void CleanCMakeFiles(const std::string& path);
 
   // Cache version info
   unsigned int CacheMajorVersion;
   unsigned int CacheMinorVersion;
+
 private:
   cmake* CMakeInstance;
-  typedef  std::map<std::string, 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);
@@ -235,7 +226,7 @@ private:
   // Only cmake and cmState should be able to add cache values
   // the commands should never use the cmCacheManager directly
   friend class cmState; // allow access to add cache values
-  friend class cmake; // allow access to add cache values
+  friend class cmake;   // allow access to add cache values
 };
 
 #endif
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 0e04838..e608d6b 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -9,93 +9,77 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-
 #include "cmCallVisualStudioMacro.h"
-#include "cmSystemTools.h"
 
+#include "cmSystemTools.h"
 
 #if defined(_MSC_VER)
 #define HAVE_COMDEF_H
 #endif
 
-
 // Just for this file:
 //
 static bool LogErrorsAsMessages;
 
-
 #if defined(HAVE_COMDEF_H)
 
-
 #include <comdef.h>
 
-
-//----------------------------------------------------------------------------
 // Copied from a correct comdef.h to avoid problems with deficient versions
 // of comdef.h that exist in the wild... Fixes issue #7533.
 //
 #ifdef _NATIVE_WCHAR_T_DEFINED
-# ifdef _DEBUG
-# pragma comment(lib, "comsuppwd.lib")
-# else
-# pragma comment(lib, "comsuppw.lib")
-# endif
+#ifdef _DEBUG
+#pragma comment(lib, "comsuppwd.lib")
 #else
-# ifdef _DEBUG
-# pragma comment(lib, "comsuppd.lib")
-# else
-# pragma comment(lib, "comsupp.lib")
-# endif
+#pragma comment(lib, "comsuppw.lib")
+#endif
+#else
+#ifdef _DEBUG
+#pragma comment(lib, "comsuppd.lib")
+#else
+#pragma comment(lib, "comsupp.lib")
+#endif
 #endif
 
-
-//----------------------------------------------------------------------------
 ///! Use ReportHRESULT to make a cmSystemTools::Message after calling
 ///! a COM method that may have failed.
-#define ReportHRESULT(hr, context) \
-  if (FAILED(hr)) \
-    { \
-    if (LogErrorsAsMessages) \
-      { \
-      std::ostringstream _hresult_oss; \
-      _hresult_oss.flags(std::ios::hex); \
-      _hresult_oss << context << " failed HRESULT, hr = 0x" \
-                   << hr << std::endl; \
-      _hresult_oss.flags(std::ios::dec); \
-      _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
-      cmSystemTools::Message(_hresult_oss.str().c_str()); \
-      } \
-    }
-
+#define ReportHRESULT(hr, context)                                            \
+  if (FAILED(hr)) {                                                           \
+    if (LogErrorsAsMessages) {                                                \
+      std::ostringstream _hresult_oss;                                        \
+      _hresult_oss.flags(std::ios::hex);                                      \
+      _hresult_oss << context << " failed HRESULT, hr = 0x" << hr             \
+                   << std::endl;                                              \
+      _hresult_oss.flags(std::ios::dec);                                      \
+      _hresult_oss << __FILE__ << "(" << __LINE__ << ")";                     \
+      cmSystemTools::Message(_hresult_oss.str().c_str());                     \
+    }                                                                         \
+  }
 
-//----------------------------------------------------------------------------
 ///! Using the given instance of Visual Studio, call the named macro
-HRESULT InstanceCallMacro(
-  IDispatch* vsIDE,
-  const std::string& macro,
-  const std::string& args)
+HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
+                          const std::string& args)
 {
   HRESULT hr = E_POINTER;
 
   _bstr_t macroName(macro.c_str());
   _bstr_t macroArgs(args.c_str());
 
-  if (0 != vsIDE)
-    {
-    DISPID dispid = (DISPID) -1;
-    OLECHAR *name = L"ExecuteCommand";
+  if (0 != vsIDE) {
+    DISPID dispid = (DISPID)-1;
+    OLECHAR* name = L"ExecuteCommand";
 
-    hr = vsIDE->GetIDsOfNames(IID_NULL, &name, 1,
-           LOCALE_USER_DEFAULT, &dispid);
+    hr =
+      vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
     ReportHRESULT(hr, "GetIDsOfNames(ExecuteCommand)");
 
-    if (SUCCEEDED(hr))
-      {
+    if (SUCCEEDED(hr)) {
       VARIANTARG vargs[2];
       DISPPARAMS params;
       VARIANT result;
       EXCEPINFO excep;
-      UINT arg = (UINT) -1;
+      UINT arg = (UINT)-1;
 
       // No VariantInit or VariantClear calls are necessary for
       // these two vargs. They are both local _bstr_t variables
@@ -108,7 +92,7 @@ HRESULT InstanceCallMacro(
 
       params.rgvarg = &vargs[0];
       params.rgdispidNamedArgs = 0;
-      params.cArgs = sizeof(vargs)/sizeof(vargs[0]);
+      params.cArgs = sizeof(vargs) / sizeof(vargs[0]);
       params.cNamedArgs = 0;
 
       VariantInit(&result);
@@ -116,7 +100,7 @@ HRESULT InstanceCallMacro(
       memset(&excep, 0, sizeof(excep));
 
       hr = vsIDE->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
-        DISPATCH_METHOD, &params, &result, &excep, &arg);
+                         DISPATCH_METHOD, &params, &result, &excep, &arg);
 
       std::ostringstream oss;
       oss << std::endl;
@@ -124,66 +108,56 @@ HRESULT InstanceCallMacro(
       oss << "  Macro: " << macro.c_str() << std::endl;
       oss << "  Args: " << args.c_str() << std::endl;
 
-      if (DISP_E_EXCEPTION == hr)
-        {
+      if (DISP_E_EXCEPTION == hr) {
         oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << std::endl;
         oss << "  wCode: " << excep.wCode << std::endl;
         oss << "  wReserved: " << excep.wReserved << std::endl;
-        if (excep.bstrSource)
-          {
-          oss << "  bstrSource: " <<
-            (const char*)(_bstr_t)excep.bstrSource << std::endl;
-          }
-        if (excep.bstrDescription)
-          {
-          oss << "  bstrDescription: " <<
-            (const char*)(_bstr_t)excep.bstrDescription << std::endl;
-          }
-        if (excep.bstrHelpFile)
-          {
-          oss << "  bstrHelpFile: " <<
-            (const char*)(_bstr_t)excep.bstrHelpFile << std::endl;
-          }
+        if (excep.bstrSource) {
+          oss << "  bstrSource: " << (const char*)(_bstr_t)excep.bstrSource
+              << std::endl;
+        }
+        if (excep.bstrDescription) {
+          oss << "  bstrDescription: "
+              << (const char*)(_bstr_t)excep.bstrDescription << std::endl;
+        }
+        if (excep.bstrHelpFile) {
+          oss << "  bstrHelpFile: " << (const char*)(_bstr_t)excep.bstrHelpFile
+              << std::endl;
+        }
         oss << "  dwHelpContext: " << excep.dwHelpContext << std::endl;
         oss << "  pvReserved: " << excep.pvReserved << std::endl;
         oss << "  pfnDeferredFillIn: " << excep.pfnDeferredFillIn << std::endl;
         oss << "  scode: " << excep.scode << std::endl;
-        }
+      }
 
       std::string exstr(oss.str());
       ReportHRESULT(hr, exstr.c_str());
 
       VariantClear(&result);
-      }
     }
+  }
 
   return hr;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Get the Solution object from the IDE object
-HRESULT GetSolutionObject(
-  IDispatch* vsIDE,
-  IDispatchPtr& vsSolution)
+HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution)
 {
   HRESULT hr = E_POINTER;
 
-  if (0 != vsIDE)
-    {
-    DISPID dispid = (DISPID) -1;
-    OLECHAR *name = L"Solution";
+  if (0 != vsIDE) {
+    DISPID dispid = (DISPID)-1;
+    OLECHAR* name = L"Solution";
 
-    hr = vsIDE->GetIDsOfNames(IID_NULL, &name, 1,
-           LOCALE_USER_DEFAULT, &dispid);
+    hr =
+      vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
     ReportHRESULT(hr, "GetIDsOfNames(Solution)");
 
-    if (SUCCEEDED(hr))
-      {
+    if (SUCCEEDED(hr)) {
       DISPPARAMS params;
       VARIANT result;
       EXCEPINFO excep;
-      UINT arg = (UINT) -1;
+      UINT arg = (UINT)-1;
 
       params.rgvarg = 0;
       params.rgdispidNamedArgs = 0;
@@ -195,45 +169,38 @@ HRESULT GetSolutionObject(
       memset(&excep, 0, sizeof(excep));
 
       hr = vsIDE->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
-        DISPATCH_PROPERTYGET, &params, &result, &excep, &arg);
+                         DISPATCH_PROPERTYGET, &params, &result, &excep, &arg);
       ReportHRESULT(hr, "Invoke(Solution)");
 
-      if (SUCCEEDED(hr))
-        {
+      if (SUCCEEDED(hr)) {
         vsSolution = V_DISPATCH(&result);
-        }
+      }
 
       VariantClear(&result);
-      }
     }
+  }
 
   return hr;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Get the FullName property from the Solution object
-HRESULT GetSolutionFullName(
-  IDispatch* vsSolution,
-  std::string& fullName)
+HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName)
 {
   HRESULT hr = E_POINTER;
 
-  if (0 != vsSolution)
-    {
-    DISPID dispid = (DISPID) -1;
-    OLECHAR *name = L"FullName";
+  if (0 != vsSolution) {
+    DISPID dispid = (DISPID)-1;
+    OLECHAR* name = L"FullName";
 
-    hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1,
-           LOCALE_USER_DEFAULT, &dispid);
+    hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT,
+                                   &dispid);
     ReportHRESULT(hr, "GetIDsOfNames(FullName)");
 
-    if (SUCCEEDED(hr))
-      {
+    if (SUCCEEDED(hr)) {
       DISPPARAMS params;
       VARIANT result;
       EXCEPINFO excep;
-      UINT arg = (UINT) -1;
+      UINT arg = (UINT)-1;
 
       params.rgvarg = 0;
       params.rgdispidNamedArgs = 0;
@@ -245,43 +212,36 @@ HRESULT GetSolutionFullName(
       memset(&excep, 0, sizeof(excep));
 
       hr = vsSolution->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
-        DISPATCH_PROPERTYGET, &params, &result, &excep, &arg);
+                              DISPATCH_PROPERTYGET, &params, &result, &excep,
+                              &arg);
       ReportHRESULT(hr, "Invoke(FullName)");
 
-      if (SUCCEEDED(hr))
-        {
-        fullName = (std::string) (_bstr_t) V_BSTR(&result);
-        }
+      if (SUCCEEDED(hr)) {
+        fullName = (std::string)(_bstr_t)V_BSTR(&result);
+      }
 
       VariantClear(&result);
-      }
     }
+  }
 
   return hr;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Get the FullName property from the Solution object, given the IDE object
-HRESULT GetIDESolutionFullName(
-  IDispatch* vsIDE,
-  std::string& fullName)
+HRESULT GetIDESolutionFullName(IDispatch* vsIDE, std::string& fullName)
 {
   IDispatchPtr vsSolution;
   HRESULT hr = GetSolutionObject(vsIDE, vsSolution);
   ReportHRESULT(hr, "GetSolutionObject");
 
-  if (SUCCEEDED(hr))
-    {
+  if (SUCCEEDED(hr)) {
     GetSolutionFullName(vsSolution, fullName);
     ReportHRESULT(hr, "GetSolutionFullName");
-    }
+  }
 
   return hr;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Get all running objects from the Windows running object table.
 ///! Save them in a map by their display names.
 HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
@@ -296,22 +256,18 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
   HRESULT hr = GetRunningObjectTable(0, &runningObjectTable);
   ReportHRESULT(hr, "GetRunningObjectTable");
 
-  if(SUCCEEDED(hr))
-    {
+  if (SUCCEEDED(hr)) {
     hr = runningObjectTable->EnumRunning(&monikerEnumerator);
     ReportHRESULT(hr, "EnumRunning");
-    }
+  }
 
-  if(SUCCEEDED(hr))
-    {
+  if (SUCCEEDED(hr)) {
     hr = monikerEnumerator->Reset();
     ReportHRESULT(hr, "Reset");
-    }
+  }
 
-  if(SUCCEEDED(hr))
-    {
-    while (S_OK == monikerEnumerator->Next(1, &moniker, &numFetched))
-      {
+  if (SUCCEEDED(hr)) {
+    while (S_OK == monikerEnumerator->Next(1, &moniker, &numFetched)) {
       std::string runningObjectName;
       IUnknownPtr runningObjectVal;
       IBindCtxPtr ctx;
@@ -319,45 +275,37 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
       hr = CreateBindCtx(0, &ctx);
       ReportHRESULT(hr, "CreateBindCtx");
 
-      if(SUCCEEDED(hr))
-        {
+      if (SUCCEEDED(hr)) {
         LPOLESTR displayName = 0;
         hr = moniker->GetDisplayName(ctx, 0, &displayName);
         ReportHRESULT(hr, "GetDisplayName");
-        if (displayName)
-          {
-          runningObjectName = (std::string) (_bstr_t) displayName;
+        if (displayName) {
+          runningObjectName = (std::string)(_bstr_t)displayName;
           CoTaskMemFree(displayName);
-          }
+        }
 
         hr = runningObjectTable->GetObject(moniker, &runningObjectVal);
         ReportHRESULT(hr, "GetObject");
-        if(SUCCEEDED(hr))
-          {
+        if (SUCCEEDED(hr)) {
           mrot.insert(std::make_pair(runningObjectName, runningObjectVal));
-          }
         }
+      }
 
       numFetched = 0;
       moniker = 0;
-      }
     }
+  }
 
   return hr;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Do the two file names refer to the same Visual Studio solution? Or are
 ///! we perhaps looking for any and all solutions?
-bool FilesSameSolution(
-  const std::string& slnFile,
-  const std::string& slnName)
+bool FilesSameSolution(const std::string& slnFile, const std::string& slnName)
 {
-  if (slnFile == "ALL" || slnName == "ALL")
-    {
+  if (slnFile == "ALL" || slnName == "ALL") {
     return true;
-    }
+  }
 
   // Otherwise, make lowercase local copies, convert to Unix slashes, and
   // see if the resulting strings are the same:
@@ -369,59 +317,48 @@ bool FilesSameSolution(
   return s1 == s2;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Find instances of Visual Studio with the given solution file
 ///! open. Pass "ALL" for slnFile to gather all running instances
 ///! of Visual Studio.
-HRESULT FindVisualStudioInstances(
-  const std::string& slnFile,
-  std::vector<IDispatchPtr>& instances)
+HRESULT FindVisualStudioInstances(const std::string& slnFile,
+                                  std::vector<IDispatchPtr>& instances)
 {
   std::map<std::string, IUnknownPtr> mrot;
 
   HRESULT hr = GetRunningInstances(mrot);
   ReportHRESULT(hr, "GetRunningInstances");
 
-  if(SUCCEEDED(hr))
-    {
+  if (SUCCEEDED(hr)) {
     std::map<std::string, IUnknownPtr>::iterator it;
-    for(it = mrot.begin(); it != mrot.end(); ++it)
-      {
+    for (it = mrot.begin(); it != mrot.end(); ++it) {
       if (cmSystemTools::StringStartsWith(it->first.c_str(),
-        "!VisualStudio.DTE."))
-        {
+                                          "!VisualStudio.DTE.")) {
         IDispatchPtr disp(it->second);
-        if (disp != (IDispatch*) 0)
-          {
+        if (disp != (IDispatch*)0) {
           std::string slnName;
           hr = GetIDESolutionFullName(disp, slnName);
           ReportHRESULT(hr, "GetIDESolutionFullName");
 
-          if (FilesSameSolution(slnFile, slnName))
-            {
+          if (FilesSameSolution(slnFile, slnName)) {
             instances.push_back(disp);
 
-            //std::cout << "Found Visual Studio instance." << std::endl;
-            //std::cout << "  ROT entry name: " << it->first << std::endl;
-            //std::cout << "  ROT entry object: "
+            // std::cout << "Found Visual Studio instance." << std::endl;
+            // std::cout << "  ROT entry name: " << it->first << std::endl;
+            // std::cout << "  ROT entry object: "
             //          << (IUnknown*) it->second << std::endl;
-            //std::cout << "  slnFile: " << slnFile << std::endl;
-            //std::cout << "  slnName: " << slnName << std::endl;
-            }
+            // std::cout << "  slnFile: " << slnFile << std::endl;
+            // std::cout << "  slnName: " << slnName << std::endl;
           }
         }
       }
     }
+  }
 
   return hr;
 }
 
+#endif // defined(HAVE_COMDEF_H)
 
-#endif  //defined(HAVE_COMDEF_H)
-
-
-//----------------------------------------------------------------------------
 int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
   const std::string& slnFile)
 {
@@ -433,22 +370,20 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
   HRESULT hr = CoInitialize(0);
   ReportHRESULT(hr, "CoInitialize");
 
-  if(SUCCEEDED(hr))
-    {
+  if (SUCCEEDED(hr)) {
     std::vector<IDispatchPtr> instances;
     hr = FindVisualStudioInstances(slnFile, instances);
     ReportHRESULT(hr, "FindVisualStudioInstances");
 
-    if(SUCCEEDED(hr))
-      {
+    if (SUCCEEDED(hr)) {
       count = static_cast<int>(instances.size());
-      }
+    }
 
     // Force release all COM pointers before CoUninitialize:
     instances.clear();
 
     CoUninitialize();
-    }
+  }
 #else
   (void)slnFile;
 #endif
@@ -456,15 +391,12 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
   return count;
 }
 
-
-//----------------------------------------------------------------------------
 ///! Get all running objects from the Windows running object table.
 ///! Save them in a map by their display names.
-int cmCallVisualStudioMacro::CallMacro(
-  const std::string& slnFile,
-  const std::string& macro,
-  const std::string& args,
-  const bool logErrorsAsMessages)
+int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile,
+                                       const std::string& macro,
+                                       const std::string& args,
+                                       const bool logErrorsAsMessages)
 {
   int err = 1; // no comdef.h
 
@@ -476,60 +408,53 @@ int cmCallVisualStudioMacro::CallMacro(
   HRESULT hr = CoInitialize(0);
   ReportHRESULT(hr, "CoInitialize");
 
-  if(SUCCEEDED(hr))
-    {
+  if (SUCCEEDED(hr)) {
     std::vector<IDispatchPtr> instances;
     hr = FindVisualStudioInstances(slnFile, instances);
     ReportHRESULT(hr, "FindVisualStudioInstances");
 
-    if(SUCCEEDED(hr))
-      {
+    if (SUCCEEDED(hr)) {
       err = 0; // no error
 
       std::vector<IDispatchPtr>::iterator it;
-      for(it = instances.begin(); it != instances.end(); ++it)
-        {
+      for (it = instances.begin(); it != instances.end(); ++it) {
         hr = InstanceCallMacro(*it, macro, args);
         ReportHRESULT(hr, "InstanceCallMacro");
 
-        if (FAILED(hr))
-          {
+        if (FAILED(hr)) {
           err = 3; // error attempting to call the macro
-          }
         }
+      }
 
-      if(instances.empty())
-        {
+      if (instances.empty()) {
         // no instances to call
 
-        //cmSystemTools::Message(
+        // cmSystemTools::Message(
         //  "cmCallVisualStudioMacro::CallMacro no instances found to call",
         //  "Warning");
-        }
       }
+    }
 
     // Force release all COM pointers before CoUninitialize:
     instances.clear();
 
     CoUninitialize();
-    }
+  }
 #else
   (void)slnFile;
   (void)macro;
   (void)args;
-  if (LogErrorsAsMessages)
-    {
+  if (LogErrorsAsMessages) {
     cmSystemTools::Message("cmCallVisualStudioMacro::CallMacro is not "
-      "supported on this platform");
-    }
+                           "supported on this platform");
+  }
 #endif
 
-  if (err && LogErrorsAsMessages)
-    {
+  if (err && LogErrorsAsMessages) {
     std::ostringstream oss;
     oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err;
     cmSystemTools::Message(oss.str().c_str());
-    }
+  }
 
   return 0;
 }
diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h
index 09bddfa..e516fe2 100644
--- a/Source/cmCallVisualStudioMacro.h
+++ b/Source/cmCallVisualStudioMacro.h
@@ -26,8 +26,7 @@ public:
   ///! Call the named macro in instances of Visual Studio with the
   ///! given solution file open. Pass "ALL" for slnFile to call the
   ///! macro in each Visual Studio instance.
-  static int CallMacro(const std::string& slnFile,
-                       const std::string& macro,
+  static int CallMacro(const std::string& slnFile, const std::string& macro,
                        const std::string& args,
                        const bool logErrorsAsMessages);
 
@@ -38,7 +37,6 @@ public:
     const std::string& slnFile);
 
 protected:
-
 private:
 };
 
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index 59bc396..0157293 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -13,9 +13,10 @@
 #define cmCommand_h
 
 #include "cmObject.h"
+
+#include "cmCommandArgumentsHelper.h"
 #include "cmListFileCache.h"
 #include "cmMakefile.h"
-#include "cmCommandArgumentsHelper.h"
 
 /** \class cmCommand
  * \brief Superclass for all commands in CMake.
@@ -36,7 +37,10 @@ public:
    * Construct the command. By default it is enabled with no makefile.
    */
   cmCommand()
-    {this->Makefile = 0; this->Enabled = true;}
+  {
+    this->Makefile = 0;
+    this->Enabled = true;
+  }
 
   /**
    * Need virtual destructor to destroy real command type.
@@ -46,8 +50,7 @@ public:
   /**
    * Specify the makefile.
    */
-  void SetMakefile(cmMakefile*m)
-    {this->Makefile = m; }
+  void SetMakefile(cmMakefile* m) { this->Makefile = m; }
   cmMakefile* GetMakefile() { return this->Makefile; }
 
   /**
@@ -56,24 +59,23 @@ public:
    * arguments and then invokes the InitialPass.
    */
   virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                                 cmExecutionStatus &status)
-    {
+                                 cmExecutionStatus& status)
+  {
     std::vector<std::string> expandedArguments;
-    if(!this->Makefile->ExpandArguments(args, expandedArguments))
-      {
+    if (!this->Makefile->ExpandArguments(args, expandedArguments)) {
       // There was an error expanding arguments.  It was already
       // reported, so we can skip this command without error.
       return true;
-      }
-    return this->InitialPass(expandedArguments,status);
     }
+    return this->InitialPass(expandedArguments, status);
+  }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &) = 0;
+                           cmExecutionStatus&) = 0;
 
   /**
    * This is called at the end after all the information
@@ -96,10 +98,7 @@ public:
   /**
    * This determines if the command is invoked when in script mode.
    */
-  virtual bool IsScriptable() const
-    {
-    return false;
-    }
+  virtual bool IsScriptable() const { return false; }
 
   /**
    * This is used to avoid including this command
@@ -107,10 +106,7 @@ public:
    * cmMacroHelperCommand and cmFunctionHelperCommand
    * which cannot provide appropriate documentation.
    */
-  virtual bool ShouldAppearInDocumentation() const
-    {
-    return true;
-    }
+  virtual bool ShouldAppearInDocumentation() const { return true; }
 
   /**
    * The name of the command as specified in CMakeList.txt.
@@ -120,58 +116,52 @@ public:
   /**
    * Enable the command.
    */
-  void EnabledOn()
-    {this->Enabled = true;}
+  void EnabledOn() { this->Enabled = true; }
 
   /**
    * Disable the command.
    */
-  void EnabledOff()
-    {this->Enabled = false;}
+  void EnabledOff() { this->Enabled = false; }
 
   /**
    * Query whether the command is enabled.
    */
-  bool GetEnabled() const
-    {return this->Enabled;}
+  bool GetEnabled() const { return this->Enabled; }
 
   /**
    * Disable or enable the command.
    */
-  void SetEnabled(bool enabled)
-    {this->Enabled = enabled;}
+  void SetEnabled(bool enabled) { this->Enabled = enabled; }
 
   /**
    * Return the last error string.
    */
   const char* GetError()
-    {
-      if(this->Error.empty())
-        {
-        this->Error = this->GetName();
-        this->Error += " unknown error.";
-        }
-      return this->Error.c_str();
+  {
+    if (this->Error.empty()) {
+      this->Error = this->GetName();
+      this->Error += " unknown error.";
     }
+    return this->Error.c_str();
+  }
 
   /**
    * Set the error message
    */
   void SetError(const std::string& e)
-    {
+  {
     this->Error = this->GetName();
     this->Error += " ";
     this->Error += e;
-    }
+  }
 
   /** Check if the command is disallowed by a policy.  */
   bool Disallowed(cmPolicies::PolicyID pol, const char* e)
-    {
-    switch(this->Makefile->GetPolicyStatus(pol))
-      {
+  {
+    switch (this->Makefile->GetPolicyStatus(pol)) {
       case cmPolicies::WARN:
         this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
-          cmPolicies::GetPolicyWarning(pol));
+                                     cmPolicies::GetPolicyWarning(pol));
       case cmPolicies::OLD:
         return false;
       case cmPolicies::REQUIRED_IF_USED:
@@ -179,9 +169,9 @@ public:
       case cmPolicies::NEW:
         this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
         break;
-      }
-    return true;
     }
+    return true;
+  }
 
 protected:
   cmMakefile* Makefile;
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 14e9e56..a4f3c7d 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -11,14 +11,14 @@
 ============================================================================*/
 #include "cmCommandArgumentParserHelper.h"
 
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
-#include "cmState.h"
 #include "cmOutputConverter.h"
+#include "cmState.h"
+#include "cmSystemTools.h"
 
 #include "cmCommandArgumentLexer.h"
 
-int cmCommandArgument_yyparse( yyscan_t yyscanner );
+int cmCommandArgument_yyparse(yyscan_t yyscanner);
 //
 cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
 {
@@ -30,7 +30,7 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
   this->EmptyVariable[0] = 0;
   strcpy(this->DCURLYVariable, "${");
   strcpy(this->RCURLYVariable, "}");
-  strcpy(this->ATVariable,     "@");
+  strcpy(this->ATVariable, "@");
   strcpy(this->DOLLARVariable, "$");
   strcpy(this->LCURLYVariable, "{");
   strcpy(this->BSLASHVariable, "\\");
@@ -39,7 +39,6 @@ cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
   this->ReplaceAtSyntax = false;
 }
 
-
 cmCommandArgumentParserHelper::~cmCommandArgumentParserHelper()
 {
   this->CleanupParser();
@@ -53,11 +52,10 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file)
 
 char* cmCommandArgumentParserHelper::AddString(const std::string& str)
 {
-  if ( str.empty() )
-    {
+  if (str.empty()) {
     return this->EmptyVariable;
-    }
-  char* stVal = new char[str.size()+1];
+  }
+  char* stVal = new char[str.size() + 1];
   strcpy(stVal, str.c_str());
   this->Variables.push_back(stVal);
   return stVal;
@@ -66,46 +64,34 @@ char* cmCommandArgumentParserHelper::AddString(const std::string& str)
 char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
                                                            const char* var)
 {
-  if ( !key )
-    {
+  if (!key) {
     return this->ExpandVariable(var);
-    }
-  if(!var)
-    {
+  }
+  if (!var) {
     return this->EmptyVariable;
-    }
-  if ( strcmp(key, "ENV") == 0 )
-    {
-    char *ptr = getenv(var);
-    if (ptr)
-      {
-      if (this->EscapeQuotes)
-        {
+  }
+  if (strcmp(key, "ENV") == 0) {
+    char* ptr = getenv(var);
+    if (ptr) {
+      if (this->EscapeQuotes) {
         return this->AddString(cmSystemTools::EscapeQuotes(ptr));
-        }
-      else
-        {
+      } else {
         return ptr;
-        }
       }
-    return this->EmptyVariable;
     }
-  if ( strcmp(key, "CACHE") == 0 )
-    {
-    if(const char* c = this->Makefile->GetState()
-                           ->GetInitializedCacheValue(var))
-      {
-      if(this->EscapeQuotes)
-        {
+    return this->EmptyVariable;
+  }
+  if (strcmp(key, "CACHE") == 0) {
+    if (const char* c =
+          this->Makefile->GetState()->GetInitializedCacheValue(var)) {
+      if (this->EscapeQuotes) {
         return this->AddString(cmSystemTools::EscapeQuotes(c));
-        }
-      else
-        {
+      } else {
         return this->AddString(c);
-        }
       }
-    return this->EmptyVariable;
     }
+    return this->EmptyVariable;
+  }
   std::ostringstream e;
   e << "Syntax $" << key << "{} is not supported.  "
     << "Only ${}, $ENV{}, and $CACHE{} are allowed.";
@@ -115,69 +101,53 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
 
 char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
 {
-  if(!var)
-    {
+  if (!var) {
     return 0;
-    }
-  if(this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0)
-    {
+  }
+  if (this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) {
     std::ostringstream ostr;
     ostr << this->FileLine;
     return this->AddString(ostr.str());
-    }
+  }
   const char* value = this->Makefile->GetDefinition(var);
-  if(!value && !this->RemoveEmpty)
-    {
+  if (!value && !this->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->WarnUninitialized && !this->Makefile->VariableInitialized(var))
-      {
+    if (this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
       if (this->CheckSystemVars ||
           cmSystemTools::IsSubDirectory(this->FileName,
                                         this->Makefile->GetHomeDirectory()) ||
-          cmSystemTools::IsSubDirectory(this->FileName,
-                                     this->Makefile->GetHomeOutputDirectory()))
-        {
+          cmSystemTools::IsSubDirectory(
+            this->FileName, this->Makefile->GetHomeOutputDirectory())) {
         std::ostringstream msg;
-        cmListFileContext lfc;
-        cmOutputConverter converter(this->Makefile->GetStateSnapshot());
-        lfc.FilePath = converter.Convert(this->FileName,
-                                         cmOutputConverter::HOME);
-
-        lfc.Line = this->FileLine;
         msg << "uninitialized variable \'" << var << "\'";
-        this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
-                                                        msg.str(), lfc);
-        }
+        this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
       }
-    return 0;
     }
-  if (this->EscapeQuotes && value)
-    {
+    return 0;
+  }
+  if (this->EscapeQuotes && value) {
     return this->AddString(cmSystemTools::EscapeQuotes(value));
-    }
+  }
   return this->AddString(value ? value : "");
 }
 
 char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
 {
-  if(this->ReplaceAtSyntax)
-    {
+  if (this->ReplaceAtSyntax) {
     // try to expand the variable
     char* ret = this->ExpandVariable(var);
     // if the return was 0 and we want to replace empty strings
     // then return an empty string
-    if(!ret && this->RemoveEmpty)
-      {
+    if (!ret && this->RemoveEmpty) {
       return this->AddString("");
-      }
+    }
     // if the ret was not 0, then return it
-    if(ret)
-      {
+    if (ret) {
       return ret;
-      }
     }
+  }
   // at this point we want to put it back because of one of these cases:
   // - this->ReplaceAtSyntax is false
   // - this->ReplaceAtSyntax is true, but this->RemoveEmpty is false,
@@ -190,79 +160,72 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
 
 char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
 {
-  if ( !in1 )
-    {
+  if (!in1) {
     return in2;
-    }
-  else if ( !in2 )
-    {
+  } else if (!in2) {
     return in1;
-    }
+  }
   size_t len = strlen(in1) + strlen(in2) + 1;
-  char* out = new char [ len ];
+  char* out = new char[len];
   strcpy(out, in1);
   strcat(out, in2);
   this->Variables.push_back(out);
   return out;
 }
 
-void cmCommandArgumentParserHelper::AllocateParserType
-(cmCommandArgumentParserHelper::ParserType* pt,const char* str, int len)
+void cmCommandArgumentParserHelper::AllocateParserType(
+  cmCommandArgumentParserHelper::ParserType* pt, const char* str, int len)
 {
   pt->str = 0;
-  if ( len == 0 )
-    {
+  if (len == 0) {
     len = static_cast<int>(strlen(str));
-    }
-  if ( len == 0 )
-    {
+  }
+  if (len == 0) {
     return;
-    }
-  pt->str = new char[ len + 1 ];
+  }
+  pt->str = new char[len + 1];
   strncpy(pt->str, str, len);
   pt->str[len] = 0;
   this->Variables.push_back(pt->str);
 }
 
-bool cmCommandArgumentParserHelper::HandleEscapeSymbol
-(cmCommandArgumentParserHelper::ParserType* pt, char symbol)
+bool cmCommandArgumentParserHelper::HandleEscapeSymbol(
+  cmCommandArgumentParserHelper::ParserType* pt, char symbol)
 {
-  switch ( symbol )
-    {
-  case '\\':
-  case '"':
-  case ' ':
-  case '#':
-  case '(':
-  case ')':
-  case '$':
-  case '@':
-  case '^':
-    this->AllocateParserType(pt, &symbol, 1);
-    break;
-  case ';':
-    this->AllocateParserType(pt, "\\;", 2);
-    break;
-  case 't':
-    this->AllocateParserType(pt, "\t", 1);
-    break;
-  case 'n':
-    this->AllocateParserType(pt, "\n", 1);
-    break;
-  case 'r':
-    this->AllocateParserType(pt, "\r", 1);
-    break;
-  case '0':
-    this->AllocateParserType(pt, "\0", 1);
-    break;
-  default:
-    {
-    std::ostringstream e;
-    e << "Invalid escape sequence \\" << symbol;
-    this->SetError(e.str());
-    }
-    return false;
+  switch (symbol) {
+    case '\\':
+    case '"':
+    case ' ':
+    case '#':
+    case '(':
+    case ')':
+    case '$':
+    case '@':
+    case '^':
+      this->AllocateParserType(pt, &symbol, 1);
+      break;
+    case ';':
+      this->AllocateParserType(pt, "\\;", 2);
+      break;
+    case 't':
+      this->AllocateParserType(pt, "\t", 1);
+      break;
+    case 'n':
+      this->AllocateParserType(pt, "\n", 1);
+      break;
+    case 'r':
+      this->AllocateParserType(pt, "\r", 1);
+      break;
+    case '0':
+      this->AllocateParserType(pt, "\0", 1);
+      break;
+    default: {
+      std::ostringstream e;
+      e << "Invalid escape sequence \\" << symbol;
+      this->SetError(e.str());
     }
+      return false;
+  }
   return true;
 }
 
@@ -270,10 +233,9 @@ void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes);
 
 int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
 {
-  if ( !str)
-    {
+  if (!str) {
     return 0;
-    }
+  }
   this->Verbose = verb;
   this->InputBuffer = str;
   this->InputBufferPos = 0;
@@ -287,53 +249,43 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
   cmCommandArgument_SetupEscapes(yyscanner, this->NoEscapeMode);
   int res = cmCommandArgument_yyparse(yyscanner);
   cmCommandArgument_yylex_destroy(yyscanner);
-  if ( res != 0 )
-    {
+  if (res != 0) {
     return 0;
-    }
+  }
 
   this->CleanupParser();
 
-  if ( Verbose )
-    {
-    std::cerr << "Expanding [" << str << "] produced: ["
-              << this->Result << "]" << std::endl;
-    }
+  if (Verbose) {
+    std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]"
+              << std::endl;
+  }
   return 1;
 }
 
 void cmCommandArgumentParserHelper::CleanupParser()
 {
   std::vector<char*>::iterator sit;
-  for ( sit = this->Variables.begin();
-    sit != this->Variables.end();
-    ++ sit )
-    {
-    delete [] *sit;
-    }
+  for (sit = this->Variables.begin(); sit != this->Variables.end(); ++sit) {
+    delete[] * sit;
+  }
   this->Variables.erase(this->Variables.begin(), this->Variables.end());
 }
 
 int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen)
 {
-  if ( maxlen < 1 )
-    {
+  if (maxlen < 1) {
     return 0;
+  }
+  if (this->InputBufferPos < this->InputBuffer.size()) {
+    buf[0] = this->InputBuffer[this->InputBufferPos++];
+    if (buf[0] == '\n') {
+      this->CurrentLine++;
     }
-  if ( this->InputBufferPos < this->InputBuffer.size() )
-    {
-    buf[0] = this->InputBuffer[ this->InputBufferPos++ ];
-    if ( buf[0] == '\n' )
-      {
-      this->CurrentLine ++;
-      }
-    return(1);
-    }
-  else
-    {
+    return (1);
+  } else {
     buf[0] = '\n';
-    return( 0 );
-    }
+    return (0);
+  }
 }
 
 void cmCommandArgumentParserHelper::Error(const char* str)
@@ -353,19 +305,17 @@ void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
 
 void cmCommandArgumentParserHelper::SetResult(const char* value)
 {
-  if ( !value )
-    {
+  if (!value) {
     this->Result = "";
     return;
-    }
+  }
   this->Result = value;
 }
 
 void cmCommandArgumentParserHelper::SetError(std::string const& msg)
 {
   // Keep only the first error.
-  if(this->ErrorString.empty())
-    {
+  if (this->ErrorString.empty()) {
     this->ErrorString = msg;
-    }
+  }
 }
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 387afc6..97b706c 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -17,8 +17,8 @@
 #define YYSTYPE cmCommandArgumentParserHelper::ParserType
 #define YYSTYPE_IS_DECLARED
 #define YY_EXTRA_TYPE cmCommandArgumentParserHelper*
-#define YY_DECL int cmCommandArgument_yylex(YYSTYPE* yylvalp,\
-  yyscan_t yyscanner)
+#define YY_DECL                                                               \
+  int cmCommandArgument_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
 
 /** \class cmCommandArgumentParserHelper
  * \brief Helper class for parsing java source files
@@ -31,7 +31,8 @@ class cmMakefile;
 class cmCommandArgumentParserHelper
 {
 public:
-  typedef struct {
+  typedef struct
+  {
     char* str;
   } ParserType;
 
@@ -42,9 +43,9 @@ public:
 
   // For the lexer:
   void AllocateParserType(cmCommandArgumentParserHelper::ParserType* pt,
-    const char* str, int len = 0);
+                          const char* str, int len = 0);
   bool HandleEscapeSymbol(cmCommandArgumentParserHelper::ParserType* pt,
-    char symbol);
+                          char symbol);
 
   int LexInput(char* buf, int maxlen);
   void Error(const char* str);
@@ -106,5 +107,3 @@ private:
 };
 
 #endif
-
-
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx
index 1a2efc6..c336bc5 100644
--- a/Source/cmCommandArgumentsHelper.cxx
+++ b/Source/cmCommandArgumentsHelper.cxx
@@ -15,26 +15,24 @@
 cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args,
                                      const char* key,
                                      cmCommandArgumentGroup* group)
-:Key(key)
-,Group(group)
-,WasActive(false)
-,ArgumentsBeforeEmpty(true)
-,CurrentIndex(0)
+  : Key(key)
+  , Group(group)
+  , WasActive(false)
+  , ArgumentsBeforeEmpty(true)
+  , CurrentIndex(0)
 {
-  if (args!=0)
-    {
+  if (args != 0) {
     args->AddArgument(this);
-    }
+  }
 
-  if (this->Group!=0)
-    {
+  if (this->Group != 0) {
     this->Group->ContainedArguments.push_back(this);
-    }
+  }
 }
 
 void cmCommandArgument::Reset()
 {
-  this->WasActive =false;
+  this->WasActive = false;
   this->CurrentIndex = 0;
   this->DoReset();
 }
@@ -47,55 +45,47 @@ void cmCommandArgument::Follows(const cmCommandArgument* arg)
 
 void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
 {
-  if (group!=0)
-    {
+  if (group != 0) {
     this->ArgumentsBeforeEmpty = false;
     this->ArgumentsBefore.insert(group->ContainedArguments.begin(),
                                  group->ContainedArguments.end());
-    }
+  }
 }
 
 bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
 {
-  if (this->ArgumentsBeforeEmpty)
-    {
+  if (this->ArgumentsBeforeEmpty) {
     return true;
-    }
+  }
 
-  std::set<const cmCommandArgument*>::const_iterator argIt
-                                         = this->ArgumentsBefore.find(current);
-  if (argIt != this->ArgumentsBefore.end())
-    {
+  std::set<const cmCommandArgument*>::const_iterator argIt =
+    this->ArgumentsBefore.find(current);
+  if (argIt != this->ArgumentsBefore.end()) {
     return true;
-    }
+  }
 
   return false;
 }
 
 bool cmCommandArgument::KeyMatches(const std::string& key) const
 {
-  if ((this->Key==0) || (this->Key[0]=='\0'))
-    {
+  if ((this->Key == 0) || (this->Key[0] == '\0')) {
     return true;
-    }
-  return (key==this->Key);
+  }
+  return (key == this->Key);
 }
 
 void cmCommandArgument::ApplyOwnGroup()
 {
-  if (this->Group!=0)
-    {
-    for (std::vector<cmCommandArgument*>::const_iterator
-         it = this->Group->ContainedArguments.begin();
-         it != this->Group->ContainedArguments.end();
-         ++it)
-      {
-      if(*it != this)
-        {
+  if (this->Group != 0) {
+    for (std::vector<cmCommandArgument*>::const_iterator it =
+           this->Group->ContainedArguments.begin();
+         it != this->Group->ContainedArguments.end(); ++it) {
+      if (*it != this) {
         this->ArgumentsBefore.insert(*it);
-        }
       }
     }
+  }
 }
 
 void cmCommandArgument::Activate()
@@ -106,37 +96,31 @@ void cmCommandArgument::Activate()
 
 bool cmCommandArgument::Consume(const std::string& arg)
 {
-  bool res=this->DoConsume(arg, this->CurrentIndex);
+  bool res = this->DoConsume(arg, this->CurrentIndex);
   this->CurrentIndex++;
   return res;
 }
 
-
 cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args,
                                    const char* key,
                                    cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Ignore(0)
+  : cmCommandArgument(args, key, group)
+  , Ignore(0)
 {
-  if ((key==0) || (*key==0))
-    {
+  if ((key == 0) || (*key == 0)) {
     this->DataStart = 0;
-    }
-  else
-    {
+  } else {
     this->DataStart = 1;
-    }
+  }
 }
 
-bool cmCAStringVector::DoConsume(const std::string& arg,unsigned int index)
+bool cmCAStringVector::DoConsume(const std::string& arg, unsigned int index)
 {
-  if (index >= this->DataStart)
-    {
-    if ((this->Ignore==0) || (arg != this->Ignore))
-      {
+  if (index >= this->DataStart) {
+    if ((this->Ignore == 0) || (arg != this->Ignore)) {
       this->Vector.push_back(arg);
-      }
     }
+  }
 
   return false;
 }
@@ -146,27 +130,22 @@ void cmCAStringVector::DoReset()
   this->Vector.clear();
 }
 
-cmCAString::cmCAString(cmCommandArgumentsHelper* args,
-                       const char* key,
+cmCAString::cmCAString(cmCommandArgumentsHelper* args, const char* key,
                        cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
+  : cmCommandArgument(args, key, group)
 {
-  if ((key==0) || (*key==0))
-    {
+  if ((key == 0) || (*key == 0)) {
     this->DataStart = 0;
-    }
-  else
-    {
+  } else {
     this->DataStart = 1;
-    }
+  }
 }
 
 bool cmCAString::DoConsume(const std::string& arg, unsigned int index)
 {
-  if (index == this->DataStart)
-    {
+  if (index == this->DataStart) {
     this->String = arg;
-    }
+  }
 
   return index >= this->DataStart;
 }
@@ -176,19 +155,18 @@ void cmCAString::DoReset()
   this->String = "";
 }
 
-cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args,
-                         const char* key,
+cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
                          cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Enabled(false)
-{}
+  : cmCommandArgument(args, key, group)
+  , Enabled(false)
+{
+}
 
 bool cmCAEnabler::DoConsume(const std::string&, unsigned int index)
 {
-  if (index==0)
-    {
+  if (index == 0) {
     this->Enabled = true;
-    }
+  }
   return true;
 }
 
@@ -197,19 +175,18 @@ void cmCAEnabler::DoReset()
   this->Enabled = false;
 }
 
-cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args,
-                           const char* key,
+cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
                            cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Enabled(true)
-{}
+  : cmCommandArgument(args, key, group)
+  , Enabled(true)
+{
+}
 
 bool cmCADisabler::DoConsume(const std::string&, unsigned int index)
 {
-  if (index==0)
-    {
+  if (index == 0) {
     this->Enabled = false;
-    }
+  }
   return true;
 }
 
@@ -220,83 +197,66 @@ void cmCADisabler::DoReset()
 
 void cmCommandArgumentGroup::Follows(const cmCommandArgument* arg)
 {
-  for(std::vector<cmCommandArgument*>::iterator
-      it = this->ContainedArguments.begin();
-      it != this->ContainedArguments.end();
-      ++it)
-    {
+  for (std::vector<cmCommandArgument*>::iterator it =
+         this->ContainedArguments.begin();
+       it != this->ContainedArguments.end(); ++it) {
     (*it)->Follows(arg);
-    }
+  }
 }
 
 void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group)
 {
-  for(std::vector<cmCommandArgument*>::iterator
-      it = this->ContainedArguments.begin();
-      it != this->ContainedArguments.end();
-      ++it)
-    {
+  for (std::vector<cmCommandArgument*>::iterator it =
+         this->ContainedArguments.begin();
+       it != this->ContainedArguments.end(); ++it) {
     (*it)->FollowsGroup(group);
-    }
+  }
 }
 
 void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args,
                                      std::vector<std::string>* unconsumedArgs)
 {
-  if(args==0)
-    {
+  if (args == 0) {
     return;
-    }
+  }
 
-  for(std::vector<cmCommandArgument*>::iterator
-      argIt = this->Arguments.begin();
-      argIt != this->Arguments.end();
-      ++argIt)
-    {
+  for (std::vector<cmCommandArgument*>::iterator argIt =
+         this->Arguments.begin();
+       argIt != this->Arguments.end(); ++argIt) {
     (*argIt)->ApplyOwnGroup();
     (*argIt)->Reset();
-    }
+  }
 
   cmCommandArgument* activeArgument = 0;
   const cmCommandArgument* previousArgument = 0;
-  for(std::vector<std::string>::const_iterator it = args->begin();
-      it != args->end();
-      ++it)
-    {
-    for(std::vector<cmCommandArgument*>::iterator
-        argIt = this->Arguments.begin();
-        argIt != this->Arguments.end();
-        ++argIt)
-      {
-      if ((*argIt)->KeyMatches(*it) && ((*argIt)->MayFollow(previousArgument)))
-        {
+  for (std::vector<std::string>::const_iterator it = args->begin();
+       it != args->end(); ++it) {
+    for (std::vector<cmCommandArgument*>::iterator argIt =
+           this->Arguments.begin();
+         argIt != this->Arguments.end(); ++argIt) {
+      if ((*argIt)->KeyMatches(*it) &&
+          ((*argIt)->MayFollow(previousArgument))) {
         activeArgument = *argIt;
         activeArgument->Activate();
         break;
-        }
       }
+    }
 
-    if (activeArgument)
-      {
+    if (activeArgument) {
       bool argDone = activeArgument->Consume(*it);
       previousArgument = activeArgument;
-      if (argDone)
-        {
+      if (argDone) {
         activeArgument = 0;
-        }
       }
-    else
-      {
-      if (unconsumedArgs!=0)
-        {
+    } else {
+      if (unconsumedArgs != 0) {
         unconsumedArgs->push_back(*it);
-        }
       }
     }
+  }
 }
 
 void cmCommandArgumentsHelper::AddArgument(cmCommandArgument* arg)
 {
   this->Arguments.push_back(arg);
 }
-
diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h
index f732f8f..c2a6f92 100644
--- a/Source/cmCommandArgumentsHelper.h
+++ b/Source/cmCommandArgumentsHelper.h
@@ -41,164 +41,161 @@ For an example see cmExportCommand.cxx.
 */
 class cmCommandArgument
 {
-  public:
-    cmCommandArgument(cmCommandArgumentsHelper* args,
-                      const char* key,
-                      cmCommandArgumentGroup* group=0);
-    virtual ~cmCommandArgument() {}
-
-    /// this argument may follow after arg. 0 means it comes first.
-    void Follows(const cmCommandArgument* arg);
-
-    /// this argument may follow after any of the arguments in the given group
-    void FollowsGroup(const cmCommandArgumentGroup* group);
-
-    /// Returns true if the argument was found in the argument list
-    bool WasFound() const                             {return this->WasActive;}
-
-    // The following methods are only called from
-    // cmCommandArgumentsHelper::Parse(), but making this a friend would
-    // give it access to everything
-
-    /// Make the current argument the currently active argument
-    void Activate();
-    /// Consume the current string
-    bool Consume(const std::string& arg);
-
-    /// Return true if this argument may follow after the given argument.
-    bool MayFollow(const cmCommandArgument* current) const;
-
-    /** Returns true if the given key matches the key for this argument.
-    If this argument has an empty key everything matches. */
-    bool KeyMatches(const std::string& key) const;
-
-    /// Make this argument follow all members of the own group
-    void ApplyOwnGroup();
-
-    /// Reset argument, so it's back to its initial state
-    void Reset();
-  private:
-    const char* Key;
-    std::set<const cmCommandArgument*> ArgumentsBefore;
-    cmCommandArgumentGroup* Group;
-    bool WasActive;
-    bool ArgumentsBeforeEmpty;
-    unsigned int CurrentIndex;
-
-    virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
-    virtual void DoReset() = 0;
+public:
+  cmCommandArgument(cmCommandArgumentsHelper* args, const char* key,
+                    cmCommandArgumentGroup* group = 0);
+  virtual ~cmCommandArgument() {}
+
+  /// this argument may follow after arg. 0 means it comes first.
+  void Follows(const cmCommandArgument* arg);
+
+  /// this argument may follow after any of the arguments in the given group
+  void FollowsGroup(const cmCommandArgumentGroup* group);
+
+  /// Returns true if the argument was found in the argument list
+  bool WasFound() const { return this->WasActive; }
+
+  // The following methods are only called from
+  // cmCommandArgumentsHelper::Parse(), but making this a friend would
+  // give it access to everything
+
+  /// Make the current argument the currently active argument
+  void Activate();
+  /// Consume the current string
+  bool Consume(const std::string& arg);
+
+  /// Return true if this argument may follow after the given argument.
+  bool MayFollow(const cmCommandArgument* current) const;
+
+  /** Returns true if the given key matches the key for this argument.
+  If this argument has an empty key everything matches. */
+  bool KeyMatches(const std::string& key) const;
+
+  /// Make this argument follow all members of the own group
+  void ApplyOwnGroup();
+
+  /// Reset argument, so it's back to its initial state
+  void Reset();
+
+private:
+  const char* Key;
+  std::set<const cmCommandArgument*> ArgumentsBefore;
+  cmCommandArgumentGroup* Group;
+  bool WasActive;
+  bool ArgumentsBeforeEmpty;
+  unsigned int CurrentIndex;
+
+  virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
+  virtual void DoReset() = 0;
 };
 
 /** cmCAStringVector is to be used for arguments which can consist of more
 than one string, e.g. the FILES argument in INSTALL(FILES f1 f2 f3 ...). */
 class cmCAStringVector : public cmCommandArgument
 {
-  public:
-    cmCAStringVector(cmCommandArgumentsHelper* args,
-                     const char* key,
-                     cmCommandArgumentGroup* group=0);
-
-    /// Return the vector of strings
-    const std::vector<std::string>& GetVector() const    {return this->Vector;}
-
-    /** Is there a keyword which should be skipped in
-    the arguments (e.g. ARGS for ADD_CUSTOM_COMMAND) ? */
-    void SetIgnore(const char* ignore)                   {this->Ignore=ignore;}
-  private:
-    std::vector<std::string> Vector;
-    unsigned int DataStart;
-    const char* Ignore;
-    cmCAStringVector();
-    virtual bool DoConsume(const std::string& arg, unsigned int index);
-    virtual void DoReset();
+public:
+  cmCAStringVector(cmCommandArgumentsHelper* args, const char* key,
+                   cmCommandArgumentGroup* group = 0);
+
+  /// Return the vector of strings
+  const std::vector<std::string>& GetVector() const { return this->Vector; }
+
+  /** Is there a keyword which should be skipped in
+  the arguments (e.g. ARGS for ADD_CUSTOM_COMMAND) ? */
+  void SetIgnore(const char* ignore) { this->Ignore = ignore; }
+private:
+  std::vector<std::string> Vector;
+  unsigned int DataStart;
+  const char* Ignore;
+  cmCAStringVector();
+  virtual bool DoConsume(const std::string& arg, unsigned int index);
+  virtual void DoReset();
 };
 
 /** cmCAString is to be used for arguments which consist of one value,
 e.g. the executable name in ADD_EXECUTABLE(). */
 class cmCAString : public cmCommandArgument
 {
-  public:
-    cmCAString(cmCommandArgumentsHelper* args,
-               const char* key,
-               cmCommandArgumentGroup* group=0);
-
-    /// Return the string
-    const std::string& GetString() const                 {return this->String;}
-    const char* GetCString() const               {return this->String.c_str();}
-  private:
-    std::string String;
-    unsigned int DataStart;
-    virtual bool DoConsume(const std::string& arg, unsigned int index);
-    virtual void DoReset();
-    cmCAString();
+public:
+  cmCAString(cmCommandArgumentsHelper* args, const char* key,
+             cmCommandArgumentGroup* group = 0);
+
+  /// Return the string
+  const std::string& GetString() const { return this->String; }
+  const char* GetCString() const { return this->String.c_str(); }
+private:
+  std::string String;
+  unsigned int DataStart;
+  virtual bool DoConsume(const std::string& arg, unsigned int index);
+  virtual void DoReset();
+  cmCAString();
 };
 
 /** cmCAEnabler is to be used for options which are off by default and can be
 enabled using a special argument, e.g. EXCLUDE_FROM_ALL in ADD_EXECUTABLE(). */
 class cmCAEnabler : public cmCommandArgument
 {
-  public:
-    cmCAEnabler(cmCommandArgumentsHelper* args,
-                const char* key,
-                cmCommandArgumentGroup* group=0);
-
-    /// Has it been enabled ?
-    bool IsEnabled() const                              {return this->Enabled;}
-  private:
-    bool Enabled;
-    virtual bool DoConsume(const std::string& arg, unsigned int index);
-    virtual void DoReset();
-    cmCAEnabler();
+public:
+  cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
+              cmCommandArgumentGroup* group = 0);
+
+  /// Has it been enabled ?
+  bool IsEnabled() const { return this->Enabled; }
+private:
+  bool Enabled;
+  virtual bool DoConsume(const std::string& arg, unsigned int index);
+  virtual void DoReset();
+  cmCAEnabler();
 };
 
 /** cmCADisable is to be used for options which are on by default and can be
 disabled using a special argument.*/
 class cmCADisabler : public cmCommandArgument
 {
-  public:
-    cmCADisabler(cmCommandArgumentsHelper* args,
-                 const char* key,
-                 cmCommandArgumentGroup* group=0);
-
-    /// Is it still enabled ?
-    bool IsEnabled() const                              {return this->Enabled;}
-  private:
-    bool Enabled;
-    virtual bool DoConsume(const std::string& arg, unsigned int index);
-    virtual void DoReset();
-    cmCADisabler();
+public:
+  cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
+               cmCommandArgumentGroup* group = 0);
+
+  /// Is it still enabled ?
+  bool IsEnabled() const { return this->Enabled; }
+private:
+  bool Enabled;
+  virtual bool DoConsume(const std::string& arg, unsigned int index);
+  virtual void DoReset();
+  cmCADisabler();
 };
 
-
 /** Group of arguments, needed for ordering. E.g. WIN32, EXCLUDE_FROM_ALL and
 MACSOX_BUNDLE from ADD_EXECUTABLE() are a group.
 */
 class cmCommandArgumentGroup
 {
   friend class cmCommandArgument;
-  public:
-    cmCommandArgumentGroup() {}
 
-    /// All members of this group may follow the given argument
-    void Follows(const cmCommandArgument* arg);
+public:
+  cmCommandArgumentGroup() {}
 
-    /// All members of this group may follow all members of the given group
-    void FollowsGroup(const cmCommandArgumentGroup* group);
-  private:
-    std::vector<cmCommandArgument*> ContainedArguments;
+  /// All members of this group may follow the given argument
+  void Follows(const cmCommandArgument* arg);
+
+  /// All members of this group may follow all members of the given group
+  void FollowsGroup(const cmCommandArgumentGroup* group);
+
+private:
+  std::vector<cmCommandArgument*> ContainedArguments;
 };
 
 class cmCommandArgumentsHelper
 {
-  public:
-    /// Parse the argument list
-    void Parse(const std::vector<std::string>* args,
-               std::vector<std::string>* unconsumedArgs);
-    /// Add an argument.
-    void AddArgument(cmCommandArgument* arg);
-  private:
-    std::vector<cmCommandArgument*> Arguments;
+public:
+  /// Parse the argument list
+  void Parse(const std::vector<std::string>* args,
+             std::vector<std::string>* unconsumedArgs);
+  /// Add an argument.
+  void AddArgument(cmCommandArgument* arg);
+
+private:
+  std::vector<cmCommandArgument*> Arguments;
 };
 
-
 #endif
diff --git a/Source/cmCommands.h b/Source/cmCommands.h
index 7a94423..d0f1ab7 100644
--- a/Source/cmCommands.h
+++ b/Source/cmCommands.h
@@ -11,6 +11,7 @@
 ============================================================================*/
 #ifndef cmCommands_h
 #define cmCommands_h
+
 #include "cmStandardIncludes.h"
 
 #include <vector>
@@ -27,5 +28,4 @@ void GetBootstrapCommands1(std::vector<cmCommand*>& commands);
 void GetBootstrapCommands2(std::vector<cmCommand*>& commands);
 void GetPredefinedCommands(std::vector<cmCommand*>& commands);
 
-
 #endif
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 76ed038..c630971 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -20,15 +20,13 @@
 #include "cmSystemTools.h"
 
 cmCommonTargetGenerator::cmCommonTargetGenerator(
-  cmOutputConverter::RelativeRoot wd,
-  cmGeneratorTarget* gt
-  )
+  cmOutputConverter::RelativeRoot wd, cmGeneratorTarget* gt)
   : WorkingDirectory(wd)
   , GeneratorTarget(gt)
   , Makefile(gt->Makefile)
   , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
   , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
-                      gt->LocalGenerator->GetGlobalGenerator()))
+      gt->LocalGenerator->GetGlobalGenerator()))
   , ConfigName(LocalGenerator->GetConfigName())
   , ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName))
   , FortranModuleDirectoryComputed(false)
@@ -45,64 +43,54 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const
 }
 
 std::string cmCommonTargetGenerator::Convert(
-  std::string const& source,
-  cmLocalGenerator::RelativeRoot relative,
-  cmLocalGenerator::OutputFormat output)
+  std::string const& source, cmOutputConverter::RelativeRoot relative,
+  cmOutputConverter::OutputFormat output)
 {
   return this->LocalGenerator->Convert(source, relative, output);
 }
 
-//----------------------------------------------------------------------------
 const char* cmCommonTargetGenerator::GetFeature(const std::string& feature)
 {
   return this->GeneratorTarget->GetFeature(feature, this->ConfigName);
 }
 
-//----------------------------------------------------------------------------
 bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature)
 {
   return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName);
 }
 
-//----------------------------------------------------------------------------
-void cmCommonTargetGenerator::AddFeatureFlags(
-  std::string& flags, const std::string& lang
-  )
+void cmCommonTargetGenerator::AddFeatureFlags(std::string& flags,
+                                              const std::string& lang)
 {
   // Add language-specific flags.
   this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName);
 
-  if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION"))
-    {
+  if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) {
     this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
 {
-  if(!this->ModuleDefinitionFile)
-    {
+  if (!this->ModuleDefinitionFile) {
     return;
-    }
+  }
 
   // TODO: Create a per-language flag variable.
   const char* defFileFlag =
     this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
-  if(!defFileFlag)
-    {
+  if (!defFileFlag) {
     return;
-    }
+  }
 
   // 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->ModuleDefinitionFile->GetFullPath()));
+    this->ModuleDefinitionFile->GetFullPath()));
   this->LocalGenerator->AppendFlags(flags, flag);
 }
 
-//----------------------------------------------------------------------------
 std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
 {
   std::string mod_dir;
@@ -110,197 +98,166 @@ std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
     this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY");
   const char* moddir_flag =
     this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
-  if(target_mod_dir && moddir_flag)
-    {
+  if (target_mod_dir && moddir_flag) {
     // Compute the full path to the module directory.
-    if(cmSystemTools::FileIsFullPath(target_mod_dir))
-      {
+    if (cmSystemTools::FileIsFullPath(target_mod_dir)) {
       // Already a full path.
       mod_dir = target_mod_dir;
-      }
-    else
-      {
+    } else {
       // Interpret relative to the current output directory.
       mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
       mod_dir += "/";
       mod_dir += target_mod_dir;
-      }
+    }
 
     // Make sure the module output directory exists.
     cmSystemTools::MakeDirectory(mod_dir);
-    }
+  }
   return mod_dir;
 }
 
-//----------------------------------------------------------------------------
 std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
 {
   // Compute the module directory.
-  if(!this->FortranModuleDirectoryComputed)
-    {
+  if (!this->FortranModuleDirectoryComputed) {
     this->FortranModuleDirectoryComputed = true;
     this->FortranModuleDirectory = this->ComputeFortranModuleDirectory();
-    }
+  }
 
   // Return the computed directory.
   return this->FortranModuleDirectory;
 }
 
-//----------------------------------------------------------------------------
 void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
 {
   // Enable module output if necessary.
-  if(const char* modout_flag =
-     this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG"))
-    {
+  if (const char* modout_flag =
+        this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
     this->LocalGenerator->AppendFlags(flags, modout_flag);
-    }
+  }
 
   // Add a module output directory flag if necessary.
   std::string mod_dir = this->GetFortranModuleDirectory();
-  if (!mod_dir.empty())
-    {
-    mod_dir = this->Convert(mod_dir,
-                            this->WorkingDirectory,
-                            cmLocalGenerator::SHELL);
-    }
-  else
-    {
+  if (!mod_dir.empty()) {
+    mod_dir =
+      this->Convert(mod_dir, this->WorkingDirectory, cmOutputConverter::SHELL);
+  } else {
     mod_dir =
       this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
-    }
-  if (!mod_dir.empty())
-    {
+  }
+  if (!mod_dir.empty()) {
     const char* moddir_flag =
       this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
     std::string modflag = moddir_flag;
     modflag += mod_dir;
     this->LocalGenerator->AppendFlags(flags, modflag);
-    }
+  }
 
   // If there is a separate module path flag then duplicate the
   // include path with it.  This compiler does not search the include
   // path for modules.
-  if(const char* modpath_flag =
-     this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
-    {
+  if (const char* modpath_flag =
+        this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
     std::vector<std::string> includes;
     const std::string& config =
       this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-    this->LocalGenerator->GetIncludeDirectories(includes,
-                                                this->GeneratorTarget,
-                                                "C", config);
-    for(std::vector<std::string>::const_iterator idi = includes.begin();
-        idi != includes.end(); ++idi)
-      {
+    this->LocalGenerator->GetIncludeDirectories(
+      includes, this->GeneratorTarget, "C", config);
+    for (std::vector<std::string>::const_iterator idi = includes.begin();
+         idi != includes.end(); ++idi) {
       std::string flg = modpath_flag;
-      flg += this->Convert(*idi,
-                           cmLocalGenerator::NONE,
-                           cmLocalGenerator::SHELL);
+      flg +=
+        this->Convert(*idi, cmOutputConverter::NONE, cmOutputConverter::SHELL);
       this->LocalGenerator->AppendFlags(flags, flg);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmCommonTargetGenerator
-::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
+void cmCommonTargetGenerator::AppendFortranFormatFlags(
+  std::string& flags, cmSourceFile const& source)
 {
   const char* srcfmt = source.GetProperty("Fortran_FORMAT");
-  cmLocalGenerator::FortranFormat format =
+  cmOutputConverter::FortranFormat format =
     this->LocalGenerator->GetFortranFormat(srcfmt);
-  if(format == cmLocalGenerator::FortranFormatNone)
-    {
+  if (format == cmOutputConverter::FortranFormatNone) {
     const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT");
     format = this->LocalGenerator->GetFortranFormat(tgtfmt);
-    }
+  }
   const char* var = 0;
-  switch (format)
-    {
-    case cmLocalGenerator::FortranFormatFixed:
-      var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break;
-    case cmLocalGenerator::FortranFormatFree:
-      var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break;
-    default: break;
-    }
-  if(var)
-    {
-    this->LocalGenerator->AppendFlags(
-      flags, this->Makefile->GetDefinition(var));
-    }
+  switch (format) {
+    case cmOutputConverter::FortranFormatFixed:
+      var = "CMAKE_Fortran_FORMAT_FIXED_FLAG";
+      break;
+    case cmOutputConverter::FortranFormatFree:
+      var = "CMAKE_Fortran_FORMAT_FREE_FLAG";
+      break;
+    default:
+      break;
+  }
+  if (var) {
+    this->LocalGenerator->AppendFlags(flags,
+                                      this->Makefile->GetDefinition(var));
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l)
 {
- if(!this->Makefile->IsOn("APPLE"))
-   {
-   return std::string();
-   }
+  if (!this->Makefile->IsOn("APPLE")) {
+    return std::string();
+  }
 
   std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
-  const char* fwSearchFlag =
-    this->Makefile->GetDefinition(fwSearchFlagVar);
-  if(!(fwSearchFlag && *fwSearchFlag))
-    {
+  const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
+  if (!(fwSearchFlag && *fwSearchFlag)) {
     return std::string();
-    }
+  }
 
- std::set<std::string> emitted;
-#ifdef __APPLE__  /* don't insert this when crosscompiling e.g. to iphone */
+  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 std::string& config =
     this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-  this->LocalGenerator->GetIncludeDirectories(includes,
-                                              this->GeneratorTarget,
+  this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
                                               "C", config);
   // check all include directories for frameworks as this
   // will already have added a -F for the framework
-  for(std::vector<std::string>::iterator i = includes.begin();
-      i != includes.end(); ++i)
-    {
-    if(this->GlobalGenerator->NameResolvesToFramework(*i))
-      {
+  for (std::vector<std::string>::iterator i = includes.begin();
+       i != includes.end(); ++i) {
+    if (this->GlobalGenerator->NameResolvesToFramework(*i)) {
       std::string frameworkDir = *i;
       frameworkDir += "/../";
       frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
       emitted.insert(frameworkDir);
-      }
     }
+  }
 
   std::string flags;
   const char* cfg = this->LocalGenerator->GetConfigName().c_str();
-  if(cmComputeLinkInformation* cli =
-     this->GeneratorTarget->GetLinkInformation(cfg))
-    {
+  if (cmComputeLinkInformation* cli =
+        this->GeneratorTarget->GetLinkInformation(cfg)) {
     std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
-    for(std::vector<std::string>::const_iterator i = frameworks.begin();
-        i != frameworks.end(); ++i)
-      {
-      if(emitted.insert(*i).second)
-        {
+    for (std::vector<std::string>::const_iterator i = frameworks.begin();
+         i != frameworks.end(); ++i) {
+      if (emitted.insert(*i).second) {
         flags += fwSearchFlag;
-        flags += this->LocalGenerator
-                     ->ConvertToOutputFormat(*i, cmLocalGenerator::SHELL);
+        flags += this->LocalGenerator->ConvertToOutputFormat(
+          *i, cmOutputConverter::SHELL);
         flags += " ";
-        }
       }
     }
+  }
   return flags;
 }
 
-//----------------------------------------------------------------------------
-std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
+std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
 {
   ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
-  if (i == this->FlagsByLanguage.end())
-    {
+  if (i == this->FlagsByLanguage.end()) {
     std::string flags;
-    const char *lang = l.c_str();
+    const char* lang = l.c_str();
 
     // Add language feature flags.
     this->AddFeatureFlags(flags, lang);
@@ -309,104 +266,95 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
                                                lang, this->ConfigName);
 
     // Fortran-specific flags computed for this target.
-    if(l == "Fortran")
-      {
+    if (l == "Fortran") {
       this->AddFortranFlags(flags);
-      }
+    }
 
-    this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
-                                          lang, this->ConfigName);
+    this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
+                                          this->ConfigName);
 
-    this->LocalGenerator->AddVisibilityPresetFlags(flags,
-                                                   this->GeneratorTarget,
-                                                   lang);
+    this->LocalGenerator->AddVisibilityPresetFlags(
+      flags, this->GeneratorTarget, lang);
 
     // Append old-style preprocessor definition flags.
-    this->LocalGenerator->
-      AppendFlags(flags, this->Makefile->GetDefineFlags());
+    this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
 
     // Add framework directory flags.
-    this->LocalGenerator->
-      AppendFlags(flags,this->GetFrameworkFlags(l));
+    this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags(l));
 
     // Add target-specific flags.
-    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
-                                            lang, this->ConfigName);
+    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
+                                            this->ConfigName);
 
     ByLanguageMap::value_type entry(l, flags);
     i = this->FlagsByLanguage.insert(entry).first;
-    }
+  }
   return i->second;
 }
 
-std::string cmCommonTargetGenerator::GetDefines(const std::string &l)
+std::string cmCommonTargetGenerator::GetDefines(const std::string& l)
 {
   ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
-  if (i == this->DefinesByLanguage.end())
-    {
+  if (i == this->DefinesByLanguage.end()) {
     std::set<std::string> defines;
-    const char *lang = l.c_str();
+    const char* lang = l.c_str();
     // Add the export symbol definition for shared library objects.
-    if(const char* exportMacro =
-       this->GeneratorTarget->GetExportMacro())
-      {
+    if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
       this->LocalGenerator->AppendDefines(defines, exportMacro);
-      }
+    }
 
     // Add preprocessor definitions for this target and configuration.
-    this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
-                            this->LocalGenerator->GetConfigName(), l);
+    this->LocalGenerator->AddCompileDefinitions(
+      defines, this->GeneratorTarget, this->LocalGenerator->GetConfigName(),
+      l);
 
     std::string definesString;
     this->LocalGenerator->JoinDefines(defines, definesString, lang);
 
     ByLanguageMap::value_type entry(l, definesString);
     i = this->DefinesByLanguage.insert(entry).first;
-    }
+  }
   return i->second;
 }
 
 std::string cmCommonTargetGenerator::GetIncludes(std::string const& l)
 {
   ByLanguageMap::iterator i = this->IncludesByLanguage.find(l);
-  if (i == this->IncludesByLanguage.end())
-    {
+  if (i == this->IncludesByLanguage.end()) {
     std::string includes;
     this->AddIncludeFlags(includes, l);
     ByLanguageMap::value_type entry(l, includes);
     i = this->IncludesByLanguage.insert(entry).first;
-    }
+  }
   return i->second;
 }
 
-std::vector<std::string>
-cmCommonTargetGenerator::GetLinkedTargetDirectories() const
+std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
+  const
 {
   std::vector<std::string> dirs;
   std::set<cmGeneratorTarget const*> emitted;
   if (cmComputeLinkInformation* cli =
-      this->GeneratorTarget->GetLinkInformation(this->ConfigName))
-    {
+        this->GeneratorTarget->GetLinkInformation(this->ConfigName)) {
     cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
-    for(cmComputeLinkInformation::ItemVector::const_iterator
-          i = items.begin(); i != items.end(); ++i)
-      {
+    for (cmComputeLinkInformation::ItemVector::const_iterator i =
+           items.begin();
+         i != items.end(); ++i) {
       cmGeneratorTarget const* linkee = i->Target;
-      if(linkee && !linkee->IsImported()
-                // We can ignore the INTERFACE_LIBRARY items because
-                // Target->GetLinkInformation already processed their
-                // link interface and they don't have any output themselves.
-                && linkee->GetType() != cmState::INTERFACE_LIBRARY
-                && emitted.insert(linkee).second)
-        {
+      if (linkee && !linkee->IsImported()
+          // We can ignore the INTERFACE_LIBRARY items because
+          // Target->GetLinkInformation already processed their
+          // link interface and they don't have any output themselves.
+          && linkee->GetType() != cmState::INTERFACE_LIBRARY &&
+          emitted.insert(linkee).second) {
         cmLocalGenerator* lg = linkee->GetLocalGenerator();
         std::string di = lg->GetCurrentBinaryDirectory();
         di += "/";
         di += lg->GetTargetDirectory(linkee);
         dirs.push_back(di);
-        }
       }
     }
+  }
   return dirs;
 }
 
@@ -417,12 +365,40 @@ std::string cmCommonTargetGenerator::GetManifests()
 
   std::vector<std::string> manifests;
   for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
-       mi != manifest_srcs.end(); ++mi)
-    {
-    manifests.push_back(this->Convert((*mi)->GetFullPath(),
-                                      this->WorkingDirectory,
-                                      cmOutputConverter::SHELL));
-    }
+       mi != manifest_srcs.end(); ++mi) {
+    manifests.push_back(this->Convert(
+      (*mi)->GetFullPath(), this->WorkingDirectory, cmOutputConverter::SHELL));
+  }
 
   return cmJoin(manifests, " ");
 }
+
+void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags,
+                                               const std::string& lang,
+                                               const char* name, bool so)
+{
+  // Lookup the flag to specify the version.
+  std::string fvar = "CMAKE_";
+  fvar += lang;
+  fvar += "_OSX_";
+  fvar += name;
+  fvar += "_VERSION_FLAG";
+  const char* flag = this->Makefile->GetDefinition(fvar);
+
+  // Skip if no such flag.
+  if (!flag) {
+    return;
+  }
+
+  // Lookup the target version information.
+  int major;
+  int minor;
+  int patch;
+  this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
+  if (major > 0 || minor > 0 || patch > 0) {
+    // Append the flag since a non-zero version is specified.
+    std::ostringstream vflag;
+    vflag << flag << major << "." << minor << "." << patch;
+    this->LocalGenerator->AppendFlags(flags, vflag.str());
+  }
+}
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index 0c17500..c9645e7 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -35,7 +35,6 @@ public:
   std::string const& GetConfigName() const;
 
 protected:
-
   // Add language feature flags.
   void AddFeatureFlags(std::string& flags, const std::string& lang);
 
@@ -65,10 +64,9 @@ protected:
   // Compute target-specific Fortran language flags.
   void AddFortranFlags(std::string& flags);
 
-  std::string Convert(std::string const& source,
-                      cmLocalGenerator::RelativeRoot relative,
-                      cmLocalGenerator::OutputFormat output =
-                      cmLocalGenerator::UNCHANGED);
+  std::string Convert(
+    std::string const& source, cmOutputConverter::RelativeRoot relative,
+    cmOutputConverter::OutputFormat output = cmOutputConverter::UNCHANGED);
 
   void AppendFortranFormatFlags(std::string& flags,
                                 cmSourceFile const& source);
@@ -79,10 +77,13 @@ protected:
   virtual void AddIncludeFlags(std::string& flags,
                                std::string const& lang) = 0;
 
+  void AppendOSXVerFlag(std::string& flags, const std::string& lang,
+                        const char* name, bool so);
+
   typedef std::map<std::string, std::string> ByLanguageMap;
-  std::string GetFlags(const std::string &l);
+  std::string GetFlags(const std::string& l);
   ByLanguageMap FlagsByLanguage;
-  std::string GetDefines(const std::string &l);
+  std::string GetDefines(const std::string& l);
   ByLanguageMap DefinesByLanguage;
   std::string GetIncludes(std::string const& l);
   ByLanguageMap IncludesByLanguage;
diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx
index 5bec6a1..4f21c3a 100644
--- a/Source/cmComputeComponentGraph.cxx
+++ b/Source/cmComputeComponentGraph.cxx
@@ -15,9 +15,8 @@
 
 #include <assert.h>
 
-//----------------------------------------------------------------------------
-cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input):
-  InputGraph(input)
+cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
+  : InputGraph(input)
 {
   // Identify components.
   this->Tarjan();
@@ -28,16 +27,14 @@ cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input):
   this->TransferEdges();
 }
 
-//----------------------------------------------------------------------------
 cmComputeComponentGraph::~cmComputeComponentGraph()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmComputeComponentGraph::Tarjan()
 {
   int n = static_cast<int>(this->InputGraph.size());
-  TarjanEntry entry = {0,0};
+  TarjanEntry entry = { 0, 0 };
   this->TarjanEntries.resize(0);
   this->TarjanEntries.resize(n, entry);
   this->TarjanComponents.resize(0);
@@ -45,20 +42,17 @@ void cmComputeComponentGraph::Tarjan()
   this->TarjanWalkId = 0;
   this->TarjanVisited.resize(0);
   this->TarjanVisited.resize(n, 0);
-  for(int i = 0; i < n; ++i)
-    {
+  for (int i = 0; i < n; ++i) {
     // Start a new DFS from this node if it has never been visited.
-    if(!this->TarjanVisited[i])
-      {
+    if (!this->TarjanVisited[i]) {
       assert(this->TarjanStack.empty());
       ++this->TarjanWalkId;
       this->TarjanIndex = 0;
       this->TarjanVisit(i);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeComponentGraph::TarjanVisit(int i)
 {
   // We are now visiting this node.
@@ -72,41 +66,35 @@ void cmComputeComponentGraph::TarjanVisit(int i)
 
   // Follow outgoing edges.
   EdgeList const& nl = this->InputGraph[i];
-  for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-    {
+  for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
     int j = *ni;
 
     // Ignore edges to nodes that have been reached by a previous DFS
     // walk.  Since we did not reach the current node from that walk
     // it must not belong to the same component and it has already
     // been assigned to a component.
-    if(this->TarjanVisited[j] > 0 &&
-       this->TarjanVisited[j] < this->TarjanWalkId)
-      {
+    if (this->TarjanVisited[j] > 0 &&
+        this->TarjanVisited[j] < this->TarjanWalkId) {
       continue;
-      }
+    }
 
     // Visit the destination if it has not yet been visited.
-    if(!this->TarjanVisited[j])
-      {
+    if (!this->TarjanVisited[j]) {
       this->TarjanVisit(j);
-      }
+    }
 
     // If the destination has not yet been assigned to a component,
     // check if it has a better root for the current object.
-    if(this->TarjanComponents[j] < 0)
-      {
-      if(this->TarjanEntries[this->TarjanEntries[j].Root].VisitIndex <
-         this->TarjanEntries[this->TarjanEntries[i].Root].VisitIndex)
-        {
+    if (this->TarjanComponents[j] < 0) {
+      if (this->TarjanEntries[this->TarjanEntries[j].Root].VisitIndex <
+          this->TarjanEntries[this->TarjanEntries[i].Root].VisitIndex) {
         this->TarjanEntries[i].Root = this->TarjanEntries[j].Root;
-        }
       }
     }
+  }
 
   // Check if we have found a component.
-  if(this->TarjanEntries[i].Root == i)
-    {
+  if (this->TarjanEntries[i].Root == i) {
     // Yes.  Create it.
     int c = static_cast<int>(this->Components.size());
     this->Components.push_back(NodeList());
@@ -114,8 +102,7 @@ void cmComputeComponentGraph::TarjanVisit(int i)
 
     // Populate the component list.
     int j;
-    do
-      {
+    do {
       // Get the next member of the component.
       j = this->TarjanStack.top();
       this->TarjanStack.pop();
@@ -126,34 +113,30 @@ void cmComputeComponentGraph::TarjanVisit(int i)
 
       // Store the node in its component.
       component.push_back(j);
-      } while(j != i);
+    } while (j != i);
 
     // Sort the component members for clarity.
     std::sort(component.begin(), component.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeComponentGraph::TransferEdges()
 {
   // Map inter-component edges in the original graph to edges in the
   // component graph.
   int n = static_cast<int>(this->InputGraph.size());
-  for(int i=0; i < n; ++i)
-    {
+  for (int i = 0; i < n; ++i) {
     int i_component = this->TarjanComponents[i];
     EdgeList const& nl = this->InputGraph[i];
-    for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
+    for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
       int j = *ni;
       int j_component = this->TarjanComponents[j];
-      if(i_component != j_component)
-        {
+      if (i_component != j_component) {
         // We do not attempt to combine duplicate edges, but instead
         // store the inter-component edges with suitable multiplicity.
         this->ComponentGraph[i_component].push_back(
           cmGraphEdge(j_component, ni->IsStrong()));
-        }
       }
     }
+  }
 }
diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h
index 4dbac4a..fb95f9a 100644
--- a/Source/cmComputeComponentGraph.h
+++ b/Source/cmComputeComponentGraph.h
@@ -40,20 +40,24 @@ public:
   ~cmComputeComponentGraph();
 
   /** Get the adjacency list of the component graph.  */
-  Graph const& GetComponentGraph() const
-    { return this->ComponentGraph; }
+  Graph const& GetComponentGraph() const { return this->ComponentGraph; }
   EdgeList const& GetComponentGraphEdges(int c) const
-    { return this->ComponentGraph[c]; }
+  {
+    return this->ComponentGraph[c];
+  }
 
   /** Get map from component index to original node indices.  */
   std::vector<NodeList> const& GetComponents() const
-    { return this->Components; }
-  NodeList const& GetComponent(int c) const
-    { return this->Components[c]; }
+  {
+    return this->Components;
+  }
+  NodeList const& GetComponent(int c) const { return this->Components[c]; }
 
   /** Get map from original node index to component index.  */
   std::vector<int> const& GetComponentMap() const
-    { return this->TarjanComponents; }
+  {
+    return this->TarjanComponents;
+  }
 
 private:
   void TransferEdges();
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 13098ad..2129394 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -11,13 +11,13 @@
 ============================================================================*/
 #include "cmComputeLinkDepends.h"
 
+#include "cmAlgorithms.h"
 #include "cmComputeComponentGraph.h"
-#include "cmLocalGenerator.h"
 #include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmTarget.h"
 #include "cmake.h"
-#include "cmAlgorithms.h"
 
 #include <assert.h>
 
@@ -170,21 +170,19 @@ items that we know the linker will re-use automatically (shared libs).
 
 */
 
-//----------------------------------------------------------------------------
-cmComputeLinkDepends
-::cmComputeLinkDepends(const cmGeneratorTarget* target,
-                       const std::string& config)
+cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
+                                           const std::string& config)
 {
   // Store context information.
   this->Target = target;
   this->Makefile = this->Target->Target->GetMakefile();
   this->GlobalGenerator =
-      this->Target->GetLocalGenerator()->GetGlobalGenerator();
+    this->Target->GetLocalGenerator()->GetGlobalGenerator();
   this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
 
   // The configuration being linked.
   this->HasConfig = !config.empty();
-  this->Config = (this->HasConfig)? config : std::string();
+  this->Config = (this->HasConfig) ? config : std::string();
   std::vector<std::string> debugConfigs =
     this->Makefile->GetCMakeInstance()->GetDebugConfigs();
   this->LinkType = CMP0003_ComputeLinkType(this->Config, debugConfigs);
@@ -199,20 +197,17 @@ cmComputeLinkDepends
   this->CCG = 0;
 }
 
-//----------------------------------------------------------------------------
 cmComputeLinkDepends::~cmComputeLinkDepends()
 {
   cmDeleteAll(this->InferredDependSets);
   delete this->CCG;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::SetOldLinkDirMode(bool b)
 {
   this->OldLinkDirMode = b;
 }
 
-//----------------------------------------------------------------------------
 std::vector<cmComputeLinkDepends::LinkEntry> const&
 cmComputeLinkDepends::Compute()
 {
@@ -220,23 +215,21 @@ cmComputeLinkDepends::Compute()
   this->AddDirectLinkEntries();
 
   // Complete the breadth-first search of dependencies.
-  while(!this->BFSQueue.empty())
-    {
+  while (!this->BFSQueue.empty()) {
     // Get the next entry.
     BFSEntry qe = this->BFSQueue.front();
     this->BFSQueue.pop();
 
     // Follow the entry's dependencies.
     this->FollowLinkEntry(qe);
-    }
+  }
 
   // Complete the search of shared library dependencies.
-  while(!this->SharedDepQueue.empty())
-    {
+  while (!this->SharedDepQueue.empty()) {
     // Handle the next entry.
     this->HandleSharedDependency(this->SharedDepQueue.front());
     this->SharedDepQueue.pop();
-    }
+  }
 
   // Infer dependencies of targets for which they were not known.
   this->InferDependencies();
@@ -245,16 +238,14 @@ cmComputeLinkDepends::Compute()
   this->CleanConstraintGraph();
 
   // Display the constraint graph.
-  if(this->DebugMode)
-    {
-    fprintf(stderr,
-            "---------------------------------------"
-            "---------------------------------------\n");
+  if (this->DebugMode) {
+    fprintf(stderr, "---------------------------------------"
+                    "---------------------------------------\n");
     fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
             this->Target->GetName().c_str(),
-            this->HasConfig?this->Config.c_str():"noconfig");
+            this->HasConfig ? this->Config.c_str() : "noconfig");
     this->DisplayConstraintGraph();
-    }
+  }
 
   // Compute the final ordering.
   this->OrderLinkEntires();
@@ -263,57 +254,51 @@ cmComputeLinkDepends::Compute()
   // Iterate in reverse order so we can keep only the last occurrence
   // of a shared library.
   std::set<int> emmitted;
-  for(std::vector<int>::const_reverse_iterator
-        li = this->FinalLinkOrder.rbegin(),
-        le = this->FinalLinkOrder.rend();
-      li != le; ++li)
-    {
+  for (std::vector<int>::const_reverse_iterator
+         li = this->FinalLinkOrder.rbegin(),
+         le = this->FinalLinkOrder.rend();
+       li != le; ++li) {
     int i = *li;
     LinkEntry const& e = this->EntryList[i];
     cmGeneratorTarget const* t = e.Target;
     // Entries that we know the linker will re-use do not need to be repeated.
     bool uniquify = t && t->GetType() == cmState::SHARED_LIBRARY;
-    if(!uniquify || emmitted.insert(i).second)
-      {
+    if (!uniquify || emmitted.insert(i).second) {
       this->FinalLinkEntries.push_back(e);
-      }
     }
+  }
   // Reverse the resulting order since we iterated in reverse.
   std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end());
 
   // Display the final set.
-  if(this->DebugMode)
-    {
+  if (this->DebugMode) {
     this->DisplayFinalEntries();
-    }
+  }
 
   return this->FinalLinkEntries;
 }
 
-//----------------------------------------------------------------------------
-std::map<std::string, int>::iterator
-cmComputeLinkDepends::AllocateLinkEntry(std::string const& item)
+std::map<std::string, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
+  std::string const& item)
 {
-  std::map<std::string, int>::value_type
-    index_entry(item, static_cast<int>(this->EntryList.size()));
-  std::map<std::string, int>::iterator
-    lei = this->LinkEntryIndex.insert(index_entry).first;
+  std::map<std::string, int>::value_type index_entry(
+    item, static_cast<int>(this->EntryList.size()));
+  std::map<std::string, int>::iterator lei =
+    this->LinkEntryIndex.insert(index_entry).first;
   this->EntryList.push_back(LinkEntry());
   this->InferredDependSets.push_back(0);
   this->EntryConstraintGraph.push_back(EdgeList());
   return lei;
 }
 
-//----------------------------------------------------------------------------
 int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
 {
   // Check if the item entry has already been added.
   std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item);
-  if(lei != this->LinkEntryIndex.end())
-    {
+  if (lei != this->LinkEntryIndex.end()) {
     // Yes.  We do not need to follow the item's dependencies again.
     return lei->second;
-    }
+  }
 
   // Allocate a spot for the item entry.
   lei = this->AllocateLinkEntry(item);
@@ -327,34 +312,27 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
                   item.substr(0, 10) != "-framework");
 
   // If the item has dependencies queue it to follow them.
-  if(entry.Target)
-    {
+  if (entry.Target) {
     // Target dependencies are always known.  Follow them.
-    BFSEntry qe = {index, 0};
+    BFSEntry qe = { index, 0 };
     this->BFSQueue.push(qe);
-    }
-  else
-    {
+  } else {
     // 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))
-      {
+    if (const char* val = this->Makefile->GetDefinition(var)) {
       // The item dependencies are known.  Follow them.
-      BFSEntry qe = {index, val};
+      BFSEntry qe = { index, val };
       this->BFSQueue.push(qe);
-      }
-    else if(!entry.IsFlag)
-      {
+    } else if (!entry.IsFlag) {
       // The item dependencies are not known.  We need to infer them.
       this->InferredDependSets[index] = new DependSetList;
-      }
     }
+  }
 
   return index;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
 {
   // Get this entry representation.
@@ -362,82 +340,66 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
   LinkEntry const& entry = this->EntryList[depender_index];
 
   // Follow the item's dependencies.
-  if(entry.Target)
-    {
+  if (entry.Target) {
     // Follow the target dependencies.
-    if(cmLinkInterface const* iface =
-       entry.Target->GetLinkInterface(this->Config, this->Target))
-      {
+    if (cmLinkInterface const* iface =
+          entry.Target->GetLinkInterface(this->Config, this->Target)) {
       const bool isIface =
-                      entry.Target->GetType() == cmState::INTERFACE_LIBRARY;
+        entry.Target->GetType() == cmState::INTERFACE_LIBRARY;
       // This target provides its own link interface information.
       this->AddLinkEntries(depender_index, iface->Libraries);
 
-      if (isIface)
-        {
+      if (isIface) {
         return;
-        }
+      }
 
       // Handle dependent shared libraries.
       this->FollowSharedDeps(depender_index, iface);
 
       // Support for CMP0003.
-      for(std::vector<cmLinkItem>::const_iterator
-            oi = iface->WrongConfigLibraries.begin();
-          oi != iface->WrongConfigLibraries.end(); ++oi)
-        {
+      for (std::vector<cmLinkItem>::const_iterator oi =
+             iface->WrongConfigLibraries.begin();
+           oi != iface->WrongConfigLibraries.end(); ++oi) {
         this->CheckWrongConfigItem(*oi);
-        }
       }
     }
-  else
-    {
+  } else {
     // Follow the old-style dependency list.
     this->AddVarLinkEntries(depender_index, qe.LibDepends);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeLinkDepends
-::FollowSharedDeps(int depender_index, cmLinkInterface const* iface,
-                   bool follow_interface)
+void cmComputeLinkDepends::FollowSharedDeps(int depender_index,
+                                            cmLinkInterface const* iface,
+                                            bool follow_interface)
 {
   // Follow dependencies if we have not followed them already.
-  if(this->SharedDepFollowed.insert(depender_index).second)
-    {
-    if(follow_interface)
-      {
+  if (this->SharedDepFollowed.insert(depender_index).second) {
+    if (follow_interface) {
       this->QueueSharedDependencies(depender_index, iface->Libraries);
-      }
-    this->QueueSharedDependencies(depender_index, iface->SharedDeps);
     }
+    this->QueueSharedDependencies(depender_index, iface->SharedDeps);
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeLinkDepends
-::QueueSharedDependencies(int depender_index,
-                          std::vector<cmLinkItem> const& deps)
+void cmComputeLinkDepends::QueueSharedDependencies(
+  int depender_index, std::vector<cmLinkItem> const& deps)
 {
-  for(std::vector<cmLinkItem>::const_iterator li = deps.begin();
-      li != deps.end(); ++li)
-    {
+  for (std::vector<cmLinkItem>::const_iterator li = deps.begin();
+       li != deps.end(); ++li) {
     SharedDepEntry qe;
     qe.Item = *li;
     qe.DependerIndex = depender_index;
     this->SharedDepQueue.push(qe);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
 {
   // Check if the target already has an entry.
   std::map<std::string, int>::iterator lei =
     this->LinkEntryIndex.find(dep.Item);
-  if(lei == this->LinkEntryIndex.end())
-    {
+  if (lei == this->LinkEntryIndex.end()) {
     // Allocate a spot for the item entry.
     lei = this->AllocateLinkEntry(dep.Item);
 
@@ -450,7 +412,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
     // shared library.  It may get special treatment
     // in cmComputeLinkInformation.
     entry.IsSharedDep = true;
-    }
+  }
 
   // Get the link entry for this target.
   int index = lei->second;
@@ -461,18 +423,15 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
   this->EntryConstraintGraph[dep.DependerIndex].push_back(index);
 
   // Target items may have their own dependencies.
-  if(entry.Target)
-    {
-    if(cmLinkInterface const* iface =
-       entry.Target->GetLinkInterface(this->Config, this->Target))
-      {
+  if (entry.Target) {
+    if (cmLinkInterface const* iface =
+          entry.Target->GetLinkInterface(this->Config, this->Target)) {
       // Follow public and private dependencies transitively.
       this->FollowSharedDeps(index, iface, true);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
                                              const char* value)
 {
@@ -486,235 +445,192 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
   std::vector<cmLinkItem> actual_libs;
   cmTargetLinkLibraryType llt = GENERAL_LibraryType;
   bool haveLLT = false;
-  for(std::vector<std::string>::const_iterator di = deplist.begin();
-      di != deplist.end(); ++di)
-    {
-    if(*di == "debug")
-      {
+  for (std::vector<std::string>::const_iterator di = deplist.begin();
+       di != deplist.end(); ++di) {
+    if (*di == "debug") {
       llt = DEBUG_LibraryType;
       haveLLT = true;
-      }
-    else if(*di == "optimized")
-      {
+    } else if (*di == "optimized") {
       llt = OPTIMIZED_LibraryType;
       haveLLT = true;
-      }
-    else if(*di == "general")
-      {
+    } else if (*di == "general") {
       llt = GENERAL_LibraryType;
       haveLLT = true;
-      }
-    else if(!di->empty())
-      {
+    } else if (!di->empty()) {
       // If no explicit link type was given prior to this entry then
       // check if the entry has its own link type variable.  This is
       // needed for compatibility with dependency files generated by
       // the export_library_dependencies command from CMake 2.4 and
       // lower.
-      if(!haveLLT)
-        {
+      if (!haveLLT) {
         std::string var = *di;
         var += "_LINK_TYPE";
-        if(const char* val = this->Makefile->GetDefinition(var))
-          {
-          if(strcmp(val, "debug") == 0)
-            {
+        if (const char* val = this->Makefile->GetDefinition(var)) {
+          if (strcmp(val, "debug") == 0) {
             llt = DEBUG_LibraryType;
-            }
-          else if(strcmp(val, "optimized") == 0)
-            {
+          } else if (strcmp(val, "optimized") == 0) {
             llt = OPTIMIZED_LibraryType;
-            }
           }
         }
+      }
 
       // If the library is meant for this link type then use it.
-      if(llt == GENERAL_LibraryType || llt == this->LinkType)
-        {
+      if (llt == GENERAL_LibraryType || llt == this->LinkType) {
         cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
         actual_libs.push_back(item);
-        }
-      else if(this->OldLinkDirMode)
-        {
+      } else if (this->OldLinkDirMode) {
         cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
         this->CheckWrongConfigItem(item);
-        }
+      }
 
       // Reset the link type until another explicit type is given.
       llt = GENERAL_LibraryType;
       haveLLT = false;
-      }
     }
+  }
 
   // Add the entries from this list.
   this->AddLinkEntries(depender_index, actual_libs);
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::AddDirectLinkEntries()
 {
   // Add direct link dependencies in this configuration.
   cmLinkImplementation const* impl =
     this->Target->GetLinkImplementation(this->Config);
   this->AddLinkEntries(-1, impl->Libraries);
-  for(std::vector<cmLinkItem>::const_iterator
-        wi = impl->WrongConfigLibraries.begin();
-      wi != impl->WrongConfigLibraries.end(); ++wi)
-    {
+  for (std::vector<cmLinkItem>::const_iterator wi =
+         impl->WrongConfigLibraries.begin();
+       wi != impl->WrongConfigLibraries.end(); ++wi) {
     this->CheckWrongConfigItem(*wi);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 template <typename T>
-void
-cmComputeLinkDepends::AddLinkEntries(
-  int depender_index, std::vector<T> const& libs)
+void cmComputeLinkDepends::AddLinkEntries(int depender_index,
+                                          std::vector<T> const& libs)
 {
   // Track inferred dependency sets implied by this list.
   std::map<int, DependSet> dependSets;
 
   // Loop over the libraries linked directly by the depender.
-  for(typename std::vector<T>::const_iterator li = libs.begin();
-      li != libs.end(); ++li)
-    {
+  for (typename std::vector<T>::const_iterator li = libs.begin();
+       li != libs.end(); ++li) {
     // Skip entries that will resolve to the target getting linked or
     // are empty.
     cmLinkItem const& item = *li;
-    if(item == this->Target->GetName() || item.empty())
-      {
+    if (item == this->Target->GetName() || item.empty()) {
       continue;
-      }
+    }
 
     // Add a link entry for this item.
     int dependee_index = this->AddLinkEntry(*li);
 
     // The dependee must come after the depender.
-    if(depender_index >= 0)
-      {
+    if (depender_index >= 0) {
       this->EntryConstraintGraph[depender_index].push_back(dependee_index);
-      }
-    else
-      {
+    } else {
       // This is a direct dependency of the target being linked.
       this->OriginalEntries.push_back(dependee_index);
-      }
+    }
 
     // Update the inferred dependencies for earlier items.
-    for(std::map<int, DependSet>::iterator dsi = dependSets.begin();
-        dsi != dependSets.end(); ++dsi)
-      {
+    for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
+         dsi != dependSets.end(); ++dsi) {
       // Add this item to the inferred dependencies of other items.
       // Target items are never inferred dependees because unknown
       // items are outside libraries that should not be depending on
       // targets.
-      if(!this->EntryList[dependee_index].Target &&
-         !this->EntryList[dependee_index].IsFlag &&
-         dependee_index != dsi->first)
-        {
+      if (!this->EntryList[dependee_index].Target &&
+          !this->EntryList[dependee_index].IsFlag &&
+          dependee_index != dsi->first) {
         dsi->second.insert(dependee_index);
-        }
       }
+    }
 
     // If this item needs to have dependencies inferred, do so.
-    if(this->InferredDependSets[dependee_index])
-      {
+    if (this->InferredDependSets[dependee_index]) {
       // Make sure an entry exists to hold the set for the item.
       dependSets[dependee_index];
-      }
     }
+  }
 
   // Store the inferred dependency sets discovered for this list.
-  for(std::map<int, DependSet>::iterator dsi = dependSets.begin();
-      dsi != dependSets.end(); ++dsi)
-    {
+  for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
+       dsi != dependSets.end(); ++dsi) {
     this->InferredDependSets[dsi->first]->push_back(dsi->second);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmGeneratorTarget const*
-cmComputeLinkDepends::FindTargetToLink(int depender_index,
-                                       const std::string& name)
+cmGeneratorTarget const* cmComputeLinkDepends::FindTargetToLink(
+  int depender_index, const std::string& name)
 {
   // Look for a target in the scope of the depender.
   cmGeneratorTarget const* from = this->Target;
-  if(depender_index >= 0)
-    {
-    if(cmGeneratorTarget const* depender =
-       this->EntryList[depender_index].Target)
-      {
+  if (depender_index >= 0) {
+    if (cmGeneratorTarget const* depender =
+          this->EntryList[depender_index].Target) {
       from = depender;
-      }
     }
+  }
   return from->FindTargetToLink(name);
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::InferDependencies()
 {
   // The inferred dependency sets for each item list the possible
   // dependencies.  The intersection of the sets for one item form its
   // inferred dependencies.
-  for(unsigned int depender_index=0;
-      depender_index < this->InferredDependSets.size(); ++depender_index)
-    {
+  for (unsigned int depender_index = 0;
+       depender_index < this->InferredDependSets.size(); ++depender_index) {
     // Skip items for which dependencies do not need to be inferred or
     // for which the inferred dependency sets are empty.
     DependSetList* sets = this->InferredDependSets[depender_index];
-    if(!sets || sets->empty())
-      {
+    if (!sets || sets->empty()) {
       continue;
-      }
+    }
 
     // Intersect the sets for this item.
     DependSetList::const_iterator i = sets->begin();
     DependSet common = *i;
-    for(++i; i != sets->end(); ++i)
-      {
+    for (++i; i != sets->end(); ++i) {
       DependSet intersection;
-      std::set_intersection
-        (common.begin(), common.end(), i->begin(), i->end(),
-         std::inserter(intersection, intersection.begin()));
+      std::set_intersection(common.begin(), common.end(), i->begin(), i->end(),
+                            std::inserter(intersection, intersection.begin()));
       common = intersection;
-      }
+    }
 
     // Add the inferred dependencies to the graph.
     cmGraphEdgeList& edges = this->EntryConstraintGraph[depender_index];
     edges.insert(edges.end(), common.begin(), common.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::CleanConstraintGraph()
 {
-  for(Graph::iterator i = this->EntryConstraintGraph.begin();
-      i != this->EntryConstraintGraph.end(); ++i)
-    {
+  for (Graph::iterator i = this->EntryConstraintGraph.begin();
+       i != this->EntryConstraintGraph.end(); ++i) {
     // Sort the outgoing edges for each graph node so that the
     // original order will be preserved as much as possible.
     std::sort(i->begin(), i->end());
 
     // Make the edge list unique.
     i->erase(std::unique(i->begin(), i->end()), i->end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::DisplayConstraintGraph()
 {
   // Display the graph nodes and their edges.
   std::ostringstream e;
-  for(unsigned int i=0; i < this->EntryConstraintGraph.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->EntryConstraintGraph.size(); ++i) {
     EdgeList const& nl = this->EntryConstraintGraph[i];
     e << "item " << i << " is [" << this->EntryList[i].Item << "]\n";
     e << cmWrap("  item ", nl, " must follow it", "\n") << "\n";
-    }
+  }
   fprintf(stderr, "%s\n", e.str().c_str());
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::OrderLinkEntires()
 {
   // Compute the DAG of strongly connected components.  The algorithm
@@ -734,73 +650,60 @@ void cmComputeLinkDepends::OrderLinkEntires()
   this->ComponentOrderId = n;
   // Run in reverse order so the topological order will preserve the
   // original order where there are no constraints.
-  for(int c = n-1; c >= 0; --c)
-    {
+  for (int c = n - 1; c >= 0; --c) {
     this->VisitComponent(c);
-    }
+  }
 
   // Display the component graph.
-  if(this->DebugMode)
-    {
+  if (this->DebugMode) {
     this->DisplayComponents();
-    }
+  }
 
   // Start with the original link line.
-  for(std::vector<int>::const_iterator i = this->OriginalEntries.begin();
-      i != this->OriginalEntries.end(); ++i)
-    {
+  for (std::vector<int>::const_iterator i = this->OriginalEntries.begin();
+       i != this->OriginalEntries.end(); ++i) {
     this->VisitEntry(*i);
-    }
+  }
 
   // Now explore anything left pending.  Since the component graph is
   // guaranteed to be acyclic we know this will terminate.
-  while(!this->PendingComponents.empty())
-    {
+  while (!this->PendingComponents.empty()) {
     // Visit one entry from the first pending component.  The visit
     // logic will update the pending components accordingly.  Since
     // the pending components are kept in topological order this will
     // not repeat one.
     int e = *this->PendingComponents.begin()->second.Entries.begin();
     this->VisitEntry(e);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeLinkDepends::DisplayComponents()
+void cmComputeLinkDepends::DisplayComponents()
 {
   fprintf(stderr, "The strongly connected components are:\n");
   std::vector<NodeList> const& components = this->CCG->GetComponents();
-  for(unsigned int c=0; c < components.size(); ++c)
-    {
+  for (unsigned int c = 0; c < components.size(); ++c) {
     fprintf(stderr, "Component (%u):\n", c);
     NodeList const& nl = components[c];
-    for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
+    for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
       int i = *ni;
-      fprintf(stderr, "  item %d [%s]\n", i,
-              this->EntryList[i].Item.c_str());
-      }
+      fprintf(stderr, "  item %d [%s]\n", i, this->EntryList[i].Item.c_str());
+    }
     EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
-    for(EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi)
-      {
+    for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
       int i = *oi;
       fprintf(stderr, "  followed by Component (%d)\n", i);
-      }
-    fprintf(stderr, "  topo order index %d\n",
-            this->ComponentOrder[c]);
     }
+    fprintf(stderr, "  topo order index %d\n", this->ComponentOrder[c]);
+  }
   fprintf(stderr, "\n");
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::VisitComponent(unsigned int c)
 {
   // Check if the node has already been visited.
-  if(this->ComponentVisited[c])
-    {
+  if (this->ComponentVisited[c]) {
     return;
-    }
+  }
 
   // We are now visiting this component so mark it.
   this->ComponentVisited[c] = 1;
@@ -809,17 +712,15 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c)
   // Run in reverse order so the topological order will preserve the
   // original order where there are no constraints.
   EdgeList const& nl = this->CCG->GetComponentGraphEdges(c);
-  for(EdgeList::const_reverse_iterator ni = nl.rbegin();
-      ni != nl.rend(); ++ni)
-    {
+  for (EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
+       ++ni) {
     this->VisitComponent(*ni);
-    }
+  }
 
   // Assign an ordering id to this component.
   this->ComponentOrder[c] = --this->ComponentOrderId;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::VisitEntry(int index)
 {
   // Include this entry on the link line.
@@ -830,67 +731,54 @@ void cmComputeLinkDepends::VisitEntry(int index)
   int component = this->CCG->GetComponentMap()[index];
   std::map<int, PendingComponent>::iterator mi =
     this->PendingComponents.find(this->ComponentOrder[component]);
-  if(mi != this->PendingComponents.end())
-    {
+  if (mi != this->PendingComponents.end()) {
     // The entry is in an already pending component.
     PendingComponent& pc = mi->second;
 
     // Remove the entry from those pending in its component.
     pc.Entries.erase(index);
-    if(pc.Entries.empty())
-      {
+    if (pc.Entries.empty()) {
       // The complete component has been seen since it was last needed.
       --pc.Count;
 
-      if(pc.Count == 0)
-        {
+      if (pc.Count == 0) {
         // The component has been completed.
         this->PendingComponents.erase(mi);
         completed = true;
-        }
-      else
-        {
+      } else {
         // The whole component needs to be seen again.
         NodeList const& nl = this->CCG->GetComponent(component);
         assert(nl.size() > 1);
         pc.Entries.insert(nl.begin(), nl.end());
-        }
       }
     }
-  else
-    {
+  } else {
     // The entry is not in an already pending component.
     NodeList const& nl = this->CCG->GetComponent(component);
-    if(nl.size() > 1)
-      {
+    if (nl.size() > 1) {
       // This is a non-trivial component.  It is now pending.
       PendingComponent& pc = this->MakePendingComponent(component);
 
       // The starting entry has already been seen.
       pc.Entries.erase(index);
-      }
-    else
-      {
+    } else {
       // This is a trivial component, so it is already complete.
       completed = true;
-      }
     }
+  }
 
   // If the entry completed a component, the component's dependencies
   // are now pending.
-  if(completed)
-    {
+  if (completed) {
     EdgeList const& ol = this->CCG->GetComponentGraphEdges(component);
-    for(EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi)
-      {
+    for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
       // This entire component is now pending no matter whether it has
       // been partially seen already.
       this->MakePendingComponent(*oi);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmComputeLinkDepends::PendingComponent&
 cmComputeLinkDepends::MakePendingComponent(unsigned int component)
 {
@@ -900,13 +788,10 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
   pc.Id = component;
   NodeList const& nl = this->CCG->GetComponent(component);
 
-  if(nl.size() == 1)
-    {
+  if (nl.size() == 1) {
     // Trivial components need be seen only once.
     pc.Count = 1;
-    }
-  else
-    {
+  } else {
     // This is a non-trivial strongly connected component of the
     // original graph.  It consists of two or more libraries
     // (archives) that mutually require objects from one another.  In
@@ -920,7 +805,7 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
     // this component will come first which minimizes the number of
     // repeats needed.
     pc.Count = this->ComputeComponentCount(nl);
-    }
+  }
 
   // Store the entries to be seen.
   pc.Entries.insert(nl.begin(), nl.end());
@@ -928,60 +813,47 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
   return pc;
 }
 
-//----------------------------------------------------------------------------
 int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
 {
-  int count = 2;
-  for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-    {
-    if(cmGeneratorTarget const* target = this->EntryList[*ni].Target)
-      {
-      if(cmLinkInterface const* iface =
-         target->GetLinkInterface(this->Config, this->Target))
-        {
-        if(iface->Multiplicity > count)
-          {
+  unsigned int count = 2;
+  for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
+    if (cmGeneratorTarget const* target = this->EntryList[*ni].Target) {
+      if (cmLinkInterface const* iface =
+            target->GetLinkInterface(this->Config, this->Target)) {
+        if (iface->Multiplicity > count) {
           count = iface->Multiplicity;
-          }
         }
       }
     }
+  }
   return count;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::DisplayFinalEntries()
 {
   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)
-      {
+  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().c_str());
-      }
-    else
-      {
+    } else {
       fprintf(stderr, "  item [%s]\n", lei->Item.c_str());
-      }
     }
+  }
   fprintf(stderr, "\n");
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkDepends::CheckWrongConfigItem(cmLinkItem const& item)
 {
-  if(!this->OldLinkDirMode)
-    {
+  if (!this->OldLinkDirMode) {
     return;
-    }
+  }
 
   // For CMake 2.4 bug-compatibility we need to consider the output
   // directories of targets linked in another configuration as link
   // directories.
-  if(item.Target && !item.Target->IsImported())
-    {
+  if (item.Target && !item.Target->IsImported()) {
     this->OldWrongConfigItems.insert(item.Target);
-    }
+  }
 }
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index f10e4e4..6aa40c3 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -13,9 +13,9 @@
 #define cmComputeLinkDepends_h
 
 #include "cmStandardIncludes.h"
-#include "cmLinkItem.h"
 
 #include "cmGraphAdjacencyList.h"
+#include "cmLinkItem.h"
 
 #include <queue>
 
@@ -42,10 +42,20 @@ public:
     cmGeneratorTarget const* Target;
     bool IsSharedDep;
     bool IsFlag;
-    LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {}
-    LinkEntry(LinkEntry const& r):
-      Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep),
-      IsFlag(r.IsFlag) {}
+    LinkEntry()
+      : Item()
+      , Target(0)
+      , IsSharedDep(false)
+      , IsFlag(false)
+    {
+    }
+    LinkEntry(LinkEntry const& r)
+      : Item(r.Item)
+      , Target(r.Target)
+      , IsSharedDep(r.IsSharedDep)
+      , IsFlag(r.IsFlag)
+    {
+    }
   };
 
   typedef std::vector<LinkEntry> EntryVector;
@@ -53,10 +63,11 @@ public:
 
   void SetOldLinkDirMode(bool b);
   std::set<cmGeneratorTarget const*> const& GetOldWrongConfigItems() const
-    { return this->OldWrongConfigItems; }
+  {
+    return this->OldWrongConfigItems;
+  }
 
 private:
-
   // Context information.
   cmGeneratorTarget const* Target;
   cmMakefile* Makefile;
@@ -65,13 +76,13 @@ private:
   std::string Config;
   EntryVector FinalLinkEntries;
 
-  std::map<std::string, int>::iterator
-  AllocateLinkEntry(std::string const& item);
+  std::map<std::string, int>::iterator AllocateLinkEntry(
+    std::string const& item);
   int AddLinkEntry(cmLinkItem const& item);
   void AddVarLinkEntries(int depender_index, const char* value);
   void AddDirectLinkEntries();
   template <typename T>
-    void AddLinkEntries(int depender_index, std::vector<T> const& libs);
+  void AddLinkEntries(int depender_index, std::vector<T> const& libs);
   cmGeneratorTarget const* FindTargetToLink(int depender_index,
                                             const std::string& name);
 
@@ -98,16 +109,19 @@ private:
   };
   std::queue<SharedDepEntry> SharedDepQueue;
   std::set<int> SharedDepFollowed;
-  void FollowSharedDeps(int depender_index,
-                        cmLinkInterface const* iface,
+  void FollowSharedDeps(int depender_index, cmLinkInterface const* iface,
                         bool follow_interface = false);
   void QueueSharedDependencies(int depender_index,
                                std::vector<cmLinkItem> const& deps);
   void HandleSharedDependency(SharedDepEntry const& dep);
 
   // Dependency inferral for each link item.
-  struct DependSet: public std::set<int> {};
-  struct DependSetList: public std::vector<DependSet> {};
+  struct DependSet : public std::set<int>
+  {
+  };
+  struct DependSetList : public std::vector<DependSet>
+  {
+  };
   std::vector<DependSetList*> InferredDependSets;
   void InferDependencies();
 
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 50d8324..e1a7bee 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -14,14 +14,14 @@
 #include "cmComputeLinkDepends.h"
 #include "cmOrderDirectories.h"
 
-#include "cmLocalGenerator.h"
+#include "cmAlgorithms.h"
+#include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
-#include "cmState.h"
-#include "cmOutputConverter.h"
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmGeneratorTarget.h"
+#include "cmOutputConverter.h"
+#include "cmState.h"
 #include "cmake.h"
-#include "cmAlgorithms.h"
 
 #include <ctype.h>
 
@@ -240,46 +240,42 @@ because this need be done only for shared libraries without soname-s.
 
 */
 
-//----------------------------------------------------------------------------
-cmComputeLinkInformation
-::cmComputeLinkInformation(const cmGeneratorTarget* target,
-                           const std::string& config)
+cmComputeLinkInformation::cmComputeLinkInformation(
+  const cmGeneratorTarget* target, const std::string& config)
 {
   // Store context information.
   this->Target = target;
   this->Makefile = this->Target->Target->GetMakefile();
   this->GlobalGenerator =
-      this->Target->GetLocalGenerator()->GetGlobalGenerator();
+    this->Target->GetLocalGenerator()->GetGlobalGenerator();
   this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
 
   // Check whether to recognize OpenBSD-style library versioned names.
-  this->OpenBSD = this->Makefile->GetState()
-            ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
+  this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+    "FIND_LIBRARY_USE_OPENBSD_VERSIONING");
 
   // The configuration being linked.
   this->Config = config;
 
   // Allocate internals.
-  this->OrderLinkerSearchPath =
-    new cmOrderDirectories(this->GlobalGenerator, target,
-                           "linker search path");
-  this->OrderRuntimeSearchPath =
-    new cmOrderDirectories(this->GlobalGenerator, target,
-                           "runtime search path");
+  this->OrderLinkerSearchPath = new cmOrderDirectories(
+    this->GlobalGenerator, target, "linker search path");
+  this->OrderRuntimeSearchPath = new cmOrderDirectories(
+    this->GlobalGenerator, target, "runtime search path");
   this->OrderDependentRPath = 0;
 
   // Get the language used for linking this target.
   this->LinkLanguage = this->Target->GetLinkerLanguage(config);
-  if(this->LinkLanguage.empty())
-    {
+  if (this->LinkLanguage.empty()) {
     // The Compute method will do nothing, so skip the rest of the
     // initialization.
     return;
-    }
+  }
 
   // Check whether we should use an import library for linking a target.
   this->UseImportLibrary =
-    this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false;
+    this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX") ? true
+                                                                 : false;
 
   // Check whether we should skip dependencies on shared library files.
   this->LinkDependsNoShared =
@@ -289,14 +285,13 @@ cmComputeLinkInformation
   // to use when creating a plugin (module) that obtains symbols from
   // the program that will load it.
   this->LoaderFlag = 0;
-  if(!this->UseImportLibrary &&
-     this->Target->GetType() == cmState::MODULE_LIBRARY)
-    {
+  if (!this->UseImportLibrary &&
+      this->Target->GetType() == cmState::MODULE_LIBRARY) {
     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);
-    }
+  }
 
   // Get options needed to link libraries.
   this->LibLinkFlag =
@@ -308,11 +303,10 @@ cmComputeLinkInformation
 
   // Get options needed to specify RPATHs.
   this->RuntimeUseChrpath = false;
-  if(this->Target->GetType() != cmState::STATIC_LIBRARY)
-    {
+  if (this->Target->GetType() != cmState::STATIC_LIBRARY) {
     const char* tType =
-      ((this->Target->GetType() == cmState::EXECUTABLE)?
-       "EXECUTABLE" : "SHARED_LIBRARY");
+      ((this->Target->GetType() == cmState::EXECUTABLE) ? "EXECUTABLE"
+                                                        : "SHARED_LIBRARY");
     std::string rtVar = "CMAKE_";
     rtVar += tType;
     rtVar += "_RUNTIME_";
@@ -321,9 +315,8 @@ cmComputeLinkInformation
     std::string rtSepVar = rtVar + "_SEP";
     this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar);
     this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar);
-    this->RuntimeAlways =
-      (this->Makefile->
-       GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
+    this->RuntimeAlways = (this->Makefile->GetSafeDefinition(
+      "CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
 
     this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config);
 
@@ -334,14 +327,14 @@ cmComputeLinkInformation
     rlVar += this->LinkLanguage;
     rlVar += "_FLAG";
     this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar);
-    }
+  }
 
   // Check if we need to include the runtime search path at link time.
   {
-  std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
-  var += this->LinkLanguage;
-  var += "_WITH_RUNTIME_PATH";
-  this->LinkWithRuntimePath = this->Makefile->IsOn(var);
+    std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
+    var += this->LinkLanguage;
+    var += "_WITH_RUNTIME_PATH";
+    this->LinkWithRuntimePath = this->Makefile->IsOn(var);
   }
 
   // Check the platform policy for missing soname case.
@@ -359,41 +352,30 @@ cmComputeLinkInformation
 
   // Choose a mode for dealing with shared library dependencies.
   this->SharedDependencyMode = SharedDepModeNone;
-  if(this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_FILES"))
-    {
+  if (this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_FILES")) {
     this->SharedDependencyMode = SharedDepModeLink;
-    }
-  else if(this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_DIRS"))
-    {
+  } else if (this->Makefile->IsOn("CMAKE_LINK_DEPENDENT_LIBRARY_DIRS")) {
     this->SharedDependencyMode = SharedDepModeLibDir;
-    }
-  else if(!this->RPathLinkFlag.empty())
-    {
+  } else if (!this->RPathLinkFlag.empty()) {
     this->SharedDependencyMode = SharedDepModeDir;
-    this->OrderDependentRPath =
-      new cmOrderDirectories(this->GlobalGenerator, target,
-                             "dependent library path");
-    }
+    this->OrderDependentRPath = new cmOrderDirectories(
+      this->GlobalGenerator, target, "dependent library path");
+  }
 
   // Add the search path entries requested by the user to path ordering.
-  this->OrderLinkerSearchPath
-    ->AddUserDirectories(this->Target->GetLinkDirectories());
-  this->OrderRuntimeSearchPath
-    ->AddUserDirectories(this->Target->GetLinkDirectories());
+  this->OrderLinkerSearchPath->AddUserDirectories(
+    this->Target->GetLinkDirectories());
+  this->OrderRuntimeSearchPath->AddUserDirectories(
+    this->Target->GetLinkDirectories());
 
   // Set up the implicit link directories.
   this->LoadImplicitLinkInfo();
-  this->OrderLinkerSearchPath
-    ->SetImplicitDirectories(this->ImplicitLinkDirs);
-  this->OrderRuntimeSearchPath
-    ->SetImplicitDirectories(this->ImplicitLinkDirs);
-  if(this->OrderDependentRPath)
-    {
-    this->OrderDependentRPath
-      ->SetImplicitDirectories(this->ImplicitLinkDirs);
-    this->OrderDependentRPath
-      ->AddLanguageDirectories(this->RuntimeLinkDirs);
-    }
+  this->OrderLinkerSearchPath->SetImplicitDirectories(this->ImplicitLinkDirs);
+  this->OrderRuntimeSearchPath->SetImplicitDirectories(this->ImplicitLinkDirs);
+  if (this->OrderDependentRPath) {
+    this->OrderDependentRPath->SetImplicitDirectories(this->ImplicitLinkDirs);
+    this->OrderDependentRPath->AddLanguageDirectories(this->RuntimeLinkDirs);
+  }
 
   // Decide whether to enable compatible library search path mode.
   // There exists code that effectively does
@@ -408,21 +390,17 @@ cmComputeLinkInformation
   // containing libraries linked with a full path to the -L path.
   this->OldLinkDirMode =
     this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW;
-  if(this->OldLinkDirMode)
-    {
+  if (this->OldLinkDirMode) {
     // Construct a mask to not bother with this behavior for link
     // directories already specified by the user.
-    std::vector<std::string> const& dirs =
-        this->Target->GetLinkDirectories();
+    std::vector<std::string> const& dirs = this->Target->GetLinkDirectories();
     this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
-    }
+  }
 
-  this->CMP0060Warn =
-    this->Makefile->PolicyOptionalWarningEnabled(
-      "CMAKE_POLICY_WARNING_CMP0060");
+  this->CMP0060Warn = this->Makefile->PolicyOptionalWarningEnabled(
+    "CMAKE_POLICY_WARNING_CMP0060");
 }
 
-//----------------------------------------------------------------------------
 cmComputeLinkInformation::~cmComputeLinkInformation()
 {
   delete this->OrderLinkerSearchPath;
@@ -430,72 +408,62 @@ cmComputeLinkInformation::~cmComputeLinkInformation()
   delete this->OrderDependentRPath;
 }
 
-//----------------------------------------------------------------------------
 cmComputeLinkInformation::ItemVector const&
 cmComputeLinkInformation::GetItems()
 {
   return this->Items;
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> const& cmComputeLinkInformation::GetDirectories()
 {
   return this->OrderLinkerSearchPath->GetOrderedDirectories();
 }
 
-//----------------------------------------------------------------------------
 std::string cmComputeLinkInformation::GetRPathLinkString()
 {
   // If there is no separate linker runtime search flag (-rpath-link)
   // there is no reason to compute a string.
-  if(!this->OrderDependentRPath)
-    {
+  if (!this->OrderDependentRPath) {
     return "";
-    }
+  }
 
   // Construct the linker runtime search path.
   return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":");
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> const& cmComputeLinkInformation::GetDepends()
 {
   return this->Depends;
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
 {
   return this->FrameworkPaths;
 }
 
-//----------------------------------------------------------------------------
 const std::set<const cmGeneratorTarget*>&
 cmComputeLinkInformation::GetSharedLibrariesLinked()
 {
   return this->SharedLibrariesLinked;
 }
 
-//----------------------------------------------------------------------------
 bool cmComputeLinkInformation::Compute()
 {
   // Skip targets that do not link.
-  if(!(this->Target->GetType() == cmState::EXECUTABLE ||
-       this->Target->GetType() == cmState::SHARED_LIBRARY ||
-       this->Target->GetType() == cmState::MODULE_LIBRARY ||
-       this->Target->GetType() == cmState::STATIC_LIBRARY))
-    {
+  if (!(this->Target->GetType() == cmState::EXECUTABLE ||
+        this->Target->GetType() == cmState::SHARED_LIBRARY ||
+        this->Target->GetType() == cmState::MODULE_LIBRARY ||
+        this->Target->GetType() == cmState::STATIC_LIBRARY)) {
     return false;
-    }
+  }
 
   // We require a link language for the target.
-  if(this->LinkLanguage.empty())
-    {
-    cmSystemTools::
-      Error("CMake can not determine linker language for target: ",
-            this->Target->GetName().c_str());
+  if (this->LinkLanguage.empty()) {
+    cmSystemTools::Error(
+      "CMake can not determine linker language for target: ",
+      this->Target->GetName().c_str());
     return false;
-    }
+  }
 
   // Compute the ordered link line items.
   cmComputeLinkDepends cld(this->Target, this->Config);
@@ -503,65 +471,54 @@ bool cmComputeLinkInformation::Compute()
   cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
 
   // Add the link line items.
-  for(cmComputeLinkDepends::EntryVector::const_iterator
-        lei = linkEntries.begin();
-      lei != linkEntries.end(); ++lei)
-    {
-    if(lei->IsSharedDep)
-      {
+  for (cmComputeLinkDepends::EntryVector::const_iterator lei =
+         linkEntries.begin();
+       lei != linkEntries.end(); ++lei) {
+    if (lei->IsSharedDep) {
       this->AddSharedDepItem(lei->Item, lei->Target);
-      }
-    else
-      {
+    } else {
       this->AddItem(lei->Item, lei->Target);
-      }
     }
+  }
 
   // Restore the target link type so the correct system runtime
   // libraries are found.
-  const char* lss =
-      this->Target->GetProperty("LINK_SEARCH_END_STATIC");
-  if(cmSystemTools::IsOn(lss))
-    {
+  const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
+  if (cmSystemTools::IsOn(lss)) {
     this->SetCurrentLinkType(LinkStatic);
-    }
-  else
-    {
+  } else {
     this->SetCurrentLinkType(this->StartLinkType);
-    }
+  }
 
   // Finish listing compatibility paths.
-  if(this->OldLinkDirMode)
-    {
+  if (this->OldLinkDirMode) {
     // For CMake 2.4 bug-compatibility we need to consider the output
     // directories of targets linked in another configuration as link
     // directories.
     std::set<cmGeneratorTarget const*> const& wrongItems =
-        cld.GetOldWrongConfigItems();
-    for(std::set<cmGeneratorTarget const*>::const_iterator i =
-        wrongItems.begin(); i != wrongItems.end(); ++i)
-      {
+      cld.GetOldWrongConfigItems();
+    for (std::set<cmGeneratorTarget const*>::const_iterator i =
+           wrongItems.begin();
+         i != wrongItems.end(); ++i) {
       cmGeneratorTarget const* tgt = *i;
-      bool implib =
-        (this->UseImportLibrary &&
-         (tgt->GetType() == cmState::SHARED_LIBRARY));
-      std::string lib = tgt->GetFullPath(this->Config , implib, true);
+      bool implib = (this->UseImportLibrary &&
+                     (tgt->GetType() == cmState::SHARED_LIBRARY));
+      std::string lib = tgt->GetFullPath(this->Config, implib, true);
       this->OldLinkDirItems.push_back(lib);
-      }
     }
+  }
 
   // Finish setting up linker search directories.
-  if(!this->FinishLinkerSearchDirectories())
-    {
+  if (!this->FinishLinkerSearchDirectories()) {
     return false;
-    }
+  }
 
   // Add implicit language runtime libraries and directories.
   this->AddImplicitLinkInfo();
 
-  if (!this->CMP0060WarnItems.empty())
-    {
+  if (!this->CMP0060WarnItems.empty()) {
     std::ostringstream w;
+    /* clang-format off */
     w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0060) << "\n"
       "Some library files are in directories implicitly searched by "
       "the linker when invoked for " << this->LinkLanguage << ":\n"
@@ -570,31 +527,28 @@ bool cmComputeLinkInformation::Compute()
       "link line will ask the linker to search for these by library "
       "name."
       ;
+    /* clang-format on */
     this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
                                       this->Target->GetBacktrace());
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddImplicitLinkInfo()
 {
   // The link closure lists all languages whose implicit info is needed.
   cmGeneratorTarget::LinkClosure const* lc =
-      this->Target->GetLinkClosure(this->Config);
-  for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
-      li != lc->Languages.end(); ++li)
-    {
+    this->Target->GetLinkClosure(this->Config);
+  for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
+       li != lc->Languages.end(); ++li) {
     // Skip those of the linker language.  They are implicit.
-    if(*li != this->LinkLanguage)
-      {
+    if (*li != this->LinkLanguage) {
       this->AddImplicitLinkInfo(*li);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
 {
   // Add libraries for this language that are not implied by the
@@ -602,212 +556,170 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
   std::string libVar = "CMAKE_";
   libVar += lang;
   libVar += "_IMPLICIT_LINK_LIBRARIES";
-  if(const char* libs = this->Makefile->GetDefinition(libVar))
-    {
+  if (const char* libs = this->Makefile->GetDefinition(libVar)) {
     std::vector<std::string> libsVec;
     cmSystemTools::ExpandListArgument(libs, libsVec);
-    for(std::vector<std::string>::const_iterator i = libsVec.begin();
-        i != libsVec.end(); ++i)
-      {
-      if(this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end())
-        {
+    for (std::vector<std::string>::const_iterator i = libsVec.begin();
+         i != libsVec.end(); ++i) {
+      if (this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) {
         this->AddItem(*i, 0);
-        }
       }
     }
+  }
 
   // Add linker search paths for this language that are not
   // implied by the linker language.
   std::string dirVar = "CMAKE_";
   dirVar += lang;
   dirVar += "_IMPLICIT_LINK_DIRECTORIES";
-  if(const char* dirs = this->Makefile->GetDefinition(dirVar))
-    {
+  if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
     std::vector<std::string> dirsVec;
     cmSystemTools::ExpandListArgument(dirs, dirsVec);
     this->OrderLinkerSearchPath->AddLanguageDirectories(dirsVec);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddItem(std::string const& item,
                                        cmGeneratorTarget const* tgt)
 {
   // Compute the proper name to use to link this library.
   const std::string& config = this->Config;
   bool impexe = (tgt && tgt->IsExecutableWithExports());
-  if(impexe && !this->UseImportLibrary && !this->LoaderFlag)
-    {
+  if (impexe && !this->UseImportLibrary && !this->LoaderFlag) {
     // Skip linking to executables on platforms with no import
     // libraries or loader flags.
     return;
-    }
+  }
 
-  if(tgt && tgt->IsLinkable())
-    {
+  if (tgt && tgt->IsLinkable()) {
     // This is a CMake target.  Ask the target for its real name.
-    if(impexe && this->LoaderFlag)
-      {
+    if (impexe && this->LoaderFlag) {
       // This link item is an executable that may provide symbols
       // used by this target.  A special flag is needed on this
       // platform.  Add it now.
       std::string linkItem;
       linkItem = this->LoaderFlag;
 
-      std::string exe = tgt->GetFullPath(config, this->UseImportLibrary,
-                                         true);
+      std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true);
       linkItem += exe;
       this->Items.push_back(Item(linkItem, true, tgt));
       this->Depends.push_back(exe);
-      }
-    else if(tgt->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    } else if (tgt->GetType() == cmState::INTERFACE_LIBRARY) {
       // Add the interface library as an item so it can be considered as part
       // of COMPATIBLE_INTERFACE_ enforcement.  The generators will ignore
       // this for the actual link line.
-      this->Items.push_back(Item(std::string(), true, tgt));
-      }
-    else
-      {
+      this->Items.push_back(Item(std::string(), false, tgt));
+    } else {
       // Decide whether to use an import library.
-      bool implib =
-        (this->UseImportLibrary &&
-         (impexe || tgt->GetType() == cmState::SHARED_LIBRARY));
+      bool implib = (this->UseImportLibrary &&
+                     (impexe || tgt->GetType() == cmState::SHARED_LIBRARY));
 
       // Pass the full path to the target file.
       std::string lib = tgt->GetFullPath(config, implib, true);
-      if(!this->LinkDependsNoShared ||
-         tgt->GetType() != cmState::SHARED_LIBRARY)
-        {
+      if (!this->LinkDependsNoShared ||
+          tgt->GetType() != cmState::SHARED_LIBRARY) {
         this->Depends.push_back(lib);
-        }
+      }
 
       this->AddTargetItem(lib, tgt);
       this->AddLibraryRuntimeInfo(lib, tgt);
-      }
     }
-  else
-    {
+  } else {
     // This is not a CMake target.  Use the name given.
-    if(cmSystemTools::FileIsFullPath(item.c_str()))
-      {
-      if(cmSystemTools::FileIsDirectory(item))
-        {
+    if (cmSystemTools::FileIsFullPath(item.c_str())) {
+      if (cmSystemTools::FileIsDirectory(item)) {
         // This is a directory.
         this->AddDirectoryItem(item);
-        }
-      else
-        {
+      } else {
         // Use the full path given to the library file.
         this->Depends.push_back(item);
         this->AddFullItem(item);
         this->AddLibraryRuntimeInfo(item);
-        }
       }
-    else
-      {
+    } else {
       // This is a library or option specified by the user.
       this->AddUserItem(item, true);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
                                                 const cmGeneratorTarget* tgt)
 {
   // If dropping shared library dependencies, ignore them.
-  if(this->SharedDependencyMode == SharedDepModeNone)
-    {
+  if (this->SharedDependencyMode == SharedDepModeNone) {
     return;
-    }
+  }
 
   // The user may have incorrectly named an item.  Skip items that are
   // not full paths to shared libraries.
-  if(tgt)
-    {
+  if (tgt) {
     // The target will provide a full path.  Make sure it is a shared
     // library.
-    if(tgt->GetType() != cmState::SHARED_LIBRARY)
-      {
+    if (tgt->GetType() != cmState::SHARED_LIBRARY) {
       return;
-      }
     }
-  else
-    {
+  } else {
     // Skip items that are not full paths.  We will not be able to
     // reliably specify them.
-    if(!cmSystemTools::FileIsFullPath(item.c_str()))
-      {
+    if (!cmSystemTools::FileIsFullPath(item.c_str())) {
       return;
-      }
+    }
 
     // Get the name of the library from the file name.
     std::string file = cmSystemTools::GetFilenameName(item);
-    if(!this->ExtractSharedLibraryName.find(file.c_str()))
-      {
+    if (!this->ExtractSharedLibraryName.find(file.c_str())) {
       // This is not the name of a shared library.
       return;
-      }
     }
+  }
 
   // If in linking mode, just link to the shared library.
-  if(this->SharedDependencyMode == SharedDepModeLink)
-    {
+  if (this->SharedDependencyMode == SharedDepModeLink) {
     this->AddItem(item, tgt);
     return;
-    }
+  }
 
   // Get a full path to the dependent shared library.
   // Add it to the runtime path computation so that the target being
   // linked will be able to find it.
   std::string lib;
-  if(tgt)
-    {
+  if (tgt) {
     lib = tgt->GetFullPath(this->Config, this->UseImportLibrary);
     this->AddLibraryRuntimeInfo(lib, tgt);
-    }
-  else
-    {
+  } else {
     lib = item;
     this->AddLibraryRuntimeInfo(lib);
-    }
+  }
 
   // Check if we need to include the dependent shared library in other
   // path ordering.
   cmOrderDirectories* order = 0;
-  if(this->SharedDependencyMode == SharedDepModeLibDir &&
-     !this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */)
-    {
+  if (this->SharedDependencyMode == SharedDepModeLibDir &&
+      !this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */) {
     // Add the item to the linker search path.
     order = this->OrderLinkerSearchPath;
-    }
-  else if(this->SharedDependencyMode == SharedDepModeDir)
-    {
+  } else if (this->SharedDependencyMode == SharedDepModeDir) {
     // Add the item to the separate dependent library search path.
     order = this->OrderDependentRPath;
-    }
-  if(order)
-    {
-    if(tgt)
-      {
+  }
+  if (order) {
+    if (tgt) {
       std::string soName = tgt->GetSOName(this->Config);
-      const char* soname = soName.empty()? 0 : soName.c_str();
+      const char* soname = soName.empty() ? 0 : soName.c_str();
       order->AddRuntimeLibrary(lib, soname);
-      }
-    else
-      {
+    } else {
       order->AddRuntimeLibrary(lib);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::ComputeLinkTypeInfo()
 {
   // Check whether archives may actually be shared libraries.
-  this->ArchivesMayBeShared = this->CMakeInstance->GetState()
-              ->GetGlobalPropertyAsBool("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS");
+  this->ArchivesMayBeShared =
+    this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(
+      "TARGET_ARCHIVES_MAY_BE_SHARED_LIBS");
 
   // First assume we cannot do link type stuff.
   this->LinkTypeEnabled = false;
@@ -816,15 +728,20 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
   const char* static_link_type_flag = 0;
   const char* shared_link_type_flag = 0;
   const char* target_type_str = 0;
-  switch(this->Target->GetType())
-    {
-    case cmState::EXECUTABLE:     target_type_str = "EXE"; break;
-    case cmState::SHARED_LIBRARY: target_type_str = "SHARED_LIBRARY"; break;
-    case cmState::MODULE_LIBRARY: target_type_str = "SHARED_MODULE"; break;
-    default: break;
-    }
-  if(target_type_str)
-    {
+  switch (this->Target->GetType()) {
+    case cmState::EXECUTABLE:
+      target_type_str = "EXE";
+      break;
+    case cmState::SHARED_LIBRARY:
+      target_type_str = "SHARED_LIBRARY";
+      break;
+    case cmState::MODULE_LIBRARY:
+      target_type_str = "SHARED_MODULE";
+      break;
+    default:
+      break;
+  }
+  if (target_type_str) {
     std::string static_link_type_flag_var = "CMAKE_";
     static_link_type_flag_var += target_type_str;
     static_link_type_flag_var += "_LINK_STATIC_";
@@ -840,26 +757,23 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
     shared_link_type_flag_var += "_FLAGS";
     shared_link_type_flag =
       this->Makefile->GetDefinition(shared_link_type_flag_var);
-    }
+  }
 
   // We can support link type switching only if all needed flags are
   // known.
-  if(static_link_type_flag && *static_link_type_flag &&
-     shared_link_type_flag && *shared_link_type_flag)
-    {
+  if (static_link_type_flag && *static_link_type_flag &&
+      shared_link_type_flag && *shared_link_type_flag) {
     this->LinkTypeEnabled = true;
     this->StaticLinkTypeFlag = static_link_type_flag;
     this->SharedLinkTypeFlag = shared_link_type_flag;
-    }
+  }
 
   // Lookup the starting link type from the target (linked statically?).
-  const char* lss =
-      this->Target->GetProperty("LINK_SEARCH_START_STATIC");
-  this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared;
+  const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
+  this->StartLinkType = cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared;
   this->CurrentLinkType = this->StartLinkType;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::ComputeItemParserInfo()
 {
   // Get possible library name prefixes.
@@ -877,50 +791,44 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
                          LinkShared);
   this->AddLinkExtension(mf->GetDefinition("CMAKE_LINK_LIBRARY_SUFFIX"),
                          LinkUnknown);
-  if(const char* linkSuffixes =
-     mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS"))
-    {
+  if (const char* linkSuffixes =
+        mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) {
     std::vector<std::string> linkSuffixVec;
     cmSystemTools::ExpandListArgument(linkSuffixes, linkSuffixVec);
-    for(std::vector<std::string>::iterator i = linkSuffixVec.begin();
-        i != linkSuffixVec.end(); ++i)
-      {
+    for (std::vector<std::string>::iterator i = linkSuffixVec.begin();
+         i != linkSuffixVec.end(); ++i) {
       this->AddLinkExtension(i->c_str(), LinkUnknown);
-      }
     }
-  if(const char* sharedSuffixes =
-     mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES"))
-    {
+  }
+  if (const char* sharedSuffixes =
+        mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")) {
     std::vector<std::string> sharedSuffixVec;
     cmSystemTools::ExpandListArgument(sharedSuffixes, sharedSuffixVec);
-    for(std::vector<std::string>::iterator i = sharedSuffixVec.begin();
-        i != sharedSuffixVec.end(); ++i)
-      {
+    for (std::vector<std::string>::iterator i = sharedSuffixVec.begin();
+         i != sharedSuffixVec.end(); ++i) {
       this->AddLinkExtension(i->c_str(), LinkShared);
-      }
     }
+  }
 
   // Compute a regex to match link extensions.
-  std::string libext = this->CreateExtensionRegex(this->LinkExtensions,
-                                                  LinkUnknown);
+  std::string libext =
+    this->CreateExtensionRegex(this->LinkExtensions, LinkUnknown);
 
   // Create regex to remove any library extension.
   std::string reg("(.*)");
   reg += libext;
-  this->OrderLinkerSearchPath->SetLinkExtensionInfo(this->LinkExtensions,
-                                                    reg);
+  this->OrderLinkerSearchPath->SetLinkExtensionInfo(this->LinkExtensions, reg);
 
   // Create a regex to match a library name.  Match index 1 will be
   // the prefix if it exists and empty otherwise.  Match index 2 will
   // be the library name.  Match index 3 will be the library
   // extension.
   reg = "^(";
-  for(std::set<std::string>::iterator p = this->LinkPrefixes.begin();
-      p != this->LinkPrefixes.end(); ++p)
-    {
+  for (std::set<std::string>::iterator p = this->LinkPrefixes.begin();
+       p != this->LinkPrefixes.end(); ++p) {
     reg += *p;
     reg += "|";
-    }
+  }
   reg += ")";
   reg += "([^/:]*)";
 
@@ -933,68 +841,57 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
   this->ExtractAnyLibraryName.compile(reg_any.c_str());
 
   // Create a regex to match static library names.
-  if(!this->StaticLinkExtensions.empty())
-    {
+  if (!this->StaticLinkExtensions.empty()) {
     std::string reg_static = reg;
-    reg_static += this->CreateExtensionRegex(this->StaticLinkExtensions,
-                                             LinkStatic);
+    reg_static +=
+      this->CreateExtensionRegex(this->StaticLinkExtensions, LinkStatic);
 #ifdef CM_COMPUTE_LINK_INFO_DEBUG
-  fprintf(stderr, "static regex [%s]\n", reg_static.c_str());
+    fprintf(stderr, "static regex [%s]\n", reg_static.c_str());
 #endif
     this->ExtractStaticLibraryName.compile(reg_static.c_str());
-    }
+  }
 
   // Create a regex to match shared library names.
-  if(!this->SharedLinkExtensions.empty())
-    {
+  if (!this->SharedLinkExtensions.empty()) {
     std::string reg_shared = reg;
     this->SharedRegexString =
       this->CreateExtensionRegex(this->SharedLinkExtensions, LinkShared);
     reg_shared += this->SharedRegexString;
 #ifdef CM_COMPUTE_LINK_INFO_DEBUG
-  fprintf(stderr, "shared regex [%s]\n", reg_shared.c_str());
+    fprintf(stderr, "shared regex [%s]\n", reg_shared.c_str());
 #endif
     this->ExtractSharedLibraryName.compile(reg_shared.c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddLinkPrefix(const char* p)
 {
-  if(p && *p)
-    {
+  if (p && *p) {
     this->LinkPrefixes.insert(p);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddLinkExtension(const char* e, LinkType type)
 {
-  if(e && *e)
-    {
-    if(type == LinkStatic)
-      {
+  if (e && *e) {
+    if (type == LinkStatic) {
       this->StaticLinkExtensions.push_back(e);
-      }
-    if(type == LinkShared)
-      {
+    }
+    if (type == LinkShared) {
       this->SharedLinkExtensions.push_back(e);
-      }
-    this->LinkExtensions.push_back(e);
     }
+    this->LinkExtensions.push_back(e);
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmComputeLinkInformation
-::CreateExtensionRegex(std::vector<std::string> const& exts, LinkType type)
+std::string cmComputeLinkInformation::CreateExtensionRegex(
+  std::vector<std::string> const& exts, LinkType type)
 {
   // Build a list of extension choices.
   std::string libext = "(";
   const char* sep = "";
-  for(std::vector<std::string>::const_iterator i = exts.begin();
-      i != exts.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = exts.begin();
+       i != exts.end(); ++i) {
     // Separate this choice from the previous one.
     libext += sep;
     sep = "|";
@@ -1006,61 +903,49 @@ cmComputeLinkInformation
 #else
     libext += *i;
 #endif
-    }
+  }
 
   // Finish the list.
   libext += ")";
 
   // Add an optional OpenBSD version component.
-  if(this->OpenBSD)
-    {
+  if (this->OpenBSD) {
     libext += "(\\.[0-9]+\\.[0-9]+)?";
-    }
-  else if(type == LinkShared)
-    {
+  } else if (type == LinkShared) {
     libext += "(\\.[0-9]+)?";
-    }
+  }
 
   libext += "$";
   return libext;
 }
 
-//----------------------------------------------------------------------------
 std::string cmComputeLinkInformation::NoCaseExpression(const char* str)
 {
   std::string ret;
   const char* s = str;
-  while(*s)
-    {
-    if(*s == '.')
-      {
+  while (*s) {
+    if (*s == '.') {
       ret += *s;
-      }
-    else
-      {
+    } else {
       ret += "[";
       ret += static_cast<char>(tolower(*s));
       ret += static_cast<char>(toupper(*s));
       ret += "]";
-      }
-    s++;
     }
+    s++;
+  }
   return ret;
 }
 
-//-------------------------------------------------------------------
 void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
 {
   // If we are changing the current link type add the flag to tell the
   // linker about it.
-  if(this->CurrentLinkType != lt)
-    {
+  if (this->CurrentLinkType != lt) {
     this->CurrentLinkType = lt;
 
-    if(this->LinkTypeEnabled)
-      {
-      switch(this->CurrentLinkType)
-        {
+    if (this->LinkTypeEnabled) {
+      switch (this->CurrentLinkType) {
         case LinkStatic:
           this->Items.push_back(Item(this->StaticLinkTypeFlag, false));
           break;
@@ -1069,12 +954,11 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
           break;
         default:
           break;
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddTargetItem(std::string const& item,
                                              cmGeneratorTarget const* target)
 {
@@ -1084,73 +968,63 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
   // shared and static libraries but static-mode can handle only
   // static libraries.  If a previous user item changed the link type
   // to static we need to make sure it is back to shared.
-  if(target->GetType() != cmState::STATIC_LIBRARY)
-    {
+  if (target->GetType() != cmState::STATIC_LIBRARY) {
     this->SetCurrentLinkType(LinkShared);
-    }
+  }
 
   // Keep track of shared library targets linked.
-  if(target->GetType() == cmState::SHARED_LIBRARY)
-    {
+  if (target->GetType() == cmState::SHARED_LIBRARY) {
     this->SharedLibrariesLinked.insert(target);
-    }
+  }
 
   // Handle case of an imported shared library with no soname.
-  if(this->NoSONameUsesPath &&
-     target->IsImportedSharedLibWithoutSOName(this->Config))
-    {
+  if (this->NoSONameUsesPath &&
+      target->IsImportedSharedLibWithoutSOName(this->Config)) {
     this->AddSharedLibNoSOName(item);
     return;
-    }
+  }
 
   // If this platform wants a flag before the full path, add it.
-  if(!this->LibLinkFileFlag.empty())
-    {
+  if (!this->LibLinkFileFlag.empty()) {
     this->Items.push_back(Item(this->LibLinkFileFlag, false));
-    }
+  }
 
   // For compatibility with CMake 2.4 include the item's directory in
   // the linker search path.
-  if(this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
-     this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
-     this->OldLinkDirMask.end())
-    {
+  if (this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
+      this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
+        this->OldLinkDirMask.end()) {
     this->OldLinkDirItems.push_back(item);
-    }
+  }
 
   // Now add the full path to the library.
   this->Items.push_back(Item(item, true, target));
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddFullItem(std::string const& item)
 {
   // Check for the implicit link directory special case.
-  if(this->CheckImplicitDirItem(item))
-    {
+  if (this->CheckImplicitDirItem(item)) {
     return;
-    }
+  }
 
   // Check for case of shared library with no builtin soname.
-  if(this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item))
-    {
+  if (this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item)) {
     return;
-    }
+  }
 
   // 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 &&
-     (generator.find("Visual Studio") != generator.npos ||
-      generator.find("Xcode") != generator.npos))
-    {
+  if (this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
+      (generator.find("Visual Studio") != generator.npos ||
+       generator.find("Xcode") != generator.npos)) {
     std::string file = cmSystemTools::GetFilenameName(item);
-    if(!this->ExtractAnyLibraryName.find(file.c_str()))
-      {
+    if (!this->ExtractAnyLibraryName.find(file.c_str())) {
       this->HandleBadFullItem(item, file);
       return;
-      }
     }
+  }
 
   // This is called to handle a link item that is a full path.
   // If the target is not a static library make sure the link type is
@@ -1158,89 +1032,76 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
   // shared and static libraries but static-mode can handle only
   // static libraries.  If a previous user item changed the link type
   // to static we need to make sure it is back to shared.
-  if(this->LinkTypeEnabled)
-    {
+  if (this->LinkTypeEnabled) {
     std::string name = cmSystemTools::GetFilenameName(item);
-    if(this->ExtractSharedLibraryName.find(name))
-      {
+    if (this->ExtractSharedLibraryName.find(name)) {
       this->SetCurrentLinkType(LinkShared);
-      }
-    else if(!this->ExtractStaticLibraryName.find(item))
-      {
+    } else if (!this->ExtractStaticLibraryName.find(item)) {
       // We cannot determine the type.  Assume it is the target's
       // default type.
       this->SetCurrentLinkType(this->StartLinkType);
-      }
     }
+  }
 
   // For compatibility with CMake 2.4 include the item's directory in
   // the linker search path.
-  if(this->OldLinkDirMode &&
-     this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
-     this->OldLinkDirMask.end())
-    {
+  if (this->OldLinkDirMode &&
+      this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
+        this->OldLinkDirMask.end()) {
     this->OldLinkDirItems.push_back(item);
-    }
+  }
 
   // If this platform wants a flag before the full path, add it.
-  if(!this->LibLinkFileFlag.empty())
-    {
+  if (!this->LibLinkFileFlag.empty()) {
     this->Items.push_back(Item(this->LibLinkFileFlag, false));
-    }
+  }
 
   // Now add the full path to the library.
   this->Items.push_back(Item(item, true));
 }
 
-//----------------------------------------------------------------------------
 bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
 {
   // We only switch to a pathless item if the link type may be
   // enforced.  Fortunately only platforms that support link types
   // seem to have magic per-architecture implicit link directories.
-  if(!this->LinkTypeEnabled)
-    {
+  if (!this->LinkTypeEnabled) {
     return false;
-    }
+  }
 
   // Check if this item is in an implicit link directory.
   std::string dir = cmSystemTools::GetFilenamePath(item);
-  if(this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end())
-    {
+  if (this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end()) {
     // Only libraries in implicit link directories are converted to
     // pathless items.
     return false;
-    }
+  }
 
   // Only apply the policy below if the library file is one that can
   // be found by the linker.
   std::string file = cmSystemTools::GetFilenameName(item);
-  if(!this->ExtractAnyLibraryName.find(file))
-    {
+  if (!this->ExtractAnyLibraryName.find(file)) {
     return false;
-    }
+  }
 
   // Check the policy for whether we should use the approach below.
-  switch (this->Target->GetPolicyStatusCMP0060())
-    {
+  switch (this->Target->GetPolicyStatusCMP0060()) {
     case cmPolicies::WARN:
-      if (this->CMP0060Warn)
-        {
+      if (this->CMP0060Warn) {
         // Print the warning at most once for this item.
         std::string const& wid = "CMP0060-WARNING-GIVEN-" + item;
-        if (!this->CMakeInstance->GetPropertyAsBool(wid))
-          {
+        if (!this->CMakeInstance->GetPropertyAsBool(wid)) {
           this->CMakeInstance->SetProperty(wid, "1");
           this->CMP0060WarnItems.insert(item);
-          }
         }
+      }
     case cmPolicies::OLD:
       break;
     case cmPolicies::REQUIRED_ALWAYS:
     case cmPolicies::REQUIRED_IF_USED:
     case cmPolicies::NEW:
       return false;
-    }
+  }
 
   // Many system linkers support multiple architectures by
   // automatically selecting the implicit linker search path for the
@@ -1256,7 +1117,6 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddUserItem(std::string const& item,
                                            bool pathNotKnown)
 {
@@ -1269,17 +1129,15 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
   //   libfoo.a  ==>  -Wl,-Bstatic -lfoo
 
   // Pass flags through untouched.
-  if(item[0] == '-' || item[0] == '$' || item[0] == '`')
-    {
+  if (item[0] == '-' || item[0] == '$' || item[0] == '`') {
     // if this is a -l option then we might need to warn about
     // CMP0003 so put it in OldUserFlagItems, if it is not a -l
     // or -Wl,-l (-framework -pthread), then allow it without a
     // CMP0003 as -L will not affect those other linker flags
-    if(item.find("-l") == 0 ||  item.find("-Wl,-l") == 0)
-      {
+    if (item.find("-l") == 0 || item.find("-Wl,-l") == 0) {
       // This is a linker option provided by the user.
       this->OldUserFlagItems.push_back(item);
-      }
+    }
 
     // Restore the target link type since this item does not specify
     // one.
@@ -1288,7 +1146,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
     // Use the item verbatim.
     this->Items.push_back(Item(item, false));
     return;
-    }
+  }
 
   // Parse out the prefix, base, and suffix components of the
   // library name.  If the name matches that of a shared or static
@@ -1301,9 +1159,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
   // libraries.  On AIX a library with the name libfoo.a can be
   // shared!
   std::string lib;
-  if(this->ExtractSharedLibraryName.find(item))
-    {
-    // This matches a shared library file name.
+  if (this->ExtractSharedLibraryName.find(item)) {
+// This matches a shared library file name.
 #ifdef CM_COMPUTE_LINK_INFO_DEBUG
     fprintf(stderr, "shared regex matched [%s] [%s] [%s]\n",
             this->ExtractSharedLibraryName.match(1).c_str(),
@@ -1315,10 +1172,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
 
     // Use just the library name so the linker will search.
     lib = this->ExtractSharedLibraryName.match(2);
-    }
-  else if(this->ExtractStaticLibraryName.find(item))
-    {
-    // This matches a static library file name.
+  } else if (this->ExtractStaticLibraryName.find(item)) {
+// This matches a static library file name.
 #ifdef CM_COMPUTE_LINK_INFO_DEBUG
     fprintf(stderr, "static regex matched [%s] [%s] [%s]\n",
             this->ExtractStaticLibraryName.match(1).c_str(),
@@ -1330,10 +1185,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
 
     // Use just the library name so the linker will search.
     lib = this->ExtractStaticLibraryName.match(2);
-    }
-  else if(this->ExtractAnyLibraryName.find(item))
-    {
-    // This matches a library file name.
+  } else if (this->ExtractAnyLibraryName.find(item)) {
+// This matches a library file name.
 #ifdef CM_COMPUTE_LINK_INFO_DEBUG
     fprintf(stderr, "any regex matched [%s] [%s] [%s]\n",
             this->ExtractAnyLibraryName.match(1).c_str(),
@@ -1346,21 +1199,18 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
 
     // Use just the library name so the linker will search.
     lib = this->ExtractAnyLibraryName.match(2);
-    }
-  else
-    {
+  } else {
     // This is a name specified by the user.
-    if(pathNotKnown)
-      {
+    if (pathNotKnown) {
       this->OldUserFlagItems.push_back(item);
-      }
+    }
 
     // We must ask the linker to search for a library with this name.
     // Restore the target link type since this item does not specify
     // one.
     this->SetCurrentLinkType(this->StartLinkType);
     lib = item;
-    }
+  }
 
   // Create an option to ask the linker to search for the library.
   std::string out = this->LibLinkFlag;
@@ -1374,18 +1224,16 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
   // specification.
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
 {
   // Try to separate the framework name and path.
-  if(!this->SplitFramework.find(item.c_str()))
-    {
+  if (!this->SplitFramework.find(item.c_str())) {
     std::ostringstream e;
     e << "Could not parse framework path \"" << item << "\" "
       << "linked by target " << this->Target->GetName() << ".";
     cmSystemTools::Error(e.str().c_str());
     return;
-    }
+  }
 
   std::string fw_path = this->SplitFramework.match(1);
   std::string fw = this->SplitFramework.match(2);
@@ -1409,21 +1257,16 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
   this->Items.push_back(Item(fw, false));
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddDirectoryItem(std::string const& item)
 {
-  if(this->Makefile->IsOn("APPLE")
-     && cmSystemTools::IsPathToFramework(item.c_str()))
-    {
+  if (this->Makefile->IsOn("APPLE") &&
+      cmSystemTools::IsPathToFramework(item.c_str())) {
     this->AddFrameworkItem(item);
-    }
-  else
-    {
+  } else {
     this->DropDirectoryItem(item);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
 {
   // A full path to a directory was found as a link item.  Warn the
@@ -1436,28 +1279,25 @@ void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
   cmSystemTools::Message(e.str().c_str());
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::ComputeFrameworkInfo()
 {
   // Avoid adding implicit framework paths.
   std::vector<std::string> implicitDirVec;
 
   // Get platform-wide implicit directories.
-  if(const char* implicitLinks = this->Makefile->GetDefinition
-     ("CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"))
-    {
+  if (const char* implicitLinks = this->Makefile->GetDefinition(
+        "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES")) {
     cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec);
-    }
+  }
 
   // Get language-specific implicit directories.
   std::string implicitDirVar = "CMAKE_";
   implicitDirVar += this->LinkLanguage;
   implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES";
-  if(const char* implicitDirs =
-     this->Makefile->GetDefinition(implicitDirVar))
-    {
+  if (const char* implicitDirs =
+        this->Makefile->GetDefinition(implicitDirVar)) {
     cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
-    }
+  }
 
   this->FrameworkPathsEmmitted.insert(implicitDirVec.begin(),
                                       implicitDirVec.end());
@@ -1466,38 +1306,32 @@ void cmComputeLinkInformation::ComputeFrameworkInfo()
   this->SplitFramework.compile("(.*)/(.*)\\.framework$");
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddFrameworkPath(std::string const& p)
 {
-  if(this->FrameworkPathsEmmitted.insert(p).second)
-    {
+  if (this->FrameworkPathsEmmitted.insert(p).second) {
     this->FrameworkPaths.push_back(p);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmComputeLinkInformation::CheckSharedLibNoSOName(std::string const& item)
 {
   // This platform will use the path to a library as its soname if the
   // library is given via path and was not built with an soname.  If
   // this is a shared library that might be the case.
   std::string file = cmSystemTools::GetFilenameName(item);
-  if(this->ExtractSharedLibraryName.find(file))
-    {
+  if (this->ExtractSharedLibraryName.find(file)) {
     // If we can guess the soname fairly reliably then assume the
     // library has one.  Otherwise assume the library has no builtin
     // soname.
     std::string soname;
-    if(!cmSystemTools::GuessLibrarySOName(item, soname))
-      {
+    if (!cmSystemTools::GuessLibrarySOName(item, soname)) {
       this->AddSharedLibNoSOName(item);
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddSharedLibNoSOName(std::string const& item)
 {
   // We have a full path to a shared library with no soname.  We need
@@ -1512,17 +1346,15 @@ void cmComputeLinkInformation::AddSharedLibNoSOName(std::string const& item)
   this->OrderLinkerSearchPath->AddLinkLibrary(item);
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
                                                  std::string const& file)
 {
   // Do not depend on things that do not exist.
   std::vector<std::string>::iterator i =
     std::find(this->Depends.begin(), this->Depends.end(), item);
-  if(i != this->Depends.end())
-    {
+  if (i != this->Depends.end()) {
     this->Depends.erase(i);
-    }
+  }
 
   // Tell the linker to search for the item and provide the proper
   // path for it.  Do not contribute to any CMP0003 warning (do not
@@ -1531,26 +1363,24 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
   this->OrderLinkerSearchPath->AddLinkLibrary(item);
 
   // Produce any needed message.
-  switch(this->Target->GetPolicyStatusCMP0008())
-    {
-    case cmPolicies::WARN:
-      {
+  switch (this->Target->GetPolicyStatusCMP0008()) {
+    case cmPolicies::WARN: {
       // Print the warning at most once for this item.
       std::string wid = "CMP0008-WARNING-GIVEN-";
       wid += item;
-      if(!this->CMakeInstance->GetState()
-              ->GetGlobalPropertyAsBool(wid))
-        {
+      if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(wid)) {
         this->CMakeInstance->GetState()->SetGlobalProperty(wid, "1");
         std::ostringstream w;
+        /* clang-format off */
         w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0008) << "\n"
           << "Target \"" << this->Target->GetName() << "\" links to item\n"
           << "  " << item << "\n"
           << "which is a full-path but not a valid library file name.";
+        /* clang-format on */
         this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
-                                        this->Target->GetBacktrace());
-        }
+                                          this->Target->GetBacktrace());
       }
+    }
     case cmPolicies::OLD:
       // OLD behavior does not warn.
       break;
@@ -1558,44 +1388,40 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
       // NEW behavior will not get here.
       break;
     case cmPolicies::REQUIRED_IF_USED:
-    case cmPolicies::REQUIRED_ALWAYS:
-      {
+    case cmPolicies::REQUIRED_ALWAYS: {
       std::ostringstream e;
+      /* clang-format off */
       e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0008) << "\n"
           << "Target \"" << this->Target->GetName() << "\" links to item\n"
           << "  " << item << "\n"
           << "which is a full-path but not a valid library file name.";
+      /* clang-format on */
       this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
                                         this->Target->GetBacktrace());
-      }
-      break;
-    }
+    } break;
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
 {
   // Support broken projects if necessary.
-  if(this->OldLinkDirItems.empty() || this->OldUserFlagItems.empty() ||
-     !this->OldLinkDirMode)
-    {
+  if (this->OldLinkDirItems.empty() || this->OldUserFlagItems.empty() ||
+      !this->OldLinkDirMode) {
     return true;
-    }
+  }
 
   // Enforce policy constraints.
-  switch(this->Target->GetPolicyStatusCMP0003())
-    {
+  switch (this->Target->GetPolicyStatusCMP0003()) {
     case cmPolicies::WARN:
-      if(!this->CMakeInstance->GetState()
-              ->GetGlobalPropertyAsBool("CMP0003-WARNING-GIVEN"))
-        {
-        this->CMakeInstance->GetState()
-            ->SetGlobalProperty("CMP0003-WARNING-GIVEN", "1");
+      if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(
+            "CMP0003-WARNING-GIVEN")) {
+        this->CMakeInstance->GetState()->SetGlobalProperty(
+          "CMP0003-WARNING-GIVEN", "1");
         std::ostringstream w;
         this->PrintLinkPolicyDiagnosis(w);
         this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
-                                        this->Target->GetBacktrace());
-        }
+                                          this->Target->GetBacktrace());
+      }
     case cmPolicies::OLD:
       // OLD behavior is to add the paths containing libraries with
       // known full paths as link directories.
@@ -1604,31 +1430,29 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
       // Should never happen due to assignment of OldLinkDirMode
       return true;
     case cmPolicies::REQUIRED_IF_USED:
-    case cmPolicies::REQUIRED_ALWAYS:
-      {
+    case cmPolicies::REQUIRED_ALWAYS: {
       std::ostringstream e;
       e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n";
       this->PrintLinkPolicyDiagnosis(e);
       this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
                                         this->Target->GetBacktrace());
       return false;
-      }
     }
+  }
 
   // Add the link directories for full path items.
-  for(std::vector<std::string>::const_iterator
-        i = this->OldLinkDirItems.begin();
-      i != this->OldLinkDirItems.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i =
+         this->OldLinkDirItems.begin();
+       i != this->OldLinkDirItems.end(); ++i) {
     this->OrderLinkerSearchPath->AddLinkLibrary(*i);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
 {
   // Tell the user what to do.
+  /* clang-format off */
   os << "Policy CMP0003 should be set before this line.  "
      << "Add code such as\n"
      << "  if(COMMAND cmake_policy)\n"
@@ -1636,54 +1460,50 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
      << "  endif(COMMAND cmake_policy)\n"
      << "as early as possible but after the most recent call to "
      << "cmake_minimum_required or cmake_policy(VERSION).  ";
+  /* clang-format on */
 
   // List the items that might need the old-style paths.
-  os << "This warning appears because target \""
-     << this->Target->GetName() << "\" "
+  os << "This warning appears because target \"" << this->Target->GetName()
+     << "\" "
      << "links to some libraries for which the linker must search:\n";
   {
-  // Format the list of unknown items to be as short as possible while
-  // still fitting in the allowed width (a true solution would be the
-  // bin packing problem if we were allowed to change the order).
-  std::string::size_type max_size = 76;
-  std::string line;
-  const char* sep = "  ";
-  for(std::vector<std::string>::const_iterator
-        i = this->OldUserFlagItems.begin();
-      i != this->OldUserFlagItems.end(); ++i)
-    {
-    // If the addition of another item will exceed the limit then
-    // output the current line and reset it.  Note that the separator
-    // is either " " or ", " which is always 2 characters.
-    if(!line.empty() && (line.size() + i->size() + 2) > max_size)
-      {
-      os << line << "\n";
-      sep = "  ";
-      line = "";
+    // Format the list of unknown items to be as short as possible while
+    // still fitting in the allowed width (a true solution would be the
+    // bin packing problem if we were allowed to change the order).
+    std::string::size_type max_size = 76;
+    std::string line;
+    const char* sep = "  ";
+    for (std::vector<std::string>::const_iterator i =
+           this->OldUserFlagItems.begin();
+         i != this->OldUserFlagItems.end(); ++i) {
+      // If the addition of another item will exceed the limit then
+      // output the current line and reset it.  Note that the separator
+      // is either " " or ", " which is always 2 characters.
+      if (!line.empty() && (line.size() + i->size() + 2) > max_size) {
+        os << line << "\n";
+        sep = "  ";
+        line = "";
       }
-    line += sep;
-    line += *i;
-    // Convert to the other separator.
-    sep = ", ";
+      line += sep;
+      line += *i;
+      // Convert to the other separator.
+      sep = ", ";
     }
-  if(!line.empty())
-    {
-    os << line << "\n";
+    if (!line.empty()) {
+      os << line << "\n";
     }
   }
 
   // List the paths old behavior is adding.
   os << "and other libraries with known full path:\n";
   std::set<std::string> emitted;
-  for(std::vector<std::string>::const_iterator
-        i = this->OldLinkDirItems.begin();
-      i != this->OldLinkDirItems.end(); ++i)
-    {
-    if(emitted.insert(cmSystemTools::GetFilenamePath(*i)).second)
-      {
+  for (std::vector<std::string>::const_iterator i =
+         this->OldLinkDirItems.begin();
+       i != this->OldLinkDirItems.end(); ++i) {
+    if (emitted.insert(cmSystemTools::GetFilenamePath(*i)).second) {
       os << "  " << *i << "\n";
-      }
     }
+  }
 
   // Explain.
   os << "CMake is adding directories in the second list to the linker "
@@ -1694,40 +1514,34 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
      << "Run \"cmake --help-policy CMP0003\" for more information.";
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::LoadImplicitLinkInfo()
 {
   std::vector<std::string> implicitDirVec;
 
   // Get platform-wide implicit directories.
-  if(const char* implicitLinks =
-     (this->Makefile->GetDefinition
-      ("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES")))
-    {
+  if (const char* implicitLinks = (this->Makefile->GetDefinition(
+        "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"))) {
     cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec);
-    }
+  }
 
   // Append library architecture to all implicit platform directories
   // and add them to the set
-  if(const char* libraryArch =
-     this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"))
-    {
+  if (const char* libraryArch =
+        this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
     for (std::vector<std::string>::const_iterator i = implicitDirVec.begin();
-         i != implicitDirVec.end(); ++i)
-      {
+         i != implicitDirVec.end(); ++i) {
       this->ImplicitLinkDirs.insert(*i + "/" + libraryArch);
-      }
     }
+  }
 
   // Get language-specific implicit directories.
   std::string implicitDirVar = "CMAKE_";
   implicitDirVar += this->LinkLanguage;
   implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES";
-  if(const char* implicitDirs =
-     this->Makefile->GetDefinition(implicitDirVar))
-    {
+  if (const char* implicitDirs =
+        this->Makefile->GetDefinition(implicitDirVar)) {
     cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
-    }
+  }
 
   // Store implicit link directories.
   this->ImplicitLinkDirs.insert(implicitDirVec.begin(), implicitDirVec.end());
@@ -1737,169 +1551,141 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
   std::string implicitLibVar = "CMAKE_";
   implicitLibVar += this->LinkLanguage;
   implicitLibVar += "_IMPLICIT_LINK_LIBRARIES";
-  if(const char* implicitLibs =
-     this->Makefile->GetDefinition(implicitLibVar))
-    {
+  if (const char* implicitLibs =
+        this->Makefile->GetDefinition(implicitLibVar)) {
     cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec);
-    }
+  }
 
   // Store implicit link libraries.
-  for(std::vector<std::string>::const_iterator i = implicitLibVec.begin();
-      i != implicitLibVec.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = implicitLibVec.begin();
+       i != implicitLibVec.end(); ++i) {
     // Items starting in '-' but not '-l' are flags, not libraries,
     // and should not be filtered by this implicit list.
     std::string const& item = *i;
-    if(item[0] != '-' || item[1] == 'l')
-      {
+    if (item[0] != '-' || item[1] == 'l') {
       this->ImplicitLinkLibs.insert(item);
-      }
     }
+  }
 
   // Get platform specific rpath link directories
-  if(const char *rpathDirs =
-     (this->Makefile->GetDefinition
-      ("CMAKE_PLATFORM_RUNTIME_PATH")))
-    {
+  if (const char* rpathDirs =
+        (this->Makefile->GetDefinition("CMAKE_PLATFORM_RUNTIME_PATH"))) {
     cmSystemTools::ExpandListArgument(rpathDirs, this->RuntimeLinkDirs);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> const&
 cmComputeLinkInformation::GetRuntimeSearchPath()
 {
   return this->OrderRuntimeSearchPath->GetOrderedDirectories();
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
-                                              cmGeneratorTarget const* target)
+void cmComputeLinkInformation::AddLibraryRuntimeInfo(
+  std::string const& fullPath, cmGeneratorTarget const* target)
 {
   // Ignore targets on Apple where install_name is not @rpath.
   // The dependenty library can be found with other means such as
   // @loader_path or full paths.
-  if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
-    if(!target->HasMacOSXRpathInstallNameDir(this->Config))
-      {
+  if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+    if (!target->HasMacOSXRpathInstallNameDir(this->Config)) {
       return;
-      }
     }
+  }
 
   // Libraries with unknown type must be handled using just the file
   // on disk.
-  if(target->GetType() == cmState::UNKNOWN_LIBRARY)
-    {
+  if (target->GetType() == cmState::UNKNOWN_LIBRARY) {
     this->AddLibraryRuntimeInfo(fullPath);
     return;
-    }
+  }
 
   // Skip targets that are not shared libraries (modules cannot be linked).
-  if(target->GetType() != cmState::SHARED_LIBRARY)
-    {
+  if (target->GetType() != cmState::SHARED_LIBRARY) {
     return;
-    }
+  }
 
   // Try to get the soname of the library.  Only files with this name
   // could possibly conflict.
   std::string soName = target->GetSOName(this->Config);
-  const char* soname = soName.empty()? 0 : soName.c_str();
+  const char* soname = soName.empty() ? 0 : soName.c_str();
 
   // Include this library in the runtime path ordering.
   this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath, soname);
-  if(this->LinkWithRuntimePath)
-    {
+  if (this->LinkWithRuntimePath) {
     this->OrderLinkerSearchPath->AddRuntimeLibrary(fullPath, soname);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath)
+void cmComputeLinkInformation::AddLibraryRuntimeInfo(
+  std::string const& fullPath)
 {
   // Get the name of the library from the file name.
   bool is_shared_library = false;
   std::string file = cmSystemTools::GetFilenameName(fullPath);
 
-  if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
+  if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
     // Check that @rpath is part of the install name.
     // If it isn't, return.
     std::string soname;
-    if(!cmSystemTools::GuessLibraryInstallName(fullPath, soname))
-      {
+    if (!cmSystemTools::GuessLibraryInstallName(fullPath, soname)) {
       return;
-      }
+    }
 
-    if(soname.find("@rpath") == std::string::npos)
-      {
+    if (soname.find("@rpath") == std::string::npos) {
       return;
-      }
     }
+  }
 
   is_shared_library = this->ExtractSharedLibraryName.find(file);
 
-  if(!is_shared_library)
-    {
+  if (!is_shared_library) {
     // On some platforms (AIX) a shared library may look static.
-    if(this->ArchivesMayBeShared)
-      {
-      if(this->ExtractStaticLibraryName.find(file.c_str()))
-        {
+    if (this->ArchivesMayBeShared) {
+      if (this->ExtractStaticLibraryName.find(file.c_str())) {
         // This is the name of a shared library or archive.
         is_shared_library = true;
-        }
       }
     }
+  }
 
   // It could be an Apple framework
-  if(!is_shared_library)
-    {
-    if(fullPath.find(".framework") != std::string::npos)
-      {
-      static cmsys::RegularExpression
-        splitFramework("^(.*)/(.*).framework/(.*)$");
-      if(splitFramework.find(fullPath) &&
-        (std::string::npos !=
-         splitFramework.match(3).find(splitFramework.match(2))))
-        {
+  if (!is_shared_library) {
+    if (fullPath.find(".framework") != std::string::npos) {
+      static cmsys::RegularExpression splitFramework(
+        "^(.*)/(.*).framework/(.*)$");
+      if (splitFramework.find(fullPath) &&
+          (std::string::npos !=
+           splitFramework.match(3).find(splitFramework.match(2)))) {
         is_shared_library = true;
-        }
       }
     }
+  }
 
-  if(!is_shared_library)
-    {
+  if (!is_shared_library) {
     return;
-    }
+  }
 
   // Include this library in the runtime path ordering.
   this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath);
-  if(this->LinkWithRuntimePath)
-    {
+  if (this->LinkWithRuntimePath) {
     this->OrderLinkerSearchPath->AddRuntimeLibrary(fullPath);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 static void cmCLI_ExpandListUnique(const char* str,
                                    std::vector<std::string>& out,
                                    std::set<std::string>& emitted)
 {
   std::vector<std::string> tmp;
   cmSystemTools::ExpandListArgument(str, tmp);
-  for(std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end(); ++i)
-    {
-    if(emitted.insert(*i).second)
-      {
+  for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
+       ++i) {
+    if (emitted.insert(*i).second) {
       out.push_back(*i);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
                                         bool for_install)
 {
@@ -1918,103 +1704,82 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
   bool use_build_rpath =
     (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) &&
      !linking_for_install);
-  bool use_link_rpath =
-    outputRuntime && linking_for_install &&
+  bool use_link_rpath = outputRuntime && linking_for_install &&
     !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") &&
     this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
 
   // Construct the RPATH.
   std::set<std::string> emitted;
-  if(use_install_rpath)
-    {
-    const char* install_rpath =
-        this->Target->GetProperty("INSTALL_RPATH");
+  if (use_install_rpath) {
+    const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
     cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted);
-    }
-  if(use_build_rpath || use_link_rpath)
-    {
+  }
+  if (use_build_rpath || use_link_rpath) {
     std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
-    const char *stagePath
-                  = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
-    const char *installPrefix
-                  = this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+    const char* stagePath =
+      this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
+    const char* installPrefix =
+      this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
     cmSystemTools::ConvertToUnixSlashes(rootPath);
     std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
-    for(std::vector<std::string>::const_iterator ri = rdirs.begin();
-        ri != rdirs.end(); ++ri)
-      {
+    for (std::vector<std::string>::const_iterator ri = rdirs.begin();
+         ri != rdirs.end(); ++ri) {
       // Put this directory in the rpath if using build-tree rpath
       // support or if using the link path as an rpath.
-      if(use_build_rpath)
-        {
+      if (use_build_rpath) {
         std::string d = *ri;
-        if (!rootPath.empty() && d.find(rootPath) == 0)
-          {
+        if (!rootPath.empty() && d.find(rootPath) == 0) {
           d = d.substr(rootPath.size());
-          }
-        else if (stagePath && *stagePath && d.find(stagePath) == 0)
-          {
+        } else if (stagePath && *stagePath && d.find(stagePath) == 0) {
           std::string suffix = d.substr(strlen(stagePath));
           d = installPrefix;
           d += "/";
           d += suffix;
           cmSystemTools::ConvertToUnixSlashes(d);
-          }
-        if(emitted.insert(d).second)
-          {
+        }
+        if (emitted.insert(d).second) {
           runtimeDirs.push_back(d);
-          }
         }
-      else if(use_link_rpath)
-        {
+      } else if (use_link_rpath) {
         // Do not add any path inside the source or build tree.
         const char* topSourceDir = this->CMakeInstance->GetHomeDirectory();
         const char* topBinaryDir =
-            this->CMakeInstance->GetHomeOutputDirectory();
-        if(!cmSystemTools::ComparePath(*ri, topSourceDir) &&
-           !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
-           !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
-           !cmSystemTools::IsSubDirectory(*ri, topBinaryDir))
-          {
+          this->CMakeInstance->GetHomeOutputDirectory();
+        if (!cmSystemTools::ComparePath(*ri, topSourceDir) &&
+            !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
+            !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
+            !cmSystemTools::IsSubDirectory(*ri, topBinaryDir)) {
           std::string d = *ri;
-          if (!rootPath.empty() && d.find(rootPath) == 0)
-            {
+          if (!rootPath.empty() && d.find(rootPath) == 0) {
             d = d.substr(rootPath.size());
-            }
-          else if (stagePath && *stagePath && d.find(stagePath) == 0)
-            {
+          } else if (stagePath && *stagePath && d.find(stagePath) == 0) {
             std::string suffix = d.substr(strlen(stagePath));
             d = installPrefix;
             d += "/";
             d += suffix;
             cmSystemTools::ConvertToUnixSlashes(d);
-            }
-          if(emitted.insert(d).second)
-            {
+          }
+          if (emitted.insert(d).second) {
             runtimeDirs.push_back(d);
-            }
           }
         }
       }
     }
+  }
 
   // Add runtime paths required by the languages to always be
   // present.  This is done even when skipping rpath support.
   {
-  cmGeneratorTarget::LinkClosure const* lc =
-    this->Target->GetLinkClosure(this->Config);
-  for(std::vector<std::string>::const_iterator li = lc->Languages.begin();
-      li != lc->Languages.end(); ++li)
-    {
-    std::string useVar = "CMAKE_" + *li +
-      "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
-    if(this->Makefile->IsOn(useVar))
-      {
-      std::string dirVar = "CMAKE_" + *li +
-        "_IMPLICIT_LINK_DIRECTORIES";
-      if(const char* dirs = this->Makefile->GetDefinition(dirVar))
-        {
-        cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
+    cmGeneratorTarget::LinkClosure const* lc =
+      this->Target->GetLinkClosure(this->Config);
+    for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
+         li != lc->Languages.end(); ++li) {
+      std::string useVar =
+        "CMAKE_" + *li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
+      if (this->Makefile->IsOn(useVar)) {
+        std::string dirVar = "CMAKE_" + *li + "_IMPLICIT_LINK_DIRECTORIES";
+        if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
+          cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
         }
       }
     }
@@ -2025,7 +1790,6 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
   cmCLI_ExpandListUnique(this->RuntimeAlways.c_str(), runtimeDirs, emitted);
 }
 
-//----------------------------------------------------------------------------
 std::string cmComputeLinkInformation::GetRPathString(bool for_install)
 {
   // Get the directories to use.
@@ -2036,34 +1800,29 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
   std::string rpath = cmJoin(runtimeDirs, this->GetRuntimeSep());
 
   // If the rpath will be replaced at install time, prepare space.
-  if(!for_install && this->RuntimeUseChrpath)
-    {
-    if(!rpath.empty())
-      {
+  if (!for_install && this->RuntimeUseChrpath) {
+    if (!rpath.empty()) {
       // Add one trailing separator so the linker does not re-use the
       // rpath .dynstr entry for a symbol name that happens to match
       // the end of the rpath string.
       rpath += this->GetRuntimeSep();
-      }
+    }
 
     // Make sure it is long enough to hold the replacement value.
     std::string::size_type minLength = this->GetChrpathString().length();
-    while(rpath.length() < minLength)
-      {
+    while (rpath.length() < minLength) {
       rpath += this->GetRuntimeSep();
-      }
     }
+  }
 
   return rpath;
 }
 
-//----------------------------------------------------------------------------
 std::string cmComputeLinkInformation::GetChrpathString()
 {
-  if(!this->RuntimeUseChrpath)
-    {
+  if (!this->RuntimeUseChrpath) {
     return "";
-    }
+  }
 
   return this->GetRPathString(true);
 }
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 5eecf7d..c0ddc53 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -35,11 +35,24 @@ public:
 
   struct Item
   {
-    Item(): Value(), IsPath(true), Target(0) {}
-    Item(Item const& item):
-      Value(item.Value), IsPath(item.IsPath), Target(item.Target) {}
-    Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0):
-      Value(v), IsPath(p), Target(target) {}
+    Item()
+      : Value()
+      , IsPath(true)
+      , Target(0)
+    {
+    }
+    Item(Item const& item)
+      : Value(item.Value)
+      , IsPath(item.IsPath)
+      , Target(item.Target)
+    {
+    }
+    Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0)
+      : Value(v)
+      , IsPath(p)
+      , Target(target)
+    {
+    }
     std::string Value;
     bool IsPath;
     cmGeneratorTarget const* Target;
@@ -60,6 +73,7 @@ public:
 
   std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
   std::string GetRPathLinkString();
+
 private:
   void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
   void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
@@ -101,7 +115,12 @@ private:
   std::string RPathLinkFlag;
   SharedDepMode SharedDependencyMode;
 
-  enum LinkType { LinkUnknown, LinkStatic, LinkShared };
+  enum LinkType
+  {
+    LinkUnknown,
+    LinkStatic,
+    LinkShared
+  };
   void SetCurrentLinkType(LinkType lt);
 
   // Link type adjustment.
@@ -184,7 +203,6 @@ private:
   void AddLibraryRuntimeInfo(std::string const& fullPath,
                              const cmGeneratorTarget* target);
   void AddLibraryRuntimeInfo(std::string const& fullPath);
-
 };
 
 #endif
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 586b5bf..570405a 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -15,9 +15,9 @@
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
+#include "cmSourceFile.h"
 #include "cmState.h"
 #include "cmSystemTools.h"
-#include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
 
@@ -94,176 +94,152 @@ transitively on all the static libraries it links.
 
 */
 
-//----------------------------------------------------------------------------
 cmComputeTargetDepends::cmComputeTargetDepends(cmGlobalGenerator* gg)
 {
   this->GlobalGenerator = gg;
   cmake* cm = this->GlobalGenerator->GetCMakeInstance();
-  this->DebugMode = cm->GetState()
-                      ->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE");
-  this->NoCycles = cm->GetState()
-                      ->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
+  this->DebugMode =
+    cm->GetState()->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_DEBUG_MODE");
+  this->NoCycles =
+    cm->GetState()->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
 }
 
-//----------------------------------------------------------------------------
 cmComputeTargetDepends::~cmComputeTargetDepends()
 {
 }
 
-//----------------------------------------------------------------------------
 bool cmComputeTargetDepends::Compute()
 {
   // Build the original graph.
   this->CollectTargets();
   this->CollectDepends();
-  if(this->DebugMode)
-    {
+  if (this->DebugMode) {
     this->DisplayGraph(this->InitialGraph, "initial");
-    }
+  }
 
   // Identify components.
   cmComputeComponentGraph ccg(this->InitialGraph);
-  if(this->DebugMode)
-    {
+  if (this->DebugMode) {
     this->DisplayComponents(ccg);
-    }
-  if(!this->CheckComponents(ccg))
-    {
+  }
+  if (!this->CheckComponents(ccg)) {
     return false;
-    }
+  }
 
   // Compute the final dependency graph.
-  if(!this->ComputeFinalDepends(ccg))
-    {
+  if (!this->ComputeFinalDepends(ccg)) {
     return false;
-    }
-  if(this->DebugMode)
-    {
+  }
+  if (this->DebugMode) {
     this->DisplayGraph(this->FinalGraph, "final");
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
-                                               cmTargetDependSet& deps)
+void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
+                                                    cmTargetDependSet& deps)
 {
   // Lookup the index for this target.  All targets should be known by
   // this point.
-  std::map<cmGeneratorTarget const*, int>::const_iterator tii
-                                                  = this->TargetIndex.find(t);
+  std::map<cmGeneratorTarget const*, int>::const_iterator tii =
+    this->TargetIndex.find(t);
   assert(tii != this->TargetIndex.end());
   int i = tii->second;
 
   // Get its final dependencies.
   EdgeList const& nl = this->FinalGraph[i];
-  for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-    {
+  for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
     cmGeneratorTarget const* dep = this->Targets[*ni];
     cmTargetDependSet::iterator di = deps.insert(dep).first;
     di->SetType(ni->IsStrong());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeTargetDepends::CollectTargets()
 {
   // Collect all targets from all generators.
   std::vector<cmLocalGenerator*> const& lgens =
     this->GlobalGenerator->GetLocalGenerators();
-  for(unsigned int i = 0; i < lgens.size(); ++i)
-    {
+  for (unsigned int i = 0; i < lgens.size(); ++i) {
     const std::vector<cmGeneratorTarget*> targets =
-        lgens[i]->GetGeneratorTargets();
-    for(std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
+      lgens[i]->GetGeneratorTargets();
+    for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
+         ti != targets.end(); ++ti) {
       cmGeneratorTarget* gt = *ti;
       int index = static_cast<int>(this->Targets.size());
       this->TargetIndex[gt] = index;
       this->Targets.push_back(gt);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeTargetDepends::CollectDepends()
 {
   // Allocate the dependency graph adjacency lists.
   this->InitialGraph.resize(this->Targets.size());
 
   // Compute each dependency list.
-  for(unsigned int i=0; i < this->Targets.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->Targets.size(); ++i) {
     this->CollectTargetDepends(i);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
 {
   // Get the depender.
   cmGeneratorTarget const* depender = this->Targets[depender_index];
-  if (depender->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (depender->GetType() == cmState::INTERFACE_LIBRARY) {
     return;
-    }
+  }
 
   // Loop over all targets linked directly in all configs.
   // We need to make targets depend on the union of all config-specific
   // dependencies in all targets, because the generated build-systems can't
   // deal with config-specific dependencies.
   {
-  std::set<std::string> emitted;
+    std::set<std::string> emitted;
 
-  std::vector<std::string> configs;
-  depender->Makefile->GetConfigurations(configs);
-  if (configs.empty())
-    {
-    configs.push_back("");
+    std::vector<std::string> configs;
+    depender->Makefile->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;
-    depender->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() != cmState::EXECUTABLE &&
-            depender->GetType() != cmState::STATIC_LIBRARY &&
-            depender->GetType() != cmState::SHARED_LIBRARY &&
-            depender->GetType() != cmState::MODULE_LIBRARY)
-          {
-          this->GlobalGenerator->GetCMakeInstance()
-            ->IssueMessage(cmake::FATAL_ERROR,
-                            "Only executables and non-OBJECT libraries may "
-                            "reference target objects.",
-                            depender->GetBacktrace());
-          return;
+    for (std::vector<std::string>::const_iterator it = configs.begin();
+         it != configs.end(); ++it) {
+      std::vector<cmSourceFile const*> objectFiles;
+      depender->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() != cmState::EXECUTABLE &&
+              depender->GetType() != cmState::STATIC_LIBRARY &&
+              depender->GetType() != cmState::SHARED_LIBRARY &&
+              depender->GetType() != cmState::MODULE_LIBRARY) {
+            this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
+              cmake::FATAL_ERROR,
+              "Only executables and non-OBJECT libraries may "
+              "reference target objects.",
+              depender->GetBacktrace());
+            return;
           }
-        const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);
+          const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);
         }
       }
 
-    cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
+      cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
 
-    // A target should not depend on itself.
-    emitted.insert(depender->GetName());
-    for(std::vector<cmLinkImplItem>::const_iterator
-          lib = impl->Libraries.begin();
-        lib != impl->Libraries.end(); ++lib)
-      {
-      // Don't emit the same library twice for this target.
-      if(emitted.insert(*lib).second)
-        {
-        this->AddTargetDepend(depender_index, *lib, true);
-        this->AddInterfaceDepends(depender_index, *lib, emitted);
+      // A target should not depend on itself.
+      emitted.insert(depender->GetName());
+      for (std::vector<cmLinkImplItem>::const_iterator lib =
+             impl->Libraries.begin();
+           lib != impl->Libraries.end(); ++lib) {
+        // Don't emit the same library twice for this target.
+        if (emitted.insert(*lib).second) {
+          this->AddTargetDepend(depender_index, *lib, true);
+          this->AddInterfaceDepends(depender_index, *lib, emitted);
         }
       }
     }
@@ -271,83 +247,69 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
 
   // Loop over all utility dependencies.
   {
-  std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
-  std::set<std::string> emitted;
-  // A target should not depend on itself.
-  emitted.insert(depender->GetName());
-  for(std::set<cmLinkItem>::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, false);
+    std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
+    std::set<std::string> emitted;
+    // A target should not depend on itself.
+    emitted.insert(depender->GetName());
+    for (std::set<cmLinkItem>::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, false);
       }
     }
   }
 }
 
-//----------------------------------------------------------------------------
-void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
-                                             const cmGeneratorTarget* dependee,
-                                             const std::string& config,
-                                             std::set<std::string> &emitted)
+void cmComputeTargetDepends::AddInterfaceDepends(
+  int depender_index, const cmGeneratorTarget* dependee,
+  const std::string& config, std::set<std::string>& emitted)
 {
   cmGeneratorTarget const* depender = this->Targets[depender_index];
-  if(cmLinkInterface const* iface =
-                                dependee->GetLinkInterface(config,
-                                                           depender))
-    {
-    for(std::vector<cmLinkItem>::const_iterator
-        lib = iface->Libraries.begin();
-        lib != iface->Libraries.end(); ++lib)
-      {
+  if (cmLinkInterface const* iface =
+        dependee->GetLinkInterface(config, depender)) {
+    for (std::vector<cmLinkItem>::const_iterator lib =
+           iface->Libraries.begin();
+         lib != iface->Libraries.end(); ++lib) {
       // Don't emit the same library twice for this target.
-      if(emitted.insert(*lib).second)
-        {
+      if (emitted.insert(*lib).second) {
         this->AddTargetDepend(depender_index, *lib, true);
         this->AddInterfaceDepends(depender_index, *lib, emitted);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
-                                             cmLinkItem const& dependee_name,
-                                             std::set<std::string> &emitted)
+void cmComputeTargetDepends::AddInterfaceDepends(
+  int depender_index, cmLinkItem const& dependee_name,
+  std::set<std::string>& emitted)
 {
   cmGeneratorTarget const* depender = this->Targets[depender_index];
   cmGeneratorTarget const* dependee = dependee_name.Target;
   // Skip targets that will not really be linked.  This is probably a
   // name conflict between an external library and an executable
   // within the project.
-  if(dependee &&
-     dependee->GetType() == cmState::EXECUTABLE &&
-     !dependee->IsExecutableWithExports())
-    {
+  if (dependee && dependee->GetType() == cmState::EXECUTABLE &&
+      !dependee->IsExecutableWithExports()) {
     dependee = 0;
-    }
+  }
 
-  if(dependee)
-    {
+  if (dependee) {
     this->AddInterfaceDepends(depender_index, dependee, "", emitted);
     std::vector<std::string> configs;
     depender->Makefile->GetConfigurations(configs);
     for (std::vector<std::string>::const_iterator it = configs.begin();
-      it != configs.end(); ++it)
-      {
+         it != configs.end(); ++it) {
       // A target should not depend on itself.
       emitted.insert(depender->GetName());
       this->AddInterfaceDepends(depender_index, dependee, *it, emitted);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmComputeTargetDepends::AddTargetDepend(
-  int depender_index, cmLinkItem const& dependee_name,
-  bool linking)
+void cmComputeTargetDepends::AddTargetDepend(int depender_index,
+                                             cmLinkItem const& dependee_name,
+                                             bool linking)
 {
   // Get the depender.
   cmGeneratorTarget const* depender = this->Targets[depender_index];
@@ -355,14 +317,12 @@ void cmComputeTargetDepends::AddTargetDepend(
   // Check the target's makefile first.
   cmGeneratorTarget const* dependee = dependee_name.Target;
 
-  if(!dependee && !linking &&
-    (depender->GetType() != cmState::GLOBAL_TARGET))
-    {
+  if (!dependee && !linking &&
+      (depender->GetType() != cmState::GLOBAL_TARGET)) {
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
     bool issueMessage = false;
     std::ostringstream e;
-    switch(depender->GetPolicyStatusCMP0046())
-      {
+    switch (depender->GetPolicyStatusCMP0046()) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n";
         issueMessage = true;
@@ -373,66 +333,52 @@ void cmComputeTargetDepends::AddTargetDepend(
       case cmPolicies::REQUIRED_ALWAYS:
         issueMessage = true;
         messageType = cmake::FATAL_ERROR;
-      }
-    if(issueMessage)
-      {
+    }
+    if (issueMessage) {
       cmake* cm = this->GlobalGenerator->GetCMakeInstance();
 
-      e << "The dependency target \"" <<  dependee_name
-        << "\" of target \"" << depender->GetName() << "\" does not exist.";
+      e << "The dependency target \"" << dependee_name << "\" of target \""
+        << depender->GetName() << "\" does not exist.";
 
       cmListFileBacktrace const* backtrace =
         depender->GetUtilityBacktrace(dependee_name);
-      if(backtrace)
-        {
+      if (backtrace) {
         cm->IssueMessage(messageType, e.str(), *backtrace);
-        }
-      else
-        {
+      } else {
         cm->IssueMessage(messageType, e.str());
-        }
-
       }
     }
+  }
 
   // Skip targets that will not really be linked.  This is probably a
   // name conflict between an external library and an executable
   // within the project.
-  if(linking && dependee &&
-     dependee->GetType() == cmState::EXECUTABLE &&
-     !dependee->IsExecutableWithExports())
-    {
+  if (linking && dependee && dependee->GetType() == cmState::EXECUTABLE &&
+      !dependee->IsExecutableWithExports()) {
     dependee = 0;
-    }
+  }
 
-  if(dependee)
-    {
+  if (dependee) {
     this->AddTargetDepend(depender_index, dependee, linking);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddTargetDepend(int depender_index,
                                              const cmGeneratorTarget* dependee,
                                              bool linking)
 {
-  if(dependee->IsImported() ||
-     dependee->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (dependee->IsImported() ||
+      dependee->GetType() == cmState::INTERFACE_LIBRARY) {
     // Skip IMPORTED and INTERFACE targets but follow their utility
     // dependencies.
     std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
-    for(std::set<cmLinkItem>::const_iterator i = utils.begin();
-        i != utils.end(); ++i)
-      {
-      if(cmGeneratorTarget const* transitive_dependee = i->Target)
-        {
+    for (std::set<cmLinkItem>::const_iterator i = utils.begin();
+         i != utils.end(); ++i) {
+      if (cmGeneratorTarget const* transitive_dependee = i->Target) {
         this->AddTargetDepend(depender_index, transitive_dependee, false);
-        }
       }
     }
-  else
-    {
+  } else {
     // Lookup the index for this target.  All targets should be known by
     // this point.
     std::map<cmGeneratorTarget const*, int>::const_iterator tii =
@@ -443,100 +389,82 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
     // Add this entry to the dependency graph.
     this->InitialGraph[depender_index].push_back(
       cmGraphEdge(dependee_index, !linking));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeTargetDepends::DisplayGraph(Graph const& graph,
-                                     const std::string& name)
+void cmComputeTargetDepends::DisplayGraph(Graph const& graph,
+                                          const std::string& 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)
-    {
+  for (int depender_index = 0; depender_index < n; ++depender_index) {
     EdgeList const& nl = graph[depender_index];
     cmGeneratorTarget const* depender = this->Targets[depender_index];
-    fprintf(stderr, "target %d is [%s]\n",
-            depender_index, depender->GetName().c_str());
-    for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
+    fprintf(stderr, "target %d is [%s]\n", depender_index,
+            depender->GetName().c_str());
+    for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
       int dependee_index = *ni;
       cmGeneratorTarget const* dependee = this->Targets[dependee_index];
       fprintf(stderr, "  depends on target %d [%s] (%s)\n", dependee_index,
-              dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
-      }
+              dependee->GetName().c_str(), ni->IsStrong() ? "strong" : "weak");
     }
+  }
   fprintf(stderr, "\n");
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeTargetDepends
-::DisplayComponents(cmComputeComponentGraph const& ccg)
+void cmComputeTargetDepends::DisplayComponents(
+  cmComputeComponentGraph const& ccg)
 {
   fprintf(stderr, "The strongly connected components are:\n");
   std::vector<NodeList> const& components = ccg.GetComponents();
   int n = static_cast<int>(components.size());
-  for(int c = 0; c < n; ++c)
-    {
+  for (int c = 0; c < n; ++c) {
     NodeList const& nl = components[c];
     fprintf(stderr, "Component (%d):\n", c);
-    for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
+    for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
       int i = *ni;
-      fprintf(stderr, "  contains target %d [%s]\n",
-              i, this->Targets[i]->GetName().c_str());
-      }
+      fprintf(stderr, "  contains target %d [%s]\n", i,
+              this->Targets[i]->GetName().c_str());
     }
+  }
   fprintf(stderr, "\n");
 }
 
-//----------------------------------------------------------------------------
-bool
-cmComputeTargetDepends
-::CheckComponents(cmComputeComponentGraph const& ccg)
+bool cmComputeTargetDepends::CheckComponents(
+  cmComputeComponentGraph const& ccg)
 {
   // All non-trivial components should consist only of static
   // libraries.
   std::vector<NodeList> const& components = ccg.GetComponents();
   int nc = static_cast<int>(components.size());
-  for(int c=0; c < nc; ++c)
-    {
+  for (int c = 0; c < nc; ++c) {
     // Get the current component.
     NodeList const& nl = components[c];
 
     // Skip trivial components.
-    if(nl.size() < 2)
-      {
+    if (nl.size() < 2) {
       continue;
-      }
+    }
 
     // Immediately complain if no cycles are allowed at all.
-    if(this->NoCycles)
-      {
+    if (this->NoCycles) {
       this->ComplainAboutBadComponent(ccg, c);
       return false;
-      }
+    }
 
     // Make sure the component is all STATIC_LIBRARY targets.
-    for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
-      if(this->Targets[*ni]->GetType() != cmState::STATIC_LIBRARY)
-        {
+    for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
+      if (this->Targets[*ni]->GetType() != cmState::STATIC_LIBRARY) {
         this->ComplainAboutBadComponent(ccg, c);
         return false;
-        }
       }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmComputeTargetDepends
-::ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c,
-                            bool strong)
+void cmComputeTargetDepends::ComplainAboutBadComponent(
+  cmComputeComponentGraph const& ccg, int c, bool strong)
 {
   // Construct the error message.
   std::ostringstream e;
@@ -545,8 +473,7 @@ cmComputeTargetDepends
   std::vector<NodeList> const& components = ccg.GetComponents();
   std::vector<int> const& cmap = ccg.GetComponentMap();
   NodeList const& cl = components[c];
-  for(NodeList::const_iterator ci = cl.begin(); ci != cl.end(); ++ci)
-    {
+  for (NodeList::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) {
     // Get the depender.
     int i = *ci;
     cmGeneratorTarget const* depender = this->Targets[i];
@@ -557,84 +484,66 @@ cmComputeTargetDepends
 
     // List its dependencies that are inside the component.
     EdgeList const& nl = this->InitialGraph[i];
-    for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
+    for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
       int j = *ni;
-      if(cmap[j] == c)
-        {
+      if (cmap[j] == c) {
         cmGeneratorTarget const* dependee = this->Targets[j];
         e << "    depends on \"" << dependee->GetName() << "\""
-          << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n";
-        }
+          << " (" << (ni->IsStrong() ? "strong" : "weak") << ")\n";
       }
     }
-  if(strong)
-    {
+  }
+  if (strong) {
     // Custom command executable dependencies cannot occur within a
     // component of static libraries.  The cycle must appear in calls
     // to add_dependencies.
     e << "The component contains at least one cycle consisting of strong "
       << "dependencies (created by add_dependencies) that cannot be broken.";
-    }
-  else if(this->NoCycles)
-    {
+  } else if (this->NoCycles) {
     e << "The GLOBAL_DEPENDS_NO_CYCLES global property is enabled, so "
       << "cyclic dependencies are not allowed even among static libraries.";
-    }
-  else
-    {
+  } else {
     e << "At least one of these targets is not a STATIC_LIBRARY.  "
       << "Cyclic dependencies are allowed only among static libraries.";
-    }
+  }
   cmSystemTools::Error(e.str().c_str());
 }
 
-//----------------------------------------------------------------------------
-bool
-cmComputeTargetDepends
-::IntraComponent(std::vector<int> const& cmap, int c, int i, int* head,
-                 std::set<int>& emitted, std::set<int>& visited)
+bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
+                                            int c, int i, int* head,
+                                            std::set<int>& emitted,
+                                            std::set<int>& visited)
 {
-  if(!visited.insert(i).second)
-    {
+  if (!visited.insert(i).second) {
     // Cycle in utility depends!
     return false;
-    }
-  if(emitted.insert(i).second)
-    {
+  }
+  if (emitted.insert(i).second) {
     // Honor strong intra-component edges in the final order.
     EdgeList const& el = this->InitialGraph[i];
-    for(EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei)
-      {
+    for (EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei) {
       int j = *ei;
-      if(cmap[j] == c && ei->IsStrong())
-        {
+      if (cmap[j] == c && ei->IsStrong()) {
         this->FinalGraph[i].push_back(cmGraphEdge(j, true));
-        if(!this->IntraComponent(cmap, c, j, head, emitted, visited))
-          {
+        if (!this->IntraComponent(cmap, c, j, head, emitted, visited)) {
           return false;
-          }
         }
       }
+    }
 
     // Prepend to a linear linked-list of intra-component edges.
-    if(*head >= 0)
-      {
+    if (*head >= 0) {
       this->FinalGraph[i].push_back(cmGraphEdge(*head, false));
-      }
-    else
-      {
+    } else {
       this->ComponentTail[c] = i;
-      }
-    *head = i;
     }
+    *head = i;
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmComputeTargetDepends
-::ComputeFinalDepends(cmComputeComponentGraph const& ccg)
+bool cmComputeTargetDepends::ComputeFinalDepends(
+  cmComputeComponentGraph const& ccg)
 {
   // Get the component graph information.
   std::vector<NodeList> const& components = ccg.GetComponents();
@@ -649,38 +558,34 @@ cmComputeTargetDepends
   this->ComponentHead.resize(components.size());
   this->ComponentTail.resize(components.size());
   int nc = static_cast<int>(components.size());
-  for(int c=0; c < nc; ++c)
-    {
+  for (int c = 0; c < nc; ++c) {
     int head = -1;
     std::set<int> emitted;
     NodeList const& nl = components[c];
-    for(NodeList::const_reverse_iterator ni = nl.rbegin();
-        ni != nl.rend(); ++ni)
-      {
+    for (NodeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
+         ++ni) {
       std::set<int> visited;
-      if(!this->IntraComponent(cmap, c, *ni, &head, emitted, visited))
-        {
+      if (!this->IntraComponent(cmap, c, *ni, &head, emitted, visited)) {
         // Cycle in add_dependencies within component!
         this->ComplainAboutBadComponent(ccg, c, true);
         return false;
-        }
       }
-    this->ComponentHead[c] = head;
     }
+    this->ComponentHead[c] = head;
+  }
 
   // Convert inter-component edges to connect component tails to heads.
   int n = static_cast<int>(cgraph.size());
-  for(int depender_component=0; depender_component < n; ++depender_component)
-    {
+  for (int depender_component = 0; depender_component < n;
+       ++depender_component) {
     int depender_component_tail = this->ComponentTail[depender_component];
     EdgeList const& nl = cgraph[depender_component];
-    for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
-      {
+    for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
       int dependee_component = *ni;
       int dependee_component_head = this->ComponentHead[dependee_component];
-      this->FinalGraph[depender_component_tail]
-        .push_back(cmGraphEdge(dependee_component_head, ni->IsStrong()));
-      }
+      this->FinalGraph[depender_component_tail].push_back(
+        cmGraphEdge(dependee_component_head, ni->IsStrong()));
     }
+  }
   return true;
 }
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index 6100d97..9e51d4d 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -39,27 +39,28 @@ public:
 
   bool Compute();
 
-  std::vector<cmGeneratorTarget const*> const&
-  GetTargets() const { return this->Targets; }
+  std::vector<cmGeneratorTarget const*> const& GetTargets() const
+  {
+    return this->Targets;
+  }
   void GetTargetDirectDepends(cmGeneratorTarget const* t,
                               cmTargetDependSet& deps);
+
 private:
   void CollectTargets();
   void CollectDepends();
   void CollectTargetDepends(int depender_index);
-  void AddTargetDepend(int depender_index,
-                       cmLinkItem const& dependee_name,
+  void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name,
                        bool linking);
   void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
                        bool linking);
   bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
-  void AddInterfaceDepends(int depender_index,
-                           cmLinkItem const& dependee_name,
-                           std::set<std::string> &emitted);
+  void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
+                           std::set<std::string>& emitted);
   void AddInterfaceDepends(int depender_index,
                            cmGeneratorTarget const* dependee,
                            const std::string& config,
-                           std::set<std::string> &emitted);
+                           std::set<std::string>& emitted);
   cmGlobalGenerator* GlobalGenerator;
   bool DebugMode;
   bool NoCycles;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 6a0ebec..7006b62 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -11,21 +11,48 @@
 ============================================================================*/
 
 #include "cmConditionEvaluator.h"
-#include "cmOutputConverter.h"
+
 #include "cmAlgorithms.h"
+#include "cmOutputConverter.h"
+
+static std::string const keyAND = "AND";
+static std::string const keyCOMMAND = "COMMAND";
+static std::string const keyDEFINED = "DEFINED";
+static std::string const keyEQUAL = "EQUAL";
+static std::string const keyEXISTS = "EXISTS";
+static std::string const keyGREATER = "GREATER";
+static std::string const keyIN_LIST = "IN_LIST";
+static std::string const keyIS_ABSOLUTE = "IS_ABSOLUTE";
+static std::string const keyIS_DIRECTORY = "IS_DIRECTORY";
+static std::string const keyIS_NEWER_THAN = "IS_NEWER_THAN";
+static std::string const keyIS_SYMLINK = "IS_SYMLINK";
+static std::string const keyLESS = "LESS";
+static std::string const keyMATCHES = "MATCHES";
+static std::string const keyNOT = "NOT";
+static std::string const keyOR = "OR";
+static std::string const keyParenL = "(";
+static std::string const keyParenR = ")";
+static std::string const keyPOLICY = "POLICY";
+static std::string const keySTREQUAL = "STREQUAL";
+static std::string const keySTRGREATER = "STRGREATER";
+static std::string const keySTRLESS = "STRLESS";
+static std::string const keyTARGET = "TARGET";
+static std::string const keyTEST = "TEST";
+static std::string const keyVERSION_EQUAL = "VERSION_EQUAL";
+static std::string const keyVERSION_GREATER = "VERSION_GREATER";
+static std::string const keyVERSION_LESS = "VERSION_LESS";
 
 cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
-                                           const cmListFileContext &context,
-                                           const cmListFileBacktrace& bt):
-  Makefile(makefile),
-  ExecutionContext(context),
-  Backtrace(bt),
-  Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)),
-  Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)),
-  Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)),
-  Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064))
+                                           const cmListFileContext& context,
+                                           const cmListFileBacktrace& bt)
+  : Makefile(makefile)
+  , ExecutionContext(context)
+  , Backtrace(bt)
+  , Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012))
+  , Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054))
+  , Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057))
+  , Policy64Status(makefile.GetPolicyStatus(cmPolicies::CMP0064))
 {
-
 }
 
 //=========================================================================
@@ -45,17 +72,15 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
 // directly. AND OR take variables or the values 0 or 1.
 
 bool cmConditionEvaluator::IsTrue(
-  const std::vector<cmExpandedCommandArgument> &args,
-  std::string &errorString,
-  cmake::MessageType &status)
+  const std::vector<cmExpandedCommandArgument>& args, std::string& errorString,
+  cmake::MessageType& status)
 {
   errorString = "";
 
   // handle empty invocation
-  if (args.size() < 1)
-    {
+  if (args.size() < 1) {
     return false;
-    }
+  }
 
   // store the reduced args in this vector
   cmArgumentList newArgs;
@@ -66,142 +91,109 @@ bool cmConditionEvaluator::IsTrue(
   // now loop through the arguments and see if we can reduce any of them
   // we do this multiple times. Once for each level of precedence
   // parens
-  if (!this->HandleLevel0(newArgs, errorString, status))
-    {
+  if (!this->HandleLevel0(newArgs, errorString, status)) {
     return false;
-    }
-  //predicates
-  if (!this->HandleLevel1(newArgs, errorString, status))
-    {
+  }
+  // predicates
+  if (!this->HandleLevel1(newArgs, errorString, status)) {
     return false;
-    }
+  }
   // binary ops
-  if (!this->HandleLevel2(newArgs, errorString, status))
-    {
+  if (!this->HandleLevel2(newArgs, errorString, status)) {
     return false;
-    }
+  }
 
   // NOT
-  if (!this->HandleLevel3(newArgs, errorString, status))
-    {
+  if (!this->HandleLevel3(newArgs, errorString, status)) {
     return false;
-    }
+  }
   // AND OR
-  if (!this->HandleLevel4(newArgs, errorString, status))
-    {
+  if (!this->HandleLevel4(newArgs, errorString, status)) {
     return false;
-    }
+  }
 
   // now at the end there should only be one argument left
-  if (newArgs.size() != 1)
-    {
+  if (newArgs.size() != 1) {
     errorString = "Unknown arguments specified";
     status = cmake::FATAL_ERROR;
     return false;
-    }
+  }
 
   return this->GetBooleanValueWithAutoDereference(*(newArgs.begin()),
-    errorString, status, true);
-}
-
-cmListFileContext cmConditionEvaluator::GetConditionContext(
-    cmMakefile* mf,
-    const cmCommandContext& command,
-    const std::string& filePath)
-{
-  cmListFileContext context =
-      cmListFileContext::FromCommandContext(
-        command,
-        filePath);
-
-  if(!mf->GetCMakeInstance()->GetIsInTryCompile())
-    {
-    cmOutputConverter converter(mf->GetStateSnapshot());
-    context.FilePath = converter.Convert(context.FilePath,
-                                         cmOutputConverter::HOME);
-    }
-  return context;
+                                                  errorString, status, true);
 }
 
 //=========================================================================
 const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
   cmExpandedCommandArgument const& argument) const
 {
-  if((this->Policy54Status != cmPolicies::WARN &&
-     this->Policy54Status != cmPolicies::OLD) &&
-     argument.WasQuoted())
-    {
+  if ((this->Policy54Status != cmPolicies::WARN &&
+       this->Policy54Status != cmPolicies::OLD) &&
+      argument.WasQuoted()) {
     return 0;
-    }
+  }
 
   const char* def = this->Makefile.GetDefinition(argument.GetValue());
 
-  if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN)
-    {
-    if(!this->Makefile.HasCMP0054AlreadyBeenReported(
-         this->ExecutionContext))
-      {
+  if (def && argument.WasQuoted() &&
+      this->Policy54Status == cmPolicies::WARN) {
+    if (!this->Makefile.HasCMP0054AlreadyBeenReported(
+          this->ExecutionContext)) {
       std::ostringstream e;
       e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n";
-      e << "Quoted variables like \"" << argument.GetValue() <<
-        "\" will no longer be dereferenced "
-        "when the policy is set to NEW.  "
-        "Since the policy is not set the OLD behavior will be used.";
-
-      this->Makefile.GetCMakeInstance()
-          ->IssueMessage(cmake::AUTHOR_WARNING, e.str(),
-                         this->Backtrace);
-      }
+      e << "Quoted variables like \"" << argument.GetValue()
+        << "\" will no longer be dereferenced "
+           "when the policy is set to NEW.  "
+           "Since the policy is not set the OLD behavior will be used.";
+
+      this->Makefile.GetCMakeInstance()->IssueMessage(
+        cmake::AUTHOR_WARNING, e.str(), this->Backtrace);
     }
+  }
 
   return def;
 }
 
 //=========================================================================
 const char* cmConditionEvaluator::GetVariableOrString(
-    const cmExpandedCommandArgument& argument) const
+  const cmExpandedCommandArgument& argument) const
 {
   const char* def = this->GetDefinitionIfUnquoted(argument);
 
-  if(!def)
-    {
+  if (!def) {
     def = argument.c_str();
-    }
+  }
 
   return def;
 }
 
 //=========================================================================
 bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
-  cmExpandedCommandArgument& argument) const
+                                     cmExpandedCommandArgument& argument) const
 {
-  if((this->Policy54Status != cmPolicies::WARN &&
-     this->Policy54Status != cmPolicies::OLD) &&
-     argument.WasQuoted())
-    {
+  if ((this->Policy54Status != cmPolicies::WARN &&
+       this->Policy54Status != cmPolicies::OLD) &&
+      argument.WasQuoted()) {
     return false;
-    }
+  }
 
   bool isKeyword = argument.GetValue() == keyword;
 
-  if(isKeyword && argument.WasQuoted() &&
-    this->Policy54Status == cmPolicies::WARN)
-    {
-    if(!this->Makefile.HasCMP0054AlreadyBeenReported(
-         this->ExecutionContext))
-      {
+  if (isKeyword && argument.WasQuoted() &&
+      this->Policy54Status == cmPolicies::WARN) {
+    if (!this->Makefile.HasCMP0054AlreadyBeenReported(
+          this->ExecutionContext)) {
       std::ostringstream e;
       e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n";
-      e << "Quoted keywords like \"" << argument.GetValue() <<
-        "\" will no longer be interpreted as keywords "
-        "when the policy is set to NEW.  "
-        "Since the policy is not set the OLD behavior will be used.";
-
-      this->Makefile.GetCMakeInstance()
-          ->IssueMessage(cmake::AUTHOR_WARNING, e.str(),
-                         this->Backtrace);
-      }
+      e << "Quoted keywords like \"" << argument.GetValue()
+        << "\" will no longer be interpreted as keywords "
+           "when the policy is set to NEW.  "
+           "Since the policy is not set the OLD behavior will be used.";
+
+      this->Makefile.GetCMakeInstance()->IssueMessage(
+        cmake::AUTHOR_WARNING, e.str(), this->Backtrace);
     }
+  }
 
   return isKeyword;
 }
@@ -211,36 +203,30 @@ bool cmConditionEvaluator::GetBooleanValue(
   cmExpandedCommandArgument& arg) const
 {
   // Check basic constants.
-  if (arg == "0")
-    {
+  if (arg == "0") {
     return false;
-    }
-  if (arg == "1")
-    {
+  }
+  if (arg == "1") {
     return true;
-    }
+  }
 
   // Check named constants.
-  if (cmSystemTools::IsOn(arg.c_str()))
-    {
+  if (cmSystemTools::IsOn(arg.c_str())) {
     return true;
-    }
-  if (cmSystemTools::IsOff(arg.c_str()))
-    {
+  }
+  if (cmSystemTools::IsOff(arg.c_str())) {
     return false;
-    }
+  }
 
   // Check for numbers.
-  if(!arg.empty())
-    {
+  if (!arg.empty()) {
     char* end;
     double d = strtod(arg.c_str(), &end);
-    if(*end == '\0')
-      {
+    if (*end == '\0') {
       // The whole string is a number.  Use C conversion to bool.
-      return d? true:false;
-      }
+      return d ? true : false;
     }
+  }
 
   // Check definition.
   const char* def = this->GetDefinitionIfUnquoted(arg);
@@ -252,179 +238,149 @@ bool cmConditionEvaluator::GetBooleanValue(
 bool cmConditionEvaluator::GetBooleanValueOld(
   cmExpandedCommandArgument const& arg, bool one) const
 {
-  if(one)
-    {
+  if (one) {
     // Old IsTrue behavior for single argument.
-    if(arg == "0")
-      { return false; }
-    else if(arg == "1")
-      { return true; }
-    else
-      {
+    if (arg == "0") {
+      return false;
+    } else if (arg == "1") {
+      return true;
+    } else {
       const char* def = this->GetDefinitionIfUnquoted(arg);
       return !cmSystemTools::IsOff(def);
-      }
     }
-  else
-    {
+  } else {
     // Old GetVariableOrNumber behavior.
     const char* def = this->GetDefinitionIfUnquoted(arg);
-    if(!def && atoi(arg.c_str()))
-      {
+    if (!def && atoi(arg.c_str())) {
       def = arg.c_str();
-      }
-    return !cmSystemTools::IsOff(def);
     }
+    return !cmSystemTools::IsOff(def);
+  }
 }
 
 //=========================================================================
 // returns the resulting boolean value
 bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
-  cmExpandedCommandArgument &newArg,
-  std::string &errorString,
-  cmake::MessageType &status,
-  bool oneArg) const
+  cmExpandedCommandArgument& newArg, std::string& errorString,
+  cmake::MessageType& status, bool oneArg) const
 {
   // Use the policy if it is set.
-  if (this->Policy12Status == cmPolicies::NEW)
-    {
+  if (this->Policy12Status == cmPolicies::NEW) {
     return GetBooleanValue(newArg);
-    }
-  else if (this->Policy12Status == cmPolicies::OLD)
-    {
+  } else if (this->Policy12Status == cmPolicies::OLD) {
     return GetBooleanValueOld(newArg, oneArg);
-    }
+  }
 
   // Check policy only if old and new results differ.
   bool newResult = this->GetBooleanValue(newArg);
   bool oldResult = this->GetBooleanValueOld(newArg, oneArg);
-  if(newResult != oldResult)
-    {
-    switch(this->Policy12Status)
-      {
-      case cmPolicies::WARN:
-        {
-        errorString = "An argument named \"" + newArg.GetValue()
-          + "\" appears in a conditional statement.  "
-          + cmPolicies::GetPolicyWarning(cmPolicies::CMP0012);
+  if (newResult != oldResult) {
+    switch (this->Policy12Status) {
+      case cmPolicies::WARN: {
+        errorString = "An argument named \"" + newArg.GetValue() +
+          "\" appears in a conditional statement.  " +
+          cmPolicies::GetPolicyWarning(cmPolicies::CMP0012);
         status = cmake::AUTHOR_WARNING;
-        }
+      }
       case cmPolicies::OLD:
         return oldResult;
       case cmPolicies::REQUIRED_IF_USED:
-      case cmPolicies::REQUIRED_ALWAYS:
-        {
-        errorString = "An argument named \"" + newArg.GetValue()
-          + "\" appears in a conditional statement.  "
-          + cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0012);
+      case cmPolicies::REQUIRED_ALWAYS: {
+        errorString = "An argument named \"" + newArg.GetValue() +
+          "\" appears in a conditional statement.  " +
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0012);
         status = cmake::FATAL_ERROR;
-        }
+      }
       case cmPolicies::NEW:
         break;
-      }
     }
+  }
   return newResult;
 }
 
 //=========================================================================
-void cmConditionEvaluator::IncrementArguments(cmArgumentList &newArgs,
-                        cmArgumentList::iterator &argP1,
-                        cmArgumentList::iterator &argP2) const
+void cmConditionEvaluator::IncrementArguments(
+  cmArgumentList& newArgs, cmArgumentList::iterator& argP1,
+  cmArgumentList::iterator& argP2) const
 {
-  if (argP1 != newArgs.end())
-    {
+  if (argP1 != newArgs.end()) {
     argP1++;
     argP2 = argP1;
-    if (argP1 != newArgs.end())
-      {
+    if (argP1 != newArgs.end()) {
       argP2++;
-      }
     }
+  }
 }
 
 //=========================================================================
 // helper function to reduce code duplication
-void cmConditionEvaluator::HandlePredicate(bool value, int &reducible,
-                     cmArgumentList::iterator &arg,
-                     cmArgumentList &newArgs,
-                     cmArgumentList::iterator &argP1,
-                     cmArgumentList::iterator &argP2) const
+void cmConditionEvaluator::HandlePredicate(
+  bool value, int& reducible, cmArgumentList::iterator& arg,
+  cmArgumentList& newArgs, cmArgumentList::iterator& argP1,
+  cmArgumentList::iterator& argP2) const
 {
-  if(value)
-    {
+  if (value) {
     *arg = cmExpandedCommandArgument("1", true);
-    }
-  else
-    {
+  } else {
     *arg = cmExpandedCommandArgument("0", true);
-    }
+  }
   newArgs.erase(argP1);
   argP1 = arg;
-  this->IncrementArguments(newArgs,argP1,argP2);
+  this->IncrementArguments(newArgs, argP1, argP2);
   reducible = 1;
 }
 
 //=========================================================================
 // helper function to reduce code duplication
-void cmConditionEvaluator::HandleBinaryOp(bool value, int &reducible,
-                     cmArgumentList::iterator &arg,
-                     cmArgumentList &newArgs,
-                     cmArgumentList::iterator &argP1,
-                     cmArgumentList::iterator &argP2)
+void cmConditionEvaluator::HandleBinaryOp(bool value, int& reducible,
+                                          cmArgumentList::iterator& arg,
+                                          cmArgumentList& newArgs,
+                                          cmArgumentList::iterator& argP1,
+                                          cmArgumentList::iterator& argP2)
 {
-  if(value)
-    {
+  if (value) {
     *arg = cmExpandedCommandArgument("1", true);
-    }
-  else
-    {
+  } else {
     *arg = cmExpandedCommandArgument("0", true);
-    }
+  }
   newArgs.erase(argP2);
   newArgs.erase(argP1);
   argP1 = arg;
-  this->IncrementArguments(newArgs,argP1,argP2);
+  this->IncrementArguments(newArgs, argP1, argP2);
   reducible = 1;
 }
 
 //=========================================================================
 // level 0 processes parenthetical expressions
-bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
-                  std::string &errorString,
-                  cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
+                                        std::string& errorString,
+                                        cmake::MessageType& status)
 {
   int reducible;
-  do
-    {
+  do {
     reducible = 0;
     cmArgumentList::iterator arg = newArgs.begin();
-    while (arg != newArgs.end())
-      {
-      if (IsKeyword("(", *arg))
-        {
+    while (arg != newArgs.end()) {
+      if (IsKeyword(keyParenL, *arg)) {
         // search for the closing paren for this opening one
         cmArgumentList::iterator argClose;
         argClose = arg;
         argClose++;
         unsigned int depth = 1;
-        while (argClose != newArgs.end() && depth)
-          {
-          if (this->IsKeyword("(", *argClose))
-            {
-              depth++;
-            }
-          if (this->IsKeyword(")", *argClose))
-            {
-              depth--;
-            }
-          argClose++;
+        while (argClose != newArgs.end() && depth) {
+          if (this->IsKeyword(keyParenL, *argClose)) {
+            depth++;
           }
-        if (depth)
-          {
+          if (this->IsKeyword(keyParenR, *argClose)) {
+            depth--;
+          }
+          argClose++;
+        }
+        if (depth) {
           errorString = "mismatched parenthesis in condition";
           status = cmake::FATAL_ERROR;
           return false;
-          }
+        }
         // store the reduced args in this vector
         std::vector<cmExpandedCommandArgument> newArgs2;
 
@@ -435,420 +391,337 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
         newArgs2.pop_back();
         // now recursively invoke IsTrue to handle the values inside the
         // parenthetical expression
-        bool value =
-          this->IsTrue(newArgs2, errorString, status);
-        if(value)
-          {
+        bool value = this->IsTrue(newArgs2, errorString, status);
+        if (value) {
           *arg = cmExpandedCommandArgument("1", true);
-          }
-        else
-          {
+        } else {
           *arg = cmExpandedCommandArgument("0", true);
-          }
+        }
         argP1 = arg;
         argP1++;
         // remove the now evaluated parenthetical expression
-        newArgs.erase(argP1,argClose);
-        }
-      ++arg;
+        newArgs.erase(argP1, argClose);
       }
+      ++arg;
     }
-  while (reducible);
+  } while (reducible);
   return true;
 }
 
 //=========================================================================
 // level one handles most predicates except for NOT
-bool cmConditionEvaluator::HandleLevel1(cmArgumentList &newArgs,
-                  std::string &, cmake::MessageType &)
+bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
+                                        cmake::MessageType&)
 {
   int reducible;
-  do
-    {
+  do {
     reducible = 0;
     cmArgumentList::iterator arg = newArgs.begin();
     cmArgumentList::iterator argP1;
     cmArgumentList::iterator argP2;
-    while (arg != newArgs.end())
-      {
+    while (arg != newArgs.end()) {
       argP1 = arg;
-      this->IncrementArguments(newArgs,argP1,argP2);
+      this->IncrementArguments(newArgs, argP1, argP2);
       // does a file exist
-      if (this->IsKeyword("EXISTS", *arg) && argP1 != newArgs.end())
-        {
-        this->HandlePredicate(
-          cmSystemTools::FileExists(argP1->c_str()),
-          reducible, arg, newArgs, argP1, argP2);
-        }
+      if (this->IsKeyword(keyEXISTS, *arg) && argP1 != newArgs.end()) {
+        this->HandlePredicate(cmSystemTools::FileExists(argP1->c_str()),
+                              reducible, arg, newArgs, argP1, argP2);
+      }
       // does a directory with this name exist
-      if (this->IsKeyword("IS_DIRECTORY", *arg) && argP1 != newArgs.end())
-        {
-        this->HandlePredicate(
-          cmSystemTools::FileIsDirectory(argP1->c_str()),
-          reducible, arg, newArgs, argP1, argP2);
-        }
+      if (this->IsKeyword(keyIS_DIRECTORY, *arg) && argP1 != newArgs.end()) {
+        this->HandlePredicate(cmSystemTools::FileIsDirectory(argP1->c_str()),
+                              reducible, arg, newArgs, argP1, argP2);
+      }
       // does a symlink with this name exist
-      if (this->IsKeyword("IS_SYMLINK", *arg) && argP1 != newArgs.end())
-        {
-        this->HandlePredicate(
-          cmSystemTools::FileIsSymlink(argP1->c_str()),
-          reducible, arg, newArgs, argP1, argP2);
-        }
+      if (this->IsKeyword(keyIS_SYMLINK, *arg) && argP1 != newArgs.end()) {
+        this->HandlePredicate(cmSystemTools::FileIsSymlink(argP1->c_str()),
+                              reducible, arg, newArgs, argP1, argP2);
+      }
       // is the given path an absolute path ?
-      if (this->IsKeyword("IS_ABSOLUTE", *arg) && argP1 != newArgs.end())
-        {
-        this->HandlePredicate(
-          cmSystemTools::FileIsFullPath(argP1->c_str()),
-          reducible, arg, newArgs, argP1, argP2);
-        }
+      if (this->IsKeyword(keyIS_ABSOLUTE, *arg) && argP1 != newArgs.end()) {
+        this->HandlePredicate(cmSystemTools::FileIsFullPath(argP1->c_str()),
+                              reducible, arg, newArgs, argP1, argP2);
+      }
       // does a command exist
-      if (this->IsKeyword("COMMAND", *arg) && argP1 != newArgs.end())
-        {
+      if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end()) {
         cmCommand* command =
-            this->Makefile.GetState()->GetCommand(argP1->c_str());
-        this->HandlePredicate(
-          command ? true : false,
-          reducible, arg, newArgs, argP1, argP2);
-        }
+          this->Makefile.GetState()->GetCommand(argP1->c_str());
+        this->HandlePredicate(command ? true : false, reducible, arg, newArgs,
+                              argP1, argP2);
+      }
       // does a policy exist
-      if (this->IsKeyword("POLICY", *arg) && argP1 != newArgs.end())
-        {
+      if (this->IsKeyword(keyPOLICY, *arg) && argP1 != newArgs.end()) {
         cmPolicies::PolicyID pid;
-        this->HandlePredicate(
-          cmPolicies::GetPolicyID(argP1->c_str(), pid),
-            reducible, arg, newArgs, argP1, argP2);
-        }
+        this->HandlePredicate(cmPolicies::GetPolicyID(argP1->c_str(), pid),
+                              reducible, arg, newArgs, argP1, argP2);
+      }
       // does a target exist
-      if (this->IsKeyword("TARGET", *arg) && argP1 != newArgs.end())
-        {
+      if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end()) {
         this->HandlePredicate(
-          this->Makefile.FindTargetToUse(argP1->GetValue())?true:false,
+          this->Makefile.FindTargetToUse(argP1->GetValue()) ? true : false,
           reducible, arg, newArgs, argP1, argP2);
-        }
+      }
       // does a test exist
-      if(this->Policy64Status != cmPolicies::OLD &&
-        this->Policy64Status != cmPolicies::WARN)
-        {
-        if (this->IsKeyword("TEST", *arg) && argP1 != newArgs.end())
-          {
+      if (this->Policy64Status != cmPolicies::OLD &&
+          this->Policy64Status != cmPolicies::WARN) {
+        if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end()) {
           const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str());
-          this->HandlePredicate(
-            haveTest?true:false,
-            reducible, arg, newArgs, argP1, argP2);
-          }
+          this->HandlePredicate(haveTest ? true : false, reducible, arg,
+                                newArgs, argP1, argP2);
         }
-      else if(this->Policy64Status == cmPolicies::WARN &&
-        this->IsKeyword("TEST", *arg))
-        {
+      } else if (this->Policy64Status == cmPolicies::WARN &&
+                 this->IsKeyword(keyTEST, *arg)) {
         std::ostringstream e;
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0064) << "\n";
         e << "TEST will be interpreted as an operator "
-          "when the policy is set to NEW.  "
-          "Since the policy is not set the OLD behavior will be used.";
+             "when the policy is set to NEW.  "
+             "Since the policy is not set the OLD behavior will be used.";
 
         this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
-        }
+      }
       // is a variable defined
-      if (this->IsKeyword("DEFINED", *arg) && argP1 != newArgs.end())
-        {
+      if (this->IsKeyword(keyDEFINED, *arg) && argP1 != newArgs.end()) {
         size_t argP1len = argP1->GetValue().size();
         bool bdef = false;
-        if(argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
-           argP1->GetValue().operator[](argP1len-1) == '}')
-          {
-          std::string env = argP1->GetValue().substr(4, argP1len-5);
-          bdef = cmSystemTools::GetEnv(env.c_str())?true:false;
-          }
-        else
-          {
+        if (argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
+            argP1->GetValue().operator[](argP1len - 1) == '}') {
+          std::string env = argP1->GetValue().substr(4, argP1len - 5);
+          bdef = cmSystemTools::GetEnv(env.c_str()) ? true : false;
+        } else {
           bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
-          }
-        this->HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2);
         }
-      ++arg;
+        this->HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2);
       }
+      ++arg;
     }
-  while (reducible);
+  } while (reducible);
   return true;
 }
 
 //=========================================================================
 // level two handles most binary operations except for AND  OR
-bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
-                  std::string &errorString,
-                  cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
+                                        std::string& errorString,
+                                        cmake::MessageType& status)
 {
   int reducible;
   std::string def_buf;
-  const char *def;
-  const char *def2;
-  do
-    {
+  const char* def;
+  const char* def2;
+  do {
     reducible = 0;
     cmArgumentList::iterator arg = newArgs.begin();
     cmArgumentList::iterator argP1;
     cmArgumentList::iterator argP2;
-    while (arg != newArgs.end())
-      {
+    while (arg != newArgs.end()) {
       argP1 = arg;
-      this->IncrementArguments(newArgs,argP1,argP2);
+      this->IncrementArguments(newArgs, argP1, argP2);
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
-        IsKeyword("MATCHES", *argP1))
-        {
+          IsKeyword(keyMATCHES, *argP1)) {
         def = this->GetVariableOrString(*arg);
         if (def != arg->c_str() // yes, we compare the pointer value
-            && cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_"))
-          {
+            && cmHasLiteralPrefix(arg->GetValue(), "CMAKE_MATCH_")) {
           // The string to match is owned by our match result variables.
           // Move it to our own buffer before clearing them.
           def_buf = def;
           def = def_buf.c_str();
-          }
+        }
         const char* rex = argP2->c_str();
         this->Makefile.ClearMatches();
         cmsys::RegularExpression regEntry;
-        if ( !regEntry.compile(rex) )
-          {
+        if (!regEntry.compile(rex)) {
           std::ostringstream error;
           error << "Regular expression \"" << rex << "\" cannot compile";
           errorString = error.str();
           status = cmake::FATAL_ERROR;
           return false;
-          }
-        if (regEntry.find(def))
-          {
+        }
+        if (regEntry.find(def)) {
           this->Makefile.StoreMatches(regEntry);
           *arg = cmExpandedCommandArgument("1", true);
-          }
-        else
-          {
+        } else {
           *arg = cmExpandedCommandArgument("0", true);
-          }
+        }
         newArgs.erase(argP2);
         newArgs.erase(argP1);
         argP1 = arg;
-        this->IncrementArguments(newArgs,argP1,argP2);
+        this->IncrementArguments(newArgs, argP1, argP2);
         reducible = 1;
-        }
+      }
 
-      if (argP1 != newArgs.end() && this->IsKeyword("MATCHES", *arg))
-        {
+      if (argP1 != newArgs.end() && this->IsKeyword(keyMATCHES, *arg)) {
         *arg = cmExpandedCommandArgument("0", true);
         newArgs.erase(argP1);
         argP1 = arg;
-        this->IncrementArguments(newArgs,argP1,argP2);
+        this->IncrementArguments(newArgs, argP1, argP2);
         reducible = 1;
-        }
+      }
 
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
-        (this->IsKeyword("LESS", *argP1) ||
-         this->IsKeyword("GREATER", *argP1) ||
-         this->IsKeyword("EQUAL", *argP1)))
-        {
+          (this->IsKeyword(keyLESS, *argP1) ||
+           this->IsKeyword(keyGREATER, *argP1) ||
+           this->IsKeyword(keyEQUAL, *argP1))) {
         def = this->GetVariableOrString(*arg);
         def2 = this->GetVariableOrString(*argP2);
         double lhs;
         double rhs;
         bool result;
-        if(sscanf(def, "%lg", &lhs) != 1 ||
-           sscanf(def2, "%lg", &rhs) != 1)
-          {
+        if (sscanf(def, "%lg", &lhs) != 1 || sscanf(def2, "%lg", &rhs) != 1) {
           result = false;
-          }
-        else if (*(argP1) == "LESS")
-          {
+        } else if (*(argP1) == keyLESS) {
           result = (lhs < rhs);
-          }
-        else if (*(argP1) == "GREATER")
-          {
+        } else if (*(argP1) == keyGREATER) {
           result = (lhs > rhs);
-          }
-        else
-          {
+        } else {
           result = (lhs == rhs);
-          }
-        this->HandleBinaryOp(result,
-          reducible, arg, newArgs, argP1, argP2);
         }
+        this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+      }
 
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
-        (this->IsKeyword("STRLESS", *argP1) ||
-         this->IsKeyword("STREQUAL", *argP1) ||
-         this->IsKeyword("STRGREATER", *argP1)))
-        {
+          (this->IsKeyword(keySTRLESS, *argP1) ||
+           this->IsKeyword(keySTREQUAL, *argP1) ||
+           this->IsKeyword(keySTRGREATER, *argP1))) {
         def = this->GetVariableOrString(*arg);
         def2 = this->GetVariableOrString(*argP2);
-        int val = strcmp(def,def2);
+        int val = strcmp(def, def2);
         bool result;
-        if (*(argP1) == "STRLESS")
-          {
+        if (*(argP1) == keySTRLESS) {
           result = (val < 0);
-          }
-        else if (*(argP1) == "STRGREATER")
-          {
+        } else if (*(argP1) == keySTRGREATER) {
           result = (val > 0);
-          }
-        else // strequal
-          {
+        } else // strequal
+        {
           result = (val == 0);
-          }
-        this->HandleBinaryOp(result,
-          reducible, arg, newArgs, argP1, argP2);
         }
+        this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+      }
 
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
-        (this->IsKeyword("VERSION_LESS", *argP1) ||
-         this->IsKeyword("VERSION_GREATER", *argP1) ||
-         this->IsKeyword("VERSION_EQUAL", *argP1)))
-        {
+          (this->IsKeyword(keyVERSION_LESS, *argP1) ||
+           this->IsKeyword(keyVERSION_GREATER, *argP1) ||
+           this->IsKeyword(keyVERSION_EQUAL, *argP1))) {
         def = this->GetVariableOrString(*arg);
         def2 = this->GetVariableOrString(*argP2);
         cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL;
-        if(*argP1 == "VERSION_LESS")
-          {
+        if (*argP1 == keyVERSION_LESS) {
           op = cmSystemTools::OP_LESS;
-          }
-        else if(*argP1 == "VERSION_GREATER")
-          {
+        } else if (*argP1 == keyVERSION_GREATER) {
           op = cmSystemTools::OP_GREATER;
-          }
-        bool result = cmSystemTools::VersionCompare(op, def, def2);
-        this->HandleBinaryOp(result,
-          reducible, arg, newArgs, argP1, argP2);
         }
+        bool result = cmSystemTools::VersionCompare(op, def, def2);
+        this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+      }
 
       // is file A newer than file B
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
-          this->IsKeyword("IS_NEWER_THAN", *argP1))
-        {
-        int fileIsNewer=0;
-        bool success=cmSystemTools::FileTimeCompare(arg->GetValue(),
-            (argP2)->GetValue(),
-            &fileIsNewer);
+          this->IsKeyword(keyIS_NEWER_THAN, *argP1)) {
+        int fileIsNewer = 0;
+        bool success = cmSystemTools::FileTimeCompare(
+          arg->GetValue(), (argP2)->GetValue(), &fileIsNewer);
         this->HandleBinaryOp(
-          (success==false || fileIsNewer==1 || fileIsNewer==0),
+          (success == false || fileIsNewer == 1 || fileIsNewer == 0),
           reducible, arg, newArgs, argP1, argP2);
-        }
+      }
 
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
-          this->IsKeyword("IN_LIST", *argP1))
-        {
-        if(this->Policy57Status != cmPolicies::OLD &&
-          this->Policy57Status != cmPolicies::WARN)
-          {
+          this->IsKeyword(keyIN_LIST, *argP1)) {
+        if (this->Policy57Status != cmPolicies::OLD &&
+            this->Policy57Status != cmPolicies::WARN) {
           bool result = false;
 
           def = this->GetVariableOrString(*arg);
           def2 = this->Makefile.GetDefinition(argP2->GetValue());
 
-          if(def2)
-            {
+          if (def2) {
             std::vector<std::string> list;
             cmSystemTools::ExpandListArgument(def2, list, true);
 
             result = std::find(list.begin(), list.end(), def) != list.end();
-            }
-
-          this->HandleBinaryOp(result,
-            reducible, arg, newArgs, argP1, argP2);
           }
-          else if(this->Policy57Status == cmPolicies::WARN)
-            {
-            std::ostringstream e;
-            e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0057) << "\n";
-            e << "IN_LIST will be interpreted as an operator "
-              "when the policy is set to NEW.  "
-              "Since the policy is not set the OLD behavior will be used.";
-
-            this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
-            }
+
+          this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
+        } else if (this->Policy57Status == cmPolicies::WARN) {
+          std::ostringstream e;
+          e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0057) << "\n";
+          e << "IN_LIST will be interpreted as an operator "
+               "when the policy is set to NEW.  "
+               "Since the policy is not set the OLD behavior will be used.";
+
+          this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
         }
+      }
 
       ++arg;
-      }
     }
-  while (reducible);
+  } while (reducible);
   return true;
 }
 
 //=========================================================================
 // level 3 handles NOT
-bool cmConditionEvaluator::HandleLevel3(cmArgumentList &newArgs,
-                  std::string &errorString,
-                  cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel3(cmArgumentList& newArgs,
+                                        std::string& errorString,
+                                        cmake::MessageType& status)
 {
   int reducible;
-  do
-    {
+  do {
     reducible = 0;
     cmArgumentList::iterator arg = newArgs.begin();
     cmArgumentList::iterator argP1;
     cmArgumentList::iterator argP2;
-    while (arg != newArgs.end())
-      {
+    while (arg != newArgs.end()) {
       argP1 = arg;
-      IncrementArguments(newArgs,argP1,argP2);
-      if (argP1 != newArgs.end() && IsKeyword("NOT", *arg))
-        {
-        bool rhs = this->GetBooleanValueWithAutoDereference(*argP1,
-                                                      errorString,
-                                                      status);
+      IncrementArguments(newArgs, argP1, argP2);
+      if (argP1 != newArgs.end() && IsKeyword(keyNOT, *arg)) {
+        bool rhs = this->GetBooleanValueWithAutoDereference(
+          *argP1, errorString, status);
         this->HandlePredicate(!rhs, reducible, arg, newArgs, argP1, argP2);
-        }
-      ++arg;
       }
+      ++arg;
     }
-  while (reducible);
+  } while (reducible);
   return true;
 }
 
 //=========================================================================
 // level 4 handles AND OR
-bool cmConditionEvaluator::HandleLevel4(cmArgumentList &newArgs,
-                  std::string &errorString,
-                  cmake::MessageType &status)
+bool cmConditionEvaluator::HandleLevel4(cmArgumentList& newArgs,
+                                        std::string& errorString,
+                                        cmake::MessageType& status)
 {
   int reducible;
   bool lhs;
   bool rhs;
-  do
-    {
+  do {
     reducible = 0;
     cmArgumentList::iterator arg = newArgs.begin();
     cmArgumentList::iterator argP1;
     cmArgumentList::iterator argP2;
-    while (arg != newArgs.end())
-      {
+    while (arg != newArgs.end()) {
       argP1 = arg;
-      IncrementArguments(newArgs,argP1,argP2);
-      if (argP1 != newArgs.end() && IsKeyword("AND", *argP1) &&
-        argP2 != newArgs.end())
-        {
-        lhs = this->GetBooleanValueWithAutoDereference(*arg,
-                                                 errorString,
-                                                 status);
-        rhs = this->GetBooleanValueWithAutoDereference(*argP2,
-                                                 errorString,
-                                                 status);
-        this->HandleBinaryOp((lhs && rhs),
-          reducible, arg, newArgs, argP1, argP2);
-        }
+      IncrementArguments(newArgs, argP1, argP2);
+      if (argP1 != newArgs.end() && IsKeyword(keyAND, *argP1) &&
+          argP2 != newArgs.end()) {
+        lhs =
+          this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
+        rhs = this->GetBooleanValueWithAutoDereference(*argP2, errorString,
+                                                       status);
+        this->HandleBinaryOp((lhs && rhs), reducible, arg, newArgs, argP1,
+                             argP2);
+      }
 
-      if (argP1 != newArgs.end() && this->IsKeyword("OR", *argP1) &&
-        argP2 != newArgs.end())
-        {
-        lhs = this->GetBooleanValueWithAutoDereference(*arg,
-                                                 errorString,
-                                                 status);
-        rhs = this->GetBooleanValueWithAutoDereference(*argP2,
-                                                 errorString,
-                                                 status);
-        this->HandleBinaryOp((lhs || rhs),
-          reducible, arg, newArgs, argP1, argP2);
-        }
-      ++arg;
+      if (argP1 != newArgs.end() && this->IsKeyword(keyOR, *argP1) &&
+          argP2 != newArgs.end()) {
+        lhs =
+          this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
+        rhs = this->GetBooleanValueWithAutoDereference(*argP2, errorString,
+                                                       status);
+        this->HandleBinaryOp((lhs || rhs), reducible, arg, newArgs, argP1,
+                             argP2);
       }
+      ++arg;
     }
-  while (reducible);
+  } while (reducible);
   return true;
 }
diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h
index 8600825..3f8c984 100644
--- a/Source/cmConditionEvaluator.h
+++ b/Source/cmConditionEvaluator.h
@@ -22,78 +22,64 @@ class cmConditionEvaluator
 public:
   typedef std::list<cmExpandedCommandArgument> cmArgumentList;
 
-  cmConditionEvaluator(cmMakefile& makefile,
-                       cmListFileContext const& context,
+  cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context,
                        cmListFileBacktrace const& bt);
 
   // this is a shared function for both If and Else to determine if the
   // arguments were valid, and if so, was the response true. If there is
   // an error, the errorString will be set.
-  bool IsTrue(const std::vector<cmExpandedCommandArgument> &args,
-      std::string &errorString,
-      cmake::MessageType &status);
-
-  static cmListFileContext GetConditionContext(cmMakefile* mf,
-      const cmCommandContext& command, std::string const& filePath);
+  bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
+              std::string& errorString, cmake::MessageType& status);
 
 private:
   // Filter the given variable definition based on policy CMP0054.
   const char* GetDefinitionIfUnquoted(
-      const cmExpandedCommandArgument& argument) const;
+    const cmExpandedCommandArgument& argument) const;
 
   const char* GetVariableOrString(
-      const cmExpandedCommandArgument& argument) const;
+    const cmExpandedCommandArgument& argument) const;
 
   bool IsKeyword(std::string const& keyword,
-    cmExpandedCommandArgument& argument) const;
-
-  bool GetBooleanValue(
-    cmExpandedCommandArgument& arg) const;
-
-  bool GetBooleanValueOld(
-    cmExpandedCommandArgument const& arg, bool one) const;
-
-  bool GetBooleanValueWithAutoDereference(
-    cmExpandedCommandArgument &newArg,
-    std::string &errorString,
-    cmake::MessageType &status,
-    bool oneArg = false) const;
-
-  void IncrementArguments(
-    cmArgumentList &newArgs,
-    cmArgumentList::iterator &argP1,
-    cmArgumentList::iterator &argP2) const;
-
-  void HandlePredicate(bool value, int &reducible,
-     cmArgumentList::iterator &arg,
-     cmArgumentList &newArgs,
-     cmArgumentList::iterator &argP1,
-     cmArgumentList::iterator &argP2) const;
-
-  void HandleBinaryOp(bool value, int &reducible,
-     cmArgumentList::iterator &arg,
-     cmArgumentList &newArgs,
-     cmArgumentList::iterator &argP1,
-     cmArgumentList::iterator &argP2);
-
-  bool HandleLevel0(cmArgumentList &newArgs,
-      std::string &errorString,
-      cmake::MessageType &status);
-
-  bool HandleLevel1(cmArgumentList &newArgs,
-      std::string &, cmake::MessageType &);
-
-  bool HandleLevel2(cmArgumentList &newArgs,
-      std::string &errorString,
-      cmake::MessageType &status);
-
-  bool HandleLevel3(cmArgumentList &newArgs,
-      std::string &errorString,
-      cmake::MessageType &status);
-
-  bool HandleLevel4(cmArgumentList &newArgs,
-      std::string &errorString,
-      cmake::MessageType &status);
+                 cmExpandedCommandArgument& argument) const;
+
+  bool GetBooleanValue(cmExpandedCommandArgument& arg) const;
+
+  bool GetBooleanValueOld(cmExpandedCommandArgument const& arg,
+                          bool one) const;
+
+  bool GetBooleanValueWithAutoDereference(cmExpandedCommandArgument& newArg,
+                                          std::string& errorString,
+                                          cmake::MessageType& status,
+                                          bool oneArg = false) const;
+
+  void IncrementArguments(cmArgumentList& newArgs,
+                          cmArgumentList::iterator& argP1,
+                          cmArgumentList::iterator& argP2) const;
+
+  void HandlePredicate(bool value, int& reducible,
+                       cmArgumentList::iterator& arg, cmArgumentList& newArgs,
+                       cmArgumentList::iterator& argP1,
+                       cmArgumentList::iterator& argP2) const;
+
+  void HandleBinaryOp(bool value, int& reducible,
+                      cmArgumentList::iterator& arg, cmArgumentList& newArgs,
+                      cmArgumentList::iterator& argP1,
+                      cmArgumentList::iterator& argP2);
+
+  bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
+                    cmake::MessageType& status);
+
+  bool HandleLevel1(cmArgumentList& newArgs, std::string&,
+                    cmake::MessageType&);
+
+  bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
+                    cmake::MessageType& status);
+
+  bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
+                    cmake::MessageType& status);
+
+  bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
+                    cmake::MessageType& status);
 
   cmMakefile& Makefile;
   cmListFileContext ExecutionContext;
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 46b71c5..899a674 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -14,118 +14,97 @@
 #include <cmsys/RegularExpression.hxx>
 
 // cmConfigureFileCommand
-bool cmConfigureFileCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments, expected 2");
     return false;
-    }
+  }
 
   const char* inFile = args[0].c_str();
-  if(!cmSystemTools::FileIsFullPath(inFile))
-    {
+  if (!cmSystemTools::FileIsFullPath(inFile)) {
     this->InputFile = this->Makefile->GetCurrentSourceDirectory();
     this->InputFile += "/";
-    }
+  }
   this->InputFile += inFile;
 
   // If the input location is a directory, error out.
-  if(cmSystemTools::FileIsDirectory(this->InputFile))
-    {
+  if (cmSystemTools::FileIsDirectory(this->InputFile)) {
     std::ostringstream e;
+    /* clang-format off */
     e << "input location\n"
       << "  " << this->InputFile << "\n"
       << "is a directory but a file was expected.";
+    /* clang-format on */
     this->SetError(e.str());
     return false;
-    }
+  }
 
   const char* outFile = args[1].c_str();
-  if(!cmSystemTools::FileIsFullPath(outFile))
-    {
+  if (!cmSystemTools::FileIsFullPath(outFile)) {
     this->OutputFile = this->Makefile->GetCurrentBinaryDirectory();
     this->OutputFile += "/";
-    }
+  }
   this->OutputFile += outFile;
 
   // If the output location is already a directory put the file in it.
-  if(cmSystemTools::FileIsDirectory(this->OutputFile))
-    {
+  if (cmSystemTools::FileIsDirectory(this->OutputFile)) {
     this->OutputFile += "/";
     this->OutputFile += cmSystemTools::GetFilenameName(inFile);
-    }
+  }
 
-  if ( !this->Makefile->CanIWriteThisFile(this->OutputFile.c_str()) )
-    {
-    std::string e = "attempted to configure a file: " + this->OutputFile
-      + " into a source directory.";
+  if (!this->Makefile->CanIWriteThisFile(this->OutputFile.c_str())) {
+    std::string e = "attempted to configure a file: " + this->OutputFile +
+      " into a source directory.";
     this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
   std::string errorMessage;
-  if (!this->NewLineStyle.ReadFromArguments(args, errorMessage))
-    {
+  if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) {
     this->SetError(errorMessage);
     return false;
-    }
+  }
   this->CopyOnly = false;
   this->EscapeQuotes = false;
 
   std::string unknown_args;
   this->AtOnly = false;
-  for(unsigned int i=2;i < args.size();++i)
-    {
-    if(args[i] == "COPYONLY")
-      {
+  for (unsigned int i = 2; i < args.size(); ++i) {
+    if (args[i] == "COPYONLY") {
       this->CopyOnly = true;
-      if (this->NewLineStyle.IsValid())
-        {
+      if (this->NewLineStyle.IsValid()) {
         this->SetError("COPYONLY could not be used in combination "
                        "with NEWLINE_STYLE");
         return false;
-        }
       }
-    else if(args[i] == "ESCAPE_QUOTES")
-      {
+    } else if (args[i] == "ESCAPE_QUOTES") {
       this->EscapeQuotes = true;
-      }
-    else if(args[i] == "@ONLY")
-      {
+    } else if (args[i] == "@ONLY") {
       this->AtOnly = true;
-      }
-    else if(args[i] == "IMMEDIATE")
-      {
+    } else if (args[i] == "IMMEDIATE") {
       /* Ignore legacy option.  */
-      }
-    else if(args[i] == "NEWLINE_STYLE" ||
-            args[i] == "LF" || args[i] == "UNIX" ||
-            args[i] == "CRLF" || args[i] == "WIN32" ||
-            args[i] == "DOS")
-      {
+    } else if (args[i] == "NEWLINE_STYLE" || args[i] == "LF" ||
+               args[i] == "UNIX" || args[i] == "CRLF" || args[i] == "WIN32" ||
+               args[i] == "DOS") {
       /* Options handled by NewLineStyle member above.  */
-      }
-    else
-      {
+    } else {
       unknown_args += " ";
       unknown_args += args[i];
       unknown_args += "\n";
-      }
     }
-  if (!unknown_args.empty())
-    {
+  }
+  if (!unknown_args.empty()) {
     std::string msg = "configure_file called with unknown argument(s):\n";
     msg += unknown_args;
     this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg);
-    }
+  }
 
-  if ( !this->ConfigureFile() )
-    {
+  if (!this->ConfigureFile()) {
     this->SetError("Problem configuring file");
     return false;
-    }
+  }
 
   return true;
 }
@@ -133,12 +112,6 @@ bool cmConfigureFileCommand
 int cmConfigureFileCommand::ConfigureFile()
 {
   return this->Makefile->ConfigureFile(
-    this->InputFile.c_str(),
-    this->OutputFile.c_str(),
-    this->CopyOnly,
-    this->AtOnly,
-    this->EscapeQuotes,
-    this->NewLineStyle);
+    this->InputFile.c_str(), this->OutputFile.c_str(), this->CopyOnly,
+    this->AtOnly, this->EscapeQuotes, this->NewLineStyle);
 }
-
-
diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h
index 8155ef7..79f00bc 100644
--- a/Source/cmConfigureFileCommand.h
+++ b/Source/cmConfigureFileCommand.h
@@ -19,22 +19,19 @@ class cmConfigureFileCommand : public cmCommand
 public:
   cmTypeMacro(cmConfigureFileCommand, cmCommand);
 
-  virtual cmCommand* Clone()
-    {
-      return new cmConfigureFileCommand;
-    }
+  virtual cmCommand* Clone() { return new cmConfigureFileCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "configure_file";}
+  virtual std::string GetName() const { return "configure_file"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -53,6 +50,4 @@ private:
   bool AtOnly;
 };
 
-
-
 #endif
diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx
index 4a03caa..c8c1b7d 100644
--- a/Source/cmContinueCommand.cxx
+++ b/Source/cmContinueCommand.cxx
@@ -12,28 +12,26 @@
 #include "cmContinueCommand.h"
 
 // cmContinueCommand
-bool cmContinueCommand::InitialPass(std::vector<std::string> const &args,
-                                  cmExecutionStatus &status)
+bool cmContinueCommand::InitialPass(std::vector<std::string> const& args,
+                                    cmExecutionStatus& status)
 {
-  if(!this->Makefile->IsLoopBlock())
-    {
+  if (!this->Makefile->IsLoopBlock()) {
     this->Makefile->IssueMessage(cmake::FATAL_ERROR,
                                  "A CONTINUE command was found outside of a "
                                  "proper FOREACH or WHILE loop scope.");
     cmSystemTools::SetFatalErrorOccured();
     return true;
-    }
+  }
 
   status.SetContinueInvoked(true);
 
-  if(!args.empty())
-    {
+  if (!args.empty()) {
     this->Makefile->IssueMessage(cmake::FATAL_ERROR,
                                  "The CONTINUE command does not accept any "
                                  "arguments.");
     cmSystemTools::SetFatalErrorOccured();
     return true;
-    }
+  }
 
   return true;
 }
diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h
index 093b14f..63ae59d 100644
--- a/Source/cmContinueCommand.h
+++ b/Source/cmContinueCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmContinueCommand;
-    }
+  virtual cmCommand* Clone() { return new cmContinueCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -50,6 +47,4 @@ public:
   cmTypeMacro(cmContinueCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 4a1f770..75d0e9e 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -10,22 +10,72 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCoreTryCompile.h"
-#include "cmake.h"
-#include "cmOutputConverter.h"
-#include "cmGlobalGenerator.h"
+
 #include "cmAlgorithms.h"
 #include "cmExportTryCompileFileGenerator.h"
+#include "cmGlobalGenerator.h"
+#include "cmOutputConverter.h"
+#include "cmake.h"
 #include <cmsys/Directory.hxx>
 
 #include <assert.h>
 
-int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
+static std::string const kCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN =
+  "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN";
+static std::string const kCMAKE_C_COMPILER_TARGET = "CMAKE_C_COMPILER_TARGET";
+static std::string const kCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN =
+  "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN";
+static std::string const kCMAKE_CXX_COMPILER_TARGET =
+  "CMAKE_CXX_COMPILER_TARGET";
+static std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS";
+static std::string const kCMAKE_LINK_SEARCH_END_STATIC =
+  "CMAKE_LINK_SEARCH_END_STATIC";
+static std::string const kCMAKE_LINK_SEARCH_START_STATIC =
+  "CMAKE_LINK_SEARCH_START_STATIC";
+static std::string const kCMAKE_OSX_ARCHITECTURES = "CMAKE_OSX_ARCHITECTURES";
+static std::string const kCMAKE_OSX_DEPLOYMENT_TARGET =
+  "CMAKE_OSX_DEPLOYMENT_TARGET";
+static std::string const kCMAKE_OSX_SYSROOT = "CMAKE_OSX_SYSROOT";
+static std::string const kCMAKE_POSITION_INDEPENDENT_CODE =
+  "CMAKE_POSITION_INDEPENDENT_CODE";
+static std::string const kCMAKE_SYSROOT = "CMAKE_SYSROOT";
+static std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES =
+  "CMAKE_TRY_COMPILE_OSX_ARCHITECTURES";
+static std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES =
+  "CMAKE_TRY_COMPILE_PLATFORM_VARIABLES";
+
+int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
+                                     bool isTryRun)
 {
   this->BinaryDirectory = argv[1].c_str();
   this->OutputFile = "";
   // which signature were we called with ?
   this->SrcFileSignature = true;
 
+  cmState::TargetType targetType = cmState::EXECUTABLE;
+  const char* tt =
+    this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE");
+  if (!isTryRun && tt && *tt) {
+    if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0) {
+      targetType = cmState::EXECUTABLE;
+    } else if (strcmp(tt, cmState::GetTargetTypeName(
+                            cmState::STATIC_LIBRARY)) == 0) {
+      targetType = cmState::STATIC_LIBRARY;
+    } else {
+      this->Makefile->IssueMessage(
+        cmake::FATAL_ERROR, std::string("Invalid value '") + tt +
+          "' for "
+          "CMAKE_TRY_COMPILE_TARGET_TYPE.  Only "
+          "'" +
+          cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and "
+                                                            "'" +
+          cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) +
+          "' "
+          "are allowed.");
+      return -1;
+    }
+  }
+
   const char* sourceDirectory = argv[2].c_str();
   const char* projectName = 0;
   std::string targetName;
@@ -44,213 +94,176 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
   bool useSources = argv[2] == "SOURCES";
   std::vector<std::string> sources;
 
-  enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions,
-               DoingLinkLibraries, DoingOutputVariable, DoingCopyFile,
-               DoingCopyFileError, DoingSources };
-  Doing doing = useSources? DoingSources : DoingNone;
-  for(size_t i=3; i < argv.size(); ++i)
-    {
-    if(argv[i] == "CMAKE_FLAGS")
-      {
+  enum Doing
+  {
+    DoingNone,
+    DoingCMakeFlags,
+    DoingCompileDefinitions,
+    DoingLinkLibraries,
+    DoingOutputVariable,
+    DoingCopyFile,
+    DoingCopyFileError,
+    DoingSources
+  };
+  Doing doing = useSources ? DoingSources : DoingNone;
+  for (size_t i = 3; i < argv.size(); ++i) {
+    if (argv[i] == "CMAKE_FLAGS") {
       doing = DoingCMakeFlags;
-      }
-    else if(argv[i] == "COMPILE_DEFINITIONS")
-      {
+    } else if (argv[i] == "COMPILE_DEFINITIONS") {
       doing = DoingCompileDefinitions;
-      }
-    else if(argv[i] == "LINK_LIBRARIES")
-      {
+    } else if (argv[i] == "LINK_LIBRARIES") {
       doing = DoingLinkLibraries;
       useOldLinkLibs = false;
-      }
-    else if(argv[i] == "OUTPUT_VARIABLE")
-      {
+    } else if (argv[i] == "OUTPUT_VARIABLE") {
       doing = DoingOutputVariable;
       didOutputVariable = true;
-      }
-    else if(argv[i] == "COPY_FILE")
-      {
+    } else if (argv[i] == "COPY_FILE") {
       doing = DoingCopyFile;
       didCopyFile = true;
-      }
-    else if(argv[i] == "COPY_FILE_ERROR")
-      {
+    } else if (argv[i] == "COPY_FILE_ERROR") {
       doing = DoingCopyFileError;
       didCopyFileError = true;
-      }
-    else if(doing == DoingCMakeFlags)
-      {
+    } else if (doing == DoingCMakeFlags) {
       cmakeFlags.push_back(argv[i]);
-      }
-    else if(doing == DoingCompileDefinitions)
-      {
+    } else if (doing == DoingCompileDefinitions) {
       compileDefs.push_back(argv[i]);
-      }
-    else if(doing == DoingLinkLibraries)
-      {
+    } else if (doing == DoingLinkLibraries) {
       libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
-      if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i]))
-        {
-        switch(tgt->GetType())
-          {
+      if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) {
+        switch (tgt->GetType()) {
           case cmState::SHARED_LIBRARY:
           case cmState::STATIC_LIBRARY:
           case cmState::INTERFACE_LIBRARY:
           case cmState::UNKNOWN_LIBRARY:
             break;
           case cmState::EXECUTABLE:
-            if (tgt->IsExecutableWithExports())
-              {
+            if (tgt->IsExecutableWithExports()) {
               break;
-              }
+            }
           default:
-            this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+            this->Makefile->IssueMessage(
+              cmake::FATAL_ERROR,
               "Only libraries may be used as try_compile or try_run IMPORTED "
-              "LINK_LIBRARIES.  Got " + std::string(tgt->GetName()) + " of "
-              "type " + cmState::GetTargetTypeName(tgt->GetType()) + ".");
+              "LINK_LIBRARIES.  Got " +
+                std::string(tgt->GetName()) + " of "
+                                              "type " +
+                cmState::GetTargetTypeName(tgt->GetType()) + ".");
             return -1;
-          }
-        if (tgt->IsImported())
-          {
+        }
+        if (tgt->IsImported()) {
           targets.push_back(argv[i]);
-          }
         }
       }
-    else if(doing == DoingOutputVariable)
-      {
+    } else if (doing == DoingOutputVariable) {
       outputVariable = argv[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingCopyFile)
-      {
+    } else if (doing == DoingCopyFile) {
       copyFile = argv[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingCopyFileError)
-      {
+    } else if (doing == DoingCopyFileError) {
       copyFileError = argv[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingSources)
-      {
+    } else if (doing == DoingSources) {
       sources.push_back(argv[i]);
-      }
-    else if(i == 3)
-      {
+    } else if (i == 3) {
       this->SrcFileSignature = false;
       projectName = argv[i].c_str();
-      }
-    else if(i == 4 && !this->SrcFileSignature)
-      {
+    } else if (i == 4 && !this->SrcFileSignature) {
       targetName = argv[i].c_str();
-      }
-    else
-      {
+    } else {
       std::ostringstream m;
       m << "try_compile given unknown argument \"" << argv[i] << "\".";
       this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
-      }
     }
+  }
 
-  if(didCopyFile && copyFile.empty())
-    {
+  if (didCopyFile && copyFile.empty()) {
     this->Makefile->IssueMessage(cmake::FATAL_ERROR,
-      "COPY_FILE must be followed by a file path");
+                                 "COPY_FILE must be followed by a file path");
     return -1;
-    }
+  }
 
-  if(didCopyFileError && copyFileError.empty())
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+  if (didCopyFileError && copyFileError.empty()) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
       "COPY_FILE_ERROR must be followed by a variable name");
     return -1;
-    }
+  }
 
-  if(didCopyFileError && !didCopyFile)
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
-      "COPY_FILE_ERROR may be used only with COPY_FILE");
+  if (didCopyFileError && !didCopyFile) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR, "COPY_FILE_ERROR may be used only with COPY_FILE");
     return -1;
-    }
+  }
 
-  if(didOutputVariable && outputVariable.empty())
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+  if (didOutputVariable && outputVariable.empty()) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
       "OUTPUT_VARIABLE must be followed by a variable name");
     return -1;
-    }
+  }
 
-  if(useSources && sources.empty())
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+  if (useSources && sources.empty()) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
       "SOURCES must be followed by at least one source file");
     return -1;
-    }
+  }
 
   // compute the binary dir when TRY_COMPILE is called with a src file
   // signature
-  if (this->SrcFileSignature)
-    {
+  if (this->SrcFileSignature) {
     this->BinaryDirectory += cmake::GetCMakeFilesDirectory();
     this->BinaryDirectory += "/CMakeTmp";
-    }
-  else
-    {
+  } else {
     // only valid for srcfile signatures
-    if (!compileDefs.empty())
-      {
-      this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+    if (!compileDefs.empty()) {
+      this->Makefile->IssueMessage(
+        cmake::FATAL_ERROR,
         "COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE");
       return -1;
-      }
-    if (!copyFile.empty())
-      {
-      this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+    }
+    if (!copyFile.empty()) {
+      this->Makefile->IssueMessage(
+        cmake::FATAL_ERROR,
         "COPY_FILE specified on a srcdir type TRY_COMPILE");
       return -1;
-      }
     }
+  }
   // make sure the binary directory exists
   cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str());
 
   // do not allow recursive try Compiles
-  if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory())
-    {
+  if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) {
     std::ostringstream e;
     e << "Attempt at a recursive or nested TRY_COMPILE in directory\n"
       << "  " << this->BinaryDirectory << "\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return -1;
-    }
+  }
 
   std::string outFileName = this->BinaryDirectory + "/CMakeLists.txt";
   // which signature are we using? If we are using var srcfile bindir
-  if (this->SrcFileSignature)
-    {
+  if (this->SrcFileSignature) {
     // remove any CMakeCache.txt files so we will have a clean test
     std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt";
     cmSystemTools::RemoveFile(ccFile);
 
     // Choose sources.
-    if(!useSources)
-      {
+    if (!useSources) {
       sources.push_back(argv[2]);
-      }
+    }
 
     // Detect languages to enable.
     cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
     std::set<std::string> testLangs;
-    for(std::vector<std::string>::iterator si = sources.begin();
-        si != sources.end(); ++si)
-      {
+    for (std::vector<std::string>::iterator si = sources.begin();
+         si != sources.end(); ++si) {
       std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
       std::string lang = gg->GetLanguageFromExtension(ext.c_str());
-      if(!lang.empty())
-        {
+      if (!lang.empty()) {
         testLangs.insert(lang);
-        }
-      else
-        {
+      } else {
         std::ostringstream err;
         err << "Unknown extension \"" << ext << "\" for file\n"
             << "  " << *si << "\n"
@@ -262,80 +275,79 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
         err << "\nSee project() command to enable other languages.";
         this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str());
         return -1;
-        }
       }
+    }
+
+    std::string const tcConfig =
+      this->Makefile->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
 
     // we need to create a directory and CMakeLists file etc...
     // first create the directories
     sourceDirectory = this->BinaryDirectory.c_str();
 
     // now create a CMakeLists.txt file in that directory
-    FILE *fout = cmsys::SystemTools::Fopen(outFileName,"w");
-    if (!fout)
-      {
+    FILE* fout = cmsys::SystemTools::Fopen(outFileName, "w");
+    if (!fout) {
       std::ostringstream e;
+      /* clang-format off */
       e << "Failed to open\n"
         << "  " << outFileName << "\n"
         << cmSystemTools::GetLastSystemError();
+      /* clang-format on */
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return -1;
-      }
+    }
 
     const char* def = this->Makefile->GetDefinition("CMAKE_MODULE_PATH");
     fprintf(fout, "cmake_minimum_required(VERSION %u.%u.%u.%u)\n",
             cmVersion::GetMajorVersion(), cmVersion::GetMinorVersion(),
             cmVersion::GetPatchVersion(), cmVersion::GetTweakVersion());
-    if(def)
-      {
+    if (def) {
       fprintf(fout, "set(CMAKE_MODULE_PATH \"%s\")\n", def);
-      }
+    }
 
     std::string projectLangs;
-    for(std::set<std::string>::iterator li = testLangs.begin();
-        li != testLangs.end(); ++li)
-      {
+    for (std::set<std::string>::iterator li = testLangs.begin();
+         li != testLangs.end(); ++li) {
       projectLangs += " " + *li;
       std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
       std::string rulesOverrideLang = rulesOverrideBase + "_" + *li;
-      if(const char* rulesOverridePath =
-         this->Makefile->GetDefinition(rulesOverrideLang))
-        {
-        fprintf(fout, "set(%s \"%s\")\n",
-                rulesOverrideLang.c_str(), rulesOverridePath);
-        }
-      else if(const char* rulesOverridePath2 =
-              this->Makefile->GetDefinition(rulesOverrideBase))
-        {
-        fprintf(fout, "set(%s \"%s\")\n",
-                rulesOverrideBase.c_str(), rulesOverridePath2);
-        }
+      if (const char* rulesOverridePath =
+            this->Makefile->GetDefinition(rulesOverrideLang)) {
+        fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(),
+                rulesOverridePath);
+      } else if (const char* rulesOverridePath2 =
+                   this->Makefile->GetDefinition(rulesOverrideBase)) {
+        fprintf(fout, "set(%s \"%s\")\n", rulesOverrideBase.c_str(),
+                rulesOverridePath2);
       }
+    }
     fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str());
     fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n");
-    for(std::set<std::string>::iterator li = testLangs.begin();
-        li != testLangs.end(); ++li)
-      {
+    for (std::set<std::string>::iterator li = testLangs.begin();
+         li != testLangs.end(); ++li) {
       std::string langFlags = "CMAKE_" + *li + "_FLAGS";
       const char* flags = this->Makefile->GetDefinition(langFlags);
       fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
-              cmOutputConverter::EscapeForCMake(flags?flags:"").c_str());
+              cmOutputConverter::EscapeForCMake(flags ? flags : "").c_str());
       fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
-              " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str());
-      }
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0056))
-      {
+                    " ${COMPILE_DEFINITIONS}\")\n",
+              li->c_str(), li->c_str());
+    }
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0056)) {
       case cmPolicies::WARN:
-        if(this->Makefile->PolicyOptionalWarningEnabled(
-             "CMAKE_POLICY_WARNING_CMP0056"))
-          {
+        if (this->Makefile->PolicyOptionalWarningEnabled(
+              "CMAKE_POLICY_WARNING_CMP0056")) {
           std::ostringstream w;
+          /* clang-format off */
           w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0056) << "\n"
             "For compatibility with older versions of CMake, try_compile "
             "is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) "
             "in the test project."
             ;
+          /* clang-format on */
           this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-          }
+        }
       case cmPolicies::OLD:
         // OLD behavior is to do nothing.
         break;
@@ -343,336 +355,282 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
       case cmPolicies::REQUIRED_ALWAYS:
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
-          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0056)
-          );
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0056));
       case cmPolicies::NEW:
         // NEW behavior is to pass linker flags.
         {
-        const char* exeLinkFlags =
-          this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
-        fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
-                cmOutputConverter::EscapeForCMake(
-                    exeLinkFlags ? exeLinkFlags : "").c_str());
-        } break;
-      }
+          const char* exeLinkFlags =
+            this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
+          fprintf(
+            fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
+            cmOutputConverter::EscapeForCMake(exeLinkFlags ? exeLinkFlags : "")
+              .c_str());
+        }
+        break;
+    }
     fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"
-            " ${EXE_LINKER_FLAGS}\")\n");
+                  " ${EXE_LINKER_FLAGS}\")\n");
     fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n");
     fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n");
     fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n");
     // handle any compile flags we need to pass on
-    if (!compileDefs.empty())
-      {
+    if (!compileDefs.empty()) {
       fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
-      }
+    }
 
     /* Use a random file name to avoid rapid creation and deletion
        of the same executable name (some filesystems fail on that).  */
-    sprintf(targetNameBuf, "cmTC_%05x",
-            cmSystemTools::RandomSeed() & 0xFFFFF);
+    sprintf(targetNameBuf, "cmTC_%05x", cmSystemTools::RandomSeed() & 0xFFFFF);
     targetName = targetNameBuf;
 
-    if (!targets.empty())
-      {
+    if (!targets.empty()) {
       std::string fname = "/" + std::string(targetName) + "Targets.cmake";
       cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile);
       tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
-      tcfg.SetConfig(this->Makefile->GetSafeDefinition(
-                                          "CMAKE_TRY_COMPILE_CONFIGURATION"));
+      tcfg.SetConfig(tcConfig);
 
-      if(!tcfg.GenerateImportFile())
-        {
+      if (!tcfg.GenerateImportFile()) {
         this->Makefile->IssueMessage(cmake::FATAL_ERROR,
                                      "could not write export file.");
         fclose(fout);
         return -1;
-        }
-      fprintf(fout,
-              "\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/%s\")\n\n",
-              fname.c_str());
       }
+      fprintf(fout, "\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/%s\")\n\n",
+              fname.c_str());
+    }
 
-    /* for the TRY_COMPILEs we want to be able to specify the architecture.
-      So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set
-      CMAKE_TRY_COMPILE_OSX_ARCHITECTURES first to i386 and then to ppc to
-      have the tests run for each specific architecture. Since
-      cmLocalGenerator doesn't allow building for "the other"
-      architecture only via CMAKE_OSX_ARCHITECTURES.
-      */
-    if(this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_OSX_ARCHITECTURES")!=0)
-      {
-      std::string flag="-DCMAKE_OSX_ARCHITECTURES=";
-      flag += this->Makefile->GetSafeDefinition(
-                                        "CMAKE_TRY_COMPILE_OSX_ARCHITECTURES");
-      cmakeFlags.push_back(flag);
-      }
-    else if (this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES")!=0)
-      {
-      std::string flag="-DCMAKE_OSX_ARCHITECTURES=";
-      flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES");
-      cmakeFlags.push_back(flag);
-      }
-    /* on APPLE also pass CMAKE_OSX_SYSROOT to the try_compile */
-    if(this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT")!=0)
-      {
-      std::string flag="-DCMAKE_OSX_SYSROOT=";
-      flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_SYSROOT");
-      cmakeFlags.push_back(flag);
-      }
-    /* on APPLE also pass CMAKE_OSX_DEPLOYMENT_TARGET to the try_compile */
-    if(this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET")!=0)
-      {
-      std::string flag="-DCMAKE_OSX_DEPLOYMENT_TARGET=";
-      flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
-      cmakeFlags.push_back(flag);
-      }
-    if (const char *cxxDef
-              = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET"))
-      {
-      std::string flag="-DCMAKE_CXX_COMPILER_TARGET=";
-      flag += cxxDef;
-      cmakeFlags.push_back(flag);
-      }
-    if (const char *cDef
-                = this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET"))
-      {
-      std::string flag="-DCMAKE_C_COMPILER_TARGET=";
-      flag += cDef;
-      cmakeFlags.push_back(flag);
-      }
-    if (const char *tcxxDef = this->Makefile->GetDefinition(
-                                  "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN"))
-      {
-      std::string flag="-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=";
-      flag += tcxxDef;
-      cmakeFlags.push_back(flag);
-      }
-    if (const char *tcDef = this->Makefile->GetDefinition(
-                                    "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN"))
-      {
-      std::string flag="-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=";
-      flag += tcDef;
-      cmakeFlags.push_back(flag);
-      }
-    if (const char *rootDef
-              = this->Makefile->GetDefinition("CMAKE_SYSROOT"))
-      {
-      std::string flag="-DCMAKE_SYSROOT=";
-      flag += rootDef;
-      cmakeFlags.push_back(flag);
-      }
-    if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0)
-      {
-      fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n");
-      }
-    if (const char *lssDef = this->Makefile->GetDefinition(
-        "CMAKE_LINK_SEARCH_START_STATIC"))
-      {
-      fprintf(fout, "set(CMAKE_LINK_SEARCH_START_STATIC \"%s\")\n", lssDef);
-      }
-    if (const char *lssDef = this->Makefile->GetDefinition(
-        "CMAKE_LINK_SEARCH_END_STATIC"))
-      {
-      fprintf(fout, "set(CMAKE_LINK_SEARCH_END_STATIC \"%s\")\n", lssDef);
+    // Forward a set of variables to the inner project cache.
+    {
+      std::set<std::string> vars;
+      vars.insert(kCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN);
+      vars.insert(kCMAKE_C_COMPILER_TARGET);
+      vars.insert(kCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN);
+      vars.insert(kCMAKE_CXX_COMPILER_TARGET);
+      vars.insert(kCMAKE_ENABLE_EXPORTS);
+      vars.insert(kCMAKE_LINK_SEARCH_END_STATIC);
+      vars.insert(kCMAKE_LINK_SEARCH_START_STATIC);
+      vars.insert(kCMAKE_OSX_ARCHITECTURES);
+      vars.insert(kCMAKE_OSX_DEPLOYMENT_TARGET);
+      vars.insert(kCMAKE_OSX_SYSROOT);
+      vars.insert(kCMAKE_POSITION_INDEPENDENT_CODE);
+      vars.insert(kCMAKE_SYSROOT);
+
+      if (const char* varListStr = this->Makefile->GetDefinition(
+            kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) {
+        std::vector<std::string> varList;
+        cmSystemTools::ExpandListArgument(varListStr, varList);
+        vars.insert(varList.begin(), varList.end());
+      }
+
+      /* for the TRY_COMPILEs we want to be able to specify the architecture.
+         So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set
+         CMAKE_TRY_COMPILE_OSX_ARCHITECTURES first to i386 and then to ppc to
+         have the tests run for each specific architecture. Since
+         cmLocalGenerator doesn't allow building for "the other"
+         architecture only via CMAKE_OSX_ARCHITECTURES.
+         */
+      if (const char* tcArchs = this->Makefile->GetDefinition(
+            kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES)) {
+        vars.erase(kCMAKE_OSX_ARCHITECTURES);
+        std::string flag = "-DCMAKE_OSX_ARCHITECTURES=" + std::string(tcArchs);
+        cmakeFlags.push_back(flag);
+      }
+
+      for (std::set<std::string>::iterator vi = vars.begin(); vi != vars.end();
+           ++vi) {
+        std::string const& var = *vi;
+        if (const char* val = this->Makefile->GetDefinition(var)) {
+          std::string flag = "-D" + var + "=" + val;
+          cmakeFlags.push_back(flag);
+        }
       }
+    }
 
     /* Set the appropriate policy information for ENABLE_EXPORTS */
     fprintf(fout, "cmake_policy(SET CMP0065 %s)\n",
-       this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) ==
-         cmPolicies::NEW ? "NEW" : "OLD");
-    if(const char *ee = this->Makefile->GetDefinition(
-        "CMAKE_ENABLE_EXPORTS"))
-      {
-      fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee);
-      }
-
-    /* Put the executable at a known location (for COPY_FILE).  */
-    fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
-            this->BinaryDirectory.c_str());
-    /* Create the actual executable.  */
-    fprintf(fout, "add_executable(%s", targetName.c_str());
-    for(std::vector<std::string>::iterator si = sources.begin();
-        si != sources.end(); ++si)
-      {
+            this->Makefile->GetPolicyStatus(cmPolicies::CMP0065) ==
+                cmPolicies::NEW
+              ? "NEW"
+              : "OLD");
+
+    if (targetType == cmState::EXECUTABLE) {
+      /* Put the executable at a known location (for COPY_FILE).  */
+      fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
+              this->BinaryDirectory.c_str());
+      /* Create the actual executable.  */
+      fprintf(fout, "add_executable(%s", targetName.c_str());
+    } else // if (targetType == cmState::STATIC_LIBRARY)
+    {
+      /* Put the static library at a known location (for COPY_FILE).  */
+      fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n",
+              this->BinaryDirectory.c_str());
+      /* Create the actual static library.  */
+      fprintf(fout, "add_library(%s STATIC", targetName.c_str());
+    }
+    for (std::vector<std::string>::iterator si = sources.begin();
+         si != sources.end(); ++si) {
       fprintf(fout, " \"%s\"", si->c_str());
 
       // Add dependencies on any non-temporary sources.
-      if(si->find("CMakeTmp") == si->npos)
-        {
+      if (si->find("CMakeTmp") == si->npos) {
         this->Makefile->AddCMakeDependFile(*si);
-        }
       }
+    }
     fprintf(fout, ")\n");
-    if (useOldLinkLibs)
-      {
-      fprintf(fout,
-              "target_link_libraries(%s ${LINK_LIBRARIES})\n",
+    if (useOldLinkLibs) {
+      fprintf(fout, "target_link_libraries(%s ${LINK_LIBRARIES})\n",
               targetName.c_str());
-      }
-    else
-      {
-      fprintf(fout, "target_link_libraries(%s %s)\n",
-              targetName.c_str(),
+    } else {
+      fprintf(fout, "target_link_libraries(%s %s)\n", targetName.c_str(),
               libsToLink.c_str());
-      }
+    }
     fclose(fout);
     projectName = "CMAKE_TRY_COMPILE";
-    }
+  }
 
   bool erroroc = cmSystemTools::GetErrorOccuredFlag();
   cmSystemTools::ResetErrorOccuredFlag();
   std::string output;
   // actually do the try compile now that everything is setup
-  int res = this->Makefile->TryCompile(sourceDirectory,
-                                       this->BinaryDirectory,
-                                       projectName,
-                                       targetName,
-                                       this->SrcFileSignature,
-                                       &cmakeFlags,
-                                       output);
-  if ( erroroc )
-    {
+  int res = this->Makefile->TryCompile(
+    sourceDirectory, this->BinaryDirectory, projectName, targetName,
+    this->SrcFileSignature, &cmakeFlags, output);
+  if (erroroc) {
     cmSystemTools::SetErrorOccured();
-    }
+  }
 
   // set the result var to the return value to indicate success or failure
-  this->Makefile->AddCacheDefinition(argv[0],
-                                     (res == 0 ? "TRUE" : "FALSE"),
+  this->Makefile->AddCacheDefinition(argv[0], (res == 0 ? "TRUE" : "FALSE"),
                                      "Result of TRY_COMPILE",
                                      cmState::INTERNAL);
 
-  if (!outputVariable.empty())
-    {
+  if (!outputVariable.empty()) {
     this->Makefile->AddDefinition(outputVariable, output.c_str());
-    }
+  }
 
-  if (this->SrcFileSignature)
-    {
+  if (this->SrcFileSignature) {
     std::string copyFileErrorMessage;
-    this->FindOutputFile(targetName);
+    this->FindOutputFile(targetName, targetType);
 
-    if ((res==0) && !copyFile.empty())
-      {
-      if(this->OutputFile.empty() ||
-         !cmSystemTools::CopyFileAlways(this->OutputFile,
-                                        copyFile))
-        {
+    if ((res == 0) && !copyFile.empty()) {
+      if (this->OutputFile.empty() ||
+          !cmSystemTools::CopyFileAlways(this->OutputFile, copyFile)) {
         std::ostringstream emsg;
+        /* clang-format off */
         emsg << "Cannot copy output executable\n"
              << "  '" << this->OutputFile << "'\n"
              << "to destination specified by COPY_FILE:\n"
              << "  '" << copyFile << "'\n";
-        if(!this->FindErrorMessage.empty())
-          {
+        /* clang-format on */
+        if (!this->FindErrorMessage.empty()) {
           emsg << this->FindErrorMessage.c_str();
-          }
-        if(copyFileError.empty())
-          {
+        }
+        if (copyFileError.empty()) {
           this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str());
           return -1;
-          }
-        else
-          {
+        } else {
           copyFileErrorMessage = emsg.str();
-          }
         }
       }
+    }
 
-    if(!copyFileError.empty())
-      {
+    if (!copyFileError.empty()) {
       this->Makefile->AddDefinition(copyFileError,
                                     copyFileErrorMessage.c_str());
-      }
     }
+  }
   return res;
 }
 
 void cmCoreTryCompile::CleanupFiles(const char* binDir)
 {
-  if ( !binDir )
-    {
+  if (!binDir) {
     return;
-    }
+  }
 
   std::string bdir = binDir;
-  if(bdir.find("CMakeTmp") == std::string::npos)
-    {
+  if (bdir.find("CMakeTmp") == std::string::npos) {
     cmSystemTools::Error(
       "TRY_COMPILE attempt to remove -rf directory that does not contain "
-      "CMakeTmp:", binDir);
+      "CMakeTmp:",
+      binDir);
     return;
-    }
+  }
 
   cmsys::Directory dir;
   dir.Load(binDir);
   size_t fileNum;
   std::set<std::string> deletedFiles;
-  for (fileNum = 0; fileNum <  dir.GetNumberOfFiles(); ++fileNum)
-    {
-    if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
-        strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
-      {
+  for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
+    if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
+        strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
 
-      if(deletedFiles.find( dir.GetFile(static_cast<unsigned long>(fileNum)))
-         == deletedFiles.end())
-        {
+      if (deletedFiles.find(dir.GetFile(
+            static_cast<unsigned long>(fileNum))) == deletedFiles.end()) {
         deletedFiles.insert(dir.GetFile(static_cast<unsigned long>(fileNum)));
         std::string fullPath = binDir;
         fullPath += "/";
         fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
-        if(cmSystemTools::FileIsDirectory(fullPath))
-          {
+        if (cmSystemTools::FileIsDirectory(fullPath)) {
           this->CleanupFiles(fullPath.c_str());
           cmSystemTools::RemoveADirectory(fullPath);
-          }
-        else
-          {
+        } else {
 #ifdef _WIN32
           // Sometimes anti-virus software hangs on to new files so we
           // cannot delete them immediately.  Try a few times.
           cmSystemTools::WindowsFileRetry retry =
             cmSystemTools::GetWindowsFileRetry();
-          while(!cmSystemTools::RemoveFile(fullPath.c_str()) &&
-                --retry.Count && cmSystemTools::FileExists(fullPath.c_str()))
-            {
+          while (!cmSystemTools::RemoveFile(fullPath.c_str()) &&
+                 --retry.Count &&
+                 cmSystemTools::FileExists(fullPath.c_str())) {
             cmSystemTools::Delay(retry.Delay);
-            }
-          if(retry.Count == 0)
+          }
+          if (retry.Count == 0)
 #else
-          if(!cmSystemTools::RemoveFile(fullPath))
+          if (!cmSystemTools::RemoveFile(fullPath))
 #endif
-            {
+          {
             std::string m = "Remove failed on file: " + fullPath;
             cmSystemTools::ReportLastSystemError(m.c_str());
-            }
           }
         }
       }
     }
+  }
 }
 
-void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
+void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
+                                      cmState::TargetType targetType)
 {
   this->FindErrorMessage = "";
   this->OutputFile = "";
   std::string tmpOutputFile = "/";
-  tmpOutputFile += targetName;
-  tmpOutputFile +=this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
+  if (targetType == cmState::EXECUTABLE) {
+    tmpOutputFile += targetName;
+    tmpOutputFile +=
+      this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
+  } else // if (targetType == cmState::STATIC_LIBRARY)
+  {
+    tmpOutputFile +=
+      this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX");
+    tmpOutputFile += targetName;
+    tmpOutputFile +=
+      this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
+  }
 
   // a list of directories where to search for the compilation result
   // at first directly in the binary dir
   std::vector<std::string> searchDirs;
   searchDirs.push_back("");
 
-  const char* config = this->Makefile->GetDefinition(
-                                            "CMAKE_TRY_COMPILE_CONFIGURATION");
+  const char* config =
+    this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
   // if a config was specified try that first
-  if (config && config[0])
-    {
+  if (config && config[0]) {
     std::string tmp = "/";
     tmp += config;
     searchDirs.push_back(tmp);
-    }
+  }
   searchDirs.push_back("/Debug");
 #if defined(__APPLE__)
   std::string app = "/Debug/" + targetName + ".app";
@@ -680,25 +638,21 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
 #endif
   searchDirs.push_back("/Development");
 
-  for(std::vector<std::string>::const_iterator it = searchDirs.begin();
-      it != searchDirs.end();
-      ++it)
-    {
+  for (std::vector<std::string>::const_iterator it = searchDirs.begin();
+       it != searchDirs.end(); ++it) {
     std::string command = this->BinaryDirectory;
     command += *it;
     command += tmpOutputFile;
-    if(cmSystemTools::FileExists(command.c_str()))
-      {
+    if (cmSystemTools::FileExists(command.c_str())) {
       this->OutputFile = cmSystemTools::CollapseFullPath(command);
       return;
-      }
     }
+  }
 
   std::ostringstream emsg;
   emsg << "Unable to find the executable at any of:\n";
-  emsg << cmWrap("  " + this->BinaryDirectory,
-                 searchDirs,
-                 tmpOutputFile, "\n") << "\n";
+  emsg << cmWrap("  " + this->BinaryDirectory, searchDirs, tmpOutputFile, "\n")
+       << "\n";
   this->FindErrorMessage = emsg.str();
   return;
 }
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 3272462..6a3b049 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -23,14 +23,13 @@
 class cmCoreTryCompile : public cmCommand
 {
 public:
-
-  protected:
+protected:
   /**
    * This is the core code for try compile. It is here so that other
    * commands, such as TryRun can access the same logic without
    * duplication.
    */
-  int TryCompileCode(std::vector<std::string> const& argv);
+  int TryCompileCode(std::vector<std::string> const& argv, bool isTryRun);
 
   /**
    * This deletes all the files created by TryCompileCode.
@@ -44,8 +43,8 @@ public:
   TryCompileCode. The result is stored in OutputFile. If nothing is found,
   the error message is stored in FindErrorMessage.
    */
-  void FindOutputFile(const std::string& targetName);
-
+  void FindOutputFile(const std::string& targetName,
+                      cmState::TargetType targetType);
 
   cmTypeMacro(cmCoreTryCompile, cmCommand);
 
@@ -53,8 +52,6 @@ public:
   std::string OutputFile;
   std::string FindErrorMessage;
   bool SrcFileSignature;
-
 };
 
-
 #endif
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 54c27d6..d8c629c 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -10,54 +10,45 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCreateTestSourceList.h"
+
 #include "cmSourceFile.h"
 
 // cmCreateTestSourceList
-bool cmCreateTestSourceList
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if (args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("called with wrong number of arguments.");
     return false;
-    }
-
+  }
 
   std::vector<std::string>::const_iterator i = args.begin();
   std::string extraInclude;
   std::string function;
   std::vector<std::string> tests;
   // extract extra include and function ot
-  for(; i != args.end(); i++)
-    {
-    if(*i == "EXTRA_INCLUDE")
-      {
+  for (; i != args.end(); i++) {
+    if (*i == "EXTRA_INCLUDE") {
       ++i;
-      if(i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("incorrect arguments to EXTRA_INCLUDE");
         return false;
-        }
+      }
       extraInclude = "#include \"";
       extraInclude += *i;
       extraInclude += "\"\n";
-      }
-    else if(*i == "FUNCTION")
-      {
+    } else if (*i == "FUNCTION") {
       ++i;
-      if(i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("incorrect arguments to FUNCTION");
         return false;
-        }
+      }
       function = *i;
       function += "(&ac, &av);\n";
-      }
-    else
-      {
+    } else {
       tests.push_back(*i);
-      }
     }
+  }
   i = tests.begin();
 
   // Name of the source list
@@ -67,19 +58,17 @@ bool cmCreateTestSourceList
 
   // Name of the test driver
   // make sure they specified an extension
-  if (cmSystemTools::GetFilenameExtension(*i).size() < 2)
-    {
+  if (cmSystemTools::GetFilenameExtension(*i).size() < 2) {
     this->SetError(
       "You must specify a file extension for the test driver file.");
     return false;
-    }
+  }
   std::string driver = this->Makefile->GetCurrentBinaryDirectory();
   driver += "/";
   driver += *i;
   ++i;
 
-  std::string configFile =
-    this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
+  std::string configFile = cmSystemTools::GetCMakeRoot();
 
   configFile += "/Templates/TestDriver.cxx.in";
   // Create the test driver file
@@ -94,96 +83,81 @@ bool cmCreateTestSourceList
   // For the moment:
   //   - replace spaces ' ', ':' and '/' with underscores '_'
   std::string forwardDeclareCode;
-  for(i = testsBegin; i != tests.end(); ++i)
-    {
-    if(*i == "EXTRA_INCLUDE")
-      {
+  for (i = testsBegin; i != tests.end(); ++i) {
+    if (*i == "EXTRA_INCLUDE") {
       break;
-      }
+    }
     std::string func_name;
-    if (!cmSystemTools::GetFilenamePath(*i).empty())
-      {
+    if (!cmSystemTools::GetFilenamePath(*i).empty()) {
       func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
         cmSystemTools::GetFilenameWithoutLastExtension(*i);
-      }
-    else
-      {
+    } else {
       func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
-      }
+    }
     cmSystemTools::ConvertToUnixSlashes(func_name);
-    cmSystemTools::ReplaceString(func_name, " ", "_");
-    cmSystemTools::ReplaceString(func_name, "/", "_");
-    cmSystemTools::ReplaceString(func_name, ":", "_");
+    std::replace(func_name.begin(), func_name.end(), ' ', '_');
+    std::replace(func_name.begin(), func_name.end(), '/', '_');
+    std::replace(func_name.begin(), func_name.end(), ':', '_');
     tests_func_name.push_back(func_name);
     forwardDeclareCode += "int ";
     forwardDeclareCode += func_name;
     forwardDeclareCode += "(int, char*[]);\n";
-    }
+  }
 
   std::string functionMapCode;
   int numTests = 0;
   std::vector<std::string>::iterator j;
-  for(i = testsBegin, j = tests_func_name.begin(); i != tests.end(); ++i, ++j)
-    {
+  for (i = testsBegin, j = tests_func_name.begin(); i != tests.end();
+       ++i, ++j) {
     std::string func_name;
-    if (!cmSystemTools::GetFilenamePath(*i).empty())
-      {
+    if (!cmSystemTools::GetFilenamePath(*i).empty()) {
       func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
         cmSystemTools::GetFilenameWithoutLastExtension(*i);
-      }
-    else
-      {
+    } else {
       func_name = cmSystemTools::GetFilenameWithoutLastExtension(*i);
-      }
+    }
     functionMapCode += "  {\n"
-      "    \"";
+                       "    \"";
     functionMapCode += func_name;
     functionMapCode += "\",\n"
-      "    ";
-    functionMapCode +=  *j;
+                       "    ";
+    functionMapCode += *j;
     functionMapCode += "\n"
-      "  },\n";
+                       "  },\n";
     numTests++;
-    }
-  if(!extraInclude.empty())
-    {
+  }
+  if (!extraInclude.empty()) {
     this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
                                   extraInclude.c_str());
-    }
-  if(!function.empty())
-    {
+  }
+  if (!function.empty()) {
     this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION",
                                   function.c_str());
-    }
+  }
   this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS",
-    forwardDeclareCode.c_str());
+                                forwardDeclareCode.c_str());
   this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
-    functionMapCode.c_str());
+                                functionMapCode.c_str());
   bool res = true;
-  if ( !this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(),
-      false, true, false) )
-    {
+  if (!this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), false,
+                                     true, false)) {
     res = false;
-    }
+  }
 
   // Construct the source list.
   std::string sourceListValue;
   {
-  cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
-  sf->SetProperty("ABSTRACT","0");
-  sourceListValue = args[1];
+    cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
+    sf->SetProperty("ABSTRACT", "0");
+    sourceListValue = args[1];
   }
-  for(i = testsBegin; i != tests.end(); ++i)
-    {
+  for (i = testsBegin; i != tests.end(); ++i) {
     cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
-    sf->SetProperty("ABSTRACT","0");
+    sf->SetProperty("ABSTRACT", "0");
     sourceListValue += ";";
     sourceListValue += *i;
-    }
+  }
 
   this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
   return res;
 }
-
-
-
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 2f6b541..cfaca2e 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -25,26 +25,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmCreateTestSourceList;
-    }
+  virtual cmCommand* Clone() { return new cmCreateTestSourceList; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "create_test_sourcelist";}
+  virtual std::string GetName() const { return "create_test_sourcelist"; }
 
   cmTypeMacro(cmCreateTestSourceList, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 6616218..85049ca 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -11,30 +11,29 @@
 ============================================================================*/
 #include "cmCryptoHash.h"
 
-#include <cmsys/MD5.h>
-#include <cmsys/FStream.hxx>
 #include "cm_sha2.h"
+#include <cmsys/FStream.hxx>
+#include <cmsys/MD5.h>
 
-//----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo)
 {
-  if(strcmp(algo,"MD5") == 0)
-    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5); }
-  else if(strcmp(algo,"SHA1") == 0)
-    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1); }
-  else if(strcmp(algo,"SHA224") == 0)
-    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224); }
-  else if(strcmp(algo,"SHA256") == 0)
-    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256); }
-  else if(strcmp(algo,"SHA384") == 0)
-    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384); }
-  else if(strcmp(algo,"SHA512") == 0)
-    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512); }
-  else
-    { return cmsys::auto_ptr<cmCryptoHash>(0); }
+  if (strcmp(algo, "MD5") == 0) {
+    return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5);
+  } else if (strcmp(algo, "SHA1") == 0) {
+    return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1);
+  } else if (strcmp(algo, "SHA224") == 0) {
+    return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224);
+  } else if (strcmp(algo, "SHA256") == 0) {
+    return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256);
+  } else if (strcmp(algo, "SHA384") == 0) {
+    return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384);
+  } else if (strcmp(algo, "SHA512") == 0) {
+    return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512);
+  } else {
+    return cmsys::auto_ptr<cmCryptoHash>(0);
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmCryptoHash::HashString(const std::string& input)
 {
   this->Initialize();
@@ -43,14 +42,12 @@ std::string cmCryptoHash::HashString(const std::string& input)
   return this->Finalize();
 }
 
-//----------------------------------------------------------------------------
 std::string cmCryptoHash::HashFile(const std::string& file)
 {
   cmsys::ifstream fin(file.c_str(), std::ios::in | std::ios::binary);
-  if(!fin)
-    {
+  if (!fin) {
     return "";
-    }
+  }
 
   this->Initialize();
 
@@ -64,45 +61,38 @@ std::string cmCryptoHash::HashFile(const std::string& file)
   // incorrect to not check the error condition on the fin.read()
   // before using the data, but the fin.gcount() will be zero if an
   // error occurred.  Therefore, the loop should be safe everywhere.
-  while(fin)
-    {
+  while (fin) {
     fin.read(buffer_c, sizeof(buffer));
-    if(int gcount = static_cast<int>(fin.gcount()))
-      {
+    if (int gcount = static_cast<int>(fin.gcount())) {
       this->Append(buffer_uc, gcount);
-      }
     }
-  if(fin.eof())
-    {
+  }
+  if (fin.eof()) {
     return this->Finalize();
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
-cmCryptoHashMD5::cmCryptoHashMD5(): MD5(cmsysMD5_New())
+cmCryptoHashMD5::cmCryptoHashMD5()
+  : MD5(cmsysMD5_New())
 {
 }
 
-//----------------------------------------------------------------------------
 cmCryptoHashMD5::~cmCryptoHashMD5()
 {
   cmsysMD5_Delete(this->MD5);
 }
 
-//----------------------------------------------------------------------------
 void cmCryptoHashMD5::Initialize()
 {
   cmsysMD5_Initialize(this->MD5);
 }
 
-//----------------------------------------------------------------------------
 void cmCryptoHashMD5::Append(unsigned char const* buf, int sz)
 {
   cmsysMD5_Append(this->MD5, buf, sz);
 }
 
-//----------------------------------------------------------------------------
 std::string cmCryptoHashMD5::Finalize()
 {
   char md5out[32];
@@ -110,22 +100,24 @@ std::string cmCryptoHashMD5::Finalize()
   return std::string(md5out, 32);
 }
 
-
-#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \
-cmCryptoHash##SHA::cmCryptoHash##SHA(): SHA(new SHA_CTX) {} \
-cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \
-void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \
-void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \
-{ SHA##_Update(this->SHA, buf, sz); } \
-std::string cmCryptoHash##SHA::Finalize() \
-{ \
-  char out[SHA##_DIGEST_STRING_LENGTH]; \
-  SHA##_End(this->SHA, out); \
-  return std::string(out, SHA##_DIGEST_STRING_LENGTH-1); \
-}
-
-cmCryptoHash_SHA_CLASS_IMPL(SHA1)
-cmCryptoHash_SHA_CLASS_IMPL(SHA224)
-cmCryptoHash_SHA_CLASS_IMPL(SHA256)
-cmCryptoHash_SHA_CLASS_IMPL(SHA384)
-cmCryptoHash_SHA_CLASS_IMPL(SHA512)
+#define cmCryptoHash_SHA_CLASS_IMPL(SHA)                                      \
+  cmCryptoHash##SHA::cmCryptoHash##SHA()                                      \
+    : SHA(new SHA_CTX)                                                        \
+  {                                                                           \
+  }                                                                           \
+  cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; }               \
+  void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); }             \
+  void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz)            \
+  {                                                                           \
+    SHA##_Update(this->SHA, buf, sz);                                         \
+  }                                                                           \
+  std::string cmCryptoHash##SHA::Finalize()                                   \
+  {                                                                           \
+    char out[SHA##_DIGEST_STRING_LENGTH];                                     \
+    SHA##_End(this->SHA, out);                                                \
+    return std::string(out, SHA##_DIGEST_STRING_LENGTH - 1);                  \
+  }
+
+cmCryptoHash_SHA_CLASS_IMPL(SHA1) cmCryptoHash_SHA_CLASS_IMPL(SHA224)
+  cmCryptoHash_SHA_CLASS_IMPL(SHA256) cmCryptoHash_SHA_CLASS_IMPL(SHA384)
+    cmCryptoHash_SHA_CLASS_IMPL(SHA512)
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 88cd240..a0c5eab 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -23,35 +23,40 @@ public:
   static cmsys::auto_ptr<cmCryptoHash> New(const char* algo);
   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;
-  virtual std::string Finalize()=0;
+  virtual void Initialize() = 0;
+  virtual void Append(unsigned char const*, int) = 0;
+  virtual std::string Finalize() = 0;
 };
 
-class cmCryptoHashMD5: public cmCryptoHash
+class cmCryptoHashMD5 : public cmCryptoHash
 {
   struct cmsysMD5_s* MD5;
+
 public:
   cmCryptoHashMD5();
   ~cmCryptoHashMD5();
+
 protected:
   virtual void Initialize();
   virtual void Append(unsigned char const* buf, int sz);
   virtual std::string Finalize();
 };
 
-#define cmCryptoHash_SHA_CLASS_DECL(SHA) \
-  class cmCryptoHash##SHA: public cmCryptoHash \
-  { \
-    union _SHA_CTX* SHA; \
-  public: \
-    cmCryptoHash##SHA(); \
-    ~cmCryptoHash##SHA(); \
-  protected: \
-    virtual void Initialize(); \
-    virtual void Append(unsigned char const* buf, int sz); \
-    virtual std::string Finalize(); \
+#define cmCryptoHash_SHA_CLASS_DECL(SHA)                                      \
+  class cmCryptoHash##SHA : public cmCryptoHash                               \
+  {                                                                           \
+    union _SHA_CTX* SHA;                                                      \
+                                                                              \
+  public:                                                                     \
+    cmCryptoHash##SHA();                                                      \
+    ~cmCryptoHash##SHA();                                                     \
+                                                                              \
+  protected:                                                                  \
+    virtual void Initialize();                                                \
+    virtual void Append(unsigned char const* buf, int sz);                    \
+    virtual std::string Finalize();                                           \
   }
 
 cmCryptoHash_SHA_CLASS_DECL(SHA1);
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index 4f3d890..5bc4f91 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -10,60 +10,53 @@
   See the License for more information.
 ============================================================================*/
 #include "cmCurl.h"
+
 #include "cmSystemTools.h"
 
 // curl versions before 7.21.5 did not provide this error code
 #if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x071505
-# define CURLE_NOT_BUILT_IN 4
+#define CURLE_NOT_BUILT_IN 4
 #endif
 
-#define check_curl_result(result, errstr)                               \
-  if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN)               \
-    {                                                                   \
-    e += e.empty()? "" : "\n";                                          \
-    e += errstr;                                                        \
-    e += ::curl_easy_strerror(result);                                  \
-    }
+#define check_curl_result(result, errstr)                                     \
+  if (result != CURLE_OK && result != CURLE_NOT_BUILT_IN) {                   \
+    e += e.empty() ? "" : "\n";                                               \
+    e += errstr;                                                              \
+    e += ::curl_easy_strerror(result);                                        \
+  }
 
-//----------------------------------------------------------------------------
-std::string cmCurlSetCAInfo(::CURL *curl, const char* cafile)
+std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
 {
   std::string e;
-  if(cafile && *cafile)
-    {
+  if (cafile && *cafile) {
     ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
     check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
-    }
-#if !defined(CMAKE_USE_SYSTEM_CURL) && \
-    !defined(_WIN32) && !defined(__APPLE__) && \
-    !defined(CURL_CA_BUNDLE) && !defined(CURL_CA_PATH)
-# define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
-  else if(cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true))
-    {
+  }
+#if !defined(CMAKE_USE_SYSTEM_CURL) && !defined(_WIN32) &&                    \
+  !defined(__APPLE__) && !defined(CURL_CA_BUNDLE) && !defined(CURL_CA_PATH)
+#define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
+  else if (cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true)) {
     ::CURLcode res =
       ::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_FEDORA);
     check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
-    }
-# undef CMAKE_CAFILE_FEDORA
-  else
-    {
-#   define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
-    if(cmSystemTools::FileExists(CMAKE_CAFILE_COMMON, true))
-      {
+  }
+#undef CMAKE_CAFILE_FEDORA
+  else {
+#define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
+    if (cmSystemTools::FileExists(CMAKE_CAFILE_COMMON, true)) {
       ::CURLcode res =
         ::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_COMMON);
       check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
-      }
-#   undef CMAKE_CAFILE_COMMON
-#   define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
-    if(cmSystemTools::FileIsDirectory(CMAKE_CAPATH_COMMON))
-      {
+    }
+#undef CMAKE_CAFILE_COMMON
+#define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
+    if (cmSystemTools::FileIsDirectory(CMAKE_CAPATH_COMMON)) {
       ::CURLcode res =
         ::curl_easy_setopt(curl, CURLOPT_CAPATH, CMAKE_CAPATH_COMMON);
       check_curl_result(res, "Unable to set TLS/SSL Verify CAPATH: ");
-      }
-#   undef CMAKE_CAPATH_COMMON
     }
+#undef CMAKE_CAPATH_COMMON
+  }
 #endif
   return e;
 }
diff --git a/Source/cmCurl.h b/Source/cmCurl.h
index 0c5609c..eac7f13 100644
--- a/Source/cmCurl.h
+++ b/Source/cmCurl.h
@@ -12,10 +12,10 @@
 #ifndef cmCurl_h
 #define cmCurl_h
 
-#include <cmsys/Configure.h>
-#include "cm_curl.h"
 #include "cmStandardIncludes.h"
 
-std::string cmCurlSetCAInfo(::CURL *curl, const char* cafile = 0);
+#include "cm_curl.h"
+
+std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = 0);
 
 #endif
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index 7c37e3b..7c00c80 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -15,7 +15,6 @@
 
 #include <cmsys/auto_ptr.hxx>
 
-//----------------------------------------------------------------------------
 cmCustomCommand::cmCustomCommand()
   : Backtrace()
 {
@@ -25,132 +24,113 @@ cmCustomCommand::cmCustomCommand()
   this->UsesTerminal = false;
 }
 
-//----------------------------------------------------------------------------
 cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
                                  const std::vector<std::string>& outputs,
                                  const std::vector<std::string>& byproducts,
                                  const std::vector<std::string>& depends,
                                  const cmCustomCommandLines& commandLines,
                                  const char* comment,
-                                 const char* workingDirectory):
-  Outputs(outputs),
-  Byproducts(byproducts),
-  Depends(depends),
-  CommandLines(commandLines),
-  Backtrace(),
-  Comment(comment?comment:""),
-  WorkingDirectory(workingDirectory?workingDirectory:""),
-  HaveComment(comment?true:false),
-  EscapeAllowMakeVars(false),
-  EscapeOldStyle(true)
-{
-  if(mf)
-    {
+                                 const char* workingDirectory)
+  : Outputs(outputs)
+  , Byproducts(byproducts)
+  , Depends(depends)
+  , CommandLines(commandLines)
+  , Backtrace()
+  , Comment(comment ? comment : "")
+  , WorkingDirectory(workingDirectory ? workingDirectory : "")
+  , HaveComment(comment ? true : false)
+  , EscapeAllowMakeVars(false)
+  , EscapeOldStyle(true)
+{
+  if (mf) {
     this->Backtrace = mf->GetBacktrace();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 const std::vector<std::string>& cmCustomCommand::GetOutputs() const
 {
   return this->Outputs;
 }
 
-//----------------------------------------------------------------------------
 const std::vector<std::string>& cmCustomCommand::GetByproducts() const
 {
   return this->Byproducts;
 }
 
-//----------------------------------------------------------------------------
 const std::vector<std::string>& cmCustomCommand::GetDepends() const
 {
   return this->Depends;
 }
 
-//----------------------------------------------------------------------------
 const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
 {
   return this->CommandLines;
 }
 
-//----------------------------------------------------------------------------
 const char* cmCustomCommand::GetComment() const
 {
   const char* no_comment = 0;
-  return this->HaveComment? this->Comment.c_str() : no_comment;
+  return this->HaveComment ? this->Comment.c_str() : no_comment;
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
 {
-  this->CommandLines.insert(this->CommandLines.end(),
-                            commandLines.begin(), commandLines.end());
+  this->CommandLines.insert(this->CommandLines.end(), commandLines.begin(),
+                            commandLines.end());
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
 {
   this->Depends.insert(this->Depends.end(), depends.begin(), depends.end());
 }
 
-//----------------------------------------------------------------------------
 bool cmCustomCommand::GetEscapeOldStyle() const
 {
   return this->EscapeOldStyle;
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::SetEscapeOldStyle(bool b)
 {
   this->EscapeOldStyle = b;
 }
 
-//----------------------------------------------------------------------------
 bool cmCustomCommand::GetEscapeAllowMakeVars() const
 {
   return this->EscapeAllowMakeVars;
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::SetEscapeAllowMakeVars(bool b)
 {
   this->EscapeAllowMakeVars = b;
 }
 
-//----------------------------------------------------------------------------
 cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
 {
   return this->Backtrace;
 }
 
-//----------------------------------------------------------------------------
 cmCustomCommand::ImplicitDependsList const&
 cmCustomCommand::GetImplicitDepends() const
 {
   return this->ImplicitDepends;
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
 {
   this->ImplicitDepends = l;
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
 {
-  this->ImplicitDepends.insert(this->ImplicitDepends.end(),
-                               l.begin(), l.end());
+  this->ImplicitDepends.insert(this->ImplicitDepends.end(), l.begin(),
+                               l.end());
 }
 
-//----------------------------------------------------------------------------
 bool cmCustomCommand::GetUsesTerminal() const
 {
   return this->UsesTerminal;
 }
 
-//----------------------------------------------------------------------------
 void cmCustomCommand::SetUsesTerminal(bool b)
 {
   this->UsesTerminal = b;
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index f9b38c3..c2b9738 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -13,6 +13,7 @@
 #define cmCustomCommand_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmListFileCache.h"
 class cmMakefile;
 
@@ -33,8 +34,7 @@ public:
                   const std::vector<std::string>& byproducts,
                   const std::vector<std::string>& depends,
                   const cmCustomCommandLines& commandLines,
-                  const char* comment,
-                  const char* workingDirectory);
+                  const char* comment, const char* workingDirectory);
 
   /** Get the output file produced by the command.  */
   const std::vector<std::string>& GetOutputs() const;
@@ -47,7 +47,9 @@ public:
 
   /** Get the working directory.  */
   std::string const& GetWorkingDirectory() const
-    { return this->WorkingDirectory; }
+  {
+    return this->WorkingDirectory;
+  }
 
   /** Get the list of command lines.  */
   const cmCustomCommandLines& GetCommandLines() const;
@@ -74,7 +76,9 @@ public:
   cmListFileBacktrace const& GetBacktrace() const;
 
   typedef std::pair<std::string, std::string> ImplicitDependsPair;
-  class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
+  class ImplicitDependsList : public std::vector<ImplicitDependsPair>
+  {
+  };
   void SetImplicitDepends(ImplicitDependsList const&);
   void AppendImplicitDepends(ImplicitDependsList const&);
   ImplicitDependsList const& GetImplicitDepends() const;
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index dc06678..99bb601 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -11,49 +11,67 @@
 ============================================================================*/
 #include "cmCustomCommandGenerator.h"
 
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
 #include "cmCustomCommand.h"
-#include "cmOutputConverter.h"
 #include "cmGeneratorExpression.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmOutputConverter.h"
 
-//----------------------------------------------------------------------------
-cmCustomCommandGenerator::cmCustomCommandGenerator(
-  cmCustomCommand const& cc, const std::string& config, cmLocalGenerator* lg):
-  CC(cc), Config(config), LG(lg),
-  OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
-  GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false)
+cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
+                                                   const std::string& config,
+                                                   cmLocalGenerator* lg)
+  : CC(cc)
+  , Config(config)
+  , LG(lg)
+  , OldStyle(cc.GetEscapeOldStyle())
+  , MakeVars(cc.GetEscapeAllowMakeVars())
+  , GE(new cmGeneratorExpression(cc.GetBacktrace()))
+  , DependsDone(false)
 {
 }
 
-//----------------------------------------------------------------------------
 cmCustomCommandGenerator::~cmCustomCommandGenerator()
 {
   delete this->GE;
 }
 
-//----------------------------------------------------------------------------
 unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
 {
   return static_cast<unsigned int>(this->CC.GetCommandLines().size());
 }
 
-//----------------------------------------------------------------------------
+bool cmCustomCommandGenerator::UseCrossCompilingEmulator(unsigned int c) const
+{
+  std::string const& argv0 = this->CC.GetCommandLines()[c][0];
+  cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
+  if (target && target->GetType() == cmState::EXECUTABLE) {
+    return target->GetProperty("CROSSCOMPILING_EMULATOR") != 0;
+  }
+  return false;
+}
+
 std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
 {
   std::string const& argv0 = this->CC.GetCommandLines()[c][0];
-  cmGeneratorTarget* target =
-      this->LG->FindGeneratorTargetToUse(argv0);
-  if(target && target->GetType() == cmState::EXECUTABLE &&
-     (target->IsImported()
-      || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")))
-    {
+  cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
+  if (target && target->GetType() == cmState::EXECUTABLE &&
+      (target->IsImported() ||
+       !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) {
     return target->GetLocation(this->Config);
+  }
+  if (target && target->GetType() == cmState::EXECUTABLE) {
+    const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
+    if (emulator) {
+      return std::string(emulator);
     }
-  return this->GE->Parse(argv0)->Evaluate(this->LG, this->Config);
+  }
+
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(argv0);
+  std::string exe = cge->Evaluate(this->LG, this->Config);
+
+  return exe;
 }
 
-//----------------------------------------------------------------------------
 std::string escapeForShellOldStyle(const std::string& str)
 {
   std::string result;
@@ -61,101 +79,84 @@ std::string escapeForShellOldStyle(const std::string& str)
   // if there are spaces
   std::string temp = str;
   if (temp.find(" ") != std::string::npos &&
-      temp.find("\"")==std::string::npos)
-    {
+      temp.find("\"") == std::string::npos) {
     result = "\"";
     result += str;
     result += "\"";
     return result;
-    }
+  }
   return str;
 #else
-  for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
-    {
-    if(*ch == ' ')
-      {
+  for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
+    if (*ch == ' ') {
       result += '\\';
-      }
-    result += *ch;
     }
+    result += *ch;
+  }
   return result;
 #endif
 }
 
-//----------------------------------------------------------------------------
-void
-cmCustomCommandGenerator
-::AppendArguments(unsigned int c, std::string& cmd) const
+void cmCustomCommandGenerator::AppendArguments(unsigned int c,
+                                               std::string& cmd) const
 {
+  unsigned int offset = 1;
+  if (this->UseCrossCompilingEmulator(c)) {
+    offset = 0;
+  }
   cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c];
-  for(unsigned int j=1;j < commandLine.size(); ++j)
-    {
+  for (unsigned int j = offset; j < commandLine.size(); ++j) {
     std::string arg =
-        this->GE->Parse(commandLine[j])->Evaluate(this->LG,
-                                                  this->Config);
+      this->GE->Parse(commandLine[j])->Evaluate(this->LG, this->Config);
     cmd += " ";
-    if(this->OldStyle)
-      {
+    if (this->OldStyle) {
       cmd += escapeForShellOldStyle(arg);
-      }
-    else
-      {
+    } else {
       cmOutputConverter converter(this->LG->GetStateSnapshot());
       cmd += converter.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::GetByproducts() const
 {
   return this->CC.GetByproducts();
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
 {
-  if (!this->DependsDone)
-    {
+  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);
+    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->LG, this->Config), result);
+      cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
+                                        result);
       for (std::vector<std::string>::iterator it = result.begin();
-          it != result.end(); ++it)
-        {
-        if (cmSystemTools::FileIsFullPath(it->c_str()))
-          {
+           it != result.end(); ++it) {
+        if (cmSystemTools::FileIsFullPath(it->c_str())) {
           *it = cmSystemTools::CollapseFullPath(*it);
-          }
         }
-      this->Depends.insert(this->Depends.end(), result.begin(), result.end());
       }
+      this->Depends.insert(this->Depends.end(), result.begin(), result.end());
     }
+  }
   return this->Depends;
 }
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index a637fed..a361153 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -28,14 +28,15 @@ class cmCustomCommandGenerator
   cmGeneratorExpression* GE;
   mutable bool DependsDone;
   mutable std::vector<std::string> Depends;
+
 public:
   cmCustomCommandGenerator(cmCustomCommand const& cc,
-                           const std::string& config,
-                           cmLocalGenerator* lg);
+                           const std::string& config, cmLocalGenerator* lg);
   ~cmCustomCommandGenerator();
   cmCustomCommand const& GetCC() const { return this->CC; }
   unsigned int GetNumberOfCommands() const;
   std::string GetCommand(unsigned int c) const;
+  bool UseCrossCompilingEmulator(unsigned int c) const;
   void AppendArguments(unsigned int c, std::string& cmd) const;
   const char* GetComment() const;
   std::string GetWorkingDirectory() const;
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 0efc7fc..484a970 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -10,50 +10,35 @@
   See the License for more information.
 ============================================================================*/
 #include "cmDefinePropertyCommand.h"
-#include "cmake.h"
+
 #include "cmState.h"
+#include "cmake.h"
 
-bool cmDefinePropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Get the scope in which to define the property.
   cmProperty::ScopeType scope;
-  if(args[0] == "GLOBAL")
-    {
+  if (args[0] == "GLOBAL") {
     scope = cmProperty::GLOBAL;
-    }
-  else if(args[0] == "DIRECTORY")
-    {
+  } else if (args[0] == "DIRECTORY") {
     scope = cmProperty::DIRECTORY;
-    }
-  else if(args[0] == "TARGET")
-    {
+  } else if (args[0] == "TARGET") {
     scope = cmProperty::TARGET;
-    }
-  else if(args[0] == "SOURCE")
-    {
+  } else if (args[0] == "SOURCE") {
     scope = cmProperty::SOURCE_FILE;
-    }
-  else if(args[0] == "TEST")
-    {
+  } else if (args[0] == "TEST") {
     scope = cmProperty::TEST;
-    }
-  else if(args[0] == "VARIABLE")
-    {
+  } else if (args[0] == "VARIABLE") {
     scope = cmProperty::VARIABLE;
-    }
-  else if (args[0] == "CACHED_VARIABLE")
-    {
+  } else if (args[0] == "CACHED_VARIABLE") {
     scope = cmProperty::CACHED_VARIABLE;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << "given invalid scope " << args[0] << ".  "
       << "Valid scopes are "
@@ -61,77 +46,63 @@ bool cmDefinePropertyCommand
       << "TEST, VARIABLE, CACHED_VARIABLE.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Parse remaining arguments.
   bool inherited = false;
-  enum Doing { DoingNone, DoingProperty, DoingBrief, DoingFull };
+  enum Doing
+  {
+    DoingNone,
+    DoingProperty,
+    DoingBrief,
+    DoingFull
+  };
   Doing doing = DoingNone;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "PROPERTY")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "PROPERTY") {
       doing = DoingProperty;
-      }
-    else if(args[i] == "BRIEF_DOCS")
-      {
+    } else if (args[i] == "BRIEF_DOCS") {
       doing = DoingBrief;
-      }
-    else if(args[i] == "FULL_DOCS")
-      {
+    } else if (args[i] == "FULL_DOCS") {
       doing = DoingFull;
-      }
-    else if(args[i] == "INHERITED")
-      {
+    } else if (args[i] == "INHERITED") {
       doing = DoingNone;
       inherited = true;
-      }
-    else if(doing == DoingProperty)
-      {
+    } else if (doing == DoingProperty) {
       doing = DoingNone;
       this->PropertyName = args[i];
-      }
-    else if(doing == DoingBrief)
-      {
+    } else if (doing == DoingBrief) {
       this->BriefDocs += args[i];
-      }
-    else if(doing == DoingFull)
-      {
+    } else if (doing == DoingFull) {
       this->FullDocs += args[i];
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "given invalid argument \"" << args[i] << "\".";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Make sure a property name was found.
-  if(this->PropertyName.empty())
-    {
+  if (this->PropertyName.empty()) {
     this->SetError("not given a PROPERTY <name> argument.");
     return false;
-    }
+  }
 
   // Make sure documentation was given.
-  if(this->BriefDocs.empty())
-    {
+  if (this->BriefDocs.empty()) {
     this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
     return false;
-    }
-  if(this->FullDocs.empty())
-    {
+  }
+  if (this->FullDocs.empty()) {
     this->SetError("not given a FULL_DOCS <full-doc> argument.");
     return false;
-    }
+  }
 
   // Actually define the property.
-  this->Makefile->GetState()->DefineProperty
-    (this->PropertyName, scope,
-     this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);
+  this->Makefile->GetState()->DefineProperty(
+    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 bc5c8a4..4248bbe 100644
--- a/Source/cmDefinePropertyCommand.h
+++ b/Source/cmDefinePropertyCommand.h
@@ -17,30 +17,26 @@
 class cmDefinePropertyCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmDefinePropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmDefinePropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "define_property";}
+  virtual std::string GetName() const { return "define_property"; }
 
   cmTypeMacro(cmDefinePropertyCommand, cmCommand);
+
 private:
   std::string PropertyName;
   std::string BriefDocs;
   std::string FullDocs;
 };
 
-
-
 #endif
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index b06fb5c..28b6677 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -13,136 +13,113 @@
 
 #include <assert.h>
 
-//----------------------------------------------------------------------------
 cmDefinitions::Def cmDefinitions::NoDef;
 
-//----------------------------------------------------------------------------
-cmDefinitions::Def const& cmDefinitions::GetInternal(
-  const std::string& key, StackIter begin, StackIter end, bool raise)
+cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key,
+                                                     StackIter begin,
+                                                     StackIter end, bool raise)
 {
   assert(begin != end);
   MapType::iterator i = begin->Map.find(key);
-  if (i != begin->Map.end())
-    {
+  if (i != begin->Map.end()) {
     i->second.Used = true;
     return i->second;
-    }
+  }
   StackIter it = begin;
   ++it;
-  if (it == end)
-    {
+  if (it == end) {
     return cmDefinitions::NoDef;
-    }
+  }
   Def const& def = cmDefinitions::GetInternal(key, it, end, raise);
-  if (!raise)
-    {
+  if (!raise) {
     return def;
-    }
+  }
   return begin->Map.insert(MapType::value_type(key, def)).first->second;
 }
 
-//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const std::string& key,
-    StackIter begin, StackIter end)
+const char* cmDefinitions::Get(const std::string& key, StackIter begin,
+                               StackIter end)
 {
   Def const& def = cmDefinitions::GetInternal(key, begin, end, false);
-  return def.Exists? def.c_str() : 0;
+  return def.Exists ? def.c_str() : 0;
 }
 
-void cmDefinitions::Raise(const std::string& key,
-                          StackIter begin, StackIter end)
+void cmDefinitions::Raise(const std::string& key, StackIter begin,
+                          StackIter end)
 {
   cmDefinitions::GetInternal(key, begin, end, true);
 }
 
-bool cmDefinitions::HasKey(const std::string& key,
-                           StackIter begin, StackIter end)
+bool cmDefinitions::HasKey(const std::string& key, StackIter begin,
+                           StackIter end)
 {
-  for (StackIter it = begin; it != end; ++it)
-    {
+  for (StackIter it = begin; it != end; ++it) {
     MapType::const_iterator i = it->Map.find(key);
-    if (i != it->Map.end())
-      {
+    if (i != it->Map.end()) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmDefinitions::Set(const std::string& key, const char* value)
 {
   Def def(value);
   this->Map[key] = def;
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> cmDefinitions::UnusedKeys() const
 {
   std::vector<std::string> keys;
   keys.reserve(this->Map.size());
   // Consider local definitions.
-  for(MapType::const_iterator mi = this->Map.begin();
-      mi != this->Map.end(); ++mi)
-    {
-    if (!mi->second.Used)
-      {
+  for (MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end();
+       ++mi) {
+    if (!mi->second.Used) {
       keys.push_back(mi->first);
-      }
     }
+  }
   return keys;
 }
 
-//----------------------------------------------------------------------------
-cmDefinitions cmDefinitions::MakeClosure(StackIter begin,
-                                         StackIter end)
+cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
 {
   cmDefinitions closure;
   std::set<std::string> undefined;
-  for (StackIter it = begin; it != end; ++it)
-    {
+  for (StackIter it = begin; it != end; ++it) {
     // Consider local definitions.
-    for(MapType::const_iterator mi = it->Map.begin();
-        mi != it->Map.end(); ++mi)
-      {
+    for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
+         ++mi) {
       // Use this key if it is not already set or unset.
-      if(closure.Map.find(mi->first) == closure.Map.end() &&
-         undefined.find(mi->first) == undefined.end())
-        {
-        if(mi->second.Exists)
-          {
+      if (closure.Map.find(mi->first) == closure.Map.end() &&
+          undefined.find(mi->first) == undefined.end()) {
+        if (mi->second.Exists) {
           closure.Map.insert(*mi);
-          }
-        else
-          {
+        } else {
           undefined.insert(mi->first);
-          }
         }
       }
     }
+  }
   return closure;
 }
 
-//----------------------------------------------------------------------------
-std::vector<std::string>
-cmDefinitions::ClosureKeys(StackIter begin, StackIter end)
+std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
+                                                    StackIter end)
 {
   std::set<std::string> bound;
   std::vector<std::string> defined;
 
-  for (StackIter it = begin; it != end; ++it)
-    {
+  for (StackIter it = begin; it != end; ++it) {
     defined.reserve(defined.size() + it->Map.size());
-    for(MapType::const_iterator mi = it->Map.begin();
-        mi != it->Map.end(); ++mi)
-      {
+    for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
+         ++mi) {
       // Use this key if it is not already set or unset.
-      if(bound.insert(mi->first).second && mi->second.Exists)
-        {
+      if (bound.insert(mi->first).second && mi->second.Exists) {
         defined.push_back(mi->first);
-        }
       }
     }
+  }
 
   return defined;
 }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 411867c..7be0098 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -36,41 +36,56 @@
 class cmDefinitions
 {
   typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
+
 public:
-  static const char* Get(const std::string& key,
-                         StackIter begin, StackIter end);
+  static const char* Get(const std::string& key, StackIter begin,
+                         StackIter end);
 
-  static void Raise(const std::string& key,
-                    StackIter begin, StackIter end);
+  static void Raise(const std::string& key, StackIter begin, StackIter end);
 
-  static bool HasKey(const std::string& key,
-                     StackIter begin, StackIter end);
+  static bool HasKey(const std::string& key, StackIter begin, StackIter end);
 
   /** Set (or unset if null) a value associated with a key.  */
   void Set(const std::string& key, const char* value);
 
   std::vector<std::string> UnusedKeys() const;
 
-  static std::vector<std::string> ClosureKeys(StackIter begin,
-                                              StackIter end);
+  static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
 
   static cmDefinitions MakeClosure(StackIter begin, StackIter end);
 
 private:
   // String with existence boolean.
-  struct Def: public std::string
+  struct Def : public std::string
   {
   private:
     typedef std::string std_string;
+
   public:
-    Def(): std_string(), Exists(false), Used(false) {}
+    Def()
+      : std_string()
+      , Exists(false)
+      , Used(false)
+    {
+    }
     Def(const char* v)
-      : std_string(v ? v : ""),
-        Exists(v ? true : false),
-        Used(false)
-    {}
-    Def(const std_string& v): std_string(v), Exists(true), Used(false) {}
-    Def(Def const& d): std_string(d), Exists(d.Exists), Used(d.Used) {}
+      : std_string(v ? v : "")
+      , Exists(v ? true : false)
+      , Used(false)
+    {
+    }
+    Def(const std_string& v)
+      : std_string(v)
+      , Exists(true)
+      , Used(false)
+    {
+    }
+    Def(Def const& d)
+      : std_string(d)
+      , Exists(d.Exists)
+      , Used(d.Used)
+    {
+    }
     bool Exists;
     bool Used;
   };
@@ -87,8 +102,8 @@ private:
 #endif
   MapType Map;
 
-  static Def const& GetInternal(const std::string& key,
-    StackIter begin, StackIter end, bool raise);
+  static Def const& GetInternal(const std::string& key, StackIter begin,
+                                StackIter end, bool raise);
 };
 
 #endif
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index d419011..5df3cc1 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -11,37 +11,33 @@
 ============================================================================*/
 #include "cmDepends.h"
 
+#include "cmFileTimeComparison.h"
+#include "cmGeneratedFileStream.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
-#include "cmFileTimeComparison.h"
-#include <string.h>
 #include <cmsys/FStream.hxx>
+#include <string.h>
 
-//----------------------------------------------------------------------------
-cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir):
-  CompileDirectory(),
-  LocalGenerator(lg),
-  Verbose(false),
-  FileComparison(0),
-  TargetDirectory(targetDir),
-  MaxPath(16384),
-  Dependee(new char[MaxPath]),
-  Depender(new char[MaxPath])
+cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir)
+  : CompileDirectory()
+  , LocalGenerator(lg)
+  , Verbose(false)
+  , FileComparison(0)
+  , TargetDirectory(targetDir)
+  , MaxPath(16384)
+  , Dependee(new char[MaxPath])
+  , Depender(new char[MaxPath])
 {
 }
 
-//----------------------------------------------------------------------------
 cmDepends::~cmDepends()
 {
-  delete [] this->Dependee;
-  delete [] this->Depender;
+  delete[] this->Dependee;
+  delete[] this->Depender;
 }
 
-//----------------------------------------------------------------------------
-bool cmDepends::Write(std::ostream &makeDepends,
-                      std::ostream &internalDepends)
+bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends)
 {
   // Lookup the set of sources to scan.
   std::string srcLang = "CMAKE_DEPENDS_CHECK_";
@@ -52,102 +48,92 @@ bool cmDepends::Write(std::ostream &makeDepends,
   cmSystemTools::ExpandListArgument(srcStr, pairs);
 
   std::map<std::string, std::set<std::string> > dependencies;
-  for(std::vector<std::string>::iterator si = pairs.begin();
-      si != pairs.end();)
-    {
+  for (std::vector<std::string>::iterator si = pairs.begin();
+       si != pairs.end();) {
     // Get the source and object file.
     std::string const& src = *si++;
-    if(si == pairs.end()) { break; }
+    if (si == pairs.end()) {
+      break;
+    }
     std::string const& obj = *si++;
     dependencies[obj].insert(src);
-    }
-  for(std::map<std::string, std::set<std::string> >::const_iterator
-      it = dependencies.begin(); it != dependencies.end(); ++it)
-    {
+  }
+  for (std::map<std::string, std::set<std::string> >::const_iterator it =
+         dependencies.begin();
+       it != dependencies.end(); ++it) {
 
     // Write the dependencies for this pair.
-    if(!this->WriteDependencies(it->second, it->first,
-                                makeDepends, internalDepends))
-      {
+    if (!this->WriteDependencies(it->second, it->first, makeDepends,
+                                 internalDepends)) {
       return false;
-      }
     }
+  }
 
   return this->Finalize(makeDepends, internalDepends);
 }
 
-//----------------------------------------------------------------------------
-bool cmDepends::Finalize(std::ostream&,
-                         std::ostream&)
+bool cmDepends::Finalize(std::ostream&, std::ostream&)
 {
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmDepends::Check(const char *makeFile, const char *internalFile,
+bool cmDepends::Check(const char* makeFile, const char* internalFile,
                       std::map<std::string, DependencyVector>& validDeps)
 {
   // Dependency checks must be done in proper working directory.
   std::string oldcwd = ".";
-  if(this->CompileDirectory != ".")
-    {
+  if (this->CompileDirectory != ".") {
     // Get the CWD but do not call CollapseFullPath because
     // we only need it to cd back, and the form does not matter
     oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false);
     cmSystemTools::ChangeDirectory(this->CompileDirectory);
-    }
+  }
 
   // Check whether dependencies must be regenerated.
   bool okay = true;
   cmsys::ifstream fin(internalFile);
-  if(!(fin && this->CheckDependencies(fin, internalFile, validDeps)))
-    {
+  if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
     // Clear all dependencies so they will be regenerated.
     this->Clear(makeFile);
     cmSystemTools::RemoveFile(internalFile);
     okay = false;
-    }
+  }
 
   // Restore working directory.
-  if(oldcwd != ".")
-    {
+  if (oldcwd != ".") {
     cmSystemTools::ChangeDirectory(oldcwd);
-    }
+  }
 
   return okay;
 }
 
-//----------------------------------------------------------------------------
-void cmDepends::Clear(const char *file)
+void cmDepends::Clear(const char* file)
 {
   // Print verbose output.
-  if(this->Verbose)
-    {
+  if (this->Verbose) {
     std::ostringstream msg;
     msg << "Clearing dependencies in \"" << file << "\"." << std::endl;
     cmSystemTools::Stdout(msg.str().c_str());
-    }
+  }
 
   // Write an empty dependency file.
   cmGeneratedFileStream depFileStream(file);
-  depFileStream
-    << "# Empty dependencies file\n"
-    << "# This may be replaced when dependencies are built." << std::endl;
+  depFileStream << "# Empty dependencies file\n"
+                << "# This may be replaced when dependencies are built."
+                << std::endl;
 }
 
-//----------------------------------------------------------------------------
-bool cmDepends::WriteDependencies(
-    const std::set<std::string>&, const std::string&,
-    std::ostream&, std::ostream&)
+bool cmDepends::WriteDependencies(const std::set<std::string>&,
+                                  const std::string&, std::ostream&,
+                                  std::ostream&)
 {
   // This should be implemented by the subclass.
   return false;
 }
 
-//----------------------------------------------------------------------------
-bool cmDepends::CheckDependencies(std::istream& internalDepends,
-                                  const char* internalDependsFileName,
-                            std::map<std::string, DependencyVector>& validDeps)
+bool cmDepends::CheckDependencies(
+  std::istream& internalDepends, const char* internalDependsFileName,
+  std::map<std::string, DependencyVector>& validDeps)
 {
   // Parse dependencies from the stream.  If any dependee is missing
   // or newer than the depender then dependencies should be
@@ -156,22 +142,18 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
   bool dependerExists = false;
   DependencyVector* currentDependencies = 0;
 
-  while(internalDepends.getline(this->Dependee, this->MaxPath))
-    {
-    if ( this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
-         this->Dependee[0] == '\r' )
-      {
+  while (internalDepends.getline(this->Dependee, this->MaxPath)) {
+    if (this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
+        this->Dependee[0] == '\r') {
       continue;
-      }
-    size_t len = internalDepends.gcount()-1;
-    if ( this->Dependee[len-1] == '\r' )
-      {
-      len --;
+    }
+    size_t len = internalDepends.gcount() - 1;
+    if (this->Dependee[len - 1] == '\r') {
+      len--;
       this->Dependee[len] = 0;
-      }
-    if ( this->Dependee[0] != ' ' )
-      {
-      memcpy(this->Depender, this->Dependee, len+1);
+    }
+    if (this->Dependee[0] != ' ') {
+      memcpy(this->Depender, this->Dependee, len + 1);
       // Calling FileExists() for the depender here saves in many cases 50%
       // of the calls to FileExists() further down in the loop. E.g. for
       // kdelibs/khtml this reduces the number of calls from 184k down to 92k,
@@ -183,7 +165,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
       // access.
       currentDependencies = &validDeps[this->Depender];
       continue;
-      }
+    }
     /*
     // Parse the dependency line.
     if(!this->ParseDependency(line.c_str()))
@@ -198,123 +180,103 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
     // * if the depender does not exist, but the dependee is newer than the
     //   depends file
     bool regenerate = false;
-    const char* dependee = this->Dependee+1;
+    const char* dependee = this->Dependee + 1;
     const char* depender = this->Depender;
-    if (currentDependencies != 0)
-      {
+    if (currentDependencies != 0) {
       currentDependencies->push_back(dependee);
-      }
+    }
 
-    if(!cmSystemTools::FileExists(dependee))
-      {
+    if (!cmSystemTools::FileExists(dependee)) {
       // The dependee does not exist.
       regenerate = true;
 
       // Print verbose output.
-      if(this->Verbose)
-        {
+      if (this->Verbose) {
         std::ostringstream msg;
-        msg << "Dependee \"" << dependee
-            << "\" does not exist for depender \""
+        msg << "Dependee \"" << dependee << "\" does not exist for depender \""
             << depender << "\"." << std::endl;
         cmSystemTools::Stdout(msg.str().c_str());
-        }
       }
-    else
-      {
-      if(dependerExists)
-        {
+    } else {
+      if (dependerExists) {
         // The dependee and depender both exist.  Compare file times.
         int result = 0;
-        if((!this->FileComparison->FileTimeCompare(depender, dependee,
-                                              &result) || result < 0))
-          {
+        if ((!this->FileComparison->FileTimeCompare(depender, dependee,
+                                                    &result) ||
+             result < 0)) {
           // The depender is older than the dependee.
           regenerate = true;
 
           // Print verbose output.
-          if(this->Verbose)
-            {
+          if (this->Verbose) {
             std::ostringstream msg;
-            msg << "Dependee \"" << dependee
-                << "\" is newer than depender \""
+            msg << "Dependee \"" << dependee << "\" is newer than depender \""
                 << depender << "\"." << std::endl;
             cmSystemTools::Stdout(msg.str().c_str());
-            }
           }
         }
-      else
-        {
+      } else {
         // The dependee exists, but the depender doesn't. Regenerate if the
         // internalDepends file is older than the dependee.
         int result = 0;
-        if((!this->FileComparison->FileTimeCompare(internalDependsFileName,
-                                             dependee, &result) || result < 0))
-          {
+        if ((!this->FileComparison->FileTimeCompare(internalDependsFileName,
+                                                    dependee, &result) ||
+             result < 0)) {
           // The depends-file is older than the dependee.
           regenerate = true;
 
           // Print verbose output.
-          if(this->Verbose)
-            {
+          if (this->Verbose) {
             std::ostringstream msg;
             msg << "Dependee \"" << dependee
                 << "\" is newer than depends file \""
                 << internalDependsFileName << "\"." << std::endl;
             cmSystemTools::Stdout(msg.str().c_str());
-            }
           }
         }
       }
-    if(regenerate)
-      {
+    }
+    if (regenerate) {
       // Dependencies must be regenerated.
       okay = false;
 
       // Remove the information of this depender from the map, it needs
       // to be rescanned
-      if (currentDependencies != 0)
-        {
+      if (currentDependencies != 0) {
         validDeps.erase(this->Depender);
         currentDependencies = 0;
-        }
+      }
 
       // Remove the depender to be sure it is rebuilt.
-      if (dependerExists)
-        {
+      if (dependerExists) {
         cmSystemTools::RemoveFile(depender);
         dependerExists = false;
-        }
       }
     }
+  }
 
   return okay;
 }
 
-//----------------------------------------------------------------------------
 void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
 {
   // Look for the new per "TARGET_" variant first:
-  const char * includePath = 0;
+  const char* includePath = 0;
   std::string includePathVar = "CMAKE_";
   includePathVar += lang;
   includePathVar += "_TARGET_INCLUDE_PATH";
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
   includePath = mf->GetDefinition(includePathVar);
-  if(includePath)
-    {
+  if (includePath) {
     cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
-    }
-  else
-    {
+  } else {
     // Fallback to the old directory level variable if no per-target var:
     includePathVar = "CMAKE_";
     includePathVar += lang;
     includePathVar += "_INCLUDE_PATH";
     includePath = mf->GetDefinition(includePathVar);
-    if(includePath)
-      {
+    if (includePath) {
       cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
-      }
     }
+  }
 }
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index 4f6517e..a62f8c2 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -29,10 +29,10 @@ class cmDepends
 public:
   /** Instances need to know the build directory name and the relative
       path from the build directory to the target file.  */
-  cmDepends(cmLocalGenerator* lg=0, const char* targetDir="");
+  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
@@ -53,27 +53,30 @@ public:
   virtual ~cmDepends();
 
   /** Write dependencies for the target file.  */
-  bool Write(std::ostream &makeDepends, std::ostream &internalDepends);
+  bool Write(std::ostream& makeDepends, std::ostream& internalDepends);
 
-  class DependencyVector: public std::vector<std::string> {};
+  class DependencyVector : public std::vector<std::string>
+  {
+  };
 
   /** Check dependencies for the target file.  Returns true if
       dependencies are okay and false if they must be generated.  If
       they must be generated Clear has already been called to wipe out
       the old dependencies.
       Dependencies which are still valid will be stored in validDeps. */
-  bool Check(const char *makeFile, const char* internalFile,
+  bool Check(const char* makeFile, const char* internalFile,
              std::map<std::string, DependencyVector>& validDeps);
 
   /** Clear dependencies for the target file so they will be regenerated.  */
-  void Clear(const char *file);
+  void Clear(const char* file);
 
   /** Set the file comparison object */
-  void SetFileComparison(cmFileTimeComparison* fc) {
-    this->FileComparison = fc; }
+  void SetFileComparison(cmFileTimeComparison* fc)
+  {
+    this->FileComparison = fc;
+  }
 
 protected:
-
   // Write dependencies for the target file to the given stream.
   // Return true for success and false for failure.
   virtual bool WriteDependencies(const std::set<std::string>& sources,
@@ -84,9 +87,9 @@ protected:
   // Check dependencies for the target file in the given stream.
   // Return false if dependencies must be regenerated and true
   // otherwise.
-  virtual bool CheckDependencies(std::istream& internalDepends,
-                                 const char* internalDependsFileName,
-                           std::map<std::string, DependencyVector>& validDeps);
+  virtual bool CheckDependencies(
+    std::istream& internalDepends, const char* internalDependsFileName,
+    std::map<std::string, DependencyVector>& validDeps);
 
   // Finalize the dependency information for the target.
   virtual bool Finalize(std::ostream& makeDepends,
@@ -117,7 +120,7 @@ protected:
   void SetIncludePathFromLanguage(const std::string& lang);
 
 private:
-  cmDepends(cmDepends const&); // Purposely not implemented.
+  cmDepends(cmDepends const&);      // Purposely not implemented.
   void operator=(cmDepends const&); // Purposely not implemented.
 };
 
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 6cdd4c1..78bb1b2 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -11,17 +11,16 @@
 ============================================================================*/
 #include "cmDependsC.h"
 
+#include "cmAlgorithms.h"
 #include "cmFileTimeComparison.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
-#include "cmAlgorithms.h"
 #include <cmsys/FStream.hxx>
 
 #include <ctype.h> // isspace
 
-
-#define INCLUDE_REGEX_LINE \
+#define INCLUDE_REGEX_LINE                                                    \
   "^[ \t]*#[ \t]*(include|import)[ \t]*[<\"]([^\">]+)([\">])"
 
 #define INCLUDE_REGEX_LINE_MARKER "#IncludeRegexLine: "
@@ -29,19 +28,16 @@
 #define INCLUDE_REGEX_COMPLAIN_MARKER "#IncludeRegexComplain: "
 #define INCLUDE_REGEX_TRANSFORM_MARKER "#IncludeRegexTransform: "
 
-//----------------------------------------------------------------------------
 cmDependsC::cmDependsC()
-: ValidDeps(0)
+  : ValidDeps(0)
 {
 }
 
-//----------------------------------------------------------------------------
-cmDependsC::cmDependsC(cmLocalGenerator* lg,
-                   const char* targetDir,
-                   const std::string& lang,
-                   const std::map<std::string, DependencyVector>* validDeps)
-: cmDepends(lg, targetDir)
-, ValidDeps(validDeps)
+cmDependsC::cmDependsC(
+  cmLocalGenerator* lg, const char* targetDir, const std::string& lang,
+  const std::map<std::string, DependencyVector>* validDeps)
+  : cmDepends(lg, targetDir)
+  , ValidDeps(validDeps)
 {
   cmMakefile* mf = lg->GetMakefile();
 
@@ -52,19 +48,17 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
   std::string scanRegex = "^.*$";
   std::string complainRegex = "^$";
   {
-  std::string scanRegexVar = "CMAKE_";
-  scanRegexVar += lang;
-  scanRegexVar += "_INCLUDE_REGEX_SCAN";
-  if(const char* sr = mf->GetDefinition(scanRegexVar))
-    {
-    scanRegex = sr;
+    std::string scanRegexVar = "CMAKE_";
+    scanRegexVar += lang;
+    scanRegexVar += "_INCLUDE_REGEX_SCAN";
+    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))
-    {
-    complainRegex = cr;
+    std::string complainRegexVar = "CMAKE_";
+    complainRegexVar += lang;
+    complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
+    if (const char* cr = mf->GetDefinition(complainRegexVar)) {
+      complainRegex = cr;
     }
   }
 
@@ -87,165 +81,140 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
   this->ReadCacheFile();
 }
 
-//----------------------------------------------------------------------------
 cmDependsC::~cmDependsC()
 {
   this->WriteCacheFile();
   cmDeleteAll(this->FileCache);
 }
 
-//----------------------------------------------------------------------------
 bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
                                    const std::string& obj,
                                    std::ostream& makeDepends,
                                    std::ostream& internalDepends)
 {
   // Make sure this is a scanning instance.
-  if(sources.empty() || sources.begin()->empty())
-    {
+  if (sources.empty() || sources.begin()->empty()) {
     cmSystemTools::Error("Cannot scan dependencies without a source file.");
     return false;
-    }
-  if(obj.empty())
-    {
+  }
+  if (obj.empty()) {
     cmSystemTools::Error("Cannot scan dependencies without an object file.");
     return false;
-    }
+  }
 
   std::set<std::string> dependencies;
   bool haveDeps = false;
 
-  if (this->ValidDeps != 0)
-    {
+  if (this->ValidDeps != 0) {
     std::map<std::string, DependencyVector>::const_iterator tmpIt =
-                                                    this->ValidDeps->find(obj);
-    if (tmpIt!= this->ValidDeps->end())
-      {
+      this->ValidDeps->find(obj);
+    if (tmpIt != this->ValidDeps->end()) {
       dependencies.insert(tmpIt->second.begin(), tmpIt->second.end());
       haveDeps = true;
-      }
     }
+  }
 
-  if (!haveDeps)
-    {
+  if (!haveDeps) {
     // Walk the dependency graph starting with the source file.
     int srcFiles = (int)sources.size();
     this->Encountered.clear();
 
-    for(std::set<std::string>::const_iterator srcIt = sources.begin();
-        srcIt != sources.end(); ++srcIt)
-      {
+    for (std::set<std::string>::const_iterator srcIt = sources.begin();
+         srcIt != sources.end(); ++srcIt) {
       UnscannedEntry root;
       root.FileName = *srcIt;
       this->Unscanned.push(root);
       this->Encountered.insert(*srcIt);
-      }
+    }
 
     std::set<std::string> scanned;
 
     // Use reserve to allocate enough memory for tempPathStr
     // so that during the loops no memory is allocated or freed
     std::string tempPathStr;
-    tempPathStr.reserve(4*1024);
+    tempPathStr.reserve(4 * 1024);
 
-    while(!this->Unscanned.empty())
-      {
+    while (!this->Unscanned.empty()) {
       // Get the next file to scan.
       UnscannedEntry current = this->Unscanned.front();
       this->Unscanned.pop();
 
       // If not a full path, find the file in the include path.
       std::string fullName;
-      if((srcFiles>0)
-         || cmSystemTools::FileIsFullPath(current.FileName.c_str()))
-        {
-        if(cmSystemTools::FileExists(current.FileName.c_str(), true))
-          {
+      if ((srcFiles > 0) ||
+          cmSystemTools::FileIsFullPath(current.FileName.c_str())) {
+        if (cmSystemTools::FileExists(current.FileName.c_str(), true)) {
           fullName = current.FileName;
-          }
         }
-      else if(!current.QuotedLocation.empty() &&
-              cmSystemTools::FileExists(current.QuotedLocation.c_str(), true))
-        {
+      } else if (!current.QuotedLocation.empty() &&
+                 cmSystemTools::FileExists(current.QuotedLocation.c_str(),
+                                           true)) {
         // The include statement producing this entry was a double-quote
         // include and the included file is present in the directory of
         // the source containing the include statement.
         fullName = current.QuotedLocation;
-        }
-      else
-        {
-        std::map<std::string, std::string>::iterator
-          headerLocationIt=this->HeaderLocationCache.find(current.FileName);
-        if (headerLocationIt!=this->HeaderLocationCache.end())
-          {
-          fullName=headerLocationIt->second;
-          }
-        else for(std::vector<std::string>::const_iterator i =
-              this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
-          {
-          // Construct the name of the file as if it were in the current
-          // include directory.  Avoid using a leading "./".
-
-          tempPathStr =
-            cmSystemTools::CollapseCombinedPath(*i, current.FileName);
-
-          // Look for the file in this location.
-          if(cmSystemTools::FileExists(tempPathStr.c_str(), true))
-            {
-            fullName = tempPathStr;
-            HeaderLocationCache[current.FileName]=fullName;
-            break;
+      } else {
+        std::map<std::string, std::string>::iterator headerLocationIt =
+          this->HeaderLocationCache.find(current.FileName);
+        if (headerLocationIt != this->HeaderLocationCache.end()) {
+          fullName = headerLocationIt->second;
+        } else
+          for (std::vector<std::string>::const_iterator i =
+                 this->IncludePath.begin();
+               i != this->IncludePath.end(); ++i) {
+            // Construct the name of the file as if it were in the current
+            // include directory.  Avoid using a leading "./".
+
+            tempPathStr =
+              cmSystemTools::CollapseCombinedPath(*i, current.FileName);
+
+            // Look for the file in this location.
+            if (cmSystemTools::FileExists(tempPathStr.c_str(), true)) {
+              fullName = tempPathStr;
+              HeaderLocationCache[current.FileName] = fullName;
+              break;
             }
           }
-        }
+      }
 
       // Complain if the file cannot be found and matches the complain
       // regex.
-      if(fullName.empty() &&
-        this->IncludeRegexComplain.find(current.FileName.c_str()))
-        {
-        cmSystemTools::Error("Cannot find file \"",
-                            current.FileName.c_str(), "\".");
+      if (fullName.empty() &&
+          this->IncludeRegexComplain.find(current.FileName.c_str())) {
+        cmSystemTools::Error("Cannot find file \"", current.FileName.c_str(),
+                             "\".");
         return false;
-        }
+      }
 
       // Scan the file if it was found and has not been scanned already.
-      if(!fullName.empty() && (scanned.find(fullName) == scanned.end()))
-        {
+      if (!fullName.empty() && (scanned.find(fullName) == scanned.end())) {
         // Record scanned files.
         scanned.insert(fullName);
 
         // Check whether this file is already in the cache
-        std::map<std::string, cmIncludeLines*>::iterator fileIt=
+        std::map<std::string, cmIncludeLines*>::iterator fileIt =
           this->FileCache.find(fullName);
-        if (fileIt!=this->FileCache.end())
-          {
-          fileIt->second->Used=true;
+        if (fileIt != this->FileCache.end()) {
+          fileIt->second->Used = true;
           dependencies.insert(fullName);
-          for (std::vector<UnscannedEntry>::const_iterator incIt=
-                fileIt->second->UnscannedEntries.begin();
-              incIt!=fileIt->second->UnscannedEntries.end(); ++incIt)
-            {
+          for (std::vector<UnscannedEntry>::const_iterator incIt =
+                 fileIt->second->UnscannedEntries.begin();
+               incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
             if (this->Encountered.find(incIt->FileName) ==
-                this->Encountered.end())
-              {
+                this->Encountered.end()) {
               this->Encountered.insert(incIt->FileName);
               this->Unscanned.push(*incIt);
-              }
             }
           }
-        else
-          {
+        } else {
 
           // Try to scan the file.  Just leave it out if we cannot find
           // it.
           cmsys::ifstream fin(fullName.c_str());
-          if(fin)
-            {
+          if (fin) {
             cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
-            if(bom == cmsys::FStream::BOM_None ||
-               bom == cmsys::FStream::BOM_UTF8)
-              {
+            if (bom == cmsys::FStream::BOM_None ||
+                bom == cmsys::FStream::BOM_UTF8) {
               // Add this file as a dependency.
               dependencies.insert(fullName);
 
@@ -253,213 +222,173 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
               // containing the file to handle double-quote includes.
               std::string dir = cmSystemTools::GetFilenamePath(fullName);
               this->Scan(fin, dir.c_str(), fullName);
-              }
-            else
-              {
+            } else {
               // Skip file with encoding we do not implement.
-              }
             }
           }
         }
+      }
 
       srcFiles--;
-      }
     }
+  }
 
   // Write the dependencies to the output stream.  Makefile rules
   // written by the original local generator for this directory
   // convert the dependencies to paths relative to the home output
   // directory.  We must do the same here.
   std::string obj_i =
-    this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT);
-  std::string obj_m =
-    this->LocalGenerator->ConvertToOutputFormat(obj_i,
-                                                cmLocalGenerator::MAKERULE);
+    this->LocalGenerator->Convert(obj, cmOutputConverter::HOME_OUTPUT);
+  std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
+    obj_i, cmOutputConverter::MAKERULE);
   internalDepends << obj_i << std::endl;
 
-  for(std::set<std::string>::const_iterator i=dependencies.begin();
-      i != dependencies.end(); ++i)
-    {
-    makeDepends << obj_m << ": " <<
-      this->LocalGenerator->Convert(*i,
-                                    cmLocalGenerator::HOME_OUTPUT,
-                                    cmLocalGenerator::MAKERULE)
+  for (std::set<std::string>::const_iterator i = dependencies.begin();
+       i != dependencies.end(); ++i) {
+    makeDepends << obj_m << ": "
+                << this->LocalGenerator->Convert(
+                     *i, cmOutputConverter::HOME_OUTPUT,
+                     cmOutputConverter::MAKERULE)
                 << std::endl;
     internalDepends << " " << *i << std::endl;
-    }
+  }
   makeDepends << std::endl;
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmDependsC::ReadCacheFile()
 {
-  if(this->CacheFileName.empty())
-    {
+  if (this->CacheFileName.empty()) {
     return;
-    }
+  }
   cmsys::ifstream fin(this->CacheFileName.c_str());
-  if(!fin)
-    {
+  if (!fin) {
     return;
-    }
+  }
 
   std::string line;
-  cmIncludeLines* cacheEntry=0;
-  bool haveFileName=false;
+  cmIncludeLines* cacheEntry = 0;
+  bool haveFileName = false;
 
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if (line.empty())
-      {
-      cacheEntry=0;
-      haveFileName=false;
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (line.empty()) {
+      cacheEntry = 0;
+      haveFileName = false;
       continue;
-      }
-    //the first line after an empty line is the name of the parsed file
-    if (haveFileName==false)
-      {
-      haveFileName=true;
-      int newer=0;
+    }
+    // the first line after an empty line is the name of the parsed file
+    if (haveFileName == false) {
+      haveFileName = true;
+      int newer = 0;
       cmFileTimeComparison comp;
-      bool res=comp.FileTimeCompare(this->CacheFileName.c_str(),
-                                    line.c_str(), &newer);
+      bool res = comp.FileTimeCompare(this->CacheFileName.c_str(),
+                                      line.c_str(), &newer);
 
-      if ((res==true) && (newer==1)) //cache is newer than the parsed file
-        {
-        cacheEntry=new cmIncludeLines;
-        this->FileCache[line]=cacheEntry;
-        }
+      if ((res == true) && (newer == 1)) // cache is newer than the parsed file
+      {
+        cacheEntry = new cmIncludeLines;
+        this->FileCache[line] = cacheEntry;
+      }
       // file doesn't exist, check that the regular expressions
       // haven't changed
-      else if (res==false)
-        {
-        if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0)
-          {
-          if (line != this->IncludeRegexLineString)
-            {
+      else if (res == false) {
+        if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0) {
+          if (line != this->IncludeRegexLineString) {
             return;
-            }
           }
-        else if (line.find(INCLUDE_REGEX_SCAN_MARKER) == 0)
-          {
-          if (line != this->IncludeRegexScanString)
-            {
+        } else if (line.find(INCLUDE_REGEX_SCAN_MARKER) == 0) {
+          if (line != this->IncludeRegexScanString) {
             return;
-            }
           }
-        else if (line.find(INCLUDE_REGEX_COMPLAIN_MARKER) == 0)
-          {
-          if (line != this->IncludeRegexComplainString)
-            {
+        } else if (line.find(INCLUDE_REGEX_COMPLAIN_MARKER) == 0) {
+          if (line != this->IncludeRegexComplainString) {
             return;
-            }
           }
-        else if (line.find(INCLUDE_REGEX_TRANSFORM_MARKER) == 0)
-          {
-          if (line != this->IncludeRegexTransformString)
-            {
+        } else if (line.find(INCLUDE_REGEX_TRANSFORM_MARKER) == 0) {
+          if (line != this->IncludeRegexTransformString) {
             return;
-            }
           }
         }
       }
-    else if (cacheEntry!=0)
-      {
+    } else if (cacheEntry != 0) {
       UnscannedEntry entry;
       entry.FileName = line;
-      if (cmSystemTools::GetLineFromStream(fin, line))
-        {
-        if (line!="-")
-          {
-          entry.QuotedLocation=line;
-          }
-        cacheEntry->UnscannedEntries.push_back(entry);
+      if (cmSystemTools::GetLineFromStream(fin, line)) {
+        if (line != "-") {
+          entry.QuotedLocation = line;
         }
+        cacheEntry->UnscannedEntries.push_back(entry);
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDependsC::WriteCacheFile() const
 {
-  if(this->CacheFileName.empty())
-    {
+  if (this->CacheFileName.empty()) {
     return;
-    }
+  }
   cmsys::ofstream cacheOut(this->CacheFileName.c_str());
-  if(!cacheOut)
-    {
+  if (!cacheOut) {
     return;
-    }
+  }
 
   cacheOut << this->IncludeRegexLineString << "\n\n";
   cacheOut << this->IncludeRegexScanString << "\n\n";
   cacheOut << this->IncludeRegexComplainString << "\n\n";
   cacheOut << this->IncludeRegexTransformString << "\n\n";
 
-  for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt=
+  for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt =
          this->FileCache.begin();
-       fileIt!=this->FileCache.end(); ++fileIt)
-    {
-    if (fileIt->second->Used)
-      {
-      cacheOut<<fileIt->first.c_str()<<std::endl;
-
-      for (std::vector<UnscannedEntry>::const_iterator
-             incIt=fileIt->second->UnscannedEntries.begin();
-           incIt!=fileIt->second->UnscannedEntries.end(); ++incIt)
-        {
-        cacheOut<<incIt->FileName.c_str()<<std::endl;
-        if (incIt->QuotedLocation.empty())
-          {
-          cacheOut<<"-"<<std::endl;
-          }
-        else
-          {
-          cacheOut<<incIt->QuotedLocation.c_str()<<std::endl;
-          }
+       fileIt != this->FileCache.end(); ++fileIt) {
+    if (fileIt->second->Used) {
+      cacheOut << fileIt->first.c_str() << std::endl;
+
+      for (std::vector<UnscannedEntry>::const_iterator incIt =
+             fileIt->second->UnscannedEntries.begin();
+           incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
+        cacheOut << incIt->FileName.c_str() << std::endl;
+        if (incIt->QuotedLocation.empty()) {
+          cacheOut << "-" << std::endl;
+        } else {
+          cacheOut << incIt->QuotedLocation.c_str() << std::endl;
         }
-      cacheOut<<std::endl;
       }
-   }
+      cacheOut << std::endl;
+    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDependsC::Scan(std::istream& is, const char* directory,
-  const std::string& fullName)
+                      const std::string& fullName)
 {
-  cmIncludeLines* newCacheEntry=new cmIncludeLines;
-  newCacheEntry->Used=true;
-  this->FileCache[fullName]=newCacheEntry;
+  cmIncludeLines* newCacheEntry = new cmIncludeLines;
+  newCacheEntry->Used = true;
+  this->FileCache[fullName] = newCacheEntry;
 
   // Read one line at a time.
   std::string line;
-  while(cmSystemTools::GetLineFromStream(is, line))
-    {
+  while (cmSystemTools::GetLineFromStream(is, line)) {
     // Transform the line content first.
-    if(!this->TransformRules.empty())
-      {
+    if (!this->TransformRules.empty()) {
       this->TransformLine(line);
-      }
+    }
 
     // Match include directives.
-    if(this->IncludeRegexLine.find(line.c_str()))
-      {
+    if (this->IncludeRegexLine.find(line.c_str())) {
       // Get the file being included.
       UnscannedEntry entry;
       entry.FileName = this->IncludeRegexLine.match(2);
       cmSystemTools::ConvertToUnixSlashes(entry.FileName);
-      if(this->IncludeRegexLine.match(3) == "\"" &&
-         !cmSystemTools::FileIsFullPath(entry.FileName.c_str()))
-        {
+      if (this->IncludeRegexLine.match(3) == "\"" &&
+          !cmSystemTools::FileIsFullPath(entry.FileName.c_str())) {
         // This was a double-quoted include with a relative path.  We
         // must check for the file in the directory containing the
         // file we are scanning.
         entry.QuotedLocation =
           cmSystemTools::CollapseCombinedPath(directory, entry.FileName);
-        }
+      }
 
       // Queue the file if it has not yet been encountered and it
       // matches the regular expression for recursive scanning.  Note
@@ -471,111 +400,94 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
       // file their own directory by simply using "filename.h" (#12619)
       // This kind of problem will be fixed when a more
       // preprocessor-like implementation of this scanner is created.
-      if (this->IncludeRegexScan.find(entry.FileName.c_str()))
-        {
+      if (this->IncludeRegexScan.find(entry.FileName.c_str())) {
         newCacheEntry->UnscannedEntries.push_back(entry);
-        if(this->Encountered.find(entry.FileName) == this->Encountered.end())
-          {
+        if (this->Encountered.find(entry.FileName) ==
+            this->Encountered.end()) {
           this->Encountered.insert(entry.FileName);
           this->Unscanned.push(entry);
-          }
         }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDependsC::SetupTransforms()
 {
   // Get the transformation rules.
   std::vector<std::string> transformRules;
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
-  if(const char* xform =
-     mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS"))
-    {
+  if (const char* xform = mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) {
     cmSystemTools::ExpandListArgument(xform, transformRules, true);
-    }
-  for(std::vector<std::string>::const_iterator tri = transformRules.begin();
-      tri != transformRules.end(); ++tri)
-    {
+  }
+  for (std::vector<std::string>::const_iterator tri = transformRules.begin();
+       tri != transformRules.end(); ++tri) {
     this->ParseTransform(*tri);
-    }
+  }
 
   this->IncludeRegexTransformString = INCLUDE_REGEX_TRANSFORM_MARKER;
-  if(!this->TransformRules.empty())
-    {
+  if (!this->TransformRules.empty()) {
     // Construct the regular expression to match lines to be
     // transformed.
     std::string xform = "^([ \t]*#[ \t]*(include|import)[ \t]*)(";
     const char* sep = "";
-    for(TransformRulesType::const_iterator tri = this->TransformRules.begin();
-        tri != this->TransformRules.end(); ++tri)
-      {
+    for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
+         tri != this->TransformRules.end(); ++tri) {
       xform += sep;
       xform += tri->first;
       sep = "|";
-      }
+    }
     xform += ")[ \t]*\\(([^),]*)\\)";
     this->IncludeRegexTransform.compile(xform.c_str());
 
     // Build a string that encodes all transformation rules and will
     // change when rules are changed.
     this->IncludeRegexTransformString += xform;
-    for(TransformRulesType::const_iterator tri = this->TransformRules.begin();
-        tri != this->TransformRules.end(); ++tri)
-      {
+    for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
+         tri != this->TransformRules.end(); ++tri) {
       this->IncludeRegexTransformString += " ";
       this->IncludeRegexTransformString += tri->first;
       this->IncludeRegexTransformString += "(%)=";
       this->IncludeRegexTransformString += tri->second;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDependsC::ParseTransform(std::string const& xform)
 {
   // A transform rule is of the form SOME_MACRO(%)=value-with-%
   // We can simply separate with "(%)=".
   std::string::size_type pos = xform.find("(%)=");
-  if(pos == xform.npos || pos == 0)
-    {
+  if (pos == xform.npos || pos == 0) {
     return;
-    }
+  }
   std::string name = xform.substr(0, pos);
-  std::string value = xform.substr(pos+4, xform.npos);
+  std::string value = xform.substr(pos + 4, xform.npos);
   this->TransformRules[name] = value;
 }
 
-//----------------------------------------------------------------------------
 void cmDependsC::TransformLine(std::string& line)
 {
   // Check for a transform rule match.  Return if none.
-  if(!this->IncludeRegexTransform.find(line.c_str()))
-    {
+  if (!this->IncludeRegexTransform.find(line.c_str())) {
     return;
-    }
+  }
   TransformRulesType::const_iterator tri =
     this->TransformRules.find(this->IncludeRegexTransform.match(3));
-  if(tri == this->TransformRules.end())
-    {
+  if (tri == this->TransformRules.end()) {
     return;
-    }
+  }
 
   // Construct the transformed line.
   std::string newline = this->IncludeRegexTransform.match(1);
   std::string arg = this->IncludeRegexTransform.match(4);
-  for(const char* c = tri->second.c_str(); *c; ++c)
-    {
-    if(*c == '%')
-      {
+  for (const char* c = tri->second.c_str(); *c; ++c) {
+    if (*c == '%') {
       newline += arg;
-      }
-    else
-      {
+    } else {
       newline += *c;
-      }
     }
+  }
 
   // Return the transformed line.
   line = newline;
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index 07d3c21..e830aa8 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -13,13 +13,14 @@
 #define cmDependsC_h
 
 #include "cmDepends.h"
+
 #include <cmsys/RegularExpression.hxx>
 #include <queue>
 
 /** \class cmDependsC
  * \brief Dependency scanner for C and C++ object files.
  */
-class cmDependsC: public cmDepends
+class cmDependsC : public cmDepends
 {
 public:
   /** Checking instances need to know the build directory name and the
@@ -35,13 +36,13 @@ public:
 protected:
   // Implement writing/checking methods required by superclass.
   virtual bool WriteDependencies(const std::set<std::string>& sources,
-                                 const std::string&           obj,
+                                 const std::string& obj,
                                  std::ostream& makeDepends,
                                  std::ostream& internalDepends);
 
   // Method to scan a single file.
   void Scan(std::istream& is, const char* directory,
-    const std::string& fullName);
+            const std::string& fullName);
 
   // Regular expression to identify C preprocessor include directives.
   cmsys::RegularExpression IncludeRegexLine;
@@ -73,24 +74,29 @@ public:
 
   struct cmIncludeLines
   {
-    cmIncludeLines(): Used(false) {}
+    cmIncludeLines()
+      : Used(false)
+    {
+    }
     std::vector<UnscannedEntry> UnscannedEntries;
     bool Used;
   };
+
 protected:
   const std::map<std::string, DependencyVector>* ValidDeps;
   std::set<std::string> Encountered;
   std::queue<UnscannedEntry> Unscanned;
 
-  std::map<std::string, cmIncludeLines *> FileCache;
+  std::map<std::string, cmIncludeLines*> FileCache;
   std::map<std::string, std::string> HeaderLocationCache;
 
   std::string CacheFileName;
 
   void WriteCacheFile() const;
   void ReadCacheFile();
+
 private:
-  cmDependsC(cmDependsC const&); // Purposely not implemented.
+  cmDependsC(cmDependsC const&);     // Purposely not implemented.
   void operator=(cmDependsC const&); // Purposely not implemented.
 };
 
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 80f560f..38e319d 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -11,20 +11,19 @@
 ============================================================================*/
 #include "cmDependsFortran.h"
 
-#include "cmSystemTools.h"
+#include "cmGeneratedFileStream.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
+#include "cmSystemTools.h"
 
 #include "cmFortranParser.h" /* Interface to parser object.  */
-#include <cmsys/FStream.hxx>
 #include <assert.h>
+#include <cmsys/FStream.hxx>
 
 // TODO: Test compiler for the case of the mod file.  Some always
 // use lower case and some always use upper case.  I do not know if any
 // use the case from the source code.
 
-//----------------------------------------------------------------------------
 class cmDependsFortranInternals
 {
 public:
@@ -39,33 +38,28 @@ public:
   typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
   ObjectInfoMap ObjectInfo;
 
-  cmFortranSourceInfo& CreateObjectInfo(const char* obj,
-                                               const char* src)
-    {
+  cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
+  {
     std::map<std::string, cmFortranSourceInfo>::iterator i =
       this->ObjectInfo.find(obj);
-    if(i == this->ObjectInfo.end())
-      {
-      std::map<std::string, cmFortranSourceInfo>::value_type
-        entry(obj, cmFortranSourceInfo());
+    if (i == this->ObjectInfo.end()) {
+      std::map<std::string, cmFortranSourceInfo>::value_type entry(
+        obj, cmFortranSourceInfo());
       i = this->ObjectInfo.insert(entry).first;
       i->second.Source = src;
-      }
-    return i->second;
     }
+    return i->second;
+  }
 };
 
-//----------------------------------------------------------------------------
-cmDependsFortran::cmDependsFortran():
-  Internal(0)
+cmDependsFortran::cmDependsFortran()
+  : Internal(0)
 {
 }
 
-//----------------------------------------------------------------------------
-cmDependsFortran
-::cmDependsFortran(cmLocalGenerator* lg):
-  cmDepends(lg),
-  Internal(new cmDependsFortranInternals)
+cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
+  : cmDepends(lg)
+  , Internal(new cmDependsFortranInternals)
 {
   // Configure the include file search path.
   this->SetIncludePathFromLanguage("Fortran");
@@ -73,54 +67,46 @@ cmDependsFortran
   // Get the list of definitions.
   std::vector<std::string> definitions;
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
-  if(const char* c_defines =
-     mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran"))
-    {
+  if (const char* c_defines =
+        mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran")) {
     cmSystemTools::ExpandListArgument(c_defines, definitions);
-    }
+  }
 
   // translate i.e. FOO=BAR to FOO and add it to the list of defined
   // preprocessor symbols
-  for(std::vector<std::string>::const_iterator
-      it = definitions.begin(); it != definitions.end(); ++it)
-    {
+  for (std::vector<std::string>::const_iterator it = definitions.begin();
+       it != definitions.end(); ++it) {
     std::string def = *it;
-    std::string::size_type assignment = def.find("=");
-    if(assignment != std::string::npos)
-      {
+    std::string::size_type assignment = def.find('=');
+    if (assignment != std::string::npos) {
       def = it->substr(0, assignment);
-      }
-    this->PPDefinitions.insert(def);
     }
+    this->PPDefinitions.insert(def);
+  }
 }
 
-//----------------------------------------------------------------------------
 cmDependsFortran::~cmDependsFortran()
 {
   delete this->Internal;
 }
 
-//----------------------------------------------------------------------------
-bool cmDependsFortran::WriteDependencies(
-    const std::set<std::string>& sources, const std::string& obj,
-    std::ostream&, std::ostream&)
+bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
+                                         const std::string& obj, std::ostream&,
+                                         std::ostream&)
 {
   // Make sure this is a scanning instance.
-  if(sources.empty() || sources.begin()->empty())
-    {
+  if (sources.empty() || sources.begin()->empty()) {
     cmSystemTools::Error("Cannot scan dependencies without a source file.");
     return false;
-    }
-  if(obj.empty())
-    {
+  }
+  if (obj.empty()) {
     cmSystemTools::Error("Cannot scan dependencies without an object file.");
     return false;
-    }
+  }
 
   bool okay = true;
-  for(std::set<std::string>::const_iterator it = sources.begin();
-      it != sources.end(); ++it)
-    {
+  for (std::set<std::string>::const_iterator it = sources.begin();
+       it != sources.end(); ++it) {
     const std::string& src = *it;
     // Get the information object for this source.
     cmFortranSourceInfo& info =
@@ -134,16 +120,14 @@ bool cmDependsFortran::WriteDependencies(
     cmFortranParser_FilePush(&parser, src.c_str());
 
     // Parse the translation unit.
-    if(cmFortran_yyparse(parser.Scanner) != 0)
-      {
+    if (cmFortran_yyparse(parser.Scanner) != 0) {
       // Failed to parse the file.  Report failure to write dependencies.
       okay = false;
-      }
     }
+  }
   return okay;
 }
 
-//----------------------------------------------------------------------------
 bool cmDependsFortran::Finalize(std::ostream& makeDepends,
                                 std::ostream& internalDepends)
 {
@@ -157,25 +141,21 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
   std::string mod_dir =
     mf->GetSafeDefinition("CMAKE_Fortran_TARGET_MODULE_DIR");
-  if (mod_dir.empty())
-    {
-    mod_dir =
-      this->LocalGenerator->GetCurrentBinaryDirectory();
-    }
+  if (mod_dir.empty()) {
+    mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
+  }
 
   // Actually write dependencies to the streams.
   typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
   ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
-  for(ObjectInfoMap::const_iterator i = objInfo.begin();
-      i != objInfo.end(); ++i)
-    {
-    if(!this->WriteDependenciesReal(i->first.c_str(), i->second,
-                                    mod_dir, stamp_dir,
-                                    makeDepends, internalDepends))
-      {
+  for (ObjectInfoMap::const_iterator i = objInfo.begin(); i != objInfo.end();
+       ++i) {
+    if (!this->WriteDependenciesReal(i->first.c_str(), i->second, mod_dir,
+                                     stamp_dir, makeDepends,
+                                     internalDepends)) {
       return false;
-      }
     }
+  }
 
   // Store the list of modules provided by this target.
   std::string fiName = this->TargetDirectory;
@@ -184,23 +164,20 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   fiStream << "# The fortran modules provided by this target.\n";
   fiStream << "provides\n";
   std::set<std::string> const& provides = this->Internal->TargetProvides;
-  for(std::set<std::string>::const_iterator i = provides.begin();
-      i != provides.end(); ++i)
-    {
+  for (std::set<std::string>::const_iterator i = provides.begin();
+       i != provides.end(); ++i) {
     fiStream << " " << *i << "\n";
-    }
+  }
 
   // Create a script to clean the modules.
-  if(!provides.empty())
-    {
+  if (!provides.empty()) {
     std::string fcName = this->TargetDirectory;
     fcName += "/cmake_clean_Fortran.cmake";
     cmGeneratedFileStream fcStream(fcName.c_str());
     fcStream << "# Remove fortran modules provided by this target.\n";
     fcStream << "FILE(REMOVE";
-    for(std::set<std::string>::const_iterator i = provides.begin();
-        i != provides.end(); ++i)
-      {
+    for (std::set<std::string>::const_iterator i = provides.begin();
+         i != provides.end(); ++i) {
       std::string mod_upper = mod_dir;
       mod_upper += "/";
       mod_upper += cmSystemTools::UpperCase(*i);
@@ -214,50 +191,46 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
       stamp += *i;
       stamp += ".mod.stamp";
       fcStream << "\n";
-      fcStream << "  \"" <<
-        this->LocalGenerator->Convert(mod_lower,
-                                      cmLocalGenerator::START_OUTPUT)
+      fcStream << "  \""
+               << this->LocalGenerator->Convert(
+                    mod_lower, cmOutputConverter::START_OUTPUT)
                << "\"\n";
-      fcStream << "  \"" <<
-        this->LocalGenerator->Convert(mod_upper,
-                                      cmLocalGenerator::START_OUTPUT)
+      fcStream << "  \""
+               << this->LocalGenerator->Convert(
+                    mod_upper, cmOutputConverter::START_OUTPUT)
                << "\"\n";
-      fcStream << "  \"" <<
-        this->LocalGenerator->Convert(stamp,
-                                      cmLocalGenerator::START_OUTPUT)
+      fcStream << "  \""
+               << this->LocalGenerator->Convert(
+                    stamp, cmOutputConverter::START_OUTPUT)
                << "\"\n";
-      }
-    fcStream << "  )\n";
     }
+    fcStream << "  )\n";
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmDependsFortran::LocateModules()
 {
   // Collect the set of modules provided and required by all sources.
   typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
   ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
-  for(ObjectInfoMap::const_iterator infoI = objInfo.begin();
-      infoI != objInfo.end(); ++infoI)
-    {
+  for (ObjectInfoMap::const_iterator infoI = objInfo.begin();
+       infoI != objInfo.end(); ++infoI) {
     cmFortranSourceInfo const& info = infoI->second;
     // Include this module in the set provided by this target.
     this->Internal->TargetProvides.insert(info.Provides.begin(),
                                           info.Provides.end());
 
-    for(std::set<std::string>::const_iterator i = info.Requires.begin();
-        i != info.Requires.end(); ++i)
-      {
+    for (std::set<std::string>::const_iterator i = info.Requires.begin();
+         i != info.Requires.end(); ++i) {
       this->Internal->TargetRequires[*i] = "";
-      }
     }
+  }
 
   // Short-circuit for simple targets.
-  if(this->Internal->TargetRequires.empty())
-    {
+  if (this->Internal->TargetRequires.empty()) {
     return;
-    }
+  }
 
   // Match modules provided by this target to those it requires.
   this->MatchLocalModules();
@@ -265,97 +238,77 @@ void cmDependsFortran::LocateModules()
   // Load information about other targets.
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
   std::vector<std::string> infoFiles;
-  if(const char* infoFilesValue =
-     mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES"))
-    {
+  if (const char* infoFilesValue =
+        mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES")) {
     cmSystemTools::ExpandListArgument(infoFilesValue, infoFiles);
-    }
-  for(std::vector<std::string>::const_iterator i = infoFiles.begin();
-      i != infoFiles.end(); ++i)
-    {
+  }
+  for (std::vector<std::string>::const_iterator i = infoFiles.begin();
+       i != infoFiles.end(); ++i) {
     std::string targetDir = cmSystemTools::GetFilenamePath(*i);
     std::string fname = targetDir + "/fortran.internal";
     cmsys::ifstream fin(fname.c_str());
-    if(fin)
-      {
+    if (fin) {
       this->MatchRemoteModules(fin, targetDir.c_str());
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDependsFortran::MatchLocalModules()
 {
   const char* stampDir = this->TargetDirectory.c_str();
   std::set<std::string> const& provides = this->Internal->TargetProvides;
-  for(std::set<std::string>::const_iterator i = provides.begin();
-      i != provides.end(); ++i)
-    {
+  for (std::set<std::string>::const_iterator i = provides.begin();
+       i != provides.end(); ++i) {
     this->ConsiderModule(i->c_str(), stampDir);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDependsFortran::MatchRemoteModules(std::istream& fin,
                                           const char* stampDir)
 {
   std::string line;
   bool doing_provides = false;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
     // Ignore comments and empty lines.
-    if(line.empty() || line[0] == '#' || line[0] == '\r')
-      {
+    if (line.empty() || line[0] == '#' || line[0] == '\r') {
       continue;
-      }
+    }
 
-    if(line[0] == ' ')
-      {
-      if(doing_provides)
-        {
-        this->ConsiderModule(line.c_str()+1, stampDir);
-        }
+    if (line[0] == ' ') {
+      if (doing_provides) {
+        this->ConsiderModule(line.c_str() + 1, stampDir);
       }
-    else if(line == "provides")
-      {
+    } else if (line == "provides") {
       doing_provides = true;
-      }
-    else
-      {
+    } else {
       doing_provides = false;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmDependsFortran::ConsiderModule(const char* name,
-                                      const char* stampDir)
+void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
 {
   // Locate each required module.
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
   TargetRequiresMap::iterator required =
     this->Internal->TargetRequires.find(name);
-  if(required != this->Internal->TargetRequires.end() &&
-     required->second.empty())
-    {
+  if (required != this->Internal->TargetRequires.end() &&
+      required->second.empty()) {
     // The module is provided by a CMake target.  It will have a stamp file.
     std::string stampFile = stampDir;
     stampFile += "/";
     stampFile += name;
     stampFile += ".mod.stamp";
     required->second = stampFile;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmDependsFortran
-::WriteDependenciesReal(const char *obj,
-                        cmFortranSourceInfo const& info,
-                        std::string const& mod_dir,
-                        const char* stamp_dir,
-                        std::ostream& makeDepends,
-                        std::ostream& internalDepends)
+bool cmDependsFortran::WriteDependenciesReal(const char* obj,
+                                             cmFortranSourceInfo const& info,
+                                             std::string const& mod_dir,
+                                             const char* stamp_dir,
+                                             std::ostream& makeDepends,
+                                             std::ostream& internalDepends)
 {
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
 
@@ -364,40 +317,35 @@ cmDependsFortran
 
   // Write the include dependencies to the output stream.
   std::string obj_i =
-    this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT);
-  std::string obj_m =
-    this->LocalGenerator->ConvertToOutputFormat(obj_i,
-                                                cmLocalGenerator::MAKERULE);
+    this->LocalGenerator->Convert(obj, cmOutputConverter::HOME_OUTPUT);
+  std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
+    obj_i, cmOutputConverter::MAKERULE);
   internalDepends << obj_i << std::endl;
   internalDepends << " " << src << std::endl;
-  for(std::set<std::string>::const_iterator i = info.Includes.begin();
-      i != info.Includes.end(); ++i)
-    {
-    makeDepends << obj_m << ": " <<
-      this->LocalGenerator->Convert(*i,
-                                    cmLocalGenerator::HOME_OUTPUT,
-                                    cmLocalGenerator::MAKERULE)
+  for (std::set<std::string>::const_iterator i = info.Includes.begin();
+       i != info.Includes.end(); ++i) {
+    makeDepends << obj_m << ": "
+                << this->LocalGenerator->Convert(
+                     *i, cmOutputConverter::HOME_OUTPUT,
+                     cmOutputConverter::MAKERULE)
                 << std::endl;
     internalDepends << " " << *i << std::endl;
-    }
+  }
   makeDepends << std::endl;
 
   // Write module requirements to the output stream.
-  for(std::set<std::string>::const_iterator i = info.Requires.begin();
-      i != info.Requires.end(); ++i)
-    {
+  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<std::string>::const_iterator(info.Provides.find(*i)) !=
-       info.Provides.end())
-      {
+    if (std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
+        info.Provides.end()) {
       continue;
-      }
+    }
 
     // If the module is provided in this target special handling is
     // needed.
-    if(this->Internal->TargetProvides.find(*i) !=
-       this->Internal->TargetProvides.end())
-      {
+    if (this->Internal->TargetProvides.find(*i) !=
+        this->Internal->TargetProvides.end()) {
       // The module is provided by a different source in the same
       // target.  Add the proxy dependency to make sure the other
       // source builds first.
@@ -405,67 +353,57 @@ cmDependsFortran
       proxy += "/";
       proxy += *i;
       proxy += ".mod.proxy";
-      proxy = this->LocalGenerator->Convert(proxy,
-                                            cmLocalGenerator::HOME_OUTPUT,
-                                            cmLocalGenerator::MAKERULE);
+      proxy = this->LocalGenerator->Convert(
+        proxy, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
 
       // since we require some things add them to our list of requirements
       makeDepends << obj_m << ".requires: " << proxy << std::endl;
-      }
+    }
 
     // The object file should depend on timestamped files for the
     // modules it uses.
     TargetRequiresMap::const_iterator required =
       this->Internal->TargetRequires.find(*i);
-    if(required == this->Internal->TargetRequires.end()) { abort(); }
-    if(!required->second.empty())
-      {
+    if (required == this->Internal->TargetRequires.end()) {
+      abort();
+    }
+    if (!required->second.empty()) {
       // This module is known.  Depend on its timestamp file.
-      std::string stampFile =
-        this->LocalGenerator->Convert(required->second,
-                                      cmLocalGenerator::HOME_OUTPUT,
-                                      cmLocalGenerator::MAKERULE);
+      std::string stampFile = this->LocalGenerator->Convert(
+        required->second, cmOutputConverter::HOME_OUTPUT,
+        cmOutputConverter::MAKERULE);
       makeDepends << obj_m << ": " << stampFile << "\n";
-      }
-    else
-      {
+    } else {
       // This module is not known to CMake.  Try to locate it where
       // the compiler will and depend on that.
       std::string module;
-      if(this->FindModule(*i, module))
-        {
-        module =
-          this->LocalGenerator->Convert(module,
-                                        cmLocalGenerator::HOME_OUTPUT,
-                                        cmLocalGenerator::MAKERULE);
+      if (this->FindModule(*i, module)) {
+        module = this->LocalGenerator->Convert(
+          module, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
         makeDepends << obj_m << ": " << module << "\n";
-        }
       }
     }
+  }
 
   // Write provided modules to the output stream.
-  for(std::set<std::string>::const_iterator i = info.Provides.begin();
-      i != info.Provides.end(); ++i)
-    {
+  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,
-                                          cmLocalGenerator::HOME_OUTPUT,
-                                          cmLocalGenerator::MAKERULE);
+    proxy = this->LocalGenerator->Convert(
+      proxy, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
     makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
-    }
+  }
 
   // If any modules are provided then they must be converted to stamp files.
-  if(!info.Provides.empty())
-    {
+  if (!info.Provides.empty()) {
     // Create a target to copy the module after the object file
     // changes.
     makeDepends << obj_m << ".provides.build:\n";
-    for(std::set<std::string>::const_iterator i = info.Provides.begin();
-        i != info.Provides.end(); ++i)
-      {
+    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);
 
@@ -476,28 +414,23 @@ cmDependsFortran
       std::string modFile = mod_dir;
       modFile += "/";
       modFile += *i;
-      modFile =
-        this->LocalGenerator->Convert(modFile,
-                                      cmLocalGenerator::HOME_OUTPUT,
-                                      cmLocalGenerator::SHELL);
+      modFile = this->LocalGenerator->Convert(
+        modFile, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::SHELL);
       std::string stampFile = stamp_dir;
       stampFile += "/";
       stampFile += m;
       stampFile += ".mod.stamp";
-      stampFile =
-        this->LocalGenerator->Convert(stampFile,
-                                      cmLocalGenerator::HOME_OUTPUT,
-                                      cmLocalGenerator::SHELL);
-      makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod "
-                  << modFile << " " << stampFile;
+      stampFile = this->LocalGenerator->Convert(
+        stampFile, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::SHELL);
+      makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
+                  << " " << stampFile;
       cmMakefile* mf = this->LocalGenerator->GetMakefile();
       const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID");
-      if(cid && *cid)
-        {
+      if (cid && *cid) {
         makeDepends << " " << cid;
-        }
-      makeDepends << "\n";
       }
+      makeDepends << "\n";
+    }
     // After copying the modules update the timestamp file so that
     // copying will not be done again until the source rebuilds.
     makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj_m
@@ -507,18 +440,15 @@ cmDependsFortran
     // the target finishes building.
     std::string driver = this->TargetDirectory;
     driver += "/build";
-    driver = this->LocalGenerator->Convert(driver,
-                                           cmLocalGenerator::HOME_OUTPUT,
-                                           cmLocalGenerator::MAKERULE);
+    driver = this->LocalGenerator->Convert(
+      driver, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
     makeDepends << driver << ": " << obj_m << ".provides.build\n";
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmDependsFortran::FindModule(std::string const& name,
-                                  std::string& module)
+bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
 {
   // Construct possible names for the module file.
   std::string mod_upper = cmSystemTools::UpperCase(name);
@@ -528,33 +458,29 @@ bool cmDependsFortran::FindModule(std::string const& name,
 
   // Search the include path for the module.
   std::string fullName;
-  for(std::vector<std::string>::const_iterator i =
-        this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
+       i != this->IncludePath.end(); ++i) {
     // Try the lower-case name.
     fullName = *i;
     fullName += "/";
     fullName += mod_lower;
-    if(cmSystemTools::FileExists(fullName.c_str(), true))
-      {
+    if (cmSystemTools::FileExists(fullName.c_str(), true)) {
       module = fullName;
       return true;
-      }
+    }
 
     // Try the upper-case name.
     fullName = *i;
     fullName += "/";
     fullName += mod_upper;
-    if(cmSystemTools::FileExists(fullName.c_str(), true))
-      {
+    if (cmSystemTools::FileExists(fullName.c_str(), true)) {
       module = fullName;
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
 {
   // Implements
@@ -570,12 +496,13 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
   std::string mod = args[2];
   std::string stamp = args[3];
   std::string compilerId;
-  if(args.size() >= 5)
-    {
+  if (args.size() >= 5) {
     compilerId = args[4];
-    }
+  }
   std::string mod_dir = cmSystemTools::GetFilenamePath(mod);
-  if(!mod_dir.empty()) { mod_dir += "/"; }
+  if (!mod_dir.empty()) {
+    mod_dir += "/";
+  }
   std::string mod_upper = mod_dir;
   mod_upper += cmSystemTools::UpperCase(cmSystemTools::GetFilenameName(mod));
   std::string mod_lower = mod_dir;
@@ -583,108 +510,85 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
   mod += ".mod";
   mod_upper += ".mod";
   mod_lower += ".mod";
-  if(cmSystemTools::FileExists(mod_upper.c_str(), true))
-    {
-    if(cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
-                                       compilerId.c_str()))
-      {
-      if(!cmSystemTools::CopyFileAlways(mod_upper, stamp))
-        {
-        std::cerr << "Error copying Fortran module from \""
-                  << mod_upper << "\" to \"" << stamp
-                  << "\".\n";
+  if (cmSystemTools::FileExists(mod_upper.c_str(), true)) {
+    if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
+                                        compilerId.c_str())) {
+      if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
+        std::cerr << "Error copying Fortran module from \"" << mod_upper
+                  << "\" to \"" << stamp << "\".\n";
         return false;
-        }
       }
-    return true;
     }
-  else if(cmSystemTools::FileExists(mod_lower.c_str(), true))
-    {
-    if(cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
-                                       compilerId.c_str()))
-      {
-      if(!cmSystemTools::CopyFileAlways(mod_lower, stamp))
-        {
-        std::cerr << "Error copying Fortran module from \""
-                  << mod_lower << "\" to \"" << stamp
-                  << "\".\n";
+    return true;
+  } else if (cmSystemTools::FileExists(mod_lower.c_str(), true)) {
+    if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
+                                        compilerId.c_str())) {
+      if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
+        std::cerr << "Error copying Fortran module from \"" << mod_lower
+                  << "\" to \"" << stamp << "\".\n";
         return false;
-        }
       }
-    return true;
     }
+    return true;
+  }
 
-  std::cerr << "Error copying Fortran module \"" << args[2]
-            << "\".  Tried \"" << mod_upper
-            << "\" and \"" << mod_lower << "\".\n";
+  std::cerr << "Error copying Fortran module \"" << args[2] << "\".  Tried \""
+            << mod_upper << "\" and \"" << mod_lower << "\".\n";
   return false;
 }
 
-//----------------------------------------------------------------------------
 // Helper function to look for a short sequence in a stream.  If this
 // is later used for longer sequences it should be re-written using an
 // efficient string search algorithm such as Boyer-Moore.
-static
-bool cmFortranStreamContainsSequence(std::istream& ifs,
-                                            const char* seq, int len)
+static bool cmFortranStreamContainsSequence(std::istream& ifs, const char* seq,
+                                            int len)
 {
   assert(len > 0);
 
   int cur = 0;
-  while(cur < len)
-    {
+  while (cur < len) {
     // Get the next character.
     int token = ifs.get();
-    if(!ifs)
-      {
+    if (!ifs) {
       return false;
-      }
+    }
 
     // Check the character.
-    if(token == static_cast<int>(seq[cur]))
-      {
+    if (token == static_cast<int>(seq[cur])) {
       ++cur;
-      }
-    else
-      {
+    } else {
       // Assume the sequence has no repeating subsequence.
       cur = 0;
-      }
     }
+  }
 
   // The entire sequence was matched.
   return true;
 }
 
-//----------------------------------------------------------------------------
 // Helper function to compare the remaining content in two streams.
-static bool cmFortranStreamsDiffer(std::istream& ifs1,
-                                          std::istream& ifs2)
+static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
 {
   // Compare the remaining content.
-  for(;;)
-    {
+  for (;;) {
     int ifs1_c = ifs1.get();
     int ifs2_c = ifs2.get();
-    if(!ifs1 && !ifs2)
-      {
+    if (!ifs1 && !ifs2) {
       // We have reached the end of both streams simultaneously.
       // The streams are identical.
       return false;
-      }
+    }
 
-    if(!ifs1 || !ifs2 || ifs1_c != ifs2_c)
-      {
+    if (!ifs1 || !ifs2 || ifs1_c != ifs2_c) {
       // We have reached the end of one stream before the other or
       // found differing content.  The streams are different.
       break;
-      }
     }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDependsFortran::ModulesDiffer(const char* modFile,
                                      const char* stampFile,
                                      const char* compilerId)
@@ -717,15 +621,13 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
     TODO ...
   */
 
-
   /* Compilers which do _not_ produce different mod content when the same
    * source is compiled twice
    *   -SunPro
    */
-  if(strcmp(compilerId, "SunPro") == 0)
-    {
+  if (strcmp(compilerId, "SunPro") == 0) {
     return cmSystemTools::FilesDiffer(modFile, stampFile);
-    }
+  }
 
 #if defined(_WIN32) || defined(__CYGWIN__)
   cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
@@ -734,11 +636,10 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
   cmsys::ifstream finModFile(modFile, std::ios::in);
   cmsys::ifstream finStampFile(stampFile, std::ios::in);
 #endif
-  if(!finModFile || !finStampFile)
-    {
+  if (!finModFile || !finStampFile) {
     // At least one of the files does not exist.  The modules differ.
     return true;
-    }
+  }
 
   /* Compilers which _do_ produce different mod content when the same
    * source is compiled twice
@@ -748,62 +649,54 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
    * Eat the stream content until all recompile only related changes
    * are left behind.
    */
-  if (strcmp(compilerId, "GNU") == 0 )
-    {
+  if (strcmp(compilerId, "GNU") == 0) {
     // GNU Fortran 4.9 and later compress .mod files with gzip
     // but also do not include a date so we can fall through to
     // compare them without skipping any prefix.
     unsigned char hdr[2];
-    bool okay = finModFile.read(reinterpret_cast<char*>(hdr), 2)? true:false;
+    bool okay =
+      finModFile.read(reinterpret_cast<char*>(hdr), 2) ? true : false;
     finModFile.seekg(0);
-    if(!(okay && hdr[0] == 0x1f && hdr[1] == 0x8b))
-      {
-      const char seq[1] = {'\n'};
+    if (!(okay && hdr[0] == 0x1f && hdr[1] == 0x8b)) {
+      const char seq[1] = { '\n' };
       const int seqlen = 1;
 
-      if(!cmFortranStreamContainsSequence(finModFile, seq, seqlen))
-        {
+      if (!cmFortranStreamContainsSequence(finModFile, seq, seqlen)) {
         // The module is of unexpected format.  Assume it is different.
         std::cerr << compilerId << " fortran module " << modFile
                   << " has unexpected format." << std::endl;
         return true;
-        }
+      }
 
-      if(!cmFortranStreamContainsSequence(finStampFile, seq, seqlen))
-        {
+      if (!cmFortranStreamContainsSequence(finStampFile, seq, seqlen)) {
         // The stamp must differ if the sequence is not contained.
         return true;
-        }
       }
     }
-  else if(strcmp(compilerId, "Intel") == 0)
-    {
-    const char seq[2] = {'\n', '\0'};
+  } else if (strcmp(compilerId, "Intel") == 0) {
+    const char seq[2] = { '\n', '\0' };
     const int seqlen = 2;
 
-    if(!cmFortranStreamContainsSequence(finModFile, seq, seqlen))
-      {
+    if (!cmFortranStreamContainsSequence(finModFile, seq, seqlen)) {
       // The module is of unexpected format.  Assume it is different.
       std::cerr << compilerId << " fortran module " << modFile
                 << " has unexpected format." << std::endl;
       return true;
-      }
+    }
 
-    if(!cmFortranStreamContainsSequence(finStampFile, seq, seqlen))
-      {
+    if (!cmFortranStreamContainsSequence(finStampFile, seq, seqlen)) {
       // The stamp must differ if the sequence is not contained.
       return true;
-      }
     }
+  }
 
   // Compare the remaining content.  If no compiler id matched above,
   // including the case none was given, this will compare the whole
   // content.
-  if(!cmFortranStreamsDiffer(finModFile, finStampFile))
-    {
+  if (!cmFortranStreamsDiffer(finModFile, finStampFile)) {
     return false;
-    }
+  }
 
-   // The modules are different.
-   return true;
+  // The modules are different.
+  return true;
 }
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index a8a4013..5ff0b6c 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -20,7 +20,7 @@ class cmFortranSourceInfo;
 /** \class cmDependsFortran
  * \brief Dependency scanner for Fortran object files.
  */
-class cmDependsFortran: public cmDepends
+class cmDependsFortran : public cmDepends
 {
 public:
   /** Checking instances need to know the build directory name and the
@@ -43,8 +43,8 @@ public:
 
   /** Determine if a mod file and the corresponding mod.stamp file
       are representing  different module information. */
-  static bool  ModulesDiffer(const char* modFile, const char* stampFile,
-                             const char* compilerId);
+  static bool ModulesDiffer(const char* modFile, const char* stampFile,
+                            const char* compilerId);
 
 protected:
   // Finalize the dependency information for the target.
@@ -59,15 +59,14 @@ protected:
   bool FindModule(std::string const& name, std::string& module);
 
   // Implement writing/checking methods required by superclass.
-  virtual bool WriteDependencies(
-    const std::set<std::string>& sources, const std::string& file,
-    std::ostream& makeDepends, std::ostream& internalDepends);
+  virtual bool WriteDependencies(const std::set<std::string>& sources,
+                                 const std::string& file,
+                                 std::ostream& makeDepends,
+                                 std::ostream& internalDepends);
 
   // Actually write the depenencies to the streams.
-  bool WriteDependenciesReal(const char *obj,
-                             cmFortranSourceInfo const& info,
-                             std::string const& mod_dir,
-                             const char* stamp_dir,
+  bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
+                             std::string const& mod_dir, const char* stamp_dir,
                              std::ostream& makeDepends,
                              std::ostream& internalDepends);
 
@@ -81,7 +80,7 @@ protected:
 
 private:
   cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
-  void operator=(cmDependsFortran const&); // Purposely not implemented.
+  void operator=(cmDependsFortran const&);   // Purposely not implemented.
 };
 
 #endif
diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx
index 949d465..4f5e2ae 100644
--- a/Source/cmDependsJava.cxx
+++ b/Source/cmDependsJava.cxx
@@ -14,32 +14,29 @@
 #include "cmDependsJavaParserHelper.h"
 #include "cmSystemTools.h"
 
-//----------------------------------------------------------------------------
 cmDependsJava::cmDependsJava()
 {
 }
 
-//----------------------------------------------------------------------------
 cmDependsJava::~cmDependsJava()
 {
 }
 
-//----------------------------------------------------------------------------
 bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
-    const std::string&, std::ostream&, std::ostream&)
+                                      const std::string&, std::ostream&,
+                                      std::ostream&)
 {
   // Make sure this is a scanning instance.
-  if(sources.empty() || sources.begin()->empty())
-    {
+  if (sources.empty() || sources.begin()->empty()) {
     cmSystemTools::Error("Cannot scan dependencies without an source file.");
     return false;
-    }
+  }
 
   return true;
 }
 
 bool cmDependsJava::CheckDependencies(std::istream&, const char*,
-                             std::map<std::string, DependencyVector >&)
+                                      std::map<std::string, DependencyVector>&)
 {
   return true;
 }
diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h
index 22af53f..44723fa 100644
--- a/Source/cmDependsJava.h
+++ b/Source/cmDependsJava.h
@@ -17,7 +17,7 @@
 /** \class cmDependsJava
  * \brief Dependency scanner for Java class files.
  */
-class cmDependsJava: public cmDepends
+class cmDependsJava : public cmDepends
 {
 public:
   /** Checking instances need to know the build directory name and the
@@ -29,15 +29,16 @@ public:
 
 protected:
   // Implement writing/checking methods required by superclass.
-  virtual bool WriteDependencies(
-    const std::set<std::string>& sources, const std::string& file,
-    std::ostream& makeDepends, std::ostream& internalDepends);
-  virtual bool CheckDependencies(std::istream& internalDepends,
-                                 const char* internalDependsFileName,
-                           std::map<std::string, DependencyVector>& validDeps);
+  virtual bool WriteDependencies(const std::set<std::string>& sources,
+                                 const std::string& file,
+                                 std::ostream& makeDepends,
+                                 std::ostream& internalDepends);
+  virtual bool CheckDependencies(
+    std::istream& internalDepends, const char* internalDependsFileName,
+    std::map<std::string, DependencyVector>& validDeps);
 
 private:
-  cmDependsJava(cmDependsJava const&); // Purposely not implemented.
+  cmDependsJava(cmDependsJava const&);  // Purposely not implemented.
   void operator=(cmDependsJava const&); // Purposely not implemented.
 };
 
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 3c02325..bd3ee4d 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -11,11 +11,11 @@
 ============================================================================*/
 #include "cmDependsJavaParserHelper.h"
 
-#include "cmSystemTools.h"
 #include "cmDependsJavaLexer.h"
+#include "cmSystemTools.h"
 #include <cmsys/FStream.hxx>
 
-int cmDependsJava_yyparse( yyscan_t yyscanner );
+int cmDependsJava_yyparse(yyscan_t yyscanner);
 
 cmDependsJavaParserHelper::cmDependsJavaParserHelper()
 {
@@ -29,185 +29,152 @@ cmDependsJavaParserHelper::cmDependsJavaParserHelper()
   this->ClassStack.push_back(tl);
 }
 
-
 cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
 {
   this->CleanupParser();
 }
 
-void cmDependsJavaParserHelper::CurrentClass
-::AddFileNamesForPrinting(std::vector<std::string> *files,
-                          const char* prefix, const char* sep)
+void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
+  std::vector<std::string>* files, const char* prefix, const char* sep)
 {
   std::string rname = "";
-  if ( prefix )
-    {
+  if (prefix) {
     rname += prefix;
     rname += sep;
-    }
+  }
   rname += this->Name;
   files->push_back(rname);
   std::vector<CurrentClass>::iterator it;
-  for ( it = this->NestedClasses->begin();
-    it != this->NestedClasses->end();
-    ++ it )
-    {
+  for (it = this->NestedClasses->begin(); it != this->NestedClasses->end();
+       ++it) {
     it->AddFileNamesForPrinting(files, rname.c_str(), sep);
-    }
+  }
 }
 
 void cmDependsJavaParserHelper::DeallocateParserType(char** pt)
 {
-  if (!pt)
-    {
+  if (!pt) {
     return;
-    }
-  if (!*pt)
-    {
+  }
+  if (!*pt) {
     return;
-    }
+  }
   *pt = 0;
-  this->UnionsAvailable --;
+  this->UnionsAvailable--;
 }
 
 void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
 {
-  if( ! sclass )
-    {
+  if (!sclass) {
     return;
-    }
+  }
   std::vector<std::string>::iterator it;
-  for ( it = this->ClassesFound.begin();
-    it != this->ClassesFound.end();
-    it ++ )
-    {
-    if ( *it == sclass )
-      {
+  for (it = this->ClassesFound.begin(); it != this->ClassesFound.end(); it++) {
+    if (*it == sclass) {
       return;
-      }
     }
+  }
   this->ClassesFound.push_back(sclass);
 }
 
 void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass)
 {
   std::vector<std::string>::iterator it;
-  for ( it = this->PackagesImport.begin();
-    it != this->PackagesImport.end();
-    it ++ )
-    {
-    if ( *it == sclass )
-      {
+  for (it = this->PackagesImport.begin(); it != this->PackagesImport.end();
+       it++) {
+    if (*it == sclass) {
       return;
-      }
     }
+  }
   this->PackagesImport.push_back(sclass);
 }
 
-void cmDependsJavaParserHelper::SafePrintMissing(const char* str,
-                                                 int line, int cnt)
+void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
+                                                 int cnt)
 {
-  if ( str )
-    {
+  if (str) {
     std::cout << line << " String " << cnt << " exists: ";
     unsigned int cc;
-    for ( cc = 0; cc < strlen(str); cc ++ )
-      {
+    for (cc = 0; cc < strlen(str); cc++) {
       unsigned char ch = str[cc];
-      if ( ch >= 32 && ch <= 126 )
-        {
+      if (ch >= 32 && ch <= 126) {
         std::cout << (char)ch;
-        }
-      else
-        {
+      } else {
         std::cout << "<" << (int)ch << ">";
         break;
-        }
       }
-    std::cout << "- " << strlen(str) << std::endl;
     }
+    std::cout << "- " << strlen(str) << std::endl;
+  }
 }
 void cmDependsJavaParserHelper::Print(const char* place, const char* str)
 {
-  if ( this->Verbose )
-    {
+  if (this->Verbose) {
     std::cout << "[" << place << "=" << str << "]" << std::endl;
-    }
+  }
 }
 
-void cmDependsJavaParserHelper::CombineUnions(char** out,
-                                              const char* in1, char** in2,
-                                              const char* sep)
+void cmDependsJavaParserHelper::CombineUnions(char** out, const char* in1,
+                                              char** in2, const char* sep)
 {
   size_t len = 1;
-  if ( in1 )
-    {
+  if (in1) {
     len += strlen(in1);
-    }
-  if ( *in2 )
-    {
+  }
+  if (*in2) {
     len += strlen(*in2);
-    }
-  if ( sep )
-    {
+  }
+  if (sep) {
     len += strlen(sep);
-    }
-  *out = new char [ len ];
+  }
+  *out = new char[len];
   *out[0] = 0;
-  if ( in1 )
-    {
+  if (in1) {
     strcat(*out, in1);
-    }
-  if ( sep )
-    {
+  }
+  if (sep) {
     strcat(*out, sep);
-    }
-  if ( *in2 )
-    {
+  }
+  if (*in2) {
     strcat(*out, *in2);
-    }
-  if ( *in2 )
-    {
+  }
+  if (*in2) {
     this->DeallocateParserType(in2);
-    }
-  this->UnionsAvailable ++;
+  }
+  this->UnionsAvailable++;
 }
 
-void cmDependsJavaParserHelper
-::CheckEmpty(int line, int cnt, cmDependsJavaParserHelper::ParserType* pt)
+void cmDependsJavaParserHelper::CheckEmpty(
+  int line, int cnt, cmDependsJavaParserHelper::ParserType* pt)
 {
   int cc;
   int kk = -cnt + 1;
-  for ( cc = 1; cc <= cnt; cc ++)
-    {
+  for (cc = 1; cc <= cnt; cc++) {
     cmDependsJavaParserHelper::ParserType* cpt = pt + kk;
     this->SafePrintMissing(cpt->str, line, cc);
-    kk ++;
-    }
+    kk++;
+  }
 }
 
-void cmDependsJavaParserHelper
-::PrepareElement(cmDependsJavaParserHelper::ParserType* me)
+void cmDependsJavaParserHelper::PrepareElement(
+  cmDependsJavaParserHelper::ParserType* me)
 {
   // Inititalize self
   me->str = 0;
 }
 
-void cmDependsJavaParserHelper
-::AllocateParserType(cmDependsJavaParserHelper::ParserType* pt,
-                     const char* str, int len)
+void cmDependsJavaParserHelper::AllocateParserType(
+  cmDependsJavaParserHelper::ParserType* pt, const char* str, int len)
 {
   pt->str = 0;
-  if ( len == 0 )
-    {
+  if (len == 0) {
     len = (int)strlen(str);
-    }
-  if ( len == 0 )
-    {
+  }
+  if (len == 0) {
     return;
-    }
-  this->UnionsAvailable ++;
-  pt->str = new char[ len + 1 ];
+  }
+  this->UnionsAvailable++;
+  pt->str = new char[len + 1];
   strncpy(pt->str, str, len);
   pt->str[len] = 0;
   this->Allocates.push_back(pt->str);
@@ -219,51 +186,43 @@ void cmDependsJavaParserHelper::StartClass(const char* cls)
   cl.Name = cls;
   this->ClassStack.push_back(cl);
 
-  this->CurrentDepth ++;
+  this->CurrentDepth++;
 }
 
 void cmDependsJavaParserHelper::EndClass()
 {
   CurrentClass* parent = 0;
   CurrentClass* current = 0;
-  if (!this->ClassStack.empty())
-    {
+  if (!this->ClassStack.empty()) {
     current = &(*(this->ClassStack.end() - 1));
-    if ( this->ClassStack.size() > 1 )
-      {
+    if (this->ClassStack.size() > 1) {
       parent = &(*(this->ClassStack.end() - 2));
-      }
     }
-  if ( current == 0 )
-    {
+  }
+  if (current == 0) {
     std::cerr << "Error when parsing. Current class is null" << std::endl;
     abort();
-    }
-  if ( parent == 0 )
-    {
+  }
+  if (parent == 0) {
     std::cerr << "Error when parsing. Parent class is null" << std::endl;
     abort();
-    }
-  this->CurrentDepth --;
+  }
+  this->CurrentDepth--;
   parent->NestedClasses->push_back(*current);
-  this->ClassStack.erase(this->ClassStack.end()-1, this->ClassStack.end());
+  this->ClassStack.erase(this->ClassStack.end() - 1, this->ClassStack.end());
 }
 
 void cmDependsJavaParserHelper::PrintClasses()
 {
-  if (this->ClassStack.empty())
-    {
+  if (this->ClassStack.empty()) {
     std::cerr << "Error when parsing. No classes on class stack" << std::endl;
     abort();
-    }
+  }
   std::vector<std::string> files = this->GetFilesProduced();
   std::vector<std::string>::iterator sit;
-  for ( sit = files.begin();
-    sit != files.end();
-    ++ sit )
-    {
+  for (sit = files.begin(); sit != files.end(); ++sit) {
     std::cout << "  " << *sit << ".class" << std::endl;
-    }
+  }
 }
 
 std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
@@ -271,77 +230,62 @@ std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
   std::vector<std::string> files;
   CurrentClass* toplevel = &(*(this->ClassStack.begin()));
   std::vector<CurrentClass>::iterator it;
-  for ( it = toplevel->NestedClasses->begin();
-    it != toplevel->NestedClasses->end();
-    ++ it )
-    {
+  for (it = toplevel->NestedClasses->begin();
+       it != toplevel->NestedClasses->end(); ++it) {
     it->AddFileNamesForPrinting(&files, 0, "$");
-    }
+  }
   return files;
 }
 
 int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
 {
-  if ( !str)
-    {
+  if (!str) {
     return 0;
-    }
+  }
   this->Verbose = verb;
   this->InputBuffer = str;
   this->InputBufferPos = 0;
   this->CurrentLine = 0;
 
-
   yyscan_t yyscanner;
   cmDependsJava_yylex_init(&yyscanner);
   cmDependsJava_yyset_extra(this, yyscanner);
   int res = cmDependsJava_yyparse(yyscanner);
   cmDependsJava_yylex_destroy(yyscanner);
-  if ( res != 0 )
-    {
+  if (res != 0) {
     std::cout << "JP_Parse returned: " << res << std::endl;
     return 0;
-    }
+  }
 
-  if ( verb )
-    {
-    if (!this->CurrentPackage.empty())
-      {
-      std::cout << "Current package is: " <<
-        this->CurrentPackage << std::endl;
-      }
+  if (verb) {
+    if (!this->CurrentPackage.empty()) {
+      std::cout << "Current package is: " << this->CurrentPackage << std::endl;
+    }
     std::cout << "Imports packages:";
-    if (!this->PackagesImport.empty())
-      {
+    if (!this->PackagesImport.empty()) {
       std::vector<std::string>::iterator it;
-      for ( it = this->PackagesImport.begin();
-        it != this->PackagesImport.end();
-        ++ it )
-        {
+      for (it = this->PackagesImport.begin(); it != this->PackagesImport.end();
+           ++it) {
         std::cout << " " << *it;
-        }
       }
+    }
     std::cout << std::endl;
     std::cout << "Depends on:";
-    if (!this->ClassesFound.empty())
-      {
+    if (!this->ClassesFound.empty()) {
       std::vector<std::string>::iterator it;
-      for ( it = this->ClassesFound.begin();
-        it != this->ClassesFound.end();
-        ++ it )
-        {
+      for (it = this->ClassesFound.begin(); it != this->ClassesFound.end();
+           ++it) {
         std::cout << " " << *it;
-        }
       }
+    }
     std::cout << std::endl;
     std::cout << "Generated files:" << std::endl;
     this->PrintClasses();
-    if ( this->UnionsAvailable != 0 )
-      {
-      std::cout << "There are still " <<
-        this->UnionsAvailable << " unions available" << std::endl;
-      }
+    if (this->UnionsAvailable != 0) {
+      std::cout << "There are still " << this->UnionsAvailable
+                << " unions available" << std::endl;
     }
+  }
   this->CleanupParser();
   return 1;
 }
@@ -349,82 +293,67 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
 void cmDependsJavaParserHelper::CleanupParser()
 {
   std::vector<char*>::iterator it;
-  for ( it = this->Allocates.begin();
-    it != this->Allocates.end();
-    ++ it )
-    {
-    delete [] *it;
-    }
-  this->Allocates.erase(this->Allocates.begin(),
-    this->Allocates.end());
+  for (it = this->Allocates.begin(); it != this->Allocates.end(); ++it) {
+    delete[] * it;
+  }
+  this->Allocates.erase(this->Allocates.begin(), this->Allocates.end());
 }
 
 int cmDependsJavaParserHelper::LexInput(char* buf, int maxlen)
 {
-  if ( maxlen < 1 )
-    {
+  if (maxlen < 1) {
     return 0;
-    }
-  if ( this->InputBufferPos < this->InputBuffer.size() )
-    {
-    buf[0] = this->InputBuffer[ this->InputBufferPos++ ];
-    if ( buf[0] == '\n' )
-      {
-      this->CurrentLine ++;
-      }
-    return(1);
-    }
-  else
-    {
+  }
+  if (this->InputBufferPos < this->InputBuffer.size()) {
+    buf[0] = this->InputBuffer[this->InputBufferPos++];
+    if (buf[0] == '\n') {
+      this->CurrentLine++;
+    }
+    return (1);
+  } else {
     buf[0] = '\n';
-    return( 0 );
-    }
+    return (0);
+  }
 }
 void cmDependsJavaParserHelper::Error(const char* str)
 {
   unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
-  fprintf(stderr, "JPError: %s (%lu / Line: %d)\n",
-          str, pos, this->CurrentLine);
+  fprintf(stderr, "JPError: %s (%lu / Line: %d)\n", str, pos,
+          this->CurrentLine);
   int cc;
   std::cerr << "String: [";
-  for ( cc = 0;
-        cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
-        cc ++ )
-    {
+  for (cc = 0;
+       cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
+       cc++) {
     std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
-    }
+  }
   std::cerr << "]" << std::endl;
 }
 
 void cmDependsJavaParserHelper::UpdateCombine(const char* str1,
                                               const char* str2)
 {
-  if ( this->CurrentCombine == "" && str1 != 0)
-    {
+  if (this->CurrentCombine == "" && str1 != 0) {
     this->CurrentCombine = str1;
-    }
+  }
   this->CurrentCombine += ".";
   this->CurrentCombine += str2;
 }
 
 int cmDependsJavaParserHelper::ParseFile(const char* file)
 {
-  if ( !cmSystemTools::FileExists(file))
-    {
+  if (!cmSystemTools::FileExists(file)) {
     return 0;
-    }
+  }
   cmsys::ifstream ifs(file);
-  if ( !ifs )
-    {
+  if (!ifs) {
     return 0;
-    }
+  }
 
   std::string fullfile = "";
   std::string line;
-  while ( cmSystemTools::GetLineFromStream(ifs, line) )
-    {
+  while (cmSystemTools::GetLineFromStream(ifs, line)) {
     fullfile += line + "\n";
-    }
+  }
   return this->ParseString(fullfile.c_str(), 0);
 }
-
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 5542018..a13d023 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -28,7 +28,8 @@
 class cmDependsJavaParserHelper
 {
 public:
-  typedef struct {
+  typedef struct
+  {
     char* str;
   } ParserType;
 
@@ -40,7 +41,7 @@ public:
 
   // For the lexer:
   void AllocateParserType(cmDependsJavaParserHelper::ParserType* pt,
-    const char* str, int len = 0);
+                          const char* str, int len = 0);
 
   int LexInput(char* buf, int maxlen);
   void Error(const char* str);
@@ -69,31 +70,18 @@ private:
   public:
     std::string Name;
     std::vector<CurrentClass>* NestedClasses;
-    CurrentClass()
-      {
-        this->NestedClasses = new std::vector<CurrentClass>;
-      }
-    ~CurrentClass()
-      {
-        delete this->NestedClasses;
-      }
+    CurrentClass() { this->NestedClasses = new std::vector<CurrentClass>; }
+    ~CurrentClass() { delete this->NestedClasses; }
     CurrentClass& operator=(CurrentClass const& c)
-      {
-        this->NestedClasses->clear();
-        this->Name = c.Name;
-        std::copy(
-          c.NestedClasses->begin(),
-          c.NestedClasses->end(),
-          std::back_inserter(
-            *this->NestedClasses)
-          );
-        return *this;
-      }
-    CurrentClass(CurrentClass const& c)
-      {
-        (*this) = c;
-      }
-    void AddFileNamesForPrinting(std::vector<std::string> *files,
+    {
+      this->NestedClasses->clear();
+      this->Name = c.Name;
+      std::copy(c.NestedClasses->begin(), c.NestedClasses->end(),
+                std::back_inserter(*this->NestedClasses));
+      return *this;
+    }
+    CurrentClass(CurrentClass const& c) { (*this) = c; }
+    void AddFileNamesForPrinting(std::vector<std::string>* files,
                                  const char* prefix, const char* sep);
   };
   std::string CurrentPackage;
@@ -117,12 +105,10 @@ private:
   void PrintClasses();
 
   void Print(const char* place, const char* str);
-  void CombineUnions(char** out, const char* in1, char** in2,
-                     const char* sep);
+  void CombineUnions(char** out, const char* in1, char** in2, const char* sep);
   void SafePrintMissing(const char* str, int line, int cnt);
 
   void CleanupParser();
 };
 
 #endif
-
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 4f34755..68a8488 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -11,103 +11,79 @@
 ============================================================================*/
 #include "cmDocumentation.h"
 
+#include "cmAlgorithms.h"
+#include "cmRST.h"
 #include "cmSystemTools.h"
 #include "cmVersion.h"
-#include "cmRST.h"
-#include "cmAlgorithms.h"
 
 #include <cmsys/Directory.hxx>
-#include <cmsys/Glob.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
 
 #include <ctype.h>
 
 #include <algorithm>
 
-//----------------------------------------------------------------------------
-static const char *cmDocumentationStandardOptions[][2] =
-{
-  {"--help,-help,-usage,-h,-H,/?",
-   "Print usage information and exit."},
-  {"--version,-version,/V [<f>]",
-   "Print version number and exit."},
-  {"--help-full [<f>]",
-   "Print all help manuals and exit."},
-  {"--help-manual <man> [<f>]",
-   "Print one help manual and exit."},
-  {"--help-manual-list [<f>]",
-   "List help manuals available and exit."},
-  {"--help-command <cmd> [<f>]",
-   "Print help for one command and exit."},
-  {"--help-command-list [<f>]",
-   "List commands with help available and exit."},
-  {"--help-commands [<f>]",
-   "Print cmake-commands manual and exit."},
-  {"--help-module <mod> [<f>]",
-   "Print help for one module and exit."},
-  {"--help-module-list [<f>]",
-   "List modules with help available and exit."},
-  {"--help-modules [<f>]",
-   "Print cmake-modules manual and exit."},
-  {"--help-policy <cmp> [<f>]",
-   "Print help for one policy and exit."},
-  {"--help-policy-list [<f>]",
-   "List policies with help available and exit."},
-  {"--help-policies [<f>]",
-   "Print cmake-policies manual and exit."},
-  {"--help-property <prop> [<f>]",
-   "Print help for one property and exit."},
-  {"--help-property-list [<f>]",
-   "List properties with help available and exit."},
-  {"--help-properties [<f>]",
-   "Print cmake-properties manual and exit."},
-  {"--help-variable var [<f>]",
-   "Print help for one variable and exit."},
-  {"--help-variable-list [<f>]",
-   "List variables with help available and exit."},
-  {"--help-variables [<f>]",
-   "Print cmake-variables manual and exit."},
-  {0,0}
+static const char* cmDocumentationStandardOptions[][2] = {
+  { "--help,-help,-usage,-h,-H,/?", "Print usage information and exit." },
+  { "--version,-version,/V [<f>]", "Print version number and exit." },
+  { "--help-full [<f>]", "Print all help manuals and exit." },
+  { "--help-manual <man> [<f>]", "Print one help manual and exit." },
+  { "--help-manual-list [<f>]", "List help manuals available and exit." },
+  { "--help-command <cmd> [<f>]", "Print help for one command and exit." },
+  { "--help-command-list [<f>]",
+    "List commands with help available and exit." },
+  { "--help-commands [<f>]", "Print cmake-commands manual and exit." },
+  { "--help-module <mod> [<f>]", "Print help for one module and exit." },
+  { "--help-module-list [<f>]", "List modules with help available and exit." },
+  { "--help-modules [<f>]", "Print cmake-modules manual and exit." },
+  { "--help-policy <cmp> [<f>]", "Print help for one policy and exit." },
+  { "--help-policy-list [<f>]",
+    "List policies with help available and exit." },
+  { "--help-policies [<f>]", "Print cmake-policies manual and exit." },
+  { "--help-property <prop> [<f>]", "Print help for one property and exit." },
+  { "--help-property-list [<f>]",
+    "List properties with help available and exit." },
+  { "--help-properties [<f>]", "Print cmake-properties manual and exit." },
+  { "--help-variable var [<f>]", "Print help for one variable and exit." },
+  { "--help-variable-list [<f>]",
+    "List variables with help available and exit." },
+  { "--help-variables [<f>]", "Print cmake-variables manual and exit." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char *cmDocumentationGeneratorsHeader[][2] =
-{
-  {0,
-   "The following generators are available on this platform:"},
-  {0,0}
+static const char* cmDocumentationGeneratorsHeader[][2] = {
+  { 0, "The following generators are available on this platform:" },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
 cmDocumentation::cmDocumentation()
 {
   this->addCommonStandardDocSections();
   this->ShowGenerators = true;
 }
 
-//----------------------------------------------------------------------------
 cmDocumentation::~cmDocumentation()
 {
   cmDeleteAll(this->AllSections);
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintVersion(std::ostream& os)
 {
+  /* clang-format off */
   os <<
     this->GetNameString() <<
     " version " << cmVersion::GetCMakeVersion() << "\n"
     "\n"
     "CMake suite maintained and supported by Kitware (kitware.com/cmake).\n"
     ;
+  /* clang-format on */
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
 {
-  switch (ht)
-    {
+  switch (ht) {
     case cmDocumentation::Usage:
       return this->PrintUsage(os);
     case cmDocumentation::Help:
@@ -144,529 +120,411 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
       return this->PrintVersion(os);
     case cmDocumentation::OldCustomModules:
       return this->PrintOldCustomModules(os);
-    default: return false;
-    }
+    default:
+      return false;
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
 {
   int count = 0;
   bool result = true;
 
   // Loop over requested documentation types.
-  for(std::vector<RequestedHelpItem>::const_iterator
-      i = this->RequestedHelpItems.begin();
-      i != this->RequestedHelpItems.end();
-      ++i)
-    {
+  for (std::vector<RequestedHelpItem>::const_iterator i =
+         this->RequestedHelpItems.begin();
+       i != this->RequestedHelpItems.end(); ++i) {
     this->CurrentArgument = i->Argument;
     // If a file name was given, use it.  Otherwise, default to the
     // given stream.
     cmsys::ofstream* fout = 0;
     std::ostream* s = &os;
-    if(!i->Filename.empty())
-      {
+    if (!i->Filename.empty()) {
       fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out);
-      if(fout)
-        {
+      if (fout) {
         s = fout;
-        }
-      else
-        {
+      } else {
         result = false;
-        }
       }
-    else if(++count > 1)
-      {
+    } else if (++count > 1) {
       os << "\n\n";
-      }
+    }
 
     // Print this documentation type to the stream.
-    if(!this->PrintDocumentation(i->HelpType, *s) || !*s)
-      {
+    if (!this->PrintDocumentation(i->HelpType, *s) || !*s) {
       result = false;
-      }
+    }
 
     // Close the file if we wrote one.
-    if(fout)
-      {
+    if (fout) {
       delete fout;
-      }
     }
+  }
   return result;
 }
 
-#define GET_OPT_ARGUMENT(target)                      \
-     if((i+1 < argc) && !this->IsOption(argv[i+1]))   \
-        {                                             \
-        target = argv[i+1];                           \
-        i = i+1;                                      \
-        };
-
+#define GET_OPT_ARGUMENT(target)                                              \
+  if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) {                       \
+    target = argv[i + 1];                                                     \
+    i = i + 1;                                                                \
+  };
 
 void cmDocumentation::WarnFormFromFilename(
   cmDocumentation::RequestedHelpItem& request, bool& result)
 {
   std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename);
   ext = cmSystemTools::UpperCase(ext);
-  if ((ext == ".HTM") || (ext == ".HTML"))
-    {
+  if ((ext == ".HTM") || (ext == ".HTML")) {
     request.HelpType = cmDocumentation::None;
     result = true;
     cmSystemTools::Message("Warning: HTML help format no longer supported");
-    }
-  else if (ext == ".DOCBOOK")
-    {
+  } else if (ext == ".DOCBOOK") {
     request.HelpType = cmDocumentation::None;
     result = true;
     cmSystemTools::Message("Warning: Docbook help format no longer supported");
-    }
+  }
   // ".1" to ".9" should be manpages
-  else if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
-    {
+  else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
     request.HelpType = cmDocumentation::None;
     result = true;
     cmSystemTools::Message("Warning: Man help format no longer supported");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmDocumentation::addCommonStandardDocSections()
 {
-    cmDocumentationSection *sec;
+  cmDocumentationSection* sec;
 
-    sec = new cmDocumentationSection("Options","OPTIONS");
-    sec->Append(cmDocumentationStandardOptions);
-    this->AllSections["Options"] = sec;
+  sec = new cmDocumentationSection("Options", "OPTIONS");
+  sec->Append(cmDocumentationStandardOptions);
+  this->AllSections["Options"] = sec;
 }
 
-//----------------------------------------------------------------------------
 void cmDocumentation::addCMakeStandardDocSections()
 {
-    cmDocumentationSection *sec;
+  cmDocumentationSection* sec;
 
-    sec = new cmDocumentationSection("Generators","GENERATORS");
-    sec->Append(cmDocumentationGeneratorsHeader);
-    this->AllSections["Generators"] = sec;
+  sec = new cmDocumentationSection("Generators", "GENERATORS");
+  sec->Append(cmDocumentationGeneratorsHeader);
+  this->AllSections["Generators"] = sec;
 }
 
-//----------------------------------------------------------------------------
 void cmDocumentation::addCTestStandardDocSections()
 {
-    // This is currently done for backward compatibility reason
-    // We may suppress some of these.
-    addCMakeStandardDocSections();
+  // This is currently done for backward compatibility reason
+  // We may suppress some of these.
+  addCMakeStandardDocSections();
 }
 
-//----------------------------------------------------------------------------
 void cmDocumentation::addCPackStandardDocSections()
 {
-    cmDocumentationSection *sec;
+  cmDocumentationSection* sec;
 
-    sec = new cmDocumentationSection("Generators","GENERATORS");
-    sec->Append(cmDocumentationGeneratorsHeader);
-    this->AllSections["Generators"] = sec;
+  sec = new cmDocumentationSection("Generators", "GENERATORS");
+  sec->Append(cmDocumentationGeneratorsHeader);
+  this->AllSections["Generators"] = sec;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
                                    const char* exitOpt)
 {
   // Providing zero arguments gives usage information.
-  if(argc == 1)
-    {
+  if (argc == 1) {
     RequestedHelpItem help;
     help.HelpType = cmDocumentation::Usage;
     this->RequestedHelpItems.push_back(help);
     return true;
-    }
+  }
 
   // Search for supported help options.
 
   bool result = false;
-  for(int i=1; i < argc; ++i)
-    {
-    if(exitOpt && strcmp(argv[i], exitOpt) == 0)
-      {
+  for (int i = 1; i < argc; ++i) {
+    if (exitOpt && strcmp(argv[i], exitOpt) == 0) {
       return result;
-      }
+    }
     RequestedHelpItem help;
     // Check if this is a supported help option.
-    if((strcmp(argv[i], "-help") == 0) ||
-       (strcmp(argv[i], "--help") == 0) ||
-       (strcmp(argv[i], "/?") == 0) ||
-       (strcmp(argv[i], "-usage") == 0) ||
-       (strcmp(argv[i], "-h") == 0) ||
-       (strcmp(argv[i], "-H") == 0))
-      {
+    if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0) ||
+        (strcmp(argv[i], "/?") == 0) || (strcmp(argv[i], "-usage") == 0) ||
+        (strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-H") == 0)) {
       help.HelpType = cmDocumentation::Help;
       GET_OPT_ARGUMENT(help.Argument);
       help.Argument = cmSystemTools::LowerCase(help.Argument);
       // special case for single command
-      if (!help.Argument.empty())
-        {
+      if (!help.Argument.empty()) {
         help.HelpType = cmDocumentation::OneCommand;
-        }
       }
-    else if(strcmp(argv[i], "--help-properties") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-properties") == 0) {
       help.HelpType = cmDocumentation::OneManual;
       help.Argument = "cmake-properties.7";
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-policies") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-policies") == 0) {
       help.HelpType = cmDocumentation::OneManual;
       help.Argument = "cmake-policies.7";
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-variables") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-variables") == 0) {
       help.HelpType = cmDocumentation::OneManual;
       help.Argument = "cmake-variables.7";
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-modules") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-modules") == 0) {
       help.HelpType = cmDocumentation::OneManual;
       help.Argument = "cmake-modules.7";
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-custom-modules") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-custom-modules") == 0) {
       GET_OPT_ARGUMENT(help.Filename);
       cmSystemTools::Message(
         "Warning: --help-custom-modules no longer supported");
-      if(help.Filename.empty())
-        {
+      if (help.Filename.empty()) {
         return true;
-        }
+      }
       // Avoid breaking old project builds completely by at least generating
       // the output file.  Abuse help.Argument to give the file name to
       // PrintOldCustomModules without disrupting our internal API.
       help.HelpType = cmDocumentation::OldCustomModules;
       help.Argument = cmSystemTools::GetFilenameName(help.Filename);
-      }
-    else if(strcmp(argv[i], "--help-commands") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-commands") == 0) {
       help.HelpType = cmDocumentation::OneManual;
       help.Argument = "cmake-commands.7";
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-compatcommands") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-compatcommands") == 0) {
       GET_OPT_ARGUMENT(help.Filename);
       cmSystemTools::Message(
         "Warning: --help-compatcommands no longer supported");
       return true;
-      }
-    else if(strcmp(argv[i], "--help-full") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-full") == 0) {
       help.HelpType = cmDocumentation::Full;
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-html") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-html") == 0) {
       GET_OPT_ARGUMENT(help.Filename);
       cmSystemTools::Message("Warning: --help-html no longer supported");
       return true;
-      }
-    else if(strcmp(argv[i], "--help-man") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-man") == 0) {
       GET_OPT_ARGUMENT(help.Filename);
       cmSystemTools::Message("Warning: --help-man no longer supported");
       return true;
-      }
-    else if(strcmp(argv[i], "--help-command") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-command") == 0) {
       help.HelpType = cmDocumentation::OneCommand;
       GET_OPT_ARGUMENT(help.Argument);
       GET_OPT_ARGUMENT(help.Filename);
       help.Argument = cmSystemTools::LowerCase(help.Argument);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-module") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-module") == 0) {
       help.HelpType = cmDocumentation::OneModule;
       GET_OPT_ARGUMENT(help.Argument);
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-property") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-property") == 0) {
       help.HelpType = cmDocumentation::OneProperty;
       GET_OPT_ARGUMENT(help.Argument);
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-policy") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-policy") == 0) {
       help.HelpType = cmDocumentation::OnePolicy;
       GET_OPT_ARGUMENT(help.Argument);
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-variable") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-variable") == 0) {
       help.HelpType = cmDocumentation::OneVariable;
       GET_OPT_ARGUMENT(help.Argument);
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-manual") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-manual") == 0) {
       help.HelpType = cmDocumentation::OneManual;
       GET_OPT_ARGUMENT(help.Argument);
       GET_OPT_ARGUMENT(help.Filename);
       this->WarnFormFromFilename(help, result);
-      }
-    else if(strcmp(argv[i], "--help-command-list") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-command-list") == 0) {
       help.HelpType = cmDocumentation::ListCommands;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    else if(strcmp(argv[i], "--help-module-list") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-module-list") == 0) {
       help.HelpType = cmDocumentation::ListModules;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    else if(strcmp(argv[i], "--help-property-list") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-property-list") == 0) {
       help.HelpType = cmDocumentation::ListProperties;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    else if(strcmp(argv[i], "--help-variable-list") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-variable-list") == 0) {
       help.HelpType = cmDocumentation::ListVariables;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    else if(strcmp(argv[i], "--help-policy-list") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-policy-list") == 0) {
       help.HelpType = cmDocumentation::ListPolicies;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    else if(strcmp(argv[i], "--help-manual-list") == 0)
-      {
+    } else if (strcmp(argv[i], "--help-manual-list") == 0) {
       help.HelpType = cmDocumentation::ListManuals;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    else if(strcmp(argv[i], "--copyright") == 0)
-      {
+    } else if (strcmp(argv[i], "--copyright") == 0) {
       GET_OPT_ARGUMENT(help.Filename);
       cmSystemTools::Message("Warning: --copyright no longer supported");
       return true;
-      }
-    else if((strcmp(argv[i], "--version") == 0) ||
-            (strcmp(argv[i], "-version") == 0) ||
-            (strcmp(argv[i], "/V") == 0))
-      {
+    } else if ((strcmp(argv[i], "--version") == 0) ||
+               (strcmp(argv[i], "-version") == 0) ||
+               (strcmp(argv[i], "/V") == 0)) {
       help.HelpType = cmDocumentation::Version;
       GET_OPT_ARGUMENT(help.Filename);
-      }
-    if(help.HelpType != None)
-      {
+    }
+    if (help.HelpType != None) {
       // This is a help option.  See if there is a file name given.
       result = true;
       this->RequestedHelpItems.push_back(help);
-      }
     }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 void cmDocumentation::SetName(const std::string& name)
 {
   this->NameString = name;
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::SetSection(const char *name,
-                                 cmDocumentationSection *section)
+void cmDocumentation::SetSection(const char* name,
+                                 cmDocumentationSection* section)
 {
-  if (this->AllSections.find(name) != this->AllSections.end())
-    {
+  if (this->AllSections.find(name) != this->AllSections.end()) {
     delete this->AllSections[name];
-    }
+  }
   this->AllSections[name] = section;
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::SetSection(const char *name,
-                                 std::vector<cmDocumentationEntry> &docs)
+void cmDocumentation::SetSection(const char* name,
+                                 std::vector<cmDocumentationEntry>& docs)
 {
-  cmDocumentationSection *sec =
-    new cmDocumentationSection(name,
-                               cmSystemTools::UpperCase(name).c_str());
+  cmDocumentationSection* sec =
+    new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
   sec->Append(docs);
-  this->SetSection(name,sec);
+  this->SetSection(name, sec);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::SetSection(const char *name,
-                                 const char *docs[][2])
+void cmDocumentation::SetSection(const char* name, const char* docs[][2])
 {
-  cmDocumentationSection *sec =
-    new cmDocumentationSection(name,
-                               cmSystemTools::UpperCase(name).c_str());
+  cmDocumentationSection* sec =
+    new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
   sec->Append(docs);
-  this->SetSection(name,sec);
+  this->SetSection(name, sec);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation
-::SetSections(std::map<std::string,cmDocumentationSection *> &sections)
+void cmDocumentation::SetSections(
+  std::map<std::string, cmDocumentationSection*>& sections)
 {
-  for (std::map<std::string,cmDocumentationSection *>::const_iterator
-         it = sections.begin(); it != sections.end(); ++it)
-    {
-    this->SetSection(it->first.c_str(),it->second);
-    }
+  for (std::map<std::string, cmDocumentationSection*>::const_iterator it =
+         sections.begin();
+       it != sections.end(); ++it) {
+    this->SetSection(it->first.c_str(), it->second);
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::PrependSection(const char *name,
-                                     const char *docs[][2])
+void cmDocumentation::PrependSection(const char* name, const char* docs[][2])
 {
-  cmDocumentationSection *sec = 0;
-  if (this->AllSections.find(name) == this->AllSections.end())
-    {
-    sec = new cmDocumentationSection
-      (name, cmSystemTools::UpperCase(name).c_str());
-    this->SetSection(name,sec);
-    }
-  else
-    {
+  cmDocumentationSection* sec = 0;
+  if (this->AllSections.find(name) == this->AllSections.end()) {
+    sec =
+      new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+    this->SetSection(name, sec);
+  } else {
     sec = this->AllSections[name];
-    }
+  }
   sec->Prepend(docs);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::PrependSection(const char *name,
-                                     std::vector<cmDocumentationEntry> &docs)
+void cmDocumentation::PrependSection(const char* name,
+                                     std::vector<cmDocumentationEntry>& docs)
 {
-  cmDocumentationSection *sec = 0;
-  if (this->AllSections.find(name) == this->AllSections.end())
-    {
-    sec = new cmDocumentationSection
-      (name, cmSystemTools::UpperCase(name).c_str());
-    this->SetSection(name,sec);
-    }
-  else
-    {
+  cmDocumentationSection* sec = 0;
+  if (this->AllSections.find(name) == this->AllSections.end()) {
+    sec =
+      new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+    this->SetSection(name, sec);
+  } else {
     sec = this->AllSections[name];
-    }
+  }
   sec->Prepend(docs);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::AppendSection(const char *name,
-                                    const char *docs[][2])
+void cmDocumentation::AppendSection(const char* name, const char* docs[][2])
 {
-  cmDocumentationSection *sec = 0;
-  if (this->AllSections.find(name) == this->AllSections.end())
-    {
-    sec = new cmDocumentationSection
-      (name, cmSystemTools::UpperCase(name).c_str());
-    this->SetSection(name,sec);
-    }
-  else
-    {
+  cmDocumentationSection* sec = 0;
+  if (this->AllSections.find(name) == this->AllSections.end()) {
+    sec =
+      new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+    this->SetSection(name, sec);
+  } else {
     sec = this->AllSections[name];
-    }
+  }
   sec->Append(docs);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::AppendSection(const char *name,
-                                    std::vector<cmDocumentationEntry> &docs)
+void cmDocumentation::AppendSection(const char* name,
+                                    std::vector<cmDocumentationEntry>& docs)
 {
-  cmDocumentationSection *sec = 0;
-  if (this->AllSections.find(name) == this->AllSections.end())
-    {
-    sec = new cmDocumentationSection
-      (name, cmSystemTools::UpperCase(name).c_str());
-    this->SetSection(name,sec);
-    }
-  else
-    {
+  cmDocumentationSection* sec = 0;
+  if (this->AllSections.find(name) == this->AllSections.end()) {
+    sec =
+      new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
+    this->SetSection(name, sec);
+  } else {
     sec = this->AllSections[name];
-    }
+  }
   sec->Append(docs);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::AppendSection(const char *name,
-                                    cmDocumentationEntry &docs)
+void cmDocumentation::AppendSection(const char* name,
+                                    cmDocumentationEntry& docs)
 {
 
   std::vector<cmDocumentationEntry> docsVec;
   docsVec.push_back(docs);
-  this->AppendSection(name,docsVec);
+  this->AppendSection(name, docsVec);
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::PrependSection(const char *name,
-                                     cmDocumentationEntry &docs)
+void cmDocumentation::PrependSection(const char* name,
+                                     cmDocumentationEntry& docs)
 {
 
   std::vector<cmDocumentationEntry> docsVec;
   docsVec.push_back(docs);
-  this->PrependSection(name,docsVec);
+  this->PrependSection(name, docsVec);
 }
 
-//----------------------------------------------------------------------------
 void cmDocumentation::GlobHelp(std::vector<std::string>& files,
                                std::string const& pattern)
 {
   cmsys::Glob gl;
   std::string findExpr =
     cmSystemTools::GetCMakeRoot() + "/Help/" + pattern + ".rst";
-  if(gl.FindFiles(findExpr))
-    {
+  if (gl.FindFiles(findExpr)) {
     files = gl.GetFiles();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentation::PrintNames(std::ostream& os,
-                                 std::string const& pattern)
+void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
 {
   std::vector<std::string> files;
   this->GlobHelp(files, pattern);
   std::vector<std::string> names;
   for (std::vector<std::string>::const_iterator i = files.begin();
-       i != files.end(); ++i)
-    {
+       i != files.end(); ++i) {
     std::string line;
     cmsys::ifstream fin(i->c_str());
-    while(fin && cmSystemTools::GetLineFromStream(fin, line))
-      {
-      if(!line.empty() && (isalnum(line[0]) || line[0] == '<'))
-        {
+    while (fin && cmSystemTools::GetLineFromStream(fin, line)) {
+      if (!line.empty() && (isalnum(line[0]) || line[0] == '<')) {
         names.push_back(line);
         break;
-        }
       }
     }
+  }
   std::sort(names.begin(), names.end());
-  for (std::vector<std::string>::iterator i = names.begin();
-       i != names.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = names.begin(); i != names.end();
+       ++i) {
     os << *i << "\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool cmDocumentation::PrintFiles(std::ostream& os,
-                                 std::string const& pattern)
+bool cmDocumentation::PrintFiles(std::ostream& os, std::string const& pattern)
 {
   bool found = false;
   std::vector<std::string> files;
@@ -674,34 +532,28 @@ bool cmDocumentation::PrintFiles(std::ostream& os,
   std::sort(files.begin(), files.end());
   cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help");
   for (std::vector<std::string>::const_iterator i = files.begin();
-       i != files.end(); ++i)
-    {
+       i != files.end(); ++i) {
     found = r.ProcessFile(*i) || found;
-    }
+  }
   return found;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpFull(std::ostream& os)
 {
   return this->PrintFiles(os, "index");
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
 {
   std::string mname = this->CurrentArgument;
   std::string::size_type mlen = mname.length();
-  if(mlen > 3 && mname[mlen-3] == '(' &&
-                 mname[mlen-1] == ')')
-    {
-    mname = mname.substr(0, mlen-3) + "." + mname[mlen-2];
-    }
-  if(this->PrintFiles(os, "manual/" + mname) ||
-     this->PrintFiles(os, "manual/" + mname + ".[0-9]"))
-    {
+  if (mlen > 3 && mname[mlen - 3] == '(' && mname[mlen - 1] == ')') {
+    mname = mname.substr(0, mlen - 3) + "." + mname[mlen - 2];
+  }
+  if (this->PrintFiles(os, "manual/" + mname) ||
+      this->PrintFiles(os, "manual/" + mname + ".[0-9]")) {
     return true;
-    }
+  }
   // Argument was not a manual.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-manual is not an available manual.  "
@@ -709,21 +561,18 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListManuals(std::ostream& os)
 {
   this->PrintNames(os, "manual/*");
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpOneCommand(std::ostream& os)
 {
   std::string cname = cmSystemTools::LowerCase(this->CurrentArgument);
-  if(this->PrintFiles(os, "command/" + cname))
-    {
+  if (this->PrintFiles(os, "command/" + cname)) {
     return true;
-    }
+  }
   // Argument was not a command.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-command is not a CMake command.  "
@@ -731,56 +580,48 @@ bool cmDocumentation::PrintHelpOneCommand(std::ostream& os)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListCommands(std::ostream& os)
 {
   this->PrintNames(os, "command/*");
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpOneModule(std::ostream& os)
 {
   std::string mname = this->CurrentArgument;
-  if(this->PrintFiles(os, "module/" + mname))
-    {
+  if (this->PrintFiles(os, "module/" + mname)) {
     return true;
-    }
+  }
   // Argument was not a module.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-module is not a CMake module.\n";
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListModules(std::ostream& os)
 {
   std::vector<std::string> files;
   this->GlobHelp(files, "module/*");
   std::vector<std::string> modules;
   for (std::vector<std::string>::iterator fi = files.begin();
-       fi != files.end(); ++fi)
-    {
+       fi != files.end(); ++fi) {
     std::string module = cmSystemTools::GetFilenameName(*fi);
-    modules.push_back(module.substr(0, module.size()-4));
-    }
+    modules.push_back(module.substr(0, module.size() - 4));
+  }
   std::sort(modules.begin(), modules.end());
   for (std::vector<std::string>::iterator i = modules.begin();
-       i != modules.end(); ++i)
-    {
+       i != modules.end(); ++i) {
     os << *i << "\n";
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpOneProperty(std::ostream& os)
 {
   std::string pname = cmSystemTools::HelpFileName(this->CurrentArgument);
-  if(this->PrintFiles(os, "prop_*/" + pname))
-    {
+  if (this->PrintFiles(os, "prop_*/" + pname)) {
     return true;
-    }
+  }
   // Argument was not a property.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-property is not a CMake property.  "
@@ -788,22 +629,19 @@ bool cmDocumentation::PrintHelpOneProperty(std::ostream& os)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListProperties(std::ostream& os)
 {
   this->PrintNames(os, "prop_*/*");
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os)
 {
   std::string pname = this->CurrentArgument;
   std::vector<std::string> files;
-  if(this->PrintFiles(os, "policy/" + pname))
-    {
+  if (this->PrintFiles(os, "policy/" + pname)) {
     return true;
-    }
+  }
 
   // Argument was not a policy.  Complain.
   os << "Argument \"" << this->CurrentArgument
@@ -811,34 +649,29 @@ bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListPolicies(std::ostream& os)
 {
   this->PrintNames(os, "policy/*");
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListGenerators(std::ostream& os)
 {
-  std::map<std::string,cmDocumentationSection*>::iterator si;
+  std::map<std::string, cmDocumentationSection*>::iterator si;
   si = this->AllSections.find("Generators");
-  if(si != this->AllSections.end())
-    {
+  if (si != this->AllSections.end()) {
     this->Formatter.SetIndent("  ");
     this->Formatter.PrintSection(os, *si->second);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpOneVariable(std::ostream& os)
 {
   std::string vname = cmSystemTools::HelpFileName(this->CurrentArgument);
-  if(this->PrintFiles(os, "variable/" + vname))
-    {
+  if (this->PrintFiles(os, "variable/" + vname)) {
     return true;
-    }
+  }
   // Argument was not a variable.  Complain.
   os << "Argument \"" << this->CurrentArgument
      << "\" to --help-variable is not a defined variable.  "
@@ -846,71 +679,57 @@ bool cmDocumentation::PrintHelpOneVariable(std::ostream& os)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
 {
   this->PrintNames(os, "variable/*");
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintUsage(std::ostream& os)
 {
-  std::map<std::string,cmDocumentationSection*>::iterator si;
+  std::map<std::string, cmDocumentationSection*>::iterator si;
   si = this->AllSections.find("Usage");
-  if(si != this->AllSections.end())
-    {
+  if (si != this->AllSections.end()) {
     this->Formatter.PrintSection(os, *si->second);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintHelp(std::ostream& os)
 {
-  std::map<std::string,cmDocumentationSection*>::iterator si;
+  std::map<std::string, cmDocumentationSection*>::iterator si;
   si = this->AllSections.find("Usage");
-  if(si != this->AllSections.end())
-    {
+  if (si != this->AllSections.end()) {
     this->Formatter.PrintSection(os, *si->second);
-    }
+  }
   si = this->AllSections.find("Options");
-  if(si != this->AllSections.end())
-    {
+  if (si != this->AllSections.end()) {
     this->Formatter.PrintSection(os, *si->second);
-    }
-  if(this->ShowGenerators)
-    {
+  }
+  if (this->ShowGenerators) {
     si = this->AllSections.find("Generators");
-    if(si != this->AllSections.end())
-      {
+    if (si != this->AllSections.end()) {
       this->Formatter.PrintSection(os, *si->second);
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 const char* cmDocumentation::GetNameString() const
 {
-  if(!this->NameString.empty())
-    {
+  if (!this->NameString.empty()) {
     return this->NameString.c_str();
-    }
-  else
-    {
+  } else {
     return "CMake";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::IsOption(const char* arg) const
 {
   return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) ||
           (strcmp(arg, "/?") == 0));
 }
 
-//----------------------------------------------------------------------------
 bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
 {
   // CheckOptions abuses the Argument field to give us the file name.
@@ -926,15 +745,13 @@ bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
     "CMake versions 3.0 and above use other means to generate their module\n"
     "help pages so this functionality is no longer available to be exposed.\n"
     "\n"
-    "This file was generated as a placeholder to provide this information.\n"
-    ;
-  if((ext == ".HTM") || (ext == ".HTML"))
-    {
+    "This file was generated as a placeholder to provide this information.\n";
+  if ((ext == ".HTM") || (ext == ".HTML")) {
     os << "<html><title>" << name << "</title><body>\n"
-       << summary << "<p/>\n" << detail << "</body></html>\n";
-    }
-  else if((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
-    {
+       << summary << "<p/>\n"
+       << detail << "</body></html>\n";
+  } else if ((ext.length() == 2) && (ext[1] >= '1') && (ext[1] <= '9')) {
+    /* clang-format off */
     os <<
       ".TH " << name << " " << ext[1] << " \"" <<
       cmSystemTools::GetCurrentDateTime("%B %d, %Y") <<
@@ -947,10 +764,9 @@ bool cmDocumentation::PrintOldCustomModules(std::ostream& os)
       ".PP\n" <<
       detail
       ;
-    }
-  else
-    {
+    /* clang-format on */
+  } else {
     os << name << "\n\n" << summary << "\n" << detail;
-    }
+  }
   return true;
 }
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index b6c5fde..dd99ca8 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -13,17 +13,17 @@
 #define _cmDocumentation_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmDocumentationFormatter.h"
 #include "cmDocumentationSection.h"
 #include "cmake.h"
 
-namespace cmsys
-{
-  class Directory;
+namespace cmsys {
+class Directory;
 }
 
 /** Class to generate documentation.  */
-class cmDocumentation: public cmDocumentationEnums
+class cmDocumentation : public cmDocumentationEnums
 {
 public:
   cmDocumentation();
@@ -39,7 +39,7 @@ public:
    * help arguments.
    */
   bool CheckOptions(int argc, const char* const* argv,
-                    const char* exitOpt =0);
+                    const char* exitOpt = 0);
 
   /**
    * Print help requested on the command line.  Call after
@@ -59,28 +59,21 @@ public:
 
   /** Set a section of the documentation. Typical sections include Name,
       Usage, Description, Options */
-  void SetSection(const char *sectionName,
-                  cmDocumentationSection *section);
-  void SetSection(const char *sectionName,
-                  std::vector<cmDocumentationEntry> &docs);
-  void SetSection(const char *sectionName,
-                  const char *docs[][2]);
-  void SetSections(std::map<std::string,cmDocumentationSection *>
-                   &sections);
+  void SetSection(const char* sectionName, cmDocumentationSection* section);
+  void SetSection(const char* sectionName,
+                  std::vector<cmDocumentationEntry>& docs);
+  void SetSection(const char* sectionName, const char* docs[][2]);
+  void SetSections(std::map<std::string, cmDocumentationSection*>& sections);
 
   /** Add the documentation to the beginning/end of the section */
-  void PrependSection(const char *sectionName,
-                      const char *docs[][2]);
-  void PrependSection(const char *sectionName,
-                      std::vector<cmDocumentationEntry> &docs);
-  void PrependSection(const char *sectionName,
-                      cmDocumentationEntry &docs);
-  void AppendSection(const char *sectionName,
-                     const char *docs[][2]);
-  void AppendSection(const char *sectionName,
-                     std::vector<cmDocumentationEntry> &docs);
-  void AppendSection(const char *sectionName,
-                     cmDocumentationEntry &docs);
+  void PrependSection(const char* sectionName, const char* docs[][2]);
+  void PrependSection(const char* sectionName,
+                      std::vector<cmDocumentationEntry>& docs);
+  void PrependSection(const char* sectionName, cmDocumentationEntry& docs);
+  void AppendSection(const char* sectionName, const char* docs[][2]);
+  void AppendSection(const char* sectionName,
+                     std::vector<cmDocumentationEntry>& docs);
+  void AppendSection(const char* sectionName, cmDocumentationEntry& docs);
 
   /** Add common (to all tools) documentation section(s) */
   void addCommonStandardDocSections();
@@ -95,7 +88,6 @@ public:
   void addCPackStandardDocSections();
 
 private:
-
   void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
   void PrintNames(std::ostream& os, std::string const& pattern);
   bool PrintFiles(std::ostream& os, std::string const& pattern);
@@ -125,13 +117,16 @@ private:
   bool ShowGenerators;
 
   std::string NameString;
-  std::map<std::string,cmDocumentationSection*> AllSections;
+  std::map<std::string, cmDocumentationSection*> AllSections;
 
   std::string CurrentArgument;
 
   struct RequestedHelpItem
   {
-    RequestedHelpItem(): HelpType(None) {}
+    RequestedHelpItem()
+      : HelpType(None)
+    {
+    }
     cmDocumentationEnums::Type HelpType;
     std::string Filename;
     std::string Argument;
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 6869e2f..4816bb9 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -13,8 +13,9 @@
 
 #include "cmDocumentationSection.h"
 
-cmDocumentationFormatter::cmDocumentationFormatter():
-  TextWidth(77), TextIndent("")
+cmDocumentationFormatter::cmDocumentationFormatter()
+  : TextWidth(77)
+  , TextIndent("")
 {
 }
 
@@ -25,67 +26,55 @@ cmDocumentationFormatter::~cmDocumentationFormatter()
 void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
                                               const char* text)
 {
-  if(!text)
-    {
+  if (!text) {
     return;
-    }
+  }
   const char* ptr = text;
-  while(*ptr)
-    {
+  while (*ptr) {
     // Any ptrs starting in a space are treated as preformatted text.
     std::string preformatted;
-    while(*ptr == ' ')
-      {
-      for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
-        {
+    while (*ptr == ' ') {
+      for (char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr) {
         preformatted.append(1, ch);
-        }
-      if(*ptr)
-        {
+      }
+      if (*ptr) {
         ++ptr;
         preformatted.append(1, '\n');
-        }
       }
-    if(!preformatted.empty())
-      {
+    }
+    if (!preformatted.empty()) {
       this->PrintPreformatted(os, preformatted.c_str());
-      }
+    }
 
     // Other ptrs are treated as paragraphs.
     std::string paragraph;
-    for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
-      {
+    for (char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr) {
       paragraph.append(1, ch);
-      }
-    if(*ptr)
-      {
+    }
+    if (*ptr) {
       ++ptr;
       paragraph.append(1, '\n');
-      }
-    if(!paragraph.empty())
-      {
+    }
+    if (!paragraph.empty()) {
       this->PrintParagraph(os, paragraph.c_str());
-      }
     }
+  }
 }
 
 void cmDocumentationFormatter::PrintPreformatted(std::ostream& os,
-                                                     const char* text)
+                                                 const char* text)
 {
   bool newline = true;
-  for(const char* ptr = text; *ptr; ++ptr)
-    {
-    if(newline && *ptr != '\n')
-      {
+  for (const char* ptr = text; *ptr; ++ptr) {
+    if (newline && *ptr != '\n') {
       os << this->TextIndent;
       newline = false;
-      }
+    }
     os << *ptr;
-    if(*ptr == '\n')
-      {
+    if (*ptr == '\n') {
       newline = true;
-      }
     }
+  }
   os << "\n";
 }
 
@@ -102,8 +91,7 @@ void cmDocumentationFormatter::SetIndent(const char* indent)
   this->TextIndent = indent;
 }
 
-void cmDocumentationFormatter::PrintColumn(std::ostream& os,
-                                           const char* text)
+void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
 {
   // Print text arranged in an indented column of fixed witdh.
   const char* l = text;
@@ -113,118 +101,97 @@ void cmDocumentationFormatter::PrintColumn(std::ostream& os,
   int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent));
 
   // Loop until the end of the text.
-  while(*l)
-    {
+  while (*l) {
     // Parse the next word.
     const char* r = l;
-    while(*r && (*r != '\n') && (*r != ' ')) { ++r; }
+    while (*r && (*r != '\n') && (*r != ' ')) {
+      ++r;
+    }
 
     // Does it fit on this line?
-    if(r-l < (width-column-(newSentence?1:0)))
-      {
+    if (r - l < (width - column - (newSentence ? 1 : 0))) {
       // Word fits on this line.
-      if(r > l)
-        {
-        if(column)
-          {
+      if (r > l) {
+        if (column) {
           // Not first word on line.  Separate from the previous word
           // by a space, or two if this is a new sentence.
-          if(newSentence)
-            {
+          if (newSentence) {
             os << "  ";
             column += 2;
-            }
-          else
-            {
+          } else {
             os << " ";
             column += 1;
-            }
           }
-        else
-          {
+        } else {
           // First word on line.  Print indentation unless this is the
           // first line.
-          os << (firstLine?"":this->TextIndent);
-          }
+          os << (firstLine ? "" : this->TextIndent);
+        }
 
         // Print the word.
-        os.write(l, static_cast<long>(r-l));
-        newSentence = (*(r-1) == '.');
-        }
+        os.write(l, static_cast<long>(r - l));
+        newSentence = (*(r - 1) == '.');
+      }
 
-      if(*r == '\n')
-        {
+      if (*r == '\n') {
         // Text provided a newline.  Start a new line.
         os << "\n";
         ++r;
         column = 0;
         firstLine = false;
-        }
-      else
-        {
+      } else {
         // No provided newline.  Continue this line.
-        column += static_cast<long>(r-l);
-        }
+        column += static_cast<long>(r - l);
       }
-    else
-      {
+    } else {
       // Word does not fit on this line.  Start a new line.
       os << "\n";
       firstLine = false;
-      if(r > l)
-        {
+      if (r > l) {
         os << this->TextIndent;
-        os.write(l, static_cast<long>(r-l));
-        column = static_cast<long>(r-l);
-        newSentence = (*(r-1) == '.');
-        }
-      else
-        {
+        os.write(l, static_cast<long>(r - l));
+        column = static_cast<long>(r - l);
+        newSentence = (*(r - 1) == '.');
+      } else {
         column = 0;
-        }
       }
+    }
 
     // Move to beginning of next word.  Skip over whitespace.
     l = r;
-    while(*l && (*l == ' ')) { ++l; }
+    while (*l && (*l == ' ')) {
+      ++l;
     }
+  }
 }
 
-void cmDocumentationFormatter
-::PrintSection(std::ostream& os,
-               cmDocumentationSection const& section)
+void cmDocumentationFormatter::PrintSection(
+  std::ostream& os, cmDocumentationSection const& section)
 {
   os << section.GetName() << "\n";
 
-  const std::vector<cmDocumentationEntry> &entries =
-    section.GetEntries();
-  for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
-      op != entries.end(); ++op)
-    {
-    if(!op->Name.empty())
-      {
+  const std::vector<cmDocumentationEntry>& entries = section.GetEntries();
+  for (std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
+       op != entries.end(); ++op) {
+    if (!op->Name.empty()) {
       os << "  " << op->Name;
       this->TextIndent = "                                 ";
-      int align = static_cast<int>(strlen(this->TextIndent))-4;
-      for(int i = static_cast<int>(op->Name.size()); i < align; ++i)
-        {
+      int align = static_cast<int>(strlen(this->TextIndent)) - 4;
+      for (int i = static_cast<int>(op->Name.size()); i < align; ++i) {
         os << " ";
-        }
-      if (op->Name.size() > strlen(this->TextIndent)-4 )
-        {
+      }
+      if (op->Name.size() > strlen(this->TextIndent) - 4) {
         os << "\n";
-        os.write(this->TextIndent, strlen(this->TextIndent)-2);
-        }
+        os.write(this->TextIndent, strlen(this->TextIndent) - 2);
+      }
       os << "= ";
       this->PrintColumn(os, op->Brief.c_str());
       os << "\n";
-      }
-    else
-      {
+    } else {
       os << "\n";
       this->TextIndent = "";
       this->PrintFormatted(os, op->Brief.c_str());
-      }
     }
+  }
   os << "\n";
 }
diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h
index 6e19b7d..7c4c35b 100644
--- a/Source/cmDocumentationFormatter.h
+++ b/Source/cmDocumentationFormatter.h
@@ -26,9 +26,24 @@ public:
   /** Types of help provided.  */
   enum Type
   {
-    None, Version, Usage, Help, Full, ListManuals, ListCommands,
-    ListModules, ListProperties, ListVariables, ListPolicies, ListGenerators,
-    OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy,
+    None,
+    Version,
+    Usage,
+    Help,
+    Full,
+    ListManuals,
+    ListCommands,
+    ListModules,
+    ListProperties,
+    ListVariables,
+    ListPolicies,
+    ListGenerators,
+    OneManual,
+    OneCommand,
+    OneModule,
+    OneProperty,
+    OneVariable,
+    OnePolicy,
     OldCustomModules
   };
 };
@@ -49,6 +64,7 @@ public:
   virtual void PrintParagraph(std::ostream& os, const char* text);
   void PrintColumn(std::ostream& os, const char* text);
   void SetIndent(const char* indent);
+
 private:
   int TextWidth;
   const char* TextIndent;
diff --git a/Source/cmDocumentationSection.cxx b/Source/cmDocumentationSection.cxx
index b0dd8ef..c6c87f4 100644
--- a/Source/cmDocumentationSection.cxx
+++ b/Source/cmDocumentationSection.cxx
@@ -11,35 +11,27 @@
 ============================================================================*/
 #include "cmDocumentationSection.h"
 
-
-//----------------------------------------------------------------------------
-void cmDocumentationSection::Append(const char *data[][2])
+void cmDocumentationSection::Append(const char* data[][2])
 {
   int i = 0;
-  while(data[i][1])
-    {
-    this->Entries.push_back(cmDocumentationEntry(data[i][0],
-                                                 data[i][1]));
+  while (data[i][1]) {
+    this->Entries.push_back(cmDocumentationEntry(data[i][0], data[i][1]));
     data += 1;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentationSection::Prepend(const char *data[][2])
+void cmDocumentationSection::Prepend(const char* data[][2])
 {
   std::vector<cmDocumentationEntry> tmp;
   int i = 0;
-  while(data[i][1])
-    {
-    tmp.push_back(cmDocumentationEntry(data[i][0],
-                                       data[i][1]));
+  while (data[i][1]) {
+    tmp.push_back(cmDocumentationEntry(data[i][0], data[i][1]));
     data += 1;
-    }
-  this->Entries.insert(this->Entries.begin(),tmp.begin(),tmp.end());
+  }
+  this->Entries.insert(this->Entries.begin(), tmp.begin(), tmp.end());
 }
 
-//----------------------------------------------------------------------------
-void cmDocumentationSection::Append(const char *n, const char *b)
+void cmDocumentationSection::Append(const char* n, const char* b)
 {
-  this->Entries.push_back(cmDocumentationEntry(n,b));
+  this->Entries.push_back(cmDocumentationEntry(n, b));
 }
diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h
index d796da8..161a731 100644
--- a/Source/cmDocumentationSection.h
+++ b/Source/cmDocumentationSection.h
@@ -12,7 +12,6 @@
 #ifndef _cmDocumentationSection_h
 #define _cmDocumentationSection_h
 
-#include "cmStandardIncludes.h"
 #include "cmDocumentationFormatter.h"
 
 // Low-level interface for custom documents:
@@ -25,7 +24,9 @@ class cmDocumentationSection
 public:
   /** Create a cmSection, with a special name for man-output mode. */
   cmDocumentationSection(const char* name, const char*)
-    :Name(name) {}
+    : Name(name)
+  {
+  }
 
   /** Has any content been added to this section or is it empty ? */
   bool IsEmpty() const { return this->Entries.empty(); }
@@ -34,29 +35,35 @@ public:
   void Clear() { this->Entries.clear(); }
 
   /** Return the name of this section. */
-  std::string GetName() const
-  { return this->Name; }
+  std::string GetName() const { return this->Name; }
 
   /** Return a pointer to the first entry of this section. */
-  const std::vector<cmDocumentationEntry> &GetEntries() const
-  { return this->Entries; }
+  const std::vector<cmDocumentationEntry>& GetEntries() const
+  {
+    return this->Entries;
+  }
 
   /** Append an entry to this section. */
   void Append(const cmDocumentationEntry& entry)
-  { this->Entries.push_back(entry); }
-  void Append(const std::vector<cmDocumentationEntry> &entries)
-  { this->Entries.insert(this->Entries.end(),entries.begin(),entries.end()); }
+  {
+    this->Entries.push_back(entry);
+  }
+  void Append(const std::vector<cmDocumentationEntry>& entries)
+  {
+    this->Entries.insert(this->Entries.end(), entries.begin(), entries.end());
+  }
 
   /** Append an entry to this section using NULL terminated chars */
-  void Append(const char *[][2]);
-  void Append(const char *n, const char *b);
+  void Append(const char* [][2]);
+  void Append(const char* n, const char* b);
 
   /** prepend some documentation to this section */
-  void Prepend(const char *[][2]);
-  void Prepend(const std::vector<cmDocumentationEntry> &entries)
-  { this->Entries.insert(this->Entries.begin(),
-                         entries.begin(),entries.end()); }
-
+  void Prepend(const char* [][2]);
+  void Prepend(const std::vector<cmDocumentationEntry>& entries)
+  {
+    this->Entries.insert(this->Entries.begin(), entries.begin(),
+                         entries.end());
+  }
 
 private:
   std::string Name;
diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx
index 944a000..7d0bbdc 100644
--- a/Source/cmDynamicLoader.cxx
+++ b/Source/cmDynamicLoader.cxx
@@ -15,8 +15,7 @@ class cmDynamicLoaderCache
 {
 public:
   ~cmDynamicLoaderCache();
-  void CacheFile(const char* path,
-    const cmsys::DynamicLoader::LibraryHandle&);
+  void CacheFile(const char* path, const cmsys::DynamicLoader::LibraryHandle&);
   bool GetCacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle&);
   bool FlushCache(const char* path);
   void FlushCache();
@@ -33,74 +32,67 @@ cmDynamicLoaderCache::~cmDynamicLoaderCache()
 {
 }
 
-void cmDynamicLoaderCache::CacheFile(const char* path,
-  const cmsys::DynamicLoader::LibraryHandle& p)
+void cmDynamicLoaderCache::CacheFile(
+  const char* path, const cmsys::DynamicLoader::LibraryHandle& p)
 {
   cmsys::DynamicLoader::LibraryHandle h;
-  if ( this->GetCacheFile(path, h) )
-    {
+  if (this->GetCacheFile(path, h)) {
     this->FlushCache(path);
-    }
+  }
   this->CacheMap[path] = p;
 }
 
 bool cmDynamicLoaderCache::GetCacheFile(const char* path,
-  cmsys::DynamicLoader::LibraryHandle& p)
+                                        cmsys::DynamicLoader::LibraryHandle& p)
 {
-  std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
-    = this->CacheMap.find(path);
-  if ( it != this->CacheMap.end() )
-    {
+  std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it =
+    this->CacheMap.find(path);
+  if (it != this->CacheMap.end()) {
     p = it->second;
     return true;
-    }
+  }
   return false;
 }
 
 bool cmDynamicLoaderCache::FlushCache(const char* path)
 {
-  std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
-    = this->CacheMap.find(path);
+  std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it =
+    this->CacheMap.find(path);
   bool ret = false;
-  if ( it != this->CacheMap.end() )
-    {
+  if (it != this->CacheMap.end()) {
     cmsys::DynamicLoader::CloseLibrary(it->second);
     this->CacheMap.erase(it);
     ret = true;
-    }
+  }
   return ret;
 }
 
 void cmDynamicLoaderCache::FlushCache()
 {
-  for ( std::map<std::string,
-    cmsys::DynamicLoader::LibraryHandle>::iterator it
-    = this->CacheMap.begin();
-        it != this->CacheMap.end(); it++ )
-    {
+  for (std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator
+         it = this->CacheMap.begin();
+       it != this->CacheMap.end(); it++) {
     cmsys::DynamicLoader::CloseLibrary(it->second);
-    }
+  }
   delete cmDynamicLoaderCache::Instance;
   cmDynamicLoaderCache::Instance = 0;
 }
 
 cmDynamicLoaderCache* cmDynamicLoaderCache::GetInstance()
 {
-  if ( !cmDynamicLoaderCache::Instance )
-    {
+  if (!cmDynamicLoaderCache::Instance) {
     cmDynamicLoaderCache::Instance = new cmDynamicLoaderCache;
-    }
+  }
   return cmDynamicLoaderCache::Instance;
 }
 
 cmsys::DynamicLoader::LibraryHandle cmDynamicLoader::OpenLibrary(
-  const char* libname )
+  const char* libname)
 {
   cmsys::DynamicLoader::LibraryHandle lh;
-  if ( cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh) )
-    {
+  if (cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh)) {
     return lh;
-    }
+  }
   lh = cmsys::DynamicLoader::OpenLibrary(libname);
   cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh);
   return lh;
diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h
index 84bc9bc..58d9ae9 100644
--- a/Source/cmDynamicLoader.h
+++ b/Source/cmDynamicLoader.h
@@ -14,7 +14,6 @@
 // cmDynamicLoader provides a portable interface to loading dynamic
 // libraries into a process.
 
-
 #ifndef cmDynamicLoader_h
 #define cmDynamicLoader_h
 
@@ -40,7 +39,7 @@ protected:
   ~cmDynamicLoader() {}
 
 private:
-  cmDynamicLoader(const cmDynamicLoader&);  // Not implemented.
+  cmDynamicLoader(const cmDynamicLoader&); // Not implemented.
   void operator=(const cmDynamicLoader&);  // Not implemented.
 };
 
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index b480cd5..26f1a44 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -10,66 +10,83 @@
   See the License for more information.
 ============================================================================*/
 #include "cmStandardIncludes.h" // to get CMAKE_USE_ELF_PARSER first
+
 #include "cmELF.h"
 
-#include <cmsys/auto_ptr.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/auto_ptr.hxx>
 
 // Include the ELF format information system header.
 #if defined(__OpenBSD__)
-# include <stdint.h>
-# include <elf_abi.h>
+#include <elf_abi.h>
+#include <stdint.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
+#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>
+#include <elf.h>
 #endif
 #if defined(__sun)
-# include <sys/link.h> // For dynamic section information
+#include <sys/link.h> // For dynamic section information
 #endif
 
-//----------------------------------------------------------------------------
 // Low-level byte swapping implementation.
-template <size_t s> struct cmELFByteSwapSize {};
+template <size_t s>
+struct cmELFByteSwapSize
+{
+};
 void cmELFByteSwap(char*, cmELFByteSwapSize<1> const&)
 {
 }
 void cmELFByteSwap(char* data, cmELFByteSwapSize<2> const&)
 {
   char one_byte;
-  one_byte = data[0]; data[0] = data[1]; data[1] = one_byte;
+  one_byte = data[0];
+  data[0] = data[1];
+  data[1] = one_byte;
 }
 void cmELFByteSwap(char* data, cmELFByteSwapSize<4> const&)
 {
   char one_byte;
-  one_byte = data[0]; data[0] = data[3]; data[3] = one_byte;
-  one_byte = data[1]; data[1] = data[2]; data[2] = one_byte;
+  one_byte = data[0];
+  data[0] = data[3];
+  data[3] = one_byte;
+  one_byte = data[1];
+  data[1] = data[2];
+  data[2] = one_byte;
 }
 void cmELFByteSwap(char* data, cmELFByteSwapSize<8> const&)
 {
   char one_byte;
-  one_byte = data[0]; data[0] = data[7]; data[7] = one_byte;
-  one_byte = data[1]; data[1] = data[6]; data[6] = one_byte;
-  one_byte = data[2]; data[2] = data[5]; data[5] = one_byte;
-  one_byte = data[3]; data[3] = data[4]; data[4] = one_byte;
+  one_byte = data[0];
+  data[0] = data[7];
+  data[7] = one_byte;
+  one_byte = data[1];
+  data[1] = data[6];
+  data[6] = one_byte;
+  one_byte = data[2];
+  data[2] = data[5];
+  data[5] = one_byte;
+  one_byte = data[3];
+  data[3] = data[4];
+  data[4] = one_byte;
 }
 
 // Low-level byte swapping interface.
@@ -79,25 +96,27 @@ void cmELFByteSwap(T& x)
   cmELFByteSwap(reinterpret_cast<char*>(&x), cmELFByteSwapSize<sizeof(T)>());
 }
 
-//----------------------------------------------------------------------------
 class cmELFInternal
 {
 public:
   typedef cmELF::StringEntry StringEntry;
-  enum ByteOrderType { ByteOrderMSB, ByteOrderLSB };
+  enum ByteOrderType
+  {
+    ByteOrderMSB,
+    ByteOrderLSB
+  };
 
   // Construct and take ownership of the file stream object.
-  cmELFInternal(cmELF* external,
-                cmsys::auto_ptr<cmsys::ifstream>& fin,
-                ByteOrderType order):
-    External(external),
-    Stream(*fin.release()),
-    ByteOrder(order),
-    ELFType(cmELF::FileTypeInvalid)
-    {
-    // In most cases the processor-specific byte order will match that
-    // of the target execution environment.  If we choose wrong here
-    // it is fixed when the header is read.
+  cmELFInternal(cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin,
+                ByteOrderType order)
+    : External(external)
+    , Stream(*fin.release())
+    , ByteOrder(order)
+    , ELFType(cmELF::FileTypeInvalid)
+  {
+// In most cases the processor-specific byte order will match that
+// of the target execution environment.  If we choose wrong here
+// it is fixed when the header is read.
 #if KWIML_ABI_ENDIAN_ID == KWIML_ABI_ENDIAN_ID_LITTLE
     this->NeedSwap = (this->ByteOrder == ByteOrderMSB);
 #elif KWIML_ABI_ENDIAN_ID == KWIML_ABI_ENDIAN_ID_BIG
@@ -108,13 +127,10 @@ public:
 
     // We have not yet loaded the section info.
     this->DynamicSectionIndex = -1;
-    }
+  }
 
   // Destruct and delete the file stream object.
-  virtual ~cmELFInternal()
-    {
-    delete &this->Stream;
-    }
+  virtual ~cmELFInternal() { delete &this->Stream; }
 
   // Forward to the per-class implementation.
   virtual unsigned int GetNumberOfSections() const = 0;
@@ -124,33 +140,33 @@ public:
   virtual void PrintInfo(std::ostream& os) const = 0;
 
   bool ReadBytes(unsigned long pos, unsigned long size, char* buf)
-    {
+  {
     this->Stream.seekg(pos);
     this->Stream.read(buf, size);
-    return this->Stream?true:false;
-    }
+    return this->Stream ? true : false;
+  }
 
   // Lookup the SONAME in the DYNAMIC section.
   StringEntry const* GetSOName()
-    {
+  {
     return this->GetDynamicSectionString(DT_SONAME);
-    }
+  }
 
   // Lookup the RPATH in the DYNAMIC section.
   StringEntry const* GetRPath()
-    {
+  {
     return this->GetDynamicSectionString(DT_RPATH);
-    }
+  }
 
   // Lookup the RUNPATH in the DYNAMIC section.
   StringEntry const* GetRunPath()
-    {
+  {
 #if defined(DT_RUNPATH)
     return this->GetDynamicSectionString(DT_RUNPATH);
 #else
     return 0;
 #endif
-    }
+  }
 
   // Return the recorded ELF type.
   cmELF::FileType GetFileType() const { return this->ELFType; }
@@ -177,22 +193,21 @@ protected:
 
   // Helper methods for subclasses.
   void SetErrorMessage(const char* msg)
-    {
+  {
     this->External->ErrorMessage = msg;
     this->ELFType = cmELF::FileTypeInvalid;
-    }
+  }
 
   // Store string table entry states.
   std::map<unsigned int, StringEntry> DynamicSectionStrings;
 };
 
-//----------------------------------------------------------------------------
 // Configure the implementation template for 32-bit ELF files.
 struct cmELFTypes32
 {
   typedef Elf32_Ehdr ELF_Ehdr;
   typedef Elf32_Shdr ELF_Shdr;
-  typedef Elf32_Dyn  ELF_Dyn;
+  typedef Elf32_Dyn ELF_Dyn;
   typedef Elf32_Half ELF_Half;
   typedef KWIML_INT_uint32_t tagtype;
   static const char* GetName() { return "32-bit"; }
@@ -203,35 +218,33 @@ struct cmELFTypes64
 {
   typedef Elf64_Ehdr ELF_Ehdr;
   typedef Elf64_Shdr ELF_Shdr;
-  typedef Elf64_Dyn  ELF_Dyn;
+  typedef Elf64_Dyn ELF_Dyn;
   typedef Elf64_Half ELF_Half;
   typedef KWIML_INT_uint64_t tagtype;
   static const char* GetName() { return "64-bit"; }
 };
 
-//----------------------------------------------------------------------------
 // Parser implementation template.
 template <class Types>
-class cmELFInternalImpl: public cmELFInternal
+class cmELFInternalImpl : public cmELFInternal
 {
 public:
   // Copy the ELF file format types from our configuration parameter.
   typedef typename Types::ELF_Ehdr ELF_Ehdr;
   typedef typename Types::ELF_Shdr ELF_Shdr;
-  typedef typename Types::ELF_Dyn  ELF_Dyn;
+  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,
-                    cmsys::auto_ptr<cmsys::ifstream>& fin,
+  cmELFInternalImpl(cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin,
                     ByteOrderType order);
 
   // Return the number of sections as specified by the ELF header.
   virtual unsigned int GetNumberOfSections() const
-    {
+  {
     return static_cast<unsigned int>(this->ELFHeader.e_shnum);
-    }
+  }
 
   // Get the file position and size of a dynamic section entry.
   virtual unsigned int GetDynamicEntryCount();
@@ -242,18 +255,14 @@ public:
 
   // Print information about the ELF file.
   virtual void PrintInfo(std::ostream& os) const
-    {
+  {
     os << "ELF " << Types::GetName();
-    if(this->ByteOrder == ByteOrderMSB)
-      {
+    if (this->ByteOrder == ByteOrderMSB) {
       os << " MSB";
-      }
-    else if(this->ByteOrder == ByteOrderLSB)
-      {
+    } else if (this->ByteOrder == ByteOrderLSB) {
       os << " LSB";
-      }
-    switch(this->ELFType)
-      {
+    }
+    switch (this->ELFType) {
       case cmELF::FileTypeInvalid:
         os << " invalid file";
         break;
@@ -275,13 +284,13 @@ public:
       case cmELF::FileTypeSpecificProc:
         os << " processor-specific type";
         break;
-      }
-    os << "\n";
     }
+    os << "\n";
+  }
 
 private:
   void ByteSwap(ELF_Ehdr& elf_header)
-    {
+  {
     cmELFByteSwap(elf_header.e_type);
     cmELFByteSwap(elf_header.e_machine);
     cmELFByteSwap(elf_header.e_version);
@@ -295,10 +304,10 @@ private:
     cmELFByteSwap(elf_header.e_shentsize);
     cmELFByteSwap(elf_header.e_shnum);
     cmELFByteSwap(elf_header.e_shstrndx);
-    }
+  }
 
   void ByteSwap(ELF_Shdr& sec_header)
-    {
+  {
     cmELFByteSwap(sec_header.sh_name);
     cmELFByteSwap(sec_header.sh_type);
     cmELFByteSwap(sec_header.sh_flags);
@@ -309,97 +318,154 @@ private:
     cmELFByteSwap(sec_header.sh_info);
     cmELFByteSwap(sec_header.sh_addralign);
     cmELFByteSwap(sec_header.sh_entsize);
-    }
+  }
 
   void ByteSwap(ELF_Dyn& dyn)
-    {
+  {
     cmELFByteSwap(dyn.d_tag);
-    switch (dyn.d_tag)
-      {
-      case DT_NULL:     /* dyn.d_un ignored */         break;
-      case DT_NEEDED:   cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_PLTRELSZ: cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_PLTGOT:   cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_HASH:     cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_STRTAB:   cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_SYMTAB:   cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_RELA:     cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_RELASZ:   cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_RELAENT:  cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_STRSZ:    cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_SYMENT:   cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_INIT:     cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_FINI:     cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_SONAME:   cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_RPATH:    cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_SYMBOLIC: /* dyn.d_un ignored */         break;
-      case DT_REL:      cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_RELSZ:    cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_RELENT:   cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_PLTREL:   cmELFByteSwap(dyn.d_un.d_val); break;
-      case DT_DEBUG:    cmELFByteSwap(dyn.d_un.d_ptr); break;
-      case DT_TEXTREL:  /* dyn.d_un ignored */         break;
-      case DT_JMPREL:   cmELFByteSwap(dyn.d_un.d_ptr); break;
+    switch (dyn.d_tag) {
+      case DT_NULL: /* dyn.d_un ignored */
+        break;
+      case DT_NEEDED:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_PLTRELSZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_PLTGOT:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_HASH:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_STRTAB:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_SYMTAB:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_RELA:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_RELASZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_RELAENT:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_STRSZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_SYMENT:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_INIT:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_FINI:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_SONAME:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_RPATH:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_SYMBOLIC: /* dyn.d_un ignored */
+        break;
+      case DT_REL:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_RELSZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_RELENT:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_PLTREL:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
+      case DT_DEBUG:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
+      case DT_TEXTREL: /* dyn.d_un ignored */
+        break;
+      case DT_JMPREL:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
 #ifdef T_BIND_NOW
-      case T_BIND_NOW:         /* dyn.d_un ignored */         break;
+      case T_BIND_NOW: /* dyn.d_un ignored */
+        break;
 #endif
 #ifdef DT_INIT_ARRAY
-      case DT_INIT_ARRAY:      cmELFByteSwap(dyn.d_un.d_ptr); break;
+      case DT_INIT_ARRAY:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
 #endif
 #ifdef DT_FINI_ARRAY
-      case DT_FINI_ARRAY:      cmELFByteSwap(dyn.d_un.d_ptr); break;
+      case DT_FINI_ARRAY:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
 #endif
 #ifdef DT_INIT_ARRAYSZ
-      case DT_INIT_ARRAYSZ:    cmELFByteSwap(dyn.d_un.d_val); break;
+      case DT_INIT_ARRAYSZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
 #endif
 #ifdef DT_FINI_ARRAYSZ
-      case DT_FINI_ARRAYSZ:    cmELFByteSwap(dyn.d_un.d_val); break;
+      case DT_FINI_ARRAYSZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
 #endif
 #ifdef DT_RUNPATH
-      case DT_RUNPATH:         cmELFByteSwap(dyn.d_un.d_val); break;
+      case DT_RUNPATH:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
 #endif
 #ifdef DT_FLAGS
-      case DT_FLAGS:           cmELFByteSwap(dyn.d_un.d_val); break;
+      case DT_FLAGS:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
 #endif
 #ifdef DT_PREINIT_ARRAY
-      case DT_PREINIT_ARRAY:   cmELFByteSwap(dyn.d_un.d_ptr); break;
+      case DT_PREINIT_ARRAY:
+        cmELFByteSwap(dyn.d_un.d_ptr);
+        break;
 #endif
 #ifdef DT_PREINIT_ARRAYSZ
-      case DT_PREINIT_ARRAYSZ: cmELFByteSwap(dyn.d_un.d_val); break;
+      case DT_PREINIT_ARRAYSZ:
+        cmELFByteSwap(dyn.d_un.d_val);
+        break;
 #endif
-      }
     }
+  }
 
   bool FileTypeValid(ELF_Half et)
-    {
+  {
     unsigned int eti = static_cast<unsigned int>(et);
-    if(eti == ET_NONE || eti == ET_REL || eti == ET_EXEC ||
-       eti == ET_DYN || eti == ET_CORE)
-      {
+    if (eti == ET_NONE || eti == ET_REL || eti == ET_EXEC || eti == ET_DYN ||
+        eti == ET_CORE) {
       return true;
-      }
+    }
 #if defined(ET_LOOS) && defined(ET_HIOS)
-    if(eti >= ET_LOOS && eti <= ET_HIOS)
-      {
+    if (eti >= ET_LOOS && eti <= ET_HIOS) {
       return true;
-      }
+    }
 #endif
 #if defined(ET_LOPROC) && defined(ET_HIPROC)
-    if(eti >= ET_LOPROC && eti <= ET_HIPROC)
-      {
+    if (eti >= ET_LOPROC && eti <= ET_HIPROC) {
       return true;
-      }
+    }
 #endif
     return false;
-    }
+  }
 
   bool Read(ELF_Ehdr& x)
-    {
+  {
     // Read the header from the file.
-    if(!this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)))
-      {
+    if (!this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x))) {
       return false;
-      }
+    }
 
     // The byte order of ELF header fields may not match that of the
     // processor-specific data.  The header fields are ordered to
@@ -408,63 +474,55 @@ private:
     // value.  As a heuristic, if the type is invalid but its
     // swapped value is okay then flip our swap mode.
     ELF_Half et = x.e_type;
-    if(this->NeedSwap)
-      {
+    if (this->NeedSwap) {
       cmELFByteSwap(et);
-      }
-    if(!this->FileTypeValid(et))
-      {
+    }
+    if (!this->FileTypeValid(et)) {
       cmELFByteSwap(et);
-      if(this->FileTypeValid(et))
-        {
+      if (this->FileTypeValid(et)) {
         // The previous byte order guess was wrong.  Flip it.
         this->NeedSwap = !this->NeedSwap;
-        }
       }
+    }
 
     // Fix the byte order of the header.
-    if(this->NeedSwap)
-      {
+    if (this->NeedSwap) {
       ByteSwap(x);
-      }
-    return true;
     }
+    return true;
+  }
   bool Read(ELF_Shdr& x)
-    {
-    if(this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
-       this->NeedSwap)
-      {
+  {
+    if (this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
+        this->NeedSwap) {
       ByteSwap(x);
-      }
-    return this->Stream? true:false;
     }
+    return this->Stream ? true : false;
+  }
   bool Read(ELF_Dyn& x)
-    {
-    if(this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
-       this->NeedSwap)
-      {
+  {
+    if (this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
+        this->NeedSwap) {
       ByteSwap(x);
-      }
-    return this->Stream? true:false;
     }
+    return this->Stream ? true : false;
+  }
 
   bool LoadSectionHeader(ELF_Half i)
-    {
+  {
     // Read the section header from the file.
     this->Stream.seekg(this->ELFHeader.e_shoff +
                        this->ELFHeader.e_shentsize * i);
-    if(!this->Read(this->SectionHeaders[i]))
-      {
+    if (!this->Read(this->SectionHeaders[i])) {
       return false;
-      }
+    }
 
     // Identify some important sections.
-    if(this->SectionHeaders[i].sh_type == SHT_DYNAMIC)
-      {
+    if (this->SectionHeaders[i].sh_type == SHT_DYNAMIC) {
       this->DynamicSectionIndex = i;
-      }
-    return true;
     }
+    return true;
+  }
 
   bool LoadDynamicSection();
 
@@ -478,24 +536,19 @@ private:
   std::vector<ELF_Dyn> DynamicSectionEntries;
 };
 
-//----------------------------------------------------------------------------
 template <class Types>
-cmELFInternalImpl<Types>
-::cmELFInternalImpl(cmELF* external,
-                    cmsys::auto_ptr<cmsys::ifstream>& fin,
-                    ByteOrderType order):
-  cmELFInternal(external, fin, order)
+cmELFInternalImpl<Types>::cmELFInternalImpl(
+  cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin, ByteOrderType order)
+  : cmELFInternal(external, fin, order)
 {
   // Read the main header.
-  if(!this->Read(this->ELFHeader))
-    {
+  if (!this->Read(this->ELFHeader)) {
     this->SetErrorMessage("Failed to read main ELF header.");
     return;
-    }
+  }
 
   // Determine the ELF file type.
-  switch(this->ELFHeader.e_type)
-    {
+  switch (this->ELFHeader.e_type) {
     case ET_NONE:
       this->SetErrorMessage("ELF file type is NONE.");
       return;
@@ -511,137 +564,116 @@ cmELFInternalImpl<Types>
     case ET_CORE:
       this->ELFType = cmELF::FileTypeCore;
       break;
-    default:
-      {
+    default: {
       unsigned int eti = static_cast<unsigned int>(this->ELFHeader.e_type);
 #if defined(ET_LOOS) && defined(ET_HIOS)
-      if(eti >= ET_LOOS && eti <= ET_HIOS)
-        {
+      if (eti >= ET_LOOS && eti <= ET_HIOS) {
         this->ELFType = cmELF::FileTypeSpecificOS;
         break;
-        }
+      }
 #endif
 #if defined(ET_LOPROC) && defined(ET_HIPROC)
-      if(eti >= ET_LOPROC && eti <= ET_HIPROC)
-        {
+      if (eti >= ET_LOPROC && eti <= ET_HIPROC) {
         this->ELFType = cmELF::FileTypeSpecificProc;
         break;
-        }
+      }
 #endif
       std::ostringstream e;
       e << "Unknown ELF file type " << eti;
       this->SetErrorMessage(e.str().c_str());
       return;
-      }
     }
+  }
 
   // Load the section headers.
   this->SectionHeaders.resize(this->ELFHeader.e_shnum);
-  for(ELF_Half i=0; i < this->ELFHeader.e_shnum; ++i)
-    {
-    if(!this->LoadSectionHeader(i))
-      {
+  for (ELF_Half i = 0; i < this->ELFHeader.e_shnum; ++i) {
+    if (!this->LoadSectionHeader(i)) {
       this->SetErrorMessage("Failed to load section headers.");
       return;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 template <class Types>
 bool cmELFInternalImpl<Types>::LoadDynamicSection()
 {
   // If there is no dynamic section we are done.
-  if(this->DynamicSectionIndex < 0)
-    {
+  if (this->DynamicSectionIndex < 0) {
     return false;
-    }
+  }
 
   // If the section was already loaded we are done.
-  if(!this->DynamicSectionEntries.empty())
-    {
+  if (!this->DynamicSectionEntries.empty()) {
     return true;
-    }
+  }
 
   // If there are no entries we are done.
   ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
-  if(sec.sh_entsize == 0)
-    {
+  if (sec.sh_entsize == 0) {
     return false;
-    }
+  }
 
   // Allocate the dynamic section entries.
   int n = static_cast<int>(sec.sh_size / sec.sh_entsize);
   this->DynamicSectionEntries.resize(n);
 
   // Read each entry.
-  for(int j=0; j < n; ++j)
-    {
+  for (int j = 0; j < n; ++j) {
     // Seek to the beginning of the section entry.
-    this->Stream.seekg(sec.sh_offset + sec.sh_entsize*j);
+    this->Stream.seekg(sec.sh_offset + sec.sh_entsize * j);
     ELF_Dyn& dyn = this->DynamicSectionEntries[j];
 
     // Try reading the entry.
-    if(!this->Read(dyn))
-      {
+    if (!this->Read(dyn)) {
       this->SetErrorMessage("Error reading entry from DYNAMIC section.");
       this->DynamicSectionIndex = -1;
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 template <class Types>
 unsigned int cmELFInternalImpl<Types>::GetDynamicEntryCount()
 {
-  if(!this->LoadDynamicSection())
-    {
+  if (!this->LoadDynamicSection()) {
     return 0;
-    }
-  for(unsigned int i = 0; i < this->DynamicSectionEntries.size(); ++i)
-    {
-    if(this->DynamicSectionEntries[i].d_tag == DT_NULL)
-      {
+  }
+  for (unsigned int i = 0; i < this->DynamicSectionEntries.size(); ++i) {
+    if (this->DynamicSectionEntries[i].d_tag == DT_NULL) {
       return i;
-      }
     }
+  }
   return static_cast<unsigned int>(this->DynamicSectionEntries.size());
 }
 
-//----------------------------------------------------------------------------
 template <class Types>
 unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)
 {
-  if(!this->LoadDynamicSection())
-    {
+  if (!this->LoadDynamicSection()) {
     return 0;
-    }
-  if(j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size()))
-    {
+  }
+  if (j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size())) {
     return 0;
-    }
+  }
   ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
-  return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize*j);
+  return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j);
 }
 
-//----------------------------------------------------------------------------
 template <class Types>
-cmELF::StringEntry const*
-cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
+cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
+  unsigned int tag)
 {
   // Short-circuit if already checked.
   std::map<unsigned int, StringEntry>::iterator dssi =
     this->DynamicSectionStrings.find(tag);
-  if(dssi != this->DynamicSectionStrings.end())
-    {
-    if(dssi->second.Position > 0)
-      {
+  if (dssi != this->DynamicSectionStrings.end()) {
+    if (dssi->second.Position > 0) {
       return &dssi->second;
-      }
-    return 0;
     }
+    return 0;
+  }
 
   // Create an entry for this tag.  Assume it is missing until found.
   StringEntry& se = this->DynamicSectionStrings[tag];
@@ -650,36 +682,31 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
   se.IndexInSection = -1;
 
   // Try reading the dynamic section.
-  if(!this->LoadDynamicSection())
-    {
+  if (!this->LoadDynamicSection()) {
     return 0;
-    }
+  }
 
   // Get the string table referenced by the DYNAMIC section.
   ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
-  if(sec.sh_link >= this->SectionHeaders.size())
-    {
+  if (sec.sh_link >= this->SectionHeaders.size()) {
     this->SetErrorMessage("Section DYNAMIC has invalid string table index.");
     return 0;
-    }
+  }
   ELF_Shdr const& strtab = this->SectionHeaders[sec.sh_link];
 
   // Look for the requested entry.
-  for(typename std::vector<ELF_Dyn>::iterator
-        di = this->DynamicSectionEntries.begin();
-      di != this->DynamicSectionEntries.end(); ++di)
-    {
+  for (typename std::vector<ELF_Dyn>::iterator di =
+         this->DynamicSectionEntries.begin();
+       di != this->DynamicSectionEntries.end(); ++di) {
     ELF_Dyn& dyn = *di;
-    if(static_cast<tagtype>(dyn.d_tag) == static_cast<tagtype>(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.
-      if(dyn.d_un.d_val >= strtab.sh_size)
-        {
+      if (dyn.d_un.d_val >= strtab.sh_size) {
         this->SetErrorMessage("Section DYNAMIC references string beyond "
                               "the end of its string section.");
         return 0;
-        }
+      }
 
       // Seek to the position reported by the entry.
       unsigned long first = static_cast<unsigned long>(dyn.d_un.d_val);
@@ -694,26 +721,21 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
       // assumption.
       bool terminated = false;
       char c;
-      while(last != end && this->Stream.get(c) && !(terminated && c))
-        {
+      while (last != end && this->Stream.get(c) && !(terminated && c)) {
         ++last;
-        if(c)
-          {
+        if (c) {
           se.Value += c;
-          }
-        else
-          {
+        } else {
           terminated = true;
-          }
         }
+      }
 
       // Make sure the whole value was read.
-      if(!this->Stream)
-        {
+      if (!this->Stream) {
         this->SetErrorMessage("Dynamic section specifies unreadable RPATH.");
         se.Value = "";
         return 0;
-        }
+      }
 
       // The value has been read successfully.  Report it.
       se.Position = static_cast<unsigned long>(strtab.sh_offset + first);
@@ -721,231 +743,173 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
       se.IndexInSection =
         static_cast<int>(di - this->DynamicSectionEntries.begin());
       return &se;
-      }
     }
+  }
   return 0;
 }
 
 //============================================================================
 // External class implementation.
 
-//----------------------------------------------------------------------------
-cmELF::cmELF(const char* fname): Internal(0)
+cmELF::cmELF(const char* fname)
+  : Internal(0)
 {
   // Try to open the file.
   cmsys::auto_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
 
   // Quit now if the file could not be opened.
-  if(!fin.get() || !*fin)
-    {
+  if (!fin.get() || !*fin) {
     this->ErrorMessage = "Error opening input file.";
     return;
-    }
+  }
 
   // Read the ELF identification block.
   char ident[EI_NIDENT];
-  if(!fin->read(ident, EI_NIDENT))
-    {
+  if (!fin->read(ident, EI_NIDENT)) {
     this->ErrorMessage = "Error reading ELF identification.";
     return;
-    }
-  if(!fin->seekg(0))
-    {
+  }
+  if (!fin->seekg(0)) {
     this->ErrorMessage = "Error seeking to beginning of file.";
     return;
-    }
+  }
 
   // Verify the ELF identification.
-  if(!(ident[EI_MAG0] == ELFMAG0 &&
-       ident[EI_MAG1] == ELFMAG1 &&
-       ident[EI_MAG2] == ELFMAG2 &&
-       ident[EI_MAG3] == ELFMAG3))
-    {
+  if (!(ident[EI_MAG0] == ELFMAG0 && ident[EI_MAG1] == ELFMAG1 &&
+        ident[EI_MAG2] == ELFMAG2 && ident[EI_MAG3] == ELFMAG3)) {
     this->ErrorMessage = "File does not have a valid ELF identification.";
     return;
-    }
+  }
 
   // Check the byte order in which the rest of the file is encoded.
   cmELFInternal::ByteOrderType order;
-  if(ident[EI_DATA] == ELFDATA2LSB)
-    {
+  if (ident[EI_DATA] == ELFDATA2LSB) {
     // File is LSB.
-    order =  cmELFInternal::ByteOrderLSB;
-    }
-  else if(ident[EI_DATA] == ELFDATA2MSB)
-    {
+    order = cmELFInternal::ByteOrderLSB;
+  } else if (ident[EI_DATA] == ELFDATA2MSB) {
     // File is MSB.
-    order =  cmELFInternal::ByteOrderMSB;
-    }
-  else
-    {
+    order = cmELFInternal::ByteOrderMSB;
+  } else {
     this->ErrorMessage = "ELF file is not LSB or MSB encoded.";
     return;
-    }
+  }
 
   // Check the class of the file and construct the corresponding
   // parser implementation.
-  if(ident[EI_CLASS] == ELFCLASS32)
-    {
+  if (ident[EI_CLASS] == ELFCLASS32) {
     // 32-bit ELF
     this->Internal = new cmELFInternalImpl<cmELFTypes32>(this, fin, order);
-    }
-  else if(ident[EI_CLASS] == ELFCLASS64)
-    {
+  } else if (ident[EI_CLASS] == ELFCLASS64) {
     // 64-bit ELF
     this->Internal = new cmELFInternalImpl<cmELFTypes64>(this, fin, order);
-    }
-  else
-    {
+  } else {
     this->ErrorMessage = "ELF file class is not 32-bit or 64-bit.";
     return;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmELF::~cmELF()
 {
   delete this->Internal;
 }
 
-//----------------------------------------------------------------------------
 bool cmELF::Valid() const
 {
   return this->Internal && this->Internal->GetFileType() != FileTypeInvalid;
 }
 
-//----------------------------------------------------------------------------
 cmELF::FileType cmELF::GetFileType() const
 {
-  if(this->Valid())
-    {
+  if (this->Valid()) {
     return this->Internal->GetFileType();
-    }
-  else
-    {
+  } else {
     return FileTypeInvalid;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 unsigned int cmELF::GetNumberOfSections() const
 {
-  if(this->Valid())
-    {
+  if (this->Valid()) {
     return this->Internal->GetNumberOfSections();
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 unsigned int cmELF::GetDynamicEntryCount() const
 {
-  if(this->Valid())
-    {
+  if (this->Valid()) {
     return this->Internal->GetDynamicEntryCount();
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 unsigned long cmELF::GetDynamicEntryPosition(int index) const
 {
-  if(this->Valid())
-    {
+  if (this->Valid()) {
     return this->Internal->GetDynamicEntryPosition(index);
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const
 {
-  if(this->Valid())
-    {
+  if (this->Valid()) {
     return this->Internal->ReadBytes(pos, size, buf);
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmELF::GetSOName(std::string& soname)
 {
-  if(StringEntry const* se = this->GetSOName())
-    {
+  if (StringEntry const* se = this->GetSOName()) {
     soname = se->Value;
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmELF::StringEntry const* cmELF::GetSOName()
 {
-  if(this->Valid() &&
-     this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)
-    {
+  if (this->Valid() &&
+      this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) {
     return this->Internal->GetSOName();
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmELF::StringEntry const* cmELF::GetRPath()
 {
-  if(this->Valid() &&
-     (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
-      this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary))
-    {
+  if (this->Valid() &&
+      (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
+       this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
     return this->Internal->GetRPath();
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmELF::StringEntry const* cmELF::GetRunPath()
 {
-  if(this->Valid() &&
-     (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
-      this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary))
-    {
+  if (this->Valid() &&
+      (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
+       this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
     return this->Internal->GetRunPath();
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmELF::PrintInfo(std::ostream& os) const
 {
-  if(this->Valid())
-    {
+  if (this->Valid()) {
     this->Internal->PrintInfo(os);
-    }
-  else
-    {
+  } else {
     os << "Not a valid ELF file.\n";
-    }
+  }
 }
diff --git a/Source/cmELF.h b/Source/cmELF.h
index ab9be42..80832ad 100644
--- a/Source/cmELF.h
+++ b/Source/cmELF.h
@@ -13,7 +13,7 @@
 #define cmELF_h
 
 #if !defined(CMAKE_USE_ELF_PARSER)
-# error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
+#error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
 #endif
 
 class cmELFInternal;
@@ -31,10 +31,7 @@ public:
   ~cmELF();
 
   /** Get the error message if any.  */
-  std::string const& GetErrorMessage() const
-    {
-    return this->ErrorMessage;
-    }
+  std::string const& GetErrorMessage() const { return this->ErrorMessage; }
 
   /** Boolean conversion.  True if the ELF file is valid.  */
   operator bool() const { return this->Valid(); }
diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx
index 163d006..6db6f8d 100644
--- a/Source/cmElseCommand.cxx
+++ b/Source/cmElseCommand.cxx
@@ -12,7 +12,7 @@
 #include "cmElseCommand.h"
 
 bool cmElseCommand::InitialPass(std::vector<std::string> const&,
-                                cmExecutionStatus &)
+                                cmExecutionStatus&)
 {
   this->SetError("An ELSE command was found outside of a proper "
                  "IF ENDIF structure. Or its arguments did not match "
diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h
index dde5fcc..815825e 100644
--- a/Source/cmElseCommand.h
+++ b/Source/cmElseCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmElseCommand;
-    }
+  virtual cmCommand* Clone() { return new cmElseCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,10 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "else";}
+  virtual std::string GetName() const { return "else"; }
 
   cmTypeMacro(cmElseCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmElseIfCommand.cxx b/Source/cmElseIfCommand.cxx
index cd9742b..dc89e24 100644
--- a/Source/cmElseIfCommand.cxx
+++ b/Source/cmElseIfCommand.cxx
@@ -12,7 +12,7 @@
 #include "cmElseIfCommand.h"
 
 bool cmElseIfCommand::InitialPass(std::vector<std::string> const&,
-                                  cmExecutionStatus &)
+                                  cmExecutionStatus&)
 {
   this->SetError("An ELSEIF command was found outside of a proper "
                  "IF ENDIF structure.");
diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h
index c627cbe..d0ffa5d 100644
--- a/Source/cmElseIfCommand.h
+++ b/Source/cmElseIfCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmElseIfCommand;
-    }
+  virtual cmCommand* Clone() { return new cmElseIfCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,10 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "elseif";}
+  virtual std::string GetName() const { return "elseif"; }
 
   cmTypeMacro(cmElseIfCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx
index dcabf6a..0ebe778 100644
--- a/Source/cmEnableLanguageCommand.cxx
+++ b/Source/cmEnableLanguageCommand.cxx
@@ -12,32 +12,24 @@
 #include "cmEnableLanguageCommand.h"
 
 // cmEnableLanguageCommand
-bool cmEnableLanguageCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
   bool optional = false;
   std::vector<std::string> languages;
-  if(args.size() < 1 )
-    {
-    this->SetError
-      ("called with incorrect number of arguments");
+  if (args.size() < 1) {
+    this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   for (std::vector<std::string>::const_iterator it = args.begin();
-       it != args.end();
-       ++it)
-    {
-    if ((*it) == "OPTIONAL")
-      {
+       it != args.end(); ++it) {
+    if ((*it) == "OPTIONAL") {
       optional = true;
-      }
-    else
-      {
+    } else {
       languages.push_back(*it);
-      }
     }
+  }
 
   this->Makefile->EnableLanguage(languages, optional);
   return true;
 }
-
diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h
index 2b09e11..657e4e5 100644
--- a/Source/cmEnableLanguageCommand.h
+++ b/Source/cmEnableLanguageCommand.h
@@ -28,26 +28,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEnableLanguageCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEnableLanguageCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "enable_language";}
+  virtual std::string GetName() const { return "enable_language"; }
 
   cmTypeMacro(cmEnableLanguageCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx
index 6a7fd46..a9c60a8 100644
--- a/Source/cmEnableTestingCommand.cxx
+++ b/Source/cmEnableTestingCommand.cxx
@@ -14,8 +14,8 @@
 // we do this in the final pass so that we now the subdirs have all
 // been defined
 bool cmEnableTestingCommand::InitialPass(std::vector<std::string> const&,
-                                         cmExecutionStatus &)
+                                         cmExecutionStatus&)
 {
-  this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED","1");
+  this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED", "1");
   return true;
 }
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
index d028c59..a518f18 100644
--- a/Source/cmEnableTestingCommand.h
+++ b/Source/cmEnableTestingCommand.h
@@ -33,26 +33,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEnableTestingCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEnableTestingCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &);
+                           cmExecutionStatus&);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "enable_testing";}
+  virtual std::string GetName() const { return "enable_testing"; }
 
   cmTypeMacro(cmEnableTestingCommand, cmCommand);
-
 };
 
-
 #endif
diff --git a/Source/cmEndForEachCommand.cxx b/Source/cmEndForEachCommand.cxx
index 7f11ae5..104b39a 100644
--- a/Source/cmEndForEachCommand.cxx
+++ b/Source/cmEndForEachCommand.cxx
@@ -11,13 +11,11 @@
 ============================================================================*/
 #include "cmEndForEachCommand.h"
 
-bool cmEndForEachCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const&,
-                    cmExecutionStatus &)
+bool cmEndForEachCommand::InvokeInitialPass(
+  std::vector<cmListFileArgument> const&, cmExecutionStatus&)
 {
   this->SetError("An ENDFOREACH command was found outside of a proper "
                  "FOREACH ENDFOREACH structure. Or its arguments did "
                  "not match the opening FOREACH command.");
   return false;
 }
-
diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h
index c3be387..ebc794f 100644
--- a/Source/cmEndForEachCommand.h
+++ b/Source/cmEndForEachCommand.h
@@ -25,24 +25,23 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEndForEachCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEndForEachCommand; }
 
   /**
    * Override cmCommand::InvokeInitialPass to get arguments before
    * expansion.
    */
   virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) {return false;}
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "endforeach";}
+  virtual std::string GetName() const { return "endforeach"; }
 
   cmTypeMacro(cmEndForEachCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmEndFunctionCommand.cxx b/Source/cmEndFunctionCommand.cxx
index 04b242d..b4bfa2d 100644
--- a/Source/cmEndFunctionCommand.cxx
+++ b/Source/cmEndFunctionCommand.cxx
@@ -11,13 +11,11 @@
 ============================================================================*/
 #include "cmEndFunctionCommand.h"
 
-bool cmEndFunctionCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const&,
-                    cmExecutionStatus &)
+bool cmEndFunctionCommand::InvokeInitialPass(
+  std::vector<cmListFileArgument> const&, cmExecutionStatus&)
 {
   this->SetError("An ENDFUNCTION command was found outside of a proper "
                  "FUNCTION ENDFUNCTION structure. Or its arguments did not "
                  "match the opening FUNCTION command.");
   return false;
 }
-
diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h
index 3a42c17..b69dec0 100644
--- a/Source/cmEndFunctionCommand.h
+++ b/Source/cmEndFunctionCommand.h
@@ -25,24 +25,23 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEndFunctionCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEndFunctionCommand; }
 
   /**
    * Override cmCommand::InvokeInitialPass to get arguments before
    * expansion.
    */
   virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) {return false;}
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "endfunction";}
+  virtual std::string GetName() const { return "endfunction"; }
 
   cmTypeMacro(cmEndFunctionCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmEndIfCommand.cxx b/Source/cmEndIfCommand.cxx
index 0ac09de..1ae3a78 100644
--- a/Source/cmEndIfCommand.cxx
+++ b/Source/cmEndIfCommand.cxx
@@ -10,20 +10,19 @@
   See the License for more information.
 ============================================================================*/
 #include "cmEndIfCommand.h"
+
 #include <stdlib.h> // required for atof
 bool cmEndIfCommand::InitialPass(std::vector<std::string> const&,
-                                 cmExecutionStatus &)
+                                 cmExecutionStatus&)
 {
-  const char* versionValue
-    = this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
-  if (!versionValue || (atof(versionValue) <= 1.4))
-    {
+  const char* versionValue =
+    this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+  if (!versionValue || (atof(versionValue) <= 1.4)) {
     return true;
-    }
+  }
 
   this->SetError("An ENDIF command was found outside of a proper "
                  "IF ENDIF structure. Or its arguments did not match "
                  "the opening IF command.");
   return false;
 }
-
diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h
index a8248c8..457dfd3 100644
--- a/Source/cmEndIfCommand.h
+++ b/Source/cmEndIfCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEndIfCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEndIfCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,10 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "endif";}
+  virtual std::string GetName() const { return "endif"; }
 
   cmTypeMacro(cmEndIfCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmEndMacroCommand.cxx b/Source/cmEndMacroCommand.cxx
index 86d907b..435c05f 100644
--- a/Source/cmEndMacroCommand.cxx
+++ b/Source/cmEndMacroCommand.cxx
@@ -11,13 +11,11 @@
 ============================================================================*/
 #include "cmEndMacroCommand.h"
 
-bool cmEndMacroCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const&,
-                    cmExecutionStatus &)
+bool cmEndMacroCommand::InvokeInitialPass(
+  std::vector<cmListFileArgument> const&, cmExecutionStatus&)
 {
   this->SetError("An ENDMACRO command was found outside of a proper "
                  "MACRO ENDMACRO structure. Or its arguments did not "
                  "match the opening MACRO command.");
   return false;
 }
-
diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h
index fdc04ee..615e8dc 100644
--- a/Source/cmEndMacroCommand.h
+++ b/Source/cmEndMacroCommand.h
@@ -25,24 +25,23 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEndMacroCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEndMacroCommand; }
 
   /**
    * Override cmCommand::InvokeInitialPass to get arguments before
    * expansion.
    */
   virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const&,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) {return false;}
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "endmacro";}
+  virtual std::string GetName() const { return "endmacro"; }
 
   cmTypeMacro(cmEndMacroCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmEndWhileCommand.cxx b/Source/cmEndWhileCommand.cxx
index abb9e5e..33507de 100644
--- a/Source/cmEndWhileCommand.cxx
+++ b/Source/cmEndWhileCommand.cxx
@@ -11,22 +11,17 @@
 ============================================================================*/
 #include "cmEndWhileCommand.h"
 
-bool cmEndWhileCommand
-::InvokeInitialPass(std::vector<cmListFileArgument> const& args,
-                    cmExecutionStatus &)
+bool cmEndWhileCommand::InvokeInitialPass(
+  std::vector<cmListFileArgument> const& args, cmExecutionStatus&)
 {
-  if (args.empty())
-    {
+  if (args.empty()) {
     this->SetError("An ENDWHILE command was found outside of a proper "
                    "WHILE ENDWHILE structure.");
-    }
-  else
-    {
+  } else {
     this->SetError("An ENDWHILE command was found outside of a proper "
                    "WHILE ENDWHILE structure. Or its arguments did not "
                    "match the opening WHILE command.");
-    }
+  }
 
   return false;
 }
-
diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h
index ec1cb65..5eda7af 100644
--- a/Source/cmEndWhileCommand.h
+++ b/Source/cmEndWhileCommand.h
@@ -25,24 +25,23 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmEndWhileCommand;
-    }
+  virtual cmCommand* Clone() { return new cmEndWhileCommand; }
 
   /**
    * Override cmCommand::InvokeInitialPass to get arguments before
    * expansion.
    */
   virtual bool InvokeInitialPass(std::vector<cmListFileArgument> const& args,
-                                 cmExecutionStatus &status);
+                                 cmExecutionStatus& status);
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) {return false;}
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -52,10 +51,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "endwhile";}
+  virtual std::string GetName() const { return "endwhile"; }
 
   cmTypeMacro(cmEndWhileCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 41785c2..f3f8c2f 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -10,19 +10,19 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExecProgramCommand.h"
+
 #include "cmSystemTools.h"
 
 #include <cmsys/Process.h>
 
 // cmExecProgramCommand
-bool cmExecProgramCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::string arguments;
   bool doingargs = false;
   int count = 0;
@@ -30,131 +30,102 @@ bool cmExecProgramCommand
   bool haveoutput_variable = false;
   std::string return_variable;
   bool havereturn_variable = false;
-  for(size_t i=0; i < args.size(); ++i)
-    {
-    if(args[i] == "OUTPUT_VARIABLE")
-      {
+  for (size_t i = 0; i < args.size(); ++i) {
+    if (args[i] == "OUTPUT_VARIABLE") {
       count++;
       doingargs = false;
       havereturn_variable = false;
       haveoutput_variable = true;
-      }
-    else if ( haveoutput_variable )
-      {
-      if (!output_variable.empty())
-        {
+    } else if (haveoutput_variable) {
+      if (!output_variable.empty()) {
         this->SetError("called with incorrect number of arguments");
         return false;
-        }
+      }
       output_variable = args[i];
       haveoutput_variable = false;
-      count ++;
-      }
-    else if(args[i] == "RETURN_VALUE")
-      {
+      count++;
+    } else if (args[i] == "RETURN_VALUE") {
       count++;
       doingargs = false;
       haveoutput_variable = false;
       havereturn_variable = true;
-      }
-    else if ( havereturn_variable )
-      {
-      if (!return_variable.empty())
-        {
+    } else if (havereturn_variable) {
+      if (!return_variable.empty()) {
         this->SetError("called with incorrect number of arguments");
         return false;
-        }
+      }
       return_variable = args[i];
       havereturn_variable = false;
-      count ++;
-      }
-    else if(args[i] == "ARGS")
-      {
+      count++;
+    } else if (args[i] == "ARGS") {
       count++;
       havereturn_variable = false;
       haveoutput_variable = false;
       doingargs = true;
-      }
-    else if(doingargs)
-      {
+    } else if (doingargs) {
       arguments += args[i];
       arguments += " ";
       count++;
-      }
     }
+  }
 
   std::string command;
-  if(!arguments.empty())
-    {
+  if (!arguments.empty()) {
     command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str());
     command += " ";
     command += arguments;
-    }
-  else
-    {
+  } else {
     command = args[0];
-    }
+  }
   bool verbose = true;
-  if(!output_variable.empty())
-    {
+  if (!output_variable.empty()) {
     verbose = false;
-    }
+  }
   int retVal = 0;
   std::string output;
   bool result = true;
-  if(args.size() - count == 2)
-    {
+  if (args.size() - count == 2) {
     cmSystemTools::MakeDirectory(args[1].c_str());
     result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
                                               args[1].c_str(), verbose);
-    }
-  else
-    {
-    result = cmExecProgramCommand::RunCommand(command.c_str(), output,
-                                              retVal, 0, verbose);
-    }
-  if(!result)
-    {
+  } else {
+    result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
+                                              0, verbose);
+  }
+  if (!result) {
     retVal = -1;
-    }
+  }
 
-  if (!output_variable.empty())
-    {
+  if (!output_variable.empty()) {
     std::string::size_type first = output.find_first_not_of(" \n\t\r");
     std::string::size_type last = output.find_last_not_of(" \n\t\r");
-    if(first == std::string::npos)
-      {
+    if (first == std::string::npos) {
       first = 0;
-      }
-    if(last == std::string::npos)
-      {
-      last = output.size()-1;
-      }
+    }
+    if (last == std::string::npos) {
+      last = output.size() - 1;
+    }
 
-    std::string coutput = std::string(output, first, last-first+1);
+    std::string coutput = std::string(output, first, last - first + 1);
     this->Makefile->AddDefinition(output_variable, coutput.c_str());
-    }
+  }
 
-  if (!return_variable.empty())
-    {
+  if (!return_variable.empty()) {
     char buffer[100];
     sprintf(buffer, "%d", retVal);
     this->Makefile->AddDefinition(return_variable, buffer);
-    }
+  }
 
   return true;
 }
 
-bool cmExecProgramCommand::RunCommand(const char* command,
-                                      std::string& output,
-                                      int &retVal,
-                                      const char* dir,
+bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
+                                      int& retVal, const char* dir,
                                       bool verbose)
 {
-  if(cmSystemTools::GetRunCommandOutput())
-    {
+  if (cmSystemTools::GetRunCommandOutput()) {
     verbose = false;
-    }
+  }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
   // if the command does not start with a quote, then
@@ -163,100 +134,82 @@ bool cmExecProgramCommand::RunCommand(const char* command,
   // shell command like echo or dir
   int count = 0;
   std::string shortCmd;
-  if(command[0] == '\"')
-    {
+  if (command[0] == '\"') {
     // count the number of quotes
-    for(const char* s = command; *s != 0; ++s)
-      {
-      if(*s == '\"')
-        {
+    for (const char* s = command; *s != 0; ++s) {
+      if (*s == '\"') {
         count++;
-        if(count > 2)
-          {
+        if (count > 2) {
           break;
-          }
         }
       }
+    }
     // if there are more than two double quotes use
     // GetShortPathName, the cmd.exe program in windows which
     // is used by system fails to execute if there are more than
     // one set of quotes in the arguments
-    if(count > 2)
-      {
+    if (count > 2) {
       cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)");
-      if(quoted.find(command))
-        {
+      if (quoted.find(command)) {
         std::string cmd = quoted.match(1);
         std::string args = quoted.match(2);
-        if(! cmSystemTools::FileExists(cmd.c_str()) )
-          {
+        if (!cmSystemTools::FileExists(cmd.c_str())) {
           shortCmd = cmd;
-          }
-        else if(!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd))
-          {
-         cmSystemTools::Error("GetShortPath failed for " , cmd.c_str());
+        } else if (!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) {
+          cmSystemTools::Error("GetShortPath failed for ", cmd.c_str());
           return false;
-          }
+        }
         shortCmd += " ";
         shortCmd += args;
 
         command = shortCmd.c_str();
-        }
-      else
-        {
+      } else {
         cmSystemTools::Error("Could not parse command line with quotes ",
                              command);
-        }
       }
     }
+  }
 #endif
 
   // Allocate a process instance.
   cmsysProcess* cp = cmsysProcess_New();
-  if(!cp)
-    {
+  if (!cp) {
     cmSystemTools::Error("Error allocating process instance.");
     return false;
-    }
+  }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  if(dir)
-    {
+  if (dir) {
     cmsysProcess_SetWorkingDirectory(cp, dir);
-    }
-  if(cmSystemTools::GetRunCommandHideConsole())
-    {
+  }
+  if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
-    }
+  }
   cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1);
-  const char* cmd[] = {command, 0};
+  const char* cmd[] = { command, 0 };
   cmsysProcess_SetCommand(cp, cmd);
 #else
   std::string commandInDir;
-  if(dir)
-    {
+  if (dir) {
     commandInDir = "cd \"";
     commandInDir += dir;
     commandInDir += "\" && ";
     commandInDir += command;
-    }
-  else
-    {
+  } else {
     commandInDir = command;
-    }
+  }
 #ifndef __VMS
   commandInDir += " 2>&1";
 #endif
   command = commandInDir.c_str();
-  if(verbose)
-    {
+  if (verbose) {
     cmSystemTools::Stdout("running ");
     cmSystemTools::Stdout(command);
     cmSystemTools::Stdout("\n");
-    }
+  }
   fflush(stdout);
   fflush(stderr);
-  const char* cmd[] = {"/bin/sh", "-c", command, 0};
+  const char* cmd[] = { "/bin/sh", "-c", command, 0 };
   cmsysProcess_SetCommand(cp, cmd);
 #endif
 
@@ -266,25 +219,21 @@ bool cmExecProgramCommand::RunCommand(const char* command,
   int length;
   char* data;
   int p;
-  while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p))
-    {
-    if(p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR)
-      {
-      if(verbose)
-        {
+  while ((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) {
+    if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
+      if (verbose) {
         cmSystemTools::Stdout(data, length);
-        }
-      output.append(data, length);
       }
+      output.append(data, length);
     }
+  }
 
   // All output has been read.  Wait for the process to exit.
   cmsysProcess_WaitForExit(cp, 0);
 
   // Check the result of running the process.
   std::string msg;
-  switch(cmsysProcess_GetState(cp))
-    {
+  switch (cmsysProcess_GetState(cp)) {
     case cmsysProcess_State_Exited:
       retVal = cmsysProcess_GetExitValue(cp);
       break;
@@ -302,29 +251,26 @@ bool cmExecProgramCommand::RunCommand(const char* command,
       retVal = -1;
       msg += "\nProcess terminated due to timeout.";
       break;
-    }
-  if(!msg.empty())
-    {
+  }
+  if (!msg.empty()) {
 #if defined(_WIN32) && !defined(__CYGWIN__)
     // Old Windows process execution printed this info.
     msg += "\n\nfor command: ";
     msg += command;
-    if(dir)
-      {
+    if (dir) {
       msg += "\nin dir: ";
       msg += dir;
-      }
+    }
     msg += "\n";
-    if(verbose)
-      {
+    if (verbose) {
       cmSystemTools::Stdout(msg.c_str());
-      }
+    }
     output += msg;
 #else
     // Old UNIX process execution only put message in output.
     output += msg;
 #endif
-    }
+  }
 
   // Delete the process instance.
   cmsysProcess_Delete(cp);
diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h
index adefdf9..e6e76d2 100644
--- a/Source/cmExecProgramCommand.h
+++ b/Source/cmExecProgramCommand.h
@@ -27,23 +27,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmExecProgramCommand;
-    }
+  virtual cmCommand* Clone() { return new cmExecProgramCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const
-    {return "exec_program";}
+  virtual std::string GetName() const { return "exec_program"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -51,10 +47,10 @@ public:
   virtual bool IsScriptable() const { return true; }
 
   cmTypeMacro(cmExecProgramCommand, cmCommand);
+
 private:
-  static bool RunCommand(const char* command, std::string& output,
-                         int &retVal, const char* directory = 0,
-                         bool verbose = true);
+  static bool RunCommand(const char* command, std::string& output, int& retVal,
+                         const char* directory = 0, bool verbose = true);
 };
 
 #endif
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index a371390..575cdc3 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExecuteProcessCommand.h"
+
 #include "cmSystemTools.h"
 
 #include <cmsys/Process.h>
@@ -23,19 +24,18 @@ static bool cmExecuteProcessCommandIsWhitespace(char c)
 
 void cmExecuteProcessCommandFixText(std::vector<char>& output,
                                     bool strip_trailing_whitespace);
-void cmExecuteProcessCommandAppend(std::vector<char>& output,
-                                   const char* data, int length);
+void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
+                                   int length);
 
 // cmExecuteProcessCommand
-bool cmExecuteProcessCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
-  std::vector< std::vector<const char*> > cmds;
+  }
+  std::vector<std::vector<const char*> > cmds;
   std::string arguments;
   bool doing_command = false;
   size_t command_index = 0;
@@ -51,246 +51,173 @@ bool cmExecuteProcessCommand
   std::string error_variable;
   std::string result_variable;
   std::string working_directory;
-  for(size_t i=0; i < args.size(); ++i)
-    {
-    if(args[i] == "COMMAND")
-      {
+  for (size_t i = 0; i < args.size(); ++i) {
+    if (args[i] == "COMMAND") {
       doing_command = true;
       command_index = cmds.size();
       cmds.push_back(std::vector<const char*>());
-      }
-    else if(args[i] == "OUTPUT_VARIABLE")
-      {
+    } else if (args[i] == "OUTPUT_VARIABLE") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         output_variable = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for OUTPUT_VARIABLE.");
         return false;
-        }
       }
-    else if(args[i] == "ERROR_VARIABLE")
-      {
+    } else if (args[i] == "ERROR_VARIABLE") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         error_variable = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for ERROR_VARIABLE.");
         return false;
-        }
       }
-    else if(args[i] == "RESULT_VARIABLE")
-      {
+    } else if (args[i] == "RESULT_VARIABLE") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         result_variable = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for RESULT_VARIABLE.");
         return false;
-        }
       }
-    else if(args[i] == "WORKING_DIRECTORY")
-      {
+    } else if (args[i] == "WORKING_DIRECTORY") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         working_directory = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for WORKING_DIRECTORY.");
         return false;
-        }
       }
-    else if(args[i] == "INPUT_FILE")
-      {
+    } else if (args[i] == "INPUT_FILE") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         input_file = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for INPUT_FILE.");
         return false;
-        }
       }
-    else if(args[i] == "OUTPUT_FILE")
-      {
+    } else if (args[i] == "OUTPUT_FILE") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         output_file = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for OUTPUT_FILE.");
         return false;
-        }
       }
-    else if(args[i] == "ERROR_FILE")
-      {
+    } else if (args[i] == "ERROR_FILE") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         error_file = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for ERROR_FILE.");
         return false;
-        }
       }
-    else if(args[i] == "TIMEOUT")
-      {
+    } else if (args[i] == "TIMEOUT") {
       doing_command = false;
-      if(++i < args.size())
-        {
+      if (++i < args.size()) {
         timeout_string = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError(" called with no value for TIMEOUT.");
         return false;
-        }
       }
-    else if(args[i] == "OUTPUT_QUIET")
-      {
+    } else if (args[i] == "OUTPUT_QUIET") {
       doing_command = false;
       output_quiet = true;
-      }
-    else if(args[i] == "ERROR_QUIET")
-      {
+    } else if (args[i] == "ERROR_QUIET") {
       doing_command = false;
       error_quiet = true;
-      }
-    else if(args[i] == "OUTPUT_STRIP_TRAILING_WHITESPACE")
-      {
+    } else if (args[i] == "OUTPUT_STRIP_TRAILING_WHITESPACE") {
       doing_command = false;
       output_strip_trailing_whitespace = true;
-      }
-    else if(args[i] == "ERROR_STRIP_TRAILING_WHITESPACE")
-      {
+    } else if (args[i] == "ERROR_STRIP_TRAILING_WHITESPACE") {
       doing_command = false;
       error_strip_trailing_whitespace = true;
-      }
-    else if(doing_command)
-      {
+    } else if (doing_command) {
       cmds[command_index].push_back(args[i].c_str());
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << " given unknown argument \"" << args[i] << "\".";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
-  if ( !this->Makefile->CanIWriteThisFile(output_file.c_str()) )
-    {
-    std::string e = "attempted to output into a file: " + output_file
-      + " into a source directory.";
+  if (!this->Makefile->CanIWriteThisFile(output_file.c_str())) {
+    std::string e = "attempted to output into a file: " + output_file +
+      " into a source directory.";
     this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
 
   // Check for commands given.
-  if(cmds.empty())
-    {
+  if (cmds.empty()) {
     this->SetError(" called with no COMMAND argument.");
     return false;
-    }
-  for(unsigned int i=0; i < cmds.size(); ++i)
-    {
-    if(cmds[i].empty())
-      {
+  }
+  for (unsigned int i = 0; i < cmds.size(); ++i) {
+    if (cmds[i].empty()) {
       this->SetError(" given COMMAND argument with no value.");
       return false;
-      }
-    else
-      {
+    } else {
       // Add the null terminating pointer to the command argument list.
       cmds[i].push_back(0);
-      }
     }
+  }
 
   // Parse the timeout string.
   double timeout = -1;
-  if(!timeout_string.empty())
-    {
-    if(sscanf(timeout_string.c_str(), "%lg", &timeout) != 1)
-      {
+  if (!timeout_string.empty()) {
+    if (sscanf(timeout_string.c_str(), "%lg", &timeout) != 1) {
       this->SetError(" called with TIMEOUT value that could not be parsed.");
       return false;
-      }
     }
+  }
 
   // Create a process instance.
   cmsysProcess* cp = cmsysProcess_New();
 
   // Set the command sequence.
-  for(unsigned int i=0; i < cmds.size(); ++i)
-    {
+  for (unsigned int i = 0; i < cmds.size(); ++i) {
     cmsysProcess_AddCommand(cp, &*cmds[i].begin());
-    }
+  }
 
   // Set the process working directory.
-  if(!working_directory.empty())
-    {
+  if (!working_directory.empty()) {
     cmsysProcess_SetWorkingDirectory(cp, working_directory.c_str());
-    }
+  }
 
   // Always hide the process window.
   cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
 
   // Check the output variables.
   bool merge_output = false;
-  if(!input_file.empty())
-    {
+  if (!input_file.empty()) {
     cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str());
-    }
-  if(!output_file.empty())
-    {
+  }
+  if (!output_file.empty()) {
     cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDOUT,
                              output_file.c_str());
-    }
-  if(!error_file.empty())
-    {
-    if (error_file == output_file)
-      {
+  }
+  if (!error_file.empty()) {
+    if (error_file == output_file) {
       merge_output = true;
-      }
-    else
-      {
+    } else {
       cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDERR,
                                error_file.c_str());
-      }
     }
-  if (!output_variable.empty() && output_variable == error_variable)
-    {
+  }
+  if (!output_variable.empty() && output_variable == error_variable) {
     merge_output = true;
-    }
-  if (merge_output)
-    {
+  }
+  if (merge_output) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
-    }
+  }
 
   // Set the timeout if any.
-  if(timeout >= 0)
-    {
+  if (timeout >= 0) {
     cmsysProcess_SetTimeout(cp, timeout);
-    }
+  }
 
   // Start the process.
   cmsysProcess_Execute(cp);
@@ -301,81 +228,61 @@ bool cmExecuteProcessCommand
   int length;
   char* data;
   int p;
-  while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p))
-    {
+  while ((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) {
     // Put the output in the right place.
-    if (p == cmsysProcess_Pipe_STDOUT && !output_quiet)
-      {
-      if(output_variable.empty())
-        {
+    if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) {
+      if (output_variable.empty()) {
         cmSystemTools::Stdout(data, length);
-        }
-      else
-        {
+      } else {
         cmExecuteProcessCommandAppend(tempOutput, data, length);
-        }
       }
-    else if(p == cmsysProcess_Pipe_STDERR && !error_quiet)
-      {
-      if(error_variable.empty())
-        {
+    } else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) {
+      if (error_variable.empty()) {
         cmSystemTools::Stderr(data, length);
-        }
-      else
-        {
+      } else {
         cmExecuteProcessCommandAppend(tempError, data, length);
-        }
       }
     }
+  }
 
   // All output has been read.  Wait for the process to exit.
   cmsysProcess_WaitForExit(cp, 0);
 
   // Fix the text in the output strings.
-  cmExecuteProcessCommandFixText(tempOutput,
-                                 output_strip_trailing_whitespace);
-  cmExecuteProcessCommandFixText(tempError,
-                                 error_strip_trailing_whitespace);
+  cmExecuteProcessCommandFixText(tempOutput, output_strip_trailing_whitespace);
+  cmExecuteProcessCommandFixText(tempError, error_strip_trailing_whitespace);
 
   // Store the output obtained.
-  if(!output_variable.empty() && !tempOutput.empty())
-    {
-    this->Makefile->AddDefinition(output_variable,
-                                  &*tempOutput.begin());
-    }
-  if(!merge_output && !error_variable.empty() && !tempError.empty())
-    {
-    this->Makefile->AddDefinition(error_variable,
-                                  &*tempError.begin());
-    }
+  if (!output_variable.empty() && !tempOutput.empty()) {
+    this->Makefile->AddDefinition(output_variable, &*tempOutput.begin());
+  }
+  if (!merge_output && !error_variable.empty() && !tempError.empty()) {
+    this->Makefile->AddDefinition(error_variable, &*tempError.begin());
+  }
 
   // Store the result of running the process.
-  if(!result_variable.empty())
-    {
-    switch(cmsysProcess_GetState(cp))
-      {
-      case cmsysProcess_State_Exited:
-        {
+  if (!result_variable.empty()) {
+    switch (cmsysProcess_GetState(cp)) {
+      case cmsysProcess_State_Exited: {
         int v = cmsysProcess_GetExitValue(cp);
         char buf[100];
         sprintf(buf, "%d", v);
         this->Makefile->AddDefinition(result_variable, buf);
-        }
-        break;
+      } break;
       case cmsysProcess_State_Exception:
         this->Makefile->AddDefinition(result_variable,
-                                  cmsysProcess_GetExceptionString(cp));
+                                      cmsysProcess_GetExceptionString(cp));
         break;
       case cmsysProcess_State_Error:
         this->Makefile->AddDefinition(result_variable,
-                                  cmsysProcess_GetErrorString(cp));
+                                      cmsysProcess_GetErrorString(cp));
         break;
       case cmsysProcess_State_Expired:
         this->Makefile->AddDefinition(result_variable,
-                                  "Process terminated due to timeout");
+                                      "Process terminated due to timeout");
         break;
-      }
     }
+  }
 
   // Delete the process instance.
   cmsysProcess_Delete(cp);
@@ -383,32 +290,28 @@ bool cmExecuteProcessCommand
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmExecuteProcessCommandFixText(std::vector<char>& output,
                                     bool strip_trailing_whitespace)
 {
   // Remove \0 characters and the \r part of \r\n pairs.
   unsigned int in_index = 0;
   unsigned int out_index = 0;
-  while(in_index < output.size())
-    {
+  while (in_index < output.size()) {
     char c = output[in_index++];
-    if((c != '\r' || !(in_index < output.size() && output[in_index] == '\n'))
-       && c != '\0')
-      {
+    if ((c != '\r' ||
+         !(in_index < output.size() && output[in_index] == '\n')) &&
+        c != '\0') {
       output[out_index++] = c;
-      }
     }
+  }
 
   // Remove trailing whitespace if requested.
-  if(strip_trailing_whitespace)
-    {
-    while(out_index > 0 &&
-          cmExecuteProcessCommandIsWhitespace(output[out_index-1]))
-      {
+  if (strip_trailing_whitespace) {
+    while (out_index > 0 &&
+           cmExecuteProcessCommandIsWhitespace(output[out_index - 1])) {
       --out_index;
-      }
     }
+  }
 
   // Shrink the vector to the size needed.
   output.resize(out_index);
@@ -417,20 +320,18 @@ void cmExecuteProcessCommandFixText(std::vector<char>& output,
   output.push_back('\0');
 }
 
-//----------------------------------------------------------------------------
-void cmExecuteProcessCommandAppend(std::vector<char>& output,
-                                   const char* data, int length)
+void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
+                                   int length)
 {
 #if defined(__APPLE__)
   // HACK on Apple to work around bug with inserting at the
   // end of an empty vector.  This resulted in random failures
   // that were hard to reproduce.
-  if(output.empty() && length > 0)
-    {
+  if (output.empty() && length > 0) {
     output.push_back(data[0]);
     ++data;
     --length;
-    }
+  }
 #endif
-  output.insert(output.end(), data, data+length);
+  output.insert(output.end(), data, data + length);
 }
diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h
index 6906a08..a89e705 100644
--- a/Source/cmExecuteProcessCommand.h
+++ b/Source/cmExecuteProcessCommand.h
@@ -26,23 +26,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmExecuteProcessCommand;
-    }
+  virtual cmCommand* Clone() { return new cmExecuteProcessCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const
-    {return "execute_process";}
+  virtual std::string GetName() const { return "execute_process"; }
 
   /**
    * This determines if the command is invoked when in script mode.
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 201465d..508c6bd 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -24,28 +24,22 @@ class cmExecutionStatus
 public:
   cmExecutionStatus() { this->Clear(); }
 
-  void SetReturnInvoked(bool val)
-  { this->ReturnInvoked = val; }
-  bool GetReturnInvoked()
-  { return this->ReturnInvoked; }
+  void SetReturnInvoked(bool val) { this->ReturnInvoked = val; }
+  bool GetReturnInvoked() { return this->ReturnInvoked; }
 
-  void SetBreakInvoked(bool val)
-  { this->BreakInvoked = val; }
-  bool GetBreakInvoked()
-  { return this->BreakInvoked; }
+  void SetBreakInvoked(bool val) { this->BreakInvoked = val; }
+  bool GetBreakInvoked() { return this->BreakInvoked; }
 
-  void SetContinueInvoked(bool val)
-  { this->ContinueInvoked = val; }
-  bool GetContinueInvoked()
-  { return this->ContinueInvoked; }
+  void SetContinueInvoked(bool val) { this->ContinueInvoked = val; }
+  bool GetContinueInvoked() { return this->ContinueInvoked; }
 
   void Clear()
-    {
+  {
     this->ReturnInvoked = false;
     this->BreakInvoked = false;
     this->ContinueInvoked = false;
     this->NestedError = false;
-    }
+  }
   void SetNestedError(bool val) { this->NestedError = val; }
   bool GetNestedError() { return this->NestedError; }
 
diff --git a/Source/cmExpandedCommandArgument.cxx b/Source/cmExpandedCommandArgument.cxx
index 4477cf5..df7fba1 100644
--- a/Source/cmExpandedCommandArgument.cxx
+++ b/Source/cmExpandedCommandArgument.cxx
@@ -12,17 +12,16 @@
 
 #include "cmExpandedCommandArgument.h"
 
-cmExpandedCommandArgument::cmExpandedCommandArgument():
-  Quoted(false)
+cmExpandedCommandArgument::cmExpandedCommandArgument()
+  : Quoted(false)
 {
-
 }
 
-cmExpandedCommandArgument::cmExpandedCommandArgument(
-  std::string const& value, bool quoted):
-    Value(value), Quoted(quoted)
+cmExpandedCommandArgument::cmExpandedCommandArgument(std::string const& value,
+                                                     bool quoted)
+  : Value(value)
+  , Quoted(quoted)
 {
-
 }
 
 std::string const& cmExpandedCommandArgument::GetValue() const
@@ -35,7 +34,7 @@ bool cmExpandedCommandArgument::WasQuoted() const
   return this->Quoted;
 }
 
-bool cmExpandedCommandArgument::operator== (std::string const& value) const
+bool cmExpandedCommandArgument::operator==(std::string const& value) const
 {
   return this->Value == value;
 }
diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h
index f4e1517..1f8e405 100644
--- a/Source/cmExpandedCommandArgument.h
+++ b/Source/cmExpandedCommandArgument.h
@@ -31,7 +31,7 @@ public:
 
   bool WasQuoted() const;
 
-  bool operator== (std::string const& value) const;
+  bool operator==(std::string const& value) const;
 
   bool empty() const;
 
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index dcb2187..8ca7a11 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -11,73 +11,61 @@
 ============================================================================*/
 #include "cmExportBuildFileGenerator.h"
 
-#include "cmLocalGenerator.h"
-#include "cmGlobalGenerator.h"
 #include "cmExportSet.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmTargetExport.h"
 
-//----------------------------------------------------------------------------
 cmExportBuildFileGenerator::cmExportBuildFileGenerator()
 {
   this->LG = 0;
   this->ExportSet = 0;
 }
 
-//----------------------------------------------------------------------------
 void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg)
 {
   this->LG = lg;
-  if (this->ExportSet)
-    {
+  if (this->ExportSet) {
     this->ExportSet->Compute(lg);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
 {
   {
-  std::string expectedTargets;
-  std::string sep;
-  std::vector<std::string> targets;
-  this->GetTargets(targets);
-  for(std::vector<std::string>::const_iterator
-        tei = targets.begin();
-      tei != targets.end(); ++tei)
-    {
-    cmGeneratorTarget *te = this->LG
-                                ->FindGeneratorTargetToUse(*tei);
-    expectedTargets += sep + this->Namespace + te->GetExportName();
-    sep = " ";
-    if(this->ExportedTargets.insert(te).second)
-      {
-      this->Exports.push_back(te);
-      }
-    else
-      {
-      std::ostringstream e;
-      e << "given target \"" << te->GetName() << "\" more than once.";
-      this->LG->GetGlobalGenerator()->GetCMakeInstance()
-          ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                         this->LG->GetMakefile()->GetBacktrace());
-      return false;
+    std::string expectedTargets;
+    std::string sep;
+    std::vector<std::string> targets;
+    this->GetTargets(targets);
+    for (std::vector<std::string>::const_iterator tei = targets.begin();
+         tei != targets.end(); ++tei) {
+      cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(*tei);
+      expectedTargets += sep + this->Namespace + te->GetExportName();
+      sep = " ";
+      if (this->ExportedTargets.insert(te).second) {
+        this->Exports.push_back(te);
+      } else {
+        std::ostringstream e;
+        e << "given target \"" << te->GetName() << "\" more than once.";
+        this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+          cmake::FATAL_ERROR, e.str(),
+          this->LG->GetMakefile()->GetBacktrace());
+        return false;
       }
-    if (te->GetType() == cmState::INTERFACE_LIBRARY)
-      {
-      this->GenerateRequiredCMakeVersion(os, "3.0.0");
+      if (te->GetType() == cmState::INTERFACE_LIBRARY) {
+        this->GenerateRequiredCMakeVersion(os, "3.0.0");
       }
     }
 
-  this->GenerateExpectedTargetsCode(os, expectedTargets);
+    this->GenerateExpectedTargetsCode(os, expectedTargets);
   }
 
   std::vector<std::string> missingTargets;
 
   // Create all the imported targets.
-  for(std::vector<cmGeneratorTarget*>::const_iterator
-        tei = this->Exports.begin();
-      tei != this->Exports.end(); ++tei)
-    {
+  for (std::vector<cmGeneratorTarget*>::const_iterator tei =
+         this->Exports.begin();
+       tei != this->Exports.end(); ++tei) {
     cmGeneratorTarget* gte = *tei;
     this->GenerateImportTargetCode(os, gte);
 
@@ -103,68 +91,56 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
     this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte,
                                     cmGeneratorExpression::BuildInterface,
                                     properties, missingTargets);
-    this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
-                                  gte, properties);
+    this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gte,
+                                    properties);
     const bool newCMP0022Behavior =
-        gte->GetPolicyStatusCMP0022() != cmPolicies::WARN
-        && gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
-    if (newCMP0022Behavior)
-      {
-      this->PopulateInterfaceLinkLibrariesProperty(gte,
-                                    cmGeneratorExpression::BuildInterface,
-                                    properties, missingTargets);
-      }
+      gte->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+      gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+    if (newCMP0022Behavior) {
+      this->PopulateInterfaceLinkLibrariesProperty(
+        gte, cmGeneratorExpression::BuildInterface, properties,
+        missingTargets);
+    }
     this->PopulateCompatibleInterfaceProperties(gte, properties);
 
     this->GenerateInterfaceProperties(gte, os, properties);
-    }
+  }
 
   // Generate import file content for each configuration.
-  for(std::vector<std::string>::const_iterator
-        ci = this->Configurations.begin();
-      ci != this->Configurations.end(); ++ci)
-    {
+  for (std::vector<std::string>::const_iterator ci =
+         this->Configurations.begin();
+       ci != this->Configurations.end(); ++ci) {
     this->GenerateImportConfig(os, *ci, missingTargets);
-    }
+  }
 
   this->GenerateMissingTargetsCheckCode(os, missingTargets);
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportBuildFileGenerator
-::GenerateImportTargetsConfig(std::ostream& os,
-                              const std::string& config,
-                              std::string const& suffix,
-                              std::vector<std::string> &missingTargets)
+void cmExportBuildFileGenerator::GenerateImportTargetsConfig(
+  std::ostream& os, const std::string& config, std::string const& suffix,
+  std::vector<std::string>& missingTargets)
 {
-  for(std::vector<cmGeneratorTarget*>::const_iterator
-        tei = this->Exports.begin();
-      tei != this->Exports.end(); ++tei)
-    {
+  for (std::vector<cmGeneratorTarget*>::const_iterator tei =
+         this->Exports.begin();
+       tei != this->Exports.end(); ++tei) {
     // Collect import properties for this target.
     cmGeneratorTarget* target = *tei;
     ImportPropertyMap properties;
 
-    if (target->GetType() != cmState::INTERFACE_LIBRARY)
-      {
+    if (target->GetType() != cmState::INTERFACE_LIBRARY) {
       this->SetImportLocationProperty(config, suffix, target, properties);
-      }
-    if(!properties.empty())
-      {
+    }
+    if (!properties.empty()) {
       // Get the rest of the target details.
-      if (target->GetType() != cmState::INTERFACE_LIBRARY)
-        {
-        this->SetImportDetailProperties(config, suffix,
-                                        target,
-                                        properties, missingTargets);
+      if (target->GetType() != cmState::INTERFACE_LIBRARY) {
+        this->SetImportDetailProperties(config, suffix, target, properties,
+                                        missingTargets);
         this->SetImportLinkInterface(config, suffix,
                                      cmGeneratorExpression::BuildInterface,
-                                     target,
-                                     properties, missingTargets);
-        }
+                                     target, properties, missingTargets);
+      }
 
       // TOOD: PUBLIC_HEADER_LOCATION
       // This should wait until the build feature propagation stuff
@@ -173,185 +149,148 @@ cmExportBuildFileGenerator
       //                              properties);
 
       // Generate code in the export file.
-      this->GenerateImportPropertyCode(os, config, target,
-                                       properties);
-      }
+      this->GenerateImportPropertyCode(os, config, target, properties);
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet)
+void cmExportBuildFileGenerator::SetExportSet(cmExportSet* exportSet)
 {
   this->ExportSet = exportSet;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportBuildFileGenerator
-::SetImportLocationProperty(const std::string& config,
-                            std::string const& suffix,
-                            cmGeneratorTarget* target,
-                            ImportPropertyMap& properties)
+void cmExportBuildFileGenerator::SetImportLocationProperty(
+  const std::string& config, std::string const& suffix,
+  cmGeneratorTarget* target, ImportPropertyMap& properties)
 {
   // Get the makefile in which to lookup target information.
   cmMakefile* mf = target->Makefile;
 
   // Add the main target file.
   {
-  std::string prop = "IMPORTED_LOCATION";
-  prop += suffix;
-  std::string value;
-  if(target->IsAppBundleOnApple())
-    {
-    value = target->GetFullPath(config, false);
-    }
-  else
-    {
-    value = target->GetFullPath(config, false, true);
+    std::string prop = "IMPORTED_LOCATION";
+    prop += suffix;
+    std::string value;
+    if (target->IsAppBundleOnApple()) {
+      value = target->GetFullPath(config, false);
+    } else {
+      value = target->GetFullPath(config, false, true);
     }
-  properties[prop] = value;
+    properties[prop] = value;
   }
 
   // Add the import library for windows DLLs.
-  if(target->IsDLLPlatform() &&
-     (target->GetType() == cmState::SHARED_LIBRARY ||
-      target->IsExecutableWithExports()) &&
-     mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
-    {
+  if (target->IsDLLPlatform() &&
+      (target->GetType() == cmState::SHARED_LIBRARY ||
+       target->IsExecutableWithExports()) &&
+      mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
     std::string prop = "IMPORTED_IMPLIB";
     prop += suffix;
     std::string value = target->GetFullPath(config, true);
-    target->GetImplibGNUtoMS(value, value,
-                             "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
+    target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
     properties[prop] = value;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportBuildFileGenerator::HandleMissingTarget(
-    std::string& link_libs,
-    std::vector<std::string>& missingTargets,
-    cmGeneratorTarget* depender,
-    cmGeneratorTarget* dependee)
+void cmExportBuildFileGenerator::HandleMissingTarget(
+  std::string& link_libs, std::vector<std::string>& missingTargets,
+  cmGeneratorTarget* depender, cmGeneratorTarget* dependee)
 {
   // The target is not in the export.
-  if(!this->AppendMode)
-    {
+  if (!this->AppendMode) {
     const std::string name = dependee->GetName();
     cmGlobalGenerator* gg =
-        dependee->GetLocalGenerator()->GetGlobalGenerator();
+      dependee->GetLocalGenerator()->GetGlobalGenerator();
     std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
 
     int targetOccurrences = (int)namespaces.size();
-    if (targetOccurrences == 1)
-      {
+    if (targetOccurrences == 1) {
       std::string missingTarget = namespaces[0];
 
       missingTarget += dependee->GetExportName();
       link_libs += missingTarget;
       missingTargets.push_back(missingTarget);
       return;
-      }
-    else
-      {
+    } else {
       // We are not appending, so all exported targets should be
       // known here.  This is probably user-error.
       this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
-      }
     }
+  }
   // Assume the target will be exported by another command.
   // Append it with the export namespace.
   link_libs += this->Namespace;
   link_libs += dependee->GetExportName();
 }
 
-//----------------------------------------------------------------------------
-void cmExportBuildFileGenerator
-::GetTargets(std::vector<std::string> &targets) const
+void cmExportBuildFileGenerator::GetTargets(
+  std::vector<std::string>& targets) const
 {
-  if (this->ExportSet)
-    {
-    for(std::vector<cmTargetExport*>::const_iterator
-          tei = this->ExportSet->GetTargetExports()->begin();
-          tei != this->ExportSet->GetTargetExports()->end(); ++tei)
-      {
+  if (this->ExportSet) {
+    for (std::vector<cmTargetExport*>::const_iterator tei =
+           this->ExportSet->GetTargetExports()->begin();
+         tei != this->ExportSet->GetTargetExports()->end(); ++tei) {
       targets.push_back((*tei)->TargetName);
-      }
-    return;
     }
+    return;
+  }
   targets = this->Targets;
 }
 
-//----------------------------------------------------------------------------
-std::vector<std::string>
-cmExportBuildFileGenerator
-::FindNamespaces(cmGlobalGenerator* gg, const std::string& name)
+std::vector<std::string> cmExportBuildFileGenerator::FindNamespaces(
+  cmGlobalGenerator* gg, const std::string& name)
 {
   std::vector<std::string> namespaces;
 
-  std::map<std::string, cmExportBuildFileGenerator*>& exportSets
-                                                  = gg->GetBuildExportSets();
+  std::map<std::string, cmExportBuildFileGenerator*>& exportSets =
+    gg->GetBuildExportSets();
 
-  for(std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
-      expIt = exportSets.begin(); expIt != exportSets.end(); ++expIt)
-    {
+  for (std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
+         expIt = exportSets.begin();
+       expIt != exportSets.end(); ++expIt) {
     const cmExportBuildFileGenerator* exportSet = expIt->second;
     std::vector<std::string> targets;
     exportSet->GetTargets(targets);
-    if (std::find(targets.begin(), targets.end(), name) != targets.end())
-      {
+    if (std::find(targets.begin(), targets.end(), name) != targets.end()) {
       namespaces.push_back(exportSet->GetNamespace());
-      }
     }
+  }
 
   return namespaces;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportBuildFileGenerator
-::ComplainAboutMissingTarget(cmGeneratorTarget* depender,
-                             cmGeneratorTarget* dependee,
-                             int occurrences)
+void cmExportBuildFileGenerator::ComplainAboutMissingTarget(
+  cmGeneratorTarget* depender, cmGeneratorTarget* dependee, int occurrences)
 {
-  if(cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return;
-    }
+  }
 
   std::ostringstream e;
   e << "export called with target \"" << depender->GetName()
     << "\" which requires target \"" << dependee->GetName() << "\" ";
-  if (occurrences == 0)
-    {
+  if (occurrences == 0) {
     e << "that is not in the export set.\n";
-    }
-  else
-    {
+  } else {
     e << "that is not in this export set, but " << occurrences
-    << " times in others.\n";
-    }
+      << " times in others.\n";
+  }
   e << "If the required target is not easy to reference in this call, "
     << "consider using the APPEND option with multiple separate calls.";
 
-  this->LG->GetGlobalGenerator()->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                     this->LG->GetMakefile()->GetBacktrace());
+  this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+    cmake::FATAL_ERROR, e.str(), this->LG->GetMakefile()->GetBacktrace());
 }
 
-std::string
-cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target,
-                                           const std::string& config)
+std::string cmExportBuildFileGenerator::InstallNameDir(
+  cmGeneratorTarget* target, const std::string& config)
 {
   std::string install_name_dir;
 
   cmMakefile* mf = target->Target->GetMakefile();
-  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
-    install_name_dir =
-      target->GetInstallNameDirForBuildTree(config);
-    }
+  if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+    install_name_dir = target->GetInstallNameDirForBuildTree(config);
+  }
 
   return install_name_dir;
 }
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 85aae2f..be3c70a 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -26,18 +26,21 @@ class cmExportSet;
  *
  * This is used to implement the EXPORT() command.
  */
-class cmExportBuildFileGenerator: public cmExportFileGenerator
+class cmExportBuildFileGenerator : public cmExportFileGenerator
 {
 public:
   cmExportBuildFileGenerator();
 
   /** Set the list of targets to export.  */
   void SetTargets(std::vector<std::string> const& targets)
-    { this->Targets = targets; }
-  void GetTargets(std::vector<std::string> &targets) const;
+  {
+    this->Targets = targets;
+  }
+  void GetTargets(std::vector<std::string>& targets) const;
   void AppendTargets(std::vector<std::string> const& targets)
-    { this->Targets.insert(this->Targets.end(),
-      targets.begin(), targets.end()); }
+  {
+    this->Targets.insert(this->Targets.end(), targets.begin(), targets.end());
+  }
   void SetExportSet(cmExportSet*);
 
   /** Set whether to append generated code to the output file.  */
@@ -48,10 +51,9 @@ public:
 protected:
   // Implement virtual methods from the superclass.
   virtual bool GenerateMainFile(std::ostream& os);
-  virtual void GenerateImportTargetsConfig(std::ostream& os,
-                                           const std::string& config,
-                                           std::string const& suffix,
-                            std::vector<std::string> &missingTargets);
+  virtual void GenerateImportTargetsConfig(
+    std::ostream& os, const std::string& config, std::string const& suffix,
+    std::vector<std::string>& missingTargets);
   virtual void HandleMissingTarget(std::string& link_libs,
                                    std::vector<std::string>& missingTargets,
                                    cmGeneratorTarget* depender,
@@ -70,11 +72,11 @@ protected:
   std::string InstallNameDir(cmGeneratorTarget* target,
                              const std::string& config);
 
-  std::vector<std::string>
-  FindNamespaces(cmGlobalGenerator* gg, const std::string& name);
+  std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
+                                          const std::string& name);
 
   std::vector<std::string> Targets;
-  cmExportSet *ExportSet;
+  cmExportSet* ExportSet;
   std::vector<cmGeneratorTarget*> Exports;
   cmLocalGenerator* LG;
 };
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 4eec66a..a0e7e45 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -10,12 +10,13 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExportCommand.h"
-#include "cmGlobalGenerator.h"
+
 #include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
 #include "cmake.h"
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/Encoding.hxx>
+#include <cmsys/RegularExpression.hxx>
 
 #include "cmExportBuildFileGenerator.h"
 
@@ -25,276 +26,230 @@
 #endif
 
 cmExportCommand::cmExportCommand()
-:cmCommand()
-,ArgumentGroup()
-,Targets(&Helper, "TARGETS")
-,Append(&Helper, "APPEND", &ArgumentGroup)
-,ExportSetName(&Helper, "EXPORT", &ArgumentGroup)
-,Namespace(&Helper, "NAMESPACE", &ArgumentGroup)
-,Filename(&Helper, "FILE", &ArgumentGroup)
-,ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup)
+  : cmCommand()
+  , ArgumentGroup()
+  , Targets(&Helper, "TARGETS")
+  , Append(&Helper, "APPEND", &ArgumentGroup)
+  , ExportSetName(&Helper, "EXPORT", &ArgumentGroup)
+  , Namespace(&Helper, "NAMESPACE", &ArgumentGroup)
+  , Filename(&Helper, "FILE", &ArgumentGroup)
+  , ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup)
 {
   this->ExportSet = 0;
 }
 
-
 // cmExportCommand
-bool cmExportCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
+                                  cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with too few arguments");
     return false;
-    }
+  }
 
-  if(args[0] == "PACKAGE")
-    {
+  if (args[0] == "PACKAGE") {
     return this->HandlePackage(args);
-    }
-  else if (args[0] == "EXPORT")
-    {
+  } else if (args[0] == "EXPORT") {
     this->ExportSetName.Follows(0);
     this->ArgumentGroup.Follows(&this->ExportSetName);
-    }
-  else
-    {
+  } else {
     this->Targets.Follows(0);
     this->ArgumentGroup.Follows(&this->Targets);
-    }
+  }
 
   std::vector<std::string> unknownArgs;
   this->Helper.Parse(&args, &unknownArgs);
 
-  if (!unknownArgs.empty())
-    {
+  if (!unknownArgs.empty()) {
     this->SetError("Unknown arguments.");
     return false;
-    }
+  }
 
   std::string fname;
-  if(!this->Filename.WasFound())
-    {
-    if (args[0] != "EXPORT")
-      {
+  if (!this->Filename.WasFound()) {
+    if (args[0] != "EXPORT") {
       this->SetError("FILE <filename> option missing.");
       return false;
-      }
-    fname = this->ExportSetName.GetString() + ".cmake";
     }
-  else
-    {
+    fname = this->ExportSetName.GetString() + ".cmake";
+  } else {
     // Make sure the file has a .cmake extension.
-    if(cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString())
-      != ".cmake")
-      {
+    if (cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString()) !=
+        ".cmake") {
       std::ostringstream e;
       e << "FILE option given filename \"" << this->Filename.GetString()
         << "\" which does not have an extension of \".cmake\".\n";
       this->SetError(e.str());
       return false;
-      }
-    fname = this->Filename.GetString();
     }
+    fname = this->Filename.GetString();
+  }
 
   // Get the file to write.
-  if(cmSystemTools::FileIsFullPath(fname.c_str()))
-    {
-    if(!this->Makefile->CanIWriteThisFile(fname.c_str()))
-      {
+  if (cmSystemTools::FileIsFullPath(fname.c_str())) {
+    if (!this->Makefile->CanIWriteThisFile(fname.c_str())) {
       std::ostringstream e;
       e << "FILE option given filename \"" << fname
         << "\" which is in the source tree.\n";
       this->SetError(e.str());
       return false;
-      }
     }
-  else
-    {
+  } else {
     // Interpret relative paths with respect to the current build dir.
     std::string dir = this->Makefile->GetCurrentBinaryDirectory();
     fname = dir + "/" + fname;
-    }
+  }
 
   std::vector<std::string> targets;
 
-  cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator();
+  cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
 
-  if(args[0] == "EXPORT")
-    {
-    if (this->Append.IsEnabled())
-      {
+  if (args[0] == "EXPORT") {
+    if (this->Append.IsEnabled()) {
       std::ostringstream e;
       e << "EXPORT signature does not recognise the APPEND option.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
-    if (this->ExportOld.IsEnabled())
-      {
+    if (this->ExportOld.IsEnabled()) {
       std::ostringstream e;
       e << "EXPORT signature does not recognise the "
-        "EXPORT_LINK_INTERFACE_LIBRARIES option.";
+           "EXPORT_LINK_INTERFACE_LIBRARIES option.";
       this->SetError(e.str());
       return false;
-      }
+    }
 
-    cmExportSetMap &setMap = gg->GetExportSets();
+    cmExportSetMap& setMap = gg->GetExportSets();
     std::string setName = this->ExportSetName.GetString();
-    if (setMap.find(setName) == setMap.end())
-      {
+    if (setMap.find(setName) == setMap.end()) {
       std::ostringstream e;
       e << "Export set \"" << setName << "\" not found.";
       this->SetError(e.str());
       return false;
-      }
-    this->ExportSet = setMap[setName];
     }
-  else if (this->Targets.WasFound())
-    {
-    for(std::vector<std::string>::const_iterator
-        currentTarget = this->Targets.GetVector().begin();
-        currentTarget != this->Targets.GetVector().end();
-        ++currentTarget)
-      {
-      if (this->Makefile->IsAlias(*currentTarget))
-        {
+    this->ExportSet = setMap[setName];
+  } else if (this->Targets.WasFound()) {
+    for (std::vector<std::string>::const_iterator currentTarget =
+           this->Targets.GetVector().begin();
+         currentTarget != this->Targets.GetVector().end(); ++currentTarget) {
+      if (this->Makefile->IsAlias(*currentTarget)) {
         std::ostringstream e;
         e << "given ALIAS target \"" << *currentTarget
           << "\" which may not be exported.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
-      if(cmTarget* target = gg->FindTarget(*currentTarget))
-        {
-        if(target->GetType() == cmState::OBJECT_LIBRARY)
-          {
+      if (cmTarget* target = gg->FindTarget(*currentTarget)) {
+        if (target->GetType() == cmState::OBJECT_LIBRARY) {
           std::ostringstream e;
           e << "given OBJECT library \"" << *currentTarget
             << "\" which may not be exported.";
           this->SetError(e.str());
           return false;
-          }
-        if (target->GetType() == cmState::UTILITY)
-          {
-          this->SetError("given custom target \"" + *currentTarget
-                         + "\" which may not be exported.");
+        }
+        if (target->GetType() == cmState::UTILITY) {
+          this->SetError("given custom target \"" + *currentTarget +
+                         "\" which may not be exported.");
           return false;
-          }
         }
-      else
-        {
+      } else {
         std::ostringstream e;
         e << "given target \"" << *currentTarget
           << "\" which is not built by this project.";
         this->SetError(e.str());
         return false;
-        }
-      targets.push_back(*currentTarget);
       }
-    if (this->Append.IsEnabled())
-      {
-      if (cmExportBuildFileGenerator *ebfg = gg->GetExportedTargetsFile(fname))
-        {
+      targets.push_back(*currentTarget);
+    }
+    if (this->Append.IsEnabled()) {
+      if (cmExportBuildFileGenerator* ebfg =
+            gg->GetExportedTargetsFile(fname)) {
         ebfg->AppendTargets(targets);
         return true;
-        }
       }
     }
-  else
-    {
+  } else {
     this->SetError("EXPORT or TARGETS specifier missing.");
     return false;
-    }
+  }
 
   // Setup export file generation.
-  cmExportBuildFileGenerator *ebfg = new cmExportBuildFileGenerator;
+  cmExportBuildFileGenerator* ebfg = new cmExportBuildFileGenerator;
   ebfg->SetExportFile(fname.c_str());
   ebfg->SetNamespace(this->Namespace.GetCString());
   ebfg->SetAppendMode(this->Append.IsEnabled());
-  if (this->ExportSet)
-    {
+  if (this->ExportSet) {
     ebfg->SetExportSet(this->ExportSet);
-    }
-  else
-    {
+  } else {
     ebfg->SetTargets(targets);
-    }
+  }
   this->Makefile->AddExportBuildFileGenerator(ebfg);
   ebfg->SetExportOld(this->ExportOld.IsEnabled());
 
   // Compute the set of configurations exported.
   std::vector<std::string> configurationTypes;
   this->Makefile->GetConfigurations(configurationTypes);
-  if(configurationTypes.empty())
-    {
+  if (configurationTypes.empty()) {
     configurationTypes.push_back("");
-    }
-  for(std::vector<std::string>::const_iterator
-        ci = configurationTypes.begin();
-      ci != configurationTypes.end(); ++ci)
-    {
+  }
+  for (std::vector<std::string>::const_iterator ci =
+         configurationTypes.begin();
+       ci != configurationTypes.end(); ++ci) {
     ebfg->AddConfiguration(*ci);
-    }
-  if (this->ExportSet)
-    {
+  }
+  if (this->ExportSet) {
     gg->AddBuildExportExportSet(ebfg);
-    }
-  else
-    {
+  } else {
     gg->AddBuildExportSet(ebfg);
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
 {
   // Parse PACKAGE mode arguments.
-  enum Doing { DoingNone, DoingPackage };
+  enum Doing
+  {
+    DoingNone,
+    DoingPackage
+  };
   Doing doing = DoingPackage;
   std::string package;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(doing == DoingPackage)
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (doing == DoingPackage) {
       package = args[i];
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "PACKAGE given unknown argument: " << args[i];
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Verify the package name.
-  if(package.empty())
-    {
+  if (package.empty()) {
     this->SetError("PACKAGE must be given a package name.");
     return false;
-    }
+  }
   const char* packageExpr = "^[A-Za-z0-9_.-]+$";
   cmsys::RegularExpression packageRegex(packageExpr);
-  if(!packageRegex.find(package.c_str()))
-    {
+  if (!packageRegex.find(package.c_str())) {
     std::ostringstream e;
     e << "PACKAGE given invalid package name \"" << package << "\".  "
       << "Package names must match \"" << packageExpr << "\".";
     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"))
-    {
+  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
@@ -311,29 +266,24 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
 }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-# include <windows.h>
-# undef GetCurrentDirectory
-//----------------------------------------------------------------------------
+#include <windows.h>
+#undef GetCurrentDirectory
 void cmExportCommand::ReportRegistryError(std::string const& msg,
-                                          std::string const& key,
-                                          long err)
+                                          std::string const& key, long err)
 {
   std::ostringstream e;
   e << msg << "\n"
     << "  HKEY_CURRENT_USER\\" << key << "\n";
   wchar_t winmsg[1024];
-  if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
-                   FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
-                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                   winmsg, 1024, 0) > 0)
-    {
+  if (FormatMessageW(
+        FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, err,
+        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), winmsg, 1024, 0) > 0) {
     e << "Windows reported:\n"
       << "  " << cmsys::Encoding::ToNarrow(winmsg);
-    }
+  }
   this->Makefile->IssueMessage(cmake::WARNING, e.str());
 }
 
-//----------------------------------------------------------------------------
 void cmExportCommand::StorePackageRegistryWin(std::string const& package,
                                               const char* content,
                                               const char* hash)
@@ -341,32 +291,28 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
   std::string key = "Software\\Kitware\\CMake\\Packages\\";
   key += package;
   HKEY hKey;
-  LONG err = RegCreateKeyExW(HKEY_CURRENT_USER,
-                            cmsys::Encoding::ToWide(key).c_str(),
-                            0, 0, REG_OPTION_NON_VOLATILE,
-                            KEY_SET_VALUE, 0, &hKey, 0);
-  if(err != ERROR_SUCCESS)
-    {
-    this->ReportRegistryError(
-      "Cannot create/open registry key", key, err);
+  LONG err =
+    RegCreateKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(key).c_str(), 0,
+                    0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, &hKey, 0);
+  if (err != ERROR_SUCCESS) {
+    this->ReportRegistryError("Cannot create/open registry key", key, err);
     return;
-    }
+  }
 
   std::wstring wcontent = cmsys::Encoding::ToWide(content);
-  err = RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(),
-                       0, REG_SZ, (BYTE const*)wcontent.c_str(),
-                       static_cast<DWORD>(wcontent.size()+1)*sizeof(wchar_t));
+  err =
+    RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(), 0, REG_SZ,
+                   (BYTE const*)wcontent.c_str(),
+                   static_cast<DWORD>(wcontent.size() + 1) * sizeof(wchar_t));
   RegCloseKey(hKey);
-  if(err != ERROR_SUCCESS)
-    {
+  if (err != ERROR_SUCCESS) {
     std::ostringstream msg;
     msg << "Cannot set registry value \"" << hash << "\" under key";
     this->ReportRegistryError(msg.str(), key, err);
     return;
-    }
+  }
 }
 #else
-//----------------------------------------------------------------------------
 void cmExportCommand::StorePackageRegistryDir(std::string const& package,
                                               const char* content,
                                               const char* hash)
@@ -374,19 +320,17 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
 #if defined(__HAIKU__)
   char dir[B_PATH_NAME_LENGTH];
   if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) !=
-      B_OK)
-    {
+      B_OK) {
     return;
-    }
+  }
   std::string fname = dir;
   fname += "/cmake/packages/";
   fname += package;
 #else
   const char* home = cmSystemTools::GetEnv("HOME");
-  if(!home)
-    {
+  if (!home) {
     return;
-    }
+  }
   std::string fname = home;
   cmSystemTools::ConvertToUnixSlashes(fname);
   fname += "/.cmake/packages/";
@@ -395,21 +339,19 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
   cmSystemTools::MakeDirectory(fname.c_str());
   fname += "/";
   fname += hash;
-  if(!cmSystemTools::FileExists(fname.c_str()))
-    {
+  if (!cmSystemTools::FileExists(fname.c_str())) {
     cmGeneratedFileStream entry(fname.c_str(), true);
-    if(entry)
-      {
+    if (entry) {
       entry << content << "\n";
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
+      /* clang-format off */
       e << "Cannot create package registry file:\n"
         << "  " << fname << "\n"
         << cmSystemTools::GetLastSystemError() << "\n";
+      /* clang-format on */
       this->Makefile->IssueMessage(cmake::WARNING, e.str());
-      }
     }
+  }
 }
 #endif
diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h
index f9506bb..a71393a 100644
--- a/Source/cmExportCommand.h
+++ b/Source/cmExportCommand.h
@@ -30,22 +30,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmExportCommand;
-    }
+  virtual cmCommand* Clone() { return new cmExportCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "export";}
+  virtual std::string GetName() const { return "export"; }
 
   cmTypeMacro(cmExportCommand, cmCommand);
 
@@ -58,19 +55,18 @@ private:
   cmCAString Filename;
   cmCAEnabler ExportOld;
 
-  cmExportSet *ExportSet;
+  cmExportSet* ExportSet;
 
   friend class cmExportBuildFileGenerator;
   std::string ErrorMessage;
 
   bool HandlePackage(std::vector<std::string> const& args);
-  void StorePackageRegistryWin(std::string const& package,
-                               const char* content, const char* hash);
-  void StorePackageRegistryDir(std::string const& package,
-                               const char* content, const char* hash);
+  void StorePackageRegistryWin(std::string const& package, const char* content,
+                               const char* hash);
+  void StorePackageRegistryDir(std::string const& package, const char* content,
+                               const char* hash);
   void ReportRegistryError(std::string const& msg, std::string const& key,
                            long err);
 };
 
-
 #endif
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index c005995..736c7da 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -11,112 +11,102 @@
 ============================================================================*/
 #include "cmExportFileGenerator.h"
 
+#include "cmAlgorithms.h"
+#include "cmComputeLinkInformation.h"
 #include "cmExportSet.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
 #include "cmInstallExportGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
+#include "cmOutputConverter.h"
 #include "cmSystemTools.h"
 #include "cmTargetExport.h"
 #include "cmVersion.h"
-#include "cmComputeLinkInformation.h"
-#include "cmAlgorithms.h"
-#include "cmOutputConverter.h"
 
-#include <cmsys/auto_ptr.hxx>
-#include <cmsys/FStream.hxx>
 #include <assert.h>
+#include <cmsys/FStream.hxx>
+#include <cmsys/auto_ptr.hxx>
 
-//----------------------------------------------------------------------------
 static std::string cmExportFileGeneratorEscape(std::string const& str)
 {
   // Escape a property value for writing into a .cmake file.
   std::string result = cmOutputConverter::EscapeForCMake(str);
   // Un-escape variable references generated by our own export code.
-  cmSystemTools::ReplaceString(result,
-                               "\\${_IMPORT_PREFIX}",
+  cmSystemTools::ReplaceString(result, "\\${_IMPORT_PREFIX}",
                                "${_IMPORT_PREFIX}");
-  cmSystemTools::ReplaceString(result,
-                               "\\${CMAKE_IMPORT_LIBRARY_SUFFIX}",
+  cmSystemTools::ReplaceString(result, "\\${CMAKE_IMPORT_LIBRARY_SUFFIX}",
                                "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
   return result;
 }
 
-//----------------------------------------------------------------------------
 cmExportFileGenerator::cmExportFileGenerator()
 {
   this->AppendMode = false;
   this->ExportOld = false;
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::AddConfiguration(const std::string& config)
 {
   this->Configurations.push_back(config);
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::SetExportFile(const char* mainFile)
 {
   this->MainImportFile = mainFile;
-  this->FileDir =
-    cmSystemTools::GetFilenamePath(this->MainImportFile);
+  this->FileDir = cmSystemTools::GetFilenamePath(this->MainImportFile);
   this->FileBase =
     cmSystemTools::GetFilenameWithoutLastExtension(this->MainImportFile);
   this->FileExt =
     cmSystemTools::GetFilenameLastExtension(this->MainImportFile);
 }
 
-//----------------------------------------------------------------------------
 const char* cmExportFileGenerator::GetMainExportFileName() const
 {
   return this->MainImportFile.c_str();
 }
 
-//----------------------------------------------------------------------------
 bool cmExportFileGenerator::GenerateImportFile()
 {
   // Open the output file to generate it.
   cmsys::auto_ptr<cmsys::ofstream> foutPtr;
-  if(this->AppendMode)
-    {
+  if (this->AppendMode) {
     // Open for append.
-    cmsys::auto_ptr<cmsys::ofstream>
-      ap(new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
+    cmsys::auto_ptr<cmsys::ofstream> ap(
+      new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
     foutPtr = ap;
-    }
-  else
-    {
+  } else {
     // Generate atomically and with copy-if-different.
-    cmsys::auto_ptr<cmGeneratedFileStream>
-      ap(new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
+    cmsys::auto_ptr<cmGeneratedFileStream> ap(
+      new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
     ap->SetCopyIfDifferent(true);
     foutPtr = ap;
-    }
-  if(!foutPtr.get() || !*foutPtr)
-    {
+  }
+  if (!foutPtr.get() || !*foutPtr) {
     std::string se = cmSystemTools::GetLastSystemError();
     std::ostringstream e;
-    e << "cannot write to file \"" << this->MainImportFile
-      << "\": " << se;
+    e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
     cmSystemTools::Error(e.str().c_str());
     return false;
-    }
+  }
   std::ostream& os = *foutPtr;
 
   // Protect that file against use with older CMake versions.
+  /* clang-format off */
   os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
   os << "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"
      << "   message(FATAL_ERROR \"CMake >= 2.6.0 required\")\n"
      << "endif()\n";
+  /* clang-format on */
 
   // Isolate the file policy level.
   // We use 2.6 here instead of the current version because newer
   // versions of CMake should be able to export files imported by 2.6
   // until the import format changes.
+  /* clang-format off */
   os << "cmake_policy(PUSH)\n"
      << "cmake_policy(VERSION 2.6)\n";
+  /* clang-format on */
 
   // Start with the import file header.
   this->GenerateImportHeaderCode(os);
@@ -131,123 +121,103 @@ bool cmExportFileGenerator::GenerateImportFile()
   return result;
 }
 
-//----------------------------------------------------------------------------
-void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
-                                    const std::string& config,
-                                    std::vector<std::string> &missingTargets)
+void cmExportFileGenerator::GenerateImportConfig(
+  std::ostream& os, const std::string& config,
+  std::vector<std::string>& missingTargets)
 {
   // Construct the property configuration suffix.
   std::string suffix = "_";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     suffix += cmSystemTools::UpperCase(config);
-    }
-  else
-    {
+  } else {
     suffix += "NOCONFIG";
-    }
+  }
 
   // Generate the per-config target information.
   this->GenerateImportTargetsConfig(os, config, suffix, missingTargets);
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::PopulateInterfaceProperty(
-                                              const std::string& propName,
-                                              cmGeneratorTarget *target,
-                                              ImportPropertyMap &properties)
+  const std::string& propName, cmGeneratorTarget* target,
+  ImportPropertyMap& properties)
 {
-  const char *input = target->GetProperty(propName);
-  if (input)
-    {
+  const char* input = target->GetProperty(propName);
+  if (input) {
     properties[propName] = input;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::PopulateInterfaceProperty(
-                      const std::string& propName,
-                      const std::string& outputName,
-                      cmGeneratorTarget *target,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets)
+  const std::string& propName, const std::string& outputName,
+  cmGeneratorTarget* target,
+  cmGeneratorExpression::PreprocessContext preprocessRule,
+  ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
 {
-  const char *input = target->GetProperty(propName);
-  if (input)
-    {
-    if (!*input)
-      {
+  const char* input = target->GetProperty(propName);
+  if (input) {
+    if (!*input) {
       // Set to empty
       properties[outputName] = "";
       return;
-      }
+    }
 
-    std::string prepro = cmGeneratorExpression::Preprocess(input,
-                                                           preprocessRule);
-    if (!prepro.empty())
-      {
+    std::string prepro =
+      cmGeneratorExpression::Preprocess(input, preprocessRule);
+    if (!prepro.empty()) {
       this->ResolveTargetsInGeneratorExpressions(prepro, target,
                                                  missingTargets);
       properties[outputName] = prepro;
-      }
     }
+  }
 }
 
-void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
-                                                    const char *versionString)
+void cmExportFileGenerator::GenerateRequiredCMakeVersion(
+  std::ostream& os, const char* versionString)
 {
+  /* clang-format off */
   os << "if(CMAKE_VERSION VERSION_LESS " << versionString << ")\n"
         "  message(FATAL_ERROR \"This file relies on consumers using "
         "CMake " << versionString << " or greater.\")\n"
         "endif()\n\n";
+  /* clang-format on */
 }
 
-//----------------------------------------------------------------------------
 bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
-                      cmGeneratorTarget *target,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets)
+  cmGeneratorTarget* target,
+  cmGeneratorExpression::PreprocessContext preprocessRule,
+  ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
 {
-  if(!target->IsLinkable())
-    {
+  if (!target->IsLinkable()) {
     return false;
-    }
-  const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
-  if (input)
-    {
-    std::string prepro = cmGeneratorExpression::Preprocess(input,
-                                                           preprocessRule);
-    if (!prepro.empty())
-      {
-      this->ResolveTargetsInGeneratorExpressions(prepro, target,
-                                                 missingTargets,
-                                                 ReplaceFreeTargets);
+  }
+  const char* input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
+  if (input) {
+    std::string prepro =
+      cmGeneratorExpression::Preprocess(input, preprocessRule);
+    if (!prepro.empty()) {
+      this->ResolveTargetsInGeneratorExpressions(
+        prepro, target, missingTargets, ReplaceFreeTargets);
       properties["INTERFACE_LINK_LIBRARIES"] = prepro;
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 static bool isSubDirectory(const char* a, const char* b)
 {
   return (cmSystemTools::ComparePath(a, b) ||
           cmSystemTools::IsSubDirectory(a, b));
 }
 
-//----------------------------------------------------------------------------
-static bool checkInterfaceDirs(const std::string &prepro,
-                      cmGeneratorTarget *target, const std::string& prop)
+static bool checkInterfaceDirs(const std::string& prepro,
+                               cmGeneratorTarget* target,
+                               const std::string& prop)
 {
   const char* installDir =
-            target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
-  const char* topSourceDir =
-      target->GetLocalGenerator()->GetSourceDirectory();
-  const char* topBinaryDir =
-      target->GetLocalGenerator()->GetBinaryDirectory();
+    target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+  const char* topSourceDir = target->GetLocalGenerator()->GetSourceDirectory();
+  const char* topBinaryDir = target->GetLocalGenerator()->GetBinaryDirectory();
 
   std::vector<std::string> parts;
   cmGeneratorExpression::Split(prepro, parts);
@@ -256,22 +226,17 @@ static bool checkInterfaceDirs(const std::string &prepro,
 
   bool hadFatalError = false;
 
-  for(std::vector<std::string>::iterator li = parts.begin();
-      li != parts.end(); ++li)
-    {
+  for (std::vector<std::string>::iterator li = parts.begin();
+       li != parts.end(); ++li) {
     size_t genexPos = cmGeneratorExpression::Find(*li);
-    if (genexPos == 0)
-      {
+    if (genexPos == 0) {
       continue;
-      }
+    }
     cmake::MessageType messageType = cmake::FATAL_ERROR;
     std::ostringstream e;
-    if (genexPos != std::string::npos)
-      {
-      if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
-        {
-        switch (target->GetPolicyStatusCMP0041())
-          {
+    if (genexPos != std::string::npos) {
+      if (prop == "INTERFACE_INCLUDE_DIRECTORIES") {
+        switch (target->GetPolicyStatusCMP0041()) {
           case cmPolicies::WARN:
             messageType = cmake::WARNING;
             e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0041) << "\n";
@@ -283,28 +248,25 @@ static bool checkInterfaceDirs(const std::string &prepro,
           case cmPolicies::NEW:
             hadFatalError = true;
             break; // Issue fatal message.
-          }
         }
-      else
-        {
+      } else {
         hadFatalError = true;
-        }
       }
-    if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}"))
-      {
+    }
+    if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) {
       continue;
-      }
-    if (!cmSystemTools::FileIsFullPath(li->c_str()))
-      {
+    }
+    if (!cmSystemTools::FileIsFullPath(li->c_str())) {
+      /* clang-format off */
       e << "Target \"" << target->GetName() << "\" " << prop <<
            " property contains relative path:\n"
            "  \"" << *li << "\"";
+      /* clang-format on */
       target->GetLocalGenerator()->IssueMessage(messageType, e.str());
-      }
+    }
     bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
     bool inSource = isSubDirectory(li->c_str(), topSourceDir);
-    if (isSubDirectory(li->c_str(), installDir))
-      {
+    if (isSubDirectory(li->c_str(), installDir)) {
       // 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
@@ -313,26 +275,25 @@ static bool checkInterfaceDirs(const std::string &prepro,
         (!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
         (!inSource || isSubDirectory(installDir, topSourceDir));
 
-      if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
-        {
-        if (!shouldContinue)
-          {
-          switch(target->GetPolicyStatusCMP0052())
-            {
-            case cmPolicies::WARN:
-              {
+      if (prop == "INTERFACE_INCLUDE_DIRECTORIES") {
+        if (!shouldContinue) {
+          switch (target->GetPolicyStatusCMP0052()) {
+            case cmPolicies::WARN: {
               std::ostringstream s;
               s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n";
-              s << "Directory:\n    \"" << *li << "\"\nin "
-                "INTERFACE_INCLUDE_DIRECTORIES of target \""
+              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;
+                                        "directory:\n    \""
+                << installDir << "\"\nhowever it is also "
+                                 "a subdirectory of the "
+                << (inBinary ? "build" : "source") << " tree:\n    \""
+                << (inBinary ? topBinaryDir : topSourceDir) << "\""
+                << std::endl;
               target->GetLocalGenerator()->IssueMessage(cmake::AUTHOR_WARNING,
-                                                  s.str());
-              }
+                                                        s.str());
+            }
             case cmPolicies::OLD:
               shouldContinue = true;
               break;
@@ -340,247 +301,207 @@ static bool checkInterfaceDirs(const std::string &prepro,
             case cmPolicies::REQUIRED_IF_USED:
             case cmPolicies::NEW:
               break;
-            }
           }
         }
-      if (shouldContinue)
-        {
+      }
+      if (shouldContinue) {
         continue;
-        }
       }
-    if (inBinary)
-      {
+    }
+    if (inBinary) {
+      /* clang-format off */
       e << "Target \"" << target->GetName() << "\" " << prop <<
            " property contains path:\n"
            "  \"" << *li << "\"\nwhich is prefixed in the build directory.";
+      /* clang-format on */
       target->GetLocalGenerator()->IssueMessage(messageType, e.str());
-      }
-    if (!inSourceBuild)
-      {
-      if (inSource)
-        {
-        e << "Target \"" << target->GetName() << "\" " << prop <<
-            " property contains path:\n"
-            "  \"" << *li << "\"\nwhich is prefixed in the source directory.";
+    }
+    if (!inSourceBuild) {
+      if (inSource) {
+        e << "Target \"" << target->GetName() << "\" " << prop
+          << " property contains path:\n"
+             "  \""
+          << *li << "\"\nwhich is prefixed in the source directory.";
         target->GetLocalGenerator()->IssueMessage(messageType, e.str());
-        }
       }
     }
+  }
   return !hadFatalError;
 }
 
-//----------------------------------------------------------------------------
-static void prefixItems(std::string &exportDirs)
+static void prefixItems(std::string& exportDirs)
 {
   std::vector<std::string> entries;
   cmGeneratorExpression::Split(exportDirs, entries);
   exportDirs = "";
-  const char *sep = "";
-  for(std::vector<std::string>::const_iterator ei = entries.begin();
-      ei != entries.end(); ++ei)
-    {
+  const char* sep = "";
+  for (std::vector<std::string>::const_iterator ei = entries.begin();
+       ei != entries.end(); ++ei) {
     exportDirs += sep;
     sep = ";";
-    if (!cmSystemTools::FileIsFullPath(ei->c_str())
-        && ei->find("${_IMPORT_PREFIX}") == std::string::npos)
-      {
+    if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
+        ei->find("${_IMPORT_PREFIX}") == std::string::npos) {
       exportDirs += "${_IMPORT_PREFIX}/";
-      }
-    exportDirs += *ei;
     }
+    exportDirs += *ei;
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::PopulateSourcesInterface(
-                      cmTargetExport *tei,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets)
+  cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+  ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
 {
   cmGeneratorTarget* gt = tei->Target;
   assert(preprocessRule == cmGeneratorExpression::InstallInterface);
 
-  const char *propName = "INTERFACE_SOURCES";
-  const char *input = gt->GetProperty(propName);
+  const char* propName = "INTERFACE_SOURCES";
+  const char* input = gt->GetProperty(propName);
 
-  if (!input)
-    {
+  if (!input) {
     return;
-    }
+  }
 
-  if (!*input)
-    {
+  if (!*input) {
     properties[propName] = "";
     return;
-    }
+  }
 
-  std::string prepro = cmGeneratorExpression::Preprocess(input,
-                                                         preprocessRule,
-                                                         true);
-  if (!prepro.empty())
-    {
-    this->ResolveTargetsInGeneratorExpressions(prepro, gt,
-                                                missingTargets);
+  std::string prepro =
+    cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+  if (!prepro.empty()) {
+    this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
 
-    if (!checkInterfaceDirs(prepro, gt, propName))
-      {
+    if (!checkInterfaceDirs(prepro, gt, propName)) {
       return;
-      }
-    properties[propName] = prepro;
     }
+    properties[propName] = prepro;
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
-                      cmTargetExport *tei,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets)
+  cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+  ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
 {
-  cmGeneratorTarget *target = tei->Target;
+  cmGeneratorTarget* target = tei->Target;
   assert(preprocessRule == cmGeneratorExpression::InstallInterface);
 
-  const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
-  const char *input = target->GetProperty(propName);
+  const char* propName = "INTERFACE_INCLUDE_DIRECTORIES";
+  const char* input = target->GetProperty(propName);
 
   cmGeneratorExpression ge;
 
   std::string dirs = cmGeneratorExpression::Preprocess(
-                                            tei->InterfaceIncludeDirectories,
-                                            preprocessRule,
-                                            true);
+    tei->InterfaceIncludeDirectories, preprocessRule, true);
   this->ReplaceInstallPrefix(dirs);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
-  std::string exportDirs = cge->Evaluate(target->GetLocalGenerator(), "",
-                                         false, target);
+  std::string exportDirs =
+    cge->Evaluate(target->GetLocalGenerator(), "", false, target);
 
-  if (cge->GetHadContextSensitiveCondition())
-    {
+  if (cge->GetHadContextSensitiveCondition()) {
     cmLocalGenerator* lg = target->GetLocalGenerator();
     std::ostringstream e;
-    e << "Target \"" << target->GetName() << "\" is installed with "
-    "INCLUDES DESTINATION set to a context sensitive path.  Paths which "
-    "depend on the configuration, policy values or the link interface are "
-    "not supported.  Consider using target_include_directories instead.";
+    e << "Target \"" << target->GetName()
+      << "\" is installed with "
+         "INCLUDES DESTINATION set to a context sensitive path.  Paths which "
+         "depend on the configuration, policy values or the link interface "
+         "are "
+         "not supported.  Consider using target_include_directories instead.";
     lg->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
+  }
 
-  if (!input && exportDirs.empty())
-    {
+  if (!input && exportDirs.empty()) {
     return;
-    }
-  if ((input && !*input) && exportDirs.empty())
-    {
+  }
+  if ((input && !*input) && exportDirs.empty()) {
     // Set to empty
     properties[propName] = "";
     return;
-    }
+  }
 
   prefixItems(exportDirs);
 
-  std::string includes = (input?input:"");
+  std::string includes = (input ? input : "");
   const char* sep = input ? ";" : "";
   includes += sep + exportDirs;
-  std::string prepro = cmGeneratorExpression::Preprocess(includes,
-                                                         preprocessRule,
-                                                         true);
-  if (!prepro.empty())
-    {
-    this->ResolveTargetsInGeneratorExpressions(prepro, target,
-                                                missingTargets);
+  std::string prepro =
+    cmGeneratorExpression::Preprocess(includes, preprocessRule, true);
+  if (!prepro.empty()) {
+    this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets);
 
-    if (!checkInterfaceDirs(prepro, target, propName))
-      {
+    if (!checkInterfaceDirs(prepro, target, propName)) {
       return;
-      }
-    properties[propName] = prepro;
     }
+    properties[propName] = prepro;
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::PopulateInterfaceProperty(
-                      const std::string& propName,
-                      cmGeneratorTarget* target,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets)
+  const std::string& propName, cmGeneratorTarget* target,
+  cmGeneratorExpression::PreprocessContext preprocessRule,
+  ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
 {
   this->PopulateInterfaceProperty(propName, propName, target, preprocessRule,
-                            properties, missingTargets);
+                                  properties, missingTargets);
 }
 
-
-//----------------------------------------------------------------------------
-void getPropertyContents(cmGeneratorTarget const* tgt,
-                         const std::string& prop,
-                         std::set<std::string> &ifaceProperties)
+void getPropertyContents(cmGeneratorTarget const* tgt, const std::string& prop,
+                         std::set<std::string>& ifaceProperties)
 {
-  const char *p = tgt->GetProperty(prop);
-  if (!p)
-    {
+  const char* p = tgt->GetProperty(prop);
+  if (!p) {
     return;
-    }
+  }
   std::vector<std::string> content;
   cmSystemTools::ExpandListArgument(p, content);
   ifaceProperties.insert(content.begin(), content.end());
 }
 
-//----------------------------------------------------------------------------
-void getCompatibleInterfaceProperties(cmGeneratorTarget *target,
-                                      std::set<std::string> &ifaceProperties,
+void getCompatibleInterfaceProperties(cmGeneratorTarget* target,
+                                      std::set<std::string>& ifaceProperties,
                                       const std::string& config)
 {
-  cmComputeLinkInformation *info = target->GetLinkInformation(config);
+  cmComputeLinkInformation* info = target->GetLinkInformation(config);
 
-  if (!info)
-    {
+  if (!info) {
     cmLocalGenerator* lg = target->GetLocalGenerator();
     std::ostringstream e;
-    e << "Exporting the target \"" << target->GetName() << "\" is not "
-        "allowed since its linker language cannot be determined";
+    e << "Exporting the target \"" << target->GetName()
+      << "\" is not "
+         "allowed since its linker language cannot be determined";
     lg->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
+  }
 
-  const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
+  const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
 
-  for(cmComputeLinkInformation::ItemVector::const_iterator li =
-      deps.begin();
-      li != deps.end(); ++li)
-    {
-    if (!li->Target)
-      {
+  for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
+       li != deps.end(); ++li) {
+    if (!li->Target) {
       continue;
-      }
-    getPropertyContents(li->Target,
-                        "COMPATIBLE_INTERFACE_BOOL",
+    }
+    getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_BOOL",
                         ifaceProperties);
-    getPropertyContents(li->Target,
-                        "COMPATIBLE_INTERFACE_STRING",
+    getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_STRING",
                         ifaceProperties);
-    getPropertyContents(li->Target,
-                        "COMPATIBLE_INTERFACE_NUMBER_MIN",
+    getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
                         ifaceProperties);
-    getPropertyContents(li->Target,
-                        "COMPATIBLE_INTERFACE_NUMBER_MAX",
+    getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
                         ifaceProperties);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
-                                cmGeneratorTarget *gtarget,
-                                ImportPropertyMap &properties)
+  cmGeneratorTarget* gtarget, ImportPropertyMap& properties)
 {
-  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL",
-                                gtarget, properties);
-  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING",
-                                gtarget, properties);
-  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN",
-                                gtarget, properties);
-  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX",
-                                gtarget, properties);
+  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", gtarget,
+                                  properties);
+  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", gtarget,
+                                  properties);
+  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", gtarget,
+                                  properties);
+  this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", gtarget,
+                                  properties);
 
   std::set<std::string> ifaceProperties;
 
@@ -591,342 +512,272 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
   getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX",
                       ifaceProperties);
 
-  if (gtarget->GetType() != cmState::INTERFACE_LIBRARY)
-    {
+  if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) {
     getCompatibleInterfaceProperties(gtarget, ifaceProperties, "");
 
     std::vector<std::string> configNames;
     gtarget->Target->GetMakefile()->GetConfigurations(configNames);
 
     for (std::vector<std::string>::const_iterator ci = configNames.begin();
-      ci != configNames.end(); ++ci)
-      {
+         ci != configNames.end(); ++ci) {
       getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
-      }
     }
+  }
 
   for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
-    it != ifaceProperties.end(); ++it)
-    {
-    this->PopulateInterfaceProperty("INTERFACE_" + *it,
-                                    gtarget, properties);
-    }
+       it != ifaceProperties.end(); ++it) {
+    this->PopulateInterfaceProperty("INTERFACE_" + *it, gtarget, properties);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateInterfaceProperties(
-                                        const cmGeneratorTarget* target,
-                                        std::ostream& os,
-                                        const ImportPropertyMap &properties)
+  const cmGeneratorTarget* target, std::ostream& os,
+  const ImportPropertyMap& properties)
 {
-  if (!properties.empty())
-    {
+  if (!properties.empty()) {
     std::string targetName = this->Namespace;
     targetName += target->GetExportName();
     os << "set_target_properties(" << targetName << " PROPERTIES\n";
-    for(ImportPropertyMap::const_iterator pi = properties.begin();
-        pi != properties.end(); ++pi)
-      {
-      os << "  " << pi->first << " "
-         << cmExportFileGeneratorEscape(pi->second) << "\n";
-      }
-    os << ")\n\n";
+    for (ImportPropertyMap::const_iterator pi = properties.begin();
+         pi != properties.end(); ++pi) {
+      os << "  " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
+         << "\n";
     }
+    os << ")\n\n";
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmExportFileGenerator::AddTargetNamespace(std::string &input,
-                                    cmGeneratorTarget* target,
-                                    std::vector<std::string> &missingTargets)
+bool cmExportFileGenerator::AddTargetNamespace(
+  std::string& input, cmGeneratorTarget* target,
+  std::vector<std::string>& missingTargets)
 {
-  cmLocalGenerator *lg = target->GetLocalGenerator();
+  cmLocalGenerator* lg = target->GetLocalGenerator();
 
-  cmGeneratorTarget *tgt = lg->FindGeneratorTargetToUse(input);
-  if (!tgt)
-    {
+  cmGeneratorTarget* tgt = lg->FindGeneratorTargetToUse(input);
+  if (!tgt) {
     return false;
-    }
+  }
 
-  if(tgt->IsImported())
-    {
+  if (tgt->IsImported()) {
     return true;
-    }
-  if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
-    {
+  }
+  if (this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) {
     input = this->Namespace + tgt->GetExportName();
-    }
-  else
-    {
+  } else {
     std::string namespacedTarget;
-    this->HandleMissingTarget(namespacedTarget, missingTargets,
-                              target, tgt);
-    if (!namespacedTarget.empty())
-      {
+    this->HandleMissingTarget(namespacedTarget, missingTargets, target, tgt);
+    if (!namespacedTarget.empty()) {
       input = namespacedTarget;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
-                                    std::string &input,
-                                    cmGeneratorTarget* target,
-                                    std::vector<std::string> &missingTargets,
-                                    FreeTargetsReplace replace)
+void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
+  std::string& input, cmGeneratorTarget* target,
+  std::vector<std::string>& missingTargets, FreeTargetsReplace replace)
 {
-  if (replace == NoReplaceFreeTargets)
-    {
+  if (replace == NoReplaceFreeTargets) {
     this->ResolveTargetsInGeneratorExpression(input, target, missingTargets);
     return;
-    }
+  }
   std::vector<std::string> parts;
   cmGeneratorExpression::Split(input, parts);
 
   std::string sep;
   input = "";
-  for(std::vector<std::string>::iterator li = parts.begin();
-      li != parts.end(); ++li)
-    {
-    if (cmGeneratorExpression::Find(*li) == std::string::npos)
-      {
+  for (std::vector<std::string>::iterator li = parts.begin();
+       li != parts.end(); ++li) {
+    if (cmGeneratorExpression::Find(*li) == std::string::npos) {
       this->AddTargetNamespace(*li, target, missingTargets);
-      }
-    else
-      {
-      this->ResolveTargetsInGeneratorExpression(
-                                    *li,
-                                    target,
-                                    missingTargets);
-      }
+    } else {
+      this->ResolveTargetsInGeneratorExpression(*li, target, missingTargets);
+    }
     input += sep + *li;
     sep = ";";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
-                                    std::string &input,
-                                    cmGeneratorTarget* target,
-                                    std::vector<std::string> &missingTargets)
+void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
+  std::string& input, cmGeneratorTarget* target,
+  std::vector<std::string>& missingTargets)
 {
   std::string::size_type pos = 0;
   std::string::size_type lastPos = pos;
 
-  while((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos)
-    {
-    std::string::size_type nameStartPos = pos +
-                                            sizeof("$<TARGET_PROPERTY:") - 1;
-    std::string::size_type closePos = input.find(">", nameStartPos);
-    std::string::size_type commaPos = input.find(",", nameStartPos);
+  while ((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != input.npos) {
+    std::string::size_type nameStartPos =
+      pos + sizeof("$<TARGET_PROPERTY:") - 1;
+    std::string::size_type closePos = input.find('>', nameStartPos);
+    std::string::size_type commaPos = input.find(',', nameStartPos);
     std::string::size_type nextOpenPos = input.find("$<", nameStartPos);
-    if (commaPos == input.npos // Implied 'this' target
-        || closePos == input.npos // Imcomplete expression.
-        || closePos < commaPos // Implied 'this' target
+    if (commaPos == input.npos     // Implied 'this' target
+        || closePos == input.npos  // Imcomplete expression.
+        || closePos < commaPos     // Implied 'this' target
         || nextOpenPos < commaPos) // Non-literal
-      {
+    {
       lastPos = nameStartPos;
       continue;
-      }
+    }
 
-    std::string targetName = input.substr(nameStartPos,
-                                                commaPos - nameStartPos);
+    std::string targetName =
+      input.substr(nameStartPos, commaPos - nameStartPos);
 
-    if (this->AddTargetNamespace(targetName, target, missingTargets))
-      {
+    if (this->AddTargetNamespace(targetName, target, missingTargets)) {
       input.replace(nameStartPos, commaPos - nameStartPos, targetName);
-      }
-    lastPos = nameStartPos + targetName.size() + 1;
     }
+    lastPos = nameStartPos + targetName.size() + 1;
+  }
 
   std::string errorString;
   pos = 0;
   lastPos = pos;
-  while((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos)
-    {
+  while ((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos) {
     std::string::size_type nameStartPos = pos + sizeof("$<TARGET_NAME:") - 1;
-    std::string::size_type endPos = input.find(">", nameStartPos);
-    if (endPos == input.npos)
-      {
+    std::string::size_type endPos = input.find('>', nameStartPos);
+    if (endPos == input.npos) {
       errorString = "$<TARGET_NAME:...> expression incomplete";
       break;
-      }
-    std::string targetName = input.substr(nameStartPos,
-                                                endPos - nameStartPos);
-    if(targetName.find("$<") != input.npos)
-      {
+    }
+    std::string targetName = input.substr(nameStartPos, endPos - nameStartPos);
+    if (targetName.find("$<") != input.npos) {
       errorString = "$<TARGET_NAME:...> requires its parameter to be a "
                     "literal.";
       break;
-      }
-    if (!this->AddTargetNamespace(targetName, target, missingTargets))
-      {
+    }
+    if (!this->AddTargetNamespace(targetName, target, missingTargets)) {
       errorString = "$<TARGET_NAME:...> requires its parameter to be a "
                     "reachable target.";
       break;
-      }
+    }
     input.replace(pos, endPos - pos + 1, targetName);
     lastPos = endPos;
-    }
+  }
 
   pos = 0;
   lastPos = pos;
   while (errorString.empty() &&
-         (pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos)
-    {
+         (pos = input.find("$<LINK_ONLY:", lastPos)) != input.npos) {
     std::string::size_type nameStartPos = pos + sizeof("$<LINK_ONLY:") - 1;
-    std::string::size_type endPos = input.find(">", nameStartPos);
-    if (endPos == input.npos)
-      {
+    std::string::size_type endPos = input.find('>', nameStartPos);
+    if (endPos == input.npos) {
       errorString = "$<LINK_ONLY:...> expression incomplete";
       break;
-      }
+    }
     std::string libName = input.substr(nameStartPos, endPos - nameStartPos);
     if (cmGeneratorExpression::IsValidTargetName(libName) &&
-        this->AddTargetNamespace(libName, target, missingTargets))
-      {
+        this->AddTargetNamespace(libName, target, missingTargets)) {
       input.replace(nameStartPos, endPos - nameStartPos, libName);
-      }
-    lastPos = nameStartPos + libName.size() + 1;
     }
+    lastPos = nameStartPos + libName.size() + 1;
+  }
 
   this->ReplaceInstallPrefix(input);
 
-  if (!errorString.empty())
-    {
+  if (!errorString.empty()) {
     target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
+void cmExportFileGenerator::ReplaceInstallPrefix(std::string&)
 {
   // Do nothing
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator
-::SetImportLinkInterface(const std::string& config, std::string const& suffix,
-                    cmGeneratorExpression::PreprocessContext preprocessRule,
-                    cmGeneratorTarget* target, ImportPropertyMap& properties,
-                    std::vector<std::string>& missingTargets)
+void cmExportFileGenerator::SetImportLinkInterface(
+  const std::string& config, std::string const& suffix,
+  cmGeneratorExpression::PreprocessContext preprocessRule,
+  cmGeneratorTarget* target, ImportPropertyMap& properties,
+  std::vector<std::string>& missingTargets)
 {
   // Add the transitive link dependencies for this configuration.
-  cmLinkInterface const* iface = target->GetLinkInterface(config,
-                                                          target);
-  if (!iface)
-    {
+  cmLinkInterface const* iface = target->GetLinkInterface(config, target);
+  if (!iface) {
     return;
-    }
+  }
 
-  if (iface->ImplementationIsInterface)
-    {
+  if (iface->ImplementationIsInterface) {
     // Policy CMP0022 must not be NEW.
     this->SetImportLinkProperty(suffix, target,
                                 "IMPORTED_LINK_INTERFACE_LIBRARIES",
                                 iface->Libraries, properties, missingTargets);
     return;
-    }
+  }
 
-  const char *propContent;
+  const char* propContent;
 
-  if (const char *prop_suffixed = target->GetProperty(
-                    "LINK_INTERFACE_LIBRARIES" + suffix))
-    {
+  if (const char* prop_suffixed =
+        target->GetProperty("LINK_INTERFACE_LIBRARIES" + suffix)) {
     propContent = prop_suffixed;
-    }
-  else if (const char *prop = target->GetProperty(
-                    "LINK_INTERFACE_LIBRARIES"))
-    {
+  } else if (const char* prop =
+               target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
     propContent = prop;
-    }
-  else
-    {
+  } else {
     return;
-    }
+  }
 
   const bool newCMP0022Behavior =
-                        target->GetPolicyStatusCMP0022() != cmPolicies::WARN
-                     && target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+    target->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+    target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
 
-  if(newCMP0022Behavior && !this->ExportOld)
-    {
-    cmLocalGenerator *lg = target->GetLocalGenerator();
+  if (newCMP0022Behavior && !this->ExportOld) {
+    cmLocalGenerator* lg = target->GetLocalGenerator();
     std::ostringstream e;
-    e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
+    e << "Target \"" << target->GetName()
+      << "\" has policy CMP0022 enabled, "
          "but also has old-style LINK_INTERFACE_LIBRARIES properties "
          "populated, but it was exported without the "
          "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
     lg->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
+  }
 
-  if (!*propContent)
-    {
+  if (!*propContent) {
     properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
     return;
-    }
+  }
 
-  std::string prepro = cmGeneratorExpression::Preprocess(propContent,
-                                                         preprocessRule);
-  if (!prepro.empty())
-    {
-    this->ResolveTargetsInGeneratorExpressions(prepro, target,
-                                               missingTargets,
+  std::string prepro =
+    cmGeneratorExpression::Preprocess(propContent, preprocessRule);
+  if (!prepro.empty()) {
+    this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets,
                                                ReplaceFreeTargets);
     properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator
-::SetImportDetailProperties(const std::string& config,
-                            std::string const& suffix,
-                            cmGeneratorTarget* target,
-                            ImportPropertyMap& properties,
-                            std::vector<std::string>& missingTargets
-                           )
+void cmExportFileGenerator::SetImportDetailProperties(
+  const std::string& config, std::string const& suffix,
+  cmGeneratorTarget* target, ImportPropertyMap& properties,
+  std::vector<std::string>& missingTargets)
 {
   // Get the makefile in which to lookup target information.
   cmMakefile* mf = target->Makefile;
 
   // Add the soname for unix shared libraries.
-  if(target->GetType() == cmState::SHARED_LIBRARY ||
-     target->GetType() == cmState::MODULE_LIBRARY)
-    {
-    if(!target->IsDLLPlatform())
-      {
+  if (target->GetType() == cmState::SHARED_LIBRARY ||
+      target->GetType() == cmState::MODULE_LIBRARY) {
+    if (!target->IsDLLPlatform()) {
       std::string prop;
       std::string value;
-      if(target->HasSOName(config))
-        {
-        if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-          {
+      if (target->HasSOName(config)) {
+        if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
           value = this->InstallNameDir(target, config);
-          }
+        }
         prop = "IMPORTED_SONAME";
         value += target->GetSOName(config);
-        }
-      else
-        {
+      } else {
         prop = "IMPORTED_NO_SONAME";
         value = "TRUE";
-        }
+      }
       prop += suffix;
       properties[prop] = value;
-      }
     }
+  }
 
   // Add the transitive link dependencies for this configuration.
-  if(cmLinkInterface const* iface =
-                            target->GetLinkInterface(config, target))
-    {
+  if (cmLinkInterface const* iface =
+        target->GetLinkInterface(config, target)) {
     this->SetImportLinkProperty(suffix, target,
                                 "IMPORTED_LINK_INTERFACE_LANGUAGES",
                                 iface->Languages, properties, missingTargets);
@@ -935,41 +786,32 @@ cmExportFileGenerator
     this->SetImportLinkProperty(suffix, target,
                                 "IMPORTED_LINK_DEPENDENT_LIBRARIES",
                                 iface->SharedDeps, properties, dummy);
-    if(iface->Multiplicity > 0)
-      {
+    if (iface->Multiplicity > 0) {
       std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
       prop += suffix;
       std::ostringstream m;
       m << iface->Multiplicity;
       properties[prop] = m.str();
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 template <typename T>
-void
-cmExportFileGenerator
-::SetImportLinkProperty(std::string const& suffix,
-                        cmGeneratorTarget* target,
-                        const std::string& propName,
-                        std::vector<T> const& entries,
-                        ImportPropertyMap& properties,
-                        std::vector<std::string>& missingTargets
-  )
+void cmExportFileGenerator::SetImportLinkProperty(
+  std::string const& suffix, cmGeneratorTarget* target,
+  const std::string& propName, std::vector<T> const& entries,
+  ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
 {
   // Skip the property if there are no entries.
-  if(entries.empty())
-    {
+  if (entries.empty()) {
     return;
-    }
+  }
 
   // Construct the property value.
   std::string link_entries;
   const char* sep = "";
-  for(typename std::vector<T>::const_iterator li = entries.begin();
-      li != entries.end(); ++li)
-    {
+  for (typename std::vector<T>::const_iterator li = entries.begin();
+       li != entries.end(); ++li) {
     // Separate this from the previous entry.
     link_entries += sep;
     sep = ";";
@@ -977,7 +819,7 @@ cmExportFileGenerator
     std::string temp = *li;
     this->AddTargetNamespace(temp, target, missingTargets);
     link_entries += temp;
-    }
+  }
 
   // Store the property.
   std::string prop = propName;
@@ -985,46 +827,42 @@ cmExportFileGenerator
   properties[prop] = link_entries;
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
-                                                    const std::string& config)
+                                                     const std::string& config)
 {
   os << "#----------------------------------------------------------------\n"
      << "# Generated CMake target import file";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     os << " for configuration \"" << config << "\".\n";
-    }
-  else
-    {
+  } else {
     os << ".\n";
-    }
+  }
   os << "#----------------------------------------------------------------\n"
      << "\n";
   this->GenerateImportVersionCode(os);
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
 {
   os << "# Commands beyond this point should not need to know the version.\n"
      << "set(CMAKE_IMPORT_FILE_VERSION)\n";
 }
 
-//----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
 {
   // Store an import file format version.  This will let us change the
   // format later while still allowing old import files to work.
+  /* clang-format off */
   os << "# Commands may need to know the format version.\n"
      << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
      << "\n";
+  /* clang-format on */
 }
 
-//----------------------------------------------------------------------------
-void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
-                                            const std::string &expectedTargets)
+void cmExportFileGenerator::GenerateExpectedTargetsCode(
+  std::ostream& os, const std::string& expectedTargets)
 {
+  /* clang-format off */
   os << "# Protect against multiple inclusion, which would fail when already "
         "imported targets are added once more.\n"
         "set(_targetsDefined)\n"
@@ -1040,6 +878,9 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
         "  endif()\n"
         "endforeach()\n"
         "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
+        "  unset(_targetsDefined)\n"
+        "  unset(_targetsNotDefined)\n"
+        "  unset(_expectedTargets)\n"
         "  set(CMAKE_IMPORT_FILE_VERSION)\n"
         "  cmake_policy(POP)\n"
         "  return()\n"
@@ -1053,11 +894,10 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
         "unset(_targetsNotDefined)\n"
         "unset(_expectedTargets)\n"
         "\n\n";
+  /* clang-format on */
 }
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator
-::GenerateImportTargetCode(std::ostream& os, const cmGeneratorTarget* target)
+void cmExportFileGenerator::GenerateImportTargetCode(
+  std::ostream& os, const cmGeneratorTarget* target)
 {
   // Construct the imported target name.
   std::string targetName = this->Namespace;
@@ -1066,8 +906,7 @@ cmExportFileGenerator
 
   // Create the imported target.
   os << "# Create imported target " << targetName << "\n";
-  switch(target->GetType())
-    {
+  switch (target->GetType()) {
     case cmState::EXECUTABLE:
       os << "add_executable(" << targetName << " IMPORTED)\n";
       break;
@@ -1086,45 +925,36 @@ cmExportFileGenerator
     case cmState::INTERFACE_LIBRARY:
       os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
       break;
-    default:  // should never happen
+    default: // should never happen
       break;
-    }
+  }
 
   // Mark the imported executable if it has exports.
-  if(target->IsExecutableWithExports())
-    {
+  if (target->IsExecutableWithExports()) {
     os << "set_property(TARGET " << targetName
        << " PROPERTY ENABLE_EXPORTS 1)\n";
-    }
+  }
 
   // Mark the imported library if it is a framework.
-  if(target->IsFrameworkOnApple())
-    {
-    os << "set_property(TARGET " << targetName
-       << " PROPERTY FRAMEWORK 1)\n";
-    }
+  if (target->IsFrameworkOnApple()) {
+    os << "set_property(TARGET " << targetName << " PROPERTY FRAMEWORK 1)\n";
+  }
 
   // Mark the imported executable if it is an application bundle.
-  if(target->IsAppBundleOnApple())
-    {
+  if (target->IsAppBundleOnApple()) {
     os << "set_property(TARGET " << targetName
        << " PROPERTY MACOSX_BUNDLE 1)\n";
-    }
+  }
 
-  if (target->IsCFBundleOnApple())
-    {
-    os << "set_property(TARGET " << targetName
-       << " PROPERTY BUNDLE 1)\n";
-    }
+  if (target->IsCFBundleOnApple()) {
+    os << "set_property(TARGET " << targetName << " PROPERTY BUNDLE 1)\n";
+  }
   os << "\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator
-::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
-                             cmGeneratorTarget const* target,
-                             ImportPropertyMap const& properties)
+void cmExportFileGenerator::GenerateImportPropertyCode(
+  std::ostream& os, const std::string& config, cmGeneratorTarget const* target,
+  ImportPropertyMap const& properties)
 {
   // Construct the imported target name.
   std::string targetName = this->Namespace;
@@ -1136,50 +966,46 @@ cmExportFileGenerator
      << config << "\"\n";
   os << "set_property(TARGET " << targetName
      << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     os << cmSystemTools::UpperCase(config);
-    }
-  else
-    {
+  } else {
     os << "NOCONFIG";
-    }
+  }
   os << ")\n";
   os << "set_target_properties(" << targetName << " PROPERTIES\n";
-  for(ImportPropertyMap::const_iterator pi = properties.begin();
-      pi != properties.end(); ++pi)
-    {
-    os << "  " << pi->first << " "
-       << cmExportFileGeneratorEscape(pi->second) << "\n";
-    }
+  for (ImportPropertyMap::const_iterator pi = properties.begin();
+       pi != properties.end(); ++pi) {
+    os << "  " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
+       << "\n";
+  }
   os << "  )\n"
      << "\n";
 }
 
-
-//----------------------------------------------------------------------------
-void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
-                                const std::vector<std::string>& missingTargets)
+void cmExportFileGenerator::GenerateMissingTargetsCheckCode(
+  std::ostream& os, const std::vector<std::string>& missingTargets)
 {
-  if (missingTargets.empty())
-    {
+  if (missingTargets.empty()) {
+    /* clang-format off */
     os << "# This file does not depend on other imported targets which have\n"
           "# been exported from the same project but in a separate "
             "export set.\n\n";
+    /* clang-format on */
     return;
-    }
+  }
+  /* clang-format off */
   os << "# Make sure the targets which have been exported in some other \n"
         "# export set exist.\n"
         "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
         "foreach(_target ";
+  /* clang-format on */
   std::set<std::string> emitted;
-  for(unsigned int i=0; i<missingTargets.size(); ++i)
-    {
-    if (emitted.insert(missingTargets[i]).second)
-      {
-      os << "\"" << missingTargets[i] <<  "\" ";
-      }
+  for (unsigned int i = 0; i < missingTargets.size(); ++i) {
+    if (emitted.insert(missingTargets[i]).second) {
+      os << "\"" << missingTargets[i] << "\" ";
     }
+  }
+  /* clang-format off */
   os << ")\n"
         "  if(NOT TARGET \"${_target}\" )\n"
         "    set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
@@ -1203,12 +1029,10 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
         "endif()\n"
         "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
         "\n";
+  /* clang-format on */
 }
 
-
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
+void cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
 {
   // Add code which verifies at cmake time that the file which is being
   // imported actually exists on disk. This should in theory always be theory
@@ -1217,6 +1041,7 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
   // the non-development package, something similar happened to me without
   // on SUSE with a mysql pkg-config file, which claimed everything is fine,
   // but the development package was not installed.).
+  /* clang-format off */
   os << "# Loop over all imported files and verify that they actually exist\n"
         "foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
         "  foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
@@ -1237,33 +1062,30 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
         "endforeach()\n"
         "unset(_IMPORT_CHECK_TARGETS)\n"
         "\n";
+  /* clang-format on */
 }
 
-
-//----------------------------------------------------------------------------
-void
-cmExportFileGenerator
-::GenerateImportedFileChecksCode(std::ostream& os, cmGeneratorTarget* target,
-                                 ImportPropertyMap const& properties,
-                                const std::set<std::string>& importedLocations)
+void cmExportFileGenerator::GenerateImportedFileChecksCode(
+  std::ostream& os, cmGeneratorTarget* target,
+  ImportPropertyMap const& properties,
+  const std::set<std::string>& importedLocations)
 {
   // Construct the imported target name.
   std::string targetName = this->Namespace;
   targetName += target->GetExportName();
 
-  os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
-        "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
+  os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName
+     << " )\n"
+        "list(APPEND _IMPORT_CHECK_FILES_FOR_"
+     << targetName << " ";
 
-  for(std::set<std::string>::const_iterator li = importedLocations.begin();
-      li != importedLocations.end();
-      ++li)
-    {
+  for (std::set<std::string>::const_iterator li = importedLocations.begin();
+       li != importedLocations.end(); ++li) {
     ImportPropertyMap::const_iterator pi = properties.find(*li);
-    if (pi != properties.end())
-      {
+    if (pi != properties.end()) {
       os << cmExportFileGeneratorEscape(pi->second) << " ";
-      }
     }
+  }
 
   os << ")\n\n";
 }
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 18f0b00..9c96015 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -15,19 +15,18 @@
 #include "cmCommand.h"
 #include "cmGeneratorExpression.h"
 
-#include "cmVersionMacros.h"
 #include "cmVersion.h"
+#include "cmVersionMacros.h"
 
 #define STRINGIFY_HELPER(X) #X
 #define STRINGIFY(X) STRINGIFY_HELPER(X)
 
-#define DEVEL_CMAKE_VERSION(major, minor) ( \
-  CMake_VERSION_ENCODE(major, minor, 0) > \
-  CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0) ?  \
-    STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(CMake_VERSION_MINOR) "." \
-    STRINGIFY(CMake_VERSION_PATCH) \
-  : #major "." #minor ".0" \
-  )
+#define DEVEL_CMAKE_VERSION(major, minor)                                     \
+  (CMake_VERSION_ENCODE(major, minor, 0) >                                    \
+       CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0)      \
+     ? STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(                          \
+         CMake_VERSION_MINOR) "." STRINGIFY(CMake_VERSION_PATCH)              \
+     : #major "." #minor ".0")
 
 class cmTargetExport;
 
@@ -47,7 +46,7 @@ public:
 
   /** Set the full path to the export file to generate.  */
   void SetExportFile(const char* mainFile);
-  const char *GetMainExportFileName() const;
+  const char* GetMainExportFileName() const;
 
   /** Set the namespace in which to place exported target names.  */
   void SetNamespace(const std::string& ns) { this->Namespace = ns; }
@@ -61,14 +60,14 @@ public:
   /** Actually generate the export file.  Returns whether there was an
       error.  */
   bool GenerateImportFile();
-protected:
 
+protected:
   typedef std::map<std::string, std::string> ImportPropertyMap;
 
   // Generate per-configuration target information to the given output
   // stream.
   void GenerateImportConfig(std::ostream& os, const std::string& config,
-                            std::vector<std::string> &missingTargets);
+                            std::vector<std::string>& missingTargets);
 
   // Methods to implement export file code generation.
   void GenerateImportHeaderCode(std::ostream& os,
@@ -80,16 +79,16 @@ protected:
   void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
                                   cmGeneratorTarget const* target,
                                   ImportPropertyMap const& properties);
-  void GenerateImportedFileChecksCode(std::ostream& os,
-                                      cmGeneratorTarget* target,
-                                      ImportPropertyMap const& properties,
-                               const std::set<std::string>& importedLocations);
+  void GenerateImportedFileChecksCode(
+    std::ostream& os, cmGeneratorTarget* target,
+    ImportPropertyMap const& properties,
+    const std::set<std::string>& importedLocations);
   void GenerateImportedFileCheckLoop(std::ostream& os);
-  void GenerateMissingTargetsCheckCode(std::ostream& os,
-                               const std::vector<std::string>& missingTargets);
+  void GenerateMissingTargetsCheckCode(
+    std::ostream& os, const std::vector<std::string>& missingTargets);
 
   void GenerateExpectedTargetsCode(std::ostream& os,
-                                          const std::string &expectedTargets);
+                                   const std::string& expectedTargets);
 
   // Collect properties with detailed information about targets beyond
   // their location on disk.
@@ -111,10 +110,9 @@ protected:
   virtual bool GenerateMainFile(std::ostream& os) = 0;
 
   /** Each subclass knows where the target files are located.  */
-  virtual void GenerateImportTargetsConfig(std::ostream& os,
-                                           const std::string& config,
-                                           std::string const& suffix,
-                            std::vector<std::string> &missingTargets) = 0;
+  virtual void GenerateImportTargetsConfig(
+    std::ostream& os, const std::string& config, std::string const& suffix,
+    std::vector<std::string>& missingTargets) = 0;
 
   /** Each subclass knows how to deal with a target that is  missing from an
    *  export set.  */
@@ -122,52 +120,49 @@ protected:
                                    std::vector<std::string>& missingTargets,
                                    cmGeneratorTarget* depender,
                                    cmGeneratorTarget* dependee) = 0;
-  void PopulateInterfaceProperty(const std::string&,
-                                 cmGeneratorTarget *target,
-                                 cmGeneratorExpression::PreprocessContext,
-                                 ImportPropertyMap &properties,
-                                 std::vector<std::string> &missingTargets);
-  bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target,
+  void PopulateInterfaceProperty(const std::string&, cmGeneratorTarget* target,
                                  cmGeneratorExpression::PreprocessContext,
-                                 ImportPropertyMap &properties,
-                                 std::vector<std::string> &missingTargets);
+                                 ImportPropertyMap& properties,
+                                 std::vector<std::string>& missingTargets);
+  bool PopulateInterfaceLinkLibrariesProperty(
+    cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext,
+    ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
   void PopulateInterfaceProperty(const std::string& propName,
                                  cmGeneratorTarget* target,
-                                 ImportPropertyMap &properties);
-  void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target,
-                                 ImportPropertyMap &properties);
+                                 ImportPropertyMap& properties);
+  void PopulateCompatibleInterfaceProperties(cmGeneratorTarget* target,
+                                             ImportPropertyMap& properties);
   void GenerateInterfaceProperties(cmGeneratorTarget const* target,
                                    std::ostream& os,
-                                   const ImportPropertyMap &properties);
+                                   const ImportPropertyMap& properties);
   void PopulateIncludeDirectoriesInterface(
-                      cmTargetExport *target,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets);
+    cmTargetExport* target,
+    cmGeneratorExpression::PreprocessContext preprocessRule,
+    ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
   void PopulateSourcesInterface(
-                      cmTargetExport *target,
-                      cmGeneratorExpression::PreprocessContext preprocessRule,
-                      ImportPropertyMap &properties,
-                      std::vector<std::string> &missingTargets);
-
-  void SetImportLinkInterface(const std::string& config,
-                    std::string const& suffix,
-                    cmGeneratorExpression::PreprocessContext preprocessRule,
-                    cmGeneratorTarget* target, ImportPropertyMap& properties,
-                    std::vector<std::string>& missingTargets);
-
-  enum FreeTargetsReplace {
+    cmTargetExport* target,
+    cmGeneratorExpression::PreprocessContext preprocessRule,
+    ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+
+  void SetImportLinkInterface(
+    const std::string& config, std::string const& suffix,
+    cmGeneratorExpression::PreprocessContext preprocessRule,
+    cmGeneratorTarget* target, ImportPropertyMap& properties,
+    std::vector<std::string>& missingTargets);
+
+  enum FreeTargetsReplace
+  {
     ReplaceFreeTargets,
     NoReplaceFreeTargets
   };
 
-  void ResolveTargetsInGeneratorExpressions(std::string &input,
-                          cmGeneratorTarget* target,
-                          std::vector<std::string> &missingTargets,
-                          FreeTargetsReplace replace = NoReplaceFreeTargets);
+  void ResolveTargetsInGeneratorExpressions(
+    std::string& input, cmGeneratorTarget* target,
+    std::vector<std::string>& missingTargets,
+    FreeTargetsReplace replace = NoReplaceFreeTargets);
 
   void GenerateRequiredCMakeVersion(std::ostream& os,
-                                    const char *versionString);
+                                    const char* versionString);
 
   // The namespace in which the exports are placed in the generated file.
   std::string Namespace;
@@ -191,17 +186,17 @@ private:
   void PopulateInterfaceProperty(const std::string&, const std::string&,
                                  cmGeneratorTarget* target,
                                  cmGeneratorExpression::PreprocessContext,
-                                 ImportPropertyMap &properties,
-                                 std::vector<std::string> &missingTargets);
+                                 ImportPropertyMap& properties,
+                                 std::vector<std::string>& missingTargets);
 
-  bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target,
-                          std::vector<std::string> &missingTargets);
+  bool AddTargetNamespace(std::string& input, cmGeneratorTarget* target,
+                          std::vector<std::string>& missingTargets);
 
-  void ResolveTargetsInGeneratorExpression(std::string &input,
-                                    cmGeneratorTarget* target,
-                                    std::vector<std::string> &missingTargets);
+  void ResolveTargetsInGeneratorExpression(
+    std::string& input, cmGeneratorTarget* target,
+    std::vector<std::string>& missingTargets);
 
-  virtual void ReplaceInstallPrefix(std::string &input);
+  virtual void ReplaceInstallPrefix(std::string& input);
 
   virtual std::string InstallNameDir(cmGeneratorTarget* target,
                                      const std::string& config) = 0;
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 71418e8..38b08f0 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -11,24 +11,22 @@
 ============================================================================*/
 #include "cmExportInstallFileGenerator.h"
 
+#include "cmAlgorithms.h"
 #include "cmExportSet.h"
 #include "cmExportSetMap.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
 #include "cmInstallExportGenerator.h"
 #include "cmInstallTargetGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmTargetExport.h"
-#include "cmAlgorithms.h"
 
-//----------------------------------------------------------------------------
-cmExportInstallFileGenerator
-::cmExportInstallFileGenerator(cmInstallExportGenerator* iegen):
-  IEGen(iegen)
+cmExportInstallFileGenerator::cmExportInstallFileGenerator(
+  cmInstallExportGenerator* iegen)
+  : IEGen(iegen)
 {
 }
 
-//----------------------------------------------------------------------------
 std::string cmExportInstallFileGenerator::GetConfigImportFileGlob()
 {
   std::string glob = this->FileBase;
@@ -37,56 +35,52 @@ std::string cmExportInstallFileGenerator::GetConfigImportFileGlob()
   return glob;
 }
 
-//----------------------------------------------------------------------------
 bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
 {
   std::vector<cmTargetExport*> allTargets;
   {
-  std::string expectedTargets;
-  std::string sep;
-  for(std::vector<cmTargetExport*>::const_iterator
-        tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
-      tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
-    {
-    expectedTargets +=
+    std::string expectedTargets;
+    std::string sep;
+    for (std::vector<cmTargetExport*>::const_iterator tei =
+           this->IEGen->GetExportSet()->GetTargetExports()->begin();
+         tei != this->IEGen->GetExportSet()->GetTargetExports()->end();
+         ++tei) {
+      expectedTargets +=
         sep + this->Namespace + (*tei)->Target->GetExportName();
-    sep = " ";
-    cmTargetExport * te = *tei;
-    if(this->ExportedTargets.insert(te->Target).second)
-      {
-      allTargets.push_back(te);
-      }
-    else
-      {
-      std::ostringstream e;
-      e << "install(EXPORT \""
-        << this->IEGen->GetExportSet()->GetName()
-        << "\" ...) " << "includes target \"" << te->Target->GetName()
-        << "\" more than once in the export set.";
-      cmSystemTools::Error(e.str().c_str());
-      return false;
+      sep = " ";
+      cmTargetExport* te = *tei;
+      if (this->ExportedTargets.insert(te->Target).second) {
+        allTargets.push_back(te);
+      } else {
+        std::ostringstream e;
+        e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
+          << "\" ...) "
+          << "includes target \"" << te->Target->GetName()
+          << "\" more than once in the export set.";
+        cmSystemTools::Error(e.str().c_str());
+        return false;
       }
     }
 
-  this->GenerateExpectedTargetsCode(os, expectedTargets);
+    this->GenerateExpectedTargetsCode(os, expectedTargets);
   }
 
   // Set an _IMPORT_PREFIX variable for import location properties
   // to reference if they are relative to the install prefix.
-  std::string installPrefix = this->IEGen->GetLocalGenerator()
-      ->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+  std::string installPrefix =
+    this->IEGen->GetLocalGenerator()->GetMakefile()->GetSafeDefinition(
+      "CMAKE_INSTALL_PREFIX");
   std::string const& expDest = this->IEGen->GetDestination();
-  if(cmSystemTools::FileIsFullPath(expDest))
-    {
+  if (cmSystemTools::FileIsFullPath(expDest)) {
     // The export file is being installed to an absolute path so the
     // package is not relocatable.  Use the configured install prefix.
+    /* clang-format off */
     os <<
       "# The installation prefix configured by this project.\n"
       "set(_IMPORT_PREFIX \"" << installPrefix << "\")\n"
       "\n";
-    }
-  else
-    {
+    /* clang-format on */
+  } else {
     // Add code to compute the installation prefix relative to the
     // import file location.
     std::string absDest = installPrefix + "/" + expDest;
@@ -94,12 +88,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
     os << "# Compute the installation prefix relative to this file.\n"
        << "get_filename_component(_IMPORT_PREFIX"
        << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
-    if(cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
-       cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
-       cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
-       cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/"))
-      {
+    if (cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
+        cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
+        cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
+        cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/")) {
       // Handle "/usr move" symlinks created by some Linux distros.
+      /* clang-format off */
       os <<
         "# Use original install prefix when loaded through a\n"
         "# cross-prefix symbolic link such as /lib -> /usr/lib.\n"
@@ -110,16 +104,16 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
         "endif()\n"
         "unset(_realOrig)\n"
         "unset(_realCurr)\n";
-      }
+      /* clang-format on */
+    }
     std::string dest = expDest;
-    while(!dest.empty())
-      {
-      os <<
-        "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
+    while (!dest.empty()) {
+      os << "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" "
+            "PATH)\n";
       dest = cmSystemTools::GetFilenamePath(dest);
-      }
-    os << "\n";
     }
+    os << "\n";
+  }
 
   std::vector<std::string> missingTargets;
 
@@ -128,92 +122,77 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
   bool require3_1_0 = false;
   bool requiresConfigFiles = false;
   // Create all the imported targets.
-  for(std::vector<cmTargetExport*>::const_iterator
-        tei = allTargets.begin();
-      tei != allTargets.end(); ++tei)
-    {
+  for (std::vector<cmTargetExport*>::const_iterator tei = allTargets.begin();
+       tei != allTargets.end(); ++tei) {
     cmGeneratorTarget* gt = (*tei)->Target;
 
-    requiresConfigFiles = requiresConfigFiles
-                              || gt->GetType() != cmState::INTERFACE_LIBRARY;
+    requiresConfigFiles =
+      requiresConfigFiles || gt->GetType() != cmState::INTERFACE_LIBRARY;
 
     this->GenerateImportTargetCode(os, gt);
 
     ImportPropertyMap properties;
 
-    this->PopulateIncludeDirectoriesInterface(*tei,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
+    this->PopulateIncludeDirectoriesInterface(
+      *tei, cmGeneratorExpression::InstallInterface, properties,
+      missingTargets);
     this->PopulateSourcesInterface(*tei,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
-    this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
-                                  gt,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
-    this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
-                                  gt,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
-    this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
-                                  gt,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
-    this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS",
-                                  gt,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
-    this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
-                                  gt,
-                                  cmGeneratorExpression::InstallInterface,
-                                  properties, missingTargets);
+                                   cmGeneratorExpression::InstallInterface,
+                                   properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
+                                    cmGeneratorExpression::InstallInterface,
+                                    properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", gt,
+                                    cmGeneratorExpression::InstallInterface,
+                                    properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gt,
+                                    cmGeneratorExpression::InstallInterface,
+                                    properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt,
+                                    cmGeneratorExpression::InstallInterface,
+                                    properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gt,
+                                    cmGeneratorExpression::InstallInterface,
+                                    properties, missingTargets);
 
     const bool newCMP0022Behavior =
-        gt->GetPolicyStatusCMP0022() != cmPolicies::WARN
-        && gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
-    if (newCMP0022Behavior)
-      {
-      if (this->PopulateInterfaceLinkLibrariesProperty(gt,
-                                    cmGeneratorExpression::InstallInterface,
-                                    properties, missingTargets)
-          && !this->ExportOld)
-        {
+      gt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+      gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
+    if (newCMP0022Behavior) {
+      if (this->PopulateInterfaceLinkLibrariesProperty(
+            gt, cmGeneratorExpression::InstallInterface, properties,
+            missingTargets) &&
+          !this->ExportOld) {
         require2_8_12 = true;
-        }
       }
-    if (gt->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    }
+    if (gt->GetType() == cmState::INTERFACE_LIBRARY) {
       require3_0_0 = true;
-      }
-    if(gt->GetProperty("INTERFACE_SOURCES"))
-      {
+    }
+    if (gt->GetProperty("INTERFACE_SOURCES")) {
       // We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1
       // can consume them.
       require3_1_0 = true;
-      }
+    }
 
-    this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
-                                  gt, properties);
+    this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gt,
+                                    properties);
 
     this->PopulateCompatibleInterfaceProperties(gt, properties);
 
     this->GenerateInterfaceProperties(gt, os, properties);
-    }
+  }
 
-  if (require3_1_0)
-    {
+  if (require3_1_0) {
     this->GenerateRequiredCMakeVersion(os, "3.1.0");
-    }
-  else if (require3_0_0)
-    {
+  } else if (require3_0_0) {
     this->GenerateRequiredCMakeVersion(os, "3.0.0");
-    }
-  else if (require2_8_12)
-    {
+  } else if (require2_8_12) {
     this->GenerateRequiredCMakeVersion(os, "2.8.12");
-    }
+  }
 
   // Now load per-configuration properties for them.
+  /* clang-format off */
   os << "# Load information for each installed configuration.\n"
      << "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
      << "file(GLOB CONFIG_FILES \"${_DIR}/"
@@ -222,87 +201,75 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
      << "  include(${f})\n"
      << "endforeach()\n"
      << "\n";
+  /* clang-format on */
 
   // Cleanup the import prefix variable.
+  /* clang-format off */
   os << "# Cleanup temporary variables.\n"
      << "set(_IMPORT_PREFIX)\n"
      << "\n";
+  /* clang-format on */
   this->GenerateImportedFileCheckLoop(os);
 
   bool result = true;
   // Generate an import file for each configuration.
   // Don't do this if we only export INTERFACE_LIBRARY targets.
-  if (requiresConfigFiles)
-    {
-    for(std::vector<std::string>::const_iterator
-          ci = this->Configurations.begin();
-        ci != this->Configurations.end(); ++ci)
-      {
-      if(!this->GenerateImportFileConfig(*ci, missingTargets))
-        {
+  if (requiresConfigFiles) {
+    for (std::vector<std::string>::const_iterator ci =
+           this->Configurations.begin();
+         ci != this->Configurations.end(); ++ci) {
+      if (!this->GenerateImportFileConfig(*ci, missingTargets)) {
         result = false;
-        }
       }
     }
+  }
 
   this->GenerateMissingTargetsCheckCode(os, missingTargets);
 
   return result;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input)
+void cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string& input)
 {
   std::string::size_type pos = 0;
   std::string::size_type lastPos = pos;
 
-  while((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos)
-    {
+  while ((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos) {
     std::string::size_type endPos = pos + sizeof("$<INSTALL_PREFIX>") - 1;
     input.replace(pos, endPos - pos, "${_IMPORT_PREFIX}");
     lastPos = endPos;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmExportInstallFileGenerator::GenerateImportFileConfig(
-                                    const std::string& config,
-                                    std::vector<std::string> &missingTargets)
+bool cmExportInstallFileGenerator::GenerateImportFileConfig(
+  const std::string& config, std::vector<std::string>& missingTargets)
 {
   // Skip configurations not enabled for this export.
-  if(!this->IEGen->InstallsForConfig(config))
-    {
+  if (!this->IEGen->InstallsForConfig(config)) {
     return true;
-    }
+  }
 
   // Construct the name of the file to generate.
   std::string fileName = this->FileDir;
   fileName += "/";
   fileName += this->FileBase;
   fileName += "-";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     fileName += cmSystemTools::LowerCase(config);
-    }
-  else
-    {
+  } else {
     fileName += "noconfig";
-    }
+  }
   fileName += this->FileExt;
 
   // Open the output file to generate it.
   cmGeneratedFileStream exportFileStream(fileName.c_str(), true);
-  if(!exportFileStream)
-    {
+  if (!exportFileStream) {
     std::string se = cmSystemTools::GetLastSystemError();
     std::ostringstream e;
-    e << "cannot write to file \"" << fileName
-      << "\": " << se;
+    e << "cannot write to file \"" << fileName << "\": " << se;
     cmSystemTools::Error(e.str().c_str());
     return false;
-    }
+  }
   std::ostream& os = exportFileStream;
 
   // Start with the import file header.
@@ -320,25 +287,19 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportInstallFileGenerator
-::GenerateImportTargetsConfig(std::ostream& os,
-                              const std::string& config,
-                              std::string const& suffix,
-                              std::vector<std::string> &missingTargets)
+void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
+  std::ostream& os, const std::string& config, std::string const& suffix,
+  std::vector<std::string>& missingTargets)
 {
   // Add each target in the set to the export.
-  for(std::vector<cmTargetExport*>::const_iterator
-        tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
-      tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
-    {
+  for (std::vector<cmTargetExport*>::const_iterator tei =
+         this->IEGen->GetExportSet()->GetTargetExports()->begin();
+       tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
     // Collect import properties for this target.
     cmTargetExport const* te = *tei;
-    if (te->Target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (te->Target->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
 
     ImportPropertyMap properties;
     std::set<std::string> importedLocations;
@@ -347,9 +308,8 @@ cmExportInstallFileGenerator
                                     properties, importedLocations);
     this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
                                     properties, importedLocations);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->RuntimeGenerator, properties,
-                                    importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->RuntimeGenerator,
+                                    properties, importedLocations);
     this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator,
                                     properties, importedLocations);
     this->SetImportLocationProperty(config, suffix, te->BundleGenerator,
@@ -357,12 +317,11 @@ cmExportInstallFileGenerator
 
     // If any file location was set for the target add it to the
     // import file.
-    if(!properties.empty())
-      {
+    if (!properties.empty()) {
       // Get the rest of the target details.
-      cmGeneratorTarget *gtgt = te->Target;
-      this->SetImportDetailProperties(config, suffix,
-                                      gtgt, properties, missingTargets);
+      cmGeneratorTarget* gtgt = te->Target;
+      this->SetImportDetailProperties(config, suffix, gtgt, properties,
+                                      missingTargets);
 
       this->SetImportLinkInterface(config, suffix,
                                    cmGeneratorExpression::InstallInterface,
@@ -378,25 +337,19 @@ cmExportInstallFileGenerator
       this->GenerateImportPropertyCode(os, config, gtgt, properties);
       this->GenerateImportedFileChecksCode(os, gtgt, properties,
                                            importedLocations);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportInstallFileGenerator
-::SetImportLocationProperty(const std::string& config,
-                            std::string const& suffix,
-                            cmInstallTargetGenerator* itgen,
-                            ImportPropertyMap& properties,
-                            std::set<std::string>& importedLocations
-                           )
+void cmExportInstallFileGenerator::SetImportLocationProperty(
+  const std::string& config, std::string const& suffix,
+  cmInstallTargetGenerator* itgen, ImportPropertyMap& properties,
+  std::set<std::string>& importedLocations)
 {
   // Skip rules that do not match this configuration.
-  if(!(itgen && itgen->InstallsForConfig(config)))
-    {
+  if (!(itgen && itgen->InstallsForConfig(config))) {
     return;
-    }
+  }
 
   // Get the target to be installed.
   cmGeneratorTarget* target = itgen->GetTarget();
@@ -404,16 +357,14 @@ cmExportInstallFileGenerator
   // Construct the installed location of the target.
   std::string dest = itgen->GetDestination(config);
   std::string value;
-  if(!cmSystemTools::FileIsFullPath(dest.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(dest.c_str())) {
     // The target is installed relative to the installation prefix.
     value = "${_IMPORT_PREFIX}/";
-    }
+  }
   value += dest;
   value += "/";
 
-  if(itgen->IsImportLibrary())
-    {
+  if (itgen->IsImportLibrary()) {
     // Construct the property name.
     std::string prop = "IMPORTED_IMPLIB";
     prop += suffix;
@@ -425,135 +376,106 @@ cmExportInstallFileGenerator
     // Store the property.
     properties[prop] = value;
     importedLocations.insert(prop);
-    }
-  else
-    {
+  } else {
     // Construct the property name.
     std::string prop = "IMPORTED_LOCATION";
     prop += suffix;
 
     // Append the installed file name.
-    if(target->IsAppBundleOnApple())
-      {
+    if (target->IsAppBundleOnApple()) {
       value += itgen->GetInstallFilename(target, config);
       value += ".app/Contents/MacOS/";
       value += itgen->GetInstallFilename(target, config);
-      }
-    else
-      {
+    } else {
       value += itgen->GetInstallFilename(target, config,
                                          cmInstallTargetGenerator::NameReal);
-      }
+    }
 
     // Store the property.
     properties[prop] = value;
     importedLocations.insert(prop);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportInstallFileGenerator::HandleMissingTarget(std::string& link_libs,
-  std::vector<std::string>& missingTargets,
+void cmExportInstallFileGenerator::HandleMissingTarget(
+  std::string& link_libs, std::vector<std::string>& missingTargets,
   cmGeneratorTarget* depender, cmGeneratorTarget* dependee)
 {
   const std::string name = dependee->GetName();
   cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
   std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
   int targetOccurrences = (int)namespaces.size();
-  if (targetOccurrences == 1)
-    {
+  if (targetOccurrences == 1) {
     std::string missingTarget = namespaces[0];
 
     missingTarget += dependee->GetExportName();
     link_libs += missingTarget;
     missingTargets.push_back(missingTarget);
-    }
-  else
-    {
+  } else {
     // All exported targets should be known here and should be unique.
     // This is probably user-error.
     this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::vector<std::string>
-cmExportInstallFileGenerator
-::FindNamespaces(cmGlobalGenerator* gg, const std::string& name)
+std::vector<std::string> cmExportInstallFileGenerator::FindNamespaces(
+  cmGlobalGenerator* gg, const std::string& name)
 {
   std::vector<std::string> namespaces;
   const cmExportSetMap& exportSets = gg->GetExportSets();
 
-  for(cmExportSetMap::const_iterator expIt = exportSets.begin();
-      expIt != exportSets.end();
-      ++expIt)
-    {
+  for (cmExportSetMap::const_iterator expIt = exportSets.begin();
+       expIt != exportSets.end(); ++expIt) {
     const cmExportSet* exportSet = expIt->second;
     std::vector<cmTargetExport*> const* targets =
-                                                 exportSet->GetTargetExports();
+      exportSet->GetTargetExports();
 
     bool containsTarget = false;
-    for(unsigned int i=0; i<targets->size(); i++)
-      {
-      if (name == (*targets)[i]->TargetName)
-        {
+    for (unsigned int i = 0; i < targets->size(); i++) {
+      if (name == (*targets)[i]->TargetName) {
         containsTarget = true;
         break;
-        }
       }
+    }
 
-    if (containsTarget)
-      {
+    if (containsTarget) {
       std::vector<cmInstallExportGenerator const*> const* installs =
-                                                 exportSet->GetInstallations();
-      for(unsigned int i=0; i<installs->size(); i++)
-        {
+        exportSet->GetInstallations();
+      for (unsigned int i = 0; i < installs->size(); i++) {
         namespaces.push_back((*installs)[i]->GetNamespace());
-        }
       }
     }
+  }
 
   return namespaces;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportInstallFileGenerator
-::ComplainAboutMissingTarget(cmGeneratorTarget* depender,
-                             cmGeneratorTarget* dependee,
-                             int occurrences)
+void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
+  cmGeneratorTarget* depender, cmGeneratorTarget* dependee, int occurrences)
 {
   std::ostringstream e;
-  e << "install(EXPORT \""
-    << this->IEGen->GetExportSet()->GetName()
+  e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
     << "\" ...) "
     << "includes target \"" << depender->GetName()
     << "\" which requires target \"" << dependee->GetName() << "\" ";
-  if (occurrences == 0)
-    {
+  if (occurrences == 0) {
     e << "that is not in the export set.";
-    }
-  else
-    {
+  } else {
     e << "that is not in this export set, but " << occurrences
-    << " times in others.";
-    }
+      << " times in others.";
+  }
   cmSystemTools::Error(e.str().c_str());
 }
 
-std::string
-cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target,
-                                             const std::string&)
+std::string cmExportInstallFileGenerator::InstallNameDir(
+  cmGeneratorTarget* target, const std::string&)
 {
   std::string install_name_dir;
 
   cmMakefile* mf = target->Target->GetMakefile();
-  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
-    install_name_dir =
-      target->GetInstallNameDirForInstallTree();
-    }
+  if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+    install_name_dir = target->GetInstallNameDirForInstallTree();
+  }
 
   return install_name_dir;
 }
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 13dae89..723b6e5 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -31,7 +31,7 @@ class cmInstallTargetGenerator;
  *
  * This is used to implement the INSTALL(EXPORT) command.
  */
-class cmExportInstallFileGenerator: public cmExportFileGenerator
+class cmExportInstallFileGenerator : public cmExportFileGenerator
 {
 public:
   /** Construct with the export installer that will install the
@@ -42,25 +42,26 @@ public:
       maps from the configuration name to the file temporary location
       for installation.  */
   std::map<std::string, std::string> const& GetConfigImportFiles()
-    { return this->ConfigImportFiles; }
+  {
+    return this->ConfigImportFiles;
+  }
 
   /** Compute the globbing expression used to load per-config import
       files from the main file.  */
   std::string GetConfigImportFileGlob();
-protected:
 
+protected:
   // Implement virtual methods from the superclass.
   virtual bool GenerateMainFile(std::ostream& os);
-  virtual void GenerateImportTargetsConfig(std::ostream& os,
-                                           const std::string& config,
-                                           std::string const& suffix,
-                            std::vector<std::string> &missingTargets);
+  virtual void GenerateImportTargetsConfig(
+    std::ostream& os, const std::string& config, std::string const& suffix,
+    std::vector<std::string>& missingTargets);
   virtual void HandleMissingTarget(std::string& link_libs,
                                    std::vector<std::string>& missingTargets,
                                    cmGeneratorTarget* depender,
                                    cmGeneratorTarget* dependee);
 
-  virtual void ReplaceInstallPrefix(std::string &input);
+  virtual void ReplaceInstallPrefix(std::string& input);
 
   void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
                                   cmGeneratorTarget* dependee,
@@ -69,18 +70,16 @@ protected:
   std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
                                           const std::string& name);
 
-
   /** Generate a per-configuration file for the targets.  */
   bool GenerateImportFileConfig(const std::string& config,
-                            std::vector<std::string> &missingTargets);
+                                std::vector<std::string>& missingTargets);
 
   /** Fill in properties indicating installed file locations.  */
   void SetImportLocationProperty(const std::string& config,
                                  std::string const& suffix,
                                  cmInstallTargetGenerator* itgen,
                                  ImportPropertyMap& properties,
-                                 std::set<std::string>& importedLocations
-                                );
+                                 std::set<std::string>& importedLocations);
 
   std::string InstallNameDir(cmGeneratorTarget* target,
                              const std::string& config);
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 21d961f..ab43aa8 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -10,40 +10,39 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExportLibraryDependenciesCommand.h"
-#include "cmGlobalGenerator.h"
+
 #include "cmGeneratedFileStream.h"
-#include "cmake.h"
+#include "cmGlobalGenerator.h"
 #include "cmVersion.h"
+#include "cmake.h"
 
 #include <cmsys/auto_ptr.hxx>
 
-bool cmExportLibraryDependenciesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmExportLibraryDependenciesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0033,
-      "The export_library_dependencies command should not be called; "
-      "see CMP0033."))
-    { return true; }
-  if(args.size() < 1 )
-    {
+  if (this->Disallowed(
+        cmPolicies::CMP0033,
+        "The export_library_dependencies command should not be called; "
+        "see CMP0033.")) {
+    return true;
+  }
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // store the arguments for the final pass
   this->Filename = args[0];
   this->Append = false;
-  if(args.size() > 1)
-    {
-    if(args[1] == "APPEND")
-      {
+  if (args.size() > 1) {
+    if (args[1] == "APPEND") {
       this->Append = true;
-      }
     }
+  }
   return true;
 }
 
-
 void cmExportLibraryDependenciesCommand::FinalPass()
 {
   // export_library_dependencies() shouldn't modify anything
@@ -55,27 +54,23 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
 {
   // Use copy-if-different if not appending.
   cmsys::auto_ptr<cmsys::ofstream> foutPtr;
-  if(this->Append)
-    {
+  if (this->Append) {
     cmsys::auto_ptr<cmsys::ofstream> ap(
       new cmsys::ofstream(this->Filename.c_str(), std::ios::app));
     foutPtr = ap;
-    }
-  else
-    {
+  } else {
     cmsys::auto_ptr<cmGeneratedFileStream> ap(
       new cmGeneratedFileStream(this->Filename.c_str(), true));
     ap->SetCopyIfDifferent(true);
     foutPtr = ap;
-    }
+  }
   std::ostream& fout = *foutPtr.get();
 
-  if (!fout)
-    {
+  if (!fout) {
     cmSystemTools::Error("Error Writing ", this->Filename.c_str());
     cmSystemTools::ReportLastSystemError("");
     return;
-    }
+  }
 
   // Collect dependency information about all library targets built in
   // the project.
@@ -85,22 +80,18 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
   std::map<std::string, std::string> libDepsOld;
   std::map<std::string, std::string> libDepsNew;
   std::map<std::string, std::string> libTypes;
-  for(std::vector<cmMakefile*>::const_iterator i = locals.begin();
-      i != locals.end(); ++i)
-    {
-    const cmTargets &tgts = (*i)->GetTargets();
-    for(cmTargets::const_iterator l = tgts.begin();
-        l != tgts.end(); ++l)
-      {
+  for (std::vector<cmMakefile*>::const_iterator i = locals.begin();
+       i != locals.end(); ++i) {
+    const cmTargets& tgts = (*i)->GetTargets();
+    for (cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) {
       // Get the current target.
       cmTarget const& target = l->second;
 
       // Skip non-library targets.
-      if(target.GetType() < cmState::STATIC_LIBRARY
-         || target.GetType() > cmState::MODULE_LIBRARY)
-        {
+      if (target.GetType() < cmState::STATIC_LIBRARY ||
+          target.GetType() > cmState::MODULE_LIBRARY) {
         continue;
-        }
+      }
 
       // Construct the dependency variable name.
       std::string targetEntry = target.GetName();
@@ -112,14 +103,12 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
       std::string valueNew;
       cmTarget::LinkLibraryVectorType const& libs =
         target.GetOriginalLinkLibraries();
-      for(cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
-          li != libs.end(); ++li)
-        {
+      for (cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
+           li != libs.end(); ++li) {
         std::string ltVar = li->first;
         ltVar += "_LINK_TYPE";
         std::string ltValue;
-        switch(li->second)
-          {
+        switch (li->second) {
           case GENERAL_LibraryType:
             valueNew += "general;";
             ltValue = "general";
@@ -132,73 +121,62 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
             valueNew += "optimized;";
             ltValue = "optimized";
             break;
-          }
+        }
         std::string lib = li->first;
-        if(cmTarget* libtgt = global->FindTarget(lib))
-          {
+        if (cmTarget* libtgt = global->FindTarget(lib)) {
           // Handle simple output name changes.  This command is
           // deprecated so we do not support full target name
           // translation (which requires per-configuration info).
-          if(const char* outname = libtgt->GetProperty("OUTPUT_NAME"))
-            {
+          if (const char* outname = libtgt->GetProperty("OUTPUT_NAME")) {
             lib = outname;
-            }
           }
+        }
         valueOld += lib;
         valueOld += ";";
         valueNew += lib;
         valueNew += ";";
 
         std::string& ltEntry = libTypes[ltVar];
-        if(ltEntry.empty())
-          {
+        if (ltEntry.empty()) {
           ltEntry = ltValue;
-          }
-        else if(ltEntry != ltValue)
-          {
+        } else if (ltEntry != ltValue) {
           ltEntry = "general";
-          }
         }
+      }
       libDepsNew[targetEntry] = valueNew;
       libDepsOld[targetEntry] = valueOld;
-      }
     }
+  }
 
   // Generate dependency information for both old and new style CMake
   // versions.
   const char* vertest =
     "\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" GREATER 2.4";
-  fout << "# Generated by CMake " <<  cmVersion::GetCMakeVersion() << "\n\n";
+  fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
   fout << "if(" << vertest << ")\n";
   fout << "  # Information for CMake 2.6 and above.\n";
-  for(std::map<std::string, std::string>::const_iterator
-        i = libDepsNew.begin();
-      i != libDepsNew.end(); ++i)
-    {
-    if(!i->second.empty())
-      {
+  for (std::map<std::string, std::string>::const_iterator i =
+         libDepsNew.begin();
+       i != libDepsNew.end(); ++i) {
+    if (!i->second.empty()) {
       fout << "  set(\"" << i->first << "\" \"" << i->second << "\")\n";
-      }
     }
+  }
   fout << "else()\n";
   fout << "  # Information for CMake 2.4 and lower.\n";
-  for(std::map<std::string, std::string>::const_iterator
-        i = libDepsOld.begin();
-      i != libDepsOld.end(); ++i)
-    {
-    if(!i->second.empty())
-      {
+  for (std::map<std::string, std::string>::const_iterator i =
+         libDepsOld.begin();
+       i != libDepsOld.end(); ++i) {
+    if (!i->second.empty()) {
       fout << "  set(\"" << i->first << "\" \"" << i->second << "\")\n";
-      }
     }
-  for(std::map<std::string, std::string>::const_iterator i = libTypes.begin();
-      i != libTypes.end(); ++i)
-    {
-    if(i->second != "general")
-      {
+  }
+  for (std::map<std::string, std::string>::const_iterator i = libTypes.begin();
+       i != libTypes.end(); ++i) {
+    if (i->second != "general") {
       fout << "  set(\"" << i->first << "\" \"" << i->second << "\")\n";
-      }
     }
+  }
   fout << "endif()\n";
   return;
 }
diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h
index 81aa21a..3fb3565 100644
--- a/Source/cmExportLibraryDependenciesCommand.h
+++ b/Source/cmExportLibraryDependenciesCommand.h
@@ -20,8 +20,8 @@ public:
   cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand);
   virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const { return "export_library_dependencies";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "export_library_dependencies"; }
 
   virtual void FinalPass();
   virtual bool HasFinalPass() const { return true; }
@@ -32,5 +32,4 @@ private:
   void ConstFinalPass() const;
 };
 
-
 #endif
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index 0059b64..c468e3e 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -11,9 +11,10 @@
 ============================================================================*/
 
 #include "cmExportSet.h"
-#include "cmTargetExport.h"
+
 #include "cmAlgorithms.h"
 #include "cmLocalGenerator.h"
+#include "cmTargetExport.h"
 
 cmExportSet::~cmExportSet()
 {
@@ -23,10 +24,9 @@ cmExportSet::~cmExportSet()
 void cmExportSet::Compute(cmLocalGenerator* lg)
 {
   for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin();
-       it != this->TargetExports.end(); ++it)
-    {
+       it != this->TargetExports.end(); ++it) {
     (*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName);
-    }
+  }
 }
 
 void cmExportSet::AddTargetExport(cmTargetExport* te)
diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h
index d780a22..49f2cac 100644
--- a/Source/cmExportSet.h
+++ b/Source/cmExportSet.h
@@ -13,6 +13,7 @@
 #define cmExportSet_h
 
 #include "cmSystemTools.h"
+
 class cmTargetExport;
 class cmInstallExportGenerator;
 class cmLocalGenerator;
@@ -22,7 +23,10 @@ class cmExportSet
 {
 public:
   /// Construct an empty export set named \a name
-  cmExportSet(const std::string &name) : Name(name) {}
+  cmExportSet(const std::string& name)
+    : Name(name)
+  {
+  }
   /// Destructor
   ~cmExportSet();
 
@@ -35,10 +39,14 @@ public:
   std::string const& GetName() const { return this->Name; }
 
   std::vector<cmTargetExport*> const* GetTargetExports() const
-     { return &this->TargetExports; }
+  {
+    return &this->TargetExports;
+  }
 
   std::vector<cmInstallExportGenerator const*> const* GetInstallations() const
-     { return &this->Installations; }
+  {
+    return &this->Installations;
+  }
 
 private:
   std::vector<cmTargetExport*> TargetExports;
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
index cf431c6..ac1c66e 100644
--- a/Source/cmExportSetMap.cxx
+++ b/Source/cmExportSetMap.cxx
@@ -11,16 +11,17 @@
 ============================================================================*/
 
 #include "cmExportSetMap.h"
-#include "cmExportSet.h"
+
 #include "cmAlgorithms.h"
+#include "cmExportSet.h"
 
-cmExportSet* cmExportSetMap::operator[](const std::string &name)
+cmExportSet* cmExportSetMap::operator[](const std::string& name)
 {
   std::map<std::string, cmExportSet*>::iterator it = this->find(name);
   if (it == this->end()) // Export set not found
-    {
+  {
     it = this->insert(std::make_pair(name, new cmExportSet(name))).first;
-    }
+  }
   return it->second;
 }
 
diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h
index 965046c..d2954e3 100644
--- a/Source/cmExportSetMap.h
+++ b/Source/cmExportSetMap.h
@@ -13,19 +13,21 @@
 #define cmExportSetMap_h
 
 #include "cmSystemTools.h"
+
 class cmExportSet;
 
 /// A name -> cmExportSet map with overloaded operator[].
 class cmExportSetMap : public std::map<std::string, cmExportSet*>
 {
   typedef std::map<std::string, cmExportSet*> derived;
+
 public:
   /** \brief Overloaded operator[].
    *
    * The operator is overloaded because cmExportSet has no default constructor:
    * we do not want unnamed export sets.
    */
-  cmExportSet* operator[](const std::string &name);
+  cmExportSet* operator[](const std::string& name);
 
   void clear();
 
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 83127e7..5a826f2 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -13,15 +13,13 @@
 #include "cmExportTryCompileFileGenerator.h"
 
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpressionDAGChecker.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
-#include "cmGeneratorExpressionDAGChecker.h"
 
-//----------------------------------------------------------------------------
 cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
-    cmGlobalGenerator* gg,
-    const std::vector<std::string>& targets,
-    cmMakefile* mf)
+  cmGlobalGenerator* gg, const std::vector<std::string>& targets,
+  cmMakefile* mf)
 {
   gg->CreateImportedGenerationObjects(mf, targets, this->Exports);
 }
@@ -30,19 +28,17 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
 {
   std::set<cmGeneratorTarget const*> emitted;
   std::set<cmGeneratorTarget const*> emittedDeps;
-  while(!this->Exports.empty())
-    {
+  while (!this->Exports.empty()) {
     cmGeneratorTarget const* te = this->Exports.back();
     this->Exports.pop_back();
-    if (emitted.insert(te).second)
-      {
+    if (emitted.insert(te).second) {
       emittedDeps.insert(te);
       this->GenerateImportTargetCode(os, te);
 
       ImportPropertyMap properties;
 
-#define FIND_TARGETS(PROPERTY) \
-      this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps);
+#define FIND_TARGETS(PROPERTY)                                                \
+  this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps);
 
       CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
 
@@ -51,27 +47,23 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
       this->PopulateProperties(te, properties, emittedDeps);
 
       this->GenerateInterfaceProperties(te, os, properties);
-      }
     }
+  }
   return true;
 }
 
 std::string cmExportTryCompileFileGenerator::FindTargets(
-                                  const std::string& propName,
-                                  cmGeneratorTarget const* tgt,
-                                  std::set<cmGeneratorTarget const*> &emitted)
+  const std::string& propName, cmGeneratorTarget const* tgt,
+  std::set<cmGeneratorTarget const*>& emitted)
 {
-  const char *prop = tgt->GetProperty(propName);
-  if(!prop)
-    {
+  const char* prop = tgt->GetProperty(propName);
+  if (!prop) {
     return std::string();
-    }
+  }
 
   cmGeneratorExpression ge;
 
-  cmGeneratorExpressionDAGChecker dagChecker(
-                                      tgt->GetName(),
-                                      propName, 0, 0);
+  cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName, 0, 0);
 
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
 
@@ -82,71 +74,58 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
   cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
 
   std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
-                                     false, &gDummyHead,
-                                     tgt, &dagChecker);
-
-  const std::set<cmGeneratorTarget const*> &allTargets =
-      cge->GetAllTargetsSeen();
-  for(std::set<cmGeneratorTarget const*>::const_iterator li =
-      allTargets.begin(); li != allTargets.end(); ++li)
-    {
-    if(emitted.insert(*li).second)
-      {
+                                     false, &gDummyHead, tgt, &dagChecker);
+
+  const std::set<cmGeneratorTarget const*>& allTargets =
+    cge->GetAllTargetsSeen();
+  for (std::set<cmGeneratorTarget const*>::const_iterator li =
+         allTargets.begin();
+       li != allTargets.end(); ++li) {
+    if (emitted.insert(*li).second) {
       this->Exports.push_back(*li);
-      }
     }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
-void
-cmExportTryCompileFileGenerator::PopulateProperties(
-                                 const cmGeneratorTarget* target,
-                                 ImportPropertyMap& properties,
-                                 std::set<cmGeneratorTarget const*> &emitted)
+void cmExportTryCompileFileGenerator::PopulateProperties(
+  const cmGeneratorTarget* target, ImportPropertyMap& properties,
+  std::set<cmGeneratorTarget const*>& emitted)
 {
   std::vector<std::string> props = target->GetPropertyKeys();
-  for(std::vector<std::string>::const_iterator i = props.begin();
-      i != props.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = props.begin();
+       i != props.end(); ++i) {
 
     properties[*i] = target->GetProperty(*i);
 
-    if(i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
-        || i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
-        || i->find("INTERFACE_LINK_LIBRARIES") == 0)
-      {
-      std::string evalResult = this->FindTargets(*i,
-                                                 target, emitted);
+    if (i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
+        i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 ||
+        i->find("INTERFACE_LINK_LIBRARIES") == 0) {
+      std::string evalResult = this->FindTargets(*i, target, emitted);
 
       std::vector<std::string> depends;
       cmSystemTools::ExpandListArgument(evalResult, depends);
-      for(std::vector<std::string>::const_iterator li = depends.begin();
-          li != depends.end(); ++li)
-        {
-        cmGeneratorTarget *tgt =
-            target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
-        if(tgt && emitted.insert(tgt).second)
-          {
+      for (std::vector<std::string>::const_iterator li = depends.begin();
+           li != depends.end(); ++li) {
+        cmGeneratorTarget* tgt =
+          target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
+        if (tgt && emitted.insert(tgt).second) {
           this->Exports.push_back(tgt);
-          }
         }
       }
     }
+  }
 }
 
-std::string
-cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target,
-                                                const std::string& config)
+std::string cmExportTryCompileFileGenerator::InstallNameDir(
+  cmGeneratorTarget* target, const std::string& config)
 {
   std::string install_name_dir;
 
   cmMakefile* mf = target->Target->GetMakefile();
-  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
-    install_name_dir =
-      target->GetInstallNameDirForBuildTree(config);
-    }
+  if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
+    install_name_dir = target->GetInstallNameDirForBuildTree(config);
+  }
 
   return install_name_dir;
 }
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index fc135a4..26f4db1 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -17,7 +17,7 @@
 class cmInstallExportGenerator;
 class cmInstallTargetGenerator;
 
-class cmExportTryCompileFileGenerator: public cmExportFileGenerator
+class cmExportTryCompileFileGenerator : public cmExportFileGenerator
 {
 public:
   cmExportTryCompileFileGenerator(cmGlobalGenerator* gg,
@@ -27,18 +27,18 @@ public:
   /** Set the list of targets to export.  */
   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 std::string&,
+  virtual void GenerateImportTargetsConfig(std::ostream&, const std::string&,
                                            std::string const&,
-                            std::vector<std::string>&) {}
-  virtual void HandleMissingTarget(std::string&,
-                                   std::vector<std::string>&,
-                                   cmGeneratorTarget*,
-                                   cmGeneratorTarget*) {}
+                                           std::vector<std::string>&)
+  {
+  }
+  virtual void HandleMissingTarget(std::string&, std::vector<std::string>&,
+                                   cmGeneratorTarget*, cmGeneratorTarget*)
+  {
+  }
 
   void PopulateProperties(cmGeneratorTarget const* target,
                           ImportPropertyMap& properties,
@@ -46,12 +46,12 @@ protected:
 
   std::string InstallNameDir(cmGeneratorTarget* target,
                              const std::string& config);
+
 private:
   std::string FindTargets(const std::string& prop,
                           const cmGeneratorTarget* tgt,
                           std::set<const cmGeneratorTarget*>& emitted);
 
-
   std::vector<cmGeneratorTarget const*> Exports;
   std::string Config;
 };
diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx
index 6016c4c..2ba9b8d 100644
--- a/Source/cmExprParserHelper.cxx
+++ b/Source/cmExprParserHelper.cxx
@@ -11,12 +11,12 @@
 ============================================================================*/
 #include "cmExprParserHelper.h"
 
-#include "cmSystemTools.h"
 #include "cmMakefile.h"
+#include "cmSystemTools.h"
 
 #include "cmExprLexer.h"
 
-int cmExpr_yyparse( yyscan_t yyscanner );
+int cmExpr_yyparse(yyscan_t yyscanner);
 //
 cmExprParserHelper::cmExprParserHelper()
 {
@@ -24,7 +24,6 @@ cmExprParserHelper::cmExprParserHelper()
   this->FileName = 0;
 }
 
-
 cmExprParserHelper::~cmExprParserHelper()
 {
   this->CleanupParser();
@@ -32,11 +31,10 @@ cmExprParserHelper::~cmExprParserHelper()
 
 int cmExprParserHelper::ParseString(const char* str, int verb)
 {
-  if ( !str)
-    {
+  if (!str) {
     return 0;
-    }
-  //printf("Do some parsing: %s\n", str);
+  }
+  // printf("Do some parsing: %s\n", str);
 
   this->Verbose = verb;
   this->InputBuffer = str;
@@ -50,20 +48,18 @@ int cmExprParserHelper::ParseString(const char* str, int verb)
   cmExpr_yyset_extra(this, yyscanner);
   int res = cmExpr_yyparse(yyscanner);
   cmExpr_yylex_destroy(yyscanner);
-  if ( res != 0 )
-    {
-    //str << "CAL_Parser returned: " << res << std::endl;
-    //std::cerr << "When parsing: [" << str << "]" << std::endl;
+  if (res != 0) {
+    // str << "CAL_Parser returned: " << res << std::endl;
+    // std::cerr << "When parsing: [" << str << "]" << std::endl;
     return 0;
-    }
+  }
 
   this->CleanupParser();
 
-  if ( Verbose )
-    {
-    std::cerr << "Expanding [" << str << "] produced: ["
-              << this->Result << "]" << std::endl;
-    }
+  if (Verbose) {
+    std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]"
+              << std::endl;
+  }
   return 1;
 }
 
@@ -73,27 +69,22 @@ void cmExprParserHelper::CleanupParser()
 
 int cmExprParserHelper::LexInput(char* buf, int maxlen)
 {
-  //std::cout << "JPLexInput ";
-  //std::cout.write(buf, maxlen);
-  //std::cout << std::endl;
-  if ( maxlen < 1 )
-    {
+  // std::cout << "JPLexInput ";
+  // std::cout.write(buf, maxlen);
+  // std::cout << std::endl;
+  if (maxlen < 1) {
     return 0;
+  }
+  if (this->InputBufferPos < this->InputBuffer.size()) {
+    buf[0] = this->InputBuffer[this->InputBufferPos++];
+    if (buf[0] == '\n') {
+      this->CurrentLine++;
     }
-  if ( this->InputBufferPos < this->InputBuffer.size() )
-    {
-    buf[0] = this->InputBuffer[ this->InputBufferPos++ ];
-    if ( buf[0] == '\n' )
-      {
-      this->CurrentLine ++;
-      }
-    return(1);
-    }
-  else
-    {
+    return (1);
+  } else {
     buf[0] = '\n';
-    return( 0 );
-    }
+    return (0);
+  }
 }
 
 void cmExprParserHelper::Error(const char* str)
@@ -108,5 +99,3 @@ void cmExprParserHelper::SetResult(int value)
 {
   this->Result = value;
 }
-
-
diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h
index 8d6b2cd..af0b916 100644
--- a/Source/cmExprParserHelper.h
+++ b/Source/cmExprParserHelper.h
@@ -30,7 +30,8 @@ class cmMakefile;
 class cmExprParserHelper
 {
 public:
-  typedef struct {
+  typedef struct
+  {
     int Number;
   } ParserType;
 
@@ -66,6 +67,3 @@ private:
 };
 
 #endif
-
-
-
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index 9264671..0e42d75 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -9,62 +9,52 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include <assert.h>
 
 #include "cmExternalMakefileProjectGenerator.h"
 
-void cmExternalMakefileProjectGenerator
-::EnableLanguage(std::vector<std::string> const&,
-                 cmMakefile *, bool)
+#include <assert.h>
+
+void cmExternalMakefileProjectGenerator::EnableLanguage(
+  std::vector<std::string> const&, cmMakefile*, bool)
 {
 }
 
 std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
-                                            const std::string& globalGenerator,
-                                            const std::string& extraGenerator)
+  const std::string& globalGenerator, const std::string& extraGenerator)
 {
   std::string fullName;
-  if (!globalGenerator.empty())
-    {
-    if (!extraGenerator.empty())
-      {
+  if (!globalGenerator.empty()) {
+    if (!extraGenerator.empty()) {
       fullName = extraGenerator;
       fullName += " - ";
-      }
-    fullName += globalGenerator;
     }
+    fullName += globalGenerator;
+  }
   return fullName;
 }
 
 std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
-                                                  const std::string& fullName)
+  const std::string& fullName)
 {
   // at least one global generator must be supported
   assert(!this->SupportedGlobalGenerators.empty());
 
-  if (fullName.empty())
-    {
+  if (fullName.empty()) {
     return "";
-    }
+  }
 
-  std::string currentName = fullName;
   // if we get only the short name, take the first global generator as default
-  if (currentName == this->GetName())
-    {
+  if (fullName == this->GetName()) {
     return this->SupportedGlobalGenerators[0];
-    }
+  }
 
   // otherwise search for the matching global generator
-  for (std::vector<std::string>::const_iterator
-       it = this->SupportedGlobalGenerators.begin();
-       it != this->SupportedGlobalGenerators.end();
-       ++it)
-    {
-      if (this->CreateFullGeneratorName(*it, this->GetName())
-                                                                == currentName)
-      {
-        return *it;
-      }
+  for (std::vector<std::string>::const_iterator it =
+         this->SupportedGlobalGenerators.begin();
+       it != this->SupportedGlobalGenerators.end(); ++it) {
+    if (this->CreateFullGeneratorName(*it, this->GetName()) == fullName) {
+      return *it;
     }
+  }
   return "";
 }
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index cba1c76..5d4d54d 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -33,7 +33,6 @@ class cmGlobalGenerator;
 class cmExternalMakefileProjectGenerator
 {
 public:
-
   virtual ~cmExternalMakefileProjectGenerator() {}
 
   ///! Get the name for this generator.
@@ -42,15 +41,19 @@ public:
   virtual void GetDocumentation(cmDocumentationEntry& entry,
                                 const std::string& fullName) const = 0;
   virtual void EnableLanguage(std::vector<std::string> const& languages,
-                              cmMakefile *, bool optional);
+                              cmMakefile*, bool optional);
 
   ///! set the global generator which will generate the makefiles
   virtual void SetGlobalGenerator(cmGlobalGenerator* generator)
-                                           {this->GlobalGenerator = generator;}
+  {
+    this->GlobalGenerator = generator;
+  }
 
   ///! Return the list of global generators supported by this extra generator
   const std::vector<std::string>& GetSupportedGlobalGenerators() const
-                                      {return this->SupportedGlobalGenerators;}
+  {
+    return this->SupportedGlobalGenerators;
+  }
 
   ///! Get the name of the global generator for the given full name
   std::string GetGlobalGeneratorName(const std::string& fullName);
@@ -58,11 +61,11 @@ public:
    * extra generator name
    */
   static std::string CreateFullGeneratorName(
-                                            const std::string& globalGenerator,
-                                            const std::string& extraGenerator);
+    const std::string& globalGenerator, const std::string& extraGenerator);
 
   ///! Generate the project files, the Makefiles have already been generated
   virtual void Generate() = 0;
+
 protected:
   ///! Contains the names of the global generators support by this generator.
   std::vector<std::string> SupportedGlobalGenerators;
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 9348ef2..589bf53 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -11,14 +11,15 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExtraCodeBlocksGenerator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
-#include "cmake.h"
 #include "cmSourceFile.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
+#include "cmake.h"
 
 #include <cmsys/SystemTools.hxx>
 
@@ -35,16 +36,15 @@ Discussion:
 http://forums.codeblocks.org/index.php/topic,6789.0.html
 */
 
-//----------------------------------------------------------------------------
-void cmExtraCodeBlocksGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
+void cmExtraCodeBlocksGenerator::GetDocumentation(cmDocumentationEntry& entry,
+                                                  const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates CodeBlocks project files.";
 }
 
 cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator()
-:cmExternalMakefileProjectGenerator()
+  : cmExternalMakefileProjectGenerator()
 {
 #if defined(_WIN32)
   this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
@@ -56,37 +56,32 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator()
   this->SupportedGlobalGenerators.push_back("Unix Makefiles");
 }
 
-
 void cmExtraCodeBlocksGenerator::Generate()
 {
   // for each sub project in the project create a codeblocks project
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-       it = this->GlobalGenerator->GetProjectMap().begin();
-      it!= this->GlobalGenerator->GetProjectMap().end();
-      ++it)
-    {
+         it = this->GlobalGenerator->GetProjectMap().begin();
+       it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
     // create a project file
     this->CreateProjectFile(it->second);
-    }
+  }
 }
 
-
 /* create the project file */
 void cmExtraCodeBlocksGenerator::CreateProjectFile(
-                                     const std::vector<cmLocalGenerator*>& lgs)
+  const std::vector<cmLocalGenerator*>& lgs)
 {
-  std::string outputDir=lgs[0]->GetCurrentBinaryDirectory();
-  std::string projectName=lgs[0]->GetProjectName();
+  std::string outputDir = lgs[0]->GetCurrentBinaryDirectory();
+  std::string projectName = lgs[0]->GetProjectName();
 
-  std::string filename=outputDir+"/";
-  filename+=projectName+".cbp";
-  std::string sessionFilename=outputDir+"/";
-  sessionFilename+=projectName+".layout";
+  std::string filename = outputDir + "/";
+  filename += projectName + ".cbp";
+  std::string sessionFilename = outputDir + "/";
+  sessionFilename += projectName + ".layout";
 
   this->CreateNewProjectFile(lgs, filename);
 }
 
-
 /* Tree is used to create a "Virtual Folder" in CodeBlocks, in which all
  CMake files this project depends on will be put. This means additionally
  to the "Sources" and "Headers" virtual folders of CodeBlocks, there will
@@ -95,286 +90,261 @@ void cmExtraCodeBlocksGenerator::CreateProjectFile(
  files in QtCreator).*/
 struct Tree
 {
-  std::string path; //only one component of the path
+  std::string path; // only one component of the path
   std::vector<Tree> folders;
   std::vector<std::string> files;
   void InsertPath(const std::vector<std::string>& splitted,
                   std::vector<std::string>::size_type start,
                   const std::string& fileName);
-  void BuildVirtualFolder(std::string& virtualFolders) const;
+  void BuildVirtualFolder(cmXMLWriter& xml) const;
   void BuildVirtualFolderImpl(std::string& virtualFolders,
                               const std::string& prefix) const;
-  void BuildUnit(std::string& unitString, const std::string& fsPath) const;
-  void BuildUnitImpl(std::string& unitString,
-                     const std::string& virtualFolderPath,
+  void BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const;
+  void BuildUnitImpl(cmXMLWriter& xml, const std::string& virtualFolderPath,
                      const std::string& fsPath) const;
 };
 
-
 void Tree::InsertPath(const std::vector<std::string>& splitted,
                       std::vector<std::string>::size_type start,
                       const std::string& fileName)
 {
-  if (start == splitted.size())
-    {
+  if (start == splitted.size()) {
     files.push_back(fileName);
     return;
-    }
-  for (std::vector<Tree>::iterator
-       it = folders.begin();
-       it != folders.end();
-       ++it)
-    {
-    if ((*it).path == splitted[start])
-      {
-      if (start + 1 <  splitted.size())
-        {
+  }
+  for (std::vector<Tree>::iterator it = folders.begin(); it != folders.end();
+       ++it) {
+    if ((*it).path == splitted[start]) {
+      if (start + 1 < splitted.size()) {
         it->InsertPath(splitted, start + 1, fileName);
         return;
-        }
-      else
-        {
+      } else {
         // last part of splitted
         it->files.push_back(fileName);
         return;
-        }
       }
     }
+  }
   // Not found in folders, thus insert
   Tree newFolder;
   newFolder.path = splitted[start];
-  if (start + 1 <  splitted.size())
-    {
+  if (start + 1 < splitted.size()) {
     newFolder.InsertPath(splitted, start + 1, fileName);
     folders.push_back(newFolder);
     return;
-    }
-  else
-    {
+  } else {
     // last part of splitted
     newFolder.files.push_back(fileName);
     folders.push_back(newFolder);
     return;
-    }
+  }
 }
 
-
-void Tree::BuildVirtualFolder(std::string& virtualFolders) const
+void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
 {
-  virtualFolders += "<Option virtualFolders=\"CMake Files\\;";
+  xml.StartElement("Option");
+  std::string virtualFolders = "CMake Files\\;";
   for (std::vector<Tree>::const_iterator it = folders.begin();
-     it != folders.end();
-     ++it)
-    {
+       it != folders.end(); ++it) {
     it->BuildVirtualFolderImpl(virtualFolders, "");
-    }
-  virtualFolders += "\" />";
+  }
+  xml.Attribute("virtualFolders", virtualFolders);
+  xml.EndElement();
 }
 
-
 void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
                                   const std::string& prefix) const
 {
-  virtualFolders += "CMake Files\\" + prefix +  path + "\\;";
+  virtualFolders += "CMake Files\\" + prefix + path + "\\;";
   for (std::vector<Tree>::const_iterator it = folders.begin();
-       it != folders.end();
-     ++it)
-    {
+       it != folders.end(); ++it) {
     it->BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\");
-    }
+  }
 }
 
-
-void Tree::BuildUnit(std::string& unitString, const std::string& fsPath) const
+void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
 {
   for (std::vector<std::string>::const_iterator it = files.begin();
-       it != files.end();
-       ++it)
-    {
-    unitString += "      <Unit filename=\"" + fsPath + *it + "\">\n";
-    unitString += "          <Option virtualFolder=\"CMake Files\\\" />\n";
-    unitString += "      </Unit>\n";
-    }
+       it != files.end(); ++it) {
+    xml.StartElement("Unit");
+    xml.Attribute("filename", fsPath + *it);
+
+    xml.StartElement("Option");
+    xml.Attribute("virtualFolder", "CMake Files\\");
+    xml.EndElement();
+
+    xml.EndElement();
+  }
   for (std::vector<Tree>::const_iterator it = folders.begin();
-     it != folders.end();
-     ++it)
-    {
-    it->BuildUnitImpl(unitString, "", fsPath);
-    }
+       it != folders.end(); ++it) {
+    it->BuildUnitImpl(xml, "", fsPath);
+  }
 }
 
-
-void Tree::BuildUnitImpl(std::string& unitString,
+void Tree::BuildUnitImpl(cmXMLWriter& xml,
                          const std::string& virtualFolderPath,
                          const std::string& fsPath) const
 {
   for (std::vector<std::string>::const_iterator it = files.begin();
-       it != files.end();
-       ++it)
-    {
-    unitString += "      <Unit filename=\"" +fsPath+path+ "/" + *it + "\">\n";
-    unitString += "          <Option virtualFolder=\"CMake Files\\"
-               + virtualFolderPath + path + "\\\" />\n";
-    unitString += "      </Unit>\n";
-    }
+       it != files.end(); ++it) {
+    xml.StartElement("Unit");
+    xml.Attribute("filename", fsPath + path + "/" + *it);
+
+    xml.StartElement("Option");
+    xml.Attribute("virtualFolder",
+                  "CMake Files\\" + virtualFolderPath + path + "\\");
+    xml.EndElement();
+
+    xml.EndElement();
+  }
   for (std::vector<Tree>::const_iterator it = folders.begin();
-     it != folders.end();
-     ++it)
-    {
-    it->BuildUnitImpl(unitString,
-                      virtualFolderPath + path + "\\", fsPath + path + "/");
-    }
+       it != folders.end(); ++it) {
+    it->BuildUnitImpl(xml, virtualFolderPath + path + "\\",
+                      fsPath + path + "/");
+  }
 }
 
-
-void cmExtraCodeBlocksGenerator
-  ::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
-                         const std::string& filename)
+void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
+  const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
 {
-  const cmMakefile* mf=lgs[0]->GetMakefile();
+  const cmMakefile* mf = lgs[0]->GetMakefile();
   cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
 
   Tree tree;
 
   // build tree of virtual folders
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-          it = this->GlobalGenerator->GetProjectMap().begin();
-         it != this->GlobalGenerator->GetProjectMap().end();
-         ++it)
-    {
+         it = this->GlobalGenerator->GetProjectMap().begin();
+       it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
     // Collect all files
     std::vector<std::string> listFiles;
-    for (std::vector<cmLocalGenerator *>::const_iterator
-         jt = it->second.begin();
-         jt != it->second.end();
-         ++jt)
-      {
-      const std::vector<std::string> & files =
-                                          (*jt)->GetMakefile()->GetListFiles();
+    for (std::vector<cmLocalGenerator*>::const_iterator jt =
+           it->second.begin();
+         jt != it->second.end(); ++jt) {
+      const std::vector<std::string>& files =
+        (*jt)->GetMakefile()->GetListFiles();
       listFiles.insert(listFiles.end(), files.begin(), files.end());
-      }
+    }
 
     // Convert
-    const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT");
     for (std::vector<std::string>::const_iterator jt = listFiles.begin();
-         jt != listFiles.end();
-         ++jt)
-      {
+         jt != listFiles.end(); ++jt) {
       // don't put cmake's own files into the project (#12110):
-      if (jt->find(cmakeRoot) == 0)
-        {
+      if (jt->find(cmSystemTools::GetCMakeRoot()) == 0) {
         continue;
-        }
+      }
 
-      const std::string &relative = cmSystemTools::RelativePath(
-                         it->second[0]->GetSourceDirectory(),
-                         jt->c_str());
+      const std::string& relative = cmSystemTools::RelativePath(
+        it->second[0]->GetSourceDirectory(), jt->c_str());
       std::vector<std::string> splitted;
       cmSystemTools::SplitPath(relative, splitted, false);
       // Split filename from path
-      std::string fileName = *(splitted.end()-1);
+      std::string fileName = *(splitted.end() - 1);
       splitted.erase(splitted.end() - 1, splitted.end());
 
       // We don't want paths with CMakeFiles in them
       // or do we?
       // In speedcrunch those where purely internal
-      if (splitted.size() >= 1
-          && relative.find("CMakeFiles") == std::string::npos)
-        {
+      if (splitted.size() >= 1 &&
+          relative.find("CMakeFiles") == std::string::npos) {
         tree.InsertPath(splitted, 1, fileName);
-        }
       }
     }
-
-  // Now build a virtual tree string
-  std::string virtualFolders;
-  tree.BuildVirtualFolder(virtualFolders);
-  // And one for <Unit>
-  std::string unitFiles;
-  tree.BuildUnit(unitFiles, std::string(lgs[0]->GetSourceDirectory()) + "/");
+  }
 
   // figure out the compiler
   std::string compiler = this->GetCBCompilerId(mf);
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+  const std::string makeArgs =
+    mf->GetSafeDefinition("CMAKE_CODEBLOCKS_MAKE_ARGUMENTS");
+
+  cmXMLWriter xml(fout);
+  xml.StartDocument();
+  xml.StartElement("CodeBlocks_project_file");
+
+  xml.StartElement("FileVersion");
+  xml.Attribute("major", 1);
+  xml.Attribute("minor", 6);
+  xml.EndElement();
+
+  xml.StartElement("Project");
+
+  xml.StartElement("Option");
+  xml.Attribute("title", lgs[0]->GetProjectName());
+  xml.EndElement();
+
+  xml.StartElement("Option");
+  xml.Attribute("makefile_is_custom", 1);
+  xml.EndElement();
+
+  xml.StartElement("Option");
+  xml.Attribute("compiler", compiler);
+  xml.EndElement();
+
+  // Now build a virtual tree
+  tree.BuildVirtualFolder(xml);
 
-  fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"
-        "<CodeBlocks_project_file>\n"
-        "   <FileVersion major=\"1\" minor=\"6\" />\n"
-        "   <Project>\n"
-        "      <Option title=\"" << lgs[0]->GetProjectName()<<"\" />\n"
-        "      <Option makefile_is_custom=\"1\" />\n"
-        "      <Option compiler=\"" << compiler << "\" />\n"
-        "      "<<virtualFolders<<"\n"
-        "      <Build>\n";
+  xml.StartElement("Build");
 
-  this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str());
+  this->AppendTarget(xml, "all", 0, make.c_str(), lgs[0], compiler.c_str(),
+                     makeArgs);
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
-  for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
-       lg!=lgs.end(); lg++)
-    {
-    std::vector<cmGeneratorTarget*> targets=(*lg)->GetGeneratorTargets();
+  for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
+       lg != lgs.end(); lg++) {
+    std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-         ti != targets.end(); ti++)
-      {
+         ti != targets.end(); ti++) {
       std::string targetName = (*ti)->GetName();
-      switch((*ti)->GetType())
-        {
-        case cmState::GLOBAL_TARGET:
-          {
+      switch ((*ti)->GetType()) {
+        case cmState::GLOBAL_TARGET: {
           // Only add the global targets from CMAKE_BINARY_DIR,
           // not from the subdirs
           if (strcmp((*lg)->GetCurrentBinaryDirectory(),
-                     (*lg)->GetBinaryDirectory())==0)
-            {
-            this->AppendTarget(fout, targetName, 0,
-                               make.c_str(), *lg, compiler.c_str());
-            }
+                     (*lg)->GetBinaryDirectory()) == 0) {
+            this->AppendTarget(xml, targetName, 0, make.c_str(), *lg,
+                               compiler.c_str(), makeArgs);
           }
-          break;
+        } break;
         case cmState::UTILITY:
           // Add all utility targets, except the Nightly/Continuous/
           // Experimental-"sub"targets as e.g. NightlyStart
-          if (((targetName.find("Nightly")==0)   &&(targetName!="Nightly"))
-             || ((targetName.find("Continuous")==0)
-                 &&(targetName!="Continuous"))
-             || ((targetName.find("Experimental")==0)
-                                             && (targetName!="Experimental")))
-            {
+          if (((targetName.find("Nightly") == 0) &&
+               (targetName != "Nightly")) ||
+              ((targetName.find("Continuous") == 0) &&
+               (targetName != "Continuous")) ||
+              ((targetName.find("Experimental") == 0) &&
+               (targetName != "Experimental"))) {
             break;
-            }
+          }
 
-          this->AppendTarget(fout, targetName, 0,
-                                 make.c_str(), *lg, compiler.c_str());
+          this->AppendTarget(xml, targetName, 0, make.c_str(), *lg,
+                             compiler.c_str(), makeArgs);
           break;
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
         case cmState::SHARED_LIBRARY:
         case cmState::MODULE_LIBRARY:
-        case cmState::OBJECT_LIBRARY:
-          {
+        case cmState::OBJECT_LIBRARY: {
           cmGeneratorTarget* gt = *ti;
-          this->AppendTarget(fout, targetName, gt,
-                             make.c_str(), *lg, compiler.c_str());
+          this->AppendTarget(xml, targetName, gt, make.c_str(), *lg,
+                             compiler.c_str(), makeArgs);
           std::string fastTarget = targetName;
           fastTarget += "/fast";
-          this->AppendTarget(fout, fastTarget, gt,
-                             make.c_str(), *lg, compiler.c_str());
-          }
-          break;
+          this->AppendTarget(xml, fastTarget, gt, make.c_str(), *lg,
+                             compiler.c_str(), makeArgs);
+        } break;
         default:
           break;
-        }
       }
     }
+  }
 
-  fout<<"      </Build>\n";
-
+  xml.EndElement(); // Build
 
   // Collect all used source files in the project.
   // Keep a list of C/C++ source files which might have an acompanying header
@@ -384,74 +354,66 @@ void cmExtraCodeBlocksGenerator
   std::vector<std::string> cFiles;
 
   std::vector<std::string> srcExts =
-      this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
+    this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
 
-  for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
-       lg!=lgs.end(); lg++)
-    {
-    cmMakefile* makefile=(*lg)->GetMakefile();
-    std::vector<cmGeneratorTarget*> targets=(*lg)->GetGeneratorTargets();
+  for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
+       lg != lgs.end(); lg++) {
+    cmMakefile* makefile = (*lg)->GetMakefile();
+    std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-         ti != targets.end(); ti++)
-      {
-      switch((*ti)->GetType())
-        {
+         ti != targets.end(); ti++) {
+      switch ((*ti)->GetType()) {
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
         case cmState::SHARED_LIBRARY:
         case cmState::MODULE_LIBRARY:
         case cmState::OBJECT_LIBRARY:
         case cmState::UTILITY: // can have sources since 2.6.3
-          {
+        {
           std::vector<cmSourceFile*> sources;
           cmGeneratorTarget* gt = *ti;
           gt->GetSourceFiles(sources,
-                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-          for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
-               si!=sources.end(); si++)
-            {
+                             makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+          for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+               si != sources.end(); si++) {
             // don't add source files which have the GENERATED property set:
-            if ((*si)->GetPropertyAsBool("GENERATED"))
-              {
+            if ((*si)->GetPropertyAsBool("GENERATED")) {
               continue;
-              }
+            }
 
             // check whether it is a C/C++ implementation file
             bool isCFile = false;
             std::string lang = (*si)->GetLanguage();
-            if (lang == "C" || lang == "CXX")
-              {
+            if (lang == "C" || lang == "CXX") {
               std::string srcext = (*si)->GetExtension();
-              for(std::vector<std::string>::const_iterator
-                  ext = srcExts.begin(); ext != srcExts.end(); ++ext)
-                {
-                if (srcext == *ext)
-                  {
+              for (std::vector<std::string>::const_iterator ext =
+                     srcExts.begin();
+                   ext != srcExts.end(); ++ext) {
+                if (srcext == *ext) {
                   isCFile = true;
                   break;
-                  }
                 }
               }
+            }
 
             std::string fullPath = (*si)->GetFullPath();
 
-            if(isCFile)
-              {
+            if (isCFile) {
               cFiles.push_back(fullPath);
-              }
+            }
 
-            CbpUnit &cbpUnit = allFiles[fullPath];
+            CbpUnit& cbpUnit = allFiles[fullPath];
             cbpUnit.Targets.push_back(*ti);
-            }
           }
-        default:  // intended fallthrough
-          break;
         }
+        default: // intended fallthrough
+          break;
       }
     }
+  }
 
   std::vector<std::string> headerExts =
-      this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
+    this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
 
   // The following loop tries to add header files matching to implementation
   // files to the project. It does that by iterating over all
@@ -460,73 +422,62 @@ void cmExtraCodeBlocksGenerator
   // file exists. If it does, it is inserted into the map of files.
   // A very similar version of that code exists also in the kdevelop
   // project generator.
-  for (std::vector<std::string>::const_iterator
-       sit=cFiles.begin();
-       sit!=cFiles.end();
-       ++sit)
-    {
+  for (std::vector<std::string>::const_iterator sit = cFiles.begin();
+       sit != cFiles.end(); ++sit) {
     std::string const& fileName = *sit;
-    std::string headerBasename=cmSystemTools::GetFilenamePath(fileName);
-    headerBasename+="/";
-    headerBasename+=cmSystemTools::GetFilenameWithoutExtension(fileName);
+    std::string headerBasename = cmSystemTools::GetFilenamePath(fileName);
+    headerBasename += "/";
+    headerBasename += cmSystemTools::GetFilenameWithoutExtension(fileName);
 
     // check if there's a matching header around
-    for(std::vector<std::string>::const_iterator
-        ext = headerExts.begin();
-        ext != headerExts.end();
-        ++ext)
-      {
-      std::string hname=headerBasename;
+    for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+         ext != headerExts.end(); ++ext) {
+      std::string hname = headerBasename;
       hname += ".";
       hname += *ext;
       // if it's already in the set, don't check if it exists on disk
-      if (allFiles.find(hname) != allFiles.end())
-        {
+      if (allFiles.find(hname) != allFiles.end()) {
         break;
-        }
+      }
 
-      if(cmSystemTools::FileExists(hname.c_str()))
-        {
+      if (cmSystemTools::FileExists(hname.c_str())) {
         allFiles[hname].Targets = allFiles[fileName].Targets;
         break;
-        }
       }
     }
+  }
 
   // insert all source files in the CodeBlocks project
-  for (all_files_map_t::const_iterator
-       sit=allFiles.begin();
-       sit!=allFiles.end();
-       ++sit)
-    {
+  for (all_files_map_t::const_iterator sit = allFiles.begin();
+       sit != allFiles.end(); ++sit) {
     std::string const& unitFilename = sit->first;
     CbpUnit const& unit = sit->second;
 
-    fout<<"      <Unit filename=\""<< cmXMLSafe(unitFilename) <<"\">\n";
-
-    for(std::vector<const cmGeneratorTarget*>::const_iterator ti =
-        unit.Targets.begin();
-        ti != unit.Targets.end(); ++ti)
-      {
-      std::string const& targetName = (*ti)->GetName();
-      fout<<"         <Option target=\""<< cmXMLSafe(targetName) <<"\"/>\n";
-      }
+    xml.StartElement("Unit");
+    xml.Attribute("filename", unitFilename);
 
-    fout<<"      </Unit>\n";
+    for (std::vector<const cmGeneratorTarget*>::const_iterator ti =
+           unit.Targets.begin();
+         ti != unit.Targets.end(); ++ti) {
+      xml.StartElement("Option");
+      xml.Attribute("target", (*ti)->GetName());
+      xml.EndElement();
     }
 
+    xml.EndElement();
+  }
+
   // Add CMakeLists.txt
-  fout<<unitFiles;
+  tree.BuildUnit(xml, std::string(mf->GetHomeDirectory()) + "/");
 
-  fout<<"   </Project>\n"
-        "</CodeBlocks_project_file>\n";
+  xml.EndElement(); // Project
+  xml.EndElement(); // CodeBlocks_project_file
+  xml.EndDocument();
 }
 
-
 // Write a dummy file for OBJECT libraries, so C::B can reference some file
 std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
-                                        cmLocalGenerator* lg,
-                                        cmGeneratorTarget* target) const
+  cmLocalGenerator* lg, cmGeneratorTarget* target) const
 {
   // this file doesn't seem to be used by C::B in custom makefile mode,
   // but we generate a unique file for each OBJECT library so in case
@@ -538,260 +489,284 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
   filename += target->GetName();
   filename += ".objlib";
   cmGeneratedFileStream fout(filename.c_str());
-  if(fout)
-    {
+  if (fout) {
+    /* clang-format off */
     fout << "# This is a dummy file for the OBJECT library "
          << target->GetName()
          << " for the CMake CodeBlocks project generator.\n"
          << "# Don't edit, this file will be overwritten.\n";
-    }
+    /* clang-format on */
+  }
   return filename;
 }
 
-
 // Generate the xml code for one target.
-void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
-                                              const std::string& targetName,
-                                              cmGeneratorTarget* target,
-                                              const char* make,
-                                              const cmLocalGenerator* lg,
-                                              const char* compiler)
+void cmExtraCodeBlocksGenerator::AppendTarget(
+  cmXMLWriter& xml, const std::string& targetName, cmGeneratorTarget* target,
+  const char* make, const cmLocalGenerator* lg, const char* compiler,
+  const std::string& makeFlags)
 {
   cmMakefile const* makefile = lg->GetMakefile();
   std::string makefileName = lg->GetCurrentBinaryDirectory();
   makefileName += "/Makefile";
 
-  fout<<"      <Target title=\"" << targetName << "\">\n";
-  if (target!=0)
-    {
+  xml.StartElement("Target");
+  xml.Attribute("title", targetName);
+
+  if (target != 0) {
     int cbTargetType = this->GetCBTargetType(target);
     std::string workingDir = lg->GetCurrentBinaryDirectory();
-    if ( target->GetType()==cmState::EXECUTABLE)
-      {
+    if (target->GetType() == cmState::EXECUTABLE) {
       // Determine the directory where the executable target is created, and
       // set the working directory to this dir.
-      const char* runtimeOutputDir = makefile->GetDefinition(
-                                             "CMAKE_RUNTIME_OUTPUT_DIRECTORY");
-      if (runtimeOutputDir != 0)
-        {
+      const char* runtimeOutputDir =
+        makefile->GetDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY");
+      if (runtimeOutputDir != 0) {
         workingDir = runtimeOutputDir;
-        }
-      else
-        {
-        const char* executableOutputDir = makefile->GetDefinition(
-                                                     "EXECUTABLE_OUTPUT_PATH");
-        if (executableOutputDir != 0)
-          {
+      } else {
+        const char* executableOutputDir =
+          makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
+        if (executableOutputDir != 0) {
           workingDir = executableOutputDir;
-          }
         }
       }
+    }
 
     std::string buildType = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
     std::string location;
-    if ( target->GetType()==cmState::OBJECT_LIBRARY)
-      {
-      location = this->CreateDummyTargetFile(const_cast<cmLocalGenerator*>(lg),
-                                             target);
-      }
-    else
-      {
+    if (target->GetType() == cmState::OBJECT_LIBRARY) {
+      location =
+        this->CreateDummyTargetFile(const_cast<cmLocalGenerator*>(lg), target);
+    } else {
       location = target->GetLocation(buildType);
-      }
+    }
+
+    xml.StartElement("Option");
+    xml.Attribute("output", location);
+    xml.Attribute("prefix_auto", 0);
+    xml.Attribute("extension_auto", 0);
+    xml.EndElement();
+
+    xml.StartElement("Option");
+    xml.Attribute("working_dir", workingDir);
+    xml.EndElement();
+
+    xml.StartElement("Option");
+    xml.Attribute("object_output", "./");
+    xml.EndElement();
 
-    fout<<"         <Option output=\"" << location
-                            << "\" prefix_auto=\"0\" extension_auto=\"0\" />\n"
-          "         <Option working_dir=\"" << workingDir << "\" />\n"
-          "         <Option object_output=\"./\" />\n"
-          "         <Option type=\"" << cbTargetType << "\" />\n"
-          "         <Option compiler=\"" << compiler << "\" />\n"
-          "         <Compiler>\n";
+    xml.StartElement("Option");
+    xml.Attribute("type", cbTargetType);
+    xml.EndElement();
+
+    xml.StartElement("Option");
+    xml.Attribute("compiler", compiler);
+    xml.EndElement();
+
+    xml.StartElement("Compiler");
 
     // the compilerdefines for this target
     std::vector<std::string> cdefs;
     target->GetCompileDefinitions(cdefs, buildType, "C");
 
     // Expand the list.
-    for(std::vector<std::string>::const_iterator di = cdefs.begin();
-        di != cdefs.end(); ++di)
-      {
-      cmXMLSafe safedef(di->c_str());
-      fout <<"            <Add option=\"-D" << safedef.str() << "\" />\n";
-      }
+    for (std::vector<std::string>::const_iterator di = cdefs.begin();
+         di != cdefs.end(); ++di) {
+      xml.StartElement("Add");
+      xml.Attribute("option", "-D" + *di);
+      xml.EndElement();
+    }
 
     // the include directories for this target
-    std::set<std::string> uniqIncludeDirs;
+    std::vector<std::string> allIncludeDirs;
 
     std::vector<std::string> includes;
     lg->GetIncludeDirectories(includes, target, "C", buildType);
 
-    uniqIncludeDirs.insert(includes.begin(), includes.end());
+    allIncludeDirs.insert(allIncludeDirs.end(), includes.begin(),
+                          includes.end());
 
     std::string systemIncludeDirs = makefile->GetSafeDefinition(
-                              "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
-    if (!systemIncludeDirs.empty())
-      {
+      "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
+    if (!systemIncludeDirs.empty()) {
       std::vector<std::string> dirs;
       cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
-      uniqIncludeDirs.insert(dirs.begin(), dirs.end());
-      }
+      allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end());
+    }
 
     systemIncludeDirs = makefile->GetSafeDefinition(
-                            "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
-    if (!systemIncludeDirs.empty())
-      {
+      "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
+    if (!systemIncludeDirs.empty()) {
       std::vector<std::string> dirs;
       cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
-      uniqIncludeDirs.insert(dirs.begin(), dirs.end());
-      }
+      allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end());
+    }
 
-    for(std::set<std::string>::const_iterator dirIt=uniqIncludeDirs.begin();
-        dirIt != uniqIncludeDirs.end();
-        ++dirIt)
-      {
-      fout <<"            <Add directory=\"" << *dirIt << "\" />\n";
-      }
+    std::vector<std::string>::const_iterator end =
+      cmRemoveDuplicates(allIncludeDirs);
 
-    fout<<"         </Compiler>\n";
-    }
-  else // e.g. all and the GLOBAL and UTILITY targets
-    {
-    fout<<"         <Option working_dir=\""
-        << lg->GetCurrentBinaryDirectory() << "\" />\n"
-        <<"         <Option type=\"" << 4 << "\" />\n";
+    for (std::vector<std::string>::const_iterator i = allIncludeDirs.begin();
+         i != end; ++i) {
+      xml.StartElement("Add");
+      xml.Attribute("directory", *i);
+      xml.EndElement();
     }
 
-  fout<<"         <MakeCommands>\n"
-        "            <Build command=\""
-      << this->BuildMakeCommand(make, makefileName.c_str(), targetName)
-      << "\" />\n"
-        "            <CompileFile command=\""
-      << this->BuildMakeCommand(make, makefileName.c_str(),""$file"")
-      << "\" />\n"
-        "            <Clean command=\""
-      << this->BuildMakeCommand(make, makefileName.c_str(), "clean")
-      << "\" />\n"
-        "            <DistClean command=\""
-      << this->BuildMakeCommand(make, makefileName.c_str(), "clean")
-      << "\" />\n"
-        "         </MakeCommands>\n"
-        "      </Target>\n";
+    xml.EndElement(); // Compiler
+  } else              // e.g. all and the GLOBAL and UTILITY targets
+  {
+    xml.StartElement("Option");
+    xml.Attribute("working_dir", lg->GetCurrentBinaryDirectory());
+    xml.EndElement();
 
-}
+    xml.StartElement("Option");
+    xml.Attribute("type", 4);
+    xml.EndElement();
+  }
 
+  xml.StartElement("MakeCommands");
+
+  xml.StartElement("Build");
+  xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
+                                                  targetName, makeFlags));
+  xml.EndElement();
+
+  xml.StartElement("CompileFile");
+  xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
+                                                  "\"$file\"", makeFlags));
+  xml.EndElement();
+
+  xml.StartElement("Clean");
+  xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
+                                                  "clean", makeFlags));
+  xml.EndElement();
+
+  xml.StartElement("DistClean");
+  xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
+                                                  "clean", makeFlags));
+  xml.EndElement();
+
+  xml.EndElement(); // MakeCommands
+  xml.EndElement(); // Target
+}
 
 // Translate the cmake compiler id into the CodeBlocks compiler id
 std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
 {
   // figure out which language to use
-  // for now care only for C and C++
-  std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
-  if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false)
-    {
+  // for now care only for C, C++, and Fortran
+
+  // projects with C/C++ and Fortran are handled as C/C++ projects
+  bool pureFortran = false;
+  std::string compilerIdVar;
+  if (this->GlobalGenerator->GetLanguageEnabled("CXX") == true) {
+    compilerIdVar = "CMAKE_CXX_COMPILER_ID";
+  } else if (this->GlobalGenerator->GetLanguageEnabled("C") == true) {
     compilerIdVar = "CMAKE_C_COMPILER_ID";
-    }
+  } else if (this->GlobalGenerator->GetLanguageEnabled("Fortran") == true) {
+    compilerIdVar = "CMAKE_Fortran_COMPILER_ID";
+    pureFortran = true;
+  }
 
   std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
-  std::string compiler = "gcc";  // default to gcc
-  if (compilerId == "MSVC")
-    {
-    compiler = "msvc8";
-    }
-  else if (compilerId == "Borland")
-    {
+  std::string compiler = "gcc"; // default to gcc
+  if (compilerId == "MSVC") {
+    if (mf->IsDefinitionSet("MSVC10") == true) {
+      compiler = "msvc10";
+    } else {
+      compiler = "msvc8";
+    }
+  } else if (compilerId == "Borland") {
     compiler = "bcc";
-    }
-  else if (compilerId == "SDCC")
-    {
+  } else if (compilerId == "SDCC") {
     compiler = "sdcc";
+  } else if (compilerId == "Intel") {
+    if (pureFortran && mf->IsDefinitionSet("WIN32")) {
+      compiler = "ifcwin"; // Intel Fortran for Windows (known by cbFortran)
+    } else {
+      compiler = "icc";
     }
-  else if (compilerId == "Intel")
-    {
-    compiler = "icc";
-    }
-  else if (compilerId == "Watcom" || compilerId == "OpenWatcom")
-    {
+  } else if (compilerId == "Watcom" || compilerId == "OpenWatcom") {
     compiler = "ow";
-    }
-  else if (compilerId == "GNU")
-    {
-    compiler = "gcc";
-    }
+  } else if (compilerId == "Clang") {
+    compiler = "clang";
+  } else if (compilerId == "PGI") {
+    if (pureFortran) {
+      compiler = "pgifortran";
+    } else {
+      compiler = "pgi"; // does not exist as default in CodeBlocks 16.01
+    }
+  } else if (compilerId == "GNU") {
+    if (pureFortran) {
+      compiler = "gfortran";
+    } else {
+      compiler = "gcc";
+    }
+  }
   return compiler;
 }
 
-
 // Translate the cmake target type into the CodeBlocks target type id
 int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
 {
-  if ( target->GetType()==cmState::EXECUTABLE)
-    {
-    if ((target->GetPropertyAsBool("WIN32_EXECUTABLE"))
-        || (target->GetPropertyAsBool("MACOSX_BUNDLE")))
-      {
+  if (target->GetType() == cmState::EXECUTABLE) {
+    if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) ||
+        (target->GetPropertyAsBool("MACOSX_BUNDLE"))) {
       return 0;
-      }
-    else
-      {
+    } else {
       return 1;
-      }
     }
-  else if (( target->GetType()==cmState::STATIC_LIBRARY)
-        || (target->GetType()==cmState::OBJECT_LIBRARY))
-    {
+  } else if ((target->GetType() == cmState::STATIC_LIBRARY) ||
+             (target->GetType() == cmState::OBJECT_LIBRARY)) {
     return 2;
-    }
-  else if ((target->GetType()==cmState::SHARED_LIBRARY)
-           || (target->GetType()==cmState::MODULE_LIBRARY))
-    {
+  } else if ((target->GetType() == cmState::SHARED_LIBRARY) ||
+             (target->GetType() == cmState::MODULE_LIBRARY)) {
     return 3;
-    }
+  }
   return 4;
 }
 
 // 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 std::string& target)
+  const std::string& make, const char* makefile, const std::string& target,
+  const std::string& makeFlags)
 {
   std::string command = make;
+  if (makeFlags.size() > 0) {
+    command += " ";
+    command += makeFlags;
+  }
+
   std::string generator = this->GlobalGenerator->GetName();
-  if (generator == "NMake Makefiles")
-    {
+  if (generator == "NMake Makefiles") {
     // For Windows ConvertToOutputPath already adds quotes when required.
     // These need to be escaped, see
     // http://public.kitware.com/Bug/view.php?id=13952
     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
     command += " /NOLOGO /f ";
-    command += cmXMLSafe(makefileName).str();
+    command += makefileName;
     command += " VERBOSE=1 ";
     command += target;
-    }
-  else if (generator == "MinGW Makefiles")
-    {
+  } else if (generator == "MinGW Makefiles") {
     // no escaping of spaces in this case, see
     // http://public.kitware.com/Bug/view.php?id=10014
     std::string makefileName = makefile;
-    command += " -f "";
+    command += " -f \"";
     command += makefileName;
-    command += "" ";
+    command += "\" ";
     command += " VERBOSE=1 ";
     command += target;
-    }
-  else if (generator == "Ninja")
-    {
+  } else if (generator == "Ninja") {
     command += " -v ";
     command += target;
-    }
-  else
-    {
+  } else {
     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
-    command += " -f "";
+    command += " -f \"";
     command += makefileName;
-    command += "" ";
+    command += "\" ";
     command += " VERBOSE=1 ";
     command += target;
-    }
+  }
   return command;
 }
diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h
index 0c3846d..fe4f513 100644
--- a/Source/cmExtraCodeBlocksGenerator.h
+++ b/Source/cmExtraCodeBlocksGenerator.h
@@ -18,7 +18,7 @@
 class cmLocalGenerator;
 class cmMakefile;
 class cmGeneratorTarget;
-class cmGeneratedFileStream;
+class cmXMLWriter;
 
 /** \class cmExtraCodeBlocksGenerator
  * \brief Write CodeBlocks project files for Makefile based projects
@@ -29,15 +29,20 @@ public:
   cmExtraCodeBlocksGenerator();
 
   virtual std::string GetName() const
-                         { return cmExtraCodeBlocksGenerator::GetActualName();}
-  static std::string GetActualName()                    { return "CodeBlocks";}
+  {
+    return cmExtraCodeBlocksGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "CodeBlocks"; }
   static cmExternalMakefileProjectGenerator* New()
-                                     { return new cmExtraCodeBlocksGenerator; }
+  {
+    return new cmExtraCodeBlocksGenerator;
+  }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
                                 const std::string& fullName) const;
 
   virtual void Generate();
+
 private:
   struct CbpUnit
   {
@@ -47,21 +52,19 @@ private:
   void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
-                                const std::string& filename);
+                            const std::string& filename);
   std::string CreateDummyTargetFile(cmLocalGenerator* lg,
                                     cmGeneratorTarget* target) const;
 
   std::string GetCBCompilerId(const cmMakefile* mf);
   int GetCBTargetType(cmGeneratorTarget* target);
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
-                               const std::string& target);
-  void AppendTarget(cmGeneratedFileStream& fout,
-                    const std::string& targetName,
-                    cmGeneratorTarget* target,
-                    const char* make,
-                    const cmLocalGenerator* lg,
-                    const char* compiler);
-
+                               const std::string& target,
+                               const std::string& makeFlags);
+  void AppendTarget(cmXMLWriter& xml, const std::string& targetName,
+                    cmGeneratorTarget* target, const char* make,
+                    const cmLocalGenerator* lg, const char* compiler,
+                    const std::string& makeFlags);
 };
 
 #endif
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index 67aa157..ba58767 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -12,21 +12,21 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExtraCodeLiteGenerator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
-#include "cmake.h"
 #include "cmSourceFile.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
+#include "cmake.h"
 
-#include <cmsys/SystemTools.hxx>
-#include <cmsys/SystemInformation.hxx>
-#include <cmsys/Directory.hxx>
 #include "cmStandardIncludes.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
+#include <cmsys/Directory.hxx>
+#include <cmsys/SystemInformation.hxx>
+#include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------------
 void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
                                                 const std::string&) const
 {
@@ -54,95 +54,109 @@ void cmExtraCodeLiteGenerator::Generate()
   std::string workspaceOutputDir;
   std::string workspaceFileName;
   std::string workspaceSourcePath;
-  std::string lprjdebug;
 
-  cmGeneratedFileStream fout;
+  const std::map<std::string, std::vector<cmLocalGenerator*> >& projectMap =
+    this->GlobalGenerator->GetProjectMap();
 
   // loop projects and locate the root project.
   // and extract the information for creating the worspace
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-       it = this->GlobalGenerator->GetProjectMap().begin();
-       it!= this->GlobalGenerator->GetProjectMap().end();
-       ++it)
-    {
-    const cmMakefile* mf =it->second[0]->GetMakefile();
-    this->ConfigName = GetConfigurationName( mf );
+         it = projectMap.begin();
+       it != projectMap.end(); ++it) {
+    const cmMakefile* mf = it->second[0]->GetMakefile();
+    this->ConfigName = GetConfigurationName(mf);
 
     if (strcmp(it->second[0]->GetCurrentBinaryDirectory(),
-               it->second[0]->GetBinaryDirectory()) == 0)
-      {
-      workspaceOutputDir   = it->second[0]->GetCurrentBinaryDirectory();
+               it->second[0]->GetBinaryDirectory()) == 0) {
+      workspaceOutputDir = it->second[0]->GetCurrentBinaryDirectory();
       workspaceProjectName = it->second[0]->GetProjectName();
-      workspaceSourcePath  = it->second[0]->GetSourceDirectory();
-      workspaceFileName    = workspaceOutputDir+"/";
-      workspaceFileName   += workspaceProjectName + ".workspace";
-      this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();;
-
-      fout.Open(workspaceFileName.c_str(), false, false);
-      fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-           "<CodeLite_Workspace Name=\"" << workspaceProjectName << "\" >\n";
-      }
+      workspaceSourcePath = it->second[0]->GetSourceDirectory();
+      workspaceFileName = workspaceOutputDir + "/";
+      workspaceFileName += workspaceProjectName + ".workspace";
+      this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();
+      ;
+      break;
     }
+  }
+
+  cmGeneratedFileStream fout(workspaceFileName.c_str());
+  cmXMLWriter xml(fout);
+
+  xml.StartDocument("utf-8");
+  xml.StartElement("CodeLite_Workspace");
+  xml.Attribute("Name", workspaceProjectName);
 
   // for each sub project in the workspace create a codelite project
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-       it = this->GlobalGenerator->GetProjectMap().begin();
-       it!= this->GlobalGenerator->GetProjectMap().end();
-       ++it)
-    {
+         it = projectMap.begin();
+       it != projectMap.end(); ++it) {
     // retrive project information
-    std::string outputDir   = it->second[0]->GetCurrentBinaryDirectory();
+    std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
     std::string projectName = it->second[0]->GetProjectName();
-    std::string filename    = outputDir + "/" + projectName + ".project";
+    std::string filename = outputDir + "/" + projectName + ".project";
 
     // Make the project file relative to the workspace
     filename = cmSystemTools::RelativePath(this->WorkspacePath.c_str(),
-                                          filename.c_str());
+                                           filename.c_str());
 
     // create a project file
     this->CreateProjectFile(it->second);
-    fout << "  <Project Name=\"" << projectName << "\" Path=\""
-    << filename << "\" Active=\"No\"/>\n";
-    lprjdebug += "<Project Name=\"" + projectName
-              + "\" ConfigName=\"" + this->ConfigName + "\"/>\n";
-    }
+    xml.StartElement("Project");
+    xml.Attribute("Name", projectName);
+    xml.Attribute("Path", filename);
+    xml.Attribute("Active", "No");
+    xml.EndElement();
+  }
+
+  xml.StartElement("BuildMatrix");
+  xml.StartElement("WorkspaceConfiguration");
+  xml.Attribute("Name", this->ConfigName);
+  xml.Attribute("Selected", "yes");
 
-  fout << "  <BuildMatrix>\n"
-       "    <WorkspaceConfiguration Name=\""
-       << this->ConfigName << "\" Selected=\"yes\">\n"
-       "      " << lprjdebug << ""
-       "    </WorkspaceConfiguration>\n"
-       "  </BuildMatrix>\n"
-       "</CodeLite_Workspace>\n";
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
+         it = projectMap.begin();
+       it != projectMap.end(); ++it) {
+    // retrive project information
+    std::string projectName = it->second[0]->GetProjectName();
+
+    xml.StartElement("Project");
+    xml.Attribute("Name", projectName);
+    xml.Attribute("ConfigName", this->ConfigName);
+    xml.EndElement();
+  }
+
+  xml.EndElement(); // WorkspaceConfiguration
+  xml.EndElement(); // BuildMatrix
+  xml.EndElement(); // CodeLite_Workspace
 }
 
 /* create the project file */
 void cmExtraCodeLiteGenerator::CreateProjectFile(
   const std::vector<cmLocalGenerator*>& lgs)
 {
-  std::string outputDir   = lgs[0]->GetCurrentBinaryDirectory();
+  std::string outputDir = lgs[0]->GetCurrentBinaryDirectory();
   std::string projectName = lgs[0]->GetProjectName();
-  std::string filename    = outputDir + "/";
+  std::string filename = outputDir + "/";
 
   filename += projectName + ".project";
   this->CreateNewProjectFile(lgs, filename);
 }
 
-void cmExtraCodeLiteGenerator
-::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
-                       const std::string& filename)
+void cmExtraCodeLiteGenerator::CreateNewProjectFile(
+  const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
 {
-  const cmMakefile* mf=lgs[0]->GetMakefile();
+  const cmMakefile* mf = lgs[0]->GetMakefile();
   cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
+  cmXMLWriter xml(fout);
 
   ////////////////////////////////////
-  fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-       "<CodeLite_Project Name=\"" << lgs[0]->GetProjectName()
-       << "\" InternalType=\"\">\n";
+  xml.StartDocument("utf-8");
+  xml.StartElement("CodeLite_Project");
+  xml.Attribute("Name", lgs[0]->GetProjectName());
+  xml.Attribute("InternalType", "");
 
   // Collect all used source files in the project
   // Sort them into two containers, one for C/C++ implementation files
@@ -150,94 +164,75 @@ void cmExtraCodeLiteGenerator
   std::string projectType;
 
   std::vector<std::string> srcExts =
-      this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
+    this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
   std::vector<std::string> headerExts =
-      this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
+    this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
 
   std::map<std::string, cmSourceFile*> cFiles;
   std::set<std::string> otherFiles;
-  for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
-       lg!=lgs.end(); lg++)
-    {
-    cmMakefile* makefile=(*lg)->GetMakefile();
-    std::vector<cmGeneratorTarget*> targets=(*lg)->GetGeneratorTargets();
+  for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
+       lg != lgs.end(); lg++) {
+    cmMakefile* makefile = (*lg)->GetMakefile();
+    std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-         ti != targets.end(); ti++)
-      {
+         ti != targets.end(); ti++) {
 
-      switch((*ti)->GetType())
-        {
-        case cmState::EXECUTABLE:
-          {
+      switch ((*ti)->GetType()) {
+        case cmState::EXECUTABLE: {
           projectType = "Executable";
-          }
-        break;
-        case cmState::STATIC_LIBRARY:
-          {
+        } break;
+        case cmState::STATIC_LIBRARY: {
           projectType = "Static Library";
-          }
-        break;
-        case cmState::SHARED_LIBRARY:
-          {
+        } break;
+        case cmState::SHARED_LIBRARY: {
           projectType = "Dynamic Library";
-          }
-        break;
-        case cmState::MODULE_LIBRARY:
-          {
+        } break;
+        case cmState::MODULE_LIBRARY: {
           projectType = "Dynamic Library";
-          }
-        break;
-        default:  // intended fallthrough
+        } break;
+        default: // intended fallthrough
           break;
-        }
+      }
 
-      switch((*ti)->GetType())
-        {
+      switch ((*ti)->GetType()) {
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
         case cmState::SHARED_LIBRARY:
-        case cmState::MODULE_LIBRARY:
-          {
+        case cmState::MODULE_LIBRARY: {
           std::vector<cmSourceFile*> sources;
           cmGeneratorTarget* gt = *ti;
           gt->GetSourceFiles(sources,
-                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-          for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
-               si!=sources.end(); si++)
-            {
+                             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;
             std::string lang = (*si)->GetLanguage();
-            if (lang == "C" || lang == "CXX")
-              {
+            if (lang == "C" || lang == "CXX") {
               std::string srcext = (*si)->GetExtension();
-              for(std::vector<std::string>::const_iterator
-                  ext = srcExts.begin(); ext != srcExts.end(); ++ext)
-                {
-                if (srcext == *ext)
-                  {
+              for (std::vector<std::string>::const_iterator ext =
+                     srcExts.begin();
+                   ext != srcExts.end(); ++ext) {
+                if (srcext == *ext) {
                   isCFile = true;
                   break;
-                  }
                 }
               }
+            }
 
             // then put it accordingly into one of the two containers
-            if (isCFile)
-              {
-              cFiles[(*si)->GetFullPath()] = *si ;
-              }
-            else
-              {
+            if (isCFile) {
+              cFiles[(*si)->GetFullPath()] = *si;
+            } else {
               otherFiles.insert((*si)->GetFullPath());
-              }
             }
           }
-        default:  // intended fallthrough
-          break;
         }
+        default: // intended fallthrough
+          break;
       }
     }
+  }
 
   // The following loop tries to add header files matching to implementation
   // files to the project. It does that by iterating over all source files,
@@ -245,38 +240,31 @@ void cmExtraCodeLiteGenerator
   // file exists. If it does, it is inserted into the map of files.
   // A very similar version of that code exists also in the kdevelop
   // project generator.
-  for (std::map<std::string, cmSourceFile*>::const_iterator
-       sit=cFiles.begin();
-       sit!=cFiles.end();
-       ++sit)
-    {
-    std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first);
-    headerBasename+="/";
-    headerBasename+=cmSystemTools::GetFilenameWithoutExtension(sit->first);
+  for (std::map<std::string, cmSourceFile*>::const_iterator sit =
+         cFiles.begin();
+       sit != cFiles.end(); ++sit) {
+    std::string headerBasename = cmSystemTools::GetFilenamePath(sit->first);
+    headerBasename += "/";
+    headerBasename += cmSystemTools::GetFilenameWithoutExtension(sit->first);
 
     // check if there's a matching header around
-    for(std::vector<std::string>::const_iterator
-        ext = headerExts.begin();
-        ext != headerExts.end();
-        ++ext)
-      {
-      std::string hname=headerBasename;
+    for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+         ext != headerExts.end(); ++ext) {
+      std::string hname = headerBasename;
       hname += ".";
       hname += *ext;
       // if it's already in the set, don't check if it exists on disk
-      std::set<std::string>::const_iterator headerIt=otherFiles.find(hname);
-      if (headerIt != otherFiles.end())
-        {
+      std::set<std::string>::const_iterator headerIt = otherFiles.find(hname);
+      if (headerIt != otherFiles.end()) {
         break;
-        }
+      }
 
-      if(cmSystemTools::FileExists(hname.c_str()))
-        {
+      if (cmSystemTools::FileExists(hname.c_str())) {
         otherFiles.insert(hname);
         break;
-        }
       }
     }
+  }
 
   // Get the project path ( we need it later to convert files to
   // their relative path)
@@ -285,109 +273,143 @@ void cmExtraCodeLiteGenerator
   // Create 2 virtual folders: src and include
   // and place all the implementation files into the src
   // folder, the rest goes to the include folder
-  fout<< "  <VirtualDirectory Name=\"src\">\n";
+  xml.StartElement("VirtualDirectory");
+  xml.Attribute("Name", "src");
 
   // insert all source files in the codelite project
   // first the C/C++ implementation files, then all others
-  for (std::map<std::string, cmSourceFile*>::const_iterator
-       sit=cFiles.begin();
-       sit!=cFiles.end();
-       ++sit)
-    {
-    std::string relativePath =
-      cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str());
-    fout<< "    <File Name=\"" << relativePath << "\"/>\n";
-    }
-  fout<< "  </VirtualDirectory>\n";
-  fout<< "  <VirtualDirectory Name=\"include\">\n";
-  for (std::set<std::string>::const_iterator
-       sit=otherFiles.begin();
-       sit!=otherFiles.end();
-       ++sit)
-    {
-    std::string relativePath =
-      cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str());
-    fout << "    <File Name=\"" << relativePath << "\"/>\n";
-    }
-  fout << "  </VirtualDirectory>\n";
+  for (std::map<std::string, cmSourceFile*>::const_iterator sit =
+         cFiles.begin();
+       sit != cFiles.end(); ++sit) {
+    xml.StartElement("File");
+    xml.Attribute("Name", cmSystemTools::RelativePath(projectPath.c_str(),
+                                                      sit->first.c_str()));
+    xml.EndElement();
+  }
+  xml.EndElement(); // VirtualDirectory
+  xml.StartElement("VirtualDirectory");
+  xml.Attribute("Name", "include");
+  for (std::set<std::string>::const_iterator sit = otherFiles.begin();
+       sit != otherFiles.end(); ++sit) {
+    xml.StartElement("File");
+    xml.Attribute(
+      "Name", cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()));
+    xml.EndElement();
+  }
+  xml.EndElement(); // VirtualDirectory
 
   // Get the number of CPUs. We use this information for the make -jN
   // command
   cmsys::SystemInformation info;
   info.RunCPUCheck();
 
-  this->CpuCount = info.GetNumberOfLogicalCPU() *
-                   info.GetNumberOfPhysicalCPU();
-
-  std::string cleanCommand      = GetCleanCommand(mf);
-  std::string buildCommand      = GetBuildCommand(mf);
-  std::string rebuildCommand    = GetRebuildCommand(mf);
-  std::string singleFileCommand = GetSingleFileBuildCommand(mf);
+  this->CpuCount =
+    info.GetNumberOfLogicalCPU() * info.GetNumberOfPhysicalCPU();
 
   std::string codeliteCompilerName = this->GetCodeLiteCompilerName(mf);
 
-  fout << "\n"
-     "  <Settings Type=\"" << projectType << "\">\n"
-     "    <Configuration Name=\"" << this->ConfigName << "\" CompilerType=\""
-     << codeliteCompilerName << "\" DebuggerType=\"GNU gdb debugger\" "
-     "Type=\""
-     << projectType << "\" BuildCmpWithGlobalSettings=\"append\" "
-     "BuildLnkWithGlobalSettings=\"append\" "
-     "BuildResWithGlobalSettings=\"append\">\n"
-     "      <Compiler Options=\"-g\" "
-     "Required=\"yes\" PreCompiledHeader=\"\">\n"
-     "        <IncludePath Value=\".\"/>\n"
-     "      </Compiler>\n"
-     "      <Linker Options=\"\" Required=\"yes\"/>\n"
-     "      <ResourceCompiler Options=\"\" Required=\"no\"/>\n"
-     "      <General OutputFile=\"$(IntermediateDirectory)/$(ProjectName)\" "
-     "IntermediateDirectory=\"./\" Command=\"./$(ProjectName)\" "
-     "CommandArguments=\"\" WorkingDirectory=\"$(IntermediateDirectory)\" "
-     "PauseExecWhenProcTerminates=\"yes\"/>\n"
-     "      <Debugger IsRemote=\"no\" RemoteHostName=\"\" "
-     "RemoteHostPort=\"\" DebuggerPath=\"\">\n"
-     "        <PostConnectCommands/>\n"
-     "        <StartupCommands/>\n"
-     "      </Debugger>\n"
-     "      <PreBuild/>\n"
-     "      <PostBuild/>\n"
-     "      <CustomBuild Enabled=\"yes\">\n"
-     "        <RebuildCommand>" << rebuildCommand << "</RebuildCommand>\n"
-     "        <CleanCommand>" << cleanCommand << "</CleanCommand>\n"
-     "        <BuildCommand>" << buildCommand << "</BuildCommand>\n"
-     "        <SingleFileCommand>" << singleFileCommand
-     << "</SingleFileCommand>\n"
-     "        <PreprocessFileCommand/>\n"
-     "        <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>\n"
-     "      </CustomBuild>\n"
-     "      <AdditionalRules>\n"
-     "        <CustomPostBuild/>\n"
-     "        <CustomPreBuild/>\n"
-     "      </AdditionalRules>\n"
-     "    </Configuration>\n"
-     "    <GlobalSettings>\n"
-     "      <Compiler Options=\"\">\n"
-     "        <IncludePath Value=\".\"/>\n"
-     "      </Compiler>\n"
-     "      <Linker Options=\"\">\n"
-     "        <LibraryPath Value=\".\"/>\n"
-     "      </Linker>\n"
-     "      <ResourceCompiler Options=\"\"/>\n"
-     "    </GlobalSettings>\n"
-     "  </Settings>\n"
-     "</CodeLite_Project>\n";
+  xml.StartElement("Settings");
+  xml.Attribute("Type", projectType);
+
+  xml.StartElement("Configuration");
+  xml.Attribute("Name", this->ConfigName);
+  xml.Attribute("CompilerType", this->GetCodeLiteCompilerName(mf));
+  xml.Attribute("DebuggerType", "GNU gdb debugger");
+  xml.Attribute("Type", projectType);
+  xml.Attribute("BuildCmpWithGlobalSettings", "append");
+  xml.Attribute("BuildLnkWithGlobalSettings", "append");
+  xml.Attribute("BuildResWithGlobalSettings", "append");
+
+  xml.StartElement("Compiler");
+  xml.Attribute("Options", "-g");
+  xml.Attribute("Required", "yes");
+  xml.Attribute("PreCompiledHeader", "");
+  xml.StartElement("IncludePath");
+  xml.Attribute("Value", ".");
+  xml.EndElement(); // IncludePath
+  xml.EndElement(); // Compiler
+
+  xml.StartElement("Linker");
+  xml.Attribute("Options", "");
+  xml.Attribute("Required", "yes");
+  xml.EndElement(); // Linker
+
+  xml.StartElement("ResourceCompiler");
+  xml.Attribute("Options", "");
+  xml.Attribute("Required", "no");
+  xml.EndElement(); // ResourceCompiler
+
+  xml.StartElement("General");
+  xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)");
+  xml.Attribute("IntermediateDirectory", "./");
+  xml.Attribute("Command", "./$(ProjectName)");
+  xml.Attribute("CommandArguments", "");
+  xml.Attribute("WorkingDirectory", "$(IntermediateDirectory)");
+  xml.Attribute("PauseExecWhenProcTerminates", "yes");
+  xml.EndElement(); // General
+
+  xml.StartElement("Debugger");
+  xml.Attribute("IsRemote", "no");
+  xml.Attribute("RemoteHostName", "");
+  xml.Attribute("RemoteHostPort", "");
+  xml.Attribute("DebuggerPath", "");
+  xml.Element("PostConnectCommands");
+  xml.Element("StartupCommands");
+  xml.EndElement(); // Debugger
+
+  xml.Element("PreBuild");
+  xml.Element("PostBuild");
+
+  xml.StartElement("CustomBuild");
+  xml.Attribute("Enabled", "yes");
+  xml.Element("RebuildCommand", GetRebuildCommand(mf));
+  xml.Element("CleanCommand", GetCleanCommand(mf));
+  xml.Element("BuildCommand", GetBuildCommand(mf));
+  xml.Element("SingleFileCommand", GetSingleFileBuildCommand(mf));
+  xml.Element("PreprocessFileCommand");
+  xml.Element("WorkingDirectory", "$(WorkspacePath)");
+  xml.EndElement(); // CustomBuild
+
+  xml.StartElement("AdditionalRules");
+  xml.Element("CustomPostBuild");
+  xml.Element("CustomPreBuild");
+  xml.EndElement(); // AdditionalRules
+
+  xml.EndElement(); // Configuration
+  xml.StartElement("GlobalSettings");
+
+  xml.StartElement("Compiler");
+  xml.Attribute("Options", "");
+  xml.StartElement("IncludePath");
+  xml.Attribute("Value", ".");
+  xml.EndElement(); // IncludePath
+  xml.EndElement(); // Compiler
+
+  xml.StartElement("Linker");
+  xml.Attribute("Options", "");
+  xml.StartElement("LibraryPath");
+  xml.Attribute("Value", ".");
+  xml.EndElement(); // LibraryPath
+  xml.EndElement(); // Linker
+
+  xml.StartElement("ResourceCompiler");
+  xml.Attribute("Options", "");
+  xml.EndElement(); // ResourceCompiler
+
+  xml.EndElement(); // GlobalSettings
+  xml.EndElement(); // Settings
+  xml.EndElement(); // CodeLite_Project
 }
 
-std::string
-cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const
+std::string cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(
+  const cmMakefile* mf) const
 {
   // figure out which language to use
   // for now care only for C and C++
   std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
-  if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false)
-    {
+  if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) {
     compilerIdVar = "CMAKE_C_COMPILER_ID";
-    }
+  }
 
   std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
   std::string compiler = "gnu g++"; // default to g++
@@ -395,80 +417,67 @@ cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const
   // Since we need the compiler for parsing purposes only
   // it does not matter if we use clang or clang++, same as
   // "gnu gcc" vs "gnu g++"
-  if (compilerId == "MSVC")
-    {
+  if (compilerId == "MSVC") {
     compiler = "VC++";
-    }
-  else if (compilerId == "Clang")
-    {
+  } else if (compilerId == "Clang") {
     compiler = "clang++";
-    }
-  else if (compilerId == "GNU")
-    {
+  } else if (compilerId == "GNU") {
     compiler = "gnu g++";
-    }
+  }
   return compiler;
 }
 
-std::string
-cmExtraCodeLiteGenerator::GetConfigurationName(const cmMakefile* mf) const
+std::string cmExtraCodeLiteGenerator::GetConfigurationName(
+  const cmMakefile* mf) const
 {
   std::string confName = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
   // Trim the configuration name from whitespaces (left and right)
   confName.erase(0, confName.find_first_not_of(" \t\r\v\n"));
-  confName.erase(confName.find_last_not_of(" \t\r\v\n")+1);
-  if ( confName.empty() )
-    {
+  confName.erase(confName.find_last_not_of(" \t\r\v\n") + 1);
+  if (confName.empty()) {
     confName = "NoConfig";
-    }
+  }
   return confName;
 }
 
-std::string
-cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const
+std::string cmExtraCodeLiteGenerator::GetBuildCommand(
+  const cmMakefile* mf) const
 {
   std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string buildCommand = make; // Default
-  if ( generator == "NMake Makefiles" ||
-       generator == "Ninja" )
-    {
+  if (generator == "NMake Makefiles" || generator == "Ninja") {
     buildCommand = make;
-    }
-  else if ( generator == "MinGW Makefiles" ||
-            generator == "Unix Makefiles" )
-    {
+  } else if (generator == "MinGW Makefiles" || generator == "Unix Makefiles") {
     std::ostringstream ss;
     ss << make << " -j " << this->CpuCount;
     buildCommand = ss.str();
-    }
+  }
   return buildCommand;
 }
 
-std::string
-cmExtraCodeLiteGenerator::GetCleanCommand(const cmMakefile* mf) const
+std::string cmExtraCodeLiteGenerator::GetCleanCommand(
+  const cmMakefile* mf) const
 {
   return GetBuildCommand(mf) + " clean";
 }
 
-std::string
-cmExtraCodeLiteGenerator::GetRebuildCommand(const cmMakefile* mf) const
+std::string cmExtraCodeLiteGenerator::GetRebuildCommand(
+  const cmMakefile* mf) const
 {
-  return GetCleanCommand(mf) + cmXMLSafe(" && ").str() + GetBuildCommand(mf);
+  return GetCleanCommand(mf) + " && " + GetBuildCommand(mf);
 }
 
-std::string
-cmExtraCodeLiteGenerator::GetSingleFileBuildCommand
-(const cmMakefile* mf) const
+std::string cmExtraCodeLiteGenerator::GetSingleFileBuildCommand(
+  const cmMakefile* mf) const
 {
   std::string buildCommand;
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
-  if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" )
-    {
+  if (generator == "Unix Makefiles" || generator == "MinGW Makefiles") {
     std::ostringstream ss;
     ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o";
     buildCommand = ss.str();
-    }
+  }
   return buildCommand;
 }
diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h
index 6b4965d..01ff31f 100644
--- a/Source/cmExtraCodeLiteGenerator.h
+++ b/Source/cmExtraCodeLiteGenerator.h
@@ -27,19 +27,24 @@ protected:
 
 protected:
   std::string GetCodeLiteCompilerName(const cmMakefile* mf) const;
-  std::string GetConfigurationName( const cmMakefile* mf ) const;
+  std::string GetConfigurationName(const cmMakefile* mf) const;
   std::string GetBuildCommand(const cmMakefile* mf) const;
   std::string GetCleanCommand(const cmMakefile* mf) const;
   std::string GetRebuildCommand(const cmMakefile* mf) const;
   std::string GetSingleFileBuildCommand(const cmMakefile* mf) const;
+
 public:
   cmExtraCodeLiteGenerator();
 
   virtual std::string GetName() const
-                          { return cmExtraCodeLiteGenerator::GetActualName();}
-  static std::string GetActualName()                     { return "CodeLite";}
+  {
+    return cmExtraCodeLiteGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "CodeLite"; }
   static cmExternalMakefileProjectGenerator* New()
-                                      { return new cmExtraCodeLiteGenerator; }
+  {
+    return new cmExtraCodeLiteGenerator;
+  }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
                                 const std::string& fullName) const;
@@ -48,7 +53,7 @@ public:
   void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
-                                const std::string& filename);
+                            const std::string& filename);
 };
 
 #endif
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index aedf6f4..f24e7fb 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -12,21 +12,39 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExtraEclipseCDT4Generator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
-#include "cmGeneratedFileStream.h"
+#include "cmSourceFile.h"
 #include "cmState.h"
 #include "cmTarget.h"
-#include "cmSourceFile.h"
+#include "cmXMLWriter.h"
 
 #include "cmSystemTools.h"
-#include <stdlib.h>
 #include <assert.h>
+#include <stdlib.h>
 
-//----------------------------------------------------------------------------
-cmExtraEclipseCDT4Generator
-::cmExtraEclipseCDT4Generator() : cmExternalMakefileProjectGenerator()
+static void AppendAttribute(cmXMLWriter& xml, const char* keyval)
+{
+  xml.StartElement("attribute");
+  xml.Attribute("key", keyval);
+  xml.Attribute("value", keyval);
+  xml.EndElement();
+}
+
+template <typename T>
+void AppendDictionary(cmXMLWriter& xml, const char* key, T const& value)
+{
+  xml.StartElement("dictionary");
+  xml.Element("key", key);
+  xml.Element("value", value);
+  xml.EndElement();
+}
+
+cmExtraEclipseCDT4Generator::cmExtraEclipseCDT4Generator()
+  : cmExternalMakefileProjectGenerator()
 {
 // TODO: Verify if __CYGWIN__ should be checked.
 //#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -42,41 +60,35 @@ cmExtraEclipseCDT4Generator
   this->GenerateLinkedResources = true;
   this->SupportsGmakeErrorParser = true;
   this->SupportsMachO64Parser = true;
+  this->CEnabled = false;
+  this->CXXEnabled = false;
 }
 
-//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator
-::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
+void cmExtraEclipseCDT4Generator::GetDocumentation(cmDocumentationEntry& entry,
+                                                   const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates Eclipse CDT 4.0 project files.";
 }
 
-//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator
-::EnableLanguage(std::vector<std::string> const& languages,
-                 cmMakefile *, bool)
+void cmExtraEclipseCDT4Generator::EnableLanguage(
+  std::vector<std::string> const& languages, cmMakefile*, bool)
 {
   for (std::vector<std::string>::const_iterator lit = languages.begin();
-       lit != languages.end(); ++lit)
-    {
-    if (*lit == "CXX")
-      {
+       lit != languages.end(); ++lit) {
+    if (*lit == "CXX") {
       this->Natures.insert("org.eclipse.cdt.core.ccnature");
       this->Natures.insert("org.eclipse.cdt.core.cnature");
-      }
-    else if (*lit == "C")
-      {
+      this->CXXEnabled = true;
+    } else if (*lit == "C") {
       this->Natures.insert("org.eclipse.cdt.core.cnature");
-      }
-    else if (*lit == "Java")
-      {
+      this->CEnabled = true;
+    } else if (*lit == "Java") {
       this->Natures.insert("org.eclipse.jdt.core.javanature");
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator::Generate()
 {
   cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
@@ -84,66 +96,65 @@ void cmExtraEclipseCDT4Generator::Generate()
 
   std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION");
   cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*");
-  if (regex.find(eclipseVersion.c_str()))
-    {
+  if (regex.find(eclipseVersion.c_str())) {
     unsigned int majorVersion = 0;
     unsigned int minorVersion = 0;
-    int res=sscanf(regex.match(1).c_str(), "%u.%u", &majorVersion,
-                                                    &minorVersion);
-    if (res == 2)
-      {
+    int res =
+      sscanf(regex.match(1).c_str(), "%u.%u", &majorVersion, &minorVersion);
+    if (res == 2) {
       int version = majorVersion * 1000 + minorVersion;
       if (version < 3006) // 3.6 is Helios
-        {
+      {
         this->SupportsVirtualFolders = false;
         this->SupportsMachO64Parser = false;
-        }
+      }
       if (version < 3007) // 3.7 is Indigo
-        {
+      {
         this->SupportsGmakeErrorParser = false;
-        }
       }
     }
+  }
 
   // TODO: Decide if these are local or member variables
-  this->HomeDirectory       = lg->GetSourceDirectory();
+  this->HomeDirectory = lg->GetSourceDirectory();
   this->HomeOutputDirectory = lg->GetBinaryDirectory();
 
-  this->GenerateLinkedResources = mf->IsOn(
-                                    "CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES");
+  this->GenerateLinkedResources =
+    mf->IsOn("CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES");
 
-  this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory);
+  this->IsOutOfSourceBuild =
+    (this->HomeDirectory != this->HomeOutputDirectory);
 
-  this->GenerateSourceProject = (this->IsOutOfSourceBuild &&
-                            mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT"));
+  this->GenerateSourceProject =
+    (this->IsOutOfSourceBuild &&
+     mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT"));
 
-  if ((this->GenerateSourceProject == false)
-    && (mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT")))
-    {
-    mf->IssueMessage(cmake::WARNING,
-              "ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, "
-              "but this variable is not supported anymore since CMake 2.8.7.\n"
-              "Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
-    }
+  if ((this->GenerateSourceProject == false) &&
+      (mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"))) {
+    mf->IssueMessage(
+      cmake::WARNING,
+      "ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, "
+      "but this variable is not supported anymore since CMake 2.8.7.\n"
+      "Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
+  }
 
   if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
-                                    this->HomeDirectory))
-    {
-    mf->IssueMessage(cmake::WARNING, "The build directory is a subdirectory "
+                                    this->HomeDirectory)) {
+    mf->IssueMessage(cmake::WARNING,
+                     "The build directory is a subdirectory "
                      "of the source directory.\n"
                      "This is not supported well by Eclipse. It is strongly "
                      "recommended to use a build directory which is a "
                      "sibling of the source directory.");
-    }
+  }
 
   // NOTE: This is not good, since it pollutes the source tree. However,
   //       Eclipse doesn't allow CVS/SVN to work when the .project is not in
   //       the cvs/svn root directory. Hence, this is provided as an option.
-  if (this->GenerateSourceProject)
-    {
+  if (this->GenerateSourceProject) {
     // create .project file in the source tree
     this->CreateSourceProjectFile();
-    }
+  }
 
   // create a .project file
   this->CreateProjectFile();
@@ -158,44 +169,37 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
 
   // set up the project name: <project>-Source@<baseSourcePathName>
   cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
-  std::string name = this->GenerateProjectName(lg->GetProjectName(), "Source",
-                                   this->GetPathBasename(this->HomeDirectory));
+  std::string name =
+    this->GenerateProjectName(lg->GetProjectName(), "Source",
+                              this->GetPathBasename(this->HomeDirectory));
 
   const std::string filename = this->HomeDirectory + "/.project";
   cmGeneratedFileStream fout(filename.c_str());
-  if (!fout)
-    {
+  if (!fout) {
     return;
-    }
-
-  fout <<
-    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-    "<projectDescription>\n"
-    "\t<name>" << this->EscapeForXML(name) << "</name>\n"
-    "\t<comment></comment>\n"
-    "\t<projects>\n"
-    "\t</projects>\n"
-    "\t<buildSpec>\n"
-    "\t</buildSpec>\n"
-    "\t<natures>\n"
-    "\t</natures>\n"
-    "\t<linkedResources>\n";
-
-  if (this->SupportsVirtualFolders)
-    {
-    this->CreateLinksToSubprojects(fout, this->HomeDirectory);
+  }
+
+  cmXMLWriter xml(fout);
+  xml.StartDocument("UTF-8");
+  xml.StartElement("projectDescription");
+  xml.Element("name", name);
+  xml.Element("comment", "");
+  xml.Element("projects", "");
+  xml.Element("buildSpec", "");
+  xml.Element("natures", "");
+  xml.StartElement("linkedResources");
+
+  if (this->SupportsVirtualFolders) {
+    this->CreateLinksToSubprojects(xml, this->HomeDirectory);
     this->SrcLinkedResources.clear();
-    }
+  }
 
-  fout <<
-    "\t</linkedResources>\n"
-    "</projectDescription>\n"
-    ;
+  xml.EndElement(); // linkedResources
+  xml.EndElement(); // projectDescription
+  xml.EndDocument();
 }
 
-
-//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
+void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
                                             const char* envVar,
                                             cmLocalGenerator* lg)
 {
@@ -208,57 +212,44 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
 
   std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
   cacheEntryName += envVar;
-  const char* cacheValue = lg->GetState()->GetInitializedCacheValue(
-                                                       cacheEntryName);
+  const char* cacheValue =
+    lg->GetState()->GetInitializedCacheValue(cacheEntryName);
 
   // now we have both, decide which one to use
   std::string valueToUse;
-  if (envVarValue==0 && cacheValue==0)
-    {
+  if (envVarValue == 0 && cacheValue == 0) {
     // nothing known, do nothing
     valueToUse = "";
-    }
-  else if (envVarValue!=0 && cacheValue==0)
-    {
+  } else if (envVarValue != 0 && cacheValue == 0) {
     // The variable is in the env, but not in the cache. Use it and put it
     // in the cache
     valueToUse = envVarValue;
     mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
-                           cacheEntryName.c_str(), cmState::STRING,
-                           true);
+                           cacheEntryName.c_str(), cmState::STRING, true);
     mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
-    }
-  else if (envVarValue==0 && cacheValue!=0)
-    {
+  } else if (envVarValue == 0 && cacheValue != 0) {
     // It is already in the cache, but not in the env, so use it from the cache
     valueToUse = cacheValue;
-    }
-  else
-    {
+  } else {
     // It is both in the cache and in the env.
     // Use the version from the env. except if the value from the env is
     // completely contained in the value from the cache (for the case that we
     // now have a PATH without MSVC dirs in the env. but had the full PATH with
     // all MSVC dirs during the cmake run which stored the var in the cache:
     valueToUse = cacheValue;
-    if (valueToUse.find(envVarValue) == std::string::npos)
-      {
+    if (valueToUse.find(envVarValue) == std::string::npos) {
       valueToUse = envVarValue;
       mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
-                             cacheEntryName.c_str(), cmState::STRING,
-                             true);
+                             cacheEntryName.c_str(), cmState::STRING, true);
       mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
-      }
     }
+  }
 
-  if (!valueToUse.empty())
-    {
-    fout << envVar << "=" << valueToUse << "|";
-    }
+  if (!valueToUse.empty()) {
+    out << envVar << "=" << valueToUse << "|";
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator::CreateProjectFile()
 {
   cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
@@ -267,228 +258,144 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
   const std::string filename = this->HomeOutputDirectory + "/.project";
 
   cmGeneratedFileStream fout(filename.c_str());
-  if (!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
 
   std::string compilerId = mf->GetSafeDefinition("CMAKE_C_COMPILER_ID");
-  if (compilerId.empty())  // no C compiler, try the C++ compiler:
-    {
+  if (compilerId.empty()) // no C compiler, try the C++ compiler:
+  {
     compilerId = mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
-    }
+  }
+
+  cmXMLWriter xml(fout);
+
+  xml.StartDocument("UTF-8");
+  xml.StartElement("projectDescription");
 
-  fout <<
-    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-    "<projectDescription>\n"
-    "\t<name>" <<
-    this->GenerateProjectName(lg->GetProjectName(),
-                              mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
-                              this->GetPathBasename(this->HomeOutputDirectory))
-    << "</name>\n"
-    "\t<comment></comment>\n"
-    "\t<projects>\n"
-    "\t</projects>\n"
-    "\t<buildSpec>\n"
-    "\t\t<buildCommand>\n"
-    "\t\t\t<name>org.eclipse.cdt.make.core.makeBuilder</name>\n"
-    "\t\t\t<triggers>clean,full,incremental,</triggers>\n"
-    "\t\t\t<arguments>\n"
-    ;
+  xml.Element("name", this->GenerateProjectName(
+                        lg->GetProjectName(),
+                        mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
+                        this->GetPathBasename(this->HomeOutputDirectory)));
+
+  xml.Element("comment", "");
+  xml.Element("projects", "");
+
+  xml.StartElement("buildSpec");
+  xml.StartElement("buildCommand");
+  xml.Element("name", "org.eclipse.cdt.make.core.makeBuilder");
+  xml.Element("triggers", "clean,full,incremental,");
+  xml.StartElement("arguments");
 
   // use clean target
-  fout <<
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>\n"
-    "\t\t\t\t\t<value>clean</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableCleanBuild</key>\n"
-    "\t\t\t\t\t<value>true</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.append_environment</key>\n"
-    "\t\t\t\t\t<value>true</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.stopOnError</key>\n"
-    "\t\t\t\t\t<value>true</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    ;
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.cleanBuildTarget", "clean");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.enableCleanBuild", "true");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.append_environment",
+                   "true");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.stopOnError", "true");
 
   // set the make command
-  std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
-  const std::string makeArgs = mf->GetSafeDefinition(
-                                               "CMAKE_ECLIPSE_MAKE_ARGUMENTS");
-
-  fout <<
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>\n"
-    "\t\t\t\t\t<value>true</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.command</key>\n"
-    "\t\t\t\t\t<value>" << this->GetEclipsePath(make) << "</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.contents</key>\n"
-    "\t\t\t\t\t<value>org.eclipse.cdt.make.core.activeConfigSettings</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.inc</key>\n"
-    "\t\t\t\t\t<value>all</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.arguments</key>\n"
-    "\t\t\t\t\t<value>" << makeArgs << "</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildLocation</key>\n"
-    "\t\t\t\t\t<value>"
-     << this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>\n"
-    "\t\t\t\t\t<value>false</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    ;
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.enabledIncrementalBuild",
+                   "true");
+  AppendDictionary(
+    xml, "org.eclipse.cdt.make.core.build.command",
+    this->GetEclipsePath(mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")));
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.contents",
+                   "org.eclipse.cdt.make.core.activeConfigSettings");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.inc", "all");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.build.arguments",
+                   mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS"));
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.buildLocation",
+                   this->GetEclipsePath(this->HomeOutputDirectory));
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.useDefaultBuildCmd",
+                   "false");
 
   // set project specific environment
-  fout <<
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.environment</key>\n"
-    "\t\t\t\t\t<value>VERBOSE=1|CMAKE_NO_VERBOSE=1|"  //verbose Makefile output
-    ;
+  std::stringstream environment;
+  environment << "VERBOSE=1|CMAKE_NO_VERBOSE=1|"; // verbose Makefile output
   // set vsvars32.bat environment available at CMake time,
   //   but not necessarily when eclipse is open
-  if (compilerId == "MSVC")
-    {
-    AddEnvVar(fout, "PATH", lg);
-    AddEnvVar(fout, "INCLUDE", lg);
-    AddEnvVar(fout, "LIB", lg);
-    AddEnvVar(fout, "LIBPATH", lg);
-    }
-  else if (compilerId == "Intel")
-    {
+  if (compilerId == "MSVC") {
+    AddEnvVar(environment, "PATH", lg);
+    AddEnvVar(environment, "INCLUDE", lg);
+    AddEnvVar(environment, "LIB", lg);
+    AddEnvVar(environment, "LIBPATH", lg);
+  } else if (compilerId == "Intel") {
     // if the env.var is set, use this one and put it in the cache
     // if the env.var is not set, but the value is in the cache,
     // use it from the cache:
-    AddEnvVar(fout, "INTEL_LICENSE_FILE", lg);
-    }
-  fout <<
-    "</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    ;
-
-  fout <<
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableFullBuild</key>\n"
-    "\t\t\t\t\t<value>true</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.auto</key>\n"
-    "\t\t\t\t\t<value>all</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enableAutoBuild</key>\n"
-    "\t\t\t\t\t<value>false</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.target.clean</key>\n"
-    "\t\t\t\t\t<value>clean</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.fullBuildTarget</key>\n"
-    "\t\t\t\t\t<value>all</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildArguments</key>\n"
-    "\t\t\t\t\t<value></value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.location</key>\n"
-    "\t\t\t\t\t<value>"
-    << this->GetEclipsePath(this->HomeOutputDirectory) << "</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.make.core.autoBuildTarget</key>\n"
-    "\t\t\t\t\t<value>all</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    ;
+    AddEnvVar(environment, "INTEL_LICENSE_FILE", lg);
+  }
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.environment",
+                   environment.str());
+
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.enableFullBuild", "true");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.auto", "all");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.enableAutoBuild", "false");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.clean",
+                   "clean");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.fullBuildTarget", "all");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.buildArguments", "");
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.build.location",
+                   this->GetEclipsePath(this->HomeOutputDirectory));
+  AppendDictionary(xml, "org.eclipse.cdt.make.core.autoBuildTarget", "all");
 
   // set error parsers
-  fout <<
-    "\t\t\t\t<dictionary>\n"
-    "\t\t\t\t\t<key>org.eclipse.cdt.core.errorOutputParser</key>\n"
-    "\t\t\t\t\t<value>"
-    ;
-  if (compilerId == "MSVC")
-    {
-    fout << "org.eclipse.cdt.core.VCErrorParser;";
-    }
-  else if (compilerId == "Intel")
-    {
-    fout << "org.eclipse.cdt.core.ICCErrorParser;";
-    }
-
-  if (this->SupportsGmakeErrorParser)
-    {
-    fout << "org.eclipse.cdt.core.GmakeErrorParser;";
-    }
-  else
-    {
-    fout << "org.eclipse.cdt.core.MakeErrorParser;";
-    }
-
-  fout <<
-    "org.eclipse.cdt.core.GCCErrorParser;"
-    "org.eclipse.cdt.core.GASErrorParser;"
-    "org.eclipse.cdt.core.GLDErrorParser;"
-    "</value>\n"
-    "\t\t\t\t</dictionary>\n"
-    ;
-
-  fout <<
-    "\t\t\t</arguments>\n"
-    "\t\t</buildCommand>\n"
-    "\t\t<buildCommand>\n"
-    "\t\t\t<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>\n"
-    "\t\t\t<arguments>\n"
-    "\t\t\t</arguments>\n"
-    "\t\t</buildCommand>\n"
-    "\t</buildSpec>\n"
-    ;
+  std::stringstream errorOutputParser;
+
+  if (compilerId == "MSVC") {
+    errorOutputParser << "org.eclipse.cdt.core.VCErrorParser;";
+  } else if (compilerId == "Intel") {
+    errorOutputParser << "org.eclipse.cdt.core.ICCErrorParser;";
+  }
+
+  if (this->SupportsGmakeErrorParser) {
+    errorOutputParser << "org.eclipse.cdt.core.GmakeErrorParser;";
+  } else {
+    errorOutputParser << "org.eclipse.cdt.core.MakeErrorParser;";
+  }
+
+  errorOutputParser << "org.eclipse.cdt.core.GCCErrorParser;"
+                       "org.eclipse.cdt.core.GASErrorParser;"
+                       "org.eclipse.cdt.core.GLDErrorParser;";
+  AppendDictionary(xml, "org.eclipse.cdt.core.errorOutputParser",
+                   errorOutputParser.str());
+
+  xml.EndElement(); // arguments
+  xml.EndElement(); // buildCommand
+  xml.StartElement("buildCommand");
+  xml.Element("name", "org.eclipse.cdt.make.core.ScannerConfigBuilder");
+  xml.StartElement("arguments");
+  xml.EndElement(); // arguments
+  xml.EndElement(); // buildCommand
+  xml.EndElement(); // buildSpec
 
   // set natures for c/c++ projects
-  fout <<
-    "\t<natures>\n"
-    "\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n"
-    "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n";
-
-  for (std::set<std::string>::const_iterator nit=this->Natures.begin();
-       nit != this->Natures.end(); ++nit)
-    {
-    fout << "\t\t<nature>" << *nit << "</nature>\n";
-    }
-
-  if (const char *extraNaturesProp = mf->GetState()
-        ->GetGlobalProperty("ECLIPSE_EXTRA_NATURES"))
-    {
+  xml.StartElement("natures");
+  xml.Element("nature", "org.eclipse.cdt.make.core.makeNature");
+  xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature");
+  ;
+
+  for (std::set<std::string>::const_iterator nit = this->Natures.begin();
+       nit != this->Natures.end(); ++nit) {
+    xml.Element("nature", *nit);
+  }
+
+  if (const char* extraNaturesProp =
+        mf->GetState()->GetGlobalProperty("ECLIPSE_EXTRA_NATURES")) {
     std::vector<std::string> extraNatures;
     cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures);
     for (std::vector<std::string>::const_iterator nit = extraNatures.begin();
-         nit != extraNatures.end(); ++nit)
-      {
-      fout << "\t\t<nature>" << *nit << "</nature>\n";
-      }
+         nit != extraNatures.end(); ++nit) {
+      xml.Element("nature", *nit);
     }
+  }
 
-  fout << "\t</natures>\n";
+  xml.EndElement(); // natures
 
-  fout << "\t<linkedResources>\n";
+  xml.StartElement("linkedResources");
   // create linked resources
-  if (this->IsOutOfSourceBuild)
-    {
+  if (this->IsOutOfSourceBuild) {
     // create a linked resource to CMAKE_SOURCE_DIR
     // (this is not done anymore for each project because of
     // http://public.kitware.com/Bug/view.php?id=9978 and because I found it
@@ -496,204 +403,183 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
     // projects, Alex
 
     std::string sourceLinkedResourceName = "[Source directory]";
-    std::string linkSourceDirectory = this->GetEclipsePath(
-                                             lg->GetCurrentSourceDirectory());
+    std::string linkSourceDirectory =
+      this->GetEclipsePath(lg->GetCurrentSourceDirectory());
     // .project dir can't be subdir of a linked resource dir
     if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
-                                         linkSourceDirectory))
-      {
-      this->AppendLinkedResource(fout, sourceLinkedResourceName,
+                                       linkSourceDirectory)) {
+      this->AppendLinkedResource(xml, sourceLinkedResourceName,
                                  this->GetEclipsePath(linkSourceDirectory),
                                  LinkToFolder);
       this->SrcLinkedResources.push_back(sourceLinkedResourceName);
-      }
-
     }
+  }
 
-  if (this->SupportsVirtualFolders)
-    {
-    this->CreateLinksToSubprojects(fout, this->HomeOutputDirectory);
+  if (this->SupportsVirtualFolders) {
+    this->CreateLinksToSubprojects(xml, this->HomeOutputDirectory);
 
-    this->CreateLinksForTargets(fout);
-    }
+    this->CreateLinksForTargets(xml);
+  }
 
-  fout << "\t</linkedResources>\n";
-
-  fout << "</projectDescription>\n";
+  xml.EndElement(); // linkedResources
+  xml.EndElement(); // projectDescription
 }
 
+void cmExtraEclipseCDT4Generator::WriteGroups(
+  std::vector<cmSourceGroup> const& sourceGroups, std::string& linkName,
+  cmXMLWriter& xml)
+{
+  for (std::vector<cmSourceGroup>::const_iterator sgIt = sourceGroups.begin();
+       sgIt != sourceGroups.end(); ++sgIt) {
+    std::string linkName3 = linkName;
+    linkName3 += "/";
+    linkName3 += sgIt->GetFullName();
+
+    std::replace(linkName3.begin(), linkName3.end(), '\\', '/');
+
+    this->AppendLinkedResource(xml, linkName3, "virtual:/virtual",
+                               VirtualFolder);
+    std::vector<cmSourceGroup> const& children = sgIt->GetGroupChildren();
+    if (!children.empty()) {
+      this->WriteGroups(children, linkName, xml);
+    }
+    std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
+    for (std::vector<const cmSourceFile*>::const_iterator fileIt =
+           sFiles.begin();
+         fileIt != sFiles.end(); ++fileIt) {
+      std::string fullPath = (*fileIt)->GetFullPath();
+
+      if (!cmSystemTools::FileIsDirectory(fullPath)) {
+        std::string linkName4 = linkName3;
+        linkName4 += "/";
+        linkName4 += cmSystemTools::GetFilenameName(fullPath);
+        this->AppendLinkedResource(xml, linkName4,
+                                   this->GetEclipsePath(fullPath), LinkToFile);
+      }
+    }
+  }
+}
 
-//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
-                                                   cmGeneratedFileStream& fout)
+void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
 {
   std::string linkName = "[Targets]";
-  this->AppendLinkedResource(fout, linkName, "virtual:/virtual",VirtualFolder);
+  this->AppendLinkedResource(xml, linkName, "virtual:/virtual", VirtualFolder);
 
-  for (std::vector<cmLocalGenerator*>::const_iterator
-       lgIt = this->GlobalGenerator->GetLocalGenerators().begin();
-       lgIt != this->GlobalGenerator->GetLocalGenerators().end();
-       ++lgIt)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator lgIt =
+         this->GlobalGenerator->GetLocalGenerators().begin();
+       lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) {
     cmMakefile* makefile = (*lgIt)->GetMakefile();
     const std::vector<cmGeneratorTarget*> targets =
-        (*lgIt)->GetGeneratorTargets();
+      (*lgIt)->GetGeneratorTargets();
 
-    for(std::vector<cmGeneratorTarget*>::const_iterator ti=targets.begin();
-        ti!=targets.end();++ti)
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
+         ti != targets.end(); ++ti) {
       std::string linkName2 = linkName;
       linkName2 += "/";
-      switch((*ti)->GetType())
-        {
+      switch ((*ti)->GetType()) {
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
         case cmState::SHARED_LIBRARY:
         case cmState::MODULE_LIBRARY:
-        case cmState::OBJECT_LIBRARY:
-          {
-          const char* prefix = ((*ti)->GetType()==cmState::EXECUTABLE ?
-                                                          "[exe] " : "[lib] ");
+        case cmState::OBJECT_LIBRARY: {
+          const char* prefix =
+            ((*ti)->GetType() == cmState::EXECUTABLE ? "[exe] " : "[lib] ");
           linkName2 += prefix;
           linkName2 += (*ti)->GetName();
-          this->AppendLinkedResource(fout, linkName2, "virtual:/virtual",
+          this->AppendLinkedResource(xml, linkName2, "virtual:/virtual",
                                      VirtualFolder);
-          if (!this->GenerateLinkedResources)
-            {
+          if (!this->GenerateLinkedResources) {
             break; // skip generating the linked resources to the source files
-            }
-          std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups();
+          }
+          std::vector<cmSourceGroup> sourceGroups =
+            makefile->GetSourceGroups();
           // get the files from the source lists then add them to the groups
           cmGeneratorTarget* gt = const_cast<cmGeneratorTarget*>(*ti);
           std::vector<cmSourceFile*> files;
           gt->GetSourceFiles(files,
-                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-          for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
-              sfIt != files.end();
-              sfIt++)
-            {
+                             makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+          for (std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
+               sfIt != files.end(); sfIt++) {
             // Add the file to the list of sources.
             std::string source = (*sfIt)->GetFullPath();
             cmSourceGroup* sourceGroup =
-                       makefile->FindSourceGroup(source.c_str(), sourceGroups);
+              makefile->FindSourceGroup(source.c_str(), sourceGroups);
             sourceGroup->AssignSource(*sfIt);
-            }
-
-          for(std::vector<cmSourceGroup>::iterator sgIt = sourceGroups.begin();
-              sgIt != sourceGroups.end();
-              ++sgIt)
-            {
-            std::string linkName3 = linkName2;
-            linkName3 += "/";
-            linkName3 += sgIt->GetFullName();
-            this->AppendLinkedResource(fout, linkName3, "virtual:/virtual",
-                                       VirtualFolder);
-
-            std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
-            for(std::vector<const cmSourceFile*>::const_iterator fileIt =
-                                                                sFiles.begin();
-                fileIt != sFiles.end();
-                ++fileIt)
-              {
-              std::string fullPath = (*fileIt)->GetFullPath();
-              if (!cmSystemTools::FileIsDirectory(fullPath))
-                {
-                std::string linkName4 = linkName3;
-                linkName4 += "/";
-                linkName4 += cmSystemTools::GetFilenameName(fullPath);
-                this->AppendLinkedResource(fout, linkName4,
-                                           this->GetEclipsePath(fullPath),
-                                           LinkToFile);
-                }
-              }
-            }
           }
-          break;
+
+          this->WriteGroups(sourceGroups, linkName2, xml);
+        } break;
         // ignore all others:
         default:
           break;
-        }
       }
     }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
-                       cmGeneratedFileStream& fout, const std::string& baseDir)
+  cmXMLWriter& xml, const std::string& baseDir)
 {
-  if (!this->GenerateLinkedResources)
-    {
+  if (!this->GenerateLinkedResources) {
     return;
-    }
+  }
 
   // for each sub project create a linked resource to the source dir
   // - only if it is an out-of-source build
-  this->AppendLinkedResource(fout, "[Subprojects]",
-                             "virtual:/virtual", VirtualFolder);
+  this->AppendLinkedResource(xml, "[Subprojects]", "virtual:/virtual",
+                             VirtualFolder);
 
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-       it = this->GlobalGenerator->GetProjectMap().begin();
-       it != this->GlobalGenerator->GetProjectMap().end();
-       ++it)
-    {
-    std::string linkSourceDirectory = this->GetEclipsePath(
-                   it->second[0]->GetCurrentSourceDirectory());
+         it = this->GlobalGenerator->GetProjectMap().begin();
+       it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+    std::string linkSourceDirectory =
+      this->GetEclipsePath(it->second[0]->GetCurrentSourceDirectory());
     // a linked resource must not point to a parent directory of .project or
     // .project itself
     if ((baseDir != linkSourceDirectory) &&
-        !cmSystemTools::IsSubDirectory(baseDir,
-                                       linkSourceDirectory))
-      {
+        !cmSystemTools::IsSubDirectory(baseDir, linkSourceDirectory)) {
       std::string linkName = "[Subprojects]/";
       linkName += it->first;
-      this->AppendLinkedResource(fout, linkName,
+      this->AppendLinkedResource(xml, linkName,
                                  this->GetEclipsePath(linkSourceDirectory),
-                                 LinkToFolder
-                                );
+                                 LinkToFolder);
       // Don't add it to the srcLinkedResources, because listing multiple
       // directories confuses the Eclipse indexer (#13596).
-      }
     }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
-                            cmGeneratedFileStream& fout,
-                            const std::vector<std::string>& includeDirs,
-                            std::set<std::string>& emittedDirs)
+  cmXMLWriter& xml, const std::vector<std::string>& includeDirs,
+  std::set<std::string>& emittedDirs)
 {
-  for(std::vector<std::string>::const_iterator inc = includeDirs.begin();
-      inc != includeDirs.end();
-      ++inc)
-    {
-    if (!inc->empty())
-      {
+  for (std::vector<std::string>::const_iterator inc = includeDirs.begin();
+       inc != includeDirs.end(); ++inc) {
+    if (!inc->empty()) {
       std::string dir = cmSystemTools::CollapseFullPath(*inc);
 
       // handle framework include dirs on OSX, the remainder after the
       // Frameworks/ part has to be stripped
       //   /System/Library/Frameworks/GLUT.framework/Headers
       cmsys::RegularExpression frameworkRx("(.+/Frameworks)/.+\\.framework/");
-      if(frameworkRx.find(dir.c_str()))
-        {
+      if (frameworkRx.find(dir.c_str())) {
         dir = frameworkRx.match(1);
-        }
+      }
 
-      if(emittedDirs.find(dir) == emittedDirs.end())
-        {
+      if (emittedDirs.find(dir) == emittedDirs.end()) {
         emittedDirs.insert(dir);
-        fout << "<pathentry include=\""
-             << cmExtraEclipseCDT4Generator::EscapeForXML(
-                              cmExtraEclipseCDT4Generator::GetEclipsePath(dir))
-             << "\" kind=\"inc\" path=\"\" system=\"true\"/>\n";
-        }
+        xml.StartElement("pathentry");
+        xml.Attribute("include",
+                      cmExtraEclipseCDT4Generator::GetEclipsePath(dir));
+        xml.Attribute("kind", "inc");
+        xml.Attribute("path", "");
+        xml.Attribute("system", "true");
+        xml.EndElement();
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
 {
   std::set<std::string> emmited;
@@ -704,571 +590,514 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
   const std::string filename = this->HomeOutputDirectory + "/.cproject";
 
   cmGeneratedFileStream fout(filename.c_str());
-  if (!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
+
+  cmXMLWriter xml(fout);
 
   // add header
-  fout <<
-    "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
-    "<?fileVersion 4.0.0?>\n\n"
-    "<cproject>\n"
-    "<storageModule moduleId=\"org.eclipse.cdt.core.settings\">\n"
-    ;
+  xml.StartDocument("UTF-8");
+  xml.ProcessingInstruction("fileVersion", "4.0.0");
+  xml.StartElement("cproject");
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
 
-  fout << "<cconfiguration id=\"org.eclipse.cdt.core.default.config.1\">\n";
+  xml.StartElement("cconfiguration");
+  xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
 
   // Configuration settings...
-  fout <<
-    "<storageModule"
-    " buildSystemId=\"org.eclipse.cdt.core.defaultConfigDataProvider\""
-    " id=\"org.eclipse.cdt.core.default.config.1\""
-    " moduleId=\"org.eclipse.cdt.core.settings\" name=\"Configuration\">\n"
-    "<externalSettings/>\n"
-    "<extensions>\n"
-    ;
+  xml.StartElement("storageModule");
+  xml.Attribute("buildSystemId",
+                "org.eclipse.cdt.core.defaultConfigDataProvider");
+  xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
+  xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
+  xml.Attribute("name", "Configuration");
+  xml.Element("externalSettings");
+  xml.StartElement("extensions");
+
   // TODO: refactor this out...
-  std::string executableFormat = mf->GetSafeDefinition(
-                                                    "CMAKE_EXECUTABLE_FORMAT");
-  if (executableFormat == "ELF")
-    {
-    fout << "<extension id=\"org.eclipse.cdt.core.ELF\""
-            " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
-            ;
-    fout << "<extension id=\"org.eclipse.cdt.core.GNU_ELF\""
-            " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
-            "<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
-            "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
-            "</extension>\n"
-            ;
-    }
-  else
-    {
+  std::string executableFormat =
+    mf->GetSafeDefinition("CMAKE_EXECUTABLE_FORMAT");
+  if (executableFormat == "ELF") {
+    xml.StartElement("extension");
+    xml.Attribute("id", "org.eclipse.cdt.core.ELF");
+    xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+    xml.EndElement(); // extension
+
+    xml.StartElement("extension");
+    xml.Attribute("id", "org.eclipse.cdt.core.GNU_ELF");
+    xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+    AppendAttribute(xml, "addr2line");
+    AppendAttribute(xml, "c++filt");
+    xml.EndElement(); // extension
+  } else {
     std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
-    if (systemName == "CYGWIN")
-      {
-      fout << "<extension id=\"org.eclipse.cdt.core.Cygwin_PE\""
-              " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
-              "<attribute key=\"addr2line\" value=\"addr2line\"/>\n"
-              "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
-              "<attribute key=\"cygpath\" value=\"cygpath\"/>\n"
-              "<attribute key=\"nm\" value=\"nm\"/>\n"
-              "</extension>\n"
-              ;
-      }
-    else if (systemName == "Windows")
-      {
-      fout << "<extension id=\"org.eclipse.cdt.core.PE\""
-              " point=\"org.eclipse.cdt.core.BinaryParser\"/>\n"
-              ;
-      }
-    else if (systemName == "Darwin")
-      {
-      fout << "<extension id=\"" <<
-           (this->SupportsMachO64Parser ? "org.eclipse.cdt.core.MachO64"
-                                        : "org.eclipse.cdt.core.MachO") << "\""
-              " point=\"org.eclipse.cdt.core.BinaryParser\">\n"
-              "<attribute key=\"c++filt\" value=\"c++filt\"/>\n"
-              "</extension>\n"
-              ;
-      }
-    else
-      {
+    if (systemName == "CYGWIN") {
+      xml.StartElement("extension");
+      xml.Attribute("id", "org.eclipse.cdt.core.Cygwin_PE");
+      xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+      AppendAttribute(xml, "addr2line");
+      AppendAttribute(xml, "c++filt");
+      AppendAttribute(xml, "cygpath");
+      AppendAttribute(xml, "nm");
+      xml.EndElement(); // extension
+    } else if (systemName == "Windows") {
+      xml.StartElement("extension");
+      xml.Attribute("id", "org.eclipse.cdt.core.PE");
+      xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+      xml.EndElement(); // extension
+    } else if (systemName == "Darwin") {
+      xml.StartElement("extension");
+      xml.Attribute("id", this->SupportsMachO64Parser
+                      ? "org.eclipse.cdt.core.MachO64"
+                      : "org.eclipse.cdt.core.MachO");
+      xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
+      AppendAttribute(xml, "c++filt");
+      xml.EndElement(); // extension
+    } else {
       // *** Should never get here ***
-      fout << "<error_toolchain_type/>\n";
-      }
+      xml.Element("error_toolchain_type");
     }
+  }
 
-  fout << "</extensions>\n"
-          "</storageModule>\n"
-          ;
+  xml.EndElement(); // extensions
+  xml.EndElement(); // storageModule
 
   // ???
-  fout <<
-    "<storageModule moduleId=\"org.eclipse.cdt.core.language.mapping\">\n"
-    "<project-mappings/>\n"
-    "</storageModule>\n"
-    ;
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "org.eclipse.cdt.core.language.mapping");
+  xml.Element("project-mappings");
+  xml.EndElement(); // storageModule
 
   // ???
-  fout<<"<storageModule moduleId=\"org.eclipse.cdt.core.externalSettings\"/>\n"
-          ;
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "org.eclipse.cdt.core.externalSettings");
+  xml.EndElement(); // storageModule
 
   // set the path entries (includes, libs, source dirs, etc.)
-  fout << "<storageModule moduleId=\"org.eclipse.cdt.core.pathentry\">\n"
-          ;
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "org.eclipse.cdt.core.pathentry");
+
   // for each sub project with a linked resource to the source dir:
   // - make it type 'src'
   // - and exclude it from type 'out'
   std::string excludeFromOut;
-/* I don't know what the pathentry kind="src" are good for, e.g. autocompletion
- * works also without them. Done wrong, the indexer complains, see #12417
- * and #12213.
- * According to #13596, this entry at least limits the directories the
- * indexer is searching for files. So now the "src" entry contains only
- * the linked resource to CMAKE_SOURCE_DIR.
- * The CDT documentation is very terse on that:
- * "CDT_SOURCE: Entry kind constant describing a path entry identifying a
- * folder containing source code to be compiled."
- * Also on the cdt-dev list didn't bring any information:
- * http://web.archiveorange.com/archive/v/B4NlJDNIpYoOS1SbxFNy
- * Alex */
-
-  for (std::vector<std::string>::const_iterator
-       it = this->SrcLinkedResources.begin();
-       it != this->SrcLinkedResources.end();
-       ++it)
-    {
-    fout << "<pathentry kind=\"src\" path=\"" << this->EscapeForXML(*it)
-         << "\"/>\n";
+  /* I don't know what the pathentry kind="src" are good for, e.g.
+   * autocompletion
+   * works also without them. Done wrong, the indexer complains, see #12417
+   * and #12213.
+   * According to #13596, this entry at least limits the directories the
+   * indexer is searching for files. So now the "src" entry contains only
+   * the linked resource to CMAKE_SOURCE_DIR.
+   * The CDT documentation is very terse on that:
+   * "CDT_SOURCE: Entry kind constant describing a path entry identifying a
+   * folder containing source code to be compiled."
+   * Also on the cdt-dev list didn't bring any information:
+   * http://web.archiveorange.com/archive/v/B4NlJDNIpYoOS1SbxFNy
+   * Alex */
+
+  for (std::vector<std::string>::const_iterator it =
+         this->SrcLinkedResources.begin();
+       it != this->SrcLinkedResources.end(); ++it) {
+    xml.StartElement("pathentry");
+    xml.Attribute("kind", "src");
+    xml.Attribute("path", *it);
+    xml.EndElement();
 
     // exlude source directory from output search path
     // - only if not named the same as an output directory
     if (!cmSystemTools::FileIsDirectory(
-           std::string(this->HomeOutputDirectory + "/" + *it)))
-      {
-      excludeFromOut += this->EscapeForXML(*it) + "/|";
-      }
+          std::string(this->HomeOutputDirectory + "/" + *it))) {
+      excludeFromOut += *it + "/|";
     }
+  }
 
   excludeFromOut += "**/CMakeFiles/";
-  fout << "<pathentry excluding=\"" << excludeFromOut
-       << "\" kind=\"out\" path=\"\"/>\n";
+
+  xml.StartElement("pathentry");
+  xml.Attribute("excluding", excludeFromOut);
+  xml.Attribute("kind", "out");
+  xml.Attribute("path", "");
+  xml.EndElement();
 
   // add pre-processor definitions to allow eclipse to gray out sections
   emmited.clear();
-  for (std::vector<cmLocalGenerator*>::const_iterator
-        it = this->GlobalGenerator->GetLocalGenerators().begin();
-       it != this->GlobalGenerator->GetLocalGenerators().end();
-       ++it)
-    {
-
-    if(const char* cdefs = (*it)->GetMakefile()->GetProperty(
-                                                        "COMPILE_DEFINITIONS"))
-      {
+  for (std::vector<cmLocalGenerator*>::const_iterator it =
+         this->GlobalGenerator->GetLocalGenerators().begin();
+       it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
+
+    if (const char* cdefs =
+          (*it)->GetMakefile()->GetProperty("COMPILE_DEFINITIONS")) {
       // Expand the list.
       std::vector<std::string> defs;
       cmGeneratorExpression::Split(cdefs, defs);
 
-      for(std::vector<std::string>::const_iterator di = defs.begin();
-          di != defs.end(); ++di)
-        {
-        if (cmGeneratorExpression::Find(*di) != std::string::npos)
-          {
+      for (std::vector<std::string>::const_iterator di = defs.begin();
+           di != defs.end(); ++di) {
+        if (cmGeneratorExpression::Find(*di) != std::string::npos) {
           continue;
-          }
+        }
 
         std::string::size_type equals = di->find('=', 0);
         std::string::size_type enddef = di->length();
 
         std::string def;
         std::string val;
-        if (equals != std::string::npos && equals < enddef)
-          {
+        if (equals != std::string::npos && equals < enddef) {
           // we have -DFOO=BAR
           def = di->substr(0, equals);
           val = di->substr(equals + 1, enddef - equals + 1);
-          }
-        else
-          {
+        } else {
           // we have -DFOO
           def = *di;
-          }
+        }
 
         // insert the definition if not already added.
-        if(emmited.find(def) == emmited.end())
-          {
+        if (emmited.find(def) == emmited.end()) {
           emmited.insert(def);
-          fout << "<pathentry kind=\"mac\" name=\"" << def
-               << "\" path=\"\" value=\"" << this->EscapeForXML(val)
-               << "\"/>\n";
-          }
+          xml.StartElement("pathentry");
+          xml.Attribute("kind", "mac");
+          xml.Attribute("name", def);
+          xml.Attribute("path", "");
+          xml.Attribute("value", val);
+          xml.EndElement();
         }
       }
     }
+  }
   // add system defined c macros
-  const char* cDefs=mf->GetDefinition(
-                              "CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS");
-  if(cDefs)
-    {
+  const char* cDefs =
+    mf->GetDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS");
+  if (this->CEnabled && cDefs) {
     // Expand the list.
     std::vector<std::string> defs;
     cmSystemTools::ExpandListArgument(cDefs, defs, true);
 
     // the list must contain only definition-value pairs:
-    if ((defs.size() % 2) == 0)
-      {
+    if ((defs.size() % 2) == 0) {
       std::vector<std::string>::const_iterator di = defs.begin();
-      while (di != defs.end())
-        {
+      while (di != defs.end()) {
         std::string def = *di;
         ++di;
         std::string val;
-        if (di != defs.end())
-          {
+        if (di != defs.end()) {
           val = *di;
           ++di;
-          }
+        }
 
         // insert the definition if not already added.
-        if(emmited.find(def) == emmited.end())
-          {
+        if (emmited.find(def) == emmited.end()) {
           emmited.insert(def);
-          fout << "<pathentry kind=\"mac\" name=\"" << def
-               << "\" path=\"\" value=\"" << this->EscapeForXML(val)
-               << "\"/>\n";
-          }
+          xml.StartElement("pathentry");
+          xml.Attribute("kind", "mac");
+          xml.Attribute("name", def);
+          xml.Attribute("path", "");
+          xml.Attribute("value", val);
+          xml.EndElement();
         }
       }
     }
+  }
   // add system defined c++ macros
-  const char* cxxDefs = mf->GetDefinition(
-                            "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS");
-  if(cxxDefs)
-    {
+  const char* cxxDefs =
+    mf->GetDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS");
+  if (this->CXXEnabled && cxxDefs) {
     // Expand the list.
     std::vector<std::string> defs;
     cmSystemTools::ExpandListArgument(cxxDefs, defs, true);
 
     // the list must contain only definition-value pairs:
-    if ((defs.size() % 2) == 0)
-      {
+    if ((defs.size() % 2) == 0) {
       std::vector<std::string>::const_iterator di = defs.begin();
-      while (di != defs.end())
-        {
+      while (di != defs.end()) {
         std::string def = *di;
         ++di;
         std::string val;
-        if (di != defs.end())
-          {
+        if (di != defs.end()) {
           val = *di;
           ++di;
-          }
+        }
 
         // insert the definition if not already added.
-        if(emmited.find(def) == emmited.end())
-          {
+        if (emmited.find(def) == emmited.end()) {
           emmited.insert(def);
-          fout << "<pathentry kind=\"mac\" name=\"" << def
-               << "\" path=\"\" value=\"" << this->EscapeForXML(val)
-               << "\"/>\n";
-          }
+          xml.StartElement("pathentry");
+          xml.Attribute("kind", "mac");
+          xml.Attribute("name", def);
+          xml.Attribute("path", "");
+          xml.Attribute("value", val);
+          xml.EndElement();
         }
       }
     }
+  }
 
   // include dirs
   emmited.clear();
-  for (std::vector<cmLocalGenerator*>::const_iterator
-        it = this->GlobalGenerator->GetLocalGenerators().begin();
-       it != this->GlobalGenerator->GetLocalGenerators().end();
-       ++it)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator it =
+         this->GlobalGenerator->GetLocalGenerators().begin();
+       it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
     std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
-         l != targets.end(); ++l)
-      {
+         l != targets.end(); ++l) {
       std::vector<std::string> includeDirs;
       std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
       (*it)->GetIncludeDirectories(includeDirs, *l, "C", config);
-      this->AppendIncludeDirectories(fout, includeDirs, emmited);
-      }
+      this->AppendIncludeDirectories(xml, includeDirs, emmited);
     }
+  }
   // now also the system include directories, in case we found them in
   // CMakeSystemSpecificInformation.cmake. This makes Eclipse find the
   // standard headers.
   std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER");
-  if (!compiler.empty())
-    {
-    std::string systemIncludeDirs = mf->GetSafeDefinition(
-                                "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
+  if (this->CEnabled && !compiler.empty()) {
+    std::string systemIncludeDirs =
+      mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
     std::vector<std::string> dirs;
     cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
-    this->AppendIncludeDirectories(fout, dirs, emmited);
-    }
+    this->AppendIncludeDirectories(xml, dirs, emmited);
+  }
   compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
-  if (!compiler.empty())
-    {
-    std::string systemIncludeDirs = mf->GetSafeDefinition(
-                              "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
+  if (this->CXXEnabled && !compiler.empty()) {
+    std::string systemIncludeDirs =
+      mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
     std::vector<std::string> dirs;
     cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
-    this->AppendIncludeDirectories(fout, dirs, emmited);
-    }
+    this->AppendIncludeDirectories(xml, dirs, emmited);
+  }
 
-  fout << "</storageModule>\n";
+  xml.EndElement(); // storageModule
 
   // add build targets
-  fout <<
-    "<storageModule moduleId=\"org.eclipse.cdt.make.core.buildtargets\">\n"
-    "<buildTargets>\n"
-    ;
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "org.eclipse.cdt.make.core.buildtargets");
+  xml.StartElement("buildTargets");
   emmited.clear();
   const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
-  const std::string makeArgs = mf->GetSafeDefinition(
-                                               "CMAKE_ECLIPSE_MAKE_ARGUMENTS");
+  const std::string makeArgs =
+    mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS");
 
-  cmGlobalGenerator* generator
-    = const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
+  cmGlobalGenerator* generator =
+    const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
 
   std::string allTarget;
   std::string cleanTarget;
-  if (generator->GetAllTargetName())
-    {
+  if (generator->GetAllTargetName()) {
     allTarget = generator->GetAllTargetName();
-    }
-  if (generator->GetCleanTargetName())
-    {
+  }
+  if (generator->GetCleanTargetName()) {
     cleanTarget = generator->GetCleanTargetName();
-    }
+  }
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
-  for (std::vector<cmLocalGenerator*>::const_iterator
-        it = this->GlobalGenerator->GetLocalGenerators().begin();
-       it != this->GlobalGenerator->GetLocalGenerators().end();
-       ++it)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator it =
+         this->GlobalGenerator->GetLocalGenerators().begin();
+       it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
     const std::vector<cmGeneratorTarget*> targets =
-        (*it)->GetGeneratorTargets();
+      (*it)->GetGeneratorTargets();
     std::string subdir = (*it)->Convert((*it)->GetCurrentBinaryDirectory(),
-                           cmLocalGenerator::HOME_OUTPUT);
-    if (subdir == ".")
-      {
+                                        cmOutputConverter::HOME_OUTPUT);
+    if (subdir == ".") {
       subdir = "";
-      }
+    }
 
-    for(std::vector<cmGeneratorTarget*>::const_iterator ti =
-        targets.begin(); ti!=targets.end(); ++ti)
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
+         ti != targets.end(); ++ti) {
       std::string targetName = (*ti)->GetName();
-      switch((*ti)->GetType())
-        {
-        case cmState::GLOBAL_TARGET:
-          {
+      switch ((*ti)->GetType()) {
+        case cmState::GLOBAL_TARGET: {
           // Only add the global targets from CMAKE_BINARY_DIR,
           // not from the subdirs
-          if (subdir.empty())
-           {
-           this->AppendTarget(fout, targetName, make, makeArgs, subdir, ": ");
-           }
-         }
-         break;
-       case cmState::UTILITY:
-         // Add all utility targets, except the Nightly/Continuous/
-         // Experimental-"sub"targets as e.g. NightlyStart
-         if (((targetName.find("Nightly")==0)   &&(targetName!="Nightly"))
-          || ((targetName.find("Continuous")==0)&&(targetName!="Continuous"))
-          || ((targetName.find("Experimental")==0)
-                                            && (targetName!="Experimental")))
-           {
-           break;
-           }
-
-         this->AppendTarget(fout, targetName, make, makeArgs, subdir, ": ");
-         break;
-       case cmState::EXECUTABLE:
-       case cmState::STATIC_LIBRARY:
-       case cmState::SHARED_LIBRARY:
-       case cmState::MODULE_LIBRARY:
-       case cmState::OBJECT_LIBRARY:
-         {
-         const char* prefix = ((*ti)->GetType()==cmState::EXECUTABLE ?
-                                                          "[exe] " : "[lib] ");
-         this->AppendTarget(fout, targetName, make, makeArgs, subdir, prefix);
-         std::string fastTarget = targetName;
-         fastTarget += "/fast";
-         this->AppendTarget(fout, fastTarget, make, makeArgs, subdir, prefix);
-
-         // Add Build and Clean targets in the virtual folder of targets:
-         if (this->SupportsVirtualFolders)
-          {
-          std::string virtDir = "[Targets]/";
-          virtDir += prefix;
-          virtDir += targetName;
-          std::string buildArgs = "-C \"";
-          buildArgs += (*it)->GetBinaryDirectory();
-          buildArgs += "\" ";
-          buildArgs += makeArgs;
-          this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "",
-                             targetName.c_str());
-
-          std::string cleanArgs = "-E chdir \"";
-          cleanArgs += (*it)->GetCurrentBinaryDirectory();
-          cleanArgs += "\" \"";
-          cleanArgs += cmSystemTools::GetCMakeCommand();
-          cleanArgs += "\" -P \"";
-          cmGeneratorTarget* gt = *ti;
-          cleanArgs += (*it)->GetTargetDirectory(gt);
-          cleanArgs += "/cmake_clean.cmake\"";
-          this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(),
-                             cleanArgs, virtDir, "", "");
+          if (subdir.empty()) {
+            this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
+          }
+        } break;
+        case cmState::UTILITY:
+          // Add all utility targets, except the Nightly/Continuous/
+          // Experimental-"sub"targets as e.g. NightlyStart
+          if (((targetName.find("Nightly") == 0) &&
+               (targetName != "Nightly")) ||
+              ((targetName.find("Continuous") == 0) &&
+               (targetName != "Continuous")) ||
+              ((targetName.find("Experimental") == 0) &&
+               (targetName != "Experimental"))) {
+            break;
           }
-         }
-         break;
+
+          this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
+          break;
+        case cmState::EXECUTABLE:
+        case cmState::STATIC_LIBRARY:
+        case cmState::SHARED_LIBRARY:
+        case cmState::MODULE_LIBRARY:
+        case cmState::OBJECT_LIBRARY: {
+          const char* prefix =
+            ((*ti)->GetType() == cmState::EXECUTABLE ? "[exe] " : "[lib] ");
+          this->AppendTarget(xml, targetName, make, makeArgs, subdir, prefix);
+          std::string fastTarget = targetName;
+          fastTarget += "/fast";
+          this->AppendTarget(xml, fastTarget, make, makeArgs, subdir, prefix);
+
+          // Add Build and Clean targets in the virtual folder of targets:
+          if (this->SupportsVirtualFolders) {
+            std::string virtDir = "[Targets]/";
+            virtDir += prefix;
+            virtDir += targetName;
+            std::string buildArgs = "-C \"";
+            buildArgs += (*it)->GetBinaryDirectory();
+            buildArgs += "\" ";
+            buildArgs += makeArgs;
+            this->AppendTarget(xml, "Build", make, buildArgs, virtDir, "",
+                               targetName.c_str());
+
+            std::string cleanArgs = "-E chdir \"";
+            cleanArgs += (*it)->GetCurrentBinaryDirectory();
+            cleanArgs += "\" \"";
+            cleanArgs += cmSystemTools::GetCMakeCommand();
+            cleanArgs += "\" -P \"";
+            cmGeneratorTarget* gt = *ti;
+            cleanArgs += (*it)->GetTargetDirectory(gt);
+            cleanArgs += "/cmake_clean.cmake\"";
+            this->AppendTarget(xml, "Clean", cmSystemTools::GetCMakeCommand(),
+                               cleanArgs, virtDir, "", "");
+          }
+        } break;
         default:
           break;
-        }
       }
+    }
 
     // insert the all and clean targets in every subdir
-    if (!allTarget.empty())
-      {
-      this->AppendTarget(fout, allTarget, make, makeArgs, subdir, ": ");
-      }
-    if (!cleanTarget.empty())
-      {
-      this->AppendTarget(fout, cleanTarget, make, makeArgs, subdir, ": ");
-      }
+    if (!allTarget.empty()) {
+      this->AppendTarget(xml, allTarget, make, makeArgs, subdir, ": ");
+    }
+    if (!cleanTarget.empty()) {
+      this->AppendTarget(xml, cleanTarget, make, makeArgs, subdir, ": ");
+    }
 
-    //insert rules for compiling, preprocessing and assembling individual files
+    // insert rules for compiling, preprocessing and assembling individual
+    // files
     std::vector<std::string> objectFileTargets;
     (*it)->GetIndividualFileTargets(objectFileTargets);
-    for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin();
-        fit != objectFileTargets.end();
-        ++fit)
-      {
+    for (std::vector<std::string>::const_iterator fit =
+           objectFileTargets.begin();
+         fit != objectFileTargets.end(); ++fit) {
       const char* prefix = "[obj] ";
-      if ((*fit)[fit->length()-1] == 's')
-        {
+      if ((*fit)[fit->length() - 1] == 's') {
         prefix = "[to asm] ";
-        }
-      else if ((*fit)[fit->length()-1] == 'i')
-        {
+      } else if ((*fit)[fit->length() - 1] == 'i') {
         prefix = "[pre] ";
-        }
-      this->AppendTarget(fout, *fit, make, makeArgs, subdir, prefix);
       }
+      this->AppendTarget(xml, *fit, make, makeArgs, subdir, prefix);
     }
+  }
 
-  fout << "</buildTargets>\n"
-          "</storageModule>\n"
-          ;
-
-  this->AppendStorageScanners(fout, *mf);
-
-  fout << "</cconfiguration>\n"
-          "</storageModule>\n"
-          "<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n"
-          "<project id=\"" << this->EscapeForXML(lg->GetProjectName())
-       << ".null.1\" name=\"" << this->EscapeForXML(lg->GetProjectName())
-       << "\"/>\n"
-          "</storageModule>\n"
-          "</cproject>\n"
-          ;
+  xml.EndElement(); // buildTargets
+  xml.EndElement(); // storageModule
+
+  this->AppendStorageScanners(xml, *mf);
+
+  xml.EndElement(); // cconfiguration
+  xml.EndElement(); // storageModule
+
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "cdtBuildSystem");
+  xml.Attribute("version", "4.0.0");
+
+  xml.StartElement("project");
+  xml.Attribute("id", std::string(lg->GetProjectName()) + ".null.1");
+  xml.Attribute("name", lg->GetProjectName());
+  xml.EndElement(); // project
+
+  xml.EndElement(); // storageModule
+  xml.EndElement(); // cproject
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path)
+std::string cmExtraEclipseCDT4Generator::GetEclipsePath(
+  const std::string& path)
 {
 #if defined(__CYGWIN__)
   std::string cmd = "cygpath -m " + path;
   std::string out;
-  if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out, &out))
-    {
+  if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out, &out)) {
     return path;
-    }
-  else
-    {
+  } else {
     out.erase(out.find_last_of('\n'));
     return out;
-    }
+  }
 #else
   return path;
 #endif
 }
 
-std::string
-cmExtraEclipseCDT4Generator::GetPathBasename(const std::string& path)
+std::string cmExtraEclipseCDT4Generator::GetPathBasename(
+  const std::string& path)
 {
   std::string outputBasename = path;
   while (!outputBasename.empty() &&
          (outputBasename[outputBasename.size() - 1] == '/' ||
-          outputBasename[outputBasename.size() - 1] == '\\'))
-    {
+          outputBasename[outputBasename.size() - 1] == '\\')) {
     outputBasename.resize(outputBasename.size() - 1);
-    }
+  }
   std::string::size_type loc = outputBasename.find_last_of("/\\");
-  if (loc != std::string::npos)
-    {
+  if (loc != std::string::npos) {
     outputBasename = outputBasename.substr(loc + 1);
-    }
+  }
 
   return outputBasename;
 }
 
-std::string
-cmExtraEclipseCDT4Generator::GenerateProjectName(const std::string& name,
-                                                 const std::string& type,
-                                                 const std::string& path)
-{
-  return cmExtraEclipseCDT4Generator::EscapeForXML(name)
-                                +(type.empty() ? "" : "-") + type + "@" + path;
-}
-
-std::string cmExtraEclipseCDT4Generator::EscapeForXML(const std::string& value)
+std::string cmExtraEclipseCDT4Generator::GenerateProjectName(
+  const std::string& name, const std::string& type, const std::string& path)
 {
-  std::string str = value;
-  cmSystemTools::ReplaceString(str, "&", "&");
-  cmSystemTools::ReplaceString(str, "<", "<");
-  cmSystemTools::ReplaceString(str, ">", ">");
-  cmSystemTools::ReplaceString(str, "\"", """);
-  // NOTE: This one is not necessary, since as of Eclipse CDT4 it will
-  //       automatically change this to the original value (').
-  //cmSystemTools::ReplaceString(str, "'", "'");
-  return str;
+  return name + (type.empty() ? "" : "-") + type + "@" + path;
 }
 
-//----------------------------------------------------------------------------
 // Helper functions
-//----------------------------------------------------------------------------
-void cmExtraEclipseCDT4Generator
-::AppendStorageScanners(cmGeneratedFileStream& fout,
-                        const cmMakefile& makefile)
+void cmExtraEclipseCDT4Generator::AppendStorageScanners(
+  cmXMLWriter& xml, const cmMakefile& makefile)
 {
   // we need the "make" and the C (or C++) compiler which are used, Alex
   std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER");
   std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1");
-  if (compiler.empty())
-    {
+  if (compiler.empty()) {
     compiler = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER");
     arg1 = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER_ARG1");
-    }
-  if (compiler.empty())  //Hmm, what to do now ?
-    {
+  }
+  if (compiler.empty()) // Hmm, what to do now ?
+  {
     compiler = "gcc";
-    }
+  }
 
   // the following right now hardcodes gcc behaviour :-/
   std::string compilerArgs =
-                         "-E -P -v -dD ${plugin_state_location}/${specs_file}";
-  if (!arg1.empty())
-    {
+    "-E -P -v -dD ${plugin_state_location}/${specs_file}";
+  if (!arg1.empty()) {
     arg1 += " ";
     compilerArgs = arg1 + compilerArgs;
-    }
-
-  fout <<
-    "<storageModule moduleId=\"scannerConfiguration\">\n"
-    "<autodiscovery enabled=\"true\" problemReportingEnabled=\"true\""
-    " selectedProfileId="
-    "\"org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile\"/>\n"
-    ;
-  cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
-    "org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile",
-    true, "", true, "specsFile",
-    compilerArgs,
-    compiler, true, true);
-  cmExtraEclipseCDT4Generator::AppendScannerProfile(fout,
-    "org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile",
-    true, "", true, "makefileGenerator",
-    "-f ${project_name}_scd.mk",
-    make, true, true);
-
-  fout << "</storageModule>\n";
+  }
+
+  xml.StartElement("storageModule");
+  xml.Attribute("moduleId", "scannerConfiguration");
+
+  xml.StartElement("autodiscovery");
+  xml.Attribute("enabled", "true");
+  xml.Attribute("problemReportingEnabled", "true");
+  xml.Attribute("selectedProfileId",
+                "org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile");
+  xml.EndElement(); // autodiscovery
+
+  cmExtraEclipseCDT4Generator::AppendScannerProfile(
+    xml, "org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile", true,
+    "", true, "specsFile", compilerArgs, compiler, true, true);
+  cmExtraEclipseCDT4Generator::AppendScannerProfile(
+    xml, "org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile", true, "",
+    true, "makefileGenerator", "-f ${project_name}_scd.mk", make, true, true);
+
+  xml.EndElement(); // storageModule
 }
 
 // The prefix is prepended before the actual name of the target. The purpose
@@ -1279,93 +1108,77 @@ void cmExtraEclipseCDT4Generator
 // finally the assembly files "[to asm] ". Note the "to" in "to asm",
 // without it, "asm" would be the first targets in the list, with the "to"
 // they are the last targets, which makes more sense.
-void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
-                                               const std::string&     target,
-                                               const std::string&     make,
-                                               const std::string&     makeArgs,
-                                               const std::string&     path,
-                                               const char* prefix,
-                                               const char* makeTarget
-                                              )
+void cmExtraEclipseCDT4Generator::AppendTarget(
+  cmXMLWriter& xml, const std::string& target, const std::string& make,
+  const std::string& makeArgs, const std::string& path, const char* prefix,
+  const char* makeTarget)
 {
-  std::string targetXml = cmExtraEclipseCDT4Generator::EscapeForXML(target);
-  std::string makeTargetXml = targetXml;
-  if (makeTarget != NULL)
-    {
-    makeTargetXml = cmExtraEclipseCDT4Generator::EscapeForXML(makeTarget);
-    }
-  cmExtraEclipseCDT4Generator::EscapeForXML(target);
-  std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path);
-  fout <<
-    "<target name=\"" << prefix << targetXml << "\""
-    " path=\"" << pathXml << "\""
-    " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
-    "<buildCommand>"
-    << cmExtraEclipseCDT4Generator::GetEclipsePath(make)
-    << "</buildCommand>\n"
-    "<buildArguments>"  << makeArgs << "</buildArguments>\n"
-    "<buildTarget>" << makeTargetXml << "</buildTarget>\n"
-    "<stopOnError>true</stopOnError>\n"
-    "<useDefaultCommand>false</useDefaultCommand>\n"
-    "</target>\n"
-    ;
+  xml.StartElement("target");
+  xml.Attribute("name", prefix + target);
+  xml.Attribute("path", path);
+  xml.Attribute("targetID", "org.eclipse.cdt.make.MakeTargetBuilder");
+  xml.Element("buildCommand",
+              cmExtraEclipseCDT4Generator::GetEclipsePath(make));
+  xml.Element("buildArguments", makeArgs);
+  xml.Element("buildTarget", makeTarget ? makeTarget : target.c_str());
+  xml.Element("stopOnError", "true");
+  xml.Element("useDefaultCommand", "false");
+  xml.EndElement();
 }
 
-void cmExtraEclipseCDT4Generator
-::AppendScannerProfile(cmGeneratedFileStream& fout,
-                       const std::string&     profileID,
-                       bool                   openActionEnabled,
-                       const std::string&     openActionFilePath,
-                       bool                   pParserEnabled,
-                       const std::string&     scannerInfoProviderID,
-                       const std::string&     runActionArguments,
-                       const std::string&     runActionCommand,
-                       bool                   runActionUseDefault,
-                       bool                   sipParserEnabled)
+void cmExtraEclipseCDT4Generator::AppendScannerProfile(
+  cmXMLWriter& xml, const std::string& profileID, bool openActionEnabled,
+  const std::string& openActionFilePath, bool pParserEnabled,
+  const std::string& scannerInfoProviderID,
+  const std::string& runActionArguments, const std::string& runActionCommand,
+  bool runActionUseDefault, bool sipParserEnabled)
 {
-  fout <<
-    "<profile id=\"" << profileID << "\">\n"
-    "<buildOutputProvider>\n"
-    "<openAction enabled=\"" << (openActionEnabled ? "true" : "false")
-    << "\" filePath=\"" << openActionFilePath << "\"/>\n"
-    "<parser enabled=\"" << (pParserEnabled ? "true" : "false") << "\"/>\n"
-    "</buildOutputProvider>\n"
-    "<scannerInfoProvider id=\"" << scannerInfoProviderID << "\">\n"
-    "<runAction arguments=\"" << runActionArguments << "\""
-    " command=\"" << runActionCommand
-    << "\" useDefault=\"" << (runActionUseDefault ? "true":"false") << "\"/>\n"
-    "<parser enabled=\"" << (sipParserEnabled ? "true" : "false") << "\"/>\n"
-    "</scannerInfoProvider>\n"
-    "</profile>\n"
-    ;
+  xml.StartElement("profile");
+  xml.Attribute("id", profileID);
+
+  xml.StartElement("buildOutputProvider");
+  xml.StartElement("openAction");
+  xml.Attribute("enabled", openActionEnabled ? "true" : "false");
+  xml.Attribute("filePath", openActionFilePath);
+  xml.EndElement(); // openAction
+  xml.StartElement("parser");
+  xml.Attribute("enabled", pParserEnabled ? "true" : "false");
+  xml.EndElement(); // parser
+  xml.EndElement(); // buildOutputProvider
+
+  xml.StartElement("scannerInfoProvider");
+  xml.Attribute("id", scannerInfoProviderID);
+  xml.StartElement("runAction");
+  xml.Attribute("arguments", runActionArguments);
+  xml.Attribute("command", runActionCommand);
+  xml.Attribute("useDefault", runActionUseDefault ? "true" : "false");
+  xml.EndElement(); // runAction
+  xml.StartElement("parser");
+  xml.Attribute("enabled", sipParserEnabled ? "true" : "false");
+  xml.EndElement(); // parser
+  xml.EndElement(); // scannerInfoProvider
+
+  xml.EndElement(); // profile
 }
 
-void cmExtraEclipseCDT4Generator
-::AppendLinkedResource (cmGeneratedFileStream& fout,
-                        const std::string&     name,
-                        const std::string&     path,
-                        LinkType linkType)
+void cmExtraEclipseCDT4Generator::AppendLinkedResource(cmXMLWriter& xml,
+                                                       const std::string& name,
+                                                       const std::string& path,
+                                                       LinkType linkType)
 {
   const char* locationTag = "location";
-  const char* typeTag = "2";
+  int typeTag = 2;
   if (linkType == VirtualFolder) // ... and not a linked folder
-    {
+  {
     locationTag = "locationURI";
-    }
-  if (linkType == LinkToFile)
-    {
-    typeTag = "1";
-    }
-
-  fout <<
-    "\t\t<link>\n"
-    "\t\t\t<name>"
-    << cmExtraEclipseCDT4Generator::EscapeForXML(name)
-    << "</name>\n"
-    "\t\t\t<type>" << typeTag << "</type>\n"
-    "\t\t\t<" << locationTag << ">"
-    << cmExtraEclipseCDT4Generator::EscapeForXML(path)
-    << "</" << locationTag << ">\n"
-    "\t\t</link>\n"
-    ;
+  }
+  if (linkType == LinkToFile) {
+    typeTag = 1;
+  }
+
+  xml.StartElement("link");
+  xml.Element("name", name);
+  xml.Element("type", typeTag);
+  xml.Element(locationTag, path);
+  xml.EndElement();
 }
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index 16675f2..0cef071 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -17,7 +17,8 @@
 #include "cmExternalMakefileProjectGenerator.h"
 
 class cmMakefile;
-class cmGeneratedFileStream;
+class cmXMLWriter;
+class cmSourceGroup;
 
 /** \class cmExtraEclipseCDT4Generator
  * \brief Write Eclipse project files for Makefile based projects
@@ -25,24 +26,31 @@ class cmGeneratedFileStream;
 class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator
 {
 public:
-  enum LinkType {VirtualFolder, LinkToFolder, LinkToFile };
+  enum LinkType
+  {
+    VirtualFolder,
+    LinkToFolder,
+    LinkToFile
+  };
 
   cmExtraEclipseCDT4Generator();
 
-  static cmExternalMakefileProjectGenerator* New() {
+  static cmExternalMakefileProjectGenerator* New()
+  {
     return new cmExtraEclipseCDT4Generator;
   }
 
-  virtual std::string GetName() const {
+  virtual std::string GetName() const
+  {
     return cmExtraEclipseCDT4Generator::GetActualName();
   }
 
   static std::string GetActualName() { return "Eclipse CDT4"; }
 
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const std::string&    fullName) const;
+                                const std::string& fullName) const;
   virtual void EnableLanguage(std::vector<std::string> const& languages,
-                              cmMakefile *, bool optional);
+                              cmMakefile*, bool optional);
 
   virtual void Generate();
 
@@ -67,44 +75,35 @@ private:
                                          const std::string& type,
                                          const std::string& path);
 
-  static std::string EscapeForXML(const std::string& value);
-
   // Helper functions
-  static void AppendStorageScanners(cmGeneratedFileStream& fout,
+  static void AppendStorageScanners(cmXMLWriter& xml,
                                     const cmMakefile& makefile);
-  static void AppendTarget         (cmGeneratedFileStream& fout,
-                                    const std::string&     target,
-                                    const std::string&     make,
-                                    const std::string&     makeArguments,
-                                    const std::string&     path,
-                                    const char* prefix = "",
-                                    const char* makeTarget = NULL);
-  static void AppendScannerProfile (cmGeneratedFileStream& fout,
-                                    const std::string&   profileID,
-                                    bool                 openActionEnabled,
-                                    const std::string&   openActionFilePath,
-                                    bool                 pParserEnabled,
-                                    const std::string&   scannerInfoProviderID,
-                                    const std::string&   runActionArguments,
-                                    const std::string&   runActionCommand,
-                                    bool                 runActionUseDefault,
-                                    bool                 sipParserEnabled);
-
-  static void AppendLinkedResource (cmGeneratedFileStream& fout,
-                                    const std::string&     name,
-                                    const std::string&     path,
-                                    LinkType linkType);
-
-  static void AppendIncludeDirectories(cmGeneratedFileStream& fout,
-                                   const std::vector<std::string>& includeDirs,
-                                   std::set<std::string>& emittedDirs);
-
-  static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
+  static void AppendTarget(cmXMLWriter& xml, const std::string& target,
+                           const std::string& make,
+                           const std::string& makeArguments,
+                           const std::string& path, const char* prefix = "",
+                           const char* makeTarget = NULL);
+  static void AppendScannerProfile(
+    cmXMLWriter& xml, const std::string& profileID, bool openActionEnabled,
+    const std::string& openActionFilePath, bool pParserEnabled,
+    const std::string& scannerInfoProviderID,
+    const std::string& runActionArguments, const std::string& runActionCommand,
+    bool runActionUseDefault, bool sipParserEnabled);
+
+  static void AppendLinkedResource(cmXMLWriter& xml, const std::string& name,
+                                   const std::string& path, LinkType linkType);
+
+  static void AppendIncludeDirectories(
+    cmXMLWriter& xml, const std::vector<std::string>& includeDirs,
+    std::set<std::string>& emittedDirs);
+
+  static void AddEnvVar(std::ostream& out, const char* envVar,
                         cmLocalGenerator* lg);
 
-  void CreateLinksToSubprojects(cmGeneratedFileStream& fout,
-                                const std::string& baseDir);
-  void CreateLinksForTargets(cmGeneratedFileStream& fout);
+  void WriteGroups(std::vector<cmSourceGroup> const& sourceGroups,
+                   std::string& linkName, cmXMLWriter& xml);
+  void CreateLinksToSubprojects(cmXMLWriter& xml, const std::string& baseDir);
+  void CreateLinksForTargets(cmXMLWriter& xml);
 
   std::vector<std::string> SrcLinkedResources;
   std::set<std::string> Natures;
@@ -116,7 +115,8 @@ private:
   bool SupportsVirtualFolders;
   bool SupportsGmakeErrorParser;
   bool SupportsMachO64Parser;
-
+  bool CEnabled;
+  bool CXXEnabled;
 };
 
 #endif
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index ff5d3ab..02159dd 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -11,26 +11,26 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExtraKateGenerator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
-#include "cmake.h"
 #include "cmSourceFile.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
+#include "cmake.h"
 
 #include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------------
-void cmExtraKateGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
+void cmExtraKateGenerator::GetDocumentation(cmDocumentationEntry& entry,
+                                            const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates Kate project files.";
 }
 
 cmExtraKateGenerator::cmExtraKateGenerator()
-:cmExternalMakefileProjectGenerator()
+  : cmExternalMakefileProjectGenerator()
 {
 #if defined(_WIN32)
   this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
@@ -42,231 +42,206 @@ cmExtraKateGenerator::cmExtraKateGenerator()
   this->SupportedGlobalGenerators.push_back("Unix Makefiles");
 }
 
-
 void cmExtraKateGenerator::Generate()
 {
   cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
   const cmMakefile* mf = lg->GetMakefile();
-  this->ProjectName = this->GenerateProjectName(lg->GetProjectName(),
-                          mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
-                          this->GetPathBasename(lg->GetBinaryDirectory()));
+  this->ProjectName = this->GenerateProjectName(
+    lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
+    this->GetPathBasename(lg->GetBinaryDirectory()));
   this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja");
 
   this->CreateKateProjectFile(lg);
   this->CreateDummyKateProjectFile(lg);
 }
 
-
 void cmExtraKateGenerator::CreateKateProjectFile(
-    const cmLocalGenerator* lg) const
+  const cmLocalGenerator* lg) const
 {
   std::string filename = lg->GetBinaryDirectory();
   filename += "/.kateproject";
   cmGeneratedFileStream fout(filename.c_str());
-  if (!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
 
+  /* clang-format off */
   fout <<
     "{\n"
     "\t\"name\": \"" << this->ProjectName << "\",\n"
     "\t\"directory\": \"" << lg->GetSourceDirectory() << "\",\n"
     "\t\"files\": [ { " << this->GenerateFilesString(lg) << "} ],\n";
+  /* clang-format on */
   this->WriteTargets(lg, fout);
   fout << "}\n";
 }
 
-
-void
-cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
-                                   cmGeneratedFileStream& fout) const
+void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
+                                        cmGeneratedFileStream& fout) const
 {
   cmMakefile const* mf = lg->GetMakefile();
   const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
-  const std::string makeArgs = mf->GetSafeDefinition(
-    "CMAKE_KATE_MAKE_ARGUMENTS");
+  const std::string makeArgs =
+    mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS");
   const char* homeOutputDir = lg->GetBinaryDirectory();
 
+  /* clang-format off */
   fout <<
   "\t\"build\": {\n"
   "\t\t\"directory\": \"" << lg->GetBinaryDirectory() << "\",\n"
   "\t\t\"default_target\": \"all\",\n"
   "\t\t\"clean_target\": \"clean\",\n";
+  /* clang-format on */
 
   // build, clean and quick are for the build plugin kate <= 4.12:
-  fout << "\t\t\"build\": \"" << make << " -C \\\"" << homeOutputDir
-       << "\\\" " << makeArgs << " " << "all\",\n";
-  fout << "\t\t\"clean\": \"" << make << " -C \\\"" << homeOutputDir
-       << "\\\" " << makeArgs << " " << "clean\",\n";
-  fout << "\t\t\"quick\": \"" << make << " -C \\\"" << homeOutputDir
-       << "\\\" " << makeArgs << " " << "install\",\n";
+  fout << "\t\t\"build\": \"" << make << " -C \\\"" << homeOutputDir << "\\\" "
+       << makeArgs << " "
+       << "all\",\n";
+  fout << "\t\t\"clean\": \"" << make << " -C \\\"" << homeOutputDir << "\\\" "
+       << makeArgs << " "
+       << "clean\",\n";
+  fout << "\t\t\"quick\": \"" << make << " -C \\\"" << homeOutputDir << "\\\" "
+       << makeArgs << " "
+       << "install\",\n";
 
   // this is for kate >= 4.13:
-  fout <<
-  "\t\t\"targets\":[\n";
+  fout << "\t\t\"targets\":[\n";
 
-  this->AppendTarget(fout, "all", make, makeArgs,
-                     homeOutputDir, homeOutputDir);
-  this->AppendTarget(fout, "clean", make, makeArgs,
-                     homeOutputDir, homeOutputDir);
+  this->AppendTarget(fout, "all", make, makeArgs, homeOutputDir,
+                     homeOutputDir);
+  this->AppendTarget(fout, "clean", make, makeArgs, homeOutputDir,
+                     homeOutputDir);
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
-  for (std::vector<cmLocalGenerator*>::const_iterator
-       it = this->GlobalGenerator->GetLocalGenerators().begin();
-       it != this->GlobalGenerator->GetLocalGenerators().end();
-       ++it)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator it =
+         this->GlobalGenerator->GetLocalGenerators().begin();
+       it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
     const std::vector<cmGeneratorTarget*> targets =
-        (*it)->GetGeneratorTargets();
+      (*it)->GetGeneratorTargets();
     std::string currentDir = (*it)->GetCurrentBinaryDirectory();
     bool topLevel = (currentDir == (*it)->GetBinaryDirectory());
 
-    for(std::vector<cmGeneratorTarget*>::const_iterator ti =
-        targets.begin(); ti!=targets.end(); ++ti)
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
+         ti != targets.end(); ++ti) {
       std::string targetName = (*ti)->GetName();
-      switch((*ti)->GetType())
-        {
-        case cmState::GLOBAL_TARGET:
-          {
+      switch ((*ti)->GetType()) {
+        case cmState::GLOBAL_TARGET: {
           bool insertTarget = false;
           // Only add the global targets from CMAKE_BINARY_DIR,
           // not from the subdirs
-          if (topLevel)
-            {
+          if (topLevel) {
             insertTarget = true;
             // only add the "edit_cache" target if it's not ccmake, because
             // this will not work within the IDE
-            if (targetName == "edit_cache")
-              {
-              const char* editCommand = (*it)->GetMakefile()->GetDefinition
-              ("CMAKE_EDIT_COMMAND");
-              if (editCommand == 0)
-                {
+            if (targetName == "edit_cache") {
+              const char* editCommand =
+                (*it)->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
+              if (editCommand == 0) {
                 insertTarget = false;
-                }
-              else if (strstr(editCommand, "ccmake")!=NULL)
-                {
+              } else if (strstr(editCommand, "ccmake") != NULL) {
                 insertTarget = false;
-                }
               }
             }
-          if (insertTarget)
-            {
-            this->AppendTarget(fout, targetName, make, makeArgs,
-                               currentDir, homeOutputDir);
-            }
-        }
-        break;
+          }
+          if (insertTarget) {
+            this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
+                               homeOutputDir);
+          }
+        } break;
         case cmState::UTILITY:
           // Add all utility targets, except the Nightly/Continuous/
           // Experimental-"sub"targets as e.g. NightlyStart
-          if (((targetName.find("Nightly")==0)   &&(targetName!="Nightly"))
-            || ((targetName.find("Continuous")==0)
-                &&(targetName!="Continuous"))
-            || ((targetName.find("Experimental")==0)
-            && (targetName!="Experimental")))
-            {
-              break;
-            }
-
-            this->AppendTarget(fout, targetName, make, makeArgs,
-                               currentDir, homeOutputDir);
+          if (((targetName.find("Nightly") == 0) &&
+               (targetName != "Nightly")) ||
+              ((targetName.find("Continuous") == 0) &&
+               (targetName != "Continuous")) ||
+              ((targetName.find("Experimental") == 0) &&
+               (targetName != "Experimental"))) {
+            break;
+          }
+
+          this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
+                             homeOutputDir);
           break;
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
         case cmState::SHARED_LIBRARY:
         case cmState::MODULE_LIBRARY:
-        case cmState::OBJECT_LIBRARY:
-        {
-          this->AppendTarget(fout, targetName, make, makeArgs,
-                             currentDir, homeOutputDir);
+        case cmState::OBJECT_LIBRARY: {
+          this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
+                             homeOutputDir);
           std::string fastTarget = targetName;
           fastTarget += "/fast";
-          this->AppendTarget(fout, fastTarget, make, makeArgs,
-                             currentDir, homeOutputDir);
+          this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir,
+                             homeOutputDir);
 
-        }
-        break;
+        } break;
         default:
           break;
       }
     }
 
-    //insert rules for compiling, preprocessing and assembling individual files
+    // insert rules for compiling, preprocessing and assembling individual
+    // files
     std::vector<std::string> objectFileTargets;
     (*it)->GetIndividualFileTargets(objectFileTargets);
-    for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin();
-        fit != objectFileTargets.end();
-        ++fit)
-      {
-      this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir);
-      }
+    for (std::vector<std::string>::const_iterator fit =
+           objectFileTargets.begin();
+         fit != objectFileTargets.end(); ++fit) {
+      this->AppendTarget(fout, *fit, make, makeArgs, currentDir,
+                         homeOutputDir);
+    }
   }
 
-  fout <<
-  "\t] }\n";
+  fout << "\t] }\n";
 }
 
-
-void
-cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
-                                   const std::string&     target,
-                                   const std::string&     make,
-                                   const std::string&     makeArgs,
-                                   const std::string&     path,
-                                   const char*            homeOutputDir
-                                  ) const
+void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
+                                        const std::string& target,
+                                        const std::string& make,
+                                        const std::string& makeArgs,
+                                        const std::string& path,
+                                        const char* homeOutputDir) const
 {
   static char JsonSep = ' ';
 
-  fout <<
-    "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", "
-    "\"build_cmd\":\"" << make
-               << " -C \\\"" << (this->UseNinja ? homeOutputDir : path.c_str())
-               << "\\\" " << makeArgs << " "
-               << target << "\"}\n";
+  fout << "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", "
+                                                             "\"build_cmd\":\""
+       << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path.c_str())
+       << "\\\" " << makeArgs << " " << target << "\"}\n";
 
   JsonSep = ',';
 }
 
-
-
-void
-cmExtraKateGenerator::CreateDummyKateProjectFile(
-    const cmLocalGenerator* lg) const
+void cmExtraKateGenerator::CreateDummyKateProjectFile(
+  const cmLocalGenerator* lg) const
 {
   std::string filename = lg->GetBinaryDirectory();
   filename += "/";
   filename += this->ProjectName;
   filename += ".kateproject";
   cmGeneratedFileStream fout(filename.c_str());
-  if (!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
 
   fout << "#Generated by " << cmSystemTools::GetCMakeCommand()
        << ", do not edit.\n";
 }
 
-
-std::string
-cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const
+std::string cmExtraKateGenerator::GenerateFilesString(
+  const cmLocalGenerator* lg) const
 {
   std::string s = lg->GetSourceDirectory();
   s += "/.git";
-  if(cmSystemTools::FileExists(s.c_str()))
-  {
+  if (cmSystemTools::FileExists(s.c_str())) {
     return std::string("\"git\": 1 ");
   }
 
   s = lg->GetSourceDirectory();
   s += "/.svn";
-  if(cmSystemTools::FileExists(s.c_str()))
-  {
+  if (cmSystemTools::FileExists(s.c_str())) {
     return std::string("\"svn\": 1 ");
   }
 
@@ -275,77 +250,69 @@ cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const
 
   std::set<std::string> files;
   std::string tmp;
-  const std::vector<cmLocalGenerator *>& lgs =
-                                   this->GlobalGenerator->GetLocalGenerators();
-
-  for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
-       it!=lgs.end(); it++)
-    {
-    cmMakefile* makefile=(*it)->GetMakefile();
-    const std::vector<std::string>& listFiles=makefile->GetListFiles();
-    for (std::vector<std::string>::const_iterator lt=listFiles.begin();
-         lt!=listFiles.end(); lt++)
+  const std::vector<cmLocalGenerator*>& lgs =
+    this->GlobalGenerator->GetLocalGenerators();
+
+  for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin();
+       it != lgs.end(); it++) {
+    cmMakefile* makefile = (*it)->GetMakefile();
+    const std::vector<std::string>& listFiles = makefile->GetListFiles();
+    for (std::vector<std::string>::const_iterator lt = listFiles.begin();
+         lt != listFiles.end(); lt++) {
+      tmp = *lt;
       {
-      tmp=*lt;
-        {
         files.insert(tmp);
-        }
       }
+    }
 
     const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles();
     for (std::vector<cmSourceFile*>::const_iterator sfIt = sources.begin();
-         sfIt != sources.end(); sfIt++)
-      {
+         sfIt != sources.end(); sfIt++) {
       cmSourceFile* sf = *sfIt;
-      if (sf->GetPropertyAsBool("GENERATED"))
-        {
+      if (sf->GetPropertyAsBool("GENERATED")) {
         continue;
-        }
+      }
 
       tmp = sf->GetFullPath();
       files.insert(tmp);
-      }
     }
+  }
 
   const char* sep = "";
   tmp = "\"list\": [";
-  for(std::set<std::string>::const_iterator it = files.begin();
-      it != files.end(); ++it)
-    {
+  for (std::set<std::string>::const_iterator it = files.begin();
+       it != files.end(); ++it) {
     tmp += sep;
     tmp += " \"";
     tmp += *it;
     tmp += "\"";
     sep = ",";
-    }
+  }
   tmp += "] ";
 
   return tmp;
 }
 
-
-std::string cmExtraKateGenerator::GenerateProjectName(const std::string& name,
-                                                 const std::string& type,
-                                                 const std::string& path) const
+std::string cmExtraKateGenerator::GenerateProjectName(
+  const std::string& name, const std::string& type,
+  const std::string& path) const
 {
   return name + (type.empty() ? "" : "-") + type + "@" + path;
 }
 
-
-std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const
+std::string cmExtraKateGenerator::GetPathBasename(
+  const std::string& path) const
 {
   std::string outputBasename = path;
   while (!outputBasename.empty() &&
          (outputBasename[outputBasename.size() - 1] == '/' ||
-          outputBasename[outputBasename.size() - 1] == '\\'))
-    {
+          outputBasename[outputBasename.size() - 1] == '\\')) {
     outputBasename.resize(outputBasename.size() - 1);
-    }
+  }
   std::string::size_type loc = outputBasename.find_last_of("/\\");
-  if (loc != std::string::npos)
-    {
+  if (loc != std::string::npos) {
     outputBasename = outputBasename.substr(loc + 1);
-    }
+  }
 
   return outputBasename;
 }
diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h
index 281c1ef..71e88a9 100644
--- a/Source/cmExtraKateGenerator.h
+++ b/Source/cmExtraKateGenerator.h
@@ -27,26 +27,28 @@ public:
   cmExtraKateGenerator();
 
   virtual std::string GetName() const
-                         { return cmExtraKateGenerator::GetActualName();}
-  static std::string GetActualName()                    { return "Kate";}
+  {
+    return cmExtraKateGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "Kate"; }
   static cmExternalMakefileProjectGenerator* New()
-                                     { return new cmExtraKateGenerator; }
+  {
+    return new cmExtraKateGenerator;
+  }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
                                 const std::string& fullName) const;
 
   virtual void Generate();
+
 private:
   void CreateKateProjectFile(const cmLocalGenerator* lg) const;
   void CreateDummyKateProjectFile(const cmLocalGenerator* lg) const;
   void WriteTargets(const cmLocalGenerator* lg,
                     cmGeneratedFileStream& fout) const;
-  void AppendTarget(cmGeneratedFileStream& fout,
-                    const std::string&     target,
-                    const std::string&     make,
-                    const std::string&     makeArgs,
-                    const std::string&     path,
-                    const char*            homeOutputDir) const;
+  void AppendTarget(cmGeneratedFileStream& fout, const std::string& target,
+                    const std::string& make, const std::string& makeArgs,
+                    const std::string& path, const char* homeOutputDir) const;
 
   std::string GenerateFilesString(const cmLocalGenerator* lg) const;
   std::string GetPathBasename(const std::string& path) const;
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 92d38b9..9b3ea0b 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -11,7 +11,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmExtraSublimeTextGenerator.h"
-#include "cmake.h"
+
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
@@ -20,6 +20,7 @@
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmSystemTools.h"
+#include "cmake.h"
 
 #include <cmsys/SystemTools.hxx>
 
@@ -37,16 +38,15 @@ http://www.sublimetext.com/docs/2/projects.html
 http://sublimetext.info/docs/en/reference/build_systems.html
 */
 
-//----------------------------------------------------------------------------
-void cmExtraSublimeTextGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
+void cmExtraSublimeTextGenerator::GetDocumentation(cmDocumentationEntry& entry,
+                                                   const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates Sublime Text 2 project files.";
 }
 
 cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
-:cmExternalMakefileProjectGenerator()
+  : cmExternalMakefileProjectGenerator()
 {
 #if defined(_WIN32)
   this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
@@ -58,68 +58,57 @@ cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
   this->SupportedGlobalGenerators.push_back("Unix Makefiles");
 }
 
-
 void cmExtraSublimeTextGenerator::Generate()
 {
   // for each sub project in the project create a sublime text 2 project
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-       it = this->GlobalGenerator->GetProjectMap().begin();
-      it!= this->GlobalGenerator->GetProjectMap().end();
-      ++it)
-    {
+         it = this->GlobalGenerator->GetProjectMap().begin();
+       it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
     // create a project file
     this->CreateProjectFile(it->second);
-    }
+  }
 }
 
-
 void cmExtraSublimeTextGenerator::CreateProjectFile(
-                                     const std::vector<cmLocalGenerator*>& lgs)
+  const std::vector<cmLocalGenerator*>& lgs)
 {
-  std::string outputDir=lgs[0]->GetCurrentBinaryDirectory();
-  std::string projectName=lgs[0]->GetProjectName();
+  std::string outputDir = lgs[0]->GetCurrentBinaryDirectory();
+  std::string projectName = lgs[0]->GetProjectName();
 
   const std::string filename =
-                     outputDir + "/" + projectName + ".sublime-project";
+    outputDir + "/" + projectName + ".sublime-project";
 
   this->CreateNewProjectFile(lgs, filename);
 }
 
-void cmExtraSublimeTextGenerator
-  ::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
-                         const std::string& filename)
+void cmExtraSublimeTextGenerator::CreateNewProjectFile(
+  const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
 {
-  const cmMakefile* mf=lgs[0]->GetMakefile();
+  const cmMakefile* mf = lgs[0]->GetMakefile();
   cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
 
-  const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath(
-                     lgs[0]->GetBinaryDirectory(),
-                     lgs[0]->GetSourceDirectory());
+  const std::string& sourceRootRelativeToOutput = cmSystemTools::RelativePath(
+    lgs[0]->GetBinaryDirectory(), lgs[0]->GetSourceDirectory());
   // Write the folder entries to the project file
   fout << "{\n";
   fout << "\t\"folders\":\n\t[\n\t";
-  if (!sourceRootRelativeToOutput.empty())
-    {
-      fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
-      const std::string &outputRelativeToSourceRoot =
-        cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(),
-                                    lgs[0]->GetBinaryDirectory());
-      if ((!outputRelativeToSourceRoot.empty()) &&
+  if (!sourceRootRelativeToOutput.empty()) {
+    fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
+    const std::string& outputRelativeToSourceRoot =
+      cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(),
+                                  lgs[0]->GetBinaryDirectory());
+    if ((!outputRelativeToSourceRoot.empty()) &&
         ((outputRelativeToSourceRoot.length() < 3) ||
-          (outputRelativeToSourceRoot.substr(0, 3) != "../")))
-        {
-        fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" <<
-                outputRelativeToSourceRoot << "\"]";
-        }
-    }
-  else
-    {
-      fout << "\t{\n\t\t\t\"path\": \"./\"";
+         (outputRelativeToSourceRoot.substr(0, 3) != "../"))) {
+      fout << ",\n\t\t\t\"folder_exclude_patterns\": [\""
+           << outputRelativeToSourceRoot << "\"]";
     }
+  } else {
+    fout << "\t{\n\t\t\t\"path\": \"./\"";
+  }
   fout << "\n\t\t}";
   // End of the folders section
   fout << "\n\t]";
@@ -138,173 +127,143 @@ void cmExtraSublimeTextGenerator
   fout << "\n\t}";
 }
 
-
-void cmExtraSublimeTextGenerator::
-  AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
-                   const cmMakefile* mf,
-                   cmGeneratedFileStream& fout,
-                   MapSourceFileFlags& sourceFileFlags)
+void cmExtraSublimeTextGenerator::AppendAllTargets(
+  const std::vector<cmLocalGenerator*>& lgs, const cmMakefile* mf,
+  cmGeneratedFileStream& fout, MapSourceFileFlags& sourceFileFlags)
 {
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string compiler = "";
-  if (!lgs.empty())
-    {
-      this->AppendTarget(fout, "all", lgs[0], 0, make.c_str(), mf,
-                         compiler.c_str(), sourceFileFlags, true);
-      this->AppendTarget(fout, "clean", lgs[0], 0, make.c_str(), mf,
-                         compiler.c_str(), sourceFileFlags, false);
-    }
+  if (!lgs.empty()) {
+    this->AppendTarget(fout, "all", lgs[0], 0, make.c_str(), mf,
+                       compiler.c_str(), sourceFileFlags, true);
+    this->AppendTarget(fout, "clean", lgs[0], 0, make.c_str(), mf,
+                       compiler.c_str(), sourceFileFlags, false);
+  }
 
   // add all executable and library targets and some of the GLOBAL
   // and UTILITY targets
-  for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
-       lg!=lgs.end(); lg++)
-    {
-    cmMakefile* makefile=(*lg)->GetMakefile();
-    std::vector<cmGeneratorTarget*> targets=(*lg)->GetGeneratorTargets();
+  for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
+       lg != lgs.end(); lg++) {
+    cmMakefile* makefile = (*lg)->GetMakefile();
+    std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-         ti != targets.end(); ti++)
-      {
+         ti != targets.end(); ti++) {
       std::string targetName = (*ti)->GetName();
-      switch((*ti)->GetType())
-        {
-        case cmState::GLOBAL_TARGET:
-          {
+      switch ((*ti)->GetType()) {
+        case cmState::GLOBAL_TARGET: {
           // Only add the global targets from CMAKE_BINARY_DIR,
           // not from the subdirs
           if (strcmp((*lg)->GetCurrentBinaryDirectory(),
-                     (*lg)->GetBinaryDirectory())==0)
-            {
-            this->AppendTarget(fout, targetName, *lg, 0,
-                               make.c_str(), makefile, compiler.c_str(),
-                               sourceFileFlags, false);
-            }
+                     (*lg)->GetBinaryDirectory()) == 0) {
+            this->AppendTarget(fout, targetName, *lg, 0, make.c_str(),
+                               makefile, compiler.c_str(), sourceFileFlags,
+                               false);
           }
-          break;
+        } break;
         case cmState::UTILITY:
           // Add all utility targets, except the Nightly/Continuous/
           // Experimental-"sub"targets as e.g. NightlyStart
-          if (((targetName.find("Nightly")==0)   &&(targetName!="Nightly"))
-             || ((targetName.find("Continuous")==0)
-                 &&(targetName!="Continuous"))
-             || ((targetName.find("Experimental")==0)
-                 && (targetName!="Experimental")))
-            {
+          if (((targetName.find("Nightly") == 0) &&
+               (targetName != "Nightly")) ||
+              ((targetName.find("Continuous") == 0) &&
+               (targetName != "Continuous")) ||
+              ((targetName.find("Experimental") == 0) &&
+               (targetName != "Experimental"))) {
             break;
-            }
+          }
 
-          this->AppendTarget(fout, targetName, *lg, 0,
-                             make.c_str(), makefile, compiler.c_str(),
-                             sourceFileFlags, false);
+          this->AppendTarget(fout, targetName, *lg, 0, make.c_str(), makefile,
+                             compiler.c_str(), sourceFileFlags, false);
           break;
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
         case cmState::SHARED_LIBRARY:
         case cmState::MODULE_LIBRARY:
-        case cmState::OBJECT_LIBRARY:
-          {
-          this->AppendTarget(fout, targetName, *lg, *ti,
-                             make.c_str(), makefile, compiler.c_str(),
-                             sourceFileFlags, false);
+        case cmState::OBJECT_LIBRARY: {
+          this->AppendTarget(fout, targetName, *lg, *ti, make.c_str(),
+                             makefile, compiler.c_str(), sourceFileFlags,
+                             false);
           std::string fastTarget = targetName;
           fastTarget += "/fast";
-          this->AppendTarget(fout, fastTarget, *lg, *ti,
-                             make.c_str(), makefile, compiler.c_str(),
-                             sourceFileFlags, false);
-          }
-          break;
+          this->AppendTarget(fout, fastTarget, *lg, *ti, make.c_str(),
+                             makefile, compiler.c_str(), sourceFileFlags,
+                             false);
+        } break;
         default:
           break;
-        }
       }
     }
+  }
 }
 
-void cmExtraSublimeTextGenerator::
-  AppendTarget(cmGeneratedFileStream& fout,
-               const std::string& targetName,
-               cmLocalGenerator* lg,
-               cmGeneratorTarget* target,
-               const char* make,
-               const cmMakefile* makefile,
-               const char*, //compiler
-               MapSourceFileFlags& sourceFileFlags,
-               bool firstTarget)
+void cmExtraSublimeTextGenerator::AppendTarget(
+  cmGeneratedFileStream& fout, const std::string& targetName,
+  cmLocalGenerator* lg, cmGeneratorTarget* target, const char* make,
+  const cmMakefile* makefile,
+  const char*, // compiler
+  MapSourceFileFlags& sourceFileFlags, bool firstTarget)
 {
 
-  if (target != 0)
-    {
-      std::vector<cmSourceFile*> sourceFiles;
-      target->GetSourceFiles(sourceFiles,
-                             makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-      std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
-        sourceFiles.end();
-      for (std::vector<cmSourceFile*>::const_iterator iter =
-        sourceFiles.begin(); iter != sourceFilesEnd; ++iter)
-        {
-          cmSourceFile* sourceFile = *iter;
-          MapSourceFileFlags::iterator sourceFileFlagsIter =
-            sourceFileFlags.find(sourceFile->GetFullPath());
-          if (sourceFileFlagsIter == sourceFileFlags.end())
-            {
-            sourceFileFlagsIter =
-              sourceFileFlags.insert(MapSourceFileFlags::value_type(
-                sourceFile->GetFullPath(), std::vector<std::string>())).first;
-            }
-          std::vector<std::string>& flags = sourceFileFlagsIter->second;
-          std::string flagsString =
-            this->ComputeFlagsForObject(*iter, lg, target);
-          std::string definesString =
-            this->ComputeDefines(*iter, lg, target);
-          flags.clear();
-          cmsys::RegularExpression flagRegex;
-          // Regular expression to extract compiler flags from a string
-          // https://gist.github.com/3944250
-          const char* regexString =
-            "(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?";
-          flagRegex.compile(regexString);
-          std::string workString = flagsString + " " + definesString;
-          while (flagRegex.find(workString))
-            {
-              std::string::size_type start = flagRegex.start();
-              if (workString[start] == ' ')
-                {
-                  start++;
-                }
-              flags.push_back(workString.substr(start,
-                flagRegex.end() - start));
-              if (flagRegex.end() < workString.size())
-                {
-                workString = workString.substr(flagRegex.end());
-                }
-                else
-                {
-                workString = "";
-                }
-            }
+  if (target != 0) {
+    std::vector<cmSourceFile*> sourceFiles;
+    target->GetSourceFiles(sourceFiles,
+                           makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+    std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
+      sourceFiles.end();
+    for (std::vector<cmSourceFile*>::const_iterator iter = sourceFiles.begin();
+         iter != sourceFilesEnd; ++iter) {
+      cmSourceFile* sourceFile = *iter;
+      MapSourceFileFlags::iterator sourceFileFlagsIter =
+        sourceFileFlags.find(sourceFile->GetFullPath());
+      if (sourceFileFlagsIter == sourceFileFlags.end()) {
+        sourceFileFlagsIter =
+          sourceFileFlags
+            .insert(MapSourceFileFlags::value_type(sourceFile->GetFullPath(),
+                                                   std::vector<std::string>()))
+            .first;
+      }
+      std::vector<std::string>& flags = sourceFileFlagsIter->second;
+      std::string flagsString = this->ComputeFlagsForObject(*iter, lg, target);
+      std::string definesString = this->ComputeDefines(*iter, lg, target);
+      flags.clear();
+      cmsys::RegularExpression flagRegex;
+      // Regular expression to extract compiler flags from a string
+      // https://gist.github.com/3944250
+      const char* regexString =
+        "(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?";
+      flagRegex.compile(regexString);
+      std::string workString = flagsString + " " + definesString;
+      while (flagRegex.find(workString)) {
+        std::string::size_type start = flagRegex.start();
+        if (workString[start] == ' ') {
+          start++;
+        }
+        flags.push_back(workString.substr(start, flagRegex.end() - start));
+        if (flagRegex.end() < workString.size()) {
+          workString = workString.substr(flagRegex.end());
+        } else {
+          workString = "";
         }
+      }
     }
+  }
 
   // Ninja uses ninja.build files (look for a way to get the output file name
   // from cmMakefile or something)
   std::string makefileName;
-  if (this->GlobalGenerator->GetName() == "Ninja")
-    {
-      makefileName = "build.ninja";
-    }
-    else
-    {
-      makefileName = "Makefile";
-    }
-  if (!firstTarget)
-    {
+  if (this->GlobalGenerator->GetName() == "Ninja") {
+    makefileName = "build.ninja";
+  } else {
+    makefileName = "Makefile";
+  }
+  if (!firstTarget) {
     fout << ",\n\t";
-    }
-  fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - " <<
-          targetName << "\",\n";
-  fout << "\t\t\t\"cmd\": [" <<
-          this->BuildMakeCommand(make, makefileName.c_str(), targetName) <<
-          "],\n";
+  }
+  fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - "
+       << targetName << "\",\n";
+  fout << "\t\t\t\"cmd\": ["
+       << this->BuildMakeCommand(make, makefileName.c_str(), targetName)
+       << "],\n";
   fout << "\t\t\t\"working_dir\": \"${project_path}\",\n";
   fout << "\t\t\t\"file_regex\": \"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$\"\n";
   fout << "\t\t}";
@@ -313,66 +272,54 @@ void cmExtraSublimeTextGenerator::
 // 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 std::string& target)
+  const std::string& make, const char* makefile, const std::string& target)
 {
   std::string command = "\"";
   command += make + "\"";
   std::string generator = this->GlobalGenerator->GetName();
-  if (generator == "NMake Makefiles")
-    {
+  if (generator == "NMake Makefiles") {
     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
     command += ", \"/NOLOGO\", \"/f\", \"";
     command += makefileName + "\"";
     command += ", \"VERBOSE=1\", \"";
     command += target;
     command += "\"";
-    }
-  else if (generator == "Ninja")
-    {
+  } else if (generator == "Ninja") {
     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
     command += ", \"-f\", \"";
     command += makefileName + "\"";
     command += ", \"-v\", \"";
     command += target;
     command += "\"";
-    }
-  else
-    {
+  } else {
     std::string makefileName;
-    if (generator == "MinGW Makefiles")
-      {
-        // no escaping of spaces in this case, see
-        // http://public.kitware.com/Bug/view.php?id=10014
-        makefileName = makefile;
-      }
-      else
-      {
-        makefileName = cmSystemTools::ConvertToOutputPath(makefile);
-      }
+    if (generator == "MinGW Makefiles") {
+      // no escaping of spaces in this case, see
+      // http://public.kitware.com/Bug/view.php?id=10014
+      makefileName = makefile;
+    } else {
+      makefileName = cmSystemTools::ConvertToOutputPath(makefile);
+    }
     command += ", \"-f\", \"";
     command += makefileName + "\"";
     command += ", \"VERBOSE=1\", \"";
     command += target;
     command += "\"";
-    }
+  }
   return command;
 }
 
 // TODO: Most of the code is picked up from the Ninja generator, refactor it.
-std::string
-cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
-                                                   cmLocalGenerator* lg,
-                                                   cmGeneratorTarget* gtgt)
+std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
+  cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt)
 {
   std::string flags;
 
-  cmMakefile *makefile = lg->GetMakefile();
+  cmMakefile* makefile = lg->GetMakefile();
   std::string language = source->GetLanguage();
-  if (language.empty())
-   {
-   language = "C";
-   }
+  if (language.empty()) {
+    language = "C";
+  }
   const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   // Add language-specific flags.
   lg->AddLanguageFlags(flags, language, config);
@@ -391,11 +338,11 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
 
   // Add include directory flags.
   {
-  std::vector<std::string> includes;
-  lg->GetIncludeDirectories(includes, gtgt, language, config);
-  std::string includeFlags =
-    lg->GetIncludeFlags(includes, gtgt, language, true); // full include paths
-  lg->AppendFlags(flags, includeFlags);
+    std::vector<std::string> includes;
+    lg->GetIncludeDirectories(includes, gtgt, language, config);
+    std::string includeFlags = lg->GetIncludeFlags(includes, gtgt, language,
+                                                   true); // full include paths
+    lg->AppendFlags(flags, includeFlags);
   }
 
   // Append old-style preprocessor definition flags.
@@ -414,30 +361,27 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
 
 // TODO: Refactor with
 // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
-std::string
-cmExtraSublimeTextGenerator::
-ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
-               cmGeneratorTarget* target)
+std::string cmExtraSublimeTextGenerator::ComputeDefines(
+  cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* target)
 
 {
   std::set<std::string> defines;
-  cmMakefile *makefile = lg->GetMakefile();
+  cmMakefile* makefile = lg->GetMakefile();
   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())
-    {
+  if (const char* exportMacro = target->GetExportMacro()) {
     lg->AppendDefines(defines, exportMacro);
-    }
+  }
 
   // Add preprocessor definitions for this target and configuration.
   lg->AddCompileDefinitions(defines, target, config, language);
   lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
   {
-  std::string defPropName = "COMPILE_DEFINITIONS_";
-  defPropName += cmSystemTools::UpperCase(config);
-  lg->AppendDefines(defines, source->GetProperty(defPropName));
+    std::string defPropName = "COMPILE_DEFINITIONS_";
+    defPropName += cmSystemTools::UpperCase(config);
+    lg->AppendDefines(defines, source->GetProperty(defPropName));
   }
 
   std::string definesString;
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index cf31ee0..6efec7a 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -31,29 +31,31 @@ public:
   cmExtraSublimeTextGenerator();
 
   virtual std::string GetName() const
-                        { return cmExtraSublimeTextGenerator::GetActualName();}
-  static std::string GetActualName()
-                        { return "Sublime Text 2";}
+  {
+    return cmExtraSublimeTextGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "Sublime Text 2"; }
   static cmExternalMakefileProjectGenerator* New()
-                                    { return new cmExtraSublimeTextGenerator; }
+  {
+    return new cmExtraSublimeTextGenerator;
+  }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
                                 const std::string& fullName) const;
 
   virtual void Generate();
-private:
 
+private:
   void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
 
   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
-                                const std::string& filename);
+                            const std::string& filename);
 
   /** Appends all targets as build systems to the project file and get all
    * include directories and compiler definitions used.
    */
   void AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
-                        const cmMakefile* mf,
-                        cmGeneratedFileStream& fout,
+                        const cmMakefile* mf, cmGeneratedFileStream& fout,
                         MapSourceFileFlags& sourceFileFlags);
   /** Returns the build command that needs to be executed to build the
    *  specified target.
@@ -63,24 +65,20 @@ private:
   /** Appends the specified target to the generated project file as a Sublime
    *  Text build system.
    */
-  void AppendTarget(cmGeneratedFileStream& fout,
-                    const std::string& targetName,
-                    cmLocalGenerator* lg,
-                    cmGeneratorTarget* target,
-                    const char* make,
-                    const cmMakefile* makefile,
-                    const char* compiler,
-                    MapSourceFileFlags& sourceFileFlags, bool firstTarget);
+  void AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName,
+                    cmLocalGenerator* lg, cmGeneratorTarget* target,
+                    const char* make, const cmMakefile* makefile,
+                    const char* compiler, MapSourceFileFlags& sourceFileFlags,
+                    bool firstTarget);
   /**
    * 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,
-                                    cmLocalGenerator* lg,
+  std::string ComputeFlagsForObject(cmSourceFile* source, cmLocalGenerator* lg,
                                     cmGeneratorTarget* gtgt);
 
-  std::string ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
+  std::string ComputeDefines(cmSourceFile* source, cmLocalGenerator* lg,
                              cmGeneratorTarget* gtgt);
 };
 
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index c64e813..ebd6223 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -14,14 +14,13 @@
 #include "cmSourceFile.h"
 
 // cmFLTKWrapUICommand
-bool cmFLTKWrapUICommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
+                                      cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // what is the current source dir
   std::string cdir = this->Makefile->GetCurrentSourceDirectory();
@@ -29,27 +28,25 @@ bool cmFLTKWrapUICommand
     this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
 
   // get parameter for the command
-  this->Target = args[0];  // Target that will use the generated files
+  this->Target = args[0]; // Target that will use the generated files
 
   // get the list of GUI files from which .cxx and .h will be generated
   std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory();
 
   {
-  // Some of the generated files are *.h so the directory "GUI"
-  // where they are created have to be added to the include path
-  std::vector<std::string> outputDirectories;
-  outputDirectories.push_back(outputDirectory);
-  this->Makefile->AddIncludeDirectories( outputDirectories );
+    // Some of the generated files are *.h so the directory "GUI"
+    // where they are created have to be added to the include path
+    std::vector<std::string> outputDirectories;
+    outputDirectories.push_back(outputDirectory);
+    this->Makefile->AddIncludeDirectories(outputDirectories);
   }
 
-  for(std::vector<std::string>::const_iterator i = (args.begin() + 1);
-      i != args.end(); i++)
-    {
-    cmSourceFile *curr = this->Makefile->GetSource(*i);
+  for (std::vector<std::string>::const_iterator i = (args.begin() + 1);
+       i != args.end(); i++) {
+    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"))
-      {
+    if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) {
       std::string outName = outputDirectory;
       outName += "/";
       outName += cmSystemTools::GetFilenameWithoutExtension(*i);
@@ -70,7 +67,7 @@ bool cmFLTKWrapUICommand
       commandLine.push_back(hname);
       commandLine.push_back("-o"); // optionally rename .cxx files
       commandLine.push_back(cxxres);
-      commandLine.push_back(origname);// name of the GUI fluid file
+      commandLine.push_back(origname); // name of the GUI fluid file
       cmCustomCommandLines commandLines;
       commandLines.push_back(commandLine);
 
@@ -78,33 +75,29 @@ bool cmFLTKWrapUICommand
       std::string no_main_dependency = "";
       const char* no_comment = 0;
       const char* no_working_dir = 0;
-      this->Makefile->AddCustomCommandToOutput(cxxres,
-                                           depends, no_main_dependency,
-                                           commandLines, no_comment,
-                                           no_working_dir);
-      this->Makefile->AddCustomCommandToOutput(hname,
-                                           depends, no_main_dependency,
-                                           commandLines, no_comment,
-                                           no_working_dir);
-
-      cmSourceFile *sf = this->Makefile->GetSource(cxxres);
+      this->Makefile->AddCustomCommandToOutput(
+        cxxres, depends, no_main_dependency, commandLines, no_comment,
+        no_working_dir);
+      this->Makefile->AddCustomCommandToOutput(
+        hname, depends, no_main_dependency, commandLines, no_comment,
+        no_working_dir);
+
+      cmSourceFile* sf = this->Makefile->GetSource(cxxres);
       sf->AddDepend(hname.c_str());
       sf->AddDepend(origname.c_str());
       this->GeneratedSourcesClasses.push_back(sf);
-      }
     }
+  }
 
   // create the variable with the list of sources in it
   size_t lastHeadersClass = this->GeneratedSourcesClasses.size();
   std::string sourceListValue;
-  for(size_t classNum = 0; classNum < lastHeadersClass; classNum++)
-    {
-    if (classNum)
-      {
+  for (size_t classNum = 0; classNum < lastHeadersClass; classNum++) {
+    if (classNum) {
       sourceListValue += ";";
-      }
-    sourceListValue += this->GeneratedSourcesClasses[classNum]->GetFullPath();
     }
+    sourceListValue += this->GeneratedSourcesClasses[classNum]->GetFullPath();
+  }
   std::string varName = this->Target;
   varName += "_FLTK_UI_SRCS";
   this->Makefile->AddDefinition(varName, sourceListValue.c_str());
@@ -118,18 +111,14 @@ void cmFLTKWrapUICommand::FinalPass()
   // didn't support that, so check and see if they added the files in and if
   // they didn;t then print a warning and add then anyhow
   cmTarget* target = this->Makefile->FindLocalNonAliasTarget(this->Target);
-  if(!target)
-    {
+  if (!target) {
     std::string msg =
       "FLTK_WRAP_UI was called with a target that was never created: ";
     msg += this->Target;
-    msg +=".  The problem was found while processing the source directory: ";
+    msg += ".  The problem was found while processing the source directory: ";
     msg += this->Makefile->GetCurrentSourceDirectory();
     msg += ".  This FLTK_WRAP_UI call will be ignored.";
-    cmSystemTools::Message(msg.c_str(),"Warning");
+    cmSystemTools::Message(msg.c_str(), "Warning");
     return;
-    }
+  }
 }
-
-
-
diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h
index 617fcd9..2e60051 100644
--- a/Source/cmFLTKWrapUICommand.h
+++ b/Source/cmFLTKWrapUICommand.h
@@ -28,17 +28,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFLTKWrapUICommand;
-    }
+  virtual cmCommand* Clone() { return new cmFLTKWrapUICommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This is called at the end after all the information
@@ -52,13 +49,13 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "fltk_wrap_ui";}
+  virtual std::string GetName() const { return "fltk_wrap_ui"; }
 
 private:
   /**
    * List of produced files.
    */
-  std::vector<cmSourceFile *> GeneratedSourcesClasses;
+  std::vector<cmSourceFile*> GeneratedSourcesClasses;
 
   /**
    * List of Fluid files that provide the source
@@ -67,6 +64,4 @@ private:
   std::string Target;
 };
 
-
-
 #endif
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index b3557f9..4e72f36 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -10,14 +10,15 @@
   See the License for more information.
 ============================================================================*/
 #include "cmFileCommand.h"
+
+#include "cmAlgorithms.h"
+#include "cmCryptoHash.h"
 #include "cmCryptoHash.h"
-#include "cmake.h"
-#include "cmHexFileConverter.h"
-#include "cmInstallType.h"
 #include "cmFileTimeComparison.h"
 #include "cmGlobalGenerator.h"
-#include "cmCryptoHash.h"
-#include "cmAlgorithms.h"
+#include "cmHexFileConverter.h"
+#include "cmInstallType.h"
+#include "cmake.h"
 
 #include "cmTimestamp.h"
 
@@ -28,15 +29,17 @@
 
 #undef GetCurrentDirectory
 #include <assert.h>
+
 #include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h>
 
-#include <cmsys/auto_ptr.hxx>
 #include <cmsys/Directory.hxx>
+#include <cmsys/Encoding.hxx>
+#include <cmsys/FStream.hxx>
 #include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
-#include <cmsys/FStream.hxx>
-#include <cmsys/Encoding.hxx>
+#include <cmsys/auto_ptr.hxx>
 
 // Table of permissions flags.
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -71,234 +74,169 @@ static mode_t mode_setgid = S_ISGID;
 static std::string fix_file_url_windows(const std::string& url)
 {
   std::string ret = url;
-  if(strncmp(url.c_str(), "file://", 7) == 0)
-    {
+  if (strncmp(url.c_str(), "file://", 7) == 0) {
     std::wstring wurl = cmsys::Encoding::ToWide(url);
-    if(!wurl.empty())
-      {
-      int mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1,
-                                   NULL, 0, NULL, NULL);
-      if(mblen > 0)
-        {
+    if (!wurl.empty()) {
+      int mblen =
+        WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, NULL, 0, NULL, NULL);
+      if (mblen > 0) {
         std::vector<char> chars(mblen);
-        mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1,
-                                   &chars[0], mblen, NULL, NULL);
-        if(mblen > 0)
-          {
+        mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, &chars[0],
+                                    mblen, NULL, NULL);
+        if (mblen > 0) {
           ret = &chars[0];
-          }
         }
       }
     }
+  }
   return ret;
 }
 #endif
 
 // cmLibraryCommand
-bool cmFileCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmFileCommand::InitialPass(std::vector<std::string> const& args,
+                                cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("must be called with at least two arguments.");
     return false;
-    }
+  }
   std::string subCommand = args[0];
-  if ( subCommand == "WRITE" )
-    {
+  if (subCommand == "WRITE") {
     return this->HandleWriteCommand(args, false);
-    }
-  else if ( subCommand == "APPEND" )
-    {
+  } else if (subCommand == "APPEND") {
     return this->HandleWriteCommand(args, true);
-    }
-  else if ( subCommand == "DOWNLOAD" )
-    {
+  } else if (subCommand == "DOWNLOAD") {
     return this->HandleDownloadCommand(args);
-    }
-  else if ( subCommand == "UPLOAD" )
-    {
+  } else if (subCommand == "UPLOAD") {
     return this->HandleUploadCommand(args);
-    }
-  else if ( subCommand == "READ" )
-    {
+  } else if (subCommand == "READ") {
     return this->HandleReadCommand(args);
-    }
-  else if ( subCommand == "MD5" ||
-            subCommand == "SHA1" ||
-            subCommand == "SHA224" ||
-            subCommand == "SHA256" ||
-            subCommand == "SHA384" ||
-            subCommand == "SHA512" )
-    {
+  } else if (subCommand == "MD5" || subCommand == "SHA1" ||
+             subCommand == "SHA224" || subCommand == "SHA256" ||
+             subCommand == "SHA384" || subCommand == "SHA512") {
     return this->HandleHashCommand(args);
-    }
-  else if ( subCommand == "STRINGS" )
-    {
+  } else if (subCommand == "STRINGS") {
     return this->HandleStringsCommand(args);
-    }
-  else if ( subCommand == "GLOB" )
-    {
+  } else if (subCommand == "GLOB") {
     return this->HandleGlobCommand(args, false);
-    }
-  else if ( subCommand == "GLOB_RECURSE" )
-    {
+  } else if (subCommand == "GLOB_RECURSE") {
     return this->HandleGlobCommand(args, true);
-    }
-  else if ( subCommand == "MAKE_DIRECTORY" )
-    {
+  } else if (subCommand == "MAKE_DIRECTORY") {
     return this->HandleMakeDirectoryCommand(args);
-    }
-  else if ( subCommand == "RENAME" )
-    {
+  } else if (subCommand == "RENAME") {
     return this->HandleRename(args);
-    }
-  else if ( subCommand == "REMOVE" )
-    {
+  } else if (subCommand == "REMOVE") {
     return this->HandleRemove(args, false);
-    }
-  else if ( subCommand == "REMOVE_RECURSE" )
-    {
+  } else if (subCommand == "REMOVE_RECURSE") {
     return this->HandleRemove(args, true);
-    }
-  else if ( subCommand == "COPY" )
-    {
+  } else if (subCommand == "COPY") {
     return this->HandleCopyCommand(args);
-    }
-  else if ( subCommand == "INSTALL" )
-    {
+  } else if (subCommand == "INSTALL") {
     return this->HandleInstallCommand(args);
-    }
-  else if ( subCommand == "DIFFERENT" )
-    {
+  } else if (subCommand == "DIFFERENT") {
     return this->HandleDifferentCommand(args);
-    }
-  else if ( subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH" )
-    {
+  } else if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") {
     return this->HandleRPathChangeCommand(args);
-    }
-  else if ( subCommand == "RPATH_CHECK" )
-    {
+  } else if (subCommand == "RPATH_CHECK") {
     return this->HandleRPathCheckCommand(args);
-    }
-  else if ( subCommand == "RPATH_REMOVE" )
-    {
+  } else if (subCommand == "RPATH_REMOVE") {
     return this->HandleRPathRemoveCommand(args);
-    }
-  else if ( subCommand == "RELATIVE_PATH" )
-    {
+  } else if (subCommand == "RELATIVE_PATH") {
     return this->HandleRelativePathCommand(args);
-    }
-  else if ( subCommand == "TO_CMAKE_PATH" )
-    {
+  } else if (subCommand == "TO_CMAKE_PATH") {
     return this->HandleCMakePathCommand(args, false);
-    }
-  else if ( subCommand == "TO_NATIVE_PATH" )
-    {
+  } else if (subCommand == "TO_NATIVE_PATH") {
     return this->HandleCMakePathCommand(args, true);
-    }
-  else if ( subCommand == "TIMESTAMP" )
-    {
+  } else if (subCommand == "TIMESTAMP") {
     return this->HandleTimestampCommand(args);
-    }
-  else if ( subCommand == "GENERATE" )
-    {
+  } else if (subCommand == "GENERATE") {
     return this->HandleGenerateCommand(args);
-    }
-  else if ( subCommand == "LOCK" )
-    {
+  } else if (subCommand == "LOCK") {
     return this->HandleLockCommand(args);
-    }
+  }
 
-  std::string e = "does not recognize sub-command "+subCommand;
+  std::string e = "does not recognize sub-command " + subCommand;
   this->SetError(e);
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
-  bool append)
+                                       bool append)
 {
   std::vector<std::string>::const_iterator i = args.begin();
 
   i++; // Get rid of subcommand
 
   std::string fileName = *i;
-  if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) )
-    {
+  if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
     fileName = this->Makefile->GetCurrentSourceDirectory();
     fileName += "/" + *i;
-    }
+  }
 
   i++;
 
-  if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
-    {
-    std::string e
-      = "attempted to write a file: " + fileName +
-      " into a source directory.";
+  if (!this->Makefile->CanIWriteThisFile(fileName.c_str())) {
+    std::string e =
+      "attempted to write a file: " + fileName + " into a source directory.";
     this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
   std::string dir = cmSystemTools::GetFilenamePath(fileName);
   cmSystemTools::MakeDirectory(dir.c_str());
 
   mode_t mode = 0;
 
   // Set permissions to writable
-  if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
-    {
+  if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) {
     cmSystemTools::SetPermissions(fileName.c_str(),
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
-      mode | S_IWRITE
+#if defined(_MSC_VER) || defined(__MINGW32__)
+                                  mode | S_IWRITE
 #else
-      mode | S_IWUSR | S_IWGRP
+                                  mode | S_IWUSR | S_IWGRP
 #endif
-    );
-    }
+                                  );
+  }
   // If GetPermissions fails, pretend like it is ok. File open will fail if
   // the file is not writable
-  cmsys::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out);
-  if ( !file )
-    {
+  cmsys::ofstream file(fileName.c_str(),
+                       append ? std::ios::app : std::ios::out);
+  if (!file) {
     std::string error = "failed to open for writing (";
     error += cmSystemTools::GetLastSystemError();
     error += "):\n  ";
     error += fileName;
     this->SetError(error);
     return false;
-    }
+  }
   std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
   file << message;
   file.close();
-  if(mode)
-    {
+  if (mode) {
     cmSystemTools::SetPermissions(fileName.c_str(), mode);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
 {
-  if ( args.size() < 3 )
-    {
+  if (args.size() < 3) {
     this->SetError("READ must be called with at least two additional "
                    "arguments");
     return false;
-    }
+  }
 
   cmCommandArgumentsHelper argHelper;
   cmCommandArgumentGroup group;
 
-  cmCAString readArg    (&argHelper, "READ");
-  cmCAString fileNameArg    (&argHelper, 0);
-  cmCAString resultArg      (&argHelper, 0);
+  cmCAString readArg(&argHelper, "READ");
+  cmCAString fileNameArg(&argHelper, 0);
+  cmCAString resultArg(&argHelper, 0);
 
-  cmCAString offsetArg      (&argHelper, "OFFSET", &group);
-  cmCAString limitArg       (&argHelper, "LIMIT", &group);
-  cmCAEnabler hexOutputArg  (&argHelper, "HEX", &group);
+  cmCAString offsetArg(&argHelper, "OFFSET", &group);
+  cmCAString limitArg(&argHelper, "LIMIT", &group);
+  cmCAEnabler hexOutputArg(&argHelper, "HEX", &group);
   readArg.Follows(0);
   fileNameArg.Follows(&readArg);
   resultArg.Follows(&fileNameArg);
@@ -306,122 +244,104 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
   argHelper.Parse(&args, 0);
 
   std::string fileName = fileNameArg.GetString();
-  if ( !cmsys::SystemTools::FileIsFullPath(fileName.c_str()) )
-    {
+  if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
     fileName = this->Makefile->GetCurrentSourceDirectory();
     fileName += "/" + fileNameArg.GetString();
-    }
+  }
 
   std::string variable = resultArg.GetString();
 
-  // Open the specified file.
+// Open the specified file.
 #if defined(_WIN32) || defined(__CYGWIN__)
-  cmsys::ifstream file(fileName.c_str(), std::ios::in |
-               (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in));
+  cmsys::ifstream file(
+    fileName.c_str(), std::ios::in |
+      (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in));
 #else
   cmsys::ifstream file(fileName.c_str(), std::ios::in);
 #endif
 
-  if ( !file )
-    {
+  if (!file) {
     std::string error = "failed to open for reading (";
     error += cmSystemTools::GetLastSystemError();
     error += "):\n  ";
     error += fileName;
     this->SetError(error);
     return false;
-    }
+  }
 
   // is there a limit?
   long sizeLimit = -1;
-  if (!limitArg.GetString().empty())
-    {
+  if (!limitArg.GetString().empty()) {
     sizeLimit = atoi(limitArg.GetCString());
-    }
+  }
 
   // is there an offset?
   long offset = 0;
-  if (!offsetArg.GetString().empty())
-    {
+  if (!offsetArg.GetString().empty()) {
     offset = atoi(offsetArg.GetCString());
-    }
+  }
 
   file.seekg(offset, std::ios::beg); // explicit ios::beg for IBM VisualAge 6
 
   std::string output;
 
-  if (hexOutputArg.IsEnabled())
-    {
+  if (hexOutputArg.IsEnabled()) {
     // Convert part of the file into hex code
     char c;
-    while((sizeLimit != 0) && (file.get(c)))
-      {
+    while ((sizeLimit != 0) && (file.get(c))) {
       char hex[4];
-      sprintf(hex, "%.2x", c&0xff);
+      sprintf(hex, "%.2x", c & 0xff);
       output += hex;
-      if (sizeLimit > 0)
-        {
+      if (sizeLimit > 0) {
         sizeLimit--;
-        }
       }
     }
-  else
-    {
+  } else {
     std::string line;
     bool has_newline = false;
-    while (sizeLimit != 0 &&
-          cmSystemTools::GetLineFromStream(file, line, &has_newline,
-                                            sizeLimit) )
-      {
-      if (sizeLimit > 0)
-        {
+    while (sizeLimit != 0 && cmSystemTools::GetLineFromStream(
+                               file, line, &has_newline, sizeLimit)) {
+      if (sizeLimit > 0) {
         sizeLimit = sizeLimit - static_cast<long>(line.size());
-        if (has_newline)
-          {
+        if (has_newline) {
           sizeLimit--;
-          }
-        if (sizeLimit < 0)
-          {
+        }
+        if (sizeLimit < 0) {
           sizeLimit = 0;
-          }
         }
+      }
       output += line;
-      if ( has_newline )
-        {
+      if (has_newline) {
         output += "\n";
-        }
       }
     }
+  }
   this->Makefile->AddDefinition(variable, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     std::ostringstream e;
     e << args[0] << " requires a file name and output variable";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
-  if(hash.get())
-    {
+  if (hash.get()) {
     std::string out = hash->HashFile(args[1]);
-    if(!out.empty())
-      {
+    if (!out.empty()) {
       this->Makefile->AddDefinition(args[2], out.c_str());
       return true;
-      }
+    }
     std::ostringstream e;
-    e << args[0] << " failed to read file \"" << args[1] << "\": "
-      << cmSystemTools::GetLastSystemError();
+    e << args[0] << " failed to read file \"" << args[1]
+      << "\": " << cmSystemTools::GetLastSystemError();
     this->SetError(e.str());
-    }
+  }
   return false;
 #else
   std::ostringstream e;
@@ -431,36 +351,36 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("STRINGS requires a file name and output variable");
     return false;
-    }
+  }
 
   // Get the file to read.
   std::string fileName = args[1];
-  if(!cmsys::SystemTools::FileIsFullPath(fileName.c_str()))
-    {
+  if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
     fileName = this->Makefile->GetCurrentSourceDirectory();
     fileName += "/" + args[1];
-    }
+  }
 
   // Get the variable in which to store the results.
   std::string outVar = args[2];
 
   // Parse the options.
-  enum { arg_none,
-         arg_limit_input,
-         arg_limit_output,
-         arg_limit_count,
-         arg_length_minimum,
-         arg_length_maximum,
-         arg__maximum,
-         arg_regex,
-         arg_encoding };
+  enum
+  {
+    arg_none,
+    arg_limit_input,
+    arg_limit_output,
+    arg_limit_count,
+    arg_length_minimum,
+    arg_length_maximum,
+    arg__maximum,
+    arg_regex,
+    arg_encoding
+  };
   unsigned int minlen = 0;
   unsigned int maxlen = 0;
   int limit_input = -1;
@@ -470,396 +390,302 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
   bool have_regex = false;
   bool newline_consume = false;
   bool hex_conversion_enabled = true;
-  enum { encoding_none = cmsys::FStream::BOM_None,
-         encoding_utf8 = cmsys::FStream::BOM_UTF8,
-         encoding_utf16le = cmsys::FStream::BOM_UTF16LE,
-         encoding_utf16be = cmsys::FStream::BOM_UTF16BE,
-         encoding_utf32le = cmsys::FStream::BOM_UTF32LE,
-         encoding_utf32be = cmsys::FStream::BOM_UTF32BE};
+  enum
+  {
+    encoding_none = cmsys::FStream::BOM_None,
+    encoding_utf8 = cmsys::FStream::BOM_UTF8,
+    encoding_utf16le = cmsys::FStream::BOM_UTF16LE,
+    encoding_utf16be = cmsys::FStream::BOM_UTF16BE,
+    encoding_utf32le = cmsys::FStream::BOM_UTF32LE,
+    encoding_utf32be = cmsys::FStream::BOM_UTF32BE
+  };
   int encoding = encoding_none;
   int arg_mode = arg_none;
-  for(unsigned int i=3; i < args.size(); ++i)
-    {
-    if(args[i] == "LIMIT_INPUT")
-      {
+  for (unsigned int i = 3; i < args.size(); ++i) {
+    if (args[i] == "LIMIT_INPUT") {
       arg_mode = arg_limit_input;
-      }
-    else if(args[i] == "LIMIT_OUTPUT")
-      {
+    } else if (args[i] == "LIMIT_OUTPUT") {
       arg_mode = arg_limit_output;
-      }
-    else if(args[i] == "LIMIT_COUNT")
-      {
+    } else if (args[i] == "LIMIT_COUNT") {
       arg_mode = arg_limit_count;
-      }
-    else if(args[i] == "LENGTH_MINIMUM")
-      {
+    } else if (args[i] == "LENGTH_MINIMUM") {
       arg_mode = arg_length_minimum;
-      }
-    else if(args[i] == "LENGTH_MAXIMUM")
-      {
+    } else if (args[i] == "LENGTH_MAXIMUM") {
       arg_mode = arg_length_maximum;
-      }
-    else if(args[i] == "REGEX")
-      {
+    } else if (args[i] == "REGEX") {
       arg_mode = arg_regex;
-      }
-    else if(args[i] == "NEWLINE_CONSUME")
-      {
+    } else if (args[i] == "NEWLINE_CONSUME") {
       newline_consume = true;
       arg_mode = arg_none;
-      }
-    else if(args[i] == "NO_HEX_CONVERSION")
-      {
+    } else if (args[i] == "NO_HEX_CONVERSION") {
       hex_conversion_enabled = false;
       arg_mode = arg_none;
-      }
-    else if(args[i] == "ENCODING")
-      {
+    } else if (args[i] == "ENCODING") {
       arg_mode = arg_encoding;
-      }
-    else if(arg_mode == arg_limit_input)
-      {
-      if(sscanf(args[i].c_str(), "%d", &limit_input) != 1 ||
-         limit_input < 0)
-        {
+    } else if (arg_mode == arg_limit_input) {
+      if (sscanf(args[i].c_str(), "%d", &limit_input) != 1 ||
+          limit_input < 0) {
         std::ostringstream e;
-        e << "STRINGS option LIMIT_INPUT value \""
-          << args[i] << "\" is not an unsigned integer.";
+        e << "STRINGS option LIMIT_INPUT value \"" << args[i]
+          << "\" is not an unsigned integer.";
         this->SetError(e.str());
         return false;
-        }
-      arg_mode = arg_none;
       }
-    else if(arg_mode == arg_limit_output)
-      {
-      if(sscanf(args[i].c_str(), "%d", &limit_output) != 1 ||
-         limit_output < 0)
-        {
+      arg_mode = arg_none;
+    } else if (arg_mode == arg_limit_output) {
+      if (sscanf(args[i].c_str(), "%d", &limit_output) != 1 ||
+          limit_output < 0) {
         std::ostringstream e;
-        e << "STRINGS option LIMIT_OUTPUT value \""
-          << args[i] << "\" is not an unsigned integer.";
+        e << "STRINGS option LIMIT_OUTPUT value \"" << args[i]
+          << "\" is not an unsigned integer.";
         this->SetError(e.str());
         return false;
-        }
-      arg_mode = arg_none;
       }
-    else if(arg_mode == arg_limit_count)
-      {
+      arg_mode = arg_none;
+    } else if (arg_mode == arg_limit_count) {
       int count;
-      if(sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0)
-        {
+      if (sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0) {
         std::ostringstream e;
-        e << "STRINGS option LIMIT_COUNT value \""
-          << args[i] << "\" is not an unsigned integer.";
+        e << "STRINGS option LIMIT_COUNT value \"" << args[i]
+          << "\" is not an unsigned integer.";
         this->SetError(e.str());
         return false;
-        }
+      }
       limit_count = count;
       arg_mode = arg_none;
-      }
-    else if(arg_mode == arg_length_minimum)
-      {
+    } else if (arg_mode == arg_length_minimum) {
       int len;
-      if(sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0)
-        {
+      if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
         std::ostringstream e;
-        e << "STRINGS option LENGTH_MINIMUM value \""
-          << args[i] << "\" is not an unsigned integer.";
+        e << "STRINGS option LENGTH_MINIMUM value \"" << args[i]
+          << "\" is not an unsigned integer.";
         this->SetError(e.str());
         return false;
-        }
+      }
       minlen = len;
       arg_mode = arg_none;
-      }
-    else if(arg_mode == arg_length_maximum)
-      {
+    } else if (arg_mode == arg_length_maximum) {
       int len;
-      if(sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0)
-        {
+      if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
         std::ostringstream e;
-        e << "STRINGS option LENGTH_MAXIMUM value \""
-          << args[i] << "\" is not an unsigned integer.";
+        e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i]
+          << "\" is not an unsigned integer.";
         this->SetError(e.str());
         return false;
-        }
+      }
       maxlen = len;
       arg_mode = arg_none;
-      }
-    else if(arg_mode == arg_regex)
-      {
-      if(!regex.compile(args[i].c_str()))
-        {
+    } else if (arg_mode == arg_regex) {
+      if (!regex.compile(args[i].c_str())) {
         std::ostringstream e;
-        e << "STRINGS option REGEX value \""
-          << args[i] << "\" could not be compiled.";
+        e << "STRINGS option REGEX value \"" << args[i]
+          << "\" could not be compiled.";
         this->SetError(e.str());
         return false;
-        }
+      }
       have_regex = true;
       arg_mode = arg_none;
-      }
-    else if(arg_mode == arg_encoding)
-      {
-      if(args[i] == "UTF-8")
-        {
+    } else if (arg_mode == arg_encoding) {
+      if (args[i] == "UTF-8") {
         encoding = encoding_utf8;
-        }
-      else if(args[i] == "UTF-16LE")
-        {
+      } else if (args[i] == "UTF-16LE") {
         encoding = encoding_utf16le;
-        }
-      else if(args[i] == "UTF-16BE")
-        {
+      } else if (args[i] == "UTF-16BE") {
         encoding = encoding_utf16be;
-        }
-      else if(args[i] == "UTF-32LE")
-        {
+      } else if (args[i] == "UTF-32LE") {
         encoding = encoding_utf32le;
-        }
-      else if(args[i] == "UTF-32BE")
-        {
+      } else if (args[i] == "UTF-32BE") {
         encoding = encoding_utf32be;
-        }
-      else
-        {
+      } else {
         std::ostringstream e;
-        e << "STRINGS option ENCODING \""
-          << args[i] << "\" not recognized.";
+        e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized.";
         this->SetError(e.str());
         return false;
-        }
-      arg_mode = arg_none;
       }
-    else
-      {
+      arg_mode = arg_none;
+    } else {
       std::ostringstream e;
-      e << "STRINGS given unknown argument \""
-        << args[i] << "\"";
+      e << "STRINGS given unknown argument \"" << args[i] << "\"";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
-  if (hex_conversion_enabled)
-    {
+  if (hex_conversion_enabled) {
     // TODO: should work without temp file, but just on a memory buffer
     std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory();
     binaryFileName += cmake::GetCMakeFilesDirectory();
     binaryFileName += "/FileCommandStringsBinaryFile";
-    if(cmHexFileConverter::TryConvert(fileName.c_str(),binaryFileName.c_str()))
-      {
+    if (cmHexFileConverter::TryConvert(fileName.c_str(),
+                                       binaryFileName.c_str())) {
       fileName = binaryFileName;
-      }
     }
+  }
 
-  // Open the specified file.
+// Open the specified file.
 #if defined(_WIN32) || defined(__CYGWIN__)
   cmsys::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary);
 #else
   cmsys::ifstream fin(fileName.c_str(), std::ios::in);
 #endif
-  if(!fin)
-    {
+  if (!fin) {
     std::ostringstream e;
     e << "STRINGS file \"" << fileName << "\" cannot be read.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
-  //If BOM is found and encoding was not specified, use the BOM
+  // If BOM is found and encoding was not specified, use the BOM
   int bom_found = cmsys::FStream::ReadBOM(fin);
-  if(encoding == encoding_none && bom_found != cmsys::FStream::BOM_None)
-    {
+  if (encoding == encoding_none && bom_found != cmsys::FStream::BOM_None) {
     encoding = bom_found;
-    }
+  }
 
   unsigned int bytes_rem = 0;
-  if(encoding == encoding_utf16le || encoding == encoding_utf16be)
-    {
+  if (encoding == encoding_utf16le || encoding == encoding_utf16be) {
     bytes_rem = 1;
-    }
-  if(encoding == encoding_utf32le || encoding == encoding_utf32be)
-    {
+  }
+  if (encoding == encoding_utf32le || encoding == encoding_utf32be) {
     bytes_rem = 3;
-    }
+  }
 
   // Parse strings out of the file.
   int output_size = 0;
   std::vector<std::string> strings;
   std::string s;
-  while((!limit_count || strings.size() < limit_count) &&
-        (limit_input < 0 || static_cast<int>(fin.tellg()) < limit_input) &&
-        fin)
-    {
+  while ((!limit_count || strings.size() < limit_count) &&
+         (limit_input < 0 || static_cast<int>(fin.tellg()) < limit_input) &&
+         fin) {
     std::string current_str;
 
     int c = fin.get();
-    for(unsigned int i=0; i<bytes_rem; ++i)
-      {
+    for (unsigned int i = 0; i < bytes_rem; ++i) {
       int c1 = fin.get();
-      if(!fin)
-        {
+      if (!fin) {
         fin.putback(static_cast<char>(c1));
         break;
-        }
-      c = (c << 8) | c1;
       }
-    if(encoding == encoding_utf16le)
-      {
+      c = (c << 8) | c1;
+    }
+    if (encoding == encoding_utf16le) {
       c = ((c & 0xFF) << 8) | ((c & 0xFF00) >> 8);
-      }
-    else if(encoding == encoding_utf32le)
-      {
-       c = (((c & 0xFF) << 24) | ((c & 0xFF00) << 8) |
-          ((c & 0xFF0000) >> 8) | ((c & 0xFF000000) >> 24));
-      }
+    } else if (encoding == encoding_utf32le) {
+      c = (((c & 0xFF) << 24) | ((c & 0xFF00) << 8) | ((c & 0xFF0000) >> 8) |
+           ((c & 0xFF000000) >> 24));
+    }
 
-    if(c == '\r')
-      {
+    if (c == '\r') {
       // Ignore CR character to make output always have UNIX newlines.
       continue;
-      }
+    }
 
-    else if((c >= 0x20 && c < 0x7F) || c == '\t' ||
-            (c == '\n' && newline_consume))
-      {
+    else if ((c >= 0x20 && c < 0x7F) || c == '\t' ||
+             (c == '\n' && newline_consume)) {
       // This is an ASCII character that may be part of a string.
       // Cast added to avoid compiler warning. Cast is ok because
       // c is guaranteed to fit in char by the above if...
       current_str += static_cast<char>(c);
-      }
-    else if(encoding == encoding_utf8)
-      {
+    } else if (encoding == encoding_utf8) {
       // Check for UTF-8 encoded string (up to 4 octets)
-      static const unsigned char utf8_check_table[3][2] =
-        {
-          {0xE0, 0xC0},
-          {0xF0, 0xE0},
-          {0xF8, 0xF0},
-        };
+      static const unsigned char utf8_check_table[3][2] = {
+        { 0xE0, 0xC0 }, { 0xF0, 0xE0 }, { 0xF8, 0xF0 },
+      };
 
       // how many octets are there?
       unsigned int num_utf8_bytes = 0;
-      for(unsigned int j=0; num_utf8_bytes == 0 && j<3; j++)
-        {
-        if((c & utf8_check_table[j][0]) == utf8_check_table[j][1])
-          num_utf8_bytes = j+2;
-        }
+      for (unsigned int j = 0; num_utf8_bytes == 0 && j < 3; j++) {
+        if ((c & utf8_check_table[j][0]) == utf8_check_table[j][1])
+          num_utf8_bytes = j + 2;
+      }
 
       // get subsequent octets and check that they are valid
-      for(unsigned int j=0; j<num_utf8_bytes; j++)
-        {
-        if(j != 0)
-          {
+      for (unsigned int j = 0; j < num_utf8_bytes; j++) {
+        if (j != 0) {
           c = fin.get();
-          if(!fin || (c & 0xC0) != 0x80)
-            {
+          if (!fin || (c & 0xC0) != 0x80) {
             fin.putback(static_cast<char>(c));
             break;
-            }
           }
-        current_str += static_cast<char>(c);
         }
+        current_str += static_cast<char>(c);
+      }
 
       // if this was an invalid utf8 sequence, discard the data, and put
       // back subsequent characters
-      if((current_str.length() != num_utf8_bytes))
-        {
-        for(unsigned int j=0; j<current_str.size()-1; j++)
-          {
+      if ((current_str.length() != num_utf8_bytes)) {
+        for (unsigned int j = 0; j < current_str.size() - 1; j++) {
           c = current_str[current_str.size() - 1 - j];
           fin.putback(static_cast<char>(c));
-          }
-        current_str = "";
         }
+        current_str = "";
       }
+    }
 
-
-    if(c == '\n' && !newline_consume)
-      {
+    if (c == '\n' && !newline_consume) {
       // The current line has been terminated.  Check if the current
       // string matches the requirements.  The length may now be as
       // low as zero since blank lines are allowed.
-      if(s.length() >= minlen &&
-         (!have_regex || regex.find(s.c_str())))
-        {
+      if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
         output_size += static_cast<int>(s.size()) + 1;
-        if(limit_output >= 0 && output_size >= limit_output)
-          {
+        if (limit_output >= 0 && output_size >= limit_output) {
           s = "";
           break;
-          }
-        strings.push_back(s);
         }
+        strings.push_back(s);
+      }
 
       // Reset the string to empty.
       s = "";
-      }
-    else if(current_str.empty())
-      {
+    } else if (current_str.empty()) {
       // A non-string character has been found.  Check if the current
       // string matches the requirements.  We require that the length
       // be at least one no matter what the user specified.
-      if(s.length() >= minlen && !s.empty() &&
-      (!have_regex || regex.find(s.c_str())))
-        {
+      if (s.length() >= minlen && !s.empty() &&
+          (!have_regex || regex.find(s.c_str()))) {
         output_size += static_cast<int>(s.size()) + 1;
-        if(limit_output >= 0 && output_size >= limit_output)
-          {
+        if (limit_output >= 0 && output_size >= limit_output) {
           s = "";
           break;
-          }
-        strings.push_back(s);
         }
+        strings.push_back(s);
+      }
 
       // Reset the string to empty.
       s = "";
-      }
-    else
-      {
+    } else {
       s += current_str;
-      }
-
+    }
 
-    if(maxlen > 0 && s.size() == maxlen)
-      {
+    if (maxlen > 0 && s.size() == maxlen) {
       // Terminate a string if the maximum length is reached.
-      if(s.length() >= minlen &&
-         (!have_regex || regex.find(s.c_str())))
-        {
+      if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
         output_size += static_cast<int>(s.size()) + 1;
-        if(limit_output >= 0 && output_size >= limit_output)
-          {
+        if (limit_output >= 0 && output_size >= limit_output) {
           s = "";
           break;
-          }
-        strings.push_back(s);
         }
-      s = "";
+        strings.push_back(s);
       }
+      s = "";
     }
+  }
 
   // If there is a non-empty current string we have hit the end of the
   // input file or the input size limit.  Check if the current string
   // matches the requirements.
-  if((!limit_count || strings.size() < limit_count) &&
-     !s.empty() && s.length() >= minlen &&
-     (!have_regex || regex.find(s.c_str())))
-    {
+  if ((!limit_count || strings.size() < limit_count) && !s.empty() &&
+      s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
     output_size += static_cast<int>(s.size()) + 1;
-    if(limit_output < 0 || output_size < limit_output)
-      {
+    if (limit_output < 0 || output_size < limit_output) {
       strings.push_back(s);
-      }
     }
+  }
 
   // Encode the result in a CMake list.
   const char* sep = "";
   std::string output;
-  for(std::vector<std::string>::const_iterator si = strings.begin();
-      si != strings.end(); ++si)
-    {
+  for (std::vector<std::string>::const_iterator si = strings.begin();
+       si != strings.end(); ++si) {
     // Separate the strings in the output to make it a list.
     output += sep;
     sep = ";";
@@ -867,24 +693,21 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
     // Store the string in the output, but escape semicolons to
     // make sure it is a list.
     std::string const& sr = *si;
-    for(unsigned int i=0; i < sr.size(); ++i)
-      {
-      if(sr[i] == ';')
-        {
+    for (unsigned int i = 0; i < sr.size(); ++i) {
+      if (sr[i] == ';') {
         output += '\\';
-        }
-      output += sr[i];
       }
+      output += sr[i];
     }
+  }
 
   // Save the output in a makefile variable.
   this->Makefile->AddDefinition(outVar, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
-  bool recurse)
+                                      bool recurse)
 {
   // File commands has at least one argument
   assert(args.size() > 1);
@@ -901,10 +724,8 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
   bool explicitFollowSymlinks = false;
   cmPolicies::PolicyStatus status =
     this->Makefile->GetPolicyStatus(cmPolicies::CMP0009);
-  if(recurse)
-    {
-    switch(status)
-      {
+  if (recurse) {
+    switch (status) {
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
       case cmPolicies::NEW:
@@ -914,160 +735,130 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
       case cmPolicies::WARN:
         g.RecurseThroughSymlinksOn();
         break;
-      }
     }
+  }
 
   std::string output = "";
   bool first = true;
-  for ( ; i != args.end(); ++i )
-    {
-    if( *i == "LIST_DIRECTORIES" )
-      {
+  for (; i != args.end(); ++i) {
+    if (*i == "LIST_DIRECTORIES") {
       ++i;
-      if(i != args.end())
-        {
-        if(cmSystemTools::IsOn(i->c_str()))
-          {
+      if (i != args.end()) {
+        if (cmSystemTools::IsOn(i->c_str())) {
           g.SetListDirs(true);
           g.SetRecurseListDirs(true);
-          }
-        else if(cmSystemTools::IsOff(i->c_str()))
-          {
+        } else if (cmSystemTools::IsOff(i->c_str())) {
           g.SetListDirs(false);
           g.SetRecurseListDirs(false);
-          }
-        else
-          {
+        } else {
           this->SetError("LIST_DIRECTORIES missing bool value.");
           return false;
-          }
         }
-      else
-        {
+      } else {
         this->SetError("LIST_DIRECTORIES missing bool value.");
         return false;
-        }
-      ++i;
       }
+      ++i;
+    }
 
-    if ( recurse && (*i == "FOLLOW_SYMLINKS") )
-      {
+    if (recurse && (*i == "FOLLOW_SYMLINKS")) {
       explicitFollowSymlinks = true;
       g.RecurseThroughSymlinksOn();
       ++i;
-      if ( i == args.end() )
-        {
+      if (i == args.end()) {
         this->SetError(
           "GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS");
         return false;
-        }
       }
+    }
 
-    if ( *i == "RELATIVE" )
-      {
+    if (*i == "RELATIVE") {
       ++i; // skip RELATIVE
-      if ( i == args.end() )
-        {
+      if (i == args.end()) {
         this->SetError("GLOB requires a directory after the RELATIVE tag");
         return false;
-        }
+      }
       g.SetRelative(i->c_str());
       ++i;
-      if(i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("GLOB requires a glob expression after the directory");
         return false;
-        }
       }
+    }
 
     cmsys::Glob::GlobMessages globMessages;
-    if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) )
-      {
+    if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
       std::string expr = this->Makefile->GetCurrentSourceDirectory();
       // Handle script mode
-      if (!expr.empty())
-        {
+      if (!expr.empty()) {
         expr += "/" + *i;
         g.FindFiles(expr, &globMessages);
-        }
-      else
-        {
+      } else {
         g.FindFiles(*i, &globMessages);
-        }
       }
-    else
-      {
+    } else {
       g.FindFiles(*i, &globMessages);
-      }
+    }
 
-    if(!globMessages.empty())
-      {
+    if (!globMessages.empty()) {
       bool shouldExit = false;
-      for(cmsys::Glob::GlobMessagesIterator it=globMessages.begin();
-        it != globMessages.end(); ++it)
-        {
-        if(it->type == cmsys::Glob::cyclicRecursion)
-          {
-          this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
-            "Cyclic recursion detected while globbing for '"
-            + *i + "':\n" + it->content);
-          }
-        else
-          {
-          this->Makefile->IssueMessage(cmake::FATAL_ERROR,
-            "Error has occured while globbing for '"
-            + *i + "' - " + it->content);
+      for (cmsys::Glob::GlobMessagesIterator it = globMessages.begin();
+           it != globMessages.end(); ++it) {
+        if (it->type == cmsys::Glob::cyclicRecursion) {
+          this->Makefile->IssueMessage(
+            cmake::AUTHOR_WARNING,
+            "Cyclic recursion detected while globbing for '" + *i + "':\n" +
+              it->content);
+        } else {
+          this->Makefile->IssueMessage(
+            cmake::FATAL_ERROR, "Error has occurred while globbing for '" +
+              *i + "' - " + it->content);
           shouldExit = true;
-          }
-        }
-      if(shouldExit)
-        {
-          return false;
         }
       }
+      if (shouldExit) {
+        return false;
+      }
+    }
 
     std::vector<std::string>::size_type cc;
     std::vector<std::string>& files = g.GetFiles();
-    for ( cc = 0; cc < files.size(); cc ++ )
-      {
-      if ( !first )
-        {
+    std::sort(files.begin(), files.end());
+    for (cc = 0; cc < files.size(); cc++) {
+      if (!first) {
         output += ";";
-        }
+      }
       output += files[cc];
       first = false;
-      }
     }
+  }
 
-  if(recurse && !explicitFollowSymlinks)
-    {
-    switch (status)
-      {
+  if (recurse && !explicitFollowSymlinks) {
+    switch (status) {
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
       case cmPolicies::NEW:
         // Correct behavior, yay!
         break;
       case cmPolicies::OLD:
-        // Probably not really the expected behavior, but the author explicitly
-        // asked for the old behavior... no warning.
+      // Probably not really the expected behavior, but the author explicitly
+      // asked for the old behavior... no warning.
       case cmPolicies::WARN:
         // Possibly unexpected old behavior *and* we actually traversed
         // symlinks without being explicitly asked to: warn the author.
-        if(g.GetFollowedSymlinkCount() != 0)
-          {
-          this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
+        if (g.GetFollowedSymlinkCount() != 0) {
+          this->Makefile->IssueMessage(
+            cmake::AUTHOR_WARNING,
             cmPolicies::GetPolicyWarning(cmPolicies::CMP0009));
-          }
+        }
         break;
-      }
     }
+  }
 
   this->Makefile->AddDefinition(variable, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleMakeDirectoryCommand(
   std::vector<std::string> const& args)
 {
@@ -1079,36 +870,31 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
   i++; // Get rid of subcommand
 
   std::string expr;
-  for ( ; i != args.end(); ++i )
-    {
+  for (; i != args.end(); ++i) {
     const std::string* cdir = &(*i);
-    if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) )
-      {
+    if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
       expr = this->Makefile->GetCurrentSourceDirectory();
       expr += "/" + *i;
       cdir = &expr;
-      }
-    if ( !this->Makefile->CanIWriteThisFile(cdir->c_str()) )
-      {
-      std::string e = "attempted to create a directory: " + *cdir
-        + " into a source directory.";
+    }
+    if (!this->Makefile->CanIWriteThisFile(cdir->c_str())) {
+      std::string e = "attempted to create a directory: " + *cdir +
+        " into a source directory.";
       this->SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
-      }
-    if ( !cmSystemTools::MakeDirectory(cdir->c_str()) )
-      {
+    }
+    if (!cmSystemTools::MakeDirectory(cdir->c_str())) {
       std::string error = "problem creating directory: " + *cdir;
       this->SetError(error);
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args)
+bool cmFileCommand::HandleDifferentCommand(
+  std::vector<std::string> const& args)
 {
   /*
     FILE(DIFFERENT <variable> FILES <lhs> <rhs>)
@@ -1118,79 +904,72 @@ cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args)
   const char* file_lhs = 0;
   const char* file_rhs = 0;
   const char* var = 0;
-  enum Doing { DoingNone, DoingVar, DoingFileLHS, DoingFileRHS };
+  enum Doing
+  {
+    DoingNone,
+    DoingVar,
+    DoingFileLHS,
+    DoingFileRHS
+  };
   Doing doing = DoingVar;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "FILES")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "FILES") {
       doing = DoingFileLHS;
-      }
-    else if(doing == DoingVar)
-      {
+    } else if (doing == DoingVar) {
       var = args[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingFileLHS)
-      {
+    } else if (doing == DoingFileLHS) {
       file_lhs = args[i].c_str();
       doing = DoingFileRHS;
-      }
-    else if(doing == DoingFileRHS)
-      {
+    } else if (doing == DoingFileRHS) {
       file_rhs = args[i].c_str();
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "DIFFERENT given unknown argument " << args[i];
       this->SetError(e.str());
       return false;
-      }
     }
-  if(!var)
-    {
+  }
+  if (!var) {
     this->SetError("DIFFERENT not given result variable name.");
     return false;
-    }
-  if(!file_lhs || !file_rhs)
-    {
+  }
+  if (!file_lhs || !file_rhs) {
     this->SetError("DIFFERENT not given FILES option with two file names.");
     return false;
-    }
+  }
 
   // Compare the files.
   const char* result =
-    cmSystemTools::FilesDiffer(file_lhs, file_rhs)? "1" : "0";
+    cmSystemTools::FilesDiffer(file_lhs, file_rhs) ? "1" : "0";
   this->Makefile->AddDefinition(var, result);
   return true;
 }
 
-//----------------------------------------------------------------------------
 // File installation helper class.
 struct cmFileCopier
 {
-  cmFileCopier(cmFileCommand* command, const char* name = "COPY"):
-    FileCommand(command),
-    Makefile(command->GetMakefile()),
-    Name(name),
-    Always(false),
-    MatchlessFiles(true),
-    FilePermissions(0),
-    DirPermissions(0),
-    CurrentMatchRule(0),
-    UseGivenPermissionsFile(false),
-    UseGivenPermissionsDir(false),
-    UseSourcePermissions(true),
-    Doing(DoingNone)
-    {
-    }
+  cmFileCopier(cmFileCommand* command, const char* name = "COPY")
+    : FileCommand(command)
+    , Makefile(command->GetMakefile())
+    , Name(name)
+    , Always(false)
+    , MatchlessFiles(true)
+    , FilePermissions(0)
+    , DirPermissions(0)
+    , CurrentMatchRule(0)
+    , UseGivenPermissionsFile(false)
+    , UseGivenPermissionsDir(false)
+    , UseSourcePermissions(true)
+    , Doing(DoingNone)
+  {
+  }
   virtual ~cmFileCopier() {}
 
   bool Run(std::vector<std::string> const& args);
-protected:
 
+protected:
   cmFileCommand* FileCommand;
   cmMakefile* Makefile;
   const char* Name;
@@ -1209,7 +988,11 @@ protected:
   {
     bool Exclude;
     mode_t Permissions;
-    MatchProperties(): Exclude(false), Permissions(0) {}
+    MatchProperties()
+      : Exclude(false)
+      , Permissions(0)
+    {
+    }
   };
   struct MatchRule;
   friend struct MatchRule;
@@ -1218,15 +1001,18 @@ protected:
     cmsys::RegularExpression Regex;
     MatchProperties Properties;
     std::string RegexString;
-    MatchRule(std::string const& regex):
-      Regex(regex.c_str()), RegexString(regex) {}
+    MatchRule(std::string const& regex)
+      : Regex(regex.c_str())
+      , RegexString(regex)
+    {
+    }
   };
   std::vector<MatchRule> MatchRules;
 
   // Get the properties from rules matching this input file.
   MatchProperties CollectMatchProperties(const char* file)
-    {
-    // Match rules are case-insensitive on some platforms.
+  {
+// Match rules are case-insensitive on some platforms.
 #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
     std::string lower = cmSystemTools::LowerCase(file);
     const char* file_to_match = lower.c_str();
@@ -1237,58 +1023,64 @@ protected:
     // Collect properties from all matching rules.
     bool matched = false;
     MatchProperties result;
-    for(std::vector<MatchRule>::iterator mr = this->MatchRules.begin();
-        mr != this->MatchRules.end(); ++mr)
-      {
-      if(mr->Regex.find(file_to_match))
-        {
+    for (std::vector<MatchRule>::iterator mr = this->MatchRules.begin();
+         mr != this->MatchRules.end(); ++mr) {
+      if (mr->Regex.find(file_to_match)) {
         matched = true;
         result.Exclude |= mr->Properties.Exclude;
         result.Permissions |= mr->Properties.Permissions;
-        }
       }
-    if(!matched && !this->MatchlessFiles)
-      {
+    }
+    if (!matched && !this->MatchlessFiles) {
       result.Exclude = !cmSystemTools::FileIsDirectory(file);
-      }
-    return result;
     }
+    return result;
+  }
 
   bool SetPermissions(const char* toFile, mode_t permissions)
-    {
-    if(permissions && !cmSystemTools::SetPermissions(toFile, permissions))
-      {
+  {
+    if (permissions && !cmSystemTools::SetPermissions(toFile, permissions)) {
       std::ostringstream e;
       e << this->Name << " cannot set permissions on \"" << toFile << "\"";
       this->FileCommand->SetError(e.str());
       return false;
-      }
-    return true;
     }
+    return true;
+  }
 
   // Translate an argument to a permissions bit.
   bool CheckPermissions(std::string const& arg, mode_t& permissions)
-    {
-    if(arg == "OWNER_READ")         { permissions |= mode_owner_read; }
-    else if(arg == "OWNER_WRITE")   { permissions |= mode_owner_write; }
-    else if(arg == "OWNER_EXECUTE") { permissions |= mode_owner_execute; }
-    else if(arg == "GROUP_READ")    { permissions |= mode_group_read; }
-    else if(arg == "GROUP_WRITE")   { permissions |= mode_group_write; }
-    else if(arg == "GROUP_EXECUTE") { permissions |= mode_group_execute; }
-    else if(arg == "WORLD_READ")    { permissions |= mode_world_read; }
-    else if(arg == "WORLD_WRITE")   { permissions |= mode_world_write; }
-    else if(arg == "WORLD_EXECUTE") { permissions |= mode_world_execute; }
-    else if(arg == "SETUID")        { permissions |= mode_setuid; }
-    else if(arg == "SETGID")        { permissions |= mode_setgid; }
-    else
-      {
+  {
+    if (arg == "OWNER_READ") {
+      permissions |= mode_owner_read;
+    } else if (arg == "OWNER_WRITE") {
+      permissions |= mode_owner_write;
+    } else if (arg == "OWNER_EXECUTE") {
+      permissions |= mode_owner_execute;
+    } else if (arg == "GROUP_READ") {
+      permissions |= mode_group_read;
+    } else if (arg == "GROUP_WRITE") {
+      permissions |= mode_group_write;
+    } else if (arg == "GROUP_EXECUTE") {
+      permissions |= mode_group_execute;
+    } else if (arg == "WORLD_READ") {
+      permissions |= mode_world_read;
+    } else if (arg == "WORLD_WRITE") {
+      permissions |= mode_world_write;
+    } else if (arg == "WORLD_EXECUTE") {
+      permissions |= mode_world_execute;
+    } else if (arg == "SETUID") {
+      permissions |= mode_setuid;
+    } else if (arg == "SETGID") {
+      permissions |= mode_setgid;
+    } else {
       std::ostringstream e;
       e << this->Name << " given invalid permission \"" << arg << "\".";
       this->FileCommand->SetError(e.str());
       return false;
-      }
-    return true;
     }
+    return true;
+  }
 
   bool InstallSymlink(const char* fromFile, const char* toFile);
   bool InstallFile(const char* fromFile, const char* toFile,
@@ -1297,7 +1089,9 @@ protected:
                         MatchProperties const& match_properties);
   virtual bool Install(const char* fromFile, const char* toFile);
   virtual std::string const& ToName(std::string const& fromName)
-    { return fromName; }
+  {
+    return fromName;
+  }
 
   enum Type
   {
@@ -1307,13 +1101,13 @@ protected:
   };
   virtual void ReportCopy(const char*, Type, bool) {}
   virtual bool ReportMissing(const char* fromFile)
-    {
+  {
     // The input file does not exist and installation is not optional.
     std::ostringstream e;
     e << this->Name << " cannot find \"" << fromFile << "\".";
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
 
   MatchRule* CurrentMatchRule;
   bool UseGivenPermissionsFile;
@@ -1341,30 +1135,30 @@ protected:
   virtual bool CheckValue(std::string const& arg);
 
   void NotBeforeMatch(std::string const& arg)
-    {
+  {
     std::ostringstream e;
     e << "option " << arg << " may not appear before PATTERN or REGEX.";
     this->FileCommand->SetError(e.str());
     this->Doing = DoingError;
-    }
+  }
   void NotAfterMatch(std::string const& arg)
-    {
+  {
     std::ostringstream e;
     e << "option " << arg << " may not appear after PATTERN or REGEX.";
     this->FileCommand->SetError(e.str());
     this->Doing = DoingError;
-    }
+  }
   virtual void DefaultFilePermissions()
-    {
+  {
     // Use read/write permissions.
     this->FilePermissions = 0;
     this->FilePermissions |= mode_owner_read;
     this->FilePermissions |= mode_owner_write;
     this->FilePermissions |= mode_group_read;
     this->FilePermissions |= mode_world_read;
-    }
+  }
   virtual void DefaultDirectoryPermissions()
-    {
+  {
     // Use read/write/executable permissions.
     this->DirPermissions = 0;
     this->DirPermissions |= mode_owner_read;
@@ -1374,200 +1168,137 @@ protected:
     this->DirPermissions |= mode_group_execute;
     this->DirPermissions |= mode_world_read;
     this->DirPermissions |= mode_world_execute;
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::Parse(std::vector<std::string> const& args)
 {
   this->Doing = DoingFiles;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
+  for (unsigned int i = 1; i < args.size(); ++i) {
     // Check this argument.
-    if(!this->CheckKeyword(args[i]) &&
-       !this->CheckValue(args[i]))
-      {
+    if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) {
       std::ostringstream e;
       e << "called with unknown argument \"" << args[i] << "\".";
       this->FileCommand->SetError(e.str());
       return false;
-      }
+    }
 
     // Quit if an argument is invalid.
-    if(this->Doing == DoingError)
-      {
+    if (this->Doing == DoingError) {
       return false;
-      }
     }
+  }
 
   // Require a destination.
-  if(this->Destination.empty())
-    {
+  if (this->Destination.empty()) {
     std::ostringstream e;
     e << this->Name << " given no DESTINATION";
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
 
   // If file permissions were not specified set default permissions.
-  if(!this->UseGivenPermissionsFile && !this->UseSourcePermissions)
-    {
+  if (!this->UseGivenPermissionsFile && !this->UseSourcePermissions) {
     this->DefaultFilePermissions();
-    }
+  }
 
   // If directory permissions were not specified set default permissions.
-  if(!this->UseGivenPermissionsDir && !this->UseSourcePermissions)
-    {
+  if (!this->UseGivenPermissionsDir && !this->UseSourcePermissions) {
     this->DefaultDirectoryPermissions();
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::CheckKeyword(std::string const& arg)
 {
-  if(arg == "DESTINATION")
-    {
-    if(this->CurrentMatchRule)
-      {
+  if (arg == "DESTINATION") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingDestination;
-      }
     }
-  else if(arg == "PATTERN")
-    {
+  } else if (arg == "PATTERN") {
     this->Doing = DoingPattern;
-    }
-  else if(arg == "REGEX")
-    {
+  } else if (arg == "REGEX") {
     this->Doing = DoingRegex;
-    }
-  else if(arg == "EXCLUDE")
-    {
+  } else if (arg == "EXCLUDE") {
     // Add this property to the current match rule.
-    if(this->CurrentMatchRule)
-      {
+    if (this->CurrentMatchRule) {
       this->CurrentMatchRule->Properties.Exclude = true;
       this->Doing = DoingNone;
-      }
-    else
-      {
+    } else {
       this->NotBeforeMatch(arg);
-      }
     }
-  else if(arg == "PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->Doing = DoingPermissionsMatch;
-      }
-    else
-      {
+    } else {
       this->NotBeforeMatch(arg);
-      }
     }
-  else if(arg == "FILE_PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "FILE_PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingPermissionsFile;
       this->UseGivenPermissionsFile = true;
-      }
     }
-  else if(arg == "DIRECTORY_PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "DIRECTORY_PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingPermissionsDir;
       this->UseGivenPermissionsDir = true;
-      }
     }
-  else if(arg == "USE_SOURCE_PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "USE_SOURCE_PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->UseSourcePermissions = true;
-      }
     }
-  else if(arg == "NO_SOURCE_PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "NO_SOURCE_PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->UseSourcePermissions = false;
-      }
     }
-  else if(arg == "FILES_MATCHING")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "FILES_MATCHING") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->MatchlessFiles = false;
-      }
     }
-  else
-    {
+  } else {
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::CheckValue(std::string const& arg)
 {
-  switch(this->Doing)
-    {
+  switch (this->Doing) {
     case DoingFiles:
-      if(arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str()))
-        {
+      if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) {
         this->Files.push_back(arg);
-        }
-      else
-        {
+      } else {
         std::string file = this->Makefile->GetCurrentSourceDirectory();
         file += "/" + arg;
         this->Files.push_back(file);
-        }
+      }
       break;
     case DoingDestination:
-      if(arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str()))
-        {
+      if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) {
         this->Destination = arg;
-        }
-      else
-        {
+      } else {
         this->Destination = this->Makefile->GetCurrentBinaryDirectory();
         this->Destination += "/" + arg;
-        }
+      }
       this->Doing = DoingNone;
       break;
-    case DoingPattern:
-      {
+    case DoingPattern: {
       // Convert the pattern to a regular expression.  Require a
       // leading slash and trailing end-of-string in the matched
       // string to make sure the pattern matches only whole file
@@ -1576,255 +1307,214 @@ bool cmFileCopier::CheckValue(std::string const& arg)
       regex += cmsys::Glob::PatternToRegex(arg, false);
       regex += "$";
       this->MatchRules.push_back(MatchRule(regex));
-      this->CurrentMatchRule = &*(this->MatchRules.end()-1);
-      if(this->CurrentMatchRule->Regex.is_valid())
-        {
+      this->CurrentMatchRule = &*(this->MatchRules.end() - 1);
+      if (this->CurrentMatchRule->Regex.is_valid()) {
         this->Doing = DoingNone;
-        }
-      else
-        {
+      } else {
         std::ostringstream e;
         e << "could not compile PATTERN \"" << arg << "\".";
         this->FileCommand->SetError(e.str());
         this->Doing = DoingError;
-        }
       }
-      break;
+    } break;
     case DoingRegex:
       this->MatchRules.push_back(MatchRule(arg));
-      this->CurrentMatchRule = &*(this->MatchRules.end()-1);
-      if(this->CurrentMatchRule->Regex.is_valid())
-        {
+      this->CurrentMatchRule = &*(this->MatchRules.end() - 1);
+      if (this->CurrentMatchRule->Regex.is_valid()) {
         this->Doing = DoingNone;
-        }
-      else
-        {
+      } else {
         std::ostringstream e;
         e << "could not compile REGEX \"" << arg << "\".";
         this->FileCommand->SetError(e.str());
         this->Doing = DoingError;
-        }
+      }
       break;
     case DoingPermissionsFile:
-      if(!this->CheckPermissions(arg, this->FilePermissions))
-        {
+      if (!this->CheckPermissions(arg, this->FilePermissions)) {
         this->Doing = DoingError;
-        }
+      }
       break;
     case DoingPermissionsDir:
-      if(!this->CheckPermissions(arg, this->DirPermissions))
-        {
+      if (!this->CheckPermissions(arg, this->DirPermissions)) {
         this->Doing = DoingError;
-        }
+      }
       break;
     case DoingPermissionsMatch:
-      if(!this->CheckPermissions(
-           arg, this->CurrentMatchRule->Properties.Permissions))
-        {
+      if (!this->CheckPermissions(
+            arg, this->CurrentMatchRule->Properties.Permissions)) {
         this->Doing = DoingError;
-        }
+      }
       break;
     default:
       return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::Run(std::vector<std::string> const& args)
 {
-  if(!this->Parse(args))
-    {
+  if (!this->Parse(args)) {
     return false;
-    }
+  }
 
   std::vector<std::string> const& files = this->Files;
-  for(std::vector<std::string>::size_type i = 0; i < files.size(); ++i)
-    {
+  for (std::vector<std::string>::size_type i = 0; i < files.size(); ++i) {
     // Split the input file into its directory and name components.
     std::vector<std::string> fromPathComponents;
     cmSystemTools::SplitPath(files[i], fromPathComponents);
-    std::string fromName = *(fromPathComponents.end()-1);
-    std::string fromDir = cmSystemTools::JoinPath(fromPathComponents.begin(),
-                                                  fromPathComponents.end()-1);
+    std::string fromName = *(fromPathComponents.end() - 1);
+    std::string fromDir = cmSystemTools::JoinPath(
+      fromPathComponents.begin(), fromPathComponents.end() - 1);
 
     // Compute the full path to the destination file.
     std::string toFile = this->Destination;
     std::string const& toName = this->ToName(fromName);
-    if(!toName.empty())
-      {
+    if (!toName.empty()) {
       toFile += "/";
       toFile += toName;
-      }
+    }
 
     // Construct the full path to the source file.  The file name may
     // have been changed above.
     std::string fromFile = fromDir;
-    if(!fromName.empty())
-      {
+    if (!fromName.empty()) {
       fromFile += "/";
       fromFile += fromName;
-      }
+    }
 
-    if(!this->Install(fromFile.c_str(), toFile.c_str()))
-      {
+    if (!this->Install(fromFile.c_str(), toFile.c_str())) {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::Install(const char* fromFile, const char* toFile)
 {
-  if(!*fromFile)
-    {
+  if (!*fromFile) {
     std::ostringstream e;
     e << "INSTALL encountered an empty string input file name.";
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
 
   // Collect any properties matching this file name.
   MatchProperties match_properties = this->CollectMatchProperties(fromFile);
 
   // Skip the file if it is excluded.
-  if(match_properties.Exclude)
-    {
+  if (match_properties.Exclude) {
     return true;
-    }
+  }
 
-  if(cmSystemTools::SameFile(fromFile, toFile))
-    {
+  if (cmSystemTools::SameFile(fromFile, toFile)) {
     return true;
-    }
-  else if(cmSystemTools::FileIsSymlink(fromFile))
-    {
+  } else if (cmSystemTools::FileIsSymlink(fromFile)) {
     return this->InstallSymlink(fromFile, toFile);
-    }
-  else if(cmSystemTools::FileIsDirectory(fromFile))
-    {
+  } else if (cmSystemTools::FileIsDirectory(fromFile)) {
     return this->InstallDirectory(fromFile, toFile, match_properties);
-    }
-  else if(cmSystemTools::FileExists(fromFile))
-    {
+  } else if (cmSystemTools::FileExists(fromFile)) {
     return this->InstallFile(fromFile, toFile, match_properties);
-    }
+  }
   return this->ReportMissing(fromFile);
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
 {
   // Read the original symlink.
   std::string symlinkTarget;
-  if(!cmSystemTools::ReadSymlink(fromFile, symlinkTarget))
-    {
+  if (!cmSystemTools::ReadSymlink(fromFile, symlinkTarget)) {
     std::ostringstream e;
     e << this->Name << " cannot read symlink \"" << fromFile
       << "\" to duplicate at \"" << toFile << "\".";
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
 
   // Compare the symlink value to that at the destination if not
   // always installing.
   bool copy = true;
-  if(!this->Always)
-    {
+  if (!this->Always) {
     std::string oldSymlinkTarget;
-    if(cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget))
-      {
-      if(symlinkTarget == oldSymlinkTarget)
-        {
+    if (cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget)) {
+      if (symlinkTarget == oldSymlinkTarget) {
         copy = false;
-        }
       }
     }
+  }
 
   // Inform the user about this file installation.
   this->ReportCopy(toFile, TypeLink, copy);
 
-  if(copy)
-    {
+  if (copy) {
     // Remove the destination file so we can always create the symlink.
     cmSystemTools::RemoveFile(toFile);
 
     // Create the symlink.
-    if(!cmSystemTools::CreateSymlink(symlinkTarget, toFile))
-      {
+    if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
       std::ostringstream e;
-      e << this->Name <<  " cannot duplicate symlink \"" << fromFile
+      e << this->Name << " cannot duplicate symlink \"" << fromFile
         << "\" at \"" << toFile << "\".";
       this->FileCommand->SetError(e.str());
       return false;
-      }
     }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
                                MatchProperties const& match_properties)
 {
   // Determine whether we will copy the file.
   bool copy = true;
-  if(!this->Always)
-    {
+  if (!this->Always) {
     // If both files exist with the same time do not copy.
-    if(!this->FileTimes.FileTimesDiffer(fromFile, toFile))
-      {
+    if (!this->FileTimes.FileTimesDiffer(fromFile, toFile)) {
       copy = false;
-      }
     }
+  }
 
   // Inform the user about this file installation.
   this->ReportCopy(toFile, TypeFile, copy);
 
   // Copy the file.
-  if(copy && !cmSystemTools::CopyAFile(fromFile, toFile, true))
-    {
+  if (copy && !cmSystemTools::CopyAFile(fromFile, toFile, true)) {
     std::ostringstream e;
-    e << this->Name << " cannot copy file \"" << fromFile
-      << "\" to \"" << toFile << "\".";
+    e << this->Name << " cannot copy file \"" << fromFile << "\" to \""
+      << toFile << "\".";
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
 
   // Set the file modification time of the destination file.
-  if(copy && !this->Always)
-    {
+  if (copy && !this->Always) {
     // Add write permission so we can set the file time.
     // Permissions are set unconditionally below anyway.
     mode_t perm = 0;
-    if(cmSystemTools::GetPermissions(toFile, perm))
-      {
+    if (cmSystemTools::GetPermissions(toFile, perm)) {
       cmSystemTools::SetPermissions(toFile, perm | mode_owner_write);
-      }
-    if (!cmSystemTools::CopyFileTime(fromFile, toFile))
-      {
+    }
+    if (!cmSystemTools::CopyFileTime(fromFile, toFile)) {
       std::ostringstream e;
-      e << this->Name << " cannot set modification time on \""
-        << toFile << "\"";
+      e << this->Name << " cannot set modification time on \"" << toFile
+        << "\"";
       this->FileCommand->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Set permissions of the destination file.
-  mode_t permissions = (match_properties.Permissions?
-                        match_properties.Permissions : this->FilePermissions);
-  if(!permissions)
-    {
+  mode_t permissions =
+    (match_properties.Permissions ? match_properties.Permissions
+                                  : this->FilePermissions);
+  if (!permissions) {
     // No permissions were explicitly provided but the user requested
     // that the source file permissions be used.
     cmSystemTools::GetPermissions(fromFile, permissions);
-    }
+  }
   return this->SetPermissions(toFile, permissions);
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCopier::InstallDirectory(const char* source,
                                     const char* destination,
                                     MatchProperties const& match_properties)
@@ -1834,24 +1524,23 @@ bool cmFileCopier::InstallDirectory(const char* source,
                    !cmSystemTools::FileIsDirectory(destination));
 
   // Make sure the destination directory exists.
-  if(!cmSystemTools::MakeDirectory(destination))
-    {
+  if (!cmSystemTools::MakeDirectory(destination)) {
     std::ostringstream e;
-    e << this->Name << " cannot make directory \"" << destination << "\": "
-      << cmSystemTools::GetLastSystemError();
+    e << this->Name << " cannot make directory \"" << destination
+      << "\": " << cmSystemTools::GetLastSystemError();
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
 
   // Compute the requested permissions for the destination directory.
-  mode_t permissions = (match_properties.Permissions?
-                        match_properties.Permissions : this->DirPermissions);
-  if(!permissions)
-    {
+  mode_t permissions =
+    (match_properties.Permissions ? match_properties.Permissions
+                                  : this->DirPermissions);
+  if (!permissions) {
     // No permissions were explicitly provided but the user requested
     // that the source directory permissions be used.
     cmSystemTools::GetPermissions(source, permissions);
-    }
+  }
 
   // Compute the set of permissions required on this directory to
   // recursively install files and subdirectories safely.
@@ -1863,70 +1552,60 @@ bool cmFileCopier::InstallDirectory(const char* source,
   // permissions temporarily during file installation.
   mode_t permissions_before = 0;
   mode_t permissions_after = 0;
-  if((permissions & required_permissions) == required_permissions)
-    {
+  if ((permissions & required_permissions) == required_permissions) {
     permissions_before = permissions;
-    }
-  else
-    {
+  } else {
     permissions_before = permissions | required_permissions;
     permissions_after = permissions;
-    }
+  }
 
   // Set the required permissions of the destination directory.
-  if(!this->SetPermissions(destination, permissions_before))
-    {
+  if (!this->SetPermissions(destination, permissions_before)) {
     return false;
-    }
+  }
 
   // Load the directory contents to traverse it recursively.
   cmsys::Directory dir;
-  if(source && *source)
-    {
+  if (source && *source) {
     dir.Load(source);
-    }
+  }
   unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
-  for(unsigned long fileNum = 0; fileNum < numFiles; ++fileNum)
-    {
-    if(!(strcmp(dir.GetFile(fileNum), ".") == 0 ||
-         strcmp(dir.GetFile(fileNum), "..") == 0))
-      {
+  for (unsigned long fileNum = 0; fileNum < numFiles; ++fileNum) {
+    if (!(strcmp(dir.GetFile(fileNum), ".") == 0 ||
+          strcmp(dir.GetFile(fileNum), "..") == 0)) {
       std::string fromPath = source;
       fromPath += "/";
       fromPath += dir.GetFile(fileNum);
       std::string toPath = destination;
       toPath += "/";
       toPath += dir.GetFile(fileNum);
-      if(!this->Install(fromPath.c_str(), toPath.c_str()))
-        {
+      if (!this->Install(fromPath.c_str(), toPath.c_str())) {
         return false;
-        }
       }
     }
+  }
 
   // Set the requested permissions of the destination directory.
   return this->SetPermissions(destination, permissions_after);
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleCopyCommand(std::vector<std::string> const& args)
 {
   cmFileCopier copier(this);
   return copier.Run(args);
 }
 
-//----------------------------------------------------------------------------
-struct cmFileInstaller: public cmFileCopier
+struct cmFileInstaller : public cmFileCopier
 {
-  cmFileInstaller(cmFileCommand* command):
-    cmFileCopier(command, "INSTALL"),
-    InstallType(cmInstallType_FILES),
-    Optional(false),
-    MessageAlways(false),
-    MessageLazy(false),
-    MessageNever(false),
-    DestDirLength(0)
-    {
+  cmFileInstaller(cmFileCommand* command)
+    : cmFileCopier(command, "INSTALL")
+    , InstallType(cmInstallType_FILES)
+    , Optional(false)
+    , MessageAlways(false)
+    , MessageLazy(false)
+    , MessageNever(false)
+    , DestDirLength(0)
+  {
     // Installation does not use source permissions by default.
     this->UseSourcePermissions = false;
     // Check whether to copy files always or only if they have changed.
@@ -1935,13 +1614,13 @@ struct cmFileInstaller: public cmFileCopier
     // Get the current manifest.
     this->Manifest =
       this->Makefile->GetSafeDefinition("CMAKE_INSTALL_MANIFEST_FILES");
-    }
+  }
   ~cmFileInstaller()
-    {
+  {
     // Save the updated install manifest.
     this->Makefile->AddDefinition("CMAKE_INSTALL_MANIFEST_FILES",
                                   this->Manifest.c_str());
-    }
+  }
 
 protected:
   cmInstallType InstallType;
@@ -1954,45 +1633,42 @@ protected:
 
   std::string Manifest;
   void ManifestAppend(std::string const& file)
-    {
-    if (!this->Manifest.empty())
-      {
+  {
+    if (!this->Manifest.empty()) {
       this->Manifest += ";";
-      }
-    this->Manifest += file.substr(this->DestDirLength);
     }
+    this->Manifest += file.substr(this->DestDirLength);
+  }
 
   virtual std::string const& ToName(std::string const& fromName)
-    { return this->Rename.empty()? fromName : this->Rename; }
+  {
+    return this->Rename.empty() ? fromName : this->Rename;
+  }
 
   virtual void ReportCopy(const char* toFile, Type type, bool copy)
-    {
-    if(!this->MessageNever && (copy || !this->MessageLazy))
-      {
-      std::string message = (copy? "Installing: " : "Up-to-date: ");
+  {
+    if (!this->MessageNever && (copy || !this->MessageLazy)) {
+      std::string message = (copy ? "Installing: " : "Up-to-date: ");
       message += toFile;
       this->Makefile->DisplayStatus(message.c_str(), -1);
-      }
-    if(type != TypeDir)
-      {
+    }
+    if (type != TypeDir) {
       // Add the file to the manifest.
       this->ManifestAppend(toFile);
-      }
     }
+  }
   virtual bool ReportMissing(const char* fromFile)
-    {
-    return (this->Optional ||
-            this->cmFileCopier::ReportMissing(fromFile));
-    }
+  {
+    return (this->Optional || this->cmFileCopier::ReportMissing(fromFile));
+  }
   virtual bool Install(const char* fromFile, const char* toFile)
-    {
+  {
     // Support installing from empty source to make a directory.
-    if(this->InstallType == cmInstallType_DIRECTORY && !*fromFile)
-      {
+    if (this->InstallType == cmInstallType_DIRECTORY && !*fromFile) {
       return this->InstallDirectory(fromFile, toFile, MatchProperties());
-      }
-    return this->cmFileCopier::Install(fromFile, toFile);
     }
+    return this->cmFileCopier::Install(fromFile, toFile);
+  }
 
   virtual bool Parse(std::vector<std::string> const& args);
   enum
@@ -2004,308 +1680,220 @@ protected:
   virtual bool CheckKeyword(std::string const& arg);
   virtual bool CheckValue(std::string const& arg);
   virtual void DefaultFilePermissions()
-    {
+  {
     this->cmFileCopier::DefaultFilePermissions();
     // Add execute permissions based on the target type.
-    switch(this->InstallType)
-      {
+    switch (this->InstallType) {
       case cmInstallType_SHARED_LIBRARY:
       case cmInstallType_MODULE_LIBRARY:
-        if(this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE"))
-          {
+        if (this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE")) {
           break;
-          }
+        }
       case cmInstallType_EXECUTABLE:
       case cmInstallType_PROGRAMS:
         this->FilePermissions |= mode_owner_execute;
         this->FilePermissions |= mode_group_execute;
         this->FilePermissions |= mode_world_execute;
         break;
-      default: break;
-      }
+      default:
+        break;
     }
+  }
   bool GetTargetTypeFromString(const std::string& stype);
   bool HandleInstallDestination();
 };
 
-//----------------------------------------------------------------------------
 bool cmFileInstaller::Parse(std::vector<std::string> const& args)
 {
-  if(!this->cmFileCopier::Parse(args))
-    {
+  if (!this->cmFileCopier::Parse(args)) {
     return false;
-    }
+  }
 
-  if(!this->Rename.empty())
-    {
-    if(this->InstallType != cmInstallType_FILES &&
-       this->InstallType != cmInstallType_PROGRAMS)
-      {
+  if (!this->Rename.empty()) {
+    if (this->InstallType != cmInstallType_FILES &&
+        this->InstallType != cmInstallType_PROGRAMS) {
       this->FileCommand->SetError("INSTALL option RENAME may be used "
                                   "only with FILES or PROGRAMS.");
       return false;
-      }
-    if(this->Files.size() > 1)
-      {
+    }
+    if (this->Files.size() > 1) {
       this->FileCommand->SetError("INSTALL option RENAME may be used "
                                   "only with one file.");
       return false;
-      }
     }
+  }
 
-  if(!this->HandleInstallDestination())
-    {
+  if (!this->HandleInstallDestination()) {
     return false;
-    }
+  }
 
-  if(((this->MessageAlways?1:0) +
-      (this->MessageLazy?1:0) +
-      (this->MessageNever?1:0)) > 1)
-    {
+  if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) +
+       (this->MessageNever ? 1 : 0)) > 1) {
     this->FileCommand->SetError("INSTALL options MESSAGE_ALWAYS, "
                                 "MESSAGE_LAZY, and MESSAGE_NEVER "
                                 "are mutually exclusive.");
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileInstaller::CheckKeyword(std::string const& arg)
 {
-  if(arg == "TYPE")
-    {
-    if(this->CurrentMatchRule)
-      {
+  if (arg == "TYPE") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingType;
-      }
     }
-  else if(arg == "FILES")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "FILES") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingFiles;
-      }
     }
-  else if(arg == "RENAME")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "RENAME") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingRename;
-      }
     }
-  else if(arg == "OPTIONAL")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "OPTIONAL") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->Optional = true;
-      }
     }
-  else if(arg == "MESSAGE_ALWAYS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "MESSAGE_ALWAYS") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->MessageAlways = true;
-      }
     }
-  else if(arg == "MESSAGE_LAZY")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "MESSAGE_LAZY") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->MessageLazy = true;
-      }
     }
-  else if(arg == "MESSAGE_NEVER")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "MESSAGE_NEVER") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       this->Doing = DoingNone;
       this->MessageNever = true;
-      }
     }
-  else if(arg == "PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->Doing = DoingPermissionsMatch;
-      }
-    else
-      {
+    } else {
       // file(INSTALL) aliases PERMISSIONS to FILE_PERMISSIONS
       this->Doing = DoingPermissionsFile;
       this->UseGivenPermissionsFile = true;
-      }
     }
-  else if(arg == "DIR_PERMISSIONS")
-    {
-    if(this->CurrentMatchRule)
-      {
+  } else if (arg == "DIR_PERMISSIONS") {
+    if (this->CurrentMatchRule) {
       this->NotAfterMatch(arg);
-      }
-    else
-      {
+    } else {
       // file(INSTALL) aliases DIR_PERMISSIONS to DIRECTORY_PERMISSIONS
       this->Doing = DoingPermissionsDir;
       this->UseGivenPermissionsDir = true;
-      }
     }
-  else if(arg == "COMPONENTS" || arg == "CONFIGURATIONS" ||
-          arg == "PROPERTIES")
-    {
+  } else if (arg == "COMPONENTS" || arg == "CONFIGURATIONS" ||
+             arg == "PROPERTIES") {
     std::ostringstream e;
     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());
     this->Doing = DoingError;
-    }
-  else
-    {
+  } else {
     return this->cmFileCopier::CheckKeyword(arg);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileInstaller::CheckValue(std::string const& arg)
 {
-  switch(this->Doing)
-    {
+  switch (this->Doing) {
     case DoingType:
-      if(!this->GetTargetTypeFromString(arg))
-        {
+      if (!this->GetTargetTypeFromString(arg)) {
         this->Doing = DoingError;
-        }
+      }
       break;
     case DoingRename:
       this->Rename = arg;
       break;
     default:
       return this->cmFileCopier::CheckValue(arg);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmFileInstaller
-::GetTargetTypeFromString(const std::string& stype)
+bool cmFileInstaller::GetTargetTypeFromString(const std::string& stype)
 {
-  if ( stype == "EXECUTABLE" )
-    {
+  if (stype == "EXECUTABLE") {
     this->InstallType = cmInstallType_EXECUTABLE;
-    }
-  else if ( stype == "FILE" )
-    {
+  } else if (stype == "FILE") {
     this->InstallType = cmInstallType_FILES;
-    }
-  else if ( stype == "PROGRAM" )
-    {
+  } else if (stype == "PROGRAM") {
     this->InstallType = cmInstallType_PROGRAMS;
-    }
-  else if ( stype == "STATIC_LIBRARY" )
-    {
+  } else if (stype == "STATIC_LIBRARY") {
     this->InstallType = cmInstallType_STATIC_LIBRARY;
-    }
-  else if ( stype == "SHARED_LIBRARY" )
-    {
+  } else if (stype == "SHARED_LIBRARY") {
     this->InstallType = cmInstallType_SHARED_LIBRARY;
-    }
-  else if ( stype == "MODULE" )
-    {
+  } else if (stype == "MODULE") {
     this->InstallType = cmInstallType_MODULE_LIBRARY;
-    }
-  else if ( stype == "DIRECTORY" )
-    {
+  } else if (stype == "DIRECTORY") {
     this->InstallType = cmInstallType_DIRECTORY;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << "Option TYPE given unknown value \"" << stype << "\".";
     this->FileCommand->SetError(e.str());
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileInstaller::HandleInstallDestination()
 {
   std::string& destination = this->Destination;
 
   // allow for / to be a valid destination
-  if ( destination.size() < 2 && destination != "/" )
-    {
+  if (destination.size() < 2 && destination != "/") {
     this->FileCommand->SetError("called with inappropriate arguments. "
-        "No DESTINATION provided or .");
+                                "No DESTINATION provided or .");
     return false;
-    }
+  }
 
   const char* destdir = cmSystemTools::GetEnv("DESTDIR");
-  if ( destdir && *destdir )
-    {
+  if (destdir && *destdir) {
     std::string sdestdir = destdir;
     cmSystemTools::ConvertToUnixSlashes(sdestdir);
     char ch1 = destination[0];
     char ch2 = destination[1];
     char ch3 = 0;
-    if ( destination.size() > 2 )
-      {
+    if (destination.size() > 2) {
       ch3 = destination[2];
-      }
+    }
     int skip = 0;
-    if ( ch1 != '/' )
-      {
+    if (ch1 != '/') {
       int relative = 0;
       if (((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z')) &&
-             ch2 == ':' )
-        {
+          ch2 == ':') {
         // Assume windows
         // let's do some destdir magic:
         skip = 2;
-        if ( ch3 != '/' )
-          {
+        if (ch3 != '/') {
           relative = 1;
-          }
         }
-      else
-        {
+      } else {
         relative = 1;
-        }
-      if ( relative )
-        {
+      }
+      if (relative) {
         // This is relative path on unix or windows. Since we are doing
         // destdir, this case does not make sense.
         this->FileCommand->SetError(
@@ -2313,371 +1901,321 @@ bool cmFileInstaller::HandleInstallDestination()
           "does not make sense when using DESTDIR. Specify "
           "absolute path or remove DESTDIR environment variable.");
         return false;
-        }
       }
-    else
-      {
-      if ( ch2 == '/' )
-        {
+    } else {
+      if (ch2 == '/') {
         // looks like a network path.
-        std::string message = "called with network path DESTINATION. This "
+        std::string message =
+          "called with network path DESTINATION. This "
           "does not make sense when using DESTDIR. Specify local "
           "absolute path or remove DESTDIR environment variable."
           "\nDESTINATION=\n";
         message += destination;
         this->FileCommand->SetError(message);
         return false;
-        }
       }
+    }
     destination = sdestdir + (destination.c_str() + skip);
     this->DestDirLength = int(sdestdir.size());
-    }
+  }
 
-  if(this->InstallType != cmInstallType_DIRECTORY)
-    {
-    if ( !cmSystemTools::FileExists(destination.c_str()) )
-      {
-      if ( !cmSystemTools::MakeDirectory(destination.c_str()) )
-        {
+  if (this->InstallType != cmInstallType_DIRECTORY) {
+    if (!cmSystemTools::FileExists(destination.c_str())) {
+      if (!cmSystemTools::MakeDirectory(destination.c_str())) {
         std::string errstring = "cannot create directory: " + destination +
           ". Maybe need administrative privileges.";
         this->FileCommand->SetError(errstring);
         return false;
-        }
       }
-    if ( !cmSystemTools::FileIsDirectory(destination) )
-      {
-      std::string errstring = "INSTALL destination: " + destination +
-        " is not a directory.";
+    }
+    if (!cmSystemTools::FileIsDirectory(destination)) {
+      std::string errstring =
+        "INSTALL destination: " + destination + " is not a directory.";
       this->FileCommand->SetError(errstring);
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
+bool cmFileCommand::HandleRPathChangeCommand(
+  std::vector<std::string> const& args)
 {
   // Evaluate arguments.
   const char* file = 0;
   const char* oldRPath = 0;
   const char* newRPath = 0;
-  enum Doing { DoingNone, DoingFile, DoingOld, DoingNew };
+  enum Doing
+  {
+    DoingNone,
+    DoingFile,
+    DoingOld,
+    DoingNew
+  };
   Doing doing = DoingNone;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "OLD_RPATH")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "OLD_RPATH") {
       doing = DoingOld;
-      }
-    else if(args[i] == "NEW_RPATH")
-      {
+    } else if (args[i] == "NEW_RPATH") {
       doing = DoingNew;
-      }
-    else if(args[i] == "FILE")
-      {
+    } else if (args[i] == "FILE") {
       doing = DoingFile;
-      }
-    else if(doing == DoingFile)
-      {
+    } else if (doing == DoingFile) {
       file = args[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingOld)
-      {
+    } else if (doing == DoingOld) {
       oldRPath = args[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingNew)
-      {
+    } else if (doing == DoingNew) {
       newRPath = args[i].c_str();
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "RPATH_CHANGE given unknown argument " << args[i];
       this->SetError(e.str());
       return false;
-      }
     }
-  if(!file)
-    {
+  }
+  if (!file) {
     this->SetError("RPATH_CHANGE not given FILE option.");
     return false;
-    }
-  if(!oldRPath)
-    {
+  }
+  if (!oldRPath) {
     this->SetError("RPATH_CHANGE not given OLD_RPATH option.");
     return false;
-    }
-  if(!newRPath)
-    {
+  }
+  if (!newRPath) {
     this->SetError("RPATH_CHANGE not given NEW_RPATH option.");
     return false;
-    }
-  if(!cmSystemTools::FileExists(file, true))
-    {
+  }
+  if (!cmSystemTools::FileExists(file, true)) {
     std::ostringstream e;
     e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
     this->SetError(e.str());
     return false;
-    }
+  }
   bool success = true;
   cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
   bool have_ft = cmSystemTools::FileTimeGet(file, ft);
   std::string emsg;
   bool changed;
-  if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed))
-    {
+  if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) {
     std::ostringstream e;
+    /* clang-format off */
     e << "RPATH_CHANGE could not write new RPATH:\n"
       << "  " << newRPath << "\n"
       << "to the file:\n"
       << "  " << file << "\n"
       << emsg;
+    /* clang-format on */
     this->SetError(e.str());
     success = false;
-    }
-  if(success)
-    {
-    if(changed)
-      {
+  }
+  if (success) {
+    if (changed) {
       std::string message = "Set runtime path of \"";
       message += file;
       message += "\" to \"";
       message += newRPath;
       message += "\"";
       this->Makefile->DisplayStatus(message.c_str(), -1);
-      }
-    if(have_ft)
-      {
+    }
+    if (have_ft) {
       cmSystemTools::FileTimeSet(file, ft);
-      }
     }
+  }
   cmSystemTools::FileTimeDelete(ft);
   return success;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
+bool cmFileCommand::HandleRPathRemoveCommand(
+  std::vector<std::string> const& args)
 {
   // Evaluate arguments.
   const char* file = 0;
-  enum Doing { DoingNone, DoingFile };
+  enum Doing
+  {
+    DoingNone,
+    DoingFile
+  };
   Doing doing = DoingNone;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "FILE")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "FILE") {
       doing = DoingFile;
-      }
-    else if(doing == DoingFile)
-      {
+    } else if (doing == DoingFile) {
       file = args[i].c_str();
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "RPATH_REMOVE given unknown argument " << args[i];
       this->SetError(e.str());
       return false;
-      }
     }
-  if(!file)
-    {
+  }
+  if (!file) {
     this->SetError("RPATH_REMOVE not given FILE option.");
     return false;
-    }
-  if(!cmSystemTools::FileExists(file, true))
-    {
+  }
+  if (!cmSystemTools::FileExists(file, true)) {
     std::ostringstream e;
     e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
     this->SetError(e.str());
     return false;
-    }
+  }
   bool success = true;
   cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
   bool have_ft = cmSystemTools::FileTimeGet(file, ft);
   std::string emsg;
   bool removed;
-  if(!cmSystemTools::RemoveRPath(file, &emsg, &removed))
-    {
+  if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) {
     std::ostringstream e;
+    /* clang-format off */
     e << "RPATH_REMOVE could not remove RPATH from file:\n"
       << "  " << file << "\n"
       << emsg;
+    /* clang-format on */
     this->SetError(e.str());
     success = false;
-    }
-  if(success)
-    {
-    if(removed)
-      {
+  }
+  if (success) {
+    if (removed) {
       std::string message = "Removed runtime path from \"";
       message += file;
       message += "\"";
       this->Makefile->DisplayStatus(message.c_str(), -1);
-      }
-    if(have_ft)
-      {
+    }
+    if (have_ft) {
       cmSystemTools::FileTimeSet(file, ft);
-      }
     }
+  }
   cmSystemTools::FileTimeDelete(ft);
   return success;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmFileCommand::HandleRPathCheckCommand(std::vector<std::string> const& args)
+bool cmFileCommand::HandleRPathCheckCommand(
+  std::vector<std::string> const& args)
 {
   // Evaluate arguments.
   const char* file = 0;
   const char* rpath = 0;
-  enum Doing { DoingNone, DoingFile, DoingRPath };
+  enum Doing
+  {
+    DoingNone,
+    DoingFile,
+    DoingRPath
+  };
   Doing doing = DoingNone;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "RPATH")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "RPATH") {
       doing = DoingRPath;
-      }
-    else if(args[i] == "FILE")
-      {
+    } else if (args[i] == "FILE") {
       doing = DoingFile;
-      }
-    else if(doing == DoingFile)
-      {
+    } else if (doing == DoingFile) {
       file = args[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingRPath)
-      {
+    } else if (doing == DoingRPath) {
       rpath = args[i].c_str();
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "RPATH_CHECK given unknown argument " << args[i];
       this->SetError(e.str());
       return false;
-      }
     }
-  if(!file)
-    {
+  }
+  if (!file) {
     this->SetError("RPATH_CHECK not given FILE option.");
     return false;
-    }
-  if(!rpath)
-    {
+  }
+  if (!rpath) {
     this->SetError("RPATH_CHECK not given RPATH option.");
     return false;
-    }
+  }
 
   // If the file exists but does not have the desired RPath then
   // delete it.  This is used during installation to re-install a file
   // if its RPath will change.
-  if(cmSystemTools::FileExists(file, true) &&
-     !cmSystemTools::CheckRPath(file, rpath))
-    {
+  if (cmSystemTools::FileExists(file, true) &&
+      !cmSystemTools::CheckRPath(file, rpath)) {
     cmSystemTools::RemoveFile(file);
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args)
 {
   cmFileInstaller installer(this);
   return installer.Run(args);
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleRelativePathCommand(
   std::vector<std::string> const& args)
 {
-  if(args.size() != 4 )
-    {
+  if (args.size() != 4) {
     this->SetError("RELATIVE_PATH called with incorrect number of arguments");
     return false;
-    }
+  }
 
   const std::string& outVar = args[1];
   const std::string& directoryName = args[2];
   const std::string& fileName = args[3];
 
-  if(!cmSystemTools::FileIsFullPath(directoryName.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(directoryName.c_str())) {
     std::string errstring =
-      "RELATIVE_PATH must be passed a full path to the directory: "
-      + directoryName;
+      "RELATIVE_PATH must be passed a full path to the directory: " +
+      directoryName;
     this->SetError(errstring);
     return false;
-    }
-  if(!cmSystemTools::FileIsFullPath(fileName.c_str()))
-    {
+  }
+  if (!cmSystemTools::FileIsFullPath(fileName.c_str())) {
     std::string errstring =
-      "RELATIVE_PATH must be passed a full path to the file: "
-      + fileName;
+      "RELATIVE_PATH must be passed a full path to the file: " + fileName;
     this->SetError(errstring);
     return false;
-    }
+  }
 
-  std::string res = cmSystemTools::RelativePath(directoryName.c_str(),
-                                                fileName.c_str());
-  this->Makefile->AddDefinition(outVar,
-    res.c_str());
+  std::string res =
+    cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str());
+  this->Makefile->AddDefinition(outVar, res.c_str());
   return true;
 }
 
-
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("RENAME given incorrect number of arguments.");
     return false;
-    }
+  }
 
   // Compute full path for old and new names.
   std::string oldname = args[1];
-  if(!cmsys::SystemTools::FileIsFullPath(oldname.c_str()))
-    {
+  if (!cmsys::SystemTools::FileIsFullPath(oldname.c_str())) {
     oldname = this->Makefile->GetCurrentSourceDirectory();
     oldname += "/" + args[1];
-    }
+  }
   std::string newname = args[2];
-  if(!cmsys::SystemTools::FileIsFullPath(newname.c_str()))
-    {
+  if (!cmsys::SystemTools::FileIsFullPath(newname.c_str())) {
     newname = this->Makefile->GetCurrentSourceDirectory();
     newname += "/" + args[2];
-    }
+  }
 
-  if(!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str()))
-    {
+  if (!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str())) {
     std::string err = cmSystemTools::GetLastSystemError();
     std::ostringstream e;
+    /* clang-format off */
     e << "RENAME failed to rename\n"
       << "  " << oldname << "\n"
       << "to\n"
       << "  " << newname << "\n"
       << "because: " << err << "\n";
+    /* clang-format on */
     this->SetError(e.str());
     return false;
-    }
+  }
   return true;
 }
 
-
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
                                  bool recurse)
 {
@@ -2686,80 +2224,64 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
   std::vector<std::string>::const_iterator i = args.begin();
 
   i++; // Get rid of subcommand
-  for(;i != args.end(); ++i)
-    {
+  for (; i != args.end(); ++i) {
     std::string fileName = *i;
-    if(!cmsys::SystemTools::FileIsFullPath(fileName.c_str()))
-      {
+    if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
       fileName = this->Makefile->GetCurrentSourceDirectory();
       fileName += "/" + *i;
-      }
+    }
 
-    if(cmSystemTools::FileIsDirectory(fileName) &&
-       !cmSystemTools::FileIsSymlink(fileName) && recurse)
-      {
+    if (cmSystemTools::FileIsDirectory(fileName) &&
+        !cmSystemTools::FileIsSymlink(fileName) && recurse) {
       cmSystemTools::RemoveADirectory(fileName);
-      }
-    else
-      {
+    } else {
       cmSystemTools::RemoveFile(fileName);
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmFileCommand::HandleCMakePathCommand(std::vector<std::string>
-                                           const& args,
-                                           bool nativePath)
+bool cmFileCommand::HandleCMakePathCommand(
+  std::vector<std::string> const& args, bool nativePath)
 {
   std::vector<std::string>::const_iterator i = args.begin();
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be "
-      "called with exactly three arguments.");
+                   "called with exactly three arguments.");
     return false;
-    }
+  }
   i++; // Get rid of subcommand
 #if defined(_WIN32) && !defined(__CYGWIN__)
   char pathSep = ';';
 #else
   char pathSep = ':';
 #endif
-  std::vector<cmsys::String> path = cmSystemTools::SplitString(*i,
-                                                             pathSep);
+  std::vector<cmsys::String> path = cmSystemTools::SplitString(*i, pathSep);
   i++;
-  const char* var =  i->c_str();
+  const char* var = i->c_str();
   std::string value;
-  for(std::vector<cmsys::String>::iterator j = path.begin();
-      j != path.end(); ++j)
-    {
-    if(j != path.begin())
-      {
+  for (std::vector<cmsys::String>::iterator j = path.begin(); j != path.end();
+       ++j) {
+    if (j != path.begin()) {
       value += ";";
-      }
-    if(!nativePath)
-      {
+    }
+    if (!nativePath) {
       cmSystemTools::ConvertToUnixSlashes(*j);
-      }
-    else
-      {
+    } else {
       *j = cmSystemTools::ConvertToOutputPath(j->c_str());
       // remove double quotes in the path
       cmsys::String& s = *j;
 
-      if(s.size() > 1 && s[0] == '\"' && s[s.size()-1] == '\"')
-        {
-        s = s.substr(1,s.size()-2);
-        }
+      if (s.size() > 1 && s[0] == '\"' && s[s.size() - 1] == '\"') {
+        s = s.substr(1, s.size() - 2);
       }
-    value += *j;
     }
+    value += *j;
+  }
   this->Makefile->AddDefinition(var, value.c_str());
   return true;
 }
 
-
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 
 // Stuff for curl download/upload
@@ -2767,212 +2289,181 @@ typedef std::vector<char> cmFileCommandVectorOfChar;
 
 namespace {
 
-  size_t
-  cmWriteToFileCallback(void *ptr, size_t size, size_t nmemb,
-                        void *data)
-    {
-    int realsize = (int)(size * nmemb);
-    cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data);
-    const char* chPtr = static_cast<char*>(ptr);
-    fout->write(chPtr, realsize);
-    return realsize;
-    }
-
-
-  size_t
-  cmWriteToMemoryCallback(void *ptr, size_t size, size_t nmemb,
-                          void *data)
-    {
-    int realsize = (int)(size * nmemb);
-    cmFileCommandVectorOfChar *vec
-      = static_cast<cmFileCommandVectorOfChar*>(data);
-    const char* chPtr = static_cast<char*>(ptr);
-    vec->insert(vec->end(), chPtr, chPtr + realsize);
-    return realsize;
-    }
-
+size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
+{
+  int realsize = (int)(size * nmemb);
+  cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data);
+  const char* chPtr = static_cast<char*>(ptr);
+  fout->write(chPtr, realsize);
+  return realsize;
+}
 
-  static size_t
-  cmFileCommandCurlDebugCallback(CURL *, curl_infotype type, char *chPtr,
-                                 size_t size, void *data)
-    {
-    cmFileCommandVectorOfChar *vec
-      = static_cast<cmFileCommandVectorOfChar*>(data);
-    switch(type)
-      {
-      case CURLINFO_TEXT:
-      case CURLINFO_HEADER_IN:
-      case CURLINFO_HEADER_OUT:
-        vec->insert(vec->end(), chPtr, chPtr + size);
-        break;
-      case CURLINFO_DATA_IN:
-      case CURLINFO_DATA_OUT:
-      case CURLINFO_SSL_DATA_IN:
-      case CURLINFO_SSL_DATA_OUT:
-        {
-        char buf[128];
-        int n = sprintf(buf, "[%" KWIML_INT_PRIu64 " bytes data]\n",
-                        static_cast<KWIML_INT_uint64_t>(size));
-        if (n > 0)
-          {
-          vec->insert(vec->end(), buf, buf + n);
-          }
-        }
-        break;
-      default:
-        break;
-      }
-    return 0;
-    }
+size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb,
+                               void* data)
+{
+  int realsize = (int)(size * nmemb);
+  cmFileCommandVectorOfChar* vec =
+    static_cast<cmFileCommandVectorOfChar*>(data);
+  const char* chPtr = static_cast<char*>(ptr);
+  vec->insert(vec->end(), chPtr, chPtr + realsize);
+  return realsize;
+}
 
+static size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type,
+                                             char* chPtr, size_t size,
+                                             void* data)
+{
+  cmFileCommandVectorOfChar* vec =
+    static_cast<cmFileCommandVectorOfChar*>(data);
+  switch (type) {
+    case CURLINFO_TEXT:
+    case CURLINFO_HEADER_IN:
+    case CURLINFO_HEADER_OUT:
+      vec->insert(vec->end(), chPtr, chPtr + size);
+      break;
+    case CURLINFO_DATA_IN:
+    case CURLINFO_DATA_OUT:
+    case CURLINFO_SSL_DATA_IN:
+    case CURLINFO_SSL_DATA_OUT: {
+      char buf[128];
+      int n = sprintf(buf, "[%" KWIML_INT_PRIu64 " bytes data]\n",
+                      static_cast<KWIML_INT_uint64_t>(size));
+      if (n > 0) {
+        vec->insert(vec->end(), buf, buf + n);
+      }
+    } break;
+    default:
+      break;
+  }
+  return 0;
+}
 
-  class cURLProgressHelper
+class cURLProgressHelper
+{
+public:
+  cURLProgressHelper(cmFileCommand* fc, const char* text)
   {
-  public:
-    cURLProgressHelper(cmFileCommand *fc, const char *text)
-      {
-      this->CurrentPercentage = -1;
-      this->FileCommand = fc;
-      this->Text = text;
-      }
-
-    bool UpdatePercentage(double value, double total, std::string &status)
-      {
-      int OldPercentage = this->CurrentPercentage;
-
-      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;
-          }
-        }
+    this->CurrentPercentage = -1;
+    this->FileCommand = fc;
+    this->Text = text;
+  }
 
-      bool updated = (OldPercentage != this->CurrentPercentage);
-
-      if (updated)
-        {
-        std::ostringstream oss;
-        oss << "[" << this->Text << " " << this->CurrentPercentage
-            << "% complete]";
-        status = oss.str();
-        }
+  bool UpdatePercentage(double value, double total, std::string& status)
+  {
+    int OldPercentage = this->CurrentPercentage;
 
-      return updated;
+    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;
       }
+    }
 
-    cmFileCommand *GetFileCommand()
-      {
-      return this->FileCommand;
-      }
+    bool updated = (OldPercentage != this->CurrentPercentage);
 
-  private:
-    int CurrentPercentage;
-    cmFileCommand *FileCommand;
-    std::string Text;
-  };
+    if (updated) {
+      std::ostringstream oss;
+      oss << "[" << this->Text << " " << this->CurrentPercentage
+          << "% complete]";
+      status = oss.str();
+    }
 
+    return updated;
+  }
 
-  static int
-  cmFileDownloadProgressCallback(void *clientp,
-                                 double dltotal, double dlnow,
-                                 double ultotal, double ulnow)
-    {
-    cURLProgressHelper *helper =
-      reinterpret_cast<cURLProgressHelper *>(clientp);
+  cmFileCommand* GetFileCommand() { return this->FileCommand; }
 
-    static_cast<void>(ultotal);
-    static_cast<void>(ulnow);
+private:
+  int CurrentPercentage;
+  cmFileCommand* FileCommand;
+  std::string Text;
+};
 
-    std::string status;
-    if (helper->UpdatePercentage(dlnow, dltotal, status))
-      {
-      cmFileCommand *fc = helper->GetFileCommand();
-      cmMakefile *mf = fc->GetMakefile();
-      mf->DisplayStatus(status.c_str(), -1);
-      }
+static int cmFileDownloadProgressCallback(void* clientp, double dltotal,
+                                          double dlnow, double ultotal,
+                                          double ulnow)
+{
+  cURLProgressHelper* helper = reinterpret_cast<cURLProgressHelper*>(clientp);
 
-    return 0;
-    }
+  static_cast<void>(ultotal);
+  static_cast<void>(ulnow);
 
+  std::string status;
+  if (helper->UpdatePercentage(dlnow, dltotal, status)) {
+    cmFileCommand* fc = helper->GetFileCommand();
+    cmMakefile* mf = fc->GetMakefile();
+    mf->DisplayStatus(status.c_str(), -1);
+  }
 
-  static int
-  cmFileUploadProgressCallback(void *clientp,
-                               double dltotal, double dlnow,
-                               double ultotal, double ulnow)
-    {
-    cURLProgressHelper *helper =
-    reinterpret_cast<cURLProgressHelper *>(clientp);
+  return 0;
+}
 
-    static_cast<void>(dltotal);
-    static_cast<void>(dlnow);
+static int cmFileUploadProgressCallback(void* clientp, double dltotal,
+                                        double dlnow, double ultotal,
+                                        double ulnow)
+{
+  cURLProgressHelper* helper = reinterpret_cast<cURLProgressHelper*>(clientp);
 
-    std::string status;
-    if (helper->UpdatePercentage(ulnow, ultotal, status))
-      {
-      cmFileCommand *fc = helper->GetFileCommand();
-      cmMakefile *mf = fc->GetMakefile();
-      mf->DisplayStatus(status.c_str(), -1);
-      }
+  static_cast<void>(dltotal);
+  static_cast<void>(dlnow);
 
-    return 0;
-    }
-}
+  std::string status;
+  if (helper->UpdatePercentage(ulnow, ultotal, status)) {
+    cmFileCommand* fc = helper->GetFileCommand();
+    cmMakefile* mf = fc->GetMakefile();
+    mf->DisplayStatus(status.c_str(), -1);
+  }
 
+  return 0;
+}
+}
 
 namespace {
 
-  class cURLEasyGuard
+class cURLEasyGuard
+{
+public:
+  cURLEasyGuard(CURL* easy)
+    : Easy(easy)
   {
-  public:
-    cURLEasyGuard(CURL * easy)
-      : Easy(easy)
-      {}
-
-    ~cURLEasyGuard(void)
-      {
-        if (this->Easy)
-          {
-          ::curl_easy_cleanup(this->Easy);
-          }
-      }
+  }
 
-    inline void release(void)
-      {
-        this->Easy = 0;
-        return;
-      }
+  ~cURLEasyGuard(void)
+  {
+    if (this->Easy) {
+      ::curl_easy_cleanup(this->Easy);
+    }
+  }
 
-  private:
-    ::CURL * Easy;
-  };
+  inline void release(void)
+  {
+    this->Easy = 0;
+    return;
+  }
 
+private:
+  ::CURL* Easy;
+};
 }
 #endif
 
+#define check_curl_result(result, errstr)                                     \
+  if (result != CURLE_OK) {                                                   \
+    std::string e(errstr);                                                    \
+    e += ::curl_easy_strerror(result);                                        \
+    this->SetError(e);                                                        \
+    return false;                                                             \
+  }
 
-#define check_curl_result(result, errstr) \
-  if (result != CURLE_OK)                 \
-    {                                     \
-    std::string e(errstr);                \
-    e += ::curl_easy_strerror(result);    \
-    this->SetError(e);            \
-    return false;                         \
-    }
-
-
-bool
-cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
+bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   std::vector<std::string>::const_iterator i = args.begin();
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("DOWNLOAD must be called with at least three arguments.");
     return false;
-    }
+  }
   ++i; // Get rid of subcommand
   std::string url = *i;
   ++i;
@@ -2990,183 +2481,140 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   cmsys::auto_ptr<cmCryptoHash> hash;
   bool showProgress = false;
 
-  while(i != args.end())
-    {
-    if(*i == "TIMEOUT")
-      {
+  while (i != args.end()) {
+    if (*i == "TIMEOUT") {
       ++i;
-      if(i != args.end())
-        {
+      if (i != args.end()) {
         timeout = atol(i->c_str());
-        }
-      else
-        {
+      } else {
         this->SetError("DOWNLOAD missing time for TIMEOUT.");
         return false;
-        }
       }
-    else if(*i == "INACTIVITY_TIMEOUT")
-      {
+    } else if (*i == "INACTIVITY_TIMEOUT") {
       ++i;
-      if(i != args.end())
-        {
+      if (i != args.end()) {
         inactivity_timeout = atol(i->c_str());
-        }
-      else
-        {
+      } else {
         this->SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT.");
         return false;
-        }
       }
-    else if(*i == "LOG")
-      {
+    } else if (*i == "LOG") {
       ++i;
-      if( i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("DOWNLOAD missing VAR for LOG.");
         return false;
-        }
-      logVar = *i;
       }
-    else if(*i == "STATUS")
-      {
+      logVar = *i;
+    } else if (*i == "STATUS") {
       ++i;
-      if( i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("DOWNLOAD missing VAR for STATUS.");
         return false;
-        }
-      statusVar = *i;
       }
-    else if(*i == "TLS_VERIFY")
-      {
+      statusVar = *i;
+    } else if (*i == "TLS_VERIFY") {
       ++i;
-      if(i != args.end())
-        {
+      if (i != args.end()) {
         tls_verify = cmSystemTools::IsOn(i->c_str());
-        }
-      else
-        {
+      } else {
         this->SetError("TLS_VERIFY missing bool value.");
         return false;
-        }
       }
-    else if(*i == "TLS_CAINFO")
-      {
+    } else if (*i == "TLS_CAINFO") {
       ++i;
-      if(i != args.end())
-        {
+      if (i != args.end()) {
         cainfo = i->c_str();
-        }
-      else
-        {
+      } else {
         this->SetError("TLS_CAFILE missing file value.");
         return false;
-        }
       }
-    else if(*i == "EXPECTED_MD5")
-      {
+    } else if (*i == "EXPECTED_MD5") {
       ++i;
-      if( i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
         return false;
-        }
+      }
       hash = cmsys::auto_ptr<cmCryptoHash>(cmCryptoHash::New("MD5"));
       hashMatchMSG = "MD5 sum";
       expectedHash = cmSystemTools::LowerCase(*i);
-      }
-    else if(*i == "SHOW_PROGRESS")
-      {
+    } else if (*i == "SHOW_PROGRESS") {
       showProgress = true;
-      }
-    else if(*i == "EXPECTED_HASH")
-      {
+    } else if (*i == "EXPECTED_HASH") {
       ++i;
-      if(i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH.");
         return false;
-        }
+      }
       std::string::size_type pos = i->find("=");
-      if(pos == std::string::npos)
-        {
+      if (pos == std::string::npos) {
         std::string err =
           "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ";
         err += *i;
         this->SetError(err);
         return false;
-        }
+      }
       std::string algo = i->substr(0, pos);
-      expectedHash = cmSystemTools::LowerCase(i->substr(pos+1));
+      expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1));
       hash = cmsys::auto_ptr<cmCryptoHash>(cmCryptoHash::New(algo.c_str()));
-      if(!hash.get())
-        {
+      if (!hash.get()) {
         std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
         err += algo;
         this->SetError(err);
         return false;
-        }
-      hashMatchMSG = algo + " hash";
       }
-    ++i;
+      hashMatchMSG = algo + " hash";
     }
+    ++i;
+  }
   // If file exists already, and caller specified an expected md5 or sha,
   // and the existing file already has the expected hash, then simply
   // return.
   //
-  if(cmSystemTools::FileExists(file.c_str()) && hash.get())
-    {
+  if (cmSystemTools::FileExists(file.c_str()) && hash.get()) {
     std::string msg;
     std::string actualHash = hash->HashFile(file);
-    if(actualHash == expectedHash)
-      {
+    if (actualHash == expectedHash) {
       msg = "returning early; file already exists with expected ";
       msg += hashMatchMSG;
       msg += "\"";
-      if(!statusVar.empty())
-        {
+      if (!statusVar.empty()) {
         std::ostringstream result;
         result << (int)0 << ";\"" << msg;
-        this->Makefile->AddDefinition(statusVar,
-                                      result.str().c_str());
-        }
-      return true;
+        this->Makefile->AddDefinition(statusVar, result.str().c_str());
       }
+      return true;
     }
+  }
   // 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);
-  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 "
+  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);
     return false;
-    }
+  }
 
   cmsys::ofstream fout(file.c_str(), std::ios::binary);
-  if(!fout)
-    {
+  if (!fout) {
     this->SetError("DOWNLOAD cannot open file for write.");
     return false;
-    }
+  }
 
 #if defined(_WIN32) && defined(CMAKE_ENCODING_UTF8)
   url = fix_file_url_windows(url);
 #endif
 
-  ::CURL *curl;
+  ::CURL* curl;
   ::curl_global_init(CURL_GLOBAL_DEFAULT);
   curl = ::curl_easy_init();
-  if(!curl)
-    {
+  if (!curl) {
     this->SetError("DOWNLOAD error initializing curl.");
     return false;
-    }
+  }
 
   cURLEasyGuard g_curl(curl);
   ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@@ -3179,8 +2627,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   res = ::curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/" LIBCURL_VERSION);
   check_curl_result(res, "DOWNLOAD cannot set user agent option: ");
 
-  res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
-                           cmWriteToFileCallback);
+  res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToFileCallback);
   check_curl_result(res, "DOWNLOAD cannot set write function: ");
 
   res = ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
@@ -3188,54 +2635,47 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   check_curl_result(res, "DOWNLOAD cannot set debug function: ");
 
   // check to see if TLS verification is requested
-  if(tls_verify)
-    {
+  if (tls_verify) {
     res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
     check_curl_result(res, "Unable to set TLS/SSL Verify on: ");
-    }
-  else
-    {
+  } else {
     res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
     check_curl_result(res, "Unable to set TLS/SSL Verify off: ");
-    }
+  }
   // check to see if a CAINFO file has been specified
   // command arg comes first
   std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
-  if (!cainfo_err.empty())
-    {
+  if (!cainfo_err.empty()) {
     this->SetError(cainfo_err);
     return false;
-    }
+  }
 
   cmFileCommandVectorOfChar chunkDebug;
 
-  res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&fout);
+  res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&fout);
   check_curl_result(res, "DOWNLOAD cannot set write data: ");
 
-  res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+  res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
   check_curl_result(res, "DOWNLOAD cannot set debug data: ");
 
   res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
   check_curl_result(res, "DOWNLOAD cannot set follow-redirect option: ");
 
-  if(!logVar.empty())
-    {
+  if (!logVar.empty()) {
     res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
     check_curl_result(res, "DOWNLOAD cannot set verbose: ");
-    }
+  }
 
-  if(timeout > 0)
-    {
-    res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout );
+  if (timeout > 0) {
+    res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
     check_curl_result(res, "DOWNLOAD cannot set timeout: ");
-    }
+  }
 
-  if(inactivity_timeout > 0)
-    {
+  if (inactivity_timeout > 0) {
     // Give up if there is no progress for a long time.
     ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
     ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, inactivity_timeout);
-    }
+  }
 
   // Need the progress helper's scope to last through the duration of
   // the curl_easy_perform call... so this object is declared at function
@@ -3244,19 +2684,18 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   //
   cURLProgressHelper helper(this, "download");
 
-  if(showProgress)
-    {
+  if (showProgress) {
     res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
     check_curl_result(res, "DOWNLOAD cannot set noprogress value: ");
 
-    res = ::curl_easy_setopt(curl,
-      CURLOPT_PROGRESSFUNCTION, cmFileDownloadProgressCallback);
+    res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION,
+                             cmFileDownloadProgressCallback);
     check_curl_result(res, "DOWNLOAD cannot set progress function: ");
 
-    res = ::curl_easy_setopt(curl,
-      CURLOPT_PROGRESSDATA, reinterpret_cast<void*>(&helper));
+    res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA,
+                             reinterpret_cast<void*>(&helper));
     check_curl_result(res, "DOWNLOAD cannot set progress data: ");
-    }
+  }
 
   res = ::curl_easy_perform(curl);
 
@@ -3264,13 +2703,11 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   g_curl.release();
   ::curl_easy_cleanup(curl);
 
-  if(!statusVar.empty())
-    {
+  if (!statusVar.empty()) {
     std::ostringstream result;
     result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
-    this->Makefile->AddDefinition(statusVar,
-                                  result.str().c_str());
-    }
+    this->Makefile->AddDefinition(statusVar, result.str().c_str());
+  }
 
   ::curl_global_cleanup();
 
@@ -3281,35 +2718,38 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
 
   // Verify MD5 sum if requested:
   //
-  if (hash.get())
-    {
+  if (hash.get()) {
     std::string actualHash = hash->HashFile(file);
-    if (actualHash.empty())
-      {
+    if (actualHash.empty()) {
       this->SetError("DOWNLOAD cannot compute hash on downloaded file");
       return false;
-      }
+    }
 
-    if (expectedHash != actualHash)
-      {
+    if (expectedHash != actualHash) {
       std::ostringstream oss;
       oss << "DOWNLOAD HASH mismatch" << std::endl
-        << "  for file: [" << file << "]" << std::endl
-        << "    expected hash: [" << expectedHash << "]" << std::endl
-        << "      actual hash: [" << actualHash << "]" << std::endl
-        << "           status: [" << (int)res << ";\""
-          << ::curl_easy_strerror(res) << "\"]" << std::endl
-        ;
+          << "  for file: [" << file << "]" << std::endl
+          << "    expected hash: [" << expectedHash << "]" << std::endl
+          << "      actual hash: [" << actualHash << "]" << std::endl
+          << "           status: [" << (int)res << ";\""
+          << ::curl_easy_strerror(res) << "\"]" << std::endl;
+
+      if (!statusVar.empty() && res == 0) {
+        std::string status = "1;HASH mismatch: "
+                             "expected: " +
+          expectedHash + " actual: " + actualHash;
+        this->Makefile->AddDefinition(statusVar, status.c_str());
+      }
+
       this->SetError(oss.str());
       return false;
-      }
     }
+  }
 
-  if (!logVar.empty())
-    {
+  if (!logVar.empty()) {
     chunkDebug.push_back(0);
     this->Makefile->AddDefinition(logVar, &*chunkDebug.begin());
-    }
+  }
 
   return true;
 #else
@@ -3318,16 +2758,13 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
 #endif
 }
 
-
-bool
-cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
+bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("UPLOAD must be called with at least three arguments.");
     return false;
-    }
+  }
   std::vector<std::string>::const_iterator i = args.begin();
   ++i;
   std::string filename = *i;
@@ -3341,72 +2778,53 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   std::string statusVar;
   bool showProgress = false;
 
-  while(i != args.end())
-    {
-    if(*i == "TIMEOUT")
-      {
+  while (i != args.end()) {
+    if (*i == "TIMEOUT") {
       ++i;
-      if(i != args.end())
-        {
+      if (i != args.end()) {
         timeout = atol(i->c_str());
-        }
-      else
-        {
+      } else {
         this->SetError("UPLOAD missing time for TIMEOUT.");
         return false;
-        }
       }
-    else if(*i == "INACTIVITY_TIMEOUT")
-      {
+    } else if (*i == "INACTIVITY_TIMEOUT") {
       ++i;
-      if(i != args.end())
-        {
+      if (i != args.end()) {
         inactivity_timeout = atol(i->c_str());
-        }
-      else
-        {
+      } else {
         this->SetError("UPLOAD missing time for INACTIVITY_TIMEOUT.");
         return false;
-        }
       }
-    else if(*i == "LOG")
-      {
+    } else if (*i == "LOG") {
       ++i;
-      if( i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("UPLOAD missing VAR for LOG.");
         return false;
-        }
-      logVar = *i;
       }
-    else if(*i == "STATUS")
-      {
+      logVar = *i;
+    } else if (*i == "STATUS") {
       ++i;
-      if( i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("UPLOAD missing VAR for STATUS.");
         return false;
-        }
-      statusVar = *i;
       }
-    else if(*i == "SHOW_PROGRESS")
-      {
+      statusVar = *i;
+    } else if (*i == "SHOW_PROGRESS") {
       showProgress = true;
-      }
+    }
 
     ++i;
-    }
+  }
 
   // Open file for reading:
   //
-  FILE *fin = cmsys::SystemTools::Fopen(filename, "rb");
-  if(!fin)
-    {
+  FILE* fin = cmsys::SystemTools::Fopen(filename, "rb");
+  if (!fin) {
     std::string errStr = "UPLOAD cannot open file '";
     errStr += filename + "' for reading.";
     this->SetError(errStr);
     return false;
-    }
+  }
 
   unsigned long file_size = cmsys::SystemTools::FileLength(filename);
 
@@ -3414,15 +2832,14 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   url = fix_file_url_windows(url);
 #endif
 
-  ::CURL *curl;
+  ::CURL* curl;
   ::curl_global_init(CURL_GLOBAL_DEFAULT);
   curl = ::curl_easy_init();
-  if(!curl)
-    {
+  if (!curl) {
     this->SetError("UPLOAD error initializing curl.");
     fclose(fin);
     return false;
-    }
+  }
 
   cURLEasyGuard g_curl(curl);
 
@@ -3437,8 +2854,8 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
   check_curl_result(res, "UPLOAD cannot set url: ");
 
-  res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
-                           cmWriteToMemoryCallback);
+  res =
+    ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToMemoryCallback);
   check_curl_result(res, "UPLOAD cannot set write function: ");
 
   res = ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
@@ -3448,33 +2865,30 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   cmFileCommandVectorOfChar chunkResponse;
   cmFileCommandVectorOfChar chunkDebug;
 
-  res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunkResponse);
+  res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&chunkResponse);
   check_curl_result(res, "UPLOAD cannot set write data: ");
 
-  res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
+  res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
   check_curl_result(res, "UPLOAD cannot set debug data: ");
 
   res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
   check_curl_result(res, "UPLOAD cannot set follow-redirect option: ");
 
-  if(!logVar.empty())
-    {
+  if (!logVar.empty()) {
     res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
     check_curl_result(res, "UPLOAD cannot set verbose: ");
-    }
+  }
 
-  if(timeout > 0)
-    {
-    res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout );
+  if (timeout > 0) {
+    res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
     check_curl_result(res, "UPLOAD cannot set timeout: ");
-    }
+  }
 
-  if(inactivity_timeout > 0)
-    {
+  if (inactivity_timeout > 0) {
     // Give up if there is no progress for a long time.
     ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
     ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, inactivity_timeout);
-    }
+  }
 
   // Need the progress helper's scope to last through the duration of
   // the curl_easy_perform call... so this object is declared at function
@@ -3483,27 +2897,26 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   //
   cURLProgressHelper helper(this, "upload");
 
-  if(showProgress)
-    {
+  if (showProgress) {
     res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
     check_curl_result(res, "UPLOAD cannot set noprogress value: ");
 
-    res = ::curl_easy_setopt(curl,
-      CURLOPT_PROGRESSFUNCTION, cmFileUploadProgressCallback);
+    res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION,
+                             cmFileUploadProgressCallback);
     check_curl_result(res, "UPLOAD cannot set progress function: ");
 
-    res = ::curl_easy_setopt(curl,
-      CURLOPT_PROGRESSDATA, reinterpret_cast<void*>(&helper));
+    res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA,
+                             reinterpret_cast<void*>(&helper));
     check_curl_result(res, "UPLOAD cannot set progress data: ");
-    }
+  }
 
   // now specify which file to upload
   res = ::curl_easy_setopt(curl, CURLOPT_INFILE, fin);
   check_curl_result(res, "UPLOAD cannot set input file: ");
 
   // and give the size of the upload (optional)
-  res = ::curl_easy_setopt(curl,
-    CURLOPT_INFILESIZE, static_cast<long>(file_size));
+  res =
+    ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(file_size));
   check_curl_result(res, "UPLOAD cannot set input file size: ");
 
   res = ::curl_easy_perform(curl);
@@ -3512,41 +2925,36 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
   g_curl.release();
   ::curl_easy_cleanup(curl);
 
-  if(!statusVar.empty())
-    {
+  if (!statusVar.empty()) {
     std::ostringstream result;
     result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
-    this->Makefile->AddDefinition(statusVar,
-                                  result.str().c_str());
-    }
+    this->Makefile->AddDefinition(statusVar, result.str().c_str());
+  }
 
   ::curl_global_cleanup();
 
   fclose(fin);
   fin = NULL;
 
-  if(!logVar.empty())
-    {
+  if (!logVar.empty()) {
     std::string log;
 
-    if(!chunkResponse.empty())
-      {
+    if (!chunkResponse.empty()) {
       chunkResponse.push_back(0);
       log += "Response:\n";
       log += &*chunkResponse.begin();
       log += "\n";
-      }
+    }
 
-    if(!chunkDebug.empty())
-      {
+    if (!chunkDebug.empty()) {
       chunkDebug.push_back(0);
       log += "Debug:\n";
       log += &*chunkDebug.begin();
       log += "\n";
-      }
+    }
 
     this->Makefile->AddDefinition(logVar, log.c_str());
-    }
+  }
 
   return true;
 #else
@@ -3555,84 +2963,72 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
 #endif
 }
 
-//----------------------------------------------------------------------------
-void cmFileCommand::AddEvaluationFile(const std::string &inputName,
-                                      const std::string &outputExpr,
-                                      const std::string &condition,
-                                      bool inputIsContent
-                                     )
+void cmFileCommand::AddEvaluationFile(const std::string& inputName,
+                                      const std::string& outputExpr,
+                                      const std::string& condition,
+                                      bool inputIsContent)
 {
   cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
 
   cmGeneratorExpression outputGe(lfbt);
-  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge
-                                                = outputGe.Parse(outputExpr);
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge =
+    outputGe.Parse(outputExpr);
 
   cmGeneratorExpression conditionGe(lfbt);
-  cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge
-                                              = conditionGe.Parse(condition);
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge =
+    conditionGe.Parse(condition);
 
-  this->Makefile->AddEvaluationFile(inputName, outputCge,
-                                    conditionCge, inputIsContent);
+  this->Makefile->AddEvaluationFile(inputName, outputCge, conditionCge,
+                                    inputIsContent);
 }
 
-//----------------------------------------------------------------------------
-bool cmFileCommand::HandleGenerateCommand(
-  std::vector<std::string> const& args)
+bool cmFileCommand::HandleGenerateCommand(std::vector<std::string> const& args)
 {
-  if (args.size() < 5)
-    {
+  if (args.size() < 5) {
     this->SetError("Incorrect arguments to GENERATE subcommand.");
     return false;
-    }
-  if (args[1] != "OUTPUT")
-    {
+  }
+  if (args[1] != "OUTPUT") {
     this->SetError("Incorrect arguments to GENERATE subcommand.");
     return false;
-    }
+  }
   std::string condition;
-  if (args.size() > 5)
-    {
-    if (args[5] != "CONDITION")
-      {
+  if (args.size() > 5) {
+    if (args[5] != "CONDITION") {
       this->SetError("Incorrect arguments to GENERATE subcommand.");
       return false;
-      }
-    if (args.size() != 7)
-      {
+    }
+    if (args.size() != 7) {
       this->SetError("Incorrect arguments to GENERATE subcommand.");
       return false;
-      }
+    }
     condition = args[6];
-    if (condition.empty())
-      {
+    if (condition.empty()) {
       this->SetError("CONDITION of sub-command GENERATE must not be empty if "
-        "specified.");
+                     "specified.");
       return false;
-      }
     }
+  }
   std::string output = args[2];
   const bool inputIsContent = args[3] != "INPUT";
-  if (inputIsContent && args[3] != "CONTENT")
-    {
+  if (inputIsContent && args[3] != "CONTENT") {
     this->SetError("Incorrect arguments to GENERATE subcommand.");
     return false;
-    }
+  }
   std::string input = args[4];
 
   this->AddEvaluationFile(input, output, condition, inputIsContent);
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmFileCommand::HandleLockCommand(
-  std::vector<std::string> const& args)
+bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   // Default values
   bool directory = false;
   bool release = false;
-  enum Guard {
+  enum Guard
+  {
     GUARD_FUNCTION,
     GUARD_FILE,
     GUARD_PROCESS
@@ -3642,148 +3038,111 @@ bool cmFileCommand::HandleLockCommand(
   unsigned long timeout = static_cast<unsigned long>(-1);
 
   // Parse arguments
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->Makefile->IssueMessage(
-        cmake::FATAL_ERROR,
-        "sub-command LOCK requires at least two arguments.");
+      cmake::FATAL_ERROR, "sub-command LOCK requires at least two arguments.");
     return false;
-    }
+  }
 
   std::string path = args[1];
-  for (unsigned i = 2; i < args.size(); ++i)
-    {
-    if (args[i] == "DIRECTORY")
-      {
+  for (unsigned i = 2; i < args.size(); ++i) {
+    if (args[i] == "DIRECTORY") {
       directory = true;
-      }
-    else if (args[i] == "RELEASE")
-      {
+    } else if (args[i] == "RELEASE") {
       release = true;
-      }
-    else if (args[i] == "GUARD")
-      {
+    } else if (args[i] == "GUARD") {
       ++i;
       const char* merr = "expected FUNCTION, FILE or PROCESS after GUARD";
-      if (i >= args.size())
-        {
+      if (i >= args.size()) {
         this->Makefile->IssueMessage(cmake::FATAL_ERROR, merr);
         return false;
-        }
-      else
-        {
-        if (args[i] == "FUNCTION")
-          {
+      } else {
+        if (args[i] == "FUNCTION") {
           guard = GUARD_FUNCTION;
-          }
-        else if (args[i] == "FILE")
-          {
+        } else if (args[i] == "FILE") {
           guard = GUARD_FILE;
-          }
-        else if (args[i] == "PROCESS")
-          {
+        } else if (args[i] == "PROCESS") {
           guard = GUARD_PROCESS;
-          }
-        else
-          {
+        } else {
           std::ostringstream e;
           e << merr << ", but got:\n  \"" << args[i] << "\".";
           this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
           return false;
-          }
         }
       }
-    else if (args[i] == "RESULT_VARIABLE")
-      {
+    } else if (args[i] == "RESULT_VARIABLE") {
       ++i;
-      if (i >= args.size())
-        {
+      if (i >= args.size()) {
         this->Makefile->IssueMessage(
-            cmake::FATAL_ERROR,
-            "expected variable name after RESULT_VARIABLE");
+          cmake::FATAL_ERROR, "expected variable name after RESULT_VARIABLE");
         return false;
-        }
-      resultVariable = args[i];
       }
-    else if (args[i] == "TIMEOUT")
-      {
+      resultVariable = args[i];
+    } else if (args[i] == "TIMEOUT") {
       ++i;
-      if (i >= args.size())
-        {
-        this->Makefile->IssueMessage(
-            cmake::FATAL_ERROR,
-            "expected timeout value after TIMEOUT");
+      if (i >= args.size()) {
+        this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+                                     "expected timeout value after TIMEOUT");
         return false;
-        }
+      }
       long scanned;
-      if(!cmSystemTools::StringToLong(args[i].c_str(), &scanned)
-         || scanned < 0)
-        {
+      if (!cmSystemTools::StringToLong(args[i].c_str(), &scanned) ||
+          scanned < 0) {
         std::ostringstream e;
         e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
         this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
         return false;
-        }
-      timeout = static_cast<unsigned long>(scanned);
       }
-    else
-      {
+      timeout = static_cast<unsigned long>(scanned);
+    } else {
       std::ostringstream e;
       e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n";
       e << "but got: \"" << args[i] << "\".";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return false;
-      }
     }
+  }
 
-  if (directory)
-    {
+  if (directory) {
     path += "/cmake.lock";
-    }
+  }
 
-  if (!cmsys::SystemTools::FileIsFullPath(path))
-    {
+  if (!cmsys::SystemTools::FileIsFullPath(path)) {
     path = this->Makefile->GetCurrentSourceDirectory() + ("/" + path);
-    }
+  }
 
   // Unify path (remove '//', '/../', ...)
   path = cmSystemTools::CollapseFullPath(path);
 
   // Create file and directories if needed
   std::string parentDir = cmSystemTools::GetParentDirectory(path);
-  if (!cmSystemTools::MakeDirectory(parentDir))
-    {
+  if (!cmSystemTools::MakeDirectory(parentDir)) {
     std::ostringstream e;
     e << "directory\n  \"" << parentDir << "\"\ncreation failed ";
     e << "(check permissions).";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
-  FILE *file = cmsys::SystemTools::Fopen(path, "w");
-  if (!file)
-    {
+  }
+  FILE* file = cmsys::SystemTools::Fopen(path, "w");
+  if (!file) {
     std::ostringstream e;
     e << "file\n  \"" << path << "\"\ncreation failed (check permissions).";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
   fclose(file);
 
   // Actual lock/unlock
-  cmFileLockPool& lockPool = this->Makefile->GetGlobalGenerator()
-                                           ->GetFileLockPool();
+  cmFileLockPool& lockPool =
+    this->Makefile->GetGlobalGenerator()->GetFileLockPool();
 
   cmFileLockResult fileLockResult(cmFileLockResult::MakeOk());
-  if (release)
-    {
+  if (release) {
     fileLockResult = lockPool.Release(path);
-    }
-  else
-    {
-    switch (guard)
-      {
+  } else {
+    switch (guard) {
       case GUARD_FUNCTION:
         fileLockResult = lockPool.LockFunctionScope(path, timeout);
         break;
@@ -3796,24 +3155,22 @@ bool cmFileCommand::HandleLockCommand(
       default:
         cmSystemTools::SetFatalErrorOccured();
         return false;
-      }
     }
+  }
 
   const std::string result = fileLockResult.GetOutputMessage();
 
-  if (resultVariable.empty() && !fileLockResult.IsOk())
-    {
+  if (resultVariable.empty() && !fileLockResult.IsOk()) {
     std::ostringstream e;
     e << "error locking file\n  \"" << path << "\"\n" << result << ".";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
 
-  if (!resultVariable.empty())
-    {
+  if (!resultVariable.empty()) {
     this->Makefile->AddDefinition(resultVariable, result.c_str());
-    }
+  }
 
   return true;
 #else
@@ -3823,20 +3180,16 @@ bool cmFileCommand::HandleLockCommand(
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmFileCommand::HandleTimestampCommand(
   std::vector<std::string> const& args)
 {
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("sub-command TIMESTAMP requires at least two arguments.");
     return false;
-    }
-  else if(args.size() > 5)
-    {
+  } else if (args.size() > 5) {
     this->SetError("sub-command TIMESTAMP takes at most four arguments.");
     return false;
-    }
+  }
 
   unsigned int argsIndex = 1;
 
@@ -3845,30 +3198,25 @@ bool cmFileCommand::HandleTimestampCommand(
   const std::string& outputVariable = args[argsIndex++];
 
   std::string formatString;
-  if(args.size() > argsIndex && args[argsIndex] != "UTC")
-    {
+  if (args.size() > argsIndex && args[argsIndex] != "UTC") {
     formatString = args[argsIndex++];
-    }
+  }
 
   bool utcFlag = false;
-  if(args.size() > argsIndex)
-    {
-    if(args[argsIndex] == "UTC")
-      {
+  if (args.size() > argsIndex) {
+    if (args[argsIndex] == "UTC") {
       utcFlag = true;
-      }
-    else
-      {
+    } else {
       std::string e = " TIMESTAMP sub-command does not recognize option " +
-          args[argsIndex] + ".";
+        args[argsIndex] + ".";
       this->SetError(e);
       return false;
-      }
     }
+  }
 
   cmTimestamp timestamp;
-  std::string result = timestamp.FileModificationTime(
-    filename.c_str(), formatString, utcFlag);
+  std::string result =
+    timestamp.FileModificationTime(filename.c_str(), formatString, utcFlag);
   this->Makefile->AddDefinition(outputVariable, result.c_str());
 
   return true;
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index a4d341f..84bb456 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -26,17 +26,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFileCommand;
-    }
+  virtual cmCommand* Clone() { return new cmFileCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -46,7 +43,7 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "file";}
+  virtual std::string GetName() const { return "file"; }
 
   cmTypeMacro(cmFileCommand, cmCommand);
 
@@ -78,11 +75,9 @@ protected:
   bool HandleLockCommand(std::vector<std::string> const& args);
 
 private:
-  void AddEvaluationFile(const std::string &inputName,
-                         const std::string &outputExpr,
-                         const std::string &condition,
-                         bool inputIsContent);
+  void AddEvaluationFile(const std::string& inputName,
+                         const std::string& outputExpr,
+                         const std::string& condition, bool inputIsContent);
 };
 
-
 #endif
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
index e6aa5f4..828511f 100644
--- a/Source/cmFileLock.cxx
+++ b/Source/cmFileLock.cxx
@@ -12,56 +12,48 @@
 
 #include "cmFileLock.h"
 
-#include <assert.h>
 #include "cmFileLockResult.h"
+#include <assert.h>
 
 // Common implementation
 
 cmFileLock::~cmFileLock()
 {
-  if (!this->Filename.empty())
-    {
+  if (!this->Filename.empty()) {
     const cmFileLockResult result = this->Release();
     static_cast<void>(result);
     assert(result.IsOk());
-    }
+  }
 }
 
-cmFileLockResult cmFileLock::Lock(
-    const std::string& filename, unsigned long timeout)
+cmFileLockResult cmFileLock::Lock(const std::string& filename,
+                                  unsigned long timeout)
 {
-  if (filename.empty())
-    {
+  if (filename.empty()) {
     // Error is internal since all the directories and file must be created
     // before actual lock called.
     return cmFileLockResult::MakeInternal();
-    }
+  }
 
-  if (!this->Filename.empty())
-    {
+  if (!this->Filename.empty()) {
     // Error is internal since double-lock must be checked in class
     // cmFileLockPool by the cmFileLock::IsLocked method.
     return cmFileLockResult::MakeInternal();
-    }
+  }
 
   this->Filename = filename;
   cmFileLockResult result = this->OpenFile();
-  if (result.IsOk())
-    {
-    if (timeout == static_cast<unsigned long>(-1))
-      {
+  if (result.IsOk()) {
+    if (timeout == static_cast<unsigned long>(-1)) {
       result = this->LockWithoutTimeout();
-      }
-    else
-      {
+    } else {
       result = this->LockWithTimeout(timeout);
-      }
     }
+  }
 
-  if (!result.IsOk())
-    {
+  if (!result.IsOk()) {
     this->Filename = "";
-    }
+  }
 
   return result;
 }
@@ -72,7 +64,7 @@ bool cmFileLock::IsLocked(const std::string& filename) const
 }
 
 #if defined(_WIN32)
-# include "cmFileLockWin32.cxx"
+#include "cmFileLockWin32.cxx"
 #else
-# include "cmFileLockUnix.cxx"
+#include "cmFileLockUnix.cxx"
 #endif
diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h
index dd959a7..538b716 100644
--- a/Source/cmFileLock.h
+++ b/Source/cmFileLock.h
@@ -16,7 +16,7 @@
 #include "cmStandardIncludes.h"
 
 #if defined(_WIN32)
-# include <windows.h> // HANDLE
+#include <windows.h> // HANDLE
 #endif
 
 class cmFileLockResult;
@@ -29,7 +29,7 @@ class cmFileLockResult;
   */
 class cmFileLock
 {
- public:
+public:
   cmFileLock();
   ~cmFileLock();
 
@@ -51,7 +51,7 @@ class cmFileLock
     */
   bool IsLocked(const std::string& filename) const;
 
- private:
+private:
   cmFileLock(const cmFileLock&);
   cmFileLock& operator=(const cmFileLock&);
 
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index 3710eb0..7c51459 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -14,9 +14,9 @@
 
 #include <assert.h>
 
+#include "cmAlgorithms.h"
 #include "cmFileLock.h"
 #include "cmFileLockResult.h"
-#include "cmAlgorithms.h"
 
 cmFileLockPool::cmFileLockPool()
 {
@@ -52,85 +52,73 @@ void cmFileLockPool::PopFileScope()
   this->FileScopes.pop_back();
 }
 
-cmFileLockResult cmFileLockPool::LockFunctionScope(
-    const std::string& filename, unsigned long timeoutSec)
+cmFileLockResult cmFileLockPool::LockFunctionScope(const std::string& filename,
+                                                   unsigned long timeoutSec)
 {
-  if (this->IsAlreadyLocked(filename))
-    {
+  if (this->IsAlreadyLocked(filename)) {
     return cmFileLockResult::MakeAlreadyLocked();
-    }
-  if (this->FunctionScopes.empty())
-    {
+  }
+  if (this->FunctionScopes.empty()) {
     return cmFileLockResult::MakeNoFunction();
-    }
+  }
   return this->FunctionScopes.back()->Lock(filename, timeoutSec);
 }
 
-cmFileLockResult cmFileLockPool::LockFileScope(
-    const std::string& filename, unsigned long timeoutSec)
+cmFileLockResult cmFileLockPool::LockFileScope(const std::string& filename,
+                                               unsigned long timeoutSec)
 {
-  if (this->IsAlreadyLocked(filename))
-    {
+  if (this->IsAlreadyLocked(filename)) {
     return cmFileLockResult::MakeAlreadyLocked();
-    }
+  }
   assert(!this->FileScopes.empty());
   return this->FileScopes.back()->Lock(filename, timeoutSec);
 }
 
-cmFileLockResult cmFileLockPool::LockProcessScope(
-    const std::string& filename, unsigned long timeoutSec)
+cmFileLockResult cmFileLockPool::LockProcessScope(const std::string& filename,
+                                                  unsigned long timeoutSec)
 {
-  if (this->IsAlreadyLocked(filename))
-    {
+  if (this->IsAlreadyLocked(filename)) {
     return cmFileLockResult::MakeAlreadyLocked();
-    }
+  }
   return this->ProcessScope.Lock(filename, timeoutSec);
 }
 
 cmFileLockResult cmFileLockPool::Release(const std::string& filename)
 {
-  for (It i = this->FunctionScopes.begin();
-      i != this->FunctionScopes.end(); ++i)
-    {
+  for (It i = this->FunctionScopes.begin(); i != this->FunctionScopes.end();
+       ++i) {
     const cmFileLockResult result = (*i)->Release(filename);
-    if (!result.IsOk())
-      {
+    if (!result.IsOk()) {
       return result;
-      }
     }
+  }
 
-  for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i)
-    {
+  for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) {
     const cmFileLockResult result = (*i)->Release(filename);
-    if (!result.IsOk())
-      {
+    if (!result.IsOk()) {
       return result;
-      }
     }
+  }
 
   return this->ProcessScope.Release(filename);
 }
 
 bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const
 {
-  for (CIt i = this->FunctionScopes.begin();
-      i != this->FunctionScopes.end(); ++i)
-    {
+  for (CIt i = this->FunctionScopes.begin(); i != this->FunctionScopes.end();
+       ++i) {
     const bool result = (*i)->IsAlreadyLocked(filename);
-    if (result)
-      {
+    if (result) {
       return true;
-      }
     }
+  }
 
-  for (CIt i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i)
-    {
+  for (CIt i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) {
     const bool result = (*i)->IsAlreadyLocked(filename);
-    if (result)
-      {
+    if (result) {
       return true;
-      }
     }
+  }
 
   return this->ProcessScope.IsAlreadyLocked(filename);
 }
@@ -144,45 +132,38 @@ cmFileLockPool::ScopePool::~ScopePool()
   cmDeleteAll(this->Locks);
 }
 
-cmFileLockResult cmFileLockPool::ScopePool::Lock(
-    const std::string& filename, unsigned long timeoutSec)
+cmFileLockResult cmFileLockPool::ScopePool::Lock(const std::string& filename,
+                                                 unsigned long timeoutSec)
 {
-  cmFileLock *lock = new cmFileLock();
+  cmFileLock* lock = new cmFileLock();
   const cmFileLockResult result = lock->Lock(filename, timeoutSec);
-  if (result.IsOk())
-    {
+  if (result.IsOk()) {
     this->Locks.push_back(lock);
     return cmFileLockResult::MakeOk();
-    }
-  else
-    {
+  } else {
     delete lock;
     return result;
-    }
+  }
 }
 
 cmFileLockResult cmFileLockPool::ScopePool::Release(
-    const std::string& filename)
+  const std::string& filename)
 {
-  for (It i = this->Locks.begin(); i != this->Locks.end(); ++i)
-    {
-    if ((*i)->IsLocked(filename))
-      {
+  for (It i = this->Locks.begin(); i != this->Locks.end(); ++i) {
+    if ((*i)->IsLocked(filename)) {
       return (*i)->Release();
-      }
     }
+  }
   return cmFileLockResult::MakeOk();
 }
 
 bool cmFileLockPool::ScopePool::IsAlreadyLocked(
-    const std::string& filename) const
+  const std::string& filename) const
 {
-  for (CIt i = this->Locks.begin(); i != this->Locks.end(); ++i)
-    {
-    if ((*i)->IsLocked(filename))
-      {
+  for (CIt i = this->Locks.begin(); i != this->Locks.end(); ++i) {
+    if ((*i)->IsLocked(filename)) {
       return true;
-      }
     }
+  }
   return false;
 }
diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h
index f0614a3..dc42e6f 100644
--- a/Source/cmFileLockPool.h
+++ b/Source/cmFileLockPool.h
@@ -21,7 +21,7 @@ class cmFileLock;
 
 class cmFileLockPool
 {
- public:
+public:
   cmFileLockPool();
   ~cmFileLockPool();
 
@@ -46,15 +46,12 @@ class cmFileLockPool
     * @brief Lock the file in given scope.
     * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
     */
-  cmFileLockResult LockFunctionScope(
-      const std::string& filename, unsigned long timeoutSec
-  );
-  cmFileLockResult LockFileScope(
-      const std::string& filename, unsigned long timeoutSec
-  );
-  cmFileLockResult LockProcessScope(
-      const std::string& filename, unsigned long timeoutSec
-  );
+  cmFileLockResult LockFunctionScope(const std::string& filename,
+                                     unsigned long timeoutSec);
+  cmFileLockResult LockFileScope(const std::string& filename,
+                                 unsigned long timeoutSec);
+  cmFileLockResult LockProcessScope(const std::string& filename,
+                                    unsigned long timeoutSec);
   //@}
 
   /**
@@ -62,7 +59,7 @@ class cmFileLockPool
     */
   cmFileLockResult Release(const std::string& filename);
 
- private:
+private:
   cmFileLockPool(const cmFileLockPool&);
   cmFileLockPool& operator=(const cmFileLockPool&);
 
@@ -70,17 +67,16 @@ class cmFileLockPool
 
   class ScopePool
   {
-   public:
+  public:
     ScopePool();
     ~ScopePool();
 
-    cmFileLockResult Lock(
-        const std::string& filename, unsigned long timeoutSec
-    );
+    cmFileLockResult Lock(const std::string& filename,
+                          unsigned long timeoutSec);
     cmFileLockResult Release(const std::string& filename);
     bool IsAlreadyLocked(const std::string& filename) const;
 
-   private:
+  private:
     ScopePool(const ScopePool&);
     ScopePool& operator=(const ScopePool&);
 
diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx
index 045e7ee..090fe60 100644
--- a/Source/cmFileLockResult.cxx
+++ b/Source/cmFileLockResult.cxx
@@ -56,40 +56,29 @@ bool cmFileLockResult::IsOk() const
 
 std::string cmFileLockResult::GetOutputMessage() const
 {
-  switch (this->Type)
-    {
+  switch (this->Type) {
     case OK:
       return "0";
     case SYSTEM:
 #if defined(_WIN32)
-      {
+    {
       char* errorText = NULL;
 
       // http://stackoverflow.com/a/455533/2288008
       DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM |
-          FORMAT_MESSAGE_ALLOCATE_BUFFER |
-          FORMAT_MESSAGE_IGNORE_INSERTS;
-      ::FormatMessageA(
-          flags,
-          NULL,
-          this->ErrorValue,
-          MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-          (LPSTR)&errorText,
-          0,
-          NULL
-      );
+        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS;
+      ::FormatMessageA(flags, NULL, this->ErrorValue,
+                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                       (LPSTR)&errorText, 0, NULL);
 
-      if (errorText != NULL)
-        {
+      if (errorText != NULL) {
         const std::string message = errorText;
         ::LocalFree(errorText);
         return message;
-        }
-      else
-        {
+      } else {
         return "Internal error (FormatMessageA failed)";
-        }
       }
+    }
 #else
       return strerror(this->ErrorValue);
 #endif
@@ -102,10 +91,11 @@ std::string cmFileLockResult::GetOutputMessage() const
     case INTERNAL:
     default:
       return "Internal error";
-    }
+  }
 }
 
-cmFileLockResult::cmFileLockResult(ErrorType typeValue, Error errorValue):
-    Type(typeValue), ErrorValue(errorValue)
+cmFileLockResult::cmFileLockResult(ErrorType typeValue, Error errorValue)
+  : Type(typeValue)
+  , ErrorValue(errorValue)
 {
 }
diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h
index 531fb49..d5ac354 100644
--- a/Source/cmFileLockResult.h
+++ b/Source/cmFileLockResult.h
@@ -16,7 +16,7 @@
 #include "cmStandardIncludes.h"
 
 #if defined(_WIN32)
-# include <windows.h> // DWORD
+#include <windows.h> // DWORD
 #endif
 
 /**
@@ -25,7 +25,7 @@
   */
 class cmFileLockResult
 {
- public:
+public:
 #if defined(_WIN32)
   typedef DWORD Error;
 #else
@@ -65,7 +65,7 @@ class cmFileLockResult
   bool IsOk() const;
   std::string GetOutputMessage() const;
 
- private:
+private:
   enum ErrorType
   {
     OK,
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
index 36a2d72..6be6abc 100644
--- a/Source/cmFileLockUnix.cxx
+++ b/Source/cmFileLockUnix.cxx
@@ -12,22 +12,22 @@
 
 #include "cmFileLock.h"
 
+#include "cmSystemTools.h"
 #include <errno.h> // errno
-#include <stdio.h> // SEEK_SET
 #include <fcntl.h>
+#include <stdio.h> // SEEK_SET
 #include <unistd.h>
-#include "cmSystemTools.h"
 
-cmFileLock::cmFileLock(): File(-1)
+cmFileLock::cmFileLock()
+  : File(-1)
 {
 }
 
 cmFileLockResult cmFileLock::Release()
 {
-  if (this->Filename.empty())
-    {
+  if (this->Filename.empty()) {
     return cmFileLockResult::MakeOk();
-    }
+  }
   const int lockResult = this->LockFile(F_SETLK, F_UNLCK);
 
   this->Filename = "";
@@ -35,71 +35,56 @@ cmFileLockResult cmFileLock::Release()
   ::close(this->File);
   this->File = -1;
 
-  if (lockResult == 0)
-    {
+  if (lockResult == 0) {
     return cmFileLockResult::MakeOk();
-    }
-  else
-    {
+  } else {
     return cmFileLockResult::MakeSystem();
-    }
+  }
 }
 
 cmFileLockResult cmFileLock::OpenFile()
 {
   this->File = ::open(this->Filename.c_str(), O_RDWR);
-  if (this->File == -1)
-    {
+  if (this->File == -1) {
     return cmFileLockResult::MakeSystem();
-    }
-  else
-    {
+  } else {
     return cmFileLockResult::MakeOk();
-    }
+  }
 }
 
 cmFileLockResult cmFileLock::LockWithoutTimeout()
 {
-  if (this->LockFile(F_SETLKW, F_WRLCK) == -1)
-    {
+  if (this->LockFile(F_SETLKW, F_WRLCK) == -1) {
     return cmFileLockResult::MakeSystem();
-    }
-  else
-    {
+  } else {
     return cmFileLockResult::MakeOk();
-    }
+  }
 }
 
 cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
 {
-  while (true)
-    {
-    if (this->LockFile(F_SETLK, F_WRLCK) == -1)
-      {
-      if (errno != EACCES && errno != EAGAIN)
-        {
+  while (true) {
+    if (this->LockFile(F_SETLK, F_WRLCK) == -1) {
+      if (errno != EACCES && errno != EAGAIN) {
         return cmFileLockResult::MakeSystem();
-        }
       }
-    else
-      {
+    } else {
       return cmFileLockResult::MakeOk();
-      }
-    if (seconds == 0)
-      {
+    }
+    if (seconds == 0) {
       return cmFileLockResult::MakeTimeout();
-      }
+    }
     --seconds;
     cmSystemTools::Delay(1000);
-    }
+  }
 }
 
 int cmFileLock::LockFile(int cmd, int type)
 {
   struct ::flock lock;
   lock.l_start = 0;
-  lock.l_len = 0; // lock all bytes
-  lock.l_pid = 0; // unused (for F_GETLK only)
+  lock.l_len = 0;                         // lock all bytes
+  lock.l_pid = 0;                         // unused (for F_GETLK only)
   lock.l_type = static_cast<short>(type); // exclusive lock
   lock.l_whence = SEEK_SET;
   return ::fcntl(this->File, cmd, &lock);
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
index dc65948..0ba1e9a 100644
--- a/Source/cmFileLockWin32.cxx
+++ b/Source/cmFileLockWin32.cxx
@@ -12,43 +12,35 @@
 
 #include "cmFileLock.h"
 
-#include <windows.h> // CreateFileW
 #include "cmSystemTools.h"
+#include <windows.h> // CreateFileW
 
-cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE)
+cmFileLock::cmFileLock()
+  : File(INVALID_HANDLE_VALUE)
 {
 }
 
 cmFileLockResult cmFileLock::Release()
 {
-  if (this->Filename.empty())
-    {
+  if (this->Filename.empty()) {
     return cmFileLockResult::MakeOk();
-    }
+  }
   const unsigned long len = static_cast<unsigned long>(-1);
   static OVERLAPPED overlapped;
   const DWORD reserved = 0;
-  const BOOL unlockResult = UnlockFileEx(
-      File,
-      reserved,
-      len,
-      len,
-      &overlapped
-  );
+  const BOOL unlockResult =
+    UnlockFileEx(File, reserved, len, len, &overlapped);
 
   this->Filename = "";
 
   CloseHandle(this->File);
   this->File = INVALID_HANDLE_VALUE;
 
-  if (unlockResult)
-    {
+  if (unlockResult) {
     return cmFileLockResult::MakeOk();
-    }
-  else
-    {
+  } else {
     return cmFileLockResult::MakeSystem();
-    }
+  }
 }
 
 cmFileLockResult cmFileLock::OpenFile()
@@ -59,58 +51,42 @@ cmFileLockResult cmFileLock::OpenFile()
   const DWORD attr = 0;
   const HANDLE templ = NULL;
   this->File = CreateFileW(
-      cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(),
-      access,
-      shareMode,
-      security,
-      OPEN_EXISTING,
-      attr,
-      templ
-  );
-  if (this->File == INVALID_HANDLE_VALUE)
-    {
+    cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(),
+    access, shareMode, security, OPEN_EXISTING, attr, templ);
+  if (this->File == INVALID_HANDLE_VALUE) {
     return cmFileLockResult::MakeSystem();
-    }
-  else
-    {
+  } else {
     return cmFileLockResult::MakeOk();
-    }
+  }
 }
 
 cmFileLockResult cmFileLock::LockWithoutTimeout()
 {
-  if (!this->LockFile(LOCKFILE_EXCLUSIVE_LOCK))
-    {
+  if (!this->LockFile(LOCKFILE_EXCLUSIVE_LOCK)) {
     return cmFileLockResult::MakeSystem();
-    }
-  else
-    {
+  } else {
     return cmFileLockResult::MakeOk();
-    }
+  }
 }
 
 cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
 {
   const DWORD flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
-  while (true)
-    {
+  while (true) {
     const BOOL result = this->LockFile(flags);
-    if (result)
-      {
+    if (result) {
       return cmFileLockResult::MakeOk();
-      }
+    }
     const DWORD error = GetLastError();
-    if (error != ERROR_LOCK_VIOLATION)
-      {
+    if (error != ERROR_LOCK_VIOLATION) {
       return cmFileLockResult::MakeSystem();
-      }
-    if (seconds == 0)
-      {
+    }
+    if (seconds == 0) {
       return cmFileLockResult::MakeTimeout();
-      }
+    }
     --seconds;
     cmSystemTools::Delay(1000);
-    }
+  }
 }
 
 BOOL cmFileLock::LockFile(DWORD flags)
@@ -118,12 +94,5 @@ BOOL cmFileLock::LockFile(DWORD flags)
   const DWORD reserved = 0;
   const unsigned long len = static_cast<unsigned long>(-1);
   static OVERLAPPED overlapped;
-  return LockFileEx(
-      this->File,
-      flags,
-      reserved,
-      len,
-      len,
-      &overlapped
-  );
+  return LockFileEx(this->File, flags, reserved, len, len, &overlapped);
 }
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 279b61d..7efe194 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -16,7 +16,7 @@
 #ifdef CMake_HAVE_CXX11_UNORDERED_MAP
 #include <unordered_map>
 #else
-# include <cmsys/hash_map.hxx>
+#include <cmsys/hash_map.hxx>
 #endif
 #endif
 
@@ -24,15 +24,14 @@
 
 // Use a platform-specific API to get file times efficiently.
 #if !defined(_WIN32) || defined(__CYGWIN__)
-#  define cmFileTimeComparison_Type struct stat
-#  include <ctype.h>
-#  include <sys/stat.h>
+#define cmFileTimeComparison_Type struct stat
+#include <ctype.h>
+#include <sys/stat.h>
 #else
-#  define cmFileTimeComparison_Type FILETIME
-#  include <windows.h>
+#define cmFileTimeComparison_Type FILETIME
+#include <windows.h>
 #endif
 
-//----------------------------------------------------------------------------
 class cmFileTimeComparisonInternal
 {
 public:
@@ -45,24 +44,22 @@ private:
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   // Use a hash table to efficiently map from file name to modification time.
   class HashString
-    {
+  {
   public:
-    size_t operator()(const std::string& s) const
-      {
-      return h(s.c_str());
-      }
+    size_t operator()(const std::string& s) const { return h(s.c_str()); }
 #ifdef CMake_HAVE_CXX11_UNORDERED_MAP
     std::hash<const char*> h;
 #else
     cmsys::hash<const char*> h;
 #endif
-    };
+  };
 #ifdef CMake_HAVE_CXX11_UNORDERED_MAP
   typedef std::unordered_map<std::string,
 #else
   typedef cmsys::hash_map<std::string,
 #endif
-                          cmFileTimeComparison_Type, HashString> FileStatsMap;
+                             cmFileTimeComparison_Type, HashString>
+    FileStatsMap;
   FileStatsMap Files;
 #endif
 
@@ -74,7 +71,6 @@ private:
                           cmFileTimeComparison_Type* st2);
 };
 
-//----------------------------------------------------------------------------
 bool cmFileTimeComparisonInternal::Stat(const char* fname,
                                         cmFileTimeComparison_Type* st)
 {
@@ -82,29 +78,26 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
   // Use the stored time if available.
   cmFileTimeComparisonInternal::FileStatsMap::iterator fit =
     this->Files.find(fname);
-  if ( fit != this->Files.end() )
-    {
+  if (fit != this->Files.end()) {
     *st = fit->second;
     return true;
-    }
+  }
 #endif
 
 #if !defined(_WIN32) || defined(__CYGWIN__)
   // POSIX version.  Use the stat function.
   int res = ::stat(fname, st);
-  if ( res != 0 )
-    {
+  if (res != 0) {
     return false;
-    }
+  }
 #else
   // Windows version.  Get the modification time from extended file
   // attributes.
   WIN32_FILE_ATTRIBUTE_DATA fdata;
-  if(!GetFileAttributesExW(cmsys::Encoding::ToWide(fname).c_str(),
-                           GetFileExInfoStandard, &fdata))
-    {
+  if (!GetFileAttributesExW(cmsys::Encoding::ToWide(fname).c_str(),
+                            GetFileExInfoStandard, &fdata)) {
     return false;
-    }
+  }
 
   // Copy the file time to the output location.
   *st = fdata.ftLastWriteTime;
@@ -118,83 +111,61 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname,
   return true;
 }
 
-//----------------------------------------------------------------------------
 cmFileTimeComparison::cmFileTimeComparison()
 {
   this->Internals = new cmFileTimeComparisonInternal;
 }
 
-//----------------------------------------------------------------------------
 cmFileTimeComparison::~cmFileTimeComparison()
 {
   delete this->Internals;
 }
 
-//----------------------------------------------------------------------------
-bool cmFileTimeComparison::FileTimeCompare(const char* f1,
-                                           const char* f2, int* result)
+bool cmFileTimeComparison::FileTimeCompare(const char* f1, const char* f2,
+                                           int* result)
 {
   return this->Internals->FileTimeCompare(f1, f2, result);
 }
 
-//----------------------------------------------------------------------------
 bool cmFileTimeComparison::FileTimesDiffer(const char* f1, const char* f2)
 {
   return this->Internals->FileTimesDiffer(f1, f2);
 }
 
-//----------------------------------------------------------------------------
 int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
                                           cmFileTimeComparison_Type* s2)
 {
 #if !defined(_WIN32) || defined(__CYGWIN__)
-# if CMake_STAT_HAS_ST_MTIM
+#if CMake_STAT_HAS_ST_MTIM
   // Compare using nanosecond resolution.
-  if(s1->st_mtim.tv_sec < s2->st_mtim.tv_sec)
-    {
+  if (s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) {
     return -1;
-    }
-  else if(s1->st_mtim.tv_sec > s2->st_mtim.tv_sec)
-    {
+  } else if (s1->st_mtim.tv_sec > s2->st_mtim.tv_sec) {
     return 1;
-    }
-  else if(s1->st_mtim.tv_nsec < s2->st_mtim.tv_nsec)
-    {
+  } else if (s1->st_mtim.tv_nsec < s2->st_mtim.tv_nsec) {
     return -1;
-    }
-  else if(s1->st_mtim.tv_nsec > s2->st_mtim.tv_nsec)
-    {
+  } else if (s1->st_mtim.tv_nsec > s2->st_mtim.tv_nsec) {
     return 1;
-    }
-# elif CMake_STAT_HAS_ST_MTIMESPEC
+  }
+#elif CMake_STAT_HAS_ST_MTIMESPEC
   // Compare using nanosecond resolution.
-  if(s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec)
-    {
+  if (s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec) {
     return -1;
-    }
-  else if(s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec)
-    {
+  } else if (s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec) {
     return 1;
-    }
-  else if(s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec)
-    {
+  } else if (s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec) {
     return -1;
-    }
-  else if(s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec)
-    {
+  } else if (s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec) {
     return 1;
-    }
-# else
+  }
+#else
   // Compare using 1 second resolution.
-  if(s1->st_mtime < s2->st_mtime)
-    {
+  if (s1->st_mtime < s2->st_mtime) {
     return -1;
-    }
-  else if(s1->st_mtime > s2->st_mtime)
-    {
+  } else if (s1->st_mtime > s2->st_mtime) {
     return 1;
-    }
-# endif
+  }
+#endif
   // Files have the same time.
   return 0;
 #else
@@ -203,60 +174,44 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
                                                cmFileTimeComparison_Type* s2)
 {
 #if !defined(_WIN32) || defined(__CYGWIN__)
-# if CMake_STAT_HAS_ST_MTIM
+#if CMake_STAT_HAS_ST_MTIM
   // Times are integers in units of 1ns.
   long long bil = 1000000000;
   long long t1 = s1->st_mtim.tv_sec * bil + s1->st_mtim.tv_nsec;
   long long t2 = s2->st_mtim.tv_sec * bil + s2->st_mtim.tv_nsec;
-  if(t1 < t2)
-    {
+  if (t1 < t2) {
     return (t2 - t1) >= bil;
-    }
-  else if(t2 < t1)
-    {
+  } else if (t2 < t1) {
     return (t1 - t2) >= bil;
-    }
-  else
-    {
+  } else {
     return false;
-    }
-# elif CMake_STAT_HAS_ST_MTIMESPEC
+  }
+#elif CMake_STAT_HAS_ST_MTIMESPEC
   // Times are integers in units of 1ns.
   long long bil = 1000000000;
   long long t1 = s1->st_mtimespec.tv_sec * bil + s1->st_mtimespec.tv_nsec;
   long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec;
-  if(t1 < t2)
-    {
+  if (t1 < t2) {
     return (t2 - t1) >= bil;
-    }
-  else if(t2 < t1)
-    {
+  } else if (t2 < t1) {
     return (t1 - t2) >= bil;
-    }
-  else
-    {
+  } else {
     return false;
-    }
-# else
+  }
+#else
   // Times are integers in units of 1s.
-  if(s1->st_mtime < s2->st_mtime)
-    {
+  if (s1->st_mtime < s2->st_mtime) {
     return (s2->st_mtime - s1->st_mtime) >= 1;
-    }
-  else if(s1->st_mtime > s2->st_mtime)
-    {
+  } else if (s1->st_mtime > s2->st_mtime) {
     return (s1->st_mtime - s2->st_mtime) >= 1;
-    }
-  else
-    {
+  } else {
     return false;
-    }
-# endif
+  }
+#endif
 #else
   // Times are integers in units of 100ns.
   LARGE_INTEGER t1;
@@ -265,60 +220,44 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
   t1.HighPart = s1->dwHighDateTime;
   t2.LowPart = s2->dwLowDateTime;
   t2.HighPart = s2->dwHighDateTime;
-  if(t1.QuadPart < t2.QuadPart)
-    {
+  if (t1.QuadPart < t2.QuadPart) {
     return (t2.QuadPart - t1.QuadPart) >= static_cast<LONGLONG>(10000000);
-    }
-  else if(t2.QuadPart < t1.QuadPart)
-    {
+  } else if (t2.QuadPart < t1.QuadPart) {
     return (t1.QuadPart - t2.QuadPart) >= static_cast<LONGLONG>(10000000);
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
-                                                   const char* f2,
-                                                   int* result)
+                                                   const char* f2, int* result)
 {
   // Get the modification time for each file.
   cmFileTimeComparison_Type s1;
   cmFileTimeComparison_Type s2;
-  if(this->Stat(f1, &s1) &&
-     this->Stat(f2, &s2))
-    {
+  if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) {
     // Compare the two modification times.
     *result = this->Compare(&s1, &s2);
     return true;
-    }
-  else
-    {
+  } else {
     // No comparison available.  Default to the same time.
     *result = 0;
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
                                                    const char* f2)
 {
   // Get the modification time for each file.
   cmFileTimeComparison_Type s1;
   cmFileTimeComparison_Type s2;
-  if(this->Stat(f1, &s1) &&
-     this->Stat(f2, &s2))
-    {
+  if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) {
     // Compare the two modification times.
     return this->TimesDiffer(&s1, &s2);
-    }
-  else
-    {
+  } else {
     // No comparison available.  Default to different times.
     return true;
-    }
+  }
 }
diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h
index cc1ef63..409bd64 100644
--- a/Source/cmFileTimeComparison.h
+++ b/Source/cmFileTimeComparison.h
@@ -42,10 +42,7 @@ public:
   bool FileTimesDiffer(const char* f1, const char* f2);
 
 protected:
-
   cmFileTimeComparisonInternal* Internals;
 };
 
-
 #endif
-
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index fa9b381..082bbf0 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -22,62 +22,48 @@ cmFindBase::cmFindBase()
   this->NamesPerDirAllowed = false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
 {
-  if(argsIn.size() < 2 )
-    {
+  if (argsIn.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // copy argsIn into args so it can be modified,
   // in the process extract the DOC "documentation"
   size_t size = argsIn.size();
   std::vector<std::string> args;
   bool foundDoc = false;
-  for(unsigned int j = 0; j < size; ++j)
-    {
-    if(foundDoc  || argsIn[j] != "DOC" )
-      {
-      if(argsIn[j] == "ENV")
-        {
-        if(j+1 < size)
-          {
+  for (unsigned int j = 0; j < size; ++j) {
+    if (foundDoc || argsIn[j] != "DOC") {
+      if (argsIn[j] == "ENV") {
+        if (j + 1 < size) {
           j++;
           cmSystemTools::GetPath(args, argsIn[j].c_str());
-          }
         }
-      else
-        {
+      } else {
         args.push_back(argsIn[j]);
-        }
       }
-    else
-      {
-      if(j+1 < size)
-        {
+    } else {
+      if (j + 1 < size) {
         foundDoc = true;
-        this->VariableDocumentation = argsIn[j+1];
+        this->VariableDocumentation = argsIn[j + 1];
         j++;
-        if(j >= size)
-          {
+        if (j >= size) {
           break;
-          }
         }
       }
     }
-  if(args.size() < 2 )
-    {
+  }
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   this->VariableName = args[0];
-  if(this->CheckForVariableInCache())
-    {
+  if (this->CheckForVariableInCache()) {
     this->AlreadyInCache = true;
     return true;
-    }
+  }
   this->AlreadyInCache = false;
 
   // Find the current root path mode.
@@ -87,107 +73,81 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
   this->SelectDefaultMacMode();
 
   bool newStyle = false;
-  enum Doing { DoingNone, DoingNames, DoingPaths, DoingPathSuffixes,
-               DoingHints };
+  enum Doing
+  {
+    DoingNone,
+    DoingNames,
+    DoingPaths,
+    DoingPathSuffixes,
+    DoingHints
+  };
   Doing doing = DoingNames; // assume it starts with a name
-  for (unsigned int j = 1; j < args.size(); ++j)
-    {
-    if(args[j] == "NAMES")
-      {
+  for (unsigned int j = 1; j < args.size(); ++j) {
+    if (args[j] == "NAMES") {
       doing = DoingNames;
       newStyle = true;
-      }
-    else if (args[j] == "PATHS")
-      {
+    } else if (args[j] == "PATHS") {
       doing = DoingPaths;
       newStyle = true;
-      }
-    else if (args[j] == "HINTS")
-      {
+    } else if (args[j] == "HINTS") {
       doing = DoingHints;
       newStyle = true;
-      }
-    else if (args[j] == "PATH_SUFFIXES")
-      {
+    } else if (args[j] == "PATH_SUFFIXES") {
       doing = DoingPathSuffixes;
       newStyle = true;
-      }
-    else if (args[j] == "NAMES_PER_DIR")
-      {
+    } else if (args[j] == "NAMES_PER_DIR") {
       doing = DoingNone;
-      if(this->NamesPerDirAllowed)
-        {
+      if (this->NamesPerDirAllowed) {
         this->NamesPerDir = true;
-        }
-      else
-        {
+      } else {
         this->SetError("does not support NAMES_PER_DIR");
         return false;
-        }
       }
-    else if (args[j] == "NO_SYSTEM_PATH")
-      {
+    } else if (args[j] == "NO_SYSTEM_PATH") {
       doing = DoingNone;
       this->NoDefaultPath = true;
-      }
-    else if (this->CheckCommonArgument(args[j]))
-      {
+    } else if (this->CheckCommonArgument(args[j])) {
       doing = DoingNone;
       // Some common arguments were accidentally supported by CMake
       // 2.4 and 2.6.0 in the short-hand form of the command, so we
       // must support it even though it is not documented.
-      }
-    else if(doing == DoingNames)
-      {
+    } else if (doing == DoingNames) {
       this->Names.push_back(args[j]);
-      }
-    else if(doing == DoingPaths)
-      {
+    } else if (doing == DoingPaths) {
       this->UserGuessArgs.push_back(args[j]);
-      }
-    else if(doing == DoingHints)
-      {
+    } else if (doing == DoingHints) {
       this->UserHintsArgs.push_back(args[j]);
-      }
-    else if(doing == DoingPathSuffixes)
-      {
+    } else if (doing == DoingPathSuffixes) {
       this->AddPathSuffix(args[j]);
-      }
     }
+  }
 
-  if(this->VariableDocumentation.empty())
-    {
+  if (this->VariableDocumentation.empty()) {
     this->VariableDocumentation = "Where can ";
-    if(this->Names.empty())
-      {
+    if (this->Names.empty()) {
       this->VariableDocumentation += "the (unknown) library be found";
-      }
-    else if(this->Names.size() == 1)
-      {
-      this->VariableDocumentation += "the "
-        + this->Names[0] + " library be found";
-      }
-    else
-      {
+    } else if (this->Names.size() == 1) {
+      this->VariableDocumentation +=
+        "the " + this->Names[0] + " library be found";
+    } else {
       this->VariableDocumentation += "one of the ";
       this->VariableDocumentation +=
         cmJoin(cmMakeRange(this->Names).retreat(1), ", ");
-      this->VariableDocumentation += " or "
-        + this->Names[this->Names.size() - 1] + " libraries be found";
-      }
+      this->VariableDocumentation +=
+        " or " + this->Names[this->Names.size() - 1] + " libraries be found";
     }
+  }
 
   // look for old style
   // FIND_*(VAR name path1 path2 ...)
-  if(!newStyle)
-    {
+  if (!newStyle) {
     // All the short-hand arguments have been recorded as names.
     std::vector<std::string> shortArgs = this->Names;
     this->Names.clear(); // clear out any values in Names
     this->Names.push_back(shortArgs[0]);
     this->UserGuessArgs.insert(this->UserGuessArgs.end(),
                                shortArgs.begin() + 1, shortArgs.end());
-    }
+  }
   this->ExpandPaths();
 
   this->ComputeFinalPaths();
@@ -197,36 +157,29 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
 
 void cmFindBase::ExpandPaths()
 {
-  if(!this->NoDefaultPath)
-    {
-    if(!this->NoCMakePath)
-      {
+  if (!this->NoDefaultPath) {
+    if (!this->NoCMakePath) {
       this->FillCMakeVariablePath();
-      }
-    if(!this->NoCMakeEnvironmentPath)
-      {
+    }
+    if (!this->NoCMakeEnvironmentPath) {
       this->FillCMakeEnvironmentPath();
-      }
     }
+  }
   this->FillUserHintsPath();
-  if(!this->NoDefaultPath)
-    {
-    if(!this->NoSystemEnvironmentPath)
-      {
+  if (!this->NoDefaultPath) {
+    if (!this->NoSystemEnvironmentPath) {
       this->FillSystemEnvironmentPath();
-      }
-    if(!this->NoCMakeSystemPath)
-      {
+    }
+    if (!this->NoCMakeSystemPath) {
       this->FillCMakeSystemVariablePath();
-      }
     }
+  }
   this->FillUserGuessPath();
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::FillCMakeEnvironmentPath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
 
   // Add CMAKE_*_PATH environment variables
   std::string var = "CMAKE_";
@@ -235,21 +188,17 @@ void cmFindBase::FillCMakeEnvironmentPath()
   paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH");
   paths.AddEnvPath(var);
 
-  if(this->CMakePathName == "PROGRAM")
-    {
+  if (this->CMakePathName == "PROGRAM") {
     paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
-    }
-  else
-    {
+  } else {
     paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
-    }
+  }
   paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::FillCMakeVariablePath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::CMake];
 
   // Add CMake varibles of the same name as the previous environment
   // varibles CMAKE_*_PATH to be used most of the time with -D
@@ -260,37 +209,35 @@ void cmFindBase::FillCMakeVariablePath()
   paths.AddCMakePrefixPath("CMAKE_PREFIX_PATH");
   paths.AddCMakePath(var);
 
-  if(this->CMakePathName == "PROGRAM")
-    {
+  if (this->CMakePathName == "PROGRAM") {
     paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
-    }
-  else
-    {
+  } else {
     paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
-    }
+  }
   paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::FillSystemEnvironmentPath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::SystemEnvironment];
 
   // Add LIB or INCLUDE
-  if(!this->EnvironmentPath.empty())
-    {
+  if (!this->EnvironmentPath.empty()) {
     paths.AddEnvPath(this->EnvironmentPath);
+#if defined(_WIN32) || defined(__CYGWIN__)
     paths.AddEnvPrefixPath("PATH", true);
-    }
-  // Add PATH
-  paths.AddEnvPath("PATH");
+    paths.AddEnvPath("PATH");
+#endif
+  } else {
+    // Add PATH
+    paths.AddEnvPath("PATH");
+  }
   paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::FillCMakeSystemVariablePath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeSystem];
 
   std::string var = "CMAKE_SYSTEM_";
   var += this->CMakePathName;
@@ -298,44 +245,38 @@ void cmFindBase::FillCMakeSystemVariablePath()
   paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
   paths.AddCMakePath(var);
 
-  if(this->CMakePathName == "PROGRAM")
-    {
+  if (this->CMakePathName == "PROGRAM") {
     paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
-    }
-  else
-    {
+  } else {
     paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
-    }
+  }
   paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::FillUserHintsPath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
 
-  for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin();
-      p != this->UserHintsArgs.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p =
+         this->UserHintsArgs.begin();
+       p != this->UserHintsArgs.end(); ++p) {
     paths.AddUserPath(*p);
-    }
+  }
   paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::FillUserGuessPath()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
 
-  for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin();
-      p != this->UserGuessArgs.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p =
+         this->UserGuessArgs.begin();
+       p != this->UserGuessArgs.end(); ++p) {
     paths.AddUserPath(*p);
-    }
+  }
   paths.AddSuffixes(this->SearchPathSuffixes);
 }
 
-//----------------------------------------------------------------------------
 void cmFindBase::PrintFindStuff()
 {
   std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
@@ -345,14 +286,13 @@ void cmFindBase::PrintFindStuff()
   std::cerr << "SearchAppBundleOnly: " << this->SearchAppBundleOnly << "\n";
   std::cerr << "SearchAppBundleFirst: " << this->SearchAppBundleFirst << "\n";
   std::cerr << "VariableName " << this->VariableName << "\n";
-  std::cerr << "VariableDocumentation "
-            << this->VariableDocumentation << "\n";
+  std::cerr << "VariableDocumentation " << this->VariableDocumentation << "\n";
   std::cerr << "NoDefaultPath " << this->NoDefaultPath << "\n";
-  std::cerr << "NoCMakeEnvironmentPath "
-            << this->NoCMakeEnvironmentPath << "\n";
+  std::cerr << "NoCMakeEnvironmentPath " << this->NoCMakeEnvironmentPath
+            << "\n";
   std::cerr << "NoCMakePath " << this->NoCMakePath << "\n";
-  std::cerr << "NoSystemEnvironmentPath "
-            << this->NoSystemEnvironmentPath << "\n";
+  std::cerr << "NoSystemEnvironmentPath " << this->NoSystemEnvironmentPath
+            << "\n";
   std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
   std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
   std::cerr << "CMakePathName " << this->CMakePathName << "\n";
@@ -366,32 +306,28 @@ void cmFindBase::PrintFindStuff()
 
 bool cmFindBase::CheckForVariableInCache()
 {
-  if(const char* cacheValue =
-     this->Makefile->GetDefinition(this->VariableName))
-    {
+  if (const char* cacheValue =
+        this->Makefile->GetDefinition(this->VariableName)) {
     cmState* state = this->Makefile->GetState();
     const char* cacheEntry = state->GetCacheEntryValue(this->VariableName);
     bool found = !cmSystemTools::IsNOTFOUND(cacheValue);
     bool cached = cacheEntry ? true : false;
-    if(found)
-      {
+    if (found) {
       // If the user specifies the entry on the command line without a
       // type we should add the type and docstring but keep the
       // original value.  Tell the subclass implementations to do
       // this.
-      if(cached && state->GetCacheEntryType(this->VariableName)
-                                            == cmState::UNINITIALIZED)
-        {
+      if (cached &&
+          state->GetCacheEntryType(this->VariableName) ==
+            cmState::UNINITIALIZED) {
         this->AlreadyInCacheWithoutMetaInfo = true;
-        }
-      return true;
-      }
-    else if(cached)
-      {
-      const char* hs = state->GetCacheEntryProperty(this->VariableName,
-                                                     "HELPSTRING");
-      this->VariableDocumentation = hs?hs:"(none)";
       }
+      return true;
+    } else if (cached) {
+      const char* hs =
+        state->GetCacheEntryProperty(this->VariableName, "HELPSTRING");
+      this->VariableDocumentation = hs ? hs : "(none)";
     }
+  }
   return false;
 }
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 8ca311d..054c33b 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -52,6 +52,7 @@ protected:
 
   bool AlreadyInCache;
   bool AlreadyInCacheWithoutMetaInfo;
+
 private:
   // Add pieces of the search.
   void FillCMakeVariablePath();
@@ -62,6 +63,4 @@ private:
   void FillUserGuessPath();
 };
 
-
-
 #endif
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 913985f..638c1d1 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -10,21 +10,20 @@
   See the License for more information.
 ============================================================================*/
 #include "cmFindCommon.h"
-#include <functional>
+
 #include <algorithm>
+#include <functional>
 
-//----------------------------------------------------------------------------
 cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
 cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE");
-cmFindCommon::PathLabel
-  cmFindCommon::PathLabel::CMakeEnvironment("CMAKE_ENVIRONMENT");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeEnvironment(
+  "CMAKE_ENVIRONMENT");
 cmFindCommon::PathLabel cmFindCommon::PathLabel::Hints("HINTS");
-cmFindCommon::PathLabel
-  cmFindCommon::PathLabel::SystemEnvironment("SYSTM_ENVIRONMENT");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::SystemEnvironment(
+  "SYSTM_ENVIRONMENT");
 cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM");
 cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS");
 
-//----------------------------------------------------------------------------
 cmFindCommon::cmFindCommon()
 {
   this->FindRootPathMode = RootPathModeBoth;
@@ -34,8 +33,8 @@ cmFindCommon::cmFindCommon()
   this->NoSystemEnvironmentPath = false;
   this->NoCMakeSystemPath = false;
 
-  // OS X Bundle and Framework search policy.  The default is to
-  // search frameworks first on apple.
+// OS X Bundle and Framework search policy.  The default is to
+// search frameworks first on apple.
 #if defined(__APPLE__)
   this->SearchFrameworkFirst = true;
   this->SearchAppBundleFirst = true;
@@ -51,12 +50,10 @@ cmFindCommon::cmFindCommon()
   this->InitializeSearchPathGroups();
 }
 
-//----------------------------------------------------------------------------
 cmFindCommon::~cmFindCommon()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::InitializeSearchPathGroups()
 {
   std::vector<PathLabel>* labels;
@@ -76,21 +73,20 @@ void cmFindCommon::InitializeSearchPathGroups()
   this->PathGroupOrder.push_back(PathGroup::All);
 
   // Create the idividual labeld search paths
-  this->LabeledPaths.insert(std::make_pair(PathLabel::CMake,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeEnvironment,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::Hints,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::SystemEnvironment,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeSystem,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::Guess,
-    cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::CMake, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::CMakeEnvironment, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::Hints, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::SystemEnvironment, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::CMakeSystem, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::Guess, cmSearchPath(this)));
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::SelectDefaultRootPathMode()
 {
   // Check the policy variable for this find command type.
@@ -98,77 +94,56 @@ void cmFindCommon::SelectDefaultRootPathMode()
   findRootPathVar += this->CMakePathName;
   std::string rootPathMode =
     this->Makefile->GetSafeDefinition(findRootPathVar);
-  if (rootPathMode=="NEVER")
-    {
+  if (rootPathMode == "NEVER") {
     this->FindRootPathMode = RootPathModeNever;
-    }
-  else if (rootPathMode=="ONLY")
-    {
+  } else if (rootPathMode == "ONLY") {
     this->FindRootPathMode = RootPathModeOnly;
-    }
-  else if (rootPathMode=="BOTH")
-    {
+  } else if (rootPathMode == "BOTH") {
     this->FindRootPathMode = RootPathModeBoth;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::SelectDefaultMacMode()
 {
   std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK");
-  if(ff == "NEVER")
-    {
+  if (ff == "NEVER") {
     this->SearchFrameworkLast = false;
     this->SearchFrameworkFirst = false;
     this->SearchFrameworkOnly = false;
-    }
-  else if(ff == "ONLY")
-    {
+  } else if (ff == "ONLY") {
     this->SearchFrameworkLast = false;
     this->SearchFrameworkFirst = false;
     this->SearchFrameworkOnly = true;
-    }
-  else if(ff == "FIRST")
-    {
+  } else if (ff == "FIRST") {
     this->SearchFrameworkLast = false;
     this->SearchFrameworkFirst = true;
     this->SearchFrameworkOnly = false;
-    }
-  else if(ff == "LAST")
-    {
+  } else if (ff == "LAST") {
     this->SearchFrameworkLast = true;
     this->SearchFrameworkFirst = false;
     this->SearchFrameworkOnly = false;
-    }
+  }
 
   std::string fab = this->Makefile->GetSafeDefinition("CMAKE_FIND_APPBUNDLE");
-  if(fab == "NEVER")
-    {
+  if (fab == "NEVER") {
     this->SearchAppBundleLast = false;
     this->SearchAppBundleFirst = false;
     this->SearchAppBundleOnly = false;
-    }
-  else if(fab == "ONLY")
-    {
+  } else if (fab == "ONLY") {
     this->SearchAppBundleLast = false;
     this->SearchAppBundleFirst = false;
     this->SearchAppBundleOnly = true;
-    }
-  else if(fab == "FIRST")
-    {
+  } else if (fab == "FIRST") {
     this->SearchAppBundleLast = false;
     this->SearchAppBundleFirst = true;
     this->SearchAppBundleOnly = false;
-    }
-  else if(fab == "LAST")
-    {
+  } else if (fab == "LAST") {
     this->SearchAppBundleLast = true;
     this->SearchAppBundleFirst = false;
     this->SearchAppBundleOnly = false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
 {
 #if 0
@@ -179,128 +154,105 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
     }
 #endif
   // Short-circuit if there is nothing to do.
-  if(this->FindRootPathMode == RootPathModeNever)
-    {
+  if (this->FindRootPathMode == RootPathModeNever) {
     return;
-    }
+  }
 
-  const char* sysroot =
-    this->Makefile->GetDefinition("CMAKE_SYSROOT");
-  const char* rootPath =
-    this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH");
+  const char* sysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT");
+  const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH");
   const bool noSysroot = !sysroot || !*sysroot;
   const bool noRootPath = !rootPath || !*rootPath;
-  if(noSysroot && noRootPath)
-    {
+  if (noSysroot && noRootPath) {
     return;
-    }
+  }
 
   // Construct the list of path roots with no trailing slashes.
   std::vector<std::string> roots;
-  if (rootPath)
-    {
+  if (rootPath) {
     cmSystemTools::ExpandListArgument(rootPath, roots);
-    }
-  if (sysroot)
-    {
+  }
+  if (sysroot) {
     roots.push_back(sysroot);
-    }
-  for(std::vector<std::string>::iterator ri = roots.begin();
-      ri != roots.end(); ++ri)
-    {
+  }
+  for (std::vector<std::string>::iterator ri = roots.begin();
+       ri != roots.end(); ++ri) {
     cmSystemTools::ConvertToUnixSlashes(*ri);
-    }
+  }
 
   const char* stagePrefix =
-      this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
+    this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
 
   // Copy the original set of unrooted paths.
   std::vector<std::string> unrootedPaths = paths;
   paths.clear();
 
-  for(std::vector<std::string>::const_iterator ri = roots.begin();
-      ri != roots.end(); ++ri)
-    {
-    for(std::vector<std::string>::const_iterator ui = unrootedPaths.begin();
-        ui != unrootedPaths.end(); ++ui)
-      {
+  for (std::vector<std::string>::const_iterator ri = roots.begin();
+       ri != roots.end(); ++ri) {
+    for (std::vector<std::string>::const_iterator ui = unrootedPaths.begin();
+         ui != unrootedPaths.end(); ++ui) {
       // Place the unrooted path under the current root if it is not
       // already inside.  Skip the unrooted path if it is relative to
       // a user home directory or is empty.
       std::string rootedDir;
-      if(cmSystemTools::IsSubDirectory(*ui, *ri)
-          || (stagePrefix
-            && cmSystemTools::IsSubDirectory(*ui, stagePrefix)))
-        {
+      if (cmSystemTools::IsSubDirectory(*ui, *ri) ||
+          (stagePrefix && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) {
         rootedDir = *ui;
-        }
-      else if(!ui->empty() && (*ui)[0] != '~')
-        {
+      } else if (!ui->empty() && (*ui)[0] != '~') {
         // Start with the new root.
         rootedDir = *ri;
         rootedDir += "/";
 
         // Append the original path with its old root removed.
         rootedDir += cmSystemTools::SplitPathRootComponent(*ui);
-        }
+      }
 
       // Store the new path.
       paths.push_back(rootedDir);
-      }
     }
+  }
 
   // If searching both rooted and unrooted paths add the original
   // paths again.
-  if(this->FindRootPathMode == RootPathModeBoth)
-    {
+  if (this->FindRootPathMode == RootPathModeBoth) {
     paths.insert(paths.end(), unrootedPaths.begin(), unrootedPaths.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::FilterPaths(const std::vector<std::string>& inPaths,
                                const std::set<std::string>& ignore,
                                std::vector<std::string>& outPaths)
 {
-  for(std::vector<std::string>::const_iterator i = inPaths.begin();
-      i != inPaths.end(); ++i)
-    {
-    if(ignore.count(*i) == 0)
-      {
+  for (std::vector<std::string>::const_iterator i = inPaths.begin();
+       i != inPaths.end(); ++i) {
+    if (ignore.count(*i) == 0) {
       outPaths.push_back(*i);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore)
 {
   // null-terminated list of paths.
-  static const char *paths[] =
-    { "CMAKE_SYSTEM_IGNORE_PATH", "CMAKE_IGNORE_PATH", 0 };
+  static const char* paths[] = { "CMAKE_SYSTEM_IGNORE_PATH",
+                                 "CMAKE_IGNORE_PATH", 0 };
 
   // Construct the list of path roots with no trailing slashes.
-  for(const char **pathName = paths; *pathName; ++pathName)
-    {
+  for (const char** pathName = paths; *pathName; ++pathName) {
     // Get the list of paths to ignore from the variable.
     const char* ignorePath = this->Makefile->GetDefinition(*pathName);
-    if((ignorePath == 0) || (strlen(ignorePath) == 0))
-      {
+    if ((ignorePath == 0) || (strlen(ignorePath) == 0)) {
       continue;
-      }
+    }
 
     cmSystemTools::ExpandListArgument(ignorePath, ignore);
-    }
+  }
 
-  for(std::vector<std::string>::iterator i = ignore.begin();
-      i != ignore.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = ignore.begin();
+       i != ignore.end(); ++i) {
     cmSystemTools::ConvertToUnixSlashes(*i);
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore)
 {
   std::vector<std::string> ignoreVec;
@@ -308,89 +260,63 @@ void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore)
   ignore.insert(ignoreVec.begin(), ignoreVec.end());
 }
 
-//----------------------------------------------------------------------------
 bool cmFindCommon::CheckCommonArgument(std::string const& arg)
 {
-  if(arg == "NO_DEFAULT_PATH")
-    {
+  if (arg == "NO_DEFAULT_PATH") {
     this->NoDefaultPath = true;
-    }
-  else if(arg == "NO_CMAKE_ENVIRONMENT_PATH")
-    {
+  } else if (arg == "NO_CMAKE_ENVIRONMENT_PATH") {
     this->NoCMakeEnvironmentPath = true;
-    }
-  else if(arg == "NO_CMAKE_PATH")
-    {
+  } else if (arg == "NO_CMAKE_PATH") {
     this->NoCMakePath = true;
-    }
-  else if(arg == "NO_SYSTEM_ENVIRONMENT_PATH")
-    {
+  } else if (arg == "NO_SYSTEM_ENVIRONMENT_PATH") {
     this->NoSystemEnvironmentPath = true;
-    }
-  else if(arg == "NO_CMAKE_SYSTEM_PATH")
-    {
+  } else if (arg == "NO_CMAKE_SYSTEM_PATH") {
     this->NoCMakeSystemPath = true;
-    }
-    else if(arg == "NO_CMAKE_FIND_ROOT_PATH")
-    {
+  } else if (arg == "NO_CMAKE_FIND_ROOT_PATH") {
     this->FindRootPathMode = RootPathModeNever;
-    }
-  else if(arg == "ONLY_CMAKE_FIND_ROOT_PATH")
-    {
+  } else if (arg == "ONLY_CMAKE_FIND_ROOT_PATH") {
     this->FindRootPathMode = RootPathModeOnly;
-    }
-  else if(arg == "CMAKE_FIND_ROOT_PATH_BOTH")
-    {
+  } else if (arg == "CMAKE_FIND_ROOT_PATH_BOTH") {
     this->FindRootPathMode = RootPathModeBoth;
-    }
-  else
-    {
+  } else {
     // The argument is not one of the above.
     return false;
-    }
+  }
 
   // The argument is one of the above.
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::AddPathSuffix(std::string const& arg)
 {
   std::string suffix = arg;
 
   // Strip leading and trailing slashes.
-  if(suffix.empty())
-    {
+  if (suffix.empty()) {
     return;
-    }
-  if(suffix[0] == '/')
-    {
+  }
+  if (suffix[0] == '/') {
     suffix = suffix.substr(1, suffix.npos);
-    }
-  if(suffix.empty())
-    {
+  }
+  if (suffix.empty()) {
     return;
-    }
-  if(suffix[suffix.size()-1] == '/')
-    {
-    suffix = suffix.substr(0, suffix.size()-1);
-    }
-  if(suffix.empty())
-    {
+  }
+  if (suffix[suffix.size() - 1] == '/') {
+    suffix = suffix.substr(0, suffix.size() - 1);
+  }
+  if (suffix.empty()) {
     return;
-    }
+  }
 
   // Store the suffix.
   this->SearchPathSuffixes.push_back(suffix);
 }
 
-//----------------------------------------------------------------------------
 void AddTrailingSlash(std::string& s)
 {
-  if(!s.empty() && *s.rbegin() != '/')
-    {
+  if (!s.empty() && *s.rbegin() != '/') {
     s += '/';
-    }
+  }
 }
 void cmFindCommon::ComputeFinalPaths()
 {
@@ -401,11 +327,10 @@ void cmFindCommon::ComputeFinalPaths()
   // Combine the seperate path types, filtering out ignores
   this->SearchPaths.clear();
   std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All];
-  for(std::vector<PathLabel>::const_iterator l = allLabels.begin();
-      l != allLabels.end(); ++l)
-    {
+  for (std::vector<PathLabel>::const_iterator l = allLabels.begin();
+       l != allLabels.end(); ++l) {
     this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths);
-    }
+  }
 
   // Expand list of paths inside all search roots.
   this->RerootPaths(this->SearchPaths);
@@ -415,16 +340,14 @@ void cmFindCommon::ComputeFinalPaths()
                 &AddTrailingSlash);
 }
 
-//----------------------------------------------------------------------------
 void cmFindCommon::SetMakefile(cmMakefile* makefile)
 {
   cmCommand::SetMakefile(makefile);
 
   // If we are building for Apple (OSX or also iphone), make sure
   // that frameworks and bundles are searched first.
-  if(this->Makefile->IsOn("APPLE"))
-    {
+  if (this->Makefile->IsOn("APPLE")) {
     this->SearchFrameworkFirst = true;
     this->SearchAppBundleFirst = true;
-    }
+  }
 }
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 3fefc8d..ebec884 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -13,8 +13,8 @@
 #define cmFindCommon_h
 
 #include "cmCommand.h"
-#include "cmSearchPath.h"
 #include "cmPathLabel.h"
+#include "cmSearchPath.h"
 
 /** \class cmFindCommon
  * \brief Base class for FIND_XXX implementations.
@@ -38,8 +38,12 @@ protected:
   {
   protected:
     PathGroup();
+
   public:
-    PathGroup(const std::string& label) : cmPathLabel(label) { }
+    PathGroup(const std::string& label)
+      : cmPathLabel(label)
+    {
+    }
     static PathGroup All;
   };
 
@@ -48,8 +52,12 @@ protected:
   {
   protected:
     PathLabel();
+
   public:
-    PathLabel(const std::string& label) : cmPathLabel(label) { }
+    PathLabel(const std::string& label)
+      : cmPathLabel(label)
+    {
+    }
     static PathLabel CMake;
     static PathLabel CMakeEnvironment;
     static PathLabel Hints;
@@ -58,9 +66,12 @@ protected:
     static PathLabel Guess;
   };
 
-  enum RootPathMode { RootPathModeNever,
-                      RootPathModeOnly,
-                      RootPathModeBoth };
+  enum RootPathMode
+  {
+    RootPathModeNever,
+    RootPathModeOnly,
+    RootPathModeBoth
+  };
 
   /** Construct the various path groups and labels */
   void InitializeSearchPathGroups();
diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx
index 615e7c1..a6666ba 100644
--- a/Source/cmFindFileCommand.cxx
+++ b/Source/cmFindFileCommand.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmFindFileCommand.h"
+
 #include "cmSystemTools.h"
 
 cmFindFileCommand::cmFindFileCommand()
diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h
index daf1d65..74b01f1 100644
--- a/Source/cmFindFileCommand.h
+++ b/Source/cmFindFileCommand.h
@@ -29,15 +29,10 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFindFileCommand;
-    }
-  virtual std::string GetName() const { return "find_file";}
+  virtual cmCommand* Clone() { return new cmFindFileCommand; }
+  virtual std::string GetName() const { return "find_file"; }
 
   cmTypeMacro(cmFindFileCommand, cmFindPathCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index e7696af..a4d4dbb 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmFindLibraryCommand.h"
+
 #include <cmsys/Directory.hxx>
 
 cmFindLibraryCommand::cmFindLibraryCommand()
@@ -19,142 +20,118 @@ cmFindLibraryCommand::cmFindLibraryCommand()
 }
 
 // cmFindLibraryCommand
-bool cmFindLibraryCommand
-::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
+bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn,
+                                       cmExecutionStatus&)
 {
   this->VariableDocumentation = "Path to a library.";
   this->CMakePathName = "LIBRARY";
-  if(!this->ParseArguments(argsIn))
-    {
+  if (!this->ParseArguments(argsIn)) {
     return false;
-    }
-  if(this->AlreadyInCache)
-    {
+  }
+  if (this->AlreadyInCache) {
     // If the user specifies the entry on the command line without a
     // type we should add the type and docstring but keep the original
     // value.
-    if(this->AlreadyInCacheWithoutMetaInfo)
-      {
+    if (this->AlreadyInCacheWithoutMetaInfo) {
       this->Makefile->AddCacheDefinition(this->VariableName, "",
                                          this->VariableDocumentation.c_str(),
                                          cmState::FILEPATH);
-      }
-    return true;
     }
+    return true;
+  }
 
-  if(const char* abi_name =
-     this->Makefile->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI"))
-    {
+  if (const char* abi_name =
+        this->Makefile->GetDefinition("CMAKE_INTERNAL_PLATFORM_ABI")) {
     std::string abi = abi_name;
-    if(abi.find("ELF N32") != abi.npos)
-      {
+    if (abi.find("ELF N32") != abi.npos) {
       // Convert lib to lib32.
       this->AddArchitecturePaths("32");
-      }
     }
+  }
 
-  if(this->Makefile->GetState()
-         ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS"))
-    {
+  if (this->Makefile->GetState()->GetGlobalPropertyAsBool(
+        "FIND_LIBRARY_USE_LIB64_PATHS")) {
     // add special 64 bit paths if this is a 64 bit compile.
-    if(this->Makefile->PlatformIs64Bit())
-      {
+    if (this->Makefile->PlatformIs64Bit()) {
       this->AddArchitecturePaths("64");
-      }
     }
+  }
 
   std::string library = this->FindLibrary();
-  if(library != "")
-    {
+  if (library != "") {
     // Save the value in the cache
-    this->Makefile->AddCacheDefinition(this->VariableName,
-                                       library.c_str(),
+    this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(),
                                        this->VariableDocumentation.c_str(),
                                        cmState::FILEPATH);
     return true;
-    }
+  }
   std::string notfound = this->VariableName + "-NOTFOUND";
-  this->Makefile->AddCacheDefinition(this->VariableName,
-                                     notfound.c_str(),
+  this->Makefile->AddCacheDefinition(this->VariableName, notfound.c_str(),
                                      this->VariableDocumentation.c_str(),
                                      cmState::FILEPATH);
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
 {
   std::vector<std::string> original;
   original.swap(this->SearchPaths);
-  for(std::vector<std::string>::const_iterator i = original.begin();
-      i != original.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = original.begin();
+       i != original.end(); ++i) {
     this->AddArchitecturePath(*i, 0, suffix);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindLibraryCommand::AddArchitecturePath(
-  std::string const& dir, std::string::size_type start_pos,
-  const char* suffix, bool fresh)
+  std::string const& dir, std::string::size_type start_pos, const char* suffix,
+  bool fresh)
 {
   std::string::size_type pos = dir.find("lib/", start_pos);
-  if(pos != std::string::npos)
-    {
-    std::string cur_dir  = dir.substr(0,pos+3);
+  if (pos != std::string::npos) {
+    std::string cur_dir = dir.substr(0, pos + 3);
 
     // Follow "lib<suffix>".
     std::string next_dir = cur_dir + suffix;
-    if(cmSystemTools::FileIsDirectory(next_dir))
-      {
-      next_dir += dir.substr(pos+3);
-      std::string::size_type next_pos = pos+3+strlen(suffix)+1;
+    if (cmSystemTools::FileIsDirectory(next_dir)) {
+      next_dir += dir.substr(pos + 3);
+      std::string::size_type next_pos = pos + 3 + strlen(suffix) + 1;
       this->AddArchitecturePath(next_dir, next_pos, suffix);
-      }
+    }
 
     // Follow "lib".
-    if(cmSystemTools::FileIsDirectory(cur_dir))
-      {
-      this->AddArchitecturePath(dir, pos+3+1, suffix, false);
-      }
+    if (cmSystemTools::FileIsDirectory(cur_dir)) {
+      this->AddArchitecturePath(dir, pos + 3 + 1, suffix, false);
     }
-  if(fresh)
-    {
+  }
+  if (fresh) {
     // Check for <dir><suffix>/.
-    std::string cur_dir  = dir + suffix + "/";
-    if(cmSystemTools::FileIsDirectory(cur_dir))
-      {
+    std::string cur_dir = dir + suffix + "/";
+    if (cmSystemTools::FileIsDirectory(cur_dir)) {
       this->SearchPaths.push_back(cur_dir);
-      }
+    }
 
     // Now add the original unchanged path
-    if(cmSystemTools::FileIsDirectory(dir))
-      {
+    if (cmSystemTools::FileIsDirectory(dir)) {
       this->SearchPaths.push_back(dir);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindLibrary()
 {
   std::string library;
-  if(this->SearchFrameworkFirst || this->SearchFrameworkOnly)
-    {
+  if (this->SearchFrameworkFirst || this->SearchFrameworkOnly) {
     library = this->FindFrameworkLibrary();
-    }
-  if(library.empty() && !this->SearchFrameworkOnly)
-    {
+  }
+  if (library.empty() && !this->SearchFrameworkOnly) {
     library = this->FindNormalLibrary();
-    }
-  if(library.empty() && this->SearchFrameworkLast)
-    {
+  }
+  if (library.empty() && this->SearchFrameworkLast) {
     library = this->FindFrameworkLibrary();
-    }
+  }
   return library;
 }
 
-//----------------------------------------------------------------------------
 struct cmFindLibraryHelper
 {
   cmFindLibraryHelper(cmMakefile* mf);
@@ -182,7 +159,10 @@ struct cmFindLibraryHelper
     bool TryRaw;
     std::string Raw;
     cmsys::RegularExpression Regex;
-    Name(): TryRaw(false) {}
+    Name()
+      : TryRaw(false)
+    {
+    }
   };
   std::vector<Name> Names;
 
@@ -192,15 +172,15 @@ struct cmFindLibraryHelper
   void RegexFromLiteral(std::string& out, std::string const& in);
   void RegexFromList(std::string& out, std::vector<std::string> const& in);
   size_type GetPrefixIndex(std::string const& prefix)
-    {
-    return std::find(this->Prefixes.begin(), this->Prefixes.end(),
-                           prefix) - this->Prefixes.begin();
-    }
+  {
+    return std::find(this->Prefixes.begin(), this->Prefixes.end(), prefix) -
+      this->Prefixes.begin();
+  }
   size_type GetSuffixIndex(std::string const& suffix)
-    {
-    return std::find(this->Suffixes.begin(), this->Suffixes.end(),
-                           suffix) - this->Suffixes.begin();
-    }
+  {
+    return std::find(this->Suffixes.begin(), this->Suffixes.end(), suffix) -
+      this->Suffixes.begin();
+  }
   bool HasValidSuffix(std::string const& name);
   void AddName(std::string const& name);
   void SetName(std::string const& name);
@@ -208,9 +188,8 @@ struct cmFindLibraryHelper
   bool CheckDirectoryForName(std::string const& path, Name& name);
 };
 
-//----------------------------------------------------------------------------
-cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf):
-  Makefile(mf)
+cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf)
+  : Makefile(mf)
 {
   this->GG = this->Makefile->GetGlobalGenerator();
 
@@ -225,33 +204,28 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf):
   this->RegexFromList(this->SuffixRegexStr, this->Suffixes);
 
   // Check whether to use OpenBSD-style library version comparisons.
-  this->OpenBSD =
-    this->Makefile->GetState()
-        ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
+  this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+    "FIND_LIBRARY_USE_OPENBSD_VERSIONING");
 }
 
-//----------------------------------------------------------------------------
 void cmFindLibraryHelper::RegexFromLiteral(std::string& out,
                                            std::string const& in)
 {
-  for(std::string::const_iterator ci = in.begin(); ci != in.end(); ++ci)
-    {
+  for (std::string::const_iterator ci = in.begin(); ci != in.end(); ++ci) {
     char ch = *ci;
-    if(ch == '[' || ch == ']' || ch == '(' || ch == ')' || ch == '\\' ||
-       ch == '.' || ch == '*' || ch == '+' || ch == '?' || ch == '-' ||
-       ch == '^' || ch == '$')
-      {
+    if (ch == '[' || ch == ']' || ch == '(' || ch == ')' || ch == '\\' ||
+        ch == '.' || ch == '*' || ch == '+' || ch == '?' || ch == '-' ||
+        ch == '^' || ch == '$') {
       out += "\\";
-      }
+    }
 #if defined(_WIN32) || defined(__APPLE__)
     out += tolower(ch);
 #else
     out += ch;
 #endif
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindLibraryHelper::RegexFromList(std::string& out,
                                         std::vector<std::string> const& in)
 {
@@ -259,47 +233,40 @@ void cmFindLibraryHelper::RegexFromList(std::string& out,
   // else and the result can be checked after matching.
   out += "(";
   const char* sep = "";
-  for(std::vector<std::string>::const_iterator si = in.begin();
-      si != in.end(); ++si)
-    {
+  for (std::vector<std::string>::const_iterator si = in.begin();
+       si != in.end(); ++si) {
     // Separate from previous item.
     out += sep;
     sep = "|";
 
     // Append this item.
     this->RegexFromLiteral(out, *si);
-    }
+  }
   out += ")";
 }
 
-//----------------------------------------------------------------------------
 bool cmFindLibraryHelper::HasValidSuffix(std::string const& name)
 {
-  for(std::vector<std::string>::const_iterator si = this->Suffixes.begin();
-      si != this->Suffixes.end(); ++si)
-    {
+  for (std::vector<std::string>::const_iterator si = this->Suffixes.begin();
+       si != this->Suffixes.end(); ++si) {
     std::string suffix = *si;
-    if(name.length() <= suffix.length())
-      {
+    if (name.length() <= suffix.length()) {
       continue;
-      }
+    }
     // Check if the given name ends in a valid library suffix.
-    if(name.substr(name.size()-suffix.length()) == suffix)
-      {
+    if (name.substr(name.size() - suffix.length()) == suffix) {
       return true;
-      }
+    }
     // Check if a valid library suffix is somewhere in the name,
     // this may happen e.g. for versioned shared libraries: libfoo.so.2
     suffix += ".";
-    if(name.find(suffix) != name.npos)
-      {
+    if (name.find(suffix) != name.npos) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmFindLibraryHelper::AddName(std::string const& name)
 {
   Name entry;
@@ -313,37 +280,31 @@ void cmFindLibraryHelper::AddName(std::string const& name)
   regex += this->PrefixRegexStr;
   this->RegexFromLiteral(regex, name);
   regex += this->SuffixRegexStr;
-  if(this->OpenBSD)
-    {
+  if (this->OpenBSD) {
     regex += "(\\.[0-9]+\\.[0-9]+)?";
-    }
+  }
   regex += "$";
   entry.Regex.compile(regex.c_str());
   this->Names.push_back(entry);
 }
 
-//----------------------------------------------------------------------------
 void cmFindLibraryHelper::SetName(std::string const& name)
 {
   this->Names.clear();
   this->AddName(name);
 }
 
-//----------------------------------------------------------------------------
 bool cmFindLibraryHelper::CheckDirectory(std::string const& path)
 {
-  for(std::vector<Name>::iterator i = this->Names.begin();
-      i != this->Names.end(); ++i)
-    {
-    if(this->CheckDirectoryForName(path, *i))
-      {
+  for (std::vector<Name>::iterator i = this->Names.begin();
+       i != this->Names.end(); ++i) {
+    if (this->CheckDirectoryForName(path, *i)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
                                                 Name& name)
 {
@@ -352,18 +313,15 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
   // specifically for a static library on some platforms (on MS tools
   // one cannot tell just from the library name whether it is a static
   // library or an import library).
-  if(name.TryRaw)
-    {
+  if (name.TryRaw) {
     this->TestPath = path;
     this->TestPath += name.Raw;
-    if(cmSystemTools::FileExists(this->TestPath.c_str(), true))
-      {
-      this->BestPath =
-        cmSystemTools::CollapseFullPath(this->TestPath);
+    if (cmSystemTools::FileExists(this->TestPath.c_str(), true)) {
+      this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
       cmSystemTools::ConvertToUnixSlashes(this->BestPath);
       return true;
-      }
     }
+  }
 
   // No library file has yet been found.
   size_type bestPrefix = this->Prefixes.size();
@@ -375,21 +333,18 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
   std::string dir = path;
   cmSystemTools::ConvertToUnixSlashes(dir);
   std::set<std::string> const& files = this->GG->GetDirectoryContent(dir);
-  for(std::set<std::string>::const_iterator fi = files.begin();
-      fi != files.end(); ++fi)
-    {
+  for (std::set<std::string>::const_iterator fi = files.begin();
+       fi != files.end(); ++fi) {
     std::string const& origName = *fi;
 #if defined(_WIN32) || defined(__APPLE__)
     std::string testName = cmSystemTools::LowerCase(origName);
 #else
     std::string const& testName = origName;
 #endif
-    if(name.Regex.find(testName))
-      {
+    if (name.Regex.find(testName)) {
       this->TestPath = path;
       this->TestPath += origName;
-      if(!cmSystemTools::FileIsDirectory(this->TestPath))
-        {
+      if (!cmSystemTools::FileIsDirectory(this->TestPath)) {
         // This is a matching file.  Check if it is better than the
         // best name found so far.  Earlier prefixes are preferred,
         // followed by earlier suffixes.  For OpenBSD, shared library
@@ -398,151 +353,125 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
         size_type suffix = this->GetSuffixIndex(name.Regex.match(2));
         unsigned int major = 0;
         unsigned int minor = 0;
-        if(this->OpenBSD)
-          {
+        if (this->OpenBSD) {
           sscanf(name.Regex.match(3).c_str(), ".%u.%u", &major, &minor);
-          }
-        if(this->BestPath.empty() || prefix < bestPrefix ||
-           (prefix == bestPrefix && suffix < bestSuffix) ||
-           (prefix == bestPrefix && suffix == bestSuffix &&
-            (major > bestMajor ||
-             (major == bestMajor && minor > bestMinor))))
-          {
+        }
+        if (this->BestPath.empty() || prefix < bestPrefix ||
+            (prefix == bestPrefix && suffix < bestSuffix) ||
+            (prefix == bestPrefix && suffix == bestSuffix &&
+             (major > bestMajor ||
+              (major == bestMajor && minor > bestMinor)))) {
           this->BestPath = this->TestPath;
           bestPrefix = prefix;
           bestSuffix = suffix;
           bestMajor = major;
           bestMinor = minor;
-          }
         }
       }
     }
+  }
 
   // Use the best candidate found in this directory, if any.
   return !this->BestPath.empty();
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindNormalLibrary()
 {
-  if(this->NamesPerDir)
-    {
+  if (this->NamesPerDir) {
     return this->FindNormalLibraryNamesPerDir();
-    }
-  else
-    {
+  } else {
     return this->FindNormalLibraryDirsPerName();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindNormalLibraryNamesPerDir()
 {
   // Search for all names in each directory.
   cmFindLibraryHelper helper(this->Makefile);
-  for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end() ; ++ni)
-    {
+  for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
     helper.AddName(*ni);
-    }
+  }
   // Search every directory.
-  for(std::vector<std::string>::const_iterator
-        p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p)
-    {
-    if(helper.CheckDirectory(*p))
-      {
+  for (std::vector<std::string>::const_iterator p = this->SearchPaths.begin();
+       p != this->SearchPaths.end(); ++p) {
+    if (helper.CheckDirectory(*p)) {
       return helper.BestPath;
-      }
     }
+  }
   // Couldn't find the library.
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindNormalLibraryDirsPerName()
 {
   // Search the entire path for each name.
   cmFindLibraryHelper helper(this->Makefile);
-  for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end() ; ++ni)
-    {
+  for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
     // Switch to searching for this name.
     helper.SetName(*ni);
 
     // Search every directory.
-    for(std::vector<std::string>::const_iterator
-          p = this->SearchPaths.begin();
-        p != this->SearchPaths.end(); ++p)
-      {
-      if(helper.CheckDirectory(*p))
-        {
+    for (std::vector<std::string>::const_iterator p =
+           this->SearchPaths.begin();
+         p != this->SearchPaths.end(); ++p) {
+      if (helper.CheckDirectory(*p)) {
         return helper.BestPath;
-        }
       }
     }
+  }
   // Couldn't find the library.
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindFrameworkLibrary()
 {
-  if(this->NamesPerDir)
-    {
+  if (this->NamesPerDir) {
     return this->FindFrameworkLibraryNamesPerDir();
-    }
-  else
-    {
+  } else {
     return this->FindFrameworkLibraryDirsPerName();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir()
 {
   std::string fwPath;
   // Search for all names in each search path.
-  for(std::vector<std::string>::const_iterator di = this->SearchPaths.begin();
-      di != this->SearchPaths.end(); ++di)
-    {
-    for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-        ni != this->Names.end() ; ++ni)
-      {
+  for (std::vector<std::string>::const_iterator di = this->SearchPaths.begin();
+       di != this->SearchPaths.end(); ++di) {
+    for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+         ni != this->Names.end(); ++ni) {
       fwPath = *di;
       fwPath += *ni;
       fwPath += ".framework";
-      if(cmSystemTools::FileIsDirectory(fwPath))
-        {
+      if (cmSystemTools::FileIsDirectory(fwPath)) {
         return cmSystemTools::CollapseFullPath(fwPath);
-        }
       }
     }
+  }
 
   // No framework found.
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName()
 {
   std::string fwPath;
   // Search for each name in all search paths.
-  for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end() ; ++ni)
-    {
-    for(std::vector<std::string>::const_iterator
-          di = this->SearchPaths.begin();
-        di != this->SearchPaths.end(); ++di)
-      {
+  for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
+    for (std::vector<std::string>::const_iterator di =
+           this->SearchPaths.begin();
+         di != this->SearchPaths.end(); ++di) {
       fwPath = *di;
       fwPath += *ni;
       fwPath += ".framework";
-      if(cmSystemTools::FileIsDirectory(fwPath))
-        {
+      if (cmSystemTools::FileIsDirectory(fwPath)) {
         return cmSystemTools::CollapseFullPath(fwPath);
-        }
       }
     }
+  }
 
   // No framework found.
   return "";
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index e257174..a08e151 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -14,7 +14,6 @@
 
 #include "cmFindBase.h"
 
-
 /** \class cmFindLibraryCommand
  * \brief Define a command to search for a library.
  *
@@ -29,17 +28,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFindLibraryCommand;
-    }
+  virtual cmCommand* Clone() { return new cmFindLibraryCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -49,7 +45,7 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "find_library";}
+  virtual std::string GetName() const { return "find_library"; }
 
   cmTypeMacro(cmFindLibraryCommand, cmFindBase);
 
@@ -57,9 +53,9 @@ protected:
   void AddArchitecturePaths(const char* suffix);
   void AddArchitecturePath(std::string const& dir,
                            std::string::size_type start_pos,
-                           const char* suffix,
-                           bool fresh = true);
+                           const char* suffix, bool fresh = true);
   std::string FindLibrary();
+
 private:
   std::string FindNormalLibrary();
   std::string FindNormalLibraryNamesPerDir();
@@ -69,6 +65,4 @@ private:
   std::string FindFrameworkLibraryDirsPerName();
 };
 
-
-
 #endif
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 64176e7..7908afe 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -11,30 +11,28 @@
 ============================================================================*/
 #include "cmFindPackageCommand.h"
 
+#include "cmAlgorithms.h"
 #include <cmsys/Directory.hxx>
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/Encoding.hxx>
-#include "cmAlgorithms.h"
+#include <cmsys/RegularExpression.hxx>
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
 #include "cmVariableWatch.h"
 #endif
 
 #if defined(__HAIKU__)
-#include <string.h>
 #include <FindDirectory.h>
 #include <StorageDefs.h>
+#include <string.h>
 #endif
 
-//----------------------------------------------------------------------------
-cmFindPackageCommand::PathLabel
-  cmFindPackageCommand::PathLabel::UserRegistry("PACKAGE_REGISTRY");
-cmFindPackageCommand::PathLabel
-  cmFindPackageCommand::PathLabel::Builds("BUILDS");
+cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::UserRegistry(
+  "PACKAGE_REGISTRY");
+cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::Builds(
+  "BUILDS");
 cmFindPackageCommand::PathLabel
   cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY");
 
-//----------------------------------------------------------------------------
 cmFindPackageCommand::cmFindPackageCommand()
 {
   this->CMakePathName = "PACKAGE";
@@ -63,79 +61,71 @@ cmFindPackageCommand::cmFindPackageCommand()
   this->AppendSearchPathGroups();
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::AppendSearchPathGroups()
 {
   std::vector<cmFindCommon::PathLabel>* labels;
 
   // Update the All group with new paths
   labels = &this->PathGroupLabelMap[PathGroup::All];
-  labels->insert(std::find(labels->begin(), labels->end(),
-                           PathLabel::CMakeSystem),
-                 PathLabel::UserRegistry);
-  labels->insert(std::find(labels->begin(), labels->end(),
-                           PathLabel::CMakeSystem),
-                 PathLabel::Builds);
+  labels->insert(
+    std::find(labels->begin(), labels->end(), PathLabel::CMakeSystem),
+    PathLabel::UserRegistry);
+  labels->insert(
+    std::find(labels->begin(), labels->end(), PathLabel::CMakeSystem),
+    PathLabel::Builds);
   labels->insert(std::find(labels->begin(), labels->end(), PathLabel::Guess),
                  PathLabel::SystemRegistry);
 
   // Create the new path objects
-  this->LabeledPaths.insert(std::make_pair(PathLabel::UserRegistry,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::Builds,
-    cmSearchPath(this)));
-  this->LabeledPaths.insert(std::make_pair(PathLabel::SystemRegistry,
-    cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::UserRegistry, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::Builds, cmSearchPath(this)));
+  this->LabeledPaths.insert(
+    std::make_pair(PathLabel::SystemRegistry, cmSearchPath(this)));
 }
 
-//----------------------------------------------------------------------------
-bool cmFindPackageCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Lookup required version of CMake.
-  if(const char* rv =
-     this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"))
-    {
-    unsigned int v[3] = {0,0,0};
+  if (const char* rv =
+        this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
+    unsigned int v[3] = { 0, 0, 0 };
     sscanf(rv, "%u.%u.%u", &v[0], &v[1], &v[2]);
-    this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0],v[1],v[2]);
-    }
+    this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0], v[1], v[2]);
+  }
 
   // Check for debug mode.
   this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE");
 
   // Lookup target architecture, if any.
-  if(const char* arch =
-     this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"))
-    {
+  if (const char* arch =
+        this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
     this->LibraryArchitecture = arch;
-    }
+  }
 
   // Lookup whether lib64 paths should be used.
-  if(this->Makefile->PlatformIs64Bit() &&
-     this->Makefile->GetState()
-         ->GetGlobalPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS"))
-    {
+  if (this->Makefile->PlatformIs64Bit() &&
+      this->Makefile->GetState()->GetGlobalPropertyAsBool(
+        "FIND_LIBRARY_USE_LIB64_PATHS")) {
     this->UseLib64Paths = true;
-    }
+  }
 
   // Check if User Package Registry should be disabled
-  if(this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY"))
-    {
+  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"))
-    {
+  if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) {
     this->NoSystemRegistry = true;
-    }
+  }
 
   // Find the current root path mode.
   this->SelectDefaultRootPathMode();
@@ -154,120 +144,89 @@ bool cmFindPackageCommand
   this->SearchPathSuffixes.push_back("");
 
   // Parse the arguments.
-  enum Doing { DoingNone, DoingComponents, DoingOptionalComponents, DoingNames,
-               DoingPaths, DoingPathSuffixes, DoingConfigs, DoingHints };
+  enum Doing
+  {
+    DoingNone,
+    DoingComponents,
+    DoingOptionalComponents,
+    DoingNames,
+    DoingPaths,
+    DoingPathSuffixes,
+    DoingConfigs,
+    DoingHints
+  };
   Doing doing = DoingNone;
   cmsys::RegularExpression version("^[0-9.]+$");
   bool haveVersion = false;
   std::set<unsigned int> configArgs;
   std::set<unsigned int> moduleArgs;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "QUIET")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "QUIET") {
       this->Quiet = true;
       doing = DoingNone;
-      }
-    else if(args[i] == "EXACT")
-      {
+    } else if (args[i] == "EXACT") {
       this->VersionExact = true;
       doing = DoingNone;
-      }
-    else if(args[i] == "MODULE")
-      {
+    } else if (args[i] == "MODULE") {
       moduleArgs.insert(i);
       doing = DoingNone;
-      }
-    else if(args[i] == "CONFIG")
-      {
+    } else if (args[i] == "CONFIG") {
       configArgs.insert(i);
       doing = DoingNone;
-      }
-    else if(args[i] == "NO_MODULE")
-      {
+    } else if (args[i] == "NO_MODULE") {
       configArgs.insert(i);
       doing = DoingNone;
-      }
-    else if(args[i] == "REQUIRED")
-      {
+    } else if (args[i] == "REQUIRED") {
       this->Required = true;
       doing = DoingComponents;
-      }
-    else if(args[i] == "COMPONENTS")
-      {
+    } else if (args[i] == "COMPONENTS") {
       doing = DoingComponents;
-      }
-    else if(args[i] == "OPTIONAL_COMPONENTS")
-      {
+    } else if (args[i] == "OPTIONAL_COMPONENTS") {
       doing = DoingOptionalComponents;
-      }
-    else if(args[i] == "NAMES")
-      {
+    } else if (args[i] == "NAMES") {
       configArgs.insert(i);
       doing = DoingNames;
-      }
-    else if(args[i] == "PATHS")
-      {
+    } else if (args[i] == "PATHS") {
       configArgs.insert(i);
       doing = DoingPaths;
-      }
-    else if(args[i] == "HINTS")
-      {
+    } else if (args[i] == "HINTS") {
       configArgs.insert(i);
       doing = DoingHints;
-      }
-    else if(args[i] == "PATH_SUFFIXES")
-      {
+    } else if (args[i] == "PATH_SUFFIXES") {
       configArgs.insert(i);
       doing = DoingPathSuffixes;
-      }
-    else if(args[i] == "CONFIGS")
-      {
+    } else if (args[i] == "CONFIGS") {
       configArgs.insert(i);
       doing = DoingConfigs;
-      }
-    else if(args[i] == "NO_POLICY_SCOPE")
-      {
+    } else if (args[i] == "NO_POLICY_SCOPE") {
       this->PolicyScope = false;
       doing = DoingNone;
-      }
-    else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY")
-      {
+    } else if (args[i] == "NO_CMAKE_PACKAGE_REGISTRY") {
       this->NoUserRegistry = true;
       configArgs.insert(i);
       doing = DoingNone;
-      }
-    else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY")
-      {
+    } else if (args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY") {
       this->NoSystemRegistry = true;
       configArgs.insert(i);
       doing = DoingNone;
-      }
-    else if(args[i] == "NO_CMAKE_BUILDS_PATH")
-      {
+    } else if (args[i] == "NO_CMAKE_BUILDS_PATH") {
       // Ignore legacy option.
       configArgs.insert(i);
       doing = DoingNone;
-      }
-    else if(this->CheckCommonArgument(args[i]))
-      {
+    } else if (this->CheckCommonArgument(args[i])) {
       configArgs.insert(i);
       doing = DoingNone;
-      }
-    else if((doing == DoingComponents) || (doing == DoingOptionalComponents))
-      {
+    } else if ((doing == DoingComponents) ||
+               (doing == DoingOptionalComponents)) {
       // Set a variable telling the find script whether this component
       // is required.
       const char* isRequired = "1";
-      if (doing == DoingOptionalComponents)
-        {
+      if (doing == DoingOptionalComponents) {
         isRequired = "0";
         optionalComponents.insert(args[i]);
-        }
-      else
-        {
+      } else {
         requiredComponents.insert(args[i]);
-        }
+      }
 
       std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
       this->AddFindDefinition(req_var, isRequired);
@@ -276,105 +235,82 @@ bool cmFindPackageCommand
       components += components_sep;
       components += args[i];
       components_sep = ";";
-      }
-    else if(doing == DoingNames)
-      {
+    } else if (doing == DoingNames) {
       this->Names.push_back(args[i]);
-      }
-    else if(doing == DoingPaths)
-      {
+    } else if (doing == DoingPaths) {
       this->UserGuessArgs.push_back(args[i]);
-      }
-    else if(doing == DoingHints)
-      {
+    } else if (doing == DoingHints) {
       this->UserHintsArgs.push_back(args[i]);
-      }
-    else if(doing == DoingPathSuffixes)
-      {
+    } else if (doing == DoingPathSuffixes) {
       this->AddPathSuffix(args[i]);
-      }
-    else if(doing == DoingConfigs)
-      {
-      if(args[i].find_first_of(":/\\") != args[i].npos ||
-         cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake")
-        {
+    } else if (doing == DoingConfigs) {
+      if (args[i].find_first_of(":/\\") != args[i].npos ||
+          cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake") {
         std::ostringstream e;
-        e << "given CONFIGS option followed by invalid file name \""
-          << args[i] << "\".  The names given must be file names without "
+        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());
         return false;
-        }
-      this->Configs.push_back(args[i]);
       }
-    else if(!haveVersion && version.find(args[i].c_str()))
-      {
+      this->Configs.push_back(args[i]);
+    } else if (!haveVersion && version.find(args[i].c_str())) {
       haveVersion = true;
       this->Version = args[i];
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "called with invalid argument \"" << args[i] << "\"";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   std::vector<std::string> doubledComponents;
   std::set_intersection(requiredComponents.begin(), requiredComponents.end(),
                         optionalComponents.begin(), optionalComponents.end(),
                         std::back_inserter(doubledComponents));
-  if(!doubledComponents.empty())
-    {
+  if (!doubledComponents.empty()) {
     std::ostringstream e;
     e << "called with components that are both required and optional:\n";
     e << cmWrap("  ", doubledComponents, "", "\n") << "\n";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Maybe choose one mode exclusively.
   this->UseFindModules = configArgs.empty();
   this->UseConfigFiles = moduleArgs.empty();
-  if(!this->UseFindModules && !this->UseConfigFiles)
-    {
+  if (!this->UseFindModules && !this->UseConfigFiles) {
     std::ostringstream e;
     e << "given options exclusive to Module mode:\n";
-    for(std::set<unsigned int>::const_iterator si = moduleArgs.begin();
-        si != moduleArgs.end(); ++si)
-      {
+    for (std::set<unsigned int>::const_iterator si = moduleArgs.begin();
+         si != moduleArgs.end(); ++si) {
       e << "  " << args[*si] << "\n";
-      }
+    }
     e << "and options exclusive to Config mode:\n";
-    for(std::set<unsigned int>::const_iterator si = configArgs.begin();
-        si != configArgs.end(); ++si)
-      {
+    for (std::set<unsigned int>::const_iterator si = configArgs.begin();
+         si != configArgs.end(); ++si) {
       e << "  " << args[*si] << "\n";
-      }
+    }
     e << "The options are incompatible.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Ignore EXACT with no version.
-  if(this->Version.empty() && this->VersionExact)
-    {
+  if (this->Version.empty() && this->VersionExact) {
     this->VersionExact = false;
     this->Makefile->IssueMessage(
       cmake::AUTHOR_WARNING, "Ignoring EXACT since no version is requested.");
-    }
+  }
 
-  if(this->Version.empty() || components.empty())
-    {
+  if (this->Version.empty() || components.empty()) {
     // Check whether we are recursing inside "Find<name>.cmake" within
     // another find_package(<name>) call.
     std::string mod = this->Name;
     mod += "_FIND_MODULE";
-    if(this->Makefile->IsOn(mod))
-      {
-      if(this->Version.empty())
-        {
+    if (this->Makefile->IsOn(mod)) {
+      if (this->Version.empty()) {
         // Get version information from the outer call if necessary.
         // Requested version string.
         std::string ver = this->Name;
@@ -385,102 +321,102 @@ bool cmFindPackageCommand
         std::string exact = this->Name;
         exact += "_FIND_VERSION_EXACT";
         this->VersionExact = this->Makefile->IsOn(exact);
-        }
-      if(components.empty())
-        {
+      }
+      if (components.empty()) {
         std::string components_var = this->Name + "_FIND_COMPONENTS";
         components = this->Makefile->GetSafeDefinition(components_var);
-        }
       }
     }
+  }
 
-  if(!this->Version.empty())
-    {
+  if (!this->Version.empty()) {
     // Try to parse the version number and store the results that were
     // successfully parsed.
     unsigned int parsed_major;
     unsigned int parsed_minor;
     unsigned int parsed_patch;
     unsigned int parsed_tweak;
-    this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u.%u",
-                                &parsed_major, &parsed_minor,
-                                &parsed_patch, &parsed_tweak);
-    switch(this->VersionCount)
-      {
-      case 4: this->VersionTweak = parsed_tweak; // no break!
-      case 3: this->VersionPatch = parsed_patch; // no break!
-      case 2: this->VersionMinor = parsed_minor; // no break!
-      case 1: this->VersionMajor = parsed_major; // no break!
-      default: break;
-      }
+    this->VersionCount =
+      sscanf(this->Version.c_str(), "%u.%u.%u.%u", &parsed_major,
+             &parsed_minor, &parsed_patch, &parsed_tweak);
+    switch (this->VersionCount) {
+      case 4:
+        this->VersionTweak = parsed_tweak; // no break!
+      case 3:
+        this->VersionPatch = parsed_patch; // no break!
+      case 2:
+        this->VersionMinor = parsed_minor; // no break!
+      case 1:
+        this->VersionMajor = parsed_major; // no break!
+      default:
+        break;
     }
+  }
 
   std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
   disableFindPackageVar += this->Name;
-  if(this->Makefile->IsOn(disableFindPackageVar))
-    {
-    if (this->Required)
-      {
+  if (this->Makefile->IsOn(disableFindPackageVar)) {
+    if (this->Required) {
       std::ostringstream e;
       e << "for module " << this->Name << " called with REQUIRED, but "
         << disableFindPackageVar
         << " is enabled. A REQUIRED package cannot be disabled.";
       this->SetError(e.str());
       return false;
-      }
-
-    return true;
     }
 
+    return true;
+  }
 
   this->SetModuleVariables(components);
 
   // See if there is a Find<package>.cmake module.
-  if(this->UseFindModules)
-    {
+  if (this->UseFindModules) {
     bool foundModule = false;
-    if(!this->FindModule(foundModule))
-      {
+    if (!this->FindModule(foundModule)) {
       this->AppendSuccessInformation();
       return false;
-      }
-    if(foundModule)
-      {
+    }
+    if (foundModule) {
       this->AppendSuccessInformation();
       return true;
-      }
     }
+  }
 
-  if(this->UseFindModules && this->UseConfigFiles &&
-     this->Makefile->IsOn("CMAKE_FIND_PACKAGE_WARN_NO_MODULE"))
-    {
+  if (this->UseFindModules && this->UseConfigFiles &&
+      this->Makefile->IsOn("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")) {
     std::ostringstream aw;
-    if(this->RequiredCMakeVersion >= CMake_VERSION_ENCODE(2,8,8))
-      {
+    if (this->RequiredCMakeVersion >= CMake_VERSION_ENCODE(2, 8, 8)) {
       aw << "find_package called without either MODULE or CONFIG option and "
-        "no Find" << this->Name << ".cmake module is in CMAKE_MODULE_PATH.  "
-        "Add MODULE to exclusively request Module mode and fail if "
-        "Find" << this->Name << ".cmake is missing.  "
-        "Add CONFIG to exclusively request Config mode and search for a "
-        "package configuration file provided by " << this->Name <<
-        " (" << this->Name << "Config.cmake or " <<
-        cmSystemTools::LowerCase(this->Name) << "-config.cmake).  ";
-      }
-    else
-      {
-      aw << "find_package called without NO_MODULE option and no "
-        "Find" << this->Name << ".cmake module is in CMAKE_MODULE_PATH.  "
-        "Add NO_MODULE to exclusively request Config mode and search for a "
-        "package configuration file provided by " << this->Name <<
-        " (" << this->Name << "Config.cmake or " <<
-        cmSystemTools::LowerCase(this->Name) << "-config.cmake).  "
-        "Otherwise make Find" << this->Name << ".cmake available in "
-        "CMAKE_MODULE_PATH.";
-      }
+            "no Find"
+         << this->Name
+         << ".cmake module is in CMAKE_MODULE_PATH.  "
+            "Add MODULE to exclusively request Module mode and fail if "
+            "Find"
+         << this->Name
+         << ".cmake is missing.  "
+            "Add CONFIG to exclusively request Config mode and search for a "
+            "package configuration file provided by "
+         << this->Name << " (" << this->Name << "Config.cmake or "
+         << cmSystemTools::LowerCase(this->Name) << "-config.cmake).  ";
+    } else {
+      aw
+        << "find_package called without NO_MODULE option and no "
+           "Find"
+        << this->Name
+        << ".cmake module is in CMAKE_MODULE_PATH.  "
+           "Add NO_MODULE to exclusively request Config mode and search for a "
+           "package configuration file provided by "
+        << this->Name << " (" << this->Name << "Config.cmake or "
+        << cmSystemTools::LowerCase(this->Name) << "-config.cmake).  "
+                                                   "Otherwise make Find"
+        << this->Name << ".cmake available in "
+                         "CMAKE_MODULE_PATH.";
+    }
     aw << "\n"
-      "(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.)";
+          "(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.)";
     this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
-    }
+  }
 
   // No find module.  Assume the project has a CMake config file.  Use
   // a <package>_DIR cache variable to locate it.
@@ -488,17 +424,14 @@ bool cmFindPackageCommand
   this->Variable += "_DIR";
 
   // Add the default name.
-  if(this->Names.empty())
-    {
+  if (this->Names.empty()) {
     this->Names.push_back(this->Name);
-    }
+  }
 
   // Add the default configs.
-  if(this->Configs.empty())
-    {
-    for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-        ni != this->Names.end(); ++ni)
-      {
+  if (this->Configs.empty()) {
+    for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+         ni != this->Names.end(); ++ni) {
       std::string config = *ni;
       config += "Config.cmake";
       this->Configs.push_back(config);
@@ -506,8 +439,8 @@ bool cmFindPackageCommand
       config = cmSystemTools::LowerCase(*ni);
       config += "-config.cmake";
       this->Configs.push_back(config);
-      }
     }
+  }
 
   // get igonored paths from vars and reroot them.
   std::vector<std::string> ignored;
@@ -524,8 +457,6 @@ bool cmFindPackageCommand
   return result;
 }
 
-
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::SetModuleVariables(const std::string& components)
 {
   this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name.c_str());
@@ -534,26 +465,23 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
   std::string components_var = this->Name + "_FIND_COMPONENTS";
   this->AddFindDefinition(components_var, components.c_str());
 
-  if(this->Quiet)
-    {
+  if (this->Quiet) {
     // Tell the module that is about to be read that it should find
     // quietly.
     std::string quietly = this->Name;
     quietly += "_FIND_QUIETLY";
     this->AddFindDefinition(quietly, "1");
-    }
+  }
 
-  if(this->Required)
-    {
+  if (this->Required) {
     // Tell the module that is about to be read that it should report
     // a fatal error if the package is not found.
     std::string req = this->Name;
     req += "_FIND_REQUIRED";
     this->AddFindDefinition(req, "1");
-    }
+  }
 
-  if(!this->Version.empty())
-    {
+  if (!this->Version.empty()) {
     // Tell the module that is about to be read what version of the
     // package has been requested.
     std::string ver = this->Name;
@@ -561,66 +489,56 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
     this->AddFindDefinition(ver, this->Version.c_str());
     char buf[64];
     sprintf(buf, "%u", this->VersionMajor);
-    this->AddFindDefinition(ver+"_MAJOR", buf);
+    this->AddFindDefinition(ver + "_MAJOR", buf);
     sprintf(buf, "%u", this->VersionMinor);
-    this->AddFindDefinition(ver+"_MINOR", buf);
+    this->AddFindDefinition(ver + "_MINOR", buf);
     sprintf(buf, "%u", this->VersionPatch);
-    this->AddFindDefinition(ver+"_PATCH", buf);
+    this->AddFindDefinition(ver + "_PATCH", buf);
     sprintf(buf, "%u", this->VersionTweak);
-    this->AddFindDefinition(ver+"_TWEAK", buf);
+    this->AddFindDefinition(ver + "_TWEAK", buf);
     sprintf(buf, "%u", this->VersionCount);
-    this->AddFindDefinition(ver+"_COUNT", 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, this->VersionExact? "1":"0");
-   }
+    this->AddFindDefinition(exact, this->VersionExact ? "1" : "0");
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::AddFindDefinition(const std::string& var,
                                              const char* val)
 {
-  if(const char* old = this->Makefile->GetDefinition(var))
-    {
+  if (const char* old = this->Makefile->GetDefinition(var)) {
     this->OriginalDefs[var].exists = true;
     this->OriginalDefs[var].value = old;
-    }
-  else
-    {
+  } else {
     this->OriginalDefs[var].exists = false;
-    }
+  }
   this->Makefile->AddDefinition(var, val);
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::RestoreFindDefinitions()
 {
-  for(std::map<std::string, OriginalDef>::iterator
-        i = this->OriginalDefs.begin(); i != this->OriginalDefs.end(); ++i)
-    {
+  for (std::map<std::string, OriginalDef>::iterator i =
+         this->OriginalDefs.begin();
+       i != this->OriginalDefs.end(); ++i) {
     OriginalDef const& od = i->second;
-    if(od.exists)
-      {
+    if (od.exists) {
       this->Makefile->AddDefinition(i->first, od.value.c_str());
-      }
-    else
-      {
+    } else {
       this->Makefile->RemoveDefinition(i->first);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::FindModule(bool& found)
 {
   std::string module = "Find";
   module += this->Name;
   module += ".cmake";
   std::string mfile = this->Makefile->GetModulesFile(module.c_str());
-  if (!mfile.empty())
-    {
+  if (!mfile.empty()) {
     // Load the module we found, and set "<name>_FIND_MODULE" to true
     // while inside it.
     found = true;
@@ -630,11 +548,10 @@ bool cmFindPackageCommand::FindModule(bool& found)
     bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope);
     this->Makefile->RemoveDefinition(var);
     return result;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::HandlePackageMode()
 {
   this->ConsideredConfigs.clear();
@@ -650,44 +567,38 @@ bool cmFindPackageCommand::HandlePackageMode()
 
   // Try to load the config file if the directory is known
   bool fileFound = false;
-  if (this->UseConfigFiles)
-    {
-    if(!cmSystemTools::IsOff(def))
-      {
+  if (this->UseConfigFiles) {
+    if (!cmSystemTools::IsOff(def)) {
       // Get the directory from the variable value.
       std::string dir = def;
       cmSystemTools::ConvertToUnixSlashes(dir);
 
       // Treat relative paths with respect to the current source dir.
-      if(!cmSystemTools::FileIsFullPath(dir.c_str()))
-        {
+      if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
         dir = "/" + dir;
         dir = this->Makefile->GetCurrentSourceDirectory() + dir;
-        }
+      }
       // The file location was cached.  Look for the correct file.
       std::string file;
-      if (this->FindConfigFile(dir, file))
-        {
+      if (this->FindConfigFile(dir, file)) {
         this->FileFound = file;
         fileFound = true;
-        }
-      def = this->Makefile->GetDefinition(this->Variable);
       }
+      def = this->Makefile->GetDefinition(this->Variable);
+    }
 
     // Search for the config file if it is not already found.
-    if(cmSystemTools::IsOff(def) || !fileFound)
-      {
+    if (cmSystemTools::IsOff(def) || !fileFound) {
       fileFound = this->FindConfig();
-      }
+    }
 
     // Sanity check.
-    if(fileFound && this->FileFound.empty())
-      {
+    if (fileFound && this->FileFound.empty()) {
       this->Makefile->IssueMessage(
         cmake::INTERNAL_ERROR, "fileFound is true but FileFound is empty!");
       fileFound = false;
-      }
     }
+  }
 
   std::string foundVar = this->Name;
   foundVar += "_FOUND";
@@ -700,17 +611,15 @@ bool cmFindPackageCommand::HandlePackageMode()
   bool found = false;
   bool configFileSetFOUNDFalse = false;
 
-  if(fileFound)
-    {
-    if ((this->Makefile->IsDefinitionSet(foundVar))
-      && (this->Makefile->IsOn(foundVar) == false))
-      {
+  if (fileFound) {
+    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);
-      }
+    }
     this->Makefile->RemoveDefinition(notFoundMessageVar);
 
     // Set the version variables before loading the config file.
@@ -718,149 +627,135 @@ bool cmFindPackageCommand::HandlePackageMode()
     this->StoreVersionFound();
 
     // Parse the configuration file.
-    if(this->ReadListFile(this->FileFound.c_str(), DoPolicyScope))
-      {
+    if (this->ReadListFile(this->FileFound.c_str(), DoPolicyScope)) {
       // The package has been found.
       found = true;
 
       // Check whether the Config file has set Foo_FOUND to FALSE:
-      if ((this->Makefile->IsDefinitionSet(foundVar))
-           && (this->Makefile->IsOn(foundVar) == 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);
-        }
+        notFoundMessage =
+          this->Makefile->GetSafeDefinition(notFoundMessageVar);
       }
-    else
-      {
+    } else {
       // The configuration file is invalid.
       result = false;
-      }
     }
+  }
 
-  if (result && !found && (!this->Quiet || this->Required))
-    {
+  if (result && !found && (!this->Quiet || this->Required)) {
     // The variable is not set.
     std::ostringstream e;
     std::ostringstream aw;
-    if (configFileSetFOUNDFalse)
-      {
+    if (configFileSetFOUNDFalse) {
+      /* clang-format off */
       e << "Found package configuration file:\n"
         "  " << this->FileFound << "\n"
         "but it set " << foundVar << " to FALSE so package \"" <<
         this->Name << "\" is considered to be NOT FOUND.";
-      if (!notFoundMessage.empty())
-        {
+      /* clang-format on */
+      if (!notFoundMessage.empty()) {
         e << " Reason given by package: \n" << notFoundMessage << "\n";
-        }
       }
+    }
     // If there are files in ConsideredConfigs, it means that FooConfig.cmake
     // have been found, but they didn't have appropriate versions.
-    else if (!this->ConsideredConfigs.empty())
-      {
-      e << "Could not find a configuration file for package \""
-        << this->Name << "\" that "
-        << (this->VersionExact? "exactly matches" : "is compatible with")
+    else if (!this->ConsideredConfigs.empty()) {
+      e << "Could not find a configuration file for package \"" << this->Name
+        << "\" that "
+        << (this->VersionExact ? "exactly matches" : "is compatible with")
         << " requested version \"" << this->Version << "\".\n"
         << "The following configuration files were considered but not "
            "accepted:\n";
-      for(std::vector<ConfigFileInfo>::size_type i=0;
-          i<this->ConsideredConfigs.size(); i++)
-        {
+      for (std::vector<ConfigFileInfo>::size_type i = 0;
+           i < this->ConsideredConfigs.size(); i++) {
         e << "  " << this->ConsideredConfigs[i].filename
           << ", version: " << this->ConsideredConfigs[i].version << "\n";
-        }
       }
-    else
-      {
+    } else {
       std::string requestedVersionString;
-      if(!this->Version.empty())
-        {
+      if (!this->Version.empty()) {
         requestedVersionString = " (requested version ";
         requestedVersionString += this->Version;
         requestedVersionString += ")";
-        }
+      }
 
-      if (this->UseConfigFiles)
-        {
-        if(this->UseFindModules)
-          {
-          e << "By not providing \"Find" << this->Name << ".cmake\" in "
+      if (this->UseConfigFiles) {
+        if (this->UseFindModules) {
+          e << "By not providing \"Find" << this->Name
+            << ".cmake\" in "
                "CMAKE_MODULE_PATH this project has asked CMake to find a "
-               "package configuration file provided by \""<<this->Name<< "\", "
-               "but CMake did not find one.\n";
-          }
+               "package configuration file provided by \""
+            << this->Name << "\", "
+                             "but CMake did not find one.\n";
+        }
 
-        if(this->Configs.size() == 1)
-          {
+        if (this->Configs.size() == 1) {
           e << "Could not find a package configuration file named \""
-            << this->Configs[0] << "\" provided by package \""
-            << this->Name << "\"" << requestedVersionString <<".\n";
-          }
-        else
-          {
+            << this->Configs[0] << "\" provided by package \"" << this->Name
+            << "\"" << requestedVersionString << ".\n";
+        } else {
           e << "Could not find a package configuration file provided by \""
             << this->Name << "\"" << requestedVersionString
             << " with any of the following names:\n"
             << cmWrap("  ", this->Configs, "", "\n") << "\n";
-          }
-
-        e << "Add the installation prefix of \"" << this->Name << "\" to "
-          "CMAKE_PREFIX_PATH or set \"" << this->Variable << "\" to a "
-          "directory containing one of the above files. "
-          "If \"" << this->Name << "\" provides a separate development "
-          "package or SDK, be sure it has been installed.";
         }
-      else // if(!this->UseFindModules && !this->UseConfigFiles)
-        {
+
+        e << "Add the installation prefix of \"" << this->Name
+          << "\" to "
+             "CMAKE_PREFIX_PATH or set \""
+          << this->Variable << "\" to a "
+                               "directory containing one of the above files. "
+                               "If \""
+          << this->Name << "\" provides a separate development "
+                           "package or SDK, be sure it has been installed.";
+      } else // if(!this->UseFindModules && !this->UseConfigFiles)
+      {
         e << "No \"Find" << this->Name << ".cmake\" found in "
           << "CMAKE_MODULE_PATH.";
 
-        aw<< "Find"<< this->Name <<".cmake must either be part of this "
-             "project itself, in this case adjust CMAKE_MODULE_PATH so that "
-             "it points to the correct location inside its source tree.\n"
-             "Or it must be installed by a package which has already been "
-             "found via find_package().  In this case make sure that "
-             "package has indeed been found and adjust CMAKE_MODULE_PATH to "
-             "contain the location where that package has installed "
-             "Find" << this->Name << ".cmake.  This must be a location "
-             "provided by that package.  This error in general means that "
-             "the buildsystem of this project is relying on a Find-module "
-             "without ensuring that it is actually available.\n";
-        }
+        aw << "Find" << this->Name
+           << ".cmake must either be part of this "
+              "project itself, in this case adjust CMAKE_MODULE_PATH so that "
+              "it points to the correct location inside its source tree.\n"
+              "Or it must be installed by a package which has already been "
+              "found via find_package().  In this case make sure that "
+              "package has indeed been found and adjust CMAKE_MODULE_PATH to "
+              "contain the location where that package has installed "
+              "Find"
+           << this->Name
+           << ".cmake.  This must be a location "
+              "provided by that package.  This error in general means that "
+              "the buildsystem of this project is relying on a Find-module "
+              "without ensuring that it is actually available.\n";
       }
-
+    }
 
     this->Makefile->IssueMessage(
-      this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str());
-    if (this->Required)
-      {
+      this->Required ? cmake::FATAL_ERROR : cmake::WARNING, e.str());
+    if (this->Required) {
       cmSystemTools::SetFatalErrorOccured();
-      }
+    }
 
-    if (!aw.str().empty())
-      {
-      this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,aw.str());
-      }
+    if (!aw.str().empty()) {
+      this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
     }
+  }
 
   // Set a variable marking whether the package was found.
-  this->Makefile->AddDefinition(foundVar, 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)
-    {
+  if (found) {
     this->Makefile->AddDefinition(fileVar, this->FileFound.c_str());
-    }
-  else
-    {
+  } else {
     this->Makefile->RemoveDefinition(fileVar);
-    }
+  }
 
   std::string consideredConfigsVar = this->Name;
   consideredConfigsVar += "_CONSIDERED_CONFIGS";
@@ -871,15 +766,14 @@ bool cmFindPackageCommand::HandlePackageMode()
   std::string consideredVersions;
 
   const char* sep = "";
-  for(std::vector<ConfigFileInfo>::size_type i=0;
-      i<this->ConsideredConfigs.size(); i++)
-    {
+  for (std::vector<ConfigFileInfo>::size_type i = 0;
+       i < this->ConsideredConfigs.size(); i++) {
     consideredConfigFiles += sep;
     consideredVersions += sep;
     consideredConfigFiles += this->ConsideredConfigs[i].filename;
     consideredVersions += this->ConsideredConfigs[i].version;
     sep = ";";
-    }
+  }
 
   this->Makefile->AddDefinition(consideredConfigsVar,
                                 consideredConfigFiles.c_str());
@@ -890,7 +784,6 @@ bool cmFindPackageCommand::HandlePackageMode()
   return result;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::FindConfig()
 {
   // Compute the set of search prefixes.
@@ -900,109 +793,89 @@ bool cmFindPackageCommand::FindConfig()
   bool found = false;
 
   // Search for frameworks.
-  if(!found && (this->SearchFrameworkFirst || this->SearchFrameworkOnly))
-    {
+  if (!found && (this->SearchFrameworkFirst || this->SearchFrameworkOnly)) {
     found = this->FindFrameworkConfig();
-    }
+  }
 
   // Search for apps.
-  if(!found && (this->SearchAppBundleFirst || this->SearchAppBundleOnly))
-    {
+  if (!found && (this->SearchAppBundleFirst || this->SearchAppBundleOnly)) {
     found = this->FindAppBundleConfig();
-    }
+  }
 
   // Search prefixes.
-  if(!found && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
-    {
+  if (!found && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) {
     found = this->FindPrefixedConfig();
-    }
+  }
 
   // Search for frameworks.
-  if(!found && this->SearchFrameworkLast)
-    {
+  if (!found && this->SearchFrameworkLast) {
     found = this->FindFrameworkConfig();
-    }
+  }
 
   // Search for apps.
-  if(!found && this->SearchAppBundleLast)
-    {
+  if (!found && this->SearchAppBundleLast) {
     found = this->FindAppBundleConfig();
-    }
+  }
 
   // Store the entry in the cache so it can be set by the user.
   std::string init;
-  if(found)
-    {
+  if (found) {
     init = cmSystemTools::GetFilenamePath(this->FileFound);
-    }
-  else
-    {
+  } else {
     init = this->Variable + "-NOTFOUND";
-    }
+  }
   std::string help =
     "The directory containing a CMake configuration file for ";
   help += this->Name;
   help += ".";
   // We force the value since we do not get here if it was already set.
-  this->Makefile->AddCacheDefinition(this->Variable,
-                                     init.c_str(), help.c_str(),
-                                     cmState::PATH, true);
+  this->Makefile->AddCacheDefinition(this->Variable, init.c_str(),
+                                     help.c_str(), cmState::PATH, true);
   return found;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::FindPrefixedConfig()
 {
   std::vector<std::string>& prefixes = this->SearchPaths;
-  for(std::vector<std::string>::const_iterator pi = prefixes.begin();
-      pi != prefixes.end(); ++pi)
-    {
-    if(this->SearchPrefix(*pi))
-      {
+  for (std::vector<std::string>::const_iterator pi = prefixes.begin();
+       pi != prefixes.end(); ++pi) {
+    if (this->SearchPrefix(*pi)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::FindFrameworkConfig()
 {
   std::vector<std::string>& prefixes = this->SearchPaths;
-  for(std::vector<std::string>::const_iterator i = prefixes.begin();
-      i != prefixes.end(); ++i)
-    {
-    if(this->SearchFrameworkPrefix(*i))
-      {
+  for (std::vector<std::string>::const_iterator i = prefixes.begin();
+       i != prefixes.end(); ++i) {
+    if (this->SearchFrameworkPrefix(*i)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::FindAppBundleConfig()
 {
   std::vector<std::string>& prefixes = this->SearchPaths;
-  for(std::vector<std::string>::const_iterator i = prefixes.begin();
-      i != prefixes.end(); ++i)
-    {
-    if(this->SearchAppBundlePrefix(*i))
-      {
+  for (std::vector<std::string>::const_iterator i = prefixes.begin();
+       i != prefixes.end(); ++i) {
+    if (this->SearchAppBundlePrefix(*i)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
 {
   const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope;
-  if(this->Makefile->ReadDependentFile(f, noPolicyScope))
-    {
+  if (this->Makefile->ReadDependentFile(f, noPolicyScope)) {
     return true;
-    }
+  }
   std::string e = "Error reading CMake code from \"";
   e += f;
   e += "\".";
@@ -1010,69 +883,56 @@ bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::AppendToFoundProperty(bool found)
 {
   std::vector<std::string> foundContents;
-  const char *foundProp = this->Makefile->GetState()
-                              ->GetGlobalProperty("PACKAGES_FOUND");
-  if (foundProp && *foundProp)
-    {
+  const char* foundProp =
+    this->Makefile->GetState()->GetGlobalProperty("PACKAGES_FOUND");
+  if (foundProp && *foundProp) {
     std::string tmp = foundProp;
 
     cmSystemTools::ExpandListArgument(tmp, foundContents, false);
-    std::vector<std::string>::iterator nameIt = std::find(
-                       foundContents.begin(), foundContents.end(), this->Name);
-    if(nameIt != foundContents.end())
-      {
+    std::vector<std::string>::iterator nameIt =
+      std::find(foundContents.begin(), foundContents.end(), this->Name);
+    if (nameIt != foundContents.end()) {
       foundContents.erase(nameIt);
-      }
     }
+  }
 
   std::vector<std::string> notFoundContents;
-  const char *notFoundProp =
-         this->Makefile->GetState()
-             ->GetGlobalProperty("PACKAGES_NOT_FOUND");
-  if (notFoundProp && *notFoundProp)
-    {
+  const char* notFoundProp =
+    this->Makefile->GetState()->GetGlobalProperty("PACKAGES_NOT_FOUND");
+  if (notFoundProp && *notFoundProp) {
     std::string tmp = notFoundProp;
 
     cmSystemTools::ExpandListArgument(tmp, notFoundContents, false);
-    std::vector<std::string>::iterator nameIt = std::find(
-                 notFoundContents.begin(), notFoundContents.end(), this->Name);
-    if(nameIt != notFoundContents.end())
-      {
+    std::vector<std::string>::iterator nameIt =
+      std::find(notFoundContents.begin(), notFoundContents.end(), this->Name);
+    if (nameIt != notFoundContents.end()) {
       notFoundContents.erase(nameIt);
-      }
     }
+  }
 
-  if(found)
-    {
+  if (found) {
     foundContents.push_back(this->Name);
-    }
-  else
-    {
+  } else {
     notFoundContents.push_back(this->Name);
-    }
-
+  }
 
   std::string tmp = cmJoin(foundContents, ";");
-  this->Makefile->GetState()
-      ->SetGlobalProperty("PACKAGES_FOUND", tmp.c_str());
+  this->Makefile->GetState()->SetGlobalProperty("PACKAGES_FOUND", tmp.c_str());
 
   tmp = cmJoin(notFoundContents, ";");
-  this->Makefile->GetState()
-      ->SetGlobalProperty("PACKAGES_NOT_FOUND", tmp.c_str());
+  this->Makefile->GetState()->SetGlobalProperty("PACKAGES_NOT_FOUND",
+                                                tmp.c_str());
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::AppendSuccessInformation()
 {
   {
-  std::string transitivePropName = "_CMAKE_";
-  transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
-  this->Makefile->GetState()
-                ->SetGlobalProperty(transitivePropName, "False");
+    std::string transitivePropName = "_CMAKE_";
+    transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
+    this->Makefile->GetState()->SetGlobalProperty(transitivePropName, "False");
   }
   std::string found = this->Name;
   found += "_FOUND";
@@ -1080,8 +940,8 @@ void cmFindPackageCommand::AppendSuccessInformation()
 
   const char* upperResult = this->Makefile->GetDefinition(upperFound);
   const char* result = this->Makefile->GetDefinition(found);
-  bool packageFound = ((cmSystemTools::IsOn(result))
-                                        || (cmSystemTools::IsOn(upperResult)));
+  bool packageFound =
+    ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult)));
 
   this->AppendToFoundProperty(packageFound);
 
@@ -1090,79 +950,66 @@ void cmFindPackageCommand::AppendSuccessInformation()
   std::string quietInfoPropName = "_CMAKE_";
   quietInfoPropName += this->Name;
   quietInfoPropName += "_QUIET";
-  this->Makefile->GetState()
-      ->SetGlobalProperty(quietInfoPropName, this->Quiet ? "TRUE" : "FALSE");
+  this->Makefile->GetState()->SetGlobalProperty(
+    quietInfoPropName, this->Quiet ? "TRUE" : "FALSE");
 
   // set a global property to record the required version of this package
   std::string versionInfoPropName = "_CMAKE_";
   versionInfoPropName += this->Name;
   versionInfoPropName += "_REQUIRED_VERSION";
   std::string versionInfo;
-  if(!this->Version.empty())
-    {
+  if (!this->Version.empty()) {
     versionInfo = this->VersionExact ? "==" : ">=";
     versionInfo += " ";
     versionInfo += this->Version;
-    }
-  this->Makefile->GetState()
-      ->SetGlobalProperty(versionInfoPropName, versionInfo.c_str());
-  if (this->Required)
-    {
+  }
+  this->Makefile->GetState()->SetGlobalProperty(versionInfoPropName,
+                                                versionInfo.c_str());
+  if (this->Required) {
     std::string requiredInfoPropName = "_CMAKE_";
     requiredInfoPropName += this->Name;
     requiredInfoPropName += "_TYPE";
-    this->Makefile->GetState()
-        ->SetGlobalProperty(requiredInfoPropName, "REQUIRED");
-    }
-
+    this->Makefile->GetState()->SetGlobalProperty(requiredInfoPropName,
+                                                  "REQUIRED");
+  }
 
   // Restore original state of "_FIND_" variables we set.
   this->RestoreFindDefinitions();
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::ComputePrefixes()
 {
-  if(!this->NoDefaultPath)
-    {
-    if(!this->NoCMakePath)
-      {
+  if (!this->NoDefaultPath) {
+    if (!this->NoCMakePath) {
       this->FillPrefixesCMakeVariable();
-      }
-    if(!this->NoCMakeEnvironmentPath)
-      {
+    }
+    if (!this->NoCMakeEnvironmentPath) {
       this->FillPrefixesCMakeEnvironment();
-      }
     }
+  }
   this->FillPrefixesUserHints();
-  if(!this->NoDefaultPath)
-    {
-    if(!this->NoSystemEnvironmentPath)
-      {
+  if (!this->NoDefaultPath) {
+    if (!this->NoSystemEnvironmentPath) {
       this->FillPrefixesSystemEnvironment();
-      }
-    if(!this->NoUserRegistry)
-      {
+    }
+    if (!this->NoUserRegistry) {
       this->FillPrefixesUserRegistry();
-      }
-    if(!this->NoCMakeSystemPath)
-      {
+    }
+    if (!this->NoCMakeSystemPath) {
       this->FillPrefixesCMakeSystemVariable();
-      }
-    if(!this->NoSystemRegistry)
-      {
+    }
+    if (!this->NoSystemRegistry) {
       this->FillPrefixesSystemRegistry();
-      }
     }
+  }
   this->FillPrefixesUserGuess();
 
   this->ComputeFinalPaths();
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
 
   // Check the environment variable with the same name as the cache
   // entry.
@@ -1174,43 +1021,36 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
   paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesCMakeVariable()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::CMake];
 
   paths.AddCMakePath("CMAKE_PREFIX_PATH");
   paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
   paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesSystemEnvironment()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::SystemEnvironment];
 
   // Use the system search path to generate prefixes.
   // Relative paths are interpreted with respect to the current
   // working directory.
   std::vector<std::string> tmp;
   cmSystemTools::GetPath(tmp);
-  for(std::vector<std::string>::iterator i = tmp.begin();
-      i != tmp.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
+       ++i) {
     // If the path is a PREFIX/bin case then add its parent instead.
-    if((cmHasLiteralSuffix(*i, "/bin")) ||
-       (cmHasLiteralSuffix(*i, "/sbin")))
-      {
+    if ((cmHasLiteralSuffix(*i, "/bin")) ||
+        (cmHasLiteralSuffix(*i, "/sbin"))) {
       paths.AddPath(cmSystemTools::GetFilenamePath(*i));
-      }
-    else
-      {
+    } else {
       paths.AddPath(*i);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesUserRegistry()
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -1218,33 +1058,29 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
 #elif defined(__HAIKU__)
   char dir[B_PATH_NAME_LENGTH];
   if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) ==
-      B_OK)
-    {
+      B_OK) {
     std::string fname = dir;
     fname += "/cmake/packages/";
     fname += Name;
     this->LoadPackageRegistryDir(fname,
                                  this->LabeledPaths[PathLabel::UserRegistry]);
-    }
+  }
 #else
-  if(const char* home = cmSystemTools::GetEnv("HOME"))
-    {
+  if (const char* home = cmSystemTools::GetEnv("HOME")) {
     std::string dir = home;
     dir += "/.cmake/packages/";
     dir += this->Name;
     this->LoadPackageRegistryDir(dir,
                                  this->LabeledPaths[PathLabel::UserRegistry]);
-    }
+  }
 #endif
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesSystemRegistry()
 {
-  if(this->NoSystemRegistry || this->NoDefaultPath)
-    {
+  if (this->NoSystemRegistry || this->NoDefaultPath) {
     return;
-    }
+  }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
   this->LoadPackageRegistryWinSystem();
@@ -1252,16 +1088,15 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
 }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-# include <windows.h>
-# undef GetCurrentDirectory
-  // http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx
-# if !defined(KEY_WOW64_32KEY)
-#  define KEY_WOW64_32KEY 0x0200
-# endif
-# if !defined(KEY_WOW64_64KEY)
-#  define KEY_WOW64_64KEY 0x0100
-# endif
-//----------------------------------------------------------------------------
+#include <windows.h>
+#undef GetCurrentDirectory
+// http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx
+#if !defined(KEY_WOW64_32KEY)
+#define KEY_WOW64_32KEY 0x0200
+#endif
+#if !defined(KEY_WOW64_64KEY)
+#define KEY_WOW64_64KEY 0x0100
+#endif
 void cmFindPackageCommand::LoadPackageRegistryWinUser()
 {
   // HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views.
@@ -1269,26 +1104,21 @@ void cmFindPackageCommand::LoadPackageRegistryWinUser()
                                this->LabeledPaths[PathLabel::UserRegistry]);
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::LoadPackageRegistryWinSystem()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemRegistry];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::SystemRegistry];
 
   // HKEY_LOCAL_MACHINE\\SOFTWARE has separate 32-bit and 64-bit views.
   // Prefer the target platform view first.
-  if(this->Makefile->PlatformIs64Bit())
-    {
+  if (this->Makefile->PlatformIs64Bit()) {
     this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
     this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
-    }
-  else
-    {
+  } else {
     this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
     this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
                                                   cmSearchPath& outPaths)
 {
@@ -1296,248 +1126,221 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
   key += cmsys::Encoding::ToWide(this->Name);
   std::set<std::wstring> bad;
   HKEY hKey;
-  if(RegOpenKeyExW(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(),
-                   0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS)
-    {
+  if (RegOpenKeyExW(user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(),
+                    0, KEY_QUERY_VALUE | view, &hKey) == ERROR_SUCCESS) {
     DWORD valueType = REG_NONE;
     wchar_t name[16383]; // RegEnumValue docs limit name to 32767 _bytes_
     std::vector<wchar_t> data(512);
     bool done = false;
     DWORD index = 0;
-    while(!done)
-      {
+    while (!done) {
       DWORD nameSize = static_cast<DWORD>(sizeof(name));
-      DWORD dataSize = static_cast<DWORD>(data.size()*sizeof(data[0]));
-      switch(RegEnumValueW(hKey, index, name, &nameSize,
-                          0, &valueType, (BYTE*)&data[0], &dataSize))
-        {
+      DWORD dataSize = static_cast<DWORD>(data.size() * sizeof(data[0]));
+      switch (RegEnumValueW(hKey, index, name, &nameSize, 0, &valueType,
+                            (BYTE*)&data[0], &dataSize)) {
         case ERROR_SUCCESS:
           ++index;
-          if(valueType == REG_SZ)
-            {
+          if (valueType == REG_SZ) {
             data[dataSize] = 0;
-            if(!this->CheckPackageRegistryEntry(
-                  cmsys::Encoding::ToNarrow(&data[0]), outPaths))
-              {
+            if (!this->CheckPackageRegistryEntry(
+                  cmsys::Encoding::ToNarrow(&data[0]), outPaths)) {
               // The entry is invalid.
               bad.insert(name);
-              }
             }
+          }
           break;
         case ERROR_MORE_DATA:
-          data.resize((dataSize+sizeof(data[0])-1)/sizeof(data[0]));
+          data.resize((dataSize + sizeof(data[0]) - 1) / sizeof(data[0]));
+          break;
+        case ERROR_NO_MORE_ITEMS:
+        default:
+          done = true;
           break;
-        case ERROR_NO_MORE_ITEMS: default: done = true; break;
-        }
       }
-    RegCloseKey(hKey);
     }
+    RegCloseKey(hKey);
+  }
 
   // Remove bad values if possible.
-  if(user && !bad.empty() &&
-     RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(),
-                  0, KEY_SET_VALUE|view, &hKey) == ERROR_SUCCESS)
-    {
-    for(std::set<std::wstring>::const_iterator vi = bad.begin();
-        vi != bad.end(); ++vi)
-      {
+  if (user && !bad.empty() &&
+      RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_SET_VALUE | view,
+                    &hKey) == ERROR_SUCCESS) {
+    for (std::set<std::wstring>::const_iterator vi = bad.begin();
+         vi != bad.end(); ++vi) {
       RegDeleteValueW(hKey, vi->c_str());
-      }
-    RegCloseKey(hKey);
     }
+    RegCloseKey(hKey);
+  }
 }
 #else
-//----------------------------------------------------------------------------
 class cmFindPackageCommandHoldFile
 {
   const char* File;
+
 public:
-  cmFindPackageCommandHoldFile(const char* f): File(f) {}
+  cmFindPackageCommandHoldFile(const char* f)
+    : File(f)
+  {
+  }
   ~cmFindPackageCommandHoldFile()
-    { if(this->File) { cmSystemTools::RemoveFile(this->File); } }
+  {
+    if (this->File) {
+      cmSystemTools::RemoveFile(this->File);
+    }
+  }
   void Release() { this->File = 0; }
 };
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
                                                   cmSearchPath& outPaths)
 {
   cmsys::Directory files;
-  if(!files.Load(dir))
-    {
+  if (!files.Load(dir)) {
     return;
-    }
+  }
 
   std::string fname;
-  for(unsigned long i=0; i < files.GetNumberOfFiles(); ++i)
-    {
+  for (unsigned long i = 0; i < files.GetNumberOfFiles(); ++i) {
     fname = dir;
     fname += "/";
     fname += files.GetFile(i);
 
-    if(!cmSystemTools::FileIsDirectory(fname))
-      {
+    if (!cmSystemTools::FileIsDirectory(fname)) {
       // Hold this file hostage until it behaves.
       cmFindPackageCommandHoldFile holdFile(fname.c_str());
 
       // Load the file.
       cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
       std::string fentry;
-      if(fin && cmSystemTools::GetLineFromStream(fin, fentry) &&
-         this->CheckPackageRegistryEntry(fentry, outPaths))
-        {
+      if (fin && cmSystemTools::GetLineFromStream(fin, fentry) &&
+          this->CheckPackageRegistryEntry(fentry, outPaths)) {
         // The file references an existing package, so release it.
         holdFile.Release();
-        }
       }
     }
+  }
 
   // TODO: Wipe out the directory if it is empty.
 }
 #endif
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
                                                      cmSearchPath& outPaths)
 {
   // Parse the content of one package registry entry.
-  if(cmSystemTools::FileIsFullPath(fname.c_str()))
-    {
+  if (cmSystemTools::FileIsFullPath(fname.c_str())) {
     // The first line in the stream is the full path to a file or
     // directory containing the package.
-    if(cmSystemTools::FileExists(fname.c_str()))
-      {
+    if (cmSystemTools::FileExists(fname.c_str())) {
       // The path exists.  Look for the package here.
-      if(!cmSystemTools::FileIsDirectory(fname))
-        {
+      if (!cmSystemTools::FileIsDirectory(fname)) {
         outPaths.AddPath(cmSystemTools::GetFilenamePath(fname));
-        }
-      else
-        {
+      } else {
         outPaths.AddPath(fname);
-        }
-      return true;
       }
-    else
-      {
+      return true;
+    } else {
       // The path does not exist.  Assume the stream content is
       // associated with an old package that no longer exists, and
       // delete it to keep the package registry clean.
       return false;
-      }
     }
-  else
-    {
+  } else {
     // The first line in the stream is not the full path to a file or
     // directory.  Assume the stream content was created by a future
     // version of CMake that uses a different format, and leave it.
     return true;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeSystem];
 
   paths.AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
   paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
   paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesUserGuess()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
 
-  for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin();
-      p != this->UserGuessArgs.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p =
+         this->UserGuessArgs.begin();
+       p != this->UserGuessArgs.end(); ++p) {
     paths.AddUserPath(*p);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::FillPrefixesUserHints()
 {
-  cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints];
+  cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
 
-  for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin();
-      p != this->UserHintsArgs.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p =
+         this->UserHintsArgs.begin();
+       p != this->UserHintsArgs.end(); ++p) {
     paths.AddUserPath(*p);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
 {
-  assert(!dir.empty() && dir[dir.size()-1] == '/');
+  assert(!dir.empty() && dir[dir.size() - 1] == '/');
 
   // Check each path suffix on this directory.
-  for(std::vector<std::string>::const_iterator
-        si = this->SearchPathSuffixes.begin();
-      si != this->SearchPathSuffixes.end(); ++si)
-    {
+  for (std::vector<std::string>::const_iterator si =
+         this->SearchPathSuffixes.begin();
+       si != this->SearchPathSuffixes.end(); ++si) {
     std::string d = dir;
-    if(!si->empty())
-      {
+    if (!si->empty()) {
       d += *si;
       d += "/";
-      }
-    if(this->CheckDirectory(d))
-      {
+    }
+    if (this->CheckDirectory(d)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::CheckDirectory(std::string const& dir)
 {
-  assert(!dir.empty() && dir[dir.size()-1] == '/');
+  assert(!dir.empty() && dir[dir.size() - 1] == '/');
 
   // Look for the file in this directory.
-  std::string d = dir.substr(0, dir.size()-1);
-  if(this->FindConfigFile(d, this->FileFound))
-    {
+  std::string d = dir.substr(0, dir.size() - 1);
+  if (this->FindConfigFile(d, this->FileFound)) {
     // Remove duplicate slashes.
     cmSystemTools::ConvertToUnixSlashes(this->FileFound);
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
                                           std::string& file)
 {
-  if (this->IgnoredPaths.count(dir))
-    {
+  if (this->IgnoredPaths.count(dir)) {
     return false;
-    }
+  }
 
-  for(std::vector<std::string>::const_iterator ci = this->Configs.begin();
-      ci != this->Configs.end(); ++ci)
-    {
+  for (std::vector<std::string>::const_iterator ci = this->Configs.begin();
+       ci != this->Configs.end(); ++ci) {
     file = dir;
     file += "/";
     file += *ci;
-    if(this->DebugMode)
-      {
+    if (this->DebugMode) {
       fprintf(stderr, "Checking file [%s]\n", file.c_str());
-      }
-    if(cmSystemTools::FileExists(file.c_str(), true) &&
-       this->CheckVersion(file))
-      {
+    }
+    if (cmSystemTools::FileExists(file.c_str(), true) &&
+        this->CheckVersion(file)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
 {
   bool result = false; // by default, assume the version is not ok.
@@ -1551,29 +1354,25 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
   // Look for foo-config-version.cmake
   std::string version_file = version_file_base;
   version_file += "-version.cmake";
-  if ((haveResult == false)
-       && (cmSystemTools::FileExists(version_file.c_str(), true)))
-    {
+  if ((haveResult == false) &&
+      (cmSystemTools::FileExists(version_file.c_str(), true))) {
     result = this->CheckVersionFile(version_file, version);
     haveResult = true;
-    }
+  }
 
   // Look for fooConfigVersion.cmake
   version_file = version_file_base;
   version_file += "Version.cmake";
-  if ((haveResult == false)
-       && (cmSystemTools::FileExists(version_file.c_str(), true)))
-    {
+  if ((haveResult == false) &&
+      (cmSystemTools::FileExists(version_file.c_str(), true))) {
     result = this->CheckVersionFile(version_file, version);
     haveResult = true;
-    }
-
+  }
 
   // If no version was requested a versionless package is acceptable.
-  if ((haveResult == false) && (this->Version.empty()))
-    {
+  if ((haveResult == false) && (this->Version.empty())) {
     result = true;
-    }
+  }
 
   ConfigFileInfo configFileInfo;
   configFileInfo.filename = config_file;
@@ -1583,7 +1382,6 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
   return result;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
                                             std::string& result_version)
 {
@@ -1601,8 +1399,7 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
 
   // Set the input variables.
   this->Makefile->AddDefinition("PACKAGE_FIND_NAME", this->Name.c_str());
-  this->Makefile->AddDefinition("PACKAGE_FIND_VERSION",
-                                this->Version.c_str());
+  this->Makefile->AddDefinition("PACKAGE_FIND_VERSION", this->Version.c_str());
   char buf[64];
   sprintf(buf, "%u", this->VersionMajor);
   this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf);
@@ -1618,21 +1415,18 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
   // Load the version check file.  Pass NoPolicyScope because we do
   // our own policy push/pop independent of CMP0011.
   bool suitable = false;
-  if(this->ReadListFile(version_file.c_str(), NoPolicyScope))
-    {
+  if (this->ReadListFile(version_file.c_str(), NoPolicyScope)) {
     // Check the output variables.
     bool okay = this->Makefile->IsOn("PACKAGE_VERSION_EXACT");
     bool unsuitable = this->Makefile->IsOn("PACKAGE_VERSION_UNSUITABLE");
-    if(!okay && !this->VersionExact)
-      {
+    if (!okay && !this->VersionExact) {
       okay = this->Makefile->IsOn("PACKAGE_VERSION_COMPATIBLE");
-      }
+    }
 
     // The package is suitable if the version is okay and not
     // explicitly unsuitable.
     suitable = !unsuitable && (okay || this->Version.empty());
-    if(suitable)
-      {
+    if (suitable) {
       // Get the version found.
       this->VersionFound =
         this->Makefile->GetSafeDefinition("PACKAGE_VERSION");
@@ -1644,60 +1438,57 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
       unsigned int parsed_patch;
       unsigned int parsed_tweak;
       this->VersionFoundCount =
-        sscanf(this->VersionFound.c_str(), "%u.%u.%u.%u",
-               &parsed_major, &parsed_minor,
-               &parsed_patch, &parsed_tweak);
-      switch(this->VersionFoundCount)
-        {
-        case 4: this->VersionFoundTweak = parsed_tweak; // no break!
-        case 3: this->VersionFoundPatch = parsed_patch; // no break!
-        case 2: this->VersionFoundMinor = parsed_minor; // no break!
-        case 1: this->VersionFoundMajor = parsed_major; // no break!
-        default: break;
-        }
+        sscanf(this->VersionFound.c_str(), "%u.%u.%u.%u", &parsed_major,
+               &parsed_minor, &parsed_patch, &parsed_tweak);
+      switch (this->VersionFoundCount) {
+        case 4:
+          this->VersionFoundTweak = parsed_tweak; // no break!
+        case 3:
+          this->VersionFoundPatch = parsed_patch; // no break!
+        case 2:
+          this->VersionFoundMinor = parsed_minor; // no break!
+        case 1:
+          this->VersionFoundMajor = parsed_major; // no break!
+        default:
+          break;
       }
     }
+  }
 
   result_version = this->Makefile->GetSafeDefinition("PACKAGE_VERSION");
-  if (result_version.empty())
-    {
+  if (result_version.empty()) {
     result_version = "unknown";
-    }
+  }
 
   // Succeed if the version is suitable.
   return suitable;
 }
 
-//----------------------------------------------------------------------------
 void cmFindPackageCommand::StoreVersionFound()
 {
   // Store the whole version string.
   std::string ver = this->Name;
   ver += "_VERSION";
-  if(this->VersionFound.empty())
-    {
+  if (this->VersionFound.empty()) {
     this->Makefile->RemoveDefinition(ver);
-    }
-  else
-    {
+  } else {
     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", buf);
+  this->Makefile->AddDefinition(ver + "_MAJOR", buf);
   sprintf(buf, "%u", this->VersionFoundMinor);
-  this->Makefile->AddDefinition(ver+"_MINOR", buf);
+  this->Makefile->AddDefinition(ver + "_MINOR", buf);
   sprintf(buf, "%u", this->VersionFoundPatch);
-  this->Makefile->AddDefinition(ver+"_PATCH", buf);
+  this->Makefile->AddDefinition(ver + "_PATCH", buf);
   sprintf(buf, "%u", this->VersionFoundTweak);
-  this->Makefile->AddDefinition(ver+"_TWEAK", buf);
+  this->Makefile->AddDefinition(ver + "_TWEAK", buf);
   sprintf(buf, "%u", this->VersionFoundCount);
-  this->Makefile->AddDefinition(ver+"_COUNT", buf);
+  this->Makefile->AddDefinition(ver + "_COUNT", buf);
 }
 
-//----------------------------------------------------------------------------
 #include <cmsys/Glob.hxx>
 #include <cmsys/String.h>
 #include <cmsys/auto_ptr.hxx>
@@ -1709,6 +1500,7 @@ public:
   virtual ~cmFileListGeneratorBase() {}
 protected:
   bool Consider(std::string const& fullPath, cmFileList& listing);
+
 private:
   bool Search(cmFileList&);
   virtual bool Search(std::string const& parent, cmFileList&) = 0;
@@ -1721,29 +1513,30 @@ private:
 class cmFileList
 {
 public:
-  cmFileList(): First(), Last(0) {}
+  cmFileList()
+    : First()
+    , Last(0)
+  {
+  }
   virtual ~cmFileList() {}
   cmFileList& operator/(cmFileListGeneratorBase const& rhs)
-    {
-    if(this->Last)
-      {
+  {
+    if (this->Last) {
       this->Last = this->Last->SetNext(rhs);
-      }
-    else
-      {
+    } else {
       this->First = rhs.Clone();
       this->Last = this->First.get();
-      }
-    return *this;
     }
+    return *this;
+  }
   bool Search()
-    {
-    if(this->First.get())
-      {
+  {
+    if (this->First.get()) {
       return this->First->Search(*this);
-      }
-    return false;
     }
+    return false;
+  }
+
 private:
   virtual bool Visit(std::string const& fullPath) = 0;
   friend class cmFileListGeneratorBase;
@@ -1751,24 +1544,25 @@ private:
   cmFileListGeneratorBase* Last;
 };
 
-class cmFindPackageFileList: public cmFileList
+class cmFindPackageFileList : public cmFileList
 {
 public:
-  cmFindPackageFileList(cmFindPackageCommand* fpc,
-                        bool use_suffixes = true):
-    cmFileList(), FPC(fpc), UseSuffixes(use_suffixes) {}
+  cmFindPackageFileList(cmFindPackageCommand* fpc, bool use_suffixes = true)
+    : cmFileList()
+    , FPC(fpc)
+    , UseSuffixes(use_suffixes)
+  {
+  }
+
 private:
   bool Visit(std::string const& fullPath)
-    {
-    if(this->UseSuffixes)
-      {
+  {
+    if (this->UseSuffixes) {
       return this->FPC->SearchDirectory(fullPath);
-      }
-    else
-      {
+    } else {
       return this->FPC->CheckDirectory(fullPath);
-      }
     }
+  }
   cmFindPackageCommand* FPC;
   bool UseSuffixes;
 };
@@ -1778,8 +1572,8 @@ bool cmFileListGeneratorBase::Search(cmFileList& listing)
   return this->Search("", listing);
 }
 
-cmFileListGeneratorBase*
-cmFileListGeneratorBase::SetNext(cmFileListGeneratorBase const& next)
+cmFileListGeneratorBase* cmFileListGeneratorBase::SetNext(
+  cmFileListGeneratorBase const& next)
 {
   this->Next = next.Clone();
   return this->Next.get();
@@ -1788,486 +1582,467 @@ cmFileListGeneratorBase::SetNext(cmFileListGeneratorBase const& next)
 bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
                                        cmFileList& listing)
 {
-  if(this->Next.get())
-    {
+  if (this->Next.get()) {
     return this->Next->Search(fullPath + "/", listing);
-    }
-  else
-    {
+  } else {
     return listing.Visit(fullPath + "/");
-    }
+  }
 }
 
-class cmFileListGeneratorFixed: public cmFileListGeneratorBase
+class cmFileListGeneratorFixed : public cmFileListGeneratorBase
 {
 public:
-  cmFileListGeneratorFixed(std::string const& str):
-    cmFileListGeneratorBase(), String(str) {}
-  cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r):
-    cmFileListGeneratorBase(), String(r.String) {}
+  cmFileListGeneratorFixed(std::string const& str)
+    : cmFileListGeneratorBase()
+    , String(str)
+  {
+  }
+  cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r)
+    : cmFileListGeneratorBase()
+    , String(r.String)
+  {
+  }
+
 private:
   std::string String;
   virtual bool Search(std::string const& parent, cmFileList& lister)
-    {
+  {
     std::string fullPath = parent + this->String;
     return this->Consider(fullPath, lister);
-    }
+  }
   virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
-    {
-    cmsys::auto_ptr<cmFileListGeneratorBase>
-      g(new cmFileListGeneratorFixed(*this));
+  {
+    cmsys::auto_ptr<cmFileListGeneratorBase> g(
+      new cmFileListGeneratorFixed(*this));
     return g;
-    }
+  }
 };
 
-class cmFileListGeneratorEnumerate: public cmFileListGeneratorBase
+class cmFileListGeneratorEnumerate : public cmFileListGeneratorBase
 {
 public:
-  cmFileListGeneratorEnumerate(std::vector<std::string> const& v):
-    cmFileListGeneratorBase(), Vector(v) {}
-  cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r):
-    cmFileListGeneratorBase(), Vector(r.Vector) {}
+  cmFileListGeneratorEnumerate(std::vector<std::string> const& v)
+    : cmFileListGeneratorBase()
+    , Vector(v)
+  {
+  }
+  cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r)
+    : cmFileListGeneratorBase()
+    , Vector(r.Vector)
+  {
+  }
+
 private:
   std::vector<std::string> const& Vector;
   virtual bool Search(std::string const& parent, cmFileList& lister)
-    {
-    for(std::vector<std::string>::const_iterator i = this->Vector.begin();
-        i != this->Vector.end(); ++i)
-      {
-      if(this->Consider(parent + *i, lister))
-        {
+  {
+    for (std::vector<std::string>::const_iterator i = this->Vector.begin();
+         i != this->Vector.end(); ++i) {
+      if (this->Consider(parent + *i, lister)) {
         return true;
-        }
       }
-    return false;
     }
+    return false;
+  }
   virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
-    {
-    cmsys::auto_ptr<cmFileListGeneratorBase>
-      g(new cmFileListGeneratorEnumerate(*this));
+  {
+    cmsys::auto_ptr<cmFileListGeneratorBase> g(
+      new cmFileListGeneratorEnumerate(*this));
     return g;
-    }
+  }
 };
 
-class cmFileListGeneratorProject: public cmFileListGeneratorBase
+class cmFileListGeneratorProject : public cmFileListGeneratorBase
 {
 public:
-  cmFileListGeneratorProject(std::vector<std::string> const& names):
-    cmFileListGeneratorBase(), Names(names) {}
-  cmFileListGeneratorProject(cmFileListGeneratorProject const& r):
-    cmFileListGeneratorBase(), Names(r.Names) {}
+  cmFileListGeneratorProject(std::vector<std::string> const& names)
+    : cmFileListGeneratorBase()
+    , Names(names)
+  {
+  }
+  cmFileListGeneratorProject(cmFileListGeneratorProject const& r)
+    : cmFileListGeneratorBase()
+    , Names(r.Names)
+  {
+  }
+
 private:
   std::vector<std::string> const& Names;
   virtual bool Search(std::string const& parent, cmFileList& lister)
-    {
+  {
     // Construct a list of matches.
     std::vector<std::string> matches;
     cmsys::Directory d;
     d.Load(parent);
-    for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i)
-      {
+    for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
       const char* fname = d.GetFile(i);
-      if(strcmp(fname, ".") == 0 ||
-         strcmp(fname, "..") == 0)
-        {
+      if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
         continue;
-        }
-      for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-          ni != this->Names.end(); ++ni)
-        {
-        if(cmsysString_strncasecmp(fname, ni->c_str(),
-                                   ni->length()) == 0)
-          {
+      }
+      for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+           ni != this->Names.end(); ++ni) {
+        if (cmsysString_strncasecmp(fname, ni->c_str(), ni->length()) == 0) {
           matches.push_back(fname);
-          }
         }
       }
+    }
 
-    for(std::vector<std::string>::const_iterator i = matches.begin();
-        i != matches.end(); ++i)
-      {
-      if(this->Consider(parent + *i, lister))
-        {
+    for (std::vector<std::string>::const_iterator i = matches.begin();
+         i != matches.end(); ++i) {
+      if (this->Consider(parent + *i, lister)) {
         return true;
-        }
       }
-    return false;
     }
+    return false;
+  }
   virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
-    {
-    cmsys::auto_ptr<cmFileListGeneratorBase>
-      g(new cmFileListGeneratorProject(*this));
+  {
+    cmsys::auto_ptr<cmFileListGeneratorBase> g(
+      new cmFileListGeneratorProject(*this));
     return g;
-    }
+  }
 };
 
-class cmFileListGeneratorMacProject: public cmFileListGeneratorBase
+class cmFileListGeneratorMacProject : public cmFileListGeneratorBase
 {
 public:
   cmFileListGeneratorMacProject(std::vector<std::string> const& names,
-                                const char* ext):
-    cmFileListGeneratorBase(), Names(names), Extension(ext) {}
-  cmFileListGeneratorMacProject(cmFileListGeneratorMacProject const& r):
-    cmFileListGeneratorBase(), Names(r.Names), Extension(r.Extension) {}
+                                const char* ext)
+    : cmFileListGeneratorBase()
+    , Names(names)
+    , Extension(ext)
+  {
+  }
+  cmFileListGeneratorMacProject(cmFileListGeneratorMacProject const& r)
+    : cmFileListGeneratorBase()
+    , Names(r.Names)
+    , Extension(r.Extension)
+  {
+  }
+
 private:
   std::vector<std::string> const& Names;
   std::string Extension;
   virtual bool Search(std::string const& parent, cmFileList& lister)
-    {
+  {
     // Construct a list of matches.
     std::vector<std::string> matches;
     cmsys::Directory d;
     d.Load(parent);
-    for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i)
-      {
+    for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
       const char* fname = d.GetFile(i);
-      if(strcmp(fname, ".") == 0 ||
-         strcmp(fname, "..") == 0)
-        {
+      if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
         continue;
-        }
-      for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-          ni != this->Names.end(); ++ni)
-        {
+      }
+      for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+           ni != this->Names.end(); ++ni) {
         std::string name = *ni;
         name += this->Extension;
-        if(cmsysString_strcasecmp(fname, name.c_str()) == 0)
-          {
+        if (cmsysString_strcasecmp(fname, name.c_str()) == 0) {
           matches.push_back(fname);
-          }
         }
       }
+    }
 
-    for(std::vector<std::string>::const_iterator i = matches.begin();
-        i != matches.end(); ++i)
-      {
-      if(this->Consider(parent + *i, lister))
-        {
+    for (std::vector<std::string>::const_iterator i = matches.begin();
+         i != matches.end(); ++i) {
+      if (this->Consider(parent + *i, lister)) {
         return true;
-        }
       }
-    return false;
     }
+    return false;
+  }
   virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
-    {
-    cmsys::auto_ptr<cmFileListGeneratorBase>
-      g(new cmFileListGeneratorMacProject(*this));
+  {
+    cmsys::auto_ptr<cmFileListGeneratorBase> g(
+      new cmFileListGeneratorMacProject(*this));
     return g;
-    }
+  }
 };
 
-class cmFileListGeneratorCaseInsensitive: public cmFileListGeneratorBase
+class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase
 {
 public:
-  cmFileListGeneratorCaseInsensitive(std::string const& str):
-    cmFileListGeneratorBase(), String(str) {}
+  cmFileListGeneratorCaseInsensitive(std::string const& str)
+    : cmFileListGeneratorBase()
+    , String(str)
+  {
+  }
   cmFileListGeneratorCaseInsensitive(
-    cmFileListGeneratorCaseInsensitive const& r):
-    cmFileListGeneratorBase(), String(r.String) {}
+    cmFileListGeneratorCaseInsensitive const& r)
+    : cmFileListGeneratorBase()
+    , String(r.String)
+  {
+  }
+
 private:
   std::string String;
   virtual bool Search(std::string const& parent, cmFileList& lister)
-    {
+  {
     // Look for matching files.
     std::vector<std::string> matches;
     cmsys::Directory d;
     d.Load(parent);
-    for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i)
-      {
+    for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
       const char* fname = d.GetFile(i);
-      if(strcmp(fname, ".") == 0 ||
-         strcmp(fname, "..") == 0)
-        {
+      if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
         continue;
-        }
-      if(cmsysString_strcasecmp(fname, this->String.c_str()) == 0)
-        {
-        if(this->Consider(parent + fname, lister))
-          {
+      }
+      if (cmsysString_strcasecmp(fname, this->String.c_str()) == 0) {
+        if (this->Consider(parent + fname, lister)) {
           return true;
-          }
         }
       }
-    return false;
     }
+    return false;
+  }
   virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
-    {
-    cmsys::auto_ptr<cmFileListGeneratorBase>
-      g(new cmFileListGeneratorCaseInsensitive(*this));
+  {
+    cmsys::auto_ptr<cmFileListGeneratorBase> g(
+      new cmFileListGeneratorCaseInsensitive(*this));
     return g;
-    }
+  }
 };
 
-class cmFileListGeneratorGlob: public cmFileListGeneratorBase
+class cmFileListGeneratorGlob : public cmFileListGeneratorBase
 {
 public:
-  cmFileListGeneratorGlob(std::string const& str):
-    cmFileListGeneratorBase(), Pattern(str) {}
-  cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r):
-    cmFileListGeneratorBase(), Pattern(r.Pattern) {}
+  cmFileListGeneratorGlob(std::string const& str)
+    : cmFileListGeneratorBase()
+    , Pattern(str)
+  {
+  }
+  cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r)
+    : cmFileListGeneratorBase()
+    , Pattern(r.Pattern)
+  {
+  }
+
 private:
   std::string Pattern;
   virtual bool Search(std::string const& parent, cmFileList& lister)
-    {
+  {
     // Glob the set of matching files.
     std::string expr = parent;
     expr += this->Pattern;
     cmsys::Glob g;
-    if(!g.FindFiles(expr))
-      {
+    if (!g.FindFiles(expr)) {
       return false;
-      }
+    }
     std::vector<std::string> const& files = g.GetFiles();
 
     // Look for directories among the matches.
-    for(std::vector<std::string>::const_iterator fi = files.begin();
-        fi != files.end(); ++fi)
-      {
-      if(cmSystemTools::FileIsDirectory(*fi))
-        {
-        if(this->Consider(*fi, lister))
-          {
+    for (std::vector<std::string>::const_iterator fi = files.begin();
+         fi != files.end(); ++fi) {
+      if (cmSystemTools::FileIsDirectory(*fi)) {
+        if (this->Consider(*fi, lister)) {
           return true;
-          }
         }
       }
-    return false;
     }
+    return false;
+  }
   virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
-    {
-    cmsys::auto_ptr<cmFileListGeneratorBase>
-      g(new cmFileListGeneratorGlob(*this));
+  {
+    cmsys::auto_ptr<cmFileListGeneratorBase> g(
+      new cmFileListGeneratorGlob(*this));
     return g;
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
 {
-  assert(!prefix_in.empty() && prefix_in[prefix_in.size()-1] == '/');
-  if(this->DebugMode)
-    {
+  assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+  if (this->DebugMode) {
     fprintf(stderr, "Checking prefix [%s]\n", prefix_in.c_str());
-    }
+  }
 
   // Skip this if the prefix does not exist.
-  if(!cmSystemTools::FileIsDirectory(prefix_in))
-    {
+  if (!cmSystemTools::FileIsDirectory(prefix_in)) {
     return false;
-    }
+  }
 
   //  PREFIX/ (useful on windows or in build trees)
-  if(this->SearchDirectory(prefix_in))
-    {
+  if (this->SearchDirectory(prefix_in)) {
     return true;
-    }
+  }
 
   // Strip the trailing slash because the path generator is about to
   // add one.
-  std::string prefix = prefix_in.substr(0, prefix_in.size()-1);
+  std::string prefix = prefix_in.substr(0, prefix_in.size() - 1);
 
   //  PREFIX/(cmake|CMake)/ (useful on windows or in build trees)
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorCaseInsensitive("cmake");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorCaseInsensitive("cmake");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   //  PREFIX/(Foo|foo|FOO).*/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorProject(this->Names);
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorProject(this->Names);
+    if (lister.Search()) {
+      return true;
     }
   }
 
   //  PREFIX/(Foo|foo|FOO).*/(cmake|CMake)/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorProject(this->Names)
-    / cmFileListGeneratorCaseInsensitive("cmake");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorProject(this->Names) /
+      cmFileListGeneratorCaseInsensitive("cmake");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   // Construct list of common install locations (lib and share).
   std::vector<std::string> common;
-  if(!this->LibraryArchitecture.empty())
-    {
-    common.push_back("lib/"+this->LibraryArchitecture);
-    }
-  if(this->UseLib64Paths)
-    {
+  if (!this->LibraryArchitecture.empty()) {
+    common.push_back("lib/" + this->LibraryArchitecture);
+  }
+  if (this->UseLib64Paths) {
     common.push_back("lib64");
-    }
+  }
   common.push_back("lib");
   common.push_back("share");
 
   //  PREFIX/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorEnumerate(common)
-    / cmFileListGeneratorFixed("cmake")
-    / cmFileListGeneratorProject(this->Names);
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorEnumerate(common) /
+      cmFileListGeneratorFixed("cmake") /
+      cmFileListGeneratorProject(this->Names);
+    if (lister.Search()) {
+      return true;
     }
   }
 
   //  PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorEnumerate(common)
-    / cmFileListGeneratorProject(this->Names);
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorEnumerate(common) /
+      cmFileListGeneratorProject(this->Names);
+    if (lister.Search()) {
+      return true;
     }
   }
 
   //  PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorEnumerate(common)
-    / cmFileListGeneratorProject(this->Names)
-    / cmFileListGeneratorCaseInsensitive("cmake");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorEnumerate(common) /
+      cmFileListGeneratorProject(this->Names) /
+      cmFileListGeneratorCaseInsensitive("cmake");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in)
 {
-  assert(!prefix_in.empty() && prefix_in[prefix_in.size()-1] == '/');
-  if(this->DebugMode)
-    {
+  assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+  if (this->DebugMode) {
     fprintf(stderr, "Checking framework prefix [%s]\n", prefix_in.c_str());
-    }
+  }
 
   // Strip the trailing slash because the path generator is about to
   // add one.
-  std::string prefix = prefix_in.substr(0, prefix_in.size()-1);
+  std::string prefix = prefix_in.substr(0, prefix_in.size() - 1);
 
   // <prefix>/Foo.framework/Resources/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorMacProject(this->Names, ".framework")
-    / cmFileListGeneratorFixed("Resources");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorMacProject(this->Names, ".framework") /
+      cmFileListGeneratorFixed("Resources");
+    if (lister.Search()) {
+      return true;
     }
   }
   // <prefix>/Foo.framework/Resources/CMake/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorMacProject(this->Names, ".framework")
-    / cmFileListGeneratorFixed("Resources")
-    / cmFileListGeneratorCaseInsensitive("cmake");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorMacProject(this->Names, ".framework") /
+      cmFileListGeneratorFixed("Resources") /
+      cmFileListGeneratorCaseInsensitive("cmake");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   // <prefix>/Foo.framework/Versions/*/Resources/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorMacProject(this->Names, ".framework")
-    / cmFileListGeneratorFixed("Versions")
-    / cmFileListGeneratorGlob("*/Resources");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorMacProject(this->Names, ".framework") /
+      cmFileListGeneratorFixed("Versions") /
+      cmFileListGeneratorGlob("*/Resources");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   // <prefix>/Foo.framework/Versions/*/Resources/CMake/
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorMacProject(this->Names, ".framework")
-    / cmFileListGeneratorFixed("Versions")
-    / cmFileListGeneratorGlob("*/Resources")
-    / cmFileListGeneratorCaseInsensitive("cmake");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorMacProject(this->Names, ".framework") /
+      cmFileListGeneratorFixed("Versions") /
+      cmFileListGeneratorGlob("*/Resources") /
+      cmFileListGeneratorCaseInsensitive("cmake");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in)
 {
-  assert(!prefix_in.empty() && prefix_in[prefix_in.size()-1] == '/');
-  if(this->DebugMode)
-    {
+  assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+  if (this->DebugMode) {
     fprintf(stderr, "Checking bundle prefix [%s]\n", prefix_in.c_str());
-    }
+  }
 
   // Strip the trailing slash because the path generator is about to
   // add one.
-  std::string prefix = prefix_in.substr(0, prefix_in.size()-1);
+  std::string prefix = prefix_in.substr(0, prefix_in.size() - 1);
 
   // <prefix>/Foo.app/Contents/Resources
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorMacProject(this->Names, ".app")
-    / cmFileListGeneratorFixed("Contents/Resources");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorMacProject(this->Names, ".app") /
+      cmFileListGeneratorFixed("Contents/Resources");
+    if (lister.Search()) {
+      return true;
     }
   }
 
   // <prefix>/Foo.app/Contents/Resources/CMake
   {
-  cmFindPackageFileList lister(this);
-  lister
-    / cmFileListGeneratorFixed(prefix)
-    / cmFileListGeneratorMacProject(this->Names, ".app")
-    / cmFileListGeneratorFixed("Contents/Resources")
-    / cmFileListGeneratorCaseInsensitive("cmake");
-  if(lister.Search())
-    {
-    return true;
+    cmFindPackageFileList lister(this);
+    lister / cmFileListGeneratorFixed(prefix) /
+      cmFileListGeneratorMacProject(this->Names, ".app") /
+      cmFileListGeneratorFixed("Contents/Resources") /
+      cmFileListGeneratorCaseInsensitive("cmake");
+    if (lister.Search()) {
+      return true;
     }
   }
 
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 8bfd405..eff6b80 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -29,17 +29,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFindPackageCommand;
-    }
+  virtual cmCommand* Clone() { return new cmFindPackageCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -49,16 +46,21 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "find_package";}
+  virtual std::string GetName() const { return "find_package"; }
 
   cmTypeMacro(cmFindPackageCommand, cmFindCommon);
+
 private:
   class PathLabel : public cmFindCommon::PathLabel
   {
   protected:
     PathLabel();
+
   public:
-    PathLabel(const std::string& label) : cmFindCommon::PathLabel(label) { }
+    PathLabel(const std::string& label)
+      : cmFindCommon::PathLabel(label)
+    {
+    }
     static PathLabel UserRegistry;
     static PathLabel Builds;
     static PathLabel SystemRegistry;
@@ -79,7 +81,11 @@ private:
   bool FindPrefixedConfig();
   bool FindFrameworkConfig();
   bool FindAppBundleConfig();
-  enum PolicyScopeRule { NoPolicyScope, DoPolicyScope };
+  enum PolicyScopeRule
+  {
+    NoPolicyScope,
+    DoPolicyScope
+  };
   bool ReadListFile(const char* f, PolicyScopeRule psr);
   void StoreVersionFound();
 
@@ -111,7 +117,11 @@ private:
 
   friend class cmFindPackageFileList;
 
-  struct OriginalDef { bool exists; std::string value; };
+  struct OriginalDef
+  {
+    bool exists;
+    std::string value;
+  };
   std::map<std::string, OriginalDef> OriginalDefs;
 
   std::string Name;
@@ -145,7 +155,11 @@ private:
   std::vector<std::string> Configs;
   std::set<std::string> IgnoredPaths;
 
-  struct ConfigFileInfo { std::string filename; std::string version; };
+  struct ConfigFileInfo
+  {
+    std::string filename;
+    std::string version;
+  };
   std::vector<ConfigFileInfo> ConsideredConfigs;
 };
 
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 1f3d1a4..d24be6a 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -20,73 +20,57 @@ cmFindPathCommand::cmFindPathCommand()
 }
 
 // cmFindPathCommand
-bool cmFindPathCommand
-::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
+bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn,
+                                    cmExecutionStatus&)
 {
   this->VariableDocumentation = "Path to a file.";
   this->CMakePathName = "INCLUDE";
-  if(!this->ParseArguments(argsIn))
-    {
+  if (!this->ParseArguments(argsIn)) {
     return false;
-    }
-  if(this->AlreadyInCache)
-    {
+  }
+  if (this->AlreadyInCache) {
     // If the user specifies the entry on the command line without a
     // type we should add the type and docstring but keep the original
     // value.
-    if(this->AlreadyInCacheWithoutMetaInfo)
-      {
+    if (this->AlreadyInCacheWithoutMetaInfo) {
       this->Makefile->AddCacheDefinition(
-        this->VariableName, "",
-        this->VariableDocumentation.c_str(),
-        (this->IncludeFileInPath ?
-         cmState::FILEPATH :cmState::PATH)
-        );
-      }
-    return true;
+        this->VariableName, "", this->VariableDocumentation.c_str(),
+        (this->IncludeFileInPath ? cmState::FILEPATH : cmState::PATH));
     }
+    return true;
+  }
 
   std::string result = this->FindHeader();
-  if(!result.empty())
-    {
-    this->Makefile->AddCacheDefinition
-      (this->VariableName, result.c_str(),
-       this->VariableDocumentation.c_str(),
-       (this->IncludeFileInPath) ?
-       cmState::FILEPATH :cmState::PATH);
+  if (!result.empty()) {
+    this->Makefile->AddCacheDefinition(
+      this->VariableName, result.c_str(), this->VariableDocumentation.c_str(),
+      (this->IncludeFileInPath) ? cmState::FILEPATH : cmState::PATH);
     return true;
-    }
-  this->Makefile->AddCacheDefinition
-    (this->VariableName,
-     (this->VariableName + "-NOTFOUND").c_str(),
-     this->VariableDocumentation.c_str(),
-     (this->IncludeFileInPath) ?
-     cmState::FILEPATH :cmState::PATH);
+  }
+  this->Makefile->AddCacheDefinition(
+    this->VariableName, (this->VariableName + "-NOTFOUND").c_str(),
+    this->VariableDocumentation.c_str(),
+    (this->IncludeFileInPath) ? cmState::FILEPATH : cmState::PATH);
   return true;
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindPathCommand::FindHeader()
 {
   std::string header;
-  if(this->SearchFrameworkFirst || this->SearchFrameworkOnly)
-    {
+  if (this->SearchFrameworkFirst || this->SearchFrameworkOnly) {
     header = this->FindFrameworkHeader();
-    }
-  if(header.empty() && !this->SearchFrameworkOnly)
-    {
+  }
+  if (header.empty() && !this->SearchFrameworkOnly) {
     header = this->FindNormalHeader();
-    }
-  if(header.empty() && this->SearchFrameworkLast)
-    {
+  }
+  if (header.empty() && this->SearchFrameworkLast) {
     header = this->FindFrameworkHeader();
-    }
+  }
   return header;
 }
 
-std::string
-cmFindPathCommand::FindHeaderInFramework(std::string const& file,
-                                         std::string const& dir)
+std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
+                                                     std::string const& dir)
 {
   std::string fileName = file;
   std::string frameWorkName;
@@ -94,37 +78,32 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file,
   // 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
-  if(pos != fileName.npos)
-    {
+  if (pos != fileName.npos) {
     // remove the name from the slash;
-    fileName = fileName.substr(pos+1);
+    fileName = fileName.substr(pos + 1);
     frameWorkName = file;
     frameWorkName =
-      frameWorkName.substr(0, frameWorkName.size()-fileName.size()-1);
+      frameWorkName.substr(0, frameWorkName.size() - fileName.size() - 1);
     // if the framework has a path in it then just use the filename
-    if(frameWorkName.find("/") != frameWorkName.npos)
-      {
+    if (frameWorkName.find("/") != frameWorkName.npos) {
       fileName = file;
       frameWorkName = "";
-      }
-    if(!frameWorkName.empty())
-      {
+    }
+    if (!frameWorkName.empty()) {
       std::string fpath = dir;
       fpath += frameWorkName;
       fpath += ".framework";
       std::string intPath = fpath;
       intPath += "/Headers/";
       intPath += fileName;
-      if(cmSystemTools::FileExists(intPath.c_str()))
-        {
-        if(this->IncludeFileInPath)
-          {
+      if (cmSystemTools::FileExists(intPath.c_str())) {
+        if (this->IncludeFileInPath) {
           return intPath;
-          }
-        return fpath;
         }
+        return fpath;
       }
     }
+  }
   // 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>
   std::string glob = dir;
@@ -133,64 +112,51 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file,
   cmsys::Glob globIt;
   globIt.FindFiles(glob);
   std::vector<std::string> files = globIt.GetFiles();
-  if(!files.empty())
-    {
+  if (!files.empty()) {
     std::string fheader = cmSystemTools::CollapseFullPath(files[0]);
-    if(this->IncludeFileInPath)
-      {
+    if (this->IncludeFileInPath) {
       return fheader;
-      }
+    }
     fheader = cmSystemTools::GetFilenamePath(fheader);
     return fheader;
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindPathCommand::FindNormalHeader()
 {
   std::string tryPath;
-  for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end() ; ++ni)
-    {
-    for(std::vector<std::string>::const_iterator
-          p = this->SearchPaths.begin();
-        p != this->SearchPaths.end(); ++p)
-      {
+  for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
+    for (std::vector<std::string>::const_iterator p =
+           this->SearchPaths.begin();
+         p != this->SearchPaths.end(); ++p) {
       tryPath = *p;
       tryPath += *ni;
-      if(cmSystemTools::FileExists(tryPath.c_str()))
-        {
-        if(this->IncludeFileInPath)
-          {
+      if (cmSystemTools::FileExists(tryPath.c_str())) {
+        if (this->IncludeFileInPath) {
           return tryPath;
-          }
-        else
-          {
+        } else {
           return *p;
-          }
         }
       }
     }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindPathCommand::FindFrameworkHeader()
 {
-  for(std::vector<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end() ; ++ni)
-    {
-    for(std::vector<std::string>::const_iterator
-          p = this->SearchPaths.begin();
-        p != this->SearchPaths.end(); ++p)
-      {
+  for (std::vector<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
+    for (std::vector<std::string>::const_iterator p =
+           this->SearchPaths.begin();
+         p != this->SearchPaths.end(); ++p) {
       std::string fwPath = this->FindHeaderInFramework(*ni, *p);
-      if(!fwPath.empty())
-        {
+      if (!fwPath.empty()) {
         return fwPath;
-        }
       }
     }
+  }
   return "";
 }
diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h
index a51da79..e14626a 100644
--- a/Source/cmFindPathCommand.h
+++ b/Source/cmFindPathCommand.h
@@ -14,7 +14,6 @@
 
 #include "cmFindBase.h"
 
-
 /** \class cmFindPathCommand
  * \brief Define a command to search for a library.
  *
@@ -29,17 +28,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFindPathCommand;
-    }
+  virtual cmCommand* Clone() { return new cmFindPathCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -49,10 +45,11 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "find_path";}
+  virtual std::string GetName() const { return "find_path"; }
 
   cmTypeMacro(cmFindPathCommand, cmFindBase);
   bool IncludeFileInPath;
+
 private:
   std::string FindHeaderInFramework(std::string const& file,
                                     std::string const& dir);
@@ -61,6 +58,4 @@ private:
   std::string FindFrameworkHeader();
 };
 
-
-
 #endif
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 219ad48..8d142c9 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -10,25 +10,25 @@
   See the License for more information.
 ============================================================================*/
 #include "cmFindProgramCommand.h"
+
 #include <stdlib.h>
 
 #if defined(__APPLE__)
 #include <CoreFoundation/CoreFoundation.h>
 #endif
 
-//----------------------------------------------------------------------------
 struct cmFindProgramHelper
 {
   cmFindProgramHelper()
-    {
-#if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
+  {
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
     // Consider platform-specific extensions.
     this->Extensions.push_back(".com");
     this->Extensions.push_back(".exe");
 #endif
     // Consider original name with no extensions.
     this->Extensions.push_back("");
-    }
+  }
 
   // List of valid extensions.
   std::vector<std::string> Extensions;
@@ -42,47 +42,39 @@ struct cmFindProgramHelper
   // Current full path under consideration.
   std::string TestPath;
 
-  void AddName(std::string const& name)
-    {
-    this->Names.push_back(name);
-    }
+  void AddName(std::string const& name) { this->Names.push_back(name); }
   void SetName(std::string const& name)
-    {
+  {
     this->Names.clear();
     this->AddName(name);
-    }
+  }
   bool CheckDirectory(std::string const& path)
-    {
+  {
     for (std::vector<std::string>::iterator i = this->Names.begin();
-         i != this->Names.end(); ++i)
-      {
-      if (this->CheckDirectoryForName(path, *i))
-        {
+         i != this->Names.end(); ++i) {
+      if (this->CheckDirectoryForName(path, *i)) {
         return true;
-        }
       }
-    return false;
     }
+    return false;
+  }
   bool CheckDirectoryForName(std::string const& path, std::string const& name)
-    {
+  {
     for (std::vector<std::string>::iterator ext = this->Extensions.begin();
-         ext != this->Extensions.end(); ++ext)
-      {
+         ext != this->Extensions.end(); ++ext) {
       this->TestPath = path;
       this->TestPath += name;
-      if (!ext->empty() && cmSystemTools::StringEndsWith(name, ext->c_str()))
-        {
+      if (!ext->empty() && cmSystemTools::StringEndsWith(name, ext->c_str())) {
         continue;
-        }
+      }
       this->TestPath += *ext;
-      if (cmSystemTools::FileExists(this->TestPath, true))
-        {
+      if (cmSystemTools::FileExists(this->TestPath, true)) {
         this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
         return true;
-        }
       }
-    return false;
     }
+    return false;
+  }
 };
 
 cmFindProgramCommand::cmFindProgramCommand()
@@ -91,45 +83,39 @@ cmFindProgramCommand::cmFindProgramCommand()
 }
 
 // cmFindProgramCommand
-bool cmFindProgramCommand
-::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &)
+bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn,
+                                       cmExecutionStatus&)
 {
   this->VariableDocumentation = "Path to a program.";
   this->CMakePathName = "PROGRAM";
   // call cmFindBase::ParseArguments
-  if(!this->ParseArguments(argsIn))
-    {
+  if (!this->ParseArguments(argsIn)) {
     return false;
-    }
-  if(this->AlreadyInCache)
-    {
+  }
+  if (this->AlreadyInCache) {
     // If the user specifies the entry on the command line without a
     // type we should add the type and docstring but keep the original
     // value.
-    if(this->AlreadyInCacheWithoutMetaInfo)
-      {
+    if (this->AlreadyInCacheWithoutMetaInfo) {
       this->Makefile->AddCacheDefinition(this->VariableName, "",
                                          this->VariableDocumentation.c_str(),
                                          cmState::FILEPATH);
-      }
-    return true;
     }
+    return true;
+  }
 
   std::string result = FindProgram();
-  if(result != "")
-    {
+  if (result != "") {
     // Save the value in the cache
-    this->Makefile->AddCacheDefinition(this->VariableName,
-                                       result.c_str(),
+    this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(),
                                        this->VariableDocumentation.c_str(),
                                        cmState::FILEPATH);
 
     return true;
-    }
-  this->Makefile->AddCacheDefinition(this->VariableName,
-                                 (this->VariableName + "-NOTFOUND").c_str(),
-                                 this->VariableDocumentation.c_str(),
-                                 cmState::FILEPATH);
+  }
+  this->Makefile->AddCacheDefinition(
+    this->VariableName, (this->VariableName + "-NOTFOUND").c_str(),
+    this->VariableDocumentation.c_str(), cmState::FILEPATH);
   return true;
 }
 
@@ -137,117 +123,96 @@ std::string cmFindProgramCommand::FindProgram()
 {
   std::string program = "";
 
-  if(this->SearchAppBundleFirst || this->SearchAppBundleOnly)
-    {
+  if (this->SearchAppBundleFirst || this->SearchAppBundleOnly) {
     program = FindAppBundle();
-    }
-  if(program.empty() && !this->SearchAppBundleOnly)
-    {
+  }
+  if (program.empty() && !this->SearchAppBundleOnly) {
     program = this->FindNormalProgram();
-    }
+  }
 
-  if(program.empty() && this->SearchAppBundleLast)
-    {
+  if (program.empty() && this->SearchAppBundleLast) {
     program = this->FindAppBundle();
-    }
+  }
   return program;
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindProgramCommand::FindNormalProgram()
 {
-  if(this->NamesPerDir)
-    {
+  if (this->NamesPerDir) {
     return this->FindNormalProgramNamesPerDir();
-    }
-  else
-    {
+  } else {
     return this->FindNormalProgramDirsPerName();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
 {
   // Search for all names in each directory.
   cmFindProgramHelper helper;
   for (std::vector<std::string>::const_iterator ni = this->Names.begin();
-       ni != this->Names.end() ; ++ni)
-    {
+       ni != this->Names.end(); ++ni) {
     helper.AddName(*ni);
-    }
+  }
 
   // Check for the names themselves (e.g. absolute paths).
-  if (helper.CheckDirectory(std::string()))
-    {
+  if (helper.CheckDirectory(std::string())) {
     return helper.BestPath;
-    }
+  }
 
   // Search every directory.
-  for (std::vector<std::string>::const_iterator
-         p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p)
-    {
-    if(helper.CheckDirectory(*p))
-      {
+  for (std::vector<std::string>::const_iterator p = this->SearchPaths.begin();
+       p != this->SearchPaths.end(); ++p) {
+    if (helper.CheckDirectory(*p)) {
       return helper.BestPath;
-      }
     }
+  }
   // Couldn't find the program.
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
 {
   // Search the entire path for each name.
   cmFindProgramHelper helper;
   for (std::vector<std::string>::const_iterator ni = this->Names.begin();
-       ni != this->Names.end() ; ++ni)
-    {
+       ni != this->Names.end(); ++ni) {
     // Switch to searching for this name.
     helper.SetName(*ni);
 
     // Check for the name by itself (e.g. an absolute path).
-    if (helper.CheckDirectory(std::string()))
-      {
+    if (helper.CheckDirectory(std::string())) {
       return helper.BestPath;
-      }
+    }
 
     // Search every directory.
-    for (std::vector<std::string>::const_iterator
-           p = this->SearchPaths.begin();
-         p != this->SearchPaths.end(); ++p)
-      {
-      if (helper.CheckDirectory(*p))
-        {
+    for (std::vector<std::string>::const_iterator p =
+           this->SearchPaths.begin();
+         p != this->SearchPaths.end(); ++p) {
+      if (helper.CheckDirectory(*p)) {
         return helper.BestPath;
-        }
       }
     }
+  }
   // Couldn't find the program.
   return "";
 }
 
 std::string cmFindProgramCommand::FindAppBundle()
 {
-  for(std::vector<std::string>::const_iterator name = this->Names.begin();
-      name != this->Names.end() ; ++name)
-    {
+  for (std::vector<std::string>::const_iterator name = this->Names.begin();
+       name != this->Names.end(); ++name) {
 
     std::string appName = *name + std::string(".app");
-    std::string appPath = cmSystemTools::FindDirectory(appName,
-                                                       this->SearchPaths,
-                                                       true);
+    std::string appPath =
+      cmSystemTools::FindDirectory(appName, this->SearchPaths, true);
 
-    if ( !appPath.empty() )
-      {
+    if (!appPath.empty()) {
       std::string executable = GetBundleExecutable(appPath);
-      if (!executable.empty())
-        {
+      if (!executable.empty()) {
         return cmSystemTools::CollapseFullPath(executable);
-        }
       }
     }
+  }
 
   // Couldn't find app bundle
   return "";
@@ -263,45 +228,40 @@ std::string cmFindProgramCommand::GetBundleExecutable(std::string bundlePath)
 
   // Get a CFString of the app bundle path
   // XXX - Is it safe to assume everything is in UTF8?
-  CFStringRef bundlePathCFS =
-    CFStringCreateWithCString(kCFAllocatorDefault ,
-                              bundlePath.c_str(), kCFStringEncodingUTF8 );
+  CFStringRef bundlePathCFS = CFStringCreateWithCString(
+    kCFAllocatorDefault, bundlePath.c_str(), kCFStringEncodingUTF8);
 
   // Make a CFURLRef from the CFString representation of the
   // bundle’s path.
-  CFURLRef bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
-                                                     bundlePathCFS,
-                                                     kCFURLPOSIXPathStyle,
-                                                     true );
+  CFURLRef bundleURL = CFURLCreateWithFileSystemPath(
+    kCFAllocatorDefault, bundlePathCFS, kCFURLPOSIXPathStyle, true);
 
   // Make a bundle instance using the URLRef.
-  CFBundleRef appBundle = CFBundleCreate( kCFAllocatorDefault, bundleURL );
+  CFBundleRef appBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
 
   // returned executableURL is relative to <appbundle>/Contents/MacOS/
   CFURLRef executableURL = CFBundleCopyExecutableURL(appBundle);
 
-  if (executableURL != NULL)
-    {
+  if (executableURL != NULL) {
     const int MAX_OSX_PATH_SIZE = 1024;
     char buffer[MAX_OSX_PATH_SIZE];
 
     // Convert the CFString to a C string
-    CFStringGetCString( CFURLGetString(executableURL), buffer,
-                        MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8 );
+    CFStringGetCString(CFURLGetString(executableURL), buffer,
+                       MAX_OSX_PATH_SIZE, kCFStringEncodingUTF8);
 
     // And finally to a c++ string
     executable = bundlePath + "/Contents/MacOS/" + std::string(buffer);
     // Only release CFURLRef if it's not null
-    CFRelease( executableURL );
-    }
+    CFRelease(executableURL);
+  }
 
   // Any CF objects returned from functions with "create" or
   // "copy" in their names must be released by us!
-  CFRelease( bundlePathCFS );
-  CFRelease( bundleURL );
-  CFRelease( appBundle );
+  CFRelease(bundlePathCFS);
+  CFRelease(bundleURL);
+  CFRelease(appBundle);
 #endif
 
   return executable;
 }
-
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index f88186b..3f2ac0e 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -29,17 +29,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFindProgramCommand;
-    }
+  virtual cmCommand* Clone() { return new cmFindProgramCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -49,7 +46,7 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "find_program";}
+  virtual std::string GetName() const { return "find_program"; }
 
   cmTypeMacro(cmFindProgramCommand, cmFindBase);
 
@@ -60,9 +57,6 @@ private:
   std::string FindNormalProgramNamesPerDir();
   std::string FindAppBundle();
   std::string GetBundleExecutable(std::string bundlePath);
-
 };
 
-
-
 #endif
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index e983bfb..daf43e6 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -13,8 +13,9 @@
 
 #include <cmsys/auto_ptr.hxx>
 
-cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf):
-  Makefile(mf), Depth(0)
+cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf)
+  : Makefile(mf)
+  , Depth(0)
 {
   this->Makefile->PushLoopBlock();
 }
@@ -24,79 +25,68 @@ cmForEachFunctionBlocker::~cmForEachFunctionBlocker()
   this->Makefile->PopLoopBlock();
 }
 
-bool cmForEachFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
-                  cmExecutionStatus &inStatus)
+bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
+                                                 cmMakefile& mf,
+                                                 cmExecutionStatus& inStatus)
 {
-  if (!cmSystemTools::Strucmp(lff.Name.c_str(),"foreach"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "foreach")) {
     // record the number of nested foreach commands
     this->Depth++;
-    }
-  else if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endforeach"))
-    {
+  } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endforeach")) {
     // if this is the endofreach for this statement
-    if (!this->Depth)
-      {
+    if (!this->Depth) {
       // Remove the function blocker for this scope or bail.
-      cmsys::auto_ptr<cmFunctionBlocker>
-        fb(mf.RemoveFunctionBlocker(this, lff));
-      if(!fb.get()) { return false; }
+      cmsys::auto_ptr<cmFunctionBlocker> fb(
+        mf.RemoveFunctionBlocker(this, lff));
+      if (!fb.get()) {
+        return false;
+      }
 
       // at end of for each execute recorded commands
       // store the old value
       std::string oldDef;
-      if (mf.GetDefinition(this->Args[0]))
-        {
+      if (mf.GetDefinition(this->Args[0])) {
         oldDef = mf.GetDefinition(this->Args[0]);
-        }
+      }
       std::vector<std::string>::const_iterator j = this->Args.begin();
       ++j;
 
-      for( ; j != this->Args.end(); ++j)
-        {
+      for (; j != this->Args.end(); ++j) {
         // set the variable to the loop value
-        mf.AddDefinition(this->Args[0],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)
-          {
+        for (unsigned int c = 0; c < this->Functions.size(); ++c) {
           status.Clear();
-          mf.ExecuteCommand(this->Functions[c],status);
-          if (status.GetReturnInvoked())
-            {
+          mf.ExecuteCommand(this->Functions[c], status);
+          if (status.GetReturnInvoked()) {
             inStatus.SetReturnInvoked(true);
             // restore the variable to its prior value
-            mf.AddDefinition(this->Args[0],oldDef.c_str());
+            mf.AddDefinition(this->Args[0], oldDef.c_str());
             return true;
-            }
-          if (status.GetBreakInvoked())
-            {
+          }
+          if (status.GetBreakInvoked()) {
             // restore the variable to its prior value
-            mf.AddDefinition(this->Args[0],oldDef.c_str());
+            mf.AddDefinition(this->Args[0], oldDef.c_str());
             return true;
-            }
-          if (status.GetContinueInvoked())
-            {
+          }
+          if (status.GetContinueInvoked()) {
             break;
-            }
-          if(cmSystemTools::GetFatalErrorOccured() )
-            {
+          }
+          if (cmSystemTools::GetFatalErrorOccured()) {
             return true;
-            }
           }
         }
+      }
 
       // restore the variable to its prior value
-      mf.AddDefinition(this->Args[0],oldDef.c_str());
+      mf.AddDefinition(this->Args[0], oldDef.c_str());
       return true;
-      }
-    else
-      {
+    } else {
       // close out a nested foreach
       this->Depth--;
-      }
     }
+  }
 
   // record the command
   this->Functions.push_back(lff);
@@ -105,156 +95,126 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
   return true;
 }
 
-bool cmForEachFunctionBlocker::
-ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf)
+bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
+                                            cmMakefile& mf)
 {
-  if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endforeach"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endforeach")) {
     std::vector<std::string> expandedArguments;
     mf.ExpandArguments(lff.Arguments, expandedArguments);
     // if the endforeach has arguments then make sure
     // they match the begin foreach arguments
     if ((expandedArguments.empty() ||
-         (expandedArguments[0] == this->Args[0])))
-      {
+         (expandedArguments[0] == this->Args[0]))) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-bool cmForEachCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmForEachCommand::InitialPass(std::vector<std::string> const& args,
+                                   cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
-  if(args.size() > 1 && args[1] == "IN")
-    {
+  }
+  if (args.size() > 1 && args[1] == "IN") {
     return this->HandleInMode(args);
-    }
+  }
 
   // create a function blocker
-  cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker(this->Makefile);
-  if ( args.size() > 1 )
-    {
-    if ( args[1] == "RANGE" )
-      {
+  cmForEachFunctionBlocker* f = new cmForEachFunctionBlocker(this->Makefile);
+  if (args.size() > 1) {
+    if (args[1] == "RANGE") {
       int start = 0;
       int stop = 0;
       int step = 0;
-      if ( args.size() == 3 )
-        {
+      if (args.size() == 3) {
         stop = atoi(args[2].c_str());
-        }
-      if ( args.size() == 4 )
-        {
+      }
+      if (args.size() == 4) {
         start = atoi(args[2].c_str());
         stop = atoi(args[3].c_str());
-        }
-      if ( args.size() == 5 )
-        {
+      }
+      if (args.size() == 5) {
         start = atoi(args[2].c_str());
         stop = atoi(args[3].c_str());
         step = atoi(args[4].c_str());
-        }
-      if ( step == 0 )
-        {
-        if ( start > stop )
-          {
+      }
+      if (step == 0) {
+        if (start > stop) {
           step = -1;
-          }
-        else
-          {
+        } else {
           step = 1;
-          }
         }
-      if (
-        (start > stop && step > 0) ||
-        (start < stop && step < 0) ||
-        step == 0
-        )
-        {
+      }
+      if ((start > stop && step > 0) || (start < stop && step < 0) ||
+          step == 0) {
         std::ostringstream str;
         str << "called with incorrect range specification: start ";
         str << start << ", stop " << stop << ", step " << step;
         this->SetError(str.str());
         return false;
-        }
+      }
       std::vector<std::string> range;
       char buffer[100];
       range.push_back(args[0]);
       int cc;
-      for ( cc = start; ; cc += step )
-        {
-        if ( (step > 0 && cc > stop) || (step < 0 && cc < stop) )
-          {
+      for (cc = start;; cc += step) {
+        if ((step > 0 && cc > stop) || (step < 0 && cc < stop)) {
           break;
-          }
+        }
         sprintf(buffer, "%d", cc);
         range.push_back(buffer);
-        if ( cc == stop )
-          {
+        if (cc == stop) {
           break;
-          }
         }
-      f->Args = range;
       }
-    else
-      {
+      f->Args = range;
+    } else {
       f->Args = args;
-      }
     }
-  else
-    {
+  } else {
     f->Args = args;
-    }
+  }
   this->Makefile->AddFunctionBlocker(f);
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
 {
-  cmsys::auto_ptr<cmForEachFunctionBlocker>
-    f(new cmForEachFunctionBlocker(this->Makefile));
+  cmsys::auto_ptr<cmForEachFunctionBlocker> f(
+    new cmForEachFunctionBlocker(this->Makefile));
   f->Args.push_back(args[0]);
 
-  enum Doing { DoingNone, DoingLists, DoingItems };
+  enum Doing
+  {
+    DoingNone,
+    DoingLists,
+    DoingItems
+  };
   Doing doing = DoingNone;
-  for(unsigned int i=2; i < args.size(); ++i)
-    {
-    if(doing == DoingItems)
-      {
+  for (unsigned int i = 2; i < args.size(); ++i) {
+    if (doing == DoingItems) {
       f->Args.push_back(args[i]);
-      }
-    else if(args[i] == "LISTS")
-      {
+    } else if (args[i] == "LISTS") {
       doing = DoingLists;
-      }
-    else if(args[i] == "ITEMS")
-      {
+    } else if (args[i] == "ITEMS") {
       doing = DoingItems;
-      }
-    else if(doing == DoingLists)
-      {
+    } else if (doing == DoingLists) {
       const char* value = this->Makefile->GetDefinition(args[i]);
-      if(value && *value)
-        {
+      if (value && *value) {
         cmSystemTools::ExpandListArgument(value, f->Args, true);
-        }
       }
-    else
-      {
+    } else {
       std::ostringstream e;
-      e << "Unknown argument:\n" << "  " << args[i] << "\n";
+      e << "Unknown argument:\n"
+        << "  " << args[i] << "\n";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return true;
-      }
     }
+  }
 
   this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
 
diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h
index 36e8808..60956aa 100644
--- a/Source/cmForEachCommand.h
+++ b/Source/cmForEachCommand.h
@@ -13,6 +13,7 @@
 #define cmForEachCommand_h
 
 #include "cmCommand.h"
+
 #include "cmFunctionBlocker.h"
 #include "cmListFileCache.h"
 
@@ -21,13 +22,13 @@ class cmForEachFunctionBlocker : public cmFunctionBlocker
 public:
   cmForEachFunctionBlocker(cmMakefile* mf);
   ~cmForEachFunctionBlocker();
-  virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
-                                 cmMakefile &mf,
-                                 cmExecutionStatus &);
-  virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
+  virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
+                                 cmExecutionStatus&);
+  virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf);
 
   std::vector<std::string> Args;
   std::vector<cmListFileFunction> Functions;
+
 private:
   cmMakefile* Makefile;
   int Depth;
@@ -40,17 +41,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmForEachCommand;
-    }
+  virtual cmCommand* Clone() { return new cmForEachCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -60,12 +58,12 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "foreach";}
+  virtual std::string GetName() const { return "foreach"; }
 
   cmTypeMacro(cmForEachCommand, cmCommand);
+
 private:
   bool HandleInMode(std::vector<std::string> const& args);
 };
 
-
 #endif
diff --git a/Source/cmFortranLexer.cxx b/Source/cmFortranLexer.cxx
index 6779c1a..7cde4cb 100644
--- a/Source/cmFortranLexer.cxx
+++ b/Source/cmFortranLexer.cxx
@@ -1241,7 +1241,7 @@ case 43:
 /* rule 43 can match eol */
 YY_RULE_SETUP
 #line 172 "cmFortranLexer.in.l"
-/* Ignore line-endings preceeded by \ */
+/* Ignore line-endings preceded by \ */
         YY_BREAK
 case 44:
 YY_RULE_SETUP
diff --git a/Source/cmFortranLexer.in.l b/Source/cmFortranLexer.in.l
index 53984bb..e59ff5f 100644
--- a/Source/cmFortranLexer.in.l
+++ b/Source/cmFortranLexer.in.l
@@ -169,7 +169,7 @@ $[ \t]*endif    { return F90PPR_ENDIF; }
 
 
 [ \t\r,]         /* Ignore */
-\\[ \t]*\n       /* Ignore line-endings preceeded by \ */
+\\[ \t]*\n       /* Ignore line-endings preceded by \ */
 
 . { return *yytext; }
 
diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h
index cdaf46b..07e1b1c 100644
--- a/Source/cmFortranParser.h
+++ b/Source/cmFortranParser.h
@@ -13,7 +13,7 @@
 #define cmFortranParser_h
 
 #if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx)
-# include "cmStandardIncludes.h"
+#include "cmStandardIncludes.h"
 #endif
 
 #include <stddef.h> /* size_t */
@@ -22,53 +22,37 @@
 typedef struct cmFortranParser_s cmFortranParser;
 
 /* Functions to enter/exit #include'd files in order.  */
-bool cmFortranParser_FilePush(cmFortranParser* parser,
-                                    const char* fname);
+bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname);
 bool cmFortranParser_FilePop(cmFortranParser* parser);
 
 /* Callbacks for lexer.  */
-int cmFortranParser_Input(cmFortranParser* parser,
-                                 char* buffer, size_t bufferSize);
-
+int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
+                          size_t bufferSize);
 
 void cmFortranParser_StringStart(cmFortranParser* parser);
 const char* cmFortranParser_StringEnd(cmFortranParser* parser);
-void cmFortranParser_StringAppend(cmFortranParser* parser,
-                                         char c);
+void cmFortranParser_StringAppend(cmFortranParser* parser, char c);
 
-void cmFortranParser_SetInInterface(cmFortranParser* parser,
-                                           bool is_in);
+void cmFortranParser_SetInInterface(cmFortranParser* parser, bool is_in);
 bool cmFortranParser_GetInInterface(cmFortranParser* parser);
 
-
-void cmFortranParser_SetInPPFalseBranch(cmFortranParser* parser,
-                                               bool is_in);
+void cmFortranParser_SetInPPFalseBranch(cmFortranParser* parser, bool is_in);
 bool cmFortranParser_GetInPPFalseBranch(cmFortranParser* parser);
 
-
-void cmFortranParser_SetOldStartcond(cmFortranParser* parser,
-                                            int arg);
+void cmFortranParser_SetOldStartcond(cmFortranParser* parser, int arg);
 int cmFortranParser_GetOldStartcond(cmFortranParser* parser);
 
 /* Callbacks for parser.  */
-void cmFortranParser_Error(cmFortranParser* parser,
-                                  const char* message);
-void cmFortranParser_RuleUse(cmFortranParser* parser,
-                                    const char* name);
+void cmFortranParser_Error(cmFortranParser* parser, const char* message);
+void cmFortranParser_RuleUse(cmFortranParser* parser, const char* name);
 void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
                                        const char* filename);
-void cmFortranParser_RuleInclude(cmFortranParser* parser,
-                                        const char* name);
-void cmFortranParser_RuleModule(cmFortranParser* parser,
-                                       const char* name);
-void cmFortranParser_RuleDefine(cmFortranParser* parser,
-                                       const char* name);
-void cmFortranParser_RuleUndef(cmFortranParser* parser,
-                                      const char* name);
-void cmFortranParser_RuleIfdef(cmFortranParser* parser,
-                                      const char* name);
-void cmFortranParser_RuleIfndef(cmFortranParser* parser,
-                                       const char* name);
+void cmFortranParser_RuleInclude(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleModule(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleUndef(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleIfdef(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleIfndef(cmFortranParser* parser, const char* name);
 void cmFortranParser_RuleIf(cmFortranParser* parser);
 void cmFortranParser_RuleElif(cmFortranParser* parser);
 void cmFortranParser_RuleElse(cmFortranParser* parser);
@@ -83,26 +67,24 @@ union cmFortran_yystype_u
 
 /* Setup the proper yylex interface.  */
 #define YY_EXTRA_TYPE cmFortranParser*
-#define YY_DECL \
-int cmFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
+#define YY_DECL int cmFortran_yylex(YYSTYPE* yylvalp, yyscan_t yyscanner)
 #define YYSTYPE cmFortran_yystype
 #define YYSTYPE_IS_DECLARED 1
 #if !defined(cmFortranLexer_cxx)
-# include "cmFortranLexer.h"
+#include "cmFortranLexer.h"
 #endif
 #if !defined(cmFortranLexer_cxx)
 #if !defined(cmFortranParser_cxx)
-# undef YY_EXTRA_TYPE
-# undef YY_DECL
-# undef YYSTYPE
-# undef YYSTYPE_IS_DECLARED
+#undef YY_EXTRA_TYPE
+#undef YY_DECL
+#undef YYSTYPE
+#undef YYSTYPE_IS_DECLARED
 #endif
 #endif
 
 #if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx)
 #include <stack>
 
-//----------------------------------------------------------------------------
 // Information about a single source file.
 class cmFortranSourceInfo
 {
@@ -118,7 +100,6 @@ public:
   std::set<std::string> Includes;
 };
 
-//----------------------------------------------------------------------------
 // Parser methods not included in generated interface.
 
 // Get the current buffer processed by the lexer.
@@ -127,13 +108,15 @@ YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner);
 // The parser entry point.
 int cmFortran_yyparse(yyscan_t);
 
-//----------------------------------------------------------------------------
 // Define parser object internal structure.
 struct cmFortranFile
 {
-  cmFortranFile(FILE* file, YY_BUFFER_STATE buffer,
-                       const std::string& dir):
-    File(file), Buffer(buffer), Directory(dir) {}
+  cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, const std::string& dir)
+    : File(file)
+    , Buffer(buffer)
+    , Directory(dir)
+  {
+  }
   FILE* File;
   YY_BUFFER_STATE Buffer;
   std::string Directory;
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index b3b2f16..934e928 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -14,53 +14,47 @@
 #include "cmSystemTools.h"
 #include <assert.h>
 
-//----------------------------------------------------------------------------
 bool cmFortranParser_s::FindIncludeFile(const char* dir,
                                         const char* includeName,
                                         std::string& fileName)
 {
   // If the file is a full path, include it directly.
-  if(cmSystemTools::FileIsFullPath(includeName))
-    {
+  if (cmSystemTools::FileIsFullPath(includeName)) {
     fileName = includeName;
     return cmSystemTools::FileExists(fileName.c_str(), true);
-    }
-  else
-    {
+  } else {
     // Check for the file in the directory containing the including
     // file.
     std::string fullName = dir;
     fullName += "/";
     fullName += includeName;
-    if(cmSystemTools::FileExists(fullName.c_str(), true))
-      {
+    if (cmSystemTools::FileExists(fullName.c_str(), true)) {
       fileName = fullName;
       return true;
-      }
+    }
 
     // Search the include path for the file.
-    for(std::vector<std::string>::const_iterator i =
-          this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i =
+           this->IncludePath.begin();
+         i != this->IncludePath.end(); ++i) {
       fullName = *i;
       fullName += "/";
       fullName += includeName;
-      if(cmSystemTools::FileExists(fullName.c_str(), true))
-        {
+      if (cmSystemTools::FileExists(fullName.c_str(), true)) {
         fileName = fullName;
         return true;
-        }
       }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
-cmFortranParser_s
-::cmFortranParser_s(std::vector<std::string> const& includes,
-                    std::set<std::string> const& defines,
-                    cmFortranSourceInfo& info):
-  IncludePath(includes), PPDefinitions(defines), Info(info)
+cmFortranParser_s::cmFortranParser_s(std::vector<std::string> const& includes,
+                                     std::set<std::string> const& defines,
+                                     cmFortranSourceInfo& info)
+  : IncludePath(includes)
+  , PPDefinitions(defines)
+  , Info(info)
 {
   this->InInterface = 0;
   this->InPPFalseBranch = 0;
@@ -71,27 +65,21 @@ cmFortranParser_s
 
   // Create a dummy buffer that is never read but is the fallback
   // buffer when the last file is popped off the stack.
-  YY_BUFFER_STATE buffer =
-    cmFortran_yy_create_buffer(0, 4, this->Scanner);
+  YY_BUFFER_STATE buffer = cmFortran_yy_create_buffer(0, 4, this->Scanner);
   cmFortran_yy_switch_to_buffer(buffer, this->Scanner);
 }
 
-//----------------------------------------------------------------------------
 cmFortranParser_s::~cmFortranParser_s()
 {
   cmFortran_yylex_destroy(this->Scanner);
 }
 
-//----------------------------------------------------------------------------
-bool cmFortranParser_FilePush(cmFortranParser* parser,
-                                    const char* fname)
+bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)
 {
   // Open the new file and push it onto the stack.  Save the old
   // buffer with it on the stack.
-  if(FILE* file = cmsys::SystemTools::Fopen(fname, "rb"))
-    {
-    YY_BUFFER_STATE current =
-      cmFortranLexer_GetCurrentBuffer(parser->Scanner);
+  if (FILE* file = cmsys::SystemTools::Fopen(fname, "rb")) {
+    YY_BUFFER_STATE current = cmFortranLexer_GetCurrentBuffer(parser->Scanner);
     std::string dir = cmSystemTools::GetParentDirectory(fname);
     cmFortranFile f(file, current, dir);
     YY_BUFFER_STATE buffer =
@@ -99,99 +87,79 @@ bool cmFortranParser_FilePush(cmFortranParser* parser,
     cmFortran_yy_switch_to_buffer(buffer, parser->Scanner);
     parser->FileStack.push(f);
     return 1;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmFortranParser_FilePop(cmFortranParser* parser)
 {
   // Pop one file off the stack and close it.  Switch the lexer back
   // to the next one on the stack.
-  if(parser->FileStack.empty())
-    {
+  if (parser->FileStack.empty()) {
     return 0;
-    }
-  else
-    {
-    cmFortranFile f = parser->FileStack.top(); parser->FileStack.pop();
+  } else {
+    cmFortranFile f = parser->FileStack.top();
+    parser->FileStack.pop();
     fclose(f.File);
-    YY_BUFFER_STATE current =
-      cmFortranLexer_GetCurrentBuffer(parser->Scanner);
+    YY_BUFFER_STATE current = cmFortranLexer_GetCurrentBuffer(parser->Scanner);
     cmFortran_yy_delete_buffer(current, parser->Scanner);
     cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner);
     return 1;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-int cmFortranParser_Input(cmFortranParser* parser,
-                                 char* buffer, size_t bufferSize)
+int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
+                          size_t bufferSize)
 {
   // Read from the file on top of the stack.  If the stack is empty,
   // the end of the translation unit has been reached.
-  if(!parser->FileStack.empty())
-    {
+  if (!parser->FileStack.empty()) {
     FILE* file = parser->FileStack.top().File;
     return (int)fread(buffer, 1, bufferSize, file);
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_StringStart(cmFortranParser* parser)
 {
   parser->TokenString = "";
 }
 
-//----------------------------------------------------------------------------
 const char* cmFortranParser_StringEnd(cmFortranParser* parser)
 {
   return parser->TokenString.c_str();
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_StringAppend(cmFortranParser* parser,
-                                         char c)
+void cmFortranParser_StringAppend(cmFortranParser* parser, char c)
 {
   parser->TokenString += c;
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_SetInInterface(cmFortranParser* parser,
-                                           bool in)
+void cmFortranParser_SetInInterface(cmFortranParser* parser, bool in)
 {
-  if(parser->InPPFalseBranch)
-    {
+  if (parser->InPPFalseBranch) {
     return;
-    }
+  }
 
   parser->InInterface = in;
 }
 
-//----------------------------------------------------------------------------
 bool cmFortranParser_GetInInterface(cmFortranParser* parser)
 {
   return parser->InInterface;
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_SetOldStartcond(cmFortranParser* parser,
-                                            int arg)
+void cmFortranParser_SetOldStartcond(cmFortranParser* parser, int arg)
 {
   parser->OldStartcond = arg;
 }
 
-//----------------------------------------------------------------------------
 int cmFortranParser_GetOldStartcond(cmFortranParser* parser)
 {
   return parser->OldStartcond;
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_Error(cmFortranParser*, const char*)
 {
   // If there is a parser error just ignore it.  The source will not
@@ -199,17 +167,13 @@ void cmFortranParser_Error(cmFortranParser*, const char*)
   // to be regenerated anyway.
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleUse(cmFortranParser* parser,
-                                    const char* name)
+void cmFortranParser_RuleUse(cmFortranParser* parser, const char* name)
 {
-  if(!parser->InPPFalseBranch)
-    {
-    parser->Info.Requires.insert(cmSystemTools::LowerCase(name) );
-    }
+  if (!parser->InPPFalseBranch) {
+    parser->Info.Requires.insert(cmSystemTools::LowerCase(name));
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
                                        const char* filename)
 {
@@ -218,10 +182,9 @@ void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
 
   // Skip #line directives referencing non-files like
   // "<built-in>" or "<command-line>".
-  if (included.empty() || included[0] == '<')
-    {
+  if (included.empty() || included[0] == '<') {
     return;
-    }
+  }
 
   // Fix windows file path separators since our lexer does not
   // process escape sequences in string literals.
@@ -229,20 +192,16 @@ void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
   cmSystemTools::ConvertToUnixSlashes(included);
 
   // Save the named file as included in the source.
-  if (cmSystemTools::FileExists(included, true))
-    {
+  if (cmSystemTools::FileExists(included, true)) {
     parser->Info.Includes.insert(included);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleInclude(cmFortranParser* parser,
-                                        const char* name)
+void cmFortranParser_RuleInclude(cmFortranParser* parser, const char* name)
 {
-  if(parser->InPPFalseBranch)
-    {
+  if (parser->InPPFalseBranch) {
     return;
-    }
+  }
 
   // If processing an include statement there must be an open file.
   assert(!parser->FileStack.empty());
@@ -256,95 +215,71 @@ void cmFortranParser_RuleInclude(cmFortranParser* parser,
   // problem because either the source will not compile or the user
   // does not care about depending on this included source.
   std::string fullName;
-  if(parser->FindIncludeFile(dir.c_str(), name, fullName))
-    {
+  if (parser->FindIncludeFile(dir.c_str(), name, fullName)) {
     // Found the included file.  Save it in the set of included files.
     parser->Info.Includes.insert(fullName);
 
     // Parse it immediately to translate the source inline.
     cmFortranParser_FilePush(parser, fullName.c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleModule(cmFortranParser* parser,
-                                       const char* name)
+void cmFortranParser_RuleModule(cmFortranParser* parser, const char* name)
 {
-  if(!parser->InPPFalseBranch && !parser->InInterface)
-    {
+  if (!parser->InPPFalseBranch && !parser->InInterface) {
     parser->Info.Provides.insert(cmSystemTools::LowerCase(name));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleDefine(cmFortranParser* parser,
-                                       const char* macro)
+void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* macro)
 {
-  if(!parser->InPPFalseBranch)
-    {
+  if (!parser->InPPFalseBranch) {
     parser->PPDefinitions.insert(macro);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleUndef(cmFortranParser* parser,
-                                      const char* macro)
+void cmFortranParser_RuleUndef(cmFortranParser* parser, const char* macro)
 {
-  if(!parser->InPPFalseBranch)
-    {
+  if (!parser->InPPFalseBranch) {
     std::set<std::string>::iterator match;
     match = parser->PPDefinitions.find(macro);
-    if(match != parser->PPDefinitions.end())
-      {
+    if (match != parser->PPDefinitions.end()) {
       parser->PPDefinitions.erase(match);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleIfdef(cmFortranParser* parser,
-                                      const char* macro)
+void cmFortranParser_RuleIfdef(cmFortranParser* parser, const char* macro)
 {
   // A new PP branch has been opened
   parser->SkipToEnd.push(false);
 
-  if (parser->InPPFalseBranch)
-    {
+  if (parser->InPPFalseBranch) {
     parser->InPPFalseBranch++;
-    }
-  else if(parser->PPDefinitions.find(macro) == parser->PPDefinitions.end())
-    {
-    parser->InPPFalseBranch=1;
-    }
-  else
-    {
+  } else if (parser->PPDefinitions.find(macro) ==
+             parser->PPDefinitions.end()) {
+    parser->InPPFalseBranch = 1;
+  } else {
     parser->SkipToEnd.top() = true;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmFortranParser_RuleIfndef(cmFortranParser* parser,
-  const char* macro)
+void cmFortranParser_RuleIfndef(cmFortranParser* parser, const char* macro)
 {
   // A new PP branch has been opened
   parser->SkipToEnd.push(false);
 
-  if (parser->InPPFalseBranch)
-    {
+  if (parser->InPPFalseBranch) {
     parser->InPPFalseBranch++;
-    }
-  else if(parser->PPDefinitions.find(macro) != parser->PPDefinitions.end())
-    {
+  } else if (parser->PPDefinitions.find(macro) !=
+             parser->PPDefinitions.end()) {
     parser->InPPFalseBranch = 1;
-    }
-  else
-    {
+  } else {
     // ignore other branches
     parser->SkipToEnd.top() = true;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_RuleIf(cmFortranParser* parser)
 {
   /* Note: The current parser is _not_ able to get statements like
@@ -378,7 +313,6 @@ void cmFortranParser_RuleIf(cmFortranParser* parser)
   parser->SkipToEnd.push(false);
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_RuleElif(cmFortranParser* parser)
 {
   /* Note: There are parser limitations.  See the note at
@@ -388,47 +322,37 @@ void cmFortranParser_RuleElif(cmFortranParser* parser)
   // Always taken unless an #ifdef or #ifndef-branch has been taken
   // already.  If the second condition isn't meet already
   // (parser->InPPFalseBranch == 0) correct it.
-  if(!parser->SkipToEnd.empty() &&
-     parser->SkipToEnd.top() && !parser->InPPFalseBranch)
-    {
+  if (!parser->SkipToEnd.empty() && parser->SkipToEnd.top() &&
+      !parser->InPPFalseBranch) {
     parser->InPPFalseBranch = 1;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_RuleElse(cmFortranParser* parser)
 {
   // if the parent branch is false do nothing!
-  if(parser->InPPFalseBranch > 1)
-    {
+  if (parser->InPPFalseBranch > 1) {
     return;
-    }
+  }
 
   // parser->InPPFalseBranch is either 0 or 1.  We change it depending on
   // parser->SkipToEnd.top()
-  if(!parser->SkipToEnd.empty() &&
-     parser->SkipToEnd.top())
-    {
+  if (!parser->SkipToEnd.empty() && parser->SkipToEnd.top()) {
     parser->InPPFalseBranch = 1;
-    }
-  else
-    {
+  } else {
     parser->InPPFalseBranch = 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmFortranParser_RuleEndif(cmFortranParser* parser)
 {
-  if(!parser->SkipToEnd.empty())
-    {
+  if (!parser->SkipToEnd.empty()) {
     parser->SkipToEnd.pop();
-    }
+  }
 
   // #endif doesn't know if there was a "#else" in before, so it
   // always decreases InPPFalseBranch
-  if(parser->InPPFalseBranch)
-    {
+  if (parser->InPPFalseBranch) {
     parser->InPPFalseBranch--;
-    }
+  }
 }
diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h
index a3b8078..c7e3b71 100644
--- a/Source/cmFunctionBlocker.h
+++ b/Source/cmFunctionBlocker.h
@@ -13,6 +13,7 @@
 #define cmFunctionBlocker_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmExecutionStatus.h"
 #include "cmListFileCache.h"
 class cmMakefile;
@@ -23,24 +24,30 @@ public:
   /**
    * should a function be blocked
    */
-  virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
-                                 cmMakefile&mf,
-                                 cmExecutionStatus &status) = 0;
+  virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
+                                 cmExecutionStatus& status) = 0;
 
   /**
    * should this function blocker be removed, useful when one function adds a
    * blocker and another must remove it
    */
-  virtual bool ShouldRemove(const cmListFileFunction&,
-                            cmMakefile&) {return false;}
+  virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile&)
+  {
+    return false;
+  }
 
   virtual ~cmFunctionBlocker() {}
 
   /** Set/Get the context in which this blocker is created.  */
   void SetStartingContext(cmListFileContext const& lfc)
-    { this->StartingContext = lfc; }
+  {
+    this->StartingContext = lfc;
+  }
   cmListFileContext const& GetStartingContext() const
-    { return this->StartingContext; }
+  {
+    return this->StartingContext;
+  }
+
 private:
   cmListFileContext StartingContext;
 };
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index c883ad7..de9887e 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -28,17 +28,14 @@ public:
    * cmMacroHelperCommand and cmFunctionHelperCommand
    * which cannot provide appropriate documentation.
    */
-  virtual bool ShouldAppearInDocumentation() const
-    {
-    return false;
-    }
+  virtual bool ShouldAppearInDocumentation() const { return false; }
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
   {
-    cmFunctionHelperCommand *newC = new cmFunctionHelperCommand;
+    cmFunctionHelperCommand* newC = new cmFunctionHelperCommand;
     // we must copy when we clone
     newC->Args = this->Args;
     newC->Functions = this->Functions;
@@ -57,10 +54,12 @@ public:
    * the CMakeLists.txt file.
    */
   virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false; }
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
@@ -75,9 +74,8 @@ public:
   std::string FilePath;
 };
 
-bool cmFunctionHelperCommand::InvokeInitialPass
-(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus & inStatus)
+bool cmFunctionHelperCommand::InvokeInitialPass(
+  const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
 {
   // Expand the argument list to the function.
   std::vector<std::string> expandedArgs;
@@ -85,46 +83,40 @@ bool cmFunctionHelperCommand::InvokeInitialPass
 
   // make sure the number of arguments passed is at least the number
   // required by the signature
-  if (expandedArgs.size() < this->Args.size() - 1)
-    {
+  if (expandedArgs.size() < this->Args.size() - 1) {
     std::string errorMsg =
       "Function invoked with incorrect arguments for function named: ";
     errorMsg += this->Args[0];
     this->SetError(errorMsg);
     return false;
-    }
+  }
 
-  cmMakefile::FunctionPushPop functionScope(this->Makefile,
-                                            this->FilePath,
+  cmMakefile::FunctionPushPop functionScope(this->Makefile, this->FilePath,
                                             this->Policies);
 
   // set the value of argc
   std::ostringstream strStream;
   strStream << expandedArgs.size();
-  this->Makefile->AddDefinition("ARGC",strStream.str().c_str());
+  this->Makefile->AddDefinition("ARGC", strStream.str().c_str());
   this->Makefile->MarkVariableAsUsed("ARGC");
 
   // set the values for ARGV0 ARGV1 ...
-  for (unsigned int t = 0; t < expandedArgs.size(); ++t)
-    {
+  for (unsigned int t = 0; t < expandedArgs.size(); ++t) {
     std::ostringstream tmpStream;
     tmpStream << "ARGV" << t;
-    this->Makefile->AddDefinition(tmpStream.str(),
-                                  expandedArgs[t].c_str());
+    this->Makefile->AddDefinition(tmpStream.str(), expandedArgs[t].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],
-                                  expandedArgs[j-1].c_str());
-    }
+  for (unsigned int j = 1; j < this->Args.size(); ++j) {
+    this->Makefile->AddDefinition(this->Args[j], expandedArgs[j - 1].c_str());
+  }
 
   // define ARGV and ARGN
   std::string argvDef = cmJoin(expandedArgs, ";");
-  std::vector<std::string>::const_iterator eit
-      = expandedArgs.begin() + (this->Args.size()-1);
+  std::vector<std::string>::const_iterator eit =
+    expandedArgs.begin() + (this->Args.size() - 1);
   std::string argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";");
   this->Makefile->AddDefinition("ARGV", argvDef.c_str());
   this->Makefile->MarkVariableAsUsed("ARGV");
@@ -133,45 +125,37 @@ bool cmFunctionHelperCommand::InvokeInitialPass
 
   // Invoke all the functions that were collected in the block.
   // for each function
-  for(unsigned int c = 0; c < this->Functions.size(); ++c)
-    {
+  for (unsigned int c = 0; c < this->Functions.size(); ++c) {
     cmExecutionStatus status;
-    if (!this->Makefile->ExecuteCommand(this->Functions[c],status) ||
-        status.GetNestedError())
-      {
+    if (!this->Makefile->ExecuteCommand(this->Functions[c], status) ||
+        status.GetNestedError()) {
       // The error message should have already included the call stack
       // so we do not need to report an error here.
       functionScope.Quiet();
       inStatus.SetNestedError(true);
       return false;
-      }
-    if (status.GetReturnInvoked())
-      {
+    }
+    if (status.GetReturnInvoked()) {
       return true;
-      }
     }
+  }
 
   // pop scope on the makefile
   return true;
 }
 
-bool cmFunctionFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
-                  cmExecutionStatus &)
+bool cmFunctionFunctionBlocker::IsFunctionBlocked(
+  const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&)
 {
   // record commands until we hit the ENDFUNCTION
   // at the ENDFUNCTION call we shift gears and start looking for invocations
-  if(!cmSystemTools::Strucmp(lff.Name.c_str(),"function"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "function")) {
     this->Depth++;
-    }
-  else if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endfunction"))
-    {
+  } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
     // if this is the endfunction for this function then execute
-    if (!this->Depth)
-      {
+    if (!this->Depth) {
       // create a new command and add it to cmake
-      cmFunctionHelperCommand *f = new cmFunctionHelperCommand();
+      cmFunctionHelperCommand* f = new cmFunctionHelperCommand();
       f->Args = this->Args;
       f->Functions = this->Functions;
       f->FilePath = this->GetStartingContext().FilePath;
@@ -184,13 +168,11 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
       // remove the function blocker now that the function is defined
       mf.RemoveFunctionBlocker(this, lff);
       return true;
-      }
-    else
-      {
+    } else {
       // decrement for each nested function that ends
       this->Depth--;
-      }
     }
+  }
 
   // if it wasn't an endfunction and we are not executing then we must be
   // recording
@@ -198,40 +180,35 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
   return true;
 }
 
-
-bool cmFunctionFunctionBlocker::
-ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
+bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
+                                             cmMakefile& mf)
 {
-  if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endfunction"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
     std::vector<std::string> expandedArguments;
     mf.ExpandArguments(lff.Arguments, expandedArguments,
                        this->GetStartingContext().FilePath.c_str());
     // if the endfunction has arguments then make sure
     // they match the ones in the opening function command
     if ((expandedArguments.empty() ||
-         (expandedArguments[0] == this->Args[0])))
-      {
+         (expandedArguments[0] == this->Args[0]))) {
       return true;
-      }
     }
+  }
 
   return false;
 }
 
-bool cmFunctionCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmFunctionCommand::InitialPass(std::vector<std::string> const& args,
+                                    cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // create a function blocker
-  cmFunctionFunctionBlocker *f = new cmFunctionFunctionBlocker();
+  cmFunctionFunctionBlocker* f = new cmFunctionFunctionBlocker();
   f->Args.insert(f->Args.end(), args.begin(), args.end());
   this->Makefile->AddFunctionBlocker(f);
   return true;
 }
-
diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h
index 2df435e..08f7f0f 100644
--- a/Source/cmFunctionCommand.h
+++ b/Source/cmFunctionCommand.h
@@ -13,17 +13,17 @@
 #define cmFunctionCommand_h
 
 #include "cmCommand.h"
+
 #include "cmFunctionBlocker.h"
 
 class cmFunctionFunctionBlocker : public cmFunctionBlocker
 {
 public:
-  cmFunctionFunctionBlocker() {this->Depth=0;}
+  cmFunctionFunctionBlocker() { this->Depth = 0; }
   virtual ~cmFunctionFunctionBlocker() {}
-  virtual bool IsFunctionBlocked(const cmListFileFunction&,
-                                 cmMakefile &mf,
-                                 cmExecutionStatus &);
-  virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
+  virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf,
+                                 cmExecutionStatus&);
+  virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf);
 
   std::vector<std::string> Args;
   std::vector<cmListFileFunction> Functions;
@@ -37,17 +37,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmFunctionCommand;
-    }
+  virtual cmCommand* Clone() { return new cmFunctionCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -57,10 +54,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "function";}
+  virtual std::string GetName() const { return "function"; }
 
   cmTypeMacro(cmFunctionCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 600b793..2c05913 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -14,30 +14,27 @@
 #include "cmSystemTools.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <cm_zlib.h>
+#include <cm_zlib.h>
 #endif
 
-//----------------------------------------------------------------------------
-cmGeneratedFileStream::cmGeneratedFileStream():
-  cmGeneratedFileStreamBase(), Stream()
+cmGeneratedFileStream::cmGeneratedFileStream()
+  : cmGeneratedFileStreamBase()
+  , Stream()
 {
 }
 
-//----------------------------------------------------------------------------
-cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet):
-  cmGeneratedFileStreamBase(name),
-  Stream(TempName.c_str())
+cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet)
+  : cmGeneratedFileStreamBase(name)
+  , Stream(TempName.c_str())
 {
   // Check if the file opened.
-  if(!*this && !quiet)
-    {
+  if (!*this && !quiet) {
     cmSystemTools::Error("Cannot open file for write: ",
                          this->TempName.c_str());
     cmSystemTools::ReportLastSystemError("");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmGeneratedFileStream::~cmGeneratedFileStream()
 {
   // This is the first destructor called.  Check the status of the
@@ -45,43 +42,36 @@ cmGeneratedFileStream::~cmGeneratedFileStream()
   // stream will be destroyed which will close the temporary file.
   // Finally the base destructor will be called to replace the
   // destination file.
-  this->Okay = (*this)?true:false;
+  this->Okay = (*this) ? true : false;
 }
 
-//----------------------------------------------------------------------------
-cmGeneratedFileStream&
-cmGeneratedFileStream::Open(const char* name, bool quiet, bool binaryFlag)
+cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name,
+                                                   bool quiet, bool binaryFlag)
 {
   // Store the file name and construct the temporary file name.
   this->cmGeneratedFileStreamBase::Open(name);
 
   // Open the temporary output file.
-  if ( binaryFlag )
-    {
+  if (binaryFlag) {
     this->Stream::open(this->TempName.c_str(),
                        std::ios::out | std::ios::binary);
-    }
-  else
-    {
+  } else {
     this->Stream::open(this->TempName.c_str(), std::ios::out);
-    }
+  }
 
   // Check if the file opened.
-  if(!*this && !quiet)
-    {
+  if (!*this && !quiet) {
     cmSystemTools::Error("Cannot open file for write: ",
                          this->TempName.c_str());
     cmSystemTools::ReportLastSystemError("");
-    }
+  }
   return *this;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGeneratedFileStream::Close()
+bool cmGeneratedFileStream::Close()
 {
   // Save whether the temporary output file is valid before closing.
-  this->Okay = (*this)?true:false;
+  this->Okay = (*this) ? true : false;
 
   // Close the temporary output file.
   this->Stream::close();
@@ -90,54 +80,47 @@ cmGeneratedFileStream::Close()
   return this->cmGeneratedFileStreamBase::Close();
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratedFileStream::SetCopyIfDifferent(bool copy_if_different)
 {
   this->CopyIfDifferent = copy_if_different;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratedFileStream::SetCompression(bool compression)
 {
   this->Compress = compression;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratedFileStream::SetCompressionExtraExtension(bool ext)
 {
   this->CompressExtraExtension = ext;
 }
 
-//----------------------------------------------------------------------------
-cmGeneratedFileStreamBase::cmGeneratedFileStreamBase():
-  Name(),
-  TempName(),
-  CopyIfDifferent(false),
-  Okay(false),
-  Compress(false),
-  CompressExtraExtension(true)
+cmGeneratedFileStreamBase::cmGeneratedFileStreamBase()
+  : Name()
+  , TempName()
+  , CopyIfDifferent(false)
+  , Okay(false)
+  , Compress(false)
+  , CompressExtraExtension(true)
 {
 }
 
-//----------------------------------------------------------------------------
-cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name):
-  Name(),
-  TempName(),
-  CopyIfDifferent(false),
-  Okay(false),
-  Compress(false),
-  CompressExtraExtension(true)
+cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name)
+  : Name()
+  , TempName()
+  , CopyIfDifferent(false)
+  , Okay(false)
+  , Compress(false)
+  , CompressExtraExtension(true)
 {
   this->Open(name);
 }
 
-//----------------------------------------------------------------------------
 cmGeneratedFileStreamBase::~cmGeneratedFileStreamBase()
 {
   this->Close();
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratedFileStreamBase::Open(const char* name)
 {
   // Save the original name of the file.
@@ -158,42 +141,34 @@ void cmGeneratedFileStreamBase::Open(const char* name)
   cmSystemTools::MakeDirectory(dir.c_str());
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratedFileStreamBase::Close()
 {
   bool replaced = false;
 
   std::string resname = this->Name;
-  if ( this->Compress && this->CompressExtraExtension )
-    {
+  if (this->Compress && this->CompressExtraExtension) {
     resname += ".gz";
-    }
+  }
 
   // Only consider replacing the destination file if no error
   // occurred.
-  if(!this->Name.empty() &&
-    this->Okay &&
-    (!this->CopyIfDifferent ||
-     cmSystemTools::FilesDiffer(this->TempName, resname)))
-    {
+  if (!this->Name.empty() && this->Okay &&
+      (!this->CopyIfDifferent ||
+       cmSystemTools::FilesDiffer(this->TempName, resname))) {
     // The destination is to be replaced.  Rename the temporary to the
     // destination atomically.
-    if ( this->Compress )
-      {
+    if (this->Compress) {
       std::string gzname = this->TempName + ".temp.gz";
-      if ( this->CompressFile(this->TempName.c_str(), gzname.c_str()) )
-        {
+      if (this->CompressFile(this->TempName.c_str(), gzname.c_str())) {
         this->RenameFile(gzname.c_str(), resname.c_str());
-        }
-      cmSystemTools::RemoveFile(gzname);
       }
-    else
-      {
+      cmSystemTools::RemoveFile(gzname);
+    } else {
       this->RenameFile(this->TempName.c_str(), resname.c_str());
-      }
+    }
 
     replaced = true;
-    }
+  }
 
   // Else, the destination was not replaced.
   //
@@ -203,33 +178,28 @@ bool cmGeneratedFileStreamBase::Close()
   return replaced;
 }
 
-//----------------------------------------------------------------------------
 #ifdef CMAKE_BUILD_WITH_CMAKE
 int cmGeneratedFileStreamBase::CompressFile(const char* oldname,
                                             const char* newname)
 {
   gzFile gf = gzopen(newname, "w");
-  if ( !gf )
-    {
+  if (!gf) {
     return 0;
-    }
+  }
   FILE* ifs = cmsys::SystemTools::Fopen(oldname, "r");
-  if ( !ifs )
-    {
+  if (!ifs) {
     return 0;
-    }
+  }
   size_t res;
   const size_t BUFFER_SIZE = 1024;
   char buffer[BUFFER_SIZE];
-  while ( (res = fread(buffer, 1, BUFFER_SIZE, ifs)) > 0 )
-    {
-    if ( !gzwrite(gf, buffer, static_cast<int>(res)) )
-      {
+  while ((res = fread(buffer, 1, BUFFER_SIZE, ifs)) > 0) {
+    if (!gzwrite(gf, buffer, static_cast<int>(res))) {
       fclose(ifs);
       gzclose(gf);
       return 0;
-      }
     }
+  }
   fclose(ifs);
   gzclose(gf);
   return 1;
@@ -241,14 +211,12 @@ int cmGeneratedFileStreamBase::CompressFile(const char*, const char*)
 }
 #endif
 
-//----------------------------------------------------------------------------
 int cmGeneratedFileStreamBase::RenameFile(const char* oldname,
                                           const char* newname)
 {
   return cmSystemTools::RenameFile(oldname, newname);
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratedFileStream::SetName(const std::string& fname)
 {
   this->Name = fname;
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index 8df3e1a..a2de5bc 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -13,6 +13,7 @@
 #define cmGeneratedFileStream_h
 
 #include "cmStandardIncludes.h"
+
 #include <cmsys/FStream.hxx>
 
 // This is the first base class of cmGeneratedFileStream.  It will be
@@ -73,8 +74,8 @@ protected:
  * contents have changed to prevent the file modification time from
  * being updated.
  */
-class cmGeneratedFileStream: private cmGeneratedFileStreamBase,
-                             public cmsys::ofstream
+class cmGeneratedFileStream : private cmGeneratedFileStreamBase,
+                              public cmsys::ofstream
 {
 public:
   typedef cmsys::ofstream Stream;
@@ -91,7 +92,7 @@ public:
    * file cannot be opened an error message is produced unless the
    * second argument is set to true.
    */
-  cmGeneratedFileStream(const char* name, bool quiet=false);
+  cmGeneratedFileStream(const char* name, bool quiet = false);
 
   /**
    * The destructor checks the stream status to be sure the temporary
@@ -106,8 +107,8 @@ public:
    * temporary file.  If the file cannot be opened an error message is
    * produced unless the second argument is set to true.
    */
-  cmGeneratedFileStream& Open(const char* name, bool quiet=false,
-    bool binaryFlag=false);
+  cmGeneratedFileStream& Open(const char* name, bool quiet = false,
+                              bool binaryFlag = false);
 
   /**
    * Close the output file.  This should be used only with an open
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 6796a01..53243b8 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -15,29 +15,26 @@
 #include "cmAlgorithms.h"
 #include "cmSystemTools.h"
 
+#include "cmGeneratorExpressionDAGChecker.h"
 #include "cmGeneratorExpressionEvaluator.h"
 #include "cmGeneratorExpressionLexer.h"
 #include "cmGeneratorExpressionParser.h"
-#include "cmGeneratorExpressionDAGChecker.h"
 
-//----------------------------------------------------------------------------
 cmGeneratorExpression::cmGeneratorExpression(
-    const cmListFileBacktrace& backtrace):
-  Backtrace(backtrace)
+  const cmListFileBacktrace& backtrace)
+  : Backtrace(backtrace)
 {
 }
 
-//----------------------------------------------------------------------------
-cmsys::auto_ptr<cmCompiledGeneratorExpression>
-cmGeneratorExpression::Parse(std::string const& input)
+cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
+  std::string const& input)
 {
   return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
     new cmCompiledGeneratorExpression(this->Backtrace, input));
 }
 
-//----------------------------------------------------------------------------
-cmsys::auto_ptr<cmCompiledGeneratorExpression>
-cmGeneratorExpression::Parse(const char* input)
+cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
+  const char* input)
 {
   return this->Parse(std::string(input ? input : ""));
 }
@@ -46,76 +43,62 @@ cmGeneratorExpression::~cmGeneratorExpression()
 {
 }
 
-//----------------------------------------------------------------------------
-const char *cmCompiledGeneratorExpression::Evaluate(cmLocalGenerator* lg,
-  const std::string& config, bool quiet,
+const char* cmCompiledGeneratorExpression::Evaluate(
+  cmLocalGenerator* lg, const std::string& config, bool quiet,
   const cmGeneratorTarget* headTarget,
-  cmGeneratorExpressionDAGChecker *dagChecker,
-                       std::string const& language) const
+  cmGeneratorExpressionDAGChecker* dagChecker,
+  std::string const& language) const
 {
-  return this->Evaluate(lg,
-                        config,
-                        quiet,
-                        headTarget,
-                        headTarget,
-                        dagChecker,
+  return this->Evaluate(lg, config, quiet, headTarget, headTarget, dagChecker,
                         language);
 }
 
-//----------------------------------------------------------------------------
-const char *cmCompiledGeneratorExpression::Evaluate(
+const char* cmCompiledGeneratorExpression::Evaluate(
   cmLocalGenerator* lg, const std::string& config, bool quiet,
-  const cmGeneratorTarget* headTarget,
-  const cmGeneratorTarget* currentTarget,
-  cmGeneratorExpressionDAGChecker *dagChecker,
+  const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
+  cmGeneratorExpressionDAGChecker* dagChecker,
   std::string const& language) const
 {
-  cmGeneratorExpressionContext context(lg, config, quiet, headTarget,
-                                  currentTarget ? currentTarget : headTarget,
-                                  this->EvaluateForBuildsystem,
-                                  this->Backtrace, language);
+  cmGeneratorExpressionContext context(
+    lg, config, quiet, headTarget, currentTarget ? currentTarget : headTarget,
+    this->EvaluateForBuildsystem, this->Backtrace, language);
 
   return this->EvaluateWithContext(context, dagChecker);
 }
 
-//----------------------------------------------------------------------------
 const char* cmCompiledGeneratorExpression::EvaluateWithContext(
-                            cmGeneratorExpressionContext& context,
-                            cmGeneratorExpressionDAGChecker *dagChecker) const
+  cmGeneratorExpressionContext& context,
+  cmGeneratorExpressionDAGChecker* dagChecker) const
 {
-  if (!this->NeedsEvaluation)
-    {
+  if (!this->NeedsEvaluation) {
     return this->Input.c_str();
-    }
+  }
 
   this->Output = "";
 
-  std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
-                                                  = this->Evaluators.begin();
-  const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
-                                                  = this->Evaluators.end();
+  std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+    this->Evaluators.begin();
+  const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
+    this->Evaluators.end();
 
-  for ( ; it != end; ++it)
-    {
+  for (; it != end; ++it) {
     this->Output += (*it)->Evaluate(&context, dagChecker);
 
     this->SeenTargetProperties.insert(context.SeenTargetProperties.begin(),
                                       context.SeenTargetProperties.end());
-    if (context.HadError)
-      {
+    if (context.HadError) {
       this->Output = "";
       break;
-      }
     }
+  }
 
   this->MaxLanguageStandard = context.MaxLanguageStandard;
 
-  if (!context.HadError)
-    {
+  if (!context.HadError) {
     this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
     this->HadHeadSensitiveCondition = context.HadHeadSensitiveCondition;
     this->SourceSensitiveTargets = context.SourceSensitiveTargets;
-    }
+  }
 
   this->DependTargets = context.DependTargets;
   this->AllTargetsSeen = context.AllTargets;
@@ -124,334 +107,270 @@ const char* cmCompiledGeneratorExpression::EvaluateWithContext(
 }
 
 cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
-              cmListFileBacktrace const& backtrace,
-              const std::string& input)
-  : Backtrace(backtrace), Input(input),
-    HadContextSensitiveCondition(false),
-    HadHeadSensitiveCondition(false),
-    EvaluateForBuildsystem(false)
+  cmListFileBacktrace const& backtrace, const std::string& input)
+  : Backtrace(backtrace)
+  , Input(input)
+  , HadContextSensitiveCondition(false)
+  , HadHeadSensitiveCondition(false)
+  , EvaluateForBuildsystem(false)
 {
   cmGeneratorExpressionLexer l;
-  std::vector<cmGeneratorExpressionToken> tokens =
-                                              l.Tokenize(this->Input);
+  std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(this->Input);
   this->NeedsEvaluation = l.GetSawGeneratorExpression();
 
-  if (this->NeedsEvaluation)
-    {
+  if (this->NeedsEvaluation) {
     cmGeneratorExpressionParser p(tokens);
     p.Parse(this->Evaluators);
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
 {
   cmDeleteAll(this->Evaluators);
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorExpression::StripEmptyListElements(
-                                                    const std::string &input)
+  const std::string& input)
 {
-  if (input.find(';') == input.npos)
-    {
+  if (input.find(';') == input.npos) {
     return input;
-    }
+  }
   std::string result;
   result.reserve(input.size());
 
-  const char *c = input.c_str();
-  const char *last = c;
+  const char* c = input.c_str();
+  const char* last = c;
   bool skipSemiColons = true;
-  for ( ; *c; ++c)
-    {
-    if(*c == ';')
-      {
-      if(skipSemiColons)
-        {
+  for (; *c; ++c) {
+    if (*c == ';') {
+      if (skipSemiColons) {
         result.append(last, c - last);
         last = c + 1;
-        }
-      skipSemiColons = true;
       }
-    else
-      {
+      skipSemiColons = true;
+    } else {
       skipSemiColons = false;
-      }
     }
+  }
   result.append(last);
 
-  if (!result.empty() && *(result.end() - 1) == ';')
-    {
+  if (!result.empty() && *(result.end() - 1) == ';') {
     result.resize(result.size() - 1);
-    }
+  }
 
   return result;
 }
 
-//----------------------------------------------------------------------------
-static std::string stripAllGeneratorExpressions(const std::string &input)
+static std::string stripAllGeneratorExpressions(const std::string& input)
 {
   std::string result;
   std::string::size_type pos = 0;
   std::string::size_type lastPos = pos;
   int nestingLevel = 0;
-  while((pos = input.find("$<", lastPos)) != input.npos)
-    {
+  while ((pos = input.find("$<", lastPos)) != input.npos) {
     result += input.substr(lastPos, pos - lastPos);
     pos += 2;
     nestingLevel = 1;
-    const char *c = input.c_str() + pos;
-    const char * const cStart = c;
-    for ( ; *c; ++c)
-      {
-      if(c[0] == '$' && c[1] == '<')
-        {
+    const char* c = input.c_str() + pos;
+    const char* const cStart = c;
+    for (; *c; ++c) {
+      if (c[0] == '$' && c[1] == '<') {
         ++nestingLevel;
         ++c;
         continue;
-        }
-      if(c[0] == '>')
-        {
+      }
+      if (c[0] == '>') {
         --nestingLevel;
-        if (nestingLevel == 0)
-          {
+        if (nestingLevel == 0) {
           break;
-          }
         }
       }
+    }
     const std::string::size_type traversed = (c - cStart) + 1;
-    if (!*c)
-      {
+    if (!*c) {
       result += "$<" + input.substr(pos, traversed);
-      }
+    }
     pos += traversed;
     lastPos = pos;
-    }
-  if (nestingLevel == 0)
-    {
+  }
+  if (nestingLevel == 0) {
     result += input.substr(lastPos);
-    }
+  }
   return cmGeneratorExpression::StripEmptyListElements(result);
 }
 
-//----------------------------------------------------------------------------
-static void prefixItems(const std::string &content, std::string &result,
-                        const std::string &prefix)
+static void prefixItems(const std::string& content, std::string& result,
+                        const std::string& prefix)
 {
   std::vector<std::string> entries;
   cmGeneratorExpression::Split(content, entries);
-  const char *sep = "";
-  for(std::vector<std::string>::const_iterator ei = entries.begin();
-      ei != entries.end(); ++ei)
-    {
+  const char* sep = "";
+  for (std::vector<std::string>::const_iterator ei = entries.begin();
+       ei != entries.end(); ++ei) {
     result += sep;
     sep = ";";
-    if (!cmSystemTools::FileIsFullPath(ei->c_str())
-        && cmGeneratorExpression::Find(*ei) != 0)
-      {
+    if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
+        cmGeneratorExpression::Find(*ei) != 0) {
       result += prefix;
-      }
-    result += *ei;
     }
+    result += *ei;
+  }
 }
 
-//----------------------------------------------------------------------------
-static std::string stripExportInterface(const std::string &input,
-                          cmGeneratorExpression::PreprocessContext context,
-                          bool resolveRelative)
+static std::string stripExportInterface(
+  const std::string& input, cmGeneratorExpression::PreprocessContext context,
+  bool resolveRelative)
 {
   std::string result;
 
   int nestingLevel = 0;
   std::string::size_type pos = 0;
   std::string::size_type lastPos = pos;
-  while (true)
-    {
+  while (true) {
     std::string::size_type bPos = input.find("$<BUILD_INTERFACE:", lastPos);
     std::string::size_type iPos = input.find("$<INSTALL_INTERFACE:", lastPos);
 
-    if (bPos == std::string::npos && iPos == std::string::npos)
-      {
+    if (bPos == std::string::npos && iPos == std::string::npos) {
       break;
-      }
+    }
 
-    if (bPos == std::string::npos)
-      {
+    if (bPos == std::string::npos) {
       pos = iPos;
-      }
-    else if (iPos == std::string::npos)
-      {
+    } else if (iPos == std::string::npos) {
       pos = bPos;
-      }
-    else
-      {
+    } else {
       pos = (bPos < iPos) ? bPos : iPos;
-      }
+    }
 
     result += input.substr(lastPos, pos - lastPos);
     const bool gotInstallInterface = input[pos + 2] == 'I';
     pos += gotInstallInterface ? sizeof("$<INSTALL_INTERFACE:") - 1
                                : sizeof("$<BUILD_INTERFACE:") - 1;
     nestingLevel = 1;
-    const char *c = input.c_str() + pos;
-    const char * const cStart = c;
-    for ( ; *c; ++c)
-      {
-      if(c[0] == '$' && c[1] == '<')
-        {
+    const char* c = input.c_str() + pos;
+    const char* const cStart = c;
+    for (; *c; ++c) {
+      if (c[0] == '$' && c[1] == '<') {
         ++nestingLevel;
         ++c;
         continue;
-        }
-      if(c[0] == '>')
-        {
+      }
+      if (c[0] == '>') {
         --nestingLevel;
-        if (nestingLevel != 0)
-          {
+        if (nestingLevel != 0) {
           continue;
-          }
-        if(context == cmGeneratorExpression::BuildInterface
-            && !gotInstallInterface)
-          {
+        }
+        if (context == cmGeneratorExpression::BuildInterface &&
+            !gotInstallInterface) {
           result += input.substr(pos, c - cStart);
-          }
-        else if(context == cmGeneratorExpression::InstallInterface
-            && gotInstallInterface)
-          {
+        } else if (context == cmGeneratorExpression::InstallInterface &&
+                   gotInstallInterface) {
           const std::string content = input.substr(pos, c - cStart);
-          if (resolveRelative)
-            {
+          if (resolveRelative) {
             prefixItems(content, result, "${_IMPORT_PREFIX}/");
-            }
-          else
-            {
+          } else {
             result += content;
-            }
           }
-        break;
         }
+        break;
       }
+    }
     const std::string::size_type traversed = (c - cStart) + 1;
-    if (!*c)
-      {
+    if (!*c) {
       result += std::string(gotInstallInterface ? "$<INSTALL_INTERFACE:"
-                                                : "$<BUILD_INTERFACE:")
-             + input.substr(pos, traversed);
-      }
+                                                : "$<BUILD_INTERFACE:") +
+        input.substr(pos, traversed);
+    }
     pos += traversed;
     lastPos = pos;
-    }
-  if (nestingLevel == 0)
-    {
+  }
+  if (nestingLevel == 0) {
     result += input.substr(lastPos);
-    }
+  }
 
   return cmGeneratorExpression::StripEmptyListElements(result);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorExpression::Split(const std::string &input,
-                                  std::vector<std::string> &output)
+void cmGeneratorExpression::Split(const std::string& input,
+                                  std::vector<std::string>& output)
 {
   std::string::size_type pos = 0;
   std::string::size_type lastPos = pos;
-  while((pos = input.find("$<", lastPos)) != input.npos)
-    {
+  while ((pos = input.find("$<", lastPos)) != input.npos) {
     std::string part = input.substr(lastPos, pos - lastPos);
     std::string preGenex;
-    if (!part.empty())
-      {
-      std::string::size_type startPos = input.rfind(";", pos);
-      if (startPos == std::string::npos)
-        {
+    if (!part.empty()) {
+      std::string::size_type startPos = input.rfind(';', pos);
+      if (startPos == std::string::npos) {
         preGenex = part;
         part = "";
-        }
-      else if (startPos != pos - 1 && startPos >= lastPos)
-        {
+      } else if (startPos != pos - 1 && startPos >= lastPos) {
         part = input.substr(lastPos, startPos - lastPos);
         preGenex = input.substr(startPos + 1, pos - startPos - 1);
-        }
-      if(!part.empty())
-        {
+      }
+      if (!part.empty()) {
         cmSystemTools::ExpandListArgument(part, output);
-        }
       }
+    }
     pos += 2;
     int nestingLevel = 1;
-    const char *c = input.c_str() + pos;
-    const char * const cStart = c;
-    for ( ; *c; ++c)
-      {
-      if(c[0] == '$' && c[1] == '<')
-        {
+    const char* c = input.c_str() + pos;
+    const char* const cStart = c;
+    for (; *c; ++c) {
+      if (c[0] == '$' && c[1] == '<') {
         ++nestingLevel;
         ++c;
         continue;
-        }
-      if(c[0] == '>')
-        {
+      }
+      if (c[0] == '>') {
         --nestingLevel;
-        if (nestingLevel == 0)
-          {
+        if (nestingLevel == 0) {
           break;
-          }
         }
       }
-    for ( ; *c; ++c)
-      {
+    }
+    for (; *c; ++c) {
       // Capture the part after the genex and before the next ';'
-      if(c[0] == ';')
-        {
+      if (c[0] == ';') {
         --c;
         break;
-        }
       }
+    }
     const std::string::size_type traversed = (c - cStart) + 1;
     output.push_back(preGenex + "$<" + input.substr(pos, traversed));
     pos += traversed;
     lastPos = pos;
-    }
-  if (lastPos < input.size())
-    {
+  }
+  if (lastPos < input.size()) {
     cmSystemTools::ExpandListArgument(input.substr(lastPos), output);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string cmGeneratorExpression::Preprocess(const std::string &input,
+std::string cmGeneratorExpression::Preprocess(const std::string& input,
                                               PreprocessContext context,
                                               bool resolveRelative)
 {
-  if (context == StripAllGeneratorExpressions)
-    {
+  if (context == StripAllGeneratorExpressions) {
     return stripAllGeneratorExpressions(input);
-    }
-  else if (context == BuildInterface || context == InstallInterface)
-    {
+  } else if (context == BuildInterface || context == InstallInterface) {
     return stripExportInterface(input, context, resolveRelative);
-    }
+  }
 
   assert(0 && "cmGeneratorExpression::Preprocess called with invalid args");
   return std::string();
 }
 
-//----------------------------------------------------------------------------
-std::string::size_type cmGeneratorExpression::Find(const std::string &input)
+std::string::size_type cmGeneratorExpression::Find(const std::string& input)
 {
   const std::string::size_type openpos = input.find("$<");
-  if (openpos != std::string::npos
-      && input.find(">", openpos) != std::string::npos)
-    {
+  if (openpos != std::string::npos &&
+      input.find('>', openpos) != std::string::npos) {
     return openpos;
-    }
+  }
   return std::string::npos;
 }
 
-//----------------------------------------------------------------------------
-bool cmGeneratorExpression::IsValidTargetName(const std::string &input)
+bool cmGeneratorExpression::IsValidTargetName(const std::string& input)
 {
   // The ':' is supported to allow use with IMPORTED targets. At least
   // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter.
@@ -460,17 +379,14 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string &input)
   return targetNameValidator.find(input);
 }
 
-//----------------------------------------------------------------------------
-void
-cmCompiledGeneratorExpression::GetMaxLanguageStandard(
-    const cmGeneratorTarget* tgt,
-                  std::map<std::string, std::string>& mapping)
+void cmCompiledGeneratorExpression::GetMaxLanguageStandard(
+  const cmGeneratorTarget* tgt, std::map<std::string, std::string>& mapping)
 {
   typedef std::map<cmGeneratorTarget const*,
-                   std::map<std::string, std::string> > MapType;
+                   std::map<std::string, std::string> >
+    MapType;
   MapType::const_iterator it = this->MaxLanguageStandard.find(tgt);
-  if (it != this->MaxLanguageStandard.end())
-    {
+  if (it != this->MaxLanguageStandard.end()) {
     mapping = it->second;
-    }
+  }
 }
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index efd381b..71fbba3 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -14,6 +14,7 @@
 #define cmGeneratorExpression_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmListFileCache.h"
 
 #include <cmsys/RegularExpression.hxx>
@@ -43,34 +44,36 @@ class cmGeneratorExpression
 public:
   /** Construct. */
   cmGeneratorExpression(
-      cmListFileBacktrace const& backtrace = cmListFileBacktrace());
+    cmListFileBacktrace const& backtrace = cmListFileBacktrace());
   ~cmGeneratorExpression();
 
   cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(
-                                                std::string const& input);
+    std::string const& input);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
 
-  enum PreprocessContext {
+  enum PreprocessContext
+  {
     StripAllGeneratorExpressions,
     BuildInterface,
     InstallInterface
   };
 
-  static std::string Preprocess(const std::string &input,
+  static std::string Preprocess(const std::string& input,
                                 PreprocessContext context,
                                 bool resolveRelative = false);
 
-  static void Split(const std::string &input,
-                    std::vector<std::string> &output);
+  static void Split(const std::string& input,
+                    std::vector<std::string>& output);
 
-  static std::string::size_type Find(const std::string &input);
+  static std::string::size_type Find(const std::string& input);
 
-  static bool IsValidTargetName(const std::string &input);
+  static bool IsValidTargetName(const std::string& input);
+
+  static std::string StripEmptyListElements(const std::string& input);
 
-  static std::string StripEmptyListElements(const std::string &input);
 private:
-  cmGeneratorExpression(const cmGeneratorExpression &);
-  void operator=(const cmGeneratorExpression &);
+  cmGeneratorExpression(const cmGeneratorExpression&);
+  void operator=(const cmGeneratorExpression&);
 
   cmListFileBacktrace Backtrace;
 };
@@ -82,35 +85,34 @@ public:
                        bool quiet = false,
                        cmGeneratorTarget const* headTarget = 0,
                        cmGeneratorTarget const* currentTarget = 0,
-                       cmGeneratorExpressionDAGChecker *dagChecker = 0,
+                       cmGeneratorExpressionDAGChecker* dagChecker = 0,
                        std::string const& language = std::string()) const;
   const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
-                       bool quiet,
-                       cmGeneratorTarget const* headTarget,
-                       cmGeneratorExpressionDAGChecker *dagChecker,
+                       bool quiet, cmGeneratorTarget const* headTarget,
+                       cmGeneratorExpressionDAGChecker* dagChecker,
                        std::string const& language = std::string()) const;
 
   /** Get set of targets found during evaluations.  */
   std::set<cmGeneratorTarget*> const& GetTargets() const
-    { return this->DependTargets; }
+  {
+    return this->DependTargets;
+  }
 
   std::set<std::string> const& GetSeenTargetProperties() const
-    { return this->SeenTargetProperties; }
+  {
+    return this->SeenTargetProperties;
+  }
 
   std::set<cmGeneratorTarget const*> const& GetAllTargetsSeen() const
-    { return this->AllTargetsSeen; }
+  {
+    return this->AllTargetsSeen;
+  }
 
   ~cmCompiledGeneratorExpression();
 
-  std::string const& GetInput() const
-  {
-    return this->Input;
-  }
+  std::string const& GetInput() const { return this->Input; }
 
-  cmListFileBacktrace GetBacktrace() const
-  {
-    return this->Backtrace;
-  }
+  cmListFileBacktrace GetBacktrace() const { return this->Backtrace; }
   bool GetHadContextSensitiveCondition() const
   {
     return this->HadContextSensitiveCondition;
@@ -130,19 +132,20 @@ public:
   }
 
   void GetMaxLanguageStandard(cmGeneratorTarget const* tgt,
-                    std::map<std::string, std::string>& mapping);
+                              std::map<std::string, std::string>& mapping);
 
 private:
-  const char* EvaluateWithContext(cmGeneratorExpressionContext& context,
-                           cmGeneratorExpressionDAGChecker *dagChecker) const;
+  const char* EvaluateWithContext(
+    cmGeneratorExpressionContext& context,
+    cmGeneratorExpressionDAGChecker* dagChecker) const;
 
   cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
-              const std::string& input);
+                                const std::string& input);
 
   friend class cmGeneratorExpression;
 
-  cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
-  void operator=(const cmCompiledGeneratorExpression &);
+  cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression&);
+  void operator=(const cmCompiledGeneratorExpression&);
 
   cmListFileBacktrace Backtrace;
   std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
@@ -153,11 +156,12 @@ private:
   mutable std::set<cmGeneratorTarget const*> AllTargetsSeen;
   mutable std::set<std::string> SeenTargetProperties;
   mutable std::map<cmGeneratorTarget const*,
-                   std::map<std::string, std::string> > MaxLanguageStandard;
+                   std::map<std::string, std::string> >
+    MaxLanguageStandard;
   mutable std::string Output;
   mutable bool HadContextSensitiveCondition;
   mutable bool HadHeadSensitiveCondition;
-  mutable std::set<cmGeneratorTarget const*>  SourceSensitiveTargets;
+  mutable std::set<cmGeneratorTarget const*> SourceSensitiveTargets;
   bool EvaluateForBuildsystem;
 };
 
diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx
index 5c9462f..8da6b50 100644
--- a/Source/cmGeneratorExpressionContext.cxx
+++ b/Source/cmGeneratorExpressionContext.cxx
@@ -11,25 +11,24 @@
 ============================================================================*/
 
 #include "cmGeneratorExpressionContext.h"
+
 #include "cmGeneratorTarget.h"
 
 cmGeneratorExpressionContext::cmGeneratorExpressionContext(
-      cmLocalGenerator* lg, std::string const& config,
-      bool quiet, cmGeneratorTarget const* headTarget,
-      const cmGeneratorTarget* currentTarget,
-      bool evaluateForBuildsystem,
-      cmListFileBacktrace const& backtrace,
-      std::string const& language)
-  : Backtrace(backtrace),
-    LG(lg),
-    Config(config),
-    Language(language),
-    HeadTarget(headTarget),
-    CurrentTarget(currentTarget),
-    Quiet(quiet),
-    HadError(false),
-    HadContextSensitiveCondition(false),
-    HadHeadSensitiveCondition(false),
-    EvaluateForBuildsystem(evaluateForBuildsystem)
+  cmLocalGenerator* lg, std::string const& config, bool quiet,
+  cmGeneratorTarget const* headTarget, const cmGeneratorTarget* currentTarget,
+  bool evaluateForBuildsystem, cmListFileBacktrace const& backtrace,
+  std::string const& language)
+  : Backtrace(backtrace)
+  , LG(lg)
+  , Config(config)
+  , Language(language)
+  , HeadTarget(headTarget)
+  , CurrentTarget(currentTarget)
+  , Quiet(quiet)
+  , HadError(false)
+  , HadContextSensitiveCondition(false)
+  , HadHeadSensitiveCondition(false)
+  , EvaluateForBuildsystem(evaluateForBuildsystem)
 {
 }
diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h
index e802138..cff7289 100644
--- a/Source/cmGeneratorExpressionContext.h
+++ b/Source/cmGeneratorExpressionContext.h
@@ -14,14 +14,13 @@
 
 #include "cmListFileCache.h"
 
-#include <set>
 #include <map>
+#include <set>
 #include <string>
 
 class cmGeneratorTarget;
 class cmLocalGenerator;
 
-//----------------------------------------------------------------------------
 struct cmGeneratorExpressionContext
 {
   cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string const& config,
@@ -31,15 +30,14 @@ struct cmGeneratorExpressionContext
                                cmListFileBacktrace const& backtrace,
                                std::string const& language);
 
-
   cmListFileBacktrace Backtrace;
   std::set<cmGeneratorTarget*> DependTargets;
   std::set<cmGeneratorTarget const*> AllTargets;
   std::set<std::string> SeenTargetProperties;
   std::set<cmGeneratorTarget const*> SourceSensitiveTargets;
   std::map<cmGeneratorTarget const*, std::map<std::string, std::string> >
-                                                          MaxLanguageStandard;
-  cmLocalGenerator *LG;
+    MaxLanguageStandard;
+  cmLocalGenerator* LG;
   std::string Config;
   std::string Language;
   // The target whose property is being evaluated.
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index c3b0272..c700156 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -12,234 +12,213 @@
 
 #include "cmGeneratorExpressionDAGChecker.h"
 
-#include "cmLocalGenerator.h"
 #include "cmAlgorithms.h"
+#include "cmLocalGenerator.h"
 
-//----------------------------------------------------------------------------
 cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
-                const cmListFileBacktrace &backtrace,
-                const std::string &target,
-                const std::string &property,
-                const GeneratorExpressionContent *content,
-                cmGeneratorExpressionDAGChecker *parent)
-  : Parent(parent), Target(target), Property(property),
-    Content(content), Backtrace(backtrace), TransitivePropertiesOnly(false)
+  const cmListFileBacktrace& backtrace, const std::string& target,
+  const std::string& property, const GeneratorExpressionContent* content,
+  cmGeneratorExpressionDAGChecker* parent)
+  : 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(), TransitivePropertiesOnly(false)
+  const std::string& target, const std::string& property,
+  const GeneratorExpressionContent* content,
+  cmGeneratorExpressionDAGChecker* parent)
+  : Parent(parent)
+  , Target(target)
+  , Property(property)
+  , Content(content)
+  , Backtrace()
+  , TransitivePropertiesOnly(false)
 {
   Initialize();
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorExpressionDAGChecker::Initialize()
+void cmGeneratorExpressionDAGChecker::Initialize()
 {
-  const cmGeneratorExpressionDAGChecker *top = this;
-  const cmGeneratorExpressionDAGChecker *p = this->Parent;
-  while (p)
-    {
+  const cmGeneratorExpressionDAGChecker* top = this;
+  const cmGeneratorExpressionDAGChecker* p = this->Parent;
+  while (p) {
     top = p;
     p = p->Parent;
-    }
+  }
   this->CheckResult = this->CheckGraph();
 
-#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) \
-  top->METHOD () ||
+#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() ||
 
-  if (CheckResult == DAG && (
-      CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(TEST_TRANSITIVE_PROPERTY_METHOD)
-      false)
-     )
+  if (CheckResult == DAG && (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
+                              TEST_TRANSITIVE_PROPERTY_METHOD) false))
 #undef TEST_TRANSITIVE_PROPERTY_METHOD
-    {
-    std::map<std::string, std::set<std::string> >::const_iterator it
-                                              = top->Seen.find(this->Target);
-    if (it != top->Seen.end())
-      {
-      const std::set<std::string> &propSet = it->second;
-      if (propSet.find(this->Property) != propSet.end())
-        {
+  {
+    std::map<std::string, std::set<std::string> >::const_iterator it =
+      top->Seen.find(this->Target);
+    if (it != top->Seen.end()) {
+      const std::set<std::string>& propSet = it->second;
+      if (propSet.find(this->Property) != propSet.end()) {
         this->CheckResult = ALREADY_SEEN;
         return;
-        }
       }
-    const_cast<cmGeneratorExpressionDAGChecker *>(top)
-      ->Seen[this->Target].insert(this->Property);
     }
+    const_cast<cmGeneratorExpressionDAGChecker*>(top)
+      ->Seen[this->Target]
+      .insert(this->Property);
+  }
 }
 
-//----------------------------------------------------------------------------
 cmGeneratorExpressionDAGChecker::Result
 cmGeneratorExpressionDAGChecker::Check() const
 {
   return this->CheckResult;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorExpressionDAGChecker::ReportError(
-                  cmGeneratorExpressionContext *context,
-                  const std::string &expr)
+  cmGeneratorExpressionContext* context, const std::string& expr)
 {
-  if (this->CheckResult == DAG)
-    {
+  if (this->CheckResult == DAG) {
     return;
-    }
+  }
 
   context->HadError = true;
-  if (context->Quiet)
-    {
+  if (context->Quiet) {
     return;
-    }
+  }
 
-  const cmGeneratorExpressionDAGChecker *parent = this->Parent;
+  const cmGeneratorExpressionDAGChecker* parent = this->Parent;
 
-  if (parent && !parent->Parent)
-    {
+  if (parent && !parent->Parent) {
     std::ostringstream e;
     e << "Error evaluating generator expression:\n"
       << "  " << expr << "\n"
-      << "Self reference on target \""
-      << context->HeadTarget->GetName() << "\".\n";
-    context->LG->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                      parent->Backtrace);
+      << "Self reference on target \"" << context->HeadTarget->GetName()
+      << "\".\n";
+    context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                                  parent->Backtrace);
     return;
-    }
+  }
 
   {
-  std::ostringstream e;
+    std::ostringstream e;
+    /* clang-format off */
   e << "Error evaluating generator expression:\n"
     << "  " << expr << "\n"
     << "Dependency loop found.";
-  context->LG->GetCMakeInstance()
-    ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                    context->Backtrace);
+    /* clang-format on */
+    context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                                  context->Backtrace);
   }
 
   int loopStep = 1;
-  while (parent)
-    {
+  while (parent) {
     std::ostringstream e;
     e << "Loop step " << loopStep << "\n"
       << "  "
       << (parent->Content ? parent->Content->GetOriginalExpression() : expr)
       << "\n";
-    context->LG->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                      parent->Backtrace);
+    context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                                  parent->Backtrace);
     parent = parent->Parent;
     ++loopStep;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmGeneratorExpressionDAGChecker::Result
 cmGeneratorExpressionDAGChecker::CheckGraph() const
 {
-  const cmGeneratorExpressionDAGChecker *parent = this->Parent;
-  while (parent)
-    {
-    if (this->Target == parent->Target && this->Property == parent->Property)
-      {
+  const cmGeneratorExpressionDAGChecker* parent = this->Parent;
+  while (parent) {
+    if (this->Target == parent->Target && this->Property == parent->Property) {
       return (parent == this->Parent) ? SELF_REFERENCE : CYCLIC_REFERENCE;
-      }
-    parent = parent->Parent;
     }
+    parent = parent->Parent;
+  }
   return DAG;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly()
 {
-  const cmGeneratorExpressionDAGChecker *top = this;
-  const cmGeneratorExpressionDAGChecker *parent = this->Parent;
-  while (parent)
-    {
+  const cmGeneratorExpressionDAGChecker* top = this;
+  const cmGeneratorExpressionDAGChecker* parent = this->Parent;
+  while (parent) {
     top = parent;
     parent = parent->Parent;
-    }
+  }
 
   return top->TransitivePropertiesOnly;
 }
 
-//----------------------------------------------------------------------------
-bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt)
+bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char* tgt)
 {
-  const cmGeneratorExpressionDAGChecker *top = this;
-  const cmGeneratorExpressionDAGChecker *parent = this->Parent;
-  while (parent)
-    {
+  const cmGeneratorExpressionDAGChecker* top = this;
+  const cmGeneratorExpressionDAGChecker* parent = this->Parent;
+  while (parent) {
     top = parent;
     parent = parent->Parent;
-    }
+  }
 
-  const char *prop = top->Property.c_str();
+  const char* prop = top->Property.c_str();
 
-  if (tgt)
-    {
+  if (tgt) {
     return top->Target == tgt && strcmp(prop, "LINK_LIBRARIES") == 0;
-    }
+  }
 
-  return (strcmp(prop, "LINK_LIBRARIES") == 0
-       || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0
-       || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
-       || cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_")
-       || cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_"))
-       || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0;
+  return (strcmp(prop, "LINK_LIBRARIES") == 0 ||
+          strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 ||
+          strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
+          cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") ||
+          cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_")) ||
+    strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0;
 }
 
 std::string cmGeneratorExpressionDAGChecker::TopTarget() const
 {
-  const cmGeneratorExpressionDAGChecker *top = this;
-  const cmGeneratorExpressionDAGChecker *parent = this->Parent;
-  while (parent)
-    {
+  const cmGeneratorExpressionDAGChecker* top = this;
+  const cmGeneratorExpressionDAGChecker* parent = this->Parent;
+  while (parent) {
     top = parent;
     parent = parent->Parent;
-    }
+  }
   return top->Target;
 }
 
-enum TransitiveProperty {
+enum TransitiveProperty
+{
 #define DEFINE_ENUM_ENTRY(NAME) NAME,
   CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY)
 #undef DEFINE_ENUM_ENTRY
-  TransitivePropertyTerminal
+    TransitivePropertyTerminal
 };
 
-template<TransitiveProperty>
+template <TransitiveProperty>
 bool additionalTest(const char* const)
 {
   return false;
 }
 
-template<>
+template <>
 bool additionalTest<COMPILE_DEFINITIONS>(const char* const prop)
 {
   return cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_");
 }
 
-#define DEFINE_TRANSITIVE_PROPERTY_METHOD(METHOD, PROPERTY) \
-bool cmGeneratorExpressionDAGChecker::METHOD() const \
-{ \
-  const char* const prop = this->Property.c_str(); \
-  if (strcmp(prop, #PROPERTY) == 0 \
-      || strcmp(prop, "INTERFACE_" #PROPERTY) == 0) \
-    { \
-    return true; \
-    } \
-  return additionalTest<PROPERTY>(prop); \
-}
+#define DEFINE_TRANSITIVE_PROPERTY_METHOD(METHOD, PROPERTY)                   \
+  bool cmGeneratorExpressionDAGChecker::METHOD() const                        \
+  {                                                                           \
+    const char* const prop = this->Property.c_str();                          \
+    if (strcmp(prop, #PROPERTY) == 0 ||                                       \
+        strcmp(prop, "INTERFACE_" #PROPERTY) == 0) {                          \
+      return true;                                                            \
+    }                                                                         \
+    return additionalTest<PROPERTY>(prop);                                    \
+  }
 
 CM_FOR_EACH_TRANSITIVE_PROPERTY(DEFINE_TRANSITIVE_PROPERTY_METHOD)
 
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 10f9fa7..28ca824 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -20,38 +20,38 @@
 #define CM_SELECT_FIRST(F, A1, A2) F(A1)
 #define CM_SELECT_SECOND(F, A1, A2) F(A2)
 
-#define CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, SELECT) \
-  SELECT(F, EvaluatingIncludeDirectories,       INCLUDE_DIRECTORIES) \
-  SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES) \
-  SELECT(F, EvaluatingCompileDefinitions,       COMPILE_DEFINITIONS) \
-  SELECT(F, EvaluatingCompileOptions,           COMPILE_OPTIONS) \
-  SELECT(F, EvaluatingAutoUicOptions,           AUTOUIC_OPTIONS) \
-  SELECT(F, EvaluatingSources,                  SOURCES) \
-  SELECT(F, EvaluatingCompileFeatures,          COMPILE_FEATURES)
-
-#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \
+#define CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, SELECT)                       \
+  SELECT(F, EvaluatingIncludeDirectories, INCLUDE_DIRECTORIES)                \
+  SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES)   \
+  SELECT(F, EvaluatingCompileDefinitions, COMPILE_DEFINITIONS)                \
+  SELECT(F, EvaluatingCompileOptions, COMPILE_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)
 
-#define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \
+#define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F)                             \
   CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST)
 
-#define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \
+#define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F)                               \
   CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_SECOND)
 
-//----------------------------------------------------------------------------
 struct cmGeneratorExpressionDAGChecker
 {
-  cmGeneratorExpressionDAGChecker(const cmListFileBacktrace &backtrace,
-                                  const std::string &target,
-                                  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 {
+  cmGeneratorExpressionDAGChecker(const cmListFileBacktrace& backtrace,
+                                  const std::string& target,
+                                  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,
     SELF_REFERENCE,
     CYCLIC_REFERENCE,
@@ -60,21 +60,19 @@ struct cmGeneratorExpressionDAGChecker
 
   Result Check() const;
 
-  void ReportError(cmGeneratorExpressionContext *context,
-                   const std::string &expr);
+  void ReportError(cmGeneratorExpressionContext* context,
+                   const std::string& expr);
 
-  bool EvaluatingLinkLibraries(const char *tgt = 0);
+  bool EvaluatingLinkLibraries(const char* tgt = 0);
 
-#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) \
-  bool METHOD () const;
+#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) bool METHOD() const;
 
   CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(DECLARE_TRANSITIVE_PROPERTY_METHOD)
 
 #undef DECLARE_TRANSITIVE_PROPERTY_METHOD
 
   bool GetTransitivePropertiesOnly();
-  void SetTransitivePropertiesOnly()
-    { this->TransitivePropertiesOnly = true; }
+  void SetTransitivePropertiesOnly() { this->TransitivePropertiesOnly = true; }
 
   std::string TopTarget() const;
 
@@ -83,11 +81,11 @@ private:
   void Initialize();
 
 private:
-  const cmGeneratorExpressionDAGChecker * const Parent;
+  const cmGeneratorExpressionDAGChecker* const Parent;
   const std::string Target;
   const std::string Property;
   std::map<std::string, std::set<std::string> > Seen;
-  const GeneratorExpressionContent * const Content;
+  const GeneratorExpressionContent* const Content;
   const cmListFileBacktrace Backtrace;
   Result CheckResult;
   bool TransitivePropertiesOnly;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 4ac2a0d..5b48eea 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -12,177 +12,153 @@
 
 #include "cmGeneratorExpressionEvaluationFile.h"
 
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
 #include "cmSourceFile.h"
-#include "cmGeneratedFileStream.h"
 #include <cmsys/FStream.hxx>
 
 #include <assert.h>
 
-//----------------------------------------------------------------------------
 cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
-        const std::string &input,
-        cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr,
-        cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
-        bool inputIsContent)
-  : Input(input),
-    OutputFileExpr(outputFileExpr),
-    Condition(condition),
-    InputIsContent(inputIsContent)
+  const std::string& input,
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+  bool inputIsContent)
+  : Input(input)
+  , OutputFileExpr(outputFileExpr)
+  , Condition(condition)
+  , InputIsContent(inputIsContent)
 {
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg,
-              const std::string& config,
-              const std::string& lang,
-              cmCompiledGeneratorExpression* inputExpression,
-              std::map<std::string, std::string> &outputFiles, mode_t perm)
+void cmGeneratorExpressionEvaluationFile::Generate(
+  cmLocalGenerator* lg, const std::string& config, const std::string& lang,
+  cmCompiledGeneratorExpression* inputExpression,
+  std::map<std::string, std::string>& outputFiles, mode_t perm)
 {
   std::string rawCondition = this->Condition->GetInput();
-  if (!rawCondition.empty())
-    {
-    std::string condResult = this->Condition->Evaluate(lg,
-                                                       config,
-                                                       false, 0, 0, 0, lang);
-    if (condResult == "0")
-      {
+  if (!rawCondition.empty()) {
+    std::string condResult =
+      this->Condition->Evaluate(lg, config, false, 0, 0, 0, lang);
+    if (condResult == "0") {
       return;
-      }
-    if (condResult != "1")
-      {
+    }
+    if (condResult != "1") {
       std::ostringstream e;
-      e << "Evaluation file condition \"" << rawCondition << "\" did "
-          "not evaluate to valid content. Got \"" << condResult << "\".";
+      e << "Evaluation file condition \"" << rawCondition
+        << "\" did "
+           "not evaluate to valid content. Got \""
+        << condResult << "\".";
       lg->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
     }
+  }
 
-  const std::string outputFileName
-                    = this->OutputFileExpr->Evaluate(lg, config,
-                                                     false, 0, 0, 0, lang);
-  const std::string outputContent
-                          = inputExpression->Evaluate(lg,
-                                                      config,
-                                                      false, 0, 0, 0, lang);
-
-  std::map<std::string, std::string>::iterator it
-                                          = outputFiles.find(outputFileName);
-
-  if(it != outputFiles.end())
-    {
-    if (it->second == outputContent)
-      {
+  const std::string outputFileName =
+    this->OutputFileExpr->Evaluate(lg, config, false, 0, 0, 0, lang);
+  const std::string outputContent =
+    inputExpression->Evaluate(lg, config, false, 0, 0, 0, lang);
+
+  std::map<std::string, std::string>::iterator it =
+    outputFiles.find(outputFileName);
+
+  if (it != outputFiles.end()) {
+    if (it->second == outputContent) {
       return;
-      }
+    }
     std::ostringstream e;
     e << "Evaluation file to be written multiple times for different "
          "configurations or languages with different content:\n  "
       << outputFileName;
     lg->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
+  }
 
-  lg->GetMakefile()->AddCMakeOutputFile(outputFileName.c_str());
+  lg->GetMakefile()->AddCMakeOutputFile(outputFileName);
   this->Files.push_back(outputFileName);
   outputFiles[outputFileName] = outputContent;
 
   cmGeneratedFileStream fout(outputFileName.c_str());
   fout.SetCopyIfDifferent(true);
   fout << outputContent;
-  if (fout.Close() && perm)
-    {
+  if (fout.Close() && perm) {
     cmSystemTools::SetPermissions(outputFileName.c_str(), perm);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
-    cmLocalGenerator *lg, std::string const& config)
+  cmLocalGenerator* lg, std::string const& config)
 {
   std::vector<std::string> enabledLanguages;
-  cmGlobalGenerator *gg = lg->GetGlobalGenerator();
+  cmGlobalGenerator* gg = lg->GetGlobalGenerator();
   gg->GetEnabledLanguages(enabledLanguages);
 
-  for(std::vector<std::string>::const_iterator le = enabledLanguages.begin();
-      le != enabledLanguages.end(); ++le)
-    {
-    std::string name = this->OutputFileExpr->Evaluate(lg,
-                                                      config,
-                                                      false, 0, 0, 0, *le);
+  for (std::vector<std::string>::const_iterator le = enabledLanguages.begin();
+       le != enabledLanguages.end(); ++le) {
+    std::string name =
+      this->OutputFileExpr->Evaluate(lg, config, false, 0, 0, 0, *le);
     cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name);
     sf->SetProperty("GENERATED", "1");
 
-    gg->SetFilenameTargetDepends(sf,
-                          this->OutputFileExpr->GetSourceSensitiveTargets());
-    }
+    gg->SetFilenameTargetDepends(
+      sf, this->OutputFileExpr->GetSourceSensitiveTargets());
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg)
+void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
 {
   mode_t perm = 0;
   std::string inputContent;
-  if (this->InputIsContent)
-    {
+  if (this->InputIsContent) {
     inputContent = this->Input;
-    }
-  else
-    {
-    lg->GetMakefile()->AddCMakeDependFile(this->Input.c_str());
+  } else {
+    lg->GetMakefile()->AddCMakeDependFile(this->Input);
     cmSystemTools::GetPermissions(this->Input.c_str(), perm);
     cmsys::ifstream fin(this->Input.c_str());
-    if(!fin)
-      {
+    if (!fin) {
       std::ostringstream e;
       e << "Evaluation file \"" << this->Input << "\" cannot be read.";
       lg->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
+    }
 
     std::string line;
     std::string sep;
-    while(cmSystemTools::GetLineFromStream(fin, line))
-      {
+    while (cmSystemTools::GetLineFromStream(fin, line)) {
       inputContent += sep + line;
       sep = "\n";
-      }
-    inputContent += sep;
     }
+    inputContent += sep;
+  }
 
   cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
   cmGeneratorExpression contentGE(lfbt);
-  cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression
-                                              = contentGE.Parse(inputContent);
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression =
+    contentGE.Parse(inputContent);
 
   std::map<std::string, std::string> outputFiles;
 
   std::vector<std::string> allConfigs;
   lg->GetMakefile()->GetConfigurations(allConfigs);
 
-  if (allConfigs.empty())
-    {
+  if (allConfigs.empty()) {
     allConfigs.push_back("");
-    }
+  }
 
   std::vector<std::string> enabledLanguages;
-  cmGlobalGenerator *gg = lg->GetGlobalGenerator();
+  cmGlobalGenerator* gg = lg->GetGlobalGenerator();
   gg->GetEnabledLanguages(enabledLanguages);
 
-  for(std::vector<std::string>::const_iterator le = enabledLanguages.begin();
-      le != enabledLanguages.end(); ++le)
-    {
-    for(std::vector<std::string>::const_iterator li = allConfigs.begin();
-        li != allConfigs.end(); ++li)
-      {
+  for (std::vector<std::string>::const_iterator le = enabledLanguages.begin();
+       le != enabledLanguages.end(); ++le) {
+    for (std::vector<std::string>::const_iterator li = allConfigs.begin();
+         li != allConfigs.end(); ++li) {
       this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm);
-      if(cmSystemTools::GetFatalErrorOccured())
-        {
+      if (cmSystemTools::GetFatalErrorOccured()) {
         return;
-        }
       }
     }
+  }
 }
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index ad41274..bfd6add 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -12,22 +12,21 @@
 #ifndef cmGeneratorExpressionEvaluationFile_h
 #define cmGeneratorExpressionEvaluationFile_h
 
-#include "cmStandardIncludes.h"
-#include <sys/types.h>
-#include <cmsys/auto_ptr.hxx>
-
 #include "cmGeneratorExpression.h"
 
+#include <cmsys/auto_ptr.hxx>
+#include <sys/types.h>
+
 class cmLocalGenerator;
 
-//----------------------------------------------------------------------------
 class cmGeneratorExpressionEvaluationFile
 {
 public:
-  cmGeneratorExpressionEvaluationFile(const std::string &input,
-        cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr,
-        cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
-        bool inputIsContent);
+  cmGeneratorExpressionEvaluationFile(
+    const std::string& input,
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+    bool inputIsContent);
 
   void Generate(cmLocalGenerator* lg);
 
@@ -39,7 +38,7 @@ private:
   void Generate(cmLocalGenerator* lg, const std::string& config,
                 const std::string& lang,
                 cmCompiledGeneratorExpression* inputExpression,
-                std::map<std::string, std::string> &outputFiles, mode_t perm);
+                std::map<std::string, std::string>& outputFiles, mode_t perm);
 
 private:
   const std::string Input;
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index af94bcc..66437eb 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -9,16 +9,16 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include "cmMakefile.h"
-
 #include "cmGeneratorExpressionEvaluator.h"
-#include "cmGeneratorExpressionParser.h"
-#include "cmGeneratorExpressionDAGChecker.h"
+
+#include "cmAlgorithms.h"
 #include "cmGeneratorExpression.h"
-#include "cmLocalGenerator.h"
+#include "cmGeneratorExpressionDAGChecker.h"
+#include "cmGeneratorExpressionParser.h"
 #include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
 #include "cmSourceFile.h"
-#include "cmAlgorithms.h"
 
 #include <cmsys/String.h>
 
@@ -27,224 +27,182 @@
 
 #include "cmGeneratorExpressionNode.h"
 
-//----------------------------------------------------------------------------
 GeneratorExpressionContent::GeneratorExpressionContent(
-                                                    const char *startContent,
-                                                    size_t length)
-  : StartContent(startContent), ContentLength(length)
+  const char* startContent, size_t length)
+  : StartContent(startContent)
+  , ContentLength(length)
 {
-
 }
 
-//----------------------------------------------------------------------------
 std::string GeneratorExpressionContent::GetOriginalExpression() const
 {
   return std::string(this->StartContent, this->ContentLength);
 }
 
-//----------------------------------------------------------------------------
 std::string GeneratorExpressionContent::ProcessArbitraryContent(
-    const cmGeneratorExpressionNode *node,
-    const std::string &identifier,
-    cmGeneratorExpressionContext *context,
-    cmGeneratorExpressionDAGChecker *dagChecker,
-    std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
+  const cmGeneratorExpressionNode* node, const std::string& identifier,
+  cmGeneratorExpressionContext* context,
+  cmGeneratorExpressionDAGChecker* dagChecker,
+  std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
     pit) const
 {
   std::string result;
 
-  const
-  std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
-                                      pend = this->ParamChildren.end();
-  for ( ; pit != pend; ++pit)
-    {
-    std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
-                                                            = pit->begin();
-    const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
-                                                              = pit->end();
-    for ( ; it != end; ++it)
-      {
-      if (node->RequiresLiteralInput())
-        {
-        if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
-          {
-          reportError(context, this->GetOriginalExpression(),
-                "$<" + identifier + "> expression requires literal input.");
+  const std::vector<
+    std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator pend =
+    this->ParamChildren.end();
+  for (; pit != pend; ++pit) {
+    std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+      pit->begin();
+    const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
+      pit->end();
+    for (; it != end; ++it) {
+      if (node->RequiresLiteralInput()) {
+        if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text) {
+          reportError(context, this->GetOriginalExpression(), "$<" +
+                        identifier + "> expression requires literal input.");
           return std::string();
-          }
         }
+      }
       result += (*it)->Evaluate(context, dagChecker);
-      if (context->HadError)
-        {
+      if (context->HadError) {
         return std::string();
-        }
       }
-      if ((pit + 1) != pend)
-        {
-        result += ",";
-        }
     }
-  if (node->RequiresLiteralInput())
-    {
+    if ((pit + 1) != pend) {
+      result += ",";
+    }
+  }
+  if (node->RequiresLiteralInput()) {
     std::vector<std::string> parameters;
     parameters.push_back(result);
     return node->Evaluate(parameters, context, this, dagChecker);
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 std::string GeneratorExpressionContent::Evaluate(
-                            cmGeneratorExpressionContext *context,
-                            cmGeneratorExpressionDAGChecker *dagChecker) const
+  cmGeneratorExpressionContext* context,
+  cmGeneratorExpressionDAGChecker* dagChecker) const
 {
   std::string identifier;
   {
-  std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
-                                          = this->IdentifierChildren.begin();
-  const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
-                                          = this->IdentifierChildren.end();
-  for ( ; it != end; ++it)
-    {
-    identifier += (*it)->Evaluate(context, dagChecker);
-    if (context->HadError)
-      {
-      return std::string();
+    std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+      this->IdentifierChildren.begin();
+    const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
+      this->IdentifierChildren.end();
+    for (; it != end; ++it) {
+      identifier += (*it)->Evaluate(context, dagChecker);
+      if (context->HadError) {
+        return std::string();
       }
     }
   }
 
-  const cmGeneratorExpressionNode *node =
-      cmGeneratorExpressionNode::GetNode(identifier);
+  const cmGeneratorExpressionNode* node =
+    cmGeneratorExpressionNode::GetNode(identifier);
 
-  if (!node)
-    {
+  if (!node) {
     reportError(context, this->GetOriginalExpression(),
-              "Expression did not evaluate to a known generator expression");
+                "Expression did not evaluate to a known generator expression");
     return std::string();
-    }
+  }
 
-  if (!node->GeneratesContent())
-    {
-    if (node->NumExpectedParameters() == 1
-        && node->AcceptsArbitraryContentParameter())
-      {
-      if (this->ParamChildren.empty())
-        {
+  if (!node->GeneratesContent()) {
+    if (node->NumExpectedParameters() == 1 &&
+        node->AcceptsArbitraryContentParameter()) {
+      if (this->ParamChildren.empty()) {
         reportError(context, this->GetOriginalExpression(),
-                  "$<" + identifier + "> expression requires a parameter.");
-        }
+                    "$<" + identifier + "> expression requires a parameter.");
       }
-    else
-      {
+    } else {
       std::vector<std::string> parameters;
       this->EvaluateParameters(node, identifier, context, dagChecker,
                                parameters);
-      }
-    return std::string();
     }
+    return std::string();
+  }
 
   std::vector<std::string> parameters;
   this->EvaluateParameters(node, identifier, context, dagChecker, parameters);
-  if (context->HadError)
-    {
+  if (context->HadError) {
     return std::string();
-    }
+  }
 
   return node->Evaluate(parameters, context, this, dagChecker);
 }
 
-//----------------------------------------------------------------------------
 std::string GeneratorExpressionContent::EvaluateParameters(
-                                const cmGeneratorExpressionNode *node,
-                                const std::string &identifier,
-                                cmGeneratorExpressionContext *context,
-                                cmGeneratorExpressionDAGChecker *dagChecker,
-                                std::vector<std::string> &parameters) const
+  const cmGeneratorExpressionNode* node, const std::string& identifier,
+  cmGeneratorExpressionContext* context,
+  cmGeneratorExpressionDAGChecker* dagChecker,
+  std::vector<std::string>& parameters) const
 {
   const int numExpected = node->NumExpectedParameters();
   {
-  std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
-                                        pit = this->ParamChildren.begin();
-  const
-  std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
-                                        pend = this->ParamChildren.end();
-  const bool acceptsArbitraryContent
-                                  = node->AcceptsArbitraryContentParameter();
-  int counter = 1;
-  for ( ; pit != pend; ++pit, ++counter)
-    {
-    if (acceptsArbitraryContent && counter == numExpected)
-      {
-      std::string lastParam = this->ProcessArbitraryContent(node, identifier,
-                                                            context,
-                                                            dagChecker,
-                                                            pit);
-      parameters.push_back(lastParam);
-      return std::string();
-      }
-    else
-      {
-      std::string parameter;
-      std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
-                                                                pit->begin();
-      const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
-                                                                pit->end();
-      for ( ; it != end; ++it)
-        {
-        parameter += (*it)->Evaluate(context, dagChecker);
-        if (context->HadError)
-          {
-          return std::string();
+    std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
+      pit = this->ParamChildren.begin();
+    const std::vector<
+      std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator pend =
+      this->ParamChildren.end();
+    const bool acceptsArbitraryContent =
+      node->AcceptsArbitraryContentParameter();
+    int counter = 1;
+    for (; pit != pend; ++pit, ++counter) {
+      if (acceptsArbitraryContent && counter == numExpected) {
+        std::string lastParam = this->ProcessArbitraryContent(
+          node, identifier, context, dagChecker, pit);
+        parameters.push_back(lastParam);
+        return std::string();
+      } else {
+        std::string parameter;
+        std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+          pit->begin();
+        const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator
+          end = pit->end();
+        for (; it != end; ++it) {
+          parameter += (*it)->Evaluate(context, dagChecker);
+          if (context->HadError) {
+            return std::string();
           }
         }
-      parameters.push_back(parameter);
+        parameters.push_back(parameter);
       }
     }
   }
 
-  if ((numExpected > cmGeneratorExpressionNode::DynamicParameters
-      && (unsigned int)numExpected != parameters.size()))
-    {
-    if (numExpected == 0)
-      {
+  if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
+       (unsigned int)numExpected != parameters.size())) {
+    if (numExpected == 0) {
       reportError(context, this->GetOriginalExpression(),
                   "$<" + identifier + "> expression requires no parameters.");
-      }
-    else if (numExpected == 1)
-      {
-      reportError(context, this->GetOriginalExpression(),
-                  "$<" + identifier + "> expression requires "
-                  "exactly one parameter.");
-      }
-    else
-      {
+    } else if (numExpected == 1) {
+      reportError(context, this->GetOriginalExpression(), "$<" + identifier +
+                    "> expression requires "
+                    "exactly one parameter.");
+    } else {
       std::ostringstream e;
-      e << "$<" + identifier + "> expression requires "
-        << numExpected
-        << " comma separated parameters, but got "
-        << parameters.size() << " instead.";
+      e << "$<" + identifier + "> expression requires " << numExpected
+        << " comma separated parameters, but got " << parameters.size()
+        << " instead.";
       reportError(context, this->GetOriginalExpression(), e.str());
-      }
-    return std::string();
     }
+    return std::string();
+  }
 
-  if (numExpected == cmGeneratorExpressionNode::OneOrMoreParameters
-      && parameters.empty())
-    {
-    reportError(context, this->GetOriginalExpression(), "$<" + identifier
-                      + "> expression requires at least one parameter.");
-    }
-  if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters
-      && parameters.size() > 1)
-    {
-    reportError(context, this->GetOriginalExpression(), "$<" + identifier
-                      + "> expression requires one or zero parameters.");
-    }
+  if (numExpected == cmGeneratorExpressionNode::OneOrMoreParameters &&
+      parameters.empty()) {
+    reportError(context, this->GetOriginalExpression(), "$<" + identifier +
+                  "> expression requires at least one parameter.");
+  }
+  if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters &&
+      parameters.size() > 1) {
+    reportError(context, this->GetOriginalExpression(), "$<" + identifier +
+                  "> expression requires one or zero parameters.");
+  }
   return std::string();
 }
 
-//----------------------------------------------------------------------------
 GeneratorExpressionContent::~GeneratorExpressionContent()
 {
   cmDeleteAll(this->IdentifierChildren);
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 407f83f..7ca62c5 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -12,16 +12,16 @@
 #ifndef cmGeneratorExpressionEvaluator_h
 #define cmGeneratorExpressionEvaluator_h
 
-#include "cmListFileCache.h"
 #include "cmGeneratorExpressionContext.h"
 
-#include <vector>
+#include "cmListFileCache.h"
+
 #include <string>
+#include <vector>
 
 struct cmGeneratorExpressionDAGChecker;
 struct cmGeneratorExpressionNode;
 
-//----------------------------------------------------------------------------
 struct cmGeneratorExpressionEvaluator
 {
   cmGeneratorExpressionEvaluator() {}
@@ -35,94 +35,80 @@ struct cmGeneratorExpressionEvaluator
 
   virtual Type GetType() const = 0;
 
-  virtual std::string Evaluate(cmGeneratorExpressionContext *context,
-                              cmGeneratorExpressionDAGChecker *) const = 0;
+  virtual std::string Evaluate(cmGeneratorExpressionContext* context,
+                               cmGeneratorExpressionDAGChecker*) const = 0;
 
 private:
-  cmGeneratorExpressionEvaluator(const cmGeneratorExpressionEvaluator &);
-  void operator=(const cmGeneratorExpressionEvaluator &);
+  cmGeneratorExpressionEvaluator(const cmGeneratorExpressionEvaluator&);
+  void operator=(const cmGeneratorExpressionEvaluator&);
 };
 
 struct TextContent : public cmGeneratorExpressionEvaluator
 {
-  TextContent(const char *start, size_t length)
-    : Content(start), Length(length)
+  TextContent(const char* start, size_t length)
+    : Content(start)
+    , Length(length)
   {
-
   }
 
-  std::string Evaluate(cmGeneratorExpressionContext *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(cmGeneratorExpressionContext*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return std::string(this->Content, this->Length);
   }
 
-  Type GetType() const
-  {
-    return cmGeneratorExpressionEvaluator::Text;
-  }
+  Type GetType() const { return cmGeneratorExpressionEvaluator::Text; }
 
-  void Extend(size_t length)
-  {
-    this->Length += length;
-  }
+  void Extend(size_t length) { this->Length += length; }
 
-  size_t GetLength()
-  {
-    return this->Length;
-  }
+  size_t GetLength() { return this->Length; }
 
 private:
-  const char *Content;
+  const char* Content;
   size_t Length;
 };
 
-//----------------------------------------------------------------------------
 struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
 {
-  GeneratorExpressionContent(const char *startContent, size_t length);
+  GeneratorExpressionContent(const char* startContent, size_t length);
   void SetIdentifier(std::vector<cmGeneratorExpressionEvaluator*> identifier)
   {
     this->IdentifierChildren = identifier;
   }
 
   void SetParameters(
-        std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters)
+    std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters)
   {
     this->ParamChildren = parameters;
   }
 
-  Type GetType() const
-  {
-    return cmGeneratorExpressionEvaluator::Generator;
-  }
+  Type GetType() const { return cmGeneratorExpressionEvaluator::Generator; }
 
-  std::string Evaluate(cmGeneratorExpressionContext *context,
-                       cmGeneratorExpressionDAGChecker *) const;
+  std::string Evaluate(cmGeneratorExpressionContext* context,
+                       cmGeneratorExpressionDAGChecker*) const;
 
   std::string GetOriginalExpression() const;
 
   ~GeneratorExpressionContent();
 
 private:
-  std::string EvaluateParameters(const cmGeneratorExpressionNode *node,
-                                 const std::string &identifier,
-                                 cmGeneratorExpressionContext *context,
-                                 cmGeneratorExpressionDAGChecker *dagChecker,
-                                 std::vector<std::string> &parameters) const;
+  std::string EvaluateParameters(const cmGeneratorExpressionNode* node,
+                                 const std::string& identifier,
+                                 cmGeneratorExpressionContext* context,
+                                 cmGeneratorExpressionDAGChecker* dagChecker,
+                                 std::vector<std::string>& parameters) const;
 
   std::string ProcessArbitraryContent(
-    const cmGeneratorExpressionNode *node,
-    const std::string &identifier,
-    cmGeneratorExpressionContext *context,
-    cmGeneratorExpressionDAGChecker *dagChecker,
+    const cmGeneratorExpressionNode* node, const std::string& identifier,
+    cmGeneratorExpressionContext* context,
+    cmGeneratorExpressionDAGChecker* dagChecker,
     std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
-    pit) const;
+      pit) const;
 
 private:
   std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren;
   std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren;
-  const char *StartContent;
+  const char* StartContent;
   size_t ContentLength;
 };
 
diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx
index 1c83466..5a4eccc 100644
--- a/Source/cmGeneratorExpressionLexer.cxx
+++ b/Source/cmGeneratorExpressionLexer.cxx
@@ -11,71 +11,63 @@
 ============================================================================*/
 #include "cmGeneratorExpressionLexer.h"
 
-
-//----------------------------------------------------------------------------
 cmGeneratorExpressionLexer::cmGeneratorExpressionLexer()
-  : SawBeginExpression(false), SawGeneratorExpression(false)
+  : SawBeginExpression(false)
+  , SawGeneratorExpression(false)
 {
-
 }
 
-//----------------------------------------------------------------------------
-static void InsertText(const char *upto, const char *c,
-                        std::vector<cmGeneratorExpressionToken> &result)
+static void InsertText(const char* upto, const char* c,
+                       std::vector<cmGeneratorExpressionToken>& result)
 {
-  if (upto != c)
-    {
+  if (upto != c) {
     result.push_back(cmGeneratorExpressionToken(
-                          cmGeneratorExpressionToken::Text, upto, c - upto));
-    }
+      cmGeneratorExpressionToken::Text, upto, c - upto));
+  }
 }
 
-//----------------------------------------------------------------------------
-std::vector<cmGeneratorExpressionToken>
-cmGeneratorExpressionLexer::Tokenize(const std::string& input)
+std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize(
+  const std::string& input)
 {
   std::vector<cmGeneratorExpressionToken> result;
 
-  const char *c = input.c_str();
-  const char *upto = c;
+  const char* c = input.c_str();
+  const char* upto = c;
 
-  for ( ; *c; ++c)
-    {
-    switch(*c)
-      {
+  for (; *c; ++c) {
+    switch (*c) {
       case '$':
-        if(c[1] == '<')
-          {
+        if (c[1] == '<') {
           InsertText(upto, c, result);
           result.push_back(cmGeneratorExpressionToken(
-                           cmGeneratorExpressionToken::BeginExpression, c, 2));
+            cmGeneratorExpressionToken::BeginExpression, c, 2));
           upto = c + 2;
           ++c;
           SawBeginExpression = true;
-          }
+        }
         break;
       case '>':
         InsertText(upto, c, result);
         result.push_back(cmGeneratorExpressionToken(
-                            cmGeneratorExpressionToken::EndExpression, c, 1));
+          cmGeneratorExpressionToken::EndExpression, c, 1));
         upto = c + 1;
         SawGeneratorExpression = SawBeginExpression;
         break;
       case ':':
         InsertText(upto, c, result);
         result.push_back(cmGeneratorExpressionToken(
-                            cmGeneratorExpressionToken::ColonSeparator, c, 1));
+          cmGeneratorExpressionToken::ColonSeparator, c, 1));
         upto = c + 1;
         break;
       case ',':
         InsertText(upto, c, result);
         result.push_back(cmGeneratorExpressionToken(
-                            cmGeneratorExpressionToken::CommaSeparator, c, 1));
+          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 1e2e8c2..72ad731 100644
--- a/Source/cmGeneratorExpressionLexer.h
+++ b/Source/cmGeneratorExpressionLexer.h
@@ -16,14 +16,16 @@
 
 #include <vector>
 
-//----------------------------------------------------------------------------
 struct cmGeneratorExpressionToken
 {
-  cmGeneratorExpressionToken(unsigned type, const char *c, size_t l)
-    : TokenType(type), Content(c), Length(l)
+  cmGeneratorExpressionToken(unsigned type, const char* c, size_t l)
+    : TokenType(type)
+    , Content(c)
+    , Length(l)
   {
   }
-  enum {
+  enum
+  {
     Text,
     BeginExpression,
     EndExpression,
@@ -31,7 +33,7 @@ struct cmGeneratorExpressionToken
     CommaSeparator
   };
   unsigned TokenType;
-  const char *Content;
+  const char* Content;
   size_t Length;
 };
 
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 32b2f82..e750551 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -11,41 +11,33 @@
 ============================================================================*/
 
 #include "cmGeneratorExpressionNode.h"
-#include "cmGlobalGenerator.h"
+
 #include "cmAlgorithms.h"
-#include "cmOutputConverter.h"
+#include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
+#include "cmOutputConverter.h"
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
-    std::string const& prop, cmLocalGenerator *lg,
-    cmGeneratorExpressionContext *context,
-    cmGeneratorTarget const* headTarget,
-    cmGeneratorTarget const* currentTarget,
-    cmGeneratorExpressionDAGChecker *dagChecker)
+  std::string const& prop, cmLocalGenerator* lg,
+  cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
+  cmGeneratorTarget const* currentTarget,
+  cmGeneratorExpressionDAGChecker* dagChecker)
 {
   cmGeneratorExpression ge(context->Backtrace);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
   cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
-  std::string result = cge->Evaluate(lg,
-                        context->Config,
-                        context->Quiet,
-                        headTarget,
-                        currentTarget,
-                        dagChecker,
-                        context->Language);
-  if (cge->GetHadContextSensitiveCondition())
-    {
+  std::string result =
+    cge->Evaluate(lg, context->Config, context->Quiet, headTarget,
+                  currentTarget, dagChecker, context->Language);
+  if (cge->GetHadContextSensitiveCondition()) {
     context->HadContextSensitiveCondition = true;
-    }
-  if (cge->GetHadHeadSensitiveCondition())
-    {
+  }
+  if (cge->GetHadHeadSensitiveCondition()) {
     context->HadHeadSensitiveCondition = true;
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 static const struct ZeroNode : public cmGeneratorExpressionNode
 {
   ZeroNode() {}
@@ -54,680 +46,625 @@ static const struct ZeroNode : public cmGeneratorExpressionNode
 
   virtual bool AcceptsArbitraryContentParameter() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>&,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return std::string();
   }
 } zeroNode;
 
-//----------------------------------------------------------------------------
 static const struct OneNode : public cmGeneratorExpressionNode
 {
   OneNode() {}
 
   virtual bool AcceptsArbitraryContentParameter() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return parameters.front();
   }
 } oneNode;
 
-//----------------------------------------------------------------------------
 static const struct OneNode buildInterfaceNode;
 
-//----------------------------------------------------------------------------
 static const struct ZeroNode installInterfaceNode;
 
-//----------------------------------------------------------------------------
-#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
-static const struct OP ## Node : public cmGeneratorExpressionNode \
-{ \
-  OP ## Node () {} \
-  virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
- \
-  std::string Evaluate(const std::vector<std::string> &parameters, \
-                       cmGeneratorExpressionContext *context, \
-                       const GeneratorExpressionContent *content, \
-                       cmGeneratorExpressionDAGChecker *) const \
-  { \
-    std::vector<std::string>::const_iterator it = parameters.begin(); \
-    const std::vector<std::string>::const_iterator end = parameters.end(); \
-    for ( ; it != end; ++it) \
-      { \
-      if (*it == #FAILURE_VALUE) \
-        { \
-        return #FAILURE_VALUE; \
-        } \
-      else if (*it != #SUCCESS_VALUE) \
-        { \
-        reportError(context, content->GetOriginalExpression(), \
-        "Parameters to $<" #OP "> must resolve to either '0' or '1'."); \
-        return std::string(); \
-        } \
-      } \
-    return #SUCCESS_VALUE; \
-  } \
-} OPNAME;
+#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE)             \
+  static const struct OP##Node : public cmGeneratorExpressionNode             \
+  {                                                                           \
+    OP##Node() {}                                                             \
+    virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
+                                                                              \
+    std::string Evaluate(const std::vector<std::string>& parameters,          \
+                         cmGeneratorExpressionContext* context,               \
+                         const GeneratorExpressionContent* content,           \
+                         cmGeneratorExpressionDAGChecker*) const              \
+    {                                                                         \
+      std::vector<std::string>::const_iterator it = parameters.begin();       \
+      const std::vector<std::string>::const_iterator end = parameters.end();  \
+      for (; it != end; ++it) {                                               \
+        if (*it == #FAILURE_VALUE) {                                          \
+          return #FAILURE_VALUE;                                              \
+        } else if (*it != #SUCCESS_VALUE) {                                   \
+          reportError(context, content->GetOriginalExpression(),              \
+                      "Parameters to $<" #OP                                  \
+                      "> must resolve to either '0' or '1'.");                \
+          return std::string();                                               \
+        }                                                                     \
+      }                                                                       \
+      return #SUCCESS_VALUE;                                                  \
+    }                                                                         \
+  } OPNAME;
 
 BOOLEAN_OP_NODE(andNode, AND, 1, 0)
 BOOLEAN_OP_NODE(orNode, OR, 0, 1)
 
 #undef BOOLEAN_OP_NODE
 
-//----------------------------------------------------------------------------
 static const struct NotNode : public cmGeneratorExpressionNode
 {
   NotNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    if (*parameters.begin() != "0" && *parameters.begin() != "1")
-      {
-      reportError(context, content->GetOriginalExpression(),
-            "$<NOT> parameter must resolve to exactly one '0' or '1' value.");
+    if (*parameters.begin() != "0" && *parameters.begin() != "1") {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<NOT> parameter must resolve to exactly one '0' or '1' value.");
       return std::string();
-      }
+    }
     return *parameters.begin() == "0" ? "1" : "0";
   }
 } notNode;
 
-//----------------------------------------------------------------------------
 static const struct BoolNode : public cmGeneratorExpressionNode
 {
   BoolNode() {}
 
   virtual int NumExpectedParameters() const { return 1; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return !cmSystemTools::IsOff(parameters.begin()->c_str()) ? "1" : "0";
   }
 } boolNode;
 
-//----------------------------------------------------------------------------
 static const struct StrEqualNode : public cmGeneratorExpressionNode
 {
   StrEqualNode() {}
 
   virtual int NumExpectedParameters() const { return 2; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return *parameters.begin() == parameters[1] ? "1" : "0";
   }
 } strEqualNode;
 
-//----------------------------------------------------------------------------
 static const struct EqualNode : public cmGeneratorExpressionNode
 {
   EqualNode() {}
 
   virtual int NumExpectedParameters() const { return 2; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    char *pEnd;
+    char* pEnd;
 
     int base = 0;
     bool flipSign = false;
 
-    const char *lhs = parameters[0].c_str();
-    if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B"))
-      {
+    const char* lhs = parameters[0].c_str();
+    if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B")) {
       base = 2;
       lhs += 2;
-      }
-    if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B"))
-      {
+    }
+    if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B")) {
       base = 2;
       lhs += 3;
       flipSign = true;
-      }
-    if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B"))
-      {
+    }
+    if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B")) {
       base = 2;
       lhs += 3;
-      }
+    }
 
     long lnum = strtol(lhs, &pEnd, base);
-    if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
-      {
+    if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
       reportError(context, content->GetOriginalExpression(),
-          "$<EQUAL> parameter " + parameters[0] + " is not a valid integer.");
+                  "$<EQUAL> parameter " + parameters[0] +
+                    " is not a valid integer.");
       return std::string();
-      }
+    }
 
-    if (flipSign)
-      {
+    if (flipSign) {
       lnum = -lnum;
-      }
+    }
 
     base = 0;
     flipSign = false;
 
-    const char *rhs = parameters[1].c_str();
-    if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B"))
-      {
+    const char* rhs = parameters[1].c_str();
+    if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B")) {
       base = 2;
       rhs += 2;
-      }
-    if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B"))
-      {
+    }
+    if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B")) {
       base = 2;
       rhs += 3;
       flipSign = true;
-      }
-    if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B"))
-      {
+    }
+    if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B")) {
       base = 2;
       rhs += 3;
-      }
+    }
 
     long rnum = strtol(rhs, &pEnd, base);
-    if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
-      {
+    if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
       reportError(context, content->GetOriginalExpression(),
-          "$<EQUAL> parameter " + parameters[1] + " is not a valid integer.");
+                  "$<EQUAL> parameter " + parameters[1] +
+                    " is not a valid integer.");
       return std::string();
-      }
+    }
 
-    if (flipSign)
-      {
+    if (flipSign) {
       rnum = -rnum;
-      }
+    }
 
     return lnum == rnum ? "1" : "0";
   }
 } equalNode;
 
-//----------------------------------------------------------------------------
 static const struct LowerCaseNode : public cmGeneratorExpressionNode
 {
   LowerCaseNode() {}
 
   bool AcceptsArbitraryContentParameter() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return cmSystemTools::LowerCase(parameters.front());
   }
 } lowerCaseNode;
 
-//----------------------------------------------------------------------------
 static const struct UpperCaseNode : public cmGeneratorExpressionNode
 {
   UpperCaseNode() {}
 
   bool AcceptsArbitraryContentParameter() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return cmSystemTools::UpperCase(parameters.front());
   }
 } upperCaseNode;
 
-//----------------------------------------------------------------------------
 static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
 {
   MakeCIdentifierNode() {}
 
   bool AcceptsArbitraryContentParameter() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return cmSystemTools::MakeCidentifier(parameters.front());
   }
 } makeCIdentifierNode;
 
-//----------------------------------------------------------------------------
 static const struct Angle_RNode : public cmGeneratorExpressionNode
 {
   Angle_RNode() {}
 
   virtual int NumExpectedParameters() const { return 0; }
 
-  std::string Evaluate(const std::vector<std::string> &,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>&,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return ">";
   }
 } angle_rNode;
 
-//----------------------------------------------------------------------------
 static const struct CommaNode : public cmGeneratorExpressionNode
 {
   CommaNode() {}
 
   virtual int NumExpectedParameters() const { return 0; }
 
-  std::string Evaluate(const std::vector<std::string> &,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>&,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return ",";
   }
 } commaNode;
 
-//----------------------------------------------------------------------------
 static const struct SemicolonNode : public cmGeneratorExpressionNode
 {
   SemicolonNode() {}
 
   virtual int NumExpectedParameters() const { return 0; }
 
-  std::string Evaluate(const std::vector<std::string> &,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>&,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return ";";
   }
 } semicolonNode;
 
-//----------------------------------------------------------------------------
 struct CompilerIdNode : public cmGeneratorExpressionNode
 {
   CompilerIdNode() {}
 
   virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
 
-  std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *,
-                       const std::string &lang) const
+  std::string EvaluateWithLanguage(const std::vector<std::string>& parameters,
+                                   cmGeneratorExpressionContext* context,
+                                   const GeneratorExpressionContent* content,
+                                   cmGeneratorExpressionDAGChecker*,
+                                   const std::string& lang) const
   {
-    const char *compilerId =
-      context->LG->GetMakefile()
-        ->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID");
-    if (parameters.empty())
-      {
+    const char* compilerId = context->LG->GetMakefile()->GetSafeDefinition(
+      "CMAKE_" + lang + "_COMPILER_ID");
+    if (parameters.empty()) {
       return compilerId ? compilerId : "";
-      }
+    }
     static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
-    if (!compilerIdValidator.find(*parameters.begin()))
-      {
+    if (!compilerIdValidator.find(*parameters.begin())) {
       reportError(context, content->GetOriginalExpression(),
                   "Expression syntax not recognized.");
       return std::string();
-      }
-    if (!compilerId)
-      {
+    }
+    if (!compilerId) {
       return parameters.front().empty() ? "1" : "0";
-      }
+    }
 
-    if (strcmp(parameters.begin()->c_str(), compilerId) == 0)
-      {
+    if (strcmp(parameters.begin()->c_str(), compilerId) == 0) {
       return "1";
-      }
+    }
 
-    if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
-      {
-      switch(context->LG->GetPolicyStatus(cmPolicies::CMP0044))
-        {
-        case cmPolicies::WARN:
-          {
+    if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) {
+      switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
+        case cmPolicies::WARN: {
           std::ostringstream e;
           e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0044);
-          context->LG->GetCMakeInstance()
-                 ->IssueMessage(cmake::AUTHOR_WARNING,
-                                e.str(), context->Backtrace);
-          }
+          context->LG->GetCMakeInstance()->IssueMessage(
+            cmake::AUTHOR_WARNING, e.str(), context->Backtrace);
+        }
         case cmPolicies::OLD:
           return "1";
         case cmPolicies::NEW:
         case cmPolicies::REQUIRED_ALWAYS:
         case cmPolicies::REQUIRED_IF_USED:
           break;
-        }
       }
+    }
     return "0";
   }
 };
 
-//----------------------------------------------------------------------------
 static const struct CCompilerIdNode : public CompilerIdNode
 {
   CCompilerIdNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
-    if (!context->HeadTarget)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<C_COMPILER_ID> may only be used with binary targets.  It may "
-          "not be used with add_custom_command or add_custom_target.");
+    if (!context->HeadTarget) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<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,
-                                      dagChecker, "C");
+    }
+    return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+                                      "C");
   }
 } cCompilerIdNode;
 
-//----------------------------------------------------------------------------
 static const struct CXXCompilerIdNode : public CompilerIdNode
 {
   CXXCompilerIdNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
-    if (!context->HeadTarget)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<CXX_COMPILER_ID> may only be used with binary targets.  It may "
-          "not be used with add_custom_command or add_custom_target.");
+    if (!context->HeadTarget) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<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,
-                                      dagChecker, "CXX");
+    }
+    return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+                                      "CXX");
   }
 } cxxCompilerIdNode;
 
-//----------------------------------------------------------------------------
 struct CompilerVersionNode : public cmGeneratorExpressionNode
 {
   CompilerVersionNode() {}
 
   virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
 
-  std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *,
-                       const std::string &lang) const
+  std::string EvaluateWithLanguage(const std::vector<std::string>& parameters,
+                                   cmGeneratorExpressionContext* context,
+                                   const GeneratorExpressionContent* content,
+                                   cmGeneratorExpressionDAGChecker*,
+                                   const std::string& lang) const
   {
-    const char *compilerVersion =
-        context->LG->GetMakefile()->GetSafeDefinition(
-          "CMAKE_" + lang + "_COMPILER_VERSION");
-    if (parameters.empty())
-      {
+    const char* compilerVersion =
+      context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
+                                                    "_COMPILER_VERSION");
+    if (parameters.empty()) {
       return compilerVersion ? compilerVersion : "";
-      }
+    }
 
     static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
-    if (!compilerIdValidator.find(*parameters.begin()))
-      {
+    if (!compilerIdValidator.find(*parameters.begin())) {
       reportError(context, content->GetOriginalExpression(),
                   "Expression syntax not recognized.");
       return std::string();
-      }
-    if (!compilerVersion)
-      {
+    }
+    if (!compilerVersion) {
       return parameters.front().empty() ? "1" : "0";
-      }
+    }
 
     return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
-                                      parameters.begin()->c_str(),
-                                      compilerVersion) ? "1" : "0";
+                                         parameters.begin()->c_str(),
+                                         compilerVersion)
+      ? "1"
+      : "0";
   }
 };
 
-//----------------------------------------------------------------------------
 static const struct CCompilerVersionNode : public CompilerVersionNode
 {
   CCompilerVersionNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
-    if (!context->HeadTarget)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<C_COMPILER_VERSION> may only be used with binary targets.  It "
-          "may not be used with add_custom_command or add_custom_target.");
+    if (!context->HeadTarget) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<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,
-                                      dagChecker, "C");
+    }
+    return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+                                      "C");
   }
 } cCompilerVersionNode;
 
-//----------------------------------------------------------------------------
 static const struct CxxCompilerVersionNode : public CompilerVersionNode
 {
   CxxCompilerVersionNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
-    if (!context->HeadTarget)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<CXX_COMPILER_VERSION> may only be used with binary targets.  It "
-          "may not be used with add_custom_command or add_custom_target.");
+    if (!context->HeadTarget) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<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,
-                                      dagChecker, "CXX");
+    }
+    return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+                                      "CXX");
   }
 } cxxCompilerVersionNode;
 
-
-//----------------------------------------------------------------------------
 struct PlatformIdNode : public cmGeneratorExpressionNode
 {
   PlatformIdNode() {}
 
   virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    const char *platformId =
+    const char* platformId =
       context->LG->GetMakefile()->GetSafeDefinition("CMAKE_SYSTEM_NAME");
-    if (parameters.empty())
-      {
+    if (parameters.empty()) {
       return platformId ? platformId : "";
-      }
+    }
 
-    if (!platformId)
-      {
+    if (!platformId) {
       return parameters.front().empty() ? "1" : "0";
-      }
+    }
 
-    if (strcmp(parameters.begin()->c_str(), platformId) == 0)
-      {
+    if (strcmp(parameters.begin()->c_str(), platformId) == 0) {
       return "1";
-      }
+    }
     return "0";
   }
 } platformIdNode;
 
-//----------------------------------------------------------------------------
 static const struct VersionGreaterNode : public cmGeneratorExpressionNode
 {
   VersionGreaterNode() {}
 
   virtual int NumExpectedParameters() const { return 2; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
                                          parameters.front().c_str(),
-                                         parameters[1].c_str()) ? "1" : "0";
+                                         parameters[1].c_str())
+      ? "1"
+      : "0";
   }
 } versionGreaterNode;
 
-//----------------------------------------------------------------------------
 static const struct VersionLessNode : public cmGeneratorExpressionNode
 {
   VersionLessNode() {}
 
   virtual int NumExpectedParameters() const { return 2; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
                                          parameters.front().c_str(),
-                                         parameters[1].c_str()) ? "1" : "0";
+                                         parameters[1].c_str())
+      ? "1"
+      : "0";
   }
 } versionLessNode;
 
-//----------------------------------------------------------------------------
 static const struct VersionEqualNode : public cmGeneratorExpressionNode
 {
   VersionEqualNode() {}
 
   virtual int NumExpectedParameters() const { return 2; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
                                          parameters.front().c_str(),
-                                         parameters[1].c_str()) ? "1" : "0";
+                                         parameters[1].c_str())
+      ? "1"
+      : "0";
   }
 } versionEqualNode;
 
-//----------------------------------------------------------------------------
 static const struct LinkOnlyNode : public cmGeneratorExpressionNode
 {
   LinkOnlyNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
-    if(!dagChecker->GetTransitivePropertiesOnly())
-      {
+    if (!dagChecker->GetTransitivePropertiesOnly()) {
       return parameters.front();
-      }
+    }
     return "";
   }
 } linkOnlyNode;
 
-//----------------------------------------------------------------------------
 static const struct ConfigurationNode : public cmGeneratorExpressionNode
 {
   ConfigurationNode() {}
 
   virtual int NumExpectedParameters() const { return 0; }
 
-  std::string Evaluate(const std::vector<std::string> &,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>&,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     context->HadContextSensitiveCondition = true;
     return context->Config;
   }
 } configurationNode;
 
-//----------------------------------------------------------------------------
 static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
 {
   ConfigurationTestNode() {}
 
   virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    if (parameters.empty())
-      {
+    if (parameters.empty()) {
       return configurationNode.Evaluate(parameters, context, content, 0);
-      }
+    }
     static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
-    if (!configValidator.find(*parameters.begin()))
-      {
+    if (!configValidator.find(*parameters.begin())) {
       reportError(context, content->GetOriginalExpression(),
                   "Expression syntax not recognized.");
       return std::string();
-      }
+    }
     context->HadContextSensitiveCondition = true;
-    if (context->Config.empty())
-      {
+    if (context->Config.empty()) {
       return parameters.front().empty() ? "1" : "0";
-      }
+    }
 
     if (cmsysString_strcasecmp(parameters.begin()->c_str(),
-                               context->Config.c_str()) == 0)
-      {
+                               context->Config.c_str()) == 0) {
       return "1";
-      }
+    }
 
-    if (context->CurrentTarget
-        && context->CurrentTarget->IsImported())
-      {
+    if (context->CurrentTarget && context->CurrentTarget->IsImported()) {
       const char* loc = 0;
       const char* imp = 0;
       std::string suffix;
-      if (context->CurrentTarget->Target->GetMappedConfig(context->Config,
-                                                  &loc,
-                                                  &imp,
-                                                  suffix))
-        {
+      if (context->CurrentTarget->Target->GetMappedConfig(
+            context->Config, &loc, &imp, suffix)) {
         // This imported target has an appropriate location
         // for this (possibly mapped) config.
         // Check if there is a proper config mapping for the tested config.
         std::vector<std::string> mappedConfigs;
         std::string mapProp = "MAP_IMPORTED_CONFIG_";
         mapProp += cmSystemTools::UpperCase(context->Config);
-        if(const char* mapValue =
-                        context->CurrentTarget->GetProperty(mapProp))
-          {
+        if (const char* mapValue =
+              context->CurrentTarget->GetProperty(mapProp)) {
           cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
                                             mappedConfigs);
           return std::find(mappedConfigs.begin(), mappedConfigs.end(),
-                           cmSystemTools::UpperCase(parameters.front()))
-              != mappedConfigs.end() ? "1" : "0";
-          }
+                           cmSystemTools::UpperCase(parameters.front())) !=
+              mappedConfigs.end()
+            ? "1"
+            : "0";
         }
       }
+    }
     return "0";
   }
 } configurationTestNode;
@@ -740,10 +677,10 @@ static const struct JoinNode : public cmGeneratorExpressionNode
 
   virtual bool AcceptsArbitraryContentParameter() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     std::vector<std::string> list;
     cmSystemTools::ExpandListArgument(parameters.front(), list);
@@ -757,122 +694,102 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
 
   virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
-    if(context->Language.empty())
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<COMPILE_LANGUAGE:...> may only be used to specify include "
-          "directories compile definitions, compile options and to evaluate "
-          "components of the file(GENERATE) command.");
+    if (context->Language.empty()) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<COMPILE_LANGUAGE:...> may only be used to specify include "
+        "directories compile definitions, compile options and to evaluate "
+        "components of the file(GENERATE) command.");
       return std::string();
-      }
+    }
 
     std::vector<std::string> enabledLanguages;
     cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
     gg->GetEnabledLanguages(enabledLanguages);
     if (!parameters.empty() &&
-          std::find(enabledLanguages.begin(), enabledLanguages.end(),
-                  parameters.front()) == enabledLanguages.end())
-      {
+        std::find(enabledLanguages.begin(), enabledLanguages.end(),
+                  parameters.front()) == enabledLanguages.end()) {
       reportError(context, content->GetOriginalExpression(),
-          "$<COMPILE_LANGUAGE:...> Unknown language.");
+                  "$<COMPILE_LANGUAGE:...> Unknown language.");
       return std::string();
-      }
+    }
     std::string genName = gg->GetName();
-    if (genName.find("Visual Studio") != std::string::npos)
-      {
+    if (genName.find("Visual Studio") != std::string::npos) {
       reportError(context, content->GetOriginalExpression(),
-          "$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
-          "generators.");
+                  "$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
+                  "generators.");
       return std::string();
-      }
-    else if (genName.find("Xcode") != std::string::npos)
-      {
-      if (dagChecker && (dagChecker->EvaluatingCompileDefinitions()
-          || dagChecker->EvaluatingIncludeDirectories()))
-        {
-        reportError(context, content->GetOriginalExpression(),
-            "$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS "
-            "with the Xcode generator.");
+    } else if (genName.find("Xcode") != std::string::npos) {
+      if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
+                         dagChecker->EvaluatingIncludeDirectories())) {
+        reportError(
+          context, content->GetOriginalExpression(),
+          "$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS "
+          "with the Xcode generator.");
         return std::string();
-        }
       }
-    else
-      {
-      if(genName.find("Makefiles") == std::string::npos &&
-              genName.find("Ninja") == std::string::npos &&
-              genName.find("Watcom WMake") == std::string::npos)
-        {
-        reportError(context, content->GetOriginalExpression(),
-            "$<COMPILE_LANGUAGE:...> not supported for this generator.");
+    } else {
+      if (genName.find("Makefiles") == std::string::npos &&
+          genName.find("Ninja") == std::string::npos &&
+          genName.find("Watcom WMake") == std::string::npos) {
+        reportError(
+          context, content->GetOriginalExpression(),
+          "$<COMPILE_LANGUAGE:...> not supported for this generator.");
         return std::string();
-        }
       }
-    if (parameters.empty())
-      {
+    }
+    if (parameters.empty()) {
       return context->Language;
-      }
+    }
     return context->Language == parameters.front() ? "1" : "0";
   }
 } languageNode;
 
-#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
-  , "INTERFACE_" #PROPERTY
+#define TRANSITIVE_PROPERTY_NAME(PROPERTY) , "INTERFACE_" #PROPERTY
 
-//----------------------------------------------------------------------------
 static const char* targetPropertyTransitiveWhitelist[] = {
-  0
-  CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
+  0 CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
 };
 
 #undef TRANSITIVE_PROPERTY_NAME
 
 template <typename T>
-std::string
-getLinkedTargetsContent(
-  std::vector<T> const &libraries,
-  cmGeneratorTarget const* target,
-  cmGeneratorTarget const* headTarget,
-  cmGeneratorExpressionContext *context,
-  cmGeneratorExpressionDAGChecker *dagChecker,
-  const std::string &interfacePropertyName)
+std::string getLinkedTargetsContent(
+  std::vector<T> const& libraries, cmGeneratorTarget const* target,
+  cmGeneratorTarget const* headTarget, cmGeneratorExpressionContext* context,
+  cmGeneratorExpressionDAGChecker* dagChecker,
+  const std::string& interfacePropertyName)
 {
   std::string linkedTargetsContent;
   std::string sep;
   std::string depString;
   for (typename std::vector<T>::const_iterator it = libraries.begin();
-       it != libraries.end(); ++it)
-    {
+       it != libraries.end(); ++it) {
     // 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.
-    if (it->Target && it->Target != target)
-      {
-      depString +=
-        sep + "$<TARGET_PROPERTY:" +
-        it->Target->GetName() + "," + interfacePropertyName + ">";
+    if (it->Target && it->Target != target) {
+      depString += sep + "$<TARGET_PROPERTY:" + it->Target->GetName() + "," +
+        interfacePropertyName + ">";
       sep = ";";
-      }
     }
-  if(!depString.empty())
-    {
+  }
+  if (!depString.empty()) {
     linkedTargetsContent =
-        cmGeneratorExpressionNode::EvaluateDependentExpression(depString,
-                                        target->GetLocalGenerator(),
-                                        context,
-                                        headTarget,
-                                        target, dagChecker);
-    }
+      cmGeneratorExpressionNode::EvaluateDependentExpression(
+        depString, target->GetLocalGenerator(), context, headTarget, target,
+        dagChecker);
+  }
   linkedTargetsContent =
     cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
   return linkedTargetsContent;
 }
 
-//----------------------------------------------------------------------------
 static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 {
   TargetPropertyNode() {}
@@ -880,352 +797,292 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
   // This node handles errors on parameter count itself.
   virtual int NumExpectedParameters() const { return OneOrMoreParameters; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagCheckerParent
-                      ) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagCheckerParent) const
   {
-    if (parameters.size() != 1 && parameters.size() != 2)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<TARGET_PROPERTY:...> expression requires one or two parameters");
+    if (parameters.size() != 1 && parameters.size() != 2) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<TARGET_PROPERTY:...> expression requires one or two parameters");
       return std::string();
-      }
+    }
     static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
 
     cmGeneratorTarget const* target = context->HeadTarget;
     std::string propertyName = *parameters.begin();
 
-    if (parameters.size() == 1)
-      {
+    if (parameters.size() == 1) {
       context->HadHeadSensitiveCondition = true;
-      }
-    if (!target && parameters.size() == 1)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<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.");
+    }
+    if (!target && parameters.size() == 1) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<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();
-      }
+    }
 
-    if (parameters.size() == 2)
-      {
-      if (parameters.begin()->empty() && parameters[1].empty())
-        {
-        reportError(context, content->GetOriginalExpression(),
-            "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
-            "target name and property name.");
+    if (parameters.size() == 2) {
+      if (parameters.begin()->empty() && parameters[1].empty()) {
+        reportError(
+          context, content->GetOriginalExpression(),
+          "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
+          "target name and property name.");
         return std::string();
-        }
-      if (parameters.begin()->empty())
-        {
-        reportError(context, content->GetOriginalExpression(),
-            "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
-            "target name.");
+      }
+      if (parameters.begin()->empty()) {
+        reportError(
+          context, content->GetOriginalExpression(),
+          "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
+          "target name.");
         return std::string();
-        }
+      }
 
       std::string targetName = parameters.front();
       propertyName = parameters[1];
-      if (!cmGeneratorExpression::IsValidTargetName(targetName))
-        {
-        if (!propertyNameValidator.find(propertyName.c_str()))
-          {
+      if (!cmGeneratorExpression::IsValidTargetName(targetName)) {
+        if (!propertyNameValidator.find(propertyName.c_str())) {
           ::reportError(context, content->GetOriginalExpression(),
                         "Target name and property name not supported.");
           return std::string();
-          }
+        }
         ::reportError(context, content->GetOriginalExpression(),
                       "Target name not supported.");
         return std::string();
-        }
-      if(propertyName == "ALIASED_TARGET")
-        {
-        if(context->LG->GetMakefile()->IsAlias(targetName))
-          {
-          if(cmGeneratorTarget* tgt =
-             context->LG->FindGeneratorTargetToUse(targetName))
-            {
+      }
+      if (propertyName == "ALIASED_TARGET") {
+        if (context->LG->GetMakefile()->IsAlias(targetName)) {
+          if (cmGeneratorTarget* tgt =
+                context->LG->FindGeneratorTargetToUse(targetName)) {
             return tgt->GetName();
-            }
           }
-        return "";
         }
+        return "";
+      }
       target = context->LG->FindGeneratorTargetToUse(targetName);
 
-      if (!target)
-        {
+      if (!target) {
         std::ostringstream e;
-        e << "Target \""
-          << targetName
-          << "\" not found.";
+        e << "Target \"" << targetName << "\" not found.";
         reportError(context, content->GetOriginalExpression(), e.str());
         return std::string();
-        }
-      context->AllTargets.insert(target);
       }
+      context->AllTargets.insert(target);
+    }
 
-    if (target == context->HeadTarget)
-      {
+    if (target == context->HeadTarget) {
       // Keep track of the properties seen while processing.
       // The evaluation of the LINK_LIBRARIES generator expressions
       // will check this to ensure that properties have one consistent
       // value for all evaluations.
       context->SeenTargetProperties.insert(propertyName);
-      }
-    if (propertyName == "SOURCES")
-      {
+    }
+    if (propertyName == "SOURCES") {
       context->SourceSensitiveTargets.insert(target);
-      }
+    }
 
-    if (propertyName.empty())
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<TARGET_PROPERTY:...> expression requires a non-empty property "
-          "name.");
+    if (propertyName.empty()) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<TARGET_PROPERTY:...> expression requires a non-empty property "
+        "name.");
       return std::string();
-      }
+    }
 
-    if (!propertyNameValidator.find(propertyName))
-      {
+    if (!propertyNameValidator.find(propertyName)) {
       ::reportError(context, content->GetOriginalExpression(),
                     "Property name not supported.");
       return std::string();
-      }
+    }
 
     assert(target);
 
-    if (propertyName == "LINKER_LANGUAGE")
-      {
-      if (target->LinkLanguagePropagatesToDependents() &&
-          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");
+    if (propertyName == "LINKER_LANGUAGE") {
+      if (target->LinkLanguagePropagatesToDependents() && 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();
-        }
-      return target->GetLinkerLanguage(context->Config);
       }
+      return target->GetLinkerLanguage(context->Config);
+    }
 
     cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
-                                               target->GetName(),
-                                               propertyName,
-                                               content,
-                                               dagCheckerParent);
-
-    switch (dagChecker.Check())
-      {
-    case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
-      dagChecker.ReportError(context, content->GetOriginalExpression());
-      return std::string();
-    case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
-      // No error. We just skip cyclic references.
-      return std::string();
-    case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
-      for (size_t i = 1;
-          i < cmArraySize(targetPropertyTransitiveWhitelist);
-          ++i)
-        {
-        if (targetPropertyTransitiveWhitelist[i] == propertyName)
-          {
-          // No error. We're not going to find anything new here.
-          return std::string();
+                                               target->GetName(), propertyName,
+                                               content, dagCheckerParent);
+
+    switch (dagChecker.Check()) {
+      case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
+        dagChecker.ReportError(context, content->GetOriginalExpression());
+        return std::string();
+      case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
+        // No error. We just skip cyclic references.
+        return std::string();
+      case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
+        for (size_t i = 1; i < cmArraySize(targetPropertyTransitiveWhitelist);
+             ++i) {
+          if (targetPropertyTransitiveWhitelist[i] == propertyName) {
+            // No error. We're not going to find anything new here.
+            return std::string();
           }
         }
-    case cmGeneratorExpressionDAGChecker::DAG:
-      break;
-      }
+      case cmGeneratorExpressionDAGChecker::DAG:
+        break;
+    }
 
-    const char *prop = target->GetProperty(propertyName);
-
-    if (dagCheckerParent)
-      {
-      if (dagCheckerParent->EvaluatingLinkLibraries())
-        {
-#define TRANSITIVE_PROPERTY_COMPARE(PROPERTY) \
-    (#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) ||
-        if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_COMPARE)
-            false)
-          {
-          reportError(context, content->GetOriginalExpression(),
-              "$<TARGET_PROPERTY:...> expression in link libraries "
-              "evaluation depends on target property which is transitive "
-              "over the link libraries, creating a recursion.");
+    const char* prop = target->GetProperty(propertyName);
+
+    if (dagCheckerParent) {
+      if (dagCheckerParent->EvaluatingLinkLibraries()) {
+#define TRANSITIVE_PROPERTY_COMPARE(PROPERTY)                                 \
+  (#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) ||
+        if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(
+              TRANSITIVE_PROPERTY_COMPARE) false) {
+          reportError(
+            context, content->GetOriginalExpression(),
+            "$<TARGET_PROPERTY:...> expression in link libraries "
+            "evaluation depends on target property which is transitive "
+            "over the link libraries, creating a recursion.");
           return std::string();
-          }
+        }
 #undef TRANSITIVE_PROPERTY_COMPARE
 
-        if(!prop)
-          {
+        if (!prop) {
           return std::string();
-          }
         }
-      else
-        {
-#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) \
-  dagCheckerParent->METHOD () ||
-
-        assert(
-          CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
-                                            ASSERT_TRANSITIVE_PROPERTY_METHOD)
-          false);
+      } else {
+#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() ||
+
+        assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
+          ASSERT_TRANSITIVE_PROPERTY_METHOD) false);
 #undef ASSERT_TRANSITIVE_PROPERTY_METHOD
-        }
       }
+    }
 
     std::string linkedTargetsContent;
 
     std::string interfacePropertyName;
     bool isInterfaceProperty = false;
 
-#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
-    if (propertyName == #prop) \
-      { \
-      interfacePropertyName = "INTERFACE_" #prop; \
-      } \
-    else if (propertyName == "INTERFACE_" #prop) \
-      { \
-      interfacePropertyName = "INTERFACE_" #prop; \
-      isInterfaceProperty = true; \
-      } \
-    else
+#define POPULATE_INTERFACE_PROPERTY_NAME(prop)                                \
+  if (propertyName == #prop) {                                                \
+    interfacePropertyName = "INTERFACE_" #prop;                               \
+  } else if (propertyName == "INTERFACE_" #prop) {                            \
+    interfacePropertyName = "INTERFACE_" #prop;                               \
+    isInterfaceProperty = true;                                               \
+  } else
 
     CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
-      // Note that the above macro terminates with an else
+    // Note that the above macro terminates with an else
     /* else */ if (cmHasLiteralPrefix(propertyName.c_str(),
-                           "COMPILE_DEFINITIONS_"))
-      {
+                                      "COMPILE_DEFINITIONS_")) {
       cmPolicies::PolicyStatus polSt =
-          context->LG->GetPolicyStatus(cmPolicies::CMP0043);
-      if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD)
-        {
+        context->LG->GetPolicyStatus(cmPolicies::CMP0043);
+      if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
         interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
-        }
       }
+    }
 #undef POPULATE_INTERFACE_PROPERTY_NAME
     cmGeneratorTarget const* headTarget =
-        context->HeadTarget && isInterfaceProperty
-                               ? context->HeadTarget : target;
-
-    if(isInterfaceProperty)
-      {
-      if(cmLinkInterfaceLibraries const* iface =
-         target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
-        {
+      context->HeadTarget && isInterfaceProperty ? context->HeadTarget
+                                                 : target;
+
+    if (isInterfaceProperty) {
+      if (cmLinkInterfaceLibraries const* iface =
+            target->GetLinkInterfaceLibraries(context->Config, headTarget,
+                                              true)) {
         linkedTargetsContent =
-          getLinkedTargetsContent(iface->Libraries, target,
-                                  headTarget,
-                                  context, &dagChecker,
-                                  interfacePropertyName);
-        }
+          getLinkedTargetsContent(iface->Libraries, target, headTarget,
+                                  context, &dagChecker, interfacePropertyName);
       }
-    else if(!interfacePropertyName.empty())
-      {
-      if(cmLinkImplementationLibraries const* impl =
-         target->GetLinkImplementationLibraries(context->Config))
-        {
+    } else if (!interfacePropertyName.empty()) {
+      if (cmLinkImplementationLibraries const* impl =
+            target->GetLinkImplementationLibraries(context->Config)) {
         linkedTargetsContent =
-          getLinkedTargetsContent(impl->Libraries, target,
-                                  target,
-                                  context, &dagChecker,
-                                  interfacePropertyName);
-        }
+          getLinkedTargetsContent(impl->Libraries, target, target, context,
+                                  &dagChecker, interfacePropertyName);
       }
+    }
 
-    if (!prop)
-      {
-      if (target->IsImported()
-          || target->GetType() == cmState::INTERFACE_LIBRARY)
-        {
+    if (!prop) {
+      if (target->IsImported() ||
+          target->GetType() == cmState::INTERFACE_LIBRARY) {
         return linkedTargetsContent;
-        }
+      }
       if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
-                                                     context->Config))
-        {
+                                                       context->Config)) {
         context->HadContextSensitiveCondition = true;
-        return target->GetLinkInterfaceDependentBoolProperty(
-                                                propertyName,
-                                                context->Config) ? "1" : "0";
-        }
+        return target->GetLinkInterfaceDependentBoolProperty(propertyName,
+                                                             context->Config)
+          ? "1"
+          : "0";
+      }
       if (target->IsLinkInterfaceDependentStringProperty(propertyName,
-                                                       context->Config))
-        {
+                                                         context->Config)) {
         context->HadContextSensitiveCondition = true;
-        const char *propContent =
-                              target->GetLinkInterfaceDependentStringProperty(
-                                                propertyName,
-                                                context->Config);
+        const char* propContent =
+          target->GetLinkInterfaceDependentStringProperty(propertyName,
+                                                          context->Config);
         return propContent ? propContent : "";
-        }
+      }
       if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
-                                                          context->Config))
-        {
+                                                            context->Config)) {
         context->HadContextSensitiveCondition = true;
-        const char *propContent =
-                          target->GetLinkInterfaceDependentNumberMinProperty(
-                                                propertyName,
-                                                context->Config);
+        const char* propContent =
+          target->GetLinkInterfaceDependentNumberMinProperty(propertyName,
+                                                             context->Config);
         return propContent ? propContent : "";
-        }
+      }
       if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
-                                                          context->Config))
-        {
+                                                            context->Config)) {
         context->HadContextSensitiveCondition = true;
-        const char *propContent =
-                          target->GetLinkInterfaceDependentNumberMaxProperty(
-                                                propertyName,
-                                                context->Config);
+        const char* propContent =
+          target->GetLinkInterfaceDependentNumberMaxProperty(propertyName,
+                                                             context->Config);
         return propContent ? propContent : "";
-        }
+      }
 
       return linkedTargetsContent;
-      }
+    }
 
-    if (!target->IsImported()
-        && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries())
-      {
+    if (!target->IsImported() && dagCheckerParent &&
+        !dagCheckerParent->EvaluatingLinkLibraries()) {
       if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
-                                                          context->Config))
-        {
+                                                            context->Config)) {
         context->HadContextSensitiveCondition = true;
-        const char *propContent =
-                            target->GetLinkInterfaceDependentNumberMinProperty(
-                                                propertyName,
-                                                context->Config);
+        const char* propContent =
+          target->GetLinkInterfaceDependentNumberMinProperty(propertyName,
+                                                             context->Config);
         return propContent ? propContent : "";
-        }
+      }
       if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
-                                                          context->Config))
-        {
+                                                            context->Config)) {
         context->HadContextSensitiveCondition = true;
-        const char *propContent =
-                            target->GetLinkInterfaceDependentNumberMaxProperty(
-                                                propertyName,
-                                                context->Config);
+        const char* propContent =
+          target->GetLinkInterfaceDependentNumberMaxProperty(propertyName,
+                                                             context->Config);
         return propContent ? propContent : "";
-        }
       }
-    if(!interfacePropertyName.empty())
-      {
-      std::string result = this->EvaluateDependentExpression(prop,
-                                        context->LG, context,
-                                        headTarget, target, &dagChecker);
-      if (!linkedTargetsContent.empty())
-        {
+    }
+    if (!interfacePropertyName.empty()) {
+      std::string result = this->EvaluateDependentExpression(
+        prop, context->LG, context, headTarget, target, &dagChecker);
+      if (!linkedTargetsContent.empty()) {
         result += (result.empty() ? "" : ";") + linkedTargetsContent;
-        }
-      return result;
       }
+      return result;
+    }
     return prop;
   }
 } targetPropertyNode;
 
-//----------------------------------------------------------------------------
 static const struct TargetNameNode : public cmGeneratorExpressionNode
 {
   TargetNameNode() {}
@@ -1235,10 +1092,10 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
   virtual bool AcceptsArbitraryContentParameter() const { return true; }
   virtual bool RequiresLiteralInput() const { return true; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *,
-                       const GeneratorExpressionContent *,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext*,
+                       const GeneratorExpressionContent*,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     return parameters.front();
   }
@@ -1247,102 +1104,96 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
 
 } targetNameNode;
 
-//----------------------------------------------------------------------------
 static const struct TargetObjectsNode : public cmGeneratorExpressionNode
 {
   TargetObjectsNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    if (!context->EvaluateForBuildsystem)
-      {
+    if (!context->EvaluateForBuildsystem) {
       std::ostringstream 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.";
+           "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->LG->FindGeneratorTargetToUse(tgtName);
-    if (!gt)
-      {
+    cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName);
+    if (!gt) {
       std::ostringstream e;
       e << "Objects of target \"" << tgtName
         << "\" referenced but no such target exists.";
       reportError(context, content->GetOriginalExpression(), e.str());
       return std::string();
-      }
-    if (gt->GetType() != cmState::OBJECT_LIBRARY)
-      {
+    }
+    if (gt->GetType() != cmState::OBJECT_LIBRARY) {
       std::ostringstream 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)
-      {
+    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::vector<cmSourceFile const*>::const_iterator it
-        = objectSources.begin(); it != objectSources.end(); ++it)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator it =
+           objectSources.begin();
+         it != objectSources.end(); ++it) {
       // Find the object file name corresponding to this source file.
-      std::map<cmSourceFile const*, std::string>::const_iterator
-        map_it = mapping.find(*it);
+      std::map<cmSourceFile const*, std::string>::const_iterator map_it =
+        mapping.find(*it);
       // It must exist because we populated the mapping just above.
       assert(!map_it->second.empty());
       result += sep;
       std::string objFile = obj_dir + map_it->second;
       cmSourceFile* sf =
-          context->LG->GetMakefile()->GetOrCreateSource(objFile, true);
+        context->LG->GetMakefile()->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
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
     cmGeneratorTarget 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.");
+    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();
-      }
+    }
     context->HadHeadSensitiveCondition = true;
 
     typedef std::map<std::string, std::vector<std::string> > LangMap;
@@ -1351,86 +1202,69 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
     LangMap testedFeatures;
 
     for (std::vector<std::string>::const_iterator it = parameters.begin();
-        it != parameters.end(); ++it)
-      {
+         it != parameters.end(); ++it) {
       std::string error;
       std::string lang;
       if (!context->LG->GetMakefile()->CompileFeatureKnown(
-            context->HeadTarget->Target,
-                                                  *it, lang, &error))
-        {
+            context->HeadTarget->Target, *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->LG->GetMakefile()->CompileFeaturesAvailable(lang,
-                                                                   &error);
-        if (!featuresKnown)
-          {
+      if (availableFeatures.find(lang) == availableFeatures.end()) {
+        const char* featuresKnown =
+          context->LG->GetMakefile()->CompileFeaturesAvailable(lang, &error);
+        if (!featuresKnown) {
           reportError(context, content->GetOriginalExpression(), error);
           return std::string();
-          }
+        }
         cmSystemTools::ExpandListArgument(featuresKnown,
                                           availableFeatures[lang]);
-        }
       }
+    }
 
     bool evalLL = dagChecker && dagChecker->EvaluatingLinkLibraries();
 
     for (LangMap::const_iterator lit = testedFeatures.begin();
-          lit != testedFeatures.end(); ++lit)
-      {
-      std::vector<std::string> const& langAvailable
-                                              = availableFeatures[lit->first];
-      const char* standardDefault = context->LG->GetMakefile()
-        ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
+         lit != testedFeatures.end(); ++lit) {
+      std::vector<std::string> const& langAvailable =
+        availableFeatures[lit->first];
+      const char* standardDefault = context->LG->GetMakefile()->GetDefinition(
+        "CMAKE_" + lit->first + "_STANDARD_DEFAULT");
       for (std::vector<std::string>::const_iterator it = lit->second.begin();
-          it != lit->second.end(); ++it)
-        {
-        if (std::find(langAvailable.begin(), langAvailable.end(), *it)
-                                                      == langAvailable.end())
-          {
+           it != lit->second.end(); ++it) {
+        if (std::find(langAvailable.begin(), langAvailable.end(), *it) ==
+            langAvailable.end()) {
           return "0";
-          }
-        if (standardDefault && !*standardDefault)
-          {
+        }
+        if (standardDefault && !*standardDefault) {
           // This compiler has no notion of language standard levels.
           // All features known for the language are always available.
           continue;
-          }
-        if (!context->LG->GetMakefile()->HaveStandardAvailable(target->Target,
-                                                      lit->first, *it))
-          {
-          if (evalLL)
-            {
+        }
+        if (!context->LG->GetMakefile()->HaveStandardAvailable(
+              target->Target, lit->first, *it)) {
+          if (evalLL) {
             const char* l = target->GetProperty(lit->first + "_STANDARD");
-            if (!l)
-              {
+            if (!l) {
               l = standardDefault;
-              }
+            }
             assert(l);
             context->MaxLanguageStandard[target][lit->first] = l;
-            }
-          else
-            {
+          } else {
             return "0";
-            }
           }
         }
       }
+    }
     return "1";
   }
 } compileFeaturesNode;
 
-//----------------------------------------------------------------------------
 static const char* targetPolicyWhitelist[] = {
   0
-#define TARGET_POLICY_STRING(POLICY) \
-  , #POLICY
+#define TARGET_POLICY_STRING(POLICY) , #POLICY
 
   CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
 
@@ -1438,13 +1272,12 @@ static const char* targetPolicyWhitelist[] = {
 };
 
 cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt,
-                                         const char *policy)
+                                         const char* policy)
 {
-#define RETURN_POLICY(POLICY) \
-  if (strcmp(policy, #POLICY) == 0) \
-  { \
-    return tgt->GetPolicyStatus ## POLICY (); \
-  } \
+#define RETURN_POLICY(POLICY)                                                 \
+  if (strcmp(policy, #POLICY) == 0) {                                         \
+    return tgt->GetPolicyStatus##POLICY();                                    \
+  }
 
   CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
 
@@ -1454,13 +1287,12 @@ cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt,
   return cmPolicies::WARN;
 }
 
-cmPolicies::PolicyID policyForString(const char *policy_id)
+cmPolicies::PolicyID policyForString(const char* policy_id)
 {
-#define RETURN_POLICY_ID(POLICY_ID) \
-  if (strcmp(policy_id, #POLICY_ID) == 0) \
-  { \
-    return cmPolicies:: POLICY_ID; \
-  } \
+#define RETURN_POLICY_ID(POLICY_ID)                                           \
+  if (strcmp(policy_id, #POLICY_ID) == 0) {                                   \
+    return cmPolicies::POLICY_ID;                                             \
+  }
 
   CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID)
 
@@ -1470,69 +1302,65 @@ cmPolicies::PolicyID policyForString(const char *policy_id)
   return cmPolicies::CMP0002;
 }
 
-//----------------------------------------------------------------------------
 static const struct TargetPolicyNode : public cmGeneratorExpressionNode
 {
   TargetPolicyNode() {}
 
   virtual int NumExpectedParameters() const { return 1; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context ,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    if (!context->HeadTarget)
-      {
-      reportError(context, content->GetOriginalExpression(),
-          "$<TARGET_POLICY:prop> may only be used with binary targets.  It "
-          "may not be used with add_custom_command or add_custom_target.");
+    if (!context->HeadTarget) {
+      reportError(
+        context, content->GetOriginalExpression(),
+        "$<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();
-      }
+    }
 
     context->HadContextSensitiveCondition = true;
     context->HadHeadSensitiveCondition = true;
 
-    for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i)
-      {
-      const char *policy = targetPolicyWhitelist[i];
-      if (parameters.front() == policy)
-        {
+    for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i) {
+      const char* policy = targetPolicyWhitelist[i];
+      if (parameters.front() == policy) {
         cmLocalGenerator* lg = context->HeadTarget->GetLocalGenerator();
-        switch(statusForTarget(context->HeadTarget, policy))
-          {
+        switch (statusForTarget(context->HeadTarget, policy)) {
           case cmPolicies::WARN:
-            lg->IssueMessage(cmake::AUTHOR_WARNING,
-                        cmPolicies::GetPolicyWarning(policyForString(policy)));
+            lg->IssueMessage(
+              cmake::AUTHOR_WARNING,
+              cmPolicies::GetPolicyWarning(policyForString(policy)));
           case cmPolicies::REQUIRED_IF_USED:
           case cmPolicies::REQUIRED_ALWAYS:
           case cmPolicies::OLD:
             return "0";
           case cmPolicies::NEW:
             return "1";
-          }
         }
       }
-    reportError(context, content->GetOriginalExpression(),
+    }
+    reportError(
+      context, content->GetOriginalExpression(),
       "$<TARGET_POLICY:prop> may only be used with a limited number of "
       "policies.  Currently it may be used with the following policies:\n"
 
 #define STRINGIFY_HELPER(X) #X
 #define STRINGIFY(X) STRINGIFY_HELPER(X)
 
-#define TARGET_POLICY_LIST_ITEM(POLICY) \
-      " * " STRINGIFY(POLICY) "\n"
+#define TARGET_POLICY_LIST_ITEM(POLICY) " * " STRINGIFY(POLICY) "\n"
 
       CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM)
 
 #undef TARGET_POLICY_LIST_ITEM
-      );
+        );
     return std::string();
   }
 
 } targetPolicyNode;
 
-//----------------------------------------------------------------------------
 static const struct InstallPrefixNode : public cmGeneratorExpressionNode
 {
   InstallPrefixNode() {}
@@ -1540,10 +1368,10 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode
   virtual bool GeneratesContent() const { return true; }
   virtual int NumExpectedParameters() const { return 0; }
 
-  std::string Evaluate(const std::vector<std::string> &,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>&,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
     reportError(context, content->GetOriginalExpression(),
                 "INSTALL_PREFIX is a marker for install(EXPORT) only.  It "
@@ -1553,7 +1381,6 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode
 
 } installPrefixNode;
 
-//----------------------------------------------------------------------------
 class ArtifactNameTag;
 class ArtifactLinkerTag;
 class ArtifactSonameTag;
@@ -1562,38 +1389,34 @@ class ArtifactPdbTag;
 class ArtifactPathTag;
 class ArtifactDirTag;
 
-//----------------------------------------------------------------------------
-template<typename ArtifactT>
+template <typename ArtifactT>
 struct TargetFilesystemArtifactResultCreator
 {
   static std::string Create(cmGeneratorTarget* target,
-                            cmGeneratorExpressionContext *context,
-                            const GeneratorExpressionContent *content);
+                            cmGeneratorExpressionContext* context,
+                            const GeneratorExpressionContent* content);
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
 {
   static std::string Create(cmGeneratorTarget* target,
-                            cmGeneratorExpressionContext *context,
-                            const GeneratorExpressionContent *content)
+                            cmGeneratorExpressionContext* context,
+                            const GeneratorExpressionContent* content)
   {
     // The target soname file (.so.1).
-    if(target->IsDLLPlatform())
-      {
+    if (target->IsDLLPlatform()) {
       ::reportError(context, content->GetOriginalExpression(),
                     "TARGET_SONAME_FILE is not allowed "
                     "for DLL target platforms.");
       return std::string();
-      }
-    if(target->GetType() != cmState::SHARED_LIBRARY)
-      {
+    }
+    if (target->GetType() != cmState::SHARED_LIBRARY) {
       ::reportError(context, content->GetOriginalExpression(),
                     "TARGET_SONAME_FILE is allowed only for "
                     "SHARED libraries.");
       return std::string();
-      }
+    }
     std::string result = target->GetDirectory(context->Config);
     result += "/";
     result += target->GetSOName(context->Config);
@@ -1601,43 +1424,39 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
   }
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
 {
   static std::string Create(cmGeneratorTarget* target,
-                            cmGeneratorExpressionContext *context,
-                            const GeneratorExpressionContent *content)
+                            cmGeneratorExpressionContext* context,
+                            const GeneratorExpressionContent* content)
   {
-    if (target->IsImported())
-      {
+    if (target->IsImported()) {
       ::reportError(context, content->GetOriginalExpression(),
                     "TARGET_PDB_FILE not allowed for IMPORTED targets.");
       return std::string();
-      }
+    }
 
     std::string language = target->GetLinkerLanguage(context->Config);
 
     std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
 
-    if(!context->LG->GetMakefile()->IsOn(pdbSupportVar))
-      {
+    if (!context->LG->GetMakefile()->IsOn(pdbSupportVar)) {
       ::reportError(context, content->GetOriginalExpression(),
                     "TARGET_PDB_FILE is not supported by the target linker.");
       return std::string();
-      }
+    }
 
     cmState::TargetType targetType = target->GetType();
 
-    if(targetType != cmState::SHARED_LIBRARY &&
-       targetType != cmState::MODULE_LIBRARY &&
-       targetType != cmState::EXECUTABLE)
-      {
+    if (targetType != cmState::SHARED_LIBRARY &&
+        targetType != cmState::MODULE_LIBRARY &&
+        targetType != cmState::EXECUTABLE) {
       ::reportError(context, content->GetOriginalExpression(),
                     "TARGET_PDB_FILE is allowed only for "
                     "targets with linker created artifacts.");
       return std::string();
-      }
+    }
 
     std::string result = target->GetPDBDirectory(context->Config);
     result += "/";
@@ -1646,189 +1465,165 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
   }
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
 {
   static std::string Create(cmGeneratorTarget* target,
-                            cmGeneratorExpressionContext *context,
-                            const GeneratorExpressionContent *content)
+                            cmGeneratorExpressionContext* context,
+                            const GeneratorExpressionContent* content)
   {
     // The file used to link to the target (.so, .lib, .a).
-    if(!target->IsLinkable())
-      {
+    if (!target->IsLinkable()) {
       ::reportError(context, content->GetOriginalExpression(),
                     "TARGET_LINKER_FILE is allowed only for libraries and "
                     "executables with ENABLE_EXPORTS.");
       return std::string();
-      }
-    return target->GetFullPath(context->Config,
-                               target->HasImportLibrary());
+    }
+    return target->GetFullPath(context->Config, target->HasImportLibrary());
   }
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultCreator<ArtifactNameTag>
 {
   static std::string Create(cmGeneratorTarget* target,
-                            cmGeneratorExpressionContext *context,
-                            const GeneratorExpressionContent *)
+                            cmGeneratorExpressionContext* context,
+                            const GeneratorExpressionContent*)
   {
     return target->GetFullPath(context->Config, false, true);
   }
 };
 
-
-//----------------------------------------------------------------------------
-template<typename ArtifactT>
+template <typename ArtifactT>
 struct TargetFilesystemArtifactResultGetter
 {
-  static std::string Get(const std::string &result);
+  static std::string Get(const std::string& result);
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultGetter<ArtifactNameTag>
 {
-  static std::string Get(const std::string &result)
-  { return cmSystemTools::GetFilenameName(result); }
+  static std::string Get(const std::string& result)
+  {
+    return cmSystemTools::GetFilenameName(result);
+  }
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultGetter<ArtifactDirTag>
 {
-  static std::string Get(const std::string &result)
-  { return cmSystemTools::GetFilenamePath(result); }
+  static std::string Get(const std::string& result)
+  {
+    return cmSystemTools::GetFilenamePath(result);
+  }
 };
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 struct TargetFilesystemArtifactResultGetter<ArtifactPathTag>
 {
-  static std::string Get(const std::string &result)
-  { return result; }
+  static std::string Get(const std::string& result) { return result; }
 };
 
-//----------------------------------------------------------------------------
-template<typename ArtifactT, typename ComponentT>
+template <typename ArtifactT, typename ComponentT>
 struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
 {
   TargetFilesystemArtifact() {}
 
   virtual int NumExpectedParameters() const { return 1; }
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker* dagChecker) const
   {
     // Lookup the referenced target.
     std::string name = *parameters.begin();
 
-    if (!cmGeneratorExpression::IsValidTargetName(name))
-      {
+    if (!cmGeneratorExpression::IsValidTargetName(name)) {
       ::reportError(context, content->GetOriginalExpression(),
                     "Expression syntax not recognized.");
       return std::string();
-      }
-    cmGeneratorTarget* target =
-        context->LG->FindGeneratorTargetToUse(name);
-    if(!target)
-      {
+    }
+    cmGeneratorTarget* target = context->LG->FindGeneratorTargetToUse(name);
+    if (!target) {
       ::reportError(context, content->GetOriginalExpression(),
                     "No target \"" + name + "\"");
       return std::string();
-      }
-    if(target->GetType() >= cmState::OBJECT_LIBRARY &&
-      target->GetType() != cmState::UNKNOWN_LIBRARY)
-      {
-      ::reportError(context, content->GetOriginalExpression(),
-                  "Target \"" + name + "\" is not an executable or library.");
+    }
+    if (target->GetType() >= cmState::OBJECT_LIBRARY &&
+        target->GetType() != cmState::UNKNOWN_LIBRARY) {
+      ::reportError(context, content->GetOriginalExpression(), "Target \"" +
+                      name + "\" is not an executable or library.");
       return std::string();
-      }
-    if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str())
-        || (dagChecker->EvaluatingSources()
-          && name == dagChecker->TopTarget())))
-      {
+    }
+    if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str()) ||
+                       (dagChecker->EvaluatingSources() &&
+                        name == dagChecker->TopTarget()))) {
       ::reportError(context, content->GetOriginalExpression(),
                     "Expressions which require the linker language may not "
                     "be used while evaluating link libraries");
       return std::string();
-      }
+    }
     context->DependTargets.insert(target);
     context->AllTargets.insert(target);
 
     std::string result =
-                TargetFilesystemArtifactResultCreator<ArtifactT>::Create(
-                          target,
-                          context,
-                          content);
-    if (context->HadError)
-      {
+      TargetFilesystemArtifactResultCreator<ArtifactT>::Create(target, context,
+                                                               content);
+    if (context->HadError) {
       return std::string();
-      }
-    return
-        TargetFilesystemArtifactResultGetter<ComponentT>::Get(result);
+    }
+    return TargetFilesystemArtifactResultGetter<ComponentT>::Get(result);
   }
 };
 
-//----------------------------------------------------------------------------
-template<typename ArtifactT>
+template <typename ArtifactT>
 struct TargetFilesystemArtifactNodeGroup
 {
-  TargetFilesystemArtifactNodeGroup()
-    {
-    }
+  TargetFilesystemArtifactNodeGroup() {}
 
   TargetFilesystemArtifact<ArtifactT, ArtifactPathTag> File;
   TargetFilesystemArtifact<ArtifactT, ArtifactNameTag> FileName;
   TargetFilesystemArtifact<ArtifactT, ArtifactDirTag> FileDir;
 };
 
-//----------------------------------------------------------------------------
-static const
-TargetFilesystemArtifactNodeGroup<ArtifactNameTag> targetNodeGroup;
+static const TargetFilesystemArtifactNodeGroup<ArtifactNameTag>
+  targetNodeGroup;
 
-static const
-TargetFilesystemArtifactNodeGroup<ArtifactLinkerTag> targetLinkerNodeGroup;
+static const TargetFilesystemArtifactNodeGroup<ArtifactLinkerTag>
+  targetLinkerNodeGroup;
 
-static const
-TargetFilesystemArtifactNodeGroup<ArtifactSonameTag> targetSoNameNodeGroup;
+static const TargetFilesystemArtifactNodeGroup<ArtifactSonameTag>
+  targetSoNameNodeGroup;
 
-static const
-TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup;
+static const TargetFilesystemArtifactNodeGroup<ArtifactPdbTag>
+  targetPdbNodeGroup;
 
-//----------------------------------------------------------------------------
 static const struct ShellPathNode : public cmGeneratorExpressionNode
 {
   ShellPathNode() {}
 
-  std::string Evaluate(const std::vector<std::string> &parameters,
-                       cmGeneratorExpressionContext *context,
-                       const GeneratorExpressionContent *content,
-                       cmGeneratorExpressionDAGChecker *) const
+  std::string Evaluate(const std::vector<std::string>& parameters,
+                       cmGeneratorExpressionContext* context,
+                       const GeneratorExpressionContent* content,
+                       cmGeneratorExpressionDAGChecker*) const
   {
-    if (!cmSystemTools::FileIsFullPath(parameters.front()))
-      {
+    if (!cmSystemTools::FileIsFullPath(parameters.front())) {
       reportError(context, content->GetOriginalExpression(),
                   "\"" + parameters.front() + "\" is not an absolute path.");
       return std::string();
-      }
+    }
     cmOutputConverter converter(context->LG->GetStateSnapshot());
     return converter.ConvertDirectorySeparatorsForShell(parameters.front());
   }
 } shellPathNode;
 
-//----------------------------------------------------------------------------
-const cmGeneratorExpressionNode*
-cmGeneratorExpressionNode::GetNode(const std::string &identifier)
+const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
+  const std::string& identifier)
 {
   typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
   static NodeMap nodeMap;
-  if (nodeMap.empty())
-    {
+  if (nodeMap.empty()) {
     nodeMap["0"] = &zeroNode;
     nodeMap["1"] = &oneNode;
     nodeMap["AND"] = &andNode;
@@ -1877,30 +1672,28 @@ cmGeneratorExpressionNode::GetNode(const std::string &identifier)
     nodeMap["LINK_ONLY"] = &linkOnlyNode;
     nodeMap["COMPILE_LANGUAGE"] = &languageNode;
     nodeMap["SHELL_PATH"] = &shellPathNode;
-    }
+  }
   NodeMap::const_iterator i = nodeMap.find(identifier);
-  if (i == nodeMap.end())
-    {
+  if (i == nodeMap.end()) {
     return 0;
-    }
+  }
   return i->second;
 }
 
-//----------------------------------------------------------------------------
-void reportError(cmGeneratorExpressionContext *context,
-                 const std::string &expr, const std::string &result)
+void reportError(cmGeneratorExpressionContext* context,
+                 const std::string& expr, const std::string& result)
 {
   context->HadError = true;
-  if (context->Quiet)
-    {
+  if (context->Quiet) {
     return;
-    }
+  }
 
   std::ostringstream e;
+  /* clang-format off */
   e << "Error evaluating generator expression:\n"
     << "  " << expr << "\n"
     << result;
-  context->LG->GetCMakeInstance()
-    ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                    context->Backtrace);
+  /* clang-format on */
+  context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                                context->Backtrace);
 }
diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h
index 854811b..3ee57eb 100644
--- a/Source/cmGeneratorExpressionNode.h
+++ b/Source/cmGeneratorExpressionNode.h
@@ -12,10 +12,11 @@
 #ifndef cmGeneratorExpressionNode_h
 #define cmGeneratorExpressionNode_h
 
+#include "cmGeneratorExpression.h"
+
+#include "cmGeneratorExpressionDAGChecker.h"
 #include "cmGeneratorExpressionEvaluator.h"
 #include "cmGeneratorExpressionParser.h"
-#include "cmGeneratorExpressionDAGChecker.h"
-#include "cmGeneratorExpression.h"
 #include "cmLocalGenerator.h"
 #include "cmSourceFile.h"
 
@@ -26,10 +27,10 @@
 
 #include "cmListFileCache.h"
 
-//----------------------------------------------------------------------------
 struct cmGeneratorExpressionNode
 {
-  enum {
+  enum
+  {
     DynamicParameters = 0,
     OneOrMoreParameters = -1,
     OneOrZeroParameters = -2
@@ -40,30 +41,27 @@ struct cmGeneratorExpressionNode
 
   virtual bool RequiresLiteralInput() const { return false; }
 
-  virtual bool AcceptsArbitraryContentParameter() const
-    { return false; }
+  virtual bool AcceptsArbitraryContentParameter() const { return false; }
 
   virtual int NumExpectedParameters() const { return 1; }
 
-  virtual std::string Evaluate(const std::vector<std::string> &parameters,
-                               cmGeneratorExpressionContext *context,
-                               const GeneratorExpressionContent *content,
-                               cmGeneratorExpressionDAGChecker *dagChecker
-                              ) const = 0;
+  virtual std::string Evaluate(
+    const std::vector<std::string>& parameters,
+    cmGeneratorExpressionContext* context,
+    const GeneratorExpressionContent* content,
+    cmGeneratorExpressionDAGChecker* dagChecker) const = 0;
 
   static std::string EvaluateDependentExpression(
-    std::string const& prop, cmLocalGenerator *lg,
-    cmGeneratorExpressionContext *context,
-    const cmGeneratorTarget* headTarget,
+    std::string const& prop, cmLocalGenerator* lg,
+    cmGeneratorExpressionContext* context, const cmGeneratorTarget* headTarget,
     const cmGeneratorTarget* currentTarget,
-    cmGeneratorExpressionDAGChecker *dagChecker);
+    cmGeneratorExpressionDAGChecker* dagChecker);
 
   static const cmGeneratorExpressionNode* GetNode(
-                                              const std::string &identifier);
+    const std::string& identifier);
 };
 
-//----------------------------------------------------------------------------
-void reportError(cmGeneratorExpressionContext *context,
-                 const std::string &expr, const std::string &result);
+void reportError(cmGeneratorExpressionContext* context,
+                 const std::string& expr, const std::string& result);
 
 #endif
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index a17da8c..f853f8d 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -16,56 +16,49 @@
 
 #include "assert.h"
 
-//----------------------------------------------------------------------------
 cmGeneratorExpressionParser::cmGeneratorExpressionParser(
-                      const std::vector<cmGeneratorExpressionToken> &tokens)
-  : Tokens(tokens), NestingLevel(0)
+  const std::vector<cmGeneratorExpressionToken>& tokens)
+  : Tokens(tokens)
+  , NestingLevel(0)
 {
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorExpressionParser::Parse(
-                        std::vector<cmGeneratorExpressionEvaluator*> &result)
+  std::vector<cmGeneratorExpressionEvaluator*>& result)
 {
   it = this->Tokens.begin();
 
-  while (this->it != this->Tokens.end())
-    {
+  while (this->it != this->Tokens.end()) {
     this->ParseContent(result);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-static void extendText(std::vector<cmGeneratorExpressionEvaluator*> &result,
-                  std::vector<cmGeneratorExpressionToken>::const_iterator it)
+static void extendText(
+  std::vector<cmGeneratorExpressionEvaluator*>& result,
+  std::vector<cmGeneratorExpressionToken>::const_iterator it)
 {
-  if (!result.empty()
-      && (*(result.end() - 1))->GetType()
-                                  == cmGeneratorExpressionEvaluator::Text)
-    {
-    TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1));
+  if (!result.empty() &&
+      (*(result.end() - 1))->GetType() ==
+        cmGeneratorExpressionEvaluator::Text) {
+    TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
     textContent->Extend(it->Length);
-    }
-  else
-    {
-    TextContent *textContent = new TextContent(it->Content, it->Length);
+  } else {
+    TextContent* textContent = new TextContent(it->Content, it->Length);
     result.push_back(textContent);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result,
-                const std::vector<cmGeneratorExpressionEvaluator*> &contents)
+static void extendResult(
+  std::vector<cmGeneratorExpressionEvaluator*>& result,
+  const std::vector<cmGeneratorExpressionEvaluator*>& contents)
 {
-  if (!result.empty()
-      && (*(result.end() - 1))->GetType()
-                                  == cmGeneratorExpressionEvaluator::Text
-      && (*contents.begin())->GetType()
-                                  == cmGeneratorExpressionEvaluator::Text)
-  {
-    TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1));
+  if (!result.empty() &&
+      (*(result.end() - 1))->GetType() ==
+        cmGeneratorExpressionEvaluator::Text &&
+      (*contents.begin())->GetType() == cmGeneratorExpressionEvaluator::Text) {
+    TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
     textContent->Extend(
-                  static_cast<TextContent*>(*contents.begin())->GetLength());
+      static_cast<TextContent*>(*contents.begin())->GetLength());
     delete *contents.begin();
     result.insert(result.end(), contents.begin() + 1, contents.end());
   } else {
@@ -73,210 +66,179 @@ static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result,
   }
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorExpressionParser::ParseGeneratorExpression(
-                        std::vector<cmGeneratorExpressionEvaluator*> &result)
+  std::vector<cmGeneratorExpressionEvaluator*>& result)
 {
   assert(this->it != this->Tokens.end());
   unsigned int nestedLevel = this->NestingLevel;
   ++this->NestingLevel;
 
-  std::vector<cmGeneratorExpressionToken>::const_iterator startToken
-                                                              = this->it - 1;
+  std::vector<cmGeneratorExpressionToken>::const_iterator startToken =
+    this->it - 1;
 
   std::vector<cmGeneratorExpressionEvaluator*> identifier;
-  while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression
-      && this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator)
-    {
-    if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
-      {
+  while (this->it->TokenType != cmGeneratorExpressionToken::EndExpression &&
+         this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator) {
+    if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) {
       extendText(identifier, this->it);
       ++this->it;
-      }
-    else
-      {
+    } else {
       this->ParseContent(identifier);
-      }
-    if (this->it == this->Tokens.end())
-      {
+    }
+    if (this->it == this->Tokens.end()) {
       break;
-      }
     }
-  if (identifier.empty())
-    {
+  }
+  if (identifier.empty()) {
     // ERROR
-    }
+  }
 
   if (this->it != this->Tokens.end() &&
-      this->it->TokenType == cmGeneratorExpressionToken::EndExpression)
-    {
-    GeneratorExpressionContent *content = new GeneratorExpressionContent(
-                startToken->Content, this->it->Content
-                                    - startToken->Content
-                                    + this->it->Length);
+      this->it->TokenType == cmGeneratorExpressionToken::EndExpression) {
+    GeneratorExpressionContent* content =
+      new GeneratorExpressionContent(startToken->Content, this->it->Content -
+                                       startToken->Content + this->it->Length);
     assert(this->it != this->Tokens.end());
     ++this->it;
     --this->NestingLevel;
     content->SetIdentifier(identifier);
     result.push_back(content);
     return;
-    }
+  }
 
   std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters;
   std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator>
-                                                            commaTokens;
+    commaTokens;
   std::vector<cmGeneratorExpressionToken>::const_iterator colonToken;
 
   bool emptyParamTermination = false;
 
   if (this->it != this->Tokens.end() &&
-      this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
-    {
+      this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) {
     colonToken = this->it;
     parameters.resize(parameters.size() + 1);
     assert(this->it != this->Tokens.end());
     ++this->it;
-    if(this->it == this->Tokens.end())
-      {
+    if (this->it == this->Tokens.end()) {
       emptyParamTermination = true;
-      }
+    }
 
     while (this->it != this->Tokens.end() &&
-           this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
-      {
+           this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) {
       commaTokens.push_back(this->it);
       parameters.resize(parameters.size() + 1);
       assert(this->it != this->Tokens.end());
       ++this->it;
-      if(this->it == this->Tokens.end())
-        {
+      if (this->it == this->Tokens.end()) {
         emptyParamTermination = true;
-        }
       }
+    }
     while (this->it != this->Tokens.end() &&
-           this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
-      {
+           this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) {
       extendText(*(parameters.end() - 1), this->it);
       assert(this->it != this->Tokens.end());
       ++this->it;
-      }
+    }
     while (this->it != this->Tokens.end() &&
-           this->it->TokenType != cmGeneratorExpressionToken::EndExpression)
-      {
+           this->it->TokenType != cmGeneratorExpressionToken::EndExpression) {
       this->ParseContent(*(parameters.end() - 1));
-      if (this->it == this->Tokens.end())
-        {
+      if (this->it == this->Tokens.end()) {
         break;
-        }
+      }
       while (this->it != this->Tokens.end() &&
-             this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
-        {
+             this->it->TokenType ==
+               cmGeneratorExpressionToken::CommaSeparator) {
         commaTokens.push_back(this->it);
         parameters.resize(parameters.size() + 1);
         assert(this->it != this->Tokens.end());
         ++this->it;
-        if(this->it == this->Tokens.end())
-          {
+        if (this->it == this->Tokens.end()) {
           emptyParamTermination = true;
-          }
         }
+      }
       while (this->it != this->Tokens.end() &&
-             this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
-        {
+             this->it->TokenType ==
+               cmGeneratorExpressionToken::ColonSeparator) {
         extendText(*(parameters.end() - 1), this->it);
         assert(this->it != this->Tokens.end());
         ++this->it;
-        }
       }
-      if(this->it != this->Tokens.end()
-          && this->it->TokenType == cmGeneratorExpressionToken::EndExpression)
-        {
-        --this->NestingLevel;
-        assert(this->it != this->Tokens.end());
-        ++this->it;
-        }
     }
+    if (this->it != this->Tokens.end() &&
+        this->it->TokenType == cmGeneratorExpressionToken::EndExpression) {
+      --this->NestingLevel;
+      assert(this->it != this->Tokens.end());
+      ++this->it;
+    }
+  }
 
-  if (nestedLevel != this->NestingLevel)
-  {
+  if (nestedLevel != this->NestingLevel) {
     // There was a '$<' in the text, but no corresponding '>'. Rebuild to
     // treat the '$<' as having been plain text, along with the
     // corresponding : and , tokens that might have been found.
     extendText(result, startToken);
     extendResult(result, identifier);
-    if (!parameters.empty())
-      {
+    if (!parameters.empty()) {
       extendText(result, colonToken);
 
       typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
       typedef std::vector<cmGeneratorExpressionToken> TokenVector;
       std::vector<EvaluatorVector>::const_iterator pit = parameters.begin();
       const std::vector<EvaluatorVector>::const_iterator pend =
-                                                         parameters.end();
+        parameters.end();
       std::vector<TokenVector::const_iterator>::const_iterator commaIt =
-                                                         commaTokens.begin();
+        commaTokens.begin();
       assert(parameters.size() > commaTokens.size());
-      for ( ; pit != pend; ++pit, ++commaIt)
-        {
-        if (!pit->empty() && !emptyParamTermination)
-          {
+      for (; pit != pend; ++pit, ++commaIt) {
+        if (!pit->empty() && !emptyParamTermination) {
           extendResult(result, *pit);
-          }
-        if (commaIt != commaTokens.end())
-          {
+        }
+        if (commaIt != commaTokens.end()) {
           extendText(result, *commaIt);
-          }
-        else
-          {
+        } else {
           break;
-          }
         }
       }
+    }
     return;
   }
 
-  size_t contentLength = ((this->it - 1)->Content
-                    - startToken->Content)
-                    + (this->it - 1)->Length;
-  GeneratorExpressionContent *content = new GeneratorExpressionContent(
-                            startToken->Content, contentLength);
+  size_t contentLength =
+    ((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length;
+  GeneratorExpressionContent* content =
+    new GeneratorExpressionContent(startToken->Content, contentLength);
   content->SetIdentifier(identifier);
   content->SetParameters(parameters);
   result.push_back(content);
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorExpressionParser::ParseContent(
-                        std::vector<cmGeneratorExpressionEvaluator*> &result)
+  std::vector<cmGeneratorExpressionEvaluator*>& result)
 {
   assert(this->it != this->Tokens.end());
-  switch(this->it->TokenType)
-    {
-    case cmGeneratorExpressionToken::Text:
-    {
-      if (this->NestingLevel == 0)
-        {
-        if (!result.empty()
-            && (*(result.end() - 1))->GetType()
-                                      == cmGeneratorExpressionEvaluator::Text)
-          {
+  switch (this->it->TokenType) {
+    case cmGeneratorExpressionToken::Text: {
+      if (this->NestingLevel == 0) {
+        if (!result.empty() &&
+            (*(result.end() - 1))->GetType() ==
+              cmGeneratorExpressionEvaluator::Text) {
           // A comma in 'plain text' could have split text that should
           // otherwise be continuous. Extend the last text content instead of
           // creating a new one.
-          TextContent *textContent =
-                              static_cast<TextContent*>(*(result.end() - 1));
+          TextContent* textContent =
+            static_cast<TextContent*>(*(result.end() - 1));
           textContent->Extend(this->it->Length);
           assert(this->it != this->Tokens.end());
           ++this->it;
           return;
-          }
         }
-      cmGeneratorExpressionEvaluator* n = new TextContent(this->it->Content,
-                                                          this->it->Length);
+      }
+      cmGeneratorExpressionEvaluator* n =
+        new TextContent(this->it->Content, this->it->Length);
       result.push_back(n);
       assert(this->it != this->Tokens.end());
       ++this->it;
-      return ;
+      return;
     }
     case cmGeneratorExpressionToken::BeginExpression:
       assert(this->it != this->Tokens.end());
@@ -286,17 +248,14 @@ void cmGeneratorExpressionParser::ParseContent(
     case cmGeneratorExpressionToken::EndExpression:
     case cmGeneratorExpressionToken::ColonSeparator:
     case cmGeneratorExpressionToken::CommaSeparator:
-      if (this->NestingLevel == 0)
-        {
+      if (this->NestingLevel == 0) {
         extendText(result, this->it);
-        }
-      else
-        {
-          assert(0 && "Got unexpected syntax token.");
-        }
+      } else {
+        assert(0 && "Got unexpected syntax token.");
+      }
       assert(this->it != this->Tokens.end());
       ++this->it;
       return;
-    }
-    assert(0 && "Unhandled token in generator expression.");
+  }
+  assert(0 && "Unhandled token in generator expression.");
 }
diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h
index 5bd6777..b0e9ea4 100644
--- a/Source/cmGeneratorExpressionParser.h
+++ b/Source/cmGeneratorExpressionParser.h
@@ -21,18 +21,16 @@
 
 struct cmGeneratorExpressionEvaluator;
 
-//----------------------------------------------------------------------------
 struct cmGeneratorExpressionParser
 {
   cmGeneratorExpressionParser(
-                      const std::vector<cmGeneratorExpressionToken> &tokens);
+    const std::vector<cmGeneratorExpressionToken>& tokens);
 
-  void Parse(std::vector<cmGeneratorExpressionEvaluator*> &result);
+  void Parse(std::vector<cmGeneratorExpressionEvaluator*>& result);
 
 private:
-  void ParseContent(std::vector<cmGeneratorExpressionEvaluator*> &);
-  void ParseGeneratorExpression(
-                              std::vector<cmGeneratorExpressionEvaluator*> &);
+  void ParseContent(std::vector<cmGeneratorExpressionEvaluator*>&);
+  void ParseGeneratorExpression(std::vector<cmGeneratorExpressionEvaluator*>&);
 
 private:
   std::vector<cmGeneratorExpressionToken>::const_iterator it;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index ff12320..3856091 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -11,21 +11,21 @@
 ============================================================================*/
 #include "cmGeneratorTarget.h"
 
-#include "cmTarget.h"
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
-#include "cmGlobalGenerator.h"
-#include "cmSourceFile.h"
-#include "cmGeneratorExpression.h"
-#include "cmGeneratorExpressionDAGChecker.h"
+#include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommandGenerator.h"
-#include "cmAlgorithms.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorExpressionDAGChecker.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmSourceFile.h"
+#include "cmTarget.h"
 
 #include <queue>
 
-#include <errno.h>
 #include "assert.h"
+#include <errno.h>
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include <cmsys/hash_set.hxx>
@@ -34,94 +34,123 @@
 #define UNORDERED_SET std::set
 #endif
 
-class cmGeneratorTarget::TargetPropertyEntry {
+class cmGeneratorTarget::TargetPropertyEntry
+{
   static cmLinkImplItem NoLinkImplItem;
+
 public:
   TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
                       cmLinkImplItem const& item = NoLinkImplItem)
-    : ge(cge), LinkImplItem(item)
-  {}
+    : ge(cge)
+    , LinkImplItem(item)
+  {
+  }
   const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
   cmLinkImplItem const& LinkImplItem;
 };
 cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
 
-//----------------------------------------------------------------------------
 void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
-                     cmGeneratorTarget const* target, cmake *cm)
+                     cmGeneratorTarget const* target, cmake* cm)
 {
-  if(!badObjLib.empty())
-    {
+  if (!badObjLib.empty()) {
     std::ostringstream e;
     e << "OBJECT library \"" << target->GetName() << "\" contains:\n";
-    for(std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
-        i != badObjLib.end(); ++i)
-      {
+    for (std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
+         i != badObjLib.end(); ++i) {
       e << "  " << (*i)->GetLocation().GetName() << "\n";
-      }
+    }
     e << "but may contain only sources that compile, header files, and "
          "other files that would not affect linking of a normal library.";
-    cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                     target->GetBacktrace());
-    }
+    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 {};
-struct AppManifestTag{};
-struct ManifestsTag{};
-struct CertificatesTag{};
-struct XamlTag{};
-
-template<typename Tag, typename OtherTag>
+struct ObjectSourcesTag
+{
+};
+struct CustomCommandsTag
+{
+};
+struct ExtraSourcesTag
+{
+};
+struct HeaderSourcesTag
+{
+};
+struct ExternalObjectsTag
+{
+};
+struct IDLSourcesTag
+{
+};
+struct ResxTag
+{
+};
+struct ModuleDefinitionFileTag
+{
+};
+struct AppManifestTag
+{
+};
+struct ManifestsTag
+{
+};
+struct CertificatesTag
+{
+};
+struct XamlTag
+{
+};
+
+template <typename Tag, typename OtherTag>
 struct IsSameTag
 {
-  enum {
+  enum
+  {
     Result = false
   };
 };
 
-template<typename Tag>
+template <typename Tag>
 struct IsSameTag<Tag, Tag>
 {
-  enum {
+  enum
+  {
     Result = true
   };
 };
 
-template<bool>
+template <bool>
 struct DoAccept
 {
-  template <typename T> static void Do(T&, cmSourceFile*) {}
+  template <typename T>
+  static void Do(T&, cmSourceFile*)
+  {
+  }
 };
 
-template<>
+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";
+    std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h";
     data.ExpectedResxHeaders.insert(hFileName);
     data.ResxSources.push_back(f);
-    }
+  }
   static void Do(cmGeneratorTarget::XamlData& data, cmSourceFile* f)
-    {
+  {
     // Build and save the name of the corresponding .h and .cpp file
     // This relationship will be used later when building the project files.
     // Both names would have been auto generated from Visual Studio
@@ -133,29 +162,29 @@ struct DoAccept<true>
     data.ExpectedXamlHeaders.insert(hFileName);
     data.ExpectedXamlSources.insert(cppFileName);
     data.XamlSources.push_back(f);
-    }
+  }
   static void Do(std::string& data, cmSourceFile* f)
-    {
+  {
     data = f->GetFullPath();
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
-template<typename Tag, typename DataType = std::vector<cmSourceFile const*> >
+template <typename Tag, typename DataType = std::vector<cmSourceFile const*> >
 struct TagVisitor
 {
   DataType& Data;
   std::vector<cmSourceFile*> BadObjLibFiles;
   cmGeneratorTarget const* Target;
-  cmGlobalGenerator *GlobalGenerator;
+  cmGlobalGenerator* GlobalGenerator;
   cmsys::RegularExpression Header;
   bool IsObjLib;
 
   TagVisitor(cmGeneratorTarget const* target, DataType& data)
-    : Data(data), Target(target),
-    GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()),
-    Header(CM_HEADER_REGEX),
-    IsObjLib(target->GetType() == cmState::OBJECT_LIBRARY)
+    : Data(data)
+    , Target(target)
+    , GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator())
+    , Header(CM_HEADER_REGEX)
+    , IsObjLib(target->GetType() == cmState::OBJECT_LIBRARY)
   {
   }
 
@@ -165,114 +194,79 @@ struct TagVisitor
                     this->GlobalGenerator->GetCMakeInstance());
   }
 
-  void Accept(cmSourceFile *sf)
+  void Accept(cmSourceFile* sf)
   {
     std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
-    if(sf->GetCustomCommand())
-      {
+    if (sf->GetCustomCommand()) {
       DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf);
-      }
-    else if(this->Target->GetType() == cmState::UTILITY)
-      {
+    } else if (this->Target->GetType() == cmState::UTILITY) {
       DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
-      }
-    else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
-      {
+    } else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) {
       DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
-      }
-    else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
-      {
+    } else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
       DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf);
-      if(this->IsObjLib)
-        {
+      if (this->IsObjLib) {
         this->BadObjLibFiles.push_back(sf);
-        }
       }
-    else if(!sf->GetLanguage().empty())
-      {
+    } else if (!sf->GetLanguage().empty()) {
       DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf);
-      }
-    else if(ext == "def")
-      {
+    } else if (ext == "def") {
       DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data,
                                                                     sf);
-      if(this->IsObjLib)
-        {
+      if (this->IsObjLib) {
         this->BadObjLibFiles.push_back(sf);
-        }
       }
-    else if(ext == "idl")
-      {
+    } else if (ext == "idl") {
       DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf);
-      if(this->IsObjLib)
-        {
+      if (this->IsObjLib) {
         this->BadObjLibFiles.push_back(sf);
-        }
       }
-    else if(ext == "resx")
-      {
+    } else if (ext == "resx") {
       DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf);
-      }
-    else if (ext == "appxmanifest")
-      {
+    } else if (ext == "appxmanifest") {
       DoAccept<IsSameTag<Tag, AppManifestTag>::Result>::Do(this->Data, sf);
-      }
-    else if (ext == "manifest")
-      {
+    } else if (ext == "manifest") {
       DoAccept<IsSameTag<Tag, ManifestsTag>::Result>::Do(this->Data, sf);
-      }
-    else if (ext == "pfx")
-      {
+    } else if (ext == "pfx") {
       DoAccept<IsSameTag<Tag, CertificatesTag>::Result>::Do(this->Data, sf);
-      }
-    else if (ext == "xaml")
-      {
+    } else if (ext == "xaml") {
       DoAccept<IsSameTag<Tag, XamlTag>::Result>::Do(this->Data, sf);
-      }
-    else if(this->Header.find(sf->GetFullPath().c_str()))
-      {
+    } 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()))
-      {
+    } else if (this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) {
       DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
-      }
-    else
-      {
+    } else {
       DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
-      }
+    }
   }
 };
 
 void CreatePropertyGeneratorExpressions(
-    cmStringRange const& entries,
-    cmBacktraceRange const& backtraces,
-    std::vector<cmGeneratorTarget::TargetPropertyEntry*>& items,
-    bool evaluateForBuildsystem = false)
+  cmStringRange const& entries, cmBacktraceRange const& backtraces,
+  std::vector<cmGeneratorTarget::TargetPropertyEntry*>& items,
+  bool evaluateForBuildsystem = false)
 {
   std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin();
   for (std::vector<std::string>::const_iterator it = entries.begin();
-       it != entries.end(); ++it, ++btIt)
-    {
+       it != entries.end(); ++it, ++btIt) {
     cmGeneratorExpression ge(*btIt);
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
     cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
     items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
-  : Target(t),
-  SourceFileFlagsConstructed(false),
-  PolicyWarnedCMP0022(false),
-  DebugIncludesDone(false),
-  DebugCompileOptionsDone(false),
-  DebugCompileFeaturesDone(false),
-  DebugCompileDefinitionsDone(false),
-  DebugSourcesDone(false),
-  LinkImplementationLanguageIsContextDependent(true),
-  UtilityItemsDone(false)
+  : Target(t)
+  , SourceFileFlagsConstructed(false)
+  , PolicyWarnedCMP0022(false)
+  , DebugIncludesDone(false)
+  , DebugCompileOptionsDone(false)
+  , DebugCompileFeaturesDone(false)
+  , DebugCompileDefinitionsDone(false)
+  , DebugSourcesDone(false)
+  , LinkImplementationLanguageIsContextDependent(true)
+  , UtilityItemsDone(false)
 {
   this->Makefile = this->Target->GetMakefile();
   this->LocalGenerator = lg;
@@ -280,34 +274,29 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
 
   this->GlobalGenerator->ComputeTargetObjectDirectory(this);
 
-  CreatePropertyGeneratorExpressions(
-        t->GetIncludeDirectoriesEntries(),
-        t->GetIncludeDirectoriesBacktraces(),
-        this->IncludeDirectoriesEntries);
+  CreatePropertyGeneratorExpressions(t->GetIncludeDirectoriesEntries(),
+                                     t->GetIncludeDirectoriesBacktraces(),
+                                     this->IncludeDirectoriesEntries);
 
-  CreatePropertyGeneratorExpressions(
-        t->GetCompileOptionsEntries(),
-        t->GetCompileOptionsBacktraces(),
-        this->CompileOptionsEntries);
+  CreatePropertyGeneratorExpressions(t->GetCompileOptionsEntries(),
+                                     t->GetCompileOptionsBacktraces(),
+                                     this->CompileOptionsEntries);
 
-  CreatePropertyGeneratorExpressions(
-        t->GetCompileFeaturesEntries(),
-        t->GetCompileFeaturesBacktraces(),
-        this->CompileFeaturesEntries);
+  CreatePropertyGeneratorExpressions(t->GetCompileFeaturesEntries(),
+                                     t->GetCompileFeaturesBacktraces(),
+                                     this->CompileFeaturesEntries);
 
-  CreatePropertyGeneratorExpressions(
-        t->GetCompileDefinitionsEntries(),
-        t->GetCompileDefinitionsBacktraces(),
-        this->CompileDefinitionsEntries);
+  CreatePropertyGeneratorExpressions(t->GetCompileDefinitionsEntries(),
+                                     t->GetCompileDefinitionsBacktraces(),
+                                     this->CompileDefinitionsEntries);
 
-  CreatePropertyGeneratorExpressions(
-        t->GetSourceEntries(),
-        t->GetSourceBacktraces(),
-        this->SourceEntries, true);
+  CreatePropertyGeneratorExpressions(t->GetSourceEntries(),
+                                     t->GetSourceBacktraces(),
+                                     this->SourceEntries, true);
 
-  this->DLLPlatform = (this->Makefile->IsOn("WIN32") ||
-                       this->Makefile->IsOn("CYGWIN") ||
-                       this->Makefile->IsOn("MINGW"));
+  this->DLLPlatform =
+    (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
+     this->Makefile->IsOn("MINGW"));
 
   this->PolicyMap = t->PolicyMap;
 }
@@ -328,101 +317,80 @@ cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const
   return this->LocalGenerator;
 }
 
-//----------------------------------------------------------------------------
 cmState::TargetType cmGeneratorTarget::GetType() const
 {
   return this->Target->GetType();
 }
 
-//----------------------------------------------------------------------------
 const std::string& cmGeneratorTarget::GetName() const
 {
   return this->Target->GetName();
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetExportName() const
 {
-  const char *exportName = this->GetProperty("EXPORT_NAME");
+  const char* exportName = this->GetProperty("EXPORT_NAME");
 
-  if (exportName && *exportName)
-    {
-    if (!cmGeneratorExpression::IsValidTargetName(exportName))
-      {
+  if (exportName && *exportName) {
+    if (!cmGeneratorExpression::IsValidTargetName(exportName)) {
       std::ostringstream e;
       e << "EXPORT_NAME property \"" << exportName << "\" for \""
         << this->GetName() << "\": is not valid.";
       cmSystemTools::Error(e.str().c_str());
       return "";
-      }
-    return exportName;
     }
+    return exportName;
+  }
   return this->GetName();
 }
 
-//----------------------------------------------------------------------------
-const char *cmGeneratorTarget::GetProperty(const std::string& prop) const
+const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
 {
   return this->Target->GetProperty(prop);
 }
 
-//----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
 {
-  switch(this->GetType())
-    {
+  switch (this->GetType()) {
     case cmState::SHARED_LIBRARY:
-      if(this->IsDLLPlatform())
-        {
-        if(implib)
-          {
+      if (this->IsDLLPlatform()) {
+        if (implib) {
           // A DLL import library is treated as an archive target.
           return "ARCHIVE";
-          }
-        else
-          {
+        } else {
           // A DLL shared library is treated as a runtime target.
           return "RUNTIME";
-          }
         }
-      else
-        {
+      } else {
         // For non-DLL platforms shared libraries are treated as
         // library targets.
         return "LIBRARY";
-        }
+      }
     case cmState::STATIC_LIBRARY:
       // Static libraries are always treated as archive targets.
       return "ARCHIVE";
     case cmState::MODULE_LIBRARY:
-      if(implib)
-        {
+      if (implib) {
         // Module libraries are always treated as library targets.
         return "ARCHIVE";
-        }
-      else
-        {
+      } else {
         // Module import libraries are treated as archive targets.
         return "LIBRARY";
-        }
+      }
     case cmState::EXECUTABLE:
-      if(implib)
-        {
+      if (implib) {
         // Executable import libraries are treated as archive targets.
         return "ARCHIVE";
-        }
-      else
-        {
+      } else {
         // Executables are always treated as runtime targets.
         return "RUNTIME";
-        }
+      }
     default:
       break;
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetOutputName(const std::string& config,
                                              bool implib) const
 {
@@ -430,8 +398,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config,
   OutputNameKey key(config, implib);
   cmGeneratorTarget::OutputNameMapType::iterator i =
     this->OutputNameMap.find(key);
-  if(i == this->OutputNameMap.end())
-    {
+  if (i == this->OutputNameMap.end()) {
     // Add empty name in map to detect potential recursion.
     OutputNameMapType::value_type entry(key, "");
     i = this->OutputNameMap.insert(entry).first;
@@ -440,57 +407,48 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config,
     std::vector<std::string> props;
     std::string type = this->GetOutputTargetType(implib);
     std::string configUpper = cmSystemTools::UpperCase(config);
-    if(!type.empty() && !configUpper.empty())
-      {
+    if (!type.empty() && !configUpper.empty()) {
       // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
       props.push_back(type + "_OUTPUT_NAME_" + configUpper);
-      }
-    if(!type.empty())
-      {
+    }
+    if (!type.empty()) {
       // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME
       props.push_back(type + "_OUTPUT_NAME");
-      }
-    if(!configUpper.empty())
-      {
+    }
+    if (!configUpper.empty()) {
       // OUTPUT_NAME_<CONFIG>
       props.push_back("OUTPUT_NAME_" + configUpper);
       // <CONFIG>_OUTPUT_NAME
       props.push_back(configUpper + "_OUTPUT_NAME");
-      }
+    }
     // OUTPUT_NAME
     props.push_back("OUTPUT_NAME");
 
     std::string outName;
-    for(std::vector<std::string>::const_iterator it = props.begin();
-        it != props.end(); ++it)
-      {
-      if (const char* outNameProp = this->GetProperty(*it))
-        {
+    for (std::vector<std::string>::const_iterator it = props.begin();
+         it != props.end(); ++it) {
+      if (const char* outNameProp = this->GetProperty(*it)) {
         outName = outNameProp;
         break;
-        }
       }
+    }
 
-    if(outName.empty())
-      {
+    if (outName.empty()) {
       outName = this->GetName();
-      }
+    }
 
     // Now evaluate genex and update the previously-prepared map entry.
     cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
     i->second = cge->Evaluate(this->LocalGenerator, config);
-    }
-  else if(i->second.empty())
-    {
+  } else if (i->second.empty()) {
     // An empty map entry indicates we have been called recursively
     // from the above block.
-    this->LocalGenerator->GetCMakeInstance()
-          ->IssueMessage(
+    this->LocalGenerator->GetCMakeInstance()->IssueMessage(
       cmake::FATAL_ERROR,
       "Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.",
       this->GetBacktrace());
-    }
+  }
   return i->second;
 }
 
@@ -501,8 +459,7 @@ void cmGeneratorTarget::AddSource(const std::string& src)
   cmGeneratorExpression ge(lfbt);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
   cge->SetEvaluateForBuildsystem(true);
-  this->SourceEntries.push_back(
-                        new TargetPropertyEntry(cge));
+  this->SourceEntries.push_back(new TargetPropertyEntry(cge));
   this->SourceFilesMap.clear();
   this->LinkImplementationLanguageIsContextDependent = true;
 }
@@ -510,8 +467,7 @@ void cmGeneratorTarget::AddSource(const std::string& src)
 void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
 {
   this->Target->AddTracedSources(srcs);
-  if (!srcs.empty())
-    {
+  if (!srcs.empty()) {
     std::string srcFiles = cmJoin(srcs, ";");
     this->SourceFilesMap.clear();
     this->LinkImplementationLanguageIsContextDependent = true;
@@ -520,333 +476,271 @@ void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
     cge->SetEvaluateForBuildsystem(true);
     this->SourceEntries.push_back(
-          new cmGeneratorTarget::TargetPropertyEntry(cge));
-    }
+      new cmGeneratorTarget::TargetPropertyEntry(cge));
+  }
 }
 
-//----------------------------------------------------------------------------
-std::vector<cmSourceFile*> const*
-cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
+std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
+  cmSourceFile const* sf) const
 {
   SourceEntriesType::const_iterator i = this->SourceDepends.find(sf);
-  if(i != this->SourceDepends.end())
-    {
+  if (i != this->SourceDepends.end()) {
     return &i->second.Depends;
-    }
+  }
   return 0;
 }
 
-static void handleSystemIncludesDep(cmLocalGenerator *lg,
-                                  cmGeneratorTarget const* depTgt,
-                                  const std::string& config,
-                                  cmGeneratorTarget const* headTarget,
-                                  cmGeneratorExpressionDAGChecker *dagChecker,
-                                  std::vector<std::string>& result,
-                                  bool excludeImported)
+static void handleSystemIncludesDep(
+  cmLocalGenerator* lg, cmGeneratorTarget const* depTgt,
+  const std::string& config, cmGeneratorTarget const* headTarget,
+  cmGeneratorExpressionDAGChecker* dagChecker,
+  std::vector<std::string>& result, bool excludeImported)
 {
   if (const char* dirs =
-          depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"))
-    {
+        depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
     cmGeneratorExpression ge;
-    cmSystemTools::ExpandListArgument(ge.Parse(dirs)
-                                      ->Evaluate(lg,
-                                      config, false, headTarget,
-                                      depTgt, dagChecker), result);
-    }
-  if (!depTgt->IsImported() || excludeImported)
-    {
+    cmSystemTools::ExpandListArgument(
+      ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt,
+                               dagChecker),
+      result);
+  }
+  if (!depTgt->IsImported() || excludeImported) {
     return;
-    }
+  }
 
   if (const char* dirs =
-                depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES"))
-    {
+        depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
     cmGeneratorExpression ge;
-    cmSystemTools::ExpandListArgument(ge.Parse(dirs)
-                                      ->Evaluate(lg,
-                                      config, false, headTarget,
-                                      depTgt, dagChecker), result);
-    }
+    cmSystemTools::ExpandListArgument(
+      ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt,
+                               dagChecker),
+      result);
+  }
 }
 
-#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \
-  { \
-  std::vector<cmSourceFile*> sourceFiles; \
-  this->GetSourceFiles(sourceFiles, config); \
-  TagVisitor< DATA##Tag DATATYPE > visitor(this, data); \
-  for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
-      si != sourceFiles.end(); ++si) \
-    { \
-    visitor.Accept(*si); \
-    } \
-  } \
-
+/* clang-format off */
+#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE)                                  \
+  {                                                                           \
+    std::vector<cmSourceFile*> sourceFiles;                                   \
+    this->GetSourceFiles(sourceFiles, config);                                \
+    TagVisitor< DATA##Tag DATATYPE > visitor(this, data);                     \
+    for (std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
+         si != sourceFiles.end(); ++si) {                                     \
+      visitor.Accept(*si);                                                    \
+    }                                                                         \
+  }
+/* clang-format on */
 
-#define IMPLEMENT_VISIT(DATA) \
-  IMPLEMENT_VISIT_IMPL(DATA, EMPTY) \
+#define IMPLEMENT_VISIT(DATA) IMPLEMENT_VISIT_IMPL(DATA, EMPTY)
 
 #define EMPTY
 #define COMMA ,
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetObjectSources(std::vector<cmSourceFile const*> &data,
-                   const std::string& config) const
+void cmGeneratorTarget::GetObjectSources(
+  std::vector<cmSourceFile const*>& data, const std::string& config) const
 {
   IMPLEMENT_VISIT(ObjectSources);
 
-  if (!this->Objects.empty())
-    {
+  if (!this->Objects.empty()) {
     return;
-    }
+  }
 
-  for(std::vector<cmSourceFile const*>::const_iterator it = data.begin();
-      it != data.end(); ++it)
-    {
+  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())
-    {
+  if (!this->Objects.empty()) {
     return;
-    }
+  }
 
   std::vector<std::string> configs;
   this->Makefile->GetConfigurations(configs);
-  if (configs.empty())
-    {
+  if (configs.empty()) {
     configs.push_back("");
-    }
-  for(std::vector<std::string>::const_iterator ci = configs.begin();
-      ci != configs.end(); ++ci)
-    {
+  }
+  for (std::vector<std::string>::const_iterator ci = configs.begin();
+       ci != configs.end(); ++ci) {
     std::vector<cmSourceFile const*> sourceFiles;
     this->GetObjectSources(sourceFiles, *ci);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetFeature(const std::string& feature,
                                           const std::string& config) const
 {
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     std::string featureConfig = feature;
     featureConfig += "_";
     featureConfig += cmSystemTools::UpperCase(config);
-    if(const char* value = this->GetProperty(featureConfig))
-      {
+    if (const char* value = this->GetProperty(featureConfig)) {
       return value;
-      }
     }
-  if(const char* value = this->GetProperty(feature))
-    {
+  }
+  if (const char* value = this->GetProperty(feature)) {
     return value;
-    }
+  }
   return this->LocalGenerator->GetFeature(feature, config);
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::GetFeatureAsBool(const std::string& feature,
                                          const std::string& config) const
 {
   return cmSystemTools::IsOn(this->GetFeature(feature, config));
 }
 
-//----------------------------------------------------------------------------
 const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
 {
   this->ComputeObjectMapping();
   return this->Objects[file];
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
 {
   this->ExplicitObjectName.insert(sf);
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
 {
   const_cast<cmGeneratorTarget*>(this)->ComputeObjectMapping();
-  std::set<cmSourceFile const*>::const_iterator it
-                                        = this->ExplicitObjectName.find(file);
+  std::set<cmSourceFile const*>::const_iterator it =
+    this->ExplicitObjectName.find(file);
   return it != this->ExplicitObjectName.end();
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget
-::GetIDLSources(std::vector<cmSourceFile const*>& data,
-                const std::string& config) const
+void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile const*>& data,
+                                      const std::string& config) const
 {
   IMPLEMENT_VISIT(IDLSources);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetHeaderSources(std::vector<cmSourceFile const*>& data,
-                   const std::string& config) const
+void cmGeneratorTarget::GetHeaderSources(
+  std::vector<cmSourceFile const*>& data, const std::string& config) const
 {
   IMPLEMENT_VISIT(HeaderSources);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget
-::GetExtraSources(std::vector<cmSourceFile const*>& data,
-                  const std::string& config) const
+void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile const*>& data,
+                                        const std::string& config) const
 {
   IMPLEMENT_VISIT(ExtraSources);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetCustomCommands(std::vector<cmSourceFile const*>& data,
-                    const std::string& config) const
+void cmGeneratorTarget::GetCustomCommands(
+  std::vector<cmSourceFile const*>& data, const std::string& config) const
 {
   IMPLEMENT_VISIT(CustomCommands);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetExternalObjects(std::vector<cmSourceFile const*>& data,
-                     const std::string& config) const
+void cmGeneratorTarget::GetExternalObjects(
+  std::vector<cmSourceFile const*>& data, const std::string& config) const
 {
   IMPLEMENT_VISIT(ExternalObjects);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
-                                          const std::string& config) const
+void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
+                                               const std::string& config) const
 {
   ResxData data;
   IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
   srcs = data.ExpectedResxHeaders;
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget
-::GetResxSources(std::vector<cmSourceFile const*>& srcs,
-                 const std::string& 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;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetAppManifest(std::vector<cmSourceFile const*>& data,
-                 const std::string& config) const
+void cmGeneratorTarget::GetAppManifest(std::vector<cmSourceFile const*>& data,
+                                       const std::string& config) const
 {
   IMPLEMENT_VISIT(AppManifest);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetManifests(std::vector<cmSourceFile const*>& data,
-               const std::string& config) const
+void cmGeneratorTarget::GetManifests(std::vector<cmSourceFile const*>& data,
+                                     const std::string& config) const
 {
   IMPLEMENT_VISIT(Manifests);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget
-::GetCertificates(std::vector<cmSourceFile const*>& data,
-                  const std::string& config) const
+void cmGeneratorTarget::GetCertificates(std::vector<cmSourceFile const*>& data,
+                                        const std::string& config) const
 {
   IMPLEMENT_VISIT(Certificates);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers,
-                                          const std::string& config) const
+void cmGeneratorTarget::GetExpectedXamlHeaders(std::set<std::string>& headers,
+                                               const std::string& config) const
 {
   XamlData data;
   IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
   headers = data.ExpectedXamlHeaders;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs,
-                                          const std::string& config) const
+void cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs,
+                                               const std::string& config) const
 {
   XamlData data;
   IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
-      srcs = data.ExpectedXamlSources;
+  srcs = data.ExpectedXamlSources;
 }
 
 std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
 {
-  if(!this->UtilityItemsDone)
-    {
+  if (!this->UtilityItemsDone) {
     this->UtilityItemsDone = true;
     std::set<std::string> const& utilities = this->GetUtilities();
-    for(std::set<std::string>::const_iterator i = utilities.begin();
-        i != utilities.end(); ++i)
-      {
+    for (std::set<std::string>::const_iterator i = utilities.begin();
+         i != utilities.end(); ++i) {
       cmGeneratorTarget* gt =
-          this->LocalGenerator->FindGeneratorTargetToUse(*i);
+        this->LocalGenerator->FindGeneratorTargetToUse(*i);
       this->UtilityItems.insert(cmLinkItem(*i, gt));
-      }
     }
+  }
   return this->UtilityItems;
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget
-::GetXamlSources(std::vector<cmSourceFile const*>& srcs,
-                 const std::string& config) const
+void cmGeneratorTarget::GetXamlSources(std::vector<cmSourceFile const*>& srcs,
+                                       const std::string& config) const
 {
   XamlData data;
   IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
   srcs = data.XamlSources;
 }
 
-//----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetLocation(const std::string& config) const
 {
   static std::string location;
-  if (this->IsImported())
-    {
+  if (this->IsImported()) {
     location = this->Target->ImportedGetFullPath(config, false);
-    }
-  else
-    {
+  } else {
     location = this->GetFullPath(config, false);
-    }
+  }
   return location.c_str();
 }
 
-std::vector<cmCustomCommand> const&
-cmGeneratorTarget::GetPreBuildCommands() const
+std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPreBuildCommands()
+  const
 {
   return this->Target->GetPreBuildCommands();
 }
 
-std::vector<cmCustomCommand> const&
-cmGeneratorTarget::GetPreLinkCommands() const
+std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPreLinkCommands()
+  const
 {
   return this->Target->GetPreLinkCommands();
 }
 
-std::vector<cmCustomCommand> const&
-cmGeneratorTarget::GetPostBuildCommands() const
+std::vector<cmCustomCommand> const& cmGeneratorTarget::GetPostBuildCommands()
+  const
 {
   return this->Target->GetPostBuildCommands();
 }
@@ -861,239 +755,205 @@ bool cmGeneratorTarget::IsImportedGloballyVisible() const
   return this->Target->IsImportedGloballyVisible();
 }
 
-//----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetLocationForBuild() const
 {
   static std::string location;
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     location = this->Target->ImportedGetFullPath("", false);
     return location.c_str();
-    }
+  }
 
   // Now handle the deprecated build-time configuration location.
   location = this->GetDirectory();
   const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
-  if(cfgid && strcmp(cfgid, ".") != 0)
-    {
+  if (cfgid && strcmp(cfgid, ".") != 0) {
     location += "/";
     location += cfgid;
-    }
+  }
 
-  if(this->IsAppBundleOnApple())
-    {
-    std::string macdir = this->BuildMacContentDirectory("", "",
-                                                                false);
-    if(!macdir.empty())
-      {
+  if (this->IsAppBundleOnApple()) {
+    std::string macdir = this->BuildMacContentDirectory("", "", false);
+    if (!macdir.empty()) {
       location += "/";
       location += macdir;
-      }
     }
+  }
   location += "/";
   location += this->GetFullName("", false);
   return location.c_str();
 }
 
-
-//----------------------------------------------------------------------------
-bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
-                                              const std::string& config) const
+bool cmGeneratorTarget::IsSystemIncludeDirectory(
+  const std::string& dir, const std::string& config) const
 {
   assert(this->GetType() != cmState::INTERFACE_LIBRARY);
   std::string config_upper;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     config_upper = cmSystemTools::UpperCase(config);
-    }
+  }
 
   typedef std::map<std::string, std::vector<std::string> > IncludeCacheType;
   IncludeCacheType::const_iterator iter =
-      this->SystemIncludesCache.find(config_upper);
+    this->SystemIncludesCache.find(config_upper);
 
-  if (iter == this->SystemIncludesCache.end())
-    {
+  if (iter == this->SystemIncludesCache.end()) {
     cmGeneratorExpressionDAGChecker dagChecker(
-                                        this->GetName(),
-                                        "SYSTEM_INCLUDE_DIRECTORIES", 0, 0);
+      this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", 0, 0);
 
-    bool excludeImported
-                = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
+    bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
 
     std::vector<std::string> result;
-    for (std::set<std::string>::const_iterator
-        it = this->Target->GetSystemIncludeDirectories().begin();
-        it != this->Target->GetSystemIncludeDirectories().end(); ++it)
-      {
+    for (std::set<std::string>::const_iterator it =
+           this->Target->GetSystemIncludeDirectories().begin();
+         it != this->Target->GetSystemIncludeDirectories().end(); ++it) {
       cmGeneratorExpression ge;
-      cmSystemTools::ExpandListArgument(ge.Parse(*it)
-                                          ->Evaluate(this->LocalGenerator,
-                                          config, false, this,
-                                          &dagChecker), result);
-      }
+      cmSystemTools::ExpandListArgument(
+        ge.Parse(*it)->Evaluate(this->LocalGenerator, config, false, this,
+                                &dagChecker),
+        result);
+    }
 
     std::vector<cmGeneratorTarget const*> const& deps =
       this->GetLinkImplementationClosure(config);
-    for(std::vector<cmGeneratorTarget const*>::const_iterator
-          li = deps.begin(), le = deps.end(); li != le; ++li)
-      {
+    for (std::vector<cmGeneratorTarget const *>::const_iterator
+           li = deps.begin(),
+           le = deps.end();
+         li != le; ++li) {
       handleSystemIncludesDep(this->LocalGenerator, *li, config, this,
                               &dagChecker, result, excludeImported);
-      }
+    }
 
     std::set<std::string> unique;
-    for(std::vector<std::string>::iterator li = result.begin();
-        li != result.end(); ++li)
-      {
+    for (std::vector<std::string>::iterator li = result.begin();
+         li != result.end(); ++li) {
       cmSystemTools::ConvertToUnixSlashes(*li);
       unique.insert(*li);
-      }
+    }
     result.clear();
     result.insert(result.end(), unique.begin(), unique.end());
 
     IncludeCacheType::value_type entry(config_upper, result);
     iter = this->SystemIncludesCache.insert(entry).first;
-    }
+  }
 
   return std::binary_search(iter->second.begin(), iter->second.end(), dir);
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
 {
   return this->Target->GetPropertyAsBool(prop);
 }
 
-//----------------------------------------------------------------------------
 static void AddInterfaceEntries(
   cmGeneratorTarget const* thisTarget, std::string const& config,
   std::string const& prop,
   std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries)
 {
-  if(cmLinkImplementationLibraries const* impl =
-     thisTarget->GetLinkImplementationLibraries(config))
-    {
+  if (cmLinkImplementationLibraries const* impl =
+        thisTarget->GetLinkImplementationLibraries(config)) {
     for (std::vector<cmLinkImplItem>::const_iterator
-           it = impl->Libraries.begin(), end = impl->Libraries.end();
-         it != end; ++it)
-      {
-      if(it->Target)
-        {
-        std::string genex =
-          "$<TARGET_PROPERTY:" + *it + "," + prop + ">";
+           it = impl->Libraries.begin(),
+           end = impl->Libraries.end();
+         it != end; ++it) {
+      if (it->Target) {
+        std::string genex = "$<TARGET_PROPERTY:" + *it + "," + prop + ">";
         cmGeneratorExpression ge(it->Backtrace);
         cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
         cge->SetEvaluateForBuildsystem(true);
         entries.push_back(
           new cmGeneratorTarget::TargetPropertyEntry(cge, *it));
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-static bool processSources(cmGeneratorTarget const* tgt,
-      const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
-      std::vector<std::string> &srcs,
-      UNORDERED_SET<std::string> &uniqueSrcs,
-      cmGeneratorExpressionDAGChecker *dagChecker,
-      std::string const& config, bool debugSources)
+static bool processSources(
+  cmGeneratorTarget const* tgt,
+  const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+  std::vector<std::string>& srcs, UNORDERED_SET<std::string>& uniqueSrcs,
+  cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config,
+  bool debugSources)
 {
-  cmMakefile *mf = tgt->Target->GetMakefile();
+  cmMakefile* mf = tgt->Target->GetMakefile();
 
   bool contextDependent = false;
 
-  for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator
-      it = entries.begin(), end = entries.end(); it != end; ++it)
-    {
+  for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
+         it = entries.begin(),
+         end = entries.end();
+       it != end; ++it) {
     cmLinkImplItem const& item = (*it)->LinkImplItem;
     std::string const& targetName = item;
     std::vector<std::string> entrySources;
-    cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(
-                                              tgt->GetLocalGenerator(),
-                                              config,
-                                              false,
-                                              tgt,
-                                              tgt,
-                                              dagChecker),
-                                    entrySources);
-
-    if ((*it)->ge->GetHadContextSensitiveCondition())
-      {
+    cmSystemTools::ExpandListArgument(
+      (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt, tgt,
+                          dagChecker),
+      entrySources);
+
+    if ((*it)->ge->GetHadContextSensitiveCondition()) {
       contextDependent = true;
-      }
+    }
 
-    for(std::vector<std::string>::iterator i = entrySources.begin();
-        i != entrySources.end(); ++i)
-      {
+    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;
       std::string fullPath = sf->GetFullPath(&e);
-      if(fullPath.empty())
-        {
-        if(!e.empty())
-          {
+      if (fullPath.empty()) {
+        if (!e.empty()) {
           cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
-          cm->IssueMessage(cmake::FATAL_ERROR, e,
-                          tgt->GetBacktrace());
-          }
-        return contextDependent;
+          cm->IssueMessage(cmake::FATAL_ERROR, e, tgt->GetBacktrace());
         }
+        return contextDependent;
+      }
 
-      if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str()))
-        {
+      if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) {
         std::ostringstream err;
-        if (!targetName.empty())
-          {
-          err << "Target \"" << targetName << "\" contains relative "
-            "path in its INTERFACE_SOURCES:\n"
-            "  \"" << src << "\"";
-          }
-        else
-          {
+        if (!targetName.empty()) {
+          err << "Target \"" << targetName
+              << "\" contains relative "
+                 "path in its INTERFACE_SOURCES:\n"
+                 "  \""
+              << src << "\"";
+        } else {
           err << "Found relative path while evaluating sources of "
-          "\"" << tgt->GetName() << "\":\n  \"" << src << "\"\n";
-          }
+                 "\""
+              << tgt->GetName() << "\":\n  \"" << src << "\"\n";
+        }
         tgt->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, err.str());
         return contextDependent;
-        }
-      src = fullPath;
       }
+      src = fullPath;
+    }
     std::string usedSources;
-    for(std::vector<std::string>::iterator
-          li = entrySources.begin(); li != entrySources.end(); ++li)
-      {
+    for (std::vector<std::string>::iterator li = entrySources.begin();
+         li != entrySources.end(); ++li) {
       std::string src = *li;
 
-      if(uniqueSrcs.insert(src).second)
-        {
+      if (uniqueSrcs.insert(src).second) {
         srcs.push_back(src);
-        if (debugSources)
-          {
+        if (debugSources) {
           usedSources += " * " + src + "\n";
-          }
         }
       }
-    if (!usedSources.empty())
-      {
-      tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(cmake::LOG,
-                            std::string("Used sources for target ")
-                            + tgt->GetName() + ":\n"
-                            + usedSources, (*it)->ge->GetBacktrace());
-      }
     }
+    if (!usedSources.empty()) {
+      tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
+        cmake::LOG, std::string("Used sources for target ") + tgt->GetName() +
+          ":\n" + usedSources,
+        (*it)->ge->GetBacktrace());
+    }
+  }
   return contextDependent;
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files,
-                              const std::string& config) const
+void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
+                                       const std::string& config) const
 {
   assert(this->GetType() != cmState::INTERFACE_LIBRARY);
 
-  if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026())
-    {
+  if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
     // 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
@@ -1101,127 +961,99 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files,
     // behavior of CMP0024 and CMP0026 only.
 
     cmStringRange sourceEntries = this->Target->GetSourceEntries();
-    for(cmStringRange::const_iterator
-          i = sourceEntries.begin();
-        i != sourceEntries.end(); ++i)
-      {
+    for (cmStringRange::const_iterator i = sourceEntries.begin();
+         i != sourceEntries.end(); ++i) {
       std::string const& entry = *i;
 
       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] == '>')
-          {
+      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);
         }
+        files.push_back(*li);
       }
-    return;
     }
+    return;
+  }
 
   std::vector<std::string> debugProperties;
-  const char *debugProp =
-              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
-  if (debugProp)
-    {
+  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();
+  bool debugSources = !this->DebugSourcesDone &&
+    std::find(debugProperties.begin(), debugProperties.end(), "SOURCES") !=
+      debugProperties.end();
 
-  if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026())
-    {
+  if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
     this->DebugSourcesDone = true;
-    }
+  }
 
-  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
-                                             "SOURCES", 0, 0);
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES", 0, 0);
 
   UNORDERED_SET<std::string> uniqueSrcs;
-  bool contextDependentDirectSources = processSources(this,
-                 this->SourceEntries,
-                 files,
-                 uniqueSrcs,
-                 &dagChecker,
-                 config,
-                 debugSources);
+  bool contextDependentDirectSources =
+    processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker,
+                   config, debugSources);
 
   std::vector<cmGeneratorTarget::TargetPropertyEntry*>
     linkInterfaceSourcesEntries;
 
-  AddInterfaceEntries(
-    this, config, "INTERFACE_SOURCES",
-    linkInterfaceSourcesEntries);
+  AddInterfaceEntries(this, config, "INTERFACE_SOURCES",
+                      linkInterfaceSourcesEntries);
 
   std::vector<std::string>::size_type numFilesBefore = files.size();
-  bool contextDependentInterfaceSources = processSources(this,
-    linkInterfaceSourcesEntries,
-                            files,
-                            uniqueSrcs,
-                            &dagChecker,
-                            config,
-                            debugSources);
-
-  if (!contextDependentDirectSources
-      && !(contextDependentInterfaceSources && numFilesBefore < files.size()))
-    {
+  bool contextDependentInterfaceSources =
+    processSources(this, linkInterfaceSourcesEntries, files, uniqueSrcs,
+                   &dagChecker, config, debugSources);
+
+  if (!contextDependentDirectSources &&
+      !(contextDependentInterfaceSources && numFilesBefore < files.size())) {
     this->LinkImplementationLanguageIsContextDependent = false;
-    }
+  }
 
   cmDeleteAll(linkInterfaceSourcesEntries);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
+void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files,
                                        const std::string& config) const
 {
 
   // Lookup any existing link implementation for this configuration.
   std::string key = cmSystemTools::UpperCase(config);
 
-  if(!this->LinkImplementationLanguageIsContextDependent)
-    {
+  if (!this->LinkImplementationLanguageIsContextDependent) {
     files = this->SourceFilesMap.begin()->second;
     return;
-    }
+  }
 
-  SourceFilesMapType::iterator
-    it = this->SourceFilesMap.find(key);
-  if(it != this->SourceFilesMap.end())
-    {
+  SourceFilesMapType::iterator it = this->SourceFilesMap.find(key);
+  if (it != this->SourceFilesMap.end()) {
     files = it->second;
-    }
-  else
-    {
+  } else {
     std::vector<std::string> srcs;
     this->GetSourceFiles(srcs, config);
 
     std::set<cmSourceFile*> emitted;
 
-    for(std::vector<std::string>::const_iterator i = srcs.begin();
-        i != srcs.end(); ++i)
-      {
+    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)
-        {
+      if (emitted.insert(sf).second) {
         files.push_back(sf);
-        }
       }
-    this->SourceFilesMap[key] = files;
     }
+    this->SourceFilesMap[key] = files;
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetCompilePDBName(const std::string& config) const
+std::string cmGeneratorTarget::GetCompilePDBName(
+  const std::string& config) const
 {
   std::string prefix;
   std::string base;
@@ -1233,38 +1065,32 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const
   std::string configProp = "COMPILE_PDB_NAME_";
   configProp += configUpper;
   const char* config_name = this->GetProperty(configProp);
-  if(config_name && *config_name)
-    {
+  if (config_name && *config_name) {
     return prefix + config_name + ".pdb";
-    }
+  }
 
   const char* name = this->GetProperty("COMPILE_PDB_NAME");
-  if(name && *name)
-    {
+  if (name && *name) {
     return prefix + name + ".pdb";
-    }
+  }
 
   return "";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const
+std::string cmGeneratorTarget::GetCompilePDBPath(
+  const std::string& config) const
 {
   std::string dir = this->GetCompilePDBDirectory(config);
   std::string name = this->GetCompilePDBName(config);
-  if(dir.empty() && !name.empty())
-    {
+  if (dir.empty() && !name.empty()) {
     dir = this->GetPDBDirectory(config);
-    }
-  if(!dir.empty())
-    {
+  }
+  if (!dir.empty()) {
     dir += "/";
-    }
+  }
   return dir + name;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasSOName(const std::string& config) const
 {
   // soname is supported only for shared libraries and modules,
@@ -1274,462 +1100,364 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const
           this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config)));
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const
+bool cmGeneratorTarget::NeedRelinkBeforeInstall(
+  const std::string& config) const
 {
   // Only executables and shared libraries can have an rpath and may
   // need relinking.
-  if(this->GetType() != cmState::EXECUTABLE &&
-     this->GetType() != cmState::SHARED_LIBRARY &&
-     this->GetType() != cmState::MODULE_LIBRARY)
-    {
+  if (this->GetType() != cmState::EXECUTABLE &&
+      this->GetType() != cmState::SHARED_LIBRARY &&
+      this->GetType() != cmState::MODULE_LIBRARY) {
     return false;
-    }
+  }
 
   // If there is no install location this target will not be installed
   // and therefore does not need relinking.
-  if(!this->Target->GetHaveInstallRule())
-    {
+  if (!this->Target->GetHaveInstallRule()) {
     return false;
-    }
+  }
 
   // If skipping all rpaths completely then no relinking is needed.
-  if(this->Makefile->IsOn("CMAKE_SKIP_RPATH"))
-    {
+  if (this->Makefile->IsOn("CMAKE_SKIP_RPATH")) {
     return false;
-    }
+  }
 
   // If building with the install-tree rpath no relinking is needed.
-  if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
-    {
+  if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
     return false;
-    }
+  }
 
   // If chrpath is going to be used no relinking is needed.
-  if(this->IsChrpathUsed(config))
-    {
+  if (this->IsChrpathUsed(config)) {
     return false;
-    }
+  }
 
   // Check for rpath support on this platform.
   std::string ll = this->GetLinkerLanguage(config);
-  if(!ll.empty())
-    {
+  if (!ll.empty()) {
     std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
     flagVar += ll;
     flagVar += "_FLAG";
-    if(!this->Makefile->IsSet(flagVar))
-      {
+    if (!this->Makefile->IsSet(flagVar)) {
       // There is no rpath support on this platform so nothing needs
       // relinking.
       return false;
-      }
     }
-  else
-    {
+  } else {
     // No linker language is known.  This error will be reported by
     // other code.
     return false;
-    }
+  }
 
   // If either a build or install tree rpath is set then the rpath
   // will likely change between the build tree and install tree and
   // this target must be relinked.
-  return this->HaveBuildTreeRPATH(config)
-      || this->HaveInstallTreeRPATH();
+  return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH();
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
 {
   // Only certain target types have an rpath.
-  if(!(this->GetType() == cmState::SHARED_LIBRARY ||
-       this->GetType() == cmState::MODULE_LIBRARY ||
-       this->GetType() == cmState::EXECUTABLE))
-    {
+  if (!(this->GetType() == cmState::SHARED_LIBRARY ||
+        this->GetType() == cmState::MODULE_LIBRARY ||
+        this->GetType() == cmState::EXECUTABLE)) {
     return false;
-    }
+  }
 
   // If the target will not be installed we do not need to change its
   // rpath.
-  if(!this->Target->GetHaveInstallRule())
-    {
+  if (!this->Target->GetHaveInstallRule()) {
     return false;
-    }
+  }
 
   // Skip chrpath if skipping rpath altogether.
-  if(this->Makefile->IsOn("CMAKE_SKIP_RPATH"))
-    {
+  if (this->Makefile->IsOn("CMAKE_SKIP_RPATH")) {
     return false;
-    }
+  }
 
   // Skip chrpath if it does not need to be changed at install time.
-  if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
-    {
+  if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
     return false;
-    }
+  }
 
   // Allow the user to disable builtin chrpath explicitly.
-  if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH"))
-    {
+  if (this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) {
     return false;
-    }
+  }
 
-  if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
+  if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
     return true;
-    }
+  }
 
 #if defined(CMAKE_USE_ELF_PARSER)
   // Enable if the rpath flag uses a separator and the target uses ELF
   // binaries.
   std::string ll = this->GetLinkerLanguage(config);
-  if(!ll.empty())
-    {
+  if (!ll.empty()) {
     std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
     sepVar += ll;
     sepVar += "_FLAG_SEP";
     const char* sep = this->Makefile->GetDefinition(sepVar);
-    if(sep && *sep)
-      {
+    if (sep && *sep) {
       // TODO: Add ELF check to ABI detection and get rid of
       // CMAKE_EXECUTABLE_FORMAT.
-      if(const char* fmt =
-         this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT"))
-        {
+      if (const char* fmt =
+            this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) {
         return strcmp(fmt, "ELF") == 0;
-        }
       }
     }
+  }
 #endif
   static_cast<void>(config);
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName(
-                                          const std::string& config) const
+  const std::string& config) const
 {
-  if(this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY)
-    {
-    if(cmGeneratorTarget::ImportInfo const* info =
-       this->GetImportInfo(config))
-      {
+  if (this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) {
+    if (cmGeneratorTarget::ImportInfo const* info =
+          this->GetImportInfo(config)) {
       return info->NoSOName;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
-    const std::string& config) const
+  const std::string& config) const
 {
   bool install_name_is_rpath = false;
   bool macosx_rpath = false;
 
-  if(!this->IsImported())
-    {
-    if(this->GetType() != cmState::SHARED_LIBRARY)
-      {
+  if (!this->IsImported()) {
+    if (this->GetType() != cmState::SHARED_LIBRARY) {
       return false;
-      }
+    }
     const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
     bool use_install_name =
       this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
-    if(install_name && use_install_name &&
-       std::string(install_name) == "@rpath")
-      {
+    if (install_name && use_install_name &&
+        std::string(install_name) == "@rpath") {
       install_name_is_rpath = true;
-      }
-    else if(install_name && use_install_name)
-      {
+    } else if (install_name && use_install_name) {
       return false;
-      }
-    if(!install_name_is_rpath)
-      {
+    }
+    if (!install_name_is_rpath) {
       macosx_rpath = this->MacOSXRpathInstallNameDirDefault();
-      }
     }
-  else
-    {
+  } else {
     // Lookup the imported soname.
-    if(cmGeneratorTarget::ImportInfo const* info =
-       this->GetImportInfo(config))
-      {
-      if(!info->NoSOName && !info->SOName.empty())
-        {
-        if(info->SOName.find("@rpath/") == 0)
-          {
+    if (cmGeneratorTarget::ImportInfo const* info =
+          this->GetImportInfo(config)) {
+      if (!info->NoSOName && !info->SOName.empty()) {
+        if (info->SOName.find("@rpath/") == 0) {
           install_name_is_rpath = true;
-          }
         }
-      else
-        {
+      } else {
         std::string install_name;
         cmSystemTools::GuessLibraryInstallName(info->Location, install_name);
-        if(install_name.find("@rpath") != std::string::npos)
-          {
+        if (install_name.find("@rpath") != std::string::npos) {
           install_name_is_rpath = true;
-          }
         }
       }
     }
+  }
 
-  if(!install_name_is_rpath && !macosx_rpath)
-    {
+  if (!install_name_is_rpath && !macosx_rpath) {
     return false;
-    }
+  }
 
-  if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
-    {
+  if (!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) {
     std::ostringstream w;
     w << "Attempting to use";
-    if(macosx_rpath)
-      {
+    if (macosx_rpath) {
       w << " MACOSX_RPATH";
-      }
-    else
-      {
+    } else {
       w << " @rpath";
-      }
+    }
     w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set.";
     w << "  This could be because you are using a Mac OS X version";
     w << " less than 10.5 or because CMake's platform configuration is";
     w << " corrupt.";
     cmake* cm = this->LocalGenerator->GetCMakeInstance();
-    cm->IssueMessage(cmake::FATAL_ERROR, w.str(),
-                     this->GetBacktrace());
-    }
+    cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace());
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
 {
   // we can't do rpaths when unsupported
-  if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
-    {
+  if (!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) {
     return false;
-    }
+  }
 
   const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
-  if(macosx_rpath_str)
-    {
+  if (macosx_rpath_str) {
     return this->GetPropertyAsBool("MACOSX_RPATH");
-    }
+  }
 
   cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042();
 
-  if(cmp0042 == cmPolicies::WARN)
-    {
-    this->LocalGenerator->GetGlobalGenerator()->
-      AddCMP0042WarnTarget(this->GetName());
-    }
+  if (cmp0042 == cmPolicies::WARN) {
+    this->LocalGenerator->GetGlobalGenerator()->AddCMP0042WarnTarget(
+      this->GetName());
+  }
 
-  if(cmp0042 == cmPolicies::NEW)
-    {
+  if (cmp0042 == cmPolicies::NEW) {
     return true;
-    }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetSOName(const std::string& config) const
 {
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     // Lookup the imported soname.
-    if(cmGeneratorTarget::ImportInfo const* info =
-       this->GetImportInfo(config))
-      {
-      if(info->NoSOName)
-        {
+    if (cmGeneratorTarget::ImportInfo const* info =
+          this->GetImportInfo(config)) {
+      if (info->NoSOName) {
         // The imported library has no builtin soname so the name
         // searched at runtime will be just the filename.
         return cmSystemTools::GetFilenameName(info->Location);
-        }
-      else
-        {
+      } else {
         // Use the soname given if any.
-        if(info->SOName.find("@rpath/") == 0)
-          {
+        if (info->SOName.find("@rpath/") == 0) {
           return info->SOName.substr(6);
-          }
-        return info->SOName;
         }
+        return info->SOName;
       }
-    else
-      {
+    } else {
       return "";
-      }
     }
-  else
-    {
+  } else {
     // Compute the soname that will be built.
     std::string name;
     std::string soName;
     std::string realName;
     std::string impName;
     std::string pdbName;
-    this->GetLibraryNames(name, soName, realName,
-                          impName, pdbName, config);
+    this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
     return soName;
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
-                                         bool contentOnly) const
+std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
+                                                     bool contentOnly) const
 {
   std::string fpath = this->GetFullName(config, false);
   fpath += ".app";
-  if(!this->Makefile->PlatformIsAppleIos())
-    {
+  if (!this->Makefile->PlatformIsAppleIos()) {
     fpath += "/Contents";
-    if(!contentOnly)
+    if (!contentOnly)
       fpath += "/MacOS";
-    }
+  }
   return fpath;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsBundleOnApple() const
 {
-  return this->IsFrameworkOnApple()
-      || this->IsAppBundleOnApple()
-      || this->IsCFBundleOnApple();
+  return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() ||
+    this->IsCFBundleOnApple();
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config,
                                                     bool contentOnly) const
 {
   std::string fpath;
   fpath += this->GetOutputName(config, false);
   fpath += ".";
-  const char *ext = this->GetProperty("BUNDLE_EXTENSION");
-  if (!ext)
-    {
-    if (this->IsXCTestOnApple())
-      {
+  const char* ext = this->GetProperty("BUNDLE_EXTENSION");
+  if (!ext) {
+    if (this->IsXCTestOnApple()) {
       ext = "xctest";
-      }
-    else
-      {
+    } else {
       ext = "bundle";
-      }
     }
+  }
   fpath += ext;
-  if(!this->Makefile->PlatformIsAppleIos())
-  {
+  if (!this->Makefile->PlatformIsAppleIos()) {
     fpath += "/Contents";
-    if(!contentOnly)
+    if (!contentOnly)
       fpath += "/MacOS";
   }
   return fpath;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
-                                         bool rootDir) const
+std::string cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
+                                                     bool rootDir) const
 {
   std::string fpath;
   fpath += this->GetOutputName(config, false);
   fpath += ".framework";
-  if(!rootDir && !this->Makefile->PlatformIsAppleIos())
-    {
+  if (!rootDir && !this->Makefile->PlatformIsAppleIos()) {
     fpath += "/Versions/";
     fpath += this->GetFrameworkVersion();
-    }
+  }
   return fpath;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const
+std::string cmGeneratorTarget::GetFullName(const std::string& config,
+                                           bool implib) const
 {
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return this->GetFullNameImported(config, implib);
-    }
-  else
-    {
+  } else {
     return this->GetFullNameInternal(config, implib);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetInstallNameDirForBuildTree(
-                                            const std::string& config) const
+std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
+  const std::string& config) const
 {
   // If building directly for installation then the build tree install_name
   // is the same as the install tree.
-  if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
-    {
+  if (this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) {
     return this->GetInstallNameDirForInstallTree();
-    }
+  }
 
   // Use the build tree directory for the target.
-  if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
-     !this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
-     !this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
-    {
+  if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") &&
+      !this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
+      !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
     std::string dir;
-    if(this->MacOSXRpathInstallNameDirDefault())
-      {
+    if (this->MacOSXRpathInstallNameDirDefault()) {
       dir = "@rpath";
-      }
-    else
-      {
+    } else {
       dir = this->GetDirectory(config);
-      }
+    }
     dir += "/";
     return dir;
-    }
-  else
-    {
+  } else {
     return "";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
 {
-  if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
+  if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
     std::string dir;
     const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
 
-    if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
-       !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH"))
-      {
-      if(install_name_dir && *install_name_dir)
-        {
+    if (!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
+        !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) {
+      if (install_name_dir && *install_name_dir) {
         dir = install_name_dir;
         dir += "/";
-        }
       }
-    if(!install_name_dir)
-      {
-      if(this->MacOSXRpathInstallNameDirDefault())
-        {
+    }
+    if (!install_name_dir) {
+      if (this->MacOSXRpathInstallNameDirDefault()) {
         dir = "@rpath/";
-        }
       }
-    return dir;
     }
-  else
-    {
+    return dir;
+  } else {
     return "";
-    }
+  }
 }
 
 cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
@@ -1737,7 +1465,7 @@ cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
   return this->Target->GetBacktrace();
 }
 
-const std::vector<std::string>&cmGeneratorTarget::GetLinkDirectories() const
+const std::vector<std::string>& cmGeneratorTarget::GetLinkDirectories() const
 {
   return this->Target->GetLinkDirectories();
 }
@@ -1747,78 +1475,67 @@ const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
   return this->Target->GetUtilities();
 }
 
-const cmListFileBacktrace*
-cmGeneratorTarget::GetUtilityBacktrace(const std::string& u) const
+const cmListFileBacktrace* cmGeneratorTarget::GetUtilityBacktrace(
+  const std::string& u) const
 {
   return this->Target->GetUtilityBacktrace(u);
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
 {
-  return
-    this->GetType() == cmState::STATIC_LIBRARY ||
+  return this->GetType() == cmState::STATIC_LIBRARY ||
     this->GetType() == cmState::SHARED_LIBRARY ||
     this->GetType() == cmState::MODULE_LIBRARY ||
     this->GetType() == cmState::EXECUTABLE;
 }
 
-//----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetExportMacro() const
 {
   // Define the symbol for targets that export symbols.
-  if(this->GetType() == cmState::SHARED_LIBRARY ||
-     this->GetType() == cmState::MODULE_LIBRARY ||
-     this->IsExecutableWithExports())
-    {
-    if(const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL"))
-      {
+  if (this->GetType() == cmState::SHARED_LIBRARY ||
+      this->GetType() == cmState::MODULE_LIBRARY ||
+      this->IsExecutableWithExports()) {
+    if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
       this->ExportMacro = custom_export_name;
-      }
-    else
-      {
+    } else {
       std::string in = this->GetName();
       in += "_EXPORTS";
       this->ExportMacro = cmSystemTools::MakeCidentifier(in);
-      }
-    return this->ExportMacro.c_str();
     }
-  else
-    {
+    return this->ExportMacro.c_str();
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 class cmTargetCollectLinkLanguages
 {
 public:
   cmTargetCollectLinkLanguages(cmGeneratorTarget const* target,
                                const std::string& config,
                                UNORDERED_SET<std::string>& languages,
-                               cmGeneratorTarget const* head):
-    Config(config), Languages(languages), HeadTarget(head),
-    Target(target)
-  { this->Visited.insert(target); }
+                               cmGeneratorTarget const* head)
+    : Config(config)
+    , Languages(languages)
+    , HeadTarget(head)
+    , Target(target)
+  {
+    this->Visited.insert(target);
+  }
 
   void Visit(cmLinkItem const& item)
-    {
-    if(!item.Target)
-      {
-      if(item.find("::") != std::string::npos)
-        {
+  {
+    if (!item.Target) {
+      if (item.find("::") != std::string::npos) {
         bool noMessage = false;
         cmake::MessageType messageType = cmake::FATAL_ERROR;
         std::stringstream e;
-        switch(this->Target->GetLocalGenerator()
-               ->GetPolicyStatus(cmPolicies::CMP0028))
-          {
-          case cmPolicies::WARN:
-            {
+        switch (this->Target->GetLocalGenerator()->GetPolicyStatus(
+          cmPolicies::CMP0028)) {
+          case cmPolicies::WARN: {
             e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n";
             messageType = cmake::AUTHOR_WARNING;
-            }
-            break;
+          } break;
           case cmPolicies::OLD:
             noMessage = true;
           case cmPolicies::REQUIRED_IF_USED:
@@ -1826,41 +1543,41 @@ public:
           case cmPolicies::NEW:
             // Issue the fatal message.
             break;
-          }
+        }
 
-        if(!noMessage)
-          {
+        if (!noMessage) {
           e << "Target \"" << this->Target->GetName()
             << "\" links to target \"" << item
             << "\" but the target was not found.  Perhaps a find_package() "
-            "call is missing for an IMPORTED target, or an ALIAS target is "
-            "missing?";
+               "call is missing for an IMPORTED target, or an ALIAS target is "
+               "missing?";
           this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
             messageType, e.str(), this->Target->GetBacktrace());
-          }
         }
-      return;
       }
-    if(!this->Visited.insert(item.Target).second)
-      {
       return;
-      }
+    }
+    if (!this->Visited.insert(item.Target).second) {
+      return;
+    }
     cmLinkInterface const* iface =
       item.Target->GetLinkInterface(this->Config, this->HeadTarget);
-    if(!iface) { return; }
+    if (!iface) {
+      return;
+    }
 
-    for(std::vector<std::string>::const_iterator
-          li = iface->Languages.begin(); li != iface->Languages.end(); ++li)
-      {
+    for (std::vector<std::string>::const_iterator li =
+           iface->Languages.begin();
+         li != iface->Languages.end(); ++li) {
       this->Languages.insert(*li);
-      }
+    }
 
-    for(std::vector<cmLinkItem>::const_iterator
-          li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li)
-      {
+    for (std::vector<cmLinkItem>::const_iterator li = iface->Libraries.begin();
+         li != iface->Libraries.end(); ++li) {
       this->Visit(*li);
-      }
     }
+  }
+
 private:
   std::string Config;
   UNORDERED_SET<std::string>& Languages;
@@ -1869,142 +1586,122 @@ private:
   std::set<cmGeneratorTarget const*> Visited;
 };
 
-//----------------------------------------------------------------------------
-cmGeneratorTarget::LinkClosure const*
-cmGeneratorTarget::GetLinkClosure(const std::string& config) const
+cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure(
+  const std::string& config) const
 {
   std::string key(cmSystemTools::UpperCase(config));
-  LinkClosureMapType::iterator
-    i = this->LinkClosureMap.find(key);
-  if(i == this->LinkClosureMap.end())
-    {
+  LinkClosureMapType::iterator i = this->LinkClosureMap.find(key);
+  if (i == this->LinkClosureMap.end()) {
     LinkClosure lc;
     this->ComputeLinkClosure(config, lc);
     LinkClosureMapType::value_type entry(key, lc);
     i = this->LinkClosureMap.insert(entry).first;
-    }
+  }
   return &i->second;
 }
 
-//----------------------------------------------------------------------------
 class cmTargetSelectLinker
 {
   int Preference;
   cmGeneratorTarget const* Target;
   cmGlobalGenerator* GG;
   std::set<std::string> Preferred;
+
 public:
   cmTargetSelectLinker(cmGeneratorTarget const* target)
-      : Preference(0), Target(target)
-    {
+    : Preference(0)
+    , Target(target)
+  {
     this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator();
-    }
+  }
   void Consider(const char* lang)
-    {
+  {
     int preference = this->GG->GetLinkerPreference(lang);
-    if(preference > this->Preference)
-      {
+    if (preference > this->Preference) {
       this->Preference = preference;
       this->Preferred.clear();
-      }
-    if(preference == this->Preference)
-      {
+    }
+    if (preference == this->Preference) {
       this->Preferred.insert(lang);
-      }
     }
+  }
   std::string Choose()
-    {
-    if(this->Preferred.empty())
-      {
+  {
+    if (this->Preferred.empty()) {
       return "";
-      }
-    else if(this->Preferred.size() > 1)
-      {
+    } else if (this->Preferred.size() > 1) {
       std::stringstream e;
       e << "Target " << this->Target->GetName()
         << " contains multiple languages with the highest linker preference"
         << " (" << this->Preference << "):\n";
-      for(std::set<std::string>::const_iterator
-            li = this->Preferred.begin(); li != this->Preferred.end(); ++li)
-        {
+      for (std::set<std::string>::const_iterator li = this->Preferred.begin();
+           li != this->Preferred.end(); ++li) {
         e << "  " << *li << "\n";
-        }
+      }
       e << "Set the LINKER_LANGUAGE property for this target.";
       cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
       cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
                        this->Target->GetBacktrace());
-      }
-    return *this->Preferred.begin();
     }
+    return *this->Preferred.begin();
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
                                            LinkClosure& lc) const
 {
   // Get languages built in this target.
   UNORDERED_SET<std::string> languages;
-  cmLinkImplementation const* impl =
-                            this->GetLinkImplementation(config);
+  cmLinkImplementation const* impl = this->GetLinkImplementation(config);
   assert(impl);
-  for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
-      li != impl->Languages.end(); ++li)
-    {
+  for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
+       li != impl->Languages.end(); ++li) {
     languages.insert(*li);
-    }
+  }
 
   // Add interface languages from linked targets.
   cmTargetCollectLinkLanguages cll(this, config, languages, this);
-  for(std::vector<cmLinkImplItem>::const_iterator li = impl->Libraries.begin();
-      li != impl->Libraries.end(); ++li)
-    {
+  for (std::vector<cmLinkImplItem>::const_iterator li =
+         impl->Libraries.begin();
+       li != impl->Libraries.end(); ++li) {
     cll.Visit(*li);
-    }
+  }
 
   // Store the transitive closure of languages.
-  for(UNORDERED_SET<std::string>::const_iterator li = languages.begin();
-      li != languages.end(); ++li)
-    {
+  for (UNORDERED_SET<std::string>::const_iterator li = languages.begin();
+       li != languages.end(); ++li) {
     lc.Languages.push_back(*li);
-    }
+  }
 
   // Choose the language whose linker should be used.
-  if(this->GetProperty("HAS_CXX"))
-    {
+  if (this->GetProperty("HAS_CXX")) {
     lc.LinkerLanguage = "CXX";
-    }
-  else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE"))
-    {
+  } else if (const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) {
     lc.LinkerLanguage = linkerLang;
-    }
-  else
-    {
+  } else {
     // Find the language with the highest preference value.
     cmTargetSelectLinker tsl(this);
 
     // First select from the languages compiled directly in this target.
-    for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
-        li != impl->Languages.end(); ++li)
-      {
+    for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
+         li != impl->Languages.end(); ++li) {
       tsl.Consider(li->c_str());
-      }
+    }
 
     // Now consider languages that propagate from linked targets.
-    for(UNORDERED_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))
-        {
+    for (UNORDERED_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)) {
         tsl.Consider(sit->c_str());
-        }
       }
+    }
 
     lc.LinkerLanguage = tsl.Choose();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
                                               std::string& base,
                                               std::string& suffix,
@@ -2014,97 +1711,80 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix,
   this->GetFullNameInternal(config, implib, prefix, base, suffix);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::BuildMacContentDirectory(const std::string& base,
-                                            const std::string& config,
-                                            bool contentOnly) const
+std::string cmGeneratorTarget::BuildMacContentDirectory(
+  const std::string& base, const std::string& config, bool contentOnly) const
 {
   std::string fpath = base;
-  if(this->IsAppBundleOnApple())
-    {
+  if (this->IsAppBundleOnApple()) {
     fpath += this->GetAppBundleDirectory(config, contentOnly);
-    }
-  if(this->IsFrameworkOnApple())
-    {
+  }
+  if (this->IsFrameworkOnApple()) {
     fpath += this->GetFrameworkDirectory(config, contentOnly);
-    }
-  if(this->IsCFBundleOnApple())
-    {
+  }
+  if (this->IsCFBundleOnApple()) {
     fpath += this->GetCFBundleDirectory(config, contentOnly);
-    }
+  }
   return fpath;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetMacContentDirectory(const std::string& config,
-                                          bool implib) const
+std::string cmGeneratorTarget::GetMacContentDirectory(
+  const std::string& config, bool implib) const
 {
   // Start with the output directory for the target.
   std::string fpath = this->GetDirectory(config, implib);
   fpath += "/";
   bool contentOnly = true;
-  if(this->IsFrameworkOnApple())
-    {
+  if (this->IsFrameworkOnApple()) {
     // additional files with a framework go into the version specific
     // directory
     contentOnly = false;
-    }
+  }
   fpath = this->BuildMacContentDirectory(fpath, config, contentOnly);
   return fpath;
 }
 
-
-//----------------------------------------------------------------------------
 cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
-                                            const std::string& config) const
+  const std::string& config) const
 {
   // There is no compile information for imported targets.
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return 0;
-    }
+  }
 
-  if(this->GetType() > cmState::OBJECT_LIBRARY)
-    {
+  if (this->GetType() > cmState::OBJECT_LIBRARY) {
     std::string msg = "cmTarget::GetCompileInfo called for ";
     msg += this->GetName();
     msg += " which has type ";
     msg += cmState::GetTargetTypeName(this->GetType());
     this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
     return 0;
-    }
+  }
 
   // Lookup/compute/cache the compile information for this configuration.
   std::string config_upper;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     config_upper = cmSystemTools::UpperCase(config);
-    }
+  }
   CompileInfoMapType::const_iterator i =
     this->CompileInfoMap.find(config_upper);
-  if(i == this->CompileInfoMap.end())
-    {
+  if (i == this->CompileInfoMap.end()) {
     CompileInfo info;
     this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir);
     CompileInfoMapType::value_type entry(config_upper, info);
     i = this->CompileInfoMap.insert(entry).first;
-    }
+  }
   return &i->second;
 }
 
-//----------------------------------------------------------------------------
-cmSourceFile const*
-cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const
+cmSourceFile const* cmGeneratorTarget::GetModuleDefinitionFile(
+  const std::string& config) const
 {
   std::vector<cmSourceFile const*> data;
   IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile,
                        COMMA std::vector<cmSourceFile const*>)
-  if(!data.empty())
-    {
+  if (!data.empty()) {
     return data.front();
-    }
+  }
 
   return 0;
 }
@@ -2114,128 +1794,106 @@ bool cmGeneratorTarget::IsDLLPlatform() const
   return this->DLLPlatform;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
-                                      const std::string &config) const
+void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
+                                           const std::string& config) const
 {
   std::vector<cmSourceFile const*> objectFiles;
   this->GetExternalObjects(objectFiles, config);
   std::vector<cmGeneratorTarget*> objectLibraries;
-  for(std::vector<cmSourceFile const*>::const_iterator
-      it = objectFiles.begin(); it != objectFiles.end(); ++it)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator it =
+         objectFiles.begin();
+       it != objectFiles.end(); ++it) {
     std::string objLib = (*it)->GetObjectLibrary();
     if (cmGeneratorTarget* tgt =
-        this->LocalGenerator->FindGeneratorTargetToUse(objLib))
-      {
+          this->LocalGenerator->FindGeneratorTargetToUse(objLib)) {
       objectLibraries.push_back(tgt);
-      }
     }
+  }
 
-  std::vector<cmGeneratorTarget*>::const_iterator end
-      = cmRemoveDuplicates(objectLibraries);
+  std::vector<cmGeneratorTarget*>::const_iterator end =
+    cmRemoveDuplicates(objectLibraries);
 
-  for(std::vector<cmGeneratorTarget*>::const_iterator
-        ti = objectLibraries.begin();
-      ti != end; ++ti)
-    {
+  for (std::vector<cmGeneratorTarget*>::const_iterator ti =
+         objectLibraries.begin();
+       ti != end; ++ti) {
     cmGeneratorTarget* ogt = *ti;
     std::vector<cmSourceFile const*> objectSources;
     ogt->GetObjectSources(objectSources, config);
-    for(std::vector<cmSourceFile const*>::const_iterator
-          si = objectSources.begin();
-        si != objectSources.end(); ++si)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator si =
+           objectSources.begin();
+         si != objectSources.end(); ++si) {
       std::string obj = ogt->ObjectDirectory;
       obj += ogt->Objects[*si];
       objs.push_back(obj);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string> &result,
-                                 const std::string& config) const
+void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
+                                          const std::string& config) const
 {
-  const char *prop
-            = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS",
-                                                            config);
-  if (!prop)
-    {
+  const char* prop =
+    this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config);
+  if (!prop) {
     return;
-    }
+  }
   cmGeneratorExpression ge;
 
-  cmGeneratorExpressionDAGChecker dagChecker(
-                                      this->GetName(),
-                                      "AUTOUIC_OPTIONS", 0, 0);
-  cmSystemTools::ExpandListArgument(ge.Parse(prop)
-                                      ->Evaluate(this->LocalGenerator,
-                                                config,
-                                                false,
-                                                this,
-                                                &dagChecker),
-                                  result);
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                             "AUTOUIC_OPTIONS", 0, 0);
+  cmSystemTools::ExpandListArgument(
+    ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, this,
+                             &dagChecker),
+    result);
 }
 
-//----------------------------------------------------------------------------
 void processILibs(const std::string& config,
-                  cmGeneratorTarget const* headTarget,
-                  cmLinkItem const& item,
+                  cmGeneratorTarget const* headTarget, cmLinkItem const& item,
                   cmGlobalGenerator* gg,
                   std::vector<cmGeneratorTarget const*>& tgts,
                   std::set<cmGeneratorTarget const*>& emitted)
 {
-  if (item.Target && emitted.insert(item.Target).second)
-    {
+  if (item.Target && emitted.insert(item.Target).second) {
     tgts.push_back(item.Target);
-    if(cmLinkInterfaceLibraries const* iface =
-       item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
-      {
-      for(std::vector<cmLinkItem>::const_iterator
-            it = iface->Libraries.begin();
-          it != iface->Libraries.end(); ++it)
-        {
+    if (cmLinkInterfaceLibraries const* iface =
+          item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) {
+      for (std::vector<cmLinkItem>::const_iterator it =
+             iface->Libraries.begin();
+           it != iface->Libraries.end(); ++it) {
         processILibs(config, headTarget, *it, gg, tgts, emitted);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 const std::vector<const cmGeneratorTarget*>&
 cmGeneratorTarget::GetLinkImplementationClosure(
-    const std::string& config) const
+  const std::string& config) const
 {
-  LinkImplClosure& tgts =
-    this->LinkImplClosureMap[config];
-  if(!tgts.Done)
-    {
+  LinkImplClosure& tgts = this->LinkImplClosureMap[config];
+  if (!tgts.Done) {
     tgts.Done = true;
     std::set<cmGeneratorTarget const*> emitted;
 
-    cmLinkImplementationLibraries const* impl
-      = this->GetLinkImplementationLibraries(config);
+    cmLinkImplementationLibraries const* impl =
+      this->GetLinkImplementationLibraries(config);
 
-    for(std::vector<cmLinkImplItem>::const_iterator
-          it = impl->Libraries.begin();
-        it != impl->Libraries.end(); ++it)
-      {
+    for (std::vector<cmLinkImplItem>::const_iterator it =
+           impl->Libraries.begin();
+         it != impl->Libraries.end(); ++it) {
       processILibs(config, this, *it,
-                   this->LocalGenerator->GetGlobalGenerator(),
-                   tgts , emitted);
-      }
+                   this->LocalGenerator->GetGlobalGenerator(), tgts, emitted);
     }
+  }
   return tgts;
 }
 
-//----------------------------------------------------------------------------
 class cmTargetTraceDependencies
 {
 public:
   cmTargetTraceDependencies(cmGeneratorTarget* target);
   void Trace();
+
 private:
   cmGeneratorTarget* GeneratorTarget;
   cmMakefile* Makefile;
@@ -2260,10 +1918,8 @@ private:
                             std::set<std::string>& emitted);
 };
 
-//----------------------------------------------------------------------------
-cmTargetTraceDependencies
-::cmTargetTraceDependencies(cmGeneratorTarget* target):
-  GeneratorTarget(target)
+cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
+  : GeneratorTarget(target)
 {
   // Convenience.
   this->Makefile = target->Target->GetMakefile();
@@ -2272,79 +1928,66 @@ cmTargetTraceDependencies
   this->CurrentEntry = 0;
 
   // Queue all the source files already specified for the target.
-  if (target->GetType() != cmState::INTERFACE_LIBRARY)
-    {
+  if (target->GetType() != cmState::INTERFACE_LIBRARY) {
     std::vector<std::string> configs;
     this->Makefile->GetConfigurations(configs);
-    if (configs.empty())
-      {
+    if (configs.empty()) {
       configs.push_back("");
-      }
+    }
     std::set<cmSourceFile*> emitted;
-    for(std::vector<std::string>::const_iterator ci = configs.begin();
-        ci != configs.end(); ++ci)
-      {
+    for (std::vector<std::string>::const_iterator ci = configs.begin();
+         ci != configs.end(); ++ci) {
       std::vector<cmSourceFile*> sources;
       this->GeneratorTarget->GetSourceFiles(sources, *ci);
-      for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
-          si != sources.end(); ++si)
-        {
+      for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+           si != sources.end(); ++si) {
         cmSourceFile* sf = *si;
         const std::set<cmGeneratorTarget const*> tgts =
-                          this->GlobalGenerator->GetFilenameTargetDepends(sf);
-        if (tgts.find(this->GeneratorTarget) != tgts.end())
-          {
+          this->GlobalGenerator->GetFilenameTargetDepends(sf);
+        if (tgts.find(this->GeneratorTarget) != tgts.end()) {
           std::ostringstream e;
           e << "Evaluation output file\n  \"" << sf->GetFullPath()
             << "\"\ndepends on the sources of a target it is used in.  This "
-              "is a dependency loop and is not allowed.";
-          this->GeneratorTarget
-              ->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
+               "is a dependency loop and is not allowed.";
+          this->GeneratorTarget->LocalGenerator->IssueMessage(
+            cmake::FATAL_ERROR, e.str());
           return;
-          }
-        if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second)
-          {
+        }
+        if (emitted.insert(sf).second &&
+            this->SourcesQueued.insert(sf).second) {
           this->SourceQueue.push(sf);
-          }
         }
       }
     }
+  }
 
   // Queue pre-build, pre-link, and post-build rule dependencies.
-  this->CheckCustomCommands(
-        this->GeneratorTarget->GetPreBuildCommands());
-  this->CheckCustomCommands(
-        this->GeneratorTarget->GetPreLinkCommands());
-  this->CheckCustomCommands(
-        this->GeneratorTarget->GetPostBuildCommands());
+  this->CheckCustomCommands(this->GeneratorTarget->GetPreBuildCommands());
+  this->CheckCustomCommands(this->GeneratorTarget->GetPreLinkCommands());
+  this->CheckCustomCommands(this->GeneratorTarget->GetPostBuildCommands());
 }
 
-//----------------------------------------------------------------------------
 void cmTargetTraceDependencies::Trace()
 {
   // Process one dependency at a time until the queue is empty.
-  while(!this->SourceQueue.empty())
-    {
+  while (!this->SourceQueue.empty()) {
     // Get the next source from the queue.
     cmSourceFile* sf = this->SourceQueue.front();
     this->SourceQueue.pop();
     this->CurrentEntry = &this->GeneratorTarget->SourceDepends[sf];
 
     // Queue dependencies added explicitly by the user.
-    if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS"))
-      {
+    if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) {
       std::vector<std::string> objDeps;
       cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
-      for(std::vector<std::string>::iterator odi = objDeps.begin();
-          odi != objDeps.end(); ++odi)
-        {
-        if (cmSystemTools::FileIsFullPath(*odi))
-          {
+      for (std::vector<std::string>::iterator odi = objDeps.begin();
+           odi != objDeps.end(); ++odi) {
+        if (cmSystemTools::FileIsFullPath(*odi)) {
           *odi = cmSystemTools::CollapseFullPath(*odi);
-          }
         }
-      this->FollowNames(objDeps);
       }
+      this->FollowNames(objDeps);
+    }
 
     // Queue the source needed to generate this file, if any.
     this->FollowName(sf->GetFullPath());
@@ -2353,62 +1996,52 @@ void cmTargetTraceDependencies::Trace()
     this->FollowNames(sf->GetDepends());
 
     // Queue custom command dependencies.
-    if(cmCustomCommand const* cc = sf->GetCustomCommand())
-      {
+    if (cmCustomCommand const* cc = sf->GetCustomCommand()) {
       this->CheckCustomCommand(*cc);
-      }
     }
+  }
   this->CurrentEntry = 0;
 
   this->GeneratorTarget->AddTracedSources(this->NewSources);
 }
 
-//----------------------------------------------------------------------------
 void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
 {
-  if(this->SourcesQueued.insert(sf).second)
-    {
+  if (this->SourcesQueued.insert(sf).second) {
     this->SourceQueue.push(sf);
 
     // Make sure this file is in the target at the end.
     this->NewSources.push_back(sf->GetFullPath());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTargetTraceDependencies::FollowName(std::string const& name)
 {
   NameMapType::iterator i = this->NameMap.find(name);
-  if(i == this->NameMap.end())
-    {
+  if (i == this->NameMap.end()) {
     // Check if we know how to generate this file.
     cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name);
     NameMapType::value_type entry(name, sf);
     i = this->NameMap.insert(entry).first;
-    }
-  if(cmSourceFile* sf = i->second)
-    {
+  }
+  if (cmSourceFile* sf = i->second) {
     // Record the dependency we just followed.
-    if(this->CurrentEntry)
-      {
+    if (this->CurrentEntry) {
       this->CurrentEntry->Depends.push_back(sf);
-      }
-    this->QueueSource(sf);
     }
+    this->QueueSource(sf);
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names)
+void cmTargetTraceDependencies::FollowNames(
+  std::vector<std::string> const& names)
 {
-  for(std::vector<std::string>::const_iterator i = names.begin();
-      i != names.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = names.begin();
+       i != names.end(); ++i) {
     this->FollowName(*i);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
 {
   // Dependencies on targets (utilities) are supposed to be named by
@@ -2418,24 +2051,20 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
   // that case the target name will be the file basename of the
   // dependency.
   std::string util = cmSystemTools::GetFilenameName(dep);
-  if(cmSystemTools::GetFilenameLastExtension(util) == ".exe")
-    {
+  if (cmSystemTools::GetFilenameLastExtension(util) == ".exe") {
     util = cmSystemTools::GetFilenameWithoutLastExtension(util);
-    }
+  }
 
   // Check for a target with this name.
-  if(cmGeneratorTarget* t
-                    = this->GeneratorTarget->
-                    GetLocalGenerator()->FindGeneratorTargetToUse(util))
-    {
+  if (cmGeneratorTarget* t =
+        this->GeneratorTarget->GetLocalGenerator()->FindGeneratorTargetToUse(
+          util)) {
     // If we find the target and the dep was given as a full path,
     // then make sure it was not a full path to something else, and
     // the fact that the name matched a target was just a coincidence.
-    if(cmSystemTools::FileIsFullPath(dep.c_str()))
-      {
-      if(t->GetType() >= cmState::EXECUTABLE &&
-         t->GetType() <= cmState::MODULE_LIBRARY)
-        {
+    if (cmSystemTools::FileIsFullPath(dep.c_str())) {
+      if (t->GetType() >= cmState::EXECUTABLE &&
+          t->GetType() <= cmState::MODULE_LIBRARY) {
         // This is really only for compatibility so we do not need to
         // worry about configuration names and output names.
         std::string tLocation = t->GetLocationForBuild();
@@ -2443,30 +2072,24 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
         std::string depLocation = cmSystemTools::GetFilenamePath(dep);
         depLocation = cmSystemTools::CollapseFullPath(depLocation);
         tLocation = cmSystemTools::CollapseFullPath(tLocation);
-        if(depLocation == tLocation)
-          {
+        if (depLocation == tLocation) {
           this->GeneratorTarget->Target->AddUtility(util);
           return true;
-          }
         }
       }
-    else
-      {
+    } else {
       // The original name of the dependency was not a full path.  It
       // must name a target, so add the target-level dependency.
       this->GeneratorTarget->Target->AddUtility(util);
       return true;
-      }
     }
+  }
 
   // The dependency does not name a target built in this project.
   return false;
 }
 
-//----------------------------------------------------------------------------
-void
-cmTargetTraceDependencies
-::CheckCustomCommand(cmCustomCommand const& cc)
+void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
 {
   // Transform command names that reference targets built in this
   // project to corresponding target-level dependencies.
@@ -2475,164 +2098,136 @@ cmTargetTraceDependencies
   // Add target-level dependencies referenced by generator expressions.
   std::set<cmGeneratorTarget*> targets;
 
-  for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
-      cit != cc.GetCommandLines().end(); ++cit)
-    {
+  for (cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
+       cit != cc.GetCommandLines().end(); ++cit) {
     std::string const& command = *cit->begin();
     // Check for a target with this name.
-    if(cmGeneratorTarget* t =
-       this->LocalGenerator->FindGeneratorTargetToUse(command))
-      {
-      if(t->GetType() == cmState::EXECUTABLE)
-        {
+    if (cmGeneratorTarget* t =
+          this->LocalGenerator->FindGeneratorTargetToUse(command)) {
+      if (t->GetType() == cmState::EXECUTABLE) {
         // The command refers to an executable target built in
         // this project.  Add the target-level dependency to make
         // sure the executable is up to date before this custom
         // command possibly runs.
         this->GeneratorTarget->Target->AddUtility(command);
-        }
       }
+    }
 
     // Check for target references in generator expressions.
-    for(cmCustomCommandLine::const_iterator cli = cit->begin();
-        cli != cit->end(); ++cli)
-      {
-      const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
-                                                              = ge.Parse(*cli);
+    for (cmCustomCommandLine::const_iterator cli = cit->begin();
+         cli != cit->end(); ++cli) {
+      const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+        ge.Parse(*cli);
       cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
       std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
       targets.insert(geTargets.begin(), geTargets.end());
-      }
     }
+  }
 
-  for(std::set<cmGeneratorTarget*>::iterator ti = targets.begin();
-      ti != targets.end(); ++ti)
-    {
+  for (std::set<cmGeneratorTarget*>::iterator ti = targets.begin();
+       ti != targets.end(); ++ti) {
     this->GeneratorTarget->Target->AddUtility((*ti)->GetName());
-    }
+  }
 
   // Queue the custom command dependencies.
   std::vector<std::string> configs;
   std::set<std::string> emitted;
   this->Makefile->GetConfigurations(configs);
-  if (configs.empty())
-    {
+  if (configs.empty()) {
     configs.push_back("");
-    }
-  for(std::vector<std::string>::const_iterator ci = configs.begin();
-      ci != configs.end(); ++ci)
-    {
+  }
+  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)
+void cmTargetTraceDependencies::FollowCommandDepends(
+  cmCustomCommand const& cc, const std::string& config,
+  std::set<std::string>& emitted)
 {
   cmCustomCommandGenerator ccg(cc, config,
                                this->GeneratorTarget->LocalGenerator);
 
   const std::vector<std::string>& depends = ccg.GetDepends();
 
-  for(std::vector<std::string>::const_iterator di = depends.begin();
-      di != depends.end(); ++di)
-    {
+  for (std::vector<std::string>::const_iterator di = depends.begin();
+       di != depends.end(); ++di) {
     std::string const& dep = *di;
-    if(emitted.insert(dep).second)
-      {
-      if(!this->IsUtility(dep))
-        {
+    if (emitted.insert(dep).second) {
+      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);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmTargetTraceDependencies
-::CheckCustomCommands(const std::vector<cmCustomCommand>& commands)
+void cmTargetTraceDependencies::CheckCustomCommands(
+  const std::vector<cmCustomCommand>& commands)
 {
-  for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
-      cli != commands.end(); ++cli)
-    {
+  for (std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
+       cli != commands.end(); ++cli) {
     this->CheckCustomCommand(*cli);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::TraceDependencies()
 {
   // CMake-generated targets have no dependencies to trace.  Normally tracing
   // would find nothing anyway, but when building CMake itself the "install"
   // target command ends up referencing the "cmake" target but we do not
   // really want the dependency because "install" depend on "all" anyway.
-  if(this->GetType() == cmState::GLOBAL_TARGET)
-    {
+  if (this->GetType() == cmState::GLOBAL_TARGET) {
     return;
-    }
+  }
 
   // Use a helper object to trace the dependencies.
   cmTargetTraceDependencies tracer(this);
   tracer.Trace();
 }
 
-std::string
-cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const
+std::string cmGeneratorTarget::GetCompilePDBDirectory(
+  const std::string& config) const
 {
-  if(CompileInfo const* info = this->GetCompileInfo(config))
-    {
+  if (CompileInfo const* info = this->GetCompileInfo(config)) {
     return info->CompilePdbDir;
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetAppleArchs(const std::string& config,
-                             std::vector<std::string>& archVec) const
+                                      std::vector<std::string>& archVec) const
 {
   const char* archs = 0;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     std::string defVarName = "OSX_ARCHITECTURES_";
     defVarName += cmSystemTools::UpperCase(config);
     archs = this->GetProperty(defVarName);
-    }
-  if(!archs)
-    {
+  }
+  if (!archs) {
     archs = this->GetProperty("OSX_ARCHITECTURES");
-    }
-  if(archs)
-    {
+  }
+  if (archs) {
     cmSystemTools::ExpandListArgument(std::string(archs), archVec);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang,
-                                         std::string const& config) const
+std::string cmGeneratorTarget::GetCreateRuleVariable(
+  std::string const& lang, std::string const& config) const
 {
-  switch(this->GetType())
-    {
-    case cmState::STATIC_LIBRARY:
-      {
+  switch (this->GetType()) {
+    case cmState::STATIC_LIBRARY: {
       std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY";
-      if(this->GetFeatureAsBool(
-           "INTERPROCEDURAL_OPTIMIZATION", config))
-        {
+      if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) {
         std::string varIPO = var + "_IPO";
-        if(this->Makefile->GetDefinition(varIPO))
-          {
+        if (this->Makefile->GetDefinition(varIPO)) {
           return varIPO;
-          }
         }
-      return var;
       }
+      return var;
+    }
     case cmState::SHARED_LIBRARY:
       return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY";
     case cmState::MODULE_LIBRARY:
@@ -2641,47 +2236,39 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang,
       return "CMAKE_" + lang + "_LINK_EXECUTABLE";
     default:
       break;
-    }
+  }
   return "";
 }
-//----------------------------------------------------------------------------
-static void processIncludeDirectories(cmGeneratorTarget const* tgt,
-      const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
-      std::vector<std::string> &includes,
-      UNORDERED_SET<std::string> &uniqueIncludes,
-      cmGeneratorExpressionDAGChecker *dagChecker,
-      const std::string& config, bool debugIncludes,
-      const std::string& language)
-{
-  for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator
-      it = entries.begin(), end = entries.end(); it != end; ++it)
-    {
+static void processIncludeDirectories(
+  cmGeneratorTarget const* tgt,
+  const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+  std::vector<std::string>& includes,
+  UNORDERED_SET<std::string>& uniqueIncludes,
+  cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
+  bool debugIncludes, const std::string& language)
+{
+  for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
+         it = entries.begin(),
+         end = entries.end();
+       it != end; ++it) {
     cmLinkImplItem const& item = (*it)->LinkImplItem;
     std::string const& targetName = item;
     bool const fromImported = item.Target && item.Target->IsImported();
     bool const checkCMP0027 = item.FromGenex;
     std::vector<std::string> entryIncludes;
-    cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(
-                                        tgt->GetLocalGenerator(),
-                                              config,
-                                              false,
-                                              tgt,
-                                              dagChecker, language),
-                                    entryIncludes);
+    cmSystemTools::ExpandListArgument(
+      (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
+                          dagChecker, language),
+      entryIncludes);
 
     std::string usedIncludes;
-    for(std::vector<std::string>::iterator
-          li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
-      {
-      if (fromImported
-          && !cmSystemTools::FileExists(li->c_str()))
-        {
+    for (std::vector<std::string>::iterator li = entryIncludes.begin();
+         li != entryIncludes.end(); ++li) {
+      if (fromImported && !cmSystemTools::FileExists(li->c_str())) {
         std::ostringstream e;
         cmake::MessageType messageType = cmake::FATAL_ERROR;
-        if (checkCMP0027)
-          {
-          switch(tgt->GetPolicyStatusCMP0027())
-            {
+        if (checkCMP0027) {
+          switch (tgt->GetPolicyStatusCMP0027()) {
             case cmPolicies::WARN:
               e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
             case cmPolicies::OLD:
@@ -2691,8 +2278,9 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt,
             case cmPolicies::REQUIRED_IF_USED:
             case cmPolicies::NEW:
               break;
-            }
           }
+        }
+        /* clang-format off */
         e << "Imported target \"" << targetName << "\" includes "
              "non-existent path\n  \"" << *li << "\"\nin its "
              "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
@@ -2702,31 +2290,27 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt,
              "successfully.\n"
              "* The installation package was faulty and references files it "
              "does not provide.\n";
+        /* clang-format on */
         tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
         return;
-        }
+      }
 
-      if (!cmSystemTools::FileIsFullPath(li->c_str()))
-        {
+      if (!cmSystemTools::FileIsFullPath(li->c_str())) {
         std::ostringstream e;
         bool noMessage = false;
         cmake::MessageType messageType = cmake::FATAL_ERROR;
-        if (!targetName.empty())
-          {
+        if (!targetName.empty()) {
+          /* clang-format off */
           e << "Target \"" << targetName << "\" contains relative "
             "path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
             "  \"" << *li << "\"";
-          }
-        else
-          {
-          switch(tgt->GetPolicyStatusCMP0021())
-            {
-            case cmPolicies::WARN:
-              {
+          /* clang-format on */
+        } else {
+          switch (tgt->GetPolicyStatusCMP0021()) {
+            case cmPolicies::WARN: {
               e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
               messageType = cmake::AUTHOR_WARNING;
-              }
-              break;
+            } break;
             case cmPolicies::OLD:
               noMessage = true;
             case cmPolicies::REQUIRED_IF_USED:
@@ -2734,49 +2318,42 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt,
             case cmPolicies::NEW:
               // Issue the fatal message.
               break;
-            }
-          e << "Found relative path while evaluating include directories of "
-          "\"" << tgt->GetName() << "\":\n  \"" << *li << "\"\n";
           }
-        if (!noMessage)
-          {
+          e << "Found relative path while evaluating include directories of "
+               "\""
+            << tgt->GetName() << "\":\n  \"" << *li << "\"\n";
+        }
+        if (!noMessage) {
           tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
-          if (messageType == cmake::FATAL_ERROR)
-            {
+          if (messageType == cmake::FATAL_ERROR) {
             return;
-            }
           }
         }
+      }
 
-      if (!cmSystemTools::IsOff(li->c_str()))
-        {
+      if (!cmSystemTools::IsOff(li->c_str())) {
         cmSystemTools::ConvertToUnixSlashes(*li);
-        }
+      }
       std::string inc = *li;
 
-      if(uniqueIncludes.insert(inc).second)
-        {
+      if (uniqueIncludes.insert(inc).second) {
         includes.push_back(inc);
-        if (debugIncludes)
-          {
+        if (debugIncludes) {
           usedIncludes += " * " + inc + "\n";
-          }
         }
       }
-    if (!usedIncludes.empty())
-      {
-      tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(cmake::LOG,
-                            std::string("Used includes for target ")
-                            + tgt->GetName() + ":\n"
-                            + usedIncludes, (*it)->ge->GetBacktrace());
-      }
     }
+    if (!usedIncludes.empty()) {
+      tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
+        cmake::LOG, std::string("Used includes for target ") + tgt->GetName() +
+          ":\n" + usedIncludes,
+        (*it)->ge->GetBacktrace());
+    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::vector<std::string>
-cmGeneratorTarget::GetIncludeDirectories(const std::string& config,
-                                         const std::string& lang) const
+std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
+  const std::string& config, const std::string& lang) const
 {
   std::vector<std::string> includes;
   UNORDERED_SET<std::string> uniqueIncludes;
@@ -2785,145 +2362,126 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config,
                                              "INCLUDE_DIRECTORIES", 0, 0);
 
   std::vector<std::string> debugProperties;
-  const char *debugProp =
-              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
-  if (debugProp)
-    {
+  const char* debugProp =
+    this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp) {
     cmSystemTools::ExpandListArgument(debugProp, debugProperties);
-    }
+  }
 
-  bool debugIncludes = !this->DebugIncludesDone
-                    && std::find(debugProperties.begin(),
-                                 debugProperties.end(),
-                                 "INCLUDE_DIRECTORIES")
-                        != debugProperties.end();
+  bool debugIncludes = !this->DebugIncludesDone &&
+    std::find(debugProperties.begin(), debugProperties.end(),
+              "INCLUDE_DIRECTORIES") != debugProperties.end();
 
-  if (this->GlobalGenerator->GetConfigureDoneCMP0026())
-    {
+  if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
     this->DebugIncludesDone = true;
-    }
+  }
 
-  processIncludeDirectories(this,
-                            this->IncludeDirectoriesEntries,
-                            includes,
-                            uniqueIncludes,
-                            &dagChecker,
-                            config,
-                            debugIncludes,
+  processIncludeDirectories(this, this->IncludeDirectoriesEntries, includes,
+                            uniqueIncludes, &dagChecker, config, debugIncludes,
                             lang);
 
   std::vector<cmGeneratorTarget::TargetPropertyEntry*>
     linkInterfaceIncludeDirectoriesEntries;
-  AddInterfaceEntries(
-    this, config, "INTERFACE_INCLUDE_DIRECTORIES",
-    linkInterfaceIncludeDirectoriesEntries);
+  AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES",
+                      linkInterfaceIncludeDirectoriesEntries);
 
-  if(this->Makefile->IsOn("APPLE"))
-    {
+  if (this->Makefile->IsOn("APPLE")) {
     cmLinkImplementationLibraries const* impl =
-        this->GetLinkImplementationLibraries(config);
-    for(std::vector<cmLinkImplItem>::const_iterator
-        it = impl->Libraries.begin();
-        it != impl->Libraries.end(); ++it)
-      {
+      this->GetLinkImplementationLibraries(config);
+    for (std::vector<cmLinkImplItem>::const_iterator it =
+           impl->Libraries.begin();
+         it != impl->Libraries.end(); ++it) {
       std::string libDir = cmSystemTools::CollapseFullPath(*it);
 
-      static cmsys::RegularExpression
-        frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
-      if(!frameworkCheck.find(libDir))
-        {
+      static cmsys::RegularExpression frameworkCheck(
+        "(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
+      if (!frameworkCheck.find(libDir)) {
         continue;
-        }
+      }
 
       libDir = frameworkCheck.match(1);
 
       cmGeneratorExpression ge;
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
-                ge.Parse(libDir.c_str());
-      linkInterfaceIncludeDirectoriesEntries
-              .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
-      }
+        ge.Parse(libDir.c_str());
+      linkInterfaceIncludeDirectoriesEntries.push_back(
+        new cmGeneratorTarget::TargetPropertyEntry(cge));
     }
+  }
 
-  processIncludeDirectories(this,
-                            linkInterfaceIncludeDirectoriesEntries,
-                            includes,
-                            uniqueIncludes,
-                            &dagChecker,
-                            config,
-                            debugIncludes,
-                            lang);
+  processIncludeDirectories(this, linkInterfaceIncludeDirectoriesEntries,
+                            includes, uniqueIncludes, &dagChecker, config,
+                            debugIncludes, lang);
 
   cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
 
+  // Add standard include directories for this language.
+  std::string const standardIncludesVar =
+    "CMAKE_" + lang + "_STANDARD_INCLUDE_DIRECTORIES";
+  std::string const standardIncludes =
+    this->Makefile->GetSafeDefinition(standardIncludesVar);
+  std::vector<std::string>::size_type const before = includes.size();
+  cmSystemTools::ExpandListArgument(standardIncludes, includes);
+  for (std::vector<std::string>::iterator i = includes.begin() + before;
+       i != includes.end(); ++i) {
+    cmSystemTools::ConvertToUnixSlashes(*i);
+  }
+
   return includes;
 }
 
-//----------------------------------------------------------------------------
-static void processCompileOptionsInternal(cmGeneratorTarget const* tgt,
-      const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
-      std::vector<std::string> &options,
-      UNORDERED_SET<std::string> &uniqueOptions,
-      cmGeneratorExpressionDAGChecker *dagChecker,
-      const std::string& config, bool debugOptions, const char *logName,
-      std::string const& language)
+static void processCompileOptionsInternal(
+  cmGeneratorTarget const* tgt,
+  const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+  std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+  cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
+  bool debugOptions, const char* logName, std::string const& language)
 {
-  for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator
-      it = entries.begin(), end = entries.end(); it != end; ++it)
-    {
+  for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
+         it = entries.begin(),
+         end = entries.end();
+       it != end; ++it) {
     std::vector<std::string> entryOptions;
-    cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(
-                                        tgt->GetLocalGenerator(),
-                                              config,
-                                              false,
-                                              tgt,
-                                              dagChecker,
-                                              language),
-                                    entryOptions);
+    cmSystemTools::ExpandListArgument(
+      (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
+                          dagChecker, language),
+      entryOptions);
     std::string usedOptions;
-    for(std::vector<std::string>::iterator
-          li = entryOptions.begin(); li != entryOptions.end(); ++li)
-      {
+    for (std::vector<std::string>::iterator li = entryOptions.begin();
+         li != entryOptions.end(); ++li) {
       std::string const& opt = *li;
 
-      if(uniqueOptions.insert(opt).second)
-        {
+      if (uniqueOptions.insert(opt).second) {
         options.push_back(opt);
-        if (debugOptions)
-          {
+        if (debugOptions) {
           usedOptions += " * " + opt + "\n";
-          }
         }
       }
-    if (!usedOptions.empty())
-      {
-      tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(cmake::LOG,
-                            std::string("Used compile ") + logName
-                            + std::string(" for target ")
-                            + tgt->GetName() + ":\n"
-                            + usedOptions, (*it)->ge->GetBacktrace());
-      }
     }
+    if (!usedOptions.empty()) {
+      tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
+        cmake::LOG, std::string("Used compile ") + logName +
+          std::string(" for target ") + tgt->GetName() + ":\n" + usedOptions,
+        (*it)->ge->GetBacktrace());
+    }
+  }
 }
 
-//----------------------------------------------------------------------------
-static void processCompileOptions(cmGeneratorTarget const* tgt,
-      const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
-      std::vector<std::string> &options,
-      UNORDERED_SET<std::string> &uniqueOptions,
-      cmGeneratorExpressionDAGChecker *dagChecker,
-      const std::string& config, bool debugOptions,
-      std::string const& language)
+static void processCompileOptions(
+  cmGeneratorTarget const* tgt,
+  const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+  std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+  cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
+  bool debugOptions, std::string const& language)
 {
   processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
                                 dagChecker, config, debugOptions, "options",
                                 language);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetCompileOptions(std::vector<std::string> &result,
-                                 const std::string& config,
-                                 const std::string& language) const
+void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
+                                          const std::string& config,
+                                          const std::string& language) const
 {
   UNORDERED_SET<std::string> uniqueOptions;
 
@@ -2931,137 +2489,101 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string> &result,
                                              "COMPILE_OPTIONS", 0, 0);
 
   std::vector<std::string> debugProperties;
-  const char *debugProp =
-              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
-  if (debugProp)
-    {
+  const char* debugProp =
+    this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp) {
     cmSystemTools::ExpandListArgument(debugProp, debugProperties);
-    }
+  }
 
-  bool debugOptions = !this->DebugCompileOptionsDone
-                    && std::find(debugProperties.begin(),
-                                 debugProperties.end(),
-                                 "COMPILE_OPTIONS")
-                        != debugProperties.end();
+  bool debugOptions = !this->DebugCompileOptionsDone &&
+    std::find(debugProperties.begin(), debugProperties.end(),
+              "COMPILE_OPTIONS") != debugProperties.end();
 
-  if (this->GlobalGenerator->GetConfigureDoneCMP0026())
-    {
+  if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
     this->DebugCompileOptionsDone = true;
-    }
+  }
 
-  processCompileOptions(this,
-                            this->CompileOptionsEntries,
-                            result,
-                            uniqueOptions,
-                            &dagChecker,
-                            config,
-                            debugOptions,
-                            language);
+  processCompileOptions(this, this->CompileOptionsEntries, result,
+                        uniqueOptions, &dagChecker, config, debugOptions,
+                        language);
 
   std::vector<cmGeneratorTarget::TargetPropertyEntry*>
     linkInterfaceCompileOptionsEntries;
 
-  AddInterfaceEntries(
-    this, config, "INTERFACE_COMPILE_OPTIONS",
-    linkInterfaceCompileOptionsEntries);
-
-  processCompileOptions(this,
-                        linkInterfaceCompileOptionsEntries,
-                            result,
-                            uniqueOptions,
-                            &dagChecker,
-                            config,
-                            debugOptions,
-                            language);
+  AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS",
+                      linkInterfaceCompileOptionsEntries);
+
+  processCompileOptions(this, linkInterfaceCompileOptionsEntries, result,
+                        uniqueOptions, &dagChecker, config, debugOptions,
+                        language);
 
   cmDeleteAll(linkInterfaceCompileOptionsEntries);
 }
 
-//----------------------------------------------------------------------------
-static void processCompileFeatures(cmGeneratorTarget const* tgt,
-      const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
-      std::vector<std::string> &options,
-      UNORDERED_SET<std::string> &uniqueOptions,
-      cmGeneratorExpressionDAGChecker *dagChecker,
-      const std::string& config, bool debugOptions)
+static void processCompileFeatures(
+  cmGeneratorTarget const* tgt,
+  const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+  std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+  cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
+  bool debugOptions)
 {
   processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
                                 dagChecker, config, debugOptions, "features",
                                 std::string());
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string> &result,
-                                  const std::string& config) const
+void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
+                                           const std::string& config) const
 {
   UNORDERED_SET<std::string> uniqueFeatures;
 
   cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
-                                             "COMPILE_FEATURES",
-                                             0, 0);
+                                             "COMPILE_FEATURES", 0, 0);
 
   std::vector<std::string> debugProperties;
-  const char *debugProp =
-              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
-  if (debugProp)
-    {
+  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();
+  bool debugFeatures = !this->DebugCompileFeaturesDone &&
+    std::find(debugProperties.begin(), debugProperties.end(),
+              "COMPILE_FEATURES") != debugProperties.end();
 
-  if (this->GlobalGenerator->GetConfigureDoneCMP0026())
-    {
+  if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
     this->DebugCompileFeaturesDone = true;
-    }
+  }
 
-  processCompileFeatures(this,
-                            this->CompileFeaturesEntries,
-                            result,
-                            uniqueFeatures,
-                            &dagChecker,
-                            config,
-                            debugFeatures);
+  processCompileFeatures(this, this->CompileFeaturesEntries, result,
+                         uniqueFeatures, &dagChecker, config, debugFeatures);
 
   std::vector<cmGeneratorTarget::TargetPropertyEntry*>
     linkInterfaceCompileFeaturesEntries;
-  AddInterfaceEntries(
-    this, config, "INTERFACE_COMPILE_FEATURES",
-    linkInterfaceCompileFeaturesEntries);
-
-  processCompileFeatures(this,
-                         linkInterfaceCompileFeaturesEntries,
-                            result,
-                            uniqueFeatures,
-                            &dagChecker,
-                            config,
-                            debugFeatures);
+  AddInterfaceEntries(this, config, "INTERFACE_COMPILE_FEATURES",
+                      linkInterfaceCompileFeaturesEntries);
+
+  processCompileFeatures(this, linkInterfaceCompileFeaturesEntries, result,
+                         uniqueFeatures, &dagChecker, config, debugFeatures);
 
   cmDeleteAll(linkInterfaceCompileFeaturesEntries);
 }
 
-//----------------------------------------------------------------------------
-static void processCompileDefinitions(cmGeneratorTarget const* tgt,
-      const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
-      std::vector<std::string> &options,
-      UNORDERED_SET<std::string> &uniqueOptions,
-      cmGeneratorExpressionDAGChecker *dagChecker,
-      const std::string& config, bool debugOptions,
-      std::string const& language)
+static void processCompileDefinitions(
+  cmGeneratorTarget const* tgt,
+  const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+  std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+  cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
+  bool debugOptions, std::string const& language)
 {
   processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
                                 dagChecker, config, debugOptions,
                                 "definitions", language);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list,
-                                            const std::string& config,
-                                            const std::string& language) const
+void cmGeneratorTarget::GetCompileDefinitions(
+  std::vector<std::string>& list, const std::string& config,
+  const std::string& language) const
 {
   UNORDERED_SET<std::string> uniqueOptions;
 
@@ -3069,91 +2591,66 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list,
                                              "COMPILE_DEFINITIONS", 0, 0);
 
   std::vector<std::string> debugProperties;
-  const char *debugProp =
-              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
-  if (debugProp)
-    {
+  const char* debugProp =
+    this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp) {
     cmSystemTools::ExpandListArgument(debugProp, debugProperties);
-    }
+  }
 
-  bool debugDefines = !this->DebugCompileDefinitionsDone
-                          && std::find(debugProperties.begin(),
-                                debugProperties.end(),
-                                "COMPILE_DEFINITIONS")
-                        != debugProperties.end();
+  bool debugDefines = !this->DebugCompileDefinitionsDone &&
+    std::find(debugProperties.begin(), debugProperties.end(),
+              "COMPILE_DEFINITIONS") != debugProperties.end();
 
-  if (this->GlobalGenerator->GetConfigureDoneCMP0026())
-    {
+  if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
     this->DebugCompileDefinitionsDone = true;
-    }
+  }
 
-  processCompileDefinitions(this,
-                            this->CompileDefinitionsEntries,
-                            list,
-                            uniqueOptions,
-                            &dagChecker,
-                            config,
-                            debugDefines,
+  processCompileDefinitions(this, this->CompileDefinitionsEntries, list,
+                            uniqueOptions, &dagChecker, config, debugDefines,
                             language);
 
   std::vector<cmGeneratorTarget::TargetPropertyEntry*>
     linkInterfaceCompileDefinitionsEntries;
-  AddInterfaceEntries(
-    this, config, "INTERFACE_COMPILE_DEFINITIONS",
-    linkInterfaceCompileDefinitionsEntries);
-  if (!config.empty())
-    {
-    std::string configPropName = "COMPILE_DEFINITIONS_"
-                                        + cmSystemTools::UpperCase(config);
-    const char *configProp = this->GetProperty(configPropName);
-    if (configProp)
-      {
-      switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043))
-        {
-        case cmPolicies::WARN:
-          {
+  AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS",
+                      linkInterfaceCompileDefinitionsEntries);
+  if (!config.empty()) {
+    std::string configPropName =
+      "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
+    const char* configProp = this->GetProperty(configPropName);
+    if (configProp) {
+      switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) {
+        case cmPolicies::WARN: {
           std::ostringstream e;
           e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043);
-          this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING,
-                                       e.str());
-          }
-        case cmPolicies::OLD:
-          {
+          this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+        }
+        case cmPolicies::OLD: {
           cmGeneratorExpression ge;
           cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
-                                                      ge.Parse(configProp);
-          linkInterfaceCompileDefinitionsEntries
-                .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
-          }
-          break;
+            ge.Parse(configProp);
+          linkInterfaceCompileDefinitionsEntries.push_back(
+            new cmGeneratorTarget::TargetPropertyEntry(cge));
+        } break;
         case cmPolicies::NEW:
         case cmPolicies::REQUIRED_ALWAYS:
         case cmPolicies::REQUIRED_IF_USED:
           break;
-        }
       }
     }
+  }
 
-  processCompileDefinitions(this,
-                            linkInterfaceCompileDefinitionsEntries,
-                            list,
-                            uniqueOptions,
-                            &dagChecker,
-                            config,
-                            debugDefines,
+  processCompileDefinitions(this, linkInterfaceCompileDefinitionsEntries, list,
+                            uniqueOptions, &dagChecker, config, debugDefines,
                             language);
 
   cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::ComputeTargetManifest(
-                                              const std::string& config) const
+void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
 {
-  if (this->IsImported())
-    {
+  if (this->IsImported()) {
     return;
-    }
+  }
   cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
 
   // Get the names.
@@ -3162,76 +2659,61 @@ void cmGeneratorTarget::ComputeTargetManifest(
   std::string realName;
   std::string impName;
   std::string pdbName;
-  if(this->GetType() == cmState::EXECUTABLE)
-    {
+  if (this->GetType() == cmState::EXECUTABLE) {
     this->GetExecutableNames(name, realName, impName, pdbName, config);
-    }
-  else if(this->GetType() == cmState::STATIC_LIBRARY ||
-          this->GetType() == cmState::SHARED_LIBRARY ||
-          this->GetType() == cmState::MODULE_LIBRARY)
-    {
-    this->GetLibraryNames(name, soName, realName, impName, pdbName,
-                                  config);
-    }
-  else
-    {
+  } else if (this->GetType() == cmState::STATIC_LIBRARY ||
+             this->GetType() == cmState::SHARED_LIBRARY ||
+             this->GetType() == cmState::MODULE_LIBRARY) {
+    this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
+  } else {
     return;
-    }
+  }
 
   // Get the directory.
   std::string dir = this->GetDirectory(config, false);
 
   // Add each name.
   std::string f;
-  if(!name.empty())
-    {
+  if (!name.empty()) {
     f = dir;
     f += "/";
     f += name;
     gg->AddToManifest(f);
-    }
-  if(!soName.empty())
-    {
+  }
+  if (!soName.empty()) {
     f = dir;
     f += "/";
     f += soName;
     gg->AddToManifest(f);
-    }
-  if(!realName.empty())
-    {
+  }
+  if (!realName.empty()) {
     f = dir;
     f += "/";
     f += realName;
     gg->AddToManifest(f);
-    }
-  if(!pdbName.empty())
-    {
+  }
+  if (!pdbName.empty()) {
     f = dir;
     f += "/";
     f += pdbName;
     gg->AddToManifest(f);
-    }
-  if(!impName.empty())
-    {
+  }
+  if (!impName.empty()) {
     f = this->GetDirectory(config, true);
     f += "/";
     f += impName;
     gg->AddToManifest(f);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetFullPath(const std::string& config,
                                            bool implib, bool realname) const
 {
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return this->Target->ImportedGetFullPath(config, implib);
-    }
-  else
-    {
+  } else {
     return this->NormalGetFullPath(config, implib, realname);
-    }
+  }
 }
 
 std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
@@ -3240,44 +2722,35 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
 {
   std::string fpath = this->GetDirectory(config, implib);
   fpath += "/";
-  if(this->IsAppBundleOnApple())
-    {
+  if (this->IsAppBundleOnApple()) {
     fpath = this->BuildMacContentDirectory(fpath, config, false);
     fpath += "/";
-    }
+  }
 
   // Add the full name of the target.
-  if(implib)
-    {
+  if (implib) {
     fpath += this->GetFullName(config, true);
-    }
-  else if(realname)
-    {
+  } else if (realname) {
     fpath += this->NormalGetRealName(config);
-    }
-  else
-    {
+  } else {
     fpath += this->GetFullName(config, false);
-    }
+  }
   return fpath;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::NormalGetRealName(const std::string& config) const
+std::string cmGeneratorTarget::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
   // enforcement of the limited imported target API.
-  if(this->IsImported())
-    {
-    std::string msg =  "NormalGetRealName called on imported target: ";
+  if (this->IsImported()) {
+    std::string msg = "NormalGetRealName called on imported target: ";
     msg += this->GetName();
     this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
-    }
+  }
 
-  if(this->GetType() == cmState::EXECUTABLE)
-    {
+  if (this->GetType() == cmState::EXECUTABLE) {
     // Compute the real name that will be built.
     std::string name;
     std::string realName;
@@ -3285,64 +2758,54 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const
     std::string pdbName;
     this->GetExecutableNames(name, realName, impName, pdbName, config);
     return realName;
-    }
-  else
-    {
+  } else {
     // Compute the real name that will be built.
     std::string name;
     std::string soName;
     std::string realName;
     std::string impName;
     std::string pdbName;
-    this->GetLibraryNames(name, soName, realName,
-                          impName, pdbName, config);
+    this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
     return realName;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetLibraryNames(std::string& name,
-                               std::string& soName,
-                               std::string& realName,
-                               std::string& impName,
-                               std::string& pdbName,
-                               const std::string& config) const
+void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
+                                        std::string& realName,
+                                        std::string& impName,
+                                        std::string& pdbName,
+                                        const std::string& config) const
 {
   // This should not be called for imported targets.
   // TODO: Split cmTarget into a class hierarchy to get compile-time
   // enforcement of the limited imported target API.
-  if(this->IsImported())
-    {
-    std::string msg =  "GetLibraryNames called on imported target: ";
+  if (this->IsImported()) {
+    std::string msg = "GetLibraryNames called on imported target: ";
     msg += this->GetName();
-    this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR,
-                                 msg);
+    this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
     return;
-    }
+  }
 
   // Check for library version properties.
   const char* version = this->GetProperty("VERSION");
   const char* soversion = this->GetProperty("SOVERSION");
-  if(!this->HasSOName(config) ||
-     this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
-     this->IsFrameworkOnApple())
-    {
+  if (!this->HasSOName(config) ||
+      this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
+      this->IsFrameworkOnApple()) {
     // Versioning is supported only for shared libraries and modules,
     // and then only when the platform supports an soname flag.
     version = 0;
     soversion = 0;
-    }
-  if(version && !soversion)
-    {
+  }
+  if (version && !soversion) {
     // The soversion must be set if the library version is set.  Use
     // the library version as the soversion.
     soversion = version;
-    }
-  if(!version && soversion)
-    {
+  }
+  if (!version && soversion) {
     // Use the soversion as the library version.
     version = soversion;
-    }
+  }
 
   // Get the components of the library name.
   std::string prefix;
@@ -3351,75 +2814,63 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
   this->GetFullNameInternal(config, false, prefix, base, suffix);
 
   // The library name.
-  name = prefix+base+suffix;
+  name = prefix + base + suffix;
 
-  if(this->IsFrameworkOnApple())
-    {
+  if (this->IsFrameworkOnApple()) {
     realName = prefix;
-    if(!this->Makefile->PlatformIsAppleIos())
-      {
+    if (!this->Makefile->PlatformIsAppleIos()) {
       realName += "Versions/";
       realName += this->GetFrameworkVersion();
       realName += "/";
-      }
+    }
     realName += base;
     soName = realName;
-    }
-  else
-  {
+  } else {
     // The library's soname.
-    this->ComputeVersionedName(soName, prefix, base, suffix,
-                              name, soversion);
+    this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion);
 
     // The library's real name on disk.
-    this->ComputeVersionedName(realName, prefix, base, suffix,
-                              name, version);
+    this->ComputeVersionedName(realName, prefix, base, suffix, name, version);
   }
 
   // The import library name.
-  if(this->GetType() == cmState::SHARED_LIBRARY ||
-     this->GetType() == cmState::MODULE_LIBRARY)
-    {
+  if (this->GetType() == cmState::SHARED_LIBRARY ||
+      this->GetType() == cmState::MODULE_LIBRARY) {
     impName = this->GetFullNameInternal(config, true);
-    }
-  else
-    {
+  } else {
     impName = "";
-    }
+  }
 
   // The program database file name.
   pdbName = this->GetPDBName(config);
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetExecutableNames(std::string& name,
-                                  std::string& realName,
-                                  std::string& impName,
-                                  std::string& pdbName,
-                                  const std::string& config) const
+                                           std::string& realName,
+                                           std::string& impName,
+                                           std::string& pdbName,
+                                           const std::string& config) const
 {
   // This should not be called for imported targets.
   // TODO: Split cmTarget into a class hierarchy to get compile-time
   // enforcement of the limited imported target API.
-  if(this->IsImported())
-    {
-    std::string msg =
-      "GetExecutableNames called on imported target: ";
+  if (this->IsImported()) {
+    std::string msg = "GetExecutableNames called on imported target: ";
     msg += this->GetName();
     this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
-    }
+  }
 
-  // This versioning is supported only for executables and then only
-  // when the platform supports symbolic links.
+// This versioning is supported only for executables and then only
+// when the platform supports symbolic links.
 #if defined(_WIN32) && !defined(__CYGWIN__)
   const char* version = 0;
 #else
   // Check for executable version properties.
   const char* version = this->GetProperty("VERSION");
-  if(this->GetType() != cmState::EXECUTABLE || this->Makefile->IsOn("XCODE"))
-    {
+  if (this->GetType() != cmState::EXECUTABLE ||
+      this->Makefile->IsOn("XCODE")) {
     version = 0;
-    }
+  }
 #endif
 
   // Get the components of the executable name.
@@ -3429,19 +2880,18 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
   this->GetFullNameInternal(config, false, prefix, base, suffix);
 
   // The executable name.
-  name = prefix+base+suffix;
+  name = prefix + base + suffix;
 
-  // The executable's real name on disk.
+// The executable's real name on disk.
 #if defined(__CYGWIN__)
-  realName = prefix+base;
+  realName = prefix + base;
 #else
   realName = name;
 #endif
-  if(version)
-    {
+  if (version) {
     realName += "-";
     realName += version;
-    }
+  }
 #if defined(__CYGWIN__)
   realName += suffix;
 #endif
@@ -3453,7 +2903,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
   pdbName = this->GetPDBName(config);
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config,
                                                    bool implib) const
 {
@@ -3461,12 +2910,11 @@ std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config,
   std::string base;
   std::string suffix;
   this->GetFullNameInternal(config, implib, prefix, base, suffix);
-  return prefix+base+suffix;
+  return prefix + base + suffix;
 }
 
-//----------------------------------------------------------------------------
-const char*
-cmGeneratorTarget::ImportedGetLocation(const std::string& config) const
+const char* cmGeneratorTarget::ImportedGetLocation(
+  const std::string& config) const
 {
   static std::string location;
   assert(this->IsImported());
@@ -3474,7 +2922,6 @@ cmGeneratorTarget::ImportedGetLocation(const std::string& config) const
   return location.c_str();
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetFullNameImported(const std::string& config,
                                                    bool implib) const
 {
@@ -3482,7 +2929,6 @@ std::string cmGeneratorTarget::GetFullNameImported(const std::string& config,
     this->Target->ImportedGetFullPath(config, implib));
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
                                             bool implib,
                                             std::string& outPrefix,
@@ -3490,138 +2936,119 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
                                             std::string& outSuffix) const
 {
   // Use just the target name for non-main target types.
-  if(this->GetType() != cmState::STATIC_LIBRARY &&
-     this->GetType() != cmState::SHARED_LIBRARY &&
-     this->GetType() != cmState::MODULE_LIBRARY &&
-     this->GetType() != cmState::EXECUTABLE)
-    {
+  if (this->GetType() != cmState::STATIC_LIBRARY &&
+      this->GetType() != cmState::SHARED_LIBRARY &&
+      this->GetType() != cmState::MODULE_LIBRARY &&
+      this->GetType() != cmState::EXECUTABLE) {
     outPrefix = "";
     outBase = this->GetName();
     outSuffix = "";
     return;
-    }
+  }
 
   // Return an empty name for the import library if this platform
   // does not support import libraries.
-  if(implib &&
-     !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
-    {
+  if (implib &&
+      !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
     outPrefix = "";
     outBase = "";
     outSuffix = "";
     return;
-    }
+  }
 
   // The implib option is only allowed for shared libraries, module
   // libraries, and executables.
-  if(this->GetType() != cmState::SHARED_LIBRARY &&
-     this->GetType() != cmState::MODULE_LIBRARY &&
-     this->GetType() != cmState::EXECUTABLE)
-    {
+  if (this->GetType() != cmState::SHARED_LIBRARY &&
+      this->GetType() != cmState::MODULE_LIBRARY &&
+      this->GetType() != cmState::EXECUTABLE) {
     implib = false;
-    }
+  }
 
   // Compute the full name for main target types.
-  const char* targetPrefix = (implib
-                              ? this->GetProperty("IMPORT_PREFIX")
-                              : this->GetProperty("PREFIX"));
-  const char* targetSuffix = (implib
-                              ? this->GetProperty("IMPORT_SUFFIX")
-                              : this->GetProperty("SUFFIX"));
+  const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX")
+                                     : this->GetProperty("PREFIX"));
+  const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX")
+                                     : this->GetProperty("SUFFIX"));
   const char* configPostfix = 0;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     std::string configProp = cmSystemTools::UpperCase(config);
     configProp += "_POSTFIX";
     configPostfix = this->GetProperty(configProp);
     // Mac application bundles and frameworks have no postfix.
-    if(configPostfix &&
-       (this->IsAppBundleOnApple() || this->IsFrameworkOnApple()))
-      {
+    if (configPostfix &&
+        (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) {
       configPostfix = 0;
-      }
     }
+  }
   const char* prefixVar = this->Target->GetPrefixVariableInternal(implib);
   const char* suffixVar = this->Target->GetSuffixVariableInternal(implib);
 
   // Check for language-specific default prefix and suffix.
   std::string ll = this->GetLinkerLanguage(config);
-  if(!ll.empty())
-    {
-    if(!targetSuffix && suffixVar && *suffixVar)
-      {
+  if (!ll.empty()) {
+    if (!targetSuffix && suffixVar && *suffixVar) {
       std::string langSuff = suffixVar + std::string("_") + ll;
       targetSuffix = this->Makefile->GetDefinition(langSuff);
-      }
-    if(!targetPrefix && prefixVar && *prefixVar)
-      {
+    }
+    if (!targetPrefix && prefixVar && *prefixVar) {
       std::string langPrefix = prefixVar + std::string("_") + ll;
       targetPrefix = this->Makefile->GetDefinition(langPrefix);
-      }
     }
+  }
 
   // if there is no prefix on the target use the cmake definition
-  if(!targetPrefix && prefixVar)
-    {
+  if (!targetPrefix && prefixVar) {
     targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
-    }
+  }
   // if there is no suffix on the target use the cmake definition
-  if(!targetSuffix && suffixVar)
-    {
+  if (!targetSuffix && suffixVar) {
     targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
-    }
+  }
 
   // frameworks have directory prefix but no suffix
   std::string fw_prefix;
-  if(this->IsFrameworkOnApple())
-    {
+  if (this->IsFrameworkOnApple()) {
     fw_prefix = this->GetOutputName(config, false);
     fw_prefix += ".framework/";
     targetPrefix = fw_prefix.c_str();
     targetSuffix = 0;
-    }
+  }
 
-  if(this->IsCFBundleOnApple())
-    {
+  if (this->IsCFBundleOnApple()) {
     fw_prefix = this->GetCFBundleDirectory(config, false);
     fw_prefix += "/";
     targetPrefix = fw_prefix.c_str();
     targetSuffix = 0;
-    }
+  }
 
   // Begin the final name with the prefix.
-  outPrefix = targetPrefix?targetPrefix:"";
+  outPrefix = targetPrefix ? targetPrefix : "";
 
   // Append the target name or property-specified name.
   outBase += this->GetOutputName(config, implib);
 
   // Append the per-configuration postfix.
-  outBase += configPostfix?configPostfix:"";
+  outBase += configPostfix ? configPostfix : "";
 
   // Name shared libraries with their version number on some platforms.
-  if(const char* soversion = this->GetProperty("SOVERSION"))
-    {
-    if(this->GetType() == cmState::SHARED_LIBRARY && !implib &&
-       this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION"))
-      {
+  if (const char* soversion = this->GetProperty("SOVERSION")) {
+    if (this->GetType() == cmState::SHARED_LIBRARY && !implib &&
+        this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
       outBase += "-";
       outBase += soversion;
-      }
     }
+  }
 
   // Append the suffix.
-  outSuffix = targetSuffix?targetSuffix:"";
+  outSuffix = targetSuffix ? targetSuffix : "";
 }
 
-
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const
+std::string cmGeneratorTarget::GetLinkerLanguage(
+  const std::string& config) const
 {
   return this->GetLinkClosure(config)->LinkerLanguage;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
 {
   std::string prefix;
@@ -3630,42 +3057,36 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
   this->GetFullNameInternal(config, false, prefix, base, suffix);
 
   std::vector<std::string> props;
-  std::string configUpper =
-    cmSystemTools::UpperCase(config);
-  if(!configUpper.empty())
-    {
+  std::string configUpper = cmSystemTools::UpperCase(config);
+  if (!configUpper.empty()) {
     // PDB_NAME_<CONFIG>
     props.push_back("PDB_NAME_" + configUpper);
-    }
+  }
 
   // PDB_NAME
   props.push_back("PDB_NAME");
 
-  for(std::vector<std::string>::const_iterator i = props.begin();
-      i != props.end(); ++i)
-    {
-    if(const char* outName = this->GetProperty(*i))
-      {
+  for (std::vector<std::string>::const_iterator i = props.begin();
+       i != props.end(); ++i) {
+    if (const char* outName = this->GetProperty(*i)) {
       base = outName;
       break;
-      }
     }
-  return prefix+base+".pdb";
+  }
+  return prefix + base + ".pdb";
 }
 
 bool cmGeneratorTarget::StrictTargetComparison::operator()(
-    cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const
+  cmGeneratorTarget const* t1, cmGeneratorTarget const* t2) const
 {
   int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
-  if (nameResult == 0)
-    {
+  if (nameResult == 0) {
     return strcmp(t1->GetLocalGenerator()->GetCurrentBinaryDirectory(),
                   t2->GetLocalGenerator()->GetCurrentBinaryDirectory()) < 0;
-    }
+  }
   return nameResult < 0;
 }
 
-//----------------------------------------------------------------------------
 struct cmGeneratorTarget::SourceFileFlags
 cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
 {
@@ -3673,174 +3094,144 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
   this->ConstructSourceFileFlags();
   std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
     this->SourceFlagsMap.find(sf);
-  if(si != this->SourceFlagsMap.end())
-    {
+  if (si != this->SourceFlagsMap.end()) {
     flags = si->second;
-    }
-  else
-    {
+  } 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"))
-      {
+    if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) {
       flags.MacFolder = location;
-      if(strcmp(location, "Resources") == 0)
-        {
+      if (strcmp(location, "Resources") == 0) {
         flags.Type = cmGeneratorTarget::SourceFileTypeResource;
-        }
-      else
-        {
+      } else {
         flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
-        }
       }
     }
+  }
   return flags;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::ConstructSourceFileFlags() const
 {
-  if(this->SourceFileFlagsConstructed)
-    {
+  if (this->SourceFileFlagsConstructed) {
     return;
-    }
+  }
   this->SourceFileFlagsConstructed = true;
 
   // Process public headers to mark the source files.
-  if(const char* files = this->GetProperty("PUBLIC_HEADER"))
-    {
+  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))
-        {
+    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->GetProperty("PRIVATE_HEADER"))
-    {
+  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))
-        {
+    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->GetProperty("RESOURCE"))
-    {
+  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))
-        {
+    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 = "";
-        if(!this->Makefile->PlatformIsAppleIos())
-          {
+        if (!this->Makefile->PlatformIsAppleIos()) {
           flags.MacFolder = "Resources";
-          }
-        flags.Type = cmGeneratorTarget::SourceFileTypeResource;
         }
+        flags.Type = cmGeneratorTarget::SourceFileTypeResource;
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 const cmGeneratorTarget::CompatibleInterfacesBase&
 cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
 {
   cmGeneratorTarget::CompatibleInterfaces& compat =
     this->CompatibleInterfacesMap[config];
-  if(!compat.Done)
-    {
+  if (!compat.Done) {
     compat.Done = true;
     compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
     compat.PropsString.insert("AUTOUIC_OPTIONS");
     std::vector<cmGeneratorTarget const*> const& deps =
       this->GetLinkImplementationClosure(config);
-    for(std::vector<cmGeneratorTarget const*>::const_iterator li =
-        deps.begin(); li != deps.end(); ++li)
-      {
-#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
-      if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \
-        { \
-        std::vector<std::string> props; \
-        cmSystemTools::ExpandListArgument(prop, props); \
-        compat.Props##x.insert(props.begin(), props.end()); \
-        }
+    for (std::vector<cmGeneratorTarget const*>::const_iterator li =
+           deps.begin();
+         li != deps.end(); ++li) {
+#define CM_READ_COMPATIBLE_INTERFACE(X, x)                                    \
+  if (const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) {    \
+    std::vector<std::string> props;                                           \
+    cmSystemTools::ExpandListArgument(prop, props);                           \
+    compat.Props##x.insert(props.begin(), props.end());                       \
+  }
       CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
       CM_READ_COMPATIBLE_INTERFACE(STRING, String)
       CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin)
       CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax)
 #undef CM_READ_COMPATIBLE_INTERFACE
-      }
     }
+  }
   return compat;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty(
-    const std::string &p, const std::string& config) const
+  const std::string& p, const std::string& config) const
 {
-  if (this->GetType() == cmState::OBJECT_LIBRARY
-      || this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::OBJECT_LIBRARY ||
+      this->GetType() == cmState::INTERFACE_LIBRARY) {
     return false;
-    }
+  }
   return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty(
-    const std::string &p, const std::string& config) const
+  const std::string& p, const std::string& config) const
 {
-  if (this->GetType() == cmState::OBJECT_LIBRARY
-      || this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::OBJECT_LIBRARY ||
+      this->GetType() == cmState::INTERFACE_LIBRARY) {
     return false;
-    }
+  }
   return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty(
-    const std::string &p, const std::string& config) const
+  const std::string& p, const std::string& config) const
 {
-  if (this->GetType() == cmState::OBJECT_LIBRARY
-      || this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::OBJECT_LIBRARY ||
+      this->GetType() == cmState::INTERFACE_LIBRARY) {
     return false;
-    }
+  }
   return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty(
-    const std::string &p, const std::string& config) const
+  const std::string& p, const std::string& config) const
 {
-  if (this->GetType() == cmState::OBJECT_LIBRARY
-      || this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::OBJECT_LIBRARY ||
+      this->GetType() == cmState::INTERFACE_LIBRARY) {
     return false;
-    }
+  }
   return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0;
 }
 
@@ -3852,111 +3243,100 @@ enum CompatibleType
   NumberMaxType
 };
 
-template<typename PropertyType>
+template <typename PropertyType>
 PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
                                                const std::string& prop,
                                                const std::string& config,
-                                               CompatibleType,
-                                               PropertyType *);
+                                               CompatibleType, PropertyType*);
 
-template<>
+template <>
 bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
                                        const std::string& prop,
                                        const std::string& config,
-                                       CompatibleType, bool *)
+                                       CompatibleType, bool*)
 {
   return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
 }
 
-template<>
-const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
-                                               const std::string& prop,
-                                               const std::string& config,
-                                               CompatibleType t,
-                                               const char **)
+template <>
+const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
+                                              const std::string& prop,
+                                              const std::string& config,
+                                              CompatibleType t, const char**)
 {
-  switch(t)
-  {
-  case BoolType:
-    assert(0 && "String compatibility check function called for boolean");
-    return 0;
-  case StringType:
-    return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
-  case NumberMinType:
-    return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config);
-  case NumberMaxType:
-    return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
+  switch (t) {
+    case BoolType:
+      assert(0 && "String compatibility check function called for boolean");
+      return 0;
+    case StringType:
+      return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
+    case NumberMinType:
+      return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config);
+    case NumberMaxType:
+      return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
   }
   assert(0 && "Unreachable!");
   return 0;
 }
 
-//----------------------------------------------------------------------------
-template<typename PropertyType>
+template <typename PropertyType>
 void checkPropertyConsistency(cmGeneratorTarget const* depender,
                               cmGeneratorTarget const* dependee,
                               const std::string& propName,
-                              std::set<std::string> &emitted,
-                              const std::string& config,
-                              CompatibleType t,
-                              PropertyType *)
-{
-  const char *prop = dependee->GetProperty(propName);
-  if (!prop)
-    {
+                              std::set<std::string>& emitted,
+                              const std::string& config, CompatibleType t,
+                              PropertyType*)
+{
+  const char* prop = dependee->GetProperty(propName);
+  if (!prop) {
     return;
-    }
+  }
 
   std::vector<std::string> props;
   cmSystemTools::ExpandListArgument(prop, props);
-  std::string pdir =
-    dependee->Target->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT");
+  std::string pdir = cmSystemTools::GetCMakeRoot();
   pdir += "/Help/prop_tgt/";
 
-  for(std::vector<std::string>::iterator pi = props.begin();
-      pi != props.end(); ++pi)
-    {
+  for (std::vector<std::string>::iterator pi = props.begin();
+       pi != props.end(); ++pi) {
     std::string pname = cmSystemTools::HelpFileName(*pi);
     std::string pfile = pdir + pname + ".rst";
-    if(cmSystemTools::FileExists(pfile.c_str(), true))
-      {
+    if (cmSystemTools::FileExists(pfile.c_str(), true)) {
       std::ostringstream e;
-      e << "Target \"" << dependee->GetName() << "\" has property \""
-        << *pi << "\" listed in its " << propName << " property.  "
-          "This is not allowed.  Only user-defined properties may appear "
-          "listed in the " << propName << " property.";
+      e << "Target \"" << dependee->GetName() << "\" has property \"" << *pi
+        << "\" listed in its " << propName
+        << " property.  "
+           "This is not allowed.  Only user-defined properties may appear "
+           "listed in the "
+        << propName << " property.";
       depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
-    if(emitted.insert(*pi).second)
-      {
-      getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config,
-                                                      t, 0);
-      if (cmSystemTools::GetErrorOccuredFlag())
-        {
+    }
+    if (emitted.insert(*pi).second) {
+      getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, t,
+                                                      0);
+      if (cmSystemTools::GetErrorOccuredFlag()) {
         return;
-        }
       }
     }
+  }
 }
 
-static std::string intersect(const std::set<std::string> &s1,
-                             const std::set<std::string> &s2)
+static std::string intersect(const std::set<std::string>& s1,
+                             const std::set<std::string>& s2)
 {
   std::set<std::string> intersect;
-  std::set_intersection(s1.begin(),s1.end(),
-                        s2.begin(),s2.end(),
-                      std::inserter(intersect,intersect.begin()));
-  if (!intersect.empty())
-    {
+  std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
+                        std::inserter(intersect, intersect.begin()));
+  if (!intersect.empty()) {
     return *intersect.begin();
-    }
+  }
   return "";
 }
 
-static std::string intersect(const std::set<std::string> &s1,
-                       const std::set<std::string> &s2,
-                       const std::set<std::string> &s3)
+static std::string intersect(const std::set<std::string>& s1,
+                             const std::set<std::string>& s2,
+                             const std::set<std::string>& s3)
 {
   std::string result;
   result = intersect(s1, s2);
@@ -3968,10 +3348,10 @@ static std::string intersect(const std::set<std::string> &s1,
   return intersect(s2, s3);
 }
 
-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)
+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)
 {
   std::string result;
   result = intersect(s1, s2);
@@ -3986,11 +3366,10 @@ static std::string intersect(const std::set<std::string> &s1,
   return intersect(s2, s3, s4);
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::CheckPropertyCompatibility(
-    cmComputeLinkInformation *info, const std::string& config) const
+  cmComputeLinkInformation* info, const std::string& config) const
 {
-  const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
+  const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
 
   std::set<std::string> emittedBools;
   static std::string strBool = "COMPATIBLE_INTERFACE_BOOL";
@@ -4001,97 +3380,77 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
   std::set<std::string> emittedMaxNumbers;
   static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
 
-  for(cmComputeLinkInformation::ItemVector::const_iterator li =
-      deps.begin(); li != deps.end(); ++li)
-    {
-    if (!li->Target)
-      {
+  for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
+       li != deps.end(); ++li) {
+    if (!li->Target) {
       continue;
-      }
+    }
 
-    checkPropertyConsistency<bool>(this, li->Target,
-                                strBool,
-                                emittedBools, config, BoolType, 0);
-    if (cmSystemTools::GetErrorOccuredFlag())
-      {
+    checkPropertyConsistency<bool>(this, li->Target, strBool, emittedBools,
+                                   config, BoolType, 0);
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       return;
-      }
-    checkPropertyConsistency<const char *>(this, li->Target,
-                                strString,
-                                emittedStrings, config,
-                                StringType, 0);
-    if (cmSystemTools::GetErrorOccuredFlag())
-      {
+    }
+    checkPropertyConsistency<const char*>(
+      this, li->Target, strString, emittedStrings, config, StringType, 0);
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       return;
-      }
-    checkPropertyConsistency<const char *>(this, li->Target,
-                                strNumMin,
-                                emittedMinNumbers, config,
-                                NumberMinType, 0);
-    if (cmSystemTools::GetErrorOccuredFlag())
-      {
+    }
+    checkPropertyConsistency<const char*>(this, li->Target, strNumMin,
+                                          emittedMinNumbers, config,
+                                          NumberMinType, 0);
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       return;
-      }
-    checkPropertyConsistency<const char *>(this, li->Target,
-                                strNumMax,
-                                emittedMaxNumbers, config,
-                                NumberMaxType, 0);
-    if (cmSystemTools::GetErrorOccuredFlag())
-      {
+    }
+    checkPropertyConsistency<const char*>(this, li->Target, strNumMax,
+                                          emittedMaxNumbers, config,
+                                          NumberMaxType, 0);
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       return;
-      }
     }
+  }
 
-  std::string prop = intersect(emittedBools,
-                               emittedStrings,
-                               emittedMinNumbers,
+  std::string prop = intersect(emittedBools, emittedStrings, emittedMinNumbers,
                                emittedMaxNumbers);
 
-  if (!prop.empty())
-    {
+  if (!prop.empty()) {
     // Use a sorted std::vector to keep the error message sorted.
     std::vector<std::string> props;
     std::set<std::string>::const_iterator i = emittedBools.find(prop);
-    if (i != emittedBools.end())
-      {
+    if (i != emittedBools.end()) {
       props.push_back(strBool);
-      }
+    }
     i = emittedStrings.find(prop);
-    if (i != emittedStrings.end())
-      {
+    if (i != emittedStrings.end()) {
       props.push_back(strString);
-      }
+    }
     i = emittedMinNumbers.find(prop);
-    if (i != emittedMinNumbers.end())
-      {
+    if (i != emittedMinNumbers.end()) {
       props.push_back(strNumMin);
-      }
+    }
     i = emittedMaxNumbers.find(prop);
-    if (i != emittedMaxNumbers.end())
-      {
+    if (i != emittedMaxNumbers.end()) {
       props.push_back(strNumMax);
-      }
+    }
     std::sort(props.begin(), props.end());
 
     std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", ");
     propsString += " and the " + props.back();
 
     std::ostringstream e;
-    e << "Property \"" << prop << "\" appears in both the "
-      << propsString <<
-    " property in the dependencies of target \"" << this->GetName() <<
-    "\".  This is not allowed. A property may only require compatibility "
-    "in a boolean interpretation, a numeric minimum, a numeric maximum or a "
-    "string interpretation, but not a mixture.";
+    e << "Property \"" << prop << "\" appears in both the " << propsString
+      << " property in the dependencies of target \"" << this->GetName()
+      << "\".  This is not allowed. A property may only require compatibility "
+         "in a boolean interpretation, a numeric minimum, a numeric maximum "
+         "or a "
+         "string interpretation, but not a mixture.";
     this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string compatibilityType(CompatibleType t)
 {
-  switch(t)
-    {
+  switch (t) {
     case BoolType:
       return "Boolean compatibility";
     case StringType:
@@ -4100,214 +3459,183 @@ std::string compatibilityType(CompatibleType t)
       return "Numeric maximum compatibility";
     case NumberMinType:
       return "Numeric minimum compatibility";
-    }
+  }
   assert(0 && "Unreachable!");
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string compatibilityAgree(CompatibleType t, bool dominant)
 {
-  switch(t)
-    {
+  switch (t) {
     case BoolType:
     case StringType:
       return dominant ? "(Disagree)\n" : "(Agree)\n";
     case NumberMaxType:
     case NumberMinType:
       return dominant ? "(Dominant)\n" : "(Ignored)\n";
-    }
+  }
   assert(0 && "Unreachable!");
   return "";
 }
 
-//----------------------------------------------------------------------------
-template<typename PropertyType>
+template <typename PropertyType>
 PropertyType getTypedProperty(cmGeneratorTarget const* tgt,
                               const std::string& prop);
 
-//----------------------------------------------------------------------------
-template<>
+template <>
 bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
                             const std::string& prop)
 {
   return tgt->GetPropertyAsBool(prop);
 }
 
-//----------------------------------------------------------------------------
-template<>
-const char *getTypedProperty<const char *>(cmGeneratorTarget const* tgt,
-                                           const std::string& prop)
+template <>
+const char* getTypedProperty<const char*>(cmGeneratorTarget const* tgt,
+                                          const std::string& prop)
 {
   return tgt->GetProperty(prop);
 }
 
-template<typename PropertyType>
+template <typename PropertyType>
 std::string valueAsString(PropertyType);
-template<>
+template <>
 std::string valueAsString<bool>(bool value)
 {
   return value ? "TRUE" : "FALSE";
 }
-template<>
+template <>
 std::string valueAsString<const char*>(const char* value)
 {
   return value ? value : "(unset)";
 }
 
-template<typename PropertyType>
+template <typename PropertyType>
 PropertyType impliedValue(PropertyType);
-template<>
+template <>
 bool impliedValue<bool>(bool)
 {
   return false;
 }
-template<>
+template <>
 const char* impliedValue<const char*>(const char*)
 {
   return "";
 }
 
-//----------------------------------------------------------------------------
-template<typename PropertyType>
+template <typename PropertyType>
 std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
                                                  PropertyType rhs,
                                                  CompatibleType t);
 
-//----------------------------------------------------------------------------
-template<>
-std::pair<bool, bool> consistentProperty(bool lhs, bool rhs,
-                                         CompatibleType)
+template <>
+std::pair<bool, bool> consistentProperty(bool lhs, bool rhs, CompatibleType)
 {
   return std::make_pair(lhs == rhs, lhs);
 }
 
-//----------------------------------------------------------------------------
-std::pair<bool, const char*> consistentStringProperty(const char *lhs,
-                                                      const char *rhs)
+std::pair<bool, const char*> consistentStringProperty(const char* lhs,
+                                                      const char* rhs)
 {
   const bool b = strcmp(lhs, rhs) == 0;
   return std::make_pair(b, b ? lhs : 0);
 }
 
-//----------------------------------------------------------------------------
-std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
-                                                   const char *rhs,
-                                                   CompatibleType t)
+std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
+                                                      const char* rhs,
+                                                      CompatibleType t)
 {
-  char *pEnd;
+  char* pEnd;
 
   const char* const null_ptr = 0;
 
   long lnum = strtol(lhs, &pEnd, 0);
-  if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
-    {
+  if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
     return std::pair<bool, const char*>(false, null_ptr);
-    }
+  }
 
   long rnum = strtol(rhs, &pEnd, 0);
-  if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
-    {
+  if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
     return std::pair<bool, const char*>(false, null_ptr);
-    }
+  }
 
-  if (t == NumberMaxType)
-    {
+  if (t == NumberMaxType) {
     return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs);
-    }
-  else
-    {
+  } else {
     return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-template<>
-std::pair<bool, const char*> consistentProperty(const char *lhs,
-                                                const char *rhs,
+template <>
+std::pair<bool, const char*> consistentProperty(const char* lhs,
+                                                const char* rhs,
                                                 CompatibleType t)
 {
-  if (!lhs && !rhs)
-    {
+  if (!lhs && !rhs) {
     return std::make_pair(true, lhs);
-    }
-  if (!lhs)
-    {
+  }
+  if (!lhs) {
     return std::make_pair(true, rhs);
-    }
-  if (!rhs)
-    {
+  }
+  if (!rhs) {
     return std::make_pair(true, lhs);
-    }
+  }
 
   const char* const null_ptr = 0;
 
-  switch(t)
-  {
-  case BoolType:
-    assert(0 && "consistentProperty for strings called with BoolType");
-    return std::pair<bool, const char*>(false, null_ptr);
-  case StringType:
-    return consistentStringProperty(lhs, rhs);
-  case NumberMinType:
-  case NumberMaxType:
-    return consistentNumberProperty(lhs, rhs, t);
+  switch (t) {
+    case BoolType:
+      assert(0 && "consistentProperty for strings called with BoolType");
+      return std::pair<bool, const char*>(false, null_ptr);
+    case StringType:
+      return consistentStringProperty(lhs, rhs);
+    case NumberMinType:
+    case NumberMaxType:
+      return consistentNumberProperty(lhs, rhs, t);
   }
   assert(0 && "Unreachable!");
   return std::pair<bool, const char*>(false, null_ptr);
 }
 
-//----------------------------------------------------------------------------
-template<typename PropertyType>
+template <typename PropertyType>
 PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
-                                          const std::string &p,
-                                          const std::string& config,
-                                          const char *defaultValue,
-                                          CompatibleType t,
-                                          PropertyType *)
+                                                 const std::string& p,
+                                                 const std::string& config,
+                                                 const char* defaultValue,
+                                                 CompatibleType t,
+                                                 PropertyType*)
 {
   PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
   std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
   const bool explicitlySet =
-      std::find(headPropKeys.begin(), headPropKeys.end(),
-                p) != headPropKeys.end();
+    std::find(headPropKeys.begin(), headPropKeys.end(), p) !=
+    headPropKeys.end();
 
-  const bool impliedByUse =
-          tgt->IsNullImpliedByLinkLibraries(p);
-  assert((impliedByUse ^ explicitlySet)
-      || (!impliedByUse && !explicitlySet));
+  const bool impliedByUse = tgt->IsNullImpliedByLinkLibraries(p);
+  assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet));
 
   std::vector<cmGeneratorTarget const*> const& deps =
     tgt->GetLinkImplementationClosure(config);
 
-  if(deps.empty())
-    {
+  if (deps.empty()) {
     return propContent;
-    }
+  }
   bool propInitialized = explicitlySet;
 
   std::string report = " * Target \"";
   report += tgt->GetName();
-  if (explicitlySet)
-    {
+  if (explicitlySet) {
     report += "\" has property content \"";
     report += valueAsString<PropertyType>(propContent);
     report += "\"\n";
-    }
-  else if (impliedByUse)
-    {
+  } else if (impliedByUse) {
     report += "\" property is implied by use.\n";
-    }
-  else
-    {
+  } else {
     report += "\" property not set.\n";
-    }
+  }
 
   std::string interfaceProperty = "INTERFACE_" + p;
-  for(std::vector<cmGeneratorTarget const*>::const_iterator li =
-      deps.begin();
-      li != deps.end(); ++li)
-    {
+  for (std::vector<cmGeneratorTarget const*>::const_iterator li = deps.begin();
+       li != deps.end(); ++li) {
     // An error should be reported if one dependency
     // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
     // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the
@@ -4318,221 +3646,169 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
 
     std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
 
-    const bool ifaceIsSet =
-        std::find(propKeys.begin(), propKeys.end(),
-                  interfaceProperty) != propKeys.end();
+    const bool ifaceIsSet = std::find(propKeys.begin(), propKeys.end(),
+                                      interfaceProperty) != propKeys.end();
     PropertyType ifacePropContent =
-                    getTypedProperty<PropertyType>(theTarget,
-                              interfaceProperty);
+      getTypedProperty<PropertyType>(theTarget, interfaceProperty);
 
     std::string reportEntry;
-    if (ifaceIsSet)
-      {
+    if (ifaceIsSet) {
       reportEntry += " * Target \"";
       reportEntry += theTarget->GetName();
       reportEntry += "\" property value \"";
       reportEntry += valueAsString<PropertyType>(ifacePropContent);
       reportEntry += "\" ";
-      }
+    }
 
-    if (explicitlySet)
-      {
-      if (ifaceIsSet)
-        {
+    if (explicitlySet) {
+      if (ifaceIsSet) {
         std::pair<bool, PropertyType> consistent =
-                                  consistentProperty(propContent,
-                                                     ifacePropContent, t);
+          consistentProperty(propContent, ifacePropContent, t);
         report += reportEntry;
         report += compatibilityAgree(t, propContent != consistent.second);
-        if (!consistent.first)
-          {
+        if (!consistent.first) {
           std::ostringstream e;
-          e << "Property " << p << " on target \""
-            << tgt->GetName() << "\" does\nnot match the "
-            "INTERFACE_" << p << " property requirement\nof "
-            "dependency \"" << theTarget->GetName() << "\".\n";
+          e << "Property " << p << " on target \"" << tgt->GetName()
+            << "\" does\nnot match the "
+               "INTERFACE_"
+            << p << " property requirement\nof "
+                    "dependency \""
+            << theTarget->GetName() << "\".\n";
           cmSystemTools::Error(e.str().c_str());
           break;
-          }
-        else
-          {
+        } else {
           propContent = consistent.second;
           continue;
-          }
         }
-      else
-        {
+      } else {
         // Explicitly set on target and not set in iface. Can't disagree.
         continue;
-        }
       }
-    else if (impliedByUse)
-      {
+    } else if (impliedByUse) {
       propContent = impliedValue<PropertyType>(propContent);
 
-      if (ifaceIsSet)
-        {
+      if (ifaceIsSet) {
         std::pair<bool, PropertyType> consistent =
-                                  consistentProperty(propContent,
-                                                     ifacePropContent, t);
+          consistentProperty(propContent, ifacePropContent, t);
         report += reportEntry;
         report += compatibilityAgree(t, propContent != consistent.second);
-        if (!consistent.first)
-          {
+        if (!consistent.first) {
           std::ostringstream e;
-          e << "Property " << p << " on target \""
-            << tgt->GetName() << "\" is\nimplied to be " << defaultValue
+          e << "Property " << p << " on target \"" << tgt->GetName()
+            << "\" is\nimplied to be " << defaultValue
             << " because it was used to determine the link libraries\n"
-               "already. The INTERFACE_" << p << " property on\ndependency \""
-            << theTarget->GetName() << "\" is in conflict.\n";
+               "already. The INTERFACE_"
+            << p << " property on\ndependency \"" << theTarget->GetName()
+            << "\" is in conflict.\n";
           cmSystemTools::Error(e.str().c_str());
           break;
-          }
-        else
-          {
+        } else {
           propContent = consistent.second;
           continue;
-          }
         }
-      else
-        {
+      } else {
         // Implicitly set on target and not set in iface. Can't disagree.
         continue;
-        }
       }
-    else
-      {
-      if (ifaceIsSet)
-        {
-        if (propInitialized)
-          {
+    } else {
+      if (ifaceIsSet) {
+        if (propInitialized) {
           std::pair<bool, PropertyType> consistent =
-                                    consistentProperty(propContent,
-                                                       ifacePropContent, t);
+            consistentProperty(propContent, ifacePropContent, t);
           report += reportEntry;
           report += compatibilityAgree(t, propContent != consistent.second);
-          if (!consistent.first)
-            {
+          if (!consistent.first) {
             std::ostringstream e;
             e << "The INTERFACE_" << p << " property of \""
               << theTarget->GetName() << "\" does\nnot agree with the value "
-                "of " << p << " already determined\nfor \""
-              << tgt->GetName() << "\".\n";
+                                         "of "
+              << p << " already determined\nfor \"" << tgt->GetName()
+              << "\".\n";
             cmSystemTools::Error(e.str().c_str());
             break;
-            }
-          else
-            {
+          } else {
             propContent = consistent.second;
             continue;
-            }
           }
-        else
-          {
+        } else {
           report += reportEntry + "(Interface set)\n";
           propContent = ifacePropContent;
           propInitialized = true;
-          }
         }
-      else
-        {
+      } else {
         // Not set. Nothing to agree on.
         continue;
-        }
       }
     }
+  }
 
   tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent),
                             report, compatibilityType(t));
   return propContent;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty(
-    const std::string &p, const std::string& config) const
+  const std::string& p, const std::string& config) const
 {
-  return checkInterfacePropertyCompatibility<bool>(this, p, config,
-                                                   "FALSE",
+  return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
                                                    BoolType, 0);
 }
 
-//----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty(
-                                              const std::string &p,
-                                              const std::string& config) const
+  const std::string& p, const std::string& config) const
 {
-  return checkInterfacePropertyCompatibility<const char *>(this,
-                                                           p,
-                                                           config,
-                                                           "empty",
-                                                     StringType, 0);
+  return checkInterfacePropertyCompatibility<const char*>(
+    this, p, config, "empty", StringType, 0);
 }
 
-//----------------------------------------------------------------------------
-const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty(
-                                              const std::string &p,
-                                              const std::string& config) const
+const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty(
+  const std::string& p, const std::string& config) const
 {
-  return checkInterfacePropertyCompatibility<const char *>(this,
-                                                           p,
-                                                           config,
-                                                           "empty",
-                                                   NumberMinType, 0);
+  return checkInterfacePropertyCompatibility<const char*>(
+    this, p, config, "empty", NumberMinType, 0);
 }
 
-//----------------------------------------------------------------------------
-const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty(
-                                              const std::string &p,
-                                              const std::string& config) const
+const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty(
+  const std::string& p, const std::string& config) const
 {
-  return checkInterfacePropertyCompatibility<const char *>(this,
-                                                           p,
-                                                           config,
-                                                           "empty",
-                                                   NumberMaxType, 0);
+  return checkInterfacePropertyCompatibility<const char*>(
+    this, p, config, "empty", NumberMaxType, 0);
 }
 
-//----------------------------------------------------------------------------
-cmComputeLinkInformation*
-cmGeneratorTarget::GetLinkInformation(const std::string& config) const
+cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(
+  const std::string& config) const
 {
   // Lookup any existing information for this configuration.
   std::string key(cmSystemTools::UpperCase(config));
-  cmTargetLinkInformationMap::iterator
-    i = this->LinkInformation.find(key);
-  if(i == this->LinkInformation.end())
-    {
+  cmTargetLinkInformationMap::iterator i = this->LinkInformation.find(key);
+  if (i == this->LinkInformation.end()) {
     // Compute information for this configuration.
     cmComputeLinkInformation* info =
       new cmComputeLinkInformation(this, config);
-    if(!info || !info->Compute())
-      {
+    if (!info || !info->Compute()) {
       delete info;
       info = 0;
-      }
+    }
 
     // Store the information for this configuration.
     cmTargetLinkInformationMap::value_type entry(key, info);
     i = this->LinkInformation.insert(entry).first;
 
-    if (info)
-      {
+    if (info) {
       this->CheckPropertyCompatibility(info, config);
-      }
     }
+  }
   return i->second;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const
 {
   int patch;
   this->GetTargetVersion(false, major, minor, patch);
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetTargetVersion(bool soversion,
-                                int& major, int& minor, int& patch) const
+void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major,
+                                         int& minor, int& patch) const
 {
   // Set the default values.
   major = 0;
@@ -4542,58 +3818,52 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion,
   assert(this->GetType() != cmState::INTERFACE_LIBRARY);
 
   // Look for a VERSION or SOVERSION property.
-  const char* prop = soversion? "SOVERSION" : "VERSION";
-  if(const char* version = this->GetProperty(prop))
-    {
+  const char* prop = soversion ? "SOVERSION" : "VERSION";
+  if (const char* version = this->GetProperty(prop)) {
     // Try to parse the version number and store the results that were
     // successfully parsed.
     int parsed_major;
     int parsed_minor;
     int parsed_patch;
-    switch(sscanf(version, "%d.%d.%d",
-                  &parsed_major, &parsed_minor, &parsed_patch))
-      {
-      case 3: patch = parsed_patch; // no break!
-      case 2: minor = parsed_minor; // no break!
-      case 1: major = parsed_major; // no break!
-      default: break;
-      }
+    switch (sscanf(version, "%d.%d.%d", &parsed_major, &parsed_minor,
+                   &parsed_patch)) {
+      case 3:
+        patch = parsed_patch; // no break!
+      case 2:
+        minor = parsed_minor; // no break!
+      case 1:
+        major = parsed_major; // no break!
+      default:
+        break;
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetFrameworkVersion() const
 {
   assert(this->GetType() != cmState::INTERFACE_LIBRARY);
 
-  if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
-    {
+  if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
     return fversion;
-    }
-  else if(const char* tversion = this->GetProperty("VERSION"))
-    {
+  } else if (const char* tversion = this->GetProperty("VERSION")) {
     return tversion;
-    }
-  else
-    {
+  } else {
     return "A";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
-                                    std::string const& prefix,
-                                    std::string const& base,
-                                    std::string const& suffix,
-                                    std::string const& name,
-                                    const char* version) const
-{
-  vName = this->Makefile->IsOn("APPLE") ? (prefix+base) : name;
-  if(version)
-    {
+                                             std::string const& prefix,
+                                             std::string const& base,
+                                             std::string const& suffix,
+                                             std::string const& name,
+                                             const char* version) const
+{
+  vName = this->Makefile->IsOn("APPLE") ? (prefix + base) : name;
+  if (version) {
     vName += ".";
     vName += version;
-    }
+  }
   vName += this->Makefile->IsOn("APPLE") ? suffix : std::string();
 }
 
@@ -4603,42 +3873,33 @@ std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
   std::vector<std::string> props;
   props.reserve(propsObject.size());
   for (cmPropertyMap::const_iterator it = propsObject.begin();
-       it != propsObject.end(); ++it)
-    {
+       it != propsObject.end(); ++it) {
     props.push_back(it->first);
-    }
+  }
   return props;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
-                               const std::string &result,
-                               const std::string &report,
-                               const std::string &compatibilityType) const
+void cmGeneratorTarget::ReportPropertyOrigin(
+  const std::string& p, const std::string& result, const std::string& report,
+  const std::string& compatibilityType) const
 {
   std::vector<std::string> debugProperties;
-  const char *debugProp = this->Target->GetMakefile()
-      ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
-  if (debugProp)
-    {
+  const char* debugProp = this->Target->GetMakefile()->GetDefinition(
+    "CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp) {
     cmSystemTools::ExpandListArgument(debugProp, debugProperties);
-    }
+  }
 
-  bool debugOrigin = !this->DebugCompatiblePropertiesDone[p]
-                    && std::find(debugProperties.begin(),
-                                 debugProperties.end(),
-                                 p)
-                        != debugProperties.end();
+  bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] &&
+    std::find(debugProperties.begin(), debugProperties.end(), p) !=
+      debugProperties.end();
 
-  if (this->GlobalGenerator->GetConfigureDoneCMP0026())
-    {
+  if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
     this->DebugCompatiblePropertiesDone[p] = true;
-    }
-  if (!debugOrigin)
-    {
+  }
+  if (!debugOrigin) {
     return;
-    }
+  }
 
   std::string areport = compatibilityType;
   areport += std::string(" of property \"") + p + "\" for target \"";
@@ -4650,302 +3911,241 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
   this->LocalGenerator->GetCMakeInstance()->IssueMessage(cmake::LOG, areport);
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
-                               std::vector<cmLinkItem>& items) const
+                                        std::vector<cmLinkItem>& items) const
 {
-  for(std::vector<std::string>::const_iterator i = names.begin();
-      i != names.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = names.begin();
+       i != names.end(); ++i) {
     std::string name = this->CheckCMP0004(*i);
-    if(name == this->GetName() || name.empty())
-      {
+    if (name == this->GetName() || name.empty()) {
       continue;
-      }
-    items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
     }
+    items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
-                               std::string const& value,
-                               std::string const& config,
-                               cmGeneratorTarget const* headTarget,
-                               bool usage_requirements_only,
-                               std::vector<cmLinkItem>& items,
-                               bool& hadHeadSensitiveCondition) const
+void cmGeneratorTarget::ExpandLinkItems(
+  std::string const& prop, std::string const& value, std::string const& config,
+  cmGeneratorTarget const* headTarget, bool usage_requirements_only,
+  std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition) const
 {
   cmGeneratorExpression ge;
   cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0);
   // The $<LINK_ONLY> expression may be in a link interface to specify private
   // link dependencies that are otherwise excluded from usage requirements.
-  if(usage_requirements_only)
-    {
+  if (usage_requirements_only) {
     dagChecker.SetTransitivePropertiesOnly();
-    }
+  }
   std::vector<std::string> libs;
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
-  cmSystemTools::ExpandListArgument(cge->Evaluate(
-                                      this->LocalGenerator,
-                                      config,
-                                      false,
-                                      headTarget,
-                                      this, &dagChecker), libs);
+  cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config,
+                                                  false, headTarget, this,
+                                                  &dagChecker),
+                                    libs);
   this->LookupLinkItems(libs, items);
   hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
 }
 
-//----------------------------------------------------------------------------
-cmLinkInterface const*
-cmGeneratorTarget::GetLinkInterface(const std::string& config,
-                                    cmGeneratorTarget const* head) const
+cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
+  const std::string& config, cmGeneratorTarget const* head) const
 {
   // Imported targets have their own link interface.
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return this->GetImportLinkInterface(config, head, false);
-    }
+  }
 
   // Link interfaces are not supported for executables that do not
   // export symbols.
-  if(this->GetType() == cmState::EXECUTABLE &&
-     !this->IsExecutableWithExports())
-    {
+  if (this->GetType() == cmState::EXECUTABLE &&
+      !this->IsExecutableWithExports()) {
     return 0;
-    }
+  }
 
   // Lookup any existing link interface for this configuration.
-  cmHeadToLinkInterfaceMap& hm =
-      this->GetHeadToLinkInterfaceMap(config);
+  cmHeadToLinkInterfaceMap& hm = this->GetHeadToLinkInterfaceMap(config);
 
   // If the link interface does not depend on the head target
   // then return the one we computed first.
-  if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
-    {
+  if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
     return &hm.begin()->second;
-    }
+  }
 
   cmOptionalLinkInterface& iface = hm[head];
-  if(!iface.LibrariesDone)
-    {
+  if (!iface.LibrariesDone) {
     iface.LibrariesDone = true;
-    this->ComputeLinkInterfaceLibraries(
-      config, iface, head, false);
-    }
-  if(!iface.AllDone)
-    {
+    this->ComputeLinkInterfaceLibraries(config, iface, head, false);
+  }
+  if (!iface.AllDone) {
     iface.AllDone = true;
-    if(iface.Exists)
-      {
+    if (iface.Exists) {
       this->ComputeLinkInterface(config, iface, head);
-      }
     }
+  }
 
-  return iface.Exists? &iface : 0;
+  return iface.Exists ? &iface : 0;
 }
 
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::ComputeLinkInterface(const std::string& config,
-                                    cmOptionalLinkInterface &iface,
-                                    cmGeneratorTarget const* headTarget) const
+void cmGeneratorTarget::ComputeLinkInterface(
+  const std::string& config, cmOptionalLinkInterface& iface,
+  cmGeneratorTarget const* headTarget) const
 {
-  if(iface.ExplicitLibraries)
-    {
-    if(this->GetType() == cmState::SHARED_LIBRARY
-        || this->GetType() == cmState::STATIC_LIBRARY
-        || this->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  if (iface.ExplicitLibraries) {
+    if (this->GetType() == cmState::SHARED_LIBRARY ||
+        this->GetType() == cmState::STATIC_LIBRARY ||
+        this->GetType() == cmState::INTERFACE_LIBRARY) {
       // Shared libraries may have runtime implementation dependencies
       // on other shared libraries that are not in the interface.
       UNORDERED_SET<std::string> emitted;
-      for(std::vector<cmLinkItem>::const_iterator
-          li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
-        {
+      for (std::vector<cmLinkItem>::const_iterator li =
+             iface.Libraries.begin();
+           li != iface.Libraries.end(); ++li) {
         emitted.insert(*li);
-        }
-      if (this->GetType() != cmState::INTERFACE_LIBRARY)
-        {
-        cmLinkImplementation const* impl =
-            this->GetLinkImplementation(config);
-        for(std::vector<cmLinkImplItem>::const_iterator
-              li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
-          {
-          if(emitted.insert(*li).second)
-            {
-            if(li->Target)
-              {
+      }
+      if (this->GetType() != cmState::INTERFACE_LIBRARY) {
+        cmLinkImplementation const* impl = this->GetLinkImplementation(config);
+        for (std::vector<cmLinkImplItem>::const_iterator li =
+               impl->Libraries.begin();
+             li != impl->Libraries.end(); ++li) {
+          if (emitted.insert(*li).second) {
+            if (li->Target) {
               // This is a runtime dependency on another shared library.
-              if(li->Target->GetType() == cmState::SHARED_LIBRARY)
-                {
+              if (li->Target->GetType() == cmState::SHARED_LIBRARY) {
                 iface.SharedDeps.push_back(*li);
-                }
               }
-            else
-              {
+            } 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->GetPolicyStatusCMP0022() == cmPolicies::WARN
-        || this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
-    {
+  } else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN ||
+             this->GetPolicyStatusCMP0022() == cmPolicies::OLD) {
     // The link implementation is the default link interface.
-    cmLinkImplementationLibraries const*
-      impl = this->GetLinkImplementationLibrariesInternal(config,
-                                                          headTarget);
+    cmLinkImplementationLibraries const* impl =
+      this->GetLinkImplementationLibrariesInternal(config, headTarget);
     iface.ImplementationIsInterface = true;
     iface.WrongConfigLibraries = impl->WrongConfigLibraries;
-    }
+  }
 
-  if(this->LinkLanguagePropagatesToDependents())
-    {
+  if (this->LinkLanguagePropagatesToDependents()) {
     // Targets using this archive need its language runtime libraries.
-    if(cmLinkImplementation const* impl =
-       this->GetLinkImplementation(config))
-      {
+    if (cmLinkImplementation const* impl =
+          this->GetLinkImplementation(config)) {
       iface.Languages = impl->Languages;
-      }
     }
+  }
 
-  if(this->GetType() == cmState::STATIC_LIBRARY)
-    {
+  if (this->GetType() == cmState::STATIC_LIBRARY) {
     // Construct the property name suffix for this configuration.
     std::string suffix = "_";
-    if(!config.empty())
-      {
+    if (!config.empty()) {
       suffix += cmSystemTools::UpperCase(config);
-      }
-    else
-      {
+    } 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))
-      {
+    if (const char* config_reps = this->GetProperty(propName)) {
       sscanf(config_reps, "%u", &iface.Multiplicity);
-      }
-    else if(const char* reps =
-            this->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
-      {
+    } else if (const char* reps =
+                 this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) {
       sscanf(reps, "%u", &iface.Multiplicity);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-const cmLinkInterfaceLibraries *
-cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config,
-                                    cmGeneratorTarget const* head,
-                                    bool usage_requirements_only) const
+const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
+  const std::string& config, cmGeneratorTarget const* head,
+  bool usage_requirements_only) const
 {
   // Imported targets have their own link interface.
-  if(this->IsImported())
-    {
-    return this->GetImportLinkInterface(config, head,
-                                                usage_requirements_only);
-    }
+  if (this->IsImported()) {
+    return this->GetImportLinkInterface(config, head, usage_requirements_only);
+  }
 
   // Link interfaces are not supported for executables that do not
   // export symbols.
-  if(this->GetType() == cmState::EXECUTABLE &&
-     !this->IsExecutableWithExports())
-    {
+  if (this->GetType() == cmState::EXECUTABLE &&
+      !this->IsExecutableWithExports()) {
     return 0;
-    }
+  }
 
   // Lookup any existing link interface for this configuration.
   std::string CONFIG = cmSystemTools::UpperCase(config);
   cmHeadToLinkInterfaceMap& hm =
-    (usage_requirements_only ?
-     this->GetHeadToLinkInterfaceUsageRequirementsMap(config) :
-     this->GetHeadToLinkInterfaceMap(config));
+    (usage_requirements_only
+       ? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
+       : this->GetHeadToLinkInterfaceMap(config));
 
   // If the link interface does not depend on the head target
   // then return the one we computed first.
-  if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
-    {
+  if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
     return &hm.begin()->second;
-    }
+  }
 
   cmOptionalLinkInterface& iface = hm[head];
-  if(!iface.LibrariesDone)
-    {
+  if (!iface.LibrariesDone) {
     iface.LibrariesDone = true;
-    this->ComputeLinkInterfaceLibraries(
-      config, iface, head, usage_requirements_only);
-    }
+    this->ComputeLinkInterfaceLibraries(config, iface, head,
+                                        usage_requirements_only);
+  }
 
-  return iface.Exists? &iface : 0;
+  return iface.Exists ? &iface : 0;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetDirectory(const std::string& config,
-                                   bool implib) const
+                                            bool implib) const
 {
-  if (this->IsImported())
-    {
+  if (this->IsImported()) {
     // Return the directory from which the target is imported.
-    return
-      cmSystemTools::GetFilenamePath(
+    return cmSystemTools::GetFilenamePath(
       this->Target->ImportedGetFullPath(config, implib));
-    }
-  else if(OutputInfo const* info = this->GetOutputInfo(config))
-    {
+  } else if (OutputInfo const* info = this->GetOutputInfo(config)) {
     // Return the directory in which the target will be built.
-    return implib? info->ImpDir : info->OutDir;
-    }
+    return implib ? info->ImpDir : info->OutDir;
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config,
-                                    bool implib) const
+                                             bool implib) const
 {
   std::string dir;
   return this->ComputeOutputDir(config, implib, dir);
 }
 
-//----------------------------------------------------------------------------
 cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
-    const std::string& config) const
+  const std::string& config) const
 {
   // There is no output information for imported targets.
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return 0;
-    }
+  }
 
   // Only libraries and executables have well-defined output files.
-  if(!this->HaveWellDefinedOutputFiles())
-    {
+  if (!this->HaveWellDefinedOutputFiles()) {
     std::string msg = "cmGeneratorTarget::GetOutputInfo called for ";
     msg += this->GetName();
     msg += " which has type ";
     msg += cmState::GetTargetTypeName(this->GetType());
     this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
     return 0;
-    }
+  }
 
   // Lookup/compute/cache the output information for this configuration.
   std::string config_upper;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     config_upper = cmSystemTools::UpperCase(config);
-    }
-  OutputInfoMapType::iterator i =
-    this->OutputInfoMap.find(config_upper);
-  if(i == this->OutputInfoMap.end())
-    {
+  }
+  OutputInfoMapType::iterator i = this->OutputInfoMap.find(config_upper);
+  if (i == this->OutputInfoMap.end()) {
     // Add empty info in map to detect potential recursion.
     OutputInfo info;
     OutputInfoMapType::value_type entry(config_upper, info);
@@ -4954,16 +4154,13 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
     // Compute output directories.
     this->ComputeOutputDir(config, false, info.OutDir);
     this->ComputeOutputDir(config, true, info.ImpDir);
-    if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir))
-      {
+    if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) {
       info.PdbDir = info.OutDir;
-      }
+    }
 
     // Now update the previously-prepared map entry.
     i->second = info;
-    }
-  else if(i->second.empty())
-    {
+  } else if (i->second.empty()) {
     // An empty map entry indicates we have been called recursively
     // from the above block.
     this->LocalGenerator->GetCMakeInstance()->IssueMessage(
@@ -4971,13 +4168,12 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
       "Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.",
       this->GetBacktrace());
     return 0;
-    }
+  }
   return &i->second;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
-                                bool implib, std::string& out) const
+                                         bool implib, std::string& out) const
 {
   bool usesDefaultOutputDir = false;
   std::string conf = config;
@@ -4987,26 +4183,23 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
   std::string targetTypeName = this->GetOutputTargetType(implib);
   const char* propertyName = 0;
   std::string propertyNameStr = targetTypeName;
-  if(!propertyNameStr.empty())
-    {
+  if (!propertyNameStr.empty()) {
     propertyNameStr += "_OUTPUT_DIRECTORY";
     propertyName = propertyNameStr.c_str();
-    }
+  }
 
   // Check for a per-configuration output directory target property.
   std::string configUpper = cmSystemTools::UpperCase(conf);
   const char* configProp = 0;
   std::string configPropStr = targetTypeName;
-  if(!configPropStr.empty())
-    {
+  if (!configPropStr.empty()) {
     configPropStr += "_OUTPUT_DIRECTORY_";
     configPropStr += configUpper;
     configProp = configPropStr.c_str();
-    }
+  }
 
   // Select an output directory.
-  if(const char* config_outdir = this->GetProperty(configProp))
-    {
+  if (const char* config_outdir = this->GetProperty(configProp)) {
     // Use the user-specified per-configuration output directory.
     cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
@@ -5015,162 +4208,133 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
 
     // Skip per-configuration subdirectory.
     conf = "";
-    }
-  else if(const char* outdir = this->GetProperty(propertyName))
-    {
+  } else if (const char* outdir = this->GetProperty(propertyName)) {
     // Use the user-specified output directory.
     cmGeneratorExpression ge;
-    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
-      ge.Parse(outdir);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(outdir);
     out = cge->Evaluate(this->LocalGenerator, config);
 
     // Skip per-configuration subdirectory if the value contained a
     // generator expression.
-    if (out != outdir)
-      {
+    if (out != outdir) {
       conf = "";
-      }
     }
-  else if(this->GetType() == cmState::EXECUTABLE)
-    {
+  } else if (this->GetType() == cmState::EXECUTABLE) {
     // Lookup the output path for executables.
     out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
-    }
-  else if(this->GetType() == cmState::STATIC_LIBRARY ||
-          this->GetType() == cmState::SHARED_LIBRARY ||
-          this->GetType() == cmState::MODULE_LIBRARY)
-    {
+  } else if (this->GetType() == cmState::STATIC_LIBRARY ||
+             this->GetType() == cmState::SHARED_LIBRARY ||
+             this->GetType() == cmState::MODULE_LIBRARY) {
     // Lookup the output path for libraries.
     out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
-    }
-  if(out.empty())
-    {
+  }
+  if (out.empty()) {
     // Default to the current output directory.
     usesDefaultOutputDir = true;
     out = ".";
-    }
+  }
 
   // Convert the output path to a full path in case it is
   // specified as a relative path.  Treat a relative path as
   // relative to the current output directory for this makefile.
-  out = (cmSystemTools::CollapseFullPath
-         (out, this->LocalGenerator->GetCurrentBinaryDirectory()));
+  out = (cmSystemTools::CollapseFullPath(
+    out, this->LocalGenerator->GetCurrentBinaryDirectory()));
 
   // The generator may add the configuration's subdirectory.
-  if(!conf.empty())
-    {
+  if (!conf.empty()) {
     bool iosPlatform = this->Makefile->PlatformIsAppleIos();
     std::string suffix =
       usesDefaultOutputDir && iosPlatform ? "${EFFECTIVE_PLATFORM_NAME}" : "";
-    this->LocalGenerator->GetGlobalGenerator()->
-      AppendDirectoryForConfig("/", conf, suffix, out);
-    }
+    this->LocalGenerator->GetGlobalGenerator()->AppendDirectoryForConfig(
+      "/", conf, suffix, out);
+  }
 
   return usesDefaultOutputDir;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
-                                   const std::string& config,
-                                   std::string& out) const
+                                            const std::string& config,
+                                            std::string& out) const
 {
   // Look for a target property defining the target output directory
   // based on the target type.
   const char* propertyName = 0;
   std::string propertyNameStr = kind;
-  if(!propertyNameStr.empty())
-    {
+  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(conf);
   const char* configProp = 0;
   std::string configPropStr = kind;
-  if(!configPropStr.empty())
-    {
+  if (!configPropStr.empty()) {
     configPropStr += "_OUTPUT_DIRECTORY_";
     configPropStr += configUpper;
     configProp = configPropStr.c_str();
-    }
+  }
 
   // Select an output directory.
-  if(const char* config_outdir = this->GetProperty(configProp))
-    {
+  if (const char* config_outdir = this->GetProperty(configProp)) {
     // Use the user-specified per-configuration output directory.
     out = config_outdir;
 
     // Skip per-configuration subdirectory.
     conf = "";
-    }
-  else if(const char* outdir = this->GetProperty(propertyName))
-    {
+  } else if (const char* outdir = this->GetProperty(propertyName)) {
     // Use the user-specified output directory.
     out = outdir;
-    }
-  if(out.empty())
-    {
+  }
+  if (out.empty()) {
     return false;
-    }
+  }
 
   // Convert the output path to a full path in case it is
   // specified as a relative path.  Treat a relative path as
   // relative to the current output directory for this makefile.
-  out = (cmSystemTools::CollapseFullPath
-         (out, this->LocalGenerator->GetCurrentBinaryDirectory()));
+  out = (cmSystemTools::CollapseFullPath(
+    out, this->LocalGenerator->GetCurrentBinaryDirectory()));
 
   // The generator may add the configuration's subdirectory.
-  if(!conf.empty())
-    {
-    this->LocalGenerator->GetGlobalGenerator()->
-      AppendDirectoryForConfig("/", conf, "", out);
-    }
+  if (!conf.empty()) {
+    this->LocalGenerator->GetGlobalGenerator()->AppendDirectoryForConfig(
+      "/", conf, "", out);
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HaveInstallTreeRPATH() const
 {
   const char* install_rpath = this->GetProperty("INSTALL_RPATH");
   return (install_rpath && *install_rpath) &&
-          !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
+    !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
 }
 
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::ComputeLinkInterfaceLibraries(
-  const std::string& config,
-  cmOptionalLinkInterface& iface,
-  cmGeneratorTarget const* headTarget,
-  bool usage_requirements_only) const
+void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
+  const std::string& config, cmOptionalLinkInterface& iface,
+  cmGeneratorTarget const* headTarget, bool usage_requirements_only) const
 {
   // Construct the property name suffix for this configuration.
   std::string suffix = "_";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     suffix += cmSystemTools::UpperCase(config);
-    }
-  else
-    {
+  } else {
     suffix += "NOCONFIG";
-    }
+  }
 
   // An explicit list of interface libraries may be set for shared
   // libraries and executables that export symbols.
   const char* explicitLibraries = 0;
   std::string linkIfaceProp;
-  if(this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
-     this->GetPolicyStatusCMP0022() != cmPolicies::WARN)
-    {
+  if (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
+      this->GetPolicyStatusCMP0022() != cmPolicies::WARN) {
     // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
     linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
     explicitLibraries = this->GetProperty(linkIfaceProp);
-    }
-  else if(this->GetType() == cmState::SHARED_LIBRARY ||
-          this->IsExecutableWithExports())
-    {
+  } else if (this->GetType() == cmState::SHARED_LIBRARY ||
+             this->IsExecutableWithExports()) {
     // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
     // shared lib or executable.
 
@@ -5180,25 +4344,23 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries(
     explicitLibraries = this->GetProperty(linkIfaceProp);
 
     // If not set, try the generic property.
-    if(!explicitLibraries)
-      {
+    if (!explicitLibraries) {
       linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
       explicitLibraries = this->GetProperty(linkIfaceProp);
-      }
     }
+  }
 
-  if(explicitLibraries &&
-     this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
-     !this->PolicyWarnedCMP0022)
-    {
+  if (explicitLibraries &&
+      this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
+      !this->PolicyWarnedCMP0022) {
     // Compare the explicitly set old link interface properties to the
     // preferred new link interface property one and warn if different.
     const char* newExplicitLibraries =
       this->GetProperty("INTERFACE_LINK_LIBRARIES");
-    if (newExplicitLibraries
-        && strcmp(newExplicitLibraries, explicitLibraries) != 0)
-      {
+    if (newExplicitLibraries &&
+        strcmp(newExplicitLibraries, explicitLibraries) != 0) {
       std::ostringstream w;
+      /* clang-format off */
       w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
         "Target \"" << this->GetName() << "\" has an "
         "INTERFACE_LINK_LIBRARIES property which differs from its " <<
@@ -5208,68 +4370,62 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries(
         "  " << newExplicitLibraries << "\n" <<
         linkIfaceProp << ":\n"
         "  " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
+      /* clang-format on */
       this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
       this->PolicyWarnedCMP0022 = true;
-      }
     }
+  }
 
   // There is no implicit link interface for executables or modules
   // so if none was explicitly set then there is no link interface.
-  if(!explicitLibraries &&
-     (this->GetType() == cmState::EXECUTABLE ||
-      (this->GetType() == cmState::MODULE_LIBRARY)))
-    {
+  if (!explicitLibraries && (this->GetType() == cmState::EXECUTABLE ||
+                             (this->GetType() == cmState::MODULE_LIBRARY))) {
     return;
-    }
+  }
   iface.Exists = true;
   iface.ExplicitLibraries = explicitLibraries;
 
-  if(explicitLibraries)
-    {
+  if (explicitLibraries) {
     // The interface libraries have been explicitly set.
-    this->ExpandLinkItems(linkIfaceProp, explicitLibraries,
-                                  config,
-                                headTarget, usage_requirements_only,
-                                iface.Libraries,
-                                iface.HadHeadSensitiveCondition);
-    }
-  else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN
-        || this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
-    // If CMP0022 is NEW then the plain tll signature sets the
-    // INTERFACE_LINK_LIBRARIES, so if we get here then the project
-    // cleared the property explicitly and we should not fall back
-    // to the link implementation.
-    {
+    this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget,
+                          usage_requirements_only, iface.Libraries,
+                          iface.HadHeadSensitiveCondition);
+  } else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN ||
+             this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
+  // If CMP0022 is NEW then the plain tll signature sets the
+  // INTERFACE_LINK_LIBRARIES, so if we get here then the project
+  // cleared the property explicitly and we should not fall back
+  // to the link implementation.
+  {
     // The link implementation is the default link interface.
     cmLinkImplementationLibraries const* impl =
       this->GetLinkImplementationLibrariesInternal(config, headTarget);
-    iface.Libraries.insert(iface.Libraries.end(),
-                           impl->Libraries.begin(), impl->Libraries.end());
-    if(this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
-       !this->PolicyWarnedCMP0022 && !usage_requirements_only)
-      {
+    iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(),
+                           impl->Libraries.end());
+    if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
+        !this->PolicyWarnedCMP0022 && !usage_requirements_only) {
       // Compare the link implementation fallback link interface to the
       // preferred new link interface property and warn if different.
       std::vector<cmLinkItem> ifaceLibs;
       static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
-      if(const char* newExplicitLibraries = this->GetProperty(newProp))
-        {
+      if (const char* newExplicitLibraries = this->GetProperty(newProp)) {
         bool hadHeadSensitiveConditionDummy = false;
         this->ExpandLinkItems(newProp, newExplicitLibraries, config,
-                              headTarget,
-                              usage_requirements_only,
-                              ifaceLibs, hadHeadSensitiveConditionDummy);
-        }
-      if (ifaceLibs != iface.Libraries)
-        {
+                              headTarget, usage_requirements_only, ifaceLibs,
+                              hadHeadSensitiveConditionDummy);
+      }
+      if (ifaceLibs != iface.Libraries) {
         std::string oldLibraries = cmJoin(impl->Libraries, ";");
         std::string newLibraries = cmJoin(ifaceLibs, ";");
-        if(oldLibraries.empty())
-          { oldLibraries = "(empty)"; }
-        if(newLibraries.empty())
-          { newLibraries = "(empty)"; }
+        if (oldLibraries.empty()) {
+          oldLibraries = "(empty)";
+        }
+        if (newLibraries.empty()) {
+          newLibraries = "(empty)";
+        }
 
         std::ostringstream w;
+        /* clang-format off */
         w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
           "Target \"" << this->GetName() << "\" has an "
           "INTERFACE_LINK_LIBRARIES property.  "
@@ -5282,107 +4438,91 @@ cmGeneratorTarget::ComputeLinkInterfaceLibraries(
           "  " << newLibraries << "\n"
           "Link implementation:\n"
           "  " << oldLibraries << "\n";
+        /* clang-format on */
         this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
         this->PolicyWarnedCMP0022 = true;
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-const cmLinkInterface *
-cmGeneratorTarget::GetImportLinkInterface(const std::string& config,
-                                 cmGeneratorTarget const* headTarget,
-                                 bool usage_requirements_only) const
+const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
+  const std::string& config, cmGeneratorTarget const* headTarget,
+  bool usage_requirements_only) const
 {
   cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config);
-  if(!info)
-    {
+  if (!info) {
     return 0;
-    }
+  }
 
   std::string CONFIG = cmSystemTools::UpperCase(config);
   cmHeadToLinkInterfaceMap& hm =
-    (usage_requirements_only ?
-     this->GetHeadToLinkInterfaceUsageRequirementsMap(config) :
-     this->GetHeadToLinkInterfaceMap(config));
+    (usage_requirements_only
+       ? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
+       : this->GetHeadToLinkInterfaceMap(config));
 
   // If the link interface does not depend on the head target
   // then return the one we computed first.
-  if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
-    {
+  if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
     return &hm.begin()->second;
-    }
+  }
 
   cmOptionalLinkInterface& iface = hm[headTarget];
-  if(!iface.AllDone)
-    {
+  if (!iface.AllDone) {
     iface.AllDone = true;
     iface.Multiplicity = info->Multiplicity;
     cmSystemTools::ExpandListArgument(info->Languages, iface.Languages);
-    this->ExpandLinkItems(info->LibrariesProp, info->Libraries,
-                                  config,
-                          headTarget, usage_requirements_only,
-                          iface.Libraries,
+    this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config,
+                          headTarget, usage_requirements_only, iface.Libraries,
                           iface.HadHeadSensitiveCondition);
     std::vector<std::string> deps;
     cmSystemTools::ExpandListArgument(info->SharedDeps, deps);
     this->LookupLinkItems(deps, iface.SharedDeps);
-    }
+  }
 
   return &iface;
 }
 
-//----------------------------------------------------------------------------
-cmGeneratorTarget::ImportInfo const*
-cmGeneratorTarget::GetImportInfo(const std::string& config) const
+cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo(
+  const std::string& config) const
 {
   // There is no imported information for non-imported targets.
-  if(!this->IsImported())
-    {
+  if (!this->IsImported()) {
     return 0;
-    }
+  }
 
   // Lookup/compute/cache the import information for this
   // configuration.
   std::string config_upper;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     config_upper = cmSystemTools::UpperCase(config);
-    }
-  else
-    {
+  } else {
     config_upper = "NOCONFIG";
-    }
+  }
 
-  ImportInfoMapType::const_iterator i =
-    this->ImportInfoMap.find(config_upper);
-  if(i == this->ImportInfoMap.end())
-    {
+  ImportInfoMapType::const_iterator i = this->ImportInfoMap.find(config_upper);
+  if (i == this->ImportInfoMap.end()) {
     ImportInfo info;
     this->ComputeImportInfo(config_upper, info);
     ImportInfoMapType::value_type entry(config_upper, info);
     i = this->ImportInfoMap.insert(entry).first;
-    }
+  }
 
-  if(this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::INTERFACE_LIBRARY) {
     return &i->second;
-    }
+  }
   // If the location is empty then the target is not available for
   // this configuration.
-  if(i->second.Location.empty() && i->second.ImportLibrary.empty())
-    {
+  if (i->second.Location.empty() && i->second.ImportLibrary.empty()) {
     return 0;
-    }
+  }
 
   // Return the import information.
   return &i->second;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
-                                 ImportInfo& info) const
+                                          ImportInfo& info) const
 {
   // This method finds information about an imported target from its
   // properties.  The "IMPORTED_" namespace is reserved for properties
@@ -5394,164 +4534,128 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
   const char* loc = 0;
   const char* imp = 0;
   std::string suffix;
-  if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix))
-    {
+  if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) {
     return;
-    }
+  }
 
   // Get the link interface.
   {
-  std::string linkProp = "INTERFACE_LINK_LIBRARIES";
-  const char *propertyLibs = this->GetProperty(linkProp);
-
-  if (this->GetType() != cmState::INTERFACE_LIBRARY)
-    {
-    if(!propertyLibs)
-      {
-      linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
-      linkProp += suffix;
-      propertyLibs = this->GetProperty(linkProp);
+    std::string linkProp = "INTERFACE_LINK_LIBRARIES";
+    const char* propertyLibs = this->GetProperty(linkProp);
+
+    if (this->GetType() != cmState::INTERFACE_LIBRARY) {
+      if (!propertyLibs) {
+        linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
+        linkProp += suffix;
+        propertyLibs = this->GetProperty(linkProp);
       }
 
-    if(!propertyLibs)
-      {
-      linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
-      propertyLibs = this->GetProperty(linkProp);
+      if (!propertyLibs) {
+        linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
+        propertyLibs = this->GetProperty(linkProp);
       }
     }
-  if(propertyLibs)
-    {
-    info.LibrariesProp = linkProp;
-    info.Libraries = propertyLibs;
+    if (propertyLibs) {
+      info.LibrariesProp = linkProp;
+      info.Libraries = propertyLibs;
     }
   }
-  if(this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::INTERFACE_LIBRARY) {
     return;
-    }
+  }
 
   // A provided configuration has been chosen.  Load the
   // configuration's properties.
 
   // Get the location.
-  if(loc)
-    {
+  if (loc) {
     info.Location = loc;
-    }
-  else
-    {
+  } else {
     std::string impProp = "IMPORTED_LOCATION";
     impProp += suffix;
-    if(const char* config_location = this->GetProperty(impProp))
-      {
+    if (const char* config_location = this->GetProperty(impProp)) {
       info.Location = config_location;
-      }
-    else if(const char* location = this->GetProperty("IMPORTED_LOCATION"))
-      {
+    } else if (const char* location = this->GetProperty("IMPORTED_LOCATION")) {
       info.Location = location;
-      }
     }
+  }
 
   // Get the soname.
-  if(this->GetType() == cmState::SHARED_LIBRARY)
-    {
+  if (this->GetType() == cmState::SHARED_LIBRARY) {
     std::string soProp = "IMPORTED_SONAME";
     soProp += suffix;
-    if(const char* config_soname = this->GetProperty(soProp))
-      {
+    if (const char* config_soname = this->GetProperty(soProp)) {
       info.SOName = config_soname;
-      }
-    else if(const char* soname = this->GetProperty("IMPORTED_SONAME"))
-      {
+    } else if (const char* soname = this->GetProperty("IMPORTED_SONAME")) {
       info.SOName = soname;
-      }
     }
+  }
 
   // Get the "no-soname" mark.
-  if(this->GetType() == cmState::SHARED_LIBRARY)
-    {
+  if (this->GetType() == cmState::SHARED_LIBRARY) {
     std::string soProp = "IMPORTED_NO_SONAME";
     soProp += suffix;
-    if(const char* config_no_soname = this->GetProperty(soProp))
-      {
+    if (const char* config_no_soname = this->GetProperty(soProp)) {
       info.NoSOName = cmSystemTools::IsOn(config_no_soname);
-      }
-    else if(const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME"))
-      {
+    } else if (const char* no_soname =
+                 this->GetProperty("IMPORTED_NO_SONAME")) {
       info.NoSOName = cmSystemTools::IsOn(no_soname);
-      }
     }
+  }
 
   // Get the import library.
-  if(imp)
-    {
+  if (imp) {
     info.ImportLibrary = imp;
-    }
-  else if(this->GetType() == cmState::SHARED_LIBRARY ||
-          this->IsExecutableWithExports())
-    {
+  } else if (this->GetType() == cmState::SHARED_LIBRARY ||
+             this->IsExecutableWithExports()) {
     std::string impProp = "IMPORTED_IMPLIB";
     impProp += suffix;
-    if(const char* config_implib = this->GetProperty(impProp))
-      {
+    if (const char* config_implib = this->GetProperty(impProp)) {
       info.ImportLibrary = config_implib;
-      }
-    else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB"))
-      {
+    } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
       info.ImportLibrary = implib;
-      }
     }
+  }
 
   // Get the link dependencies.
   {
-  std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
-  linkProp += suffix;
-  if(const char* config_libs = this->GetProperty(linkProp))
-    {
-    info.SharedDeps = config_libs;
-    }
-  else if(const char* libs =
-          this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES"))
-    {
-    info.SharedDeps = libs;
+    std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
+    linkProp += suffix;
+    if (const char* config_libs = this->GetProperty(linkProp)) {
+      info.SharedDeps = config_libs;
+    } else if (const char* libs =
+                 this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) {
+      info.SharedDeps = libs;
     }
   }
 
   // Get the link languages.
-  if(this->LinkLanguagePropagatesToDependents())
-    {
+  if (this->LinkLanguagePropagatesToDependents()) {
     std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
     linkProp += suffix;
-    if(const char* config_libs = this->GetProperty(linkProp))
-      {
+    if (const char* config_libs = this->GetProperty(linkProp)) {
       info.Languages = config_libs;
-      }
-    else if(const char* libs =
-            this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES"))
-      {
+    } else if (const char* libs =
+                 this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) {
       info.Languages = libs;
-      }
     }
+  }
 
   // Get the cyclic repetition count.
-  if(this->GetType() == cmState::STATIC_LIBRARY)
-    {
+  if (this->GetType() == cmState::STATIC_LIBRARY) {
     std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
     linkProp += suffix;
-    if(const char* config_reps = this->GetProperty(linkProp))
-      {
+    if (const char* config_reps = this->GetProperty(linkProp)) {
       sscanf(config_reps, "%u", &info.Multiplicity);
-      }
-    else if(const char* reps =
-            this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY"))
-      {
+    } else if (const char* reps =
+                 this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) {
       sscanf(reps, "%u", &info.Multiplicity);
-      }
     }
+  }
 }
 
-cmHeadToLinkInterfaceMap&
-cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const
+cmHeadToLinkInterfaceMap& cmGeneratorTarget::GetHeadToLinkInterfaceMap(
+  const std::string& config) const
 {
   std::string CONFIG = cmSystemTools::UpperCase(config);
   return this->LinkInterfaceMap[CONFIG];
@@ -5559,78 +4663,69 @@ cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const
 
 cmHeadToLinkInterfaceMap&
 cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap(
-    const std::string &config) const
+  const std::string& config) const
 {
   std::string CONFIG = cmSystemTools::UpperCase(config);
   return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG];
 }
 
-//----------------------------------------------------------------------------
-const cmLinkImplementation *
-cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
+const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
+  const std::string& config) const
 {
   // There is no link implementation for imported targets.
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return 0;
-    }
+  }
 
   std::string CONFIG = cmSystemTools::UpperCase(config);
   cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this];
-  if(!impl.LibrariesDone)
-    {
+  if (!impl.LibrariesDone) {
     impl.LibrariesDone = true;
     this->ComputeLinkImplementationLibraries(config, impl, this);
-    }
-  if(!impl.LanguagesDone)
-    {
+  }
+  if (!impl.LanguagesDone) {
     impl.LanguagesDone = true;
     this->ComputeLinkImplementationLanguages(config, impl);
-    }
+  }
   return &impl;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::GetConfigCommonSourceFiles(
-    std::vector<cmSourceFile*>& files) const
+  std::vector<cmSourceFile*>& files) const
 {
   std::vector<std::string> configs;
   this->Makefile->GetConfigurations(configs);
-  if (configs.empty())
-    {
+  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)
-    {
+  for (; it != configs.end(); ++it) {
     std::vector<cmSourceFile*> configFiles;
     this->GetSourceFiles(configFiles, *it);
-    if (configFiles != files)
-      {
+    if (configFiles != files) {
       std::string firstConfigFiles;
       const char* sep = "";
       for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
-           fi != files.end(); ++fi)
-        {
+           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)
-        {
+           fi != configFiles.end(); ++fi) {
         thisConfigFiles += sep;
         thisConfigFiles += (*fi)->GetFullPath();
         sep = "\n  ";
-        }
+      }
       std::ostringstream e;
+      /* clang-format off */
       e << "Target \"" << this->GetName()
         << "\" has source files which vary by "
         "configuration. This is not supported by the \""
@@ -5640,16 +4735,16 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles(
           "  " << firstConfigFiles << "\n"
           "Config \"" << *it << "\":\n"
           "  " << thisConfigFiles << "\n";
+      /* clang-format on */
       this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetObjectLibrariesCMP0026(
-    std::vector<cmGeneratorTarget*>& objlibs) const
+  std::vector<cmGeneratorTarget*>& objlibs) const
 {
   // 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
@@ -5657,37 +4752,31 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026(
   // for TARGET_OBJECTS instead for backwards compatibility with OLD
   // behavior of CMP0024 and CMP0026 only.
   cmStringRange rng = this->Target->GetSourceEntries();
-  for(std::vector<std::string>::const_iterator
-        i = rng.begin(); i != rng.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = rng.begin();
+       i != rng.end(); ++i) {
     std::string const& entry = *i;
 
     std::vector<std::string> files;
     cmSystemTools::ExpandListArgument(entry, files);
-    for (std::vector<std::string>::const_iterator
-        li = files.begin(); li != files.end(); ++li)
-      {
-      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)
-          {
+    for (std::vector<std::string>::const_iterator li = files.begin();
+         li != files.end(); ++li) {
+      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;
-          }
-        cmGeneratorTarget *objLib =
-            this->LocalGenerator->FindGeneratorTargetToUse(objLibName);
-        if(objLib)
-          {
+        }
+        cmGeneratorTarget* objLib =
+          this->LocalGenerator->FindGeneratorTargetToUse(objLibName);
+        if (objLib) {
           objlibs.push_back(objLib);
-          }
         }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
 {
   // Strip whitespace off the library names because we used to do this
@@ -5695,234 +4784,190 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
   // do the expansion but users link to libraries like " ${VAR} ".
   std::string lib = item;
   std::string::size_type pos = lib.find_first_not_of(" \t\r\n");
-  if(pos != lib.npos)
-    {
+  if (pos != lib.npos) {
     lib = lib.substr(pos, lib.npos);
-    }
+  }
   pos = lib.find_last_not_of(" \t\r\n");
-  if(pos != lib.npos)
-    {
-    lib = lib.substr(0, pos+1);
-    }
-  if(lib != item)
-    {
+  if (pos != lib.npos) {
+    lib = lib.substr(0, pos + 1);
+  }
+  if (lib != item) {
     cmake* cm = this->LocalGenerator->GetCMakeInstance();
-    switch(this->GetPolicyStatusCMP0004())
-      {
-      case cmPolicies::WARN:
-        {
+    switch (this->GetPolicyStatusCMP0004()) {
+      case cmPolicies::WARN: {
         std::ostringstream w;
         w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n"
-          << "Target \"" << this->GetName() << "\" links to item \""
-          << item << "\" which has leading or trailing whitespace.";
-        cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
-                         this->GetBacktrace());
-        }
+          << "Target \"" << this->GetName() << "\" links to item \"" << item
+          << "\" which has leading or trailing whitespace.";
+        cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->GetBacktrace());
+      }
       case cmPolicies::OLD:
         break;
-      case cmPolicies::NEW:
-        {
+      case cmPolicies::NEW: {
         std::ostringstream e;
-        e << "Target \"" << this->GetName() << "\" links to item \""
-          << item << "\" which has leading or trailing whitespace.  "
+        e << "Target \"" << this->GetName() << "\" links to item \"" << item
+          << "\" which has leading or trailing whitespace.  "
           << "This is now an error according to policy CMP0004.";
-        cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                         this->GetBacktrace());
-        }
-        break;
+        cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+      } break;
       case cmPolicies::REQUIRED_IF_USED:
-      case cmPolicies::REQUIRED_ALWAYS:
-        {
+      case cmPolicies::REQUIRED_ALWAYS: {
         std::ostringstream e;
         e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n"
-          << "Target \"" << this->GetName() << "\" links to item \""
-          << item << "\" which has leading or trailing whitespace.";
-        cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                         this->GetBacktrace());
-        }
-        break;
-      }
+          << "Target \"" << this->GetName() << "\" links to item \"" << item
+          << "\" which has leading or trailing whitespace.";
+        cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+      } break;
     }
+  }
   return lib;
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
-                            const std::string& config) const
+                                     const std::string& config) const
 {
   std::vector<cmSourceFile*> sourceFiles;
   this->GetSourceFiles(sourceFiles, config);
-  for(std::vector<cmSourceFile*>::const_iterator
-        i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin();
+       i != sourceFiles.end(); ++i) {
     const std::string& lang = (*i)->GetLanguage();
-    if(!lang.empty())
-      {
+    if (!lang.empty()) {
       languages.insert(lang);
-      }
     }
+  }
 
   std::vector<cmGeneratorTarget*> objectLibraries;
   std::vector<cmSourceFile const*> externalObjects;
-  if (!this->GlobalGenerator->GetConfigureDoneCMP0026())
-    {
+  if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) {
     std::vector<cmGeneratorTarget*> objectTargets;
     this->GetObjectLibrariesCMP0026(objectTargets);
     objectLibraries.reserve(objectTargets.size());
     for (std::vector<cmGeneratorTarget*>::const_iterator it =
-         objectTargets.begin(); it != objectTargets.end(); ++it)
-      {
+           objectTargets.begin();
+         it != objectTargets.end(); ++it) {
       objectLibraries.push_back(*it);
-      }
     }
-  else
-    {
+  } else {
     this->GetExternalObjects(externalObjects, config);
-    for(std::vector<cmSourceFile const*>::const_iterator
-          i = externalObjects.begin(); i != externalObjects.end(); ++i)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator i =
+           externalObjects.begin();
+         i != externalObjects.end(); ++i) {
       std::string objLib = (*i)->GetObjectLibrary();
       if (cmGeneratorTarget* tgt =
-          this->LocalGenerator->FindGeneratorTargetToUse(objLib))
-        {
+            this->LocalGenerator->FindGeneratorTargetToUse(objLib)) {
         objectLibraries.push_back(tgt);
-        }
       }
     }
-  for(std::vector<cmGeneratorTarget*>::const_iterator
-      i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
-    {
+  }
+  for (std::vector<cmGeneratorTarget*>::const_iterator i =
+         objectLibraries.begin();
+       i != objectLibraries.end(); ++i) {
     (*i)->GetLanguages(languages, config);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::ComputeLinkImplementationLanguages(
-  const std::string& config,
-  cmOptionalLinkImplementation& impl) const
+  const std::string& config, cmOptionalLinkImplementation& impl) const
 {
   // This target needs runtime libraries for its source languages.
   std::set<std::string> languages;
   // Get languages used in our source files.
   this->GetLanguages(languages, config);
   // Copy the set of langauges to the link implementation.
-  impl.Languages.insert(impl.Languages.begin(),
-                        languages.begin(), languages.end());
+  impl.Languages.insert(impl.Languages.begin(), languages.begin(),
+                        languages.end());
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const
 {
-  if (this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
-    {
+  if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
     return false;
-    }
-  if(cmLinkImplementationLibraries const* impl =
-     this->GetLinkImplementationLibraries(config))
-    {
+  }
+  if (cmLinkImplementationLibraries const* impl =
+        this->GetLinkImplementationLibraries(config)) {
     return !impl->Libraries.empty();
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 cmLinkImplementationLibraries const*
 cmGeneratorTarget::GetLinkImplementationLibraries(
-    const std::string& config) const
+  const std::string& config) const
 {
   return this->GetLinkImplementationLibrariesInternal(config, this);
 }
 
-//----------------------------------------------------------------------------
 cmLinkImplementationLibraries const*
 cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
-    const std::string& config, cmGeneratorTarget const* head) const
+  const std::string& config, cmGeneratorTarget const* head) const
 {
   // There is no link implementation for imported targets.
-  if(this->IsImported())
-    {
+  if (this->IsImported()) {
     return 0;
-    }
+  }
 
   // Populate the link implementation libraries for this configuration.
   std::string CONFIG = cmSystemTools::UpperCase(config);
-  HeadToLinkImplementationMap& hm =
-    this->LinkImplMap[CONFIG];
+  HeadToLinkImplementationMap& hm = this->LinkImplMap[CONFIG];
 
   // If the link implementation does not depend on the head target
   // then return the one we computed first.
-  if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
-    {
+  if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
     return &hm.begin()->second;
-    }
+  }
 
   cmOptionalLinkImplementation& impl = hm[head];
-  if(!impl.LibrariesDone)
-    {
+  if (!impl.LibrariesDone) {
     impl.LibrariesDone = true;
     this->ComputeLinkImplementationLibraries(config, impl, head);
-    }
+  }
   return &impl;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGeneratorTarget::IsNullImpliedByLinkLibraries(const std::string &p) const
+bool cmGeneratorTarget::IsNullImpliedByLinkLibraries(
+  const std::string& p) const
 {
-  return this->LinkImplicitNullProperties.find(p)
-      != this->LinkImplicitNullProperties.end();
+  return this->LinkImplicitNullProperties.find(p) !=
+    this->LinkImplicitNullProperties.end();
 }
 
-//----------------------------------------------------------------------------
 void cmGeneratorTarget::ComputeLinkImplementationLibraries(
-  const std::string& config,
-  cmOptionalLinkImplementation& impl,
+  const std::string& config, cmOptionalLinkImplementation& impl,
   cmGeneratorTarget const* head) const
 {
-  cmStringRange entryRange =
-      this->Target->GetLinkImplementationEntries();
-  cmBacktraceRange btRange =
-      this->Target->GetLinkImplementationBacktraces();
+  cmStringRange entryRange = this->Target->GetLinkImplementationEntries();
+  cmBacktraceRange btRange = this->Target->GetLinkImplementationBacktraces();
   cmBacktraceRange::const_iterator btIt = btRange.begin();
   // Collect libraries directly linked in this configuration.
   for (cmStringRange::const_iterator le = entryRange.begin(),
-      end = entryRange.end(); le != end; ++le, ++btIt)
-    {
+                                     end = entryRange.end();
+       le != end; ++le, ++btIt) {
     std::vector<std::string> llibs;
-    cmGeneratorExpressionDAGChecker dagChecker(
-                                        this->GetName(),
-                                        "LINK_LIBRARIES", 0, 0);
+    cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                               "LINK_LIBRARIES", 0, 0);
     cmGeneratorExpression ge(*btIt);
-    cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge =
-      ge.Parse(*le);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
     std::string const evaluated =
       cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
     cmSystemTools::ExpandListArgument(evaluated, llibs);
-    if(cge->GetHadHeadSensitiveCondition())
-      {
+    if (cge->GetHadHeadSensitiveCondition()) {
       impl.HadHeadSensitiveCondition = true;
-      }
+    }
 
-    for(std::vector<std::string>::const_iterator li = llibs.begin();
-        li != llibs.end(); ++li)
-      {
+    for (std::vector<std::string>::const_iterator li = llibs.begin();
+         li != llibs.end(); ++li) {
       // Skip entries that resolve to the target itself or are empty.
       std::string name = this->CheckCMP0004(*li);
-      if(name == this->GetName() || name.empty())
-        {
-        if(name == this->GetName())
-          {
+      if (name == this->GetName() || name.empty()) {
+        if (name == this->GetName()) {
           bool noMessage = false;
           cmake::MessageType messageType = cmake::FATAL_ERROR;
           std::ostringstream e;
-          switch(this->GetPolicyStatusCMP0038())
-            {
-            case cmPolicies::WARN:
-              {
+          switch (this->GetPolicyStatusCMP0038()) {
+            case cmPolicies::WARN: {
               e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n";
               messageType = cmake::AUTHOR_WARNING;
-              }
-              break;
+            } break;
             case cmPolicies::OLD:
               noMessage = true;
             case cmPolicies::REQUIRED_IF_USED:
@@ -5930,140 +4975,121 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
             case cmPolicies::NEW:
               // Issue the fatal message.
               break;
-            }
+          }
 
-          if(!noMessage)
-            {
+          if (!noMessage) {
             e << "Target \"" << this->GetName() << "\" links to itself.";
             this->LocalGenerator->GetCMakeInstance()->IssueMessage(
               messageType, e.str(), this->GetBacktrace());
-            if (messageType == cmake::FATAL_ERROR)
-              {
+            if (messageType == cmake::FATAL_ERROR) {
               return;
-              }
             }
           }
-        continue;
         }
+        continue;
+      }
 
       // The entry is meant for this configuration.
-      impl.Libraries.push_back(
-        cmLinkImplItem(name, this->FindTargetToLink(name),
-                       *btIt, evaluated != *le));
-      }
+      impl.Libraries.push_back(cmLinkImplItem(
+        name, this->FindTargetToLink(name), *btIt, evaluated != *le));
+    }
 
     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))
-        {
+         it != seenProps.end(); ++it) {
+      if (!this->GetProperty(*it)) {
         this->LinkImplicitNullProperties.insert(*it);
-        }
       }
-    cge->GetMaxLanguageStandard(this,
-                                this->MaxLanguageStandards);
     }
+    cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
+  }
 
   // Get the list of configurations considered to be DEBUG.
   std::vector<std::string> debugConfigs =
     this->Makefile->GetCMakeInstance()->GetDebugConfigs();
 
   cmTargetLinkLibraryType linkType =
-      CMP0003_ComputeLinkType(config, debugConfigs);
+    CMP0003_ComputeLinkType(config, debugConfigs);
   cmTarget::LinkLibraryVectorType const& oldllibs =
     this->Target->GetOriginalLinkLibraries();
-  for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
-      li != oldllibs.end(); ++li)
-    {
-    if(li->second != GENERAL_LibraryType && li->second != linkType)
-      {
+  for (cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
+       li != oldllibs.end(); ++li) {
+    if (li->second != GENERAL_LibraryType && li->second != linkType) {
       std::string name = this->CheckCMP0004(li->first);
-      if(name == this->GetName() || name.empty())
-        {
+      if (name == this->GetName() || name.empty()) {
         continue;
-        }
+      }
       // Support OLD behavior for CMP0003.
       impl.WrongConfigLibraries.push_back(
         cmLinkItem(name, this->FindTargetToLink(name)));
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmGeneratorTarget*
-cmGeneratorTarget::FindTargetToLink(std::string const& name) const
+cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink(
+  std::string const& name) const
 {
   cmGeneratorTarget* tgt =
-      this->LocalGenerator->FindGeneratorTargetToUse(name);
+    this->LocalGenerator->FindGeneratorTargetToUse(name);
 
   // Skip targets that will not really be linked.  This is probably a
   // name conflict between an external library and an executable
   // within the project.
-  if(tgt && tgt->GetType() == cmState::EXECUTABLE &&
-     !tgt->IsExecutableWithExports())
-    {
+  if (tgt && tgt->GetType() == cmState::EXECUTABLE &&
+      !tgt->IsExecutableWithExports()) {
     tgt = 0;
-    }
+  }
 
-  if(tgt && tgt->GetType() == cmState::OBJECT_LIBRARY)
-    {
+  if (tgt && tgt->GetType() == cmState::OBJECT_LIBRARY) {
     std::ostringstream e;
     e << "Target \"" << this->GetName() << "\" links to "
-      "OBJECT library \"" << tgt->GetName() << "\" but this is not "
-      "allowed.  "
-      "One may link only to STATIC or SHARED libraries, or to executables "
-      "with the ENABLE_EXPORTS property set.";
+                                           "OBJECT library \""
+      << tgt->GetName()
+      << "\" but this is not "
+         "allowed.  "
+         "One may link only to STATIC or SHARED libraries, or to executables "
+         "with the ENABLE_EXPORTS property set.";
     cmake* cm = this->LocalGenerator->GetCMakeInstance();
-    cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                     this->GetBacktrace());
+    cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
     tgt = 0;
-    }
+  }
 
   return tgt;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
+std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
 {
-  if(OutputInfo const* info = this->GetOutputInfo(config))
-    {
+  if (OutputInfo const* info = this->GetOutputInfo(config)) {
     // Return the directory in which the target will be built.
     return info->PdbDir;
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasImplibGNUtoMS() const
 {
-  return this->HasImportLibrary()
-      && this->GetPropertyAsBool("GNUtoMS");
+  return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
-                                std::string& out, const char* newExt) const
+                                         std::string& out,
+                                         const char* newExt) const
 {
-  if(this->HasImplibGNUtoMS() &&
-     gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
-    {
-    out = gnuName.substr(0, gnuName.size()-6);
-    out += newExt? newExt : ".lib";
+  if (this->HasImplibGNUtoMS() && gnuName.size() > 6 &&
+      gnuName.substr(gnuName.size() - 6) == ".dll.a") {
+    out = gnuName.substr(0, gnuName.size() - 6);
+    out += newExt ? newExt : ".lib";
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsExecutableWithExports() const
 {
   return (this->GetType() == cmState::EXECUTABLE &&
           this->GetPropertyAsBool("ENABLE_EXPORTS"));
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasImportLibrary() const
 {
   return (this->IsDLLPlatform() &&
@@ -6071,7 +5097,6 @@ bool cmGeneratorTarget::HasImportLibrary() const
            this->IsExecutableWithExports()));
 }
 
-//----------------------------------------------------------------------------
 std::string cmGeneratorTarget::GetSupportDirectory() const
 {
   std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory();
@@ -6086,7 +5111,6 @@ std::string cmGeneratorTarget::GetSupportDirectory() const
   return dir;
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsLinkable() const
 {
   return (this->GetType() == cmState::STATIC_LIBRARY ||
@@ -6097,7 +5121,6 @@ bool cmGeneratorTarget::IsLinkable() const
           this->IsExecutableWithExports());
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsFrameworkOnApple() const
 {
   return (this->GetType() == cmState::SHARED_LIBRARY &&
@@ -6105,7 +5128,6 @@ bool cmGeneratorTarget::IsFrameworkOnApple() const
           this->GetPropertyAsBool("FRAMEWORK"));
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsAppBundleOnApple() const
 {
   return (this->GetType() == cmState::EXECUTABLE &&
@@ -6113,17 +5135,13 @@ bool cmGeneratorTarget::IsAppBundleOnApple() const
           this->GetPropertyAsBool("MACOSX_BUNDLE"));
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsXCTestOnApple() const
 {
-  return (this->IsCFBundleOnApple() &&
-          this->GetPropertyAsBool("XCTEST"));
+  return (this->IsCFBundleOnApple() && this->GetPropertyAsBool("XCTEST"));
 }
 
-//----------------------------------------------------------------------------
 bool cmGeneratorTarget::IsCFBundleOnApple() const
 {
   return (this->GetType() == cmState::MODULE_LIBRARY &&
-          this->Makefile->IsOn("APPLE") &&
-          this->GetPropertyAsBool("BUNDLE"));
+          this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("BUNDLE"));
 }
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index d96a32c..63208bc 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -32,15 +32,17 @@ public:
 
   bool IsImported() const;
   bool IsImportedGloballyVisible() const;
-  const char *GetLocation(const std::string& config) const;
+  const char* GetLocation(const std::string& config) const;
 
-  std::vector<cmCustomCommand> const &GetPreBuildCommands() const;
-  std::vector<cmCustomCommand> const &GetPreLinkCommands() const;
-  std::vector<cmCustomCommand> const &GetPostBuildCommands() const;
+  std::vector<cmCustomCommand> const& GetPreBuildCommands() const;
+  std::vector<cmCustomCommand> const& GetPreLinkCommands() const;
+  std::vector<cmCustomCommand> const& GetPostBuildCommands() const;
 
-#define DECLARE_TARGET_POLICY(POLICY) \
-  cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
-    { return this->PolicyMap.Get(cmPolicies::POLICY); }
+#define DECLARE_TARGET_POLICY(POLICY)                                         \
+  cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const                    \
+  {                                                                           \
+    return this->PolicyMap.Get(cmPolicies::POLICY);                           \
+  }
 
   CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
 
@@ -51,20 +53,20 @@ public:
       location is suitable for use as the LOCATION target property.  */
   const char* GetLocationForBuild() const;
 
-  cmComputeLinkInformation*
-    GetLinkInformation(const std::string& config) const;
+  cmComputeLinkInformation* GetLinkInformation(
+    const std::string& config) const;
 
   cmState::TargetType GetType() const;
   const std::string& GetName() const;
   std::string GetExportName() const;
 
   std::vector<std::string> GetPropertyKeys() const;
-  const char *GetProperty(const std::string& prop) 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);
 
@@ -98,7 +100,7 @@ public:
   void GetExpectedXamlSources(std::set<std::string>&,
                               const std::string& config) const;
 
-  std::set<cmLinkItem>const& GetUtilityItems() const;
+  std::set<cmLinkItem> const& GetUtilityItems() const;
 
   void ComputeObjectMapping();
 
@@ -107,44 +109,43 @@ public:
   bool GetFeatureAsBool(const std::string& feature,
                         const std::string& config) const;
 
-  bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
-                         const std::string& config) const;
-  bool IsLinkInterfaceDependentStringProperty(const std::string &p,
-                         const std::string& config) const;
-  bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
-                         const std::string& config) const;
-  bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
-                         const std::string& config) const;
+  bool IsLinkInterfaceDependentBoolProperty(const std::string& p,
+                                            const std::string& config) const;
+  bool IsLinkInterfaceDependentStringProperty(const std::string& p,
+                                              const std::string& config) const;
+  bool IsLinkInterfaceDependentNumberMinProperty(
+    const std::string& p, const std::string& config) const;
+  bool IsLinkInterfaceDependentNumberMaxProperty(
+    const std::string& p, const std::string& config) const;
 
-  bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
+  bool GetLinkInterfaceDependentBoolProperty(const std::string& p,
                                              const std::string& config) const;
 
-  const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
-                         const std::string& config) const;
-  const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
-                         const std::string& config) const;
-  const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
-                         const std::string& config) const;
+  const char* GetLinkInterfaceDependentStringProperty(
+    const std::string& p, const std::string& config) const;
+  const char* GetLinkInterfaceDependentNumberMinProperty(
+    const std::string& p, const std::string& config) const;
+  const char* GetLinkInterfaceDependentNumberMaxProperty(
+    const std::string& p, const std::string& config) const;
 
-  cmLinkInterface const* GetLinkInterface(const std::string& config,
-                                    const cmGeneratorTarget* headTarget) const;
+  cmLinkInterface const* GetLinkInterface(
+    const std::string& config, const cmGeneratorTarget* headTarget) const;
   void ComputeLinkInterface(const std::string& config,
                             cmOptionalLinkInterface& iface,
                             const cmGeneratorTarget* head) const;
 
-  cmLinkInterfaceLibraries const*
-    GetLinkInterfaceLibraries(const std::string& config,
-                              const cmGeneratorTarget* headTarget,
-                              bool usage_requirements_only) const;
+  cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries(
+    const std::string& config, const cmGeneratorTarget* headTarget,
+    bool usage_requirements_only) const;
 
   void ComputeLinkInterfaceLibraries(const std::string& config,
-                                     cmOptionalLinkInterface &iface,
+                                     cmOptionalLinkInterface& iface,
                                      const cmGeneratorTarget* head,
                                      bool usage_requirements_only) const;
 
   /** Get the full path to the target according to the settings in its
       makefile and the configuration type.  */
-  std::string GetFullPath(const std::string& config="", bool implib = false,
+  std::string GetFullPath(const std::string& config = "", bool implib = false,
                           bool realname = false) const;
   std::string NormalGetFullPath(const std::string& config, bool implib,
                                 bool realname) const;
@@ -160,7 +161,7 @@ public:
 
   /** Get the full name of the target according to the settings in its
       makefile.  */
-  std::string GetFullName(const std::string& config="",
+  std::string GetFullName(const std::string& config = "",
                           bool implib = false) const;
 
   /** @return the Mac framework directory without the base. */
@@ -188,11 +189,13 @@ public:
 
   const std::vector<std::string>& GetLinkDirectories() const;
 
-  std::set<std::string>const& GetUtilities() const;
+  std::set<std::string> const& GetUtilities() const;
   cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
   bool LinkLanguagePropagatesToDependents() const
-  { return this->GetType() == cmState::STATIC_LIBRARY; }
+  {
+    return this->GetType() == cmState::STATIC_LIBRARY;
+  }
 
   /** Get the macro to define when building sources in this target.
       If no macro should be defined null is returned.  */
@@ -201,9 +204,9 @@ public:
   /** Get the soname of the target.  Allowed only for a shared library.  */
   std::string GetSOName(const std::string& config) const;
 
-  void GetFullNameComponents(std::string& prefix,
-                             std::string& base, std::string& suffix,
-                             const std::string& config="",
+  void GetFullNameComponents(std::string& prefix, std::string& base,
+                             std::string& suffix,
+                             const std::string& config = "",
                              bool implib = false) const;
 
   /** Append to @a base the mac content directory and return it. */
@@ -242,15 +245,14 @@ public:
   LinkClosure const* GetLinkClosure(const std::string& config) const;
   void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const;
 
-  cmLinkImplementation const*
-    GetLinkImplementation(const std::string& config) const;
+  cmLinkImplementation const* GetLinkImplementation(
+    const std::string& config) const;
 
-  void ComputeLinkImplementationLanguages(const std::string& config,
-                                          cmOptionalLinkImplementation& impl
-                                          ) const;
+  void ComputeLinkImplementationLanguages(
+    const std::string& config, cmOptionalLinkImplementation& impl) const;
 
-  cmLinkImplementationLibraries const*
-    GetLinkImplementationLibraries(const std::string& config) const;
+  cmLinkImplementationLibraries const* GetLinkImplementationLibraries(
+    const std::string& config) const;
 
   void ComputeLinkImplementationLibraries(const std::string& config,
                                           cmOptionalLinkImplementation& impl,
@@ -266,8 +268,8 @@ public:
   void GetLanguages(std::set<std::string>& languages,
                     std::string const& config) const;
 
-  void
-  GetObjectLibrariesCMP0026(std::vector<cmGeneratorTarget*>& objlibs) const;
+  void GetObjectLibrariesCMP0026(
+    std::vector<cmGeneratorTarget*>& objlibs) const;
 
   std::string GetFullNameImported(const std::string& config,
                                   bool implib) const;
@@ -293,16 +295,16 @@ public:
 
   /** Get the include directories for this target.  */
   std::vector<std::string> GetIncludeDirectories(
-      const std::string& config, const std::string& lang) const;
+    const std::string& config, const std::string& lang) const;
 
-  void GetCompileOptions(std::vector<std::string> &result,
+  void GetCompileOptions(std::vector<std::string>& result,
                          const std::string& config,
                          const std::string& language) const;
 
-  void GetCompileFeatures(std::vector<std::string> &features,
+  void GetCompileFeatures(std::vector<std::string>& features,
                           const std::string& config) const;
 
-  void GetCompileDefinitions(std::vector<std::string> &result,
+  void GetCompileDefinitions(std::vector<std::string>& result,
                              const std::string& config,
                              const std::string& language) const;
 
@@ -332,8 +334,8 @@ public:
   std::string GetCompilePDBDirectory(const std::string& config = "") const;
 
   /** Get sources that must be built before the given source.  */
-  std::vector<cmSourceFile*> const*
-  GetSourceDepends(cmSourceFile const* sf) const;
+  std::vector<cmSourceFile*> const* GetSourceDepends(
+    cmSourceFile const* sf) const;
 
   /** Return whether this target uses the default value for its output
       directory.  */
@@ -346,13 +348,15 @@ public:
     std::string ImpDir;
     std::string PdbDir;
     bool empty() const
-      { return OutDir.empty() && ImpDir.empty() && PdbDir.empty(); }
+    {
+      return OutDir.empty() && ImpDir.empty() && PdbDir.empty();
+    }
   };
 
   OutputInfo const* GetOutputInfo(const std::string& config) const;
 
   /** Get the name of the pdb file for the target.  */
-  std::string GetPDBName(const std::string& config="") const;
+  std::string GetPDBName(const std::string& config = "") const;
 
   /** Whether this library has soname enabled and platform supports it.  */
   bool HasSOName(const std::string& config) const;
@@ -367,13 +371,13 @@ public:
   typedef std::map<std::string, CompileInfo> CompileInfoMapType;
   mutable CompileInfoMapType CompileInfoMap;
 
-  bool IsNullImpliedByLinkLibraries(const std::string &p) const;
+  bool IsNullImpliedByLinkLibraries(const std::string& p) const;
 
   /** Get the name of the compiler pdb file for the target.  */
-  std::string GetCompilePDBName(const std::string& config="") const;
+  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;
+  std::string GetCompilePDBPath(const std::string& config = "") const;
 
   // Get the target base name.
   std::string GetOutputName(const std::string& config, bool implib) const;
@@ -396,13 +400,20 @@ public:
   };
   struct SourceFileFlags
   {
-    SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
-    SourceFileFlags(SourceFileFlags const& r):
-      Type(r.Type), MacFolder(r.MacFolder) {}
+    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
   };
-  void GetAutoUicOptions(std::vector<std::string> &result,
+  void GetAutoUicOptions(std::vector<std::string>& result,
                          const std::string& config) const;
 
   /** Get the names of the executable needed to generate a build rule
@@ -468,24 +479,25 @@ public:
   /** Return whether this target is a CFBundle (plugin) on Apple.  */
   bool IsCFBundleOnApple() const;
 
-  struct SourceFileFlags
-  GetTargetSourceFileFlags(const cmSourceFile* sf) const;
+  struct SourceFileFlags GetTargetSourceFileFlags(
+    const cmSourceFile* sf) const;
 
-  struct ResxData {
+  struct ResxData
+  {
     mutable std::set<std::string> ExpectedResxHeaders;
     mutable std::vector<cmSourceFile const*> ResxSources;
   };
 
-  struct XamlData {
+  struct XamlData
+  {
     std::set<std::string> ExpectedXamlHeaders;
     std::set<std::string> ExpectedXamlSources;
     std::vector<cmSourceFile const*> XamlSources;
   };
 
-  void ReportPropertyOrigin(const std::string &p,
-                            const std::string &result,
-                            const std::string &report,
-                            const std::string &compatibilityType) const;
+  void ReportPropertyOrigin(const std::string& p, const std::string& result,
+                            const std::string& report,
+                            const std::string& compatibilityType) const;
 
   class TargetPropertyEntry;
 
@@ -511,12 +523,15 @@ public:
   /** Get the target major, minor, and patch version numbers
       interpreted from the VERSION or SOVERSION property.  Version 0
       is returned if the property is not set or cannot be parsed.  */
-  void
-  GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
+  void GetTargetVersion(bool soversion, int& major, int& minor,
+                        int& patch) const;
 
 private:
   friend class cmTargetTraceDependencies;
-  struct SourceEntry { std::vector<cmSourceFile*> Depends; };
+  struct SourceEntry
+  {
+    std::vector<cmSourceFile*> Depends;
+  };
   typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
   SourceEntriesType SourceDepends;
   mutable std::map<cmSourceFile const*, std::string> Objects;
@@ -543,10 +558,8 @@ private:
   // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
   const char* GetOutputTargetType(bool implib) const;
 
-  void ComputeVersionedName(std::string& vName,
-                            std::string const& prefix,
-                            std::string const& base,
-                            std::string const& suffix,
+  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;
 
@@ -557,49 +570,58 @@ private:
     std::set<std::string> PropsNumberMax;
     std::set<std::string> PropsNumberMin;
   };
-  CompatibleInterfacesBase const&
-    GetCompatibleInterfaces(std::string const& config) const;
+  CompatibleInterfacesBase const& GetCompatibleInterfaces(
+    std::string const& config) const;
 
-  struct CompatibleInterfaces: public CompatibleInterfacesBase
+  struct CompatibleInterfaces : public CompatibleInterfacesBase
   {
-    CompatibleInterfaces(): Done(false) {}
+    CompatibleInterfaces()
+      : Done(false)
+    {
+    }
     bool Done;
   };
   mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;
 
   typedef std::map<std::string, cmComputeLinkInformation*>
-                                                   cmTargetLinkInformationMap;
+    cmTargetLinkInformationMap;
   mutable cmTargetLinkInformationMap LinkInformation;
 
-  void CheckPropertyCompatibility(cmComputeLinkInformation *info,
+  void CheckPropertyCompatibility(cmComputeLinkInformation* info,
                                   const std::string& config) const;
 
   cmGeneratorTarget(cmGeneratorTarget const&);
   void operator=(cmGeneratorTarget const&);
 
-  struct LinkImplClosure: public std::vector<cmGeneratorTarget const*>
+  struct LinkImplClosure : public std::vector<cmGeneratorTarget const*>
   {
-    LinkImplClosure(): Done(false) {}
+    LinkImplClosure()
+      : Done(false)
+    {
+    }
     bool Done;
   };
   mutable std::map<std::string, LinkImplClosure> LinkImplClosureMap;
 
-  typedef std::map<std::string, cmHeadToLinkInterfaceMap>
-                                                          LinkInterfaceMapType;
+  typedef std::map<std::string, cmHeadToLinkInterfaceMap> LinkInterfaceMapType;
   mutable LinkInterfaceMapType LinkInterfaceMap;
   mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap;
 
-  cmHeadToLinkInterfaceMap&
-  GetHeadToLinkInterfaceMap(std::string const& config) const;
+  cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceMap(
+    std::string const& config) const;
   cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap(
-      std::string const& config) const;
+    std::string const& config) const;
 
   // Cache import information from properties for each configuration.
   struct ImportInfo
   {
-    ImportInfo(): NoSOName(false), Multiplicity(0) {}
+    ImportInfo()
+      : NoSOName(false)
+      , Multiplicity(0)
+    {
+    }
     bool NoSOName;
-    int Multiplicity;
+    unsigned int Multiplicity;
     std::string Location;
     std::string SOName;
     std::string ImportLibrary;
@@ -619,13 +641,12 @@ private:
       the link dependencies of this target.  */
   std::string CheckCMP0004(std::string const& item) const;
 
-  cmLinkInterface const*
-    GetImportLinkInterface(const std::string& config,
-                           const cmGeneratorTarget* head,
-                           bool usage_requirements_only) const;
+  cmLinkInterface const* GetImportLinkInterface(
+    const std::string& config, const cmGeneratorTarget* head,
+    bool usage_requirements_only) const;
 
   typedef std::map<std::string, std::vector<cmSourceFile*> >
-                                                       SourceFilesMapType;
+    SourceFilesMapType;
   mutable SourceFilesMapType SourceFilesMap;
 
   std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
@@ -647,18 +668,17 @@ private:
   void GetSourceFiles(std::vector<std::string>& files,
                       const std::string& config) const;
 
-  struct HeadToLinkImplementationMap:
-    public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation> {};
-  typedef std::map<std::string,
-                   HeadToLinkImplementationMap> LinkImplMapType;
+  struct HeadToLinkImplementationMap
+    : public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation>
+  {
+  };
+  typedef std::map<std::string, HeadToLinkImplementationMap> LinkImplMapType;
   mutable LinkImplMapType LinkImplMap;
 
-  cmLinkImplementationLibraries const*
-    GetLinkImplementationLibrariesInternal(const std::string& config,
-                                          const cmGeneratorTarget* head) const;
-  bool
-  ComputeOutputDir(const std::string& config,
-                   bool implib, std::string& out) const;
+  cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(
+    const std::string& config, const cmGeneratorTarget* head) const;
+  bool ComputeOutputDir(const std::string& config, bool implib,
+                        std::string& out) const;
 
   typedef std::map<std::string, OutputInfo> OutputInfoMapType;
   mutable OutputInfoMapType OutputInfoMap;
@@ -682,17 +702,17 @@ private:
                            std::string& out) const;
 
 public:
-  const std::vector<const cmGeneratorTarget*>&
-  GetLinkImplementationClosure(const std::string& config) const;
+  const std::vector<const cmGeneratorTarget*>& GetLinkImplementationClosure(
+    const std::string& config) const;
 
   mutable std::map<std::string, std::string> MaxLanguageStandards;
-  std::map<std::string, std::string> const&
-  GetMaxLanguageStandards() const
+  std::map<std::string, std::string> const& GetMaxLanguageStandards() const
   {
     return this->MaxLanguageStandards;
   }
 
-  struct StrictTargetComparison {
+  struct StrictTargetComparison
+  {
     bool operator()(cmGeneratorTarget const* t1,
                     cmGeneratorTarget const* t2) const;
   };
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index 1a91183..331aab9 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -11,57 +11,45 @@
 ============================================================================*/
 #include "cmGetCMakePropertyCommand.h"
 
+#include "cmAlgorithms.h"
 #include "cmGlobalGenerator.h"
-#include "cmake.h"
 #include "cmState.h"
-#include "cmAlgorithms.h"
+#include "cmake.h"
 
 // cmGetCMakePropertyCommand
-bool cmGetCMakePropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetCMakePropertyCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string variable = args[0];
   std::string output = "NOTFOUND";
 
-  if ( args[1] == "VARIABLES" )
-    {
-    if (const char* varsProp = this->Makefile->GetProperty("VARIABLES"))
-      {
+  if (args[1] == "VARIABLES") {
+    if (const char* varsProp = this->Makefile->GetProperty("VARIABLES")) {
       output = varsProp;
-      }
     }
-  else if ( args[1] == "MACROS" )
-    {
+  } else if (args[1] == "MACROS") {
     output.clear();
-    if (const char* macrosProp = this->Makefile->GetProperty("MACROS"))
-      {
+    if (const char* macrosProp = this->Makefile->GetProperty("MACROS")) {
       output = macrosProp;
-      }
     }
-  else if ( args[1] == "COMPONENTS" )
-    {
-    const std::set<std::string>* components
-      = this->Makefile->GetGlobalGenerator()->GetInstallComponents();
+  } else if (args[1] == "COMPONENTS") {
+    const std::set<std::string>* components =
+      this->Makefile->GetGlobalGenerator()->GetInstallComponents();
     output = cmJoin(*components, ";");
-    }
-  else
-    {
-    const char *prop = 0;
-    if (!args[1].empty())
-      {
+  } else {
+    const char* prop = 0;
+    if (!args[1].empty()) {
       prop = this->Makefile->GetState()->GetGlobalProperty(args[1]);
-      }
-    if (prop)
-      {
+    }
+    if (prop) {
       output = prop;
-      }
     }
+  }
 
   this->Makefile->AddDefinition(variable, output.c_str());
 
diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h
index 1511406..fd247e8 100644
--- a/Source/cmGetCMakePropertyCommand.h
+++ b/Source/cmGetCMakePropertyCommand.h
@@ -17,17 +17,14 @@
 class cmGetCMakePropertyCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmGetCMakePropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetCMakePropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -37,11 +34,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "get_cmake_property";}
+  virtual std::string GetName() const { return "get_cmake_property"; }
 
   cmTypeMacro(cmGetCMakePropertyCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 2558876..1b5bcc9 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -14,94 +14,84 @@
 #include "cmake.h"
 
 // cmGetDirectoryPropertyCommand
-bool cmGetDirectoryPropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetDirectoryPropertyCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::vector<std::string>::const_iterator i = args.begin();
   std::string variable = *i;
   ++i;
 
   // get the directory argument if there is one
-  cmMakefile *dir = this->Makefile;
-  if (*i == "DIRECTORY")
-    {
+  cmMakefile* dir = this->Makefile;
+  if (*i == "DIRECTORY") {
     ++i;
-    if (i == args.end())
-      {
-      this->SetError
-        ("DIRECTORY argument provided without subsequent arguments");
+    if (i == args.end()) {
+      this->SetError(
+        "DIRECTORY argument provided without subsequent arguments");
       return false;
-      }
+    }
     std::string sd = *i;
     // make sure the start dir is a full path
-    if (!cmSystemTools::FileIsFullPath(sd.c_str()))
-      {
+    if (!cmSystemTools::FileIsFullPath(sd.c_str())) {
       sd = this->Makefile->GetCurrentSourceDirectory();
       sd += "/";
       sd += *i;
-      }
+    }
 
     // The local generators are associated with collapsed paths.
     sd = cmSystemTools::CollapseFullPath(sd);
 
     // lookup the makefile from the directory name
     dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd);
-    if (!dir)
-      {
-      this->SetError
-        ("DIRECTORY argument provided but requested directory not found. "
-         "This could be because the directory argument was invalid or, "
-         "it is valid but has not been processed yet.");
+    if (!dir) {
+      this->SetError(
+        "DIRECTORY argument provided but requested directory not found. "
+        "This could be because the directory argument was invalid or, "
+        "it is valid but has not been processed yet.");
       return false;
-      }
-    ++i;
     }
+    ++i;
+  }
 
   // OK, now we have the directory to process, we just get the requested
   // information out of it
 
-  if ( *i == "DEFINITION" )
-    {
+  if (*i == "DEFINITION") {
     ++i;
-    if (i == args.end())
-      {
+    if (i == args.end()) {
       this->SetError("A request for a variable definition was made without "
                      "providing the name of the variable to get.");
       return false;
-      }
+    }
     std::string output = dir->GetSafeDefinition(*i);
     this->Makefile->AddDefinition(variable, output.c_str());
     return true;
-    }
+  }
 
-  const char *prop = 0;
-  if (!i->empty())
-    {
-    if (*i == "DEFINITIONS")
-      {
-      switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0059))
-        {
+  const char* prop = 0;
+  if (!i->empty()) {
+    if (*i == "DEFINITIONS") {
+      switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0059)) {
         case cmPolicies::WARN:
-          this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
-                           cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
+          this->Makefile->IssueMessage(
+            cmake::AUTHOR_WARNING,
+            cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
         case cmPolicies::OLD:
-          this->StoreResult(variable,
-                                   this->Makefile->GetDefineFlagsCMP0059());
-        return true;
+          this->StoreResult(variable, this->Makefile->GetDefineFlagsCMP0059());
+          return true;
         case cmPolicies::NEW:
         case cmPolicies::REQUIRED_ALWAYS:
         case cmPolicies::REQUIRED_IF_USED:
           break;
-        }
       }
-    prop = dir->GetProperty(*i);
     }
+    prop = dir->GetProperty(*i);
+  }
   this->StoreResult(variable, prop);
   return true;
 }
@@ -109,11 +99,9 @@ bool cmGetDirectoryPropertyCommand
 void cmGetDirectoryPropertyCommand::StoreResult(std::string const& variable,
                                                 const char* prop)
 {
-  if (prop)
-    {
+  if (prop) {
     this->Makefile->AddDefinition(variable, prop);
     return;
-    }
+  }
   this->Makefile->AddDefinition(variable, "");
 }
-
diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h
index f418886..97394ec 100644
--- a/Source/cmGetDirectoryPropertyCommand.h
+++ b/Source/cmGetDirectoryPropertyCommand.h
@@ -17,17 +17,14 @@
 class cmGetDirectoryPropertyCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmGetDirectoryPropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetDirectoryPropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -37,7 +34,7 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string 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 0f56c8e..1830b0c 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -10,142 +10,106 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGetFilenameComponentCommand.h"
+
 #include "cmSystemTools.h"
 
 // cmGetFilenameComponentCommand
-bool cmGetFilenameComponentCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetFilenameComponentCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Check and see if the value has been stored in the cache
   // already, if so use that value
-  if(args.size() >= 4 && args[args.size() - 1] == "CACHE")
-    {
+  if (args.size() >= 4 && args[args.size() - 1] == "CACHE") {
     const char* cacheValue = this->Makefile->GetDefinition(args[0]);
-    if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
-      {
+    if (cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) {
       return true;
-      }
     }
+  }
 
   std::string result;
   std::string filename = args[1];
-  if(filename.find("[HKEY") != filename.npos)
-    {
+  if (filename.find("[HKEY") != filename.npos) {
     // Check the registry as the target application would view it.
     cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
     cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
-    if(this->Makefile->PlatformIs64Bit())
-      {
+    if (this->Makefile->PlatformIs64Bit()) {
       view = cmSystemTools::KeyWOW64_64;
       other_view = cmSystemTools::KeyWOW64_32;
-      }
+    }
     cmSystemTools::ExpandRegistryValues(filename, view);
-    if(filename.find("/registry") != filename.npos)
-      {
+    if (filename.find("/registry") != filename.npos) {
       std::string other = args[1];
       cmSystemTools::ExpandRegistryValues(other, other_view);
-      if(other.find("/registry") == other.npos)
-        {
+      if (other.find("/registry") == other.npos) {
         filename = other;
-        }
       }
     }
+  }
   std::string storeArgs;
   std::string programArgs;
-  if (args[2] == "DIRECTORY" || args[2] == "PATH")
-    {
+  if (args[2] == "DIRECTORY" || args[2] == "PATH") {
     result = cmSystemTools::GetFilenamePath(filename);
-    }
-  else if (args[2] == "NAME")
-    {
+  } else if (args[2] == "NAME") {
     result = cmSystemTools::GetFilenameName(filename);
-    }
-  else if (args[2] == "PROGRAM")
-    {
-    for(unsigned int i=2; i < args.size(); ++i)
-      {
-      if(args[i] == "PROGRAM_ARGS")
-        {
+  } else if (args[2] == "PROGRAM") {
+    for (unsigned int i = 2; i < args.size(); ++i) {
+      if (args[i] == "PROGRAM_ARGS") {
         i++;
-        if(i < args.size())
-          {
+        if (i < args.size()) {
           storeArgs = args[i];
-          }
         }
       }
-    cmSystemTools::SplitProgramFromArgs(filename,
-                                        result, programArgs);
     }
-  else if (args[2] == "EXT")
-    {
+    cmSystemTools::SplitProgramFromArgs(filename, result, programArgs);
+  } else if (args[2] == "EXT") {
     result = cmSystemTools::GetFilenameExtension(filename);
-    }
-  else if (args[2] == "NAME_WE")
-    {
+  } else if (args[2] == "NAME_WE") {
     result = cmSystemTools::GetFilenameWithoutExtension(filename);
-    }
-  else if (args[2] == "ABSOLUTE" ||
-           args[2] == "REALPATH")
-    {
+  } else if (args[2] == "ABSOLUTE" || args[2] == "REALPATH") {
     // If the path given is relative, evaluate it relative to the
     // current source directory unless the user passes a different
     // base directory.
     std::string baseDir = this->Makefile->GetCurrentSourceDirectory();
-    for(unsigned int i=3; i < args.size(); ++i)
-      {
-      if(args[i] == "BASE_DIR")
-        {
+    for (unsigned int i = 3; i < args.size(); ++i) {
+      if (args[i] == "BASE_DIR") {
         ++i;
-        if(i < args.size())
-          {
+        if (i < args.size()) {
           baseDir = args[i];
-          }
         }
       }
+    }
     // Collapse the path to its simplest form.
     result = cmSystemTools::CollapseFullPath(filename, baseDir);
-    if(args[2] == "REALPATH")
-      {
+    if (args[2] == "REALPATH") {
       // Resolve symlinks if possible
       result = cmSystemTools::GetRealPath(result);
-      }
     }
-  else
-    {
+  } else {
     std::string err = "unknown component " + args[2];
     this->SetError(err);
     return false;
-    }
+  }
 
-  if(args.size() >= 4 && args[args.size() - 1] == "CACHE")
-    {
-    if(!programArgs.empty() && !storeArgs.empty())
-      {
-      this->Makefile->AddCacheDefinition
-        (storeArgs, programArgs.c_str(),
-         "", args[2] == "PATH" ? cmState::FILEPATH
-         : cmState::STRING);
-      }
-    this->Makefile->AddCacheDefinition
-      (args[0], result.c_str(), "",
-       args[2] == "PATH" ? cmState::FILEPATH
-       : cmState::STRING);
+  if (args.size() >= 4 && args[args.size() - 1] == "CACHE") {
+    if (!programArgs.empty() && !storeArgs.empty()) {
+      this->Makefile->AddCacheDefinition(storeArgs, programArgs.c_str(), "",
+                                         args[2] == "PATH" ? cmState::FILEPATH
+                                                           : cmState::STRING);
     }
-  else
-    {
-    if(!programArgs.empty() && !storeArgs.empty())
-      {
+    this->Makefile->AddCacheDefinition(args[0], result.c_str(), "",
+                                       args[2] == "PATH" ? cmState::FILEPATH
+                                                         : cmState::STRING);
+  } else {
+    if (!programArgs.empty() && !storeArgs.empty()) {
       this->Makefile->AddDefinition(storeArgs, programArgs.c_str());
-      }
-    this->Makefile->AddDefinition(args[0], result.c_str());
     }
+    this->Makefile->AddDefinition(args[0], result.c_str());
+  }
 
   return true;
 }
-
diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h
index 534de53..a114b3d 100644
--- a/Source/cmGetFilenameComponentCommand.h
+++ b/Source/cmGetFilenameComponentCommand.h
@@ -26,17 +26,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmGetFilenameComponentCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetFilenameComponentCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -46,11 +43,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "get_filename_component";}
+  virtual std::string GetName() const { return "get_filename_component"; }
 
   cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 617a811..06f7504 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -11,272 +11,220 @@
 ============================================================================*/
 #include "cmGetPropertyCommand.h"
 
-#include "cmake.h"
-#include "cmState.h"
-#include "cmTest.h"
 #include "cmGlobalGenerator.h"
-#include "cmSourceFile.h"
 #include "cmPropertyDefinition.h"
+#include "cmSourceFile.h"
+#include "cmState.h"
+#include "cmTest.h"
+#include "cmake.h"
 
-//----------------------------------------------------------------------------
 cmGetPropertyCommand::cmGetPropertyCommand()
 {
   this->InfoType = OutValue;
 }
 
-//----------------------------------------------------------------------------
-bool cmGetPropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetPropertyCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 3 )
-    {
+  if (args.size() < 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // The cmake variable in which to store the result.
   this->Variable = args[0];
 
   // Get the scope from which to get the property.
   cmProperty::ScopeType scope;
-  if(args[1] == "GLOBAL")
-    {
+  if (args[1] == "GLOBAL") {
     scope = cmProperty::GLOBAL;
-    }
-  else if(args[1] == "DIRECTORY")
-    {
+  } else if (args[1] == "DIRECTORY") {
     scope = cmProperty::DIRECTORY;
-    }
-  else if(args[1] == "TARGET")
-    {
+  } else if (args[1] == "TARGET") {
     scope = cmProperty::TARGET;
-    }
-  else if(args[1] == "SOURCE")
-    {
+  } else if (args[1] == "SOURCE") {
     scope = cmProperty::SOURCE_FILE;
-    }
-  else if(args[1] == "TEST")
-    {
+  } else if (args[1] == "TEST") {
     scope = cmProperty::TEST;
-    }
-  else if(args[1] == "VARIABLE")
-    {
+  } else if (args[1] == "VARIABLE") {
     scope = cmProperty::VARIABLE;
-    }
-  else if(args[1] == "CACHE")
-    {
+  } else if (args[1] == "CACHE") {
     scope = cmProperty::CACHE;
-    }
-  else if(args[1] == "INSTALL")
-    {
+  } else if (args[1] == "INSTALL") {
     scope = cmProperty::INSTALL;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << "given invalid scope " << args[1] << ".  "
       << "Valid scopes are "
       << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Parse remaining arguments.
-  enum Doing { DoingNone, DoingName, DoingProperty, DoingType };
+  enum Doing
+  {
+    DoingNone,
+    DoingName,
+    DoingProperty,
+    DoingType
+  };
   Doing doing = DoingName;
-  for(unsigned int i=2; i < args.size(); ++i)
-    {
-    if(args[i] == "PROPERTY")
-      {
+  for (unsigned int i = 2; i < args.size(); ++i) {
+    if (args[i] == "PROPERTY") {
       doing = DoingProperty;
-      }
-    else if(args[i] == "BRIEF_DOCS")
-      {
+    } else if (args[i] == "BRIEF_DOCS") {
       doing = DoingNone;
       this->InfoType = OutBriefDoc;
-      }
-    else if(args[i] == "FULL_DOCS")
-      {
+    } else if (args[i] == "FULL_DOCS") {
       doing = DoingNone;
       this->InfoType = OutFullDoc;
-      }
-    else if(args[i] == "SET")
-      {
+    } else if (args[i] == "SET") {
       doing = DoingNone;
       this->InfoType = OutSet;
-      }
-    else if(args[i] == "DEFINED")
-      {
+    } else if (args[i] == "DEFINED") {
       doing = DoingNone;
       this->InfoType = OutDefined;
-      }
-    else if(doing == DoingName)
-      {
+    } else if (doing == DoingName) {
       doing = DoingNone;
       this->Name = args[i];
-      }
-    else if(doing == DoingProperty)
-      {
+    } else if (doing == DoingProperty) {
       doing = DoingNone;
       this->PropertyName = args[i];
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "given invalid argument \"" << args[i] << "\".";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Make sure a property name was found.
-  if(this->PropertyName.empty())
-    {
+  if (this->PropertyName.empty()) {
     this->SetError("not given a PROPERTY <name> argument.");
     return false;
-    }
+  }
 
   // Compute requested output.
-  if(this->InfoType == OutBriefDoc)
-    {
+  if (this->InfoType == OutBriefDoc) {
     // Lookup brief documentation.
     std::string output;
-    if(cmPropertyDefinition const* def = this->Makefile->GetState()->
-       GetPropertyDefinition(this->PropertyName, scope))
-      {
+    if (cmPropertyDefinition const* def =
+          this->Makefile->GetState()->GetPropertyDefinition(this->PropertyName,
+                                                            scope)) {
       output = def->GetShortDescription();
-      }
-    else
-      {
+    } else {
       output = "NOTFOUND";
-      }
-    this->Makefile->AddDefinition(this->Variable, output.c_str());
     }
-  else if(this->InfoType == OutFullDoc)
-    {
+    this->Makefile->AddDefinition(this->Variable, output.c_str());
+  } else if (this->InfoType == OutFullDoc) {
     // Lookup full documentation.
     std::string output;
-    if(cmPropertyDefinition const* def = this->Makefile->GetState()->
-       GetPropertyDefinition(this->PropertyName, scope))
-      {
+    if (cmPropertyDefinition const* def =
+          this->Makefile->GetState()->GetPropertyDefinition(this->PropertyName,
+                                                            scope)) {
       output = def->GetFullDescription();
-      }
-    else
-      {
+    } else {
       output = "NOTFOUND";
-      }
-    this->Makefile->AddDefinition(this->Variable, output.c_str());
     }
-  else if(this->InfoType == OutDefined)
-    {
+    this->Makefile->AddDefinition(this->Variable, output.c_str());
+  } else if (this->InfoType == OutDefined) {
     // Lookup if the property is defined
-    if(this->Makefile->GetState()->
-       GetPropertyDefinition(this->PropertyName, scope))
-      {
+    if (this->Makefile->GetState()->GetPropertyDefinition(this->PropertyName,
+                                                          scope)) {
       this->Makefile->AddDefinition(this->Variable, "1");
-      }
-    else
-      {
+    } else {
       this->Makefile->AddDefinition(this->Variable, "0");
-      }
     }
-  else
-    {
+  } else {
     // Dispatch property getting.
-    switch(scope)
-      {
-      case cmProperty::GLOBAL:      return this->HandleGlobalMode();
-      case cmProperty::DIRECTORY:   return this->HandleDirectoryMode();
-      case cmProperty::TARGET:      return this->HandleTargetMode();
-      case cmProperty::SOURCE_FILE: return this->HandleSourceMode();
-      case cmProperty::TEST:        return this->HandleTestMode();
-      case cmProperty::VARIABLE:    return this->HandleVariableMode();
-      case cmProperty::CACHE:       return this->HandleCacheMode();
-      case cmProperty::INSTALL:       return this->HandleInstallMode();
+    switch (scope) {
+      case cmProperty::GLOBAL:
+        return this->HandleGlobalMode();
+      case cmProperty::DIRECTORY:
+        return this->HandleDirectoryMode();
+      case cmProperty::TARGET:
+        return this->HandleTargetMode();
+      case cmProperty::SOURCE_FILE:
+        return this->HandleSourceMode();
+      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
-      }
     }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::StoreResult(const char* value)
 {
-  if(this->InfoType == OutSet)
-    {
-    this->Makefile->AddDefinition(this->Variable, value? "1":"0");
-    }
-  else // if(this->InfoType == OutValue)
-    {
-    if(value)
-      {
+  if (this->InfoType == OutSet) {
+    this->Makefile->AddDefinition(this->Variable, value ? "1" : "0");
+  } else // if(this->InfoType == OutValue)
+  {
+    if (value) {
       this->Makefile->AddDefinition(this->Variable, value);
-      }
-    else
-      {
+    } else {
       this->Makefile->RemoveDefinition(this->Variable);
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleGlobalMode()
 {
-  if(!this->Name.empty())
-    {
+  if (!this->Name.empty()) {
     this->SetError("given name for GLOBAL scope.");
     return false;
-    }
+  }
 
   // Get the property.
   cmake* cm = this->Makefile->GetCMakeInstance();
-  return this->StoreResult(cm->GetState()
-             ->GetGlobalProperty(this->PropertyName));
+  return this->StoreResult(
+    cm->GetState()->GetGlobalProperty(this->PropertyName));
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleDirectoryMode()
 {
   // Default to the current directory.
   cmMakefile* mf = this->Makefile;
 
   // Lookup the directory if given.
-  if(!this->Name.empty())
-    {
+  if (!this->Name.empty()) {
     // Construct the directory name.  Interpret relative paths with
     // respect to the current directory.
     std::string dir = this->Name;
-    if(!cmSystemTools::FileIsFullPath(dir.c_str()))
-      {
+    if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
       dir = this->Makefile->GetCurrentSourceDirectory();
       dir += "/";
       dir += this->Name;
-      }
+    }
 
     // The local generators are associated with collapsed paths.
     dir = cmSystemTools::CollapseFullPath(dir);
 
     // Lookup the generator.
     mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
-    if (!mf)
-      {
+    if (!mf) {
       // Could not find the directory.
-      this->SetError
-        ("DIRECTORY scope provided but requested directory was not found. "
-         "This could be because the directory argument was invalid or, "
-         "it is valid but has not been processed yet.");
+      this->SetError(
+        "DIRECTORY scope provided but requested directory was not found. "
+        "This could be because the directory argument was invalid or, "
+        "it is valid but has not been processed yet.");
       return false;
-      }
     }
+  }
 
-  if (this->PropertyName == "DEFINITIONS")
-    {
-    switch(mf->GetPolicyStatus(cmPolicies::CMP0059))
-      {
+  if (this->PropertyName == "DEFINITIONS") {
+    switch (mf->GetPolicyStatus(cmPolicies::CMP0059)) {
       case cmPolicies::WARN:
         mf->IssueMessage(cmake::AUTHOR_WARNING,
                          cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
@@ -286,89 +234,70 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
       case cmPolicies::REQUIRED_ALWAYS:
       case cmPolicies::REQUIRED_IF_USED:
         break;
-      }
     }
+  }
 
   // Get the property.
   return this->StoreResult(mf->GetProperty(this->PropertyName));
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleTargetMode()
 {
-  if(this->Name.empty())
-    {
+  if (this->Name.empty()) {
     this->SetError("not given name for TARGET scope.");
     return false;
-    }
+  }
 
-  if(this->PropertyName == "ALIASED_TARGET")
-    {
-    if(this->Makefile->IsAlias(this->Name))
-      {
-      if(cmTarget* target =
-                          this->Makefile->FindTargetToUse(this->Name))
-        {
+  if (this->PropertyName == "ALIASED_TARGET") {
+    if (this->Makefile->IsAlias(this->Name)) {
+      if (cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) {
         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,
-                                                 this->Makefile));
     }
-  else
-    {
+    return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
+  }
+  if (cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) {
+    return this->StoreResult(
+      target->GetProperty(this->PropertyName, this->Makefile));
+  } else {
     std::ostringstream e;
     e << "could not find TARGET " << this->Name
       << ".  Perhaps it has not yet been created.";
     this->SetError(e.str());
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleSourceMode()
 {
-  if(this->Name.empty())
-    {
+  if (this->Name.empty()) {
     this->SetError("not given name for SOURCE scope.");
     return false;
-    }
+  }
 
   // Get the source file.
-  if(cmSourceFile* sf =
-     this->Makefile->GetOrCreateSource(this->Name))
-    {
-    return
-      this->StoreResult(sf->GetPropertyForUser(this->PropertyName));
-    }
-  else
-    {
+  if (cmSourceFile* sf = this->Makefile->GetOrCreateSource(this->Name)) {
+    return this->StoreResult(sf->GetPropertyForUser(this->PropertyName));
+  } else {
     std::ostringstream e;
     e << "given SOURCE name that could not be found or created: "
       << this->Name;
     this->SetError(e.str());
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleTestMode()
 {
-  if(this->Name.empty())
-    {
+  if (this->Name.empty()) {
     this->SetError("not given name for TEST scope.");
     return false;
-    }
+  }
 
   // Loop over all tests looking for matching names.
-  if(cmTest* test = this->Makefile->GetTest(this->Name))
-    {
+  if (cmTest* test = this->Makefile->GetTest(this->Name)) {
     return this->StoreResult(test->GetProperty(this->PropertyName));
-    }
+  }
 
   // If not found it is an error.
   std::ostringstream e;
@@ -377,64 +306,53 @@ bool cmGetPropertyCommand::HandleTestMode()
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleVariableMode()
 {
-  if(!this->Name.empty())
-    {
+  if (!this->Name.empty()) {
     this->SetError("given name for VARIABLE scope.");
     return false;
-    }
+  }
 
-  return this->StoreResult
-    (this->Makefile->GetDefinition(this->PropertyName));
+  return this->StoreResult(this->Makefile->GetDefinition(this->PropertyName));
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleCacheMode()
 {
-  if(this->Name.empty())
-    {
+  if (this->Name.empty()) {
     this->SetError("not given name for CACHE scope.");
     return false;
-    }
+  }
 
   const char* value = 0;
-  if(this->Makefile->GetState()->GetCacheEntryValue(this->Name))
-    {
-    value = this->Makefile->GetState()
-                ->GetCacheEntryProperty(this->Name, this->PropertyName);
-    }
+  if (this->Makefile->GetState()->GetCacheEntryValue(this->Name)) {
+    value = this->Makefile->GetState()->GetCacheEntryProperty(
+      this->Name, this->PropertyName);
+  }
   this->StoreResult(value);
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGetPropertyCommand::HandleInstallMode()
 {
-  if(this->Name.empty())
-    {
+  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))
-    {
+  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
-    {
+  } else {
     std::ostringstream 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 40b7dbc..aeed01d 100644
--- a/Source/cmGetPropertyCommand.h
+++ b/Source/cmGetPropertyCommand.h
@@ -19,17 +19,14 @@ class cmGetPropertyCommand : public cmCommand
 public:
   cmGetPropertyCommand();
 
-  virtual cmCommand* Clone()
-    {
-      return new cmGetPropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetPropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -39,11 +36,19 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "get_property";}
+  virtual std::string GetName() const { return "get_property"; }
 
   cmTypeMacro(cmGetPropertyCommand, cmCommand);
+
 private:
-  enum OutType { OutValue, OutDefined, OutBriefDoc, OutFullDoc, OutSet };
+  enum OutType
+  {
+    OutValue,
+    OutDefined,
+    OutBriefDoc,
+    OutFullDoc,
+    OutSet
+  };
   std::string Variable;
   std::string Name;
   std::string PropertyName;
diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx
index 46daa34..e64befe 100644
--- a/Source/cmGetSourceFilePropertyCommand.cxx
+++ b/Source/cmGetSourceFilePropertyCommand.cxx
@@ -14,43 +14,36 @@
 #include "cmSourceFile.h"
 
 // cmSetSourceFilePropertyCommand
-bool cmGetSourceFilePropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetSourceFilePropertyCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() != 3 )
-    {
+  if (args.size() != 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   const char* var = args[0].c_str();
   const char* file = args[1].c_str();
   cmSourceFile* sf = this->Makefile->GetSource(file);
 
   // for the location we must create a source file first
-  if (!sf && args[2] == "LOCATION")
-    {
+  if (!sf && args[2] == "LOCATION") {
     sf = this->Makefile->CreateSource(file);
-    }
-  if(sf)
-    {
-    if(args[2] == "LANGUAGE")
-      {
+  }
+  if (sf) {
+    if (args[2] == "LANGUAGE") {
       this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
       return true;
-      }
-    const char *prop = 0;
-    if (!args[2].empty())
-      {
+    }
+    const char* prop = 0;
+    if (!args[2].empty()) {
       prop = sf->GetPropertyForUser(args[2]);
-      }
-    if (prop)
-      {
+    }
+    if (prop) {
       this->Makefile->AddDefinition(var, prop);
       return true;
-      }
     }
+  }
 
   this->Makefile->AddDefinition(var, "NOTFOUND");
   return true;
 }
-
diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h
index ab8ce36..06f582f 100644
--- a/Source/cmGetSourceFilePropertyCommand.h
+++ b/Source/cmGetSourceFilePropertyCommand.h
@@ -17,26 +17,21 @@
 class cmGetSourceFilePropertyCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmGetSourceFilePropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetSourceFilePropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "get_source_file_property";}
+  virtual std::string GetName() const { return "get_source_file_property"; }
 
   cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index ca40bd0..dded9f7 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -12,52 +12,40 @@
 #include "cmGetTargetPropertyCommand.h"
 
 // cmSetTargetPropertyCommand
-bool cmGetTargetPropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetTargetPropertyCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() != 3 )
-    {
+  if (args.size() != 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::string var = args[0];
   const std::string& targetName = args[1];
   std::string prop;
   bool prop_exists = false;
 
-  if(args[2] == "ALIASED_TARGET")
-    {
-    if(this->Makefile->IsAlias(targetName))
-      {
-      if(cmTarget* target =
-                          this->Makefile->FindTargetToUse(targetName))
-        {
+  if (args[2] == "ALIASED_TARGET") {
+    if (this->Makefile->IsAlias(targetName)) {
+      if (cmTarget* target = this->Makefile->FindTargetToUse(targetName)) {
         prop = target->GetName();
         prop_exists = true;
-        }
       }
     }
-  else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
-    {
+  } else if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) {
     cmTarget& target = *tgt;
     const char* prop_cstr = 0;
-    if (!args[2].empty())
-      {
+    if (!args[2].empty()) {
       prop_cstr = target.GetProperty(args[2], this->Makefile);
-      }
-    if(prop_cstr)
-      {
+    }
+    if (prop_cstr) {
       prop = prop_cstr;
       prop_exists = true;
-      }
     }
-  else
-    {
+  } else {
     bool issueMessage = false;
     std::ostringstream e;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0045))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) {
       case cmPolicies::WARN:
         issueMessage = true;
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n";
@@ -68,24 +56,20 @@ bool cmGetTargetPropertyCommand
       case cmPolicies::NEW:
         issueMessage = true;
         messageType = cmake::FATAL_ERROR;
-      }
-    if (issueMessage)
-      {
+    }
+    if (issueMessage) {
       e << "get_target_property() called with non-existent target \""
-        << targetName <<  "\".";
+        << targetName << "\".";
       this->Makefile->IssueMessage(messageType, e.str());
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
-  if (prop_exists)
-    {
+  }
+  if (prop_exists) {
     this->Makefile->AddDefinition(var, prop.c_str());
     return true;
-    }
-  this->Makefile->AddDefinition(var, (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 a35c6fe..9a1e18e 100644
--- a/Source/cmGetTargetPropertyCommand.h
+++ b/Source/cmGetTargetPropertyCommand.h
@@ -17,26 +17,21 @@
 class cmGetTargetPropertyCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmGetTargetPropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetTargetPropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "get_target_property";}
+  virtual std::string GetName() const { return "get_target_property"; }
 
   cmTypeMacro(cmGetTargetPropertyCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx
index bf34589..6599021 100644
--- a/Source/cmGetTestPropertyCommand.cxx
+++ b/Source/cmGetTestPropertyCommand.cxx
@@ -11,36 +11,31 @@
 ============================================================================*/
 #include "cmGetTestPropertyCommand.h"
 
-#include "cmake.h"
 #include "cmTest.h"
+#include "cmake.h"
 
 // cmGetTestPropertyCommand
-bool cmGetTestPropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmGetTestPropertyCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 3 )
-    {
+  if (args.size() < 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string testName = args[0];
   std::string var = args[2];
-  cmTest *test = this->Makefile->GetTest(testName);
-  if (test)
-    {
-    const char *prop = 0;
-    if (!args[1].empty())
-      {
+  cmTest* test = this->Makefile->GetTest(testName);
+  if (test) {
+    const char* prop = 0;
+    if (!args[1].empty()) {
       prop = test->GetProperty(args[1]);
-      }
-    if (prop)
-      {
+    }
+    if (prop) {
       this->Makefile->AddDefinition(var, prop);
       return true;
-      }
     }
+  }
   this->Makefile->AddDefinition(var, "NOTFOUND");
   return true;
 }
-
diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h
index 2819492..fc281c4 100644
--- a/Source/cmGetTestPropertyCommand.h
+++ b/Source/cmGetTestPropertyCommand.h
@@ -17,26 +17,21 @@
 class cmGetTestPropertyCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-    return new cmGetTestPropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmGetTestPropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "get_test_property";}
+  virtual std::string GetName() const { return "get_test_property"; }
 
   cmTypeMacro(cmGetTestPropertyCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmGhsMultiGpj.cxx b/Source/cmGhsMultiGpj.cxx
index e1dce52..ca88578 100644
--- a/Source/cmGhsMultiGpj.cxx
+++ b/Source/cmGhsMultiGpj.cxx
@@ -14,11 +14,10 @@
 #include "cmGeneratedFileStream.h"
 
 void GhsMultiGpj::WriteGpjTag(Types const gpjType,
-                              cmGeneratedFileStream *const filestream)
+                              cmGeneratedFileStream* const filestream)
 {
-  char const *tag;
-  switch (gpjType)
-    {
+  char const* tag;
+  switch (gpjType) {
     case INTERGRITY_APPLICATION:
       tag = "INTEGRITY Application";
       break;
@@ -39,6 +38,6 @@ void GhsMultiGpj::WriteGpjTag(Types const gpjType,
       break;
     default:
       tag = "";
-    }
+  }
   *filestream << "[" << tag << "]" << std::endl;
 }
diff --git a/Source/cmGhsMultiGpj.h b/Source/cmGhsMultiGpj.h
index 91ff0f4..b388455 100644
--- a/Source/cmGhsMultiGpj.h
+++ b/Source/cmGhsMultiGpj.h
@@ -12,6 +12,8 @@
 #ifndef cmGhsMultiGpj_h
 #define cmGhsMultiGpj_h
 
+#include "cmStandardIncludes.h"
+
 class cmGeneratedFileStream;
 
 class GhsMultiGpj
@@ -28,7 +30,7 @@ public:
   };
 
   static void WriteGpjTag(Types const gpjType,
-                          cmGeneratedFileStream *filestream);
+                          cmGeneratedFileStream* filestream);
 };
 
 #endif // ! cmGhsMultiGpjType_h
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 18e140e..8565fdb 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -10,29 +10,28 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGhsMultiTargetGenerator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalGhsMultiGenerator.h"
 #include "cmLocalGhsMultiGenerator.h"
 #include "cmMakefile.h"
-#include "cmTarget.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSourceFile.h"
+#include "cmTarget.h"
 #include <assert.h>
-#include <cmAlgorithms.h>
 
 std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic");
 
-cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget *target)
+cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target)
   : GeneratorTarget(target)
-  , LocalGenerator(static_cast<cmLocalGhsMultiGenerator *>(
-                     target->GetLocalGenerator()))
+  , LocalGenerator(
+      static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator()))
   , Makefile(target->Target->GetMakefile())
   , TargetGroup(DetermineIfTargetGroup(target))
   , DynamicDownload(false)
 {
   this->RelBuildFilePath = this->GetRelBuildFilePath(target);
 
-  this->RelOutputFileName =
-    this->RelBuildFilePath + target->GetName() + ".a";
+  this->RelOutputFileName = this->RelBuildFilePath + target->GetName() + ".a";
 
   this->RelBuildFileName = this->RelBuildFilePath;
   this->RelBuildFileName += this->GetBuildFileName(target);
@@ -49,50 +48,48 @@ cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator()
   cmDeleteAll(this->FolderBuildStreams);
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetRelBuildFilePath(
-        const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetRelBuildFilePath(
+  const cmGeneratorTarget* target)
 {
   std::string output;
-  char const *folderProp = target->GetProperty("FOLDER");
+  char const* folderProp = target->GetProperty("FOLDER");
   output = NULL == folderProp ? "" : folderProp;
   cmSystemTools::ConvertToUnixSlashes(output);
-  if (!output.empty())
-  {
+  if (!output.empty()) {
     output += "/";
   }
   output += target->GetName() + "/";
   return output;
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetAbsPathToRoot(
+  const cmGeneratorTarget* target)
 {
   return target->GetLocalGenerator()->GetBinaryDirectory();
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetAbsBuildFilePath(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetAbsBuildFilePath(
+  const cmGeneratorTarget* target)
 {
   std::string output;
   output = cmGhsMultiTargetGenerator::GetAbsPathToRoot(target);
   output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
   output += cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
-  return  output;
+  return output;
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetRelBuildFileName(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetRelBuildFileName(
+  const cmGeneratorTarget* target)
 {
   std::string output;
   output = cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
   output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
   output += cmGhsMultiTargetGenerator::GetBuildFileName(target);
-  return  output;
+  return output;
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetBuildFileName(const cmGeneratorTarget *target)
+std::string cmGhsMultiTargetGenerator::GetBuildFileName(
+  const cmGeneratorTarget* target)
 {
   std::string output;
   output = target->GetName();
@@ -100,44 +97,39 @@ cmGhsMultiTargetGenerator::GetBuildFileName(const cmGeneratorTarget *target)
   return output;
 }
 
-std::string
-cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(std::string const &input)
+std::string cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(
+  std::string const& input)
 {
   std::string output(input);
-  if (!cmHasLiteralSuffix(output, "/"))
-    {
+  if (!cmHasLiteralSuffix(output, "/")) {
     output += "/";
-    }
+  }
   return output;
 }
 
 void cmGhsMultiTargetGenerator::Generate()
 {
-  const std::vector<cmSourceFile *> objectSources = this->GetSources();
-  if (!objectSources.empty() && this->IncludeThisTarget())
-    {
-    if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str()))
-      {
+  std::vector<cmSourceFile*> objectSources = this->GetSources();
+  if (!objectSources.empty() && this->IncludeThisTarget()) {
+    if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str())) {
       cmSystemTools::MakeDirectory(this->AbsBuildFilePath.c_str());
-      }
+    }
     cmGlobalGhsMultiGenerator::Open(std::string(""), this->AbsBuildFileName,
                                     &this->FolderBuildStreams);
     cmGlobalGhsMultiGenerator::OpenBuildFileStream(
       this->GetFolderBuildStreams());
     std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-    if (0 == config.length())
-      {
+    if (0 == config.length()) {
       config = "RELEASE";
-      }
+    }
     const std::string language(
-          this->GeneratorTarget->GetLinkerLanguage(config));
+      this->GeneratorTarget->GetLinkerLanguage(config));
     config = cmSystemTools::UpperCase(config);
     this->DynamicDownload = this->DetermineIfDynamicDownload(config, language);
-    if (this->DynamicDownload)
-      {
+    if (this->DynamicDownload) {
       *this->GetFolderBuildStreams() << "#component integrity_dynamic_download"
                                      << std::endl;
-      }
+    }
     GhsMultiGpj::WriteGpjTag(this->GetGpjTag(), this->GetFolderBuildStreams());
     cmGlobalGhsMultiGenerator::WriteDisclaimer(this->GetFolderBuildStreams());
 
@@ -147,32 +139,34 @@ void cmGhsMultiTargetGenerator::Generate()
     this->WriteCompilerFlags(config, language);
     this->WriteCompilerDefinitions(config, language);
     this->WriteIncludes(config, language);
-    if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-      {
-      this->WriteTargetLinkLibraries();
-      }
+    if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+      this->WriteTargetLinkLibraries(config, language);
+    }
     this->WriteCustomCommands();
 
-    this->WriteSources(objectSources);
-    }
+    std::map<const cmSourceFile*, std::string> objectNames =
+      cmGhsMultiTargetGenerator::GetObjectNames(
+        &objectSources, this->LocalGenerator, this->GeneratorTarget);
+
+    this->WriteSources(objectSources, objectNames);
+  }
 }
 
 bool cmGhsMultiTargetGenerator::IncludeThisTarget()
 {
   bool output = true;
-  char const *excludeFromAll =
-      this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
+  char const* excludeFromAll =
+    this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
   if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
-      '\0' == excludeFromAll[1])
-    {
+      '\0' == excludeFromAll[1]) {
     output = false;
-    }
+  }
   return output;
 }
 
-std::vector<cmSourceFile *> cmGhsMultiTargetGenerator::GetSources() const
+std::vector<cmSourceFile*> cmGhsMultiTargetGenerator::GetSources() const
 {
-  std::vector<cmSourceFile *> output;
+  std::vector<cmSourceFile*> output;
   std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   this->GeneratorTarget->GetSourceFiles(output, config);
   return output;
@@ -184,235 +178,233 @@ GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const
 }
 
 GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag(
-    const cmGeneratorTarget *target)
+  const cmGeneratorTarget* target)
 {
   GhsMultiGpj::Types output;
-  if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target))
-    {
+  if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) {
     output = GhsMultiGpj::INTERGRITY_APPLICATION;
-    }
-  else if (target->GetType() == cmState::STATIC_LIBRARY)
-    {
+  } else if (target->GetType() == cmState::STATIC_LIBRARY) {
     output = GhsMultiGpj::LIBRARY;
-    }
-  else
-    {
+  } else {
     output = GhsMultiGpj::PROGRAM;
-    }
+  }
   return output;
 }
 
-cmGlobalGhsMultiGenerator*
-cmGhsMultiTargetGenerator::GetGlobalGenerator() const
+cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
+  const
 {
-  return static_cast<cmGlobalGhsMultiGenerator *>(
+  return static_cast<cmGlobalGhsMultiGenerator*>(
     this->LocalGenerator->GetGlobalGenerator());
 }
 
-void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string &config,
+void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string& config,
                                                    bool const notKernel)
 {
   std::string outputDir(this->GetOutputDirectory(config));
   std::string outputFilename(this->GetOutputFilename(config));
 
-  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
-    {
-    *this->GetFolderBuildStreams() << "    -o \""
-                                   << outputDir << outputFilename << ".a\""
-                                   << std::endl;
-    }
-  else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-    {
-    if (notKernel && !this->IsTargetGroup())
-      {
+  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) {
+    std::string const static_library_suffix =
+      this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
+    *this->GetFolderBuildStreams() << "    -o \"" << outputDir
+                                   << outputFilename << static_library_suffix
+                                   << "\"" << std::endl;
+  } else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+    if (notKernel && !this->IsTargetGroup()) {
       *this->GetFolderBuildStreams() << "    -relprog" << std::endl;
-      }
-    if (this->IsTargetGroup())
-      {
+    }
+    if (this->IsTargetGroup()) {
       *this->GetFolderBuildStreams()
-          << "    -o \"" << outputDir
-          << outputFilename << ".elf\"" << std::endl;
+        << "    -o \"" << outputDir << outputFilename << ".elf\"" << std::endl;
       *this->GetFolderBuildStreams() << "    :extraOutputFile=\"" << outputDir
                                      << outputFilename << ".elf.ael\""
                                      << std::endl;
-      }
-    else
-      {
-      *this->GetFolderBuildStreams() << "    -o \""
-                                     << outputDir << outputFilename << ".as\""
-                                     << std::endl;
-      }
+    } else {
+      std::string const executable_suffix =
+        this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
+      *this->GetFolderBuildStreams() << "    -o \"" << outputDir
+                                     << outputFilename << executable_suffix
+                                     << "\"" << std::endl;
     }
+  }
 }
 
-void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const &config,
-                                                 const std::string &language,
+void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
+                                                 const std::string& language,
                                                  bool const notKernel)
 {
   std::map<std::string, std::string>::iterator i =
     this->FlagsByLanguage.find(language);
-  if (i == this->FlagsByLanguage.end())
-    {
+  if (i == this->FlagsByLanguage.end()) {
     std::string flags;
-    const char *lang = language.c_str();
+    const char* lang = language.c_str();
 
-    if (notKernel)
-      {
+    if (notKernel) {
       this->LocalGenerator->AddLanguageFlags(flags, lang, config);
-      }
-    else
-      {
-        this->LocalGenerator->AddLanguageFlags(
-            flags, lang + std::string("_GHS_KERNEL"), config);
-      }
-    this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
-                                          lang, config);
-    this->LocalGenerator->AddVisibilityPresetFlags(flags,
-                                                   this->GeneratorTarget,
-                                                   lang);
+    } else {
+      this->LocalGenerator->AddLanguageFlags(
+        flags, lang + std::string("_GHS_KERNEL"), config);
+    }
+    this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
+                                          config);
+    this->LocalGenerator->AddVisibilityPresetFlags(
+      flags, this->GeneratorTarget, lang);
 
     // Append old-style preprocessor definition flags.
-    if (std::string(" ") != std::string(this->Makefile->GetDefineFlags()))
-      {
+    if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) {
       this->LocalGenerator->AppendFlags(flags,
-                                      this->Makefile->GetDefineFlags());
-      }
+                                        this->Makefile->GetDefineFlags());
+    }
 
     // Add target-specific flags.
-    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
-                                            lang, config);
+    this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
+                                            config);
 
     std::map<std::string, std::string>::value_type entry(language, flags);
     i = this->FlagsByLanguage.insert(entry).first;
-    }
+  }
 }
 
-std::string cmGhsMultiTargetGenerator::GetDefines(const std::string &language,
-                                                  std::string const &config)
+std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language,
+                                                  std::string const& config)
 {
   std::map<std::string, std::string>::iterator i =
     this->DefinesByLanguage.find(language);
-  if (i == this->DefinesByLanguage.end())
-    {
+  if (i == this->DefinesByLanguage.end()) {
     std::set<std::string> defines;
-    const char *lang = language.c_str();
+    const char* lang = language.c_str();
     // Add the export symbol definition for shared library objects.
-    if (const char *exportMacro = this->GeneratorTarget->GetExportMacro())
-      {
+    if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
       this->LocalGenerator->AppendDefines(defines, exportMacro);
-      }
+    }
 
     // Add preprocessor definitions for this target and configuration.
-    this->LocalGenerator->AddCompileDefinitions(defines,
-                                                this->GeneratorTarget, config,
-                                                language);
+    this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
+                                                config, language);
 
     std::string definesString;
     this->LocalGenerator->JoinDefines(defines, definesString, lang);
 
     std::map<std::string, std::string>::value_type entry(language,
-                                                          definesString);
+                                                         definesString);
     i = this->DefinesByLanguage.insert(entry).first;
-    }
+  }
   return i->second;
 }
 
-void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const &,
-                                                   const std::string &language)
+void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const&,
+                                                   const std::string& language)
 {
   std::map<std::string, std::string>::iterator flagsByLangI =
-      this->FlagsByLanguage.find(language);
-  if (flagsByLangI != this->FlagsByLanguage.end())
-    {
-    if (!flagsByLangI->second.empty())
-      {
+    this->FlagsByLanguage.find(language);
+  if (flagsByLangI != this->FlagsByLanguage.end()) {
+    if (!flagsByLangI->second.empty()) {
       *this->GetFolderBuildStreams() << "    " << flagsByLangI->second
-        << std::endl;
-      }
+                                     << std::endl;
     }
+  }
 }
 
 void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
-  const std::string &config, const std::string &language)
+  const std::string& config, const std::string& language)
 {
   std::vector<std::string> compileDefinitions;
-  this->GeneratorTarget->GetCompileDefinitions(compileDefinitions,
-                                               config, language);
+  this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, config,
+                                               language);
   for (std::vector<std::string>::const_iterator cdI =
          compileDefinitions.begin();
-       cdI != compileDefinitions.end(); ++cdI)
-    {
+       cdI != compileDefinitions.end(); ++cdI) {
     *this->GetFolderBuildStreams() << "    -D" << (*cdI) << std::endl;
-    }
+  }
 }
 
-void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config,
-                                              const std::string &language)
+void cmGhsMultiTargetGenerator::WriteIncludes(const std::string& config,
+                                              const std::string& language)
 {
-  std::vector<std::string> includes =
-    this->GeneratorTarget->GetIncludeDirectories(config, language);
+  std::vector<std::string> includes;
+  this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
+                                              language, config);
+
   for (std::vector<std::string>::const_iterator includes_i = includes.begin();
-       includes_i != includes.end(); ++includes_i)
-    {
+       includes_i != includes.end(); ++includes_i) {
     *this->GetFolderBuildStreams() << "    -I\"" << *includes_i << "\""
                                    << std::endl;
-    }
+  }
 }
 
-void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
+void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
+  std::string const& config, std::string const& language)
 {
   // library directories
   cmTargetDependSet tds =
     this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
   for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end();
-       ++tdsI)
-    {
-    const cmGeneratorTarget *tg = *tdsI;
+       ++tdsI) {
+    const cmGeneratorTarget* tg = *tdsI;
     *this->GetFolderBuildStreams() << "    -L\"" << GetAbsBuildFilePath(tg)
                                    << "\"" << std::endl;
-    }
+  }
   // library targets
   cmTarget::LinkLibraryVectorType llv =
     this->GeneratorTarget->Target->GetOriginalLinkLibraries();
   for (cmTarget::LinkLibraryVectorType::const_iterator llvI = llv.begin();
-       llvI != llv.end(); ++llvI)
-    {
+       llvI != llv.end(); ++llvI) {
     std::string libName = llvI->first;
     // if it is a user defined target get the full path to the lib
-    cmTarget *tg(GetGlobalGenerator()->FindTarget(libName));
-    if (NULL != tg)
-      {
+    cmTarget* tg(GetGlobalGenerator()->FindTarget(libName));
+    if (NULL != tg) {
       libName = tg->GetName() + ".a";
-      }
+    }
     *this->GetFolderBuildStreams() << "    -l\"" << libName << "\""
                                    << std::endl;
+  }
+
+  if (!this->TargetGroup) {
+    std::string linkLibraries;
+    std::string flags;
+    std::string linkFlags;
+    std::string frameworkPath;
+    std::string linkPath;
+    std::string createRule =
+      this->GeneratorTarget->GetCreateRuleVariable(language, config);
+    bool useWatcomQuote =
+      this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
+    this->LocalGenerator->GetTargetFlags(
+      linkLibraries, flags, linkFlags, frameworkPath, linkPath,
+      this->GeneratorTarget, useWatcomQuote);
+    linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
+
+    if (!linkPath.empty()) {
+      linkPath = " " + linkPath.substr(0U, linkPath.size() - 1U);
+      *this->GetFolderBuildStreams() << linkPath;
     }
+
+    if (!linkFlags.empty()) {
+      *this->GetFolderBuildStreams() << "    " << linkFlags << std::endl;
+    }
+  }
 }
 
 void cmGhsMultiTargetGenerator::WriteCustomCommands()
 {
-  WriteCustomCommandsHelper(
-        this->GeneratorTarget->GetPreBuildCommands(),
-        cmTarget::PRE_BUILD);
-  WriteCustomCommandsHelper(
-        this->GeneratorTarget->GetPostBuildCommands(),
-        cmTarget::POST_BUILD);
+  WriteCustomCommandsHelper(this->GeneratorTarget->GetPreBuildCommands(),
+                            cmTarget::PRE_BUILD);
+  WriteCustomCommandsHelper(this->GeneratorTarget->GetPostBuildCommands(),
+                            cmTarget::POST_BUILD);
 }
 
 void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
-  std::vector<cmCustomCommand> const &commandsSet,
+  std::vector<cmCustomCommand> const& commandsSet,
   cmTarget::CustomCommandType const commandType)
 {
   for (std::vector<cmCustomCommand>::const_iterator commandsSetI =
          commandsSet.begin();
-       commandsSetI != commandsSet.end(); ++commandsSetI)
-    {
-    cmCustomCommandLines const &commands = commandsSetI->GetCommandLines();
+       commandsSetI != commandsSet.end(); ++commandsSetI) {
+    cmCustomCommandLines const& commands = commandsSetI->GetCommandLines();
     for (cmCustomCommandLines::const_iterator commandI = commands.begin();
-         commandI != commands.end(); ++commandI)
-      {
-      switch (commandType)
-        {
+         commandI != commands.end(); ++commandI) {
+      switch (commandType) {
         case cmTarget::PRE_BUILD:
           *this->GetFolderBuildStreams() << "    :preexecShellSafe=";
           break;
@@ -421,39 +413,82 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
           break;
         default:
           assert("Only pre and post are supported");
-        }
-      cmCustomCommandLine const &command = *commandI;
+      }
+      cmCustomCommandLine const& command = *commandI;
       for (cmCustomCommandLine::const_iterator commandLineI = command.begin();
-           commandLineI != command.end(); ++commandLineI)
-        {
+           commandLineI != command.end(); ++commandLineI) {
         std::string subCommandE =
-            this->LocalGenerator->EscapeForShell(*commandLineI, true);
-        if (!command.empty())
-          {
+          this->LocalGenerator->EscapeForShell(*commandLineI, true);
+        if (!command.empty()) {
           *this->GetFolderBuildStreams()
             << (command.begin() == commandLineI ? "'" : " ");
-          //Need to double escape backslashes
+          // Need to double escape backslashes
           cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\");
-          }
-        *this->GetFolderBuildStreams() << subCommandE;
         }
-      if (!command.empty())
-        {
+        *this->GetFolderBuildStreams() << subCommandE;
+      }
+      if (!command.empty()) {
         *this->GetFolderBuildStreams() << "'" << std::endl;
-        }
       }
     }
+  }
+}
+
+std::map<const cmSourceFile*, std::string>
+cmGhsMultiTargetGenerator::GetObjectNames(
+  std::vector<cmSourceFile*>* const objectSources,
+  cmLocalGhsMultiGenerator* const localGhsMultiGenerator,
+  cmGeneratorTarget* const generatorTarget)
+{
+  std::map<std::string, std::vector<cmSourceFile*> > filenameToSource;
+  std::map<cmSourceFile*, std::string> sourceToFilename;
+  for (std::vector<cmSourceFile*>::const_iterator sf = objectSources->begin();
+       sf != objectSources->end(); ++sf) {
+    const std::string filename =
+      cmSystemTools::GetFilenameName((*sf)->GetFullPath());
+    const std::string lower_filename = cmSystemTools::LowerCase(filename);
+    filenameToSource[lower_filename].push_back(*sf);
+    sourceToFilename[*sf] = lower_filename;
+  }
+
+  std::vector<cmSourceFile*> duplicateSources;
+  for (std::map<std::string, std::vector<cmSourceFile*> >::const_iterator
+         msvSourceI = filenameToSource.begin();
+       msvSourceI != filenameToSource.end(); ++msvSourceI) {
+    if (msvSourceI->second.size() > 1) {
+      duplicateSources.insert(duplicateSources.end(),
+                              msvSourceI->second.begin(),
+                              msvSourceI->second.end());
+    }
+  }
+
+  std::map<const cmSourceFile*, std::string> objectNamesCorrected;
+
+  for (std::vector<cmSourceFile*>::const_iterator sf =
+         duplicateSources.begin();
+       sf != duplicateSources.end(); ++sf) {
+    std::string const longestObjectDirectory(
+      cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
+        localGhsMultiGenerator, generatorTarget, *sf));
+    std::string objFilenameName =
+      localGhsMultiGenerator->GetObjectFileNameWithoutTarget(
+        **sf, longestObjectDirectory);
+    cmsys::SystemTools::ReplaceString(objFilenameName, "/", "_");
+    objectNamesCorrected[*sf] = objFilenameName;
+  }
+
+  return objectNamesCorrected;
 }
 
 void cmGhsMultiTargetGenerator::WriteSources(
-  std::vector<cmSourceFile *> const &objectSources)
+  std::vector<cmSourceFile*> const& objectSources,
+  std::map<const cmSourceFile*, std::string> const& objectNames)
 {
-  for (std::vector<cmSourceFile *>::const_iterator si = objectSources.begin();
-       si != objectSources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator si = objectSources.begin();
+       si != objectSources.end(); ++si) {
     std::vector<cmSourceGroup> sourceGroups(this->Makefile->GetSourceGroups());
-    char const *sourceFullPath = (*si)->GetFullPath().c_str();
-    cmSourceGroup *sourceGroup =
+    char const* sourceFullPath = (*si)->GetFullPath().c_str();
+    cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups);
     std::string sgPath(sourceGroup->GetFullName());
     cmSystemTools::ConvertToUnixSlashes(sgPath);
@@ -463,112 +498,127 @@ void cmGhsMultiTargetGenerator::WriteSources(
       GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath);
 
     std::string fullSourcePath((*si)->GetFullPath());
-    if ((*si)->GetExtension() == "int" || (*si)->GetExtension() == "bsp")
-      {
+    if ((*si)->GetExtension() == "int" || (*si)->GetExtension() == "bsp") {
       *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
-      }
-    else
-      {
-      //WORKAROUND: GHS MULTI needs the path to use backslashes without quotes
+    } else {
+      // WORKAROUND: GHS MULTI needs the path to use backslashes without quotes
       //  to open files in search as of version 6.1.6
       cmsys::SystemTools::ReplaceString(fullSourcePath, "/", "\\");
       *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
-      }
+    }
 
     if ("ld" != (*si)->GetExtension() && "int" != (*si)->GetExtension() &&
-        "bsp" != (*si)->GetExtension())
-      {
+        "bsp" != (*si)->GetExtension()) {
       this->WriteObjectLangOverride(this->FolderBuildStreams[sgPath], (*si));
+      if (objectNames.end() != objectNames.find(*si)) {
+        *this->FolderBuildStreams[sgPath]
+          << "    -o \"" << objectNames.find(*si)->second << "\"" << std::endl;
+      }
 
       this->WriteObjectDir(this->FolderBuildStreams[sgPath],
                            this->AbsBuildFilePath + sgPath);
-      }
     }
+  }
 }
 
 void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
-  cmGeneratedFileStream *fileStream, cmSourceFile *sourceFile)
+  cmGeneratedFileStream* fileStream, cmSourceFile* sourceFile)
 {
-  const char *rawLangProp = sourceFile->GetProperty("LANGUAGE");
-  if (NULL != rawLangProp)
-    {
+  const char* rawLangProp = sourceFile->GetProperty("LANGUAGE");
+  if (NULL != rawLangProp) {
     std::string sourceLangProp(rawLangProp);
     std::string extension(sourceFile->GetExtension());
-    if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension))
-      {
+    if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) {
       *fileStream << "    -dotciscxx" << std::endl;
-      }
     }
+  }
 }
 
 void cmGhsMultiTargetGenerator::WriteObjectDir(
-  cmGeneratedFileStream *fileStream, std::string const &dir)
+  cmGeneratedFileStream* fileStream, std::string const& dir)
 {
   std::string workingDir(dir);
   cmSystemTools::ConvertToUnixSlashes(workingDir);
-  if (!workingDir.empty())
-    {
+  if (!workingDir.empty()) {
     workingDir += "/";
-    }
+  }
   workingDir += "Objs";
   *fileStream << "    -object_dir=\"" << workingDir << "\"" << std::endl;
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetOutputDirectory(const std::string &config) const
+std::string cmGhsMultiTargetGenerator::GetOutputDirectory(
+  const std::string& config) const
 {
   std::string outputDir(AbsBuildFilePath);
 
-  const char *runtimeOutputProp =
+  const char* runtimeOutputProp =
     this->GeneratorTarget->GetProperty("RUNTIME_OUTPUT_DIRECTORY");
-  if (NULL != runtimeOutputProp)
-    {
+  if (NULL != runtimeOutputProp) {
     outputDir = runtimeOutputProp;
-    }
+  }
 
   std::string configCapped(cmSystemTools::UpperCase(config));
-  const char *runtimeOutputSProp =
-    this->GeneratorTarget
-      ->GetProperty("RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
-  if (NULL != runtimeOutputSProp)
-    {
+  const char* runtimeOutputSProp = this->GeneratorTarget->GetProperty(
+    "RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
+  if (NULL != runtimeOutputSProp) {
     outputDir = runtimeOutputSProp;
-    }
+  }
   cmSystemTools::ConvertToUnixSlashes(outputDir);
 
-  if (!outputDir.empty())
-    {
+  if (!outputDir.empty()) {
     outputDir += "/";
-    }
+  }
 
   return outputDir;
 }
 
-std::string
-cmGhsMultiTargetGenerator::GetOutputFilename(const std::string &config) const
+std::string cmGhsMultiTargetGenerator::GetOutputFilename(
+  const std::string& config) const
 {
   std::string outputFilename(this->GeneratorTarget->GetName());
 
-  const char *outputNameProp =
-      this->GeneratorTarget->GetProperty("OUTPUT_NAME");
-  if (NULL != outputNameProp)
-    {
+  const char* outputNameProp =
+    this->GeneratorTarget->GetProperty("OUTPUT_NAME");
+  if (NULL != outputNameProp) {
     outputFilename = outputNameProp;
-    }
+  }
 
   std::string configCapped(cmSystemTools::UpperCase(config));
-  const char *outputNameSProp =
+  const char* outputNameSProp =
     this->GeneratorTarget->GetProperty(configCapped + "_OUTPUT_NAME");
-  if (NULL != outputNameSProp)
-    {
+  if (NULL != outputNameSProp) {
     outputFilename = outputNameSProp;
-    }
+  }
 
   return outputFilename;
 }
 
-bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config,
-                                            const std::string &language)
+std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
+  cmLocalGhsMultiGenerator const* localGhsMultiGenerator,
+  cmGeneratorTarget* const generatorTarget, cmSourceFile* const sourceFile)
+{
+  std::string dir_max;
+  dir_max +=
+    localGhsMultiGenerator->GetMakefile()->GetCurrentBinaryDirectory();
+  dir_max += "/";
+  dir_max += generatorTarget->Target->GetName();
+  dir_max += "/";
+  std::vector<cmSourceGroup> sourceGroups(
+    localGhsMultiGenerator->GetMakefile()->GetSourceGroups());
+  char const* const sourceFullPath = sourceFile->GetFullPath().c_str();
+  cmSourceGroup* sourceGroup =
+    localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath,
+                                                           sourceGroups);
+  std::string const sgPath(sourceGroup->GetFullName());
+  dir_max += sgPath;
+  dir_max += "/Objs/libs/";
+  dir_max += generatorTarget->Target->GetName();
+  dir_max += "/";
+  return dir_max;
+}
+
+bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const& config,
+                                            const std::string& language)
 {
   bool output;
   std::vector<std::string> options;
@@ -579,38 +629,34 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config,
 }
 
 bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
-    const cmGeneratorTarget *target)
+  const cmGeneratorTarget* target)
 {
   bool output = false;
-  std::vector<cmSourceFile *> sources;
+  std::vector<cmSourceFile*> sources;
   std::string config =
-      target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
+    target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
   target->GetSourceFiles(sources, config);
-  for (std::vector<cmSourceFile *>::const_iterator sources_i = sources.begin();
-       sources.end() != sources_i; ++sources_i)
-    {
-    if ("int" == (*sources_i)->GetExtension())
-      {
+  for (std::vector<cmSourceFile*>::const_iterator sources_i = sources.begin();
+       sources.end() != sources_i; ++sources_i) {
+    if ("int" == (*sources_i)->GetExtension()) {
       output = true;
-      }
     }
+  }
   return output;
 }
 
 bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload(
-  std::string const &config, const std::string &language)
+  std::string const& config, const std::string& language)
 {
   std::vector<std::string> options;
   bool output = false;
   this->GeneratorTarget->GetCompileOptions(options, config, language);
   for (std::vector<std::string>::const_iterator options_i = options.begin();
-       options_i != options.end(); ++options_i)
-    {
+       options_i != options.end(); ++options_i) {
     std::string option = *options_i;
-    if (this->DDOption == option)
-      {
+    if (this->DDOption == option) {
       output = true;
-      }
     }
+  }
   return output;
 }
diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h
index 327fdef..92a1109 100644
--- a/Source/cmGhsMultiTargetGenerator.h
+++ b/Source/cmGhsMultiTargetGenerator.h
@@ -12,10 +12,10 @@
 #ifndef cmGhsMultiTargetGenerator_h
 #define cmGhsMultiTargetGenerator_h
 
-#include "cmStandardIncludes.h"
-#include "cmTarget.h"
 #include "cmGhsMultiGpj.h"
 
+#include "cmTarget.h"
+
 class cmGeneratedFileStream;
 class cmGlobalGhsMultiGenerator;
 class cmLocalGhsMultiGenerator;
@@ -34,81 +34,91 @@ public:
   virtual void Generate();
 
   bool IncludeThisTarget();
-  std::vector<cmSourceFile *> GetSources() const;
+  std::vector<cmSourceFile*> GetSources() const;
   GhsMultiGpj::Types GetGpjTag() const;
   static GhsMultiGpj::Types GetGpjTag(const cmGeneratorTarget* target);
-  const char *GetAbsBuildFilePath() const
+  const char* GetAbsBuildFilePath() const
   {
     return this->AbsBuildFilePath.c_str();
   }
-  const char *GetRelBuildFileName() const
+  const char* GetRelBuildFileName() const
   {
     return this->RelBuildFileName.c_str();
   }
-  const char *GetAbsBuildFileName() const
+  const char* GetAbsBuildFileName() const
   {
     return this->AbsBuildFileName.c_str();
   }
-  const char *GetAbsOutputFileName() const
+  const char* GetAbsOutputFileName() const
   {
     return this->AbsOutputFileName.c_str();
   }
 
-  static std::string GetRelBuildFilePath(const cmGeneratorTarget *target);
-  static std::string GetAbsPathToRoot(const cmGeneratorTarget *target);
-  static std::string GetAbsBuildFilePath(const cmGeneratorTarget *target);
-  static std::string GetRelBuildFileName(const cmGeneratorTarget *target);
-  static std::string GetBuildFileName(const cmGeneratorTarget *target);
-  static std::string AddSlashIfNeededToPath(std::string const &input);
+  static std::string GetRelBuildFilePath(const cmGeneratorTarget* target);
+  static std::string GetAbsPathToRoot(const cmGeneratorTarget* target);
+  static std::string GetAbsBuildFilePath(const cmGeneratorTarget* target);
+  static std::string GetRelBuildFileName(const cmGeneratorTarget* target);
+  static std::string GetBuildFileName(const cmGeneratorTarget* target);
+  static std::string AddSlashIfNeededToPath(std::string const& input);
 
 private:
-  cmGlobalGhsMultiGenerator *GetGlobalGenerator() const;
-  cmGeneratedFileStream *GetFolderBuildStreams()
+  cmGlobalGhsMultiGenerator* GetGlobalGenerator() const;
+  cmGeneratedFileStream* GetFolderBuildStreams()
   {
     return this->FolderBuildStreams[""];
   };
   bool IsTargetGroup() const { return this->TargetGroup; }
 
-  void WriteTypeSpecifics(const std::string &config, bool notKernel);
-  void WriteCompilerFlags(const std::string &config,
-    const std::string &language);
-  void WriteCompilerDefinitions(const std::string &config,
-                                const std::string &language);
+  void WriteTypeSpecifics(const std::string& config, bool notKernel);
+  void WriteCompilerFlags(const std::string& config,
+                          const std::string& language);
+  void WriteCompilerDefinitions(const std::string& config,
+                                const std::string& language);
 
-  void SetCompilerFlags(std::string const &config, const std::string &language,
+  void SetCompilerFlags(std::string const& config, const std::string& language,
                         bool const notKernel);
-  std::string GetDefines(const std::string &langugae,
-                         std::string const &config);
+  std::string GetDefines(const std::string& langugae,
+                         std::string const& config);
 
-  void WriteIncludes(const std::string &config, const std::string &language);
-  void WriteTargetLinkLibraries();
+  void WriteIncludes(const std::string& config, const std::string& language);
+  void WriteTargetLinkLibraries(std::string const& config,
+                                std::string const& language);
   void WriteCustomCommands();
-  void
-  WriteCustomCommandsHelper(std::vector<cmCustomCommand> const &commandsSet,
-                            cmTarget::CustomCommandType commandType);
-  void WriteSources(std::vector<cmSourceFile *> const &objectSources);
-  static void WriteObjectLangOverride(cmGeneratedFileStream *fileStream,
-                                      cmSourceFile *sourceFile);
-  static void WriteObjectDir(cmGeneratedFileStream *fileStream,
-                             std::string const &dir);
-  std::string GetOutputDirectory(const std::string &config) const;
-  std::string GetOutputFilename(const std::string &config) const;
-
-  bool IsNotKernel(std::string const &config, const std::string &language);
+  void WriteCustomCommandsHelper(
+    std::vector<cmCustomCommand> const& commandsSet,
+    cmTarget::CustomCommandType commandType);
+  void WriteSources(
+    std::vector<cmSourceFile*> const& objectSources,
+    std::map<const cmSourceFile*, std::string> const& objectNames);
+  static std::map<const cmSourceFile*, std::string> GetObjectNames(
+    std::vector<cmSourceFile*>* objectSources,
+    cmLocalGhsMultiGenerator* localGhsMultiGenerator,
+    cmGeneratorTarget* generatorTarget);
+  static void WriteObjectLangOverride(cmGeneratedFileStream* fileStream,
+                                      cmSourceFile* sourceFile);
+  static void WriteObjectDir(cmGeneratedFileStream* fileStream,
+                             std::string const& dir);
+  std::string GetOutputDirectory(const std::string& config) const;
+  std::string GetOutputFilename(const std::string& config) const;
+  static std::string ComputeLongestObjectDirectory(
+    cmLocalGhsMultiGenerator const* localGhsMultiGenerator,
+    cmGeneratorTarget* generatorTarget, cmSourceFile* const sourceFile);
+
+  bool IsNotKernel(std::string const& config, const std::string& language);
   static bool DetermineIfTargetGroup(const cmGeneratorTarget* target);
-  bool DetermineIfDynamicDownload(std::string const &config,
-                                  const std::string &language);
+  bool DetermineIfDynamicDownload(std::string const& config,
+                                  const std::string& language);
 
   cmGeneratorTarget* GeneratorTarget;
-  cmLocalGhsMultiGenerator *LocalGenerator;
-  cmMakefile *Makefile;
+  cmLocalGhsMultiGenerator* LocalGenerator;
+  cmMakefile* Makefile;
   std::string AbsBuildFilePath;
   std::string RelBuildFilePath;
   std::string AbsBuildFileName;
   std::string RelBuildFileName;
   std::string RelOutputFileName;
   std::string AbsOutputFileName;
-  std::map<std::string, cmGeneratedFileStream *> FolderBuildStreams;
+  std::map<std::string, cmGeneratedFileStream*> FolderBuildStreams;
   bool TargetGroup;
   bool DynamicDownload;
   static std::string const DDOption;
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index 40e8d29..0f4de73 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalBorlandMakefileGenerator.h"
+
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmake.h"
@@ -29,11 +30,8 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator(cmake* cm)
   this->UnixCD = false;
 }
 
-
-void cmGlobalBorlandMakefileGenerator
-::EnableLanguage(std::vector<std::string>const& l,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalBorlandMakefileGenerator::EnableLanguage(
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   std::string outdir = this->CMakeInstance->GetHomeOutputDirectory();
   mf->AddDefinition("BORLAND", "1");
@@ -43,21 +41,19 @@ void cmGlobalBorlandMakefileGenerator
 }
 
 ///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
-    cmMakefile *mf)
+cmLocalGenerator* cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
+  cmMakefile* mf)
 {
   cmLocalUnixMakefileGenerator3* lg =
-      new cmLocalUnixMakefileGenerator3(this, mf);
+    new cmLocalUnixMakefileGenerator3(this, mf);
   lg->SetMakefileVariableSize(32);
   lg->SetMakeCommandEscapeTargetTwice(true);
   lg->SetBorlandMakeCurlyHack(true);
   return lg;
 }
 
-
-//----------------------------------------------------------------------------
-void cmGlobalBorlandMakefileGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalBorlandMakefileGenerator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalBorlandMakefileGenerator::GetActualName();
   entry.Brief = "Generates Borland makefiles.";
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index b59c86d..4e10f10 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -23,27 +23,31 @@ class cmGlobalBorlandMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalBorlandMakefileGenerator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalBorlandMakefileGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<
+      cmGlobalBorlandMakefileGenerator>();
+  }
 
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalBorlandMakefileGenerator::GetActualName();}
-  static std::string GetActualName() {return "Borland Makefiles";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalBorlandMakefileGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "Borland Makefiles"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 
   virtual bool AllowNotParallel() const { return false; }
   virtual bool AllowDeleteOnError() const { return false; }
diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx
index dc8e5a7..900b08e 100644
--- a/Source/cmGlobalCommonGenerator.cxx
+++ b/Source/cmGlobalCommonGenerator.cxx
@@ -11,8 +11,8 @@
 ============================================================================*/
 #include "cmGlobalCommonGenerator.h"
 
-cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm):
-  cmGlobalGenerator(cm)
+cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm)
+  : cmGlobalGenerator(cm)
 {
 }
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 848028f..a1764a3 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -12,36 +12,37 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include "windows.h" // this must be first to define GetCurrentDirectory
 #if defined(_MSC_VER) && _MSC_VER >= 1800
-# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
 #endif
 #endif
 
 #include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
+
+#include "cmAlgorithms.h"
+#include "cmCPackPropertiesGenerator.h"
+#include "cmComputeTargetDepends.h"
+#include "cmExportBuildFileGenerator.h"
 #include "cmExternalMakefileProjectGenerator.h"
-#include "cmake.h"
-#include "cmState.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
+#include "cmInstallGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmQtAutoGeneratorInitializer.h"
 #include "cmSourceFile.h"
-#include "cmVersion.h"
+#include "cmState.h"
 #include "cmTargetExport.h"
-#include "cmComputeTargetDepends.h"
-#include "cmGeneratedFileStream.h"
-#include "cmGeneratorTarget.h"
-#include "cmGeneratorExpression.h"
-#include "cmExportBuildFileGenerator.h"
-#include "cmCPackPropertiesGenerator.h"
-#include "cmAlgorithms.h"
-#include "cmInstallGenerator.h"
+#include "cmVersion.h"
+#include "cmake.h"
 
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <cmsys/MD5.h>
-# include "cm_jsoncpp_value.h"
-# include "cm_jsoncpp_writer.h"
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
+#include <cmsys/MD5.h>
 #endif
 
 #include <stdlib.h> // required for atof
@@ -52,11 +53,10 @@ bool cmTarget::StrictTargetComparison::operator()(cmTarget const* t1,
                                                   cmTarget const* t2) const
 {
   int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
-  if (nameResult == 0)
-    {
+  if (nameResult == 0) {
     return strcmp(t1->GetMakefile()->GetCurrentBinaryDirectory(),
                   t2->GetMakefile()->GetCurrentBinaryDirectory()) < 0;
-    }
+  }
   return nameResult < 0;
 }
 
@@ -104,18 +104,19 @@ cmGlobalGenerator::~cmGlobalGenerator()
 bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
                                              cmMakefile* mf)
 {
-  if(p.empty())
-    {
+  if (p.empty()) {
     return true;
-    }
+  }
 
   std::ostringstream e;
+  /* clang-format off */
   e <<
     "Generator\n"
     "  " << this->GetName() << "\n"
     "does not support platform specification, but platform\n"
     "  " << p << "\n"
     "was specified.";
+  /* clang-format on */
   mf->IssueMessage(cmake::FATAL_ERROR, e.str());
   return false;
 }
@@ -123,115 +124,95 @@ bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
 bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
                                             cmMakefile* mf)
 {
-  if(ts.empty())
-    {
+  if (ts.empty()) {
     return true;
-    }
+  }
   std::ostringstream e;
+  /* clang-format off */
   e <<
     "Generator\n"
     "  " << this->GetName() << "\n"
     "does not support toolset specification, but toolset\n"
     "  " << ts << "\n"
     "was specified.";
+  /* clang-format on */
   mf->IssueMessage(cmake::FATAL_ERROR, e.str());
   return false;
 }
 
 std::string cmGlobalGenerator::SelectMakeProgram(
-                                          const std::string& inMakeProgram,
-                                          const std::string& makeDefault) const
+  const std::string& inMakeProgram, const std::string& makeDefault) const
 {
   std::string makeProgram = inMakeProgram;
-  if(cmSystemTools::IsOff(makeProgram.c_str()))
-    {
+  if (cmSystemTools::IsOff(makeProgram.c_str())) {
     const char* makeProgramCSTR =
       this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
-    if(cmSystemTools::IsOff(makeProgramCSTR))
-      {
+    if (cmSystemTools::IsOff(makeProgramCSTR)) {
       makeProgram = makeDefault;
-      }
-    else
-      {
+    } else {
       makeProgram = makeProgramCSTR;
-      }
-    if(cmSystemTools::IsOff(makeProgram.c_str()) &&
-       !makeProgram.empty())
-      {
+    }
+    if (cmSystemTools::IsOff(makeProgram.c_str()) && !makeProgram.empty()) {
       makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND";
-      }
     }
+  }
   return makeProgram;
 }
 
-void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
-                                                cmMakefile *mf,
+void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
+                                                cmMakefile* mf,
                                                 bool optional) const
 {
   std::string langComp = "CMAKE_";
   langComp += lang;
   langComp += "_COMPILER";
 
-  if(!mf->GetDefinition(langComp))
-    {
-    if(!optional)
-      {
-      cmSystemTools::Error(langComp.c_str(),
-                           " not set, after EnableLanguage");
-      }
-    return;
+  if (!mf->GetDefinition(langComp)) {
+    if (!optional) {
+      cmSystemTools::Error(langComp.c_str(), " not set, after EnableLanguage");
     }
+    return;
+  }
   const char* name = mf->GetRequiredDefinition(langComp);
   std::string path;
-  if(!cmSystemTools::FileIsFullPath(name))
-    {
+  if (!cmSystemTools::FileIsFullPath(name)) {
     path = cmSystemTools::FindProgram(name);
-    }
-  else
-    {
+  } else {
     path = name;
-    }
-  if((path.empty() || !cmSystemTools::FileExists(path.c_str()))
-      && (optional==false))
-    {
+  }
+  if ((path.empty() || !cmSystemTools::FileExists(path.c_str())) &&
+      (optional == false)) {
     return;
-    }
-  const char* cname = this->GetCMakeInstance()->
-    GetState()->GetInitializedCacheValue(langComp);
+  }
+  const char* cname =
+    this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp);
   std::string changeVars;
-  if(cname && !optional)
-    {
+  if (cname && !optional) {
     std::string cnameString;
-    if(!cmSystemTools::FileIsFullPath(cname))
-      {
+    if (!cmSystemTools::FileIsFullPath(cname)) {
       cnameString = cmSystemTools::FindProgram(cname);
-      }
-    else
-      {
+    } else {
       cnameString = cname;
-      }
+    }
     std::string pathString = path;
     // get rid of potentially multiple slashes:
     cmSystemTools::ConvertToUnixSlashes(cnameString);
     cmSystemTools::ConvertToUnixSlashes(pathString);
-    if (cnameString != pathString)
-      {
+    if (cnameString != pathString) {
       const char* cvars =
         this->GetCMakeInstance()->GetState()->GetGlobalProperty(
           "__CMAKE_DELETE_CACHE_CHANGE_VARS_");
-      if(cvars)
-        {
+      if (cvars) {
         changeVars += cvars;
         changeVars += ";";
-        }
+      }
       changeVars += langComp;
       changeVars += ";";
       changeVars += cname;
       this->GetCMakeInstance()->GetState()->SetGlobalProperty(
-        "__CMAKE_DELETE_CACHE_CHANGE_VARS_",
-        changeVars.c_str());
-      }
+        "__CMAKE_DELETE_CACHE_CHANGE_VARS_", changeVars.c_str());
     }
+  }
 }
 
 void cmGlobalGenerator::AddBuildExportSet(cmExportBuildFileGenerator* gen)
@@ -239,78 +220,70 @@ void cmGlobalGenerator::AddBuildExportSet(cmExportBuildFileGenerator* gen)
   this->BuildExportSets[gen->GetMainExportFileName()] = gen;
 }
 
-void
-cmGlobalGenerator::AddBuildExportExportSet(cmExportBuildFileGenerator* gen)
+void cmGlobalGenerator::AddBuildExportExportSet(
+  cmExportBuildFileGenerator* gen)
 {
   this->BuildExportSets[gen->GetMainExportFileName()] = gen;
   this->BuildExportExportSets[gen->GetMainExportFileName()] = gen;
 }
 
-bool cmGlobalGenerator::GenerateImportFile(const std::string &file)
+bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
 {
-  std::map<std::string, cmExportBuildFileGenerator*>::iterator it
-                                          = this->BuildExportSets.find(file);
-  if (it != this->BuildExportSets.end())
-    {
+  std::map<std::string, cmExportBuildFileGenerator*>::iterator it =
+    this->BuildExportSets.find(file);
+  if (it != this->BuildExportSets.end()) {
     bool result = it->second->GenerateImportFile();
 
-    if (!this->ConfigureDoneCMP0026AndCMP0024)
-      {
+    if (!this->ConfigureDoneCMP0026AndCMP0024) {
       for (std::vector<cmMakefile*>::const_iterator mit =
-           this->Makefiles.begin(); mit != this->Makefiles.end(); ++mit)
-        {
+             this->Makefiles.begin();
+           mit != this->Makefiles.end(); ++mit) {
         (*mit)->RemoveExportBuildFileGeneratorCMP0024(it->second);
-        }
       }
+    }
 
     delete it->second;
     it->second = 0;
     this->BuildExportSets.erase(it);
     return result;
-    }
+  }
   return false;
 }
 
 void cmGlobalGenerator::ForceLinkerLanguages()
 {
-
 }
 
-bool
-cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const
+bool cmGlobalGenerator::IsExportedTargetsFile(
+  const std::string& filename) const
 {
-  const std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it
-                                      = this->BuildExportSets.find(filename);
-  if (it == this->BuildExportSets.end())
-    {
+  const std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it =
+    this->BuildExportSets.find(filename);
+  if (it == this->BuildExportSets.end()) {
     return false;
-    }
-  return this->BuildExportExportSets.find(filename)
-                                        == this->BuildExportExportSets.end();
+  }
+  return this->BuildExportExportSets.find(filename) ==
+    this->BuildExportExportSets.end();
 }
 
 // Find the make program for the generator, required for try compiles
 void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
 {
-  if(this->FindMakeProgramFile.empty())
-    {
+  if (this->FindMakeProgramFile.empty()) {
     cmSystemTools::Error(
       "Generator implementation error, "
       "all generators must specify this->FindMakeProgramFile");
-    }
-  if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
-     || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
-    {
+  }
+  if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
+      cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
     std::string setMakeProgram =
       mf->GetModulesFile(this->FindMakeProgramFile.c_str());
-    if(!setMakeProgram.empty())
-      {
+    if (!setMakeProgram.empty()) {
       mf->ReadListFile(setMakeProgram.c_str());
-      }
     }
-  if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
-     || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
-    {
+  }
+  if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
+      cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
     std::ostringstream err;
     err << "CMake was unable to find a build program corresponding to \""
         << this->GetName() << "\".  CMAKE_MAKE_PROGRAM is not set.  You "
@@ -318,28 +291,24 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
     cmSystemTools::Error(err.str().c_str());
     cmSystemTools::SetFatalErrorOccured();
     return;
-    }
+  }
   std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   // if there are spaces in the make program use short path
   // but do not short path the actual program name, as
   // this can cause trouble with VSExpress
-  if(makeProgram.find(' ') != makeProgram.npos)
-    {
+  if (makeProgram.find(' ') != makeProgram.npos) {
     std::string dir;
     std::string file;
-    cmSystemTools::SplitProgramPath(makeProgram,
-                                    dir, file);
+    cmSystemTools::SplitProgramPath(makeProgram, dir, file);
     std::string saveFile = file;
     cmSystemTools::GetShortPath(makeProgram, makeProgram);
-    cmSystemTools::SplitProgramPath(makeProgram,
-                                    dir, file);
+    cmSystemTools::SplitProgramPath(makeProgram, dir, file);
     makeProgram = dir;
     makeProgram += "/";
     makeProgram += saveFile;
     mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
-                           "make program",
-                           cmState::FILEPATH);
-    }
+                           "make program", cmState::FILEPATH);
+  }
 }
 
 // enable the given language
@@ -387,43 +356,48 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
 //
 //
 
-void
-cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
-                                  cmMakefile *mf, bool optional)
+void cmGlobalGenerator::EnableLanguage(
+  std::vector<std::string> const& languages, cmMakefile* mf, bool optional)
 {
-  if(languages.empty())
-    {
+  if (languages.empty()) {
     cmSystemTools::Error("EnableLanguage must have a lang specified!");
     cmSystemTools::SetFatalErrorOccured();
     return;
+  }
+
+  std::set<std::string> cur_languages(languages.begin(), languages.end());
+  for (std::set<std::string>::iterator li = cur_languages.begin();
+       li != cur_languages.end(); ++li) {
+    if (!this->LanguagesInProgress.insert(*li).second) {
+      std::ostringstream e;
+      e << "Language '" << *li << "' is currently being enabled.  "
+                                  "Recursive call not allowed.";
+      mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+      cmSystemTools::SetFatalErrorOccured();
+      return;
     }
+  }
 
-  if(this->TryCompileOuterMakefile)
-    {
+  if (this->TryCompileOuterMakefile) {
     // In a try-compile we can only enable languages provided by caller.
-    for(std::vector<std::string>::const_iterator li = languages.begin();
-        li != languages.end(); ++li)
-      {
-      if(*li == "NONE")
-        {
+    for (std::vector<std::string>::const_iterator li = languages.begin();
+         li != languages.end(); ++li) {
+      if (*li == "NONE") {
         this->SetLanguageEnabled("NONE", mf);
-        }
-      else
-        {
+      } else {
         const char* lang = li->c_str();
-        if(this->LanguagesReady.find(lang) == this->LanguagesReady.end())
-          {
+        if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) {
           std::ostringstream e;
-          e << "The test project needs language "
-            << lang << " which is not enabled.";
-          this->TryCompileOuterMakefile
-            ->IssueMessage(cmake::FATAL_ERROR, e.str());
+          e << "The test project needs language " << lang
+            << " which is not enabled.";
+          this->TryCompileOuterMakefile->IssueMessage(cmake::FATAL_ERROR,
+                                                      e.str());
           cmSystemTools::SetFatalErrorOccured();
           return;
-          }
         }
       }
     }
+  }
 
   bool fatalError = false;
 
@@ -434,15 +408,14 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
   // If the configuration files path has been set,
   // then we are in a try compile and need to copy the enable language
   // files from the parent cmake bin dir, into the try compile bin dir
-  if(!this->ConfiguredFilesPath.empty())
-    {
+  if (!this->ConfiguredFilesPath.empty()) {
     rootBin = this->ConfiguredFilesPath;
-    }
+  }
   rootBin += "/";
   rootBin += cmVersion::GetCMakeVersion();
 
   // set the dir for parent files so they can be used by modules
-  mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR",rootBin.c_str());
+  mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR", rootBin.c_str());
 
   // find and make sure CMAKE_MAKE_PROGRAM is defined
   this->FindMakeProgram(mf);
@@ -450,18 +423,15 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
   // try and load the CMakeSystem.cmake if it is there
   std::string fpath = rootBin;
   bool const readCMakeSystem = !mf->GetDefinition("CMAKE_SYSTEM_LOADED");
-  if(readCMakeSystem)
-    {
+  if (readCMakeSystem) {
     fpath += "/CMakeSystem.cmake";
-    if(cmSystemTools::FileExists(fpath.c_str()))
-      {
+    if (cmSystemTools::FileExists(fpath.c_str())) {
       mf->ReadListFile(fpath.c_str());
-      }
     }
+  }
   //  Load the CMakeDetermineSystem.cmake file and find out
   // what platform we are running on
-  if (!mf->GetDefinition("CMAKE_SYSTEM"))
-    {
+  if (!mf->GetDefinition("CMAKE_SYSTEM")) {
 #if defined(_WIN32) && !defined(__CYGWIN__)
     /* Windows version number data.  */
     OSVERSIONINFOEXW osviex;
@@ -469,12 +439,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
     osviex.dwOSVersionInfoSize = sizeof(osviex);
 
 #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-# pragma warning (push)
-# pragma warning (disable:4996)
+#pragma warning(push)
+#pragma warning(disable : 4996)
 #endif
     GetVersionExW((OSVERSIONINFOW*)&osviex);
 #ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-# pragma warning (pop)
+#pragma warning(pop)
 #endif
     std::ostringstream windowsVersionString;
     windowsVersionString << osviex.dwMajorVersion << "."
@@ -492,45 +462,39 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
     fpath = rootBin;
     fpath += "/CMakeSystem.cmake";
     mf->ReadListFile(fpath.c_str());
-    }
+  }
 
-  if(readCMakeSystem)
-    {
+  if (readCMakeSystem) {
     // Tell the generator about the target system.
     std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
-    if(!this->SetSystemName(system, mf))
-      {
+    if (!this->SetSystemName(system, mf)) {
       cmSystemTools::SetFatalErrorOccured();
       return;
-      }
+    }
 
     // Tell the generator about the platform, if any.
     std::string platform = mf->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM");
-    if(!this->SetGeneratorPlatform(platform, mf))
-      {
+    if (!this->SetGeneratorPlatform(platform, mf)) {
       cmSystemTools::SetFatalErrorOccured();
       return;
-      }
+    }
 
     // Tell the generator about the toolset, if any.
     std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET");
-    if(!this->SetGeneratorToolset(toolset, mf))
-      {
+    if (!this->SetGeneratorToolset(toolset, mf)) {
       cmSystemTools::SetFatalErrorOccured();
       return;
-      }
     }
+  }
 
   // **** Load the system specific initialization if not yet loaded
-  if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED"))
-    {
+  if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED")) {
     fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake");
-    if(!mf->ReadListFile(fpath.c_str()))
-      {
+    if (!mf->ReadListFile(fpath.c_str())) {
       cmSystemTools::Error("Could not find cmake module file: "
                            "CMakeSystemSpecificInitialize.cmake");
-      }
     }
+  }
 
   std::map<std::string, bool> needTestLanguage;
   std::map<std::string, bool> needSetLanguageEnabledMaps;
@@ -538,21 +502,18 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
   // load the CMakeDetermine(LANG)Compiler.cmake file to find
   // the compiler
 
-  for(std::vector<std::string>::const_iterator l = languages.begin();
-      l != languages.end(); ++l)
-    {
+  for (std::vector<std::string>::const_iterator l = languages.begin();
+       l != languages.end(); ++l) {
     const char* lang = l->c_str();
     needSetLanguageEnabledMaps[lang] = false;
-    if(*l == "NONE")
-      {
+    if (*l == "NONE") {
       this->SetLanguageEnabled("NONE", mf);
       continue;
-      }
+    }
     std::string loadedLang = "CMAKE_";
-    loadedLang +=  lang;
+    loadedLang += lang;
     loadedLang += "_COMPILER_LOADED";
-    if(!mf->GetDefinition(loadedLang))
-      {
+    if (!mf->GetDefinition(loadedLang)) {
       fpath = rootBin;
       fpath += "/CMake";
       fpath += lang;
@@ -561,31 +522,27 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
       // If the existing build tree was already configured with this
       // version of CMake then try to load the configured file first
       // to avoid duplicate compiler tests.
-      if(cmSystemTools::FileExists(fpath.c_str()))
-        {
-        if(!mf->ReadListFile(fpath.c_str()))
-          {
+      if (cmSystemTools::FileExists(fpath.c_str())) {
+        if (!mf->ReadListFile(fpath.c_str())) {
           cmSystemTools::Error("Could not find cmake module file: ",
                                fpath.c_str());
-          }
+        }
         // if this file was found then the language was already determined
         // to be working
         needTestLanguage[lang] = false;
         this->SetLanguageEnabledFlag(lang, mf);
         needSetLanguageEnabledMaps[lang] = true;
         // this can only be called after loading CMake(LANG)Compiler.cmake
-        }
       }
+    }
 
-    if(!this->GetLanguageEnabled(lang) )
-      {
-      if (this->CMakeInstance->GetIsInTryCompile())
-        {
+    if (!this->GetLanguageEnabled(lang)) {
+      if (this->CMakeInstance->GetIsInTryCompile()) {
         cmSystemTools::Error("This should not have happened. "
                              "If you see this message, you are probably "
                              "using a broken CMakeLists.txt file or a "
                              "problematic release of CMake");
-        }
+      }
       // if the CMake(LANG)Compiler.cmake file was not found then
       // load CMakeDetermine(LANG)Compiler.cmake
       std::string determineCompiler = "CMakeDetermine";
@@ -593,20 +550,17 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
       determineCompiler += "Compiler.cmake";
       std::string determineFile =
         mf->GetModulesFile(determineCompiler.c_str());
-      if(!mf->ReadListFile(determineFile.c_str()))
-        {
+      if (!mf->ReadListFile(determineFile.c_str())) {
         cmSystemTools::Error("Could not find cmake module file: ",
                              determineCompiler.c_str());
-        }
-      if (cmSystemTools::GetFatalErrorOccured())
-        {
+      }
+      if (cmSystemTools::GetFatalErrorOccured()) {
         return;
-        }
+      }
       needTestLanguage[lang] = true;
       // Some generators like visual studio should not use the env variables
       // So the global generator can specify that in this variable
-      if(!mf->GetDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV"))
-        {
+      if (!mf->GetDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV")) {
         // put ${CMake_(LANG)_COMPILER_ENV_VAR}=${CMAKE_(LANG)_COMPILER
         // into the environment, in case user scripts want to run
         // configure, or sub cmakes
@@ -617,13 +571,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
         compilerEnv += lang;
         compilerEnv += "_COMPILER_ENV_VAR";
         std::string envVar = mf->GetRequiredDefinition(compilerEnv);
-        std::string envVarValue =
-          mf->GetRequiredDefinition(compilerName);
+        std::string envVarValue = mf->GetRequiredDefinition(compilerName);
         std::string env = envVar;
         env += "=";
         env += envVarValue;
         cmSystemTools::PutEnv(env);
-        }
+      }
 
       // if determineLanguage was called then load the file it
       // configures CMake(LANG)Compiler.cmake
@@ -631,11 +584,10 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
       fpath += "/CMake";
       fpath += lang;
       fpath += "Compiler.cmake";
-      if(!mf->ReadListFile(fpath.c_str()))
-        {
+      if (!mf->ReadListFile(fpath.c_str())) {
         cmSystemTools::Error("Could not find cmake module file: ",
                              fpath.c_str());
-        }
+      }
       this->SetLanguageEnabledFlag(lang, mf);
       needSetLanguageEnabledMaps[lang] = true;
       // this can only be called after loading CMake(LANG)Compiler.cmake
@@ -643,30 +595,26 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
       // not know if it is a working compiler yet so set the test language
       // flag
       needTestLanguage[lang] = true;
-      } // end if(!this->GetLanguageEnabled(lang) )
-    }  // end loop over languages
+    } // end if(!this->GetLanguageEnabled(lang) )
+  }   // end loop over languages
 
   // **** Load the system specific information if not yet loaded
-  if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED"))
-    {
+  if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED")) {
     fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake");
-    if(!mf->ReadListFile(fpath.c_str()))
-      {
+    if (!mf->ReadListFile(fpath.c_str())) {
       cmSystemTools::Error("Could not find cmake module file: "
                            "CMakeSystemSpecificInformation.cmake");
-      }
     }
+  }
   // loop over languages again loading CMake(LANG)Information.cmake
   //
-  for(std::vector<std::string>::const_iterator l = languages.begin();
-      l != languages.end(); ++l)
-    {
+  for (std::vector<std::string>::const_iterator l = languages.begin();
+       l != languages.end(); ++l) {
     const char* lang = l->c_str();
-    if(*l == "NONE")
-      {
+    if (*l == "NONE") {
       this->SetLanguageEnabled("NONE", mf);
       continue;
-      }
+    }
 
     // Check that the compiler was found.
     std::string compilerName = "CMAKE_";
@@ -677,39 +625,36 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
     compilerEnv += "_COMPILER_ENV_VAR";
     std::ostringstream noCompiler;
     const char* compilerFile = mf->GetDefinition(compilerName);
-    if(!compilerFile || !*compilerFile ||
-       cmSystemTools::IsNOTFOUND(compilerFile))
-      {
+    if (!compilerFile || !*compilerFile ||
+        cmSystemTools::IsNOTFOUND(compilerFile)) {
+      /* clang-format off */
       noCompiler <<
         "No " << compilerName << " could be found.\n"
         ;
-      }
-    else if(strcmp(lang, "RC") != 0 &&
-            strcmp(lang, "ASM_MASM") != 0)
-      {
-      if(!cmSystemTools::FileIsFullPath(compilerFile))
-        {
+      /* clang-format on */
+    } else if (strcmp(lang, "RC") != 0 && strcmp(lang, "ASM_MASM") != 0) {
+      if (!cmSystemTools::FileIsFullPath(compilerFile)) {
+        /* clang-format off */
         noCompiler <<
           "The " << compilerName << ":\n"
           "  " << compilerFile << "\n"
           "is not a full path and was not found in the PATH.\n"
           ;
-        }
-      else if(!cmSystemTools::FileExists(compilerFile))
-        {
+        /* clang-format on */
+      } else if (!cmSystemTools::FileExists(compilerFile)) {
+        /* clang-format off */
         noCompiler <<
           "The " << compilerName << ":\n"
           "  " << compilerFile << "\n"
           "is not a full path to an existing compiler tool.\n"
           ;
-        }
+        /* clang-format on */
       }
-    if(!noCompiler.str().empty())
-      {
+    }
+    if (!noCompiler.str().empty()) {
       // Skip testing this language since the compiler is not found.
       needTestLanguage[lang] = false;
-      if(!optional)
-        {
+      if (!optional) {
         // The compiler was not found and it is not optional.  Remove
         // CMake(LANG)Compiler.cmake so we try again next time CMake runs.
         std::string compilerLangFile = rootBin;
@@ -717,40 +662,34 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
         compilerLangFile += lang;
         compilerLangFile += "Compiler.cmake";
         cmSystemTools::RemoveFile(compilerLangFile);
-        if(!this->CMakeInstance->GetIsInTryCompile())
-          {
+        if (!this->CMakeInstance->GetIsInTryCompile()) {
           this->PrintCompilerAdvice(noCompiler, lang,
                                     mf->GetDefinition(compilerEnv));
           mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str());
           fatalError = true;
-          }
         }
       }
+    }
 
     std::string langLoadedVar = "CMAKE_";
     langLoadedVar += lang;
     langLoadedVar += "_INFORMATION_LOADED";
-    if (!mf->GetDefinition(langLoadedVar))
-      {
+    if (!mf->GetDefinition(langLoadedVar)) {
       fpath = "CMake";
-      fpath +=  lang;
+      fpath += lang;
       fpath += "Information.cmake";
       std::string informationFile = mf->GetModulesFile(fpath.c_str());
-      if (informationFile.empty())
-        {
+      if (informationFile.empty()) {
         cmSystemTools::Error("Could not find cmake module file: ",
                              fpath.c_str());
-        }
-      else if(!mf->ReadListFile(informationFile.c_str()))
-        {
+      } else if (!mf->ReadListFile(informationFile.c_str())) {
         cmSystemTools::Error("Could not process cmake module file: ",
                              informationFile.c_str());
-        }
       }
-    if (needSetLanguageEnabledMaps[lang])
-      {
+    }
+    if (needSetLanguageEnabledMaps[lang]) {
       this->SetLanguageEnabledMaps(lang, mf);
-      }
+    }
     this->LanguagesReady.insert(lang);
 
     // Test the compiler for the language just setup
@@ -758,121 +697,107 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
     // At this point we should have enough info for a try compile
     // which is used in the backward stuff
     // If the language is untested then test it now with a try compile.
-    if(needTestLanguage[lang])
-      {
-      if (!this->CMakeInstance->GetIsInTryCompile())
-        {
+    if (needTestLanguage[lang]) {
+      if (!this->CMakeInstance->GetIsInTryCompile()) {
         std::string testLang = "CMakeTest";
         testLang += lang;
         testLang += "Compiler.cmake";
         std::string ifpath = mf->GetModulesFile(testLang.c_str());
-        if(!mf->ReadListFile(ifpath.c_str()))
-          {
+        if (!mf->ReadListFile(ifpath.c_str())) {
           cmSystemTools::Error("Could not find cmake module file: ",
                                testLang.c_str());
-          }
+        }
         std::string compilerWorks = "CMAKE_";
         compilerWorks += lang;
         compilerWorks += "_COMPILER_WORKS";
         // 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))
-          {
+        if (!mf->IsOn(compilerWorks)) {
           std::string compilerLangFile = rootBin;
           compilerLangFile += "/CMake";
           compilerLangFile += lang;
           compilerLangFile += "Compiler.cmake";
           cmSystemTools::RemoveFile(compilerLangFile);
-          }
-        } // end if in try compile
-      } // end need test language
+        }
+      } // end if in try compile
+    }   // end need test language
     // Store the shared library flags so that we can satisfy CMP0018
     std::string sharedLibFlagsVar = "CMAKE_SHARED_LIBRARY_";
     sharedLibFlagsVar += lang;
     sharedLibFlagsVar += "_FLAGS";
-    const char* sharedLibFlags =
-      mf->GetSafeDefinition(sharedLibFlagsVar);
-    if (sharedLibFlags)
-      {
+    const char* sharedLibFlags = mf->GetSafeDefinition(sharedLibFlagsVar);
+    if (sharedLibFlags) {
       this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
-      }
+    }
 
     // Translate compiler ids for compatibility.
     this->CheckCompilerIdCompatibility(mf, lang);
-    } // end for each language
+  } // end for each language
 
   // Now load files that can override any settings on the platform or for
   // the project First load the project compatibility file if it is in
   // cmake
-  std::string projectCompatibility = mf->GetDefinition("CMAKE_ROOT");
+  std::string projectCompatibility = cmSystemTools::GetCMakeRoot();
   projectCompatibility += "/Modules/";
   projectCompatibility += mf->GetSafeDefinition("PROJECT_NAME");
   projectCompatibility += "Compatibility.cmake";
-  if(cmSystemTools::FileExists(projectCompatibility.c_str()))
-    {
+  if (cmSystemTools::FileExists(projectCompatibility.c_str())) {
     mf->ReadListFile(projectCompatibility.c_str());
-    }
+  }
   // Inform any extra generator of the new language.
-  if (this->ExtraGenerator)
-    {
+  if (this->ExtraGenerator) {
     this->ExtraGenerator->EnableLanguage(languages, mf, false);
-    }
+  }
 
-  if(fatalError)
-    {
+  if (fatalError) {
     cmSystemTools::SetFatalErrorOccured();
-    }
+  }
+
+  for (std::set<std::string>::iterator li = cur_languages.begin();
+       li != cur_languages.end(); ++li) {
+    this->LanguagesInProgress.erase(*li);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
                                             std::string const& lang,
                                             const char* envVar) const
 {
   // Subclasses override this method if they do not support this advice.
-  os <<
-    "Tell CMake where to find the compiler by setting "
-    ;
-  if(envVar)
-    {
-    os <<
-      "either the environment variable \"" << envVar << "\" or "
-      ;
-    }
-  os <<
-    "the CMake cache entry CMAKE_" << lang << "_COMPILER "
-    "to the full path to the compiler, or to the compiler name "
-    "if it is in the PATH."
-    ;
+  os << "Tell CMake where to find the compiler by setting ";
+  if (envVar) {
+    os << "either the environment variable \"" << envVar << "\" or ";
+  }
+  os << "the CMake cache entry CMAKE_" << lang
+     << "_COMPILER "
+        "to the full path to the compiler, or to the compiler name "
+        "if it is in the PATH.";
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
-                                                std::string const& lang) const
+void cmGlobalGenerator::CheckCompilerIdCompatibility(
+  cmMakefile* mf, std::string const& lang) const
 {
   std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
   const char* compilerId = mf->GetDefinition(compilerIdVar);
-  if(!compilerId)
-    {
+  if (!compilerId) {
     return;
-    }
+  }
 
-  if(strcmp(compilerId, "AppleClang") == 0)
-    {
-    switch(mf->GetPolicyStatus(cmPolicies::CMP0025))
-      {
+  if (strcmp(compilerId, "AppleClang") == 0) {
+    switch (mf->GetPolicyStatus(cmPolicies::CMP0025)) {
       case cmPolicies::WARN:
-        if(!this->CMakeInstance->GetIsInTryCompile() &&
-           mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0025"))
-          {
+        if (!this->CMakeInstance->GetIsInTryCompile() &&
+            mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0025")) {
           std::ostringstream w;
+          /* clang-format off */
           w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0025) << "\n"
             "Converting " << lang <<
             " compiler id \"AppleClang\" to \"Clang\" for compatibility."
             ;
+          /* clang-format on */
           mf->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-          }
+        }
       case cmPolicies::OLD:
         // OLD behavior is to convert AppleClang to Clang.
         mf->AddDefinition(compilerIdVar, "Clang");
@@ -881,101 +806,85 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
       case cmPolicies::REQUIRED_ALWAYS:
         mf->IssueMessage(
           cmake::FATAL_ERROR,
-          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0025)
-          );
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0025));
       case cmPolicies::NEW:
         // NEW behavior is to keep AppleClang.
         break;
-      }
     }
+  }
 
-  if(strcmp(compilerId, "QCC") == 0)
-    {
-    switch(mf->GetPolicyStatus(cmPolicies::CMP0047))
-      {
+  if (strcmp(compilerId, "QCC") == 0) {
+    switch (mf->GetPolicyStatus(cmPolicies::CMP0047)) {
       case cmPolicies::WARN:
-        if(!this->CMakeInstance->GetIsInTryCompile() &&
-           mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0047"))
-          {
+        if (!this->CMakeInstance->GetIsInTryCompile() &&
+            mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0047")) {
           std::ostringstream w;
+          /* clang-format off */
           w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0047) << "\n"
             "Converting " << lang <<
             " compiler id \"QCC\" to \"GNU\" for compatibility."
             ;
+          /* clang-format on */
           mf->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-          }
+        }
       case cmPolicies::OLD:
         // OLD behavior is to convert QCC to GNU.
         mf->AddDefinition(compilerIdVar, "GNU");
-        if(lang == "C")
-          {
+        if (lang == "C") {
           mf->AddDefinition("CMAKE_COMPILER_IS_GNUCC", "1");
-          }
-        else if(lang == "CXX")
-          {
+        } else if (lang == "CXX") {
           mf->AddDefinition("CMAKE_COMPILER_IS_GNUCXX", "1");
-          }
+        }
         break;
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
         mf->IssueMessage(
           cmake::FATAL_ERROR,
-          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0047)
-          );
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0047));
       case cmPolicies::NEW:
         // NEW behavior is to keep QCC.
         break;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
+std::string cmGlobalGenerator::GetLanguageOutputExtension(
+  cmSourceFile const& source) const
 {
   const std::string& lang = source.GetLanguage();
-  if(!lang.empty())
-    {
+  if (!lang.empty()) {
     std::map<std::string, std::string>::const_iterator it =
-                                  this->LanguageToOutputExtension.find(lang);
+      this->LanguageToOutputExtension.find(lang);
 
-    if(it != this->LanguageToOutputExtension.end())
-      {
+    if (it != this->LanguageToOutputExtension.end()) {
       return it->second;
-      }
     }
-  else
-    {
+  } else {
     // if no language is found then check to see if it is already an
     // ouput extension for some language.  In that case it should be ignored
     // and in this map, so it will not be compiled but will just be used.
     std::string const& ext = source.GetExtension();
-    if(!ext.empty())
-      {
-      if(this->OutputExtensions.count(ext))
-        {
+    if (!ext.empty()) {
+      if (this->OutputExtensions.count(ext)) {
         return ext;
-        }
       }
     }
+  }
   return "";
 }
 
-
 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
-  if(ext && *ext == '.')
-    {
+  if (ext && *ext == '.') {
     ++ext;
-    }
-  std::map<std::string, std::string>::const_iterator it
-                                        = this->ExtensionToLanguage.find(ext);
-  if(it != this->ExtensionToLanguage.end())
-    {
+  }
+  std::map<std::string, std::string>::const_iterator it =
+    this->ExtensionToLanguage.find(ext);
+  if (it != this->ExtensionToLanguage.end()) {
     return it->second;
-    }
+  }
   return "";
 }
 
@@ -1017,96 +926,83 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
   // use LanguageToLinkerPreference to detect whether this functions has
   // run before
   if (this->LanguageToLinkerPreference.find(l) !=
-                                        this->LanguageToLinkerPreference.end())
-    {
+      this->LanguageToLinkerPreference.end()) {
     return;
-    }
+  }
 
-  std::string linkerPrefVar = std::string("CMAKE_") +
-    std::string(l) + std::string("_LINKER_PREFERENCE");
+  std::string linkerPrefVar =
+    std::string("CMAKE_") + std::string(l) + std::string("_LINKER_PREFERENCE");
   const char* linkerPref = mf->GetDefinition(linkerPrefVar);
   int preference = 0;
-  if(linkerPref)
-    {
-    if (sscanf(linkerPref, "%d", &preference)!=1)
-      {
+  if (linkerPref) {
+    if (sscanf(linkerPref, "%d", &preference) != 1) {
       // backward compatibility: before 2.6 LINKER_PREFERENCE
       // was either "None" or "Preferred", and only the first character was
       // tested. So if there is a custom language out there and it is
       // "Preferred", set its preference high
-      if (linkerPref[0]=='P')
-        {
+      if (linkerPref[0] == 'P') {
         preference = 100;
-        }
-      else
-        {
+      } else {
         preference = 0;
-        }
       }
     }
+  }
 
-  if (preference < 0)
-    {
+  if (preference < 0) {
     std::string msg = linkerPrefVar;
     msg += " is negative, adjusting it to 0";
     cmSystemTools::Message(msg.c_str(), "Warning");
     preference = 0;
-    }
+  }
 
   this->LanguageToLinkerPreference[l] = preference;
 
-  std::string outputExtensionVar = std::string("CMAKE_") +
-    std::string(l) + std::string("_OUTPUT_EXTENSION");
+  std::string outputExtensionVar =
+    std::string("CMAKE_") + std::string(l) + std::string("_OUTPUT_EXTENSION");
   const char* outputExtension = mf->GetDefinition(outputExtensionVar);
-  if(outputExtension)
-    {
+  if (outputExtension) {
     this->LanguageToOutputExtension[l] = outputExtension;
     this->OutputExtensions[outputExtension] = outputExtension;
-    if(outputExtension[0] == '.')
-      {
-      this->OutputExtensions[outputExtension+1] = outputExtension+1;
-      }
+    if (outputExtension[0] == '.') {
+      this->OutputExtensions[outputExtension + 1] = outputExtension + 1;
     }
+  }
 
   // The map was originally filled by SetLanguageEnabledFlag, but
   // since then the compiler- and platform-specific files have been
   // loaded which might have added more entries.
   this->FillExtensionToLanguageMap(l, mf);
 
-  std::string ignoreExtensionsVar = std::string("CMAKE_") +
-    std::string(l) + std::string("_IGNORE_EXTENSIONS");
+  std::string ignoreExtensionsVar =
+    std::string("CMAKE_") + std::string(l) + std::string("_IGNORE_EXTENSIONS");
   std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar);
   std::vector<std::string> extensionList;
   cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
-  for(std::vector<std::string>::iterator i = extensionList.begin();
-      i != extensionList.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = extensionList.begin();
+       i != extensionList.end(); ++i) {
     this->IgnoreExtensions[*i] = true;
-    }
-
+  }
 }
 
 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 extensionsVar = std::string("CMAKE_") + std::string(l) +
+    std::string("_SOURCE_FILE_EXTENSIONS");
   std::string exts = mf->GetSafeDefinition(extensionsVar);
   std::vector<std::string> extensionList;
   cmSystemTools::ExpandListArgument(exts, extensionList);
-  for(std::vector<std::string>::iterator i = extensionList.begin();
-      i != extensionList.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = extensionList.begin();
+       i != extensionList.end(); ++i) {
     this->ExtensionToLanguage[*i] = l;
-    }
+  }
 }
 
 bool cmGlobalGenerator::IgnoreFile(const char* ext) const
 {
-  if(!this->GetLanguageFromExtension(ext).empty())
-    {
+  if (!this->GetLanguageFromExtension(ext).empty()) {
     return false;
-    }
+  }
   return (this->IgnoreExtensions.count(ext) > 0);
 }
 
@@ -1126,10 +1022,9 @@ void cmGlobalGenerator::CreateLocalGenerators()
   this->LocalGenerators.clear();
   this->LocalGenerators.reserve(this->Makefiles.size());
   for (std::vector<cmMakefile*>::const_iterator it = this->Makefiles.begin();
-       it != this->Makefiles.end(); ++it)
-    {
+       it != this->Makefiles.end(); ++it) {
     this->LocalGenerators.push_back(this->CreateLocalGenerator(*it));
-    }
+  }
 }
 
 void cmGlobalGenerator::Configure()
@@ -1139,16 +1034,16 @@ void cmGlobalGenerator::Configure()
 
   cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
 
-  snapshot.GetDirectory().SetCurrentSource
-    (this->CMakeInstance->GetHomeDirectory());
-  snapshot.GetDirectory().SetCurrentBinary
-    (this->CMakeInstance->GetHomeOutputDirectory());
+  snapshot.GetDirectory().SetCurrentSource(
+    this->CMakeInstance->GetHomeDirectory());
+  snapshot.GetDirectory().SetCurrentBinary(
+    this->CMakeInstance->GetHomeOutputDirectory());
 
   cmMakefile* dirMf = new cmMakefile(this, snapshot);
   this->Makefiles.push_back(dirMf);
 
   this->BinaryDirectories.insert(
-      this->CMakeInstance->GetHomeOutputDirectory());
+    this->CMakeInstance->GetHomeOutputDirectory());
 
   // now do it
   this->ConfigureDoneCMP0026AndCMP0024 = false;
@@ -1161,55 +1056,47 @@ void cmGlobalGenerator::Configure()
   cmTargets globalTargets;
   this->CreateDefaultGlobalTargets(&globalTargets);
 
-  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
     cmMakefile* mf = this->Makefiles[i];
     cmTargets* targets = &(mf->GetTargets());
     cmTargets::iterator tit;
-    for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit )
-      {
+    for (tit = globalTargets.begin(); tit != globalTargets.end(); ++tit) {
       (*targets)[tit->first] = tit->second;
       (*targets)[tit->first].SetMakefile(mf);
-      }
     }
+  }
 
   // update the cache entry for the number of local generators, this is used
   // for progress
   char num[100];
-  sprintf(num,"%d",static_cast<int>(this->Makefiles.size()));
-  this->GetCMakeInstance()->AddCacheEntry
-    ("CMAKE_NUMBER_OF_MAKEFILES", num,
-     "number of local generators", cmState::INTERNAL);
+  sprintf(num, "%d", static_cast<int>(this->Makefiles.size()));
+  this->GetCMakeInstance()->AddCacheEntry("CMAKE_NUMBER_OF_MAKEFILES", num,
+                                          "number of local generators",
+                                          cmState::INTERNAL);
 
   // check for link libraries and include directories containing "NOTFOUND"
   // and for infinite loops
   this->CheckTargetProperties();
 
-  if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE)
-    {
+  if (this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) {
     std::ostringstream msg;
-    if(cmSystemTools::GetErrorOccuredFlag())
-      {
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       msg << "Configuring incomplete, errors occurred!";
-      const char* logs[] = {"CMakeOutput.log", "CMakeError.log", 0};
-      for(const char** log = logs; *log; ++log)
-        {
+      const char* logs[] = { "CMakeOutput.log", "CMakeError.log", 0 };
+      for (const char** log = logs; *log; ++log) {
         std::string f = this->CMakeInstance->GetHomeOutputDirectory();
         f += this->CMakeInstance->GetCMakeFilesDirectory();
         f += "/";
         f += *log;
-        if(cmSystemTools::FileExists(f.c_str()))
-          {
+        if (cmSystemTools::FileExists(f.c_str())) {
           msg << "\nSee also \"" << f << "\".";
-          }
         }
       }
-    else
-      {
+    } else {
       msg << "Configuring done";
-      }
-    this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1);
     }
+    this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1);
+  }
 }
 
 void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
@@ -1219,35 +1106,32 @@ void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
   this->ComputeBuildFileGenerators();
 }
 
-void cmGlobalGenerator::CreateImportedGenerationObjects(cmMakefile* mf,
-    const std::vector<std::string>& targets,
-    std::vector<const cmGeneratorTarget*>& exports)
+void cmGlobalGenerator::CreateImportedGenerationObjects(
+  cmMakefile* mf, const std::vector<std::string>& targets,
+  std::vector<const cmGeneratorTarget*>& exports)
 {
   this->CreateGenerationObjects(ImportedOnly);
   std::vector<cmMakefile*>::iterator mfit =
-      std::find(this->Makefiles.begin(), this->Makefiles.end(), mf);
+    std::find(this->Makefiles.begin(), this->Makefiles.end(), mf);
   cmLocalGenerator* lg =
-      this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)];
+    this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)];
   for (std::vector<std::string>::const_iterator it = targets.begin();
-       it != targets.end(); ++it)
-    {
+       it != targets.end(); ++it) {
     cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(*it);
-    if (gt)
-      {
+    if (gt) {
       exports.push_back(gt);
-      }
     }
+  }
 }
 
-cmExportBuildFileGenerator*
-cmGlobalGenerator::GetExportedTargetsFile(const std::string &filename) const
+cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile(
+  const std::string& filename) const
 {
-  std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it
-    = this->BuildExportSets.find(filename);
+  std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it =
+    this->BuildExportSets.find(filename);
   return it == this->BuildExportSets.end() ? 0 : it->second;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
 {
   this->CMP0042WarnTargets.insert(target);
@@ -1256,11 +1140,10 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
 bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
 {
   // If the property is not enabled then okay.
-  if(!this->CMakeInstance->GetState()
-     ->GetGlobalPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS"))
-    {
+  if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(
+        "ALLOW_DUPLICATE_CUSTOM_TARGETS")) {
     return true;
-    }
+  }
 
   // This generator does not support duplicate custom targets.
   std::ostringstream e;
@@ -1276,16 +1159,15 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
 
 void cmGlobalGenerator::ComputeBuildFileGenerators()
 {
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
     std::vector<cmExportBuildFileGenerator*> gens =
-        this->Makefiles[i]->GetExportBuildFileGenerators();
+      this->Makefiles[i]->GetExportBuildFileGenerators();
     for (std::vector<cmExportBuildFileGenerator*>::const_iterator it =
-         gens.begin(); it != gens.end(); ++it)
-      {
+           gens.begin();
+         it != gens.end(); ++it) {
       (*it)->Compute(this->LocalGenerators[i]);
-      }
     }
+  }
 }
 
 bool cmGlobalGenerator::Compute()
@@ -1298,10 +1180,9 @@ bool cmGlobalGenerator::Compute()
   this->CMP0042WarnTargets.clear();
 
   // Check whether this generator is allowed to run.
-  if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS())
-    {
+  if (!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) {
     return false;
-    }
+  }
   this->FinalizeTargetCompileInfo();
 
   this->CreateGenerationObjects();
@@ -1314,63 +1195,56 @@ bool cmGlobalGenerator::Compute()
   // Iterate through all targets and set up automoc for those which have
   // the AUTOMOC, AUTOUIC or AUTORCC property set
   std::vector<cmGeneratorTarget const*> autogenTargets =
-      this->CreateQtAutoGeneratorsTargets();
+    this->CreateQtAutoGeneratorsTargets();
 #endif
 
   unsigned int i;
 
   // Add generator specific helper commands
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     this->LocalGenerators[i]->AddHelperCommands();
-    }
+  }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   for (std::vector<cmGeneratorTarget const*>::iterator it =
-       autogenTargets.begin(); it != autogenTargets.end(); ++it)
-    {
+         autogenTargets.begin();
+       it != autogenTargets.end(); ++it) {
     cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it);
-    }
+  }
 #endif
 
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     cmMakefile* mf = this->LocalGenerators[i]->GetMakefile();
     std::vector<cmInstallGenerator*>& gens = mf->GetInstallGenerators();
     for (std::vector<cmInstallGenerator*>::const_iterator git = gens.begin();
-         git != gens.end(); ++git)
-      {
+         git != gens.end(); ++git) {
       (*git)->Compute(this->LocalGenerators[i]);
-      }
     }
+  }
 
   this->AddExtraIDETargets();
 
   // Trace the dependencies, after that no custom commands should be added
   // because their dependencies might not be handled correctly
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     this->LocalGenerators[i]->TraceDependencies();
-    }
+  }
 
   this->ForceLinkerLanguages();
 
   // Compute the manifest of main targets generated.
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     this->LocalGenerators[i]->ComputeTargetManifest();
-    }
+  }
 
   // Compute the inter-target dependencies.
-  if(!this->ComputeTargetDepends())
-    {
+  if (!this->ComputeTargetDepends()) {
     return false;
-    }
+  }
 
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     this->LocalGenerators[i]->ComputeHomeRelativeOutputPath();
-    }
+  }
 
   return true;
 }
@@ -1384,265 +1258,243 @@ void cmGlobalGenerator::Generate()
   this->ProcessEvaluationFiles();
 
   // Generate project files
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
     this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile());
     this->LocalGenerators[i]->Generate();
-    if(!this->LocalGenerators[i]->GetMakefile()->IsOn(
-      "CMAKE_SKIP_INSTALL_RULES"))
-      {
+    if (!this->LocalGenerators[i]->GetMakefile()->IsOn(
+          "CMAKE_SKIP_INSTALL_RULES")) {
       this->LocalGenerators[i]->GenerateInstallRules();
-      }
-    this->LocalGenerators[i]->GenerateTestFiles();
-    this->CMakeInstance->UpdateProgress("Generating",
-      (static_cast<float>(i)+1.0f)/
-       static_cast<float>(this->LocalGenerators.size()));
     }
+    this->LocalGenerators[i]->GenerateTestFiles();
+    this->CMakeInstance->UpdateProgress(
+      "Generating", (static_cast<float>(i) + 1.0f) /
+        static_cast<float>(this->LocalGenerators.size()));
+  }
   this->SetCurrentMakefile(0);
 
-  if(!this->GenerateCPackPropertiesFile())
-    {
+  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)
-    {
-    if (!it->second->GenerateImportFile()
-        && !cmSystemTools::GetErrorOccuredFlag())
-      {
-      this->GetCMakeInstance()
-          ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file.");
+  for (std::map<std::string, cmExportBuildFileGenerator*>::iterator it =
+         this->BuildExportSets.begin();
+       it != this->BuildExportSets.end(); ++it) {
+    if (!it->second->GenerateImportFile() &&
+        !cmSystemTools::GetErrorOccuredFlag()) {
+      this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
+                                             "Could not write export file.");
       return;
-      }
     }
+  }
   // Update rule hashes.
   this->CheckRuleHashes();
 
   this->WriteSummary();
 
-  if (this->ExtraGenerator != 0)
-    {
+  if (this->ExtraGenerator != 0) {
     this->ExtraGenerator->Generate();
-    }
+  }
 
-  if(!this->CMP0042WarnTargets.empty())
-    {
+  if (!this->CMP0042WarnTargets.empty()) {
     std::ostringstream w;
     w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
     w << "MACOSX_RPATH is not specified for"
          " the following targets:\n";
-    for(std::set<std::string>::iterator
-      iter = this->CMP0042WarnTargets.begin();
-      iter != this->CMP0042WarnTargets.end();
-      ++iter)
-      {
+    for (std::set<std::string>::iterator iter =
+           this->CMP0042WarnTargets.begin();
+         iter != this->CMP0042WarnTargets.end(); ++iter) {
       w << " " << *iter << "\n";
-      }
-    this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
     }
+    this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+  }
 
   this->CMakeInstance->UpdateProgress("Generating done", -1);
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalGenerator::ComputeTargetDepends()
 {
   cmComputeTargetDepends ctd(this);
-  if(!ctd.Compute())
-    {
+  if (!ctd.Compute()) {
     return false;
-    }
+  }
   std::vector<cmGeneratorTarget const*> const& targets = ctd.GetTargets();
-  for(std::vector<cmGeneratorTarget const*>::const_iterator ti
-      = targets.begin(); ti != targets.end(); ++ti)
-    {
+  for (std::vector<cmGeneratorTarget const*>::const_iterator ti =
+         targets.begin();
+       ti != targets.end(); ++ti) {
     ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 std::vector<const cmGeneratorTarget*>
 cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
 {
   std::vector<const cmGeneratorTarget*> autogenTargets;
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
-  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
     std::vector<cmGeneratorTarget*> targets =
       this->LocalGenerators[i]->GetGeneratorTargets();
     std::vector<cmGeneratorTarget*> filteredTargets;
     filteredTargets.reserve(targets.size());
-    for(std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
-      if ((*ti)->GetType() == cmState::GLOBAL_TARGET)
-        {
+    for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
+         ti != targets.end(); ++ti) {
+      if ((*ti)->GetType() == cmState::GLOBAL_TARGET) {
         continue;
-        }
-      if((*ti)->GetType() != cmState::EXECUTABLE &&
-         (*ti)->GetType() != cmState::STATIC_LIBRARY &&
-         (*ti)->GetType() != cmState::SHARED_LIBRARY &&
-         (*ti)->GetType() != cmState::MODULE_LIBRARY &&
-         (*ti)->GetType() != cmState::OBJECT_LIBRARY)
-        {
+      }
+      if ((*ti)->GetType() != cmState::EXECUTABLE &&
+          (*ti)->GetType() != cmState::STATIC_LIBRARY &&
+          (*ti)->GetType() != cmState::SHARED_LIBRARY &&
+          (*ti)->GetType() != cmState::MODULE_LIBRARY &&
+          (*ti)->GetType() != cmState::OBJECT_LIBRARY) {
         continue;
-        }
-      if((!(*ti)->GetPropertyAsBool("AUTOMOC")
-            && !(*ti)->GetPropertyAsBool("AUTOUIC")
-            && !(*ti)->GetPropertyAsBool("AUTORCC"))
-          || (*ti)->IsImported())
-        {
+      }
+      if ((!(*ti)->GetPropertyAsBool("AUTOMOC") &&
+           !(*ti)->GetPropertyAsBool("AUTOUIC") &&
+           !(*ti)->GetPropertyAsBool("AUTORCC")) ||
+          (*ti)->IsImported()) {
         continue;
-        }
+      }
       // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
       cmMakefile* mf = (*ti)->Target->GetMakefile();
       std::string qtMajorVersion = mf->GetSafeDefinition("QT_VERSION_MAJOR");
-      if (qtMajorVersion == "")
-        {
+      if (qtMajorVersion == "") {
         qtMajorVersion = mf->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
-        }
-      if (qtMajorVersion != "4" && qtMajorVersion != "5")
-        {
+      }
+      if (qtMajorVersion != "4" && qtMajorVersion != "5") {
         continue;
-        }
+      }
 
       cmGeneratorTarget* gt = *ti;
 
       cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt);
       filteredTargets.push_back(gt);
-      }
-    for(std::vector<cmGeneratorTarget*>::iterator ti = filteredTargets.begin();
-        ti != filteredTargets.end(); ++ti)
-      {
+    }
+    for (std::vector<cmGeneratorTarget*>::iterator ti =
+           filteredTargets.begin();
+         ti != filteredTargets.end(); ++ti) {
       cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
-           this->LocalGenerators[i], *ti);
+        this->LocalGenerators[i], *ti);
       autogenTargets.push_back(*ti);
-      }
     }
+  }
 #endif
   return autogenTargets;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::FinalizeTargetCompileInfo()
 {
+  std::vector<std::string> const langs =
+    this->CMakeInstance->GetState()->GetEnabledLanguages();
+
   // Construct per-target generator information.
-  for(unsigned int i=0; i < this->Makefiles.size(); ++i)
-    {
-    cmMakefile *mf = this->Makefiles[i];
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
+    cmMakefile* mf = this->Makefiles[i];
 
     const cmStringRange noconfig_compile_definitions =
-                                mf->GetCompileDefinitionsEntries();
+      mf->GetCompileDefinitionsEntries();
     const cmBacktraceRange noconfig_compile_definitions_bts =
-                                mf->GetCompileDefinitionsBacktraces();
+      mf->GetCompileDefinitionsBacktraces();
 
     cmTargets& targets = mf->GetTargets();
-    for(cmTargets::iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
+    for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) {
       cmTarget* t = &ti->second;
-      if (t->GetType() == cmState::GLOBAL_TARGET)
-        {
+      if (t->GetType() == cmState::GLOBAL_TARGET) {
         continue;
-        }
+      }
 
       t->AppendBuildInterfaceIncludes();
 
-      if (t->GetType() == cmState::INTERFACE_LIBRARY)
-        {
+      if (t->GetType() == cmState::INTERFACE_LIBRARY) {
         continue;
-        }
+      }
 
-      cmBacktraceRange::const_iterator btIt
-          = noconfig_compile_definitions_bts.begin();
-      for (cmStringRange::const_iterator it
-                                      = noconfig_compile_definitions.begin();
-          it != noconfig_compile_definitions.end(); ++it, ++btIt)
-        {
+      cmBacktraceRange::const_iterator btIt =
+        noconfig_compile_definitions_bts.begin();
+      for (cmStringRange::const_iterator
+             it = noconfig_compile_definitions.begin();
+           it != noconfig_compile_definitions.end(); ++it, ++btIt) {
         t->InsertCompileDefinition(*it, *btIt);
-        }
+      }
 
-      cmPolicies::PolicyStatus polSt
-                                  = mf->GetPolicyStatus(cmPolicies::CMP0043);
-      if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD)
-        {
+      cmPolicies::PolicyStatus polSt =
+        mf->GetPolicyStatus(cmPolicies::CMP0043);
+      if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
         std::vector<std::string> configs;
         mf->GetConfigurations(configs);
 
-        for(std::vector<std::string>::const_iterator ci = configs.begin();
-            ci != configs.end(); ++ci)
-          {
+        for (std::vector<std::string>::const_iterator ci = configs.begin();
+             ci != configs.end(); ++ci) {
           std::string defPropName = "COMPILE_DEFINITIONS_";
           defPropName += cmSystemTools::UpperCase(*ci);
-          t->AppendProperty(defPropName,
-                            mf->GetProperty(defPropName));
-          }
+          t->AppendProperty(defPropName, mf->GetProperty(defPropName));
         }
       }
     }
+
+    // The standard include directories for each language
+    // should be treated as system include directories.
+    std::set<std::string> standardIncludesSet;
+    for (std::vector<std::string>::const_iterator li = langs.begin();
+         li != langs.end(); ++li) {
+      std::string const standardIncludesVar =
+        "CMAKE_" + *li + "_STANDARD_INCLUDE_DIRECTORIES";
+      std::string const standardIncludesStr =
+        mf->GetSafeDefinition(standardIncludesVar);
+      std::vector<std::string> standardIncludesVec;
+      cmSystemTools::ExpandListArgument(standardIncludesStr,
+                                        standardIncludesVec);
+      standardIncludesSet.insert(standardIncludesVec.begin(),
+                                 standardIncludesVec.end());
+    }
+    mf->AddSystemIncludeDirectories(standardIncludesSet);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::CreateGeneratorTargets(
-    TargetTypes targetTypes,
-    cmMakefile *mf,
-    cmLocalGenerator *lg,
-    std::map<cmTarget*, cmGeneratorTarget*> const& importedMap)
+  TargetTypes targetTypes, cmMakefile* mf, cmLocalGenerator* lg,
+  std::map<cmTarget*, cmGeneratorTarget*> const& importedMap)
 {
-  if (targetTypes == AllTargets)
-    {
+  if (targetTypes == AllTargets) {
     cmTargets& targets = mf->GetTargets();
-    for(cmTargets::iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
+    for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) {
       cmTarget* t = &ti->second;
       cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
       lg->AddGeneratorTarget(gt);
-      }
     }
+  }
 
   std::vector<cmTarget*> itgts = mf->GetImportedTargets();
 
-  for(std::vector<cmTarget*>::const_iterator
-        j = itgts.begin(); j != itgts.end(); ++j)
-    {
+  for (std::vector<cmTarget*>::const_iterator j = itgts.begin();
+       j != itgts.end(); ++j) {
     lg->AddImportedGeneratorTarget(importedMap.find(*j)->second);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
 {
   std::map<cmTarget*, cmGeneratorTarget*> importedMap;
-  for(unsigned int i=0; i < this->Makefiles.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
     cmMakefile* mf = this->Makefiles[i];
-    for(std::vector<cmTarget*>::const_iterator
-          j = mf->GetOwnedImportedTargets().begin();
-        j != mf->GetOwnedImportedTargets().end(); ++j)
-      {
+    for (std::vector<cmTarget*>::const_iterator j =
+           mf->GetOwnedImportedTargets().begin();
+         j != mf->GetOwnedImportedTargets().end(); ++j) {
       cmLocalGenerator* lg = this->LocalGenerators[i];
       cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
       lg->AddOwnedImportedGeneratorTarget(gt);
       importedMap[*j] = gt;
-      }
     }
+  }
 
   // Construct per-target generator information.
-  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
     this->CreateGeneratorTargets(targetTypes, this->Makefiles[i],
                                  this->LocalGenerators[i], importedMap);
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::ClearGeneratorMembers()
 {
   cmDeleteAll(this->BuildExportSets);
@@ -1664,7 +1516,6 @@ void cmGlobalGenerator::ClearGeneratorMembers()
   this->BinaryDirectories.clear();
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
 {
 }
@@ -1672,126 +1523,108 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
 void cmGlobalGenerator::CheckTargetProperties()
 {
   std::map<std::string, std::string> notFoundMap;
-//  std::set<std::string> notFoundMap;
+  //  std::set<std::string> notFoundMap;
   // after it is all done do a ConfigureFinalPass
   cmState* state = this->GetCMakeInstance()->GetState();
-  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
     this->Makefiles[i]->ConfigureFinalPass();
-    cmTargets &targets =
-      this->Makefiles[i]->GetTargets();
-    for (cmTargets::iterator l = targets.begin();
-         l != targets.end(); l++)
-      {
-      if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
-        {
+    cmTargets& targets = this->Makefiles[i]->GetTargets();
+    for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) {
+      if (l->second.GetType() == cmState::INTERFACE_LIBRARY) {
         continue;
-        }
+      }
       const cmTarget::LinkLibraryVectorType& libs =
         l->second.GetOriginalLinkLibraries();
-      for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
-          lib != libs.end(); ++lib)
-        {
-        if(lib->first.size() > 9 &&
-           cmSystemTools::IsNOTFOUND(lib->first.c_str()))
-          {
-          std::string varName = lib->first.substr(0, lib->first.size()-9);
-          if(state->GetCacheEntryPropertyAsBool(varName, "ADVANCED"))
-            {
+      for (cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
+           lib != libs.end(); ++lib) {
+        if (lib->first.size() > 9 &&
+            cmSystemTools::IsNOTFOUND(lib->first.c_str())) {
+          std::string varName = lib->first.substr(0, lib->first.size() - 9);
+          if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) {
             varName += " (ADVANCED)";
-            }
+          }
           std::string text = notFoundMap[varName];
           text += "\n    linked by target \"";
           text += l->second.GetName();
           text += "\" in directory ";
-          text+=this->Makefiles[i]->GetCurrentSourceDirectory();
+          text += this->Makefiles[i]->GetCurrentSourceDirectory();
           notFoundMap[varName] = text;
-          }
         }
+      }
       std::vector<std::string> incs;
-      const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
-      if (!incDirProp)
-        {
+      const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
+      if (!incDirProp) {
         continue;
-        }
+      }
 
-      std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp,
-                        cmGeneratorExpression::StripAllGeneratorExpressions);
+      std::string incDirs = cmGeneratorExpression::Preprocess(
+        incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions);
 
       cmSystemTools::ExpandListArgument(incDirs, incs);
 
-      for( std::vector<std::string>::const_iterator incDir = incs.begin();
-            incDir != incs.end(); ++incDir)
-        {
-        if(incDir->size() > 9 &&
-            cmSystemTools::IsNOTFOUND(incDir->c_str()))
-          {
-          std::string varName = incDir->substr(0, incDir->size()-9);
-          if(state->GetCacheEntryPropertyAsBool(varName, "ADVANCED"))
-            {
+      for (std::vector<std::string>::const_iterator incDir = incs.begin();
+           incDir != incs.end(); ++incDir) {
+        if (incDir->size() > 9 && cmSystemTools::IsNOTFOUND(incDir->c_str())) {
+          std::string varName = incDir->substr(0, incDir->size() - 9);
+          if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) {
             varName += " (ADVANCED)";
-            }
+          }
           std::string text = notFoundMap[varName];
           text += "\n   used as include directory in directory ";
           text += this->Makefiles[i]->GetCurrentSourceDirectory();
           notFoundMap[varName] = text;
-          }
         }
       }
-    this->CMakeInstance->UpdateProgress
-      ("Configuring", 0.9f+0.1f*(static_cast<float>(i)+1.0f)/
-        static_cast<float>(this->Makefiles.size()));
     }
+    this->CMakeInstance->UpdateProgress(
+      "Configuring", 0.9f +
+        0.1f * (static_cast<float>(i) + 1.0f) /
+          static_cast<float>(this->Makefiles.size()));
+  }
 
-  if(!notFoundMap.empty())
-    {
+  if (!notFoundMap.empty()) {
     std::string notFoundVars;
-    for(std::map<std::string, std::string>::const_iterator
-        ii = notFoundMap.begin();
-        ii != notFoundMap.end();
-        ++ii)
-      {
+    for (std::map<std::string, std::string>::const_iterator ii =
+           notFoundMap.begin();
+         ii != notFoundMap.end(); ++ii) {
       notFoundVars += ii->first;
       notFoundVars += ii->second;
       notFoundVars += "\n";
-      }
+    }
     cmSystemTools::Error("The following variables are used in this project, "
                          "but they are set to NOTFOUND.\n"
                          "Please set them or make sure they are set and "
                          "tested correctly in the CMake files:\n",
                          notFoundVars.c_str());
-    }
+  }
 }
 
 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)
+                                  std::string& output, cmMakefile* mf)
 {
   // if this is not set, then this is a first time configure
   // and there is a good chance that the try compile stuff will
   // take the bulk of the time, so try and guess some progress
   // by getting closer and closer to 100 without actually getting there.
-  if (!this->CMakeInstance->GetState()->GetInitializedCacheValue
-      ("CMAKE_NUMBER_OF_MAKEFILES"))
-    {
+  if (!this->CMakeInstance->GetState()->GetInitializedCacheValue(
+        "CMAKE_NUMBER_OF_MAKEFILES")) {
     // If CMAKE_NUMBER_OF_MAKEFILES is not set
     // we are in the first time progress and we have no
     // idea how long it will be.  So, just move 1/10th of the way
     // there each time, and don't go over 95%
-    this->FirstTimeProgress += ((1.0f - this->FirstTimeProgress) /30.0f);
-    if(this->FirstTimeProgress > 0.95f)
-      {
+    this->FirstTimeProgress += ((1.0f - this->FirstTimeProgress) / 30.0f);
+    if (this->FirstTimeProgress > 0.95f) {
       this->FirstTimeProgress = 0.95f;
-      }
+    }
     this->CMakeInstance->UpdateProgress("Configuring",
                                         this->FirstTimeProgress);
-    }
+  }
 
   std::string newTarget;
-  if (!target.empty())
-    {
+  if (!target.empty()) {
     newTarget += target;
 #if 0
 #if defined(_WIN32) || defined(__CYGWIN__)
@@ -1804,35 +1637,30 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir,
       }
 #endif // WIN32
 #endif
-    }
+  }
   std::string config =
     mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
-  return this->Build(srcdir,bindir,projectName,
-                     newTarget,
-                     output,"",config,false,fast,false,
-                     this->TryCompileTimeout);
+  return this->Build(srcdir, bindir, projectName, newTarget, output, "",
+                     config, false, fast, false, this->TryCompileTimeout);
 }
 
 void cmGlobalGenerator::GenerateBuildCommand(
   std::vector<std::string>& makeCommand, const std::string&,
   const std::string&, const std::string&, const std::string&,
-  const std::string&, bool, bool,
-  std::vector<std::string> const&)
+  const std::string&, bool, bool, std::vector<std::string> const&)
 {
   makeCommand.push_back(
     "cmGlobalGenerator::GenerateBuildCommand not implemented");
 }
 
-int cmGlobalGenerator::Build(
-  const std::string&, const std::string& bindir,
-  const std::string& projectName, const std::string& target,
-  std::string& output,
-  const std::string& makeCommandCSTR,
-  const std::string& config,
-  bool clean, bool fast, bool verbose,
-  double timeout,
-  cmSystemTools::OutputOption outputflag,
-  std::vector<std::string> const& nativeOptions)
+int cmGlobalGenerator::Build(const std::string&, const std::string& bindir,
+                             const std::string& projectName,
+                             const std::string& target, std::string& output,
+                             const std::string& makeCommandCSTR,
+                             const std::string& config, bool clean, bool fast,
+                             bool verbose, double timeout,
+                             cmSystemTools::OutputOption outputflag,
+                             std::vector<std::string> const& nativeOptions)
 {
   /**
    * Run an executable command and put the stdout in output.
@@ -1850,21 +1678,19 @@ int cmGlobalGenerator::Build(
   std::string* outputPtr = &outputBuffer;
 
   std::vector<std::string> makeCommand;
-  this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
-                             bindir, target, config, fast, verbose,
-                             nativeOptions);
+  this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName, bindir,
+                             target, config, fast, verbose, nativeOptions);
 
   // Workaround to convince VCExpress.exe to produce output.
   if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH &&
-      !makeCommand.empty() && cmSystemTools::LowerCase(
-        cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe")
-    {
+      !makeCommand.empty() &&
+      cmSystemTools::LowerCase(
+        cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe") {
     outputflag = cmSystemTools::OUTPUT_FORWARD;
-    }
+  }
 
   // should we do a clean first?
-  if (clean)
-    {
+  if (clean) {
     std::vector<std::string> cleanCommand;
     this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
                                bindir, "clean", config, fast, verbose);
@@ -1873,8 +1699,7 @@ int cmGlobalGenerator::Build(
     output += "\n";
 
     if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr,
-                                         &retVal, 0, outputflag, timeout))
-      {
+                                         &retVal, 0, outputflag, timeout)) {
       cmSystemTools::SetRunCommandHideConsole(hideconsole);
       cmSystemTools::Error("Generator: execution of make clean failed.");
       output += *outputPtr;
@@ -1883,9 +1708,9 @@ int cmGlobalGenerator::Build(
       // return to the original directory
       cmSystemTools::ChangeDirectory(cwd);
       return 1;
-      }
-    output += *outputPtr;
     }
+    output += *outputPtr;
+  }
 
   // now build
   std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
@@ -1894,118 +1719,104 @@ int cmGlobalGenerator::Build(
   output += "\n";
 
   if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr,
-                                       &retVal, 0, outputflag, timeout))
-    {
+                                       &retVal, 0, outputflag, timeout)) {
     cmSystemTools::SetRunCommandHideConsole(hideconsole);
-    cmSystemTools::Error
-      ("Generator: execution of make failed. Make command was: ",
-       makeCommandStr.c_str());
+    cmSystemTools::Error(
+      "Generator: execution of make failed. Make command was: ",
+      makeCommandStr.c_str());
     output += *outputPtr;
-    output += "\nGenerator: execution of make failed. Make command was: "
-        + makeCommandStr + "\n";
+    output += "\nGenerator: execution of make failed. Make command was: " +
+      makeCommandStr + "\n";
 
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd);
     return 1;
-    }
+  }
   output += *outputPtr;
   cmSystemTools::SetRunCommandHideConsole(hideconsole);
 
   // The SGI MipsPro 7.3 compiler does not return an error code when
   // the source has a #error in it!  This is a work-around for such
   // compilers.
-  if((retVal == 0) && (output.find("#error") != std::string::npos))
-    {
+  if ((retVal == 0) && (output.find("#error") != std::string::npos)) {
     retVal = 1;
-    }
+  }
 
   cmSystemTools::ChangeDirectory(cwd);
   return retVal;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
   const std::string& target, const std::string& config,
-  const std::string& native,
-  bool ignoreErrors)
+  const std::string& native, bool ignoreErrors)
 {
   std::string makeCommand = cmSystemTools::GetCMakeCommand();
   makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
   makeCommand += " --build .";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     makeCommand += " --config \"";
     makeCommand += config;
     makeCommand += "\"";
-    }
-  if(!target.empty())
-    {
+  }
+  if (!target.empty()) {
     makeCommand += " --target \"";
     makeCommand += target;
     makeCommand += "\"";
-    }
+  }
   const char* sep = " -- ";
-  if(ignoreErrors)
-    {
+  if (ignoreErrors) {
     const char* iflag = this->GetBuildIgnoreErrorsFlag();
-    if(iflag && *iflag)
-      {
+    if (iflag && *iflag) {
       makeCommand += sep;
       makeCommand += iflag;
       sep = " ";
-      }
     }
-  if(!native.empty())
-    {
+  }
+  if (!native.empty()) {
     makeCommand += sep;
     makeCommand += native;
-    }
+  }
   return makeCommand;
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::AddMakefile(cmMakefile *mf)
+void cmGlobalGenerator::AddMakefile(cmMakefile* mf)
 {
   this->Makefiles.push_back(mf);
 
   // update progress
   // estimate how many lg there will be
-  const char *numGenC =
-    this->CMakeInstance->GetState()->GetInitializedCacheValue
-    ("CMAKE_NUMBER_OF_MAKEFILES");
+  const char* numGenC =
+    this->CMakeInstance->GetState()->GetInitializedCacheValue(
+      "CMAKE_NUMBER_OF_MAKEFILES");
 
-  if (!numGenC)
-    {
+  if (!numGenC) {
     // If CMAKE_NUMBER_OF_MAKEFILES is not set
     // we are in the first time progress and we have no
     // idea how long it will be.  So, just move half way
     // there each time, and don't go over 95%
-    this->FirstTimeProgress += ((1.0f - this->FirstTimeProgress) /30.0f);
-    if(this->FirstTimeProgress > 0.95f)
-      {
+    this->FirstTimeProgress += ((1.0f - this->FirstTimeProgress) / 30.0f);
+    if (this->FirstTimeProgress > 0.95f) {
       this->FirstTimeProgress = 0.95f;
-      }
+    }
     this->CMakeInstance->UpdateProgress("Configuring",
                                         this->FirstTimeProgress);
     return;
-    }
+  }
 
   int numGen = atoi(numGenC);
-  float prog = 0.9f*static_cast<float>(this->Makefiles.size())/
+  float prog = 0.9f * static_cast<float>(this->Makefiles.size()) /
     static_cast<float>(numGen);
-  if (prog > 0.9f)
-    {
+  if (prog > 0.9f) {
     prog = 0.9f;
-    }
+  }
   this->CMakeInstance->UpdateProgress("Configuring", prog);
 }
 
 void cmGlobalGenerator::AddInstallComponent(const char* component)
 {
-  if(component && *component)
-    {
+  if (component && *component) {
     this->InstallComponents.insert(component);
-    }
+  }
 }
 
 void cmGlobalGenerator::EnableInstallTarget()
@@ -2013,13 +1824,12 @@ void cmGlobalGenerator::EnableInstallTarget()
   this->InstallTargetEnabled = true;
 }
 
-cmLocalGenerator*
-cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf)
+cmLocalGenerator* cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
   return new cmLocalGenerator(this, mf);
 }
 
-void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
+void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator* gen,
                                                      cmMakefile* mf)
 {
   this->SetConfiguredFilesPath(gen);
@@ -2027,12 +1837,10 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
   const char* make =
     gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
   this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
-                                          "make program",
-                                          cmState::FILEPATH);
+                                          "make program", cmState::FILEPATH);
   // copy the enabled languages
   this->GetCMakeInstance()->GetState()->SetEnabledLanguages(
-    gen->GetCMakeInstance()->GetState()->GetEnabledLanguages()
-    );
+    gen->GetCMakeInstance()->GetState()->GetEnabledLanguages());
   this->LanguagesReady = gen->LanguagesReady;
   this->ExtensionToLanguage = gen->ExtensionToLanguage;
   this->IgnoreExtensions = gen->IgnoreExtensions;
@@ -2041,39 +1849,32 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
   this->OutputExtensions = gen->OutputExtensions;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen)
 {
-  if(!gen->ConfiguredFilesPath.empty())
-    {
+  if (!gen->ConfiguredFilesPath.empty()) {
     this->ConfiguredFilesPath = gen->ConfiguredFilesPath;
-    }
-  else
-    {
+  } else {
     this->ConfiguredFilesPath = gen->CMakeInstance->GetHomeOutputDirectory();
     this->ConfiguredFilesPath += cmake::GetCMakeFilesDirectory();
-    }
+  }
 }
 
 bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp,
-                       cmState::Snapshot const& snp_) const
+                                   cmState::Snapshot const& snp_) const
 {
   cmState::Snapshot snp = snp_;
-  while (snp.IsValid())
-    {
-    if(snp == rootSnp)
-      {
+  while (snp.IsValid()) {
+    if (snp == rootSnp) {
       // No directory excludes itself.
       return false;
-      }
+    }
 
-    if(snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-      {
+    if (snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
       // This directory is excluded from its parent.
       return true;
-      }
-    snp = snp.GetBuildsystemDirectoryParent();
     }
+    snp = snp.GetBuildsystemDirectoryParent();
+  }
   return false;
 }
 
@@ -2091,19 +1892,18 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
 bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
                                    cmGeneratorTarget* target) const
 {
-  if(target->GetType() == cmState::INTERFACE_LIBRARY
-      || target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-    {
+  if (target->GetType() == cmState::INTERFACE_LIBRARY ||
+      target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
     // This target is excluded from its directory.
     return true;
-    }
+  }
   // This target is included in its directory.  Check whether the
   // directory is excluded.
   return this->IsExcluded(root, target->GetLocalGenerator());
 }
 
-void
-cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
+void cmGlobalGenerator::GetEnabledLanguages(
+  std::vector<std::string>& lang) const
 {
   lang = this->CMakeInstance->GetState()->GetEnabledLanguages();
 }
@@ -2111,11 +1911,10 @@ cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
 int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
 {
   std::map<std::string, int>::const_iterator it =
-                                   this->LanguageToLinkerPreference.find(lang);
-  if (it != this->LanguageToLinkerPreference.end())
-    {
+    this->LanguageToLinkerPreference.find(lang);
+  if (it != this->LanguageToLinkerPreference.end()) {
     return it->second;
-    }
+  }
   return 0;
 }
 
@@ -2123,64 +1922,54 @@ void cmGlobalGenerator::FillProjectMap()
 {
   this->ProjectMap.clear(); // make sure we start with a clean map
   unsigned int i;
-  for(i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     // for each local generator add all projects
     cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot();
     std::string name;
-    do
-      {
+    do {
       std::string snpProjName = snp.GetProjectName();
-      if (name != snpProjName)
-        {
+      if (name != snpProjName) {
         name = snpProjName;
         this->ProjectMap[name].push_back(this->LocalGenerators[i]);
-        }
-      snp = snp.GetBuildsystemDirectoryParent();
       }
-    while (snp.IsValid());
-    }
+      snp = snp.GetBuildsystemDirectoryParent();
+    } while (snp.IsValid());
+  }
 }
 
-cmMakefile*
-cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
+cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
 {
-  for(std::vector<cmMakefile*>::const_iterator it =
-      this->Makefiles.begin(); it != this->Makefiles.end(); ++it)
-    {
+  for (std::vector<cmMakefile*>::const_iterator it = this->Makefiles.begin();
+       it != this->Makefiles.end(); ++it) {
     std::string sd = (*it)->GetCurrentSourceDirectory();
-    if (sd == start_dir)
-      {
+    if (sd == start_dir) {
       return *it;
-      }
     }
+  }
   return 0;
 }
 
 ///! Find a local generator by its startdirectory
-cmLocalGenerator*
-cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
+cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(
+  const std::string& start_dir) const
 {
-  for(std::vector<cmLocalGenerator*>::const_iterator it =
-      this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator it =
+         this->LocalGenerators.begin();
+       it != this->LocalGenerators.end(); ++it) {
     std::string sd = (*it)->GetCurrentSourceDirectory();
-    if (sd == start_dir)
-      {
+    if (sd == start_dir) {
       return *it;
-      }
     }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::AddAlias(const std::string& name,
                                  std::string const& tgtName)
 {
   this->AliasTargets[name] = tgtName;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalGenerator::IsAlias(const std::string& name) const
 {
   return this->AliasTargets.find(name) != this->AliasTargets.end();
@@ -2188,98 +1977,83 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const
 
 void cmGlobalGenerator::IndexTarget(cmTarget* t)
 {
-  if (!t->IsImported() || t->IsImportedGloballyVisible())
-    {
+  if (!t->IsImported() || t->IsImportedGloballyVisible()) {
     this->TargetSearchIndex[t->GetName()] = t;
-    }
+  }
 }
 
 void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt)
 {
-  if (!gt->IsImported() || gt->IsImportedGloballyVisible())
-    {
+  if (!gt->IsImported() || gt->IsImportedGloballyVisible()) {
     this->GeneratorTargetSearchIndex[gt->GetName()] = gt;
-    }
+  }
 }
 
 cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
 {
   TargetMap::const_iterator i = this->TargetSearchIndex.find(name);
-  if (i != this->TargetSearchIndex.end())
-    {
+  if (i != this->TargetSearchIndex.end()) {
     return i->second;
-    }
+  }
   return 0;
 }
 
-cmGeneratorTarget*
-cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
+cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTargetImpl(
+  std::string const& name) const
 {
   GeneratorTargetMap::const_iterator i =
     this->GeneratorTargetSearchIndex.find(name);
-  if (i != this->GeneratorTargetSearchIndex.end())
-    {
+  if (i != this->GeneratorTargetSearchIndex.end()) {
     return i->second;
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
-cmTarget*
-cmGlobalGenerator::FindTarget(const std::string& name,
-                              bool excludeAliases) const
+cmTarget* cmGlobalGenerator::FindTarget(const std::string& name,
+                                        bool excludeAliases) const
 {
-  if (!excludeAliases)
-    {
+  if (!excludeAliases) {
     std::map<std::string, std::string>::const_iterator ai =
-        this->AliasTargets.find(name);
-    if (ai != this->AliasTargets.end())
-      {
+      this->AliasTargets.find(name);
+    if (ai != this->AliasTargets.end()) {
       return this->FindTargetImpl(ai->second);
-      }
     }
+  }
   return this->FindTargetImpl(name);
 }
 
-cmGeneratorTarget*
-cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
+cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget(
+  const std::string& name) const
 {
   std::map<std::string, std::string>::const_iterator ai =
-      this->AliasTargets.find(name);
-  if (ai != this->AliasTargets.end())
-    {
+    this->AliasTargets.find(name);
+  if (ai != this->AliasTargets.end()) {
     return this->FindGeneratorTargetImpl(ai->second);
-    }
+  }
   return this->FindGeneratorTargetImpl(name);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const
+bool cmGlobalGenerator::NameResolvesToFramework(
+  const std::string& libname) const
 {
-  if(cmSystemTools::IsPathToFramework(libname.c_str()))
-    {
+  if (cmSystemTools::IsPathToFramework(libname.c_str())) {
     return true;
-    }
+  }
 
-  if(cmTarget* tgt = this->FindTarget(libname))
-    {
-    if(tgt->IsFrameworkOnApple())
-       {
-       return true;
-       }
+  if (cmTarget* tgt = this->FindTarget(libname)) {
+    if (tgt->IsFrameworkOnApple()) {
+      return true;
     }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 inline std::string removeQuotes(const std::string& s)
 {
-  if(s[0] == '\"' && s[s.size()-1] == '\"')
-    {
-    return s.substr(1, s.size()-2);
-    }
+  if (s[0] == '\"' && s[s.size() - 1] == '\"') {
+    return s.substr(1, s.size() - 2);
+  }
   return s;
 }
 
@@ -2289,98 +2063,86 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
   const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
 
   // CPack
-  std::string workingDir =  mf->GetCurrentBinaryDirectory();
+  std::string workingDir = mf->GetCurrentBinaryDirectory();
   cmCustomCommandLines cpackCommandLines;
   std::vector<std::string> depends;
   cmCustomCommandLine singleLine;
   singleLine.push_back(cmSystemTools::GetCPackCommand());
-  if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
-    {
+  if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
     singleLine.push_back("-C");
     singleLine.push_back(cmakeCfgIntDir);
-    }
+  }
   singleLine.push_back("--config");
-  std::string configFile = mf->GetCurrentBinaryDirectory();;
+  std::string configFile = mf->GetCurrentBinaryDirectory();
+  ;
   configFile += "/CPackConfig.cmake";
   std::string relConfigFile = "./CPackConfig.cmake";
   singleLine.push_back(relConfigFile);
   cpackCommandLines.push_back(singleLine);
-  if ( this->GetPreinstallTargetName() )
-    {
+  if (this->GetPreinstallTargetName()) {
     depends.push_back(this->GetPreinstallTargetName());
-    }
-  else
-    {
+  } else {
     const char* noPackageAll =
       mf->GetDefinition("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY");
-    if(!noPackageAll || cmSystemTools::IsOff(noPackageAll))
-      {
+    if (!noPackageAll || cmSystemTools::IsOff(noPackageAll)) {
       depends.push_back(this->GetAllTargetName());
-      }
-    }
-  if(cmSystemTools::FileExists(configFile.c_str()))
-    {
-    (*targets)[this->GetPackageTargetName()]
-      = this->CreateGlobalTarget(this->GetPackageTargetName(),
-                                 "Run CPack packaging tool...",
-                                 &cpackCommandLines, depends,
-                                 workingDir.c_str(), /*uses_terminal*/true);
     }
+  }
+  if (cmSystemTools::FileExists(configFile.c_str())) {
+    (*targets)[this->GetPackageTargetName()] = this->CreateGlobalTarget(
+      this->GetPackageTargetName(), "Run CPack packaging tool...",
+      &cpackCommandLines, depends, workingDir.c_str(), /*uses_terminal*/ true);
+  }
   // CPack source
   const char* packageSourceTargetName = this->GetPackageSourceTargetName();
-  if ( packageSourceTargetName )
-    {
+  if (packageSourceTargetName) {
     cpackCommandLines.erase(cpackCommandLines.begin(),
                             cpackCommandLines.end());
     singleLine.erase(singleLine.begin(), singleLine.end());
     depends.erase(depends.begin(), depends.end());
     singleLine.push_back(cmSystemTools::GetCPackCommand());
     singleLine.push_back("--config");
-    configFile = mf->GetCurrentBinaryDirectory();;
+    configFile = mf->GetCurrentBinaryDirectory();
+    ;
     configFile += "/CPackSourceConfig.cmake";
     relConfigFile = "./CPackSourceConfig.cmake";
     singleLine.push_back(relConfigFile);
-    if(cmSystemTools::FileExists(configFile.c_str()))
-      {
+    if (cmSystemTools::FileExists(configFile.c_str())) {
       singleLine.push_back(configFile);
       cpackCommandLines.push_back(singleLine);
-      (*targets)[packageSourceTargetName]
-        = this->CreateGlobalTarget(packageSourceTargetName,
-                                   "Run CPack packaging tool for source...",
-                                   &cpackCommandLines, depends,
-                                   workingDir.c_str(), /*uses_terminal*/true);
-      }
+      (*targets)[packageSourceTargetName] = this->CreateGlobalTarget(
+        packageSourceTargetName, "Run CPack packaging tool for source...",
+        &cpackCommandLines, depends, workingDir.c_str(),
+        /*uses_terminal*/ true);
     }
+  }
 
   // Test
-  if(mf->IsOn("CMAKE_TESTING_ENABLED"))
-    {
+  if (mf->IsOn("CMAKE_TESTING_ENABLED")) {
     cpackCommandLines.erase(cpackCommandLines.begin(),
                             cpackCommandLines.end());
     singleLine.erase(singleLine.begin(), singleLine.end());
     depends.erase(depends.begin(), depends.end());
     singleLine.push_back(cmSystemTools::GetCTestCommand());
     singleLine.push_back("--force-new-ctest-process");
-    if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.')
-      {
+    if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
       singleLine.push_back("-C");
       singleLine.push_back(cmakeCfgIntDir);
-      }
-    else // TODO: This is a hack. Should be something to do with the generator
-      {
+    } else // TODO: This is a hack. Should be something to do with the
+           // generator
+    {
       singleLine.push_back("$(ARGS)");
-      }
-    cpackCommandLines.push_back(singleLine);
-    (*targets)[this->GetTestTargetName()]
-      = this->CreateGlobalTarget(this->GetTestTargetName(),
-        "Running tests...", &cpackCommandLines, depends, 0,
-        /*uses_terminal*/true);
     }
+    cpackCommandLines.push_back(singleLine);
+    (*targets)[this->GetTestTargetName()] =
+      this->CreateGlobalTarget(this->GetTestTargetName(), "Running tests...",
+                               &cpackCommandLines, depends, 0,
+                               /*uses_terminal*/ true);
+  }
 
-  //Edit Cache
+  // Edit Cache
   const char* editCacheTargetName = this->GetEditCacheTargetName();
-  if ( editCacheTargetName )
-    {
+  if (editCacheTargetName) {
     cpackCommandLines.erase(cpackCommandLines.begin(),
                             cpackCommandLines.end());
     singleLine.erase(singleLine.begin(), singleLine.end());
@@ -2388,36 +2150,29 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
 
     // Use generator preference for the edit_cache rule if it is defined.
     std::string edit_cmd = this->GetEditCacheCommand();
-    if (!edit_cmd.empty())
-      {
+    if (!edit_cmd.empty()) {
       singleLine.push_back(edit_cmd);
       singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
       singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
       cpackCommandLines.push_back(singleLine);
-      (*targets)[editCacheTargetName] =
-        this->CreateGlobalTarget(
-          editCacheTargetName, "Running CMake cache editor...",
-          &cpackCommandLines, depends, 0, /*uses_terminal*/true);
-      }
-    else
-      {
+      (*targets)[editCacheTargetName] = this->CreateGlobalTarget(
+        editCacheTargetName, "Running CMake cache editor...",
+        &cpackCommandLines, depends, 0, /*uses_terminal*/ true);
+    } else {
       singleLine.push_back(cmSystemTools::GetCMakeCommand());
       singleLine.push_back("-E");
       singleLine.push_back("echo");
       singleLine.push_back("No interactive CMake dialog available.");
       cpackCommandLines.push_back(singleLine);
-      (*targets)[editCacheTargetName] =
-        this->CreateGlobalTarget(
-          editCacheTargetName,
-          "No interactive CMake dialog available...",
-          &cpackCommandLines, depends, 0, /*uses_terminal*/false);
-      }
+      (*targets)[editCacheTargetName] = this->CreateGlobalTarget(
+        editCacheTargetName, "No interactive CMake dialog available...",
+        &cpackCommandLines, depends, 0, /*uses_terminal*/ false);
     }
+  }
 
-  //Rebuild Cache
+  // Rebuild Cache
   const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName();
-  if ( rebuildCacheTargetName )
-    {
+  if (rebuildCacheTargetName) {
     cpackCommandLines.erase(cpackCommandLines.begin(),
                             cpackCommandLines.end());
     singleLine.erase(singleLine.begin(), singleLine.end());
@@ -2426,157 +2181,131 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
     singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
     singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
     cpackCommandLines.push_back(singleLine);
-    (*targets)[rebuildCacheTargetName] =
-      this->CreateGlobalTarget(
-        rebuildCacheTargetName, "Running CMake to regenerate build system...",
-        &cpackCommandLines, depends, 0, /*uses_terminal*/true);
-    }
+    (*targets)[rebuildCacheTargetName] = this->CreateGlobalTarget(
+      rebuildCacheTargetName, "Running CMake to regenerate build system...",
+      &cpackCommandLines, depends, 0, /*uses_terminal*/ true);
+  }
 
-  //Install
+  // Install
   bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES");
-  if(this->InstallTargetEnabled && skipInstallRules)
-    {
+  if (this->InstallTargetEnabled && skipInstallRules) {
     mf->IssueMessage(cmake::WARNING,
-      "CMAKE_SKIP_INSTALL_RULES was enabled even though "
-      "installation rules have been specified");
-    }
-  else if(this->InstallTargetEnabled && !skipInstallRules)
-    {
-    if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.')
-      {
+                     "CMAKE_SKIP_INSTALL_RULES was enabled even though "
+                     "installation rules have been specified");
+  } else if (this->InstallTargetEnabled && !skipInstallRules) {
+    if (!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') {
       std::set<std::string>* componentsSet = &this->InstallComponents;
       cpackCommandLines.erase(cpackCommandLines.begin(),
-        cpackCommandLines.end());
+                              cpackCommandLines.end());
       depends.erase(depends.begin(), depends.end());
       std::ostringstream ostr;
-      if (!componentsSet->empty())
-        {
+      if (!componentsSet->empty()) {
         ostr << "Available install components are: ";
         ostr << cmWrap('"', *componentsSet, '"', " ");
-        }
-      else
-        {
+      } else {
         ostr << "Only default component available";
-        }
-      singleLine.push_back(ostr.str());
-      (*targets)["list_install_components"]
-        = this->CreateGlobalTarget("list_install_components",
-          ostr.str().c_str(),
-          &cpackCommandLines, depends, 0, /*uses_terminal*/false);
       }
+      singleLine.push_back(ostr.str());
+      (*targets)["list_install_components"] = this->CreateGlobalTarget(
+        "list_install_components", ostr.str().c_str(), &cpackCommandLines,
+        depends, 0, /*uses_terminal*/ false);
+    }
     std::string cmd = cmSystemTools::GetCMakeCommand();
     cpackCommandLines.erase(cpackCommandLines.begin(),
-      cpackCommandLines.end());
+                            cpackCommandLines.end());
     singleLine.erase(singleLine.begin(), singleLine.end());
     depends.erase(depends.begin(), depends.end());
-    if ( this->GetPreinstallTargetName() )
-      {
+    if (this->GetPreinstallTargetName()) {
       depends.push_back(this->GetPreinstallTargetName());
-      }
-    else
-      {
+    } else {
       const char* noall =
         mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
-      if(!noall || cmSystemTools::IsOff(noall))
-        {
+      if (!noall || cmSystemTools::IsOff(noall)) {
         depends.push_back(this->GetAllTargetName());
-        }
       }
-    if(mf->GetDefinition("CMake_BINARY_DIR") &&
-       !mf->IsOn("CMAKE_CROSSCOMPILING"))
-      {
+    }
+    if (mf->GetDefinition("CMake_BINARY_DIR") &&
+        !mf->IsOn("CMAKE_CROSSCOMPILING")) {
       // We are building CMake itself.  We cannot use the original
       // executable to install over itself.  The generator will
       // automatically convert this name to the build-time location.
       cmd = "cmake";
-      }
+    }
     singleLine.push_back(cmd);
-    if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
-      {
+    if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
       std::string cfgArg = "-DBUILD_TYPE=";
       bool iosPlatform = mf->PlatformIsAppleIos();
-      if(iosPlatform)
-        {
+      if (iosPlatform) {
         cfgArg += "$(CONFIGURATION)";
         singleLine.push_back(cfgArg);
         cfgArg = "-DEFFECTIVE_PLATFORM_NAME=$(EFFECTIVE_PLATFORM_NAME)";
-        }
-      else
-        {
+      } else {
         cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR");
-        }
-      singleLine.push_back(cfgArg);
       }
+      singleLine.push_back(cfgArg);
+    }
     singleLine.push_back("-P");
     singleLine.push_back("cmake_install.cmake");
     cpackCommandLines.push_back(singleLine);
-    (*targets)[this->GetInstallTargetName()] =
-      this->CreateGlobalTarget(
-        this->GetInstallTargetName(), "Install the project...",
-        &cpackCommandLines, depends, 0, /*uses_terminal*/true);
+    (*targets)[this->GetInstallTargetName()] = this->CreateGlobalTarget(
+      this->GetInstallTargetName(), "Install the project...",
+      &cpackCommandLines, depends, 0, /*uses_terminal*/ true);
 
     // install_local
-    if(const char* install_local = this->GetInstallLocalTargetName())
-      {
+    if (const char* install_local = this->GetInstallLocalTargetName()) {
       cmCustomCommandLine localCmdLine = singleLine;
 
-      localCmdLine.insert(localCmdLine.begin()+1,
-                                               "-DCMAKE_INSTALL_LOCAL_ONLY=1");
+      localCmdLine.insert(localCmdLine.begin() + 1,
+                          "-DCMAKE_INSTALL_LOCAL_ONLY=1");
       cpackCommandLines.erase(cpackCommandLines.begin(),
-                                                      cpackCommandLines.end());
+                              cpackCommandLines.end());
       cpackCommandLines.push_back(localCmdLine);
 
-      (*targets)[install_local] =
-        this->CreateGlobalTarget(
-          install_local, "Installing only the local directory...",
-          &cpackCommandLines, depends, 0, /*uses_terminal*/true);
-      }
+      (*targets)[install_local] = this->CreateGlobalTarget(
+        install_local, "Installing only the local directory...",
+        &cpackCommandLines, depends, 0, /*uses_terminal*/ true);
+    }
 
     // install_strip
     const char* install_strip = this->GetInstallStripTargetName();
-    if((install_strip !=0) && (mf->IsSet("CMAKE_STRIP")))
-      {
+    if ((install_strip != 0) && (mf->IsSet("CMAKE_STRIP"))) {
       cmCustomCommandLine stripCmdLine = singleLine;
 
-      stripCmdLine.insert(stripCmdLine.begin()+1,"-DCMAKE_INSTALL_DO_STRIP=1");
+      stripCmdLine.insert(stripCmdLine.begin() + 1,
+                          "-DCMAKE_INSTALL_DO_STRIP=1");
       cpackCommandLines.erase(cpackCommandLines.begin(),
-        cpackCommandLines.end());
+                              cpackCommandLines.end());
       cpackCommandLines.push_back(stripCmdLine);
 
-      (*targets)[install_strip] =
-        this->CreateGlobalTarget(
-          install_strip, "Installing the project stripped...",
-          &cpackCommandLines, depends, 0, /*uses_terminal*/true);
-      }
+      (*targets)[install_strip] = this->CreateGlobalTarget(
+        install_strip, "Installing the project stripped...",
+        &cpackCommandLines, depends, 0, /*uses_terminal*/ true);
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalGenerator::GetPredefinedTargetsFolder()
 {
-  const char* prop = this->GetCMakeInstance()->GetState()
-                         ->GetGlobalProperty("PREDEFINED_TARGETS_FOLDER");
+  const char* prop = this->GetCMakeInstance()->GetState()->GetGlobalProperty(
+    "PREDEFINED_TARGETS_FOLDER");
 
-  if (prop)
-    {
+  if (prop) {
     return prop;
-    }
+  }
 
   return "CMakePredefinedTargets";
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalGenerator::UseFolderProperty()
 {
-  const char* prop = this->GetCMakeInstance()->GetState()
-                         ->GetGlobalProperty("USE_FOLDERS");
+  const char* prop =
+    this->GetCMakeInstance()->GetState()->GetGlobalProperty("USE_FOLDERS");
 
   // If this property is defined, let the setter turn this on or off...
   //
-  if (prop)
-    {
+  if (prop) {
     return cmSystemTools::IsOn(prop);
-    }
+  }
 
   // By default, this feature is OFF, since it is not supported in the
   // Visual Studio Express editions until VS11:
@@ -2584,73 +2313,63 @@ bool cmGlobalGenerator::UseFolderProperty()
   return false;
 }
 
-//----------------------------------------------------------------------------
 cmTarget cmGlobalGenerator::CreateGlobalTarget(
   const std::string& name, const char* message,
-  const cmCustomCommandLines* commandLines,
-  std::vector<std::string> depends,
-  const char* workingDirectory,
-  bool uses_terminal)
+  const cmCustomCommandLines* commandLines, std::vector<std::string> depends,
+  const char* workingDirectory, bool uses_terminal)
 {
   // Package
   cmTarget target;
   target.SetType(cmState::GLOBAL_TARGET, name);
-  target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
+  target.SetProperty("EXCLUDE_FROM_ALL", "TRUE");
 
   std::vector<std::string> no_outputs;
   std::vector<std::string> no_byproducts;
   std::vector<std::string> no_depends;
   // Store the custom command in the target.
-  cmCustomCommand cc(0, no_outputs, no_byproducts, no_depends,
-                     *commandLines, 0, workingDirectory);
+  cmCustomCommand cc(0, no_outputs, no_byproducts, no_depends, *commandLines,
+                     0, workingDirectory);
   cc.SetUsesTerminal(uses_terminal);
   target.AddPostBuildCommand(cc);
   target.SetProperty("EchoString", message);
   std::vector<std::string>::iterator dit;
-  for ( dit = depends.begin(); dit != depends.end(); ++ dit )
-    {
+  for (dit = depends.begin(); dit != depends.end(); ++dit) {
     target.AddUtility(*dit);
-    }
+  }
 
   // Organize in the "predefined targets" folder:
   //
-  if (this->UseFolderProperty())
-    {
+  if (this->UseFolderProperty()) {
     target.SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
-    }
+  }
 
   return target;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalGenerator::GenerateRuleFile(std::string const& output) const
+std::string cmGlobalGenerator::GenerateRuleFile(
+  std::string const& output) const
 {
   std::string ruleFile = output;
   ruleFile += ".rule";
   const char* dir = this->GetCMakeCFGIntDir();
-  if(dir && dir[0] == '$')
-    {
+  if (dir && dir[0] == '$') {
     cmSystemTools::ReplaceString(ruleFile, dir,
                                  cmake::GetCMakeFilesDirectory());
-    }
+  }
   return ruleFile;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
-                                                  std::string const& l) const
+  std::string const& l) const
 {
   std::map<std::string, std::string>::const_iterator it =
-                              this->LanguageToOriginalSharedLibFlags.find(l);
-  if(it != this->LanguageToOriginalSharedLibFlags.end())
-    {
+    this->LanguageToOriginalSharedLibFlags.find(l);
+  if (it != this->LanguageToOriginalSharedLibFlags.end()) {
     return it->second;
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&,
                                                  const std::string&,
                                                  const std::string&,
@@ -2661,7 +2380,6 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&,
   // configuration.
 }
 
-//----------------------------------------------------------------------------
 cmGlobalGenerator::TargetDependSet const&
 cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
 {
@@ -2674,39 +2392,29 @@ bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
   // by one or more of the cmake generators.
 
   // Adding additional targets to this list will require a policy!
-  const char* reservedTargets[] =
-  {
-    "all", "ALL_BUILD",
-    "help",
-    "install", "INSTALL",
-    "preinstall",
-    "clean",
-    "edit_cache",
-    "rebuild_cache",
-    "test", "RUN_TESTS",
-    "package", "PACKAGE",
-    "package_source",
-    "ZERO_CHECK"
+  const char* reservedTargets[] = {
+    "all",        "ALL_BUILD", "help",       "install",        "INSTALL",
+    "preinstall", "clean",     "edit_cache", "rebuild_cache",  "test",
+    "RUN_TESTS",  "package",   "PACKAGE",    "package_source", "ZERO_CHECK"
   };
 
-  return std::find(cmArrayBegin(reservedTargets),
-                   cmArrayEnd(reservedTargets), name)
-      != cmArrayEnd(reservedTargets);
+  return std::find(cmArrayBegin(reservedTargets), cmArrayEnd(reservedTargets),
+                   name) != cmArrayEnd(reservedTargets);
 }
 
 void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
-                            cmExternalMakefileProjectGenerator *extraGenerator)
+  cmExternalMakefileProjectGenerator* extraGenerator)
 {
   this->ExtraGenerator = extraGenerator;
-  if (this->ExtraGenerator!=0)
-    {
+  if (this->ExtraGenerator != 0) {
     this->ExtraGenerator->SetGlobalGenerator(this);
-    }
+  }
 }
 
 std::string cmGlobalGenerator::GetExtraGeneratorName() const
 {
-  return this->ExtraGenerator? this->ExtraGenerator->GetName() : std::string();
+  return this->ExtraGenerator ? this->ExtraGenerator->GetName()
+                              : std::string();
 }
 
 void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename)
@@ -2714,78 +2422,65 @@ void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename)
   this->FilesReplacedDuringGenerate.push_back(filename);
 }
 
-void
-cmGlobalGenerator
-::GetFilesReplacedDuringGenerate(std::vector<std::string>& filenames)
+void cmGlobalGenerator::GetFilesReplacedDuringGenerate(
+  std::vector<std::string>& filenames)
 {
   filenames.clear();
-  std::copy(
-    this->FilesReplacedDuringGenerate.begin(),
-    this->FilesReplacedDuringGenerate.end(),
-    std::back_inserter(filenames));
+  std::copy(this->FilesReplacedDuringGenerate.begin(),
+            this->FilesReplacedDuringGenerate.end(),
+            std::back_inserter(filenames));
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
                                       TargetDependSet& originalTargets,
                                       cmLocalGenerator* root,
                                       GeneratorVector const& generators)
 {
   // loop over all local generators
-  for(std::vector<cmLocalGenerator*>::const_iterator i = generators.begin();
-      i != generators.end(); ++i)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator i = generators.begin();
+       i != generators.end(); ++i) {
     // check to make sure generator is not excluded
-    if(this->IsExcluded(root, *i))
-      {
+    if (this->IsExcluded(root, *i)) {
       continue;
-      }
+    }
     // Get the targets in the makefile
     std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets();
     // loop over all the targets
     for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-         l != tgts.end(); ++l)
-      {
+         l != tgts.end(); ++l) {
       cmGeneratorTarget* target = *l;
-      if(this->IsRootOnlyTarget(target) &&
-         target->GetLocalGenerator() != root)
-        {
+      if (this->IsRootOnlyTarget(target) &&
+          target->GetLocalGenerator() != root) {
         continue;
-        }
+      }
       // put the target in the set of original targets
       originalTargets.insert(target);
       // Get the set of targets that depend on target
       this->AddTargetDepends(target, projectTargets);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalGenerator::IsRootOnlyTarget(cmGeneratorTarget* target) const
 {
   return (target->GetType() == cmState::GLOBAL_TARGET ||
           target->GetName() == this->GetAllTargetName());
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::AddTargetDepends(cmGeneratorTarget const* target,
                                          TargetDependSet& projectTargets)
 {
   // add the target itself
-  if(projectTargets.insert(target).second)
-    {
+  if (projectTargets.insert(target).second) {
     // This is the first time we have encountered the target.
     // Recursively follow its dependencies.
     TargetDependSet const& ts = this->GetTargetDirectDepends(target);
-    for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i)
-      {
+    for (TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) {
       this->AddTargetDepends(*i, projectTargets);
-      }
     }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::AddToManifest(std::string const& f)
 {
   // Add to the content listing for the file's directory.
@@ -2796,68 +2491,59 @@ void cmGlobalGenerator::AddToManifest(std::string const& f)
   dc.All.insert(file);
 }
 
-//----------------------------------------------------------------------------
-std::set<std::string> const&
-cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk)
+std::set<std::string> const& cmGlobalGenerator::GetDirectoryContent(
+  std::string const& dir, bool needDisk)
 {
   DirectoryContent& dc = this->DirectoryContentMap[dir];
-  if(needDisk)
-    {
+  if (needDisk) {
     long mt = cmSystemTools::ModifiedTime(dir);
-    if (mt != dc.LastDiskTime)
-      {
+    if (mt != dc.LastDiskTime) {
       // Reset to non-loaded directory content.
       dc.All = dc.Generated;
 
       // Load the directory content from disk.
       cmsys::Directory d;
-      if(d.Load(dir))
-        {
+      if (d.Load(dir)) {
         unsigned long n = d.GetNumberOfFiles();
-        for(unsigned long i = 0; i < n; ++i)
-          {
+        for (unsigned long i = 0; i < n; ++i) {
           const char* f = d.GetFile(i);
-          if(strcmp(f, ".") != 0 && strcmp(f, "..") != 0)
-            {
+          if (strcmp(f, ".") != 0 && strcmp(f, "..") != 0) {
             dc.All.insert(f);
-            }
           }
         }
-      dc.LastDiskTime = mt;
       }
+      dc.LastDiskTime = mt;
     }
+  }
   return dc.All;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
-                               std::string const& content)
+void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
+                                    std::string const& content)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   // Ignore if there are no outputs.
-  if(outputs.empty())
-    {
+  if (outputs.empty()) {
     return;
-    }
+  }
 
   // Compute a hash of the rule.
   RuleHash hash;
   {
-  unsigned char const* data =
-    reinterpret_cast<unsigned char const*>(content.c_str());
-  int length = static_cast<int>(content.length());
-  cmsysMD5* sum = cmsysMD5_New();
-  cmsysMD5_Initialize(sum);
-  cmsysMD5_Append(sum, data, length);
-  cmsysMD5_FinalizeHex(sum, hash.Data);
-  cmsysMD5_Delete(sum);
+    unsigned char const* data =
+      reinterpret_cast<unsigned char const*>(content.c_str());
+    int length = static_cast<int>(content.length());
+    cmsysMD5* sum = cmsysMD5_New();
+    cmsysMD5_Initialize(sum);
+    cmsysMD5_Append(sum, data, length);
+    cmsysMD5_FinalizeHex(sum, hash.Data);
+    cmsysMD5_Delete(sum);
   }
 
   // Shorten the output name (in expected use case).
   cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot());
-  std::string fname = converter.Convert(
-        outputs[0], cmLocalGenerator::HOME_OUTPUT);
+  std::string fname =
+    converter.Convert(outputs[0], cmOutputConverter::HOME_OUTPUT);
 
   // Associate the hash with this output.
   this->RuleHashes[fname] = hash;
@@ -2867,7 +2553,6 @@ cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
 #endif
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::CheckRuleHashes()
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -2880,7 +2565,6 @@ void cmGlobalGenerator::CheckRuleHashes()
 #endif
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
                                         std::string const& home)
 {
@@ -2889,22 +2573,19 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
 #else
   cmsys::ifstream fin(pfile.c_str(), std::ios::in);
 #endif
-  if(!fin)
-    {
+  if (!fin) {
     return;
-    }
+  }
   std::string line;
   std::string fname;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
     // Line format is a 32-byte hex string followed by a space
     // followed by a file name (with no escaping).
 
     // Skip blank and comment lines.
-    if(line.size() < 34 || line[0] == '#')
-      {
+    if (line.size() < 34 || line[0] == '#') {
       continue;
-      }
+    }
 
     // Get the filename.
     fname = line.substr(33, line.npos);
@@ -2912,59 +2593,48 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
     // Look for a hash for this file's rule.
     std::map<std::string, RuleHash>::const_iterator rhi =
       this->RuleHashes.find(fname);
-    if(rhi != this->RuleHashes.end())
-      {
+    if (rhi != this->RuleHashes.end()) {
       // Compare the rule hash in the file to that we were given.
-      if(strncmp(line.c_str(), rhi->second.Data, 32) != 0)
-        {
+      if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) {
         // The rule has changed.  Delete the output so it will be
         // built again.
         fname = cmSystemTools::CollapseFullPath(fname, home.c_str());
         cmSystemTools::RemoveFile(fname);
-        }
       }
-    else
-      {
+    } else {
       // We have no hash for a rule previously listed.  This may be a
       // case where a user has turned off a build option and might
       // want to turn it back on later, so do not delete the file.
       // Instead, we keep the rule hash as long as the file exists so
       // that if the feature is turned back on and the rule has
       // changed the file is still rebuilt.
-      std::string fpath =
-        cmSystemTools::CollapseFullPath(fname, home.c_str());
-      if(cmSystemTools::FileExists(fpath.c_str()))
-        {
+      std::string fpath = cmSystemTools::CollapseFullPath(fname, home.c_str());
+      if (cmSystemTools::FileExists(fpath.c_str())) {
         RuleHash hash;
         strncpy(hash.Data, line.c_str(), 32);
         this->RuleHashes[fname] = hash;
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
 {
   // Now generate a new persistence file with the current hashes.
-  if(this->RuleHashes.empty())
-    {
+  if (this->RuleHashes.empty()) {
     cmSystemTools::RemoveFile(pfile);
-    }
-  else
-    {
+  } else {
     cmGeneratedFileStream fout(pfile.c_str());
     fout << "# Hashes of file build rules.\n";
-    for(std::map<std::string, RuleHash>::const_iterator
-          rhi = this->RuleHashes.begin(); rhi != this->RuleHashes.end(); ++rhi)
-      {
+    for (std::map<std::string, RuleHash>::const_iterator rhi =
+           this->RuleHashes.begin();
+         rhi != this->RuleHashes.end(); ++rhi) {
       fout.write(rhi->second.Data, 32);
       fout << " " << rhi->first << "\n";
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::WriteSummary()
 {
   // Record all target directories in a central location.
@@ -2973,24 +2643,20 @@ void cmGlobalGenerator::WriteSummary()
   fname += "/TargetDirectories.txt";
   cmGeneratedFileStream fout(fname.c_str());
 
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
     std::vector<cmGeneratorTarget*> tgts =
-        this->LocalGenerators[i]->GetGeneratorTargets();
+      this->LocalGenerators[i]->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
-         it != tgts.end(); ++it)
-      {
-      if ((*it)->GetType() == cmState::INTERFACE_LIBRARY)
-        {
+         it != tgts.end(); ++it) {
+      if ((*it)->GetType() == cmState::INTERFACE_LIBRARY) {
         continue;
-        }
+      }
       this->WriteSummary(*it);
       fout << (*it)->GetSupportDirectory() << "\n";
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
 {
   // Place the labels file in a per-target support directory.
@@ -3001,16 +2667,12 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   // Check whether labels are enabled for this target.
-  if(const char* value = target->GetProperty("LABELS"))
-    {
+  if (const char* value = target->GetProperty("LABELS")) {
     Json::Value lj_root(Json::objectValue);
-    Json::Value& lj_target =
-      lj_root["target"] = Json::objectValue;
+    Json::Value& lj_target = lj_root["target"] = Json::objectValue;
     lj_target["name"] = target->GetName();
-    Json::Value& lj_target_labels =
-      lj_target["labels"] = Json::arrayValue;
-    Json::Value& lj_sources =
-      lj_root["sources"] = Json::arrayValue;
+    Json::Value& lj_target_labels = lj_target["labels"] = Json::arrayValue;
+    Json::Value& lj_sources = lj_root["sources"] = Json::arrayValue;
 
     cmSystemTools::MakeDirectory(dir.c_str());
     cmGeneratedFileStream fout(file.c_str());
@@ -3019,69 +2681,60 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
     // these labels.
     std::vector<std::string> labels;
     cmSystemTools::ExpandListArgument(value, labels);
-    if(!labels.empty())
-      {
+    if (!labels.empty()) {
       fout << "# Target labels\n";
-      for(std::vector<std::string>::const_iterator li = labels.begin();
-          li != labels.end(); ++li)
-        {
+      for (std::vector<std::string>::const_iterator li = labels.begin();
+           li != labels.end(); ++li) {
         fout << " " << *li << "\n";
         lj_target_labels.append(*li);
-        }
       }
+    }
 
     // List the source files with any per-source labels.
     fout << "# Source files and their labels\n";
     std::vector<cmSourceFile*> sources;
     std::vector<std::string> configs;
     target->Target->GetMakefile()->GetConfigurations(configs);
-    if (configs.empty())
-      {
+    if (configs.empty()) {
       configs.push_back("");
-      }
-    for(std::vector<std::string>::const_iterator ci = configs.begin();
-        ci != configs.end(); ++ci)
-      {
+    }
+    for (std::vector<std::string>::const_iterator ci = configs.begin();
+         ci != configs.end(); ++ci) {
       target->GetSourceFiles(sources, *ci);
-      }
-    std::vector<cmSourceFile*>::const_iterator sourcesEnd
-        = cmRemoveDuplicates(sources);
-    for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
-        si != sourcesEnd; ++si)
-      {
+    }
+    std::vector<cmSourceFile*>::const_iterator sourcesEnd =
+      cmRemoveDuplicates(sources);
+    for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+         si != sourcesEnd; ++si) {
       Json::Value& lj_source = lj_sources.append(Json::objectValue);
       cmSourceFile* sf = *si;
       std::string const& sfp = sf->GetFullPath();
       fout << sfp << "\n";
       lj_source["file"] = sfp;
-      if(const char* svalue = sf->GetProperty("LABELS"))
-        {
+      if (const char* svalue = sf->GetProperty("LABELS")) {
         labels.clear();
-        Json::Value& lj_source_labels =
-          lj_source["labels"] = Json::arrayValue;
+        Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue;
         cmSystemTools::ExpandListArgument(svalue, labels);
-        for(std::vector<std::string>::const_iterator li = labels.begin();
-            li != labels.end(); ++li)
-          {
+        for (std::vector<std::string>::const_iterator li = labels.begin();
+             li != labels.end(); ++li) {
           fout << " " << *li << "\n";
           lj_source_labels.append(*li);
-          }
         }
       }
+    }
     cmGeneratedFileStream json_fout(json_file.c_str());
     json_fout << lj_root;
-    }
-  else
+  } else
 #endif
-    {
+  {
     cmSystemTools::RemoveFile(file);
     cmSystemTools::RemoveFile(json_file);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 // static
-std::string cmGlobalGenerator::EscapeJSON(const std::string& s) {
+std::string cmGlobalGenerator::EscapeJSON(const std::string& s)
+{
   std::string result;
   for (std::string::size_type i = 0; i < s.size(); ++i) {
     if (s[i] == '"' || s[i] == '\\') {
@@ -3092,49 +2745,42 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) {
   return result;
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::SetFilenameTargetDepends(cmSourceFile* sf,
-                                     std::set<cmGeneratorTarget const*> tgts)
+void cmGlobalGenerator::SetFilenameTargetDepends(
+  cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts)
 {
   this->FilenameTargetDepends[sf] = tgts;
 }
 
-//----------------------------------------------------------------------------
 std::set<cmGeneratorTarget const*> const&
-cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const {
+cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const
+{
   return this->FilenameTargetDepends[sf];
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::CreateEvaluationSourceFiles(
-                                              std::string const& config) const
+  std::string const& config) const
 {
   unsigned int i;
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     this->LocalGenerators[i]->CreateEvaluationFileOutputs(config);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::ProcessEvaluationFiles()
 {
   std::vector<std::string> generatedFiles;
   unsigned int i;
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     this->LocalGenerators[i]->ProcessEvaluationFiles(generatedFiles);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string cmGlobalGenerator::ExpandCFGIntDir(const std::string& str,
-                            const std::string& /*config*/) const
+std::string cmGlobalGenerator::ExpandCFGIntDir(
+  const std::string& str, const std::string& /*config*/) const
 {
   return str;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalGenerator::GenerateCPackPropertiesFile()
 {
   cmake::InstalledFilesMap const& installedFiles =
@@ -3149,24 +2795,22 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
   std::string path = this->CMakeInstance->GetHomeOutputDirectory();
   path += "/CPackProperties.cmake";
 
-  if(!cmSystemTools::FileExists(path.c_str()) && installedFiles.empty())
-    {
-      return true;
-    }
+  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)
-    {
+  for (cmake::InstalledFilesMap::const_iterator i = installedFiles.begin();
+       i != installedFiles.end(); ++i) {
     cmInstalledFile const& installedFile = i->second;
 
-    cmCPackPropertiesGenerator cpackPropertiesGenerator(
-      lg, installedFile, configs);
+    cmCPackPropertiesGenerator cpackPropertiesGenerator(lg, installedFile,
+                                                        configs);
 
     cpackPropertiesGenerator.Generate(file, config, configs);
-    }
+  }
 
   return true;
 }
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 48fa704..2575911 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -15,21 +15,21 @@
 
 #include "cmStandardIncludes.h"
 
-#include "cmTarget.h" // For cmTargets
-#include "cmTargetDepend.h" // For cmTargetDependSet
-#include "cmSystemTools.h" // for cmSystemTools::OutputOption
 #include "cmExportSetMap.h" // For cmExportSetMap
-#include "cmGeneratorTarget.h"
 #include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
 #include "cmState.h"
+#include "cmSystemTools.h"  // for cmSystemTools::OutputOption
+#include "cmTarget.h"       // For cmTargets
+#include "cmTargetDepend.h" // For cmTargetDependSet
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include "cmFileLockPool.h"
-# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
-#  include <unordered_map>
-# else
-#  include <cmsys/hash_map.hxx>
-# endif
+#include "cmFileLockPool.h"
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
+#include <cmsys/hash_map.hxx>
+#endif
 #endif
 
 class cmake;
@@ -55,19 +55,19 @@ public:
   cmGlobalGenerator(cmake* cm);
   virtual ~cmGlobalGenerator();
 
-  virtual cmLocalGenerator*
-  CreateLocalGenerator(cmMakefile* mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   ///! Get the name for this generator
   virtual std::string GetName() const { return "Generic"; }
 
   /** Check whether the given name matches the current generator.  */
   virtual bool MatchesGeneratorName(const std::string& name) const
-  { return this->GetName() == name; }
+  {
+    return this->GetName() == name;
+  }
 
   /** Tell the generator about the target system.  */
-  virtual bool SetSystemName(std::string const&, cmMakefile*)
-    { return true; }
+  virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; }
 
   /** Set the generator-specific platform name.  Returns true if platform
       is supported and false otherwise.  */
@@ -86,14 +86,15 @@ public:
   bool Compute();
   virtual void AddExtraIDETargets() {}
 
-  enum TargetTypes {
+  enum TargetTypes
+  {
     AllTargets,
     ImportedOnly
   };
 
-  void CreateImportedGenerationObjects(cmMakefile* mf,
-                             std::vector<std::string> const& targets,
-                             std::vector<cmGeneratorTarget const*>& exports);
+  void CreateImportedGenerationObjects(
+    cmMakefile* mf, std::vector<std::string> const& targets,
+    std::vector<cmGeneratorTarget const*>& exports);
   void CreateGenerationObjects(TargetTypes targetTypes = AllTargets);
 
   /**
@@ -114,31 +115,28 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 
   /**
    * Resolve the CMAKE_<lang>_COMPILER setting for the given language.
    * Intended to be called from EnableLanguage.
    */
-  void ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf,
+  void ResolveLanguageCompiler(const std::string& lang, cmMakefile* mf,
                                bool optional) const;
 
   /**
    * Try to determine system information, get it from another generator
    */
-  void EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
-                                            cmMakefile* mf);
+  void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, cmMakefile* mf);
 
   /**
    * Try running cmake and building a file. This is used for dynamically
    * loaded commands, not as part of the usual build process.
    */
   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);
-
+                 const std::string& projectName, const std::string& targetName,
+                 bool fast, std::string& output, cmMakefile* mf);
 
   /**
    * Build a file given the following information. This is a more direct call
@@ -148,22 +146,19 @@ public:
    */
   int Build(const std::string& srcdir, const std::string& bindir,
             const std::string& projectName, const std::string& targetName,
-            std::string& output,
-            const std::string& makeProgram, const std::string& config,
-            bool clean, bool fast, bool verbose,
-            double timeout,
-            cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE,
+            std::string& output, const std::string& makeProgram,
+            const std::string& config, bool clean, bool fast, bool verbose,
+            double timeout, cmSystemTools::OutputOption outputflag =
+                              cmSystemTools::OUTPUT_NONE,
             std::vector<std::string> const& nativeOptions =
-            std::vector<std::string>());
+              std::vector<std::string>());
 
   virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
     const std::string& projectName, const std::string& projectDir,
-    const std::string& targetName, const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    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 std::string& target,
@@ -172,36 +167,38 @@ public:
                                         bool ignoreErrors);
 
   ///! Get the CMake instance
-  cmake *GetCMakeInstance() const { return this->CMakeInstance; }
+  cmake* GetCMakeInstance() const { return this->CMakeInstance; }
 
   void SetConfiguredFilesPath(cmGlobalGenerator* gen);
-  const std::vector<cmMakefile*>& GetMakefiles() const {
-    return this->Makefiles;}
-  const std::vector<cmLocalGenerator *>& GetLocalGenerators() const {
-    return this->LocalGenerators;}
-
-  cmMakefile* GetCurrentMakefile() const
+  const std::vector<cmMakefile*>& GetMakefiles() const
+  {
+    return this->Makefiles;
+  }
+  const std::vector<cmLocalGenerator*>& GetLocalGenerators() const
   {
-    return this->CurrentMakefile;
+    return this->LocalGenerators;
   }
 
-  void SetCurrentMakefile(cmMakefile* mf)
-  {this->CurrentMakefile = mf;}
+  cmMakefile* GetCurrentMakefile() const { return this->CurrentMakefile; }
 
-  void AddMakefile(cmMakefile *mf);
+  void SetCurrentMakefile(cmMakefile* mf) { this->CurrentMakefile = mf; }
+
+  void AddMakefile(cmMakefile* mf);
 
   ///! Set an generator for an "external makefile based project"
   void SetExternalMakefileProjectGenerator(
-                           cmExternalMakefileProjectGenerator *extraGenerator);
+    cmExternalMakefileProjectGenerator* extraGenerator);
 
   std::string GetExtraGeneratorName() const;
 
   void AddInstallComponent(const char* component);
 
   const std::set<std::string>* GetInstallComponents() const
-    { return &this->InstallComponents; }
+  {
+    return &this->InstallComponents;
+  }
 
-  cmExportSetMap& GetExportSets() {return this->ExportSets;}
+  cmExportSetMap& GetExportSets() { return this->ExportSets; }
 
   /** Add a file to the manifest of generated targets for a configuration.  */
   void AddToManifest(std::string const& f);
@@ -241,11 +238,6 @@ public:
    */
   virtual void FindMakeProgram(cmMakefile*);
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  /** Is this the Visual Studio 6 generator?  */
-  bool IsForVS6() const { return this->GetName() == "Visual Studio 6"; }
-#endif
-
   ///! Find a target by name by searching the local generators.
   cmTarget* FindTarget(const std::string& name,
                        bool excludeAliases = false) const;
@@ -283,17 +275,17 @@ public:
 
   static bool IsReservedTarget(std::string const& name);
 
-  virtual const char* GetAllTargetName()         const { return "ALL_BUILD"; }
-  virtual const char* GetInstallTargetName()       const { return "INSTALL"; }
-  virtual const char* GetInstallLocalTargetName()  const { return 0; }
-  virtual const char* GetInstallStripTargetName()  const { return 0; }
-  virtual const char* GetPreinstallTargetName()    const { return 0; }
-  virtual const char* GetTestTargetName()        const { return "RUN_TESTS"; }
-  virtual const char* GetPackageTargetName()       const { return "PACKAGE"; }
+  virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
+  virtual const char* GetInstallTargetName() const { return "INSTALL"; }
+  virtual const char* GetInstallLocalTargetName() const { return 0; }
+  virtual const char* GetInstallStripTargetName() const { return 0; }
+  virtual const char* GetPreinstallTargetName() const { return 0; }
+  virtual const char* GetTestTargetName() const { return "RUN_TESTS"; }
+  virtual const char* GetPackageTargetName() const { return "PACKAGE"; }
   virtual const char* GetPackageSourceTargetName() const { return 0; }
-  virtual const char* GetEditCacheTargetName()     const { return 0; }
-  virtual const char* GetRebuildCacheTargetName()  const { return 0; }
-  virtual const char* GetCleanTargetName()         const { return 0; }
+  virtual const char* GetEditCacheTargetName() const { return 0; }
+  virtual const char* GetRebuildCacheTargetName() const { return 0; }
+  virtual const char* GetCleanTargetName() const { return 0; }
 
   // Lookup edit_cache target command preferred by this generator.
   virtual std::string GetEditCacheCommand() const { return ""; }
@@ -304,10 +296,13 @@ public:
   // what targets does the specified target depend on directly
   // via a target_link_libraries or add_dependencies
   TargetDependSet const& GetTargetDirectDepends(
-      const cmGeneratorTarget* target);
+    const cmGeneratorTarget* target);
 
   const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
-                                               const {return this->ProjectMap;}
+    const
+  {
+    return this->ProjectMap;
+  }
 
   // track files replaced during a Generate
   void FileReplacedDuringGenerate(const std::string& filename);
@@ -318,9 +313,9 @@ public:
 
   /** Return whether the given binary directory is unused.  */
   bool BinaryDirectoryIsNew(const std::string& dir)
-    {
+  {
     return this->BinaryDirectories.insert(dir).second;
-    }
+  }
 
   /** Return true if the generated build tree may contain multiple builds.
       i.e. "Can I build Debug and Release in the same tree?" */
@@ -336,13 +331,15 @@ public:
   void ProcessEvaluationFiles();
 
   std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets()
-    {return this->BuildExportSets;}
+  {
+    return this->BuildExportSets;
+  }
   void AddBuildExportSet(cmExportBuildFileGenerator*);
   void AddBuildExportExportSet(cmExportBuildFileGenerator*);
-  bool IsExportedTargetsFile(const std::string &filename) const;
-  bool GenerateImportFile(const std::string &file);
-  cmExportBuildFileGenerator*
-  GetExportedTargetsFile(const std::string &filename) const;
+  bool IsExportedTargetsFile(const std::string& filename) const;
+  bool GenerateImportFile(const std::string& file);
+  cmExportBuildFileGenerator* GetExportedTargetsFile(
+    const std::string& filename) const;
   void AddCMP0042WarnTarget(const std::string& target);
 
   virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
@@ -351,26 +348,29 @@ public:
 
   void CreateEvaluationSourceFiles(std::string const& config) const;
 
-  void SetFilenameTargetDepends(cmSourceFile* sf,
-                                std::set<const cmGeneratorTarget*> tgts);
-  const std::set<const cmGeneratorTarget*>&
-  GetFilenameTargetDepends(cmSourceFile* sf) const;
+  void SetFilenameTargetDepends(
+    cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts);
+  const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
+    cmSourceFile* sf) const;
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   cmFileLockPool& GetFileLockPool() { return FileLockPool; }
 #endif
 
   bool GetConfigureDoneCMP0026() const
-  { return this->ConfigureDoneCMP0026AndCMP0024; }
+  {
+    return this->ConfigureDoneCMP0026AndCMP0024;
+  }
 
   std::string MakeSilentFlag;
+
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
   // information, and also collect all the targets
   void GetTargetSets(TargetDependSet& projectTargets,
-                             TargetDependSet& originalTargets,
-                             cmLocalGenerator* root, GeneratorVector const&);
+                     TargetDependSet& originalTargets, cmLocalGenerator* root,
+                     GeneratorVector const&);
   bool IsRootOnlyTarget(cmGeneratorTarget* target) const;
   void AddTargetDepends(const cmGeneratorTarget* target,
                         TargetDependSet& projectTargets);
@@ -400,15 +400,15 @@ protected:
   virtual void InitializeProgressMarks() {}
   void CreateDefaultGlobalTargets(cmTargets* targets);
   cmTarget CreateGlobalTarget(const std::string& name, const char* message,
-    const cmCustomCommandLines* commandLines,
-    std::vector<std::string> depends, const char* workingDir,
-    bool uses_terminal);
+                              const cmCustomCommandLines* commandLines,
+                              std::vector<std::string> depends,
+                              const char* workingDir, bool uses_terminal);
 
   std::string FindMakeProgramFile;
   std::string ConfiguredFilesPath;
-  cmake *CMakeInstance;
+  cmake* CMakeInstance;
   std::vector<cmMakefile*> Makefiles;
-  std::vector<cmLocalGenerator *> LocalGenerators;
+  std::vector<cmLocalGenerator*> LocalGenerators;
   cmMakefile* CurrentMakefile;
   // map from project name to vector of local generators in that project
   std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap;
@@ -425,26 +425,25 @@ protected:
   cmTarget* FindTargetImpl(std::string const& name) const;
 
   cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
-  cmGeneratorTarget*
-  FindImportedGeneratorTargetImpl(std::string const& name) const;
+  cmGeneratorTarget* FindImportedGeneratorTargetImpl(
+    std::string const& name) const;
 
   const char* GetPredefinedTargetsFolder();
   virtual bool UseFolderProperty();
 
 private:
-
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
   typedef std::unordered_map<std::string, cmTarget*> TargetMap;
   typedef std::unordered_map<std::string, cmGeneratorTarget*>
     GeneratorTargetMap;
-# else
+#else
   typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
   typedef cmsys::hash_map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
-# endif
+#endif
 #else
-  typedef std::map<std::string,cmTarget *> TargetMap;
-  typedef std::map<std::string,cmGeneratorTarget *> GeneratorTargetMap;
+  typedef std::map<std::string, cmTarget*> TargetMap;
+  typedef std::map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
 #endif
   // Map efficiently from target name to cmTarget instance.
   // Do not use this structure for looping over all targets.
@@ -457,6 +456,7 @@ private:
   // in EnableLanguagesFromGenerator
   std::map<std::string, bool> IgnoreExtensions;
   std::set<std::string> LanguagesReady; // Ready for try_compile
+  std::set<std::string> LanguagesInProgress;
   std::map<std::string, std::string> OutputExtensions;
   std::map<std::string, std::string> LanguageToOutputExtension;
   std::map<std::string, std::string> ExtensionToLanguage;
@@ -464,7 +464,10 @@ private:
   std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
 
   // Record hashes for rules and outputs.
-  struct RuleHash { char Data[32]; };
+  struct RuleHash
+  {
+    char Data[32];
+  };
   std::map<std::string, RuleHash> RuleHashes;
   void CheckRuleHashes();
   void CheckRuleHashes(std::string const& pfile, std::string const& home);
@@ -493,9 +496,9 @@ private:
   TargetDependMap TargetDependencies;
 
   friend class cmake;
-  void CreateGeneratorTargets(TargetTypes targetTypes, cmMakefile* mf,
-                   cmLocalGenerator* lg,
-                   std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
+  void CreateGeneratorTargets(
+    TargetTypes targetTypes, cmMakefile* mf, cmLocalGenerator* lg,
+    std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
   void CreateGeneratorTargets(TargetTypes targetTypes);
 
   void ClearGeneratorMembers();
@@ -508,9 +511,16 @@ private:
     long LastDiskTime;
     std::set<std::string> All;
     std::set<std::string> Generated;
-    DirectoryContent(): LastDiskTime(-1) {}
-    DirectoryContent(DirectoryContent const& dc):
-      LastDiskTime(dc.LastDiskTime), All(dc.All), Generated(dc.Generated) {}
+    DirectoryContent()
+      : LastDiskTime(-1)
+    {
+    }
+    DirectoryContent(DirectoryContent const& dc)
+      : LastDiskTime(dc.LastDiskTime)
+      , All(dc.All)
+      , Generated(dc.Generated)
+    {
+    }
   };
   std::map<std::string, DirectoryContent> DirectoryContentMap;
 
@@ -521,7 +531,7 @@ private:
   std::set<std::string> CMP0042WarnTargets;
 
   mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> >
-  FilenameTargetDepends;
+    FilenameTargetDepends;
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   // Pool of file locks
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 18d4324..640497a 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -30,8 +30,8 @@ public:
   virtual ~cmGlobalGeneratorFactory() {}
 
   /** Create a GlobalGenerator */
-  virtual cmGlobalGenerator* CreateGlobalGenerator(
-      const std::string& n, cmake* cm) const = 0;
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& n,
+                                                   cmake* cm) const = 0;
 
   /** Get the documentation entry for this factory */
   virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
@@ -43,23 +43,30 @@ public:
   virtual bool SupportsToolset() const = 0;
 };
 
-template<class T>
+template <class T>
 class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
 {
 public:
   /** Create a GlobalGenerator */
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const {
-    if (name != T::GetActualName()) return 0;
-    return new T(cm); }
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
+    if (name != T::GetActualName())
+      return 0;
+    return new T(cm);
+  }
 
   /** Get the documentation entry for this factory */
-  virtual void GetDocumentation(cmDocumentationEntry& entry) const {
-    T::GetDocumentation(entry); }
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const
+  {
+    T::GetDocumentation(entry);
+  }
 
   /** Get the names of the current registered generators */
-  virtual void GetGenerators(std::vector<std::string>& names) const {
-    names.push_back(T::GetActualName()); }
+  virtual void GetGenerators(std::vector<std::string>& names) const
+  {
+    names.push_back(T::GetActualName());
+  }
 
   /** Determine whether or not this generator supports toolsets */
   virtual bool SupportsToolset() const { return T::SupportsToolset(); }
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 1bcbd26..0ae913e 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -10,19 +10,21 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalGhsMultiGenerator.h"
+
+#include "cmGeneratedFileStream.h"
+#include "cmGhsMultiTargetGenerator.h"
 #include "cmLocalGhsMultiGenerator.h"
 #include "cmMakefile.h"
 #include "cmVersion.h"
-#include "cmGeneratedFileStream.h"
-#include "cmGhsMultiTargetGenerator.h"
-#include <cmsys/SystemTools.hxx>
 #include <cmAlgorithms.h>
+#include <cmsys/SystemTools.hxx>
 
-const char *cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
-const char *cmGlobalGhsMultiGenerator::DEFAULT_MAKE_PROGRAM = "gbuild";
+const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
+const char* cmGlobalGhsMultiGenerator::DEFAULT_MAKE_PROGRAM = "gbuild";
 
 cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
-  : cmGlobalGenerator(cm), OSDirRelative(false)
+  : cmGlobalGenerator(cm)
+  , OSDirRelative(false)
 {
   this->GhsBuildCommandInitialized = false;
 }
@@ -32,13 +34,13 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
   cmDeleteAll(TargetFolderBuildStreams);
 }
 
-cmLocalGenerator *
-cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf)
+cmLocalGenerator* cmGlobalGhsMultiGenerator::CreateLocalGenerator(
+  cmMakefile* mf)
 {
   return new cmLocalGhsMultiGenerator(this, mf);
 }
 
-void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry)
+void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry& entry)
 {
   entry.Name = GetActualName();
   entry.Brief =
@@ -46,7 +48,7 @@ void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry)
 }
 
 void cmGlobalGhsMultiGenerator::EnableLanguage(
-  std::vector<std::string> const &l, cmMakefile *mf, bool optional)
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   mf->AddDefinition("CMAKE_SYSTEM_NAME", "GHS-MULTI");
   mf->AddDefinition("CMAKE_SYSTEM_PROCESSOR", "ARM");
@@ -67,38 +69,35 @@ void cmGlobalGhsMultiGenerator::EnableLanguage(
   mf->AddDefinition("CMAKE_CXX_COMPILER_ID", "GHS");
   mf->AddDefinition("CMAKE_CXX_COMPILER_FORCED", "TRUE");
 
-  if (!ghsCompRoot.empty())
-    {
-    static const char *compPreFix = "comp_";
+  if (!ghsCompRoot.empty()) {
+    static const char* compPreFix = "comp_";
     std::string compFilename =
       cmsys::SystemTools::FindLastString(ghsCompRoot.c_str(), compPreFix);
     cmsys::SystemTools::ReplaceString(compFilename, compPreFix, "");
     mf->AddDefinition("CMAKE_SYSTEM_VERSION", compFilename.c_str());
-    }
+  }
 
   mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files
   this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
 }
 
-void cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile *mf)
+void cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* mf)
 {
   // The GHS generator knows how to lookup its build tool
   // directly instead of needing a helper module to do it, so we
   // do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
-  if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
-    {
+  if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
     mf->AddDefinition("CMAKE_MAKE_PROGRAM",
                       this->GetGhsBuildCommand().c_str());
-    }
+  }
 }
 
-std::string const &cmGlobalGhsMultiGenerator::GetGhsBuildCommand()
+std::string const& cmGlobalGhsMultiGenerator::GetGhsBuildCommand()
 {
-  if (!this->GhsBuildCommandInitialized)
-    {
+  if (!this->GhsBuildCommandInitialized) {
     this->GhsBuildCommandInitialized = true;
     this->GhsBuildCommand = this->FindGhsBuildCommand();
-    }
+  }
   return this->GhsBuildCommand;
 }
 
@@ -108,10 +107,9 @@ std::string cmGlobalGhsMultiGenerator::FindGhsBuildCommand()
   userPaths.push_back(this->GetCompRoot());
   std::string makeProgram =
     cmSystemTools::FindProgram(DEFAULT_MAKE_PROGRAM, userPaths);
-  if (makeProgram.empty())
-    {
+  if (makeProgram.empty()) {
     makeProgram = DEFAULT_MAKE_PROGRAM;
-    }
+  }
   return makeProgram;
 }
 
@@ -119,8 +117,8 @@ std::string cmGlobalGhsMultiGenerator::GetCompRoot()
 {
   std::string output;
 
-  const std::vector<std::string>
-    potentialDirsHardPaths(GetCompRootHardPaths());
+  const std::vector<std::string> potentialDirsHardPaths(
+    GetCompRootHardPaths());
   const std::vector<std::string> potentialDirsRegistry(GetCompRootRegistry());
 
   std::vector<std::string> potentialDirsComplete;
@@ -136,16 +134,14 @@ std::string cmGlobalGhsMultiGenerator::GetCompRoot()
   for (std::vector<std::string>::const_iterator potentialDirsCompleteIt =
          potentialDirsComplete.begin();
        potentialDirsCompleteIt != potentialDirsComplete.end();
-       ++potentialDirsCompleteIt)
-    {
+       ++potentialDirsCompleteIt) {
     const std::string dirName(
       cmsys::SystemTools::GetFilenameName(*potentialDirsCompleteIt));
-    if (dirName.compare(outputDirName) > 0)
-      {
+    if (dirName.compare(outputDirName) > 0) {
       output = *potentialDirsCompleteIt;
       outputDirName = dirName;
-      }
     }
+  }
 
   return output;
 }
@@ -155,10 +151,9 @@ std::vector<std::string> cmGlobalGhsMultiGenerator::GetCompRootHardPaths()
   std::vector<std::string> output;
   cmSystemTools::Glob("C:/ghs", "comp_[^;]+", output);
   for (std::vector<std::string>::iterator outputIt = output.begin();
-       outputIt != output.end(); ++outputIt)
-    {
+       outputIt != output.end(); ++outputIt) {
     *outputIt = "C:/ghs/" + *outputIt;
-    }
+  }
   return output;
 }
 
@@ -181,21 +176,19 @@ std::vector<std::string> cmGlobalGhsMultiGenerator::GetCompRootRegistry()
 }
 
 void cmGlobalGhsMultiGenerator::OpenBuildFileStream(
-  std::string const &filepath, cmGeneratedFileStream **filestream)
+  std::string const& filepath, cmGeneratedFileStream** filestream)
 {
   // Get a stream where to generate things.
-  if (NULL == *filestream)
-    {
+  if (NULL == *filestream) {
     *filestream = new cmGeneratedFileStream(filepath.c_str());
-    if (NULL != *filestream)
-      {
+    if (NULL != *filestream) {
       OpenBuildFileStream(*filestream);
-      }
     }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::OpenBuildFileStream(
-  cmGeneratedFileStream *filestream)
+  cmGeneratedFileStream* filestream)
 {
   *filestream << "#!gbuild" << std::endl;
 }
@@ -212,155 +205,130 @@ void cmGlobalGhsMultiGenerator::OpenBuildFileStream()
   this->Open(std::string(""), buildFilePath, &this->TargetFolderBuildStreams);
   OpenBuildFileStream(GetBuildFileStream());
 
-  char const *osDir =
+  char const* osDir =
     this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR");
-  if (NULL == osDir)
-    {
+  if (NULL == osDir) {
     osDir = "";
     cmSystemTools::Error("GHS_OS_DIR cache variable must be set");
-    }
-  else
-    {
+  } else {
     this->GetCMakeInstance()->MarkCliAsUsed("GHS_OS_DIR");
-    }
+  }
   std::string fOSDir(this->trimQuotes(osDir));
-  cmSystemTools::ReplaceString(fOSDir, "\\", "/");
-  if (!fOSDir.empty() && ('c' == fOSDir[0] || 'C' == fOSDir[0]))
-    {
+  std::replace(fOSDir.begin(), fOSDir.end(), '\\', '/');
+  if (!fOSDir.empty() && ('c' == fOSDir[0] || 'C' == fOSDir[0])) {
     this->OSDirRelative = false;
-    }
-  else
-    {
+  } else {
     this->OSDirRelative = true;
-    }
+  }
 
-  char const *bspName =
+  char const* bspName =
     this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME");
-  if (NULL == bspName)
-    {
+  if (NULL == bspName) {
     bspName = "";
     cmSystemTools::Error("GHS_BSP_NAME cache variable must be set");
-    }
-  else
-    {
+  } else {
     this->GetCMakeInstance()->MarkCliAsUsed("GHS_BSP_NAME");
-    }
+  }
   std::string fBspName(this->trimQuotes(bspName));
-  cmSystemTools::ReplaceString(fBspName, "\\", "/");
+  std::replace(fBspName.begin(), fBspName.end(), '\\', '/');
   this->WriteMacros();
   this->WriteHighLevelDirectives();
 
   GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, this->GetBuildFileStream());
   this->WriteDisclaimer(this->GetBuildFileStream());
   *this->GetBuildFileStream() << "# Top Level Project File" << std::endl;
-  if (!fBspName.empty())
-    {
+  if (!fBspName.empty()) {
     *this->GetBuildFileStream() << "    -bsp " << fBspName << std::endl;
-    }
+  }
   this->WriteCompilerOptions(fOSDir);
 }
 
 void cmGlobalGhsMultiGenerator::CloseBuildFileStream(
-  cmGeneratedFileStream **filestream)
+  cmGeneratedFileStream** filestream)
 {
-  if (filestream)
-    {
+  if (filestream) {
     delete *filestream;
     *filestream = NULL;
-    }
-  else
-    {
+  } else {
     cmSystemTools::Error("Build file stream was not open.");
-    }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::Generate()
 {
   this->cmGlobalGenerator::Generate();
 
-  if (!this->LocalGenerators.empty())
-    {
+  if (!this->LocalGenerators.empty()) {
     this->OpenBuildFileStream();
 
     // Build all the folder build files
-    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-      {
-      cmLocalGhsMultiGenerator *lg =
-        static_cast<cmLocalGhsMultiGenerator *>(this->LocalGenerators[i]);
+    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
+      cmLocalGhsMultiGenerator* lg =
+        static_cast<cmLocalGhsMultiGenerator*>(this->LocalGenerators[i]);
       std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
       this->UpdateBuildFiles(tgts);
-      }
     }
+  }
 
   cmDeleteAll(TargetFolderBuildStreams);
   this->TargetFolderBuildStreams.clear();
 }
 
 void cmGlobalGhsMultiGenerator::GenerateBuildCommand(
-  std::vector<std::string> &makeCommand, const std::string &makeProgram,
-  const std::string & /*projectName*/, const std::string & /*projectDir*/,
-  const std::string &targetName, const std::string & /*config*/,
-  bool /*fast*/, bool /*verbose*/,
-  std::vector<std::string> const &makeOptions)
+  std::vector<std::string>& makeCommand, const std::string& makeProgram,
+  const std::string& /*projectName*/, const std::string& /*projectDir*/,
+  const std::string& targetName, const std::string& /*config*/, bool /*fast*/,
+  bool /*verbose*/, std::vector<std::string> const& makeOptions)
 {
   makeCommand.push_back(
-    this->SelectMakeProgram(makeProgram, this->GetGhsBuildCommand())
-    );
-
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
-  if (!targetName.empty())
-    {
-    if (targetName == "clean")
-      {
+    this->SelectMakeProgram(makeProgram, this->GetGhsBuildCommand()));
+
+  makeCommand.insert(makeCommand.end(), makeOptions.begin(),
+                     makeOptions.end());
+  if (!targetName.empty()) {
+    if (targetName == "clean") {
       makeCommand.push_back("-clean");
-      }
-    else
-      {
+    } else {
       makeCommand.push_back(targetName);
-      }
     }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::WriteMacros()
 {
-  char const *ghsGpjMacros =
+  char const* ghsGpjMacros =
     this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
-  if (NULL != ghsGpjMacros)
-    {
+  if (NULL != ghsGpjMacros) {
     std::vector<std::string> expandedList;
     cmSystemTools::ExpandListArgument(std::string(ghsGpjMacros), expandedList);
     for (std::vector<std::string>::const_iterator expandedListI =
            expandedList.begin();
-         expandedListI != expandedList.end(); ++expandedListI)
-      {
+         expandedListI != expandedList.end(); ++expandedListI) {
       *this->GetBuildFileStream() << "macro " << *expandedListI << std::endl;
-      }
     }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives()
 {
   *this->GetBuildFileStream() << "primaryTarget=arm_integrity.tgt"
                               << std::endl;
-  char const *const customization =
+  char const* const customization =
     this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
-  if (NULL != customization && strlen(customization) > 0)
-    {
-    *this->GetBuildFileStream() << "customization="
-                                << trimQuotes(customization)
-                                << std::endl;
+  if (NULL != customization && strlen(customization) > 0) {
+    *this->GetBuildFileStream()
+      << "customization=" << trimQuotes(customization) << std::endl;
     this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION");
-    }
+  }
 }
 
-void cmGlobalGhsMultiGenerator::WriteCompilerOptions(std::string const &fOSDir)
+void cmGlobalGhsMultiGenerator::WriteCompilerOptions(std::string const& fOSDir)
 {
   *this->GetBuildFileStream() << "    -os_dir=\"" << fOSDir << "\""
                               << std::endl;
 }
 
-void cmGlobalGhsMultiGenerator::WriteDisclaimer(std::ostream *os)
+void cmGlobalGhsMultiGenerator::WriteDisclaimer(std::ostream* os)
 {
   (*os) << "#" << std::endl
         << "# CMAKE generated file: DO NOT EDIT!" << std::endl
@@ -371,10 +339,10 @@ void cmGlobalGhsMultiGenerator::WriteDisclaimer(std::ostream *os)
 }
 
 void cmGlobalGhsMultiGenerator::AddFilesUpToPath(
-  cmGeneratedFileStream *mainBuildFile,
-  std::map<std::string, cmGeneratedFileStream *> *targetFolderBuildStreams,
-  char const *homeOutputDirectory, std::string const &path,
-  GhsMultiGpj::Types projType, std::string const &relPath)
+  cmGeneratedFileStream* mainBuildFile,
+  std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
+  char const* homeOutputDirectory, std::string const& path,
+  GhsMultiGpj::Types projType, std::string const& relPath)
 {
   std::string workingPath(path);
   cmSystemTools::ConvertToUnixSlashes(workingPath);
@@ -382,55 +350,50 @@ void cmGlobalGhsMultiGenerator::AddFilesUpToPath(
     cmSystemTools::SplitString(workingPath);
   std::string workingRelPath(relPath);
   cmSystemTools::ConvertToUnixSlashes(workingRelPath);
-  if (!workingRelPath.empty())
-    {
+  if (!workingRelPath.empty()) {
     workingRelPath += "/";
-    }
+  }
   std::string pathUpTo;
   for (std::vector<cmsys::String>::const_iterator splitPathI =
          splitPath.begin();
-       splitPath.end() != splitPathI; ++splitPathI)
-    {
+       splitPath.end() != splitPathI; ++splitPathI) {
     pathUpTo += *splitPathI;
     if (targetFolderBuildStreams->end() ==
-        targetFolderBuildStreams->find(pathUpTo))
-      {
+        targetFolderBuildStreams->find(pathUpTo)) {
       AddFilesUpToPathNewBuildFile(
-        mainBuildFile, targetFolderBuildStreams, homeOutputDirectory,
-        pathUpTo, splitPath.begin() == splitPathI, workingRelPath, projType);
-      }
+        mainBuildFile, targetFolderBuildStreams, homeOutputDirectory, pathUpTo,
+        splitPath.begin() == splitPathI, workingRelPath, projType);
+    }
     AddFilesUpToPathAppendNextFile(targetFolderBuildStreams, pathUpTo,
                                    splitPathI, splitPath.end(), projType);
     pathUpTo += "/";
-    }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::Open(
-  std::string const &mapKeyName, std::string const &fileName,
-  std::map<std::string, cmGeneratedFileStream *> *fileMap)
+  std::string const& mapKeyName, std::string const& fileName,
+  std::map<std::string, cmGeneratedFileStream*>* fileMap)
 {
-  if (fileMap->end() == fileMap->find(fileName))
-    {
-    cmGeneratedFileStream *temp(new cmGeneratedFileStream);
+  if (fileMap->end() == fileMap->find(fileName)) {
+    cmGeneratedFileStream* temp(new cmGeneratedFileStream);
     temp->open(fileName.c_str());
     (*fileMap)[mapKeyName] = temp;
-    }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::AddFilesUpToPathNewBuildFile(
-  cmGeneratedFileStream *mainBuildFile,
-  std::map<std::string, cmGeneratedFileStream *> *targetFolderBuildStreams,
-  char const *homeOutputDirectory, std::string const &pathUpTo,
-  bool const isFirst, std::string const &relPath,
+  cmGeneratedFileStream* mainBuildFile,
+  std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
+  char const* homeOutputDirectory, std::string const& pathUpTo,
+  bool const isFirst, std::string const& relPath,
   GhsMultiGpj::Types const projType)
 {
   // create folders up to file path
   std::string absPath = std::string(homeOutputDirectory) + "/" + relPath;
   std::string newPath = absPath + pathUpTo;
-  if (!cmSystemTools::FileExists(newPath.c_str()))
-    {
+  if (!cmSystemTools::FileExists(newPath.c_str())) {
     cmSystemTools::MakeDirectory(newPath.c_str());
-    }
+  }
 
   // Write out to filename for first time
   std::string relFilename(GetFileNameFromPath(pathUpTo));
@@ -441,16 +404,15 @@ void cmGlobalGhsMultiGenerator::AddFilesUpToPathNewBuildFile(
   WriteDisclaimer((*targetFolderBuildStreams)[pathUpTo]);
 
   // Add to main build file
-  if (isFirst)
-    {
+  if (isFirst) {
     *mainBuildFile << relFilename << " ";
     GhsMultiGpj::WriteGpjTag(projType, mainBuildFile);
-    }
+  }
 }
 
 void cmGlobalGhsMultiGenerator::AddFilesUpToPathAppendNextFile(
-  std::map<std::string, cmGeneratedFileStream *> *targetFolderBuildStreams,
-  std::string const &pathUpTo,
+  std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
+  std::string const& pathUpTo,
   std::vector<cmsys::String>::const_iterator splitPathI,
   std::vector<cmsys::String>::const_iterator end,
   GhsMultiGpj::Types const projType)
@@ -458,25 +420,23 @@ void cmGlobalGhsMultiGenerator::AddFilesUpToPathAppendNextFile(
   std::vector<cmsys::String>::const_iterator splitPathNextI = splitPathI + 1;
   if (end != splitPathNextI &&
       targetFolderBuildStreams->end() ==
-      targetFolderBuildStreams->find(pathUpTo + "/" + *splitPathNextI))
-    {
+        targetFolderBuildStreams->find(pathUpTo + "/" + *splitPathNextI)) {
     std::string nextFilename(*splitPathNextI);
     nextFilename = GetFileNameFromPath(nextFilename);
     *(*targetFolderBuildStreams)[pathUpTo] << nextFilename << " ";
     GhsMultiGpj::WriteGpjTag(projType, (*targetFolderBuildStreams)[pathUpTo]);
-    }
+  }
 }
 
-std::string
-cmGlobalGhsMultiGenerator::GetFileNameFromPath(std::string const &path)
+std::string cmGlobalGhsMultiGenerator::GetFileNameFromPath(
+  std::string const& path)
 {
   std::string output(path);
-  if (!path.empty())
-    {
+  if (!path.empty()) {
     cmSystemTools::ConvertToUnixSlashes(output);
     std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(output);
     output += "/" + splitPath.back() + FILE_EXTENSION;
-    }
+  }
   return output;
 }
 
@@ -484,64 +444,56 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
   std::vector<cmGeneratorTarget*> tgts)
 {
   for (std::vector<cmGeneratorTarget*>::iterator tgtsI = tgts.begin();
-       tgtsI != tgts.end(); ++tgtsI)
-    {
-    const cmGeneratorTarget *tgt = *tgtsI;
-    if (IsTgtForBuild(tgt))
-      {
-      char const *rawFolderName = tgt->GetProperty("FOLDER");
-      if (NULL == rawFolderName)
-        {
+       tgtsI != tgts.end(); ++tgtsI) {
+    const cmGeneratorTarget* tgt = *tgtsI;
+    if (IsTgtForBuild(tgt)) {
+      char const* rawFolderName = tgt->GetProperty("FOLDER");
+      if (NULL == rawFolderName) {
         rawFolderName = "";
-        }
+      }
       std::string folderName(rawFolderName);
       if (this->TargetFolderBuildStreams.end() ==
-          this->TargetFolderBuildStreams.find(folderName))
-        {
+          this->TargetFolderBuildStreams.find(folderName)) {
         this->AddFilesUpToPath(
           GetBuildFileStream(), &this->TargetFolderBuildStreams,
           this->GetCMakeInstance()->GetHomeOutputDirectory(), folderName,
           GhsMultiGpj::PROJECT);
-        }
+      }
       std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(
-            cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt));
+        cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt));
       std::string foldNameRelBuildFile(*(splitPath.end() - 2) + "/" +
                                        splitPath.back());
       *this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile
                                                   << " ";
-      GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(
-                                 tgt),
+      GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(tgt),
                                this->TargetFolderBuildStreams[folderName]);
-      }
     }
+  }
 }
 
-bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmGeneratorTarget *tgt)
+bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmGeneratorTarget* tgt)
 {
   const std::string config =
     tgt->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
-  std::vector<cmSourceFile *> tgtSources;
+  std::vector<cmSourceFile*> tgtSources;
   tgt->GetSourceFiles(tgtSources, config);
   bool tgtInBuild = true;
-  char const *excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL");
+  char const* excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL");
   if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
-    '\0' == excludeFromAll[1])
-  {
+      '\0' == excludeFromAll[1]) {
     tgtInBuild = false;
   }
   return !tgtSources.empty() && tgtInBuild;
 }
 
-std::string cmGlobalGhsMultiGenerator::trimQuotes(std::string const &str)
+std::string cmGlobalGhsMultiGenerator::trimQuotes(std::string const& str)
 {
   std::string result;
   result.reserve(str.size());
-  for (const char *ch = str.c_str(); *ch != '\0'; ++ch)
-    {
-    if (*ch != '"')
-      {
+  for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
+    if (*ch != '"') {
       result += *ch;
-      }
     }
+  }
   return result;
 }
diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h
index 6f86c5d..473d153 100644
--- a/Source/cmGlobalGhsMultiGenerator.h
+++ b/Source/cmGlobalGhsMultiGenerator.h
@@ -12,9 +12,10 @@
 #ifndef cmGhsMultiGenerator_h
 #define cmGhsMultiGenerator_h
 
-#include "cmGlobalGeneratorFactory.h"
 #include "cmGlobalGenerator.h"
+
 #include "cmGhsMultiGpj.h"
+#include "cmGlobalGeneratorFactory.h"
 
 class cmGeneratedFileStream;
 
@@ -22,16 +23,18 @@ class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
 {
 public:
   /// The default name of GHS MULTI's build file. Typically: monolith.gpj.
-  static const char *FILE_EXTENSION;
+  static const char* FILE_EXTENSION;
 
   cmGlobalGhsMultiGenerator(cmake* cm);
   ~cmGlobalGhsMultiGenerator();
 
-  static cmGlobalGeneratorFactory *NewFactory()
-  { return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>();
+  }
 
   ///! create the correct local generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   /// @return the name of this generator.
   static std::string GetActualName() { return "Green Hills MULTI"; }
@@ -40,7 +43,7 @@ public:
   virtual std::string GetName() const { return this->GetActualName(); }
 
   /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
-  static void GetDocumentation(cmDocumentationEntry &entry);
+  static void GetDocumentation(cmDocumentationEntry& entry);
 
   /**
    * Utilized by the generator factory to determine if this generator
@@ -52,49 +55,48 @@ public:
   * Try to determine system information such as shared library
   * extension, pthreads, byte order etc.
   */
-  virtual void EnableLanguage(std::vector<std::string> const &languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
   /*
   * Determine what program to use for building the project.
   */
-  virtual void FindMakeProgram(cmMakefile *);
+  virtual void FindMakeProgram(cmMakefile*);
 
-  cmGeneratedFileStream *GetBuildFileStream()
+  cmGeneratedFileStream* GetBuildFileStream()
   {
     return this->TargetFolderBuildStreams[""];
   }
 
-  static void OpenBuildFileStream(std::string const &filepath,
-                                  cmGeneratedFileStream **filestream);
-  static void OpenBuildFileStream(cmGeneratedFileStream *filestream);
-  static void CloseBuildFileStream(cmGeneratedFileStream **filestream);
+  static void OpenBuildFileStream(std::string const& filepath,
+                                  cmGeneratedFileStream** filestream);
+  static void OpenBuildFileStream(cmGeneratedFileStream* filestream);
+  static void CloseBuildFileStream(cmGeneratedFileStream** filestream);
   /// Write the common disclaimer text at the top of each build file.
-  static void WriteDisclaimer(std::ostream *os);
+  static void WriteDisclaimer(std::ostream* os);
   std::vector<std::string> GetLibDirs() { return this->LibDirs; }
 
   static void AddFilesUpToPath(
-      cmGeneratedFileStream *mainBuildFile,
-      std::map<std::string, cmGeneratedFileStream *> *targetFolderBuildStreams,
-      char const *homeOutputDirectory, std::string const &path,
-      GhsMultiGpj::Types projType, std::string const &relPath = "");
-  static void Open(std::string const &mapKeyName, std::string const &fileName,
-                   std::map<std::string, cmGeneratedFileStream *> *fileMap);
-
-  static std::string trimQuotes(std::string const &str);
+    cmGeneratedFileStream* mainBuildFile,
+    std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
+    char const* homeOutputDirectory, std::string const& path,
+    GhsMultiGpj::Types projType, std::string const& relPath = "");
+  static void Open(std::string const& mapKeyName, std::string const& fileName,
+                   std::map<std::string, cmGeneratedFileStream*>* fileMap);
+
+  static std::string trimQuotes(std::string const& str);
   inline bool IsOSDirRelative() { return this->OSDirRelative; }
 
 protected:
   virtual void Generate();
   virtual void GenerateBuildCommand(
-      std::vector<std::string> &makeCommand, const std::string &makeProgram,
-      const std::string &projectName, const std::string &projectDir,
-      const std::string &targetName, const std::string &config, bool fast,
-      bool verbose,
-      std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    std::vector<std::string> const& makeOptions = std::vector<std::string>());
 
 private:
-  std::string const &GetGhsBuildCommand();
+  std::string const& GetGhsBuildCommand();
   std::string FindGhsBuildCommand();
   std::string GetCompRoot();
   std::vector<std::string> GetCompRootHardPaths();
@@ -103,32 +105,32 @@ private:
 
   void WriteMacros();
   void WriteHighLevelDirectives();
-  void WriteCompilerOptions(std::string const &fOSDir);
+  void WriteCompilerOptions(std::string const& fOSDir);
 
   static void AddFilesUpToPathNewBuildFile(
-      cmGeneratedFileStream *mainBuildFile,
-      std::map<std::string, cmGeneratedFileStream *> *targetFolderBuildStreams,
-      char const *homeOutputDirectory, std::string const &pathUpTo,
-      bool isFirst, std::string const &relPath, GhsMultiGpj::Types projType);
+    cmGeneratedFileStream* mainBuildFile,
+    std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
+    char const* homeOutputDirectory, std::string const& pathUpTo, bool isFirst,
+    std::string const& relPath, GhsMultiGpj::Types projType);
   static void AddFilesUpToPathAppendNextFile(
-      std::map<std::string, cmGeneratedFileStream *> *targetFolderBuildStreams,
-      std::string const &pathUpTo,
-      std::vector<cmsys::String>::const_iterator splitPathI,
-      std::vector<cmsys::String>::const_iterator end,
-      GhsMultiGpj::Types projType);
-  static std::string GetFileNameFromPath(std::string const &path);
+    std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
+    std::string const& pathUpTo,
+    std::vector<cmsys::String>::const_iterator splitPathI,
+    std::vector<cmsys::String>::const_iterator end,
+    GhsMultiGpj::Types projType);
+  static std::string GetFileNameFromPath(std::string const& path);
   void UpdateBuildFiles(std::vector<cmGeneratorTarget*> tgts);
-  bool IsTgtForBuild(const cmGeneratorTarget *tgt);
+  bool IsTgtForBuild(const cmGeneratorTarget* tgt);
 
-  std::vector<cmGeneratedFileStream *> TargetSubProjects;
-  std::map<std::string, cmGeneratedFileStream *> TargetFolderBuildStreams;
+  std::vector<cmGeneratedFileStream*> TargetSubProjects;
+  std::map<std::string, cmGeneratedFileStream*> TargetFolderBuildStreams;
 
   std::vector<std::string> LibDirs;
 
   bool OSDirRelative;
   bool GhsBuildCommandInitialized;
   std::string GhsBuildCommand;
-  static const char *DEFAULT_MAKE_PROGRAM;
+  static const char* DEFAULT_MAKE_PROGRAM;
 };
 
 #endif
diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx
index 3f33f91..0bdd624 100644
--- a/Source/cmGlobalJOMMakefileGenerator.cxx
+++ b/Source/cmGlobalJOMMakefileGenerator.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalJOMMakefileGenerator.h"
+
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 
@@ -28,10 +29,8 @@ cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator(cmake* cm)
   this->MakeSilentFlag = "/nologo";
 }
 
-void cmGlobalJOMMakefileGenerator
-::EnableLanguage(std::vector<std::string>const& l,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalJOMMakefileGenerator::EnableLanguage(
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   // pick a default
   mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
@@ -39,26 +38,24 @@ void cmGlobalJOMMakefileGenerator
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalJOMMakefileGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalJOMMakefileGenerator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalJOMMakefileGenerator::GetActualName();
   entry.Brief = "Generates JOM makefiles.";
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
-                                                  std::string const& lang,
-                                                  const char* envVar) const
+void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(
+  std::ostream& os, std::string const& lang, const char* envVar) const
 {
-  if(lang == "CXX" || lang == "C")
-    {
+  if (lang == "CXX" || lang == "C") {
+    /* clang-format off */
     os <<
       "To use the JOM generator with Visual C++, cmake must be run from a "
       "shell that can use the compiler cl from the command line. This "
       "environment is unable to invoke the cl compiler. To fix this problem, "
       "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n";
-    }
+    /* clang-format on */
+  }
   this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
 }
diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h
index 1869fed..bb2273a 100644
--- a/Source/cmGlobalJOMMakefileGenerator.h
+++ b/Source/cmGlobalJOMMakefileGenerator.h
@@ -23,15 +23,18 @@ class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalJOMMakefileGenerator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalJOMMakefileGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<cmGlobalJOMMakefileGenerator>();
+  }
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalJOMMakefileGenerator::GetActualName();}
+  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 std::string 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);
@@ -40,8 +43,9 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
+
 private:
   void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
                            const char* envVar) const;
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index 018ab24..5c1e733 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -11,28 +11,29 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalKdevelopGenerator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
-#include "cmake.h"
 #include "cmSourceFile.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
+#include "cmXMLWriter.h"
+#include "cmake.h"
 
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/SystemTools.hxx>
 
-//----------------------------------------------------------------------------
-void cmGlobalKdevelopGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
+void cmGlobalKdevelopGenerator::GetDocumentation(cmDocumentationEntry& entry,
+                                                 const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates KDevelop 3 project files.";
 }
 
 cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
-:cmExternalMakefileProjectGenerator()
+  : cmExternalMakefileProjectGenerator()
 {
   this->SupportedGlobalGenerators.push_back("Unix Makefiles");
 #ifdef CMAKE_USE_NINJA
@@ -45,570 +46,557 @@ void cmGlobalKdevelopGenerator::Generate()
   // for each sub project in the project create
   // a kdevelop project
   for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
-       it = this->GlobalGenerator->GetProjectMap().begin();
-      it!= this->GlobalGenerator->GetProjectMap().end();
-      ++it)
-    {
-    std::string outputDir=it->second[0]->GetCurrentBinaryDirectory();
-    std::string projectDir=it->second[0]->GetSourceDirectory();
-    std::string projectName=it->second[0]->GetProjectName();
+         it = this->GlobalGenerator->GetProjectMap().begin();
+       it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+    std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
+    std::string projectDir = it->second[0]->GetSourceDirectory();
+    std::string projectName = it->second[0]->GetProjectName();
     std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
     std::string fileToOpen;
-    const std::vector<cmLocalGenerator*>& lgs= it->second;
+    const std::vector<cmLocalGenerator*>& lgs = it->second;
     // create the project.kdevelop.filelist file
-    if(!this->CreateFilelistFile(lgs, outputDir, projectDir,
-                                 projectName, cmakeFilePattern, fileToOpen))
-      {
+    if (!this->CreateFilelistFile(lgs, outputDir, projectDir, projectName,
+                                  cmakeFilePattern, fileToOpen)) {
       cmSystemTools::Error("Can not create filelist file");
       return;
-      }
-    //try to find the name of an executable so we have something to
-    //run from kdevelop for now just pick the first executable found
+    }
+    // try to find the name of an executable so we have something to
+    // run from kdevelop for now just pick the first executable found
     std::string executable;
-    for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
-         lg!=lgs.end(); lg++)
-      {
+    for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
+         lg != lgs.end(); lg++) {
       std::vector<cmGeneratorTarget*> const& targets =
-          (*lg)->GetGeneratorTargets();
+        (*lg)->GetGeneratorTargets();
       for (std::vector<cmGeneratorTarget*>::const_iterator ti =
-           targets.begin(); ti != targets.end(); ti++)
-        {
-        if ((*ti)->GetType()==cmState::EXECUTABLE)
-          {
+             targets.begin();
+           ti != targets.end(); ti++) {
+        if ((*ti)->GetType() == cmState::EXECUTABLE) {
           executable = (*ti)->GetLocation("");
           break;
-          }
         }
-      if (!executable.empty())
-        {
+      }
+      if (!executable.empty()) {
         break;
-        }
       }
+    }
 
     // now create a project file
-    this->CreateProjectFile(outputDir, projectDir, projectName,
-                            executable, cmakeFilePattern, fileToOpen);
-    }
+    this->CreateProjectFile(outputDir, projectDir, projectName, executable,
+                            cmakeFilePattern, fileToOpen);
+  }
 }
 
-bool cmGlobalKdevelopGenerator
-::CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
-                     const std::string& outputDir,
-                     const std::string& projectDirIn,
-                     const std::string& projectname,
-                     std::string& cmakeFilePattern,
-                     std::string& fileToOpen)
+bool cmGlobalKdevelopGenerator::CreateFilelistFile(
+  const std::vector<cmLocalGenerator*>& lgs, const std::string& outputDir,
+  const std::string& projectDirIn, const std::string& projectname,
+  std::string& cmakeFilePattern, std::string& fileToOpen)
 {
   std::string projectDir = projectDirIn + "/";
-  std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
+  std::string filename = outputDir + "/" + projectname + ".kdevelop.filelist";
 
   std::set<std::string> files;
   std::string tmp;
 
   std::vector<std::string> hdrExts =
-      this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
-
-  for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
-       it!=lgs.end(); it++)
-    {
-    cmMakefile* makefile=(*it)->GetMakefile();
-    const std::vector<std::string>& listFiles=makefile->GetListFiles();
-    for (std::vector<std::string>::const_iterator lt=listFiles.begin();
-         lt!=listFiles.end(); lt++)
-      {
-      tmp=*lt;
+    this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
+
+  for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin();
+       it != lgs.end(); it++) {
+    cmMakefile* makefile = (*it)->GetMakefile();
+    const std::vector<std::string>& listFiles = makefile->GetListFiles();
+    for (std::vector<std::string>::const_iterator lt = listFiles.begin();
+         lt != listFiles.end(); lt++) {
+      tmp = *lt;
       cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
       // make sure the file is part of this source tree
-      if ((tmp[0]!='/') &&
-          (strstr(tmp.c_str(),
-                  cmake::GetCMakeFilesDirectoryPostSlash())==0))
-        {
+      if ((tmp[0] != '/') &&
+          (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
+           0)) {
         files.insert(tmp);
-        tmp=cmSystemTools::GetFilenameName(tmp);
-        //add all files which dont match the default
+        tmp = cmSystemTools::GetFilenameName(tmp);
+        // add all files which dont match the default
         // */CMakeLists.txt;*cmake; to the file pattern
-        if ((tmp!="CMakeLists.txt")
-            && (strstr(tmp.c_str(), ".cmake")==0))
-          {
-          cmakeFilePattern+=tmp+";";
-          }
+        if ((tmp != "CMakeLists.txt") &&
+            (strstr(tmp.c_str(), ".cmake") == 0)) {
+          cmakeFilePattern += tmp + ";";
         }
       }
+    }
 
-    //get all sources
-    std::vector<cmGeneratorTarget*> targets=(*it)->GetGeneratorTargets();
+    // get all sources
+    std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-         ti != targets.end(); ti++)
-      {
+         ti != targets.end(); ti++) {
       std::vector<cmSourceFile*> sources;
       cmGeneratorTarget* gt = *ti;
-      gt->GetSourceFiles(sources, gt->Target->GetMakefile()
-                                    ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-      for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
-           si!=sources.end(); si++)
-        {
-        tmp=(*si)->GetFullPath();
-        std::string headerBasename=cmSystemTools::GetFilenamePath(tmp);
-        headerBasename+="/";
-        headerBasename+=cmSystemTools::GetFilenameWithoutExtension(tmp);
+      gt->GetSourceFiles(sources, gt->Target->GetMakefile()->GetSafeDefinition(
+                                    "CMAKE_BUILD_TYPE"));
+      for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+           si != sources.end(); si++) {
+        tmp = (*si)->GetFullPath();
+        std::string headerBasename = cmSystemTools::GetFilenamePath(tmp);
+        headerBasename += "/";
+        headerBasename += cmSystemTools::GetFilenameWithoutExtension(tmp);
 
         cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
 
-        if ((tmp[0]!='/')  &&
-            (strstr(tmp.c_str(),
-                  cmake::GetCMakeFilesDirectoryPostSlash())==0) &&
-           (cmSystemTools::GetFilenameExtension(tmp)!=".moc"))
-          {
+        if ((tmp[0] != '/') &&
+            (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
+             0) &&
+            (cmSystemTools::GetFilenameExtension(tmp) != ".moc")) {
           files.insert(tmp);
 
           // check if there's a matching header around
-          for(std::vector<std::string>::const_iterator
-                ext = hdrExts.begin(); ext != hdrExts.end(); ++ext)
-            {
-            std::string hname=headerBasename;
+          for (std::vector<std::string>::const_iterator ext = hdrExts.begin();
+               ext != hdrExts.end(); ++ext) {
+            std::string hname = headerBasename;
             hname += ".";
             hname += *ext;
-            if(cmSystemTools::FileExists(hname.c_str()))
-              {
+            if (cmSystemTools::FileExists(hname.c_str())) {
               cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
               files.insert(hname);
               break;
-              }
             }
           }
         }
-      for (std::vector<std::string>::const_iterator lt=listFiles.begin();
-           lt!=listFiles.end(); lt++)
-        {
-        tmp=*lt;
+      }
+      for (std::vector<std::string>::const_iterator lt = listFiles.begin();
+           lt != listFiles.end(); lt++) {
+        tmp = *lt;
         cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
-        if ((tmp[0]!='/') &&
-            (strstr(tmp.c_str(),
-                    cmake::GetCMakeFilesDirectoryPostSlash())==0))
-          {
+        if ((tmp[0] != '/') &&
+            (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
+             0)) {
           files.insert(tmp);
-          }
         }
       }
     }
+  }
 
-  //check if the output file already exists and read it
-  //insert all files which exist into the set of files
+  // check if the output file already exists and read it
+  // insert all files which exist into the set of files
   cmsys::ifstream oldFilelist(filename.c_str());
-  if (oldFilelist)
-    {
-    while (cmSystemTools::GetLineFromStream(oldFilelist, tmp))
-      {
-      if (tmp[0]=='/')
-        {
+  if (oldFilelist) {
+    while (cmSystemTools::GetLineFromStream(oldFilelist, tmp)) {
+      if (tmp[0] == '/') {
         continue;
-        }
-      std::string completePath=projectDir+tmp;
-      if (cmSystemTools::FileExists(completePath.c_str()))
-        {
+      }
+      std::string completePath = projectDir + tmp;
+      if (cmSystemTools::FileExists(completePath.c_str())) {
         files.insert(tmp);
-        }
       }
-    oldFilelist.close();
     }
+    oldFilelist.close();
+  }
 
-  //now write the new filename
+  // now write the new filename
   cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return false;
-    }
+  }
 
-  fileToOpen="";
-  for (std::set<std::string>::const_iterator it=files.begin();
-       it!=files.end(); it++)
-    {
+  fileToOpen = "";
+  for (std::set<std::string>::const_iterator it = files.begin();
+       it != files.end(); it++) {
     // get the full path to the file
-    tmp=cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
+    tmp = cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
     // just select the first source file
-    if (fileToOpen.empty())
-    {
-       std::string ext = cmSystemTools::GetFilenameExtension(tmp);
-       if ((ext==".c") || (ext==".cc") || (ext==".cpp")  || (ext==".cxx")
-           || (ext==".C") || (ext==".h") || (ext==".hpp"))
-       {
-       fileToOpen=tmp;
-       }
+    if (fileToOpen.empty()) {
+      std::string ext = cmSystemTools::GetFilenameExtension(tmp);
+      if ((ext == ".c") || (ext == ".cc") || (ext == ".cpp") ||
+          (ext == ".cxx") || (ext == ".C") || (ext == ".h") ||
+          (ext == ".hpp")) {
+        fileToOpen = tmp;
+      }
     }
     // make it relative to the project dir
     cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
     // only put relative paths
-    if (!tmp.empty() && tmp[0] != '/')
-      {
-      fout << tmp.c_str() <<"\n";
-      }
+    if (!tmp.empty() && tmp[0] != '/') {
+      fout << tmp.c_str() << "\n";
     }
+  }
   return true;
 }
 
-
 /* create the project file, if it already exists, merge it with the
 existing one, otherwise create a new one */
-void cmGlobalKdevelopGenerator
-::CreateProjectFile(const std::string& outputDir,
-                    const std::string& projectDir,
-                    const std::string& projectname,
-                    const std::string& executable,
-                    const std::string& cmakeFilePattern,
-                    const std::string& fileToOpen)
+void cmGlobalKdevelopGenerator::CreateProjectFile(
+  const std::string& outputDir, const std::string& projectDir,
+  const std::string& projectname, const std::string& executable,
+  const std::string& cmakeFilePattern, const std::string& fileToOpen)
 {
   this->Blacklist.clear();
 
-  std::string filename=outputDir+"/";
-  filename+=projectname+".kdevelop";
-  std::string sessionFilename=outputDir+"/";
-  sessionFilename+=projectname+".kdevses";
+  std::string filename = outputDir + "/";
+  filename += projectname + ".kdevelop";
+  std::string sessionFilename = outputDir + "/";
+  sessionFilename += projectname + ".kdevses";
 
-  if (cmSystemTools::FileExists(filename.c_str()))
-    {
-    this->MergeProjectFiles(outputDir, projectDir, filename,
-                            executable, cmakeFilePattern,
-                            fileToOpen, sessionFilename);
-    }
-  else
-    {
+  if (cmSystemTools::FileExists(filename.c_str())) {
+    this->MergeProjectFiles(outputDir, projectDir, filename, executable,
+                            cmakeFilePattern, fileToOpen, sessionFilename);
+  } else {
     // add all subdirectories which are cmake build directories to the
     // kdevelop blacklist so they are not monitored for added or removed files
     // since this is handled by adding files to the cmake files
     cmsys::Directory d;
-    if (d.Load(projectDir))
-      {
+    if (d.Load(projectDir)) {
       size_t numf = d.GetNumberOfFiles();
-      for (unsigned int i = 0; i < numf; i++)
-        {
+      for (unsigned int i = 0; i < numf; i++) {
         std::string nextFile = d.GetFile(i);
-        if ((nextFile!=".") && (nextFile!=".."))
-          {
+        if ((nextFile != ".") && (nextFile != "..")) {
           std::string tmp = projectDir;
           tmp += "/";
           tmp += nextFile;
-          if (cmSystemTools::FileIsDirectory(tmp))
-            {
+          if (cmSystemTools::FileIsDirectory(tmp)) {
             tmp += "/CMakeCache.txt";
-            if ((nextFile == "CMakeFiles")
-                || (cmSystemTools::FileExists(tmp.c_str())))
-              {
+            if ((nextFile == "CMakeFiles") ||
+                (cmSystemTools::FileExists(tmp.c_str()))) {
               this->Blacklist.push_back(nextFile);
-              }
             }
           }
         }
       }
-    this->CreateNewProjectFile(outputDir, projectDir, filename,
-                               executable, cmakeFilePattern,
-                               fileToOpen, sessionFilename);
     }
-
+    this->CreateNewProjectFile(outputDir, projectDir, filename, executable,
+                               cmakeFilePattern, fileToOpen, sessionFilename);
+  }
 }
 
-void cmGlobalKdevelopGenerator
-::MergeProjectFiles(const std::string& outputDir,
-                    const std::string& projectDir,
-                    const std::string& filename,
-                    const std::string& executable,
-                    const std::string& cmakeFilePattern,
-                    const std::string& fileToOpen,
-                    const std::string& sessionFilename)
+void cmGlobalKdevelopGenerator::MergeProjectFiles(
+  const std::string& outputDir, const std::string& projectDir,
+  const std::string& filename, const std::string& executable,
+  const std::string& cmakeFilePattern, const std::string& fileToOpen,
+  const std::string& sessionFilename)
 {
   cmsys::ifstream oldProjectFile(filename.c_str());
-  if (!oldProjectFile)
-    {
-    this->CreateNewProjectFile(outputDir, projectDir, filename,
-                               executable, cmakeFilePattern,
-                               fileToOpen, sessionFilename);
+  if (!oldProjectFile) {
+    this->CreateNewProjectFile(outputDir, projectDir, filename, executable,
+                               cmakeFilePattern, fileToOpen, sessionFilename);
     return;
-    }
+  }
 
   /* Read the existing project file (line by line), copy all lines
     into the new project file, except the ones which can be reliably
     set from contents of the CMakeLists.txt */
   std::string tmp;
   std::vector<std::string> lines;
-  while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp))
-    {
+  while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp)) {
     lines.push_back(tmp);
-    }
+  }
   oldProjectFile.close();
 
   cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
 
-  for (std::vector<std::string>::const_iterator it=lines.begin();
-       it!=lines.end(); it++)
-    {
-    const char* line=(*it).c_str();
+  for (std::vector<std::string>::const_iterator it = lines.begin();
+       it != lines.end(); it++) {
+    const char* line = (*it).c_str();
     // skip these tags as they are always replaced
-    if ((strstr(line, "<projectdirectory>")!=0)
-        || (strstr(line, "<projectmanagement>")!=0)
-        || (strstr(line, "<absoluteprojectpath>")!=0)
-        || (strstr(line, "<filelistdirectory>")!=0)
-        || (strstr(line, "<buildtool>")!=0)
-        || (strstr(line, "<builddir>")!=0))
-      {
+    if ((strstr(line, "<projectdirectory>") != 0) ||
+        (strstr(line, "<projectmanagement>") != 0) ||
+        (strstr(line, "<absoluteprojectpath>") != 0) ||
+        (strstr(line, "<filelistdirectory>") != 0) ||
+        (strstr(line, "<buildtool>") != 0) ||
+        (strstr(line, "<builddir>") != 0)) {
       continue;
-      }
+    }
 
     // output the line from the file if it is not one of the above tags
-    fout<<*it<<"\n";
+    fout << *it << "\n";
     // if this is the <general> tag output the stuff that goes in the
     // general tag
-    if (strstr(line, "<general>"))
-      {
-      fout<< "  <projectmanagement>KDevCustomProject</projectmanagement>\n";
-      fout<< "  <projectdirectory>" <<projectDir
-          << "</projectdirectory>\n";   //this one is important
-      fout<<"  <absoluteprojectpath>true</absoluteprojectpath>\n";
-      //and this one
-      }
+    if (strstr(line, "<general>")) {
+      fout << "  <projectmanagement>KDevCustomProject</projectmanagement>\n";
+      fout << "  <projectdirectory>" << projectDir
+           << "</projectdirectory>\n"; // this one is important
+      fout << "  <absoluteprojectpath>true</absoluteprojectpath>\n";
+      // and this one
+    }
     // inside kdevcustomproject the <filelistdirectory> must be put
-    if (strstr(line, "<kdevcustomproject>"))
-      {
-      fout<<"    <filelistdirectory>"<<outputDir
-          <<"</filelistdirectory>\n";
-      }
+    if (strstr(line, "<kdevcustomproject>")) {
+      fout << "    <filelistdirectory>" << outputDir
+           << "</filelistdirectory>\n";
+    }
     // buildtool and builddir go inside <build>
-    if (strstr(line, "<build>"))
-      {
-      fout<<"      <buildtool>make</buildtool>\n";
-      fout<<"      <builddir>"<<outputDir<<"</builddir>\n";
-      }
+    if (strstr(line, "<build>")) {
+      fout << "      <buildtool>make</buildtool>\n";
+      fout << "      <builddir>" << outputDir << "</builddir>\n";
     }
+  }
 }
 
-void cmGlobalKdevelopGenerator
-::CreateNewProjectFile(const std::string& outputDir,
-                       const std::string& projectDir,
-                       const std::string& filename,
-                       const std::string& executable,
-                       const std::string& cmakeFilePattern,
-                       const std::string& fileToOpen,
-                       const std::string& sessionFilename)
+void cmGlobalKdevelopGenerator::CreateNewProjectFile(
+  const std::string& outputDir, const std::string& projectDir,
+  const std::string& filename, const std::string& executable,
+  const std::string& cmakeFilePattern, const std::string& fileToOpen,
+  const std::string& sessionFilename)
 {
   cmGeneratedFileStream fout(filename.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
+  cmXMLWriter xml(fout);
 
   // check for a version control system
   bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
   bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
 
-  bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C")
-                          || this->GlobalGenerator->GetLanguageEnabled("CXX"));
+  bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C") ||
+                    this->GlobalGenerator->GetLanguageEnabled("CXX"));
   bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
   std::string primaryLanguage = "C++";
-  if (enableFortran && !enableCxx)
-    {
-    primaryLanguage="Fortran77";
-    }
-
-  fout<<"<?xml version = '1.0'?>\n"
-        "<kdevelop>\n"
-        "  <general>\n"
-        "  <author></author>\n"
-        "  <email></email>\n"
-        "  <version>$VERSION$</version>\n"
-        "  <projectmanagement>KDevCustomProject</projectmanagement>\n"
-        "  <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
-        "  <ignoreparts/>\n"
-        "  <projectdirectory>" << projectDir <<
-        "</projectdirectory>\n";   //this one is important
-  fout<<"  <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
+  if (enableFortran && !enableCxx) {
+    primaryLanguage = "Fortran77";
+  }
+
+  xml.StartDocument();
+  xml.StartElement("kdevelop");
+  xml.StartElement("general");
+
+  xml.Element("author", "");
+  xml.Element("email", "");
+  xml.Element("version", "$VERSION$");
+  xml.Element("projectmanagement", "KDevCustomProject");
+  xml.Element("primarylanguage", primaryLanguage);
+  xml.Element("ignoreparts");
+  xml.Element("projectdirectory", projectDir); // this one is important
+  xml.Element("absoluteprojectpath", "true");  // and this one
 
   // setup additional languages
-  fout<<"  <secondaryLanguages>\n";
-  if (enableFortran && enableCxx)
-    {
-    fout<<"     <language>Fortran</language>\n";
-    }
-  if (enableCxx)
-    {
-    fout<<"     <language>C</language>\n";
-    }
-  fout<<"  </secondaryLanguages>\n";
-
-  if (hasSvn)
-    {
-    fout << "  <versioncontrol>kdevsubversion</versioncontrol>\n";
-    }
-  else if (hasCvs)
-    {
-    fout << "  <versioncontrol>kdevcvsservice</versioncontrol>\n";
-    }
-
-  fout<<"  </general>\n"
-        "  <kdevcustomproject>\n"
-        "    <filelistdirectory>" << outputDir <<
-        "</filelistdirectory>\n"
-        "    <run>\n"
-        "      <mainprogram>" << executable << "</mainprogram>\n"
-        "      <directoryradio>custom</directoryradio>\n"
-        "      <customdirectory>"<<outputDir<<"</customdirectory>\n"
-        "      <programargs></programargs>\n"
-        "      <terminal>false</terminal>\n"
-        "      <autocompile>true</autocompile>\n"
-        "      <envvars/>\n"
-        "    </run>\n"
-        "    <build>\n"
-        "      <buildtool>make</buildtool>\n"; //this one is important
-  fout<<"      <builddir>"<<outputDir<<"</builddir>\n";  //and this one
-  fout<<"    </build>\n"
-        "    <make>\n"
-        "      <abortonerror>false</abortonerror>\n"
-        "      <numberofjobs>1</numberofjobs>\n"
-        "      <dontact>false</dontact>\n"
-        "      <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]->
-            GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")
-            << " </makebin>\n"
-        "      <selectedenvironment>default</selectedenvironment>\n"
-        "      <environments>\n"
-        "        <default>\n"
-        "          <envvar value=\"1\" name=\"VERBOSE\" />\n"
-        "          <envvar value=\"1\" name=\"CMAKE_NO_VERBOSE\" />\n"
-        "        </default>\n"
-        "      </environments>\n"
-        "    </make>\n";
-
-  fout<<"    <blacklist>\n";
-  for(std::vector<std::string>::const_iterator dirIt=this->Blacklist.begin();
-      dirIt != this->Blacklist.end();
-      ++dirIt)
-    {
-    fout<<"      <path>" << *dirIt << "</path>\n";
-    }
-  fout<<"    </blacklist>\n";
-
-  fout<<"  </kdevcustomproject>\n"
-        "  <kdevfilecreate>\n"
-        "    <filetypes/>\n"
-        "    <useglobaltypes>\n"
-        "      <type ext=\"ui\" />\n"
-        "      <type ext=\"cpp\" />\n"
-        "      <type ext=\"h\" />\n"
-        "    </useglobaltypes>\n"
-        "  </kdevfilecreate>\n"
-        "  <kdevdoctreeview>\n"
-        "    <projectdoc>\n"
-        "      <userdocDir>html/</userdocDir>\n"
-        "      <apidocDir>html/</apidocDir>\n"
-        "    </projectdoc>\n"
-        "    <ignoreqt_xml/>\n"
-        "    <ignoredoxygen/>\n"
-        "    <ignorekdocs/>\n"
-        "    <ignoretocs/>\n"
-        "    <ignoredevhelp/>\n"
-        "  </kdevdoctreeview>\n";
-
-  if (enableCxx)
-    {
-    fout<<"  <cppsupportpart>\n"
-          "    <filetemplates>\n"
-          "      <interfacesuffix>.h</interfacesuffix>\n"
-          "      <implementationsuffix>.cpp</implementationsuffix>\n"
-          "    </filetemplates>\n"
-          "  </cppsupportpart>\n"
-          "  <kdevcppsupport>\n"
-          "    <codecompletion>\n"
-          "      <includeGlobalFunctions>true</includeGlobalFunctions>\n"
-          "      <includeTypes>true</includeTypes>\n"
-          "      <includeEnums>true</includeEnums>\n"
-          "      <includeTypedefs>false</includeTypedefs>\n"
-          "      <automaticCodeCompletion>true</automaticCodeCompletion>\n"
-          "      <automaticArgumentsHint>true</automaticArgumentsHint>\n"
-          "      <automaticHeaderCompletion>true</automaticHeaderCompletion>\n"
-          "      <codeCompletionDelay>250</codeCompletionDelay>\n"
-          "      <argumentsHintDelay>400</argumentsHintDelay>\n"
-          "      <headerCompletionDelay>250</headerCompletionDelay>\n"
-          "    </codecompletion>\n"
-          "    <references/>\n"
-          "  </kdevcppsupport>\n";
-    }
-
-  if (enableFortran)
-    {
-    fout<<"  <kdevfortransupport>\n"
-          "    <ftnchek>\n"
-          "      <division>false</division>\n"
-          "      <extern>false</extern>\n"
-          "      <declare>false</declare>\n"
-          "      <pure>false</pure>\n"
-          "      <argumentsall>false</argumentsall>\n"
-          "      <commonall>false</commonall>\n"
-          "      <truncationall>false</truncationall>\n"
-          "      <usageall>false</usageall>\n"
-          "      <f77all>false</f77all>\n"
-          "      <portabilityall>false</portabilityall>\n"
-          "      <argumentsonly/>\n"
-          "      <commononly/>\n"
-          "      <truncationonly/>\n"
-          "      <usageonly/>\n"
-          "      <f77only/>\n"
-          "      <portabilityonly/>\n"
-          "    </ftnchek>\n"
-          "  </kdevfortransupport>\n";
-    }
+  xml.StartElement("secondaryLanguages");
+  if (enableFortran && enableCxx) {
+    xml.Element("language", "Fortran");
+  }
+  if (enableCxx) {
+    xml.Element("language", "C");
+  }
+  xml.EndElement();
+
+  if (hasSvn) {
+    xml.Element("versioncontrol", "kdevsubversion");
+  } else if (hasCvs) {
+    xml.Element("versioncontrol", "kdevcvsservice");
+  }
+
+  xml.EndElement(); // general
+  xml.StartElement("kdevcustomproject");
+
+  xml.Element("filelistdirectory", outputDir);
+
+  xml.StartElement("run");
+  xml.Element("mainprogram", executable);
+  xml.Element("directoryradio", "custom");
+  xml.Element("customdirectory", outputDir);
+  xml.Element("programargs", "");
+  xml.Element("terminal", "false");
+  xml.Element("autocompile", "true");
+  xml.Element("envvars");
+  xml.EndElement();
+
+  xml.StartElement("build");
+  xml.Element("buildtool", "make");   // this one is important
+  xml.Element("builddir", outputDir); // and this one
+  xml.EndElement();
+
+  xml.StartElement("make");
+  xml.Element("abortonerror", "false");
+  xml.Element("numberofjobs", 1);
+  xml.Element("dontact", "false");
+  xml.Element("makebin", this->GlobalGenerator->GetLocalGenerators()[0]
+                           ->GetMakefile()
+                           ->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"));
+  xml.Element("selectedenvironment", "default");
+
+  xml.StartElement("environments");
+  xml.StartElement("default");
+
+  xml.StartElement("envvar");
+  xml.Attribute("value", 1);
+  xml.Attribute("name", "VERBOSE");
+  xml.EndElement();
+
+  xml.StartElement("envvar");
+  xml.Attribute("value", 1);
+  xml.Attribute("name", "CMAKE_NO_VERBOSE");
+  xml.EndElement();
+
+  xml.EndElement(); // default
+  xml.EndElement(); // environments
+  xml.EndElement(); // make
+
+  xml.StartElement("blacklist");
+  for (std::vector<std::string>::const_iterator dirIt =
+         this->Blacklist.begin();
+       dirIt != this->Blacklist.end(); ++dirIt) {
+    xml.Element("path", *dirIt);
+  }
+  xml.EndElement();
+
+  xml.EndElement(); // kdevcustomproject
+
+  xml.StartElement("kdevfilecreate");
+  xml.Element("filetypes");
+  xml.StartElement("useglobaltypes");
+
+  xml.StartElement("type");
+  xml.Attribute("ext", "ui");
+  xml.EndElement();
+
+  xml.StartElement("type");
+  xml.Attribute("ext", "cpp");
+  xml.EndElement();
+
+  xml.StartElement("type");
+  xml.Attribute("ext", "h");
+  xml.EndElement();
+
+  xml.EndElement(); // useglobaltypes
+  xml.EndElement(); // kdevfilecreate
+
+  xml.StartElement("kdevdoctreeview");
+  xml.StartElement("projectdoc");
+  xml.Element("userdocDir", "html/");
+  xml.Element("apidocDir", "html/");
+  xml.EndElement(); // projectdoc
+  xml.Element("ignoreqt_xml");
+  xml.Element("ignoredoxygen");
+  xml.Element("ignorekdocs");
+  xml.Element("ignoretocs");
+  xml.Element("ignoredevhelp");
+  xml.EndElement(); // kdevdoctreeview;
+
+  if (enableCxx) {
+    xml.StartElement("cppsupportpart");
+    xml.StartElement("filetemplates");
+    xml.Element("interfacesuffix", ".h");
+    xml.Element("implementationsuffix", ".cpp");
+    xml.EndElement(); // filetemplates
+    xml.EndElement(); // cppsupportpart
+
+    xml.StartElement("kdevcppsupport");
+    xml.StartElement("codecompletion");
+    xml.Element("includeGlobalFunctions", "true");
+    xml.Element("includeTypes", "true");
+    xml.Element("includeEnums", "true");
+    xml.Element("includeTypedefs", "false");
+    xml.Element("automaticCodeCompletion", "true");
+    xml.Element("automaticArgumentsHint", "true");
+    xml.Element("automaticHeaderCompletion", "true");
+    xml.Element("codeCompletionDelay", 250);
+    xml.Element("argumentsHintDelay", 400);
+    xml.Element("headerCompletionDelay", 250);
+    xml.EndElement(); // codecompletion
+    xml.Element("references");
+    xml.EndElement(); // kdevcppsupport;
+  }
+
+  if (enableFortran) {
+    xml.StartElement("kdevfortransupport");
+    xml.StartElement("ftnchek");
+    xml.Element("division", "false");
+    xml.Element("extern", "false");
+    xml.Element("declare", "false");
+    xml.Element("pure", "false");
+    xml.Element("argumentsall", "false");
+    xml.Element("commonall", "false");
+    xml.Element("truncationall", "false");
+    xml.Element("usageall", "false");
+    xml.Element("f77all", "false");
+    xml.Element("portabilityall", "false");
+    xml.Element("argumentsonly");
+    xml.Element("commononly");
+    xml.Element("truncationonly");
+    xml.Element("usageonly");
+    xml.Element("f77only");
+    xml.Element("portabilityonly");
+    xml.EndElement(); // ftnchek
+    xml.EndElement(); // kdevfortransupport;
+  }
 
   // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
   // command
-  fout<<"  <kdevfileview>\n"
-        "    <groups>\n"
-        "      <group pattern=\"" << cmakeFilePattern <<
-        "\" name=\"CMake\" />\n";
-
-  if (enableCxx)
-    {
-    fout<<"      <group pattern=\"*.h;*.hxx;*.hpp\" name=\"Header\" />\n"
-          "      <group pattern=\"*.c\" name=\"C Sources\" />\n"
-          "      <group pattern=\"*.cpp;*.C;*.cxx;*.cc\" name=\"C++ Sources\""
-          "/>\n";
-    }
-
-  if (enableFortran)
-    {
-    fout<<"      <group pattern=\"*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;"
-          "*.F95\" name=\"Fortran Sources\" />\n";
-    }
-
-  fout<<"      <group pattern=\"*.ui\" name=\"Qt Designer files\" />\n"
-        "      <hidenonprojectfiles>true</hidenonprojectfiles>\n"
-        "    </groups>\n"
-        "    <tree>\n"
-        "      <hidepatterns>*.o,*.lo,CVS,*~,cmake*</hidepatterns>\n"
-        "      <hidenonprojectfiles>true</hidenonprojectfiles>\n"
-        "    </tree>\n"
-        "  </kdevfileview>\n"
-        "</kdevelop>\n";
-
-  if (sessionFilename.empty())
-    {
+  xml.StartElement("kdevfileview");
+  xml.StartElement("groups");
+
+  xml.StartElement("group");
+  xml.Attribute("pattern", cmakeFilePattern);
+  xml.Attribute("name", "CMake");
+  xml.EndElement();
+
+  if (enableCxx) {
+    xml.StartElement("group");
+    xml.Attribute("pattern", "*.h;*.hxx;*.hpp");
+    xml.Attribute("name", "Header");
+    xml.EndElement();
+
+    xml.StartElement("group");
+    xml.Attribute("pattern", "*.c");
+    xml.Attribute("name", "C Sources");
+    xml.EndElement();
+
+    xml.StartElement("group");
+    xml.Attribute("pattern", "*.cpp;*.C;*.cxx;*.cc");
+    xml.Attribute("name", "C++ Sources");
+    xml.EndElement();
+  }
+
+  if (enableFortran) {
+    xml.StartElement("group");
+    xml.Attribute("pattern",
+                  "*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;*.F95");
+    xml.Attribute("name", "Fortran Sources");
+    xml.EndElement();
+  }
+
+  xml.StartElement("group");
+  xml.Attribute("pattern", "*.ui");
+  xml.Attribute("name", "Qt Designer files");
+  xml.EndElement();
+
+  xml.Element("hidenonprojectfiles", "true");
+  xml.EndElement(); // groups
+
+  xml.StartElement("tree");
+  xml.Element("hidepatterns", "*.o,*.lo,CVS,*~,cmake*");
+  xml.Element("hidenonprojectfiles", "true");
+  xml.EndElement(); // tree
+
+  xml.EndElement(); // kdevfileview
+  xml.EndElement(); // kdevelop;
+  xml.EndDocument();
+
+  if (sessionFilename.empty()) {
     return;
-    }
+  }
 
   // and a session file, so that kdevelop opens a file if it opens the
   // project the first time
   cmGeneratedFileStream devses(sessionFilename.c_str());
-  if(!devses)
-    {
+  if (!devses) {
     return;
-    }
-  devses<<"<?xml version = '1.0' encoding = \'UTF-8\'?>\n"
-          "<!DOCTYPE KDevPrjSession>\n"
-          "<KDevPrjSession>\n"
-          " <DocsAndViews NumberOfDocuments=\"1\" >\n"
-          "  <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
-          "\" >\n"
-          "   <View0 line=\"0\" Type=\"Source\" />\n"
-          "  </Doc0>\n"
-          " </DocsAndViews>\n"
-          "</KDevPrjSession>\n";
+  }
+  cmXMLWriter sesxml(devses);
+  sesxml.StartDocument("UTF-8");
+  sesxml.Doctype("KDevPrjSession");
+  sesxml.StartElement("KDevPrjSession");
+
+  sesxml.StartElement("DocsAndViews");
+  sesxml.Attribute("NumberOfDocuments", 1);
+
+  sesxml.StartElement("Doc0");
+  sesxml.Attribute("NumberOfViews", 1);
+  sesxml.Attribute("URL", "file://" + fileToOpen);
+
+  sesxml.StartElement("View0");
+  sesxml.Attribute("line", 0);
+  sesxml.Attribute("Type", "Source");
+  sesxml.EndElement(); // View0
+
+  sesxml.EndElement(); // Doc0
+  sesxml.EndElement(); // DocsAndViews
+  sesxml.EndElement(); // KDevPrjSession;
 }
-
diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h
index 0d59fc5..315e38e 100644
--- a/Source/cmGlobalKdevelopGenerator.h
+++ b/Source/cmGlobalKdevelopGenerator.h
@@ -34,15 +34,20 @@ public:
   cmGlobalKdevelopGenerator();
 
   virtual std::string GetName() const
-                          { return cmGlobalKdevelopGenerator::GetActualName();}
-  static std::string GetActualName()                     { return "KDevelop3";}
+  {
+    return cmGlobalKdevelopGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "KDevelop3"; }
   static cmExternalMakefileProjectGenerator* New()
-                                      { return new cmGlobalKdevelopGenerator; }
+  {
+    return new cmGlobalKdevelopGenerator;
+  }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
                                 const std::string& fullName) const;
 
   virtual void Generate();
+
 private:
   /*** Create the foo.kdevelop.filelist file, return false if it doesn't
     succeed.  If the file already exists the contents will be merged.
diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx
index 9a6f3ba..6bf178a 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.cxx
+++ b/Source/cmGlobalMSYSMakefileGenerator.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalMSYSMakefileGenerator.h"
+
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmake.h"
@@ -25,8 +26,8 @@ cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator(cmake* cm)
   cm->GetState()->SetMSYSShell(true);
 }
 
-std::string
-cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc)
+std::string cmGlobalMSYSMakefileGenerator::FindMinGW(
+  std::string const& makeloc)
 {
   std::string fstab = makeloc;
   fstab += "/../etc/fstab";
@@ -34,23 +35,19 @@ cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc)
   std::string path;
   std::string mount;
   std::string mingwBin;
-  while(fin)
-    {
+  while (fin) {
     fin >> path;
     fin >> mount;
-    if(mount == "/mingw")
-      {
+    if (mount == "/mingw") {
       mingwBin = path;
       mingwBin += "/bin";
-      }
     }
+  }
   return mingwBin;
 }
 
-void cmGlobalMSYSMakefileGenerator
-::EnableLanguage(std::vector<std::string>const& l,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalMSYSMakefileGenerator::EnableLanguage(
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   this->FindMakeProgram(mf);
   std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
@@ -62,41 +59,35 @@ void cmGlobalMSYSMakefileGenerator
   locations.push_back("c:/mingw/bin");
   std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
   std::string gcc = "gcc.exe";
-  if(!tgcc.empty())
-    {
+  if (!tgcc.empty()) {
     gcc = tgcc;
-    }
+  }
   std::string tgxx = cmSystemTools::FindProgram("g++", locations);
   std::string gxx = "g++.exe";
-  if(!tgxx.empty())
-    {
+  if (!tgxx.empty()) {
     gxx = tgxx;
-    }
+  }
   std::string trc = cmSystemTools::FindProgram("windres", locations);
   std::string rc = "windres.exe";
-  if(!trc.empty())
-    {
+  if (!trc.empty()) {
     rc = trc;
-    }
+  }
   mf->AddDefinition("MSYS", "1");
   mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
   mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
   mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
 
-  if(!mf->IsSet("CMAKE_AR") &&
-      !this->CMakeInstance->GetIsInTryCompile() &&
-      !(1==l.size() && l[0]=="NONE"))
-    {
-    cmSystemTools::Error
-      ("CMAKE_AR was not found, please set to archive program. ",
-       mf->GetDefinition("CMAKE_AR"));
-    }
+  if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() &&
+      !(1 == l.size() && l[0] == "NONE")) {
+    cmSystemTools::Error(
+      "CMAKE_AR was not found, please set to archive program. ",
+      mf->GetDefinition("CMAKE_AR"));
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalMSYSMakefileGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalMSYSMakefileGenerator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalMSYSMakefileGenerator::GetActualName();
   entry.Brief = "Generates MSYS makefiles.";
diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h
index 2cefc97..d687d19 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.h
+++ b/Source/cmGlobalMSYSMakefileGenerator.h
@@ -23,14 +23,17 @@ class cmGlobalMSYSMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalMSYSMakefileGenerator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalMSYSMakefileGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<cmGlobalMSYSMakefileGenerator>();
+  }
 
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalMSYSMakefileGenerator::GetActualName();}
-  static std::string GetActualName() {return "MSYS Makefiles";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalMSYSMakefileGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "MSYS Makefiles"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -39,8 +42,8 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 
 private:
   std::string FindMinGW(std::string const& makeloc);
diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx
index b6e52d7..05f1b36 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.cxx
+++ b/Source/cmGlobalMinGWMakefileGenerator.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalMinGWMakefileGenerator.h"
+
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 
@@ -24,10 +25,8 @@ cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator(cmake* cm)
   cm->GetState()->SetMinGWMake(true);
 }
 
-void cmGlobalMinGWMakefileGenerator
-::EnableLanguage(std::vector<std::string>const& l,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalMinGWMakefileGenerator::EnableLanguage(
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   this->FindMakeProgram(mf);
   std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
@@ -37,31 +36,27 @@ void cmGlobalMinGWMakefileGenerator
   locations.push_back("c:/mingw/bin");
   std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
   std::string gcc = "gcc.exe";
-  if(!tgcc.empty())
-    {
+  if (!tgcc.empty()) {
     gcc = tgcc;
-    }
+  }
   std::string tgxx = cmSystemTools::FindProgram("g++", locations);
   std::string gxx = "g++.exe";
-  if(!tgxx.empty())
-    {
+  if (!tgxx.empty()) {
     gxx = tgxx;
-    }
+  }
   std::string trc = cmSystemTools::FindProgram("windres", locations);
   std::string rc = "windres.exe";
-  if(!trc.empty())
-    {
+  if (!trc.empty()) {
     rc = trc;
-    }
+  }
   mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
   mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
   mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalMinGWMakefileGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalMinGWMakefileGenerator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalMinGWMakefileGenerator::GetActualName();
   entry.Brief = "Generates a make file for use with mingw32-make.";
diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h
index 3b00126..90cfde7 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.h
+++ b/Source/cmGlobalMinGWMakefileGenerator.h
@@ -23,13 +23,17 @@ class cmGlobalMinGWMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalMinGWMakefileGenerator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalMinGWMakefileGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<
+      cmGlobalMinGWMakefileGenerator>();
+  }
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalMinGWMakefileGenerator::GetActualName();}
-  static std::string GetActualName() {return "MinGW Makefiles";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalMinGWMakefileGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "MinGW Makefiles"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -38,8 +42,8 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 };
 
 #endif
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index 7c570a6..605a773 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalNMakeMakefileGenerator.h"
+
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 
@@ -28,10 +29,8 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator(cmake* cm)
   this->MakeSilentFlag = "/nologo";
 }
 
-void cmGlobalNMakeMakefileGenerator
-::EnableLanguage(std::vector<std::string>const& l,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalNMakeMakefileGenerator::EnableLanguage(
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   // pick a default
   mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
@@ -39,26 +38,24 @@ void cmGlobalNMakeMakefileGenerator
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalNMakeMakefileGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalNMakeMakefileGenerator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName();
   entry.Brief = "Generates NMake makefiles.";
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(std::ostream& os,
-                                                  std::string const& lang,
-                                                  const char* envVar) const
+void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(
+  std::ostream& os, std::string const& lang, const char* envVar) const
 {
-  if(lang == "CXX" || lang == "C")
-    {
+  if (lang == "CXX" || lang == "C") {
+    /* clang-format off */
     os <<
       "To use the NMake generator with Visual C++, cmake must be run from a "
       "shell that can use the compiler cl from the command line. This "
       "environment is unable to invoke the cl compiler. To fix this problem, "
       "run cmake from the Visual Studio Command Prompt (vcvarsall.bat).\n";
-    }
+    /* clang-format on */
+  }
   this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
 }
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 3c8375a..3ab684e 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -23,13 +23,17 @@ class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalNMakeMakefileGenerator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalNMakeMakefileGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<
+      cmGlobalNMakeMakefileGenerator>();
+  }
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalNMakeMakefileGenerator::GetActualName();}
-  static std::string GetActualName() {return "NMake Makefiles";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalNMakeMakefileGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "NMake Makefiles"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -38,8 +42,9 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
+
 private:
   void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
                            const char* envVar) const;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 0f06e43..143ad92 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -10,14 +10,15 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+#include "cmGlobalNinjaGenerator.h"
+
+#include "cmAlgorithms.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorExpressionEvaluationFile.h"
 #include "cmGeneratorTarget.h"
-#include "cmGlobalNinjaGenerator.h"
 #include "cmLocalNinjaGenerator.h"
 #include "cmMakefile.h"
 #include "cmVersion.h"
-#include "cmAlgorithms.h"
 
 #include <algorithm>
 #include <assert.h>
@@ -29,15 +30,14 @@ const char* cmGlobalNinjaGenerator::INDENT = "  ";
 
 void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count)
 {
-  for(int i = 0; i < count; ++i)
+  for (int i = 0; i < count; ++i)
     os << cmGlobalNinjaGenerator::INDENT;
 }
 
 void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os)
 {
-  os
-    << "# ======================================"
-    << "=======================================\n";
+  os << "# ======================================"
+     << "=======================================\n";
 }
 
 void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
@@ -46,16 +46,14 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
   if (comment.empty())
     return;
 
-  std::string replace = comment;
   std::string::size_type lpos = 0;
   std::string::size_type rpos;
   os << "\n#############################################\n";
-  while((rpos = replace.find('\n', lpos)) != std::string::npos)
-    {
-    os << "# " << replace.substr(lpos, rpos - lpos) << "\n";
+  while ((rpos = comment.find('\n', lpos)) != std::string::npos) {
+    os << "# " << comment.substr(lpos, rpos - lpos) << "\n";
     lpos = rpos + 1;
-    }
-  os << "# " << replace.substr(lpos) << "\n\n";
+  }
+  os << "# " << comment.substr(lpos) << "\n\n";
 }
 
 std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
@@ -63,35 +61,29 @@ std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
   // Ninja rule names must match "[a-zA-Z0-9_.-]+".  Use ".xx" to encode
   // "." and all invalid characters as hexadecimal.
   std::string encoded;
-  for (std::string::const_iterator i = name.begin();
-       i != name.end(); ++i)
-    {
-    if (isalnum(*i) || *i == '_' || *i == '-')
-      {
+  for (std::string::const_iterator i = name.begin(); i != name.end(); ++i) {
+    if (isalnum(*i) || *i == '_' || *i == '-') {
       encoded += *i;
-      }
-    else
-      {
+    } else {
       char buf[16];
       sprintf(buf, ".%02x", static_cast<unsigned int>(*i));
       encoded += buf;
-      }
     }
+  }
   return encoded;
 }
 
 static bool IsIdentChar(char c)
 {
-  return
-    ('a' <= c && c <= 'z') ||
-    ('+' <= c && c <= '9') ||  // +,-./ and numbers
-    ('A' <= c && c <= 'Z') ||
-    (c == '_') || (c == '$') || (c == '\\') ||
+  return ('a' <= c && c <= 'z') ||
+    ('+' <= c && c <= '9') || // +,-./ and numbers
+    ('A' <= c && c <= 'Z') || (c == '_') || (c == '$') || (c == '\\') ||
     (c == ' ') || (c == ':');
 }
 
-std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident,
-                                                std::ostream &vars) {
+std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string& ident,
+                                                std::ostream& vars)
+{
   if (std::find_if(ident.begin(), ident.end(),
                    std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) {
     static unsigned VarNum = 0;
@@ -107,7 +99,7 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident,
   }
 }
 
-std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit)
+std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
 {
   std::string result = lit;
   cmSystemTools::ReplaceString(result, "$", "$$");
@@ -115,54 +107,47 @@ std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit)
   return result;
 }
 
-std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path)
+std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path)
 {
   std::string result = path;
 #ifdef _WIN32
   if (this->IsGCCOnWindows())
-    cmSystemTools::ReplaceString(result, "\\", "/");
+    std::replace(result.begin(), result.end(), '\\', '/');
   else
-    cmSystemTools::ReplaceString(result, "/", "\\");
+    std::replace(result.begin(), result.end(), '/', '\\');
 #endif
   return EncodeLiteral(result);
 }
 
-std::string cmGlobalNinjaGenerator::EncodeDepfileSpace(const std::string &path)
+std::string cmGlobalNinjaGenerator::EncodeDepfileSpace(const std::string& path)
 {
   std::string result = path;
   cmSystemTools::ReplaceString(result, " ", "\\ ");
   return result;
 }
 
-void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
-                                        const std::string& comment,
-                                        const std::string& rule,
-                                        const cmNinjaDeps& outputs,
-                                        const cmNinjaDeps& explicitDeps,
-                                        const cmNinjaDeps& implicitDeps,
-                                        const cmNinjaDeps& orderOnlyDeps,
-                                        const cmNinjaVars& variables,
-                                        const std::string& rspfile,
-                                        int cmdLineLimit,
-                                        bool* usedResponseFile)
+void cmGlobalNinjaGenerator::WriteBuild(
+  std::ostream& os, const std::string& comment, const std::string& rule,
+  const cmNinjaDeps& outputs, const cmNinjaDeps& explicitDeps,
+  const cmNinjaDeps& implicitDeps, const cmNinjaDeps& orderOnlyDeps,
+  const cmNinjaVars& variables, const std::string& rspfile, int cmdLineLimit,
+  bool* usedResponseFile)
 {
   // Make sure there is a rule.
-  if(rule.empty())
-    {
+  if (rule.empty()) {
     cmSystemTools::Error("No rule for WriteBuildStatement! called "
                          "with comment: ",
                          comment.c_str());
     return;
-    }
+  }
 
   // Make sure there is at least one output file.
-  if(outputs.empty())
-    {
+  if (outputs.empty()) {
     cmSystemTools::Error("No output files for WriteBuildStatement! called "
                          "with comment: ",
                          comment.c_str());
     return;
-    }
+  }
 
   cmGlobalNinjaGenerator::WriteComment(os, comment);
 
@@ -171,32 +156,26 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
   // TODO: Better formatting for when there are multiple input/output files.
 
   // Write explicit dependencies.
-  for(cmNinjaDeps::const_iterator i = explicitDeps.begin();
-      i != explicitDeps.end();
-      ++i)
-    {
+  for (cmNinjaDeps::const_iterator i = explicitDeps.begin();
+       i != explicitDeps.end(); ++i) {
     arguments += " " + EncodeIdent(EncodePath(*i), os);
-    }
+  }
 
   // Write implicit dependencies.
-  if(!implicitDeps.empty())
-    {
+  if (!implicitDeps.empty()) {
     arguments += " |";
-    for(cmNinjaDeps::const_iterator i = implicitDeps.begin();
-        i != implicitDeps.end();
-        ++i)
+    for (cmNinjaDeps::const_iterator i = implicitDeps.begin();
+         i != implicitDeps.end(); ++i)
       arguments += " " + EncodeIdent(EncodePath(*i), os);
-    }
+  }
 
   // Write order-only dependencies.
-  if(!orderOnlyDeps.empty())
-    {
+  if (!orderOnlyDeps.empty()) {
     arguments += " ||";
-    for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
-        i != orderOnlyDeps.end();
-        ++i)
+    for (cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
+         i != orderOnlyDeps.end(); ++i)
       arguments += " " + EncodeIdent(EncodePath(*i), os);
-    }
+  }
 
   arguments += "\n";
 
@@ -204,15 +183,13 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
 
   // Write outputs files.
   build += "build";
-  for(cmNinjaDeps::const_iterator i = outputs.begin();
-      i != outputs.end(); ++i)
-    {
+  for (cmNinjaDeps::const_iterator i = outputs.begin(); i != outputs.end();
+       ++i) {
     build += " " + EncodeIdent(EncodePath(*i), os);
-    if (this->ComputingUnknownDependencies)
-      {
-      this->CombinedBuildOutputs.insert( EncodePath(*i) );
-      }
+    if (this->ComputingUnknownDependencies) {
+      this->CombinedBuildOutputs.insert(EncodePath(*i));
     }
+  }
   build += ":";
 
   // Write the rule.
@@ -220,56 +197,45 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
 
   // Write the variables bound to this build statement.
   std::ostringstream variable_assignments;
-  for(cmNinjaVars::const_iterator i = variables.begin();
-      i != variables.end(); ++i)
-    cmGlobalNinjaGenerator::WriteVariable(variable_assignments,
-                                          i->first, i->second, "", 1);
+  for (cmNinjaVars::const_iterator i = variables.begin(); i != variables.end();
+       ++i)
+    cmGlobalNinjaGenerator::WriteVariable(variable_assignments, i->first,
+                                          i->second, "", 1);
 
   // check if a response file rule should be used
   std::string buildstr = build;
   std::string assignments = variable_assignments.str();
   const std::string& args = arguments;
   bool useResponseFile = false;
-  if (cmdLineLimit > 0
-      && args.size() + buildstr.size() + assignments.size()
-                                                    > (size_t) cmdLineLimit) {
+  if (cmdLineLimit < 0 ||
+      (cmdLineLimit > 0 &&
+       (args.size() + buildstr.size() + assignments.size()) >
+         static_cast<size_t>(cmdLineLimit))) {
     variable_assignments.str(std::string());
-    cmGlobalNinjaGenerator::WriteVariable(variable_assignments,
-                                          "RSP_FILE", rspfile, "", 1);
+    cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE",
+                                          rspfile, "", 1);
     assignments += variable_assignments.str();
     useResponseFile = true;
   }
-  if (usedResponseFile)
-    {
+  if (usedResponseFile) {
     *usedResponseFile = useResponseFile;
-    }
+  }
 
   os << buildstr << args << assignments;
 }
 
-void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os,
-                                             const std::string& comment,
-                                             const cmNinjaDeps& outputs,
-                                             const cmNinjaDeps& explicitDeps,
-                                             const cmNinjaDeps& implicitDeps,
-                                             const cmNinjaDeps& orderOnlyDeps,
-                                             const cmNinjaVars& variables)
+void cmGlobalNinjaGenerator::WritePhonyBuild(
+  std::ostream& os, const std::string& comment, const cmNinjaDeps& outputs,
+  const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps,
+  const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables)
 {
-  this->WriteBuild(os,
-                   comment,
-                   "phony",
-                   outputs,
-                   explicitDeps,
-                   implicitDeps,
-                   orderOnlyDeps,
-                   variables);
+  this->WriteBuild(os, comment, "phony", outputs, explicitDeps, implicitDeps,
+                   orderOnlyDeps, variables);
 }
 
 void cmGlobalNinjaGenerator::AddCustomCommandRule()
 {
-  this->AddRule("CUSTOM_COMMAND",
-                "$COMMAND",
-                "$DESC",
+  this->AddRule("CUSTOM_COMMAND", "$COMMAND", "$DESC",
                 "Rule for running custom commands.",
                 /*depfile*/ "",
                 /*deptype*/ "",
@@ -279,21 +245,17 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
                 /*generator*/ false);
 }
 
-void
-cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
-                                                const std::string& description,
-                                                const std::string& comment,
-                                                bool uses_terminal,
-                                                bool restat,
-                                                const cmNinjaDeps& outputs,
-                                                const cmNinjaDeps& deps,
-                                                const cmNinjaDeps& orderOnly)
+void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
+  const std::string& command, const std::string& description,
+  const std::string& comment, bool uses_terminal, bool restat,
+  const cmNinjaDeps& outputs, const cmNinjaDeps& deps,
+  const cmNinjaDeps& orderOnly)
 {
   std::string cmd = command;
 #ifdef _WIN32
-   if (cmd.empty())
-      // TODO Shouldn't an empty command be handled by ninja?
-      cmd = "cmd.exe /c";
+  if (cmd.empty())
+    // TODO Shouldn't an empty command be handled by ninja?
+    cmd = "cmd.exe /c";
 #endif
 
   this->AddCustomCommandRule();
@@ -301,48 +263,35 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
   cmNinjaVars vars;
   vars["COMMAND"] = cmd;
   vars["DESC"] = EncodeLiteral(description);
-  if (restat)
-    {
+  if (restat) {
     vars["restat"] = "1";
-    }
-  if (uses_terminal && SupportsConsolePool())
-    {
+  }
+  if (uses_terminal && SupportsConsolePool()) {
     vars["pool"] = "console";
-    }
+  }
 
-  this->WriteBuild(*this->BuildFileStream,
-                   comment,
-                   "CUSTOM_COMMAND",
-                   outputs,
-                   deps,
-                   cmNinjaDeps(),
-                   orderOnly,
-                   vars);
-
-  if (this->ComputingUnknownDependencies)
-    {
-    //we need to track every dependency that comes in, since we are trying
-    //to find dependencies that are side effects of build commands
-    for(cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i)
-      {
+  this->WriteBuild(*this->BuildFileStream, comment, "CUSTOM_COMMAND", outputs,
+                   deps, cmNinjaDeps(), orderOnly, vars);
+
+  if (this->ComputingUnknownDependencies) {
+    // we need to track every dependency that comes in, since we are trying
+    // to find dependencies that are side effects of build commands
+    for (cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i) {
       this->CombinedCustomCommandExplicitDependencies.insert(EncodePath(*i));
-      }
     }
+  }
 }
 
-void
-cmGlobalNinjaGenerator::AddMacOSXContentRule()
+void cmGlobalNinjaGenerator::AddMacOSXContentRule()
 {
-  cmLocalGenerator *lg = this->LocalGenerators[0];
+  cmLocalGenerator* lg = this->LocalGenerators[0];
 
   std::ostringstream cmd;
   cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
-                                   cmLocalGenerator::SHELL)
+                                   cmOutputConverter::SHELL)
       << " -E copy $in $out";
 
-  this->AddRule("COPY_OSX_CONTENT",
-                cmd.str(),
-                "Copying OS X Content $out",
+  this->AddRule("COPY_OSX_CONTENT", cmd.str(), "Copying OS X Content $out",
                 "Rule for copying OS X bundle content file.",
                 /*depfile*/ "",
                 /*deptype*/ "",
@@ -352,9 +301,8 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule()
                 /*generator*/ false);
 }
 
-void
-cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input,
-                                                const std::string& output)
+void cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input,
+                                                     const std::string& output)
 {
   this->AddMacOSXContentRule();
 
@@ -364,45 +312,32 @@ cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input,
   deps.push_back(input);
   cmNinjaVars vars;
 
-  this->WriteBuild(*this->BuildFileStream,
-                   "",
-                   "COPY_OSX_CONTENT",
-                   outputs,
-                   deps,
-                   cmNinjaDeps(),
-                   cmNinjaDeps(),
-                   cmNinjaVars());
+  this->WriteBuild(*this->BuildFileStream, "", "COPY_OSX_CONTENT", outputs,
+                   deps, cmNinjaDeps(), cmNinjaDeps(), cmNinjaVars());
 }
 
-void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
-                                       const std::string& name,
-                                       const std::string& command,
-                                       const std::string& description,
-                                       const std::string& comment,
-                                       const std::string& depfile,
-                                       const std::string& deptype,
-                                       const std::string& rspfile,
-                                       const std::string& rspcontent,
-                                       const std::string& restat,
-                                       bool generator)
+void cmGlobalNinjaGenerator::WriteRule(
+  std::ostream& os, const std::string& name, const std::string& command,
+  const std::string& description, const std::string& comment,
+  const std::string& depfile, const std::string& deptype,
+  const std::string& rspfile, const std::string& rspcontent,
+  const std::string& restat, bool generator)
 {
   // Make sure the rule has a name.
-  if(name.empty())
-    {
+  if (name.empty()) {
     cmSystemTools::Error("No name given for WriteRuleStatement! called "
                          "with comment: ",
                          comment.c_str());
     return;
-    }
+  }
 
   // Make sure a command is given.
-  if(command.empty())
-    {
+  if (command.empty()) {
     cmSystemTools::Error("No command given for WriteRuleStatement! called "
                          "with comment: ",
                          comment.c_str());
     return;
-    }
+  }
 
   cmGlobalNinjaGenerator::WriteComment(os, comment);
 
@@ -410,54 +345,47 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
   os << "rule " << name << "\n";
 
   // Write the depfile if any.
-  if(!depfile.empty())
-    {
+  if (!depfile.empty()) {
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "depfile = " << depfile << "\n";
-    }
+  }
 
   // Write the deptype if any.
-  if (!deptype.empty())
-    {
+  if (!deptype.empty()) {
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "deps = " << deptype << "\n";
-    }
+  }
 
   // Write the command.
   cmGlobalNinjaGenerator::Indent(os, 1);
   os << "command = " << command << "\n";
 
   // Write the description if any.
-  if(!description.empty())
-    {
+  if (!description.empty()) {
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "description = " << description << "\n";
-    }
+  }
 
-  if(!rspfile.empty())
-    {
-    if (rspcontent.empty())
-      {
+  if (!rspfile.empty()) {
+    if (rspcontent.empty()) {
       cmSystemTools::Error("No rspfile_content given!", comment.c_str());
       return;
-      }
+    }
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "rspfile = " << rspfile << "\n";
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "rspfile_content = " << rspcontent << "\n";
-    }
+  }
 
-  if(!restat.empty())
-    {
+  if (!restat.empty()) {
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "restat = " << restat << "\n";
-    }
+  }
 
-  if(generator)
-    {
+  if (generator) {
     cmGlobalNinjaGenerator::Indent(os, 1);
     os << "generator = 1\n";
-    }
+  }
 
   os << "\n";
 }
@@ -469,20 +397,18 @@ void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os,
                                            int indent)
 {
   // Make sure we have a name.
-  if(name.empty())
-    {
+  if (name.empty()) {
     cmSystemTools::Error("No name given for WriteVariable! called "
                          "with comment: ",
                          comment.c_str());
     return;
-    }
+  }
 
   // Do not add a variable if the value is empty.
   std::string val = cmSystemTools::TrimWhitespace(value);
-  if(val.empty())
-    {
+  if (val.empty()) {
     return;
-    }
+  }
 
   cmGlobalNinjaGenerator::WriteComment(os, comment);
   cmGlobalNinjaGenerator::Indent(os, indent);
@@ -503,12 +429,12 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os,
 {
   cmGlobalNinjaGenerator::WriteComment(os, comment);
   os << "default";
-  for(cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end(); ++i)
+  for (cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end();
+       ++i)
     os << " " << *i;
   os << "\n";
 }
 
-
 cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
   : cmGlobalCommonGenerator(cm)
   , BuildFileStream(0)
@@ -528,18 +454,14 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
   this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";
 }
 
-
-//----------------------------------------------------------------------------
 // Virtual public methods.
 
-cmLocalGenerator*
-cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf)
+cmLocalGenerator* cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
   return new cmLocalNinjaGenerator(this, mf);
 }
 
-void cmGlobalNinjaGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalNinjaGenerator::GetDocumentation(cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalNinjaGenerator::GetActualName();
   entry.Brief = "Generates build.ninja files.";
@@ -554,21 +476,24 @@ void cmGlobalNinjaGenerator::Generate()
   // Check minimum Ninja version.
   if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
                                     this->NinjaVersion.c_str(),
-                                    RequiredNinjaVersion().c_str()))
-    {
+                                    RequiredNinjaVersion().c_str())) {
     std::ostringstream msg;
     msg << "The detected version of Ninja (" << this->NinjaVersion;
     msg << ") is less than the version of Ninja required by CMake (";
     msg << this->RequiredNinjaVersion() << ").";
     this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str());
     return;
-    }
+  }
   this->OpenBuildFileStream();
   this->OpenRulesFileStream();
 
+  this->InitOutputPathPrefix();
+  this->TargetAll = this->NinjaOutputPath("all");
+  this->CMakeCacheFile = this->NinjaOutputPath("CMakeCache.txt");
+
   this->PolicyCMP0058 =
-    this->LocalGenerators[0]->GetMakefile()
-    ->GetPolicyStatus(cmPolicies::CMP0058);
+    this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus(
+      cmPolicies::CMP0058);
   this->ComputingUnknownDependencies =
     (this->PolicyCMP0058 == cmPolicies::OLD ||
      this->PolicyCMP0058 == cmPolicies::WARN);
@@ -577,6 +502,7 @@ void cmGlobalNinjaGenerator::Generate()
 
   this->WriteAssumedSourceDependencies();
   this->WriteTargetAliases(*this->BuildFileStream);
+  this->WriteFolderTargets(*this->BuildFileStream);
   this->WriteUnknownExplicitDependencies(*this->BuildFileStream);
   this->WriteBuiltinTargets(*this->BuildFileStream);
 
@@ -593,48 +519,40 @@ void cmGlobalNinjaGenerator::Generate()
 void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
 {
   this->cmGlobalGenerator::FindMakeProgram(mf);
-  if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM"))
-    {
+  if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) {
     this->NinjaCommand = ninjaCommand;
     std::vector<std::string> command;
     command.push_back(this->NinjaCommand);
     command.push_back("--version");
     std::string version;
-    cmSystemTools::RunSingleCommand(command,
-                                    &version, 0, 0, 0,
+    cmSystemTools::RunSingleCommand(command, &version, 0, 0, 0,
                                     cmSystemTools::OUTPUT_NONE);
     this->NinjaVersion = cmSystemTools::TrimWhitespace(version);
-    }
+  }
 }
 
-void cmGlobalNinjaGenerator
-::EnableLanguage(std::vector<std::string>const& langs,
-                 cmMakefile* mf,
-                 bool optional)
+void cmGlobalNinjaGenerator::EnableLanguage(
+  std::vector<std::string> const& langs, cmMakefile* mf, bool optional)
 {
-  if (std::find(langs.begin(), langs.end(), "Fortran") != langs.end())
-    {
+  if (std::find(langs.begin(), langs.end(), "Fortran") != langs.end()) {
     cmSystemTools::Error("The Ninja generator does not support Fortran yet.");
-    }
+  }
   this->cmGlobalGenerator::EnableLanguage(langs, mf, optional);
-  for(std::vector<std::string>::const_iterator l = langs.begin();
-      l != langs.end(); ++l)
-    {
-    if(*l == "NONE")
-      {
+  for (std::vector<std::string>::const_iterator l = langs.begin();
+       l != langs.end(); ++l) {
+    if (*l == "NONE") {
       continue;
-      }
-    this->ResolveLanguageCompiler(*l, mf, optional);
     }
+    this->ResolveLanguageCompiler(*l, mf, optional);
+  }
 #ifdef _WIN32
   if (mf->IsOn("CMAKE_COMPILER_IS_MINGW") ||
       strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "GNU") == 0 ||
       strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "GNU") == 0 ||
       strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "GNU") == 0 ||
-      strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "GNU") == 0)
-    {
+      strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "GNU") == 0) {
     this->UsingGCCOnWindows = true;
-    }
+  }
 #endif
 }
 
@@ -642,90 +560,62 @@ void cmGlobalNinjaGenerator
 //   cmGlobalUnixMakefileGenerator3
 //   cmGlobalGhsMultiGenerator
 //   cmGlobalVisualStudio10Generator
-//   cmGlobalVisualStudio6Generator
 //   cmGlobalVisualStudio7Generator
 //   cmGlobalXCodeGenerator
 // Called by:
 //   cmGlobalGenerator::Build()
-void cmGlobalNinjaGenerator
-::GenerateBuildCommand(std::vector<std::string>& makeCommand,
-                       const std::string& makeProgram,
-                       const std::string& /*projectName*/,
-                       const std::string& /*projectDir*/,
-                       const std::string& targetName,
-                       const std::string& /*config*/,
-                       bool /*fast*/,
-                       bool verbose,
-                       std::vector<std::string> const& makeOptions)
+void cmGlobalNinjaGenerator::GenerateBuildCommand(
+  std::vector<std::string>& makeCommand, const std::string& makeProgram,
+  const std::string& /*projectName*/, const std::string& /*projectDir*/,
+  const std::string& targetName, const std::string& /*config*/, bool /*fast*/,
+  bool verbose, std::vector<std::string> const& makeOptions)
 {
-  makeCommand.push_back(
-    this->SelectMakeProgram(makeProgram)
-    );
+  makeCommand.push_back(this->SelectMakeProgram(makeProgram));
 
-  if(verbose)
-    {
+  if (verbose) {
     makeCommand.push_back("-v");
-    }
+  }
 
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
-  if(!targetName.empty())
-    {
-    if(targetName == "clean")
-      {
+  makeCommand.insert(makeCommand.end(), makeOptions.begin(),
+                     makeOptions.end());
+  if (!targetName.empty()) {
+    if (targetName == "clean") {
       makeCommand.push_back("-t");
       makeCommand.push_back("clean");
-      }
-    else
-      {
+    } else {
       makeCommand.push_back(targetName);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 // Non-virtual public methods.
 
-void cmGlobalNinjaGenerator::AddRule(const std::string& name,
-                                     const std::string& command,
-                                     const std::string& description,
-                                     const std::string& comment,
-                                     const std::string& depfile,
-                                     const std::string& deptype,
-                                     const std::string& rspfile,
-                                     const std::string& rspcontent,
-                                     const std::string& restat,
-                                     bool generator)
+void cmGlobalNinjaGenerator::AddRule(
+  const std::string& name, const std::string& command,
+  const std::string& description, const std::string& comment,
+  const std::string& depfile, const std::string& deptype,
+  const std::string& rspfile, const std::string& rspcontent,
+  const std::string& restat, bool generator)
 {
   // Do not add the same rule twice.
-  if (this->HasRule(name))
-    {
+  if (this->HasRule(name)) {
     return;
-    }
+  }
 
   this->Rules.insert(name);
-  cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream,
-                                    name,
-                                    command,
-                                    description,
-                                    comment,
-                                    depfile,
-                                    deptype,
-                                    rspfile,
-                                    rspcontent,
-                                    restat,
-                                    generator);
-
-  this->RuleCmdLength[name] = (int) command.size();
+  cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, name, command,
+                                    description, comment, depfile, deptype,
+                                    rspfile, rspcontent, restat, generator);
+
+  this->RuleCmdLength[name] = (int)command.size();
 }
 
-bool cmGlobalNinjaGenerator::HasRule(const std::string &name)
+bool cmGlobalNinjaGenerator::HasRule(const std::string& name)
 {
   RulesSetType::const_iterator rule = this->Rules.find(name);
   return (rule != this->Rules.end());
 }
 
-//----------------------------------------------------------------------------
 // Private virtual overrides
 
 std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
@@ -735,9 +625,8 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
   return cmSystemTools::GetCMakeGUICommand();
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalNinjaGenerator
-::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+void cmGlobalNinjaGenerator::ComputeTargetObjectDirectory(
+  cmGeneratorTarget* gt) const
 {
   // Compute full path to object file directory for this target.
   std::string dir;
@@ -748,7 +637,6 @@ void cmGlobalNinjaGenerator
   gt->ObjectDirectory = dir;
 }
 
-//----------------------------------------------------------------------------
 // Private methods
 
 void cmGlobalNinjaGenerator::OpenBuildFileStream()
@@ -760,16 +648,14 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream()
   buildFilePath += cmGlobalNinjaGenerator::NINJA_BUILD_FILE;
 
   // Get a stream where to generate things.
-  if (!this->BuildFileStream)
-    {
+  if (!this->BuildFileStream) {
     this->BuildFileStream = new cmGeneratedFileStream(buildFilePath.c_str());
-    if (!this->BuildFileStream)
-      {
+    if (!this->BuildFileStream) {
       // An error message is generated by the constructor if it cannot
       // open the file.
       return;
-      }
     }
+  }
 
   // Write the do not edit header.
   this->WriteDisclaimer(*this->BuildFileStream);
@@ -777,21 +663,17 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream()
   // Write a comment about this file.
   *this->BuildFileStream
     << "# This file contains all the build statements describing the\n"
-    << "# compilation DAG.\n\n"
-    ;
+    << "# compilation DAG.\n\n";
 }
 
 void cmGlobalNinjaGenerator::CloseBuildFileStream()
 {
-  if (this->BuildFileStream)
-    {
+  if (this->BuildFileStream) {
     delete this->BuildFileStream;
     this->BuildFileStream = 0;
-    }
-  else
-    {
+  } else {
     cmSystemTools::Error("Build file stream was not open.");
-   }
+  }
 }
 
 void cmGlobalNinjaGenerator::OpenRulesFileStream()
@@ -803,80 +685,104 @@ void cmGlobalNinjaGenerator::OpenRulesFileStream()
   rulesFilePath += cmGlobalNinjaGenerator::NINJA_RULES_FILE;
 
   // Get a stream where to generate things.
-  if (!this->RulesFileStream)
-    {
+  if (!this->RulesFileStream) {
     this->RulesFileStream = new cmGeneratedFileStream(rulesFilePath.c_str());
-    if (!this->RulesFileStream)
-      {
+    if (!this->RulesFileStream) {
       // An error message is generated by the constructor if it cannot
       // open the file.
       return;
-      }
     }
+  }
 
   // Write the do not edit header.
   this->WriteDisclaimer(*this->RulesFileStream);
 
   // Write comment about this file.
+  /* clang-format off */
   *this->RulesFileStream
     << "# This file contains all the rules used to get the outputs files\n"
     << "# built from the input files.\n"
     << "# It is included in the main '" << NINJA_BUILD_FILE << "'.\n\n"
     ;
+  /* clang-format on */
 }
 
 void cmGlobalNinjaGenerator::CloseRulesFileStream()
 {
-  if (this->RulesFileStream)
-    {
+  if (this->RulesFileStream) {
     delete this->RulesFileStream;
     this->RulesFileStream = 0;
-    }
-  else
-    {
+  } else {
     cmSystemTools::Error("Rules file stream was not open.");
-   }
+  }
+}
+
+static void EnsureTrailingSlash(std::string& path)
+{
+  if (path.empty()) {
+    return;
+  }
+  std::string::value_type last = path[path.size() - 1];
+#ifdef _WIN32
+  if (last != '\\') {
+    path += '\\';
+  }
+#else
+  if (last != '/') {
+    path += '/';
+  }
+#endif
 }
 
 std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
 {
-  cmLocalNinjaGenerator *ng =
-    static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]);
+  cmLocalNinjaGenerator* ng =
+    static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
   std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT);
+  convPath = this->NinjaOutputPath(convPath);
 #ifdef _WIN32
-  cmSystemTools::ReplaceString(convPath, "/", "\\");
+  std::replace(convPath.begin(), convPath.end(), '/', '\\');
+#endif
+  return convPath;
+}
+
+std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
+  const std::string& path)
+{
+  cmLocalNinjaGenerator* ng =
+    static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
+  std::string convPath = ng->Convert(path + "/all", cmOutputConverter::HOME);
+  convPath = this->NinjaOutputPath(convPath);
+#ifdef _WIN32
+  std::replace(convPath.begin(), convPath.end(), '/', '\\');
 #endif
   return convPath;
 }
 
 void cmGlobalNinjaGenerator::AddCXXCompileCommand(
-                                      const std::string &commandLine,
-                                      const std::string &sourceFile)
+  const std::string& commandLine, const std::string& sourceFile)
 {
   // Compute Ninja's build file path.
   std::string buildFileDir =
     this->GetCMakeInstance()->GetHomeOutputDirectory();
-  if (!this->CompileCommandsStream)
-    {
+  if (!this->CompileCommandsStream) {
     std::string buildFilePath = buildFileDir + "/compile_commands.json";
 
     // Get a stream where to generate things.
     this->CompileCommandsStream =
       new cmGeneratedFileStream(buildFilePath.c_str());
     *this->CompileCommandsStream << "[";
-    } else {
+  } else {
     *this->CompileCommandsStream << "," << std::endl;
-    }
+  }
 
   std::string sourceFileName = sourceFile;
-  if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) {
     sourceFileName = cmSystemTools::CollapseFullPath(
-      sourceFileName,
-      this->GetCMakeInstance()->GetHomeOutputDirectory());
-    }
-
+      sourceFileName, this->GetCMakeInstance()->GetHomeOutputDirectory());
+  }
 
+  /* clang-format off */
   *this->CompileCommandsStream << "\n{\n"
      << "  \"directory\": \""
      << cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n"
@@ -885,27 +791,24 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
      << "  \"file\": \""
      << cmGlobalGenerator::EscapeJSON(sourceFileName) << "\"\n"
      << "}";
+  /* clang-format on */
 }
 
 void cmGlobalNinjaGenerator::CloseCompileCommandsStream()
 {
-  if (this->CompileCommandsStream)
-    {
+  if (this->CompileCommandsStream) {
     *this->CompileCommandsStream << "\n]";
     delete this->CompileCommandsStream;
     this->CompileCommandsStream = 0;
-    }
-
+  }
 }
 
 void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os)
 {
-  os
-    << "# CMAKE generated file: DO NOT EDIT!\n"
-    << "# Generated by \"" << this->GetName() << "\""
-    << " Generator, CMake Version "
-    << cmVersion::GetMajorVersion() << "."
-    << cmVersion::GetMinorVersion() << "\n\n";
+  os << "# CMAKE generated file: DO NOT EDIT!\n"
+     << "# Generated by \"" << this->GetName() << "\""
+     << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "."
+     << cmVersion::GetMinorVersion() << "\n\n";
 }
 
 void cmGlobalNinjaGenerator::AddDependencyToAll(cmGeneratorTarget* target)
@@ -920,22 +823,20 @@ void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& input)
 
 void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
 {
-  for (std::map<std::string, std::set<std::string> >::iterator
-       i = this->AssumedSourceDependencies.begin();
+  for (std::map<std::string, std::set<std::string> >::iterator i =
+         this->AssumedSourceDependencies.begin();
        i != this->AssumedSourceDependencies.end(); ++i) {
     cmNinjaDeps deps;
     std::copy(i->second.begin(), i->second.end(), std::back_inserter(deps));
     WriteCustomCommandBuild(/*command=*/"", /*description=*/"",
                             "Assume dependencies for generated source file.",
-                            /*uses_terminal*/false,
-                            /*restat*/true,
-                            cmNinjaDeps(1, i->first), deps);
+                            /*uses_terminal*/ false,
+                            /*restat*/ true, cmNinjaDeps(1, i->first), deps);
   }
 }
 
-void
-cmGlobalNinjaGenerator
-::AppendTargetOutputs(cmGeneratorTarget const* target, cmNinjaDeps& outputs)
+void cmGlobalNinjaGenerator::AppendTargetOutputs(
+  cmGeneratorTarget const* target, cmNinjaDeps& outputs)
 {
   std::string configName =
     target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -947,43 +848,36 @@ cmGlobalNinjaGenerator
   bool realname = target->IsFrameworkOnApple();
 
   switch (target->GetType()) {
-  case cmState::EXECUTABLE:
-  case cmState::SHARED_LIBRARY:
-  case cmState::STATIC_LIBRARY:
-  case cmState::MODULE_LIBRARY:
-    {
-    outputs.push_back(this->ConvertToNinjaPath(
-      target->GetFullPath(configName, false, realname)));
-    break;
+    case cmState::EXECUTABLE:
+    case cmState::SHARED_LIBRARY:
+    case cmState::STATIC_LIBRARY:
+    case cmState::MODULE_LIBRARY: {
+      outputs.push_back(this->ConvertToNinjaPath(
+        target->GetFullPath(configName, false, realname)));
+      break;
     }
-  case cmState::OBJECT_LIBRARY:
-  case cmState::UTILITY: {
-    std::string path = this->ConvertToNinjaPath(
-      target->GetLocalGenerator()->GetCurrentBinaryDirectory());
-    if (path.empty() || path == ".")
-      outputs.push_back(target->GetName());
-    else {
-      path += "/";
-      path += target->GetName();
-      outputs.push_back(path);
+    case cmState::OBJECT_LIBRARY:
+    case cmState::UTILITY: {
+      std::string path =
+        target->GetLocalGenerator()->GetCurrentBinaryDirectory() +
+        std::string("/") + target->GetName();
+      outputs.push_back(this->ConvertToNinjaPath(path));
+      break;
     }
-    break;
-  }
 
-  case cmState::GLOBAL_TARGET:
-    // Always use the target in HOME instead of an unused duplicate in a
-    // subdirectory.
-    outputs.push_back(target->GetName());
-    break;
+    case cmState::GLOBAL_TARGET:
+      // Always use the target in HOME instead of an unused duplicate in a
+      // subdirectory.
+      outputs.push_back(this->NinjaOutputPath(target->GetName()));
+      break;
 
-  default:
-    return;
+    default:
+      return;
   }
 }
 
-void
-cmGlobalNinjaGenerator
-::AppendTargetDepends(cmGeneratorTarget const* target, cmNinjaDeps& outputs)
+void cmGlobalNinjaGenerator::AppendTargetDepends(
+  cmGeneratorTarget const* target, cmNinjaDeps& outputs)
 {
   if (target->GetType() == cmState::GLOBAL_TARGET) {
     // Global targets only depend on other utilities, which may not appear in
@@ -991,21 +885,24 @@ cmGlobalNinjaGenerator
     std::set<std::string> const& utils = target->GetUtilities();
     std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
   } else {
+    cmNinjaDeps outs;
     cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
     for (cmTargetDependSet::const_iterator i = targetDeps.begin();
-         i != targetDeps.end(); ++i)
-      {
-      if ((*i)->GetType() == cmState::INTERFACE_LIBRARY)
-        {
+         i != targetDeps.end(); ++i) {
+      if ((*i)->GetType() == cmState::INTERFACE_LIBRARY) {
         continue;
-        }
-      this->AppendTargetOutputs(*i, outputs);
+      }
+      this->AppendTargetOutputs(*i, outs);
     }
+    std::sort(outs.begin(), outs.end());
+    outputs.insert(outputs.end(), outs.begin(), outs.end());
   }
 }
 
 void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
-                                            cmGeneratorTarget* target) {
+                                            cmGeneratorTarget* target)
+{
+  std::string buildAlias = this->NinjaOutputPath(alias);
   cmNinjaDeps outputs;
   this->AppendTargetOutputs(target, outputs);
   // Mark the target's outputs as ambiguous to ensure that no other target uses
@@ -1016,7 +913,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
   // Insert the alias into the map.  If the alias was already present in the
   // map and referred to another target, mark it as ambiguous.
   std::pair<TargetAliasMap::iterator, bool> newAlias =
-    TargetAliases.insert(std::make_pair(alias, target));
+    TargetAliases.insert(std::make_pair(buildAlias, target));
   if (newAlias.second && newAlias.first->second != target)
     newAlias.first->second = 0;
 }
@@ -1035,19 +932,78 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
     cmNinjaDeps deps;
     this->AppendTargetOutputs(i->second, deps);
 
-    this->WritePhonyBuild(os,
-                          "",
-                          cmNinjaDeps(1, i->first),
-                          deps);
+    this->WritePhonyBuild(os, "", cmNinjaDeps(1, i->first), deps);
+  }
+}
+
+void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
+{
+  cmGlobalNinjaGenerator::WriteDivider(os);
+  os << "# Folder targets.\n\n";
+
+  std::map<std::string, cmNinjaDeps> targetsPerFolder;
+  for (std::vector<cmLocalGenerator*>::const_iterator lgi =
+         this->LocalGenerators.begin();
+       lgi != this->LocalGenerators.end(); ++lgi) {
+    cmLocalGenerator const* lg = *lgi;
+    const std::string currentSourceFolder(
+      lg->GetStateSnapshot().GetDirectory().GetCurrentSource());
+    // The directory-level rule should depend on the target-level rules
+    // for all targets in the directory.
+    targetsPerFolder[currentSourceFolder] = cmNinjaDeps();
+    for (std::vector<cmGeneratorTarget*>::const_iterator ti =
+           lg->GetGeneratorTargets().begin();
+         ti != lg->GetGeneratorTargets().end(); ++ti) {
+      cmGeneratorTarget const* gt = *ti;
+      cmState::TargetType const type = gt->GetType();
+      if ((type == cmState::EXECUTABLE || type == cmState::STATIC_LIBRARY ||
+           type == cmState::SHARED_LIBRARY ||
+           type == cmState::MODULE_LIBRARY ||
+           type == cmState::OBJECT_LIBRARY || type == cmState::UTILITY) &&
+          !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+        targetsPerFolder[currentSourceFolder].push_back(gt->GetName());
+      }
+    }
+
+    // The directory-level rule should depend on the directory-level
+    // rules of the subdirectories.
+    std::vector<cmState::Snapshot> const& children =
+      lg->GetStateSnapshot().GetChildren();
+    for (std::vector<cmState::Snapshot>::const_iterator stateIt =
+           children.begin();
+         stateIt != children.end(); ++stateIt) {
+      targetsPerFolder[currentSourceFolder].push_back(
+        this->ConvertToNinjaFolderRule(
+          stateIt->GetDirectory().GetCurrentSource()));
+    }
+  }
+
+  std::string const rootSourceDir =
+    this->LocalGenerators[0]->GetSourceDirectory();
+  for (std::map<std::string, cmNinjaDeps>::const_iterator it =
+         targetsPerFolder.begin();
+       it != targetsPerFolder.end(); ++it) {
+    cmGlobalNinjaGenerator::WriteDivider(os);
+    std::string const& currentSourceDir = it->first;
+
+    // Do not generate a rule for the root source dir.
+    if (rootSourceDir.length() >= currentSourceDir.length()) {
+      continue;
+    }
+
+    std::string const comment = "Folder: " + currentSourceDir;
+    cmNinjaDeps output(1);
+    output.push_back(this->ConvertToNinjaFolderRule(currentSourceDir));
+
+    this->WritePhonyBuild(os, comment, output, it->second);
   }
 }
 
 void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
 {
-  if (!this->ComputingUnknownDependencies)
-    {
+  if (!this->ComputingUnknownDependencies) {
     return;
-    }
+  }
 
   // We need to collect the set of known build outputs.
   // Start with those generated by WriteBuild calls.
@@ -1056,120 +1012,109 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
   std::set<std::string> knownDependencies;
   knownDependencies.swap(this->CombinedBuildOutputs);
 
-  //now write out the unknown explicit dependencies.
+  // now write out the unknown explicit dependencies.
 
-  //union the configured files, evaluations files and the CombinedBuildOutputs,
-  //and then difference with CombinedExplicitDependencies to find the explicit
-  //dependencies that we have no rule for
+  // union the configured files, evaluations files and the
+  // CombinedBuildOutputs,
+  // and then difference with CombinedExplicitDependencies to find the explicit
+  // dependencies that we have no rule for
 
   cmGlobalNinjaGenerator::WriteDivider(os);
+  /* clang-format off */
   os << "# Unknown Build Time Dependencies.\n"
      << "# Tell Ninja that they may appear as side effects of build rules\n"
      << "# otherwise ordered by order-only dependencies.\n\n";
+  /* clang-format on */
 
-  //get the list of files that cmake itself has generated as a
-  //product of configuration.
+  // get the list of files that cmake itself has generated as a
+  // product of configuration.
 
-  for (std::vector<cmLocalGenerator *>::const_iterator i =
-       this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i)
-    {
-    //get the vector of files created by this makefile and convert them
-    //to ninja paths, which are all relative in respect to the build directory
+  for (std::vector<cmLocalGenerator*>::const_iterator i =
+         this->LocalGenerators.begin();
+       i != this->LocalGenerators.end(); ++i) {
+    // get the vector of files created by this makefile and convert them
+    // to ninja paths, which are all relative in respect to the build directory
     const std::vector<std::string>& files =
-                                    (*i)->GetMakefile()->GetOutputFiles();
+      (*i)->GetMakefile()->GetOutputFiles();
     typedef std::vector<std::string>::const_iterator vect_it;
-    for(vect_it j = files.begin(); j != files.end(); ++j)
-      {
-      knownDependencies.insert( this->ConvertToNinjaPath( *j ) );
-      }
-    //get list files which are implicit dependencies as well and will be phony
-    //for rebuild manifest
+    for (vect_it j = files.begin(); j != files.end(); ++j) {
+      knownDependencies.insert(this->ConvertToNinjaPath(*j));
+    }
+    // get list files which are implicit dependencies as well and will be phony
+    // for rebuild manifest
     std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
     typedef std::vector<std::string>::const_iterator vect_it;
-    for(vect_it j = lf.begin(); j != lf.end(); ++j)
-      {
-      knownDependencies.insert( this->ConvertToNinjaPath( *j ) );
-      }
+    for (vect_it j = lf.begin(); j != lf.end(); ++j) {
+      knownDependencies.insert(this->ConvertToNinjaPath(*j));
+    }
     std::vector<cmGeneratorExpressionEvaluationFile*> const& ef =
-        (*i)->GetMakefile()->GetEvaluationFiles();
-    for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
-        li = ef.begin(); li != ef.end(); ++li)
-      {
-      //get all the files created by generator expressions and convert them
-      //to ninja paths
+      (*i)->GetMakefile()->GetEvaluationFiles();
+    for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
+           ef.begin();
+         li != ef.end(); ++li) {
+      // get all the files created by generator expressions and convert them
+      // to ninja paths
       std::vector<std::string> evaluationFiles = (*li)->GetFiles();
-      for(vect_it j = evaluationFiles.begin(); j != evaluationFiles.end(); ++j)
-        {
-        knownDependencies.insert( this->ConvertToNinjaPath( *j ) );
-        }
+      for (vect_it j = evaluationFiles.begin(); j != evaluationFiles.end();
+           ++j) {
+        knownDependencies.insert(this->ConvertToNinjaPath(*j));
       }
     }
-  knownDependencies.insert( "CMakeCache.txt" );
+  }
+  knownDependencies.insert(this->CMakeCacheFile);
 
-  for(TargetAliasMap::const_iterator i= this->TargetAliases.begin();
-      i != this->TargetAliases.end();
-      ++i)
-    {
-    knownDependencies.insert( this->ConvertToNinjaPath(i->first) );
-    }
+  for (TargetAliasMap::const_iterator i = this->TargetAliases.begin();
+       i != this->TargetAliases.end(); ++i) {
+    knownDependencies.insert(this->ConvertToNinjaPath(i->first));
+  }
 
-  //remove all source files we know will exist.
+  // remove all source files we know will exist.
   typedef std::map<std::string, std::set<std::string> >::const_iterator map_it;
-  for(map_it i = this->AssumedSourceDependencies.begin();
-      i != this->AssumedSourceDependencies.end();
-      ++i)
-    {
-    knownDependencies.insert( this->ConvertToNinjaPath(i->first) );
-    }
+  for (map_it i = this->AssumedSourceDependencies.begin();
+       i != this->AssumedSourceDependencies.end(); ++i) {
+    knownDependencies.insert(this->ConvertToNinjaPath(i->first));
+  }
 
-  //now we difference with CombinedCustomCommandExplicitDependencies to find
-  //the list of items we know nothing about.
-  //We have encoded all the paths in CombinedCustomCommandExplicitDependencies
-  //and knownDependencies so no matter if unix or windows paths they
-  //should all match now.
+  // now we difference with CombinedCustomCommandExplicitDependencies to find
+  // the list of items we know nothing about.
+  // We have encoded all the paths in CombinedCustomCommandExplicitDependencies
+  // and knownDependencies so no matter if unix or windows paths they
+  // should all match now.
 
   std::vector<std::string> unknownExplicitDepends;
-  this->CombinedCustomCommandExplicitDependencies.erase("all");
+  this->CombinedCustomCommandExplicitDependencies.erase(this->TargetAll);
 
   std::set_difference(this->CombinedCustomCommandExplicitDependencies.begin(),
                       this->CombinedCustomCommandExplicitDependencies.end(),
-                      knownDependencies.begin(),
-                      knownDependencies.end(),
+                      knownDependencies.begin(), knownDependencies.end(),
                       std::back_inserter(unknownExplicitDepends));
 
   std::string const rootBuildDirectory =
-      this->GetCMakeInstance()->GetHomeOutputDirectory();
+    this->GetCMakeInstance()->GetHomeOutputDirectory();
   bool const inSourceBuild =
     (rootBuildDirectory == this->GetCMakeInstance()->GetHomeDirectory());
   std::vector<std::string> warnExplicitDepends;
-  for (std::vector<std::string>::const_iterator
-       i = unknownExplicitDepends.begin();
-       i != unknownExplicitDepends.end();
-       ++i)
-    {
-    //verify the file is in the build directory
-    std::string const absDepPath = cmSystemTools::CollapseFullPath(
-                                     *i, rootBuildDirectory.c_str());
-    bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath,
-                                                  rootBuildDirectory);
-    if(inBuildDir)
-      {
-      cmNinjaDeps deps(1,*i);
-      this->WritePhonyBuild(os,
-                            "",
-                            deps,
-                            cmNinjaDeps());
-      if (this->PolicyCMP0058 == cmPolicies::WARN &&
-          !inSourceBuild && warnExplicitDepends.size() < 10)
-        {
+  for (std::vector<std::string>::const_iterator i =
+         unknownExplicitDepends.begin();
+       i != unknownExplicitDepends.end(); ++i) {
+    // verify the file is in the build directory
+    std::string const absDepPath =
+      cmSystemTools::CollapseFullPath(*i, rootBuildDirectory.c_str());
+    bool const inBuildDir =
+      cmSystemTools::IsSubDirectory(absDepPath, rootBuildDirectory);
+    if (inBuildDir) {
+      cmNinjaDeps deps(1, *i);
+      this->WritePhonyBuild(os, "", deps, cmNinjaDeps());
+      if (this->PolicyCMP0058 == cmPolicies::WARN && !inSourceBuild &&
+          warnExplicitDepends.size() < 10) {
         warnExplicitDepends.push_back(*i);
-        }
       }
-   }
+    }
+  }
 
-  if (!warnExplicitDepends.empty())
-    {
+  if (!warnExplicitDepends.empty()) {
     std::ostringstream w;
+    /* clang-format off */
     w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0058) << "\n"
       "This project specifies custom command DEPENDS on files "
       "in the build tree that are not specified as the OUTPUT or "
@@ -1183,8 +1128,9 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
       "Project authors should add the missing BYPRODUCTS or OUTPUT "
       "options to the custom commands that produce these files."
       ;
+    /* clang-format on */
     this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-    }
+  }
 }
 
 void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
@@ -1202,55 +1148,50 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
 void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os)
 {
   cmNinjaDeps outputs;
-  outputs.push_back("all");
+  outputs.push_back(this->TargetAll);
 
-  this->WritePhonyBuild(os,
-                        "The main all target.",
-                        outputs,
+  this->WritePhonyBuild(os, "The main all target.", outputs,
                         this->AllDependencies);
 
-  cmGlobalNinjaGenerator::WriteDefault(os,
-                                       outputs,
-                                       "Make the all target the default.");
+  if (!this->HasOutputPathPrefix()) {
+    cmGlobalNinjaGenerator::WriteDefault(os, outputs,
+                                         "Make the all target the default.");
+  }
 }
 
 void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
 {
-  cmLocalGenerator *lg = this->LocalGenerators[0];
+  cmLocalGenerator* lg = this->LocalGenerators[0];
 
   std::ostringstream cmd;
   cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
-                                   cmLocalGenerator::SHELL)
+                                   cmOutputConverter::SHELL)
       << " -H"
       << lg->ConvertToOutputFormat(lg->GetSourceDirectory(),
-                                   cmLocalGenerator::SHELL)
+                                   cmOutputConverter::SHELL)
       << " -B"
       << lg->ConvertToOutputFormat(lg->GetBinaryDirectory(),
-                                   cmLocalGenerator::SHELL);
-  WriteRule(*this->RulesFileStream,
-            "RERUN_CMAKE",
-            cmd.str(),
-            "Re-running CMake...",
-            "Rule for re-running cmake.",
-            /*depfile=*/ "",
-            /*deptype=*/ "",
-            /*rspfile=*/ "",
+                                   cmOutputConverter::SHELL);
+  WriteRule(*this->RulesFileStream, "RERUN_CMAKE", cmd.str(),
+            "Re-running CMake...", "Rule for re-running cmake.",
+            /*depfile=*/"",
+            /*deptype=*/"",
+            /*rspfile=*/"",
             /*rspcontent*/ "",
-            /*restat=*/ "",
-            /*generator=*/ true);
+            /*restat=*/"",
+            /*generator=*/true);
 
   cmNinjaDeps implicitDeps;
-  for(std::vector<cmLocalGenerator*>::const_iterator i =
-        this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator i =
+         this->LocalGenerators.begin();
+       i != this->LocalGenerators.end(); ++i) {
     std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
-    for(std::vector<std::string>::const_iterator fi = lf.begin();
-        fi != lf.end(); ++fi)
-      {
+    for (std::vector<std::string>::const_iterator fi = lf.begin();
+         fi != lf.end(); ++fi) {
       implicitDeps.push_back(this->ConvertToNinjaPath(*fi));
-      }
     }
-  implicitDeps.push_back("CMakeCache.txt");
+  }
+  implicitDeps.push_back(this->CMakeCacheFile);
 
   std::sort(implicitDeps.begin(), implicitDeps.end());
   implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()),
@@ -1259,24 +1200,19 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
   cmNinjaVars variables;
   // Use 'console' pool to get non buffered output of the CMake re-run call
   // Available since Ninja 1.5
-  if(SupportsConsolePool())
-    {
+  if (SupportsConsolePool()) {
     variables["pool"] = "console";
-    }
+  }
 
-  this->WriteBuild(os,
-                   "Re-run CMake if any of its inputs changed.",
+  std::string const ninjaBuildFile = this->NinjaOutputPath(NINJA_BUILD_FILE);
+  this->WriteBuild(os, "Re-run CMake if any of its inputs changed.",
                    "RERUN_CMAKE",
-                   /*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE),
-                   /*explicitDeps=*/ cmNinjaDeps(),
-                   implicitDeps,
-                   /*orderOnlyDeps=*/ cmNinjaDeps(),
-                   variables);
-
-  this->WritePhonyBuild(os,
-                        "A missing CMake input file is not an error.",
-                        implicitDeps,
-                        cmNinjaDeps());
+                   /*outputs=*/cmNinjaDeps(1, ninjaBuildFile),
+                   /*explicitDeps=*/cmNinjaDeps(), implicitDeps,
+                   /*orderOnlyDeps=*/cmNinjaDeps(), variables);
+
+  this->WritePhonyBuild(os, "A missing CMake input file is not an error.",
+                        implicitDeps, cmNinjaDeps());
 }
 
 std::string cmGlobalNinjaGenerator::ninjaCmd() const
@@ -1284,60 +1220,78 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
   cmLocalGenerator* lgen = this->LocalGenerators[0];
   if (lgen) {
     return lgen->ConvertToOutputFormat(this->NinjaCommand,
-                                       cmLocalGenerator::SHELL);
+                                       cmOutputConverter::SHELL);
   }
   return "ninja";
 }
 
 bool cmGlobalNinjaGenerator::SupportsConsolePool() const
 {
-  return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
-    this->NinjaVersion.c_str(),
-    RequiredNinjaVersionForConsolePool().c_str()) == false;
+  return cmSystemTools::VersionCompare(
+           cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
+           RequiredNinjaVersionForConsolePool().c_str()) == false;
 }
 
 void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
 {
-  WriteRule(*this->RulesFileStream,
-            "CLEAN",
-            ninjaCmd() + " -t clean",
+  WriteRule(*this->RulesFileStream, "CLEAN", ninjaCmd() + " -t clean",
             "Cleaning all built files...",
             "Rule for cleaning all built files.",
-            /*depfile=*/ "",
-            /*deptype=*/ "",
-            /*rspfile=*/ "",
+            /*depfile=*/"",
+            /*deptype=*/"",
+            /*rspfile=*/"",
             /*rspcontent*/ "",
-            /*restat=*/ "",
-            /*generator=*/ false);
-  WriteBuild(os,
-             "Clean all the built files.",
-             "CLEAN",
-             /*outputs=*/ cmNinjaDeps(1, "clean"),
-             /*explicitDeps=*/ cmNinjaDeps(),
-             /*implicitDeps=*/ cmNinjaDeps(),
-             /*orderOnlyDeps=*/ cmNinjaDeps(),
-             /*variables=*/ cmNinjaVars());
+            /*restat=*/"",
+            /*generator=*/false);
+  WriteBuild(os, "Clean all the built files.", "CLEAN",
+             /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("clean")),
+             /*explicitDeps=*/cmNinjaDeps(),
+             /*implicitDeps=*/cmNinjaDeps(),
+             /*orderOnlyDeps=*/cmNinjaDeps(),
+             /*variables=*/cmNinjaVars());
 }
 
 void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
 {
-  WriteRule(*this->RulesFileStream,
-            "HELP",
-            ninjaCmd() + " -t targets",
+  WriteRule(*this->RulesFileStream, "HELP", ninjaCmd() + " -t targets",
             "All primary targets available:",
             "Rule for printing all primary targets available.",
-            /*depfile=*/ "",
-            /*deptype=*/ "",
-            /*rspfile=*/ "",
+            /*depfile=*/"",
+            /*deptype=*/"",
+            /*rspfile=*/"",
             /*rspcontent*/ "",
-            /*restat=*/ "",
-            /*generator=*/ false);
-  WriteBuild(os,
-             "Print all primary targets available.",
-             "HELP",
-             /*outputs=*/ cmNinjaDeps(1, "help"),
-             /*explicitDeps=*/ cmNinjaDeps(),
-             /*implicitDeps=*/ cmNinjaDeps(),
-             /*orderOnlyDeps=*/ cmNinjaDeps(),
-             /*variables=*/ cmNinjaVars());
+            /*restat=*/"",
+            /*generator=*/false);
+  WriteBuild(os, "Print all primary targets available.", "HELP",
+             /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("help")),
+             /*explicitDeps=*/cmNinjaDeps(),
+             /*implicitDeps=*/cmNinjaDeps(),
+             /*orderOnlyDeps=*/cmNinjaDeps(),
+             /*variables=*/cmNinjaVars());
+}
+
+void cmGlobalNinjaGenerator::InitOutputPathPrefix()
+{
+  this->OutputPathPrefix =
+    this->LocalGenerators[0]->GetMakefile()->GetSafeDefinition(
+      "CMAKE_NINJA_OUTPUT_PATH_PREFIX");
+  EnsureTrailingSlash(this->OutputPathPrefix);
+}
+
+std::string cmGlobalNinjaGenerator::NinjaOutputPath(std::string const& path)
+{
+  if (!this->HasOutputPathPrefix() || cmSystemTools::FileIsFullPath(path)) {
+    return path;
+  }
+  return this->OutputPathPrefix + path;
+}
+
+void cmGlobalNinjaGenerator::StripNinjaOutputPathPrefixAsSuffix(
+  std::string& path)
+{
+  if (path.empty()) {
+    return;
+  }
+  EnsureTrailingSlash(path);
+  cmStripSuffixIfExists(path, this->OutputPathPrefix);
 }
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 8656590..6d9bfe8 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -11,11 +11,12 @@
   See the License for more information.
 ============================================================================*/
 #ifndef cmGlobalNinjaGenerator_h
-#  define cmGlobalNinjaGenerator_h
+#define cmGlobalNinjaGenerator_h
 
-#  include "cmGlobalCommonGenerator.h"
-#  include "cmGlobalGeneratorFactory.h"
-#  include "cmNinjaTypes.h"
+#include "cmGlobalCommonGenerator.h"
+
+#include "cmGlobalGeneratorFactory.h"
+#include "cmNinjaTypes.h"
 
 //#define NINJA_GEN_VERBOSE_FILES
 
@@ -62,10 +63,10 @@ public:
   static void WriteDivider(std::ostream& os);
 
   static std::string EncodeRuleName(std::string const& name);
-  static std::string EncodeIdent(const std::string &ident, std::ostream &vars);
-  static std::string EncodeLiteral(const std::string &lit);
-  std::string EncodePath(const std::string &path);
-  static std::string EncodeDepfileSpace(const std::string &path);
+  static std::string EncodeIdent(const std::string& ident, std::ostream& vars);
+  static std::string EncodeLiteral(const std::string& lit);
+  std::string EncodePath(const std::string& path);
+  static std::string EncodeDepfileSpace(const std::string& path);
 
   /**
    * Write the given @a comment to the output stream @a os. It
@@ -85,23 +86,19 @@ public:
    * It also writes the variables bound to this build statement.
    * @warning no escaping of any kind is done here.
    */
-  void WriteBuild(std::ostream& os,
-                  const std::string& comment,
-                  const std::string& rule,
-                  const cmNinjaDeps& outputs,
+  void WriteBuild(std::ostream& os, const std::string& comment,
+                  const std::string& rule, const cmNinjaDeps& outputs,
                   const cmNinjaDeps& explicitDeps,
                   const cmNinjaDeps& implicitDeps,
                   const cmNinjaDeps& orderOnlyDeps,
                   const cmNinjaVars& variables,
                   const std::string& rspfile = std::string(),
-                  int cmdLineLimit = -1,
-                  bool* usedResponseFile = 0);
+                  int cmdLineLimit = 0, bool* usedResponseFile = 0);
 
   /**
    * Helper to write a build statement with the special 'phony' rule.
    */
-  void WritePhonyBuild(std::ostream& os,
-                       const std::string& comment,
+  void WritePhonyBuild(std::ostream& os, const std::string& comment,
                        const cmNinjaDeps& outputs,
                        const cmNinjaDeps& explicitDeps,
                        const cmNinjaDeps& implicitDeps = cmNinjaDeps(),
@@ -110,10 +107,8 @@ public:
 
   void WriteCustomCommandBuild(const std::string& command,
                                const std::string& description,
-                               const std::string& comment,
-                               bool uses_terminal,
-                               bool restat,
-                               const cmNinjaDeps& outputs,
+                               const std::string& comment, bool uses_terminal,
+                               bool restat, const cmNinjaDeps& outputs,
                                const cmNinjaDeps& deps = cmNinjaDeps(),
                                const cmNinjaDeps& orderOnly = cmNinjaDeps());
   void WriteMacOSXContentBuild(const std::string& input,
@@ -125,43 +120,35 @@ public:
    * It also writes the variables bound to this rule statement.
    * @warning no escaping of any kind is done here.
    */
-  static void WriteRule(std::ostream& os,
-                        const std::string& name,
+  static void WriteRule(std::ostream& os, const std::string& name,
                         const std::string& command,
                         const std::string& description,
-                        const std::string& comment,
-                        const std::string& depfile,
-                        const std::string& deptype,
-                        const std::string& rspfile,
+                        const std::string& comment, const std::string& depfile,
+                        const std::string& deptype, const std::string& rspfile,
                         const std::string& rspcontent,
-                        const std::string& restat,
-                        bool generator);
+                        const std::string& restat, bool generator);
 
   /**
    * Write a variable named @a name to @a os with value @a value and an
    * optional @a comment. An @a indent level can be specified.
    * @warning no escaping of any kind is done here.
    */
-  static void WriteVariable(std::ostream& os,
-                            const std::string& name,
+  static void WriteVariable(std::ostream& os, const std::string& name,
                             const std::string& value,
-                            const std::string& comment = "",
-                            int indent = 0);
+                            const std::string& comment = "", int indent = 0);
 
   /**
    * Write an include statement including @a filename with an optional
    * @a comment to the @a os stream.
    */
-  static void WriteInclude(std::ostream& os,
-                           const std::string& filename,
+  static void WriteInclude(std::ostream& os, const std::string& filename,
                            const std::string& comment = "");
 
   /**
    * Write a default target statement specifying @a targets as
    * the default targets.
    */
-  static void WriteDefault(std::ostream& os,
-                           const cmNinjaDeps& targets,
+  static void WriteDefault(std::ostream& os, const cmNinjaDeps& targets,
                            const std::string& comment = "");
 
   bool IsGCCOnWindows() const { return UsingGCCOnWindows; }
@@ -169,123 +156,130 @@ public:
 public:
   cmGlobalNinjaGenerator(cmake* cm);
 
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>();
+  }
 
-  virtual ~cmGlobalNinjaGenerator() { }
+  virtual ~cmGlobalNinjaGenerator() {}
 
   virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
-  virtual std::string GetName() const {
-    return cmGlobalNinjaGenerator::GetActualName(); }
+  virtual std::string GetName() const
+  {
+    return cmGlobalNinjaGenerator::GetActualName();
+  }
 
   static std::string GetActualName() { return "Ninja"; }
 
   static void GetDocumentation(cmDocumentationEntry& entry);
 
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile* mf,
-                              bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile* mf, bool optional);
 
   virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
-    const std::string& projectName,
-    const std::string& projectDir,
-    const std::string& targetName,
-    const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    std::vector<std::string> const& makeOptions = std::vector<std::string>());
 
   // Setup target names
-  virtual const char* GetAllTargetName()           const { return "all"; }
-  virtual const char* GetInstallTargetName()       const { return "install"; }
-  virtual const char* GetInstallLocalTargetName()  const {
+  virtual const char* GetAllTargetName() const { return "all"; }
+  virtual const char* GetInstallTargetName() const { return "install"; }
+  virtual const char* GetInstallLocalTargetName() const
+  {
     return "install/local";
   }
-  virtual const char* GetInstallStripTargetName()  const {
+  virtual const char* GetInstallStripTargetName() const
+  {
     return "install/strip";
   }
-  virtual const char* GetTestTargetName()          const { return "test"; }
-  virtual const char* GetPackageTargetName()       const { return "package"; }
-  virtual const char* GetPackageSourceTargetName() const {
+  virtual const char* GetTestTargetName() const { return "test"; }
+  virtual const char* GetPackageTargetName() const { return "package"; }
+  virtual const char* GetPackageSourceTargetName() const
+  {
     return "package_source";
   }
-  virtual const char* GetEditCacheTargetName()     const {
-    return "edit_cache";
-  }
-  virtual const char* GetRebuildCacheTargetName()  const {
+  virtual const char* GetEditCacheTargetName() const { return "edit_cache"; }
+  virtual const char* GetRebuildCacheTargetName() const
+  {
     return "rebuild_cache";
   }
-  virtual const char* GetCleanTargetName()         const { return "clean"; }
-
+  virtual const char* GetCleanTargetName() const { return "clean"; }
 
-  cmGeneratedFileStream* GetBuildFileStream() const {
-    return this->BuildFileStream; }
+  cmGeneratedFileStream* GetBuildFileStream() const
+  {
+    return this->BuildFileStream;
+  }
 
-  cmGeneratedFileStream* GetRulesFileStream() const {
-    return this->RulesFileStream; }
+  cmGeneratedFileStream* GetRulesFileStream() const
+  {
+    return this->RulesFileStream;
+  }
 
   std::string ConvertToNinjaPath(const std::string& path);
+  std::string ConvertToNinjaFolderRule(const std::string& path);
 
-  struct MapToNinjaPathImpl {
+  struct MapToNinjaPathImpl
+  {
     cmGlobalNinjaGenerator* GG;
-    MapToNinjaPathImpl(cmGlobalNinjaGenerator* gg): GG(gg) {}
-    std::string operator()(std::string const& path) {
+    MapToNinjaPathImpl(cmGlobalNinjaGenerator* gg)
+      : GG(gg)
+    {
+    }
+    std::string operator()(std::string const& path)
+    {
       return this->GG->ConvertToNinjaPath(path);
     }
   };
-  MapToNinjaPathImpl MapToNinjaPath() {
-    return MapToNinjaPathImpl(this);
-  }
+  MapToNinjaPathImpl MapToNinjaPath() { return MapToNinjaPathImpl(this); }
 
-  void AddCXXCompileCommand(const std::string &commandLine,
-                            const std::string &sourceFile);
+  void AddCXXCompileCommand(const std::string& commandLine,
+                            const std::string& sourceFile);
 
   /**
    * Add a rule to the generated build system.
    * Call WriteRule() behind the scene but perform some check before like:
    * - Do not add twice the same rule.
    */
-  void AddRule(const std::string& name,
-               const std::string& command,
-               const std::string& description,
-               const std::string& comment,
-               const std::string& depfile,
-               const std::string& deptype,
-               const std::string& rspfile,
-               const std::string& rspcontent,
-               const std::string& restat,
-               bool generator);
+  void AddRule(const std::string& name, const std::string& command,
+               const std::string& description, const std::string& comment,
+               const std::string& depfile, const std::string& deptype,
+               const std::string& rspfile, const std::string& rspcontent,
+               const std::string& restat, bool generator);
 
   bool HasRule(const std::string& name);
 
   void AddCustomCommandRule();
   void AddMacOSXContentRule();
 
-  bool HasCustomCommandOutput(const std::string &output) {
+  bool HasCustomCommandOutput(const std::string& output)
+  {
     return this->CustomCommandOutputs.find(output) !=
-           this->CustomCommandOutputs.end();
+      this->CustomCommandOutputs.end();
   }
 
   /// Called when we have seen the given custom command.  Returns true
   /// if we has seen it before.
-  bool SeenCustomCommand(cmCustomCommand const *cc) {
+  bool SeenCustomCommand(cmCustomCommand const* cc)
+  {
     return !this->CustomCommands.insert(cc).second;
   }
 
   /// Called when we have seen the given custom command output.
-  void SeenCustomCommandOutput(const std::string &output) {
+  void SeenCustomCommandOutput(const std::string& output)
+  {
     this->CustomCommandOutputs.insert(output);
     // We don't need the assumed dependencies anymore, because we have
     // an output.
     this->AssumedSourceDependencies.erase(output);
   }
 
-  void AddAssumedSourceDependencies(const std::string &source,
-                                    const cmNinjaDeps &deps) {
-    std::set<std::string> &ASD = this->AssumedSourceDependencies[source];
+  void AddAssumedSourceDependencies(const std::string& source,
+                                    const cmNinjaDeps& deps)
+  {
+    std::set<std::string>& ASD = this->AssumedSourceDependencies[source];
     // Because we may see the same source file multiple times (same source
     // specified in multiple targets), compute the union of any assumed
     // dependencies.
@@ -299,14 +293,17 @@ public:
   void AddDependencyToAll(cmGeneratorTarget* target);
   void AddDependencyToAll(const std::string& input);
 
-  const std::vector<cmLocalGenerator*>& GetLocalGenerators() const {
-    return LocalGenerators; }
+  const std::vector<cmLocalGenerator*>& GetLocalGenerators() const
+  {
+    return LocalGenerators;
+  }
 
-  bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) {
-    return cmGlobalGenerator::IsExcluded(root, target); }
+  bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target)
+  {
+    return cmGlobalGenerator::IsExcluded(root, target);
+  }
 
-  int GetRuleCmdLength(const std::string& name) {
-    return RuleCmdLength[name]; }
+  int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; }
 
   void AddTargetAlias(const std::string& alias, cmGeneratorTarget* target);
 
@@ -317,13 +314,15 @@ public:
   static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
   bool SupportsConsolePool() const;
 
-protected:
+  std::string NinjaOutputPath(std::string const& path);
+  bool HasOutputPathPrefix() const { return !this->OutputPathPrefix.empty(); }
+  void StripNinjaOutputPathPrefixAsSuffix(std::string& path);
 
+protected:
   virtual void Generate();
 
   virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; }
 
-
 private:
   virtual std::string GetEditCacheCommand() const;
   virtual void FindMakeProgram(cmMakefile* mf);
@@ -342,6 +341,7 @@ private:
   void WriteAssumedSourceDependencies();
 
   void WriteTargetAliases(std::ostream& os);
+  void WriteFolderTargets(std::ostream& os);
   void WriteUnknownExplicitDependencies(std::ostream& os);
 
   void WriteBuiltinTargets(std::ostream& os);
@@ -401,6 +401,13 @@ private:
 
   std::string NinjaCommand;
   std::string NinjaVersion;
+
+private:
+  void InitOutputPathPrefix();
+
+  std::string OutputPathPrefix;
+  std::string TargetAll;
+  std::string CMakeCacheFile;
 };
 
 #endif // ! cmGlobalNinjaGenerator_h
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index ce7815d..cc5d1ba 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -10,13 +10,14 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalUnixMakefileGenerator3.h"
+
+#include "cmAlgorithms.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorTarget.h"
 #include "cmLocalUnixMakefileGenerator3.h"
-#include "cmMakefileTargetGenerator.h"
 #include "cmMakefile.h"
+#include "cmMakefileTargetGenerator.h"
 #include "cmake.h"
-#include "cmGeneratedFileStream.h"
-#include "cmGeneratorTarget.h"
-#include "cmAlgorithms.h"
 
 cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
   : cmGlobalCommonGenerator(cm)
@@ -39,78 +40,65 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
   this->UnixCD = true;
 }
 
-void cmGlobalUnixMakefileGenerator3
-::EnableLanguage(std::vector<std::string>const& languages,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalUnixMakefileGenerator3::EnableLanguage(
+  std::vector<std::string> const& languages, cmMakefile* mf, bool optional)
 {
   this->cmGlobalGenerator::EnableLanguage(languages, mf, optional);
-  for(std::vector<std::string>::const_iterator l = languages.begin();
-      l != languages.end(); ++l)
-    {
-    if(*l == "NONE")
-      {
+  for (std::vector<std::string>::const_iterator l = languages.begin();
+       l != languages.end(); ++l) {
+    if (*l == "NONE") {
       continue;
-      }
-    this->ResolveLanguageCompiler(*l, mf, optional);
     }
+    this->ResolveLanguageCompiler(*l, mf, optional);
+  }
 }
 
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(
-    cmMakefile* mf)
+  cmMakefile* mf)
 {
   return new cmLocalUnixMakefileGenerator3(this, mf);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalUnixMakefileGenerator3
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalUnixMakefileGenerator3::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalUnixMakefileGenerator3::GetActualName();
   entry.Brief = "Generates standard UNIX makefiles.";
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const
 {
   // If generating for an extra IDE, the edit_cache target cannot
   // launch a terminal-interactive tool, so always use cmake-gui.
-  if(!this->GetExtraGeneratorName().empty())
-    {
+  if (!this->GetExtraGeneratorName().empty()) {
     return cmSystemTools::GetCMakeGUICommand();
-    }
+  }
 
   // Use an internal cache entry to track the latest dialog used
   // to edit the cache, and use that for the edit_cache target.
   cmake* cm = this->GetCMakeInstance();
   std::string editCacheCommand = cm->GetCMakeEditCommand();
-  if(!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") ||
-     !editCacheCommand.empty())
-    {
-    if(editCacheCommand.empty())
-      {
+  if (!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") ||
+      !editCacheCommand.empty()) {
+    if (editCacheCommand.empty()) {
       editCacheCommand = cmSystemTools::GetCMakeCursesCommand();
-      }
-    if(editCacheCommand.empty())
-      {
+    }
+    if (editCacheCommand.empty()) {
       editCacheCommand = cmSystemTools::GetCMakeGUICommand();
-      }
-    if(!editCacheCommand.empty())
-      {
-      cm->AddCacheEntry
-        ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
-         "Path to cache edit program executable.", cmState::INTERNAL);
-      }
     }
+    if (!editCacheCommand.empty()) {
+      cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
+                        "Path to cache edit program executable.",
+                        cmState::INTERNAL);
+    }
+  }
   const char* edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND");
-  return edit_cmd? edit_cmd : "";
+  return edit_cmd ? edit_cmd : "";
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory(
+  cmGeneratorTarget* gt) const
 {
   // Compute full path to object file directory for this target.
   std::string dir;
@@ -136,11 +124,10 @@ void cmGlobalUnixMakefileGenerator3::Generate()
 
   // initialize progress
   unsigned long total = 0;
-  for(ProgressMapType::const_iterator pmi = this->ProgressMap.begin();
-      pmi != this->ProgressMap.end(); ++pmi)
-    {
+  for (ProgressMapType::const_iterator pmi = this->ProgressMap.begin();
+       pmi != this->ProgressMap.end(); ++pmi) {
     total += pmi->second.NumberOfActions;
-    }
+  }
 
   // write each target's progress.make this loop is done twice. Bascially the
   // Generate pass counts all the actions, the first loop below determines
@@ -150,21 +137,19 @@ void cmGlobalUnixMakefileGenerator3::Generate()
   // well. This is because the all targets require more information that is
   // computed in the first loop.
   unsigned long current = 0;
-  for(ProgressMapType::iterator pmi = this->ProgressMap.begin();
-      pmi != this->ProgressMap.end(); ++pmi)
-    {
+  for (ProgressMapType::iterator pmi = this->ProgressMap.begin();
+       pmi != this->ProgressMap.end(); ++pmi) {
     pmi->second.WriteProgressVariables(total, current);
-    }
-  for(unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    cmLocalGenerator *lg = this->LocalGenerators[i];
+  }
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
+    cmLocalGenerator* lg = this->LocalGenerators[i];
     std::string markFileName = lg->GetCurrentBinaryDirectory();
     markFileName += "/";
     markFileName += cmake::GetCMakeFilesDirectory();
     markFileName += "/progress.marks";
     cmGeneratedFileStream markFile(markFileName.c_str());
     markFile << this->CountProgressMarksInAll(lg) << "\n";
-    }
+  }
 
   // write the main makefile
   this->WriteMainMakefile2();
@@ -178,29 +163,30 @@ void cmGlobalUnixMakefileGenerator3::Generate()
 }
 
 void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
-    const std::string &sourceFile, const std::string &workingDirectory,
-    const std::string &compileCommand) {
-  if (this->CommandDatabase == NULL)
-    {
+  const std::string& sourceFile, const std::string& workingDirectory,
+  const std::string& compileCommand)
+{
+  if (this->CommandDatabase == NULL) {
     std::string commandDatabaseName =
-      std::string(this->GetCMakeInstance()->GetHomeOutputDirectory())
-      + "/compile_commands.json";
+      std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
+      "/compile_commands.json";
     this->CommandDatabase =
       new cmGeneratedFileStream(commandDatabaseName.c_str());
     *this->CommandDatabase << "[" << std::endl;
-    } else {
+  } else {
     *this->CommandDatabase << "," << std::endl;
-    }
+  }
   *this->CommandDatabase << "{" << std::endl
-      << "  \"directory\": \""
-      << cmGlobalGenerator::EscapeJSON(workingDirectory) << "\","
-      << std::endl
-      << "  \"command\": \"" <<
-      cmGlobalGenerator::EscapeJSON(compileCommand) << "\","
-      << std::endl
-      << "  \"file\": \"" <<
-      cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
-      << std::endl << "}";
+                         << "  \"directory\": \""
+                         << cmGlobalGenerator::EscapeJSON(workingDirectory)
+                         << "\"," << std::endl
+                         << "  \"command\": \""
+                         << cmGlobalGenerator::EscapeJSON(compileCommand)
+                         << "\"," << std::endl
+                         << "  \"file\": \""
+                         << cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
+                         << std::endl
+                         << "}";
 }
 
 void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
@@ -213,14 +199,13 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
   makefileName += cmake::GetCMakeFilesDirectory();
   makefileName += "/Makefile2";
   cmGeneratedFileStream makefileStream(makefileName.c_str());
-  if(!makefileStream)
-    {
+  if (!makefileStream) {
     return;
-    }
+  }
 
   // get a local generator for some useful methods
-  cmLocalUnixMakefileGenerator3 *lg =
-    static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
+  cmLocalUnixMakefileGenerator3* lg =
+    static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
 
   // Write the do not edit header.
   lg->WriteDisclaimer(makefileStream);
@@ -236,47 +221,38 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
   lg->WriteMakeRule(makefileStream,
                     "Default target executed when no arguments are "
                     "given to make.",
-                    "default_target",
-                    depends,
-                    no_commands, true);
+                    "default_target", depends, no_commands, true);
 
   depends.clear();
 
   // The all and preinstall rules might never have any dependencies
   // added to them.
-  if(this->EmptyRuleHackDepends != "")
-    {
+  if (this->EmptyRuleHackDepends != "") {
     depends.push_back(this->EmptyRuleHackDepends);
-    }
+  }
 
   // Write and empty all:
-  lg->WriteMakeRule(makefileStream,
-                    "The main recursive all target", "all",
+  lg->WriteMakeRule(makefileStream, "The main recursive all target", "all",
                     depends, no_commands, true);
 
   // Write an empty preinstall:
-  lg->WriteMakeRule(makefileStream,
-                    "The main recursive preinstall target", "preinstall",
-                    depends, no_commands, true);
+  lg->WriteMakeRule(makefileStream, "The main recursive preinstall target",
+                    "preinstall", depends, no_commands, true);
 
   // Write out the "special" stuff
   lg->WriteSpecialTargetsTop(makefileStream);
 
   // write the target convenience rules
   unsigned int i;
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    lg =
-      static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
-    this->WriteConvenienceRules2(makefileStream,lg);
-    }
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
+    lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+    this->WriteConvenienceRules2(makefileStream, lg);
+  }
 
-  lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
+  lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
   lg->WriteSpecialTargetsBottom(makefileStream);
 }
 
-
-//----------------------------------------------------------------------------
 void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
 {
   // Open the output file.  This should not be copy-if-different
@@ -287,48 +263,45 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   cmakefileName += cmake::GetCMakeFilesDirectory();
   cmakefileName += "/Makefile.cmake";
   cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
-  if(!cmakefileStream)
-    {
+  if (!cmakefileStream) {
     return;
-    }
+  }
 
   std::string makefileName =
     this->GetCMakeInstance()->GetHomeOutputDirectory();
   makefileName += "/Makefile";
 
   // get a local generator for some useful methods
-  cmLocalUnixMakefileGenerator3 *lg =
-    static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
+  cmLocalUnixMakefileGenerator3* lg =
+    static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
 
   // Write the do not edit header.
   lg->WriteDisclaimer(cmakefileStream);
 
   // Save the generator name
-  cmakefileStream
-    << "# The generator used is:\n"
-    << "set(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n";
+  cmakefileStream << "# The generator used is:\n"
+                  << "set(CMAKE_DEPENDS_GENERATOR \"" << this->GetName()
+                  << "\")\n\n";
 
   // for each cmMakefile get its list of dependencies
   std::vector<std::string> lfiles;
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    lg =
-      static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
+    lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
 
     // Get the list of files contributing to this generation step.
-    lfiles.insert(lfiles.end(),lg->GetMakefile()->GetListFiles().begin(),
+    lfiles.insert(lfiles.end(), lg->GetMakefile()->GetListFiles().begin(),
                   lg->GetMakefile()->GetListFiles().end());
-    }
+  }
   // Sort the list and remove duplicates.
   std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
 #if !defined(__VMS) // The Compaq STL on VMS crashes, so accept duplicates.
   std::vector<std::string>::iterator new_end =
-    std::unique(lfiles.begin(),lfiles.end());
+    std::unique(lfiles.begin(), lfiles.end());
   lfiles.erase(new_end, lfiles.end());
 #endif
 
   // reset lg to the first makefile
-  lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
+  lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
 
   // Build the path to the cache file.
   std::string cache = this->GetCMakeInstance()->GetHomeOutputDirectory();
@@ -338,19 +311,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   cmakefileStream
     << "# The top level Makefile was generated from the following files:\n"
     << "set(CMAKE_MAKEFILE_DEPENDS\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, cmLocalGenerator::START_OUTPUT)
-      << "\"\n";
-    }
-  cmakefileStream
-    << "  )\n\n";
+    << "  \"" << lg->Convert(cache, cmOutputConverter::START_OUTPUT) << "\"\n";
+  for (std::vector<std::string>::const_iterator i = lfiles.begin();
+       i != lfiles.end(); ++i) {
+    cmakefileStream << "  \""
+                    << lg->Convert(*i, cmOutputConverter::START_OUTPUT)
+                    << "\"\n";
+  }
+  cmakefileStream << "  )\n\n";
 
   // Build the path to the cache check file.
   std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
@@ -358,97 +326,83 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
   check += "/cmake.check_cache";
 
   // Set the corresponding makefile in the cmake file.
-  cmakefileStream
-    << "# The corresponding makefile is:\n"
-    << "set(CMAKE_MAKEFILE_OUTPUTS\n"
-    << "  \""
-    << lg->Convert(makefileName,
-                   cmLocalGenerator::START_OUTPUT) << "\"\n"
-    << "  \""
-    << lg->Convert(check,
-                   cmLocalGenerator::START_OUTPUT) << "\"\n";
+  cmakefileStream << "# The corresponding makefile is:\n"
+                  << "set(CMAKE_MAKEFILE_OUTPUTS\n"
+                  << "  \""
+                  << lg->Convert(makefileName, cmOutputConverter::START_OUTPUT)
+                  << "\"\n"
+                  << "  \""
+                  << lg->Convert(check, cmOutputConverter::START_OUTPUT)
+                  << "\"\n";
   cmakefileStream << "  )\n\n";
 
   // CMake must rerun if a byproduct is missing.
   {
-  cmakefileStream
-    << "# Byproducts of CMake generate step:\n"
-    << "set(CMAKE_MAKEFILE_PRODUCTS\n";
-  const std::vector<std::string>& outfiles =
-    lg->GetMakefile()->GetOutputFiles();
-  for(std::vector<std::string>::const_iterator k = outfiles.begin();
-      k != outfiles.end(); ++k)
-    {
-    cmakefileStream << "  \"" <<
-      lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT)
-                    << "\"\n";
-    }
-
-  // add in all the directory information files
-  std::string tmpStr;
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    lg =
-      static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
-    tmpStr = lg->GetCurrentBinaryDirectory();
-    tmpStr += cmake::GetCMakeFilesDirectory();
-    tmpStr += "/CMakeDirectoryInformation.cmake";
-    cmakefileStream << "  \"" <<
-      lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT)
-                    << "\"\n";
-    }
-  cmakefileStream << "  )\n\n";
+    cmakefileStream << "# Byproducts of CMake generate step:\n"
+                    << "set(CMAKE_MAKEFILE_PRODUCTS\n";
+    const std::vector<std::string>& outfiles =
+      lg->GetMakefile()->GetOutputFiles();
+    for (std::vector<std::string>::const_iterator k = outfiles.begin();
+         k != outfiles.end(); ++k) {
+      cmakefileStream << "  \""
+                      << lg->Convert(*k, cmOutputConverter::HOME_OUTPUT)
+                      << "\"\n";
+    }
+
+    // add in all the directory information files
+    std::string tmpStr;
+    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
+      lg =
+        static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+      tmpStr = lg->GetCurrentBinaryDirectory();
+      tmpStr += cmake::GetCMakeFilesDirectory();
+      tmpStr += "/CMakeDirectoryInformation.cmake";
+      cmakefileStream << "  \""
+                      << lg->Convert(tmpStr, cmOutputConverter::HOME_OUTPUT)
+                      << "\"\n";
+    }
+    cmakefileStream << "  )\n\n";
   }
 
   this->WriteMainCMakefileLanguageRules(cmakefileStream,
                                         this->LocalGenerators);
 }
 
-void cmGlobalUnixMakefileGenerator3
-::WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
-                                  std::vector<cmLocalGenerator *> &lGenerators
-                                  )
+void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules(
+  cmGeneratedFileStream& cmakefileStream,
+  std::vector<cmLocalGenerator*>& lGenerators)
 {
-  cmLocalUnixMakefileGenerator3 *lg;
+  cmLocalUnixMakefileGenerator3* lg;
 
   // now list all the target info files
-  cmakefileStream
-    << "# Dependency information for all targets:\n";
-  cmakefileStream
-    << "set(CMAKE_DEPEND_INFO_FILES\n";
-  for (unsigned int i = 0; i < lGenerators.size(); ++i)
-    {
-    lg = static_cast<cmLocalUnixMakefileGenerator3 *>(lGenerators[i]);
+  cmakefileStream << "# Dependency information for all targets:\n";
+  cmakefileStream << "set(CMAKE_DEPEND_INFO_FILES\n";
+  for (unsigned int i = 0; i < lGenerators.size(); ++i) {
+    lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]);
     // for all of out targets
     std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-         l != tgts.end(); l++)
-      {
-      if(((*l)->GetType() == cmState::EXECUTABLE) ||
-         ((*l)->GetType() == cmState::STATIC_LIBRARY) ||
-         ((*l)->GetType() == cmState::SHARED_LIBRARY) ||
-         ((*l)->GetType() == cmState::MODULE_LIBRARY) ||
-         ((*l)->GetType() == cmState::OBJECT_LIBRARY) ||
-         ((*l)->GetType() == cmState::UTILITY))
-        {
+         l != tgts.end(); l++) {
+      if (((*l)->GetType() == cmState::EXECUTABLE) ||
+          ((*l)->GetType() == cmState::STATIC_LIBRARY) ||
+          ((*l)->GetType() == cmState::SHARED_LIBRARY) ||
+          ((*l)->GetType() == cmState::MODULE_LIBRARY) ||
+          ((*l)->GetType() == cmState::OBJECT_LIBRARY) ||
+          ((*l)->GetType() == cmState::UTILITY)) {
         cmGeneratorTarget* gt = *l;
         std::string tname = lg->GetRelativeTargetDirectory(gt);
         tname += "/DependInfo.cmake";
         cmSystemTools::ConvertToUnixSlashes(tname);
         cmakefileStream << "  \"" << tname << "\"\n";
-        }
       }
     }
+  }
   cmakefileStream << "  )\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::WriteDirectoryRule2(std::ostream& ruleFileStream,
-                      cmLocalUnixMakefileGenerator3* lg,
-                      const char* pass, bool check_all,
-                      bool check_relink)
+void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
+  std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg,
+  const char* pass, bool check_all, bool check_relink)
 {
   // Get the relative path to the subdirectory from the top.
   std::string makeTarget = lg->GetCurrentBinaryDirectory();
@@ -459,81 +413,67 @@ cmGlobalUnixMakefileGenerator3
   // for all targets in the directory.
   std::vector<std::string> depends;
   std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
-      l != targets.end(); ++l)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
+       l != targets.end(); ++l) {
     cmGeneratorTarget* gtarget = *l;
     int type = gtarget->GetType();
-    if((type == cmState::EXECUTABLE) ||
-       (type == cmState::STATIC_LIBRARY) ||
-       (type == cmState::SHARED_LIBRARY) ||
-       (type == cmState::MODULE_LIBRARY) ||
-       (type == cmState::OBJECT_LIBRARY) ||
-       (type == cmState::UTILITY))
-      {
+    if ((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) ||
+        (type == cmState::SHARED_LIBRARY) ||
+        (type == cmState::MODULE_LIBRARY) ||
+        (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY)) {
       // Add this to the list of depends rules in this directory.
-      if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
-         (!check_relink ||
-          gtarget
-            ->NeedRelinkBeforeInstall(lg->GetConfigName())))
-        {
+      if ((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
+          (!check_relink ||
+           gtarget->NeedRelinkBeforeInstall(lg->GetConfigName()))) {
         std::string tname = lg->GetRelativeTargetDirectory(gtarget);
         tname += "/";
         tname += pass;
         depends.push_back(tname);
-        }
       }
     }
+  }
 
   // The directory-level rule should depend on the directory-level
   // rules of the subdirectories.
-  std::vector<cmState::Snapshot> children
-      = lg->GetStateSnapshot().GetChildren();
-  for(std::vector<cmState::Snapshot>::const_iterator
-        ci = children.begin(); ci != children.end(); ++ci)
-    {
+  std::vector<cmState::Snapshot> children =
+    lg->GetStateSnapshot().GetChildren();
+  for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin();
+       ci != children.end(); ++ci) {
     std::string subdir = ci->GetDirectory().GetCurrentBinary();
     subdir += "/";
     subdir += pass;
     depends.push_back(subdir);
-    }
+  }
 
   // Work-around for makes that drop rules that have no dependencies
   // or commands.
-  if(depends.empty() && this->EmptyRuleHackDepends != "")
-    {
+  if (depends.empty() && this->EmptyRuleHackDepends != "") {
     depends.push_back(this->EmptyRuleHackDepends);
-    }
+  }
 
   // Write the rule.
   std::string doc = "Convenience name for \"";
   doc += pass;
   doc += "\" pass in the directory.";
   std::vector<std::string> no_commands;
-  lg->WriteMakeRule(ruleFileStream, doc.c_str(),
-                    makeTarget, depends, no_commands, true);
+  lg->WriteMakeRule(ruleFileStream, doc.c_str(), makeTarget, depends,
+                    no_commands, true);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::WriteDirectoryRules2(std::ostream& ruleFileStream,
-                       cmLocalUnixMakefileGenerator3* lg)
+void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
+  std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
 {
   // Only subdirectories need these rules.
-  if(lg->IsRootMakefile())
-    {
+  if (lg->IsRootMakefile()) {
     return;
-    }
+  }
 
   // Begin the directory-level rules section.
   std::string dir = lg->GetCurrentBinaryDirectory();
-  dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT,
-                    cmLocalGenerator::MAKERULE);
+  dir = lg->Convert(dir, cmOutputConverter::HOME_OUTPUT,
+                    cmOutputConverter::MAKERULE);
   lg->WriteDivider(ruleFileStream);
-  ruleFileStream
-    << "# Directory level rules for directory "
-    << dir << "\n\n";
+  ruleFileStream << "# Directory level rules for directory " << dir << "\n\n";
 
   // Write directory-level rules for "all".
   this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false);
@@ -545,68 +485,51 @@ cmGlobalUnixMakefileGenerator3
   this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalUnixMakefileGenerator3
-::GenerateBuildCommand(std::vector<std::string>& makeCommand,
-                       const std::string& makeProgram,
-                       const std::string& /*projectName*/,
-                       const std::string& /*projectDir*/,
-                       const std::string& targetName,
-                       const std::string& /*config*/,
-                       bool fast, bool /*verbose*/,
-                       std::vector<std::string> const& makeOptions)
+void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
+  std::vector<std::string>& makeCommand, const std::string& makeProgram,
+  const std::string& /*projectName*/, const std::string& /*projectDir*/,
+  const std::string& targetName, const std::string& /*config*/, bool fast,
+  bool /*verbose*/, std::vector<std::string> const& makeOptions)
 {
-  makeCommand.push_back(
-    this->SelectMakeProgram(makeProgram)
-    );
+  makeCommand.push_back(this->SelectMakeProgram(makeProgram));
 
   // Since we have full control over the invocation of nmake, let us
   // make it quiet.
-  if (cmHasLiteralPrefix(this->GetName(), "NMake Makefiles"))
-    {
+  if (cmHasLiteralPrefix(this->GetName(), "NMake Makefiles")) {
     makeCommand.push_back("/NOLOGO");
-    }
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
-  if (!targetName.empty())
-    {
+  }
+  makeCommand.insert(makeCommand.end(), makeOptions.begin(),
+                     makeOptions.end());
+  if (!targetName.empty()) {
     cmMakefile* mf;
-    if (!this->Makefiles.empty())
-      {
+    if (!this->Makefiles.empty()) {
       mf = this->Makefiles[0];
-      }
-    else
-      {
+    } else {
       cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
-      snapshot.GetDirectory().SetCurrentSource
-        (this->CMakeInstance->GetHomeDirectory());
-      snapshot.GetDirectory().SetCurrentBinary
-        (this->CMakeInstance->GetHomeOutputDirectory());
+      snapshot.GetDirectory().SetCurrentSource(
+        this->CMakeInstance->GetHomeDirectory());
+      snapshot.GetDirectory().SetCurrentBinary(
+        this->CMakeInstance->GetHomeOutputDirectory());
       snapshot.SetDefaultDefinitions();
       mf = new cmMakefile(this, snapshot);
-      }
+    }
 
     std::string tname = targetName;
-    if(fast)
-      {
+    if (fast) {
       tname += "/fast";
-      }
+    }
     cmOutputConverter conv(mf->GetStateSnapshot());
-    tname = conv.Convert(tname,cmOutputConverter::HOME_OUTPUT);
+    tname = conv.Convert(tname, cmOutputConverter::HOME_OUTPUT);
     cmSystemTools::ConvertToOutputSlashes(tname);
     makeCommand.push_back(tname);
-    if (this->Makefiles.empty())
-      {
+    if (this->Makefiles.empty()) {
       delete mf;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::WriteConvenienceRules(std::ostream& ruleFileStream,
-                        std::set<std::string> &emitted)
+void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
+  std::ostream& ruleFileStream, std::set<std::string>& emitted)
 {
   std::vector<std::string> depends;
   std::vector<std::string> commands;
@@ -615,54 +538,43 @@ cmGlobalUnixMakefileGenerator3
 
   // write the target convenience rules
   unsigned int i;
-  cmLocalUnixMakefileGenerator3 *lg;
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    lg = static_cast<cmLocalUnixMakefileGenerator3 *>
-      (this->LocalGenerators[i]);
+  cmLocalUnixMakefileGenerator3* lg;
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
+    lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
     // for each target Generate the rule files for each target.
     std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
-    for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-        t != targets.end(); ++t)
-      {
+    for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+         t != targets.end(); ++t) {
       cmGeneratorTarget* gtarget = *t;
       // Don't emit the same rule twice (e.g. two targets with the same
       // simple name)
       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.
-         ((type == cmState::EXECUTABLE) ||
-          (type == cmState::STATIC_LIBRARY) ||
-          (type == cmState::SHARED_LIBRARY) ||
-          (type == cmState::MODULE_LIBRARY) ||
-          (type == cmState::OBJECT_LIBRARY) ||
-          (type == cmState::UTILITY)))
-        {
+      if (!name.empty() && emitted.insert(name).second &&
+          // Handle user targets here.  Global targets are handled in
+          // the local generator on a per-directory basis.
+          ((type == cmState::EXECUTABLE) ||
+           (type == cmState::STATIC_LIBRARY) ||
+           (type == cmState::SHARED_LIBRARY) ||
+           (type == cmState::MODULE_LIBRARY) ||
+           (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY))) {
         // Add a rule to build the target by name.
         lg->WriteDivider(ruleFileStream);
-        ruleFileStream
-          << "# Target rules for targets named "
-          << name << "\n\n";
+        ruleFileStream << "# Target rules for targets named " << name
+                       << "\n\n";
 
         // Write the rule.
         commands.clear();
         std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
         tmp += "Makefile2";
-        commands.push_back(lg->GetRecursiveMakeCall
-                            (tmp.c_str(),name));
+        commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name));
         depends.clear();
         depends.push_back("cmake_check_build_system");
-        lg->WriteMakeRule(ruleFileStream,
-                          "Build rule for target.",
-                          name, depends, commands,
-                          true);
+        lg->WriteMakeRule(ruleFileStream, "Build rule for target.", name,
+                          depends, commands, true);
 
         // Add a fast rule to build the target
-        std::string localName =
-                          lg->GetRelativeTargetDirectory(gtarget);
+        std::string localName = lg->GetRelativeTargetDirectory(gtarget);
         std::string makefileName;
         makefileName = localName;
         makefileName += "/build.make";
@@ -672,67 +584,56 @@ cmGlobalUnixMakefileGenerator3
         makeTargetName += "/build";
         localName = name;
         localName += "/fast";
-        commands.push_back(lg->GetRecursiveMakeCall
-                            (makefileName.c_str(), makeTargetName));
+        commands.push_back(
+          lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
         lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
                           localName, depends, commands, true);
 
         // Add a local name for the rule to relink the target before
         // installation.
-        if(gtarget
-             ->NeedRelinkBeforeInstall(lg->GetConfigName()))
-          {
+        if (gtarget->NeedRelinkBeforeInstall(lg->GetConfigName())) {
           makeTargetName = lg->GetRelativeTargetDirectory(gtarget);
           makeTargetName += "/preinstall";
           localName = name;
           localName += "/preinstall";
           depends.clear();
           commands.clear();
-          commands.push_back(lg->GetRecursiveMakeCall
-                             (makefileName.c_str(), makeTargetName));
+          commands.push_back(
+            lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
           lg->WriteMakeRule(ruleFileStream,
                             "Manual pre-install relink rule for target.",
                             localName, depends, commands, true);
-          }
         }
       }
     }
+  }
 }
 
-
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::WriteConvenienceRules2(std::ostream& ruleFileStream,
-                         cmLocalUnixMakefileGenerator3 *lg)
+void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
+  std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
 {
   std::vector<std::string> depends;
   std::vector<std::string> commands;
   std::string localName;
   std::string makeTargetName;
 
-
   // write the directory level rules for this local gen
-  this->WriteDirectoryRules2(ruleFileStream,lg);
+  this->WriteDirectoryRules2(ruleFileStream, lg);
 
   depends.push_back("cmake_check_build_system");
 
   // for each target Generate the rule files for each target.
   std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+       t != targets.end(); ++t) {
     cmGeneratorTarget* gtarget = *t;
     int type = gtarget->GetType();
     std::string name = gtarget->GetName();
-    if (!name.empty()
-     && (  (type == cmState::EXECUTABLE)
-        || (type == cmState::STATIC_LIBRARY)
-        || (type == cmState::SHARED_LIBRARY)
-        || (type == cmState::MODULE_LIBRARY)
-        || (type == cmState::OBJECT_LIBRARY)
-        || (type == cmState::UTILITY)))
-      {
+    if (!name.empty() &&
+        ((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) ||
+         (type == cmState::SHARED_LIBRARY) ||
+         (type == cmState::MODULE_LIBRARY) ||
+         (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY))) {
       std::string makefileName;
       // Add a rule to build the target by name.
       localName = lg->GetRelativeTargetDirectory(gtarget);
@@ -742,28 +643,25 @@ cmGlobalUnixMakefileGenerator3
       bool needRequiresStep = this->NeedRequiresStep(gtarget);
 
       lg->WriteDivider(ruleFileStream);
-      ruleFileStream
-        << "# Target rules for target "
-        << localName << "\n\n";
+      ruleFileStream << "# Target rules for target " << localName << "\n\n";
 
       commands.clear();
       makeTargetName = localName;
       makeTargetName += "/depend";
-      commands.push_back(lg->GetRecursiveMakeCall
-                         (makefileName.c_str(),makeTargetName));
+      commands.push_back(
+        lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
 
       // add requires if we need it for this generator
-      if (needRequiresStep)
-        {
+      if (needRequiresStep) {
         makeTargetName = localName;
         makeTargetName += "/requires";
-        commands.push_back(lg->GetRecursiveMakeCall
-                          (makefileName.c_str(),makeTargetName));
-        }
+        commands.push_back(
+          lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+      }
       makeTargetName = localName;
       makeTargetName += "/build";
-      commands.push_back(lg->GetRecursiveMakeCall
-                         (makefileName.c_str(),makeTargetName));
+      commands.push_back(
+        lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
 
       // Write the rule.
       localName += "/all";
@@ -773,76 +671,68 @@ cmGlobalUnixMakefileGenerator3
       progress.Dir = lg->GetBinaryDirectory();
       progress.Dir += cmake::GetCMakeFilesDirectory();
       {
-      std::ostringstream progressArg;
-      const char* sep = "";
-      std::vector<unsigned long>& progFiles =
-        this->ProgressMap[gtarget].Marks;
-      for (std::vector<unsigned long>::iterator i = progFiles.begin();
-           i != progFiles.end(); ++i)
-        {
-        progressArg << sep << *i;
-        sep = ",";
+        std::ostringstream progressArg;
+        const char* sep = "";
+        std::vector<unsigned long>& progFiles =
+          this->ProgressMap[gtarget].Marks;
+        for (std::vector<unsigned long>::iterator i = progFiles.begin();
+             i != progFiles.end(); ++i) {
+          progressArg << sep << *i;
+          sep = ",";
         }
-      progress.Arg = progressArg.str();
+        progress.Arg = progressArg.str();
       }
 
       bool targetMessages = true;
-      if (const char* tgtMsg = this->GetCMakeInstance()
-                                   ->GetState()
-                                   ->GetGlobalProperty("TARGET_MESSAGES"))
-        {
+      if (const char* tgtMsg =
+            this->GetCMakeInstance()->GetState()->GetGlobalProperty(
+              "TARGET_MESSAGES")) {
         targetMessages = cmSystemTools::IsOn(tgtMsg);
-        }
+      }
 
-      if (targetMessages)
-        {
+      if (targetMessages) {
         lg->AppendEcho(commands, "Built target " + name,
-          cmLocalUnixMakefileGenerator3::EchoNormal, &progress);
-        }
+                       cmLocalUnixMakefileGenerator3::EchoNormal, &progress);
+      }
 
       this->AppendGlobalTargetDepends(depends, gtarget);
       lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
                         localName, depends, commands, true);
 
       // add the all/all dependency
-      if(!this->IsExcluded(this->LocalGenerators[0], gtarget))
-        {
+      if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
         depends.clear();
         depends.push_back(localName);
         commands.clear();
-        lg->WriteMakeRule(ruleFileStream, "Include target in all.",
-                          "all", depends, commands, true);
-        }
+        lg->WriteMakeRule(ruleFileStream, "Include target in all.", "all",
+                          depends, commands, true);
+      }
 
       // Write the rule.
       commands.clear();
 
       {
-      // TODO: Convert the total progress count to a make variable.
-      std::ostringstream progCmd;
-      progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
-      // # in target
-      progCmd << lg->Convert(progress.Dir,
-                              cmLocalGenerator::FULL,
-                              cmLocalGenerator::SHELL);
-      //
-      std::set<cmGeneratorTarget const*> emitted;
-      progCmd << " "
-              << this->CountProgressMarksInTarget(gtarget, emitted);
-      commands.push_back(progCmd.str());
+        // TODO: Convert the total progress count to a make variable.
+        std::ostringstream progCmd;
+        progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
+        // # in target
+        progCmd << lg->Convert(progress.Dir, cmOutputConverter::FULL,
+                               cmOutputConverter::SHELL);
+        //
+        std::set<cmGeneratorTarget const*> emitted;
+        progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted);
+        commands.push_back(progCmd.str());
       }
       std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
       tmp += "Makefile2";
-      commands.push_back(lg->GetRecursiveMakeCall
-                          (tmp.c_str(),localName));
+      commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName));
       {
-      std::ostringstream progCmd;
-      progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
-      progCmd << lg->Convert(progress.Dir,
-                              cmLocalGenerator::FULL,
-                              cmLocalGenerator::SHELL);
-      progCmd << " 0";
-      commands.push_back(progCmd.str());
+        std::ostringstream progCmd;
+        progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
+        progCmd << lg->Convert(progress.Dir, cmOutputConverter::FULL,
+                               cmOutputConverter::SHELL);
+        progCmd << " 0";
+        commands.push_back(progCmd.str());
       }
       depends.clear();
       depends.push_back("cmake_check_build_system");
@@ -856,32 +746,29 @@ cmGlobalUnixMakefileGenerator3
       commands.clear();
       depends.clear();
       depends.push_back(localName);
-      lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
-                        name, depends, commands, true);
+      lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", name,
+                        depends, commands, true);
 
       // Add rules to prepare the target for installation.
-      if(gtarget
-           ->NeedRelinkBeforeInstall(lg->GetConfigName()))
-        {
+      if (gtarget->NeedRelinkBeforeInstall(lg->GetConfigName())) {
         localName = lg->GetRelativeTargetDirectory(gtarget);
         localName += "/preinstall";
         depends.clear();
         commands.clear();
-        commands.push_back(lg->GetRecursiveMakeCall
-                            (makefileName.c_str(), localName));
+        commands.push_back(
+          lg->GetRecursiveMakeCall(makefileName.c_str(), localName));
         lg->WriteMakeRule(ruleFileStream,
-                          "Pre-install relink rule for target.",
-                          localName, depends, commands, true);
+                          "Pre-install relink rule for target.", localName,
+                          depends, commands, true);
 
-        if(!this->IsExcluded(this->LocalGenerators[0], gtarget))
-          {
+        if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
           depends.clear();
           depends.push_back(localName);
           commands.clear();
           lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
                             "preinstall", depends, commands, true);
-          }
         }
+      }
 
       // add the clean rule
       localName = lg->GetRelativeTargetDirectory(gtarget);
@@ -889,16 +776,16 @@ cmGlobalUnixMakefileGenerator3
       makeTargetName += "/clean";
       depends.clear();
       commands.clear();
-      commands.push_back(lg->GetRecursiveMakeCall
-                          (makefileName.c_str(), makeTargetName));
+      commands.push_back(
+        lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
       lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
                         makeTargetName, depends, commands, true);
       commands.clear();
       depends.push_back(makeTargetName);
-      lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
-                        "clean", depends, commands, true);
-      }
+      lg->WriteMakeRule(ruleFileStream, "clean rule for target.", "clean",
+                        depends, commands, true);
     }
+  }
 }
 
 // Build a map that contains a the set of targets used by each local
@@ -907,33 +794,29 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
 {
   this->DirectoryTargetsMap.clear();
   // Loop over all targets in all local generators.
-  for(std::vector<cmLocalGenerator*>::const_iterator
-        lgi = this->LocalGenerators.begin();
-      lgi != this->LocalGenerators.end(); ++lgi)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator lgi =
+         this->LocalGenerators.begin();
+       lgi != this->LocalGenerators.end(); ++lgi) {
     cmLocalGenerator* lg = *lgi;
     std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
-    for(std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
-        t != targets.end(); ++t)
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
+         t != targets.end(); ++t) {
       cmGeneratorTarget* gt = *t;
 
       cmLocalGenerator* tlg = gt->GetLocalGenerator();
 
-      if(gt->GetType() == cmState::INTERFACE_LIBRARY
-          || gt->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-        {
+      if (gt->GetType() == cmState::INTERFACE_LIBRARY ||
+          gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
         continue;
-        }
+      }
 
       cmState::Snapshot csnp = lg->GetStateSnapshot();
       cmState::Snapshot tsnp = tlg->GetStateSnapshot();
 
       // Consider the directory containing the target and all its
       // parents until something excludes the target.
-      for( ; csnp.IsValid() && !this->IsExcluded(csnp, tsnp);
-          csnp = csnp.GetBuildsystemDirectoryParent())
-        {
+      for (; csnp.IsValid() && !this->IsExcluded(csnp, tsnp);
+           csnp = csnp.GetBuildsystemDirectoryParent()) {
         // This local generator includes the target.
         std::set<cmGeneratorTarget const*>& targetSet =
           this->DirectoryTargetsMap[csnp];
@@ -943,60 +826,48 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
         // target may still be included if it is a dependency of a
         // non-excluded target.
         TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt);
-        for(TargetDependSet::const_iterator ti = tgtdeps.begin();
-            ti != tgtdeps.end(); ++ti)
-          {
+        for (TargetDependSet::const_iterator ti = tgtdeps.begin();
+             ti != tgtdeps.end(); ++ti) {
           targetSet.insert(*ti);
-          }
         }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-size_t
-cmGlobalUnixMakefileGenerator3
-::CountProgressMarksInTarget(cmGeneratorTarget const* target,
-                             std::set<cmGeneratorTarget const*>& emitted)
+size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget(
+  cmGeneratorTarget const* target, std::set<cmGeneratorTarget const*>& emitted)
 {
   size_t count = 0;
-  if(emitted.insert(target).second)
-    {
+  if (emitted.insert(target).second) {
     count = this->ProgressMap[target].Marks.size();
     TargetDependSet const& depends = this->GetTargetDirectDepends(target);
-    for(TargetDependSet::const_iterator di = depends.begin();
-        di != depends.end(); ++di)
-      {
-      if ((*di)->GetType() == cmState::INTERFACE_LIBRARY)
-        {
+    for (TargetDependSet::const_iterator di = depends.begin();
+         di != depends.end(); ++di) {
+      if ((*di)->GetType() == cmState::INTERFACE_LIBRARY) {
         continue;
-        }
-      count += this->CountProgressMarksInTarget(*di, emitted);
       }
+      count += this->CountProgressMarksInTarget(*di, emitted);
     }
+  }
   return count;
 }
 
-//----------------------------------------------------------------------------
-size_t
-cmGlobalUnixMakefileGenerator3
-::CountProgressMarksInAll(cmLocalGenerator* lg)
+size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInAll(
+  cmLocalGenerator* lg)
 {
   size_t count = 0;
   std::set<cmGeneratorTarget const*> emitted;
-  std::set<cmGeneratorTarget const*> const& targets
-      = this->DirectoryTargetsMap[lg->GetStateSnapshot()];
-  for(std::set<cmGeneratorTarget const*>::const_iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
+  std::set<cmGeneratorTarget const*> const& targets =
+    this->DirectoryTargetsMap[lg->GetStateSnapshot()];
+  for (std::set<cmGeneratorTarget const*>::const_iterator t = targets.begin();
+       t != targets.end(); ++t) {
     count += this->CountProgressMarksInTarget(*t, emitted);
-    }
+  }
   return count;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
+void cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
   cmMakefileTargetGenerator* tg)
 {
   TargetProgress& tp = this->ProgressMap[tg->GetGeneratorTarget()];
@@ -1004,144 +875,122 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
   tp.VariableFile = tg->GetProgressFileNameFull();
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3::TargetProgress
-::WriteProgressVariables(unsigned long total, unsigned long &current)
+void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
+  unsigned long total, unsigned long& current)
 {
   cmGeneratedFileStream fout(this->VariableFile.c_str());
-  for(unsigned long i = 1; i <= this->NumberOfActions; ++i)
-    {
+  for (unsigned long i = 1; i <= this->NumberOfActions; ++i) {
     fout << "CMAKE_PROGRESS_" << i << " = ";
-    if (total <= 100)
-      {
+    if (total <= 100) {
       unsigned long num = i + current;
       fout << num;
       this->Marks.push_back(num);
-      }
-    else if (((i+current)*100)/total > ((i-1+current)*100)/total)
-      {
-      unsigned long num = ((i+current)*100)/total;
+    } else if (((i + current) * 100) / total >
+               ((i - 1 + current) * 100) / total) {
+      unsigned long num = ((i + current) * 100) / total;
       fout << num;
       this->Marks.push_back(num);
-      }
-    fout << "\n";
     }
+    fout << "\n";
+  }
   fout << "\n";
   current += this->NumberOfActions;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::AppendGlobalTargetDepends(std::vector<std::string>& depends,
-                            cmGeneratorTarget* target)
+void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends(
+  std::vector<std::string>& depends, cmGeneratorTarget* target)
 {
   TargetDependSet const& depends_set = this->GetTargetDirectDepends(target);
-  for(TargetDependSet::const_iterator i = depends_set.begin();
-      i != depends_set.end(); ++i)
-    {
+  for (TargetDependSet::const_iterator i = depends_set.begin();
+       i != depends_set.end(); ++i) {
     // Create the target-level dependency.
     cmGeneratorTarget const* dep = *i;
-    if (dep->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (dep->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     cmLocalUnixMakefileGenerator3* lg3 =
       static_cast<cmLocalUnixMakefileGenerator3*>(dep->GetLocalGenerator());
     std::string tgtName =
-        lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep));
+      lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep));
     tgtName += "/all";
     depends.push_back(tgtName);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalUnixMakefileGenerator3::WriteHelpRule
-(std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3 *lg)
+void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
+  std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
 {
   // add the help target
   std::string path;
   std::vector<std::string> no_depends;
   std::vector<std::string> commands;
-  lg->AppendEcho(commands,"The following are some of the valid targets "
-                 "for this Makefile:");
-  lg->AppendEcho(commands,"... all (the default if no target is provided)");
-  lg->AppendEcho(commands,"... clean");
-  lg->AppendEcho(commands,"... depend");
+  lg->AppendEcho(commands, "The following are some of the valid targets "
+                           "for this Makefile:");
+  lg->AppendEcho(commands, "... all (the default if no target is provided)");
+  lg->AppendEcho(commands, "... clean");
+  lg->AppendEcho(commands, "... depend");
 
   // Keep track of targets already listed.
   std::set<std::string> emittedTargets;
 
   // for each local generator
   unsigned int i;
-  cmLocalUnixMakefileGenerator3 *lg2;
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  cmLocalUnixMakefileGenerator3* lg2;
+  for (i = 0; i < this->LocalGenerators.size(); ++i) {
     lg2 =
-      static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
+      static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
     // for the passed in makefile or if this is the top Makefile wripte out
     // the targets
-    if (lg2 == lg || lg->IsRootMakefile())
-      {
+    if (lg2 == lg || lg->IsRootMakefile()) {
       // for each target Generate the rule files for each target.
       std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets();
-      for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-          t != targets.end(); ++t)
-        {
+      for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+           t != targets.end(); ++t) {
         cmGeneratorTarget* target = *t;
         cmState::TargetType type = target->GetType();
-        if((type == cmState::EXECUTABLE) ||
-           (type == cmState::STATIC_LIBRARY) ||
-           (type == cmState::SHARED_LIBRARY) ||
-           (type == cmState::MODULE_LIBRARY) ||
-           (type == cmState::OBJECT_LIBRARY) ||
-           (type == cmState::GLOBAL_TARGET) ||
-           (type == cmState::UTILITY))
-          {
+        if ((type == cmState::EXECUTABLE) ||
+            (type == cmState::STATIC_LIBRARY) ||
+            (type == cmState::SHARED_LIBRARY) ||
+            (type == cmState::MODULE_LIBRARY) ||
+            (type == cmState::OBJECT_LIBRARY) ||
+            (type == cmState::GLOBAL_TARGET) || (type == cmState::UTILITY)) {
           std::string name = target->GetName();
-          if(emittedTargets.insert(name).second)
-            {
+          if (emittedTargets.insert(name).second) {
             path = "... ";
             path += name;
-            lg->AppendEcho(commands,path.c_str());
-            }
+            lg->AppendEcho(commands, path);
           }
         }
       }
     }
+  }
   std::vector<std::string> const& localHelp = lg->GetLocalHelp();
-  for(std::vector<std::string>::const_iterator o = localHelp.begin();
-      o != localHelp.end(); ++o)
-    {
+  for (std::vector<std::string>::const_iterator o = localHelp.begin();
+       o != localHelp.end(); ++o) {
     path = "... ";
     path += *o;
-    lg->AppendEcho(commands, path.c_str());
-    }
-  lg->WriteMakeRule(ruleFileStream, "Help Target",
-                    "help",
-                    no_depends, commands, true);
+    lg->AppendEcho(commands, path);
+  }
+  lg->WriteMakeRule(ruleFileStream, "Help Target", "help", no_depends,
+                    commands, true);
   ruleFileStream << "\n\n";
 }
 
-
-bool cmGlobalUnixMakefileGenerator3
-::NeedRequiresStep(const cmGeneratorTarget* target)
+bool cmGlobalUnixMakefileGenerator3::NeedRequiresStep(
+  const cmGeneratorTarget* target)
 {
   std::set<std::string> languages;
-  target->GetLanguages(languages,
-                       target->Target->GetMakefile()
-                       ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-  for(std::set<std::string>::const_iterator l = languages.begin();
-      l != languages.end(); ++l)
-    {
+  target->GetLanguages(
+    languages,
+    target->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->Target->GetMakefile()->GetDefinition(var))
-      {
+    if (target->Target->GetMakefile()->GetDefinition(var)) {
       return true;
-      }
     }
+  }
   return false;
 }
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 0591a5a..f951b2a 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -13,6 +13,7 @@
 #define cmGlobalUnixMakefileGenerator3_h
 
 #include "cmGlobalCommonGenerator.h"
+
 #include "cmGlobalGeneratorFactory.h"
 
 class cmGeneratedFileStream;
@@ -55,14 +56,18 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalCommonGenerator
 {
 public:
   cmGlobalUnixMakefileGenerator3(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalUnixMakefileGenerator3>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<
+      cmGlobalUnixMakefileGenerator3>();
+  }
 
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalUnixMakefileGenerator3::GetActualName();}
-  static std::string GetActualName() {return "Unix Makefiles";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalUnixMakefileGenerator3::GetActualName();
+  }
+  static std::string GetActualName() { return "Unix Makefiles"; }
 
   /**
    * Utilized by the generator factory to determine if this generator
@@ -73,14 +78,14 @@ public:
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
 
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 
   virtual void Configure();
 
@@ -91,17 +96,16 @@ public:
    */
   virtual void Generate();
 
-
   void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
-                                       std::vector<cmLocalGenerator *> &);
+                                       std::vector<cmLocalGenerator*>&);
 
   // write out the help rule listing the valid targets
   void WriteHelpRule(std::ostream& ruleFileStream,
-                     cmLocalUnixMakefileGenerator3 *);
+                     cmLocalUnixMakefileGenerator3*);
 
   // write the top level target rules
   void WriteConvenienceRules(std::ostream& ruleFileStream,
-                             std::set<std::string> &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.  */
@@ -113,22 +117,18 @@ public:
 
   // change the build command for speed
   virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
-    const std::string& projectName,
-    const std::string& projectDir,
-    const std::string& targetName,
-    const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    std::vector<std::string> const& makeOptions = std::vector<std::string>());
 
   /** Record per-target progress information.  */
   void RecordTargetProgress(cmMakefileTargetGenerator* tg);
 
-  void AddCXXCompileCommand(const std::string &sourceFile,
-                            const std::string &workingDirectory,
-                            const std::string &compileCommand);
+  void AddCXXCompileCommand(const std::string& sourceFile,
+                            const std::string& workingDirectory,
+                            const std::string& compileCommand);
 
   /** Does the make tool tolerate .NOTPARALLEL? */
   virtual bool AllowNotParallel() const { return true; }
@@ -142,6 +142,7 @@ public:
   bool DefineWindowsNULL;
   bool PassMakeflags;
   bool UnixCD;
+
 protected:
   void WriteMainMakefile2();
   void WriteMainCMakefile();
@@ -150,9 +151,8 @@ protected:
                               cmLocalUnixMakefileGenerator3*);
 
   void WriteDirectoryRule2(std::ostream& ruleFileStream,
-                           cmLocalUnixMakefileGenerator3* lg,
-                           const char* pass, bool check_all,
-                           bool check_relink);
+                           cmLocalUnixMakefileGenerator3* lg, const char* pass,
+                           bool check_all, bool check_relink);
   void WriteDirectoryRules2(std::ostream& ruleFileStream,
                             cmLocalUnixMakefileGenerator3* lg);
 
@@ -163,17 +163,17 @@ protected:
   bool NeedRequiresStep(cmGeneratorTarget const*);
 
   // Target name hooks for superclass.
-  const char* GetAllTargetName()           const { return "all"; }
-  const char* GetInstallTargetName()       const { return "install"; }
-  const char* GetInstallLocalTargetName()  const { return "install/local"; }
-  const char* GetInstallStripTargetName()  const { return "install/strip"; }
-  const char* GetPreinstallTargetName()    const { return "preinstall"; }
-  const char* GetTestTargetName()          const { return "test"; }
-  const char* GetPackageTargetName()       const { return "package"; }
+  const char* GetAllTargetName() const { return "all"; }
+  const char* GetInstallTargetName() const { return "install"; }
+  const char* GetInstallLocalTargetName() const { return "install/local"; }
+  const char* GetInstallStripTargetName() const { return "install/strip"; }
+  const char* GetPreinstallTargetName() const { return "preinstall"; }
+  const char* GetTestTargetName() const { return "test"; }
+  const char* GetPackageTargetName() const { return "package"; }
   const char* GetPackageSourceTargetName() const { return "package_source"; }
-  const char* GetEditCacheTargetName()     const { return "edit_cache"; }
-  const char* GetRebuildCacheTargetName()  const { return "rebuild_cache"; }
-  const char* GetCleanTargetName()         const { return "clean"; }
+  const char* GetEditCacheTargetName() const { return "edit_cache"; }
+  const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; }
+  const char* GetCleanTargetName() const { return "clean"; }
 
   virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; }
 
@@ -192,28 +192,34 @@ protected:
   // Store per-target progress counters.
   struct TargetProgress
   {
-    TargetProgress(): NumberOfActions(0) {}
+    TargetProgress()
+      : NumberOfActions(0)
+    {
+    }
     unsigned long NumberOfActions;
     std::string VariableFile;
     std::vector<unsigned long> Marks;
     void WriteProgressVariables(unsigned long total, unsigned long& current);
   };
   typedef std::map<cmGeneratorTarget const*, TargetProgress,
-                   cmGeneratorTarget::StrictTargetComparison> ProgressMapType;
+                   cmGeneratorTarget::StrictTargetComparison>
+    ProgressMapType;
   ProgressMapType ProgressMap;
 
-  size_t CountProgressMarksInTarget(cmGeneratorTarget const* target,
-                                 std::set<cmGeneratorTarget const*>& emitted);
+  size_t CountProgressMarksInTarget(
+    cmGeneratorTarget const* target,
+    std::set<cmGeneratorTarget const*>& emitted);
   size_t CountProgressMarksInAll(cmLocalGenerator* lg);
 
-  cmGeneratedFileStream *CommandDatabase;
+  cmGeneratedFileStream* CommandDatabase;
+
 private:
   virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; }
   virtual std::string GetEditCacheCommand() const;
 
-  std::map<cmState::Snapshot,
-           std::set<cmGeneratorTarget const*>,
-           cmState::Snapshot::StrictWeakOrder> DirectoryTargetsMap;
+  std::map<cmState::Snapshot, std::set<cmGeneratorTarget const*>,
+           cmState::Snapshot::StrictWeakOrder>
+    DirectoryTargetsMap;
   virtual void InitializeProgressMarks();
 };
 
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index c49008d..90ff98b 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -10,30 +10,30 @@
   See the License for more information.
 ============================================================================*/
 #include "windows.h" // this must be first to define GetCurrentDirectory
+
 #include "cmGlobalVisualStudio10Generator.h"
+
+#include "cmAlgorithms.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmVisualStudioSlnData.h"
 #include "cmVisualStudioSlnParser.h"
 #include "cmake.h"
-#include "cmAlgorithms.h"
 
 static const char vs10generatorName[] = "Visual Studio 10 2010";
 
 // Map generator name without year to name with year.
 static const char* cmVS10GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name.c_str(), vs10generatorName,
-             sizeof(vs10generatorName)-6) != 0)
-    {
+  if (strncmp(name.c_str(), vs10generatorName,
+              sizeof(vs10generatorName) - 6) != 0) {
     return 0;
-    }
+  }
   const char* p = name.c_str() + sizeof(vs10generatorName) - 6;
-  if(cmHasLiteralPrefix(p, " 2010"))
-    {
+  if (cmHasLiteralPrefix(p, " 2010")) {
     p += 5;
-    }
+  }
   genName = std::string(vs10generatorName) + p;
   return p;
 }
@@ -42,64 +42,60 @@ class cmGlobalVisualStudio10Generator::Factory
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const
-    {
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
     std::string genName;
     const char* p = cmVS10GenName(name, genName);
-    if(!p)
-      { return 0; }
-    if(!*p)
-      {
+    if (!p) {
+      return 0;
+    }
+    if (!*p) {
       return new cmGlobalVisualStudio10Generator(cm, genName, "");
-      }
-    if(*p++ != ' ')
-      { return 0; }
-    if(strcmp(p, "Win64") == 0)
-      {
+    }
+    if (*p++ != ' ') {
+      return 0;
+    }
+    if (strcmp(p, "Win64") == 0) {
       return new cmGlobalVisualStudio10Generator(cm, genName, "x64");
-      }
-    if(strcmp(p, "IA64") == 0)
-      {
+    }
+    if (strcmp(p, "IA64") == 0) {
       return new cmGlobalVisualStudio10Generator(cm, genName, "Itanium");
-      }
-    return 0;
     }
+    return 0;
+  }
 
   virtual void GetDocumentation(cmDocumentationEntry& entry) const
-    {
+  {
     entry.Name = std::string(vs10generatorName) + " [arch]";
-    entry.Brief =
-      "Generates Visual Studio 2010 project files.  "
-      "Optional [arch] can be \"Win64\" or \"IA64\"."
-      ;
-    }
+    entry.Brief = "Generates Visual Studio 2010 project files.  "
+                  "Optional [arch] can be \"Win64\" or \"IA64\".";
+  }
 
   virtual void GetGenerators(std::vector<std::string>& names) const
-    {
+  {
     names.push_back(vs10generatorName);
     names.push_back(vs10generatorName + std::string(" IA64"));
     names.push_back(vs10generatorName + std::string(" Win64"));
-    }
+  }
 
   virtual bool SupportsToolset() const { return true; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(cmake* cm,
-  const std::string& name, const std::string& platformName)
+cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
+  cmake* cm, const std::string& name, const std::string& platformName)
   : cmGlobalVisualStudio8Generator(cm, name, platformName)
 {
   std::string vc10Express;
   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;"
-    "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
+    "ProductDir",
+    vc10Express, cmSystemTools::KeyWOW64_32);
   this->SystemIsWindowsCE = false;
   this->SystemIsWindowsPhone = false;
   this->SystemIsWindowsStore = false;
@@ -107,160 +103,127 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(cmake* cm,
   this->Version = VS10;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio10Generator::MatchesGeneratorName(
-                                               const std::string& name) const
+bool cmGlobalVisualStudio10Generator::MatchesGeneratorName(
+  const std::string& name) const
 {
   std::string genName;
-  if(cmVS10GenName(name, genName))
-    {
+  if (cmVS10GenName(name, genName)) {
     return genName == this->GetName();
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s,
                                                     cmMakefile* mf)
 {
   this->SystemName = s;
   this->SystemVersion = mf->GetSafeDefinition("CMAKE_SYSTEM_VERSION");
-  if(!this->InitializeSystem(mf))
-    {
+  if (!this->InitializeSystem(mf)) {
     return false;
-    }
+  }
   return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio10Generator::SetGeneratorPlatform(std::string const& p,
-                                                      cmMakefile* mf)
+bool cmGlobalVisualStudio10Generator::SetGeneratorPlatform(
+  std::string const& p, cmMakefile* mf)
 {
-  if(!this->cmGlobalVisualStudio8Generator::SetGeneratorPlatform(p, mf))
-    {
+  if (!this->cmGlobalVisualStudio8Generator::SetGeneratorPlatform(p, mf)) {
     return false;
-    }
-  if(this->GetPlatformName() == "Itanium" || this->GetPlatformName() == "x64")
-    {
-    if(this->IsExpressEdition() && !this->Find64BitTools(mf))
-      {
+  }
+  if (this->GetPlatformName() == "Itanium" ||
+      this->GetPlatformName() == "x64") {
+    if (this->IsExpressEdition() && !this->Find64BitTools(mf)) {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts,
-                                                     cmMakefile* mf)
+bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
+  std::string const& ts, cmMakefile* mf)
 {
   if (this->SystemIsWindowsCE && ts.empty() &&
-      this->DefaultPlatformToolset.empty())
-    {
+      this->DefaultPlatformToolset.empty()) {
     std::ostringstream e;
     e << this->GetName() << " Windows CE version '" << this->SystemVersion
       << "' requires CMAKE_GENERATOR_TOOLSET to be set.";
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
 
   this->GeneratorToolset = ts;
-  if(const char* toolset = this->GetPlatformToolset())
-    {
+  if (const char* toolset = this->GetPlatformToolset()) {
     mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
 {
-  if (this->SystemName == "Windows")
-    {
-    if (!this->InitializeWindows(mf))
-      {
+  if (this->SystemName == "Windows") {
+    if (!this->InitializeWindows(mf)) {
       return false;
-      }
     }
-  else if (this->SystemName == "WindowsCE")
-    {
+  } else if (this->SystemName == "WindowsCE") {
     this->SystemIsWindowsCE = true;
-    if (!this->InitializeWindowsCE(mf))
-      {
+    if (!this->InitializeWindowsCE(mf)) {
       return false;
-      }
     }
-  else if (this->SystemName == "WindowsPhone")
-    {
+  } else if (this->SystemName == "WindowsPhone") {
     this->SystemIsWindowsPhone = true;
-    if(!this->InitializeWindowsPhone(mf))
-      {
+    if (!this->InitializeWindowsPhone(mf)) {
       return false;
-      }
     }
-  else if (this->SystemName == "WindowsStore")
-    {
+  } else if (this->SystemName == "WindowsStore") {
     this->SystemIsWindowsStore = true;
-    if(!this->InitializeWindowsStore(mf))
-      {
+    if (!this->InitializeWindowsStore(mf)) {
       return false;
-      }
     }
-  else if(this->SystemName == "Android")
-    {
-    if(this->DefaultPlatformName != "Win32")
-      {
+  } else if (this->SystemName == "Android") {
+    if (this->DefaultPlatformName != "Win32") {
       std::ostringstream e;
       e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR "
         << "specifies a platform too: '" << this->GetName() << "'";
       mf->IssueMessage(cmake::FATAL_ERROR, e.str());
       return false;
-      }
+    }
     std::string v = this->GetInstalledNsightTegraVersion();
-    if(v.empty())
-      {
+    if (v.empty()) {
       mf->IssueMessage(cmake::FATAL_ERROR,
-        "CMAKE_SYSTEM_NAME is 'Android' but "
-        "'NVIDIA Nsight Tegra Visual Studio Edition' "
-        "is not installed.");
+                       "CMAKE_SYSTEM_NAME is 'Android' but "
+                       "'NVIDIA Nsight Tegra Visual Studio Edition' "
+                       "is not installed.");
       return false;
-      }
+    }
     this->DefaultPlatformName = "Tegra-Android";
     this->DefaultPlatformToolset = "Default";
     this->NsightTegraVersion = v;
     mf->AddDefinition("CMAKE_VS_NsightTegra_VERSION", v.c_str());
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*)
 {
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
 {
-  if (this->DefaultPlatformName != "Win32")
-    {
+  if (this->DefaultPlatformName != "Win32") {
     std::ostringstream e;
     e << "CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR "
       << "specifies a platform too: '" << this->GetName() << "'";
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
 
   this->DefaultPlatformToolset = this->SelectWindowsCEToolset();
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
 {
   std::ostringstream e;
@@ -269,7 +232,6 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
 {
   std::ostringstream e;
@@ -278,51 +240,41 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
   return false;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
+bool cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
   std::string& toolset) const
 {
   toolset = "";
   return false;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
+bool cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
   std::string& toolset) const
 {
   toolset = "";
   return false;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const
 {
-  if (this->SystemVersion == "8.0")
-    {
+  if (this->SystemVersion == "8.0") {
     return "CE800";
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
 {
   fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
-  if (this->ExpressEdition)
-    {
+  if (this->ExpressEdition) {
     fout << "# Visual C++ Express 2010\n";
-    }
-  else
-    {
+  } else {
     fout << "# Visual Studio 2010\n";
-    }
+  }
 }
 
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator(
-    cmMakefile* mf)
+  cmMakefile* mf)
 {
   return new cmLocalVisualStudio10Generator(this, mf);
 }
@@ -331,10 +283,10 @@ void cmGlobalVisualStudio10Generator::Generate()
 {
   this->LongestSource = LongestSourcePath();
   this->cmGlobalVisualStudio8Generator::Generate();
-  if(this->LongestSource.Length > 0)
-    {
+  if (this->LongestSource.Length > 0) {
     cmLocalGenerator* lg = this->LongestSource.Target->GetLocalGenerator();
     std::ostringstream e;
+    /* clang-format off */
     e <<
       "The binary and/or source directory paths may be too long to generate "
       "Visual Studio 10 files for this project.  "
@@ -354,33 +306,28 @@ void cmGlobalVisualStudio10Generator::Generate()
       "the path length is too long for some internal buffer or API.  "
       "To avoid this problem CMake must use a full path for this file "
       "which then triggers the VS 10 property dialog bug.";
+    /* clang-format on */
     lg->IssueMessage(cmake::WARNING, e.str().c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio10Generator
-::EnableLanguage(std::vector<std::string>const &  lang,
-                 cmMakefile *mf, bool optional)
+void cmGlobalVisualStudio10Generator::EnableLanguage(
+  std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
 {
   cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const
 {
-  if(!this->GeneratorToolset.empty())
-    {
+  if (!this->GeneratorToolset.empty()) {
     return this->GeneratorToolset.c_str();
-    }
-  if(!this->DefaultPlatformToolset.empty())
-    {
+  }
+  if (!this->DefaultPlatformToolset.empty()) {
     return this->DefaultPlatformToolset.c_str();
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
 {
   this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf);
@@ -388,18 +335,15 @@ void cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
                     this->GetMSBuildCommand().c_str());
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand()
 {
-  if(!this->MSBuildCommandInitialized)
-    {
+  if (!this->MSBuildCommandInitialized) {
     this->MSBuildCommandInitialized = true;
     this->MSBuildCommand = this->FindMSBuildCommand();
-    }
+  }
   return this->MSBuildCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
 {
   std::string msbuild;
@@ -407,41 +351,33 @@ std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\";
   mskey += this->GetToolsVersion();
   mskey += ";MSBuildToolsPath";
-  if(cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
-                                      cmSystemTools::KeyWOW64_32))
-    {
+  if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
+                                       cmSystemTools::KeyWOW64_32)) {
     cmSystemTools::ConvertToUnixSlashes(msbuild);
     msbuild += "/";
-    }
+  }
   msbuild += "MSBuild.exe";
   return msbuild;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand()
 {
-  if(this->ExpressEdition)
-    {
+  if (this->ExpressEdition) {
     // Visual Studio Express >= 10 do not have "devenv.com" or
     // "VCExpress.exe" that we can use to build reliably.
     // Tell the caller it needs to use MSBuild instead.
     return "";
-    }
+  }
   // Skip over the cmGlobalVisualStudio8Generator implementation because
   // we expect a real devenv and do not want to look for VCExpress.
   return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand();
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
-  std::vector<std::string>& makeCommand,
-  const std::string& makeProgram,
-  const std::string& projectName,
-  const std::string& projectDir,
-  const std::string& targetName,
-  const std::string& config,
-  bool fast, bool verbose,
-  std::vector<std::string> const& makeOptions)
+  std::vector<std::string>& makeCommand, const std::string& makeProgram,
+  const std::string& projectName, const std::string& projectDir,
+  const std::string& targetName, const std::string& config, bool fast,
+  bool verbose, std::vector<std::string> const& makeOptions)
 {
   // Select the caller- or user-preferred make program, else MSBuild.
   std::string makeProgramSelected =
@@ -450,100 +386,82 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
   // Check if the caller explicitly requested a devenv tool.
   std::string makeProgramLower = makeProgramSelected;
   cmSystemTools::LowerCase(makeProgramLower);
-  bool useDevEnv =
-    (makeProgramLower.find("devenv") != std::string::npos ||
-     makeProgramLower.find("vcexpress") != std::string::npos);
+  bool useDevEnv = (makeProgramLower.find("devenv") != std::string::npos ||
+                    makeProgramLower.find("vcexpress") != std::string::npos);
 
   // MSBuild is preferred (and required for VS Express), but if the .sln has
   // an Intel Fortran .vfproj then we have to use devenv. Parse it to find out.
   cmSlnData slnData;
   {
-  std::string slnFile;
-  if(!projectDir.empty())
-    {
-    slnFile = projectDir;
-    slnFile += "/";
-    }
-  slnFile += projectName;
-  slnFile += ".sln";
-  cmVisualStudioSlnParser parser;
-  if(parser.ParseFile(slnFile, slnData,
-                      cmVisualStudioSlnParser::DataGroupProjects))
-    {
-    std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
-    for(std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin();
-        !useDevEnv && i != slnProjects.end(); ++i)
-      {
-      std::string proj = i->GetRelativePath();
-      if(proj.size() > 7 &&
-         proj.substr(proj.size()-7) == ".vfproj")
-        {
-        useDevEnv = true;
+    std::string slnFile;
+    if (!projectDir.empty()) {
+      slnFile = projectDir;
+      slnFile += "/";
+    }
+    slnFile += projectName;
+    slnFile += ".sln";
+    cmVisualStudioSlnParser parser;
+    if (parser.ParseFile(slnFile, slnData,
+                         cmVisualStudioSlnParser::DataGroupProjects)) {
+      std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
+      for (std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin();
+           !useDevEnv && i != slnProjects.end(); ++i) {
+        std::string proj = i->GetRelativePath();
+        if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") {
+          useDevEnv = true;
         }
       }
     }
   }
-  if(useDevEnv)
-    {
+  if (useDevEnv) {
     // Use devenv to build solutions containing Intel Fortran projects.
     cmGlobalVisualStudio7Generator::GenerateBuildCommand(
-      makeCommand, makeProgram, projectName, projectDir,
-      targetName, config, fast, verbose, makeOptions);
+      makeCommand, makeProgram, projectName, projectDir, targetName, config,
+      fast, verbose, makeOptions);
     return;
-    }
+  }
 
   makeCommand.push_back(makeProgramSelected);
 
   std::string realTarget = targetName;
   // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
-  if(realTarget.empty())
-    {
+  if (realTarget.empty()) {
     realTarget = "ALL_BUILD";
-    }
-  if ( realTarget == "clean" )
-    {
-    makeCommand.push_back(std::string(projectName)+".sln");
+  }
+  if (realTarget == "clean") {
+    makeCommand.push_back(std::string(projectName) + ".sln");
     makeCommand.push_back("/t:Clean");
-    }
-  else
-    {
+  } else {
     std::string targetProject(realTarget);
     targetProject += ".vcxproj";
-    if (targetProject.find('/') == std::string::npos)
-      {
+    if (targetProject.find('/') == std::string::npos) {
       // it might be in a subdir
       if (cmSlnProjectEntry const* proj =
-          slnData.GetProjectByName(realTarget))
-        {
+            slnData.GetProjectByName(realTarget)) {
         targetProject = proj->GetRelativePath();
         cmSystemTools::ConvertToUnixSlashes(targetProject);
-        }
       }
-    makeCommand.push_back(targetProject);
     }
+    makeCommand.push_back(targetProject);
+  }
   std::string configArg = "/p:Configuration=";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     configArg += config;
-    }
-  else
-    {
+  } else {
     configArg += "Debug";
-    }
+  }
   makeCommand.push_back(configArg);
-  makeCommand.push_back(std::string("/p:VisualStudioVersion=")+
+  makeCommand.push_back(std::string("/p:VisualStudioVersion=") +
                         this->GetIDEVersion());
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
+  makeCommand.insert(makeCommand.end(), makeOptions.begin(),
+                     makeOptions.end());
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
 {
-  if(this->GetPlatformToolset())
-    {
+  if (this->GetPlatformToolset()) {
     return true;
-    }
+  }
   // This edition does not come with 64-bit tools.  Look for them.
   //
   // TODO: Detect available tools?  x64\v100 exists but does not work?
@@ -551,32 +469,30 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
   // c:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/Platforms/
   //   {Itanium,Win32,x64}/PlatformToolsets/{v100,v90,Windows7.1SDK}
   std::string winSDK_7_1;
-  if(cmSystemTools::ReadRegistryValue(
-       "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\"
-       "Windows\\v7.1;InstallationFolder", winSDK_7_1))
-    {
+  if (cmSystemTools::ReadRegistryValue(
+        "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\"
+        "Windows\\v7.1;InstallationFolder",
+        winSDK_7_1)) {
     std::ostringstream m;
     m << "Found Windows SDK v7.1: " << winSDK_7_1;
     mf->DisplayStatus(m.str().c_str(), -1);
     this->DefaultPlatformToolset = "Windows7.1SDK";
     return true;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
+    /* clang-format off */
     e << "Cannot enable 64-bit tools with Visual Studio 2010 Express.\n"
       << "Install the Microsoft Windows SDK v7.1 to get 64-bit tools:\n"
       << "  http://msdn.microsoft.com/en-us/windows/bb980924.aspx";
+    /* clang-format on */
     mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalVisualStudio10Generator
-::GenerateRuleFile(std::string const& output) const
+std::string cmGlobalVisualStudio10Generator::GenerateRuleFile(
+  std::string const& output) const
 {
   // The VS 10 generator needs to create the .rule files on disk.
   // Hide them away under the CMakeFiles directory.
@@ -591,47 +507,37 @@ cmGlobalVisualStudio10Generator
   return ruleFile;
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio10Generator::PathTooLong(
-        cmGeneratorTarget *target, cmSourceFile const* sf,
-        std::string const& sfRel)
+void cmGlobalVisualStudio10Generator::PathTooLong(cmGeneratorTarget* target,
+                                                  cmSourceFile const* sf,
+                                                  std::string const& sfRel)
 {
   size_t len =
-      (strlen(target->GetLocalGenerator()->GetCurrentBinaryDirectory()) +
-                1 + sfRel.length());
-  if(len > this->LongestSource.Length)
-    {
+    (strlen(target->GetLocalGenerator()->GetCurrentBinaryDirectory()) + 1 +
+     sfRel.length());
+  if (len > this->LongestSource.Length) {
     this->LongestSource.Length = len;
     this->LongestSource.Target = target;
     this->LongestSource.SourceFile = sf;
     this->LongestSource.SourceRel = sfRel;
-    }
-}
-
-//----------------------------------------------------------------------------
-bool cmGlobalVisualStudio10Generator::UseFolderProperty()
-{
-  return IsExpressEdition() ? false : cmGlobalGenerator::UseFolderProperty();
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::IsNsightTegra() const
 {
   return !this->NsightTegraVersion.empty();
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio10Generator::GetNsightTegraVersion() const
 {
   return this->NsightTegraVersion;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion()
 {
   std::string version;
   cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;"
-    "Version", version, cmSystemTools::KeyWOW64_32);
+    "Version",
+    version, cmSystemTools::KeyWOW64_32);
   return version;
 }
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 6bf4740..51fd5a5 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -14,18 +14,16 @@
 
 #include "cmGlobalVisualStudio8Generator.h"
 
-
 /** \class cmGlobalVisualStudio10Generator
  * \brief Write a Unix makefiles.
  *
  * cmGlobalVisualStudio10Generator manages UNIX build process for a tree
  */
-class cmGlobalVisualStudio10Generator :
-  public cmGlobalVisualStudio8Generator
+class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
 {
 public:
   cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
-    const std::string& platformName);
+                                  const std::string& platformName);
   static cmGlobalGeneratorFactory* NewFactory();
 
   virtual bool MatchesGeneratorName(const std::string& name) const;
@@ -35,30 +33,23 @@ public:
   virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
 
   virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
-    const std::string& projectName,
-    const std::string& projectDir,
-    const std::string& targetName,
-    const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    std::vector<std::string> const& makeOptions = std::vector<std::string>());
 
   ///! create the correct local generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
   virtual void WriteSLNHeader(std::ostream& fout);
 
-  /** Is the installed VS an Express edition?  */
-  bool IsExpressEdition() const { return this->ExpressEdition; }
-
   /** Generating for Nsight Tegra VS plugin?  */
   bool IsNsightTegra() const;
   std::string GetNsightTegraVersion() const;
@@ -74,22 +65,20 @@ public:
 
   /** Return the Windows version targeted on VS 2015 and above.  */
   std::string const& GetWindowsTargetPlatformVersion() const
-    { return this->WindowsTargetPlatformVersion; }
+  {
+    return this->WindowsTargetPlatformVersion;
+  }
 
   /** Return true if building for WindowsCE */
-  bool TargetsWindowsCE() const
-    { return this->SystemIsWindowsCE; }
+  bool TargetsWindowsCE() const { return this->SystemIsWindowsCE; }
 
   /** Return true if building for WindowsPhone */
-  bool TargetsWindowsPhone() const
-    { return this->SystemIsWindowsPhone; }
+  bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
 
   /** Return true if building for WindowsStore */
-  bool TargetsWindowsStore() const
-    { return this->SystemIsWindowsStore; }
+  bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
 
-  virtual const char* GetCMakeCFGIntDir() const
-    { return "$(Configuration)";}
+  virtual const char* GetCMakeCFGIntDir() const { return "$(Configuration)"; }
   bool Find64BitTools(cmMakefile* mf);
 
   /** Generate an <output>.rule file path for a given command output.  */
@@ -129,15 +118,17 @@ protected:
   bool SystemIsWindowsCE;
   bool SystemIsWindowsPhone;
   bool SystemIsWindowsStore;
-  bool ExpressEdition;
-
-  bool UseFolderProperty();
 
 private:
   class Factory;
   struct LongestSourcePath
   {
-    LongestSourcePath(): Length(0), Target(0), SourceFile(0) {}
+    LongestSourcePath()
+      : Length(0)
+      , Target(0)
+      , SourceFile(0)
+    {
+    }
     size_t Length;
     cmGeneratorTarget* Target;
     cmSourceFile const* SourceFile;
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 9522f6e..295b6eb 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -10,25 +10,24 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalVisualStudio11Generator.h"
+
+#include "cmAlgorithms.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
-#include "cmAlgorithms.h"
 
 static const char vs11generatorName[] = "Visual Studio 11 2012";
 
 // Map generator name without year to name with year.
 static const char* cmVS11GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name.c_str(), vs11generatorName,
-             sizeof(vs11generatorName)-6) != 0)
-    {
+  if (strncmp(name.c_str(), vs11generatorName,
+              sizeof(vs11generatorName) - 6) != 0) {
     return 0;
-    }
+  }
   const char* p = name.c_str() + sizeof(vs11generatorName) - 6;
-  if(cmHasLiteralPrefix(p, " 2012"))
-    {
+  if (cmHasLiteralPrefix(p, " 2012")) {
     p += 5;
-    }
+  }
   genName = std::string(vs11generatorName) + p;
   return p;
 }
@@ -37,215 +36,178 @@ class cmGlobalVisualStudio11Generator::Factory
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const
-    {
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
     std::string genName;
     const char* p = cmVS11GenName(name, genName);
-    if(!p)
-      { return 0; }
-    if(!*p)
-      {
+    if (!p) {
+      return 0;
+    }
+    if (!*p) {
       return new cmGlobalVisualStudio11Generator(cm, genName, "");
-      }
-    if(*p++ != ' ')
-      { return 0; }
-    if(strcmp(p, "Win64") == 0)
-      {
+    }
+    if (*p++ != ' ') {
+      return 0;
+    }
+    if (strcmp(p, "Win64") == 0) {
       return new cmGlobalVisualStudio11Generator(cm, genName, "x64");
-      }
-    if(strcmp(p, "ARM") == 0)
-      {
+    }
+    if (strcmp(p, "ARM") == 0) {
       return new cmGlobalVisualStudio11Generator(cm, genName, "ARM");
-      }
+    }
 
     std::set<std::string> installedSDKs =
       cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
 
-    if(installedSDKs.find(p) == installedSDKs.end())
-      {
+    if (installedSDKs.find(p) == installedSDKs.end()) {
       return 0;
-      }
+    }
 
     cmGlobalVisualStudio11Generator* ret =
       new cmGlobalVisualStudio11Generator(cm, name, p);
     ret->WindowsCEVersion = "8.00";
     return ret;
-    }
+  }
 
   virtual void GetDocumentation(cmDocumentationEntry& entry) const
-    {
+  {
     entry.Name = std::string(vs11generatorName) + " [arch]";
-    entry.Brief =
-      "Generates Visual Studio 2012 project files.  "
-      "Optional [arch] can be \"Win64\" or \"ARM\"."
-      ;
-    }
+    entry.Brief = "Generates Visual Studio 2012 project files.  "
+                  "Optional [arch] can be \"Win64\" or \"ARM\".";
+  }
 
   virtual void GetGenerators(std::vector<std::string>& names) const
-    {
+  {
     names.push_back(vs11generatorName);
     names.push_back(vs11generatorName + std::string(" ARM"));
     names.push_back(vs11generatorName + std::string(" Win64"));
 
     std::set<std::string> installedSDKs =
       cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
-    for(std::set<std::string>::const_iterator i =
-        installedSDKs.begin(); i != installedSDKs.end(); ++i)
-      {
+    for (std::set<std::string>::const_iterator i = installedSDKs.begin();
+         i != installedSDKs.end(); ++i) {
       names.push_back(std::string(vs11generatorName) + " " + *i);
-      }
     }
+  }
 
   virtual bool SupportsToolset() const { return true; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(cmake* cm,
-  const std::string& name, const std::string& platformName)
+cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
+  cmake* cm, const std::string& name, const std::string& platformName)
   : cmGlobalVisualStudio10Generator(cm, name, platformName)
 {
   std::string vc11Express;
   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;"
-    "ProductDir", vc11Express, cmSystemTools::KeyWOW64_32);
+    "ProductDir",
+    vc11Express, cmSystemTools::KeyWOW64_32);
   this->DefaultPlatformToolset = "v110";
   this->Version = VS11;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::MatchesGeneratorName(
-                                                const std::string& name) const
+bool cmGlobalVisualStudio11Generator::MatchesGeneratorName(
+  const std::string& name) const
 {
   std::string genName;
-  if(cmVS11GenName(name, genName))
-    {
+  if (cmVS11GenName(name, genName)) {
     return genName == this->GetName();
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
 {
-  if(!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset))
-    {
+  if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) {
     std::ostringstream e;
-    if(this->DefaultPlatformToolset.empty())
-      {
+    if (this->DefaultPlatformToolset.empty()) {
       e << this->GetName() << " supports Windows Phone '8.0', but not '"
         << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
-      }
-    else
-      {
+    } else {
       e << "A Windows Phone component with CMake requires both the Windows "
         << "Desktop SDK as well as the Windows Phone '" << this->SystemVersion
         << "' SDK. Please make sure that you have both installed";
-      }
+    }
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
 {
-  if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset))
-    {
+  if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
     std::ostringstream e;
-    if(this->DefaultPlatformToolset.empty())
-      {
+    if (this->DefaultPlatformToolset.empty()) {
       e << this->GetName() << " supports Windows Store '8.0', but not '"
         << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
-      }
-    else
-      {
+    } else {
       e << "A Windows Store component with CMake requires both the Windows "
         << "Desktop SDK as well as the Windows Store '" << this->SystemVersion
         << "' SDK. Please make sure that you have both installed";
-      }
+    }
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
+bool cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
   std::string& toolset) const
 {
-  if(this->SystemVersion == "8.0")
-    {
+  if (this->SystemVersion == "8.0") {
     if (this->IsWindowsPhoneToolsetInstalled() &&
-        this->IsWindowsDesktopToolsetInstalled())
-      {
+        this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v110_wp80";
       return true;
-      }
-    else
-      {
+    } else {
       return false;
-      }
     }
-  return
-    this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(toolset);
+  }
+  return this->cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
+    toolset);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
+bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
   std::string& toolset) const
 {
-  if(this->SystemVersion == "8.0")
-    {
-    if(this->IsWindowsStoreToolsetInstalled() &&
-       this->IsWindowsDesktopToolsetInstalled())
-      {
+  if (this->SystemVersion == "8.0") {
+    if (this->IsWindowsStoreToolsetInstalled() &&
+        this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v110";
       return true;
-      }
-    else
-      {
+    } else {
       return false;
-      }
     }
-  return
-    this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(toolset);
+  }
+  return this->cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
+    toolset);
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
 {
   fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
-  if (this->ExpressEdition)
-    {
+  if (this->ExpressEdition) {
     fout << "# Visual Studio Express 2012 for Windows Desktop\n";
-    }
-  else
-    {
+  } else {
     fout << "# Visual Studio 2012\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio11Generator::UseFolderProperty()
 {
-  // Intentionally skip over the parent class implementation and call the
-  // grand-parent class's implementation. Folders are not supported by the
-  // Express editions in VS10 and earlier, but they are in VS11 Express.
-  return cmGlobalVisualStudio8Generator::UseFolderProperty();
+  // Intentionally skip up to the top-level class implementation.
+  // Folders are not supported by the Express editions in VS10 and earlier,
+  // but they are in VS11 Express and above.
+  return cmGlobalGenerator::UseFolderProperty();
 }
 
-//----------------------------------------------------------------------------
 std::set<std::string>
 cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
 {
@@ -257,88 +219,67 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
                                     cmSystemTools::KeyWOW64_32);
 
   std::set<std::string> ret;
-  for(std::vector<std::string>::const_iterator i =
-      subkeys.begin(); i != subkeys.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = subkeys.begin();
+       i != subkeys.end(); ++i) {
     std::string key = sdksKey;
     key += '\\';
     key += *i;
     key += ';';
 
     std::string path;
-    if(cmSystemTools::ReadRegistryValue(key.c_str(),
-                                        path,
-                                        cmSystemTools::KeyWOW64_32) &&
-        !path.empty())
-      {
+    if (cmSystemTools::ReadRegistryValue(key.c_str(), path,
+                                         cmSystemTools::KeyWOW64_32) &&
+        !path.empty()) {
       ret.insert(*i);
-      }
     }
+  }
 
   return ret;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::NeedsDeploy(cmState::TargetType type) const
+bool cmGlobalVisualStudio11Generator::NeedsDeploy(
+  cmState::TargetType type) const
 {
-  if((type == cmState::EXECUTABLE ||
-      type == cmState::SHARED_LIBRARY) &&
-     (this->SystemIsWindowsPhone ||
-      this->SystemIsWindowsStore))
-    {
+  if ((type == cmState::EXECUTABLE || type == cmState::SHARED_LIBRARY) &&
+      (this->SystemIsWindowsPhone || this->SystemIsWindowsStore)) {
     return true;
-    }
+  }
   return cmGlobalVisualStudio10Generator::NeedsDeploy(type);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::IsWindowsDesktopToolsetInstalled() const
+bool cmGlobalVisualStudio11Generator::IsWindowsDesktopToolsetInstalled() const
 {
-  const char desktop80Key[] =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-    "VisualStudio\\11.0\\VC\\Libraries\\Extended";
+  const char desktop80Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+                              "VisualStudio\\11.0\\VC\\Libraries\\Extended";
   const char VS2012DesktopExpressKey[] =
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
     "WDExpress\\11.0;InstallDir";
 
   std::vector<std::string> subkeys;
   std::string path;
-  return cmSystemTools::ReadRegistryValue(VS2012DesktopExpressKey,
-                                          path,
+  return cmSystemTools::ReadRegistryValue(VS2012DesktopExpressKey, path,
                                           cmSystemTools::KeyWOW64_32) ||
-         cmSystemTools::GetRegistrySubKeys(desktop80Key,
-                                           subkeys,
-                                           cmSystemTools::KeyWOW64_32);
+    cmSystemTools::GetRegistrySubKeys(desktop80Key, subkeys,
+                                      cmSystemTools::KeyWOW64_32);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::IsWindowsPhoneToolsetInstalled() const
+bool cmGlobalVisualStudio11Generator::IsWindowsPhoneToolsetInstalled() const
 {
-  const char wp80Key[] =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-    "Microsoft SDKs\\WindowsPhone\\v8.0\\"
-    "Install Path;Install Path";
+  const char wp80Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+                         "Microsoft SDKs\\WindowsPhone\\v8.0\\"
+                         "Install Path;Install Path";
 
   std::string path;
-  cmSystemTools::ReadRegistryValue(wp80Key,
-                                   path,
-                                   cmSystemTools::KeyWOW64_32);
+  cmSystemTools::ReadRegistryValue(wp80Key, path, cmSystemTools::KeyWOW64_32);
   return !path.empty();
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio11Generator::IsWindowsStoreToolsetInstalled() const
+bool cmGlobalVisualStudio11Generator::IsWindowsStoreToolsetInstalled() const
 {
-  const char win80Key[] =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-    "VisualStudio\\11.0\\VC\\Libraries\\Core\\Arm";
+  const char win80Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+                          "VisualStudio\\11.0\\VC\\Libraries\\Core\\Arm";
 
   std::vector<std::string> subkeys;
-  return cmSystemTools::GetRegistrySubKeys(win80Key,
-                                           subkeys,
+  return cmSystemTools::GetRegistrySubKeys(win80Key, subkeys,
                                            cmSystemTools::KeyWOW64_32);
 }
diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h
index f3f6b2b..ef6d343 100644
--- a/Source/cmGlobalVisualStudio11Generator.h
+++ b/Source/cmGlobalVisualStudio11Generator.h
@@ -14,14 +14,12 @@
 
 #include "cmGlobalVisualStudio10Generator.h"
 
-
 /** \class cmGlobalVisualStudio11Generator  */
-class cmGlobalVisualStudio11Generator:
-  public cmGlobalVisualStudio10Generator
+class cmGlobalVisualStudio11Generator : public cmGlobalVisualStudio10Generator
 {
 public:
   cmGlobalVisualStudio11Generator(cmake* cm, const std::string& name,
-    const std::string& platformName);
+                                  const std::string& platformName);
   static cmGlobalGeneratorFactory* NewFactory();
 
   virtual bool MatchesGeneratorName(const std::string& name) const;
@@ -49,6 +47,7 @@ protected:
 
   /** Return true if the configuration needs to be deployed */
   virtual bool NeedsDeploy(cmState::TargetType type) const;
+
 private:
   class Factory;
   friend class Factory;
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 568d4d7..318cb39 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -10,25 +10,24 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalVisualStudio12Generator.h"
+
+#include "cmAlgorithms.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
-#include "cmAlgorithms.h"
 
 static const char vs12generatorName[] = "Visual Studio 12 2013";
 
 // Map generator name without year to name with year.
 static const char* cmVS12GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name.c_str(), vs12generatorName,
-             sizeof(vs12generatorName)-6) != 0)
-    {
+  if (strncmp(name.c_str(), vs12generatorName,
+              sizeof(vs12generatorName) - 6) != 0) {
     return 0;
-    }
+  }
   const char* p = name.c_str() + sizeof(vs12generatorName) - 6;
-  if(cmHasLiteralPrefix(p, " 2013"))
-    {
+  if (cmHasLiteralPrefix(p, " 2013")) {
     p += 5;
-    }
+  }
   genName = std::string(vs12generatorName) + p;
   return p;
 }
@@ -37,224 +36,181 @@ class cmGlobalVisualStudio12Generator::Factory
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const
-    {
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
     std::string genName;
     const char* p = cmVS12GenName(name, genName);
-    if(!p)
-      { return 0; }
-    if(!*p)
-      {
+    if (!p) {
+      return 0;
+    }
+    if (!*p) {
       return new cmGlobalVisualStudio12Generator(cm, genName, "");
-      }
-    if(*p++ != ' ')
-      { return 0; }
-    if(strcmp(p, "Win64") == 0)
-      {
+    }
+    if (*p++ != ' ') {
+      return 0;
+    }
+    if (strcmp(p, "Win64") == 0) {
       return new cmGlobalVisualStudio12Generator(cm, genName, "x64");
-      }
-    if(strcmp(p, "ARM") == 0)
-      {
+    }
+    if (strcmp(p, "ARM") == 0) {
       return new cmGlobalVisualStudio12Generator(cm, genName, "ARM");
-      }
-    return 0;
     }
+    return 0;
+  }
 
   virtual void GetDocumentation(cmDocumentationEntry& entry) const
-    {
+  {
     entry.Name = std::string(vs12generatorName) + " [arch]";
-    entry.Brief =
-      "Generates Visual Studio 2013 project files.  "
-      "Optional [arch] can be \"Win64\" or \"ARM\"."
-      ;
-    }
+    entry.Brief = "Generates Visual Studio 2013 project files.  "
+                  "Optional [arch] can be \"Win64\" or \"ARM\".";
+  }
 
   virtual void GetGenerators(std::vector<std::string>& names) const
-    {
+  {
     names.push_back(vs12generatorName);
     names.push_back(vs12generatorName + std::string(" ARM"));
     names.push_back(vs12generatorName + std::string(" Win64"));
-    }
+  }
 
   virtual bool SupportsToolset() const { return true; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(cmake* cm,
-  const std::string& name, const std::string& platformName)
+cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
+  cmake* cm, const std::string& name, const std::string& platformName)
   : cmGlobalVisualStudio11Generator(cm, name, platformName)
 {
   std::string vc12Express;
   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;"
-    "ProductDir", vc12Express, cmSystemTools::KeyWOW64_32);
+    "ProductDir",
+    vc12Express, cmSystemTools::KeyWOW64_32);
   this->DefaultPlatformToolset = "v120";
   this->Version = VS12;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio12Generator::MatchesGeneratorName(
-                                                const std::string& name) const
+bool cmGlobalVisualStudio12Generator::MatchesGeneratorName(
+  const std::string& name) const
 {
   std::string genName;
-  if(cmVS12GenName(name, genName))
-    {
+  if (cmVS12GenName(name, genName)) {
     return genName == this->GetName();
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
 {
-  if(!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset))
-    {
+  if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) {
     std::ostringstream e;
-    if(this->DefaultPlatformToolset.empty())
-      {
+    if (this->DefaultPlatformToolset.empty()) {
       e << this->GetName() << " supports Windows Phone '8.0' and '8.1', but "
-        "not '" << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
-      }
-    else
-      {
+                              "not '"
+        << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
+    } else {
       e << "A Windows Phone component with CMake requires both the Windows "
         << "Desktop SDK as well as the Windows Phone '" << this->SystemVersion
         << "' SDK. Please make sure that you have both installed";
-      }
+    }
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
 {
-  if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset))
-    {
+  if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
     std::ostringstream e;
-    if(this->DefaultPlatformToolset.empty())
-      {
+    if (this->DefaultPlatformToolset.empty()) {
       e << this->GetName() << " supports Windows Store '8.0' and '8.1', but "
-        "not '" << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
-      }
-    else
-      {
+                              "not '"
+        << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
+    } else {
       e << "A Windows Store component with CMake requires both the Windows "
         << "Desktop SDK as well as the Windows Store '" << this->SystemVersion
         << "' SDK. Please make sure that you have both installed";
-      }
+    }
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset(
+bool cmGlobalVisualStudio12Generator::SelectWindowsPhoneToolset(
   std::string& toolset) const
 {
-  if(this->SystemVersion == "8.1")
-    {
+  if (this->SystemVersion == "8.1") {
     if (this->IsWindowsPhoneToolsetInstalled() &&
-        this->IsWindowsDesktopToolsetInstalled())
-      {
+        this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v120_wp81";
       return true;
-      }
-    else
-      {
+    } else {
       return false;
-      }
     }
-  return
-    this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(toolset);
+  }
+  return this->cmGlobalVisualStudio11Generator::SelectWindowsPhoneToolset(
+    toolset);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
+bool cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
   std::string& toolset) const
 {
-  if(this->SystemVersion == "8.1")
-    {
-    if(this->IsWindowsStoreToolsetInstalled() &&
-       this->IsWindowsDesktopToolsetInstalled())
-      {
+  if (this->SystemVersion == "8.1") {
+    if (this->IsWindowsStoreToolsetInstalled() &&
+        this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v120";
       return true;
-      }
-    else
-      {
+    } else {
       return false;
-      }
     }
-  return
-    this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(toolset);
+  }
+  return this->cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
+    toolset);
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
 {
   fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
-  if (this->ExpressEdition)
-    {
+  if (this->ExpressEdition) {
     fout << "# Visual Studio Express 2013 for Windows Desktop\n";
-    }
-  else
-    {
+  } else {
     fout << "# Visual Studio 2013\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const
+bool cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const
 {
-  const char desktop81Key[] =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-    "VisualStudio\\12.0\\VC\\LibraryDesktop";
+  const char desktop81Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+                              "VisualStudio\\12.0\\VC\\LibraryDesktop";
 
   std::vector<std::string> subkeys;
-  return cmSystemTools::GetRegistrySubKeys(desktop81Key,
-                                           subkeys,
+  return cmSystemTools::GetRegistrySubKeys(desktop81Key, subkeys,
                                            cmSystemTools::KeyWOW64_32);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio12Generator::IsWindowsPhoneToolsetInstalled() const
+bool cmGlobalVisualStudio12Generator::IsWindowsPhoneToolsetInstalled() const
 {
   const char wp81Key[] =
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
     "Microsoft SDKs\\WindowsPhone\\v8.1\\Install Path;Install Path";
 
   std::string path;
-  cmSystemTools::ReadRegistryValue(wp81Key,
-                                   path,
-                                   cmSystemTools::KeyWOW64_32);
+  cmSystemTools::ReadRegistryValue(wp81Key, path, cmSystemTools::KeyWOW64_32);
   return !path.empty();
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio12Generator::IsWindowsStoreToolsetInstalled() const
+bool cmGlobalVisualStudio12Generator::IsWindowsStoreToolsetInstalled() const
 {
-  const char win81Key[] =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-    "VisualStudio\\12.0\\VC\\Libraries\\Core\\Arm";
+  const char win81Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+                          "VisualStudio\\12.0\\VC\\Libraries\\Core\\Arm";
 
   std::vector<std::string> subkeys;
-  return cmSystemTools::GetRegistrySubKeys(win81Key,
-                                           subkeys,
+  return cmSystemTools::GetRegistrySubKeys(win81Key, subkeys,
                                            cmSystemTools::KeyWOW64_32);
 }
diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h
index a7939aa..567e240 100644
--- a/Source/cmGlobalVisualStudio12Generator.h
+++ b/Source/cmGlobalVisualStudio12Generator.h
@@ -14,23 +14,21 @@
 
 #include "cmGlobalVisualStudio11Generator.h"
 
-
 /** \class cmGlobalVisualStudio12Generator  */
-class cmGlobalVisualStudio12Generator:
-  public cmGlobalVisualStudio11Generator
+class cmGlobalVisualStudio12Generator : public cmGlobalVisualStudio11Generator
 {
 public:
   cmGlobalVisualStudio12Generator(cmake* cm, const std::string& name,
-    const std::string& platformName);
+                                  const std::string& platformName);
   static cmGlobalGeneratorFactory* NewFactory();
 
   virtual bool MatchesGeneratorName(const std::string& name) const;
 
   virtual void WriteSLNHeader(std::ostream& fout);
 
-  //in Visual Studio 2013 they detached the MSBuild tools version
-  //from the .Net Framework version and instead made it have it's own
-  //version number
+  // in Visual Studio 2013 they detached the MSBuild tools version
+  // from the .Net Framework version and instead made it have it's own
+  // version number
   virtual const char* GetToolsVersion() { return "12.0"; }
 protected:
   virtual bool InitializeWindowsPhone(cmMakefile* mf);
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index c058f8c..e190e84 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -10,25 +10,24 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalVisualStudio14Generator.h"
+
+#include "cmAlgorithms.h"
 #include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
-#include "cmAlgorithms.h"
 
 static const char vs14generatorName[] = "Visual Studio 14 2015";
 
 // Map generator name without year to name with year.
 static const char* cmVS14GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name.c_str(), vs14generatorName,
-             sizeof(vs14generatorName)-6) != 0)
-    {
+  if (strncmp(name.c_str(), vs14generatorName,
+              sizeof(vs14generatorName) - 6) != 0) {
     return 0;
-    }
+  }
   const char* p = name.c_str() + sizeof(vs14generatorName) - 6;
-  if(cmHasLiteralPrefix(p, " 2015"))
-    {
+  if (cmHasLiteralPrefix(p, " 2015")) {
     p += 5;
-    }
+  }
   genName = std::string(vs14generatorName) + p;
   return p;
 }
@@ -37,212 +36,179 @@ class cmGlobalVisualStudio14Generator::Factory
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const
-    {
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
     std::string genName;
     const char* p = cmVS14GenName(name, genName);
-    if(!p)
-      { return 0; }
-    if(!*p)
-      {
+    if (!p) {
+      return 0;
+    }
+    if (!*p) {
       return new cmGlobalVisualStudio14Generator(cm, genName, "");
-      }
-    if(*p++ != ' ')
-      { return 0; }
-    if(strcmp(p, "Win64") == 0)
-      {
+    }
+    if (*p++ != ' ') {
+      return 0;
+    }
+    if (strcmp(p, "Win64") == 0) {
       return new cmGlobalVisualStudio14Generator(cm, genName, "x64");
-      }
-    if(strcmp(p, "ARM") == 0)
-      {
+    }
+    if (strcmp(p, "ARM") == 0) {
       return new cmGlobalVisualStudio14Generator(cm, genName, "ARM");
-      }
-    return 0;
     }
+    return 0;
+  }
 
   virtual void GetDocumentation(cmDocumentationEntry& entry) const
-    {
+  {
     entry.Name = std::string(vs14generatorName) + " [arch]";
-    entry.Brief =
-      "Generates Visual Studio 2015 project files.  "
-      "Optional [arch] can be \"Win64\" or \"ARM\"."
-      ;
-    }
+    entry.Brief = "Generates Visual Studio 2015 project files.  "
+                  "Optional [arch] can be \"Win64\" or \"ARM\".";
+  }
 
   virtual void GetGenerators(std::vector<std::string>& names) const
-    {
+  {
     names.push_back(vs14generatorName);
     names.push_back(vs14generatorName + std::string(" ARM"));
     names.push_back(vs14generatorName + std::string(" Win64"));
-    }
+  }
 
   virtual bool SupportsToolset() const { return true; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(cmake* cm,
-  const std::string& name, const std::string& platformName)
+cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
+  cmake* cm, const std::string& name, const std::string& platformName)
   : cmGlobalVisualStudio12Generator(cm, name, platformName)
 {
   std::string vc14Express;
   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
-    "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
+    "ProductDir",
+    vc14Express, cmSystemTools::KeyWOW64_32);
   this->DefaultPlatformToolset = "v140";
   this->Version = VS14;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio14Generator::MatchesGeneratorName(
-                                                const std::string& name) const
+bool cmGlobalVisualStudio14Generator::MatchesGeneratorName(
+  const std::string& name) const
 {
   std::string genName;
-  if(cmVS14GenName(name, genName))
-    {
+  if (cmVS14GenName(name, genName)) {
     return genName == this->GetName();
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio14Generator::InitializeWindows(cmMakefile* mf)
 {
-  if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
-    {
+  if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
     return this->SelectWindows10SDK(mf, false);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf)
 {
-  std::ostringstream  e;
-  if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset))
-    {
-    if(this->DefaultPlatformToolset.empty())
-      {
+  std::ostringstream e;
+  if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
+    if (this->DefaultPlatformToolset.empty()) {
       e << this->GetName() << " supports Windows Store '8.0', '8.1' and "
-        "'10.0', but not '" << this->SystemVersion <<
-        "'.  Check CMAKE_SYSTEM_VERSION.";
-      }
-    else
-      {
+                              "'10.0', but not '"
+        << this->SystemVersion << "'.  Check CMAKE_SYSTEM_VERSION.";
+    } else {
       e << "A Windows Store component with CMake requires both the Windows "
         << "Desktop SDK as well as the Windows Store '" << this->SystemVersion
         << "' SDK. Please make sure that you have both installed";
-      }
+    }
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
-  if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
-    {
+  }
+  if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
     return this->SelectWindows10SDK(mf, true);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
                                                          bool required)
 {
   // Find the default version of the Windows 10 SDK.
   this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
-  if (required && this->WindowsTargetPlatformVersion.empty())
-    {
-    std::ostringstream  e;
+  if (required && this->WindowsTargetPlatformVersion.empty()) {
+    std::ostringstream e;
     e << "Could not find an appropriate version of the Windows 10 SDK"
       << " installed on this machine";
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
   mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",
                     this->WindowsTargetPlatformVersion.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
+bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
   std::string& toolset) const
 {
-  if (cmHasLiteralPrefix(this->SystemVersion, "10.0"))
-    {
+  if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
     if (this->IsWindowsStoreToolsetInstalled() &&
-        this->IsWindowsDesktopToolsetInstalled())
-      {
+        this->IsWindowsDesktopToolsetInstalled()) {
       toolset = "v140";
       return true;
-      }
-    else
-      {
+    } else {
       return false;
-      }
     }
-  return
-    this->cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(toolset);
+  }
+  return this->cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
+    toolset);
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
 {
   // Visual Studio 14 writes .sln format 12.00
   fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
-  if (this->ExpressEdition)
-    {
+  if (this->ExpressEdition) {
     fout << "# Visual Studio Express 14 for Windows Desktop\n";
-    }
-  else
-    {
+  } else {
     fout << "# Visual Studio 14\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const
+bool cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const
 {
-  const char desktop10Key[] =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-    "VisualStudio\\14.0\\VC\\Runtimes";
+  const char desktop10Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+                              "VisualStudio\\14.0\\VC\\Runtimes";
 
   std::vector<std::string> vc14;
-  return cmSystemTools::GetRegistrySubKeys(desktop10Key,
-    vc14, cmSystemTools::KeyWOW64_32);
+  return cmSystemTools::GetRegistrySubKeys(desktop10Key, vc14,
+                                           cmSystemTools::KeyWOW64_32);
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const
+bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const
 {
   const char universal10Key[] =
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
     "VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;SrcPath";
 
   std::string win10SDK;
-  return cmSystemTools::ReadRegistryValue(universal10Key,
-    win10SDK, cmSystemTools::KeyWOW64_32);
+  return cmSystemTools::ReadRegistryValue(universal10Key, win10SDK,
+                                          cmSystemTools::KeyWOW64_32);
 }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
 struct NoWindowsH
 {
   bool operator()(std::string const& p)
-    {
+  {
     return !cmSystemTools::FileExists(p + "/um/windows.h", true);
-    }
+  }
 };
 #endif
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -251,15 +217,14 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
   std::string win10Root;
   if (!cmSystemTools::ReadRegistryValue(
         "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
-        "Windows Kits\\Installed Roots;KitsRoot10", win10Root,
-        cmSystemTools::KeyWOW64_32) &&
+        "Windows Kits\\Installed Roots;KitsRoot10",
+        win10Root, cmSystemTools::KeyWOW64_32) &&
       !cmSystemTools::ReadRegistryValue(
         "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
-        "Windows Kits\\Installed Roots;KitsRoot10", win10Root,
-        cmSystemTools::KeyWOW64_32))
-    {
+        "Windows Kits\\Installed Roots;KitsRoot10",
+        win10Root, cmSystemTools::KeyWOW64_32)) {
     return std::string();
-    }
+  }
 
   std::vector<std::string> sdks;
   std::string path = win10Root + "Include/*";
@@ -271,31 +236,27 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
   sdks.erase(std::remove_if(sdks.begin(), sdks.end(), NoWindowsH()),
              sdks.end());
 
-  if (!sdks.empty())
-    {
+  if (!sdks.empty()) {
     // Only use the filename, which will be the SDK version.
-    for (std::vector<std::string>::iterator i = sdks.begin();
-         i != sdks.end(); ++i)
-      {
+    for (std::vector<std::string>::iterator i = sdks.begin(); i != sdks.end();
+         ++i) {
       *i = cmSystemTools::GetFilenameName(*i);
-      }
+    }
 
     // Sort the results to make sure we select the most recent one.
     std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater);
 
     // Look for a SDK exactly matching the requested target version.
-    for (std::vector<std::string>::iterator i = sdks.begin();
-         i != sdks.end(); ++i)
-      {
-      if (cmSystemTools::VersionCompareEqual(*i, this->SystemVersion))
-        {
+    for (std::vector<std::string>::iterator i = sdks.begin(); i != sdks.end();
+         ++i) {
+      if (cmSystemTools::VersionCompareEqual(*i, this->SystemVersion)) {
         return *i;
-        }
       }
+    }
 
     // Use the latest Windows 10 SDK since the exact version is not available.
     return sdks.at(0);
-    }
+  }
 #endif
   // Return an empty string
   return std::string();
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 57e6284..a00f6c7 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -14,14 +14,12 @@
 
 #include "cmGlobalVisualStudio12Generator.h"
 
-
 /** \class cmGlobalVisualStudio14Generator  */
-class cmGlobalVisualStudio14Generator:
-  public cmGlobalVisualStudio12Generator
+class cmGlobalVisualStudio14Generator : public cmGlobalVisualStudio12Generator
 {
 public:
   cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
-    const std::string& platformName);
+                                  const std::string& platformName);
   static cmGlobalGeneratorFactory* NewFactory();
 
   virtual bool MatchesGeneratorName(const std::string& name) const;
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
deleted file mode 100644
index 5866c0e..0000000
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ /dev/null
@@ -1,451 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#include "cmGlobalVisualStudio6Generator.h"
-#include "cmLocalVisualStudio6Generator.h"
-#include "cmMakefile.h"
-#include "cmake.h"
-#include "cmGeneratedFileStream.h"
-#include <cmsys/FStream.hxx>
-
-// Utility function to make a valid VS6 *.dsp filename out
-// of a CMake target name:
-//
-std::string GetVS6TargetName(const std::string& targetName)
-{
-  std::string name(targetName);
-
-  // Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames...
-  // Replace them with underscores.
-  //
-  cmSystemTools::ReplaceString(name, "-", "_");
-
-  return name;
-}
-
-cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator(cmake* cm)
-  : cmGlobalVisualStudioGenerator(cm)
-{
-  this->MSDevCommandInitialized = false;
-  this->Version = VS6;
-}
-
-void cmGlobalVisualStudio6Generator
-::EnableLanguage(std::vector<std::string>const& lang,
-                 cmMakefile *mf,
-                 bool optional)
-{
-  mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
-  mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
-  this->GenerateConfigurations(mf);
-  this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
-}
-
-void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
-{
-  std::string fname= mf->GetRequiredDefinition("CMAKE_ROOT");
-  const char* def= mf->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
-  if(def)
-    {
-    fname = def;
-    }
-  else
-    {
-    fname += "/Templates";
-    }
-  fname += "/CMakeVisualStudio6Configurations.cmake";
-  if(!mf->ReadDependentFile(fname.c_str()))
-    {
-    cmSystemTools::Error("Cannot open ", fname.c_str(),
-                         ".  Please copy this file from the main "
-                         "CMake/Templates directory and edit it for "
-                         "your build configurations.");
-    }
-  else if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
-    {
-    cmSystemTools::Error("CMAKE_CONFIGURATION_TYPES not set by ",
-                         fname.c_str(),
-                         ".  Please copy this file from the main "
-                         "CMake/Templates directory and edit it for "
-                         "your build configurations.");
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio6Generator::FindMakeProgram(cmMakefile* mf)
-{
-  this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf);
-  mf->AddDefinition("CMAKE_VS_MSDEV_COMMAND",
-                    this->GetMSDevCommand().c_str());
-}
-
-//----------------------------------------------------------------------------
-std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand()
-{
-  if(!this->MSDevCommandInitialized)
-    {
-    this->MSDevCommandInitialized = true;
-    this->MSDevCommand = this->FindMSDevCommand();
-    }
-  return this->MSDevCommand;
-}
-
-//----------------------------------------------------------------------------
-std::string cmGlobalVisualStudio6Generator::FindMSDevCommand()
-{
-  std::string vscmd;
-  std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir";
-  if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
-                                      cmSystemTools::KeyWOW64_32))
-    {
-    cmSystemTools::ConvertToUnixSlashes(vscmd);
-    vscmd += "/MSDev98/Bin/";
-    }
-  vscmd += "msdev.exe";
-  return vscmd;
-}
-
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio6Generator::GenerateBuildCommand(
-  std::vector<std::string>& makeCommand,
-  const std::string& makeProgram,
-  const std::string& projectName,
-  const std::string& /*projectDir*/,
-  const std::string& targetName,
-  const std::string& config,
-  bool /*fast*/, bool /*verbose*/,
-  std::vector<std::string> const& makeOptions
-  )
-{
-  // now build the test
-  makeCommand.push_back(
-    this->SelectMakeProgram(makeProgram, this->GetMSDevCommand())
-    );
-
-  makeCommand.push_back(std::string(projectName)+".dsw");
-  makeCommand.push_back("/MAKE");
-  std::string targetArg;
-  bool clean = false;
-  std::string realTarget = targetName;
-  if ( realTarget == "clean" )
-    {
-    clean = true;
-    realTarget = "ALL_BUILD";
-    }
-  if (!realTarget.empty())
-    {
-    targetArg += realTarget;
-    }
-  else
-    {
-    targetArg += "ALL_BUILD";
-    }
-  targetArg += " - ";
-  if(!config.empty())
-    {
-    targetArg += config;
-    }
-  else
-    {
-    targetArg += "Debug";
-    }
-  makeCommand.push_back(targetArg);
-  if(clean)
-    {
-    makeCommand.push_back("/CLEAN");
-    }
-  else
-    {
-    makeCommand.push_back("/BUILD");
-    }
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
-}
-
-///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf)
-{
-  return new cmLocalVisualStudio6Generator(this, mf);
-}
-
-
-void cmGlobalVisualStudio6Generator::Generate()
-{
-  // first do the superclass method
-  this->cmGlobalVisualStudioGenerator::Generate();
-
-  // Now write out the DSW
-  this->OutputDSWFile();
-
-  if (!this->CMakeInstance->GetIsInTryCompile())
-    {
-    const char* cmakeWarnVS6 =
-      this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS6");
-    if (!cmakeWarnVS6 || !cmSystemTools::IsOff(cmakeWarnVS6))
-      {
-      this->CMakeInstance->IssueMessage(
-        cmake::WARNING,
-        "The \"Visual Studio 6\" generator is deprecated "
-        "and will be removed in a future version of CMake."
-        "\n"
-        "Add CMAKE_WARN_VS6=OFF to the cache to disable this warning."
-        );
-      }
-    }
-}
-
-// Write a DSW file to the stream
-void cmGlobalVisualStudio6Generator
-::WriteDSWFile(std::ostream& fout,cmLocalGenerator* root,
-               std::vector<cmLocalGenerator*>& generators)
-{
-  // Write out the header for a DSW file
-  this->WriteDSWHeader(fout);
-
-  // Collect all targets under this root generator and the transitive
-  // closure of their dependencies.
-  TargetDependSet projectTargets;
-  TargetDependSet originalTargets;
-  this->GetTargetSets(projectTargets, originalTargets, root, generators);
-  OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
-
-  for(OrderedTargetDependSet::const_iterator
-        tt = orderedProjectTargets.begin();
-      tt != orderedProjectTargets.end(); ++tt)
-    {
-    cmGeneratorTarget const* target = *tt;
-    if(target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
-      continue;
-      }
-    // Write the project into the DSW file
-    const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
-    if(expath)
-      {
-      std::string project = target->GetName();
-      std::string location = expath;
-      this->WriteExternalProject(fout, project.c_str(),
-          location.c_str(), target->GetUtilities());
-      }
-    else
-      {
-      std::string dspname = GetVS6TargetName(target->GetName());
-      std::string dir =
-          target->GetLocalGenerator()->GetCurrentBinaryDirectory();
-      dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT);
-      this->WriteProject(fout, dspname.c_str(), dir.c_str(), target);
-      }
-    }
-
-  // Write the footer for the DSW file
-  this->WriteDSWFooter(fout);
-}
-
-void cmGlobalVisualStudio6Generator
-::OutputDSWFile(cmLocalGenerator* root,
-                std::vector<cmLocalGenerator*>& generators)
-{
-  if(generators.empty())
-    {
-    return;
-    }
-  std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory();
-  fname += "/";
-  fname += root->GetProjectName();
-  fname += ".dsw";
-  cmsys::ofstream fout(fname.c_str());
-  if(!fout)
-    {
-    cmSystemTools::Error("Error can not open DSW file for write: ",
-                         fname.c_str());
-    cmSystemTools::ReportLastSystemError("");
-    return;
-    }
-  this->WriteDSWFile(fout, root, generators);
-}
-
-// output the DSW file
-void cmGlobalVisualStudio6Generator::OutputDSWFile()
-{
-  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);
-    }
-}
-
-// Write a dsp file into the DSW file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
-                                            const std::string& dspname,
-                                            const char* dir,
-                                            const cmGeneratorTarget *target)
-{
-  fout << "#########################################################"
-    "######################\n\n";
-  fout << "Project: \"" << dspname << "\"="
-       << dir << "\\" << dspname << ".dsp - Package Owner=<4>\n\n";
-  fout << "Package=<5>\n{{{\n}}}\n\n";
-  fout << "Package=<4>\n";
-  fout << "{{{\n";
-  VSDependSet const& depends = this->VSTargetDepends[target];
-  for(VSDependSet::const_iterator di = depends.begin();
-      di != depends.end(); ++di)
-    {
-    const char* name = di->c_str();
-    fout << "Begin Project Dependency\n";
-    fout << "Project_Dep_Name " << GetVS6TargetName(name) << "\n";
-    fout << "End Project Dependency\n";
-    }
-  fout << "}}}\n\n";
-
-  UtilityDependsMap::iterator ui = this->UtilityDepends.find(target);
-  if(ui != this->UtilityDepends.end())
-    {
-    const char* uname = ui->second.c_str();
-    fout << "Project: \"" << uname << "\"="
-         << dir << "\\" << uname << ".dsp - Package Owner=<4>\n\n";
-    fout <<
-      "Package=<5>\n{{{\n}}}\n\n"
-      "Package=<4>\n"
-      "{{{\n"
-      "Begin Project Dependency\n"
-      "Project_Dep_Name " << dspname << "\n"
-      "End Project Dependency\n"
-      "}}}\n\n";
-      ;
-    }
-}
-
-
-// Write a dsp file into the DSW file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
-                               const std::string& name,
-                               const char* location,
-                               const std::set<std::string>& dependencies)
-{
- fout << "#########################################################"
-    "######################\n\n";
-  fout << "Project: \"" << name << "\"="
-       << location << " - Package Owner=<4>\n\n";
-  fout << "Package=<5>\n{{{\n}}}\n\n";
-  fout << "Package=<4>\n";
-  fout << "{{{\n";
-
-
-  std::set<std::string>::const_iterator i, end;
-  // write dependencies.
-  i = dependencies.begin();
-  end = dependencies.end();
-  for(;i!= end; ++i)
-  {
-    fout << "Begin Project Dependency\n";
-    fout << "Project_Dep_Name " << GetVS6TargetName(*i) << "\n";
-    fout << "End Project Dependency\n";
-  }
-  fout << "}}}\n\n";
-}
-
-
-
-// Standard end of dsw file
-void cmGlobalVisualStudio6Generator::WriteDSWFooter(std::ostream& fout)
-{
-  fout << "######################################################"
-    "#########################\n\n";
-  fout << "Global:\n\n";
-  fout << "Package=<5>\n{{{\n}}}\n\n";
-  fout << "Package=<3>\n{{{\n}}}\n\n";
-  fout << "#####################################################"
-    "##########################\n\n";
-}
-
-
-// ouput standard header for dsw file
-void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
-{
-  fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n";
-  fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n";
-}
-
-//----------------------------------------------------------------------------
-std::string
-cmGlobalVisualStudio6Generator::WriteUtilityDepend(
-        const cmGeneratorTarget *target)
-{
-  std::string pname = target->GetName();
-  pname += "_UTILITY";
-  pname = GetVS6TargetName(pname.c_str());
-  std::string fname =
-          target->GetLocalGenerator()->GetCurrentBinaryDirectory();
-  fname += "/";
-  fname += pname;
-  fname += ".dsp";
-  cmGeneratedFileStream fout(fname.c_str());
-  fout.SetCopyIfDifferent(true);
-  fout <<
-    "# Microsoft Developer Studio Project File - Name=\""
-       << pname << "\" - Package Owner=<4>\n"
-    "# Microsoft Developer Studio Generated Build File, Format Version 6.00\n"
-    "# ** DO NOT EDIT **\n"
-    "\n"
-    "# TARGTYPE \"Win32 (x86) Generic Project\" 0x010a\n"
-    "\n"
-    "CFG=" << pname << " - Win32 Debug\n"
-    "!MESSAGE \"" << pname << " - Win32 Debug\""
-    " (based on \"Win32 (x86) Generic Project\")\n"
-    "!MESSAGE \"" << pname << " - Win32 Release\" "
-    "(based on \"Win32 (x86) Generic Project\")\n"
-    "!MESSAGE \"" << pname << " - Win32 MinSizeRel\" "
-    "(based on \"Win32 (x86) Generic Project\")\n"
-    "!MESSAGE \"" << pname << " - Win32 RelWithDebInfo\" "
-    "(based on \"Win32 (x86) Generic Project\")\n"
-    "\n"
-    "# Begin Project\n"
-    "# Begin Target\n"
-    "# Name \"" << pname << " - Win32 Debug\"\n"
-    "# Name \"" << pname << " - Win32 Release\"\n"
-    "# Name \"" << pname << " - Win32 MinSizeRel\"\n"
-    "# Name \"" << pname << " - Win32 RelWithDebInfo\"\n"
-    "# End Target\n"
-    "# End Project\n"
-    ;
-  return pname;
-}
-
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio6Generator
-::GetDocumentation(cmDocumentationEntry& entry)
-{
-  entry.Name = cmGlobalVisualStudio6Generator::GetActualName();
-  entry.Brief = "Deprecated. Generates Visual Studio 6 project files.";
-}
-
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio6Generator
-::AppendDirectoryForConfig(const std::string& prefix,
-                           const std::string& config,
-                           const std::string& suffix,
-                           std::string& dir)
-{
-  if(!config.empty())
-    {
-    dir += prefix;
-    dir += config;
-    dir += suffix;
-    }
-}
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
deleted file mode 100644
index ae2988e..0000000
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#ifndef cmGlobalVisualStudio6Generator_h
-#define cmGlobalVisualStudio6Generator_h
-
-#include "cmGlobalVisualStudioGenerator.h"
-#include "cmGlobalGeneratorFactory.h"
-
-/** \class cmGlobalVisualStudio6Generator
- * \brief Write a Unix makefiles.
- *
- * cmGlobalVisualStudio6Generator manages UNIX build process for a tree
- */
-class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator
-{
-public:
-  cmGlobalVisualStudio6Generator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalVisualStudio6Generator>(); }
-
-  ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalVisualStudio6Generator::GetActualName();}
-  static std::string GetActualName() {return "Visual Studio 6";}
-
-  /** Get the documentation entry for this generator.  */
-  static void GetDocumentation(cmDocumentationEntry& entry);
-
-  /**
-   * Utilized by the generator factory to determine if this generator
-   * supports toolsets.
-   */
-  static bool SupportsToolset() { return false; }
-
-  ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
-
-  /**
-   * Try to determine system information such as shared library
-   * extension, pthreads, byte order etc.
-   */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
-
-  /**
-   * Try running cmake and building a file. This is used for dynalically
-   * loaded commands, not as part of the usual build process.
-   */
-  virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
-    const std::string& projectName,
-    const std::string& projectDir,
-    const std::string& targetName,
-    const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
-
-  /**
-   * Generate the DSW workspace file.
-   */
-  virtual void OutputDSWFile();
-  virtual void OutputDSWFile(cmLocalGenerator* root,
-                             std::vector<cmLocalGenerator*>& generators);
-  virtual void WriteDSWFile(std::ostream& fout,
-                            cmLocalGenerator* root,
-                            std::vector<cmLocalGenerator*>& generators);
-
-  /** Append the subdirectory for the given configuration.  */
-  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?
-  virtual const char* GetCMakeCFGIntDir() const { return "$(IntDir)"; }
-
-  virtual void FindMakeProgram(cmMakefile*);
-
-protected:
-  virtual void Generate();
-  virtual const char* GetIDEVersion() { return "6.0"; }
-private:
-  virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); }
-  void GenerateConfigurations(cmMakefile* mf);
-  void WriteDSWFile(std::ostream& fout);
-  void WriteDSWHeader(std::ostream& fout);
-  void WriteProject(std::ostream& fout,
-                    const std::string& name, const char* path,
-                    cmGeneratorTarget const* t);
-  void WriteExternalProject(std::ostream& fout,
-                            const std::string& name, const char* path,
-                            const std::set<std::string>& dependencies);
-  void WriteDSWFooter(std::ostream& fout);
-  virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target);
-  std::string MSDevCommand;
-  bool MSDevCommandInitialized;
-  std::string const& GetMSDevCommand();
-  std::string FindMSDevCommand();
-};
-
-#endif
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 8227b82..45d9522 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -10,21 +10,21 @@
   See the License for more information.
 ============================================================================*/
 #include "windows.h" // this must be first to define GetCurrentDirectory
+
 #include "cmGlobalVisualStudio71Generator.h"
+
 #include "cmLocalVisualStudio7Generator.h"
 #include "cmMakefile.h"
 #include "cmake.h"
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(cmake* cm,
-  const std::string& platformName)
+cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(
+  cmake* cm, const std::string& platformName)
   : cmGlobalVisualStudio7Generator(cm, platformName)
 {
   this->ProjectConfigurationSectionName = "ProjectConfiguration";
   this->Version = VS71;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory()
 {
   // Macros not supported on Visual Studio 7.1 and earlier because
@@ -63,7 +63,6 @@ std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory()
 #endif
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio71Generator::GetUserMacrosRegKeyBase()
 {
   // Macros not supported on Visual Studio 7.1 and earlier because
@@ -77,11 +76,9 @@ std::string cmGlobalVisualStudio71Generator::GetUserMacrosRegKeyBase()
 #endif
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio71Generator
-::WriteSLNFile(std::ostream& fout,
-               cmLocalGenerator* root,
-               std::vector<cmLocalGenerator*>& generators)
+void cmGlobalVisualStudio71Generator::WriteSLNFile(
+  std::ostream& fout, cmLocalGenerator* root,
+  std::vector<cmLocalGenerator*>& generators)
 {
   std::vector<std::string> configs;
   root->GetMakefile()->GetConfigurations(configs);
@@ -94,15 +91,30 @@ void cmGlobalVisualStudio71Generator
   TargetDependSet projectTargets;
   TargetDependSet originalTargets;
   this->GetTargetSets(projectTargets, originalTargets, root, generators);
-  OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
+  OrderedTargetDependSet orderedProjectTargets(
+    projectTargets, this->GetStartupProjectName(root));
 
-  this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
+  // Generate the targets specification to a string.  We will put this in
+  // the actual .sln file later.  As a side effect, this method also
+  // populates the set of folders.
+  std::ostringstream targetsSlnString;
+  this->WriteTargetsToSolution(targetsSlnString, root, orderedProjectTargets);
 
+  // VS 7 does not support folders specified first.
+  if (this->GetVersion() <= VS71) {
+    fout << targetsSlnString.str();
+  }
+
+  // Generate folder specification.
   bool useFolderProperty = this->UseFolderProperty();
-  if (useFolderProperty)
-    {
+  if (useFolderProperty) {
     this->WriteFolders(fout);
-    }
+  }
+
+  // Now write the actual target specification content.
+  if (this->GetVersion() > VS71) {
+    fout << targetsSlnString.str();
+  }
 
   // Write out the configurations information for the solution
   fout << "Global\n";
@@ -114,13 +126,12 @@ void cmGlobalVisualStudio71Generator
   this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
   fout << "\tEndGlobalSection\n";
 
-  if (useFolderProperty)
-    {
+  if (useFolderProperty) {
     // Write out project folders
     fout << "\tGlobalSection(NestedProjects) = preSolution\n";
     this->WriteFoldersContent(fout);
     fout << "\tEndGlobalSection\n";
-    }
+  }
 
   // Write out global sections
   this->WriteSLNGlobalSections(fout, root);
@@ -129,61 +140,52 @@ void cmGlobalVisualStudio71Generator
   this->WriteSLNFooter(fout);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio71Generator
-::WriteSolutionConfigurations(std::ostream& fout,
-                              std::vector<std::string> const& configs)
+void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations(
+  std::ostream& fout, std::vector<std::string> const& configs)
 {
   fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = configs.begin();
+       i != configs.end(); ++i) {
     fout << "\t\t" << *i << " = " << *i << "\n";
-    }
+  }
   fout << "\tEndGlobalSection\n";
 }
 
-//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file,
 // Note, that dependencies from executables to
 // the libraries it uses are also done here
-void
-cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
-                                              const std::string& dspname,
-                                              const char* dir,
-                                              cmGeneratorTarget const* t)
+void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
+                                                   const std::string& dspname,
+                                                   const char* dir,
+                                                   cmGeneratorTarget const* t)
 {
   // check to see if this is a fortran build
   const char* ext = ".vcproj";
   const char* project =
     "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"";
-  if(this->TargetIsFortranOnly(t))
-    {
+  if (this->TargetIsFortranOnly(t)) {
     ext = ".vfproj";
     project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
-    }
+  }
   const char* targetExt = t->GetProperty("GENERATOR_FILE_NAME_EXT");
-  if(targetExt)
-    {
+  if (targetExt) {
     ext = targetExt;
-    }
+  }
 
   std::string guid = this->GetGUID(dspname);
-  fout << project
-       << dspname << "\", \""
-       << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"")
-       << dspname << ext << "\", \"{" << guid << "}\"\n";
+  fout << project << dspname << "\", \"" << this->ConvertToSolutionPath(dir)
+       << (dir[0] ? "\\" : "") << dspname << ext << "\", \"{" << guid
+       << "}\"\n";
   fout << "\tProjectSection(ProjectDependencies) = postProject\n";
   this->WriteProjectDepends(fout, dspname, dir, t);
   fout << "\tEndProjectSection\n";
 
-  fout <<"EndProject\n";
+  fout << "EndProject\n";
 
   UtilityDependsMap::iterator ui = this->UtilityDepends.find(t);
-  if(ui != this->UtilityDepends.end())
-    {
+  if (ui != this->UtilityDepends.end()) {
     const char* uname = ui->second.c_str();
+    /* clang-format off */
     fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
          << uname << "\", \""
          << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"")
@@ -193,85 +195,65 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
          << "\t\t{" << guid << "} = {" << guid << "}\n"
          << "\tEndProjectSection\n"
          << "EndProject\n";
-    }
+    /* clang-format on */
+  }
 }
 
-//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file,
 // Note, that dependencies from executables to
 // the libraries it uses are also done here
-void
-cmGlobalVisualStudio71Generator
-::WriteProjectDepends(std::ostream& fout,
-                      const std::string&,
-                      const char*, cmGeneratorTarget const* target)
+void cmGlobalVisualStudio71Generator::WriteProjectDepends(
+  std::ostream& fout, const std::string&, const char*,
+  cmGeneratorTarget const* target)
 {
   VSDependSet const& depends = this->VSTargetDepends[target];
-  for(VSDependSet::const_iterator di = depends.begin();
-      di != depends.end(); ++di)
-    {
+  for (VSDependSet::const_iterator di = depends.begin(); di != depends.end();
+       ++di) {
     const char* name = di->c_str();
     std::string guid = this->GetGUID(name);
-    if(guid.empty())
-      {
+    if (guid.empty()) {
       std::string m = "Target: ";
       m += target->GetName();
       m += " depends on unknown target: ";
       m += name;
       cmSystemTools::Error(m.c_str());
-      }
-    fout << "\t\t{" << guid << "} = {" << guid << "}\n";
     }
+    fout << "\t\t{" << guid << "} = {" << guid << "}\n";
+  }
 }
 
-//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file, Note, that dependencies from
 // executables to the libraries it uses are also done here
-void cmGlobalVisualStudio71Generator
-::WriteExternalProject(std::ostream& fout,
-                       const std::string& name,
-                       const char* location,
-                       const char* typeGuid,
-                       const std::set<std::string>& depends)
+void cmGlobalVisualStudio71Generator::WriteExternalProject(
+  std::ostream& fout, const std::string& name, const char* location,
+  const char* typeGuid, const std::set<std::string>& depends)
 {
   fout << "Project(\"{"
        << (typeGuid ? typeGuid : this->ExternalProjectType(location))
-       << "}\") = \""
-       << name << "\", \""
+       << "}\") = \"" << name << "\", \""
        << this->ConvertToSolutionPath(location) << "\", \"{"
-       << this->GetGUID(name)
-       << "}\"\n";
+       << this->GetGUID(name) << "}\"\n";
 
   // write out the dependencies here VS 7.1 includes dependencies with the
   // project instead of in the global section
-  if(!depends.empty())
-    {
+  if (!depends.empty()) {
     fout << "\tProjectSection(ProjectDependencies) = postProject\n";
     std::set<std::string>::const_iterator it;
-    for(it = depends.begin(); it != depends.end(); ++it)
-      {
-      if(!it->empty())
-        {
-        fout << "\t\t{"
-             << this->GetGUID(it->c_str())
-             << "} = {"
-             << this->GetGUID(it->c_str())
-             << "}\n";
-        }
+    for (it = depends.begin(); it != depends.end(); ++it) {
+      if (!it->empty()) {
+        fout << "\t\t{" << this->GetGUID(it->c_str()) << "} = {"
+             << this->GetGUID(it->c_str()) << "}\n";
       }
-    fout << "\tEndProjectSection\n";
     }
+    fout << "\tEndProjectSection\n";
+  }
 
   fout << "EndProject\n";
-
-
 }
 
-//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file, Note, that dependencies from
 // executables to the libraries it uses are also done here
-void cmGlobalVisualStudio71Generator
-::WriteProjectConfigurations(
+void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
   std::ostream& fout, const std::string& name, cmState::TargetType,
   std::vector<std::string> const& configs,
   const std::set<std::string>& configsPartOfDefaultBuild,
@@ -280,32 +262,28 @@ void cmGlobalVisualStudio71Generator
   const std::string& platformName =
     !platformMapping.empty() ? platformMapping : this->GetPlatformName();
   std::string guid = this->GetGUID(name);
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
-    fout << "\t\t{" << guid << "}." << *i
-         << ".ActiveCfg = " << *i << "|" << platformName << std::endl;
-    std::set<std::string>::const_iterator
-      ci = configsPartOfDefaultBuild.find(*i);
-    if(!(ci == configsPartOfDefaultBuild.end()))
-      {
-      fout << "\t\t{" << guid << "}." << *i
-           << ".Build.0 = " << *i << "|" << platformName << std::endl;
-      }
+  for (std::vector<std::string>::const_iterator i = configs.begin();
+       i != configs.end(); ++i) {
+    fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|"
+         << platformName << std::endl;
+    std::set<std::string>::const_iterator ci =
+      configsPartOfDefaultBuild.find(*i);
+    if (!(ci == configsPartOfDefaultBuild.end())) {
+      fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|"
+           << platformName << std::endl;
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 // ouput standard header for dsw file
 void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
 {
   fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n";
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio71Generator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalVisualStudio71Generator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalVisualStudio71Generator::GetActualName();
-  entry.Brief = "Generates Visual Studio .NET 2003 project files.";
+  entry.Brief = "Deprecated. Generates Visual Studio .NET 2003 project files.";
 }
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 5035fda..9ad1fad 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -14,7 +14,6 @@
 
 #include "cmGlobalVisualStudio7Generator.h"
 
-
 /** \class cmGlobalVisualStudio71Generator
  * \brief Write a Unix makefiles.
  *
@@ -25,14 +24,18 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
 public:
   cmGlobalVisualStudio71Generator(cmake* cm,
                                   const std::string& platformName = "");
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalVisualStudio71Generator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<
+      cmGlobalVisualStudio71Generator>();
+  }
 
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalVisualStudio71Generator::GetActualName();}
-  static std::string GetActualName() {return "Visual Studio 7 .NET 2003";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalVisualStudio71Generator::GetActualName();
+  }
+  static std::string GetActualName() { return "Visual Studio 7 .NET 2003"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -52,29 +55,29 @@ public:
 
 protected:
   virtual const char* GetIDEVersion() { return "7.1"; }
-  virtual void WriteSLNFile(std::ostream& fout,
-                            cmLocalGenerator* root,
+  virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
                             std::vector<cmLocalGenerator*>& generators);
   virtual void WriteSolutionConfigurations(
     std::ostream& fout, std::vector<std::string> const& configs);
-  virtual void WriteProject(std::ostream& fout,
-                            const std::string& name, const char* path,
-                            const cmGeneratorTarget *t);
-  virtual void WriteProjectDepends(std::ostream& fout,
-                           const std::string& name, const char* path,
-                           cmGeneratorTarget const* t);
+  virtual void WriteProject(std::ostream& fout, const std::string& name,
+                            const char* path, const cmGeneratorTarget* t);
+  virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
+                                   const char* path,
+                                   cmGeneratorTarget const* t);
   virtual void WriteProjectConfigurations(
     std::ostream& fout, const std::string& name, cmState::TargetType type,
     std::vector<std::string> const& configs,
     const std::set<std::string>& configsPartOfDefaultBuild,
     const std::string& platformMapping = "");
   virtual void WriteExternalProject(std::ostream& fout,
-                                    const std::string& name,
-                                    const char* path,
+                                    const std::string& name, const char* path,
                                     const char* typeGuid,
                                     const std::set<std::string>& depends);
   virtual void WriteSLNHeader(std::ostream& fout);
 
+  // Folders are not supported by VS 7.1.
+  virtual bool UseFolderProperty() { return false; }
+
   std::string ProjectConfigurationSectionName;
 };
 #endif
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index f5848ab..a33bd8b 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -10,8 +10,9 @@
   See the License for more information.
 ============================================================================*/
 #include "windows.h" // this must be first to define GetCurrentDirectory
-#include <assert.h>
+
 #include "cmGlobalVisualStudio7Generator.h"
+
 #include "cmGeneratedFileStream.h"
 #include "cmLocalVisualStudio7Generator.h"
 #include "cmMakefile.h"
@@ -19,48 +20,46 @@
 #include "cmake.h"
 #include <cmsys/Encoding.hxx>
 
-//----------------------------------------------------------------------------
-static cmVS7FlagTable cmVS7ExtraFlagTable[] =
-{
+#include <assert.h>
+
+static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
   // Precompiled header and related options.  Note that the
   // UsePrecompiledHeader entries are marked as "Continue" so that the
   // corresponding PrecompiledHeaderThrough entry can be found.
-  {"UsePrecompiledHeader", "YX", "Automatically Generate", "2",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true", 0},
+  { "UsePrecompiledHeader", "YX", "Automatically Generate", "2",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeaderThrough", "YX", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "UsePrecompiledHeader", "Yu", "Use Precompiled Header", "3",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "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.
 
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
 
-cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(cmake *cm,
-  const std::string& platformName)
+cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
+  cmake* cm, const std::string& platformName)
   : cmGlobalVisualStudioGenerator(cm)
 {
   this->IntelProjectVersion = 0;
   this->DevEnvCommandInitialized = false;
   this->MasmEnabled = false;
 
-  if (platformName.empty())
-    {
+  if (platformName.empty()) {
     this->DefaultPlatformName = "Win32";
-    }
-  else
-    {
+  } else {
     this->DefaultPlatformName = platformName;
-    }
+  }
   this->ExtraFlagTable = cmVS7ExtraFlagTable;
   this->Version = VS7;
 }
@@ -75,8 +74,7 @@ cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
 
 const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
 {
-  if(!this->IntelProjectVersion)
-    {
+  if (!this->IntelProjectVersion) {
     // Compute the version of the Intel plugin to the VS IDE.
     // If the key does not exist then use a default guess.
     std::string intelVersion;
@@ -86,41 +84,33 @@ const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
                                      cmSystemTools::KeyWOW64_32);
     unsigned int intelVersionNumber = ~0u;
     sscanf(intelVersion.c_str(), "%u", &intelVersionNumber);
-    if(intelVersionNumber >= 11)
-      {
+    if (intelVersionNumber >= 11) {
       // Default to latest known project file version.
       intelVersion = "11.0";
-      }
-    else if(intelVersionNumber == 10)
-      {
+    } else if (intelVersionNumber == 10) {
       // Version 10.x actually uses 9.10 in project files!
       intelVersion = "9.10";
-      }
-    else
-      {
+    } else {
       // Version <= 9: use ProductVersion from registry.
-      }
-    this->IntelProjectVersion = strdup(intelVersion.c_str());
     }
+    this->IntelProjectVersion = strdup(intelVersion.c_str());
+  }
   return this->IntelProjectVersion;
 }
 
-void cmGlobalVisualStudio7Generator
-::EnableLanguage(std::vector<std::string>const &  lang,
-                 cmMakefile *mf, bool optional)
+void cmGlobalVisualStudio7Generator::EnableLanguage(
+  std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
 {
   mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
   mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
-  if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
-    {
+  if (!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
     mf->AddCacheDefinition(
-      "CMAKE_CONFIGURATION_TYPES",
-      "Debug;Release;MinSizeRel;RelWithDebInfo",
+      "CMAKE_CONFIGURATION_TYPES", "Debug;Release;MinSizeRel;RelWithDebInfo",
       "Semicolon separated list of supported configuration types, "
       "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
       "anything else will be ignored.",
       cmState::STRING);
-    }
+  }
 
   // Create list of configurations requested by user's cache, if any.
   this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
@@ -133,17 +123,13 @@ void cmGlobalVisualStudio7Generator
   // for running commands and using dll's that the IDE environment
   // does not know about.
   const char* extraPath = cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH");
-  if(extraPath)
-    {
-    mf->AddCacheDefinition
-      ("CMAKE_MSVCIDE_RUN_PATH", extraPath,
-       "Saved environment variable CMAKE_MSVCIDE_RUN_PATH",
-       cmState::STATIC);
-    }
-
+  if (extraPath) {
+    mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath,
+                           "Saved environment variable CMAKE_MSVCIDE_RUN_PATH",
+                           cmState::STATIC);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf)
 {
   this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf);
@@ -151,77 +137,54 @@ void cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf)
                     this->GetDevEnvCommand().c_str());
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand()
 {
-  if(!this->DevEnvCommandInitialized)
-    {
+  if (!this->DevEnvCommandInitialized) {
     this->DevEnvCommandInitialized = true;
     this->DevEnvCommand = this->FindDevEnvCommand();
-    }
+  }
   return this->DevEnvCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
 {
   std::string vscmd;
   std::string vskey = this->GetRegistryBase() + ";InstallDir";
-  if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
-                                      cmSystemTools::KeyWOW64_32))
-    {
+  if (cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
+                                       cmSystemTools::KeyWOW64_32)) {
     cmSystemTools::ConvertToUnixSlashes(vscmd);
     vscmd += "/";
-    }
+  }
   vscmd += "devenv.com";
   return vscmd;
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
   const char* location)
 {
   std::string extension = cmSystemTools::GetFilenameLastExtension(location);
-  if (extension == ".vbproj")
-    {
+  if (extension == ".vbproj") {
     return "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
-    }
-  else if (extension == ".csproj")
-    {
+  } else if (extension == ".csproj") {
     return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC";
-    }
-  else if (extension == ".fsproj")
-    {
+  } else if (extension == ".fsproj") {
     return "F2A71F9B-5D33-465A-A702-920D77279786";
-    }
-  else if (extension == ".vdproj")
-    {
+  } else if (extension == ".vdproj") {
     return "54435603-DBB4-11D2-8724-00A0C9A8B90C";
-    }
-  else if (extension == ".dbproj")
-    {
+  } else if (extension == ".dbproj") {
     return "C8D11400-126E-41CD-887F-60BD40844F9E";
-    }
-  else if (extension == ".wixproj")
-    {
+  } else if (extension == ".wixproj") {
     return "930C7802-8A8C-48F9-8165-68863BCCD9DD";
-    }
-  else if (extension == ".pyproj")
-    {
+  } else if (extension == ".pyproj") {
     return "888888A0-9F3D-457C-B088-3A5042F75D52";
-    }
+  }
   return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
 }
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
-  std::vector<std::string>& makeCommand,
-  const std::string& makeProgram,
-  const std::string& projectName,
-  const std::string& /*projectDir*/,
-  const std::string& targetName,
-  const std::string& config,
-  bool /*fast*/, bool /*verbose*/,
-  std::vector<std::string> const& makeOptions)
+  std::vector<std::string>& makeCommand, const std::string& makeProgram,
+  const std::string& projectName, const std::string& /*projectDir*/,
+  const std::string& targetName, const std::string& config, bool /*fast*/,
+  bool /*verbose*/, std::vector<std::string> const& makeOptions)
 {
   // Select the caller- or user-preferred make program, else devenv.
   std::string makeProgramSelected =
@@ -232,72 +195,58 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
   // command-line compatible with devenv.
   std::string makeProgramLower = makeProgramSelected;
   cmSystemTools::LowerCase(makeProgramLower);
-  if(makeProgramLower.find("msbuild") != std::string::npos)
-    {
+  if (makeProgramLower.find("msbuild") != std::string::npos) {
     makeProgramSelected = this->GetDevEnvCommand();
-    }
+  }
 
   makeCommand.push_back(makeProgramSelected);
 
   makeCommand.push_back(std::string(projectName) + ".sln");
   std::string realTarget = targetName;
   bool clean = false;
-  if ( realTarget == "clean" )
-    {
+  if (realTarget == "clean") {
     clean = true;
     realTarget = "ALL_BUILD";
-    }
-  if(clean)
-    {
+  }
+  if (clean) {
     makeCommand.push_back("/clean");
-    }
-  else
-    {
+  } else {
     makeCommand.push_back("/build");
-    }
+  }
 
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     makeCommand.push_back(config);
-    }
-  else
-    {
+  } else {
     makeCommand.push_back("Debug");
-    }
+  }
   makeCommand.push_back("/project");
 
-  if (!realTarget.empty())
-    {
+  if (!realTarget.empty()) {
     makeCommand.push_back(realTarget);
-    }
-  else
-    {
+  } else {
     makeCommand.push_back("ALL_BUILD");
-    }
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
+  }
+  makeCommand.insert(makeCommand.end(), makeOptions.begin(),
+                     makeOptions.end());
 }
 
 ///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator(
-    cmMakefile* mf)
+cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator(
+  cmMakefile* mf)
 {
-  cmLocalVisualStudio7Generator *lg =
+  cmLocalVisualStudio7Generator* lg =
     new cmLocalVisualStudio7Generator(this, mf);
   return lg;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const
 {
-  if(!this->GeneratorPlatform.empty())
-    {
+  if (!this->GeneratorPlatform.empty()) {
     return this->GeneratorPlatform;
-    }
+  }
   return this->DefaultPlatformName;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
                                                    cmMakefile* mf)
 {
@@ -306,18 +255,14 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
   return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf);
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p,
                                                           cmMakefile* mf)
 {
-  if(this->GetPlatformName() == "x64")
-    {
+  if (this->GetPlatformName() == "x64") {
     mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
-    }
-  else if(this->GetPlatformName() == "Itanium")
-    {
+  } else if (this->GetPlatformName() == "Itanium") {
     mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
-    }
+  }
   mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str());
   return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf);
 }
@@ -331,37 +276,30 @@ void cmGlobalVisualStudio7Generator::Generate()
   this->OutputSLNFile();
   // If any solution or project files changed during the generation,
   // tell Visual Studio to reload them...
-  if(!cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (!cmSystemTools::GetErrorOccuredFlag()) {
     this->CallVisualStudioMacro(MacroReload);
-    }
+  }
 
-  if (!this->CMakeInstance->GetIsInTryCompile() &&
-      this->GetName() == "Visual Studio 7")
-    {
-    const char* cmakeWarnVS70 =
-      this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS70");
-    if (!cmakeWarnVS70 || !cmSystemTools::IsOff(cmakeWarnVS70))
-      {
+  if (this->Version == VS71 && !this->CMakeInstance->GetIsInTryCompile()) {
+    const char* cmakeWarnVS71 =
+      this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS71");
+    if (!cmakeWarnVS71 || !cmSystemTools::IsOff(cmakeWarnVS71)) {
       this->CMakeInstance->IssueMessage(
         cmake::WARNING,
-        "The \"Visual Studio 7\" generator is deprecated "
+        "The \"Visual Studio 7 .NET 2003\" generator is deprecated "
         "and will be removed in a future version of CMake."
         "\n"
-        "Add CMAKE_WARN_VS70=OFF to the cache to disable this warning."
-        );
-      }
+        "Add CMAKE_WARN_VS71=OFF to the cache to disable this warning.");
     }
+  }
 }
 
-void cmGlobalVisualStudio7Generator
-::OutputSLNFile(cmLocalGenerator* root,
-                std::vector<cmLocalGenerator*>& generators)
+void cmGlobalVisualStudio7Generator::OutputSLNFile(
+  cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
 {
-  if(generators.empty())
-    {
+  if (generators.empty()) {
     return;
-    }
+  }
   this->CurrentProject = root->GetProjectName();
   std::string fname = root->GetCurrentBinaryDirectory();
   fname += "/";
@@ -369,527 +307,262 @@ void cmGlobalVisualStudio7Generator
   fname += ".sln";
   cmGeneratedFileStream fout(fname.c_str());
   fout.SetCopyIfDifferent(true);
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
   this->WriteSLNFile(fout, root, generators);
-  if (fout.Close())
-    {
+  if (fout.Close()) {
     this->FileReplacedDuringGenerate(fname);
-    }
+  }
 }
 
 // output the SLN file
 void cmGlobalVisualStudio7Generator::OutputSLNFile()
 {
   std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
-  for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
-    {
+  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
     this->OutputSLNFile(it->second[0], it->second);
-    }
+  }
 }
 
-
 void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
-  std::ostream& fout,
-  std::vector<std::string> const& configs,
+  std::ostream& fout, std::vector<std::string> const& configs,
   OrderedTargetDependSet const& projectTargets)
 {
   // loop over again and write out configurations for each target
   // in the solution
-  for(OrderedTargetDependSet::const_iterator tt =
-        projectTargets.begin(); tt != projectTargets.end(); ++tt)
-    {
+  for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
+       tt != projectTargets.end(); ++tt) {
     cmGeneratorTarget const* target = *tt;
-    if(target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (target->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
-    if(expath)
-      {
+    if (expath) {
       std::set<std::string> allConfigurations(configs.begin(), configs.end());
       const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
       this->WriteProjectConfigurations(
-        fout, target->GetName().c_str(), target->GetType(),
-        configs, allConfigurations, mapping ? mapping : "");
-      }
-    else
-      {
+        fout, target->GetName().c_str(), target->GetType(), configs,
+        allConfigurations, mapping ? mapping : "");
+    } else {
       const std::set<std::string>& configsPartOfDefaultBuild =
         this->IsPartOfDefaultBuild(configs, projectTargets, target);
-      const char *vcprojName =
-        target->GetProperty("GENERATOR_FILE_NAME");
-      if (vcprojName)
-        {
+      const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
+      if (vcprojName) {
         this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
                                          configs, configsPartOfDefaultBuild);
-        }
       }
     }
+  }
 }
 
-
 void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
-    std::ostream& fout,
-    cmLocalGenerator* root,
-    OrderedTargetDependSet const& projectTargets)
+  std::ostream& fout, cmLocalGenerator* root,
+  OrderedTargetDependSet const& projectTargets)
 {
   VisualStudioFolders.clear();
 
-  for(OrderedTargetDependSet::const_iterator tt =
-        projectTargets.begin(); tt != projectTargets.end(); ++tt)
-    {
+  for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
+       tt != projectTargets.end(); ++tt) {
     cmGeneratorTarget const* target = *tt;
-    if(target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (target->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     bool written = false;
 
     // handle external vc project files
     const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
-    if(expath)
-      {
+    if (expath) {
       std::string project = target->GetName();
       std::string location = expath;
 
-      this->WriteExternalProject(fout,
-                                 project.c_str(),
-                                 location.c_str(),
+      this->WriteExternalProject(fout, project.c_str(), location.c_str(),
                                  target->GetProperty("VS_PROJECT_TYPE"),
                                  target->GetUtilities());
       written = true;
-      }
-    else
-      {
-      const char *vcprojName =
-        target->GetProperty("GENERATOR_FILE_NAME");
-      if(vcprojName)
-        {
+    } else {
+      const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
+      if (vcprojName) {
         cmLocalGenerator* lg = target->GetLocalGenerator();
         std::string dir = lg->GetCurrentBinaryDirectory();
-        dir = root->Convert(dir.c_str(),
-                            cmLocalGenerator::START_OUTPUT);
-        if(dir == ".")
-          {
+        dir = root->Convert(dir.c_str(), cmOutputConverter::START_OUTPUT);
+        if (dir == ".") {
           dir = ""; // msbuild cannot handle ".\" prefix
-          }
-        this->WriteProject(fout, vcprojName, dir.c_str(),
-                           target);
-        written = true;
         }
+        this->WriteProject(fout, vcprojName, dir.c_str(), target);
+        written = true;
       }
+    }
 
     // Create "solution folder" information from FOLDER target property
     //
-    if (written && this->UseFolderProperty())
-      {
-      const char *targetFolder = target->GetProperty("FOLDER");
-      if (targetFolder)
-        {
+    if (written && this->UseFolderProperty()) {
+      const char* targetFolder = target->GetProperty("FOLDER");
+      if (targetFolder) {
         std::vector<cmsys::String> tokens =
           cmSystemTools::SplitString(targetFolder, '/', false);
 
         std::string cumulativePath = "";
 
-        for(std::vector<cmsys::String>::iterator iter = tokens.begin();
-            iter != tokens.end(); ++iter)
-          {
-          if(!iter->size())
-            {
+        for (std::vector<cmsys::String>::iterator iter = tokens.begin();
+             iter != tokens.end(); ++iter) {
+          if (!iter->size()) {
             continue;
-            }
+          }
 
-          if (cumulativePath.empty())
-            {
+          if (cumulativePath.empty()) {
             cumulativePath = "CMAKE_FOLDER_GUID_" + *iter;
-            }
-          else
-            {
-            VisualStudioFolders[cumulativePath].insert(
-              cumulativePath + "/" + *iter);
+          } else {
+            VisualStudioFolders[cumulativePath].insert(cumulativePath + "/" +
+                                                       *iter);
 
             cumulativePath = cumulativePath + "/" + *iter;
-            }
           }
+        }
 
-        if (!cumulativePath.empty())
-          {
+        if (!cumulativePath.empty()) {
           VisualStudioFolders[cumulativePath].insert(target->GetName());
-          }
         }
       }
     }
+  }
 }
 
-
 void cmGlobalVisualStudio7Generator::WriteTargetDepends(
-    std::ostream& fout,
-    OrderedTargetDependSet const& projectTargets
-    )
+  std::ostream& fout, OrderedTargetDependSet const& projectTargets)
 {
-  for(OrderedTargetDependSet::const_iterator tt =
-        projectTargets.begin(); tt != projectTargets.end(); ++tt)
-    {
+  for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
+       tt != projectTargets.end(); ++tt) {
     cmGeneratorTarget const* target = *tt;
-    if(target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (target->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
-    const char *vcprojName =
-      target->GetProperty("GENERATOR_FILE_NAME");
-    if (vcprojName)
-      {
-      std::string dir = target->GetLocalGenerator()
-              ->GetCurrentSourceDirectory();
-      this->WriteProjectDepends(fout, vcprojName,
-                                dir.c_str(), target);
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-// Write a SLN file to the stream
-void cmGlobalVisualStudio7Generator
-::WriteSLNFile(std::ostream& fout,
-               cmLocalGenerator* root,
-               std::vector<cmLocalGenerator*>& generators)
-{
-  std::vector<std::string> configs;
-  root->GetMakefile()->GetConfigurations(configs);
-
-  // Write out the header for a SLN file
-  this->WriteSLNHeader(fout);
-
-  // Collect all targets under this root generator and the transitive
-  // closure of their dependencies.
-  TargetDependSet projectTargets;
-  TargetDependSet originalTargets;
-  this->GetTargetSets(projectTargets, originalTargets, root, generators);
-  OrderedTargetDependSet orderedProjectTargets(projectTargets, "ALL_BUILD");
-
-  this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
-
-  bool useFolderProperty = this->UseFolderProperty();
-  if (useFolderProperty)
-    {
-    this->WriteFolders(fout);
     }
-
-  // Write out the configurations information for the solution
-  fout << "Global\n"
-       << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
-
-  int c = 0;
-  for(std::vector<std::string>::iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
-    fout << "\t\tConfigName." << c << " = " << *i << "\n";
-    c++;
-    }
-  fout << "\tEndGlobalSection\n";
-  // Write out project(target) depends
-  fout << "\tGlobalSection(ProjectDependencies) = postSolution\n";
-  this->WriteTargetDepends(fout, orderedProjectTargets);
-  fout << "\tEndGlobalSection\n";
-
-  if (useFolderProperty)
-    {
-    // Write out project folders
-    fout << "\tGlobalSection(NestedProjects) = preSolution\n";
-    this->WriteFoldersContent(fout);
-    fout << "\tEndGlobalSection\n";
+    const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
+    if (vcprojName) {
+      std::string dir =
+        target->GetLocalGenerator()->GetCurrentSourceDirectory();
+      this->WriteProjectDepends(fout, vcprojName, dir.c_str(), target);
     }
-
-  // Write out the configurations for all the targets in the project
-  fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
-  this->WriteTargetConfigurations(fout, configs, orderedProjectTargets);
-  fout << "\tEndGlobalSection\n";
-
-  // Write out global sections
-  this->WriteSLNGlobalSections(fout, root);
-
-  // Write the footer for the SLN file
-  this->WriteSLNFooter(fout);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
 {
-  const char *prefix = "CMAKE_FOLDER_GUID_";
+  const char* prefix = "CMAKE_FOLDER_GUID_";
   const std::string::size_type skip_prefix = strlen(prefix);
   std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
-  for(std::map<std::string,std::set<std::string> >::iterator iter =
-    VisualStudioFolders.begin(); iter != VisualStudioFolders.end(); ++iter)
-    {
+  for (std::map<std::string, std::set<std::string> >::iterator iter =
+         VisualStudioFolders.begin();
+       iter != VisualStudioFolders.end(); ++iter) {
     std::string fullName = iter->first;
     std::string guid = this->GetGUID(fullName.c_str());
 
-    cmSystemTools::ReplaceString(fullName, "/", "\\");
-    if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix))
-      {
+    std::replace(fullName.begin(), fullName.end(), '/', '\\');
+    if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) {
       fullName = fullName.substr(skip_prefix);
-      }
+    }
 
     std::string nameOnly = cmSystemTools::GetFilenameName(fullName);
 
-    fout << "Project(\"{" <<
-      guidProjectTypeFolder << "}\") = \"" <<
-      nameOnly << "\", \"" <<
-      fullName << "\", \"{" <<
-      guid <<
-      "}\"\nEndProject\n";
-    }
+    fout << "Project(\"{" << guidProjectTypeFolder << "}\") = \"" << nameOnly
+         << "\", \"" << fullName << "\", \"{" << guid << "}\"\nEndProject\n";
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
 {
-  for(std::map<std::string,std::set<std::string> >::iterator iter =
-    VisualStudioFolders.begin(); iter != VisualStudioFolders.end(); ++iter)
-    {
+  for (std::map<std::string, std::set<std::string> >::iterator iter =
+         VisualStudioFolders.begin();
+       iter != VisualStudioFolders.end(); ++iter) {
     std::string key(iter->first);
     std::string guidParent(this->GetGUID(key.c_str()));
 
-    for(std::set<std::string>::iterator it = iter->second.begin();
-        it != iter->second.end(); ++it)
-      {
+    for (std::set<std::string>::iterator it = iter->second.begin();
+         it != iter->second.end(); ++it) {
       std::string value(*it);
       std::string guid(this->GetGUID(value.c_str()));
 
       fout << "\t\t{" << guid << "} = {" << guidParent << "}\n";
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
+std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(
+  const char* path)
 {
   // Convert to backslashes.  Do not use ConvertToOutputPath because
   // we will add quoting ourselves, and we know these projects always
   // use windows slashes.
   std::string d = path;
   std::string::size_type pos = 0;
-  while((pos = d.find('/', pos)) != d.npos)
-    {
+  while ((pos = d.find('/', pos)) != d.npos) {
     d[pos++] = '\\';
-    }
+  }
   return d;
 }
 
-// Write a dsp file into the SLN file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
-                               const std::string& dspname,
-                               const char* dir,
-                               cmGeneratorTarget const* target)
-{
-   // check to see if this is a fortran build
-  const char* ext = ".vcproj";
-  const char* project =
-    "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"";
-  if(this->TargetIsFortranOnly(target))
-    {
-    ext = ".vfproj";
-    project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
-    }
-
-  fout << project
-       << dspname << "\", \""
-       << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"")
-       << dspname << ext << "\", \"{"
-       << this->GetGUID(dspname) << "}\"\nEndProject\n";
-
-  UtilityDependsMap::iterator ui = this->UtilityDepends.find(target);
-  if(ui != this->UtilityDepends.end())
-    {
-    const char* uname = ui->second.c_str();
-    fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
-         << uname << "\", \""
-         << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"")
-         << uname << ".vcproj" << "\", \"{"
-         << this->GetGUID(uname) << "}\"\n"
-         << "EndProject\n";
-    }
-}
-
-
-
-// Write a dsp file into the SLN file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void
-cmGlobalVisualStudio7Generator
-::WriteProjectDepends(std::ostream& fout,
-                      const std::string& dspname,
-                      const char*, cmGeneratorTarget const* target)
-{
-  int depcount = 0;
-  std::string dspguid = this->GetGUID(dspname);
-  VSDependSet const& depends = this->VSTargetDepends[target];
-  for(VSDependSet::const_iterator di = depends.begin();
-      di != depends.end(); ++di)
-    {
-    const char* name = di->c_str();
-    std::string guid = this->GetGUID(name);
-    if(guid.empty())
-      {
-      std::string m = "Target: ";
-      m += target->GetName();
-      m += " depends on unknown target: ";
-      m += name;
-      cmSystemTools::Error(m.c_str());
-      }
-    fout << "\t\t{" << dspguid << "}." << depcount << " = {" << guid << "}\n";
-    depcount++;
-    }
-
-  UtilityDependsMap::iterator ui = this->UtilityDepends.find(target);
-  if(ui != this->UtilityDepends.end())
-    {
-    const char* uname = ui->second.c_str();
-    fout << "\t\t{" << this->GetGUID(uname) << "}.0 = {" << dspguid << "}\n";
-    }
-}
-
-
-// Write a dsp file into the SLN file, Note, that dependencies from
-// executables to the libraries it uses are also done here
-void cmGlobalVisualStudio7Generator
-::WriteProjectConfigurations(
-  std::ostream& fout, const std::string& name, cmState::TargetType,
-  std::vector<std::string> const& configs,
-  const std::set<std::string>& configsPartOfDefaultBuild,
-  const std::string& platformMapping)
-{
-  const std::string& platformName =
-    !platformMapping.empty() ? platformMapping : this->GetPlatformName();
-  std::string guid = this->GetGUID(name);
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
-    fout << "\t\t{" << guid << "}." << *i
-         << ".ActiveCfg = " << *i << "|" << platformName << "\n";
-      std::set<std::string>::const_iterator
-        ci = configsPartOfDefaultBuild.find(*i);
-      if(!(ci == configsPartOfDefaultBuild.end()))
-      {
-      fout << "\t\t{" << guid << "}." << *i
-           << ".Build.0 = " << *i << "|" << platformName << "\n";
-      }
-    }
-}
-
-
-
-// Write a dsp file into the SLN file,
-// Note, that dependencies from executables to
-// the libraries it uses are also done here
-void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
-                               const std::string& name,
-                               const char* location,
-                               const char* typeGuid,
-                               const std::set<std::string>&)
-{
-  fout << "Project("
-       << "\"{"
-       << (typeGuid ? typeGuid : this->ExternalProjectType(location))
-       << "}\") = \""
-       << name << "\", \""
-       << this->ConvertToSolutionPath(location) << "\", \"{"
-       << this->GetGUID(name)
-       << "}\"\n";
-  fout << "EndProject\n";
-}
-
-
-
-void cmGlobalVisualStudio7Generator
-::WriteSLNGlobalSections(std::ostream& fout,
-                         cmLocalGenerator* root)
+void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
+  std::ostream& fout, cmLocalGenerator* root)
 {
   bool extensibilityGlobalsOverridden = false;
   bool extensibilityAddInsOverridden = false;
   const std::vector<std::string> propKeys =
-      root->GetMakefile()->GetPropertyKeys();
-  for(std::vector<std::string>::const_iterator it = propKeys.begin();
-      it != propKeys.end(); ++it)
-    {
-    if(it->find("VS_GLOBAL_SECTION_") == 0)
-      {
+    root->GetMakefile()->GetPropertyKeys();
+  for (std::vector<std::string>::const_iterator it = propKeys.begin();
+       it != propKeys.end(); ++it) {
+    if (it->find("VS_GLOBAL_SECTION_") == 0) {
       std::string sectionType;
       std::string name = it->substr(18);
-      if(name.find("PRE_") == 0)
-        {
+      if (name.find("PRE_") == 0) {
         name = name.substr(4);
         sectionType = "preSolution";
-        }
-      else if(name.find("POST_") == 0)
-        {
+      } else if (name.find("POST_") == 0) {
         name = name.substr(5);
         sectionType = "postSolution";
-        }
-      else
+      } else
         continue;
-      if(!name.empty())
-        {
-        if(name == "ExtensibilityGlobals" && sectionType == "postSolution")
+      if (!name.empty()) {
+        if (name == "ExtensibilityGlobals" && sectionType == "postSolution")
           extensibilityGlobalsOverridden = true;
-        else if(name == "ExtensibilityAddIns" && sectionType == "postSolution")
+        else if (name == "ExtensibilityAddIns" &&
+                 sectionType == "postSolution")
           extensibilityAddInsOverridden = true;
         fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
         std::vector<std::string> keyValuePairs;
         cmSystemTools::ExpandListArgument(
-              root->GetMakefile()->GetProperty(it->c_str()),
-              keyValuePairs);
-        for(std::vector<std::string>::const_iterator itPair =
-            keyValuePairs.begin(); itPair != keyValuePairs.end(); ++itPair)
-          {
+          root->GetMakefile()->GetProperty(it->c_str()), keyValuePairs);
+        for (std::vector<std::string>::const_iterator itPair =
+               keyValuePairs.begin();
+             itPair != keyValuePairs.end(); ++itPair) {
           const std::string::size_type posEqual = itPair->find('=');
-          if(posEqual != std::string::npos)
-            {
+          if (posEqual != std::string::npos) {
             const std::string key =
               cmSystemTools::TrimWhitespace(itPair->substr(0, posEqual));
             const std::string value =
               cmSystemTools::TrimWhitespace(itPair->substr(posEqual + 1));
             fout << "\t\t" << key << " = " << value << "\n";
-            }
           }
-        fout << "\tEndGlobalSection\n";
         }
+        fout << "\tEndGlobalSection\n";
       }
     }
-  if(!extensibilityGlobalsOverridden)
+  }
+  if (!extensibilityGlobalsOverridden)
     fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
          << "\tEndGlobalSection\n";
-  if(!extensibilityAddInsOverridden)
+  if (!extensibilityAddInsOverridden)
     fout << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
          << "\tEndGlobalSection\n";
 }
 
-
-
 // Standard end of dsw file
 void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
 {
   fout << "EndGlobal\n";
 }
 
-
-// ouput standard header for dsw file
-void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
-{
-  fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
-}
-
-//----------------------------------------------------------------------------
-std::string
-cmGlobalVisualStudio7Generator::WriteUtilityDepend(
-        cmGeneratorTarget const* target)
+std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
+  cmGeneratorTarget const* target)
 {
   std::vector<std::string> configs;
   target->Target->GetMakefile()->GetConfigurations(configs);
@@ -903,6 +576,7 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(
   fout.SetCopyIfDifferent(true);
   std::string guid = this->GetGUID(pname.c_str());
 
+  /* clang-format off */
   fout <<
     "<?xml version=\"1.0\" encoding = \""
     << this->Encoding() << "\"?>\n"
@@ -915,9 +589,10 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(
     "\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n"
     "\t<Configurations>\n"
     ;
-  for(std::vector<std::string>::iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
+  /* clang-format on */
+  for (std::vector<std::string>::iterator i = configs.begin();
+       i != configs.end(); ++i) {
+    /* clang-format off */
     fout <<
       "\t\t<Configuration\n"
       "\t\t\tName=\"" << *i << "|Win32\"\n"
@@ -929,30 +604,30 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(
       "\t\t\tCharacterSet=\"2\">\n"
       "\t\t</Configuration>\n"
       ;
-    }
+    /* clang-format on */
+  }
+  /* clang-format off */
   fout <<
     "\t</Configurations>\n"
     "\t<Files></Files>\n"
     "\t<Globals></Globals>\n"
     "</VisualStudioProject>\n"
     ;
+  /* clang-format on */
 
-  if(fout.Close())
-    {
+  if (fout.Close()) {
     this->FileReplacedDuringGenerate(fname);
-    }
+  }
   return pname;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
 {
   std::string const& guidStoreName = name + "_GUID_CMAKE";
   if (const char* storedGUID =
-      this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()))
-    {
+        this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str())) {
     return std::string(storedGUID);
-    }
+  }
   // Compute a GUID that is deterministic but unique to the build tree.
   std::string input = this->CMakeInstance->GetState()->GetBinaryDirectory();
   input += "|";
@@ -961,40 +636,26 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
   cmUuid uuidGenerator;
 
   std::vector<unsigned char> uuidNamespace;
-  uuidGenerator.StringToBinary(
-    "ee30c4be-5192-4fb0-b335-722a2dffe760", uuidNamespace);
+  uuidGenerator.StringToBinary("ee30c4be-5192-4fb0-b335-722a2dffe760",
+                               uuidNamespace);
 
   std::string guid = uuidGenerator.FromMd5(uuidNamespace, input);
 
   return cmSystemTools::UpperCase(guid);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio7Generator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalVisualStudio7Generator::AppendDirectoryForConfig(
+  const std::string& prefix, const std::string& config,
+  const std::string& suffix, std::string& dir)
 {
-  entry.Name = cmGlobalVisualStudio7Generator::GetActualName();
-  entry.Brief = "Deprecated. Generates Visual Studio .NET 2002 project files.";
-}
-
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio7Generator
-::AppendDirectoryForConfig(const std::string& prefix,
-                           const std::string& config,
-                           const std::string& suffix,
-                           std::string& dir)
-{
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     dir += prefix;
     dir += config;
     dir += suffix;
-    }
+  }
 }
 
-std::set<std::string>
-cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
+std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
   std::vector<std::string> const& configs,
   OrderedTargetDependSet const& projectTargets,
   cmGeneratorTarget const* target)
@@ -1003,61 +664,52 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
   // if it is a utilitiy target then only make it part of the
   // default build if another target depends on it
   int type = target->GetType();
-  if (type == cmState::GLOBAL_TARGET)
-    {
+  if (type == cmState::GLOBAL_TARGET) {
     // check if INSTALL target is part of default build
-    if(target->GetName() == "INSTALL")
-      {
+    if (target->GetName() == "INSTALL") {
       // inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties
-      for(std::vector<std::string>::const_iterator i = configs.begin();
-          i != configs.end(); ++i)
-        {
-        const char* propertyValue = target->Target->GetMakefile()
-          ->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
+      for (std::vector<std::string>::const_iterator i = configs.begin();
+           i != configs.end(); ++i) {
+        const char* propertyValue =
+          target->Target->GetMakefile()->GetDefinition(
+            "CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
         cmGeneratorExpression ge;
-        cmsys::auto_ptr<cmCompiledGeneratorExpression>
-          cge = ge.Parse(propertyValue);
-        if(cmSystemTools::IsOn(cge->Evaluate(target->GetLocalGenerator(),
-                                             *i)))
-          {
+        cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+          ge.Parse(propertyValue);
+        if (cmSystemTools::IsOn(
+              cge->Evaluate(target->GetLocalGenerator(), *i))) {
           activeConfigs.insert(*i);
-          }
         }
       }
-    return activeConfigs;
     }
-  if(type == cmState::UTILITY && !this->IsDependedOn(projectTargets, target))
-    {
     return activeConfigs;
-    }
+  }
+  if (type == cmState::UTILITY &&
+      !this->IsDependedOn(projectTargets, target)) {
+    return activeConfigs;
+  }
   // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = configs.begin();
+       i != configs.end(); ++i) {
     const char* propertyValue =
       target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
-    if(cmSystemTools::IsOff(propertyValue))
-      {
+    if (cmSystemTools::IsOff(propertyValue)) {
       activeConfigs.insert(*i);
-      }
     }
+  }
   return activeConfigs;
 }
 
-bool
-cmGlobalVisualStudio7Generator
-::IsDependedOn(OrderedTargetDependSet const& projectTargets,
-               cmGeneratorTarget const* gtIn)
+bool cmGlobalVisualStudio7Generator::IsDependedOn(
+  OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn)
 {
   for (OrderedTargetDependSet::const_iterator l = projectTargets.begin();
-       l != projectTargets.end(); ++l)
-    {
+       l != projectTargets.end(); ++l) {
     TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(*l);
-    if(tgtdeps.count(gtIn))
-      {
+    if (tgtdeps.count(gtIn)) {
       return true;
-      }
     }
+  }
   return false;
 }
 
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index de2d35e..2092343 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -13,6 +13,7 @@
 #define cmGlobalVisualStudio7Generator_h
 
 #include "cmGlobalVisualStudioGenerator.h"
+
 #include "cmGlobalGeneratorFactory.h"
 
 class cmTarget;
@@ -30,28 +31,16 @@ public:
                                  const std::string& platformName = "");
   ~cmGlobalVisualStudio7Generator();
 
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalVisualStudio7Generator>(); }
-
-  ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalVisualStudio7Generator::GetActualName();}
-  static std::string GetActualName() {return "Visual Studio 7";}
-
   ///! Get the name for the platform.
   std::string const& GetPlatformName() const;
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
 
   virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
 
-  /** Get the documentation entry for this generator.  */
-  static void GetDocumentation(cmDocumentationEntry& entry);
-
   /**
    * Utilized by the generator factory to determine if this generator
    * supports toolsets.
@@ -62,23 +51,19 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 
   /**
    * Try running cmake and building a file. This is used for dynamically
    * loaded commands, not as part of the usual build process.
    */
   virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
-    const std::string& projectName,
-    const std::string& projectDir,
-    const std::string& targetName,
-    const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    std::vector<std::string> const& makeOptions = std::vector<std::string>());
 
   /**
    * Generate the DSW workspace file.
@@ -96,12 +81,16 @@ public:
 
   ///! What is the configurations directory variable called?
   virtual const char* GetCMakeCFGIntDir() const
-    { return "$(ConfigurationName)"; }
+  {
+    return "$(ConfigurationName)";
+  }
 
   /** Return true if the target project file should have the option
       LinkLibraryDependencies and link to .sln dependencies. */
   virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
-  { return false; }
+  {
+    return false;
+  }
 
   const char* GetIntelProjectVersion();
 
@@ -117,7 +106,7 @@ public:
 
 protected:
   virtual void Generate();
-  virtual const char* GetIDEVersion() { return "7.0"; }
+  virtual const char* GetIDEVersion() = 0;
 
   std::string const& GetDevEnvCommand();
   virtual std::string FindDevEnvCommand();
@@ -127,56 +116,49 @@ protected:
   virtual void OutputSLNFile(cmLocalGenerator* root,
                              std::vector<cmLocalGenerator*>& generators);
   virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
-                            std::vector<cmLocalGenerator*>& generators);
-  virtual void WriteProject(std::ostream& fout,
-                            const std::string& name, const char* path,
-                            const cmGeneratorTarget *t);
-  virtual void WriteProjectDepends(std::ostream& fout,
-                           const std::string& name, const char* path,
-                           cmGeneratorTarget const* t);
+                            std::vector<cmLocalGenerator*>& generators) = 0;
+  virtual void WriteProject(std::ostream& fout, const std::string& name,
+                            const char* path, const cmGeneratorTarget* t) = 0;
+  virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
+                                   const char* path,
+                                   cmGeneratorTarget const* t) = 0;
   virtual void WriteProjectConfigurations(
     std::ostream& fout, const std::string& name, cmState::TargetType type,
     std::vector<std::string> const& configs,
     const std::set<std::string>& configsPartOfDefaultBuild,
-    const std::string& platformMapping = "");
+    const std::string& platformMapping = "") = 0;
   virtual void WriteSLNGlobalSections(std::ostream& fout,
                                       cmLocalGenerator* root);
   virtual void WriteSLNFooter(std::ostream& fout);
-  virtual void WriteSLNHeader(std::ostream& fout);
-  virtual std::string WriteUtilityDepend(const cmGeneratorTarget *target);
+  virtual void WriteSLNHeader(std::ostream& fout) = 0;
+  virtual std::string WriteUtilityDepend(const cmGeneratorTarget* target);
 
   virtual void WriteTargetsToSolution(
-    std::ostream& fout,
-    cmLocalGenerator* root,
+    std::ostream& fout, cmLocalGenerator* root,
     OrderedTargetDependSet const& projectTargets);
   virtual void WriteTargetDepends(
-    std::ostream& fout,
-    OrderedTargetDependSet const& projectTargets);
+    std::ostream& fout, OrderedTargetDependSet const& projectTargets);
   virtual void WriteTargetConfigurations(
-    std::ostream& fout,
-    std::vector<std::string> const& configs,
+    std::ostream& fout, std::vector<std::string> const& configs,
     OrderedTargetDependSet const& projectTargets);
 
-  virtual void WriteExternalProject(std::ostream& fout,
-                                    const std::string& name,
-                                    const char* path,
-                                    const char* typeGuid,
-                                    const std::set<std::string>&
-                                    dependencies);
+  virtual void WriteExternalProject(
+    std::ostream& fout, const std::string& name, const char* path,
+    const char* typeGuid, const std::set<std::string>& dependencies) = 0;
 
   std::string ConvertToSolutionPath(const char* path);
 
-  std::set<std::string>
-    IsPartOfDefaultBuild(std::vector<std::string> const& configs,
-                         OrderedTargetDependSet const& projectTargets,
-                         cmGeneratorTarget const* target);
+  std::set<std::string> IsPartOfDefaultBuild(
+    std::vector<std::string> const& configs,
+    OrderedTargetDependSet const& projectTargets,
+    cmGeneratorTarget const* target);
   bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
                     cmGeneratorTarget const* target);
   std::map<std::string, std::string> GUIDMap;
 
   virtual void WriteFolders(std::ostream& fout);
   virtual void WriteFoldersContent(std::ostream& fout);
-  std::map<std::string,std::set<std::string> > VisualStudioFolders;
+  std::map<std::string, std::set<std::string> > VisualStudioFolders;
 
   // Set during OutputSLNFile with the name of the current project.
   // There is one SLN file per project.
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 3abff6c..dfe196a 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -10,164 +10,150 @@
   See the License for more information.
 ============================================================================*/
 #include "windows.h" // this must be first to define GetCurrentDirectory
+
 #include "cmGlobalVisualStudio8Generator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmLocalVisualStudio7Generator.h"
 #include "cmMakefile.h"
+#include "cmSourceFile.h"
 #include "cmVisualStudioWCEPlatformParser.h"
 #include "cmake.h"
-#include "cmGeneratedFileStream.h"
-#include "cmSourceFile.h"
 
 static const char vs8generatorName[] = "Visual Studio 8 2005";
 
-class cmGlobalVisualStudio8Generator::Factory
-  : public cmGlobalGeneratorFactory
+class cmGlobalVisualStudio8Generator::Factory : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const {
-    if(strncmp(name.c_str(), vs8generatorName,
-               sizeof(vs8generatorName) - 1) != 0)
-      {
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
+    if (strncmp(name.c_str(), vs8generatorName,
+                sizeof(vs8generatorName) - 1) != 0) {
       return 0;
-      }
+    }
 
     const char* p = name.c_str() + sizeof(vs8generatorName) - 1;
-    if(p[0] == '\0')
-      {
+    if (p[0] == '\0') {
       return new cmGlobalVisualStudio8Generator(cm, name, "");
-      }
+    }
 
-    if(p[0] != ' ')
-      {
+    if (p[0] != ' ') {
       return 0;
-      }
+    }
 
     ++p;
 
-    if(!strcmp(p, "Win64"))
-      {
+    if (!strcmp(p, "Win64")) {
       return new cmGlobalVisualStudio8Generator(cm, name, "x64");
-      }
+    }
 
     cmVisualStudioWCEPlatformParser parser(p);
     parser.ParseVersion("8.0");
-    if (!parser.Found())
-      {
+    if (!parser.Found()) {
       return 0;
-      }
+    }
 
     cmGlobalVisualStudio8Generator* ret =
-        new cmGlobalVisualStudio8Generator(cm, name, p);
+      new cmGlobalVisualStudio8Generator(cm, name, p);
     ret->WindowsCEVersion = parser.GetOSVersion();
     return ret;
   }
 
-  virtual void GetDocumentation(cmDocumentationEntry& entry) const {
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const
+  {
     entry.Name = std::string(vs8generatorName) + " [arch]";
-    entry.Brief =
-      "Generates Visual Studio 2005 project files.  "
-      "Optional [arch] can be \"Win64\"."
-      ;
+    entry.Brief = "Generates Visual Studio 2005 project files.  "
+                  "Optional [arch] can be \"Win64\".";
   }
 
-  virtual void GetGenerators(std::vector<std::string>& names) const {
+  virtual void GetGenerators(std::vector<std::string>& names) const
+  {
     names.push_back(vs8generatorName);
     names.push_back(vs8generatorName + std::string(" Win64"));
     cmVisualStudioWCEPlatformParser parser;
     parser.ParseVersion("8.0");
     const std::vector<std::string>& availablePlatforms =
       parser.GetAvailablePlatforms();
-    for(std::vector<std::string>::const_iterator i =
-        availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i =
+           availablePlatforms.begin();
+         i != availablePlatforms.end(); ++i) {
       names.push_back("Visual Studio 8 2005 " + *i);
-      }
+    }
   }
 
   virtual bool SupportsToolset() const { return false; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(cmake* cm,
-  const std::string& name, const std::string& platformName)
+cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
+  cmake* cm, const std::string& name, const std::string& platformName)
   : cmGlobalVisualStudio71Generator(cm, platformName)
 {
   this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
   this->Name = name;
   this->ExtraFlagTable = this->GetExtraFlagTableVS8();
   this->Version = VS8;
+  std::string vc8Express;
+  this->ExpressEdition = cmSystemTools::ReadRegistryValue(
+    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\8.0\\Setup\\VC;"
+    "ProductDir",
+    vc8Express, cmSystemTools::KeyWOW64_32);
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand()
 {
   // First look for VCExpress.
   std::string vsxcmd;
-  std::string vsxkey =
-    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\";
+  std::string vsxkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\";
   vsxkey += this->GetIDEVersion();
   vsxkey += ";InstallDir";
-  if(cmSystemTools::ReadRegistryValue(vsxkey.c_str(), vsxcmd,
-                                      cmSystemTools::KeyWOW64_32))
-    {
+  if (cmSystemTools::ReadRegistryValue(vsxkey.c_str(), vsxcmd,
+                                       cmSystemTools::KeyWOW64_32)) {
     cmSystemTools::ConvertToUnixSlashes(vsxcmd);
     vsxcmd += "/VCExpress.exe";
     return vsxcmd;
-    }
+  }
   // Now look for devenv.
   return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand();
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio8Generator
-::EnableLanguage(std::vector<std::string>const &  lang,
-                 cmMakefile *mf, bool optional)
+void cmGlobalVisualStudio8Generator::EnableLanguage(
+  std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
 {
-  for(std::vector<std::string>::const_iterator it = lang.begin();
-      it != lang.end(); ++it)
-    {
-    if(*it == "ASM_MASM")
-      {
+  for (std::vector<std::string>::const_iterator it = lang.begin();
+       it != lang.end(); ++it) {
+    if (*it == "ASM_MASM") {
       this->MasmEnabled = true;
-      }
     }
+  }
   this->AddPlatformDefinitions(mf);
   cmGlobalVisualStudio7Generator::EnableLanguage(lang, mf, optional);
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
 {
-  if(this->TargetsWindowsCE())
-  {
+  if (this->TargetsWindowsCE()) {
     mf->AddDefinition("CMAKE_VS_WINCE_VERSION",
-      this->WindowsCEVersion.c_str());
+                      this->WindowsCEVersion.c_str());
   }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p,
                                                           cmMakefile* mf)
 {
-  if(this->DefaultPlatformName == "Win32")
-    {
+  if (this->DefaultPlatformName == "Win32") {
     this->GeneratorPlatform = p;
     return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf);
-    }
-  else
-    {
+  } else {
     return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform(p, mf);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 // ouput standard header for dsw file
 void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
 {
@@ -175,21 +161,23 @@ void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
   fout << "# Visual Studio 2005\n";
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudio8Generator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalVisualStudio8Generator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalVisualStudio8Generator::GetActualName();
   entry.Brief = "Generates Visual Studio 8 2005 project files.";
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::Configure()
 {
   this->cmGlobalVisualStudio7Generator::Configure();
 }
 
-//----------------------------------------------------------------------------
+bool cmGlobalVisualStudio8Generator::UseFolderProperty()
+{
+  return IsExpressEdition() ? false : cmGlobalGenerator::UseFolderProperty();
+}
+
 std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
 {
   // Some VS8 sp0 versions cannot run macros.
@@ -202,38 +190,34 @@ std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
     "InstalledProducts\\KB926748;";
   std::string vc8sp1;
   if (!cmSystemTools::ReadRegistryValue(vc8sp1Registry, vc8sp1) &&
-      !cmSystemTools::ReadRegistryValue(vc8exSP1Registry, vc8sp1))
-    {
+      !cmSystemTools::ReadRegistryValue(vc8exSP1Registry, vc8sp1)) {
     return "";
-    }
+  }
 
   std::string base;
   std::string path;
 
   // base begins with the VisualStudioProjectsLocation reg value...
   if (cmSystemTools::ReadRegistryValue(
-    "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\8.0;"
-    "VisualStudioProjectsLocation",
-    base))
-    {
+        "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\8.0;"
+        "VisualStudioProjectsLocation",
+        base)) {
     cmSystemTools::ConvertToUnixSlashes(base);
 
     // 8.0 macros folder:
     path = base + "/VSMacros80";
-    }
+  }
 
   // path is (correctly) still empty if we did not read the base value from
   // the Registry value
   return path;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase()
 {
   return "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros";
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio8Generator::AddCheckTarget()
 {
   // Add a special target on which all other targets depend that
@@ -246,197 +230,170 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
   cmMakefile* mf = lg->GetMakefile();
 
   // Skip the target if no regeneration is to be done.
-  if(mf->IsOn("CMAKE_SUPPRESS_REGENERATION"))
-    {
+  if (mf->IsOn("CMAKE_SUPPRESS_REGENERATION")) {
     return false;
-    }
+  }
 
   cmCustomCommandLines noCommandLines;
   cmTarget* tgt =
     mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
-                          no_working_directory, no_depends,
-                          noCommandLines);
+                          no_working_directory, no_depends, noCommandLines);
 
   cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
   lg->AddGeneratorTarget(gt);
 
   // Organize in the "predefined targets" folder:
   //
-  if (this->UseFolderProperty())
-    {
+  if (this->UseFolderProperty()) {
     tgt->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
-    }
+  }
 
   // Create a list of all stamp files for this project.
   std::vector<std::string> stamps;
   std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash();
   stampList += "generate.stamp.list";
   {
-  std::string stampListFile =
-    generators[0]->GetMakefile()->GetCurrentBinaryDirectory();
-  stampListFile += "/";
-  stampListFile += stampList;
-  std::string stampFile;
-  cmGeneratedFileStream fout(stampListFile.c_str());
-  for(std::vector<cmLocalGenerator*>::const_iterator
-        gi = generators.begin(); gi != generators.end(); ++gi)
-    {
-    stampFile = (*gi)->GetMakefile()->GetCurrentBinaryDirectory();
-    stampFile += "/";
-    stampFile += cmake::GetCMakeFilesDirectoryPostSlash();
-    stampFile += "generate.stamp";
-    fout << stampFile << "\n";
-    stamps.push_back(stampFile);
+    std::string stampListFile =
+      generators[0]->GetMakefile()->GetCurrentBinaryDirectory();
+    stampListFile += "/";
+    stampListFile += stampList;
+    std::string stampFile;
+    cmGeneratedFileStream fout(stampListFile.c_str());
+    for (std::vector<cmLocalGenerator*>::const_iterator gi =
+           generators.begin();
+         gi != generators.end(); ++gi) {
+      stampFile = (*gi)->GetMakefile()->GetCurrentBinaryDirectory();
+      stampFile += "/";
+      stampFile += cmake::GetCMakeFilesDirectoryPostSlash();
+      stampFile += "generate.stamp";
+      fout << stampFile << "\n";
+      stamps.push_back(stampFile);
     }
   }
 
   // Add a custom rule to re-run CMake if any input files changed.
   {
-  // Collect the input files used to generate all targets in this
-  // project.
-  std::vector<std::string> listFiles;
-  for(unsigned int j = 0; j < generators.size(); ++j)
-    {
-    cmMakefile* lmf = generators[j]->GetMakefile();
-    listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(),
-                     lmf->GetListFiles().end());
-    }
-  // Sort the list of input files and remove duplicates.
-  std::sort(listFiles.begin(), listFiles.end(),
-            std::less<std::string>());
-  std::vector<std::string>::iterator new_end =
-    std::unique(listFiles.begin(), listFiles.end());
-  listFiles.erase(new_end, listFiles.end());
-
-  // Create a rule to re-run CMake.
-  std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
-  stampName += "generate.stamp";
-  cmCustomCommandLine commandLine;
-  commandLine.push_back(cmSystemTools::GetCMakeCommand());
-  std::string argH = "-H";
-  argH += lg->GetSourceDirectory();
-  commandLine.push_back(argH);
-  std::string argB = "-B";
-  argB += lg->GetBinaryDirectory();
-  commandLine.push_back(argB);
-  commandLine.push_back("--check-stamp-list");
-  commandLine.push_back(stampList.c_str());
-  commandLine.push_back("--vs-solution-file");
-  commandLine.push_back("\"$(SolutionPath)\"");
-  cmCustomCommandLines commandLines;
-  commandLines.push_back(commandLine);
-
-  // Add the rule.  Note that we cannot use the CMakeLists.txt
-  // file as the main dependency because it would get
-  // overwritten by the CreateVCProjBuildRule.
-  // (this could be avoided with per-target source files)
-  std::string no_main_dependency = "";
-  std::vector<std::string> no_byproducts;
-  if(cmSourceFile* file =
-     mf->AddCustomCommandToOutput(
-       stamps, no_byproducts, listFiles,
-       no_main_dependency, commandLines, "Checking Build System",
-       no_working_directory, true))
-    {
-    gt->AddSource(file->GetFullPath());
+    // Collect the input files used to generate all targets in this
+    // project.
+    std::vector<std::string> listFiles;
+    for (unsigned int j = 0; j < generators.size(); ++j) {
+      cmMakefile* lmf = generators[j]->GetMakefile();
+      listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(),
+                       lmf->GetListFiles().end());
     }
-  else
-    {
-    cmSystemTools::Error("Error adding rule for ", stamps[0].c_str());
+    // Sort the list of input files and remove duplicates.
+    std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>());
+    std::vector<std::string>::iterator new_end =
+      std::unique(listFiles.begin(), listFiles.end());
+    listFiles.erase(new_end, listFiles.end());
+
+    // Create a rule to re-run CMake.
+    std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
+    stampName += "generate.stamp";
+    cmCustomCommandLine commandLine;
+    commandLine.push_back(cmSystemTools::GetCMakeCommand());
+    std::string argH = "-H";
+    argH += lg->GetSourceDirectory();
+    commandLine.push_back(argH);
+    std::string argB = "-B";
+    argB += lg->GetBinaryDirectory();
+    commandLine.push_back(argB);
+    commandLine.push_back("--check-stamp-list");
+    commandLine.push_back(stampList.c_str());
+    commandLine.push_back("--vs-solution-file");
+    commandLine.push_back("\"$(SolutionPath)\"");
+    cmCustomCommandLines commandLines;
+    commandLines.push_back(commandLine);
+
+    // Add the rule.  Note that we cannot use the CMakeLists.txt
+    // file as the main dependency because it would get
+    // overwritten by the CreateVCProjBuildRule.
+    // (this could be avoided with per-target source files)
+    std::string no_main_dependency = "";
+    std::vector<std::string> no_byproducts;
+    if (cmSourceFile* file = mf->AddCustomCommandToOutput(
+          stamps, no_byproducts, listFiles, no_main_dependency, commandLines,
+          "Checking Build System", no_working_directory, true)) {
+      gt->AddSource(file->GetFullPath());
+    } else {
+      cmSystemTools::Error("Error adding rule for ", stamps[0].c_str());
     }
   }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
 {
   cmGlobalVisualStudio7Generator::AddExtraIDETargets();
-  if(this->AddCheckTarget())
-    {
-    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-      {
+  if (this->AddCheckTarget()) {
+    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
       std::vector<cmGeneratorTarget*> tgts =
-          this->LocalGenerators[i]->GetGeneratorTargets();
+        this->LocalGenerators[i]->GetGeneratorTargets();
       // All targets depend on the build-system check target.
-      for(std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin();
-          ti != tgts.end(); ++ti)
-        {
-        if((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
-          {
+      for (std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin();
+           ti != tgts.end(); ++ti) {
+        if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
           (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
-          }
         }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio8Generator
-::WriteSolutionConfigurations(std::ostream& fout,
-                              std::vector<std::string> const& configs)
+void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations(
+  std::ostream& fout, std::vector<std::string> const& configs)
 {
   fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
-    fout << "\t\t" << *i << "|" << this->GetPlatformName()
-         << " = "  << *i << "|" << this->GetPlatformName() << "\n";
-    }
+  for (std::vector<std::string>::const_iterator i = configs.begin();
+       i != configs.end(); ++i) {
+    fout << "\t\t" << *i << "|" << this->GetPlatformName() << " = " << *i
+         << "|" << this->GetPlatformName() << "\n";
+  }
   fout << "\tEndGlobalSection\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudio8Generator
-::WriteProjectConfigurations(
+void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
   std::ostream& fout, const std::string& name, cmState::TargetType type,
   std::vector<std::string> const& configs,
   const std::set<std::string>& configsPartOfDefaultBuild,
   std::string const& platformMapping)
 {
   std::string guid = this->GetGUID(name);
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
-    fout << "\t\t{" << guid << "}." << *i
-         << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
-         << (!platformMapping.empty()?
-             platformMapping : this->GetPlatformName())
+  for (std::vector<std::string>::const_iterator i = configs.begin();
+       i != configs.end(); ++i) {
+    fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+         << ".ActiveCfg = " << *i << "|"
+         << (!platformMapping.empty() ? platformMapping
+                                      : this->GetPlatformName())
          << "\n";
-      std::set<std::string>::const_iterator
-        ci = configsPartOfDefaultBuild.find(*i);
-      if(!(ci == configsPartOfDefaultBuild.end()))
-      {
-      fout << "\t\t{" << guid << "}." << *i
-           << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"
-           << (!platformMapping.empty()?
-               platformMapping : this->GetPlatformName())
+    std::set<std::string>::const_iterator ci =
+      configsPartOfDefaultBuild.find(*i);
+    if (!(ci == configsPartOfDefaultBuild.end())) {
+      fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+           << ".Build.0 = " << *i << "|"
+           << (!platformMapping.empty() ? platformMapping
+                                        : this->GetPlatformName())
            << "\n";
-      }
-    if(this->NeedsDeploy(type))
-      {
-      fout << "\t\t{" << guid << "}." << *i
-           << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|"
-           << (!platformMapping.empty()?
-               platformMapping : this->GetPlatformName())
+    }
+    if (this->NeedsDeploy(type)) {
+      fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+           << ".Deploy.0 = " << *i << "|"
+           << (!platformMapping.empty() ? platformMapping
+                                        : this->GetPlatformName())
            << "\n";
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudio8Generator::NeedsDeploy(cmState::TargetType type) const
+bool cmGlobalVisualStudio8Generator::NeedsDeploy(
+  cmState::TargetType type) const
 {
-  bool needsDeploy = (type == cmState::EXECUTABLE ||
-                      type == cmState::SHARED_LIBRARY);
+  bool needsDeploy =
+    (type == cmState::EXECUTABLE || type == cmState::SHARED_LIBRARY);
   return this->TargetsWindowsCE() && needsDeploy;
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
 {
   // Skip over the cmGlobalVisualStudioGenerator implementation!
@@ -444,85 +401,76 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
   return this->cmGlobalGenerator::ComputeTargetDepends();
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::WriteProjectDepends(
   std::ostream& fout, const std::string&, const char*,
-        cmGeneratorTarget const* gt)
+  cmGeneratorTarget const* gt)
 {
   TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
   OrderedTargetDependSet depends(unordered, std::string());
-  for(OrderedTargetDependSet::const_iterator i = depends.begin();
-      i != depends.end(); ++i)
-    {
-    if((*i)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (OrderedTargetDependSet::const_iterator i = depends.begin();
+       i != depends.end(); ++i) {
+    if ((*i)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     std::string guid = this->GetGUID((*i)->GetName().c_str());
     fout << "\t\t{" << guid << "} = {" << guid << "}\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
-        cmGeneratorTarget *target)
+  cmGeneratorTarget* target)
 {
   // Look for utility dependencies that magically link.
-  for(std::set<std::string>::const_iterator ui =
-        target->GetUtilities().begin();
-      ui != target->GetUtilities().end(); ++ui)
-    {
-    if(cmGeneratorTarget* depTarget =
-        target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str()))
-      {
-      if(depTarget->GetType() != cmState::INTERFACE_LIBRARY
-          && depTarget->GetProperty("EXTERNAL_MSPROJECT"))
-        {
+  for (std::set<std::string>::const_iterator ui =
+         target->GetUtilities().begin();
+       ui != target->GetUtilities().end(); ++ui) {
+    if (cmGeneratorTarget* depTarget =
+          target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str())) {
+      if (depTarget->GetType() != cmState::INTERFACE_LIBRARY &&
+          depTarget->GetProperty("EXTERNAL_MSPROJECT")) {
         // This utility dependency names an external .vcproj target.
         // We use LinkLibraryDependencies="true" to link to it without
         // predicting the .lib file location or name.
         return true;
-        }
       }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
-static cmVS7FlagTable cmVS8ExtraFlagTable[] =
-{
-  {"CallingConvention", "Gd", "cdecl", "0", 0 },
-  {"CallingConvention", "Gr", "fastcall", "1", 0 },
-  {"CallingConvention", "Gz", "stdcall", "2", 0 },
-
-  {"Detect64BitPortabilityProblems", "Wp64",
-   "Detect 64Bit Portability Problems", "true", 0 },
-  {"ErrorReporting", "errorReport:prompt", "Report immediately", "1", 0 },
-  {"ErrorReporting", "errorReport:queue", "Queue for next login", "2", 0 },
+static cmVS7FlagTable cmVS8ExtraFlagTable[] = {
+  { "CallingConvention", "Gd", "cdecl", "0", 0 },
+  { "CallingConvention", "Gr", "fastcall", "1", 0 },
+  { "CallingConvention", "Gz", "stdcall", "2", 0 },
+
+  { "Detect64BitPortabilityProblems", "Wp64",
+    "Detect 64Bit Portability Problems", "true", 0 },
+  { "ErrorReporting", "errorReport:prompt", "Report immediately", "1", 0 },
+  { "ErrorReporting", "errorReport:queue", "Queue for next login", "2", 0 },
   // Precompiled header and related options.  Note that the
   // UsePrecompiledHeader entries are marked as "Continue" so that the
   // corresponding PrecompiledHeaderThrough entry can be found.
-  {"UsePrecompiledHeader", "Yu", "Use Precompiled Header", "2",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
-   cmVS7FlagTable::UserValueRequired},
+  { "UsePrecompiledHeader", "Yu", "Use Precompiled Header", "2",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
   // There is no YX option in the VS8 IDE.
 
   // Exception handling mode.  If no entries match, it will be FALSE.
-  {"ExceptionHandling", "GX", "enable c++ exceptions", "1", 0},
-  {"ExceptionHandling", "EHsc", "enable c++ exceptions", "1", 0},
-  {"ExceptionHandling", "EHa", "enable SEH exceptions", "2", 0},
+  { "ExceptionHandling", "GX", "enable c++ exceptions", "1", 0 },
+  { "ExceptionHandling", "EHsc", "enable c++ exceptions", "1", 0 },
+  { "ExceptionHandling", "EHa", "enable SEH exceptions", "2", 0 },
 
-  {"EnablePREfast", "analyze", "", "true", 0},
-  {"EnablePREfast", "analyze-", "", "false", 0},
+  { "EnablePREfast", "analyze", "", "true", 0 },
+  { "EnablePREfast", "analyze-", "", "false", 0 },
 
   // Language options
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t",
-   "wchar_t is a built-in type", "true", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-",
-   "wchar_t is not a built-in type", "false", 0},
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "wchar_t is a built-in type",
+    "true", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-",
+    "wchar_t is not a built-in type", "false", 0 },
 
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
 cmIDEFlagTable const* cmGlobalVisualStudio8Generator::GetExtraFlagTableVS8()
 {
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index b3093cc..b29106f 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -14,7 +14,6 @@
 
 #include "cmGlobalVisualStudio71Generator.h"
 
-
 /** \class cmGlobalVisualStudio8Generator
  * \brief Write a Unix makefiles.
  *
@@ -24,17 +23,17 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
 {
 public:
   cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
-    const std::string& platformName);
+                                 const std::string& platformName);
   static cmGlobalGeneratorFactory* NewFactory();
 
   ///! Get the name for the generator.
-  virtual std::string GetName() const {return this->Name;}
+  virtual std::string GetName() const { return this->Name; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
 
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
   virtual void AddPlatformDefinitions(cmMakefile* mf);
 
   virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
@@ -63,8 +62,13 @@ public:
   virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget* target);
 
   /** Return true if building for Windows CE */
-  virtual bool TargetsWindowsCE() const {
-    return !this->WindowsCEVersion.empty(); }
+  virtual bool TargetsWindowsCE() const
+  {
+    return !this->WindowsCEVersion.empty();
+  }
+
+  /** Is the installed VS an Express edition?  */
+  bool IsExpressEdition() const { return this->ExpressEdition; }
 
 protected:
   virtual void AddExtraIDETargets();
@@ -89,13 +93,15 @@ protected:
     const std::set<std::string>& configsPartOfDefaultBuild,
     const std::string& platformMapping = "");
   virtual bool ComputeTargetDepends();
-  virtual void WriteProjectDepends(std::ostream& fout,
-                                   const std::string& name,
+  virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
                                    const char* path,
-                                   const cmGeneratorTarget *t);
+                                   const cmGeneratorTarget* t);
+
+  bool UseFolderProperty();
 
   std::string Name;
   std::string WindowsCEVersion;
+  bool ExpressEdition;
 
 private:
   class Factory;
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 884f754..a47f4fc 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -10,7 +10,9 @@
   See the License for more information.
 ============================================================================*/
 #include "windows.h" // this must be first to define GetCurrentDirectory
+
 #include "cmGlobalVisualStudio9Generator.h"
+
 #include "cmLocalVisualStudio7Generator.h"
 #include "cmMakefile.h"
 #include "cmVisualStudioWCEPlatformParser.h"
@@ -18,63 +20,57 @@
 
 static const char vs9generatorName[] = "Visual Studio 9 2008";
 
-class cmGlobalVisualStudio9Generator::Factory
-  : public cmGlobalGeneratorFactory
+class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const {
-    if(strncmp(name.c_str(), vs9generatorName,
-               sizeof(vs9generatorName) - 1) != 0)
-      {
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const
+  {
+    if (strncmp(name.c_str(), vs9generatorName,
+                sizeof(vs9generatorName) - 1) != 0) {
       return 0;
-      }
+    }
 
     const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
-    if(p[0] == '\0')
-      {
+    if (p[0] == '\0') {
       return new cmGlobalVisualStudio9Generator(cm, name, "");
-      }
+    }
 
-    if(p[0] != ' ')
-      {
+    if (p[0] != ' ') {
       return 0;
-      }
+    }
 
     ++p;
 
-    if(!strcmp(p, "IA64"))
-      {
+    if (!strcmp(p, "IA64")) {
       return new cmGlobalVisualStudio9Generator(cm, name, "Itanium");
-      }
+    }
 
-    if(!strcmp(p, "Win64"))
-      {
+    if (!strcmp(p, "Win64")) {
       return new cmGlobalVisualStudio9Generator(cm, name, "x64");
-      }
+    }
 
     cmVisualStudioWCEPlatformParser parser(p);
     parser.ParseVersion("9.0");
-    if (!parser.Found())
-      {
+    if (!parser.Found()) {
       return 0;
-      }
+    }
 
     cmGlobalVisualStudio9Generator* ret =
-        new cmGlobalVisualStudio9Generator(cm, name, p);
+      new cmGlobalVisualStudio9Generator(cm, name, p);
     ret->WindowsCEVersion = parser.GetOSVersion();
     return ret;
   }
 
-  virtual void GetDocumentation(cmDocumentationEntry& entry) const {
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const
+  {
     entry.Name = std::string(vs9generatorName) + " [arch]";
-    entry.Brief =
-      "Generates Visual Studio 2008 project files.  "
-      "Optional [arch] can be \"Win64\" or \"IA64\"."
-      ;
+    entry.Brief = "Generates Visual Studio 2008 project files.  "
+                  "Optional [arch] can be \"Win64\" or \"IA64\".";
   }
 
-  virtual void GetGenerators(std::vector<std::string>& names) const {
+  virtual void GetGenerators(std::vector<std::string>& names) const
+  {
     names.push_back(vs9generatorName);
     names.push_back(vs9generatorName + std::string(" Win64"));
     names.push_back(vs9generatorName + std::string(" IA64"));
@@ -82,38 +78,39 @@ public:
     parser.ParseVersion("9.0");
     const std::vector<std::string>& availablePlatforms =
       parser.GetAvailablePlatforms();
-    for(std::vector<std::string>::const_iterator i =
-        availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i =
+           availablePlatforms.begin();
+         i != availablePlatforms.end(); ++i) {
       names.push_back("Visual Studio 9 2008 " + *i);
-      }
+    }
   }
 
   virtual bool SupportsToolset() const { return false; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(cmake* cm,
-  const std::string& name, const std::string& platformName)
+cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
+  cmake* cm, const std::string& name, const std::string& platformName)
   : cmGlobalVisualStudio8Generator(cm, name, platformName)
 {
   this->Version = VS9;
+  std::string vc9Express;
+  this->ExpressEdition = cmSystemTools::ReadRegistryValue(
+    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC;"
+    "ProductDir",
+    vc9Express, cmSystemTools::KeyWOW64_32);
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
 {
   fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
   fout << "# Visual Studio 2008\n";
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
 {
   std::string base;
@@ -121,26 +118,24 @@ std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
 
   // base begins with the VisualStudioProjectsLocation reg value...
   if (cmSystemTools::ReadRegistryValue(
-    "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
-    "VisualStudioProjectsLocation",
-    base))
-    {
+        "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
+        "VisualStudioProjectsLocation",
+        base)) {
     cmSystemTools::ConvertToUnixSlashes(base);
 
     // 9.0 macros folder:
     path = base + "/VSMacros80";
-      // *NOT* a typo; right now in Visual Studio 2008 beta the macros
-      // folder is VSMacros80... They may change it to 90 before final
-      // release of 2008 or they may not... we'll have to keep our eyes
-      // on it
-    }
+    // *NOT* a typo; right now in Visual Studio 2008 beta the macros
+    // folder is VSMacros80... They may change it to 90 before final
+    // release of 2008 or they may not... we'll have to keep our eyes
+    // on it
+  }
 
   // path is (correctly) still empty if we did not read the base value from
   // the Registry value
   return path;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
 {
   return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h
index e25a4be..2c82c3a 100644
--- a/Source/cmGlobalVisualStudio9Generator.h
+++ b/Source/cmGlobalVisualStudio9Generator.h
@@ -14,18 +14,16 @@
 
 #include "cmGlobalVisualStudio8Generator.h"
 
-
 /** \class cmGlobalVisualStudio9Generator
  * \brief Write a Unix makefiles.
  *
  * cmGlobalVisualStudio9Generator manages UNIX build process for a tree
  */
-class cmGlobalVisualStudio9Generator :
-  public cmGlobalVisualStudio8Generator
+class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator
 {
 public:
   cmGlobalVisualStudio9Generator(cmake* cm, const std::string& name,
-    const std::string& platformName);
+                                 const std::string& platformName);
   static cmGlobalGeneratorFactory* NewFactory();
 
   /**
@@ -46,6 +44,7 @@ public:
    * Studio?
    */
   virtual std::string GetUserMacrosRegKeyBase();
+
 protected:
   virtual const char* GetIDEVersion() { return "9.0"; }
 private:
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 6a1aa29..1bec581 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -12,6 +12,7 @@
 ============================================================================*/
 #include "cmGlobalVisualStudioGenerator.h"
 
+#include "cmAlgorithms.h"
 #include "cmCallVisualStudioMacro.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
@@ -20,9 +21,7 @@
 #include "cmSourceFile.h"
 #include "cmTarget.h"
 #include <cmsys/Encoding.hxx>
-#include "cmAlgorithms.h"
 
-//----------------------------------------------------------------------------
 cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm)
   : cmGlobalGenerator(cm)
 {
@@ -30,40 +29,32 @@ cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm)
   cm->GetState()->SetWindowsVSIDE(true);
 }
 
-//----------------------------------------------------------------------------
 cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
 cmGlobalVisualStudioGenerator::VSVersion
 cmGlobalVisualStudioGenerator::GetVersion() const
 {
   return this->Version;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v)
 {
   this->Version = v;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudioGenerator::GetRegistryBase()
 {
-  return cmGlobalVisualStudioGenerator::GetRegistryBase(
-    this->GetIDEVersion());
+  return cmGlobalVisualStudioGenerator::GetRegistryBase(this->GetIDEVersion());
 }
 
-//----------------------------------------------------------------------------
-std::string cmGlobalVisualStudioGenerator::GetRegistryBase(
-  const char* version)
+std::string cmGlobalVisualStudioGenerator::GetRegistryBase(const char* version)
 {
   std::string key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\";
   return key + version;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
 {
   // Add a special target that depends on ALL projects for easy build
@@ -72,124 +63,96 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
   std::vector<std::string> no_depends;
   cmCustomCommandLines no_commands;
   std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
-  for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
-    {
+  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
     std::vector<cmLocalGenerator*>& gen = it->second;
     // add the ALL_BUILD to the first local generator of each project
-    if(!gen.empty())
-      {
+    if (!gen.empty()) {
       // Use no actual command lines so that the target itself is not
       // considered always out of date.
-      cmTarget* allBuild =
-        gen[0]->GetMakefile()->
-        AddUtilityCommand("ALL_BUILD", true, no_working_dir,
-                          no_depends, no_commands, false,
-                          "Build all projects");
+      cmTarget* allBuild = gen[0]->GetMakefile()->AddUtilityCommand(
+        "ALL_BUILD", true, no_working_dir, no_depends, no_commands, false,
+        "Build all projects");
 
       cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
       gen[0]->AddGeneratorTarget(gt);
 
-#if 0
-      // Can't activate this code because we want ALL_BUILD
-      // selected as the default "startup project" when first
-      // opened in Visual Studio... And if it's nested in a
-      // folder, then that doesn't happen.
       //
       // Organize in the "predefined targets" folder:
       //
-      if (this->UseFolderProperty())
-        {
+      if (this->UseFolderProperty()) {
         allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
-        }
-#endif
+      }
 
       // Now make all targets depend on the ALL_BUILD target
-      for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
-          i != gen.end(); ++i)
-        {
-        std::vector<cmGeneratorTarget*> targets =
-            (*i)->GetGeneratorTargets();
-        for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-            t != targets.end(); ++t)
-          {
+      for (std::vector<cmLocalGenerator*>::iterator i = gen.begin();
+           i != gen.end(); ++i) {
+        std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets();
+        for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+             t != targets.end(); ++t) {
           cmGeneratorTarget* tgt = *t;
-          if (tgt->GetType() == cmState::GLOBAL_TARGET
-              || tgt->IsImported())
-            {
+          if (tgt->GetType() == cmState::GLOBAL_TARGET || tgt->IsImported()) {
             continue;
-            }
-          if(!this->IsExcluded(gen[0], tgt))
-            {
+          }
+          if (!this->IsExcluded(gen[0], tgt)) {
             allBuild->AddUtility(tgt->GetName());
-            }
           }
         }
       }
     }
+  }
 
   // Configure CMake Visual Studio macros, for this user on this version
   // of Visual Studio.
   this->ConfigureCMakeVisualStudioMacros();
 
   // Add CMakeLists.txt with custom command to rerun CMake.
-  for(std::vector<cmLocalGenerator*>::const_iterator
-        lgi = this->LocalGenerators.begin();
-      lgi != this->LocalGenerators.end(); ++lgi)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator lgi =
+         this->LocalGenerators.begin();
+       lgi != this->LocalGenerators.end(); ++lgi) {
     cmLocalVisualStudioGenerator* lg =
       static_cast<cmLocalVisualStudioGenerator*>(*lgi);
     lg->AddCMakeListsRules();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalVisualStudioGenerator
-::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+void cmGlobalVisualStudioGenerator::ComputeTargetObjectDirectory(
+  cmGeneratorTarget* gt) const
 {
   std::string dir = gt->LocalGenerator->GetCurrentBinaryDirectory();
   dir += "/";
   std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(gt);
-  if(!tgtDir.empty())
-    {
+  if (!tgtDir.empty()) {
     dir += tgtDir;
     dir += "/";
-    }
+  }
   const char* cd = this->GetCMakeCFGIntDir();
-  if(cd && *cd)
-    {
+  if (cd && *cd) {
     dir += cd;
     dir += "/";
-    }
+  }
   gt->ObjectDirectory = dir;
 }
 
-//----------------------------------------------------------------------------
 bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
-  const std::string& regKeyBase,
-  std::string& nextAvailableSubKeyName);
+                                        const std::string& regKeyBase,
+                                        std::string& nextAvailableSubKeyName);
 
 void RegisterVisualStudioMacros(const std::string& macrosFile,
-  const std::string& regKeyBase);
+                                const std::string& regKeyBase);
 
-//----------------------------------------------------------------------------
-#define CMAKE_VSMACROS_FILENAME \
-  "CMakeVSMacros2.vsmacros"
+#define CMAKE_VSMACROS_FILENAME "CMakeVSMacros2.vsmacros"
 
-#define CMAKE_VSMACROS_RELOAD_MACRONAME \
+#define CMAKE_VSMACROS_RELOAD_MACRONAME                                       \
   "Macros.CMakeVSMacros2.Macros.ReloadProjects"
 
-#define CMAKE_VSMACROS_STOP_MACRONAME \
-  "Macros.CMakeVSMacros2.Macros.StopBuild"
+#define CMAKE_VSMACROS_STOP_MACRONAME "Macros.CMakeVSMacros2.Macros.StopBuild"
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
 {
-  cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
   std::string dir = this->GetUserMacrosDirectory();
 
-  if (dir != "")
-    {
-    std::string src = mf->GetRequiredDefinition("CMAKE_ROOT");
+  if (dir != "") {
+    std::string src = cmSystemTools::GetCMakeRoot();
     src += "/Templates/" CMAKE_VSMACROS_FILENAME;
 
     std::string dst = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
@@ -200,27 +163,22 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
     // purposes but newer versions distributed with CMake will replace
     // older versions in user directories.
     int res;
-    if(!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) ||
-       res > 0)
-      {
-      if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str()))
-        {
+    if (!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) ||
+        res > 0) {
+      if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str())) {
         std::ostringstream oss;
         oss << "Could not copy from: " << src << std::endl;
         oss << "                 to: " << dst << std::endl;
         cmSystemTools::Message(oss.str().c_str(), "Warning");
-        }
       }
+    }
 
     RegisterVisualStudioMacros(dst, this->GetUserMacrosRegKeyBase());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudioGenerator
-::CallVisualStudioMacro(MacroName m,
-                        const char* vsSolutionFile)
+void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
+  MacroName m, const char* vsSolutionFile)
 {
   // If any solution or project files changed during the generation,
   // tell Visual Studio to reload them...
@@ -233,173 +191,137 @@ cmGlobalVisualStudioGenerator
   //  - the CMake vsmacros file is registered
   //  - there were .sln/.vcproj files changed during generation
   //
-  if (dir != "")
-    {
+  if (dir != "") {
     std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
     std::string nextSubkeyName;
     if (cmSystemTools::FileExists(macrosFile.c_str()) &&
-      IsVisualStudioMacrosFileRegistered(macrosFile,
-        this->GetUserMacrosRegKeyBase(), nextSubkeyName)
-      )
-      {
+        IsVisualStudioMacrosFileRegistered(
+          macrosFile, this->GetUserMacrosRegKeyBase(), nextSubkeyName)) {
       std::string topLevelSlnName;
-      if(vsSolutionFile)
-        {
+      if (vsSolutionFile) {
         topLevelSlnName = vsSolutionFile;
-        }
-      else
-        {
+      } else {
         topLevelSlnName = mf->GetCurrentBinaryDirectory();
         topLevelSlnName += "/";
         topLevelSlnName += this->LocalGenerators[0]->GetProjectName();
         topLevelSlnName += ".sln";
-        }
+      }
 
-      if(m == MacroReload)
-        {
+      if (m == MacroReload) {
         std::vector<std::string> filenames;
         this->GetFilesReplacedDuringGenerate(filenames);
-        if (!filenames.empty())
-          {
+        if (!filenames.empty()) {
           // Convert vector to semi-colon delimited string of filenames:
           std::string projects;
           std::vector<std::string>::iterator it = filenames.begin();
-          if (it != filenames.end())
-            {
+          if (it != filenames.end()) {
             projects = *it;
             ++it;
-            }
-          for (; it != filenames.end(); ++it)
-            {
+          }
+          for (; it != filenames.end(); ++it) {
             projects += ";";
             projects += *it;
-            }
-          cmCallVisualStudioMacro::CallMacro(topLevelSlnName,
-            CMAKE_VSMACROS_RELOAD_MACRONAME, projects,
-            this->GetCMakeInstance()->GetDebugOutput());
           }
+          cmCallVisualStudioMacro::CallMacro(
+            topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects,
+            this->GetCMakeInstance()->GetDebugOutput());
         }
-      else if(m == MacroStop)
-        {
-        cmCallVisualStudioMacro::CallMacro(topLevelSlnName,
-          CMAKE_VSMACROS_STOP_MACRONAME, "",
+      } else if (m == MacroStop) {
+        cmCallVisualStudioMacro::CallMacro(
+          topLevelSlnName, CMAKE_VSMACROS_STOP_MACRONAME, "",
           this->GetCMakeInstance()->GetDebugOutput());
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudioGenerator::GetUserMacrosDirectory()
 {
   return "";
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
 {
   return "";
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::FillLinkClosure(
-        const cmGeneratorTarget *target,
-        TargetSet& linked)
+  const cmGeneratorTarget* target, TargetSet& linked)
 {
-  if(linked.insert(target).second)
-    {
-    TargetDependSet const& depends =
-            this->GetTargetDirectDepends(target);
-    for(TargetDependSet::const_iterator di = depends.begin();
-        di != depends.end(); ++di)
-      {
-      if(di->IsLink())
-        {
+  if (linked.insert(target).second) {
+    TargetDependSet const& depends = this->GetTargetDirectDepends(target);
+    for (TargetDependSet::const_iterator di = depends.begin();
+         di != depends.end(); ++di) {
+      if (di->IsLink()) {
         this->FillLinkClosure(*di, linked);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmGlobalVisualStudioGenerator::TargetSet const&
 cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target)
 {
   TargetSetMap::iterator i = this->TargetLinkClosure.find(target);
-  if(i == this->TargetLinkClosure.end())
-    {
+  if (i == this->TargetLinkClosure.end()) {
     TargetSetMap::value_type entry(target, TargetSet());
     i = this->TargetLinkClosure.insert(entry).first;
     this->FillLinkClosure(target, i->second);
-    }
+  }
   return i->second;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::FollowLinkDepends(
-        const cmGeneratorTarget *target,
-        std::set<const cmGeneratorTarget *> &linked)
+  const cmGeneratorTarget* target, std::set<const cmGeneratorTarget*>& linked)
 {
-  if(target->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (target->GetType() == cmState::INTERFACE_LIBRARY) {
     return;
-    }
-  if(linked.insert(target).second &&
-     target->GetType() == cmState::STATIC_LIBRARY)
-    {
+  }
+  if (linked.insert(target).second &&
+      target->GetType() == cmState::STATIC_LIBRARY) {
     // Static library targets do not list their link dependencies so
     // we must follow them transitively now.
     TargetDependSet const& depends = this->GetTargetDirectDepends(target);
-    for(TargetDependSet::const_iterator di = depends.begin();
-        di != depends.end(); ++di)
-      {
-      if(di->IsLink())
-        {
+    for (TargetDependSet::const_iterator di = depends.begin();
+         di != depends.end(); ++di) {
+      if (di->IsLink()) {
         this->FollowLinkDepends(*di, linked);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
 {
-  if(!this->cmGlobalGenerator::ComputeTargetDepends())
-    {
+  if (!this->cmGlobalGenerator::ComputeTargetDepends()) {
     return false;
-    }
+  }
   std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
-  for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
-    {
+  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
     std::vector<cmLocalGenerator*>& gen = it->second;
-    for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
-        i != gen.end(); ++i)
-      {
+    for (std::vector<cmLocalGenerator*>::iterator i = gen.begin();
+         i != gen.end(); ++i) {
       std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets();
-      for(std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-          ti != targets.end(); ++ti)
-        {
+      for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
+           ti != targets.end(); ++ti) {
         this->ComputeVSTargetDepends(*ti);
-        }
       }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 static bool VSLinkable(cmGeneratorTarget const* t)
 {
   return t->IsLinkable() || t->GetType() == cmState::OBJECT_LIBRARY;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
-        cmGeneratorTarget* target)
+  cmGeneratorTarget* target)
 {
-  if(this->VSTargetDepends.find(target) != this->VSTargetDepends.end())
-    {
+  if (this->VSTargetDepends.find(target) != this->VSTargetDepends.end()) {
     return;
-    }
+  }
   VSDependSet& vsTargetDepend = this->VSTargetDepends[target];
   // VS <= 7.1 has two behaviors that affect solution dependencies.
   //
@@ -431,101 +353,103 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
   // Static libraries cannot depend on their link implementation
   // due to behavior (2), but they do not really need to.
   std::set<cmGeneratorTarget const*> linkDepends;
-  if(target->GetType() != cmState::STATIC_LIBRARY)
-    {
-    for(TargetDependSet::const_iterator di = depends.begin();
-        di != depends.end(); ++di)
-      {
+  if (target->GetType() != cmState::STATIC_LIBRARY) {
+    for (TargetDependSet::const_iterator di = depends.begin();
+         di != depends.end(); ++di) {
       cmTargetDepend dep = *di;
-      if(dep.IsLink())
-        {
+      if (dep.IsLink()) {
         this->FollowLinkDepends(*di, linkDepends);
-        }
       }
     }
+  }
 
   // Collect explicit util dependencies (add_dependencies).
   std::set<cmGeneratorTarget const*> utilDepends;
-  for(TargetDependSet::const_iterator di = depends.begin();
-      di != depends.end(); ++di)
-    {
+  for (TargetDependSet::const_iterator di = depends.begin();
+       di != depends.end(); ++di) {
     cmTargetDepend dep = *di;
-    if(dep.IsUtil())
-      {
+    if (dep.IsUtil()) {
       this->FollowLinkDepends(*di, utilDepends);
-      }
     }
+  }
 
   // Collect all targets linked by this target so we can avoid
   // intermediate targets below.
   TargetSet linked;
-  if(target->GetType() != cmState::STATIC_LIBRARY)
-    {
+  if (target->GetType() != cmState::STATIC_LIBRARY) {
     linked = this->GetTargetLinkClosure(target);
-    }
+  }
 
   // Emit link dependencies.
-  for(std::set<cmGeneratorTarget const*>::iterator di = linkDepends.begin();
-      di != linkDepends.end(); ++di)
-    {
+  for (std::set<cmGeneratorTarget const*>::iterator di = linkDepends.begin();
+       di != linkDepends.end(); ++di) {
     cmGeneratorTarget const* dep = *di;
     vsTargetDepend.insert(dep->GetName());
-    }
+  }
 
   // Emit util dependencies.  Possibly use intermediate targets.
-  for(std::set<cmGeneratorTarget const*>::iterator di = utilDepends.begin();
-      di != utilDepends.end(); ++di)
-    {
+  for (std::set<cmGeneratorTarget const*>::iterator di = utilDepends.begin();
+       di != utilDepends.end(); ++di) {
     cmGeneratorTarget const* dgt = *di;
-    if(allowLinkable || !VSLinkable(dgt) || linked.count(dgt))
-      {
+    if (allowLinkable || !VSLinkable(dgt) || linked.count(dgt)) {
       // Direct dependency allowed.
       vsTargetDepend.insert(dgt->GetName());
-      }
-    else
-      {
+    } else {
       // Direct dependency on linkable target not allowed.
       // Use an intermediate utility target.
       vsTargetDepend.insert(this->GetUtilityDepend(dgt));
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
 {
   // Visual Studio generators know how to lookup their build tool
   // directly instead of needing a helper module to do it, so we
   // do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
-  if(cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
-    {
-    mf->AddDefinition("CMAKE_MAKE_PROGRAM",
-                      this->GetVSMakeProgram().c_str());
-    }
+  if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
+    mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetVSMakeProgram().c_str());
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalVisualStudioGenerator::GetUtilityDepend(
-        cmGeneratorTarget const* target)
+std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(
+  cmGeneratorTarget const* target)
 {
   UtilityDependsMap::iterator i = this->UtilityDepends.find(target);
-  if(i == this->UtilityDepends.end())
-    {
+  if (i == this->UtilityDepends.end()) {
     std::string name = this->WriteUtilityDepend(target);
     UtilityDependsMap::value_type entry(target, name);
     i = this->UtilityDepends.insert(entry).first;
-    }
+  }
   return i->second;
 }
 
-//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudioGenerator::GetStartupProjectName(
+  cmLocalGenerator const* root) const
+{
+  const char* n = root->GetMakefile()->GetProperty("VS_STARTUP_PROJECT");
+  if (n && *n) {
+    std::string startup = n;
+    if (this->FindTarget(startup)) {
+      return startup;
+    } else {
+      root->GetMakefile()->IssueMessage(
+        cmake::AUTHOR_WARNING,
+        "Directory property VS_STARTUP_PROJECT specifies target "
+        "'" +
+          startup + "' that does not exist.  Ignoring.");
+    }
+  }
+
+  // default, if not specified
+  return this->GetAllTargetName();
+}
+
 #include <windows.h>
 
-//----------------------------------------------------------------------------
 bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
-  const std::string& regKeyBase,
-  std::string& nextAvailableSubKeyName)
+                                        const std::string& regKeyBase,
+                                        std::string& nextAvailableSubKeyName)
 {
   bool macrosRegistered = false;
 
@@ -544,98 +468,88 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
 
   keyname = regKeyBase + "\\OtherProjects7";
   hkey = NULL;
-  result = RegOpenKeyExW(HKEY_CURRENT_USER,
-                         cmsys::Encoding::ToWide(keyname).c_str(),
-                         0, KEY_READ, &hkey);
-  if (ERROR_SUCCESS == result)
-    {
+  result =
+    RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
+                  0, KEY_READ, &hkey);
+  if (ERROR_SUCCESS == result) {
     // Iterate the subkeys and look for the values of interest in each subkey:
     wchar_t subkeyname[256];
-    DWORD cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]);
+    DWORD cch_subkeyname = sizeof(subkeyname) * sizeof(subkeyname[0]);
     wchar_t keyclass[256];
-    DWORD cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]);
+    DWORD cch_keyclass = sizeof(keyclass) * sizeof(keyclass[0]);
     FILETIME lastWriteTime;
     lastWriteTime.dwHighDateTime = 0;
     lastWriteTime.dwLowDateTime = 0;
 
     while (ERROR_SUCCESS == RegEnumKeyExW(hkey, index, subkeyname,
-                                         &cch_subkeyname,
-      0, keyclass, &cch_keyclass, &lastWriteTime))
-      {
+                                          &cch_subkeyname, 0, keyclass,
+                                          &cch_keyclass, &lastWriteTime)) {
       // Open the subkey and query the values of interest:
       HKEY hsubkey = NULL;
       result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey);
-      if (ERROR_SUCCESS == result)
-        {
+      if (ERROR_SUCCESS == result) {
         DWORD valueType = REG_SZ;
         wchar_t data1[256];
-        DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]);
-        RegQueryValueExW(hsubkey, L"Path", 0, &valueType,
-                        (LPBYTE) &data1[0], &cch_data1);
+        DWORD cch_data1 = sizeof(data1) * sizeof(data1[0]);
+        RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE)&data1[0],
+                         &cch_data1);
 
         DWORD data2 = 0;
         DWORD cch_data2 = sizeof(data2);
-        RegQueryValueExW(hsubkey, L"Security", 0, &valueType,
-                        (LPBYTE) &data2, &cch_data2);
+        RegQueryValueExW(hsubkey, L"Security", 0, &valueType, (LPBYTE)&data2,
+                         &cch_data2);
 
         DWORD data3 = 0;
         DWORD cch_data3 = sizeof(data3);
         RegQueryValueExW(hsubkey, L"StorageFormat", 0, &valueType,
-                        (LPBYTE) &data3, &cch_data3);
+                         (LPBYTE)&data3, &cch_data3);
 
         s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1));
         cmSystemTools::ConvertToUnixSlashes(s2);
-        if (s2 == s1)
-          {
+        if (s2 == s1) {
           macrosRegistered = true;
-          }
+        }
 
         std::string fullname = cmsys::Encoding::ToNarrow(data1);
         std::string filename;
         std::string filepath;
         std::string filepathname;
         std::string filepathpath;
-        if (cmSystemTools::FileExists(fullname.c_str()))
-          {
+        if (cmSystemTools::FileExists(fullname.c_str())) {
           filename = cmSystemTools::GetFilenameName(fullname);
           filepath = cmSystemTools::GetFilenamePath(fullname);
           filepathname = cmSystemTools::GetFilenameName(filepath);
           filepathpath = cmSystemTools::GetFilenamePath(filepath);
-          }
+        }
 
-        //std::cout << keyname << "\\" << subkeyname << ":" << std::endl;
-        //std::cout << "  Path: " << data1 << std::endl;
-        //std::cout << "  Security: " << data2 << std::endl;
-        //std::cout << "  StorageFormat: " << data3 << std::endl;
-        //std::cout << "  filename: " << filename << std::endl;
-        //std::cout << "  filepath: " << filepath << std::endl;
-        //std::cout << "  filepathname: " << filepathname << std::endl;
-        //std::cout << "  filepathpath: " << filepathpath << std::endl;
-        //std::cout << std::endl;
+        // std::cout << keyname << "\\" << subkeyname << ":" << std::endl;
+        // std::cout << "  Path: " << data1 << std::endl;
+        // std::cout << "  Security: " << data2 << std::endl;
+        // std::cout << "  StorageFormat: " << data3 << std::endl;
+        // std::cout << "  filename: " << filename << std::endl;
+        // std::cout << "  filepath: " << filepath << std::endl;
+        // std::cout << "  filepathname: " << filepathname << std::endl;
+        // std::cout << "  filepathpath: " << filepathpath << std::endl;
+        // std::cout << std::endl;
 
         RegCloseKey(hsubkey);
-        }
-      else
-        {
+      } else {
         std::cout << "error opening subkey: " << subkeyname << std::endl;
         std::cout << std::endl;
-        }
+      }
 
       ++index;
-      cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]);
-      cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]);
+      cch_subkeyname = sizeof(subkeyname) * sizeof(subkeyname[0]);
+      cch_keyclass = sizeof(keyclass) * sizeof(keyclass[0]);
       lastWriteTime.dwHighDateTime = 0;
       lastWriteTime.dwLowDateTime = 0;
-      }
+    }
 
     RegCloseKey(hkey);
-    }
-  else
-    {
+  } else {
     std::cout << "error opening key: " << keyname << std::endl;
     std::cout << std::endl;
-    }
-
+  }
 
   // Pass back next available sub key name, assuming sub keys always
   // follow the expected naming scheme. Expected naming scheme is that
@@ -645,141 +559,124 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
   ossNext << index;
   nextAvailableSubKeyName = ossNext.str();
 
-
   keyname = regKeyBase + "\\RecordingProject7";
   hkey = NULL;
-  result = RegOpenKeyExW(HKEY_CURRENT_USER,
-                         cmsys::Encoding::ToWide(keyname).c_str(),
-                         0, KEY_READ, &hkey);
-  if (ERROR_SUCCESS == result)
-    {
+  result =
+    RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
+                  0, KEY_READ, &hkey);
+  if (ERROR_SUCCESS == result) {
     DWORD valueType = REG_SZ;
     wchar_t data1[256];
-    DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]);
-    RegQueryValueExW(hkey, L"Path", 0, &valueType,
-                    (LPBYTE) &data1[0], &cch_data1);
+    DWORD cch_data1 = sizeof(data1) * sizeof(data1[0]);
+    RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE)&data1[0],
+                     &cch_data1);
 
     DWORD data2 = 0;
     DWORD cch_data2 = sizeof(data2);
-    RegQueryValueExW(hkey, L"Security", 0, &valueType,
-                    (LPBYTE) &data2, &cch_data2);
+    RegQueryValueExW(hkey, L"Security", 0, &valueType, (LPBYTE)&data2,
+                     &cch_data2);
 
     DWORD data3 = 0;
     DWORD cch_data3 = sizeof(data3);
-    RegQueryValueExW(hkey, L"StorageFormat", 0, &valueType,
-                    (LPBYTE) &data3, &cch_data3);
+    RegQueryValueExW(hkey, L"StorageFormat", 0, &valueType, (LPBYTE)&data3,
+                     &cch_data3);
 
     s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1));
     cmSystemTools::ConvertToUnixSlashes(s2);
-    if (s2 == s1)
-      {
+    if (s2 == s1) {
       macrosRegistered = true;
-      }
+    }
 
-    //std::cout << keyname << ":" << std::endl;
-    //std::cout << "  Path: " << data1 << std::endl;
-    //std::cout << "  Security: " << data2 << std::endl;
-    //std::cout << "  StorageFormat: " << data3 << std::endl;
-    //std::cout << std::endl;
+    // std::cout << keyname << ":" << std::endl;
+    // std::cout << "  Path: " << data1 << std::endl;
+    // std::cout << "  Security: " << data2 << std::endl;
+    // std::cout << "  StorageFormat: " << data3 << std::endl;
+    // std::cout << std::endl;
 
     RegCloseKey(hkey);
-    }
-  else
-    {
+  } else {
     std::cout << "error opening key: " << keyname << std::endl;
     std::cout << std::endl;
-    }
+  }
 
   return macrosRegistered;
 }
 
-//----------------------------------------------------------------------------
-void WriteVSMacrosFileRegistryEntry(
-  const std::string& nextAvailableSubKeyName,
-  const std::string& macrosFile,
-  const std::string& regKeyBase)
+void WriteVSMacrosFileRegistryEntry(const std::string& nextAvailableSubKeyName,
+                                    const std::string& macrosFile,
+                                    const std::string& regKeyBase)
 {
   std::string keyname = regKeyBase + "\\OtherProjects7";
   HKEY hkey = NULL;
-  LONG result = RegOpenKeyExW(HKEY_CURRENT_USER,
-    cmsys::Encoding::ToWide(keyname).c_str(), 0,
-    KEY_READ|KEY_WRITE, &hkey);
-  if (ERROR_SUCCESS == result)
-    {
+  LONG result =
+    RegOpenKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(keyname).c_str(),
+                  0, KEY_READ | KEY_WRITE, &hkey);
+  if (ERROR_SUCCESS == result) {
     // Create the subkey and set the values of interest:
     HKEY hsubkey = NULL;
     wchar_t lpClass[] = L"";
-    result = RegCreateKeyExW(hkey,
-      cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0,
-      lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0);
-    if (ERROR_SUCCESS == result)
-      {
+    result = RegCreateKeyExW(
+      hkey, cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0,
+      lpClass, 0, KEY_READ | KEY_WRITE, 0, &hsubkey, 0);
+    if (ERROR_SUCCESS == result) {
       DWORD dw = 0;
 
       std::string s(macrosFile);
-      cmSystemTools::ReplaceString(s, "/", "\\");
+      std::replace(s.begin(), s.end(), '/', '\\');
       std::wstring ws = cmsys::Encoding::ToWide(s);
 
-      result = RegSetValueExW(hsubkey, L"Path", 0, REG_SZ, (LPBYTE)ws.c_str(),
-        static_cast<DWORD>(ws.size() + 1)*sizeof(wchar_t));
-      if (ERROR_SUCCESS != result)
-        {
+      result =
+        RegSetValueExW(hsubkey, L"Path", 0, REG_SZ, (LPBYTE)ws.c_str(),
+                       static_cast<DWORD>(ws.size() + 1) * sizeof(wchar_t));
+      if (ERROR_SUCCESS != result) {
         std::cout << "error result 1: " << result << std::endl;
         std::cout << std::endl;
-        }
+      }
 
       // Security value is always "1" for sample macros files (seems to be "2"
       // if you put the file somewhere outside the standard VSMacros folder)
       dw = 1;
-      result = RegSetValueExW(hsubkey, L"Security",
-                             0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD));
-      if (ERROR_SUCCESS != result)
-        {
+      result = RegSetValueExW(hsubkey, L"Security", 0, REG_DWORD, (LPBYTE)&dw,
+                              sizeof(DWORD));
+      if (ERROR_SUCCESS != result) {
         std::cout << "error result 2: " << result << std::endl;
         std::cout << std::endl;
-        }
+      }
 
       // StorageFormat value is always "0" for sample macros files
       dw = 0;
-      result = RegSetValueExW(hsubkey, L"StorageFormat",
-                             0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD));
-      if (ERROR_SUCCESS != result)
-        {
+      result = RegSetValueExW(hsubkey, L"StorageFormat", 0, REG_DWORD,
+                              (LPBYTE)&dw, sizeof(DWORD));
+      if (ERROR_SUCCESS != result) {
         std::cout << "error result 3: " << result << std::endl;
         std::cout << std::endl;
-        }
+      }
 
       RegCloseKey(hsubkey);
-      }
-    else
-      {
-      std::cout << "error creating subkey: "
-                << nextAvailableSubKeyName << std::endl;
+    } else {
+      std::cout << "error creating subkey: " << nextAvailableSubKeyName
+                << std::endl;
       std::cout << std::endl;
-      }
-    RegCloseKey(hkey);
     }
-  else
-    {
+    RegCloseKey(hkey);
+  } else {
     std::cout << "error opening key: " << keyname << std::endl;
     std::cout << std::endl;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void RegisterVisualStudioMacros(const std::string& macrosFile,
-  const std::string& regKeyBase)
+                                const std::string& regKeyBase)
 {
   bool macrosRegistered;
   std::string nextAvailableSubKeyName;
 
-  macrosRegistered = IsVisualStudioMacrosFileRegistered(macrosFile,
-    regKeyBase, nextAvailableSubKeyName);
+  macrosRegistered = IsVisualStudioMacrosFileRegistered(
+    macrosFile, regKeyBase, nextAvailableSubKeyName);
 
-  if (!macrosRegistered)
-    {
-    int count = cmCallVisualStudioMacro::
-      GetNumberOfRunningVisualStudioInstances("ALL");
+  if (!macrosRegistered) {
+    int count =
+      cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances("ALL");
 
     // Only register the macros file if there are *no* instances of Visual
     // Studio running. If we register it while one is running, first, it has
@@ -788,18 +685,16 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
     // emit a warning asking the user to exit all running Visual Studio
     // instances...
     //
-    if (0 != count)
-      {
+    if (0 != count) {
       std::ostringstream oss;
       oss << "Could not register CMake's Visual Studio macros file '"
-        << CMAKE_VSMACROS_FILENAME "' while Visual Studio is running."
-        << " Please exit all running instances of Visual Studio before"
-        << " continuing." << std::endl
-        << std::endl
-        << "CMake needs to register Visual Studio macros when its macros"
-        << " file is updated or when it detects that its current macros file"
-        << " is no longer registered with Visual Studio."
-        << std::endl;
+          << CMAKE_VSMACROS_FILENAME "' while Visual Studio is running."
+          << " Please exit all running instances of Visual Studio before"
+          << " continuing." << std::endl
+          << std::endl
+          << "CMake needs to register Visual Studio macros when its macros"
+          << " file is updated or when it detects that its current macros file"
+          << " is no longer registered with Visual Studio." << std::endl;
       cmSystemTools::Message(oss.str().c_str(), "Warning");
 
       // Count them again now that the warning is over. In the case of a GUI
@@ -807,107 +702,90 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
       // back to the CMake GUI and clicked ok on the above warning. If so,
       // then register the macros *now* if the count is *now* 0...
       //
-      count = cmCallVisualStudioMacro::
-        GetNumberOfRunningVisualStudioInstances("ALL");
+      count = cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
+        "ALL");
 
       // Also re-get the nextAvailableSubKeyName in case Visual Studio
       // wrote out new registered macros information as it was exiting:
       //
-      if (0 == count)
-        {
+      if (0 == count) {
         IsVisualStudioMacrosFileRegistered(macrosFile, regKeyBase,
-          nextAvailableSubKeyName);
-        }
+                                           nextAvailableSubKeyName);
       }
+    }
 
     // Do another if check - 'count' may have changed inside the above if:
     //
-    if (0 == count)
-      {
+    if (0 == count) {
       WriteVSMacrosFileRegistryEntry(nextAvailableSubKeyName, macrosFile,
-        regKeyBase);
-      }
+                                     regKeyBase);
     }
+  }
 }
-bool
-cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmGeneratorTarget const* gt)
+bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
+  cmGeneratorTarget const* gt)
 {
   // check to see if this is a fortran build
   std::set<std::string> languages;
   {
-  // Issue diagnostic if the source files depend on the config.
-  std::vector<cmSourceFile*> sources;
-  if (!gt->GetConfigCommonSourceFiles(sources))
-    {
-    return false;
+    // Issue diagnostic if the source files depend on the config.
+    std::vector<cmSourceFile*> sources;
+    if (!gt->GetConfigCommonSourceFiles(sources)) {
+      return false;
     }
   }
   gt->GetLanguages(languages, "");
-  if(languages.size() == 1)
-    {
-    if(*languages.begin() == "Fortran")
-      {
+  if (languages.size() == 1) {
+    if (*languages.begin() == "Fortran") {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalVisualStudioGenerator::TargetCompare
-::operator()(cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
+bool cmGlobalVisualStudioGenerator::TargetCompare::operator()(
+  cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
 {
   // Make sure a given named target is ordered first,
   // e.g. to set ALL_BUILD as the default active project.
   // When the empty string is named this is a no-op.
-  if (r->GetName() == this->First)
-    {
+  if (r->GetName() == this->First) {
     return false;
-    }
-  if (l->GetName() == this->First)
-    {
+  }
+  if (l->GetName() == this->First) {
     return true;
-    }
+  }
   return l->GetName() < r->GetName();
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudioGenerator::OrderedTargetDependSet
-::OrderedTargetDependSet(TargetDependSet const& targets,
-                         std::string const& first):
-  derived(TargetCompare(first))
+cmGlobalVisualStudioGenerator::OrderedTargetDependSet::OrderedTargetDependSet(
+  TargetDependSet const& targets, std::string const& first)
+  : derived(TargetCompare(first))
 {
   this->insert(targets.begin(), targets.end());
 }
 
-//----------------------------------------------------------------------------
-cmGlobalVisualStudioGenerator::OrderedTargetDependSet
-::OrderedTargetDependSet(TargetSet const& targets,
-                         std::string const& first):
-  derived(TargetCompare(first))
+cmGlobalVisualStudioGenerator::OrderedTargetDependSet::OrderedTargetDependSet(
+  TargetSet const& targets, std::string const& first)
+  : derived(TargetCompare(first))
 {
-  for (TargetSet::const_iterator it = targets.begin();
-       it != targets.end(); ++it)
-    {
+  for (TargetSet::const_iterator it = targets.begin(); it != targets.end();
+       ++it) {
     this->insert(*it);
-    }
+  }
 }
 
 std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir(
-  const std::string& str,
-  const std::string& config) const
+  const std::string& str, const std::string& config) const
 {
   std::string replace = GetCMakeCFGIntDir();
 
   std::string tmp = str;
-  for(std::string::size_type i = tmp.find(replace);
-      i != std::string::npos;
-      i = tmp.find(replace, i))
-    {
+  for (std::string::size_type i = tmp.find(replace); i != std::string::npos;
+       i = tmp.find(replace, i)) {
     tmp.replace(i, replace.size(), config);
     i += config.size();
-    }
+  }
   return tmp;
 }
 
@@ -923,13 +801,12 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
   std::vector<cmSourceFile const*> objectSources;
   gt->GetObjectSources(objectSources, configName);
   std::map<cmSourceFile const*, std::string> mapping;
-  for(std::vector<cmSourceFile const*>::const_iterator it
-        = objectSources.begin(); it != objectSources.end(); ++it)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator it =
+         objectSources.begin();
+       it != objectSources.end(); ++it) {
     mapping[*it];
-    }
-  gt->LocalGenerator->
-    ComputeObjectFilenames(mapping, gt);
+  }
+  gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
   std::string obj_dir = gt->ObjectDirectory;
   std::string cmakeCommand = cmSystemTools::GetCMakeCommand();
   cmSystemTools::ConvertToWindowsExtendedPath(cmakeCommand);
@@ -939,42 +816,36 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
   cmdl.push_back("__create_def");
   cmdl.push_back(deffile);
   std::string obj_dir_expanded = obj_dir;
-  cmSystemTools::ReplaceString(obj_dir_expanded,
-                               this->GetCMakeCFGIntDir(),
+  cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(),
                                configName.c_str());
   std::string objs_file = obj_dir_expanded;
   cmSystemTools::MakeDirectory(objs_file.c_str());
   objs_file += "/objects.txt";
   cmdl.push_back(objs_file);
   cmGeneratedFileStream fout(objs_file.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     cmSystemTools::Error("could not open ", objs_file.c_str());
     return;
-    }
-  for(std::vector<cmSourceFile const*>::const_iterator it
-        = objectSources.begin(); it != objectSources.end(); ++it)
-    {
+  }
+  for (std::vector<cmSourceFile const*>::const_iterator it =
+         objectSources.begin();
+       it != objectSources.end(); ++it) {
     // Find the object file name corresponding to this source file.
-    std::map<cmSourceFile const*, std::string>::const_iterator
-      map_it = mapping.find(*it);
+    std::map<cmSourceFile const*, std::string>::const_iterator map_it =
+      mapping.find(*it);
     // It must exist because we populated the mapping just above.
     assert(!map_it->second.empty());
     std::string objFile = obj_dir + map_it->second;
     // replace $(ConfigurationName) in the object names
     cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(),
                                  configName.c_str());
-    if(cmHasLiteralSuffix(objFile, ".obj"))
-      {
+    if (cmHasLiteralSuffix(objFile, ".obj")) {
       fout << objFile << "\n";
-      }
     }
+  }
   cmCustomCommandLines commandLines;
   commandLines.push_back(cmdl);
-  cmCustomCommand command(gt->Target->GetMakefile(),
-                          outputs, empty, empty,
-                          commandLines,
-                          "Auto build dll exports",
-                          ".");
+  cmCustomCommand command(gt->Target->GetMakefile(), outputs, empty, empty,
+                          commandLines, "Auto build dll exports", ".");
   commands.push_back(command);
 }
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index f827f26..fb2cdbd 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -26,7 +26,6 @@ public:
   /** Known versions of Visual Studio.  */
   enum VSVersion
   {
-    VS6 = 60,
     VS7 = 70,
     VS71 = 71,
     VS8 = 80,
@@ -63,17 +62,20 @@ public:
    */
   virtual std::string GetUserMacrosRegKeyBase();
 
-  enum MacroName {MacroReload, MacroStop};
+  enum MacroName
+  {
+    MacroReload,
+    MacroStop
+  };
 
   /**
    * Call the ReloadProjects macro if necessary based on
    * GetFilesReplacedDuringGenerate results.
    */
-  void CallVisualStudioMacro(MacroName m,
-                             const char* vsSolutionFile = 0);
+  void CallVisualStudioMacro(MacroName m, const char* vsSolutionFile = 0);
 
   // return true if target is fortran only
-  bool TargetIsFortranOnly(const cmGeneratorTarget *gt);
+  bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
 
   /** Get the top-level registry key for this VS version.  */
   std::string GetRegistryBase();
@@ -88,12 +90,18 @@ public:
   /** Return true if building for Windows CE */
   virtual bool TargetsWindowsCE() const { return false; }
 
-  class TargetSet: public std::set<cmGeneratorTarget const*> {};
+  class TargetSet : public std::set<cmGeneratorTarget const*>
+  {
+  };
   class TargetCompare
   {
     std::string First;
+
   public:
-    TargetCompare(std::string const& first): First(first) {}
+    TargetCompare(std::string const& first)
+      : First(first)
+    {
+    }
     bool operator()(cmGeneratorTarget const* l,
                     cmGeneratorTarget const* r) const;
   };
@@ -101,15 +109,17 @@ public:
 
   virtual void FindMakeProgram(cmMakefile*);
 
-
   virtual std::string ExpandCFGIntDir(const std::string& str,
                                       const std::string& config) const;
 
   void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 
-  void AddSymbolExportCommand(
-    cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
-    std::string const& configName);
+  std::string GetStartupProjectName(cmLocalGenerator const* root) const;
+
+  void AddSymbolExportCommand(cmGeneratorTarget*,
+                              std::vector<cmCustomCommand>& commands,
+                              std::string const& configName);
+
 protected:
   virtual void AddExtraIDETargets();
 
@@ -121,16 +131,20 @@ protected:
   virtual const char* GetIDEVersion() = 0;
 
   virtual bool ComputeTargetDepends();
-  class VSDependSet: public std::set<std::string> {};
-  class VSDependMap: public std::map<cmGeneratorTarget const*, VSDependSet> {};
+  class VSDependSet : public std::set<std::string>
+  {
+  };
+  class VSDependMap : public std::map<cmGeneratorTarget const*, VSDependSet>
+  {
+  };
   VSDependMap VSTargetDepends;
-  void ComputeVSTargetDepends(cmGeneratorTarget *);
+  void ComputeVSTargetDepends(cmGeneratorTarget*);
 
   bool CheckTargetLinks(cmGeneratorTarget& target, const std::string& name);
   std::string GetUtilityForTarget(cmGeneratorTarget& target,
                                   const std::string&);
   virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
-  std::string GetUtilityDepend(const cmGeneratorTarget *target);
+  std::string GetUtilityDepend(const cmGeneratorTarget* target);
   typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap;
   UtilityDependsMap UtilityDepends;
 
@@ -140,25 +154,29 @@ protected:
 private:
   virtual std::string GetVSMakeProgram() = 0;
   void PrintCompilerAdvice(std::ostream&, std::string const&,
-                           const char*) const {}
+                           const char*) const
+  {
+  }
 
   void FollowLinkDepends(cmGeneratorTarget const* target,
                          std::set<cmGeneratorTarget const*>& linked);
 
-  class TargetSetMap: public std::map<cmGeneratorTarget*, TargetSet> {};
+  class TargetSetMap : public std::map<cmGeneratorTarget*, TargetSet>
+  {
+  };
   TargetSetMap TargetLinkClosure;
-  void FillLinkClosure(const cmGeneratorTarget *target,
-                       TargetSet& linked);
+  void FillLinkClosure(const cmGeneratorTarget* target, TargetSet& linked);
   TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target);
 };
 
-class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
-  public std::multiset<cmTargetDepend,
-                       cmGlobalVisualStudioGenerator::TargetCompare>
+class cmGlobalVisualStudioGenerator::OrderedTargetDependSet
+  : public std::multiset<cmTargetDepend,
+                         cmGlobalVisualStudioGenerator::TargetCompare>
 {
   typedef std::multiset<cmTargetDepend,
                         cmGlobalVisualStudioGenerator::TargetCompare>
     derived;
+
 public:
   typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
   typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 153773f..86fe6f2 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalWatcomWMakeGenerator.h"
+
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 
@@ -33,10 +34,8 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm)
   this->MakeSilentFlag = "-h";
 }
 
-void cmGlobalWatcomWMakeGenerator
-::EnableLanguage(std::vector<std::string>const& l,
-                 cmMakefile *mf,
-                 bool optional)
+void cmGlobalWatcomWMakeGenerator::EnableLanguage(
+  std::vector<std::string> const& l, cmMakefile* mf, bool optional)
 {
   // pick a default
   mf->AddDefinition("WATCOM", "1");
@@ -49,9 +48,8 @@ void cmGlobalWatcomWMakeGenerator
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalWatcomWMakeGenerator
-::GetDocumentation(cmDocumentationEntry& entry)
+void cmGlobalWatcomWMakeGenerator::GetDocumentation(
+  cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalWatcomWMakeGenerator::GetActualName();
   entry.Brief = "Generates Watcom WMake makefiles.";
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index 4bfcf06..3954907 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -23,13 +23,16 @@ class cmGlobalWatcomWMakeGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalWatcomWMakeGenerator(cmake* cm);
-  static cmGlobalGeneratorFactory* NewFactory() {
-    return new cmGlobalGeneratorSimpleFactory
-      <cmGlobalWatcomWMakeGenerator>(); }
+  static cmGlobalGeneratorFactory* NewFactory()
+  {
+    return new cmGlobalGeneratorSimpleFactory<cmGlobalWatcomWMakeGenerator>();
+  }
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalWatcomWMakeGenerator::GetActualName();}
-  static std::string GetActualName() {return "Watcom WMake";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalWatcomWMakeGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "Watcom WMake"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -38,8 +41,8 @@ public:
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
 
   virtual bool AllowNotParallel() const { return false; }
   virtual bool AllowDeleteOnError() const { return false; }
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 526e32f..6628cfc 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -10,22 +10,22 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalXCodeGenerator.h"
-#include "cmLocalXCodeGenerator.h"
-#include "cmMakefile.h"
-#include "cmXCodeObject.h"
-#include "cmXCode21Object.h"
-#include "cmake.h"
-#include "cmGeneratedFileStream.h"
+
+#include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
-#include "cmSourceFile.h"
 #include "cmCustomCommandGenerator.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
 #include "cmGlobalGeneratorFactory.h"
-#include "cmAlgorithms.h"
+#include "cmLocalXCodeGenerator.h"
+#include "cmMakefile.h"
+#include "cmSourceFile.h"
+#include "cmXCode21Object.h"
+#include "cmXCodeObject.h"
+#include "cmake.h"
 
 #include <cmsys/auto_ptr.hxx>
 
-//----------------------------------------------------------------------------
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cmXMLParser.h"
 
@@ -34,29 +34,25 @@
 class cmXcodeVersionParser : public cmXMLParser
 {
 public:
-  cmXcodeVersionParser(): Version("1.5") {}
-  void StartElement(const std::string&, const char**)
-    {
-      this->Data = "";
-    }
+  cmXcodeVersionParser()
+    : Version("1.5")
+  {
+  }
+  void StartElement(const std::string&, const char**) { this->Data = ""; }
   void EndElement(const std::string& name)
-    {
-      if(name == "key")
-        {
-        this->Key = this->Data;
-        }
-      else if(name == "string")
-        {
-        if(this->Key == "CFBundleShortVersionString")
-          {
-          this->Version = this->Data;
-          }
-        }
+  {
+    if (name == "key") {
+      this->Key = this->Data;
+    } else if (name == "string") {
+      if (this->Key == "CFBundleShortVersionString") {
+        this->Version = this->Data;
+      }
     }
+  }
   void CharacterDataHandler(const char* data, int length)
-    {
-      this->Data.append(data, length);
-    }
+  {
+    this->Data.append(data, length);
+  }
   std::string Version;
   std::string Key;
   std::string Data;
@@ -67,69 +63,67 @@ public:
 // given inputs.
 class cmGlobalXCodeGenerator::BuildObjectListOrString
 {
-  cmGlobalXCodeGenerator *Generator;
-  cmXCodeObject *Group;
+  cmGlobalXCodeGenerator* Generator;
+  cmXCodeObject* Group;
   bool Empty;
   std::string String;
 
 public:
-  BuildObjectListOrString(cmGlobalXCodeGenerator *gen, bool buildObjectList)
-    : Generator(gen), Group(0), Empty(true)
-    {
-    if (buildObjectList)
-      {
+  BuildObjectListOrString(cmGlobalXCodeGenerator* gen, bool buildObjectList)
+    : Generator(gen)
+    , Group(0)
+    , Empty(true)
+  {
+    if (buildObjectList) {
       this->Group = this->Generator->CreateObject(cmXCodeObject::OBJECT_LIST);
-      }
     }
+  }
 
   bool IsEmpty() const { return this->Empty; }
 
-  void Add(const char *newString)
-    {
+  void Add(const std::string& newString)
+  {
     this->Empty = false;
 
-    if (this->Group)
-      {
+    if (this->Group) {
       this->Group->AddObject(this->Generator->CreateString(newString));
-      }
-    else
-      {
+    } else {
       this->String += newString;
       this->String += ' ';
-      }
     }
+  }
 
-  const std::string &GetString() const { return this->String; }
+  const std::string& GetString() const { return this->String; }
 
-  cmXCodeObject *CreateList()
-    {
-    if (this->Group)
-      {
+  cmXCodeObject* CreateList()
+  {
+    if (this->Group) {
       return this->Group;
-      }
-    else
-      {
-      return this->Generator->CreateString(this->String.c_str());
-      }
+    } else {
+      return this->Generator->CreateString(this->String);
     }
+  }
 };
 
 class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator*
-  CreateGlobalGenerator(const std::string& name, cmake* cm) const;
+  virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+                                                   cmake* cm) const;
 
-  virtual void GetDocumentation(cmDocumentationEntry& entry) const {
-    cmGlobalXCodeGenerator::GetDocumentation(entry); }
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const
+  {
+    cmGlobalXCodeGenerator::GetDocumentation(entry);
+  }
 
-  virtual void GetGenerators(std::vector<std::string>& names) const {
-    names.push_back(cmGlobalXCodeGenerator::GetActualName()); }
+  virtual void GetGenerators(std::vector<std::string>& names) const
+  {
+    names.push_back(cmGlobalXCodeGenerator::GetActualName());
+  }
 
   virtual bool SupportsToolset() const { return true; }
 };
 
-//----------------------------------------------------------------------------
 cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm,
                                                std::string const& version)
   : cmGlobalGenerator(cm)
@@ -137,9 +131,9 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm,
   this->VersionString = version;
 
   // Compute an integer form of the version number.
-  unsigned int v[2] = {0,0};
+  unsigned int v[2] = { 0, 0 };
   sscanf(this->VersionString.c_str(), "%u.%u", &v[0], &v[1]);
-  this->XcodeVersion = 10*v[0] + v[1];
+  this->XcodeVersion = 10 * v[0] + v[1];
 
   this->RootObject = 0;
   this->MainGroupChildren = 0;
@@ -150,15 +144,13 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm,
   this->XcodeBuildCommandInitialized = false;
 }
 
-//----------------------------------------------------------------------------
 cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
 {
   return new Factory;
 }
 
-//----------------------------------------------------------------------------
-cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
-::CreateGlobalGenerator(const std::string& name, cmake* cm) const
+cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
+  const std::string& name, cmake* cm) const
 {
   if (name != GetActualName())
     return 0;
@@ -166,214 +158,162 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
   cmXcodeVersionParser parser;
   std::string versionFile;
   {
-  std::string out;
-  std::string::size_type pos;
-  if(cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0,
-                                     0, 0, cmSystemTools::OUTPUT_NONE) &&
-     (pos = out.find(".app/"), pos != out.npos))
-    {
-    versionFile = out.substr(0, pos+5)+"Contents/version.plist";
+    std::string out;
+    std::string::size_type pos;
+    if (cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0,
+                                        0, 0, cmSystemTools::OUTPUT_NONE) &&
+        (pos = out.find(".app/"), pos != out.npos)) {
+      versionFile = out.substr(0, pos + 5) + "Contents/version.plist";
     }
   }
-  if(!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str()))
-    {
+  if (!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) {
     parser.ParseFile(versionFile.c_str());
-    }
-  else if (cmSystemTools::FileExists(
-             "/Applications/Xcode.app/Contents/version.plist"))
-    {
-    parser.ParseFile
-      ("/Applications/Xcode.app/Contents/version.plist");
-    }
-  else
-    {
-    parser.ParseFile
-      ("/Developer/Applications/Xcode.app/Contents/version.plist");
-    }
-  cmsys::auto_ptr<cmGlobalXCodeGenerator>
-    gg(new cmGlobalXCodeGenerator(cm, parser.Version));
-  if (gg->XcodeVersion == 20)
-    {
+  } else if (cmSystemTools::FileExists(
+               "/Applications/Xcode.app/Contents/version.plist")) {
+    parser.ParseFile("/Applications/Xcode.app/Contents/version.plist");
+  } else {
+    parser.ParseFile(
+      "/Developer/Applications/Xcode.app/Contents/version.plist");
+  }
+  cmsys::auto_ptr<cmGlobalXCodeGenerator> gg(
+    new cmGlobalXCodeGenerator(cm, parser.Version));
+  if (gg->XcodeVersion == 20) {
     cmSystemTools::Message("Xcode 2.0 not really supported by cmake, "
                            "using Xcode 15 generator\n");
     gg->XcodeVersion = 15;
-    }
+  }
   return gg.release();
 #else
   std::cerr << "CMake should be built with cmake to use Xcode, "
-    "default to Xcode 1.5\n";
+               "default to Xcode 1.5\n";
   return new cmGlobalXCodeGenerator(cm);
 #endif
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
 {
   // The Xcode generator knows how to lookup its build tool
   // directly instead of needing a helper module to do it, so we
   // do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
-  if(cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
-    {
+  if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
     mf->AddDefinition("CMAKE_MAKE_PROGRAM",
                       this->GetXcodeBuildCommand().c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
 {
-  if(!this->XcodeBuildCommandInitialized)
-    {
+  if (!this->XcodeBuildCommandInitialized) {
     this->XcodeBuildCommandInitialized = true;
     this->XcodeBuildCommand = this->FindXcodeBuildCommand();
-    }
+  }
   return this->XcodeBuildCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
 {
-  if (this->XcodeVersion >= 40)
-    {
+  if (this->XcodeVersion >= 40) {
     std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
-    if (makeProgram.empty())
-      {
+    if (makeProgram.empty()) {
       makeProgram = "xcodebuild";
-      }
-    return makeProgram;
     }
-  else
-    {
+    return makeProgram;
+  } else {
     // Use cmakexbuild wrapper to suppress environment dump from output.
     return cmSystemTools::GetCMakeCommand() + "xbuild";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
                                                  cmMakefile* mf)
 {
-  if(this->XcodeVersion >= 30)
-    {
+  if (this->XcodeVersion >= 30) {
     this->GeneratorToolset = ts;
-    if(!this->GeneratorToolset.empty())
-      {
+    if (!this->GeneratorToolset.empty()) {
       mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
                         this->GeneratorToolset.c_str());
-      }
-    return true;
     }
-  else
-    {
+    return true;
+  } else {
     return cmGlobalGenerator::SetGeneratorToolset(ts, mf);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
-                                            lang,
-                                            cmMakefile * mf, bool optional)
+void cmGlobalXCodeGenerator::EnableLanguage(
+  std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
 {
-  mf->AddDefinition("XCODE","1");
+  mf->AddDefinition("XCODE", "1");
   mf->AddDefinition("XCODE_VERSION", this->VersionString.c_str());
-  if(this->XcodeVersion == 15)
-    {
-    }
-  else
-    {
-    if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
-      {
+  if (this->XcodeVersion == 15) {
+  } else {
+    if (!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
       mf->AddCacheDefinition(
-        "CMAKE_CONFIGURATION_TYPES",
-        "Debug;Release;MinSizeRel;RelWithDebInfo",
+        "CMAKE_CONFIGURATION_TYPES", "Debug;Release;MinSizeRel;RelWithDebInfo",
         "Semicolon separated list of supported configuration types, "
         "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
         "anything else will be ignored.",
         cmState::STRING);
-      }
     }
+  }
   mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
   this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
-    const char* osxArch =
-      mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
-  const char* sysroot =
-      mf->GetDefinition("CMAKE_OSX_SYSROOT");
-  if(osxArch && sysroot)
-    {
+  const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
+  const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT");
+  if (osxArch && sysroot) {
     this->Architectures.clear();
     cmSystemTools::ExpandListArgument(std::string(osxArch),
                                       this->Architectures);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::GenerateBuildCommand(
-  std::vector<std::string>& makeCommand,
-  const std::string& makeProgram,
-  const std::string& projectName,
-  const std::string& /*projectDir*/,
-  const std::string& targetName,
-  const std::string& config,
-  bool /*fast*/, bool /*verbose*/,
-  std::vector<std::string> const& makeOptions)
+void cmGlobalXCodeGenerator::GenerateBuildCommand(
+  std::vector<std::string>& makeCommand, const std::string& makeProgram,
+  const std::string& projectName, const std::string& /*projectDir*/,
+  const std::string& targetName, const std::string& config, bool /*fast*/,
+  bool /*verbose*/, std::vector<std::string> const& makeOptions)
 {
   // now build the test
   makeCommand.push_back(
-    this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand())
-    );
+    this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand()));
 
   makeCommand.push_back("-project");
   std::string projectArg = projectName;
   projectArg += ".xcode";
-  if(this->XcodeVersion > 20)
-    {
+  if (this->XcodeVersion > 20) {
     projectArg += "proj";
-    }
+  }
   makeCommand.push_back(projectArg);
 
   bool clean = false;
   std::string realTarget = targetName;
-  if ( realTarget == "clean" )
-    {
+  if (realTarget == "clean") {
     clean = true;
     realTarget = "ALL_BUILD";
-    }
-  if(clean)
-    {
+  }
+  if (clean) {
     makeCommand.push_back("clean");
-    }
-  else
-    {
+  } else {
     makeCommand.push_back("build");
-    }
+  }
   makeCommand.push_back("-target");
-  if (!realTarget.empty())
-    {
+  if (!realTarget.empty()) {
     makeCommand.push_back(realTarget);
-    }
-  else
-    {
+  } else {
     makeCommand.push_back("ALL_BUILD");
-    }
-  if(this->XcodeVersion == 15)
-    {
+  }
+  if (this->XcodeVersion == 15) {
     makeCommand.push_back("-buildstyle");
     makeCommand.push_back("Development");
-    }
-  else
-    {
+  } else {
     makeCommand.push_back("-configuration");
-    makeCommand.push_back(!config.empty()?config:"Debug");
-    }
-  makeCommand.insert(makeCommand.end(),
-                     makeOptions.begin(), makeOptions.end());
+    makeCommand.push_back(!config.empty() ? config : "Debug");
+  }
+  makeCommand.insert(makeCommand.end(), makeOptions.begin(),
+                     makeOptions.end());
 }
 
-//----------------------------------------------------------------------------
 ///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
+cmLocalGenerator* cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
   return new cmLocalXCodeGenerator(this, mf);
 }
@@ -383,82 +323,71 @@ void cmGlobalXCodeGenerator::AddExtraIDETargets()
   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)
-    {
+  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
     cmLocalGenerator* root = it->second[0];
     this->SetGenerationRoot(root);
     // add ALL_BUILD, INSTALL, etc
     this->AddExtraTargets(root, it->second);
-    }
+  }
 }
 
 void cmGlobalXCodeGenerator::Generate()
 {
   this->cmGlobalGenerator::Generate();
-  if(cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return;
-    }
+  }
   std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
-  for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
-    {
+  for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
     cmLocalGenerator* root = it->second[0];
     this->SetGenerationRoot(root);
     // now create the project
     this->OutputXCodeProject(root, it->second);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root)
 {
   this->CurrentProject = root->GetProjectName();
   this->SetCurrentLocalGenerator(root);
   cmSystemTools::SplitPath(
-        this->CurrentLocalGenerator->GetCurrentSourceDirectory(),
-        this->ProjectSourceDirectoryComponents);
+    this->CurrentLocalGenerator->GetCurrentSourceDirectory(),
+    this->ProjectSourceDirectoryComponents);
   cmSystemTools::SplitPath(
-        this->CurrentLocalGenerator->GetCurrentBinaryDirectory(),
-        this->ProjectOutputDirectoryComponents);
+    this->CurrentLocalGenerator->GetCurrentBinaryDirectory(),
+    this->ProjectOutputDirectoryComponents);
 
-  this->CurrentXCodeHackMakefile =
-    root->GetCurrentBinaryDirectory();
+  this->CurrentXCodeHackMakefile = root->GetCurrentBinaryDirectory();
   this->CurrentXCodeHackMakefile += "/CMakeScripts";
   cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str());
   this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName,
-                                            std::string const& configName)
+std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(
+  std::string const& tName, std::string const& configName)
 {
   std::string target = tName;
-  cmSystemTools::ReplaceString(target, " ", "_");
+  std::replace(target.begin(), target.end(), ' ', '_');
   std::string out = "PostBuild." + target;
-  if(this->XcodeVersion > 20)
-    {
+  if (this->XcodeVersion > 20) {
     out += "." + configName;
-    }
+  }
   return out;
 }
 
-//----------------------------------------------------------------------------
 #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
-                                        std::vector<cmLocalGenerator*>& gens)
+void cmGlobalXCodeGenerator::AddExtraTargets(
+  cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens)
 {
   cmMakefile* mf = root->GetMakefile();
 
   // Add ALL_BUILD
   const char* no_working_directory = 0;
   std::vector<std::string> no_depends;
-  cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends,
-                        no_working_directory,
-                        "echo", "Build all projects");
+  cmTarget* allbuild =
+    mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory,
+                          "echo", "Build all projects");
 
   cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
   root->AddGeneratorTarget(allBuildGt);
@@ -472,114 +401,98 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
   // Add XCODE depend helper
   std::string dir = root->GetCurrentBinaryDirectory();
   cmCustomCommandLine makeHelper;
-  if(this->XcodeVersion < 50)
-    {
+  if (this->XcodeVersion < 50) {
     makeHelper.push_back("make");
     makeHelper.push_back("-C");
     makeHelper.push_back(dir.c_str());
     makeHelper.push_back("-f");
     makeHelper.push_back(this->CurrentXCodeHackMakefile.c_str());
     makeHelper.push_back(""); // placeholder, see below
-    }
+  }
 
   // Add ZERO_CHECK
   bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION");
-  if (regenerate)
-    {
+  if (regenerate) {
     this->CreateReRunCMakeFile(root, gens);
-    std::string file = this->ConvertToRelativeForMake(
-      this->CurrentReRunCMakeMakefile.c_str());
+    std::string file =
+      this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str());
     cmSystemTools::ReplaceString(file, "\\ ", " ");
-    cmTarget* check = mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET,
-                          true, no_depends,
-                          no_working_directory,
-                          "make", "-f", file.c_str());
+    cmTarget* check =
+      mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends,
+                            no_working_directory, "make", "-f", file.c_str());
 
     cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
     root->AddGeneratorTarget(checkGt);
-    }
+  }
 
   // now make the allbuild depend on all the non-utility targets
   // in the project
-  for(std::vector<cmLocalGenerator*>::iterator i = gens.begin();
-      i != gens.end(); ++i)
-    {
+  for (std::vector<cmLocalGenerator*>::iterator i = gens.begin();
+       i != gens.end(); ++i) {
     cmLocalGenerator* lg = *i;
-    if(this->IsExcluded(root, *i))
-      {
+    if (this->IsExcluded(root, *i)) {
       continue;
-      }
+    }
 
     std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
-    for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-        l != tgts.end(); l++)
-      {
+    for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+         l != tgts.end(); l++) {
       cmGeneratorTarget* target = *l;
 
-      if (target->GetType() == cmState::GLOBAL_TARGET)
-        {
+      if (target->GetType() == cmState::GLOBAL_TARGET) {
         continue;
-        }
+      }
 
       std::string targetName = target->GetName();
 
-      if (regenerate && (targetName != CMAKE_CHECK_BUILD_SYSTEM_TARGET))
-        {
+      if (regenerate && (targetName != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) {
         target->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
-        }
+      }
 
       // make all exe, shared libs and modules
       // run the depend check makefile as a post build rule
       // this will make sure that when the next target is built
       // things are up-to-date
-      if(!makeHelper.empty() &&
-         (target->GetType() == cmState::EXECUTABLE ||
-// Nope - no post-build for OBJECT_LIRBRARY
-//          target->GetType() == cmState::OBJECT_LIBRARY ||
-          target->GetType() == cmState::STATIC_LIBRARY ||
-          target->GetType() == cmState::SHARED_LIBRARY ||
-          target->GetType() == cmState::MODULE_LIBRARY))
-        {
-        makeHelper[makeHelper.size()-1] = // fill placeholder
+      if (!makeHelper.empty() &&
+          (target->GetType() == cmState::EXECUTABLE ||
+           // Nope - no post-build for OBJECT_LIRBRARY
+           //          target->GetType() == cmState::OBJECT_LIBRARY ||
+           target->GetType() == cmState::STATIC_LIBRARY ||
+           target->GetType() == cmState::SHARED_LIBRARY ||
+           target->GetType() == cmState::MODULE_LIBRARY)) {
+        makeHelper[makeHelper.size() - 1] = // fill placeholder
           this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
         cmCustomCommandLines commandLines;
         commandLines.push_back(makeHelper);
         std::vector<std::string> no_byproducts;
-        lg->GetMakefile()->AddCustomCommandToTarget(target->GetName(),
-                                                    no_byproducts,
-                                                    no_depends,
-                                                    commandLines,
-                                                    cmTarget::POST_BUILD,
-                                                    "Depend check for xcode",
-                                                    dir.c_str());
-        }
+        lg->GetMakefile()->AddCustomCommandToTarget(
+          target->GetName(), no_byproducts, no_depends, commandLines,
+          cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str());
+      }
 
-      if(target->GetType() != cmState::INTERFACE_LIBRARY
-          && !target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-        {
+      if (target->GetType() != cmState::INTERFACE_LIBRARY &&
+          !target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
         allbuild->AddUtility(target->GetName());
-        }
+      }
 
       // Refer to the build configuration file for easy editing.
       listfile = lg->GetCurrentSourceDirectory();
       listfile += "/";
       listfile += "CMakeLists.txt";
       target->AddSource(listfile.c_str());
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
   cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens)
 {
   std::vector<std::string> lfiles;
-  for(std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin();
-      gi != gens.end(); ++gi)
-    {
+  for (std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin();
+       gi != gens.end(); ++gi) {
     std::vector<std::string> const& lf = (*gi)->GetMakefile()->GetListFiles();
     lfiles.insert(lfiles.end(), lf.begin(), lf.end());
-    }
+  }
 
   // sort the array
   std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
@@ -590,51 +503,56 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
   this->CurrentReRunCMakeMakefile += "/CMakeScripts";
   cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str());
   this->CurrentReRunCMakeMakefile += "/ReRunCMake.make";
-  cmGeneratedFileStream makefileStream
-    (this->CurrentReRunCMakeMakefile.c_str());
+  cmGeneratedFileStream makefileStream(
+    this->CurrentReRunCMakeMakefile.c_str());
   makefileStream.SetCopyIfDifferent(true);
-  makefileStream << "# Generated by CMake, DO NOT EDIT\n";
+  makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
+
+  makefileStream << "empty:= \n";
+  makefileStream << "space:= $(empty) $(empty)\n";
+  makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
+
+  for (std::vector<std::string>::const_iterator i = lfiles.begin();
+       i != lfiles.end(); ++i) {
+    makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
+                   << this->ConvertToRelativeForMake(i->c_str()) << "))\n";
+  }
+
   std::string checkCache = root->GetBinaryDirectory();
   checkCache += "/";
   checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
   checkCache += "cmake.check_cache";
-  makefileStream << this->ConvertToRelativeForMake(checkCache.c_str())
-                 << ": ";
-  for(std::vector<std::string>::const_iterator i = lfiles.begin();
-      i !=  lfiles.end(); ++i)
-    {
-    makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str());
-    }
-  makefileStream << "\n\t" <<
-    this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str())
-                 << " -H" << this->ConvertToRelativeForMake(
-                   root->GetSourceDirectory())
-                 << " -B" << this->ConvertToRelativeForMake(
-                   root->GetBinaryDirectory()) << "\n";
-}
 
-//----------------------------------------------------------------------------
+  makefileStream << "\n"
+                 << this->ConvertToRelativeForMake(checkCache.c_str())
+                 << ": $(TARGETS)\n";
+  makefileStream << "\t"
+                 << this->ConvertToRelativeForMake(
+                      cmSystemTools::GetCMakeCommand().c_str())
+                 << " -H"
+                 << this->ConvertToRelativeForMake(root->GetSourceDirectory())
+                 << " -B"
+                 << this->ConvertToRelativeForMake(root->GetBinaryDirectory())
+                 << "\n";
+}
 
 static bool objectIdLessThan(cmXCodeObject* l, cmXCodeObject* r)
 {
   return l->GetId() < r->GetId();
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::SortXCodeObjects()
 {
   std::sort(this->XCodeObjects.begin(), this->XCodeObjects.end(),
             objectIdLessThan);
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::ClearXCodeObjects()
 {
   this->TargetDoneSet.clear();
-  for(unsigned int i = 0; i < this->XCodeObjects.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->XCodeObjects.size(); ++i) {
     delete this->XCodeObjects[i];
-    }
+  }
   this->XCodeObjects.clear();
   this->XCodeObjectIDs.clear();
   this->XCodeObjectMap.clear();
@@ -644,83 +562,68 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
   this->FileRefs.clear();
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj)
+void cmGlobalXCodeGenerator::addObject(cmXCodeObject* obj)
 {
-  if(obj->GetType() == cmXCodeObject::OBJECT)
-    {
+  if (obj->GetType() == cmXCodeObject::OBJECT) {
     std::string id = obj->GetId();
 
     // If this is a duplicate id, it's an error:
     //
-    if(this->XCodeObjectIDs.count(id))
-      {
+    if (this->XCodeObjectIDs.count(id)) {
       cmSystemTools::Error(
         "Xcode generator: duplicate object ids not allowed");
-      }
+    }
 
     this->XCodeObjectIDs.insert(id);
-    }
+  }
 
   this->XCodeObjects.push_back(obj);
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(
+  cmXCodeObject::PBXType ptype)
 {
   cmXCodeObject* obj;
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     obj = new cmXCodeObject(ptype, cmXCodeObject::OBJECT);
-    }
-  else
-    {
+  } else {
     obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT);
-    }
+  }
   this->addObject(obj);
   return obj;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
 {
   cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type);
   this->addObject(obj);
   return obj;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateString(const std::string& s)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateString(const std::string& s)
 {
   cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING);
   obj->SetString(s);
   return obj;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator
-::CreateObjectReference(cmXCodeObject* ref)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateObjectReference(
+  cmXCodeObject* ref)
 {
   cmXCodeObject* obj = this->CreateObject(cmXCodeObject::OBJECT_REF);
   obj->SetObject(ref);
   return obj;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator
-::CreateFlatClone(cmXCodeObject* orig)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateFlatClone(cmXCodeObject* orig)
 {
   cmXCodeObject* obj = this->CreateObject(orig->GetType());
   obj->CopyAttributes(orig);
   return obj;
 }
 
-//----------------------------------------------------------------------------
-std::string
-GetGroupMapKeyFromPath(cmGeneratorTarget* target, const std::string& fullpath)
+std::string GetGroupMapKeyFromPath(cmGeneratorTarget* target,
+                                   const std::string& fullpath)
 {
   std::string key(target->GetName());
   key += "-";
@@ -728,20 +631,14 @@ GetGroupMapKeyFromPath(cmGeneratorTarget* target, const std::string& fullpath)
   return key;
 }
 
-//----------------------------------------------------------------------------
-std::string
-GetGroupMapKey(cmGeneratorTarget* target, cmSourceFile* sf)
+std::string GetGroupMapKey(cmGeneratorTarget* target, cmSourceFile* sf)
 {
   return GetGroupMapKeyFromPath(target, sf->GetFullPath());
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
-  const std::string &fullpath,
-  cmGeneratorTarget* target,
-  const std::string &lang,
-  cmSourceFile* sf)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
+  const std::string& fullpath, cmGeneratorTarget* target,
+  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.
@@ -756,170 +653,127 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
   return buildFile;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
-                                              cmSourceFile* sf,
-                                              cmGeneratorTarget* gtgt)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
+  cmLocalGenerator* lg, cmSourceFile* sf, cmGeneratorTarget* gtgt)
 {
   // Add flags from target and source file properties.
   std::string flags;
   const char* srcfmt = sf->GetProperty("Fortran_FORMAT");
-  switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt))
-    {
-    case cmLocalGenerator::FortranFormatFixed: flags="-fixed "+flags; break;
-    case cmLocalGenerator::FortranFormatFree: flags="-free "+flags; break;
-    default: break;
-    }
+  switch (this->CurrentLocalGenerator->GetFortranFormat(srcfmt)) {
+    case cmOutputConverter::FortranFormatFixed:
+      flags = "-fixed " + flags;
+      break;
+    case cmOutputConverter::FortranFormatFree:
+      flags = "-free " + flags;
+      break;
+    default:
+      break;
+  }
   lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS"));
 
   // Add per-source definitions.
   BuildObjectListOrString flagsBuild(this, false);
-  this->AppendDefines(flagsBuild,
-                      sf->GetProperty("COMPILE_DEFINITIONS"), true);
-  if (!flagsBuild.IsEmpty())
-    {
-    if (!flags.empty())
-      {
+  this->AppendDefines(flagsBuild, sf->GetProperty("COMPILE_DEFINITIONS"),
+                      true);
+  if (!flagsBuild.IsEmpty()) {
+    if (!flags.empty()) {
       flags += ' ';
-      }
-    flags += flagsBuild.GetString();
     }
+    flags += flagsBuild.GetString();
+  }
 
-  std::string lang =
-    this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
+  std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
 
   cmXCodeObject* buildFile =
     this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), gtgt, lang, sf);
   cmXCodeObject* fileRef = buildFile->GetObject("fileRef")->GetObject();
 
-  cmXCodeObject* settings =
-    this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
-  settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str()));
+  cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
+  settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags));
 
   // Is this a resource file in this target? Add it to the resources group...
   //
 
   cmGeneratorTarget::SourceFileFlags tsFlags =
-      gtgt->GetTargetSourceFileFlags(sf);
+    gtgt->GetTargetSourceFileFlags(sf);
   bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource;
 
   // Is this a "private" or "public" framework header file?
   // Set the ATTRIBUTES attribute appropriately...
   //
-  if(gtgt->IsFrameworkOnApple())
-    {
-    if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader)
-      {
+  if (gtgt->IsFrameworkOnApple()) {
+    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 == cmGeneratorTarget::SourceFileTypePublicHeader)
-      {
+    } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader) {
       cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
       attrs->AddObject(this->CreateString("Public"));
       settings->AddAttribute("ATTRIBUTES", attrs);
       isResource = true;
-      }
     }
+  }
 
   // Add the fileRef to the top level Resources group/folder if it is not
   // already there.
   //
-  if(isResource && this->ResourcesGroupChildren &&
-    !this->ResourcesGroupChildren->HasObject(fileRef))
-    {
+  if (isResource && this->ResourcesGroupChildren &&
+      !this->ResourcesGroupChildren->HasObject(fileRef)) {
     this->ResourcesGroupChildren->AddObject(fileRef);
-    }
+  }
 
   buildFile->AddAttribute("settings", settings);
   return buildFile;
 }
 
-//----------------------------------------------------------------------------
-std::string
-GetSourcecodeValueFromFileExtension(const std::string& _ext,
-                                    const std::string& lang,
-                                    bool& keepLastKnownFileType)
+std::string GetSourcecodeValueFromFileExtension(const std::string& _ext,
+                                                const std::string& lang,
+                                                bool& keepLastKnownFileType)
 {
   std::string ext = cmSystemTools::LowerCase(_ext);
   std::string sourcecode = "sourcecode";
 
-  if(ext == "o")
-    {
+  if (ext == "o") {
     sourcecode = "compiled.mach-o.objfile";
-    }
-  else if(ext == "xctest")
-    {
+  } else if (ext == "xctest") {
     sourcecode = "wrapper.cfbundle";
-    }
-  else if(ext == "xib")
-    {
+  } else if (ext == "xib") {
     keepLastKnownFileType = true;
     sourcecode = "file.xib";
-    }
-  else if(ext == "storyboard")
-    {
+  } else if (ext == "storyboard") {
     keepLastKnownFileType = true;
     sourcecode = "file.storyboard";
-    }
-  else if(ext == "mm")
-    {
+  } else if (ext == "mm") {
     sourcecode += ".cpp.objcpp";
-    }
-  else if(ext == "m")
-    {
+  } else if (ext == "m") {
     sourcecode += ".c.objc";
-    }
-  else if (ext == "swift")
-    {
+  } else if (ext == "swift") {
     sourcecode += ".swift";
-    }
-  else if(ext == "plist")
-    {
+  } else if (ext == "plist") {
     sourcecode += ".text.plist";
-    }
-  else if(ext == "h")
-    {
+  } else if (ext == "h") {
     sourcecode += ".c.h";
-    }
-  else if(ext == "hxx" || ext == "hpp" || ext == "txx"
-    || ext == "pch" || ext == "hh")
-    {
+  } else if (ext == "hxx" || ext == "hpp" || ext == "txx" || ext == "pch" ||
+             ext == "hh") {
     sourcecode += ".cpp.h";
-    }
-  else if(ext == "png" || ext == "gif" || ext == "jpg")
-    {
+  } else if (ext == "png" || ext == "gif" || ext == "jpg") {
     keepLastKnownFileType = true;
     sourcecode = "image";
-    }
-  else if(ext == "txt")
-    {
+  } else if (ext == "txt") {
     sourcecode += ".text";
-    }
-  else if(lang == "CXX")
-    {
+  } else if (lang == "CXX") {
     sourcecode += ".cpp.cpp";
-    }
-  else if(lang == "C")
-    {
+  } else if (lang == "C") {
     sourcecode += ".c.c";
-    }
-  else if(lang == "Fortran")
-    {
+  } else if (lang == "Fortran") {
     sourcecode += ".fortran.f90";
-    }
-  else if(lang == "ASM")
-    {
+  } else if (lang == "ASM") {
     sourcecode += ".asm";
-    }
-  else if (ext == "metal")
-    {
+  } else if (ext == "metal") {
     sourcecode += ".metal";
-    }
-  //else
+  }
+  // else
   //  {
   //  // Already specialized above or we leave sourcecode == "sourcecode"
   //  // which is probably the most correct choice. Extensionless headers,
@@ -930,138 +784,113 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext,
   return sourcecode;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
-  const std::string &fullpath,
-  cmGeneratorTarget* target,
-  const std::string &lang,
-  cmSourceFile* sf)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
+  const std::string& fullpath, cmGeneratorTarget* target,
+  const std::string& lang, cmSourceFile* sf)
 {
   std::string key = GetGroupMapKeyFromPath(target, fullpath);
   cmXCodeObject* fileRef = this->FileRefs[key];
-  if(!fileRef)
-    {
+  if (!fileRef) {
     fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
     fileRef->SetComment(fullpath);
     this->FileRefs[key] = fileRef;
-    }
+  }
   cmXCodeObject* group = this->GroupMap[key];
   cmXCodeObject* children = group->GetObject("children");
-  if (!children->HasObject(fileRef))
-    {
+  if (!children->HasObject(fileRef)) {
     children->AddObject(fileRef);
-    }
+  }
   fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
 
   bool useLastKnownFileType = false;
   std::string fileType;
-  if(sf)
-    {
-    if(const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE"))
-      {
+  if (sf) {
+    if (const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
       fileType = e;
-      }
-    else if(const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE"))
-      {
+    } else if (const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE")) {
       useLastKnownFileType = true;
       fileType = l;
-      }
     }
-  if(fileType.empty())
-    {
+  }
+  if (fileType.empty()) {
     // Compute the extension without leading '.'.
     std::string ext = cmSystemTools::GetFilenameLastExtension(fullpath);
-    if(!ext.empty())
-      {
+    if (!ext.empty()) {
       ext = ext.substr(1);
-      }
+    }
 
     // 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 = (ext == "xcassets"? "folder.assetcatalog" : "folder");
+    if (cmSystemTools::FileIsDirectory(fullpath.c_str())) {
+      fileType = (ext == "xcassets" ? "folder.assetcatalog" : "folder");
       useLastKnownFileType = true;
-      }
-    else
-      {
-      fileType = GetSourcecodeValueFromFileExtension(
-        ext, lang, useLastKnownFileType);
-      }
+    } else {
+      fileType =
+        GetSourcecodeValueFromFileExtension(ext, lang, useLastKnownFileType);
     }
+  }
 
-  fileRef->AddAttribute(useLastKnownFileType? "lastKnownFileType"
-                                            : "explicitFileType",
+  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());
   std::string name = cmSystemTools::GetFilenameName(path.c_str());
-  const char* sourceTree = (cmSystemTools::FileIsFullPath(path.c_str())?
-                            "<absolute>" : "SOURCE_ROOT");
-  fileRef->AddAttribute("name", this->CreateString(name.c_str()));
-  fileRef->AddAttribute("path", this->CreateString(path.c_str()));
+  const char* sourceTree =
+    (cmSystemTools::FileIsFullPath(path.c_str()) ? "<absolute>"
+                                                 : "SOURCE_ROOT");
+  fileRef->AddAttribute("name", this->CreateString(name));
+  fileRef->AddAttribute("path", this->CreateString(path));
   fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     fileRef->AddAttribute("refType", this->CreateString("4"));
-    }
+  }
   return fileRef;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
-                                                 cmGeneratorTarget* target)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference(
+  cmSourceFile* sf, cmGeneratorTarget* target)
 {
-  std::string lang =
-    this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
+  std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
 
-  return this->CreateXCodeFileReferenceFromPath(
-    sf->GetFullPath(), target, lang, sf);
+  return this->CreateXCodeFileReferenceFromPath(sf->GetFullPath(), target,
+                                                lang, sf);
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname)
 {
-  if(tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" ||
-     tname == "install" || tname == "package" || tname == "RUN_TESTS" ||
-     tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET )
-    {
-    if(this->TargetDoneSet.find(tname) != this->TargetDoneSet.end())
-      {
+  if (tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" ||
+      tname == "install" || tname == "package" || tname == "RUN_TESTS" ||
+      tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+    if (this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) {
       return true;
-      }
+    }
     this->TargetDoneSet.insert(tname);
     return false;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
 {
   this->CurrentLocalGenerator = gen;
   this->CurrentMakefile = gen->GetMakefile();
-  std::string outdir =
-    cmSystemTools::CollapseFullPath(this->CurrentLocalGenerator->
-                                    GetCurrentBinaryDirectory());
+  std::string outdir = cmSystemTools::CollapseFullPath(
+    this->CurrentLocalGenerator->GetCurrentBinaryDirectory());
   cmSystemTools::SplitPath(outdir.c_str(),
                            this->CurrentOutputDirectoryComponents);
 
   // Select the current set of configuration types.
   this->CurrentConfigurationTypes.clear();
   this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes);
-  if(this->CurrentConfigurationTypes.empty())
-    {
+  if (this->CurrentConfigurationTypes.empty()) {
     this->CurrentConfigurationTypes.push_back("");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 struct cmSourceFilePathCompare
 {
   bool operator()(cmSourceFile* l, cmSourceFile* r)
@@ -1070,76 +899,63 @@ struct cmSourceFilePathCompare
   }
 };
 
-//----------------------------------------------------------------------------
 struct cmCompareTargets
 {
-  bool operator () (std::string const& a, std::string const& b) const
+  bool operator()(std::string const& a, std::string const& b) const
   {
-    if (a == "ALL_BUILD")
-      {
+    if (a == "ALL_BUILD") {
       return true;
-      }
-    if (b == "ALL_BUILD")
-      {
+    }
+    if (b == "ALL_BUILD") {
       return false;
-      }
+    }
     return strcmp(a.c_str(), b.c_str()) < 0;
   }
 };
 
-//----------------------------------------------------------------------------
-bool
-cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
-                                           std::vector<cmXCodeObject*>&
-                                           targets)
+bool cmGlobalXCodeGenerator::CreateXCodeTargets(
+  cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets)
 {
   this->SetCurrentLocalGenerator(gen);
   std::vector<cmGeneratorTarget*> tgts =
-      this->CurrentLocalGenerator->GetGeneratorTargets();
+    this->CurrentLocalGenerator->GetGeneratorTargets();
   typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets>
-      cmSortedTargets;
+    cmSortedTargets;
   cmSortedTargets sortedTargets;
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); l++)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+       l != tgts.end(); l++) {
     sortedTargets[(*l)->GetName()] = *l;
-    }
-  for(cmSortedTargets::iterator l = sortedTargets.begin();
-      l != sortedTargets.end(); l++)
-    {
+  }
+  for (cmSortedTargets::iterator l = sortedTargets.begin();
+       l != sortedTargets.end(); l++) {
     cmGeneratorTarget* gtgt = l->second;
 
     std::string targetName = gtgt->GetName();
 
     // make sure ALL_BUILD, INSTALL, etc are only done once
-    if(this->SpecialTargetEmitted(targetName.c_str()))
-      {
+    if (this->SpecialTargetEmitted(targetName.c_str())) {
       continue;
-      }
+    }
 
-    if(gtgt->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
 
-    if(gtgt->GetType() == cmState::UTILITY ||
-       gtgt->GetType() == cmState::GLOBAL_TARGET)
-      {
+    if (gtgt->GetType() == cmState::UTILITY ||
+        gtgt->GetType() == cmState::GLOBAL_TARGET) {
       cmXCodeObject* t = this->CreateUtilityTarget(gtgt);
-      if (!t)
-        {
+      if (!t) {
         return false;
-        }
+      }
       targets.push_back(t);
       continue;
-      }
+    }
 
     // organize the sources
     std::vector<cmSourceFile*> classes;
-    if (!gtgt->GetConfigCommonSourceFiles(classes))
-      {
+    if (!gtgt->GetConfigCommonSourceFiles(classes)) {
       return false;
-      }
+    }
     std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
 
     gtgt->ComputeObjectMapping();
@@ -1148,66 +964,53 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
     std::vector<cmXCodeObject*> headerFiles;
     std::vector<cmXCodeObject*> resourceFiles;
     std::vector<cmXCodeObject*> sourceFiles;
-    for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-        i != classes.end(); ++i)
-      {
+    for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
+         i != classes.end(); ++i) {
       cmXCodeObject* xsf =
-        this->CreateXCodeSourceFile(this->CurrentLocalGenerator,
-                                    *i, gtgt);
+        this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *i, gtgt);
       cmXCodeObject* fr = xsf->GetObject("fileRef");
-      cmXCodeObject* filetype =
-        fr->GetObject()->GetObject("explicitFileType");
+      cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType");
 
       cmGeneratorTarget::SourceFileFlags tsFlags =
         gtgt->GetTargetSourceFileFlags(*i);
 
-      if(filetype &&
-         filetype->GetString() == "compiled.mach-o.objfile")
-        {
-        if ((*i)->GetObjectLibrary().empty())
-          {
+      if (filetype && filetype->GetString() == "compiled.mach-o.objfile") {
+        if ((*i)->GetObjectLibrary().empty()) {
           externalObjFiles.push_back(xsf);
-          }
         }
-      else if(this->IsHeaderFile(*i) ||
-        (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) ||
-        (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader))
-        {
+      } else if (this->IsHeaderFile(*i) ||
+                 (tsFlags.Type ==
+                  cmGeneratorTarget::SourceFileTypePrivateHeader) ||
+                 (tsFlags.Type ==
+                  cmGeneratorTarget::SourceFileTypePublicHeader)) {
         headerFiles.push_back(xsf);
-        }
-      else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource)
-        {
+      } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) {
         resourceFiles.push_back(xsf);
-        }
-      else if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY"))
-        {
+      } else if (!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) {
         // 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).empty() &&
-           !this->IgnoreFile((*i)->GetExtension().c_str()))
-          {
+        if (!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() &&
+            !this->IgnoreFile((*i)->GetExtension().c_str())) {
           sourceFiles.push_back(xsf);
-          }
         }
       }
+    }
 
-    if(this->XcodeVersion < 50)
-      {
+    if (this->XcodeVersion < 50) {
       // Add object library contents as external objects. (Equivalent to
       // the externalObjFiles above, except each one is not a cmSourceFile
       // within the target.)
       std::vector<std::string> objs;
       gtgt->UseObjectLibraries(objs, "");
-      for(std::vector<std::string>::const_iterator
-            oi = objs.begin(); oi != objs.end(); ++oi)
-        {
+      for (std::vector<std::string>::const_iterator oi = objs.begin();
+           oi != objs.end(); ++oi) {
         std::string obj = *oi;
         cmXCodeObject* xsf =
           this->CreateXCodeSourceFileFromPath(obj, gtgt, "", 0);
         externalObjFiles.push_back(xsf);
-        }
       }
+    }
 
     // some build phases only apply to bundles and/or frameworks
     bool isFrameworkTarget = gtgt->IsFrameworkOnApple();
@@ -1218,126 +1021,110 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
 
     // create source build phase
     cmXCodeObject* sourceBuildPhase = 0;
-    if (!sourceFiles.empty())
-      {
+    if (!sourceFiles.empty()) {
       sourceBuildPhase =
         this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase);
       sourceBuildPhase->SetComment("Sources");
       sourceBuildPhase->AddAttribute("buildActionMask",
                                      this->CreateString("2147483647"));
       buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
-      for(std::vector<cmXCodeObject*>::iterator i = sourceFiles.begin();
-          i != sourceFiles.end(); ++i)
-        {
+      for (std::vector<cmXCodeObject*>::iterator i = sourceFiles.begin();
+           i != sourceFiles.end(); ++i) {
         buildFiles->AddObject(*i);
-        }
+      }
       sourceBuildPhase->AddAttribute("files", buildFiles);
       sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
                                      this->CreateString("0"));
-      }
+    }
 
     // create header build phase - only for framework targets
     cmXCodeObject* headerBuildPhase = 0;
-    if (!headerFiles.empty() && isFrameworkTarget)
-      {
+    if (!headerFiles.empty() && isFrameworkTarget) {
       headerBuildPhase =
         this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase);
       headerBuildPhase->SetComment("Headers");
       headerBuildPhase->AddAttribute("buildActionMask",
                                      this->CreateString("2147483647"));
       buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
-      for(std::vector<cmXCodeObject*>::iterator i = headerFiles.begin();
-          i != headerFiles.end(); ++i)
-        {
+      for (std::vector<cmXCodeObject*>::iterator i = headerFiles.begin();
+           i != headerFiles.end(); ++i) {
         buildFiles->AddObject(*i);
-        }
+      }
       headerBuildPhase->AddAttribute("files", buildFiles);
       headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
                                      this->CreateString("0"));
-      }
+    }
 
     // create resource build phase - only for framework or bundle targets
     cmXCodeObject* resourceBuildPhase = 0;
     if (!resourceFiles.empty() &&
-        (isFrameworkTarget || isBundleTarget || isCFBundleTarget))
-      {
+        (isFrameworkTarget || isBundleTarget || isCFBundleTarget)) {
       resourceBuildPhase =
         this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
       resourceBuildPhase->SetComment("Resources");
       resourceBuildPhase->AddAttribute("buildActionMask",
                                        this->CreateString("2147483647"));
       buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
-      for(std::vector<cmXCodeObject*>::iterator i = resourceFiles.begin();
-          i != resourceFiles.end(); ++i)
-        {
+      for (std::vector<cmXCodeObject*>::iterator i = resourceFiles.begin();
+           i != resourceFiles.end(); ++i) {
         buildFiles->AddObject(*i);
-        }
+      }
       resourceBuildPhase->AddAttribute("files", buildFiles);
       resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
-                                     this->CreateString("0"));
-      }
+                                       this->CreateString("0"));
+    }
 
     // create vector of "non-resource content file" build phases - only for
     // framework or bundle targets
     std::vector<cmXCodeObject*> contentBuildPhases;
-    if (isFrameworkTarget || isBundleTarget || isCFBundleTarget)
-      {
+    if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
       typedef std::map<std::string, std::vector<cmSourceFile*> >
         mapOfVectorOfSourceFiles;
       mapOfVectorOfSourceFiles bundleFiles;
-      for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-          i != classes.end(); ++i)
-        {
+      for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
+           i != classes.end(); ++i) {
         cmGeneratorTarget::SourceFileFlags tsFlags =
           gtgt->GetTargetSourceFileFlags(*i);
-        if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent)
-          {
+        if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) {
           bundleFiles[tsFlags.MacFolder].push_back(*i);
-          }
         }
+      }
       mapOfVectorOfSourceFiles::iterator mit;
-      for ( mit = bundleFiles.begin(); mit != bundleFiles.end(); ++ mit )
-        {
+      for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) {
         cmXCodeObject* copyFilesBuildPhase =
           this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
         copyFilesBuildPhase->SetComment("Copy files");
         copyFilesBuildPhase->AddAttribute("buildActionMask",
-          this->CreateString("2147483647"));
+                                          this->CreateString("2147483647"));
         copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
-          this->CreateString("6"));
+                                          this->CreateString("6"));
         std::ostringstream ostr;
-        if (gtgt->IsFrameworkOnApple())
-          {
+        if (gtgt->IsFrameworkOnApple()) {
           // dstPath in frameworks is relative to Versions/<version>
           ostr << mit->first;
-          }
-        else if ( mit->first != "MacOS" )
-          {
+        } else if (mit->first != "MacOS") {
           // dstPath in bundles is relative to Contents/MacOS
           ostr << "../" << mit->first.c_str();
-          }
+        }
         copyFilesBuildPhase->AddAttribute("dstPath",
-          this->CreateString(ostr.str().c_str()));
-        copyFilesBuildPhase->AddAttribute(
-          "runOnlyForDeploymentPostprocessing", this->CreateString("0"));
+                                          this->CreateString(ostr.str()));
+        copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+                                          this->CreateString("0"));
         buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
         copyFilesBuildPhase->AddAttribute("files", buildFiles);
         std::vector<cmSourceFile*>::iterator sfIt;
-        for ( sfIt = mit->second.begin(); sfIt != mit->second.end(); ++ sfIt )
-          {
-          cmXCodeObject* xsf =
-            this->CreateXCodeSourceFile(this->CurrentLocalGenerator,
-                                        *sfIt, gtgt);
+        for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) {
+          cmXCodeObject* xsf = this->CreateXCodeSourceFile(
+            this->CurrentLocalGenerator, *sfIt, gtgt);
           buildFiles->AddObject(xsf);
-          }
-        contentBuildPhases.push_back(copyFilesBuildPhase);
         }
+        contentBuildPhases.push_back(copyFilesBuildPhase);
       }
+    }
 
     // create framework build phase
     cmXCodeObject* frameworkBuildPhase = 0;
-    if (!externalObjFiles.empty())
-      {
+    if (!externalObjFiles.empty()) {
       frameworkBuildPhase =
         this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase);
       frameworkBuildPhase->SetComment("Frameworks");
@@ -1345,68 +1132,63 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
                                         this->CreateString("2147483647"));
       buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
       frameworkBuildPhase->AddAttribute("files", buildFiles);
-      for(std::vector<cmXCodeObject*>::iterator i =  externalObjFiles.begin();
-          i != externalObjFiles.end(); ++i)
-        {
+      for (std::vector<cmXCodeObject*>::iterator i = externalObjFiles.begin();
+           i != externalObjFiles.end(); ++i) {
         buildFiles->AddObject(*i);
-        }
+      }
       frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
                                         this->CreateString("0"));
-      }
+    }
 
     // create list of build phases and create the Xcode target
     cmXCodeObject* buildPhases =
       this->CreateObject(cmXCodeObject::OBJECT_LIST);
 
-    this->CreateCustomCommands(buildPhases, sourceBuildPhase,
-                               headerBuildPhase, resourceBuildPhase,
-                               contentBuildPhases,
+    this->CreateCustomCommands(buildPhases, sourceBuildPhase, headerBuildPhase,
+                               resourceBuildPhase, contentBuildPhases,
                                frameworkBuildPhase, gtgt);
 
     targets.push_back(this->CreateXCodeTarget(gtgt, buildPhases));
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::ForceLinkerLanguages()
 {
-  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
     std::vector<cmGeneratorTarget*> tgts =
-        this->LocalGenerators[i]->GetGeneratorTargets();
+      this->LocalGenerators[i]->GetGeneratorTargets();
     // All targets depend on the build-system check target.
-    for(std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
-        ti != tgts.end(); ++ti)
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
+         ti != tgts.end(); ++ti) {
       // This makes sure all targets link using the proper language.
       this->ForceLinkerLanguage(*ti);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
 {
   // This matters only for targets that link.
-  if(gtgt->GetType() != cmState::EXECUTABLE &&
-     gtgt->GetType() != cmState::SHARED_LIBRARY &&
-     gtgt->GetType() != cmState::MODULE_LIBRARY)
-    {
+  if (gtgt->GetType() != cmState::EXECUTABLE &&
+      gtgt->GetType() != cmState::SHARED_LIBRARY &&
+      gtgt->GetType() != cmState::MODULE_LIBRARY) {
     return;
-    }
+  }
 
   std::string llang = gtgt->GetLinkerLanguage("NOCONFIG");
-  if(llang.empty()) { return; }
+  if (llang.empty()) {
+    return;
+  }
 
   // If the language is compiled as a source trust Xcode to link with it.
-  cmLinkImplementation const* impl =
-    gtgt->GetLinkImplementation("NOCONFIG");
-  for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
-      li != impl->Languages.end(); ++li)
-    {
-    if(*li == llang) { return; }
+  cmLinkImplementation const* impl = gtgt->GetLinkImplementation("NOCONFIG");
+  for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
+       li != impl->Languages.end(); ++li) {
+    if (*li == llang) {
+      return;
     }
+  }
 
   // Add an empty source file to the target that compiles with the
   // linker language.  This should convince Xcode to choose the proper
@@ -1420,17 +1202,15 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
   fname += ".";
   fname += cmSystemTools::LowerCase(llang);
   {
-  cmGeneratedFileStream fout(fname.c_str());
-  fout << "\n";
+    cmGeneratedFileStream fout(fname.c_str());
+    fout << "\n";
   }
-  if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str()))
-    {
+  if (cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) {
     sf->SetProperty("LANGUAGE", llang.c_str());
     gtgt->AddSource(fname);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
 {
   const std::vector<std::string>& hdrExts =
@@ -1439,59 +1219,39 @@ bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
           hdrExts.end());
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateBuildPhase(const char* name,
-                                         const char* name2,
-                                         cmGeneratorTarget* target,
-                                         const std::vector<cmCustomCommand>&
-                                         commands)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase(
+  const char* name, const char* name2, cmGeneratorTarget* target,
+  const std::vector<cmCustomCommand>& commands)
 {
-  if(commands.size() == 0 && strcmp(name, "CMake ReRun") != 0)
-    {
+  if (commands.size() == 0 && strcmp(name, "CMake ReRun") != 0) {
     return 0;
-    }
+  }
   cmXCodeObject* buildPhase =
     this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase);
   buildPhase->AddAttribute("buildActionMask",
                            this->CreateString("2147483647"));
   cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   buildPhase->AddAttribute("files", buildFiles);
-  buildPhase->AddAttribute("name",
-                           this->CreateString(name));
+  buildPhase->AddAttribute("name", this->CreateString(name));
   buildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
                            this->CreateString("0"));
-  buildPhase->AddAttribute("shellPath",
-                           this->CreateString("/bin/sh"));
-  this->AddCommandsToBuildPhase(buildPhase, target, commands,
-                                name2);
+  buildPhase->AddAttribute("shellPath", this->CreateString("/bin/sh"));
+  this->AddCommandsToBuildPhase(buildPhase, target, commands, name2);
   return buildPhase;
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
-                                                  cmXCodeObject*
-                                                  sourceBuildPhase,
-                                                  cmXCodeObject*
-                                                  headerBuildPhase,
-                                                  cmXCodeObject*
-                                                  resourceBuildPhase,
-                                                  std::vector<cmXCodeObject*>
-                                                  contentBuildPhases,
-                                                  cmXCodeObject*
-                                                  frameworkBuildPhase,
-                                                  cmGeneratorTarget* gtgt)
+void cmGlobalXCodeGenerator::CreateCustomCommands(
+  cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
+  cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
+  std::vector<cmXCodeObject*> contentBuildPhases,
+  cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt)
 {
-  std::vector<cmCustomCommand> const & prebuild
-    = gtgt->GetPreBuildCommands();
-  std::vector<cmCustomCommand> const & prelink
-    = gtgt->GetPreLinkCommands();
-  std::vector<cmCustomCommand> postbuild
-    = gtgt->GetPostBuildCommands();
-
-  if(gtgt->GetType() == cmState::SHARED_LIBRARY &&
-    !gtgt->IsFrameworkOnApple())
-    {
+  std::vector<cmCustomCommand> const& prebuild = gtgt->GetPreBuildCommands();
+  std::vector<cmCustomCommand> const& prelink = gtgt->GetPreLinkCommands();
+  std::vector<cmCustomCommand> postbuild = gtgt->GetPostBuildCommands();
+
+  if (gtgt->GetType() == cmState::SHARED_LIBRARY &&
+      !gtgt->IsFrameworkOnApple()) {
     cmCustomCommandLines cmd;
     cmd.resize(1);
     cmd[0].push_back(cmSystemTools::GetCMakeCommand());
@@ -1510,95 +1270,74 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
     cmd[0].push_back(str_so_file);
     cmd[0].push_back(str_link_file);
 
-    cmCustomCommand command(this->CurrentMakefile,
-      std::vector<std::string>(),
-      std::vector<std::string>(),
-      std::vector<std::string>(),
-      cmd,
-      "Creating symlinks",
-      "");
+    cmCustomCommand command(this->CurrentMakefile, std::vector<std::string>(),
+                            std::vector<std::string>(),
+                            std::vector<std::string>(), cmd,
+                            "Creating symlinks", "");
 
     postbuild.push_back(command);
-    }
+  }
 
   std::vector<cmSourceFile*> classes;
-  if (!gtgt->GetConfigCommonSourceFiles(classes))
-    {
+  if (!gtgt->GetConfigCommonSourceFiles(classes)) {
     return;
-    }
+  }
   // add all the sources
   std::vector<cmCustomCommand> commands;
-  for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-      i != classes.end(); ++i)
-    {
-    if((*i)->GetCustomCommand())
-      {
+  for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
+       i != classes.end(); ++i) {
+    if ((*i)->GetCustomCommand()) {
       commands.push_back(*(*i)->GetCustomCommand());
-      }
     }
+  }
   // create prebuild phase
-  cmXCodeObject* cmakeRulesBuildPhase =
-    this->CreateBuildPhase("CMake Rules",
-                           "cmakeRulesBuildPhase",
-                           gtgt, commands);
+  cmXCodeObject* cmakeRulesBuildPhase = this->CreateBuildPhase(
+    "CMake Rules", "cmakeRulesBuildPhase", gtgt, commands);
   // create prebuild phase
-  cmXCodeObject* preBuildPhase =
-    this->CreateBuildPhase("CMake PreBuild Rules", "preBuildCommands",
-                           gtgt, prebuild);
+  cmXCodeObject* preBuildPhase = this->CreateBuildPhase(
+    "CMake PreBuild Rules", "preBuildCommands", gtgt, prebuild);
   // create prelink phase
-  cmXCodeObject* preLinkPhase =
-    this->CreateBuildPhase("CMake PreLink Rules", "preLinkCommands",
-                           gtgt, prelink);
+  cmXCodeObject* preLinkPhase = this->CreateBuildPhase(
+    "CMake PreLink Rules", "preLinkCommands", gtgt, prelink);
   // create postbuild phase
-  cmXCodeObject* postBuildPhase =
-    this->CreateBuildPhase("CMake PostBuild Rules", "postBuildPhase",
-                           gtgt, postbuild);
+  cmXCodeObject* postBuildPhase = this->CreateBuildPhase(
+    "CMake PostBuild Rules", "postBuildPhase", gtgt, postbuild);
 
   // The order here is the order they will be built in.
   // The order "headers, resources, sources" mimics a native project generated
   // from an xcode template...
   //
-  if(preBuildPhase)
-    {
+  if (preBuildPhase) {
     buildPhases->AddObject(preBuildPhase);
-    }
-  if(cmakeRulesBuildPhase)
-    {
+  }
+  if (cmakeRulesBuildPhase) {
     buildPhases->AddObject(cmakeRulesBuildPhase);
-    }
-  if(headerBuildPhase)
-    {
+  }
+  if (headerBuildPhase) {
     buildPhases->AddObject(headerBuildPhase);
-    }
-  if(resourceBuildPhase)
-    {
+  }
+  if (resourceBuildPhase) {
     buildPhases->AddObject(resourceBuildPhase);
-    }
+  }
   std::vector<cmXCodeObject*>::iterator cit;
   for (cit = contentBuildPhases.begin(); cit != contentBuildPhases.end();
-       ++cit)
-    {
+       ++cit) {
     buildPhases->AddObject(*cit);
-    }
-  if(sourceBuildPhase)
-    {
+  }
+  if (sourceBuildPhase) {
     buildPhases->AddObject(sourceBuildPhase);
-    }
-  if(preLinkPhase)
-    {
+  }
+  if (preLinkPhase) {
     buildPhases->AddObject(preLinkPhase);
-    }
-  if(frameworkBuildPhase)
-    {
+  }
+  if (frameworkBuildPhase) {
     buildPhases->AddObject(frameworkBuildPhase);
-    }
-  if(postBuildPhase)
-    {
+  }
+  if (postBuildPhase) {
     buildPhases->AddObject(postBuildPhase);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 // This function removes each occurrence of the flag and returns the last one
 // (i.e., the dominant flag in GCC)
 std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
@@ -1607,32 +1346,28 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag,
   std::string retFlag;
   std::string::size_type lastOccurancePos = flags.rfind(flag);
   bool saved = false;
-  while(lastOccurancePos != flags.npos)
-    {
-    //increment pos, we use lastOccurancePos to reduce search space on next inc
+  while (lastOccurancePos != flags.npos) {
+    // increment pos, we use lastOccurancePos to reduce search space on next
+    // inc
     std::string::size_type pos = lastOccurancePos;
-    if(pos == 0 || flags[pos-1]==' ')
-      {
-      while(pos < flags.size() && flags[pos] != ' ')
-        {
-        if(!saved)
-          {
+    if (pos == 0 || flags[pos - 1] == ' ') {
+      while (pos < flags.size() && flags[pos] != ' ') {
+        if (!saved) {
           retFlag += flags[pos];
-          }
+        }
         flags[pos] = ' ';
         pos++;
-        }
-      saved = true;
       }
-    //decrement lastOccurancePos while making sure we don't loop around
-    //and become a very large positive number since size_type is unsigned
-    lastOccurancePos = lastOccurancePos == 0 ? 0 : lastOccurancePos-1;
-    lastOccurancePos = flags.rfind(flag,lastOccurancePos);
+      saved = true;
     }
+    // decrement lastOccurancePos while making sure we don't loop around
+    // and become a very large positive number since size_type is unsigned
+    lastOccurancePos = lastOccurancePos == 0 ? 0 : lastOccurancePos - 1;
+    lastOccurancePos = flags.rfind(flag, lastOccurancePos);
+  }
   return retFlag;
 }
 
-//----------------------------------------------------------------------------
 // This function removes each matching occurrence of the expression and
 // returns the last one (i.e., the dominant flag in GCC)
 std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
@@ -1643,15 +1378,13 @@ std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
 
   cmsys::RegularExpression regex(exp);
   assert(regex.is_valid());
-  if(!regex.is_valid())
-    {
+  if (!regex.is_valid()) {
     return retFlag;
-    }
+  }
 
   std::string::size_type offset = 0;
 
-  while(regex.find(flags.c_str() + offset))
-    {
+  while (regex.find(flags.c_str() + offset)) {
     const std::string::size_type startPos = offset + regex.start(matchIndex);
     const std::string::size_type endPos = offset + regex.end(matchIndex);
     const std::string::size_type size = endPos - startPos;
@@ -1660,58 +1393,47 @@ std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
 
     retFlag.assign(flags, startPos, size);
     flags.replace(startPos, size, size, ' ');
-    }
+  }
 
   return retFlag;
 }
 
- //----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
 // This function strips off Xcode attributes that do not target the current
 // configuration
-void
-cmGlobalXCodeGenerator
-::FilterConfigurationAttribute(std::string const& configName,
-                               std::string& attribute)
+void cmGlobalXCodeGenerator::FilterConfigurationAttribute(
+  std::string const& configName, std::string& attribute)
 {
   // Handle [variant=<config>] condition explicitly here.
   std::string::size_type beginVariant = attribute.find("[variant=");
-  if (beginVariant == std::string::npos)
-    {
+  if (beginVariant == std::string::npos) {
     // There is no variant in this attribute.
     return;
-    }
+  }
 
-  std::string::size_type endVariant = attribute.find("]", beginVariant+9);
-  if (endVariant == std::string::npos)
-    {
+  std::string::size_type endVariant = attribute.find("]", beginVariant + 9);
+  if (endVariant == std::string::npos) {
     // There is no terminating bracket.
     return;
-    }
+  }
 
   // Compare the variant to the configuration.
   std::string variant =
-    attribute.substr(beginVariant+9, endVariant-beginVariant-9);
-  if (variant == configName)
-    {
+    attribute.substr(beginVariant + 9, endVariant - beginVariant - 9);
+  if (variant == configName) {
     // The variant matches the configuration so use this
     // attribute but drop the [variant=<config>] condition.
-    attribute.erase(beginVariant, endVariant-beginVariant+1);
-    }
-  else
-    {
+    attribute.erase(beginVariant, endVariant - beginVariant + 1);
+  } else {
     // The variant does not match the configuration so
     // do not use this attribute.
     attribute.clear();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
-                                                cmGeneratorTarget* target,
-                                                std::vector<cmCustomCommand>
-                                                const & commands,
-                                                const char* name)
+void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
+  cmXCodeObject* buildphase, cmGeneratorTarget* target,
+  std::vector<cmCustomCommand> const& commands, const char* name)
 {
   std::string dir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
   dir += "/CMakeScripts";
@@ -1723,182 +1445,150 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
   makefile += name;
   makefile += ".make";
 
-  for (std::vector<std::string>::const_iterator currentConfig=
-            this->CurrentConfigurationTypes.begin();
-       currentConfig!=this->CurrentConfigurationTypes.end();
-       currentConfig++ )
-    {
-    this->CreateCustomRulesMakefile(makefile.c_str(),
-                                    target,
-                                    commands,
+  for (std::vector<std::string>::const_iterator currentConfig =
+         this->CurrentConfigurationTypes.begin();
+       currentConfig != this->CurrentConfigurationTypes.end();
+       currentConfig++) {
+    this->CreateCustomRulesMakefile(makefile.c_str(), target, commands,
                                     currentConfig->c_str());
-    }
+  }
 
   std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
   cdir = this->ConvertToRelativeForMake(cdir.c_str());
   std::string makecmd = "make -C ";
   makecmd += cdir;
   makecmd += " -f ";
-  makecmd += this->ConvertToRelativeForMake(
-                                          (makefile+"$CONFIGURATION").c_str());
+  makecmd +=
+    this->ConvertToRelativeForMake((makefile + "$CONFIGURATION").c_str());
   makecmd += " all";
-  buildphase->AddAttribute("shellScript",
-                           this->CreateString(makecmd.c_str()));
-  buildphase->AddAttribute("showEnvVarsInLog",
-                           this->CreateString("0"));
+  buildphase->AddAttribute("shellScript", this->CreateString(makecmd));
+  buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
 }
 
-//----------------------------------------------------------------------------
-void  cmGlobalXCodeGenerator
-::CreateCustomRulesMakefile(const char* makefileBasename,
-                            cmGeneratorTarget* target,
-                            std::vector<cmCustomCommand>
-                            const & commands,
-                            const std::string& configName)
+void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
+  const char* makefileBasename, cmGeneratorTarget* target,
+  std::vector<cmCustomCommand> const& commands, const std::string& configName)
 {
-  std::string makefileName=makefileBasename;
-  if(this->XcodeVersion > 20)
-    {
-    makefileName+=configName;
-    }
+  std::string makefileName = makefileBasename;
+  if (this->XcodeVersion > 20) {
+    makefileName += configName;
+  }
   cmGeneratedFileStream makefileStream(makefileName.c_str());
-  if(!makefileStream)
-    {
+  if (!makefileStream) {
     return;
-    }
+  }
   makefileStream.SetCopyIfDifferent(true);
   makefileStream << "# Generated by CMake, DO NOT EDIT\n";
   makefileStream << "# Custom rules for " << target->GetName() << "\n";
 
   // disable the implicit rules
-  makefileStream << ".SUFFIXES: " << "\n";
+  makefileStream << ".SUFFIXES: "
+                 << "\n";
 
   // have all depend on all outputs
   makefileStream << "all: ";
   std::map<const cmCustomCommand*, std::string> tname;
   int count = 0;
-  for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
-      i != commands.end(); ++i)
-    {
+  for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
+       i != commands.end(); ++i) {
     cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator);
-    if(ccg.GetNumberOfCommands() > 0)
-      {
+    if (ccg.GetNumberOfCommands() > 0) {
       const std::vector<std::string>& outputs = ccg.GetOutputs();
-      if(!outputs.empty())
-        {
-        for(std::vector<std::string>::const_iterator o = outputs.begin();
-            o != outputs.end(); ++o)
-          {
-          makefileStream
-              << "\\\n\t" << this->ConvertToRelativeForMake(o->c_str());
-          }
+      if (!outputs.empty()) {
+        for (std::vector<std::string>::const_iterator o = outputs.begin();
+             o != outputs.end(); ++o) {
+          makefileStream << "\\\n\t"
+                         << this->ConvertToRelativeForMake(o->c_str());
         }
-      else
-        {
+      } else {
         std::ostringstream str;
-        str << "_buildpart_" << count++ ;
+        str << "_buildpart_" << count++;
         tname[&ccg.GetCC()] = std::string(target->GetName()) + str.str();
         makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
-        }
       }
     }
+  }
   makefileStream << "\n\n";
-  for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
-      i != commands.end(); ++i)
-    {
+  for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
+       i != commands.end(); ++i) {
     cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator);
-    if(ccg.GetNumberOfCommands() > 0)
-      {
+    if (ccg.GetNumberOfCommands() > 0) {
       makefileStream << "\n";
       const std::vector<std::string>& outputs = ccg.GetOutputs();
-      if(!outputs.empty())
-        {
+      if (!outputs.empty()) {
         // There is at least one output, start the rule for it
         const char* sep = "";
-        for(std::vector<std::string>::const_iterator oi = outputs.begin();
-            oi != outputs.end(); ++oi)
-          {
-          makefileStream << sep <<
-            this->ConvertToRelativeForMake(oi->c_str());
+        for (std::vector<std::string>::const_iterator oi = outputs.begin();
+             oi != outputs.end(); ++oi) {
+          makefileStream << sep << this->ConvertToRelativeForMake(oi->c_str());
           sep = " ";
-          }
-        makefileStream << ": ";
         }
-      else
-        {
+        makefileStream << ": ";
+      } else {
         // There are no outputs.  Use the generated force rule name.
         makefileStream << tname[&ccg.GetCC()] << ": ";
-        }
-      for(std::vector<std::string>::const_iterator d =
-          ccg.GetDepends().begin();
-          d != ccg.GetDepends().end(); ++d)
-        {
+      }
+      for (std::vector<std::string>::const_iterator d =
+             ccg.GetDepends().begin();
+           d != ccg.GetDepends().end(); ++d) {
         std::string dep;
-        if(this->CurrentLocalGenerator
-           ->GetRealDependency(d->c_str(), configName, dep))
-          {
-          makefileStream << "\\\n" <<
-            this->ConvertToRelativeForMake(dep.c_str());
-          }
+        if (this->CurrentLocalGenerator->GetRealDependency(d->c_str(),
+                                                           configName, dep)) {
+          makefileStream << "\\\n"
+                         << this->ConvertToRelativeForMake(dep.c_str());
         }
+      }
       makefileStream << "\n";
 
-      if(const char* comment = ccg.GetComment())
-        {
+      if (const char* comment = ccg.GetComment()) {
         std::string echo_cmd = "echo ";
-        echo_cmd += (this->CurrentLocalGenerator->
-          EscapeForShell(comment, ccg.GetCC().GetEscapeAllowMakeVars()));
+        echo_cmd += (this->CurrentLocalGenerator->EscapeForShell(
+          comment, ccg.GetCC().GetEscapeAllowMakeVars()));
         makefileStream << "\t" << echo_cmd.c_str() << "\n";
-        }
+      }
 
       // Add each command line to the set of commands.
-      for(unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c)
-        {
+      for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
         // Build the command line in a single string.
         std::string cmd2 = ccg.GetCommand(c);
         cmSystemTools::ReplaceString(cmd2, "/./", "/");
         cmd2 = this->ConvertToRelativeForMake(cmd2.c_str());
         std::string cmd;
         std::string wd = ccg.GetWorkingDirectory();
-        if(!wd.empty())
-          {
+        if (!wd.empty()) {
           cmd += "cd ";
           cmd += this->ConvertToRelativeForMake(wd.c_str());
           cmd += " && ";
-          }
+        }
         cmd += cmd2;
         ccg.AppendArguments(c, cmd);
         makefileStream << "\t" << cmd.c_str() << "\n";
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
-                                                cmXCodeObject* buildSettings,
-                                                const std::string& configName)
+                                                 cmXCodeObject* buildSettings,
+                                                 const std::string& configName)
 {
-  if(gtgt->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
     return;
-    }
+  }
 
   std::string defFlags;
   bool shared = ((gtgt->GetType() == cmState::SHARED_LIBRARY) ||
                  (gtgt->GetType() == cmState::MODULE_LIBRARY));
   bool binary = ((gtgt->GetType() == cmState::OBJECT_LIBRARY) ||
                  (gtgt->GetType() == cmState::STATIC_LIBRARY) ||
-                 (gtgt->GetType() == cmState::EXECUTABLE) ||
-                 shared);
+                 (gtgt->GetType() == cmState::EXECUTABLE) || shared);
 
   // Compute the compilation flags for each language.
   std::set<std::string> languages;
   gtgt->GetLanguages(languages, configName);
   std::map<std::string, std::string> cflags;
   for (std::set<std::string>::iterator li = languages.begin();
-       li != languages.end(); ++li)
-    {
+       li != languages.end(); ++li) {
     std::string const& lang = *li;
     std::string& flags = cflags[lang];
 
@@ -1906,126 +1596,97 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName);
 
     // Add shared-library flags if needed.
-    this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt,
-                                                 lang, configName);
+    this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang,
+                                                 configName);
 
-    this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt,
-                                                   lang);
+    this->CurrentLocalGenerator->AddVisibilityPresetFlags(flags, gtgt, lang);
 
-    this->CurrentLocalGenerator->
-      AddCompileOptions(flags, gtgt, lang, configName);
-    }
+    this->CurrentLocalGenerator->AddCompileOptions(flags, gtgt, lang,
+                                                   configName);
+  }
 
   std::string llang = gtgt->GetLinkerLanguage(configName);
-  if(binary && llang.empty())
-    {
-    cmSystemTools::Error
-      ("CMake can not determine linker language for target: ",
-       gtgt->GetName().c_str());
+  if (binary && llang.empty()) {
+    cmSystemTools::Error(
+      "CMake can not determine linker language for target: ",
+      gtgt->GetName().c_str());
     return;
-    }
+  }
 
   // Add define flags
-  this->CurrentLocalGenerator->
-    AppendFlags(defFlags,
-                this->CurrentMakefile->GetDefineFlags());
+  this->CurrentLocalGenerator->AppendFlags(
+    defFlags, this->CurrentMakefile->GetDefineFlags());
 
   // Add preprocessor definitions for this target and configuration.
   BuildObjectListOrString ppDefs(this, this->XcodeVersion >= 30);
-  if(this->XcodeVersion > 15)
-    {
-    this->AppendDefines(ppDefs,
-      "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
-    }
-  if(const char* exportMacro = gtgt->GetExportMacro())
-    {
+  if (this->XcodeVersion > 15) {
+    this->AppendDefines(
+      ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
+  }
+  if (const char* exportMacro = gtgt->GetExportMacro()) {
     // Add the export symbol definition for shared library objects.
     this->AppendDefines(ppDefs, exportMacro);
-    }
+  }
   std::vector<std::string> targetDefines;
   gtgt->GetCompileDefinitions(targetDefines, configName, "C");
   this->AppendDefines(ppDefs, targetDefines);
-  buildSettings->AddAttribute
-    ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList());
+  buildSettings->AddAttribute("GCC_PREPROCESSOR_DEFINITIONS",
+                              ppDefs.CreateList());
 
   std::string extraLinkOptionsVar;
   std::string extraLinkOptions;
-  if(gtgt->GetType() == cmState::EXECUTABLE)
-    {
+  if (gtgt->GetType() == cmState::EXECUTABLE) {
     extraLinkOptionsVar = "CMAKE_EXE_LINKER_FLAGS";
-    }
-  else if(gtgt->GetType() == cmState::SHARED_LIBRARY)
-    {
+  } else if (gtgt->GetType() == cmState::SHARED_LIBRARY) {
     extraLinkOptionsVar = "CMAKE_SHARED_LINKER_FLAGS";
-    }
-  else if(gtgt->GetType() == cmState::MODULE_LIBRARY)
-    {
+  } else if (gtgt->GetType() == cmState::MODULE_LIBRARY) {
     extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS";
-    }
-  if(!extraLinkOptionsVar.empty())
-    {
-    this->CurrentLocalGenerator
-      ->AddConfigVariableFlags(extraLinkOptions,
-                               extraLinkOptionsVar.c_str(),
-                               configName);
-    }
+  }
+  if (!extraLinkOptionsVar.empty()) {
+    this->CurrentLocalGenerator->AddConfigVariableFlags(
+      extraLinkOptions, extraLinkOptionsVar.c_str(), configName);
+  }
 
-  if(gtgt->GetType() == cmState::OBJECT_LIBRARY ||
-     gtgt->GetType() == cmState::STATIC_LIBRARY)
-    {
-    this->CurrentLocalGenerator
-      ->GetStaticLibraryFlags(extraLinkOptions,
-                              cmSystemTools::UpperCase(configName),
-                              gtgt);
-    }
-  else
-    {
+  if (gtgt->GetType() == cmState::OBJECT_LIBRARY ||
+      gtgt->GetType() == cmState::STATIC_LIBRARY) {
+    this->CurrentLocalGenerator->GetStaticLibraryFlags(
+      extraLinkOptions, cmSystemTools::UpperCase(configName), gtgt);
+  } else {
     const char* targetLinkFlags = gtgt->GetProperty("LINK_FLAGS");
-    if(targetLinkFlags)
-      {
-      this->CurrentLocalGenerator->
-        AppendFlags(extraLinkOptions, targetLinkFlags);
-      }
-    if(!configName.empty())
-      {
+    if (targetLinkFlags) {
+      this->CurrentLocalGenerator->AppendFlags(extraLinkOptions,
+                                               targetLinkFlags);
+    }
+    if (!configName.empty()) {
       std::string linkFlagsVar = "LINK_FLAGS_";
       linkFlagsVar += cmSystemTools::UpperCase(configName);
-      if(const char* linkFlags = gtgt->GetProperty(linkFlagsVar.c_str()))
-        {
-        this->CurrentLocalGenerator->
-          AppendFlags(extraLinkOptions, linkFlags);
-        }
+      if (const char* linkFlags = gtgt->GetProperty(linkFlagsVar.c_str())) {
+        this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, linkFlags);
       }
     }
+  }
 
   // Set target-specific architectures.
   std::vector<std::string> archs;
   gtgt->GetAppleArchs(configName, archs);
 
-  if(!archs.empty())
-    {
+  if (!archs.empty()) {
     // Enable ARCHS attribute.
-    buildSettings->AddAttribute("ONLY_ACTIVE_ARCH",
-                                this->CreateString("NO"));
+    buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("NO"));
 
     // Store ARCHS value.
-    if(archs.size() == 1)
-      {
-      buildSettings->AddAttribute("ARCHS",
-                                  this->CreateString(archs[0].c_str()));
-      }
-    else
-      {
+    if (archs.size() == 1) {
+      buildSettings->AddAttribute("ARCHS", this->CreateString(archs[0]));
+    } else {
       cmXCodeObject* archObjects =
         this->CreateObject(cmXCodeObject::OBJECT_LIST);
-      for(std::vector<std::string>::iterator i = archs.begin();
-          i != archs.end(); i++)
-        {
-        archObjects->AddObject(this->CreateString((*i).c_str()));
-        }
-      buildSettings->AddAttribute("ARCHS", archObjects);
+      for (std::vector<std::string>::iterator i = archs.begin();
+           i != archs.end(); i++) {
+        archObjects->AddObject(this->CreateString(*i));
       }
+      buildSettings->AddAttribute("ARCHS", archObjects);
     }
+  }
 
   // Get the product name components.
   std::string pnprefix;
@@ -2035,280 +1696,219 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
 
   const char* version = gtgt->GetProperty("VERSION");
   const char* soversion = gtgt->GetProperty("SOVERSION");
-  if(!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple())
-    {
+  if (!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) {
     version = 0;
     soversion = 0;
-    }
-  if(version && !soversion)
-    {
+  }
+  if (version && !soversion) {
     soversion = version;
-    }
-  if(!version && soversion)
-    {
+  }
+  if (!version && soversion) {
     version = soversion;
-    }
+  }
 
   std::string realName = pnbase;
   std::string soName = pnbase;
-  if(version && soversion)
-    {
+  if (version && soversion) {
     realName += ".";
     realName += version;
     soName += ".";
     soName += soversion;
-    }
+  }
 
   // Set attributes to specify the proper name for the target.
   std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
-  if(gtgt->GetType() == cmState::STATIC_LIBRARY ||
-     gtgt->GetType() == cmState::SHARED_LIBRARY ||
-     gtgt->GetType() == cmState::MODULE_LIBRARY ||
-     gtgt->GetType() == cmState::EXECUTABLE)
-    {
-    if(this->XcodeVersion >= 21)
-      {
-      if(!gtgt->UsesDefaultOutputDir(configName, false))
-        {
+  if (gtgt->GetType() == cmState::STATIC_LIBRARY ||
+      gtgt->GetType() == cmState::SHARED_LIBRARY ||
+      gtgt->GetType() == cmState::MODULE_LIBRARY ||
+      gtgt->GetType() == cmState::EXECUTABLE) {
+    if (this->XcodeVersion >= 21) {
+      if (!gtgt->UsesDefaultOutputDir(configName, false)) {
         std::string pncdir = gtgt->GetDirectory(configName);
         buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
-                                    this->CreateString(pncdir.c_str()));
-        }
+                                    this->CreateString(pncdir));
       }
-    else
-      {
-      buildSettings->AddAttribute("OBJROOT",
-                                  this->CreateString(pndir.c_str()));
+    } else {
+      buildSettings->AddAttribute("OBJROOT", this->CreateString(pndir));
       pndir = gtgt->GetDirectory(configName);
-      }
+    }
 
-    if(gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple())
-      {
+    if (gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) {
       pnprefix = "";
-      }
+    }
 
     buildSettings->AddAttribute("EXECUTABLE_PREFIX",
-                                this->CreateString(pnprefix.c_str()));
+                                this->CreateString(pnprefix));
     buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
-                                this->CreateString(pnsuffix.c_str()));
-    }
-  else if(gtgt->GetType() == cmState::OBJECT_LIBRARY)
-    {
+                                this->CreateString(pnsuffix));
+  } else if (gtgt->GetType() == cmState::OBJECT_LIBRARY) {
     pnprefix = "lib";
     pnbase = gtgt->GetName();
     pnsuffix = ".a";
 
-    if(this->XcodeVersion >= 21)
-      {
+    if (this->XcodeVersion >= 21) {
       std::string pncdir = this->GetObjectsNormalDirectory(
         this->CurrentProject, configName, gtgt);
       buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
-                                  this->CreateString(pncdir.c_str()));
-      }
-    else
-      {
-      buildSettings->AddAttribute("OBJROOT",
-                                  this->CreateString(pndir.c_str()));
-      pndir = this->GetObjectsNormalDirectory(
-        this->CurrentProject, configName, gtgt);
-      }
+                                  this->CreateString(pncdir));
+    } else {
+      buildSettings->AddAttribute("OBJROOT", this->CreateString(pndir));
+      pndir = this->GetObjectsNormalDirectory(this->CurrentProject, configName,
+                                              gtgt);
     }
+  }
 
   // Store the product name for all target types.
-  buildSettings->AddAttribute("PRODUCT_NAME",
-                              this->CreateString(realName.c_str()));
-  buildSettings->AddAttribute("SYMROOT",
-                              this->CreateString(pndir.c_str()));
+  buildSettings->AddAttribute("PRODUCT_NAME", this->CreateString(realName));
+  buildSettings->AddAttribute("SYMROOT", this->CreateString(pndir));
 
   // Handle settings for each target type.
-  switch(gtgt->GetType())
-    {
+  switch (gtgt->GetType()) {
     case cmState::OBJECT_LIBRARY:
-    case cmState::STATIC_LIBRARY:
-    {
-    buildSettings->AddAttribute("LIBRARY_STYLE",
-                                this->CreateString("STATIC"));
-    break;
+    case cmState::STATIC_LIBRARY: {
+      buildSettings->AddAttribute("LIBRARY_STYLE",
+                                  this->CreateString("STATIC"));
+      break;
     }
 
-    case cmState::MODULE_LIBRARY:
-    {
-    buildSettings->AddAttribute("LIBRARY_STYLE",
-                                this->CreateString("BUNDLE"));
-    if (gtgt->IsCFBundleOnApple())
-      {
-      // It turns out that a BUNDLE is basically the same
-      // in many ways as an application bundle, as far as
-      // link flags go
-      std::string createFlags =
-        this->LookupFlags("CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS",
-                          "-bundle");
-      if(!createFlags.empty())
-        {
-        extraLinkOptions += " ";
-        extraLinkOptions += createFlags;
-        }
-      std::string plist = this->ComputeInfoPListLocation(gtgt);
-      // Xcode will create the final version of Info.plist at build time,
-      // so let it replace the cfbundle name. This avoids creating
-      // a per-configuration Info.plist file. The cfbundle plist
-      // is very similar to the application bundle plist
-      this->CurrentLocalGenerator
-        ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)",
-                                 plist.c_str());
-      buildSettings->AddAttribute("INFOPLIST_FILE",
-                                  this->CreateString(plist));
-      }
-    else if(this->XcodeVersion >= 22)
-      {
-      buildSettings->AddAttribute("MACH_O_TYPE",
-                                  this->CreateString("mh_bundle"));
-      buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC",
-                                  this->CreateString("NO"));
-      // Add the flags to create an executable.
-      std::string createFlags =
-        this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
-      if(!createFlags.empty())
-        {
-        extraLinkOptions += " ";
-        extraLinkOptions += createFlags;
+    case cmState::MODULE_LIBRARY: {
+      buildSettings->AddAttribute("LIBRARY_STYLE",
+                                  this->CreateString("BUNDLE"));
+      if (gtgt->IsCFBundleOnApple()) {
+        // It turns out that a BUNDLE is basically the same
+        // in many ways as an application bundle, as far as
+        // link flags go
+        std::string createFlags = this->LookupFlags(
+          "CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS", "-bundle");
+        if (!createFlags.empty()) {
+          extraLinkOptions += " ";
+          extraLinkOptions += createFlags;
         }
-      }
-    else
-      {
-      // Add the flags to create a module.
-      std::string createFlags =
-        this->LookupFlags("CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS",
-                          "-bundle");
-      if(!createFlags.empty())
-        {
-        extraLinkOptions += " ";
-        extraLinkOptions += createFlags;
+        std::string plist = this->ComputeInfoPListLocation(gtgt);
+        // Xcode will create the final version of Info.plist at build time,
+        // so let it replace the cfbundle name. This avoids creating
+        // a per-configuration Info.plist file. The cfbundle plist
+        // is very similar to the application bundle plist
+        this->CurrentLocalGenerator->GenerateAppleInfoPList(
+          gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+        buildSettings->AddAttribute("INFOPLIST_FILE",
+                                    this->CreateString(plist));
+      } else if (this->XcodeVersion >= 22) {
+        buildSettings->AddAttribute("MACH_O_TYPE",
+                                    this->CreateString("mh_bundle"));
+        buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC",
+                                    this->CreateString("NO"));
+        // Add the flags to create an executable.
+        std::string createFlags =
+          this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
+        if (!createFlags.empty()) {
+          extraLinkOptions += " ";
+          extraLinkOptions += createFlags;
+        }
+      } else {
+        // Add the flags to create a module.
+        std::string createFlags = this->LookupFlags(
+          "CMAKE_SHARED_MODULE_CREATE_", llang, "_FLAGS", "-bundle");
+        if (!createFlags.empty()) {
+          extraLinkOptions += " ";
+          extraLinkOptions += createFlags;
         }
       }
-    break;
+      break;
     }
-    case cmState::SHARED_LIBRARY:
-    {
-    if(gtgt->GetPropertyAsBool("FRAMEWORK"))
-      {
-      std::string fw_version = gtgt->GetFrameworkVersion();
-      buildSettings->AddAttribute("FRAMEWORK_VERSION",
-                                  this->CreateString(fw_version.c_str()));
-
-      std::string plist = this->ComputeInfoPListLocation(gtgt);
-      // Xcode will create the final version of Info.plist at build time,
-      // so let it replace the framework name. This avoids creating
-      // a per-configuration Info.plist file.
-      this->CurrentLocalGenerator
-        ->GenerateFrameworkInfoPList(gtgt, "$(EXECUTABLE_NAME)",
-                                     plist.c_str());
-      buildSettings->AddAttribute("INFOPLIST_FILE",
-                                  this->CreateString(plist));
-      }
-    else
-      {
-      // Add the flags to create a shared library.
+    case cmState::SHARED_LIBRARY: {
+      if (gtgt->GetPropertyAsBool("FRAMEWORK")) {
+        std::string fw_version = gtgt->GetFrameworkVersion();
+        buildSettings->AddAttribute("FRAMEWORK_VERSION",
+                                    this->CreateString(fw_version));
+
+        std::string plist = this->ComputeInfoPListLocation(gtgt);
+        // Xcode will create the final version of Info.plist at build time,
+        // so let it replace the framework name. This avoids creating
+        // a per-configuration Info.plist file.
+        this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
+          gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+        buildSettings->AddAttribute("INFOPLIST_FILE",
+                                    this->CreateString(plist));
+      } else {
+        // Add the flags to create a shared library.
+        std::string createFlags = this->LookupFlags(
+          "CMAKE_SHARED_LIBRARY_CREATE_", llang, "_FLAGS", "-dynamiclib");
+        if (!createFlags.empty()) {
+          extraLinkOptions += " ";
+          extraLinkOptions += createFlags;
+        }
+      }
+
+      buildSettings->AddAttribute("LIBRARY_STYLE",
+                                  this->CreateString("DYNAMIC"));
+      break;
+    }
+    case cmState::EXECUTABLE: {
+      // Add the flags to create an executable.
       std::string createFlags =
-        this->LookupFlags("CMAKE_SHARED_LIBRARY_CREATE_", llang, "_FLAGS",
-                          "-dynamiclib");
-      if(!createFlags.empty())
-        {
+        this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
+      if (!createFlags.empty()) {
         extraLinkOptions += " ";
         extraLinkOptions += createFlags;
-        }
       }
 
-    buildSettings->AddAttribute("LIBRARY_STYLE",
-                                this->CreateString("DYNAMIC"));
-    break;
-    }
-    case cmState::EXECUTABLE:
-    {
-    // Add the flags to create an executable.
-    std::string createFlags =
-      this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", "");
-    if(!createFlags.empty())
-      {
-      extraLinkOptions += " ";
-      extraLinkOptions += createFlags;
-      }
-
-    // Handle bundles and normal executables separately.
-    if(gtgt->GetPropertyAsBool("MACOSX_BUNDLE"))
-      {
-      std::string plist = this->ComputeInfoPListLocation(gtgt);
-      // Xcode will create the final version of Info.plist at build time,
-      // so let it replace the executable name.  This avoids creating
-      // a per-configuration Info.plist file.
-      this->CurrentLocalGenerator
-        ->GenerateAppleInfoPList(gtgt, "$(EXECUTABLE_NAME)",
-                                 plist.c_str());
-      buildSettings->AddAttribute("INFOPLIST_FILE",
-                                  this->CreateString(plist));
-
-      }
-    }
-    break;
+      // Handle bundles and normal executables separately.
+      if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
+        std::string plist = this->ComputeInfoPListLocation(gtgt);
+        // Xcode will create the final version of Info.plist at build time,
+        // so let it replace the executable name.  This avoids creating
+        // a per-configuration Info.plist file.
+        this->CurrentLocalGenerator->GenerateAppleInfoPList(
+          gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+        buildSettings->AddAttribute("INFOPLIST_FILE",
+                                    this->CreateString(plist));
+      }
+    } break;
     default:
       break;
-    }
-  if(this->XcodeVersion >= 22 && this->XcodeVersion < 40)
-    {
-    buildSettings->AddAttribute("PREBINDING",
-                                this->CreateString("NO"));
-    }
+  }
+  if (this->XcodeVersion >= 22 && this->XcodeVersion < 40) {
+    buildSettings->AddAttribute("PREBINDING", this->CreateString("NO"));
+  }
 
   BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
   BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
   std::vector<std::string> includes;
-  this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt,
-                                                     "C", configName);
+  this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C",
+                                                     configName);
   std::set<std::string> emitted;
   emitted.insert("/System/Library/Frameworks");
-  for(std::vector<std::string>::iterator i = includes.begin();
-      i != includes.end(); ++i)
-    {
-    if(this->NameResolvesToFramework(i->c_str()))
-      {
+  for (std::vector<std::string>::iterator i = includes.begin();
+       i != includes.end(); ++i) {
+    if (this->NameResolvesToFramework(i->c_str())) {
       std::string frameworkDir = *i;
       frameworkDir += "/../";
-      frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
-      if(emitted.insert(frameworkDir).second)
-        {
-        fdirs.Add(this->XCodeEscapePath(frameworkDir.c_str()).c_str());
-        }
-      }
-    else
-      {
-      std::string incpath =
-        this->XCodeEscapePath(i->c_str());
-      dirs.Add(incpath.c_str());
+      frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
+      if (emitted.insert(frameworkDir).second) {
+        fdirs.Add(this->XCodeEscapePath(frameworkDir));
       }
+    } else {
+      std::string incpath = this->XCodeEscapePath(*i);
+      dirs.Add(incpath);
     }
+  }
   // Add framework search paths needed for linking.
-  if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName))
-    {
+  if (cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) {
     std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths();
-    for(std::vector<std::string>::const_iterator fdi = fwDirs.begin();
-        fdi != fwDirs.end(); ++fdi)
-      {
-      if(emitted.insert(*fdi).second)
-        {
-        fdirs.Add(this->XCodeEscapePath(fdi->c_str()).c_str());
-        }
+    for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
+         fdi != fwDirs.end(); ++fdi) {
+      if (emitted.insert(*fdi).second) {
+        fdirs.Add(this->XCodeEscapePath(*fdi));
       }
     }
-  if(!fdirs.IsEmpty())
-    {
-    buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS",
-                                fdirs.CreateList());
-    }
-  if(!dirs.IsEmpty())
-    {
-    buildSettings->AddAttribute("HEADER_SEARCH_PATHS",
-                                dirs.CreateList());
-    }
+  }
+  if (!fdirs.IsEmpty()) {
+    buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", fdirs.CreateList());
+  }
+  if (!dirs.IsEmpty()) {
+    buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList());
+  }
 
   bool same_gflags = true;
   std::map<std::string, std::string> gflags;
@@ -2317,52 +1917,42 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
 
   // Minimal map of flags to build settings.
   for (std::set<std::string>::iterator li = languages.begin();
-       li != languages.end(); ++li)
-    {
+       li != languages.end(); ++li) {
     std::string& flags = cflags[*li];
     std::string& gflag = gflags[*li];
     std::string oflag =
       this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags);
-    if(oflag.size() == 2)
-      {
+    if (oflag.size() == 2) {
       optLevel = "1";
-      }
-    else if(oflag.size() > 2)
-      {
+    } else if (oflag.size() > 2) {
       optLevel = oflag.substr(2);
-      }
+    }
     gflag = this->ExtractFlag("-g", flags);
     // put back gdwarf-2 if used since there is no way
     // to represent it in the gui, but we still want debug yes
-    if(gflag == "-gdwarf-2")
-      {
+    if (gflag == "-gdwarf-2") {
       flags += " ";
       flags += gflag;
-      }
-    if (last_gflag && *last_gflag != gflag)
-      {
+    }
+    if (last_gflag && *last_gflag != gflag) {
       same_gflags = false;
-      }
-    last_gflag = &gflag;
     }
+    last_gflag = &gflag;
+  }
 
   const char* debugStr = "YES";
-  if (!same_gflags)
-    {
+  if (!same_gflags) {
     // We can't set the Xcode flag differently depending on the language,
     // so put them back in this case.
     for (std::set<std::string>::iterator li = languages.begin();
-         li != languages.end(); ++li)
-      {
+         li != languages.end(); ++li) {
       cflags[*li] += " ";
       cflags[*li] += gflags[*li];
-      }
-    debugStr = "NO";
     }
-  else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0"))
-    {
     debugStr = "NO";
-    }
+  } else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0")) {
+    debugStr = "NO";
+  }
 
   buildSettings->AddAttribute("COMBINE_HIDPI_IMAGES",
                               this->CreateString("YES"));
@@ -2375,45 +1965,40 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
   buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
                               this->CreateString("NO"));
   for (std::set<std::string>::iterator li = languages.begin();
-       li != languages.end(); ++li)
-    {
+       li != languages.end(); ++li) {
     std::string flags = cflags[*li] + " " + defFlags;
-    if (*li == "CXX")
-      {
+    if (*li == "CXX") {
       buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
-                                  this->CreateString(flags.c_str()));
-      }
-    else if (*li == "Fortran")
-      {
+                                  this->CreateString(flags));
+    } else if (*li == "Fortran") {
       buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
-                                  this->CreateString(flags.c_str()));
-      }
-    else if (*li == "C")
-      {
-      buildSettings->AddAttribute("OTHER_CFLAGS",
-                                  this->CreateString(flags.c_str()));
-      }
+                                  this->CreateString(flags));
+    } else if (*li == "C") {
+      buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
     }
+  }
 
   // Add Fortran source format attribute if property is set.
   const char* format = 0;
   const char* tgtfmt = gtgt->GetProperty("Fortran_FORMAT");
-  switch(this->CurrentLocalGenerator->GetFortranFormat(tgtfmt))
-    {
-    case cmLocalGenerator::FortranFormatFixed: format = "fixed"; break;
-    case cmLocalGenerator::FortranFormatFree: format = "free"; break;
-    default: break;
-    }
-  if(format)
-    {
+  switch (this->CurrentLocalGenerator->GetFortranFormat(tgtfmt)) {
+    case cmOutputConverter::FortranFormatFixed:
+      format = "fixed";
+      break;
+    case cmOutputConverter::FortranFormatFree:
+      format = "free";
+      break;
+    default:
+      break;
+  }
+  if (format) {
     buildSettings->AddAttribute("IFORT_LANG_SRCFMT",
                                 this->CreateString(format));
-    }
+  }
 
   // Create the INSTALL_PATH attribute.
   std::string install_name_dir;
-  if(gtgt->GetType() == cmState::SHARED_LIBRARY)
-    {
+  if (gtgt->GetType() == cmState::SHARED_LIBRARY) {
     // Get the install_name directory for the build tree.
     install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName);
     // Xcode doesn't create the correct install_name in some cases.
@@ -2422,86 +2007,71 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     // This is done by adding a link flag to create an install_name
     // with just the library soname.
     std::string install_name;
-    if(!install_name_dir.empty())
-      {
+    if (!install_name_dir.empty()) {
       // Convert to a path for the native build tool.
       cmSystemTools::ConvertToUnixSlashes(install_name_dir);
       install_name += install_name_dir;
       install_name += "/";
-      }
+    }
     install_name += gtgt->GetSOName(configName);
 
-    if((realName != soName) || install_name_dir.empty())
-      {
+    if ((realName != soName) || install_name_dir.empty()) {
       install_name_dir = "";
       extraLinkOptions += " -install_name ";
-      extraLinkOptions += XCodeEscapePath(install_name.c_str());
-      }
+      extraLinkOptions += XCodeEscapePath(install_name);
     }
+  }
   buildSettings->AddAttribute("INSTALL_PATH",
-                              this->CreateString(install_name_dir.c_str()));
+                              this->CreateString(install_name_dir));
 
   // Create the LD_RUNPATH_SEARCH_PATHS
   cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName);
-  if(pcli)
-    {
+  if (pcli) {
     std::string search_paths;
     std::vector<std::string> runtimeDirs;
     pcli->GetRPath(runtimeDirs, false);
     // runpath dirs needs to be unique to prevent corruption
     std::set<std::string> unique_dirs;
 
-    for(std::vector<std::string>::const_iterator i = runtimeDirs.begin();
-        i != runtimeDirs.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i = runtimeDirs.begin();
+         i != runtimeDirs.end(); ++i) {
       std::string runpath = *i;
       runpath = this->ExpandCFGIntDir(runpath, configName);
 
-      if(unique_dirs.find(runpath) == unique_dirs.end())
-        {
+      if (unique_dirs.find(runpath) == unique_dirs.end()) {
         unique_dirs.insert(runpath);
-        if(!search_paths.empty())
-          {
+        if (!search_paths.empty()) {
           search_paths += " ";
-          }
-        search_paths += this->XCodeEscapePath(runpath.c_str());
         }
+        search_paths += this->XCodeEscapePath(runpath);
       }
-    if(!search_paths.empty())
-      {
+    }
+    if (!search_paths.empty()) {
       buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS",
-                                  this->CreateString(search_paths.c_str()));
-      }
+                                  this->CreateString(search_paths));
     }
+  }
 
   buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(gtgt),
-                              this->CreateString(extraLinkOptions.c_str()));
-  buildSettings->AddAttribute("OTHER_REZFLAGS",
-                              this->CreateString(""));
-  buildSettings->AddAttribute("SECTORDER_FLAGS",
-                              this->CreateString(""));
-  buildSettings->AddAttribute("USE_HEADERMAP",
-                              this->CreateString("NO"));
-  if (this->XcodeVersion >= 30)
-    {
-    cmXCodeObject *group = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+                              this->CreateString(extraLinkOptions));
+  buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString(""));
+  buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString(""));
+  buildSettings->AddAttribute("USE_HEADERMAP", this->CreateString("NO"));
+  if (this->XcodeVersion >= 30) {
+    cmXCodeObject* group = this->CreateObject(cmXCodeObject::OBJECT_LIST);
     group->AddObject(this->CreateString("-Wmost"));
     group->AddObject(this->CreateString("-Wno-four-char-constants"));
     group->AddObject(this->CreateString("-Wno-unknown-pragmas"));
     group->AddObject(this->CreateString("$(inherited)"));
     buildSettings->AddAttribute("WARNING_CFLAGS", group);
-    }
-  else
-    {
-    buildSettings->AddAttribute("WARNING_CFLAGS",
-                                this->CreateString(
-                                  "-Wmost -Wno-four-char-constants"
-                                  " -Wno-unknown-pragmas"));
-    }
+  } else {
+    buildSettings->AddAttribute(
+      "WARNING_CFLAGS", this->CreateString("-Wmost -Wno-four-char-constants"
+                                           " -Wno-unknown-pragmas"));
+  }
 
   // Runtime version information.
-  if(gtgt->GetType() == cmState::SHARED_LIBRARY)
-    {
+  if (gtgt->GetType() == cmState::SHARED_LIBRARY) {
     int major;
     int minor;
     int patch;
@@ -2511,52 +2081,47 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     std::ostringstream v;
 
     // Xcode always wants at least 1.0.0 or nothing
-    if(!(major == 0 && minor == 0 && patch == 0))
-      {
+    if (!(major == 0 && minor == 0 && patch == 0)) {
       v << major << "." << minor << "." << patch;
-      }
+    }
     buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
-                                this->CreateString(v.str().c_str()));
+                                this->CreateString(v.str()));
 
     // SOVERSION -> compatibility_version
     gtgt->GetTargetVersion(true, major, minor, patch);
     std::ostringstream vso;
 
     // Xcode always wants at least 1.0.0 or nothing
-    if(!(major == 0 && minor == 0 && patch == 0))
-      {
+    if (!(major == 0 && minor == 0 && patch == 0)) {
       vso << major << "." << minor << "." << patch;
-      }
-    buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
-                                this->CreateString(vso.str().c_str()));
     }
+    buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
+                                this->CreateString(vso.str()));
+  }
   // put this last so it can override existing settings
   // Convert "XCODE_ATTRIBUTE_*" properties directly.
   {
-  std::vector<std::string> const& props = gtgt->GetPropertyKeys();
-  for(std::vector<std::string>::const_iterator i = props.begin();
-      i != props.end(); ++i)
-    {
-    if(i->find("XCODE_ATTRIBUTE_") == 0)
-      {
-      std::string attribute = i->substr(16);
-      this->FilterConfigurationAttribute(configName, attribute);
-      if (!attribute.empty())
-        {
-        cmGeneratorExpression ge;
-        std::string processed = ge.Parse(gtgt->GetProperty(*i))
-          ->Evaluate(this->CurrentLocalGenerator, configName);
-        buildSettings->AddAttribute(attribute.c_str(),
-                                    this->CreateString(processed));
+    std::vector<std::string> const& props = gtgt->GetPropertyKeys();
+    for (std::vector<std::string>::const_iterator i = props.begin();
+         i != props.end(); ++i) {
+      if (i->find("XCODE_ATTRIBUTE_") == 0) {
+        std::string attribute = i->substr(16);
+        this->FilterConfigurationAttribute(configName, attribute);
+        if (!attribute.empty()) {
+          cmGeneratorExpression ge;
+          std::string processed =
+            ge.Parse(gtgt->GetProperty(*i))
+              ->Evaluate(this->CurrentLocalGenerator, configName);
+          buildSettings->AddAttribute(attribute.c_str(),
+                                      this->CreateString(processed));
         }
       }
     }
   }
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateUtilityTarget(cmGeneratorTarget* gtgt)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
+  cmGeneratorTarget* gtgt)
 {
   cmXCodeObject* shellBuildPhase =
     this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase);
@@ -2570,70 +2135,56 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmGeneratorTarget* gtgt)
   shellBuildPhase->AddAttribute("outputPaths", outputPaths);
   shellBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
                                 this->CreateString("0"));
-  shellBuildPhase->AddAttribute("shellPath",
-                                this->CreateString("/bin/sh"));
-  shellBuildPhase->AddAttribute("shellScript",
-                                this->CreateString(
-                                  "# shell script goes here\nexit 0"));
-  shellBuildPhase->AddAttribute("showEnvVarsInLog",
-                                this->CreateString("0"));
+  shellBuildPhase->AddAttribute("shellPath", this->CreateString("/bin/sh"));
+  shellBuildPhase->AddAttribute(
+    "shellScript", this->CreateString("# shell script goes here\nexit 0"));
+  shellBuildPhase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
 
   cmXCodeObject* target =
     this->CreateObject(cmXCodeObject::PBXAggregateTarget);
   target->SetComment(gtgt->GetName().c_str());
-  cmXCodeObject* buildPhases =
-    this->CreateObject(cmXCodeObject::OBJECT_LIST);
+  cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   std::vector<cmXCodeObject*> emptyContentVector;
   this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0,
                              gtgt);
   target->AddAttribute("buildPhases", buildPhases);
-  if(this->XcodeVersion > 20)
-    {
+  if (this->XcodeVersion > 20) {
     this->AddConfigurations(target, gtgt);
-    }
-  else
-    {
+  } else {
     std::string theConfig =
       this->CurrentMakefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
     cmXCodeObject* buildSettings =
       this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     this->CreateBuildSettings(gtgt, buildSettings, theConfig);
     target->AddAttribute("buildSettings", buildSettings);
-    }
-  cmXCodeObject* dependencies =
-    this->CreateObject(cmXCodeObject::OBJECT_LIST);
+  }
+  cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   target->AddAttribute("dependencies", dependencies);
   target->AddAttribute("name", this->CreateString(gtgt->GetName()));
-  target->AddAttribute("productName",this->CreateString(gtgt->GetName()));
+  target->AddAttribute("productName", this->CreateString(gtgt->GetName()));
   target->SetTarget(gtgt);
   this->XCodeObjectMap[gtgt] = target;
 
   // Add source files without build rules for editing convenience.
-  if(gtgt->GetType() == cmState::UTILITY)
-    {
+  if (gtgt->GetType() == cmState::UTILITY) {
     std::vector<cmSourceFile*> sources;
-    if (!gtgt->GetConfigCommonSourceFiles(sources))
-      {
+    if (!gtgt->GetConfigCommonSourceFiles(sources)) {
       return 0;
-      }
+    }
 
-    for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
-        i != sources.end(); ++i)
-      {
-      if(!(*i)->GetPropertyAsBool("GENERATED"))
-        {
+    for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
+         i != sources.end(); ++i) {
+      if (!(*i)->GetPropertyAsBool("GENERATED")) {
         this->CreateXCodeFileReference(*i, gtgt);
-        }
       }
     }
+  }
 
-  target->SetId(this->GetOrCreateId(
-    gtgt->GetName(), target->GetId()).c_str());
+  target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()).c_str());
 
   return target;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
                                                       cmGeneratorTarget* gtgt)
 {
@@ -2656,52 +2207,43 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
   configlist->SetComment(comment.c_str());
   target->AddAttribute("buildConfigurationList",
                        this->CreateObjectReference(configlist));
-  for(unsigned int i = 0; i < configVector.size(); ++i)
-    {
+  for (unsigned int i = 0; i < configVector.size(); ++i) {
     cmXCodeObject* config =
       this->CreateObject(cmXCodeObject::XCBuildConfiguration);
     buildConfigurations->AddObject(config);
     cmXCodeObject* buildSettings =
       this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
-    this->CreateBuildSettings(gtgt, buildSettings,
-                              configVector[i].c_str());
-    config->AddAttribute("name", this->CreateString(configVector[i].c_str()));
+    this->CreateBuildSettings(gtgt, buildSettings, configVector[i].c_str());
+    config->AddAttribute("name", this->CreateString(configVector[i]));
     config->SetComment(configVector[i].c_str());
     config->AddAttribute("buildSettings", buildSettings);
-    }
-  if(!configVector.empty())
-    {
+  }
+  if (!configVector.empty()) {
     configlist->AddAttribute("defaultConfigurationName",
-                             this->CreateString(configVector[0].c_str()));
+                             this->CreateString(configVector[0]));
     configlist->AddAttribute("defaultConfigurationIsVisible",
                              this->CreateString("0"));
     return configVector[0];
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
-    cmGeneratorTarget const* target) const
+  cmGeneratorTarget const* target) const
 {
-  if(this->XcodeVersion >= 60 &&
-     (target->GetType() == cmState::STATIC_LIBRARY ||
-      target->GetType() == cmState::OBJECT_LIBRARY))
-    {
+  if (this->XcodeVersion >= 60 &&
+      (target->GetType() == cmState::STATIC_LIBRARY ||
+       target->GetType() == cmState::OBJECT_LIBRARY)) {
     return "OTHER_LIBTOOLFLAGS";
-    }
-  else
-    {
+  } else {
     return "OTHER_LDFLAGS";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalXCodeGenerator::GetTargetFileType(
-    cmGeneratorTarget* target)
+  cmGeneratorTarget* target)
 {
-  switch(target->GetType())
-    {
+  switch (target->GetType()) {
     case cmState::OBJECT_LIBRARY:
     case cmState::STATIC_LIBRARY:
       return "archive.ar";
@@ -2711,24 +2253,24 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
       else if (target->IsCFBundleOnApple())
         return "wrapper.plug-in";
       else
-        return ((this->XcodeVersion >= 22)?
-              "compiled.mach-o.executable" : "compiled.mach-o.dylib");
+        return ((this->XcodeVersion >= 22) ? "compiled.mach-o.executable"
+                                           : "compiled.mach-o.dylib");
     case cmState::SHARED_LIBRARY:
-      return (target->GetPropertyAsBool("FRAMEWORK")?
-              "wrapper.framework" : "compiled.mach-o.dylib");
+      return (target->GetPropertyAsBool("FRAMEWORK")
+                ? "wrapper.framework"
+                : "compiled.mach-o.dylib");
     case cmState::EXECUTABLE:
       return "compiled.mach-o.executable";
-    default: break;
-    }
+    default:
+      break;
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalXCodeGenerator::GetTargetProductType(
-    cmGeneratorTarget* target)
+  cmGeneratorTarget* target)
 {
-  switch(target->GetType())
-    {
+  switch (target->GetType()) {
     case cmState::OBJECT_LIBRARY:
     case cmState::STATIC_LIBRARY:
       return "com.apple.product-type.library.static";
@@ -2738,109 +2280,93 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
       else if (target->IsCFBundleOnApple())
         return "com.apple.product-type.bundle";
       else
-        return ((this->XcodeVersion >= 22)?
-                "com.apple.product-type.tool" :
-                "com.apple.product-type.library.dynamic");
+        return ((this->XcodeVersion >= 22)
+                  ? "com.apple.product-type.tool"
+                  : "com.apple.product-type.library.dynamic");
     case cmState::SHARED_LIBRARY:
-      return (target->GetPropertyAsBool("FRAMEWORK")?
-              "com.apple.product-type.framework" :
-              "com.apple.product-type.library.dynamic");
+      return (target->GetPropertyAsBool("FRAMEWORK")
+                ? "com.apple.product-type.framework"
+                : "com.apple.product-type.library.dynamic");
     case cmState::EXECUTABLE:
-      return (target->GetPropertyAsBool("MACOSX_BUNDLE")?
-              "com.apple.product-type.application" :
-              "com.apple.product-type.tool");
-    default: break;
-    }
+      return (target->GetPropertyAsBool("MACOSX_BUNDLE")
+                ? "com.apple.product-type.application"
+                : "com.apple.product-type.tool");
+    default:
+      break;
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt,
-                                          cmXCodeObject* buildPhases)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
+  cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases)
 {
-  if(gtgt->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
     return 0;
-    }
-  cmXCodeObject* target =
-    this->CreateObject(cmXCodeObject::PBXNativeTarget);
+  }
+  cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
   target->AddAttribute("buildPhases", buildPhases);
   cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   target->AddAttribute("buildRules", buildRules);
   std::string defConfig;
-  if(this->XcodeVersion > 20)
-    {
+  if (this->XcodeVersion > 20) {
     defConfig = this->AddConfigurations(target, gtgt);
-    }
-  else
-    {
+  } else {
     cmXCodeObject* buildSettings =
       this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     defConfig = this->CurrentMakefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
     this->CreateBuildSettings(gtgt, buildSettings, defConfig.c_str());
     target->AddAttribute("buildSettings", buildSettings);
-    }
-  cmXCodeObject* dependencies =
-    this->CreateObject(cmXCodeObject::OBJECT_LIST);
+  }
+  cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   target->AddAttribute("dependencies", dependencies);
   target->AddAttribute("name", this->CreateString(gtgt->GetName()));
-  target->AddAttribute("productName",this->CreateString(gtgt->GetName()));
+  target->AddAttribute("productName", this->CreateString(gtgt->GetName()));
 
-  cmXCodeObject* fileRef =
-    this->CreateObject(cmXCodeObject::PBXFileReference);
-  if(const char* fileType = this->GetTargetFileType(gtgt))
-    {
+  cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
+  if (const char* fileType = this->GetTargetFileType(gtgt)) {
     fileRef->AddAttribute("explicitFileType", this->CreateString(fileType));
-    }
+  }
   std::string fullName;
-  if(gtgt->GetType() == cmState::OBJECT_LIBRARY)
-    {
+  if (gtgt->GetType() == cmState::OBJECT_LIBRARY) {
     fullName = "lib";
     fullName += gtgt->GetName();
     fullName += ".a";
-    }
-  else
-    {
+  } else {
     fullName = gtgt->GetFullName(defConfig.c_str());
-    }
-  fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
-  fileRef->AddAttribute("refType", this->CreateString("0"));
+  }
+  fileRef->AddAttribute("path", this->CreateString(fullName));
+  if (this->XcodeVersion == 15) {
+    fileRef->AddAttribute("refType", this->CreateString("0"));
+  }
   fileRef->AddAttribute("sourceTree",
                         this->CreateString("BUILT_PRODUCTS_DIR"));
   fileRef->SetComment(gtgt->GetName().c_str());
   target->AddAttribute("productReference",
                        this->CreateObjectReference(fileRef));
-  if(const char* productType = this->GetTargetProductType(gtgt))
-    {
+  if (const char* productType = this->GetTargetProductType(gtgt)) {
     target->AddAttribute("productType", this->CreateString(productType));
-    }
+  }
   target->SetTarget(gtgt);
   this->XCodeObjectMap[gtgt] = target;
-  target->SetId(this->GetOrCreateId(
-    gtgt->GetName(), target->GetId()).c_str());
+  target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()).c_str());
   return target;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject*
-cmGlobalXCodeGenerator::FindXCodeTarget(cmGeneratorTarget const* t)
+cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(
+  cmGeneratorTarget const* t)
 {
-  if(!t)
-    {
+  if (!t) {
     return 0;
-    }
+  }
 
   std::map<cmGeneratorTarget const*, cmXCodeObject*>::const_iterator const i =
     this->XCodeObjectMap.find(t);
-  if (i == this->XCodeObjectMap.end())
-    {
+  if (i == this->XCodeObjectMap.end()) {
     return 0;
-    }
+  }
   return i->second;
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
                                                   const std::string& id)
 {
@@ -2849,18 +2375,17 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
   const char* storedGUID =
     this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str());
 
-  if(storedGUID)
-    {
+  if (storedGUID) {
     return storedGUID;
-    }
+  }
 
-  this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
-    id.c_str(), "Stored Xcode object GUID", cmState::INTERNAL);
+  this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), id.c_str(),
+                                     "Stored Xcode object GUID",
+                                     cmState::INTERNAL);
 
   return id;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
                                              cmXCodeObject* dependTarget)
 {
@@ -2873,68 +2398,52 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
   container->AddAttribute("proxyType", this->CreateString("1"));
   container->AddAttribute("remoteGlobalIDString",
                           this->CreateObjectReference(dependTarget));
-  container->AddAttribute("remoteInfo",
-                          this->CreateString(
-                            dependTarget->GetTarget()->GetName()));
+  container->AddAttribute(
+    "remoteInfo", this->CreateString(dependTarget->GetTarget()->GetName()));
   cmXCodeObject* targetdep =
     this->CreateObject(cmXCodeObject::PBXTargetDependency);
   targetdep->SetComment("PBXTargetDependency");
-  targetdep->AddAttribute("target",
-                          this->CreateObjectReference(dependTarget));
+  targetdep->AddAttribute("target", this->CreateObjectReference(dependTarget));
   targetdep->AddAttribute("targetProxy",
                           this->CreateObjectReference(container));
 
   cmXCodeObject* depends = target->GetObject("dependencies");
-  if(!depends)
-    {
-    cmSystemTools::
-      Error("target does not have dependencies attribute error..");
+  if (!depends) {
+    cmSystemTools::Error(
+      "target does not have dependencies attribute error..");
 
-    }
-  else
-    {
+  } else {
     depends->AddUniqueObject(targetdep);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
                                                      const char* attribute,
                                                      const char* value)
 {
-  if(settings)
-    {
+  if (settings) {
     cmXCodeObject* attr = settings->GetObject(attribute);
-    if(!attr)
-      {
-      settings->AddAttribute(attribute, this->CreateString(value));
-      }
-    else
-      {
+    if (!attr) {
+      settings->AddAttribute(attribute, this->CreateString(value));
+    } else {
       std::string oldValue = attr->GetString();
       oldValue += " ";
       oldValue += value;
       attr->SetString(oldValue.c_str());
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator
-::AppendBuildSettingAttribute(cmXCodeObject* target,
-                              const char* attribute,
-                              const char* value,
-                              const std::string& configName)
+void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
+  cmXCodeObject* target, const char* attribute, const char* value,
+  const std::string& configName)
 {
-  if(this->XcodeVersion < 21)
-    {
+  if (this->XcodeVersion < 21) {
     // There is only one configuration.  Add the setting to the buildSettings
     // of the target.
     this->AppendOrAddBuildSetting(target->GetObject("buildSettings"),
                                   attribute, value);
-    }
-  else
-    {
+  } else {
     // There are multiple configurations.  Add the setting to the
     // buildSettings of the configuration name given.
     cmXCodeObject* configurationList =
@@ -2943,364 +2452,307 @@ void cmGlobalXCodeGenerator
       configurationList->GetObject("buildConfigurations");
     std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList();
     // each configuration and the target itself has a buildSettings in it
-    //list.push_back(target);
-    for(std::vector<cmXCodeObject*>::iterator i = list.begin();
-        i != list.end(); ++i)
-      {
-      if(!configName.empty())
-        {
-        if((*i)->GetObject("name")->GetString() == configName)
-          {
+    // list.push_back(target);
+    for (std::vector<cmXCodeObject*>::iterator i = list.begin();
+         i != list.end(); ++i) {
+      if (!configName.empty()) {
+        if ((*i)->GetObject("name")->GetString() == configName) {
           cmXCodeObject* settings = (*i)->GetObject("buildSettings");
           this->AppendOrAddBuildSetting(settings, attribute, value);
-          }
         }
-      else
-        {
+      } else {
         cmXCodeObject* settings = (*i)->GetObject("buildSettings");
         this->AppendOrAddBuildSetting(settings, attribute, value);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator
-::AddDependAndLinkInformation(cmXCodeObject* target)
+void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
 {
   cmGeneratorTarget* gt = target->GetTarget();
-  if(!gt)
-    {
+  if (!gt) {
     cmSystemTools::Error("Error no target on xobject\n");
     return;
-    }
-  if(gt->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  }
+  if (gt->GetType() == cmState::INTERFACE_LIBRARY) {
     return;
-    }
+  }
 
   // Add dependencies on other CMake targets.
   TargetDependSet const& deps = this->GetTargetDirectDepends(gt);
-  for(TargetDependSet::const_iterator i = deps.begin(); i != deps.end(); ++i)
-    {
-    if(cmXCodeObject* dptarget = this->FindXCodeTarget(*i))
-      {
+  for (TargetDependSet::const_iterator i = deps.begin(); i != deps.end();
+       ++i) {
+    if (cmXCodeObject* dptarget = this->FindXCodeTarget(*i)) {
       this->AddDependTarget(target, dptarget);
-      }
     }
+  }
 
   // Loop over configuration types and set per-configuration info.
-  for(std::vector<std::string>::iterator i =
-        this->CurrentConfigurationTypes.begin();
-      i != this->CurrentConfigurationTypes.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i =
+         this->CurrentConfigurationTypes.begin();
+       i != this->CurrentConfigurationTypes.end(); ++i) {
     // Get the current configuration name.
     std::string configName = *i;
 
-    if(this->XcodeVersion >= 50)
-      {
+    if (this->XcodeVersion >= 50) {
       // Add object library contents as link flags.
       std::string linkObjs;
       const char* sep = "";
       std::vector<std::string> objs;
       gt->UseObjectLibraries(objs, "");
-      for(std::vector<std::string>::const_iterator
-            oi = objs.begin(); oi != objs.end(); ++oi)
-        {
+      for (std::vector<std::string>::const_iterator oi = objs.begin();
+           oi != objs.end(); ++oi) {
         linkObjs += sep;
         sep = " ";
-        linkObjs += this->XCodeEscapePath(oi->c_str());
-        }
-      this->AppendBuildSettingAttribute(
-        target, this->GetTargetLinkFlagsVar(gt),
-        linkObjs.c_str(), configName);
+        linkObjs += this->XCodeEscapePath(*oi);
       }
+      this->AppendBuildSettingAttribute(
+        target, this->GetTargetLinkFlagsVar(gt), linkObjs.c_str(), configName);
+    }
 
     // Skip link information for object libraries.
-    if(gt->GetType() == cmState::OBJECT_LIBRARY ||
-       gt->GetType() == cmState::STATIC_LIBRARY)
-      {
+    if (gt->GetType() == cmState::OBJECT_LIBRARY ||
+        gt->GetType() == cmState::STATIC_LIBRARY) {
       continue;
-      }
+    }
 
     // Compute the link library and directory information.
     cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName);
-    if(!pcli)
-      {
+    if (!pcli) {
       continue;
-      }
+    }
     cmComputeLinkInformation& cli = *pcli;
 
     // Add dependencies directly on library files.
     {
-    std::vector<std::string> const& libDeps = cli.GetDepends();
-    for(std::vector<std::string>::const_iterator j = libDeps.begin();
-        j != libDeps.end(); ++j)
-      {
-      target->AddDependLibrary(configName, j->c_str());
+      std::vector<std::string> const& libDeps = cli.GetDepends();
+      for (std::vector<std::string>::const_iterator j = libDeps.begin();
+           j != libDeps.end(); ++j) {
+        target->AddDependLibrary(configName, j->c_str());
       }
     }
 
     // add the library search paths
     {
-    std::vector<std::string> const& libDirs = cli.GetDirectories();
-    std::string linkDirs;
-    for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
-        libDir != libDirs.end(); ++libDir)
-      {
-      if(libDir->size() && *libDir != "/usr/lib")
-        {
-        if(this->XcodeVersion > 15)
-          {
-          // Now add the same one but append
-          // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
-          linkDirs += " ";
-          linkDirs += this->XCodeEscapePath(
-            (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str());
+      std::vector<std::string> const& libDirs = cli.GetDirectories();
+      std::string linkDirs;
+      for (std::vector<std::string>::const_iterator libDir = libDirs.begin();
+           libDir != libDirs.end(); ++libDir) {
+        if (libDir->size() && *libDir != "/usr/lib") {
+          if (this->XcodeVersion > 15) {
+            // Now add the same one but append
+            // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
+            linkDirs += " ";
+            linkDirs += this->XCodeEscapePath(
+              *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
           }
-        linkDirs += " ";
-        linkDirs += this->XCodeEscapePath(libDir->c_str());
+          linkDirs += " ";
+          linkDirs += this->XCodeEscapePath(*libDir);
         }
       }
-    this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
-                                      linkDirs.c_str(), configName);
+      this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
+                                        linkDirs.c_str(), configName);
     }
 
     // now add the link libraries
     {
-    std::string linkLibs;
-    const char* sep = "";
-    typedef cmComputeLinkInformation::ItemVector ItemVector;
-    ItemVector const& libNames = cli.GetItems();
-    for(ItemVector::const_iterator li = libNames.begin();
-        li != libNames.end(); ++li)
-      {
-      linkLibs += sep;
-      sep = " ";
-      if(li->IsPath)
-        {
-        linkLibs += this->XCodeEscapePath(li->Value.c_str());
-        }
-      else if (!li->Target
-          || li->Target->GetType() != cmState::INTERFACE_LIBRARY)
-        {
-        linkLibs += li->Value;
+      std::string linkLibs;
+      const char* sep = "";
+      typedef cmComputeLinkInformation::ItemVector ItemVector;
+      ItemVector const& libNames = cli.GetItems();
+      for (ItemVector::const_iterator li = libNames.begin();
+           li != libNames.end(); ++li) {
+        linkLibs += sep;
+        sep = " ";
+        if (li->IsPath) {
+          linkLibs += this->XCodeEscapePath(li->Value);
+        } else if (!li->Target ||
+                   li->Target->GetType() != cmState::INTERFACE_LIBRARY) {
+          linkLibs += li->Value;
         }
-      if(li->Target && !li->Target->IsImported())
-        {
-        target->AddDependTarget(configName, li->Target->GetName());
+        if (li->Target && !li->Target->IsImported()) {
+          target->AddDependTarget(configName, li->Target->GetName());
         }
       }
-    this->AppendBuildSettingAttribute(
-      target, this->GetTargetLinkFlagsVar(gt),
-      linkLibs.c_str(), configName);
-    }
+      this->AppendBuildSettingAttribute(
+        target, this->GetTargetLinkFlagsVar(gt), linkLibs.c_str(), configName);
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
-                                          std::vector<cmLocalGenerator*>&
-                                          generators)
+bool cmGlobalXCodeGenerator::CreateGroups(
+  cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
 {
-  for(std::vector<cmLocalGenerator*>::iterator i = generators.begin();
-      i != generators.end(); ++i)
-    {
-    if(this->IsExcluded(root, *i))
-      {
+  for (std::vector<cmLocalGenerator*>::iterator i = generators.begin();
+       i != generators.end(); ++i) {
+    if (this->IsExcluded(root, *i)) {
       continue;
-      }
+    }
     cmMakefile* mf = (*i)->GetMakefile();
     std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
     std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets();
-    for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-        l != tgts.end(); l++)
-      {
+    for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+         l != tgts.end(); l++) {
       cmGeneratorTarget* gtgt = *l;
 
       // Same skipping logic here as in CreateXCodeTargets so that we do not
       // end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source
       // groups:
       //
-      if(gtgt->GetType() == cmState::GLOBAL_TARGET)
-        {
+      if (gtgt->GetType() == cmState::GLOBAL_TARGET) {
         continue;
-        }
-      if(gtgt->GetType() == cmState::INTERFACE_LIBRARY)
-        {
+      }
+      if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) {
         continue;
-        }
+      }
 
       // add the soon to be generated Info.plist file as a source for a
       // MACOSX_BUNDLE file
-      if(gtgt->GetPropertyAsBool("MACOSX_BUNDLE"))
-        {
+      if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
         std::string plist = this->ComputeInfoPListLocation(gtgt);
         mf->GetOrCreateSource(plist, true);
         gtgt->AddSource(plist);
-        }
+      }
 
       std::vector<cmSourceFile*> classes;
-      if (!gtgt->GetConfigCommonSourceFiles(classes))
-        {
+      if (!gtgt->GetConfigCommonSourceFiles(classes)) {
         return false;
-        }
+      }
       // Put cmSourceFile instances in proper groups:
-      for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
-          s != classes.end(); s++)
-        {
+      for (std::vector<cmSourceFile*>::const_iterator s = classes.begin();
+           s != classes.end(); s++) {
         cmSourceFile* sf = *s;
         // Add the file to the list of sources.
         std::string const& source = sf->GetFullPath();
         cmSourceGroup* sourceGroup =
           mf->FindSourceGroup(source.c_str(), sourceGroups);
-        cmXCodeObject* pbxgroup =
-          this->CreateOrGetPBXGroup(gtgt, sourceGroup);
+        cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup);
         std::string key = GetGroupMapKey(gtgt, sf);
         this->GroupMap[key] = pbxgroup;
-        }
+      }
 
       // Put OBJECT_LIBRARY objects in proper groups:
       std::vector<std::string> objs;
       gtgt->UseObjectLibraries(objs, "");
-      for(std::vector<std::string>::const_iterator
-            oi = objs.begin(); oi != objs.end(); ++oi)
-        {
+      for (std::vector<std::string>::const_iterator oi = objs.begin();
+           oi != objs.end(); ++oi) {
         std::string const& source = *oi;
         cmSourceGroup* sourceGroup =
           mf->FindSourceGroup(source.c_str(), sourceGroups);
-        cmXCodeObject* pbxgroup =
-          this->CreateOrGetPBXGroup(gtgt, sourceGroup);
+        cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup);
         std::string key = GetGroupMapKeyFromPath(gtgt, source);
         this->GroupMap[key] = pbxgroup;
-        }
       }
     }
+  }
   return true;
 }
 
-cmXCodeObject *cmGlobalXCodeGenerator
-::CreatePBXGroup(cmXCodeObject *parent, std::string name)
+cmXCodeObject* cmGlobalXCodeGenerator::CreatePBXGroup(cmXCodeObject* parent,
+                                                      std::string name)
 {
   cmXCodeObject* parentChildren = NULL;
-  if(parent)
+  if (parent)
     parentChildren = parent->GetObject("children");
   cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
   cmXCodeObject* groupChildren =
-  this->CreateObject(cmXCodeObject::OBJECT_LIST);
-  group->AddAttribute("name", this->CreateString(name.c_str()));
+    this->CreateObject(cmXCodeObject::OBJECT_LIST);
+  group->AddAttribute("name", this->CreateString(name));
   group->AddAttribute("children", groupChildren);
-  if(this->XcodeVersion == 15)
-  {
+  if (this->XcodeVersion == 15) {
     group->AddAttribute("refType", this->CreateString("4"));
   }
   group->AddAttribute("sourceTree", this->CreateString("<group>"));
-  if(parentChildren)
+  if (parentChildren)
     parentChildren->AddObject(group);
   return group;
 }
 
-//----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator
-::CreateOrGetPBXGroup(cmGeneratorTarget* gtgt, cmSourceGroup* sg)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
+  cmGeneratorTarget* gtgt, cmSourceGroup* sg)
 {
   std::string s;
   std::string target;
-  const char *targetFolder= gtgt->GetProperty("FOLDER");
-  if(targetFolder) {
+  const char* targetFolder = gtgt->GetProperty("FOLDER");
+  if (targetFolder) {
     target = targetFolder;
     target += "/";
   }
   target += gtgt->GetName();
   s = target + "/";
   s += sg->GetFullName();
-  std::map<std::string, cmXCodeObject* >::iterator it =
+  std::map<std::string, cmXCodeObject*>::iterator it =
     this->GroupNameMap.find(s);
-  if(it != this->GroupNameMap.end())
-    {
+  if (it != this->GroupNameMap.end()) {
     return it->second;
-    }
+  }
 
   it = this->TargetGroup.find(target);
   cmXCodeObject* tgroup = 0;
-  if(it != this->TargetGroup.end())
-    {
+  if (it != this->TargetGroup.end()) {
     tgroup = it->second;
-    }
-  else
-    {
+  } else {
     std::vector<std::string> tgt_folders =
       cmSystemTools::tokenize(target, "/");
     std::string curr_tgt_folder;
-    for(std::vector<std::string>::size_type i = 0; i < tgt_folders.size();i++)
-      {
-      if (i != 0)
-        {
+    for (std::vector<std::string>::size_type i = 0; i < tgt_folders.size();
+         i++) {
+      if (i != 0) {
         curr_tgt_folder += "/";
-        }
+      }
       curr_tgt_folder += tgt_folders[i];
       it = this->TargetGroup.find(curr_tgt_folder);
-      if(it != this->TargetGroup.end())
-        {
+      if (it != this->TargetGroup.end()) {
         tgroup = it->second;
         continue;
-        }
-      tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]);
+      }
+      tgroup = this->CreatePBXGroup(tgroup, tgt_folders[i]);
       this->TargetGroup[curr_tgt_folder] = tgroup;
-      if(i == 0)
-        {
+      if (i == 0) {
         this->SourcesGroupChildren->AddObject(tgroup);
-        }
       }
     }
+  }
   this->TargetGroup[target] = tgroup;
 
   // If it's the default source group (empty name) then put the source file
   // directly in the tgroup...
   //
-  if (std::string(sg->GetFullName()) == "")
-    {
+  if (std::string(sg->GetFullName()) == "") {
     this->GroupNameMap[s] = tgroup;
     return tgroup;
-    }
+  }
 
-  //It's a recursive folder structure, let's find the real parent group
-  if(std::string(sg->GetFullName()) != std::string(sg->GetName()))
-    {
+  // It's a recursive folder structure, let's find the real parent group
+  if (std::string(sg->GetFullName()) != std::string(sg->GetName())) {
     std::vector<std::string> folders =
       cmSystemTools::tokenize(sg->GetFullName(), "\\");
     std::string curr_folder = target;
     curr_folder += "/";
-    for(std::vector<std::string>::size_type i = 0; i < folders.size();i++)
-      {
+    for (std::vector<std::string>::size_type i = 0; i < folders.size(); i++) {
       curr_folder += folders[i];
-      std::map<std::string, 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())
-        {
-        cmXCodeObject *group = this->CreatePBXGroup(tgroup,folders[i]);
+      // Create new folder
+      if (i_folder == this->GroupNameMap.end()) {
+        cmXCodeObject* group = this->CreatePBXGroup(tgroup, folders[i]);
         this->GroupNameMap[curr_folder] = group;
         tgroup = group;
-        }
-      else
-        {
+      } else {
         tgroup = i_folder->second;
-        }
-      curr_folder = curr_folder + "\\";
       }
-    return tgroup;
+      curr_folder = curr_folder + "\\";
     }
-  cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName());
+    return tgroup;
+  }
+  cmXCodeObject* group = this->CreatePBXGroup(tgroup, sg->GetName());
   this->GroupNameMap[s] = group;
   return group;
 }
 
-//----------------------------------------------------------------------------
-bool cmGlobalXCodeGenerator
-::CreateXCodeObjects(cmLocalGenerator* root,
-                     std::vector<cmLocalGenerator*>&
-                     generators)
+bool cmGlobalXCodeGenerator::CreateXCodeObjects(
+  cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
 {
   this->ClearXCodeObjects();
   this->RootObject = 0;
@@ -3312,24 +2764,19 @@ bool cmGlobalXCodeGenerator
   cmXCodeObject* developBuildStyle =
     this->CreateObject(cmXCodeObject::PBXBuildStyle);
   cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
-  if(this->XcodeVersion == 15)
-    {
-    developBuildStyle->AddAttribute("name",
-                                    this->CreateString("Development"));
+  if (this->XcodeVersion == 15) {
+    developBuildStyle->AddAttribute("name", this->CreateString("Development"));
     developBuildStyle->AddAttribute("buildSettings", group);
     listObjs->AddObject(developBuildStyle);
     group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("YES"));
     cmXCodeObject* deployBuildStyle =
-    this->CreateObject(cmXCodeObject::PBXBuildStyle);
+      this->CreateObject(cmXCodeObject::PBXBuildStyle);
     deployBuildStyle->AddAttribute("name", this->CreateString("Deployment"));
     deployBuildStyle->AddAttribute("buildSettings", group);
     listObjs->AddObject(deployBuildStyle);
-    }
-  else
-    {
-    for(unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i)
-      {
+  } else {
+    for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) {
       cmXCodeObject* buildStyle =
         this->CreateObject(cmXCodeObject::PBXBuildStyle);
       const char* name = this->CurrentConfigurationTypes[i].c_str();
@@ -3340,28 +2787,24 @@ bool cmGlobalXCodeGenerator
       sgroup->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
       buildStyle->AddAttribute("buildSettings", sgroup);
       listObjs->AddObject(buildStyle);
-      }
     }
+  }
 
   cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup);
-  this->MainGroupChildren =
-    this->CreateObject(cmXCodeObject::OBJECT_LIST);
+  this->MainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   mainGroup->AddAttribute("children", this->MainGroupChildren);
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     mainGroup->AddAttribute("refType", this->CreateString("4"));
-    }
+  }
   mainGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
 
   cmXCodeObject* sourcesGroup = this->CreateObject(cmXCodeObject::PBXGroup);
-  this->SourcesGroupChildren =
-    this->CreateObject(cmXCodeObject::OBJECT_LIST);
+  this->SourcesGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST);
   sourcesGroup->AddAttribute("name", this->CreateString("Sources"));
   sourcesGroup->AddAttribute("children", this->SourcesGroupChildren);
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     sourcesGroup->AddAttribute("refType", this->CreateString("4"));
-    }
+  }
   sourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
   this->MainGroupChildren->AddObject(sourcesGroup);
 
@@ -3370,49 +2813,45 @@ bool cmGlobalXCodeGenerator
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   resourcesGroup->AddAttribute("name", this->CreateString("Resources"));
   resourcesGroup->AddAttribute("children", this->ResourcesGroupChildren);
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     resourcesGroup->AddAttribute("refType", this->CreateString("4"));
-    }
+  }
   resourcesGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
   this->MainGroupChildren->AddObject(resourcesGroup);
 
   // now create the cmake groups
-  if (!this->CreateGroups(root, generators))
-    {
+  if (!this->CreateGroups(root, generators)) {
     return false;
-    }
+  }
 
   cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup);
   productGroup->AddAttribute("name", this->CreateString("Products"));
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     productGroup->AddAttribute("refType", this->CreateString("4"));
-    }
+  }
   productGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
   cmXCodeObject* productGroupChildren =
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   productGroup->AddAttribute("children", productGroupChildren);
   this->MainGroupChildren->AddObject(productGroup);
 
-
   this->RootObject = this->CreateObject(cmXCodeObject::PBXProject);
   this->RootObject->SetComment("Project object");
 
   std::string project_id = "PROJECT_";
   project_id += root->GetProjectName();
-  this->RootObject->SetId(this->GetOrCreateId(
-    project_id.c_str(), this->RootObject->GetId()).c_str());
+  this->RootObject->SetId(
+    this->GetOrCreateId(project_id.c_str(), this->RootObject->GetId())
+      .c_str());
 
   group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
   this->RootObject->AddAttribute("mainGroup",
-                             this->CreateObjectReference(mainGroup));
+                                 this->CreateObjectReference(mainGroup));
   this->RootObject->AddAttribute("buildSettings", group);
   this->RootObject->AddAttribute("buildStyles", listObjs);
   this->RootObject->AddAttribute("hasScannedForEncodings",
-                             this->CreateString("0"));
-  if (this->XcodeVersion >= 30)
-    {
+                                 this->CreateString("0"));
+  if (this->XcodeVersion >= 30) {
     group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     group->AddAttribute("BuildIndependentTargetsInParallel",
                         this->CreateString("YES"));
@@ -3429,14 +2868,13 @@ bool cmGlobalXCodeGenerator
     else
       this->RootObject->AddAttribute("compatibilityVersion",
                                      this->CreateString("Xcode 3.0"));
-    }
+  }
   // Point Xcode at the top of the source tree.
   {
-  std::string pdir =
-    this->RelativeToBinary(root->GetCurrentSourceDirectory());
-  this->RootObject->AddAttribute("projectDirPath",
-                                 this->CreateString(pdir.c_str()));
-  this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
+    std::string pdir =
+      this->RelativeToBinary(root->GetCurrentSourceDirectory());
+    this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir));
+    this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
   }
   cmXCodeObject* configlist =
     this->CreateObject(cmXCodeObject::XCConfigurationList);
@@ -3444,9 +2882,8 @@ bool cmGlobalXCodeGenerator
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   typedef std::vector<std::pair<std::string, cmXCodeObject*> > Configs;
   Configs configs;
-  const char *defaultConfigName = "Debug";
-  if(this->XcodeVersion == 15)
-    {
+  const char* defaultConfigName = "Debug";
+  if (this->XcodeVersion == 15) {
     cmXCodeObject* configDebug =
       this->CreateObject(cmXCodeObject::XCBuildConfiguration);
     configDebug->AddAttribute("name", this->CreateString("Debug"));
@@ -3455,26 +2892,21 @@ bool cmGlobalXCodeGenerator
       this->CreateObject(cmXCodeObject::XCBuildConfiguration);
     configRelease->AddAttribute("name", this->CreateString("Release"));
     configs.push_back(std::make_pair("Release", configRelease));
-    }
-  else
-    {
-    for(unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i)
-      {
+  } else {
+    for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) {
       const char* name = this->CurrentConfigurationTypes[i].c_str();
-      if (0 == i)
-        {
+      if (0 == i) {
         defaultConfigName = name;
-        }
+      }
       cmXCodeObject* config =
         this->CreateObject(cmXCodeObject::XCBuildConfiguration);
       config->AddAttribute("name", this->CreateString(name));
       configs.push_back(std::make_pair(name, config));
-      }
     }
-  for(Configs::iterator c = configs.begin(); c != configs.end(); ++c)
-    {
+  }
+  for (Configs::iterator c = configs.begin(); c != configs.end(); ++c) {
     buildConfigurations->AddObject(c->second);
-    }
+  }
   configlist->AddAttribute("buildConfigurations", buildConfigurations);
 
   std::string comment = "Build configuration list for PBXProject";
@@ -3487,134 +2919,111 @@ bool cmGlobalXCodeGenerator
   configlist->AddAttribute("defaultConfigurationName",
                            this->CreateString(defaultConfigName));
   cmXCodeObject* buildSettings =
-      this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
+    this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
   const char* osxArch =
-      this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
+    this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
   const char* sysroot =
-      this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
+    this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
   const char* deploymentTarget =
     this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
   std::string archs;
-  if(sysroot)
-    {
-    if(osxArch)
-      {
+  if (sysroot) {
+    if (osxArch) {
       // recompute this as it may have been changed since enable language
       this->Architectures.clear();
       cmSystemTools::ExpandListArgument(std::string(osxArch),
                                         this->Architectures);
       archs = cmJoin(this->Architectures, " ");
-      }
-    buildSettings->AddAttribute("SDKROOT",
-                                this->CreateString(sysroot));
     }
-  if (archs.empty())
-    {
+    buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot));
+  }
+  if (archs.empty()) {
     // Tell Xcode to use NATIVE_ARCH instead of ARCHS.
     buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES"));
-    }
-  else
-    {
+  } else {
     // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO).
-    buildSettings->AddAttribute("ARCHS", this->CreateString(archs.c_str()));
-    }
-  if(deploymentTarget && *deploymentTarget)
-    {
+    buildSettings->AddAttribute("ARCHS", this->CreateString(archs));
+  }
+  if (deploymentTarget && *deploymentTarget) {
     buildSettings->AddAttribute("MACOSX_DEPLOYMENT_TARGET",
                                 this->CreateString(deploymentTarget));
-    }
-  if(!this->GeneratorToolset.empty())
-    {
+  }
+  if (!this->GeneratorToolset.empty()) {
     buildSettings->AddAttribute("GCC_VERSION",
-      this->CreateString(this->GeneratorToolset.c_str()));
-    }
+                                this->CreateString(this->GeneratorToolset));
+  }
 
   std::string symroot = root->GetCurrentBinaryDirectory();
   symroot += "/build";
-  buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str()));
+  buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot));
 
-  for(Configs::iterator i = configs.begin(); i != configs.end(); ++i)
-    {
+  for (Configs::iterator i = configs.begin(); i != configs.end(); ++i) {
     cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings);
 
     // Put this last so it can override existing settings
     // Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
     std::vector<std::string> vars = this->CurrentMakefile->GetDefinitions();
-    for(std::vector<std::string>::const_iterator d = vars.begin();
-        d != vars.end(); ++d)
-      {
-      if(d->find("CMAKE_XCODE_ATTRIBUTE_") == 0)
-        {
+    for (std::vector<std::string>::const_iterator d = vars.begin();
+         d != vars.end(); ++d) {
+      if (d->find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
         std::string attribute = d->substr(22);
         this->FilterConfigurationAttribute(i->first, attribute);
-        if(!attribute.empty())
-          {
+        if (!attribute.empty()) {
           cmGeneratorExpression ge;
           std::string processed =
             ge.Parse(this->CurrentMakefile->GetDefinition(*d))
               ->Evaluate(this->CurrentLocalGenerator, i->first);
           buildSettingsForCfg->AddAttribute(attribute,
-            this->CreateString(processed));
-          }
+                                            this->CreateString(processed));
         }
       }
+    }
     // store per-config buildSettings into configuration object
     i->second->AddAttribute("buildSettings", buildSettingsForCfg);
-    }
+  }
 
   this->RootObject->AddAttribute("buildConfigurationList",
-                             this->CreateObjectReference(configlist));
+                                 this->CreateObjectReference(configlist));
 
   std::vector<cmXCodeObject*> targets;
-  for(std::vector<cmLocalGenerator*>::iterator i = generators.begin();
-      i != generators.end(); ++i)
-    {
-    if(!this->IsExcluded(root, *i))
-      {
-      if (!this->CreateXCodeTargets(*i, targets))
-        {
+  for (std::vector<cmLocalGenerator*>::iterator i = generators.begin();
+       i != generators.end(); ++i) {
+    if (!this->IsExcluded(root, *i)) {
+      if (!this->CreateXCodeTargets(*i, targets)) {
         return false;
-        }
       }
     }
+  }
   // loop over all targets and add link and depend info
-  for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
-      i != targets.end(); ++i)
-    {
+  for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
+       i != targets.end(); ++i) {
     cmXCodeObject* t = *i;
     this->AddDependAndLinkInformation(t);
-    }
-  if(this->XcodeVersion < 50)
-    {
+  }
+  if (this->XcodeVersion < 50) {
     // now create xcode depend hack makefile
     this->CreateXCodeDependHackTarget(targets);
-    }
+  }
   // now add all targets to the root object
   cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST);
-  for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
-      i != targets.end(); ++i)
-    {
+  for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
+       i != targets.end(); ++i) {
     cmXCodeObject* t = *i;
     allTargets->AddObject(t);
     cmXCodeObject* productRef = t->GetObject("productReference");
-    if(productRef)
-      {
+    if (productRef) {
       productGroupChildren->AddObject(productRef->GetObject());
-      }
     }
+  }
   this->RootObject->AddAttribute("targets", allTargets);
   return true;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalXCodeGenerator::GetObjectsNormalDirectory(
-  const std::string &projName,
-  const std::string &configName,
-  const cmGeneratorTarget *t) const
+std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory(
+  const std::string& projName, const std::string& configName,
+  const cmGeneratorTarget* t) const
 {
-  std::string dir =
-    t->GetLocalGenerator()->GetCurrentBinaryDirectory();
+  std::string dir = t->GetLocalGenerator()->GetCurrentBinaryDirectory();
   dir += "/";
   dir += projName;
   dir += ".build/";
@@ -3626,22 +3035,19 @@ cmGlobalXCodeGenerator::GetObjectsNormalDirectory(
   return dir;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
+void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
   std::vector<cmXCodeObject*>& targets)
 {
-  cmGeneratedFileStream
-    makefileStream(this->CurrentXCodeHackMakefile.c_str());
-  if(!makefileStream)
-    {
+  cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str());
+  if (!makefileStream) {
     cmSystemTools::Error("Could not create",
                          this->CurrentXCodeHackMakefile.c_str());
     return;
-    }
+  }
   makefileStream.SetCopyIfDifferent(true);
   // one more pass for external depend information not handled
   // correctly by xcode
+  /* clang-format off */
   makefileStream << "# DO NOT EDIT\n";
   makefileStream << "# This makefile makes sure all linkable targets are\n";
   makefileStream << "# up-to-date with anything they link to\n"
@@ -3651,94 +3057,86 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
   makefileStream
     << "# For each target create a dummy rule "
     "so the target does not have to exist\n";
+  /* clang-format on */
   std::set<std::string> emitted;
-  for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
-      i != targets.end(); ++i)
-    {
+  for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
+       i != targets.end(); ++i) {
     cmXCodeObject* target = *i;
     std::map<std::string, cmXCodeObject::StringVec> const& deplibs =
       target->GetDependLibraries();
-    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();
-          d != ci->second.end(); ++d)
-        {
-        if(emitted.insert(*d).second)
-          {
-          makefileStream <<
-            this->ConvertToRelativeForMake(d->c_str()) << ":\n";
-          }
+    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();
+           d != ci->second.end(); ++d) {
+        if (emitted.insert(*d).second) {
+          makefileStream << this->ConvertToRelativeForMake(d->c_str())
+                         << ":\n";
         }
       }
     }
+  }
   makefileStream << "\n\n";
 
   // Write rules to help Xcode relink things at the right time.
+  /* clang-format off */
   makefileStream <<
     "# Rules to remove targets that are older than anything to which they\n"
     "# link.  This forces Xcode to relink the targets from scratch.  It\n"
     "# does not seem to check these dependencies itself.\n";
-  for(std::vector<std::string>::const_iterator
-        ct = this->CurrentConfigurationTypes.begin();
-      ct != this->CurrentConfigurationTypes.end(); ++ct)
-    {
+  /* clang-format on */
+  for (std::vector<std::string>::const_iterator ct =
+         this->CurrentConfigurationTypes.begin();
+       ct != this->CurrentConfigurationTypes.end(); ++ct) {
     std::string configName = *ct;
-    for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
-        i != targets.end(); ++i)
-      {
+    for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
+         i != targets.end(); ++i) {
       cmXCodeObject* target = *i;
-      cmGeneratorTarget* gt =target->GetTarget();
-
-      if(gt->GetType() == cmState::EXECUTABLE ||
-// Nope - no post-build for OBJECT_LIRBRARY
-//         gt->GetType() == cmState::OBJECT_LIBRARY ||
-         gt->GetType() == cmState::STATIC_LIBRARY ||
-         gt->GetType() == cmState::SHARED_LIBRARY ||
-         gt->GetType() == cmState::MODULE_LIBRARY)
-        {
+      cmGeneratorTarget* gt = target->GetTarget();
+
+      if (gt->GetType() == cmState::EXECUTABLE ||
+          // Nope - no post-build for OBJECT_LIRBRARY
+          //         gt->GetType() == cmState::OBJECT_LIBRARY ||
+          gt->GetType() == cmState::STATIC_LIBRARY ||
+          gt->GetType() == cmState::SHARED_LIBRARY ||
+          gt->GetType() == cmState::MODULE_LIBRARY) {
         // Declare an entry point for the target post-build phase.
         makefileStream << this->PostBuildMakeTarget(gt->GetName(), *ct)
                        << ":\n";
-        }
+      }
 
-      if(gt->GetType() == cmState::EXECUTABLE ||
-         gt->GetType() == cmState::SHARED_LIBRARY ||
-         gt->GetType() == cmState::MODULE_LIBRARY)
-        {
+      if (gt->GetType() == cmState::EXECUTABLE ||
+          gt->GetType() == cmState::SHARED_LIBRARY ||
+          gt->GetType() == cmState::MODULE_LIBRARY) {
         std::string tfull = gt->GetFullPath(configName);
         std::string trel = this->ConvertToRelativeForMake(tfull.c_str());
 
         // Add this target to the post-build phases of its dependencies.
-        std::map<std::string, cmXCodeObject::StringVec>::const_iterator
-          y = target->GetDependTargets().find(*ct);
-        if(y != target->GetDependTargets().end())
-          {
+        std::map<std::string, cmXCodeObject::StringVec>::const_iterator y =
+          target->GetDependTargets().find(*ct);
+        if (y != target->GetDependTargets().end()) {
           std::vector<std::string> const& deptgts = y->second;
-          for(std::vector<std::string>::const_iterator d = deptgts.begin();
-              d != deptgts.end(); ++d)
-            {
+          for (std::vector<std::string>::const_iterator d = deptgts.begin();
+               d != deptgts.end(); ++d) {
             makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": "
                            << trel << "\n";
-            }
           }
+        }
 
         // Create a rule for this target.
         makefileStream << trel << ":";
 
         // List dependencies if any exist.
-        std::map<std::string, cmXCodeObject::StringVec>::const_iterator
-          x = target->GetDependLibraries().find(*ct);
-        if(x != target->GetDependLibraries().end())
-          {
+        std::map<std::string, cmXCodeObject::StringVec>::const_iterator x =
+          target->GetDependLibraries().find(*ct);
+        if (x != target->GetDependLibraries().end()) {
           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" <<
-              this->ConvertToRelativeForMake(d->c_str());
-            }
+          for (std::vector<std::string>::const_iterator d = deplibs.begin();
+               d != deplibs.end(); ++d) {
+            makefileStream << "\\\n\t"
+                           << this->ConvertToRelativeForMake(d->c_str());
           }
+        }
         // Write the action to remove the target if it is out of date.
         makefileStream << "\n";
         makefileStream << "\t/bin/rm -f "
@@ -3746,70 +3144,59 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
                        << "\n";
         // if building for more than one architecture
         // then remove those exectuables as well
-        if(this->Architectures.size() > 1)
-          {
+        if (this->Architectures.size() > 1) {
           std::string universal = this->GetObjectsNormalDirectory(
             this->CurrentProject, configName, gt);
-          for( std::vector<std::string>::iterator arch =
+          for (std::vector<std::string>::iterator arch =
                  this->Architectures.begin();
-               arch != this->Architectures.end(); ++arch)
-            {
+               arch != this->Architectures.end(); ++arch) {
             std::string universalFile = universal;
             universalFile += *arch;
             universalFile += "/";
             universalFile += gt->GetFullName(configName);
             makefileStream << "\t/bin/rm -f "
-                           <<
-              this->ConvertToRelativeForMake(universalFile.c_str())
+                           << this->ConvertToRelativeForMake(
+                                universalFile.c_str())
                            << "\n";
-            }
           }
-        makefileStream << "\n\n";
         }
+        makefileStream << "\n\n";
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
-                                           std::vector<cmLocalGenerator*>&
-                                           generators)
+void cmGlobalXCodeGenerator::OutputXCodeProject(
+  cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
 {
-  if(generators.size() == 0)
-    {
+  if (generators.size() == 0) {
     return;
-    }
+  }
   // Skip local generators that are excluded from this project.
-  for(std::vector<cmLocalGenerator*>::iterator g = generators.begin();
-      g != generators.end(); ++g)
-    {
-    if(this->IsExcluded(root, *g))
-      {
+  for (std::vector<cmLocalGenerator*>::iterator g = generators.begin();
+       g != generators.end(); ++g) {
+    if (this->IsExcluded(root, *g)) {
       continue;
-      }
     }
+  }
 
-  if (!this->CreateXCodeObjects(root, generators))
-    {
+  if (!this->CreateXCodeObjects(root, generators)) {
     return;
-    }
+  }
   std::string xcodeDir = root->GetCurrentBinaryDirectory();
   xcodeDir += "/";
   xcodeDir += root->GetProjectName();
   xcodeDir += ".xcode";
-  if(this->XcodeVersion > 20)
-    {
+  if (this->XcodeVersion > 20) {
     xcodeDir += "proj";
-    }
+  }
   cmSystemTools::MakeDirectory(xcodeDir.c_str());
   std::string xcodeProjFile = xcodeDir + "/project.pbxproj";
   cmGeneratedFileStream fout(xcodeProjFile.c_str());
   fout.SetCopyIfDifferent(true);
-  if(!fout)
-    {
+  if (!fout) {
     return;
-    }
+  }
   this->WriteXCodePBXProj(fout, root, generators);
   this->ClearXCodeObjects();
 
@@ -3819,11 +3206,9 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
     root->GetBinaryDirectory());
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
-                                          cmLocalGenerator* ,
-                                          std::vector<cmLocalGenerator*>& )
+void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
+                                               cmLocalGenerator*,
+                                               std::vector<cmLocalGenerator*>&)
 {
   SortXCodeObjects();
 
@@ -3836,8 +3221,7 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
   cmXCodeObject::Indent(1, fout);
   fout << "};\n";
   cmXCodeObject::Indent(1, fout);
-  if(this->XcodeVersion >= 21)
-    {
+  if (this->XcodeVersion >= 21) {
     if (this->XcodeVersion >= 32)
       fout << "objectVersion = 46;\n";
     else if (this->XcodeVersion >= 31)
@@ -3847,145 +3231,118 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
     else
       fout << "objectVersion = 42;\n";
     cmXCode21Object::PrintList(this->XCodeObjects, fout);
-    }
-  else
-    {
+  } else {
     fout << "objectVersion = 39;\n";
     cmXCodeObject::PrintList(this->XCodeObjects, fout);
-    }
+  }
   cmXCodeObject::Indent(1, fout);
   fout << "rootObject = " << this->RootObject->GetId()
        << " /* Project object */;\n";
   fout << "}\n";
 }
 
-//----------------------------------------------------------------------------
 const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const
 {
-  return this->XcodeVersion >= 21 ?
-    "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" : ".";
+  return this->XcodeVersion >= 21
+    ? "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"
+    : ".";
 }
 
-std::string cmGlobalXCodeGenerator::ExpandCFGIntDir(const std::string& str,
-                                        const std::string& config) const
+std::string cmGlobalXCodeGenerator::ExpandCFGIntDir(
+  const std::string& str, const std::string& config) const
 {
   std::string replace1 = "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
   std::string replace2 = "$(CONFIGURATION)";
 
   std::string tmp = str;
-  for(std::string::size_type i = tmp.find(replace1);
-      i != std::string::npos;
-      i = tmp.find(replace1, i))
-    {
+  for (std::string::size_type i = tmp.find(replace1); i != std::string::npos;
+       i = tmp.find(replace1, i)) {
     tmp.replace(i, replace1.size(), config);
     i += config.size();
-    }
-  for(std::string::size_type i = tmp.find(replace2);
-      i != std::string::npos;
-      i = tmp.find(replace2, i))
-    {
+  }
+  for (std::string::size_type i = tmp.find(replace2); i != std::string::npos;
+       i = tmp.find(replace2, i)) {
     tmp.replace(i, replace2.size(), config);
     i += config.size();
-    }
+  }
   return tmp;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry)
 {
   entry.Name = cmGlobalXCodeGenerator::GetActualName();
   entry.Brief = "Generate Xcode project files.";
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(const char* p)
 {
   return cmSystemTools::ConvertToOutputPath(p);
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p)
 {
   // We force conversion because Xcode breakpoints do not work unless
   // they are in a file named relative to the source tree.
-  return this->CurrentLocalGenerator->
-    ConvertToRelativePath(this->ProjectSourceDirectoryComponents, p, true);
+  return this->CurrentLocalGenerator->ConvertToRelativePath(
+    this->ProjectSourceDirectoryComponents, p, true);
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
 {
-  return this->CurrentLocalGenerator->
-    ConvertToRelativePath(this->ProjectOutputDirectoryComponents, p);
+  return this->CurrentLocalGenerator->ConvertToRelativePath(
+    this->ProjectOutputDirectoryComponents, p);
 }
 
-//----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
+std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
 {
-  std::string ret = p;
-  if(ret.find(' ') != ret.npos)
-    {
-    std::string t = ret;
-    ret = "\"";
-    ret += t;
-    ret += "\"";
-    }
-  return ret;
+  if (p.find(' ') != p.npos) {
+    std::string t = "\"";
+    t += p;
+    t += "\"";
+    return t;
+  }
+  return p;
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator
-::AppendDirectoryForConfig(const std::string& prefix,
-                           const std::string& config,
-                           const std::string& suffix,
-                           std::string& dir)
+void cmGlobalXCodeGenerator::AppendDirectoryForConfig(
+  const std::string& prefix, const std::string& config,
+  const std::string& suffix, std::string& dir)
 {
-  if(this->XcodeVersion > 20)
-    {
-    if(!config.empty())
-      {
+  if (this->XcodeVersion > 20) {
+    if (!config.empty()) {
       dir += prefix;
       dir += config;
       dir += suffix;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::LookupFlags(
-                                              const std::string& varNamePrefix,
-                                              const std::string& varNameLang,
-                                              const std::string& varNameSuffix,
-                                              const std::string& default_flags)
+  const std::string& varNamePrefix, const std::string& varNameLang,
+  const std::string& varNameSuffix, const std::string& default_flags)
 {
-  if(!varNameLang.empty())
-    {
+  if (!varNameLang.empty()) {
     std::string varName = varNamePrefix;
     varName += varNameLang;
     varName += varNameSuffix;
-    if(const char* varValue =
-       this->CurrentMakefile->GetDefinition(varName.c_str()))
-      {
-      if(*varValue)
-        {
+    if (const char* varValue =
+          this->CurrentMakefile->GetDefinition(varName.c_str())) {
+      if (*varValue) {
         return varValue;
-        }
       }
     }
+  }
   return default_flags;
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
                                            const char* defines_list,
                                            bool dflag)
 {
   // Skip this if there are no definitions.
-  if(!defines_list)
-    {
+  if (!defines_list) {
     return;
-    }
+  }
 
   // Expand the list of definitions.
   std::vector<std::string> defines;
@@ -3995,43 +3352,37 @@ void cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
   this->AppendDefines(defs, defines, dflag);
 }
 
-//----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
-                                      std::vector<std::string> const& defines,
-                                      bool dflag)
+void cmGlobalXCodeGenerator::AppendDefines(
+  BuildObjectListOrString& defs, std::vector<std::string> const& defines,
+  bool dflag)
 {
   // GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions.
   std::string def;
-  for(std::vector<std::string>::const_iterator di = defines.begin();
-      di != defines.end(); ++di)
-    {
+  for (std::vector<std::string>::const_iterator di = defines.begin();
+       di != defines.end(); ++di) {
     // Start with -D if requested.
-    def = dflag? "-D": "";
+    def = dflag ? "-D" : "";
     def += *di;
 
     // Append the flag with needed escapes.
     std::string tmp;
     this->AppendFlag(tmp, def);
-    defs.Add(tmp.c_str());
-    }
+    defs.Add(tmp);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
                                         std::string const& flag)
 {
   // Short-circuit for an empty flag.
-  if(flag.empty())
-    {
+  if (flag.empty()) {
     return;
-    }
+  }
 
   // Separate from previous flags.
-  if(!flags.empty())
-    {
+  if (!flags.empty()) {
     flags += " ";
-    }
+  }
 
   // Check if the flag needs quoting.
   bool quoteFlag =
@@ -4047,49 +3398,36 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
   // The final level of escaping is done when the string is stored
   // into the project file by cmXCodeObject::PrintString.
 
-  if(quoteFlag)
-    {
+  if (quoteFlag) {
     // Open single quote.
     flags += "'";
-    }
+  }
 
   // Flag value with escaped quotes and backslashes.
-  for(const char* c = flag.c_str(); *c; ++c)
-    {
-    if(*c == '\'')
-      {
-      if (this->XcodeVersion >= 40)
-        {
+  for (const char* c = flag.c_str(); *c; ++c) {
+    if (*c == '\'') {
+      if (this->XcodeVersion >= 40) {
         flags += "'\\''";
-        }
-      else
-        {
+      } else {
         flags += "\\'";
-        }
       }
-    else if(*c == '\\')
-      {
+    } else if (*c == '\\') {
       flags += "\\\\";
-      }
-    else
-      {
+    } else {
       flags += *c;
-      }
     }
+  }
 
-  if(quoteFlag)
-    {
+  if (quoteFlag) {
     // Close single quote.
     flags += "'";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmGlobalXCodeGenerator::ComputeInfoPListLocation(cmGeneratorTarget* target)
+std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation(
+  cmGeneratorTarget* target)
 {
-  std::string plist =
-      target->GetLocalGenerator()->GetCurrentBinaryDirectory();
+  std::string plist = target->GetLocalGenerator()->GetCurrentBinaryDirectory();
   plist += cmake::GetCMakeFilesDirectory();
   plist += "/";
   plist += target->GetName();
@@ -4097,40 +3435,34 @@ cmGlobalXCodeGenerator::ComputeInfoPListLocation(cmGeneratorTarget* target)
   return plist;
 }
 
-//----------------------------------------------------------------------------
 // Return true if the generated build tree may contain multiple builds.
 // i.e. "Can I build Debug and Release in the same tree?"
 bool cmGlobalXCodeGenerator::IsMultiConfig()
 {
   // Old Xcode 1.5 is single config:
-  if(this->XcodeVersion == 15)
-    {
+  if (this->XcodeVersion == 15) {
     return false;
-    }
+  }
 
   // Newer Xcode versions are multi config:
   return true;
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator
-::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
+void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
+  cmGeneratorTarget* gt) const
 {
   std::string configName = this->GetCMakeCFGIntDir();
-  std::string dir = this->GetObjectsNormalDirectory(
-    "$(PROJECT_NAME)", configName, gt);
-  if(this->XcodeVersion >= 21)
-    {
+  std::string dir =
+    this->GetObjectsNormalDirectory("$(PROJECT_NAME)", configName, gt);
+  if (this->XcodeVersion >= 21) {
     dir += "$(CURRENT_ARCH)/";
-    }
-  else
-    {
+  } else {
 #ifdef __ppc__
     dir += "ppc/";
 #endif
 #ifdef __i386
     dir += "i386/";
 #endif
-    }
+  }
   gt->ObjectDirectory = dir;
 }
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 862746f..2ca4c19 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -13,13 +13,13 @@
 #define cmGlobalXCodeGenerator_h
 
 #include "cmGlobalGenerator.h"
-#include "cmXCodeObject.h"
+
 #include "cmCustomCommand.h"
+#include "cmXCodeObject.h"
 class cmGlobalGeneratorFactory;
 class cmSourceFile;
 class cmSourceGroup;
 
-
 /** \class cmGlobalXCodeGenerator
  * \brief Write a Unix makefiles.
  *
@@ -32,36 +32,34 @@ public:
   static cmGlobalGeneratorFactory* NewFactory();
 
   ///! Get the name for the generator.
-  virtual std::string GetName() const {
-    return cmGlobalXCodeGenerator::GetActualName();}
-  static std::string GetActualName() {return "Xcode";}
+  virtual std::string GetName() const
+  {
+    return cmGlobalXCodeGenerator::GetActualName();
+  }
+  static std::string GetActualName() { return "Xcode"; }
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library
    * extension, pthreads, byte order etc.
    */
-  virtual void EnableLanguage(std::vector<std::string>const& languages,
-                              cmMakefile *, bool optional);
+  virtual void EnableLanguage(std::vector<std::string> const& languages,
+                              cmMakefile*, bool optional);
   /**
    * Try running cmake and building a file. This is used for dynalically
    * loaded commands, not as part of the usual build process.
    */
   virtual void GenerateBuildCommand(
-    std::vector<std::string>& makeCommand,
-    const std::string& makeProgram,
-    const std::string& projectName,
-    const std::string& projectDir,
-    const std::string& targetName,
-    const std::string& config,
-    bool fast, bool verbose,
-    std::vector<std::string> const& makeOptions = std::vector<std::string>()
-    );
+    std::vector<std::string>& makeCommand, const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
+    bool verbose,
+    std::vector<std::string> const& makeOptions = std::vector<std::string>());
 
   /** Append the subdirectory for the given configuration.  */
   virtual void AppendDirectoryForConfig(const std::string& prefix,
@@ -85,18 +83,18 @@ public:
 
   virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
   void AppendFlag(std::string& flags, std::string const& flag);
+
 protected:
   virtual void AddExtraIDETargets();
   virtual void Generate();
+
 private:
   cmXCodeObject* CreateOrGetPBXGroup(cmGeneratorTarget* gtgt,
                                      cmSourceGroup* sg);
-  cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
-                                std::string name);
+  cmXCodeObject* CreatePBXGroup(cmXCodeObject* parent, std::string name);
   bool CreateGroups(cmLocalGenerator* root,
-                    std::vector<cmLocalGenerator*>&
-                    generators);
-  std::string XCodeEscapePath(const char* p);
+                    std::vector<cmLocalGenerator*>& generators);
+  std::string XCodeEscapePath(const std::string& p);
   std::string RelativeToSource(const char* p);
   std::string RelativeToBinary(const char* p);
   std::string ConvertToRelativeForMake(const char* p);
@@ -106,22 +104,21 @@ private:
                             cmXCodeObject* resourceBuildPhase,
                             std::vector<cmXCodeObject*> contentBuildPhases,
                             cmXCodeObject* frameworkBuildPhase,
-                            cmGeneratorTarget *gtgt);
+                            cmGeneratorTarget* gtgt);
 
-  std::string ComputeInfoPListLocation(cmGeneratorTarget *target);
+  std::string ComputeInfoPListLocation(cmGeneratorTarget* target);
 
   void AddCommandsToBuildPhase(cmXCodeObject* buildphase,
-                               cmGeneratorTarget *target,
-                               std::vector<cmCustomCommand>
-                               const & commands,
+                               cmGeneratorTarget* target,
+                               std::vector<cmCustomCommand> const& commands,
                                const char* commandFileName);
 
   void CreateCustomRulesMakefile(const char* makefileBasename,
                                  cmGeneratorTarget* target,
-                                 std::vector<cmCustomCommand> const & commands,
+                                 std::vector<cmCustomCommand> const& commands,
                                  const std::string& configName);
 
-  cmXCodeObject* FindXCodeTarget(const cmGeneratorTarget *);
+  cmXCodeObject* FindXCodeTarget(const cmGeneratorTarget*);
   std::string GetOrCreateId(const std::string& name, const std::string& id);
 
   // create cmXCodeObject from these functions so that memory can be managed
@@ -131,23 +128,23 @@ private:
   cmXCodeObject* CreateString(const std::string& s);
   cmXCodeObject* CreateObjectReference(cmXCodeObject*);
   cmXCodeObject* CreateFlatClone(cmXCodeObject*);
-  cmXCodeObject* CreateXCodeTarget(cmGeneratorTarget *gtgt,
+  cmXCodeObject* CreateXCodeTarget(cmGeneratorTarget* gtgt,
                                    cmXCodeObject* buildPhases);
   void ForceLinkerLanguages();
   void ForceLinkerLanguage(cmGeneratorTarget* gtgt);
-  const char* GetTargetLinkFlagsVar(const cmGeneratorTarget *target) const;
+  const char* GetTargetLinkFlagsVar(const cmGeneratorTarget* target) const;
   const char* GetTargetFileType(cmGeneratorTarget* target);
   const char* GetTargetProductType(cmGeneratorTarget* target);
   std::string AddConfigurations(cmXCodeObject* target,
-                                cmGeneratorTarget *gtgt);
+                                cmGeneratorTarget* gtgt);
   void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
                                const char* value);
   void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
                                    const char* value,
                                    const std::string& configName);
-  cmXCodeObject* CreateUtilityTarget(cmGeneratorTarget *gtgt);
+  cmXCodeObject* CreateUtilityTarget(cmGeneratorTarget* gtgt);
   void AddDependAndLinkInformation(cmXCodeObject* target);
-  void CreateBuildSettings(cmGeneratorTarget *gtgt,
+  void CreateBuildSettings(cmGeneratorTarget* gtgt,
                            cmXCodeObject* buildSettings,
                            const std::string& buildType);
   std::string ExtractFlag(const char* flag, std::string& flags);
@@ -164,32 +161,28 @@ private:
                           std::vector<cmLocalGenerator*>& generators);
   void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root,
                          std::vector<cmLocalGenerator*>& generators);
-  cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string &fullpath,
-                                                  cmGeneratorTarget *target,
-                                                  const std::string &lang,
+  cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath,
+                                                  cmGeneratorTarget* target,
+                                                  const std::string& lang,
                                                   cmSourceFile* sf);
-  cmXCodeObject* CreateXCodeSourceFileFromPath(const std::string &fullpath,
-                                               cmGeneratorTarget *target,
-                                               const std::string &lang,
+  cmXCodeObject* CreateXCodeSourceFileFromPath(const std::string& fullpath,
+                                               cmGeneratorTarget* target,
+                                               const std::string& lang,
                                                cmSourceFile* sf);
   cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf,
-                                          cmGeneratorTarget *target);
-  cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
-                                       cmSourceFile* sf,
-                                       cmGeneratorTarget *gtgt);
-  bool CreateXCodeTargets(cmLocalGenerator* gen,
-                          std::vector<cmXCodeObject*>&);
+                                          cmGeneratorTarget* target);
+  cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen, cmSourceFile* sf,
+                                       cmGeneratorTarget* gtgt);
+  bool CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*>&);
   bool IsHeaderFile(cmSourceFile*);
-  void AddDependTarget(cmXCodeObject* target,
-                       cmXCodeObject* dependTarget);
+  void AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget);
   void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);
   bool SpecialTargetEmitted(std::string const& tname);
   void SetGenerationRoot(cmLocalGenerator* root);
   void AddExtraTargets(cmLocalGenerator* root,
                        std::vector<cmLocalGenerator*>& gens);
-  cmXCodeObject* CreateBuildPhase(const char* name,
-                                  const char* name2,
-                                  cmGeneratorTarget *target,
+  cmXCodeObject* CreateBuildPhase(const char* name, const char* name2,
+                                  cmGeneratorTarget* target,
                                   const std::vector<cmCustomCommand>&);
   void CreateReRunCMakeFile(cmLocalGenerator* root,
                             std::vector<cmLocalGenerator*> const& gens);
@@ -210,6 +203,7 @@ private:
                      bool dflag = false);
 
   void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
 protected:
   virtual const char* GetInstallTargetName() const { return "install"; }
   virtual const char* GetPackageTargetName() const { return "package"; }
@@ -219,6 +213,7 @@ protected:
   std::set<std::string> XCodeObjectIDs;
   std::vector<cmXCodeObject*> XCodeObjects;
   cmXCodeObject* RootObject;
+
 private:
   std::string const& GetXcodeBuildCommand();
   std::string FindXcodeBuildCommand();
@@ -226,13 +221,15 @@ private:
   bool XcodeBuildCommandInitialized;
 
   void PrintCompilerAdvice(std::ostream&, std::string const&,
-                           const char*) const {}
+                           const char*) const
+  {
+  }
 
-  std::string GetObjectsNormalDirectory(const std::string &projName,
-    const std::string &configName,
-    const cmGeneratorTarget *t) const;
+  std::string GetObjectsNormalDirectory(const std::string& projName,
+                                        const std::string& configName,
+                                        const cmGeneratorTarget* t) const;
 
-  void addObject(cmXCodeObject *obj);
+  void addObject(cmXCodeObject* obj);
   std::string PostBuildMakeTarget(std::string const& tName,
                                   std::string const& configName);
   cmXCodeObject* MainGroupChildren;
@@ -248,11 +245,11 @@ private:
   std::vector<std::string> CurrentOutputDirectoryComponents;
   std::vector<std::string> ProjectSourceDirectoryComponents;
   std::vector<std::string> ProjectOutputDirectoryComponents;
-  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::map<cmGeneratorTarget const*, cmXCodeObject* > XCodeObjectMap;
+  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::map<cmGeneratorTarget const*, cmXCodeObject*> XCodeObjectMap;
   std::vector<std::string> Architectures;
   std::string GeneratorToolset;
 };
diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h
index 0149d33..5666d48 100644
--- a/Source/cmGraphAdjacencyList.h
+++ b/Source/cmGraphAdjacencyList.h
@@ -22,10 +22,26 @@
 class cmGraphEdge
 {
 public:
-  cmGraphEdge(): Dest(0), Strong(true) {}
-  cmGraphEdge(int n): Dest(n), Strong(true) {}
-  cmGraphEdge(int n, bool s): Dest(n), Strong(s) {}
-  cmGraphEdge(cmGraphEdge const& r): Dest(r.Dest), Strong(r.Strong) {}
+  cmGraphEdge()
+    : Dest(0)
+    , Strong(true)
+  {
+  }
+  cmGraphEdge(int n)
+    : Dest(n)
+    , Strong(true)
+  {
+  }
+  cmGraphEdge(int n, bool s)
+    : Dest(n)
+    , Strong(s)
+  {
+  }
+  cmGraphEdge(cmGraphEdge const& r)
+    : Dest(r.Dest)
+    , Strong(r.Strong)
+  {
+  }
   operator int() const { return this->Dest; }
 
   bool IsStrong() const { return this->Strong; }
@@ -33,8 +49,14 @@ private:
   int Dest;
   bool Strong;
 };
-struct cmGraphEdgeList: public std::vector<cmGraphEdge> {};
-struct cmGraphNodeList: public std::vector<int> {};
-struct cmGraphAdjacencyList: public std::vector<cmGraphEdgeList> {};
+struct cmGraphEdgeList : public std::vector<cmGraphEdge>
+{
+};
+struct cmGraphNodeList : public std::vector<int>
+{
+};
+struct cmGraphAdjacencyList : public std::vector<cmGraphEdgeList>
+{
+};
 
 #endif
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 448306f..20cd171 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -10,22 +10,19 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGraphVizWriter.h"
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
-#include "cmGlobalGenerator.h"
-#include "cmGeneratedFileStream.h"
-
 
+#include "cmGeneratedFileStream.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
 
 static const char* getShapeForTarget(const cmGeneratorTarget* target)
 {
-  if (!target)
-    {
+  if (!target) {
     return "ellipse";
-    }
+  }
 
-  switch ( target->GetType() )
-    {
+  switch (target->GetType()) {
     case cmState::EXECUTABLE:
       return "house";
     case cmState::STATIC_LIBRARY:
@@ -36,31 +33,29 @@ static const char* getShapeForTarget(const cmGeneratorTarget* target)
       return "octagon";
     default:
       break;
-    }
+  }
 
   return "box";
 }
 
-
-cmGraphVizWriter::cmGraphVizWriter(const std::vector<cmLocalGenerator*>&
-                                                               localGenerators)
-:GraphType("digraph")
-,GraphName("GG")
-,GraphHeader("node [\n  fontsize = \"12\"\n];")
-,GraphNodePrefix("node")
-,LocalGenerators(localGenerators)
-,GenerateForExecutables(true)
-,GenerateForStaticLibs(true)
-,GenerateForSharedLibs(true)
-,GenerateForModuleLibs(true)
-,GenerateForExternals(true)
-,GeneratePerTarget(true)
-,GenerateDependers(true)
-,HaveTargetsAndLibs(false)
+cmGraphVizWriter::cmGraphVizWriter(
+  const std::vector<cmLocalGenerator*>& localGenerators)
+  : GraphType("digraph")
+  , GraphName("GG")
+  , GraphHeader("node [\n  fontsize = \"12\"\n];")
+  , GraphNodePrefix("node")
+  , LocalGenerators(localGenerators)
+  , GenerateForExecutables(true)
+  , GenerateForStaticLibs(true)
+  , GenerateForSharedLibs(true)
+  , GenerateForModuleLibs(true)
+  , GenerateForExternals(true)
+  , GeneratePerTarget(true)
+  , GenerateDependers(true)
+  , HaveTargetsAndLibs(false)
 {
 }
 
-
 void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
                                     const char* fallbackSettingsFileName)
 {
@@ -70,36 +65,32 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator ggi(&cm);
   cmsys::auto_ptr<cmMakefile> mf(
-        new cmMakefile(&ggi, cm.GetCurrentSnapshot()));
+    new cmMakefile(&ggi, cm.GetCurrentSnapshot()));
   cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator(mf.get()));
 
   const char* inFileName = settingsFileName;
 
-  if ( !cmSystemTools::FileExists(inFileName) )
-    {
+  if (!cmSystemTools::FileExists(inFileName)) {
     inFileName = fallbackSettingsFileName;
-    if ( !cmSystemTools::FileExists(inFileName) )
-      {
+    if (!cmSystemTools::FileExists(inFileName)) {
       return;
-      }
     }
+  }
 
-  if ( !mf->ReadListFile(inFileName) )
-    {
+  if (!mf->ReadListFile(inFileName)) {
     cmSystemTools::Error("Problem opening GraphViz options file: ",
                          inFileName);
     return;
-    }
+  }
 
   std::cout << "Reading GraphViz options file: " << inFileName << std::endl;
 
-#define __set_if_set(var, cmakeDefinition) \
-  { \
-  const char* value = mf->GetDefinition(cmakeDefinition); \
-  if ( value ) \
-    { \
-    var = value; \
-    } \
+#define __set_if_set(var, cmakeDefinition)                                    \
+  {                                                                           \
+    const char* value = mf->GetDefinition(cmakeDefinition);                   \
+    if (value) {                                                              \
+      var = value;                                                            \
+    }                                                                         \
   }
 
   __set_if_set(this->GraphType, "GRAPHVIZ_GRAPH_TYPE");
@@ -107,13 +98,12 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
   __set_if_set(this->GraphHeader, "GRAPHVIZ_GRAPH_HEADER");
   __set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
 
-#define __set_bool_if_set(var, cmakeDefinition) \
-  { \
-  const char* value = mf->GetDefinition(cmakeDefinition); \
-  if ( value ) \
-    { \
-    var = mf->IsOn(cmakeDefinition); \
-    } \
+#define __set_bool_if_set(var, cmakeDefinition)                               \
+  {                                                                           \
+    const char* value = mf->GetDefinition(cmakeDefinition);                   \
+    if (value) {                                                              \
+      var = mf->IsOn(cmakeDefinition);                                        \
+    }                                                                         \
   }
 
   __set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
@@ -128,55 +118,44 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
   __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
 
   this->TargetsToIgnoreRegex.clear();
-  if (!ignoreTargetsRegexes.empty())
-    {
+  if (!ignoreTargetsRegexes.empty()) {
     std::vector<std::string> ignoreTargetsRegExVector;
     cmSystemTools::ExpandListArgument(ignoreTargetsRegexes,
                                       ignoreTargetsRegExVector);
-    for(std::vector<std::string>::const_iterator itvIt
-                                            = ignoreTargetsRegExVector.begin();
-        itvIt != ignoreTargetsRegExVector.end();
-        ++ itvIt )
-      {
+    for (std::vector<std::string>::const_iterator itvIt =
+           ignoreTargetsRegExVector.begin();
+         itvIt != ignoreTargetsRegExVector.end(); ++itvIt) {
       std::string currentRegexString(*itvIt);
       cmsys::RegularExpression currentRegex;
-      if (!currentRegex.compile(currentRegexString.c_str()))
-        {
+      if (!currentRegex.compile(currentRegexString.c_str())) {
         std::cerr << "Could not compile bad regex \"" << currentRegexString
                   << "\"" << std::endl;
-        }
-      this->TargetsToIgnoreRegex.push_back(currentRegex);
       }
+      this->TargetsToIgnoreRegex.push_back(currentRegex);
     }
-
+  }
 }
 
-
 // Iterate over all targets and write for each one a graph which shows
 // which other targets depend on it.
 void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
 {
-  if(this->GenerateDependers == false)
-    {
+  if (this->GenerateDependers == false) {
     return;
-    }
+  }
 
   this->CollectTargetsAndLibs();
 
-  for(std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
-                                                      this->TargetPtrs.begin();
-      ptrIt != this->TargetPtrs.end();
-      ++ptrIt)
-    {
-    if (ptrIt->second == NULL)
-      {
+  for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
+         this->TargetPtrs.begin();
+       ptrIt != this->TargetPtrs.end(); ++ptrIt) {
+    if (ptrIt->second == NULL) {
       continue;
-      }
+    }
 
-    if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
-      {
+    if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) {
       continue;
-      }
+    }
 
     std::string currentFilename = fileName;
     currentFilename += ".";
@@ -184,10 +163,9 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
     currentFilename += ".dependers";
 
     cmGeneratedFileStream str(currentFilename.c_str());
-    if ( !str )
-      {
+    if (!str) {
       return;
-      }
+    }
 
     std::set<std::string> insertedConnections;
     std::set<std::string> insertedNodes;
@@ -195,39 +173,33 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
     std::cout << "Writing " << currentFilename << "..." << std::endl;
     this->WriteHeader(str);
 
-    this->WriteDependerConnections(ptrIt->first,
-                                   insertedNodes, insertedConnections, str);
+    this->WriteDependerConnections(ptrIt->first, insertedNodes,
+                                   insertedConnections, str);
 
     this->WriteFooter(str);
-    }
+  }
 }
 
-
 // Iterate over all targets and write for each one a graph which shows
 // on which targets it depends.
 void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
 {
-  if(this->GeneratePerTarget == false)
-    {
+  if (this->GeneratePerTarget == false) {
     return;
-    }
+  }
 
   this->CollectTargetsAndLibs();
 
-  for(std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
-                                                      this->TargetPtrs.begin();
-      ptrIt != this->TargetPtrs.end();
-      ++ptrIt)
-    {
-    if (ptrIt->second == NULL)
-      {
+  for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
+         this->TargetPtrs.begin();
+       ptrIt != this->TargetPtrs.end(); ++ptrIt) {
+    if (ptrIt->second == NULL) {
       continue;
-      }
+    }
 
-    if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
-      {
+    if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) {
       continue;
-      }
+    }
 
     std::set<std::string> insertedConnections;
     std::set<std::string> insertedNodes;
@@ -236,31 +208,27 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
     currentFilename += ".";
     currentFilename += ptrIt->first;
     cmGeneratedFileStream str(currentFilename.c_str());
-    if ( !str )
-      {
+    if (!str) {
       return;
-      }
+    }
 
     std::cout << "Writing " << currentFilename << "..." << std::endl;
     this->WriteHeader(str);
 
-    this->WriteConnections(ptrIt->first,
-                              insertedNodes, insertedConnections, str);
+    this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections,
+                           str);
     this->WriteFooter(str);
-    }
-
+  }
 }
 
-
 void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
 {
   this->CollectTargetsAndLibs();
 
   cmGeneratedFileStream str(fileName);
-  if ( !str )
-    {
+  if (!str) {
     return;
-    }
+  }
   this->WriteHeader(str);
 
   std::cout << "Writing " << fileName << "..." << std::endl;
@@ -268,323 +236,268 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
   std::set<std::string> insertedConnections;
   std::set<std::string> insertedNodes;
 
-  for(std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
-                                                      this->TargetPtrs.begin();
-      ptrIt != this->TargetPtrs.end();
-      ++ptrIt)
-    {
-    if (ptrIt->second == NULL)
-      {
+  for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
+         this->TargetPtrs.begin();
+       ptrIt != this->TargetPtrs.end(); ++ptrIt) {
+    if (ptrIt->second == NULL) {
       continue;
-      }
+    }
 
-    if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
-      {
+    if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) {
       continue;
-      }
-
-    this->WriteConnections(ptrIt->first,
-                              insertedNodes, insertedConnections, str);
     }
+
+    this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections,
+                           str);
+  }
   this->WriteFooter(str);
 }
 
-
 void cmGraphVizWriter::WriteHeader(cmGeneratedFileStream& str) const
 {
   str << this->GraphType << " \"" << this->GraphName << "\" {" << std::endl;
   str << this->GraphHeader << std::endl;
 }
 
-
 void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const
 {
   str << "}" << std::endl;
 }
 
-
-void cmGraphVizWriter::WriteConnections(const std::string& targetName,
-                                    std::set<std::string>& insertedNodes,
-                                    std::set<std::string>& insertedConnections,
-                                    cmGeneratedFileStream& str) const
+void cmGraphVizWriter::WriteConnections(
+  const std::string& targetName, std::set<std::string>& insertedNodes,
+  std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const
 {
-  std::map<std::string, const cmGeneratorTarget* >::const_iterator targetPtrIt
-      = this->TargetPtrs.find(targetName);
+  std::map<std::string, const cmGeneratorTarget*>::const_iterator targetPtrIt =
+    this->TargetPtrs.find(targetName);
 
-  if (targetPtrIt == this->TargetPtrs.end())  // not found at all
-    {
+  if (targetPtrIt == this->TargetPtrs.end()) // not found at all
+  {
     return;
-    }
+  }
 
   this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str);
 
   if (targetPtrIt->second == NULL) // it's an external library
-    {
+  {
     return;
-    }
-
+  }
 
   std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
 
   const cmTarget::LinkLibraryVectorType* ll =
-      &(targetPtrIt->second->Target->GetOriginalLinkLibraries());
+    &(targetPtrIt->second->Target->GetOriginalLinkLibraries());
 
   for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
-       llit != ll->end();
-       ++ llit )
-    {
+       llit != ll->end(); ++llit) {
     const char* libName = llit->first.c_str();
     std::map<std::string, std::string>::const_iterator libNameIt =
-                                          this->TargetNamesNodes.find(libName);
+      this->TargetNamesNodes.find(libName);
 
     // can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used
-    if(libNameIt == this->TargetNamesNodes.end())
-      {
+    if (libNameIt == this->TargetNamesNodes.end()) {
       continue;
-      }
+    }
 
     std::string connectionName = myNodeName;
     connectionName += "-";
     connectionName += libNameIt->second;
-    if (insertedConnections.find(connectionName) == insertedConnections.end())
-      {
+    if (insertedConnections.find(connectionName) ==
+        insertedConnections.end()) {
       insertedConnections.insert(connectionName);
       this->WriteNode(libName, this->TargetPtrs.find(libName)->second,
                       insertedNodes, str);
 
-      str << "    \"" << myNodeName << "\" -> \""
-          << libNameIt->second << "\"";
+      str << "    \"" << myNodeName << "\" -> \"" << libNameIt->second << "\"";
       str << " // " << targetName << " -> " << libName << std::endl;
       this->WriteConnections(libName, insertedNodes, insertedConnections, str);
-      }
     }
-
+  }
 }
 
-
-void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
-                                    std::set<std::string>& insertedNodes,
-                                    std::set<std::string>& insertedConnections,
-                                    cmGeneratedFileStream& str) const
+void cmGraphVizWriter::WriteDependerConnections(
+  const std::string& targetName, std::set<std::string>& insertedNodes,
+  std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const
 {
-  std::map<std::string, const cmGeneratorTarget* >::const_iterator targetPtrIt
-      = this->TargetPtrs.find(targetName);
+  std::map<std::string, const cmGeneratorTarget*>::const_iterator targetPtrIt =
+    this->TargetPtrs.find(targetName);
 
-  if (targetPtrIt == this->TargetPtrs.end())  // not found at all
-    {
+  if (targetPtrIt == this->TargetPtrs.end()) // not found at all
+  {
     return;
-    }
+  }
 
   this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str);
 
   if (targetPtrIt->second == NULL) // it's an external library
-    {
+  {
     return;
-    }
-
+  }
 
   std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
 
   // now search who links against me
-  for(std::map<std::string, const cmGeneratorTarget*>::const_iterator
-      dependerIt = this->TargetPtrs.begin();
-      dependerIt != this->TargetPtrs.end();
-      ++dependerIt)
-    {
-    if (dependerIt->second == NULL)
-      {
+  for (std::map<std::string, const cmGeneratorTarget*>::const_iterator
+         dependerIt = this->TargetPtrs.begin();
+       dependerIt != this->TargetPtrs.end(); ++dependerIt) {
+    if (dependerIt->second == NULL) {
       continue;
-      }
+    }
 
-    if (this->GenerateForTargetType(dependerIt->second->GetType()) == false)
-      {
+    if (this->GenerateForTargetType(dependerIt->second->GetType()) == false) {
       continue;
-      }
+    }
 
     // Now we have a target, check whether it links against targetName.
     // If so, draw a connection, and then continue with dependers on that one.
     const cmTarget::LinkLibraryVectorType* ll =
-        &(dependerIt->second->Target->GetOriginalLinkLibraries());
+      &(dependerIt->second->Target->GetOriginalLinkLibraries());
 
     for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
-         llit != ll->end();
-         ++ llit )
-      {
+         llit != ll->end(); ++llit) {
       std::string libName = llit->first;
-      if (libName == targetName)
-        {
+      if (libName == targetName) {
         // So this target links against targetName.
         std::map<std::string, std::string>::const_iterator dependerNodeNameIt =
-                                this->TargetNamesNodes.find(dependerIt->first);
+          this->TargetNamesNodes.find(dependerIt->first);
 
-        if(dependerNodeNameIt != this->TargetNamesNodes.end())
-          {
+        if (dependerNodeNameIt != this->TargetNamesNodes.end()) {
           std::string connectionName = dependerNodeNameIt->second;
           connectionName += "-";
           connectionName += myNodeName;
 
           if (insertedConnections.find(connectionName) ==
-                                                     insertedConnections.end())
-            {
+              insertedConnections.end()) {
             insertedConnections.insert(connectionName);
             this->WriteNode(dependerIt->first, dependerIt->second,
                             insertedNodes, str);
 
             str << "    \"" << dependerNodeNameIt->second << "\" -> \""
                 << myNodeName << "\"";
-            str << " // " <<targetName<< " -> " <<dependerIt->first<<std::endl;
-            this->WriteDependerConnections(dependerIt->first,
-                                      insertedNodes, insertedConnections, str);
-            }
-
-
+            str << " // " << targetName << " -> " << dependerIt->first
+                << std::endl;
+            this->WriteDependerConnections(dependerIt->first, insertedNodes,
+                                           insertedConnections, str);
           }
-        break;
         }
+        break;
       }
     }
-
+  }
 }
 
-
 void cmGraphVizWriter::WriteNode(const std::string& targetName,
                                  const cmGeneratorTarget* target,
                                  std::set<std::string>& insertedNodes,
                                  cmGeneratedFileStream& str) const
 {
-  if (insertedNodes.find(targetName) == insertedNodes.end())
-  {
+  if (insertedNodes.find(targetName) == insertedNodes.end()) {
     insertedNodes.insert(targetName);
     std::map<std::string, std::string>::const_iterator nameIt =
-                                       this->TargetNamesNodes.find(targetName);
+      this->TargetNamesNodes.find(targetName);
 
-    str << "    \"" << nameIt->second << "\" [ label=\""
-        << targetName <<  "\" shape=\"" << getShapeForTarget(target)
-        << "\"];" << std::endl;
+    str << "    \"" << nameIt->second << "\" [ label=\"" << targetName
+        << "\" shape=\"" << getShapeForTarget(target) << "\"];" << std::endl;
   }
 }
 
-
 void cmGraphVizWriter::CollectTargetsAndLibs()
 {
-  if (this->HaveTargetsAndLibs == false)
-    {
+  if (this->HaveTargetsAndLibs == false) {
     this->HaveTargetsAndLibs = true;
     int cnt = this->CollectAllTargets();
-    if (this->GenerateForExternals)
-      {
+    if (this->GenerateForExternals) {
       this->CollectAllExternalLibs(cnt);
-      }
     }
+  }
 }
 
-
 int cmGraphVizWriter::CollectAllTargets()
 {
   int cnt = 0;
   // First pass get the list of all cmake targets
   for (std::vector<cmLocalGenerator*>::const_iterator lit =
-                                                 this->LocalGenerators.begin();
-       lit != this->LocalGenerators.end();
-       ++ lit )
-    {
+         this->LocalGenerators.begin();
+       lit != this->LocalGenerators.end(); ++lit) {
     std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets();
-    for ( std::vector<cmGeneratorTarget*>::const_iterator it =
-          targets.begin(); it != targets.end(); ++it )
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin();
+         it != targets.end(); ++it) {
       const char* realTargetName = (*it)->GetName().c_str();
-      if(this->IgnoreThisTarget(realTargetName))
-        {
+      if (this->IgnoreThisTarget(realTargetName)) {
         // Skip ignored targets
         continue;
-        }
-      //std::cout << "Found target: " << tit->first.c_str() << std::endl;
+      }
+      // std::cout << "Found target: " << tit->first.c_str() << std::endl;
       std::ostringstream ostr;
       ostr << this->GraphNodePrefix << cnt++;
       this->TargetNamesNodes[realTargetName] = ostr.str();
       this->TargetPtrs[realTargetName] = *it;
-      }
     }
+  }
 
   return cnt;
 }
 
-
 int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
 {
   // Ok, now find all the stuff we link to that is not in cmake
   for (std::vector<cmLocalGenerator*>::const_iterator lit =
-                                                 this->LocalGenerators.begin();
-       lit != this->LocalGenerators.end();
-       ++ lit )
-    {
+         this->LocalGenerators.begin();
+       lit != this->LocalGenerators.end(); ++lit) {
     std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets();
-    for ( std::vector<cmGeneratorTarget*>::const_iterator it =
-          targets.begin(); it != targets.end(); ++it )
-      {
+    for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin();
+         it != targets.end(); ++it) {
       const char* realTargetName = (*it)->GetName().c_str();
-      if (this->IgnoreThisTarget(realTargetName))
-        {
+      if (this->IgnoreThisTarget(realTargetName)) {
         // Skip ignored targets
         continue;
-        }
+      }
       const cmTarget::LinkLibraryVectorType* ll =
-          &((*it)->Target->GetOriginalLinkLibraries());
+        &((*it)->Target->GetOriginalLinkLibraries());
       for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
-           llit != ll->end();
-           ++ llit )
-        {
+           llit != ll->end(); ++llit) {
         const char* libName = llit->first.c_str();
-        if (this->IgnoreThisTarget(libName))
-          {
+        if (this->IgnoreThisTarget(libName)) {
           // Skip ignored targets
           continue;
-          }
+        }
 
-        std::map<std::string, const cmGeneratorTarget*>::const_iterator tarIt
-            = this->TargetPtrs.find(libName);
-        if ( tarIt == this->TargetPtrs.end() )
-          {
+        std::map<std::string, const cmGeneratorTarget*>::const_iterator tarIt =
+          this->TargetPtrs.find(libName);
+        if (tarIt == this->TargetPtrs.end()) {
           std::ostringstream ostr;
           ostr << this->GraphNodePrefix << cnt++;
           this->TargetNamesNodes[libName] = ostr.str();
           this->TargetPtrs[libName] = NULL;
           // str << "    \"" << ostr.c_str() << "\" [ label=\"" << libName
           // <<  "\" shape=\"ellipse\"];" << std::endl;
-          }
         }
       }
     }
-   return cnt;
+  }
+  return cnt;
 }
 
-
 bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
 {
-  for(std::vector<cmsys::RegularExpression>::iterator itvIt
-                                          = this->TargetsToIgnoreRegex.begin();
-      itvIt != this->TargetsToIgnoreRegex.end();
-      ++ itvIt )
-    {
+  for (std::vector<cmsys::RegularExpression>::iterator itvIt =
+         this->TargetsToIgnoreRegex.begin();
+       itvIt != this->TargetsToIgnoreRegex.end(); ++itvIt) {
     cmsys::RegularExpression& regEx = *itvIt;
-    if (regEx.is_valid())
-      {
-      if (regEx.find(name))
-        {
+    if (regEx.is_valid()) {
+      if (regEx.find(name)) {
         return true;
-        }
       }
     }
+  }
 
   return false;
 }
 
-
-bool cmGraphVizWriter::GenerateForTargetType(cmState::TargetType targetType)
-                                                                          const
+bool cmGraphVizWriter::GenerateForTargetType(
+  cmState::TargetType targetType) const
 {
-  switch (targetType)
-  {
+  switch (targetType) {
     case cmState::EXECUTABLE:
       return this->GenerateForExecutables;
     case cmState::STATIC_LIBRARY:
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index 90d31d3..c73d82d 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -1,5 +1,3 @@
-#ifndef CMGRAPHVIZWRITER_H
-#define CMGRAPHVIZWRITER_H
 /*============================================================================
   CMake - Cross Platform Makefile Generator
   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
@@ -11,9 +9,13 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
+#ifndef CMGRAPHVIZWRITER_H
+#define CMGRAPHVIZWRITER_H
+
 #include "cmStandardIncludes.h"
-#include "cmLocalGenerator.h"
+
 #include "cmGeneratedFileStream.h"
+#include "cmLocalGenerator.h"
 #include <cmsys/RegularExpression.hxx>
 
 class cmGeneratorTarget;
@@ -23,7 +25,6 @@ class cmGeneratorTarget;
 class cmGraphVizWriter
 {
 public:
-
   cmGraphVizWriter(const std::vector<cmLocalGenerator*>& localGenerators);
 
   void ReadSettings(const char* settingsFileName,
@@ -35,7 +36,6 @@ public:
   void WriteGlobalFile(const char* fileName);
 
 protected:
-
   void CollectTargetsAndLibs();
 
   int CollectAllTargets();
diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx
index 6ea597e..9609e95 100644
--- a/Source/cmHexFileConverter.cxx
+++ b/Source/cmHexFileConverter.cxx
@@ -14,62 +14,55 @@
 #include <stdio.h>
 #include <string.h>
 
-#define INTEL_HEX_MIN_LINE_LENGTH     (1+8        +2)
-#define INTEL_HEX_MAX_LINE_LENGTH     (1+8+(256*2)+2)
-#define MOTOROLA_SREC_MIN_LINE_LENGTH (2+2+4        +2)
-#define MOTOROLA_SREC_MAX_LINE_LENGTH (2+2+8+(256*2)+2)
+#define INTEL_HEX_MIN_LINE_LENGTH (1 + 8 + 2)
+#define INTEL_HEX_MAX_LINE_LENGTH (1 + 8 + (256 * 2) + 2)
+#define MOTOROLA_SREC_MIN_LINE_LENGTH (2 + 2 + 4 + 2)
+#define MOTOROLA_SREC_MAX_LINE_LENGTH (2 + 2 + 8 + (256 * 2) + 2)
 
 // might go to SystemTools ?
 static bool cm_IsHexChar(char c)
 {
-  return (((c >= '0') && (c <= '9'))
-         || ((c >= 'a') && (c <= 'f'))
-         || ((c >= 'A') && (c <= 'F')));
+  return (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
+          ((c >= 'A') && (c <= 'F')));
 }
 
 static unsigned int ChompStrlen(const char* line)
 {
-  if (line == 0)
-    {
+  if (line == 0) {
     return 0;
-    }
-  unsigned int  length = static_cast<unsigned int>(strlen(line));
-  if ((line[length-1] == '\n') || (line[length-1] == '\r'))
-    {
+  }
+  unsigned int length = static_cast<unsigned int>(strlen(line));
+  if ((line[length - 1] == '\n') || (line[length - 1] == '\r')) {
     length--;
-    }
-  if ((line[length-1] == '\n') || (line[length-1] == '\r'))
-    {
+  }
+  if ((line[length - 1] == '\n') || (line[length - 1] == '\r')) {
     length--;
-    }
+  }
   return length;
 }
 
-static bool OutputBin(FILE* file, const char * buf,
-                      unsigned int startIndex, unsigned int stopIndex)
+static bool OutputBin(FILE* file, const char* buf, unsigned int startIndex,
+                      unsigned int stopIndex)
 {
   bool success = true;
   char hexNumber[3];
   hexNumber[2] = '\0';
   char outBuf[256];
   unsigned int outBufCount = 0;
-  for (unsigned int i = startIndex; i < stopIndex; i += 2)
-    {
+  for (unsigned int i = startIndex; i < stopIndex; i += 2) {
     hexNumber[0] = buf[i];
-    hexNumber[1] = buf[i+1];
+    hexNumber[1] = buf[i + 1];
     unsigned int convertedByte = 0;
-    if (sscanf(hexNumber, "%x", &convertedByte) != 1)
-      {
+    if (sscanf(hexNumber, "%x", &convertedByte) != 1) {
       success = false;
       break;
-      }
+    }
     outBuf[outBufCount] = static_cast<char>(convertedByte & 0xff);
     outBufCount++;
-    }
-  if (success)
-    {
-    success = (fwrite(outBuf, 1, outBufCount, file)==outBufCount);
-    }
+  }
+  if (success) {
+    success = (fwrite(outBuf, 1, outBufCount, file) == outBufCount);
+  }
   return success;
 }
 
@@ -77,45 +70,35 @@ static bool OutputBin(FILE* file, const char * buf,
 static bool ConvertMotorolaSrecLine(const char* buf, FILE* outFile)
 {
   unsigned int slen = ChompStrlen(buf);
-  if ((slen < MOTOROLA_SREC_MIN_LINE_LENGTH)
-       || (slen > MOTOROLA_SREC_MAX_LINE_LENGTH))
-    {
+  if ((slen < MOTOROLA_SREC_MIN_LINE_LENGTH) ||
+      (slen > MOTOROLA_SREC_MAX_LINE_LENGTH)) {
     return false;
-    }
+  }
 
   // line length must be even
-  if (slen % 2 == 1)
-    {
+  if (slen % 2 == 1) {
     return false;
-    }
+  }
 
-  if (buf[0] != 'S')
-    {
+  if (buf[0] != 'S') {
     return false;
-    }
+  }
 
   unsigned int dataStart = 0;
   // ignore extra address records
-  if ((buf[1] == '5') || (buf[1] == '7') || (buf[1] == '8') || (buf[1] == '9'))
-    {
+  if ((buf[1] == '5') || (buf[1] == '7') || (buf[1] == '8') ||
+      (buf[1] == '9')) {
     return true;
-    }
-  else if (buf[1] == '1')
-    {
+  } else if (buf[1] == '1') {
     dataStart = 8;
-    }
-  else if (buf[1] == '2')
-    {
+  } else if (buf[1] == '2') {
     dataStart = 10;
-    }
-  else if (buf[1] == '3')
-    {
+  } else if (buf[1] == '3') {
     dataStart = 12;
-    }
-  else // unknown record type
-    {
+  } else // unknown record type
+  {
     return false;
-    }
+  }
 
   // ignore the last two bytes  (checksum)
   return OutputBin(outFile, buf, dataStart, slen - 2);
@@ -125,91 +108,77 @@ static bool ConvertMotorolaSrecLine(const char* buf, FILE* outFile)
 static bool ConvertIntelHexLine(const char* buf, FILE* outFile)
 {
   unsigned int slen = ChompStrlen(buf);
-  if ((slen < INTEL_HEX_MIN_LINE_LENGTH)
-       || (slen > INTEL_HEX_MAX_LINE_LENGTH))
-    {
+  if ((slen < INTEL_HEX_MIN_LINE_LENGTH) ||
+      (slen > INTEL_HEX_MAX_LINE_LENGTH)) {
     return false;
-    }
+  }
 
   // line length must be odd
-  if (slen % 2 == 0)
-    {
+  if (slen % 2 == 0) {
     return false;
-    }
+  }
 
-  if ((buf[0] != ':') || (buf[7] != '0'))
-    {
+  if ((buf[0] != ':') || (buf[7] != '0')) {
     return false;
-    }
+  }
 
   unsigned int dataStart = 0;
-  if ((buf[8] == '0') || (buf[8] == '1'))
-    {
+  if ((buf[8] == '0') || (buf[8] == '1')) {
     dataStart = 9;
-    }
+  }
   // ignore extra address records
-  else if ((buf[8] == '2') || (buf[8] == '3') || (buf[8] == '4')
-            || (buf[8] == '5'))
-    {
+  else if ((buf[8] == '2') || (buf[8] == '3') || (buf[8] == '4') ||
+           (buf[8] == '5')) {
     return true;
-    }
-  else  // unknown record type
-    {
+  } else // unknown record type
+  {
     return false;
-    }
+  }
 
-// ignore the last two bytes  (checksum)
+  // ignore the last two bytes  (checksum)
   return OutputBin(outFile, buf, dataStart, slen - 2);
 }
 
 cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType(
-                                                        const char* inFileName)
+  const char* inFileName)
 {
   char buf[1024];
   FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb");
-  if (inFile == 0)
-    {
+  if (inFile == 0) {
     return Binary;
-    }
+  }
 
-  if(!fgets(buf, 1024, inFile))
-    {
+  if (!fgets(buf, 1024, inFile)) {
     buf[0] = 0;
-    }
+  }
   fclose(inFile);
   FileType type = Binary;
   unsigned int minLineLength = 0;
   unsigned int maxLineLength = 0;
   if (buf[0] == ':') // might be an intel hex file
-    {
+  {
     type = IntelHex;
     minLineLength = INTEL_HEX_MIN_LINE_LENGTH;
     maxLineLength = INTEL_HEX_MAX_LINE_LENGTH;
-    }
-  else if (buf[0] == 'S') // might be a motorola srec file
-    {
+  } else if (buf[0] == 'S') // might be a motorola srec file
+  {
     type = MotorolaSrec;
     minLineLength = MOTOROLA_SREC_MIN_LINE_LENGTH;
     maxLineLength = MOTOROLA_SREC_MAX_LINE_LENGTH;
-    }
-  else
-    {
+  } else {
     return Binary;
-    }
+  }
 
   unsigned int slen = ChompStrlen(buf);
-  if ((slen < minLineLength) || (slen > maxLineLength))
-    {
+  if ((slen < minLineLength) || (slen > maxLineLength)) {
     return Binary;
-    }
+  }
 
-  for (unsigned int i = 1; i < slen; i++)
-    {
-    if (!cm_IsHexChar(buf[i]))
-      {
+  for (unsigned int i = 1; i < slen; i++) {
+    if (!cm_IsHexChar(buf[i])) {
       return Binary;
-      }
     }
+  }
   return type;
 }
 
@@ -217,49 +186,39 @@ bool cmHexFileConverter::TryConvert(const char* inFileName,
                                     const char* outFileName)
 {
   FileType type = DetermineFileType(inFileName);
-  if (type == Binary)
-    {
+  if (type == Binary) {
     return false;
-    }
+  }
 
   // try to open the file
   FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb");
   FILE* outFile = cmsys::SystemTools::Fopen(outFileName, "wb");
-  if ((inFile == 0) || (outFile == 0))
-    {
-    if (inFile != 0)
-      {
+  if ((inFile == 0) || (outFile == 0)) {
+    if (inFile != 0) {
       fclose(inFile);
-      }
-    if (outFile != 0)
-      {
+    }
+    if (outFile != 0) {
       fclose(outFile);
-      }
-    return false;
     }
+    return false;
+  }
 
   // convert them line by line
   bool success = false;
   char buf[1024];
-  while (fgets(buf, 1024, inFile) != 0)
-    {
-    if (type == MotorolaSrec)
-      {
+  while (fgets(buf, 1024, inFile) != 0) {
+    if (type == MotorolaSrec) {
       success = ConvertMotorolaSrecLine(buf, outFile);
-      }
-    else if (type == IntelHex)
-      {
+    } else if (type == IntelHex) {
       success = ConvertIntelHexLine(buf, outFile);
-      }
-    if (success == false)
-      {
+    }
+    if (success == false) {
       break;
-      }
     }
+  }
 
   // close them again
   fclose(inFile);
   fclose(outFile);
   return success;
 }
-
diff --git a/Source/cmHexFileConverter.h b/Source/cmHexFileConverter.h
index e11d74a..56fa9b1 100644
--- a/Source/cmHexFileConverter.h
+++ b/Source/cmHexFileConverter.h
@@ -12,6 +12,8 @@
 #ifndef cmHexFileConverter_h
 #define cmHexFileConverter_h
 
+#include "cmStandardIncludes.h"
+
 /** \class cmHexFileConverter
  * \brief Can detects Intel Hex and Motorola S-record files and convert them
  *        to binary files.
@@ -20,7 +22,12 @@
 class cmHexFileConverter
 {
 public:
-  enum FileType {Binary, IntelHex, MotorolaSrec};
+  enum FileType
+  {
+    Binary,
+    IntelHex,
+    MotorolaSrec
+  };
   static FileType DetermineFileType(const char* inFileName);
   static bool TryConvert(const char* inFileName, const char* outFileName);
 };
diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h
index adc7763..e8a6e38 100644
--- a/Source/cmIDEFlagTable.h
+++ b/Source/cmIDEFlagTable.h
@@ -15,26 +15,26 @@
 // This is a table mapping XML tag IDE names to command line options
 struct cmIDEFlagTable
 {
-  const char* IDEName;  // name used in the IDE xml file
+  const char* IDEName;     // name used in the IDE xml file
   const char* commandFlag; // command line flag
   const char* comment;     // comment
-  const char* value; // string value
-  unsigned int special; // flags for special handling requests
+  const char* value;       // string value
+  unsigned int special;    // flags for special handling requests
   enum
   {
-    UserValue    = (1<<0), // flag contains a user-specified value
-    UserIgnored  = (1<<1), // ignore any user value
-    UserRequired = (1<<2), // match only when user value is non-empty
-    Continue     = (1<<3), // continue looking for matching entries
-    SemicolonAppendable = (1<<4), // a flag that if specified multiple times
-                                  // should have its value appended to the
-                                  // old value with semicolons (e.g.
-                                  // /NODEFAULTLIB: =>
-                                  // IgnoreDefaultLibraryNames)
-    UserFollowing = (1<<5), // expect value in following argument
-    CaseInsensitive = (1<<6), // flag may be any case
+    UserValue = (1 << 0),           // flag contains a user-specified value
+    UserIgnored = (1 << 1),         // ignore any user value
+    UserRequired = (1 << 2),        // match only when user value is non-empty
+    Continue = (1 << 3),            // continue looking for matching entries
+    SemicolonAppendable = (1 << 4), // a flag that if specified multiple times
+                                    // should have its value appended to the
+                                    // old value with semicolons (e.g.
+                                    // /NODEFAULTLIB: =>
+                                    // IgnoreDefaultLibraryNames)
+    UserFollowing = (1 << 5),       // expect value in following argument
+    CaseInsensitive = (1 << 6),     // flag may be any case
 
-    UserValueIgnored  = UserValue | UserIgnored,
+    UserValueIgnored = UserValue | UserIgnored,
     UserValueRequired = UserValue | UserRequired
   };
 };
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 509602f..9f4b537 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -15,200 +15,162 @@
 
 #include <cmsys/String.h>
 
-//----------------------------------------------------------------------------
 cmIDEOptions::cmIDEOptions()
 {
   this->DoingDefine = false;
   this->AllowDefine = true;
   this->AllowSlash = false;
   this->DoingFollowing = 0;
-  for(int i=0; i < FlagTableCount; ++i)
-    {
+  for (int i = 0; i < FlagTableCount; ++i) {
     this->FlagTable[i] = 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmIDEOptions::~cmIDEOptions()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::HandleFlag(const char* flag)
 {
   // If the last option was -D then this option is the definition.
-  if(this->DoingDefine)
-    {
+  if (this->DoingDefine) {
     this->DoingDefine = false;
     this->Defines.push_back(flag);
     return;
-    }
+  }
 
   // If the last option expected a following value, this is it.
-  if(this->DoingFollowing)
-    {
+  if (this->DoingFollowing) {
     this->FlagMapUpdate(this->DoingFollowing, flag);
     this->DoingFollowing = 0;
     return;
-    }
+  }
 
   // Look for known arguments.
-  if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
-    {
+  if (flag[0] == '-' || (this->AllowSlash && flag[0] == '/')) {
     // Look for preprocessor definitions.
-    if(this->AllowDefine && flag[1] == 'D')
-      {
-      if(flag[2] == '\0')
-        {
+    if (this->AllowDefine && flag[1] == 'D') {
+      if (flag[2] == '\0') {
         // The next argument will have the definition.
         this->DoingDefine = true;
-        }
-      else
-        {
+      } else {
         // Store this definition.
-        this->Defines.push_back(flag+2);
-        }
-      return;
+        this->Defines.push_back(flag + 2);
       }
+      return;
+    }
 
     // Look through the available flag tables.
     bool flag_handled = false;
-    for(int i=0; i < FlagTableCount && this->FlagTable[i]; ++i)
-      {
-      if(this->CheckFlagTable(this->FlagTable[i], flag, flag_handled))
-        {
+    for (int i = 0; i < FlagTableCount && this->FlagTable[i]; ++i) {
+      if (this->CheckFlagTable(this->FlagTable[i], flag, flag_handled)) {
         return;
-        }
       }
+    }
 
     // If any map entry handled the flag we are done.
-    if(flag_handled)
-      {
+    if (flag_handled) {
       return;
-      }
     }
+  }
 
   // This option is not known.  Store it in the output flags.
   this->StoreUnknownFlag(flag);
 }
 
-//----------------------------------------------------------------------------
 bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
                                   const char* flag, bool& flag_handled)
 {
   // Look for an entry in the flag table matching this flag.
-  for(cmIDEFlagTable const* entry = table; entry->IDEName; ++entry)
-    {
+  for (cmIDEFlagTable const* entry = table; entry->IDEName; ++entry) {
     bool entry_found = false;
-    if(entry->special & cmIDEFlagTable::UserValue)
-      {
+    if (entry->special & cmIDEFlagTable::UserValue) {
       // This flag table entry accepts a user-specified value.  If
       // the entry specifies UserRequired we must match only if a
       // non-empty value is given.
       int n = static_cast<int>(strlen(entry->commandFlag));
-      if((strncmp(flag+1, entry->commandFlag, n) == 0 ||
-          (entry->special & cmIDEFlagTable::CaseInsensitive &&
-           cmsysString_strncasecmp(flag+1, entry->commandFlag, n))) &&
-         (!(entry->special & cmIDEFlagTable::UserRequired) ||
-          static_cast<int>(strlen(flag+1)) > n))
-        {
-        this->FlagMapUpdate(entry, flag+n+1);
+      if ((strncmp(flag + 1, entry->commandFlag, n) == 0 ||
+           (entry->special & cmIDEFlagTable::CaseInsensitive &&
+            cmsysString_strncasecmp(flag + 1, entry->commandFlag, n))) &&
+          (!(entry->special & cmIDEFlagTable::UserRequired) ||
+           static_cast<int>(strlen(flag + 1)) > n)) {
+        this->FlagMapUpdate(entry, flag + n + 1);
         entry_found = true;
-        }
       }
-    else if(strcmp(flag+1, entry->commandFlag) == 0 ||
-            (entry->special & cmIDEFlagTable::CaseInsensitive &&
-             cmsysString_strcasecmp(flag+1, entry->commandFlag) == 0))
-      {
-      if(entry->special & cmIDEFlagTable::UserFollowing)
-        {
+    } else if (strcmp(flag + 1, entry->commandFlag) == 0 ||
+               (entry->special & cmIDEFlagTable::CaseInsensitive &&
+                cmsysString_strcasecmp(flag + 1, entry->commandFlag) == 0)) {
+      if (entry->special & cmIDEFlagTable::UserFollowing) {
         // This flag expects a value in the following argument.
         this->DoingFollowing = entry;
-        }
-      else
-        {
+      } else {
         // This flag table entry provides a fixed value.
         this->FlagMap[entry->IDEName] = entry->value;
-        }
-      entry_found = true;
       }
+      entry_found = true;
+    }
 
     // If the flag has been handled by an entry not requesting a
     // search continuation we are done.
-    if(entry_found && !(entry->special & cmIDEFlagTable::Continue))
-      {
+    if (entry_found && !(entry->special & cmIDEFlagTable::Continue)) {
       return true;
-      }
+    }
 
     // If the entry was found the flag has been handled.
     flag_handled = flag_handled || entry_found;
-    }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
                                  const char* new_value)
 {
-  if(entry->special & cmIDEFlagTable::UserIgnored)
-    {
+  if (entry->special & cmIDEFlagTable::UserIgnored) {
     // Ignore the user-specified value.
     this->FlagMap[entry->IDEName] = entry->value;
-    }
-  else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
-    {
+  } else if (entry->special & cmIDEFlagTable::SemicolonAppendable) {
     this->FlagMap[entry->IDEName].push_back(new_value);
-    }
-  else
-    {
+  } else {
     // Use the user-specified value.
     this->FlagMap[entry->IDEName] = new_value;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::AddDefine(const std::string& def)
 {
   this->Defines.push_back(def);
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::AddDefines(const char* defines)
 {
-  if(defines)
-    {
+  if (defines) {
     // Expand the list of definitions.
     cmSystemTools::ExpandListArgument(defines, this->Defines);
-    }
+  }
 }
-//----------------------------------------------------------------------------
-void cmIDEOptions::AddDefines(const std::vector<std::string> &defines)
+void cmIDEOptions::AddDefines(const std::vector<std::string>& defines)
 {
   this->Defines.insert(this->Defines.end(), defines.begin(), defines.end());
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::AddFlag(const char* flag, const char* value)
 {
   this->FlagMap[flag] = value;
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::AddFlag(const char* flag,
                            std::vector<std::string> const& value)
 {
   this->FlagMap[flag] = value;
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::AppendFlag(std::string const& flag,
                               std::string const& value)
 {
   this->FlagMap[flag].push_back(value);
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::AppendFlag(std::string const& flag,
                               std::vector<std::string> const& value)
 {
@@ -216,26 +178,22 @@ void cmIDEOptions::AppendFlag(std::string const& flag,
   std::copy(value.begin(), value.end(), std::back_inserter(fv));
 }
 
-//----------------------------------------------------------------------------
 void cmIDEOptions::RemoveFlag(const char* flag)
 {
   this->FlagMap.erase(flag);
 }
 
-//----------------------------------------------------------------------------
 bool cmIDEOptions::HasFlag(std::string const& flag) const
 {
   return this->FlagMap.find(flag) != this->FlagMap.end();
 }
 
-//----------------------------------------------------------------------------
 const char* cmIDEOptions::GetFlag(const char* flag)
 {
   // This method works only for single-valued flags!
   std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(flag);
-  if(i != this->FlagMap.end() && i->second.size() == 1)
-    {
+  if (i != this->FlagMap.end() && i->second.size() == 1) {
     return i->second[0].c_str();
-    }
+  }
   return 0;
 }
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index 7386016..fac7d4e 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -13,6 +13,7 @@
 #define cmIDEOptions_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmIDEFlagTable.h"
 
 /** \class cmIDEOptions
@@ -27,7 +28,7 @@ public:
   // Store definitions and flags.
   void AddDefine(const std::string& define);
   void AddDefines(const char* defines);
-  void AddDefines(const std::vector<std::string> &defines);
+  void AddDefines(const std::vector<std::string>& defines);
   void AddFlag(const char* flag, const char* value);
   void AddFlag(const char* flag, std::vector<std::string> const& value);
   void AppendFlag(std::string const& flag, std::string const& value);
@@ -45,23 +46,24 @@ protected:
   // Then parse the command line flags specified in CMAKE_CXX_FLAGS
   // and CMAKE_C_FLAGS
   // and overwrite or add new values to this map
-  class FlagValue: public std::vector<std::string>
+  class FlagValue : public std::vector<std::string>
   {
     typedef std::vector<std::string> derived;
+
   public:
     FlagValue& operator=(std::string const& r)
-      {
+    {
       this->resize(1);
       this->operator[](0) = r;
       return *this;
-      }
+    }
     FlagValue& operator=(std::vector<std::string> const& r)
-      {
+    {
       this->derived::operator=(r);
       return *this;
-      }
+    }
   };
-  std::map<std::string, FlagValue > FlagMap;
+  std::map<std::string, FlagValue> FlagMap;
 
   // Preprocessor definitions.
   std::vector<std::string> Defines;
@@ -73,7 +75,10 @@ protected:
   bool AllowDefine;
   bool AllowSlash;
   cmIDEFlagTable const* DoingFollowing;
-  enum { FlagTableCount = 16 };
+  enum
+  {
+    FlagTableCount = 16
+  };
   cmIDEFlagTable const* FlagTable[FlagTableCount];
   void HandleFlag(const char* flag);
   bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 5964ef1..45395d1 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -10,94 +10,81 @@
   See the License for more information.
 ============================================================================*/
 #include "cmIfCommand.h"
-#include "cmStringCommand.h"
+
 #include "cmOutputConverter.h"
+#include "cmStringCommand.h"
 
 #include "cmConditionEvaluator.h"
 
-#include <stdlib.h> // required for atof
-#include <list>
 #include <cmsys/RegularExpression.hxx>
-
+#include <list>
+#include <stdlib.h> // required for atof
 
 static std::string cmIfCommandError(
   std::vector<cmExpandedCommandArgument> const& args)
 {
   std::string err = "given arguments:\n ";
-  for(std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
     err += " ";
     err += cmOutputConverter::EscapeForCMake(i->GetValue());
-    }
+  }
   err += "\n";
   return err;
 }
 
 //=========================================================================
-bool cmIfFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff,
-                  cmMakefile &mf,
-                  cmExecutionStatus &inStatus)
+bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
+                                            cmMakefile& mf,
+                                            cmExecutionStatus& inStatus)
 {
   // we start by recording all the functions
-  if (!cmSystemTools::Strucmp(lff.Name.c_str(),"if"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "if")) {
     this->ScopeDepth++;
-    }
-  else if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endif"))
-    {
+  } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endif")) {
     this->ScopeDepth--;
     // if this is the endif for this if statement, then start executing
-    if (!this->ScopeDepth)
-      {
+    if (!this->ScopeDepth) {
       // Remove the function blocker for this scope or bail.
-      cmsys::auto_ptr<cmFunctionBlocker>
-        fb(mf.RemoveFunctionBlocker(this, lff));
-      if(!fb.get()) { return false; }
+      cmsys::auto_ptr<cmFunctionBlocker> fb(
+        mf.RemoveFunctionBlocker(this, lff));
+      if (!fb.get()) {
+        return false;
+      }
 
       // execute the functions for the true parts of the if statement
       cmExecutionStatus status;
       int scopeDepth = 0;
-      for(unsigned int c = 0; c < this->Functions.size(); ++c)
-        {
+      for (unsigned int c = 0; c < this->Functions.size(); ++c) {
         // keep track of scope depth
-        if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),"if"))
-          {
+        if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "if")) {
           scopeDepth++;
-          }
-        if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),"endif"))
-          {
+        }
+        if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
+                                    "endif")) {
           scopeDepth--;
-          }
+        }
         // watch for our state change
         if (scopeDepth == 0 &&
-            !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),"else"))
-          {
+            !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "else")) {
           this->IsBlocking = this->HasRun;
           this->HasRun = true;
 
           // if trace is enabled, print a (trivially) evaluated "else"
           // statement
-          if(!this->IsBlocking && mf.GetCMakeInstance()->GetTrace())
-            {
+          if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) {
             mf.PrintCommandTrace(this->Functions[c]);
-            }
           }
-        else if (scopeDepth == 0 && !cmSystemTools::Strucmp
-                 (this->Functions[c].Name.c_str(),"elseif"))
-          {
-          if (this->HasRun)
-            {
+        } else if (scopeDepth == 0 &&
+                   !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
+                                           "elseif")) {
+          if (this->HasRun) {
             this->IsBlocking = true;
-            }
-          else
-            {
+          } else {
             // if trace is enabled, print the evaluated "elseif" statement
-            if(mf.GetCMakeInstance()->GetTrace())
-              {
+            if (mf.GetCMakeInstance()->GetTrace()) {
               mf.PrintCommandTrace(this->Functions[c]);
-              }
+            }
 
             std::string errorString;
 
@@ -108,63 +95,54 @@ IsFunctionBlocked(const cmListFileFunction& lff,
             cmake::MessageType messType;
 
             cmListFileContext conditionContext =
-                cmConditionEvaluator::GetConditionContext(
-                  &mf, this->Functions[c],
-                  this->GetStartingContext().FilePath);
+              cmListFileContext::FromCommandContext(
+                this->Functions[c], this->GetStartingContext().FilePath);
 
             cmConditionEvaluator conditionEvaluator(
-                  mf, conditionContext,
-                  mf.GetBacktrace(this->Functions[c]));
+              mf, conditionContext, mf.GetBacktrace(this->Functions[c]));
 
-            bool isTrue = conditionEvaluator.IsTrue(
-              expandedArguments, errorString, messType);
+            bool isTrue = conditionEvaluator.IsTrue(expandedArguments,
+                                                    errorString, messType);
 
-            if (!errorString.empty())
-              {
+            if (!errorString.empty()) {
               std::string err = cmIfCommandError(expandedArguments);
               err += errorString;
               cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
               mf.GetCMakeInstance()->IssueMessage(messType, err, bt);
-              if (messType == cmake::FATAL_ERROR)
-                {
+              if (messType == cmake::FATAL_ERROR) {
                 cmSystemTools::SetFatalErrorOccured();
                 return true;
-                }
               }
+            }
 
-            if (isTrue)
-              {
+            if (isTrue) {
               this->IsBlocking = false;
               this->HasRun = true;
-              }
             }
           }
+        }
 
         // should we execute?
-        else if (!this->IsBlocking)
-          {
+        else if (!this->IsBlocking) {
           status.Clear();
-          mf.ExecuteCommand(this->Functions[c],status);
-          if (status.GetReturnInvoked())
-            {
+          mf.ExecuteCommand(this->Functions[c], status);
+          if (status.GetReturnInvoked()) {
             inStatus.SetReturnInvoked(true);
             return true;
-            }
-          if (status.GetBreakInvoked())
-            {
+          }
+          if (status.GetBreakInvoked()) {
             inStatus.SetBreakInvoked(true);
             return true;
-            }
-          if (status.GetContinueInvoked())
-            {
+          }
+          if (status.GetContinueInvoked()) {
             inStatus.SetContinueInvoked(true);
             return true;
-            }
           }
         }
-      return true;
       }
+      return true;
     }
+  }
 
   // record the command
   this->Functions.push_back(lff);
@@ -177,24 +155,20 @@ IsFunctionBlocked(const cmListFileFunction& lff,
 bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
                                        cmMakefile&)
 {
-  if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endif"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endif")) {
     // if the endif has arguments, then make sure
     // they match the arguments of the matching if
-    if (lff.Arguments.empty() ||
-        lff.Arguments == this->Args)
-      {
+    if (lff.Arguments.empty() || lff.Arguments == this->Args) {
       return true;
-      }
     }
+  }
 
   return false;
 }
 
 //=========================================================================
-bool cmIfCommand
-::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                    cmExecutionStatus &)
+bool cmIfCommand::InvokeInitialPass(
+  const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
 {
   std::string errorString;
 
@@ -203,44 +177,32 @@ bool cmIfCommand
 
   cmake::MessageType status;
 
-  cmListFileContext execContext = this->Makefile->GetExecutionContext();
-
-  cmCommandContext commandContext;
-  commandContext.Line = execContext.Line;
-  commandContext.Name = execContext.Name;
-
   cmConditionEvaluator conditionEvaluator(
-        *(this->Makefile), cmConditionEvaluator::GetConditionContext(
-          this->Makefile, commandContext, execContext.FilePath),
-        this->Makefile->GetBacktrace());
+    *(this->Makefile), this->Makefile->GetExecutionContext(),
+    this->Makefile->GetBacktrace());
 
-  bool isTrue = conditionEvaluator.IsTrue(
-    expandedArguments, errorString, status);
+  bool isTrue =
+    conditionEvaluator.IsTrue(expandedArguments, errorString, status);
 
-  if (!errorString.empty())
-    {
+  if (!errorString.empty()) {
     std::string err = cmIfCommandError(expandedArguments);
     err += errorString;
-    if (status == cmake::FATAL_ERROR)
-      {
+    if (status == cmake::FATAL_ERROR) {
       this->SetError(err);
       cmSystemTools::SetFatalErrorOccured();
       return false;
-      }
-    else
-      {
+    } else {
       this->Makefile->IssueMessage(status, err);
-      }
     }
+  }
 
-  cmIfFunctionBlocker *f = new cmIfFunctionBlocker();
+  cmIfFunctionBlocker* f = new cmIfFunctionBlocker();
   // if is isn't true block the commands
   f->ScopeDepth = 1;
   f->IsBlocking = !isTrue;
-  if (isTrue)
-    {
+  if (isTrue) {
     f->HasRun = true;
-    }
+  }
   f->Args = args;
   this->Makefile->AddFunctionBlocker(f);
 
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index 689efce..54200df 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -13,19 +13,21 @@
 #define cmIfCommand_h
 
 #include "cmCommand.h"
+
 #include "cmFunctionBlocker.h"
 
 class cmIfFunctionBlocker : public cmFunctionBlocker
 {
 public:
-  cmIfFunctionBlocker() {
-    this->HasRun = false; this->ScopeDepth = 0; }
+  cmIfFunctionBlocker()
+  {
+    this->HasRun = false;
+    this->ScopeDepth = 0;
+  }
   virtual ~cmIfFunctionBlocker() {}
-  virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
-                                 cmMakefile &mf,
-                                 cmExecutionStatus &);
-  virtual bool ShouldRemove(const cmListFileFunction& lff,
-                            cmMakefile &mf);
+  virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
+                                 cmExecutionStatus&);
+  virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf);
 
   std::vector<cmListFileArgument> Args;
   std::vector<cmListFileFunction> Functions;
@@ -41,29 +43,28 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmIfCommand;
-    }
+  virtual cmCommand* Clone() { return new cmIfCommand; }
 
   /**
    * This overrides the default InvokeInitialPass implementation.
    * It records the arguments before expansion.
    */
   virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false;}
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "if";}
+  virtual std::string GetName() const { return "if"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -77,5 +78,4 @@ public:
   cmTypeMacro(cmIfCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index 8890e2b..cb9b74d 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -11,97 +11,77 @@
 ============================================================================*/
 #include "cmIncludeCommand.h"
 
-
 // cmIncludeCommand
-bool cmIncludeCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
+                                   cmExecutionStatus&)
 {
-  if (args.size()< 1 || args.size() > 4)
-    {
-      this->SetError("called with wrong number of arguments.  "
-                     "include() only takes one file.");
-      return false;
-    }
+  if (args.size() < 1 || args.size() > 4) {
+    this->SetError("called with wrong number of arguments.  "
+                   "include() only takes one file.");
+    return false;
+  }
   bool optional = false;
   bool noPolicyScope = false;
   std::string fname = args[0];
   std::string resultVarName;
 
-  for (unsigned int i=1; i<args.size(); i++)
-    {
-    if (args[i] == "OPTIONAL")
-      {
-      if (optional)
-        {
+  for (unsigned int i = 1; i < args.size(); i++) {
+    if (args[i] == "OPTIONAL") {
+      if (optional) {
         this->SetError("called with invalid arguments: OPTIONAL used twice");
         return false;
-        }
-      optional = true;
       }
-    else if(args[i] == "RESULT_VARIABLE")
-      {
-      if (!resultVarName.empty())
-        {
+      optional = true;
+    } else if (args[i] == "RESULT_VARIABLE") {
+      if (!resultVarName.empty()) {
         this->SetError("called with invalid arguments: "
-            "only one result variable allowed");
+                       "only one result variable allowed");
         return false;
-        }
-      if(++i < args.size())
-        {
+      }
+      if (++i < args.size()) {
         resultVarName = args[i];
-        }
-      else
-        {
+      } else {
         this->SetError("called with no value for RESULT_VARIABLE.");
         return false;
-        }
       }
-    else if(args[i] == "NO_POLICY_SCOPE")
-      {
+    } else if (args[i] == "NO_POLICY_SCOPE") {
       noPolicyScope = true;
-      }
-      else if(i > 1)  // compat.: in previous cmake versions the second
+    } else if (i > 1) // compat.: in previous cmake versions the second
                       // parameter was ignored if it wasn't "OPTIONAL"
-        {
-        std::string errorText = "called with invalid argument: ";
-        errorText += args[i];
-        this->SetError(errorText);
-        return false;
-        }
+    {
+      std::string errorText = "called with invalid argument: ";
+      errorText += args[i];
+      this->SetError(errorText);
+      return false;
     }
+  }
 
-  if(fname.empty())
-    {
+  if (fname.empty()) {
     this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
                                  "include() given empty file name (ignored).");
     return true;
-    }
+  }
 
-  if(!cmSystemTools::FileIsFullPath(fname.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(fname.c_str())) {
     // Not a path. Maybe module.
     std::string module = fname;
     module += ".cmake";
     std::string mfile = this->Makefile->GetModulesFile(module.c_str());
-    if (!mfile.empty())
-      {
+    if (!mfile.empty()) {
       fname = mfile.c_str();
-      }
     }
+  }
 
-  std::string fname_abs =
-      cmSystemTools::CollapseFullPath(fname,
-                                 this->Makefile->GetCurrentSourceDirectory());
+  std::string fname_abs = cmSystemTools::CollapseFullPath(
+    fname, this->Makefile->GetCurrentSourceDirectory());
 
-  cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator();
-  if (gg->IsExportedTargetsFile(fname_abs))
-    {
-    const char *modal = 0;
+  cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
+  if (gg->IsExportedTargetsFile(fname_abs)) {
+    const char* modal = 0;
     std::ostringstream e;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
 
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0024)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0024) << "\n";
         modal = "should";
@@ -112,55 +92,47 @@ bool cmIncludeCommand
       case cmPolicies::NEW:
         modal = "may";
         messageType = cmake::FATAL_ERROR;
-      }
-    if (modal)
-      {
+    }
+    if (modal) {
       e << "The file\n  " << fname_abs << "\nwas generated by the export() "
-        "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";
+                                          "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());
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
+    }
     gg->CreateGenerationObjects();
     gg->GenerateImportFile(fname_abs);
-    }
+  }
 
-  std::string listFile =
-    cmSystemTools::CollapseFullPath(fname.c_str(),
-                                  this->Makefile->GetCurrentSourceDirectory());
-  if(optional && !cmSystemTools::FileExists(listFile.c_str()))
-    {
-    if (!resultVarName.empty())
-      {
+  std::string listFile = cmSystemTools::CollapseFullPath(
+    fname.c_str(), this->Makefile->GetCurrentSourceDirectory());
+  if (optional && !cmSystemTools::FileExists(listFile.c_str())) {
+    if (!resultVarName.empty()) {
       this->Makefile->AddDefinition(resultVarName, "NOTFOUND");
-      }
-    return true;
     }
+    return true;
+  }
 
   bool readit =
     this->Makefile->ReadDependentFile(listFile.c_str(), noPolicyScope);
 
   // add the location of the included file if a result variable was given
-  if (!resultVarName.empty())
-    {
-      this->Makefile->AddDefinition(resultVarName,
-                                    readit?fname_abs.c_str():"NOTFOUND");
-    }
-
-  if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured())
-    {
-    std::string m =
-      "could not find load file:\n"
-      "  ";
+  if (!resultVarName.empty()) {
+    this->Makefile->AddDefinition(resultVarName,
+                                  readit ? fname_abs.c_str() : "NOTFOUND");
+  }
+
+  if (!optional && !readit && !cmSystemTools::GetFatalErrorOccured()) {
+    std::string m = "could not find load file:\n"
+                    "  ";
     m += fname;
     this->SetError(m);
     return false;
-    }
+  }
   return true;
 }
-
-
diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h
index 0dcd7de..e319dbd 100644
--- a/Source/cmIncludeCommand.h
+++ b/Source/cmIncludeCommand.h
@@ -26,17 +26,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmIncludeCommand;
-    }
+  virtual cmCommand* Clone() { return new cmIncludeCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -46,11 +43,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "include";}
+  virtual std::string GetName() const { return "include"; }
 
   cmTypeMacro(cmIncludeCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index 5c28cfd..cafdba7 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -12,68 +12,55 @@
 #include "cmIncludeDirectoryCommand.h"
 
 // cmIncludeDirectoryCommand
-bool cmIncludeDirectoryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmIncludeDirectoryCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
 
   std::vector<std::string>::const_iterator i = args.begin();
 
   bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
   bool system = false;
 
-  if ((*i) == "BEFORE")
-    {
+  if ((*i) == "BEFORE") {
     before = true;
     ++i;
-    }
-  else if ((*i) == "AFTER")
-    {
+  } else if ((*i) == "AFTER") {
     before = false;
     ++i;
-    }
+  }
 
   std::vector<std::string> beforeIncludes;
   std::vector<std::string> afterIncludes;
   std::set<std::string> systemIncludes;
 
-  for(; i != args.end(); ++i)
-    {
-    if(*i == "SYSTEM")
-      {
+  for (; i != args.end(); ++i) {
+    if (*i == "SYSTEM") {
       system = true;
       continue;
-      }
-    if(i->empty())
-      {
+    }
+    if (i->empty()) {
       this->SetError("given empty-string as include directory.");
       return false;
-      }
+    }
 
     std::vector<std::string> includes;
 
     this->GetIncludes(*i, includes);
 
-    if (before)
-      {
-      beforeIncludes.insert(beforeIncludes.end(),
-                            includes.begin(),
+    if (before) {
+      beforeIncludes.insert(beforeIncludes.end(), includes.begin(),
                             includes.end());
-      }
-    else
-      {
-      afterIncludes.insert(afterIncludes.end(),
-                           includes.begin(),
+    } else {
+      afterIncludes.insert(afterIncludes.end(), includes.begin(),
                            includes.end());
-      }
-    if (system)
-      {
+    }
+    if (system) {
       systemIncludes.insert(includes.begin(), includes.end());
-      }
     }
+  }
   std::reverse(beforeIncludes.begin(), beforeIncludes.end());
 
   this->Makefile->AddIncludeDirectories(afterIncludes);
@@ -83,7 +70,7 @@ bool cmIncludeDirectoryCommand
   return true;
 }
 
-static bool StartsWithGeneratorExpression(const std::string &input)
+static bool StartsWithGeneratorExpression(const std::string& input)
 {
   return input[0] == '$' && input[1] == '<';
 }
@@ -100,60 +87,50 @@ static bool StartsWithGeneratorExpression(const std::string &input)
 // output from a program and passing it into a command the cleanup doesn't
 // always happen
 //
-void cmIncludeDirectoryCommand::GetIncludes(const std::string &arg,
-                                            std::vector<std::string> &incs)
+void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg,
+                                            std::vector<std::string>& incs)
 {
   // break apart any line feed arguments
   std::string::size_type pos = 0;
   std::string::size_type lastPos = 0;
-  while((pos = arg.find('\n', lastPos)) != std::string::npos)
-    {
-    if (pos)
-      {
-      std::string inc = arg.substr(lastPos,pos);
+  while ((pos = arg.find('\n', lastPos)) != std::string::npos) {
+    if (pos) {
+      std::string inc = arg.substr(lastPos, pos);
       this->NormalizeInclude(inc);
-      if (!inc.empty())
-        {
+      if (!inc.empty()) {
         incs.push_back(inc);
-        }
       }
-    lastPos = pos + 1;
     }
+    lastPos = pos + 1;
+  }
   std::string inc = arg.substr(lastPos);
   this->NormalizeInclude(inc);
-  if (!inc.empty())
-    {
+  if (!inc.empty()) {
     incs.push_back(inc);
-    }
+  }
 }
 
-void cmIncludeDirectoryCommand::NormalizeInclude(std::string &inc)
+void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc)
 {
   std::string::size_type b = inc.find_first_not_of(" \r");
   std::string::size_type e = inc.find_last_not_of(" \r");
-  if ((b!=inc.npos) && (e!=inc.npos))
-    {
-    inc.assign(inc, b, 1+e-b);   // copy the remaining substring
-    }
-  else
-    {
+  if ((b != inc.npos) && (e != inc.npos)) {
+    inc.assign(inc, b, 1 + e - b); // copy the remaining substring
+  } else {
     inc = "";
     return;
-    }
+  }
 
-  if (!cmSystemTools::IsOff(inc.c_str()))
-    {
+  if (!cmSystemTools::IsOff(inc.c_str())) {
     cmSystemTools::ConvertToUnixSlashes(inc);
 
-    if(!cmSystemTools::FileIsFullPath(inc.c_str()))
-      {
-      if(!StartsWithGeneratorExpression(inc))
-        {
+    if (!cmSystemTools::FileIsFullPath(inc.c_str())) {
+      if (!StartsWithGeneratorExpression(inc)) {
         std::string tmp = this->Makefile->GetCurrentSourceDirectory();
         tmp += "/";
         tmp += inc;
         inc = tmp;
-        }
       }
     }
+  }
 }
diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h
index 6cc2c83..952294b 100644
--- a/Source/cmIncludeDirectoryCommand.h
+++ b/Source/cmIncludeDirectoryCommand.h
@@ -26,31 +26,26 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmIncludeDirectoryCommand;
-    }
+  virtual cmCommand* Clone() { return new cmIncludeDirectoryCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "include_directories";}
+  virtual std::string GetName() const { return "include_directories"; }
 
   cmTypeMacro(cmIncludeDirectoryCommand, cmCommand);
 
 protected:
   // used internally
-  void GetIncludes(const std::string &arg, std::vector<std::string> &incs);
-  void NormalizeInclude(std::string &inc);
+  void GetIncludes(const std::string& arg, std::vector<std::string>& incs);
+  void NormalizeInclude(std::string& inc);
 };
 
-
-
 #endif
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index c64d128..9720d63 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -12,20 +12,24 @@
 #include "cmIncludeExternalMSProjectCommand.h"
 
 // cmIncludeExternalMSProjectCommand
-bool cmIncludeExternalMSProjectCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmIncludeExternalMSProjectCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2)
-  {
-  this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
-                 "number of arguments");
-  return false;
+  if (args.size() < 2) {
+    this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
+                   "number of arguments");
+    return false;
   }
 // only compile this for win32 to avoid coverage errors
 #ifdef _WIN32
-  if(this->Makefile->GetDefinition("WIN32"))
+  if (this->Makefile->GetDefinition("WIN32")) {
+    enum Doing
     {
-    enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform };
+      DoingNone,
+      DoingType,
+      DoingGuid,
+      DoingPlatform
+    };
 
     Doing doing = DoingNone;
 
@@ -34,32 +38,31 @@ bool cmIncludeExternalMSProjectCommand
     std::string platformMapping;
 
     std::vector<std::string> depends;
-    for (unsigned int i=2; i<args.size(); ++i)
-      {
-      if (args[i] == "TYPE")
-        {
+    for (unsigned int i = 2; i < args.size(); ++i) {
+      if (args[i] == "TYPE") {
         doing = DoingType;
-        }
-      else if (args[i] == "GUID")
-        {
+      } else if (args[i] == "GUID") {
         doing = DoingGuid;
-        }
-      else if (args[i] == "PLATFORM")
-        {
+      } else if (args[i] == "PLATFORM") {
         doing = DoingPlatform;
+      } else {
+        switch (doing) {
+          case DoingNone:
+            depends.push_back(args[i]);
+            break;
+          case DoingType:
+            customType = args[i];
+            break;
+          case DoingGuid:
+            customGuid = args[i];
+            break;
+          case DoingPlatform:
+            platformMapping = args[i];
+            break;
         }
-      else
-        {
-        switch (doing)
-          {
-          case DoingNone: depends.push_back(args[i]);    break;
-          case DoingType: customType = args[i];          break;
-          case DoingGuid: customGuid = args[i];          break;
-          case DoingPlatform: platformMapping = args[i]; break;
-          }
         doing = DoingNone;
-        }
       }
+    }
 
     // Hack together a utility target storing enough information
     // to reproduce the target inclusion.
@@ -68,34 +71,31 @@ bool cmIncludeExternalMSProjectCommand
     std::string path = args[1];
     cmSystemTools::ConvertToUnixSlashes(path);
 
-    if (!customGuid.empty())
-      {
+    if (!customGuid.empty()) {
       std::string guidVariable = utility_name + "_GUID_CMAKE";
       this->Makefile->GetCMakeInstance()->AddCacheEntry(
-        guidVariable.c_str(), customGuid.c_str(),
-        "Stored GUID", cmState::INTERNAL);
-      }
+        guidVariable.c_str(), customGuid.c_str(), "Stored GUID",
+        cmState::INTERNAL);
+    }
 
     // Create a target instance for this utility.
-    cmTarget* target=this->Makefile->AddNewTarget(cmState::UTILITY,
-                                                  utility_name.c_str());
+    cmTarget* target =
+      this->Makefile->AddNewTarget(cmState::UTILITY, utility_name.c_str());
 
     target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
     target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
     target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
 
     if (!customType.empty())
-      target->SetProperty("VS_PROJECT_TYPE",customType.c_str());
+      target->SetProperty("VS_PROJECT_TYPE", customType.c_str());
     if (!platformMapping.empty())
-      target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str());
+      target->SetProperty("VS_PLATFORM_MAPPING", platformMapping.c_str());
 
     for (std::vector<std::string>::const_iterator it = depends.begin();
-         it != depends.end();
-         ++it)
-      {
+         it != depends.end(); ++it) {
       target->AddUtility(it->c_str());
-      }
     }
+  }
 #endif
   return true;
 }
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 081f77a..999eb9e 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -27,26 +27,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmIncludeExternalMSProjectCommand;
-    }
+  virtual cmCommand* Clone() { return new cmIncludeExternalMSProjectCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "include_external_msproject";}
+  virtual std::string GetName() const { return "include_external_msproject"; }
 
   cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx
index d6dfdd2..2473dff 100644
--- a/Source/cmIncludeRegularExpressionCommand.cxx
+++ b/Source/cmIncludeRegularExpressionCommand.cxx
@@ -12,21 +12,18 @@
 #include "cmIncludeRegularExpressionCommand.h"
 
 // cmIncludeRegularExpressionCommand
-bool cmIncludeRegularExpressionCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmIncludeRegularExpressionCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if((args.size() < 1) || (args.size() > 2))
-    {
+  if ((args.size() < 1) || (args.size() > 2)) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   this->Makefile->SetIncludeRegularExpression(args[0].c_str());
 
-  if(args.size() > 1)
-    {
+  if (args.size() > 1) {
     this->Makefile->SetComplainRegularExpression(args[1]);
-    }
+  }
 
   return true;
 }
-
diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h
index c58f018..1071a7a 100644
--- a/Source/cmIncludeRegularExpressionCommand.h
+++ b/Source/cmIncludeRegularExpressionCommand.h
@@ -26,26 +26,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmIncludeRegularExpressionCommand;
-    }
+  virtual cmCommand* Clone() { return new cmIncludeRegularExpressionCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "include_regular_expression";}
+  virtual std::string GetName() const { return "include_regular_expression"; }
 
   cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 7e72a8a..e9de8df 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -11,97 +11,79 @@
 ============================================================================*/
 #include "cmInstallCommand.h"
 
+#include "cmExportSet.h"
+#include "cmInstallCommandArguments.h"
 #include "cmInstallDirectoryGenerator.h"
+#include "cmInstallExportGenerator.h"
 #include "cmInstallFilesGenerator.h"
 #include "cmInstallScriptGenerator.h"
 #include "cmInstallTargetGenerator.h"
-#include "cmInstallExportGenerator.h"
-#include "cmInstallCommandArguments.h"
 #include "cmTargetExport.h"
-#include "cmExportSet.h"
 
 #include <cmsys/Glob.hxx>
 
-static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target,
-     const cmInstallCommandArguments& args, bool impLib, bool forceOpt = false)
+static cmInstallTargetGenerator* CreateInstallTargetGenerator(
+  cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
+  bool forceOpt = false)
 {
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
   target.SetHaveInstallRule(true);
-  return new cmInstallTargetGenerator(target.GetName(),
-                        args.GetDestination().c_str(),
-                        impLib, args.GetPermissions().c_str(),
-                        args.GetConfigurations(), args.GetComponent().c_str(),
-                        message,
-                        args.GetOptional() || forceOpt);
+  return new cmInstallTargetGenerator(
+    target.GetName(), args.GetDestination().c_str(), impLib,
+    args.GetPermissions().c_str(), args.GetConfigurations(),
+    args.GetComponent().c_str(), message, args.GetExcludeFromAll(),
+    args.GetOptional() || forceOpt);
 }
 
 static cmInstallFilesGenerator* CreateInstallFilesGenerator(
-  cmMakefile* mf,
-    const std::vector<std::string>& absFiles,
-    const cmInstallCommandArguments& args, bool programs)
+  cmMakefile* mf, const std::vector<std::string>& absFiles,
+  const cmInstallCommandArguments& args, bool programs)
 {
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(mf);
   return new cmInstallFilesGenerator(
-                        absFiles, args.GetDestination().c_str(),
-                        programs, args.GetPermissions().c_str(),
-                        args.GetConfigurations(), args.GetComponent().c_str(),
-                        message,
-                        args.GetRename().c_str(), args.GetOptional());
+    absFiles, args.GetDestination().c_str(), programs,
+    args.GetPermissions().c_str(), args.GetConfigurations(),
+    args.GetComponent().c_str(), message, args.GetExcludeFromAll(),
+    args.GetRename().c_str(), args.GetOptional());
 }
 
-
 // cmInstallCommand
 bool cmInstallCommand::InitialPass(std::vector<std::string> const& args,
-                                   cmExecutionStatus &)
+                                   cmExecutionStatus&)
 {
   // Allow calling with no arguments so that arguments may be built up
   // using a variable that may be left empty.
-  if(args.empty())
-    {
+  if (args.empty()) {
     return true;
-    }
+  }
 
   // Enable the install target.
   this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
 
-  this->DefaultComponentName = this->Makefile->GetSafeDefinition(
-                                       "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
-  if (this->DefaultComponentName.empty())
-    {
+  this->DefaultComponentName =
+    this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
+  if (this->DefaultComponentName.empty()) {
     this->DefaultComponentName = "Unspecified";
-    }
+  }
 
   // Switch among the command modes.
-  if(args[0] == "SCRIPT")
-    {
+  if (args[0] == "SCRIPT") {
     return this->HandleScriptMode(args);
-    }
-  else if(args[0] == "CODE")
-    {
+  } else if (args[0] == "CODE") {
     return this->HandleScriptMode(args);
-    }
-  else if(args[0] == "TARGETS")
-    {
+  } else if (args[0] == "TARGETS") {
     return this->HandleTargetsMode(args);
-    }
-  else if(args[0] == "FILES")
-    {
+  } else if (args[0] == "FILES") {
     return this->HandleFilesMode(args);
-    }
-  else if(args[0] == "PROGRAMS")
-    {
+  } else if (args[0] == "PROGRAMS") {
     return this->HandleFilesMode(args);
-    }
-  else if(args[0] == "DIRECTORY")
-    {
+  } else if (args[0] == "DIRECTORY") {
     return this->HandleDirectoryMode(args);
-    }
-  else if(args[0] == "EXPORT")
-    {
+  } else if (args[0] == "EXPORT") {
     return this->HandleExportMode(args);
-    }
+  }
 
   // Unknown mode.
   std::string e = "called with unknown mode ";
@@ -110,102 +92,85 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args,
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
 {
   std::string component = this->DefaultComponentName;
   int componentCount = 0;
   bool doing_script = false;
   bool doing_code = false;
+  bool exclude_from_all = false;
 
   // Scan the args once for COMPONENT. Only allow one.
   //
-  for(size_t i=0; i < args.size(); ++i)
-    {
-    if(args[i] == "COMPONENT" && i+1 < args.size())
-        {
-        ++componentCount;
-        ++i;
-        component = args[i];
-        }
+  for (size_t i = 0; i < args.size(); ++i) {
+    if (args[i] == "COMPONENT" && i + 1 < args.size()) {
+      ++componentCount;
+      ++i;
+      component = args[i];
     }
+    if (args[i] == "EXCLUDE_FROM_ALL") {
+      exclude_from_all = true;
+    }
+  }
 
-  if(componentCount>1)
-    {
+  if (componentCount > 1) {
     this->SetError("given more than one COMPONENT for the SCRIPT or CODE "
-      "signature of the INSTALL command. "
-      "Use multiple INSTALL commands with one COMPONENT each.");
+                   "signature of the INSTALL command. "
+                   "Use multiple INSTALL commands with one COMPONENT each.");
     return false;
-    }
+  }
 
   // Scan the args again, this time adding install generators each time we
   // encounter a SCRIPT or CODE arg:
   //
-  for(size_t i=0; i < args.size(); ++i)
-    {
-    if(args[i] == "SCRIPT")
-      {
+  for (size_t i = 0; i < args.size(); ++i) {
+    if (args[i] == "SCRIPT") {
       doing_script = true;
       doing_code = false;
-      }
-    else if(args[i] == "CODE")
-      {
+    } else if (args[i] == "CODE") {
       doing_script = false;
       doing_code = true;
-      }
-    else if(args[i] == "COMPONENT")
-      {
+    } else if (args[i] == "COMPONENT") {
       doing_script = false;
       doing_code = false;
-      }
-    else if(doing_script)
-      {
+    } else if (doing_script) {
       doing_script = false;
       std::string script = args[i];
-      if(!cmSystemTools::FileIsFullPath(script.c_str()))
-        {
+      if (!cmSystemTools::FileIsFullPath(script.c_str())) {
         script = this->Makefile->GetCurrentSourceDirectory();
         script += "/";
         script += args[i];
-        }
-      if(cmSystemTools::FileIsDirectory(script))
-        {
+      }
+      if (cmSystemTools::FileIsDirectory(script)) {
         this->SetError("given a directory as value of SCRIPT argument.");
         return false;
-        }
-      this->Makefile->AddInstallGenerator(
-        new cmInstallScriptGenerator(script.c_str(), false,
-                                     component.c_str()));
       }
-    else if(doing_code)
-      {
+      this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
+        script.c_str(), false, component.c_str(), exclude_from_all));
+    } else if (doing_code) {
       doing_code = false;
       std::string code = args[i];
-      this->Makefile->AddInstallGenerator(
-        new cmInstallScriptGenerator(code.c_str(), true,
-                                     component.c_str()));
-      }
+      this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
+        code.c_str(), true, component.c_str(), exclude_from_all));
     }
+  }
 
-  if(doing_script)
-    {
+  if (doing_script) {
     this->SetError("given no value for SCRIPT argument.");
     return false;
-    }
-  if(doing_code)
-    {
+  }
+  if (doing_code) {
     this->SetError("given no value for CODE argument.");
     return false;
-    }
+  }
 
-  //Tell the global generator about any installation component names specified.
-  this->Makefile->GetGlobalGenerator()
-                             ->AddInstallComponent(component.c_str());
+  // Tell the global generator about any installation component names
+  // specified.
+  this->Makefile->GetGlobalGenerator()->AddInstallComponent(component.c_str());
 
   return true;
 }
 
-
 /*struct InstallPart
 {
   InstallPart(cmCommandArgumentsHelper* helper, const char* key,
@@ -214,7 +179,6 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
   cmInstallCommandArguments args;
 };*/
 
-//----------------------------------------------------------------------------
 bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
 {
   // This is the TARGETS mode.
@@ -222,16 +186,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
 
   cmCommandArgumentsHelper argHelper;
   cmCommandArgumentGroup group;
-  cmCAStringVector genericArgVector      (&argHelper,0);
-  cmCAStringVector archiveArgVector      (&argHelper,"ARCHIVE",&group);
-  cmCAStringVector libraryArgVector      (&argHelper,"LIBRARY",&group);
-  cmCAStringVector runtimeArgVector      (&argHelper,"RUNTIME",&group);
-  cmCAStringVector frameworkArgVector    (&argHelper,"FRAMEWORK",&group);
-  cmCAStringVector bundleArgVector       (&argHelper,"BUNDLE",&group);
-  cmCAStringVector includesArgVector     (&argHelper,"INCLUDES",&group);
-  cmCAStringVector privateHeaderArgVector(&argHelper,"PRIVATE_HEADER",&group);
-  cmCAStringVector publicHeaderArgVector (&argHelper,"PUBLIC_HEADER",&group);
-  cmCAStringVector resourceArgVector     (&argHelper,"RESOURCE",&group);
+  cmCAStringVector genericArgVector(&argHelper, 0);
+  cmCAStringVector archiveArgVector(&argHelper, "ARCHIVE", &group);
+  cmCAStringVector libraryArgVector(&argHelper, "LIBRARY", &group);
+  cmCAStringVector runtimeArgVector(&argHelper, "RUNTIME", &group);
+  cmCAStringVector frameworkArgVector(&argHelper, "FRAMEWORK", &group);
+  cmCAStringVector bundleArgVector(&argHelper, "BUNDLE", &group);
+  cmCAStringVector includesArgVector(&argHelper, "INCLUDES", &group);
+  cmCAStringVector privateHeaderArgVector(&argHelper, "PRIVATE_HEADER",
+                                          &group);
+  cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group);
+  cmCAStringVector resourceArgVector(&argHelper, "RESOURCE", &group);
   genericArgVector.Follows(0);
   group.Follows(&genericArgVector);
 
@@ -243,7 +208,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
   std::vector<std::string> unknownArgs;
   cmInstallCommandArguments genericArgs(this->DefaultComponentName);
   cmCAStringVector targetList(&genericArgs.Parser, "TARGETS");
-  cmCAString exports(&genericArgs.Parser,"EXPORT", &genericArgs.ArgumentGroup);
+  cmCAString exports(&genericArgs.Parser, "EXPORT",
+                     &genericArgs.ArgumentGroup);
   targetList.Follows(0);
   genericArgs.ArgumentGroup.Follows(&targetList);
   genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs);
@@ -261,24 +227,23 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
 
   // now parse the args for specific parts of the target (e.g. LIBRARY,
   // RUNTIME, ARCHIVE etc.
-  archiveArgs.Parse      (&archiveArgVector.GetVector(),       &unknownArgs);
-  libraryArgs.Parse      (&libraryArgVector.GetVector(),       &unknownArgs);
-  runtimeArgs.Parse      (&runtimeArgVector.GetVector(),       &unknownArgs);
-  frameworkArgs.Parse    (&frameworkArgVector.GetVector(),     &unknownArgs);
-  bundleArgs.Parse       (&bundleArgVector.GetVector(),        &unknownArgs);
+  archiveArgs.Parse(&archiveArgVector.GetVector(), &unknownArgs);
+  libraryArgs.Parse(&libraryArgVector.GetVector(), &unknownArgs);
+  runtimeArgs.Parse(&runtimeArgVector.GetVector(), &unknownArgs);
+  frameworkArgs.Parse(&frameworkArgVector.GetVector(), &unknownArgs);
+  bundleArgs.Parse(&bundleArgVector.GetVector(), &unknownArgs);
   privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs);
-  publicHeaderArgs.Parse (&publicHeaderArgVector.GetVector(),  &unknownArgs);
-  resourceArgs.Parse     (&resourceArgVector.GetVector(),      &unknownArgs);
-  includesArgs.Parse     (&includesArgVector.GetVector(),      &unknownArgs);
+  publicHeaderArgs.Parse(&publicHeaderArgVector.GetVector(), &unknownArgs);
+  resourceArgs.Parse(&resourceArgVector.GetVector(), &unknownArgs);
+  includesArgs.Parse(&includesArgVector.GetVector(), &unknownArgs);
 
-  if(!unknownArgs.empty())
-    {
+  if (!unknownArgs.empty()) {
     // Unknown argument.
     std::ostringstream e;
     e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // apply generic args
   archiveArgs.SetGenericArguments(&genericArgs);
@@ -299,125 +264,98 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
   success = success && publicHeaderArgs.Finalize();
   success = success && resourceArgs.Finalize();
 
-  if(!success)
-    {
+  if (!success) {
     return false;
-    }
+  }
 
   // Enforce argument rules too complex to specify for the
   // general-purpose parser.
-  if(archiveArgs.GetNamelinkOnly() ||
-     runtimeArgs.GetNamelinkOnly() ||
-     frameworkArgs.GetNamelinkOnly() ||
-     bundleArgs.GetNamelinkOnly() ||
-     privateHeaderArgs.GetNamelinkOnly() ||
-     publicHeaderArgs.GetNamelinkOnly() ||
-     resourceArgs.GetNamelinkOnly())
-    {
+  if (archiveArgs.GetNamelinkOnly() || runtimeArgs.GetNamelinkOnly() ||
+      frameworkArgs.GetNamelinkOnly() || bundleArgs.GetNamelinkOnly() ||
+      privateHeaderArgs.GetNamelinkOnly() ||
+      publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly()) {
     this->SetError(
       "TARGETS given NAMELINK_ONLY option not in LIBRARY group.  "
-      "The NAMELINK_ONLY option may be specified only following LIBRARY."
-      );
+      "The NAMELINK_ONLY option may be specified only following LIBRARY.");
     return false;
-    }
-  if(archiveArgs.GetNamelinkSkip() ||
-     runtimeArgs.GetNamelinkSkip() ||
-     frameworkArgs.GetNamelinkSkip() ||
-     bundleArgs.GetNamelinkSkip() ||
-     privateHeaderArgs.GetNamelinkSkip() ||
-     publicHeaderArgs.GetNamelinkSkip() ||
-     resourceArgs.GetNamelinkSkip())
-    {
+  }
+  if (archiveArgs.GetNamelinkSkip() || runtimeArgs.GetNamelinkSkip() ||
+      frameworkArgs.GetNamelinkSkip() || bundleArgs.GetNamelinkSkip() ||
+      privateHeaderArgs.GetNamelinkSkip() ||
+      publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip()) {
     this->SetError(
       "TARGETS given NAMELINK_SKIP option not in LIBRARY group.  "
-      "The NAMELINK_SKIP option may be specified only following LIBRARY."
-      );
+      "The NAMELINK_SKIP option may be specified only following LIBRARY.");
     return false;
-    }
-  if(libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip())
-    {
-    this->SetError(
-      "TARGETS given NAMELINK_ONLY and NAMELINK_SKIP.  "
-      "At most one of these two options may be specified."
-      );
+  }
+  if (libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip()) {
+    this->SetError("TARGETS given NAMELINK_ONLY and NAMELINK_SKIP.  "
+                   "At most one of these two options may be specified.");
     return false;
-    }
+  }
 
   // Select the mode for installing symlinks to versioned shared libraries.
-  cmInstallTargetGenerator::NamelinkModeType
-    namelinkMode = cmInstallTargetGenerator::NamelinkModeNone;
-  if(libraryArgs.GetNamelinkOnly())
-    {
+  cmInstallTargetGenerator::NamelinkModeType namelinkMode =
+    cmInstallTargetGenerator::NamelinkModeNone;
+  if (libraryArgs.GetNamelinkOnly()) {
     namelinkMode = cmInstallTargetGenerator::NamelinkModeOnly;
-    }
-  else if(libraryArgs.GetNamelinkSkip())
-    {
+  } else if (libraryArgs.GetNamelinkSkip()) {
     namelinkMode = cmInstallTargetGenerator::NamelinkModeSkip;
-    }
+  }
 
   // Check if there is something to do.
-  if(targetList.GetVector().empty())
-    {
+  if (targetList.GetVector().empty()) {
     return true;
-    }
+  }
 
   // Check whether this is a DLL platform.
-  bool dll_platform = (this->Makefile->IsOn("WIN32") ||
-                       this->Makefile->IsOn("CYGWIN") ||
-                       this->Makefile->IsOn("MINGW"));
-
-  for(std::vector<std::string>::const_iterator
-      targetIt=targetList.GetVector().begin();
-      targetIt!=targetList.GetVector().end();
-      ++targetIt)
-    {
-
-    if (this->Makefile->IsAlias(*targetIt))
-      {
+  bool dll_platform =
+    (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
+     this->Makefile->IsOn("MINGW"));
+
+  for (std::vector<std::string>::const_iterator targetIt =
+         targetList.GetVector().begin();
+       targetIt != targetList.GetVector().end(); ++targetIt) {
+
+    if (this->Makefile->IsAlias(*targetIt)) {
       std::ostringstream e;
-      e << "TARGETS given target \"" << (*targetIt)
-        << "\" which is an alias.";
+      e << "TARGETS given target \"" << (*targetIt) << "\" which is an alias.";
       this->SetError(e.str());
       return false;
-      }
+    }
     // Lookup this target in the current directory.
-    if(cmTarget* target=this->Makefile->FindLocalNonAliasTarget(*targetIt))
-      {
+    if (cmTarget* target =
+          this->Makefile->FindLocalNonAliasTarget(*targetIt)) {
       // Found the target.  Check its type.
-      if(target->GetType() != cmState::EXECUTABLE &&
-         target->GetType() != cmState::STATIC_LIBRARY &&
-         target->GetType() != cmState::SHARED_LIBRARY &&
-         target->GetType() != cmState::MODULE_LIBRARY &&
-         target->GetType() != cmState::OBJECT_LIBRARY &&
-         target->GetType() != cmState::INTERFACE_LIBRARY)
-        {
+      if (target->GetType() != cmState::EXECUTABLE &&
+          target->GetType() != cmState::STATIC_LIBRARY &&
+          target->GetType() != cmState::SHARED_LIBRARY &&
+          target->GetType() != cmState::MODULE_LIBRARY &&
+          target->GetType() != cmState::OBJECT_LIBRARY &&
+          target->GetType() != cmState::INTERFACE_LIBRARY) {
         std::ostringstream e;
         e << "TARGETS given target \"" << (*targetIt)
           << "\" which is not an executable, library, or module.";
         this->SetError(e.str());
         return false;
-        }
-      else if(target->GetType() == cmState::OBJECT_LIBRARY)
-        {
+      } else if (target->GetType() == cmState::OBJECT_LIBRARY) {
         std::ostringstream e;
         e << "TARGETS given OBJECT library \"" << (*targetIt)
           << "\" which may not be installed.";
         this->SetError(e.str());
         return false;
-        }
+      }
       // Store the target in the list to be installed.
       targets.push_back(target);
-      }
-    else
-      {
+    } else {
       // Did not find the target.
       std::ostringstream e;
       e << "TARGETS given target \"" << (*targetIt)
         << "\" which does not exist in this directory.";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Keep track of whether we will be performing an installation of
   // any files of the given type.
@@ -431,9 +369,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
   bool installsResource = false;
 
   // Generate install script code to install the given targets.
-  for(std::vector<cmTarget*>::iterator ti = targets.begin();
-      ti != targets.end(); ++ti)
-    {
+  for (std::vector<cmTarget*>::iterator ti = targets.begin();
+       ti != targets.end(); ++ti) {
     // Handle each target type.
     cmTarget& target = *(*ti);
     cmInstallTargetGenerator* archiveGenerator = 0;
@@ -448,204 +385,163 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
     // Track whether this is a namelink-only rule.
     bool namelinkOnly = false;
 
-    switch(target.GetType())
-      {
-      case cmState::SHARED_LIBRARY:
-        {
+    switch (target.GetType()) {
+      case cmState::SHARED_LIBRARY: {
         // Shared libraries are handled differently on DLL and non-DLL
         // platforms.  All windows platforms are DLL platforms including
         // cygwin.  Currently no other platform is a DLL platform.
-        if(dll_platform)
-          {
+        if (dll_platform) {
           // When in namelink only mode skip all libraries on Windows.
-          if(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly)
-            {
+          if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) {
             continue;
-            }
+          }
 
           // This is a DLL platform.
-          if(!archiveArgs.GetDestination().empty())
-            {
+          if (!archiveArgs.GetDestination().empty()) {
             // The import library uses the ARCHIVE properties.
-            archiveGenerator = CreateInstallTargetGenerator(target,
-                                                            archiveArgs, true);
-            }
-          if(!runtimeArgs.GetDestination().empty())
-            {
+            archiveGenerator =
+              CreateInstallTargetGenerator(target, archiveArgs, true);
+          }
+          if (!runtimeArgs.GetDestination().empty()) {
             // The DLL uses the RUNTIME properties.
-            runtimeGenerator = CreateInstallTargetGenerator(target,
-                                                           runtimeArgs, false);
-            }
-          if ((archiveGenerator==0) && (runtimeGenerator==0))
-            {
+            runtimeGenerator =
+              CreateInstallTargetGenerator(target, runtimeArgs, false);
+          }
+          if ((archiveGenerator == 0) && (runtimeGenerator == 0)) {
             this->SetError("Library TARGETS given no DESTINATION!");
             return false;
-            }
           }
-        else
-          {
+        } else {
           // This is a non-DLL platform.
           // If it is marked with FRAMEWORK property use the FRAMEWORK set of
           // INSTALL properties. Otherwise, use the LIBRARY properties.
-          if(target.IsFrameworkOnApple())
-            {
+          if (target.IsFrameworkOnApple()) {
             // When in namelink only mode skip frameworks.
-            if(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly)
-              {
+            if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) {
               continue;
-              }
+            }
 
             // Use the FRAMEWORK properties.
-            if (!frameworkArgs.GetDestination().empty())
-              {
-              frameworkGenerator = CreateInstallTargetGenerator(target,
-                                                         frameworkArgs, false);
-              }
-            else
-              {
+            if (!frameworkArgs.GetDestination().empty()) {
+              frameworkGenerator =
+                CreateInstallTargetGenerator(target, frameworkArgs, false);
+            } else {
               std::ostringstream e;
               e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
-                "FRAMEWORK target \"" << target.GetName() << "\".";
+                   "FRAMEWORK target \""
+                << target.GetName() << "\".";
               this->SetError(e.str());
               return false;
-              }
             }
-          else
-            {
+          } else {
             // The shared library uses the LIBRARY properties.
-            if (!libraryArgs.GetDestination().empty())
-              {
-              libraryGenerator = CreateInstallTargetGenerator(target,
-                                                           libraryArgs, false);
+            if (!libraryArgs.GetDestination().empty()) {
+              libraryGenerator =
+                CreateInstallTargetGenerator(target, libraryArgs, false);
               libraryGenerator->SetNamelinkMode(namelinkMode);
               namelinkOnly =
                 (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
-              }
-            else
-              {
+            } else {
               std::ostringstream e;
               e << "TARGETS given no LIBRARY DESTINATION for shared library "
-                "target \"" << target.GetName() << "\".";
+                   "target \""
+                << target.GetName() << "\".";
               this->SetError(e.str());
               return false;
-              }
             }
           }
         }
-        break;
-      case cmState::STATIC_LIBRARY:
-        {
+      } break;
+      case cmState::STATIC_LIBRARY: {
         // Static libraries use ARCHIVE properties.
-        if (!archiveArgs.GetDestination().empty())
-          {
-          archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs,
-                                                          false);
-          }
-        else
-          {
+        if (!archiveArgs.GetDestination().empty()) {
+          archiveGenerator =
+            CreateInstallTargetGenerator(target, archiveArgs, false);
+        } else {
           std::ostringstream e;
           e << "TARGETS given no ARCHIVE DESTINATION for static library "
-            "target \"" << target.GetName() << "\".";
+               "target \""
+            << target.GetName() << "\".";
           this->SetError(e.str());
           return false;
-          }
         }
-        break;
-      case cmState::MODULE_LIBRARY:
-        {
+      } break;
+      case cmState::MODULE_LIBRARY: {
         // Modules use LIBRARY properties.
-        if (!libraryArgs.GetDestination().empty())
-          {
-          libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs,
-                                                          false);
+        if (!libraryArgs.GetDestination().empty()) {
+          libraryGenerator =
+            CreateInstallTargetGenerator(target, libraryArgs, false);
           libraryGenerator->SetNamelinkMode(namelinkMode);
           namelinkOnly =
             (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
-          }
-        else
-          {
+        } else {
           std::ostringstream e;
           e << "TARGETS given no LIBRARY DESTINATION for module target \""
             << target.GetName() << "\".";
           this->SetError(e.str());
           return false;
-          }
         }
-        break;
-      case cmState::EXECUTABLE:
-        {
-        if(target.IsAppBundleOnApple())
-          {
+      } break;
+      case cmState::EXECUTABLE: {
+        if (target.IsAppBundleOnApple()) {
           // Application bundles use the BUNDLE properties.
-          if (!bundleArgs.GetDestination().empty())
-            {
-            bundleGenerator = CreateInstallTargetGenerator(target, bundleArgs,
-                                                           false);
-            }
-          else if(!runtimeArgs.GetDestination().empty())
-            {
+          if (!bundleArgs.GetDestination().empty()) {
+            bundleGenerator =
+              CreateInstallTargetGenerator(target, bundleArgs, false);
+          } else if (!runtimeArgs.GetDestination().empty()) {
             bool failure = false;
-            if(this->CheckCMP0006(failure))
-              {
+            if (this->CheckCMP0006(failure)) {
               // For CMake 2.4 compatibility fallback to the RUNTIME
               // properties.
               bundleGenerator =
                 CreateInstallTargetGenerator(target, runtimeArgs, false);
-              }
-            else if(failure)
-              {
+            } else if (failure) {
               return false;
-              }
             }
-          if(!bundleGenerator)
-            {
+          }
+          if (!bundleGenerator) {
             std::ostringstream e;
             e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
-                 "executable target \"" << target.GetName() << "\".";
+                 "executable target \""
+              << target.GetName() << "\".";
             this->SetError(e.str());
             return false;
-            }
           }
-        else
-          {
+        } else {
           // Executables use the RUNTIME properties.
-          if (!runtimeArgs.GetDestination().empty())
-            {
-            runtimeGenerator = CreateInstallTargetGenerator(target,
-                                                           runtimeArgs, false);
-            }
-          else
-            {
+          if (!runtimeArgs.GetDestination().empty()) {
+            runtimeGenerator =
+              CreateInstallTargetGenerator(target, runtimeArgs, false);
+          } else {
             std::ostringstream e;
             e << "TARGETS given no RUNTIME DESTINATION for executable "
-                 "target \"" << target.GetName() << "\".";
+                 "target \""
+              << target.GetName() << "\".";
             this->SetError(e.str());
             return false;
-            }
           }
+        }
 
         // On DLL platforms an executable may also have an import
         // library.  Install it to the archive destination if it
         // exists.
-        if(dll_platform && !archiveArgs.GetDestination().empty() &&
-           target.IsExecutableWithExports())
-          {
+        if (dll_platform && !archiveArgs.GetDestination().empty() &&
+            target.IsExecutableWithExports()) {
           // The import library uses the ARCHIVE properties.
-          archiveGenerator = CreateInstallTargetGenerator(target,
-                                                      archiveArgs, true, true);
-          }
+          archiveGenerator =
+            CreateInstallTargetGenerator(target, archiveArgs, true, true);
         }
-        break;
+      } break;
       case cmState::INTERFACE_LIBRARY:
-          // Nothing to do. An INTERFACE_LIBRARY can be installed, but the
-          // only effect of that is to make it exportable. It installs no
-          // other files itself.
+        // Nothing to do. An INTERFACE_LIBRARY can be installed, but the
+        // only effect of that is to make it exportable. It installs no
+        // other files itself.
         break;
       default:
         // This should never happen due to the above type check.
         // Ignore the case.
         break;
-      }
+    }
 
     // These well-known sets of files are installed *automatically* for
     // FRAMEWORK SHARED library targets on the Mac as part of installing the
@@ -654,94 +550,75 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
     // generators for them.
     bool createInstallGeneratorsForTargetFileSets = true;
 
-    if(target.IsFrameworkOnApple()
-        || target.GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (target.IsFrameworkOnApple() ||
+        target.GetType() == cmState::INTERFACE_LIBRARY) {
       createInstallGeneratorsForTargetFileSets = false;
-      }
+    }
 
-    if(createInstallGeneratorsForTargetFileSets && !namelinkOnly)
-      {
+    if (createInstallGeneratorsForTargetFileSets && !namelinkOnly) {
       const char* files = target.GetProperty("PRIVATE_HEADER");
-      if ((files) && (*files))
-        {
+      if ((files) && (*files)) {
         std::vector<std::string> relFiles;
         cmSystemTools::ExpandListArgument(files, relFiles);
         std::vector<std::string> absFiles;
-        if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles))
-          {
+        if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) {
           return false;
-          }
+        }
 
         // Create the files install generator.
-        if (!privateHeaderArgs.GetDestination().empty())
-          {
-          privateHeaderGenerator =
-            CreateInstallFilesGenerator(this->Makefile, absFiles,
-                                        privateHeaderArgs, false);
-          }
-        else
-          {
+        if (!privateHeaderArgs.GetDestination().empty()) {
+          privateHeaderGenerator = CreateInstallFilesGenerator(
+            this->Makefile, absFiles, privateHeaderArgs, false);
+        } else {
           std::ostringstream e;
           e << "INSTALL TARGETS - target " << target.GetName() << " has "
             << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
           cmSystemTools::Message(e.str().c_str(), "Warning");
-          }
         }
+      }
 
       files = target.GetProperty("PUBLIC_HEADER");
-      if ((files) && (*files))
-        {
+      if ((files) && (*files)) {
         std::vector<std::string> relFiles;
         cmSystemTools::ExpandListArgument(files, relFiles);
         std::vector<std::string> absFiles;
-        if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles))
-          {
+        if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) {
           return false;
-          }
+        }
 
         // Create the files install generator.
-        if (!publicHeaderArgs.GetDestination().empty())
-          {
-          publicHeaderGenerator =
-            CreateInstallFilesGenerator(this->Makefile, absFiles,
-                                        publicHeaderArgs, false);
-          }
-        else
-          {
+        if (!publicHeaderArgs.GetDestination().empty()) {
+          publicHeaderGenerator = CreateInstallFilesGenerator(
+            this->Makefile, absFiles, publicHeaderArgs, false);
+        } else {
           std::ostringstream e;
           e << "INSTALL TARGETS - target " << target.GetName() << " has "
             << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
           cmSystemTools::Message(e.str().c_str(), "Warning");
-          }
         }
+      }
 
       files = target.GetProperty("RESOURCE");
-      if ((files) && (*files))
-        {
+      if ((files) && (*files)) {
         std::vector<std::string> relFiles;
         cmSystemTools::ExpandListArgument(files, relFiles);
         std::vector<std::string> absFiles;
-        if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles))
-          {
+        if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) {
           return false;
-          }
+        }
 
         // Create the files install generator.
-        if (!resourceArgs.GetDestination().empty())
-          {
+        if (!resourceArgs.GetDestination().empty()) {
           resourceGenerator = CreateInstallFilesGenerator(
             this->Makefile, absFiles, resourceArgs, false);
-          }
-        else
-          {
+        } else {
           std::ostringstream e;
           e << "INSTALL TARGETS - target " << target.GetName() << " has "
             << "RESOURCE files but no RESOURCE DESTINATION.";
           cmSystemTools::Message(e.str().c_str(), "Warning");
-          }
         }
       }
+    }
 
     // Keep track of whether we're installing anything in each category
     installsArchive = installsArchive || archiveGenerator != 0;
@@ -749,8 +626,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
     installsRuntime = installsRuntime || runtimeGenerator != 0;
     installsFramework = installsFramework || frameworkGenerator != 0;
     installsBundle = installsBundle || bundleGenerator != 0;
-    installsPrivateHeader = installsPrivateHeader
-      || privateHeaderGenerator != 0;
+    installsPrivateHeader =
+      installsPrivateHeader || privateHeaderGenerator != 0;
     installsPublicHeader = installsPublicHeader || publicHeaderGenerator != 0;
     installsResource = installsResource || resourceGenerator;
 
@@ -765,9 +642,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
 
     // Add this install rule to an export if one was specified and
     // this is not a namelink-only rule.
-    if(!exports.GetString().empty() && !namelinkOnly)
-      {
-      cmTargetExport *te = new cmTargetExport;
+    if (!exports.GetString().empty() && !namelinkOnly) {
+      cmTargetExport* te = new cmTargetExport;
       te->TargetName = target.GetName();
       te->ArchiveGenerator = archiveGenerator;
       te->BundleGenerator = bundleGenerator;
@@ -776,60 +652,52 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
       te->LibraryGenerator = libraryGenerator;
       te->RuntimeGenerator = runtimeGenerator;
       this->Makefile->GetGlobalGenerator()
-        ->GetExportSets()[exports.GetString()]->AddTargetExport(te);
+        ->GetExportSets()[exports.GetString()]
+        ->AddTargetExport(te);
 
       te->InterfaceIncludeDirectories =
-          cmJoin(includesArgs.GetIncludeDirs(), ";");
-      }
+        cmJoin(includesArgs.GetIncludeDirs(), ";");
     }
+  }
 
   // Tell the global generator about any installation component names
   // specified
-  if (installsArchive)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(archiveArgs.GetComponent().c_str());
-    }
-  if (installsLibrary)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(libraryArgs.GetComponent().c_str());
-    }
-  if (installsRuntime)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(runtimeArgs.GetComponent().c_str());
-    }
-  if (installsFramework)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(frameworkArgs.GetComponent().c_str());
-    }
-  if (installsBundle)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(bundleArgs.GetComponent().c_str());
-    }
-  if (installsPrivateHeader)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str());
-    }
-  if (installsPublicHeader)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str());
-    }
-  if (installsResource)
-    {
-    this->Makefile->GetGlobalGenerator()
-      ->AddInstallComponent(resourceArgs.GetComponent().c_str());
-    }
+  if (installsArchive) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      archiveArgs.GetComponent().c_str());
+  }
+  if (installsLibrary) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      libraryArgs.GetComponent().c_str());
+  }
+  if (installsRuntime) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      runtimeArgs.GetComponent().c_str());
+  }
+  if (installsFramework) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      frameworkArgs.GetComponent().c_str());
+  }
+  if (installsBundle) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      bundleArgs.GetComponent().c_str());
+  }
+  if (installsPrivateHeader) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      privateHeaderArgs.GetComponent().c_str());
+  }
+  if (installsPublicHeader) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      publicHeaderArgs.GetComponent().c_str());
+  }
+  if (installsResource) {
+    this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+      resourceArgs.GetComponent().c_str());
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
 {
   // This is the FILES mode.
@@ -841,53 +709,46 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
   std::vector<std::string> unknownArgs;
   ica.Parse(&args, &unknownArgs);
 
-  if(!unknownArgs.empty())
-    {
+  if (!unknownArgs.empty()) {
     // Unknown argument.
     std::ostringstream e;
     e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   const std::vector<std::string>& filesVector = files.GetVector();
 
   // Check if there is something to do.
-  if(filesVector.empty())
-    {
+  if (filesVector.empty()) {
     return true;
-    }
+  }
 
-  if(!ica.GetRename().empty() && filesVector.size() > 1)
-    {
+  if (!ica.GetRename().empty() && filesVector.size() > 1) {
     // The rename option works only with one file.
     std::ostringstream e;
     e << args[0] << " given RENAME option with more than one file.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   std::vector<std::string> absFiles;
-  if (!this->MakeFilesFullPath(args[0].c_str(), filesVector, absFiles))
-    {
+  if (!this->MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) {
     return false;
-    }
+  }
 
   cmPolicies::PolicyStatus status =
-      this->Makefile->GetPolicyStatus(cmPolicies::CMP0062);
-
-  cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator();
-  for(std::vector<std::string>::const_iterator fileIt = filesVector.begin();
-      fileIt != filesVector.end(); ++fileIt)
-    {
-    if (gg->IsExportedTargetsFile(*fileIt))
-      {
-      const char *modal = 0;
+    this->Makefile->GetPolicyStatus(cmPolicies::CMP0062);
+
+  cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
+  for (std::vector<std::string>::const_iterator fileIt = filesVector.begin();
+       fileIt != filesVector.end(); ++fileIt) {
+    if (gg->IsExportedTargetsFile(*fileIt)) {
+      const char* modal = 0;
       std::ostringstream e;
       cmake::MessageType messageType = cmake::AUTHOR_WARNING;
 
-      switch(status)
-        {
+      switch (status) {
         case cmPolicies::WARN:
           e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n";
           modal = "should";
@@ -898,57 +759,65 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
         case cmPolicies::NEW:
           modal = "may";
           messageType = cmake::FATAL_ERROR;
-        }
-      if (modal)
-        {
+      }
+      if (modal) {
         e << "The file\n  " << *fileIt << "\nwas generated by the export() "
-          "command.  It " << modal << " not be installed with the "
-          "install() command.  Use the install(EXPORT) mechanism "
-          "instead.  See the cmake-packages(7) manual for more.\n";
+                                          "command.  It "
+          << modal << " not be installed with the "
+                      "install() command.  Use the install(EXPORT) mechanism "
+                      "instead.  See the cmake-packages(7) manual for more.\n";
         this->Makefile->IssueMessage(messageType, e.str());
-        if (messageType == cmake::FATAL_ERROR)
-          {
+        if (messageType == cmake::FATAL_ERROR) {
           return false;
-          }
         }
       }
     }
+  }
 
-  if (!ica.Finalize())
-    {
+  if (!ica.Finalize()) {
     return false;
-    }
+  }
 
-  if(ica.GetDestination().empty())
-    {
+  if (ica.GetDestination().empty()) {
     // A destination is required.
     std::ostringstream e;
     e << args[0] << " given no DESTINATION!";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Create the files install generator.
   this->Makefile->AddInstallGenerator(
     CreateInstallFilesGenerator(this->Makefile, absFiles, ica, programs));
 
-  //Tell the global generator about any installation component names specified.
-  this->Makefile->GetGlobalGenerator()
-                             ->AddInstallComponent(ica.GetComponent().c_str());
+  // Tell the global generator about any installation component names
+  // specified.
+  this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+    ica.GetComponent().c_str());
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
+bool cmInstallCommand::HandleDirectoryMode(
+  std::vector<std::string> const& args)
 {
-  enum Doing { DoingNone, DoingDirs, DoingDestination, DoingPattern,
-               DoingRegex, DoingPermsFile, DoingPermsDir, DoingPermsMatch,
-               DoingConfigurations, DoingComponent };
+  enum Doing
+  {
+    DoingNone,
+    DoingDirs,
+    DoingDestination,
+    DoingPattern,
+    DoingRegex,
+    DoingPermsFile,
+    DoingPermsDir,
+    DoingPermsMatch,
+    DoingConfigurations,
+    DoingComponent
+  };
   Doing doing = DoingDirs;
   bool in_match_mode = false;
   bool optional = false;
+  bool exclude_from_all = false;
   bool message_never = false;
   std::vector<std::string> dirs;
   const char* destination = 0;
@@ -957,215 +826,178 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
   std::vector<std::string> configurations;
   std::string component = this->DefaultComponentName;
   std::string literal_args;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "DESTINATION")
-      {
-      if(in_match_mode)
-        {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "DESTINATION") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Switch to setting the destination property.
       doing = DoingDestination;
-      }
-    else if(args[i] == "OPTIONAL")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "OPTIONAL") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Mark the rule as optional.
       optional = true;
       doing = DoingNone;
-      }
-    else if(args[i] == "MESSAGE_NEVER")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "MESSAGE_NEVER") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Mark the rule as quiet.
       message_never = true;
       doing = DoingNone;
-      }
-    else if(args[i] == "PATTERN")
-      {
+    } else if (args[i] == "PATTERN") {
       // Switch to a new pattern match rule.
       doing = DoingPattern;
       in_match_mode = true;
-      }
-    else if(args[i] == "REGEX")
-      {
+    } else if (args[i] == "REGEX") {
       // Switch to a new regex match rule.
       doing = DoingRegex;
       in_match_mode = true;
-      }
-    else if(args[i] == "EXCLUDE")
-      {
+    } else if (args[i] == "EXCLUDE") {
       // Add this property to the current match rule.
-      if(!in_match_mode || doing == DoingPattern || doing == DoingRegex)
-        {
+      if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" before a PATTERN or REGEX is given.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" before a PATTERN or REGEX is given.";
         this->SetError(e.str());
         return false;
-        }
+      }
       literal_args += " EXCLUDE";
       doing = DoingNone;
-      }
-    else if(args[i] == "PERMISSIONS")
-      {
-      if(!in_match_mode)
-        {
+    } else if (args[i] == "PERMISSIONS") {
+      if (!in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" before a PATTERN or REGEX is given.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" before a PATTERN or REGEX is given.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Switch to setting the current match permissions property.
       literal_args += " PERMISSIONS";
       doing = DoingPermsMatch;
-      }
-    else if(args[i] == "FILE_PERMISSIONS")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "FILE_PERMISSIONS") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Switch to setting the file permissions property.
       doing = DoingPermsFile;
-      }
-    else if(args[i] == "DIRECTORY_PERMISSIONS")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "DIRECTORY_PERMISSIONS") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Switch to setting the directory permissions property.
       doing = DoingPermsDir;
-      }
-    else if(args[i] == "USE_SOURCE_PERMISSIONS")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "USE_SOURCE_PERMISSIONS") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Add this option literally.
       literal_args += " USE_SOURCE_PERMISSIONS";
       doing = DoingNone;
-      }
-    else if(args[i] == "FILES_MATCHING")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "FILES_MATCHING") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Add this option literally.
       literal_args += " FILES_MATCHING";
       doing = DoingNone;
-      }
-    else if(args[i] == "CONFIGURATIONS")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "CONFIGURATIONS") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Switch to setting the configurations property.
       doing = DoingConfigurations;
-      }
-    else if(args[i] == "COMPONENT")
-      {
-      if(in_match_mode)
-        {
+    } else if (args[i] == "COMPONENT") {
+      if (in_match_mode) {
         std::ostringstream e;
-        e << args[0] << " does not allow \""
-          << args[i] << "\" after PATTERN or REGEX.";
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Switch to setting the component property.
       doing = DoingComponent;
+    } else if (args[i] == "EXCLUDE_FROM_ALL") {
+      if (in_match_mode) {
+        std::ostringstream e;
+        e << args[0] << " does not allow \"" << args[i]
+          << "\" after PATTERN or REGEX.";
+        this->SetError(e.str().c_str());
+        return false;
       }
-    else if(doing == DoingDirs)
-      {
+      exclude_from_all = true;
+      doing = DoingNone;
+    } else if (doing == DoingDirs) {
       // Convert this directory to a full path.
       std::string dir = args[i];
-      if(!cmSystemTools::FileIsFullPath(dir.c_str()))
-        {
+      if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
         dir = this->Makefile->GetCurrentSourceDirectory();
         dir += "/";
         dir += args[i];
-        }
+      }
 
       // Make sure the name is a directory.
-      if(cmSystemTools::FileExists(dir.c_str()) &&
-         !cmSystemTools::FileIsDirectory(dir))
-        {
+      if (cmSystemTools::FileExists(dir.c_str()) &&
+          !cmSystemTools::FileIsDirectory(dir)) {
         std::ostringstream e;
-        e << args[0] << " given non-directory \""
-          << args[i] << "\" to install.";
+        e << args[0] << " given non-directory \"" << args[i]
+          << "\" to install.";
         this->SetError(e.str());
         return false;
-        }
+      }
 
       // Store the directory for installation.
       dirs.push_back(dir);
-      }
-    else if(doing == DoingConfigurations)
-      {
+    } else if (doing == DoingConfigurations) {
       configurations.push_back(args[i]);
-      }
-    else if(doing == DoingDestination)
-      {
+    } else if (doing == DoingDestination) {
       destination = args[i].c_str();
       doing = DoingNone;
-      }
-    else if(doing == DoingPattern)
-      {
+    } else if (doing == DoingPattern) {
       // Convert the pattern to a regular expression.  Require a
       // leading slash and trailing end-of-string in the matched
       // string to make sure the pattern matches only whole file
@@ -1176,11 +1008,9 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
       literal_args += regex;
       literal_args += "$\"";
       doing = DoingNone;
-      }
-    else if(doing == DoingRegex)
-      {
+    } else if (doing == DoingRegex) {
       literal_args += " REGEX \"";
-    // Match rules are case-insensitive on some platforms.
+// Match rules are case-insensitive on some platforms.
 #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
       std::string regex = cmSystemTools::LowerCase(args[i]);
 #else
@@ -1190,101 +1020,80 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
       literal_args += regex;
       literal_args += "\"";
       doing = DoingNone;
-      }
-    else if(doing == DoingComponent)
-      {
+    } else if (doing == DoingComponent) {
       component = args[i];
       doing = DoingNone;
-      }
-    else if(doing == DoingPermsFile)
-     {
-     // Check the requested permission.
-     if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_file))
-        {
+    } else if (doing == DoingPermsFile) {
+      // Check the requested permission.
+      if (!cmInstallCommandArguments::CheckPermissions(args[i],
+                                                       permissions_file)) {
         std::ostringstream e;
-        e << args[0] << " given invalid file permission \""
-          << args[i] << "\".";
+        e << args[0] << " given invalid file permission \"" << args[i]
+          << "\".";
         this->SetError(e.str());
         return false;
-        }
       }
-    else if(doing == DoingPermsDir)
-      {
+    } else if (doing == DoingPermsDir) {
       // Check the requested permission.
-      if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_dir))
-        {
+      if (!cmInstallCommandArguments::CheckPermissions(args[i],
+                                                       permissions_dir)) {
         std::ostringstream e;
-        e << args[0] << " given invalid directory permission \""
-          << args[i] << "\".";
+        e << args[0] << " given invalid directory permission \"" << args[i]
+          << "\".";
         this->SetError(e.str());
         return false;
-        }
       }
-    else if(doing == DoingPermsMatch)
-      {
+    } else if (doing == DoingPermsMatch) {
       // Check the requested permission.
-      if(!cmInstallCommandArguments::CheckPermissions(args[i], literal_args))
-        {
+      if (!cmInstallCommandArguments::CheckPermissions(args[i],
+                                                       literal_args)) {
         std::ostringstream e;
-        e << args[0] << " given invalid permission \""
-          << args[i] << "\".";
+        e << args[0] << " given invalid permission \"" << args[i] << "\".";
         this->SetError(e.str());
         return false;
-        }
       }
-    else
-      {
+    } else {
       // Unknown argument.
       std::ostringstream e;
       e << args[0] << " given unknown argument \"" << args[i] << "\".";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Support installing an empty directory.
-  if(dirs.empty() && destination)
-    {
+  if (dirs.empty() && destination) {
     dirs.push_back("");
-    }
+  }
 
   // Check if there is something to do.
-  if(dirs.empty())
-    {
+  if (dirs.empty()) {
     return true;
-    }
-  if(!destination)
-    {
+  }
+  if (!destination) {
     // A destination is required.
     std::ostringstream e;
     e << args[0] << " given no DESTINATION!";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never);
 
   // Create the directory install generator.
-  this->Makefile->AddInstallGenerator(
-    new cmInstallDirectoryGenerator(dirs, destination,
-                                    permissions_file.c_str(),
-                                    permissions_dir.c_str(),
-                                    configurations,
-                                    component.c_str(),
-                                    message,
-                                    literal_args.c_str(),
-                                    optional));
+  this->Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator(
+    dirs, destination, permissions_file.c_str(), permissions_dir.c_str(),
+    configurations, component.c_str(), message, exclude_from_all,
+    literal_args.c_str(), optional));
 
   // Tell the global generator about any installation component names
   // specified.
-  this->Makefile->GetGlobalGenerator()
-    ->AddInstallComponent(component.c_str());
+  this->Makefile->GetGlobalGenerator()->AddInstallComponent(component.c_str());
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
 {
   // This is the EXPORT mode.
@@ -1300,61 +1109,54 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
   std::vector<std::string> unknownArgs;
   ica.Parse(&args, &unknownArgs);
 
-  if (!unknownArgs.empty())
-    {
+  if (!unknownArgs.empty()) {
     // Unknown argument.
     std::ostringstream e;
     e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
     this->SetError(e.str());
     return false;
-    }
+  }
 
-  if (!ica.Finalize())
-    {
+  if (!ica.Finalize()) {
     return false;
-    }
+  }
 
   // Make sure there is a destination.
-  if(ica.GetDestination().empty())
-    {
+  if (ica.GetDestination().empty()) {
     // A destination is required.
     std::ostringstream e;
     e << args[0] << " given no DESTINATION!";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Check the file name.
   std::string fname = filename.GetString();
-  if(fname.find_first_of(":/\\") != fname.npos)
-    {
+  if (fname.find_first_of(":/\\") != fname.npos) {
     std::ostringstream e;
     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());
     return false;
-    }
+  }
 
   // Check the file extension.
-  if(!fname.empty() &&
-     cmSystemTools::GetFilenameLastExtension(fname) != ".cmake")
-    {
+  if (!fname.empty() &&
+      cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") {
     std::ostringstream e;
     e << args[0] << " given invalid export file name \"" << fname << "\".  "
       << "The FILE argument must specify a name ending in \".cmake\".";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Construct the file name.
-  if(fname.empty())
-    {
+  if (fname.empty()) {
     fname = exp.GetString();
     fname += ".cmake";
 
-    if(fname.find_first_of(":/\\") != fname.npos)
-      {
+    if (fname.find_first_of(":/\\") != fname.npos) {
       std::ostringstream e;
       e << args[0] << " given export name \"" << exp.GetString() << "\".  "
         << "This name cannot be safely converted to a file name.  "
@@ -1362,97 +1164,83 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
         << "a file name explicitly.";
       this->SetError(e.str());
       return false;
-      }
     }
-
-  cmExportSet *exportSet = this->Makefile->GetGlobalGenerator()
-                                         ->GetExportSets()[exp.GetString()];
-  if (exportOld.IsEnabled())
-    {
-    for(std::vector<cmTargetExport*>::const_iterator
-          tei = exportSet->GetTargetExports()->begin();
-        tei != exportSet->GetTargetExports()->end(); ++tei)
-      {
+  }
+
+  cmExportSet* exportSet =
+    this->Makefile->GetGlobalGenerator()->GetExportSets()[exp.GetString()];
+  if (exportOld.IsEnabled()) {
+    for (std::vector<cmTargetExport*>::const_iterator tei =
+           exportSet->GetTargetExports()->begin();
+         tei != exportSet->GetTargetExports()->end(); ++tei) {
       cmTargetExport const* te = *tei;
       cmTarget* tgt =
         this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
       const bool newCMP0022Behavior =
-        (tgt &&
-         tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
+        (tgt && tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
          tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
 
-      if(!newCMP0022Behavior)
-        {
+      if (!newCMP0022Behavior) {
         std::ostringstream e;
         e << "INSTALL(EXPORT) given keyword \""
-          << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \""
-          << te->TargetName
+          << "EXPORT_LINK_INTERFACE_LIBRARIES"
+          << "\", but target \"" << te->TargetName
           << "\" does not have policy CMP0022 set to NEW.";
         this->SetError(e.str());
         return false;
-        }
       }
     }
+  }
 
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(this->Makefile);
 
   // Create the export install generator.
-  cmInstallExportGenerator* exportGenerator =
-    new cmInstallExportGenerator(
-      exportSet,
-      ica.GetDestination().c_str(),
-      ica.GetPermissions().c_str(), ica.GetConfigurations(),
-      ica.GetComponent().c_str(), message, fname.c_str(),
-      name_space.GetCString(), exportOld.IsEnabled());
+  cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
+    exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+    ica.GetConfigurations(), ica.GetComponent().c_str(), message,
+    ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(),
+    exportOld.IsEnabled());
   this->Makefile->AddInstallGenerator(exportGenerator);
 
   return true;
 }
 
-bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
-                                      const std::vector<std::string>& relFiles,
-                                      std::vector<std::string>& absFiles)
+bool cmInstallCommand::MakeFilesFullPath(
+  const char* modeName, const std::vector<std::string>& relFiles,
+  std::vector<std::string>& absFiles)
 {
-  for(std::vector<std::string>::const_iterator fileIt = relFiles.begin();
-      fileIt != relFiles.end();
-      ++fileIt)
-    {
+  for (std::vector<std::string>::const_iterator fileIt = relFiles.begin();
+       fileIt != relFiles.end(); ++fileIt) {
     std::string file = (*fileIt);
     std::string::size_type gpos = cmGeneratorExpression::Find(file);
-    if(gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str()))
-      {
+    if (gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str())) {
       file = this->Makefile->GetCurrentSourceDirectory();
       file += "/";
       file += *fileIt;
-      }
+    }
 
     // Make sure the file is not a directory.
-    if(gpos == file.npos && cmSystemTools::FileIsDirectory(file))
-      {
+    if (gpos == file.npos && cmSystemTools::FileIsDirectory(file)) {
       std::ostringstream e;
       e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
       this->SetError(e.str());
       return false;
-      }
+    }
     // Store the file for installation.
     absFiles.push_back(file);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmInstallCommand::CheckCMP0006(bool& failure)
 {
-  switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0006))
-    {
-    case cmPolicies::WARN:
-      {
+  switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0006)) {
+    case cmPolicies::WARN: {
       this->Makefile->IssueMessage(
         cmake::AUTHOR_WARNING,
-        cmPolicies::GetPolicyWarning(cmPolicies::CMP0006)
-        );
-      }
+        cmPolicies::GetPolicyWarning(cmPolicies::CMP0006));
+    }
     case cmPolicies::OLD:
       // OLD behavior is to allow compatibility
       return true;
@@ -1464,9 +1252,8 @@ bool cmInstallCommand::CheckCMP0006(bool& failure)
       failure = true;
       this->Makefile->IssueMessage(
         cmake::FATAL_ERROR,
-        cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0006)
-        );
+        cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0006));
       break;
-    }
+  }
   return false;
 }
diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h
index 8e14a08..93aca45 100644
--- a/Source/cmInstallCommand.h
+++ b/Source/cmInstallCommand.h
@@ -26,22 +26,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmInstallCommand;
-    }
+  virtual cmCommand* Clone() { return new cmInstallCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "install";}
+  virtual std::string GetName() const { return "install"; }
 
   cmTypeMacro(cmInstallCommand, cmCommand);
 
@@ -59,5 +56,4 @@ private:
   std::string DefaultComponentName;
 };
 
-
 #endif
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index 236ca1f..57e37a3 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -10,153 +10,145 @@
   See the License for more information.
 ============================================================================*/
 #include "cmInstallCommandArguments.h"
+
 #include "cmSystemTools.h"
 
 // Table of valid permissions.
-const char* cmInstallCommandArguments::PermissionsTable[] =
-{
-  "OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE",
-  "GROUP_READ", "GROUP_WRITE", "GROUP_EXECUTE",
-  "WORLD_READ", "WORLD_WRITE", "WORLD_EXECUTE",
-  "SETUID", "SETGID", 0
+const char* cmInstallCommandArguments::PermissionsTable[] = {
+  "OWNER_READ",    "OWNER_WRITE",   "OWNER_EXECUTE", "GROUP_READ",
+  "GROUP_WRITE",   "GROUP_EXECUTE", "WORLD_READ",    "WORLD_WRITE",
+  "WORLD_EXECUTE", "SETUID",        "SETGID",        0
 };
 
 const std::string cmInstallCommandArguments::EmptyString;
 
 cmInstallCommandArguments::cmInstallCommandArguments(
-                                           const std::string& defaultComponent)
-:Parser()
-,ArgumentGroup()
-,Destination   (&Parser, "DESTINATION"   , &ArgumentGroup)
-,Component     (&Parser, "COMPONENT"     , &ArgumentGroup)
-,Rename        (&Parser, "RENAME"        , &ArgumentGroup)
-,Permissions   (&Parser, "PERMISSIONS"   , &ArgumentGroup)
-,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup)
-,Optional      (&Parser, "OPTIONAL"      , &ArgumentGroup)
-,NamelinkOnly  (&Parser, "NAMELINK_ONLY" , &ArgumentGroup)
-,NamelinkSkip  (&Parser, "NAMELINK_SKIP" , &ArgumentGroup)
-,GenericArguments(0)
-,DefaultComponentName(defaultComponent)
+  const std::string& defaultComponent)
+  : Parser()
+  , ArgumentGroup()
+  , Destination(&Parser, "DESTINATION", &ArgumentGroup)
+  , Component(&Parser, "COMPONENT", &ArgumentGroup)
+  , ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup)
+  , Rename(&Parser, "RENAME", &ArgumentGroup)
+  , Permissions(&Parser, "PERMISSIONS", &ArgumentGroup)
+  , Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup)
+  , Optional(&Parser, "OPTIONAL", &ArgumentGroup)
+  , NamelinkOnly(&Parser, "NAMELINK_ONLY", &ArgumentGroup)
+  , NamelinkSkip(&Parser, "NAMELINK_SKIP", &ArgumentGroup)
+  , GenericArguments(0)
+  , DefaultComponentName(defaultComponent)
 {
 }
 
 const std::string& cmInstallCommandArguments::GetDestination() const
 {
-  if (!this->DestinationString.empty())
-    {
+  if (!this->DestinationString.empty()) {
     return this->DestinationString;
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetDestination();
-    }
+  }
   return this->EmptyString;
 }
 
 const std::string& cmInstallCommandArguments::GetComponent() const
 {
-  if (!this->Component.GetString().empty())
-    {
+  if (!this->Component.GetString().empty()) {
     return this->Component.GetString();
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetComponent();
-    }
-  if (!this->DefaultComponentName.empty())
-    {
+  }
+  if (!this->DefaultComponentName.empty()) {
     return this->DefaultComponentName;
-    }
+  }
   static std::string unspecifiedComponent = "Unspecified";
   return unspecifiedComponent;
 }
 
 const std::string& cmInstallCommandArguments::GetRename() const
 {
-  if (!this->Rename.GetString().empty())
-    {
+  if (!this->Rename.GetString().empty()) {
     return this->Rename.GetString();
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetRename();
-    }
+  }
   return this->EmptyString;
 }
 
 const std::string& cmInstallCommandArguments::GetPermissions() const
 {
-  if (!this->PermissionsString.empty())
-    {
+  if (!this->PermissionsString.empty()) {
     return this->PermissionsString;
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetPermissions();
-    }
+  }
   return this->EmptyString;
 }
 
 bool cmInstallCommandArguments::GetOptional() const
 {
-  if (this->Optional.IsEnabled())
-    {
+  if (this->Optional.IsEnabled()) {
     return true;
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetOptional();
-    }
+  }
+  return false;
+}
+
+bool cmInstallCommandArguments::GetExcludeFromAll() const
+{
+  if (this->ExcludeFromAll.IsEnabled()) {
+    return true;
+  }
+  if (this->GenericArguments != 0) {
+    return this->GenericArguments->GetExcludeFromAll();
+  }
   return false;
 }
 
 bool cmInstallCommandArguments::GetNamelinkOnly() const
 {
-  if (this->NamelinkOnly.IsEnabled())
-    {
+  if (this->NamelinkOnly.IsEnabled()) {
     return true;
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetNamelinkOnly();
-    }
+  }
   return false;
 }
 
 bool cmInstallCommandArguments::GetNamelinkSkip() const
 {
-  if (this->NamelinkSkip.IsEnabled())
-    {
+  if (this->NamelinkSkip.IsEnabled()) {
     return true;
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetNamelinkSkip();
-    }
+  }
   return false;
 }
 
-const std::vector<std::string>&
-    cmInstallCommandArguments::GetConfigurations() const
+const std::vector<std::string>& cmInstallCommandArguments::GetConfigurations()
+  const
 {
-  if (!this->Configurations.GetVector().empty())
-    {
+  if (!this->Configurations.GetVector().empty()) {
     return this->Configurations.GetVector();
-    }
-  if (this->GenericArguments!=0)
-    {
+  }
+  if (this->GenericArguments != 0) {
     return this->GenericArguments->GetConfigurations();
-    }
+  }
   return this->Configurations.GetVector();
 }
 
-
 bool cmInstallCommandArguments::Finalize()
 {
-  if (!this->CheckPermissions())
-    {
+  if (!this->CheckPermissions()) {
     return false;
-    }
+  }
   this->DestinationString = this->Destination.GetString();
   cmSystemTools::ConvertToUnixSlashes(this->DestinationString);
   return true;
@@ -168,45 +160,38 @@ void cmInstallCommandArguments::Parse(const std::vector<std::string>* args,
   this->Parser.Parse(args, unconsumedArgs);
 }
 
-
 bool cmInstallCommandArguments::CheckPermissions()
 {
   this->PermissionsString = "";
-  for(std::vector<std::string>::const_iterator
-      permIt = this->Permissions.GetVector().begin();
-      permIt != this->Permissions.GetVector().end();
-      ++permIt)
-    {
-    if (!this->CheckPermissions(*permIt, this->PermissionsString))
-      {
+  for (std::vector<std::string>::const_iterator permIt =
+         this->Permissions.GetVector().begin();
+       permIt != this->Permissions.GetVector().end(); ++permIt) {
+    if (!this->CheckPermissions(*permIt, this->PermissionsString)) {
       return false;
-      }
     }
+  }
   return true;
 }
 
 bool cmInstallCommandArguments::CheckPermissions(
-                    const std::string& onePermission, std::string& permissions)
+  const std::string& onePermission, std::string& permissions)
 {
   // Check the permission against the table.
-  for(const char** valid = cmInstallCommandArguments::PermissionsTable;
-      *valid; ++valid)
-    {
-    if(onePermission == *valid)
-      {
+  for (const char** valid = cmInstallCommandArguments::PermissionsTable;
+       *valid; ++valid) {
+    if (onePermission == *valid) {
       // This is a valid permission.
       permissions += " ";
       permissions += onePermission;
       return true;
-      }
     }
+  }
   // This is not a valid permission.
   return false;
 }
 
 cmInstallCommandIncludesArgument::cmInstallCommandIncludesArgument()
 {
-
 }
 
 const std::vector<std::string>&
@@ -216,19 +201,16 @@ cmInstallCommandIncludesArgument::GetIncludeDirs() const
 }
 
 void cmInstallCommandIncludesArgument::Parse(
-                                        const std::vector<std::string>* args,
-                                        std::vector<std::string>*)
+  const std::vector<std::string>* args, std::vector<std::string>*)
 {
-  if(args->empty())
-    {
+  if (args->empty()) {
     return;
-    }
+  }
   std::vector<std::string>::const_iterator it = args->begin();
   ++it;
-  for ( ; it != args->end(); ++it)
-    {
+  for (; it != args->end(); ++it) {
     std::string dir = *it;
     cmSystemTools::ConvertToUnixSlashes(dir);
     this->IncludeDirs.push_back(dir);
-    }
+  }
 }
diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h
index 90347e6..6ccb3e8 100644
--- a/Source/cmInstallCommandArguments.h
+++ b/Source/cmInstallCommandArguments.h
@@ -14,68 +14,73 @@
 #define cmInstallCommandArguments_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmCommandArgumentsHelper.h"
 
 class cmInstallCommandArguments
 {
-  public:
-    cmInstallCommandArguments(const std::string& defaultComponent);
-    void SetGenericArguments(cmInstallCommandArguments* args)
-                                               {this->GenericArguments = args;}
-    void Parse(const std::vector<std::string>* args,
-               std::vector<std::string>* unconsumedArgs);
-
-    // Compute destination path.and check permissions
-    bool Finalize();
-
-    const std::string& GetDestination() const;
-    const std::string& GetComponent() const;
-    const std::string& GetRename() const;
-    const std::string& GetPermissions() const;
-    const std::vector<std::string>& GetConfigurations() const;
-    bool GetOptional() const;
-    bool GetNamelinkOnly() const;
-    bool GetNamelinkSkip() const;
-
-    // once HandleDirectoryMode() is also switched to using
-    // cmInstallCommandArguments then these two functions can become non-static
-    // private member functions without arguments
-    static bool CheckPermissions(const std::string& onePerm,
-                                 std::string& perm);
-    cmCommandArgumentsHelper Parser;
-    cmCommandArgumentGroup ArgumentGroup;
-  private:
-    cmInstallCommandArguments(); // disabled
-    cmCAString Destination;
-    cmCAString Component;
-    cmCAString Rename;
-    cmCAStringVector Permissions;
-    cmCAStringVector Configurations;
-    cmCAEnabler Optional;
-    cmCAEnabler NamelinkOnly;
-    cmCAEnabler NamelinkSkip;
-
-    std::string DestinationString;
-    std::string PermissionsString;
-
-    cmInstallCommandArguments* GenericArguments;
-    static const char* PermissionsTable[];
-    static const std::string EmptyString;
-    std::string DefaultComponentName;
-    bool CheckPermissions();
+public:
+  cmInstallCommandArguments(const std::string& defaultComponent);
+  void SetGenericArguments(cmInstallCommandArguments* args)
+  {
+    this->GenericArguments = args;
+  }
+  void Parse(const std::vector<std::string>* args,
+             std::vector<std::string>* unconsumedArgs);
+
+  // Compute destination path.and check permissions
+  bool Finalize();
+
+  const std::string& GetDestination() const;
+  const std::string& GetComponent() const;
+  bool GetExcludeFromAll() const;
+  const std::string& GetRename() const;
+  const std::string& GetPermissions() const;
+  const std::vector<std::string>& GetConfigurations() const;
+  bool GetOptional() const;
+  bool GetNamelinkOnly() const;
+  bool GetNamelinkSkip() const;
+
+  // once HandleDirectoryMode() is also switched to using
+  // cmInstallCommandArguments then these two functions can become non-static
+  // private member functions without arguments
+  static bool CheckPermissions(const std::string& onePerm, std::string& perm);
+  cmCommandArgumentsHelper Parser;
+  cmCommandArgumentGroup ArgumentGroup;
+
+private:
+  cmInstallCommandArguments(); // disabled
+  cmCAString Destination;
+  cmCAString Component;
+  cmCAEnabler ExcludeFromAll;
+  cmCAString Rename;
+  cmCAStringVector Permissions;
+  cmCAStringVector Configurations;
+  cmCAEnabler Optional;
+  cmCAEnabler NamelinkOnly;
+  cmCAEnabler NamelinkSkip;
+
+  std::string DestinationString;
+  std::string PermissionsString;
+
+  cmInstallCommandArguments* GenericArguments;
+  static const char* PermissionsTable[];
+  static const std::string EmptyString;
+  std::string DefaultComponentName;
+  bool CheckPermissions();
 };
 
 class cmInstallCommandIncludesArgument
 {
-  public:
-    cmInstallCommandIncludesArgument();
-    void Parse(const std::vector<std::string>* args,
-               std::vector<std::string>* unconsumedArgs);
+public:
+  cmInstallCommandIncludesArgument();
+  void Parse(const std::vector<std::string>* args,
+             std::vector<std::string>* unconsumedArgs);
 
-    const std::vector<std::string>& GetIncludeDirs() const;
+  const std::vector<std::string>& GetIncludeDirs() const;
 
-  private:
-    std::vector<std::string> IncludeDirs;
+private:
+  std::vector<std::string> IncludeDirs;
 };
 
 #endif
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index f2e8609..671ab4c 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -14,43 +14,36 @@
 #include "cmGeneratorExpression.h"
 #include "cmLocalGenerator.h"
 
-//----------------------------------------------------------------------------
-cmInstallDirectoryGenerator
-::cmInstallDirectoryGenerator(std::vector<std::string> const& dirs,
-                              const char* dest,
-                              const char* file_permissions,
-                              const char* dir_permissions,
-                              std::vector<std::string> const& configurations,
-                              const char* component,
-                              MessageLevel message,
-                              const char* literal_args,
-                              bool optional):
-  cmInstallGenerator(dest, configurations, component, message),
-  LocalGenerator(0),
-  Directories(dirs),
-  FilePermissions(file_permissions), DirPermissions(dir_permissions),
-  LiteralArguments(literal_args), Optional(optional)
+cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
+  std::vector<std::string> const& dirs, const char* dest,
+  const char* file_permissions, const char* dir_permissions,
+  std::vector<std::string> const& configurations, const char* component,
+  MessageLevel message, bool exclude_from_all, const char* literal_args,
+  bool optional)
+  : cmInstallGenerator(dest, configurations, component, message,
+                       exclude_from_all)
+  , LocalGenerator(0)
+  , Directories(dirs)
+  , FilePermissions(file_permissions)
+  , DirPermissions(dir_permissions)
+  , LiteralArguments(literal_args)
+  , Optional(optional)
 {
   // We need per-config actions if destination have generator expressions.
-  if(cmGeneratorExpression::Find(Destination) != std::string::npos)
-    {
+  if (cmGeneratorExpression::Find(Destination) != std::string::npos) {
     this->ActionsPerConfig = true;
-    }
+  }
 
   // We need per-config actions if any directories have generator expressions.
-  for(std::vector<std::string>::const_iterator i = dirs.begin();
-      !this->ActionsPerConfig && i != dirs.end(); ++i)
-    {
-    if(cmGeneratorExpression::Find(*i) != std::string::npos)
-      {
+  for (std::vector<std::string>::const_iterator i = dirs.begin();
+       !this->ActionsPerConfig && i != dirs.end(); ++i) {
+    if (cmGeneratorExpression::Find(*i) != std::string::npos) {
       this->ActionsPerConfig = true;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmInstallDirectoryGenerator
-::~cmInstallDirectoryGenerator()
+cmInstallDirectoryGenerator::~cmInstallDirectoryGenerator()
 {
 }
 
@@ -59,62 +52,46 @@ void cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg)
   LocalGenerator = lg;
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
-                                                   Indent const& indent)
+void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
+                                                        Indent const& indent)
 {
-  if(this->ActionsPerConfig)
-    {
+  if (this->ActionsPerConfig) {
     this->cmInstallGenerator::GenerateScriptActions(os, indent);
-    }
-  else
-    {
+  } else {
     this->AddDirectoryInstallRule(os, "", indent, this->Directories);
-    }
+  }
 }
 
 void cmInstallDirectoryGenerator::GenerateScriptForConfig(
-  std::ostream& os,
-  const std::string& config,
-  Indent const& indent)
+  std::ostream& os, const std::string& config, Indent const& indent)
 {
   std::vector<std::string> dirs;
   cmGeneratorExpression ge;
-  for(std::vector<std::string>::const_iterator i = this->Directories.begin();
-      i != this->Directories.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = this->Directories.begin();
+       i != this->Directories.end(); ++i) {
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
-    cmSystemTools::ExpandListArgument(cge->Evaluate(
-        this->LocalGenerator, config), dirs);
-    }
+    cmSystemTools::ExpandListArgument(
+      cge->Evaluate(this->LocalGenerator, config), dirs);
+  }
   this->AddDirectoryInstallRule(os, config, indent, dirs);
 }
 
 void cmInstallDirectoryGenerator::AddDirectoryInstallRule(
-  std::ostream& os,
-  const std::string& config,
-  Indent const& indent,
+  std::ostream& os, const std::string& config, Indent const& indent,
   std::vector<std::string> const& dirs)
 {
   // Write code to install the directories.
   const char* no_rename = 0;
-  this->AddInstallRule(os,
-                       this->GetDestination(config),
-                       cmInstallType_DIRECTORY,
-                       dirs,
-                       this->Optional,
+  this->AddInstallRule(os, this->GetDestination(config),
+                       cmInstallType_DIRECTORY, dirs, this->Optional,
                        this->FilePermissions.c_str(),
-                       this->DirPermissions.c_str(),
-                       no_rename, this->LiteralArguments.c_str(),
-                       indent);
+                       this->DirPermissions.c_str(), no_rename,
+                       this->LiteralArguments.c_str(), indent);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallDirectoryGenerator::GetDestination(std::string const& config) const
+std::string cmInstallDirectoryGenerator::GetDestination(
+  std::string const& config) const
 {
   cmGeneratorExpression ge;
-  return ge.Parse(this->Destination)
-    ->Evaluate(this->LocalGenerator, config);
+  return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config);
 }
diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h
index 9b732d3..10d7c95 100644
--- a/Source/cmInstallDirectoryGenerator.h
+++ b/Source/cmInstallDirectoryGenerator.h
@@ -17,17 +17,15 @@
 /** \class cmInstallDirectoryGenerator
  * \brief Generate directory installation rules.
  */
-class cmInstallDirectoryGenerator: public cmInstallGenerator
+class cmInstallDirectoryGenerator : public cmInstallGenerator
 {
 public:
   cmInstallDirectoryGenerator(std::vector<std::string> const& dirs,
-                              const char* dest,
-                              const char* file_permissions,
+                              const char* dest, const char* file_permissions,
                               const char* dir_permissions,
                               std::vector<std::string> const& configurations,
-                              const char* component,
-                              MessageLevel message,
-                              const char* literal_args,
+                              const char* component, MessageLevel message,
+                              bool exclude_from_all, const char* literal_args,
                               bool optional = false);
   virtual ~cmInstallDirectoryGenerator();
 
@@ -40,8 +38,7 @@ protected:
   virtual void GenerateScriptForConfig(std::ostream& os,
                                        const std::string& config,
                                        Indent const& indent);
-  void AddDirectoryInstallRule(std::ostream& os,
-                               const std::string& config,
+  void AddDirectoryInstallRule(std::ostream& os, const std::string& config,
                                Indent const& indent,
                                std::vector<std::string> const& dirs);
   cmLocalGenerator* LocalGenerator;
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 9570ba3..2fef3a8 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -13,41 +13,36 @@
 
 #include <stdio.h>
 
-#include "cmake.h"
-#include "cmInstallTargetGenerator.h"
 #include "cmGeneratedFileStream.h"
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
 #include "cmGlobalGenerator.h"
+#include "cmInstallTargetGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmake.h"
 
 #include "cmInstallFilesGenerator.h"
 
 #include "cmExportInstallFileGenerator.h"
 #include "cmExportSet.h"
 
-//----------------------------------------------------------------------------
 cmInstallExportGenerator::cmInstallExportGenerator(
-  cmExportSet* exportSet,
-  const char* destination,
-  const char* file_permissions,
-  std::vector<std::string> const& configurations,
-  const char* component,
-  MessageLevel message,
-  const char* filename, const char* name_space,
-  bool exportOld)
-  :cmInstallGenerator(destination, configurations, component, message)
-  ,ExportSet(exportSet)
-  ,FilePermissions(file_permissions)
-  ,FileName(filename)
-  ,Namespace(name_space)
-  ,ExportOld(exportOld)
-  ,LocalGenerator(0)
+  cmExportSet* exportSet, const char* destination,
+  const char* file_permissions, std::vector<std::string> const& configurations,
+  const char* component, MessageLevel message, bool exclude_from_all,
+  const char* filename, const char* name_space, bool exportOld)
+  : cmInstallGenerator(destination, configurations, component, message,
+                       exclude_from_all)
+  , ExportSet(exportSet)
+  , FilePermissions(file_permissions)
+  , FileName(filename)
+  , Namespace(name_space)
+  , ExportOld(exportOld)
+  , LocalGenerator(0)
 {
   this->EFGen = new cmExportInstallFileGenerator(this);
   exportSet->AddInstallation(this);
 }
 
-//----------------------------------------------------------------------------
 cmInstallExportGenerator::~cmInstallExportGenerator()
 {
   delete this->EFGen;
@@ -59,23 +54,18 @@ void cmInstallExportGenerator::Compute(cmLocalGenerator* lg)
   this->ExportSet->Compute(lg);
 }
 
-//----------------------------------------------------------------------------
 void cmInstallExportGenerator::ComputeTempDir()
 {
   // Choose a temporary directory in which to generate the import
   // files to be installed.
-  this->TempDir =
-      this->LocalGenerator->GetCurrentBinaryDirectory();
+  this->TempDir = this->LocalGenerator->GetCurrentBinaryDirectory();
   this->TempDir += cmake::GetCMakeFilesDirectory();
   this->TempDir += "/Export";
-  if(this->Destination.empty())
-    {
+  if (this->Destination.empty()) {
     return;
-    }
-  else
-    {
+  } else {
     this->TempDir += "/";
-    }
+  }
 
   // Enforce a maximum length.
   bool useMD5 = false;
@@ -84,55 +74,44 @@ void cmInstallExportGenerator::ComputeTempDir()
 #else
   std::string::size_type const max_total_len = 1000;
 #endif
-  if(this->TempDir.size() < max_total_len)
-    {
+  if (this->TempDir.size() < max_total_len) {
     // Keep the total path length below the limit.
     std::string::size_type max_len = max_total_len - this->TempDir.size();
-    if(this->Destination.size() > max_len)
-      {
+    if (this->Destination.size() > max_len) {
       useMD5 = true;
-      }
     }
-  else
-    {
+  } else {
     useMD5 = true;
-    }
-  if(useMD5)
-    {
+  }
+  if (useMD5) {
     // Replace the destination path with a hash to keep it short.
-    this->TempDir +=
-      cmSystemTools::ComputeStringMD5(this->Destination);
-    }
-  else
-    {
+    this->TempDir += cmSystemTools::ComputeStringMD5(this->Destination);
+  } else {
     std::string dest = this->Destination;
     // Avoid unix full paths.
-    if(dest[0] == '/')
-      {
+    if (dest[0] == '/') {
       dest[0] = '_';
-      }
+    }
     // Avoid windows full paths by removing colons.
-    cmSystemTools::ReplaceString(dest, ":", "_");
+    std::replace(dest.begin(), dest.end(), ':', '_');
     // Avoid relative paths that go up the tree.
     cmSystemTools::ReplaceString(dest, "../", "__/");
     // Avoid spaces.
-    cmSystemTools::ReplaceString(dest, " ", "_");
+    std::replace(dest.begin(), dest.end(), ' ', '_');
     this->TempDir += dest;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmInstallExportGenerator::GenerateScript(std::ostream& os)
 {
   // Skip empty sets.
-  if(ExportSet->GetTargetExports()->empty())
-    {
+  if (ExportSet->GetTargetExports()->empty()) {
     std::ostringstream e;
-    e << "INSTALL(EXPORT) given unknown export \""
-      << ExportSet->GetName() << "\"";
+    e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
+      << "\"";
     cmSystemTools::Error(e.str().c_str());
     return;
-    }
+  }
 
   // Create the temporary directory in which to store the files.
   this->ComputeTempDir();
@@ -147,36 +126,27 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
   this->EFGen->SetExportFile(this->MainImportFile.c_str());
   this->EFGen->SetNamespace(this->Namespace);
   this->EFGen->SetExportOld(this->ExportOld);
-  if(this->ConfigurationTypes->empty())
-    {
-    if(!this->ConfigurationName.empty())
-      {
+  if (this->ConfigurationTypes->empty()) {
+    if (!this->ConfigurationName.empty()) {
       this->EFGen->AddConfiguration(this->ConfigurationName);
-      }
-    else
-      {
+    } else {
       this->EFGen->AddConfiguration("");
-      }
     }
-  else
-    {
-    for(std::vector<std::string>::const_iterator
-          ci = this->ConfigurationTypes->begin();
-        ci != this->ConfigurationTypes->end(); ++ci)
-      {
+  } else {
+    for (std::vector<std::string>::const_iterator ci =
+           this->ConfigurationTypes->begin();
+         ci != this->ConfigurationTypes->end(); ++ci) {
       this->EFGen->AddConfiguration(*ci);
-      }
     }
+  }
   this->EFGen->GenerateImportFile();
 
   // Perform the main install script generation.
   this->cmInstallGenerator::GenerateScript(os);
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
-                                                Indent const& indent)
+void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
+                                                     Indent const& indent)
 {
   // Create the main install rules first.
   this->cmInstallGenerator::GenerateScriptConfigs(os, indent);
@@ -184,23 +154,20 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
   // Now create a configuration-specific install rule for the import
   // file of each configuration.
   std::vector<std::string> files;
-  for(std::map<std::string, std::string>::const_iterator
-        i = this->EFGen->GetConfigImportFiles().begin();
-      i != this->EFGen->GetConfigImportFiles().end(); ++i)
-    {
+  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);
     os << indent << "if(" << config_test << ")\n";
-    this->AddInstallRule(os, this->Destination,
-                         cmInstallType_FILES, files, false,
-                         this->FilePermissions.c_str(), 0, 0, 0,
+    this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
+                         false, this->FilePermissions.c_str(), 0, 0, 0,
                          indent.Next());
     os << indent << "endif()\n";
     files.clear();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
                                                      Indent const& indent)
 {
@@ -214,6 +181,7 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
   Indent indentN = indent.Next();
   Indent indentNN = indentN.Next();
   Indent indentNNN = indentNN.Next();
+  /* clang-format off */
   os << indentN << "file(DIFFERENT EXPORT_FILE_CHANGED FILES\n"
      << indentN << "     \"" << installedFile << "\"\n"
      << indentN << "     \"" << this->MainImportFile << "\")\n";
@@ -227,11 +195,11 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
   os << indentNN << "endif()\n";
   os << indentN << "endif()\n";
   os << indent << "endif()\n";
+  /* clang-format on */
 
   // Install the main export file.
   std::vector<std::string> files;
   files.push_back(this->MainImportFile);
-  this->AddInstallRule(os, this->Destination,
-                       cmInstallType_FILES, files, false,
-                       this->FilePermissions.c_str(), 0, 0, 0, indent);
+  this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
+                       false, this->FilePermissions.c_str(), 0, 0, 0, indent);
 }
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index 885ed05..256c0c9 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -23,19 +23,18 @@ class cmMakefile;
 /** \class cmInstallExportGenerator
  * \brief Generate rules for creating an export files.
  */
-class cmInstallExportGenerator: public cmInstallGenerator
+class cmInstallExportGenerator : public cmInstallGenerator
 {
 public:
-  cmInstallExportGenerator(cmExportSet* exportSet,
-                           const char* dest, const char* file_permissions,
+  cmInstallExportGenerator(cmExportSet* exportSet, const char* dest,
+                           const char* file_permissions,
                            const std::vector<std::string>& configurations,
-                           const char* component,
-                           MessageLevel message,
-                           const char* filename, const char* name_space,
-                           bool exportOld);
+                           const char* component, MessageLevel message,
+                           bool exclude_from_all, const char* filename,
+                           const char* name_space, bool exportOld);
   ~cmInstallExportGenerator();
 
-  cmExportSet* GetExportSet() {return this->ExportSet;}
+  cmExportSet* GetExportSet() { return this->ExportSet; }
 
   void Compute(cmLocalGenerator* lg);
 
@@ -43,8 +42,7 @@ public:
 
   const std::string& GetNamespace() const { return this->Namespace; }
 
-  std::string const& GetDestination() const
-    { return this->Destination; }
+  std::string const& GetDestination() const { return this->Destination; }
 
 protected:
   virtual void GenerateScript(std::ostream& os);
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 68557bd..64efe61 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -14,42 +14,36 @@
 #include "cmInstallFilesGenerator.h"
 
 // cmExecutableCommand
-bool cmInstallFilesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& args,
+                                        cmExecutionStatus&)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Enable the install target.
   this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
 
   this->Destination = args[0];
 
-  if((args.size() > 1) && (args[1] == "FILES"))
-    {
+  if ((args.size() > 1) && (args[1] == "FILES")) {
     this->IsFilesForm = true;
-    for(std::vector<std::string>::const_iterator s = args.begin()+2;
-        s != args.end(); ++s)
-      {
+    for (std::vector<std::string>::const_iterator s = args.begin() + 2;
+         s != args.end(); ++s) {
       // Find the source location for each file listed.
       std::string f = this->FindInstallSource(s->c_str());
       this->Files.push_back(f);
-      }
-    this->CreateInstallGenerator();
     }
-  else
-    {
+    this->CreateInstallGenerator();
+  } else {
     this->IsFilesForm = false;
-    this->FinalArgs.insert(this->FinalArgs.end(),
-                           args.begin() + 1, args.end());
-    }
+    this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1,
+                           args.end());
+  }
 
-  this->Makefile->GetGlobalGenerator()
-                      ->AddInstallComponent(this->Makefile->GetSafeDefinition(
-                                      "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+  this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+    this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
 
   return true;
 }
@@ -57,53 +51,45 @@ bool cmInstallFilesCommand
 void cmInstallFilesCommand::FinalPass()
 {
   // No final pass for "FILES" form of arguments.
-  if(this->IsFilesForm)
-    {
+  if (this->IsFilesForm) {
     return;
-    }
+  }
 
   std::string testf;
   std::string ext = this->FinalArgs[0];
 
   // two different options
-  if (this->FinalArgs.size() > 1)
-    {
+  if (this->FinalArgs.size() > 1) {
     // now put the files into the list
     std::vector<std::string>::iterator s = this->FinalArgs.begin();
     ++s;
     // for each argument, get the files
-    for (;s != this->FinalArgs.end(); ++s)
-      {
+    for (; s != this->FinalArgs.end(); ++s) {
       // replace any variables
       std::string temps = *s;
-      if (!cmSystemTools::GetFilenamePath(temps).empty())
-        {
-          testf = cmSystemTools::GetFilenamePath(temps) + "/" +
-            cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
-        }
-      else
-        {
-          testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
-        }
+      if (!cmSystemTools::GetFilenamePath(temps).empty()) {
+        testf = cmSystemTools::GetFilenamePath(temps) + "/" +
+          cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
+      } else {
+        testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
+      }
 
       // add to the result
       this->Files.push_back(this->FindInstallSource(testf.c_str()));
-      }
     }
-  else     // reg exp list
-    {
+  } else // reg exp list
+  {
     std::vector<std::string> files;
     std::string regex = this->FinalArgs[0];
-    cmSystemTools::Glob(this->Makefile->GetCurrentSourceDirectory(),
-                        regex, files);
+    cmSystemTools::Glob(this->Makefile->GetCurrentSourceDirectory(), regex,
+                        files);
 
     std::vector<std::string>::iterator s = files.begin();
     // for each argument, get the files
-    for (;s != files.end(); ++s)
-      {
+    for (; s != files.end(); ++s) {
       this->Files.push_back(this->FindInstallSource(s->c_str()));
-      }
     }
+  }
 
   this->CreateInstallGenerator();
 }
@@ -114,27 +100,24 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
   // the prefix.  We skip the leading slash given by the user.
   std::string destination = this->Destination.substr(1);
   cmSystemTools::ConvertToUnixSlashes(destination);
-  if(destination.empty())
-    {
+  if (destination.empty()) {
     destination = ".";
-    }
+  }
 
   // Use a file install generator.
   const char* no_permissions = "";
   const char* no_rename = "";
-  std::string no_component = this->Makefile->GetSafeDefinition(
-                                       "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
+  bool no_exclude_from_all = false;
+  std::string no_component =
+    this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
   std::vector<std::string> no_configurations;
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(this->Makefile);
-  this->Makefile->AddInstallGenerator(
-    new cmInstallFilesGenerator(this->Files,
-                                destination.c_str(), false,
-                                no_permissions, no_configurations,
-                                no_component.c_str(), message, no_rename));
+  this->Makefile->AddInstallGenerator(new cmInstallFilesGenerator(
+    this->Files, destination.c_str(), false, no_permissions, no_configurations,
+    no_component.c_str(), message, no_exclude_from_all, no_rename));
 }
 
-
 /**
  * Find a file in the build or source tree for installation given a
  * relative path from the CMakeLists.txt file.  This will favor files
@@ -143,12 +126,11 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
  */
 std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
 {
-  if(cmSystemTools::FileIsFullPath(name) ||
-     cmGeneratorExpression::Find(name) == 0)
-    {
+  if (cmSystemTools::FileIsFullPath(name) ||
+      cmGeneratorExpression::Find(name) == 0) {
     // This is a full path.
     return name;
-    }
+  }
 
   // This is a relative path.
   std::string tb = this->Makefile->GetCurrentBinaryDirectory();
@@ -158,20 +140,15 @@ std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
   ts += "/";
   ts += name;
 
-  if(cmSystemTools::FileExists(tb.c_str()))
-    {
+  if (cmSystemTools::FileExists(tb.c_str())) {
     // The file exists in the binary tree.  Use it.
     return tb;
-    }
-  else if(cmSystemTools::FileExists(ts.c_str()))
-    {
+  } else if (cmSystemTools::FileExists(ts.c_str())) {
     // The file exists in the source tree.  Use it.
     return ts;
-    }
-  else
-    {
+  } else {
     // The file doesn't exist.  Assume it will be present in the
     // binary tree when the install occurs.
     return tb;
-    }
+  }
 }
diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h
index 8062d11..0d0388a 100644
--- a/Source/cmInstallFilesCommand.h
+++ b/Source/cmInstallFilesCommand.h
@@ -26,22 +26,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmInstallFilesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmInstallFilesCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "install_files";}
+  virtual std::string GetName() const { return "install_files"; }
 
   /**
    * This is called at the end after all the information
@@ -58,12 +55,11 @@ protected:
   void CreateInstallGenerator() const;
   std::string FindInstallSource(const char* name) const;
 
- private:
+private:
   std::vector<std::string> FinalArgs;
   bool IsFilesForm;
   std::string Destination;
   std::vector<std::string> Files;
 };
 
-
 #endif
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 383031b..8c1b357 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -12,48 +12,39 @@
 #include "cmInstallFilesGenerator.h"
 
 #include "cmGeneratorExpression.h"
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
-#include "cmLocalGenerator.h"
 
-//----------------------------------------------------------------------------
-cmInstallFilesGenerator
-::cmInstallFilesGenerator(std::vector<std::string> const& files,
-                          const char* dest, bool programs,
-                          const char* file_permissions,
-                          std::vector<std::string> const& configurations,
-                          const char* component,
-                          MessageLevel message,
-                          const char* rename,
-                          bool optional):
-  cmInstallGenerator(dest, configurations, component, message),
-  LocalGenerator(0),
-  Files(files),
-  FilePermissions(file_permissions),
-  Rename(rename),
-  Programs(programs),
-  Optional(optional)
+cmInstallFilesGenerator::cmInstallFilesGenerator(
+  std::vector<std::string> const& files, const char* dest, bool programs,
+  const char* file_permissions, std::vector<std::string> const& configurations,
+  const char* component, MessageLevel message, bool exclude_from_all,
+  const char* rename, bool optional)
+  : cmInstallGenerator(dest, configurations, component, message,
+                       exclude_from_all)
+  , LocalGenerator(0)
+  , Files(files)
+  , FilePermissions(file_permissions)
+  , Rename(rename)
+  , Programs(programs)
+  , Optional(optional)
 {
   // We need per-config actions if the destination has generator expressions.
-  if(cmGeneratorExpression::Find(Destination) != std::string::npos)
-    {
+  if (cmGeneratorExpression::Find(Destination) != std::string::npos) {
     this->ActionsPerConfig = true;
-    }
+  }
 
   // We need per-config actions if any files have generator expressions.
-  for(std::vector<std::string>::const_iterator i = files.begin();
-      !this->ActionsPerConfig && i != files.end(); ++i)
-    {
-    if(cmGeneratorExpression::Find(*i) != std::string::npos)
-      {
+  for (std::vector<std::string>::const_iterator i = files.begin();
+       !this->ActionsPerConfig && i != files.end(); ++i) {
+    if (cmGeneratorExpression::Find(*i) != std::string::npos) {
       this->ActionsPerConfig = true;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmInstallFilesGenerator
-::~cmInstallFilesGenerator()
+cmInstallFilesGenerator::~cmInstallFilesGenerator()
 {
 }
 
@@ -62,62 +53,46 @@ void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg)
   this->LocalGenerator = lg;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallFilesGenerator::GetDestination(std::string const& config) const
+std::string cmInstallFilesGenerator::GetDestination(
+  std::string const& config) const
 {
   cmGeneratorExpression ge;
-  return ge.Parse(this->Destination)
-    ->Evaluate(this->LocalGenerator, config);
+  return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config);
 }
 
-//----------------------------------------------------------------------------
 void cmInstallFilesGenerator::AddFilesInstallRule(
-  std::ostream& os,
-  const std::string config,
-  Indent const& indent,
+  std::ostream& os, std::string const& config, Indent const& indent,
   std::vector<std::string> const& files)
 {
   // Write code to install the files.
   const char* no_dir_permissions = 0;
-  this->AddInstallRule(os,
-                       this->GetDestination(config),
-                       (this->Programs
-                        ? cmInstallType_PROGRAMS
-                        : cmInstallType_FILES),
-                       files,
-                       this->Optional,
-                       this->FilePermissions.c_str(), no_dir_permissions,
-                       this->Rename.c_str(), 0, indent);
+  this->AddInstallRule(
+    os, this->GetDestination(config),
+    (this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), files,
+    this->Optional, this->FilePermissions.c_str(), no_dir_permissions,
+    this->Rename.c_str(), 0, indent);
 }
 
-//----------------------------------------------------------------------------
 void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
                                                     Indent const& indent)
 {
-  if(this->ActionsPerConfig)
-    {
+  if (this->ActionsPerConfig) {
     this->cmInstallGenerator::GenerateScriptActions(os, indent);
-    }
-  else
-    {
+  } else {
     this->AddFilesInstallRule(os, "", indent, this->Files);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
-                                                    const std::string& config,
-                                                    Indent const& indent)
+void cmInstallFilesGenerator::GenerateScriptForConfig(
+  std::ostream& os, const std::string& config, Indent const& indent)
 {
   std::vector<std::string> files;
   cmGeneratorExpression ge;
-  for(std::vector<std::string>::const_iterator i = this->Files.begin();
-      i != this->Files.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = this->Files.begin();
+       i != this->Files.end(); ++i) {
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
-    cmSystemTools::ExpandListArgument(cge->Evaluate(
-        this->LocalGenerator, config), files);
-    }
+    cmSystemTools::ExpandListArgument(
+      cge->Evaluate(this->LocalGenerator, config), files);
+  }
   this->AddFilesInstallRule(os, config, indent, files);
 }
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index bfe4039..0e738d3 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -17,16 +17,15 @@
 /** \class cmInstallFilesGenerator
  * \brief Generate file installation rules.
  */
-class cmInstallFilesGenerator: public cmInstallGenerator
+class cmInstallFilesGenerator : public cmInstallGenerator
 {
 public:
   cmInstallFilesGenerator(std::vector<std::string> const& files,
                           const char* dest, bool programs,
                           const char* file_permissions,
                           std::vector<std::string> const& configurations,
-                          const char* component,
-                          MessageLevel message,
-                          const char* rename,
+                          const char* component, MessageLevel message,
+                          bool exclude_from_all, const char* rename,
                           bool optional = false);
   virtual ~cmInstallFilesGenerator();
 
@@ -39,8 +38,7 @@ protected:
   virtual void GenerateScriptForConfig(std::ostream& os,
                                        const std::string& config,
                                        Indent const& indent);
-  void AddFilesInstallRule(std::ostream& os,
-                           const std::string config,
+  void AddFilesInstallRule(std::ostream& os, std::string const& config,
                            Indent const& indent,
                            std::vector<std::string> const& files);
 
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index 2e1c5f0..e3d5bad 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -14,148 +14,139 @@
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
 
-//----------------------------------------------------------------------------
-cmInstallGenerator
-::cmInstallGenerator(const char* destination,
-                     std::vector<std::string> const& configurations,
-                     const char* component,
-                     MessageLevel message):
-  cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations),
-  Destination(destination? destination:""),
-  Component(component? component:""),
-  Message(message)
+cmInstallGenerator::cmInstallGenerator(
+  const char* destination, std::vector<std::string> const& configurations,
+  const char* component, MessageLevel message, bool exclude_from_all)
+  : cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations)
+  , Destination(destination ? destination : "")
+  , Component(component ? component : "")
+  , Message(message)
+  , ExcludeFromAll(exclude_from_all)
 {
 }
 
-//----------------------------------------------------------------------------
-cmInstallGenerator
-::~cmInstallGenerator()
+cmInstallGenerator::~cmInstallGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
-void cmInstallGenerator
-::AddInstallRule(
-                 std::ostream& os,
-                 std::string const& dest,
-                 cmInstallType type,
-                 std::vector<std::string> const& files,
-                 bool optional /* = false */,
-                 const char* permissions_file /* = 0 */,
-                 const char* permissions_dir /* = 0 */,
-                 const char* rename /* = 0 */,
-                 const char* literal_args /* = 0 */,
-                 Indent const& indent
-                 )
+void cmInstallGenerator::AddInstallRule(
+  std::ostream& os, std::string const& dest, cmInstallType type,
+  std::vector<std::string> const& files, bool optional /* = false */,
+  const char* permissions_file /* = 0 */,
+  const char* permissions_dir /* = 0 */, const char* rename /* = 0 */,
+  const char* literal_args /* = 0 */, Indent const& indent)
 {
   // Use the FILE command to install the file.
   std::string stype;
-  switch(type)
-    {
-    case cmInstallType_DIRECTORY:      stype = "DIRECTORY"; break;
-    case cmInstallType_PROGRAMS:       stype = "PROGRAM"; break;
-    case cmInstallType_EXECUTABLE:     stype = "EXECUTABLE"; break;
-    case cmInstallType_STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break;
-    case cmInstallType_SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break;
-    case cmInstallType_MODULE_LIBRARY: stype = "MODULE"; break;
-    case cmInstallType_FILES:          stype = "FILE"; break;
-    }
+  switch (type) {
+    case cmInstallType_DIRECTORY:
+      stype = "DIRECTORY";
+      break;
+    case cmInstallType_PROGRAMS:
+      stype = "PROGRAM";
+      break;
+    case cmInstallType_EXECUTABLE:
+      stype = "EXECUTABLE";
+      break;
+    case cmInstallType_STATIC_LIBRARY:
+      stype = "STATIC_LIBRARY";
+      break;
+    case cmInstallType_SHARED_LIBRARY:
+      stype = "SHARED_LIBRARY";
+      break;
+    case cmInstallType_MODULE_LIBRARY:
+      stype = "MODULE";
+      break;
+    case cmInstallType_FILES:
+      stype = "FILE";
+      break;
+  }
   os << indent;
-  if (cmSystemTools::FileIsFullPath(dest.c_str()))
-     {
-     os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n";
-     os << indent << " \"";
-     for(std::vector<std::string>::const_iterator fi = files.begin();
-               fi != files.end(); ++fi)
-             {
-               if (fi!=files.begin())
-                 {
-                 os << ";";
-                 }
-               os << dest << "/";
-               if (rename && *rename)
-                 {
-                 os << rename;
-                 }
-               else
-                 {
-                 os << cmSystemTools::GetFilenameName(*fi);
-                 }
-             }
-     os << "\")\n";
-     os << indent << "if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n";
-     os << indent << indent << "message(WARNING \"ABSOLUTE path INSTALL "
-        << "DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
-     os << indent << "endif()\n";
+  if (cmSystemTools::FileIsFullPath(dest.c_str())) {
+    os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n";
+    os << indent << " \"";
+    for (std::vector<std::string>::const_iterator fi = files.begin();
+         fi != files.end(); ++fi) {
+      if (fi != files.begin()) {
+        os << ";";
+      }
+      os << dest << "/";
+      if (rename && *rename) {
+        os << rename;
+      } else {
+        os << cmSystemTools::GetFilenameName(*fi);
+      }
+    }
+    os << "\")\n";
+    os << indent << "if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n";
+    os << indent << indent << "message(WARNING \"ABSOLUTE path INSTALL "
+       << "DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
+    os << indent << "endif()\n";
 
-     os << indent << "if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n";
-     os << indent << indent << "message(FATAL_ERROR \"ABSOLUTE path INSTALL "
-        << "DESTINATION forbidden (by caller): "
-        << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
-     os << indent << "endif()\n";
-     }
+    os << indent << "if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n";
+    os << indent << indent << "message(FATAL_ERROR \"ABSOLUTE path INSTALL "
+       << "DESTINATION forbidden (by caller): "
+       << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
+    os << indent << "endif()\n";
+  }
   std::string absDest = this->ConvertToAbsoluteDestination(dest);
   os << "file(INSTALL DESTINATION \"" << absDest << "\" TYPE " << stype;
-  if(optional)
-    {
+  if (optional) {
     os << " OPTIONAL";
-    }
-  switch(this->Message)
-    {
-    case MessageDefault: break;
-    case MessageAlways: os << " MESSAGE_ALWAYS"; break;
-    case MessageLazy:   os << " MESSAGE_LAZY"; break;
-    case MessageNever:  os << " MESSAGE_NEVER"; break;
-    }
-  if(permissions_file && *permissions_file)
-    {
+  }
+  switch (this->Message) {
+    case MessageDefault:
+      break;
+    case MessageAlways:
+      os << " MESSAGE_ALWAYS";
+      break;
+    case MessageLazy:
+      os << " MESSAGE_LAZY";
+      break;
+    case MessageNever:
+      os << " MESSAGE_NEVER";
+      break;
+  }
+  if (permissions_file && *permissions_file) {
     os << " PERMISSIONS" << permissions_file;
-    }
-  if(permissions_dir && *permissions_dir)
-    {
+  }
+  if (permissions_dir && *permissions_dir) {
     os << " DIR_PERMISSIONS" << permissions_dir;
-    }
-  if(rename && *rename)
-    {
+  }
+  if (rename && *rename) {
     os << " RENAME \"" << rename << "\"";
-    }
+  }
   os << " FILES";
-  if(files.size() == 1)
-    {
+  if (files.size() == 1) {
     os << " \"" << files[0] << "\"";
-    }
-  else
-    {
-    for(std::vector<std::string>::const_iterator fi = files.begin();
-        fi != files.end(); ++fi)
-      {
+  } else {
+    for (std::vector<std::string>::const_iterator fi = files.begin();
+         fi != files.end(); ++fi) {
       os << "\n" << indent << "  \"" << *fi << "\"";
-      }
+    }
     os << "\n" << indent << " ";
-    if(!(literal_args && *literal_args))
-      {
+    if (!(literal_args && *literal_args)) {
       os << " ";
-      }
     }
-  if(literal_args && *literal_args)
-    {
+  }
+  if (literal_args && *literal_args) {
     os << literal_args;
-    }
+  }
   os << ")\n";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallGenerator::CreateComponentTest(const char* component)
+std::string cmInstallGenerator::CreateComponentTest(const char* component,
+                                                    bool exclude_from_all)
 {
-  std::string result = "NOT CMAKE_INSTALL_COMPONENT OR "
-    "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \"";
+  std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \"";
   result += component;
   result += "\"";
+  if (!exclude_from_all) {
+    result += " OR NOT CMAKE_INSTALL_COMPONENT";
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 void cmInstallGenerator::GenerateScript(std::ostream& os)
 {
   // Track indentation.
@@ -163,7 +154,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
 
   // Begin this block of installation.
   std::string component_test =
-    this->CreateComponentTest(this->Component.c_str());
+    this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
   os << indent << "if(" << component_test << ")\n";
 
   // Generate the script possibly with per-configuration code.
@@ -173,46 +164,37 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
   os << indent << "endif()\n\n";
 }
 
-//----------------------------------------------------------------------------
 bool cmInstallGenerator::InstallsForConfig(const std::string& config)
 {
   return this->GeneratesForConfig(config);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallGenerator::ConvertToAbsoluteDestination(std::string const& dest) const
+std::string cmInstallGenerator::ConvertToAbsoluteDestination(
+  std::string const& dest) const
 {
   std::string result;
-  if(!dest.empty() &&
-     !cmSystemTools::FileIsFullPath(dest.c_str()))
-    {
+  if (!dest.empty() && !cmSystemTools::FileIsFullPath(dest.c_str())) {
     result = "${CMAKE_INSTALL_PREFIX}/";
-    }
+  }
   result += dest;
   return result;
 }
 
-//----------------------------------------------------------------------------
-cmInstallGenerator::MessageLevel
-cmInstallGenerator::SelectMessageLevel(cmMakefile* mf, bool never)
+cmInstallGenerator::MessageLevel cmInstallGenerator::SelectMessageLevel(
+  cmMakefile* mf, bool never)
 {
-  if(never)
-    {
+  if (never) {
     return MessageNever;
-    }
+  }
   std::string m = mf->GetSafeDefinition("CMAKE_INSTALL_MESSAGE");
-  if(m == "ALWAYS")
-    {
+  if (m == "ALWAYS") {
     return MessageAlways;
-    }
-  if(m == "LAZY")
-    {
+  }
+  if (m == "LAZY") {
     return MessageLazy;
-    }
-  if(m == "NEVER")
-    {
+  }
+  if (m == "NEVER") {
     return MessageNever;
-    }
+  }
   return MessageDefault;
 }
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index b8e5b53..e271d53 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -22,7 +22,7 @@ class cmMakefile;
  * \brief Support class for generating install scripts.
  *
  */
-class cmInstallGenerator: public cmScriptGenerator
+class cmInstallGenerator : public cmScriptGenerator
 {
 public:
   enum MessageLevel
@@ -35,22 +35,17 @@ public:
 
   cmInstallGenerator(const char* destination,
                      std::vector<std::string> const& configurations,
-                     const char* component,
-                     MessageLevel message);
+                     const char* component, MessageLevel message,
+                     bool exclude_from_all);
   virtual ~cmInstallGenerator();
 
-  void AddInstallRule(
-    std::ostream& os,
-    std::string const& dest,
-    cmInstallType type,
-    std::vector<std::string> const& files,
-    bool optional = false,
-    const char* permissions_file = 0,
-    const char* permissions_dir = 0,
-    const char* rename = 0,
-    const char* literal_args = 0,
-    Indent const& indent = Indent()
-    );
+  void AddInstallRule(std::ostream& os, std::string const& dest,
+                      cmInstallType type,
+                      std::vector<std::string> const& files,
+                      bool optional = false, const char* permissions_file = 0,
+                      const char* permissions_dir = 0, const char* rename = 0,
+                      const char* literal_args = 0,
+                      Indent const& indent = Indent());
 
   /** Get the install destination as it should appear in the
       installation script.  */
@@ -67,12 +62,14 @@ public:
 protected:
   virtual void GenerateScript(std::ostream& os);
 
-  std::string CreateComponentTest(const char* component);
+  std::string CreateComponentTest(const char* component,
+                                  bool exclude_from_all);
 
   // Information shared by most generator types.
   std::string Destination;
   std::string Component;
   MessageLevel Message;
+  bool ExcludeFromAll;
 };
 
 #endif
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index e6fbe88..2e5fc1f 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -10,16 +10,16 @@
   See the License for more information.
 ============================================================================*/
 #include "cmInstallProgramsCommand.h"
+
 #include "cmInstallFilesGenerator.h"
 // cmExecutableCommand
-bool cmInstallProgramsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmInstallProgramsCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Enable the install target.
   this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
@@ -28,9 +28,8 @@ bool cmInstallProgramsCommand
 
   this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1, args.end());
 
-  this->Makefile->GetGlobalGenerator()
-                       ->AddInstallComponent(this->Makefile->GetSafeDefinition(
-                                      "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+  this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+    this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
 
   return true;
 }
@@ -38,63 +37,55 @@ bool cmInstallProgramsCommand
 void cmInstallProgramsCommand::FinalPass()
 {
   bool files_mode = false;
-  if(!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES")
-    {
+  if (!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES") {
     files_mode = true;
-    }
+  }
 
   // two different options
-  if (this->FinalArgs.size() > 1 || files_mode)
-    {
+  if (this->FinalArgs.size() > 1 || files_mode) {
     // for each argument, get the programs
     std::vector<std::string>::iterator s = this->FinalArgs.begin();
-    if(files_mode)
-      {
+    if (files_mode) {
       // Skip the FILES argument in files mode.
       ++s;
-      }
-    for(;s != this->FinalArgs.end(); ++s)
-      {
+    }
+    for (; s != this->FinalArgs.end(); ++s) {
       // add to the result
       this->Files.push_back(this->FindInstallSource(s->c_str()));
-      }
     }
-  else     // reg exp list
-    {
+  } else // reg exp list
+  {
     std::vector<std::string> programs;
     cmSystemTools::Glob(this->Makefile->GetCurrentSourceDirectory(),
                         this->FinalArgs[0], programs);
 
     std::vector<std::string>::iterator s = programs.begin();
     // for each argument, get the programs
-    for (;s != programs.end(); ++s)
-      {
+    for (; s != programs.end(); ++s) {
       this->Files.push_back(this->FindInstallSource(s->c_str()));
-      }
     }
+  }
 
   // Construct the destination.  This command always installs under
   // the prefix.  We skip the leading slash given by the user.
   std::string destination = this->Destination.substr(1);
   cmSystemTools::ConvertToUnixSlashes(destination);
-  if(destination.empty())
-    {
+  if (destination.empty()) {
     destination = ".";
-    }
+  }
 
   // Use a file install generator.
   const char* no_permissions = "";
   const char* no_rename = "";
-  std::string no_component = this->Makefile->GetSafeDefinition(
-                                       "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
+  bool no_exclude_from_all = false;
+  std::string no_component =
+    this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
   std::vector<std::string> no_configurations;
   cmInstallGenerator::MessageLevel message =
     cmInstallGenerator::SelectMessageLevel(this->Makefile);
-  this->Makefile->AddInstallGenerator(
-    new cmInstallFilesGenerator(this->Files,
-                                destination.c_str(), true,
-                                no_permissions, no_configurations,
-                                no_component.c_str(), message, no_rename));
+  this->Makefile->AddInstallGenerator(new cmInstallFilesGenerator(
+    this->Files, destination.c_str(), true, no_permissions, no_configurations,
+    no_component.c_str(), message, no_exclude_from_all, no_rename));
 }
 
 /**
@@ -103,15 +94,13 @@ void cmInstallProgramsCommand::FinalPass()
  * present in the build tree.  If a full path is given, it is just
  * returned.
  */
-std::string cmInstallProgramsCommand
-::FindInstallSource(const char* name) const
+std::string cmInstallProgramsCommand::FindInstallSource(const char* name) const
 {
-  if(cmSystemTools::FileIsFullPath(name) ||
-     cmGeneratorExpression::Find(name) == 0)
-    {
+  if (cmSystemTools::FileIsFullPath(name) ||
+      cmGeneratorExpression::Find(name) == 0) {
     // This is a full path.
     return name;
-    }
+  }
 
   // This is a relative path.
   std::string tb = this->Makefile->GetCurrentBinaryDirectory();
@@ -121,20 +110,15 @@ std::string cmInstallProgramsCommand
   ts += "/";
   ts += name;
 
-  if(cmSystemTools::FileExists(tb.c_str()))
-    {
+  if (cmSystemTools::FileExists(tb.c_str())) {
     // The file exists in the binary tree.  Use it.
     return tb;
-    }
-  else if(cmSystemTools::FileExists(ts.c_str()))
-    {
+  } else if (cmSystemTools::FileExists(ts.c_str())) {
     // The file exists in the source tree.  Use it.
     return ts;
-    }
-  else
-    {
+  } else {
     // The file doesn't exist.  Assume it will be present in the
     // binary tree when the install occurs.
     return tb;
-    }
+  }
 }
diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h
index 524debf..b104c69 100644
--- a/Source/cmInstallProgramsCommand.h
+++ b/Source/cmInstallProgramsCommand.h
@@ -26,22 +26,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmInstallProgramsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmInstallProgramsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "install_programs";}
+  virtual std::string GetName() const { return "install_programs"; }
 
   /**
    * This is called at the end after all the information
@@ -57,11 +54,11 @@ public:
 
 protected:
   std::string FindInstallSource(const char* name) const;
+
 private:
   std::vector<std::string> FinalArgs;
   std::string Destination;
   std::vector<std::string> Files;
 };
 
-
 #endif
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index 933aa07..1b0f1d1 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -11,37 +11,33 @@
 ============================================================================*/
 #include "cmInstallScriptGenerator.h"
 
-//----------------------------------------------------------------------------
-cmInstallScriptGenerator
-::cmInstallScriptGenerator(const char* script, bool code,
-                           const char* component) :
-  cmInstallGenerator(0, std::vector<std::string>(), component, MessageDefault),
-  Script(script), Code(code)
+cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
+                                                   bool code,
+                                                   const char* component,
+                                                   bool exclude_from_all)
+  : cmInstallGenerator(0, std::vector<std::string>(), component,
+                       MessageDefault, exclude_from_all)
+  , Script(script)
+  , Code(code)
 {
 }
 
-//----------------------------------------------------------------------------
-cmInstallScriptGenerator
-::~cmInstallScriptGenerator()
+cmInstallScriptGenerator::~cmInstallScriptGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
 {
   Indent indent;
   std::string component_test =
-    this->CreateComponentTest(this->Component.c_str());
+    this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
   os << indent << "if(" << component_test << ")\n";
 
-  if(this->Code)
-    {
+  if (this->Code) {
     os << indent.Next() << this->Script << "\n";
-    }
-  else
-    {
+  } else {
     os << indent.Next() << "include(\"" << this->Script << "\")\n";
-    }
+  }
 
   os << indent << "endif()\n\n";
 }
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 54a7b21..ff2f2fa 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -17,11 +17,11 @@
 /** \class cmInstallScriptGenerator
  * \brief Generate target installation rules.
  */
-class cmInstallScriptGenerator: public cmInstallGenerator
+class cmInstallScriptGenerator : public cmInstallGenerator
 {
 public:
   cmInstallScriptGenerator(const char* script, bool code,
-    const char* component);
+                           const char* component, bool exclude_from_all);
   virtual ~cmInstallScriptGenerator();
 
 protected:
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index b93fb8d..e68bac2 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -13,79 +13,66 @@
 
 #include "cmComputeLinkInformation.h"
 #include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
+#include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmGeneratorTarget.h"
 #include "cmake.h"
-#include "cmGeneratorTarget.h"
 
 #include <assert.h>
 
-//----------------------------------------------------------------------------
-cmInstallTargetGenerator
-::cmInstallTargetGenerator(const std::string& targetName,
-                           const char* dest, bool implib,
-                           const char* file_permissions,
-                           std::vector<std::string> const& configurations,
-                           const char* component,
-                           MessageLevel message,
-                           bool optional):
-  cmInstallGenerator(dest, configurations, component, message),
-  TargetName(targetName),
-  Target(0),
-  FilePermissions(file_permissions),
-  ImportLibrary(implib),
-  Optional(optional)
+cmInstallTargetGenerator::cmInstallTargetGenerator(
+  const std::string& targetName, const char* dest, bool implib,
+  const char* file_permissions, std::vector<std::string> const& configurations,
+  const char* component, MessageLevel message, bool exclude_from_all,
+  bool optional)
+  : cmInstallGenerator(dest, configurations, component, message,
+                       exclude_from_all)
+  , TargetName(targetName)
+  , Target(0)
+  , FilePermissions(file_permissions)
+  , ImportLibrary(implib)
+  , Optional(optional)
 {
   this->ActionsPerConfig = true;
   this->NamelinkMode = NamelinkModeNone;
 }
 
-//----------------------------------------------------------------------------
-cmInstallTargetGenerator
-::~cmInstallTargetGenerator()
+cmInstallTargetGenerator::~cmInstallTargetGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
 {
   // Warn if installing an exclude-from-all target.
-  if(this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-    {
+  if (this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
     std::ostringstream msg;
     msg << "WARNING: Target \"" << this->Target->GetName()
         << "\" has EXCLUDE_FROM_ALL set and will not be built by default "
         << "but an install rule has been provided for it.  CMake does "
         << "not define behavior for this case.";
     cmSystemTools::Message(msg.str().c_str(), "Warning");
-    }
+  }
 
   // Perform the main install script generation.
   this->cmInstallGenerator::GenerateScript(os);
 }
 
-//----------------------------------------------------------------------------
-void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
-                                                    const std::string& config,
-                                                    Indent const& indent)
+void cmInstallTargetGenerator::GenerateScriptForConfig(
+  std::ostream& os, const std::string& config, Indent const& indent)
 {
   // Compute the build tree directory from which to copy the target.
   std::string fromDirConfig;
-  if(this->Target->NeedRelinkBeforeInstall(config))
-    {
+  if (this->Target->NeedRelinkBeforeInstall(config)) {
     fromDirConfig =
-        this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory();
+      this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory();
     fromDirConfig += cmake::GetCMakeFilesDirectory();
     fromDirConfig += "/CMakeRelink.dir/";
-    }
-  else
-    {
-    fromDirConfig =
-        this->Target->GetDirectory(config, this->ImportLibrary);
+  } else {
+    fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary);
     fromDirConfig += "/";
-    }
+  }
   std::string toDir =
     this->ConvertToAbsoluteDestination(this->GetDestination(config));
   toDir += "/";
@@ -96,12 +83,19 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
   std::string literal_args;
   cmState::TargetType targetType = this->Target->GetType();
   cmInstallType type = cmInstallType();
-  switch(targetType)
-    {
-    case cmState::EXECUTABLE: type = cmInstallType_EXECUTABLE; break;
-    case cmState::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break;
-    case cmState::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break;
-    case cmState::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break;
+  switch (targetType) {
+    case cmState::EXECUTABLE:
+      type = cmInstallType_EXECUTABLE;
+      break;
+    case cmState::STATIC_LIBRARY:
+      type = cmInstallType_STATIC_LIBRARY;
+      break;
+    case cmState::SHARED_LIBRARY:
+      type = cmInstallType_SHARED_LIBRARY;
+      break;
+    case cmState::MODULE_LIBRARY:
+      type = cmInstallType_MODULE_LIBRARY;
+      break;
     case cmState::INTERFACE_LIBRARY:
       // Not reachable. We never create a cmInstallTargetGenerator for
       // an INTERFACE_LIBRARY.
@@ -111,12 +105,12 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
     case cmState::UTILITY:
     case cmState::GLOBAL_TARGET:
     case cmState::UNKNOWN_LIBRARY:
-      this->Target->GetLocalGenerator()->IssueMessage(cmake::INTERNAL_ERROR,
+      this->Target->GetLocalGenerator()->IssueMessage(
+        cmake::INTERNAL_ERROR,
         "cmInstallTargetGenerator created with non-installable target.");
       return;
-    }
-  if(targetType == cmState::EXECUTABLE)
-    {
+  }
+  if (targetType == cmState::EXECUTABLE) {
     // There is a bug in cmInstallCommand if this fails.
     assert(this->NamelinkMode == NamelinkModeNone);
 
@@ -125,33 +119,27 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
     std::string targetNameImport;
     std::string targetNamePDB;
     this->Target->GetExecutableNames(targetName, targetNameReal,
-                                     targetNameImport, targetNamePDB,
-                                     config);
-    if(this->ImportLibrary)
-      {
+                                     targetNameImport, targetNamePDB, config);
+    if (this->ImportLibrary) {
       std::string from1 = fromDirConfig + targetNameImport;
       std::string to1 = toDir + targetNameImport;
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
       std::string targetNameImportLib;
-      if(this->Target->GetImplibGNUtoMS(targetNameImport,
-                                        targetNameImportLib))
-        {
+      if (this->Target->GetImplibGNUtoMS(targetNameImport,
+                                         targetNameImportLib)) {
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
         filesTo.push_back(toDir + targetNameImportLib);
-        }
+      }
 
       // An import library looks like a static library.
       type = cmInstallType_STATIC_LIBRARY;
-      }
-    else
-      {
+    } else {
       std::string from1 = fromDirConfig + targetName;
       std::string to1 = toDir + targetName;
 
       // Handle OSX Bundles.
-      if(this->Target->IsAppBundleOnApple())
-        {
+      if (this->Target->IsAppBundleOnApple()) {
         cmMakefile const* mf = this->Target->Target->GetMakefile();
 
         // Install the whole app bundle directory.
@@ -161,41 +149,32 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
 
         // Tweaks apply to the binary inside the bundle.
         to1 += ".app/";
-        if(!mf->PlatformIsAppleIos())
-          {
+        if (!mf->PlatformIsAppleIos()) {
           to1 += "Contents/MacOS/";
-          }
-        to1 += targetName;
         }
-      else
-        {
+        to1 += targetName;
+      } else {
         // Tweaks apply to the real file, so list it first.
-        if(targetNameReal != targetName)
-          {
+        if (targetNameReal != targetName) {
           std::string from2 = fromDirConfig + targetNameReal;
           std::string to2 = toDir += targetNameReal;
           filesFrom.push_back(from2);
           filesTo.push_back(to2);
-          }
         }
+      }
 
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
-      }
     }
-  else
-    {
+  } else {
     std::string targetName;
     std::string targetNameSO;
     std::string targetNameReal;
     std::string targetNameImport;
     std::string targetNamePDB;
-    this->Target->GetLibraryNames(targetName, targetNameSO,
-                                          targetNameReal,
-                                  targetNameImport, targetNamePDB,
-                                  config);
-    if(this->ImportLibrary)
-      {
+    this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
+                                  targetNameImport, targetNamePDB, config);
+    if (this->ImportLibrary) {
       // There is a bug in cmInstallCommand if this fails.
       assert(this->NamelinkMode == NamelinkModeNone);
 
@@ -204,18 +183,15 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
       std::string targetNameImportLib;
-      if(this->Target->GetImplibGNUtoMS(targetNameImport,
-                                        targetNameImportLib))
-        {
+      if (this->Target->GetImplibGNUtoMS(targetNameImport,
+                                         targetNameImportLib)) {
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
         filesTo.push_back(toDir + targetNameImportLib);
-        }
+      }
 
       // An import library looks like a static library.
       type = cmInstallType_STATIC_LIBRARY;
-      }
-    else if(this->Target->IsFrameworkOnApple())
-      {
+    } else if (this->Target->IsFrameworkOnApple()) {
       // There is a bug in cmInstallCommand if this fails.
       assert(this->NamelinkMode == NamelinkModeNone);
 
@@ -231,9 +207,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
 
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
-      }
-    else if(this->Target->IsCFBundleOnApple())
-      {
+    } else if (this->Target->IsCFBundleOnApple()) {
       // Install the whole app bundle directory.
       type = cmInstallType_DIRECTORY;
       literal_args += " USE_SOURCE_PERMISSIONS";
@@ -245,9 +219,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
 
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
-      }
-    else
-      {
+    } else {
       bool haveNamelink = false;
 
       // Library link name.
@@ -257,79 +229,65 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
       // Library interface name.
       std::string fromSOName;
       std::string toSOName;
-      if(targetNameSO != targetName)
-        {
+      if (targetNameSO != targetName) {
         haveNamelink = true;
         fromSOName = fromDirConfig + targetNameSO;
         toSOName = toDir + targetNameSO;
-        }
+      }
 
       // Library implementation name.
       std::string fromRealName;
       std::string toRealName;
-      if(targetNameReal != targetName &&
-         targetNameReal != targetNameSO)
-        {
+      if (targetNameReal != targetName && targetNameReal != targetNameSO) {
         haveNamelink = true;
         fromRealName = fromDirConfig + targetNameReal;
         toRealName = toDir + targetNameReal;
-        }
+      }
 
       // Add the names based on the current namelink mode.
-      if(haveNamelink)
-        {
+      if (haveNamelink) {
         // With a namelink we need to check the mode.
-        if(this->NamelinkMode == NamelinkModeOnly)
-          {
+        if (this->NamelinkMode == NamelinkModeOnly) {
           // Install the namelink only.
           filesFrom.push_back(fromName);
           filesTo.push_back(toName);
-          }
-        else
-          {
+        } else {
           // Install the real file if it has its own name.
-          if(!fromRealName.empty())
-            {
+          if (!fromRealName.empty()) {
             filesFrom.push_back(fromRealName);
             filesTo.push_back(toRealName);
-            }
+          }
 
           // Install the soname link if it has its own name.
-          if(!fromSOName.empty())
-            {
+          if (!fromSOName.empty()) {
             filesFrom.push_back(fromSOName);
             filesTo.push_back(toSOName);
-            }
+          }
 
           // Install the namelink if it is not to be skipped.
-          if(this->NamelinkMode != NamelinkModeSkip)
-            {
+          if (this->NamelinkMode != NamelinkModeSkip) {
             filesFrom.push_back(fromName);
             filesTo.push_back(toName);
-            }
           }
         }
-      else
-        {
+      } else {
         // Without a namelink there will be only one file.  Install it
         // if this is not a namelink-only rule.
-        if(this->NamelinkMode != NamelinkModeOnly)
-          {
+        if (this->NamelinkMode != NamelinkModeOnly) {
           filesFrom.push_back(fromName);
           filesTo.push_back(toName);
-          }
         }
       }
     }
+  }
 
   // If this fails the above code is buggy.
   assert(filesFrom.size() == filesTo.size());
 
   // Skip this rule if no files are to be installed for the target.
-  if(filesFrom.empty())
-    {
+  if (filesFrom.empty()) {
     return;
-    }
+  }
 
   // Add pre-installation tweaks.
   this->AddTweak(os, indent, config, filesTo,
@@ -339,10 +297,9 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
   const char* no_dir_permissions = 0;
   const char* no_rename = 0;
   bool optional = this->Optional || this->ImportLibrary;
-  this->AddInstallRule(os, this->GetDestination(config),
-                       type, filesFrom, optional,
-                       this->FilePermissions.c_str(), no_dir_permissions,
-                       no_rename, literal_args.c_str(),
+  this->AddInstallRule(os, this->GetDestination(config), type, filesFrom,
+                       optional, this->FilePermissions.c_str(),
+                       no_dir_permissions, no_rename, literal_args.c_str(),
                        indent);
 
   // Add post-installation tweaks.
@@ -350,64 +307,49 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
                  &cmInstallTargetGenerator::PostReplacementTweaks);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallTargetGenerator::GetDestination(std::string const& config) const
+std::string cmInstallTargetGenerator::GetDestination(
+  std::string const& config) const
 {
   cmGeneratorExpression ge;
   return ge.Parse(this->Destination)
     ->Evaluate(this->Target->GetLocalGenerator(), config);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const
+std::string cmInstallTargetGenerator::GetInstallFilename(
+  const std::string& config) const
 {
-  NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
-  return
-    cmInstallTargetGenerator::GetInstallFilename(this->Target, config,
-                                                 nameType);
+  NameType nameType = this->ImportLibrary ? NameImplib : NameNormal;
+  return cmInstallTargetGenerator::GetInstallFilename(this->Target, config,
+                                                      nameType);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target,
-                                             const std::string& config,
-                                             NameType nameType)
+std::string cmInstallTargetGenerator::GetInstallFilename(
+  cmGeneratorTarget const* target, const std::string& config,
+  NameType nameType)
 {
   std::string fname;
   // Compute the name of the library.
-  if(target->GetType() == cmState::EXECUTABLE)
-    {
+  if (target->GetType() == cmState::EXECUTABLE) {
     std::string targetName;
     std::string targetNameReal;
     std::string targetNameImport;
     std::string targetNamePDB;
-    target->GetExecutableNames(targetName, targetNameReal,
-                               targetNameImport, targetNamePDB,
-                               config);
-    if(nameType == NameImplib)
-      {
+    target->GetExecutableNames(targetName, targetNameReal, targetNameImport,
+                               targetNamePDB, config);
+    if (nameType == NameImplib) {
       // Use the import library name.
-      if(!target->GetImplibGNUtoMS(targetNameImport, fname,
-                                   "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
-        {
+      if (!target->GetImplibGNUtoMS(targetNameImport, fname,
+                                    "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
         fname = targetNameImport;
-        }
       }
-    else if(nameType == NameReal)
-      {
+    } else if (nameType == NameReal) {
       // Use the canonical name.
       fname = targetNameReal;
-      }
-    else
-      {
+    } else {
       // Use the canonical name.
       fname = targetName;
-      }
     }
-  else
-    {
+  } else {
     std::string targetName;
     std::string targetNameSO;
     std::string targetNameReal;
@@ -415,31 +357,23 @@ cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target,
     std::string targetNamePDB;
     target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
                             targetNameImport, targetNamePDB, config);
-    if(nameType == NameImplib)
-      {
+    if (nameType == NameImplib) {
       // Use the import library name.
-      if(!target->GetImplibGNUtoMS(targetNameImport, fname,
-                                   "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
-        {
+      if (!target->GetImplibGNUtoMS(targetNameImport, fname,
+                                    "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
         fname = targetNameImport;
-        }
       }
-    else if(nameType == NameSO)
-      {
+    } else if (nameType == NameSO) {
       // Use the soname.
       fname = targetNameSO;
-      }
-    else if(nameType == NameReal)
-      {
+    } else if (nameType == NameReal) {
       // Use the real name.
       fname = targetNameReal;
-      }
-    else
-      {
+    } else {
       // Use the canonical name.
       fname = targetName;
-      }
     }
+  }
 
   return fname;
 }
@@ -449,72 +383,61 @@ void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
   this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName);
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator
-::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
-           std::string const& file, TweakMethod tweak)
+void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent,
+                                        const std::string& config,
+                                        std::string const& file,
+                                        TweakMethod tweak)
 {
   std::ostringstream tw;
   (this->*tweak)(tw, indent.Next(), config, file);
   std::string tws = tw.str();
-  if(!tws.empty())
-    {
+  if (!tws.empty()) {
     os << indent << "if(EXISTS \"" << file << "\" AND\n"
        << indent << "   NOT IS_SYMLINK \"" << file << "\")\n";
     os << tws;
     os << indent << "endif()\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator
-::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
-           std::vector<std::string> const& files, TweakMethod tweak)
+void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent const& indent,
+                                        const std::string& config,
+                                        std::vector<std::string> const& files,
+                                        TweakMethod tweak)
 {
-  if(files.size() == 1)
-    {
+  if (files.size() == 1) {
     // Tweak a single file.
     this->AddTweak(os, indent, config, this->GetDestDirPath(files[0]), tweak);
-    }
-  else
-    {
+  } else {
     // Generate a foreach loop to tweak multiple files.
     std::ostringstream tw;
     this->AddTweak(tw, indent.Next(), config, "${file}", tweak);
     std::string tws = tw.str();
-    if(!tws.empty())
-      {
+    if (!tws.empty()) {
       Indent indent2 = indent.Next().Next();
       os << indent << "foreach(file\n";
-      for(std::vector<std::string>::const_iterator i = files.begin();
-          i != files.end(); ++i)
-        {
+      for (std::vector<std::string>::const_iterator i = files.begin();
+           i != files.end(); ++i) {
         os << indent2 << "\"" << this->GetDestDirPath(*i) << "\"\n";
-        }
+      }
       os << indent2 << ")\n";
       os << tws;
       os << indent << "endforeach()\n";
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file)
 {
   // Construct the path of the file on disk after installation on
   // which tweaks may be performed.
   std::string toDestDirPath = "$ENV{DESTDIR}";
-  if(file[0] != '/' && file[0] != '$')
-    {
+  if (file[0] != '/' && file[0] != '$') {
     toDestDirPath += "/";
-    }
+  }
   toDestDirPath += file;
   return toDestDirPath;
 }
 
-//----------------------------------------------------------------------------
 void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os,
                                                     Indent const& indent,
                                                     const std::string& config,
@@ -523,11 +446,10 @@ void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os,
   this->AddRPathCheckRule(os, indent, config, file);
 }
 
-//----------------------------------------------------------------------------
 void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
-                                                    Indent const& indent,
-                                                    const std::string& 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);
@@ -536,59 +458,52 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
   this->AddStripRule(os, indent, file);
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator
-::AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
-                          const std::string& config,
-                          std::string const& toDestDirPath)
+void cmInstallTargetGenerator::AddInstallNamePatchRule(
+  std::ostream& os, Indent const& indent, const std::string& config,
+  std::string const& toDestDirPath)
 {
-  if(this->ImportLibrary ||
-     !(this->Target->GetType() == cmState::SHARED_LIBRARY ||
-       this->Target->GetType() == cmState::MODULE_LIBRARY ||
-       this->Target->GetType() == cmState::EXECUTABLE))
-    {
+  if (this->ImportLibrary ||
+      !(this->Target->GetType() == cmState::SHARED_LIBRARY ||
+        this->Target->GetType() == cmState::MODULE_LIBRARY ||
+        this->Target->GetType() == cmState::EXECUTABLE)) {
     return;
-    }
+  }
 
   // Fix the install_name settings in installed binaries.
-  std::string installNameTool = this->Target->Target->GetMakefile()
-      ->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
+  std::string installNameTool =
+    this->Target->Target->GetMakefile()->GetSafeDefinition(
+      "CMAKE_INSTALL_NAME_TOOL");
 
-  if(installNameTool.empty())
-    {
+  if (installNameTool.empty()) {
     return;
-    }
+  }
 
   // Build a map of build-tree install_name to install-tree install_name for
   // shared libraries linked to this target.
   std::map<std::string, std::string> install_name_remap;
-  if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
-    {
-    std::set<cmGeneratorTarget const*> const& sharedLibs
-                                            = cli->GetSharedLibrariesLinked();
-    for(std::set<cmGeneratorTarget const*>::const_iterator j
-        = sharedLibs.begin(); j != sharedLibs.end(); ++j)
-      {
+  if (cmComputeLinkInformation* cli =
+        this->Target->GetLinkInformation(config)) {
+    std::set<cmGeneratorTarget const*> const& sharedLibs =
+      cli->GetSharedLibrariesLinked();
+    for (std::set<cmGeneratorTarget const*>::const_iterator j =
+           sharedLibs.begin();
+         j != sharedLibs.end(); ++j) {
       cmGeneratorTarget const* tgt = *j;
 
       // The install_name of an imported target does not change.
-      if(tgt->IsImported())
-        {
+      if (tgt->IsImported()) {
         continue;
-        }
+      }
 
       // If the build tree and install tree use different path
       // components of the install_name field then we need to create a
       // mapping to be applied after installation.
       std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
       std::string for_install = tgt->GetInstallNameDirForInstallTree();
-      if(for_build != for_install)
-        {
+      if (for_build != for_install) {
         // The directory portions differ.  Append the filename to
         // create the mapping.
-        std::string fname =
-          this->GetInstallFilename(tgt, config, NameSO);
+        std::string fname = this->GetInstallFilename(tgt, config, NameSO);
 
         // Map from the build-tree install_name.
         for_build += fname;
@@ -598,84 +513,72 @@ cmInstallTargetGenerator
 
         // Store the mapping entry.
         install_name_remap[for_build] = for_install;
-        }
       }
     }
+  }
 
   // Edit the install_name of the target itself if necessary.
   std::string new_id;
-  if(this->Target->GetType() == cmState::SHARED_LIBRARY)
-    {
+  if (this->Target->GetType() == cmState::SHARED_LIBRARY) {
     std::string for_build =
       this->Target->GetInstallNameDirForBuildTree(config);
-    std::string for_install =
-      this->Target->GetInstallNameDirForInstallTree();
+    std::string for_install = this->Target->GetInstallNameDirForInstallTree();
 
-    if(this->Target->IsFrameworkOnApple() && for_install.empty())
-      {
+    if (this->Target->IsFrameworkOnApple() && for_install.empty()) {
       // Frameworks seem to have an id corresponding to their own full
       // path.
       // ...
       // for_install = fullDestPath_without_DESTDIR_or_name;
-      }
+    }
 
     // If the install name will change on installation set the new id
     // on the installed file.
-    if(for_build != for_install)
-      {
+    if (for_build != for_install) {
       // Prepare to refer to the install-tree install_name.
       new_id = for_install;
       new_id += this->GetInstallFilename(this->Target, config, NameSO);
-      }
     }
+  }
 
   // Write a rule to run install_name_tool to set the install-tree
   // install_name value and references.
-  if(!new_id.empty() || !install_name_remap.empty())
-    {
+  if (!new_id.empty() || !install_name_remap.empty()) {
     os << indent << "execute_process(COMMAND \"" << installNameTool;
     os << "\"";
-    if(!new_id.empty())
-      {
+    if (!new_id.empty()) {
       os << "\n" << indent << "  -id \"" << new_id << "\"";
-      }
-    for(std::map<std::string, std::string>::const_iterator
-          i = install_name_remap.begin();
-        i != install_name_remap.end(); ++i)
-      {
-      os << "\n" << indent << "  -change \""
-         << i->first << "\" \"" << i->second << "\"";
-      }
-    os << "\n" << indent << "  \"" << toDestDirPath << "\")\n";
     }
+    for (std::map<std::string, std::string>::const_iterator i =
+           install_name_remap.begin();
+         i != install_name_remap.end(); ++i) {
+      os << "\n"
+         << indent << "  -change \"" << i->first << "\" \"" << i->second
+         << "\"";
+    }
+    os << "\n" << indent << "  \"" << toDestDirPath << "\")\n";
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator
-::AddRPathCheckRule(std::ostream& os, Indent const& indent,
-                    const std::string& config,
-                    std::string const& toDestDirPath)
+void cmInstallTargetGenerator::AddRPathCheckRule(
+  std::ostream& os, Indent const& indent, 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))
-    {
+  if (this->ImportLibrary || !this->Target->IsChrpathUsed(config)) {
     return;
-    }
+  }
   // Skip if on Apple
-  if(this->Target->Target->GetMakefile()
-     ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
+  if (this->Target->Target->GetMakefile()->IsOn(
+        "CMAKE_PLATFORM_HAS_INSTALLNAME")) {
     return;
-    }
+  }
 
   // Get the link information for this target.
   // It can provide the RPATH.
   cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
-  if(!cli)
-    {
+  if (!cli) {
     return;
-    }
+  }
 
   // Get the install RPATH from the link information.
   std::string newRpath = cli->GetChrpathString();
@@ -683,36 +586,32 @@ cmInstallTargetGenerator
   // Write a rule to remove the installed file if its rpath is not the
   // new rpath.  This is needed for existing build/install trees when
   // the installed rpath changes but the file is not rebuilt.
+  /* clang-format off */
   os << indent << "file(RPATH_CHECK\n"
      << indent << "     FILE \"" << toDestDirPath << "\"\n"
      << indent << "     RPATH \"" << newRpath << "\")\n";
+  /* clang-format on */
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator
-::AddChrpathPatchRule(std::ostream& os, Indent const& indent,
-                      const std::string& config,
-                      std::string const& toDestDirPath)
+void cmInstallTargetGenerator::AddChrpathPatchRule(
+  std::ostream& os, Indent const& indent, 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))
-    {
+  if (this->ImportLibrary || !this->Target->IsChrpathUsed(config)) {
     return;
-    }
+  }
 
   // Get the link information for this target.
   // It can provide the RPATH.
   cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
-  if(!cli)
-    {
+  if (!cli) {
     return;
-    }
+  }
 
   cmMakefile* mf = this->Target->Target->GetMakefile();
 
-  if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
-    {
+  if (mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
     // If using install_name_tool, set up the rules to modify the rpaths.
     std::string installNameTool =
       mf->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
@@ -727,57 +626,50 @@ cmInstallTargetGenerator
     std::stringstream ss(darwin_major_version_s);
     int darwin_major_version;
     ss >> darwin_major_version;
-    if(!ss.fail() && darwin_major_version <= 9 &&
-       (!oldRuntimeDirs.empty() || !newRuntimeDirs.empty())
-      )
-      {
+    if (!ss.fail() && darwin_major_version <= 9 &&
+        (!oldRuntimeDirs.empty() || !newRuntimeDirs.empty())) {
       std::ostringstream msg;
-      msg << "WARNING: Target \"" << this->Target->GetName()
+      msg
+        << "WARNING: Target \"" << this->Target->GetName()
         << "\" has runtime paths which cannot be changed during install.  "
         << "To change runtime paths, OS X version 10.6 or newer is required.  "
         << "Therefore, runtime paths will not be changed when installing.  "
         << "CMAKE_BUILD_WITH_INSTALL_RPATH may be used to work around"
            " this limitation.";
       mf->IssueMessage(cmake::WARNING, msg.str());
-      }
-    else
-      {
+    } else {
       // Note: These paths are kept unique to avoid
       // install_name_tool corruption.
       std::set<std::string> runpaths;
-      for(std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin();
-          i != oldRuntimeDirs.end(); ++i)
-        {
+      for (std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin();
+           i != oldRuntimeDirs.end(); ++i) {
         std::string runpath =
           mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config);
 
-        if(runpaths.find(runpath) == runpaths.end())
-          {
+        if (runpaths.find(runpath) == runpaths.end()) {
           runpaths.insert(runpath);
-          os << indent << "execute_process(COMMAND " << installNameTool <<"\n";
+          os << indent << "execute_process(COMMAND " << installNameTool
+             << "\n";
           os << indent << "  -delete_rpath \"" << runpath << "\"\n";
           os << indent << "  \"" << toDestDirPath << "\")\n";
-          }
         }
+      }
 
       runpaths.clear();
-      for(std::vector<std::string>::const_iterator i = newRuntimeDirs.begin();
-          i != newRuntimeDirs.end(); ++i)
-        {
+      for (std::vector<std::string>::const_iterator i = newRuntimeDirs.begin();
+           i != newRuntimeDirs.end(); ++i) {
         std::string runpath =
           mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config);
 
-        if(runpaths.find(runpath) == runpaths.end())
-          {
-          os << indent << "execute_process(COMMAND " << installNameTool <<"\n";
+        if (runpaths.find(runpath) == runpaths.end()) {
+          os << indent << "execute_process(COMMAND " << installNameTool
+             << "\n";
           os << indent << "  -add_rpath \"" << runpath << "\"\n";
           os << indent << "  \"" << toDestDirPath << "\")\n";
-          }
         }
       }
     }
-  else
-    {
+  } else {
     // Construct the original rpath string to be replaced.
     std::string oldRpath = cli->GetRPathString(false);
 
@@ -785,44 +677,39 @@ cmInstallTargetGenerator
     std::string newRpath = cli->GetChrpathString();
 
     // Skip the rule if the paths are identical
-    if(oldRpath == newRpath)
-      {
+    if (oldRpath == newRpath) {
       return;
-      }
+    }
 
     // Write a rule to run chrpath to set the install-tree RPATH
     os << indent << "file(RPATH_CHANGE\n"
        << indent << "     FILE \"" << toDestDirPath << "\"\n"
        << indent << "     OLD_RPATH \"" << oldRpath << "\"\n"
        << indent << "     NEW_RPATH \"" << newRpath << "\")\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator::AddStripRule(std::ostream& os,
-                                       Indent const& indent,
-                                       const std::string& toDestDirPath)
+void cmInstallTargetGenerator::AddStripRule(std::ostream& os,
+                                            Indent const& indent,
+                                            const std::string& toDestDirPath)
 {
 
   // don't strip static and import libraries, because it removes the only
   // symbol table they have so you can't link to them anymore
-  if(this->Target->GetType()==cmState::STATIC_LIBRARY || this->ImportLibrary)
-    {
+  if (this->Target->GetType() == cmState::STATIC_LIBRARY ||
+      this->ImportLibrary) {
     return;
-    }
+  }
 
   // Don't handle OSX Bundles.
-  if(this->Target->Target->GetMakefile()->IsOn("APPLE") &&
-     this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
-    {
+  if (this->Target->Target->GetMakefile()->IsOn("APPLE") &&
+      this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) {
     return;
-    }
+  }
 
-  if(! this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
-    {
+  if (!this->Target->Target->GetMakefile()->IsSet("CMAKE_STRIP")) {
     return;
-    }
+  }
 
   os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n";
   os << indent << "  execute_process(COMMAND \""
@@ -831,58 +718,47 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os,
   os << indent << "endif()\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
-                                        Indent const& indent,
-                                        const std::string& toDestDirPath)
+void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
+                                             Indent const& indent,
+                                             const std::string& toDestDirPath)
 {
   // Static libraries need ranlib on this platform.
-  if(this->Target->GetType() != cmState::STATIC_LIBRARY)
-    {
+  if (this->Target->GetType() != cmState::STATIC_LIBRARY) {
     return;
-    }
+  }
 
   // Perform post-installation processing on the file depending
   // on its type.
-  if(!this->Target->Target->GetMakefile()->IsOn("APPLE"))
-    {
+  if (!this->Target->Target->GetMakefile()->IsOn("APPLE")) {
     return;
-    }
+  }
 
   std::string ranlib =
     this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
-  if(ranlib.empty())
-    {
+  if (ranlib.empty()) {
     return;
-    }
+  }
 
-  os << indent << "execute_process(COMMAND \""
-     << ranlib << "\" \"" << toDestDirPath << "\")\n";
+  os << indent << "execute_process(COMMAND \"" << ranlib << "\" \""
+     << toDestDirPath << "\")\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmInstallTargetGenerator
-::AddUniversalInstallRule(std::ostream& os,
-                          Indent const& indent,
-                          const std::string& toDestDirPath)
+void cmInstallTargetGenerator::AddUniversalInstallRule(
+  std::ostream& os, Indent const& indent, const std::string& toDestDirPath)
 {
   cmMakefile const* mf = this->Target->Target->GetMakefile();
 
-  if(!mf->PlatformIsAppleIos() || !mf->IsOn("XCODE"))
-    {
+  if (!mf->PlatformIsAppleIos() || !mf->IsOn("XCODE")) {
     return;
-    }
+  }
 
   const char* xcodeVersion = mf->GetDefinition("XCODE_VERSION");
-  if(!xcodeVersion || cmSystemTools::VersionCompareGreater("6", xcodeVersion))
-    {
+  if (!xcodeVersion ||
+      cmSystemTools::VersionCompareGreater("6", xcodeVersion)) {
     return;
-    }
+  }
 
-  switch(this->Target->GetType())
-    {
+  switch (this->Target->GetType()) {
     case cmState::EXECUTABLE:
     case cmState::STATIC_LIBRARY:
     case cmState::SHARED_LIBRARY:
@@ -891,15 +767,14 @@ cmInstallTargetGenerator
 
     default:
       return;
-    }
+  }
 
-  if(!this->Target->Target->GetPropertyAsBool("IOS_INSTALL_COMBINED"))
-   {
-   return;
-   }
+  if (!this->Target->Target->GetPropertyAsBool("IOS_INSTALL_COMBINED")) {
+    return;
+  }
 
   os << indent << "include(CMakeIOSInstallCombined)\n";
   os << indent << "ios_install_combined("
-               << "\"" << this->Target->Target->GetName() << "\" "
-               << "\"" << toDestDirPath << "\")\n";
+     << "\"" << this->Target->Target->GetName() << "\" "
+     << "\"" << toDestDirPath << "\")\n";
 }
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 18b3130..2fd85b5 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -19,17 +19,14 @@ class cmGeneratorTarget;
 /** \class cmInstallTargetGenerator
  * \brief Generate target installation rules.
  */
-class cmInstallTargetGenerator: public cmInstallGenerator
+class cmInstallTargetGenerator : public cmInstallGenerator
 {
 public:
-  cmInstallTargetGenerator(
-    std::string const& targetName, const char* dest, bool implib,
-    const char* file_permissions,
-    std::vector<std::string> const& configurations,
-    const char* component,
-    MessageLevel message,
-    bool optional
-    );
+  cmInstallTargetGenerator(std::string const& targetName, const char* dest,
+                           bool implib, const char* file_permissions,
+                           std::vector<std::string> const& configurations,
+                           const char* component, MessageLevel message,
+                           bool exclude_from_all, bool optional);
   virtual ~cmInstallTargetGenerator();
 
   /** Select the policy for installing shared library linkable name
@@ -70,16 +67,16 @@ protected:
   virtual void GenerateScriptForConfig(std::ostream& os,
                                        const std::string& config,
                                        Indent const& indent);
-  typedef void (cmInstallTargetGenerator::*TweakMethod)(
-    std::ostream&, Indent const&, const std::string&, std::string const&
-    );
+  typedef void (cmInstallTargetGenerator::*TweakMethod)(std::ostream&,
+                                                        Indent const&,
+                                                        const std::string&,
+                                                        std::string const&);
   void AddTweak(std::ostream& os, Indent const& indent,
                 const std::string& config, std::string const& file,
                 TweakMethod tweak);
   void AddTweak(std::ostream& os, Indent const& indent,
                 const std::string& config,
-                std::vector<std::string> const& files,
-                TweakMethod tweak);
+                std::vector<std::string> const& files, TweakMethod tweak);
   std::string GetDestDirPath(std::string const& file);
   void PreReplacementTweaks(std::ostream& os, Indent const& indent,
                             const std::string& config,
diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx
index 7e7b848..056ea24 100644
--- a/Source/cmInstallTargetsCommand.cxx
+++ b/Source/cmInstallTargetsCommand.cxx
@@ -12,54 +12,44 @@
 #include "cmInstallTargetsCommand.h"
 
 // cmExecutableCommand
-bool cmInstallTargetsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Enable the install target.
   this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
 
-  cmTargets &tgts = this->Makefile->GetTargets();
+  cmTargets& tgts = this->Makefile->GetTargets();
   std::vector<std::string>::const_iterator s = args.begin();
   ++s;
   std::string runtime_dir = "/bin";
-  for (;s != args.end(); ++s)
-    {
-    if (*s == "RUNTIME_DIRECTORY")
-      {
+  for (; s != args.end(); ++s) {
+    if (*s == "RUNTIME_DIRECTORY") {
       ++s;
-      if ( s == args.end() )
-        {
+      if (s == args.end()) {
         this->SetError("called with RUNTIME_DIRECTORY but no actual "
                        "directory");
         return false;
-        }
+      }
 
       runtime_dir = *s;
-      }
-    else if (tgts.find(*s) != tgts.end())
-      {
+    } else if (tgts.find(*s) != tgts.end()) {
       tgts[*s].SetInstallPath(args[0].c_str());
       tgts[*s].SetRuntimeInstallPath(runtime_dir.c_str());
       tgts[*s].SetHaveInstallRule(true);
-      }
-    else
-      {
+    } else {
       std::string str = "Cannot find target: \"" + *s + "\" to install.";
       this->SetError(str);
       return false;
-      }
     }
+  }
 
-  this->Makefile->GetGlobalGenerator()
-                       ->AddInstallComponent(this->Makefile->GetSafeDefinition(
-                                      "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+  this->Makefile->GetGlobalGenerator()->AddInstallComponent(
+    this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
 
   return true;
 }
-
diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h
index 05160eb..b0d04b0 100644
--- a/Source/cmInstallTargetsCommand.h
+++ b/Source/cmInstallTargetsCommand.h
@@ -27,25 +27,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmInstallTargetsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmInstallTargetsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "install_targets";}
+  virtual std::string GetName() const { return "install_targets"; }
 
   cmTypeMacro(cmInstallTargetsCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx
index fa5e815..ed0f74b 100644
--- a/Source/cmInstalledFile.cxx
+++ b/Source/cmInstalledFile.cxx
@@ -10,29 +10,25 @@
   See the License for more information.
 ============================================================================*/
 #include "cmInstalledFile.h"
-#include "cmSystemTools.h"
-#include "cmMakefile.h"
+
 #include "cmAlgorithms.h"
+#include "cmMakefile.h"
+#include "cmSystemTools.h"
 
-//----------------------------------------------------------------------------
-cmInstalledFile::cmInstalledFile():
-  NameExpression(0)
+cmInstalledFile::cmInstalledFile()
+  : NameExpression(0)
 {
-
 }
 
-//----------------------------------------------------------------------------
 cmInstalledFile::~cmInstalledFile()
 {
-  if(NameExpression)
-    {
+  if (NameExpression) {
     delete NameExpression;
-    }
+  }
 }
 
 cmInstalledFile::Property::Property()
 {
-
 }
 
 cmInstalledFile::Property::~Property()
@@ -40,7 +36,6 @@ cmInstalledFile::Property::~Property()
   cmDeleteAll(this->ValueExpressions);
 }
 
-//----------------------------------------------------------------------------
 void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
 {
   cmListFileBacktrace backtrace = mf->GetBacktrace();
@@ -50,35 +45,31 @@ void cmInstalledFile::SetName(cmMakefile* mf, const std::string& 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)
+                                  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*/)
+                                     const std::string& prop,
+                                     const char* value, bool /*asString*/)
 {
   cmListFileBacktrace backtrace = mf->GetBacktrace();
   cmGeneratorExpression ge(backtrace);
@@ -87,42 +78,36 @@ void cmInstalledFile::AppendProperty(cmMakefile const* mf,
   property.ValueExpressions.push_back(ge.Parse(value).release());
 }
 
-//----------------------------------------------------------------------------
-bool cmInstalledFile::HasProperty(
-  const std::string& prop) const
+bool cmInstalledFile::HasProperty(const std::string& prop) const
 {
   return this->Properties.find(prop) != this->Properties.end();
 }
 
-//----------------------------------------------------------------------------
-bool cmInstalledFile::GetProperty(
-  const std::string& prop, std::string& value) const
+bool cmInstalledFile::GetProperty(const std::string& prop,
+                                  std::string& value) const
 {
   PropertyMapType::const_iterator i = this->Properties.find(prop);
-  if(i == this->Properties.end())
-    {
+  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)
-    {
+  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;
@@ -130,9 +115,8 @@ bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const
   return isSet && cmSystemTools::IsOn(value.c_str());
 }
 
-//----------------------------------------------------------------------------
 void cmInstalledFile::GetPropertyAsList(const std::string& prop,
-  std::vector<std::string>& list) const
+                                        std::vector<std::string>& list) const
 {
   std::string value;
   this->GetProperty(prop, value);
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
index 3af90a7..d000891 100644
--- a/Source/cmInstalledFile.h
+++ b/Source/cmInstalledFile.h
@@ -22,12 +22,10 @@
 class cmInstalledFile
 {
 public:
-
   typedef cmsys::auto_ptr<cmCompiledGeneratorExpression>
     CompiledGeneratorExpressionPtrType;
 
-  typedef std::vector<cmCompiledGeneratorExpression*>
-    ExpressionVectorType;
+  typedef std::vector<cmCompiledGeneratorExpression*> ExpressionVectorType;
 
   struct Property
   {
@@ -45,11 +43,11 @@ public:
 
   void RemoveProperty(const std::string& prop);
 
-  void SetProperty(cmMakefile const* mf,
-    const std::string& prop, const char *value);
+  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);
+  void AppendProperty(cmMakefile const* mf, const std::string& prop,
+                      const char* value, bool asString = false);
 
   bool HasProperty(const std::string& prop) const;
 
@@ -58,7 +56,7 @@ public:
   bool GetPropertyAsBool(const std::string& prop) const;
 
   void GetPropertyAsList(const std::string& prop,
-    std::vector<std::string>& list) const;
+                         std::vector<std::string>& list) const;
 
   void SetName(cmMakefile* mf, const std::string& name);
 
diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx
index b6c0072..a33b429 100644
--- a/Source/cmLinkDirectoriesCommand.cxx
+++ b/Source/cmLinkDirectoriesCommand.cxx
@@ -12,36 +12,33 @@
 #include "cmLinkDirectoriesCommand.h"
 
 // cmLinkDirectoriesCommand
-bool cmLinkDirectoriesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmLinkDirectoriesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
- if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
 
-  for(std::vector<std::string>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
     this->AddLinkDir(*i);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
 {
   std::string unixPath = dir;
   cmSystemTools::ConvertToUnixSlashes(unixPath);
-  if(!cmSystemTools::FileIsFullPath(unixPath.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(unixPath.c_str())) {
     bool convertToAbsolute = false;
     std::ostringstream e;
+    /* clang-format off */
     e << "This command specifies the relative path\n"
       << "  " << unixPath << "\n"
       << "as a link directory.\n";
-    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015))
-      {
+    /* clang-format on */
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015);
         this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
@@ -56,14 +53,13 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
         // NEW behavior converts
         convertToAbsolute = true;
         break;
-      }
-    if (convertToAbsolute)
-      {
+    }
+    if (convertToAbsolute) {
       std::string tmp = this->Makefile->GetCurrentSourceDirectory();
       tmp += "/";
       tmp += unixPath;
       unixPath = tmp;
-      }
     }
+  }
   this->Makefile->AppendProperty("LINK_DIRECTORIES", unixPath.c_str());
 }
diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h
index 8e04baf..7014a69 100644
--- a/Source/cmLinkDirectoriesCommand.h
+++ b/Source/cmLinkDirectoriesCommand.h
@@ -28,28 +28,24 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmLinkDirectoriesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmLinkDirectoriesCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "link_directories";}
+  virtual std::string GetName() const { return "link_directories"; }
 
   cmTypeMacro(cmLinkDirectoriesCommand, cmCommand);
+
 private:
   void AddLinkDir(std::string const& dir);
 };
 
-
-
 #endif
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index b603bcc..0fbe093 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -19,28 +19,51 @@
 class cmGeneratorTarget;
 
 // Basic information about each link item.
-class cmLinkItem: public std::string
+class cmLinkItem : public std::string
 {
   typedef std::string std_string;
+
 public:
-  cmLinkItem(): std_string(), Target(0) {}
-  cmLinkItem(const std_string& n,
-             cmGeneratorTarget const* t): std_string(n), Target(t) {}
-  cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {}
+  cmLinkItem()
+    : std_string()
+    , Target(0)
+  {
+  }
+  cmLinkItem(const std_string& n, cmGeneratorTarget const* t)
+    : std_string(n)
+    , Target(t)
+  {
+  }
+  cmLinkItem(cmLinkItem const& r)
+    : std_string(r)
+    , Target(r.Target)
+  {
+  }
   cmGeneratorTarget const* Target;
 };
 
-class cmLinkImplItem: public cmLinkItem
+class cmLinkImplItem : public cmLinkItem
 {
 public:
-  cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {}
-  cmLinkImplItem(std::string const& n,
-                 cmGeneratorTarget const* t,
-                 cmListFileBacktrace const& bt,
-                 bool fromGenex):
-    cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {}
-  cmLinkImplItem(cmLinkImplItem const& r):
-    cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {}
+  cmLinkImplItem()
+    : cmLinkItem()
+    , Backtrace()
+    , FromGenex(false)
+  {
+  }
+  cmLinkImplItem(std::string const& n, cmGeneratorTarget const* t,
+                 cmListFileBacktrace const& bt, bool fromGenex)
+    : cmLinkItem(n, t)
+    , Backtrace(bt)
+    , FromGenex(fromGenex)
+  {
+  }
+  cmLinkImplItem(cmLinkImplItem const& r)
+    : cmLinkItem(r)
+    , Backtrace(r.Backtrace)
+    , FromGenex(r.FromGenex)
+  {
+  }
   cmListFileBacktrace Backtrace;
   bool FromGenex;
 };
@@ -63,7 +86,7 @@ struct cmLinkInterfaceLibraries
   std::vector<cmLinkItem> Libraries;
 };
 
-struct cmLinkInterface: public cmLinkInterfaceLibraries
+struct cmLinkInterface : public cmLinkInterfaceLibraries
 {
   // Languages whose runtime libraries must be linked.
   std::vector<std::string> Languages;
@@ -73,7 +96,7 @@ struct cmLinkInterface: public cmLinkInterfaceLibraries
 
   // Number of repetitions of a strongly connected component of two
   // or more static libraries.
-  int Multiplicity;
+  unsigned int Multiplicity;
 
   // Libraries listed for other configurations.
   // Needed only for OLD behavior of CMP0003.
@@ -81,15 +104,23 @@ struct cmLinkInterface: public cmLinkInterfaceLibraries
 
   bool ImplementationIsInterface;
 
-  cmLinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {}
+  cmLinkInterface()
+    : Multiplicity(0)
+    , ImplementationIsInterface(false)
+  {
+  }
 };
 
-struct cmOptionalLinkInterface: public cmLinkInterface
+struct cmOptionalLinkInterface : public cmLinkInterface
 {
-  cmOptionalLinkInterface():
-    LibrariesDone(false), AllDone(false),
-    Exists(false), HadHeadSensitiveCondition(false),
-    ExplicitLibraries(0) {}
+  cmOptionalLinkInterface()
+    : LibrariesDone(false)
+    , AllDone(false)
+    , Exists(false)
+    , HadHeadSensitiveCondition(false)
+    , ExplicitLibraries(0)
+  {
+  }
   bool LibrariesDone;
   bool AllDone;
   bool Exists;
@@ -97,49 +128,48 @@ struct cmOptionalLinkInterface: public cmLinkInterface
   const char* ExplicitLibraries;
 };
 
-struct cmHeadToLinkInterfaceMap:
-    public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface>
+struct cmHeadToLinkInterfaceMap
+  : public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface>
 {
 };
 
-struct cmLinkImplementation: public cmLinkImplementationLibraries
+struct cmLinkImplementation : public cmLinkImplementationLibraries
 {
   // Languages whose runtime libraries must be linked.
   std::vector<std::string> Languages;
 };
 
 // Cache link implementation computation from each configuration.
-struct cmOptionalLinkImplementation: public cmLinkImplementation
+struct cmOptionalLinkImplementation : public cmLinkImplementation
 {
-  cmOptionalLinkImplementation():
-    LibrariesDone(false), LanguagesDone(false),
-    HadHeadSensitiveCondition(false) {}
+  cmOptionalLinkImplementation()
+    : LibrariesDone(false)
+    , LanguagesDone(false)
+    , HadHeadSensitiveCondition(false)
+  {
+  }
   bool LibrariesDone;
   bool LanguagesDone;
   bool HadHeadSensitiveCondition;
 };
 
 /** Compute the link type to use for the given configuration.  */
-inline cmTargetLinkLibraryType
-CMP0003_ComputeLinkType(const std::string& config,
-                        std::vector<std::string> const& debugConfigs)
+inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
+  const std::string& config, std::vector<std::string> const& debugConfigs)
 {
   // No configuration is always optimized.
-  if(config.empty())
-    {
+  if (config.empty()) {
     return OPTIMIZED_LibraryType;
-    }
+  }
 
   // Check if any entry in the list matches this configuration.
   std::string configUpper = cmSystemTools::UpperCase(config);
   if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) !=
-      debugConfigs.end())
-    {
+      debugConfigs.end()) {
     return DEBUG_LibraryType;
-    }
+  }
   // The current configuration is not a debug configuration.
   return OPTIMIZED_LibraryType;
 }
 
-
 #endif
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index eb3bfce..5d23d6a 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -12,48 +12,36 @@
 #include "cmLinkLibrariesCommand.h"
 
 // cmLinkLibrariesCommand
-bool cmLinkLibrariesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
   // add libraries, nothe that there is an optional prefix
   // of debug and optimized than can be used
-  for(std::vector<std::string>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
-    if (*i == "debug")
-      {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
+    if (*i == "debug") {
       ++i;
-      if(i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("The \"debug\" argument must be followed by "
                        "a library");
         return false;
-        }
-      this->Makefile->AddLinkLibrary(*i,
-                                 DEBUG_LibraryType);
       }
-    else if (*i == "optimized")
-      {
+      this->Makefile->AddLinkLibrary(*i, DEBUG_LibraryType);
+    } else if (*i == "optimized") {
       ++i;
-      if(i == args.end())
-        {
+      if (i == args.end()) {
         this->SetError("The \"optimized\" argument must be followed by "
                        "a library");
         return false;
-        }
-      this->Makefile->AddLinkLibrary(*i,
-                                 OPTIMIZED_LibraryType);
       }
-    else
-      {
+      this->Makefile->AddLinkLibrary(*i, OPTIMIZED_LibraryType);
+    } else {
       this->Makefile->AddLinkLibrary(*i);
-      }
     }
+  }
 
   return true;
 }
-
diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h
index 1ddefc4..6ab50ce 100644
--- a/Source/cmLinkLibrariesCommand.h
+++ b/Source/cmLinkLibrariesCommand.h
@@ -27,26 +27,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmLinkLibrariesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmLinkLibrariesCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "link_libraries";}
+  virtual std::string GetName() const { return "link_libraries"; }
 
   cmTypeMacro(cmLinkLibrariesCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index 3b41459..1a85396 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -32,12 +32,13 @@
   forward-only-iterated toward the root.  Extending the tree never
   invalidates existing iterators.
  */
-template<typename T>
+template <typename T>
 class cmLinkedTree
 {
   typedef typename std::vector<T>::size_type PositionType;
   typedef T* PointerType;
   typedef T& ReferenceType;
+
 public:
   class iterator : public std::iterator<std::forward_iterator_tag, T>
   {
@@ -48,16 +49,16 @@ public:
     PositionType Position;
 
     iterator(cmLinkedTree* tree, PositionType pos)
-      : Tree(tree), Position(pos)
+      : Tree(tree)
+      , Position(pos)
     {
-
     }
 
   public:
     iterator()
-      : Tree(0), Position(0)
+      : Tree(0)
+      , Position(0)
     {
-
     }
 
     void operator++()
@@ -122,10 +123,9 @@ public:
 
     bool IsValid() const
     {
-      if (!this->Tree)
-        {
+      if (!this->Tree) {
         return false;
-        }
+      }
       return this->Position <= this->Tree->Data.size();
     }
 
@@ -142,36 +142,26 @@ public:
     return iterator(const_cast<cmLinkedTree*>(this), 0);
   }
 
-  iterator Push(iterator it)
-  {
-    return Push_impl(it, T());
-  }
+  iterator Push(iterator it) { return Push_impl(it, T()); }
 
-  iterator Push(iterator it, T t)
-  {
-    return Push_impl(it, t);
-  }
+  iterator Push(iterator it, T t) { return Push_impl(it, t); }
 
-  bool IsLast(iterator it)
-    {
-    return it.Position == this->Data.size();
-    }
+  bool IsLast(iterator it) { return it.Position == this->Data.size(); }
 
   iterator Pop(iterator it)
-    {
+  {
     assert(!this->Data.empty());
     assert(this->UpPositions.size() == this->Data.size());
     bool const isLast = this->IsLast(it);
     ++it;
     // If this is the last entry then no other entry can refer
     // to it so we can drop its storage.
-    if (isLast)
-      {
+    if (isLast) {
       this->Data.pop_back();
       this->UpPositions.pop_back();
-      }
-    return it;
     }
+    return it;
+  }
 
   iterator Truncate()
   {
@@ -190,15 +180,9 @@ public:
   }
 
 private:
-  T& GetReference(PositionType pos)
-  {
-    return this->Data[pos];
-  }
+  T& GetReference(PositionType pos) { return this->Data[pos]; }
 
-  T* GetPointer(PositionType pos)
-  {
-    return &this->Data[pos];
-  }
+  T* GetPointer(PositionType pos) { return &this->Data[pos]; }
 
   iterator Push_impl(iterator it, T t)
   {
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 6041fb7..32e965d 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -10,111 +10,95 @@
   See the License for more information.
 ============================================================================*/
 #include "cmListCommand.h"
+
+#include "cmAlgorithms.h"
 #include <cmsys/RegularExpression.hxx>
 #include <cmsys/SystemTools.hxx>
-#include "cmAlgorithms.h"
 
-#include <stdlib.h> // required for atoi
-#include <ctype.h>
+#include <algorithm>
 #include <assert.h>
-//----------------------------------------------------------------------------
-bool cmListCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+#include <ctype.h>
+#include <stdlib.h> // required for atoi
+bool cmListCommand::InitialPass(std::vector<std::string> const& args,
+                                cmExecutionStatus&)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("must be called with at least two arguments.");
     return false;
-    }
+  }
 
-  const std::string &subCommand = args[0];
-  if(subCommand == "LENGTH")
-    {
+  const std::string& subCommand = args[0];
+  if (subCommand == "LENGTH") {
     return this->HandleLengthCommand(args);
-    }
-  if(subCommand == "GET")
-    {
+  }
+  if (subCommand == "GET") {
     return this->HandleGetCommand(args);
-    }
-  if(subCommand == "APPEND")
-    {
+  }
+  if (subCommand == "APPEND") {
     return this->HandleAppendCommand(args);
-    }
-  if(subCommand == "FIND")
-    {
+  }
+  if (subCommand == "FIND") {
     return this->HandleFindCommand(args);
-    }
-  if(subCommand == "INSERT")
-    {
+  }
+  if (subCommand == "INSERT") {
     return this->HandleInsertCommand(args);
-    }
-  if(subCommand == "REMOVE_AT")
-    {
+  }
+  if (subCommand == "REMOVE_AT") {
     return this->HandleRemoveAtCommand(args);
-    }
-  if(subCommand == "REMOVE_ITEM")
-    {
+  }
+  if (subCommand == "REMOVE_ITEM") {
     return this->HandleRemoveItemCommand(args);
-    }
-  if(subCommand == "REMOVE_DUPLICATES")
-    {
+  }
+  if (subCommand == "REMOVE_DUPLICATES") {
     return this->HandleRemoveDuplicatesCommand(args);
-    }
-  if(subCommand == "SORT")
-    {
+  }
+  if (subCommand == "SORT") {
     return this->HandleSortCommand(args);
-    }
-  if(subCommand == "REVERSE")
-    {
+  }
+  if (subCommand == "REVERSE") {
     return this->HandleReverseCommand(args);
-    }
+  }
+  if (subCommand == "FILTER") {
+    return this->HandleFilterCommand(args);
+  }
 
-  std::string e = "does not recognize sub-command "+subCommand;
+  std::string e = "does not recognize sub-command " + subCommand;
   this->SetError(e);
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::GetListString(std::string& listString,
                                   const std::string& var)
 {
   // get the old value
-  const char* cacheValue
-    = this->Makefile->GetDefinition(var);
-  if(!cacheValue)
-    {
+  const char* cacheValue = this->Makefile->GetDefinition(var);
+  if (!cacheValue) {
     return false;
-    }
+  }
   listString = cacheValue;
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::GetList(std::vector<std::string>& list,
                             const std::string& var)
 {
   std::string listString;
-  if ( !this->GetListString(listString, var) )
-    {
+  if (!this->GetListString(listString, var)) {
     return false;
-    }
+  }
   // if the size of the list
-  if(listString.empty())
-    {
+  if (listString.empty()) {
     return true;
-    }
+  }
   // expand the variable into a list
   cmSystemTools::ExpandListArgument(listString, list, true);
   // if no empty elements then just return
-  if (std::find(list.begin(), list.end(), std::string()) == list.end())
-    {
+  if (std::find(list.begin(), list.end(), std::string()) == list.end()) {
     return true;
-    }
+  }
   // if we have empty elements we need to check policy CMP0007
-  switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0007))
-    {
-    case cmPolicies::WARN:
-      {
+  switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0007)) {
+    case cmPolicies::WARN: {
       // Default is to warn and use old behavior
       // OLD behavior is to allow compatibility, so recall
       // ExpandListArgument without the true which will remove
@@ -125,10 +109,9 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
       warn += " List has value = [";
       warn += listString;
       warn += "].";
-      this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
-                                   warn);
+      this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, warn);
       return true;
-      }
+    }
     case cmPolicies::OLD:
       // OLD behavior is to allow compatibility, so recall
       // ExpandListArgument without the true which will remove
@@ -142,21 +125,18 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
     case cmPolicies::REQUIRED_ALWAYS:
       this->Makefile->IssueMessage(
         cmake::FATAL_ERROR,
-        cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0007)
-        );
+        cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0007));
       return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("sub-command LENGTH requires two arguments.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   const std::string& variableName = args[args.size() - 1];
@@ -173,221 +153,193 @@ bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args)
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 4)
-    {
+  if (args.size() < 4) {
     this->SetError("sub-command GET requires at least three arguments.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   const std::string& variableName = args[args.size() - 1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->Makefile->AddDefinition(variableName, "NOTFOUND");
     return true;
-    }
+  }
   // FIXME: Add policy to make non-existing lists an error like empty lists.
-  if(varArgsExpanded.empty())
-    {
+  if (varArgsExpanded.empty()) {
     this->SetError("GET given empty list");
     return false;
-    }
+  }
 
   std::string value;
   size_t cc;
   const char* sep = "";
   size_t nitem = varArgsExpanded.size();
-  for ( cc = 2; cc < args.size()-1; cc ++ )
-    {
+  for (cc = 2; cc < args.size() - 1; cc++) {
     int item = atoi(args[cc].c_str());
     value += sep;
     sep = ";";
-    if ( item < 0 )
-      {
+    if (item < 0) {
       item = (int)nitem + item;
-      }
-    if ( item < 0 || nitem <= (size_t)item )
-      {
+    }
+    if (item < 0 || nitem <= (size_t)item) {
       std::ostringstream str;
-      str << "index: " << item << " out of range (-"
-          << nitem << ", "
+      str << "index: " << item << " out of range (-" << nitem << ", "
           << nitem - 1 << ")";
       this->SetError(str.str());
       return false;
-      }
-    value += varArgsExpanded[item];
     }
+    value += varArgsExpanded[item];
+  }
 
   this->Makefile->AddDefinition(variableName, value.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
 {
   assert(args.size() >= 2);
 
   // Skip if nothing to append.
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     return true;
-    }
+  }
 
   const std::string& listName = args[1];
   // expand the variable
   std::string listString;
   this->GetListString(listString, listName);
 
-  if(!listString.empty() && !args.empty())
-    {
+  if (!listString.empty() && !args.empty()) {
     listString += ";";
-    }
+  }
   listString += cmJoin(cmMakeRange(args).advance(2), ";");
 
   this->Makefile->AddDefinition(listName, listString.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
 {
-  if(args.size() != 4)
-    {
+  if (args.size() != 4) {
     this->SetError("sub-command FIND requires three arguments.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   const std::string& variableName = args[args.size() - 1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->Makefile->AddDefinition(variableName, "-1");
     return true;
-    }
+  }
 
   std::vector<std::string>::iterator it =
-      std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]);
-  if (it != varArgsExpanded.end())
-    {
+    std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]);
+  if (it != varArgsExpanded.end()) {
     std::ostringstream indexStream;
     indexStream << std::distance(varArgsExpanded.begin(), it);
     this->Makefile->AddDefinition(variableName, indexStream.str().c_str());
     return true;
-    }
+  }
 
   this->Makefile->AddDefinition(variableName, "-1");
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 4)
-    {
+  if (args.size() < 4) {
     this->SetError("sub-command INSERT requires at least three arguments.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
 
   // expand the variable
   int item = atoi(args[2].c_str());
   std::vector<std::string> varArgsExpanded;
-  if((!this->GetList(varArgsExpanded, listName)
-      || varArgsExpanded.empty()) && item != 0)
-    {
+  if ((!this->GetList(varArgsExpanded, listName) || varArgsExpanded.empty()) &&
+      item != 0) {
     std::ostringstream str;
     str << "index: " << item << " out of range (0, 0)";
     this->SetError(str.str());
     return false;
-    }
+  }
 
-  if (!varArgsExpanded.empty())
-    {
+  if (!varArgsExpanded.empty()) {
     size_t nitem = varArgsExpanded.size();
-    if ( item < 0 )
-      {
+    if (item < 0) {
       item = (int)nitem + item;
-      }
-    if ( item < 0 || nitem <= (size_t)item )
-      {
+    }
+    if (item < 0 || nitem <= (size_t)item) {
       std::ostringstream str;
-      str << "index: " << item << " out of range (-"
-        << varArgsExpanded.size() << ", "
-        << (varArgsExpanded.empty() ? 0 : (varArgsExpanded.size() - 1)) << ")";
+      str << "index: " << item << " out of range (-" << varArgsExpanded.size()
+          << ", "
+          << (varArgsExpanded.empty() ? 0 : (varArgsExpanded.size() - 1))
+          << ")";
       this->SetError(str.str());
       return false;
-      }
     }
+  }
 
-  varArgsExpanded.insert(varArgsExpanded.begin()+item,
-                         args.begin() + 3, args.end());
+  varArgsExpanded.insert(varArgsExpanded.begin() + item, args.begin() + 3,
+                         args.end());
 
   std::string value = cmJoin(varArgsExpanded, ";");
   this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmListCommand
-::HandleRemoveItemCommand(std::vector<std::string> const& args)
+bool cmListCommand::HandleRemoveItemCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("sub-command REMOVE_ITEM requires two or more arguments.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->SetError("sub-command REMOVE_ITEM requires list to be present.");
     return false;
-    }
+  }
 
   std::vector<std::string> remove(args.begin() + 2, args.end());
   std::sort(remove.begin(), remove.end());
   std::vector<std::string>::const_iterator remEnd =
-      std::unique(remove.begin(), remove.end());
+    std::unique(remove.begin(), remove.end());
   std::vector<std::string>::const_iterator remBegin = remove.begin();
 
   std::vector<std::string>::const_iterator argsEnd =
-      cmRemoveMatching(varArgsExpanded, cmMakeRange(remBegin, remEnd));
+    cmRemoveMatching(varArgsExpanded, cmMakeRange(remBegin, remEnd));
   std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
   std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
   this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmListCommand
-::HandleReverseCommand(std::vector<std::string> const& args)
+bool cmListCommand::HandleReverseCommand(std::vector<std::string> const& args)
 {
   assert(args.size() >= 2);
-  if(args.size() > 2)
-    {
-    this->SetError(
-      "sub-command REVERSE only takes one argument.");
+  if (args.size() > 2) {
+    this->SetError("sub-command REVERSE only takes one argument.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->SetError("sub-command REVERSE requires list to be present.");
     return false;
-    }
+  }
 
   std::string value = cmJoin(cmReverseRange(varArgsExpanded), ";");
 
@@ -395,58 +347,48 @@ bool cmListCommand
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmListCommand
-::HandleRemoveDuplicatesCommand(std::vector<std::string> const& args)
+bool cmListCommand::HandleRemoveDuplicatesCommand(
+  std::vector<std::string> const& args)
 {
   assert(args.size() >= 2);
-  if(args.size() > 2)
-    {
-    this->SetError(
-      "sub-command REMOVE_DUPLICATES only takes one argument.");
+  if (args.size() > 2) {
+    this->SetError("sub-command REMOVE_DUPLICATES only takes one argument.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->SetError(
       "sub-command REMOVE_DUPLICATES requires list to be present.");
     return false;
-    }
+  }
 
   std::vector<std::string>::const_iterator argsEnd =
-      cmRemoveDuplicates(varArgsExpanded);
-  std::vector<std::string>::const_iterator argsBegin =
-      varArgsExpanded.begin();
+    cmRemoveDuplicates(varArgsExpanded);
+  std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
   std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
 
   this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmListCommand
-::HandleSortCommand(std::vector<std::string> const& args)
+bool cmListCommand::HandleSortCommand(std::vector<std::string> const& args)
 {
   assert(args.size() >= 2);
-  if(args.size() > 2)
-    {
-    this->SetError(
-      "sub-command SORT only takes one argument.");
+  if (args.size() > 2) {
+    this->SetError("sub-command SORT only takes one argument.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->SetError("sub-command SORT requires list to be present.");
     return false;
-    }
+  }
 
   std::sort(varArgsExpanded.begin(), varArgsExpanded.end());
 
@@ -455,61 +397,52 @@ bool cmListCommand
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmListCommand::HandleRemoveAtCommand(
-  std::vector<std::string> const& args)
+bool cmListCommand::HandleRemoveAtCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("sub-command REMOVE_AT requires at least "
                    "two arguments.");
     return false;
-    }
+  }
 
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName) )
-    {
+  if (!this->GetList(varArgsExpanded, listName)) {
     this->SetError("sub-command REMOVE_AT requires list to be present.");
     return false;
-    }
+  }
   // FIXME: Add policy to make non-existing lists an error like empty lists.
-  if(varArgsExpanded.empty())
-    {
+  if (varArgsExpanded.empty()) {
     this->SetError("REMOVE_AT given empty list");
     return false;
-    }
+  }
 
   size_t cc;
   std::vector<size_t> removed;
   size_t nitem = varArgsExpanded.size();
-  for ( cc = 2; cc < args.size(); ++ cc )
-    {
+  for (cc = 2; cc < args.size(); ++cc) {
     int item = atoi(args[cc].c_str());
-    if ( item < 0 )
-      {
+    if (item < 0) {
       item = (int)nitem + item;
-      }
-    if ( item < 0 || nitem <= (size_t)item )
-      {
+    }
+    if (item < 0 || nitem <= (size_t)item) {
       std::ostringstream str;
-      str << "index: " << item << " out of range (-"
-          << nitem << ", "
+      str << "index: " << item << " out of range (-" << nitem << ", "
           << nitem - 1 << ")";
       this->SetError(str.str());
       return false;
-      }
-    removed.push_back(static_cast<size_t>(item));
     }
+    removed.push_back(static_cast<size_t>(item));
+  }
 
   std::sort(removed.begin(), removed.end());
   std::vector<size_t>::const_iterator remEnd =
-      std::unique(removed.begin(), removed.end());
+    std::unique(removed.begin(), removed.end());
   std::vector<size_t>::const_iterator remBegin = removed.begin();
 
   std::vector<std::string>::const_iterator argsEnd =
-      cmRemoveIndices(varArgsExpanded, cmMakeRange(remBegin, remEnd));
+    cmRemoveIndices(varArgsExpanded, cmMakeRange(remBegin, remEnd));
   std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
   std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
 
@@ -517,3 +450,97 @@ bool cmListCommand::HandleRemoveAtCommand(
   return true;
 }
 
+bool cmListCommand::HandleFilterCommand(std::vector<std::string> const& args)
+{
+  if (args.size() < 2) {
+    this->SetError("sub-command FILTER requires a list to be specified.");
+    return false;
+  }
+
+  if (args.size() < 3) {
+    this->SetError("sub-command FILTER requires an operator to be specified.");
+    return false;
+  }
+
+  if (args.size() < 4) {
+    this->SetError("sub-command FILTER requires a mode to be specified.");
+    return false;
+  }
+
+  const std::string& listName = args[1];
+  // expand the variable
+  std::vector<std::string> varArgsExpanded;
+  if (!this->GetList(varArgsExpanded, listName)) {
+    this->SetError("sub-command FILTER requires list to be present.");
+    return false;
+  }
+
+  const std::string& op = args[2];
+  bool includeMatches;
+  if (op == "INCLUDE") {
+    includeMatches = true;
+  } else if (op == "EXCLUDE") {
+    includeMatches = false;
+  } else {
+    this->SetError("sub-command FILTER does not recognize operator " + op);
+    return false;
+  }
+
+  const std::string& mode = args[3];
+  if (mode == "REGEX") {
+    if (args.size() != 5) {
+      this->SetError("sub-command FILTER, mode REGEX "
+                     "requires five arguments.");
+      return false;
+    }
+    return this->FilterRegex(args, includeMatches, listName, varArgsExpanded);
+  }
+
+  this->SetError("sub-command FILTER does not recognize mode " + mode);
+  return false;
+}
+
+class MatchesRegex
+{
+public:
+  MatchesRegex(cmsys::RegularExpression& in_regex, bool in_includeMatches)
+    : regex(in_regex)
+    , includeMatches(in_includeMatches)
+  {
+  }
+
+  bool operator()(const std::string& target)
+  {
+    return regex.find(target) ^ includeMatches;
+  }
+
+private:
+  cmsys::RegularExpression& regex;
+  const bool includeMatches;
+};
+
+bool cmListCommand::FilterRegex(std::vector<std::string> const& args,
+                                bool includeMatches,
+                                std::string const& listName,
+                                std::vector<std::string>& varArgsExpanded)
+{
+  const std::string& pattern = args[4];
+  cmsys::RegularExpression regex(pattern);
+  if (!regex.is_valid()) {
+    std::string error = "sub-command FILTER, mode REGEX ";
+    error += "failed to compile regex \"";
+    error += pattern;
+    error += "\".";
+    this->SetError(error);
+    return false;
+  }
+
+  std::vector<std::string>::iterator argsBegin = varArgsExpanded.begin();
+  std::vector<std::string>::iterator argsEnd = varArgsExpanded.end();
+  std::vector<std::string>::iterator newArgsEnd =
+    std::remove_if(argsBegin, argsEnd, MatchesRegex(regex, includeMatches));
+
+  std::string value = cmJoin(cmMakeRange(argsBegin, newArgsEnd), ";");
+  this->Makefile->AddDefinition(listName, value.c_str());
+  return true;
+}
diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h
index 5ea1d9f..56d9694 100644
--- a/Source/cmListCommand.h
+++ b/Source/cmListCommand.h
@@ -24,17 +24,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmListCommand;
-    }
+  virtual cmCommand* Clone() { return new cmListCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -44,9 +41,10 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "list";}
+  virtual std::string GetName() const { return "list"; }
 
   cmTypeMacro(cmListCommand, cmCommand);
+
 protected:
   bool HandleLengthCommand(std::vector<std::string> const& args);
   bool HandleGetCommand(std::vector<std::string> const& args);
@@ -58,11 +56,13 @@ protected:
   bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args);
   bool HandleSortCommand(std::vector<std::string> const& args);
   bool HandleReverseCommand(std::vector<std::string> const& args);
-
+  bool HandleFilterCommand(std::vector<std::string> const& args);
+  bool FilterRegex(std::vector<std::string> const& args, bool includeMatches,
+                   std::string const& listName,
+                   std::vector<std::string>& varArgsExpanded);
 
   bool GetList(std::vector<std::string>& list, const std::string& var);
   bool GetListString(std::string& listString, const std::string& var);
 };
 
-
 #endif
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 7ba61f3..f47e9b6 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -12,15 +12,13 @@
 #include "cmListFileCache.h"
 
 #include "cmListFileLexer.h"
+#include "cmMakefile.h"
 #include "cmOutputConverter.h"
 #include "cmSystemTools.h"
-#include "cmMakefile.h"
 #include "cmVersion.h"
 
 #include <cmsys/RegularExpression.hxx>
 
-
-//----------------------------------------------------------------------------
 struct cmListFileParser
 {
   cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
@@ -34,80 +32,66 @@ struct cmListFileParser
   const char* FileName;
   cmListFileLexer* Lexer;
   cmListFileFunction Function;
-  enum { SeparationOkay, SeparationWarning, SeparationError} Separation;
+  enum
+  {
+    SeparationOkay,
+    SeparationWarning,
+    SeparationError
+  } Separation;
 };
 
-//----------------------------------------------------------------------------
 cmListFileParser::cmListFileParser(cmListFile* lf, cmMakefile* mf,
-                                   const char* filename):
-  ListFile(lf), Makefile(mf), FileName(filename),
-  Lexer(cmListFileLexer_New())
+                                   const char* filename)
+  : ListFile(lf)
+  , Makefile(mf)
+  , FileName(filename)
+  , Lexer(cmListFileLexer_New())
 {
 }
 
-//----------------------------------------------------------------------------
 cmListFileParser::~cmListFileParser()
 {
   cmListFileLexer_Delete(this->Lexer);
 }
 
-//----------------------------------------------------------------------------
 bool cmListFileParser::ParseFile()
 {
   // Open the file.
   cmListFileLexer_BOM bom;
-  if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom))
-    {
+  if (!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom)) {
     cmSystemTools::Error("cmListFileCache: error can not open file ",
                          this->FileName);
     return false;
-    }
+  }
 
   // Verify the Byte-Order-Mark, if any.
-  if(bom != cmListFileLexer_BOM_None &&
-     bom != cmListFileLexer_BOM_UTF8)
-    {
+  if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) {
     cmListFileLexer_SetFileName(this->Lexer, 0, 0);
     std::ostringstream m;
     m << "File\n  " << this->FileName << "\n"
       << "starts with a Byte-Order-Mark that is not UTF-8.";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
     return false;
-    }
+  }
 
   // Use a simple recursive-descent parser to process the token
   // stream.
   bool haveNewline = true;
-  while(cmListFileLexer_Token* token =
-        cmListFileLexer_Scan(this->Lexer))
-    {
-    if(token->type == cmListFileLexer_Token_Space)
-      {
-      }
-    else if(token->type == cmListFileLexer_Token_Newline)
-      {
+  while (cmListFileLexer_Token* token = cmListFileLexer_Scan(this->Lexer)) {
+    if (token->type == cmListFileLexer_Token_Space) {
+    } else if (token->type == cmListFileLexer_Token_Newline) {
       haveNewline = true;
-      }
-    else if(token->type == cmListFileLexer_Token_CommentBracket)
-      {
+    } else if (token->type == cmListFileLexer_Token_CommentBracket) {
       haveNewline = false;
-      }
-    else if(token->type == cmListFileLexer_Token_Identifier)
-      {
-      if(haveNewline)
-        {
+    } else if (token->type == cmListFileLexer_Token_Identifier) {
+      if (haveNewline) {
         haveNewline = false;
-        if(this->ParseFunction(token->text, token->line))
-          {
+        if (this->ParseFunction(token->text, token->line)) {
           this->ListFile->Functions.push_back(this->Function);
-          }
-        else
-          {
+        } else {
           return false;
-          }
         }
-      else
-        {
+      } else {
         std::ostringstream error;
         error << "Error in cmake code at\n"
               << this->FileName << ":" << token->line << ":\n"
@@ -116,64 +100,51 @@ bool cmListFileParser::ParseFile()
               << " with text \"" << token->text << "\".";
         cmSystemTools::Error(error.str().c_str());
         return false;
-        }
       }
-    else
-      {
+    } else {
       std::ostringstream error;
       error << "Error in cmake code at\n"
             << this->FileName << ":" << token->line << ":\n"
             << "Parse error.  Expected a command name, got "
             << cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
-            << " with text \""
-            << token->text << "\".";
+            << " with text \"" << token->text << "\".";
       cmSystemTools::Error(error.str().c_str());
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmListFile::ParseFile(const char* filename,
-                           bool topLevel,
-                           cmMakefile *mf)
+bool cmListFile::ParseFile(const char* filename, bool topLevel, cmMakefile* mf)
 {
-  if(!cmSystemTools::FileExists(filename) ||
-     cmSystemTools::FileIsDirectory(filename))
-    {
+  if (!cmSystemTools::FileExists(filename) ||
+      cmSystemTools::FileIsDirectory(filename)) {
     return false;
-    }
+  }
 
   bool parseError = false;
 
   {
-  cmListFileParser parser(this, mf, filename);
-  parseError = !parser.ParseFile();
+    cmListFileParser parser(this, mf, filename);
+    parseError = !parser.ParseFile();
   }
 
   // do we need a cmake_policy(VERSION call?
-  if(topLevel)
-  {
+  if (topLevel) {
     bool hasVersion = false;
     // search for the right policy command
-    for(std::vector<cmListFileFunction>::iterator i
-          = this->Functions.begin();
-        i != this->Functions.end(); ++i)
-    {
-      if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required")
-      {
+    for (std::vector<cmListFileFunction>::iterator i = this->Functions.begin();
+         i != this->Functions.end(); ++i) {
+      if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") {
         hasVersion = true;
         break;
       }
     }
     // if no policy command is found this is an error if they use any
     // non advanced functions or a lot of functions
-    if(!hasVersion)
-    {
+    if (!hasVersion) {
       bool isProblem = true;
-      if (this->Functions.size() < 30)
-      {
+      if (this->Functions.size() < 30) {
         // the list of simple commands DO NOT ADD TO THIS LIST!!!!!
         // these commands must have backwards compatibility forever and
         // and that is a lot longer than your tiny mind can comprehend mortal
@@ -190,165 +161,137 @@ bool cmListFile::ParseFile(const char* filename,
         allowedCommands.insert("option");
         allowedCommands.insert("message");
         isProblem = false;
-        for(std::vector<cmListFileFunction>::iterator i
-              = this->Functions.begin();
-            i != this->Functions.end(); ++i)
-        {
+        for (std::vector<cmListFileFunction>::iterator i =
+               this->Functions.begin();
+             i != this->Functions.end(); ++i) {
           std::string name = cmSystemTools::LowerCase(i->Name);
-          if (allowedCommands.find(name) == allowedCommands.end())
-          {
+          if (allowedCommands.find(name) == allowedCommands.end()) {
             isProblem = true;
             break;
           }
         }
       }
 
-      if (isProblem)
-      {
-      // Tell the top level cmMakefile to diagnose
-      // this violation of CMP0000.
-      mf->SetCheckCMP0000(true);
+      if (isProblem) {
+        // Tell the top level cmMakefile to diagnose
+        // this violation of CMP0000.
+        mf->SetCheckCMP0000(true);
 
-      // Implicitly set the version for the user.
-      mf->SetPolicyVersion("2.4");
+        // Implicitly set the version for the user.
+        mf->SetPolicyVersion("2.4");
       }
     }
   }
 
-  if(topLevel)
-    {
+  if (topLevel) {
     bool hasProject = false;
     // search for a project command
-    for(std::vector<cmListFileFunction>::iterator i
-          = this->Functions.begin();
-        i != this->Functions.end(); ++i)
-      {
-      if(cmSystemTools::LowerCase(i->Name) == "project")
-        {
+    for (std::vector<cmListFileFunction>::iterator i = this->Functions.begin();
+         i != this->Functions.end(); ++i) {
+      if (cmSystemTools::LowerCase(i->Name) == "project") {
         hasProject = true;
         break;
-        }
       }
+    }
     // if no project command is found, add one
-    if(!hasProject)
-      {
+    if (!hasProject) {
       cmListFileFunction project;
       project.Name = "PROJECT";
       cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0);
       project.Arguments.push_back(prj);
-      this->Functions.insert(this->Functions.begin(),project);
-      }
+      this->Functions.insert(this->Functions.begin(), project);
     }
-  if(parseError)
-    {
+  }
+  if (parseError) {
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmListFileParser::ParseFunction(const char* name, long line)
 {
-  // Inintialize a new function call.
+  // Ininitialize a new function call.
   this->Function = cmListFileFunction();
   this->Function.Name = name;
   this->Function.Line = line;
 
   // Command name has already been parsed.  Read the left paren.
   cmListFileLexer_Token* token;
-  while((token = cmListFileLexer_Scan(this->Lexer)) &&
-        token->type == cmListFileLexer_Token_Space) {}
-  if(!token)
-    {
+  while ((token = cmListFileLexer_Scan(this->Lexer)) &&
+         token->type == cmListFileLexer_Token_Space) {
+  }
+  if (!token) {
     std::ostringstream error;
+    /* clang-format off */
     error << "Error in cmake code at\n" << this->FileName << ":"
           << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
           << "Parse error.  Function missing opening \"(\".";
+    /* clang-format on */
     cmSystemTools::Error(error.str().c_str());
     return false;
-    }
-  if(token->type != cmListFileLexer_Token_ParenLeft)
-    {
+  }
+  if (token->type != cmListFileLexer_Token_ParenLeft) {
     std::ostringstream error;
-    error << "Error in cmake code at\n" << this->FileName << ":"
+    error << "Error in cmake code at\n"
+          << this->FileName << ":"
           << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
           << "Parse error.  Expected \"(\", got "
           << cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
           << " with text \"" << token->text << "\".";
     cmSystemTools::Error(error.str().c_str());
     return false;
-    }
+  }
 
   // Arguments.
   unsigned long lastLine;
   unsigned long parenDepth = 0;
   this->Separation = SeparationOkay;
-  while((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer),
-         token = cmListFileLexer_Scan(this->Lexer)))
-    {
-    if(token->type == cmListFileLexer_Token_Space ||
-       token->type == cmListFileLexer_Token_Newline)
-      {
+  while ((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer),
+          token = cmListFileLexer_Scan(this->Lexer))) {
+    if (token->type == cmListFileLexer_Token_Space ||
+        token->type == cmListFileLexer_Token_Newline) {
       this->Separation = SeparationOkay;
       continue;
-      }
-    if(token->type == cmListFileLexer_Token_ParenLeft)
-      {
+    }
+    if (token->type == cmListFileLexer_Token_ParenLeft) {
       parenDepth++;
       this->Separation = SeparationOkay;
-      if(!this->AddArgument(token, cmListFileArgument::Unquoted))
-        {
+      if (!this->AddArgument(token, cmListFileArgument::Unquoted)) {
         return false;
-        }
       }
-    else if(token->type == cmListFileLexer_Token_ParenRight)
-      {
-      if (parenDepth == 0)
-        {
+    } else if (token->type == cmListFileLexer_Token_ParenRight) {
+      if (parenDepth == 0) {
         return true;
-        }
+      }
       parenDepth--;
       this->Separation = SeparationOkay;
-      if(!this->AddArgument(token, cmListFileArgument::Unquoted))
-        {
+      if (!this->AddArgument(token, cmListFileArgument::Unquoted)) {
         return false;
-        }
-      this->Separation = SeparationWarning;
       }
-    else if(token->type == cmListFileLexer_Token_Identifier ||
-            token->type == cmListFileLexer_Token_ArgumentUnquoted)
-      {
-      if(!this->AddArgument(token, cmListFileArgument::Unquoted))
-        {
-        return false;
-        }
       this->Separation = SeparationWarning;
-      }
-    else if(token->type == cmListFileLexer_Token_ArgumentQuoted)
-      {
-      if(!this->AddArgument(token, cmListFileArgument::Quoted))
-        {
+    } else if (token->type == cmListFileLexer_Token_Identifier ||
+               token->type == cmListFileLexer_Token_ArgumentUnquoted) {
+      if (!this->AddArgument(token, cmListFileArgument::Unquoted)) {
         return false;
-        }
+      }
       this->Separation = SeparationWarning;
+    } else if (token->type == cmListFileLexer_Token_ArgumentQuoted) {
+      if (!this->AddArgument(token, cmListFileArgument::Quoted)) {
+        return false;
       }
-    else if(token->type == cmListFileLexer_Token_ArgumentBracket)
-      {
-      if(!this->AddArgument(token, cmListFileArgument::Bracket))
-        {
+      this->Separation = SeparationWarning;
+    } else if (token->type == cmListFileLexer_Token_ArgumentBracket) {
+      if (!this->AddArgument(token, cmListFileArgument::Bracket)) {
         return false;
-        }
-      this->Separation = SeparationError;
       }
-    else if(token->type == cmListFileLexer_Token_CommentBracket)
-      {
       this->Separation = SeparationError;
-      }
-    else
-      {
+    } else if (token->type == cmListFileLexer_Token_CommentBracket) {
+      this->Separation = SeparationError;
+    } else {
       // Error.
       std::ostringstream error;
-      error << "Error in cmake code at\n" << this->FileName << ":"
+      error << "Error in cmake code at\n"
+            << this->FileName << ":"
             << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
             << "Parse error.  Function missing ending \")\".  "
             << "Instead found "
@@ -356,8 +299,8 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
             << " with text \"" << token->text << "\".";
       cmSystemTools::Error(error.str().c_str());
       return false;
-      }
     }
+  }
 
   std::ostringstream error;
   error << "Error in cmake code at\n"
@@ -369,118 +312,206 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
                                    cmListFileArgument::Delimiter delim)
 {
   cmListFileArgument a(token->text, delim, token->line);
   this->Function.Arguments.push_back(a);
-  if(this->Separation == SeparationOkay)
-    {
+  if (this->Separation == SeparationOkay) {
     return true;
-    }
+  }
   bool isError = (this->Separation == SeparationError ||
                   delim == cmListFileArgument::Bracket);
   std::ostringstream m;
+  /* clang-format off */
   m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
     << "  " << this->FileName << ":" << token->line << ":"
     << token->column << "\n"
     << "Argument not separated from preceding token by whitespace.";
-  if(isError)
-    {
+  /* clang-format on */
+  if (isError) {
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
     return false;
-    }
-  else
-    {
+  } else {
     this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
     return true;
-    }
+  }
 }
 
-cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot snapshot,
-                                         cmCommandContext const& cc)
-  : Context(cc)
-  , Snapshot(snapshot)
+struct cmListFileBacktrace::Entry : public cmListFileContext
 {
-  if (this->Snapshot.IsValid())
-    {
-    this->Snapshot.Keep();
+  Entry(cmListFileContext const& lfc, Entry* up)
+    : cmListFileContext(lfc)
+    , Up(up)
+    , RefCount(0)
+  {
+    if (this->Up) {
+      this->Up->Ref();
     }
+  }
+  ~Entry()
+  {
+    if (this->Up) {
+      this->Up->Unref();
+    }
+  }
+  void Ref() { ++this->RefCount; }
+  void Unref()
+  {
+    if (--this->RefCount == 0) {
+      delete this;
+    }
+  }
+  Entry* Up;
+  unsigned int RefCount;
+};
+
+cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom, Entry* up,
+                                         cmListFileContext const& lfc)
+  : Bottom(bottom)
+  , Cur(new Entry(lfc, up))
+{
+  assert(this->Bottom.IsValid());
+  this->Cur->Ref();
+}
+
+cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur)
+  : Bottom(bottom)
+  , Cur(cur)
+{
+  if (this->Cur) {
+    assert(this->Bottom.IsValid());
+    this->Cur->Ref();
+  }
+}
+
+cmListFileBacktrace::cmListFileBacktrace()
+  : Bottom()
+  , Cur(0)
+{
+}
+
+cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot snapshot)
+  : Bottom(snapshot.GetCallStackBottom())
+  , Cur(0)
+{
+}
+
+cmListFileBacktrace::cmListFileBacktrace(cmListFileBacktrace const& r)
+  : Bottom(r.Bottom)
+  , Cur(r.Cur)
+{
+  if (this->Cur) {
+    assert(this->Bottom.IsValid());
+    this->Cur->Ref();
+  }
+}
+
+cmListFileBacktrace& cmListFileBacktrace::operator=(
+  cmListFileBacktrace const& r)
+{
+  cmListFileBacktrace tmp(r);
+  std::swap(this->Cur, tmp.Cur);
+  std::swap(this->Bottom, tmp.Bottom);
+  return *this;
 }
 
 cmListFileBacktrace::~cmListFileBacktrace()
 {
+  if (this->Cur) {
+    this->Cur->Unref();
+  }
+}
+
+cmListFileBacktrace cmListFileBacktrace::Push(std::string const& file) const
+{
+  // We are entering a file-level scope but have not yet reached
+  // any specific line or command invocation within it.  This context
+  // is useful to print when it is at the top but otherwise can be
+  // skipped during call stack printing.
+  cmListFileContext lfc;
+  lfc.FilePath = file;
+  return cmListFileBacktrace(this->Bottom, this->Cur, lfc);
+}
+
+cmListFileBacktrace cmListFileBacktrace::Push(
+  cmListFileContext const& lfc) const
+{
+  return cmListFileBacktrace(this->Bottom, this->Cur, lfc);
+}
+
+cmListFileBacktrace cmListFileBacktrace::Pop() const
+{
+  assert(this->Cur);
+  return cmListFileBacktrace(this->Bottom, this->Cur->Up);
+}
+
+cmListFileContext const& cmListFileBacktrace::Top() const
+{
+  if (this->Cur) {
+    return *this->Cur;
+  } else {
+    static cmListFileContext const empty;
+    return empty;
+  }
 }
 
 void cmListFileBacktrace::PrintTitle(std::ostream& out) const
 {
-  if (!this->Snapshot.IsValid())
-    {
+  if (!this->Cur) {
     return;
-    }
-  cmOutputConverter converter(this->Snapshot);
-  cmListFileContext lfc =
-      cmListFileContext::FromCommandContext(
-        this->Context, this->Snapshot.GetExecutionListFile());
-  lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+  }
+  cmOutputConverter converter(this->Bottom);
+  cmListFileContext lfc = *this->Cur;
+  if (!this->Bottom.GetState()->GetIsInTryCompile()) {
+    lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+  }
   out << (lfc.Line ? " at " : " in ") << lfc;
 }
 
 void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
 {
-  if (!this->Snapshot.IsValid())
-    {
+  if (!this->Cur || !this->Cur->Up) {
     return;
+  }
+
+  bool first = true;
+  cmOutputConverter converter(this->Bottom);
+  for (Entry* i = this->Cur->Up; i; i = i->Up) {
+    if (i->Name.empty()) {
+      // Skip this whole-file scope.  When we get here we already will
+      // have printed a more-specific context within the file.
+      continue;
     }
-  cmState::Snapshot parent = this->Snapshot.GetCallStackParent();
-  if (!parent.IsValid() || parent.GetExecutionListFile().empty())
-    {
-    return;
+    if (first) {
+      first = false;
+      out << "Call Stack (most recent call first):\n";
     }
-
-  cmOutputConverter converter(this->Snapshot);
-  std::string commandName = this->Snapshot.GetEntryPointCommand();
-  long commandLine = this->Snapshot.GetEntryPointLine();
-
-  out << "Call Stack (most recent call first):\n";
-  while(parent.IsValid())
-    {
-    cmListFileContext lfc;
-    lfc.Name = commandName;
-    lfc.Line = commandLine;
-
-    lfc.FilePath = converter.Convert(parent.GetExecutionListFile(),
-                                     cmOutputConverter::HOME);
-    out << "  " << lfc << "\n";
-
-    commandName = parent.GetEntryPointCommand();
-    commandLine = parent.GetEntryPointLine();
-    parent = parent.GetCallStackParent();
+    cmListFileContext lfc = *i;
+    if (!this->Bottom.GetState()->GetIsInTryCompile()) {
+      lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
     }
+    out << "  " << lfc << "\n";
+  }
 }
 
-//----------------------------------------------------------------------------
 std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
 {
   os << lfc.FilePath;
-  if(lfc.Line)
-    {
+  if (lfc.Line) {
     os << ":" << lfc.Line;
-    if(!lfc.Name.empty())
-      {
+    if (!lfc.Name.empty()) {
       os << " (" << lfc.Name << ")";
-      }
     }
+  }
   return os;
 }
 
 bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs)
 {
-  if(lhs.Line != rhs.Line)
-    {
+  if (lhs.Line != rhs.Line) {
     return lhs.Line < rhs.Line;
-    }
+  }
   return lhs.FilePath < rhs.FilePath;
 }
 
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 03e0abe..d72c360 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -29,41 +29,61 @@ struct cmCommandContext
 {
   std::string Name;
   long Line;
-  cmCommandContext(): Name(), Line(0) {}
+  cmCommandContext()
+    : Name()
+    , Line(0)
+  {
+  }
 };
 
 struct cmListFileArgument
 {
   enum Delimiter
-    {
+  {
     Unquoted,
     Quoted,
     Bracket
-    };
-  cmListFileArgument(): Value(), Delim(Unquoted), Line(0) {}
+  };
+  cmListFileArgument()
+    : Value()
+    , Delim(Unquoted)
+    , Line(0)
+  {
+  }
   cmListFileArgument(const cmListFileArgument& r)
-    : Value(r.Value), Delim(r.Delim), Line(r.Line) {}
+    : Value(r.Value)
+    , Delim(r.Delim)
+    , Line(r.Line)
+  {
+  }
   cmListFileArgument(const std::string& v, Delimiter d, long line)
-    : Value(v), Delim(d), Line(line) {}
-  bool operator == (const cmListFileArgument& r) const
-    {
+    : Value(v)
+    , Delim(d)
+    , Line(line)
+  {
+  }
+  bool operator==(const cmListFileArgument& r) const
+  {
     return (this->Value == r.Value) && (this->Delim == r.Delim);
-    }
-  bool operator != (const cmListFileArgument& r) const
-    {
-    return !(*this == r);
-    }
+  }
+  bool operator!=(const cmListFileArgument& r) const { return !(*this == r); }
   std::string Value;
   Delimiter Delim;
   long Line;
 };
 
-struct cmListFileContext
+class cmListFileContext
 {
+public:
   std::string Name;
   std::string FilePath;
   long Line;
-  cmListFileContext(): Name(), FilePath(), Line(0) {}
+  cmListFileContext()
+    : Name()
+    , FilePath()
+    , Line(0)
+  {
+  }
 
   static cmListFileContext FromCommandContext(cmCommandContext const& lfcc,
                                               std::string const& fileName)
@@ -81,30 +101,64 @@ bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
 bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
 bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
 
-struct cmListFileFunction: public cmCommandContext
+struct cmListFileFunction : public cmCommandContext
 {
   std::vector<cmListFileArgument> Arguments;
 };
 
+// Represent a backtrace (call stack).  Provide value semantics
+// but use efficient reference-counting underneath to avoid copies.
 class cmListFileBacktrace
 {
-  public:
-    cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
-                        cmCommandContext const& cc = cmCommandContext());
-    ~cmListFileBacktrace();
-
-    void PrintTitle(std::ostream& out) const;
-    void PrintCallStack(std::ostream& out) const;
-  private:
-    cmCommandContext Context;
-    cmState::Snapshot Snapshot;
+public:
+  // Default-constructed backtrace may not be used until after
+  // set via assignment from a backtrace constructed with a
+  // valid snapshot.
+  cmListFileBacktrace();
+
+  // Construct an empty backtrace whose bottom sits in the directory
+  // indicated by the given valid snapshot.
+  cmListFileBacktrace(cmState::Snapshot snapshot);
+
+  // Backtraces may be copied and assigned as values.
+  cmListFileBacktrace(cmListFileBacktrace const& r);
+  cmListFileBacktrace& operator=(cmListFileBacktrace const& r);
+  ~cmListFileBacktrace();
+
+  // Get a backtrace with the given file scope added to the top.
+  // May not be called until after construction with a valid snapshot.
+  cmListFileBacktrace Push(std::string const& file) const;
+
+  // Get a backtrace with the given call context added to the top.
+  // May not be called until after construction with a valid snapshot.
+  cmListFileBacktrace Push(cmListFileContext const& lfc) const;
+
+  // Get a backtrace with the top level removed.
+  // May not be called until after a matching Push.
+  cmListFileBacktrace Pop() const;
+
+  // Get the context at the top of the backtrace.
+  // Returns an empty context if the backtrace is empty.
+  cmListFileContext const& Top() const;
+
+  // Print the top of the backtrace.
+  void PrintTitle(std::ostream& out) const;
+
+  // Print the call stack below the top of the backtrace.
+  void PrintCallStack(std::ostream& out) const;
+
+private:
+  struct Entry;
+  cmState::Snapshot Bottom;
+  Entry* Cur;
+  cmListFileBacktrace(cmState::Snapshot bottom, Entry* up,
+                      cmListFileContext const& lfc);
+  cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur);
 };
 
 struct cmListFile
 {
-  bool ParseFile(const char* path,
-                 bool topLevel,
-                 cmMakefile *mf);
+  bool ParseFile(const char* path, bool topLevel, cmMakefile* mf);
 
   std::vector<cmListFileFunction> Functions;
 };
diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c
index af4fc3d..bc1666e 100644
--- a/Source/cmListFileLexer.c
+++ b/Source/cmListFileLexer.c
@@ -8,8 +8,8 @@
 
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 0
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -93,15 +93,15 @@ typedef unsigned int flex_uint32_t;
 /* The "const" storage-class-modifier is valid. */
 #define YY_USE_CONST
 
-#else   /* ! __cplusplus */
+#else	/* ! __cplusplus */
 
 /* C99 requires __STDC__ to be defined as 1. */
 #if defined (__STDC__)
 
 #define YY_USE_CONST
 
-#endif  /* defined (__STDC__) */
-#endif  /* ! __cplusplus */
+#endif	/* defined (__STDC__) */
+#endif	/* ! __cplusplus */
 
 #ifdef YY_USE_CONST
 #define yyconst const
@@ -179,6 +179,11 @@ typedef void* yyscan_t;
 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 #endif
 
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
 #define EOB_ACT_CONTINUE_SCAN 0
 #define EOB_ACT_END_OF_FILE 1
 #define EOB_ACT_LAST_MATCH 2
@@ -197,89 +202,93 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
                     if ( yytext[yyl] == '\n' )\
                         --yylineno;\
             }while(0)
+    #define YY_LINENO_REWIND_TO(dst) \
+            do {\
+                const char *p;\
+                for ( p = yy_cp-1; p >= (dst); --p)\
+                    if ( *p == '\n' )\
+                        --yylineno;\
+            }while(0)
 
 /* Return all but the first "n" matched characters back to the input stream. */
 #define yyless(n) \
-        do \
-                { \
-                /* Undo effects of setting up yytext. */ \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
         int yyless_macro_arg = (n); \
         YY_LESS_LINENO(yyless_macro_arg);\
-                *yy_cp = yyg->yy_hold_char; \
-                YY_RESTORE_YY_MORE_OFFSET \
-                yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
-                YY_DO_BEFORE_ACTION; /* set up yytext again */ \
-                } \
-        while ( 0 )
+		*yy_cp = yyg->yy_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		} \
+	while ( 0 )
 
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
+#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
 
 #ifndef YY_STRUCT_YY_BUFFER_STATE
 #define YY_STRUCT_YY_BUFFER_STATE
 struct yy_buffer_state
-        {
-        FILE *yy_input_file;
-
-        char *yy_ch_buf;                /* input buffer */
-        char *yy_buf_pos;               /* current position in input buffer */
-
-        /* Size of input buffer in bytes, not including room for EOB
-         * characters.
-         */
-        yy_size_t yy_buf_size;
-
-        /* Number of characters read into yy_ch_buf, not including EOB
-         * characters.
-         */
-        int yy_n_chars;
-
-        /* Whether we "own" the buffer - i.e., we know we created it,
-         * and can realloc() it to grow it, and should free() it to
-         * delete it.
-         */
-        int yy_is_our_buffer;
-
-        /* Whether this is an "interactive" input source; if so, and
-         * if we're using stdio for input, then we want to use getc()
-         * instead of fread(), to make sure we stop fetching input after
-         * each newline.
-         */
-        int yy_is_interactive;
-
-        /* Whether we're considered to be at the beginning of a line.
-         * If so, '^' rules will be active on the next match, otherwise
-         * not.
-         */
-        int yy_at_bol;
+	{
+	FILE *yy_input_file;
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
 
     int yy_bs_lineno; /**< The line count. */
     int yy_bs_column; /**< The column count. */
 
-        /* Whether to try to fill the input buffer when we reach the
-         * end of it.
-         */
-        int yy_fill_buffer;
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
 
-        int yy_buffer_status;
+	int yy_buffer_status;
 
 #define YY_BUFFER_NEW 0
 #define YY_BUFFER_NORMAL 1
-        /* When an EOF's been seen but there's still some text to process
-         * then we mark the buffer as YY_EOF_PENDING, to indicate that we
-         * shouldn't try reading from the input source any more.  We might
-         * still have a bunch of tokens to match, though, because of
-         * possible backing-up.
-         *
-         * When we actually see the EOF, we change the status to "new"
-         * (via cmListFileLexer_yyrestart()), so that the user can continue scanning by
-         * just pointing yyin at a new input file.
-         */
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via cmListFileLexer_yyrestart()), so that the user can continue scanning by
+	 * just pointing yyin at a new input file.
+	 */
 #define YY_BUFFER_EOF_PENDING 2
 
-        };
+	};
 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
 
 /* We provide macros for accessing buffer states in case in the
@@ -313,7 +322,7 @@ static void cmListFileLexer_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan
 
 YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
 YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
 
 void *cmListFileLexer_yyalloc (yy_size_t ,yyscan_t yyscanner );
 void *cmListFileLexer_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
@@ -322,30 +331,30 @@ void cmListFileLexer_yyfree (void * ,yyscan_t yyscanner );
 #define yy_new_buffer cmListFileLexer_yy_create_buffer
 
 #define yy_set_interactive(is_interactive) \
-        { \
-        if ( ! YY_CURRENT_BUFFER ){ \
+	{ \
+	if ( ! YY_CURRENT_BUFFER ){ \
         cmListFileLexer_yyensure_buffer_stack (yyscanner); \
-                YY_CURRENT_BUFFER_LVALUE =    \
+		YY_CURRENT_BUFFER_LVALUE =    \
             cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
-        } \
-        YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
-        }
+	} \
+	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+	}
 
 #define yy_set_bol(at_bol) \
-        { \
-        if ( ! YY_CURRENT_BUFFER ){\
+	{ \
+	if ( ! YY_CURRENT_BUFFER ){\
         cmListFileLexer_yyensure_buffer_stack (yyscanner); \
-                YY_CURRENT_BUFFER_LVALUE =    \
+		YY_CURRENT_BUFFER_LVALUE =    \
             cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
-        } \
-        YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
-        }
+	} \
+	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+	}
 
 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
 
 /* Begin user sect3 */
 
-#define cmListFileLexer_yywrap(n) 1
+#define cmListFileLexer_yywrap(yyscanner) (/*CONSTCOND*/1)
 #define YY_SKIP_YYWRAP
 
 typedef unsigned char YY_CHAR;
@@ -357,27 +366,30 @@ typedef int yy_state_type;
 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
 static int yy_get_next_buffer (yyscan_t yyscanner );
+#if defined(__GNUC__) && __GNUC__ >= 3
+__attribute__((__noreturn__))
+#endif
 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
 
 /* Done after the current pattern has been matched and before the
  * corresponding action - sets up yytext.
  */
 #define YY_DO_BEFORE_ACTION \
-        yyg->yytext_ptr = yy_bp; \
-        yyleng = (size_t) (yy_cp - yy_bp); \
-        yyg->yy_hold_char = *yy_cp; \
-        *yy_cp = '\0'; \
-        yyg->yy_c_buf_p = yy_cp;
+	yyg->yytext_ptr = yy_bp; \
+	yyleng = (size_t) (yy_cp - yy_bp); \
+	yyg->yy_hold_char = *yy_cp; \
+	*yy_cp = '\0'; \
+	yyg->yy_c_buf_p = yy_cp;
 
 #define YY_NUM_RULES 24
 #define YY_END_OF_BUFFER 25
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
-        {
-        flex_int32_t yy_verify;
-        flex_int32_t yy_nxt;
-        };
+	{
+	flex_int32_t yy_verify;
+	flex_int32_t yy_nxt;
+	};
 static yyconst flex_int16_t yy_accept[77] =
     {   0,
         0,    0,    0,    0,    0,    0,    0,    0,    4,    4,
@@ -390,7 +402,7 @@ static yyconst flex_int16_t yy_accept[77] =
         0,    0,    0,    0,    0,    0
     } ;
 
-static yyconst flex_int32_t yy_ec[256] =
+static yyconst YY_CHAR yy_ec[256] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
         1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
@@ -422,13 +434,13 @@ static yyconst flex_int32_t yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static yyconst flex_int32_t yy_meta[16] =
+static yyconst YY_CHAR yy_meta[16] =
     {   0,
         1,    1,    2,    3,    4,    3,    1,    3,    5,    6,
         1,    6,    1,    1,    7
     } ;
 
-static yyconst flex_int16_t yy_base[95] =
+static yyconst flex_uint16_t yy_base[95] =
     {   0,
         0,    0,   13,   25,   14,   16,   17,   18,   90,   88,
        88,   39,   20,  237,  237,   74,   78,  237,  237,   13,
@@ -458,7 +470,7 @@ static yyconst flex_int16_t yy_def[95] =
 
     } ;
 
-static yyconst flex_int16_t yy_nxt[253] =
+static yyconst flex_uint16_t yy_nxt[253] =
     {   0,
        12,   13,   14,   13,   15,   16,   17,   18,   19,   12,
        12,   20,   21,   22,   12,   24,   28,   25,   28,   28,
@@ -552,19 +564,16 @@ static yyconst flex_int32_t yy_rule_can_match_eol[25] =
 
 This file must be translated to C and modified to build everywhere.
 
-Run flex like this:
+Run flex >= 2.6 like this:
 
   flex --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l
 
 Modify cmListFileLexer.c:
-  - remove TABs
-  - remove use of the 'register' storage class specifier
-  - remove the yyunput function
-  - add a statement "(void)yyscanner;" to the top of these methods:
-      yy_fatal_error, cmListFileLexer_yyalloc, cmListFileLexer_yyrealloc, cmListFileLexer_yyfree
+  - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
+  - remove blank lines at end of file
   - remove statement "yyscanner = NULL;" from cmListFileLexer_yylex_destroy
   - remove all YY_BREAK lines occurring right after return statements
-  - remove the isatty forward declaration
+  - remove unnecessary cast to (int) in yy_get_next_buffer
 
 */
 
@@ -583,7 +592,7 @@ Modify cmListFileLexer.c:
 struct cmListFileLexer_s
 {
   cmListFileLexer_Token token;
-  int bracket;
+  yy_size_t bracket;
   int comment;
   int line;
   int column;
@@ -649,7 +658,7 @@ struct yyguts_t
     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
     char yy_hold_char;
     int yy_n_chars;
-    int yyleng_r;
+    yy_size_t yyleng_r;
     char *yy_c_buf_p;
     int yy_init;
     int yy_start;
@@ -690,23 +699,23 @@ void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner
 
 FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner );
 
-void cmListFileLexer_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
+void cmListFileLexer_yyset_in  (FILE * _in_str ,yyscan_t yyscanner );
 
 FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner );
 
-void cmListFileLexer_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
+void cmListFileLexer_yyset_out  (FILE * _out_str ,yyscan_t yyscanner );
 
-int cmListFileLexer_yyget_leng (yyscan_t yyscanner );
+yy_size_t cmListFileLexer_yyget_leng (yyscan_t yyscanner );
 
 char *cmListFileLexer_yyget_text (yyscan_t yyscanner );
 
 int cmListFileLexer_yyget_lineno (yyscan_t yyscanner );
 
-void cmListFileLexer_yyset_lineno (int line_number ,yyscan_t yyscanner );
+void cmListFileLexer_yyset_lineno (int _line_number ,yyscan_t yyscanner );
 
 int cmListFileLexer_yyget_column  (yyscan_t yyscanner );
 
-void cmListFileLexer_yyset_column (int column_no ,yyscan_t yyscanner );
+void cmListFileLexer_yyset_column (int _column_no ,yyscan_t yyscanner );
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -720,6 +729,12 @@ extern int cmListFileLexer_yywrap (yyscan_t yyscanner );
 #endif
 #endif
 
+#ifndef YY_NO_UNPUT
+
+    static void yyunput (int c,char *buf_ptr  ,yyscan_t yyscanner);
+
+#endif
+
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
 #endif
@@ -761,33 +776,33 @@ static int input (yyscan_t yyscanner );
  */
 #ifndef YY_INPUT
 #define YY_INPUT(buf,result,max_size) \
-        if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
-                { \
-                int c = '*'; \
-                size_t n; \
-                for ( n = 0; n < max_size && \
-                             (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
-                        buf[n] = (char) c; \
-                if ( c == '\n' ) \
-                        buf[n++] = (char) c; \
-                if ( c == EOF && ferror( yyin ) ) \
-                        YY_FATAL_ERROR( "input in flex scanner failed" ); \
-                result = n; \
-                } \
-        else \
-                { \
-                errno=0; \
-                while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
-                        { \
-                        if( errno != EINTR) \
-                                { \
-                                YY_FATAL_ERROR( "input in flex scanner failed" ); \
-                                break; \
-                                } \
-                        errno=0; \
-                        clearerr(yyin); \
-                        } \
-                }\
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+		{ \
+		int c = '*'; \
+		size_t n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( yyin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else \
+		{ \
+		errno=0; \
+		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+			{ \
+			if( errno != EINTR) \
+				{ \
+				YY_FATAL_ERROR( "input in flex scanner failed" ); \
+				break; \
+				} \
+			errno=0; \
+			clearerr(yyin); \
+			} \
+		}\
 \
 
 #endif
@@ -832,123 +847,124 @@ extern int cmListFileLexer_yylex (yyscan_t yyscanner);
 
 /* Code executed at the end of each rule. */
 #ifndef YY_BREAK
-#define YY_BREAK break;
+#define YY_BREAK /*LINTED*/break;
 #endif
 
 #define YY_RULE_SETUP \
-        YY_USER_ACTION
+	YY_USER_ACTION
 
 /** The main scanner function which does all the work.
  */
 YY_DECL
 {
-        yy_state_type yy_current_state;
-        char *yy_cp, *yy_bp;
-        int yy_act;
+	yy_state_type yy_current_state;
+	char *yy_cp, *yy_bp;
+	int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 91 "cmListFileLexer.in.l"
+	if ( !yyg->yy_init )
+		{
+		yyg->yy_init = 1;
 
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
 
-#line 865 "cmListFileLexer.c"
+		if ( ! yyg->yy_start )
+			yyg->yy_start = 1;	/* first start state */
 
-        if ( !yyg->yy_init )
-                {
-                yyg->yy_init = 1;
+		if ( ! yyin )
+			yyin = stdin;
 
-#ifdef YY_USER_INIT
-                YY_USER_INIT;
-#endif
+		if ( ! yyout )
+			yyout = stdout;
 
-                if ( ! yyg->yy_start )
-                        yyg->yy_start = 1;      /* first start state */
+		if ( ! YY_CURRENT_BUFFER ) {
+			cmListFileLexer_yyensure_buffer_stack (yyscanner);
+			YY_CURRENT_BUFFER_LVALUE =
+				cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+		}
 
-                if ( ! yyin )
-                        yyin = stdin;
+		cmListFileLexer_yy_load_buffer_state(yyscanner );
+		}
 
-                if ( ! yyout )
-                        yyout = stdout;
+	{
+#line 88 "cmListFileLexer.in.l"
 
-                if ( ! YY_CURRENT_BUFFER ) {
-                        cmListFileLexer_yyensure_buffer_stack (yyscanner);
-                        YY_CURRENT_BUFFER_LVALUE =
-                                cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
-                }
 
-                cmListFileLexer_yy_load_buffer_state(yyscanner );
-                }
+#line 896 "cmListFileLexer.c"
 
-        while ( 1 )             /* loops until end-of-file is reached */
-                {
-                yy_cp = yyg->yy_c_buf_p;
+	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
+		{
+		yy_cp = yyg->yy_c_buf_p;
 
-                /* Support of yytext. */
-                *yy_cp = yyg->yy_hold_char;
+		/* Support of yytext. */
+		*yy_cp = yyg->yy_hold_char;
 
-                /* yy_bp points to the position in yy_ch_buf of the start of
-                 * the current run.
-                 */
-                yy_bp = yy_cp;
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
 
-                yy_current_state = yyg->yy_start;
+		yy_current_state = yyg->yy_start;
 yy_match:
-                do
-                        {
-                        YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
-                        if ( yy_accept[yy_current_state] )
-                                {
-                                yyg->yy_last_accepting_state = yy_current_state;
-                                yyg->yy_last_accepting_cpos = yy_cp;
-                                }
-                        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-                                {
-                                yy_current_state = (int) yy_def[yy_current_state];
-                                if ( yy_current_state >= 77 )
-                                        yy_c = yy_meta[(unsigned int) yy_c];
-                                }
-                        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-                        ++yy_cp;
-                        }
-                while ( yy_base[yy_current_state] != 237 );
+		do
+			{
+			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+			if ( yy_accept[yy_current_state] )
+				{
+				yyg->yy_last_accepting_state = yy_current_state;
+				yyg->yy_last_accepting_cpos = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 77 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_base[yy_current_state] != 237 );
 
 yy_find_action:
-                yy_act = yy_accept[yy_current_state];
-                if ( yy_act == 0 )
-                        { /* have to back up */
-                        yy_cp = yyg->yy_last_accepting_cpos;
-                        yy_current_state = yyg->yy_last_accepting_state;
-                        yy_act = yy_accept[yy_current_state];
-                        }
-
-                YY_DO_BEFORE_ACTION;
-
-                if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
-                        {
-                        int yyl;
-                        for ( yyl = 0; yyl < yyleng; ++yyl )
-                                if ( yytext[yyl] == '\n' )
+		yy_act = yy_accept[yy_current_state];
+		if ( yy_act == 0 )
+			{ /* have to back up */
+			yy_cp = yyg->yy_last_accepting_cpos;
+			yy_current_state = yyg->yy_last_accepting_state;
+			yy_act = yy_accept[yy_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+			{
+			yy_size_t yyl;
+			for ( yyl = 0; yyl < yyleng; ++yyl )
+				if ( yytext[yyl] == '\n' )
 
     do{ yylineno++;
         yycolumn=0;
     }while(0)
 ;
-                        }
+			}
 
-do_action:      /* This label is used only to access EOF actions. */
+do_action:	/* This label is used only to access EOF actions. */
 
-                switch ( yy_act )
-        { /* beginning of action switch */
-                        case 0: /* must back up */
-                        /* undo the effects of YY_DO_BEFORE_ACTION */
-                        *yy_cp = yyg->yy_hold_char;
-                        yy_cp = yyg->yy_last_accepting_cpos;
-                        yy_current_state = yyg->yy_last_accepting_state;
-                        goto yy_find_action;
+		switch ( yy_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = yyg->yy_hold_char;
+			yy_cp = yyg->yy_last_accepting_cpos;
+			yy_current_state = yyg->yy_last_accepting_state;
+			goto yy_find_action;
 
 case 1:
 /* rule 1 can match eol */
 YY_RULE_SETUP
-#line 93 "cmListFileLexer.in.l"
+#line 90 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_Newline;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -960,51 +976,45 @@ YY_RULE_SETUP
 case 2:
 /* rule 2 can match eol */
 YY_RULE_SETUP
-#line 102 "cmListFileLexer.in.l"
+#line 99 "cmListFileLexer.in.l"
 {
   const char* bracket = yytext;
   lexer->comment = yytext[0] == '#';
-  if(lexer->comment)
-    {
+  if (lexer->comment) {
     lexer->token.type = cmListFileLexer_Token_CommentBracket;
     bracket += 1;
-    }
-  else
-    {
+  } else {
     lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
-    }
+  }
   cmListFileLexerSetToken(lexer, "", 0);
-  lexer->bracket = (int)(strchr(bracket+1, '[') - bracket);
-  if(yytext[yyleng-1] == '\n')
-    {
+  lexer->bracket = strchr(bracket+1, '[') - bracket;
+  if (yytext[yyleng-1] == '\n') {
     ++lexer->line;
     lexer->column = 1;
-    }
-  else
-    {
+  } else {
     lexer->column += yyleng;
-    }
+  }
   BEGIN(BRACKET);
 }
-        YY_BREAK
+	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 128 "cmListFileLexer.in.l"
+#line 119 "cmListFileLexer.in.l"
 {
   lexer->column += yyleng;
   BEGIN(COMMENT);
 }
-        YY_BREAK
+	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 133 "cmListFileLexer.in.l"
+#line 124 "cmListFileLexer.in.l"
 {
   lexer->column += yyleng;
 }
-        YY_BREAK
+	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 137 "cmListFileLexer.in.l"
+#line 128 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_ParenLeft;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1013,7 +1023,7 @@ YY_RULE_SETUP
 }
 case 6:
 YY_RULE_SETUP
-#line 144 "cmListFileLexer.in.l"
+#line 135 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_ParenRight;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1022,7 +1032,7 @@ YY_RULE_SETUP
 }
 case 7:
 YY_RULE_SETUP
-#line 151 "cmListFileLexer.in.l"
+#line 142 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_Identifier;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1031,20 +1041,19 @@ YY_RULE_SETUP
 }
 case 8:
 YY_RULE_SETUP
-#line 158 "cmListFileLexer.in.l"
+#line 149 "cmListFileLexer.in.l"
 {
   /* Handle ]]====]=======]*/
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
-  if(yyleng == lexer->bracket)
-    {
+  if (yyleng == lexer->bracket) {
     BEGIN(BRACKETEND);
-    }
+  }
 }
-        YY_BREAK
+	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 168 "cmListFileLexer.in.l"
+#line 158 "cmListFileLexer.in.l"
 {
   lexer->column += yyleng;
   /* Erase the partial bracket from the token.  */
@@ -1055,35 +1064,35 @@ YY_RULE_SETUP
 }
 case 10:
 YY_RULE_SETUP
-#line 177 "cmListFileLexer.in.l"
+#line 167 "cmListFileLexer.in.l"
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
 }
-        YY_BREAK
+	YY_BREAK
 case 11:
 /* rule 11 can match eol */
 YY_RULE_SETUP
-#line 182 "cmListFileLexer.in.l"
+#line 172 "cmListFileLexer.in.l"
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   ++lexer->line;
   lexer->column = 1;
   BEGIN(BRACKET);
 }
-        YY_BREAK
+	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 189 "cmListFileLexer.in.l"
+#line 179 "cmListFileLexer.in.l"
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
   BEGIN(BRACKET);
 }
-        YY_BREAK
+	YY_BREAK
 case YY_STATE_EOF(BRACKET):
 case YY_STATE_EOF(BRACKETEND):
-#line 195 "cmListFileLexer.in.l"
+#line 185 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_BadBracket;
   BEGIN(INITIAL);
@@ -1091,7 +1100,7 @@ case YY_STATE_EOF(BRACKETEND):
 }
 case 13:
 YY_RULE_SETUP
-#line 201 "cmListFileLexer.in.l"
+#line 191 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1100,7 +1109,7 @@ YY_RULE_SETUP
 }
 case 14:
 YY_RULE_SETUP
-#line 208 "cmListFileLexer.in.l"
+#line 198 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1109,7 +1118,7 @@ YY_RULE_SETUP
 }
 case 15:
 YY_RULE_SETUP
-#line 215 "cmListFileLexer.in.l"
+#line 205 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1118,45 +1127,45 @@ YY_RULE_SETUP
 }
 case 16:
 YY_RULE_SETUP
-#line 222 "cmListFileLexer.in.l"
+#line 212 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
   cmListFileLexerSetToken(lexer, "", 0);
   lexer->column += yyleng;
   BEGIN(STRING);
 }
-        YY_BREAK
+	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 229 "cmListFileLexer.in.l"
+#line 219 "cmListFileLexer.in.l"
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
 }
-        YY_BREAK
+	YY_BREAK
 case 18:
 /* rule 18 can match eol */
 YY_RULE_SETUP
-#line 234 "cmListFileLexer.in.l"
+#line 224 "cmListFileLexer.in.l"
 {
   /* Continuation: text is not part of string */
   ++lexer->line;
   lexer->column = 1;
 }
-        YY_BREAK
+	YY_BREAK
 case 19:
 /* rule 19 can match eol */
 YY_RULE_SETUP
-#line 240 "cmListFileLexer.in.l"
+#line 230 "cmListFileLexer.in.l"
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   ++lexer->line;
   lexer->column = 1;
 }
-        YY_BREAK
+	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 246 "cmListFileLexer.in.l"
+#line 236 "cmListFileLexer.in.l"
 {
   lexer->column += yyleng;
   BEGIN(INITIAL);
@@ -1164,14 +1173,14 @@ YY_RULE_SETUP
 }
 case 21:
 YY_RULE_SETUP
-#line 252 "cmListFileLexer.in.l"
+#line 242 "cmListFileLexer.in.l"
 {
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
 }
-        YY_BREAK
+	YY_BREAK
 case YY_STATE_EOF(STRING):
-#line 257 "cmListFileLexer.in.l"
+#line 247 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_BadString;
   BEGIN(INITIAL);
@@ -1179,7 +1188,7 @@ case YY_STATE_EOF(STRING):
 }
 case 22:
 YY_RULE_SETUP
-#line 263 "cmListFileLexer.in.l"
+#line 253 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_Space;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1188,7 +1197,7 @@ YY_RULE_SETUP
 }
 case 23:
 YY_RULE_SETUP
-#line 270 "cmListFileLexer.in.l"
+#line 260 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_BadCharacter;
   cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1197,7 +1206,7 @@ YY_RULE_SETUP
 }
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(COMMENT):
-#line 277 "cmListFileLexer.in.l"
+#line 267 "cmListFileLexer.in.l"
 {
   lexer->token.type = cmListFileLexer_Token_None;
   cmListFileLexerSetToken(lexer, 0, 0);
@@ -1205,339 +1214,387 @@ case YY_STATE_EOF(COMMENT):
 }
 case 24:
 YY_RULE_SETUP
-#line 283 "cmListFileLexer.in.l"
+#line 273 "cmListFileLexer.in.l"
 ECHO;
-        YY_BREAK
-#line 1238 "cmListFileLexer.c"
-
-        case YY_END_OF_BUFFER:
-                {
-                /* Amount of text matched not including the EOB char. */
-                int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
-
-                /* Undo the effects of YY_DO_BEFORE_ACTION. */
-                *yy_cp = yyg->yy_hold_char;
-                YY_RESTORE_YY_MORE_OFFSET
-
-                if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
-                        {
-                        /* We're scanning a new file or input source.  It's
-                         * possible that this happened because the user
-                         * just pointed yyin at a new source and called
-                         * cmListFileLexer_yylex().  If so, then we have to assure
-                         * consistency between YY_CURRENT_BUFFER and our
-                         * globals.  Here is the right place to do so, because
-                         * this is the first action (other than possibly a
-                         * back-up) that will match for the new input source.
-                         */
-                        yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
-                        YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
-                        YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
-                        }
-
-                /* Note that here we test for yy_c_buf_p "<=" to the position
-                 * of the first EOB in the buffer, since yy_c_buf_p will
-                 * already have been incremented past the NUL character
-                 * (since all states make transitions on EOB to the
-                 * end-of-buffer state).  Contrast this with the test
-                 * in input().
-                 */
-                if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
-                        { /* This was really a NUL. */
-                        yy_state_type yy_next_state;
-
-                        yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
-
-                        yy_current_state = yy_get_previous_state( yyscanner );
-
-                        /* Okay, we're now positioned to make the NUL
-                         * transition.  We couldn't have
-                         * yy_get_previous_state() go ahead and do it
-                         * for us because it doesn't know how to deal
-                         * with the possibility of jamming (and we don't
-                         * want to build jamming into it because then it
-                         * will run more slowly).
-                         */
-
-                        yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
-
-                        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
-
-                        if ( yy_next_state )
-                                {
-                                /* Consume the NUL. */
-                                yy_cp = ++yyg->yy_c_buf_p;
-                                yy_current_state = yy_next_state;
-                                goto yy_match;
-                                }
-
-                        else
-                                {
-                                yy_cp = yyg->yy_c_buf_p;
-                                goto yy_find_action;
-                                }
-                        }
-
-                else switch ( yy_get_next_buffer( yyscanner ) )
-                        {
-                        case EOB_ACT_END_OF_FILE:
-                                {
-                                yyg->yy_did_buffer_switch_on_eof = 0;
-
-                                if ( cmListFileLexer_yywrap(yyscanner ) )
-                                        {
-                                        /* Note: because we've taken care in
-                                         * yy_get_next_buffer() to have set up
-                                         * yytext, we can now set up
-                                         * yy_c_buf_p so that if some total
-                                         * hoser (like flex itself) wants to
-                                         * call the scanner after we return the
-                                         * YY_NULL, it'll still work - another
-                                         * YY_NULL will get returned.
-                                         */
-                                        yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
-
-                                        yy_act = YY_STATE_EOF(YY_START);
-                                        goto do_action;
-                                        }
-
-                                else
-                                        {
-                                        if ( ! yyg->yy_did_buffer_switch_on_eof )
-                                                YY_NEW_FILE;
-                                        }
-                                break;
-                                }
-
-                        case EOB_ACT_CONTINUE_SCAN:
-                                yyg->yy_c_buf_p =
-                                        yyg->yytext_ptr + yy_amount_of_matched_text;
-
-                                yy_current_state = yy_get_previous_state( yyscanner );
-
-                                yy_cp = yyg->yy_c_buf_p;
-                                yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
-                                goto yy_match;
-
-                        case EOB_ACT_LAST_MATCH:
-                                yyg->yy_c_buf_p =
-                                &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
-
-                                yy_current_state = yy_get_previous_state( yyscanner );
-
-                                yy_cp = yyg->yy_c_buf_p;
-                                yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
-                                goto yy_find_action;
-                        }
-                break;
-                }
-
-        default:
-                YY_FATAL_ERROR(
-                        "fatal flex scanner internal error--no action found" );
-        } /* end of action switch */
-                } /* end of scanning one token */
+	YY_BREAK
+#line 1235 "cmListFileLexer.c"
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = yyg->yy_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed yyin at a new source and called
+			 * cmListFileLexer_yylex().  If so, then we have to assure
+			 * consistency between YY_CURRENT_BUFFER and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state( yyscanner );
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
+
+			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++yyg->yy_c_buf_p;
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+				yy_cp = yyg->yy_c_buf_p;
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer( yyscanner ) )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				yyg->yy_did_buffer_switch_on_eof = 0;
+
+				if ( cmListFileLexer_yywrap(yyscanner ) )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * yytext, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! yyg->yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				yyg->yy_c_buf_p =
+					yyg->yytext_ptr + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state( yyscanner );
+
+				yy_cp = yyg->yy_c_buf_p;
+				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				yyg->yy_c_buf_p =
+				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
+
+				yy_current_state = yy_get_previous_state( yyscanner );
+
+				yy_cp = yyg->yy_c_buf_p;
+				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of user's declarations */
 } /* end of cmListFileLexer_yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
  *
  * Returns a code representing an action:
- *      EOB_ACT_LAST_MATCH -
- *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- *      EOB_ACT_END_OF_FILE - end of file
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
  */
 static int yy_get_next_buffer (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-        char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
-        char *source = yyg->yytext_ptr;
-        int number_to_move, i;
-        int ret_val;
-
-        if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
-                YY_FATAL_ERROR(
-                "fatal flex scanner internal error--end of buffer missed" );
-
-        if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
-                { /* Don't try to fill the buffer, so this is an EOF. */
-                if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
-                        {
-                        /* We matched a single character, the EOB, so
-                         * treat this as a final EOF.
-                         */
-                        return EOB_ACT_END_OF_FILE;
-                        }
-
-                else
-                        {
-                        /* We matched some text prior to the EOB, first
-                         * process it.
-                         */
-                        return EOB_ACT_LAST_MATCH;
-                        }
-                }
-
-        /* Try to read more data. */
-
-        /* First move last chars to start of buffer. */
-        number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
-
-        for ( i = 0; i < number_to_move; ++i )
-                *(dest++) = *(source++);
-
-        if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
-                /* don't do the read, it's not guaranteed to return an EOF,
-                 * just force an EOF
-                 */
-                YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
-
-        else
-                {
-                        int num_to_read =
-                        YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
-                while ( num_to_read <= 0 )
-                        { /* Not enough room in the buffer - grow it. */
-
-                        /* just a shorter name for the current buffer */
-                        YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
-                        int yy_c_buf_p_offset =
-                                (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
-
-                        if ( b->yy_is_our_buffer )
-                                {
-                                int new_size = b->yy_buf_size * 2;
-
-                                if ( new_size <= 0 )
-                                        b->yy_buf_size += b->yy_buf_size / 8;
-                                else
-                                        b->yy_buf_size *= 2;
-
-                                b->yy_ch_buf = (char *)
-                                        /* Include room in for 2 EOB chars. */
-                                        cmListFileLexer_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
-                                }
-                        else
-                                /* Can't grow it, we don't own it. */
-                                b->yy_ch_buf = 0;
-
-                        if ( ! b->yy_ch_buf )
-                                YY_FATAL_ERROR(
-                                "fatal error - scanner input buffer overflow" );
-
-                        yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
-                        num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
-                                                number_to_move - 1;
-
-                        }
-
-                if ( num_to_read > YY_READ_BUF_SIZE )
-                        num_to_read = YY_READ_BUF_SIZE;
-
-                /* Read in more data. */
-                YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
-                        yyg->yy_n_chars, (size_t) num_to_read );
-
-                YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
-                }
-
-        if ( yyg->yy_n_chars == 0 )
-                {
-                if ( number_to_move == YY_MORE_ADJ )
-                        {
-                        ret_val = EOB_ACT_END_OF_FILE;
-                        cmListFileLexer_yyrestart(yyin  ,yyscanner);
-                        }
-
-                else
-                        {
-                        ret_val = EOB_ACT_LAST_MATCH;
-                        YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
-                                YY_BUFFER_EOF_PENDING;
-                        }
-                }
-
-        else
-                ret_val = EOB_ACT_CONTINUE_SCAN;
-
-        if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
-                /* Extend the array by 50%, plus the number we really need. */
-                yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
-                YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmListFileLexer_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
-                if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
-                        YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
-        }
+	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+	char *source = yyg->yytext_ptr;
+	yy_size_t number_to_move, i;
+	int ret_val;
+
+	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
+
+	else
+		{
+			yy_size_t num_to_read =
+			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
+
+			int yy_c_buf_p_offset =
+				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				yy_size_t new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					cmListFileLexer_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+						number_to_move - 1;
+
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+			yyg->yy_n_chars, num_to_read );
+
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+		}
+
+	if ( yyg->yy_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			cmListFileLexer_yyrestart(yyin  ,yyscanner);
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+		/* Extend the array by 50%, plus the number we really need. */
+		int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmListFileLexer_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+	}
 
-        yyg->yy_n_chars += number_to_move;
-        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
-        YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+	yyg->yy_n_chars += number_to_move;
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
 
-        yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
 
-        return ret_val;
+	return ret_val;
 }
 
 /* yy_get_previous_state - get the state just before the EOB char was reached */
 
     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
 {
-        yy_state_type yy_current_state;
-        char *yy_cp;
+	yy_state_type yy_current_state;
+	char *yy_cp;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        yy_current_state = yyg->yy_start;
+	yy_current_state = yyg->yy_start;
 
-        for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
-                {
-                YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
-                if ( yy_accept[yy_current_state] )
-                        {
-                        yyg->yy_last_accepting_state = yy_current_state;
-                        yyg->yy_last_accepting_cpos = yy_cp;
-                        }
-                while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-                        {
-                        yy_current_state = (int) yy_def[yy_current_state];
-                        if ( yy_current_state >= 77 )
-                                yy_c = yy_meta[(unsigned int) yy_c];
-                        }
-                yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-                }
+	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
+		{
+		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		if ( yy_accept[yy_current_state] )
+			{
+			yyg->yy_last_accepting_state = yy_current_state;
+			yyg->yy_last_accepting_cpos = yy_cp;
+			}
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 77 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		}
 
-        return yy_current_state;
+	return yy_current_state;
 }
 
 /* yy_try_NUL_trans - try to make a transition on the NUL character
  *
  * synopsis
- *      next_state = yy_try_NUL_trans( current_state );
+ *	next_state = yy_try_NUL_trans( current_state );
  */
     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
 {
-        int yy_is_jam;
+	int yy_is_jam;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
-        char *yy_cp = yyg->yy_c_buf_p;
-
-        YY_CHAR yy_c = 1;
-        if ( yy_accept[yy_current_state] )
-                {
-                yyg->yy_last_accepting_state = yy_current_state;
-                yyg->yy_last_accepting_cpos = yy_cp;
-                }
-        while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-                {
-                yy_current_state = (int) yy_def[yy_current_state];
-                if ( yy_current_state >= 77 )
-                        yy_c = yy_meta[(unsigned int) yy_c];
-                }
-        yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-        yy_is_jam = (yy_current_state == 76);
-
-        return yy_is_jam ? 0 : yy_current_state;
+	char *yy_cp = yyg->yy_c_buf_p;
+
+	YY_CHAR yy_c = 1;
+	if ( yy_accept[yy_current_state] )
+		{
+		yyg->yy_last_accepting_state = yy_current_state;
+		yyg->yy_last_accepting_cpos = yy_cp;
+		}
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 77 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 76);
+
+	(void)yyg;
+	return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_UNPUT
+
+    static void yyunput (int c, char * yy_bp , yyscan_t yyscanner)
+{
+	char *yy_cp;
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+    yy_cp = yyg->yy_c_buf_p;
+
+	/* undo effects of setting up yytext */
+	*yy_cp = yyg->yy_hold_char;
+
+	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		yy_size_t number_to_move = yyg->yy_n_chars + 2;
+		char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
+		char *source =
+				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
+
+		while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+			*--dest = *--source;
+
+		yy_cp += (int) (dest - source);
+		yy_bp += (int) (dest - source);
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
+
+		if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--yy_cp = (char) c;
+
+    if ( c == '\n' ){
+        --yylineno;
+    }
+
+	yyg->yytext_ptr = yy_bp;
+	yyg->yy_hold_char = *yy_cp;
+	yyg->yy_c_buf_p = yy_cp;
 }
 
+#endif
+
 #ifndef YY_NO_INPUT
 #ifdef __cplusplus
     static int yyinput (yyscan_t yyscanner)
@@ -1546,79 +1603,79 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 #endif
 
 {
-        int c;
+	int c;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        *yyg->yy_c_buf_p = yyg->yy_hold_char;
-
-        if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
-                {
-                /* yy_c_buf_p now points to the character we want to return.
-                 * If this occurs *before* the EOB characters, then it's a
-                 * valid NUL; if not, then we've hit the end of the buffer.
-                 */
-                if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
-                        /* This was really a NUL. */
-                        *yyg->yy_c_buf_p = '\0';
-
-                else
-                        { /* need more input */
-                        int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
-                        ++yyg->yy_c_buf_p;
-
-                        switch ( yy_get_next_buffer( yyscanner ) )
-                                {
-                                case EOB_ACT_LAST_MATCH:
-                                        /* This happens because yy_g_n_b()
-                                         * sees that we've accumulated a
-                                         * token and flags that we need to
-                                         * try matching the token before
-                                         * proceeding.  But for input(),
-                                         * there's no matching to consider.
-                                         * So convert the EOB_ACT_LAST_MATCH
-                                         * to EOB_ACT_END_OF_FILE.
-                                         */
-
-                                        /* Reset buffer status. */
-                                        cmListFileLexer_yyrestart(yyin ,yyscanner);
-
-                                        /*FALLTHROUGH*/
-
-                                case EOB_ACT_END_OF_FILE:
-                                        {
-                                        if ( cmListFileLexer_yywrap(yyscanner ) )
-                                                return EOF;
-
-                                        if ( ! yyg->yy_did_buffer_switch_on_eof )
-                                                YY_NEW_FILE;
+	*yyg->yy_c_buf_p = yyg->yy_hold_char;
+
+	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+			/* This was really a NUL. */
+			*yyg->yy_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+			++yyg->yy_c_buf_p;
+
+			switch ( yy_get_next_buffer( yyscanner ) )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					cmListFileLexer_yyrestart(yyin ,yyscanner);
+
+					/*FALLTHROUGH*/
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( cmListFileLexer_yywrap(yyscanner ) )
+						return EOF;
+
+					if ( ! yyg->yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
 #ifdef __cplusplus
-                                        return yyinput(yyscanner);
+					return yyinput(yyscanner);
 #else
-                                        return input(yyscanner);
+					return input(yyscanner);
 #endif
-                                        }
+					}
 
-                                case EOB_ACT_CONTINUE_SCAN:
-                                        yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
-                                        break;
-                                }
-                        }
-                }
+				case EOB_ACT_CONTINUE_SCAN:
+					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
+					break;
+				}
+			}
+		}
 
-        c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
-        *yyg->yy_c_buf_p = '\0';        /* preserve yytext */
-        yyg->yy_hold_char = *++yyg->yy_c_buf_p;
+	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
+	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
+	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
 
-        if ( c == '\n' )
+	if ( c == '\n' )
 
     do{ yylineno++;
         yycolumn=0;
     }while(0)
 ;
 
-        return c;
+	return c;
 }
-#endif  /* ifndef YY_NO_INPUT */
+#endif	/* ifndef YY_NO_INPUT */
 
 /** Immediately switch to a different input stream.
  * @param input_file A readable stream.
@@ -1629,14 +1686,14 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        if ( ! YY_CURRENT_BUFFER ){
+	if ( ! YY_CURRENT_BUFFER ){
         cmListFileLexer_yyensure_buffer_stack (yyscanner);
-                YY_CURRENT_BUFFER_LVALUE =
+		YY_CURRENT_BUFFER_LVALUE =
             cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
-        }
+	}
 
-        cmListFileLexer_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
-        cmListFileLexer_yy_load_buffer_state(yyscanner );
+	cmListFileLexer_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
+	cmListFileLexer_yy_load_buffer_state(yyscanner );
 }
 
 /** Switch to a different input buffer.
@@ -1647,41 +1704,41 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        /* TODO. We should be able to replace this entire function body
-         * with
-         *              cmListFileLexer_yypop_buffer_state();
-         *              cmListFileLexer_yypush_buffer_state(new_buffer);
+	/* TODO. We should be able to replace this entire function body
+	 * with
+	 *		cmListFileLexer_yypop_buffer_state();
+	 *		cmListFileLexer_yypush_buffer_state(new_buffer);
      */
-        cmListFileLexer_yyensure_buffer_stack (yyscanner);
-        if ( YY_CURRENT_BUFFER == new_buffer )
-                return;
-
-        if ( YY_CURRENT_BUFFER )
-                {
-                /* Flush out information for old buffer. */
-                *yyg->yy_c_buf_p = yyg->yy_hold_char;
-                YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
-                YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
-                }
-
-        YY_CURRENT_BUFFER_LVALUE = new_buffer;
-        cmListFileLexer_yy_load_buffer_state(yyscanner );
-
-        /* We don't actually know whether we did this switch during
-         * EOF (cmListFileLexer_yywrap()) processing, but the only time this flag
-         * is looked at is after cmListFileLexer_yywrap() is called, so it's safe
-         * to go ahead and always set it.
-         */
-        yyg->yy_did_buffer_switch_on_eof = 1;
+	cmListFileLexer_yyensure_buffer_stack (yyscanner);
+	if ( YY_CURRENT_BUFFER == new_buffer )
+		return;
+
+	if ( YY_CURRENT_BUFFER )
+		{
+		/* Flush out information for old buffer. */
+		*yyg->yy_c_buf_p = yyg->yy_hold_char;
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+		}
+
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
+	cmListFileLexer_yy_load_buffer_state(yyscanner );
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (cmListFileLexer_yywrap()) processing, but the only time this flag
+	 * is looked at is after cmListFileLexer_yywrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	yyg->yy_did_buffer_switch_on_eof = 1;
 }
 
 static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-        yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
-        yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
-        yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
-        yyg->yy_hold_char = *yyg->yy_c_buf_p;
+	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+	yyg->yy_hold_char = *yyg->yy_c_buf_p;
 }
 
 /** Allocate and initialize an input buffer state.
@@ -1692,26 +1749,26 @@ static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
  */
     YY_BUFFER_STATE cmListFileLexer_yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
 {
-        YY_BUFFER_STATE b;
+	YY_BUFFER_STATE b;
 
-        b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
-        if ( ! b )
-                YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" );
+	b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" );
 
-        b->yy_buf_size = size;
+	b->yy_buf_size = (yy_size_t)size;
 
-        /* yy_ch_buf has to be 2 characters longer than the size given because
-         * we need to put in 2 end-of-buffer characters.
-         */
-        b->yy_ch_buf = (char *) cmListFileLexer_yyalloc(b->yy_buf_size + 2 ,yyscanner );
-        if ( ! b->yy_ch_buf )
-                YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" );
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) cmListFileLexer_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" );
 
-        b->yy_is_our_buffer = 1;
+	b->yy_is_our_buffer = 1;
 
-        cmListFileLexer_yy_init_buffer(b,file ,yyscanner);
+	cmListFileLexer_yy_init_buffer(b,file ,yyscanner);
 
-        return b;
+	return b;
 }
 
 /** Destroy the buffer.
@@ -1722,16 +1779,16 @@ static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        if ( ! b )
-                return;
+	if ( ! b )
+		return;
 
-        if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
-                YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
 
-        if ( b->yy_is_our_buffer )
-                cmListFileLexer_yyfree((void *) b->yy_ch_buf ,yyscanner );
+	if ( b->yy_is_our_buffer )
+		cmListFileLexer_yyfree((void *) b->yy_ch_buf ,yyscanner );
 
-        cmListFileLexer_yyfree((void *) b ,yyscanner );
+	cmListFileLexer_yyfree((void *) b ,yyscanner );
 }
 
 /* Initializes or reinitializes a buffer.
@@ -1741,13 +1798,13 @@ static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
     static void cmListFileLexer_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
 
 {
-        int oerrno = errno;
+	int oerrno = errno;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        cmListFileLexer_yy_flush_buffer(b ,yyscanner);
+	cmListFileLexer_yy_flush_buffer(b ,yyscanner);
 
-        b->yy_input_file = file;
-        b->yy_fill_buffer = 1;
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
 
     /* If b is the current buffer, then cmListFileLexer_yy_init_buffer was _probably_
      * called from cmListFileLexer_yyrestart() or through yy_get_next_buffer.
@@ -1760,7 +1817,7 @@ static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
 
         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
 
-        errno = oerrno;
+	errno = oerrno;
 }
 
 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
@@ -1770,25 +1827,25 @@ static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
     void cmListFileLexer_yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-        if ( ! b )
-                return;
+	if ( ! b )
+		return;
 
-        b->yy_n_chars = 0;
+	b->yy_n_chars = 0;
 
-        /* We always need two end-of-buffer characters.  The first causes
-         * a transition to the end-of-buffer state.  The second causes
-         * a jam in that state.
-         */
-        b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
-        b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
 
-        b->yy_buf_pos = &b->yy_ch_buf[0];
+	b->yy_buf_pos = &b->yy_ch_buf[0];
 
-        b->yy_at_bol = 1;
-        b->yy_buffer_status = YY_BUFFER_NEW;
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
 
-        if ( b == YY_CURRENT_BUFFER )
-                cmListFileLexer_yy_load_buffer_state(yyscanner );
+	if ( b == YY_CURRENT_BUFFER )
+		cmListFileLexer_yy_load_buffer_state(yyscanner );
 }
 
 /** Pushes the new state onto the stack. The new state becomes
@@ -1800,28 +1857,28 @@ static void cmListFileLexer_yy_load_buffer_state  (yyscan_t yyscanner)
 void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-        if (new_buffer == NULL)
-                return;
+	if (new_buffer == NULL)
+		return;
 
-        cmListFileLexer_yyensure_buffer_stack(yyscanner);
+	cmListFileLexer_yyensure_buffer_stack(yyscanner);
 
-        /* This block is copied from cmListFileLexer_yy_switch_to_buffer. */
-        if ( YY_CURRENT_BUFFER )
-                {
-                /* Flush out information for old buffer. */
-                *yyg->yy_c_buf_p = yyg->yy_hold_char;
-                YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
-                YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
-                }
+	/* This block is copied from cmListFileLexer_yy_switch_to_buffer. */
+	if ( YY_CURRENT_BUFFER )
+		{
+		/* Flush out information for old buffer. */
+		*yyg->yy_c_buf_p = yyg->yy_hold_char;
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+		}
 
-        /* Only push if top exists. Otherwise, replace top. */
-        if (YY_CURRENT_BUFFER)
-                yyg->yy_buffer_stack_top++;
-        YY_CURRENT_BUFFER_LVALUE = new_buffer;
+	/* Only push if top exists. Otherwise, replace top. */
+	if (YY_CURRENT_BUFFER)
+		yyg->yy_buffer_stack_top++;
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
 
-        /* copied from cmListFileLexer_yy_switch_to_buffer. */
-        cmListFileLexer_yy_load_buffer_state(yyscanner );
-        yyg->yy_did_buffer_switch_on_eof = 1;
+	/* copied from cmListFileLexer_yy_switch_to_buffer. */
+	cmListFileLexer_yy_load_buffer_state(yyscanner );
+	yyg->yy_did_buffer_switch_on_eof = 1;
 }
 
 /** Removes and deletes the top of the stack, if present.
@@ -1831,18 +1888,18 @@ void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t
 void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-        if (!YY_CURRENT_BUFFER)
-                return;
+	if (!YY_CURRENT_BUFFER)
+		return;
 
-        cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
-        YY_CURRENT_BUFFER_LVALUE = NULL;
-        if (yyg->yy_buffer_stack_top > 0)
-                --yyg->yy_buffer_stack_top;
+	cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+	YY_CURRENT_BUFFER_LVALUE = NULL;
+	if (yyg->yy_buffer_stack_top > 0)
+		--yyg->yy_buffer_stack_top;
 
-        if (YY_CURRENT_BUFFER) {
-                cmListFileLexer_yy_load_buffer_state(yyscanner );
-                yyg->yy_did_buffer_switch_on_eof = 1;
-        }
+	if (YY_CURRENT_BUFFER) {
+		cmListFileLexer_yy_load_buffer_state(yyscanner );
+		yyg->yy_did_buffer_switch_on_eof = 1;
+	}
 }
 
 /* Allocates the stack if it does not exist.
@@ -1850,46 +1907,46 @@ void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner)
  */
 static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
 {
-        int num_to_alloc;
+	yy_size_t num_to_alloc;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-        if (!yyg->yy_buffer_stack) {
+	if (!yyg->yy_buffer_stack) {
 
-                /* First allocation is just for 2 elements, since we don't know if this
-                 * scanner will even need a stack. We use 2 instead of 1 to avoid an
-                 * immediate realloc on the next call.
+		/* First allocation is just for 2 elements, since we don't know if this
+		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
+		 * immediate realloc on the next call.
          */
-                num_to_alloc = 1;
-                yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyalloc
-                                                                (num_to_alloc * sizeof(struct yy_buffer_state*)
-                                                                , yyscanner);
-                if ( ! yyg->yy_buffer_stack )
-                        YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
-
-                memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
-                yyg->yy_buffer_stack_max = num_to_alloc;
-                yyg->yy_buffer_stack_top = 0;
-                return;
-        }
+		num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
+		yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyalloc
+								(num_to_alloc * sizeof(struct yy_buffer_state*)
+								, yyscanner);
+		if ( ! yyg->yy_buffer_stack )
+			YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
 
-        if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
+		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 
-                /* Increase the buffer to prepare for a possible push. */
-                int grow_size = 8 /* arbitrary grow size */;
+		yyg->yy_buffer_stack_max = num_to_alloc;
+		yyg->yy_buffer_stack_top = 0;
+		return;
+	}
 
-                num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
-                yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyrealloc
-                                                                (yyg->yy_buffer_stack,
-                                                                num_to_alloc * sizeof(struct yy_buffer_state*)
-                                                                , yyscanner);
-                if ( ! yyg->yy_buffer_stack )
-                        YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
+	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
 
-                /* zero only the new slots.*/
-                memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
-                yyg->yy_buffer_stack_max = num_to_alloc;
-        }
+		/* Increase the buffer to prepare for a possible push. */
+		yy_size_t grow_size = 8 /* arbitrary grow size */;
+
+		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
+		yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyrealloc
+								(yyg->yy_buffer_stack,
+								num_to_alloc * sizeof(struct yy_buffer_state*)
+								, yyscanner);
+		if ( ! yyg->yy_buffer_stack )
+			YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
+
+		/* zero only the new slots.*/
+		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
+		yyg->yy_buffer_stack_max = num_to_alloc;
+	}
 }
 
 /** Setup the input buffer state to scan directly from a user-specified character buffer.
@@ -1900,31 +1957,31 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
  */
 YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
 {
-        YY_BUFFER_STATE b;
+	YY_BUFFER_STATE b;
 
-        if ( size < 2 ||
-             base[size-2] != YY_END_OF_BUFFER_CHAR ||
-             base[size-1] != YY_END_OF_BUFFER_CHAR )
-                /* They forgot to leave room for the EOB's. */
-                return 0;
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
 
-        b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
-        if ( ! b )
-                YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_buffer()" );
+	b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_buffer()" );
 
-        b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
-        b->yy_buf_pos = b->yy_ch_buf = base;
-        b->yy_is_our_buffer = 0;
-        b->yy_input_file = 0;
-        b->yy_n_chars = b->yy_buf_size;
-        b->yy_is_interactive = 0;
-        b->yy_at_bol = 1;
-        b->yy_fill_buffer = 0;
-        b->yy_buffer_status = YY_BUFFER_NEW;
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
 
-        cmListFileLexer_yy_switch_to_buffer(b ,yyscanner );
+	cmListFileLexer_yy_switch_to_buffer(b ,yyscanner );
 
-        return b;
+	return b;
 }
 
 /** Setup the input buffer state to scan a string. The next call to cmListFileLexer_yylex() will
@@ -1938,7 +1995,7 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer  (char * base, yy_size_t  size ,
 YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
 {
 
-        return cmListFileLexer_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
+	return cmListFileLexer_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
 }
 
 /** Setup the input buffer state to scan the given bytes. The next call to cmListFileLexer_yylex() will
@@ -1948,34 +2005,34 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char * yystr , yyscan_t
  * @param yyscanner The scanner object.
  * @return the newly allocated buffer state object.
  */
-YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
 {
-        YY_BUFFER_STATE b;
-        char *buf;
-        yy_size_t n;
-        int i;
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	yy_size_t i;
 
-        /* Get memory for full buffer, including space for trailing EOB's. */
-        n = _yybytes_len + 2;
-        buf = (char *) cmListFileLexer_yyalloc(n ,yyscanner );
-        if ( ! buf )
-                YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_bytes()" );
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = _yybytes_len + 2;
+	buf = (char *) cmListFileLexer_yyalloc(n ,yyscanner );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_bytes()" );
 
-        for ( i = 0; i < _yybytes_len; ++i )
-                buf[i] = yybytes[i];
+	for ( i = 0; i < _yybytes_len; ++i )
+		buf[i] = yybytes[i];
 
-        buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
 
-        b = cmListFileLexer_yy_scan_buffer(buf,n ,yyscanner);
-        if ( ! b )
-                YY_FATAL_ERROR( "bad buffer in cmListFileLexer_yy_scan_bytes()" );
+	b = cmListFileLexer_yy_scan_buffer(buf,n ,yyscanner);
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in cmListFileLexer_yy_scan_bytes()" );
 
-        /* It's okay to grow etc. this buffer, and we should throw it
-         * away when we're done.
-         */
-        b->yy_is_our_buffer = 1;
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
 
-        return b;
+	return b;
 }
 
 #ifndef YY_EXIT_FAILURE
@@ -1984,27 +2041,28 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes  (yyconst char * yybytes, int  _yy
 
 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
 {
-        (void)yyscanner;
-        (void) fprintf( stderr, "%s\n", msg );
-        exit( YY_EXIT_FAILURE );
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+	(void)yyg;
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
 }
 
 /* Redefine yyless() so it works in section 3 code. */
 
 #undef yyless
 #define yyless(n) \
-        do \
-                { \
-                /* Undo effects of setting up yytext. */ \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
         int yyless_macro_arg = (n); \
         YY_LESS_LINENO(yyless_macro_arg);\
-                yytext[yyleng] = yyg->yy_hold_char; \
-                yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
-                yyg->yy_hold_char = *yyg->yy_c_buf_p; \
-                *yyg->yy_c_buf_p = '\0'; \
-                yyleng = yyless_macro_arg; \
-                } \
-        while ( 0 )
+		yytext[yyleng] = yyg->yy_hold_char; \
+		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
+		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
+		*yyg->yy_c_buf_p = '\0'; \
+		yyleng = yyless_macro_arg; \
+		} \
+	while ( 0 )
 
 /* Accessor  methods (get/set functions) to struct members. */
 
@@ -2064,7 +2122,7 @@ FILE *cmListFileLexer_yyget_out  (yyscan_t yyscanner)
 /** Get the length of the current token.
  * @param yyscanner The scanner object.
  */
-int cmListFileLexer_yyget_leng  (yyscan_t yyscanner)
+yy_size_t cmListFileLexer_yyget_leng  (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
     return yyleng;
@@ -2091,51 +2149,51 @@ void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscann
 }
 
 /** Set the current line number.
- * @param line_number
+ * @param _line_number line number
  * @param yyscanner The scanner object.
  */
-void cmListFileLexer_yyset_lineno (int  line_number , yyscan_t yyscanner)
+void cmListFileLexer_yyset_lineno (int  _line_number , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* lineno is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           yy_fatal_error( "cmListFileLexer_yyset_lineno called with no buffer" , yyscanner);
+           YY_FATAL_ERROR( "cmListFileLexer_yyset_lineno called with no buffer" );
 
-    yylineno = line_number;
+    yylineno = _line_number;
 }
 
 /** Set the current column.
- * @param line_number
+ * @param _column_no column number
  * @param yyscanner The scanner object.
  */
-void cmListFileLexer_yyset_column (int  column_no , yyscan_t yyscanner)
+void cmListFileLexer_yyset_column (int  _column_no , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
         /* column is only valid if an input buffer exists. */
         if (! YY_CURRENT_BUFFER )
-           yy_fatal_error( "cmListFileLexer_yyset_column called with no buffer" , yyscanner);
+           YY_FATAL_ERROR( "cmListFileLexer_yyset_column called with no buffer" );
 
-    yycolumn = column_no;
+    yycolumn = _column_no;
 }
 
 /** Set the input stream. This does not discard the current
  * input buffer.
- * @param in_str A readable stream.
+ * @param _in_str A readable stream.
  * @param yyscanner The scanner object.
  * @see cmListFileLexer_yy_switch_to_buffer
  */
-void cmListFileLexer_yyset_in (FILE *  in_str , yyscan_t yyscanner)
+void cmListFileLexer_yyset_in (FILE *  _in_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yyin = in_str ;
+    yyin = _in_str ;
 }
 
-void cmListFileLexer_yyset_out (FILE *  out_str , yyscan_t yyscanner)
+void cmListFileLexer_yyset_out (FILE *  _out_str , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yyout = out_str ;
+    yyout = _out_str ;
 }
 
 int cmListFileLexer_yyget_debug  (yyscan_t yyscanner)
@@ -2144,10 +2202,10 @@ int cmListFileLexer_yyget_debug  (yyscan_t yyscanner)
     return yy_flex_debug;
 }
 
-void cmListFileLexer_yyset_debug (int  bdebug , yyscan_t yyscanner)
+void cmListFileLexer_yyset_debug (int  _bdebug , yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-    yy_flex_debug = bdebug ;
+    yy_flex_debug = _bdebug ;
 }
 
 /* Accessor methods for yylval and yylloc */
@@ -2255,15 +2313,15 @@ int cmListFileLexer_yylex_destroy  (yyscan_t yyscanner)
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
     /* Pop the buffer stack, destroying each element. */
-        while(YY_CURRENT_BUFFER){
-                cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
-                YY_CURRENT_BUFFER_LVALUE = NULL;
-                cmListFileLexer_yypop_buffer_state(yyscanner);
-        }
+	while(YY_CURRENT_BUFFER){
+		cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+		YY_CURRENT_BUFFER_LVALUE = NULL;
+		cmListFileLexer_yypop_buffer_state(yyscanner);
+	}
 
-        /* Destroy the stack itself. */
-        cmListFileLexer_yyfree(yyg->yy_buffer_stack ,yyscanner);
-        yyg->yy_buffer_stack = NULL;
+	/* Destroy the stack itself. */
+	cmListFileLexer_yyfree(yyg->yy_buffer_stack ,yyscanner);
+	yyg->yy_buffer_stack = NULL;
 
     /* Destroy the start condition stack. */
         cmListFileLexer_yyfree(yyg->yy_start_stack ,yyscanner );
@@ -2285,51 +2343,58 @@ int cmListFileLexer_yylex_destroy  (yyscan_t yyscanner)
 #ifndef yytext_ptr
 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
 {
-        int i;
-        for ( i = 0; i < n; ++i )
-                s1[i] = s2[i];
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+	(void)yyg;
+
+	int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
 }
 #endif
 
 #ifdef YY_NEED_STRLEN
 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
 {
-        int n;
-        for ( n = 0; s[n]; ++n )
-                ;
+	int n;
+	for ( n = 0; s[n]; ++n )
+		;
 
-        return n;
+	return n;
 }
 #endif
 
 void *cmListFileLexer_yyalloc (yy_size_t  size , yyscan_t yyscanner)
 {
-        (void)yyscanner;
-        return (void *) malloc( size );
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+	(void)yyg;
+	return (void *) malloc( size );
 }
 
 void *cmListFileLexer_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
 {
-        /* The cast to (char *) in the following accommodates both
-         * implementations that use char* generic pointers, and those
-         * that use void* generic pointers.  It works with the latter
-         * because both ANSI C and C++ allow castless assignment from
-         * any pointer type to void*, and deal with argument conversions
-         * as though doing an assignment.
-         */
-        (void)yyscanner;
-        return (void *) realloc( (char *) ptr, size );
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+	(void)yyg;
+
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
 }
 
 void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner)
 {
-        (void)yyscanner;
-        free( (char *) ptr );   /* see cmListFileLexer_yyrealloc() for (char *) cast */
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+	(void)yyg;
+	free( (char *) ptr );	/* see cmListFileLexer_yyrealloc() for (char *) cast */
 }
 
 #define YYTABLES_NAME "yytables"
 
-#line 282 "cmListFileLexer.in.l"
+#line 273 "cmListFileLexer.in.l"
 
 
 
@@ -2342,30 +2407,25 @@ static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
   lexer->token.column = lexer->column;
 
   /* Use the same buffer if possible.  */
-  if(lexer->token.text)
-    {
-    if(text && length < lexer->size)
-      {
+  if (lexer->token.text) {
+    if (text && length < lexer->size) {
       strcpy(lexer->token.text, text);
       lexer->token.length = length;
       return;
-      }
+    }
     free(lexer->token.text);
     lexer->token.text = 0;
     lexer->size = 0;
-    }
+  }
 
   /* Need to extend the buffer.  */
-  if(text)
-    {
+  if (text) {
     lexer->token.text = strdup(text);
     lexer->token.length = length;
-    lexer->size = length+1;
-    }
-  else
-    {
+    lexer->size = length + 1;
+  } else {
     lexer->token.length = 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
@@ -2377,22 +2437,20 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
 
   /* If the appended text will fit in the buffer, do not reallocate.  */
   newSize = lexer->token.length + length + 1;
-  if(lexer->token.text && newSize <= lexer->size)
-    {
-    strcpy(lexer->token.text+lexer->token.length, text);
+  if (lexer->token.text && newSize <= lexer->size) {
+    strcpy(lexer->token.text + lexer->token.length, text);
     lexer->token.length += length;
     return;
-    }
+  }
 
   /* We need to extend the buffer.  */
   temp = malloc(newSize);
-  if(lexer->token.text)
-    {
+  if (lexer->token.text) {
     memcpy(temp, lexer->token.text, lexer->token.length);
     free(lexer->token.text);
-    }
-  memcpy(temp+lexer->token.length, text, length);
-  temp[lexer->token.length+length] = 0;
+  }
+  memcpy(temp + lexer->token.length, text, length);
+  temp[lexer->token.length + length] = 0;
   lexer->token.text = temp;
   lexer->token.length += length;
   lexer->size = newSize;
@@ -2402,96 +2460,84 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
 static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
                                 size_t bufferSize)
 {
-  if(lexer)
-    {
-    if(lexer->file)
-      {
+  if (lexer) {
+    if (lexer->file) {
       /* Convert CRLF -> LF explicitly.  The C FILE "t"ext mode
          does not convert newlines on all platforms.  Move any
          trailing CR to the start of the buffer for the next read. */
       size_t cr = lexer->cr;
       size_t n;
       buffer[0] = '\r';
-      n = fread(buffer+cr, 1, bufferSize-cr, lexer->file);
-      if(n)
-        {
+      n = fread(buffer + cr, 1, bufferSize - cr, lexer->file);
+      if (n) {
         char* o = buffer;
         const char* i = buffer;
         const char* e;
         n += cr;
-        cr = (buffer[n-1] == '\r')? 1:0;
+        cr = (buffer[n - 1] == '\r') ? 1 : 0;
         e = buffer + n - cr;
-        while(i != e)
-          {
-          if(i[0] == '\r' && i[1] == '\n')
-            {
+        while (i != e) {
+          if (i[0] == '\r' && i[1] == '\n') {
             ++i;
-            }
-          *o++ = *i++;
           }
-        n = o - buffer;
+          *o++ = *i++;
         }
-      else
-        {
+        n = o - buffer;
+      } else {
         n = cr;
         cr = 0;
-        }
+      }
       lexer->cr = cr;
       return n;
-      }
-    else if(lexer->string_left)
-      {
+    } else if (lexer->string_left) {
       int length = lexer->string_left;
-      if((int)bufferSize < length) { length = (int)bufferSize; }
+      if ((int)bufferSize < length) {
+        length = (int)bufferSize;
+      }
       memcpy(buffer, lexer->string_position, length);
       lexer->string_position += length;
       lexer->string_left -= length;
       return length;
-      }
     }
+  }
   return 0;
 }
 
 /*--------------------------------------------------------------------------*/
 static void cmListFileLexerInit(cmListFileLexer* lexer)
 {
-  if(lexer->file || lexer->string_buffer)
-    {
+  if (lexer->file || lexer->string_buffer) {
     cmListFileLexer_yylex_init(&lexer->scanner);
     cmListFileLexer_yyset_extra(lexer, lexer->scanner);
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 static void cmListFileLexerDestroy(cmListFileLexer* lexer)
 {
   cmListFileLexerSetToken(lexer, 0, 0);
-  if(lexer->file || lexer->string_buffer)
-    {
+  if (lexer->file || lexer->string_buffer) {
     cmListFileLexer_yylex_destroy(lexer->scanner);
-    if(lexer->file)
-      {
+    if (lexer->file) {
       fclose(lexer->file);
       lexer->file = 0;
-      }
-    if(lexer->string_buffer)
-      {
+    }
+    if (lexer->string_buffer) {
       free(lexer->string_buffer);
       lexer->string_buffer = 0;
       lexer->string_left = 0;
       lexer->string_position = 0;
-      }
     }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 cmListFileLexer* cmListFileLexer_New()
 {
   cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer));
-  if(!lexer)
-    {
+  if (!lexer) {
     return 0;
-    }
+  }
   memset(lexer, 0, sizeof(*lexer));
   lexer->line = 1;
   lexer->column = 1;
@@ -2509,39 +2555,28 @@ void cmListFileLexer_Delete(cmListFileLexer* lexer)
 static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
 {
   unsigned char b[2];
-  if(fread(b, 1, 2, f) == 2)
-    {
-    if(b[0] == 0xEF && b[1] == 0xBB)
-      {
-      if(fread(b, 1, 1, f) == 1 && b[0] == 0xBF)
-        {
+  if (fread(b, 1, 2, f) == 2) {
+    if (b[0] == 0xEF && b[1] == 0xBB) {
+      if (fread(b, 1, 1, f) == 1 && b[0] == 0xBF) {
         return cmListFileLexer_BOM_UTF8;
-        }
       }
-    else if(b[0] == 0xFE && b[1] == 0xFF)
-      {
+    } else if (b[0] == 0xFE && b[1] == 0xFF) {
       /* UTF-16 BE */
       return cmListFileLexer_BOM_UTF16BE;
-      }
-    else if(b[0] == 0 && b[1] == 0)
-      {
-      if(fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF)
-        {
+    } else if (b[0] == 0 && b[1] == 0) {
+      if (fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF) {
         return cmListFileLexer_BOM_UTF32BE;
-        }
       }
-    else if(b[0] == 0xFF && b[1] == 0xFE)
-      {
+    } else if (b[0] == 0xFF && b[1] == 0xFE) {
       fpos_t p;
       fgetpos(f, &p);
-      if(fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0)
-        {
+      if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
         return cmListFileLexer_BOM_UTF32LE;
-        }
+      }
       fsetpos(f, &p);
       return cmListFileLexer_BOM_UTF16LE;
-      }
     }
+  }
   rewind(f);
   return cmListFileLexer_BOM_None;
 }
@@ -2552,8 +2587,7 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
 {
   int result = 1;
   cmListFileLexerDestroy(lexer);
-  if(name)
-    {
+  if (name) {
 #ifdef _WIN32
     wchar_t* wname = cmsysEncoding_DupToWide(name);
     lexer->file = _wfopen(wname, L"rb");
@@ -2561,18 +2595,14 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
 #else
     lexer->file = fopen(name, "rb");
 #endif
-    if(lexer->file)
-      {
-      if(bom)
-        {
+    if (lexer->file) {
+      if (bom) {
         *bom = cmListFileLexer_ReadBOM(lexer->file);
-        }
       }
-    else
-      {
+    } else {
       result = 0;
-      }
     }
+  }
   cmListFileLexerInit(lexer);
   return result;
 }
@@ -2582,21 +2612,17 @@ int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)
 {
   int result = 1;
   cmListFileLexerDestroy(lexer);
-  if(text)
-    {
+  if (text) {
     int length = (int)strlen(text);
-    lexer->string_buffer = (char*)malloc(length+1);
-    if(lexer->string_buffer)
-      {
+    lexer->string_buffer = (char*)malloc(length + 1);
+    if (lexer->string_buffer) {
       strcpy(lexer->string_buffer, text);
       lexer->string_position = lexer->string_buffer;
       lexer->string_left = length;
-      }
-    else
-      {
+    } else {
       result = 0;
-      }
     }
+  }
   cmListFileLexerInit(lexer);
   return result;
 }
@@ -2604,45 +2630,35 @@ int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)
 /*--------------------------------------------------------------------------*/
 cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer)
 {
-  if(!lexer->file)
-    {
+  if (!lexer->file) {
     return 0;
-    }
-  if(cmListFileLexer_yylex(lexer->scanner, lexer))
-    {
+  }
+  if (cmListFileLexer_yylex(lexer->scanner, lexer)) {
     return &lexer->token;
-    }
-  else
-    {
+  } else {
     cmListFileLexer_SetFileName(lexer, 0, 0);
     return 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 long cmListFileLexer_GetCurrentLine(cmListFileLexer* lexer)
 {
-  if(lexer->file)
-    {
+  if (lexer->file) {
     return lexer->line;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 long cmListFileLexer_GetCurrentColumn(cmListFileLexer* lexer)
 {
-  if(lexer->file)
-    {
+  if (lexer->file) {
     return lexer->column;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
@@ -2650,21 +2666,33 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
                                             cmListFileLexer_Type type)
 {
   (void)lexer;
-  switch(type)
-    {
-    case cmListFileLexer_Token_None: return "nothing";
-    case cmListFileLexer_Token_Space: return "space";
-    case cmListFileLexer_Token_Newline: return "newline";
-    case cmListFileLexer_Token_Identifier: return "identifier";
-    case cmListFileLexer_Token_ParenLeft: return "left paren";
-    case cmListFileLexer_Token_ParenRight: return "right paren";
-    case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument";
-    case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument";
-    case cmListFileLexer_Token_ArgumentBracket: return "bracket argument";
-    case cmListFileLexer_Token_CommentBracket: return "bracket comment";
-    case cmListFileLexer_Token_BadCharacter: return "bad character";
-    case cmListFileLexer_Token_BadBracket: return "unterminated bracket";
-    case cmListFileLexer_Token_BadString: return "unterminated string";
-    }
+  switch (type) {
+    case cmListFileLexer_Token_None:
+      return "nothing";
+    case cmListFileLexer_Token_Space:
+      return "space";
+    case cmListFileLexer_Token_Newline:
+      return "newline";
+    case cmListFileLexer_Token_Identifier:
+      return "identifier";
+    case cmListFileLexer_Token_ParenLeft:
+      return "left paren";
+    case cmListFileLexer_Token_ParenRight:
+      return "right paren";
+    case cmListFileLexer_Token_ArgumentUnquoted:
+      return "unquoted argument";
+    case cmListFileLexer_Token_ArgumentQuoted:
+      return "quoted argument";
+    case cmListFileLexer_Token_ArgumentBracket:
+      return "bracket argument";
+    case cmListFileLexer_Token_CommentBracket:
+      return "bracket comment";
+    case cmListFileLexer_Token_BadCharacter:
+      return "bad character";
+    case cmListFileLexer_Token_BadBracket:
+      return "unterminated bracket";
+    case cmListFileLexer_Token_BadString:
+      return "unterminated string";
+  }
   return "unknown token";
 }
diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h
index bd2868a..88300e1 100644
--- a/Source/cmListFileLexer.h
+++ b/Source/cmListFileLexer.h
@@ -12,8 +12,7 @@
 #ifndef cmListFileLexer_h
 #define cmListFileLexer_h
 
-typedef enum cmListFileLexer_Type_e
-{
+typedef enum cmListFileLexer_Type_e {
   cmListFileLexer_Token_None,
   cmListFileLexer_Token_Space,
   cmListFileLexer_Token_Newline,
@@ -53,8 +52,7 @@ typedef enum cmListFileLexer_BOM_e cmListFileLexer_BOM;
 typedef struct cmListFileLexer_s cmListFileLexer;
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
 cmListFileLexer* cmListFileLexer_New();
diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l
index a520c72..6d44814 100644
--- a/Source/cmListFileLexer.in.l
+++ b/Source/cmListFileLexer.in.l
@@ -14,19 +14,16 @@
 
 This file must be translated to C and modified to build everywhere.
 
-Run flex like this:
+Run flex >= 2.6 like this:
 
   flex --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l
 
 Modify cmListFileLexer.c:
-  - remove TABs
-  - remove use of the 'register' storage class specifier
-  - remove the yyunput function
-  - add a statement "(void)yyscanner;" to the top of these methods:
-      yy_fatal_error, cmListFileLexer_yyalloc, cmListFileLexer_yyrealloc, cmListFileLexer_yyfree
+  - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
+  - remove blank lines at end of file
   - remove statement "yyscanner = NULL;" from cmListFileLexer_yylex_destroy
   - remove all YY_BREAK lines occurring right after return statements
-  - remove the isatty forward declaration
+  - remove unnecessary cast to (int) in yy_get_next_buffer
 
 */
 
@@ -45,7 +42,7 @@ Modify cmListFileLexer.c:
 struct cmListFileLexer_s
 {
   cmListFileLexer_Token token;
-  int bracket;
+  yy_size_t bracket;
   int comment;
   int line;
   int column;
@@ -102,26 +99,20 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
 #?\[=*\[\n? {
   const char* bracket = yytext;
   lexer->comment = yytext[0] == '#';
-  if(lexer->comment)
-    {
+  if (lexer->comment) {
     lexer->token.type = cmListFileLexer_Token_CommentBracket;
     bracket += 1;
-    }
-  else
-    {
+  } else {
     lexer->token.type = cmListFileLexer_Token_ArgumentBracket;
-    }
+  }
   cmListFileLexerSetToken(lexer, "", 0);
-  lexer->bracket = (int)(strchr(bracket+1, '[') - bracket);
-  if(yytext[yyleng-1] == '\n')
-    {
+  lexer->bracket = strchr(bracket+1, '[') - bracket;
+  if (yytext[yyleng-1] == '\n') {
     ++lexer->line;
     lexer->column = 1;
-    }
-  else
-    {
+  } else {
     lexer->column += yyleng;
-    }
+  }
   BEGIN(BRACKET);
 }
 
@@ -159,10 +150,9 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
   /* Handle ]]====]=======]*/
   cmListFileLexerAppend(lexer, yytext, yyleng);
   lexer->column += yyleng;
-  if(yyleng == lexer->bracket)
-    {
+  if (yyleng == lexer->bracket) {
     BEGIN(BRACKETEND);
-    }
+  }
 }
 
 <BRACKETEND>\] {
@@ -291,30 +281,25 @@ static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
   lexer->token.column = lexer->column;
 
   /* Use the same buffer if possible.  */
-  if(lexer->token.text)
-    {
-    if(text && length < lexer->size)
-      {
+  if (lexer->token.text) {
+    if (text && length < lexer->size) {
       strcpy(lexer->token.text, text);
       lexer->token.length = length;
       return;
-      }
+    }
     free(lexer->token.text);
     lexer->token.text = 0;
     lexer->size = 0;
-    }
+  }
 
   /* Need to extend the buffer.  */
-  if(text)
-    {
+  if (text) {
     lexer->token.text = strdup(text);
     lexer->token.length = length;
-    lexer->size = length+1;
-    }
-  else
-    {
+    lexer->size = length + 1;
+  } else {
     lexer->token.length = 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
@@ -326,22 +311,20 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
 
   /* If the appended text will fit in the buffer, do not reallocate.  */
   newSize = lexer->token.length + length + 1;
-  if(lexer->token.text && newSize <= lexer->size)
-    {
-    strcpy(lexer->token.text+lexer->token.length, text);
+  if (lexer->token.text && newSize <= lexer->size) {
+    strcpy(lexer->token.text + lexer->token.length, text);
     lexer->token.length += length;
     return;
-    }
+  }
 
   /* We need to extend the buffer.  */
   temp = malloc(newSize);
-  if(lexer->token.text)
-    {
+  if (lexer->token.text) {
     memcpy(temp, lexer->token.text, lexer->token.length);
     free(lexer->token.text);
-    }
-  memcpy(temp+lexer->token.length, text, length);
-  temp[lexer->token.length+length] = 0;
+  }
+  memcpy(temp + lexer->token.length, text, length);
+  temp[lexer->token.length + length] = 0;
   lexer->token.text = temp;
   lexer->token.length += length;
   lexer->size = newSize;
@@ -351,96 +334,84 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
 static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer,
                                 size_t bufferSize)
 {
-  if(lexer)
-    {
-    if(lexer->file)
-      {
+  if (lexer) {
+    if (lexer->file) {
       /* Convert CRLF -> LF explicitly.  The C FILE "t"ext mode
          does not convert newlines on all platforms.  Move any
          trailing CR to the start of the buffer for the next read. */
       size_t cr = lexer->cr;
       size_t n;
       buffer[0] = '\r';
-      n = fread(buffer+cr, 1, bufferSize-cr, lexer->file);
-      if(n)
-        {
+      n = fread(buffer + cr, 1, bufferSize - cr, lexer->file);
+      if (n) {
         char* o = buffer;
         const char* i = buffer;
         const char* e;
         n += cr;
-        cr = (buffer[n-1] == '\r')? 1:0;
+        cr = (buffer[n - 1] == '\r') ? 1 : 0;
         e = buffer + n - cr;
-        while(i != e)
-          {
-          if(i[0] == '\r' && i[1] == '\n')
-            {
+        while (i != e) {
+          if (i[0] == '\r' && i[1] == '\n') {
             ++i;
-            }
-          *o++ = *i++;
           }
-        n = o - buffer;
+          *o++ = *i++;
         }
-      else
-        {
+        n = o - buffer;
+      } else {
         n = cr;
         cr = 0;
-        }
+      }
       lexer->cr = cr;
       return n;
-      }
-    else if(lexer->string_left)
-      {
+    } else if (lexer->string_left) {
       int length = lexer->string_left;
-      if((int)bufferSize < length) { length = (int)bufferSize; }
+      if ((int)bufferSize < length) {
+        length = (int)bufferSize;
+      }
       memcpy(buffer, lexer->string_position, length);
       lexer->string_position += length;
       lexer->string_left -= length;
       return length;
-      }
     }
+  }
   return 0;
 }
 
 /*--------------------------------------------------------------------------*/
 static void cmListFileLexerInit(cmListFileLexer* lexer)
 {
-  if(lexer->file || lexer->string_buffer)
-    {
+  if (lexer->file || lexer->string_buffer) {
     cmListFileLexer_yylex_init(&lexer->scanner);
     cmListFileLexer_yyset_extra(lexer, lexer->scanner);
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 static void cmListFileLexerDestroy(cmListFileLexer* lexer)
 {
   cmListFileLexerSetToken(lexer, 0, 0);
-  if(lexer->file || lexer->string_buffer)
-    {
+  if (lexer->file || lexer->string_buffer) {
     cmListFileLexer_yylex_destroy(lexer->scanner);
-    if(lexer->file)
-      {
+    if (lexer->file) {
       fclose(lexer->file);
       lexer->file = 0;
-      }
-    if(lexer->string_buffer)
-      {
+    }
+    if (lexer->string_buffer) {
       free(lexer->string_buffer);
       lexer->string_buffer = 0;
       lexer->string_left = 0;
       lexer->string_position = 0;
-      }
     }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 cmListFileLexer* cmListFileLexer_New()
 {
   cmListFileLexer* lexer = (cmListFileLexer*)malloc(sizeof(cmListFileLexer));
-  if(!lexer)
-    {
+  if (!lexer) {
     return 0;
-    }
+  }
   memset(lexer, 0, sizeof(*lexer));
   lexer->line = 1;
   lexer->column = 1;
@@ -458,39 +429,28 @@ void cmListFileLexer_Delete(cmListFileLexer* lexer)
 static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
 {
   unsigned char b[2];
-  if(fread(b, 1, 2, f) == 2)
-    {
-    if(b[0] == 0xEF && b[1] == 0xBB)
-      {
-      if(fread(b, 1, 1, f) == 1 && b[0] == 0xBF)
-        {
+  if (fread(b, 1, 2, f) == 2) {
+    if (b[0] == 0xEF && b[1] == 0xBB) {
+      if (fread(b, 1, 1, f) == 1 && b[0] == 0xBF) {
         return cmListFileLexer_BOM_UTF8;
-        }
       }
-    else if(b[0] == 0xFE && b[1] == 0xFF)
-      {
+    } else if (b[0] == 0xFE && b[1] == 0xFF) {
       /* UTF-16 BE */
       return cmListFileLexer_BOM_UTF16BE;
-      }
-    else if(b[0] == 0 && b[1] == 0)
-      {
-      if(fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF)
-        {
+    } else if (b[0] == 0 && b[1] == 0) {
+      if (fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF) {
         return cmListFileLexer_BOM_UTF32BE;
-        }
       }
-    else if(b[0] == 0xFF && b[1] == 0xFE)
-      {
+    } else if (b[0] == 0xFF && b[1] == 0xFE) {
       fpos_t p;
       fgetpos(f, &p);
-      if(fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0)
-        {
+      if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
         return cmListFileLexer_BOM_UTF32LE;
-        }
+      }
       fsetpos(f, &p);
       return cmListFileLexer_BOM_UTF16LE;
-      }
     }
+  }
   rewind(f);
   return cmListFileLexer_BOM_None;
 }
@@ -501,8 +461,7 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
 {
   int result = 1;
   cmListFileLexerDestroy(lexer);
-  if(name)
-    {
+  if (name) {
 #ifdef _WIN32
     wchar_t* wname = cmsysEncoding_DupToWide(name);
     lexer->file = _wfopen(wname, L"rb");
@@ -510,18 +469,14 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
 #else
     lexer->file = fopen(name, "rb");
 #endif
-    if(lexer->file)
-      {
-      if(bom)
-        {
+    if (lexer->file) {
+      if (bom) {
         *bom = cmListFileLexer_ReadBOM(lexer->file);
-        }
       }
-    else
-      {
+    } else {
       result = 0;
-      }
     }
+  }
   cmListFileLexerInit(lexer);
   return result;
 }
@@ -531,21 +486,17 @@ int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)
 {
   int result = 1;
   cmListFileLexerDestroy(lexer);
-  if(text)
-    {
+  if (text) {
     int length = (int)strlen(text);
-    lexer->string_buffer = (char*)malloc(length+1);
-    if(lexer->string_buffer)
-      {
+    lexer->string_buffer = (char*)malloc(length + 1);
+    if (lexer->string_buffer) {
       strcpy(lexer->string_buffer, text);
       lexer->string_position = lexer->string_buffer;
       lexer->string_left = length;
-      }
-    else
-      {
+    } else {
       result = 0;
-      }
     }
+  }
   cmListFileLexerInit(lexer);
   return result;
 }
@@ -553,45 +504,35 @@ int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)
 /*--------------------------------------------------------------------------*/
 cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer)
 {
-  if(!lexer->file)
-    {
+  if (!lexer->file) {
     return 0;
-    }
-  if(cmListFileLexer_yylex(lexer->scanner, lexer))
-    {
+  }
+  if (cmListFileLexer_yylex(lexer->scanner, lexer)) {
     return &lexer->token;
-    }
-  else
-    {
+  } else {
     cmListFileLexer_SetFileName(lexer, 0, 0);
     return 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 long cmListFileLexer_GetCurrentLine(cmListFileLexer* lexer)
 {
-  if(lexer->file)
-    {
+  if (lexer->file) {
     return lexer->line;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
 long cmListFileLexer_GetCurrentColumn(cmListFileLexer* lexer)
 {
-  if(lexer->file)
-    {
+  if (lexer->file) {
     return lexer->column;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
 /*--------------------------------------------------------------------------*/
@@ -599,21 +540,33 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
                                             cmListFileLexer_Type type)
 {
   (void)lexer;
-  switch(type)
-    {
-    case cmListFileLexer_Token_None: return "nothing";
-    case cmListFileLexer_Token_Space: return "space";
-    case cmListFileLexer_Token_Newline: return "newline";
-    case cmListFileLexer_Token_Identifier: return "identifier";
-    case cmListFileLexer_Token_ParenLeft: return "left paren";
-    case cmListFileLexer_Token_ParenRight: return "right paren";
-    case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument";
-    case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument";
-    case cmListFileLexer_Token_ArgumentBracket: return "bracket argument";
-    case cmListFileLexer_Token_CommentBracket: return "bracket comment";
-    case cmListFileLexer_Token_BadCharacter: return "bad character";
-    case cmListFileLexer_Token_BadBracket: return "unterminated bracket";
-    case cmListFileLexer_Token_BadString: return "unterminated string";
-    }
+  switch (type) {
+    case cmListFileLexer_Token_None:
+      return "nothing";
+    case cmListFileLexer_Token_Space:
+      return "space";
+    case cmListFileLexer_Token_Newline:
+      return "newline";
+    case cmListFileLexer_Token_Identifier:
+      return "identifier";
+    case cmListFileLexer_Token_ParenLeft:
+      return "left paren";
+    case cmListFileLexer_Token_ParenRight:
+      return "right paren";
+    case cmListFileLexer_Token_ArgumentUnquoted:
+      return "unquoted argument";
+    case cmListFileLexer_Token_ArgumentQuoted:
+      return "quoted argument";
+    case cmListFileLexer_Token_ArgumentBracket:
+      return "bracket argument";
+    case cmListFileLexer_Token_CommentBracket:
+      return "bracket comment";
+    case cmListFileLexer_Token_BadCharacter:
+      return "bad character";
+    case cmListFileLexer_Token_BadBracket:
+      return "unterminated bracket";
+    case cmListFileLexer_Token_BadString:
+      return "unterminated string";
+  }
   return "unknown token";
 }
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index 6ade535..85188d1 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -11,102 +11,86 @@
 ============================================================================*/
 #include "cmLoadCacheCommand.h"
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
 
 // cmLoadCacheCommand
-bool cmLoadCacheCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args,
+                                     cmExecutionStatus&)
 {
-  if (args.size()< 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with wrong number of arguments.");
-    }
+  }
 
-  if(args.size() >= 2 && args[1] == "READ_WITH_PREFIX")
-    {
+  if (args.size() >= 2 && args[1] == "READ_WITH_PREFIX") {
     return this->ReadWithPrefix(args);
-    }
+  }
 
   // Cache entries to be excluded from the import list.
   // If this set is empty, all cache entries are brought in
   // and they can not be overridden.
-  bool excludeFiles=false;
+  bool excludeFiles = false;
   unsigned int i;
   std::set<std::string> excludes;
 
-  for(i=0; i<args.size(); i++)
-    {
-    if (excludeFiles)
-      {
+  for (i = 0; i < args.size(); i++) {
+    if (excludeFiles) {
       excludes.insert(args[i]);
-      }
-    if (args[i] == "EXCLUDE")
-      {
-      excludeFiles=true;
-      }
-    if (excludeFiles && (args[i] == "INCLUDE_INTERNALS"))
-      {
+    }
+    if (args[i] == "EXCLUDE") {
+      excludeFiles = true;
+    }
+    if (excludeFiles && (args[i] == "INCLUDE_INTERNALS")) {
       break;
-      }
     }
+  }
 
   // Internal cache entries to be imported.
   // If this set is empty, no internal cache entries are
   // brought in.
-  bool includeFiles=false;
+  bool includeFiles = false;
   std::set<std::string> includes;
 
-  for(i=0; i<args.size(); i++)
-    {
-    if (includeFiles)
-      {
+  for (i = 0; i < args.size(); i++) {
+    if (includeFiles) {
       includes.insert(args[i]);
-      }
-    if (args[i] == "INCLUDE_INTERNALS")
-      {
-      includeFiles=true;
-      }
-    if (includeFiles && (args[i] == "EXCLUDE"))
-      {
+    }
+    if (args[i] == "INCLUDE_INTERNALS") {
+      includeFiles = true;
+    }
+    if (includeFiles && (args[i] == "EXCLUDE")) {
       break;
-      }
     }
+  }
 
   // Loop over each build directory listed in the arguments.  Each
   // directory has a cache file.
-  for(i=0; i<args.size(); i++)
-    {
-    if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS"))
-      {
+  for (i = 0; i < args.size(); i++) {
+    if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS")) {
       break;
-      }
-    this->Makefile->GetCMakeInstance()->LoadCache(args[i], false,
-                                                  excludes, includes);
     }
-
+    this->Makefile->GetCMakeInstance()->LoadCache(args[i], false, excludes,
+                                                  includes);
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
 {
   // Make sure we have a prefix.
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     this->SetError("READ_WITH_PREFIX form must specify a prefix.");
     return false;
-    }
+  }
 
   // Make sure the cache file exists.
-  std::string cacheFile = args[0]+"/CMakeCache.txt";
-  if(!cmSystemTools::FileExists(cacheFile.c_str()))
-    {
+  std::string cacheFile = args[0] + "/CMakeCache.txt";
+  if (!cmSystemTools::FileExists(cacheFile.c_str())) {
     std::string e = "Cannot load cache file from " + cacheFile;
     this->SetError(e);
     return false;
-    }
+  }
 
   // Prepare the table of variables to read.
   this->Prefix = args[2];
@@ -121,74 +105,62 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
   const int bufferSize = 4096;
   char buffer[bufferSize];
   std::string line;
-  while(fin)
-    {
+  while (fin) {
     // Read a block of the file.
     fin.read(buffer, bufferSize);
-    if(fin.gcount())
-      {
+    if (fin.gcount()) {
       // Parse for newlines directly.
       const char* i = buffer;
-      const char* end = buffer+fin.gcount();
-      while(i != end)
-        {
+      const char* end = buffer + fin.gcount();
+      while (i != end) {
         const char* begin = i;
-        while(i != end && *i != '\n') { ++i; }
-        if(i == begin || *(i-1) != '\r')
-          {
+        while (i != end && *i != '\n') {
+          ++i;
+        }
+        if (i == begin || *(i - 1) != '\r') {
           // Include this portion of the line.
-          line += std::string(begin, i-begin);
-          }
-        else
-          {
+          line += std::string(begin, i - begin);
+        } else {
           // Include this portion of the line.
           // Don't include the \r in a \r\n pair.
-          line += std::string(begin, i-1-begin);
-          }
-        if(i != end)
-          {
+          line += std::string(begin, i - 1 - begin);
+        }
+        if (i != end) {
           // Completed a line.
           this->CheckLine(line.c_str());
           line = "";
 
           // Skip the newline character.
           ++i;
-          }
         }
       }
     }
-  if(!line.empty())
-    {
+  }
+  if (!line.empty()) {
     // Partial last line.
     this->CheckLine(line.c_str());
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmLoadCacheCommand::CheckLine(const char* line)
 {
   // Check one line of the cache file.
   std::string var;
   std::string value;
   cmState::CacheEntryType type = cmState::UNINITIALIZED;
-  if(cmake::ParseCacheEntry(line, var, value, type))
-    {
+  if (cmake::ParseCacheEntry(line, var, value, type)) {
     // Found a real entry.  See if this one was requested.
-    if(this->VariablesToRead.find(var) != this->VariablesToRead.end())
-      {
+    if (this->VariablesToRead.find(var) != this->VariablesToRead.end()) {
       // This was requested.  Set this variable locally with the given
       // prefix.
       var = this->Prefix + var;
-      if(!value.empty())
-        {
+      if (!value.empty()) {
         this->Makefile->AddDefinition(var, value.c_str());
-        }
-      else
-        {
+      } else {
         this->Makefile->RemoveDefinition(var);
-        }
       }
     }
+  }
 }
diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h
index 04207d0..67d93ac 100644
--- a/Source/cmLoadCacheCommand.h
+++ b/Source/cmLoadCacheCommand.h
@@ -25,26 +25,23 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmLoadCacheCommand;
-    }
+  virtual cmCommand* Clone() { return new cmLoadCacheCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "load_cache";}
+  virtual std::string GetName() const { return "load_cache"; }
 
   cmTypeMacro(cmLoadCacheCommand, cmCommand);
-protected:
 
+protected:
   std::set<std::string> VariablesToRead;
   std::string Prefix;
 
@@ -52,5 +49,4 @@ protected:
   void CheckLine(const char* line);
 };
 
-
 #endif
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 403f7fc..081c22e 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -10,8 +10,9 @@
   See the License for more information.
 ============================================================================*/
 #include "cmLoadCommandCommand.h"
-#include "cmCPluginAPI.h"
+
 #include "cmCPluginAPI.cxx"
+#include "cmCPluginAPI.h"
 #include "cmDynamicLoader.h"
 
 #include <cmsys/DynamicLoader.hxx>
@@ -19,19 +20,19 @@
 #include <stdlib.h>
 
 #ifdef __QNX__
-# include <malloc.h> /* for malloc/free on QNX */
+#include <malloc.h> /* for malloc/free on QNX */
 #endif
 
 #include <signal.h>
 extern "C" void TrapsForSignalsCFunction(int sig);
 
-
 // a class for loadabple commands
 class cmLoadedCommand : public cmCommand
 {
 public:
-  cmLoadedCommand() {
-    memset(&this->info,0,sizeof(this->info));
+  cmLoadedCommand()
+  {
+    memset(&this->info, 0, sizeof(this->info));
     this->info.CAPI = &cmStaticCAPI;
   }
 
@@ -42,19 +43,19 @@ public:
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
-    {
-      cmLoadedCommand *newC = new cmLoadedCommand;
-      // we must copy when we clone
-      memcpy(&newC->info,&this->info,sizeof(info));
-      return newC;
-    }
+  {
+    cmLoadedCommand* newC = new cmLoadedCommand;
+    // we must copy when we clone
+    memcpy(&newC->info, &this->info, sizeof(info));
+    return newC;
+  }
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &);
+                           cmExecutionStatus&);
 
   /**
    * This is called at the end after all the information
@@ -64,7 +65,9 @@ public:
    */
   virtual void FinalPass();
   virtual bool HasFinalPass() const
-    { return this->info.FinalPass? true:false; }
+  {
+    return this->info.FinalPass ? true : false;
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
@@ -73,35 +76,31 @@ public:
 
   static const char* LastName;
   static void TrapsForSignals(int sig)
-    {
-      fprintf(stderr, "CMake loaded command %s crashed with signal: %d.\n",
-              cmLoadedCommand::LastName, sig);
-    }
+  {
+    fprintf(stderr, "CMake loaded command %s crashed with signal: %d.\n",
+            cmLoadedCommand::LastName, sig);
+  }
   static void InstallSignalHandlers(const char* name, int remove = 0)
-    {
-      cmLoadedCommand::LastName = name;
-      if(!name)
-        {
-        cmLoadedCommand::LastName = "????";
-        }
-
-      if(!remove)
-        {
-        signal(SIGSEGV, TrapsForSignalsCFunction);
+  {
+    cmLoadedCommand::LastName = name;
+    if (!name) {
+      cmLoadedCommand::LastName = "????";
+    }
+
+    if (!remove) {
+      signal(SIGSEGV, TrapsForSignalsCFunction);
 #ifdef SIGBUS
-        signal(SIGBUS,  TrapsForSignalsCFunction);
+      signal(SIGBUS, TrapsForSignalsCFunction);
 #endif
-        signal(SIGILL,  TrapsForSignalsCFunction);
-        }
-      else
-        {
-        signal(SIGSEGV, 0);
+      signal(SIGILL, TrapsForSignalsCFunction);
+    } else {
+      signal(SIGSEGV, 0);
 #ifdef SIGBUS
-        signal(SIGBUS,  0);
+      signal(SIGBUS, 0);
 #endif
-        signal(SIGILL,  0);
-        }
+      signal(SIGILL, 0);
     }
+  }
 
   cmTypeMacro(cmLoadedCommand, cmCommand);
 
@@ -113,89 +112,80 @@ extern "C" void TrapsForSignalsCFunction(int sig)
   cmLoadedCommand::TrapsForSignals(sig);
 }
 
-
 const char* cmLoadedCommand::LastName = 0;
 
 bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args,
-                                  cmExecutionStatus &)
+                                  cmExecutionStatus&)
 {
-  if (!info.InitialPass)
-    {
+  if (!info.InitialPass) {
     return true;
-    }
+  }
 
   // clear the error string
-  if (this->info.Error)
-    {
+  if (this->info.Error) {
     free(this->info.Error);
-    }
+  }
 
   // create argc and argv and then invoke the command
-  int argc = static_cast<int> (args.size());
-  char **argv = 0;
-  if (argc)
-    {
-    argv = (char **)malloc(argc*sizeof(char *));
-    }
+  int argc = static_cast<int>(args.size());
+  char** argv = 0;
+  if (argc) {
+    argv = (char**)malloc(argc * sizeof(char*));
+  }
   int i;
-  for (i = 0; i < argc; ++i)
-    {
+  for (i = 0; i < argc; ++i) {
     argv[i] = strdup(args[i].c_str());
-    }
+  }
   cmLoadedCommand::InstallSignalHandlers(info.Name);
-  int result = info.InitialPass((void *)&info,
-                                (void *)this->Makefile,argc,argv);
+  int result =
+    info.InitialPass((void*)&info, (void*)this->Makefile, argc, argv);
   cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
-  cmFreeArguments(argc,argv);
+  cmFreeArguments(argc, argv);
 
-  if (result)
-    {
+  if (result) {
     return true;
-    }
+  }
 
   /* Initial Pass must have failed so set the error string */
-  if (this->info.Error)
-    {
+  if (this->info.Error) {
     this->SetError(this->info.Error);
-    }
+  }
   return false;
 }
 
 void cmLoadedCommand::FinalPass()
 {
-  if (this->info.FinalPass)
-    {
+  if (this->info.FinalPass) {
     cmLoadedCommand::InstallSignalHandlers(info.Name);
-    this->info.FinalPass((void *)&this->info,(void *)this->Makefile);
+    this->info.FinalPass((void*)&this->info, (void*)this->Makefile);
     cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
-    }
+  }
 }
 
 cmLoadedCommand::~cmLoadedCommand()
 {
-  if (this->info.Destructor)
-    {
+  if (this->info.Destructor) {
     cmLoadedCommand::InstallSignalHandlers(info.Name);
-    this->info.Destructor((void *)&this->info);
+    this->info.Destructor((void*)&this->info);
     cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
-    }
-  if (this->info.Error)
-    {
+  }
+  if (this->info.Error) {
     free(this->info.Error);
-    }
+  }
 }
 
 // cmLoadCommandCommand
-bool cmLoadCommandCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0031,
-      "The load_command command should not be called; see CMP0031."))
-    { return true; }
-  if(args.size() < 1 )
-    {
+  if (this->Disallowed(
+        cmPolicies::CMP0031,
+        "The load_command command should not be called; see CMP0031.")) {
     return true;
-    }
+  }
+  if (args.size() < 1) {
+    return true;
+  }
 
   // Construct a variable to report what file was loaded, if any.
   // Start by removing the definition in case of failure.
@@ -212,72 +202,64 @@ bool cmLoadCommandCommand
 
   // search for the file
   std::vector<std::string> path;
-  for (unsigned int j = 1; j < args.size(); j++)
-    {
+  for (unsigned int j = 1; j < args.size(); j++) {
     // expand variables
     std::string exp = args[j];
     cmSystemTools::ExpandRegistryValues(exp);
 
     // Glob the entry in case of wildcards.
     cmSystemTools::GlobDirs(exp, path);
-    }
+  }
 
   // Try to find the program.
   std::string fullPath = cmSystemTools::FindFile(moduleName.c_str(), path);
-  if (fullPath == "")
-    {
+  if (fullPath == "") {
     std::ostringstream e;
-    e << "Attempt to load command failed from file \""
-      << moduleName << "\"";
+    e << "Attempt to load command failed from file \"" << moduleName << "\"";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // try loading the shared library / dll
-  cmsys::DynamicLoader::LibraryHandle lib
-    = cmDynamicLoader::OpenLibrary(fullPath.c_str());
-  if(!lib)
-    {
+  cmsys::DynamicLoader::LibraryHandle lib =
+    cmDynamicLoader::OpenLibrary(fullPath.c_str());
+  if (!lib) {
     std::string err = "Attempt to load the library ";
     err += fullPath + " failed.";
     const char* error = cmsys::DynamicLoader::LastError();
-    if ( error )
-      {
+    if (error) {
       err += " Additional error info is:\n";
       err += error;
-      }
+    }
     this->SetError(err);
     return false;
-    }
+  }
 
   // Report what file was loaded for this command.
   this->Makefile->AddDefinition(reportVar, fullPath.c_str());
 
   // find the init function
   std::string initFuncName = args[0] + "Init";
-  CM_INIT_FUNCTION initFunction
-    = (CM_INIT_FUNCTION)
-    cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName.c_str());
-  if ( !initFunction )
-    {
+  CM_INIT_FUNCTION initFunction =
+    (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(
+      lib, initFuncName.c_str());
+  if (!initFunction) {
     initFuncName = "_";
     initFuncName += args[0];
     initFuncName += "Init";
     initFunction = (CM_INIT_FUNCTION)(
       cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName.c_str()));
-    }
+  }
   // if the symbol is found call it to set the name on the
   // function blocker
-  if(initFunction)
-    {
+  if (initFunction) {
     // create a function blocker and set it up
-    cmLoadedCommand *f = new cmLoadedCommand();
+    cmLoadedCommand* f = new cmLoadedCommand();
     (*initFunction)(&f->info);
     this->Makefile->GetState()->AddCommand(f);
     return true;
-    }
+  }
   this->SetError("Attempt to load command failed. "
                  "No init function found.");
   return false;
 }
-
diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h
index 445e167..e00a01e 100644
--- a/Source/cmLoadCommandCommand.h
+++ b/Source/cmLoadCommandCommand.h
@@ -19,11 +19,9 @@ class cmLoadCommandCommand : public cmCommand
 public:
   virtual cmCommand* Clone() { return new cmLoadCommandCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const {return "load_command";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "load_command"; }
   cmTypeMacro(cmLoadCommandCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 5a18e2f..3ebd128 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -14,8 +14,8 @@
 #include "cmMakefile.h"
 
 cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
-                                               cmMakefile* mf):
-  cmLocalGenerator(gg, mf)
+                                               cmMakefile* mf)
+  : cmLocalGenerator(gg, mf)
 {
 }
 
@@ -26,14 +26,11 @@ cmLocalCommonGenerator::~cmLocalCommonGenerator()
 void cmLocalCommonGenerator::SetConfigName()
 {
   // Store the configuration name that will be generated.
-  if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"))
-    {
+  if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
     // Use the build type given by the user.
     this->ConfigName = config;
-    }
-  else
-    {
+  } else {
     // No configuration type given.
     this->ConfigName = "";
-    }
+  }
 }
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index 6b4b1cd..d282054 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -19,7 +19,7 @@ class cmCommonTargetGenerator;
 /** \class cmLocalCommonGenerator
  * \brief Common infrastructure for Makefile and Ninja local generators.
  */
-class cmLocalCommonGenerator: public cmLocalGenerator
+class cmLocalCommonGenerator : public cmLocalGenerator
 {
 public:
   cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 586e4c6..e91eb46 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -11,26 +11,26 @@
 ============================================================================*/
 #include "cmLocalGenerator.h"
 
+#include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpressionEvaluationFile.h"
 #include "cmGlobalGenerator.h"
-#include "cmInstallGenerator.h"
 #include "cmInstallFilesGenerator.h"
-#include "cmGeneratorExpressionEvaluationFile.h"
+#include "cmInstallGenerator.h"
 #include "cmInstallScriptGenerator.h"
 #include "cmInstallTargetGenerator.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmTest.h"
 #include "cmTestGenerator.h"
-#include "cmCustomCommandGenerator.h"
 #include "cmVersion.h"
 #include "cmake.h"
-#include "cmAlgorithms.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# define CM_LG_ENCODE_OBJECT_NAMES
-# include <cmsys/MD5.h>
+#define CM_LG_ENCODE_OBJECT_NAMES
+#include <cmsys/MD5.h>
 #endif
 
 #include <ctype.h> // for isalpha
@@ -42,10 +42,9 @@
 #include <StorageDefs.h>
 #endif
 
-cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
-                                   cmMakefile* makefile)
-  : cmOutputConverter(makefile->GetStateSnapshot()),
-    StateSnapshot(makefile->GetStateSnapshot())
+cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
+  : cmOutputConverter(makefile->GetStateSnapshot())
+  , StateSnapshot(makefile->GetStateSnapshot())
 {
   this->GlobalGenerator = gg;
 
@@ -69,56 +68,38 @@ cmLocalGenerator::~cmLocalGenerator()
 void cmLocalGenerator::IssueMessage(cmake::MessageType t,
                                     std::string const& text) const
 {
-  cmListFileContext lfc;
-  lfc.FilePath = this->StateSnapshot.GetDirectory().GetCurrentSource();
-  lfc.FilePath += "/CMakeLists.txt";
-
-  if(!this->GlobalGenerator->GetCMakeInstance()->GetIsInTryCompile())
-    {
-    cmOutputConverter converter(this->StateSnapshot);
-    lfc.FilePath = converter.Convert(lfc.FilePath, cmLocalGenerator::HOME);
-    }
-  lfc.Line = 0;
-  this->GlobalGenerator->GetCMakeInstance()->IssueMessage(t, text, lfc);
+  this->Makefile->IssueMessage(t, text);
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::ComputeObjectMaxPath()
 {
-  // Choose a maximum object file name length.
+// Choose a maximum object file name length.
 #if defined(_WIN32) || defined(__CYGWIN__)
   this->ObjectPathMax = 250;
 #else
   this->ObjectPathMax = 1000;
 #endif
   const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX");
-  if(plen && *plen)
-    {
+  if (plen && *plen) {
     unsigned int pmax;
-    if(sscanf(plen, "%u", &pmax) == 1)
-      {
-      if(pmax >= 128)
-        {
+    if (sscanf(plen, "%u", &pmax) == 1) {
+      if (pmax >= 128) {
         this->ObjectPathMax = pmax;
-        }
-      else
-        {
+      } else {
         std::ostringstream w;
         w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax
           << ", which is less than the minimum of 128.  "
           << "The value will be ignored.";
         this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-        }
       }
-    else
-      {
+    } else {
       std::ostringstream w;
       w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen
         << "\", which fails to parse as a positive integer.  "
         << "The value will be ignored.";
       this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-      }
     }
+  }
   this->ObjectMaxPathViolations.clear();
 }
 
@@ -126,42 +107,36 @@ void cmLocalGenerator::TraceDependencies()
 {
   std::vector<std::string> configs;
   this->Makefile->GetConfigurations(configs);
-  if (configs.empty())
-    {
+  if (configs.empty()) {
     configs.push_back("");
-    }
-  for(std::vector<std::string>::const_iterator ci = configs.begin();
-      ci != configs.end(); ++ci)
-    {
+  }
+  for (std::vector<std::string>::const_iterator ci = configs.begin();
+       ci != configs.end(); ++ci) {
     this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
-    }
+  }
   // Generate the rule files for each target.
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
-    if ((*t)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+       t != targets.end(); ++t) {
+    if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
-    (*t)->TraceDependencies();
     }
+    (*t)->TraceDependencies();
+  }
 }
 
 void cmLocalGenerator::GenerateTestFiles()
 {
-  if ( !this->Makefile->IsOn("CMAKE_TESTING_ENABLED") )
-    {
+  if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) {
     return;
-    }
+  }
 
   // Compute the set of configurations.
   std::vector<std::string> configurationTypes;
   const std::string& config =
     this->Makefile->GetConfigurations(configurationTypes, false);
 
-  std::string file =
-      this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
   file += "/";
   file += "CTestTestfile.cmake";
 
@@ -170,11 +145,9 @@ void cmLocalGenerator::GenerateTestFiles()
 
   fout << "# CMake generated Testfile for " << std::endl
        << "# Source directory: "
-       << this->StateSnapshot.GetDirectory().GetCurrentSource()
-       << std::endl
+       << this->StateSnapshot.GetDirectory().GetCurrentSource() << std::endl
        << "# Build directory: "
-       << this->StateSnapshot.GetDirectory().GetCurrentBinary()
-       << std::endl
+       << this->StateSnapshot.GetDirectory().GetCurrentBinary() << std::endl
        << "# " << std::endl
        << "# This file includes the relevant testing commands "
        << "required for " << std::endl
@@ -183,130 +156,112 @@ void cmLocalGenerator::GenerateTestFiles()
 
   const char* testIncludeFile =
     this->Makefile->GetProperty("TEST_INCLUDE_FILE");
-  if ( testIncludeFile )
-    {
+  if (testIncludeFile) {
     fout << "include(\"" << testIncludeFile << "\")" << std::endl;
-    }
+  }
 
   // Ask each test generator to write its code.
-  std::vector<cmTestGenerator*> const&
-    testers = this->Makefile->GetTestGenerators();
-  for(std::vector<cmTestGenerator*>::const_iterator gi = testers.begin();
-      gi != testers.end(); ++gi)
-    {
+  std::vector<cmTestGenerator*> const& testers =
+    this->Makefile->GetTestGenerators();
+  for (std::vector<cmTestGenerator*>::const_iterator gi = testers.begin();
+       gi != testers.end(); ++gi) {
     (*gi)->Compute(this);
     (*gi)->Generate(fout, config, configurationTypes);
-    }
+  }
   size_t i;
-  std::vector<cmState::Snapshot> children
-      = this->Makefile->GetStateSnapshot().GetChildren();
-  for(i = 0; i < children.size(); ++i)
-    {
+  std::vector<cmState::Snapshot> children =
+    this->Makefile->GetStateSnapshot().GetChildren();
+  for (i = 0; i < children.size(); ++i) {
     // TODO: Use add_subdirectory instead?
     fout << "subdirs(";
     std::string outP = children[i].GetDirectory().GetCurrentBinary();
-    fout << this->Convert(outP,START_OUTPUT);
+    fout << this->Convert(outP, START_OUTPUT);
     fout << ")" << std::endl;
-    }
+  }
 }
 
 void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config)
 {
   std::vector<cmGeneratorExpressionEvaluationFile*> ef =
-      this->Makefile->GetEvaluationFiles();
-  for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
-      li = ef.begin(); li != ef.end(); ++li)
-    {
+    this->Makefile->GetEvaluationFiles();
+  for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
+         ef.begin();
+       li != ef.end(); ++li) {
     (*li)->CreateOutputFile(this, config);
-    }
+  }
 }
 
 void cmLocalGenerator::ProcessEvaluationFiles(
-    std::vector<std::string>& generatedFiles)
+  std::vector<std::string>& generatedFiles)
 {
   std::vector<cmGeneratorExpressionEvaluationFile*> ef =
-      this->Makefile->GetEvaluationFiles();
-  for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
-      li = ef.begin();
-      li != ef.end();
-      ++li)
-    {
+    this->Makefile->GetEvaluationFiles();
+  for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
+         ef.begin();
+       li != ef.end(); ++li) {
     (*li)->Generate(this);
-    if (cmSystemTools::GetFatalErrorOccured())
-      {
+    if (cmSystemTools::GetFatalErrorOccured()) {
       return;
-      }
+    }
     std::vector<std::string> files = (*li)->GetFiles();
     std::sort(files.begin(), files.end());
 
     std::vector<std::string> intersection;
-    std::set_intersection(files.begin(), files.end(),
-                          generatedFiles.begin(), generatedFiles.end(),
+    std::set_intersection(files.begin(), files.end(), generatedFiles.begin(),
+                          generatedFiles.end(),
                           std::back_inserter(intersection));
-    if (!intersection.empty())
-      {
+    if (!intersection.empty()) {
       cmSystemTools::Error("Files to be generated by multiple different "
-        "commands: ", cmWrap('"', intersection, '"', " ").c_str());
+                           "commands: ",
+                           cmWrap('"', intersection, '"', " ").c_str());
       return;
-      }
+    }
 
     generatedFiles.insert(generatedFiles.end(), files.begin(), files.end());
     std::vector<std::string>::iterator newIt =
-        generatedFiles.end() - files.size();
+      generatedFiles.end() - files.size();
     std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::GenerateInstallRules()
 {
   // Compute the install prefix.
   const char* prefix = this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX");
 #if defined(_WIN32) && !defined(__CYGWIN__)
   std::string prefix_win32;
-  if(!prefix)
-    {
-    if(!cmSystemTools::GetEnv("SystemDrive", prefix_win32))
-      {
+  if (!prefix) {
+    if (!cmSystemTools::GetEnv("SystemDrive", prefix_win32)) {
       prefix_win32 = "C:";
-      }
+    }
     const char* project_name = this->Makefile->GetDefinition("PROJECT_NAME");
-    if(project_name && project_name[0])
-      {
+    if (project_name && project_name[0]) {
       prefix_win32 += "/Program Files/";
       prefix_win32 += project_name;
-      }
-    else
-      {
+    } else {
       prefix_win32 += "/InstalledCMakeProject";
-      }
-    prefix = prefix_win32.c_str();
     }
+    prefix = prefix_win32.c_str();
+  }
 #elif defined(__HAIKU__)
   char dir[B_PATH_NAME_LENGTH];
-  if (!prefix)
-    {
-    if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir))
-        == B_OK)
-      {
+  if (!prefix) {
+    if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) ==
+        B_OK) {
       prefix = dir;
-      }
-    else
-      {
+    } else {
       prefix = "/boot/system";
-      }
     }
+  }
 #else
-  if (!prefix)
-    {
+  if (!prefix) {
     prefix = "/usr/local";
-    }
+  }
 #endif
-  if (const char *stagingPrefix
-                  = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"))
-    {
+  if (const char* stagingPrefix =
+        this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX")) {
     prefix = stagingPrefix;
-    }
+  }
 
   // Compute the set of configurations.
   std::vector<std::string> configurationTypes;
@@ -315,41 +270,35 @@ void cmLocalGenerator::GenerateInstallRules()
 
   // Choose a default install configuration.
   std::string default_config = config;
-  const char* default_order[] = {"RELEASE", "MINSIZEREL",
-                                 "RELWITHDEBINFO", "DEBUG", 0};
-  for(const char** c = default_order; *c && default_config.empty(); ++c)
-    {
-    for(std::vector<std::string>::iterator i = configurationTypes.begin();
-        i != configurationTypes.end(); ++i)
-      {
-      if(cmSystemTools::UpperCase(*i) == *c)
-        {
+  const char* default_order[] = { "RELEASE", "MINSIZEREL", "RELWITHDEBINFO",
+                                  "DEBUG", 0 };
+  for (const char** c = default_order; *c && default_config.empty(); ++c) {
+    for (std::vector<std::string>::iterator i = configurationTypes.begin();
+         i != configurationTypes.end(); ++i) {
+      if (cmSystemTools::UpperCase(*i) == *c) {
         default_config = *i;
-        }
       }
     }
-  if(default_config.empty() && !configurationTypes.empty())
-    {
+  }
+  if (default_config.empty() && !configurationTypes.empty()) {
     default_config = configurationTypes[0];
-    }
+  }
 
   // Create the install script file.
-  std::string file =
-      this->StateSnapshot.GetDirectory().GetCurrentBinary();
+  std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
   std::string homedir = this->GetState()->GetBinaryDirectory();
   int toplevel_install = 0;
-  if (file == homedir)
-    {
+  if (file == homedir) {
     toplevel_install = 1;
-    }
+  }
   file += "/cmake_install.cmake";
   cmGeneratedFileStream fout(file.c_str());
   fout.SetCopyIfDifferent(true);
 
   // Write the header.
   fout << "# Install script for directory: "
-       << this->StateSnapshot.GetDirectory().GetCurrentSource()
-       << std::endl << std::endl;
+       << this->StateSnapshot.GetDirectory().GetCurrentSource() << std::endl
+       << std::endl;
   fout << "# Set the install prefix" << std::endl
        << "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
        << "  set(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl
@@ -359,6 +308,7 @@ void cmLocalGenerator::GenerateInstallRules()
        << std::endl;
 
   // Write support code for generating per-configuration install rules.
+  /* clang-format off */
   fout <<
     "# Set the install configuration name.\n"
     "if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)\n"
@@ -372,8 +322,10 @@ void cmLocalGenerator::GenerateInstallRules()
     "\\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n"
     "endif()\n"
     "\n";
+  /* clang-format on */
 
   // Write support code for dealing with component-specific installs.
+  /* clang-format off */
   fout <<
     "# Set the component getting installed.\n"
     "if(NOT CMAKE_INSTALL_COMPONENT)\n"
@@ -385,57 +337,55 @@ void cmLocalGenerator::GenerateInstallRules()
     "  endif()\n"
     "endif()\n"
     "\n";
+  /* clang-format on */
 
   // Copy user-specified install options to the install code.
-  if(const char* so_no_exe =
-     this->Makefile->GetDefinition("CMAKE_INSTALL_SO_NO_EXE"))
-    {
+  if (const char* so_no_exe =
+        this->Makefile->GetDefinition("CMAKE_INSTALL_SO_NO_EXE")) {
+    /* clang-format off */
     fout <<
       "# Install shared libraries without execute permission?\n"
       "if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n"
       "  set(CMAKE_INSTALL_SO_NO_EXE \"" << so_no_exe << "\")\n"
       "endif()\n"
       "\n";
-    }
+    /* clang-format on */
+  }
 
   // Ask each install generator to write its code.
   std::vector<cmInstallGenerator*> const& installers =
     this->Makefile->GetInstallGenerators();
-  for(std::vector<cmInstallGenerator*>::const_iterator
-        gi = installers.begin();
-      gi != installers.end(); ++gi)
-    {
+  for (std::vector<cmInstallGenerator*>::const_iterator gi =
+         installers.begin();
+       gi != installers.end(); ++gi) {
     (*gi)->Generate(fout, config, configurationTypes);
-    }
+  }
 
   // Write rules from old-style specification stored in targets.
   this->GenerateTargetInstallRules(fout, config, configurationTypes);
 
   // Include install scripts from subdirectories.
-  std::vector<cmState::Snapshot> children
-      = this->Makefile->GetStateSnapshot().GetChildren();
-  if(!children.empty())
-    {
+  std::vector<cmState::Snapshot> children =
+    this->Makefile->GetStateSnapshot().GetChildren();
+  if (!children.empty()) {
     fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n";
     fout << "  # Include the install script for each subdirectory.\n";
-    for(std::vector<cmState::Snapshot>::const_iterator
-          ci = children.begin(); ci != children.end(); ++ci)
-      {
-      if(!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-        {
+    for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin();
+         ci != children.end(); ++ci) {
+      if (!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
         std::string odir = ci->GetDirectory().GetCurrentBinary();
         cmSystemTools::ConvertToUnixSlashes(odir);
-        fout << "  include(\"" <<  odir
-             << "/cmake_install.cmake\")" << std::endl;
-        }
+        fout << "  include(\"" << odir << "/cmake_install.cmake\")"
+             << std::endl;
       }
+    }
     fout << "\n";
     fout << "endif()\n\n";
-    }
+  }
 
   // Record the install manifest.
-  if ( toplevel_install )
-    {
+  if (toplevel_install) {
+    /* clang-format off */
     fout <<
       "if(CMAKE_INSTALL_COMPONENT)\n"
       "  set(CMAKE_INSTALL_MANIFEST \"install_manifest_"
@@ -448,10 +398,10 @@ void cmLocalGenerator::GenerateInstallRules()
       "       \"${CMAKE_INSTALL_MANIFEST_FILES}\")\n"
       "file(WRITE \"" << homedir << "/${CMAKE_INSTALL_MANIFEST}\"\n"
       "     \"${CMAKE_INSTALL_MANIFEST_CONTENT}\")\n";
-    }
+    /* clang-format on */
+  }
 }
 
-
 void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
 {
   this->GeneratorTargets.push_back(gt);
@@ -474,59 +424,52 @@ struct NamedGeneratorTargetFinder
   NamedGeneratorTargetFinder(std::string const& name)
     : Name(name)
   {
-
   }
 
   bool operator()(cmGeneratorTarget* tgt)
   {
     return tgt->GetName() == this->Name;
   }
+
 private:
   std::string Name;
 };
 
 cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget(
-    const std::string& name) const
+  const std::string& name) const
 {
   std::vector<cmGeneratorTarget*>::const_iterator ti =
-      std::find_if(this->GeneratorTargets.begin(),
-                   this->GeneratorTargets.end(),
-                   NamedGeneratorTargetFinder(name));
-  if ( ti != this->GeneratorTargets.end() )
-    {
+    std::find_if(this->GeneratorTargets.begin(), this->GeneratorTargets.end(),
+                 NamedGeneratorTargetFinder(name));
+  if (ti != this->GeneratorTargets.end()) {
     return *ti;
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::ComputeTargetManifest()
 {
   // Collect the set of configuration types.
   std::vector<std::string> configNames;
   this->Makefile->GetConfigurations(configNames);
-  if(configNames.empty())
-    {
+  if (configNames.empty()) {
     configNames.push_back("");
-    }
+  }
 
   // Add our targets to the manifest for each configuration.
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+       t != targets.end(); ++t) {
     cmGeneratorTarget* target = *t;
-    if (target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (target->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
-    for(std::vector<std::string>::iterator ci = configNames.begin();
-        ci != configNames.end(); ++ci)
-      {
+    }
+    for (std::vector<std::string>::iterator ci = configNames.begin();
+         ci != configNames.end(); ++ci) {
       const char* config = ci->c_str();
       target->ComputeTargetManifest(config);
-      }
     }
+  }
 }
 
 bool cmLocalGenerator::IsRootMakefile() const
@@ -549,8 +492,7 @@ cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
 // replaced in the form <var> with GetSafeDefinition(var).
 // ${LANG} is replaced in the variable first with all enabled
 // languages.
-static const char* ruleReplaceVars[] =
-{
+static const char* ruleReplaceVars[] = {
   "CMAKE_${LANG}_COMPILER",
   "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
   "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
@@ -568,266 +510,195 @@ static const char* ruleReplaceVars[] =
   0
 };
 
-std::string
-cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
-                                     const RuleVariables& replaceValues)
+std::string cmLocalGenerator::ExpandRuleVariable(
+  std::string const& variable, const RuleVariables& replaceValues)
 {
-  if(replaceValues.LinkFlags)
-    {
-    if(variable == "LINK_FLAGS")
-      {
+  if (replaceValues.LinkFlags) {
+    if (variable == "LINK_FLAGS") {
       return replaceValues.LinkFlags;
-      }
     }
-  if(replaceValues.Manifests)
-    {
-    if(variable == "MANIFESTS")
-      {
+  }
+  if (replaceValues.Manifests) {
+    if (variable == "MANIFESTS") {
       return replaceValues.Manifests;
-      }
     }
-  if(replaceValues.Flags)
-    {
-    if(variable == "FLAGS")
-      {
+  }
+  if (replaceValues.Flags) {
+    if (variable == "FLAGS") {
       return replaceValues.Flags;
-      }
     }
+  }
 
-  if(replaceValues.Source)
-    {
-    if(variable == "SOURCE")
-      {
+  if (replaceValues.Source) {
+    if (variable == "SOURCE") {
       return replaceValues.Source;
-      }
     }
-  if(replaceValues.PreprocessedSource)
-    {
-    if(variable == "PREPROCESSED_SOURCE")
-      {
+  }
+  if (replaceValues.PreprocessedSource) {
+    if (variable == "PREPROCESSED_SOURCE") {
       return replaceValues.PreprocessedSource;
-      }
     }
-  if(replaceValues.AssemblySource)
-    {
-    if(variable == "ASSEMBLY_SOURCE")
-      {
+  }
+  if (replaceValues.AssemblySource) {
+    if (variable == "ASSEMBLY_SOURCE") {
       return replaceValues.AssemblySource;
-      }
     }
-  if(replaceValues.Object)
-    {
-    if(variable == "OBJECT")
-      {
+  }
+  if (replaceValues.Object) {
+    if (variable == "OBJECT") {
       return replaceValues.Object;
-      }
     }
-  if(replaceValues.ObjectDir)
-    {
-    if(variable == "OBJECT_DIR")
-      {
+  }
+  if (replaceValues.ObjectDir) {
+    if (variable == "OBJECT_DIR") {
       return replaceValues.ObjectDir;
-      }
     }
-  if(replaceValues.ObjectFileDir)
-    {
-    if(variable == "OBJECT_FILE_DIR")
-      {
+  }
+  if (replaceValues.ObjectFileDir) {
+    if (variable == "OBJECT_FILE_DIR") {
       return replaceValues.ObjectFileDir;
-      }
     }
-  if(replaceValues.Objects)
-    {
-    if(variable == "OBJECTS")
-      {
+  }
+  if (replaceValues.Objects) {
+    if (variable == "OBJECTS") {
       return replaceValues.Objects;
-      }
     }
-  if(replaceValues.ObjectsQuoted)
-    {
-    if(variable == "OBJECTS_QUOTED")
-      {
+  }
+  if (replaceValues.ObjectsQuoted) {
+    if (variable == "OBJECTS_QUOTED") {
       return replaceValues.ObjectsQuoted;
-      }
     }
-  if(replaceValues.Defines && variable == "DEFINES")
-    {
+  }
+  if (replaceValues.Defines && variable == "DEFINES") {
     return replaceValues.Defines;
-    }
-  if(replaceValues.Includes && variable == "INCLUDES")
-    {
+  }
+  if (replaceValues.Includes && variable == "INCLUDES") {
     return replaceValues.Includes;
-    }
-  if(replaceValues.TargetPDB )
-    {
-    if(variable == "TARGET_PDB")
-      {
+  }
+  if (replaceValues.TargetPDB) {
+    if (variable == "TARGET_PDB") {
       return replaceValues.TargetPDB;
-      }
     }
-  if(replaceValues.TargetCompilePDB)
-    {
-    if(variable == "TARGET_COMPILE_PDB")
-      {
+  }
+  if (replaceValues.TargetCompilePDB) {
+    if (variable == "TARGET_COMPILE_PDB") {
       return replaceValues.TargetCompilePDB;
-      }
     }
-  if(replaceValues.DependencyFile )
-    {
-    if(variable == "DEP_FILE")
-      {
+  }
+  if (replaceValues.DependencyFile) {
+    if (variable == "DEP_FILE") {
       return replaceValues.DependencyFile;
-      }
     }
+  }
 
-  if(replaceValues.Target)
-    {
-    if(variable == "TARGET_QUOTED")
-      {
+  if (replaceValues.Target) {
+    if (variable == "TARGET_QUOTED") {
       std::string targetQuoted = replaceValues.Target;
-      if(!targetQuoted.empty() && targetQuoted[0] != '\"')
-        {
+      if (!targetQuoted.empty() && targetQuoted[0] != '\"') {
         targetQuoted = '\"';
         targetQuoted += replaceValues.Target;
         targetQuoted += '\"';
-        }
-      return targetQuoted;
       }
-    if(variable == "TARGET_UNQUOTED")
-      {
+      return targetQuoted;
+    }
+    if (variable == "TARGET_UNQUOTED") {
       std::string unquoted = replaceValues.Target;
       std::string::size_type sz = unquoted.size();
-      if(sz > 2 && unquoted[0] == '\"' && unquoted[sz-1] == '\"')
-        {
-        unquoted = unquoted.substr(1, sz-2);
-        }
-      return unquoted;
+      if (sz > 2 && unquoted[0] == '\"' && unquoted[sz - 1] == '\"') {
+        unquoted = unquoted.substr(1, sz - 2);
       }
-    if(replaceValues.LanguageCompileFlags)
-      {
-      if(variable == "LANGUAGE_COMPILE_FLAGS")
-        {
+      return unquoted;
+    }
+    if (replaceValues.LanguageCompileFlags) {
+      if (variable == "LANGUAGE_COMPILE_FLAGS") {
         return replaceValues.LanguageCompileFlags;
-        }
       }
-    if(replaceValues.Target)
-      {
-      if(variable == "TARGET")
-        {
+    }
+    if (replaceValues.Target) {
+      if (variable == "TARGET") {
         return replaceValues.Target;
-        }
       }
-    if(variable == "TARGET_IMPLIB")
-      {
+    }
+    if (variable == "TARGET_IMPLIB") {
       return this->TargetImplib;
-      }
-    if(variable == "TARGET_VERSION_MAJOR")
-      {
-      if(replaceValues.TargetVersionMajor)
-        {
+    }
+    if (variable == "TARGET_VERSION_MAJOR") {
+      if (replaceValues.TargetVersionMajor) {
         return replaceValues.TargetVersionMajor;
-        }
-      else
-        {
+      } else {
         return "0";
-        }
       }
-    if(variable == "TARGET_VERSION_MINOR")
-      {
-      if(replaceValues.TargetVersionMinor)
-        {
+    }
+    if (variable == "TARGET_VERSION_MINOR") {
+      if (replaceValues.TargetVersionMinor) {
         return replaceValues.TargetVersionMinor;
-        }
-      else
-        {
+      } else {
         return "0";
-        }
       }
-    if(replaceValues.Target)
-      {
-      if(variable == "TARGET_BASE")
-        {
+    }
+    if (replaceValues.Target) {
+      if (variable == "TARGET_BASE") {
         // Strip the last extension off the target name.
         std::string targetBase = replaceValues.Target;
-        std::string::size_type pos = targetBase.rfind(".");
-        if(pos != targetBase.npos)
-          {
-        return targetBase.substr(0, pos);
-          }
-        else
-          {
+        std::string::size_type pos = targetBase.rfind('.');
+        if (pos != targetBase.npos) {
+          return targetBase.substr(0, pos);
+        } else {
           return targetBase;
-          }
         }
       }
     }
-  if(variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
-     variable == "TARGET_INSTALLNAME_DIR")
-    {
+  }
+  if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
+      variable == "TARGET_INSTALLNAME_DIR") {
     // All these variables depend on TargetSOName
-    if(replaceValues.TargetSOName)
-      {
-      if(variable == "TARGET_SONAME")
-        {
+    if (replaceValues.TargetSOName) {
+      if (variable == "TARGET_SONAME") {
         return replaceValues.TargetSOName;
-        }
-      if(variable == "SONAME_FLAG" && replaceValues.SONameFlag)
-        {
+      }
+      if (variable == "SONAME_FLAG" && replaceValues.SONameFlag) {
         return replaceValues.SONameFlag;
-        }
-      if(replaceValues.TargetInstallNameDir &&
-         variable == "TARGET_INSTALLNAME_DIR")
-        {
+      }
+      if (replaceValues.TargetInstallNameDir &&
+          variable == "TARGET_INSTALLNAME_DIR") {
         return replaceValues.TargetInstallNameDir;
-        }
       }
-    return "";
     }
-  if(replaceValues.LinkLibraries)
-    {
-    if(variable == "LINK_LIBRARIES")
-      {
+    return "";
+  }
+  if (replaceValues.LinkLibraries) {
+    if (variable == "LINK_LIBRARIES") {
       return replaceValues.LinkLibraries;
-      }
     }
-  if(replaceValues.Language)
-    {
-    if(variable == "LANGUAGE")
-      {
+  }
+  if (replaceValues.Language) {
+    if (variable == "LANGUAGE") {
       return replaceValues.Language;
-      }
     }
-  if(replaceValues.CMTarget)
-    {
-    if(variable == "TARGET_NAME")
-      {
+  }
+  if (replaceValues.CMTarget) {
+    if (variable == "TARGET_NAME") {
       return replaceValues.CMTarget->GetName();
-      }
-    if(variable == "TARGET_TYPE")
-      {
+    }
+    if (variable == "TARGET_TYPE") {
       return cmState::GetTargetTypeName(replaceValues.CMTarget->GetType());
-      }
     }
-  if(replaceValues.Output)
-    {
-    if(variable == "OUTPUT")
-      {
+  }
+  if (replaceValues.Output) {
+    if (variable == "OUTPUT") {
       return replaceValues.Output;
-      }
     }
-  if(variable == "CMAKE_COMMAND")
-    {
+  }
+  if (variable == "CMAKE_COMMAND") {
     return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL);
-    }
+  }
   std::vector<std::string> enabledLanguages =
-      this->GetState()->GetEnabledLanguages();
+    this->GetState()->GetEnabledLanguages();
   // loop over language specific replace variables
   int pos = 0;
-  while(ruleReplaceVars[pos])
-    {
-    for(std::vector<std::string>::iterator i = enabledLanguages.begin();
-        i != enabledLanguages.end(); ++i)
-      {
+  while (ruleReplaceVars[pos]) {
+    for (std::vector<std::string>::iterator i = enabledLanguages.begin();
+         i != enabledLanguages.end(); ++i) {
       const char* lang = i->c_str();
       std::string actualReplace = ruleReplaceVars[pos];
       // If this is the compiler then look for the extra variable
@@ -839,225 +710,176 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
       const char* compilerOptionExternalToolchain = 0;
       const char* compilerSysroot = 0;
       const char* compilerOptionSysroot = 0;
-      if(actualReplace == "CMAKE_${LANG}_COMPILER")
-        {
+      if (actualReplace == "CMAKE_${LANG}_COMPILER") {
         std::string arg1 = actualReplace + "_ARG1";
         cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
         compilerArg1 = this->Makefile->GetDefinition(arg1);
-        compilerTarget
-              = this->Makefile->GetDefinition(
-                std::string("CMAKE_") + lang + "_COMPILER_TARGET");
-        compilerOptionTarget
-              = this->Makefile->GetDefinition(
-                std::string("CMAKE_") + lang +
-                                          "_COMPILE_OPTIONS_TARGET");
-        compilerExternalToolchain
-              = this->Makefile->GetDefinition(
-                std::string("CMAKE_") + lang +
-                                    "_COMPILER_EXTERNAL_TOOLCHAIN");
-        compilerOptionExternalToolchain
-              = this->Makefile->GetDefinition(
-                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");
-        }
-      if(actualReplace.find("${LANG}") != actualReplace.npos)
-        {
+        compilerTarget = this->Makefile->GetDefinition(
+          std::string("CMAKE_") + lang + "_COMPILER_TARGET");
+        compilerOptionTarget = this->Makefile->GetDefinition(
+          std::string("CMAKE_") + lang + "_COMPILE_OPTIONS_TARGET");
+        compilerExternalToolchain = this->Makefile->GetDefinition(
+          std::string("CMAKE_") + lang + "_COMPILER_EXTERNAL_TOOLCHAIN");
+        compilerOptionExternalToolchain =
+          this->Makefile->GetDefinition(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");
+      }
+      if (actualReplace.find("${LANG}") != actualReplace.npos) {
         cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
-        }
-      if(actualReplace == variable)
-        {
-        std::string replace =
-          this->Makefile->GetSafeDefinition(variable);
+      }
+      if (actualReplace == variable) {
+        std::string replace = this->Makefile->GetSafeDefinition(variable);
         // if the variable is not a FLAG then treat it like a path
-        if(variable.find("_FLAG") == variable.npos)
-          {
+        if (variable.find("_FLAG") == variable.npos) {
           std::string ret = this->ConvertToOutputForExisting(replace);
           // if there is a required first argument to the compiler add it
           // to the compiler string
-          if(compilerArg1)
-            {
+          if (compilerArg1) {
             ret += " ";
             ret += compilerArg1;
-            }
-          if (compilerTarget && compilerOptionTarget)
-            {
+          }
+          if (compilerTarget && compilerOptionTarget) {
             ret += " ";
             ret += compilerOptionTarget;
             ret += compilerTarget;
-            }
-          if (compilerExternalToolchain && compilerOptionExternalToolchain)
-            {
+          }
+          if (compilerExternalToolchain && compilerOptionExternalToolchain) {
             ret += " ";
             ret += compilerOptionExternalToolchain;
             ret += this->EscapeForShell(compilerExternalToolchain, true);
-            }
-          if (compilerSysroot && compilerOptionSysroot)
-            {
+          }
+          if (compilerSysroot && compilerOptionSysroot) {
             ret += " ";
             ret += compilerOptionSysroot;
             ret += this->EscapeForShell(compilerSysroot, true);
-            }
-          return ret;
           }
-        return replace;
+          return ret;
         }
+        return replace;
       }
-    pos++;
     }
+    pos++;
+  }
   return variable;
 }
 
-
-void
-cmLocalGenerator::ExpandRuleVariables(std::string& s,
-                                      const RuleVariables& replaceValues)
+void cmLocalGenerator::ExpandRuleVariables(std::string& s,
+                                           const RuleVariables& replaceValues)
 {
-  if(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)
-    {
+  if (start == s.npos) {
     return;
-    }
+  }
   std::string::size_type pos = 0;
   std::string expandedInput;
-  while(start != s.npos && start < s.size()-2)
-    {
+  while (start != s.npos && start < s.size() - 2) {
     std::string::size_type end = s.find('>', start);
     // if we find a < with no > we are done
-    if(end == s.npos)
-      {
+    if (end == s.npos) {
       return;
-      }
-    char c = s[start+1];
+    }
+    char c = s[start + 1];
     // if the next char after the < is not A-Za-z then
     // skip it and try to find the next < in the string
-    if(!isalpha(c))
-      {
-      start = s.find('<', start+1);
-      }
-    else
-      {
+    if (!isalpha(c)) {
+      start = s.find('<', start + 1);
+    } else {
       // extract the var
-      std::string var = s.substr(start+1,  end - start-1);
-      std::string replace = this->ExpandRuleVariable(var,
-                                                     replaceValues);
-      expandedInput += s.substr(pos, start-pos);
+      std::string var = s.substr(start + 1, end - start - 1);
+      std::string replace = this->ExpandRuleVariable(var, replaceValues);
+      expandedInput += s.substr(pos, start - pos);
       expandedInput += replace;
       // move to next one
-      start = s.find('<', start+var.size()+2);
-      pos = end+1;
-      }
+      start = s.find('<', start + var.size() + 2);
+      pos = end + 1;
     }
+  }
   // add the rest of the input
-  expandedInput += s.substr(pos, s.size()-pos);
+  expandedInput += s.substr(pos, s.size() - pos);
   s = expandedInput;
 }
 
-//----------------------------------------------------------------------------
 const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
                                               const std::string& prop)
 {
-  if(target)
-    {
+  if (target) {
     return target->GetProperty(prop);
-    }
-  else
-    {
+  } else {
     return this->Makefile->GetProperty(prop);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::InsertRuleLauncher(std::string& s,
                                           cmGeneratorTarget* target,
                                           const std::string& prop)
 {
-  if(const char* val = this->GetRuleLauncher(target, prop))
-    {
+  if (const char* val = this->GetRuleLauncher(target, prop)) {
     std::ostringstream wrapped;
     wrapped << val << " " << s;
     s = wrapped.str();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
-                                            OutputFormat format,
-                                            bool forceFullPaths)
+std::string cmLocalGenerator::ConvertToIncludeReference(
+  std::string const& path, OutputFormat format, bool forceFullPaths)
 {
   return this->ConvertToOutputForExisting(
-    path, forceFullPaths? FULL : START_OUTPUT, format);
+    path, forceFullPaths ? FULL : START_OUTPUT, format);
 }
 
-//----------------------------------------------------------------------------
 std::string cmLocalGenerator::GetIncludeFlags(
-                                     const std::vector<std::string> &includes,
-                                     cmGeneratorTarget* target,
-                                     const std::string& lang,
-                                     bool forceFullPaths,
-                                     bool forResponseFile,
-                                     const std::string& config)
-{
-  if(lang.empty())
-    {
+  const std::vector<std::string>& includes, cmGeneratorTarget* target,
+  const std::string& lang, bool forceFullPaths, bool forResponseFile,
+  const std::string& config)
+{
+  if (lang.empty()) {
     return "";
-    }
+  }
 
-  OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
+  OutputFormat shellFormat = forResponseFile ? RESPONSE : SHELL;
   std::ostringstream includeFlags;
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
   flagVar += lang;
-  const char* includeFlag =
-    this->Makefile->GetSafeDefinition(flagVar);
+  const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar);
   flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
   flagVar += lang;
   const char* sep = this->Makefile->GetDefinition(flagVar);
   bool quotePaths = false;
-  if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS"))
-    {
+  if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) {
     quotePaths = true;
-    }
+  }
   bool repeatFlag = true;
   // should the include flag be repeated like ie. -IA -IB
-  if(!sep)
-    {
+  if (!sep) {
     sep = " ";
-    }
-  else
-    {
+  } else {
     // if there is a separator then the flag is not repeated but is only
     // given once i.e.  -classpath a:b:c
     repeatFlag = false;
-    }
+  }
 
   // Support special system include flag if it is available and the
   // normal flag is repeated for each directory.
   std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_";
   sysFlagVar += lang;
   const char* sysIncludeFlag = 0;
-  if(repeatFlag)
-    {
+  if (repeatFlag) {
     sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
-    }
+  }
 
   std::string fwSearchFlagVar = "CMAKE_";
   fwSearchFlagVar += lang;
   fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
-  const char* fwSearchFlag =
-    this->Makefile->GetDefinition(fwSearchFlagVar);
+  const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
 
   std::string sysFwSearchFlagVar = "CMAKE_";
   sysFwSearchFlagVar += lang;
@@ -1071,67 +893,53 @@ std::string cmLocalGenerator::GetIncludeFlags(
   emitted.insert("/System/Library/Frameworks");
 #endif
   std::vector<std::string>::const_iterator i;
-  for(i = includes.begin(); i != includes.end(); ++i)
-    {
-    if(fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE")
-       && cmSystemTools::IsPathToFramework(i->c_str()))
-      {
+  for (i = includes.begin(); i != includes.end(); ++i) {
+    if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") &&
+        cmSystemTools::IsPathToFramework(i->c_str())) {
       std::string frameworkDir = *i;
       frameworkDir += "/../";
       frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
-      if(emitted.insert(frameworkDir).second)
-        {
+      if (emitted.insert(frameworkDir).second) {
         if (sysFwSearchFlag && target &&
-            target->IsSystemIncludeDirectory(*i, config))
-          {
+            target->IsSystemIncludeDirectory(*i, config)) {
           includeFlags << sysFwSearchFlag;
-          }
-        else
-          {
+        } else {
           includeFlags << fwSearchFlag;
-          }
-        includeFlags << this->ConvertToOutputFormat(frameworkDir, shellFormat)
-          << " ";
         }
-      continue;
+        includeFlags << this->ConvertToOutputFormat(frameworkDir, shellFormat)
+                     << " ";
       }
+      continue;
+    }
 
-    if(!flagUsed || repeatFlag)
-      {
-      if(sysIncludeFlag && target &&
-         target->IsSystemIncludeDirectory(*i, config))
-        {
+    if (!flagUsed || repeatFlag) {
+      if (sysIncludeFlag && target &&
+          target->IsSystemIncludeDirectory(*i, config)) {
         includeFlags << sysIncludeFlag;
-        }
-      else
-        {
+      } else {
         includeFlags << includeFlag;
-        }
-      flagUsed = true;
       }
+      flagUsed = true;
+    }
     std::string includePath =
       this->ConvertToIncludeReference(*i, shellFormat, forceFullPaths);
-    if(quotePaths && !includePath.empty() && includePath[0] != '\"')
-      {
+    if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
       includeFlags << "\"";
-      }
+    }
     includeFlags << includePath;
-    if(quotePaths && !includePath.empty() && includePath[0] != '\"')
-      {
+    if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
       includeFlags << "\"";
-      }
-    includeFlags << sep;
     }
+    includeFlags << sep;
+  }
   std::string flags = includeFlags.str();
   // remove trailing separators
-  if((sep[0] != ' ') && !flags.empty() && flags[flags.size()-1] == sep[0])
-    {
-    flags[flags.size()-1] = ' ';
-    }
+  if ((sep[0] != ' ') && !flags.empty() && flags[flags.size() - 1] == sep[0]) {
+    flags[flags.size() - 1] = ' ';
+  }
   return flags;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
                                              cmGeneratorTarget const* target,
                                              const std::string& config,
@@ -1142,98 +950,87 @@ void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
   this->AppendDefines(defines, targetDefines);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::AddCompileOptions(
-  std::string& flags, cmGeneratorTarget* target,
-  const std::string& lang, const std::string& config
-  )
+void cmLocalGenerator::AddCompileOptions(std::string& flags,
+                                         cmGeneratorTarget* target,
+                                         const std::string& lang,
+                                         const std::string& config)
 {
-  std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
+  std::string langFlagRegexVar = std::string("CMAKE_") + lang + "_FLAG_REGEX";
 
-  if(const char* langFlagRegexStr =
-     this->Makefile->GetDefinition(langFlagRegexVar))
-    {
+  if (const char* langFlagRegexStr =
+        this->Makefile->GetDefinition(langFlagRegexVar)) {
     // Filter flags acceptable to this language.
     cmsys::RegularExpression r(langFlagRegexStr);
     std::vector<std::string> opts;
-    if(const char* targetFlags = target->GetProperty("COMPILE_FLAGS"))
-      {
+    if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
       cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
-      }
+    }
     target->GetCompileOptions(opts, config, lang);
-    for(std::vector<std::string>::const_iterator i = opts.begin();
-        i != opts.end(); ++i)
-      {
-      if(r.find(i->c_str()))
-        {
+    for (std::vector<std::string>::const_iterator i = opts.begin();
+         i != opts.end(); ++i) {
+      if (r.find(i->c_str())) {
         // (Re-)Escape this flag.  COMPILE_FLAGS were already parsed
         // as a command line above, and COMPILE_OPTIONS are escaped.
         this->AppendFlagEscape(flags, *i);
-        }
       }
     }
-  else
-    {
+  } else {
     // Use all flags.
-    if(const char* targetFlags = target->GetProperty("COMPILE_FLAGS"))
-      {
+    if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
       // COMPILE_FLAGS are not escaped for historical reasons.
       this->AppendFlags(flags, targetFlags);
-      }
+    }
     std::vector<std::string> opts;
     target->GetCompileOptions(opts, config, lang);
-    for(std::vector<std::string>::const_iterator i = opts.begin();
-        i != opts.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i = opts.begin();
+         i != opts.end(); ++i) {
       // COMPILE_OPTIONS are escaped.
       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->Target, *it))
-      {
+  for (std::vector<std::string>::const_iterator it = features.begin();
+       it != features.end(); ++it) {
+    if (!this->Makefile->AddRequiredTargetFeature(target->Target, *it)) {
       return;
-      }
     }
+  }
 
-  for(std::map<std::string, std::string>::const_iterator it
-      = target->GetMaxLanguageStandards().begin();
-      it != target->GetMaxLanguageStandards().end(); ++it)
-    {
+  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)
-      {
+    if (!standard) {
       continue;
-      }
-    if (this->Makefile->IsLaterStandard(it->first, standard, it->second))
-      {
+    }
+    if (this->Makefile->IsLaterStandard(it->first, standard, it->second)) {
       std::ostringstream 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;
+      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->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
     }
+  }
   this->AddCompilerRequirementFlag(flags, target, lang);
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
                                              cmGeneratorTarget const* target,
                                              const std::string& lang,
                                              const std::string& config,
-                                             bool stripImplicitInclDirs
-                                            ) const
+                                             bool stripImplicitInclDirs) const
 {
   // Need to decide whether to automatically include the source and
   // binary directories at the beginning of the include path.
@@ -1247,39 +1044,33 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
   // file in a subdirectory of the current source directory but we
   // cannot fix this because not all native build tools support
   // per-source-file include paths.
-  if(this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR"))
-    {
+  if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) {
     includeSourceDir = true;
     includeBinaryDir = true;
-    }
+  }
 
   // Do not repeat an include path.
   std::set<std::string> emitted;
 
   // Store the automatic include paths.
-  if(includeBinaryDir)
-    {
+  if (includeBinaryDir) {
     std::string binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
-    if(emitted.find(binDir) == emitted.end())
-      {
+    if (emitted.find(binDir) == emitted.end()) {
       dirs.push_back(binDir);
       emitted.insert(binDir);
-      }
     }
-  if(includeSourceDir)
-    {
+  }
+  if (includeSourceDir) {
     std::string srcDir = this->StateSnapshot.GetDirectory().GetCurrentSource();
-    if(emitted.find(srcDir) == emitted.end())
-      {
+    if (emitted.find(srcDir) == emitted.end()) {
       dirs.push_back(srcDir);
       emitted.insert(srcDir);
-      }
     }
+  }
 
-  if(!target)
-    {
+  if (!target) {
     return;
-    }
+  }
 
   std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
 
@@ -1288,22 +1079,19 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
   std::string impDirVar = "CMAKE_";
   impDirVar += lang;
   impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES";
-  if(const char* value = this->Makefile->GetDefinition(impDirVar))
-    {
+  if (const char* value = this->Makefile->GetDefinition(impDirVar)) {
     std::vector<std::string> impDirVec;
     cmSystemTools::ExpandListArgument(value, impDirVec);
-    for(std::vector<std::string>::const_iterator i = impDirVec.begin();
-        i != impDirVec.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i = impDirVec.begin();
+         i != impDirVec.end(); ++i) {
       std::string d = rootPath + *i;
       cmSystemTools::ConvertToUnixSlashes(d);
       emitted.insert(d);
-      if (!stripImplicitInclDirs)
-        {
+      if (!stripImplicitInclDirs) {
         implicitDirs.push_back(*i);
-        }
       }
     }
+  }
 
   // Get the target-specific include directories.
   std::vector<std::string> includes;
@@ -1312,74 +1100,61 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
 
   // Support putting all the in-project include directories first if
   // it is requested by the project.
-  if(this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"))
-    {
+  if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) {
     const char* topSourceDir = this->GetState()->GetSourceDirectory();
     const char* topBinaryDir = this->GetState()->GetBinaryDirectory();
-    for(std::vector<std::string>::const_iterator i = includes.begin();
-        i != includes.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i = includes.begin();
+         i != includes.end(); ++i) {
       // Emit this directory only if it is a subdirectory of the
       // top-level source or binary tree.
-      if(cmSystemTools::ComparePath(*i, topSourceDir) ||
-         cmSystemTools::ComparePath(*i, topBinaryDir) ||
-         cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
-         cmSystemTools::IsSubDirectory(*i, topBinaryDir))
-        {
-        if(emitted.insert(*i).second)
-          {
+      if (cmSystemTools::ComparePath(*i, topSourceDir) ||
+          cmSystemTools::ComparePath(*i, topBinaryDir) ||
+          cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
+          cmSystemTools::IsSubDirectory(*i, topBinaryDir)) {
+        if (emitted.insert(*i).second) {
           dirs.push_back(*i);
-          }
         }
       }
     }
+  }
 
   // Construct the final ordered include directory list.
-  for(std::vector<std::string>::const_iterator i = includes.begin();
-      i != includes.end(); ++i)
-    {
-    if(emitted.insert(*i).second)
-      {
+  for (std::vector<std::string>::const_iterator i = includes.begin();
+       i != includes.end(); ++i) {
+    if (emitted.insert(*i).second) {
       dirs.push_back(*i);
-      }
     }
+  }
 
-  for(std::vector<std::string>::const_iterator i = implicitDirs.begin();
-      i != implicitDirs.end(); ++i)
-    {
-    if(std::find(includes.begin(), includes.end(), *i) != includes.end())
-      {
+  for (std::vector<std::string>::const_iterator i = implicitDirs.begin();
+       i != implicitDirs.end(); ++i) {
+    if (std::find(includes.begin(), includes.end(), *i) != includes.end()) {
       dirs.push_back(*i);
-      }
     }
+  }
 }
 
 void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
                                              std::string const& config,
                                              cmGeneratorTarget* target)
 {
-  this->AppendFlags(flags,
-    this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
-  if(!config.empty())
-    {
+  this->AppendFlags(
+    flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
+  if (!config.empty()) {
     std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
     this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name));
-    }
+  }
   this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     std::string name = "STATIC_LIBRARY_FLAGS_" + config;
     this->AppendFlags(flags, target->GetProperty(name));
-    }
+  }
 }
 
-void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
-                                 std::string& flags,
-                                 std::string& linkFlags,
-                                 std::string& frameworkPath,
-                                 std::string& linkPath,
-                                 cmGeneratorTarget* target,
-                                 bool useWatcomQuote)
+void cmLocalGenerator::GetTargetFlags(
+  std::string& linkLibs, std::string& flags, std::string& linkFlags,
+  std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target,
+  bool useWatcomQuote)
 {
   std::string buildType =
     this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -1387,140 +1162,115 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
   const char* libraryLinkVariable =
     "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library
 
-  switch(target->GetType())
-    {
+  switch (target->GetType()) {
     case cmState::STATIC_LIBRARY:
       this->GetStaticLibraryFlags(linkFlags, buildType, target);
       break;
     case cmState::MODULE_LIBRARY:
       libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
-    case cmState::SHARED_LIBRARY:
-      {
+    case cmState::SHARED_LIBRARY: {
       linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable);
       linkFlags += " ";
-      if(!buildType.empty())
-        {
+      if (!buildType.empty()) {
         std::string build = libraryLinkVariable;
         build += "_";
         build += buildType;
         linkFlags += this->Makefile->GetSafeDefinition(build);
         linkFlags += " ";
-        }
-      if(this->Makefile->IsOn("WIN32") &&
-         !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
-        {
+      }
+      if (this->Makefile->IsOn("WIN32") &&
+          !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) {
         std::vector<cmSourceFile*> sources;
         target->GetSourceFiles(sources, buildType);
-        for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
-            i != sources.end(); ++i)
-          {
+        for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
+             i != sources.end(); ++i) {
           cmSourceFile* sf = *i;
-          if(sf->GetExtension() == "def")
-            {
+          if (sf->GetExtension() == "def") {
             linkFlags +=
               this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
-            linkFlags += this->Convert(sf->GetFullPath(),
-                                       FULL, SHELL);
+            linkFlags += this->Convert(sf->GetFullPath(), FULL, SHELL);
             linkFlags += " ";
-            }
           }
         }
+      }
       const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
-      if(targetLinkFlags)
-        {
+      if (targetLinkFlags) {
         linkFlags += targetLinkFlags;
         linkFlags += " ";
-        }
-      if(!buildType.empty())
-        {
+      }
+      if (!buildType.empty()) {
         std::string configLinkFlags = "LINK_FLAGS_";
         configLinkFlags += buildType;
         targetLinkFlags = target->GetProperty(configLinkFlags);
-        if(targetLinkFlags)
-          {
+        if (targetLinkFlags) {
           linkFlags += targetLinkFlags;
           linkFlags += " ";
-          }
         }
-      this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false, false, useWatcomQuote);
       }
-      break;
-    case cmState::EXECUTABLE:
-      {
-      linkFlags +=
-        this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
+      this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target,
+                                false, false, useWatcomQuote);
+    } break;
+    case cmState::EXECUTABLE: {
+      linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
       linkFlags += " ";
-      if(!buildType.empty())
-        {
+      if (!buildType.empty()) {
         std::string build = "CMAKE_EXE_LINKER_FLAGS_";
         build += buildType;
         linkFlags += this->Makefile->GetSafeDefinition(build);
         linkFlags += " ";
-        }
+      }
       std::string linkLanguage = target->GetLinkerLanguage(buildType);
-      if(linkLanguage.empty())
-        {
-        cmSystemTools::Error
-          ("CMake can not determine linker language for target: ",
-           target->GetName().c_str());
+      if (linkLanguage.empty()) {
+        cmSystemTools::Error(
+          "CMake can not determine linker language for target: ",
+          target->GetName().c_str());
         return;
-        }
+      }
       this->AddLanguageFlags(flags, linkLanguage, buildType);
-      this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *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");
+      this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *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);
         linkFlags += " ";
-        }
-      if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
-        {
+      }
+      if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
         linkFlags +=
           this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
         linkFlags += " ";
-        }
-      else
-        {
+      } else {
         linkFlags +=
           this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
         linkFlags += " ";
-        }
-      if (target->IsExecutableWithExports())
-        {
+      }
+      if (target->IsExecutableWithExports()) {
         std::string exportFlagVar = "CMAKE_EXE_EXPORTS_";
         exportFlagVar += linkLanguage;
         exportFlagVar += "_FLAG";
 
-        linkFlags +=
-          this->Makefile->GetSafeDefinition(exportFlagVar);
+        linkFlags += this->Makefile->GetSafeDefinition(exportFlagVar);
         linkFlags += " ";
-        }
+      }
       const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
-      if(targetLinkFlags)
-        {
+      if (targetLinkFlags) {
         linkFlags += targetLinkFlags;
         linkFlags += " ";
-        }
-      if(!buildType.empty())
-        {
+      }
+      if (!buildType.empty()) {
         std::string configLinkFlags = "LINK_FLAGS_";
         configLinkFlags += buildType;
         targetLinkFlags = target->GetProperty(configLinkFlags);
-        if(targetLinkFlags)
-          {
+        if (targetLinkFlags) {
           linkFlags += targetLinkFlags;
           linkFlags += " ";
-          }
         }
       }
-      break;
+    } break;
     default:
       break;
-    }
+  }
 }
 
 std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
@@ -1528,27 +1278,24 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
   // Work-ardound command line parsing limitations in MSVC 6.0
-  if(this->Makefile->IsOn("MSVC60"))
-    {
+  if (this->Makefile->IsOn("MSVC60")) {
     // Search for the last space.
     std::string::size_type pos = lib.rfind(' ');
-    if(pos != lib.npos)
-      {
+    if (pos != lib.npos) {
       // Find the slash after the last space, if any.
       pos = lib.find('/', pos);
 
       // Convert the portion of the path with a space to a short path.
       std::string sp;
-      if(cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp))
-        {
+      if (cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp)) {
         // Append the rest of the path with no space.
         sp += lib.substr(pos);
 
         // Convert to an output path.
         return this->Convert(sp.c_str(), NONE, format);
-        }
       }
     }
+  }
 #endif
 
   // Normal behavior.
@@ -1563,21 +1310,19 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
 void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
                                            std::string& frameworkPath,
                                            std::string& linkPath,
-                                           cmGeneratorTarget &tgt,
-                                           bool relink,
+                                           cmGeneratorTarget& tgt, bool relink,
                                            bool forResponseFile,
                                            bool useWatcomQuote)
 {
-  OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
-                             ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
+  OutputFormat shellFormat =
+    (forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
   bool escapeAllowMakeVars = !forResponseFile;
   std::ostringstream fout;
   std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config);
-  if(!pcli)
-    {
+  if (!pcli) {
     return;
-    }
+  }
   cmComputeLinkInformation& cli = *pcli;
 
   // Collect library linking flags command line options.
@@ -1592,218 +1337,189 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
 
   // Flags to link an executable to shared libraries.
   if (tgt.GetType() == cmState::EXECUTABLE &&
-      this->StateSnapshot.GetState()->
-        GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS"))
-    {
+      this->StateSnapshot.GetState()->GetGlobalPropertyAsBool(
+        "TARGET_SUPPORTS_SHARED_LIBS")) {
     bool add_shlib_flags = false;
-    switch(tgt.GetPolicyStatusCMP0065())
-      {
+    switch (tgt.GetPolicyStatusCMP0065()) {
       case cmPolicies::WARN:
-        if(!tgt.GetPropertyAsBool("ENABLE_EXPORTS") &&
-           this->Makefile->PolicyOptionalWarningEnabled(
-             "CMAKE_POLICY_WARNING_CMP0065"))
-          {
+        if (!tgt.GetPropertyAsBool("ENABLE_EXPORTS") &&
+            this->Makefile->PolicyOptionalWarningEnabled(
+              "CMAKE_POLICY_WARNING_CMP0065")) {
           std::ostringstream w;
+          /* clang-format off */
           w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0065) << "\n"
             "For compatibility with older versions of CMake, "
             "additional flags may be added to export symbols on all "
             "executables regardless of thier ENABLE_EXPORTS property.";
-          this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-          }
+          /* clang-format on */
+          this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+        }
       case cmPolicies::OLD:
         // OLD behavior is to always add the flags
         add_shlib_flags = true;
         break;
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
-        this->Makefile->IssueMessage(
+        this->IssueMessage(
           cmake::FATAL_ERROR,
-          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065)
-          );
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065));
       case cmPolicies::NEW:
         // NEW behavior is to only add the flags if ENABLE_EXPORTS is on
         add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS");
         break;
-      }
+    }
 
-    if(add_shlib_flags)
-      {
+    if (add_shlib_flags) {
       std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
       linkFlagsVar += linkLanguage;
       linkFlagsVar += "_FLAGS";
       linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar);
       linkLibs += " ";
-      }
     }
+  }
 
   // Append the framework search path flags.
   std::string fwSearchFlagVar = "CMAKE_";
   fwSearchFlagVar += linkLanguage;
   fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
-  const char* fwSearchFlag =
-    this->Makefile->GetDefinition(fwSearchFlagVar);
-  if(fwSearchFlag && *fwSearchFlag)
-    {
+  const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
+  if (fwSearchFlag && *fwSearchFlag) {
     std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
-    for(std::vector<std::string>::const_iterator fdi = fwDirs.begin();
-        fdi != fwDirs.end(); ++fdi)
-      {
+    for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
+         fdi != fwDirs.end(); ++fdi) {
       frameworkPath += fwSearchFlag;
       frameworkPath += this->Convert(*fdi, NONE, shellFormat);
       frameworkPath += " ";
-      }
     }
+  }
 
   // Append the library search path flags.
   std::vector<std::string> const& libDirs = cli.GetDirectories();
-  for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
-      libDir != libDirs.end(); ++libDir)
-    {
-    std::string libpath = this->ConvertToOutputForExisting(*libDir,
-                                                           START_OUTPUT,
-                                                           shellFormat);
+  for (std::vector<std::string>::const_iterator libDir = libDirs.begin();
+       libDir != libDirs.end(); ++libDir) {
+    std::string libpath =
+      this->ConvertToOutputForExisting(*libDir, START_OUTPUT, shellFormat);
     linkPath += " " + libPathFlag;
     linkPath += libpath;
     linkPath += libPathTerminator;
     linkPath += " ";
-    }
+  }
 
   // Append the link items.
   typedef cmComputeLinkInformation::ItemVector ItemVector;
   ItemVector const& items = cli.GetItems();
-  for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li)
-    {
-    if(li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (ItemVector::const_iterator li = items.begin(); li != items.end();
+       ++li) {
+    if (li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
-    if(li->IsPath)
-      {
+    }
+    if (li->IsPath) {
       linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
-      }
-    else
-      {
+    } else {
       linkLibs += li->Value;
-      }
-    linkLibs += " ";
     }
+    linkLibs += " ";
+  }
 
   // Write the library flags to the build rule.
   fout << linkLibs;
 
   // Check what kind of rpath flags to use.
-  if(cli.GetRuntimeSep().empty())
-    {
+  if (cli.GetRuntimeSep().empty()) {
     // Each rpath entry gets its own option ("-R a -R b -R c")
     std::vector<std::string> runtimeDirs;
     cli.GetRPath(runtimeDirs, relink);
 
     std::string rpath;
-    for(std::vector<std::string>::iterator ri = runtimeDirs.begin();
-        ri != runtimeDirs.end(); ++ri)
-      {
+    for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
+         ri != runtimeDirs.end(); ++ri) {
       rpath += cli.GetRuntimeFlag();
       rpath += this->Convert(*ri, NONE, shellFormat);
       rpath += " ";
-      }
-    fout << rpath;
     }
-  else
-    {
+    fout << rpath;
+  } else {
     // All rpath entries are combined ("-Wl,-rpath,a:b:c").
     std::string rpath = cli.GetRPathString(relink);
 
     // Store the rpath option in the stream.
-    if(!rpath.empty())
-      {
+    if (!rpath.empty()) {
       fout << cli.GetRuntimeFlag();
       fout << this->EscapeForShell(rpath, escapeAllowMakeVars);
       fout << " ";
-      }
     }
+  }
 
   // Add the linker runtime search path if any.
   std::string rpath_link = cli.GetRPathLinkString();
-  if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
-    {
+  if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) {
     fout << cli.GetRPathLinkFlag();
     fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars);
     fout << " ";
-    }
+  }
 
   // Add standard libraries for this language.
   std::string standardLibsVar = "CMAKE_";
   standardLibsVar += cli.GetLinkLanguage();
   standardLibsVar += "_STANDARD_LIBRARIES";
-  if(const char* stdLibs =
-     this->Makefile->GetDefinition(standardLibsVar))
-    {
+  if (const char* stdLibs = this->Makefile->GetDefinition(standardLibsVar)) {
     fout << stdLibs << " ";
-    }
+  }
 
   linkLibraries = fout.str();
 }
 
-
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
                                             cmGeneratorTarget const* target,
                                             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"))
-    {
+  if (!this->Makefile->IsOn("APPLE")) {
     return;
-    }
+  }
 
-  if(this->EmitUniversalBinaryFlags)
-    {
+  if (this->EmitUniversalBinaryFlags) {
     std::vector<std::string> archs;
     target->GetAppleArchs(config, archs);
     const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
-    if(sysroot && sysroot[0] == '/' && !sysroot[1])
-      { sysroot = 0; }
+    if (sysroot && sysroot[0] == '/' && !sysroot[1]) {
+      sysroot = 0;
+    }
     std::string sysrootFlagVar =
       std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
-    const char* sysrootFlag =
-      this->Makefile->GetDefinition(sysrootFlagVar);
+    const char* sysrootFlag = 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);
-    if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F'))
-      {
-      for(std::vector<std::string>::iterator i = archs.begin();
-          i != archs.end(); ++i)
-        {
+    if (!archs.empty() && !lang.empty() &&
+        (lang[0] == 'C' || lang[0] == 'F')) {
+      for (std::vector<std::string>::iterator i = archs.begin();
+           i != archs.end(); ++i) {
         flags += " -arch ";
         flags += *i;
-        }
       }
+    }
 
-    if(sysrootFlag && *sysrootFlag && sysroot && *sysroot)
-      {
+    if (sysrootFlag && *sysrootFlag && sysroot && *sysroot) {
       flags += " ";
       flags += sysrootFlag;
       flags += " ";
       flags += this->Convert(sysroot, NONE, SHELL);
-      }
+    }
 
-    if (deploymentTargetFlag && *deploymentTargetFlag &&
-        deploymentTarget && *deploymentTarget)
-      {
+    if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget &&
+        *deploymentTarget) {
       flags += " ";
       flags += deploymentTargetFlag;
       flags += deploymentTarget;
-      }
     }
+  }
 }
 
-
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AddLanguageFlags(std::string& flags,
                                         const std::string& lang,
                                         const std::string& config)
@@ -1815,28 +1531,23 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
   this->AddConfigVariableFlags(flags, flagsVar, config);
 }
 
-//----------------------------------------------------------------------------
-cmGeneratorTarget*
-cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
+cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse(
+  const std::string& name) const
 {
-  std::vector<cmGeneratorTarget*>::const_iterator
-    imported = std::find_if(this->ImportedGeneratorTargets.begin(),
-                            this->ImportedGeneratorTargets.end(),
-                            NamedGeneratorTargetFinder(name));
-  if(imported != this->ImportedGeneratorTargets.end())
-    {
+  std::vector<cmGeneratorTarget*>::const_iterator imported = std::find_if(
+    this->ImportedGeneratorTargets.begin(),
+    this->ImportedGeneratorTargets.end(), NamedGeneratorTargetFinder(name));
+  if (imported != this->ImportedGeneratorTargets.end()) {
     return *imported;
-    }
+  }
 
-  if(cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name))
-    {
+  if (cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name)) {
     return t;
-    }
+  }
 
   return this->GetGlobalGenerator()->FindGeneratorTarget(name);
 }
 
-//----------------------------------------------------------------------------
 bool cmLocalGenerator::GetRealDependency(const std::string& inName,
                                          const std::string& config,
                                          std::string& dep)
@@ -1850,46 +1561,38 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
 
   // If the input name is the empty string, there is no real
   // dependency. Short-circuit the other checks:
-  if(name == "")
-    {
+  if (name == "") {
     return false;
-    }
+  }
 
-  if(cmSystemTools::GetFilenameLastExtension(name) == ".exe")
-    {
+  if (cmSystemTools::GetFilenameLastExtension(name) == ".exe") {
     name = cmSystemTools::GetFilenameWithoutLastExtension(name);
-    }
+  }
 
   // Look for a CMake target with the given name.
-  if(cmGeneratorTarget* target =
-     this->FindGeneratorTargetToUse(name))
-    {
+  if (cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name)) {
     // make sure it is not just a coincidence that the target name
     // found is part of the inName
-    if(cmSystemTools::FileIsFullPath(inName.c_str()))
-      {
+    if (cmSystemTools::FileIsFullPath(inName.c_str())) {
       std::string tLocation;
-      if(target->GetType() >= cmState::EXECUTABLE &&
-         target->GetType() <= cmState::MODULE_LIBRARY)
-        {
+      if (target->GetType() >= cmState::EXECUTABLE &&
+          target->GetType() <= cmState::MODULE_LIBRARY) {
         tLocation = target->GetLocation(config);
         tLocation = cmSystemTools::GetFilenamePath(tLocation);
         tLocation = cmSystemTools::CollapseFullPath(tLocation);
-        }
-      std::string depLocation = cmSystemTools::GetFilenamePath(
-        std::string(inName));
+      }
+      std::string depLocation =
+        cmSystemTools::GetFilenamePath(std::string(inName));
       depLocation = cmSystemTools::CollapseFullPath(depLocation);
-      if(depLocation != tLocation)
-        {
+      if (depLocation != tLocation) {
         // it is a full path to a depend that has the same name
         // as a target but is in a different location so do not use
         // the target as the depend
         dep = inName;
         return true;
-        }
       }
-    switch (target->GetType())
-      {
+    }
+    switch (target->GetType()) {
       case cmState::EXECUTABLE:
       case cmState::STATIC_LIBRARY:
       case cmState::SHARED_LIBRARY:
@@ -1910,24 +1613,22 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
         // A utility target has no file on which to depend.  This was listed
         // only to get the target-level dependency.
         return false;
-      }
     }
+  }
 
   // The name was not that of a CMake target.  It must name a file.
-  if(cmSystemTools::FileIsFullPath(inName.c_str()))
-    {
+  if (cmSystemTools::FileIsFullPath(inName.c_str())) {
     // This is a full path.  Return it as given.
     dep = inName;
     return true;
-    }
+  }
 
   // Check for a source file in this directory that matches the
   // dependency.
-  if(cmSourceFile* sf = this->Makefile->GetSource(inName))
-    {
+  if (cmSourceFile* sf = this->Makefile->GetSource(inName)) {
     dep = sf->GetFullPath();
     return true;
-    }
+  }
 
   // Treat the name as relative to the source directory in which it
   // was given.
@@ -1937,85 +1638,70 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AddSharedFlags(std::string& flags,
-                                      const std::string& lang,
-                                      bool shared)
+                                      const std::string& lang, bool shared)
 {
   std::string flagsVar;
 
   // Add flags for dealing with shared libraries for this language.
-  if(shared)
-    {
+  if (shared) {
     flagsVar = "CMAKE_SHARED_LIBRARY_";
     flagsVar += lang;
     flagsVar += "_FLAGS";
     this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::
-AddCompilerRequirementFlag(std::string &flags,
-                           cmGeneratorTarget const* target,
-                           const std::string& lang)
+void cmLocalGenerator::AddCompilerRequirementFlag(
+  std::string& flags, cmGeneratorTarget const* target, const std::string& lang)
 {
-  if (lang.empty())
-    {
+  if (lang.empty()) {
     return;
-    }
-  const char* defaultStd
-      = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
-  if (!defaultStd || !*defaultStd)
-    {
+  }
+  const char* defaultStd =
+    this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
+  if (!defaultStd || !*defaultStd) {
     // This compiler has no notion of language standard levels.
     return;
-    }
+  }
   std::string stdProp = lang + "_STANDARD";
-  const char *standardProp = target->GetProperty(stdProp);
-  if (!standardProp)
-    {
+  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))
-      {
+  if (const char* extPropValue = target->GetProperty(extProp)) {
+    if (cmSystemTools::IsOff(extPropValue)) {
       ext = false;
       type = "STANDARD";
-      }
     }
+  }
 
-  if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED"))
-    {
+  if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED")) {
     std::string option_flag =
-              "CMAKE_" + lang + standardProp
-                      + "_" + type + "_COMPILE_OPTION";
+      "CMAKE_" + lang + standardProp + "_" + type + "_COMPILE_OPTION";
 
-    const char *opt = target->Target->GetMakefile()
-        ->GetDefinition(option_flag);
-    if (!opt)
-      {
+    const char* opt =
+      target->Target->GetMakefile()->GetDefinition(option_flag);
+    if (!opt) {
       std::ostringstream e;
       e << "Target \"" << target->GetName() << "\" requires the language "
-           "dialect \"" << lang << standardProp << "\" "
-        << (ext ? "(with compiler extensions)" : "") << ", but CMake "
+                                               "dialect \""
+        << lang << standardProp << "\" "
+        << (ext ? "(with compiler extensions)" : "")
+        << ", but CMake "
            "does not know the compile flags to use to enable it.";
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
-      }
-    else
-      {
+    } else {
       this->AppendFlagEscape(flags, opt);
-      }
-    return;
     }
+    return;
+  }
 
   static std::map<std::string, std::vector<std::string> > langStdMap;
-  if (langStdMap.empty())
-    {
+  if (langStdMap.empty()) {
     // Maintain sorted order, most recent first.
     langStdMap["CXX"].push_back("14");
     langStdMap["CXX"].push_back("11");
@@ -2024,147 +1710,125 @@ AddCompilerRequirementFlag(std::string &flags,
     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);
-  if (stdIt == stds.end())
-    {
+    std::find(stds.begin(), stds.end(), standard);
+  if (stdIt == stds.end()) {
     std::string e =
       lang + "_STANDARD is set to invalid value '" + standard + "'";
-    this->GetGlobalGenerator()->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e, target->GetBacktrace());
+    this->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+      cmake::FATAL_ERROR, e, target->GetBacktrace());
     return;
-    }
+  }
 
   std::vector<std::string>::const_iterator defaultStdIt =
     std::find(stds.begin(), stds.end(), defaultStd);
-  if (defaultStdIt == stds.end())
-    {
-    std::string e =
-      "CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" +
-      std::string(defaultStd) + "'";
+  if (defaultStdIt == stds.end()) {
+    std::string e = "CMAKE_" + lang +
+      "_STANDARD_DEFAULT is set to invalid value '" + std::string(defaultStd) +
+      "'";
     this->IssueMessage(cmake::INTERNAL_ERROR, e);
     return;
-    }
+  }
 
   // Greater or equal because the standards are stored in
   // backward chronological order.
-  if (stdIt >= defaultStdIt)
-    {
+  if (stdIt >= defaultStdIt) {
     std::string option_flag =
-              "CMAKE_" + lang + *stdIt
-                      + "_" + type + "_COMPILE_OPTION";
+      "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
 
-    const char *opt =
-        target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
+    const char* opt =
+      target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
     this->AppendFlagEscape(flags, opt);
     return;
-    }
+  }
 
-  for ( ; stdIt < defaultStdIt; ++stdIt)
-    {
+  for (; stdIt < defaultStdIt; ++stdIt) {
     std::string option_flag =
-              "CMAKE_" + lang + *stdIt
-                      + "_" + type + "_COMPILE_OPTION";
+      "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
 
-    if (const char *opt = target->Target
-        ->GetMakefile()->GetDefinition(option_flag))
-      {
+    if (const char* opt =
+          target->Target->GetMakefile()->GetDefinition(option_flag)) {
       this->AppendFlagEscape(flags, opt);
       return;
-      }
     }
+  }
 }
 
-static void AddVisibilityCompileOption(std::string &flags,
+static void AddVisibilityCompileOption(std::string& flags,
                                        cmGeneratorTarget const* target,
-                                       cmLocalGenerator *lg,
+                                       cmLocalGenerator* lg,
                                        const std::string& lang,
                                        std::string* warnCMP0063)
 {
-  std::string l(lang);
-  std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
-  const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
-  if (!opt)
-    {
+  std::string compileOption = "CMAKE_" + lang + "_COMPILE_OPTIONS_VISIBILITY";
+  const char* opt = lg->GetMakefile()->GetDefinition(compileOption);
+  if (!opt) {
     return;
-    }
-  std::string flagDefine = l + "_VISIBILITY_PRESET";
+  }
+  std::string flagDefine = lang + "_VISIBILITY_PRESET";
 
-  const char *prop = target->GetProperty(flagDefine);
-  if (!prop)
-    {
+  const char* prop = target->GetProperty(flagDefine);
+  if (!prop) {
     return;
-    }
-  if (warnCMP0063)
-    {
+  }
+  if (warnCMP0063) {
     *warnCMP0063 += "  " + flagDefine + "\n";
     return;
-    }
-  if (strcmp(prop, "hidden") != 0
-      && strcmp(prop, "default") != 0
-      && strcmp(prop, "protected") != 0
-      && strcmp(prop, "internal") != 0 )
-    {
+  }
+  if (strcmp(prop, "hidden") != 0 && strcmp(prop, "default") != 0 &&
+      strcmp(prop, "protected") != 0 && strcmp(prop, "internal") != 0) {
     std::ostringstream e;
-    e << "Target " << target->GetName() << " uses unsupported value \""
-      << prop << "\" for " << flagDefine << ".";
+    e << "Target " << target->GetName() << " uses unsupported value \"" << prop
+      << "\" for " << flagDefine << ".";
     cmSystemTools::Error(e.str().c_str());
     return;
-    }
+  }
   std::string option = std::string(opt) + prop;
   lg->AppendFlags(flags, option);
 }
 
-static void AddInlineVisibilityCompileOption(std::string &flags,
-                                       cmGeneratorTarget const* target,
-                                       cmLocalGenerator *lg,
-                                       std::string* warnCMP0063)
+static void AddInlineVisibilityCompileOption(std::string& flags,
+                                             cmGeneratorTarget const* target,
+                                             cmLocalGenerator* lg,
+                                             std::string* warnCMP0063)
 {
-  std::string compileOption
-                = "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
-  const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
-  if (!opt)
-    {
+  std::string compileOption =
+    "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
+  const char* opt = lg->GetMakefile()->GetDefinition(compileOption);
+  if (!opt) {
     return;
-    }
+  }
 
   bool prop = target->GetPropertyAsBool("VISIBILITY_INLINES_HIDDEN");
-  if (!prop)
-    {
+  if (!prop) {
     return;
-    }
-  if (warnCMP0063)
-    {
+  }
+  if (warnCMP0063) {
     *warnCMP0063 += "  VISIBILITY_INLINES_HIDDEN\n";
     return;
-    }
+  }
   lg->AppendFlags(flags, opt);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator
-::AddVisibilityPresetFlags(std::string &flags, cmGeneratorTarget const* target,
-                            const std::string& lang)
+void cmLocalGenerator::AddVisibilityPresetFlags(
+  std::string& flags, cmGeneratorTarget const* target, const std::string& lang)
 {
-  if (lang.empty())
-    {
+  if (lang.empty()) {
     return;
-    }
+  }
 
   std::string warnCMP0063;
-  std::string *pWarnCMP0063 = 0;
+  std::string* pWarnCMP0063 = 0;
   if (target->GetType() != cmState::SHARED_LIBRARY &&
       target->GetType() != cmState::MODULE_LIBRARY &&
-      !target->IsExecutableWithExports())
-    {
-    switch (target->GetPolicyStatusCMP0063())
-      {
+      !target->IsExecutableWithExports()) {
+    switch (target->GetPolicyStatusCMP0063()) {
       case cmPolicies::OLD:
         return;
       case cmPolicies::WARN:
@@ -2172,20 +1836,18 @@ void cmLocalGenerator
         break;
       default:
         break;
-      }
     }
+  }
 
   AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
 
-  if(lang == "CXX")
-    {
+  if (lang == "CXX") {
     AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
-    }
+  }
 
-  if (!warnCMP0063.empty() &&
-      this->WarnCMP0063.insert(target).second)
-    {
+  if (!warnCMP0063.empty() && this->WarnCMP0063.insert(target).second) {
     std::ostringstream w;
+    /* clang-format off */
     w <<
       cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n"
       "Target \"" << target->GetName() << "\" of "
@@ -2193,14 +1855,13 @@ void cmLocalGenerator
       "has the following visibility properties set for " << lang << ":\n" <<
       warnCMP0063 <<
       "For compatibility CMake is not honoring them for this target.";
-    target->GetLocalGenerator()->GetCMakeInstance()
-      ->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
-                     target->GetBacktrace());
-    }
+    /* clang-format on */
+    target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
+      cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace());
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::AddCMP0018Flags(std::string &flags,
+void cmLocalGenerator::AddCMP0018Flags(std::string& flags,
                                        cmGeneratorTarget const* target,
                                        std::string const& lang,
                                        const std::string& config)
@@ -2208,61 +1869,50 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags,
   int targetType = target->GetType();
 
   bool shared = ((targetType == cmState::SHARED_LIBRARY) ||
-                  (targetType == cmState::MODULE_LIBRARY));
+                 (targetType == cmState::MODULE_LIBRARY));
 
-  if (this->GetShouldUseOldFlags(shared, lang))
-    {
+  if (this->GetShouldUseOldFlags(shared, lang)) {
     this->AddSharedFlags(flags, lang, shared);
-    }
-  else
-    {
-    if (target->GetType() == cmState::OBJECT_LIBRARY)
-      {
-      if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE"))
-        {
+  } else {
+    if (target->GetType() == cmState::OBJECT_LIBRARY) {
+      if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) {
         this->AddPositionIndependentFlags(flags, lang, targetType);
-        }
-      return;
       }
+      return;
+    }
 
     if (target->GetLinkInterfaceDependentBoolProperty(
-                                                "POSITION_INDEPENDENT_CODE",
-                                                config))
-      {
+          "POSITION_INDEPENDENT_CODE", config)) {
       this->AddPositionIndependentFlags(flags, lang, targetType);
-      }
-    if (shared)
-      {
+    }
+    if (shared) {
       this->AppendFeatureOptions(flags, lang, "DLL");
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
-                                            const std::string &lang) const
+                                            const std::string& lang) const
 {
   std::string originalFlags =
     this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang);
-  if (shared)
-    {
+  if (shared) {
     std::string flagsVar = "CMAKE_SHARED_LIBRARY_";
     flagsVar += lang;
     flagsVar += "_FLAGS";
-    const char* flags =
-        this->Makefile->GetSafeDefinition(flagsVar);
-
-    if (flags && flags != originalFlags)
-      {
-      switch (this->GetPolicyStatus(cmPolicies::CMP0018))
-        {
-        case cmPolicies::WARN:
-        {
+    const char* flags = this->Makefile->GetSafeDefinition(flagsVar);
+
+    if (flags && flags != originalFlags) {
+      switch (this->GetPolicyStatus(cmPolicies::CMP0018)) {
+        case cmPolicies::WARN: {
           std::ostringstream e;
-          e << "Variable " << flagsVar << " has been modified. CMake "
-            "will ignore the POSITION_INDEPENDENT_CODE target property for "
-            "shared libraries and will use the " << flagsVar << " variable "
-            "instead.  This may cause errors if the original content of "
+          e << "Variable " << flagsVar
+            << " has been modified. CMake "
+               "will ignore the POSITION_INDEPENDENT_CODE target property for "
+               "shared libraries and will use the "
+            << flagsVar
+            << " variable "
+               "instead.  This may cause errors if the original content of "
             << flagsVar << " was removed.\n"
             << cmPolicies::GetPolicyWarning(cmPolicies::CMP0018);
 
@@ -2275,46 +1925,40 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
         case cmPolicies::REQUIRED_ALWAYS:
         case cmPolicies::NEW:
           return false;
-        }
       }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
                                                    std::string const& lang,
                                                    int targetType)
 {
   const char* picFlags = 0;
 
-  if(targetType == cmState::EXECUTABLE)
-    {
+  if (targetType == cmState::EXECUTABLE) {
     std::string flagsVar = "CMAKE_";
     flagsVar += lang;
     flagsVar += "_COMPILE_OPTIONS_PIE";
     picFlags = this->Makefile->GetSafeDefinition(flagsVar);
-    }
-  if (!picFlags)
-    {
+  }
+  if (!picFlags) {
     std::string flagsVar = "CMAKE_";
     flagsVar += lang;
     flagsVar += "_COMPILE_OPTIONS_PIC";
     picFlags = this->Makefile->GetSafeDefinition(flagsVar);
-    }
-  if (picFlags)
-    {
+  }
+  if (picFlags) {
     std::vector<std::string> options;
     cmSystemTools::ExpandListArgument(picFlags, options);
-    for(std::vector<std::string>::const_iterator oi = options.begin();
-        oi != options.end(); ++oi)
-      {
+    for (std::vector<std::string>::const_iterator oi = options.begin();
+         oi != options.end(); ++oi) {
       this->AppendFlagEscape(flags, *oi);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
                                               const std::string& var,
                                               const std::string& config)
@@ -2323,54 +1967,44 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
   std::string flagsVar = var;
   this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
   // Add the flags from the build-type specific variable.
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     flagsVar += "_";
     flagsVar += cmSystemTools::UpperCase(config);
     this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AppendFlags(std::string& flags,
                                    const std::string& newFlags)
 {
-  if(!newFlags.empty())
-    {
-    if(!flags.empty())
-      {
+  if (!newFlags.empty()) {
+    if (!flags.empty()) {
       flags += " ";
-      }
-    flags += newFlags;
     }
+    flags += newFlags;
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::AppendFlags(std::string& flags,
-                                   const char* newFlags)
+void cmLocalGenerator::AppendFlags(std::string& flags, const char* newFlags)
 {
-  if(newFlags && *newFlags)
-    {
+  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));
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
                                      const char* defines_list)
 {
   // Short-circuit if there are no definitions.
-  if(!defines_list)
-    {
+  if (!defines_list) {
     return;
-    }
+  }
 
   // Expand the list of definitions.
   std::vector<std::string> defines_vec;
@@ -2378,50 +2012,42 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
   this->AppendDefines(defines, defines_vec);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
-                                  const std::vector<std::string> &defines_vec)
+void cmLocalGenerator::AppendDefines(
+  std::set<std::string>& defines, const std::vector<std::string>& defines_vec)
 {
-  for(std::vector<std::string>::const_iterator di = defines_vec.begin();
-      di != defines_vec.end(); ++di)
-    {
+  for (std::vector<std::string>::const_iterator di = defines_vec.begin();
+       di != defines_vec.end(); ++di) {
     // Skip unsupported definitions.
-    if(!this->CheckDefinition(*di))
-      {
+    if (!this->CheckDefinition(*di)) {
       continue;
-      }
-    defines.insert(*di);
     }
+    defines.insert(*di);
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
-                                   std::string &definesString,
+                                   std::string& definesString,
                                    const std::string& lang)
 {
   // Lookup the define flag for the current language.
   std::string dflag = "-D";
-  if(!lang.empty())
-    {
+  if (!lang.empty()) {
     std::string defineFlagVar = "CMAKE_";
     defineFlagVar += lang;
     defineFlagVar += "_DEFINE_FLAG";
     const char* df = this->Makefile->GetDefinition(defineFlagVar);
-    if(df && *df)
-      {
+    if (df && *df) {
       dflag = df;
-      }
     }
+  }
 
   std::set<std::string>::const_iterator defineIt = defines.begin();
   const std::set<std::string>::const_iterator defineEnd = defines.end();
   const char* itemSeparator = definesString.empty() ? "" : " ";
-  for( ; defineIt != defineEnd; ++defineIt)
-    {
+  for (; defineIt != defineEnd; ++defineIt) {
     // Append the definition with proper escaping.
     std::string def = dflag;
-    if(this->GetState()->UseWatcomWMake())
-      {
+    if (this->GetState()->UseWatcomWMake()) {
       // The Watcom compiler does its own command line parsing instead
       // of using the windows shell rules.  Definitions are one of
       //   -DNAME
@@ -2432,74 +2058,63 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
       // command line without any escapes.  However we still have to
       // get the '$' and '#' characters through WMake as '$$' and
       // '$#'.
-      for(const char* c = defineIt->c_str(); *c; ++c)
-        {
-        if(*c == '$' || *c == '#')
-          {
+      for (const char* c = defineIt->c_str(); *c; ++c) {
+        if (*c == '$' || *c == '#') {
           def += '$';
-          }
-        def += *c;
         }
+        def += *c;
       }
-    else
-      {
+    } else {
       // Make the definition appear properly on the command line.  Use
-      // -DNAME="value" instead of -D"NAME=value" to help VS6 parser.
+      // -DNAME="value" instead of -D"NAME=value" for historical reasons.
       std::string::size_type eq = defineIt->find("=");
       def += defineIt->substr(0, eq);
-      if(eq != defineIt->npos)
-        {
+      if (eq != defineIt->npos) {
         def += "=";
         def += this->EscapeForShell(defineIt->c_str() + eq + 1, true);
-        }
       }
+    }
     definesString += itemSeparator;
     itemSeparator = " ";
     definesString += def;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::AppendFeatureOptions(
-  std::string& flags, const std::string& lang, const char* feature)
+void cmLocalGenerator::AppendFeatureOptions(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))
-    {
+  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)
-      {
+    for (std::vector<std::string>::const_iterator oi = options.begin();
+         oi != options.end(); ++oi) {
       this->AppendFlagEscape(flags, *oi);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 const char* cmLocalGenerator::GetFeature(const std::string& feature,
                                          const std::string& config)
 {
   std::string featureName = feature;
   // TODO: Define accumulation policy for features (prepend, append, replace).
   // Currently we always replace.
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     featureName += "_";
     featureName += cmSystemTools::UpperCase(config);
-    }
+  }
   cmState::Snapshot snp = this->StateSnapshot;
-  while(snp.IsValid())
-    {
-    if(const char* value = snp.GetDirectory().GetProperty(featureName))
-      {
+  while (snp.IsValid()) {
+    if (const char* value = snp.GetDirectory().GetProperty(featureName)) {
       return value;
-      }
-    snp = snp.GetBuildsystemDirectoryParent();
     }
+    snp = snp.GetBuildsystemDirectoryParent();
+  }
   return 0;
 }
 
@@ -2508,138 +2123,118 @@ std::string cmLocalGenerator::GetProjectName() const
   return this->StateSnapshot.GetProjectName();
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,
-                                   const char* default_comment)
+std::string cmLocalGenerator::ConstructComment(
+  cmCustomCommandGenerator const& ccg, const char* default_comment)
 {
   // Check for a comment provided with the command.
-  if(ccg.GetComment())
-    {
+  if (ccg.GetComment()) {
     return ccg.GetComment();
-    }
+  }
 
   // Construct a reasonable default comment if possible.
-  if(!ccg.GetOutputs().empty())
-    {
+  if (!ccg.GetOutputs().empty()) {
     std::string comment;
     comment = "Generating ";
     const char* sep = "";
-    for(std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
-        o != ccg.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, cmLocalGenerator::START_OUTPUT);
+      comment += this->Convert(*o, cmOutputConverter::START_OUTPUT);
       sep = ", ";
-      }
-    return comment;
     }
+    return comment;
+  }
 
   // Otherwise use the provided default.
   return default_comment;
 }
 
-//----------------------------------------------------------------------------
-class cmInstallTargetGeneratorLocal: public cmInstallTargetGenerator
+class cmInstallTargetGeneratorLocal : public cmInstallTargetGenerator
 {
 public:
   cmInstallTargetGeneratorLocal(cmLocalGenerator* lg, std::string const& t,
-                                const char* dest, bool implib):
-    cmInstallTargetGenerator(
-      t, dest, implib, "", std::vector<std::string>(), "Unspecified",
-      cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()),
-      false)
+                                const char* dest, bool implib)
+    : cmInstallTargetGenerator(
+        t, dest, implib, "", std::vector<std::string>(), "Unspecified",
+        cmInstallGenerator::SelectMessageLevel(lg->GetMakefile()), false,
+        false)
   {
     this->Compute(lg);
   }
 };
 
-//----------------------------------------------------------------------------
-void
-cmLocalGenerator
-::GenerateTargetInstallRules(
+void cmLocalGenerator::GenerateTargetInstallRules(
   std::ostream& os, const std::string& config,
   std::vector<std::string> const& configurationTypes)
 {
   // Convert the old-style install specification from each target to
   // an install generator and run it.
   std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); ++l)
-    {
-    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+       l != tgts.end(); ++l) {
+    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
 
     // Include the user-specified pre-install script for this target.
-    if(const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT"))
-      {
-      cmInstallScriptGenerator g(preinstall, false, 0);
+    if (const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT")) {
+      cmInstallScriptGenerator g(preinstall, false, 0, false);
       g.Generate(os, config, configurationTypes);
-      }
+    }
 
     // Install this target if a destination is given.
-    if((*l)->Target->GetInstallPath() != "")
-      {
+    if ((*l)->Target->GetInstallPath() != "") {
       // Compute the full install destination.  Note that converting
       // to unix slashes also removes any trailing slash.
       // We also skip over the leading slash given by the user.
       std::string destination = (*l)->Target->GetInstallPath().substr(1);
       cmSystemTools::ConvertToUnixSlashes(destination);
-      if(destination.empty())
-        {
+      if (destination.empty()) {
         destination = ".";
-        }
+      }
 
       // Generate the proper install generator for this target type.
-      switch((*l)->GetType())
-        {
+      switch ((*l)->GetType()) {
         case cmState::EXECUTABLE:
         case cmState::STATIC_LIBRARY:
-        case cmState::MODULE_LIBRARY:
-          {
+        case cmState::MODULE_LIBRARY: {
           // Use a target install generator.
-          cmInstallTargetGeneratorLocal
-            g(this, (*l)->GetName(), destination.c_str(), false);
+          cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
+                                          destination.c_str(), false);
           g.Generate(os, config, configurationTypes);
-          }
-          break;
-        case cmState::SHARED_LIBRARY:
-          {
+        } break;
+        case cmState::SHARED_LIBRARY: {
 #if defined(_WIN32) || defined(__CYGWIN__)
           // Special code to handle DLL.  Install the import library
           // to the normal destination and the DLL to the runtime
           // destination.
-          cmInstallTargetGeneratorLocal
-            g1(this, (*l)->GetName(), destination.c_str(), true);
+          cmInstallTargetGeneratorLocal g1(this, (*l)->GetName(),
+                                           destination.c_str(), true);
           g1.Generate(os, config, configurationTypes);
           // We also skip over the leading slash given by the user.
           destination = (*l)->Target->GetRuntimeInstallPath().substr(1);
           cmSystemTools::ConvertToUnixSlashes(destination);
-          cmInstallTargetGeneratorLocal
-            g2(this, (*l)->GetName(), destination.c_str(), false);
+          cmInstallTargetGeneratorLocal g2(this, (*l)->GetName(),
+                                           destination.c_str(), false);
           g2.Generate(os, config, configurationTypes);
 #else
           // Use a target install generator.
-          cmInstallTargetGeneratorLocal
-            g(this, (*l)->GetName(), destination.c_str(), false);
+          cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
+                                          destination.c_str(), false);
           g.Generate(os, config, configurationTypes);
 #endif
-          }
-          break;
+        } break;
         default:
           break;
-        }
       }
+    }
 
     // Include the user-specified post-install script for this target.
-    if(const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT"))
-      {
-      cmInstallScriptGenerator g(postinstall, false, 0);
+    if (const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT")) {
+      cmInstallScriptGenerator g(postinstall, false, 0, false);
       g.Generate(os, config, configurationTypes);
-      }
     }
+  }
 }
 
 #if defined(CM_LG_ENCODE_OBJECT_NAMES)
@@ -2654,127 +2249,105 @@ static std::string cmLocalGeneratorMD5(const char* input)
   return std::string(md5out, 32);
 }
 
-static bool
-cmLocalGeneratorShortenObjectName(std::string& objName,
-                                  std::string::size_type max_len)
+static bool cmLocalGeneratorShortenObjectName(std::string& objName,
+                                              std::string::size_type max_len)
 {
   // Replace the beginning of the path portion of the object name with
   // its own md5 sum.
-  std::string::size_type pos = objName.find('/', objName.size()-max_len+32);
-  if(pos != objName.npos)
-    {
+  std::string::size_type pos =
+    objName.find('/', objName.size() - max_len + 32);
+  if (pos != objName.npos) {
     std::string md5name = cmLocalGeneratorMD5(objName.substr(0, pos).c_str());
     md5name += objName.substr(pos);
     objName = md5name;
 
     // The object name is now short enough.
     return true;
-    }
-  else
-    {
+  } else {
     // The object name could not be shortened enough.
     return false;
-    }
+  }
 }
 
-static
 bool cmLocalGeneratorCheckObjectName(std::string& objName,
                                      std::string::size_type dir_len,
                                      std::string::size_type max_total_len)
 {
   // Enforce the maximum file name length if possible.
   std::string::size_type max_obj_len = max_total_len;
-  if(dir_len < max_total_len)
-    {
+  if (dir_len < max_total_len) {
     max_obj_len = max_total_len - dir_len;
-    if(objName.size() > max_obj_len)
-      {
+    if (objName.size() > max_obj_len) {
       // The current object file name is too long.  Try to shorten it.
       return cmLocalGeneratorShortenObjectName(objName, max_obj_len);
-      }
-    else
-      {
+    } else {
       // The object file name is short enough.
       return true;
-      }
     }
-  else
-    {
+  } else {
     // The build directory in which the object will be stored is
     // already too deep.
     return false;
-    }
+  }
 }
 #endif
 
-//----------------------------------------------------------------------------
-std::string&
-cmLocalGenerator
-::CreateSafeUniqueObjectFileName(const std::string& sin,
-                                 std::string const& dir_max)
+std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(
+  const std::string& sin, std::string const& dir_max)
 {
   // Look for an existing mapped name for this object file.
-  std::map<std::string,std::string>::iterator it =
+  std::map<std::string, std::string>::iterator it =
     this->UniqueObjectNamesMap.find(sin);
 
   // If no entry exists create one.
-  if(it == this->UniqueObjectNamesMap.end())
-    {
+  if (it == this->UniqueObjectNamesMap.end()) {
     // Start with the original name.
     std::string ssin = sin;
 
     // Avoid full paths by removing leading slashes.
-    ssin.erase(0, ssin.find_first_not_of("/"));
+    ssin.erase(0, ssin.find_first_not_of('/'));
 
     // Avoid full paths by removing colons.
-    cmSystemTools::ReplaceString(ssin, ":", "_");
+    std::replace(ssin.begin(), ssin.end(), ':', '_');
 
     // Avoid relative paths that go up the tree.
     cmSystemTools::ReplaceString(ssin, "../", "__/");
 
     // Avoid spaces.
-    cmSystemTools::ReplaceString(ssin, " ", "_");
+    std::replace(ssin.begin(), ssin.end(), ' ', '_');
 
     // Mangle the name if necessary.
-    if(this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES"))
-      {
+    if (this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES")) {
       bool done;
       int cc = 0;
       char rpstr[100];
       sprintf(rpstr, "_p_");
       cmSystemTools::ReplaceString(ssin, "+", rpstr);
       std::string sssin = sin;
-      do
-        {
+      do {
         done = true;
-        for ( it = this->UniqueObjectNamesMap.begin();
-              it != this->UniqueObjectNamesMap.end();
-              ++ it )
-          {
-          if ( it->second == ssin )
-            {
+        for (it = this->UniqueObjectNamesMap.begin();
+             it != this->UniqueObjectNamesMap.end(); ++it) {
+          if (it->second == ssin) {
             done = false;
-            }
           }
-        if ( done )
-          {
+        }
+        if (done) {
           break;
-          }
+        }
         sssin = ssin;
         cmSystemTools::ReplaceString(ssin, "_p_", rpstr);
         sprintf(rpstr, "_p%d_", cc++);
-        }
-      while ( !done );
-      }
+      } while (!done);
+    }
 
 #if defined(CM_LG_ENCODE_OBJECT_NAMES)
-    if(!cmLocalGeneratorCheckObjectName(ssin, dir_max.size(),
-                                        this->ObjectPathMax))
-      {
+    if (!cmLocalGeneratorCheckObjectName(ssin, dir_max.size(),
+                                         this->ObjectPathMax)) {
       // Warn if this is the first time the path has been seen.
-      if(this->ObjectMaxPathViolations.insert(dir_max).second)
-        {
+      if (this->ObjectMaxPathViolations.insert(dir_max).second) {
         std::ostringstream m;
+        /* clang-format off */
         m << "The object file directory\n"
           << "  " << dir_max << "\n"
           << "has " << dir_max.size() << " characters.  "
@@ -2785,9 +2358,10 @@ cmLocalGenerator
           << "  " << ssin << "\n"
           << "cannot be safely placed under this directory.  "
           << "The build may not work correctly.";
+        /* clang-format on */
         this->IssueMessage(cmake::WARNING, m.str());
-        }
       }
+    }
 #else
     (void)dir_max;
 #endif
@@ -2795,18 +2369,15 @@ cmLocalGenerator
     // Insert the newly mapped object file name.
     std::map<std::string, std::string>::value_type e(sin, ssin);
     it = this->UniqueObjectNamesMap.insert(e).first;
-    }
+  }
 
   // Return the map entry.
   return it->second;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::ComputeObjectFilenames(
-                            std::map<cmSourceFile const*, std::string>&,
-                            cmGeneratorTarget const*)
+  std::map<cmSourceFile const*, std::string>&, cmGeneratorTarget const*)
 {
-
 }
 
 bool cmLocalGenerator::IsWindowsShell() const
@@ -2829,12 +2400,9 @@ bool cmLocalGenerator::IsNMake() const
   return this->GetState()->UseNMake();
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalGenerator
-::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
-                                 std::string const& dir_max,
-                                 bool* hasSourceExtension)
+std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
+  const cmSourceFile& source, std::string const& dir_max,
+  bool* hasSourceExtension)
 {
   // Construct the object file name using the full path to the source
   // file which is its only unique identification.
@@ -2855,83 +2423,64 @@ cmLocalGenerator
   // Select a nice-looking reference to the source file to construct
   // the object file name.
   std::string objectName;
-  if((relSource && !relBinary) || (subSource && !subBinary))
-    {
+  if ((relSource && !relBinary) || (subSource && !subBinary)) {
     objectName = relFromSource;
-    }
-  else if((relBinary && !relSource) || (subBinary && !subSource))
-    {
+  } else if ((relBinary && !relSource) || (subBinary && !subSource)) {
     objectName = relFromBinary;
-    }
-  else if(relFromBinary.length() < relFromSource.length())
-    {
+  } else if (relFromBinary.length() < relFromSource.length()) {
     objectName = relFromBinary;
-    }
-  else
-    {
+  } else {
     objectName = relFromSource;
-    }
+  }
 
   // if it is still a full path check for the try compile case
   // try compile never have in source sources, and should not
   // have conflicting source file names in the same target
-  if(cmSystemTools::FileIsFullPath(objectName.c_str()))
-    {
-    if(this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile())
-      {
+  if (cmSystemTools::FileIsFullPath(objectName.c_str())) {
+    if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {
       objectName = cmSystemTools::GetFilenameName(source.GetFullPath());
-      }
     }
+  }
 
   // Replace the original source file extension with the object file
   // extension.
   bool keptSourceExtension = true;
-  if(!source.GetPropertyAsBool("KEEP_EXTENSION"))
-    {
+  if (!source.GetPropertyAsBool("KEEP_EXTENSION")) {
     // Decide whether this language wants to replace the source
     // extension with the object extension.  For CMake 2.4
     // compatibility do this by default.
     bool replaceExt = this->NeedBackwardsCompatibility_2_4();
-    if(!replaceExt)
-      {
+    if (!replaceExt) {
       std::string lang = source.GetLanguage();
-      if(!lang.empty())
-        {
+      if (!lang.empty()) {
         std::string repVar = "CMAKE_";
         repVar += lang;
         repVar += "_OUTPUT_EXTENSION_REPLACE";
         replaceExt = this->Makefile->IsOn(repVar);
-        }
       }
+    }
 
     // Remove the source extension if it is to be replaced.
-    if(replaceExt)
-      {
+    if (replaceExt) {
       keptSourceExtension = false;
-      std::string::size_type dot_pos = objectName.rfind(".");
-      if(dot_pos != std::string::npos)
-        {
+      std::string::size_type dot_pos = objectName.rfind('.');
+      if (dot_pos != std::string::npos) {
         objectName = objectName.substr(0, dot_pos);
-        }
       }
+    }
 
     // Store the new extension.
-    objectName +=
-      this->GlobalGenerator->GetLanguageOutputExtension(source);
-    }
-  if(hasSourceExtension)
-    {
+    objectName += this->GlobalGenerator->GetLanguageOutputExtension(source);
+  }
+  if (hasSourceExtension) {
     *hasSourceExtension = keptSourceExtension;
-    }
+  }
 
   // Convert to a safe name.
   return this->CreateSafeUniqueObjectFileName(objectName, dir_max);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalGenerator
-::GetSourceFileLanguage(const cmSourceFile& source)
+std::string cmLocalGenerator::GetSourceFileLanguage(const cmSourceFile& source)
 {
   return source.GetLanguage();
 }
@@ -2961,52 +2510,51 @@ const char* cmLocalGenerator::GetCurrentSourceDirectory() const
   return this->StateSnapshot.GetDirectory().GetCurrentSource();
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalGenerator::GetTargetDirectory(const cmGeneratorTarget*) const
+std::string cmLocalGenerator::GetTargetDirectory(
+  const cmGeneratorTarget*) const
 {
   cmSystemTools::Error("GetTargetDirectory"
                        " called on cmLocalGenerator");
   return "";
 }
 
-//----------------------------------------------------------------------------
 KWIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility()
 {
   // The computed version may change until the project is fully
   // configured.
-  if(!this->BackwardsCompatibilityFinal)
-    {
+  if (!this->BackwardsCompatibilityFinal) {
     unsigned int major = 0;
     unsigned int minor = 0;
     unsigned int patch = 0;
-    if(const char* value
-       = this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"))
-      {
-      switch(sscanf(value, "%u.%u.%u", &major, &minor, &patch))
-        {
-        case 2: patch = 0; break;
-        case 1: minor = 0; patch = 0; break;
-        default: break;
-        }
+    if (const char* value =
+          this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY")) {
+      switch (sscanf(value, "%u.%u.%u", &major, &minor, &patch)) {
+        case 2:
+          patch = 0;
+          break;
+        case 1:
+          minor = 0;
+          patch = 0;
+          break;
+        default:
+          break;
       }
+    }
     this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch);
     this->BackwardsCompatibilityFinal = true;
-    }
+  }
 
   return this->BackwardsCompatibility;
 }
 
-//----------------------------------------------------------------------------
 bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
 {
   // Check the policy to decide whether to pay attention to this
   // variable.
-  switch(this->GetPolicyStatus(cmPolicies::CMP0001))
-    {
+  switch (this->GetPolicyStatus(cmPolicies::CMP0001)) {
     case cmPolicies::WARN:
-      // WARN is just OLD without warning because user code does not
-      // always affect whether this check is done.
+    // WARN is just OLD without warning because user code does not
+    // always affect whether this check is done.
     case cmPolicies::OLD:
       // Old behavior is to check the variable.
       break;
@@ -3020,92 +2568,85 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
       // 2.6 or higher.  Once we add that requirement then this whole
       // method can be removed anyway.
       return false;
-    }
+  }
 
   // Compatibility is needed if CMAKE_BACKWARDS_COMPATIBILITY is set
   // equal to or lower than the given version.
   KWIML_INT_uint64_t actual_compat = this->GetBackwardsCompatibility();
-  return (actual_compat &&
-          actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
+  return (actual_compat && actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
 }
 
-cmPolicies::PolicyStatus
-cmLocalGenerator::GetPolicyStatus(cmPolicies::PolicyID id) const
+cmPolicies::PolicyStatus cmLocalGenerator::GetPolicyStatus(
+  cmPolicies::PolicyID id) const
 {
   return this->Makefile->GetPolicyStatus(id);
 }
 
-//----------------------------------------------------------------------------
 bool cmLocalGenerator::CheckDefinition(std::string const& define) const
 {
   // Many compilers do not support -DNAME(arg)=sdf so we disable it.
   std::string::size_type pos = define.find_first_of("(=");
-  if (pos != std::string::npos)
-    {
-    if (define[pos] == '(')
-      {
+  if (pos != std::string::npos) {
+    if (define[pos] == '(') {
       std::ostringstream e;
+      /* clang-format off */
       e << "WARNING: Function-style preprocessor definitions may not be "
         << "passed on the compiler command line because many compilers "
         << "do not support it.\n"
         << "CMake is dropping a preprocessor definition: " << define << "\n"
         << "Consider defining the macro in a (configured) header file.\n";
+      /* clang-format on */
       cmSystemTools::Message(e.str().c_str());
       return false;
-      }
     }
+  }
 
   // Many compilers do not support # in the value so we disable it.
-  if(define.find_first_of("#") != define.npos)
-    {
+  if (define.find_first_of('#') != define.npos) {
     std::ostringstream e;
+    /* clang-format off */
     e << "WARNING: Preprocessor definitions containing '#' may not be "
       << "passed on the compiler command line because many compilers "
       << "do not support it.\n"
       << "CMake is dropping a preprocessor definition: " << define << "\n"
       << "Consider defining the macro in a (configured) header file.\n";
+    /* clang-format on */
     cmSystemTools::Message(e.str().c_str());
     return false;
-    }
+  }
 
   // Assume it is supported.
   return true;
 }
 
-//----------------------------------------------------------------------------
 static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target,
-    const std::string& prop)
+                         const std::string& prop)
 {
-  if(const char* val = target->GetProperty(prop))
-    {
+  if (const char* val = target->GetProperty(prop)) {
     mf->AddDefinition(prop, val);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
                                               const std::string& targetName,
                                               const char* fname)
 {
   // Find the Info.plist template.
   const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
-  std::string inFile = (in && *in)? in : "MacOSXBundleInfo.plist.in";
-  if(!cmSystemTools::FileIsFullPath(inFile.c_str()))
-    {
+  std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
+  if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
     std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
-    if(!inMod.empty())
-      {
+    if (!inMod.empty()) {
       inFile = inMod;
-      }
     }
-  if(!cmSystemTools::FileExists(inFile.c_str(), true))
-    {
+  }
+  if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
     std::ostringstream e;
-    e << "Target " << target->GetName() << " Info.plist template \""
-      << inFile << "\" could not be found.";
+    e << "Target " << target->GetName() << " Info.plist template \"" << inFile
+      << "\" could not be found.";
     cmSystemTools::Error(e.str().c_str());
     return;
-    }
+  }
 
   // Convert target properties to variables in an isolated makefile
   // scope to configure the file.  If properties are set they will
@@ -3125,30 +2666,25 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
   mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalGenerator::GenerateFrameworkInfoPList(cmGeneratorTarget* target,
-                                                const std::string& targetName,
-                                                const char* fname)
+void cmLocalGenerator::GenerateFrameworkInfoPList(
+  cmGeneratorTarget* target, const std::string& targetName, const char* fname)
 {
   // Find the Info.plist template.
   const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
-  std::string inFile = (in && *in)? in : "MacOSXFrameworkInfo.plist.in";
-  if(!cmSystemTools::FileIsFullPath(inFile.c_str()))
-    {
+  std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
+  if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
     std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
-    if(!inMod.empty())
-      {
+    if (!inMod.empty()) {
       inFile = inMod;
-      }
     }
-  if(!cmSystemTools::FileExists(inFile.c_str(), true))
-    {
+  }
+  if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
     std::ostringstream e;
-    e << "Target " << target->GetName() << " Info.plist template \""
-      << inFile << "\" could not be found.";
+    e << "Target " << target->GetName() << " Info.plist template \"" << inFile
+      << "\" could not be found.";
     cmSystemTools::Error(e.str().c_str());
     return;
-    }
+  }
 
   // Convert target properties to variables in an isolated makefile
   // scope to configure the file.  If properties are set they will
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index b673a85..5c603a6 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -13,9 +13,10 @@
 #define cmLocalGenerator_h
 
 #include "cmStandardIncludes.h"
+
+#include "cmOutputConverter.h"
 #include "cmState.h"
 #include "cmake.h"
-#include "cmOutputConverter.h"
 
 class cmMakefile;
 class cmGlobalGenerator;
@@ -70,36 +71,36 @@ public:
   bool IsRootMakefile() const;
 
   ///! Get the makefile for this generator
-  cmMakefile *GetMakefile() {
-    return this->Makefile; }
+  cmMakefile* GetMakefile() { return this->Makefile; }
 
   ///! Get the makefile for this generator, const version
-    const cmMakefile *GetMakefile() const {
-      return this->Makefile; }
+  const cmMakefile* GetMakefile() const { return this->Makefile; }
 
   ///! Get the GlobalGenerator this is associated with
-  cmGlobalGenerator *GetGlobalGenerator() {
-    return this->GlobalGenerator; }
-  const cmGlobalGenerator *GetGlobalGenerator() const {
-    return this->GlobalGenerator; }
+  cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
+  const cmGlobalGenerator* GetGlobalGenerator() const
+  {
+    return this->GlobalGenerator;
+  }
 
   cmState* GetState() const;
   cmState::Snapshot GetStateSnapshot() const;
 
   void AddArchitectureFlags(std::string& flags,
                             cmGeneratorTarget const* target,
-                            const std::string&lang, const std::string& config);
+                            const std::string& lang,
+                            const std::string& config);
 
   void AddLanguageFlags(std::string& flags, const std::string& lang,
                         const std::string& config);
-  void AddCMP0018Flags(std::string &flags, cmGeneratorTarget const* target,
+  void AddCMP0018Flags(std::string& flags, cmGeneratorTarget const* target,
                        std::string const& lang, const std::string& config);
-  void AddVisibilityPresetFlags(std::string &flags,
+  void AddVisibilityPresetFlags(std::string& flags,
                                 cmGeneratorTarget const* target,
                                 const std::string& lang);
   void AddConfigVariableFlags(std::string& flags, const std::string& var,
                               const std::string& config);
-  void AddCompilerRequirementFlag(std::string &flags,
+  void AddCompilerRequirementFlag(std::string& flags,
                                   cmGeneratorTarget const* target,
                                   const std::string& lang);
   ///! Append flags to a string.
@@ -108,51 +109,48 @@ public:
   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,
+  std::string GetIncludeFlags(const std::vector<std::string>& includes,
                               cmGeneratorTarget* target,
                               const std::string& lang,
                               bool forceFullPaths = false,
                               bool forResponseFile = false,
                               const std::string& config = "");
 
-  const std::vector<cmGeneratorTarget*> &GetGeneratorTargets() const
-    {
-      return this->GeneratorTargets;
-    }
+  const std::vector<cmGeneratorTarget*>& GetGeneratorTargets() const
+  {
+    return this->GeneratorTargets;
+  }
 
-  const std::vector<cmGeneratorTarget*> &GetImportedGeneratorTargets() const
-    {
-      return this->ImportedGeneratorTargets;
-    }
+  const std::vector<cmGeneratorTarget*>& GetImportedGeneratorTargets() const
+  {
+    return this->ImportedGeneratorTargets;
+  }
 
   void AddGeneratorTarget(cmGeneratorTarget* gt);
   void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
   void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
 
-  cmGeneratorTarget*
-    FindLocalNonAliasGeneratorTarget(const std::string& name) const;
+  cmGeneratorTarget* FindLocalNonAliasGeneratorTarget(
+    const std::string& name) const;
   cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
 
   /**
    * Encode a list of preprocessor definitions for the compiler
    * command line.
    */
-  void AppendDefines(std::set<std::string>& defines,
-                     const char* defines_list);
-  void AppendDefines(std::set<std::string>& defines,
-                     std::string defines_list)
+  void AppendDefines(std::set<std::string>& defines, const char* defines_list);
+  void AppendDefines(std::set<std::string>& defines, std::string defines_list)
   {
     this->AppendDefines(defines, defines_list.c_str());
   }
   void AppendDefines(std::set<std::string>& defines,
-                     const std::vector<std::string> &defines_vec);
+                     const std::vector<std::string>& defines_vec);
 
   /**
    * Join a set of defines into a definesString with a space separator.
    */
   void JoinDefines(const std::set<std::string>& defines,
-                   std::string &definesString,
-                   const std::string& lang);
+                   std::string& definesString, const std::string& lang);
 
   /** Lookup and append options associated with a particular feature.  */
   void AppendFeatureOptions(std::string& flags, const std::string& lang,
@@ -176,19 +174,20 @@ public:
   bool GetRealDependency(const std::string& name, const std::string& config,
                          std::string& dep);
 
-  virtual std::string ConvertToIncludeReference(std::string const& path,
-                                                OutputFormat format = SHELL,
-                                                bool forceFullPaths = false);
+  virtual std::string ConvertToIncludeReference(
+    std::string const& path,
+    cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
+    bool forceFullPaths = false);
 
   /** Called from command-line hook to clear dependencies.  */
-  virtual void ClearDependencies(cmMakefile* /* mf */,
-                                 bool /* verbose */) {}
+  virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {}
 
   /** Called from command-line hook to update dependencies.  */
-  virtual bool UpdateDependencies(const char* /* tgtInfo */,
-                                  bool /*verbose*/,
+  virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/,
                                   bool /*color*/)
-    { return true; }
+  {
+    return true;
+  }
 
   /** Get the include flags for the current makefile and language.  */
   void GetIncludeDirectories(std::vector<std::string>& dirs,
@@ -216,10 +215,7 @@ public:
   // ExpandRuleVariables
   struct RuleVariables
   {
-    RuleVariables()
-      {
-        memset(this, 0,  sizeof(*this));
-      }
+    RuleVariables() { memset(this, 0, sizeof(*this)); }
     cmGeneratorTarget* CMTarget;
     const char* TargetPDB;
     const char* TargetCompilePDB;
@@ -255,8 +251,8 @@ public:
    * Get the relative path from the generator output directory to a
    * per-target support directory.
    */
-  virtual std::string
-  GetTargetDirectory(cmGeneratorTarget const* target) const;
+  virtual std::string GetTargetDirectory(
+    cmGeneratorTarget const* target) const;
 
   /**
    * Get the level of backwards compatibility requested by the project
@@ -307,23 +303,19 @@ public:
                                              bool* hasSourceExtension = 0);
 
   /** Fill out the static linker flags for the given target.  */
-  void GetStaticLibraryFlags(std::string& flags,
-                             std::string const& config,
+  void GetStaticLibraryFlags(std::string& flags, std::string const& config,
                              cmGeneratorTarget* target);
 
   /** Fill out these strings for the given target.  Libraries to link,
    *  flags, and linkflags. */
-  void GetTargetFlags(std::string& linkLibs,
-                      std::string& flags,
-                      std::string& linkFlags,
-                      std::string& frameworkPath,
-                      std::string& linkPath,
-                      cmGeneratorTarget* target,
+  void GetTargetFlags(std::string& linkLibs, std::string& flags,
+                      std::string& linkFlags, std::string& frameworkPath,
+                      std::string& linkPath, cmGeneratorTarget* target,
                       bool useWatcomQuote);
 
   virtual void ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* gt = 0);
+    std::map<cmSourceFile const*, std::string>& mapping,
+    cmGeneratorTarget const* gt = 0);
 
   bool IsWindowsShell() const;
   bool IsWatcomWMake() const;
@@ -338,12 +330,9 @@ public:
 protected:
   ///! put all the libraries for a target on into the given stream
   void OutputLinkLibraries(std::string& linkLibraries,
-                                   std::string& frameworkPath,
-                                   std::string& linkPath,
-                                   cmGeneratorTarget &,
-                                   bool relink,
-                                   bool forResponseFile,
-                                   bool useWatcomQuote);
+                           std::string& frameworkPath, std::string& linkPath,
+                           cmGeneratorTarget&, bool relink,
+                           bool forResponseFile, bool useWatcomQuote);
 
   // Expand rule variables in CMake of the type found in language rules
   void ExpandRuleVariables(std::string& string,
@@ -365,16 +354,17 @@ protected:
   std::string& CreateSafeUniqueObjectFileName(const std::string& sin,
                                               std::string const& dir_max);
 
-  virtual std::string ConvertToLinkReference(std::string const& lib,
-                                             OutputFormat format = SHELL);
+  virtual std::string ConvertToLinkReference(
+    std::string const& lib,
+    cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL);
 
   /** Check whether the native build system supports the given
       definition.  Issues a warning.  */
   virtual bool CheckDefinition(std::string const& define) const;
 
-  cmMakefile *Makefile;
+  cmMakefile* Makefile;
   cmState::Snapshot StateSnapshot;
-  cmGlobalGenerator *GlobalGenerator;
+  cmGlobalGenerator* GlobalGenerator;
   std::map<std::string, std::string> UniqueObjectNamesMap;
   std::string::size_type ObjectPathMax;
   std::set<std::string> ObjectMaxPathViolations;
@@ -393,14 +383,21 @@ protected:
 
   KWIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
+
 private:
   void AddSharedFlags(std::string& flags, const std::string& lang,
                       bool shared);
-  bool GetShouldUseOldFlags(bool shared, const std::string &lang) const;
+  bool GetShouldUseOldFlags(bool shared, const std::string& lang) const;
   void AddPositionIndependentFlags(std::string& flags, std::string const& l,
                                    int targetType);
 
   void ComputeObjectMaxPath();
 };
 
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+bool cmLocalGeneratorCheckObjectName(std::string& objName,
+                                     std::string::size_type dir_len,
+                                     std::string::size_type max_total_len);
+#endif
+
 #endif
diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx
index a77a75e..01537dd 100644
--- a/Source/cmLocalGhsMultiGenerator.cxx
+++ b/Source/cmLocalGhsMultiGenerator.cxx
@@ -10,11 +10,12 @@
   See the License for more information.
 ============================================================================*/
 #include "cmLocalGhsMultiGenerator.h"
-#include "cmGlobalGhsMultiGenerator.h"
+
+#include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
-#include "cmMakefile.h"
 #include "cmGhsMultiTargetGenerator.h"
-#include "cmGeneratedFileStream.h"
+#include "cmGlobalGhsMultiGenerator.h"
+#include "cmMakefile.h"
 
 cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
                                                    cmMakefile* mf)
@@ -22,20 +23,20 @@ cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
 {
 }
 
-cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {}
+cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator()
+{
+}
 
 void cmLocalGhsMultiGenerator::Generate()
 {
   std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
 
   for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-       l != tgts.end(); ++l)
-    {
-    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+       l != tgts.end(); ++l) {
+    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     cmGhsMultiTargetGenerator tg(*l);
     tg.Generate();
-    }
+  }
 }
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 2d13507..6c231c3 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -11,14 +11,15 @@
   See the License for more information.
 ============================================================================*/
 #include "cmLocalNinjaGenerator.h"
+
 #include "cmCustomCommandGenerator.h"
-#include "cmMakefile.h"
+#include "cmGeneratedFileStream.h"
 #include "cmGlobalNinjaGenerator.h"
+#include "cmMakefile.h"
 #include "cmNinjaTargetGenerator.h"
-#include "cmGeneratedFileStream.h"
 #include "cmSourceFile.h"
-#include "cmake.h"
 #include "cmState.h"
+#include "cmake.h"
 
 #include <assert.h>
 
@@ -30,7 +31,6 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
   this->TargetImplib = "$TARGET_IMPLIB";
 }
 
-//----------------------------------------------------------------------------
 // Virtual public methods.
 
 cmLocalNinjaGenerator::~cmLocalNinjaGenerator()
@@ -41,12 +41,11 @@ void cmLocalNinjaGenerator::Generate()
 {
   // Compute the path to use when referencing the current output
   // directory from the top output directory.
-  this->HomeRelativeOutputPath =
-    this->Convert(this->GetCurrentBinaryDirectory(), HOME_OUTPUT);
-  if(this->HomeRelativeOutputPath == ".")
-    {
+  this->HomeRelativeOutputPath = this->Convert(
+    this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
+  if (this->HomeRelativeOutputPath == ".") {
     this->HomeRelativeOutputPath = "";
-    }
+  }
 
   this->SetConfigName();
 
@@ -56,50 +55,44 @@ void cmLocalNinjaGenerator::Generate()
 #endif
 
   // We do that only once for the top CMakeLists.txt file.
-  if(this->IsRootMakefile())
-    {
+  if (this->IsRootMakefile()) {
     this->WriteBuildFileTop();
 
     this->WritePools(this->GetRulesFileStream());
 
-    const std::string showIncludesPrefix = this->GetMakefile()
-             ->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
-    if (!showIncludesPrefix.empty())
-      {
+    const std::string showIncludesPrefix =
+      this->GetMakefile()->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
+    if (!showIncludesPrefix.empty()) {
       cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(),
                                            "localized /showIncludes string");
-      this->GetRulesFileStream()
-            << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n";
-      }
+      this->GetRulesFileStream() << "msvc_deps_prefix = " << showIncludesPrefix
+                                 << "\n\n";
     }
+  }
 
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
-    if ((*t)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+       t != targets.end(); ++t) {
+    if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(*t);
-    if(tg)
-      {
+    if (tg) {
       tg->Generate();
       // Add the target to "all" if required.
       if (!this->GetGlobalNinjaGenerator()->IsExcluded(
-            this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0],
-            *t))
+            this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t))
         this->GetGlobalNinjaGenerator()->AddDependencyToAll(*t);
       delete tg;
-      }
     }
+  }
 
   this->WriteCustomCommandBuildStatements();
 }
 
 // TODO: Picked up from cmLocalUnixMakefileGenerator3.  Refactor it.
-std::string cmLocalNinjaGenerator
-::GetTargetDirectory(cmGeneratorTarget const* target) const
+std::string cmLocalNinjaGenerator::GetTargetDirectory(
+  cmGeneratorTarget const* target) const
 {
   std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
   dir += target->GetName();
@@ -111,14 +104,13 @@ std::string cmLocalNinjaGenerator
   return dir;
 }
 
-//----------------------------------------------------------------------------
 // Non-virtual public methods.
 
-const cmGlobalNinjaGenerator*
-cmLocalNinjaGenerator::GetGlobalNinjaGenerator() const
+const cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
+  const
 {
-  return
-    static_cast<const cmGlobalNinjaGenerator*>(this->GetGlobalGenerator());
+  return static_cast<const cmGlobalNinjaGenerator*>(
+    this->GetGlobalGenerator());
 }
 
 cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
@@ -126,25 +118,24 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
   return static_cast<cmGlobalNinjaGenerator*>(this->GetGlobalGenerator());
 }
 
-//----------------------------------------------------------------------------
 // Virtual protected methods.
 
-std::string
-cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib,
-                                              OutputFormat format)
+std::string cmLocalNinjaGenerator::ConvertToLinkReference(
+  std::string const& lib, cmOutputConverter::OutputFormat format)
 {
-  return this->Convert(lib, HOME_OUTPUT, format);
+  std::string path = this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(lib);
+  return this->ConvertToOutputFormat(path, format);
 }
 
-std::string
-cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path,
-                                                 OutputFormat format,
-                                                 bool forceFullPaths)
+std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
+  std::string const& path, cmOutputConverter::OutputFormat format,
+  bool forceFullPaths)
 {
-  return this->Convert(path, forceFullPaths? FULL : HOME_OUTPUT, format);
+  return this->Convert(path, forceFullPaths ? cmOutputConverter::FULL
+                                            : cmOutputConverter::HOME_OUTPUT,
+                       format);
 }
 
-//----------------------------------------------------------------------------
 // Private methods.
 
 cmGeneratedFileStream& cmLocalNinjaGenerator::GetBuildFileStream() const
@@ -181,10 +172,8 @@ void cmLocalNinjaGenerator::WriteBuildFileTop()
 void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
-  os
-    << "# Project: " << this->GetProjectName() << std::endl
-    << "# Configuration: " << this->ConfigName << std::endl
-    ;
+  os << "# Project: " << this->GetProjectName() << std::endl
+     << "# Configuration: " << this->ConfigName << std::endl;
   cmGlobalNinjaGenerator::WriteDivider(os);
 }
 
@@ -192,116 +181,104 @@ void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
 {
   // Default required version
   std::string requiredVersion =
-      this->GetGlobalNinjaGenerator()->RequiredNinjaVersion();
+    this->GetGlobalNinjaGenerator()->RequiredNinjaVersion();
 
   // Ninja generator uses the 'console' pool if available (>= 1.5)
-  if(this->GetGlobalNinjaGenerator()->SupportsConsolePool())
-    {
+  if (this->GetGlobalNinjaGenerator()->SupportsConsolePool()) {
     requiredVersion =
       this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool();
-    }
+  }
 
-  cmGlobalNinjaGenerator::WriteComment(os,
-                          "Minimal version of Ninja required by this file");
-  os
-    << "ninja_required_version = "
-    << requiredVersion
-    << std::endl << std::endl
-    ;
+  cmGlobalNinjaGenerator::WriteComment(
+    os, "Minimal version of Ninja required by this file");
+  os << "ninja_required_version = " << requiredVersion << std::endl
+     << std::endl;
 }
 
 void cmLocalNinjaGenerator::WritePools(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
 
-  const char* jobpools = this->GetCMakeInstance()->GetState()
-                             ->GetGlobalProperty("JOB_POOLS");
-  if (jobpools)
-    {
-    cmGlobalNinjaGenerator::WriteComment(os,
-                            "Pools defined by global property JOB_POOLS");
+  const char* jobpools =
+    this->GetCMakeInstance()->GetState()->GetGlobalProperty("JOB_POOLS");
+  if (jobpools) {
+    cmGlobalNinjaGenerator::WriteComment(
+      os, "Pools defined by global property JOB_POOLS");
     std::vector<std::string> pools;
     cmSystemTools::ExpandListArgument(jobpools, pools);
-    for (size_t i = 0; i < pools.size(); ++i)
-      {
+    for (size_t i = 0; i < pools.size(); ++i) {
       const std::string pool = pools[i];
-      const std::string::size_type eq = pool.find("=");
+      const std::string::size_type eq = pool.find('=');
       unsigned int jobs;
       if (eq != std::string::npos &&
-          sscanf(pool.c_str() + eq, "=%u", &jobs) == 1)
-        {
+          sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) {
         os << "pool " << pool.substr(0, eq) << std::endl;
         os << "  depth = " << jobs << std::endl;
         os << std::endl;
-        }
-      else
-        {
+      } else {
         cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': ",
                              pool.c_str());
-        }
       }
     }
+  }
 }
 
 void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
-  os
-    << "# Include auxiliary files.\n"
-    << "\n"
-    ;
-  cmGlobalNinjaGenerator::WriteInclude(os,
-                                      cmGlobalNinjaGenerator::NINJA_RULES_FILE,
+  os << "# Include auxiliary files.\n"
+     << "\n";
+  cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
+  std::string const ninjaRulesFile =
+    ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
+  std::string const rulesFilePath =
+    ng->EncodeIdent(ng->EncodePath(ninjaRulesFile), os);
+  cmGlobalNinjaGenerator::WriteInclude(os, rulesFilePath,
                                        "Include rules file.");
   os << "\n";
 }
 
-//----------------------------------------------------------------------------
 void cmLocalNinjaGenerator::ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* gt)
+  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)
-    {
+  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);
-    }
+    si->second =
+      this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
+  }
 }
 
 void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
-  os
-    << "# Write statements declared in CMakeLists.txt:" << std::endl
-    << "# "
-    << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << std::endl;
-  if(this->IsRootMakefile())
+  os << "# Write statements declared in CMakeLists.txt:" << std::endl
+     << "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")
+     << std::endl;
+  if (this->IsRootMakefile())
     os << "# Which is the root file." << std::endl;
   cmGlobalNinjaGenerator::WriteDivider(os);
   os << std::endl;
 }
 
-void
-cmLocalNinjaGenerator
-::AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs)
+void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target,
+                                                cmNinjaDeps& outputs)
 {
   this->GetGlobalNinjaGenerator()->AppendTargetOutputs(target, outputs);
 }
 
-void
-cmLocalNinjaGenerator
-::AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs)
+void cmLocalNinjaGenerator::AppendTargetDepends(cmGeneratorTarget* target,
+                                                cmNinjaDeps& outputs)
 {
   this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs);
 }
 
 void cmLocalNinjaGenerator::AppendCustomCommandDeps(
-  cmCustomCommandGenerator const& ccg,
-  cmNinjaDeps &ninjaDeps)
+  cmCustomCommandGenerator const& ccg, cmNinjaDeps& ninjaDeps)
 {
-  const std::vector<std::string> &deps = ccg.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;
@@ -312,7 +289,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(
 }
 
 std::string cmLocalNinjaGenerator::BuildCommandLine(
-                                    const std::vector<std::string> &cmdLines)
+  const std::vector<std::string>& cmdLines)
 {
   // If we have no commands but we need to build a command anyway, use ":".
   // This happens when building a POST_BUILD value for link targets that
@@ -328,36 +305,30 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
   for (std::vector<std::string>::const_iterator li = cmdLines.begin();
        li != cmdLines.end(); ++li)
 #ifdef _WIN32
-    {
-    if (li != cmdLines.begin())
-      {
+  {
+    if (li != cmdLines.begin()) {
       cmd << " && ";
-      }
-    else if (cmdLines.size() > 1)
-      {
+    } else if (cmdLines.size() > 1) {
       cmd << "cmd.exe /C \"";
-      }
-    cmd << *li;
     }
-  if (cmdLines.size() > 1)
-    {
+    cmd << *li;
+  }
+  if (cmdLines.size() > 1) {
     cmd << "\"";
-    }
+  }
 #else
-    {
-    if (li != cmdLines.begin())
-      {
+  {
+    if (li != cmdLines.begin()) {
       cmd << " && ";
-      }
-    cmd << *li;
     }
+    cmd << *li;
+  }
 #endif
   return cmd.str();
 }
 
 void cmLocalNinjaGenerator::AppendCustomCommandLines(
-  cmCustomCommandGenerator const& ccg,
-  std::vector<std::string> &cmdLines)
+  cmCustomCommandGenerator const& ccg, std::vector<std::string>& cmdLines)
 {
   if (ccg.GetNumberOfCommands() > 0) {
     std::string wd = ccg.GetWorkingDirectory();
@@ -366,11 +337,12 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
 
     std::ostringstream cdCmd;
 #ifdef _WIN32
-        std::string cdStr = "cd /D ";
+    std::string cdStr = "cd /D ";
 #else
-        std::string cdStr = "cd ";
+    std::string cdStr = "cd ";
 #endif
-    cdCmd << cdStr << this->ConvertToOutputFormat(wd, SHELL);
+    cdCmd << cdStr
+          << this->ConvertToOutputFormat(wd, cmOutputConverter::SHELL);
     cmdLines.push_back(cdCmd.str());
   }
 
@@ -378,43 +350,40 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
 
   for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {
     cmdLines.push_back(launcher +
-      this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL));
+                       this->ConvertToOutputFormat(ccg.GetCommand(i),
+                                                   cmOutputConverter::SHELL));
 
     std::string& cmd = cmdLines.back();
     ccg.AppendArguments(i, cmd);
   }
 }
 
-void
-cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
-  cmCustomCommand const *cc, const cmNinjaDeps& orderOnlyDeps)
+void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
+  cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps)
 {
   if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc))
     return;
 
   cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this);
 
-  const std::vector<std::string> &outputs = ccg.GetOutputs();
-  const std::vector<std::string> &byproducts = ccg.GetByproducts();
-  cmNinjaDeps ninjaOutputs(outputs.size()+byproducts.size()), ninjaDeps;
+  const std::vector<std::string>& outputs = ccg.GetOutputs();
+  const std::vector<std::string>& byproducts = ccg.GetByproducts();
+  cmNinjaDeps ninjaOutputs(outputs.size() + byproducts.size()), ninjaDeps;
 
   bool symbolic = false;
   for (std::vector<std::string>::const_iterator o = outputs.begin();
-       !symbolic && o != outputs.end(); ++o)
-    {
-    if (cmSourceFile* sf = this->Makefile->GetSource(*o))
-      {
+       !symbolic && o != outputs.end(); ++o) {
+    if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
       symbolic = sf->GetPropertyAsBool("SYMBOLIC");
-      }
     }
+  }
 
 #if 0
 #error TODO: Once CC in an ExternalProject target must provide the \
     file of each imported target that has an add_dependencies pointing \
     at us.  How to know which ExternalProject step actually provides it?
 #endif
-  std::transform(outputs.begin(), outputs.end(),
-                 ninjaOutputs.begin(),
+  std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(),
                  this->GetGlobalNinjaGenerator()->MapToNinjaPath());
   std::transform(byproducts.begin(), byproducts.end(),
                  ninjaOutputs.begin() + outputs.size(),
@@ -431,22 +400,13 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
   if (cmdLines.empty()) {
     this->GetGlobalNinjaGenerator()->WritePhonyBuild(
       this->GetBuildFileStream(),
-      "Phony custom command for " +
-      ninjaOutputs[0],
-      ninjaOutputs,
-      ninjaDeps,
-      cmNinjaDeps(),
-      orderOnlyDeps,
-      cmNinjaVars());
+      "Phony custom command for " + ninjaOutputs[0], ninjaOutputs, ninjaDeps,
+      cmNinjaDeps(), orderOnlyDeps, cmNinjaVars());
   } else {
     this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild(
-      this->BuildCommandLine(cmdLines),
-      this->ConstructComment(ccg),
-      "Custom command for " + ninjaOutputs[0],
-      cc->GetUsesTerminal(),
-      /*restat*/!symbolic || !byproducts.empty(),
-      ninjaOutputs,
-      ninjaDeps,
+      this->BuildCommandLine(cmdLines), this->ConstructComment(ccg),
+      "Custom command for " + ninjaOutputs[0], cc->GetUsesTerminal(),
+      /*restat*/ !symbolic || !byproducts.empty(), ninjaOutputs, ninjaDeps,
       orderOnlyDeps);
   }
 }
@@ -454,13 +414,23 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
 void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
                                                    cmGeneratorTarget* target)
 {
-  this->CustomCommandTargets[cc].insert(target);
+  CustomCommandTargetMap::value_type v(cc, std::set<cmGeneratorTarget*>());
+  std::pair<CustomCommandTargetMap::iterator, bool> ins =
+    this->CustomCommandTargets.insert(v);
+  if (ins.second) {
+    this->CustomCommands.push_back(cc);
+  }
+  ins.first->second.insert(target);
 }
 
 void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
 {
-  for (CustomCommandTargetMap::iterator i = this->CustomCommandTargets.begin();
-       i != this->CustomCommandTargets.end(); ++i) {
+  for (std::vector<cmCustomCommand const*>::iterator vi =
+         this->CustomCommands.begin();
+       vi != this->CustomCommands.end(); ++vi) {
+    CustomCommandTargetMap::iterator i = this->CustomCommandTargets.find(*vi);
+    assert(i != this->CustomCommandTargets.end());
+
     // A custom command may appear on multiple targets.  However, some build
     // systems exist where the target dependencies on some of the targets are
     // overspecified, leading to a dependency cycle.  If we assume all target
@@ -497,8 +467,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
   const char* property = "RULE_LAUNCH_CUSTOM";
   const char* property_value = this->Makefile->GetProperty(property);
 
-  if(!property_value || !*property_value)
-  {
+  if (!property_value || !*property_value) {
     return std::string();
   }
 
@@ -508,19 +477,19 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
   vars.RuleLauncher = property;
   std::string output;
   const std::vector<std::string>& outputs = ccg.GetOutputs();
-  if(!outputs.empty())
-  {
-    RelativeRoot relative_root =
-      ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE;
+  if (!outputs.empty()) {
+    cmOutputConverter::RelativeRoot relative_root =
+      ccg.GetWorkingDirectory().empty() ? cmOutputConverter::START_OUTPUT
+                                        : cmOutputConverter::NONE;
 
-    output = this->Convert(outputs[0], relative_root, SHELL);
+    output =
+      this->Convert(outputs[0], relative_root, cmOutputConverter::SHELL);
   }
   vars.Output = output.c_str();
 
   std::string launcher;
   this->ExpandRuleVariables(launcher, vars);
-  if(!launcher.empty())
-  {
+  if (!launcher.empty()) {
     launcher += " ";
   }
 
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index b6987ef..9899360 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -11,10 +11,11 @@
   See the License for more information.
 ============================================================================*/
 #ifndef cmLocalNinjaGenerator_h
-#  define cmLocalNinjaGenerator_h
+#define cmLocalNinjaGenerator_h
 
-#  include "cmLocalCommonGenerator.h"
-#  include "cmNinjaTypes.h"
+#include "cmLocalCommonGenerator.h"
+
+#include "cmNinjaTypes.h"
 
 class cmCustomCommandGenerator;
 class cmGlobalNinjaGenerator;
@@ -37,8 +38,8 @@ public:
 
   virtual void Generate();
 
-  virtual
-  std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
+  virtual std::string GetTargetDirectory(
+    cmGeneratorTarget const* target) const;
 
   const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const;
   cmGlobalNinjaGenerator* GetGlobalNinjaGenerator();
@@ -49,14 +50,17 @@ public:
   /// @returns the relative path between the HomeOutputDirectory and this
   /// local generators StartOutputDirectory.
   std::string GetHomeRelativeOutputPath() const
-  { return this->HomeRelativeOutputPath; }
+  {
+    return this->HomeRelativeOutputPath;
+  }
 
   void ExpandRuleVariables(std::string& string,
-                           const RuleVariables& replaceValues) {
+                           const RuleVariables& replaceValues)
+  {
     cmLocalGenerator::ExpandRuleVariables(string, replaceValues);
   }
 
-  std::string BuildCommandLine(const std::vector<std::string> &cmdLines);
+  std::string BuildCommandLine(const std::vector<std::string>& cmdLines);
 
   void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs);
   void AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs);
@@ -64,23 +68,23 @@ public:
   void AddCustomCommandTarget(cmCustomCommand const* cc,
                               cmGeneratorTarget* target);
   void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
-                                std::vector<std::string> &cmdLines);
+                                std::vector<std::string>& cmdLines);
   void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
-                               cmNinjaDeps &ninjaDeps);
+                               cmNinjaDeps& ninjaDeps);
 
-  virtual std::string ConvertToLinkReference(std::string const& lib,
-                                             OutputFormat format = SHELL);
+  virtual std::string ConvertToLinkReference(
+    std::string const& lib,
+    cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL);
 
   virtual void ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* gt = 0);
-
+    std::map<cmSourceFile const*, std::string>& mapping,
+    cmGeneratorTarget const* gt = 0);
 
 protected:
-  virtual std::string ConvertToIncludeReference(std::string const& path,
-                                                OutputFormat format = SHELL,
-                                                bool forceFullPaths = false);
-
+  virtual std::string ConvertToIncludeReference(
+    std::string const& path,
+    cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
+    bool forceFullPaths = false);
 
 private:
   cmGeneratedFileStream& GetBuildFileStream() const;
@@ -94,7 +98,7 @@ private:
   void WritePools(std::ostream& os);
 
   void WriteCustomCommandRule();
-  void WriteCustomCommandBuildStatement(cmCustomCommand const *cc,
+  void WriteCustomCommandBuildStatement(cmCustomCommand const* cc,
                                         const cmNinjaDeps& orderOnlyDeps);
 
   void WriteCustomCommandBuildStatements();
@@ -106,6 +110,7 @@ private:
   typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*> >
     CustomCommandTargetMap;
   CustomCommandTargetMap CustomCommandTargets;
+  std::vector<cmCustomCommand const*> CustomCommands;
 };
 
 #endif // ! cmLocalNinjaGenerator_h
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 62fea3d..f60a595 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -11,76 +11,79 @@
 ============================================================================*/
 #include "cmLocalUnixMakefileGenerator3.h"
 
+#include "cmAlgorithms.h"
+#include "cmCustomCommandGenerator.h"
+#include "cmFileTimeComparison.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmMakefileTargetGenerator.h"
 #include "cmSourceFile.h"
-#include "cmake.h"
 #include "cmVersion.h"
-#include "cmFileTimeComparison.h"
-#include "cmCustomCommandGenerator.h"
-#include "cmAlgorithms.h"
+#include "cmake.h"
 
 // Include dependency scanners for supported languages.  Only the
 // C/C++ scanner is needed for bootstrapping CMake.
 #include "cmDependsC.h"
 #ifdef CMAKE_BUILD_WITH_CMAKE
-# include "cmDependsFortran.h"
-# include "cmDependsJava.h"
+#include "cmDependsFortran.h"
+#include "cmDependsJava.h"
 #endif
 
-#include <cmsys/auto_ptr.hxx>
 #include <cmsys/Terminal.h>
+#include <cmsys/auto_ptr.hxx>
 
+#include <algorithm>
 #include <queue>
 
-//----------------------------------------------------------------------------
 // Escape special characters in Makefile dependency lines
 class cmMakeSafe
 {
 public:
-  cmMakeSafe(const char* s): Data(s) {}
-  cmMakeSafe(std::string const& s): Data(s.c_str()) {}
+  cmMakeSafe(const char* s)
+    : Data(s)
+  {
+  }
+  cmMakeSafe(std::string const& s)
+    : Data(s.c_str())
+  {
+  }
+
 private:
   const char* Data;
-  friend std::ostream& operator<<(std::ostream& os,
-                                  cmMakeSafe const& self)
-    {
-    for(const char* c = self.Data; *c; ++c)
-      {
-      switch (*c)
-        {
-        case '=': os << "$(EQUALS)"; break;
-        default: os << *c; break;
-        }
+  friend std::ostream& operator<<(std::ostream& os, cmMakeSafe const& self)
+  {
+    for (const char* c = self.Data; *c; ++c) {
+      switch (*c) {
+        case '=':
+          os << "$(EQUALS)";
+          break;
+        default:
+          os << *c;
+          break;
       }
-    return os;
     }
+    return os;
+  }
 };
 
-//----------------------------------------------------------------------------
 // Helper function used below.
 static std::string cmSplitExtension(std::string const& in, std::string& base)
 {
   std::string ext;
-  std::string::size_type dot_pos = in.rfind(".");
-  if(dot_pos != std::string::npos)
-    {
+  std::string::size_type dot_pos = in.rfind('.');
+  if (dot_pos != std::string::npos) {
     // Remove the extension first in case &base == &in.
     ext = in.substr(dot_pos, std::string::npos);
     base = in.substr(0, dot_pos);
-    }
-  else
-    {
+  } else {
     base = in;
-    }
+  }
   return ext;
 }
 
-//----------------------------------------------------------------------------
-cmLocalUnixMakefileGenerator3::
-cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf)
+cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
+  cmGlobalGenerator* gg, cmMakefile* mf)
   : cmLocalCommonGenerator(gg, mf)
 {
   this->MakefileVariableSize = 0;
@@ -91,22 +94,19 @@ cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf)
   this->BorlandMakeCurlyHack = false;
 }
 
-//----------------------------------------------------------------------------
 cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3()
 {
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::Generate()
 {
   this->SetConfigName();
 
   // Record whether some options are enabled to avoid checking many
   // times later.
-  if(!this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile())
-    {
+  if (!this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {
     this->ColorMakefile = this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE");
-    }
+  }
   this->SkipPreprocessedSourceRules =
     this->Makefile->IsOn("CMAKE_SKIP_PREPROCESSED_SOURCE_RULES");
   this->SkipAssemblySourceRules =
@@ -116,21 +116,18 @@ void cmLocalUnixMakefileGenerator3::Generate()
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
   cmGlobalUnixMakefileGenerator3* gg =
     static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-  for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
-    if ((*t)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+       t != targets.end(); ++t) {
+    if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     cmsys::auto_ptr<cmMakefileTargetGenerator> tg(
       cmMakefileTargetGenerator::New(*t));
-    if (tg.get())
-      {
+    if (tg.get()) {
       tg->WriteRuleFiles();
       gg->RecordTargetProgress(tg.get());
-      }
     }
+  }
 
   // write the local Makefile
   this->WriteLocalMakefile();
@@ -143,48 +140,42 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
 {
   // Compute the path to use when referencing the current output
   // directory from the top output directory.
-  this->HomeRelativeOutputPath =
-    this->Convert(this->GetCurrentBinaryDirectory(), HOME_OUTPUT);
-  if(this->HomeRelativeOutputPath == ".")
-    {
+  this->HomeRelativeOutputPath = this->Convert(
+    this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
+  if (this->HomeRelativeOutputPath == ".") {
     this->HomeRelativeOutputPath = "";
-    }
-  if(!this->HomeRelativeOutputPath.empty())
-    {
+  }
+  if (!this->HomeRelativeOutputPath.empty()) {
     this->HomeRelativeOutputPath += "/";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* gt)
+  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)
-    {
+  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);
-    }
+    si->second =
+      this->GetObjectFileNameWithoutTarget(*sf, gt->ObjectDirectory);
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::
-GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
+void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
+  std::map<std::string, LocalObjectInfo>& localObjectFiles)
 {
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
-      ti != targets.end(); ++ti)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
+       ti != targets.end(); ++ti) {
     cmGeneratorTarget* gt = *ti;
-    if (gt->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (gt->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     std::vector<cmSourceFile const*> objectSources;
-    gt->GetObjectSources(objectSources, this->Makefile
-                                    ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+    gt->GetObjectSources(
+      objectSources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
     // Compute full path to object file directory for this target.
     std::string dir;
     dir += gt->LocalGenerator->GetCurrentBinaryDirectory();
@@ -192,53 +183,44 @@ GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
     dir += this->GetTargetDirectory(gt);
     dir += "/";
     // Compute the name of each object file.
-    for(std::vector<cmSourceFile const*>::iterator
-          si = objectSources.begin();
-        si != objectSources.end(); ++si)
-      {
+    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()))
-        {
+      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, sf->GetLanguage()));
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets
-                                            (std::vector<std::string>& targets)
+void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets(
+  std::vector<std::string>& targets)
 {
   std::map<std::string, LocalObjectInfo> localObjectFiles;
   this->GetLocalObjectFiles(localObjectFiles);
   for (std::map<std::string, LocalObjectInfo>::iterator lo =
          localObjectFiles.begin();
-       lo != localObjectFiles.end(); ++lo)
-    {
+       lo != localObjectFiles.end(); ++lo) {
     targets.push_back(lo->first);
 
     std::string::size_type dot_pos = lo->first.rfind(".");
     std::string base = lo->first.substr(0, dot_pos);
-    if(lo->second.HasPreprocessRule)
-      {
+    if (lo->second.HasPreprocessRule) {
       targets.push_back(base + ".i");
-      }
+    }
 
-    if(lo->second.HasAssembleRule)
-      {
+    if (lo->second.HasAssembleRule) {
       targets.push_back(base + ".s");
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
 {
   // generate the includes
@@ -248,15 +230,13 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
   // rules may depend on this file itself.
   std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
   cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
-  if(!ruleFileStream)
-    {
+  if (!ruleFileStream) {
     return;
-    }
+  }
   // always write the top makefile
-  if (!this->IsRootMakefile())
-    {
+  if (!this->IsRootMakefile()) {
     ruleFileStream.SetCopyIfDifferent(true);
-    }
+  }
 
   // write the all rules
   this->WriteLocalAllRules(ruleFileStream);
@@ -264,23 +244,18 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
   // only write local targets unless at the top Keep track of targets already
   // listed.
   std::set<std::string> emittedTargets;
-  if (!this->IsRootMakefile())
-    {
+  if (!this->IsRootMakefile()) {
     // write our targets, and while doing it collect up the object
     // file rules
-    this->WriteLocalMakefileTargets(ruleFileStream,emittedTargets);
-    }
-  else
-    {
-    cmGlobalUnixMakefileGenerator3 *gg =
+    this->WriteLocalMakefileTargets(ruleFileStream, emittedTargets);
+  } else {
+    cmGlobalUnixMakefileGenerator3* gg =
       static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-    gg->WriteConvenienceRules(ruleFileStream,emittedTargets);
-    }
+    gg->WriteConvenienceRules(ruleFileStream, emittedTargets);
+  }
 
-  bool do_preprocess_rules =
-    this->GetCreatePreprocessedSourceRules();
-  bool do_assembly_rules =
-    this->GetCreateAssemblySourceRules();
+  bool do_preprocess_rules = this->GetCreatePreprocessedSourceRules();
+  bool do_assembly_rules = this->GetCreateAssemblySourceRules();
 
   std::map<std::string, LocalObjectInfo> localObjectFiles;
   this->GetLocalObjectFiles(localObjectFiles);
@@ -289,8 +264,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
   // for each object file name
   for (std::map<std::string, LocalObjectInfo>::iterator lo =
          localObjectFiles.begin();
-       lo != localObjectFiles.end(); ++lo)
-    {
+       lo != localObjectFiles.end(); ++lo) {
     // Add a convenience rule for building the object file.
     this->WriteObjectConvenienceRule(ruleFileStream,
                                      "target to build an object file",
@@ -301,67 +275,57 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
     bool lang_has_preprocessor = false;
     bool lang_has_assembly = false;
 
-    for(std::vector<LocalObjectEntry>::const_iterator ei =
-          lo->second.begin(); ei != lo->second.end(); ++ei)
-      {
-      if(ei->Language == "C" ||
-         ei->Language == "CXX" ||
-         ei->Language == "Fortran")
-        {
+    for (std::vector<LocalObjectEntry>::const_iterator ei = lo->second.begin();
+         ei != lo->second.end(); ++ei) {
+      if (ei->Language == "C" || ei->Language == "CXX" ||
+          ei->Language == "Fortran") {
         // Right now, C, C++ and Fortran have both a preprocessor and the
         // ability to generate assembly code
         lang_has_preprocessor = true;
         lang_has_assembly = true;
         break;
-        }
       }
+    }
 
     // Add convenience rules for preprocessed and assembly files.
-    if(lang_has_preprocessor && do_preprocess_rules)
-      {
+    if (lang_has_preprocessor && do_preprocess_rules) {
       std::string::size_type dot_pos = lo->first.rfind(".");
       std::string base = lo->first.substr(0, dot_pos);
-      this->WriteObjectConvenienceRule(
-        ruleFileStream, "target to preprocess a source file",
-       (base + ".i").c_str(), lo->second);
+      this->WriteObjectConvenienceRule(ruleFileStream,
+                                       "target to preprocess a source file",
+                                       (base + ".i").c_str(), lo->second);
       lo->second.HasPreprocessRule = true;
-      }
+    }
 
-    if(lang_has_assembly && do_assembly_rules)
-      {
+    if (lang_has_assembly && do_assembly_rules) {
       std::string::size_type dot_pos = lo->first.rfind(".");
       std::string base = lo->first.substr(0, dot_pos);
       this->WriteObjectConvenienceRule(
-       ruleFileStream, "target to generate assembly for a file",
-       (base + ".s").c_str(), lo->second);
+        ruleFileStream, "target to generate assembly for a file",
+        (base + ".s").c_str(), lo->second);
       lo->second.HasAssembleRule = true;
-      }
     }
+  }
 
   // add a help target as long as there isn;t a real target named help
-  if(emittedTargets.insert("help").second)
-    {
-    cmGlobalUnixMakefileGenerator3 *gg =
+  if (emittedTargets.insert("help").second) {
+    cmGlobalUnixMakefileGenerator3* gg =
       static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-    gg->WriteHelpRule(ruleFileStream,this);
-    }
+    gg->WriteHelpRule(ruleFileStream, this);
+  }
 
   this->WriteSpecialTargetsBottom(ruleFileStream);
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::WriteObjectConvenienceRule(std::ostream& ruleFileStream,
-                             const char* comment, const char* output,
-                             LocalObjectInfo const& info)
+void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
+  std::ostream& ruleFileStream, const char* comment, const char* output,
+  LocalObjectInfo const& info)
 {
   // If the rule includes the source file extension then create a
   // version that has the extension removed.  The help should include
   // only the version without source extension.
   bool inHelp = true;
-  if(info.HasSourceExtension)
-    {
+  if (info.HasSourceExtension) {
     // Remove the last extension.  This should be kept.
     std::string outBase1 = output;
     std::string outExt1 = cmSplitExtension(outBase1, outBase1);
@@ -376,40 +340,34 @@ cmLocalUnixMakefileGenerator3
     std::vector<std::string> depends;
     depends.push_back(output);
     std::vector<std::string> no_commands;
-    this->WriteMakeRule(ruleFileStream, 0,
-                        outNoExt, depends, no_commands, true, true);
+    this->WriteMakeRule(ruleFileStream, 0, outNoExt, depends, no_commands,
+                        true, true);
     inHelp = false;
-    }
+  }
 
   // Recursively make the rule for each target using the object file.
   std::vector<std::string> commands;
-  for(std::vector<LocalObjectEntry>::const_iterator t = info.begin();
-      t != info.end(); ++t)
-    {
-    std::string tgtMakefileName =
-      this->GetRelativeTargetDirectory(t->Target);
+  for (std::vector<LocalObjectEntry>::const_iterator t = info.begin();
+       t != info.end(); ++t) {
+    std::string tgtMakefileName = this->GetRelativeTargetDirectory(t->Target);
     std::string targetName = tgtMakefileName;
     tgtMakefileName += "/build.make";
     targetName += "/";
     targetName += output;
     commands.push_back(
-      this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName)
-      );
-    }
-  this->CreateCDCommand(commands,
-                        this->GetBinaryDirectory(),
-                        cmLocalGenerator::START_OUTPUT);
+      this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName));
+  }
+  this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                        cmOutputConverter::START_OUTPUT);
 
   // Write the rule to the makefile.
   std::vector<std::string> no_depends;
-  this->WriteMakeRule(ruleFileStream, comment,
-                      output, no_depends, commands, true, inHelp);
+  this->WriteMakeRule(ruleFileStream, comment, output, no_depends, commands,
+                      true, inHelp);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3
-::WriteLocalMakefileTargets(std::ostream& ruleFileStream,
-                            std::set<std::string> &emitted)
+void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
+  std::ostream& ruleFileStream, std::set<std::string>& emitted)
 {
   std::vector<std::string> depends;
   std::vector<std::string> commands;
@@ -418,16 +376,14 @@ void cmLocalUnixMakefileGenerator3
   // on the target
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
   std::string localName;
-  for(std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
-      t != targets.end(); ++t)
-    {
-    if(((*t)->GetType() == cmState::EXECUTABLE) ||
-       ((*t)->GetType() == cmState::STATIC_LIBRARY) ||
-       ((*t)->GetType() == cmState::SHARED_LIBRARY) ||
-       ((*t)->GetType() == cmState::MODULE_LIBRARY) ||
-       ((*t)->GetType() == cmState::OBJECT_LIBRARY) ||
-       ((*t)->GetType() == cmState::UTILITY))
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
+       t != targets.end(); ++t) {
+    if (((*t)->GetType() == cmState::EXECUTABLE) ||
+        ((*t)->GetType() == cmState::STATIC_LIBRARY) ||
+        ((*t)->GetType() == cmState::SHARED_LIBRARY) ||
+        ((*t)->GetType() == cmState::MODULE_LIBRARY) ||
+        ((*t)->GetType() == cmState::OBJECT_LIBRARY) ||
+        ((*t)->GetType() == cmState::UTILITY)) {
       emitted.insert((*t)->GetName());
 
       // for subdirs add a rule to build this specific target by name.
@@ -439,67 +395,59 @@ void cmLocalUnixMakefileGenerator3
       // Build the target for this pass.
       std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash();
       makefile2 += "Makefile2";
-      commands.push_back(this->GetRecursiveMakeCall
-                         (makefile2.c_str(),localName));
-      this->CreateCDCommand(commands,
-                            this->GetBinaryDirectory(),
-                            cmLocalGenerator::START_OUTPUT);
+      commands.push_back(
+        this->GetRecursiveMakeCall(makefile2.c_str(), localName));
+      this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                            cmOutputConverter::START_OUTPUT);
       this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
                           localName, depends, commands, true);
 
       // Add a target with the canonical name (no prefix, suffix or path).
-      if(localName != (*t)->GetName())
-        {
+      if (localName != (*t)->GetName()) {
         commands.clear();
         depends.push_back(localName);
         this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
                             (*t)->GetName(), depends, commands, true);
-        }
+      }
 
       // Add a fast rule to build the target
-      std::string makefileName =
-                         this->GetRelativeTargetDirectory(*t);
+      std::string makefileName = this->GetRelativeTargetDirectory(*t);
       makefileName += "/build.make";
       // make sure the makefile name is suitable for a makefile
-      std::string makeTargetName =
-        this->GetRelativeTargetDirectory(*t);
+      std::string makeTargetName = this->GetRelativeTargetDirectory(*t);
       makeTargetName += "/build";
       localName = (*t)->GetName();
       localName += "/fast";
       depends.clear();
       commands.clear();
-      commands.push_back(this->GetRecursiveMakeCall
-                         (makefileName.c_str(), makeTargetName));
-      this->CreateCDCommand(commands,
-                            this->GetBinaryDirectory(),
-                            cmLocalGenerator::START_OUTPUT);
+      commands.push_back(
+        this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+      this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                            cmOutputConverter::START_OUTPUT);
       this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
                           localName, depends, commands, true);
 
       // Add a local name for the rule to relink the target before
       // installation.
-      if((*t)->NeedRelinkBeforeInstall(this->ConfigName))
-        {
+      if ((*t)->NeedRelinkBeforeInstall(this->ConfigName)) {
         makeTargetName = this->GetRelativeTargetDirectory(*t);
         makeTargetName += "/preinstall";
         localName = (*t)->GetName();
         localName += "/preinstall";
         depends.clear();
         commands.clear();
-        commands.push_back(this->GetRecursiveMakeCall
-                           (makefile2.c_str(), makeTargetName));
-        this->CreateCDCommand(commands,
-                              this->GetBinaryDirectory(),
-                              cmLocalGenerator::START_OUTPUT);
+        commands.push_back(
+          this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName));
+        this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                              cmOutputConverter::START_OUTPUT);
         this->WriteMakeRule(ruleFileStream,
                             "Manual pre-install relink rule for target.",
                             localName, depends, commands, true);
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
 {
   std::string infoFileName = this->GetCurrentBinaryDirectory();
@@ -508,16 +456,16 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
 
   // Open the output file.
   cmGeneratedFileStream infoFileStream(infoFileName.c_str());
-  if(!infoFileStream)
-    {
+  if (!infoFileStream) {
     return;
-    }
+  }
 
   infoFileStream.SetCopyIfDifferent(true);
   // Write the do not edit header.
   this->WriteDisclaimer(infoFileStream);
 
   // Setup relative path conversion tops.
+  /* clang-format off */
   infoFileStream
     << "# Relative path conversion top directories.\n"
     << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \""
@@ -527,44 +475,38 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
     << this->StateSnapshot.GetDirectory().GetRelativePathTopBinary()
     << "\")\n"
     << "\n";
+  /* clang-format on */
 
   // Tell the dependency scanner to use unix paths if necessary.
-  if(cmSystemTools::GetForceUnixPaths())
-    {
+  if (cmSystemTools::GetForceUnixPaths()) {
+    /* clang-format off */
     infoFileStream
       << "# Force unix paths in dependencies.\n"
       << "set(CMAKE_FORCE_UNIX_PATHS 1)\n"
       << "\n";
-    }
+    /* clang-format on */
+  }
 
   // Store the include regular expressions for this directory.
-  infoFileStream
-    << "\n"
-    << "# The C and CXX include file regular expressions for "
-    << "this directory.\n";
-  infoFileStream
-    << "set(CMAKE_C_INCLUDE_REGEX_SCAN ";
+  infoFileStream << "\n"
+                 << "# The C and CXX include file regular expressions for "
+                 << "this directory.\n";
+  infoFileStream << "set(CMAKE_C_INCLUDE_REGEX_SCAN ";
   this->WriteCMakeArgument(infoFileStream,
                            this->Makefile->GetIncludeRegularExpression());
-  infoFileStream
-    << ")\n";
-  infoFileStream
-    << "set(CMAKE_C_INCLUDE_REGEX_COMPLAIN ";
+  infoFileStream << ")\n";
+  infoFileStream << "set(CMAKE_C_INCLUDE_REGEX_COMPLAIN ";
   this->WriteCMakeArgument(infoFileStream,
                            this->Makefile->GetComplainRegularExpression());
-  infoFileStream
-    << ")\n";
+  infoFileStream << ")\n";
   infoFileStream
     << "set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})\n";
-  infoFileStream
-    << "set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN "
-    "${CMAKE_C_INCLUDE_REGEX_COMPLAIN})\n";
+  infoFileStream << "set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN "
+                    "${CMAKE_C_INCLUDE_REGEX_COMPLAIN})\n";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3
-::ConvertToFullPath(const std::string& localPath)
+std::string cmLocalUnixMakefileGenerator3::ConvertToFullPath(
+  const std::string& localPath)
 {
   std::string dir = this->GetCurrentBinaryDirectory();
   dir += "/";
@@ -572,168 +514,143 @@ cmLocalUnixMakefileGenerator3
   return dir;
 }
 
-
-const std::string &cmLocalUnixMakefileGenerator3::GetHomeRelativeOutputPath()
+const std::string& cmLocalUnixMakefileGenerator3::GetHomeRelativeOutputPath()
 {
   return this->HomeRelativeOutputPath;
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::WriteMakeRule(std::ostream& os,
-                const char* comment,
-                const std::string& target,
-                const std::vector<std::string>& depends,
-                const std::vector<std::string>& commands,
-                bool symbolic,
-                bool in_help)
+void cmLocalUnixMakefileGenerator3::WriteMakeRule(
+  std::ostream& os, const char* comment, 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.empty())
-    {
+  if (target.empty()) {
     cmSystemTools::Error("No target for WriteMakeRule! called with comment: ",
                          comment);
     return;
-    }
+  }
 
   std::string replace;
 
   // Write the comment describing the rule in the makefile.
-  if(comment)
-    {
+  if (comment) {
     replace = comment;
     std::string::size_type lpos = 0;
     std::string::size_type rpos;
-    while((rpos = replace.find('\n', lpos)) != std::string::npos)
-      {
-      os << "# " << replace.substr(lpos, rpos-lpos) << "\n";
-      lpos = rpos+1;
-      }
-    os << "# " << replace.substr(lpos) << "\n";
+    while ((rpos = replace.find('\n', lpos)) != std::string::npos) {
+      os << "# " << replace.substr(lpos, rpos - lpos) << "\n";
+      lpos = rpos + 1;
     }
+    os << "# " << replace.substr(lpos) << "\n";
+  }
 
   // Construct the left hand side of the rule.
-  std::string tgt = this->Convert(target, HOME_OUTPUT, MAKERULE);
+  std::string tgt = this->Convert(target, cmOutputConverter::HOME_OUTPUT,
+                                  cmOutputConverter::MAKERULE);
 
   const char* space = "";
-  if(tgt.size() == 1)
-    {
+  if (tgt.size() == 1) {
     // Add a space before the ":" to avoid drive letter confusion on
     // Windows.
     space = " ";
-    }
+  }
 
   // Mark the rule as symbolic if requested.
-  if(symbolic)
-    {
-    if(const char* sym =
-       this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE"))
-      {
+  if (symbolic) {
+    if (const char* sym =
+          this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) {
       os << cmMakeSafe(tgt) << space << ": " << sym << "\n";
-      }
     }
+  }
 
   // Write the rule.
-  if(depends.empty())
-    {
+  if (depends.empty()) {
     // No dependencies.  The commands will always run.
     os << cmMakeSafe(tgt) << space << ":\n";
-    }
-  else
-    {
+  } else {
     // Split dependencies into multiple rule lines.  This allows for
     // very long dependency lists even on older make implementations.
-    for(std::vector<std::string>::const_iterator dep = depends.begin();
-        dep != depends.end(); ++dep)
-      {
+    for (std::vector<std::string>::const_iterator dep = depends.begin();
+         dep != depends.end(); ++dep) {
       replace = *dep;
-      replace = this->Convert(replace,HOME_OUTPUT,MAKERULE);
+      replace = this->Convert(replace, cmOutputConverter::HOME_OUTPUT,
+                              cmOutputConverter::MAKERULE);
       os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
-      }
     }
+  }
 
   // Write the list of commands.
   os << cmWrap("\t", commands, "", "\n") << "\n";
-  if(symbolic && !this->IsWatcomWMake())
-    {
+  if (symbolic && !this->IsWatcomWMake()) {
     os << ".PHONY : " << cmMakeSafe(tgt) << "\n";
-    }
+  }
   os << "\n";
   // Add the output to the local help if requested.
-  if(in_help)
-    {
+  if (in_help) {
     this->LocalHelp.push_back(target);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3
-::ConvertShellCommand(std::string const& cmd, RelativeRoot root)
+std::string cmLocalUnixMakefileGenerator3::ConvertShellCommand(
+  std::string const& cmd, cmOutputConverter::RelativeRoot root)
 {
-  if(this->IsWatcomWMake() &&
-     cmSystemTools::FileIsFullPath(cmd.c_str()) &&
-     cmd.find_first_of("( )") != cmd.npos)
-    {
+  if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd.c_str()) &&
+      cmd.find_first_of("( )") != cmd.npos) {
     // On Watcom WMake use the windows short path for the command
     // name.  This is needed to avoid funny quoting problems on
     // lines with shell redirection operators.
     std::string scmd;
-    if(cmSystemTools::GetShortPath(cmd, scmd))
-      {
-      return this->Convert(scmd, NONE, SHELL);
-      }
+    if (cmSystemTools::GetShortPath(cmd, scmd)) {
+      return this->Convert(scmd, cmOutputConverter::NONE,
+                           cmOutputConverter::SHELL);
     }
-  return this->Convert(cmd, root, SHELL);
+  }
+  return this->Convert(cmd, root, cmOutputConverter::SHELL);
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::WriteMakeVariables(std::ostream& makefileStream)
+void cmLocalUnixMakefileGenerator3::WriteMakeVariables(
+  std::ostream& makefileStream)
 {
   this->WriteDivider(makefileStream);
-  makefileStream
-    << "# Set environment variables for the build.\n"
-    << "\n";
+  makefileStream << "# Set environment variables for the build.\n"
+                 << "\n";
   cmGlobalUnixMakefileGenerator3* gg =
     static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-  if(gg->DefineWindowsNULL)
-    {
-    makefileStream
-      << "!IF \"$(OS)\" == \"Windows_NT\"\n"
-      << "NULL=\n"
-      << "!ELSE\n"
-      << "NULL=nul\n"
-      << "!ENDIF\n";
-    }
-  if(this->IsWindowsShell())
-    {
-     makefileStream
-       << "SHELL = cmd.exe\n"
-       << "\n";
-    }
-  else
-    {
+  if (gg->DefineWindowsNULL) {
+    makefileStream << "!IF \"$(OS)\" == \"Windows_NT\"\n"
+                   << "NULL=\n"
+                   << "!ELSE\n"
+                   << "NULL=nul\n"
+                   << "!ENDIF\n";
+  }
+  if (this->IsWindowsShell()) {
+    makefileStream << "SHELL = cmd.exe\n"
+                   << "\n";
+  } else {
 #if !defined(__VMS)
+    /* clang-format off */
       makefileStream
         << "# The shell in which to execute make rules.\n"
         << "SHELL = /bin/sh\n"
         << "\n";
+/* clang-format on */
 #endif
-    }
+  }
 
+  /* clang-format off */
   makefileStream
     << "# The CMake executable.\n"
     << "CMAKE_COMMAND = "
-    << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL)
+    << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(),
+                                 cmOutputConverter::FULL)
     << "\n"
     << "\n";
   makefileStream
     << "# The command to remove a file.\n"
     << "RM = "
-    << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL)
+    << this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(),
+                                 cmOutputConverter::FULL)
     << " -E remove -f\n"
     << "\n";
   makefileStream
@@ -743,26 +660,28 @@ cmLocalUnixMakefileGenerator3
   makefileStream
     << "# The top-level source directory on which CMake was run.\n"
     << "CMAKE_SOURCE_DIR = "
-    << this->Convert(this->GetSourceDirectory(), FULL, SHELL)
+    << this->Convert(this->GetSourceDirectory(),
+                     cmOutputConverter::FULL,
+                     cmOutputConverter::SHELL)
     << "\n"
     << "\n";
   makefileStream
     << "# The top-level build directory on which CMake was run.\n"
     << "CMAKE_BINARY_DIR = "
-    << this->Convert(this->GetBinaryDirectory(), FULL, SHELL)
+    << this->Convert(this->GetBinaryDirectory(),
+                     cmOutputConverter::FULL,
+                     cmOutputConverter::SHELL)
     << "\n"
     << "\n";
+  /* clang-format on */
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::WriteSpecialTargetsTop(std::ostream& makefileStream)
+void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop(
+  std::ostream& makefileStream)
 {
   this->WriteDivider(makefileStream);
-  makefileStream
-    << "# Special targets provided by cmake.\n"
-    << "\n";
+  makefileStream << "# Special targets provided by cmake.\n"
+                 << "\n";
 
   std::vector<std::string> no_commands;
   std::vector<std::string> no_depends;
@@ -770,52 +689,52 @@ cmLocalUnixMakefileGenerator3
   // Special target to cleanup operation of make tool.
   // This should be the first target except for the default_target in
   // the interface Makefile.
-  this->WriteMakeRule(
-    makefileStream, "Disable implicit rules so canonical targets will work.",
-    ".SUFFIXES", no_depends, no_commands, false);
+  this->WriteMakeRule(makefileStream,
+                      "Disable implicit rules so canonical targets will work.",
+                      ".SUFFIXES", no_depends, no_commands, false);
 
-  if(!this->IsNMake()
-      && !this->IsWatcomWMake() && !this->BorlandMakeCurlyHack)
-    {
+  if (!this->IsNMake() && !this->IsWatcomWMake() &&
+      !this->BorlandMakeCurlyHack) {
     // turn off RCS and SCCS automatic stuff from gmake
     makefileStream
       << "# Remove some rules from gmake that .SUFFIXES does not remove.\n"
       << "SUFFIXES =\n\n";
-    }
+  }
   // Add a fake suffix to keep HP happy.  Must be max 32 chars for SGI make.
   std::vector<std::string> depends;
   depends.push_back(".hpux_make_needs_suffix_list");
-  this->WriteMakeRule(makefileStream, 0,
-                      ".SUFFIXES", depends, no_commands, false);
-  if(this->IsWatcomWMake())
-    {
+  this->WriteMakeRule(makefileStream, 0, ".SUFFIXES", depends, no_commands,
+                      false);
+  if (this->IsWatcomWMake()) {
     // 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).
+    /* clang-format off */
     makefileStream <<
       "\n"
       ".ERASE\n"
       "\n"
       ;
-    }
-  if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
-    {
+    /* clang-format on */
+  }
+  if (this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) {
+    /* clang-format off */
     makefileStream
       << "# Produce verbose output by default.\n"
       << "VERBOSE = 1\n"
       << "\n";
-    }
-  if(this->IsWatcomWMake())
-    {
+    /* clang-format on */
+  }
+  if (this->IsWatcomWMake()) {
+    /* clang-format off */
     makefileStream <<
       "!ifndef VERBOSE\n"
       ".SILENT\n"
       "!endif\n"
       "\n"
       ;
-    }
-  else
-    {
+    /* clang-format on */
+  } 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
@@ -824,91 +743,74 @@ cmLocalUnixMakefileGenerator3
     // the user.
     this->WriteMakeRule(makefileStream,
                         "Suppress display of executed commands.",
-                        "$(VERBOSE).SILENT",
-                        no_depends,
-                        no_commands, false);
-    }
+                        "$(VERBOSE).SILENT", no_depends, no_commands, false);
+  }
 
   // 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())
-    {
+  if (!hack.empty()) {
     no_depends.push_back(hack);
-    }
+  }
   std::string hack_cmd = gg->GetEmptyRuleHackCommand();
-  if(!hack_cmd.empty())
-    {
+  if (!hack_cmd.empty()) {
     no_commands.push_back(hack_cmd);
-    }
+  }
 
   // Special symbolic target that never exists to force dependers to
   // run their rules.
-  this->WriteMakeRule
-    (makefileStream,
-     "A target that is always out of date.",
-     "cmake_force", no_depends, no_commands, true);
+  this->WriteMakeRule(makefileStream, "A target that is always out of date.",
+                      "cmake_force", no_depends, no_commands, true);
 
   // Variables for reference by other rules.
   this->WriteMakeVariables(makefileStream);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3
-::WriteSpecialTargetsBottom(std::ostream& makefileStream)
+void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom(
+  std::ostream& makefileStream)
 {
   this->WriteDivider(makefileStream);
-  makefileStream
-    << "# Special targets to cleanup operation of make.\n"
-    << "\n";
+  makefileStream << "# Special targets to cleanup operation of make.\n"
+                 << "\n";
 
   // Write special "cmake_check_build_system" target to run cmake with
   // the --check-build-system flag.
   {
-  // Build command to run CMake to check if anything needs regenerating.
-  std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash();
-  cmakefileName += "Makefile.cmake";
-  std::string runRule =
-    "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
-  runRule += " --check-build-system ";
-  runRule += this->Convert(cmakefileName,NONE,SHELL);
-  runRule += " 0";
+    // Build command to run CMake to check if anything needs regenerating.
+    std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash();
+    cmakefileName += "Makefile.cmake";
+    std::string runRule =
+      "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
+    runRule += " --check-build-system ";
+    runRule += this->Convert(cmakefileName, cmOutputConverter::NONE,
+                             cmOutputConverter::SHELL);
+    runRule += " 0";
 
-  std::vector<std::string> no_depends;
-  std::vector<std::string> commands;
-  commands.push_back(runRule);
-  if(!this->IsRootMakefile())
-    {
-    this->CreateCDCommand(commands,
-                          this->GetBinaryDirectory(),
-                          cmLocalGenerator::START_OUTPUT);
-    }
-  this->WriteMakeRule(makefileStream,
-                      "Special rule to run CMake to check the build system "
+    std::vector<std::string> no_depends;
+    std::vector<std::string> commands;
+    commands.push_back(runRule);
+    if (!this->IsRootMakefile()) {
+      this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                            cmOutputConverter::START_OUTPUT);
+    }
+    this->WriteMakeRule(
+      makefileStream, "Special rule to run CMake to check the build system "
                       "integrity.\n"
                       "No rule that depends on this can have "
                       "commands that come from listfiles\n"
                       "because they might be regenerated.",
-                      "cmake_check_build_system",
-                      no_depends,
-                      commands, true);
+      "cmake_check_build_system", no_depends, commands, true);
   }
 }
 
-
-
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::WriteConvenienceRule(std::ostream& ruleFileStream,
-                       const std::string& realTarget,
-                       const std::string& helpTarget)
+void cmLocalUnixMakefileGenerator3::WriteConvenienceRule(
+  std::ostream& ruleFileStream, const std::string& realTarget,
+  const std::string& helpTarget)
 {
   // A rule is only needed if the names are different.
-  if(realTarget != helpTarget)
-    {
+  if (realTarget != helpTarget) {
     // The helper target depends on the real target.
     std::vector<std::string> depends;
     depends.push_back(realTarget);
@@ -919,249 +821,194 @@ cmLocalUnixMakefileGenerator3
     // Write the rule.
     this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
                         helpTarget, depends, no_commands, true);
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3
-::GetRelativeTargetDirectory(cmGeneratorTarget* target)
+std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(
+  cmGeneratorTarget* target)
 {
   std::string dir = this->HomeRelativeOutputPath;
   dir += this->GetTargetDirectory(target);
-  return this->Convert(dir,NONE,UNCHANGED);
+  return this->Convert(dir, cmOutputConverter::NONE,
+                       cmOutputConverter::UNCHANGED);
 }
 
-
-
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
                                                 const std::string& newFlags)
 {
-  if(this->IsWatcomWMake() && !newFlags.empty())
-    {
+  if (this->IsWatcomWMake() && !newFlags.empty()) {
     std::string newf = newFlags;
-    if(newf.find("\\\"") != newf.npos)
-      {
+    if (newf.find("\\\"") != newf.npos) {
       cmSystemTools::ReplaceString(newf, "\\\"", "\"");
       this->cmLocalGenerator::AppendFlags(flags, newf);
       return;
-      }
     }
+  }
   this->cmLocalGenerator::AppendFlags(flags, newFlags);
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
                                                 const char* newFlags)
 {
   this->cmLocalGenerator::AppendFlags(flags, newFlags);
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendRuleDepend(std::vector<std::string>& depends,
-                   const char* ruleFileName)
+void cmLocalUnixMakefileGenerator3::AppendRuleDepend(
+  std::vector<std::string>& depends, const char* ruleFileName)
 {
   // Add a dependency on the rule file itself unless an option to skip
   // it is specifically enabled by the user or project.
   const char* nodep =
     this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY");
-  if(!nodep || cmSystemTools::IsOff(nodep))
-    {
+  if (!nodep || cmSystemTools::IsOff(nodep)) {
     depends.push_back(ruleFileName);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendRuleDepends(std::vector<std::string>& depends,
-                    std::vector<std::string> const& ruleFiles)
+void cmLocalUnixMakefileGenerator3::AppendRuleDepends(
+  std::vector<std::string>& depends, std::vector<std::string> const& ruleFiles)
 {
   // Add a dependency on the rule file itself unless an option to skip
   // it is specifically enabled by the user or project.
-  if(!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY"))
-    {
+  if (!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY")) {
     depends.insert(depends.end(), ruleFiles.begin(), ruleFiles.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendCustomDepends(std::vector<std::string>& depends,
-                      const std::vector<cmCustomCommand>& ccs)
+void cmLocalUnixMakefileGenerator3::AppendCustomDepends(
+  std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs)
 {
-  for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
-      i != ccs.end(); ++i)
-    {
+  for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
+       i != ccs.end(); ++i) {
     cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
     this->AppendCustomDepend(depends, ccg);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendCustomDepend(std::vector<std::string>& depends,
-                     cmCustomCommandGenerator const& ccg)
+void cmLocalUnixMakefileGenerator3::AppendCustomDepend(
+  std::vector<std::string>& depends, cmCustomCommandGenerator const& ccg)
 {
-  for(std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
-      d != ccg.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, this->ConfigName,
-                               dep))
-      {
+    if (this->GetRealDependency(*d, this->ConfigName, dep)) {
       depends.push_back(dep);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendCustomCommands(std::vector<std::string>& commands,
-                       const std::vector<cmCustomCommand>& ccs,
-                       cmGeneratorTarget* target,
-                       cmLocalGenerator::RelativeRoot relative)
+void cmLocalUnixMakefileGenerator3::AppendCustomCommands(
+  std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs,
+  cmGeneratorTarget* target, cmOutputConverter::RelativeRoot relative)
 {
-  for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
-      i != ccs.end(); ++i)
-    {
+  for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
+       i != ccs.end(); ++i) {
     cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
     this->AppendCustomCommand(commands, ccg, target, true, relative);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendCustomCommand(std::vector<std::string>& commands,
-                      cmCustomCommandGenerator const& ccg,
-                      cmGeneratorTarget* target,
-                      bool echo_comment,
-                      cmLocalGenerator::RelativeRoot relative,
-                      std::ostream* content)
+void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
+  std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg,
+  cmGeneratorTarget* target, bool echo_comment,
+  cmOutputConverter::RelativeRoot relative, std::ostream* content)
 {
   // Optionally create a command to display the custom command's
   // comment text.  This is used for pre-build, pre-link, and
   // post-build command comments.  Custom build step commands have
   // their comments generated elsewhere.
-  if(echo_comment)
-    {
+  if (echo_comment) {
     const char* comment = ccg.GetComment();
-    if(comment && *comment)
-      {
+    if (comment && *comment) {
       this->AppendEcho(commands, comment,
                        cmLocalUnixMakefileGenerator3::EchoGenerate);
-      }
     }
+  }
 
   // if the command specified a working directory use it.
-  std::string dir  = this->GetCurrentBinaryDirectory();
+  std::string dir = this->GetCurrentBinaryDirectory();
   std::string workingDir = ccg.GetWorkingDirectory();
-  if(!workingDir.empty())
-    {
+  if (!workingDir.empty()) {
     dir = workingDir;
-    }
-  if(content)
-    {
+  }
+  if (content) {
     *content << dir;
-    }
+  }
 
   // Add each command line to the set of commands.
   std::vector<std::string> commands1;
-  for(unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c)
-    {
+  for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
     // Build the command line in a single string.
     std::string cmd = ccg.GetCommand(c);
-    if (!cmd.empty())
-      {
+    if (!cmd.empty()) {
       // Use "call " before any invocations of .bat or .cmd files
       // invoked as custom commands in the WindowsShell.
       //
       bool useCall = false;
 
-      if (this->IsWindowsShell())
-        {
+      if (this->IsWindowsShell()) {
         std::string suffix;
-        if (cmd.size() > 4)
-          {
-          suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size()-4));
-          if (suffix == ".bat" || suffix == ".cmd")
-            {
+        if (cmd.size() > 4) {
+          suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
+          if (suffix == ".bat" || suffix == ".cmd") {
             useCall = true;
-            }
           }
         }
+      }
 
       cmSystemTools::ReplaceString(cmd, "/./", "/");
       // 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.empty())
-        {
-        cmd = this->Convert(cmd,START_OUTPUT);
-        }
-      bool has_slash = cmd.find("/") != cmd.npos;
-      if(had_slash && !has_slash)
-        {
+      bool had_slash = cmd.find('/') != cmd.npos;
+      if (workingDir.empty()) {
+        cmd = this->Convert(cmd, cmOutputConverter::START_OUTPUT);
+      }
+      bool has_slash = cmd.find('/') != cmd.npos;
+      if (had_slash && !has_slash) {
         // This command was specified as a path to a file in the
         // current directory.  Add a leading "./" so it can run
         // without the current directory being in the search path.
         cmd = "./" + cmd;
-        }
-      std::string launcher =
-        this->MakeLauncher(ccg, target,
-                           workingDir.empty()? START_OUTPUT : NONE);
-      cmd = launcher + this->ConvertShellCommand(cmd, NONE);
+      }
+      std::string launcher = this->MakeLauncher(
+        ccg, target, workingDir.empty() ? cmOutputConverter::START_OUTPUT
+                                        : cmOutputConverter::NONE);
+      cmd = launcher + this->ConvertShellCommand(cmd, cmOutputConverter::NONE);
 
       ccg.AppendArguments(c, cmd);
-      if(content)
-        {
+      if (content) {
         // Rule content does not include the launcher.
-        *content << (cmd.c_str()+launcher.size());
-        }
-      if(this->BorlandMakeCurlyHack)
-        {
+        *content << (cmd.c_str() + launcher.size());
+      }
+      if (this->BorlandMakeCurlyHack) {
         // Borland Make has a very strange bug.  If the first curly
         // brace anywhere in the command string is a left curly, it
         // must be written {{} instead of just {.  Otherwise some
         // curly braces are removed.  The hack can be skipped if the
         // first curly brace is the last character.
-        std::string::size_type lcurly = cmd.find("{");
-        if(lcurly != cmd.npos && lcurly < (cmd.size()-1))
-          {
-          std::string::size_type rcurly = cmd.find("}");
-          if(rcurly == cmd.npos || rcurly > lcurly)
-            {
+        std::string::size_type lcurly = cmd.find('{');
+        if (lcurly != cmd.npos && lcurly < (cmd.size() - 1)) {
+          std::string::size_type rcurly = cmd.find('}');
+          if (rcurly == cmd.npos || rcurly > lcurly) {
             // The first curly is a left curly.  Use the hack.
             std::string hack_cmd = cmd.substr(0, lcurly);
             hack_cmd += "{{}";
-            hack_cmd += cmd.substr(lcurly+1);
+            hack_cmd += cmd.substr(lcurly + 1);
             cmd = hack_cmd;
-            }
           }
         }
-      if (launcher.empty())
-        {
-        if (useCall)
-          {
+      }
+      if (launcher.empty()) {
+        if (useCall) {
           cmd = "call " + cmd;
-          }
-        else if (this->IsNMake() && cmd[0]=='"')
-          {
+        } else if (this->IsNMake() && cmd[0] == '"') {
           cmd = "echo >nul && " + cmd;
-          }
         }
-      commands1.push_back(cmd);
       }
+      commands1.push_back(cmd);
     }
+  }
 
   // Setup the proper working directory for the commands.
   this->CreateCDCommand(commands1, dir.c_str(), relative);
@@ -1170,19 +1017,16 @@ cmLocalUnixMakefileGenerator3
   commands.insert(commands.end(), commands1.begin(), commands1.end());
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3::MakeLauncher(
-  cmCustomCommandGenerator const& ccg,
-  cmGeneratorTarget* target, RelativeRoot relative)
+std::string cmLocalUnixMakefileGenerator3::MakeLauncher(
+  cmCustomCommandGenerator const& ccg, cmGeneratorTarget* target,
+  cmOutputConverter::RelativeRoot relative)
 {
   // Short-circuit if there is no launcher.
   const char* prop = "RULE_LAUNCH_CUSTOM";
   const char* val = this->GetRuleLauncher(target, prop);
-  if(!(val && *val))
-    {
+  if (!(val && *val)) {
     return "";
-    }
+  }
 
   // Expand rules in the empty string.  It may insert the launcher and
   // perform replacements.
@@ -1191,90 +1035,80 @@ cmLocalUnixMakefileGenerator3::MakeLauncher(
   vars.CMTarget = target;
   std::string output;
   const std::vector<std::string>& outputs = ccg.GetOutputs();
-  if(!outputs.empty())
-    {
-    output = this->Convert(outputs[0], relative, SHELL);
-    }
+  if (!outputs.empty()) {
+    output = this->Convert(outputs[0], relative, cmOutputConverter::SHELL);
+  }
   vars.Output = output.c_str();
 
   std::string launcher;
   this->ExpandRuleVariables(launcher, vars);
-  if(!launcher.empty())
-    {
+  if (!launcher.empty()) {
     launcher += " ";
-    }
+  }
   return launcher;
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::AppendCleanCommand(std::vector<std::string>& commands,
-                     const std::vector<std::string>& files,
-                     cmGeneratorTarget* target, const char* filename)
+void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
+  std::vector<std::string>& commands, const std::vector<std::string>& files,
+  cmGeneratorTarget* target, const char* filename)
 {
   std::string cleanfile = this->GetCurrentBinaryDirectory();
   cleanfile += "/";
   cleanfile += this->GetTargetDirectory(target);
   cleanfile += "/cmake_clean";
-  if(filename)
-    {
+  if (filename) {
     cleanfile += "_";
     cleanfile += filename;
-    }
+  }
   cleanfile += ".cmake";
-  std::string cleanfilePath = this->Convert(cleanfile, FULL);
+  std::string cleanfilePath =
+    this->Convert(cleanfile, cmOutputConverter::FULL);
   cmsys::ofstream fout(cleanfilePath.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     cmSystemTools::Error("Could not create ", cleanfilePath.c_str());
-    }
-  if(!files.empty())
-    {
+  }
+  if (!files.empty()) {
     fout << "file(REMOVE_RECURSE\n";
-    for(std::vector<std::string>::const_iterator f = files.begin();
-        f != files.end(); ++f)
-      {
-      std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED);
+    for (std::vector<std::string>::const_iterator f = files.begin();
+         f != files.end(); ++f) {
+      std::string fc = this->Convert(*f, cmOutputConverter::START_OUTPUT,
+                                     cmOutputConverter::UNCHANGED);
       fout << "  " << cmOutputConverter::EscapeForCMake(fc) << "\n";
-      }
-    fout << ")\n";
     }
+    fout << ")\n";
+  }
   std::string remove = "$(CMAKE_COMMAND) -P ";
-  remove += this->Convert(cleanfile, START_OUTPUT, SHELL);
+  remove += this->Convert(cleanfile, cmOutputConverter::START_OUTPUT,
+                          cmOutputConverter::SHELL);
   commands.push_back(remove);
 
   // For the main clean rule add per-language cleaning.
-  if(!filename)
-    {
+  if (!filename) {
     // Get the set of source languages in the target.
     std::set<std::string> languages;
-    target->GetLanguages(languages,
-                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+    target->GetLanguages(
+      languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+    /* clang-format off */
     fout << "\n"
          << "# Per-language clean rules from dependency scanning.\n"
          << "foreach(lang " << cmJoin(languages, " ") << ")\n"
          << "  include(" << this->GetTargetDirectory(target)
          << "/cmake_clean_${lang}.cmake OPTIONAL)\n"
          << "endforeach()\n";
-    }
+    /* clang-format on */
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
-                                          std::string const& text,
-                                          EchoColor color,
-                                          EchoProgress const* progress)
+void cmLocalUnixMakefileGenerator3::AppendEcho(
+  std::vector<std::string>& commands, std::string const& text, EchoColor color,
+  EchoProgress const* progress)
 {
   // Choose the color for the text.
   std::string color_name;
-  if(this->GlobalGenerator->GetToolSupportsColor() && this->ColorMakefile)
-    {
+  if (this->GlobalGenerator->GetToolSupportsColor() && this->ColorMakefile) {
     // See cmake::ExecuteEchoColor in cmake.cxx for these options.
     // This color set is readable on both black and white backgrounds.
-    switch(color)
-      {
+    switch (color) {
       case EchoNormal:
         break;
       case EchoDepend:
@@ -1292,47 +1126,39 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
       case EchoGlobal:
         color_name = "--cyan ";
         break;
-      }
     }
+  }
 
   // Echo one line at a time.
   std::string line;
   line.reserve(200);
-  for(const char* c = text.c_str();; ++c)
-    {
-    if(*c == '\n' || *c == '\0')
-      {
+  for (const char* c = text.c_str();; ++c) {
+    if (*c == '\n' || *c == '\0') {
       // Avoid writing a blank last line on end-of-string.
-      if(*c != '\0' || !line.empty())
-        {
+      if (*c != '\0' || !line.empty()) {
         // Add a command to echo this line.
         std::string cmd;
-        if(color_name.empty() && !progress)
-          {
+        if (color_name.empty() && !progress) {
           // Use the native echo command.
           cmd = "@echo ";
           cmd += this->EscapeForShell(line, false, true);
-          }
-        else
-          {
+        } else {
           // Use cmake to echo the text in color.
           cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) ";
           cmd += color_name;
-          if (progress)
-            {
+          if (progress) {
             cmd += "--progress-dir=";
-            cmd += this->Convert(progress->Dir,
-                                 cmLocalGenerator::FULL,
-                                 cmLocalGenerator::SHELL);
+            cmd += this->Convert(progress->Dir, cmOutputConverter::FULL,
+                                 cmOutputConverter::SHELL);
             cmd += " ";
             cmd += "--progress-num=";
             cmd += progress->Arg;
             cmd += " ";
-            }
-          cmd += this->EscapeForShell(line);
           }
-        commands.push_back(cmd);
+          cmd += this->EscapeForShell(line);
         }
+        commands.push_back(cmd);
+      }
 
       // Reset the line to emtpy.
       line = "";
@@ -1341,122 +1167,105 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
       progress = 0;
 
       // Terminate on end-of-string.
-      if(*c == '\0')
-        {
+      if (*c == '\0') {
         return;
-        }
       }
-    else if(*c != '\r')
-      {
+    } else if (*c != '\r') {
       // Append this character to the current line.
       line += *c;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3
-::CreateMakeVariable(const std::string& sin, const std::string& s2in)
+std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
+  const std::string& sin, const std::string& s2)
 {
   std::string s = sin;
-  std::string s2 = s2in;
   std::string unmodified = s;
   unmodified += s2;
   // if there is no restriction on the length of make variables
   // and there are no "." characters in the string, then return the
   // unmodified combination.
-  if((!this->MakefileVariableSize && unmodified.find('.') == s.npos)
-     && (!this->MakefileVariableSize && unmodified.find('+') == s.npos)
-     && (!this->MakefileVariableSize && unmodified.find('-') == s.npos))
-    {
+  if ((!this->MakefileVariableSize && unmodified.find('.') == s.npos) &&
+      (!this->MakefileVariableSize && unmodified.find('+') == s.npos) &&
+      (!this->MakefileVariableSize && unmodified.find('-') == s.npos)) {
     return unmodified;
-    }
+  }
 
   // see if the variable has been defined before and return
   // the modified version of the variable
   std::map<std::string, std::string>::iterator i =
     this->MakeVariableMap.find(unmodified);
-  if(i != this->MakeVariableMap.end())
-    {
+  if (i != this->MakeVariableMap.end()) {
     return i->second;
-    }
+  }
   // start with the unmodified variable
   std::string ret = unmodified;
   // if this there is no value for this->MakefileVariableSize then
   // the string must have bad characters in it
-  if(!this->MakefileVariableSize)
-    {
-    cmSystemTools::ReplaceString(ret, ".", "_");
+  if (!this->MakefileVariableSize) {
+    std::replace(ret.begin(), ret.end(), '.', '_');
     cmSystemTools::ReplaceString(ret, "-", "__");
     cmSystemTools::ReplaceString(ret, "+", "___");
     int ni = 0;
     char buffer[5];
     // make sure the _ version is not already used, if
     // it is used then add number to the end of the variable
-    while(this->ShortMakeVariableMap.count(ret) && ni < 1000)
-      {
+    while (this->ShortMakeVariableMap.count(ret) && ni < 1000) {
       ++ni;
       sprintf(buffer, "%04d", ni);
       ret = unmodified + buffer;
-      }
+    }
     this->ShortMakeVariableMap[ret] = "1";
     this->MakeVariableMap[unmodified] = ret;
     return ret;
-    }
+  }
 
   // if the string is greater than 32 chars it is an invalid variable name
   // for borland make
-  if(static_cast<int>(ret.size()) > this->MakefileVariableSize)
-    {
+  if (static_cast<int>(ret.size()) > this->MakefileVariableSize) {
     int keep = this->MakefileVariableSize - 8;
     int size = keep + 3;
     std::string str1 = s;
     std::string str2 = s2;
     // we must shorten the combined string by 4 characters
     // keep no more than 24 characters from the second string
-    if(static_cast<int>(str2.size()) > keep)
-      {
+    if (static_cast<int>(str2.size()) > keep) {
       str2 = str2.substr(0, keep);
-      }
-    if(static_cast<int>(str1.size()) + static_cast<int>(str2.size()) > size)
-      {
+    }
+    if (static_cast<int>(str1.size()) + static_cast<int>(str2.size()) > size) {
       str1 = str1.substr(0, size - str2.size());
-      }
+    }
     char buffer[5];
     int ni = 0;
     sprintf(buffer, "%04d", ni);
     ret = str1 + str2 + buffer;
-    while(this->ShortMakeVariableMap.count(ret) && ni < 1000)
-      {
+    while (this->ShortMakeVariableMap.count(ret) && ni < 1000) {
       ++ni;
       sprintf(buffer, "%04d", ni);
       ret = str1 + str2 + buffer;
-      }
-    if(ni == 1000)
-      {
+    }
+    if (ni == 1000) {
       cmSystemTools::Error("Borland makefile variable length too long");
       return unmodified;
-      }
+    }
     // once an unused variable is found
     this->ShortMakeVariableMap[ret] = "1";
-    }
+  }
   // always make an entry into the unmodified to variable map
   this->MakeVariableMap[unmodified] = ret;
   return ret;
 }
 
-//----------------------------------------------------------------------------
 bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
                                                        bool verbose,
                                                        bool color)
 {
   // read in the target info file
-  if(!this->Makefile->ReadListFile(tgtInfo) ||
-     cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (!this->Makefile->ReadListFile(tgtInfo) ||
+      cmSystemTools::GetErrorOccuredFlag()) {
     cmSystemTools::Error("Target DependInfo.cmake file not found");
-    }
+  }
 
   // Check if any multiple output pairs have a missing file.
   this->CheckMultipleOutputs(verbose);
@@ -1473,19 +1282,16 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
   cmFileTimeComparison* ftc =
     this->GlobalGenerator->GetCMakeInstance()->GetFileComparison();
   {
-  int result;
-  if(!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) ||
-     result < 0)
-    {
-    if(verbose)
-      {
-      std::ostringstream msg;
-      msg << "Dependee \"" << tgtInfo
-          << "\" is newer than depender \""
-          << internalDependFile << "\"." << std::endl;
-      cmSystemTools::Stdout(msg.str().c_str());
+    int result;
+    if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) ||
+        result < 0) {
+      if (verbose) {
+        std::ostringstream msg;
+        msg << "Dependee \"" << tgtInfo << "\" is newer than depender \""
+            << internalDependFile << "\"." << std::endl;
+        cmSystemTools::Stdout(msg.str().c_str());
       }
-    needRescanDependInfo = true;
+      needRescanDependInfo = true;
     }
   }
 
@@ -1496,19 +1302,17 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
   dirInfoFile += cmake::GetCMakeFilesDirectory();
   dirInfoFile += "/CMakeDirectoryInformation.cmake";
   {
-  int result;
-  if(!ftc->FileTimeCompare(internalDependFile.c_str(),
-                           dirInfoFile.c_str(), &result) || result < 0)
-    {
-    if(verbose)
-      {
-      std::ostringstream msg;
-      msg << "Dependee \"" << dirInfoFile
-          << "\" is newer than depender \""
-          << internalDependFile << "\"." << std::endl;
-      cmSystemTools::Stdout(msg.str().c_str());
+    int result;
+    if (!ftc->FileTimeCompare(internalDependFile.c_str(), dirInfoFile.c_str(),
+                              &result) ||
+        result < 0) {
+      if (verbose) {
+        std::ostringstream msg;
+        msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \""
+            << internalDependFile << "\"." << std::endl;
+        cmSystemTools::Stdout(msg.str().c_str());
       }
-    needRescanDirInfo = true;
+      needRescanDirInfo = true;
     }
   }
 
@@ -1518,8 +1322,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
   // not be considered.
   std::map<std::string, cmDepends::DependencyVector> validDependencies;
   bool needRescanDependencies = false;
-  if (needRescanDirInfo == false)
-    {
+  if (needRescanDirInfo == false) {
     cmDependsC checker;
     checker.SetVerbose(verbose);
     checker.SetFileComparison(ftc);
@@ -1533,35 +1336,30 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
     // dependency vector. This means that in the normal case, when only
     // few or one file have been edited, then also only this one file is
     // actually scanned again, instead of all files for this target.
-    needRescanDependencies = !checker.Check(dependFile.c_str(),
-                                            internalDependFile.c_str(),
-                                            validDependencies);
-    }
+    needRescanDependencies = !checker.Check(
+      dependFile.c_str(), internalDependFile.c_str(), validDependencies);
+  }
 
-  if(needRescanDependInfo || needRescanDirInfo || needRescanDependencies)
-    {
+  if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
     // The dependencies must be regenerated.
     std::string targetName = cmSystemTools::GetFilenameName(dir);
-    targetName = targetName.substr(0, targetName.length()-4);
+    targetName = targetName.substr(0, targetName.length() - 4);
     std::string message = "Scanning dependencies of target ";
     message += targetName;
-    cmSystemTools::MakefileColorEcho(
-      cmsysTerminal_Color_ForegroundMagenta |
-      cmsysTerminal_Color_ForegroundBold,
-      message.c_str(), true, color);
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundMagenta |
+                                       cmsysTerminal_Color_ForegroundBold,
+                                     message.c_str(), true, color);
 
     return this->ScanDependencies(dir.c_str(), validDependencies);
-    }
+  }
 
   // The dependencies are already up-to-date.
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmLocalUnixMakefileGenerator3
-::ScanDependencies(const char* targetDir,
-                 std::map<std::string, cmDepends::DependencyVector>& validDeps)
+bool cmLocalUnixMakefileGenerator3::ScanDependencies(
+  const char* targetDir,
+  std::map<std::string, cmDepends::DependencyVector>& validDeps)
 {
   // Read the directory information file.
   cmMakefile* mf = this->Makefile;
@@ -1569,42 +1367,34 @@ cmLocalUnixMakefileGenerator3
   std::string dirInfoFile = this->GetCurrentBinaryDirectory();
   dirInfoFile += cmake::GetCMakeFilesDirectory();
   dirInfoFile += "/CMakeDirectoryInformation.cmake";
-  if(mf->ReadListFile(dirInfoFile.c_str()) &&
-     !cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (mf->ReadListFile(dirInfoFile.c_str()) &&
+      !cmSystemTools::GetErrorOccuredFlag()) {
     haveDirectoryInfo = true;
-    }
+  }
 
   // Lookup useful directory information.
-  if(haveDirectoryInfo)
-    {
+  if (haveDirectoryInfo) {
     // Test whether we need to force Unix paths.
-    if(const char* force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS"))
-      {
-      if(!cmSystemTools::IsOff(force))
-        {
+    if (const char* force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS")) {
+      if (!cmSystemTools::IsOff(force)) {
         cmSystemTools::SetForceUnixPaths(true);
-        }
       }
+    }
 
     // Setup relative path top directories.
-    if(const char* relativePathTopSource =
-       mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE"))
-      {
-      this->StateSnapshot.GetDirectory()
-            .SetRelativePathTopSource(relativePathTopSource);
-      }
-    if(const char* relativePathTopBinary =
-       mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY"))
-      {
-      this->StateSnapshot.GetDirectory()
-            .SetRelativePathTopBinary(relativePathTopBinary);
-      }
+    if (const char* relativePathTopSource =
+          mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) {
+      this->StateSnapshot.GetDirectory().SetRelativePathTopSource(
+        relativePathTopSource);
     }
-  else
-    {
-    cmSystemTools::Error("Directory Information file not found");
+    if (const char* relativePathTopBinary =
+          mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) {
+      this->StateSnapshot.GetDirectory().SetRelativePathTopBinary(
+        relativePathTopBinary);
     }
+  } else {
+    cmSystemTools::Error("Directory Information file not found");
+  }
 
   // create the file stream for the depends file
   std::string dir = targetDir;
@@ -1615,141 +1405,125 @@ cmLocalUnixMakefileGenerator3
   ruleFileNameFull += "/depend.make";
   cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
   ruleFileStream.SetCopyIfDifferent(true);
-  if(!ruleFileStream)
-    {
+  if (!ruleFileStream) {
     return false;
-    }
+  }
 
   // Open the cmake dependency tracking file.  This should not be
   // copy-if-different because dependencies are re-scanned when it is
   // older than the DependInfo.cmake.
   std::string internalRuleFileNameFull = dir;
   internalRuleFileNameFull += "/depend.internal";
-  cmGeneratedFileStream
-    internalRuleFileStream(internalRuleFileNameFull.c_str());
-  if(!internalRuleFileStream)
-    {
+  cmGeneratedFileStream internalRuleFileStream(
+    internalRuleFileNameFull.c_str());
+  if (!internalRuleFileStream) {
     return false;
-    }
+  }
 
   this->WriteDisclaimer(ruleFileStream);
   this->WriteDisclaimer(internalRuleFileStream);
 
   // for each language we need to scan, scan it
-  const char *langStr = mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
+  const char* langStr = mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
   std::vector<std::string> langs;
   cmSystemTools::ExpandListArgument(langStr, langs);
-  for (std::vector<std::string>::iterator li =
-         langs.begin(); li != langs.end(); ++li)
-    {
+  for (std::vector<std::string>::iterator li = langs.begin();
+       li != langs.end(); ++li) {
     // construct the checker
     std::string lang = *li;
 
     // Create the scanner for this language
-    cmDepends *scanner = 0;
-    if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM")
-      {
+    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, &validDeps);
-      }
+    }
 #ifdef CMAKE_BUILD_WITH_CMAKE
-    else if(lang == "Fortran")
-      {
+    else if (lang == "Fortran") {
       scanner = new cmDependsFortran(this);
-      }
-    else if(lang == "Java")
-      {
+    } else if (lang == "Java") {
       scanner = new cmDependsJava();
-      }
+    }
 #endif
 
-    if (scanner)
-      {
+    if (scanner) {
       scanner->SetLocalGenerator(this);
-      scanner->SetFileComparison
-        (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
+      scanner->SetFileComparison(
+        this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
       scanner->SetLanguage(lang);
       scanner->SetTargetDirectory(dir.c_str());
       scanner->Write(ruleFileStream, internalRuleFileStream);
 
       // free the scanner for this language
       delete scanner;
-      }
     }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
 {
   cmMakefile* mf = this->Makefile;
 
   // Get the string listing the multiple output pairs.
   const char* pairs_string = mf->GetDefinition("CMAKE_MULTIPLE_OUTPUT_PAIRS");
-  if(!pairs_string)
-    {
+  if (!pairs_string) {
     return;
-    }
+  }
 
   // Convert the string to a list and preserve empty entries.
   std::vector<std::string> pairs;
   cmSystemTools::ExpandListArgument(pairs_string, pairs, true);
-  for(std::vector<std::string>::const_iterator i = pairs.begin();
-      i != pairs.end() && (i+1) != pairs.end();)
-    {
+  for (std::vector<std::string>::const_iterator i = pairs.begin();
+       i != pairs.end() && (i + 1) != pairs.end();) {
     const std::string& depender = *i++;
     const std::string& dependee = *i++;
 
     // If the depender is missing then delete the dependee to make
     // sure both will be regenerated.
-    if(cmSystemTools::FileExists(dependee.c_str()) &&
-       !cmSystemTools::FileExists(depender.c_str()))
-      {
-      if(verbose)
-        {
+    if (cmSystemTools::FileExists(dependee.c_str()) &&
+        !cmSystemTools::FileExists(depender.c_str())) {
+      if (verbose) {
         std::ostringstream msg;
         msg << "Deleting primary custom command output \"" << dependee
-            << "\" because another output \""
-            << depender << "\" does not exist." << std::endl;
+            << "\" because another output \"" << depender
+            << "\" does not exist." << std::endl;
         cmSystemTools::Stdout(msg.str().c_str());
-        }
-      cmSystemTools::RemoveFile(dependee);
       }
+      cmSystemTools::RemoveFile(dependee);
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3
-::WriteLocalAllRules(std::ostream& ruleFileStream)
+void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
+  std::ostream& ruleFileStream)
 {
   this->WriteDisclaimer(ruleFileStream);
 
   // Write the main entry point target.  This must be the VERY first
   // target so that make with no arguments will run it.
   {
-  // Just depend on the all target to drive the build.
-  std::vector<std::string> depends;
-  std::vector<std::string> no_commands;
-  depends.push_back("all");
+    // Just depend on the all target to drive the build.
+    std::vector<std::string> depends;
+    std::vector<std::string> no_commands;
+    depends.push_back("all");
 
-  // Write the rule.
-  this->WriteMakeRule(ruleFileStream,
-                      "Default target executed when no arguments are "
-                      "given to make.",
-                      "default_target",
-                      depends,
-                      no_commands, true);
-
-  // Help out users that try "gmake target1 target2 -j".
-  cmGlobalUnixMakefileGenerator3* gg =
-    static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-  if(gg->AllowNotParallel())
-    {
-    std::vector<std::string> no_depends;
+    // Write the rule.
     this->WriteMakeRule(ruleFileStream,
-      "Allow only one \"make -f Makefile2\" at a time, but pass parallelism.",
-      ".NOTPARALLEL", no_depends, no_commands, false);
+                        "Default target executed when no arguments are "
+                        "given to make.",
+                        "default_target", depends, no_commands, true);
+
+    // Help out users that try "gmake target1 target2 -j".
+    cmGlobalUnixMakefileGenerator3* gg =
+      static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+    if (gg->AllowNotParallel()) {
+      std::vector<std::string> no_depends;
+      this->WriteMakeRule(ruleFileStream, "Allow only one \"make -f "
+                                          "Makefile2\" at a time, but pass "
+                                          "parallelism.",
+                          ".NOTPARALLEL", no_depends, no_commands, false);
     }
   }
 
@@ -1758,25 +1532,21 @@ void cmLocalUnixMakefileGenerator3
   // Include the progress variables for the target.
   // Write all global targets
   this->WriteDivider(ruleFileStream);
-  ruleFileStream
-    << "# Targets provided globally by CMake.\n"
-    << "\n";
+  ruleFileStream << "# Targets provided globally by CMake.\n"
+                 << "\n";
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
   std::vector<cmGeneratorTarget*>::iterator glIt;
-  for ( glIt = targets.begin(); glIt != targets.end(); ++ glIt )
-    {
-    if ( (*glIt)->GetType() == cmState::GLOBAL_TARGET )
-      {
-      std::string targetString = "Special rule for the target " +
-          (*glIt)->GetName();
+  for (glIt = targets.begin(); glIt != targets.end(); ++glIt) {
+    if ((*glIt)->GetType() == cmState::GLOBAL_TARGET) {
+      std::string targetString =
+        "Special rule for the target " + (*glIt)->GetName();
       std::vector<std::string> commands;
       std::vector<std::string> depends;
 
       const char* text = (*glIt)->GetProperty("EchoString");
-      if ( !text )
-        {
+      if (!text) {
         text = "Running external command ...";
-        }
+      }
       depends.insert(depends.end(), (*glIt)->GetUtilities().begin(),
                      (*glIt)->GetUtilities().end());
       this->AppendEcho(commands, text,
@@ -1785,43 +1555,33 @@ void cmLocalUnixMakefileGenerator3
       cmGeneratorTarget* gt = *glIt;
 
       // Global targets store their rules in pre- and post-build commands.
-      this->AppendCustomDepends(depends,
-                                gt->GetPreBuildCommands());
-      this->AppendCustomDepends(depends,
-                                gt->GetPostBuildCommands());
-      this->AppendCustomCommands(commands,
-                                 gt->GetPreBuildCommands(),
-                                 gt,
-                                 cmLocalGenerator::START_OUTPUT);
-      this->AppendCustomCommands(commands,
-                                 gt->GetPostBuildCommands(),
-                                 gt,
-                                 cmLocalGenerator::START_OUTPUT);
+      this->AppendCustomDepends(depends, gt->GetPreBuildCommands());
+      this->AppendCustomDepends(depends, gt->GetPostBuildCommands());
+      this->AppendCustomCommands(commands, gt->GetPreBuildCommands(), gt,
+                                 cmOutputConverter::START_OUTPUT);
+      this->AppendCustomCommands(commands, gt->GetPostBuildCommands(), gt,
+                                 cmOutputConverter::START_OUTPUT);
       std::string targetName = gt->GetName();
-      this->WriteMakeRule(ruleFileStream, targetString.c_str(),
-                          targetName, depends, commands, true);
+      this->WriteMakeRule(ruleFileStream, targetString.c_str(), targetName,
+                          depends, commands, true);
 
       // Provide a "/fast" version of the target.
       depends.clear();
-      if((targetName == "install")
-          || (targetName == "install_local")
-          || (targetName == "install_strip"))
-        {
+      if ((targetName == "install") || (targetName == "install_local") ||
+          (targetName == "install_strip")) {
         // Provide a fast install target that does not depend on all
         // but has the same command.
         depends.push_back("preinstall/fast");
-        }
-      else
-        {
+      } else {
         // Just forward to the real target so at least it will work.
         depends.push_back(targetName);
         commands.clear();
-        }
-      targetName += "/fast";
-      this->WriteMakeRule(ruleFileStream, targetString.c_str(),
-                          targetName, depends, commands, true);
       }
+      targetName += "/fast";
+      this->WriteMakeRule(ruleFileStream, targetString.c_str(), targetName,
+                          depends, commands, true);
     }
+  }
 
   std::vector<std::string> depends;
   std::vector<std::string> commands;
@@ -1834,52 +1594,46 @@ void cmLocalUnixMakefileGenerator3
 
   std::string progressDir = this->GetBinaryDirectory();
   progressDir += cmake::GetCMakeFilesDirectory();
-    {
+  {
     std::ostringstream progCmd;
-    progCmd <<
-      "$(CMAKE_COMMAND) -E cmake_progress_start ";
-    progCmd << this->Convert(progressDir,
-                             cmLocalGenerator::FULL,
-                             cmLocalGenerator::SHELL);
+    progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
+    progCmd << this->Convert(progressDir, cmOutputConverter::FULL,
+                             cmOutputConverter::SHELL);
 
     std::string progressFile = cmake::GetCMakeFilesDirectory();
     progressFile += "/progress.marks";
-    std::string progressFileNameFull =
-      this->ConvertToFullPath(progressFile);
-    progCmd << " " << this->Convert(progressFileNameFull,
-                                    cmLocalGenerator::FULL,
-                                    cmLocalGenerator::SHELL);
+    std::string progressFileNameFull = this->ConvertToFullPath(progressFile);
+    progCmd << " "
+            << this->Convert(progressFileNameFull, cmOutputConverter::FULL,
+                             cmOutputConverter::SHELL);
     commands.push_back(progCmd.str());
-    }
+  }
   std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
   mf2Dir += "Makefile2";
-  commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
-                                                recursiveTarget));
-  this->CreateCDCommand(commands,
-                        this->GetBinaryDirectory(),
-                        cmLocalGenerator::START_OUTPUT);
-    {
+  commands.push_back(
+    this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+  this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                        cmOutputConverter::START_OUTPUT);
+  {
     std::ostringstream progCmd;
     progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
-    progCmd << this->Convert(progressDir,
-                             cmLocalGenerator::FULL,
-                             cmLocalGenerator::SHELL);
+    progCmd << this->Convert(progressDir, cmOutputConverter::FULL,
+                             cmOutputConverter::SHELL);
     progCmd << " 0";
     commands.push_back(progCmd.str());
-    }
-  this->WriteMakeRule(ruleFileStream, "The main all target", "all",
-                      depends, commands, true);
+  }
+  this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends,
+                      commands, true);
 
   // Write the clean rule.
   recursiveTarget = this->GetCurrentBinaryDirectory();
   recursiveTarget += "/clean";
   commands.clear();
   depends.clear();
-  commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
-                                                recursiveTarget));
-  this->CreateCDCommand(commands,
-                                this->GetBinaryDirectory(),
-                                cmLocalGenerator::START_OUTPUT);
+  commands.push_back(
+    this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+  this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                        cmOutputConverter::START_OUTPUT);
   this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
                       depends, commands, true);
   commands.clear();
@@ -1895,21 +1649,17 @@ void cmLocalUnixMakefileGenerator3
   depends.clear();
   const char* noall =
     this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
-  if(!noall || cmSystemTools::IsOff(noall))
-    {
+  if (!noall || cmSystemTools::IsOff(noall)) {
     // Drive the build before installing.
     depends.push_back("all");
-    }
-  else
-    {
+  } else {
     // At least make sure the build system is up to date.
     depends.push_back("cmake_check_build_system");
-    }
-  commands.push_back
-    (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
-  this->CreateCDCommand(commands,
-                        this->GetBinaryDirectory(),
-                        cmLocalGenerator::START_OUTPUT);
+  }
+  commands.push_back(
+    this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+  this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                        cmOutputConverter::START_OUTPUT);
   this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
                       "preinstall", depends, commands, true);
   depends.clear();
@@ -1924,29 +1674,24 @@ void cmLocalUnixMakefileGenerator3
   std::string runRule =
     "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
   runRule += " --check-build-system ";
-  runRule += this->Convert(cmakefileName,cmLocalGenerator::NONE,
-                           cmLocalGenerator::SHELL);
+  runRule += this->Convert(cmakefileName, cmOutputConverter::NONE,
+                           cmOutputConverter::SHELL);
   runRule += " 1";
   commands.push_back(runRule);
-  this->CreateCDCommand(commands,
-                        this->GetBinaryDirectory(),
-                        cmLocalGenerator::START_OUTPUT);
-  this->WriteMakeRule(ruleFileStream, "clear depends",
-                      "depend",
-                      depends, commands, true);
+  this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+                        cmOutputConverter::START_OUTPUT);
+  this->WriteMakeRule(ruleFileStream, "clear depends", "depend", depends,
+                      commands, true);
 }
 
-
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
                                                       bool verbose)
 {
   // Get the list of target files to check
   const char* infoDef = mf->GetDefinition("CMAKE_DEPEND_INFO_FILES");
-  if(!infoDef)
-    {
+  if (!infoDef) {
     return;
-    }
+  }
   std::vector<std::string> files;
   cmSystemTools::ExpandListArgument(infoDef, files);
 
@@ -1954,9 +1699,8 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
   // dependencies for that target.
   cmDepends clearer;
   clearer.SetVerbose(verbose);
-  for(std::vector<std::string>::iterator l = files.begin();
-      l != files.end(); ++l)
-    {
+  for (std::vector<std::string>::iterator l = files.begin(); l != files.end();
+       ++l) {
     std::string dir = cmSystemTools::GetFilenamePath(*l);
 
     // Clear the implicit dependency makefile.
@@ -1967,13 +1711,60 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
     // regeneration.
     std::string internalDependFile = dir + "/depend.internal";
     cmSystemTools::RemoveFile(internalDependFile);
-    }
+  }
 }
 
+namespace {
+// Helper predicate for removing absolute paths that don't point to the
+// source or binary directory. It is used when CMAKE_DEPENDS_IN_PROJECT_ONLY
+// is set ON, to only consider in-project dependencies during the build.
+class NotInProjectDir
+{
+public:
+  // Constructor with the source and binary directory's path
+  NotInProjectDir(const std::string& sourceDir, const std::string& binaryDir)
+    : SourceDir(sourceDir)
+    , BinaryDir(binaryDir)
+  {
+  }
+
+  // Operator evaluating the predicate
+  bool operator()(const std::string& path) const
+  {
+    // Keep all relative paths:
+    if (!cmSystemTools::FileIsFullPath(path)) {
+      return false;
+    }
+    // If it's an absolute path, check if it starts with the source
+    // direcotory:
+    return (
+      !(IsInDirectory(SourceDir, path) || IsInDirectory(BinaryDir, path)));
+  }
+
+private:
+  // Helper function used by the predicate
+  static bool IsInDirectory(const std::string& baseDir,
+                            const std::string& testDir)
+  {
+    // First check if the test directory "starts with" the base directory:
+    if (testDir.find(baseDir) != 0) {
+      return false;
+    }
+    // If it does, then check that it's either the same string, or that the
+    // next character is a slash:
+    return ((testDir.size() == baseDir.size()) ||
+            (testDir[baseDir.size()] == '/'));
+  }
+
+  // The path to the source directory
+  std::string SourceDir;
+  // The path to the binary directory
+  std::string BinaryDir;
+};
+}
 
-void cmLocalUnixMakefileGenerator3
-::WriteDependLanguageInfo(std::ostream& cmakefileStream,
-                          cmGeneratorTarget* target)
+void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
+  std::ostream& cmakefileStream, cmGeneratorTarget* target)
 {
   ImplicitDependLanguageMap const& implicitLangs =
     this->GetImplicitDepends(target);
@@ -1981,36 +1772,30 @@ void cmLocalUnixMakefileGenerator3
   // list the languages
   cmakefileStream
     << "# The set of languages for which implicit dependencies are needed:\n";
-  cmakefileStream
-    << "set(CMAKE_DEPENDS_LANGUAGES\n";
-  for(ImplicitDependLanguageMap::const_iterator
-        l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
-    {
+  cmakefileStream << "set(CMAKE_DEPENDS_LANGUAGES\n";
+  for (ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin();
+       l != implicitLangs.end(); ++l) {
     cmakefileStream << "  \"" << l->first << "\"\n";
-    }
+  }
   cmakefileStream << "  )\n";
 
   // now list the files for each language
   cmakefileStream
     << "# The set of files for implicit dependencies of each language:\n";
-  for(ImplicitDependLanguageMap::const_iterator
-        l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
-    {
-    cmakefileStream
-      << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n";
+  for (ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin();
+       l != implicitLangs.end(); ++l) {
+    cmakefileStream << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n";
     ImplicitDependFileMap const& implicitPairs = l->second;
 
     // for each file pair
-    for(ImplicitDependFileMap::const_iterator pi = implicitPairs.begin();
-        pi != implicitPairs.end(); ++pi)
-      {
-      for(cmDepends::DependencyVector::const_iterator di = pi->second.begin();
-          di != pi->second.end(); ++ di)
-        {
+    for (ImplicitDependFileMap::const_iterator pi = implicitPairs.begin();
+         pi != implicitPairs.end(); ++pi) {
+      for (cmDepends::DependencyVector::const_iterator di = pi->second.begin();
+           di != pi->second.end(); ++di) {
         cmakefileStream << "  \"" << *di << "\" ";
         cmakefileStream << "\"" << pi->first << "\"\n";
-        }
       }
+    }
     cmakefileStream << "  )\n";
 
     // Tell the dependency scanner what compiler is used.
@@ -2018,186 +1803,157 @@ void cmLocalUnixMakefileGenerator3
     cidVar += l->first;
     cidVar += "_COMPILER_ID";
     const char* cid = this->Makefile->GetDefinition(cidVar);
-    if(cid && *cid)
-      {
-      cmakefileStream
-        << "set(CMAKE_" << l->first << "_COMPILER_ID \""
-        << cid << "\")\n";
-      }
+    if (cid && *cid) {
+      cmakefileStream << "set(CMAKE_" << l->first << "_COMPILER_ID \"" << cid
+                      << "\")\n";
+    }
 
     // Build a list of preprocessor definitions for the target.
     std::set<std::string> defines;
-    this->AddCompileDefinitions(defines, target,
-                                this->ConfigName, l->first);
-    if(!defines.empty())
-      {
+    this->AddCompileDefinitions(defines, target, this->ConfigName, l->first);
+    if (!defines.empty()) {
+      /* clang-format off */
       cmakefileStream
         << "\n"
         << "# Preprocessor definitions for this target.\n"
         << "set(CMAKE_TARGET_DEFINITIONS_" << l->first << "\n";
-      for(std::set<std::string>::const_iterator di = defines.begin();
-          di != defines.end(); ++di)
-        {
-        cmakefileStream
-          << "  " << cmOutputConverter::EscapeForCMake(*di) << "\n";
-        }
-      cmakefileStream
-        << "  )\n";
+      /* clang-format on */
+      for (std::set<std::string>::const_iterator di = defines.begin();
+           di != defines.end(); ++di) {
+        cmakefileStream << "  " << cmOutputConverter::EscapeForCMake(*di)
+                        << "\n";
       }
+      cmakefileStream << "  )\n";
+    }
 
     // Target-specific include directories:
-    cmakefileStream
-      << "\n"
-      << "# The include file search paths:\n";
-    cmakefileStream
-      << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n";
+    cmakefileStream << "\n"
+                    << "# The include file search paths:\n";
+    cmakefileStream << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n";
     std::vector<std::string> includes;
 
-
     const std::string& config =
       this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-    this->GetIncludeDirectories(includes, target,
-                                l->first, config);
-    for(std::vector<std::string>::iterator i = includes.begin();
-        i != includes.end(); ++i)
-      {
-      cmakefileStream
-        << "  \""
-        << this->Convert(*i, cmLocalGenerator::HOME_OUTPUT)
-        << "\"\n";
-      }
-    cmakefileStream
-      << "  )\n";
+    this->GetIncludeDirectories(includes, target, l->first, config);
+    if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
+      const char* sourceDir = this->GetState()->GetSourceDirectory();
+      const char* binaryDir = this->GetState()->GetBinaryDirectory();
+      std::vector<std::string>::iterator itr =
+        std::remove_if(includes.begin(), includes.end(),
+                       ::NotInProjectDir(sourceDir, binaryDir));
+      includes.erase(itr, includes.end());
+    }
+    for (std::vector<std::string>::iterator i = includes.begin();
+         i != includes.end(); ++i) {
+      cmakefileStream << "  \""
+                      << this->Convert(*i, cmOutputConverter::HOME_OUTPUT)
+                      << "\"\n";
     }
+    cmakefileStream << "  )\n";
+  }
 
   // Store include transform rule properties.  Write the directory
   // rules first because they may be overridden by later target rules.
   std::vector<std::string> transformRules;
-  if(const char* xform =
-     this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM"))
-    {
+  if (const char* xform =
+        this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
     cmSystemTools::ExpandListArgument(xform, transformRules);
-    }
-  if(const char* xform =
-     target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM"))
-    {
+  }
+  if (const char* xform =
+        target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
     cmSystemTools::ExpandListArgument(xform, transformRules);
+  }
+  if (!transformRules.empty()) {
+    cmakefileStream << "set(CMAKE_INCLUDE_TRANSFORMS\n";
+    for (std::vector<std::string>::const_iterator tri = transformRules.begin();
+         tri != transformRules.end(); ++tri) {
+      cmakefileStream << "  " << cmOutputConverter::EscapeForCMake(*tri)
+                      << "\n";
     }
-  if(!transformRules.empty())
-    {
-    cmakefileStream
-      << "set(CMAKE_INCLUDE_TRANSFORMS\n";
-    for(std::vector<std::string>::const_iterator tri = transformRules.begin();
-        tri != transformRules.end(); ++tri)
-      {
-      cmakefileStream << "  "
-          << cmOutputConverter::EscapeForCMake(*tri) << "\n";
-      }
-    cmakefileStream
-      << "  )\n";
-    }
+    cmakefileStream << "  )\n";
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
 {
-  os
-    << "# CMAKE generated file: DO NOT EDIT!\n"
-    << "# Generated by \"" << this->GlobalGenerator->GetName() << "\""
-    << " Generator, CMake Version "
-    << cmVersion::GetMajorVersion() << "."
-    << cmVersion::GetMinorVersion() << "\n\n";
+  os << "# CMAKE generated file: DO NOT EDIT!\n"
+     << "# Generated by \"" << this->GlobalGenerator->GetName() << "\""
+     << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "."
+     << cmVersion::GetMinorVersion() << "\n\n";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3
-::GetRecursiveMakeCall(const char *makefile, const std::string& tgt)
+std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
+  const char* makefile, const std::string& tgt)
 {
   // Call make on the given file.
   std::string cmd;
   cmd += "$(MAKE) -f ";
-  cmd += this->Convert(makefile,NONE,SHELL);
+  cmd +=
+    this->Convert(makefile, cmOutputConverter::NONE, cmOutputConverter::SHELL);
   cmd += " ";
 
   cmGlobalUnixMakefileGenerator3* gg =
     static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
   // Pass down verbosity level.
-  if(!gg->MakeSilentFlag.empty())
-    {
+  if (!gg->MakeSilentFlag.empty()) {
     cmd += gg->MakeSilentFlag;
     cmd += " ";
-    }
+  }
 
   // Most unix makes will pass the command line flags to make down to
   // sub-invoked makes via an environment variable.  However, some
   // makes do not support that, so you have to pass the flags
   // explicitly.
-  if(gg->PassMakeflags)
-    {
+  if (gg->PassMakeflags) {
     cmd += "-$(MAKEFLAGS) ";
-    }
+  }
 
   // Add the target.
-  if (!tgt.empty())
-    {
+  if (!tgt.empty()) {
     // The make target is always relative to the top of the build tree.
-    std::string tgt2 = this->Convert(tgt, HOME_OUTPUT);
+    std::string tgt2 = this->Convert(tgt, cmOutputConverter::HOME_OUTPUT);
 
     // The target may have been written with windows paths.
     cmSystemTools::ConvertToOutputSlashes(tgt2);
 
     // Escape one extra time if the make tool requires it.
-    if(this->MakeCommandEscapeTargetTwice)
-      {
+    if (this->MakeCommandEscapeTargetTwice) {
       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, true, false);
-    }
+  }
   return cmd;
 }
 
-//----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os)
 {
-  os
-    << "#======================================"
-    << "=======================================\n";
+  os << "#======================================"
+     << "=======================================\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3
-::WriteCMakeArgument(std::ostream& os, const char* s)
+void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
+                                                       const char* s)
 {
   // Write the given string to the stream with escaping to get it back
   // into CMake through the lexical scanner.
   os << "\"";
-  for(const char* c = s; *c; ++c)
-    {
-    if(*c == '\\')
-      {
+  for (const char* c = s; *c; ++c) {
+    if (*c == '\\') {
       os << "\\\\";
-      }
-    else if(*c == '"')
-      {
+    } else if (*c == '"') {
       os << "\\\"";
-      }
-    else
-      {
+    } else {
       os << *c;
-      }
     }
+  }
   os << "\"";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
-                                                         bool useWatcomQuote)
+std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
+  const char* p, bool useWatcomQuote)
 {
   // Split the path into its components.
   std::vector<std::string> components;
@@ -2205,79 +1961,65 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
 
   // Open the quoted result.
   std::string result;
-  if(useWatcomQuote)
-    {
+  if (useWatcomQuote) {
 #if defined(_WIN32) && !defined(__CYGWIN__)
     result = "'";
 #else
     result = "\"'";
 #endif
-    }
-  else
-    {
+  } else {
     result = "\"";
-    }
+  }
 
   // Return an empty path if there are no components.
-  if(!components.empty())
-    {
+  if (!components.empty()) {
     // Choose a slash direction and fix root component.
     const char* slash = "/";
 #if defined(_WIN32) && !defined(__CYGWIN__)
-    if(!cmSystemTools::GetForceUnixPaths())
-      {
+    if (!cmSystemTools::GetForceUnixPaths()) {
       slash = "\\";
-      for(std::string::iterator i = components[0].begin();
-          i != components[0].end(); ++i)
-        {
-        if(*i == '/')
-          {
+      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.
     result += components[0];
 
-    if (components.size() > 1)
-      {
+    if (components.size() > 1) {
       // Now add the rest of the components separated by the proper slash
       // direction for this platform.
-      std::vector<std::string>::const_iterator compEnd
-          = std::remove(components.begin() + 1, components.end() - 1,
-                          std::string());
-      std::vector<std::string>::const_iterator compStart
-          = components.begin() + 1;
+      std::vector<std::string>::const_iterator compEnd = std::remove(
+        components.begin() + 1, components.end() - 1, std::string());
+      std::vector<std::string>::const_iterator compStart =
+        components.begin() + 1;
       result += cmJoin(cmMakeRange(compStart, compEnd), slash);
       // Only the last component can be empty to avoid double slashes.
       result += slash;
       result += components.back();
-      }
     }
+  }
 
   // Close the quoted result.
-  if(useWatcomQuote)
-    {
+  if (useWatcomQuote) {
 #if defined(_WIN32) && !defined(__CYGWIN__)
     result += "'";
 #else
     result += "'\"";
 #endif
-    }
-  else
-    {
+  } else {
     result += "\"";
-    }
+  }
 
   return result;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalUnixMakefileGenerator3
-::GetTargetDirectory(cmGeneratorTarget const* target) const
+std::string cmLocalUnixMakefileGenerator3::GetTargetDirectory(
+  cmGeneratorTarget const* target) const
 {
   std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
   dir += target->GetName();
@@ -2289,36 +2031,29 @@ cmLocalUnixMakefileGenerator3
   return dir;
 }
 
-//----------------------------------------------------------------------------
 cmLocalUnixMakefileGenerator3::ImplicitDependLanguageMap const&
-cmLocalUnixMakefileGenerator3::GetImplicitDepends(
-    const cmGeneratorTarget* tgt)
+cmLocalUnixMakefileGenerator3::GetImplicitDepends(const cmGeneratorTarget* tgt)
 {
   return this->ImplicitDepends[tgt->GetName()];
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalUnixMakefileGenerator3::AddImplicitDepends(const cmGeneratorTarget* tgt,
-                                                  const std::string& lang,
-                                                  const char* obj,
-                                                  const char* src)
+void cmLocalUnixMakefileGenerator3::AddImplicitDepends(
+  const cmGeneratorTarget* tgt, const std::string& lang, const char* obj,
+  const char* src)
 {
   this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src);
 }
 
-//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3
-::CreateCDCommand(std::vector<std::string>& commands, const char *tgtDir,
-                  cmLocalGenerator::RelativeRoot relRetDir)
+void cmLocalUnixMakefileGenerator3::CreateCDCommand(
+  std::vector<std::string>& commands, const char* tgtDir,
+  cmOutputConverter::RelativeRoot relRetDir)
 {
   const char* retDir = this->GetRelativeRootPath(relRetDir);
 
   // do we need to cd?
-  if (!strcmp(tgtDir,retDir))
-    {
+  if (!strcmp(tgtDir, retDir)) {
     return;
-    }
+  }
 
   // In a Windows shell we must change drive letter too.  The shell
   // used by NMake and Borland make does not support "cd /d" so this
@@ -2328,29 +2063,26 @@ void cmLocalUnixMakefileGenerator3
 
   cmGlobalUnixMakefileGenerator3* gg =
     static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-  if(!gg->UnixCD)
-    {
+  if (!gg->UnixCD) {
     // On Windows we must perform each step separately and then change
     // back because the shell keeps the working directory between
     // commands.
     std::string cmd = cd_cmd;
     cmd += this->ConvertToOutputForExisting(tgtDir, relRetDir);
-    commands.insert(commands.begin(),cmd);
+    commands.insert(commands.begin(), cmd);
 
     // Change back to the starting directory.
     cmd = cd_cmd;
     cmd += this->ConvertToOutputForExisting(relRetDir, tgtDir);
     commands.push_back(cmd);
-    }
-  else
-    {
+  } else {
     // On UNIX we must construct a single shell command to change
     // directory and build because make resets the directory between
     // each command.
     std::string outputForExisting =
-                          this->ConvertToOutputForExisting(tgtDir, relRetDir);
+      this->ConvertToOutputForExisting(tgtDir, relRetDir);
     std::string prefix = cd_cmd + outputForExisting + " && ";
     std::transform(commands.begin(), commands.end(), commands.begin(),
                    std::bind1st(std::plus<std::string>(), prefix));
-    }
+  }
 }
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 8f69311..a65a1a1 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -44,15 +44,13 @@ public:
 
   // this returns the relative path between the HomeOutputDirectory and this
   // local generators StartOutputDirectory
-  const std::string &GetHomeRelativeOutputPath();
+  const std::string& GetHomeRelativeOutputPath();
 
   // Write out a make rule
-  void WriteMakeRule(std::ostream& os,
-                     const char* comment,
+  void WriteMakeRule(std::ostream& os, const char* comment,
                      const std::string& target,
                      const std::vector<std::string>& depends,
-                     const std::vector<std::string>& commands,
-                     bool symbolic,
+                     const std::vector<std::string>& commands, bool symbolic,
                      bool in_help = false);
 
   // write the main variables used by the makefiles
@@ -68,14 +66,15 @@ public:
    * extra level of escapes.
    */
   void SetMakeCommandEscapeTargetTwice(bool b)
-    { this->MakeCommandEscapeTargetTwice = b; }
+  {
+    this->MakeCommandEscapeTargetTwice = b;
+  }
 
   /**
    * Set whether the Borland curly brace command line hack should be
    * applied.
    */
-  void SetBorlandMakeCurlyHack(bool b)
-    { this->BorlandMakeCurlyHack = b; }
+  void SetBorlandMakeCurlyHack(bool b) { this->BorlandMakeCurlyHack = b; }
 
   // used in writing out Cmake files such as WriteDirectoryInformation
   static void WriteCMakeArgument(std::ostream& os, const char* s);
@@ -87,7 +86,7 @@ public:
   void WriteDivider(std::ostream& os);
 
   /** used to create a recursive make call */
-  std::string GetRecursiveMakeCall(const char *makefile,
+  std::string GetRecursiveMakeCall(const char* makefile,
                                    const std::string& tgt);
 
   // append flags to a string
@@ -95,22 +94,33 @@ public:
   virtual void AppendFlags(std::string& flags, const char* newFlags);
 
   // append an echo command
-  enum EchoColor { EchoNormal, EchoDepend, EchoBuild, EchoLink,
-                   EchoGenerate, EchoGlobal };
-  struct EchoProgress { std::string Dir; std::string Arg; };
+  enum EchoColor
+  {
+    EchoNormal,
+    EchoDepend,
+    EchoBuild,
+    EchoLink,
+    EchoGenerate,
+    EchoGlobal
+  };
+  struct EchoProgress
+  {
+    std::string Dir;
+    std::string Arg;
+  };
   void AppendEcho(std::vector<std::string>& commands, std::string const& text,
                   EchoColor color = EchoNormal, EchoProgress const* = 0);
 
   /** Get whether the makefile is to have color.  */
   bool GetColorMakefile() const { return this->ColorMakefile; }
 
-  virtual
-  std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
+  virtual std::string GetTargetDirectory(
+    cmGeneratorTarget const* target) const;
 
-    // create a command that cds to the start dir then runs the commands
+  // create a command that cds to the start dir then runs the commands
   void CreateCDCommand(std::vector<std::string>& commands,
-                       const char *targetDir,
-                       cmLocalGenerator::RelativeRoot returnDir);
+                       const char* targetDir,
+                       cmOutputConverter::RelativeRoot returnDir);
 
   static std::string ConvertToQuotedOutputPath(const char* p,
                                                bool useWatcomQuote);
@@ -120,8 +130,8 @@ public:
 
   /** Called from command-line hook to bring dependencies up to date
       for a target.  */
-  virtual bool UpdateDependencies(const char* tgtInfo,
-                                  bool verbose, bool color);
+  virtual bool UpdateDependencies(const char* tgtInfo, bool verbose,
+                                  bool color);
 
   /** Called from command-line hook to clear dependencies.  */
   virtual void ClearDependencies(cmMakefile* mf, bool verbose);
@@ -134,18 +144,24 @@ public:
 
   // 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<std::string, cmDepends::DependencyVector> {};
-  struct ImplicitDependLanguageMap:
-    public std::map<std::string, ImplicitDependFileMap> {};
-  struct ImplicitDependTargetMap:
-    public std::map<std::string, ImplicitDependLanguageMap> {};
-  ImplicitDependLanguageMap const&
-  GetImplicitDepends(cmGeneratorTarget const* tgt);
+  struct ImplicitDependFileMap
+    : public std::map<std::string, cmDepends::DependencyVector>
+  {
+  };
+  struct ImplicitDependLanguageMap
+    : public std::map<std::string, ImplicitDependFileMap>
+  {
+  };
+  struct ImplicitDependTargetMap
+    : public std::map<std::string, ImplicitDependLanguageMap>
+  {
+  };
+  ImplicitDependLanguageMap const& GetImplicitDepends(
+    cmGeneratorTarget const* tgt);
 
   void AddImplicitDepends(cmGeneratorTarget const* tgt,
-                          const std::string& lang,
-                          const char* obj, const char* src);
+                          const std::string& lang, const char* obj,
+                          const char* src);
 
   // write the target rules for the local Makefile into the stream
   void WriteLocalAllRules(std::ostream& ruleFileStream);
@@ -156,13 +172,13 @@ public:
       assembly sources.  This could be converted to a variable lookup
       later.  */
   bool GetCreatePreprocessedSourceRules()
-    {
+  {
     return !this->SkipPreprocessedSourceRules;
-    }
+  }
   bool GetCreateAssemblySourceRules()
-    {
+  {
     return !this->SkipAssemblySourceRules;
-    }
+  }
 
   // Fill the vector with the target names for the object files,
   // preprocessed files and assembly files. Currently only used by the
@@ -172,18 +188,16 @@ public:
 protected:
   void WriteLocalMakefile();
 
-
   // write the target rules for the local Makefile into the stream
   void WriteLocalMakefileTargets(std::ostream& ruleFileStream,
-                                 std::set<std::string> &emitted);
+                                 std::set<std::string>& emitted);
 
   // this method Writes the Directory information files
   void WriteDirectoryInformationFile();
 
-
   // write the depend info
   void WriteDependLanguageInfo(std::ostream& cmakefileStream,
-                               cmGeneratorTarget *tgt);
+                               cmGeneratorTarget* tgt);
 
   // write the local help rule
   void WriteHelpRule(std::ostream& ruleFileStream);
@@ -192,7 +206,6 @@ protected:
   // into a full path
   std::string ConvertToFullPath(const std::string& localPath);
 
-
   void WriteConvenienceRule(std::ostream& ruleFileStream,
                             const std::string& realTarget,
                             const std::string& helpTarget);
@@ -214,35 +227,35 @@ protected:
                            const std::vector<cmCustomCommand>& ccs);
   void AppendCustomDepend(std::vector<std::string>& depends,
                           cmCustomCommandGenerator const& cc);
-  void AppendCustomCommands(std::vector<std::string>& commands,
-                            const std::vector<cmCustomCommand>& ccs,
-                            cmGeneratorTarget* target,
-                            cmLocalGenerator::RelativeRoot relative =
-                            cmLocalGenerator::HOME_OUTPUT);
-  void AppendCustomCommand(std::vector<std::string>& commands,
-                           cmCustomCommandGenerator const& ccg,
-                           cmGeneratorTarget* target,
-                           bool echo_comment=false,
-                           cmLocalGenerator::RelativeRoot relative =
-                           cmLocalGenerator::HOME_OUTPUT,
-                           std::ostream* content = 0);
+  void AppendCustomCommands(
+    std::vector<std::string>& commands,
+    const std::vector<cmCustomCommand>& ccs, cmGeneratorTarget* target,
+    cmOutputConverter::RelativeRoot relative = cmOutputConverter::HOME_OUTPUT);
+  void AppendCustomCommand(
+    std::vector<std::string>& commands, cmCustomCommandGenerator const& ccg,
+    cmGeneratorTarget* target, bool echo_comment = false,
+    cmOutputConverter::RelativeRoot relative = cmOutputConverter::HOME_OUTPUT,
+    std::ostream* content = 0);
   void AppendCleanCommand(std::vector<std::string>& commands,
                           const std::vector<std::string>& files,
-                          cmGeneratorTarget* target, const char* filename =0);
+                          cmGeneratorTarget* target, const char* filename = 0);
 
   // Helper methods for dependeny updates.
-  bool ScanDependencies(const char* targetDir,
-                std::map<std::string, cmDepends::DependencyVector>& validDeps);
+  bool ScanDependencies(
+    const char* targetDir,
+    std::map<std::string, cmDepends::DependencyVector>& validDeps);
   void CheckMultipleOutputs(bool verbose);
 
 private:
-  std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root);
+  std::string ConvertShellCommand(std::string const& cmd,
+                                  cmOutputConverter::RelativeRoot root);
   std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
-                           cmGeneratorTarget* target, RelativeRoot relative);
+                           cmGeneratorTarget* target,
+                           cmOutputConverter::RelativeRoot relative);
 
   virtual void ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* gt = 0);
+    std::map<cmSourceFile const*, std::string>& mapping,
+    cmGeneratorTarget const* gt = 0);
 
   friend class cmMakefileTargetGenerator;
   friend class cmMakefileExecutableTargetGenerator;
@@ -258,20 +271,31 @@ private:
   {
     cmGeneratorTarget* Target;
     std::string Language;
-    LocalObjectEntry(): Target(0), Language() {}
-    LocalObjectEntry(cmGeneratorTarget* t, const std::string& lang):
-      Target(t), Language(lang) {}
+    LocalObjectEntry()
+      : Target(0)
+      , Language()
+    {
+    }
+    LocalObjectEntry(cmGeneratorTarget* t, const std::string& lang)
+      : Target(t)
+      , Language(lang)
+    {
+    }
   };
-  struct LocalObjectInfo: public std::vector<LocalObjectEntry>
+  struct LocalObjectInfo : public std::vector<LocalObjectEntry>
   {
     bool HasSourceExtension;
     bool HasPreprocessRule;
     bool HasAssembleRule;
-    LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false),
-                      HasAssembleRule(false) {}
+    LocalObjectInfo()
+      : HasSourceExtension(false)
+      , HasPreprocessRule(false)
+      , HasAssembleRule(false)
+    {
+    }
   };
   void GetLocalObjectFiles(
-                    std::map<std::string, LocalObjectInfo> &localObjectFiles);
+    std::map<std::string, LocalObjectInfo>& localObjectFiles);
 
   void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
                                   const char* comment, const char* output,
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index d0784ad..37b5505 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -10,59 +10,53 @@
   See the License for more information.
 ============================================================================*/
 #include "cmLocalVisualStudio10Generator.h"
+
+#include "cmGlobalVisualStudio10Generator.h"
 #include "cmMakefile.h"
 #include "cmVisualStudio10TargetGenerator.h"
-#include "cmGlobalVisualStudio10Generator.h"
-#include <cm_expat.h>
 #include "cmXMLParser.h"
+#include <cm_expat.h>
+
 class cmVS10XMLParser : public cmXMLParser
 {
-  public:
-  virtual void EndElement(const std::string& /* name */)
-    {
-    }
+public:
+  virtual void EndElement(const std::string& /* name */) {}
   virtual void CharacterDataHandler(const char* data, int length)
-    {
-      if(this->DoGUID )
-        {
-        this->GUID.assign(data+1, length-2);
-        this->DoGUID = false;
-        }
+  {
+    if (this->DoGUID) {
+      this->GUID.assign(data + 1, length - 2);
+      this->DoGUID = false;
     }
+  }
   virtual void StartElement(const std::string& name, const char**)
-    {
-      // once the GUID is found do nothing
-      if(!this->GUID.empty())
-        {
-        return;
-        }
-      if("ProjectGUID" == name || "ProjectGuid" == name)
-        {
-        this->DoGUID = true;
-        }
+  {
+    // once the GUID is found do nothing
+    if (!this->GUID.empty()) {
+      return;
+    }
+    if ("ProjectGUID" == name || "ProjectGuid" == name) {
+      this->DoGUID = true;
     }
+  }
   int InitializeParser()
-    {
-      this->DoGUID = false;
-      int ret = cmXMLParser::InitializeParser();
-      if(ret == 0)
-        {
-        return ret;
-        }
-      // visual studio projects have a strange encoding, but it is
-      // really utf-8
-      XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
-      return 1;
+  {
+    this->DoGUID = false;
+    int ret = cmXMLParser::InitializeParser();
+    if (ret == 0) {
+      return ret;
     }
+    // visual studio projects have a strange encoding, but it is
+    // really utf-8
+    XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
+    return 1;
+  }
   std::string GUID;
   bool DoGUID;
 };
 
-
-//----------------------------------------------------------------------------
-cmLocalVisualStudio10Generator
-::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf):
-  cmLocalVisualStudio7Generator(gg, mf)
+cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator(
+  cmGlobalGenerator* gg, cmMakefile* mf)
+  : cmLocalVisualStudio7Generator(gg, mf)
 {
 }
 
@@ -74,54 +68,43 @@ void cmLocalVisualStudio10Generator::Generate()
 {
 
   std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); ++l)
-    {
-    if((*l)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+       l != tgts.end(); ++l) {
+    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
-    if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
-       ->TargetIsFortranOnly(*l))
-      {
+    }
+    if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
+          ->TargetIsFortranOnly(*l)) {
       this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
-      }
-    else
-      {
+    } else {
       cmVisualStudio10TargetGenerator tg(
         *l, static_cast<cmGlobalVisualStudio10Generator*>(
-          this->GetGlobalGenerator()));
+              this->GetGlobalGenerator()));
       tg.Generate();
-      }
     }
+  }
   this->WriteStampFiles();
 }
 
-
-void cmLocalVisualStudio10Generator
-::ReadAndStoreExternalGUID(const std::string& name,
-                           const char* path)
+void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID(
+  const std::string& name, const char* path)
 {
   cmVS10XMLParser parser;
   parser.ParseFile(path);
 
   // if we can not find a GUID then we will generate one later
-  if(parser.GUID.empty())
-    {
+  if (parser.GUID.empty()) {
     return;
-    }
+  }
 
   std::string guidStoreName = name;
   guidStoreName += "_GUID_CMAKE";
   // save the GUID in the cache
-  this->GlobalGenerator->GetCMakeInstance()->
-    AddCacheEntry(guidStoreName.c_str(),
-                  parser.GUID.c_str(),
-                  "Stored GUID",
-                  cmState::INTERNAL);
+  this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
+    guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID",
+    cmState::INTERNAL);
 }
 
-//----------------------------------------------------------------------------
 const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const
 {
   return ":VCEnd";
diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h
index e187590..6ec894c 100644
--- a/Source/cmLocalVisualStudio10Generator.h
+++ b/Source/cmLocalVisualStudio10Generator.h
@@ -14,7 +14,6 @@
 
 #include "cmLocalVisualStudio7Generator.h"
 
-
 /** \class cmLocalVisualStudio10Generator
  * \brief Write Visual Studio 10 project files.
  *
@@ -29,7 +28,6 @@ public:
 
   virtual ~cmLocalVisualStudio10Generator();
 
-
   /**
    * Generate the makefile for this directory.
    */
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
deleted file mode 100644
index cdacb9e..0000000
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ /dev/null
@@ -1,2002 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#include "cmGlobalGenerator.h"
-#include "cmLocalVisualStudio6Generator.h"
-#include "cmMakefile.h"
-#include "cmSystemTools.h"
-#include "cmSourceFile.h"
-#include "cmGeneratorTarget.h"
-#include "cmCustomCommandGenerator.h"
-#include "cmake.h"
-
-#include "cmComputeLinkInformation.h"
-
-#include <cmsys/RegularExpression.hxx>
-#include <cmsys/FStream.hxx>
-
-cmLocalVisualStudio6Generator
-::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf):
-  cmLocalVisualStudioGenerator(gg, mf)
-{
-}
-
-cmLocalVisualStudio6Generator::~cmLocalVisualStudio6Generator()
-{
-}
-
-//----------------------------------------------------------------------------
-// Helper class to write build events.
-class cmLocalVisualStudio6Generator::EventWriter
-{
-public:
-  EventWriter(cmLocalVisualStudio6Generator* lg,
-              const std::string& config, std::string& code):
-    LG(lg), Config(config), Code(code), First(true) {}
-  void Start(const char* event)
-    {
-    this->First = true;
-    this->Event = event;
-    }
-  void Finish()
-    {
-    this->Code += (this->First? "" : "\n");
-    }
-  void Write(std::vector<cmCustomCommand> const& ccs)
-    {
-    for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
-        ci != ccs.end(); ++ci)
-      {
-      this->Write(*ci);
-      }
-    }
-  void Write(cmCustomCommand const& cc)
-    {
-    cmCustomCommandGenerator ccg(cc, this->Config, this->LG);
-    if(this->First)
-      {
-      this->Code += this->Event + "_Cmds=";
-      this->First = false;
-      }
-    else
-      {
-      this->Code += "\\\n\t";
-      }
-    this->Code += this->LG->ConstructScript(ccg, "\\\n\t");
-    }
-private:
-  cmLocalVisualStudio6Generator* LG;
-  std::string Config;
-  std::string& Code;
-  bool First;
-  std::string Event;
-};
-
-void cmLocalVisualStudio6Generator::AddCMakeListsRules()
-{
-  std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); ++l)
-    {
-    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY
-        || (*l)->GetType() == cmState::GLOBAL_TARGET)
-      {
-      continue;
-      }
-
-    // Add a rule to regenerate the build system when the target
-    // specification source changes.
-    const char* suppRegenRule =
-      this->Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
-    if (!cmSystemTools::IsOn(suppRegenRule))
-      {
-      this->AddDSPBuildRule(*l);
-      }
-    }
-}
-
-void cmLocalVisualStudio6Generator::Generate()
-{
-  this->OutputDSPFile();
-}
-
-void cmLocalVisualStudio6Generator::OutputDSPFile()
-{
-  // If not an in source build, then create the output directory
-  if(strcmp(this->GetCurrentBinaryDirectory(),
-            this->GetSourceDirectory()) != 0)
-    {
-    if(!cmSystemTools::MakeDirectory
-       (this->GetCurrentBinaryDirectory()))
-      {
-      cmSystemTools::Error("Error creating directory ",
-                           this->GetCurrentBinaryDirectory());
-      }
-    }
-
-  // Create the DSP or set of DSP's for libraries and executables
-
-  std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); ++l)
-    {
-    switch((*l)->GetType())
-      {
-      case cmState::STATIC_LIBRARY:
-      case cmState::OBJECT_LIBRARY:
-        this->SetBuildType(STATIC_LIBRARY,
-                           (*l)->GetName().c_str(), *l);
-        break;
-      case cmState::SHARED_LIBRARY:
-      case cmState::MODULE_LIBRARY:
-        this->SetBuildType(DLL,
-                           (*l)->GetName().c_str(), *l);
-        break;
-      case cmState::EXECUTABLE:
-        this->SetBuildType(EXECUTABLE,
-                           (*l)->GetName().c_str(), *l);
-        break;
-      case cmState::UTILITY:
-      case cmState::GLOBAL_TARGET:
-        this->SetBuildType(UTILITY,
-                           (*l)->GetName().c_str(), *l);
-        break;
-      case cmState::INTERFACE_LIBRARY:
-        continue;
-      default:
-        cmSystemTools::Error("Bad target type: ", (*l)->GetName().c_str());
-        break;
-      }
-    // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
-    // so don't build a projectfile for it
-    const char* path =
-      (*l)->GetProperty("EXTERNAL_MSPROJECT");
-    if(!path)
-      {
-      // check to see if the dsp is going into a sub-directory
-      std::string::size_type pos = (*l)->GetName().rfind('/');
-      if(pos != std::string::npos)
-        {
-        std::string dir = this->GetCurrentBinaryDirectory();
-        dir += "/";
-        dir += (*l)->GetName().substr(0, pos);
-        if(!cmSystemTools::MakeDirectory(dir.c_str()))
-          {
-          cmSystemTools::Error("Error creating directory: ", dir.c_str());
-          }
-        }
-      this->CreateSingleDSP((*l)->GetName().c_str(), *l);
-      }
-    }
-}
-
-// Utility function to make a valid VS6 *.dsp filename out
-// of a CMake target name:
-//
-extern std::string GetVS6TargetName(const std::string& targetName);
-
-void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname,
-                                                    cmGeneratorTarget* target)
-{
-  // add to the list of projects
-  std::string pname = GetVS6TargetName(lname);
-
-  // create the dsp.cmake file
-  std::string fname;
-  fname = this->GetCurrentBinaryDirectory();
-  fname += "/";
-  fname += pname;
-  fname += ".dsp";
-  // save the name of the real dsp file
-  std::string realDSP = fname;
-  fname += ".cmake";
-  cmsys::ofstream fout(fname.c_str());
-  if(!fout)
-    {
-    cmSystemTools::Error("Error Writing ", fname.c_str());
-    cmSystemTools::ReportLastSystemError("");
-    }
-  this->WriteDSPFile(fout,pname.c_str(),target);
-  fout.close();
-  // if the dsp file has changed, then write it.
-  cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str());
-}
-
-
-void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmGeneratorTarget *tgt)
-{
-  std::string dspname = GetVS6TargetName(tgt->GetName());
-  dspname += ".dsp.cmake";
-  cmCustomCommandLine commandLine;
-  commandLine.push_back(cmSystemTools::GetCMakeCommand());
-  std::string makefileIn = this->GetCurrentSourceDirectory();
-  makefileIn += "/";
-  makefileIn += "CMakeLists.txt";
-  if(!cmSystemTools::FileExists(makefileIn.c_str()))
-    {
-    return;
-    }
-  std::string comment = "Building Custom Rule ";
-  comment += makefileIn;
-  std::string args;
-  args = "-H";
-  args += this->GetSourceDirectory();
-  commandLine.push_back(args);
-  args = "-B";
-  args += this->GetBinaryDirectory();
-  commandLine.push_back(args);
-
-  std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
-
-  cmCustomCommandLines commandLines;
-  commandLines.push_back(commandLine);
-  const char* no_working_directory = 0;
-  this->Makefile->AddCustomCommandToOutput(dspname.c_str(), listFiles,
-                                           makefileIn.c_str(), commandLines,
-                                           comment.c_str(),
-                                           no_working_directory, true);
-  if(this->Makefile->GetSource(makefileIn.c_str()))
-    {
-    tgt->AddSource(makefileIn);
-    }
-  else
-    {
-    cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
-    }
-}
-
-
-void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
-                                                 const std::string& libName,
-                                                 cmGeneratorTarget *target)
-{
-  // For utility targets need custom command since pre- and post-
-  // build does not do anything in Visual Studio 6.  In order for the
-  // rules to run in the correct order as custom commands, we need
-  // special care for dependencies.  The first rule must depend on all
-  // the dependencies of all the rules.  The later rules must each
-  // depend only on the previous rule.
-  if ((target->GetType() == cmState::UTILITY ||
-      target->GetType() == cmState::GLOBAL_TARGET) &&
-      (!target->GetPreBuildCommands().empty() ||
-       !target->GetPostBuildCommands().empty()))
-    {
-    // Accumulate the dependencies of all the commands.
-    std::vector<std::string> depends;
-    for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->GetPreBuildCommands().begin();
-         cr != target->GetPreBuildCommands().end(); ++cr)
-      {
-      depends.insert(depends.end(),
-                     cr->GetDepends().begin(), cr->GetDepends().end());
-      }
-    for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->GetPostBuildCommands().begin();
-         cr != target->GetPostBuildCommands().end(); ++cr)
-      {
-      depends.insert(depends.end(),
-                     cr->GetDepends().begin(), cr->GetDepends().end());
-      }
-
-    // Add the pre- and post-build commands in order.
-    int count = 1;
-    for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->GetPreBuildCommands().begin();
-         cr != target->GetPreBuildCommands().end(); ++cr)
-      {
-      this->AddUtilityCommandHack(target, count++, depends, *cr);
-      }
-    for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->GetPostBuildCommands().begin();
-         cr != target->GetPostBuildCommands().end(); ++cr)
-      {
-      this->AddUtilityCommandHack(target, count++, depends, *cr);
-      }
-    }
-
-  // We may be modifying the source groups temporarily, so make a copy.
-  std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
-
-  // get the classes from the source lists then add them to the groups
-  std::vector<cmSourceFile*> 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 =
-      this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
-    sourceGroup->AssignSource(*i);
-    // while we are at it, if it is a .rule file then for visual studio 6 we
-    // must generate it
-    if ((*i)->GetPropertyAsBool("__CMAKE_RULE"))
-      {
-      if(!cmSystemTools::FileExists(source.c_str()))
-        {
-        cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
-        // Make sure the path exists for the file
-        std::string path = cmSystemTools::GetFilenamePath(source);
-        cmSystemTools::MakeDirectory(path.c_str());
-#if defined(_WIN32) || defined(__CYGWIN__)
-        cmsys::ofstream sourceFout(source.c_str(),
-                           std::ios::binary | std::ios::out
-                           | std::ios::trunc);
-#else
-        cmsys::ofstream sourceFout(source.c_str(),
-                           std::ios::out | std::ios::trunc);
-#endif
-        if(sourceFout)
-          {
-          sourceFout.write("# generated from CMake",22);
-          sourceFout.flush();
-          sourceFout.close();
-          }
-        }
-      }
-    }
-
-  // Write the DSP file's header.
-  this->WriteDSPHeader(fout, libName, target, sourceGroups);
-
-
-  // Loop through every source group.
-  for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
-      sg != sourceGroups.end(); ++sg)
-    {
-    this->WriteGroup(&(*sg), target, fout, libName);
-    }
-
-  // Write the DSP file's footer.
-  this->WriteDSPFooter(fout);
-}
-
-void cmLocalVisualStudio6Generator
-::WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target,
-             std::ostream &fout, const std::string& libName)
-{
-  const std::vector<const cmSourceFile *> &sourceFiles =
-    sg->GetSourceFiles();
-  // If the group is empty, don't write it at all.
-
-  if(sourceFiles.empty() && sg->GetGroupChildren().empty())
-    {
-    return;
-    }
-
-  // If the group has a name, write the header.
-  std::string name = sg->GetName();
-  if(name != "")
-    {
-    this->WriteDSPBeginGroup(fout, name.c_str(), "");
-    }
-
-  // Loop through each source in the source group.
-  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();
-    std::string compileFlags;
-    std::vector<std::string> depends;
-    std::string objectNameDir;
-    if(target->HasExplicitObjectName(*sf))
-      {
-      objectNameDir =
-          cmSystemTools::GetFilenamePath(target->GetObjectName(*sf));
-      }
-
-    // Add per-source file flags.
-    if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS"))
-      {
-      compileFlags += cflags;
-      }
-
-    const std::string& lang = this->GetSourceFileLanguage(*(*sf));
-    if(lang == "CXX")
-      {
-      // 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<std::string, std::string> cdmap;
-
-      {
-      std::set<std::string> targetCompileDefinitions;
-
-      this->AppendDefines(targetCompileDefinitions,
-                        (*sf)->GetProperty("COMPILE_DEFINITIONS"));
-      this->JoinDefines(targetCompileDefinitions, compileFlags, lang);
-      }
-
-    if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
-      {
-      std::set<std::string> debugCompileDefinitions;
-      this->AppendDefines(debugCompileDefinitions, cdefs);
-      this->JoinDefines(debugCompileDefinitions, cdmap["DEBUG"], lang);
-      }
-    if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE"))
-      {
-      std::set<std::string> releaseCompileDefinitions;
-      this->AppendDefines(releaseCompileDefinitions, cdefs);
-      this->JoinDefines(releaseCompileDefinitions, cdmap["RELEASE"], lang);
-      }
-    if(const char* cdefs =
-       (*sf)->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"))
-      {
-      std::set<std::string> minsizerelCompileDefinitions;
-      this->AppendDefines(minsizerelCompileDefinitions, cdefs);
-      this->JoinDefines(minsizerelCompileDefinitions, cdmap["MINSIZEREL"],
-                        lang);
-      }
-    if(const char* cdefs =
-       (*sf)->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"))
-      {
-      std::set<std::string> relwithdebinfoCompileDefinitions;
-      this->AppendDefines(relwithdebinfoCompileDefinitions, cdefs);
-      this->JoinDefines(relwithdebinfoCompileDefinitions,
-                        cdmap["RELWITHDEBINFO"], lang);
-      }
-
-    bool excludedFromBuild =
-      (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
-
-    // Check for extra object-file dependencies.
-    const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
-    if(dependsValue)
-      {
-      cmSystemTools::ExpandListArgument(dependsValue, depends);
-      }
-    if (GetVS6TargetName(source) != libName ||
-      target->GetType() == cmState::UTILITY ||
-      target->GetType() == cmState::GLOBAL_TARGET)
-      {
-      fout << "# Begin Source File\n\n";
-
-      // Tell MS-Dev what the source is.  If the compiler knows how to
-      // build it, then it will.
-      fout << "SOURCE=" <<
-        this->ConvertToOutputFormat(source.c_str(), SHELL) << "\n\n";
-      if(!depends.empty())
-        {
-        // Write out the dependencies for the rule.
-        fout << "USERDEP__HACK=";
-        for(std::vector<std::string>::const_iterator d = depends.begin();
-            d != depends.end(); ++d)
-          {
-          fout << "\\\n\t" <<
-            this->ConvertToOutputFormat(d->c_str(), SHELL);
-          }
-        fout << "\n";
-        }
-      if (command)
-        {
-        const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
-        this->WriteCustomRule(fout, source.c_str(), *command, flags);
-        }
-      else if(!compileFlags.empty() || !objectNameDir.empty() ||
-              excludedFromBuild || !cdmap.empty())
-        {
-        for(std::vector<std::string>::iterator i
-              = this->Configurations.begin();
-            i != this->Configurations.end(); ++i)
-          {
-          // Strip the subdirectory name out of the configuration name.
-          std::string config = this->GetConfigName(*i);
-          if (i == this->Configurations.begin())
-            {
-            fout << "!IF  \"$(CFG)\" == " << i->c_str() << std::endl;
-            }
-          else
-            {
-            fout << "!ELSEIF  \"$(CFG)\" == " << i->c_str() << std::endl;
-            }
-          if(excludedFromBuild)
-            {
-            fout << "# PROP Exclude_From_Build 1\n";
-            }
-          if(!compileFlags.empty())
-            {
-            fout << "\n# ADD CPP " << compileFlags << "\n\n";
-            }
-          std::map<std::string, std::string>::iterator cdi =
-            cdmap.find(cmSystemTools::UpperCase(config));
-          if(cdi != cdmap.end() && !cdi->second.empty())
-            {
-            fout << "\n# ADD CPP " << cdi->second << "\n\n";
-            }
-          if(!objectNameDir.empty())
-            {
-            // Setup an alternate object file directory.
-            fout << "\n# PROP Intermediate_Dir \""
-                 << config << "/" << objectNameDir << "\"\n\n";
-            }
-          }
-        fout << "!ENDIF\n\n";
-        }
-      fout << "# End Source File\n";
-      }
-    }
-
-  std::vector<cmSourceGroup> const& children  = sg->GetGroupChildren();
-
-  for(unsigned int i=0;i<children.size();++i)
-    {
-    this->WriteGroup(&children[i], target, fout, libName);
-    }
-
-
-
-
-  // If the group has a name, write the footer.
-  if(name != "")
-    {
-    this->WriteDSPEndGroup(fout);
-    }
-
-}
-
-
-void
-cmLocalVisualStudio6Generator
-::AddUtilityCommandHack(cmGeneratorTarget *target, int count,
-                        std::vector<std::string>& depends,
-                        const cmCustomCommand& origCommand)
-{
-  // Create a fake output that forces the rule to run.
-  char* output = new char[(strlen(this->GetCurrentBinaryDirectory())
-                           + target->GetName().size() + 30)];
-  sprintf(output,"%s/%s_force_%i", this->GetCurrentBinaryDirectory(),
-          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.
-  std::string no_main_dependency = "";
-  if(cmSourceFile* outsf =
-     this->Makefile->AddCustomCommandToOutput(
-       output, depends, no_main_dependency,
-       origCommand.GetCommandLines(), comment,
-       origCommand.GetWorkingDirectory().c_str()))
-    {
-    target->AddSource(outsf->GetFullPath());
-    }
-
-  // Replace the dependencies with the output of this rule so that the
-  // next rule added will run after this one.
-  depends.clear();
-  depends.push_back(output);
-
-  // Free the fake output name.
-  delete [] output;
-}
-
-void
-cmLocalVisualStudio6Generator
-::WriteCustomRule(std::ostream& fout,
-                  const char* source,
-                  const cmCustomCommand& command,
-                  const char* flags)
-{
-  // 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);
-    std::string comment =
-      this->ConstructComment(ccg, "Building Custom Rule $(InputPath)");
-    if(comment == "<hack>")
-      {
-      comment = "";
-      }
-
-    std::string script =
-      this->ConstructScript(ccg, "\\\n\t");
-
-    if (i == this->Configurations.begin())
-      {
-      fout << "!IF  \"$(CFG)\" == " << i->c_str() << std::endl;
-      }
-    else
-      {
-      fout << "!ELSEIF  \"$(CFG)\" == " << i->c_str() << std::endl;
-      }
-    if(flags)
-      {
-      fout << "\n# ADD CPP " << flags << "\n\n";
-      }
-    // Write out the dependencies for the rule.
-    fout << "USERDEP__HACK=";
-    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(), config.c_str(), dep))
-        {
-        fout << "\\\n\t" <<
-          this->ConvertToOutputFormat(dep.c_str(), SHELL);
-        }
-      }
-    fout << "\n";
-
-    fout << "# PROP Ignore_Default_Tool 1\n";
-    fout << "# Begin Custom Build -";
-    if(!comment.empty())
-      {
-      fout << " " << comment.c_str();
-      }
-    fout << "\n\n";
-    if(ccg.GetOutputs().empty())
-      {
-      fout << source
-           << "_force :  \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
-      fout << script.c_str() << "\n\n";
-      }
-    else
-      {
-      for(std::vector<std::string>::const_iterator o =
-          ccg.GetOutputs().begin();
-          o != ccg.GetOutputs().end();
-          ++o)
-        {
-        // Write a rule for every output generated by this command.
-        fout << this->ConvertToOutputFormat(o->c_str(), SHELL)
-             << " :  \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
-        fout << script.c_str() << "\n\n";
-        }
-      }
-    fout << "# End Custom Build\n\n";
-    }
-
-  fout << "!ENDIF\n\n";
-}
-
-
-void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout,
-                                                       const char* group,
-                                                       const char* filter)
-{
-  fout << "# Begin Group \"" << group << "\"\n"
-    "# PROP Default_Filter \"" << filter << "\"\n";
-}
-
-
-void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
-{
-  fout << "# End Group\n";
-}
-
-
-
-
-void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
-                                                 const std::string& libName,
-                                                 cmGeneratorTarget *target)
-{
-  std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
-  const char *def=
-    this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
-
-  if( def)
-    {
-    root = def;
-    }
-  else
-    {
-    root += "/Templates";
-    }
-
-  switch(b)
-    {
-    case WIN32_EXECUTABLE:
-      break;
-    case STATIC_LIBRARY:
-      this->DSPHeaderTemplate = root;
-      this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate";
-      this->DSPFooterTemplate = root;
-      this->DSPFooterTemplate += "/staticLibFooter.dsptemplate";
-      break;
-    case DLL:
-      this->DSPHeaderTemplate =  root;
-      this->DSPHeaderTemplate += "/DLLHeader.dsptemplate";
-      this->DSPFooterTemplate =  root;
-      this->DSPFooterTemplate += "/DLLFooter.dsptemplate";
-      break;
-    case EXECUTABLE:
-      if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
-        {
-        this->DSPHeaderTemplate = root;
-        this->DSPHeaderTemplate += "/EXEWinHeader.dsptemplate";
-        this->DSPFooterTemplate = root;
-        this->DSPFooterTemplate += "/EXEFooter.dsptemplate";
-        }
-      else
-        {
-        this->DSPHeaderTemplate = root;
-        this->DSPHeaderTemplate += "/EXEHeader.dsptemplate";
-        this->DSPFooterTemplate = root;
-        this->DSPFooterTemplate += "/EXEFooter.dsptemplate";
-        }
-      break;
-    case UTILITY:
-      this->DSPHeaderTemplate = root;
-      this->DSPHeaderTemplate += "/UtilityHeader.dsptemplate";
-      this->DSPFooterTemplate = root;
-      this->DSPFooterTemplate += "/UtilityFooter.dsptemplate";
-      break;
-    }
-
-  // once the build type is set, determine what configurations are
-  // possible
-  cmsys::ifstream fin(this->DSPHeaderTemplate.c_str());
-
-  cmsys::RegularExpression reg("# Name ");
-  if(!fin)
-    {
-    cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
-    }
-
-  // reset this->Configurations
-  this->Configurations.erase(this->Configurations.begin(),
-                             this->Configurations.end());
-
-  // now add all the configurations possible
-  std::string vs6name = GetVS6TargetName(libName);
-  std::string line;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
-    if (reg.find(line))
-      {
-      this->Configurations.push_back(line.substr(reg.end()));
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-cmsys::auto_ptr<cmCustomCommand>
-cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmGeneratorTarget* target,
-                                                    const std::string& config)
-{
-  cmsys::auto_ptr<cmCustomCommand> pcc;
-
-  // VS6 forgets to create the output directory for archives if it
-  // differs from the intermediate directory.
-  if(target->GetType() != cmState::STATIC_LIBRARY) { return pcc; }
-
-  std::string outDir = target->GetDirectory(config, false);
-
-  // Add a pre-link event to create the directory.
-  cmCustomCommandLine command;
-  command.push_back(cmSystemTools::GetCMakeCommand());
-  command.push_back("-E");
-  command.push_back("make_directory");
-  command.push_back(outDir);
-  std::vector<std::string> no_output;
-  std::vector<std::string> no_byproducts;
-  std::vector<std::string> no_depends;
-  cmCustomCommandLines commands;
-  commands.push_back(command);
-  pcc.reset(new cmCustomCommand(0, no_output, no_byproducts,
-                                no_depends, commands, 0, 0));
-  pcc->SetEscapeOldStyle(false);
-  pcc->SetEscapeAllowMakeVars(true);
-  return pcc;
-}
-
-// look for custom rules on a target and collect them together
-std::string
-cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
-                                              const std::string& configName,
-                                              const std::string& /* libName */)
-{
-  if (target->GetType() >= cmState::UTILITY )
-    {
-    return "";
-    }
-
-  std::string customRuleCode = "# Begin Special Build Tool\n";
-  EventWriter event(this, configName, customRuleCode);
-
-  // Write the pre-build and pre-link together (VS6 does not support both).
-  event.Start("PreLink");
-  event.Write(target->GetPreBuildCommands());
-  event.Write(target->GetPreLinkCommands());
-  cmsys::auto_ptr<cmCustomCommand> pcc(
-    this->MaybeCreateImplibDir(target, configName, false));
-  if(pcc.get())
-    {
-    event.Write(*pcc);
-    }
-  pcc = this->MaybeCreateOutputDir(target, configName);
-  if(pcc.get())
-    {
-    event.Write(*pcc);
-    }
-  event.Finish();
-
-  // Write the post-build rules.
-  event.Start("PostBuild");
-  event.Write(target->GetPostBuildCommands());
-  event.Finish();
-
-  customRuleCode += "# End Special Build Tool\n";
-  return customRuleCode;
-}
-
-
-inline std::string removeQuotes(const std::string& s)
-{
-  if(s[0] == '\"' && s[s.size()-1] == '\"')
-    {
-    return s.substr(1, s.size()-2);
-    }
-  return s;
-}
-
-
-std::string
-cmLocalVisualStudio6Generator::GetTargetIncludeOptions(
-        cmGeneratorTarget *target,
-                                                  const std::string& config)
-{
-  std::string includeOptions;
-
-  // Setup /I and /LIBPATH options for the resulting DSP file.  VS 6
-  // truncates long include paths so make it as short as possible if
-  // the length threatens this problem.
-  unsigned int maxIncludeLength = 3000;
-  bool useShortPath = false;
-
-  for(int j=0; j < 2; ++j)
-    {
-    std::vector<std::string> includes;
-    this->GetIncludeDirectories(includes, target, "C", config);
-
-    std::vector<std::string>::iterator i;
-    for(i = includes.begin(); i != includes.end(); ++i)
-      {
-      std::string tmp =
-        this->ConvertToOutputFormat(i->c_str(), SHELL);
-      if(useShortPath)
-        {
-        cmSystemTools::GetShortPath(tmp.c_str(), tmp);
-        }
-      includeOptions +=  " /I ";
-
-      // quote if not already quoted
-      if (tmp[0] != '"')
-        {
-        includeOptions += "\"";
-        includeOptions += tmp;
-        includeOptions += "\"";
-        }
-      else
-        {
-        includeOptions += tmp;
-        }
-      }
-
-    if(j == 0 && includeOptions.size() > maxIncludeLength)
-      {
-      includeOptions = "";
-      useShortPath = true;
-      }
-    else
-      {
-      break;
-      }
-    }
-
-  return includeOptions;
-}
-
-
-// Code in blocks surrounded by a test for this definition is needed
-// only for compatibility with user project's replacement DSP
-// templates.  The CMake templates no longer use them.
-#define CM_USE_OLD_VS6
-
-void cmLocalVisualStudio6Generator
-::WriteDSPHeader(std::ostream& fout,
-                 const std::string& libName, cmGeneratorTarget* target,
-                 std::vector<cmSourceGroup> &)
-{
-  bool targetBuilds = (target->GetType() >= cmState::EXECUTABLE &&
-                       target->GetType() <= cmState::MODULE_LIBRARY);
-#ifdef CM_USE_OLD_VS6
-  // Lookup the library and executable output directories.
-  std::string libPath;
-  if(this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
-    {
-    libPath = this->Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
-    }
-  std::string exePath;
-  if(this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
-    {
-    exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
-    }
-
-  // Make sure there are trailing slashes.
-  if(!libPath.empty())
-    {
-    if(libPath[libPath.size()-1] != '/')
-      {
-      libPath += "/";
-      }
-    }
-  if(!exePath.empty())
-    {
-    if(exePath[exePath.size()-1] != '/')
-      {
-      exePath += "/";
-      }
-    }
-
-  std::set<std::string> pathEmitted;
-
-  // determine the link directories
-  std::string libOptions;
-  std::string libDebugOptions;
-  std::string libOptimizedOptions;
-
-  std::string libMultiLineOptions;
-  std::string libMultiLineOptionsForDebug;
-  std::string libMultiLineDebugOptions;
-  std::string libMultiLineOptimizedOptions;
-
-  if(!libPath.empty())
-    {
-    std::string lpath =
-      this->ConvertToOutputFormat(libPath.c_str(), SHELL);
-    if(lpath.empty())
-      {
-      lpath = ".";
-      }
-    std::string lpathIntDir = libPath + "$(INTDIR)";
-    lpathIntDir =
-      this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL);
-    if(pathEmitted.insert(lpath).second)
-      {
-      libOptions += " /LIBPATH:";
-      libOptions += lpathIntDir;
-      libOptions += " ";
-      libOptions += " /LIBPATH:";
-      libOptions += lpath;
-      libOptions += " ";
-      libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
-      libMultiLineOptions += lpathIntDir;
-      libMultiLineOptions += " ";
-      libMultiLineOptions += " /LIBPATH:";
-      libMultiLineOptions += lpath;
-      libMultiLineOptions += " \n";
-      libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
-      libMultiLineOptionsForDebug += lpathIntDir;
-      libMultiLineOptionsForDebug += " ";
-      libMultiLineOptionsForDebug += " /LIBPATH:";
-      libMultiLineOptionsForDebug += lpath;
-      libMultiLineOptionsForDebug += " \n";
-      }
-    }
-  if(!exePath.empty())
-    {
-    std::string lpath =
-      this->ConvertToOutputFormat(exePath.c_str(), SHELL);
-    if(lpath.empty())
-      {
-      lpath = ".";
-      }
-    std::string lpathIntDir = exePath + "$(INTDIR)";
-    lpathIntDir =
-      this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL);
-
-    if(pathEmitted.insert(lpath).second)
-      {
-      libOptions += " /LIBPATH:";
-      libOptions += lpathIntDir;
-      libOptions += " ";
-      libOptions += " /LIBPATH:";
-      libOptions += lpath;
-      libOptions += " ";
-      libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
-      libMultiLineOptions += lpathIntDir;
-      libMultiLineOptions += " ";
-      libMultiLineOptions += " /LIBPATH:";
-      libMultiLineOptions += lpath;
-      libMultiLineOptions += " \n";
-      libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
-      libMultiLineOptionsForDebug += lpathIntDir;
-      libMultiLineOptionsForDebug += " ";
-      libMultiLineOptionsForDebug += " /LIBPATH:";
-      libMultiLineOptionsForDebug += lpath;
-      libMultiLineOptionsForDebug += " \n";
-      }
-    }
-  std::vector<std::string>::const_iterator i;
-  const std::vector<std::string>& libdirs =
-      target->GetLinkDirectories();
-  for(i = libdirs.begin(); i != libdirs.end(); ++i)
-    {
-    std::string path = *i;
-    if(path[path.size()-1] != '/')
-      {
-      path += "/";
-      }
-    std::string lpath =
-      this->ConvertToOutputFormat(path.c_str(), SHELL);
-    if(lpath.empty())
-      {
-      lpath = ".";
-      }
-    std::string lpathIntDir = path + "$(INTDIR)";
-    lpathIntDir =
-      this->ConvertToOutputFormat(lpathIntDir.c_str(), SHELL);
-    if(pathEmitted.insert(lpath).second)
-      {
-      libOptions += " /LIBPATH:";
-      libOptions += lpathIntDir;
-      libOptions += " ";
-      libOptions += " /LIBPATH:";
-      libOptions += lpath;
-      libOptions += " ";
-
-      libMultiLineOptions += "# ADD LINK32 /LIBPATH:";
-      libMultiLineOptions += lpathIntDir;
-      libMultiLineOptions += " ";
-      libMultiLineOptions += " /LIBPATH:";
-      libMultiLineOptions += lpath;
-      libMultiLineOptions += " \n";
-      libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
-      libMultiLineOptionsForDebug += lpathIntDir;
-      libMultiLineOptionsForDebug += " ";
-      libMultiLineOptionsForDebug += " /LIBPATH:";
-      libMultiLineOptionsForDebug += lpath;
-      libMultiLineOptionsForDebug += " \n";
-      }
-    }
-  // find link libraries
-  const cmTarget::LinkLibraryVectorType& libs =
-    target->Target->GetLinkLibrariesForVS6();
-  cmTarget::LinkLibraryVectorType::const_iterator j;
-  for(j = libs.begin(); j != libs.end(); ++j)
-    {
-    // add libraries to executables and dlls (but never include
-    // a library in a library, bad recursion)
-    // NEVER LINK STATIC LIBRARIES TO OTHER STATIC LIBRARIES
-    if ((target->GetType() != cmState::SHARED_LIBRARY
-         && target->GetType() != cmState::STATIC_LIBRARY
-         && target->GetType() != cmState::MODULE_LIBRARY) ||
-        (target->GetType()==cmState::SHARED_LIBRARY
-         && libName != GetVS6TargetName(j->first)) ||
-        (target->GetType()==cmState::MODULE_LIBRARY
-         && libName != GetVS6TargetName(j->first)))
-      {
-      // Compute the proper name to use to link this library.
-      std::string lib;
-      std::string libDebug;
-      cmGeneratorTarget* tgt =
-          this->GlobalGenerator->FindGeneratorTarget(j->first.c_str());
-      if(tgt)
-        {
-        lib = cmSystemTools::GetFilenameWithoutExtension
-          (tgt->GetFullName().c_str());
-        libDebug = cmSystemTools::GetFilenameWithoutExtension
-          (tgt->GetFullName("Debug").c_str());
-        lib += ".lib";
-        libDebug += ".lib";
-        }
-      else
-        {
-        lib = j->first.c_str();
-        libDebug = j->first.c_str();
-        if(j->first.find(".lib") == std::string::npos)
-          {
-          lib += ".lib";
-          libDebug += ".lib";
-          }
-        }
-      lib = this->ConvertToOutputFormat(lib.c_str(), SHELL);
-      libDebug =
-        this->ConvertToOutputFormat(libDebug.c_str(), SHELL);
-
-      if (j->second == GENERAL_LibraryType)
-        {
-        libOptions += " ";
-        libOptions += lib;
-        libMultiLineOptions += "# ADD LINK32 ";
-        libMultiLineOptions +=  lib;
-        libMultiLineOptions += "\n";
-        libMultiLineOptionsForDebug += "# ADD LINK32 ";
-        libMultiLineOptionsForDebug +=  libDebug;
-        libMultiLineOptionsForDebug += "\n";
-        }
-      if (j->second == DEBUG_LibraryType)
-        {
-        libDebugOptions += " ";
-        libDebugOptions += lib;
-
-        libMultiLineDebugOptions += "# ADD LINK32 ";
-        libMultiLineDebugOptions += libDebug;
-        libMultiLineDebugOptions += "\n";
-        }
-      if (j->second == OPTIMIZED_LibraryType)
-        {
-        libOptimizedOptions += " ";
-        libOptimizedOptions += lib;
-
-        libMultiLineOptimizedOptions += "# ADD LINK32 ";
-        libMultiLineOptimizedOptions += lib;
-        libMultiLineOptimizedOptions += "\n";
-        }
-      }
-    }
-#endif
-
-  // Get include options for this target.
-  std::string includeOptionsDebug = this->GetTargetIncludeOptions(target,
-                                                                  "DEBUG");
-  std::string includeOptionsRelease = this->GetTargetIncludeOptions(target,
-                                                                  "RELEASE");
-  std::string includeOptionsRelWithDebInfo = this->GetTargetIncludeOptions(
-                                                            target,
-                                                            "RELWITHDEBINFO");
-  std::string includeOptionsMinSizeRel = this->GetTargetIncludeOptions(target,
-                                                                "MINSIZEREL");
-
-  // Get extra linker options for this target type.
-  std::string extraLinkOptions;
-  std::string extraLinkOptionsDebug;
-  std::string extraLinkOptionsRelease;
-  std::string extraLinkOptionsMinSizeRel;
-  std::string extraLinkOptionsRelWithDebInfo;
-  if(target->GetType() == cmState::EXECUTABLE)
-    {
-    extraLinkOptions = this->Makefile->
-      GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
-    extraLinkOptionsDebug = this->Makefile->
-      GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_DEBUG");
-    extraLinkOptionsRelease = this->Makefile->
-      GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELEASE");
-    extraLinkOptionsMinSizeRel = this->Makefile->
-      GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_MINSIZEREL");
-    extraLinkOptionsRelWithDebInfo = this->Makefile->
-      GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO");
-    }
-  if(target->GetType() == cmState::SHARED_LIBRARY)
-    {
-    extraLinkOptions = this->Makefile->
-      GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
-    extraLinkOptionsDebug = this->Makefile->
-      GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_DEBUG");
-    extraLinkOptionsRelease = this->Makefile->
-      GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELEASE");
-    extraLinkOptionsMinSizeRel = this->Makefile->
-      GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL");
-    extraLinkOptionsRelWithDebInfo = this->Makefile->
-      GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO");
-    }
-  if(target->GetType() == cmState::MODULE_LIBRARY)
-    {
-    extraLinkOptions = this->Makefile->
-      GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
-    extraLinkOptionsDebug = this->Makefile->
-      GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_DEBUG");
-    extraLinkOptionsRelease = this->Makefile->
-      GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELEASE");
-    extraLinkOptionsMinSizeRel = this->Makefile->
-      GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL");
-    extraLinkOptionsRelWithDebInfo = this->Makefile->
-      GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO");
-    }
-
-  // Get extra linker options for this target.
-  if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"))
-    {
-    extraLinkOptions += " ";
-    extraLinkOptions += targetLinkFlags;
-    }
-
-  if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_DEBUG"))
-    {
-    extraLinkOptionsDebug += " ";
-    extraLinkOptionsDebug += targetLinkFlags;
-    }
-
-  if(const char* targetLinkFlags = target->GetProperty("LINK_FLAGS_RELEASE"))
-    {
-    extraLinkOptionsRelease += " ";
-    extraLinkOptionsRelease += targetLinkFlags;
-    }
-
-  if(const char* targetLinkFlags =
-     target->GetProperty("LINK_FLAGS_MINSIZEREL"))
-    {
-    extraLinkOptionsMinSizeRel += " ";
-    extraLinkOptionsMinSizeRel += targetLinkFlags;
-    }
-
-  if(const char* targetLinkFlags =
-     target->GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
-    {
-    extraLinkOptionsRelWithDebInfo += " ";
-    extraLinkOptionsRelWithDebInfo += targetLinkFlags;
-    }
-
-  // Get standard libraries for this language.
-  if(targetBuilds)
-    {
-    // Get the language to use for linking.
-    std::vector<std::string> configs;
-    target->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().c_str());
-      return;
-      }
-
-    // Compute the variable name to lookup standard libraries for this
-    // language.
-    std::string standardLibsVar = "CMAKE_";
-    standardLibsVar += linkLanguage;
-    standardLibsVar += "_STANDARD_LIBRARIES";
-
-    // Add standard libraries.
-    if(const char* stdLibs =
-       this->Makefile->GetDefinition(standardLibsVar.c_str()))
-      {
-      extraLinkOptions += " ";
-      extraLinkOptions += stdLibs;
-      }
-    }
-
-  // Compute version number information.
-  std::string targetVersionFlag;
-  if(target->GetType() == cmState::EXECUTABLE ||
-     target->GetType() == cmState::SHARED_LIBRARY ||
-     target->GetType() == cmState::MODULE_LIBRARY)
-    {
-    int major;
-    int minor;
-    target->GetTargetVersion(major, minor);
-    std::ostringstream targetVersionStream;
-    targetVersionStream << "/version:" << major << "." << minor;
-    targetVersionFlag = targetVersionStream.str();
-    }
-
-  // Compute the real name of the target.
-  std::string outputName =
-    "(OUTPUT_NAME is for libraries and executables only)";
-  std::string outputNameDebug = outputName;
-  std::string outputNameRelease = outputName;
-  std::string outputNameMinSizeRel = outputName;
-  std::string outputNameRelWithDebInfo = outputName;
-  if(target->GetType() == cmState::EXECUTABLE ||
-     target->GetType() == cmState::STATIC_LIBRARY ||
-     target->GetType() == cmState::SHARED_LIBRARY ||
-     target->GetType() == cmState::MODULE_LIBRARY)
-    {
-    outputName = target->GetFullName();
-    outputNameDebug = target->GetFullName("Debug");
-    outputNameRelease = target->GetFullName("Release");
-    outputNameMinSizeRel = target->GetFullName("MinSizeRel");
-    outputNameRelWithDebInfo = target->GetFullName("RelWithDebInfo");
-    }
-  else if(target->GetType() == cmState::OBJECT_LIBRARY)
-    {
-    outputName = target->GetName();
-    outputName += ".lib";
-    outputNameDebug = outputName;
-    outputNameRelease = outputName;
-    outputNameMinSizeRel = outputName;
-    outputNameRelWithDebInfo = outputName;
-    }
-
-  // Compute the output directory for the target.
-  std::string outputDirOld;
-  std::string outputDirDebug;
-  std::string outputDirRelease;
-  std::string outputDirMinSizeRel;
-  std::string outputDirRelWithDebInfo;
-  if(target->GetType() == cmState::EXECUTABLE ||
-     target->GetType() == cmState::STATIC_LIBRARY ||
-     target->GetType() == cmState::SHARED_LIBRARY ||
-     target->GetType() == cmState::MODULE_LIBRARY)
-    {
-#ifdef CM_USE_OLD_VS6
-    outputDirOld =
-      removeQuotes(this->ConvertToOutputFormat
-                   (target->GetDirectory().c_str(), SHELL));
-#endif
-    outputDirDebug =
-        removeQuotes(this->ConvertToOutputFormat(
-                       target->GetDirectory("Debug").c_str(), SHELL));
-    outputDirRelease =
-        removeQuotes(this->ConvertToOutputFormat(
-                 target->GetDirectory("Release").c_str(), SHELL));
-    outputDirMinSizeRel =
-        removeQuotes(this->ConvertToOutputFormat(
-                 target->GetDirectory("MinSizeRel").c_str(), SHELL));
-    outputDirRelWithDebInfo =
-        removeQuotes(this->ConvertToOutputFormat(
-                 target->GetDirectory("RelWithDebInfo").c_str(), SHELL));
-    }
-  else if(target->GetType() == cmState::OBJECT_LIBRARY)
-    {
-    std::string outputDir = cmake::GetCMakeFilesDirectoryPostSlash();
-    outputDirDebug = outputDir + "Debug";
-    outputDirRelease = outputDir + "Release";
-    outputDirMinSizeRel = outputDir + "MinSizeRel";
-    outputDirRelWithDebInfo = outputDir + "RelWithDebInfo";
-    }
-
-  // Compute the proper link information for the target.
-  std::string optionsDebug;
-  std::string optionsRelease;
-  std::string optionsMinSizeRel;
-  std::string optionsRelWithDebInfo;
-  if(target->GetType() == cmState::EXECUTABLE ||
-     target->GetType() == cmState::SHARED_LIBRARY ||
-     target->GetType() == cmState::MODULE_LIBRARY)
-    {
-    extraLinkOptionsDebug =
-      extraLinkOptions + " " + extraLinkOptionsDebug;
-    extraLinkOptionsRelease =
-      extraLinkOptions + " " + extraLinkOptionsRelease;
-    extraLinkOptionsMinSizeRel =
-      extraLinkOptions + " " + extraLinkOptionsMinSizeRel;
-    extraLinkOptionsRelWithDebInfo =
-      extraLinkOptions + " " + extraLinkOptionsRelWithDebInfo;
-    this->ComputeLinkOptions(target, "Debug", extraLinkOptionsDebug,
-                             optionsDebug);
-    this->ComputeLinkOptions(target, "Release", extraLinkOptionsRelease,
-                             optionsRelease);
-    this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptionsMinSizeRel,
-                             optionsMinSizeRel);
-    this->ComputeLinkOptions(target, "RelWithDebInfo",
-                             extraLinkOptionsRelWithDebInfo,
-                             optionsRelWithDebInfo);
-    }
-
-  // Compute the path of the import library.
-  std::string targetImplibFlagDebug;
-  std::string targetImplibFlagRelease;
-  std::string targetImplibFlagMinSizeRel;
-  std::string targetImplibFlagRelWithDebInfo;
-  if(target->GetType() == cmState::SHARED_LIBRARY ||
-     target->GetType() == cmState::MODULE_LIBRARY ||
-     target->GetType() == cmState::EXECUTABLE)
-    {
-    std::string fullPathImpDebug = target->GetDirectory("Debug", true);
-    std::string fullPathImpRelease = target->GetDirectory("Release", true);
-    std::string fullPathImpMinSizeRel =
-      target->GetDirectory("MinSizeRel", true);
-    std::string fullPathImpRelWithDebInfo =
-      target->GetDirectory("RelWithDebInfo", true);
-    fullPathImpDebug += "/";
-    fullPathImpRelease += "/";
-    fullPathImpMinSizeRel += "/";
-    fullPathImpRelWithDebInfo += "/";
-    fullPathImpDebug += target->GetFullName("Debug", true);
-    fullPathImpRelease += target->GetFullName("Release", true);
-    fullPathImpMinSizeRel += target->GetFullName("MinSizeRel", true);
-    fullPathImpRelWithDebInfo += target->GetFullName("RelWithDebInfo", true);
-
-    targetImplibFlagDebug = "/implib:";
-    targetImplibFlagRelease = "/implib:";
-    targetImplibFlagMinSizeRel = "/implib:";
-    targetImplibFlagRelWithDebInfo = "/implib:";
-    targetImplibFlagDebug +=
-      this->ConvertToOutputFormat(fullPathImpDebug.c_str(), SHELL);
-    targetImplibFlagRelease +=
-      this->ConvertToOutputFormat(fullPathImpRelease.c_str(), SHELL);
-    targetImplibFlagMinSizeRel +=
-      this->ConvertToOutputFormat(fullPathImpMinSizeRel.c_str(), SHELL);
-    targetImplibFlagRelWithDebInfo +=
-      this->ConvertToOutputFormat(fullPathImpRelWithDebInfo.c_str(), SHELL);
-    }
-
-#ifdef CM_USE_OLD_VS6
-  // Compute link information for the target.
-  if(!extraLinkOptions.empty())
-    {
-    libOptions += " ";
-    libOptions += extraLinkOptions;
-    libOptions += " ";
-    libMultiLineOptions += "# ADD LINK32 ";
-    libMultiLineOptions +=  extraLinkOptions;
-    libMultiLineOptions += " \n";
-    libMultiLineOptionsForDebug += "# ADD LINK32 ";
-    libMultiLineOptionsForDebug +=  extraLinkOptions;
-    libMultiLineOptionsForDebug += " \n";
-    }
-#endif
-
-  // are there any custom rules on the target itself
-  // only if the target is a lib or exe
-  std::string customRuleCodeRelease
-      = this->CreateTargetRules(target, "RELEASE",        libName);
-  std::string customRuleCodeDebug
-      = this->CreateTargetRules(target, "DEBUG",          libName);
-  std::string customRuleCodeMinSizeRel
-      = this->CreateTargetRules(target, "MINSIZEREL",     libName);
-  std::string customRuleCodeRelWithDebInfo
-      = this->CreateTargetRules(target, "RELWITHDEBINFO", libName);
-
-  cmsys::ifstream fin(this->DSPHeaderTemplate.c_str());
-  if(!fin)
-    {
-    cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str());
-    }
-  std::string staticLibOptions;
-  std::string staticLibOptionsDebug;
-  std::string staticLibOptionsRelease;
-  std::string staticLibOptionsMinSizeRel;
-  std::string staticLibOptionsRelWithDebInfo;
-  if(target->GetType() == cmState::STATIC_LIBRARY )
-    {
-    const char *libflagsGlobal =
-      this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS");
-    this->AppendFlags(staticLibOptions, libflagsGlobal);
-    this->AppendFlags(staticLibOptionsDebug, libflagsGlobal);
-    this->AppendFlags(staticLibOptionsRelease, libflagsGlobal);
-    this->AppendFlags(staticLibOptionsMinSizeRel, libflagsGlobal);
-    this->AppendFlags(staticLibOptionsRelWithDebInfo, libflagsGlobal);
-
-    this->AppendFlags(staticLibOptionsDebug, this->Makefile->
-      GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_DEBUG"));
-    this->AppendFlags(staticLibOptionsRelease, this->Makefile->
-      GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELEASE"));
-    this->AppendFlags(staticLibOptionsMinSizeRel, this->Makefile->
-      GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL"));
-    this->AppendFlags(staticLibOptionsRelWithDebInfo, this->Makefile->
-      GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO"));
-
-    const char *libflags = target->GetProperty("STATIC_LIBRARY_FLAGS");
-    this->AppendFlags(staticLibOptions, libflags);
-    this->AppendFlags(staticLibOptionsDebug, libflags);
-    this->AppendFlags(staticLibOptionsRelease, libflags);
-    this->AppendFlags(staticLibOptionsMinSizeRel, libflags);
-    this->AppendFlags(staticLibOptionsRelWithDebInfo, libflags);
-
-    this->AppendFlags(staticLibOptionsDebug,
-      target->GetProperty("STATIC_LIBRARY_FLAGS_DEBUG"));
-    this->AppendFlags(staticLibOptionsRelease,
-      target->GetProperty("STATIC_LIBRARY_FLAGS_RELEASE"));
-    this->AppendFlags(staticLibOptionsMinSizeRel,
-      target->GetProperty("STATIC_LIBRARY_FLAGS_MINSIZEREL"));
-    this->AppendFlags(staticLibOptionsRelWithDebInfo,
-      target->GetProperty("STATIC_LIBRARY_FLAGS_RELWITHDEBINFO"));
-
-    std::string objects;
-    this->OutputObjects(target, "LIB", objects);
-    if(!objects.empty())
-      {
-      objects = "\n" + objects;
-      staticLibOptionsDebug += objects;
-      staticLibOptionsRelease += objects;
-      staticLibOptionsMinSizeRel += objects;
-      staticLibOptionsRelWithDebInfo += objects;
-      }
-    }
-
-  // Add the export symbol definition for shared library objects.
-  std::string exportSymbol;
-  if(const char* exportMacro = target->GetExportMacro())
-    {
-    exportSymbol = exportMacro;
-    }
-
-  std::string line;
-  std::string libnameExports;
-  if(!exportSymbol.empty())
-    {
-    libnameExports = "/D \"";
-    libnameExports += exportSymbol;
-    libnameExports += "\"";
-    }
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
-    if(!mfcFlag)
-      {
-      mfcFlag = "0";
-      }
-    cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS",
-                                 libnameExports.c_str());
-    cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG",
-                                 mfcFlag);
-    if(target->GetType() == cmState::STATIC_LIBRARY ||
-       target->GetType() == cmState::OBJECT_LIBRARY)
-      {
-      cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_DEBUG",
-                                   staticLibOptionsDebug.c_str());
-      cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELEASE",
-                                   staticLibOptionsRelease.c_str());
-      cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_MINSIZEREL",
-                                   staticLibOptionsMinSizeRel.c_str());
-      cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS_RELWITHDEBINFO",
-                                   staticLibOptionsRelWithDebInfo.c_str());
-      cmSystemTools::ReplaceString(line, "CM_STATIC_LIB_ARGS",
-                                   staticLibOptions.c_str());
-      }
-    if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
-      {
-      cmSystemTools::ReplaceString(line, "/nologo", "");
-      }
-
-#ifdef CM_USE_OLD_VS6
-    cmSystemTools::ReplaceString(line, "CM_LIBRARIES",
-                                 libOptions.c_str());
-    cmSystemTools::ReplaceString(line, "CM_DEBUG_LIBRARIES",
-                                 libDebugOptions.c_str());
-    cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
-                                 libOptimizedOptions.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG",
-                                 libMultiLineOptionsForDebug.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES",
-                                 libMultiLineOptions.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES",
-                                 libMultiLineDebugOptions.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIMIZED_LIBRARIES",
-                                 libMultiLineOptimizedOptions.c_str());
-#endif
-
-    // Substitute the rules for custom command. When specifying just the
-    // target name for the command the command can be different for
-    // different configs
-    cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELEASE",
-                                 customRuleCodeRelease.c_str());
-    cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_DEBUG",
-                                 customRuleCodeDebug.c_str());
-    cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_MINSIZEREL",
-                                 customRuleCodeMinSizeRel.c_str());
-    cmSystemTools::ReplaceString(line, "CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO",
-                                 customRuleCodeRelWithDebInfo.c_str());
-
-    // Substitute the real output name into the template.
-    cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG",
-                                 outputNameDebug.c_str());
-    cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE",
-                                 outputNameRelease.c_str());
-    cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL",
-                                 outputNameMinSizeRel.c_str());
-    cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO",
-                                 outputNameRelWithDebInfo.c_str());
-    cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str());
-
-    // Substitute the proper link information into the template.
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG",
-                                 optionsDebug.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE",
-                                 optionsRelease.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL",
-                                 optionsMinSizeRel.c_str());
-    cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO",
-                                 optionsRelWithDebInfo.c_str());
-
-    cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_DEBUG",
-                                 includeOptionsDebug.c_str());
-    cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELEASE",
-                                 includeOptionsRelease.c_str());
-    cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_MINSIZEREL",
-                                 includeOptionsMinSizeRel.c_str());
-    cmSystemTools::ReplaceString(line, "BUILD_INCLUDES_RELWITHDEBINFO",
-                                 includeOptionsRelWithDebInfo.c_str());
-
-    cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG",
-                                 targetVersionFlag.c_str());
-    cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG",
-                                 targetImplibFlagDebug.c_str());
-    cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELEASE",
-                                 targetImplibFlagRelease.c_str());
-    cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_MINSIZEREL",
-                                 targetImplibFlagMinSizeRel.c_str());
-    cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELWITHDEBINFO",
-                                 targetImplibFlagRelWithDebInfo.c_str());
-
-    std::string vs6name = GetVS6TargetName(libName);
-    cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
-
-#ifdef CM_USE_OLD_VS6
-    // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
-    // are already quoted in the template file,
-    // we need to remove the quotes here, we still need
-    // to convert to output path for unix to win32 conversion
-    cmSystemTools::ReplaceString
-      (line, "LIBRARY_OUTPUT_PATH",
-       removeQuotes(this->ConvertToOutputFormat
-                    (libPath.c_str(), SHELL)).c_str());
-    cmSystemTools::ReplaceString
-      (line, "EXECUTABLE_OUTPUT_PATH",
-       removeQuotes(this->ConvertToOutputFormat
-                    (exePath.c_str(), SHELL)).c_str());
-#endif
-
-    if(targetBuilds || target->GetType() == cmState::OBJECT_LIBRARY)
-      {
-      cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_DEBUG",
-                                   outputDirDebug.c_str());
-      cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELEASE",
-                                   outputDirRelease.c_str());
-      cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_MINSIZEREL",
-                                   outputDirMinSizeRel.c_str());
-      cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY_RELWITHDEBINFO",
-                                   outputDirRelWithDebInfo.c_str());
-      if(!outputDirOld.empty())
-        {
-        cmSystemTools::ReplaceString(line, "OUTPUT_DIRECTORY",
-                                     outputDirOld.c_str());
-        }
-      }
-
-    cmSystemTools::ReplaceString(line,
-                                 "EXTRA_DEFINES",
-                                 this->Makefile->GetDefineFlags());
-    const char* debugPostfix
-      = this->Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
-    cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX",
-                                 debugPostfix?debugPostfix:"");
-    if(target->GetType() >= cmState::EXECUTABLE &&
-       target->GetType() <= cmState::OBJECT_LIBRARY)
-      {
-      // store flags for each configuration
-      std::string flags = " ";
-      std::string flagsRelease = " ";
-      std::string flagsMinSizeRel = " ";
-      std::string flagsDebug = " ";
-      std::string flagsRelWithDebInfo = " ";
-      std::vector<std::string> configs;
-      target->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().c_str());
-        return;
-        }
-      // if CXX is on and the target contains cxx code then add the cxx flags
-      std::string baseFlagVar = "CMAKE_";
-      baseFlagVar += linkLanguage;
-      baseFlagVar += "_FLAGS";
-      flags = this->Makefile->GetSafeDefinition(baseFlagVar.c_str());
-
-      std::string flagVar = baseFlagVar + "_RELEASE";
-      flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str());
-      flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
-
-      flagVar = baseFlagVar + "_MINSIZEREL";
-      flagsMinSizeRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
-      flagsMinSizeRel += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
-
-      flagVar = baseFlagVar + "_DEBUG";
-      flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str());
-      flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
-
-      flagVar = baseFlagVar + "_RELWITHDEBINFO";
-      flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str());
-      flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
-
-      this->AddCompileOptions(flags, target, linkLanguage, "");
-      this->AddCompileOptions(flagsDebug, target, linkLanguage, "Debug");
-      this->AddCompileOptions(flagsRelease, target, linkLanguage, "Release");
-      this->AddCompileOptions(flagsMinSizeRel, target, linkLanguage,
-                              "MinSizeRel");
-      this->AddCompileOptions(flagsRelWithDebInfo, target, linkLanguage,
-                              "RelWithDebInfo");
-
-      // if _UNICODE and _SBCS are not found, then add -D_MBCS
-      std::string defs = this->Makefile->GetDefineFlags();
-      if(flags.find("D_UNICODE") == flags.npos &&
-         defs.find("D_UNICODE") == flags.npos &&
-         flags.find("D_SBCS") == flags.npos &&
-         defs.find("D_SBCS") == flags.npos)
-        {
-        flags += " /D \"_MBCS\"";
-        }
-
-      // Add per-target and per-configuration preprocessor definitions.
-      std::set<std::string> definesSet;
-      std::set<std::string> debugDefinesSet;
-      std::set<std::string> releaseDefinesSet;
-      std::set<std::string> minsizeDefinesSet;
-      std::set<std::string> debugrelDefinesSet;
-
-      this->AddCompileDefinitions(definesSet, target, "", linkLanguage);
-      this->AddCompileDefinitions(debugDefinesSet, target,
-                                  "DEBUG", linkLanguage);
-      this->AddCompileDefinitions(releaseDefinesSet, target,
-                                  "RELEASE", linkLanguage);
-      this->AddCompileDefinitions(minsizeDefinesSet, target,
-                                  "MINSIZEREL", linkLanguage);
-      this->AddCompileDefinitions(debugrelDefinesSet, target,
-                                  "RELWITHDEBINFO", linkLanguage);
-
-      std::string defines = " ";
-      std::string debugDefines = " ";
-      std::string releaseDefines = " ";
-      std::string minsizeDefines = " ";
-      std::string debugrelDefines = " ";
-
-      this->JoinDefines(definesSet, defines, "");
-      this->JoinDefines(debugDefinesSet, debugDefines, "");
-      this->JoinDefines(releaseDefinesSet, releaseDefines, "");
-      this->JoinDefines(minsizeDefinesSet, minsizeDefines, "");
-      this->JoinDefines(debugrelDefinesSet, debugrelDefines, "");
-
-      flags += defines;
-      flagsDebug += debugDefines;
-      flagsRelease += releaseDefines;
-      flagsMinSizeRel += minsizeDefines;
-      flagsRelWithDebInfo += debugrelDefines;
-
-      // The template files have CXX FLAGS in them, that need to be replaced.
-      // There are not separate CXX and C template files, so we use the same
-      // variable names.   The previous code sets up flags* variables to
-      // contain the correct C or CXX flags
-      cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL",
-                                   flagsMinSizeRel.c_str());
-      cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG",
-                                   flagsDebug.c_str());
-      cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
-                                   flagsRelWithDebInfo.c_str());
-      cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE",
-                                   flagsRelease.c_str());
-      cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
-
-      cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_MINSIZEREL",
-                                   minsizeDefines.c_str());
-      cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_DEBUG",
-                                   debugDefines.c_str());
-      cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELWITHDEBINFO",
-                                   debugrelDefines.c_str());
-      cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS_RELEASE",
-                                   releaseDefines.c_str());
-      cmSystemTools::ReplaceString(line, "COMPILE_DEFINITIONS",
-                                   defines.c_str());
-      }
-
-    fout << line.c_str() << std::endl;
-    }
-}
-
-void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
-{
-  cmsys::ifstream fin(this->DSPFooterTemplate.c_str());
-  if(!fin)
-    {
-    cmSystemTools::Error("Error Reading ",
-                         this->DSPFooterTemplate.c_str());
-    }
-  std::string line;
-  while(cmSystemTools::GetLineFromStream(fin, line))
-    {
-    fout << line << std::endl;
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmLocalVisualStudio6Generator
-::ComputeLinkOptions(cmGeneratorTarget *target,
-                     const std::string& configName,
-                     const std::string extraOptions,
-                     std::string& options)
-{
-  // Compute the link information for this configuration.
-  cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
-  if(!pcli)
-    {
-    return;
-    }
-  cmComputeLinkInformation& cli = *pcli;
-  typedef cmComputeLinkInformation::ItemVector ItemVector;
-  ItemVector const& linkLibs = cli.GetItems();
-  std::vector<std::string> const& linkDirs = cli.GetDirectories();
-
-  this->OutputObjects(target, "LINK", options);
-
-  // Build the link options code.
-  for(std::vector<std::string>::const_iterator d = linkDirs.begin();
-      d != linkDirs.end(); ++d)
-    {
-    std::string dir = *d;
-    if(!dir.empty())
-      {
-      if(dir[dir.size()-1] != '/')
-        {
-        dir += "/";
-        }
-      dir += "$(IntDir)";
-      options += "# ADD LINK32 /LIBPATH:";
-      options += this->ConvertToOutputFormat(dir.c_str(), SHELL);
-      options += " /LIBPATH:";
-      options += this->ConvertToOutputFormat(d->c_str(), SHELL);
-      options += "\n";
-      }
-    }
-  for(ItemVector::const_iterator l = linkLibs.begin();
-      l != linkLibs.end(); ++l)
-    {
-    options += "# ADD LINK32 ";
-    if(l->IsPath)
-      {
-      options +=
-        this->ConvertToOutputFormat(l->Value.c_str(), SHELL);
-      }
-    else if (!l->Target
-        || l->Target->GetType() != cmState::INTERFACE_LIBRARY)
-      {
-      options += l->Value;
-      }
-    options += "\n";
-    }
-
-  // Add extra options if any.
-  if(!extraOptions.empty())
-    {
-    options += "# ADD LINK32 ";
-    options += extraOptions;
-    options += "\n";
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmLocalVisualStudio6Generator
-::OutputObjects(cmGeneratorTarget* target, const char* tool,
-                std::string& options)
-{
-  // VS 6 does not support per-config source locations so we
-  // list object library content on the link line instead.
-  std::vector<std::string> objs;
-  target->UseObjectLibraries(objs, "");
-  for(std::vector<std::string>::const_iterator
-        oi = objs.begin(); oi != objs.end(); ++oi)
-    {
-    options += "# ADD ";
-    options += tool;
-    options += "32 ";
-    options += this->ConvertToOutputFormat(oi->c_str(), SHELL);
-    options += "\n";
-    }
-}
-
-std::string
-cmLocalVisualStudio6Generator
-::GetTargetDirectory(cmGeneratorTarget const*) const
-{
-  // No per-target directory for this generator (yet).
-  return "";
-}
-
-//----------------------------------------------------------------------------
-std::string
-cmLocalVisualStudio6Generator
-::ComputeLongestObjectDirectory(cmGeneratorTarget const*) const
-{
-  // Compute the maximum length configuration name.
-  std::string config_max;
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
-    // Strip the subdirectory name out of the configuration name.
-    std::string config = this->GetConfigName(*i);
-    if(config.size() > config_max.size())
-      {
-      config_max = config;
-      }
-    }
-
-  // Compute the maximum length full path to the intermediate
-  // files directory for any configuration.  This is used to construct
-  // object file names that do not produce paths that are too long.
-  std::string dir_max;
-  dir_max += this->GetCurrentBinaryDirectory();
-  dir_max += "/";
-  dir_max += config_max;
-  dir_max += "/";
-  return dir_max;
-}
-
-std::string
-cmLocalVisualStudio6Generator
-::GetConfigName(std::string const& configuration) const
-{
-  // Strip the subdirectory name out of the configuration name.
-  std::string config = configuration;
-  std::string::size_type pos = config.find_last_of(" ");
-  config = config.substr(pos+1, std::string::npos);
-  config = config.substr(0, config.size()-1);
-  return config;
-}
-
-//----------------------------------------------------------------------------
-bool
-cmLocalVisualStudio6Generator
-::CheckDefinition(std::string const& define) const
-{
-  // Perform the standard check first.
-  if(!this->cmLocalGenerator::CheckDefinition(define))
-    {
-    return false;
-    }
-
-  // Now do the VS6-specific check.
-  if(define.find_first_of(" ") != define.npos &&
-     define.find_first_of("\"$;") != define.npos)
-    {
-    std::ostringstream e;
-    e << "WARNING: The VS6 IDE does not support preprocessor definition "
-      << "values with spaces and '\"', '$', or ';'.\n"
-      << "CMake is dropping a preprocessor definition: " << define << "\n"
-      << "Consider defining the macro in a (configured) header file.\n";
-    cmSystemTools::Message(e.str().c_str());
-    return false;
-    }
-
-  // Assume it is supported.
-  return true;
-}
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
deleted file mode 100644
index dab32a5..0000000
--- a/Source/cmLocalVisualStudio6Generator.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-#ifndef cmLocalVisualStudio6Generator_h
-#define cmLocalVisualStudio6Generator_h
-
-#include "cmLocalVisualStudioGenerator.h"
-
-class cmSourceFile;
-class cmSourceGroup;
-class cmCustomCommand;
-
-/** \class cmLocalVisualStudio6Generator
- * \brief Write a LocalUnix makefiles.
- *
- * cmLocalVisualStudio6Generator produces a LocalUnix makefile from its
- * member this->Makefile.
- */
-class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
-{
-public:
-  ///! Set cache only and recurse to false by default.
-  cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf);
-
-  virtual ~cmLocalVisualStudio6Generator();
-
-  virtual void AddCMakeListsRules();
-
-  /**
-   * Generate the makefile for this directory.
-   */
-  virtual void Generate();
-
-  void OutputDSPFile();
-
-  enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY};
-
-  /**
-   * Specify the type of the build: static, dll, or executable.
-   */
-  void SetBuildType(BuildType, const std::string& libName, cmGeneratorTarget*);
-
-  virtual
-  std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
-  virtual std::string
-  ComputeLongestObjectDirectory(cmGeneratorTarget const*) const;
-private:
-  std::string DSPHeaderTemplate;
-  std::string DSPFooterTemplate;
-
-  void CreateSingleDSP(const std::string& lname, cmGeneratorTarget* tgt);
-  void WriteDSPFile(std::ostream& fout, const std::string& libName,
-                    cmGeneratorTarget* tgt);
-  void WriteDSPBeginGroup(std::ostream& fout,
-                          const char* group,
-                          const char* filter);
-  void WriteDSPEndGroup(std::ostream& fout);
-
-  void WriteDSPHeader(std::ostream& fout, const std::string& libName,
-                      cmGeneratorTarget* tgt, std::vector<cmSourceGroup> &sgs);
-
-  void WriteDSPFooter(std::ostream& fout);
-  void AddDSPBuildRule(cmGeneratorTarget* tgt);
-  void WriteCustomRule(std::ostream& fout,
-                       const char* source,
-                       const cmCustomCommand& command,
-                       const char* flags);
-  void AddUtilityCommandHack(cmGeneratorTarget* target, int count,
-                             std::vector<std::string>& depends,
-                             const cmCustomCommand& origCommand);
-  void WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target,
-                  std::ostream &fout, const std::string& libName);
-  class EventWriter;
-  friend class EventWriter;
-  cmsys::auto_ptr<cmCustomCommand>
-  MaybeCreateOutputDir(cmGeneratorTarget *target, const std::string& config);
-  std::string CreateTargetRules(cmGeneratorTarget* target,
-                                const std::string& configName,
-                                const std::string& libName);
-  void ComputeLinkOptions(cmGeneratorTarget* target,
-                          const std::string& configName,
-                          const std::string extraOptions,
-                          std::string& options);
-  void OutputObjects(cmGeneratorTarget* target, const char* tool,
-                     std::string& options);
-  std::string GetTargetIncludeOptions(cmGeneratorTarget* target,
-                                      const std::string& config);
-  std::vector<std::string> Configurations;
-
-  std::string GetConfigName(std::string const& configuration) const;
-
-  // Special definition check for VS6.
-  virtual bool CheckDefinition(std::string const& define) const;
-};
-
-#endif
-
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index ae6a24e..6e7d7d2 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -9,33 +9,37 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include "cmGlobalVisualStudio7Generator.h"
 #include "cmLocalVisualStudio7Generator.h"
-#include "cmXMLParser.h"
-#include <cm_expat.h>
+
+#include "cmCustomCommandGenerator.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalVisualStudio7Generator.h"
 #include "cmMakefile.h"
-#include "cmSystemTools.h"
 #include "cmSourceFile.h"
-#include "cmGeneratorTarget.h"
-#include "cmCustomCommandGenerator.h"
+#include "cmSystemTools.h"
+#include "cmXMLParser.h"
 #include "cmake.h"
+#include <cm_expat.h>
 
 #include "cmComputeLinkInformation.h"
 #include "cmGeneratedFileStream.h"
 
 #include <ctype.h> // for isspace
 
-static bool cmLVS6G_IsFAT(const char* dir);
+static bool cmLVS7G_IsFAT(const char* dir);
 
 class cmLocalVisualStudio7GeneratorInternals
 {
 public:
-  cmLocalVisualStudio7GeneratorInternals(cmLocalVisualStudio7Generator* e):
-    LocalGenerator(e) {}
+  cmLocalVisualStudio7GeneratorInternals(cmLocalVisualStudio7Generator* e)
+    : LocalGenerator(e)
+  {
+  }
   typedef cmComputeLinkInformation::ItemVector ItemVector;
   void OutputLibraries(std::ostream& fout, ItemVector const& libs);
   void OutputObjects(std::ostream& fout, cmGeneratorTarget* t,
                      const char* isep = 0);
+
 private:
   cmLocalVisualStudio7Generator* LocalGenerator;
 };
@@ -45,17 +49,15 @@ extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[];
 static void cmConvertToWindowsSlash(std::string& s)
 {
   std::string::size_type pos = 0;
-  while((pos = s.find('/', pos)) != std::string::npos)
-    {
+  while ((pos = s.find('/', pos)) != std::string::npos) {
     s[pos] = '\\';
     pos++;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmLocalVisualStudio7Generator
-::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf):
-  cmLocalVisualStudioGenerator(gg, mf)
+cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(
+  cmGlobalGenerator* gg, cmMakefile* mf)
+  : cmLocalVisualStudioGenerator(gg, mf)
 {
   this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
 }
@@ -69,21 +71,16 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
 {
   // Now create GUIDs for targets
   std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); ++l)
-    {
-    if((*l)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+       l != tgts.end(); ++l) {
+    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     const char* path = (*l)->GetProperty("EXTERNAL_MSPROJECT");
-    if(path)
-      {
-      this->ReadAndStoreExternalGUID(
-        (*l)->GetName().c_str(), path);
-      }
+    if (path) {
+      this->ReadAndStoreExternalGUID((*l)->GetName().c_str(), path);
     }
-
+  }
 
   this->FixGlobalTargets();
 }
@@ -97,28 +94,23 @@ void cmLocalVisualStudio7Generator::Generate()
 void cmLocalVisualStudio7Generator::AddCMakeListsRules()
 {
   // Create the regeneration custom rule.
-  if(!this->Makefile->IsOn("CMAKE_SUPPRESS_REGENERATION"))
-    {
+  if (!this->Makefile->IsOn("CMAKE_SUPPRESS_REGENERATION")) {
     // Create a rule to regenerate the build system when the target
     // specification source changes.
-    if(cmSourceFile* sf = this->CreateVCProjBuildRule())
-      {
+    if (cmSourceFile* sf = this->CreateVCProjBuildRule()) {
       // Add the rule to targets that need it.
       std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-      for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-          l != tgts.end(); ++l)
-        {
-        if ((*l)->GetType() == cmState::GLOBAL_TARGET)
-          {
+      for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+           l != tgts.end(); ++l) {
+        if ((*l)->GetType() == cmState::GLOBAL_TARGET) {
           continue;
-          }
-        if((*l)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
-          {
+        }
+        if ((*l)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
           (*l)->AddSource(sf->GetFullPath());
-          }
         }
       }
     }
+  }
 }
 
 void cmLocalVisualStudio7Generator::FixGlobalTargets()
@@ -127,11 +119,9 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
   // commands for targets in which no sources are built.  Add dummy
   // rules to force these targets to build.
   std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); l++)
-    {
-    if((*l)->GetType() == cmState::GLOBAL_TARGET)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+       l != tgts.end(); l++) {
+    if ((*l)->GetType() == cmState::GLOBAL_TARGET) {
       std::vector<std::string> no_depends;
       cmCustomCommandLine force_command;
       force_command.push_back("cd");
@@ -144,15 +134,13 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
       force += "/";
       force += (*l)->GetName();
       force += "_force";
-      if(cmSourceFile* file =
-         this->Makefile->AddCustomCommandToOutput(
-           force.c_str(), no_depends, no_main_dependency,
-           force_commands, " ", 0, true))
-        {
+      if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput(
+            force.c_str(), no_depends, no_main_dependency, force_commands, " ",
+            0, true)) {
         (*l)->AddSource(file->GetFullPath());
-        }
       }
     }
+  }
 }
 
 // TODO
@@ -161,38 +149,31 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
 void cmLocalVisualStudio7Generator::WriteProjectFiles()
 {
   // If not an in source build, then create the output directory
-  if(strcmp(this->GetCurrentBinaryDirectory(),
-            this->GetSourceDirectory()) != 0)
-    {
-    if(!cmSystemTools::MakeDirectory
-       (this->GetCurrentBinaryDirectory()))
-      {
+  if (strcmp(this->GetCurrentBinaryDirectory(), this->GetSourceDirectory()) !=
+      0) {
+    if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) {
       cmSystemTools::Error("Error creating directory ",
                            this->GetCurrentBinaryDirectory());
-      }
     }
+  }
 
   // Get the set of targets in this directory.
   std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
 
   // Create the project file for each target.
-  for(std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
-      l != tgts.end(); l++)
-    {
-    if((*l)->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+  for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
+       l != tgts.end(); l++) {
+    if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
     // so don't build a projectfile for it
-    if(!(*l)->GetProperty("EXTERNAL_MSPROJECT"))
-      {
+    if (!(*l)->GetProperty("EXTERNAL_MSPROJECT")) {
       this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalVisualStudio7Generator::WriteStampFiles()
 {
   // Touch a timestamp file used to determine when the project file is
@@ -216,61 +197,53 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
   cmsys::ofstream depFile(depName.c_str());
   depFile << "# CMake generation dependency list for this directory.\n";
   std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
-  for(std::vector<std::string>::const_iterator lf = listFiles.begin();
-      lf != listFiles.end(); ++lf)
-    {
+  for (std::vector<std::string>::const_iterator lf = listFiles.begin();
+       lf != listFiles.end(); ++lf) {
     depFile << *lf << std::endl;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmLocalVisualStudio7Generator
-::CreateSingleVCProj(const std::string& lname, cmGeneratorTarget *target)
+void cmLocalVisualStudio7Generator::CreateSingleVCProj(
+  const std::string& lname, cmGeneratorTarget* target)
 {
-  cmGlobalVisualStudioGenerator* gg
-      = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
+  cmGlobalVisualStudioGenerator* gg =
+    static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
   this->FortranProject = gg->TargetIsFortranOnly(target);
   this->WindowsCEProject = gg->TargetsWindowsCE();
 
   // Intel Fortran for VS10 uses VS9 format ".vfproj" files.
   cmGlobalVisualStudioGenerator::VSVersion realVersion = gg->GetVersion();
-  if(this->FortranProject
-      && gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS10)
-    {
+  if (this->FortranProject &&
+      gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS10) {
     gg->SetVersion(cmGlobalVisualStudioGenerator::VS9);
-    }
+  }
 
   // add to the list of projects
-  target->Target->SetProperty("GENERATOR_FILE_NAME",lname.c_str());
+  target->Target->SetProperty("GENERATOR_FILE_NAME", lname.c_str());
   // create the dsp.cmake file
   std::string fname;
   fname = this->GetCurrentBinaryDirectory();
   fname += "/";
   fname += lname;
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     fname += ".vfproj";
-    }
-  else
-    {
+  } else {
     fname += ".vcproj";
-    }
+  }
 
   // Generate the project file and replace it atomically with
   // copy-if-different.  We use a separate timestamp so that the IDE
   // does not reload project files unnecessarily.
   cmGeneratedFileStream fout(fname.c_str());
   fout.SetCopyIfDifferent(true);
-  this->WriteVCProjFile(fout,lname,target);
-  if (fout.Close())
-    {
+  this->WriteVCProjFile(fout, lname, target);
+  if (fout.Close()) {
     this->GlobalGenerator->FileReplacedDuringGenerate(fname);
-    }
+  }
 
   gg->SetVersion(realVersion);
 }
 
-//----------------------------------------------------------------------------
 cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
 {
   std::string stampName = this->GetCurrentBinaryDirectory();
@@ -283,10 +256,9 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
   makefileIn += "/";
   makefileIn += "CMakeLists.txt";
   makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str());
-  if(!cmSystemTools::FileExists(makefileIn.c_str()))
-    {
+  if (!cmSystemTools::FileExists(makefileIn.c_str())) {
     return 0;
-    }
+  }
   std::string comment = "Building Custom Rule ";
   comment += makefileIn;
   std::string args;
@@ -297,8 +269,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
   args += this->GetBinaryDirectory();
   commandLine.push_back(args);
   commandLine.push_back("--check-stamp-file");
-  std::string stampFilename = this->Convert(stampName.c_str(), FULL,
-                                            SHELL);
+  std::string stampFilename = this->Convert(
+    stampName.c_str(), cmOutputConverter::FULL, cmOutputConverter::SHELL);
   commandLine.push_back(stampFilename.c_str());
 
   std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
@@ -306,333 +278,322 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
   cmCustomCommandLines commandLines;
   commandLines.push_back(commandLine);
   const char* no_working_directory = 0;
-  std::string fullpathStampName = this->Convert(stampName.c_str(), FULL,
-                                            UNCHANGED);
-  this->Makefile->AddCustomCommandToOutput(fullpathStampName.c_str(),
-                                           listFiles, makefileIn.c_str(),
-                                           commandLines, comment.c_str(),
-                                           no_working_directory, true);
-  if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str()))
-    {
+  std::string fullpathStampName = this->Convert(
+    stampName.c_str(), cmOutputConverter::FULL, cmOutputConverter::UNCHANGED);
+  this->Makefile->AddCustomCommandToOutput(
+    fullpathStampName.c_str(), listFiles, makefileIn.c_str(), commandLines,
+    comment.c_str(), no_working_directory, true);
+  if (cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) {
     return file;
-    }
-  else
-    {
+  } else {
     cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
     return 0;
-    }
+  }
 }
 
 void cmLocalVisualStudio7Generator::WriteConfigurations(
-    std::ostream& fout,
-    std::vector<std::string> const& configs,
-  const std::string& libName, cmGeneratorTarget *target
-  )
+  std::ostream& fout, std::vector<std::string> const& configs,
+  const std::string& libName, cmGeneratorTarget* target)
 {
   fout << "\t<Configurations>\n";
   for (std::vector<std::string>::const_iterator i = configs.begin();
-       i != configs.end(); ++i)
-    {
+       i != configs.end(); ++i) {
     this->WriteConfiguration(fout, i->c_str(), libName, target);
-    }
+  }
   fout << "\t</Configurations>\n";
 }
-cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] =
-{
-  {"Preprocess", "fpp", "Run Preprocessor on files", "preprocessYes", 0},
-  {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0},
-  {"SourceFileFormat", "fixed", "Use Fixed Format", "fileFormatFixed", 0},
-  {"SourceFileFormat", "free", "Use Free Format", "fileFormatFree", 0},
-  {"DebugInformationFormat", "Zi", "full debug", "debugEnabled", 0},
-  {"DebugInformationFormat", "debug:full", "full debug", "debugEnabled", 0},
-  {"DebugInformationFormat", "Z7", "c7 compat", "debugOldStyleInfo", 0},
-  {"DebugInformationFormat", "Zd", "line numbers", "debugLineInfoOnly", 0},
-  {"Optimization", "Od", "disable optimization", "optimizeDisabled", 0},
-  {"Optimization", "O1", "min space", "optimizeMinSpace", 0},
-  {"Optimization", "O3", "full optimize", "optimizeFull", 0},
-  {"GlobalOptimizations", "Og", "global optimize", "true", 0},
-  {"InlineFunctionExpansion", "Ob0", "", "expandDisable", 0},
-  {"InlineFunctionExpansion", "Ob1", "", "expandOnlyInline", 0},
-  {"FavorSizeOrSpeed", "Os", "", "favorSize", 0},
-  {"OmitFramePointers", "Oy-", "", "false", 0},
-  {"OptimizeForProcessor", "GB", "", "procOptimizeBlended", 0},
-  {"OptimizeForProcessor", "G5", "", "procOptimizePentium", 0},
-  {"OptimizeForProcessor", "G6", "", "procOptimizePentiumProThruIII", 0},
-  {"UseProcessorExtensions", "QzxK", "", "codeForStreamingSIMD", 0},
-  {"OptimizeForProcessor", "QaxN", "", "codeForPentium4", 0},
-  {"OptimizeForProcessor", "QaxB", "", "codeForPentiumM", 0},
-  {"OptimizeForProcessor", "QaxP", "", "codeForCodeNamedPrescott", 0},
-  {"OptimizeForProcessor", "QaxT", "", "codeForCore2Duo", 0},
-  {"OptimizeForProcessor", "QxK", "", "codeExclusivelyStreamingSIMD", 0},
-  {"OptimizeForProcessor", "QxN", "", "codeExclusivelyPentium4", 0},
-  {"OptimizeForProcessor", "QxB", "", "codeExclusivelyPentiumM", 0},
-  {"OptimizeForProcessor", "QxP", "", "codeExclusivelyCodeNamedPrescott", 0},
-  {"OptimizeForProcessor", "QxT", "", "codeExclusivelyCore2Duo", 0},
-  {"OptimizeForProcessor", "QxO", "", "codeExclusivelyCore2StreamingSIMD", 0},
-  {"OptimizeForProcessor", "QxS", "", "codeExclusivelyCore2StreamingSIMD4", 0},
-  {"OpenMP", "Qopenmp", "", "OpenMPParallelCode", 0},
-  {"OpenMP", "Qopenmp-stubs", "", "OpenMPSequentialCode", 0},
-  {"Traceback", "traceback", "", "true", 0},
-  {"Traceback", "notraceback", "", "false", 0},
-  {"FloatingPointExceptionHandling", "fpe:0", "", "fpe0", 0},
-  {"FloatingPointExceptionHandling", "fpe:1", "", "fpe1", 0},
-  {"FloatingPointExceptionHandling", "fpe:3", "", "fpe3", 0},
-
-  {"ModulePath", "module:", "", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"LoopUnrolling", "Qunroll:", "", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"AutoParallelThreshold", "Qpar-threshold:", "", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"HeapArrays", "heap-arrays:", "", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"ObjectText", "bintext:", "", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"Parallelization", "Qparallel", "", "true", 0},
-  {"PrefetchInsertion", "Qprefetch-", "", "false", 0},
-  {"BufferedIO", "assume:buffered_io", "", "true", 0},
-  {"CallingConvention", "iface:stdcall", "", "callConventionStdCall", 0},
-  {"CallingConvention", "iface:cref", "", "callConventionCRef", 0},
-  {"CallingConvention", "iface:stdref", "", "callConventionStdRef", 0},
-  {"CallingConvention", "iface:stdcall", "", "callConventionStdCall", 0},
-  {"CallingConvention", "iface:cvf", "", "callConventionCVF", 0},
-  {"EnableRecursion", "recursive", "", "true", 0},
-  {"ReentrantCode", "reentrancy", "", "true", 0},
+cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] = {
+  { "Preprocess", "fpp", "Run Preprocessor on files", "preprocessYes", 0 },
+  { "SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0 },
+  { "SourceFileFormat", "fixed", "Use Fixed Format", "fileFormatFixed", 0 },
+  { "SourceFileFormat", "free", "Use Free Format", "fileFormatFree", 0 },
+  { "DebugInformationFormat", "Zi", "full debug", "debugEnabled", 0 },
+  { "DebugInformationFormat", "debug:full", "full debug", "debugEnabled", 0 },
+  { "DebugInformationFormat", "Z7", "c7 compat", "debugOldStyleInfo", 0 },
+  { "DebugInformationFormat", "Zd", "line numbers", "debugLineInfoOnly", 0 },
+  { "Optimization", "Od", "disable optimization", "optimizeDisabled", 0 },
+  { "Optimization", "O1", "min space", "optimizeMinSpace", 0 },
+  { "Optimization", "O3", "full optimize", "optimizeFull", 0 },
+  { "GlobalOptimizations", "Og", "global optimize", "true", 0 },
+  { "InlineFunctionExpansion", "Ob0", "", "expandDisable", 0 },
+  { "InlineFunctionExpansion", "Ob1", "", "expandOnlyInline", 0 },
+  { "FavorSizeOrSpeed", "Os", "", "favorSize", 0 },
+  { "OmitFramePointers", "Oy-", "", "false", 0 },
+  { "OptimizeForProcessor", "GB", "", "procOptimizeBlended", 0 },
+  { "OptimizeForProcessor", "G5", "", "procOptimizePentium", 0 },
+  { "OptimizeForProcessor", "G6", "", "procOptimizePentiumProThruIII", 0 },
+  { "UseProcessorExtensions", "QzxK", "", "codeForStreamingSIMD", 0 },
+  { "OptimizeForProcessor", "QaxN", "", "codeForPentium4", 0 },
+  { "OptimizeForProcessor", "QaxB", "", "codeForPentiumM", 0 },
+  { "OptimizeForProcessor", "QaxP", "", "codeForCodeNamedPrescott", 0 },
+  { "OptimizeForProcessor", "QaxT", "", "codeForCore2Duo", 0 },
+  { "OptimizeForProcessor", "QxK", "", "codeExclusivelyStreamingSIMD", 0 },
+  { "OptimizeForProcessor", "QxN", "", "codeExclusivelyPentium4", 0 },
+  { "OptimizeForProcessor", "QxB", "", "codeExclusivelyPentiumM", 0 },
+  { "OptimizeForProcessor", "QxP", "", "codeExclusivelyCodeNamedPrescott", 0 },
+  { "OptimizeForProcessor", "QxT", "", "codeExclusivelyCore2Duo", 0 },
+  { "OptimizeForProcessor", "QxO", "", "codeExclusivelyCore2StreamingSIMD",
+    0 },
+  { "OptimizeForProcessor", "QxS", "", "codeExclusivelyCore2StreamingSIMD4",
+    0 },
+  { "OpenMP", "Qopenmp", "", "OpenMPParallelCode", 0 },
+  { "OpenMP", "Qopenmp-stubs", "", "OpenMPSequentialCode", 0 },
+  { "Traceback", "traceback", "", "true", 0 },
+  { "Traceback", "notraceback", "", "false", 0 },
+  { "FloatingPointExceptionHandling", "fpe:0", "", "fpe0", 0 },
+  { "FloatingPointExceptionHandling", "fpe:1", "", "fpe1", 0 },
+  { "FloatingPointExceptionHandling", "fpe:3", "", "fpe3", 0 },
+
+  { "MultiProcessorCompilation", "MP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
+    cmVS7FlagTable::UserValueRequired },
+
+  { "ModulePath", "module:", "", "", cmVS7FlagTable::UserValueRequired },
+  { "LoopUnrolling", "Qunroll:", "", "", cmVS7FlagTable::UserValueRequired },
+  { "AutoParallelThreshold", "Qpar-threshold:", "", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "HeapArrays", "heap-arrays:", "", "", cmVS7FlagTable::UserValueRequired },
+  { "ObjectText", "bintext:", "", "", cmVS7FlagTable::UserValueRequired },
+  { "Parallelization", "Qparallel", "", "true", 0 },
+  { "PrefetchInsertion", "Qprefetch-", "", "false", 0 },
+  { "BufferedIO", "assume:buffered_io", "", "true", 0 },
+  { "CallingConvention", "iface:stdcall", "", "callConventionStdCall", 0 },
+  { "CallingConvention", "iface:cref", "", "callConventionCRef", 0 },
+  { "CallingConvention", "iface:stdref", "", "callConventionStdRef", 0 },
+  { "CallingConvention", "iface:stdcall", "", "callConventionStdCall", 0 },
+  { "CallingConvention", "iface:cvf", "", "callConventionCVF", 0 },
+  { "EnableRecursion", "recursive", "", "true", 0 },
+  { "ReentrantCode", "reentrancy", "", "true", 0 },
   // done up to Language
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
 // fill the table here currently the comment field is not used for
 // anything other than documentation NOTE: Make sure the longer
 // commandFlag comes FIRST!
-cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
-{
+cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {
   // option flags (some flags map to the same option)
-  {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1", 0},
-  {"BasicRuntimeChecks", "RTCsu",
-   "Both stack and uninitialized checks", "3", 0},
-  {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1", 0},
-  {"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2", 0},
-  {"BasicRuntimeChecks", "RTC1",
-   "Both stack and uninitialized checks", "3", 0},
-  {"DebugInformationFormat", "Z7", "debug format", "1", 0},
-  {"DebugInformationFormat", "Zd", "debug format", "2", 0},
-  {"DebugInformationFormat", "Zi", "debug format", "3", 0},
-  {"DebugInformationFormat", "ZI", "debug format", "4", 0},
-  {"EnableEnhancedInstructionSet", "arch:SSE2",
-   "Use sse2 instructions", "2", 0},
-  {"EnableEnhancedInstructionSet", "arch:SSE",
-   "Use sse instructions",   "1", 0},
-  {"FloatingPointModel", "fp:precise",
-   "Use precise floating point model", "0", 0},
-  {"FloatingPointModel", "fp:strict",
-   "Use strict floating point model", "1", 0},
-  {"FloatingPointModel", "fp:fast", "Use fast floating point model", "2", 0},
-  {"FavorSizeOrSpeed",  "Ot", "Favor fast code",  "1", 0},
-  {"FavorSizeOrSpeed",  "Os", "Favor small code", "2", 0},
-  {"CompileAs", "TC", "Compile as c code",        "1", 0},
-  {"CompileAs", "TP", "Compile as c++ code",      "2", 0},
-  {"Optimization", "Od", "Non Debug",        "0", 0},
-  {"Optimization", "O1", "Min Size",         "1", 0},
-  {"Optimization", "O2", "Max Speed",        "2", 0},
-  {"Optimization", "Ox", "Max Optimization", "3", 0},
-  {"OptimizeForProcessor", "GB", "Blended processor mode", "0", 0},
-  {"OptimizeForProcessor", "G5", "Pentium",                "1", 0},
-  {"OptimizeForProcessor", "G6", "PPro PII PIII",          "2", 0},
-  {"OptimizeForProcessor", "G7", "Pentium 4 or Athlon",    "3", 0},
-  {"InlineFunctionExpansion", "Ob0", "no inlines",              "0", 0},
-  {"InlineFunctionExpansion", "Ob1", "when inline keyword",     "1", 0},
-  {"InlineFunctionExpansion", "Ob2", "any time you can inline", "2", 0},
-  {"RuntimeLibrary", "MTd", "Multithreaded debug",     "1", 0},
-  {"RuntimeLibrary", "MT", "Multithreaded", "0", 0},
-  {"RuntimeLibrary", "MDd", "Multithreaded dll debug", "3", 0},
-  {"RuntimeLibrary", "MD", "Multithreaded dll",        "2", 0},
-  {"RuntimeLibrary", "MLd", "Single Thread debug",    "5", 0},
-  {"RuntimeLibrary", "ML", "Single Thread",           "4", 0},
-  {"StructMemberAlignment", "Zp16", "struct align 16 byte ",   "5", 0},
-  {"StructMemberAlignment", "Zp1", "struct align 1 byte ",     "1", 0},
-  {"StructMemberAlignment", "Zp2", "struct align 2 byte ",     "2", 0},
-  {"StructMemberAlignment", "Zp4", "struct align 4 byte ",     "3", 0},
-  {"StructMemberAlignment", "Zp8", "struct align 8 byte ",     "4", 0},
-  {"WarningLevel", "W0", "Warning level", "0", 0},
-  {"WarningLevel", "W1", "Warning level", "1", 0},
-  {"WarningLevel", "W2", "Warning level", "2", 0},
-  {"WarningLevel", "W3", "Warning level", "3", 0},
-  {"WarningLevel", "W4", "Warning level", "4", 0},
-  {"DisableSpecificWarnings", "wd", "Disable specific warnings", "",
-   cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "BasicRuntimeChecks", "GZ", "Stack frame checks", "1", 0 },
+  { "BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks", "3",
+    0 },
+  { "BasicRuntimeChecks", "RTCs", "Stack frame checks", "1", 0 },
+  { "BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2", 0 },
+  { "BasicRuntimeChecks", "RTC1", "Both stack and uninitialized checks", "3",
+    0 },
+  { "DebugInformationFormat", "Z7", "debug format", "1", 0 },
+  { "DebugInformationFormat", "Zd", "debug format", "2", 0 },
+  { "DebugInformationFormat", "Zi", "debug format", "3", 0 },
+  { "DebugInformationFormat", "ZI", "debug format", "4", 0 },
+  { "EnableEnhancedInstructionSet", "arch:SSE2", "Use sse2 instructions", "2",
+    0 },
+  { "EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1",
+    0 },
+  { "FloatingPointModel", "fp:precise", "Use precise floating point model",
+    "0", 0 },
+  { "FloatingPointModel", "fp:strict", "Use strict floating point model", "1",
+    0 },
+  { "FloatingPointModel", "fp:fast", "Use fast floating point model", "2", 0 },
+  { "FavorSizeOrSpeed", "Ot", "Favor fast code", "1", 0 },
+  { "FavorSizeOrSpeed", "Os", "Favor small code", "2", 0 },
+  { "CompileAs", "TC", "Compile as c code", "1", 0 },
+  { "CompileAs", "TP", "Compile as c++ code", "2", 0 },
+  { "Optimization", "Od", "Non Debug", "0", 0 },
+  { "Optimization", "O1", "Min Size", "1", 0 },
+  { "Optimization", "O2", "Max Speed", "2", 0 },
+  { "Optimization", "Ox", "Max Optimization", "3", 0 },
+  { "OptimizeForProcessor", "GB", "Blended processor mode", "0", 0 },
+  { "OptimizeForProcessor", "G5", "Pentium", "1", 0 },
+  { "OptimizeForProcessor", "G6", "PPro PII PIII", "2", 0 },
+  { "OptimizeForProcessor", "G7", "Pentium 4 or Athlon", "3", 0 },
+  { "InlineFunctionExpansion", "Ob0", "no inlines", "0", 0 },
+  { "InlineFunctionExpansion", "Ob1", "when inline keyword", "1", 0 },
+  { "InlineFunctionExpansion", "Ob2", "any time you can inline", "2", 0 },
+  { "RuntimeLibrary", "MTd", "Multithreaded debug", "1", 0 },
+  { "RuntimeLibrary", "MT", "Multithreaded", "0", 0 },
+  { "RuntimeLibrary", "MDd", "Multithreaded dll debug", "3", 0 },
+  { "RuntimeLibrary", "MD", "Multithreaded dll", "2", 0 },
+  { "RuntimeLibrary", "MLd", "Single Thread debug", "5", 0 },
+  { "RuntimeLibrary", "ML", "Single Thread", "4", 0 },
+  { "StructMemberAlignment", "Zp16", "struct align 16 byte ", "5", 0 },
+  { "StructMemberAlignment", "Zp1", "struct align 1 byte ", "1", 0 },
+  { "StructMemberAlignment", "Zp2", "struct align 2 byte ", "2", 0 },
+  { "StructMemberAlignment", "Zp4", "struct align 4 byte ", "3", 0 },
+  { "StructMemberAlignment", "Zp8", "struct align 8 byte ", "4", 0 },
+  { "WarningLevel", "W0", "Warning level", "0", 0 },
+  { "WarningLevel", "W1", "Warning level", "1", 0 },
+  { "WarningLevel", "W2", "Warning level", "2", 0 },
+  { "WarningLevel", "W3", "Warning level", "3", 0 },
+  { "WarningLevel", "W4", "Warning level", "4", 0 },
+  { "DisableSpecificWarnings", "wd", "Disable specific warnings", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
   // Precompiled header and related options.  Note that the
   // UsePrecompiledHeader entries are marked as "Continue" so that the
   // corresponding PrecompiledHeaderThrough entry can be found.
-  {"UsePrecompiledHeader", "Yc", "Create Precompiled Header", "1",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeaderThrough", "Yc", "Precompiled Header Name", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderFile", "Fp", "Generated Precompiled Header", "",
-   cmVS7FlagTable::UserValue},
+  { "UsePrecompiledHeader", "Yc", "Create Precompiled Header", "1",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeaderThrough", "Yc", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderFile", "Fp", "Generated Precompiled Header", "",
+    cmVS7FlagTable::UserValue },
   // The YX and Yu options are in a per-global-generator table because
   // their values differ based on the VS IDE version.
-  {"ForcedIncludeFiles", "FI", "Forced include files", "",
-   cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SemicolonAppendable},
+  { "ForcedIncludeFiles", "FI", "Forced include files", "",
+    cmVS7FlagTable::UserValueRequired | cmVS7FlagTable::SemicolonAppendable },
 
-  {"AssemblerListingLocation", "Fa", "ASM List Location", "",
-   cmVS7FlagTable::UserValue},
-  {"ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
-   cmVS7FlagTable::UserValue},
+  { "AssemblerListingLocation", "Fa", "ASM List Location", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
+    cmVS7FlagTable::UserValue },
 
   // boolean flags
-  {"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},
-  {"EnableFiberSafeOptimizations", "GT", "Enable Fiber-safe Optimizations",
-   "true", 0},
-  {"EnableFunctionLevelLinking", "Gy",
-   "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},
-  {"RuntimeTypeInfo", "GR",
-   "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},
-  {"WholeProgramOptimization", "GL",
-   "Enables whole program optimization", "true", 0},
-  {"WholeProgramOptimization", "GL-",
-   "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},
-  {0,0,0,0,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 },
+  { "EnableFiberSafeOptimizations", "GT", "Enable Fiber-safe Optimizations",
+    "true", 0 },
+  { "EnableFunctionLevelLinking", "Gy", "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 },
+  { "RuntimeTypeInfo", "GR", "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 },
+  { "WholeProgramOptimization", "GL", "Enables whole program optimization",
+    "true", 0 },
+  { "WholeProgramOptimization", "GL-", "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 },
+  { 0, 0, 0, 0, 0 }
 };
 
-
-
-cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
-{
+cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {
   // option flags (some flags map to the same option)
-  {"GenerateManifest", "MANIFEST:NO",
-   "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},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
-  {"DataExecutionPrevention", "NXCOMPAT:NO",
-   "Not known to work with Windows Data Execution Prevention", "1", 0},
-  {"DataExecutionPrevention", "NXCOMPAT",
-   "Known to work with Windows Data Execution Prevention", "2", 0},
-  {"DelaySign", "DELAYSIGN:NO", "", "false", 0},
-  {"DelaySign", "DELAYSIGN", "", "true", 0},
-  {"EntryPointSymbol", "ENTRY:", "sets the starting address", "",
-   cmVS7FlagTable::UserValue},
-  {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "",
-  cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs",
-   "true", 0},
-  {"FixedBaseAddress", "FIXED:NO", "Generate a relocation section", "1", 0},
-  {"FixedBaseAddress", "FIXED", "Image must be loaded at a fixed address",
-   "2", 0},
-  {"EnableCOMDATFolding", "OPT:NOICF", "Do not remove redundant COMDATs",
-   "1", 0},
-  {"EnableCOMDATFolding", "OPT:ICF", "Remove redundant COMDATs", "2", 0},
-  {"ResourceOnlyDLL", "NOENTRY", "Create DLL with no entry point", "true", 0},
-  {"OptimizeReferences", "OPT:NOREF", "Keep unreferenced data", "1", 0},
-  {"OptimizeReferences", "OPT:REF", "Eliminate unreferenced data", "2", 0},
-  {"Profile", "PROFILE", "", "true", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE:NO",
-   "Image may not be rebased at load-time", "1", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE",
-   "Image may be rebased at load-time", "2", 0},
-  {"SetChecksum", "RELEASE", "Enable setting checksum in header", "true", 0},
-  {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
-  {"TargetMachine", "MACHINE:I386", "Machine x86", "1", 0},
-  {"TargetMachine", "MACHINE:X86", "Machine x86", "1", 0},
-  {"TargetMachine", "MACHINE:AM33", "Machine AM33", "2", 0},
-  {"TargetMachine", "MACHINE:ARM", "Machine ARM", "3", 0},
-  {"TargetMachine", "MACHINE:EBC", "Machine EBC", "4", 0},
-  {"TargetMachine", "MACHINE:IA64", "Machine IA64", "5", 0},
-  {"TargetMachine", "MACHINE:M32R", "Machine M32R", "6", 0},
-  {"TargetMachine", "MACHINE:MIPS", "Machine MIPS", "7", 0},
-  {"TargetMachine", "MACHINE:MIPS16", "Machine MIPS16", "8", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU)", "Machine MIPSFPU", "9", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16", "Machine MIPSFPU16", "10", 0},
-  {"TargetMachine", "MACHINE:MIPSR41XX", "Machine MIPSR41XX", "11", 0},
-  {"TargetMachine", "MACHINE:SH3", "Machine SH3", "12", 0},
-  {"TargetMachine", "MACHINE:SH3DSP", "Machine SH3DSP", "13", 0},
-  {"TargetMachine", "MACHINE:SH4", "Machine SH4", "14", 0},
-  {"TargetMachine", "MACHINE:SH5", "Machine SH5", "15", 0},
-  {"TargetMachine", "MACHINE:THUMB", "Machine THUMB", "16", 0},
-  {"TargetMachine", "MACHINE:X64", "Machine x64", "17", 0},
-  {"TurnOffAssemblyGeneration", "NOASSEMBLY",
-   "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},
-  {0,0,0,0,0}
+  { "GenerateManifest", "MANIFEST:NO", "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 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT:NO",
+    "Not known to work with Windows Data Execution Prevention", "1", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT",
+    "Known to work with Windows Data Execution Prevention", "2", 0 },
+  { "DelaySign", "DELAYSIGN:NO", "", "false", 0 },
+  { "DelaySign", "DELAYSIGN", "", "true", 0 },
+  { "EntryPointSymbol", "ENTRY:", "sets the starting address", "",
+    cmVS7FlagTable::UserValue },
+  { "IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs",
+    "true", 0 },
+  { "FixedBaseAddress", "FIXED:NO", "Generate a relocation section", "1", 0 },
+  { "FixedBaseAddress", "FIXED", "Image must be loaded at a fixed address",
+    "2", 0 },
+  { "EnableCOMDATFolding", "OPT:NOICF", "Do not remove redundant COMDATs", "1",
+    0 },
+  { "EnableCOMDATFolding", "OPT:ICF", "Remove redundant COMDATs", "2", 0 },
+  { "ResourceOnlyDLL", "NOENTRY", "Create DLL with no entry point", "true",
+    0 },
+  { "OptimizeReferences", "OPT:NOREF", "Keep unreferenced data", "1", 0 },
+  { "OptimizeReferences", "OPT:REF", "Eliminate unreferenced data", "2", 0 },
+  { "Profile", "PROFILE", "", "true", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE:NO",
+    "Image may not be rebased at load-time", "1", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE",
+    "Image may be rebased at load-time", "2", 0 },
+  { "SetChecksum", "RELEASE", "Enable setting checksum in header", "true", 0 },
+  { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
+  { "TargetMachine", "MACHINE:I386", "Machine x86", "1", 0 },
+  { "TargetMachine", "MACHINE:X86", "Machine x86", "1", 0 },
+  { "TargetMachine", "MACHINE:AM33", "Machine AM33", "2", 0 },
+  { "TargetMachine", "MACHINE:ARM", "Machine ARM", "3", 0 },
+  { "TargetMachine", "MACHINE:EBC", "Machine EBC", "4", 0 },
+  { "TargetMachine", "MACHINE:IA64", "Machine IA64", "5", 0 },
+  { "TargetMachine", "MACHINE:M32R", "Machine M32R", "6", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "Machine MIPS", "7", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "Machine MIPS16", "8", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU)", "Machine MIPSFPU", "9", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "Machine MIPSFPU16", "10", 0 },
+  { "TargetMachine", "MACHINE:MIPSR41XX", "Machine MIPSR41XX", "11", 0 },
+  { "TargetMachine", "MACHINE:SH3", "Machine SH3", "12", 0 },
+  { "TargetMachine", "MACHINE:SH3DSP", "Machine SH3DSP", "13", 0 },
+  { "TargetMachine", "MACHINE:SH4", "Machine SH4", "14", 0 },
+  { "TargetMachine", "MACHINE:SH5", "Machine SH5", "15", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "Machine THUMB", "16", 0 },
+  { "TargetMachine", "MACHINE:X64", "Machine x64", "17", 0 },
+  { "TurnOffAssemblyGeneration", "NOASSEMBLY",
+    "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 },
+  { 0, 0, 0, 0, 0 }
 };
 
-cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranLinkFlagTable[] =
-{
-  {"LinkIncremental", "INCREMENTAL:NO", "link incremental",
-   "linkIncrementalNo", 0},
-  {"LinkIncremental", "INCREMENTAL:YES", "link incremental",
-   "linkIncrementalYes", 0},
-  {0,0,0,0,0}
+cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranLinkFlagTable[] = {
+  { "LinkIncremental", "INCREMENTAL:NO", "link incremental",
+    "linkIncrementalNo", 0 },
+  { "LinkIncremental", "INCREMENTAL:YES", "link incremental",
+    "linkIncrementalYes", 0 },
+  { 0, 0, 0, 0, 0 }
 };
 
-//----------------------------------------------------------------------------
 // Helper class to write build event <Tool .../> elements.
 class cmLocalVisualStudio7Generator::EventWriter
 {
 public:
-  EventWriter(cmLocalVisualStudio7Generator* lg,
-              const std::string& config, std::ostream& os):
-    LG(lg), Config(config), Stream(os), First(true) {}
+  EventWriter(cmLocalVisualStudio7Generator* lg, const std::string& config,
+              std::ostream& os)
+    : LG(lg)
+    , Config(config)
+    , Stream(os)
+    , First(true)
+  {
+  }
   void Start(const char* tool)
-    {
+  {
     this->First = true;
     this->Stream << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"";
-    }
-  void Finish()
-    {
-    this->Stream << (this->First? "" : "\"") << "/>\n";
-    }
+  }
+  void Finish() { this->Stream << (this->First ? "" : "\"") << "/>\n"; }
   void Write(std::vector<cmCustomCommand> const& ccs)
-    {
-    for(std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
-        ci != ccs.end(); ++ci)
-      {
+  {
+    for (std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
+         ci != ccs.end(); ++ci) {
       this->Write(*ci);
-      }
     }
+  }
   void Write(cmCustomCommand const& cc)
-    {
+  {
     cmCustomCommandGenerator ccg(cc, this->Config, this->LG);
-    if(this->First)
-      {
+    if (this->First) {
       const char* comment = ccg.GetComment();
-      if(comment && *comment)
-        {
-        this->Stream << "\nDescription=\""
-                     << this->LG->EscapeForXML(comment) << "\"";
-        }
+      if (comment && *comment) {
+        this->Stream << "\nDescription=\"" << this->LG->EscapeForXML(comment)
+                     << "\"";
+      }
       this->Stream << "\nCommandLine=\"";
       this->First = false;
-      }
-    else
-      {
+    } else {
       this->Stream << this->LG->EscapeForXML("\n");
-      }
+    }
     std::string script = this->LG->ConstructScript(ccg);
     this->Stream << this->LG->EscapeForXML(script.c_str());
-    }
+  }
+
 private:
   cmLocalVisualStudio7Generator* LG;
   std::string Config;
@@ -640,22 +601,19 @@ private:
   bool First;
 };
 
-//----------------------------------------------------------------------------
-void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
-                                                const std::string& configName,
-                                                const std::string& libName,
-                                                cmGeneratorTarget *target)
+void cmLocalVisualStudio7Generator::WriteConfiguration(
+  std::ostream& fout, const std::string& configName,
+  const std::string& libName, cmGeneratorTarget* target)
 {
   const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
-  if(!mfcFlag)
-    {
+  if (!mfcFlag) {
     mfcFlag = "0";
-    }
+  }
   cmGlobalVisualStudio7Generator* gg =
     static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
   fout << "\t\t<Configuration\n"
-       << "\t\t\tName=\"" << configName
-       << "|" << gg->GetPlatformName() << "\"\n";
+       << "\t\t\tName=\"" << configName << "|" << gg->GetPlatformName()
+       << "\"\n";
   // This is an internal type to Visual Studio, it seems that:
   // 4 == static library
   // 2 == dll
@@ -665,8 +623,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   const char* projectType = 0;
   bool targetBuilds = true;
 
-  switch(target->GetType())
-    {
+  switch (target->GetType()) {
     case cmState::OBJECT_LIBRARY:
       targetBuilds = false; // no manifest tool for object library
     case cmState::STATIC_LIBRARY:
@@ -687,72 +644,66 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
     default:
       targetBuilds = false;
       break;
-    }
-  if(this->FortranProject && projectType)
-    {
+  }
+  if (this->FortranProject && projectType) {
     configType = projectType;
-    }
+  }
   std::string flags;
-  if(strcmp(configType, "10") != 0)
-    {
-    const std::string& linkLanguage = (this->FortranProject?
-                                       std::string("Fortran"):
-                                target->GetLinkerLanguage(configName));
-    if(linkLanguage.empty())
-      {
-      cmSystemTools::Error
-        ("CMake can not determine linker language for target: ",
-         target->GetName().c_str());
+  if (strcmp(configType, "10") != 0) {
+    const std::string& linkLanguage =
+      (this->FortranProject ? std::string("Fortran")
+                            : target->GetLinkerLanguage(configName));
+    if (linkLanguage.empty()) {
+      cmSystemTools::Error(
+        "CMake can not determine linker language for target: ",
+        target->GetName().c_str());
       return;
-      }
-    if(linkLanguage == "C" || linkLanguage == "CXX"
-      || linkLanguage == "Fortran")
-      {
+    }
+    if (linkLanguage == "C" || linkLanguage == "CXX" ||
+        linkLanguage == "Fortran") {
       std::string baseFlagVar = "CMAKE_";
       baseFlagVar += linkLanguage;
       baseFlagVar += "_FLAGS";
       flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str());
-      std::string flagVar = baseFlagVar + std::string("_") +
-        cmSystemTools::UpperCase(configName);
+      std::string flagVar =
+        baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName);
       flags += " ";
       flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
-      }
+    }
     // set the correct language
-    if(linkLanguage == "C")
-      {
+    if (linkLanguage == "C") {
       flags += " /TC ";
-      }
-    if(linkLanguage == "CXX")
-      {
+    }
+    if (linkLanguage == "CXX") {
       flags += " /TP ";
-      }
+    }
 
     // Add the target-specific flags.
     this->AddCompileOptions(flags, target, linkLanguage, configName);
-    }
+  }
 
-  if(this->FortranProject)
-    {
-    switch(this->GetFortranFormat(target->GetProperty("Fortran_FORMAT")))
-      {
-      case FortranFormatFixed: flags += " -fixed"; break;
-      case FortranFormatFree: flags += " -free"; break;
-      default: break;
-      }
+  if (this->FortranProject) {
+    switch (this->GetFortranFormat(target->GetProperty("Fortran_FORMAT"))) {
+      case cmOutputConverter::FortranFormatFixed:
+        flags += " -fixed";
+        break;
+      case cmOutputConverter::FortranFormatFree:
+        flags += " -free";
+        break;
+      default:
+        break;
     }
+  }
 
   // Get preprocessor definitions for this directory.
   std::string defineFlags = this->Makefile->GetDefineFlags();
   Options::Tool t = Options::Compiler;
   cmVS7FlagTable const* table = cmLocalVisualStudio7GeneratorFlagTable;
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     t = Options::FortranCompiler;
     table = cmLocalVisualStudio7GeneratorFortranFlagTable;
-    }
-  Options targetOptions(this, t,
-                        table,
-                        gg->ExtraFlagTable);
+  }
+  Options targetOptions(this, t, table, gg->ExtraFlagTable);
   targetOptions.FixExceptionHandlingDefault();
   std::string asmLocation = configName + "/";
   targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
@@ -772,10 +723,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   targetOptions.AddDefine(configDefine);
 
   // Add the export symbol definition for shared library objects.
-  if(const char* exportMacro = target->GetExportMacro())
-    {
+  if (const char* exportMacro = target->GetExportMacro()) {
     targetOptions.AddDefine(exportMacro);
-    }
+  }
 
   // The intermediate directory name consists of a directory for the
   // target and a subdirectory for the configuration name.
@@ -783,185 +733,165 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   intermediateDir += "/";
   intermediateDir += configName;
 
-  if (target->GetType() < cmState::UTILITY)
-    {
-    std::string const& outDir =
-      target->GetType() == cmState::OBJECT_LIBRARY?
-      intermediateDir : target->GetDirectory(configName);
+  if (target->GetType() < cmState::UTILITY) {
+    std::string const& outDir = target->GetType() == cmState::OBJECT_LIBRARY
+      ? intermediateDir
+      : target->GetDirectory(configName);
+    /* clang-format off */
     fout << "\t\t\tOutputDirectory=\""
          << this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n";
-    }
+    /* clang-format on */
+  }
 
+  /* clang-format off */
   fout << "\t\t\tIntermediateDirectory=\""
        << this->ConvertToXMLOutputPath(intermediateDir.c_str())
        << "\"\n"
        << "\t\t\tConfigurationType=\"" << configType << "\"\n"
        << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
        << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"false\"\n";
+  /* clang-format on */
 
-  if (this->FortranProject)
-    {
+  if (this->FortranProject) {
     // Intel Fortran >= 15.0 uses TargetName property.
     std::string targetNameFull = target->GetFullName(configName);
     std::string targetName =
       cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
     std::string targetExt =
       cmSystemTools::GetFilenameLastExtension(targetNameFull);
+    /* clang-format off */
     fout <<
       "\t\t\tTargetName=\"" << this->EscapeForXML(targetName) << "\"\n"
       "\t\t\tTargetExt=\"" << this->EscapeForXML(targetExt) << "\"\n"
       ;
-    }
+    /* clang-format on */
+  }
 
   // If unicode is enabled change the character set to unicode, if not
   // then default to MBCS.
-  if(targetOptions.UsingUnicode())
-    {
+  if (targetOptions.UsingUnicode()) {
     fout << "\t\t\tCharacterSet=\"1\">\n";
-    }
-  else if(targetOptions.UsingSBCS())
-    {
+  } else if (targetOptions.UsingSBCS()) {
     fout << "\t\t\tCharacterSet=\"0\">\n";
-    }
-  else
-    {
+  } else {
     fout << "\t\t\tCharacterSet=\"2\">\n";
-    }
+  }
   const char* tool = "VCCLCompilerTool";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     tool = "VFFortranCompilerTool";
-    }
+  }
   fout << "\t\t\t<Tool\n"
        << "\t\t\t\tName=\"" << tool << "\"\n";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     const char* target_mod_dir =
       target->GetProperty("Fortran_MODULE_DIRECTORY");
     std::string modDir;
-    if(target_mod_dir)
-      {
-      modDir = this->Convert(target_mod_dir,
-                             cmLocalGenerator::START_OUTPUT,
-                             cmLocalGenerator::UNCHANGED);
-      }
-    else
-      {
+    if (target_mod_dir) {
+      modDir = this->Convert(target_mod_dir, cmOutputConverter::START_OUTPUT,
+                             cmOutputConverter::UNCHANGED);
+    } else {
       modDir = ".";
-      }
+    }
     fout << "\t\t\t\tModulePath=\""
          << this->ConvertToXMLOutputPath(modDir.c_str())
          << "\\$(ConfigurationName)\"\n";
-    }
+  }
   targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
   fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
   std::vector<std::string> includes;
   this->GetIncludeDirectories(includes, target, "C", configName);
   std::vector<std::string>::iterator i = includes.begin();
-  for(;i != includes.end(); ++i)
-    {
+  for (; i != includes.end(); ++i) {
     // output the include path
     std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
     fout << ipath << ";";
     // if this is fortran then output the include with
     // a ConfigurationName on the end of it.
-    if(this->FortranProject)
-      {
+    if (this->FortranProject) {
       ipath = i->c_str();
       ipath += "/$(ConfigurationName)";
       ipath = this->ConvertToXMLOutputPath(ipath.c_str());
       fout << ipath << ";";
-      }
     }
+  }
   fout << "\"\n";
   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() <= cmState::OBJECT_LIBRARY)
-    {
+  if (target->GetType() <= cmState::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";
-      }
+    if (!pdb.empty()) {
+      fout << "\t\t\t\tProgramDataBaseFileName=\""
+           << this->ConvertToXMLOutputPathSingle(pdb.c_str()) << "\"\n";
     }
-  fout << "/>\n";  // end of <Tool Name=VCCLCompilerTool
-  if(gg->IsMasmEnabled() && !this->FortranProject)
-    {
+  }
+  fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
+  if (gg->IsMasmEnabled() && !this->FortranProject) {
     Options masmOptions(this, Options::MasmCompiler, 0, 0);
+    /* clang-format off */
     fout <<
       "\t\t\t<Tool\n"
       "\t\t\t\tName=\"MASM\"\n"
       "\t\t\t\tIncludePaths=\""
       ;
+    /* clang-format on */
     const char* sep = "";
-    for(i = includes.begin(); i != includes.end(); ++i)
-      {
+    for (i = includes.begin(); i != includes.end(); ++i) {
       std::string inc = *i;
       cmConvertToWindowsSlash(inc);
       fout << sep << this->EscapeForXML(inc);
       sep = ";";
-      }
+    }
     fout << "\"\n";
     // Use same preprocessor definitions as VCCLCompilerTool.
     targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n",
                                                 "ASM_MASM");
     masmOptions.OutputFlagMap(fout, "\t\t\t\t");
+    /* clang-format off */
     fout <<
       "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"
       "\t\t\t/>\n";
-    }
+    /* clang-format on */
+  }
   tool = "VCCustomBuildTool";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     tool = "VFCustomBuildTool";
-    }
+  }
   fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"/>\n";
   tool = "VCResourceCompilerTool";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     tool = "VFResourceCompilerTool";
-    }
+  }
   fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
        << "\t\t\t\tAdditionalIncludeDirectories=\"";
-  for(i = includes.begin();i != includes.end(); ++i)
-    {
+  for (i = includes.begin(); i != includes.end(); ++i) {
     std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
     fout << ipath << ";";
-    }
+  }
   // add the -D flags to the RC tool
   fout << "\"";
   targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC");
   fout << "/>\n";
   tool = "VCMIDLTool";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     tool = "VFMIDLTool";
-    }
+  }
   fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
   fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
-  for(i = includes.begin(); i != includes.end(); ++i)
-    {
+  for (i = includes.begin(); i != includes.end(); ++i) {
     std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
     fout << ipath << ";";
-    }
+  }
   fout << "\"\n";
   fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n";
-  if( gg->GetPlatformName() == "x64" )
-    {
+  if (gg->GetPlatformName() == "x64") {
     fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
-    }
-  else if( gg->GetPlatformName() == "ia64" )
-    {
+  } else if (gg->GetPlatformName() == "ia64") {
     fout << "\t\t\t\tTargetEnvironment=\"2\"\n";
-    }
-  else
-    {
+  } else {
     fout << "\t\t\t\tTargetEnvironment=\"1\"\n";
-    }
+  }
   fout << "\t\t\t\tGenerateStublessProxies=\"true\"\n";
   fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n";
   fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n";
@@ -972,140 +902,126 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   // end of <Tool Name=VCMIDLTool
 
   // Add manifest tool settings.
-  if(targetBuilds && this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8)
-    {
-    const char* manifestTool  = "VCManifestTool";
-    if (this->FortranProject)
-      {
+  if (targetBuilds &&
+      this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) {
+    const char* manifestTool = "VCManifestTool";
+    if (this->FortranProject) {
       manifestTool = "VFManifestTool";
-      }
+    }
+    /* clang-format off */
     fout <<
       "\t\t\t<Tool\n"
       "\t\t\t\tName=\"" << manifestTool << "\"";
+    /* clang-format on */
 
     std::vector<cmSourceFile const*> manifest_srcs;
     target->GetManifests(manifest_srcs, configName);
-    if (!manifest_srcs.empty())
-      {
+    if (!manifest_srcs.empty()) {
       fout << "\n\t\t\t\tAdditionalManifestFiles=\"";
-      for (std::vector<cmSourceFile const*>::const_iterator
-             mi = manifest_srcs.begin(); mi != manifest_srcs.end(); ++mi)
-        {
+      for (std::vector<cmSourceFile const*>::const_iterator mi =
+             manifest_srcs.begin();
+           mi != manifest_srcs.end(); ++mi) {
         std::string m = (*mi)->GetFullPath();
         fout << this->ConvertToXMLOutputPath(m.c_str()) << ";";
-        }
-      fout << "\"";
       }
+      fout << "\"";
+    }
 
     // Check if we need the FAT32 workaround.
     // Check the filesystem type where the target will be written.
-    if (cmLVS6G_IsFAT(target->GetDirectory(configName).c_str()))
-      {
+    if (cmLVS7G_IsFAT(target->GetDirectory(configName).c_str())) {
       // Add a flag telling the manifest tool to use a workaround
       // for FAT32 file systems, which can cause an empty manifest
       // to be embedded into the resulting executable.  See CMake
       // bug #2617.
       fout << "\n\t\t\t\tUseFAT32Workaround=\"true\"";
-      }
-    fout << "/>\n";
     }
+    fout << "/>\n";
+  }
 
   this->OutputTargetRules(fout, configName, target, libName);
   this->OutputBuildTool(fout, configName, target, targetOptions);
+  this->OutputDeploymentDebuggerTool(fout, configName, target);
   fout << "\t\t</Configuration>\n";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalVisualStudio7Generator
-::GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
-                          const std::string& configName)
+std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags(
+  std::string rootLinkerFlags, const std::string& configName)
 {
   std::string configTypeUpper = cmSystemTools::UpperCase(configName);
   std::string extraLinkOptionsBuildTypeDef =
     rootLinkerFlags + "_" + configTypeUpper;
 
   std::string extraLinkOptionsBuildType =
-    this->Makefile->GetRequiredDefinition
-    (extraLinkOptionsBuildTypeDef.c_str());
+    this->Makefile->GetRequiredDefinition(
+      extraLinkOptionsBuildTypeDef.c_str());
 
   return extraLinkOptionsBuildType;
 }
 
-void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
-  const std::string& configName, cmGeneratorTarget* target,
+void cmLocalVisualStudio7Generator::OutputBuildTool(
+  std::ostream& fout, const std::string& configName, cmGeneratorTarget* target,
   const Options& targetOptions)
 {
   cmGlobalVisualStudio7Generator* gg =
     static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
   std::string temp;
   std::string extraLinkOptions;
-  if(target->GetType() == cmState::EXECUTABLE)
-    {
+  if (target->GetType() == cmState::EXECUTABLE) {
     extraLinkOptions =
-      this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS")
-      + std::string(" ")
-      + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
-    }
-  if(target->GetType() == cmState::SHARED_LIBRARY)
-    {
+      this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") +
+      std::string(" ") +
+      GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
+  }
+  if (target->GetType() == cmState::SHARED_LIBRARY) {
     extraLinkOptions =
-      this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS")
-      + std::string(" ")
-      + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
-    }
-  if(target->GetType() == cmState::MODULE_LIBRARY)
-    {
+      this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") +
+      std::string(" ") +
+      GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
+  }
+  if (target->GetType() == cmState::MODULE_LIBRARY) {
     extraLinkOptions =
-      this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS")
-      + std::string(" ")
-      + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
-    }
+      this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") +
+      std::string(" ") +
+      GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
+  }
 
   const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
-  if(targetLinkFlags)
-    {
+  if (targetLinkFlags) {
     extraLinkOptions += " ";
     extraLinkOptions += targetLinkFlags;
-    }
+  }
   std::string configTypeUpper = cmSystemTools::UpperCase(configName);
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += configTypeUpper;
   targetLinkFlags = target->GetProperty(linkFlagsConfig.c_str());
-  if(targetLinkFlags)
-    {
+  if (targetLinkFlags) {
     extraLinkOptions += " ";
     extraLinkOptions += targetLinkFlags;
-    }
+  }
   Options linkOptions(this, Options::Linker);
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     linkOptions.AddTable(cmLocalVisualStudio7GeneratorFortranLinkFlagTable);
-    }
+  }
   linkOptions.AddTable(cmLocalVisualStudio7GeneratorLinkFlagTable);
 
   linkOptions.Parse(extraLinkOptions.c_str());
-  if(!this->ModuleDefinitionFile.empty())
-    {
-    std::string defFile =
-      this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL);
+  if (!this->ModuleDefinitionFile.empty()) {
+    std::string defFile = this->ConvertToOutputFormat(
+      this->ModuleDefinitionFile, cmOutputConverter::SHELL);
     linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
-    }
+  }
 
   if (target->GetType() == cmState::SHARED_LIBRARY &&
-      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
-    {
-    if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
+      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+    if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) {
       linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)/exportall.def");
-      }
     }
-  switch(target->GetType())
-    {
+  }
+  switch (target->GetType()) {
     case cmState::UNKNOWN_LIBRARY:
       break;
-    case cmState::OBJECT_LIBRARY:
-      {
+    case cmState::OBJECT_LIBRARY: {
       std::string libpath = this->GetTargetDirectory(target);
       libpath += "/";
       libpath += configName;
@@ -1113,271 +1029,262 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
       libpath += target->GetName();
       libpath += ".lib";
       const char* tool =
-        this->FortranProject? "VFLibrarianTool":"VCLibrarianTool";
+        this->FortranProject ? "VFLibrarianTool" : "VCLibrarianTool";
       fout << "\t\t\t<Tool\n"
            << "\t\t\t\tName=\"" << tool << "\"\n";
       fout << "\t\t\t\tOutputFile=\""
            << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
       break;
-      }
-    case cmState::STATIC_LIBRARY:
-    {
-    std::string targetNameFull = target->GetFullName(configName);
-    std::string libpath = target->GetDirectory(configName);
-    libpath += "/";
-    libpath += targetNameFull;
-    const char* tool = "VCLibrarianTool";
-    if(this->FortranProject)
-      {
-      tool = "VFLibrarianTool";
-      }
-    fout << "\t\t\t<Tool\n"
-         << "\t\t\t\tName=\"" << tool << "\"\n";
-
-    if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS8
-        || this->FortranProject)
-      {
-      std::ostringstream libdeps;
-      this->Internal->OutputObjects(libdeps, target);
-      if(!libdeps.str().empty())
-        {
-        fout << "\t\t\t\tAdditionalDependencies=\"" << libdeps.str() << "\"\n";
-        }
-      }
-    std::string libflags;
-    this->GetStaticLibraryFlags(libflags, configTypeUpper, target);
-    if(!libflags.empty())
-      {
-      fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
-      }
-    fout << "\t\t\t\tOutputFile=\""
-         << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
-    break;
     }
-    case cmState::SHARED_LIBRARY:
-    case cmState::MODULE_LIBRARY:
-    {
-    std::string targetName;
-    std::string targetNameSO;
-    std::string targetNameFull;
-    std::string targetNameImport;
-    std::string targetNamePDB;
-    target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
-                           targetNameImport, targetNamePDB, configName);
-
-    // Compute the link library and directory information.
-    cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
-    if(!pcli)
-      {
-      return;
-      }
-    cmComputeLinkInformation& cli = *pcli;
-    std::string linkLanguage = cli.GetLinkLanguage();
-
-    // Compute the variable name to lookup standard libraries for this
-    // language.
-    std::string standardLibsVar = "CMAKE_";
-    standardLibsVar += linkLanguage;
-    standardLibsVar += "_STANDARD_LIBRARIES";
-    const char* tool = "VCLinkerTool";
-    if(this->FortranProject)
-      {
-      tool = "VFLinkerTool";
-      }
-    fout << "\t\t\t<Tool\n"
-         << "\t\t\t\tName=\"" << tool << "\"\n";
-    if(!gg->NeedLinkLibraryDependencies(target))
-      {
-      fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
-      }
-    linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
-    // Use the NOINHERIT macro to avoid getting VS project default
-    // 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() < cmGlobalVisualStudioGenerator::VS8
-        || this->FortranProject)
-      {
-      this->Internal->OutputObjects(fout, target, " ");
-      }
-    fout << " ";
-    this->Internal->OutputLibraries(fout, cli.GetItems());
-    fout << "\"\n";
-    temp = target->GetDirectory(configName);
-    temp += "/";
-    temp += targetNameFull;
-    fout << "\t\t\t\tOutputFile=\""
-         << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
-    this->WriteTargetVersionAttribute(fout, target);
-    linkOptions.OutputFlagMap(fout, "\t\t\t\t");
-    fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
-    this->OutputLibraryDirectories(fout, cli.GetDirectories());
-    fout << "\"\n";
-    temp = target->GetPDBDirectory(configName);
-    temp += "/";
-    temp += targetNamePDB;
-    fout << "\t\t\t\tProgramDatabaseFile=\"" <<
-      this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
-    if(targetOptions.IsDebug())
-      {
-      fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
+    case cmState::STATIC_LIBRARY: {
+      std::string targetNameFull = target->GetFullName(configName);
+      std::string libpath = target->GetDirectory(configName);
+      libpath += "/";
+      libpath += targetNameFull;
+      const char* tool = "VCLibrarianTool";
+      if (this->FortranProject) {
+        tool = "VFLibrarianTool";
       }
-    if(this->WindowsCEProject)
-      {
-      if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9)
-        {
-        fout << "\t\t\t\tSubSystem=\"9\"\n";
-        }
-      else
-        {
-        fout << "\t\t\t\tSubSystem=\"8\"\n";
+      fout << "\t\t\t<Tool\n"
+           << "\t\t\t\tName=\"" << tool << "\"\n";
+
+      if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 ||
+          this->FortranProject) {
+        std::ostringstream libdeps;
+        this->Internal->OutputObjects(libdeps, target);
+        if (!libdeps.str().empty()) {
+          fout << "\t\t\t\tAdditionalDependencies=\"" << libdeps.str()
+               << "\"\n";
         }
       }
-    std::string stackVar = "CMAKE_";
-    stackVar += linkLanguage;
-    stackVar += "_STACK_SIZE";
-    const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
-    if(stackVal)
-      {
-      fout << "\t\t\t\tStackReserveSize=\"" << stackVal  << "\"\n";
-      }
-    temp = target->GetDirectory(configName, true);
-    temp += "/";
-    temp += targetNameImport;
-    fout << "\t\t\t\tImportLibrary=\""
-         << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"";
-    if(this->FortranProject)
-      {
-      fout << "\n\t\t\t\tLinkDLL=\"true\"";
+      std::string libflags;
+      this->GetStaticLibraryFlags(libflags, configTypeUpper, target);
+      if (!libflags.empty()) {
+        fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
       }
-    fout << "/>\n";
+      fout << "\t\t\t\tOutputFile=\""
+           << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n";
+      break;
     }
-    break;
-    case cmState::EXECUTABLE:
-    {
-    std::string targetName;
-    std::string targetNameFull;
-    std::string targetNameImport;
-    std::string targetNamePDB;
-    target->GetExecutableNames(targetName, targetNameFull,
+    case cmState::SHARED_LIBRARY:
+    case cmState::MODULE_LIBRARY: {
+      std::string targetName;
+      std::string targetNameSO;
+      std::string targetNameFull;
+      std::string targetNameImport;
+      std::string targetNamePDB;
+      target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
                               targetNameImport, targetNamePDB, configName);
 
-    // Compute the link library and directory information.
-    cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
-    if(!pcli)
-      {
-      return;
+      // Compute the link library and directory information.
+      cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
+      if (!pcli) {
+        return;
       }
-    cmComputeLinkInformation& cli = *pcli;
-    std::string linkLanguage = cli.GetLinkLanguage();
-
-    bool isWin32Executable = target->GetPropertyAsBool("WIN32_EXECUTABLE");
-
-    // Compute the variable name to lookup standard libraries for this
-    // language.
-    std::string standardLibsVar = "CMAKE_";
-    standardLibsVar += linkLanguage;
-    standardLibsVar += "_STANDARD_LIBRARIES";
-    const char* tool = "VCLinkerTool";
-    if(this->FortranProject)
-      {
-      tool = "VFLinkerTool";
+      cmComputeLinkInformation& cli = *pcli;
+      std::string linkLanguage = cli.GetLinkLanguage();
+
+      // Compute the variable name to lookup standard libraries for this
+      // language.
+      std::string standardLibsVar = "CMAKE_";
+      standardLibsVar += linkLanguage;
+      standardLibsVar += "_STANDARD_LIBRARIES";
+      const char* tool = "VCLinkerTool";
+      if (this->FortranProject) {
+        tool = "VFLinkerTool";
       }
-    fout << "\t\t\t<Tool\n"
-         << "\t\t\t\tName=\"" << tool << "\"\n";
-    if(!gg->NeedLinkLibraryDependencies(target))
-      {
-      fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
+      fout << "\t\t\t<Tool\n"
+           << "\t\t\t\tName=\"" << tool << "\"\n";
+      if (!gg->NeedLinkLibraryDependencies(target)) {
+        fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
+      }
+      linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
+      // Use the NOINHERIT macro to avoid getting VS project default
+      // 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() < cmGlobalVisualStudioGenerator::VS8 ||
+          this->FortranProject) {
+        this->Internal->OutputObjects(fout, target, " ");
+      }
+      fout << " ";
+      this->Internal->OutputLibraries(fout, cli.GetItems());
+      fout << "\"\n";
+      temp = target->GetDirectory(configName);
+      temp += "/";
+      temp += targetNameFull;
+      fout << "\t\t\t\tOutputFile=\""
+           << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+      this->WriteTargetVersionAttribute(fout, target);
+      linkOptions.OutputFlagMap(fout, "\t\t\t\t");
+      fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
+      this->OutputLibraryDirectories(fout, cli.GetDirectories());
+      fout << "\"\n";
+      temp = target->GetPDBDirectory(configName);
+      temp += "/";
+      temp += targetNamePDB;
+      fout << "\t\t\t\tProgramDatabaseFile=\""
+           << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+      if (targetOptions.IsDebug()) {
+        fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
+      }
+      if (this->WindowsCEProject) {
+        if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS9) {
+          fout << "\t\t\t\tSubSystem=\"9\"\n";
+        } else {
+          fout << "\t\t\t\tSubSystem=\"8\"\n";
+        }
       }
-    linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
-    // Use the NOINHERIT macro to avoid getting VS project default
-    // 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() < cmGlobalVisualStudioGenerator::VS8
-        || this->FortranProject)
-      {
-      this->Internal->OutputObjects(fout, target, " ");
+      std::string stackVar = "CMAKE_";
+      stackVar += linkLanguage;
+      stackVar += "_STACK_SIZE";
+      const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
+      if (stackVal) {
+        fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
+      }
+      temp = target->GetDirectory(configName, true);
+      temp += "/";
+      temp += targetNameImport;
+      fout << "\t\t\t\tImportLibrary=\""
+           << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"";
+      if (this->FortranProject) {
+        fout << "\n\t\t\t\tLinkDLL=\"true\"";
+      }
+      fout << "/>\n";
+    } break;
+    case cmState::EXECUTABLE: {
+      std::string targetName;
+      std::string targetNameFull;
+      std::string targetNameImport;
+      std::string targetNamePDB;
+      target->GetExecutableNames(targetName, targetNameFull, targetNameImport,
+                                 targetNamePDB, configName);
+
+      // Compute the link library and directory information.
+      cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
+      if (!pcli) {
+        return;
       }
-    fout << " ";
-    this->Internal->OutputLibraries(fout, cli.GetItems());
-    fout << "\"\n";
-    temp = target->GetDirectory(configName);
-    temp += "/";
-    temp += targetNameFull;
-    fout << "\t\t\t\tOutputFile=\""
-         << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
-    this->WriteTargetVersionAttribute(fout, target);
-    linkOptions.OutputFlagMap(fout, "\t\t\t\t");
-    fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
-    this->OutputLibraryDirectories(fout, cli.GetDirectories());
-    fout << "\"\n";
-    std::string path = this->ConvertToXMLOutputPathSingle(
-      target->GetPDBDirectory(configName).c_str());
-    fout << "\t\t\t\tProgramDatabaseFile=\""
-         << path << "/" << targetNamePDB
-         << "\"\n";
-    if(targetOptions.IsDebug())
-      {
-      fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
+      cmComputeLinkInformation& cli = *pcli;
+      std::string linkLanguage = cli.GetLinkLanguage();
+
+      bool isWin32Executable = target->GetPropertyAsBool("WIN32_EXECUTABLE");
+
+      // Compute the variable name to lookup standard libraries for this
+      // language.
+      std::string standardLibsVar = "CMAKE_";
+      standardLibsVar += linkLanguage;
+      standardLibsVar += "_STANDARD_LIBRARIES";
+      const char* tool = "VCLinkerTool";
+      if (this->FortranProject) {
+        tool = "VFLinkerTool";
       }
-    if ( this->WindowsCEProject )
-      {
-      if(this->GetVersion() < cmGlobalVisualStudioGenerator::VS9)
-        {
-        fout << "\t\t\t\tSubSystem=\"9\"\n";
-        }
-      else
-        {
-        fout << "\t\t\t\tSubSystem=\"8\"\n";
+      fout << "\t\t\t<Tool\n"
+           << "\t\t\t\tName=\"" << tool << "\"\n";
+      if (!gg->NeedLinkLibraryDependencies(target)) {
+        fout << "\t\t\t\tLinkLibraryDependencies=\"false\"\n";
+      }
+      linkOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n");
+      // Use the NOINHERIT macro to avoid getting VS project default
+      // 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() < cmGlobalVisualStudioGenerator::VS8 ||
+          this->FortranProject) {
+        this->Internal->OutputObjects(fout, target, " ");
+      }
+      fout << " ";
+      this->Internal->OutputLibraries(fout, cli.GetItems());
+      fout << "\"\n";
+      temp = target->GetDirectory(configName);
+      temp += "/";
+      temp += targetNameFull;
+      fout << "\t\t\t\tOutputFile=\""
+           << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
+      this->WriteTargetVersionAttribute(fout, target);
+      linkOptions.OutputFlagMap(fout, "\t\t\t\t");
+      fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
+      this->OutputLibraryDirectories(fout, cli.GetDirectories());
+      fout << "\"\n";
+      std::string path = this->ConvertToXMLOutputPathSingle(
+        target->GetPDBDirectory(configName).c_str());
+      fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" << targetNamePDB
+           << "\"\n";
+      if (targetOptions.IsDebug()) {
+        fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
+      }
+      if (this->WindowsCEProject) {
+        if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS9) {
+          fout << "\t\t\t\tSubSystem=\"9\"\n";
+        } else {
+          fout << "\t\t\t\tSubSystem=\"8\"\n";
         }
 
-      if(!linkOptions.GetFlag("EntryPointSymbol"))
-        {
-        const char* entryPointSymbol = targetOptions.UsingUnicode() ?
-          (isWin32Executable ? "wWinMainCRTStartup" : "mainWCRTStartup") :
-          (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup");
-        fout << "\t\t\t\tEntryPointSymbol=\"" << entryPointSymbol << "\"\n";
+        if (!linkOptions.GetFlag("EntryPointSymbol")) {
+          const char* entryPointSymbol = targetOptions.UsingUnicode()
+            ? (isWin32Executable ? "wWinMainCRTStartup" : "mainWCRTStartup")
+            : (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup");
+          fout << "\t\t\t\tEntryPointSymbol=\"" << entryPointSymbol << "\"\n";
         }
-      }
-    else if ( this->FortranProject )
-      {
-      fout << "\t\t\t\tSubSystem=\""
-           << (isWin32Executable ? "subSystemWindows" : "subSystemConsole")
-           << "\"\n";
-      }
-    else
-      {
-      fout << "\t\t\t\tSubSystem=\""
-           << (isWin32Executable ? "2" : "1")
-           << "\"\n";
-      }
-    std::string stackVar = "CMAKE_";
-    stackVar += linkLanguage;
-    stackVar += "_STACK_SIZE";
-    const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
-    if(stackVal)
-      {
-      fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
-      }
-    temp = target->GetDirectory(configName, true);
-    temp += "/";
-    temp += targetNameImport;
-    fout << "\t\t\t\tImportLibrary=\""
-         << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
-    break;
+      } else if (this->FortranProject) {
+        fout << "\t\t\t\tSubSystem=\""
+             << (isWin32Executable ? "subSystemWindows" : "subSystemConsole")
+             << "\"\n";
+      } else {
+        fout << "\t\t\t\tSubSystem=\"" << (isWin32Executable ? "2" : "1")
+             << "\"\n";
+      }
+      std::string stackVar = "CMAKE_";
+      stackVar += linkLanguage;
+      stackVar += "_STACK_SIZE";
+      const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
+      if (stackVal) {
+        fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
+      }
+      temp = target->GetDirectory(configName, true);
+      temp += "/";
+      temp += targetNameImport;
+      fout << "\t\t\t\tImportLibrary=\""
+           << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
+      break;
     }
     case cmState::UTILITY:
     case cmState::GLOBAL_TARGET:
     case cmState::INTERFACE_LIBRARY:
       break;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalVisualStudio7Generator
-::WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt)
+void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
+  std::ostream& fout, std::string const& config, cmGeneratorTarget* target)
+{
+  if (this->WindowsCEProject) {
+    if (const char* dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY")) {
+      /* clang-format off */
+      fout <<
+        "\t\t\t<DeploymentTool\n"
+        "\t\t\t\tForceDirty=\"-1\"\n"
+        "\t\t\t\tRemoteDirectory=\"" << this->EscapeForXML(dir) << "\"\n"
+        "\t\t\t\tRegisterOutput=\"0\"\n"
+        "\t\t\t\tAdditionalFiles=\"\"/>\n"
+        ;
+      /* clang-format on */
+      std::string const exe =
+        dir + std::string("\\") + target->GetFullName(config);
+      /* clang-format off */
+      fout <<
+        "\t\t\t<DebuggerTool\n"
+        "\t\t\t\tRemoteExecutable=\"" << this->EscapeForXML(exe) << "\"\n"
+        "\t\t\t\tArguments=\"\"\n"
+        "\t\t\t/>\n"
+        ;
+      /* clang-format on */
+    }
+  }
+}
+
+void cmLocalVisualStudio7Generator::WriteTargetVersionAttribute(
+  std::ostream& fout, cmGeneratorTarget* gt)
 {
   int major;
   int minor;
@@ -1385,89 +1292,74 @@ cmLocalVisualStudio7Generator
   fout << "\t\t\t\tVersion=\"" << major << "." << minor << "\"\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalVisualStudio7GeneratorInternals
-::OutputLibraries(std::ostream& fout, ItemVector const& libs)
+void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
+  std::ostream& fout, ItemVector const& libs)
 {
   cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
-  for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
-    {
-    if(l->IsPath)
-      {
-      std::string rel = lg->Convert(l->Value.c_str(),
-                                    cmLocalGenerator::START_OUTPUT,
-                                    cmLocalGenerator::UNCHANGED);
+  for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
+    if (l->IsPath) {
+      std::string rel =
+        lg->Convert(l->Value.c_str(), cmOutputConverter::START_OUTPUT,
+                    cmOutputConverter::UNCHANGED);
       fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
-      }
-    else if (!l->Target
-        || l->Target->GetType() != cmState::INTERFACE_LIBRARY)
-      {
+    } else if (!l->Target ||
+               l->Target->GetType() != cmState::INTERFACE_LIBRARY) {
       fout << l->Value << " ";
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalVisualStudio7GeneratorInternals
-::OutputObjects(std::ostream& fout, cmGeneratorTarget* gt, const char* isep)
+void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
+  std::ostream& fout, cmGeneratorTarget* gt, const char* isep)
 {
   // VS < 8 does not support per-config source locations so we
   // list object library content on the link line instead.
   cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
   std::vector<std::string> objs;
   gt->UseObjectLibraries(objs, "");
-  const char* sep = isep? isep : "";
-  for(std::vector<std::string>::const_iterator
-        oi = objs.begin(); oi != objs.end(); ++oi)
-    {
-    std::string rel = lg->Convert(oi->c_str(),
-                                  cmLocalGenerator::START_OUTPUT,
-                                  cmLocalGenerator::UNCHANGED);
+  const char* sep = isep ? isep : "";
+  for (std::vector<std::string>::const_iterator oi = objs.begin();
+       oi != objs.end(); ++oi) {
+    std::string rel = lg->Convert(oi->c_str(), cmOutputConverter::START_OUTPUT,
+                                  cmOutputConverter::UNCHANGED);
     fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
     sep = " ";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmLocalVisualStudio7Generator
-::OutputLibraryDirectories(std::ostream& fout,
-                           std::vector<std::string> const& dirs)
+void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
+  std::ostream& fout, std::vector<std::string> const& dirs)
 {
   const char* comma = "";
-  for(std::vector<std::string>::const_iterator d = dirs.begin();
-      d != dirs.end(); ++d)
-    {
+  for (std::vector<std::string>::const_iterator d = dirs.begin();
+       d != dirs.end(); ++d) {
     // Remove any trailing slash and skip empty paths.
     std::string dir = *d;
-    if(dir[dir.size()-1] == '/')
-      {
-      dir = dir.substr(0, dir.size()-1);
-      }
-    if(dir.empty())
-      {
+    if (dir[dir.size() - 1] == '/') {
+      dir = dir.substr(0, dir.size() - 1);
+    }
+    if (dir.empty()) {
       continue;
-      }
+    }
 
     // Switch to a relative path specification if it is shorter.
-    if(cmSystemTools::FileIsFullPath(dir.c_str()))
-      {
-      std::string rel = this->Convert(dir.c_str(), START_OUTPUT, UNCHANGED);
-      if(rel.size() < dir.size())
-        {
+    if (cmSystemTools::FileIsFullPath(dir.c_str())) {
+      std::string rel =
+        this->Convert(dir.c_str(), cmOutputConverter::START_OUTPUT,
+                      cmOutputConverter::UNCHANGED);
+      if (rel.size() < dir.size()) {
         dir = rel;
-        }
       }
+    }
 
     // First search a configuration-specific subdirectory and then the
     // original directory.
     fout << comma
-         << this->ConvertToXMLOutputPath((dir+"/$(ConfigurationName)").c_str())
+         << this->ConvertToXMLOutputPath(
+              (dir + "/$(ConfigurationName)").c_str())
          << "," << this->ConvertToXMLOutputPath(dir.c_str());
     comma = ",";
-    }
+  }
 }
 
 void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
@@ -1483,27 +1375,23 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
   // get the classes from the source lists then add them to the groups
   this->ModuleDefinitionFile = "";
   std::vector<cmSourceFile*> classes;
-  if (!target->GetConfigCommonSourceFiles(classes))
-    {
+  if (!target->GetConfigCommonSourceFiles(classes)) {
     return;
-    }
-  for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
-      i != classes.end(); i++)
-    {
-    if (!(*i)->GetObjectLibrary().empty())
-      {
+  }
+  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")
-      {
+    if (cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF") {
       this->ModuleDefinitionFile = (*i)->GetFullPath();
-      }
+    }
     cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
     sourceGroup->AssignSource(*i);
-    }
+  }
 
   // open the project
   this->WriteProjectStart(fout, libName, target, sourceGroups);
@@ -1512,34 +1400,29 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
 
   fout << "\t<Files>\n";
 
-
   // Loop through every source group.
-  for(unsigned int i = 0; i < sourceGroups.size(); ++i)
-    {
+  for (unsigned int i = 0; i < sourceGroups.size(); ++i) {
     cmSourceGroup sg = sourceGroups[i];
     this->WriteGroup(&sg, target, fout, libName, configs);
-    }
+  }
 
-  if(this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8
-      && !this->FortranProject)
-    {
+  if (this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8 &&
+      !this->FortranProject) {
     // VS >= 8 support per-config source locations so we
     // list object library content as external objects.
     std::vector<std::string> objs;
     target->UseObjectLibraries(objs, "");
-    if(!objs.empty())
-      {
+    if (!objs.empty()) {
       // TODO: Separate sub-filter for each object library used?
       fout << "\t\t<Filter Name=\"Object Libraries\">\n";
-      for(std::vector<std::string>::const_iterator
-            oi = objs.begin(); oi != objs.end(); ++oi)
-        {
+      for (std::vector<std::string>::const_iterator oi = objs.begin();
+           oi != objs.end(); ++oi) {
         std::string o = this->ConvertToXMLOutputPathSingle(oi->c_str());
         fout << "\t\t\t<File RelativePath=\"" << o << "\" />\n";
-        }
-      fout << "\t\t</Filter>\n";
       }
+      fout << "\t\t</Filter>\n";
     }
+  }
 
   fout << "\t</Files>\n";
 
@@ -1567,143 +1450,119 @@ public:
   std::map<std::string, cmLVS7GFileConfig> FileConfigMap;
 };
 
-cmLocalVisualStudio7GeneratorFCInfo
-::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg,
-                                      cmGeneratorTarget* gt,
-                                      cmSourceFile const& sf,
-                                      std::vector<std::string> const& configs)
+cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
+  cmLocalVisualStudio7Generator* lg, cmGeneratorTarget* gt,
+  cmSourceFile const& sf, std::vector<std::string> const& configs)
 {
   std::string objectName;
-  if(gt->HasExplicitObjectName(&sf))
-    {
+  if (gt->HasExplicitObjectName(&sf)) {
     objectName = gt->GetObjectName(&sf);
-    }
+  }
 
   // Compute per-source, per-config information.
-  for(std::vector<std::string>::const_iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = configs.begin();
+       i != configs.end(); ++i) {
     std::string configUpper = cmSystemTools::UpperCase(*i);
     cmLVS7GFileConfig fc;
     bool needfc = false;
-    if(!objectName.empty())
-      {
+    if (!objectName.empty()) {
       fc.ObjectName = objectName;
       needfc = true;
-      }
-    if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
-      {
+    }
+    if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
       fc.CompileFlags = cflags;
       needfc = true;
-      }
-    if(lg->FortranProject)
-      {
-      switch(lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT")))
-        {
-        case cmLocalGenerator::FortranFormatFixed:
+    }
+    if (lg->FortranProject) {
+      switch (lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT"))) {
+        case cmOutputConverter::FortranFormatFixed:
           fc.CompileFlags = "-fixed " + fc.CompileFlags;
           needfc = true;
           break;
-        case cmLocalGenerator::FortranFormatFree:
+        case cmOutputConverter::FortranFormatFree:
           fc.CompileFlags = "-free " + fc.CompileFlags;
           needfc = true;
           break;
-        default: break;
-        }
+        default:
+          break;
       }
-    if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
-      {
+    }
+    if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
       fc.CompileDefs = cdefs;
       needfc = true;
-      }
+    }
     std::string defPropName = "COMPILE_DEFINITIONS_";
     defPropName += configUpper;
-    if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
-      {
+    if (const char* ccdefs = sf.GetProperty(defPropName.c_str())) {
       fc.CompileDefsConfig = ccdefs;
       needfc = true;
-      }
+    }
 
     // Check for extra object-file dependencies.
-    if(const char* deps = sf.GetProperty("OBJECT_DEPENDS"))
-      {
+    if (const char* deps = sf.GetProperty("OBJECT_DEPENDS")) {
       std::vector<std::string> depends;
       cmSystemTools::ExpandListArgument(deps, depends);
       const char* sep = "";
-      for(std::vector<std::string>::iterator j = depends.begin();
-          j != depends.end(); ++j)
-        {
+      for (std::vector<std::string>::iterator j = depends.begin();
+           j != depends.end(); ++j) {
         fc.AdditionalDeps += sep;
         fc.AdditionalDeps += lg->ConvertToXMLOutputPath(j->c_str());
         sep = ";";
         needfc = true;
-        }
       }
+    }
 
     std::string lang =
-      lg->GlobalGenerator->GetLanguageFromExtension
-      (sf.GetExtension().c_str());
+      lg->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
     const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
     const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str());
     bool needForceLang = false;
     // source file does not match its extension language
-    if(lang != sourceLang)
-      {
+    if (lang != sourceLang) {
       needForceLang = true;
       lang = sourceLang;
-      }
+    }
     // If HEADER_FILE_ONLY is set, we must suppress this generation in
     // the project file
-    fc.ExcludedFromBuild =
-      (sf.GetPropertyAsBool("HEADER_FILE_ONLY"));
-    if(fc.ExcludedFromBuild)
-      {
+    fc.ExcludedFromBuild = (sf.GetPropertyAsBool("HEADER_FILE_ONLY"));
+    if (fc.ExcludedFromBuild) {
       needfc = true;
-      }
+    }
 
     // if the source file does not match the linker language
     // then force c or c++
-    if(needForceLang || (linkLanguage != lang))
-      {
-      if(lang == "CXX")
-        {
+    if (needForceLang || (linkLanguage != lang)) {
+      if (lang == "CXX") {
         // force a C++ file type
         fc.CompileFlags += " /TP ";
         needfc = true;
-        }
-      else if(lang == "C")
-        {
+      } else if (lang == "C") {
         // force to c
         fc.CompileFlags += " /TC ";
         needfc = true;
-        }
       }
+    }
 
-    if(needfc)
-      {
+    if (needfc) {
       this->FileConfigMap[*i] = fc;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalVisualStudio7Generator
-::ComputeLongestObjectDirectory(cmGeneratorTarget const* target) const
+std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory(
+  cmGeneratorTarget const* target) const
 {
   std::vector<std::string> configs;
   target->Target->GetMakefile()->GetConfigurations(configs);
 
   // Compute the maximum length configuration name.
   std::string config_max;
-  for(std::vector<std::string>::iterator i = configs.begin();
-      i != configs.end(); ++i)
-    {
-    if(i->size() > config_max.size())
-      {
+  for (std::vector<std::string>::iterator i = configs.begin();
+       i != configs.end(); ++i) {
+    if (i->size() > config_max.size()) {
       config_max = *i;
-      }
     }
+  }
 
   // Compute the maximum length full path to the intermediate
   // files directory for any configuration.  This is used to construct
@@ -1718,216 +1577,179 @@ cmLocalVisualStudio7Generator
   return dir_max;
 }
 
-bool cmLocalVisualStudio7Generator
-::WriteGroup(const cmSourceGroup *sg, cmGeneratorTarget* target,
-             std::ostream &fout, const std::string& libName,
-             std::vector<std::string> const& configs)
+bool cmLocalVisualStudio7Generator::WriteGroup(
+  const cmSourceGroup* sg, cmGeneratorTarget* target, std::ostream& fout,
+  const std::string& libName, std::vector<std::string> const& configs)
 {
   cmGlobalVisualStudio7Generator* gg =
-    static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
-  const std::vector<const cmSourceFile *> &sourceFiles =
-    sg->GetSourceFiles();
-  std::vector<cmSourceGroup> const& children  = sg->GetGroupChildren();
+    static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
+  const std::vector<const cmSourceFile*>& sourceFiles = sg->GetSourceFiles();
+  std::vector<cmSourceGroup> const& children = sg->GetGroupChildren();
 
   // Write the children to temporary output.
   bool hasChildrenWithSources = false;
   std::ostringstream tmpOut;
-  for(unsigned int i=0;i<children.size();++i)
-    {
-    if(this->WriteGroup(&children[i], target, tmpOut, libName, configs))
-      {
+  for (unsigned int i = 0; i < children.size(); ++i) {
+    if (this->WriteGroup(&children[i], target, tmpOut, libName, configs)) {
       hasChildrenWithSources = true;
-      }
     }
+  }
 
   // If the group is empty, don't write it at all.
-  if(sourceFiles.empty() && !hasChildrenWithSources)
-    {
+  if (sourceFiles.empty() && !hasChildrenWithSources) {
     return false;
-    }
+  }
 
   // If the group has a name, write the header.
   std::string name = sg->GetName();
-  if(name != "")
-    {
+  if (name != "") {
     this->WriteVCProjBeginGroup(fout, name.c_str(), "");
-    }
+  }
 
   // Loop through each source in the source group.
-  for(std::vector<const cmSourceFile *>::const_iterator sf =
-        sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
-    {
+  for (std::vector<const cmSourceFile*>::const_iterator sf =
+         sourceFiles.begin();
+       sf != sourceFiles.end(); ++sf) {
     std::string source = (*sf)->GetFullPath();
     FCInfo fcinfo(this, target, *(*sf), configs);
 
     if (source != libName || target->GetType() == cmState::UTILITY ||
-      target->GetType() == cmState::GLOBAL_TARGET )
-      {
+        target->GetType() == cmState::GLOBAL_TARGET) {
       fout << "\t\t\t<File\n";
       std::string d = this->ConvertToXMLOutputPathSingle(source.c_str());
       // Tell MS-Dev what the source is.  If the compiler knows how to
       // build it, then it will.
       fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
-      if(cmCustomCommand const* command = (*sf)->GetCustomCommand())
-        {
-        this->WriteCustomRule(fout, configs, source.c_str(),
-                              *command, fcinfo);
-        }
-      else if(!fcinfo.FileConfigMap.empty())
-        {
+      if (cmCustomCommand const* command = (*sf)->GetCustomCommand()) {
+        this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo);
+      } else if (!fcinfo.FileConfigMap.empty()) {
         const char* aCompilerTool = "VCCLCompilerTool";
         const char* ppLang = "CXX";
-        if(this->FortranProject)
-          {
+        if (this->FortranProject) {
           aCompilerTool = "VFFortranCompilerTool";
-          }
+        }
         std::string const& lang = (*sf)->GetLanguage();
         std::string ext = (*sf)->GetExtension();
         ext = cmSystemTools::LowerCase(ext);
-        if(ext == "idl")
-          {
+        if (ext == "idl") {
           aCompilerTool = "VCMIDLTool";
-          if(this->FortranProject)
-            {
+          if (this->FortranProject) {
             aCompilerTool = "VFMIDLTool";
-            }
           }
-        if(ext == "rc")
-          {
+        }
+        if (ext == "rc") {
           aCompilerTool = "VCResourceCompilerTool";
           ppLang = "RC";
-          if(this->FortranProject)
-            {
+          if (this->FortranProject) {
             aCompilerTool = "VFResourceCompilerTool";
-            }
           }
-        if(ext == "def")
-          {
+        }
+        if (ext == "def") {
           aCompilerTool = "VCCustomBuildTool";
-          if(this->FortranProject)
-            {
+          if (this->FortranProject) {
             aCompilerTool = "VFCustomBuildTool";
-            }
           }
+        }
         if (gg->IsMasmEnabled() && !this->FortranProject &&
-            lang == "ASM_MASM")
-          {
+            lang == "ASM_MASM") {
           aCompilerTool = "MASM";
-          }
-        for(std::map<std::string, cmLVS7GFileConfig>::const_iterator
-              fci = fcinfo.FileConfigMap.begin();
-            fci != fcinfo.FileConfigMap.end(); ++fci)
-          {
+        }
+        for (std::map<std::string, cmLVS7GFileConfig>::const_iterator fci =
+               fcinfo.FileConfigMap.begin();
+             fci != fcinfo.FileConfigMap.end(); ++fci) {
           cmLVS7GFileConfig const& fc = fci->second;
           fout << "\t\t\t\t<FileConfiguration\n"
-               << "\t\t\t\t\tName=\""  << fci->first
-               << "|" << gg->GetPlatformName() << "\"";
-          if(fc.ExcludedFromBuild)
-            {
+               << "\t\t\t\t\tName=\"" << fci->first << "|"
+               << gg->GetPlatformName() << "\"";
+          if (fc.ExcludedFromBuild) {
             fout << " ExcludedFromBuild=\"true\"";
-            }
+          }
           fout << ">\n";
           fout << "\t\t\t\t\t<Tool\n"
                << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
-          if(!fc.CompileFlags.empty() ||
-             !fc.CompileDefs.empty() ||
-             !fc.CompileDefsConfig.empty())
-            {
+          if (!fc.CompileFlags.empty() || !fc.CompileDefs.empty() ||
+              !fc.CompileDefsConfig.empty()) {
             Options::Tool tool = Options::Compiler;
             cmVS7FlagTable const* table =
               cmLocalVisualStudio7GeneratorFlagTable;
-            if(this->FortranProject)
-              {
+            if (this->FortranProject) {
               tool = Options::FortranCompiler;
               table = cmLocalVisualStudio7GeneratorFortranFlagTable;
-              }
-            Options fileOptions(this, tool, table,
-                                gg->ExtraFlagTable);
+            }
+            Options fileOptions(this, tool, table, gg->ExtraFlagTable);
             fileOptions.Parse(fc.CompileFlags.c_str());
             fileOptions.AddDefines(fc.CompileDefs.c_str());
             fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
             fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n");
             fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
-            fileOptions.OutputPreprocessorDefinitions(fout,
-                                                      "\t\t\t\t\t", "\n",
+            fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n",
                                                       ppLang);
-            }
-          if(!fc.AdditionalDeps.empty())
-            {
+          }
+          if (!fc.AdditionalDeps.empty()) {
             fout << "\t\t\t\t\tAdditionalDependencies=\""
                  << fc.AdditionalDeps.c_str() << "\"\n";
-            }
-          if(!fc.ObjectName.empty())
-            {
+          }
+          if (!fc.ObjectName.empty()) {
             fout << "\t\t\t\t\tObjectFile=\"$(IntDir)/"
                  << fc.ObjectName.c_str() << "\"\n";
-            }
+          }
           fout << "\t\t\t\t\t/>\n"
                << "\t\t\t\t</FileConfiguration>\n";
-          }
         }
-      fout << "\t\t\t</File>\n";
       }
+      fout << "\t\t\t</File>\n";
     }
+  }
 
   // If the group has children with source files, write the children.
-  if(hasChildrenWithSources)
-    {
+  if (hasChildrenWithSources) {
     fout << tmpOut.str();
-    }
+  }
 
   // If the group has a name, write the footer.
-  if(name != "")
-    {
+  if (name != "") {
     this->WriteVCProjEndGroup(fout);
-    }
+  }
 
   return true;
 }
 
-void cmLocalVisualStudio7Generator::
-WriteCustomRule(std::ostream& fout,
-                std::vector<std::string> const& configs,
-                const char* source,
-                const cmCustomCommand& command,
-                FCInfo& fcinfo)
+void cmLocalVisualStudio7Generator::WriteCustomRule(
+  std::ostream& fout, std::vector<std::string> const& configs,
+  const char* source, const cmCustomCommand& command, FCInfo& fcinfo)
 {
   cmGlobalVisualStudio7Generator* gg =
-    static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+    static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
 
   // Write the rule for each configuration.
   const char* compileTool = "VCCLCompilerTool";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     compileTool = "VFCLCompilerTool";
-    }
+  }
   const char* customTool = "VCCustomBuildTool";
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     customTool = "VFCustomBuildTool";
-    }
+  }
   for (std::vector<std::string>::const_iterator i = configs.begin();
-       i != configs.end(); ++i)
-    {
+       i != configs.end(); ++i) {
     cmCustomCommandGenerator ccg(command, *i, this);
     cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
     fout << "\t\t\t\t<FileConfiguration\n";
-    fout << "\t\t\t\t\tName=\"" << *i << "|"
-         << gg->GetPlatformName() << "\">\n";
-    if(!fc.CompileFlags.empty())
-      {
+    fout << "\t\t\t\t\tName=\"" << *i << "|" << gg->GetPlatformName()
+         << "\">\n";
+    if (!fc.CompileFlags.empty()) {
       fout << "\t\t\t\t\t<Tool\n"
            << "\t\t\t\t\tName=\"" << compileTool << "\"\n"
            << "\t\t\t\t\tAdditionalOptions=\""
            << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
-      }
+    }
 
     std::string comment = this->ConstructComment(ccg);
     std::string script = this->ConstructScript(ccg);
-    if(this->FortranProject)
-      {
+    if (this->FortranProject) {
       cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
-      }
+    }
+    /* clang-format off */
     fout << "\t\t\t\t\t<Tool\n"
          << "\t\t\t\t\tName=\"" << customTool << "\"\n"
          << "\t\t\t\t\tDescription=\""
@@ -1935,129 +1757,107 @@ WriteCustomRule(std::ostream& fout,
          << "\t\t\t\t\tCommandLine=\""
          << this->EscapeForXML(script.c_str()) << "\"\n"
          << "\t\t\t\t\tAdditionalDependencies=\"";
-    if(ccg.GetDepends().empty())
-      {
+    /* clang-format on */
+    if (ccg.GetDepends().empty()) {
       // There are no real dependencies.  Produce an artificial one to
       // make sure the rule runs reliably.
-      if(!cmSystemTools::FileExists(source))
-        {
+      if (!cmSystemTools::FileExists(source)) {
         cmsys::ofstream depout(source);
         depout << "Artificial dependency for a custom command.\n";
-        }
-      fout << this->ConvertToXMLOutputPath(source);
       }
-    else
-      {
+      fout << this->ConvertToXMLOutputPath(source);
+    } else {
       // Write out the dependencies for the rule.
-      for(std::vector<std::string>::const_iterator d =
-          ccg.GetDepends().begin();
-          d != ccg.GetDepends().end();
-          ++d)
-        {
+      for (std::vector<std::string>::const_iterator d =
+             ccg.GetDepends().begin();
+           d != ccg.GetDepends().end(); ++d) {
         // Get the real name of the dependency in case it is a CMake target.
         std::string dep;
-        if(this->GetRealDependency(d->c_str(), i->c_str(), dep))
-          {
-          fout << this->ConvertToXMLOutputPath(dep.c_str())
-               << ";";
-          }
+        if (this->GetRealDependency(d->c_str(), i->c_str(), dep)) {
+          fout << this->ConvertToXMLOutputPath(dep.c_str()) << ";";
         }
       }
+    }
     fout << "\"\n";
     fout << "\t\t\t\t\tOutputs=\"";
-    if(ccg.GetOutputs().empty())
-      {
+    if (ccg.GetOutputs().empty()) {
       fout << source << "_force";
-      }
-    else
-      {
+    } else {
       // Write a rule for the output generated by this command.
       const char* sep = "";
-      for(std::vector<std::string>::const_iterator o =
-          ccg.GetOutputs().begin();
-          o != ccg.GetOutputs().end();
-          ++o)
-        {
+      for (std::vector<std::string>::const_iterator o =
+             ccg.GetOutputs().begin();
+           o != ccg.GetOutputs().end(); ++o) {
         fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
         sep = ";";
-        }
       }
+    }
     fout << "\"/>\n";
     fout << "\t\t\t\t</FileConfiguration>\n";
-    }
+  }
 }
 
-
 void cmLocalVisualStudio7Generator::WriteVCProjBeginGroup(std::ostream& fout,
                                                           const char* group,
-                                                          const char* )
+                                                          const char*)
 {
+  /* clang-format off */
   fout << "\t\t<Filter\n"
        << "\t\t\tName=\"" << group << "\"\n"
        << "\t\t\tFilter=\"\">\n";
+  /* clang-format on */
 }
 
-
 void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
 {
   fout << "\t\t</Filter>\n";
 }
 
-
 // look for custom rules on a target and collect them together
-void cmLocalVisualStudio7Generator
-::OutputTargetRules(std::ostream& fout,
-                    const std::string& configName,
-                    cmGeneratorTarget *target,
-                    const std::string& /*libName*/)
+void cmLocalVisualStudio7Generator::OutputTargetRules(
+  std::ostream& fout, const std::string& configName, cmGeneratorTarget* target,
+  const std::string& /*libName*/)
 {
-  if (target->GetType() > cmState::GLOBAL_TARGET)
-    {
+  if (target->GetType() > cmState::GLOBAL_TARGET) {
     return;
-    }
+  }
   EventWriter event(this, configName, fout);
 
   // Add pre-build event.
   const char* tool =
-    this->FortranProject? "VFPreBuildEventTool":"VCPreBuildEventTool";
+    this->FortranProject ? "VFPreBuildEventTool" : "VCPreBuildEventTool";
   event.Start(tool);
   event.Write(target->GetPreBuildCommands());
   event.Finish();
 
   // Add pre-link event.
-  tool = this->FortranProject? "VFPreLinkEventTool":"VCPreLinkEventTool";
+  tool = this->FortranProject ? "VFPreLinkEventTool" : "VCPreLinkEventTool";
   event.Start(tool);
   bool addedPrelink = false;
   if (target->GetType() == cmState::SHARED_LIBRARY &&
-      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
-    {
-    if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
+      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+    if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) {
       addedPrelink = true;
-      std::vector<cmCustomCommand> commands =
-        target->GetPreLinkCommands();
-      cmGlobalVisualStudioGenerator* gg
-        = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
-      gg->AddSymbolExportCommand(
-        target, commands, configName);
+      std::vector<cmCustomCommand> commands = target->GetPreLinkCommands();
+      cmGlobalVisualStudioGenerator* gg =
+        static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
+      gg->AddSymbolExportCommand(target, commands, configName);
       event.Write(commands);
-      }
     }
-  if (!addedPrelink)
-    {
+  }
+  if (!addedPrelink) {
     event.Write(target->GetPreLinkCommands());
-    }
+  }
   cmsys::auto_ptr<cmCustomCommand> pcc(
-    this->MaybeCreateImplibDir(target,
-                               configName, this->FortranProject));
-  if(pcc.get())
-    {
+    this->MaybeCreateImplibDir(target, configName, this->FortranProject));
+  if (pcc.get()) {
     event.Write(*pcc);
-    }
+  }
   event.Finish();
 
   // Add post-build event.
-  tool = this->FortranProject? "VFPostBuildEventTool":"VCPostBuildEventTool";
+  tool =
+    this->FortranProject ? "VFPostBuildEventTool" : "VCPostBuildEventTool";
   event.Start(tool);
   event.Write(target->GetPostBuildCommands());
   event.Finish();
@@ -2072,136 +1872,124 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
   const char* vsLocalpath = target->GetProperty("VS_SCC_LOCALPATH");
   const char* vsProvider = target->GetProperty("VS_SCC_PROVIDER");
 
-  if(vsProvider && vsLocalpath && vsProjectname)
-    {
+  if (vsProvider && vsLocalpath && vsProjectname) {
+    /* clang-format off */
     fout << "\tSccProjectName=\"" << vsProjectname << "\"\n"
          << "\tSccLocalPath=\"" << vsLocalpath << "\"\n"
          << "\tSccProvider=\"" << vsProvider << "\"\n";
+    /* clang-format on */
 
     const char* vsAuxPath = target->GetProperty("VS_SCC_AUXPATH");
-    if(vsAuxPath)
-      {
+    if (vsAuxPath) {
       fout << "\tSccAuxPath=\"" << vsAuxPath << "\"\n";
-      }
     }
+  }
 }
 
-void
-cmLocalVisualStudio7Generator
-::WriteProjectStartFortran(std::ostream& fout,
-                           const std::string& libName,
-                           cmGeneratorTarget *target)
+void cmLocalVisualStudio7Generator::WriteProjectStartFortran(
+  std::ostream& fout, const std::string& libName, cmGeneratorTarget* target)
 {
 
   cmGlobalVisualStudio7Generator* gg =
-    static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+    static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
+  /* clang-format off */
   fout << "<?xml version=\"1.0\" encoding = \""
        << gg->Encoding() << "\"?>\n"
        << "<VisualStudioProject\n"
        << "\tProjectCreator=\"Intel Fortran\"\n"
        << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n";
+  /* clang-format on */
   const char* keyword = target->GetProperty("VS_KEYWORD");
-  if(!keyword)
-    {
+  if (!keyword) {
     keyword = "Console Application";
-    }
+  }
   const char* projectType = 0;
-  switch(target->GetType())
-    {
+  switch (target->GetType()) {
     case cmState::STATIC_LIBRARY:
       projectType = "typeStaticLibrary";
-      if(keyword)
-        {
+      if (keyword) {
         keyword = "Static Library";
-        }
+      }
       break;
     case cmState::SHARED_LIBRARY:
     case cmState::MODULE_LIBRARY:
       projectType = "typeDynamicLibrary";
-      if(!keyword)
-        {
+      if (!keyword) {
         keyword = "Dll";
-        }
+      }
       break;
     case cmState::EXECUTABLE:
-      if(!keyword)
-        {
+      if (!keyword) {
         keyword = "Console Application";
-        }
+      }
       projectType = 0;
       break;
     case cmState::UTILITY:
     case cmState::GLOBAL_TARGET:
     default:
       break;
-    }
-  if(projectType)
-    {
+  }
+  if (projectType) {
     fout << "\tProjectType=\"" << projectType << "\"\n";
-    }
+  }
   this->WriteProjectSCC(fout, target);
+  /* clang-format off */
   fout<< "\tKeyword=\"" << keyword << "\">\n"
        << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n"
        << "\t<Platforms>\n"
        << "\t\t<Platform\n\t\t\tName=\"" << gg->GetPlatformName() << "\"/>\n"
        << "\t</Platforms>\n";
+  /* clang-format on */
 }
 
-
-void
-cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
-                                                 const std::string& libName,
-                                                 cmGeneratorTarget *target,
-                                                 std::vector<cmSourceGroup> &)
+void cmLocalVisualStudio7Generator::WriteProjectStart(
+  std::ostream& fout, const std::string& libName, cmGeneratorTarget* target,
+  std::vector<cmSourceGroup>&)
 {
-  if(this->FortranProject)
-    {
+  if (this->FortranProject) {
     this->WriteProjectStartFortran(fout, libName, target);
     return;
-    }
+  }
 
   cmGlobalVisualStudio7Generator* gg =
-    static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+    static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
 
+  /* clang-format off */
   fout << "<?xml version=\"1.0\" encoding = \""
        << gg->Encoding() << "\"?>\n"
        << "<VisualStudioProject\n"
        << "\tProjectType=\"Visual C++\"\n";
-  if(gg->GetVersion() == cmGlobalVisualStudioGenerator::VS71)
-    {
+  /* clang-format on */
+  if (gg->GetVersion() == cmGlobalVisualStudioGenerator::VS71) {
     fout << "\tVersion=\"7.10\"\n";
-    }
-  else
-    {
-    fout <<  "\tVersion=\"" << (gg->GetVersion()/10) << ".00\"\n";
-    }
+  } else {
+    fout << "\tVersion=\"" << (gg->GetVersion() / 10) << ".00\"\n";
+  }
   const char* projLabel = target->GetProperty("PROJECT_LABEL");
-  if(!projLabel)
-    {
+  if (!projLabel) {
     projLabel = libName.c_str();
-    }
+  }
   const char* keyword = target->GetProperty("VS_KEYWORD");
-  if(!keyword)
-    {
+  if (!keyword) {
     keyword = "Win32Proj";
-    }
+  }
   fout << "\tName=\"" << projLabel << "\"\n";
-  if(gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS8)
-    {
+  if (gg->GetVersion() >= cmGlobalVisualStudioGenerator::VS8) {
     fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
-    }
+  }
   this->WriteProjectSCC(fout, target);
-  if(const char* targetFrameworkVersion =
-     target->GetProperty("VS_DOTNET_TARGET_FRAMEWORK_VERSION"))
-    {
+  if (const char* targetFrameworkVersion =
+        target->GetProperty("VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
     fout << "\tTargetFrameworkVersion=\"" << targetFrameworkVersion << "\"\n";
-    }
+  }
+  /* clang-format off */
   fout << "\tKeyword=\"" << keyword << "\">\n"
        << "\t<Platforms>\n"
        << "\t\t<Platform\n\t\t\tName=\"" << gg->GetPlatformName() << "\"/>\n"
        << "\t</Platforms>\n";
-  if(gg->IsMasmEnabled())
-    {
+  /* clang-format on */
+  if (gg->IsMasmEnabled()) {
+    /* clang-format off */
     fout <<
       "\t<ToolFiles>\n"
       "\t\t<DefaultToolFile\n"
@@ -2209,32 +1997,30 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
       "\t\t/>\n"
       "\t</ToolFiles>\n"
       ;
-    }
+    /* clang-format on */
+  }
 }
 
-
 void cmLocalVisualStudio7Generator::WriteVCProjFooter(
-    std::ostream& fout,
-    cmGeneratorTarget *target)
+  std::ostream& fout, cmGeneratorTarget* target)
 {
   fout << "\t<Globals>\n";
 
   std::vector<std::string> const& props = target->GetPropertyKeys();
-  for(std::vector<std::string>::const_iterator i = props.begin();
-      i != props.end(); ++i)
-    {
-    if(i->find("VS_GLOBAL_") == 0)
-      {
+  for (std::vector<std::string>::const_iterator i = props.begin();
+       i != props.end(); ++i) {
+    if (i->find("VS_GLOBAL_") == 0) {
       std::string name = i->substr(10);
-      if(name != "")
-        {
+      if (name != "") {
+        /* clang-format off */
         fout << "\t\t<Global\n"
              << "\t\t\tName=\"" << name << "\"\n"
              << "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n"
              << "\t\t/>\n";
-        }
+        /* clang-format on */
       }
     }
+  }
 
   fout << "\t</Globals>\n"
        << "</VisualStudioProject>\n";
@@ -2256,10 +2042,11 @@ std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s)
   return cmLocalVisualStudio7GeneratorEscapeForXML(s);
 }
 
-std::string cmLocalVisualStudio7Generator
-::ConvertToXMLOutputPath(const char* path)
+std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(
+  const char* path)
 {
-  std::string ret = this->ConvertToOutputFormat(path, SHELL);
+  std::string ret =
+    this->ConvertToOutputFormat(path, cmOutputConverter::SHELL);
   cmSystemTools::ReplaceString(ret, "&", "&");
   cmSystemTools::ReplaceString(ret, "\"", """);
   cmSystemTools::ReplaceString(ret, "<", "<");
@@ -2267,10 +2054,11 @@ std::string cmLocalVisualStudio7Generator
   return ret;
 }
 
-std::string cmLocalVisualStudio7Generator
-::ConvertToXMLOutputPathSingle(const char* path)
+std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(
+  const char* path)
 {
-  std::string ret = this->ConvertToOutputFormat(path, SHELL);
+  std::string ret =
+    this->ConvertToOutputFormat(path, cmOutputConverter::SHELL);
   cmSystemTools::ReplaceString(ret, "\"", "");
   cmSystemTools::ReplaceString(ret, "&", "&");
   cmSystemTools::ReplaceString(ret, "<", "<");
@@ -2278,84 +2066,67 @@ std::string cmLocalVisualStudio7Generator
   return ret;
 }
 
-
 // This class is used to parse an existing vs 7 project
 // and extract the GUID
 class cmVS7XMLParser : public cmXMLParser
 {
 public:
-  virtual void EndElement(const std::string& /* name */)
-    {
-    }
+  virtual void EndElement(const std::string& /* name */) {}
   virtual void StartElement(const std::string& name, const char** atts)
-    {
-      // once the GUID is found do nothing
-      if(!this->GUID.empty())
-        {
-        return;
-        }
-      int i =0;
-      if("VisualStudioProject" == name)
-        {
-        while(atts[i])
-          {
-          if(strcmp(atts[i], "ProjectGUID") == 0)
-            {
-            if(atts[i+1])
-              {
-              this->GUID =  atts[i+1];
-              this->GUID = this->GUID.substr(1, this->GUID.size()-2);
-              }
-            else
-              {
-              this->GUID = "";
-              }
-            return;
-            }
-          ++i;
+  {
+    // once the GUID is found do nothing
+    if (!this->GUID.empty()) {
+      return;
+    }
+    int i = 0;
+    if ("VisualStudioProject" == name) {
+      while (atts[i]) {
+        if (strcmp(atts[i], "ProjectGUID") == 0) {
+          if (atts[i + 1]) {
+            this->GUID = atts[i + 1];
+            this->GUID = this->GUID.substr(1, this->GUID.size() - 2);
+          } else {
+            this->GUID = "";
           }
+          return;
         }
+        ++i;
+      }
     }
+  }
   int InitializeParser()
-    {
-      int ret = cmXMLParser::InitializeParser();
-      if(ret == 0)
-        {
-        return ret;
-        }
-      // visual studio projects have a strange encoding, but it is
-      // really utf-8
-      XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
-      return 1;
-    }
+  {
+    int ret = cmXMLParser::InitializeParser();
+    if (ret == 0) {
+      return ret;
+    }
+    // visual studio projects have a strange encoding, but it is
+    // really utf-8
+    XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
+    return 1;
+  }
   std::string GUID;
 };
 
 void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
-  const std::string& name,
-  const char* path)
+  const std::string& name, const char* path)
 {
   cmVS7XMLParser parser;
   parser.ParseFile(path);
   // if we can not find a GUID then we will generate one later
-  if(parser.GUID.empty())
-    {
+  if (parser.GUID.empty()) {
     return;
-    }
+  }
   std::string guidStoreName = name;
   guidStoreName += "_GUID_CMAKE";
   // save the GUID in the cache
-  this->GlobalGenerator->GetCMakeInstance()->
-    AddCacheEntry(guidStoreName.c_str(),
-                  parser.GUID.c_str(),
-                  "Stored GUID",
-                  cmState::INTERNAL);
+  this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
+    guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID",
+    cmState::INTERNAL);
 }
 
-
-//----------------------------------------------------------------------------
-std::string cmLocalVisualStudio7Generator
-::GetTargetDirectory(cmGeneratorTarget const* target) const
+std::string cmLocalVisualStudio7Generator::GetTargetDirectory(
+  cmGeneratorTarget const* target) const
 {
   std::string dir;
   dir += target->GetName();
@@ -2363,20 +2134,17 @@ std::string cmLocalVisualStudio7Generator
   return dir;
 }
 
-//----------------------------------------------------------------------------
 #include <windows.h>
-static bool cmLVS6G_IsFAT(const char* dir)
+static bool cmLVS7G_IsFAT(const char* dir)
 {
-  if(dir[0] && dir[1] == ':')
-    {
+  if (dir[0] && dir[1] == ':') {
     char volRoot[4] = "_:/";
     volRoot[0] = dir[0];
     char fsName[16];
-    if(GetVolumeInformationA(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
-       strstr(fsName, "FAT") != 0)
-      {
+    if (GetVolumeInformationA(volRoot, 0, 0, 0, 0, 0, fsName, 16) &&
+        strstr(fsName, "FAT") != 0) {
       return true;
-      }
     }
+  }
   return false;
 }
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 7bb9cc6..6d1d0fb 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -13,13 +13,13 @@
 #define cmLocalVisualStudio7Generator_h
 
 #include "cmLocalVisualStudioGenerator.h"
+
 #include "cmVisualStudioGeneratorOptions.h"
 
 class cmSourceFile;
 class cmCustomCommand;
 class cmSourceGroup;
 
-
 class cmLocalVisualStudio7GeneratorOptions;
 class cmLocalVisualStudio7GeneratorFCInfo;
 class cmLocalVisualStudio7GeneratorInternals;
@@ -45,26 +45,34 @@ public:
    */
   virtual void Generate();
 
-  enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY};
+  enum BuildType
+  {
+    STATIC_LIBRARY,
+    DLL,
+    EXECUTABLE,
+    WIN32_EXECUTABLE,
+    UTILITY
+  };
 
   /**
    * Specify the type of the build: static, dll, or executable.
    */
-  void SetBuildType(BuildType,const std::string& name);
+  void SetBuildType(BuildType, const std::string& name);
 
-  virtual
-  std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
+  virtual std::string GetTargetDirectory(
+    cmGeneratorTarget const* target) const;
   cmSourceFile* CreateVCProjBuildRule();
   void WriteStampFiles();
-  virtual std::string
-  ComputeLongestObjectDirectory(cmGeneratorTarget const*) const;
+  virtual std::string ComputeLongestObjectDirectory(
+    cmGeneratorTarget const*) const;
 
   virtual void ReadAndStoreExternalGUID(const std::string& name,
                                         const char* path);
   virtual void AddCMakeListsRules();
+
 protected:
-  void CreateSingleVCProj(const std::string& lname,
-                          cmGeneratorTarget *tgt);
+  void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt);
+
 private:
   typedef cmVisualStudioGeneratorOptions Options;
   typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
@@ -74,15 +82,14 @@ private:
   void WriteProjectFiles();
   void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
                          cmGeneratorTarget* tgt,
-                         std::vector<cmSourceGroup> &sgs);
+                         std::vector<cmSourceGroup>& sgs);
   void WriteVCProjFooter(std::ostream& fout, cmGeneratorTarget* target);
   void WriteVCProjFile(std::ostream& fout, const std::string& libName,
                        cmGeneratorTarget* tgt);
   void WriteConfigurations(std::ostream& fout,
                            std::vector<std::string> const& configs,
                            const std::string& libName, cmGeneratorTarget* tgt);
-  void WriteConfiguration(std::ostream& fout,
-                          const std::string& configName,
+  void WriteConfiguration(std::ostream& fout, const std::string& configName,
                           const std::string& libName, cmGeneratorTarget* tgt);
   std::string EscapeForXML(const std::string& s);
   std::string ConvertToXMLOutputPath(const char* path);
@@ -92,30 +99,29 @@ private:
                          const std::string& libName);
   void OutputBuildTool(std::ostream& fout, const std::string& configName,
                        cmGeneratorTarget* t, const Options& targetOptions);
+  void OutputDeploymentDebuggerTool(std::ostream& fout,
+                                    std::string const& config,
+                                    cmGeneratorTarget* target);
   void OutputLibraryDirectories(std::ostream& fout,
                                 std::vector<std::string> const& dirs);
-  void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget *target);
+  void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget* target);
   void WriteProjectStart(std::ostream& fout, const std::string& libName,
                          cmGeneratorTarget* tgt,
-                         std::vector<cmSourceGroup> &sgs);
+                         std::vector<cmSourceGroup>& sgs);
   void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
                                 cmGeneratorTarget* tgt);
-  void WriteVCProjBeginGroup(std::ostream& fout,
-                          const char* group,
-                          const char* filter);
+  void WriteVCProjBeginGroup(std::ostream& fout, const char* group,
+                             const char* filter);
   void WriteVCProjEndGroup(std::ostream& fout);
 
   void WriteCustomRule(std::ostream& fout,
                        std::vector<std::string> const& configs,
-                       const char* source,
-                       const cmCustomCommand& command,
+                       const char* source, const cmCustomCommand& command,
                        FCInfo& fcinfo);
-  void WriteTargetVersionAttribute(std::ostream& fout,
-                                   cmGeneratorTarget* gt);
+  void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
 
-  bool WriteGroup(const cmSourceGroup *sg,
-                  cmGeneratorTarget* target, std::ostream &fout,
-                  const std::string& libName,
+  bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
+                  std::ostream& fout, const std::string& libName,
                   std::vector<std::string> const& configs);
 
   friend class cmLocalVisualStudio7GeneratorFCInfo;
@@ -130,6 +136,4 @@ private:
   cmLocalVisualStudio7GeneratorInternals* Internal;
 };
 
-
 #endif
-
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 561f9a1..85ab615 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -10,26 +10,24 @@
   See the License for more information.
 ============================================================================*/
 #include "cmLocalVisualStudioGenerator.h"
+
+#include "cmCustomCommandGenerator.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmSystemTools.h"
-#include "cmCustomCommandGenerator.h"
 #include "windows.h"
 
-//----------------------------------------------------------------------------
-cmLocalVisualStudioGenerator
-::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf)
+cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator(
+  cmGlobalGenerator* gg, cmMakefile* mf)
   : cmLocalGenerator(gg, mf)
 {
 }
 
-//----------------------------------------------------------------------------
 cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
 cmGlobalVisualStudioGenerator::VSVersion
 cmLocalVisualStudioGenerator::GetVersion() const
 {
@@ -38,10 +36,9 @@ cmLocalVisualStudioGenerator::GetVersion() const
   return gg->GetVersion();
 }
 
-//----------------------------------------------------------------------------
 void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* gt)
+  std::map<cmSourceFile const*, std::string>& mapping,
+  cmGeneratorTarget const* gt)
 {
   std::string dir_max = this->ComputeLongestObjectDirectory(gt);
 
@@ -49,36 +46,34 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
   // 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)
-    {
+  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 += this->GlobalGenerator->GetLanguageOutputExtension(*sf);
     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)
-    {
+  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 += this->GlobalGenerator->GetLanguageOutputExtension(*sf);
-    if(counts[cmSystemTools::LowerCase(objectName)] > 1)
-      {
+    if (counts[cmSystemTools::LowerCase(objectName)] > 1) {
       const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf);
       objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
-      }
-    si->second = objectName;
     }
+    si->second = objectName;
+  }
 }
 
-//----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCustomCommand>
 cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
                                                    const std::string& config,
@@ -89,12 +84,15 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
   // If an executable exports symbols then VS wants to create an
   // import library but forgets to create the output directory.
   // The Intel Fortran plugin always forgets to the directory.
-  if(target->GetType() != cmState::EXECUTABLE &&
-     !(isFortran && target->GetType() == cmState::SHARED_LIBRARY))
-    { return pcc; }
+  if (target->GetType() != cmState::EXECUTABLE &&
+      !(isFortran && target->GetType() == cmState::SHARED_LIBRARY)) {
+    return pcc;
+  }
   std::string outDir = target->GetDirectory(config, false);
   std::string impDir = target->GetDirectory(config, true);
-  if(impDir == outDir) { return pcc; }
+  if (impDir == outDir) {
+    return pcc;
+  }
 
   // Add a pre-build event to create the directory.
   cmCustomCommandLine command;
@@ -107,63 +105,53 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
   std::vector<std::string> no_depends;
   cmCustomCommandLines commands;
   commands.push_back(command);
-  pcc.reset(new cmCustomCommand(0, no_output, no_byproducts,
-                                no_depends, commands, 0, 0));
+  pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, no_depends,
+                                commands, 0, 0));
   pcc->SetEscapeOldStyle(false);
   pcc->SetEscapeAllowMakeVars(true);
   return pcc;
 }
 
-//----------------------------------------------------------------------------
 const char* cmLocalVisualStudioGenerator::ReportErrorLabel() const
 {
   return ":VCReportError";
 }
 
-//----------------------------------------------------------------------------
 const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
 {
   return this->ReportErrorLabel();
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalVisualStudioGenerator
-::ConstructScript(cmCustomCommandGenerator const& ccg,
-                  const std::string& newline_text)
+std::string cmLocalVisualStudioGenerator::ConstructScript(
+  cmCustomCommandGenerator const& ccg, const std::string& newline_text)
 {
   bool useLocal = this->CustomCommandUseLocal();
   std::string workingDirectory = ccg.GetWorkingDirectory();
-  RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE;
+  RelativeRoot relativeRoot = workingDirectory.empty() ? START_OUTPUT : NONE;
 
   // Avoid leading or trailing newlines.
   std::string newline = "";
 
   // Line to check for error between commands.
   std::string check_error = newline_text;
-  if(useLocal)
-    {
+  if (useLocal) {
     check_error += "if %errorlevel% neq 0 goto :cmEnd";
-    }
-  else
-    {
+  } else {
     check_error += "if errorlevel 1 goto ";
     check_error += this->GetReportErrorLabel();
-    }
+  }
 
   // Store the script in a string.
   std::string script;
 
   // Open a local context.
-  if(useLocal)
-    {
+  if (useLocal) {
     script += newline;
     newline = newline_text;
     script += "setlocal";
-    }
+  }
 
-  if(!workingDirectory.empty())
-    {
+  if (!workingDirectory.empty()) {
     // Change the working directory.
     script += newline;
     newline = newline_text;
@@ -172,35 +160,31 @@ cmLocalVisualStudioGenerator
     script += check_error;
 
     // Change the working drive.
-    if(workingDirectory.size() > 1 && workingDirectory[1] == ':')
-      {
+    if (workingDirectory.size() > 1 && workingDirectory[1] == ':') {
       script += newline;
       newline = newline_text;
       script += workingDirectory[0];
       script += workingDirectory[1];
       script += check_error;
-      }
     }
+  }
 
   // for visual studio IDE add extra stuff to the PATH
   // if CMAKE_MSVCIDE_RUN_PATH is set.
-  if(this->Makefile->GetDefinition("MSVC_IDE"))
-    {
+  if (this->Makefile->GetDefinition("MSVC_IDE")) {
     const char* extraPath =
       this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
-    if(extraPath)
-      {
+    if (extraPath) {
       script += newline;
       newline = newline_text;
       script += "set PATH=";
       script += extraPath;
       script += ";%PATH%";
-      }
     }
+  }
 
   // Write each command on a single line.
-  for(unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c)
-    {
+  for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
     // Start a new line.
     script += newline;
     newline = newline_text;
@@ -212,14 +196,12 @@ cmLocalVisualStudioGenerator
     // invoked as custom commands.
     //
     std::string suffix;
-    if (cmd.size() > 4)
-      {
-      suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size()-4));
-      if (suffix == ".bat" || suffix == ".cmd")
-        {
+    if (cmd.size() > 4) {
+      suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
+      if (suffix == ".bat" || suffix == ".cmd") {
         script += "call ";
-        }
       }
+    }
 
     script += this->Convert(cmd.c_str(), relativeRoot, SHELL);
     ccg.AppendArguments(c, script);
@@ -229,11 +211,10 @@ cmLocalVisualStudioGenerator
     // skipping the run of any subsequent commands in this
     // sequence.
     script += check_error;
-    }
+  }
 
   // Close the local context.
-  if(useLocal)
-    {
+  if (useLocal) {
     script += newline;
     script += ":cmEnd";
     script += newline;
@@ -247,7 +228,7 @@ cmLocalVisualStudioGenerator
     script += newline;
     script += "if %errorlevel% neq 0 goto ";
     script += this->GetReportErrorLabel();
-    }
+  }
 
   return script;
 }
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index f95eefa..c24d813 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -13,6 +13,7 @@
 #define cmLocalVisualStudioGenerator_h
 
 #include "cmLocalGenerator.h"
+
 #include "cmGlobalVisualStudioGenerator.h"
 
 #include <cmsys/auto_ptr.hxx>
@@ -44,24 +45,22 @@ public:
 
   cmGlobalVisualStudioGenerator::VSVersion GetVersion() const;
 
-  virtual std::string
-  ComputeLongestObjectDirectory(cmGeneratorTarget const*) const = 0;
+  virtual std::string ComputeLongestObjectDirectory(
+    cmGeneratorTarget const*) const = 0;
 
   virtual void AddCMakeListsRules() = 0;
 
   virtual void ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const* = 0);
+    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(cmGeneratorTarget *target,
-                       const std::string& config,
-                       bool isFortran);
+  cmsys::auto_ptr<cmCustomCommand> MaybeCreateImplibDir(
+    cmGeneratorTarget* target, const std::string& config, bool isFortran);
 };
 
 #endif
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index aec2603..db87946 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -10,11 +10,11 @@
   See the License for more information.
 ============================================================================*/
 #include "cmLocalXCodeGenerator.h"
+
 #include "cmGlobalXCodeGenerator.h"
-#include "cmSourceFile.h"
 #include "cmMakefile.h"
+#include "cmSourceFile.h"
 
-//----------------------------------------------------------------------------
 cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
                                              cmMakefile* mf)
   : cmLocalGenerator(gg, mf)
@@ -24,20 +24,17 @@ cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
   this->EmitUniversalBinaryFlags = false;
 }
 
-//----------------------------------------------------------------------------
 cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmLocalXCodeGenerator::GetTargetDirectory(cmGeneratorTarget const*) const
+std::string cmLocalXCodeGenerator::GetTargetDirectory(
+  cmGeneratorTarget const*) const
 {
   // No per-target directory for this generator (yet).
   return "";
 }
 
-//----------------------------------------------------------------------------
 void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
                                              const std::string& rawFlag)
 {
@@ -46,45 +43,40 @@ void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
   gg->AppendFlag(flags, rawFlag);
 }
 
-//----------------------------------------------------------------------------
 void cmLocalXCodeGenerator::Generate()
 {
   cmLocalGenerator::Generate();
 
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
-      iter != targets.end(); ++iter)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
+       iter != targets.end(); ++iter) {
     (*iter)->HasMacOSXRpathInstallNameDir("");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalXCodeGenerator::GenerateInstallRules()
 {
   cmLocalGenerator::GenerateInstallRules();
 
   std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
-  for(std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
-      iter != targets.end(); ++iter)
-    {
+  for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
+       iter != targets.end(); ++iter) {
     (*iter)->HasMacOSXRpathInstallNameDir("");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmLocalXCodeGenerator::ComputeObjectFilenames(
-                        std::map<cmSourceFile const*, std::string>& mapping,
-                        cmGeneratorTarget const*)
+  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)
-    {
+  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());
@@ -92,10 +84,9 @@ void cmLocalXCodeGenerator::ComputeObjectFilenames(
 
     std::string objectNameLower = cmSystemTools::LowerCase(objectName);
     counts[objectNameLower] += 1;
-    if (2 == counts[objectNameLower])
-      {
+    if (2 == counts[objectNameLower]) {
       // TODO: emit warning about duplicate name?
-      }
-    si->second = objectName;
     }
+    si->second = objectName;
+  }
 }
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 4381a6d..da3558e 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -24,22 +24,20 @@ class cmLocalXCodeGenerator : public cmLocalGenerator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalXCodeGenerator(cmGlobalGenerator* gg,
-                        cmMakefile* mf);
+  cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
 
   virtual ~cmLocalXCodeGenerator();
-  virtual
-  std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
+  virtual std::string GetTargetDirectory(
+    cmGeneratorTarget const* target) const;
   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:
+    std::map<cmSourceFile const*, std::string>& mapping,
+    cmGeneratorTarget const* gt = 0);
 
+private:
 };
 
 #endif
-
diff --git a/Source/cmLocale.h b/Source/cmLocale.h
index 727f0f5..e69c32e 100644
--- a/Source/cmLocale.h
+++ b/Source/cmLocale.h
@@ -12,20 +12,21 @@
 #ifndef cmLocale_h
 #define cmLocale_h
 
+#include "cmStandardIncludes.h"
+
 #include <locale.h>
 
 class cmLocaleRAII
 {
   const char* OldLocale;
+
 public:
-  cmLocaleRAII(): OldLocale(setlocale(LC_CTYPE, 0))
-    {
+  cmLocaleRAII()
+    : OldLocale(setlocale(LC_CTYPE, 0))
+  {
     setlocale(LC_CTYPE, "");
-    }
-  ~cmLocaleRAII()
-    {
-    setlocale(LC_CTYPE, this->OldLocale);
-    }
+  }
+  ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale); }
 };
 
 #endif
diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx
index 1607845..314760e 100644
--- a/Source/cmMachO.cxx
+++ b/Source/cmMachO.cxx
@@ -10,13 +10,14 @@
   See the License for more information.
 ============================================================================*/
 #include "cmStandardIncludes.h" // to get CMAKE_USE_MACH_PARSER first
+
 #include "cmMachO.h"
 
 #include <cmsys/FStream.hxx>
 
 // Include the Mach-O format information system header.
-#include <mach-o/loader.h>
 #include <mach-o/fat.h>
+#include <mach-o/loader.h>
 
 /**
 
@@ -42,48 +43,43 @@
 
 namespace {
 
-  // peek in the file
-  template <typename T>
-  bool peek(cmsys::ifstream& fin, T &v)
-    {
-    std::streampos p = fin.tellg();
-    if(!fin.read(reinterpret_cast<char*>(&v), sizeof(T)))
-      {
-      return false;
-      }
-    fin.seekg(p);
-    return fin.good();
-    }
+// peek in the file
+template <typename T>
+bool peek(cmsys::ifstream& fin, T& v)
+{
+  std::streampos p = fin.tellg();
+  if (!fin.read(reinterpret_cast<char*>(&v), sizeof(T))) {
+    return false;
+  }
+  fin.seekg(p);
+  return fin.good();
+}
 
-  // read from the file and fill a data structure
-  template <typename T>
-  bool read(cmsys::ifstream& fin, T& v)
-    {
-    if(!fin.read(reinterpret_cast<char*>(&v), sizeof(T)))
-      {
-      return false;
-      }
-    return true;
-    }
+// read from the file and fill a data structure
+template <typename T>
+bool read(cmsys::ifstream& fin, T& v)
+{
+  if (!fin.read(reinterpret_cast<char*>(&v), sizeof(T))) {
+    return false;
+  }
+  return true;
+}
 
-  // read from the file and fill multiple data structures where
-  // the vector has been resized
-  template <typename T>
-  bool read(cmsys::ifstream& fin, std::vector<T>& v)
-    {
-    // nothing to read
-    if(v.empty())
-      {
-      return true;
-      }
-    if(!fin.read(reinterpret_cast<char*>(&v[0]), sizeof(T) * v.size()))
-      {
-      return false;
-      }
+// read from the file and fill multiple data structures where
+// the vector has been resized
+template <typename T>
+bool read(cmsys::ifstream& fin, std::vector<T>& v)
+{
+  // nothing to read
+  if (v.empty()) {
     return true;
-    }
+  }
+  if (!fin.read(reinterpret_cast<char*>(&v[0]), sizeof(T) * v.size())) {
+    return false;
+  }
+  return true;
+}
 }
-
 
 // Contains header and load commands for a single Mach-O file
 class cmMachOHeaderAndLoadCommands
@@ -91,45 +87,41 @@ class cmMachOHeaderAndLoadCommands
 public:
   // A load_command and its associated data
   struct RawLoadCommand
-    {
+  {
     uint32_t type(const cmMachOHeaderAndLoadCommands* m) const
-      {
-      if(this->LoadCommand.size() < sizeof(load_command))
-        {
+    {
+      if (this->LoadCommand.size() < sizeof(load_command)) {
         return 0;
-        }
+      }
       const load_command* cmd =
         reinterpret_cast<const load_command*>(&this->LoadCommand[0]);
       return m->swap(cmd->cmd);
-      }
+    }
     std::vector<char> LoadCommand;
-    };
+  };
 
   cmMachOHeaderAndLoadCommands(bool _swap)
     : Swap(_swap)
-    {
-    }
-  virtual ~cmMachOHeaderAndLoadCommands()
-    {
-    }
+  {
+  }
+  virtual ~cmMachOHeaderAndLoadCommands() {}
 
   virtual bool read_mach_o(cmsys::ifstream& fin) = 0;
 
   const std::vector<RawLoadCommand>& load_commands() const
-    {
+  {
     return this->LoadCommands;
-    }
+  }
 
   uint32_t swap(uint32_t v) const
-    {
-    if(this->Swap)
-      {
+  {
+    if (this->Swap) {
       char* c = reinterpret_cast<char*>(&v);
       std::swap(c[0], c[3]);
       std::swap(c[1], c[2]);
-      }
-    return v;
     }
+    return v;
+  }
 
 protected:
   bool read_load_commands(uint32_t ncmds, uint32_t sizeofcmds,
@@ -147,14 +139,13 @@ class cmMachOHeaderAndLoadCommandsImpl : public cmMachOHeaderAndLoadCommands
 public:
   cmMachOHeaderAndLoadCommandsImpl(bool _swap)
     : cmMachOHeaderAndLoadCommands(_swap)
-    {
-    }
+  {
+  }
   bool read_mach_o(cmsys::ifstream& fin)
-    {
-    if(!read(fin, this->Header))
-      {
+  {
+    if (!read(fin, this->Header)) {
       return false;
-      }
+    }
     this->Header.cputype = swap(this->Header.cputype);
     this->Header.cpusubtype = swap(this->Header.cpusubtype);
     this->Header.filetype = swap(this->Header.filetype);
@@ -162,50 +153,44 @@ public:
     this->Header.sizeofcmds = swap(this->Header.sizeofcmds);
     this->Header.flags = swap(this->Header.flags);
 
-    return read_load_commands(this->Header.ncmds,
-                              this->Header.sizeofcmds,
+    return read_load_commands(this->Header.ncmds, this->Header.sizeofcmds,
                               fin);
-    }
+  }
+
 protected:
   T Header;
 };
 
-
 bool cmMachOHeaderAndLoadCommands::read_load_commands(uint32_t ncmds,
                                                       uint32_t sizeofcmds,
                                                       cmsys::ifstream& fin)
 {
   uint32_t size_read = 0;
   this->LoadCommands.resize(ncmds);
-  for(uint32_t i = 0; i<ncmds; i++)
-    {
+  for (uint32_t i = 0; i < ncmds; i++) {
     load_command lc;
-    if(!peek(fin, lc))
-      {
+    if (!peek(fin, lc)) {
       return false;
-      }
+    }
     lc.cmd = swap(lc.cmd);
     lc.cmdsize = swap(lc.cmdsize);
     size_read += lc.cmdsize;
 
     RawLoadCommand& c = this->LoadCommands[i];
     c.LoadCommand.resize(lc.cmdsize);
-    if(!read(fin, c.LoadCommand))
-      {
+    if (!read(fin, c.LoadCommand)) {
       return false;
-      }
     }
+  }
 
-  if(size_read != sizeofcmds)
-    {
+  if (size_read != sizeofcmds) {
     this->LoadCommands.clear();
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 class cmMachOInternal
 {
 public:
@@ -233,126 +218,100 @@ cmMachOInternal::cmMachOInternal(const char* fname)
   : Fin(fname)
 {
   // Quit now if the file could not be opened.
-  if(!this->Fin || !this->Fin.get() )
-    {
+  if (!this->Fin || !this->Fin.get()) {
     this->ErrorMessage = "Error opening input file.";
     return;
-    }
+  }
 
-  if(!this->Fin.seekg(0))
-    {
+  if (!this->Fin.seekg(0)) {
     this->ErrorMessage = "Error seeking to beginning of file.";
     return;
-    }
+  }
 
   // Read the binary identification block.
   uint32_t magic = 0;
-  if(!peek(this->Fin, magic))
-    {
+  if (!peek(this->Fin, magic)) {
     this->ErrorMessage = "Error reading Mach-O identification.";
     return;
-    }
+  }
 
   // Verify the binary identification.
-  if(!(magic == MH_CIGAM ||
-       magic == MH_MAGIC ||
-       magic == MH_CIGAM_64 ||
-       magic == MH_MAGIC_64 ||
-       magic == FAT_CIGAM ||
-       magic == FAT_MAGIC))
-    {
+  if (!(magic == MH_CIGAM || magic == MH_MAGIC || magic == MH_CIGAM_64 ||
+        magic == MH_MAGIC_64 || magic == FAT_CIGAM || magic == FAT_MAGIC)) {
     this->ErrorMessage = "File does not have a valid Mach-O identification.";
     return;
-    }
+  }
 
-  if(magic == FAT_MAGIC || magic == FAT_CIGAM)
-    {
+  if (magic == FAT_MAGIC || magic == FAT_CIGAM) {
     // this is a universal binary
     fat_header header;
-    if(!read(this->Fin, header))
-      {
+    if (!read(this->Fin, header)) {
       this->ErrorMessage = "Error reading fat header.";
       return;
-      }
+    }
 
     // read fat_archs
     this->FatArchs.resize(OSSwapBigToHostInt32(header.nfat_arch));
-    if(!read(this->Fin, this->FatArchs))
-      {
+    if (!read(this->Fin, this->FatArchs)) {
       this->ErrorMessage = "Error reading fat header archs.";
       return;
-      }
+    }
 
     // parse each Mach-O file
-    for(size_t i=0; i<this->FatArchs.size(); i++)
-      {
+    for (size_t i = 0; i < this->FatArchs.size(); i++) {
       const fat_arch& arch = this->FatArchs[i];
-      if(!this->read_mach_o(OSSwapBigToHostInt32(arch.offset)))
-        {
+      if (!this->read_mach_o(OSSwapBigToHostInt32(arch.offset))) {
         return;
-        }
       }
     }
-  else
-    {
+  } else {
     // parse Mach-O file at the beginning of the file
     this->read_mach_o(0);
-    }
+  }
 }
 
 cmMachOInternal::~cmMachOInternal()
 {
-  for(size_t i=0; i<this->MachOList.size(); i++)
-    {
+  for (size_t i = 0; i < this->MachOList.size(); i++) {
     delete this->MachOList[i];
-    }
+  }
 }
 
 bool cmMachOInternal::read_mach_o(uint32_t file_offset)
 {
-  if(!this->Fin.seekg(file_offset))
-    {
+  if (!this->Fin.seekg(file_offset)) {
     this->ErrorMessage = "Failed to locate Mach-O content.";
     return false;
-    }
+  }
 
   uint32_t magic;
-  if(!peek(this->Fin, magic))
-    {
+  if (!peek(this->Fin, magic)) {
     this->ErrorMessage = "Error reading Mach-O identification.";
     return false;
-    }
+  }
 
   cmMachOHeaderAndLoadCommands* f = NULL;
-  if(magic == MH_CIGAM || magic == MH_MAGIC)
-    {
+  if (magic == MH_CIGAM || magic == MH_MAGIC) {
     bool swap = false;
-    if(magic == MH_CIGAM)
-      {
+    if (magic == MH_CIGAM) {
       swap = true;
-      }
-    f = new cmMachOHeaderAndLoadCommandsImpl<mach_header>(swap);
     }
-  else if(magic == MH_CIGAM_64 || magic == MH_MAGIC_64)
-    {
+    f = new cmMachOHeaderAndLoadCommandsImpl<mach_header>(swap);
+  } else if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64) {
     bool swap = false;
-    if(magic == MH_CIGAM_64)
-      {
+    if (magic == MH_CIGAM_64) {
       swap = true;
-      }
-    f = new cmMachOHeaderAndLoadCommandsImpl<mach_header_64>(swap);
     }
+    f = new cmMachOHeaderAndLoadCommandsImpl<mach_header_64>(swap);
+  }
 
-  if(f && f->read_mach_o(this->Fin))
-    {
+  if (f && f->read_mach_o(this->Fin)) {
     this->MachOList.push_back(f);
-    }
-  else
-    {
+  } else {
     delete f;
     this->ErrorMessage = "Failed to read Mach-O header.";
     return false;
-    }
+  }
 
   return true;
 }
@@ -360,14 +319,12 @@ bool cmMachOInternal::read_mach_o(uint32_t file_offset)
 //============================================================================
 // External class implementation.
 
-//----------------------------------------------------------------------------
-cmMachO::cmMachO(const char* fname): Internal(0)
+cmMachO::cmMachO(const char* fname)
+  : Internal(0)
 {
   this->Internal = new cmMachOInternal(fname);
-
 }
 
-//----------------------------------------------------------------------------
 cmMachO::~cmMachO()
 {
   delete this->Internal;
@@ -378,7 +335,6 @@ std::string const& cmMachO::GetErrorMessage() const
   return this->Internal->ErrorMessage;
 }
 
-//----------------------------------------------------------------------------
 bool cmMachO::Valid() const
 {
   return !this->Internal->MachOList.empty();
@@ -386,30 +342,25 @@ bool cmMachO::Valid() const
 
 bool cmMachO::GetInstallName(std::string& install_name)
 {
-  if(this->Internal->MachOList.empty())
-    {
+  if (this->Internal->MachOList.empty()) {
     return false;
-    }
+  }
 
   // grab the first Mach-O and get the install name from that one
   cmMachOHeaderAndLoadCommands* macho = this->Internal->MachOList[0];
-  for(size_t i=0; i<macho->load_commands().size(); i++)
-    {
-    const cmMachOHeaderAndLoadCommands::RawLoadCommand &cmd =
+  for (size_t i = 0; i < macho->load_commands().size(); i++) {
+    const cmMachOHeaderAndLoadCommands::RawLoadCommand& cmd =
       macho->load_commands()[i];
     uint32_t lc_cmd = cmd.type(macho);
-    if(lc_cmd == LC_ID_DYLIB ||
-       lc_cmd == LC_LOAD_WEAK_DYLIB ||
-       lc_cmd == LC_LOAD_DYLIB)
-      {
-      if(sizeof(dylib_command) < cmd.LoadCommand.size())
-        {
+    if (lc_cmd == LC_ID_DYLIB || lc_cmd == LC_LOAD_WEAK_DYLIB ||
+        lc_cmd == LC_LOAD_DYLIB) {
+      if (sizeof(dylib_command) < cmd.LoadCommand.size()) {
         uint32_t namelen = cmd.LoadCommand.size() - sizeof(dylib_command);
         install_name.assign(&cmd.LoadCommand[sizeof(dylib_command)], namelen);
         return true;
-        }
       }
     }
+  }
 
   return false;
 }
diff --git a/Source/cmMachO.h b/Source/cmMachO.h
index f06f8de..327c1ce 100644
--- a/Source/cmMachO.h
+++ b/Source/cmMachO.h
@@ -13,7 +13,7 @@
 #define cmMachO_h
 
 #if !defined(CMAKE_USE_MACH_PARSER)
-# error "This file may be included only if CMAKE_USE_MACH_PARSER is enabled."
+#error "This file may be included only if CMAKE_USE_MACH_PARSER is enabled."
 #endif
 
 class cmMachOInternal;
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 71de7a7..2caa401 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -11,8 +11,8 @@
 ============================================================================*/
 #include "cmMacroCommand.h"
 
-#include "cmake.h"
 #include "cmAlgorithms.h"
+#include "cmake.h"
 
 // define the class for macro commands
 class cmMacroHelperCommand : public cmCommand
@@ -29,17 +29,14 @@ public:
    * cmMacroHelperCommand and cmFunctionHelperCommand
    * which cannot provide appropriate documentation.
    */
-  virtual bool ShouldAppearInDocumentation() const
-    {
-    return false;
-    }
+  virtual bool ShouldAppearInDocumentation() const { return false; }
 
   /**
    * This is a virtual constructor for the command.
    */
   virtual cmCommand* Clone()
   {
-    cmMacroHelperCommand *newC = new cmMacroHelperCommand;
+    cmMacroHelperCommand* newC = new cmMacroHelperCommand;
     // we must copy when we clone
     newC->Args = this->Args;
     newC->Functions = this->Functions;
@@ -58,10 +55,12 @@ public:
    * the CMakeLists.txt file.
    */
   virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false; }
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * The name of the command as specified in CMakeList.txt.
@@ -76,10 +75,8 @@ public:
   std::string FilePath;
 };
 
-
-bool cmMacroHelperCommand::InvokeInitialPass
-(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus &inStatus)
+bool cmMacroHelperCommand::InvokeInitialPass(
+  const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
 {
   // Expand the argument list to the macro.
   std::vector<std::string> expandedArgs;
@@ -87,17 +84,15 @@ bool cmMacroHelperCommand::InvokeInitialPass
 
   // make sure the number of arguments passed is at least the number
   // required by the signature
-  if (expandedArgs.size() < this->Args.size() - 1)
-    {
+  if (expandedArgs.size() < this->Args.size() - 1) {
     std::string errorMsg =
       "Macro invoked with incorrect arguments for macro named: ";
     errorMsg += this->Args[0];
     this->SetError(errorMsg);
     return false;
-    }
+  }
 
-  cmMakefile::MacroPushPop macroScope(this->Makefile,
-                                      this->FilePath,
+  cmMakefile::MacroPushPop macroScope(this->Makefile, this->FilePath,
                                       this->Policies);
 
   // set the value of argc
@@ -105,29 +100,26 @@ bool cmMacroHelperCommand::InvokeInitialPass
   argcDefStream << expandedArgs.size();
   std::string argcDef = argcDefStream.str();
 
-  std::vector<std::string>::const_iterator eit
-      = expandedArgs.begin() + (this->Args.size() - 1);
+  std::vector<std::string>::const_iterator eit =
+    expandedArgs.begin() + (this->Args.size() - 1);
   std::string expandedArgn = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";");
   std::string expandedArgv = cmJoin(expandedArgs, ";");
   std::vector<std::string> variables;
   variables.reserve(this->Args.size() - 1);
-  for (unsigned int j = 1; j < this->Args.size(); ++j)
-    {
+  for (unsigned int j = 1; j < this->Args.size(); ++j) {
     variables.push_back("${" + this->Args[j] + "}");
-    }
+  }
   std::vector<std::string> argVs;
   argVs.reserve(expandedArgs.size());
   char argvName[60];
-  for (unsigned int j = 0; j < expandedArgs.size(); ++j)
-    {
-    sprintf(argvName,"${ARGV%i}",j);
+  for (unsigned int j = 0; j < expandedArgs.size(); ++j) {
+    sprintf(argvName, "${ARGV%i}", j);
     argVs.push_back(argvName);
-    }
+  }
   // Invoke all the functions that were collected in the block.
   cmListFileFunction newLFF;
   // for each function
-  for(unsigned int c = 0; c < this->Functions.size(); ++c)
-    {
+  for (unsigned int c = 0; c < this->Functions.size(); ++c) {
     // Replace the formal arguments and then invoke the command.
     newLFF.Arguments.clear();
     newLFF.Arguments.reserve(this->Functions[c].Arguments.size());
@@ -137,18 +129,15 @@ bool cmMacroHelperCommand::InvokeInitialPass
     // for each argument of the current function
     for (std::vector<cmListFileArgument>::iterator k =
            this->Functions[c].Arguments.begin();
-         k != this->Functions[c].Arguments.end(); ++k)
-      {
+         k != this->Functions[c].Arguments.end(); ++k) {
       cmListFileArgument arg;
       arg.Value = k->Value;
-      if(k->Delim != cmListFileArgument::Bracket)
-        {
+      if (k->Delim != cmListFileArgument::Bracket) {
         // replace formal arguments
-        for (unsigned int j = 0; j < variables.size(); ++j)
-          {
+        for (unsigned int j = 0; j < variables.size(); ++j) {
           cmSystemTools::ReplaceString(arg.Value, variables[j],
                                        expandedArgs[j]);
-          }
+        }
         // replace argc
         cmSystemTools::ReplaceString(arg.Value, "${ARGC}", argcDef);
 
@@ -157,61 +146,51 @@ bool cmMacroHelperCommand::InvokeInitialPass
 
         // if the current argument of the current function has ${ARGV in it
         // then try replacing ARGV values
-        if (arg.Value.find("${ARGV") != std::string::npos)
-          {
-          for (unsigned int t = 0; t < expandedArgs.size(); ++t)
-            {
-            cmSystemTools::ReplaceString(arg.Value, argVs[t],
-                                         expandedArgs[t]);
-            }
+        if (arg.Value.find("${ARGV") != std::string::npos) {
+          for (unsigned int t = 0; t < expandedArgs.size(); ++t) {
+            cmSystemTools::ReplaceString(arg.Value, argVs[t], expandedArgs[t]);
           }
         }
+      }
       arg.Delim = k->Delim;
       arg.Line = k->Line;
       newLFF.Arguments.push_back(arg);
-      }
+    }
     cmExecutionStatus status;
-    if(!this->Makefile->ExecuteCommand(newLFF, status) ||
-       status.GetNestedError())
-      {
+    if (!this->Makefile->ExecuteCommand(newLFF, status) ||
+        status.GetNestedError()) {
       // The error message should have already included the call stack
       // so we do not need to report an error here.
       macroScope.Quiet();
       inStatus.SetNestedError(true);
       return false;
-      }
-    if (status.GetReturnInvoked())
-      {
+    }
+    if (status.GetReturnInvoked()) {
       inStatus.SetReturnInvoked(true);
       return true;
-      }
-    if (status.GetBreakInvoked())
-      {
+    }
+    if (status.GetBreakInvoked()) {
       inStatus.SetBreakInvoked(true);
       return true;
-      }
     }
+  }
   return true;
 }
 
-bool cmMacroFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
-                  cmExecutionStatus &)
+bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
+                                               cmMakefile& mf,
+                                               cmExecutionStatus&)
 {
   // record commands until we hit the ENDMACRO
   // at the ENDMACRO call we shift gears and start looking for invocations
-  if(!cmSystemTools::Strucmp(lff.Name.c_str(),"macro"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "macro")) {
     this->Depth++;
-    }
-  else if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endmacro"))
-    {
+  } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) {
     // if this is the endmacro for this macro then execute
-    if (!this->Depth)
-      {
+    if (!this->Depth) {
       mf.AppendProperty("MACROS", this->Args[0].c_str());
       // create a new command and add it to cmake
-      cmMacroHelperCommand *f = new cmMacroHelperCommand();
+      cmMacroHelperCommand* f = new cmMacroHelperCommand();
       f->Args = this->Args;
       f->Functions = this->Functions;
       f->FilePath = this->GetStartingContext().FilePath;
@@ -223,13 +202,11 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
       // remove the function blocker now that the macro is defined
       mf.RemoveFunctionBlocker(this, lff);
       return true;
-      }
-    else
-      {
+    } else {
       // decrement for each nested macro that ends
       this->Depth--;
-      }
     }
+  }
 
   // if it wasn't an endmacro and we are not executing then we must be
   // recording
@@ -237,40 +214,35 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
   return true;
 }
 
-
-bool cmMacroFunctionBlocker::
-ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
+bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
+                                          cmMakefile& mf)
 {
-  if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endmacro"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) {
     std::vector<std::string> expandedArguments;
     mf.ExpandArguments(lff.Arguments, expandedArguments,
                        this->GetStartingContext().FilePath.c_str());
     // if the endmacro has arguments make sure they
     // match the arguments of the macro
     if ((expandedArguments.empty() ||
-         (expandedArguments[0] == this->Args[0])))
-      {
+         (expandedArguments[0] == this->Args[0]))) {
       return true;
-      }
     }
+  }
 
   return false;
 }
 
 bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
-                                 cmExecutionStatus &)
+                                 cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // create a function blocker
-  cmMacroFunctionBlocker *f = new cmMacroFunctionBlocker();
+  cmMacroFunctionBlocker* f = new cmMacroFunctionBlocker();
   f->Args.insert(f->Args.end(), args.begin(), args.end());
   this->Makefile->AddFunctionBlocker(f);
   return true;
 }
-
diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h
index 5c1cc00..11d2e1c 100644
--- a/Source/cmMacroCommand.h
+++ b/Source/cmMacroCommand.h
@@ -13,17 +13,17 @@
 #define cmMacroCommand_h
 
 #include "cmCommand.h"
+
 #include "cmFunctionBlocker.h"
 
 class cmMacroFunctionBlocker : public cmFunctionBlocker
 {
 public:
-  cmMacroFunctionBlocker() {this->Depth=0;}
+  cmMacroFunctionBlocker() { this->Depth = 0; }
   virtual ~cmMacroFunctionBlocker() {}
-  virtual bool IsFunctionBlocked(const cmListFileFunction&,
-                                 cmMakefile &mf,
-                                 cmExecutionStatus &);
-  virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
+  virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf,
+                                 cmExecutionStatus&);
+  virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf);
 
   std::vector<std::string> Args;
   std::vector<cmListFileFunction> Functions;
@@ -37,17 +37,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmMacroCommand;
-    }
+  virtual cmCommand* Clone() { return new cmMacroCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -57,10 +54,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "macro";}
+  virtual std::string GetName() const { return "macro"; }
 
   cmTypeMacro(cmMacroCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx
index cc871c9..574dbf0 100644
--- a/Source/cmMakeDirectoryCommand.cxx
+++ b/Source/cmMakeDirectoryCommand.cxx
@@ -12,23 +12,20 @@
 #include "cmMakeDirectoryCommand.h"
 
 // cmMakeDirectoryCommand
-bool cmMakeDirectoryCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmMakeDirectoryCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if(args.size() != 1 )
-    {
+  if (args.size() != 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
-    if ( !this->Makefile->CanIWriteThisFile(args[0].c_str()) )
-      {
-      std::string e = "attempted to create a directory: " + args[0]
-        + " into a source directory.";
-      this->SetError(e);
-      cmSystemTools::SetFatalErrorOccured();
-      return false;
-      }
+  }
+  if (!this->Makefile->CanIWriteThisFile(args[0].c_str())) {
+    std::string e = "attempted to create a directory: " + args[0] +
+      " into a source directory.";
+    this->SetError(e);
+    cmSystemTools::SetFatalErrorOccured();
+    return false;
+  }
   cmSystemTools::MakeDirectory(args[0].c_str());
   return true;
 }
-
diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h
index 617f1fe..1a86398 100644
--- a/Source/cmMakeDirectoryCommand.h
+++ b/Source/cmMakeDirectoryCommand.h
@@ -29,22 +29,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmMakeDirectoryCommand;
-    }
+  virtual cmCommand* Clone() { return new cmMakeDirectoryCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "make_directory";}
+  virtual std::string GetName() const { return "make_directory"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -54,6 +51,4 @@ public:
   cmTypeMacro(cmMakeDirectoryCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index df687d0..e684689 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -10,43 +10,45 @@
   See the License for more information.
 ============================================================================*/
 #include "cmMakefile.h"
-#include "cmVersion.h"
+
 #include "cmCommand.h"
-#include "cmSourceFile.h"
-#include "cmSourceFileLocation.h"
-#include "cmSystemTools.h"
-#include "cmGlobalGenerator.h"
+#include "cmCommandArgumentParserHelper.h"
 #include "cmCommands.h"
-#include "cmState.h"
-#include "cmOutputConverter.h"
 #include "cmFunctionBlocker.h"
+#include "cmGeneratorExpression.h"
 #include "cmGeneratorExpressionEvaluationFile.h"
+#include "cmGlobalGenerator.h"
 #include "cmListFileCache.h"
-#include "cmCommandArgumentParserHelper.h"
-#include "cmGeneratorExpression.h"
+#include "cmOutputConverter.h"
+#include "cmSourceFile.h"
+#include "cmSourceFileLocation.h"
+#include "cmState.h"
+#include "cmSystemTools.h"
 #include "cmTest.h"
+#include "cmVersion.h"
 #ifdef CMAKE_BUILD_WITH_CMAKE
-#  include "cmVariableWatch.h"
+#include "cmVariableWatch.h"
 #endif
+#include "cmAlgorithms.h"
 #include "cmInstallGenerator.h"
 #include "cmTestGenerator.h"
-#include "cmAlgorithms.h"
 #include "cmake.h"
 #include <stdlib.h> // required for atoi
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
 #include <cmsys/auto_ptr.hxx>
 
-#include <list>
-#include <ctype.h> // for isspace
 #include <assert.h>
+#include <ctype.h> // for isspace
+#include <list>
 
 // default is not to be building executables
 cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
                        cmState::Snapshot const& snapshot)
-  : GlobalGenerator(globalGenerator),
-    StateSnapshot(snapshot)
+  : GlobalGenerator(globalGenerator)
+  , StateSnapshot(snapshot)
+  , Backtrace(snapshot)
 {
   this->IsSourceFileTryCompile = false;
 
@@ -65,8 +67,9 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
   this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
   this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
 
-  this->StateSnapshot = this->StateSnapshot.GetState()
-      ->CreatePolicyScopeSnapshot(this->StateSnapshot);
+  this->StateSnapshot =
+    this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
+      this->StateSnapshot);
 
   // Enter a policy level for this directory.
   this->PushPolicy();
@@ -80,10 +83,9 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   this->AddSourceGroup("", "^.*$");
-  this->AddSourceGroup
-    ("Source Files",
-     "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp"
-     "|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
+  this->AddSourceGroup("Source Files",
+                       "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp"
+                       "|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
   this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
   this->AddSourceGroup("CMake Rules", "\\.rule$");
   this->AddSourceGroup("Resources", "\\.plist$");
@@ -103,36 +105,16 @@ cmMakefile::~cmMakefile()
   cmDeleteAll(this->EvaluationFiles);
 }
 
-//----------------------------------------------------------------------------
-void cmMakefile::IssueMessage(cmake::MessageType t,
-                              std::string const& text,
+void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text,
                               bool force) const
 {
   // Collect context information.
-  if(!this->ExecutionStatusStack.empty())
-    {
-    if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR))
-      {
+  if (!this->ExecutionStatusStack.empty()) {
+    if ((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) {
       this->ExecutionStatusStack.back()->SetNestedError(true);
-      }
-    this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace(),
-                                           force);
-    }
-  else
-    {
-    cmListFileContext lfc;
-    // We are not currently executing a command.  Add whatever context
-    // information we have.
-    lfc.FilePath = this->GetExecutionFilePath();
-
-    if(!this->GetCMakeInstance()->GetIsInTryCompile())
-      {
-      cmOutputConverter converter(this->StateSnapshot);
-      lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
-      }
-    lfc.Line = 0;
-    this->GetCMakeInstance()->IssueMessage(t, text, lfc, force);
     }
+  }
+  this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace(), force);
 }
 
 cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
@@ -143,7 +125,7 @@ cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
 cmBacktraceRange cmMakefile::GetIncludeDirectoriesBacktraces() const
 {
   return this->StateSnapshot.GetDirectory()
-      .GetIncludeDirectoriesEntryBacktraces();
+    .GetIncludeDirectoriesEntryBacktraces();
 }
 
 cmStringRange cmMakefile::GetCompileOptionsEntries() const
@@ -164,38 +146,33 @@ cmStringRange cmMakefile::GetCompileDefinitionsEntries() const
 cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
 {
   return this->StateSnapshot.GetDirectory()
-      .GetCompileDefinitionsEntryBacktraces();
+    .GetCompileDefinitionsEntryBacktraces();
 }
 
-//----------------------------------------------------------------------------
 cmListFileBacktrace cmMakefile::GetBacktrace() const
 {
-  cmListFileBacktrace backtrace;
-  if (!this->ContextStack.empty())
-    {
-    backtrace = cmListFileBacktrace(this->StateSnapshot,
-                                    *this->ContextStack.back());
-    }
-  return backtrace;
+  return this->Backtrace;
 }
 
-//----------------------------------------------------------------------------
-cmListFileBacktrace
-cmMakefile::GetBacktrace(cmCommandContext const& cc) const
+cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const
 {
-  cmState::Snapshot snp = this->StateSnapshot;
-  return cmListFileBacktrace(snp, cc);
+  cmListFileContext lfc;
+  lfc.Name = cc.Name;
+  lfc.Line = cc.Line;
+  lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
+  return this->Backtrace.Push(lfc);
 }
 
-//----------------------------------------------------------------------------
 cmListFileContext cmMakefile::GetExecutionContext() const
 {
-  return cmListFileContext::FromCommandContext(
-        *this->ContextStack.back(),
-        this->StateSnapshot.GetExecutionListFile());
+  cmListFileContext const& cur = this->Backtrace.Top();
+  cmListFileContext lfc;
+  lfc.Name = cur.Name;
+  lfc.Line = cur.Line;
+  lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
+  return lfc;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
 {
   std::ostringstream msg;
@@ -203,37 +180,56 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
   msg << lff.Name << "(";
   bool expand = this->GetCMakeInstance()->GetTraceExpand();
   std::string temp;
-  for(std::vector<cmListFileArgument>::const_iterator i =
-        lff.Arguments.begin(); i != lff.Arguments.end(); ++i)
-    {
-    if (expand)
-      {
+  for (std::vector<cmListFileArgument>::const_iterator i =
+         lff.Arguments.begin();
+       i != lff.Arguments.end(); ++i) {
+    if (expand) {
       temp = i->Value;
       this->ExpandVariablesInString(temp);
       msg << temp;
-      }
-    else
-      {
+    } else {
       msg << i->Value;
-      }
-    msg << " ";
     }
+    msg << " ";
+  }
   msg << ")";
   cmSystemTools::Message(msg.str().c_str());
 }
 
-//----------------------------------------------------------------------------
+// Helper class to make sure the call stack is valid.
+class cmMakefileCall
+{
+public:
+  cmMakefileCall(cmMakefile* mf, cmCommandContext const& cc,
+                 cmExecutionStatus& status)
+    : Makefile(mf)
+  {
+    cmListFileContext const& lfc = cmListFileContext::FromCommandContext(
+      cc, this->Makefile->StateSnapshot.GetExecutionListFile());
+    this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc);
+    this->Makefile->ExecutionStatusStack.push_back(&status);
+  }
+
+  ~cmMakefileCall()
+  {
+    this->Makefile->ExecutionStatusStack.pop_back();
+    this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
+  }
+
+private:
+  cmMakefile* Makefile;
+};
+
 bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
-                                cmExecutionStatus &status)
+                                cmExecutionStatus& status)
 {
   bool result = true;
 
   // quick return if blocked
-  if(this->IsFunctionBlocked(lff,status))
-    {
+  if (this->IsFunctionBlocked(lff, status)) {
     // No error.
     return result;
-    }
+  }
 
   std::string name = lff.Name;
 
@@ -242,72 +238,60 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
   static_cast<void>(stack_manager);
 
   // Lookup the command prototype.
-  if(cmCommand* proto = this->GetState()->GetCommand(name))
-    {
+  if (cmCommand* proto = this->GetState()->GetCommand(name)) {
     // Clone the prototype.
     cmsys::auto_ptr<cmCommand> pcmd(proto->Clone());
     pcmd->SetMakefile(this);
 
     // Decide whether to invoke the command.
-    if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured()  &&
-       (this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE
-       || pcmd->IsScriptable()))
+    if (pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() &&
+        (this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE ||
+         pcmd->IsScriptable()))
 
-      {
+    {
       // if trace is enabled, print out invoke information
-      if(this->GetCMakeInstance()->GetTrace())
-        {
+      if (this->GetCMakeInstance()->GetTrace()) {
         this->PrintCommandTrace(lff);
-        }
+      }
       // Try invoking the command.
-      if(!pcmd->InvokeInitialPass(lff.Arguments,status) ||
-         status.GetNestedError())
-        {
-        if(!status.GetNestedError())
-          {
+      if (!pcmd->InvokeInitialPass(lff.Arguments, status) ||
+          status.GetNestedError()) {
+        if (!status.GetNestedError()) {
           // The command invocation requested that we report an error.
           this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError());
-          }
+        }
         result = false;
-        if ( this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE)
-          {
+        if (this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) {
           cmSystemTools::SetFatalErrorOccured();
-          }
         }
-      else if(pcmd->HasFinalPass())
-        {
+      } else if (pcmd->HasFinalPass()) {
         // use the command
         this->FinalPassCommands.push_back(pcmd.release());
-        }
       }
-    else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE
-              && !pcmd->IsScriptable() )
-      {
+    } else if (this->GetCMakeInstance()->GetWorkingMode() ==
+                 cmake::SCRIPT_MODE &&
+               !pcmd->IsScriptable()) {
       std::string error = "Command ";
       error += pcmd->GetName();
       error += "() is not scriptable";
       this->IssueMessage(cmake::FATAL_ERROR, error);
       result = false;
       cmSystemTools::SetFatalErrorOccured();
-      }
     }
-  else
-    {
-    if(!cmSystemTools::GetFatalErrorOccured())
-      {
+  } else {
+    if (!cmSystemTools::GetFatalErrorOccured()) {
       std::string error = "Unknown CMake command \"";
       error += lff.Name;
       error += "\".";
       this->IssueMessage(cmake::FATAL_ERROR, error);
       result = false;
       cmSystemTools::SetFatalErrorOccured();
-      }
     }
+  }
 
   return result;
 }
 
-//----------------------------------------------------------------------------
 class cmMakefile::IncludeScope
 {
 public:
@@ -323,26 +307,24 @@ private:
   void EnforceCMP0011();
 };
 
-//----------------------------------------------------------------------------
 cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
                                        std::string const& filenametoread,
-                                       bool noPolicyScope):
-  Makefile(mf), NoPolicyScope(noPolicyScope),
-  CheckCMP0011(false), ReportError(true)
+                                       bool noPolicyScope)
+  : Makefile(mf)
+  , NoPolicyScope(noPolicyScope)
+  , CheckCMP0011(false)
+  , ReportError(true)
 {
+  this->Makefile->Backtrace = this->Makefile->Backtrace.Push(filenametoread);
+
   this->Makefile->PushFunctionBlockerBarrier();
 
   this->Makefile->StateSnapshot =
-      this->Makefile->GetState()->CreateCallStackSnapshot(
-        this->Makefile->StateSnapshot,
-        this->Makefile->ContextStack.back()->Name,
-        this->Makefile->ContextStack.back()->Line,
-        filenametoread);
-  if(!this->NoPolicyScope)
-    {
+    this->Makefile->GetState()->CreateIncludeFileSnapshot(
+      this->Makefile->StateSnapshot, filenametoread);
+  if (!this->NoPolicyScope) {
     // Check CMP0011 to determine the policy scope type.
-    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) {
       case cmPolicies::WARN:
         // We need to push a scope to detect whether the script sets
         // any policies that would affect the includer and therefore
@@ -364,123 +346,94 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
         // NEW behavior is to push a (strong) scope.
         this->Makefile->PushPolicy();
         break;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 cmMakefile::IncludeScope::~IncludeScope()
 {
-  if(!this->NoPolicyScope)
-    {
+  if (!this->NoPolicyScope) {
     // If we need to enforce policy CMP0011 then the top entry is the
     // one we pushed above.  If the entry is empty, then the included
     // script did not set any policies that might affect the includer so
     // we do not need to enforce the policy.
-    if(this->CheckCMP0011
-       && !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011())
-      {
+    if (this->CheckCMP0011 &&
+        !this->Makefile->StateSnapshot.HasDefinedPolicyCMP0011()) {
       this->CheckCMP0011 = false;
-      }
+    }
 
     // Pop the scope we pushed for the script.
     this->Makefile->PopPolicy();
 
     // We enforce the policy after the script's policy stack entry has
     // been removed.
-    if(this->CheckCMP0011)
-      {
+    if (this->CheckCMP0011) {
       this->EnforceCMP0011();
-      }
     }
+  }
   this->Makefile->PopSnapshot(this->ReportError);
 
   this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
+
+  this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::IncludeScope::EnforceCMP0011()
 {
   // We check the setting of this policy again because the included
   // script might actually set this policy for its includer.
-  switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011))
-    {
+  switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0011)) {
     case cmPolicies::WARN:
       // Warn because the user did not set this policy.
       {
-      std::ostringstream w;
-      w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0011) << "\n"
-        << "The included script\n  "
-        << this->Makefile->GetExecutionFilePath() << "\n"
-        << "affects policy settings.  "
-        << "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
-        << "so the effects are applied to the including context.";
-      this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+        std::ostringstream w;
+        w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0011) << "\n"
+          << "The included script\n  "
+          << this->Makefile->GetExecutionFilePath() << "\n"
+          << "affects policy settings.  "
+          << "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
+          << "so the effects are applied to the including context.";
+        this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
       }
       break;
     case cmPolicies::REQUIRED_IF_USED:
-    case cmPolicies::REQUIRED_ALWAYS:
-      {
+    case cmPolicies::REQUIRED_ALWAYS: {
       std::ostringstream e;
+      /* clang-format off */
       e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0011) << "\n"
         << "The included script\n  "
         << this->Makefile->GetExecutionFilePath() << "\n"
         << "affects policy settings, so it requires this policy to be set.";
+      /* clang-format on */
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-      }
-      break;
+    } break;
     case cmPolicies::OLD:
     case cmPolicies::NEW:
       // The script set this policy.  We assume the purpose of the
       // script is to initialize policies for its includer, and since
       // the policy is now set for later scripts, we do not warn.
       break;
-    }
-}
-
-class cmParseFileScope
-{
-public:
-  cmParseFileScope(cmMakefile* mf)
-    : Makefile(mf)
-  {
-    this->Makefile->ContextStack.push_back(&this->Context);
-  }
-
-  ~cmParseFileScope()
-  {
-    this->Makefile->ContextStack.pop_back();
   }
-
-private:
-  cmMakefile* Makefile;
-  cmCommandContext Context;
-};
+}
 
 bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
 {
   this->AddDefinition("CMAKE_PARENT_LIST_FILE",
                       this->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
-  std::string filenametoread =
-    cmSystemTools::CollapseFullPath(filename,
-                                    this->GetCurrentSourceDirectory());
+  std::string filenametoread = cmSystemTools::CollapseFullPath(
+    filename, this->GetCurrentSourceDirectory());
 
   IncludeScope incScope(this, filenametoread, noPolicyScope);
 
   cmListFile listFile;
-  {
-  cmParseFileScope pfs(this);
-  if (!listFile.ParseFile(filenametoread.c_str(), false, this))
-    {
+  if (!listFile.ParseFile(filenametoread.c_str(), false, this)) {
     return false;
-    }
   }
 
   this->ReadListFile(listFile, filenametoread);
-  if(cmSystemTools::GetFatalErrorOccured())
-    {
+  if (cmSystemTools::GetFatalErrorOccured()) {
     incScope.Quiet();
-    }
+  }
   return true;
 }
 
@@ -488,18 +441,14 @@ class cmMakefile::ListFileScope
 {
 public:
   ListFileScope(cmMakefile* mf, std::string const& filenametoread)
-    : Makefile(mf), ReportError(true)
+    : Makefile(mf)
+    , ReportError(true)
   {
-    long line = 0;
-    std::string name;
-    if (!this->Makefile->ContextStack.empty())
-      {
-      line = this->Makefile->ContextStack.back()->Line;
-      name = this->Makefile->ContextStack.back()->Name;
-      }
+    this->Makefile->Backtrace = this->Makefile->Backtrace.Push(filenametoread);
+
     this->Makefile->StateSnapshot =
-        this->Makefile->GetState()->CreateInlineListFileSnapshot(
-          this->Makefile->StateSnapshot, name, line, filenametoread);
+      this->Makefile->GetState()->CreateInlineListFileSnapshot(
+        this->Makefile->StateSnapshot, filenametoread);
     assert(this->Makefile->StateSnapshot.IsValid());
 
     this->Makefile->PushFunctionBlockerBarrier();
@@ -509,6 +458,7 @@ public:
   {
     this->Makefile->PopSnapshot(this->ReportError);
     this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
+    this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
   }
 
   void Quiet() { this->ReportError = false; }
@@ -519,26 +469,20 @@ private:
 
 bool cmMakefile::ReadListFile(const char* filename)
 {
-  std::string filenametoread =
-    cmSystemTools::CollapseFullPath(filename,
-                                    this->GetCurrentSourceDirectory());
+  std::string filenametoread = cmSystemTools::CollapseFullPath(
+    filename, this->GetCurrentSourceDirectory());
 
   ListFileScope scope(this, filenametoread);
 
   cmListFile listFile;
-  {
-  cmParseFileScope pfs(this);
-  if (!listFile.ParseFile(filenametoread.c_str(), false, this))
-    {
+  if (!listFile.ParseFile(filenametoread.c_str(), false, this)) {
     return false;
-    }
   }
 
   this->ReadListFile(listFile, filenametoread);
-  if(cmSystemTools::GetFatalErrorOccured())
-    {
+  if (cmSystemTools::GetFatalErrorOccured()) {
     scope.Quiet();
-    }
+  }
   return true;
 }
 
@@ -548,14 +492,13 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
   // add this list file to the list of dependencies
   this->ListFiles.push_back(filenametoread);
 
-  std::string currentParentFile
-      = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
-  std::string currentFile
-    = this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE");
+  std::string currentParentFile =
+    this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
+  std::string currentFile = this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE");
 
   this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread.c_str());
   this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
-                       cmSystemTools::GetFilenamePath(filenametoread).c_str());
+                      cmSystemTools::GetFilenamePath(filenametoread).c_str());
 
   this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
   this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
@@ -563,20 +506,17 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
 
   // Run the parsed commands.
   const size_t numberFunctions = listFile.Functions.size();
-  for(size_t i =0; i < numberFunctions; ++i)
-    {
+  for (size_t i = 0; i < numberFunctions; ++i) {
     cmExecutionStatus status;
-    this->ExecuteCommand(listFile.Functions[i],status);
-    if(cmSystemTools::GetFatalErrorOccured())
-      {
+    this->ExecuteCommand(listFile.Functions[i], status);
+    if (cmSystemTools::GetFatalErrorOccured()) {
       break;
-      }
-    if(status.GetReturnInvoked())
-      {
+    }
+    if (status.GetReturnInvoked()) {
       // Exit early due to return command.
       break;
-      }
     }
+  }
   this->CheckForUnusedVariables();
 
   this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
@@ -588,26 +528,21 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
   this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::EnforceDirectoryLevelRules() const
 {
   // Diagnose a violation of CMP0000 if necessary.
-  if(this->CheckCMP0000)
-    {
+  if (this->CheckCMP0000) {
     std::ostringstream msg;
     msg << "No cmake_minimum_required command is present.  "
         << "A line of code such as\n"
-        << "  cmake_minimum_required(VERSION "
-        << cmVersion::GetMajorVersion() << "."
-        << cmVersion::GetMinorVersion()
-        << ")\n"
+        << "  cmake_minimum_required(VERSION " << cmVersion::GetMajorVersion()
+        << "." << cmVersion::GetMinorVersion() << ")\n"
         << "should be added at the top of the file.  "
         << "The version specified may be lower if you wish to "
         << "support older CMake versions for this project.  "
         << "For more information run "
         << "\"cmake --help-policy CMP0000\".";
-    switch (this->GetPolicyStatus(cmPolicies::CMP0000))
-      {
+    switch (this->GetPolicyStatus(cmPolicies::CMP0000)) {
       case cmPolicies::WARN:
         // Warn because the user did not provide a mimimum required
         // version.
@@ -623,19 +558,18 @@ void cmMakefile::EnforceDirectoryLevelRules() const
         this->IssueMessage(cmake::FATAL_ERROR, msg.str());
         cmSystemTools::SetFatalErrorOccured();
         return;
-      }
     }
+  }
 }
 
-void cmMakefile::AddEvaluationFile(const std::string& inputFile,
-                     cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName,
-                     cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
-                     bool inputIsContent)
+void cmMakefile::AddEvaluationFile(
+  const std::string& inputFile,
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName,
+  cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+  bool inputIsContent)
 {
-  this->EvaluationFiles.push_back(
-              new cmGeneratorExpressionEvaluationFile(inputFile, outputName,
-                                                      condition,
-                                                      inputIsContent));
+  this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile(
+    inputFile, outputName, condition, inputIsContent));
 }
 
 std::vector<cmGeneratorExpressionEvaluationFile*>
@@ -651,15 +585,14 @@ cmMakefile::GetExportBuildFileGenerators() const
 }
 
 void cmMakefile::RemoveExportBuildFileGeneratorCMP0024(
-    cmExportBuildFileGenerator* gen)
+  cmExportBuildFileGenerator* gen)
 {
   std::vector<cmExportBuildFileGenerator*>::iterator it =
-      std::find(this->ExportBuildFileGenerators.begin(),
-                this->ExportBuildFileGenerators.end(), gen);
-  if(it != this->ExportBuildFileGenerators.end())
-    {
+    std::find(this->ExportBuildFileGenerators.begin(),
+              this->ExportBuildFileGenerators.end(), gen);
+  if (it != this->ExportBuildFileGenerators.end()) {
     this->ExportBuildFileGenerators.erase(it);
-    }
+  }
 }
 
 void cmMakefile::AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen)
@@ -667,16 +600,15 @@ void cmMakefile::AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen)
   this->ExportBuildFileGenerators.push_back(gen);
 }
 
-namespace
+namespace {
+struct file_not_persistent
 {
-  struct file_not_persistent
+  bool operator()(const std::string& path) const
   {
-    bool operator()(const std::string& path) const
-      {
-      return !(path.find("CMakeTmp") == path.npos &&
-               cmSystemTools::FileExists(path.c_str()));
-      }
-  };
+    return !(path.find("CMakeTmp") == path.npos &&
+             cmSystemTools::FileExists(path.c_str()));
+  }
+};
 }
 
 void cmMakefile::FinalPass()
@@ -686,97 +618,63 @@ void cmMakefile::FinalPass()
 
   // give all the commands a chance to do something
   // after the file has been parsed before generation
-  for(std::vector<cmCommand*>::iterator i = this->FinalPassCommands.begin();
-      i != this->FinalPassCommands.end(); ++i)
-    {
+  for (std::vector<cmCommand*>::iterator i = this->FinalPassCommands.begin();
+       i != this->FinalPassCommands.end(); ++i) {
     (*i)->FinalPass();
-    }
+  }
 
-  //go through all configured files and see which ones still exist.
-  //we don't want cmake to re-run if a configured file is created and deleted
-  //during processing as that would make it a transient file that can't
-  //influence the build process
+  // go through all configured files and see which ones still exist.
+  // we don't want cmake to re-run if a configured file is created and deleted
+  // during processing as that would make it a transient file that can't
+  // influence the build process
 
-  //remove_if will move all items that don't have a valid file name to the
-  //back of the vector
+  // remove_if will move all items that don't have a valid file name to the
+  // back of the vector
   std::vector<std::string>::iterator new_output_files_end = std::remove_if(
-                                                     this->OutputFiles.begin(),
-                                                     this->OutputFiles.end(),
-                                                     file_not_persistent() );
-  //we just have to erase all items at the back
-  this->OutputFiles.erase(new_output_files_end, this->OutputFiles.end() );
-
-  //if a configured file is used as input for another configured file,
-  //and then deleted it will show up in the input list files so we
-  //need to scan those too
+    this->OutputFiles.begin(), this->OutputFiles.end(), file_not_persistent());
+  // we just have to erase all items at the back
+  this->OutputFiles.erase(new_output_files_end, this->OutputFiles.end());
+
+  // if a configured file is used as input for another configured file,
+  // and then deleted it will show up in the input list files so we
+  // need to scan those too
   std::vector<std::string>::iterator new_list_files_end = std::remove_if(
-                                                   this->ListFiles.begin(),
-                                                   this->ListFiles.end(),
-                                                   file_not_persistent() );
+    this->ListFiles.begin(), this->ListFiles.end(), file_not_persistent());
 
-  this->ListFiles.erase(new_list_files_end, this->ListFiles.end() );
+  this->ListFiles.erase(new_list_files_end, this->ListFiles.end());
 }
 
 // Generate the output file
 void cmMakefile::ConfigureFinalPass()
 {
   this->FinalPass();
-  const char* oldValue
-    = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
-  if (oldValue && cmSystemTools::VersionCompare(
-        cmSystemTools::OP_LESS, oldValue, "2.4"))
-    {
+  const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
+  if (oldValue &&
+      cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) {
     this->IssueMessage(
       cmake::FATAL_ERROR,
       "You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less "
       "than 2.4. This version of CMake only supports backwards compatibility "
       "with CMake 2.4 or later. For compatibility with older versions please "
       "use any CMake 2.8.x release or lower.");
-    }
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  // Do old-style link dependency analysis only for CM_USE_OLD_VS6.
-  if(this->GetGlobalGenerator()->IsForVS6())
-    {
-    for (cmTargets::iterator l = this->Targets.begin();
-         l != this->Targets.end(); l++)
-      {
-      if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
-        {
-        continue;
-        }
-      // Erase any cached link information that might have been comptued
-      // on-demand during the configuration.  This ensures that build
-      // system generation uses up-to-date information even if other cache
-      // invalidation code in this source file is buggy.
-
-      l->second.AnalyzeLibDependenciesForVS6(*this);
-      }
-    }
-#endif
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefile::AddCustomCommandToTarget(const std::string& target,
-                                   const std::vector<std::string>& byproducts,
-                                     const std::vector<std::string>& depends,
-                                     const cmCustomCommandLines& commandLines,
-                                     cmTarget::CustomCommandType type,
-                                     const char* comment,
-                                     const char* workingDir,
-                                     bool escapeOldStyle,
-                                     bool uses_terminal)
+void cmMakefile::AddCustomCommandToTarget(
+  const std::string& target, const std::vector<std::string>& byproducts,
+  const std::vector<std::string>& depends,
+  const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
+  const char* comment, const char* workingDir, bool escapeOldStyle,
+  bool uses_terminal)
 {
   // Find the target to which to add the custom command.
   cmTargets::iterator ti = this->Targets.find(target);
 
-  if(ti == this->Targets.end())
-    {
+  if (ti == this->Targets.end()) {
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
     bool issueMessage = false;
     std::ostringstream e;
-    switch(this->GetPolicyStatus(cmPolicies::CMP0040))
-      {
+    switch (this->GetPolicyStatus(cmPolicies::CMP0040)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0040) << "\n";
         issueMessage = true;
@@ -787,70 +685,59 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
       case cmPolicies::REQUIRED_ALWAYS:
         issueMessage = true;
         messageType = cmake::FATAL_ERROR;
-      }
+    }
 
-    if(issueMessage)
-      {
-      if (cmTarget const* t = this->FindTargetToUse(target))
-        {
-        if (t->IsImported())
-          {
+    if (issueMessage) {
+      if (cmTarget const* t = this->FindTargetToUse(target)) {
+        if (t->IsImported()) {
           e << "TARGET '" << target
             << "' is IMPORTED and does not build here.";
-          }
-        else
-          {
-          e << "TARGET '" << target
-            << "' was not created in this directory.";
-          }
+        } else {
+          e << "TARGET '" << target << "' was not created in this directory.";
         }
-      else
-        {
+      } else {
         e << "No TARGET '" << target
           << "' has been created in this directory.";
-        }
-      IssueMessage(messageType, e.str());
       }
-
-      return;
+      IssueMessage(messageType, e.str());
     }
 
-  if(ti->second.GetType() == cmState::OBJECT_LIBRARY)
-    {
+    return;
+  }
+
+  if (ti->second.GetType() == cmState::OBJECT_LIBRARY) {
     std::ostringstream e;
-    e << "Target \"" << target << "\" is an OBJECT library "
-      "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
+    e << "Target \"" << target
+      << "\" is an OBJECT library "
+         "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
     this->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
-  if(ti->second.GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  }
+  if (ti->second.GetType() == cmState::INTERFACE_LIBRARY) {
     std::ostringstream e;
-    e << "Target \"" << target << "\" is an INTERFACE library "
-      "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
+    e << "Target \"" << target
+      << "\" is an INTERFACE library "
+         "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
     this->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
+  }
 
   // Always create the byproduct sources and mark them generated.
-  for(std::vector<std::string>::const_iterator o = byproducts.begin();
-      o != byproducts.end(); ++o)
-    {
-    if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
-      {
+  for (std::vector<std::string>::const_iterator o = byproducts.begin();
+       o != byproducts.end(); ++o) {
+    if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
       out->SetProperty("GENERATED", "1");
-      }
     }
+  }
 
   // Add the command to the appropriate build step for the target.
   std::vector<std::string> no_output;
-  cmCustomCommand cc(this, no_output, byproducts, depends,
-                     commandLines, comment, workingDir);
+  cmCustomCommand cc(this, no_output, byproducts, depends, commandLines,
+                     comment, workingDir);
   cc.SetEscapeOldStyle(escapeOldStyle);
   cc.SetEscapeAllowMakeVars(true);
   cc.SetUsesTerminal(uses_terminal);
-  switch(type)
-    {
+  switch (type) {
     case cmTarget::PRE_BUILD:
       ti->second.AddPreBuildCommand(cc);
       break;
@@ -860,75 +747,59 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
     case cmTarget::POST_BUILD:
       ti->second.AddPostBuildCommand(cc);
       break;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmSourceFile*
-cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
-                                  const std::vector<std::string>& byproducts,
-                                     const std::vector<std::string>& depends,
-                                     const std::string& main_dependency,
-                                     const cmCustomCommandLines& commandLines,
-                                     const char* comment,
-                                     const char* workingDir,
-                                     bool replace,
-                                     bool escapeOldStyle,
-                                     bool uses_terminal)
+cmSourceFile* cmMakefile::AddCustomCommandToOutput(
+  const std::vector<std::string>& outputs,
+  const std::vector<std::string>& byproducts,
+  const std::vector<std::string>& depends, const std::string& main_dependency,
+  const cmCustomCommandLines& commandLines, const char* comment,
+  const char* workingDir, bool replace, bool escapeOldStyle,
+  bool uses_terminal)
 {
   // Make sure there is at least one output.
-  if(outputs.empty())
-    {
+  if (outputs.empty()) {
     cmSystemTools::Error("Attempt to add a custom rule with no output!");
     return 0;
-    }
+  }
 
   // Validate custom commands.  TODO: More strict?
-  for(cmCustomCommandLines::const_iterator i=commandLines.begin();
-      i != commandLines.end(); ++i)
-    {
+  for (cmCustomCommandLines::const_iterator i = commandLines.begin();
+       i != commandLines.end(); ++i) {
     cmCustomCommandLine const& cl = *i;
-    if(!cl.empty() && !cl[0].empty() && cl[0][0] == '"')
-      {
+    if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
       std::ostringstream e;
       e << "COMMAND may not contain literal quotes:\n  " << cl[0] << "\n";
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
       return 0;
-      }
     }
+  }
 
   // Choose a source file on which to store the custom command.
   cmSourceFile* file = 0;
-  if(!commandLines.empty() && !main_dependency.empty())
-    {
+  if (!commandLines.empty() && !main_dependency.empty()) {
     // The main dependency was specified.  Use it unless a different
     // custom command already used it.
     file = this->GetSource(main_dependency);
-    if(file && file->GetCustomCommand() && !replace)
-      {
+    if (file && file->GetCustomCommand() && !replace) {
       // The main dependency already has a custom command.
-      if(commandLines == file->GetCustomCommand()->GetCommandLines())
-        {
+      if (commandLines == file->GetCustomCommand()->GetCommandLines()) {
         // The existing custom command is identical.  Silently ignore
         // the duplicate.
         return file;
-        }
-      else
-        {
+      } else {
         // The existing custom command is different.  We need to
         // generate a rule file for this new command.
         file = 0;
-        }
       }
-    else if (!file)
-      {
+    } else if (!file) {
       file = this->CreateSource(main_dependency);
-      }
     }
+  }
 
   // Generate a rule file if the main dependency is not available.
-  if(!file)
-    {
+  if (!file) {
     cmGlobalGenerator* gg = this->GetGlobalGenerator();
 
     // Construct a rule file associated with the first output produced.
@@ -936,86 +807,70 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
 
     // Check if the rule file already exists.
     file = this->GetSource(outName);
-    if(file && file->GetCustomCommand() && !replace)
-      {
+    if (file && file->GetCustomCommand() && !replace) {
       // The rule file already exists.
-      if(commandLines != file->GetCustomCommand()->GetCommandLines())
-        {
+      if (commandLines != file->GetCustomCommand()->GetCommandLines()) {
         cmSystemTools::Error("Attempt to add a custom rule to output \"",
                              outName.c_str(),
                              "\" which already has a custom rule.");
-        }
-      return file;
       }
+      return file;
+    }
 
     // Create a cmSourceFile for the rule file.
-    if (!file)
-      {
+    if (!file) {
       file = this->CreateSource(outName, true);
-      }
-    file->SetProperty("__CMAKE_RULE", "1");
     }
+    file->SetProperty("__CMAKE_RULE", "1");
+  }
 
   // Always create the output sources and mark them generated.
-  for(std::vector<std::string>::const_iterator o = outputs.begin();
-      o != outputs.end(); ++o)
-    {
-    if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
-      {
+  for (std::vector<std::string>::const_iterator o = outputs.begin();
+       o != outputs.end(); ++o) {
+    if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
       out->SetProperty("GENERATED", "1");
-      }
     }
-  for(std::vector<std::string>::const_iterator o = byproducts.begin();
-      o != byproducts.end(); ++o)
-    {
-    if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
-      {
+  }
+  for (std::vector<std::string>::const_iterator o = byproducts.begin();
+       o != byproducts.end(); ++o) {
+    if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
       out->SetProperty("GENERATED", "1");
-      }
     }
+  }
 
   // Attach the custom command to the file.
-  if(file)
-    {
+  if (file) {
     // Construct a complete list of dependencies.
     std::vector<std::string> depends2(depends);
-    if(!main_dependency.empty())
-      {
+    if (!main_dependency.empty()) {
       depends2.push_back(main_dependency);
-      }
+    }
 
-    cmCustomCommand* cc =
-      new cmCustomCommand(this, outputs, byproducts, depends2,
-                          commandLines, comment, workingDir);
+    cmCustomCommand* cc = new cmCustomCommand(
+      this, outputs, byproducts, depends2, commandLines, comment, workingDir);
     cc->SetEscapeOldStyle(escapeOldStyle);
     cc->SetEscapeAllowMakeVars(true);
     cc->SetUsesTerminal(uses_terminal);
     file->SetCustomCommand(cc);
     this->UpdateOutputToSourceMap(outputs, file);
-    }
+  }
   return file;
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefile::UpdateOutputToSourceMap(std::vector<std::string> const& outputs,
-                                    cmSourceFile* source)
+void cmMakefile::UpdateOutputToSourceMap(
+  std::vector<std::string> const& outputs, cmSourceFile* source)
 {
-  for(std::vector<std::string>::const_iterator o = outputs.begin();
-      o != outputs.end(); ++o)
-    {
+  for (std::vector<std::string>::const_iterator o = outputs.begin();
+       o != outputs.end(); ++o) {
     this->UpdateOutputToSourceMap(*o, source);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefile::UpdateOutputToSourceMap(std::string const& output,
-                                    cmSourceFile* source)
+void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
+                                         cmSourceFile* source)
 {
   OutputToSourceMap::iterator i = this->OutputToSource.find(output);
-  if(i != this->OutputToSource.end())
-    {
+  if (i != this->OutputToSource.end()) {
     // Multiple custom commands produce the same output but may
     // be attached to a different source file (MAIN_DEPENDENCY).
     // LinearGetSourceFileWithOutput would return the first one,
@@ -1025,134 +880,103 @@ cmMakefile::UpdateOutputToSourceMap(std::string const& output,
     // triggers it for separate generate.stamp rules in ZERO_CHECK and
     // individual targets.
     return;
-    }
+  }
   this->OutputToSource[output] = source;
 }
 
-//----------------------------------------------------------------------------
-cmSourceFile*
-cmMakefile::AddCustomCommandToOutput(const std::string& output,
-                                     const std::vector<std::string>& depends,
-                                     const std::string& main_dependency,
-                                     const cmCustomCommandLines& commandLines,
-                                     const char* comment,
-                                     const char* workingDir,
-                                     bool replace,
-                                     bool escapeOldStyle,
-                                     bool uses_terminal)
+cmSourceFile* cmMakefile::AddCustomCommandToOutput(
+  const std::string& output, const std::vector<std::string>& depends,
+  const std::string& main_dependency, const cmCustomCommandLines& commandLines,
+  const char* comment, const char* workingDir, bool replace,
+  bool escapeOldStyle, bool uses_terminal)
 {
   std::vector<std::string> outputs;
   outputs.push_back(output);
   std::vector<std::string> no_byproducts;
-  return this->AddCustomCommandToOutput(outputs, no_byproducts,
-                                        depends, main_dependency,
-                                        commandLines, comment, workingDir,
-                                        replace, escapeOldStyle,
-                                        uses_terminal);
-}
-
-//----------------------------------------------------------------------------
-void
-cmMakefile::AddCustomCommandOldStyle(const std::string& target,
-                                     const std::vector<std::string>& outputs,
-                                     const std::vector<std::string>& depends,
-                                     const std::string& source,
-                                     const cmCustomCommandLines& commandLines,
-                                     const char* comment)
+  return this->AddCustomCommandToOutput(
+    outputs, no_byproducts, depends, main_dependency, commandLines, comment,
+    workingDir, replace, escapeOldStyle, uses_terminal);
+}
+
+void cmMakefile::AddCustomCommandOldStyle(
+  const std::string& target, const std::vector<std::string>& outputs,
+  const std::vector<std::string>& depends, const std::string& source,
+  const cmCustomCommandLines& commandLines, const char* comment)
 {
   // Translate the old-style signature to one of the new-style
   // signatures.
-  if(source == target)
-    {
+  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
     // this behavior.
     std::vector<std::string> no_byproducts;
-    this->AddCustomCommandToTarget(target, no_byproducts,
-                                   depends, commandLines,
-                                   cmTarget::POST_BUILD, comment, 0);
+    this->AddCustomCommandToTarget(target, no_byproducts, depends,
+                                   commandLines, cmTarget::POST_BUILD, comment,
+                                   0);
     return;
-    }
+  }
 
   // Each output must get its own copy of this rule.
   cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|"
                                        "rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
                                        "hm|hpp|hxx|in|txx|inl)$");
-  for(std::vector<std::string>::const_iterator oi = outputs.begin();
-      oi != outputs.end(); ++oi)
-    {
+  for (std::vector<std::string>::const_iterator oi = outputs.begin();
+       oi != outputs.end(); ++oi) {
     // Get the name of this output.
     const char* output = oi->c_str();
     cmSourceFile* sf;
 
     // Choose whether to use a main dependency.
-    if(sourceFiles.find(source))
-      {
+    if (sourceFiles.find(source)) {
       // The source looks like a real file.  Use it as the main dependency.
       sf = this->AddCustomCommandToOutput(output, depends, source,
                                           commandLines, comment, 0);
-      }
-    else
-      {
+    } else {
       // The source may not be a real file.  Do not use a main dependency.
       std::string no_main_dependency = "";
       std::vector<std::string> depends2 = depends;
       depends2.push_back(source);
       sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
                                           commandLines, comment, 0);
-      }
+    }
 
     // If the rule was added to the source (and not a .rule file),
     // then add the source to the target to make sure the rule is
     // included.
-    if(sf && !sf->GetPropertyAsBool("__CMAKE_RULE"))
-      {
-      if (this->Targets.find(target) != this->Targets.end())
-        {
+    if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) {
+      if (this->Targets.find(target) != this->Targets.end()) {
         this->Targets[target].AddSource(sf->GetFullPath());
-        }
-      else
-        {
+      } else {
         cmSystemTools::Error("Attempt to add a custom rule to a target "
                              "that does not exist yet for target ",
                              target.c_str());
         return;
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmTarget*
-cmMakefile::AddUtilityCommand(const std::string& utilityName,
-                              bool excludeFromAll,
-                              const std::vector<std::string>& depends,
-                              const char* workingDirectory,
-                              const char* command,
-                              const char* arg1,
-                              const char* arg2,
-                              const char* arg3,
-                              const char* arg4)
+cmTarget* cmMakefile::AddUtilityCommand(
+  const std::string& utilityName, bool excludeFromAll,
+  const std::vector<std::string>& depends, const char* workingDirectory,
+  const char* command, const char* arg1, const char* arg2, const char* arg3,
+  const char* arg4)
 {
   // Construct the command line for the custom command.
   cmCustomCommandLine commandLine;
   commandLine.push_back(command);
-  if(arg1)
-    {
+  if (arg1) {
     commandLine.push_back(arg1);
-    }
-  if(arg2)
-    {
+  }
+  if (arg2) {
     commandLine.push_back(arg2);
-    }
-  if(arg3)
-    {
+  }
+  if (arg3) {
     commandLine.push_back(arg3);
-    }
-  if(arg4)
-    {
+  }
+  if (arg4) {
     commandLine.push_back(arg4);
-    }
+  }
   cmCustomCommandLines commandLines;
   commandLines.push_back(commandLine);
 
@@ -1161,15 +985,11 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
                                  depends, commandLines);
 }
 
-//----------------------------------------------------------------------------
-cmTarget*
-cmMakefile::AddUtilityCommand(const std::string& utilityName,
-                              bool excludeFromAll,
-                              const char* workingDirectory,
-                              const std::vector<std::string>& depends,
-                              const cmCustomCommandLines& commandLines,
-                              bool escapeOldStyle, const char* comment,
-                              bool uses_terminal)
+cmTarget* cmMakefile::AddUtilityCommand(
+  const std::string& utilityName, bool excludeFromAll,
+  const char* workingDirectory, const std::vector<std::string>& depends,
+  const cmCustomCommandLines& commandLines, bool escapeOldStyle,
+  const char* comment, bool uses_terminal)
 {
   std::vector<std::string> no_byproducts;
   return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
@@ -1177,32 +997,25 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
                                  escapeOldStyle, comment, uses_terminal);
 }
 
-//----------------------------------------------------------------------------
-cmTarget*
-cmMakefile::AddUtilityCommand(const std::string& utilityName,
-                              bool excludeFromAll,
-                              const char* workingDirectory,
-                              const std::vector<std::string>& byproducts,
-                              const std::vector<std::string>& depends,
-                              const cmCustomCommandLines& commandLines,
-                              bool escapeOldStyle, const char* comment,
-                              bool uses_terminal)
+cmTarget* cmMakefile::AddUtilityCommand(
+  const std::string& utilityName, bool excludeFromAll,
+  const char* workingDirectory, const std::vector<std::string>& byproducts,
+  const std::vector<std::string>& depends,
+  const cmCustomCommandLines& commandLines, bool escapeOldStyle,
+  const char* comment, bool uses_terminal)
 {
   // Create a target instance for this utility.
   cmTarget* target = this->AddNewTarget(cmState::UTILITY, utilityName);
-  if (excludeFromAll)
-    {
+  if (excludeFromAll) {
     target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
-    }
-  if(!comment)
-    {
+  }
+  if (!comment) {
     // Use an empty comment to avoid generation of default comment.
     comment = "";
-    }
+  }
 
   // Store the custom command in the target.
-  if (!commandLines.empty() || !depends.empty())
-    {
+  if (!commandLines.empty() || !depends.empty()) {
     std::string force = this->GetCurrentBinaryDirectory();
     force += cmake::GetCMakeFilesDirectory();
     force += "/";
@@ -1211,52 +1024,43 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
     forced.push_back(force);
     std::string no_main_dependency = "";
     bool no_replace = false;
-    this->AddCustomCommandToOutput(forced, byproducts,
-                                   depends, no_main_dependency,
-                                   commandLines, comment,
-                                   workingDirectory, no_replace,
-                                   escapeOldStyle, uses_terminal);
+    this->AddCustomCommandToOutput(
+      forced, byproducts, depends, no_main_dependency, commandLines, comment,
+      workingDirectory, no_replace, escapeOldStyle, uses_terminal);
     cmSourceFile* sf = target->AddSourceCMP0049(force);
 
     // The output is not actually created so mark it symbolic.
-    if(sf)
-      {
+    if (sf) {
       sf->SetProperty("SYMBOLIC", "1");
-      }
-    else
-      {
+    } else {
       cmSystemTools::Error("Could not get source file entry for ",
-                          force.c_str());
-      }
+                           force.c_str());
+    }
 
     // Always create the byproduct sources and mark them generated.
-    for(std::vector<std::string>::const_iterator o = byproducts.begin();
-        o != byproducts.end(); ++o)
-      {
-      if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
-        {
+    for (std::vector<std::string>::const_iterator o = byproducts.begin();
+         o != byproducts.end(); ++o) {
+      if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
         out->SetProperty("GENERATED", "1");
-        }
       }
     }
+  }
   return target;
 }
 
 void cmMakefile::AddDefineFlag(const char* flag)
 {
-  if (!flag)
-    {
+  if (!flag) {
     return;
-    }
+  }
 
   // Update the string used for the old DEFINITIONS property.
   this->AddDefineFlag(flag, this->DefineFlagsOrig);
 
   // If this is really a definition, update COMPILE_DEFINITIONS.
-  if(this->ParseDefineFlag(flag, false))
-    {
+  if (this->ParseDefineFlag(flag, false)) {
     return;
-    }
+  }
 
   // Add this flag that does not look like a definition.
   this->AddDefineFlag(flag, this->DefineFlags);
@@ -1272,49 +1076,41 @@ void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
   std::replace(flagStart, dflags.end(), '\r', ' ');
 }
 
-
 void cmMakefile::RemoveDefineFlag(const char* flag)
 {
   // Check the length of the flag to remove.
   std::string::size_type len = strlen(flag);
-  if(len < 1)
-    {
+  if (len < 1) {
     return;
-    }
+  }
 
   // Update the string used for the old DEFINITIONS property.
   this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
 
   // If this is really a definition, update COMPILE_DEFINITIONS.
-  if(this->ParseDefineFlag(flag, true))
-    {
+  if (this->ParseDefineFlag(flag, true)) {
     return;
-    }
+  }
 
   // Remove this flag that does not look like a definition.
   this->RemoveDefineFlag(flag, len, this->DefineFlags);
 }
 
-void cmMakefile::RemoveDefineFlag(const char* flag,
-                                  std::string::size_type len,
+void cmMakefile::RemoveDefineFlag(const char* flag, std::string::size_type len,
                                   std::string& dflags)
 {
   // Remove all instances of the flag that are surrounded by
   // whitespace or the beginning/end of the string.
-  for(std::string::size_type lpos = dflags.find(flag, 0);
-      lpos != std::string::npos; lpos = dflags.find(flag, lpos))
-    {
+  for (std::string::size_type lpos = dflags.find(flag, 0);
+       lpos != std::string::npos; lpos = dflags.find(flag, lpos)) {
     std::string::size_type rpos = lpos + len;
-    if((lpos <= 0 || isspace(dflags[lpos-1])) &&
-       (rpos >= dflags.size() || isspace(dflags[rpos])))
-      {
+    if ((lpos <= 0 || isspace(dflags[lpos - 1])) &&
+        (rpos >= dflags.size() || isspace(dflags[rpos]))) {
       dflags.erase(lpos, len);
-      }
-    else
-      {
+    } else {
       ++lpos;
-      }
     }
+  }
 }
 
 void cmMakefile::AddCompileOption(const char* option)
@@ -1325,36 +1121,22 @@ void cmMakefile::AddCompileOption(const char* option)
 bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
 {
   // Create a regular expression to match valid definitions.
-  static cmsys::RegularExpression
-    valid("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$");
+  static cmsys::RegularExpression valid("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$");
 
   // Make sure the definition matches.
-  if(!valid.find(def.c_str()))
-    {
-    return false;
-    }
-
-  // VS6 IDE does not support definition values with spaces in
-  // combination with '"', '$', or ';'.
-  if((this->GetGlobalGenerator()->GetName() == "Visual Studio 6") &&
-     (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos))
-    {
+  if (!valid.find(def.c_str())) {
     return false;
-    }
+  }
 
   // Definitions with non-trivial values require a policy check.
-  static cmsys::RegularExpression
-    trivial("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
-  if(!trivial.find(def.c_str()))
-    {
+  static cmsys::RegularExpression trivial(
+    "^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
+  if (!trivial.find(def.c_str())) {
     // This definition has a non-trivial value.
-    switch(this->GetPolicyStatus(cmPolicies::CMP0005))
-      {
+    switch (this->GetPolicyStatus(cmPolicies::CMP0005)) {
       case cmPolicies::WARN:
-        this->IssueMessage(
-          cmake::AUTHOR_WARNING,
-          cmPolicies::GetPolicyWarning(cmPolicies::CMP0005)
-          );
+        this->IssueMessage(cmake::AUTHOR_WARNING,
+                           cmPolicies::GetPolicyWarning(cmPolicies::CMP0005));
       case cmPolicies::OLD:
         // OLD behavior is to not escape the value.  We should not
         // convert the definition to use the property.
@@ -1363,43 +1145,37 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
       case cmPolicies::REQUIRED_ALWAYS:
         this->IssueMessage(
           cmake::FATAL_ERROR,
-          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0005)
-          );
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0005));
         return false;
       case cmPolicies::NEW:
         // NEW behavior is to escape the value.  Proceed to convert it
         // to an entry in the property.
         break;
-      }
     }
+  }
 
   // Get the definition part after the flag.
   const char* define = def.c_str() + 2;
 
-  if(remove)
-    {
-    if(const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS"))
-      {
+  if (remove) {
+    if (const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS")) {
       // Expand the list.
       std::vector<std::string> defs;
       cmSystemTools::ExpandListArgument(cdefs, defs);
 
       // Recompose the list without the definition.
       std::vector<std::string>::const_iterator defEnd =
-          std::remove(defs.begin(), defs.end(), define);
-      std::vector<std::string>::const_iterator defBegin =
-          defs.begin();
+        std::remove(defs.begin(), defs.end(), define);
+      std::vector<std::string>::const_iterator defBegin = defs.begin();
       std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";");
 
       // Store the new list.
       this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str());
-      }
     }
-  else
-    {
+  } else {
     // Append the definition to the directory property.
     this->AppendProperty("COMPILE_DEFINITIONS", define);
-    }
+  }
 
   return true;
 }
@@ -1418,17 +1194,14 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
                                          cmTargetLinkLibraryType llt)
 {
   cmTargets::iterator i = this->Targets.find(target);
-  if ( i != this->Targets.end())
-    {
+  if (i != this->Targets.end()) {
     cmTarget* tgt = this->GetGlobalGenerator()->FindTarget(lib);
-    if(tgt)
-      {
+    if (tgt) {
       // if it is not a static or shared library then you can not link to it
-      if(!((tgt->GetType() == cmState::STATIC_LIBRARY) ||
-           (tgt->GetType() == cmState::SHARED_LIBRARY) ||
-           (tgt->GetType() == cmState::INTERFACE_LIBRARY) ||
-           tgt->IsExecutableWithExports()))
-        {
+      if (!((tgt->GetType() == cmState::STATIC_LIBRARY) ||
+            (tgt->GetType() == cmState::SHARED_LIBRARY) ||
+            (tgt->GetType() == cmState::INTERFACE_LIBRARY) ||
+            tgt->IsExecutableWithExports())) {
         std::ostringstream e;
         e << "Target \"" << lib << "\" of type "
           << cmState::GetTargetTypeName(tgt->GetType())
@@ -1436,47 +1209,40 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& 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());
-        }
       }
-    i->second.AddLinkLibrary( *this, target, lib, llt );
     }
-  else
-    {
+    i->second.AddLinkLibrary(*this, target, lib, llt);
+  } else {
     std::ostringstream e;
-    e << "Attempt to add link library \""
-      << lib << "\" to target \""
-      << target << "\" which is not built in this directory.";
+    e << "Attempt to add link library \"" << lib << "\" to target \"" << target
+      << "\" which is not built in this directory.";
     this->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
+  }
 }
 
 void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
                                            const std::string& d)
 {
   cmTargets::iterator i = this->Targets.find(target);
-  if ( i != this->Targets.end())
-    {
-    if(this->IsAlias(target))
-      {
+  if (i != this->Targets.end()) {
+    if (this->IsAlias(target)) {
       std::ostringstream e;
       e << "ALIAS target \"" << target << "\" "
         << "may not be linked into another target.";
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
-    i->second.AddLinkDirectory( d );
-    }
-  else
-    {
-    cmSystemTools::Error
-      ("Attempt to add link directories to non-existent target: ",
-       target.c_str(), " for directory ", d.c_str());
     }
+    i->second.AddLinkDirectory(d);
+  } else {
+    cmSystemTools::Error(
+      "Attempt to add link directories to non-existent target: ",
+      target.c_str(), " for directory ", d.c_str());
+  }
 }
 
 void cmMakefile::AddLinkLibrary(const std::string& lib)
 {
-  this->AddLinkLibrary(lib,GENERAL_LibraryType);
+  this->AddLinkLibrary(lib, GENERAL_LibraryType);
 }
 
 void cmMakefile::InitializeFromParent(cmMakefile* parent)
@@ -1489,27 +1255,25 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
 
   // Include transform property.  There is no per-config version.
   {
-  const char* prop = "IMPLICIT_DEPENDS_INCLUDE_TRANSFORM";
-  this->SetProperty(prop, parent->GetProperty(prop));
+    const char* prop = "IMPLICIT_DEPENDS_INCLUDE_TRANSFORM";
+    this->SetProperty(prop, parent->GetProperty(prop));
   }
 
   // compile definitions property and per-config versions
   cmPolicies::PolicyStatus polSt = this->GetPolicyStatus(cmPolicies::CMP0043);
-  if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD)
-    {
+  if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
     this->SetProperty("COMPILE_DEFINITIONS",
                       parent->GetProperty("COMPILE_DEFINITIONS"));
     std::vector<std::string> configs;
     this->GetConfigurations(configs);
-    for(std::vector<std::string>::const_iterator ci = configs.begin();
-        ci != configs.end(); ++ci)
-      {
+    for (std::vector<std::string>::const_iterator ci = configs.begin();
+         ci != configs.end(); ++ci) {
       std::string defPropName = "COMPILE_DEFINITIONS_";
       defPropName += cmSystemTools::UpperCase(*ci);
       const char* prop = parent->GetProperty(defPropName);
       this->SetProperty(defPropName, prop);
-      }
     }
+  }
 
   // link libraries
   this->LinkLibraries = parent->LinkLibraries;
@@ -1531,11 +1295,8 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
 void cmMakefile::PushFunctionScope(std::string const& fileName,
                                    const cmPolicies::PolicyMap& pm)
 {
-  this->StateSnapshot =
-      this->GetState()->CreateFunctionCallSnapshot(
-        this->StateSnapshot,
-        this->ContextStack.back()->Name, this->ContextStack.back()->Line,
-        fileName);
+  this->StateSnapshot = this->GetState()->CreateFunctionCallSnapshot(
+    this->StateSnapshot, fileName);
   assert(this->StateSnapshot.IsValid());
 
   this->PushLoopBlockBarrier();
@@ -1570,10 +1331,7 @@ void cmMakefile::PushMacroScope(std::string const& fileName,
                                 const cmPolicies::PolicyMap& pm)
 {
   this->StateSnapshot =
-      this->GetState()->CreateMacroCallSnapshot(
-        this->StateSnapshot,
-        this->ContextStack.back()->Name, this->ContextStack.back()->Line,
-        fileName);
+    this->GetState()->CreateMacroCallSnapshot(this->StateSnapshot, fileName);
   assert(this->StateSnapshot.IsValid());
 
   this->PushFunctionBlockerBarrier();
@@ -1598,14 +1356,16 @@ class cmMakefile::BuildsystemFileScope
 {
 public:
   BuildsystemFileScope(cmMakefile* mf)
-    : Makefile(mf), ReportError(true)
+    : Makefile(mf)
+    , ReportError(true)
   {
     std::string currentStart =
-        this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
+      this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
     currentStart += "/CMakeLists.txt";
     this->Makefile->StateSnapshot.SetListFile(currentStart);
-    this->Makefile->StateSnapshot = this->Makefile->StateSnapshot.GetState()
-        ->CreatePolicyScopeSnapshot(this->Makefile->StateSnapshot);
+    this->Makefile->StateSnapshot =
+      this->Makefile->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
+        this->Makefile->StateSnapshot);
     this->Makefile->PushFunctionBlockerBarrier();
 
     this->GG = mf->GetGlobalGenerator();
@@ -1638,9 +1398,17 @@ private:
   bool ReportError;
 };
 
-//----------------------------------------------------------------------------
 void cmMakefile::Configure()
 {
+  std::string currentStart =
+    this->StateSnapshot.GetDirectory().GetCurrentSource();
+  currentStart += "/CMakeLists.txt";
+
+  // Add the bottom of all backtraces within this directory.
+  // We will never pop this scope because it should be available
+  // for messages during the generate step too.
+  this->Backtrace = this->Backtrace.Push(currentStart);
+
   BuildsystemFileScope scope(this);
 
   // make sure the CMakeFiles dir is there
@@ -1648,109 +1416,96 @@ void cmMakefile::Configure()
   filesDir += cmake::GetCMakeFilesDirectory();
   cmSystemTools::MakeDirectory(filesDir.c_str());
 
-  std::string currentStart =
-      this->StateSnapshot.GetDirectory().GetCurrentSource();
-  currentStart += "/CMakeLists.txt";
   assert(cmSystemTools::FileExists(currentStart.c_str(), true));
   this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
 
   cmListFile listFile;
-  {
-  cmParseFileScope pfs(this);
-  if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this))
-    {
+  if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(),
+                          this)) {
     return;
-    }
   }
   this->ReadListFile(listFile, currentStart);
-  if(cmSystemTools::GetFatalErrorOccured())
-    {
+  if (cmSystemTools::GetFatalErrorOccured()) {
     scope.Quiet();
-    }
+  }
 
-   // at the end handle any old style subdirs
+  // at the end handle any old style subdirs
   std::vector<cmMakefile*> subdirs = this->UnConfiguredDirectories;
 
   // for each subdir recurse
   std::vector<cmMakefile*>::iterator sdi = subdirs.begin();
-  for (; sdi != subdirs.end(); ++sdi)
-    {
+  for (; sdi != subdirs.end(); ++sdi) {
     (*sdi)->StateSnapshot.InitializeFromParent_ForSubdirsCommand();
     this->ConfigureSubDirectory(*sdi);
-    }
+  }
 
   this->AddCMakeDependFilesFromUser();
 }
 
-void cmMakefile::ConfigureSubDirectory(cmMakefile *mf)
+void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
 {
   mf->InitializeFromParent(this);
   std::string currentStart = mf->GetCurrentSourceDirectory();
-  if (this->GetCMakeInstance()->GetDebugOutput())
-    {
-    std::string msg="   Entering             ";
+  if (this->GetCMakeInstance()->GetDebugOutput()) {
+    std::string msg = "   Entering             ";
     msg += currentStart;
     cmSystemTools::Message(msg.c_str());
-    }
+  }
 
   std::string const currentStartFile = currentStart + "/CMakeLists.txt";
-  if (!cmSystemTools::FileExists(currentStartFile, true))
-    {
+  if (!cmSystemTools::FileExists(currentStartFile, true)) {
     // The file is missing.  Check policy CMP0014.
     std::ostringstream e;
+    /* clang-format off */
     e << "The source directory\n"
       << "  " << currentStart << "\n"
       << "does not contain a CMakeLists.txt file.";
-    switch (this->GetPolicyStatus(cmPolicies::CMP0014))
-      {
+    /* clang-format on */
+    switch (this->GetPolicyStatus(cmPolicies::CMP0014)) {
       case cmPolicies::WARN:
         // Print the warning.
+        /* clang-format off */
         e << "\n"
           << "CMake does not support this case but it used "
           << "to work accidentally and is being allowed for "
           << "compatibility."
           << "\n"
           << cmPolicies::GetPolicyWarning(cmPolicies::CMP0014);
+        /* clang-format on */
         this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
       case cmPolicies::OLD:
         // OLD behavior does not warn.
         break;
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
-        e << "\n"
-          << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0014);
+        e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0014);
       case cmPolicies::NEW:
         // NEW behavior prints the error.
         this->IssueMessage(cmake::FATAL_ERROR, e.str());
-      }
-    return;
     }
+    return;
+  }
   // finally configure the subdir
   mf->Configure();
 
-  if (this->GetCMakeInstance()->GetDebugOutput())
-    {
-    std::string msg="   Returning to         ";
+  if (this->GetCMakeInstance()->GetDebugOutput()) {
+    std::string msg = "   Returning to         ";
     msg += this->GetCurrentSourceDirectory();
     cmSystemTools::Message(msg.c_str());
-    }
+  }
 }
 
 void cmMakefile::AddSubDirectory(const std::string& srcPath,
                                  const std::string& binPath,
-                                 bool excludeFromAll,
-                                 bool immediate)
+                                 bool excludeFromAll, bool immediate)
 {
   // Make sure the binary directory is unique.
-  if(!this->EnforceUniqueDir(srcPath, binPath))
-    {
+  if (!this->EnforceUniqueDir(srcPath, binPath)) {
     return;
-    }
+  }
 
-  cmState::Snapshot newSnapshot = this->GetState()
-      ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot,
-                                           this->ContextStack.back()->Name,
-                                           this->ContextStack.back()->Line);
+  cmState::Snapshot newSnapshot =
+    this->GetState()->CreateBuildsystemDirectorySnapshot(this->StateSnapshot);
 
   newSnapshot.GetDirectory().SetCurrentSource(srcPath);
   newSnapshot.GetDirectory().SetCurrentBinary(binPath);
@@ -1760,19 +1515,15 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
   cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
   this->GetGlobalGenerator()->AddMakefile(subMf);
 
-  if(excludeFromAll)
-    {
+  if (excludeFromAll) {
     subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
-    }
+  }
 
-  if (immediate)
-    {
+  if (immediate) {
     this->ConfigureSubDirectory(subMf);
-    }
-  else
-    {
+  } else {
     this->UnConfiguredDirectories.push_back(subMf);
-    }
+  }
 }
 
 const char* cmMakefile::GetCurrentSourceDirectory() const
@@ -1790,167 +1541,141 @@ std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
   std::vector<cmTarget*> tgts;
   tgts.reserve(this->ImportedTargets.size());
   for (TargetMap::const_iterator it = this->ImportedTargets.begin();
-       it != this->ImportedTargets.end(); ++it)
-    {
+       it != this->ImportedTargets.end(); ++it) {
     tgts.push_back(it->second);
-    }
+  }
   return tgts;
 }
 
-//----------------------------------------------------------------------------
-void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
+void cmMakefile::AddIncludeDirectories(const std::vector<std::string>& incs,
                                        bool before)
 {
-  if (incs.empty())
-    {
+  if (incs.empty()) {
     return;
-    }
+  }
 
   cmListFileBacktrace lfbt = this->GetBacktrace();
   std::string entryString = cmJoin(incs, ";");
-  if (before)
-    {
-    this->StateSnapshot.GetDirectory()
-          .PrependIncludeDirectoriesEntry(entryString, lfbt);
-    }
-  else
-    {
-    this->StateSnapshot.GetDirectory()
-          .AppendIncludeDirectoriesEntry(entryString, lfbt);
-    }
+  if (before) {
+    this->StateSnapshot.GetDirectory().PrependIncludeDirectoriesEntry(
+      entryString, lfbt);
+  } else {
+    this->StateSnapshot.GetDirectory().AppendIncludeDirectoriesEntry(
+      entryString, lfbt);
+  }
 
   // Property on each target:
-  for (cmTargets::iterator l = this->Targets.begin();
-       l != this->Targets.end(); ++l)
-    {
-    cmTarget &t = l->second;
+  for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
+       ++l) {
+    cmTarget& t = l->second;
     t.InsertInclude(entryString, lfbt, before);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefile::AddSystemIncludeDirectories(const std::set<std::string> &incs)
+void cmMakefile::AddSystemIncludeDirectories(const std::set<std::string>& incs)
 {
+  if (incs.empty()) {
+    return;
+  }
+
   this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
 
-  for (cmTargets::iterator l = this->Targets.begin();
-       l != this->Targets.end(); ++l)
-    {
-    cmTarget &t = l->second;
+  for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
+       ++l) {
+    cmTarget& t = l->second;
     t.AddSystemIncludeDirectories(incs);
-    }
+  }
 }
 
 void cmMakefile::AddDefinition(const std::string& name, const char* value)
 {
-  if (!value )
-    {
+  if (!value) {
     return;
-    }
+  }
 
-  if (this->VariableInitialized(name))
-    {
+  if (this->VariableInitialized(name)) {
     this->LogUnused("changing definition", name);
-    }
+  }
   this->StateSnapshot.SetDefinition(name, value);
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
-  if ( vv )
-    {
-    vv->VariableAccessed(name,
-                         cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
-                         value,
-                         this);
-    }
+  if (vv) {
+    vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
+                         value, this);
+  }
 #endif
 }
 
-
 void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
                                     const char* doc,
-                                    cmState::CacheEntryType type,
-                                    bool force)
-{
-  bool haveVal = value ? true : false;
-  std::string val = haveVal ? value : "";
-  const char* existingValue =
-    this->GetState()->GetInitializedCacheValue(name);
-  if(existingValue
-      && (this->GetState()->GetCacheEntryType(name)
-                                            == cmState::UNINITIALIZED))
-    {
+                                    cmState::CacheEntryType type, bool force)
+{
+  const char* existingValue = this->GetState()->GetInitializedCacheValue(name);
+  // must be outside the following if() to keep it alive long enough
+  std::string nvalue;
+
+  if (existingValue &&
+      (this->GetState()->GetCacheEntryType(name) == cmState::UNINITIALIZED)) {
     // if this is not a force, then use the value from the cache
     // if it is a force, then use the value being passed in
-    if(!force)
-      {
-      val = existingValue;
-      haveVal = true;
-      }
-    if ( type == cmState::PATH || type == cmState::FILEPATH )
-      {
+    if (!force) {
+      value = existingValue;
+    }
+    if (type == cmState::PATH || type == cmState::FILEPATH) {
       std::vector<std::string>::size_type cc;
       std::vector<std::string> files;
-      std::string nvalue = "";
-      cmSystemTools::ExpandListArgument(val, files);
-      for ( cc = 0; cc < files.size(); cc ++ )
-        {
-        if(!cmSystemTools::IsOff(files[cc].c_str()))
-          {
+      nvalue = value ? value : "";
+
+      cmSystemTools::ExpandListArgument(nvalue, files);
+      nvalue = "";
+      for (cc = 0; cc < files.size(); cc++) {
+        if (!cmSystemTools::IsOff(files[cc].c_str())) {
           files[cc] = cmSystemTools::CollapseFullPath(files[cc]);
-          }
-        if ( cc > 0 )
-          {
+        }
+        if (cc > 0) {
           nvalue += ";";
-          }
-        nvalue += files[cc];
         }
-
-      this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
-      val = this->GetState()->GetInitializedCacheValue(name);
-      haveVal = true;
+        nvalue += files[cc];
       }
 
+      this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
+      nvalue = this->GetState()->GetInitializedCacheValue(name);
+      value = nvalue.c_str();
     }
-  this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
-                                          doc, type);
+  }
+  this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
   // if there was a definition then remove it
   this->StateSnapshot.RemoveDefinition(name);
 }
 
-
 void cmMakefile::AddDefinition(const std::string& name, bool value)
 {
-  if (this->VariableInitialized(name))
-    {
+  if (this->VariableInitialized(name)) {
     this->LogUnused("changing definition", name);
-    }
+  }
 
   this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF");
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
-  if ( vv )
-    {
+  if (vv) {
     vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
-      value?"ON":"OFF", this);
-    }
+                         value ? "ON" : "OFF", this);
+  }
 #endif
 }
 
 void cmMakefile::CheckForUnusedVariables() const
 {
-  if (!this->WarnUnused)
-    {
+  if (!this->WarnUnused) {
     return;
-    }
+  }
   const std::vector<std::string>& unused = this->StateSnapshot.UnusedKeys();
   std::vector<std::string>::const_iterator it = unused.begin();
-  for (; it != unused.end(); ++it)
-    {
+  for (; it != unused.end(); ++it) {
     this->LogUnused("out of scope", *it);
-    }
+  }
 }
 
 void cmMakefile::MarkVariableAsUsed(const std::string& var)
@@ -1963,59 +1688,41 @@ bool cmMakefile::VariableInitialized(const std::string& var) const
   return this->StateSnapshot.IsInitialized(var);
 }
 
-void cmMakefile::LogUnused(const char* reason,
-                                const std::string& name) const
+void cmMakefile::LogUnused(const char* reason, const std::string& name) const
 {
-  if (this->WarnUnused)
-    {
+  if (this->WarnUnused) {
     std::string path;
-    cmListFileContext lfc;
-    if (!this->ExecutionStatusStack.empty())
-      {
-      lfc = this->GetExecutionContext();
-      path = lfc.FilePath;
-      }
-    else
-      {
+    if (!this->ExecutionStatusStack.empty()) {
+      path = this->GetExecutionContext().FilePath;
+    } else {
       path = this->GetCurrentSourceDirectory();
       path += "/CMakeLists.txt";
-      lfc.FilePath = path;
-      lfc.Line = 0;
-      }
-    cmOutputConverter converter(this->StateSnapshot);
-    lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
+    }
 
     if (this->CheckSystemVars ||
-        cmSystemTools::IsSubDirectory(path,
-                                      this->GetHomeDirectory()) ||
-        (cmSystemTools::IsSubDirectory(path,
-                                      this->GetHomeOutputDirectory()) &&
-        !cmSystemTools::IsSubDirectory(path,
-                                cmake::GetCMakeFilesDirectory())))
-      {
+        cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) ||
+        (cmSystemTools::IsSubDirectory(path, this->GetHomeOutputDirectory()) &&
+         !cmSystemTools::IsSubDirectory(path,
+                                        cmake::GetCMakeFilesDirectory()))) {
       std::ostringstream msg;
       msg << "unused variable (" << reason << ") \'" << name << "\'";
-      this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
-                                             msg.str(),
-                                             lfc);
-      }
+      this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
     }
+  }
 }
 
 void cmMakefile::RemoveDefinition(const std::string& name)
 {
-  if (this->VariableInitialized(name))
-    {
+  if (this->VariableInitialized(name)) {
     this->LogUnused("unsetting", name);
-    }
+  }
   this->StateSnapshot.RemoveDefinition(name);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
-  if ( vv )
-    {
-    vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS,
-      0, this);
-    }
+  if (vv) {
+    vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS, 0,
+                         this);
+  }
 #endif
 }
 
@@ -2033,95 +1740,81 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name,
                                           cmTarget& target)
 {
   // for these targets do not add anything
-  switch(target.GetType())
-    {
+  switch (target.GetType()) {
     case cmState::UTILITY:
     case cmState::GLOBAL_TARGET:
     case cmState::INTERFACE_LIBRARY:
       return;
     default:;
-    }
-  if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES"))
-    {
+  }
+  if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
     std::vector<std::string> linkDirs;
     cmSystemTools::ExpandListArgument(linkDirsProp, linkDirs);
 
-    for(std::vector<std::string>::iterator j = linkDirs.begin();
-        j != linkDirs.end(); ++j)
-      {
+    for (std::vector<std::string>::iterator j = linkDirs.begin();
+         j != linkDirs.end(); ++j) {
       std::string newdir = *j;
       // remove trailing slashes
-      if(*j->rbegin() == '/')
-        {
-        newdir = j->substr(0, j->size()-1);
-        }
-      if(std::find(this->LinkDirectories.begin(),
-                   this->LinkDirectories.end(), newdir)
-          == this->LinkDirectories.end())
-        {
+      if (*j->rbegin() == '/') {
+        newdir = j->substr(0, j->size() - 1);
+      }
+      if (std::find(this->LinkDirectories.begin(), this->LinkDirectories.end(),
+                    newdir) == this->LinkDirectories.end()) {
         target.AddLinkDirectory(*j);
-        }
       }
     }
-  target.MergeLinkLibraries( *this, name, this->LinkLibraries );
+  }
+  target.MergeLinkLibraries(*this, name, this->LinkLibraries);
 }
 
-
-void cmMakefile::AddAlias(const std::string& lname,
-                          std::string const& tgtName)
+void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName)
 {
   this->AliasTargets[lname] = tgtName;
   this->GetGlobalGenerator()->AddAlias(lname, tgtName);
 }
 
 cmTarget* cmMakefile::AddLibrary(const std::string& lname,
-                            cmState::TargetType type,
-                            const std::vector<std::string> &srcs,
-                            bool excludeFromAll)
+                                 cmState::TargetType type,
+                                 const std::vector<std::string>& srcs,
+                                 bool excludeFromAll)
 {
   // wrong type ? default to STATIC
-  if (    (type != cmState::STATIC_LIBRARY)
-       && (type != cmState::SHARED_LIBRARY)
-       && (type != cmState::MODULE_LIBRARY)
-       && (type != cmState::OBJECT_LIBRARY)
-       && (type != cmState::INTERFACE_LIBRARY))
-    {
+  if ((type != cmState::STATIC_LIBRARY) && (type != cmState::SHARED_LIBRARY) &&
+      (type != cmState::MODULE_LIBRARY) && (type != cmState::OBJECT_LIBRARY) &&
+      (type != cmState::INTERFACE_LIBRARY)) {
     this->IssueMessage(cmake::INTERNAL_ERROR,
                        "cmMakefile::AddLibrary given invalid target type.");
     type = cmState::STATIC_LIBRARY;
-    }
+  }
 
   cmTarget* target = this->AddNewTarget(type, lname);
   // Clear its dependencies. Otherwise, dependencies might persist
   // over changes in CMakeLists.txt, making the information stale and
   // hence useless.
-  target->ClearDependencyInformation( *this, lname );
-  if(excludeFromAll)
-    {
+  target->ClearDependencyInformation(*this, lname);
+  if (excludeFromAll) {
     target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
-    }
+  }
   target->AddSources(srcs);
   this->AddGlobalLinkInformation(lname, *target);
   return target;
 }
 
-cmTarget* cmMakefile::AddExecutable(const char *exeName,
-                                    const std::vector<std::string> &srcs,
+cmTarget* cmMakefile::AddExecutable(const char* exeName,
+                                    const std::vector<std::string>& srcs,
                                     bool excludeFromAll)
 {
   cmTarget* target = this->AddNewTarget(cmState::EXECUTABLE, exeName);
-  if(excludeFromAll)
-    {
+  if (excludeFromAll) {
     target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
-    }
+  }
   target->AddSources(srcs);
   this->AddGlobalLinkInformation(exeName, *target);
   return target;
 }
 
-//----------------------------------------------------------------------------
-cmTarget*
-cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name)
+cmTarget* cmMakefile::AddNewTarget(cmState::TargetType type,
+                                   const std::string& name)
 {
   cmTargets::iterator it =
     this->Targets.insert(cmTargets::value_type(name, cmTarget())).first;
@@ -2132,96 +1825,84 @@ cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name)
   return &it->second;
 }
 
-cmSourceFile*
-cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const
+cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput(
+  const std::string& name) const
 {
   std::string out;
 
   // look through all the source files that have custom commands
   // and see if the custom command has the passed source file as an output
-  for(std::vector<cmSourceFile*>::const_iterator i =
-        this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator i =
+         this->SourceFiles.begin();
+       i != this->SourceFiles.end(); ++i) {
     // does this source file have a custom command?
-    if ((*i)->GetCustomCommand())
-      {
+    if ((*i)->GetCustomCommand()) {
       // 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();
-          o != outputs.end(); ++o)
-        {
+      for (std::vector<std::string>::const_iterator o = outputs.begin();
+           o != outputs.end(); ++o) {
         out = *o;
         std::string::size_type pos = out.rfind(name);
         // If the output matches exactly
-        if (pos != out.npos &&
-            pos == out.size() - name.size() &&
-            (pos ==0 || out[pos-1] == '/'))
-          {
+        if (pos != out.npos && pos == out.size() - name.size() &&
+            (pos == 0 || out[pos - 1] == '/')) {
           return *i;
-          }
         }
       }
     }
+  }
 
   // otherwise return NULL
   return 0;
 }
 
-cmSourceFile *cmMakefile::GetSourceFileWithOutput(
-                                                const std::string& name) const
+cmSourceFile* cmMakefile::GetSourceFileWithOutput(
+  const std::string& name) const
 {
   // 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(name.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(name.c_str())) {
     return this->LinearGetSourceFileWithOutput(name);
-    }
+  }
   // Otherwise we use an efficient lookup map.
   OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
-  if (o != this->OutputToSource.end())
-    {
+  if (o != this->OutputToSource.end()) {
     return (*o).second;
-    }
+  }
   return 0;
 }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-cmSourceGroup*
-cmMakefile::GetSourceGroup(const std::vector<std::string>&name) const
+cmSourceGroup* cmMakefile::GetSourceGroup(
+  const std::vector<std::string>& name) const
 {
   cmSourceGroup* sg = 0;
 
   // first look for source group starting with the same as the one we want
-  for (std::vector<cmSourceGroup>::const_iterator
-      sgIt = this->SourceGroups.begin();
-      sgIt != this->SourceGroups.end(); ++sgIt)
-    {
+  for (std::vector<cmSourceGroup>::const_iterator sgIt =
+         this->SourceGroups.begin();
+       sgIt != this->SourceGroups.end(); ++sgIt) {
     std::string sgName = sgIt->GetName();
-    if(sgName == name[0])
-      {
+    if (sgName == name[0]) {
       sg = const_cast<cmSourceGroup*>(&(*sgIt));
       break;
-      }
     }
+  }
 
-  if(sg != 0)
-    {
+  if (sg != 0) {
     // iterate through its children to find match source group
-    for(unsigned int i=1; i<name.size(); ++i)
-      {
+    for (unsigned int i = 1; i < name.size(); ++i) {
       sg = sg->LookupChild(name[i].c_str());
-      if(sg == 0)
-        {
+      if (sg == 0) {
         break;
-        }
       }
     }
+  }
   return sg;
 }
 
-void cmMakefile::AddSourceGroup(const std::string& name,
-                                 const char* regex)
+void cmMakefile::AddSourceGroup(const std::string& name, const char* regex)
 {
   std::vector<std::string> nameVector;
   nameVector.push_back(name);
@@ -2234,48 +1915,40 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
   cmSourceGroup* sg = 0;
   std::vector<std::string> currentName;
   int i = 0;
-  const int lastElement = static_cast<int>(name.size()-1);
-  for(i=lastElement; i>=0; --i)
-    {
-    currentName.assign(name.begin(), name.begin()+i+1);
+  const int lastElement = static_cast<int>(name.size() - 1);
+  for (i = lastElement; i >= 0; --i) {
+    currentName.assign(name.begin(), name.begin() + i + 1);
     sg = this->GetSourceGroup(currentName);
-    if(sg != 0)
-      {
+    if (sg != 0) {
       break;
-      }
     }
+  }
 
   // i now contains the index of the last found component
-  if(i==lastElement)
-    {
+  if (i == lastElement) {
     // group already exists, replace its regular expression
-    if ( regex && sg)
-      {
+    if (regex && sg) {
       // We only want to set the regular expression.  If there are already
       // source files in the group, we don't want to remove them.
       sg->SetGroupRegex(regex);
-      }
-    return;
     }
-  else if(i==-1)
-    {
+    return;
+  } else if (i == -1) {
     // group does not exist nor belong to any existing group
     // add its first component
     this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
     sg = this->GetSourceGroup(currentName);
     i = 0; // last component found
-    }
-  if(!sg)
-    {
+  }
+  if (!sg) {
     cmSystemTools::Error("Could not create source group ");
     return;
-    }
+  }
   // build the whole source group path
-  for(++i; i<=lastElement; ++i)
-    {
+  for (++i; i <= lastElement; ++i) {
     sg->AddChild(cmSourceGroup(name[i].c_str(), 0, sg->GetFullName()));
     sg = sg->LookupChild(name[i].c_str());
-    }
+  }
 
   sg->SetGroupRegex(regex);
 }
@@ -2284,103 +1957,99 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
 
 static bool mightExpandVariablesCMP0019(const char* s)
 {
-  return s && *s && strstr(s,"${") && strchr(s,'}');
+  return s && *s && strstr(s, "${") && strchr(s, '}');
 }
 
 void cmMakefile::ExpandVariablesCMP0019()
 {
   // Drop this ancient compatibility behavior with a policy.
   cmPolicies::PolicyStatus pol = this->GetPolicyStatus(cmPolicies::CMP0019);
-  if(pol != cmPolicies::OLD && pol != cmPolicies::WARN)
-    {
+  if (pol != cmPolicies::OLD && pol != cmPolicies::WARN) {
     return;
-    }
+  }
   std::ostringstream w;
 
-  const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
-  if(mightExpandVariablesCMP0019(includeDirs))
-    {
+  const char* includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
+  if (mightExpandVariablesCMP0019(includeDirs)) {
     std::string dirs = includeDirs;
     this->ExpandVariablesInString(dirs, true, true);
-    if(pol == cmPolicies::WARN && dirs != includeDirs)
-      {
+    if (pol == cmPolicies::WARN && dirs != includeDirs) {
+      /* clang-format off */
       w << "Evaluated directory INCLUDE_DIRECTORIES\n"
         << "  " << includeDirs << "\n"
         << "as\n"
         << "  " << dirs << "\n";
-      }
-    this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+      /* clang-format on */
     }
+    this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+  }
 
   // Also for each target's INCLUDE_DIRECTORIES property:
-  for (cmTargets::iterator l = this->Targets.begin();
-       l != this->Targets.end(); ++l)
-    {
-    cmTarget &t = l->second;
-    if (t.GetType() == cmState::INTERFACE_LIBRARY
-        || t.GetType() == cmState::GLOBAL_TARGET)
-      {
+  for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
+       ++l) {
+    cmTarget& t = l->second;
+    if (t.GetType() == cmState::INTERFACE_LIBRARY ||
+        t.GetType() == cmState::GLOBAL_TARGET) {
       continue;
-      }
+    }
     includeDirs = t.GetProperty("INCLUDE_DIRECTORIES");
-    if(mightExpandVariablesCMP0019(includeDirs))
-      {
+    if (mightExpandVariablesCMP0019(includeDirs)) {
       std::string dirs = includeDirs;
       this->ExpandVariablesInString(dirs, true, true);
-      if(pol == cmPolicies::WARN && dirs != includeDirs)
-        {
+      if (pol == cmPolicies::WARN && dirs != includeDirs) {
+        /* clang-format off */
         w << "Evaluated target " << t.GetName() << " INCLUDE_DIRECTORIES\n"
           << "  " << includeDirs << "\n"
           << "as\n"
           << "  " << dirs << "\n";
-        }
-      t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+        /* clang-format on */
       }
+      t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
     }
+  }
 
-  if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES"))
-    {
-    if(mightExpandVariablesCMP0019(linkDirsProp))
-      {
+  if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
+    if (mightExpandVariablesCMP0019(linkDirsProp)) {
       std::string d = linkDirsProp;
       std::string orig = linkDirsProp;
       this->ExpandVariablesInString(d, true, true);
-      if(pol == cmPolicies::WARN && d != orig)
-        {
+      if (pol == cmPolicies::WARN && d != orig) {
+        /* clang-format off */
         w << "Evaluated link directories\n"
           << "  " << orig << "\n"
           << "as\n"
           << "  " << d << "\n";
-        }
+        /* clang-format on */
       }
     }
-  for(cmTarget::LinkLibraryVectorType::iterator l =
-        this->LinkLibraries.begin();
-      l != this->LinkLibraries.end(); ++l)
-    {
-    if(mightExpandVariablesCMP0019(l->first.c_str()))
-      {
+  }
+  for (cmTarget::LinkLibraryVectorType::iterator l =
+         this->LinkLibraries.begin();
+       l != this->LinkLibraries.end(); ++l) {
+    if (mightExpandVariablesCMP0019(l->first.c_str())) {
       std::string orig = l->first;
       this->ExpandVariablesInString(l->first, true, true);
-      if(pol == cmPolicies::WARN && l->first != orig)
-        {
+      if (pol == cmPolicies::WARN && l->first != orig) {
+        /* clang-format off */
         w << "Evaluated link library\n"
           << "  " << orig << "\n"
           << "as\n"
           << "  " << l->first << "\n";
-        }
+        /* clang-format on */
       }
     }
+  }
 
-  if(!w.str().empty())
-    {
+  if (!w.str().empty()) {
     std::ostringstream m;
+    /* clang-format off */
     m << cmPolicies::GetPolicyWarning(cmPolicies::CMP0019)
       << "\n"
       << "The following variable evaluations were encountered:\n"
       << w.str();
+    /* clang-format on */
     this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
-    }
+  }
 }
 
 bool cmMakefile::IsOn(const std::string& name) const
@@ -2392,30 +2061,26 @@ bool cmMakefile::IsOn(const std::string& name) const
 bool cmMakefile::IsSet(const std::string& name) const
 {
   const char* value = this->GetDefinition(name);
-  if ( !value )
-    {
+  if (!value) {
     return false;
-    }
+  }
 
-  if ( ! *value )
-    {
+  if (!*value) {
     return false;
-    }
+  }
 
-  if ( cmSystemTools::IsNOTFOUND(value) )
-    {
+  if (cmSystemTools::IsNOTFOUND(value)) {
     return false;
-    }
+  }
 
   return true;
 }
 
 bool cmMakefile::PlatformIs64Bit() const
 {
-  if(const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P"))
-    {
+  if (const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) {
     return atoi(sizeof_dptr) == 8;
-    }
+  }
   return false;
 }
 
@@ -2425,130 +2090,109 @@ bool cmMakefile::PlatformIsAppleIos() const
   sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT");
   sdkRoot = cmSystemTools::LowerCase(sdkRoot);
 
-  const std::string embedded[] =
-    {
-    "appletvos", "appletvsimulator",
-    "iphoneos", "iphonesimulator",
-    "watchos", "watchsimulator",
-    };
+  const std::string embedded[] = {
+    "appletvos",       "appletvsimulator", "iphoneos",
+    "iphonesimulator", "watchos",          "watchsimulator",
+  };
 
-  for(size_t i = 0; i < sizeof(embedded) / sizeof(embedded[0]); ++i)
-    {
-    if(sdkRoot.find(embedded[i]) == 0 ||
-       sdkRoot.find(std::string("/") + embedded[i]) != std::string::npos)
-      {
+  for (size_t i = 0; i < sizeof(embedded) / sizeof(embedded[0]); ++i) {
+    if (sdkRoot.find(embedded[i]) == 0 ||
+        sdkRoot.find(std::string("/") + embedded[i]) != std::string::npos) {
       return true;
-      }
     }
+  }
 
-   return false;
+  return false;
 }
 
 const char* cmMakefile::GetSONameFlag(const std::string& language) const
 {
   std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
-  if(!language.empty())
-    {
+  if (!language.empty()) {
     name += "_";
     name += language;
-    }
+  }
   name += "_FLAG";
   return GetDefinition(name);
 }
 
 bool cmMakefile::CanIWriteThisFile(const char* fileName) const
 {
-  if ( !this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES") )
-    {
+  if (!this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES")) {
     return true;
-    }
+  }
   // If we are doing an in-source build, then the test will always fail
-  if ( cmSystemTools::SameFile(this->GetHomeDirectory(),
-                               this->GetHomeOutputDirectory()) )
-    {
-    if ( this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD") )
-      {
+  if (cmSystemTools::SameFile(this->GetHomeDirectory(),
+                              this->GetHomeOutputDirectory())) {
+    if (this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD")) {
       return false;
-      }
-    return true;
     }
+    return true;
+  }
 
   // Check if this is a subdirectory of the source tree but not a
   // subdirectory of the build tree
-  if ( cmSystemTools::IsSubDirectory(fileName,
-      this->GetHomeDirectory()) &&
-    !cmSystemTools::IsSubDirectory(fileName,
-      this->GetHomeOutputDirectory()) )
-    {
+  if (cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) &&
+      !cmSystemTools::IsSubDirectory(fileName,
+                                     this->GetHomeOutputDirectory())) {
     return false;
-    }
+  }
   return true;
 }
 
 const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
 {
   const char* ret = this->GetDefinition(name);
-  if(!ret)
-    {
+  if (!ret) {
     cmSystemTools::Error("Error required internal CMake variable not "
                          "set, cmake may be not be built correctly.\n",
-                         "Missing variable is:\n",
-                         name.c_str());
+                         "Missing variable is:\n", name.c_str());
     return "";
-    }
+  }
   return ret;
 }
 
 bool cmMakefile::IsDefinitionSet(const std::string& name) const
 {
   const char* def = this->StateSnapshot.GetDefinition(name);
-  if(!def)
-    {
+  if (!def) {
     def = this->GetState()->GetInitializedCacheValue(name);
-    }
+  }
 #ifdef CMAKE_BUILD_WITH_CMAKE
-  if(cmVariableWatch* vv = this->GetVariableWatch())
-    {
-    if(!def)
-      {
-      vv->VariableAccessed
-        (name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS,
-         def, this);
-      }
+  if (cmVariableWatch* vv = this->GetVariableWatch()) {
+    if (!def) {
+      vv->VariableAccessed(
+        name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, def, this);
     }
+  }
 #endif
-  return def?true:false;
+  return def ? true : false;
 }
 
 const char* cmMakefile::GetDefinition(const std::string& name) const
 {
   const char* def = this->StateSnapshot.GetDefinition(name);
-  if(!def)
-    {
+  if (!def) {
     def = this->GetState()->GetInitializedCacheValue(name);
-    }
+  }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
-  if ( vv && !this->SuppressWatches )
-    {
-    bool const watch_function_executed =
-      vv->VariableAccessed(name,
-                           def ? cmVariableWatch::VARIABLE_READ_ACCESS
-                           : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
-                           def, this);
+  if (vv && !this->SuppressWatches) {
+    bool const watch_function_executed = vv->VariableAccessed(
+      name, def ? cmVariableWatch::VARIABLE_READ_ACCESS
+                : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
+      def, this);
 
-    if (watch_function_executed)
-      {
+    if (watch_function_executed) {
       // A callback was executed and may have caused re-allocation of the
       // variable storage.  Look it up again for now.
       // FIXME: Refactor variable storage to avoid this problem.
       def = this->StateSnapshot.GetDefinition(name);
-      if(!def)
-        {
+      if (!def) {
         def = this->GetState()->GetInitializedCacheValue(name);
-        }
       }
     }
+  }
 #endif
   return def;
 }
@@ -2556,10 +2200,9 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
 const char* cmMakefile::GetSafeDefinition(const std::string& def) const
 {
   const char* ret = this->GetDefinition(def);
-  if(!ret)
-    {
+  if (!ret) {
     return "";
-    }
+  }
   return ret;
 }
 
@@ -2572,20 +2215,14 @@ std::vector<std::string> cmMakefile::GetDefinitions() const
   return res;
 }
 
-
-const char *cmMakefile::ExpandVariablesInString(std::string& source) const
+const char* cmMakefile::ExpandVariablesInString(std::string& source) const
 {
   return this->ExpandVariablesInString(source, false, false);
 }
 
-const char *cmMakefile::ExpandVariablesInString(std::string& source,
-                                                bool escapeQuotes,
-                                                bool noEscapes,
-                                                bool atOnly,
-                                                const char* filename,
-                                                long line,
-                                                bool removeEmpty,
-                                                bool replaceAt) const
+const char* cmMakefile::ExpandVariablesInString(
+  std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly,
+  const char* filename, long line, bool removeEmpty, bool replaceAt) const
 {
   bool compareResults = false;
   cmake::MessageType mtype = cmake::LOG;
@@ -2593,25 +2230,22 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
   std::string original;
 
   // Sanity check the @ONLY mode.
-  if(atOnly && (!noEscapes || !removeEmpty))
-    {
+  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:
-      {
+  switch (this->GetPolicyStatus(cmPolicies::CMP0053)) {
+    case cmPolicies::WARN: {
       // Save the original string for the warning.
       original = source;
       newResult = source;
@@ -2619,41 +2253,36 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
       // 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);
+      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);
+      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.
+    // Messaging here would be *very* verbose.
     case cmPolicies::NEW:
       mtype = ExpandVariablesInStringNew(errorstr, source, escapeQuotes,
-                                         noEscapes, atOnly, filename,
-                                         line, removeEmpty, replaceAt);
+                                         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)
-      {
+  if (mtype != cmake::LOG) {
+    if (mtype == cmake::FATAL_ERROR) {
       cmSystemTools::SetFatalErrorOccured();
-      }
-    this->IssueMessage(mtype, errorstr);
     }
+    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 =
-      cmPolicies::GetPolicyWarning(cmPolicies::CMP0053);
+  else if (compareResults && (newResult != source || newError != mtype)) {
+    std::string msg = cmPolicies::GetPolicyWarning(cmPolicies::CMP0053);
     msg += "\n";
 
     std::string msg_input = original;
@@ -2668,52 +2297,41 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
     msg += msg_old;
     msg += "'\n";
 
-    if(newError == mtype)
-      {
+    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
-      {
+    } 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
+  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)
-    {
+  if (source.find_first_of("$@\\") == source.npos) {
     return cmake::LOG;
-    }
+  }
 
   // Special-case the @ONLY mode.
-  if(atOnly)
-    {
+  if (atOnly) {
     // Store an original copy of the input.
     std::string input = source;
 
@@ -2722,39 +2340,34 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
 
     // Look for one @VAR@ at a time.
     const char* in = input.c_str();
-    while(this->cmAtVarRegex.find(in))
-      {
+    while (this->cmAtVarRegex.find(in)) {
       // Get the range of the string to replace.
       const char* first = in + this->cmAtVarRegex.start();
-      const char* last =  in + this->cmAtVarRegex.end();
+      const char* last = in + this->cmAtVarRegex.end();
 
       // Store the unchanged part of the string now.
-      source.append(in, first-in);
+      source.append(in, first - in);
 
       // Lookup the definition of VAR.
-      std::string var(first+1, last-first-2);
-      if(const char* val = this->GetDefinition(var))
-        {
+      std::string var(first + 1, last - first - 2);
+      if (const char* val = this->GetDefinition(var)) {
         // Store the value in the output escaping as requested.
-        if(escapeQuotes)
-          {
+        if (escapeQuotes) {
           source.append(cmSystemTools::EscapeQuotes(val));
-          }
-        else
-          {
+        } else {
           source.append(val);
-          }
         }
+      }
 
       // Continue looking for @VAR@ further along the string.
       in = last;
-      }
+    }
 
     // Append the rest of the unchanged part of the string.
     source.append(in);
 
     return cmake::LOG;
-    }
+  }
 
   // This method replaces ${VAR} and @VAR@ where VAR is looked up
   // with GetDefinition(), if not found in the map, nothing is expanded.
@@ -2771,23 +2384,19 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
   int res = parser.ParseString(source.c_str(), 0);
   const char* emsg = parser.GetError();
   cmake::MessageType mtype = cmake::LOG;
-  if ( res && !emsg[0] )
-    {
+  if (res && !emsg[0]) {
     source = parser.GetResult();
-    }
-  else
-    {
+  } else {
     // Construct the main error message.
     std::ostringstream error;
     error << "Syntax error in cmake code ";
-    if(filename && line > 0)
-      {
+    if (filename && line > 0) {
       // This filename and line number may be more specific than the
       // command context because one command invocation can have
       // arguments on multiple lines.
       error << "at\n"
             << "  " << filename << ":" << line << "\n";
-      }
+    }
     error << "when parsing string\n"
           << "  " << source << "\n";
     error << emsg;
@@ -2798,12 +2407,10 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
     // helper implementation is unhappy, which has always reported an
     // error.
     mtype = cmake::FATAL_ERROR;
-    if(!res)
-      {
+    if (!res) {
       // This is a real argument parsing error.  Use policy CMP0010 to
       // decide whether it is an error.
-      switch(this->GetPolicyStatus(cmPolicies::CMP0010))
-        {
+      switch (this->GetPolicyStatus(cmPolicies::CMP0010)) {
         case cmPolicies::WARN:
           error << "\n" << cmPolicies::GetPolicyWarning(cmPolicies::CMP0010);
         case cmPolicies::OLD:
@@ -2817,36 +2424,29 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
         case cmPolicies::NEW:
           // NEW behavior is to report the error.
           break;
-        }
       }
-    errorstr = error.str();
     }
+    errorstr = error.str();
+  }
   return mtype;
 }
 
-typedef enum
-  {
-  NORMAL,
-  ENVIRONMENT,
-  CACHE
-  } t_domain;
+typedef enum { NORMAL, ENVIRONMENT, CACHE } t_domain;
 struct t_lookup
+{
+  t_lookup()
+    : domain(NORMAL)
+    , loc(0)
   {
-  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
+  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.
@@ -2864,14 +2464,11 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
 
   cmState* state = this->GetCMakeInstance()->GetState();
 
-  do
-    {
+  do {
     char inc = *in;
-    switch(inc)
-      {
+    switch (inc) {
       case '}':
-        if(!openstack.empty())
-          {
+        if (!openstack.empty()) {
           t_lookup var = openstack.back();
           openstack.pop_back();
           result.append(last, in - last);
@@ -2879,19 +2476,15 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
           const char* value = NULL;
           std::string varresult;
           static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
-          switch(var.domain)
-            {
+          switch (var.domain) {
             case NORMAL:
-              if(filename && lookup == lineVar)
-                {
+              if (filename && lookup == lineVar) {
                 std::ostringstream ostr;
                 ostr << line;
                 varresult = ostr.str();
-                }
-              else
-                {
+              } else {
                 value = this->GetDefinition(lookup);
-                }
+              }
               break;
             case ENVIRONMENT:
               value = cmSystemTools::GetEnv(lookup.c_str());
@@ -2899,160 +2492,116 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
             case CACHE:
               value = state->GetCacheEntryValue(lookup);
               break;
-            }
+          }
           // Get the string we're meant to append to.
-          if(value)
-            {
-            if(escapeQuotes)
-              {
+          if (value) {
+            if (escapeQuotes) {
               varresult = cmSystemTools::EscapeQuotes(value);
-              }
-            else
-              {
+            } else {
               varresult = value;
-              }
             }
-          else if(!removeEmpty)
-            {
+          } 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->GetCMakeInstance()->GetWarnUninitialized() &&
+                !this->VariableInitialized(lookup)) {
               if (this->CheckSystemVars ||
                   cmSystemTools::IsSubDirectory(filename,
                                                 this->GetHomeDirectory()) ||
-                  cmSystemTools::IsSubDirectory(filename,
-                                             this->GetHomeOutputDirectory()))
-                {
+                  cmSystemTools::IsSubDirectory(
+                    filename, this->GetHomeOutputDirectory())) {
                 std::ostringstream msg;
-                cmListFileContext lfc;
-                cmOutputConverter converter(this->StateSnapshot);
-                lfc.FilePath =
-                    converter.Convert(filename, cmOutputConverter::HOME);
-                lfc.Line = line;
                 msg << "uninitialized variable \'" << lookup << "\'";
-                this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
-                                                       msg.str(), lfc);
-                }
+                this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
               }
             }
+          }
           result.replace(var.loc, result.size() - var.loc, varresult);
           // Start looking from here on out.
           last = in + 1;
-          }
+        }
         break;
       case '$':
-        if(!atOnly)
-          {
+        if (!atOnly) {
           t_lookup lookup;
           const char* next = in + 1;
           const char* start = NULL;
           char nextc = *next;
-          if(nextc == '{')
-            {
+          if (nextc == '{') {
             // Looking for a variable.
             start = in + 2;
             lookup.domain = NORMAL;
-            }
-          else if(nextc == '<')
-            {
-            }
-          else if(!nextc)
-            {
+          } else if (nextc == '<') {
+          } else if (!nextc) {
             result.append(last, next - last);
             last = next;
-            }
-          else if(cmHasLiteralPrefix(next, "ENV{"))
-            {
+          } else if (cmHasLiteralPrefix(next, "ENV{")) {
             // Looking for an environment variable.
             start = in + 5;
             lookup.domain = ENVIRONMENT;
-            }
-          else if(cmHasLiteralPrefix(next, "CACHE{"))
-            {
+          } 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.";
+          } 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)
-            {
+          }
+          if (start) {
             result.append(last, in - last);
             last = start;
             in = start - 1;
             lookup.loc = result.size();
             openstack.push_back(lookup);
-            }
-          break;
           }
+          break;
+        }
       case '\\':
-        if(!noEscapes)
-          {
+        if (!noEscapes) {
           const char* next = in + 1;
           char nextc = *next;
-          if(nextc == 't')
-            {
+          if (nextc == 't') {
             result.append(last, in - last);
             result.append("\t");
             last = next + 1;
-            }
-          else if(nextc == 'n')
-            {
+          } else if (nextc == 'n') {
             result.append(last, in - last);
             result.append("\n");
             last = next + 1;
-            }
-          else if(nextc == 'r')
-            {
+          } else if (nextc == 'r') {
             result.append(last, in - last);
             result.append("\r");
             last = next + 1;
-            }
-          else if(nextc == ';' && openstack.empty())
-            {
+          } else if (nextc == ';' && openstack.empty()) {
             // Handled in ExpandListArgument; pass the backslash literally.
-            }
-          else if (isalnum(nextc) || nextc == '\0')
-            {
+          } else if (isalnum(nextc) || nextc == '\0') {
             errorstr += "Invalid character escape '\\";
-            if (nextc)
-              {
+            if (nextc) {
               errorstr += nextc;
               errorstr += "'.";
-              }
-            else
-              {
+            } else {
               errorstr += "' (at end of input).";
-              }
-            error = true;
             }
-          else
-            {
+            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)
-            {
+          if (*last) {
             ++in;
-            }
           }
+        }
         break;
       case '\n':
         // Onto the next line.
@@ -3062,87 +2611,77 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
         done = true;
         break;
       case '@':
-        if(replaceAt)
-          {
+        if (replaceAt) {
           const char* nextAt = strchr(in + 1, '@');
-          if(nextAt && nextAt != in + 1 &&
-             nextAt == in + 1 + strspn(in + 1,
-                "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                "abcdefghijklmnopqrstuvwxyz"
-                "0123456789/_.+-"))
-            {
+          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)
-              {
+            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.empty() &&
-           !(isalnum(inc) || inc == '_' ||
-             inc == '/' || inc == '.' ||
-             inc == '+' || inc == '-'))
-          {
+        }
+      // Failed to find a valid @ expansion; treat it as literal.
+      /* FALLTHROUGH */
+      default: {
+        if (!openstack.empty() &&
+            !(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.back().loc) + "'";
+                      "'" +
+            result.substr(openstack.back().loc) + "'";
           mtype = cmake::FATAL_ERROR;
           error = true;
-          }
-        break;
         }
+        break;
       }
+    }
     // Look at the next character.
-    } while(!error && !done && *++in);
+  } while (!error && !done && *++in);
 
   // Check for open variable references yet.
-  if(!error && !openstack.empty())
-    {
+  if (!error && !openstack.empty()) {
     // 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)
-    {
+  if (error) {
     std::ostringstream emsg;
     emsg << "Syntax error in cmake code ";
-    if(filename)
-      {
+    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";
-      }
+           << "  " << filename << ":" << line << "\n";
+    }
     emsg << "when parsing string\n"
          << "  " << source << "\n";
     emsg << errorstr;
     mtype = cmake::FATAL_ERROR;
     errorstr = emsg.str();
-    }
-  else
-    {
+  } else {
     // Append the rest of the unchanged part of the string.
     result.append(last);
 
     source = result;
-    }
+  }
 
   return mtype;
 }
@@ -3150,53 +2689,41 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
 void cmMakefile::RemoveVariablesInString(std::string& source,
                                          bool atOnly) const
 {
-  if(!atOnly)
-    {
+  if (!atOnly) {
     cmsys::RegularExpression var("(\\${[A-Za-z_0-9]*})");
-    while (var.find(source))
-      {
-      source.erase(var.start(),var.end() - var.start());
-      }
+    while (var.find(source)) {
+      source.erase(var.start(), var.end() - var.start());
     }
+  }
 
-  if(!atOnly)
-    {
+  if (!atOnly) {
     cmsys::RegularExpression varb("(\\$ENV{[A-Za-z_0-9]*})");
-    while (varb.find(source))
-      {
-      source.erase(varb.start(),varb.end() - varb.start());
-      }
+    while (varb.find(source)) {
+      source.erase(varb.start(), varb.end() - varb.start());
     }
+  }
   cmsys::RegularExpression var2("(@[A-Za-z_0-9]*@)");
-  while (var2.find(source))
-    {
-    source.erase(var2.start(),var2.end() - var2.start());
-    }
+  while (var2.find(source)) {
+    source.erase(var2.start(), var2.end() - var2.start());
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmMakefile::GetConfigurations(std::vector<std::string>& configs,
-                              bool singleConfig) const
+std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
+                                          bool singleConfig) const
 {
-  if(this->GetGlobalGenerator()->IsMultiConfig())
-    {
-    if(const char* configTypes =
-       this->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
-      {
+  if (this->GetGlobalGenerator()->IsMultiConfig()) {
+    if (const char* configTypes =
+          this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
       cmSystemTools::ExpandListArgument(configTypes, configs);
-      }
-    return "";
     }
-  else
-    {
+    return "";
+  } else {
     const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
-    if(singleConfig && !buildType.empty())
-      {
+    if (singleConfig && !buildType.empty()) {
       configs.push_back(buildType);
-      }
-    return buildType;
     }
+    return buildType;
+  }
 }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -3207,32 +2734,26 @@ cmMakefile::GetConfigurations(std::vector<std::string>& configs,
  * non-inherited SOURCE_GROUP commands will have precedence over
  * inherited ones.
  */
-cmSourceGroup*
-cmMakefile::FindSourceGroup(const char* source,
-                            std::vector<cmSourceGroup> &groups) const
+cmSourceGroup* cmMakefile::FindSourceGroup(
+  const char* source, std::vector<cmSourceGroup>& groups) const
 {
   // First search for a group that lists the file explicitly.
-  for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
-      sg != groups.rend(); ++sg)
-    {
-    cmSourceGroup *result = sg->MatchChildrenFiles(source);
-    if(result)
-      {
+  for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
+       sg != groups.rend(); ++sg) {
+    cmSourceGroup* result = sg->MatchChildrenFiles(source);
+    if (result) {
       return result;
-      }
     }
+  }
 
   // Now search for a group whose regex matches the file.
-  for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
-      sg != groups.rend(); ++sg)
-    {
-    cmSourceGroup *result = sg->MatchChildrenRegex(source);
-    if(result)
-      {
+  for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
+       sg != groups.rend(); ++sg) {
+    cmSourceGroup* result = sg->MatchChildrenRegex(source);
+    if (result) {
       return result;
-      }
     }
-
+  }
 
   // Shouldn't get here, but just in case, return the default group.
   return &groups.front();
@@ -3240,63 +2761,57 @@ cmMakefile::FindSourceGroup(const char* source,
 #endif
 
 bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff,
-                                   cmExecutionStatus &status)
+                                   cmExecutionStatus& status)
 {
   // if there are no blockers get out of here
-  if (this->FunctionBlockers.begin() == this->FunctionBlockers.end())
-    {
+  if (this->FunctionBlockers.begin() == this->FunctionBlockers.end()) {
     return false;
-    }
+  }
 
   // loop over all function blockers to see if any block this command
   // evaluate in reverse, this is critical for balanced IF statements etc
   std::vector<cmFunctionBlocker*>::reverse_iterator pos;
   for (pos = this->FunctionBlockers.rbegin();
-       pos != this->FunctionBlockers.rend(); ++pos)
-    {
-    if((*pos)->IsFunctionBlocked(lff, *this, status))
-      {
+       pos != this->FunctionBlockers.rend(); ++pos) {
+    if ((*pos)->IsFunctionBlocked(lff, *this, status)) {
       return true;
-      }
     }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PushFunctionBlockerBarrier()
 {
   this->FunctionBlockerBarriers.push_back(this->FunctionBlockers.size());
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
 {
   // Remove any extra entries pushed on the barrier.
   FunctionBlockersType::size_type barrier =
     this->FunctionBlockerBarriers.back();
-  while(this->FunctionBlockers.size() > barrier)
-    {
+  while (this->FunctionBlockers.size() > barrier) {
     cmsys::auto_ptr<cmFunctionBlocker> fb(this->FunctionBlockers.back());
     this->FunctionBlockers.pop_back();
-    if(reportError)
-      {
+    if (reportError) {
       // Report the context in which the unclosed block was opened.
       cmListFileContext const& lfc = fb->GetStartingContext();
       std::ostringstream e;
+      /* clang-format off */
       e << "A logical block opening on the line\n"
         << "  " << lfc << "\n"
         << "is not closed.";
+      /* clang-format on */
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
       reportError = false;
-      }
     }
+  }
 
   // Remove the barrier.
   this->FunctionBlockerBarriers.pop_back();
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PushLoopBlock()
 {
   assert(!this->LoopBlockCounter.empty());
@@ -3334,142 +2849,122 @@ std::string cmMakefile::GetExecutionFilePath() const
   return this->StateSnapshot.GetExecutionListFile();
 }
 
-//----------------------------------------------------------------------------
-bool cmMakefile::ExpandArguments(
-  std::vector<cmListFileArgument> const& inArgs,
-  std::vector<std::string>& outArgs, const char* filename) const
+bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
+                                 std::vector<std::string>& outArgs,
+                                 const char* filename) const
 {
   std::string efp = this->GetExecutionFilePath();
-  if (!filename)
-    {
+  if (!filename) {
     filename = efp.c_str();
-    }
+  }
   std::vector<cmListFileArgument>::const_iterator i;
   std::string value;
   outArgs.reserve(inArgs.size());
-  for(i = inArgs.begin(); i != inArgs.end(); ++i)
-    {
+  for (i = inArgs.begin(); i != inArgs.end(); ++i) {
     // No expansion in a bracket argument.
-    if(i->Delim == cmListFileArgument::Bracket)
-      {
+    if (i->Delim == cmListFileArgument::Bracket) {
       outArgs.push_back(i->Value);
       continue;
-      }
+    }
     // Expand the variables in the argument.
     value = i->Value;
-    this->ExpandVariablesInString(value, false, false, false,
-                                  filename, i->Line, false, false);
+    this->ExpandVariablesInString(value, false, false, false, filename,
+                                  i->Line, false, false);
 
     // If the argument is quoted, it should be one argument.
     // Otherwise, it may be a list of arguments.
-    if(i->Delim == cmListFileArgument::Quoted)
-      {
+    if (i->Delim == cmListFileArgument::Quoted) {
       outArgs.push_back(value);
-      }
-    else
-      {
+    } else {
       cmSystemTools::ExpandListArgument(value, outArgs);
-      }
     }
+  }
   return !cmSystemTools::GetFatalErrorOccured();
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::ExpandArguments(
   std::vector<cmListFileArgument> const& inArgs,
   std::vector<cmExpandedCommandArgument>& outArgs, const char* filename) const
 {
   std::string efp = this->GetExecutionFilePath();
-  if (!filename)
-    {
+  if (!filename) {
     filename = efp.c_str();
-    }
+  }
   std::vector<cmListFileArgument>::const_iterator i;
   std::string value;
   outArgs.reserve(inArgs.size());
-  for(i = inArgs.begin(); i != inArgs.end(); ++i)
-    {
+  for (i = inArgs.begin(); i != inArgs.end(); ++i) {
     // No expansion in a bracket argument.
-    if(i->Delim == cmListFileArgument::Bracket)
-      {
+    if (i->Delim == cmListFileArgument::Bracket) {
       outArgs.push_back(cmExpandedCommandArgument(i->Value, true));
       continue;
-      }
+    }
     // Expand the variables in the argument.
     value = i->Value;
-    this->ExpandVariablesInString(value, false, false, false,
-                                  filename, i->Line, false, false);
+    this->ExpandVariablesInString(value, false, false, false, filename,
+                                  i->Line, false, false);
 
     // If the argument is quoted, it should be one argument.
     // Otherwise, it may be a list of arguments.
-    if(i->Delim == cmListFileArgument::Quoted)
-      {
+    if (i->Delim == cmListFileArgument::Quoted) {
       outArgs.push_back(cmExpandedCommandArgument(value, true));
-      }
-    else
-      {
+    } else {
       std::vector<std::string> stringArgs;
       cmSystemTools::ExpandListArgument(value, stringArgs);
-      for(size_t j = 0; j < stringArgs.size(); ++j)
-        {
+      for (size_t j = 0; j < stringArgs.size(); ++j) {
         outArgs.push_back(cmExpandedCommandArgument(stringArgs[j], false));
-        }
       }
     }
+  }
   return !cmSystemTools::GetFatalErrorOccured();
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
 {
-  if(!this->ExecutionStatusStack.empty())
-    {
+  if (!this->ExecutionStatusStack.empty()) {
     // Record the context in which the blocker is created.
     fb->SetStartingContext(this->GetExecutionContext());
-    }
+  }
 
   this->FunctionBlockers.push_back(fb);
 }
 
-cmsys::auto_ptr<cmFunctionBlocker>
-cmMakefile::RemoveFunctionBlocker(cmFunctionBlocker* fb,
-                                  const cmListFileFunction& lff)
+cmsys::auto_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
+  cmFunctionBlocker* fb, const cmListFileFunction& lff)
 {
   // Find the function blocker stack barrier for the current scope.
   // We only remove a blocker whose index is not less than the barrier.
   FunctionBlockersType::size_type barrier = 0;
-  if(!this->FunctionBlockerBarriers.empty())
-    {
+  if (!this->FunctionBlockerBarriers.empty()) {
     barrier = this->FunctionBlockerBarriers.back();
-    }
+  }
 
   // Search for the function blocker whose scope this command ends.
-  for(FunctionBlockersType::size_type
-        i = this->FunctionBlockers.size(); i > barrier; --i)
-    {
+  for (FunctionBlockersType::size_type i = this->FunctionBlockers.size();
+       i > barrier; --i) {
     std::vector<cmFunctionBlocker*>::iterator pos =
       this->FunctionBlockers.begin() + (i - 1);
-    if (*pos == fb)
-      {
+    if (*pos == fb) {
       // Warn if the arguments do not match, but always remove.
-      if(!(*pos)->ShouldRemove(lff, *this))
-        {
+      if (!(*pos)->ShouldRemove(lff, *this)) {
         cmListFileContext const& lfc = fb->GetStartingContext();
         cmListFileContext closingContext =
-            cmListFileContext::FromCommandContext(lff, lfc.FilePath);
+          cmListFileContext::FromCommandContext(lff, lfc.FilePath);
         std::ostringstream e;
+        /* clang-format off */
         e << "A logical block opening on the line\n"
           << "  " << lfc << "\n"
           << "closes on the line\n"
           << "  " << closingContext << "\n"
           << "with mis-matching arguments.";
+        /* clang-format on */
         this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
-        }
+      }
       cmFunctionBlocker* b = *pos;
       this->FunctionBlockers.erase(pos);
       return cmsys::auto_ptr<cmFunctionBlocker>(b);
-      }
     }
+  }
 
   return cmsys::auto_ptr<cmFunctionBlocker>();
 }
@@ -3494,63 +2989,53 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
   std::ostringstream strStream;
   strStream << args.size();
   this->AddDefinition("CMAKE_ARGC", strStream.str().c_str());
-  //this->MarkVariableAsUsed("CMAKE_ARGC");
+  // this->MarkVariableAsUsed("CMAKE_ARGC");
 
-  for (unsigned int t = 0; t < args.size(); ++t)
-  {
+  for (unsigned int t = 0; t < args.size(); ++t) {
     std::ostringstream tmpStream;
     tmpStream << "CMAKE_ARGV" << t;
     this->AddDefinition(tmpStream.str(), args[t].c_str());
-    //this->MarkVariableAsUsed(tmpStream.str().c_str());
+    // this->MarkVariableAsUsed(tmpStream.str().c_str());
   }
 }
 
-//----------------------------------------------------------------------------
 cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
 {
   cmSourceFileLocation sfl(this, sourceName);
-  for(std::vector<cmSourceFile*>::const_iterator
-        sfi = this->SourceFiles.begin();
-      sfi != this->SourceFiles.end(); ++sfi)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator sfi =
+         this->SourceFiles.begin();
+       sfi != this->SourceFiles.end(); ++sfi) {
     cmSourceFile* sf = *sfi;
-    if(sf->Matches(sfl))
-      {
+    if (sf->Matches(sfl)) {
       return sf;
-      }
     }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
                                        bool generated)
 {
   cmSourceFile* sf = new cmSourceFile(this, sourceName);
-  if(generated)
-    {
+  if (generated) {
     sf->SetProperty("GENERATED", "1");
-    }
+  }
   this->SourceFiles.push_back(sf);
   return sf;
 }
 
-//----------------------------------------------------------------------------
 cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
                                             bool generated)
 {
-  if(cmSourceFile* esf = this->GetSource(sourceName))
-    {
+  if (cmSourceFile* esf = this->GetSource(sourceName)) {
     return esf;
-    }
-  else
-    {
+  } else {
     return this->CreateSource(sourceName, generated);
-    }
+  }
 }
 
-void cmMakefile::EnableLanguage(std::vector<std::string> const &  lang,
-                               bool optional)
+void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
+                                bool optional)
 {
   this->AddDefinition("CMAKE_CFG_INTDIR",
                       this->GetGlobalGenerator()->GetCMakeCFGIntDir());
@@ -3560,17 +3045,15 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const &  lang,
 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,
+                           const std::string& targetName, bool fast,
+                           const std::vector<std::string>* cmakeArgs,
                            std::string& output)
 {
   this->IsSourceFileTryCompile = fast;
   // does the binary directory exist ? If not create it...
-  if (!cmSystemTools::FileIsDirectory(bindir))
-    {
+  if (!cmSystemTools::FileIsDirectory(bindir)) {
     cmSystemTools::MakeDirectory(bindir.c_str());
-    }
+  }
 
   // change to the tests directory and run cmake
   // use the cmake object instead of calling cmake
@@ -3582,17 +3065,16 @@ int cmMakefile::TryCompile(const std::string& srcdir,
   // be run that way but the cmake object requires a vailid path
   cmake cm;
   cm.SetIsInTryCompile(true);
-  cmGlobalGenerator *gg = cm.CreateGlobalGenerator
-    (this->GetGlobalGenerator()->GetName());
-  if (!gg)
-    {
+  cmGlobalGenerator* gg =
+    cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName());
+  if (!gg) {
     cmSystemTools::Error(
       "Internal CMake error, TryCompile bad GlobalGenerator");
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd);
     this->IsSourceFileTryCompile = false;
     return 1;
-    }
+  }
   cm.SetGlobalGenerator(gg);
 
   // do a configure
@@ -3601,21 +3083,18 @@ int cmMakefile::TryCompile(const std::string& srcdir,
   cm.SetGeneratorPlatform(this->GetCMakeInstance()->GetGeneratorPlatform());
   cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset());
   cm.LoadCache();
-  if(!gg->IsMultiConfig())
-    {
-    if(const char* config =
-       this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"))
-      {
+  if (!gg->IsMultiConfig()) {
+    if (const char* config =
+          this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) {
       // Tell the single-configuration generator which one to use.
       // Add this before the user-provided CMake arguments in case
       // one of the arguments is -DCMAKE_BUILD_TYPE=...
-      cm.AddCacheEntry("CMAKE_BUILD_TYPE", config,
-                       "Build configuration", cmState::STRING);
-      }
+      cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, "Build configuration",
+                       cmState::STRING);
     }
+  }
   // if cmake args were provided then pass them in
-  if (cmakeArgs)
-    {
+  if (cmakeArgs) {
     // FIXME: Workaround to ignore unused CLI variables in try-compile.
     //
     // Ideally we should use SetArgs to honor options like --warn-unused-vars.
@@ -3639,49 +3118,40 @@ int cmMakefile::TryCompile(const std::string& srcdir,
     // previously built.  Instead we work around the issue by never reporting
     // unused arguments and ignoring options such as --warn-unused-vars.
     cm.SetWarnUnusedCli(false);
-    //cm.SetArgs(*cmakeArgs, true);
+    // cm.SetArgs(*cmakeArgs, true);
 
     cm.SetCacheArgs(*cmakeArgs);
-    }
+  }
   // to save time we pass the EnableLanguage info directly
   gg->EnableLanguagesFromGenerator(this->GetGlobalGenerator(), this);
-  if(this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"))
-    {
-    cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS",
-                     "TRUE", "", cmState::INTERNAL);
-    }
-  else
-    {
-    cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS",
-                     "FALSE", "", cmState::INTERNAL);
-    }
-  if (cm.Configure() != 0)
-    {
+  if (this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
+    cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "",
+                     cmState::INTERNAL);
+  } else {
+    cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "",
+                     cmState::INTERNAL);
+  }
+  if (cm.Configure() != 0) {
     cmSystemTools::Error(
       "Internal CMake error, TryCompile configure of cmake failed");
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd);
     this->IsSourceFileTryCompile = false;
     return 1;
-    }
+  }
 
-  if (cm.Generate() != 0)
-    {
+  if (cm.Generate() != 0) {
     cmSystemTools::Error(
       "Internal CMake error, TryCompile generation of cmake failed");
     // return to the original directory
     cmSystemTools::ChangeDirectory(cwd);
     this->IsSourceFileTryCompile = false;
     return 1;
-    }
+  }
 
   // finally call the generator to actually build the resulting project
-  int ret = this->GetGlobalGenerator()->TryCompile(srcdir,bindir,
-                                                   projectName,
-                                                   targetName,
-                                                   fast,
-                                                   output,
-                                                   this);
+  int ret = this->GetGlobalGenerator()->TryCompile(
+    srcdir, bindir, projectName, targetName, fast, output, this);
 
   cmSystemTools::ChangeDirectory(cwd);
   this->IsSourceFileTryCompile = false;
@@ -3693,7 +3163,7 @@ bool cmMakefile::GetIsSourceFileTryCompile() const
   return this->IsSourceFileTryCompile;
 }
 
-cmake *cmMakefile::GetCMakeInstance() const
+cmake* cmMakefile::GetCMakeInstance() const
 {
   return this->GlobalGenerator->GetCMakeInstance();
 }
@@ -3704,18 +3174,17 @@ cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
 }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
-cmVariableWatch *cmMakefile::GetVariableWatch() const
+cmVariableWatch* cmMakefile::GetVariableWatch() const
 {
-  if ( this->GetCMakeInstance() &&
-       this->GetCMakeInstance()->GetVariableWatch() )
-    {
+  if (this->GetCMakeInstance() &&
+      this->GetCMakeInstance()->GetVariableWatch()) {
     return this->GetCMakeInstance()->GetVariableWatch();
-    }
+  }
   return 0;
 }
 #endif
 
-cmState *cmMakefile::GetState() const
+cmState* cmMakefile::GetState() const
 {
   return this->GetCMakeInstance()->GetState();
 }
@@ -3723,12 +3192,11 @@ cmState *cmMakefile::GetState() const
 void cmMakefile::DisplayStatus(const char* message, float s) const
 {
   cmake* cm = this->GetCMakeInstance();
-  if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE)
-    {
+  if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) {
     // don't output any STATUS message in FIND_PACKAGE_MODE, since they will
     // directly be fed to the compiler, which will be confused.
     return;
-    }
+  }
   cm->UpdateProgress(message, s);
 }
 
@@ -3751,69 +3219,58 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
 
   // Always search in CMAKE_MODULE_PATH:
   const char* cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH");
-  if(cmakeModulePath)
-    {
+  if (cmakeModulePath) {
     std::vector<std::string> modulePath;
     cmSystemTools::ExpandListArgument(cmakeModulePath, modulePath);
 
-    //Look through the possible module directories.
-    for(std::vector<std::string>::iterator i = modulePath.begin();
-        i != modulePath.end(); ++i)
-      {
+    // Look through the possible module directories.
+    for (std::vector<std::string>::iterator i = modulePath.begin();
+         i != modulePath.end(); ++i) {
       std::string itempl = *i;
       cmSystemTools::ConvertToUnixSlashes(itempl);
       itempl += "/";
       itempl += filename;
-      if(cmSystemTools::FileExists(itempl.c_str()))
-        {
+      if (cmSystemTools::FileExists(itempl.c_str())) {
         moduleInCMakeModulePath = itempl;
         break;
-        }
       }
     }
+  }
 
   // Always search in the standard modules location.
-  const char* cmakeRoot = this->GetDefinition("CMAKE_ROOT");
-  if(cmakeRoot)
-    {
-    moduleInCMakeRoot = cmakeRoot;
-    moduleInCMakeRoot += "/Modules/";
-    moduleInCMakeRoot += filename;
-    cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
-    if(!cmSystemTools::FileExists(moduleInCMakeRoot.c_str()))
-      {
-      moduleInCMakeRoot = "";
-      }
-    }
+  moduleInCMakeRoot = cmSystemTools::GetCMakeRoot();
+  moduleInCMakeRoot += "/Modules/";
+  moduleInCMakeRoot += filename;
+  cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
+  if (!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) {
+    moduleInCMakeRoot = "";
+  }
 
   // Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
   // from which we are being called is located itself in CMAKE_ROOT, then
   // prefer results from CMAKE_ROOT depending on the policy setting.
   result = moduleInCMakeModulePath;
-  if (result.empty())
-    {
+  if (result.empty()) {
     result = moduleInCMakeRoot;
-    }
+  }
 
-  if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty())
-    {
+  if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty()) {
     const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
-    std::string mods = cmakeRoot + std::string("/Modules/");
-    if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0)
-      {
-      switch (this->GetPolicyStatus(cmPolicies::CMP0017))
-        {
-        case cmPolicies::WARN:
-        {
+    std::string mods = cmSystemTools::GetCMakeRoot() + "/Modules/";
+    if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0) {
+      switch (this->GetPolicyStatus(cmPolicies::CMP0017)) {
+        case cmPolicies::WARN: {
           std::ostringstream e;
+          /* clang-format off */
           e << "File " << currentFile << " includes "
             << moduleInCMakeModulePath
             << " (found via CMAKE_MODULE_PATH) which shadows "
             << moduleInCMakeRoot  << ". This may cause errors later on .\n"
             << cmPolicies::GetPolicyWarning(cmPolicies::CMP0017);
+          /* clang-format on */
 
           this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
-           // break;  // fall through to OLD behaviour
+          // break;  // fall through to OLD behaviour
         }
         case cmPolicies::OLD:
           result = moduleInCMakeModulePath;
@@ -3823,87 +3280,69 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
         case cmPolicies::NEW:
           result = moduleInCMakeRoot;
           break;
-        }
       }
     }
+  }
 
   return result;
 }
 
-void cmMakefile::ConfigureString(const std::string& input,
-                                 std::string& output, bool atOnly,
-                                 bool escapeQuotes) const
+void cmMakefile::ConfigureString(const std::string& input, std::string& output,
+                                 bool atOnly, bool escapeQuotes) const
 {
   // Split input to handle one line at a time.
   std::string::const_iterator lineStart = input.begin();
-  while(lineStart != input.end())
-    {
+  while (lineStart != input.end()) {
     // Find the end of this line.
     std::string::const_iterator lineEnd = lineStart;
-    while(lineEnd != input.end() && *lineEnd != '\n')
-      {
+    while (lineEnd != input.end() && *lineEnd != '\n') {
       ++lineEnd;
-      }
+    }
 
     // Copy the line.
     std::string line(lineStart, lineEnd);
 
     // Skip the newline character.
     bool haveNewline = (lineEnd != input.end());
-    if(haveNewline)
-      {
+    if (haveNewline) {
       ++lineEnd;
-      }
+    }
 
     // Replace #cmakedefine instances.
-    if(this->cmDefineRegex.find(line))
-      {
-      const char* def =
-        this->GetDefinition(this->cmDefineRegex.match(1));
-      if(!cmSystemTools::IsOff(def))
-        {
+    if (this->cmDefineRegex.find(line)) {
+      const char* def = this->GetDefinition(this->cmDefineRegex.match(1));
+      if (!cmSystemTools::IsOff(def)) {
         cmSystemTools::ReplaceString(line, "#cmakedefine", "#define");
         output += line;
-        }
-      else
-        {
+      } else {
         output += "/* #undef ";
         output += this->cmDefineRegex.match(1);
         output += " */";
-        }
       }
-    else if(this->cmDefine01Regex.find(line))
-      {
-      const char* def =
-        this->GetDefinition(this->cmDefine01Regex.match(1));
+    } else if (this->cmDefine01Regex.find(line)) {
+      const char* def = this->GetDefinition(this->cmDefine01Regex.match(1));
       cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define");
       output += line;
-      if(!cmSystemTools::IsOff(def))
-        {
+      if (!cmSystemTools::IsOff(def)) {
         output += " 1";
-        }
-      else
-        {
+      } else {
         output += " 0";
-        }
       }
-    else
-      {
+    } else {
       output += line;
-      }
+    }
 
-    if(haveNewline)
-      {
+    if (haveNewline) {
       output += "\n";
-      }
+    }
 
     // Move to the next line.
     lineStart = lineEnd;
-    }
+  }
 
   // Perform variable replacements.
-  this->ExpandVariablesInString(output, escapeQuotes, true,
-                                atOnly, 0, -1, true, true);
+  this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, 0, -1,
+                                true, true);
 }
 
 int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
@@ -3911,114 +3350,94 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
                               const cmNewLineStyle& newLine)
 {
   int res = 1;
-  if ( !this->CanIWriteThisFile(outfile) )
-    {
-    cmSystemTools::Error("Attempt to write file: ",
-                         outfile, " into a source directory.");
+  if (!this->CanIWriteThisFile(outfile)) {
+    cmSystemTools::Error("Attempt to write file: ", outfile,
+                         " into a source directory.");
     return 0;
-    }
-  if ( !cmSystemTools::FileExists(infile) )
-    {
+  }
+  if (!cmSystemTools::FileExists(infile)) {
     cmSystemTools::Error("File ", infile, " does not exist.");
     return 0;
-    }
+  }
   std::string soutfile = outfile;
   std::string sinfile = infile;
   this->AddCMakeDependFile(sinfile);
   cmSystemTools::ConvertToUnixSlashes(soutfile);
 
   // Re-generate if non-temporary outputs are missing.
-  //when we finalize the configuration we will remove all
-  //output files that now don't exist.
+  // when we finalize the configuration we will remove all
+  // output files that now don't exist.
   this->AddCMakeOutputFile(soutfile);
 
   mode_t perm = 0;
   cmSystemTools::GetPermissions(sinfile.c_str(), perm);
   std::string::size_type pos = soutfile.rfind('/');
-  if(pos != std::string::npos)
-    {
+  if (pos != std::string::npos) {
     std::string path = soutfile.substr(0, pos);
     cmSystemTools::MakeDirectory(path.c_str());
-    }
+  }
 
-  if(copyonly)
-    {
-    if ( !cmSystemTools::CopyFileIfDifferent(sinfile.c_str(),
-                                             soutfile.c_str()))
-      {
+  if (copyonly) {
+    if (!cmSystemTools::CopyFileIfDifferent(sinfile.c_str(),
+                                            soutfile.c_str())) {
       return 0;
-      }
     }
-  else
-    {
+  } else {
     std::string newLineCharacters;
     std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc;
-    if (newLine.IsValid())
-      {
+    if (newLine.IsValid()) {
       newLineCharacters = newLine.GetCharacters();
       omode |= std::ios::binary;
-      }
-    else
-      {
+    } else {
       newLineCharacters = "\n";
-      }
+    }
     std::string tempOutputFile = soutfile;
     tempOutputFile += ".tmp";
     cmsys::ofstream fout(tempOutputFile.c_str(), omode);
-    if(!fout)
-      {
-      cmSystemTools::Error(
-        "Could not open file for write in copy operation ",
-        tempOutputFile.c_str());
+    if (!fout) {
+      cmSystemTools::Error("Could not open file for write in copy operation ",
+                           tempOutputFile.c_str());
       cmSystemTools::ReportLastSystemError("");
       return 0;
-      }
+    }
     cmsys::ifstream fin(sinfile.c_str());
-    if(!fin)
-      {
+    if (!fin) {
       cmSystemTools::Error("Could not open file for read in copy operation ",
                            sinfile.c_str());
       return 0;
-      }
+    }
 
     cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
-    if(bom != cmsys::FStream::BOM_None &&
-       bom != cmsys::FStream::BOM_UTF8)
-      {
+    if (bom != cmsys::FStream::BOM_None && bom != cmsys::FStream::BOM_UTF8) {
       std::ostringstream 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;
     std::string outLine;
-    while( cmSystemTools::GetLineFromStream(fin, inLine) )
-      {
+    while (cmSystemTools::GetLineFromStream(fin, inLine)) {
       outLine = "";
       this->ConfigureString(inLine, outLine, atOnly, escapeQuotes);
       fout << outLine.c_str() << newLineCharacters;
-      }
+    }
     // close the files before attempting to copy
     fin.close();
     fout.close();
-    if ( !cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
-                                             soutfile.c_str()) )
-      {
+    if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
+                                            soutfile.c_str())) {
       res = 0;
-      }
-    else
-      {
+    } else {
       cmSystemTools::SetPermissions(soutfile.c_str(), perm);
-      }
-    cmSystemTools::RemoveFile(tempOutputFile);
     }
+    cmSystemTools::RemoveFile(tempOutputFile);
+  }
   return res;
 }
 
@@ -4028,22 +3447,20 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
   this->StateSnapshot.GetDirectory().SetProperty(prop, value, lfbt);
 }
 
-void cmMakefile::AppendProperty(const std::string& prop,
-                                const char* value,
+void cmMakefile::AppendProperty(const std::string& prop, const char* value,
                                 bool asString)
 {
   cmListFileBacktrace lfbt = this->GetBacktrace();
-  this->StateSnapshot.GetDirectory().AppendProperty(prop, value,
-                                                    asString, lfbt);
+  this->StateSnapshot.GetDirectory().AppendProperty(prop, value, asString,
+                                                    lfbt);
 }
 
-const char *cmMakefile::GetProperty(const std::string& prop) const
+const char* cmMakefile::GetProperty(const std::string& prop) const
 {
   return this->StateSnapshot.GetDirectory().GetProperty(prop);
 }
 
-const char *cmMakefile::GetProperty(const std::string& prop,
-                                    bool chain) const
+const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const
 {
   return this->StateSnapshot.GetDirectory().GetProperty(prop, chain);
 }
@@ -4060,111 +3477,86 @@ std::vector<std::string> cmMakefile::GetPropertyKeys() const
 
 cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
 {
-  cmTargets::iterator i = this->Targets.find( name );
-  if ( i != this->Targets.end() )
-    {
+  cmTargets::iterator i = this->Targets.find(name);
+  if (i != this->Targets.end()) {
     return &i->second;
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 cmTest* cmMakefile::CreateTest(const std::string& testName)
 {
   cmTest* test = this->GetTest(testName);
-  if ( test )
-    {
+  if (test) {
     return test;
-    }
+  }
   test = new cmTest(this);
   test->SetName(testName);
   this->Tests[testName] = test;
   return test;
 }
 
-//----------------------------------------------------------------------------
 cmTest* cmMakefile::GetTest(const std::string& testName) const
 {
-  std::map<std::string, cmTest*>::const_iterator
-    mi = this->Tests.find(testName);
-  if(mi != this->Tests.end())
-    {
+  std::map<std::string, cmTest*>::const_iterator mi =
+    this->Tests.find(testName);
+  if (mi != this->Tests.end()) {
     return mi->second;
-    }
+  }
   return 0;
 }
 
 void cmMakefile::AddCMakeDependFilesFromUser()
 {
   std::vector<std::string> deps;
-  if(const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS"))
-    {
+  if (const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) {
     cmSystemTools::ExpandListArgument(deps_str, deps);
-    }
-  for(std::vector<std::string>::iterator i = deps.begin();
-      i != deps.end(); ++i)
-    {
-    if(cmSystemTools::FileIsFullPath(i->c_str()))
-      {
+  }
+  for (std::vector<std::string>::iterator i = deps.begin(); i != deps.end();
+       ++i) {
+    if (cmSystemTools::FileIsFullPath(i->c_str())) {
       this->AddCMakeDependFile(*i);
-      }
-    else
-      {
+    } else {
       std::string f = this->GetCurrentSourceDirectory();
       f += "/";
       f += *i;
       this->AddCMakeDependFile(f);
-      }
     }
+  }
 }
 
 std::string cmMakefile::FormatListFileStack() const
 {
   std::vector<std::string> listFiles;
   cmState::Snapshot snp = this->StateSnapshot;
-  while (snp.IsValid())
-    {
+  while (snp.IsValid()) {
     listFiles.push_back(snp.GetExecutionListFile());
     snp = snp.GetCallStackParent();
-    }
+  }
   std::reverse(listFiles.begin(), listFiles.end());
   std::ostringstream tmp;
   size_t depth = listFiles.size();
-  if (depth > 0)
-    {
+  if (depth > 0) {
     std::vector<std::string>::const_iterator it = listFiles.end();
-    do
-      {
-      if (depth != listFiles.size())
-        {
+    do {
+      if (depth != listFiles.size()) {
         tmp << "\n                ";
-        }
+      }
       --it;
       tmp << "[";
       tmp << depth;
       tmp << "]\t";
       tmp << *it;
       depth--;
-      }
-    while (it != listFiles.begin());
-    }
+    } while (it != listFiles.begin());
+  }
   return tmp.str();
 }
 
-
 void cmMakefile::PushScope()
 {
-  std::string commandName;
-  long line = 0;
-  if (!this->ContextStack.empty())
-    {
-    commandName = this->ContextStack.back()->Name;
-    line = this->ContextStack.back()->Line;
-    }
-  this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot(
-        this->StateSnapshot,
-        commandName,
-        line);
+  this->StateSnapshot =
+    this->GetState()->CreateVariableScopeSnapshot(this->StateSnapshot);
   this->PushLoopBlockBarrier();
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -4185,26 +3577,21 @@ void cmMakefile::PopScope()
   this->PopSnapshot();
 }
 
-void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
+void cmMakefile::RaiseScope(const std::string& var, const char* varDef)
 {
-  if (var.empty())
-    {
+  if (var.empty()) {
     return;
-    }
+  }
 
-  if (!this->StateSnapshot.RaiseScope(var, varDef))
-    {
+  if (!this->StateSnapshot.RaiseScope(var, varDef)) {
     std::ostringstream m;
     m << "Cannot set \"" << var << "\": current scope has no parent.";
     this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-cmTarget*
-cmMakefile::AddImportedTarget(const std::string& name,
-                              cmState::TargetType type,
-                              bool global)
+cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
+                                        cmState::TargetType type, bool global)
 {
   // Create the target.
   cmsys::auto_ptr<cmTarget> target(new cmTarget);
@@ -4221,30 +3608,25 @@ cmMakefile::AddImportedTarget(const std::string& name,
   return target.release();
 }
 
-//----------------------------------------------------------------------------
 cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
                                       bool excludeAliases) const
 {
   // Look for an imported target.  These take priority because they
   // are more local in scope and do not have to be globally unique.
-  TargetMap::const_iterator
-    imported = this->ImportedTargets.find(name);
-  if(imported != this->ImportedTargets.end())
-    {
+  TargetMap::const_iterator imported = this->ImportedTargets.find(name);
+  if (imported != this->ImportedTargets.end()) {
     return imported->second;
-    }
+  }
 
   // Look for a target built in this directory.
-  if(cmTarget* t = this->FindLocalNonAliasTarget(name))
-    {
+  if (cmTarget* t = this->FindLocalNonAliasTarget(name)) {
     return t;
-    }
+  }
 
   // Look for a target built in this project.
   return this->GetGlobalGenerator()->FindTarget(name, excludeAliases);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::IsAlias(const std::string& name) const
 {
   if (this->AliasTargets.find(name) != this->AliasTargets.end())
@@ -4252,24 +3634,20 @@ bool cmMakefile::IsAlias(const std::string& name) const
   return this->GetGlobalGenerator()->IsAlias(name);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
                                    bool isCustom) const
 {
-  if(this->IsAlias(name))
-    {
+  if (this->IsAlias(name)) {
     std::ostringstream e;
     e << "cannot create target \"" << name
       << "\" because an alias with the same name already exists.";
     msg = e.str();
     return false;
-    }
-  if(cmTarget* existing = this->FindTargetToUse(name))
-    {
+  }
+  if (cmTarget* existing = this->FindTargetToUse(name)) {
     // The name given conflicts with an existing target.  Produce an
     // error in a compatible way.
-    if(existing->IsImported())
-      {
+    if (existing->IsImported()) {
       // Imported targets were not supported in previous versions.
       // This is new code, so we can make it an error.
       std::ostringstream e;
@@ -4277,37 +3655,34 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
         << "\" because an imported target with the same name already exists.";
       msg = e.str();
       return false;
-      }
-    else
-      {
+    } else {
       // target names must be globally unique
-      switch (this->GetPolicyStatus(cmPolicies::CMP0002))
-        {
+      switch (this->GetPolicyStatus(cmPolicies::CMP0002)) {
         case cmPolicies::WARN:
-          this->IssueMessage(cmake::AUTHOR_WARNING, cmPolicies::
-                             GetPolicyWarning(cmPolicies::CMP0002));
+          this->IssueMessage(
+            cmake::AUTHOR_WARNING,
+            cmPolicies::GetPolicyWarning(cmPolicies::CMP0002));
         case cmPolicies::OLD:
           return true;
         case cmPolicies::REQUIRED_IF_USED:
         case cmPolicies::REQUIRED_ALWAYS:
-          this->IssueMessage(cmake::FATAL_ERROR,
-            cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002)
-            );
+          this->IssueMessage(
+            cmake::FATAL_ERROR,
+            cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002));
           return true;
         case cmPolicies::NEW:
           break;
-        }
+      }
 
       // The conflict is with a non-imported target.
       // Allow this if the user has requested support.
       cmake* cm = this->GetCMakeInstance();
-      if(isCustom && existing->GetType() == cmState::UTILITY &&
-         this != existing->GetMakefile() &&
-         cm->GetState()
-           ->GetGlobalPropertyAsBool("ALLOW_DUPLICATE_CUSTOM_TARGETS"))
-        {
+      if (isCustom && existing->GetType() == cmState::UTILITY &&
+          this != existing->GetMakefile() &&
+          cm->GetState()->GetGlobalPropertyAsBool(
+            "ALLOW_DUPLICATE_CUSTOM_TARGETS")) {
         return true;
-        }
+      }
 
       // Produce an error that tells the user how to work around the
       // problem.
@@ -4315,8 +3690,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
       e << "cannot create target \"" << name
         << "\" because another target with the same name already exists.  "
         << "The existing target is ";
-      switch(existing->GetType())
-        {
+      switch (existing->GetType()) {
         case cmState::EXECUTABLE:
           e << "an executable ";
           break;
@@ -4335,33 +3709,32 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
         case cmState::INTERFACE_LIBRARY:
           e << "an interface library ";
           break;
-        default: break;
-        }
+        default:
+          break;
+      }
       e << "created in source directory \""
         << existing->GetMakefile()->GetCurrentSourceDirectory() << "\".  "
         << "See documentation for policy CMP0002 for more details.";
       msg = e.str();
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
                                   const std::string& binPath) const
 {
   // Make sure the binary directory is unique.
   cmGlobalGenerator* gg = this->GetGlobalGenerator();
-  if(gg->BinaryDirectoryIsNew(binPath))
-    {
+  if (gg->BinaryDirectoryIsNew(binPath)) {
     return true;
-    }
+  }
   std::ostringstream e;
-  switch (this->GetPolicyStatus(cmPolicies::CMP0013))
-    {
+  switch (this->GetPolicyStatus(cmPolicies::CMP0013)) {
     case cmPolicies::WARN:
       // Print the warning.
+      /* clang-format off */
       e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0013)
         << "\n"
         << "The binary directory\n"
@@ -4373,95 +3746,81 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
         << "CMake does not support this use case but it used "
         << "to work accidentally and is being allowed for "
         << "compatibility.";
+      /* clang-format on */
       this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
     case cmPolicies::OLD:
       // OLD behavior does not warn.
       return true;
     case cmPolicies::REQUIRED_IF_USED:
     case cmPolicies::REQUIRED_ALWAYS:
-      e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0013)
-        << "\n";
+      e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0013) << "\n";
     case cmPolicies::NEW:
       // NEW behavior prints the error.
+      /* clang-format off */
       e << "The binary directory\n"
         << "  " << binPath << "\n"
         << "is already used to build a source directory.  "
         << "It cannot be used to build source directory\n"
         << "  " << srcPath << "\n"
         << "Specify a unique binary directory name.";
+      /* clang-format on */
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
       break;
-    }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
-void cmMakefile::AddQtUiFileWithOptions(cmSourceFile *sf)
+void cmMakefile::AddQtUiFileWithOptions(cmSourceFile* sf)
 {
   this->QtUiFilesWithOptions.push_back(sf);
 }
 
-//----------------------------------------------------------------------------
 std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
 {
   return this->QtUiFilesWithOptions;
 }
 
 static std::string const 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"
+  "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"
 };
 
 static std::string const nMatchesVariable = "CMAKE_MATCH_COUNT";
 
-//----------------------------------------------------------------------------
 void cmMakefile::ClearMatches()
 {
   const char* nMatchesStr = this->GetDefinition(nMatchesVariable);
-  if (!nMatchesStr)
-    {
+  if (!nMatchesStr) {
     return;
-    }
+  }
   int nMatches = atoi(nMatchesStr);
-  for (int i=0; i<=nMatches; i++)
-    {
+  for (int i = 0; i <= nMatches; i++) {
     std::string const& var = matchVariables[i];
     std::string const& s = this->GetSafeDefinition(var);
-    if(!s.empty())
-      {
+    if (!s.empty()) {
       this->AddDefinition(var, "");
       this->MarkVariableAsUsed(var);
-      }
     }
+  }
   this->AddDefinition(nMatchesVariable, "0");
   this->MarkVariableAsUsed(nMatchesVariable);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
 {
   char highest = 0;
-  for (int i=0; i<10; i++)
-    {
+  for (int i = 0; i < 10; i++) {
     std::string const& m = re.match(i);
-    if(!m.empty())
-      {
+    if (!m.empty()) {
       std::string const& var = matchVariables[i];
       this->AddDefinition(var, m.c_str());
       this->MarkVariableAsUsed(var);
       highest = static_cast<char>('0' + i);
-      }
     }
-  char nMatches[] = {highest, '\0'};
+  }
+  char nMatches[] = { highest, '\0' };
   this->AddDefinition(nMatchesVariable, nMatches);
   this->MarkVariableAsUsed(nMatchesVariable);
 }
@@ -4476,145 +3835,122 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const
   return this->DefineFlagsOrig.c_str();
 }
 
-//----------------------------------------------------------------------------
-cmPolicies::PolicyStatus
-cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
+cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(
+  cmPolicies::PolicyID id) const
 {
   return this->StateSnapshot.GetPolicy(id);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var)
 {
   // Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
-  if(!var.empty())
-    {
-    if(const char* val = this->GetDefinition(var))
-      {
+  if (!var.empty()) {
+    if (const char* val = this->GetDefinition(var)) {
       return cmSystemTools::IsOn(val);
-      }
     }
+  }
   // Enable optional policy warnings with --debug-output, --trace,
   // or --trace-expand.
   cmake* cm = this->GetCMakeInstance();
   return cm->GetDebugOutput() || cm->GetTrace();
 }
 
-bool cmMakefile::SetPolicy(const char *id,
-                           cmPolicies::PolicyStatus status)
+bool cmMakefile::SetPolicy(const char* id, cmPolicies::PolicyStatus status)
 {
   cmPolicies::PolicyID pid;
-  if (!cmPolicies::GetPolicyID(id, /* out */ pid))
-    {
+  if (!cmPolicies::GetPolicyID(id, /* out */ pid)) {
     std::ostringstream e;
     e << "Policy \"" << id << "\" is not known to this version of CMake.";
     this->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
-  return this->SetPolicy(pid,status);
+  }
+  return this->SetPolicy(pid, status);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
                            cmPolicies::PolicyStatus status)
 {
   // A REQUIRED_ALWAYS policy may be set only to NEW.
-  if(status != cmPolicies::NEW &&
-     cmPolicies::GetPolicyStatus(id) ==
-     cmPolicies::REQUIRED_ALWAYS)
-    {
-    std::string msg =
-      cmPolicies::GetRequiredAlwaysPolicyError(id);
+  if (status != cmPolicies::NEW &&
+      cmPolicies::GetPolicyStatus(id) == cmPolicies::REQUIRED_ALWAYS) {
+    std::string msg = cmPolicies::GetRequiredAlwaysPolicyError(id);
     this->IssueMessage(cmake::FATAL_ERROR, msg);
     return false;
-    }
+  }
 
   this->StateSnapshot.SetPolicy(id, status);
   return true;
 }
 
-//----------------------------------------------------------------------------
-cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m): Makefile(m)
+cmMakefile::PolicyPushPop::PolicyPushPop(cmMakefile* m)
+  : Makefile(m)
 {
   this->Makefile->PushPolicy();
 }
 
-//----------------------------------------------------------------------------
 cmMakefile::PolicyPushPop::~PolicyPushPop()
 {
   this->Makefile->PopPolicy();
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm)
 {
   this->StateSnapshot.PushPolicy(pm, weak);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PopPolicy()
 {
-  if (!this->StateSnapshot.PopPolicy())
-    {
+  if (!this->StateSnapshot.PopPolicy()) {
     this->IssueMessage(cmake::FATAL_ERROR,
                        "cmake_policy POP without matching PUSH");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::PopSnapshot(bool reportError)
 {
   // cmState::Snapshot manages nested policy scopes within it.
   // Since the scope corresponding to the snapshot is closing,
   // reject any still-open nested policy scopes with an error.
-  while (!this->StateSnapshot.CanPopPolicyScope())
-    {
-    if(reportError)
-      {
+  while (!this->StateSnapshot.CanPopPolicyScope()) {
+    if (reportError) {
       this->IssueMessage(cmake::FATAL_ERROR,
                          "cmake_policy PUSH without matching POP");
       reportError = false;
-      }
-    this->PopPolicy();
     }
+    this->PopPolicy();
+  }
 
   this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot);
   assert(this->StateSnapshot.IsValid());
 }
 
-//----------------------------------------------------------------------------
-bool cmMakefile::SetPolicyVersion(const char *version)
+bool cmMakefile::SetPolicyVersion(const char* version)
 {
-  return cmPolicies::ApplyPolicyVersion(this,version);
+  return cmPolicies::ApplyPolicyVersion(this, version);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::HasCMP0054AlreadyBeenReported(
-    cmListFileContext const& context) const
+  cmListFileContext const& context) const
 {
   return !this->CMP0054ReportedIds.insert(context).second;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
 {
   /* Record the setting of every policy.  */
   typedef cmPolicies::PolicyID PolicyID;
-  for(PolicyID pid = cmPolicies::CMP0000;
-      pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid+1))
-    {
+  for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
+       pid = PolicyID(pid + 1)) {
     pm.Set(pid, this->GetPolicyStatus(pid));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::IgnoreErrorsCMP0061() const
 {
   bool ignoreErrors = true;
-  switch (this->GetPolicyStatus(cmPolicies::CMP0061))
-    {
+  switch (this->GetPolicyStatus(cmPolicies::CMP0061)) {
     case cmPolicies::WARN:
-      // No warning for this policy!
+    // No warning for this policy!
     case cmPolicies::OLD:
       break;
     case cmPolicies::REQUIRED_IF_USED:
@@ -4622,195 +3958,155 @@ bool cmMakefile::IgnoreErrorsCMP0061() const
     case cmPolicies::NEW:
       ignoreErrors = false;
       break;
-    }
+  }
   return ignoreErrors;
 }
 
-//----------------------------------------------------------------------------
 #define FEATURE_STRING(F) , #F
-static const char * const C_FEATURES[] = {
-  0
-  FOR_EACH_C_FEATURE(FEATURE_STRING)
-};
+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)
-};
+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"
-};
+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
+bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
+                                          const std::string& feature,
+                                          std::string* error) const
 {
-  if (cmGeneratorExpression::Find(feature) != std::string::npos)
-    {
+  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))
-    {
+  if (!this->CompileFeatureKnown(target, feature, lang, error)) {
     return false;
-    }
+  }
 
   const char* features = this->CompileFeaturesAvailable(lang, error);
-  if (!features)
-    {
+  if (!features) {
     return false;
-    }
+  }
 
   std::vector<std::string> availableFeatures;
   cmSystemTools::ExpandListArgument(features, availableFeatures);
-  if (std::find(availableFeatures.begin(),
-                availableFeatures.end(),
-                feature) == availableFeatures.end())
-    {
+  if (std::find(availableFeatures.begin(), availableFeatures.end(), feature) ==
+      availableFeatures.end()) {
     std::ostringstream e;
-    e << "The compiler feature \"" << feature
-      << "\" is not known to " << lang << " compiler\n\""
+    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);
+  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
+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)
-    {
+  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)
-    {
+  }
+  bool isCxxFeature =
+    std::find_if(cmArrayBegin(CXX_FEATURES) + 1, cmArrayEnd(CXX_FEATURES),
+                 cmStrCmp(feature)) != cmArrayEnd(CXX_FEATURES);
+  if (isCxxFeature) {
     lang = "CXX";
     return true;
-    }
+  }
   std::ostringstream e;
-  if (error)
-    {
+  if (error) {
     e << "specified";
-    }
-  else
-    {
+  } else {
     e << "Specified";
-    }
+  }
   e << " unknown feature \"" << feature << "\" for "
-    "target \"" << target->GetName() << "\".";
-  if (error)
-    {
+                                           "target \""
+    << target->GetName() << "\".";
+  if (error) {
     *error = e.str();
-    }
-  else
-    {
+  } else {
     this->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
-const char* cmMakefile::
-CompileFeaturesAvailable(const std::string& lang, std::string *error) const
+const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang,
+                                                 std::string* error) const
 {
   const char* featuresKnown =
     this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
 
-  if (!featuresKnown || !*featuresKnown)
-    {
+  if (!featuresKnown || !*featuresKnown) {
     std::ostringstream e;
-    if (error)
-      {
+    if (error) {
       e << "no";
-      }
-    else
-      {
+    } 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)
-      {
+    if (error) {
       *error = e.str();
-      }
-    else
-      {
+    } else {
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
-      }
-    return 0;
     }
+    return 0;
+  }
   return featuresKnown;
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::HaveStandardAvailable(cmTarget const* target,
-                                      std::string const& lang,
-                                      const std::string& feature) const
+                                       std::string const& lang,
+                                       const std::string& feature) const
 {
-  return lang == "C"
-      ? this->HaveCStandardAvailable(target, feature)
-      : this->HaveCxxStandardAvailable(target, feature);
+  return lang == "C" ? this->HaveCStandardAvailable(target, feature)
+                     : this->HaveCxxStandardAvailable(target, feature);
 }
 
-//----------------------------------------------------------------------------
-bool cmMakefile::
-HaveCStandardAvailable(cmTarget const* target,
-                       const std::string& feature) const
+bool cmMakefile::HaveCStandardAvailable(cmTarget const* target,
+                                        const std::string& feature) const
 {
   const char* defaultCStandard =
     this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
-  if (!defaultCStandard)
-    {
+  if (!defaultCStandard) {
     std::ostringstream e;
     e << "CMAKE_C_STANDARD_DEFAULT is not set.  COMPILE_FEATURES support "
-      "not fully configured for this compiler.";
+         "not fully configured for this compiler.";
     this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
     // Return true so the caller does not try to lookup the default standard.
     return true;
-    }
+  }
   if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
-                cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS))
-    {
+                   cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS)) {
     std::ostringstream e;
     e << "The CMAKE_C_STANDARD_DEFAULT variable contains an "
-         "invalid value: \"" << defaultCStandard << "\".";
+         "invalid value: \""
+      << defaultCStandard << "\".";
     this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
     return false;
-    }
+  }
 
   bool needC90 = false;
   bool needC99 = false;
@@ -4818,175 +4114,150 @@ HaveCStandardAvailable(cmTarget const* target,
 
   this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
 
-  const char *existingCStandard = target->GetProperty("C_STANDARD");
-  if (!existingCStandard)
-    {
+  const char* existingCStandard = target->GetProperty("C_STANDARD");
+  if (!existingCStandard) {
     existingCStandard = defaultCStandard;
-    }
+  }
 
   if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
-                cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS))
-    {
+                   cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS)) {
     std::ostringstream e;
     e << "The C_STANDARD property on target \"" << target->GetName()
       << "\" contained an invalid value: \"" << existingCStandard << "\".";
     this->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
 
-  const char * const *existingCIt = existingCStandard
-                                    ? std::find_if(cmArrayBegin(C_STANDARDS),
-                                      cmArrayEnd(C_STANDARDS),
-                                      cmStrCmp(existingCStandard))
-                                    : cmArrayEnd(C_STANDARDS);
+  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")))
-    {
+  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")))
-    {
+  } 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")))
-    {
+  } 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));
+  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(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);
+  return std::find_if(rhsIt, cmArrayEnd(CXX_STANDARDS), cmStrCmp(lhs)) !=
+    cmArrayEnd(CXX_STANDARDS);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
-                                         const std::string& feature) const
+                                          const std::string& feature) const
 {
   const char* defaultCxxStandard =
     this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
-  if (!defaultCxxStandard)
-    {
+  if (!defaultCxxStandard) {
     std::ostringstream e;
     e << "CMAKE_CXX_STANDARD_DEFAULT is not set.  COMPILE_FEATURES support "
-      "not fully configured for this compiler.";
+         "not fully configured for this compiler.";
     this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
     // Return true so the caller does not try to lookup the default standard.
     return true;
-    }
+  }
   if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
-                cmStrCmp(defaultCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
-    {
+                   cmStrCmp(defaultCxxStandard)) ==
+      cmArrayEnd(CXX_STANDARDS)) {
     std::ostringstream e;
     e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an "
-         "invalid value: \"" << defaultCxxStandard << "\".";
+         "invalid value: \""
+      << defaultCxxStandard << "\".";
     this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
     return false;
-    }
+  }
 
   bool needCxx98 = false;
   bool needCxx11 = false;
   bool needCxx14 = false;
   this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14);
 
-  const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
-  if (!existingCxxStandard)
-    {
+  const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
+  if (!existingCxxStandard) {
     existingCxxStandard = defaultCxxStandard;
-    }
+  }
 
   if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
-                cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
-    {
+                   cmStrCmp(existingCxxStandard)) ==
+      cmArrayEnd(CXX_STANDARDS)) {
     std::ostringstream 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);
+  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")))
-    {
+  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")))
-    {
+  } 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& needCxx98, bool& needCxx11,
                                         bool& needCxx14) const
 {
-  if (const char *propCxx98 =
-          this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES"))
-    {
+  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"))
-    {
+  }
+  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"))
-    {
+  }
+  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 cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target,
+                                             const std::string& feature) const
 {
   bool needCxx98 = false;
   bool needCxx11 = false;
@@ -4994,98 +4265,80 @@ AddRequiredTargetCxxFeature(cmTarget *target,
 
   this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14);
 
-  const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
-  if (existingCxxStandard)
-    {
+  const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
+  if (existingCxxStandard) {
     if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
-                  cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
-      {
+                     cmStrCmp(existingCxxStandard)) ==
+        cmArrayEnd(CXX_STANDARDS)) {
       std::ostringstream 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);
+  }
+  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")))
-    {
+  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")))
-    {
+  } 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")))
-    {
+  } else if (needCxx98 && existingCxxStandard &&
+             existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                          cmArrayEnd(CXX_STANDARDS),
+                                          cmStrCmp("98"))) {
     setCxx98 = true;
-    }
+  }
 
-  if (setCxx14)
-    {
+  if (setCxx14) {
     target->SetProperty("CXX_STANDARD", "14");
-    }
-  else if (setCxx11)
-    {
+  } else if (setCxx11) {
     target->SetProperty("CXX_STANDARD", "11");
-    }
-  else if (setCxx98)
-    {
+  } else if (setCxx98) {
     target->SetProperty("CXX_STANDARD", "98");
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefile::CheckNeededCLanguage(const std::string& feature,
-                                        bool& needC90,
-                                        bool& needC99,
-                                        bool& needC11) const
+                                      bool& needC90, bool& needC99,
+                                      bool& needC11) const
 {
-  if (const char *propC90 =
-          this->GetDefinition("CMAKE_C90_COMPILE_FEATURES"))
-    {
+  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"))
-    {
+  }
+  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"))
-    {
+  }
+  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 cmMakefile::AddRequiredTargetCFeature(cmTarget* target,
+                                           const std::string& feature) const
 {
   bool needC90 = false;
   bool needC99 = false;
@@ -5093,71 +4346,57 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
 
   this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
 
-  const char *existingCStandard = target->GetProperty("C_STANDARD");
-  if (existingCStandard)
-    {
+  const char* existingCStandard = target->GetProperty("C_STANDARD");
+  if (existingCStandard) {
     if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
-                  cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS))
-      {
+                     cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS)) {
       std::ostringstream e;
       e << "The C_STANDARD property on target \"" << target->GetName()
         << "\" contained an invalid value: \"" << existingCStandard << "\".";
       this->IssueMessage(cmake::FATAL_ERROR, e.str());
       return false;
-      }
     }
-  const char * const *existingCIt = existingCStandard
-                                    ? std::find_if(cmArrayBegin(C_STANDARDS),
-                                      cmArrayEnd(C_STANDARDS),
-                                      cmStrCmp(existingCStandard))
-                                    : cmArrayEnd(C_STANDARDS);
+  }
+  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")))
-    {
+  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")))
-    {
+  } 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")))
-    {
+  } else if (needC90 && existingCStandard &&
+             existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
+                                        cmArrayEnd(C_STANDARDS),
+                                        cmStrCmp("90"))) {
     setC90 = true;
-    }
+  }
 
-  if (setC11)
-    {
+  if (setC11) {
     target->SetProperty("C_STANDARD", "11");
-    }
-  else if (setC99)
-    {
+  } else if (setC99) {
     target->SetProperty("C_STANDARD", "99");
-    }
-  else if (setC90)
-    {
+  } else if (setC90) {
     target->SetProperty("C_STANDARD", "90");
-    }
+  }
   return true;
 }
 
-
 cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf,
                                              const std::string& fileName,
                                              cmPolicies::PolicyMap const& pm)
-  : Makefile(mf), ReportError(true)
+  : Makefile(mf)
+  , ReportError(true)
 {
   this->Makefile->PushFunctionScope(fileName, pm);
 }
@@ -5167,11 +4406,11 @@ cmMakefile::FunctionPushPop::~FunctionPushPop()
   this->Makefile->PopFunctionScope(this->ReportError);
 }
 
-
 cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf,
                                        const std::string& fileName,
                                        const cmPolicies::PolicyMap& pm)
-  : Makefile(mf), ReportError(true)
+  : Makefile(mf)
+  , ReportError(true)
 {
   this->Makefile->PushMacroScope(fileName, pm);
 }
@@ -5180,16 +4419,3 @@ cmMakefile::MacroPushPop::~MacroPushPop()
 {
   this->Makefile->PopMacroScope(this->ReportError);
 }
-
-cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc,
-                               cmExecutionStatus& status): Makefile(mf)
-{
-  this->Makefile->ContextStack.push_back(&lfc);
-  this->Makefile->ExecutionStatusStack.push_back(&status);
-}
-
-cmMakefileCall::~cmMakefileCall()
-{
-  this->Makefile->ExecutionStatusStack.pop_back();
-  this->Makefile->ContextStack.pop_back();
-}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 45f2efb..c665b1f 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -12,28 +12,30 @@
 #ifndef cmMakefile_h
 #define cmMakefile_h
 
+#include "cmStandardIncludes.h"
+
+#include "cmAlgorithms.h"
 #include "cmExecutionStatus.h"
+#include "cmExpandedCommandArgument.h"
 #include "cmListFileCache.h"
+#include "cmNewLineStyle.h"
+#include "cmState.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
-#include "cmNewLineStyle.h"
-#include "cmExpandedCommandArgument.h"
 #include "cmake.h"
-#include "cmState.h"
-#include "cmAlgorithms.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cmSourceGroup.h"
 #endif
 
-#include <cmsys/auto_ptr.hxx>
 #include <cmsys/RegularExpression.hxx>
+#include <cmsys/auto_ptr.hxx>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
-#  include <unordered_map>
-# else
-#  include <cmsys/hash_map.hxx>
-# endif
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
+#include <cmsys/hash_map.hxx>
+#endif
 #endif
 
 #include <stack>
@@ -64,7 +66,7 @@ public:
   /* Mark a variable as used */
   void MarkVariableAsUsed(const std::string& var);
   /* return true if a variable has been initialized */
-  bool VariableInitialized(const std::string& ) const;
+  bool VariableInitialized(const std::string&) const;
 
   /**
    * Construct an empty makefile.
@@ -95,8 +97,8 @@ public:
    * Remove the function blocker whose scope ends with the given command.
    * This returns ownership of the function blocker object.
    */
-  cmsys::auto_ptr<cmFunctionBlocker>
-  RemoveFunctionBlocker(cmFunctionBlocker* fb, const cmListFileFunction& lff);
+  cmsys::auto_ptr<cmFunctionBlocker> RemoveFunctionBlocker(
+    cmFunctionBlocker* fb, const cmListFileFunction& lff);
 
   /**
    * Try running cmake and building a file. This is used for dynalically
@@ -104,8 +106,7 @@ public:
    */
   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,
+                 bool fast, const std::vector<std::string>* cmakeArgs,
                  std::string& output);
 
   bool GetIsSourceFileTryCompile() const;
@@ -141,19 +142,14 @@ public:
     const std::vector<std::string>& byproducts,
     const std::vector<std::string>& depends,
     const std::string& main_dependency,
-    const cmCustomCommandLines& commandLines,
-    const char* comment, const char* workingDir,
-    bool replace = false,
-    bool escapeOldStyle = true,
+    const cmCustomCommandLines& commandLines, const char* comment,
+    const char* workingDir, bool replace = false, bool escapeOldStyle = true,
     bool uses_terminal = false);
   cmSourceFile* AddCustomCommandToOutput(
-    const std::string& output,
-    const std::vector<std::string>& depends,
+    const std::string& output, const std::vector<std::string>& depends,
     const std::string& main_dependency,
-    const cmCustomCommandLines& commandLines,
-    const char* comment, const char* workingDir,
-    bool replace = false,
-    bool escapeOldStyle = true,
+    const cmCustomCommandLines& commandLines, const char* comment,
+    const char* workingDir, bool replace = false, bool escapeOldStyle = true,
     bool uses_terminal = false);
   void AddCustomCommandOldStyle(const std::string& target,
                                 const std::vector<std::string>& outputs,
@@ -171,16 +167,15 @@ public:
 
   /** Create a new imported target with the name and type given.  */
   cmTarget* AddImportedTarget(const std::string& name,
-                              cmState::TargetType type,
-                              bool global);
+                              cmState::TargetType type, bool global);
 
   cmTarget* AddNewTarget(cmState::TargetType type, const std::string& name);
 
   /**
    * Add an executable to the build.
    */
-  cmTarget* AddExecutable(const char *exename,
-                          const std::vector<std::string> &srcs,
+  cmTarget* AddExecutable(const char* exename,
+                          const std::vector<std::string>& srcs,
                           bool excludeFromAll = false);
 
   /**
@@ -191,28 +186,20 @@ public:
                               bool excludeFromAll,
                               const std::vector<std::string>& depends,
                               const char* workingDirectory,
-                              const char* command,
-                              const char* arg1=0,
-                              const char* arg2=0,
-                              const char* arg3=0,
-                              const char* arg4=0);
-  cmTarget* AddUtilityCommand(const std::string& utilityName,
-                              bool excludeFromAll,
-                              const char* workingDirectory,
-                              const std::vector<std::string>& depends,
-                              const cmCustomCommandLines& commandLines,
-                              bool escapeOldStyle = true,
-                              const char* comment = 0,
-                              bool uses_terminal = false);
-  cmTarget* AddUtilityCommand(const std::string& utilityName,
-                              bool excludeFromAll,
-                              const char* workingDirectory,
-                              const std::vector<std::string>& byproducts,
-                              const std::vector<std::string>& depends,
-                              const cmCustomCommandLines& commandLines,
-                              bool escapeOldStyle = true,
-                              const char* comment = 0,
-                              bool uses_terminal = false);
+                              const char* command, const char* arg1 = 0,
+                              const char* arg2 = 0, const char* arg3 = 0,
+                              const char* arg4 = 0);
+  cmTarget* AddUtilityCommand(
+    const std::string& utilityName, bool excludeFromAll,
+    const char* workingDirectory, const std::vector<std::string>& depends,
+    const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
+    const char* comment = 0, bool uses_terminal = false);
+  cmTarget* AddUtilityCommand(
+    const std::string& utilityName, bool excludeFromAll,
+    const char* workingDirectory, const std::vector<std::string>& byproducts,
+    const std::vector<std::string>& depends,
+    const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
+    const char* comment = 0, bool uses_terminal = false);
 
   /**
    * Add a link library to the build.
@@ -227,8 +214,7 @@ public:
    * Add a subdirectory to the build.
    */
   void AddSubDirectory(const std::string& fullSrcDir,
-                       const std::string& fullBinDir,
-                       bool excludeFromAll,
+                       const std::string& fullBinDir, bool excludeFromAll,
                        bool immediate);
 
   void Configure();
@@ -241,7 +227,7 @@ public:
   /**
    * Add an include directory to the build.
    */
-  void AddIncludeDirectories(const std::vector<std::string> &incs,
+  void AddIncludeDirectories(const std::vector<std::string>& incs,
                              bool before = false);
 
   /**
@@ -251,8 +237,7 @@ public:
   void AddDefinition(const std::string& name, const char* value);
   ///! Add a definition to this makefile and the global cmake cache.
   void AddCacheDefinition(const std::string& name, const char* value,
-                          const char* doc,
-                          cmState::CacheEntryType type,
+                          const char* doc, cmState::CacheEntryType type,
                           bool force = false);
 
   /**
@@ -281,22 +266,22 @@ public:
    * Set the name of the library.
    */
   cmTarget* AddLibrary(const std::string& libname, cmState::TargetType type,
-                  const std::vector<std::string> &srcs,
-                  bool excludeFromAll = false);
+                       const std::vector<std::string>& srcs,
+                       bool excludeFromAll = false);
   void AddAlias(const std::string& libname, const std::string& tgt);
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**
    * Add a root source group for consideration when adding a new source.
    */
-  void AddSourceGroup(const std::string& 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.
    * name is tokenized.
    */
   void AddSourceGroup(const std::vector<std::string>& name,
-                      const char* regex=0);
+                      const char* regex = 0);
 
 #endif
 
@@ -305,9 +290,9 @@ public:
      * Set, Push, Pop policy values for CMake.
      */
   bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
-  bool SetPolicy(const char *id, cmPolicies::PolicyStatus status);
+  bool SetPolicy(const char* id, cmPolicies::PolicyStatus status);
   cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const;
-  bool SetPolicyVersion(const char *version);
+  bool SetPolicyVersion(const char* version);
   void RecordPolicies(cmPolicies::PolicyMap& pm);
   //@}
 
@@ -317,6 +302,7 @@ public:
   public:
     PolicyPushPop(cmMakefile* m);
     ~PolicyPushPop();
+
   private:
     cmMakefile* Makefile;
   };
@@ -326,7 +312,7 @@ public:
    * Determine if the given context, name pair has already been reported
    * in context of CMP0054.
    */
-  bool HasCMP0054AlreadyBeenReported(const cmListFileContext &context) const;
+  bool HasCMP0054AlreadyBeenReported(const cmListFileContext& context) const;
 
   bool IgnoreErrorsCMP0061() const;
 
@@ -353,39 +339,39 @@ public:
    * in order to be considered as part of the depend information.
    */
   void SetIncludeRegularExpression(const char* regex)
-    {
-      this->SetProperty("INCLUDE_REGULAR_EXPRESSION", regex);
-    }
+  {
+    this->SetProperty("INCLUDE_REGULAR_EXPRESSION", regex);
+  }
   const char* GetIncludeRegularExpression() const
-    {
-      return this->GetProperty("INCLUDE_REGULAR_EXPRESSION");
-    }
+  {
+    return this->GetProperty("INCLUDE_REGULAR_EXPRESSION");
+  }
 
   /**
    * Set a regular expression that include files that are not found
    * must match in order to be considered a problem.
    */
   void SetComplainRegularExpression(const std::string& regex)
-    {
-      this->ComplainFileRegularExpression = regex;
-    }
+  {
+    this->ComplainFileRegularExpression = regex;
+  }
   const char* GetComplainRegularExpression() const
-    {
-      return this->ComplainFileRegularExpression.c_str();
-    }
+  {
+    return this->ComplainFileRegularExpression.c_str();
+  }
 
   /**
    * Get the list of targets
    */
-  cmTargets &GetTargets() { return this->Targets; }
+  cmTargets& GetTargets() { return this->Targets; }
   /**
    * Get the list of targets, const version
    */
-  const cmTargets &GetTargets() const { return this->Targets; }
-  const std::vector<cmTarget*> &GetOwnedImportedTargets() const
-    {
-      return this->ImportedTargetsOwned;
-    }
+  const cmTargets& GetTargets() const { return this->Targets; }
+  const std::vector<cmTarget*>& GetOwnedImportedTargets() const
+  {
+    return this->ImportedTargetsOwned;
+  }
   std::vector<cmTarget*> GetImportedTargets() const;
 
   cmTarget* FindLocalNonAliasTarget(const std::string& name) const;
@@ -404,7 +390,7 @@ public:
   /**
    * Mark include directories as system directories.
    */
-  void AddSystemIncludeDirectories(const std::set<std::string> &incs);
+  void AddSystemIncludeDirectories(const std::set<std::string>& incs);
 
   /** Get a cmSourceFile pointer for a given source name, if the name is
    *  not found, then a null pointer is returned.
@@ -463,8 +449,7 @@ public:
   /**
    * Get a list of preprocessor define flags.
    */
-  const char* GetDefineFlags() const
-    {return this->DefineFlags.c_str();}
+  const char* GetDefineFlags() const { return this->DefineFlags.c_str(); }
 
   /**
    * Make sure CMake can write this file
@@ -476,22 +461,28 @@ public:
    * Get the vector source groups.
    */
   const std::vector<cmSourceGroup>& GetSourceGroups() const
-    { return this->SourceGroups; }
+  {
+    return this->SourceGroups;
+  }
 
   /**
    * Get the source group
    */
-  cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name) const;
+  cmSourceGroup* GetSourceGroup(const std::vector<std::string>& name) const;
 #endif
 
   /**
    * Get the vector of list files on which this makefile depends
    */
   const std::vector<std::string>& GetListFiles() const
-    { return this->ListFiles; }
+  {
+    return this->ListFiles;
+  }
   ///! When the file changes cmake will be re-run from the build system.
   void AddCMakeDependFile(const std::string& file)
-    { this->ListFiles.push_back(file);}
+  {
+    this->ListFiles.push_back(file);
+  }
   void AddCMakeDependFilesFromUser();
 
   std::string FormatListFileStack() const;
@@ -507,9 +498,13 @@ public:
    * Get the vector of  files created by this makefile
    */
   const std::vector<std::string>& GetOutputFiles() const
-    { return this->OutputFiles; }
+  {
+    return this->OutputFiles;
+  }
   void AddCMakeOutputFile(const std::string& file)
-    { this->OutputFiles.push_back(file);}
+  {
+    this->OutputFiles.push_back(file);
+  }
 
   /**
    * Expand all defined variables in the string.
@@ -518,12 +513,10 @@ public:
    * entry in the this->Definitions map.  Also \@var\@ is
    * expanded to match autoconf style expansions.
    */
-  const char *ExpandVariablesInString(std::string& source) const;
-  const char *ExpandVariablesInString(std::string& source, bool escapeQuotes,
-                                      bool noEscapes,
-                                      bool atOnly = false,
-                                      const char* filename = 0,
-                                      long line = -1,
+  const char* ExpandVariablesInString(std::string& source) const;
+  const char* ExpandVariablesInString(std::string& source, bool escapeQuotes,
+                                      bool noEscapes, bool atOnly = false,
+                                      const char* filename = 0, long line = -1,
                                       bool removeEmpty = false,
                                       bool replaceAt = false) const;
 
@@ -531,8 +524,7 @@ public:
    * Remove any remaining variables in the string. Anything with ${var} or
    * \@var\@ will be removed.
    */
-  void RemoveVariablesInString(std::string& source,
-                               bool atOnly = false) const;
+  void RemoveVariablesInString(std::string& source, bool atOnly = false) const;
 
   /**
    * Expand variables in the makefiles ivars such as link directories etc
@@ -549,17 +541,16 @@ public:
   /**
    * Copy file but change lines acording to ConfigureString
    */
-  int ConfigureFile(const char* infile, const char* outfile,
-                    bool copyonly, bool atOnly, bool escapeQuotes,
+  int ConfigureFile(const char* infile, const char* outfile, bool copyonly,
+                    bool atOnly, bool escapeQuotes,
                     const cmNewLineStyle& = cmNewLineStyle());
 
-
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**
    * find what source group this source is in
    */
   cmSourceGroup* FindSourceGroup(const char* source,
-                                 std::vector<cmSourceGroup> &groups) const;
+                                 std::vector<cmSourceGroup>& groups) const;
 #endif
 
   /**
@@ -572,18 +563,19 @@ public:
    * succeeded or false if it failed.
    */
   bool ExecuteCommand(const cmListFileFunction& lff,
-                      cmExecutionStatus &status);
+                      cmExecutionStatus& status);
 
   ///! Enable support for named language, if nil then all languages are
-  ///enabled.
-  void EnableLanguage(std::vector<std::string>const& languages, bool optional);
+  /// enabled.
+  void EnableLanguage(std::vector<std::string> const& languages,
+                      bool optional);
 
-  cmState *GetState() const;
+  cmState* GetState() const;
 
-  /**
-   * Get the variable watch. This is used to determine when certain variables
-   * are accessed.
-   */
+/**
+ * Get the variable watch. This is used to determine when certain variables
+ * are accessed.
+ */
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* GetVariableWatch() const;
 #endif
@@ -606,21 +598,23 @@ public:
   /**
    * Get the instance
    */
-  cmake *GetCMakeInstance() const;
+  cmake* GetCMakeInstance() const;
   cmGlobalGenerator* GetGlobalGenerator() const;
 
   /**
    * Get all the source files this makefile knows about
    */
-  const std::vector<cmSourceFile*> &GetSourceFiles() const
-    {return this->SourceFiles;}
-  std::vector<cmSourceFile*> &GetSourceFiles() {return this->SourceFiles;}
+  const std::vector<cmSourceFile*>& GetSourceFiles() const
+  {
+    return this->SourceFiles;
+  }
+  std::vector<cmSourceFile*>& GetSourceFiles() { return this->SourceFiles; }
 
   /**
    * Is there a source file that has the provided source file as an output?
    * if so then return it
    */
-  cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const;
+  cmSourceFile* GetSourceFileWithOutput(const std::string& outName) const;
 
   ///! Add a new cmTest to the list of tests for this makefile.
   cmTest* CreateTest(const std::string& testName);
@@ -636,11 +630,11 @@ public:
   std::string GetModulesFile(const char* name) const;
 
   ///! Set/Get a property of this directory
-  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, bool chain) 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, bool chain) const;
   bool GetPropertyAsBool(const std::string& prop) const;
   std::vector<std::string> GetPropertyKeys() const;
 
@@ -648,14 +642,24 @@ public:
   void InitializeFromParent(cmMakefile* parent);
 
   void AddInstallGenerator(cmInstallGenerator* g)
-    { if(g) this->InstallGenerators.push_back(g); }
+  {
+    if (g)
+      this->InstallGenerators.push_back(g);
+  }
   std::vector<cmInstallGenerator*>& GetInstallGenerators()
-    { return this->InstallGenerators; }
+  {
+    return this->InstallGenerators;
+  }
 
   void AddTestGenerator(cmTestGenerator* g)
-    { if(g) this->TestGenerators.push_back(g); }
+  {
+    if (g)
+      this->TestGenerators.push_back(g);
+  }
   const std::vector<cmTestGenerator*>& GetTestGenerators() const
-    { return this->TestGenerators; }
+  {
+    return this->TestGenerators;
+  }
 
   class FunctionPushPop
   {
@@ -691,7 +695,7 @@ public:
   void PopMacroScope(bool reportError);
   void PushScope();
   void PopScope();
-  void RaiseScope(const std::string& var, const char *value);
+  void RaiseScope(const std::string& var, const char* value);
 
   // push and pop loop scopes
   void PushLoopBlockBarrier();
@@ -701,14 +705,17 @@ public:
   class ScopePushPop
   {
   public:
-    ScopePushPop(cmMakefile* m): Makefile(m) { this->Makefile->PushScope(); }
+    ScopePushPop(cmMakefile* m)
+      : Makefile(m)
+    {
+      this->Makefile->PushScope();
+    }
     ~ScopePushPop() { this->Makefile->PopScope(); }
   private:
     cmMakefile* Makefile;
   };
 
-  void IssueMessage(cmake::MessageType t,
-                    std::string const& text,
+  void IssueMessage(cmake::MessageType t, std::string const& text,
                     bool force = false) const;
 
   /** Set whether or not to report a CMP0000 violation.  */
@@ -721,29 +728,29 @@ public:
   cmStringRange GetCompileDefinitionsEntries() const;
   cmBacktraceRange GetCompileDefinitionsBacktraces() const;
 
-  void AddQtUiFileWithOptions(cmSourceFile *sf);
+  void AddQtUiFileWithOptions(cmSourceFile* sf);
   std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const;
 
-  std::set<std::string> const & GetSystemIncludeDirectories() const
-    { return this->SystemIncludeDirectories; }
+  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 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;
+                           std::string& lang, std::string* error) const;
 
   const char* CompileFeaturesAvailable(const std::string& lang,
-                                       std::string *error) const;
+                                       std::string* error) const;
 
   bool HaveStandardAvailable(cmTarget const* target, std::string const& lang,
-                            const std::string& feature) const;
+                             const std::string& feature) const;
 
-  bool IsLaterStandard(std::string const& lang,
-                       std::string const& lhs,
+  bool IsLaterStandard(std::string const& lang, std::string const& lhs,
                        std::string const& rhs);
 
   void PushLoopBlock();
@@ -761,14 +768,15 @@ public:
 
   void EnforceDirectoryLevelRules() const;
 
-  void AddEvaluationFile(const std::string &inputFile,
-                  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName,
-                  cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
-                  bool inputIsContent);
+  void AddEvaluationFile(
+    const std::string& inputFile,
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> outputName,
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> condition,
+    bool inputIsContent);
   std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const;
 
-  std::vector<cmExportBuildFileGenerator*>
-  GetExportBuildFileGenerators() const;
+  std::vector<cmExportBuildFileGenerator*> GetExportBuildFileGenerators()
+    const;
   void RemoveExportBuildFileGeneratorCMP0024(cmExportBuildFileGenerator* gen);
   void AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen);
 
@@ -828,13 +836,14 @@ protected:
   std::vector<cmCommand*> FinalPassCommands;
   cmGlobalGenerator* GlobalGenerator;
   bool IsFunctionBlocked(const cmListFileFunction& lff,
-                         cmExecutionStatus &status);
+                         cmExecutionStatus& status);
 
 private:
   cmMakefile(const cmMakefile& mf);
   cmMakefile& operator=(const cmMakefile& mf);
 
   cmState::Snapshot StateSnapshot;
+  cmListFileBacktrace Backtrace;
 
   void ReadListFile(cmListFile const& listFile,
                     const std::string& filenametoread);
@@ -862,7 +871,6 @@ private:
 
   std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
 
-  std::vector<cmCommandContext const*> ContextStack;
   std::vector<cmExecutionStatus*> ExecutionStatusStack;
   friend class cmMakefileCall;
   friend class cmParseFileScope;
@@ -883,38 +891,25 @@ private:
   class BuildsystemFileScope;
   friend class BuildsystemFileScope;
 
-
   // 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;
+    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;
+    std::string& errorstr, std::string& source, bool escapeQuotes,
+    bool noEscapes, bool atOnly, const char* filename, long line,
+    bool removeEmpty, bool replaceAt) const;
   /**
    * 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 std::string&).
    */
-  cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const;
+  cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const;
 
-  // A map for fast output to input look up.
+// A map for fast output to input look up.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #ifdef CMake_HAVE_CXX11_UNORDERED_MAP
   typedef std::unordered_map<std::string, cmSourceFile*> OutputToSourceMap;
@@ -933,10 +928,10 @@ private:
 
   std::vector<cmSourceFile*> QtUiFilesWithOptions;
 
-  bool AddRequiredTargetCFeature(cmTarget *target,
+  bool AddRequiredTargetCFeature(cmTarget* target,
                                  const std::string& feature) const;
 
-  bool AddRequiredTargetCxxFeature(cmTarget *target,
+  bool AddRequiredTargetCxxFeature(cmTarget* target,
                                    const std::string& feature) const;
 
   void CheckNeededCLanguage(const std::string& feature, bool& needC90,
@@ -945,9 +940,9 @@ private:
                               bool& needCxx11, bool& needCxx14) const;
 
   bool HaveCStandardAvailable(cmTarget const* target,
-                             const std::string& feature) const;
+                              const std::string& feature) const;
   bool HaveCxxStandardAvailable(cmTarget const* target,
-                               const std::string& feature) const;
+                                const std::string& feature) const;
 
   void CheckForUnusedVariables() const;
 
@@ -959,17 +954,4 @@ private:
   mutable bool SuppressWatches;
 };
 
-//----------------------------------------------------------------------------
-// Helper class to make sure the call stack is valid.
-class cmMakefileCall
-{
-public:
-  cmMakefileCall(cmMakefile* mf,
-                 cmCommandContext const& lfc,
-                 cmExecutionStatus& status);
-  ~cmMakefileCall();
-private:
-  cmMakefile* Makefile;
-};
-
 #endif
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 9e35e4c..9d42257 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -18,29 +18,25 @@
 #include "cmSourceFile.h"
 #include "cmake.h"
 
-//----------------------------------------------------------------------------
-cmMakefileExecutableTargetGenerator
-::cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target):
-  cmMakefileTargetGenerator(target)
+cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
+  cmGeneratorTarget* target)
+  : cmMakefileTargetGenerator(target)
 {
   this->CustomCommandDriver = OnDepends;
   this->GeneratorTarget->GetExecutableNames(
     this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
     this->TargetNamePDB, this->ConfigName);
 
-  this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
-                                                      this->ConfigName);
+  this->OSXBundleGenerator =
+    new cmOSXBundleGenerator(target, this->ConfigName);
   this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
 }
 
-//----------------------------------------------------------------------------
-cmMakefileExecutableTargetGenerator
-::~cmMakefileExecutableTargetGenerator()
+cmMakefileExecutableTargetGenerator::~cmMakefileExecutableTargetGenerator()
 {
   delete this->OSXBundleGenerator;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
 {
   // create the build.make file and directory, put in the common blocks
@@ -57,11 +53,10 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
 
   // write the link rules
   this->WriteExecutableRule(false);
-  if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName))
-    {
+  if (this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) {
     // Write rules to link an installable version of the target.
     this->WriteExecutableRule(true);
-    }
+  }
 
   // Write the requires target.
   this->WriteTargetRequiresRules();
@@ -77,9 +72,6 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
   this->CloseFileStreams();
 }
 
-
-
-//----------------------------------------------------------------------------
 void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
 {
   std::vector<std::string> commands;
@@ -93,87 +85,73 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   std::string targetNameReal;
   std::string targetNameImport;
   std::string targetNamePDB;
-  this->GeneratorTarget->GetExecutableNames
-    (targetName, targetNameReal, targetNameImport, targetNamePDB,
-     this->ConfigName);
+  this->GeneratorTarget->GetExecutableNames(targetName, targetNameReal,
+                                            targetNameImport, targetNamePDB,
+                                            this->ConfigName);
 
   // Construct the full path version of the names.
   std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
-  if(this->GeneratorTarget->IsAppBundleOnApple())
-    {
+  if (this->GeneratorTarget->IsAppBundleOnApple()) {
     this->OSXBundleGenerator->CreateAppBundle(targetName, outpath);
-    }
+  }
   outpath += "/";
   std::string outpathImp;
-  if(relink)
-    {
+  if (relink) {
     outpath = this->Makefile->GetCurrentBinaryDirectory();
     outpath += cmake::GetCMakeFilesDirectory();
     outpath += "/CMakeRelink.dir";
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
-    if(!targetNameImport.empty())
-      {
+    if (!targetNameImport.empty()) {
       outpathImp = outpath;
-      }
     }
-  else
-    {
+  } else {
     cmSystemTools::MakeDirectory(outpath.c_str());
-    if(!targetNameImport.empty())
-      {
+    if (!targetNameImport.empty()) {
       outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true);
       cmSystemTools::MakeDirectory(outpathImp.c_str());
       outpathImp += "/";
-      }
     }
+  }
 
   std::string compilePdbOutputPath =
     this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName);
   cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
 
   std::string pdbOutputPath =
-      this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
+    this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
   cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
   pdbOutputPath += "/";
 
   std::string targetFullPath = outpath + targetName;
   std::string targetFullPathReal = outpath + targetNameReal;
-  std::string targetFullPathPDB =  pdbOutputPath + targetNamePDB;
+  std::string targetFullPathPDB = pdbOutputPath + targetNamePDB;
   std::string targetFullPathImport = outpathImp + targetNameImport;
-  std::string targetOutPathPDB =
-    this->Convert(targetFullPathPDB,
-                  cmLocalGenerator::NONE,
-                  cmLocalGenerator::SHELL);
+  std::string targetOutPathPDB = this->Convert(
+    targetFullPathPDB, cmOutputConverter::NONE, cmOutputConverter::SHELL);
   // Convert to the output path to use in constructing commands.
-  std::string targetOutPath =
-    this->Convert(targetFullPath,
-                  cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+  std::string targetOutPath = this->Convert(
+    targetFullPath, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL);
   std::string targetOutPathReal =
-    this->Convert(targetFullPathReal,
-                  cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+    this->Convert(targetFullPathReal, cmOutputConverter::START_OUTPUT,
+                  cmOutputConverter::SHELL);
   std::string targetOutPathImport =
-    this->Convert(targetFullPathImport,
-                  cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+    this->Convert(targetFullPathImport, cmOutputConverter::START_OUTPUT,
+                  cmOutputConverter::SHELL);
 
   // Get the language to use for linking this executable.
   std::string linkLanguage =
     this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
 
   // Make sure we have a link language.
-  if(linkLanguage.empty())
-    {
+  if (linkLanguage.empty()) {
     cmSystemTools::Error("Cannot determine link language for target \"",
                          this->GeneratorTarget->GetName().c_str(), "\".");
     return;
-    }
+  }
 
   this->NumberOfProgressActions++;
-  if(!this->NoRuleMessages)
-    {
+  if (!this->NoRuleMessages) {
     cmLocalUnixMakefileGenerator3::EchoProgress progress;
     this->MakeEchoProgress(progress);
     // Add the link message.
@@ -181,41 +159,34 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     buildEcho += linkLanguage;
     buildEcho += " executable ";
     buildEcho += targetOutPath;
-    this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
-                                     cmLocalUnixMakefileGenerator3::EchoLink,
-                                     &progress);
-    }
+    this->LocalGenerator->AppendEcho(
+      commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
+  }
 
   // Build a list of compiler flags and linker flags.
   std::string flags;
   std::string linkFlags;
 
   // Add flags to create an executable.
-  this->LocalGenerator->
-    AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS",
-                           this->ConfigName);
-
-
-  if(this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE"))
-    {
-    this->LocalGenerator->AppendFlags
-      (linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE"));
-    }
-  else
-    {
-    this->LocalGenerator->AppendFlags
-      (linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE"));
-    }
+  this->LocalGenerator->AddConfigVariableFlags(
+    linkFlags, "CMAKE_EXE_LINKER_FLAGS", this->ConfigName);
+
+  if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+    this->LocalGenerator->AppendFlags(
+      linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE"));
+  } else {
+    this->LocalGenerator->AppendFlags(
+      linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE"));
+  }
 
   // Add symbol export flags if necessary.
-  if(this->GeneratorTarget->IsExecutableWithExports())
-    {
+  if (this->GeneratorTarget->IsExecutableWithExports()) {
     std::string export_flag_var = "CMAKE_EXE_EXPORTS_";
     export_flag_var += linkLanguage;
     export_flag_var += "_FLAG";
-    this->LocalGenerator->AppendFlags
-      (linkFlags, this->Makefile->GetDefinition(export_flag_var));
-    }
+    this->LocalGenerator->AppendFlags(
+      linkFlags, this->Makefile->GetDefinition(export_flag_var));
+  }
 
   // Add language feature flags.
   this->AddFeatureFlags(flags, linkLanguage);
@@ -224,12 +195,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
                                              linkLanguage, this->ConfigName);
 
   // Add target-specific linker flags.
-  this->LocalGenerator->AppendFlags
-    (linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+  this->LocalGenerator->AppendFlags(
+    linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
-  this->LocalGenerator->AppendFlags
-    (linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+  this->LocalGenerator->AppendFlags(
+    linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
 
   this->AddModuleDefinitionFlag(linkFlags);
 
@@ -237,55 +208,49 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   // may need to be cleaned.
   std::vector<std::string> exeCleanFiles;
   exeCleanFiles.push_back(this->Convert(targetFullPath,
-                                        cmLocalGenerator::START_OUTPUT,
-                                        cmLocalGenerator::UNCHANGED));
+                                        cmOutputConverter::START_OUTPUT,
+                                        cmOutputConverter::UNCHANGED));
 #ifdef _WIN32
   // There may be a manifest file for this target.  Add it to the
   // clean set just in case.
-  exeCleanFiles.push_back(this->Convert((targetFullPath+".manifest").c_str(),
-                                        cmLocalGenerator::START_OUTPUT,
-                                        cmLocalGenerator::UNCHANGED));
+  exeCleanFiles.push_back(this->Convert((targetFullPath + ".manifest").c_str(),
+                                        cmOutputConverter::START_OUTPUT,
+                                        cmOutputConverter::UNCHANGED));
 #endif
-  if(targetNameReal != targetName)
-    {
+  if (targetNameReal != targetName) {
     exeCleanFiles.push_back(this->Convert(targetFullPathReal,
-                                          cmLocalGenerator::START_OUTPUT,
-                                          cmLocalGenerator::UNCHANGED));
-    }
-  if(!targetNameImport.empty())
-    {
+                                          cmOutputConverter::START_OUTPUT,
+                                          cmOutputConverter::UNCHANGED));
+  }
+  if (!targetNameImport.empty()) {
     exeCleanFiles.push_back(this->Convert(targetFullPathImport,
-                                          cmLocalGenerator::START_OUTPUT,
-                                          cmLocalGenerator::UNCHANGED));
+                                          cmOutputConverter::START_OUTPUT,
+                                          cmOutputConverter::UNCHANGED));
     std::string implib;
-    if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib))
-      {
+    if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
+                                                implib)) {
       exeCleanFiles.push_back(this->Convert(implib,
-                                            cmLocalGenerator::START_OUTPUT,
-                                            cmLocalGenerator::UNCHANGED));
-      }
+                                            cmOutputConverter::START_OUTPUT,
+                                            cmOutputConverter::UNCHANGED));
     }
+  }
 
   // List the PDB for cleaning only when the whole target is
   // cleaned.  We do not want to delete the .pdb file just before
   // linking the target.
-  this->CleanFiles.push_back
-    (this->Convert(targetFullPathPDB,
-                   cmLocalGenerator::START_OUTPUT,
-                   cmLocalGenerator::UNCHANGED));
+  this->CleanFiles.push_back(this->Convert(targetFullPathPDB,
+                                           cmOutputConverter::START_OUTPUT,
+                                           cmOutputConverter::UNCHANGED));
 
   // Add the pre-build and pre-link rules building but not when relinking.
-  if(!relink)
-    {
-    this->LocalGenerator
-      ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->GetPreBuildCommands(),
-                        this->GeneratorTarget);
-    this->LocalGenerator
-      ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->GetPreLinkCommands(),
-                        this->GeneratorTarget);
-    }
+  if (!relink) {
+    this->LocalGenerator->AppendCustomCommands(
+      commands, this->GeneratorTarget->GetPreBuildCommands(),
+      this->GeneratorTarget);
+    this->LocalGenerator->AppendCustomCommands(
+      commands, this->GeneratorTarget->GetPreLinkCommands(),
+      this->GeneratorTarget);
+  }
 
   // Determine whether a link script will be used.
   bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
@@ -298,186 +263,167 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   std::string linkRule = this->GetLinkRule(linkRuleVar);
   std::vector<std::string> commands1;
   cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
-  if(this->GeneratorTarget->IsExecutableWithExports())
-    {
+  if (this->GeneratorTarget->IsExecutableWithExports()) {
     // If a separate rule for creating an import library is specified
     // add it now.
     std::string implibRuleVar = "CMAKE_";
     implibRuleVar += linkLanguage;
     implibRuleVar += "_CREATE_IMPORT_LIBRARY";
-    if(const char* rule =
-       this->Makefile->GetDefinition(implibRuleVar))
-      {
+    if (const char* rule = this->Makefile->GetDefinition(implibRuleVar)) {
       cmSystemTools::ExpandListArgument(rule, real_link_commands);
-      }
     }
+  }
 
   // Select whether to use a response file for objects.
   bool useResponseFileForObjects = false;
   {
-  std::string responseVar = "CMAKE_";
-  responseVar += linkLanguage;
-  responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
-  if(this->Makefile->IsOn(responseVar))
-    {
-    useResponseFileForObjects = true;
+    std::string responseVar = "CMAKE_";
+    responseVar += linkLanguage;
+    responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
+    if (this->Makefile->IsOn(responseVar)) {
+      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;
+    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;
-  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,
-                          useResponseFileForObjects, buildObjs, depends,
-                          useWatcomQuote);
-
-  std::string manifests = this->GetManifests();
-
-  cmLocalGenerator::RuleVariables vars;
-  vars.RuleLauncher = "RULE_LAUNCH_LINK";
-  vars.CMTarget = this->GeneratorTarget;
-  vars.Language = linkLanguage.c_str();
-  vars.Objects = buildObjs.c_str();
-  std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
-  objectDir = this->Convert(objectDir,
-                            cmLocalGenerator::START_OUTPUT,
-                            cmLocalGenerator::SHELL);
-  vars.ObjectDir = objectDir.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.
-  std::string targetVersionMajor;
-  std::string targetVersionMinor;
-  {
-  std::ostringstream majorStream;
-  std::ostringstream minorStream;
-  int major;
-  int minor;
-  this->GeneratorTarget->GetTargetVersion(major, minor);
-  majorStream << major;
-  minorStream << minor;
-  targetVersionMajor = majorStream.str();
-  targetVersionMinor = minorStream.str();
-  }
-  vars.TargetVersionMajor = targetVersionMajor.c_str();
-  vars.TargetVersionMinor = targetVersionMinor.c_str();
-
-  vars.LinkLibraries = linkLibs.c_str();
-  vars.Flags = flags.c_str();
-  vars.LinkFlags = linkFlags.c_str();
-  vars.Manifests = manifests.c_str();
-
-  // Expand placeholders in the commands.
-  this->LocalGenerator->TargetImplib = targetOutPathImport;
-  for(std::vector<std::string>::iterator i = real_link_commands.begin();
-      i != real_link_commands.end(); ++i)
+    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;
+    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, useResponseFileForObjects,
+                            buildObjs, depends, useWatcomQuote);
+
+    std::string manifests = this->GetManifests();
+
+    cmLocalGenerator::RuleVariables vars;
+    vars.RuleLauncher = "RULE_LAUNCH_LINK";
+    vars.CMTarget = this->GeneratorTarget;
+    vars.Language = linkLanguage.c_str();
+    vars.Objects = buildObjs.c_str();
+    std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
+    objectDir = this->Convert(objectDir, cmOutputConverter::START_OUTPUT,
+                              cmOutputConverter::SHELL);
+    vars.ObjectDir = objectDir.c_str();
+    cmOutputConverter::OutputFormat output = (useWatcomQuote)
+      ? cmOutputConverter::WATCOMQUOTE
+      : cmOutputConverter::SHELL;
+    std::string target = this->Convert(
+      targetFullPathReal, cmOutputConverter::START_OUTPUT, output);
+    vars.Target = target.c_str();
+    vars.TargetPDB = targetOutPathPDB.c_str();
+
+    // Setup the target version.
+    std::string targetVersionMajor;
+    std::string targetVersionMinor;
     {
-    this->LocalGenerator->ExpandRuleVariables(*i, vars);
+      std::ostringstream majorStream;
+      std::ostringstream minorStream;
+      int major;
+      int minor;
+      this->GeneratorTarget->GetTargetVersion(major, minor);
+      majorStream << major;
+      minorStream << minor;
+      targetVersionMajor = majorStream.str();
+      targetVersionMinor = minorStream.str();
+    }
+    vars.TargetVersionMajor = targetVersionMajor.c_str();
+    vars.TargetVersionMinor = targetVersionMinor.c_str();
+
+    vars.LinkLibraries = linkLibs.c_str();
+    vars.Flags = flags.c_str();
+    vars.LinkFlags = linkFlags.c_str();
+    vars.Manifests = manifests.c_str();
+
+    // Expand placeholders in the commands.
+    this->LocalGenerator->TargetImplib = targetOutPathImport;
+    for (std::vector<std::string>::iterator i = real_link_commands.begin();
+         i != real_link_commands.end(); ++i) {
+      this->LocalGenerator->ExpandRuleVariables(*i, vars);
     }
-  this->LocalGenerator->TargetImplib = "";
+    this->LocalGenerator->TargetImplib = "";
 
-  // Restore path conversion to normal shells.
-  this->LocalGenerator->SetLinkScriptShell(false);
+    // Restore path conversion to normal shells.
+    this->LocalGenerator->SetLinkScriptShell(false);
   }
 
   // Optionally convert the build rule to use a script to avoid long
   // command lines in the make shell.
-  if(useLinkScript)
-    {
+  if (useLinkScript) {
     // Use a link script.
-    const char* name = (relink? "relink.txt" : "link.txt");
+    const char* name = (relink ? "relink.txt" : "link.txt");
     this->CreateLinkScript(name, real_link_commands, commands1, depends);
-    }
-  else
-    {
+  } else {
     // No link script.  Just use the link rule directly.
     commands1 = real_link_commands;
-    }
-  this->LocalGenerator->CreateCDCommand
-    (commands1,
-     this->Makefile->GetCurrentBinaryDirectory(),
-     cmLocalGenerator::HOME_OUTPUT);
+  }
+  this->LocalGenerator->CreateCDCommand(
+    commands1, this->Makefile->GetCurrentBinaryDirectory(),
+    cmOutputConverter::HOME_OUTPUT);
   commands.insert(commands.end(), commands1.begin(), commands1.end());
   commands1.clear();
 
   // Add a rule to create necessary symlinks for the library.
-  if(targetOutPath != targetOutPathReal)
-    {
+  if (targetOutPath != targetOutPathReal) {
     std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_executable ";
     symlink += targetOutPathReal;
     symlink += " ";
     symlink += targetOutPath;
     commands1.push_back(symlink);
-    this->LocalGenerator->CreateCDCommand(commands1,
-                                  this->Makefile->GetCurrentBinaryDirectory(),
-                                  cmLocalGenerator::HOME_OUTPUT);
+    this->LocalGenerator->CreateCDCommand(
+      commands1, this->Makefile->GetCurrentBinaryDirectory(),
+      cmOutputConverter::HOME_OUTPUT);
     commands.insert(commands.end(), commands1.begin(), commands1.end());
     commands1.clear();
-    }
+  }
 
   // Add the post-build rules when building but not when relinking.
-  if(!relink)
-    {
-    this->LocalGenerator->
-      AppendCustomCommands(commands,
-                       this->GeneratorTarget->GetPostBuildCommands(),
-                       this->GeneratorTarget);
-    }
+  if (!relink) {
+    this->LocalGenerator->AppendCustomCommands(
+      commands, this->GeneratorTarget->GetPostBuildCommands(),
+      this->GeneratorTarget);
+  }
 
   // Write the build rule.
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream,
-                                      0,
-                                      targetFullPathReal,
-                                      depends, commands, false);
+  this->LocalGenerator->WriteMakeRule(
+    *this->BuildFileStream, 0, targetFullPathReal, depends, commands, false);
 
   // The symlink name for the target should depend on the real target
   // so if the target version changes it rebuilds and recreates the
   // symlink.
-  if(targetFullPath != targetFullPathReal)
-    {
+  if (targetFullPath != targetFullPathReal) {
     depends.clear();
     commands.clear();
     depends.push_back(targetFullPathReal);
-    this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                        targetFullPath,
-                                        depends, commands, false);
-    }
+    this->LocalGenerator->WriteMakeRule(
+      *this->BuildFileStream, 0, targetFullPath, depends, commands, false);
+  }
 
   // Write the main driver rule to build everything in this target.
   this->WriteTargetDriverRule(targetFullPath, relink);
 
   // Clean all the possible executable names and symlinks.
-  this->CleanFiles.insert(this->CleanFiles.end(),
-                          exeCleanFiles.begin(),
+  this->CleanFiles.insert(this->CleanFiles.end(), exeCleanFiles.begin(),
                           exeCleanFiles.end());
 }
diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h
index 940226b..64cb17f 100644
--- a/Source/cmMakefileExecutableTargetGenerator.h
+++ b/Source/cmMakefileExecutableTargetGenerator.h
@@ -14,7 +14,7 @@
 
 #include "cmMakefileTargetGenerator.h"
 
-class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator
+class cmMakefileExecutableTargetGenerator : public cmMakefileTargetGenerator
 {
 public:
   cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 1923ea4..8f7dd7e 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -11,40 +11,35 @@
 ============================================================================*/
 #include "cmMakefileLibraryTargetGenerator.h"
 
+#include "cmAlgorithms.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmake.h"
-#include "cmAlgorithms.h"
 
-//----------------------------------------------------------------------------
-cmMakefileLibraryTargetGenerator
-::cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target):
-  cmMakefileTargetGenerator(target)
+cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
+  cmGeneratorTarget* target)
+  : cmMakefileTargetGenerator(target)
 {
   this->CustomCommandDriver = OnDepends;
-  if (this->GeneratorTarget->GetType() != cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() != cmState::INTERFACE_LIBRARY) {
     this->GeneratorTarget->GetLibraryNames(
       this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
       this->TargetNameImport, this->TargetNamePDB, this->ConfigName);
-    }
+  }
 
-  this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
-                                                      this->ConfigName);
+  this->OSXBundleGenerator =
+    new cmOSXBundleGenerator(target, this->ConfigName);
   this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
 }
 
-//----------------------------------------------------------------------------
-cmMakefileLibraryTargetGenerator
-::~cmMakefileLibraryTargetGenerator()
+cmMakefileLibraryTargetGenerator::~cmMakefileLibraryTargetGenerator()
 {
   delete this->OSXBundleGenerator;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
 {
   // create the build.make file and directory, put in the common blocks
@@ -61,26 +56,23 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
 
   // write the link rules
   // Write the rule for this target type.
-  switch(this->GeneratorTarget->GetType())
-    {
+  switch (this->GeneratorTarget->GetType()) {
     case cmState::STATIC_LIBRARY:
       this->WriteStaticLibraryRules();
       break;
     case cmState::SHARED_LIBRARY:
       this->WriteSharedLibraryRules(false);
-      if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName))
-        {
+      if (this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) {
         // Write rules to link an installable version of the target.
         this->WriteSharedLibraryRules(true);
-        }
+      }
       break;
     case cmState::MODULE_LIBRARY:
       this->WriteModuleLibraryRules(false);
-      if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName))
-        {
+      if (this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) {
         // Write rules to link an installable version of the target.
         this->WriteModuleLibraryRules(true);
-        }
+      }
       break;
     case cmState::OBJECT_LIBRARY:
       this->WriteObjectLibraryRules();
@@ -89,7 +81,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
       // If language is not known, this is an error.
       cmSystemTools::Error("Unknown Library Type");
       break;
-    }
+  }
 
   // Write the requires target.
   this->WriteTargetRequiresRules();
@@ -105,17 +97,15 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
   this->CloseFileStreams();
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
 {
   std::vector<std::string> commands;
   std::vector<std::string> depends;
 
   // Add post-build rules.
-  this->LocalGenerator->
-    AppendCustomCommands(commands,
-                         this->GeneratorTarget->GetPostBuildCommands(),
-                         this->GeneratorTarget);
+  this->LocalGenerator->AppendCustomCommands(
+    commands, this->GeneratorTarget->GetPostBuildCommands(),
+    this->GeneratorTarget);
 
   // Depend on the object files.
   this->AppendObjectDepends(depends);
@@ -129,7 +119,6 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
   this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
 {
   std::string linkLanguage =
@@ -138,26 +127,24 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
   linkRuleVar += linkLanguage;
   linkRuleVar += "_CREATE_STATIC_LIBRARY";
 
-  if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
-     this->Makefile->GetDefinition(linkRuleVar+"_IPO"))
-    {
+  if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
+      this->Makefile->GetDefinition(linkRuleVar + "_IPO")) {
     linkRuleVar += "_IPO";
-    }
+  }
 
   std::string extraFlags;
-  this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
-    cmSystemTools::UpperCase(this->ConfigName), this->GeneratorTarget);
+  this->LocalGenerator->GetStaticLibraryFlags(
+    extraFlags, cmSystemTools::UpperCase(this->ConfigName),
+    this->GeneratorTarget);
   this->WriteLibraryRules(linkRuleVar, extraFlags, false);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
 {
-  if(this->GeneratorTarget->IsFrameworkOnApple())
-    {
+  if (this->GeneratorTarget->IsFrameworkOnApple()) {
     this->WriteFrameworkRules(relink);
     return;
-    }
+  }
   std::string linkLanguage =
     this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
   std::string linkRuleVar = "CMAKE_";
@@ -165,21 +152,20 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
   linkRuleVar += "_CREATE_SHARED_LIBRARY";
 
   std::string extraFlags;
-  this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+  this->LocalGenerator->AppendFlags(
+    extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
-  this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+  this->LocalGenerator->AppendFlags(
+    extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
 
-  this->LocalGenerator->AddConfigVariableFlags
-    (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
+  this->LocalGenerator->AddConfigVariableFlags(
+    extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
   this->AddModuleDefinitionFlag(extraFlags);
 
   this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
 {
   std::string linkLanguage =
@@ -189,20 +175,19 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
   linkRuleVar += "_CREATE_SHARED_MODULE";
 
   std::string extraFlags;
-  this->LocalGenerator->AppendFlags(extraFlags,
-                           this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+  this->LocalGenerator->AppendFlags(
+    extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
-  this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
-  this->LocalGenerator->AddConfigVariableFlags
-    (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
+  this->LocalGenerator->AppendFlags(
+    extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+  this->LocalGenerator->AddConfigVariableFlags(
+    extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
   this->AddModuleDefinitionFlag(extraFlags);
 
   this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
 {
   std::string linkLanguage =
@@ -212,21 +197,20 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
   linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
 
   std::string extraFlags;
-  this->LocalGenerator->AppendFlags(extraFlags,
-                             this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+  this->LocalGenerator->AppendFlags(
+    extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
-  this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
-  this->LocalGenerator->AddConfigVariableFlags
-    (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
+  this->LocalGenerator->AppendFlags(
+    extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+  this->LocalGenerator->AddConfigVariableFlags(
+    extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
 
   this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileLibraryTargetGenerator::WriteLibraryRules
-(const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
+void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
+  const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
 {
   // TODO: Merge the methods that call this method to avoid
   // code duplication.
@@ -241,24 +225,22 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
 
   // Make sure we have a link language.
-  if(linkLanguage.empty())
-    {
+  if (linkLanguage.empty()) {
     cmSystemTools::Error("Cannot determine link language for target \"",
                          this->GeneratorTarget->GetName().c_str(), "\".");
     return;
-    }
+  }
 
   // Create set of linking flags.
   std::string linkFlags;
   this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
 
   // Add OSX version flags, if any.
-  if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
-     this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+      this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
     this->AppendOSXVerFlag(linkFlags, linkLanguage, "COMPATIBILITY", true);
     this->AppendOSXVerFlag(linkFlags, linkLanguage, "CURRENT", false);
-    }
+  }
 
   // Construct the name of the library.
   std::string targetName;
@@ -266,56 +248,47 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::string targetNameReal;
   std::string targetNameImport;
   std::string targetNamePDB;
-  this->GeneratorTarget->GetLibraryNames(
-    targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB,
-    this->ConfigName);
+  this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO,
+                                         targetNameReal, targetNameImport,
+                                         targetNamePDB, this->ConfigName);
 
   // Construct the full path version of the names.
   std::string outpath;
   std::string outpathImp;
-  if(this->GeneratorTarget->IsFrameworkOnApple())
-    {
+  if (this->GeneratorTarget->IsFrameworkOnApple()) {
     outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
     this->OSXBundleGenerator->CreateFramework(targetName, outpath);
     outpath += "/";
-    }
-  else if(this->GeneratorTarget->IsCFBundleOnApple())
-    {
+  } else if (this->GeneratorTarget->IsCFBundleOnApple()) {
     outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
     this->OSXBundleGenerator->CreateCFBundle(targetName, outpath);
     outpath += "/";
-    }
-  else if(relink)
-    {
+  } else if (relink) {
     outpath = this->Makefile->GetCurrentBinaryDirectory();
     outpath += cmake::GetCMakeFilesDirectory();
     outpath += "/CMakeRelink.dir";
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
-    if(!targetNameImport.empty())
-      {
+    if (!targetNameImport.empty()) {
       outpathImp = outpath;
-      }
     }
-  else
-    {
+  } else {
     outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
-    if(!targetNameImport.empty())
-      {
+    if (!targetNameImport.empty()) {
       outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true);
       cmSystemTools::MakeDirectory(outpathImp.c_str());
       outpathImp += "/";
-      }
     }
+  }
 
   std::string compilePdbOutputPath =
     this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName);
   cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
 
   std::string pdbOutputPath =
-      this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
+    this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
   cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
   pdbOutputPath += "/";
 
@@ -327,32 +300,28 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 
   // Construct the output path version of the names for use in command
   // arguments.
-  std::string targetOutPathPDB =
-    this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
-                  cmLocalGenerator::SHELL);
-  std::string targetOutPath =
-    this->Convert(targetFullPath,cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+  std::string targetOutPathPDB = this->Convert(
+    targetFullPathPDB, cmOutputConverter::NONE, cmOutputConverter::SHELL);
+  std::string targetOutPath = this->Convert(
+    targetFullPath, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL);
   std::string targetOutPathSO =
-    this->Convert(targetFullPathSO,cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+    this->Convert(targetFullPathSO, cmOutputConverter::START_OUTPUT,
+                  cmOutputConverter::SHELL);
   std::string targetOutPathReal =
-    this->Convert(targetFullPathReal,cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+    this->Convert(targetFullPathReal, cmOutputConverter::START_OUTPUT,
+                  cmOutputConverter::SHELL);
   std::string targetOutPathImport =
-    this->Convert(targetFullPathImport,cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
+    this->Convert(targetFullPathImport, cmOutputConverter::START_OUTPUT,
+                  cmOutputConverter::SHELL);
 
   this->NumberOfProgressActions++;
-  if(!this->NoRuleMessages)
-    {
+  if (!this->NoRuleMessages) {
     cmLocalUnixMakefileGenerator3::EchoProgress progress;
     this->MakeEchoProgress(progress);
     // Add the link message.
     std::string buildEcho = "Linking ";
     buildEcho += linkLanguage;
-    switch(this->GeneratorTarget->GetType())
-      {
+    switch (this->GeneratorTarget->GetType()) {
       case cmState::STATIC_LIBRARY:
         buildEcho += " static library ";
         break;
@@ -361,110 +330,97 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
         break;
       case cmState::MODULE_LIBRARY:
         if (this->GeneratorTarget->IsCFBundleOnApple())
-            buildEcho += " CFBundle";
+          buildEcho += " CFBundle";
         buildEcho += " shared module ";
         break;
       default:
         buildEcho += " library ";
         break;
-      }
-    buildEcho += targetOutPath.c_str();
-    this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(),
-                                     cmLocalUnixMakefileGenerator3::EchoLink,
-                                     &progress);
     }
+    buildEcho += targetOutPath;
+    this->LocalGenerator->AppendEcho(
+      commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
+  }
 
   const char* forbiddenFlagVar = 0;
-  switch(this->GeneratorTarget->GetType())
-    {
+  switch (this->GeneratorTarget->GetType()) {
     case cmState::SHARED_LIBRARY:
       forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS";
       break;
     case cmState::MODULE_LIBRARY:
       forbiddenFlagVar = "_CREATE_SHARED_MODULE_FORBIDDEN_FLAGS";
       break;
-    default: break;
-    }
+    default:
+      break;
+  }
 
   // Clean files associated with this library.
   std::vector<std::string> libCleanFiles;
   libCleanFiles.push_back(this->Convert(targetFullPath,
-        cmLocalGenerator::START_OUTPUT,
-        cmLocalGenerator::UNCHANGED));
-  if(targetNameReal != targetName)
-    {
+                                        cmOutputConverter::START_OUTPUT,
+                                        cmOutputConverter::UNCHANGED));
+  if (targetNameReal != targetName) {
     libCleanFiles.push_back(this->Convert(targetFullPathReal,
-        cmLocalGenerator::START_OUTPUT,
-        cmLocalGenerator::UNCHANGED));
-    }
-  if(targetNameSO != targetName &&
-     targetNameSO != targetNameReal)
-    {
+                                          cmOutputConverter::START_OUTPUT,
+                                          cmOutputConverter::UNCHANGED));
+  }
+  if (targetNameSO != targetName && targetNameSO != targetNameReal) {
     libCleanFiles.push_back(this->Convert(targetFullPathSO,
-        cmLocalGenerator::START_OUTPUT,
-        cmLocalGenerator::UNCHANGED));
-    }
-  if(!targetNameImport.empty())
-    {
+                                          cmOutputConverter::START_OUTPUT,
+                                          cmOutputConverter::UNCHANGED));
+  }
+  if (!targetNameImport.empty()) {
     libCleanFiles.push_back(this->Convert(targetFullPathImport,
-        cmLocalGenerator::START_OUTPUT,
-        cmLocalGenerator::UNCHANGED));
+                                          cmOutputConverter::START_OUTPUT,
+                                          cmOutputConverter::UNCHANGED));
     std::string implib;
-    if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib))
-      {
+    if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
+                                                implib)) {
       libCleanFiles.push_back(this->Convert(implib,
-                                            cmLocalGenerator::START_OUTPUT,
-                                            cmLocalGenerator::UNCHANGED));
-      }
+                                            cmOutputConverter::START_OUTPUT,
+                                            cmOutputConverter::UNCHANGED));
     }
+  }
 
   // List the PDB for cleaning only when the whole target is
   // cleaned.  We do not want to delete the .pdb file just before
   // linking the target.
-  this->CleanFiles.push_back
-    (this->Convert(targetFullPathPDB,
-                   cmLocalGenerator::START_OUTPUT,
-                   cmLocalGenerator::UNCHANGED));
+  this->CleanFiles.push_back(this->Convert(targetFullPathPDB,
+                                           cmOutputConverter::START_OUTPUT,
+                                           cmOutputConverter::UNCHANGED));
 
 #ifdef _WIN32
   // There may be a manifest file for this target.  Add it to the
   // clean set just in case.
-  if(this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY)
-    {
-    libCleanFiles.push_back(
-      this->Convert((targetFullPath+".manifest").c_str(),
-                    cmLocalGenerator::START_OUTPUT,
-                    cmLocalGenerator::UNCHANGED));
-    }
+  if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) {
+    libCleanFiles.push_back(this->Convert(
+      (targetFullPath + ".manifest").c_str(), cmOutputConverter::START_OUTPUT,
+      cmOutputConverter::UNCHANGED));
+  }
 #endif
 
   std::vector<std::string> commands1;
   // Add a command to remove any existing files for this library.
   // for static libs only
-  if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) {
     this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles,
                                              this->GeneratorTarget, "target");
-    this->LocalGenerator->CreateCDCommand
-      (commands1,
-       this->Makefile->GetCurrentBinaryDirectory(),
-       cmLocalGenerator::HOME_OUTPUT);
+    this->LocalGenerator->CreateCDCommand(
+      commands1, this->Makefile->GetCurrentBinaryDirectory(),
+      cmOutputConverter::HOME_OUTPUT);
     commands.insert(commands.end(), commands1.begin(), commands1.end());
     commands1.clear();
-    }
+  }
 
   // Add the pre-build and pre-link rules building but not when relinking.
-  if(!relink)
-    {
-    this->LocalGenerator
-      ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->GetPreBuildCommands(),
-                        this->GeneratorTarget);
-    this->LocalGenerator
-      ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->GetPreLinkCommands(),
-                        this->GeneratorTarget);
-    }
+  if (!relink) {
+    this->LocalGenerator->AppendCustomCommands(
+      commands, this->GeneratorTarget->GetPreBuildCommands(),
+      this->GeneratorTarget);
+    this->LocalGenerator->AppendCustomCommands(
+      commands, this->GeneratorTarget->GetPreLinkCommands(),
+      this->GeneratorTarget);
+  }
 
   // Determine whether a link script will be used.
   bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
@@ -472,24 +428,22 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   // Select whether to use a response file for objects.
   bool useResponseFileForObjects = false;
   {
-  std::string responseVar = "CMAKE_";
-  responseVar += linkLanguage;
-  responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
-  if(this->Makefile->IsOn(responseVar))
-    {
-    useResponseFileForObjects = true;
+    std::string responseVar = "CMAKE_";
+    responseVar += linkLanguage;
+    responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
+    if (this->Makefile->IsOn(responseVar)) {
+      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;
+    std::string responseVar = "CMAKE_";
+    responseVar += linkLanguage;
+    responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+    if (this->Makefile->IsOn(responseVar)) {
+      useResponseFileForLibs = true;
     }
   }
 
@@ -499,39 +453,33 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::vector<std::string> archiveAppendCommands;
   std::vector<std::string> archiveFinishCommands;
   std::string::size_type archiveCommandLimit = std::string::npos;
-  if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) {
     haveStaticLibraryRule =
-      this->Makefile->GetDefinition(linkRuleVar)? true:false;
+      this->Makefile->GetDefinition(linkRuleVar) ? true : false;
     std::string arCreateVar = "CMAKE_";
     arCreateVar += linkLanguage;
     arCreateVar += "_ARCHIVE_CREATE";
-    if(const char* rule = this->Makefile->GetDefinition(arCreateVar))
-      {
+    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))
-      {
+    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))
-      {
+    if (const char* rule = this->Makefile->GetDefinition(arFinishVar)) {
       cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
-      }
     }
+  }
 
   // Decide whether to use archiving rules.
-  bool useArchiveRules =
-    !haveStaticLibraryRule &&
+  bool useArchiveRules = !haveStaticLibraryRule &&
     !archiveCreateCommands.empty() && !archiveAppendCommands.empty();
-  if(useArchiveRules)
-    {
+  if (useArchiveRules) {
     // Archiving rules are always run with a link script.
     useLinkScript = true;
 
@@ -542,260 +490,232 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     // 32K command line length limit on Windows.  We could make this a
     // platform file variable but this should work everywhere.
     archiveCommandLimit = 30000;
-    }
+  }
 
   // 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);
-
-  // Collect up flags to link in needed libraries.
-  std::string linkLibs;
-  if(this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY)
-    {
-    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,
-                          useResponseFileForObjects, buildObjs, depends,
-                          useWatcomQuote);
-
-  // maybe create .def file from list of objects
-  if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY &&
-      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
-    {
-    if(this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
-      std::string name_of_def_file =
-        this->GeneratorTarget->GetSupportDirectory();
-      name_of_def_file += std::string("/") +
-        this->GeneratorTarget->GetName();
-      name_of_def_file += ".def";
-      std::string cmd = cmSystemTools::GetCMakeCommand();
-      cmd = this->Convert(cmd, cmLocalGenerator::NONE,
-                          cmLocalGenerator::SHELL);
-      cmd += " -E __create_def ";
-      cmd += this->Convert(name_of_def_file,
-                           cmLocalGenerator::START_OUTPUT,
-                           cmLocalGenerator::SHELL);
-      cmd += " ";
-      std::string objlist_file = name_of_def_file;
-      objlist_file += ".objs";
-      cmd += this->Convert(objlist_file,
-                           cmLocalGenerator::START_OUTPUT,
-                           cmLocalGenerator::SHELL);
-      real_link_commands.push_back(cmd);
-      // create a list of obj files for the -E __create_def to read
-      cmGeneratedFileStream fout(objlist_file.c_str());
-      for(std::vector<std::string>::const_iterator i = this->Objects.begin();
-          i != this->Objects.end(); ++i)
-        {
-        if(cmHasLiteralSuffix(*i, ".obj"))
-          {
-          fout << *i << "\n";
+    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;
+    if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) {
+      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,
+                            useResponseFileForObjects, buildObjs, depends,
+                            useWatcomQuote);
+
+    // maybe create .def file from list of objects
+    if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY &&
+        this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+      if (this->GeneratorTarget->GetPropertyAsBool(
+            "WINDOWS_EXPORT_ALL_SYMBOLS")) {
+        std::string name_of_def_file =
+          this->GeneratorTarget->GetSupportDirectory();
+        name_of_def_file +=
+          std::string("/") + this->GeneratorTarget->GetName();
+        name_of_def_file += ".def";
+        std::string cmd = cmSystemTools::GetCMakeCommand();
+        cmd = this->Convert(cmd, cmOutputConverter::NONE,
+                            cmOutputConverter::SHELL);
+        cmd += " -E __create_def ";
+        cmd += this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
+                             cmOutputConverter::SHELL);
+        cmd += " ";
+        std::string objlist_file = name_of_def_file;
+        objlist_file += ".objs";
+        cmd += this->Convert(objlist_file, cmOutputConverter::START_OUTPUT,
+                             cmOutputConverter::SHELL);
+        real_link_commands.push_back(cmd);
+        // create a list of obj files for the -E __create_def to read
+        cmGeneratedFileStream fout(objlist_file.c_str());
+        for (std::vector<std::string>::const_iterator i =
+               this->Objects.begin();
+             i != this->Objects.end(); ++i) {
+          if (cmHasLiteralSuffix(*i, ".obj")) {
+            fout << *i << "\n";
           }
         }
-      for(std::vector<std::string>::const_iterator i =
-        this->ExternalObjects.begin();
-          i != this->ExternalObjects.end(); ++i)
-        {
-        fout << *i << "\n";
+        for (std::vector<std::string>::const_iterator i =
+               this->ExternalObjects.begin();
+             i != this->ExternalObjects.end(); ++i) {
+          fout << *i << "\n";
         }
-      // now add the def file link flag
-      linkFlags += " ";
-      linkFlags +=
-        this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
-      linkFlags += this->Convert(name_of_def_file,
-                                 cmLocalGenerator::START_OUTPUT,
-                                 cmLocalGenerator::SHELL);
-      linkFlags += " ";
+        // now add the def file link flag
+        linkFlags += " ";
+        linkFlags +=
+          this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
+        linkFlags +=
+          this->Convert(name_of_def_file, cmOutputConverter::START_OUTPUT,
+                        cmOutputConverter::SHELL);
+        linkFlags += " ";
       }
     }
 
-  std::string manifests = this->GetManifests();
-
-  cmLocalGenerator::RuleVariables vars;
-  vars.TargetPDB = targetOutPathPDB.c_str();
-
-  // Setup the target version.
-  std::string targetVersionMajor;
-  std::string targetVersionMinor;
-  {
-  std::ostringstream majorStream;
-  std::ostringstream minorStream;
-  int major;
-  int minor;
-  this->GeneratorTarget->GetTargetVersion(major, minor);
-  majorStream << major;
-  minorStream << minor;
-  targetVersionMajor = majorStream.str();
-  targetVersionMinor = minorStream.str();
-  }
-  vars.TargetVersionMajor = targetVersionMajor.c_str();
-  vars.TargetVersionMinor = targetVersionMinor.c_str();
-
-  vars.RuleLauncher = "RULE_LAUNCH_LINK";
-  vars.CMTarget = this->GeneratorTarget;
-  vars.Language = linkLanguage.c_str();
-  vars.Objects = buildObjs.c_str();
-  std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
-  objectDir = this->Convert(objectDir,
-                            cmLocalGenerator::START_OUTPUT,
-                            cmLocalGenerator::SHELL);
-  vars.ObjectDir = objectDir.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->GeneratorTarget->HasSOName(this->ConfigName))
-    {
-    vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage);
-    vars.TargetSOName= targetNameSO.c_str();
-    }
-  vars.LinkFlags = linkFlags.c_str();
-
-  vars.Manifests = manifests.c_str();
-
-  // Compute the directory portion of the install_name setting.
-  std::string install_name_dir;
-  if(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)
-    {
-    // Get the install_name directory for the build tree.
-    install_name_dir =
-      this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName);
-
-    // Set the rule variable replacement value.
-    if(install_name_dir.empty())
-      {
-      vars.TargetInstallNameDir = "";
-      }
-    else
-      {
-      // Convert to a path for the native build tool.
+    std::string manifests = this->GetManifests();
+
+    cmLocalGenerator::RuleVariables vars;
+    vars.TargetPDB = targetOutPathPDB.c_str();
+
+    // Setup the target version.
+    std::string targetVersionMajor;
+    std::string targetVersionMinor;
+    {
+      std::ostringstream majorStream;
+      std::ostringstream minorStream;
+      int major;
+      int minor;
+      this->GeneratorTarget->GetTargetVersion(major, minor);
+      majorStream << major;
+      minorStream << minor;
+      targetVersionMajor = majorStream.str();
+      targetVersionMinor = minorStream.str();
+    }
+    vars.TargetVersionMajor = targetVersionMajor.c_str();
+    vars.TargetVersionMinor = targetVersionMinor.c_str();
+
+    vars.RuleLauncher = "RULE_LAUNCH_LINK";
+    vars.CMTarget = this->GeneratorTarget;
+    vars.Language = linkLanguage.c_str();
+    vars.Objects = buildObjs.c_str();
+    std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
+    objectDir = this->Convert(objectDir, cmOutputConverter::START_OUTPUT,
+                              cmOutputConverter::SHELL);
+    vars.ObjectDir = objectDir.c_str();
+    cmOutputConverter::OutputFormat output = (useWatcomQuote)
+      ? cmOutputConverter::WATCOMQUOTE
+      : cmOutputConverter::SHELL;
+    std::string target = this->Convert(
+      targetFullPathReal, cmOutputConverter::START_OUTPUT, output);
+    vars.Target = target.c_str();
+    vars.LinkLibraries = linkLibs.c_str();
+    vars.ObjectsQuoted = buildObjs.c_str();
+    if (this->GeneratorTarget->HasSOName(this->ConfigName)) {
+      vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage);
+      vars.TargetSOName = targetNameSO.c_str();
+    }
+    vars.LinkFlags = linkFlags.c_str();
+
+    vars.Manifests = manifests.c_str();
+
+    // Compute the directory portion of the install_name setting.
+    std::string install_name_dir;
+    if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY) {
+      // Get the install_name directory for the build tree.
       install_name_dir =
-        this->LocalGenerator->Convert(install_name_dir,
-                                      cmLocalGenerator::NONE,
-                                      cmLocalGenerator::SHELL);
-      vars.TargetInstallNameDir = install_name_dir.c_str();
+        this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName);
+
+      // Set the rule variable replacement value.
+      if (install_name_dir.empty()) {
+        vars.TargetInstallNameDir = "";
+      } else {
+        // Convert to a path for the native build tool.
+        install_name_dir = this->LocalGenerator->Convert(
+          install_name_dir, cmOutputConverter::NONE, cmOutputConverter::SHELL);
+        vars.TargetInstallNameDir = install_name_dir.c_str();
       }
     }
 
-  // Add language feature flags.
-  std::string langFlags;
-  this->AddFeatureFlags(langFlags, linkLanguage);
+    // Add language feature flags.
+    std::string langFlags;
+    this->AddFeatureFlags(langFlags, linkLanguage);
 
-  this->LocalGenerator->AddArchitectureFlags(langFlags, this->GeneratorTarget,
-                                             linkLanguage, this->ConfigName);
+    this->LocalGenerator->AddArchitectureFlags(
+      langFlags, this->GeneratorTarget, linkLanguage, this->ConfigName);
 
-  // remove any language flags that might not work with the
-  // particular os
-  if(forbiddenFlagVar)
-    {
-    this->RemoveForbiddenFlags(forbiddenFlagVar,
-                               linkLanguage, langFlags);
+    // remove any language flags that might not work with the
+    // particular os
+    if (forbiddenFlagVar) {
+      this->RemoveForbiddenFlags(forbiddenFlagVar, linkLanguage, langFlags);
     }
-  vars.LanguageCompileFlags = langFlags.c_str();
+    vars.LanguageCompileFlags = langFlags.c_str();
 
-  // Construct the main link rule and expand placeholders.
-  this->LocalGenerator->TargetImplib = targetOutPathImport;
-  if(useArchiveRules)
-    {
-    // Construct the individual object list strings.
-    std::vector<std::string> object_strings;
-    this->WriteObjectsStrings(object_strings, archiveCommandLimit);
+    // Construct the main link rule and expand placeholders.
+    this->LocalGenerator->TargetImplib = targetOutPathImport;
+    if (useArchiveRules) {
+      // Construct the individual object list strings.
+      std::vector<std::string> object_strings;
+      this->WriteObjectsStrings(object_strings, archiveCommandLimit);
 
-    // Create the archive with the first set of objects.
-    std::vector<std::string>::iterator osi = object_strings.begin();
-    {
-    vars.Objects = osi->c_str();
-    for(std::vector<std::string>::const_iterator
-          i = archiveCreateCommands.begin();
-        i != archiveCreateCommands.end(); ++i)
+      // Create the archive with the first set of objects.
+      std::vector<std::string>::iterator osi = object_strings.begin();
       {
-      std::string cmd = *i;
-      this->LocalGenerator->ExpandRuleVariables(cmd, vars);
-      real_link_commands.push_back(cmd);
+        vars.Objects = osi->c_str();
+        for (std::vector<std::string>::const_iterator i =
+               archiveCreateCommands.begin();
+             i != archiveCreateCommands.end(); ++i) {
+          std::string cmd = *i;
+          this->LocalGenerator->ExpandRuleVariables(cmd, vars);
+          real_link_commands.push_back(cmd);
+        }
       }
-    }
-    // Append to the archive with the other object sets.
-    for(++osi; osi != object_strings.end(); ++osi)
-      {
-      vars.Objects = osi->c_str();
-      for(std::vector<std::string>::const_iterator
-            i = archiveAppendCommands.begin();
-          i != archiveAppendCommands.end(); ++i)
-        {
+      // Append to the archive with the other object sets.
+      for (++osi; osi != object_strings.end(); ++osi) {
+        vars.Objects = osi->c_str();
+        for (std::vector<std::string>::const_iterator i =
+               archiveAppendCommands.begin();
+             i != archiveAppendCommands.end(); ++i) {
+          std::string cmd = *i;
+          this->LocalGenerator->ExpandRuleVariables(cmd, vars);
+          real_link_commands.push_back(cmd);
+        }
+      }
+      // Finish the archive.
+      vars.Objects = "";
+      for (std::vector<std::string>::const_iterator i =
+             archiveFinishCommands.begin();
+           i != archiveFinishCommands.end(); ++i) {
         std::string cmd = *i;
         this->LocalGenerator->ExpandRuleVariables(cmd, vars);
         real_link_commands.push_back(cmd);
-        }
-      }
-    // Finish the archive.
-    vars.Objects = "";
-    for(std::vector<std::string>::const_iterator
-          i = archiveFinishCommands.begin();
-        i != archiveFinishCommands.end(); ++i)
-      {
-      std::string cmd = *i;
-      this->LocalGenerator->ExpandRuleVariables(cmd, vars);
-      real_link_commands.push_back(cmd);
       }
-    }
-  else
-    {
-    // Get the set of commands.
-    std::string linkRule = this->GetLinkRule(linkRuleVar);
-    cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
-
-    // Expand placeholders.
-    for(std::vector<std::string>::iterator i = real_link_commands.begin();
-        i != real_link_commands.end(); ++i)
-      {
-      this->LocalGenerator->ExpandRuleVariables(*i, vars);
+    } else {
+      // Get the set of commands.
+      std::string linkRule = this->GetLinkRule(linkRuleVar);
+      cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
+
+      // Expand placeholders.
+      for (std::vector<std::string>::iterator i = real_link_commands.begin();
+           i != real_link_commands.end(); ++i) {
+        this->LocalGenerator->ExpandRuleVariables(*i, vars);
       }
     }
-  this->LocalGenerator->TargetImplib = "";
+    this->LocalGenerator->TargetImplib = "";
 
-  // Restore path conversion to normal shells.
-  this->LocalGenerator->SetLinkScriptShell(false);
+    // Restore path conversion to normal shells.
+    this->LocalGenerator->SetLinkScriptShell(false);
   }
 
   // Optionally convert the build rule to use a script to avoid long
   // command lines in the make shell.
-  if(useLinkScript)
-    {
+  if (useLinkScript) {
     // Use a link script.
-    const char* name = (relink? "relink.txt" : "link.txt");
+    const char* name = (relink ? "relink.txt" : "link.txt");
     this->CreateLinkScript(name, real_link_commands, commands1, depends);
-    }
-  else
-    {
+  } else {
     // No link script.  Just use the link rule directly.
     commands1 = real_link_commands;
-    }
-  this->LocalGenerator->CreateCDCommand
-    (commands1,
-     this->Makefile->GetCurrentBinaryDirectory(),
-     cmLocalGenerator::HOME_OUTPUT);
+  }
+  this->LocalGenerator->CreateCDCommand(
+    commands1, this->Makefile->GetCurrentBinaryDirectory(),
+    cmOutputConverter::HOME_OUTPUT);
   commands.insert(commands.end(), commands1.begin(), commands1.end());
   commands1.clear();
 
   // Add a rule to create necessary symlinks for the library.
   // Frameworks are handled by cmOSXBundleGenerator.
-  if(targetOutPath != targetOutPathReal
-     && !this->GeneratorTarget->IsFrameworkOnApple())
-    {
+  if (targetOutPath != targetOutPathReal &&
+      !this->GeneratorTarget->IsFrameworkOnApple()) {
     std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library ";
     symlink += targetOutPathReal;
     symlink += " ";
@@ -803,75 +723,36 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     symlink += " ";
     symlink += targetOutPath;
     commands1.push_back(symlink);
-    this->LocalGenerator->CreateCDCommand(commands1,
-                                  this->Makefile->GetCurrentBinaryDirectory(),
-                                  cmLocalGenerator::HOME_OUTPUT);
+    this->LocalGenerator->CreateCDCommand(
+      commands1, this->Makefile->GetCurrentBinaryDirectory(),
+      cmOutputConverter::HOME_OUTPUT);
     commands.insert(commands.end(), commands1.begin(), commands1.end());
     commands1.clear();
-    }
+  }
   // Add the post-build rules when building but not when relinking.
-  if(!relink)
-    {
-    this->LocalGenerator->
-      AppendCustomCommands(commands,
-                       this->GeneratorTarget->GetPostBuildCommands(),
-                       this->GeneratorTarget);
-    }
+  if (!relink) {
+    this->LocalGenerator->AppendCustomCommands(
+      commands, this->GeneratorTarget->GetPostBuildCommands(),
+      this->GeneratorTarget);
+  }
 
   // Compute the list of outputs.
   std::vector<std::string> outputs(1, targetFullPathReal);
-  if(targetNameSO != targetNameReal)
-    {
+  if (targetNameSO != targetNameReal) {
     outputs.push_back(targetFullPathSO);
-    }
-  if(targetName != targetNameSO &&
-     targetName != targetNameReal)
-    {
+  }
+  if (targetName != targetNameSO && targetName != targetNameReal) {
     outputs.push_back(targetFullPath);
-    }
+  }
 
   // Write the build rule.
-  this->WriteMakeRule(*this->BuildFileStream, 0, outputs,
-                      depends, commands, false);
+  this->WriteMakeRule(*this->BuildFileStream, 0, outputs, depends, commands,
+                      false);
 
   // Write the main driver rule to build everything in this target.
   this->WriteTargetDriverRule(targetFullPath, relink);
 
   // Clean all the possible library names and symlinks.
-  this->CleanFiles.insert(this->CleanFiles.end(),
-                          libCleanFiles.begin(),libCleanFiles.end());
-}
-
-//----------------------------------------------------------------------------
-void
-cmMakefileLibraryTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const std::string& lang,
-                   const char* name, bool so)
-{
-  // Lookup the flag to specify the version.
-  std::string fvar = "CMAKE_";
-  fvar += lang;
-  fvar += "_OSX_";
-  fvar += name;
-  fvar += "_VERSION_FLAG";
-  const char* flag = this->Makefile->GetDefinition(fvar);
-
-  // Skip if no such flag.
-  if(!flag)
-    {
-    return;
-    }
-
-  // Lookup the target version information.
-  int major;
-  int minor;
-  int patch;
-  this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
-  if(major > 0 || minor > 0 || patch > 0)
-    {
-    // Append the flag since a non-zero version is specified.
-    std::ostringstream vflag;
-    vflag << flag << major << "." << minor << "." << patch;
-    this->LocalGenerator->AppendFlags(flags, vflag.str());
-    }
+  this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(),
+                          libCleanFiles.end());
 }
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 68980c3..f72dbd7 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -14,8 +14,7 @@
 
 #include "cmMakefileTargetGenerator.h"
 
-class cmMakefileLibraryTargetGenerator:
-  public cmMakefileTargetGenerator
+class cmMakefileLibraryTargetGenerator : public cmMakefileTargetGenerator
 {
 public:
   cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target);
@@ -31,16 +30,12 @@ protected:
   void WriteSharedLibraryRules(bool relink);
   void WriteModuleLibraryRules(bool relink);
   void WriteLibraryRules(const std::string& linkRule,
-                         const std::string& extraFlags,
-                         bool relink);
+                         const std::string& extraFlags, bool relink);
   // MacOSX Framework support methods
   void WriteFrameworkRules(bool relink);
 
   // Store the computd framework version for OS X Frameworks.
   std::string FrameworkVersion;
-
-  void AppendOSXVerFlag(std::string& flags, const std::string& lang,
-                        const char* name, bool so);
 };
 
 #endif
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index eedc6ab..93f9e49 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -11,19 +11,19 @@
 ============================================================================*/
 #include "cmMakefileTargetGenerator.h"
 
-#include "cmGeneratorTarget.h"
+#include "cmAlgorithms.h"
+#include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
 #include "cmGlobalGenerator.h"
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
-#include "cmake.h"
 #include "cmState.h"
-#include "cmComputeLinkInformation.h"
-#include "cmCustomCommandGenerator.h"
-#include "cmGeneratorExpression.h"
-#include "cmAlgorithms.h"
+#include "cmake.h"
 
 #include "cmMakefileExecutableTargetGenerator.h"
 #include "cmMakefileLibraryTargetGenerator.h"
@@ -42,16 +42,14 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
   this->CustomCommandDriver = OnBuild;
   this->LocalGenerator =
     static_cast<cmLocalUnixMakefileGenerator3*>(target->GetLocalGenerator());
-  this->GlobalGenerator =
-    static_cast<cmGlobalUnixMakefileGenerator3*>(
-      this->LocalGenerator->GetGlobalGenerator());
+  this->GlobalGenerator = static_cast<cmGlobalUnixMakefileGenerator3*>(
+    this->LocalGenerator->GetGlobalGenerator());
   cmake* cm = this->GlobalGenerator->GetCMakeInstance();
   this->NoRuleMessages = false;
-  if(const char* ruleStatus = cm->GetState()
-                                ->GetGlobalProperty("RULE_MESSAGES"))
-    {
+  if (const char* ruleStatus =
+        cm->GetState()->GetGlobalProperty("RULE_MESSAGES")) {
     this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus);
-    }
+  }
   MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
 }
 
@@ -60,13 +58,12 @@ cmMakefileTargetGenerator::~cmMakefileTargetGenerator()
   delete MacOSXContentGenerator;
 }
 
-cmMakefileTargetGenerator *
-cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt)
+cmMakefileTargetGenerator* cmMakefileTargetGenerator::New(
+  cmGeneratorTarget* tgt)
 {
-  cmMakefileTargetGenerator *result = 0;
+  cmMakefileTargetGenerator* result = 0;
 
-  switch (tgt->GetType())
-    {
+  switch (tgt->GetType()) {
     case cmState::EXECUTABLE:
       result = new cmMakefileExecutableTargetGenerator(tgt);
       break;
@@ -82,11 +79,10 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt)
     default:
       return result;
       // break; /* unreachable */
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::CreateRuleFile()
 {
   // Create a directory for this target.
@@ -114,23 +110,20 @@ void cmMakefileTargetGenerator::CreateRuleFile()
   this->BuildFileStream =
     new cmGeneratedFileStream(this->BuildFileNameFull.c_str());
   this->BuildFileStream->SetCopyIfDifferent(true);
-  if(!this->BuildFileStream)
-    {
+  if (!this->BuildFileStream) {
     return;
-    }
+  }
   this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream);
-  if (this->GlobalGenerator->AllowDeleteOnError())
-    {
+  if (this->GlobalGenerator->AllowDeleteOnError()) {
     std::vector<std::string> no_depends;
     std::vector<std::string> no_commands;
     this->LocalGenerator->WriteMakeRule(
       *this->BuildFileStream, "Delete rule output on recipe failure.",
       ".DELETE_ON_ERROR", no_depends, no_commands, false);
-    }
+  }
   this->LocalGenerator->WriteSpecialTargetsTop(*this->BuildFileStream);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteTargetBuildRules()
 {
   const std::string& config =
@@ -138,85 +131,71 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
 
   // 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"))
-    {
+  if (const char* additional_clean_files =
+        this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) {
     cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
-                                            ge.Parse(additional_clean_files);
-
-    cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator,
-                                                    config,
-                                                    false,
-                                                    this->GeneratorTarget,
-                                                    0, 0),
-                                      this->CleanFiles);
-    }
+      ge.Parse(additional_clean_files);
+
+    cmSystemTools::ExpandListArgument(
+      cge->Evaluate(this->LocalGenerator, config, false, this->GeneratorTarget,
+                    0, 0),
+      this->CleanFiles);
+  }
 
   // add custom commands to the clean rules?
-  const char* clean_no_custom =
-    this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
+  const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
   bool clean = cmSystemTools::IsOff(clean_no_custom);
 
   // First generate the object rule files.  Save a list of all object
   // files for this target.
   std::vector<cmSourceFile const*> customCommands;
   this->GeneratorTarget->GetCustomCommands(customCommands, config);
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = customCommands.begin();
-      si != customCommands.end(); ++si)
-    {
-    cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
-                                 this->ConfigName,
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         customCommands.begin();
+       si != customCommands.end(); ++si) {
+    cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(), this->ConfigName,
                                  this->LocalGenerator);
     this->GenerateCustomRuleFile(ccg);
-    if (clean)
-      {
+    if (clean) {
       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,
-                         cmLocalGenerator::START_OUTPUT,
-                         cmLocalGenerator::UNCHANGED));
-        }
+      for (std::vector<std::string>::const_iterator o = outputs.begin();
+           o != outputs.end(); ++o) {
+        this->CleanFiles.push_back(this->Convert(
+          *o, cmOutputConverter::START_OUTPUT, cmOutputConverter::UNCHANGED));
       }
     }
+  }
   std::vector<cmSourceFile const*> headerSources;
   this->GeneratorTarget->GetHeaderSources(headerSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
-    headerSources,
-    this->MacOSXContentGenerator);
+    headerSources, this->MacOSXContentGenerator);
   std::vector<cmSourceFile const*> extraSources;
   this->GeneratorTarget->GetExtraSources(extraSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
-    extraSources,
-    this->MacOSXContentGenerator);
+    extraSources, this->MacOSXContentGenerator);
   std::vector<cmSourceFile const*> externalObjects;
   this->GeneratorTarget->GetExternalObjects(externalObjects, config);
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = externalObjects.begin();
-      si != externalObjects.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         externalObjects.begin();
+       si != externalObjects.end(); ++si) {
     this->ExternalObjects.push_back((*si)->GetFullPath());
-    }
+  }
   std::vector<cmSourceFile const*> objectSources;
   this->GeneratorTarget->GetObjectSources(objectSources, config);
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = objectSources.begin(); si != objectSources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         objectSources.begin();
+       si != objectSources.end(); ++si) {
     // Generate this object file's rule file.
     this->WriteObjectRuleFiles(**si);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteCommonCodeRules()
 {
-  const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")?
-                      "$(CMAKE_BINARY_DIR)/" : "");
+  const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")
+                        ? "$(CMAKE_BINARY_DIR)/"
+                        : "");
 
   // Include the dependencies for the target.
   std::string dependFileNameFull = this->TargetBuildDirectoryFull;
@@ -224,33 +203,30 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
   *this->BuildFileStream
     << "# Include any dependencies generated for this target.\n"
     << this->GlobalGenerator->IncludeDirective << " " << root
-    << this->Convert(dependFileNameFull,
-                     cmLocalGenerator::HOME_OUTPUT,
-                     cmLocalGenerator::MAKERULE)
+    << this->Convert(dependFileNameFull, cmOutputConverter::HOME_OUTPUT,
+                     cmOutputConverter::MAKERULE)
     << "\n\n";
 
-  if(!this->NoRuleMessages)
-    {
+  if (!this->NoRuleMessages) {
     // Include the progress variables for the target.
     *this->BuildFileStream
       << "# Include the progress variables for this target.\n"
       << this->GlobalGenerator->IncludeDirective << " " << root
       << this->Convert(this->ProgressFileNameFull,
-                       cmLocalGenerator::HOME_OUTPUT,
-                       cmLocalGenerator::MAKERULE)
+                       cmOutputConverter::HOME_OUTPUT,
+                       cmOutputConverter::MAKERULE)
       << "\n\n";
-    }
+  }
 
   // make sure the depend file exists
-  if (!cmSystemTools::FileExists(dependFileNameFull.c_str()))
-    {
+  if (!cmSystemTools::FileExists(dependFileNameFull.c_str())) {
     // Write an empty dependency file.
     cmGeneratedFileStream depFileStream(dependFileNameFull.c_str());
-    depFileStream
-      << "# Empty dependencies file for "
-      << this->GeneratorTarget->GetName() << ".\n"
-      << "# This may be replaced when dependencies are built." << std::endl;
-    }
+    depFileStream << "# Empty dependencies file for "
+                  << this->GeneratorTarget->GetName() << ".\n"
+                  << "# This may be replaced when dependencies are built."
+                  << std::endl;
+  }
 
   // Open the flags file.  This should be copy-if-different because the
   // rules may depend on this file itself.
@@ -259,19 +235,17 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
   this->FlagFileStream =
     new cmGeneratedFileStream(this->FlagFileNameFull.c_str());
   this->FlagFileStream->SetCopyIfDifferent(true);
-  if(!this->FlagFileStream)
-    {
+  if (!this->FlagFileStream) {
     return;
-    }
+  }
   this->LocalGenerator->WriteDisclaimer(*this->FlagFileStream);
 
   // Include the flags for the target.
   *this->BuildFileStream
     << "# Include the compile flags for this target's objects.\n"
     << this->GlobalGenerator->IncludeDirective << " " << root
-    << this->Convert(this->FlagFileNameFull,
-                                     cmLocalGenerator::HOME_OUTPUT,
-                                     cmLocalGenerator::MAKERULE)
+    << this->Convert(this->FlagFileNameFull, cmOutputConverter::HOME_OUTPUT,
+                     cmOutputConverter::MAKERULE)
     << "\n\n";
 }
 
@@ -279,23 +253,22 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
 {
   // write language flags for target
   std::set<std::string> languages;
-  this->GeneratorTarget->GetLanguages(languages,
-                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  this->GeneratorTarget->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<std::string>::const_iterator l = languages.begin();
-      l != languages.end(); ++l)
-    {
+  for (std::set<std::string>::const_iterator l = languages.begin();
+       l != languages.end(); ++l) {
     std::string compiler = "CMAKE_";
     compiler += *l;
     compiler += "_COMPILER";
-    *this->FlagFileStream << "# compile " << *l << " with " <<
-      this->Makefile->GetSafeDefinition(compiler) << "\n";
-    }
+    *this->FlagFileStream << "# compile " << *l << " with "
+                          << this->Makefile->GetSafeDefinition(compiler)
+                          << "\n";
+  }
 
-  for(std::set<std::string>::const_iterator l = languages.begin();
-      l != languages.end(); ++l)
-    {
+  for (std::set<std::string>::const_iterator l = languages.begin();
+       l != languages.end(); ++l) {
     std::string flags = this->GetFlags(*l);
     std::string defines = this->GetDefines(*l);
     std::string includes = this->GetIncludes(*l);
@@ -306,36 +279,30 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
     *this->FlagFileStream << *l << "_FLAGS = " << flags << "\n\n";
     *this->FlagFileStream << *l << "_DEFINES = " << defines << "\n\n";
     *this->FlagFileStream << *l << "_INCLUDES = " << includes << "\n\n";
-    }
+  }
 }
 
-
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
-  (cmSourceFile const& source, const char* pkgloc)
+void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
+  cmSourceFile const& source, const char* pkgloc)
 {
   // Skip OS X content when not building a Framework or Bundle.
-  if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple())
-    {
+  if (!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) {
     return;
-    }
+  }
 
   std::string macdir =
     this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc);
 
   // Get the input file location.
-  std::string input = source.GetFullPath();
+  std::string const& input = source.GetFullPath();
 
   // Get the output file location.
   std::string output = macdir;
   output += "/";
   output += cmSystemTools::GetFilenameName(input);
   this->Generator->CleanFiles.push_back(
-    this->Generator->Convert(output,
-                             cmLocalGenerator::START_OUTPUT));
-  output = this->Generator->Convert(output,
-                                    cmLocalGenerator::HOME_OUTPUT);
+    this->Generator->Convert(output, cmOutputConverter::START_OUTPUT));
+  output = this->Generator->Convert(output, cmOutputConverter::HOME_OUTPUT);
 
   // Create a rule to copy the content into the bundle.
   std::vector<std::string> depends;
@@ -344,76 +311,64 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
   std::string copyEcho = "Copying OS X content ";
   copyEcho += output;
   this->Generator->LocalGenerator->AppendEcho(
-    commands, copyEcho.c_str(),
-    cmLocalUnixMakefileGenerator3::EchoBuild);
+    commands, copyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
   std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
-  copyCommand += this->Generator->Convert(input,
-                                          cmLocalGenerator::NONE,
-                                          cmLocalGenerator::SHELL);
+  copyCommand += this->Generator->Convert(input, cmOutputConverter::NONE,
+                                          cmOutputConverter::SHELL);
   copyCommand += " ";
-  copyCommand += this->Generator->Convert(output,
-                                          cmLocalGenerator::NONE,
-                                          cmLocalGenerator::SHELL);
+  copyCommand += this->Generator->Convert(output, cmOutputConverter::NONE,
+                                          cmOutputConverter::SHELL);
   commands.push_back(copyCommand);
   this->Generator->LocalGenerator->WriteMakeRule(
-    *this->Generator->BuildFileStream, 0,
-    output,
-    depends, commands, false);
+    *this->Generator->BuildFileStream, 0, output, depends, commands, false);
   this->Generator->ExtraFiles.insert(output);
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::WriteObjectRuleFiles(cmSourceFile const& source)
+void cmMakefileTargetGenerator::WriteObjectRuleFiles(
+  cmSourceFile const& source)
 {
   // Identify the language of the source file.
   const std::string& lang =
     this->LocalGenerator->GetSourceFileLanguage(source);
-  if(lang.empty())
-    {
+  if (lang.empty()) {
     // don't know anything about this file so skip it
     return;
-    }
+  }
 
   // Get the full path name of the object file.
-  std::string const& objectName = this->GeneratorTarget
-                                      ->GetObjectName(&source);
+  std::string const& objectName =
+    this->GeneratorTarget->GetObjectName(&source);
   std::string obj =
-      this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+    this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   obj += "/";
   obj += objectName;
 
   // Avoid generating duplicate rules.
-  if(this->ObjectFiles.find(obj) == this->ObjectFiles.end())
-    {
+  if (this->ObjectFiles.find(obj) == this->ObjectFiles.end()) {
     this->ObjectFiles.insert(obj);
-    }
-  else
-    {
+  } else {
     std::ostringstream err;
-    err << "Warning: Source file \""
-        << source.GetFullPath()
+    err << "Warning: Source file \"" << source.GetFullPath()
         << "\" is listed multiple times for target \""
-        << this->GeneratorTarget->GetName()
-        << "\".";
+        << this->GeneratorTarget->GetName() << "\".";
     cmSystemTools::Message(err.str().c_str(), "Warning");
     return;
-    }
+  }
 
   // Create the directory containing the object file.  This may be a
   // subdirectory under the target's directory.
   std::string dir = cmSystemTools::GetFilenamePath(obj);
-  cmSystemTools::MakeDirectory
-    (this->LocalGenerator->ConvertToFullPath(dir).c_str());
+  cmSystemTools::MakeDirectory(
+    this->LocalGenerator->ConvertToFullPath(dir).c_str());
 
   // Save this in the target's list of object files.
   this->Objects.push_back(obj);
   this->CleanFiles.push_back(obj);
 
   // TODO: Remove
-  //std::string relativeObj
+  // std::string relativeObj
   //= this->LocalGenerator->GetHomeRelativeOutputPath();
-  //relativeObj += obj;
+  // relativeObj += obj;
 
   // we compute some depends when writing the depend.make that we will also
   // use in the build.make, same with depMakeFile
@@ -426,23 +381,16 @@ void cmMakefileTargetGenerator
   std::string objFullPath = this->LocalGenerator->GetCurrentBinaryDirectory();
   objFullPath += "/";
   objFullPath += obj;
-  objFullPath =
-    this->Convert(objFullPath, cmLocalGenerator::FULL);
+  objFullPath = this->Convert(objFullPath, cmOutputConverter::FULL);
   std::string srcFullPath =
-    this->Convert(source.GetFullPath(), cmLocalGenerator::FULL);
-  this->LocalGenerator->
-    AddImplicitDepends(this->GeneratorTarget, lang,
-                       objFullPath.c_str(),
-                       srcFullPath.c_str());
+    this->Convert(source.GetFullPath(), cmOutputConverter::FULL);
+  this->LocalGenerator->AddImplicitDepends(
+    this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str());
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::WriteObjectBuildFile(std::string &obj,
-                       const std::string& lang,
-                       cmSourceFile const& source,
-                       std::vector<std::string>& depends)
+void cmMakefileTargetGenerator::WriteObjectBuildFile(
+  std::string& obj, const std::string& lang, cmSourceFile const& source,
+  std::vector<std::string>& depends)
 {
   this->LocalGenerator->AppendRuleDepend(depends,
                                          this->FlagFileNameFull.c_str());
@@ -469,52 +417,43 @@ cmMakefileTargetGenerator
     cmSystemTools::UpperCase(this->LocalGenerator->GetConfigName());
 
   // Add Fortran format flags.
-  if(lang == "Fortran")
-    {
+  if (lang == "Fortran") {
     this->AppendFortranFormatFlags(flags, source);
-    }
+  }
 
   // Add flags from source file properties.
-  if (source.GetProperty("COMPILE_FLAGS"))
-    {
-    this->LocalGenerator->AppendFlags
-      (flags, source.GetProperty("COMPILE_FLAGS"));
-    *this->FlagFileStream << "# Custom flags: "
-                          << relativeObj << "_FLAGS = "
-                          << source.GetProperty("COMPILE_FLAGS")
+  if (source.GetProperty("COMPILE_FLAGS")) {
+    this->LocalGenerator->AppendFlags(flags,
+                                      source.GetProperty("COMPILE_FLAGS"));
+    *this->FlagFileStream << "# Custom flags: " << relativeObj
+                          << "_FLAGS = " << source.GetProperty("COMPILE_FLAGS")
                           << "\n"
                           << "\n";
-    }
+  }
 
   // Add language-specific defines.
   std::set<std::string> defines;
 
   // Add source-sepcific preprocessor definitions.
-  if(const char* compile_defs = source.GetProperty("COMPILE_DEFINITIONS"))
-    {
+  if (const char* compile_defs = source.GetProperty("COMPILE_DEFINITIONS")) {
     this->LocalGenerator->AppendDefines(defines, compile_defs);
-    *this->FlagFileStream << "# Custom defines: "
-                          << relativeObj << "_DEFINES = "
-                          << compile_defs << "\n"
+    *this->FlagFileStream << "# Custom defines: " << relativeObj
+                          << "_DEFINES = " << compile_defs << "\n"
                           << "\n";
-    }
+  }
   std::string defPropName = "COMPILE_DEFINITIONS_";
   defPropName += configUpper;
-  if(const char* config_compile_defs =
-     source.GetProperty(defPropName))
-    {
+  if (const char* config_compile_defs = source.GetProperty(defPropName)) {
     this->LocalGenerator->AppendDefines(defines, config_compile_defs);
-    *this->FlagFileStream
-      << "# Custom defines: "
-      << relativeObj << "_DEFINES_" << configUpper
-      << " = " << config_compile_defs << "\n"
-      << "\n";
-    }
+    *this->FlagFileStream << "# Custom defines: " << relativeObj << "_DEFINES_"
+                          << configUpper << " = " << config_compile_defs
+                          << "\n"
+                          << "\n";
+  }
 
   // Get the output paths for source and object files.
-  std::string sourceFile = this->Convert(source.GetFullPath(),
-                             cmLocalGenerator::NONE,
-                             cmLocalGenerator::SHELL);
+  std::string sourceFile = this->Convert(
+    source.GetFullPath(), cmOutputConverter::NONE, cmOutputConverter::SHELL);
 
   // Construct the build message.
   std::vector<std::string> no_commands;
@@ -523,67 +462,60 @@ cmMakefileTargetGenerator
   // add in a progress call if needed
   this->NumberOfProgressActions++;
 
-  if(!this->NoRuleMessages)
-    {
+  if (!this->NoRuleMessages) {
     cmLocalUnixMakefileGenerator3::EchoProgress progress;
     this->MakeEchoProgress(progress);
     std::string buildEcho = "Building ";
     buildEcho += lang;
     buildEcho += " object ";
     buildEcho += relativeObj;
-    this->LocalGenerator->AppendEcho
-      (commands, buildEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild,
-       &progress);
-    }
+    this->LocalGenerator->AppendEcho(commands, buildEcho,
+                                     cmLocalUnixMakefileGenerator3::EchoBuild,
+                                     &progress);
+  }
 
   std::string targetOutPathReal;
   std::string targetOutPathPDB;
   std::string targetOutPathCompilePDB;
   {
-  std::string targetFullPathReal;
-  std::string targetFullPathPDB;
-  std::string targetFullPathCompilePDB;
-  if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
-     this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
-     this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
-     this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY)
-    {
-    targetFullPathReal =
-      this->GeneratorTarget->GetFullPath(this->ConfigName, false, true);
-    targetFullPathPDB =
+    std::string targetFullPathReal;
+    std::string targetFullPathPDB;
+    std::string targetFullPathCompilePDB;
+    if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
+        this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
+        this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+        this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
+      targetFullPathReal =
+        this->GeneratorTarget->GetFullPath(this->ConfigName, false, true);
+      targetFullPathPDB =
         this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
-    targetFullPathPDB += "/";
-    targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName);
+      targetFullPathPDB += "/";
+      targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName);
     }
-  if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
-    {
-    targetFullPathCompilePDB =
-      this->GeneratorTarget->GetCompilePDBPath(this->ConfigName);
-    if(targetFullPathCompilePDB.empty())
-      {
+    if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
       targetFullPathCompilePDB =
+        this->GeneratorTarget->GetCompilePDBPath(this->ConfigName);
+      if (targetFullPathCompilePDB.empty()) {
+        targetFullPathCompilePDB =
           this->GeneratorTarget->GetSupportDirectory() + "/";
       }
     }
 
-  targetOutPathReal = this->Convert(targetFullPathReal,
-                                    cmLocalGenerator::START_OUTPUT,
-                                    cmLocalGenerator::SHELL);
-  targetOutPathPDB =
-    this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
-                  cmLocalGenerator::SHELL);
-  targetOutPathCompilePDB =
-    this->Convert(targetFullPathCompilePDB,
-                  cmLocalGenerator::START_OUTPUT,
-                  cmLocalGenerator::SHELL);
-
-  if (this->LocalGenerator->IsMinGWMake() &&
-      cmHasLiteralSuffix(targetOutPathCompilePDB, "\\"))
-    {
-    // mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c'
-    // (but 'a\ b "c"' as 'a\', 'b', and 'c'!).  Workaround this by
-    // avoiding a trailing backslash in the argument.
-    targetOutPathCompilePDB[targetOutPathCompilePDB.size()-1] = '/';
+    targetOutPathReal =
+      this->Convert(targetFullPathReal, cmOutputConverter::START_OUTPUT,
+                    cmOutputConverter::SHELL);
+    targetOutPathPDB = this->Convert(
+      targetFullPathPDB, cmOutputConverter::NONE, cmOutputConverter::SHELL);
+    targetOutPathCompilePDB =
+      this->Convert(targetFullPathCompilePDB, cmOutputConverter::START_OUTPUT,
+                    cmOutputConverter::SHELL);
+
+    if (this->LocalGenerator->IsMinGWMake() &&
+        cmHasLiteralSuffix(targetOutPathCompilePDB, "\\")) {
+      // mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c'
+      // (but 'a\ b "c"' as 'a\', 'b', and 'c'!).  Workaround this by
+      // avoiding a trailing backslash in the argument.
+      targetOutPathCompilePDB[targetOutPathCompilePDB.size() - 1] = '/';
     }
   }
   cmLocalGenerator::RuleVariables vars;
@@ -595,19 +527,15 @@ cmMakefileTargetGenerator
   vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
   vars.Source = sourceFile.c_str();
   std::string shellObj =
-    this->Convert(obj,
-                  cmLocalGenerator::NONE,
-                  cmLocalGenerator::SHELL);
+    this->Convert(obj, cmOutputConverter::NONE, cmOutputConverter::SHELL);
   vars.Object = shellObj.c_str();
   std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
-  objectDir = this->Convert(objectDir,
-                            cmLocalGenerator::START_OUTPUT,
-                            cmLocalGenerator::SHELL);
+  objectDir = this->Convert(objectDir, cmOutputConverter::START_OUTPUT,
+                            cmOutputConverter::SHELL);
   vars.ObjectDir = objectDir.c_str();
   std::string objectFileDir = cmSystemTools::GetFilenamePath(obj);
-  objectFileDir = this->Convert(objectFileDir,
-                                cmLocalGenerator::START_OUTPUT,
-                                cmLocalGenerator::SHELL);
+  objectFileDir = this->Convert(objectFileDir, cmOutputConverter::START_OUTPUT,
+                                cmOutputConverter::SHELL);
   vars.ObjectFileDir = objectFileDir.c_str();
   vars.Flags = flags.c_str();
 
@@ -625,122 +553,120 @@ cmMakefileTargetGenerator
   // At the moment, it is assumed that C, C++, and Fortran have both
   // assembly and preprocessor capabilities. The same is true for the
   // ability to export compile commands
-  bool lang_has_preprocessor = ((lang == "C") ||
-                                (lang == "CXX") ||
-                                (lang == "Fortran"));
+  bool lang_has_preprocessor =
+    ((lang == "C") || (lang == "CXX") || (lang == "Fortran"));
   bool const lang_has_assembly = lang_has_preprocessor;
   bool const lang_can_export_cmds = lang_has_preprocessor;
 
   // Construct the compile rules.
   {
-  std::string compileRuleVar = "CMAKE_";
-  compileRuleVar += lang;
-  compileRuleVar += "_COMPILE_OBJECT";
-  std::string compileRule =
-    this->Makefile->GetRequiredDefinition(compileRuleVar);
-  std::vector<std::string> compileCommands;
-  cmSystemTools::ExpandListArgument(compileRule, compileCommands);
-
-  if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
-      lang_can_export_cmds && compileCommands.size() == 1)
-    {
-    std::string compileCommand = compileCommands[0];
-    this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);
-    std::string workingDirectory =
-      this->LocalGenerator->Convert(
+    std::string compileRuleVar = "CMAKE_";
+    compileRuleVar += lang;
+    compileRuleVar += "_COMPILE_OBJECT";
+    std::string compileRule =
+      this->Makefile->GetRequiredDefinition(compileRuleVar);
+    std::vector<std::string> compileCommands;
+    cmSystemTools::ExpandListArgument(compileRule, compileCommands);
+
+    if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
+        lang_can_export_cmds && compileCommands.size() == 1) {
+      std::string compileCommand = compileCommands[0];
+      this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);
+      std::string workingDirectory = this->LocalGenerator->Convert(
         this->LocalGenerator->GetCurrentBinaryDirectory(),
-                                    cmLocalGenerator::FULL);
-    compileCommand.replace(compileCommand.find(langFlags),
-                           langFlags.size(), this->GetFlags(lang));
-    std::string langDefines = std::string("$(") + lang + "_DEFINES)";
-    compileCommand.replace(compileCommand.find(langDefines),
-                           langDefines.size(), this->GetDefines(lang));
-    std::string langIncludes = std::string("$(") + lang + "_INCLUDES)";
-    compileCommand.replace(compileCommand.find(langIncludes),
-                           langIncludes.size(), this->GetIncludes(lang));
-    this->GlobalGenerator->AddCXXCompileCommand(
-      source.GetFullPath(), workingDirectory, compileCommand);
-    }
-
-  // Maybe insert an include-what-you-use runner.
-  if (!compileCommands.empty() && (lang == "C" || lang == "CXX"))
-    {
-    std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
-    const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
-    if (iwyu && *iwyu)
-      {
-      std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_iwyu --iwyu=";
-      run_iwyu += this->LocalGenerator->EscapeForShell(iwyu);
-      run_iwyu += " -- ";
-      compileCommands.front().insert(0, run_iwyu);
+        cmOutputConverter::FULL);
+      compileCommand.replace(compileCommand.find(langFlags), langFlags.size(),
+                             this->GetFlags(lang));
+      std::string langDefines = std::string("$(") + lang + "_DEFINES)";
+      compileCommand.replace(compileCommand.find(langDefines),
+                             langDefines.size(), this->GetDefines(lang));
+      std::string langIncludes = std::string("$(") + lang + "_INCLUDES)";
+      compileCommand.replace(compileCommand.find(langIncludes),
+                             langIncludes.size(), this->GetIncludes(lang));
+      this->GlobalGenerator->AddCXXCompileCommand(
+        source.GetFullPath(), workingDirectory, compileCommand);
+    }
+
+    // Maybe insert an include-what-you-use runner.
+    if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) {
+      std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
+      const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
+      std::string const tidy_prop = lang + "_CLANG_TIDY";
+      const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+      if ((iwyu && *iwyu) || (tidy && *tidy)) {
+        std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_iwyu";
+        if (iwyu && *iwyu) {
+          run_iwyu += " --iwyu=";
+          run_iwyu += this->LocalGenerator->EscapeForShell(iwyu);
+        }
+        if (tidy && *tidy) {
+          run_iwyu += " --tidy=";
+          run_iwyu += this->LocalGenerator->EscapeForShell(tidy);
+          run_iwyu += " --source=";
+          run_iwyu += sourceFile;
+        }
+        run_iwyu += " -- ";
+        compileCommands.front().insert(0, run_iwyu);
       }
     }
 
-  // Maybe insert a compiler launcher like ccache or distcc
-  if (!compileCommands.empty() && (lang == "C" || lang == "CXX"))
-    {
-    std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
-    const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
-    if (clauncher && *clauncher)
-      {
-      std::vector<std::string> launcher_cmd;
-      cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
-      for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
-             e = launcher_cmd.end(); i != e; ++i)
-        {
-        *i = this->LocalGenerator->EscapeForShell(*i);
+    // Maybe insert a compiler launcher like ccache or distcc
+    if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) {
+      std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
+      const char* clauncher =
+        this->GeneratorTarget->GetProperty(clauncher_prop);
+      if (clauncher && *clauncher) {
+        std::vector<std::string> launcher_cmd;
+        cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
+        for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
+                                                e = launcher_cmd.end();
+             i != e; ++i) {
+          *i = this->LocalGenerator->EscapeForShell(*i);
         }
-      std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
-      compileCommands.front().insert(0, run_launcher);
+        std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
+        compileCommands.front().insert(0, run_launcher);
       }
     }
 
-  // Expand placeholders in the commands.
-  for(std::vector<std::string>::iterator i = compileCommands.begin();
-      i != compileCommands.end(); ++i)
-    {
-    this->LocalGenerator->ExpandRuleVariables(*i, vars);
+    // Expand placeholders in the commands.
+    for (std::vector<std::string>::iterator i = compileCommands.begin();
+         i != compileCommands.end(); ++i) {
+      this->LocalGenerator->ExpandRuleVariables(*i, vars);
     }
 
-  // Change the command working directory to the local build tree.
-  this->LocalGenerator->CreateCDCommand
-    (compileCommands,
-     this->LocalGenerator->GetCurrentBinaryDirectory(),
-     cmLocalGenerator::HOME_OUTPUT);
-  commands.insert(commands.end(),
-                  compileCommands.begin(), compileCommands.end());
+    // Change the command working directory to the local build tree.
+    this->LocalGenerator->CreateCDCommand(
+      compileCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
+      cmOutputConverter::HOME_OUTPUT);
+    commands.insert(commands.end(), compileCommands.begin(),
+                    compileCommands.end());
   }
 
   // Check for extra outputs created by the compilation.
   std::vector<std::string> outputs(1, relativeObj);
-  if(const char* extra_outputs_str =
-     source.GetProperty("OBJECT_OUTPUTS"))
-    {
+  if (const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) {
     // Register these as extra files to clean.
     cmSystemTools::ExpandListArgument(extra_outputs_str, outputs);
-    this->CleanFiles.insert(this->CleanFiles.end(),
-                            outputs.begin() + 1, outputs.end());
-    }
+    this->CleanFiles.insert(this->CleanFiles.end(), outputs.begin() + 1,
+                            outputs.end());
+  }
 
   // Write the rule.
-  this->WriteMakeRule(*this->BuildFileStream, 0, outputs,
-                      depends, commands);
+  this->WriteMakeRule(*this->BuildFileStream, 0, outputs, depends, commands);
 
   bool do_preprocess_rules = lang_has_preprocessor &&
     this->LocalGenerator->GetCreatePreprocessedSourceRules();
-  bool do_assembly_rules = lang_has_assembly &&
-    this->LocalGenerator->GetCreateAssemblySourceRules();
-  if(do_preprocess_rules || do_assembly_rules)
-    {
+  bool do_assembly_rules =
+    lang_has_assembly && this->LocalGenerator->GetCreateAssemblySourceRules();
+  if (do_preprocess_rules || do_assembly_rules) {
     std::vector<std::string> force_depends;
     force_depends.push_back("cmake_force");
-    std::string::size_type dot_pos = relativeObj.rfind(".");
+    std::string::size_type dot_pos = relativeObj.rfind('.');
     std::string relativeObjBase = relativeObj.substr(0, dot_pos);
-    dot_pos = obj.rfind(".");
+    dot_pos = obj.rfind('.');
     std::string objBase = obj.substr(0, dot_pos);
 
-    if(do_preprocess_rules)
-      {
+    if (do_preprocess_rules) {
       commands.clear();
       std::string relativeObjI = relativeObjBase + ".i";
       std::string objI = objBase + ".i";
@@ -750,54 +676,44 @@ cmMakefileTargetGenerator
       preprocessEcho += " source to ";
       preprocessEcho += objI;
       this->LocalGenerator->AppendEcho(
-        commands, preprocessEcho.c_str(),
-        cmLocalUnixMakefileGenerator3::EchoBuild
-        );
+        commands, preprocessEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
 
       std::string preprocessRuleVar = "CMAKE_";
       preprocessRuleVar += lang;
       preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE";
-      if(const char* preprocessRule =
-         this->Makefile->GetDefinition(preprocessRuleVar))
-        {
+      if (const char* preprocessRule =
+            this->Makefile->GetDefinition(preprocessRuleVar)) {
         std::vector<std::string> preprocessCommands;
         cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
 
-        std::string shellObjI =
-          this->Convert(objI,
-                        cmLocalGenerator::NONE,
-                        cmLocalGenerator::SHELL);
+        std::string shellObjI = this->Convert(objI, cmOutputConverter::NONE,
+                                              cmOutputConverter::SHELL);
         vars.PreprocessedSource = shellObjI.c_str();
 
         // Expand placeholders in the commands.
-        for(std::vector<std::string>::iterator i = preprocessCommands.begin();
-            i != preprocessCommands.end(); ++i)
-          {
+        for (std::vector<std::string>::iterator i = preprocessCommands.begin();
+             i != preprocessCommands.end(); ++i) {
           this->LocalGenerator->ExpandRuleVariables(*i, vars);
-          }
-
-        this->LocalGenerator->CreateCDCommand
-          (preprocessCommands,
-           this->LocalGenerator->GetCurrentBinaryDirectory(),
-           cmLocalGenerator::HOME_OUTPUT);
-        commands.insert(commands.end(),
-                        preprocessCommands.begin(),
-                        preprocessCommands.end());
         }
-      else
-        {
+
+        this->LocalGenerator->CreateCDCommand(
+          preprocessCommands,
+          this->LocalGenerator->GetCurrentBinaryDirectory(),
+          cmOutputConverter::HOME_OUTPUT);
+        commands.insert(commands.end(), preprocessCommands.begin(),
+                        preprocessCommands.end());
+      } else {
         std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable ";
         cmd += preprocessRuleVar;
         commands.push_back(cmd);
-        }
+      }
 
       this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                          relativeObjI,
-                                          force_depends, commands, false);
-      }
+                                          relativeObjI, force_depends,
+                                          commands, false);
+    }
 
-    if(do_assembly_rules)
-      {
+    if (do_assembly_rules) {
       commands.clear();
       std::string relativeObjS = relativeObjBase + ".s";
       std::string objS = objBase + ".s";
@@ -807,52 +723,42 @@ cmMakefileTargetGenerator
       assemblyEcho += " source to assembly ";
       assemblyEcho += objS;
       this->LocalGenerator->AppendEcho(
-        commands, assemblyEcho.c_str(),
-        cmLocalUnixMakefileGenerator3::EchoBuild
-        );
+        commands, assemblyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
 
       std::string assemblyRuleVar = "CMAKE_";
       assemblyRuleVar += lang;
       assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE";
-      if(const char* assemblyRule =
-         this->Makefile->GetDefinition(assemblyRuleVar))
-        {
+      if (const char* assemblyRule =
+            this->Makefile->GetDefinition(assemblyRuleVar)) {
         std::vector<std::string> assemblyCommands;
         cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
 
-        std::string shellObjS =
-          this->Convert(objS,
-                        cmLocalGenerator::NONE,
-                        cmLocalGenerator::SHELL);
+        std::string shellObjS = this->Convert(objS, cmOutputConverter::NONE,
+                                              cmOutputConverter::SHELL);
         vars.AssemblySource = shellObjS.c_str();
 
         // Expand placeholders in the commands.
-        for(std::vector<std::string>::iterator i = assemblyCommands.begin();
-            i != assemblyCommands.end(); ++i)
-          {
+        for (std::vector<std::string>::iterator i = assemblyCommands.begin();
+             i != assemblyCommands.end(); ++i) {
           this->LocalGenerator->ExpandRuleVariables(*i, vars);
-          }
-
-        this->LocalGenerator->CreateCDCommand
-          (assemblyCommands,
-           this->LocalGenerator->GetCurrentBinaryDirectory(),
-           cmLocalGenerator::HOME_OUTPUT);
-        commands.insert(commands.end(),
-                        assemblyCommands.begin(),
-                        assemblyCommands.end());
         }
-      else
-        {
+
+        this->LocalGenerator->CreateCDCommand(
+          assemblyCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
+          cmOutputConverter::HOME_OUTPUT);
+        commands.insert(commands.end(), assemblyCommands.begin(),
+                        assemblyCommands.end());
+      } else {
         std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable ";
         cmd += assemblyRuleVar;
         commands.push_back(cmd);
-        }
+      }
 
       this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                          relativeObjS,
-                                          force_depends, commands, false);
-      }
+                                          relativeObjS, force_depends,
+                                          commands, false);
     }
+  }
 
   // If the language needs provides-requires mode, create the
   // corresponding targets.
@@ -860,9 +766,8 @@ cmMakefileTargetGenerator
   objectRequires += ".requires";
   std::vector<std::string> p_depends;
   // always provide an empty requires target
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      objectRequires, p_depends,
-                                      no_commands, true);
+  this->LocalGenerator->WriteMakeRule(
+    *this->BuildFileStream, 0, objectRequires, p_depends, no_commands, true);
 
   // write a build rule to recursively build what this obj provides
   std::string objectProvides = relativeObj;
@@ -873,25 +778,21 @@ cmMakefileTargetGenerator
   std::string tgtMakefileName =
     this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
   tgtMakefileName += "/build.make";
-  r_commands.push_back
-    (this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(),
-                                                temp));
+  r_commands.push_back(
+    this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(), temp));
 
   p_depends.clear();
   p_depends.push_back(objectRequires);
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      objectProvides, p_depends,
-                                      r_commands, true);
+  this->LocalGenerator->WriteMakeRule(
+    *this->BuildFileStream, 0, 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, p_depends, no_commands,
-                                      false);
+  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, temp,
+                                      p_depends, no_commands, false);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteTargetRequiresRules()
 {
   std::vector<std::string> depends;
@@ -905,22 +806,19 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules()
   // This target drives dependency generation for all object files.
   std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
   std::string objTarget;
-  for(std::vector<std::string>::const_iterator obj = this->Objects.begin();
-      obj != this->Objects.end(); ++obj)
-    {
+  for (std::vector<std::string>::const_iterator obj = this->Objects.begin();
+       obj != this->Objects.end(); ++obj) {
     objTarget = relPath;
     objTarget += *obj;
     objTarget += ".requires";
     depends.push_back(objTarget);
-    }
+  }
 
   // Write the rule.
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depTarget,
+  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, depTarget,
                                       depends, no_commands, true);
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteTargetCleanRules()
 {
   std::vector<std::string> depends;
@@ -934,99 +832,84 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
   // Construct the clean command.
   this->LocalGenerator->AppendCleanCommand(commands, this->CleanFiles,
                                            this->GeneratorTarget);
-  this->LocalGenerator->CreateCDCommand
-    (commands,
-     this->LocalGenerator->GetCurrentBinaryDirectory(),
-     cmLocalGenerator::HOME_OUTPUT);
+  this->LocalGenerator->CreateCDCommand(
+    commands, this->LocalGenerator->GetCurrentBinaryDirectory(),
+    cmOutputConverter::HOME_OUTPUT);
 
   // Write the rule.
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      cleanTarget,
+  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, cleanTarget,
                                       depends, commands, true);
 }
 
-//----------------------------------------------------------------------------
 bool cmMakefileTargetGenerator::WriteMakeRule(
-  std::ostream& os,
-  const char* comment,
+  std::ostream& os, const char* comment,
   const std::vector<std::string>& outputs,
   const std::vector<std::string>& depends,
-  const std::vector<std::string>& commands,
-  bool in_help)
+  const std::vector<std::string>& commands, bool in_help)
 {
   bool symbolic = false;
-  if (outputs.size() == 0)
-    {
+  if (outputs.size() == 0) {
     return symbolic;
-    }
+  }
 
   // Check whether we need to bother checking for a symbolic output.
   bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
 
   // Check whether the first output is marked as symbolic.
-  if(need_symbolic)
-    {
-    if(cmSourceFile* sf = this->Makefile->GetSource(outputs[0]))
-      {
+  if (need_symbolic) {
+    if (cmSourceFile* sf = this->Makefile->GetSource(outputs[0])) {
       symbolic = sf->GetPropertyAsBool("SYMBOLIC");
-      }
     }
+  }
 
   // We always attach the actual commands to the first output.
   this->LocalGenerator->WriteMakeRule(os, comment, outputs[0], depends,
                                       commands, symbolic, in_help);
 
   // For single outputs, we are done.
-  if (outputs.size() == 1)
-    {
+  if (outputs.size() == 1) {
     return symbolic;
-    }
+  }
 
   // For multiple outputs, make the extra ones depend on the first one.
   std::vector<std::string> const output_depends(1, outputs[0]);
-  for (std::vector<std::string>::const_iterator o = outputs.begin()+1;
-       o != outputs.end(); ++o)
-    {
+  for (std::vector<std::string>::const_iterator o = outputs.begin() + 1;
+       o != outputs.end(); ++o) {
     // Touch the extra output so "make" knows that it was updated,
     // but only if the output was acually created.
-    std::string const out = this->Convert(*o, cmLocalGenerator::HOME_OUTPUT,
-                                          cmLocalGenerator::SHELL);
+    std::string const out = this->Convert(*o, cmOutputConverter::HOME_OUTPUT,
+                                          cmOutputConverter::SHELL);
     std::vector<std::string> output_commands;
 
     bool o_symbolic = false;
-    if(need_symbolic)
-      {
-      if(cmSourceFile* sf = this->Makefile->GetSource(*o))
-        {
+    if (need_symbolic) {
+      if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
         o_symbolic = sf->GetPropertyAsBool("SYMBOLIC");
-        }
       }
+    }
     symbolic = symbolic && o_symbolic;
 
-    if (!o_symbolic)
-      {
+    if (!o_symbolic) {
       output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out);
-      }
+    }
     this->LocalGenerator->WriteMakeRule(os, 0, *o, output_depends,
                                         output_commands, o_symbolic, in_help);
 
-    if (!o_symbolic)
-      {
+    if (!o_symbolic) {
       // At build time, remove the first output if this one does not exist
       // so that "make" will rerun the real commands that create this one.
       MultipleOutputPairsType::value_type p(*o, outputs[0]);
       this->MultipleOutputPairs.insert(p);
-      }
     }
+  }
   return symbolic;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteTargetDependRules()
 {
   // must write the targets depend info file
   std::string dir =
-      this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+    this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   this->InfoFileNameFull = dir;
   this->InfoFileNameFull += "/DependInfo.cmake";
   this->InfoFileNameFull =
@@ -1034,53 +917,53 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
   this->InfoFileStream =
     new cmGeneratedFileStream(this->InfoFileNameFull.c_str());
   this->InfoFileStream->SetCopyIfDifferent(true);
-  if(!*this->InfoFileStream)
-    {
+  if (!*this->InfoFileStream) {
     return;
-    }
-  this->LocalGenerator->
-    WriteDependLanguageInfo(*this->InfoFileStream, this->GeneratorTarget);
+  }
+  this->LocalGenerator->WriteDependLanguageInfo(*this->InfoFileStream,
+                                                this->GeneratorTarget);
 
   // Store multiple output pairs in the depend info file.
-  if(!this->MultipleOutputPairs.empty())
-    {
+  if (!this->MultipleOutputPairs.empty()) {
+    /* clang-format off */
     *this->InfoFileStream
       << "\n"
       << "# Pairs of files generated by the same build rule.\n"
       << "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
-    for(MultipleOutputPairsType::const_iterator pi =
-          this->MultipleOutputPairs.begin();
-        pi != this->MultipleOutputPairs.end(); ++pi)
-      {
+    /* clang-format on */
+    for (MultipleOutputPairsType::const_iterator pi =
+           this->MultipleOutputPairs.begin();
+         pi != this->MultipleOutputPairs.end(); ++pi) {
       *this->InfoFileStream
-        << "  " << cmOutputConverter::EscapeForCMake(pi->first)
-        << " "  << cmOutputConverter::EscapeForCMake(pi->second)
-        << "\n";
-      }
-    *this->InfoFileStream << "  )\n\n";
+        << "  " << cmOutputConverter::EscapeForCMake(pi->first) << " "
+        << cmOutputConverter::EscapeForCMake(pi->second) << "\n";
     }
+    *this->InfoFileStream << "  )\n\n";
+  }
 
   // Store list of targets linked directly or transitively.
   {
+    /* clang-format off */
   *this->InfoFileStream
     << "\n"
     << "# Targets to which this target links.\n"
     << "set(CMAKE_TARGET_LINKED_INFO_FILES\n";
-  std::vector<std::string> dirs = this->GetLinkedTargetDirectories();
-  for (std::vector<std::string>::iterator i = dirs.begin();
-       i != dirs.end(); ++i)
-    {
-    *this->InfoFileStream << "  \"" << *i << "/DependInfo.cmake\"\n";
+    /* clang-format on */
+    std::vector<std::string> dirs = this->GetLinkedTargetDirectories();
+    for (std::vector<std::string>::iterator i = dirs.begin(); i != dirs.end();
+         ++i) {
+      *this->InfoFileStream << "  \"" << *i << "/DependInfo.cmake\"\n";
     }
-  *this->InfoFileStream
-    << "  )\n";
+    *this->InfoFileStream << "  )\n";
   }
 
+  /* clang-format off */
   *this->InfoFileStream
     << "\n"
     << "# Fortran module output directory.\n"
     << "set(CMAKE_Fortran_TARGET_MODULE_DIR \""
     << this->GetFortranModuleDirectory() << "\")\n";
+  /* clang-format on */
 
   // and now write the rule to use it
   std::vector<std::string> depends;
@@ -1094,17 +977,16 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
   // Add a command to call CMake to scan dependencies.  CMake will
   // touch the corresponding depends file after scanning dependencies.
   std::ostringstream depCmd;
-  // TODO: Account for source file properties and directory-level
-  // definitions when scanning for dependencies.
+// TODO: Account for source file properties and directory-level
+// definitions when scanning for dependencies.
 #if !defined(_WIN32) || defined(__CYGWIN__)
   // This platform supports symlinks, so cmSystemTools will translate
   // paths.  Make sure PWD is set to the original name of the home
   // output directory to help cmSystemTools to create the same
   // translation table for the dependency scanning process.
-  depCmd << "cd "
-         << (this->LocalGenerator->Convert(
-               this->LocalGenerator->GetBinaryDirectory(),
-               cmLocalGenerator::FULL, cmLocalGenerator::SHELL))
+  depCmd << "cd " << (this->LocalGenerator->Convert(
+                       this->LocalGenerator->GetBinaryDirectory(),
+                       cmOutputConverter::FULL, cmOutputConverter::SHELL))
          << " && ";
 #endif
   // Generate a call this signature:
@@ -1119,101 +1001,86 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
   depCmd << "$(CMAKE_COMMAND) -E cmake_depends \""
          << this->GlobalGenerator->GetName() << "\" "
          << this->Convert(this->LocalGenerator->GetSourceDirectory(),
-                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
+                          cmOutputConverter::FULL, cmOutputConverter::SHELL)
          << " "
          << this->Convert(this->LocalGenerator->GetCurrentSourceDirectory(),
-                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
+                          cmOutputConverter::FULL, cmOutputConverter::SHELL)
          << " "
          << this->Convert(this->LocalGenerator->GetBinaryDirectory(),
-                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
+                          cmOutputConverter::FULL, cmOutputConverter::SHELL)
          << " "
          << this->Convert(this->LocalGenerator->GetCurrentBinaryDirectory(),
-                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
+                          cmOutputConverter::FULL, cmOutputConverter::SHELL)
          << " "
-         << this->Convert(this->InfoFileNameFull,
-                          cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
-  if(this->LocalGenerator->GetColorMakefile())
-    {
+         << this->Convert(this->InfoFileNameFull, cmOutputConverter::FULL,
+                          cmOutputConverter::SHELL);
+  if (this->LocalGenerator->GetColorMakefile()) {
     depCmd << " --color=$(COLOR)";
-    }
+  }
   commands.push_back(depCmd.str());
 
   // Make sure all custom command outputs in this target are built.
-  if(this->CustomCommandDriver == OnDepends)
-    {
+  if (this->CustomCommandDriver == OnDepends) {
     this->DriveCustomCommands(depends);
-    }
+  }
 
   // Write the rule.
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depTarget,
+  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, depTarget,
                                       depends, commands, true);
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::DriveCustomCommands(std::vector<std::string>& depends)
+void cmMakefileTargetGenerator::DriveCustomCommands(
+  std::vector<std::string>& depends)
 {
   // Depend on all custom command outputs.
   std::vector<cmSourceFile*> sources;
-  this->GeneratorTarget->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())
-      {
+  this->GeneratorTarget->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()) {
       cmCustomCommandGenerator ccg(*cc, this->ConfigName,
                                    this->LocalGenerator);
       const std::vector<std::string>& outputs = ccg.GetOutputs();
       depends.insert(depends.end(), outputs.begin(), outputs.end());
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::WriteObjectDependRules(cmSourceFile const& source,
-                         std::vector<std::string>& depends)
+void cmMakefileTargetGenerator::WriteObjectDependRules(
+  cmSourceFile const& source, std::vector<std::string>& depends)
 {
   // Create the list of dependencies known at cmake time.  These are
   // shared between the object file and dependency scanning rule.
   depends.push_back(source.GetFullPath());
-  if(const char* objectDeps = source.GetProperty("OBJECT_DEPENDS"))
-    {
+  if (const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) {
     cmSystemTools::ExpandListArgument(objectDeps, depends);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg)
+void cmMakefileTargetGenerator::GenerateCustomRuleFile(
+  cmCustomCommandGenerator const& ccg)
 {
   // Collect the commands.
   std::vector<std::string> commands;
   std::string comment = this->LocalGenerator->ConstructComment(ccg);
-  if(!comment.empty())
-    {
+  if (!comment.empty()) {
     // add in a progress call if needed
     this->NumberOfProgressActions++;
-    if(!this->NoRuleMessages)
-      {
+    if (!this->NoRuleMessages) {
       cmLocalUnixMakefileGenerator3::EchoProgress progress;
       this->MakeEchoProgress(progress);
-      this->LocalGenerator
-        ->AppendEcho(commands, comment.c_str(),
-                     cmLocalUnixMakefileGenerator3::EchoGenerate,
-                     &progress);
-      }
+      this->LocalGenerator->AppendEcho(
+        commands, comment, cmLocalUnixMakefileGenerator3::EchoGenerate,
+        &progress);
     }
+  }
 
   // Now append the actual user-specified commands.
   std::ostringstream content;
-  this->LocalGenerator->AppendCustomCommand(commands, ccg,
-                                            this->GeneratorTarget, false,
-                                            cmLocalGenerator::HOME_OUTPUT,
-                                            &content);
+  this->LocalGenerator->AppendCustomCommand(
+    commands, ccg, this->GeneratorTarget, false,
+    cmOutputConverter::HOME_OUTPUT, &content);
 
   // Collect the dependencies.
   std::vector<std::string> depends;
@@ -1221,35 +1088,30 @@ void cmMakefileTargetGenerator
 
   // Write the rule.
   const std::vector<std::string>& outputs = ccg.GetOutputs();
-  bool symbolic = this->WriteMakeRule(*this->BuildFileStream, 0,
-                                      outputs, depends, commands);
+  bool symbolic =
+    this->WriteMakeRule(*this->BuildFileStream, 0, outputs, depends, commands);
 
   // If the rule has changed make sure the output is rebuilt.
-  if(!symbolic)
-    {
+  if (!symbolic) {
     this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
-    }
+  }
 
   // Setup implicit dependency scanning.
-  for(cmCustomCommand::ImplicitDependsList::const_iterator
-        idi = ccg.GetCC().GetImplicitDepends().begin();
-      idi != ccg.GetCC().GetImplicitDepends().end(); ++idi)
-    {
+  for (cmCustomCommand::ImplicitDependsList::const_iterator idi =
+         ccg.GetCC().GetImplicitDepends().begin();
+       idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) {
     std::string objFullPath =
-      this->Convert(outputs[0], cmLocalGenerator::FULL);
+      this->Convert(outputs[0], cmOutputConverter::FULL);
     std::string srcFullPath =
-      this->Convert(idi->second, cmLocalGenerator::FULL);
-    this->LocalGenerator->
-      AddImplicitDepends(this->GeneratorTarget, idi->first,
-                         objFullPath.c_str(),
-                         srcFullPath.c_str());
-    }
+      this->Convert(idi->second, cmOutputConverter::FULL);
+    this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi->first,
+                                             objFullPath.c_str(),
+                                             srcFullPath.c_str());
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::MakeEchoProgress(cmLocalUnixMakefileGenerator3::EchoProgress& progress) const
+void cmMakefileTargetGenerator::MakeEchoProgress(
+  cmLocalUnixMakefileGenerator3::EchoProgress& progress) const
 {
   progress.Dir = this->LocalGenerator->GetBinaryDirectory();
   progress.Dir += cmake::GetCMakeFilesDirectory();
@@ -1258,101 +1120,89 @@ cmMakefileTargetGenerator
   progress.Arg = progressArg.str();
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::WriteObjectsVariable(std::string& variableName,
-                       std::string& variableNameExternal,
-                       bool useWatcomQuote)
+void cmMakefileTargetGenerator::WriteObjectsVariable(
+  std::string& variableName, std::string& variableNameExternal,
+  bool useWatcomQuote)
 {
   // Write a make variable assignment that lists all objects for the
   // target.
-  variableName =
-    this->LocalGenerator->CreateMakeVariable(this->GeneratorTarget->GetName(),
-                                             "_OBJECTS");
-  *this->BuildFileStream
-    << "# Object files for target " << this->GeneratorTarget->GetName() << "\n"
-    << variableName << " =";
+  variableName = this->LocalGenerator->CreateMakeVariable(
+    this->GeneratorTarget->GetName(), "_OBJECTS");
+  *this->BuildFileStream << "# Object files for target "
+                         << this->GeneratorTarget->GetName() << "\n"
+                         << variableName << " =";
   std::string object;
   const char* lineContinue =
     this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE");
-  if(!lineContinue)
-    {
+  if (!lineContinue) {
     lineContinue = "\\";
-    }
-  for(std::vector<std::string>::const_iterator i = this->Objects.begin();
-      i != this->Objects.end(); ++i)
-    {
+  }
+  for (std::vector<std::string>::const_iterator i = this->Objects.begin();
+       i != this->Objects.end(); ++i) {
     *this->BuildFileStream << " " << lineContinue << "\n";
-    *this->BuildFileStream  <<
-      this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
-                                                      useWatcomQuote);
-    }
+    *this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
+      i->c_str(), useWatcomQuote);
+  }
   *this->BuildFileStream << "\n";
 
   // Write a make variable assignment that lists all external objects
   // for the target.
-  variableNameExternal =
-    this->LocalGenerator->CreateMakeVariable(this->GeneratorTarget->GetName(),
-                                             "_EXTERNAL_OBJECTS");
+  variableNameExternal = this->LocalGenerator->CreateMakeVariable(
+    this->GeneratorTarget->GetName(), "_EXTERNAL_OBJECTS");
+  /* clang-format off */
   *this->BuildFileStream
     << "\n"
     << "# External object files for target "
     << this->GeneratorTarget->GetName() << "\n"
     << variableNameExternal << " =";
-  for(std::vector<std::string>::const_iterator i =
-        this->ExternalObjects.begin();
-      i != this->ExternalObjects.end(); ++i)
-    {
-    object = this->Convert(*i,cmLocalGenerator::START_OUTPUT);
-    *this->BuildFileStream
-      << " " << lineContinue << "\n"
-      << this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME");
-    *this->BuildFileStream  <<
-      this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
-                                                      useWatcomQuote);
-    }
-  *this->BuildFileStream << "\n" << "\n";
+  /* clang-format on */
+  for (std::vector<std::string>::const_iterator i =
+         this->ExternalObjects.begin();
+       i != this->ExternalObjects.end(); ++i) {
+    object = this->Convert(*i, cmOutputConverter::START_OUTPUT);
+    *this->BuildFileStream << " " << lineContinue << "\n"
+                           << this->Makefile->GetSafeDefinition(
+                                "CMAKE_OBJECT_NAME");
+    *this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
+      i->c_str(), useWatcomQuote);
+  }
+  *this->BuildFileStream << "\n"
+                         << "\n";
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::WriteObjectsString(std::string& buildObjs)
+void cmMakefileTargetGenerator::WriteObjectsString(std::string& buildObjs)
 {
   std::vector<std::string> objStrings;
   this->WriteObjectsStrings(objStrings);
   buildObjs = objStrings[0];
 }
 
-//----------------------------------------------------------------------------
 class cmMakefileTargetGeneratorObjectStrings
 {
 public:
   cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings,
                                          cmLocalUnixMakefileGenerator3* lg,
-                                         std::string::size_type limit):
-    Strings(strings), LocalGenerator(lg), LengthLimit(limit)
-    {
+                                         std::string::size_type limit)
+    : Strings(strings)
+    , LocalGenerator(lg)
+    , LengthLimit(limit)
+  {
     this->Space = "";
-    }
+  }
   void Feed(std::string const& obj)
-    {
+  {
     // Construct the name of the next object.
-    this->NextObject =
-      this->LocalGenerator->Convert(obj,
-                                    cmLocalGenerator::START_OUTPUT,
-                                    cmLocalGenerator::RESPONSE);
+    this->NextObject = this->LocalGenerator->Convert(
+      obj, cmOutputConverter::START_OUTPUT, cmOutputConverter::RESPONSE);
 
     // Roll over to next string if the limit will be exceeded.
-    if(this->LengthLimit != std::string::npos &&
-       (this->CurrentString.length() + 1 + this->NextObject.length()
-        > this->LengthLimit))
-      {
+    if (this->LengthLimit != std::string::npos &&
+        (this->CurrentString.length() + 1 + this->NextObject.length() >
+         this->LengthLimit)) {
       this->Strings.push_back(this->CurrentString);
       this->CurrentString = "";
       this->Space = "";
-      }
+    }
 
     // Separate from previous object.
     this->CurrentString += this->Space;
@@ -1360,11 +1210,8 @@ public:
 
     // Append this object.
     this->CurrentString += this->NextObject;
-    }
-  void Done()
-    {
-    this->Strings.push_back(this->CurrentString);
-    }
+  }
+  void Done() { this->Strings.push_back(this->CurrentString); }
 private:
   std::vector<std::string>& Strings;
   cmLocalUnixMakefileGenerator3* LocalGenerator;
@@ -1374,122 +1221,105 @@ private:
   const char* Space;
 };
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::WriteObjectsStrings(std::vector<std::string>& objStrings,
-                      std::string::size_type limit)
+void cmMakefileTargetGenerator::WriteObjectsStrings(
+  std::vector<std::string>& objStrings, std::string::size_type limit)
 {
-  cmMakefileTargetGeneratorObjectStrings
-    helper(objStrings, this->LocalGenerator, limit);
-  for(std::vector<std::string>::const_iterator i = this->Objects.begin();
-      i != this->Objects.end(); ++i)
-    {
+  cmMakefileTargetGeneratorObjectStrings helper(objStrings,
+                                                this->LocalGenerator, limit);
+  for (std::vector<std::string>::const_iterator i = this->Objects.begin();
+       i != this->Objects.end(); ++i) {
     helper.Feed(*i);
-    }
-  for(std::vector<std::string>::const_iterator i =
-        this->ExternalObjects.begin();
-      i != this->ExternalObjects.end(); ++i)
-    {
+  }
+  for (std::vector<std::string>::const_iterator i =
+         this->ExternalObjects.begin();
+       i != this->ExternalObjects.end(); ++i) {
     helper.Feed(*i);
-    }
+  }
   helper.Done();
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteTargetDriverRule(
-                                                const std::string& main_output,
-                                                bool relink)
+  const std::string& main_output, bool relink)
 {
   // Compute the name of the driver target.
   std::string dir =
     this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
   std::string buildTargetRuleName = dir;
-  buildTargetRuleName += relink?"/preinstall":"/build";
-  buildTargetRuleName = this->Convert(buildTargetRuleName,
-                                      cmLocalGenerator::HOME_OUTPUT,
-                                      cmLocalGenerator::UNCHANGED);
+  buildTargetRuleName += relink ? "/preinstall" : "/build";
+  buildTargetRuleName =
+    this->Convert(buildTargetRuleName, cmOutputConverter::HOME_OUTPUT,
+                  cmOutputConverter::UNCHANGED);
 
   // Build the list of target outputs to drive.
   std::vector<std::string> depends;
   depends.push_back(main_output);
 
   const char* comment = 0;
-  if(relink)
-    {
+  if (relink) {
     // Setup the comment for the preinstall driver.
     comment = "Rule to relink during preinstall.";
-    }
-  else
-    {
+  } else {
     // Setup the comment for the main build driver.
     comment = "Rule to build all files generated by this target.";
 
     // Make sure all custom command outputs in this target are built.
-    if(this->CustomCommandDriver == OnBuild)
-      {
+    if (this->CustomCommandDriver == OnBuild) {
       this->DriveCustomCommands(depends);
-      }
+    }
 
     // Make sure the extra files are built.
-    depends.insert(depends.end(),
-                   this->ExtraFiles.begin(), this->ExtraFiles.end());
-    }
+    depends.insert(depends.end(), this->ExtraFiles.begin(),
+                   this->ExtraFiles.end());
+  }
 
   // Write the driver rule.
   std::vector<std::string> no_commands;
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment,
-                                      buildTargetRuleName,
-                                      depends, no_commands, true);
+                                      buildTargetRuleName, depends,
+                                      no_commands, true);
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::AppendTargetDepends(std::vector<std::string>& depends)
+void cmMakefileTargetGenerator::AppendTargetDepends(
+  std::vector<std::string>& depends)
 {
   // Static libraries never depend on anything for linking.
-  if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) {
     return;
-    }
+  }
 
   // Loop over all library dependencies.
   const char* cfg = this->LocalGenerator->GetConfigName().c_str();
-  if(cmComputeLinkInformation* cli =
-                              this->GeneratorTarget->GetLinkInformation(cfg))
-    {
+  if (cmComputeLinkInformation* cli =
+        this->GeneratorTarget->GetLinkInformation(cfg)) {
     std::vector<std::string> const& libDeps = cli->GetDepends();
     depends.insert(depends.end(), libDeps.begin(), libDeps.end());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::AppendObjectDepends(std::vector<std::string>& depends)
+void cmMakefileTargetGenerator::AppendObjectDepends(
+  std::vector<std::string>& depends)
 {
   // Add dependencies on the compiled object files.
   std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
   std::string objTarget;
-  for(std::vector<std::string>::const_iterator obj = this->Objects.begin();
-      obj != this->Objects.end(); ++obj)
-    {
+  for (std::vector<std::string>::const_iterator obj = this->Objects.begin();
+       obj != this->Objects.end(); ++obj) {
     objTarget = relPath;
     objTarget += *obj;
     depends.push_back(objTarget);
-    }
+  }
 
   // Add dependencies on the external object files.
-  depends.insert(depends.end(),
-                 this->ExternalObjects.begin(), this->ExternalObjects.end());
+  depends.insert(depends.end(), this->ExternalObjects.begin(),
+                 this->ExternalObjects.end());
 
   // Add a dependency on the rule file itself.
   this->LocalGenerator->AppendRuleDepend(depends,
                                          this->BuildFileNameFull.c_str());
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::AppendLinkDepends(std::vector<std::string>& depends)
+void cmMakefileTargetGenerator::AppendLinkDepends(
+  std::vector<std::string>& depends)
 {
   this->AppendObjectDepends(depends);
 
@@ -1497,58 +1327,49 @@ void cmMakefileTargetGenerator
   this->AppendTargetDepends(depends);
 
   // Add a dependency on the link definitions file, if any.
-  if(this->ModuleDefinitionFile)
-    {
+  if (this->ModuleDefinitionFile) {
     depends.push_back(this->ModuleDefinitionFile->GetFullPath());
-    }
+  }
 
   // Add a dependency on user-specified manifest files, if any.
   std::vector<cmSourceFile const*> manifest_srcs;
   this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
   for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
-       mi != manifest_srcs.end(); ++mi)
-    {
+       mi != manifest_srcs.end(); ++mi) {
     depends.push_back((*mi)->GetFullPath());
-    }
+  }
 
   // Add user-specified dependencies.
-  if(const char* linkDepends =
-     this->GeneratorTarget->GetProperty("LINK_DEPENDS"))
-    {
+  if (const char* linkDepends =
+        this->GeneratorTarget->GetProperty("LINK_DEPENDS")) {
     cmSystemTools::ExpandListArgument(linkDepends, depends);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmMakefileTargetGenerator::GetLinkRule(
-                                              const std::string& linkRuleVar)
+  const std::string& linkRuleVar)
 {
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
-  if(this->GeneratorTarget->HasImplibGNUtoMS())
-    {
+  if (this->GeneratorTarget->HasImplibGNUtoMS()) {
     std::string ruleVar = "CMAKE_";
     ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
     ruleVar += "_GNUtoMS_RULE";
-    if(const char* rule = this->Makefile->GetDefinition(ruleVar))
-      {
+    if (const char* rule = this->Makefile->GetDefinition(ruleVar)) {
       linkRule += rule;
-      }
     }
+  }
   return linkRule;
 }
 
-//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator
-::CloseFileStreams()
+void cmMakefileTargetGenerator::CloseFileStreams()
 {
   delete this->BuildFileStream;
   delete this->InfoFileStream;
   delete this->FlagFileStream;
 }
 
-void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
-                                                const std::string& linkLang,
-                                                std::string& linkFlags)
+void cmMakefileTargetGenerator::RemoveForbiddenFlags(
+  const char* flagVar, 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
@@ -1557,56 +1378,46 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
   std::string removeFlags = "CMAKE_";
   removeFlags += linkLang;
   removeFlags += flagVar;
-  std::string removeflags =
-    this->Makefile->GetSafeDefinition(removeFlags);
+  std::string removeflags = this->Makefile->GetSafeDefinition(removeFlags);
   std::vector<std::string> removeList;
   cmSystemTools::ExpandListArgument(removeflags, removeList);
 
-  for(std::vector<std::string>::iterator i = removeList.begin();
-      i != removeList.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = removeList.begin();
+       i != removeList.end(); ++i) {
     std::string tmp;
     std::string::size_type lastPosition = 0;
 
-    for(;;)
-      {
+    for (;;) {
       std::string::size_type position = linkFlags.find(*i, lastPosition);
 
-      if(position == std::string::npos)
-        {
+      if (position == std::string::npos) {
         tmp += linkFlags.substr(lastPosition);
         break;
-        }
-      else
-        {
+      } else {
         std::string::size_type prefixLength = position - lastPosition;
         tmp += linkFlags.substr(lastPosition, prefixLength);
         lastPosition = position + i->length();
 
-        bool validFlagStart = position == 0 ||
-          isspace(linkFlags[position - 1]);
+        bool validFlagStart =
+          position == 0 || isspace(linkFlags[position - 1]);
 
-        bool validFlagEnd = lastPosition == linkFlags.size() ||
-          isspace(linkFlags[lastPosition]);
+        bool validFlagEnd =
+          lastPosition == linkFlags.size() || isspace(linkFlags[lastPosition]);
 
-        if(!validFlagStart || !validFlagEnd)
-          {
+        if (!validFlagStart || !validFlagEnd) {
           tmp += *i;
-          }
         }
       }
+    }
 
     linkFlags = tmp;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::CreateLinkScript(const char* name,
-                   std::vector<std::string> const& link_commands,
-                   std::vector<std::string>& makefile_commands,
-                   std::vector<std::string>& makefile_depends)
+void cmMakefileTargetGenerator::CreateLinkScript(
+  const char* name, std::vector<std::string> const& link_commands,
+  std::vector<std::string>& makefile_commands,
+  std::vector<std::string>& makefile_depends)
 {
   // Create the link script file.
   std::string linkScriptName = this->TargetBuildDirectoryFull;
@@ -1614,32 +1425,27 @@ cmMakefileTargetGenerator
   linkScriptName += name;
   cmGeneratedFileStream linkScriptStream(linkScriptName.c_str());
   linkScriptStream.SetCopyIfDifferent(true);
-  for(std::vector<std::string>::const_iterator cmd = link_commands.begin();
-      cmd != link_commands.end(); ++cmd)
-    {
+  for (std::vector<std::string>::const_iterator cmd = link_commands.begin();
+       cmd != link_commands.end(); ++cmd) {
     // Do not write out empty commands or commands beginning in the
     // shell no-op ":".
-    if(!cmd->empty() && (*cmd)[0] != ':')
-      {
+    if (!cmd->empty() && (*cmd)[0] != ':') {
       linkScriptStream << *cmd << "\n";
-      }
     }
+  }
 
   // Create the makefile command to invoke the link script.
   std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
-  link_command += this->Convert(linkScriptName,
-                                cmLocalGenerator::START_OUTPUT,
-                                cmLocalGenerator::SHELL);
+  link_command += this->Convert(
+    linkScriptName, cmOutputConverter::START_OUTPUT, cmOutputConverter::SHELL);
   link_command += " --verbose=$(VERBOSE)";
   makefile_commands.push_back(link_command);
   makefile_depends.push_back(linkScriptName);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmMakefileTargetGenerator
-::CreateResponseFile(const char* name, std::string const& options,
-                     std::vector<std::string>& makefile_depends)
+std::string cmMakefileTargetGenerator::CreateResponseFile(
+  const char* name, std::string const& options,
+  std::vector<std::string>& makefile_depends)
 {
   // Create the response file.
   std::string responseFileNameFull = this->TargetBuildDirectoryFull;
@@ -1660,36 +1466,27 @@ cmMakefileTargetGenerator
   return responseFileName;
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::CreateLinkLibs(std::string& linkLibs, bool relink,
-                 bool useResponseFile,
-                 std::vector<std::string>& makefile_depends,
-                 bool useWatcomQuote)
+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);
+  this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
+                                            *this->GeneratorTarget, relink,
+                                            useResponseFile, useWatcomQuote);
   linkLibs = frameworkPath + linkPath + linkLibs;
 
-  if(useResponseFile && linkLibs.find_first_not_of(" ") != linkLibs.npos)
-    {
+  if (useResponseFile && linkLibs.find_first_not_of(' ') != linkLibs.npos) {
     // Lookup the response file reference flag.
     std::string responseFlagVar = "CMAKE_";
-    responseFlagVar += this->GeneratorTarget
-                           ->GetLinkerLanguage(this->ConfigName);
+    responseFlagVar +=
+      this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
     responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
-    const char* responseFlag =
-      this->Makefile->GetDefinition(responseFlagVar);
-    if(!responseFlag)
-      {
+    const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar);
+    if (!responseFlag) {
       responseFlag = "@";
-      }
+    }
 
     // Create this response file.
     std::string link_rsp =
@@ -1697,26 +1494,21 @@ cmMakefileTargetGenerator
 
     // Reference the response file.
     linkLibs = responseFlag;
-    linkLibs += this->Convert(link_rsp,
-                              cmLocalGenerator::NONE,
-                              cmLocalGenerator::SHELL);
-    }
+    linkLibs += this->Convert(link_rsp, cmOutputConverter::NONE,
+                              cmOutputConverter::SHELL);
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
-::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
-                    bool useResponseFile, std::string& buildObjs,
-                    std::vector<std::string>& makefile_depends,
-                    bool useWatcomQuote)
+void cmMakefileTargetGenerator::CreateObjectLists(
+  bool useLinkScript, bool useArchiveRules, bool useResponseFile,
+  std::string& buildObjs, std::vector<std::string>& makefile_depends,
+  bool useWatcomQuote)
 {
   std::string variableName;
   std::string variableNameExternal;
   this->WriteObjectsVariable(variableName, variableNameExternal,
                              useWatcomQuote);
-  if(useResponseFile)
-    {
+  if (useResponseFile) {
     // MSVC response files cannot exceed 128K.
     std::string::size_type const responseFileLimit = 131000;
 
@@ -1726,23 +1518,20 @@ cmMakefileTargetGenerator
 
     // Lookup the response file reference flag.
     std::string responseFlagVar = "CMAKE_";
-    responseFlagVar += this->GeneratorTarget
-                           ->GetLinkerLanguage(this->ConfigName);
+    responseFlagVar +=
+      this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
     responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
-    const char* responseFlag =
-      this->Makefile->GetDefinition(responseFlagVar);
-    if(!responseFlag)
-      {
+    const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar);
+    if (!responseFlag) {
       responseFlag = "@";
-      }
+    }
 
     // Write a response file for each string.
     const char* sep = "";
-    for(unsigned int i = 0; i < object_strings.size(); ++i)
-      {
+    for (unsigned int i = 0; i < object_strings.size(); ++i) {
       // Number the response files.
       char rsp[32];
-      sprintf(rsp, "objects%u.rsp", i+1);
+      sprintf(rsp, "objects%u.rsp", i + 1);
 
       // Create this response file.
       std::string objects_rsp =
@@ -1754,29 +1543,22 @@ cmMakefileTargetGenerator
 
       // Reference the response file.
       buildObjs += responseFlag;
-      buildObjs += this->Convert(objects_rsp,
-                                 cmLocalGenerator::NONE,
-                                 cmLocalGenerator::SHELL);
-      }
+      buildObjs += this->Convert(objects_rsp, cmOutputConverter::NONE,
+                                 cmOutputConverter::SHELL);
     }
-  else if(useLinkScript)
-    {
-    if(!useArchiveRules)
-      {
+  } else if (useLinkScript) {
+    if (!useArchiveRules) {
       this->WriteObjectsString(buildObjs);
-      }
     }
-  else
-    {
+  } else {
     buildObjs = "$(";
     buildObjs += variableName;
     buildObjs += ") $(";
     buildObjs += variableNameExternal;
     buildObjs += ")";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
                                                 const std::string& lang)
 {
@@ -1785,25 +1567,19 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
   responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
   bool useResponseFile = this->Makefile->IsOn(responseVar);
 
-
   std::vector<std::string> includes;
   const std::string& config =
     this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-  this->LocalGenerator->GetIncludeDirectories(includes,
-                                              this->GeneratorTarget,
+  this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
                                               lang, config);
 
-  std::string includeFlags =
-    this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
-                                          lang, false, useResponseFile,
-                                          config);
-  if(includeFlags.empty())
-    {
+  std::string includeFlags = this->LocalGenerator->GetIncludeFlags(
+    includes, this->GeneratorTarget, lang, false, useResponseFile, config);
+  if (includeFlags.empty()) {
     return;
-    }
+  }
 
-  if(useResponseFile)
-    {
+  if (useResponseFile) {
     std::string name = "includes_";
     name += lang;
     name += ".rsp";
@@ -1811,9 +1587,7 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
       this->CreateResponseFile(name.c_str(), includeFlags,
                                this->FlagFileDepends[lang]);
     this->LocalGenerator->AppendFlags(flags, arg);
-    }
-  else
-    {
+  } else {
     this->LocalGenerator->AppendFlags(flags, includeFlags);
-    }
+  }
 }
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 38f40c0..c513026 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -30,7 +30,7 @@ class cmSourceFile;
  * \brief Support Routines for writing makefiles
  *
  */
-class cmMakefileTargetGenerator: public cmCommonTargetGenerator
+class cmMakefileTargetGenerator : public cmCommonTargetGenerator
 {
 public:
   // constructor to set the ivars
@@ -38,22 +38,22 @@ public:
   virtual ~cmMakefileTargetGenerator();
 
   // construct using this factory call
-  static cmMakefileTargetGenerator *New(cmGeneratorTarget *tgt);
+  static cmMakefileTargetGenerator* New(cmGeneratorTarget* tgt);
 
   /* the main entry point for this class. Writes the Makefiles associated
      with this target */
   virtual void WriteRuleFiles() = 0;
 
   /* return the number of actions that have progress reporting on them */
-  virtual unsigned long GetNumberOfProgressActions() {
-    return this->NumberOfProgressActions;}
-  std::string GetProgressFileNameFull()
-    { return this->ProgressFileNameFull; }
+  virtual unsigned long GetNumberOfProgressActions()
+  {
+    return this->NumberOfProgressActions;
+  }
+  std::string GetProgressFileNameFull() { return this->ProgressFileNameFull; }
 
-  cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;}
+  cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget; }
 
 protected:
-
   // create the file and directory etc
   void CreateRuleFile();
 
@@ -75,11 +75,13 @@ protected:
   void WriteTargetDependRules();
 
   // write rules for Mac OS X Application Bundle content.
-  struct MacOSXContentGeneratorType :
-    cmOSXBundleGenerator::MacOSXContentGeneratorType
+  struct MacOSXContentGeneratorType
+    : cmOSXBundleGenerator::MacOSXContentGeneratorType
   {
-    MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) :
-      Generator(gen) {}
+    MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen)
+      : Generator(gen)
+    {
+    }
 
     void operator()(cmSourceFile const& source, const char* pkgloc);
 
@@ -92,8 +94,7 @@ protected:
   void WriteObjectRuleFiles(cmSourceFile const& source);
 
   // write the build rule for an object
-  void WriteObjectBuildFile(std::string &obj,
-                            const std::string& lang,
+  void WriteObjectBuildFile(std::string& obj, const std::string& lang,
                             cmSourceFile const& source,
                             std::vector<std::string>& depends);
 
@@ -146,13 +147,11 @@ protected:
   /** Create a response file with the given set of options.  Returns
       the relative path from the target build working directory to the
       response file name.  */
-  std::string CreateResponseFile(const char* name,
-                                 std::string const& options,
+  std::string CreateResponseFile(const char* name, 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,
+  void CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile,
                       std::vector<std::string>& makefile_depends,
                       bool useWatcomQuote);
 
@@ -167,10 +166,15 @@ protected:
   virtual void CloseFileStreams();
   void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang,
                             std::string& linkFlags);
-  cmLocalUnixMakefileGenerator3 *LocalGenerator;
-  cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
+  cmLocalUnixMakefileGenerator3* LocalGenerator;
+  cmGlobalUnixMakefileGenerator3* GlobalGenerator;
 
-  enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };
+  enum CustomCommandDriveType
+  {
+    OnBuild,
+    OnDepends,
+    OnUtility
+  };
   CustomCommandDriveType CustomCommandDriver;
 
   // the full path to the build file
@@ -187,17 +191,19 @@ protected:
   std::string TargetBuildDirectoryFull;
 
   // the stream for the build file
-  cmGeneratedFileStream *BuildFileStream;
+  cmGeneratedFileStream* BuildFileStream;
 
   // the stream for the flag file
   std::string FlagFileNameFull;
-  cmGeneratedFileStream *FlagFileStream;
-  class StringList: public std::vector<std::string> {};
+  cmGeneratedFileStream* FlagFileStream;
+  class StringList : public std::vector<std::string>
+  {
+  };
   std::map<std::string, StringList> FlagFileDepends;
 
   // the stream for the info file
   std::string InfoFileNameFull;
-  cmGeneratedFileStream *InfoFileStream;
+  cmGeneratedFileStream* InfoFileStream;
 
   // files to clean
   std::vector<std::string> CleanFiles;
@@ -214,8 +220,7 @@ protected:
 
   typedef std::map<std::string, std::string> MultipleOutputPairsType;
   MultipleOutputPairsType MultipleOutputPairs;
-  bool WriteMakeRule(std::ostream& os,
-                     const char* comment,
+  bool WriteMakeRule(std::ostream& os, const char* comment,
                      const std::vector<std::string>& outputs,
                      const std::vector<std::string>& depends,
                      const std::vector<std::string>& commands,
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 5b62cbf..6e44e8f 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -17,46 +17,41 @@
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 
-//----------------------------------------------------------------------------
-cmMakefileUtilityTargetGenerator
-::cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target):
-  cmMakefileTargetGenerator(target)
+cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator(
+  cmGeneratorTarget* target)
+  : cmMakefileTargetGenerator(target)
 {
   this->CustomCommandDriver = OnUtility;
-  this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
-                                                      this->ConfigName);
+  this->OSXBundleGenerator =
+    new cmOSXBundleGenerator(target, this->ConfigName);
   this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
 }
 
-//----------------------------------------------------------------------------
-cmMakefileUtilityTargetGenerator
-::~cmMakefileUtilityTargetGenerator()
+cmMakefileUtilityTargetGenerator::~cmMakefileUtilityTargetGenerator()
 {
   delete this->OSXBundleGenerator;
 }
 
-//----------------------------------------------------------------------------
 void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
 {
   this->CreateRuleFile();
 
-  *this->BuildFileStream
-    << "# Utility rule file for "
-    << this->GeneratorTarget->GetName() << ".\n\n";
+  *this->BuildFileStream << "# Utility rule file for "
+                         << this->GeneratorTarget->GetName() << ".\n\n";
 
-  if(!this->NoRuleMessages)
-    {
-    const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")?
-                      "$(CMAKE_BINARY_DIR)/" : "");
+  if (!this->NoRuleMessages) {
+    const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")
+                          ? "$(CMAKE_BINARY_DIR)/"
+                          : "");
     // Include the progress variables for the target.
     *this->BuildFileStream
       << "# Include the progress variables for this target.\n"
       << this->GlobalGenerator->IncludeDirective << " " << root
       << this->Convert(this->ProgressFileNameFull,
-                       cmLocalGenerator::HOME_OUTPUT,
-                       cmLocalGenerator::MAKERULE)
+                       cmOutputConverter::HOME_OUTPUT,
+                       cmOutputConverter::MAKERULE)
       << "\n\n";
-    }
+  }
 
   // write the custom commands for this target
   this->WriteTargetBuildRules();
@@ -66,22 +61,22 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
   std::vector<std::string> depends;
 
   // Utility targets store their rules in pre- and post-build commands.
-  this->LocalGenerator->AppendCustomDepends
-    (depends, this->GeneratorTarget->GetPreBuildCommands());
+  this->LocalGenerator->AppendCustomDepends(
+    depends, this->GeneratorTarget->GetPreBuildCommands());
 
-  this->LocalGenerator->AppendCustomDepends
-    (depends, this->GeneratorTarget->GetPostBuildCommands());
+  this->LocalGenerator->AppendCustomDepends(
+    depends, this->GeneratorTarget->GetPostBuildCommands());
 
-  this->LocalGenerator->AppendCustomCommands
-    (commands, this->GeneratorTarget->GetPreBuildCommands(),
-     this->GeneratorTarget);
+  this->LocalGenerator->AppendCustomCommands(
+    commands, this->GeneratorTarget->GetPreBuildCommands(),
+    this->GeneratorTarget);
 
   // Depend on all custom command outputs for sources
   this->DriveCustomCommands(depends);
 
-  this->LocalGenerator->AppendCustomCommands
-    (commands, this->GeneratorTarget->GetPostBuildCommands(),
-     this->GeneratorTarget);
+  this->LocalGenerator->AppendCustomCommands(
+    commands, this->GeneratorTarget->GetPostBuildCommands(),
+    this->GeneratorTarget);
 
   // Add dependencies on targets that must be built first.
   this->AppendTargetDepends(depends);
@@ -92,14 +87,12 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
 
   // If the rule is empty add the special empty rule dependency needed
   // by some make tools.
-  if(depends.empty() && commands.empty())
-    {
+  if (depends.empty() && commands.empty()) {
     std::string hack = this->GlobalGenerator->GetEmptyRuleHackDepends();
-    if(!hack.empty())
-      {
+    if (!hack.empty()) {
       depends.push_back(hack);
-      }
     }
+  }
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
@@ -119,4 +112,3 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
   // close the streams
   this->CloseFileStreams();
 }
-
diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h
index 8f99300..dbb312c 100644
--- a/Source/cmMakefileUtilityTargetGenerator.h
+++ b/Source/cmMakefileUtilityTargetGenerator.h
@@ -14,8 +14,7 @@
 
 #include "cmMakefileTargetGenerator.h"
 
-class cmMakefileUtilityTargetGenerator:
-  public cmMakefileTargetGenerator
+class cmMakefileUtilityTargetGenerator : public cmMakefileTargetGenerator
 {
 public:
   cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target);
@@ -26,7 +25,6 @@ public:
   virtual void WriteRuleFiles();
 
 protected:
-
 };
 
 #endif
diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx
index 8d0e2b3..07f1fa8 100644
--- a/Source/cmMarkAsAdvancedCommand.cxx
+++ b/Source/cmMarkAsAdvancedCommand.cxx
@@ -12,47 +12,39 @@
 #include "cmMarkAsAdvancedCommand.h"
 
 // cmMarkAsAdvancedCommand
-bool cmMarkAsAdvancedCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
-  unsigned int i =0;
+  unsigned int i = 0;
   const char* value = "1";
   bool overwrite = false;
-  if(args[0] == "CLEAR" || args[0] == "FORCE")
-    {
+  if (args[0] == "CLEAR" || args[0] == "FORCE") {
     overwrite = true;
-    if(args[0] == "CLEAR")
-      {
+    if (args[0] == "CLEAR") {
       value = "0";
-      }
-    i = 1;
     }
-  for(; i < args.size(); ++i)
-    {
+    i = 1;
+  }
+  for (; i < args.size(); ++i) {
     std::string variable = args[i];
     cmState* state = this->Makefile->GetState();
-    if (!state->GetCacheEntryValue(variable))
-      {
+    if (!state->GetCacheEntryValue(variable)) {
       this->Makefile->GetCMakeInstance()->AddCacheEntry(
-              variable, 0, 0, cmState::UNINITIALIZED);
+        variable, 0, 0, cmState::UNINITIALIZED);
       overwrite = true;
-      }
-    if (!state->GetCacheEntryValue(variable))
-      {
+    }
+    if (!state->GetCacheEntryValue(variable)) {
       cmSystemTools::Error("This should never happen...");
       return false;
-      }
-    if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite)
-      {
+    }
+    if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite) {
       state->SetCacheEntryProperty(variable, "ADVANCED", value);
-      }
     }
+  }
   return true;
 }
-
diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h
index 38064a3..add43c9 100644
--- a/Source/cmMarkAsAdvancedCommand.h
+++ b/Source/cmMarkAsAdvancedCommand.h
@@ -25,22 +25,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmMarkAsAdvancedCommand;
-    }
+  virtual cmCommand* Clone() { return new cmMarkAsAdvancedCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string 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.
@@ -53,6 +50,4 @@ public:
   cmTypeMacro(cmMarkAsAdvancedCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx
index f1942c5..ca8b926 100644
--- a/Source/cmMathCommand.cxx
+++ b/Source/cmMathCommand.cxx
@@ -13,45 +13,39 @@
 
 #include "cmExprParserHelper.h"
 
-//----------------------------------------------------------------------------
-bool cmMathCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmMathCommand::InitialPass(std::vector<std::string> const& args,
+                                cmExecutionStatus&)
 {
-  if ( args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("must be called with at least one argument.");
     return false;
-    }
-  const std::string &subCommand = args[0];
-  if(subCommand == "EXPR")
-    {
+  }
+  const std::string& subCommand = args[0];
+  if (subCommand == "EXPR") {
     return this->HandleExprCommand(args);
-    }
-  std::string e = "does not recognize sub-command "+subCommand;
+  }
+  std::string e = "does not recognize sub-command " + subCommand;
   this->SetError(e);
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
 {
-  if ( args.size() != 3 )
-    {
+  if (args.size() != 3) {
     this->SetError("EXPR called with incorrect arguments.");
     return false;
-    }
+  }
 
   const std::string& outputVariable = args[1];
   const std::string& expression = args[2];
 
   cmExprParserHelper helper;
-  if ( !helper.ParseString(expression.c_str(), 0) )
-    {
-    std::string e = "cannot parse the expression: \""+expression+"\": ";
+  if (!helper.ParseString(expression.c_str(), 0)) {
+    std::string e = "cannot parse the expression: \"" + expression + "\": ";
     e += helper.GetError();
     this->SetError(e);
     return false;
-    }
+  }
 
   char buffer[1024];
   sprintf(buffer, "%d", helper.GetResult());
diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h
index 76dc102..3ac6f41 100644
--- a/Source/cmMathCommand.h
+++ b/Source/cmMathCommand.h
@@ -21,17 +21,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmMathCommand;
-    }
+  virtual cmCommand* Clone() { return new cmMathCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -41,14 +38,12 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "math";}
+  virtual std::string GetName() const { return "math"; }
 
   cmTypeMacro(cmMathCommand, cmCommand);
-protected:
 
+protected:
   bool HandleExprCommand(std::vector<std::string> const& args);
 };
 
-
 #endif
-
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 1c67cea..f4458a7 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -12,98 +12,68 @@
 #include "cmMessageCommand.h"
 
 // cmLibraryCommand
-bool cmMessageCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
+                                   cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::vector<std::string>::const_iterator i = args.begin();
 
   cmake::MessageType type = cmake::MESSAGE;
   bool status = false;
   bool fatal = false;
   cmake* cm = this->Makefile->GetCMakeInstance();
-  if (*i == "SEND_ERROR")
-    {
+  if (*i == "SEND_ERROR") {
     type = cmake::FATAL_ERROR;
     ++i;
-    }
-  else if (*i == "FATAL_ERROR")
-    {
+  } else if (*i == "FATAL_ERROR") {
     fatal = true;
     type = cmake::FATAL_ERROR;
     ++i;
-    }
-  else if (*i == "WARNING")
-    {
+  } else if (*i == "WARNING") {
     type = cmake::WARNING;
     ++i;
-    }
-  else if (*i == "AUTHOR_WARNING")
-    {
-    if (cm->GetDevWarningsAsErrors(this->Makefile))
-      {
+  } else if (*i == "AUTHOR_WARNING") {
+    if (cm->GetDevWarningsAsErrors(this->Makefile)) {
       fatal = true;
       type = cmake::AUTHOR_ERROR;
-      }
-    else if (!cm->GetSuppressDevWarnings(this->Makefile))
-      {
+    } else if (!cm->GetSuppressDevWarnings(this->Makefile)) {
       type = cmake::AUTHOR_WARNING;
-      }
-    else
-      {
+    } else {
       return true;
-      }
-    ++i;
     }
-  else if (*i == "STATUS")
-    {
+    ++i;
+  } else if (*i == "STATUS") {
     status = true;
     ++i;
-    }
-  else if (*i == "DEPRECATION")
-    {
-    if (cm->GetDeprecatedWarningsAsErrors(this->Makefile))
-      {
+  } else if (*i == "DEPRECATION") {
+    if (cm->GetDeprecatedWarningsAsErrors(this->Makefile)) {
       fatal = true;
       type = cmake::DEPRECATION_ERROR;
-      }
-    else if (!cm->GetSuppressDeprecatedWarnings(this->Makefile))
-      {
+    } else if (!cm->GetSuppressDeprecatedWarnings(this->Makefile)) {
       type = cmake::DEPRECATION_WARNING;
-      }
-    else
-      {
+    } else {
       return true;
-      }
-    ++i;
     }
+    ++i;
+  }
 
   std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
 
-  if (type != cmake::MESSAGE)
-    {
+  if (type != cmake::MESSAGE) {
     // we've overriden the message type, above, so force IssueMessage to use it
     this->Makefile->IssueMessage(type, message, true);
-    }
-  else
-    {
-    if (status)
-      {
+  } else {
+    if (status) {
       this->Makefile->DisplayStatus(message.c_str(), -1);
-      }
-    else
-      {
+    } else {
       cmSystemTools::Message(message.c_str());
-      }
     }
-  if(fatal)
-    {
+  }
+  if (fatal) {
     cmSystemTools::SetFatalErrorOccured();
-    }
+  }
   return true;
 }
-
diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h
index c0ae2a3..afc5509 100644
--- a/Source/cmMessageCommand.h
+++ b/Source/cmMessageCommand.h
@@ -24,22 +24,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmMessageCommand;
-    }
+  virtual cmCommand* Clone() { return new cmMessageCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "message";}
+  virtual std::string GetName() const { return "message"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -49,5 +46,4 @@ public:
   cmTypeMacro(cmMessageCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx
index 08f0b5b..c03f60d 100644
--- a/Source/cmNewLineStyle.cxx
+++ b/Source/cmNewLineStyle.cxx
@@ -11,82 +11,65 @@
 ============================================================================*/
 #include "cmNewLineStyle.h"
 
-
-
-cmNewLineStyle::cmNewLineStyle() : NewLineStyle(Invalid)
+cmNewLineStyle::cmNewLineStyle()
+  : NewLineStyle(Invalid)
 {
 }
 
-
 bool cmNewLineStyle::IsValid() const
 {
   return NewLineStyle != Invalid;
 }
 
-
 bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args,
                                        std::string& errorString)
 {
   NewLineStyle = Invalid;
 
-  for (size_t i = 0; i< args.size(); i++)
-    {
-    if (args[i] == "NEWLINE_STYLE")
-      {
+  for (size_t i = 0; i < args.size(); i++) {
+    if (args[i] == "NEWLINE_STYLE") {
       size_t const styleIndex = i + 1;
-      if (args.size() > styleIndex)
-        {
+      if (args.size() > styleIndex) {
         const std::string eol = args[styleIndex];
-        if (eol == "LF" || eol == "UNIX")
-          {
+        if (eol == "LF" || eol == "UNIX") {
           NewLineStyle = LF;
           return true;
-          }
-        else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS")
-          {
+        } else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") {
           NewLineStyle = CRLF;
           return true;
-          }
-        else
-          {
+        } else {
           errorString = "NEWLINE_STYLE sets an unknown style, only LF, "
                         "CRLF, UNIX, DOS, and WIN32 are supported";
           return false;
-          }
         }
-      else
-        {
+      } else {
         errorString = "NEWLINE_STYLE must set a style: "
                       "LF, CRLF, UNIX, DOS, or WIN32";
         return false;
-        }
       }
     }
+  }
   return true;
 }
 
-
 const std::string cmNewLineStyle::GetCharacters() const
 {
-  switch (NewLineStyle)
-    {
+  switch (NewLineStyle) {
     case Invalid:
       return "";
     case LF:
       return "\n";
     case CRLF:
       return "\r\n";
-    }
+  }
   return "";
 }
 
-
 void cmNewLineStyle::SetStyle(Style style)
 {
   NewLineStyle = style;
 }
 
-
 cmNewLineStyle::Style cmNewLineStyle::GetStyle() const
 {
   return NewLineStyle;
diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h
index cae1106..800f131 100644
--- a/Source/cmNewLineStyle.h
+++ b/Source/cmNewLineStyle.h
@@ -17,16 +17,15 @@
 class cmNewLineStyle
 {
 public:
-
   cmNewLineStyle();
 
   enum Style
   {
     Invalid,
-               // LF = '\n', 0x0A, 10
-               // CR = '\r', 0x0D, 13
-    LF,        // Unix
-    CRLF       // Dos
+    // LF = '\n', 0x0A, 10
+    // CR = '\r', 0x0D, 13
+    LF,  // Unix
+    CRLF // Dos
   };
 
   void SetStyle(Style);
@@ -35,7 +34,7 @@ public:
   bool IsValid() const;
 
   bool ReadFromArguments(const std::vector<std::string>& args,
-                         std::string &errorString);
+                         std::string& errorString);
 
   const std::string GetCharacters() const;
 
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 17561b5..3e91545 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -11,27 +11,27 @@
   See the License for more information.
 ============================================================================*/
 #include "cmNinjaNormalTargetGenerator.h"
-#include "cmLocalNinjaGenerator.h"
-#include "cmGlobalNinjaGenerator.h"
-#include "cmSourceFile.h"
+
+#include "cmAlgorithms.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalNinjaGenerator.h"
+#include "cmLocalNinjaGenerator.h"
 #include "cmMakefile.h"
 #include "cmOSXBundleGenerator.h"
-#include "cmGeneratorTarget.h"
-#include "cmCustomCommandGenerator.h"
-#include "cmAlgorithms.h"
+#include "cmSourceFile.h"
 
-#include <assert.h>
 #include <algorithm>
+#include <assert.h>
 #include <limits>
 
 #ifndef _WIN32
 #include <unistd.h>
 #endif
 
-
-cmNinjaNormalTargetGenerator::
-cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
+cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
+  cmGeneratorTarget* target)
   : cmNinjaTargetGenerator(target)
   , TargetNameOut()
   , TargetNameSO()
@@ -42,28 +42,23 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
 {
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmState::EXECUTABLE)
-    this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut,
-                               this->TargetNameReal,
-                               this->TargetNameImport,
-                               this->TargetNamePDB,
-                               GetLocalGenerator()->GetConfigName());
+    this->GetGeneratorTarget()->GetExecutableNames(
+      this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
+      this->TargetNamePDB, GetLocalGenerator()->GetConfigName());
   else
-    this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut,
-                            this->TargetNameSO,
-                            this->TargetNameReal,
-                            this->TargetNameImport,
-                            this->TargetNamePDB,
-                            GetLocalGenerator()->GetConfigName());
-
-  if(target->GetType() != cmState::OBJECT_LIBRARY)
-    {
+    this->GetGeneratorTarget()->GetLibraryNames(
+      this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
+      this->TargetNameImport, this->TargetNamePDB,
+      GetLocalGenerator()->GetConfigName());
+
+  if (target->GetType() != cmState::OBJECT_LIBRARY) {
     // on Windows the output dir is already needed at compile time
     // ensure the directory exists (OutDir test)
     EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
-    }
+  }
 
-  this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
-                                                      this->GetConfigName());
+  this->OSXBundleGenerator =
+    new cmOSXBundleGenerator(target, this->GetConfigName());
   this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
 }
 
@@ -87,14 +82,11 @@ void cmNinjaNormalTargetGenerator::Generate()
   // Write the build statements
   this->WriteObjectBuildStatements();
 
-  if(this->GetGeneratorTarget()->GetType() == cmState::OBJECT_LIBRARY)
-    {
+  if (this->GetGeneratorTarget()->GetType() == cmState::OBJECT_LIBRARY) {
     this->WriteObjectLibStatement();
-    }
-  else
-    {
+  } else {
     this->WriteLinkStatement();
-    }
+  }
 }
 
 void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
@@ -104,34 +96,28 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
   this->GetRulesFileStream()
     << "# Rules for each languages for "
     << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
-    << " target "
-    << this->GetTargetName()
-    << "\n\n";
+    << " target " << this->GetTargetName() << "\n\n";
 #endif
 
   // Write rules for languages compiled in this target.
   std::set<std::string> languages;
   std::vector<cmSourceFile*> sourceFiles;
-  this->GetGeneratorTarget()->GetSourceFiles(sourceFiles,
-    this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
-  for(std::vector<cmSourceFile*>::const_iterator
-        i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
-    {
+  this->GetGeneratorTarget()->GetSourceFiles(
+    sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin();
+       i != sourceFiles.end(); ++i) {
     const std::string& lang = (*i)->GetLanguage();
-    if(!lang.empty())
-      {
+    if (!lang.empty()) {
       languages.insert(lang);
-      }
     }
-  for(std::set<std::string>::const_iterator l = languages.begin();
-      l != languages.end();
-      ++l)
-    {
+  }
+  for (std::set<std::string>::const_iterator l = languages.begin();
+       l != languages.end(); ++l) {
     this->WriteLanguageRules(*l);
-    }
+  }
 }
 
-const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
+const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
 {
   switch (this->GetGeneratorTarget()->GetType()) {
     case cmState::STATIC_LIBRARY:
@@ -150,25 +136,17 @@ const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
   }
 }
 
-std::string
-cmNinjaNormalTargetGenerator
-::LanguageLinkerRule() const
+std::string cmNinjaNormalTargetGenerator::LanguageLinkerRule() const
 {
-  return this->TargetLinkLanguage
-    + "_"
-    + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
-    + "_LINKER__"
-    + cmGlobalNinjaGenerator::EncodeRuleName(
-        this->GetGeneratorTarget()->GetName())
-    ;
+  return this->TargetLinkLanguage + "_" +
+    cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) +
+    "_LINKER__" + cmGlobalNinjaGenerator::EncodeRuleName(
+                    this->GetGeneratorTarget()->GetName());
 }
 
-void
-cmNinjaNormalTargetGenerator
-::WriteLinkRule(bool useResponseFile)
+void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
 {
-  cmState::TargetType targetType =
-      this->GetGeneratorTarget()->GetType();
+  cmState::TargetType targetType = this->GetGeneratorTarget()->GetType();
   std::string ruleName = this->LanguageLinkerRule();
 
   // Select whether to use a response file for objects.
@@ -186,29 +164,29 @@ cmNinjaNormalTargetGenerator
       vars.Objects = "$in";
       vars.LinkLibraries = "$LINK_PATH $LINK_LIBRARIES";
     } else {
-        std::string cmakeVarLang = "CMAKE_";
-        cmakeVarLang += this->TargetLinkLanguage;
-
-        // build response file name
-        std::string cmakeLinkVar =  cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
-        const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar);
-        if(flag) {
-          responseFlag = flag;
-        } else {
-          responseFlag = "@";
-        }
-        rspfile = "$RSP_FILE";
-        responseFlag += rspfile;
-
-        // build response file content
-        if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
-          rspcontent = "$in";
-        } else {
-          rspcontent = "$in_newline";
-        }
-        rspcontent += " $LINK_PATH $LINK_LIBRARIES";
-        vars.Objects = responseFlag.c_str();
-        vars.LinkLibraries = "";
+      std::string cmakeVarLang = "CMAKE_";
+      cmakeVarLang += this->TargetLinkLanguage;
+
+      // build response file name
+      std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
+      const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
+      if (flag) {
+        responseFlag = flag;
+      } else {
+        responseFlag = "@";
+      }
+      rspfile = "$RSP_FILE";
+      responseFlag += rspfile;
+
+      // build response file content
+      if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
+        rspcontent = "$in";
+      } else {
+        rspcontent = "$in_newline";
+      }
+      rspcontent += " $LINK_PATH $LINK_LIBRARIES";
+      vars.Objects = responseFlag.c_str();
+      vars.LinkLibraries = "";
     }
 
     vars.ObjectDir = "$OBJECT_DIR";
@@ -224,15 +202,15 @@ cmNinjaNormalTargetGenerator
     std::string targetVersionMajor;
     std::string targetVersionMinor;
     {
-    std::ostringstream majorStream;
-    std::ostringstream minorStream;
-    int major;
-    int minor;
-    this->GetGeneratorTarget()->GetTargetVersion(major, minor);
-    majorStream << major;
-    minorStream << minor;
-    targetVersionMajor = majorStream.str();
-    targetVersionMinor = minorStream.str();
+      std::ostringstream majorStream;
+      std::ostringstream minorStream;
+      int major;
+      int minor;
+      this->GetGeneratorTarget()->GetTargetVersion(major, minor);
+      majorStream << major;
+      minorStream << minor;
+      targetVersionMajor = majorStream.str();
+      targetVersionMinor = minorStream.str();
     }
     vars.TargetVersionMajor = targetVersionMajor.c_str();
     vars.TargetVersionMinor = targetVersionMinor.c_str();
@@ -242,20 +220,17 @@ cmNinjaNormalTargetGenerator
     vars.Manifests = "$MANIFESTS";
 
     std::string langFlags;
-    if (targetType != cmState::EXECUTABLE)
-      {
+    if (targetType != cmState::EXECUTABLE) {
       langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS";
       vars.LanguageCompileFlags = langFlags.c_str();
-      }
+    }
 
     // Rule for linking library/executable.
     std::vector<std::string> linkCmds = this->ComputeLinkCmd();
-    for(std::vector<std::string>::iterator i = linkCmds.begin();
-        i != linkCmds.end();
-        ++i)
-      {
+    for (std::vector<std::string>::iterator i = linkCmds.begin();
+         i != linkCmds.end(); ++i) {
       this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
-      }
+    }
     linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
     linkCmds.push_back("$POST_BUILD");
     std::string linkCmd =
@@ -268,93 +243,84 @@ cmNinjaNormalTargetGenerator
     std::ostringstream description;
     description << "Linking " << this->TargetLinkLanguage << " "
                 << this->GetVisibleTypeName() << " $TARGET_FILE";
-    this->GetGlobalGenerator()->AddRule(ruleName,
-                                        linkCmd,
-                                        description.str(),
+    this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(),
                                         comment.str(),
                                         /*depfile*/ "",
-                                        /*deptype*/ "",
-                                        rspfile,
-                                        rspcontent,
+                                        /*deptype*/ "", rspfile, rspcontent,
                                         /*restat*/ "$RESTAT",
                                         /*generator*/ false);
   }
 
   if (this->TargetNameOut != this->TargetNameReal &&
-    !this->GetGeneratorTarget()->IsFrameworkOnApple()) {
+      !this->GetGeneratorTarget()->IsFrameworkOnApple()) {
     std::string cmakeCommand =
       this->GetLocalGenerator()->ConvertToOutputFormat(
-        cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
+        cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
     if (targetType == cmState::EXECUTABLE)
-      this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE",
-                                          cmakeCommand +
-                                          " -E cmake_symlink_executable"
-                                          " $in $out && $POST_BUILD",
-                                          "Creating executable symlink $out",
-                                          "Rule for creating "
-                                          "executable symlink.",
-                                          /*depfile*/ "",
-                                          /*deptype*/ "",
-                                          /*rspfile*/ "",
-                                          /*rspcontent*/ "",
-                                          /*restat*/ "",
-                                          /*generator*/ false);
+      this->GetGlobalGenerator()->AddRule(
+        "CMAKE_SYMLINK_EXECUTABLE",
+        cmakeCommand + " -E cmake_symlink_executable"
+                       " $in $out && $POST_BUILD",
+        "Creating executable symlink $out", "Rule for creating "
+                                            "executable symlink.",
+        /*depfile*/ "",
+        /*deptype*/ "",
+        /*rspfile*/ "",
+        /*rspcontent*/ "",
+        /*restat*/ "",
+        /*generator*/ false);
     else
-      this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY",
-                                          cmakeCommand +
-                                          " -E cmake_symlink_library"
-                                          " $in $SONAME $out && $POST_BUILD",
-                                          "Creating library symlink $out",
-                                          "Rule for creating "
-                                          "library symlink.",
-                                          /*depfile*/ "",
-                                          /*deptype*/ "",
-                                          /*rspfile*/ "",
-                                          /*rspcontent*/ "",
-                                          /*restat*/ "",
-                                          /*generator*/ false);
+      this->GetGlobalGenerator()->AddRule(
+        "CMAKE_SYMLINK_LIBRARY",
+        cmakeCommand + " -E cmake_symlink_library"
+                       " $in $SONAME $out && $POST_BUILD",
+        "Creating library symlink $out", "Rule for creating "
+                                         "library symlink.",
+        /*depfile*/ "",
+        /*deptype*/ "",
+        /*rspfile*/ "",
+        /*rspcontent*/ "",
+        /*restat*/ "",
+        /*generator*/ false);
   }
 }
 
-std::vector<std::string>
-cmNinjaNormalTargetGenerator
-::ComputeLinkCmd()
+std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
 {
   std::vector<std::string> linkCmds;
   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;
+    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->GetGeneratorTarget()->GetType()) {
     case cmState::STATIC_LIBRARY: {
       // We have archive link commands set. First, delete the existing archive.
       {
-      std::string cmakeCommand =
-        this->GetLocalGenerator()->ConvertToOutputFormat(
-          cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
-      linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE");
+        std::string cmakeCommand =
+          this->GetLocalGenerator()->ConvertToOutputFormat(
+            cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
+        linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE");
       }
       // TODO: Use ARCHIVE_APPEND for archives over a certain size.
       {
-      std::string linkCmdVar = "CMAKE_";
-      linkCmdVar += this->TargetLinkLanguage;
-      linkCmdVar += "_ARCHIVE_CREATE";
-      const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
-      cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+        std::string linkCmdVar = "CMAKE_";
+        linkCmdVar += this->TargetLinkLanguage;
+        linkCmdVar += "_ARCHIVE_CREATE";
+        const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar);
+        cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
       {
-      std::string linkCmdVar = "CMAKE_";
-      linkCmdVar += this->TargetLinkLanguage;
-      linkCmdVar += "_ARCHIVE_FINISH";
-      const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
-      cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+        std::string linkCmdVar = "CMAKE_";
+        linkCmdVar += this->TargetLinkLanguage;
+        linkCmdVar += "_ARCHIVE_FINISH";
+        const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar);
+        cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
       return linkCmds;
     }
@@ -368,7 +334,6 @@ cmNinjaNormalTargetGenerator
   return std::vector<std::string>();
 }
 
-
 static int calculateCommandLineLengthLimit(int linkRuleLength)
 {
   static int const limits[] = {
@@ -388,31 +353,27 @@ static int calculateCommandLineLengthLimit(int linkRuleLength)
 
   size_t const arrSz = cmArraySize(limits);
   int const sz = *std::min_element(limits, limits + arrSz);
-  if (sz == std::numeric_limits<int>::max())
-    {
+  if (sz == std::numeric_limits<int>::max()) {
     return -1;
-    }
+  }
 
   return sz - linkRuleLength;
 }
 
-
 void cmNinjaNormalTargetGenerator::WriteLinkStatement()
 {
   cmGeneratorTarget& gt = *this->GetGeneratorTarget();
   const std::string cfgName = this->GetConfigName();
-  std::string targetOutput = ConvertToNinjaPath(
-                               gt.GetFullPath(cfgName));
-  std::string targetOutputReal = ConvertToNinjaPath(
-                                   gt.GetFullPath(cfgName,
+  std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
+  std::string targetOutputReal =
+    ConvertToNinjaPath(gt.GetFullPath(cfgName,
                                       /*implib=*/false,
                                       /*realpath=*/true));
-  std::string targetOutputImplib = ConvertToNinjaPath(
-                                     gt.GetFullPath(cfgName,
-                                       /*implib=*/true));
+  std::string targetOutputImplib =
+    ConvertToNinjaPath(gt.GetFullPath(cfgName,
+                                      /*implib=*/true));
 
-  if (gt.IsAppBundleOnApple())
-    {
+  if (gt.IsAppBundleOnApple()) {
     // Create the app bundle
     std::string outpath = gt.GetDirectory(cfgName);
     this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
@@ -426,37 +387,30 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     targetOutputReal += "/";
     targetOutputReal += this->TargetNameReal;
     targetOutputReal = this->ConvertToNinjaPath(targetOutputReal);
-    }
-  else if (gt.IsFrameworkOnApple())
-    {
+  } else if (gt.IsFrameworkOnApple()) {
     // Create the library framework.
     this->OSXBundleGenerator->CreateFramework(this->TargetNameOut,
                                               gt.GetDirectory(cfgName));
-    }
-  else if(gt.IsCFBundleOnApple())
-    {
+  } else if (gt.IsCFBundleOnApple()) {
     // Create the core foundation bundle.
     this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut,
                                              gt.GetDirectory(cfgName));
-    }
+  }
 
   // Write comments.
   cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
   const cmState::TargetType targetType = gt.GetType();
-  this->GetBuildFileStream()
-    << "# Link build statements for "
-    << cmState::GetTargetTypeName(targetType)
-    << " target "
-    << this->GetTargetName()
-    << "\n\n";
+  this->GetBuildFileStream() << "# Link build statements for "
+                             << cmState::GetTargetTypeName(targetType)
+                             << " target " << this->GetTargetName() << "\n\n";
 
   cmNinjaDeps emptyDeps;
   cmNinjaVars vars;
 
   // Compute the comment.
   std::ostringstream comment;
-  comment <<
-    "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal;
+  comment << "Link the " << this->GetVisibleTypeName() << " "
+          << targetOutputReal;
 
   // Compute outputs.
   cmNinjaDeps outputs;
@@ -472,43 +426,43 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   std::string linkPath;
   cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
 
-  std::string createRule =
-    genTarget.GetCreateRuleVariable(this->TargetLinkLanguage,
-                                    this->GetConfigName());
-  bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
+  std::string createRule = genTarget.GetCreateRuleVariable(
+    this->TargetLinkLanguage, this->GetConfigName());
+  bool useWatcomQuote = mf->IsOn(createRule + "_USE_WATCOM_QUOTE");
   cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
 
   vars["TARGET_FILE"] =
-    localGen.ConvertToOutputFormat(targetOutputReal, cmLocalGenerator::SHELL);
-
-  localGen.GetTargetFlags(vars["LINK_LIBRARIES"],
-                          vars["FLAGS"],
-                          vars["LINK_FLAGS"],
-                          frameworkPath,
-                          linkPath,
-                          &genTarget,
-                          useWatcomQuote);
-  if(this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")
-     && gt.GetType() == cmState::SHARED_LIBRARY)
-    {
-    if(gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
-      std::string name_of_def_file
-        = gt.GetSupportDirectory();
+    localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
+
+  localGen.GetTargetFlags(vars["LINK_LIBRARIES"], vars["FLAGS"],
+                          vars["LINK_FLAGS"], frameworkPath, linkPath,
+                          &genTarget, useWatcomQuote);
+  if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") &&
+      gt.GetType() == cmState::SHARED_LIBRARY) {
+    if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) {
+      std::string name_of_def_file = gt.GetSupportDirectory();
       name_of_def_file += "/" + gt.GetName();
       name_of_def_file += ".def ";
       vars["LINK_FLAGS"] += " /DEF:";
-      vars["LINK_FLAGS"] += this->GetLocalGenerator()
-        ->ConvertToOutputFormat(name_of_def_file.c_str(),
-                                cmLocalGenerator::SHELL);
-      }
+      vars["LINK_FLAGS"] += this->GetLocalGenerator()->ConvertToOutputFormat(
+        name_of_def_file, cmOutputConverter::SHELL);
     }
+  }
+
+  // Add OS X version flags, if any.
+  if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+      this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
+    this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage,
+                           "COMPATIBILITY", true);
+    this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage,
+                           "CURRENT", false);
+  }
 
   this->addPoolNinjaVariable("JOB_POOL_LINK", &gt, vars);
 
   this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
-  vars["LINK_FLAGS"] = cmGlobalNinjaGenerator
-                        ::EncodeLiteral(vars["LINK_FLAGS"]);
+  vars["LINK_FLAGS"] =
+    cmGlobalNinjaGenerator::EncodeLiteral(vars["LINK_FLAGS"]);
 
   vars["MANIFESTS"] = this->GetManifests();
 
@@ -517,56 +471,45 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   // 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.
-  if (targetType == cmState::EXECUTABLE)
-    {
+  if (targetType == cmState::EXECUTABLE) {
     std::string t = vars["FLAGS"];
     localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
     vars["FLAGS"] = t;
-    }
-  else
-    {
+  } 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 (this->GetGeneratorTarget()->HasSOName(cfgName))
-    {
+  if (this->GetGeneratorTarget()->HasSOName(cfgName)) {
     vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
     vars["SONAME"] = this->TargetNameSO;
-    if (targetType == cmState::SHARED_LIBRARY)
-      {
+    if (targetType == cmState::SHARED_LIBRARY) {
       std::string install_dir =
-          this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName);
-      if (!install_dir.empty())
-        {
-        vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir,
-                                                   cmLocalGenerator::NONE,
-                                                   cmLocalGenerator::SHELL);
-        }
+        this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName);
+      if (!install_dir.empty()) {
+        vars["INSTALLNAME_DIR"] = localGen.Convert(
+          install_dir, cmOutputConverter::NONE, cmOutputConverter::SHELL);
       }
     }
+  }
 
   cmNinjaDeps byproducts;
 
-  if (!this->TargetNameImport.empty())
-    {
+  if (!this->TargetNameImport.empty()) {
     const std::string impLibPath = localGen.ConvertToOutputFormat(
-                                              targetOutputImplib,
-                                              cmLocalGenerator::SHELL);
+      targetOutputImplib, cmOutputConverter::SHELL);
     vars["TARGET_IMPLIB"] = impLibPath;
     EnsureParentDirectoryExists(impLibPath);
-    if(genTarget.HasImportLibrary())
-      {
+    if (genTarget.HasImportLibrary()) {
       byproducts.push_back(targetOutputImplib);
-      }
     }
+  }
 
-  if (!this->SetMsvcTargetPdbVariable(vars))
-    {
+  if (!this->SetMsvcTargetPdbVariable(vars)) {
     // It is common to place debug symbols at a specific place,
     // so we need a plain target name in the rule available.
     std::string prefix;
@@ -575,207 +518,162 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix);
     std::string dbg_suffix = ".dbg";
     // TODO: Where to document?
-    if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX"))
-      {
+    if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) {
       dbg_suffix = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX");
-      }
-    vars["TARGET_PDB"] = base + suffix + dbg_suffix;
     }
+    vars["TARGET_PDB"] = base + suffix + dbg_suffix;
+  }
 
   const std::string objPath = GetGeneratorTarget()->GetSupportDirectory();
-  vars["OBJECT_DIR"] =
-    this->GetLocalGenerator()->ConvertToOutputFormat(
-      this->ConvertToNinjaPath(objPath), cmLocalGenerator::SHELL);
+  vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
+    this->ConvertToNinjaPath(objPath), cmOutputConverter::SHELL);
   EnsureDirectoryExists(objPath);
 
-  if (this->GetGlobalGenerator()->IsGCCOnWindows())
-    {
+  if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
     // 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] = {
-    &gt.GetPreBuildCommands(),
-    &gt.GetPreLinkCommands(),
+  const std::vector<cmCustomCommand>* cmdLists[3] = {
+    &gt.GetPreBuildCommands(), &gt.GetPreLinkCommands(),
     &gt.GetPostBuildCommands()
   };
 
   std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
-  std::vector<std::string> *cmdLineLists[3] = {
-    &preLinkCmdLines,
-    &preLinkCmdLines,
-    &postBuildCmdLines
-  };
-
-  for (unsigned i = 0; i != 3; ++i)
-    {
-    for (std::vector<cmCustomCommand>::const_iterator
-         ci = cmdLists[i]->begin();
-         ci != cmdLists[i]->end(); ++ci)
-      {
+  std::vector<std::string>* cmdLineLists[3] = { &preLinkCmdLines,
+                                                &preLinkCmdLines,
+                                                &postBuildCmdLines };
+
+  for (unsigned i = 0; i != 3; ++i) {
+    for (std::vector<cmCustomCommand>::const_iterator ci =
+           cmdLists[i]->begin();
+         ci != cmdLists[i]->end(); ++ci) {
       cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator());
       localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
       std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
       std::transform(ccByproducts.begin(), ccByproducts.end(),
                      std::back_inserter(byproducts), MapToNinjaPath());
-      }
     }
+  }
 
   // maybe create .def file from list of objects
   if (gt.GetType() == cmState::SHARED_LIBRARY &&
-      this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
-    {
-    if(gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
+      this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+    if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) {
       std::string cmakeCommand =
-      this->GetLocalGenerator()->ConvertToOutputFormat(
-        cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
-      std::string name_of_def_file
-        = gt.GetSupportDirectory();
+        this->GetLocalGenerator()->ConvertToOutputFormat(
+          cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
+      std::string name_of_def_file = gt.GetSupportDirectory();
       name_of_def_file += "/" + gt.GetName();
       name_of_def_file += ".def";
       std::string cmd = cmakeCommand;
       cmd += " -E __create_def ";
-      cmd += this->GetLocalGenerator()
-        ->ConvertToOutputFormat(name_of_def_file.c_str(),
-                                cmLocalGenerator::SHELL);
+      cmd += this->GetLocalGenerator()->ConvertToOutputFormat(
+        name_of_def_file, cmOutputConverter::SHELL);
       cmd += " ";
       cmNinjaDeps objs = this->GetObjects();
       std::string obj_list_file = name_of_def_file;
       obj_list_file += ".objs";
-      cmd += this->GetLocalGenerator()
-        ->ConvertToOutputFormat(obj_list_file.c_str(),
-                                cmLocalGenerator::SHELL);
+      cmd += this->GetLocalGenerator()->ConvertToOutputFormat(
+        obj_list_file, cmOutputConverter::SHELL);
       preLinkCmdLines.push_back(cmd);
       // create a list of obj files for the -E __create_def to read
       cmGeneratedFileStream fout(obj_list_file.c_str());
-      for(cmNinjaDeps::iterator i=objs.begin(); i != objs.end(); ++i)
-        {
-        if(cmHasLiteralSuffix(*i, ".obj"))
-          {
+      for (cmNinjaDeps::iterator i = objs.begin(); i != objs.end(); ++i) {
+        if (cmHasLiteralSuffix(*i, ".obj")) {
           fout << *i << "\n";
-          }
         }
       }
     }
+  }
   // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
   // the link commands.
-  if (!preLinkCmdLines.empty())
-    {
+  if (!preLinkCmdLines.empty()) {
     const std::string homeOutDir = localGen.ConvertToOutputFormat(
-                                            localGen.GetBinaryDirectory(),
-                                            cmLocalGenerator::SHELL);
+      localGen.GetBinaryDirectory(), cmOutputConverter::SHELL);
     preLinkCmdLines.push_back("cd " + homeOutDir);
-    }
+  }
 
   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;
-    }
+  }
 
   cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
 
-  int commandLineLengthLimit = 1;
-  const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
-  if (!mf->IsDefinitionSet(forceRspFile) &&
-      cmSystemTools::GetEnv(forceRspFile) == 0)
-    {
+  int commandLineLengthLimit = -1;
+  if (!this->ForceResponseFile()) {
     commandLineLengthLimit = calculateCommandLineLengthLimit(
-                globalGen.GetRuleCmdLength(this->LanguageLinkerRule()));
-    }
+      globalGen.GetRuleCmdLength(this->LanguageLinkerRule()));
+  }
 
   const std::string rspfile =
-      std::string(cmake::GetCMakeFilesDirectoryPostSlash())
-      + gt.GetName() + ".rsp";
+    std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + gt.GetName() +
+    ".rsp";
 
   // Gather order-only dependencies.
   cmNinjaDeps orderOnlyDeps;
   this->GetLocalGenerator()->AppendTargetDepends(this->GetGeneratorTarget(),
-    orderOnlyDeps);
+                                                 orderOnlyDeps);
 
   // Ninja should restat after linking if and only if there are byproducts.
-  vars["RESTAT"] = byproducts.empty()? "" : "1";
+  vars["RESTAT"] = byproducts.empty() ? "" : "1";
 
   for (cmNinjaDeps::const_iterator oi = byproducts.begin(),
-         oe = byproducts.end();
-       oi != oe; ++oi)
-    {
+                                   oe = byproducts.end();
+       oi != oe; ++oi) {
     this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
     outputs.push_back(*oi);
-    }
+  }
 
   // Write the build statement for this target.
   bool usedResponseFile = false;
-  globalGen.WriteBuild(this->GetBuildFileStream(),
-                        comment.str(),
-                        this->LanguageLinkerRule(),
-                        outputs,
-                        explicitDeps,
-                        implicitDeps,
-                        orderOnlyDeps,
-                        vars,
-                        rspfile,
-                        commandLineLengthLimit,
-                        &usedResponseFile);
+  globalGen.WriteBuild(this->GetBuildFileStream(), comment.str(),
+                       this->LanguageLinkerRule(), outputs, explicitDeps,
+                       implicitDeps, orderOnlyDeps, vars, rspfile,
+                       commandLineLengthLimit, &usedResponseFile);
   this->WriteLinkRule(usedResponseFile);
 
-  if (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple())
-    {
-    if (targetType == cmState::EXECUTABLE)
-      {
-      globalGen.WriteBuild(this->GetBuildFileStream(),
-                            "Create executable symlink " + targetOutput,
-                            "CMAKE_SYMLINK_EXECUTABLE",
-                            cmNinjaDeps(1, targetOutput),
-                            cmNinjaDeps(1, targetOutputReal),
-                            emptyDeps,
-                            emptyDeps,
-                            symlinkVars);
-      }
-   else
-     {
+  if (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple()) {
+    if (targetType == cmState::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);
+      std::string const soName =
+        this->ConvertToNinjaPath(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);
-      globalGen.WriteBuild(this->GetBuildFileStream(),
-                                  "Create library symlink " + targetOutput,
-                                     "CMAKE_SYMLINK_LIBRARY",
-                                  symlinks,
-                                  cmNinjaDeps(1, targetOutputReal),
-                                  emptyDeps,
-                                  emptyDeps,
-                                  symlinkVars);
       }
+      symlinks.push_back(targetOutput);
+      globalGen.WriteBuild(
+        this->GetBuildFileStream(), "Create library symlink " + targetOutput,
+        "CMAKE_SYMLINK_LIBRARY", symlinks, cmNinjaDeps(1, targetOutputReal),
+        emptyDeps, emptyDeps, symlinkVars);
     }
+  }
 
   // Add aliases for the file name and the target name.
   globalGen.AddTargetAlias(this->TargetNameOut, &gt);
   globalGen.AddTargetAlias(this->GetTargetName(), &gt);
 }
 
-//----------------------------------------------------------------------------
 void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
 {
   // Write a phony output that depends on all object files.
@@ -783,11 +681,9 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
   this->GetLocalGenerator()->AppendTargetOutputs(this->GetGeneratorTarget(),
                                                  outputs);
   cmNinjaDeps depends = this->GetObjects();
-  this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
-                                              "Object library "
-                                                + this->GetTargetName(),
-                                              outputs,
-                                              depends);
+  this->GetGlobalGenerator()->WritePhonyBuild(
+    this->GetBuildFileStream(), "Object library " + this->GetTargetName(),
+    outputs, depends);
 
   // Add aliases for the target name.
   this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 556ed5e..300618c 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -11,13 +11,13 @@
   See the License for more information.
 ============================================================================*/
 #ifndef cmNinjaNormalTargetGenerator_h
-#  define cmNinjaNormalTargetGenerator_h
+#define cmNinjaNormalTargetGenerator_h
 
-#  include "cmNinjaTargetGenerator.h"
-#  include "cmNinjaTypes.h"
-#  include "cmStandardIncludes.h"
+#include "cmNinjaTargetGenerator.h"
 
-#  include <set>
+#include "cmNinjaTypes.h"
+
+#include <set>
 
 class cmSourceFile;
 class cmOSXBundleGenerator;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5ff4fdb..bad5e2f 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -11,59 +11,59 @@
   See the License for more information.
 ============================================================================*/
 #include "cmNinjaTargetGenerator.h"
-#include "cmGlobalNinjaGenerator.h"
-#include "cmLocalNinjaGenerator.h"
+
+#include "cmAlgorithms.h"
+#include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGeneratorTarget.h"
+#include "cmGlobalNinjaGenerator.h"
+#include "cmLocalNinjaGenerator.h"
+#include "cmMakefile.h"
 #include "cmNinjaNormalTargetGenerator.h"
 #include "cmNinjaUtilityTargetGenerator.h"
-#include "cmSystemTools.h"
-#include "cmMakefile.h"
-#include "cmComputeLinkInformation.h"
 #include "cmSourceFile.h"
-#include "cmCustomCommandGenerator.h"
-#include "cmAlgorithms.h"
+#include "cmSystemTools.h"
 
 #include <algorithm>
 
-cmNinjaTargetGenerator *
-cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
+cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
 {
-  switch (target->GetType())
-    {
-      case cmState::EXECUTABLE:
-      case cmState::SHARED_LIBRARY:
-      case cmState::STATIC_LIBRARY:
-      case cmState::MODULE_LIBRARY:
-      case cmState::OBJECT_LIBRARY:
-        return new cmNinjaNormalTargetGenerator(target);
-
-      case cmState::UTILITY:
-        return new cmNinjaUtilityTargetGenerator(target);;
-
-      case cmState::GLOBAL_TARGET: {
-        // We only want to process global targets that live in the home
-        // (i.e. top-level) directory.  CMake creates copies of these targets
-        // in every directory, which we don't need.
-        if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
-                   target->GetLocalGenerator()->GetSourceDirectory()) == 0)
-          return new cmNinjaUtilityTargetGenerator(target);
-        // else fallthrough
-      }
-
-      default:
-        return 0;
+  switch (target->GetType()) {
+    case cmState::EXECUTABLE:
+    case cmState::SHARED_LIBRARY:
+    case cmState::STATIC_LIBRARY:
+    case cmState::MODULE_LIBRARY:
+    case cmState::OBJECT_LIBRARY:
+      return new cmNinjaNormalTargetGenerator(target);
+
+    case cmState::UTILITY:
+      return new cmNinjaUtilityTargetGenerator(target);
+      ;
+
+    case cmState::GLOBAL_TARGET: {
+      // We only want to process global targets that live in the home
+      // (i.e. top-level) directory.  CMake creates copies of these targets
+      // in every directory, which we don't need.
+      if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
+                 target->GetLocalGenerator()->GetSourceDirectory()) == 0)
+        return new cmNinjaUtilityTargetGenerator(target);
+      // else fallthrough
     }
+
+    default:
+      return 0;
+  }
 }
 
 cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
-  : cmCommonTargetGenerator(cmOutputConverter::HOME_OUTPUT, target),
-    MacOSXContentGenerator(0),
-    OSXBundleGenerator(0),
-    MacContentFolders(),
-    LocalGenerator(
-      static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator())),
-    Objects()
+  : cmCommonTargetGenerator(cmOutputConverter::HOME_OUTPUT, target)
+  , MacOSXContentGenerator(0)
+  , OSXBundleGenerator(0)
+  , MacContentFolders()
+  , LocalGenerator(
+      static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator()))
+  , Objects()
 {
   MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
 }
@@ -95,8 +95,7 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule(
     cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName());
 }
 
-std::string
-cmNinjaTargetGenerator::OrderDependsTargetForTarget()
+std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget()
 {
   return "cmake_order_depends_target_" + this->GetTargetName();
 }
@@ -105,21 +104,19 @@ cmNinjaTargetGenerator::OrderDependsTargetForTarget()
 // void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink),
 // void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
 // Refactor it.
-std::string
-cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
-                                              const std::string& language)
+std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
+  cmSourceFile const* source, const std::string& language)
 {
   std::string flags = this->GetFlags(language);
 
   // Add Fortran format flags.
-  if(language == "Fortran")
-    {
+  if (language == "Fortran") {
     this->AppendFortranFormatFlags(flags, *source);
-    }
+  }
 
   // Add source file specific flags.
   this->LocalGenerator->AppendFlags(flags,
-    source->GetProperty("COMPILE_FLAGS"));
+                                    source->GetProperty("COMPILE_FLAGS"));
 
   return flags;
 }
@@ -128,52 +125,44 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
                                              std::string const& language)
 {
   std::vector<std::string> includes;
-  this->LocalGenerator->GetIncludeDirectories(includes,
-                                              this->GeneratorTarget,
-                                              language,
-                                              this->GetConfigName());
+  this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
+                                              language, this->GetConfigName());
   // Add include directory flags.
-  std::string includeFlags =
-    this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
-                                          language,
-        language == "RC" ? true : false,  // full include paths for RC
-                                          // needed by cmcldeps
-                                          false,
-                                          this->GetConfigName());
+  std::string includeFlags = this->LocalGenerator->GetIncludeFlags(
+    includes, this->GeneratorTarget, language,
+    language == "RC" ? true : false, // full include paths for RC
+    // needed by cmcldeps
+    false, this->GetConfigName());
   if (this->GetGlobalGenerator()->IsGCCOnWindows())
-    cmSystemTools::ReplaceString(includeFlags, "\\", "/");
+    std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/');
 
   this->LocalGenerator->AppendFlags(languageFlags, includeFlags);
 }
 
 bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
 {
-  return strcmp(
-    this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" + lang),
-    "msvc") == 0;
+  return strcmp(this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" +
+                                                       lang),
+                "msvc") == 0;
 }
 
 // TODO: Refactor with
 // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
-std::string
-cmNinjaTargetGenerator::
-ComputeDefines(cmSourceFile const* source, const std::string& language)
+std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
+                                                   const std::string& language)
 {
   std::set<std::string> defines;
-  this->LocalGenerator->AppendDefines
-    (defines,
-     source->GetProperty("COMPILE_DEFINITIONS"));
+  this->LocalGenerator->AppendDefines(
+    defines, source->GetProperty("COMPILE_DEFINITIONS"));
   {
-  std::string defPropName = "COMPILE_DEFINITIONS_";
-  defPropName += cmSystemTools::UpperCase(this->GetConfigName());
-  this->LocalGenerator->AppendDefines
-    (defines,
-     source->GetProperty(defPropName));
+    std::string defPropName = "COMPILE_DEFINITIONS_";
+    defPropName += cmSystemTools::UpperCase(this->GetConfigName());
+    this->LocalGenerator->AppendDefines(defines,
+                                        source->GetProperty(defPropName));
   }
 
   std::string definesString = this->GetDefines(language);
-  this->LocalGenerator->JoinDefines(defines, definesString,
-     language);
+  this->LocalGenerator->JoinDefines(defines, definesString, language);
 
   return definesString;
 }
@@ -187,58 +176,52 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
 
   cmComputeLinkInformation* cli =
     this->GeneratorTarget->GetLinkInformation(this->GetConfigName());
-  if(!cli)
+  if (!cli)
     return cmNinjaDeps();
 
-  const std::vector<std::string> &deps = cli->GetDepends();
+  const std::vector<std::string>& deps = cli->GetDepends();
   cmNinjaDeps result(deps.size());
   std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath());
 
   // Add a dependency on the link definitions file, if any.
-  if(this->ModuleDefinitionFile)
-    {
-    result.push_back(this->ConvertToNinjaPath(
-        this->ModuleDefinitionFile->GetFullPath()));
-    }
+  if (this->ModuleDefinitionFile) {
+    result.push_back(
+      this->ConvertToNinjaPath(this->ModuleDefinitionFile->GetFullPath()));
+  }
 
   // Add a dependency on user-specified manifest files, if any.
   std::vector<cmSourceFile const*> manifest_srcs;
   this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
   for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
-       mi != manifest_srcs.end(); ++mi)
-    {
+       mi != manifest_srcs.end(); ++mi) {
     result.push_back(this->ConvertToNinjaPath((*mi)->GetFullPath()));
-    }
+  }
 
   // Add user-specified dependencies.
   if (const char* linkDepends =
-      this->GeneratorTarget->GetProperty("LINK_DEPENDS"))
-    {
+        this->GeneratorTarget->GetProperty("LINK_DEPENDS")) {
     std::vector<std::string> linkDeps;
     cmSystemTools::ExpandListArgument(linkDepends, linkDeps);
     std::transform(linkDeps.begin(), linkDeps.end(),
                    std::back_inserter(result), MapToNinjaPath());
-    }
+  }
 
   return result;
 }
 
-std::string
-cmNinjaTargetGenerator
-::GetSourceFilePath(cmSourceFile const* source) const
+std::string cmNinjaTargetGenerator::GetSourceFilePath(
+  cmSourceFile const* source) const
 {
   return ConvertToNinjaPath(source->GetFullPath());
 }
 
-std::string
-cmNinjaTargetGenerator
-::GetObjectFilePath(cmSourceFile const* source) const
+std::string cmNinjaTargetGenerator::GetObjectFilePath(
+  cmSourceFile const* source) const
 {
   std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
-  if(!path.empty())
+  if (!path.empty())
     path += "/";
-  std::string const& objectName = this->GeneratorTarget
-                                      ->GetObjectName(source);
+  std::string const& objectName = this->GeneratorTarget->GetObjectName(source);
   path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   path += "/";
   path += objectName;
@@ -251,9 +234,8 @@ std::string cmNinjaTargetGenerator::GetTargetOutputDir() const
   return ConvertToNinjaPath(dir);
 }
 
-std::string
-cmNinjaTargetGenerator
-::GetTargetFilePath(const std::string& name) const
+std::string cmNinjaTargetGenerator::GetTargetFilePath(
+  const std::string& name) const
 {
   std::string path = this->GetTargetOutputDir();
   if (path.empty() || path == ".")
@@ -268,63 +250,51 @@ std::string cmNinjaTargetGenerator::GetTargetName() const
   return this->GeneratorTarget->GetName();
 }
 
-
 bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
 {
   cmMakefile* mf = this->GetMakefile();
   if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
-      mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
-    {
+      mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) {
     std::string pdbPath;
     std::string compilePdbPath;
-    if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
-       this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
-       this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
-       this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY)
-      {
+    if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
+        this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
+        this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+        this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
       pdbPath = this->GeneratorTarget->GetPDBDirectory(this->GetConfigName());
       pdbPath += "/";
       pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName());
-      }
-    if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
-      {
+    }
+    if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
       compilePdbPath =
-              this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
-      if(compilePdbPath.empty())
-        {
+        this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
+      if (compilePdbPath.empty()) {
         compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/";
-        }
       }
+    }
 
     vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
-                          ConvertToNinjaPath(pdbPath),
-                          cmLocalGenerator::SHELL);
+      ConvertToNinjaPath(pdbPath), cmOutputConverter::SHELL);
     vars["TARGET_COMPILE_PDB"] =
       this->GetLocalGenerator()->ConvertToOutputFormat(
-        ConvertToNinjaPath(compilePdbPath),
-        cmLocalGenerator::SHELL);
+        ConvertToNinjaPath(compilePdbPath), cmOutputConverter::SHELL);
 
     EnsureParentDirectoryExists(pdbPath);
     EnsureParentDirectoryExists(compilePdbPath);
     return true;
-    }
+  }
   return false;
 }
 
-void
-cmNinjaTargetGenerator
-::WriteLanguageRules(const std::string& language)
+void cmNinjaTargetGenerator::WriteLanguageRules(const std::string& language)
 {
 #ifdef NINJA_GEN_VERBOSE_FILES
-  this->GetRulesFileStream()
-    << "# Rules for language " << language << "\n\n";
+  this->GetRulesFileStream() << "# Rules for language " << language << "\n\n";
 #endif
   this->WriteCompileRule(language);
 }
 
-void
-cmNinjaTargetGenerator
-::WriteCompileRule(const std::string& lang)
+void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
 {
   cmLocalGenerator::RuleVariables vars;
   vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
@@ -341,55 +311,60 @@ cmNinjaTargetGenerator
 
   cmMakefile* mf = this->GetMakefile();
 
+  std::string flags = "$FLAGS";
+  std::string rspfile;
+  std::string rspcontent;
+  std::string responseFlag;
+
+  if (lang != "RC" && this->ForceResponseFile()) {
+    rspfile = "$RSP_FILE";
+    responseFlag = "@" + rspfile;
+    rspcontent = " $DEFINES $INCLUDES $FLAGS";
+    flags = responseFlag;
+    vars.Defines = "";
+    vars.Includes = "";
+  }
+
   // Tell ninja dependency format so all deps can be loaded into a database
   std::string deptype;
   std::string depfile;
   std::string cldeps;
-  std::string flags = "$FLAGS";
-  if (this->NeedDepTypeMSVC(lang))
-    {
+  if (this->NeedDepTypeMSVC(lang)) {
     deptype = "msvc";
     depfile = "";
     flags += " /showIncludes";
-    }
-  else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_"+lang))
-    {
+  } else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_" + lang)) {
     // For the MS resource compiler we need cmcldeps, but skip dependencies
     // for source-file try_compile cases because they are always fresh.
-    if (!mf->GetIsSourceFileTryCompile())
-      {
+    if (!mf->GetIsSourceFileTryCompile()) {
       deptype = "gcc";
       depfile = "$DEP_FILE";
-      const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER") ?
-                        mf->GetSafeDefinition("CMAKE_C_COMPILER") :
-                        mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
-      cldeps =  "\"";
+      const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER")
+        ? mf->GetSafeDefinition("CMAKE_C_COMPILER")
+        : mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
+      cldeps = "\"";
       cldeps += cmSystemTools::GetCMClDepsCommand();
       cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \"";
       cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
       cldeps += "\" \"" + cl + "\" ";
-      }
     }
-  else
-    {
+  } else {
     deptype = "gcc";
     const char* langdeptype = mf->GetDefinition("CMAKE_NINJA_DEPTYPE_" + lang);
-    if (langdeptype)
-      {
+    if (langdeptype) {
       deptype = langdeptype;
-      }
+    }
     depfile = "$DEP_FILE";
     const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
     std::string depfileFlags = mf->GetSafeDefinition(flagsName);
-    if (!depfileFlags.empty())
-      {
+    if (!depfileFlags.empty()) {
       cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
-      cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>",  "$out");
+      cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
       cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>",
                                    mf->GetDefinition("CMAKE_C_COMPILER"));
       flags += " " + depfileFlags;
-      }
     }
+  }
 
   vars.Flags = flags.c_str();
   vars.DependencyFile = depfile.c_str();
@@ -401,45 +376,49 @@ cmNinjaTargetGenerator
   cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
 
   // Maybe insert an include-what-you-use runner.
-  if (!compileCmds.empty() && (lang == "C" || lang == "CXX"))
-    {
+  if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
     std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
-    const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
-    if (iwyu && *iwyu)
-      {
-      std::string run_iwyu =
-        this->GetLocalGenerator()->ConvertToOutputFormat(
-          cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
-      run_iwyu += " -E __run_iwyu --iwyu=";
-      run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
+    const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
+    std::string const tidy_prop = lang + "_CLANG_TIDY";
+    const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+    if ((iwyu && *iwyu) || (tidy && *tidy)) {
+      std::string run_iwyu = this->GetLocalGenerator()->ConvertToOutputFormat(
+        cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
+      run_iwyu += " -E __run_iwyu";
+      if (iwyu && *iwyu) {
+        run_iwyu += " --iwyu=";
+        run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
+      }
+      if (tidy && *tidy) {
+        run_iwyu += " --tidy=";
+        run_iwyu += this->GetLocalGenerator()->EscapeForShell(tidy);
+        run_iwyu += " --source=$in";
+      }
       run_iwyu += " -- ";
       compileCmds.front().insert(0, run_iwyu);
-      }
     }
+  }
 
   // Maybe insert a compiler launcher like ccache or distcc
-  if (!compileCmds.empty() && (lang == "C" || lang == "CXX"))
-    {
+  if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
     std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
-    const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
-    if (clauncher && *clauncher)
-      {
+    const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
+    if (clauncher && *clauncher) {
       std::vector<std::string> launcher_cmd;
       cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
       for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
-             e = launcher_cmd.end(); i != e; ++i)
-        {
+                                              e = launcher_cmd.end();
+           i != e; ++i) {
         *i = this->LocalGenerator->EscapeForShell(*i);
-        }
+      }
       std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
       compileCmds.front().insert(0, run_launcher);
-      }
     }
+  }
 
-  if (!compileCmds.empty())
-    {
+  if (!compileCmds.empty()) {
     compileCmds.front().insert(0, cldeps);
-    }
+  }
 
   for (std::vector<std::string>::iterator i = compileCmds.begin();
        i != compileCmds.end(); ++i)
@@ -448,123 +427,104 @@ cmNinjaTargetGenerator
   std::string cmdLine =
     this->GetLocalGenerator()->BuildCommandLine(compileCmds);
 
-
   // Write the rule for compiling file of the given language.
   std::ostringstream comment;
   comment << "Rule for compiling " << lang << " files.";
   std::ostringstream description;
   description << "Building " << lang << " object $out";
-  this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(lang),
-                                      cmdLine,
-                                      description.str(),
-                                      comment.str(),
-                                      depfile,
-                                      deptype,
-                                      /*rspfile*/ "",
-                                      /*rspcontent*/ "",
-                                      /*restat*/ "",
-                                      /*generator*/ false);
+  this->GetGlobalGenerator()->AddRule(
+    this->LanguageCompilerRule(lang), cmdLine, description.str(),
+    comment.str(), depfile, deptype, rspfile, rspcontent,
+    /*restat*/ "",
+    /*generator*/ false);
 }
 
-void
-cmNinjaTargetGenerator
-::WriteObjectBuildStatements()
+void cmNinjaTargetGenerator::WriteObjectBuildStatements()
 {
   // Write comments.
   cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
   this->GetBuildFileStream()
     << "# Object build statements for "
     << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
-    << " target "
-    << this->GetTargetName()
-    << "\n\n";
+    << " target " << this->GetTargetName() << "\n\n";
 
   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->GetGeneratorTarget());
-     // Record the custom commands for this target. The container is used
-     // in WriteObjectBuildStatement when called in a loop below.
-     this->CustomCommands.push_back(cc);
-     }
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         customCommands.begin();
+       si != customCommands.end(); ++si) {
+    cmCustomCommand const* cc = (*si)->GetCustomCommand();
+    this->GetLocalGenerator()->AddCustomCommandTarget(
+      cc, this->GetGeneratorTarget());
+    // 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 const*> headerSources;
   this->GeneratorTarget->GetHeaderSources(headerSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
-    headerSources,
-    this->MacOSXContentGenerator);
+    headerSources, this->MacOSXContentGenerator);
   std::vector<cmSourceFile const*> extraSources;
   this->GeneratorTarget->GetExtraSources(extraSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
-    extraSources,
-    this->MacOSXContentGenerator);
+    extraSources, this->MacOSXContentGenerator);
   std::vector<cmSourceFile const*> externalObjects;
   this->GeneratorTarget->GetExternalObjects(externalObjects, config);
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = externalObjects.begin();
-      si != externalObjects.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         externalObjects.begin();
+       si != externalObjects.end(); ++si) {
     this->Objects.push_back(this->GetSourceFilePath(*si));
-    }
+  }
 
   cmNinjaDeps orderOnlyDeps;
   this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget,
                                                  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)
-    {
+  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->GetLocalGenerator());
     const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
-    const std::vector<std::string>& ccbyproducts= ccg.GetByproducts();
+    const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
     std::transform(ccoutputs.begin(), ccoutputs.end(),
                    std::back_inserter(orderOnlyDeps), MapToNinjaPath());
     std::transform(ccbyproducts.begin(), ccbyproducts.end(),
                    std::back_inserter(orderOnlyDeps), MapToNinjaPath());
-    }
+  }
 
-  if (!orderOnlyDeps.empty())
-    {
+  if (!orderOnlyDeps.empty()) {
     cmNinjaDeps orderOnlyTarget;
     orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
-    this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
-                                                "Order-only phony target for "
-                                                  + this->GetTargetName(),
-                                                orderOnlyTarget,
-                                                cmNinjaDeps(),
-                                                cmNinjaDeps(),
-                                                orderOnlyDeps);
-    }
+    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)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         objectSources.begin();
+       si != objectSources.end(); ++si) {
     this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty());
-    }
+  }
 
   this->GetBuildFileStream() << "\n";
 }
 
-void
-cmNinjaTargetGenerator
-::WriteObjectBuildStatement(
+void cmNinjaTargetGenerator::WriteObjectBuildStatement(
   cmSourceFile const* source, bool writeOrderDependsTargetForTarget)
 {
   std::string const language = source->GetLanguage();
   std::string const sourceFileName =
-    language=="RC" ? source->GetFullPath() : this->GetSourceFilePath(source);
-  std::string const objectDir = this->GeneratorTarget->GetSupportDirectory();
-  std::string const objectFileName = this->GetObjectFilePath(source);
+    language == "RC" ? source->GetFullPath() : this->GetSourceFilePath(source);
+  std::string const objectDir =
+    this->ConvertToNinjaPath(this->GeneratorTarget->GetSupportDirectory());
+  std::string const objectFileName =
+    this->ConvertToNinjaPath(this->GetObjectFilePath(source));
   std::string const objectFileDir =
     cmSystemTools::GetFilenamePath(objectFileName);
 
@@ -572,17 +532,14 @@ cmNinjaTargetGenerator
   vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
   vars["DEFINES"] = this->ComputeDefines(source, language);
   vars["INCLUDES"] = this->GetIncludes(language);
-  if (!this->NeedDepTypeMSVC(language))
-    {
+  if (!this->NeedDepTypeMSVC(language)) {
     vars["DEP_FILE"] =
       cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");
-    }
+  }
 
   this->ExportObjectCompileCommand(
-    language, sourceFileName,
-    objectDir, objectFileName, objectFileDir,
-    vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"]
-    );
+    language, sourceFileName, objectDir, objectFileName, objectFileDir,
+    vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"]);
 
   std::string comment;
   std::string rule = this->LanguageCompilerRule(language);
@@ -596,26 +553,23 @@ cmNinjaTargetGenerator
   explicitDeps.push_back(sourceFileName);
 
   cmNinjaDeps implicitDeps;
-  if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
+  if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
     std::vector<std::string> depList;
     cmSystemTools::ExpandListArgument(objectDeps, depList);
-    for(std::vector<std::string>::iterator odi = depList.begin();
-        odi != depList.end(); ++odi)
-      {
-      if (cmSystemTools::FileIsFullPath(*odi))
-        {
+    for (std::vector<std::string>::iterator odi = depList.begin();
+         odi != depList.end(); ++odi) {
+      if (cmSystemTools::FileIsFullPath(*odi)) {
         *odi = cmSystemTools::CollapseFullPath(*odi);
-        }
       }
+    }
     std::transform(depList.begin(), depList.end(),
                    std::back_inserter(implicitDeps), MapToNinjaPath());
   }
 
   cmNinjaDeps orderOnlyDeps;
-  if (writeOrderDependsTargetForTarget)
-    {
+  if (writeOrderDependsTargetForTarget) {
     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
@@ -630,72 +584,59 @@ cmNinjaTargetGenerator
   EnsureParentDirectoryExists(objectFileName);
 
   vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
-                         ConvertToNinjaPath(objectDir),
-                         cmLocalGenerator::SHELL);
+    objectDir, cmOutputConverter::SHELL);
   vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
-                              ConvertToNinjaPath(objectFileDir),
-                              cmLocalGenerator::SHELL);
+    objectFileDir, cmOutputConverter::SHELL);
 
-  this->addPoolNinjaVariable("JOB_POOL_COMPILE",
-                             this->GetGeneratorTarget(), vars);
+  this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
+                             vars);
 
   this->SetMsvcTargetPdbVariable(vars);
 
-  this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(),
-                                         comment,
-                                         rule,
-                                         outputs,
-                                         explicitDeps,
-                                         implicitDeps,
-                                         orderOnlyDeps,
-                                         vars);
+  bool const isRC = (language == "RC");
+  int const commandLineLengthLimit =
+    ((!isRC && this->ForceResponseFile())) ? -1 : 0;
+  std::string const rspfile = objectFileName + ".rsp";
+
+  this->GetGlobalGenerator()->WriteBuild(
+    this->GetBuildFileStream(), comment, rule, outputs, explicitDeps,
+    implicitDeps, orderOnlyDeps, vars, rspfile, commandLineLengthLimit);
 
-  if(const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
+  if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
     std::vector<std::string> outputList;
     cmSystemTools::ExpandListArgument(objectOutputs, outputList);
     std::transform(outputList.begin(), outputList.end(), outputList.begin(),
                    MapToNinjaPath());
     this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
                                                 "Additional output files.",
-                                                outputList,
-                                                outputs);
+                                                outputList, outputs);
   }
 }
 
-void
-cmNinjaTargetGenerator
-::ExportObjectCompileCommand(
-  std::string const& language,
-  std::string const& sourceFileName,
-  std::string const& objectDir,
-  std::string const& objectFileName,
-  std::string const& objectFileDir,
-  std::string const& flags,
-  std::string const& defines,
-  std::string const& includes
-  )
+void cmNinjaTargetGenerator::ExportObjectCompileCommand(
+  std::string const& language, std::string const& sourceFileName,
+  std::string const& objectDir, std::string const& objectFileName,
+  std::string const& objectFileDir, std::string const& flags,
+  std::string const& defines, std::string const& includes)
 {
-  if(!this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
-    {
+  if (!this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS")) {
     return;
-    }
+  }
 
   cmLocalGenerator::RuleVariables compileObjectVars;
   compileObjectVars.Language = language.c_str();
 
   std::string escapedSourceFileName = sourceFileName;
 
-  if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) {
     escapedSourceFileName = cmSystemTools::CollapseFullPath(
-      escapedSourceFileName,
-      this->GetGlobalGenerator()->GetCMakeInstance()->
-      GetHomeOutputDirectory());
-    }
+      escapedSourceFileName, this->GetGlobalGenerator()
+                               ->GetCMakeInstance()
+                               ->GetHomeOutputDirectory());
+  }
 
-  escapedSourceFileName =
-    this->LocalGenerator->ConvertToOutputFormat(
-      escapedSourceFileName, cmLocalGenerator::SHELL);
+  escapedSourceFileName = this->LocalGenerator->ConvertToOutputFormat(
+    escapedSourceFileName, cmOutputConverter::SHELL);
 
   compileObjectVars.Source = escapedSourceFileName.c_str();
   compileObjectVars.Object = objectFileName.c_str();
@@ -721,60 +662,51 @@ cmNinjaTargetGenerator
   std::string cmdLine =
     this->GetLocalGenerator()->BuildCommandLine(compileCmds);
 
-  this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine,
-                                                   sourceFileName);
+  this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine, sourceFileName);
 }
 
-void
-cmNinjaTargetGenerator
-::EnsureDirectoryExists(const std::string& path) const
+void cmNinjaTargetGenerator::EnsureDirectoryExists(
+  const std::string& path) const
 {
-  if (cmSystemTools::FileIsFullPath(path.c_str()))
-    {
+  if (cmSystemTools::FileIsFullPath(path.c_str())) {
     cmSystemTools::MakeDirectory(path.c_str());
-    }
-  else
-    {
-    const std::string fullPath = std::string(this->GetGlobalGenerator()->
-                                 GetCMakeInstance()->GetHomeOutputDirectory())
-                                   + "/" + path;
+  } else {
+    cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator();
+    std::string fullPath =
+      std::string(gg->GetCMakeInstance()->GetHomeOutputDirectory());
+    // Also ensures their is a trailing slash.
+    gg->StripNinjaOutputPathPrefixAsSuffix(fullPath);
+    fullPath += path;
     cmSystemTools::MakeDirectory(fullPath.c_str());
-    }
+  }
 }
 
-void
-cmNinjaTargetGenerator
-::EnsureParentDirectoryExists(const std::string& path) const
+void cmNinjaTargetGenerator::EnsureParentDirectoryExists(
+  const std::string& path) const
 {
   EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path));
 }
 
-
-//----------------------------------------------------------------------------
-void
-cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
+void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
   cmSourceFile const& source, const char* pkgloc)
 {
   // Skip OS X content when not building a Framework or Bundle.
-  if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple())
-    {
+  if (!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) {
     return;
-    }
+  }
 
   std::string macdir =
     this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc);
 
   // Get the input file location.
   std::string input = source.GetFullPath();
-  input =
-    this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input);
+  input = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input);
 
   // Get the output file location.
   std::string output = macdir;
   output += "/";
   output += cmSystemTools::GetFilenameName(input);
-  output =
-    this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output);
+  output = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output);
 
   // Write a build statement to copy the content into the bundle.
   this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input,
@@ -785,13 +717,18 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
 }
 
 void cmNinjaTargetGenerator::addPoolNinjaVariable(
-                                              const std::string& pool_property,
-                                              cmGeneratorTarget* target,
-                                              cmNinjaVars& vars)
+  const std::string& pool_property, cmGeneratorTarget* target,
+  cmNinjaVars& vars)
 {
-    const char* pool = target->GetProperty(pool_property);
-    if (pool)
-      {
-      vars["pool"] = pool;
-      }
+  const char* pool = target->GetProperty(pool_property);
+  if (pool) {
+    vars["pool"] = pool;
+  }
+}
+
+bool cmNinjaTargetGenerator::ForceResponseFile()
+{
+  static std::string const forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
+  return (this->GetMakefile()->IsDefinitionSet(forceRspFile) ||
+          cmSystemTools::GetEnv(forceRspFile) != 0);
 }
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index e3ec423..414aa09 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -15,10 +15,9 @@
 
 #include "cmCommonTargetGenerator.h"
 
-#include "cmStandardIncludes.h"
-#include "cmNinjaTypes.h"
 #include "cmGlobalNinjaGenerator.h"
 #include "cmLocalNinjaGenerator.h"
+#include "cmNinjaTypes.h"
 #include "cmOSXBundleGenerator.h"
 
 class cmTarget;
@@ -28,7 +27,7 @@ class cmMakefile;
 class cmSourceFile;
 class cmCustomCommand;
 
-class cmNinjaTargetGenerator: public cmCommonTargetGenerator
+class cmNinjaTargetGenerator : public cmCommonTargetGenerator
 {
 public:
   /// Create a cmNinjaTargetGenerator according to the @a target's type.
@@ -47,22 +46,24 @@ public:
   bool NeedDepTypeMSVC(const std::string& lang) const;
 
 protected:
-
   bool SetMsvcTargetPdbVariable(cmNinjaVars&) const;
 
   cmGeneratedFileStream& GetBuildFileStream() const;
   cmGeneratedFileStream& GetRulesFileStream() const;
 
   cmGeneratorTarget* GetGeneratorTarget() const
-  { return this->GeneratorTarget; }
+  {
+    return this->GeneratorTarget;
+  }
 
   cmLocalNinjaGenerator* GetLocalGenerator() const
-  { return this->LocalGenerator; }
+  {
+    return this->LocalGenerator;
+  }
 
   cmGlobalNinjaGenerator* GetGlobalGenerator() const;
 
-  cmMakefile* GetMakefile() const
-  { return this->Makefile; }
+  cmMakefile* GetMakefile() const { return this->Makefile; }
 
   std::string LanguageCompilerRule(const std::string& lang) const;
 
@@ -83,10 +84,12 @@ protected:
   std::string ComputeDefines(cmSourceFile const* source,
                              const std::string& language);
 
-  std::string ConvertToNinjaPath(const std::string& path) const {
+  std::string ConvertToNinjaPath(const std::string& path) const
+  {
     return this->GetGlobalGenerator()->ConvertToNinjaPath(path);
   }
-  cmGlobalNinjaGenerator::MapToNinjaPathImpl MapToNinjaPath() const {
+  cmGlobalNinjaGenerator::MapToNinjaPathImpl MapToNinjaPath() const
+  {
     return this->GetGlobalGenerator()->MapToNinjaPath();
   }
 
@@ -112,28 +115,24 @@ protected:
                                  bool writeOrderDependsTargetForTarget);
 
   void ExportObjectCompileCommand(
-    std::string const& language,
-    std::string const& sourceFileName,
-    std::string const& objectDir,
-    std::string const& objectFileName,
-    std::string const& objectFileDir,
-    std::string const& flags,
-    std::string const& defines,
-    std::string const& includes
-    );
-
-  cmNinjaDeps GetObjects() const
-  { return this->Objects; }
+    std::string const& language, std::string const& sourceFileName,
+    std::string const& objectDir, std::string const& objectFileName,
+    std::string const& objectFileDir, std::string const& flags,
+    std::string const& defines, std::string const& includes);
+
+  cmNinjaDeps GetObjects() const { return this->Objects; }
 
   void EnsureDirectoryExists(const std::string& dir) const;
   void EnsureParentDirectoryExists(const std::string& path) const;
 
   // write rules for Mac OS X Application Bundle content.
-  struct MacOSXContentGeneratorType :
-    cmOSXBundleGenerator::MacOSXContentGeneratorType
+  struct MacOSXContentGeneratorType
+    : cmOSXBundleGenerator::MacOSXContentGeneratorType
   {
-    MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) :
-      Generator(g)  {}
+    MacOSXContentGeneratorType(cmNinjaTargetGenerator* g)
+      : Generator(g)
+    {
+    }
 
     void operator()(cmSourceFile const& source, const char* pkgloc);
 
@@ -142,15 +141,15 @@ protected:
   };
   friend struct MacOSXContentGeneratorType;
 
-
   MacOSXContentGeneratorType* MacOSXContentGenerator;
   // Properly initialized by sub-classes.
   cmOSXBundleGenerator* OSXBundleGenerator;
   std::set<std::string> MacContentFolders;
 
   void addPoolNinjaVariable(const std::string& pool_property,
-                            cmGeneratorTarget* target,
-                            cmNinjaVars& vars);
+                            cmGeneratorTarget* target, cmNinjaVars& vars);
+
+  bool ForceResponseFile();
 
 private:
   cmLocalNinjaGenerator* LocalGenerator;
diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h
index 498f6b6..82a5220 100644
--- a/Source/cmNinjaTypes.h
+++ b/Source/cmNinjaTypes.h
@@ -11,7 +11,9 @@
   See the License for more information.
 ============================================================================*/
 #ifndef cmNinjaTypes_h
-#  define cmNinjaTypes_h
+#define cmNinjaTypes_h
+
+#include "cmStandardIncludes.h"
 
 typedef std::vector<std::string> cmNinjaDeps;
 typedef std::map<std::string, std::string> cmNinjaVars;
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index ac66fcd..f7a7f38 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -11,28 +11,35 @@
   See the License for more information.
 ============================================================================*/
 #include "cmNinjaUtilityTargetGenerator.h"
+
 #include "cmCustomCommand.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalNinjaGenerator.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
-#include "cmCustomCommandGenerator.h"
 
 cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
-    cmGeneratorTarget *target)
-  : cmNinjaTargetGenerator(target) {}
+  cmGeneratorTarget* target)
+  : cmNinjaTargetGenerator(target)
+{
+}
 
-cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {}
+cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator()
+{
+}
 
 void cmNinjaUtilityTargetGenerator::Generate()
 {
   std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash();
   utilCommandName += this->GetTargetName() + ".util";
+  utilCommandName =
+    this->GetGlobalGenerator()->NinjaOutputPath(utilCommandName);
 
   std::vector<std::string> commands;
   cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
 
-  const std::vector<cmCustomCommand> *cmdLists[2] = {
+  const std::vector<cmCustomCommand>* cmdLists[2] = {
     &this->GetGeneratorTarget()->GetPreBuildCommands(),
     &this->GetGeneratorTarget()->GetPostBuildCommands()
   };
@@ -40,8 +47,9 @@ void cmNinjaUtilityTargetGenerator::Generate()
   bool uses_terminal = false;
 
   for (unsigned i = 0; i != 2; ++i) {
-    for (std::vector<cmCustomCommand>::const_iterator
-         ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
+    for (std::vector<cmCustomCommand>::const_iterator ci =
+           cmdLists[i]->begin();
+         ci != cmdLists[i]->end(); ++ci) {
       cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
                                    this->GetLocalGenerator());
       this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
@@ -55,18 +63,16 @@ void cmNinjaUtilityTargetGenerator::Generate()
   }
 
   std::vector<cmSourceFile*> sources;
-  std::string config = this->GetMakefile()
-                           ->GetSafeDefinition("CMAKE_BUILD_TYPE");
+  std::string config =
+    this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
   this->GetGeneratorTarget()->GetSourceFiles(sources, config);
-  for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
-      source != sources.end(); ++source)
-    {
-    if(cmCustomCommand* cc = (*source)->GetCustomCommand())
-      {
+  for (std::vector<cmSourceFile*>::const_iterator source = sources.begin();
+       source != sources.end(); ++source) {
+    if (cmCustomCommand* cc = (*source)->GetCustomCommand()) {
       cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
                                    this->GetLocalGenerator());
-      this->GetLocalGenerator()->AddCustomCommandTarget(cc,
-          this->GetGeneratorTarget());
+      this->GetLocalGenerator()->AddCustomCommandTarget(
+        cc, this->GetGeneratorTarget());
 
       // Depend on all custom command outputs.
       const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
@@ -75,8 +81,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
                      std::back_inserter(deps), MapToNinjaPath());
       std::transform(ccByproducts.begin(), ccByproducts.end(),
                      std::back_inserter(deps), MapToNinjaPath());
-      }
     }
+  }
 
   this->GetLocalGenerator()->AppendTargetOutputs(this->GetGeneratorTarget(),
                                                  outputs);
@@ -84,16 +90,14 @@ void cmNinjaUtilityTargetGenerator::Generate()
                                                  deps);
 
   if (commands.empty()) {
-    this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
-                                                "Utility command for "
-                                                  + this->GetTargetName(),
-                                                outputs,
-                                                deps);
+    this->GetGlobalGenerator()->WritePhonyBuild(
+      this->GetBuildFileStream(),
+      "Utility command for " + this->GetTargetName(), outputs, deps);
   } else {
     std::string command =
       this->GetLocalGenerator()->BuildCommandLine(commands);
-    const char *echoStr =
-        this->GetGeneratorTarget()->GetProperty("EchoString");
+    const char* echoStr =
+      this->GetGeneratorTarget()->GetProperty("EchoString");
     std::string desc;
     if (echoStr)
       desc = echoStr;
@@ -103,43 +107,38 @@ void cmNinjaUtilityTargetGenerator::Generate()
     // TODO: fix problematic global targets.  For now, search and replace the
     // makefile vars.
     cmSystemTools::ReplaceString(
-      command,
-      "$(CMAKE_SOURCE_DIR)",
-      this->GetLocalGenerator()->ConvertToOutputFormat(
-        this->GetLocalGenerator()->GetSourceDirectory(),
-        cmLocalGenerator::SHELL).c_str());
+      command, "$(CMAKE_SOURCE_DIR)",
+      this->GetLocalGenerator()
+        ->ConvertToOutputFormat(
+          this->GetLocalGenerator()->GetSourceDirectory(),
+          cmOutputConverter::SHELL)
+        .c_str());
     cmSystemTools::ReplaceString(
-      command,
-      "$(CMAKE_BINARY_DIR)",
-      this->GetLocalGenerator()->ConvertToOutputFormat(
-        this->GetLocalGenerator()->GetBinaryDirectory(),
-        cmLocalGenerator::SHELL).c_str());
+      command, "$(CMAKE_BINARY_DIR)",
+      this->GetLocalGenerator()
+        ->ConvertToOutputFormat(
+          this->GetLocalGenerator()->GetBinaryDirectory(),
+          cmOutputConverter::SHELL)
+        .c_str());
     cmSystemTools::ReplaceString(command, "$(ARGS)", "");
 
     if (command.find('$') != std::string::npos)
       return;
 
-    for (cmNinjaDeps::const_iterator
-           oi = util_outputs.begin(), oe = util_outputs.end();
-         oi != oe; ++oi)
-      {
+    for (cmNinjaDeps::const_iterator oi = util_outputs.begin(),
+                                     oe = util_outputs.end();
+         oi != oe; ++oi) {
       this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
-      }
+    }
 
     this->GetGlobalGenerator()->WriteCustomCommandBuild(
-      command,
-      desc,
-      "Utility command for " + this->GetTargetName(),
+      command, desc, "Utility command for " + this->GetTargetName(),
       uses_terminal,
-      /*restat*/true,
-      util_outputs,
-      deps);
-
-    this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
-                                                "",
-                                                outputs,
-                                                cmNinjaDeps(1, utilCommandName)
-                                                );
+      /*restat*/ true, util_outputs, deps);
+
+    this->GetGlobalGenerator()->WritePhonyBuild(
+      this->GetBuildFileStream(), "", outputs,
+      cmNinjaDeps(1, utilCommandName));
   }
 
   this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h
index add0291..fec2946 100644
--- a/Source/cmNinjaUtilityTargetGenerator.h
+++ b/Source/cmNinjaUtilityTargetGenerator.h
@@ -11,10 +11,11 @@
   See the License for more information.
 ============================================================================*/
 #ifndef cmNinjaUtilityTargetGenerator_h
-#  define cmNinjaUtilityTargetGenerator_h
+#define cmNinjaUtilityTargetGenerator_h
 
-#  include "cmNinjaTargetGenerator.h"
-#  include "cmNinjaTypes.h"
+#include "cmNinjaTargetGenerator.h"
+
+#include "cmNinjaTypes.h"
 
 class cmSourceFile;
 
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 934e198..f62ba40 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -10,34 +10,30 @@
   See the License for more information.
 ============================================================================*/
 #include "cmOSXBundleGenerator.h"
+
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmTarget.h"
-#include "cmLocalGenerator.h"
 
 #include <cassert>
 
-//----------------------------------------------------------------------------
-cmOSXBundleGenerator::
-cmOSXBundleGenerator(cmGeneratorTarget* target,
-                     const std::string& configName)
- : GT(target)
- , Makefile(target->Target->GetMakefile())
- , LocalGenerator(target->GetLocalGenerator())
- , ConfigName(configName)
- , MacContentFolders(0)
+cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target,
+                                           const std::string& configName)
+  : GT(target)
+  , Makefile(target->Target->GetMakefile())
+  , LocalGenerator(target->GetLocalGenerator())
+  , ConfigName(configName)
+  , MacContentFolders(0)
 {
   if (this->MustSkip())
     return;
-
 }
 
-//----------------------------------------------------------------------------
 bool cmOSXBundleGenerator::MustSkip()
 {
   return !this->GT->HaveWellDefinedOutputFiles();
 }
 
-//----------------------------------------------------------------------------
 void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
                                            std::string& outpath)
 {
@@ -59,16 +55,14 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
   plist += "/";
   plist += this->GT->GetAppBundleDirectory(this->ConfigName, true);
   plist += "/Info.plist";
-  this->LocalGenerator->GenerateAppleInfoPList(this->GT,
-                                               targetName,
+  this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName,
                                                plist.c_str());
   this->Makefile->AddCMakeOutputFile(plist);
   outpath = newoutpath;
 }
 
-//----------------------------------------------------------------------------
-void cmOSXBundleGenerator::CreateFramework(
-  const std::string& targetName, const std::string& outpath)
+void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
+                                           const std::string& outpath)
 {
   if (this->MustSkip())
     return;
@@ -76,27 +70,25 @@ void cmOSXBundleGenerator::CreateFramework(
   assert(this->MacContentFolders);
 
   // Compute the location of the top-level foo.framework directory.
-  std::string contentdir = outpath + "/" +
-    this->GT->GetFrameworkDirectory(this->ConfigName, true);
+  std::string contentdir =
+    outpath + "/" + this->GT->GetFrameworkDirectory(this->ConfigName, true);
   contentdir += "/";
 
-  std::string newoutpath = outpath + "/" +
-    this->GT->GetFrameworkDirectory(this->ConfigName, false);
+  std::string newoutpath =
+    outpath + "/" + this->GT->GetFrameworkDirectory(this->ConfigName, false);
 
   std::string frameworkVersion = this->GT->GetFrameworkVersion();
 
   // Configure the Info.plist file
   std::string plist = newoutpath;
-  if (!this->Makefile->PlatformIsAppleIos())
-    {
+  if (!this->Makefile->PlatformIsAppleIos()) {
     // Put the Info.plist file into the Resources directory.
     this->MacContentFolders->insert("Resources");
     plist += "/Resources";
-    }
+  }
   plist += "/Info.plist";
   std::string name = cmSystemTools::GetFilenameName(targetName);
-  this->LocalGenerator->GenerateFrameworkInfoPList(this->GT,
-                                                   name,
+  this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name,
                                                    plist.c_str());
 
   // Generate Versions directory only for MacOSX frameworks
@@ -108,7 +100,6 @@ void cmOSXBundleGenerator::CreateFramework(
   std::string oldName;
   std::string newName;
 
-
   // Make foo.framework/Versions
   std::string versions = contentdir;
   versions += "Versions";
@@ -135,43 +126,39 @@ void cmOSXBundleGenerator::CreateFramework(
   this->Makefile->AddCMakeOutputFile(newName);
 
   // Resources -> Versions/Current/Resources
-  if(this->MacContentFolders->find("Resources") !=
-     this->MacContentFolders->end())
-    {
+  if (this->MacContentFolders->find("Resources") !=
+      this->MacContentFolders->end()) {
     oldName = "Versions/Current/Resources";
     newName = contentdir;
     newName += "Resources";
     cmSystemTools::RemoveFile(newName);
     cmSystemTools::CreateSymlink(oldName, newName);
     this->Makefile->AddCMakeOutputFile(newName);
-    }
+  }
 
   // Headers -> Versions/Current/Headers
-  if(this->MacContentFolders->find("Headers") !=
-     this->MacContentFolders->end())
-    {
+  if (this->MacContentFolders->find("Headers") !=
+      this->MacContentFolders->end()) {
     oldName = "Versions/Current/Headers";
     newName = contentdir;
     newName += "Headers";
     cmSystemTools::RemoveFile(newName);
     cmSystemTools::CreateSymlink(oldName, newName);
     this->Makefile->AddCMakeOutputFile(newName);
-    }
+  }
 
   // PrivateHeaders -> Versions/Current/PrivateHeaders
-  if(this->MacContentFolders->find("PrivateHeaders") !=
-     this->MacContentFolders->end())
-    {
+  if (this->MacContentFolders->find("PrivateHeaders") !=
+      this->MacContentFolders->end()) {
     oldName = "Versions/Current/PrivateHeaders";
     newName = contentdir;
     newName += "PrivateHeaders";
     cmSystemTools::RemoveFile(newName);
     cmSystemTools::CreateSymlink(oldName, newName);
     this->Makefile->AddCMakeOutputFile(newName);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
                                           const std::string& root)
 {
@@ -187,47 +174,38 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
 
   // Configure the Info.plist file.  Note that it needs the executable name
   // to be set.
-  std::string plist = root + "/" +
-    this->GT->GetCFBundleDirectory(this->ConfigName, true);
+  std::string plist =
+    root + "/" + this->GT->GetCFBundleDirectory(this->ConfigName, true);
   plist += "/Info.plist";
   std::string name = cmSystemTools::GetFilenameName(targetName);
-  this->LocalGenerator->GenerateAppleInfoPList(this->GT,
-                                               name,
-                                               plist.c_str());
+  this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str());
   this->Makefile->AddCMakeOutputFile(plist);
 }
 
-//----------------------------------------------------------------------------
-void
-cmOSXBundleGenerator::
-GenerateMacOSXContentStatements(
-                              std::vector<cmSourceFile const*> const& sources,
-                              MacOSXContentGeneratorType* generator)
+void cmOSXBundleGenerator::GenerateMacOSXContentStatements(
+  std::vector<cmSourceFile const*> const& sources,
+  MacOSXContentGeneratorType* generator)
 {
   if (this->MustSkip())
     return;
 
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = sources.begin(); si != sources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin();
+       si != sources.end(); ++si) {
     cmGeneratorTarget::SourceFileFlags tsFlags =
       this->GT->GetTargetSourceFileFlags(*si);
-    if(tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal)
-      {
+    if (tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal) {
       (*generator)(**si, tsFlags.MacFolder);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc)
+std::string cmOSXBundleGenerator::InitMacOSXContentDirectory(
+  const char* pkgloc)
 {
   // Construct the full path to the content subdirectory.
 
-  std::string macdir =
-    this->GT->GetMacContentDirectory(this->ConfigName,
-                                         /*implib*/ false);
+  std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName,
+                                                        /*implib*/ false);
   macdir += "/";
   macdir += pkgloc;
   cmSystemTools::MakeDirectory(macdir.c_str());
@@ -235,9 +213,9 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc)
   // Record use of this content location.  Only the first level
   // directory is needed.
   {
-  std::string loc = pkgloc;
-  loc = loc.substr(0, loc.find('/'));
-  this->MacContentFolders->insert(loc);
+    std::string loc = pkgloc;
+    loc = loc.substr(0, loc.find('/'));
+    this->MacContentFolders->insert(loc);
   }
 
   return macdir;
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index f945c15..55a3c75 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -13,10 +13,11 @@
 #define cmOSXBundleGenerator_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmSourceFile.h"
 
-#include <string>
 #include <set>
+#include <string>
 
 class cmTarget;
 class cmMakefile;
@@ -34,12 +35,10 @@ public:
   void CreateAppBundle(const std::string& targetName, std::string& root);
 
   // create a framework at a given root
-  void CreateFramework(const std::string& targetName,
-                       const std::string& root);
+  void CreateFramework(const std::string& targetName, const std::string& root);
 
   // create a cf bundle at a given root
-  void CreateCFBundle(const std::string& targetName,
-                      const std::string& root);
+  void CreateCFBundle(const std::string& targetName, const std::string& root);
 
   struct MacOSXContentGeneratorType
   {
@@ -54,7 +53,9 @@ public:
   std::string InitMacOSXContentDirectory(const char* pkgloc);
 
   void SetMacContentFolders(std::set<std::string>* macContentFolders)
-  { this->MacContentFolders = macContentFolders; }
+  {
+    this->MacContentFolders = macContentFolders;
+  }
 
 private:
   bool MustSkip();
@@ -67,5 +68,4 @@ private:
   std::set<std::string>* MacContentFolders;
 };
 
-
 #endif
diff --git a/Source/cmObject.h b/Source/cmObject.h
index ca6a54f..d883c52 100644
--- a/Source/cmObject.h
+++ b/Source/cmObject.h
@@ -36,16 +36,13 @@ public:
   /**
    * Returns true if this class is the given class, or a subclass of it.
    */
-  static bool IsTypeOf(const char *type)
-    { return !strcmp("cmObject", type); }
+  static bool IsTypeOf(const char* type) { return !strcmp("cmObject", type); }
 
   /**
    * Returns true if this object is an instance of the given class or
    * a subclass of it.
    */
-  virtual bool IsA(const char *type)
-    { return cmObject::IsTypeOf(type); }
+  virtual bool IsA(const char* type) { return cmObject::IsTypeOf(type); }
 };
 
 #endif
-
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index 92be5f1..f6f0ec3 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -12,53 +12,46 @@
 #include "cmOptionCommand.h"
 
 // cmOptionCommand
-bool cmOptionCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
+                                  cmExecutionStatus&)
 {
   bool argError = false;
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     argError = true;
-    }
+  }
   // for VTK 4.0 we have to support the option command with more than 3
   // arguments if CMAKE_MINIMUM_REQUIRED_VERSION is not defined, if
   // CMAKE_MINIMUM_REQUIRED_VERSION is defined, then we can have stricter
   // checking.
-  if(this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"))
-    {
-    if(args.size() > 3)
-      {
+  if (this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
+    if (args.size() > 3) {
       argError = true;
-      }
     }
-  if(argError)
-    {
+  }
+  if (argError) {
     std::string m = "called with incorrect number of arguments: ";
     m += cmJoin(args, " ");
     this->SetError(m);
     return false;
-    }
+  }
 
   std::string initialValue = "Off";
   // Now check and see if the value has been stored in the cache
   // already, if so use that value and don't look for the program
   cmState* state = this->Makefile->GetState();
   const char* existingValue = state->GetCacheEntryValue(args[0]);
-  if(existingValue)
-    {
-    if (state->GetCacheEntryType(args[0]) != cmState::UNINITIALIZED)
-      {
+  if (existingValue) {
+    if (state->GetCacheEntryType(args[0]) != cmState::UNINITIALIZED) {
       state->SetCacheEntryProperty(args[0], "HELPSTRING", args[1]);
       return true;
-      }
-    initialValue = existingValue;
     }
-  if(args.size() == 3)
-    {
+    initialValue = existingValue;
+  }
+  if (args.size() == 3) {
     initialValue = args[2];
-    }
+  }
   bool init = cmSystemTools::IsOn(initialValue.c_str());
-  this->Makefile->AddCacheDefinition(args[0], init? "ON":"OFF",
+  this->Makefile->AddCacheDefinition(args[0], init ? "ON" : "OFF",
                                      args[1].c_str(), cmState::BOOL);
   return true;
 }
diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h
index 12a6472..491f45e 100644
--- a/Source/cmOptionCommand.h
+++ b/Source/cmOptionCommand.h
@@ -25,22 +25,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmOptionCommand;
-    }
+  virtual cmCommand* Clone() { return new cmOptionCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "option";}
+  virtual std::string GetName() const { return "option"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -50,6 +47,4 @@ public:
   cmTypeMacro(cmOptionCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 61efd01..00606c7 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -11,10 +11,10 @@
 ============================================================================*/
 #include "cmOrderDirectories.h"
 
+#include "cmAlgorithms.h"
 #include "cmGlobalGenerator.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
-#include "cmAlgorithms.h"
 
 #include <assert.h>
 
@@ -28,88 +28,80 @@ Directory ordering computation.
     for shared libraries.
 */
 
-//----------------------------------------------------------------------------
 class cmOrderDirectoriesConstraint
 {
 public:
-  cmOrderDirectoriesConstraint(cmOrderDirectories* od,
-                               std::string const& file):
-    OD(od), GlobalGenerator(od->GlobalGenerator)
-    {
+  cmOrderDirectoriesConstraint(cmOrderDirectories* od, std::string const& file)
+    : OD(od)
+    , GlobalGenerator(od->GlobalGenerator)
+  {
     this->FullPath = file;
 
-    if(file.rfind(".framework") != std::string::npos)
-      {
-      static cmsys::RegularExpression
-        splitFramework("^(.*)/(.*).framework/(.*)$");
-      if(splitFramework.find(file) &&
-        (std::string::npos !=
-         splitFramework.match(3).find(splitFramework.match(2))))
-        {
+    if (file.rfind(".framework") != std::string::npos) {
+      static cmsys::RegularExpression splitFramework(
+        "^(.*)/(.*).framework/(.*)$");
+      if (splitFramework.find(file) &&
+          (std::string::npos !=
+           splitFramework.match(3).find(splitFramework.match(2)))) {
         this->Directory = splitFramework.match(1);
         this->FileName =
           std::string(file.begin() + this->Directory.size() + 1, file.end());
-        }
       }
+    }
 
-    if(this->FileName.empty())
-      {
+    if (this->FileName.empty()) {
       this->Directory = cmSystemTools::GetFilenamePath(file);
       this->FileName = cmSystemTools::GetFilenameName(file);
-      }
     }
+  }
   virtual ~cmOrderDirectoriesConstraint() {}
 
   void AddDirectory()
-    {
+  {
     this->DirectoryIndex = this->OD->AddOriginalDirectory(this->Directory);
-    }
+  }
 
   virtual void Report(std::ostream& e) = 0;
 
   void FindConflicts(unsigned int index)
-    {
-    for(unsigned int i=0; i < this->OD->OriginalDirectories.size(); ++i)
-      {
+  {
+    for (unsigned int i = 0; i < this->OD->OriginalDirectories.size(); ++i) {
       // Check if this directory conflicts with the entry.
       std::string const& dir = this->OD->OriginalDirectories[i];
       if (!this->OD->IsSameDirectory(dir, this->Directory) &&
-          this->FindConflict(dir))
-        {
+          this->FindConflict(dir)) {
         // The library will be found in this directory but this is not
         // the directory named for it.  Add an entry to make sure the
         // desired directory comes before this one.
         cmOrderDirectories::ConflictPair p(this->DirectoryIndex, index);
         this->OD->ConflictGraph[i].push_back(p);
-        }
       }
     }
+  }
 
   void FindImplicitConflicts(std::ostringstream& w)
-    {
+  {
     bool first = true;
-    for(unsigned int i=0; i < this->OD->OriginalDirectories.size(); ++i)
-      {
+    for (unsigned int i = 0; i < this->OD->OriginalDirectories.size(); ++i) {
       // Check if this directory conflicts with the entry.
       std::string const& dir = this->OD->OriginalDirectories[i];
-      if(dir != this->Directory &&
-         cmSystemTools::GetRealPath(dir) !=
-         cmSystemTools::GetRealPath(this->Directory) &&
-         this->FindConflict(dir))
-        {
+      if (dir != this->Directory &&
+          cmSystemTools::GetRealPath(dir) !=
+            cmSystemTools::GetRealPath(this->Directory) &&
+          this->FindConflict(dir)) {
         // The library will be found in this directory but it is
         // supposed to be found in an implicit search directory.
-        if(first)
-          {
+        if (first) {
           first = false;
           w << "  ";
           this->Report(w);
           w << " in " << this->Directory << " may be hidden by files in:\n";
-          }
-        w << "    " << dir << "\n";
         }
+        w << "    " << dir << "\n";
       }
     }
+  }
+
 protected:
   virtual bool FindConflict(std::string const& dir) = 0;
 
@@ -127,7 +119,6 @@ protected:
   int DirectoryIndex;
 };
 
-//----------------------------------------------------------------------------
 bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
                                                    std::string const& name)
 {
@@ -135,12 +126,11 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
   std::string file = dir;
   file += "/";
   file += name;
-  if(cmSystemTools::FileExists(file.c_str(), true))
-    {
+  if (cmSystemTools::FileExists(file.c_str(), true)) {
     // The file conflicts only if it is not the same as the original
     // file due to a symlink or hardlink.
     return !cmSystemTools::SameFile(this->FullPath, file);
-    }
+  }
 
   // Check if the file will be built by cmake.
   std::set<std::string> const& files =
@@ -149,134 +139,115 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
   return fi != files.end();
 }
 
-//----------------------------------------------------------------------------
-class cmOrderDirectoriesConstraintSOName: public cmOrderDirectoriesConstraint
+class cmOrderDirectoriesConstraintSOName : public cmOrderDirectoriesConstraint
 {
 public:
   cmOrderDirectoriesConstraintSOName(cmOrderDirectories* od,
                                      std::string const& file,
-                                     const char* soname):
-    cmOrderDirectoriesConstraint(od, file), SOName(soname? soname : "")
-    {
-    if(this->SOName.empty())
-      {
+                                     const char* soname)
+    : cmOrderDirectoriesConstraint(od, file)
+    , SOName(soname ? soname : "")
+  {
+    if (this->SOName.empty()) {
       // Try to guess the soname.
       std::string soguess;
-      if(cmSystemTools::GuessLibrarySOName(file, soguess))
-        {
+      if (cmSystemTools::GuessLibrarySOName(file, soguess)) {
         this->SOName = soguess;
-        }
       }
     }
+  }
 
   virtual void Report(std::ostream& e)
-    {
+  {
     e << "runtime library [";
-    if(this->SOName.empty())
-      {
+    if (this->SOName.empty()) {
       e << this->FileName;
-      }
-    else
-      {
+    } else {
       e << this->SOName;
-      }
-    e << "]";
     }
+    e << "]";
+  }
 
   virtual bool FindConflict(std::string const& dir);
+
 private:
   // The soname of the shared library if it is known.
   std::string SOName;
 };
 
-//----------------------------------------------------------------------------
 bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir)
 {
   // Determine which type of check to do.
-  if(!this->SOName.empty())
-    {
+  if (!this->SOName.empty()) {
     // We have the library soname.  Check if it will be found.
-    if(this->FileMayConflict(dir, this->SOName))
-      {
+    if (this->FileMayConflict(dir, this->SOName)) {
       return true;
-      }
     }
-  else
-    {
+  } else {
     // We do not have the soname.  Look for files in the directory
     // that may conflict.
     std::set<std::string> const& files =
-      (this->GlobalGenerator
-       ->GetDirectoryContent(dir, true));
+      (this->GlobalGenerator->GetDirectoryContent(dir, true));
 
     // Get the set of files that might conflict.  Since we do not
     // 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<std::string>::const_iterator first = files.lower_bound(base);
-    ++base[base.size()-1];
+    ++base[base.size() - 1];
     std::set<std::string>::const_iterator last = files.upper_bound(base);
-    if(first != last)
-      {
+    if (first != last) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
-class cmOrderDirectoriesConstraintLibrary: public cmOrderDirectoriesConstraint
+class cmOrderDirectoriesConstraintLibrary : public cmOrderDirectoriesConstraint
 {
 public:
   cmOrderDirectoriesConstraintLibrary(cmOrderDirectories* od,
-                                      std::string const& file):
-    cmOrderDirectoriesConstraint(od, file)
-    {
-    }
+                                      std::string const& file)
+    : cmOrderDirectoriesConstraint(od, file)
+  {
+  }
 
   virtual void Report(std::ostream& e)
-    {
+  {
     e << "link library [" << this->FileName << "]";
-    }
+  }
 
   virtual bool FindConflict(std::string const& dir);
 };
 
-//----------------------------------------------------------------------------
 bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir)
 {
   // We have the library file name.  Check if it will be found.
-  if(this->FileMayConflict(dir, this->FileName))
-    {
+  if (this->FileMayConflict(dir, this->FileName)) {
     return true;
-    }
+  }
 
   // Now check if the file exists with other extensions the linker
   // might consider.
-  if(!this->OD->LinkExtensions.empty() &&
-     this->OD->RemoveLibraryExtension.find(this->FileName))
-    {
+  if (!this->OD->LinkExtensions.empty() &&
+      this->OD->RemoveLibraryExtension.find(this->FileName)) {
     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)
-      {
-      if(*i != ext)
-        {
+    for (std::vector<std::string>::iterator i =
+           this->OD->LinkExtensions.begin();
+         i != this->OD->LinkExtensions.end(); ++i) {
+      if (*i != ext) {
         std::string fname = lib;
         fname += *i;
-        if(this->FileMayConflict(dir, fname))
-          {
+        if (this->FileMayConflict(dir, fname)) {
           return true;
-          }
         }
       }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg,
                                        const cmGeneratorTarget* target,
                                        const char* purpose)
@@ -287,137 +258,113 @@ cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg,
   this->Computed = false;
 }
 
-//----------------------------------------------------------------------------
 cmOrderDirectories::~cmOrderDirectories()
 {
   cmDeleteAll(this->ConstraintEntries);
   cmDeleteAll(this->ImplicitDirEntries);
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> const& cmOrderDirectories::GetOrderedDirectories()
 {
-  if(!this->Computed)
-    {
+  if (!this->Computed) {
     this->Computed = true;
     this->CollectOriginalDirectories();
     this->FindConflicts();
     this->OrderDirectories();
-    }
+  }
   return this->OrderedDirectories;
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath,
                                            const char* soname)
 {
   // Add the runtime library at most once.
-  if(this->EmmittedConstraintSOName.insert(fullPath).second)
-    {
+  if (this->EmmittedConstraintSOName.insert(fullPath).second) {
     // Implicit link directories need special handling.
-    if(!this->ImplicitDirectories.empty())
-      {
+    if (!this->ImplicitDirectories.empty()) {
       std::string dir = cmSystemTools::GetFilenamePath(fullPath);
 
-      if(fullPath.rfind(".framework") != std::string::npos)
-        {
-        static cmsys::RegularExpression
-          splitFramework("^(.*)/(.*).framework/(.*)$");
-        if(splitFramework.find(fullPath) &&
-          (std::string::npos !=
-           splitFramework.match(3).find(splitFramework.match(2))))
-          {
+      if (fullPath.rfind(".framework") != std::string::npos) {
+        static cmsys::RegularExpression splitFramework(
+          "^(.*)/(.*).framework/(.*)$");
+        if (splitFramework.find(fullPath) &&
+            (std::string::npos !=
+             splitFramework.match(3).find(splitFramework.match(2)))) {
           dir = splitFramework.match(1);
-          }
         }
+      }
 
-      if(this->ImplicitDirectories.find(dir) !=
-         this->ImplicitDirectories.end())
-        {
+      if (this->ImplicitDirectories.find(dir) !=
+          this->ImplicitDirectories.end()) {
         this->ImplicitDirEntries.push_back(
           new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
         return;
-        }
       }
+    }
 
     // Construct the runtime information entry for this library.
     this->ConstraintEntries.push_back(
       new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
-    }
-  else
-    {
+  } else {
     // This can happen if the same library is linked multiple times.
     // In that case the runtime information check need be done only
     // once anyway.  For shared libs we could add a check in AddItem
     // to not repeat them.
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath)
 {
   // Link extension info is required for library constraints.
   assert(!this->LinkExtensions.empty());
 
   // Add the link library at most once.
-  if(this->EmmittedConstraintLibrary.insert(fullPath).second)
-    {
+  if (this->EmmittedConstraintLibrary.insert(fullPath).second) {
     // Implicit link directories need special handling.
-    if(!this->ImplicitDirectories.empty())
-      {
+    if (!this->ImplicitDirectories.empty()) {
       std::string dir = cmSystemTools::GetFilenamePath(fullPath);
-      if(this->ImplicitDirectories.find(dir) !=
-         this->ImplicitDirectories.end())
-        {
+      if (this->ImplicitDirectories.find(dir) !=
+          this->ImplicitDirectories.end()) {
         this->ImplicitDirEntries.push_back(
           new cmOrderDirectoriesConstraintLibrary(this, fullPath));
         return;
-        }
       }
+    }
 
     // Construct the link library entry.
     this->ConstraintEntries.push_back(
       new cmOrderDirectoriesConstraintLibrary(this, fullPath));
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmOrderDirectories
-::AddUserDirectories(std::vector<std::string> const& extra)
+void cmOrderDirectories::AddUserDirectories(
+  std::vector<std::string> const& extra)
 {
-  this->UserDirectories.insert(this->UserDirectories.end(),
-                               extra.begin(), extra.end());
+  this->UserDirectories.insert(this->UserDirectories.end(), extra.begin(),
+                               extra.end());
 }
 
-//----------------------------------------------------------------------------
-void
-cmOrderDirectories
-::AddLanguageDirectories(std::vector<std::string> const& dirs)
+void cmOrderDirectories::AddLanguageDirectories(
+  std::vector<std::string> const& dirs)
 {
   this->LanguageDirectories.insert(this->LanguageDirectories.end(),
                                    dirs.begin(), dirs.end());
 }
 
-//----------------------------------------------------------------------------
-void
-cmOrderDirectories
-::SetImplicitDirectories(std::set<std::string> const& implicitDirs)
+void cmOrderDirectories::SetImplicitDirectories(
+  std::set<std::string> const& implicitDirs)
 {
   this->ImplicitDirectories = implicitDirs;
 }
 
-//----------------------------------------------------------------------------
-void
-cmOrderDirectories
-::SetLinkExtensionInfo(std::vector<std::string> const& linkExtensions,
-                       std::string const& removeExtRegex)
+void cmOrderDirectories::SetLinkExtensionInfo(
+  std::vector<std::string> const& linkExtensions,
+  std::string const& removeExtRegex)
 {
   this->LinkExtensions = linkExtensions;
   this->RemoveLibraryExtension.compile(removeExtRegex.c_str());
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::CollectOriginalDirectories()
 {
   // Add user directories specified for inclusion.  These should be
@@ -426,59 +373,49 @@ void cmOrderDirectories::CollectOriginalDirectories()
   this->AddOriginalDirectories(this->UserDirectories);
 
   // Add directories containing constraints.
-  for(unsigned int i=0; i < this->ConstraintEntries.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->ConstraintEntries.size(); ++i) {
     this->ConstraintEntries[i]->AddDirectory();
-    }
+  }
 
   // Add language runtime directories last.
   this->AddOriginalDirectories(this->LanguageDirectories);
 }
 
-//----------------------------------------------------------------------------
 int cmOrderDirectories::AddOriginalDirectory(std::string const& dir)
 {
   // Add the runtime directory with a unique index.
-  std::map<std::string, int>::iterator i =
-    this->DirectoryIndex.find(dir);
-  if(i == this->DirectoryIndex.end())
-    {
-    std::map<std::string, int>::value_type
-      entry(dir, static_cast<int>(this->OriginalDirectories.size()));
+  std::map<std::string, int>::iterator i = this->DirectoryIndex.find(dir);
+  if (i == this->DirectoryIndex.end()) {
+    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);
-    }
+  }
 
   return i->second;
 }
 
-//----------------------------------------------------------------------------
-void
-cmOrderDirectories
-::AddOriginalDirectories(std::vector<std::string> const& dirs)
+void cmOrderDirectories::AddOriginalDirectories(
+  std::vector<std::string> const& dirs)
 {
-  for(std::vector<std::string>::const_iterator di = dirs.begin();
-      di != dirs.end(); ++di)
-    {
+  for (std::vector<std::string>::const_iterator di = dirs.begin();
+       di != dirs.end(); ++di) {
     // We never explicitly specify implicit link directories.
-    if(this->ImplicitDirectories.find(*di) !=
-       this->ImplicitDirectories.end())
-      {
+    if (this->ImplicitDirectories.find(*di) !=
+        this->ImplicitDirectories.end()) {
       continue;
-      }
+    }
 
     // Skip the empty string.
-    if(di->empty())
-      {
+    if (di->empty()) {
       continue;
-      }
+    }
 
     // Add this directory.
     this->AddOriginalDirectory(*di);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 struct cmOrderDirectoriesCompare
 {
   typedef std::pair<int, int> ConflictPair;
@@ -486,14 +423,12 @@ struct cmOrderDirectoriesCompare
   // The conflict pair is unique based on just the directory
   // (first).  The second element is only used for displaying
   // information about why the entry is present.
-  bool operator()(ConflictPair const& l,
-                  ConflictPair const& r)
-    {
+  bool operator()(ConflictPair const& l, ConflictPair const& r)
+  {
     return l.first == r.first;
-    }
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::FindConflicts()
 {
   // Allocate the conflict graph.
@@ -501,16 +436,13 @@ void cmOrderDirectories::FindConflicts()
   this->DirectoryVisited.resize(this->OriginalDirectories.size(), 0);
 
   // Find directories conflicting with each entry.
-  for(unsigned int i=0; i < this->ConstraintEntries.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->ConstraintEntries.size(); ++i) {
     this->ConstraintEntries[i]->FindConflicts(i);
-    }
+  }
 
   // Clean up the conflict graph representation.
-  for(std::vector<ConflictList>::iterator
-        i = this->ConflictGraph.begin();
-      i != this->ConflictGraph.end(); ++i)
-    {
+  for (std::vector<ConflictList>::iterator i = this->ConflictGraph.begin();
+       i != this->ConflictGraph.end(); ++i) {
     // Sort the outgoing edges for each graph node so that the
     // original order will be preserved as much as possible.
     std::sort(i->begin(), i->end());
@@ -519,44 +451,38 @@ void cmOrderDirectories::FindConflicts()
     ConflictList::iterator last =
       std::unique(i->begin(), i->end(), cmOrderDirectoriesCompare());
     i->erase(last, i->end());
-    }
+  }
 
   // Check items in implicit link directories.
   this->FindImplicitConflicts();
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::FindImplicitConflicts()
 {
   // Check for items in implicit link directories that have conflicts
   // in the explicit directories.
   std::ostringstream conflicts;
-  for(unsigned int i=0; i < this->ImplicitDirEntries.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->ImplicitDirEntries.size(); ++i) {
     this->ImplicitDirEntries[i]->FindImplicitConflicts(conflicts);
-    }
+  }
 
   // Skip warning if there were no conflicts.
   std::string text = conflicts.str();
-  if(text.empty())
-    {
+  if (text.empty()) {
     return;
-    }
+  }
 
   // Warn about the conflicts.
   std::ostringstream w;
-  w << "Cannot generate a safe " << this->Purpose
-    << " for target " << this->Target->GetName()
+  w << "Cannot generate a safe " << this->Purpose << " for target "
+    << this->Target->GetName()
     << " because files in some directories may conflict with "
     << " libraries in implicit directories:\n"
-    << text
-    << "Some of these libraries may not be found correctly.";
-  this->GlobalGenerator->GetCMakeInstance()
-    ->IssueMessage(cmake::WARNING, w.str(),
-                   this->Target->GetBacktrace());
+    << text << "Some of these libraries may not be found correctly.";
+  this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
+    cmake::WARNING, w.str(), this->Target->GetBacktrace());
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::OrderDirectories()
 {
   // Allow a cycle to be diagnosed once.
@@ -564,78 +490,67 @@ void cmOrderDirectories::OrderDirectories()
   this->WalkId = 0;
 
   // Iterate through the directories in the original order.
-  for(unsigned int i=0; i < this->OriginalDirectories.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->OriginalDirectories.size(); ++i) {
     // Start a new DFS from this node.
     ++this->WalkId;
     this->VisitDirectory(i);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::VisitDirectory(unsigned int i)
 {
   // Skip nodes already visited.
-  if(this->DirectoryVisited[i])
-    {
-    if(this->DirectoryVisited[i] == this->WalkId)
-      {
+  if (this->DirectoryVisited[i]) {
+    if (this->DirectoryVisited[i] == this->WalkId) {
       // We have reached a node previously visited on this DFS.
       // There is a cycle.
       this->DiagnoseCycle();
-      }
-    return;
     }
+    return;
+  }
 
   // We are now visiting this node so mark it.
   this->DirectoryVisited[i] = this->WalkId;
 
   // Visit the neighbors of the node first.
   ConflictList const& clist = this->ConflictGraph[i];
-  for(ConflictList::const_iterator j = clist.begin();
-      j != clist.end(); ++j)
-    {
+  for (ConflictList::const_iterator j = clist.begin(); j != clist.end(); ++j) {
     this->VisitDirectory(j->first);
-    }
+  }
 
   // Now that all directories required to come before this one have
   // been emmitted, emit this directory.
   this->OrderedDirectories.push_back(this->OriginalDirectories[i]);
 }
 
-//----------------------------------------------------------------------------
 void cmOrderDirectories::DiagnoseCycle()
 {
   // Report the cycle at most once.
-  if(this->CycleDiagnosed)
-    {
+  if (this->CycleDiagnosed) {
     return;
-    }
+  }
   this->CycleDiagnosed = true;
 
   // Construct the message.
   std::ostringstream e;
-  e << "Cannot generate a safe " << this->Purpose
-    << " for target " << this->Target->GetName()
+  e << "Cannot generate a safe " << this->Purpose << " for target "
+    << this->Target->GetName()
     << " because there is a cycle in the constraint graph:\n";
 
   // Display the conflict graph.
-  for(unsigned int i=0; i < this->ConflictGraph.size(); ++i)
-    {
+  for (unsigned int i = 0; i < this->ConflictGraph.size(); ++i) {
     ConflictList const& clist = this->ConflictGraph[i];
     e << "  dir " << i << " is [" << this->OriginalDirectories[i] << "]\n";
-    for(ConflictList::const_iterator j = clist.begin();
-        j != clist.end(); ++j)
-      {
+    for (ConflictList::const_iterator j = clist.begin(); j != clist.end();
+         ++j) {
       e << "    dir " << j->first << " must precede it due to ";
       this->ConstraintEntries[j->second]->Report(e);
       e << "\n";
-      }
     }
+  }
   e << "Some of these libraries may not be found correctly.";
-  this->GlobalGenerator->GetCMakeInstance()
-    ->IssueMessage(cmake::WARNING, e.str(),
-                   this->Target->GetBacktrace());
+  this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
+    cmake::WARNING, e.str(), this->Target->GetBacktrace());
 }
 
 bool cmOrderDirectories::IsSameDirectory(std::string const& l,
@@ -649,11 +564,10 @@ std::string const& cmOrderDirectories::GetRealPath(std::string const& dir)
   std::map<std::string, std::string>::iterator i =
     this->RealPaths.lower_bound(dir);
   if (i == this->RealPaths.end() ||
-      this->RealPaths.key_comp()(dir, i->first))
-    {
+      this->RealPaths.key_comp()(dir, i->first)) {
     typedef std::map<std::string, std::string>::value_type value_type;
     i = this->RealPaths.insert(
       i, value_type(dir, cmSystemTools::GetRealPath(dir)));
-    }
+  }
   return i->second;
 }
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 477216b..fc1a388 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -39,6 +39,7 @@ public:
                             std::string const& removeExtRegex);
 
   std::vector<std::string> const& GetOrderedDirectories();
+
 private:
   cmGlobalGenerator* GlobalGenerator;
   cmGeneratorTarget const* Target;
@@ -77,7 +78,9 @@ private:
   // element is the index of the runtime library that added the
   // constraint.
   typedef std::pair<int, int> ConflictPair;
-  struct ConflictList: public std::vector<ConflictPair> {};
+  struct ConflictList : public std::vector<ConflictPair>
+  {
+  };
   std::vector<ConflictList> ConflictGraph;
 
   // Compare directories after resolving symlinks.
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 5acae2f..8e80bd0 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -16,42 +16,37 @@
 
 #include <assert.h>
 
-#include <string.h> /* strlen */
 #include <ctype.h>  /* isalpha */
+#include <string.h> /* strlen */
 
 cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot)
-  : StateSnapshot(snapshot), LinkScriptShell(false)
+  : StateSnapshot(snapshot)
+  , LinkScriptShell(false)
 {
+  assert(this->StateSnapshot.IsValid());
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmOutputConverter::ConvertToOutputForExistingCommon(const std::string& remote,
-                                                    std::string const& result,
-                                                    OutputFormat format) const
+std::string cmOutputConverter::ConvertToOutputForExistingCommon(
+  const std::string& remote, std::string const& result,
+  OutputFormat format) const
 {
   // 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->GetState()->UseWindowsShell() && result.find(' ') != result.npos &&
-     cmSystemTools::FileExists(remote.c_str()))
-    {
+  if (this->GetState()->UseWindowsShell() && result.find(' ') != result.npos &&
+      cmSystemTools::FileExists(remote.c_str())) {
     std::string tmp;
-    if(cmSystemTools::GetShortPath(remote, tmp))
-      {
+    if (cmSystemTools::GetShortPath(remote, tmp)) {
       return this->ConvertToOutputFormat(tmp, format);
-      }
     }
+  }
 
   // Otherwise, leave it unchanged.
   return result;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmOutputConverter::ConvertToOutputForExisting(const std::string& remote,
-                                              RelativeRoot local,
-                                              OutputFormat format) const
+std::string cmOutputConverter::ConvertToOutputForExisting(
+  const std::string& remote, RelativeRoot local, OutputFormat format) const
 {
   static_cast<void>(local);
 
@@ -62,11 +57,8 @@ cmOutputConverter::ConvertToOutputForExisting(const std::string& remote,
   return this->ConvertToOutputForExistingCommon(remote, result, format);
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmOutputConverter::ConvertToOutputForExisting(RelativeRoot remote,
-                                              const std::string& local,
-                                              OutputFormat format) const
+std::string cmOutputConverter::ConvertToOutputForExisting(
+  RelativeRoot remote, const std::string& local, OutputFormat format) const
 {
   // Perform standard conversion.
   std::string result = this->Convert(remote, local, format, true);
@@ -76,21 +68,20 @@ cmOutputConverter::ConvertToOutputForExisting(RelativeRoot remote,
   return this->ConvertToOutputForExistingCommon(remotePath, result, format);
 }
 
-//----------------------------------------------------------------------------
 const char* cmOutputConverter::GetRelativeRootPath(RelativeRoot relroot) const
 {
-  switch (relroot)
-    {
-  case HOME:
-    return this->GetState()->GetSourceDirectory();
-  case START:
-    return this->StateSnapshot.GetDirectory().GetCurrentSource();
-  case HOME_OUTPUT:
-    return this->GetState()->GetBinaryDirectory();
-  case START_OUTPUT:
-    return this->StateSnapshot.GetDirectory().GetCurrentBinary();
-  default: break;
-    }
+  switch (relroot) {
+    case HOME:
+      return this->GetState()->GetSourceDirectory();
+    case START:
+      return this->StateSnapshot.GetDirectory().GetCurrentSource();
+    case HOME_OUTPUT:
+      return this->GetState()->GetBinaryDirectory();
+    case START_OUTPUT:
+      return this->StateSnapshot.GetDirectory().GetCurrentBinary();
+    default:
+      break;
+  }
   return 0;
 }
 
@@ -101,179 +92,156 @@ std::string cmOutputConverter::Convert(const std::string& source,
   // Convert the path to a relative path.
   std::string result = source;
 
-  switch (relative)
-    {
-  case HOME:
-    result = this->ConvertToRelativePath(
-          this->GetState()->GetSourceDirectoryComponents(), result);
-    break;
-  case START:
-    result = this->ConvertToRelativePath(
-          this->StateSnapshot.GetDirectory().GetCurrentSourceComponents(),
-          result);
-    break;
-  case HOME_OUTPUT:
-    result = this->ConvertToRelativePath(
-          this->GetState()->GetBinaryDirectoryComponents(), result);
-    break;
-  case START_OUTPUT:
-    result = this->ConvertToRelativePath(
-          this->StateSnapshot.GetDirectory().GetCurrentBinaryComponents(),
-          result);
-    break;
-  case FULL:
-    result = cmSystemTools::CollapseFullPath(result);
-    break;
-  case NONE:
-    break;
-    }
+  switch (relative) {
+    case HOME:
+      result = this->ConvertToRelativePath(
+        this->GetState()->GetSourceDirectoryComponents(), result);
+      break;
+    case START:
+      result = this->ConvertToRelativePath(
+        this->StateSnapshot.GetDirectory().GetCurrentSourceComponents(),
+        result);
+      break;
+    case HOME_OUTPUT:
+      result = this->ConvertToRelativePath(
+        this->GetState()->GetBinaryDirectoryComponents(), result);
+      break;
+    case START_OUTPUT:
+      result = this->ConvertToRelativePath(
+        this->StateSnapshot.GetDirectory().GetCurrentBinaryComponents(),
+        result);
+      break;
+    case FULL:
+      result = cmSystemTools::CollapseFullPath(result);
+      break;
+    case NONE:
+      break;
+  }
   return this->ConvertToOutputFormat(result, output);
 }
 
-//----------------------------------------------------------------------------
 std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source,
                                                      OutputFormat output) const
 {
   std::string result = source;
   // Convert it to an output path.
-  if (output == MAKERULE)
-    {
+  if (output == MAKERULE) {
     result = cmSystemTools::ConvertToOutputPath(result.c_str());
-    }
-  else if(output == SHELL || output == WATCOMQUOTE)
-    {
+  } else if (output == SHELL || output == WATCOMQUOTE) {
     result = this->ConvertDirectorySeparatorsForShell(source);
     result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
-    }
-  else if(output == RESPONSE)
-    {
+  } else if (output == RESPONSE) {
     result = this->EscapeForShell(result, false, false, false);
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 std::string cmOutputConverter::ConvertDirectorySeparatorsForShell(
-                                              const std::string& source) const
+  const std::string& source) const
 {
   std::string result = source;
   // For the MSYS shell convert drive letters to posix paths, so
   // that c:/some/path becomes /c/some/path.  This is needed to
   // avoid problems with the shell path translation.
-  if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell)
-    {
-    if(result.size() > 2 && result[1] == ':')
-      {
+  if (this->GetState()->UseMSYSShell() && !this->LinkScriptShell) {
+    if (result.size() > 2 && result[1] == ':') {
       result[1] = result[0];
       result[0] = '/';
-      }
     }
-  if(this->GetState()->UseWindowsShell())
-    {
+  }
+  if (this->GetState()->UseWindowsShell()) {
     std::replace(result.begin(), result.end(), '/', '\\');
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 std::string cmOutputConverter::Convert(RelativeRoot remote,
-                                      const std::string& local,
-                                      OutputFormat output,
-                                      bool optional) const
+                                       const std::string& local,
+                                       OutputFormat output,
+                                       bool optional) const
 {
   const char* remotePath = this->GetRelativeRootPath(remote);
 
   // The relative root must have a path (i.e. not FULL or NONE)
   assert(remotePath != 0);
 
-  if(!local.empty() && !optional)
-    {
+  if (!local.empty() && !optional) {
     std::vector<std::string> components;
     cmSystemTools::SplitPath(local, components);
     std::string result = this->ConvertToRelativePath(components, remotePath);
     return this->ConvertToOutputFormat(result, output);
-    }
+  }
 
   return this->ConvertToOutputFormat(remotePath, output);
 }
 
-//----------------------------------------------------------------------------
 static bool cmOutputConverterNotAbove(const char* a, const char* b)
 {
   return (cmSystemTools::ComparePath(a, b) ||
           cmSystemTools::IsSubDirectory(a, b));
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmOutputConverter::ConvertToRelativePath(const std::vector<std::string>& local,
-                                        const std::string& in_remote,
-                                        bool force) const
+std::string cmOutputConverter::ConvertToRelativePath(
+  const std::vector<std::string>& local, const std::string& in_remote,
+  bool force) const
 {
   // The path should never be quoted.
   assert(in_remote[0] != '\"');
 
   // The local path should never have a trailing slash.
-  assert(!local.empty() && !(local[local.size()-1] == ""));
+  assert(!local.empty() && !(local[local.size() - 1] == ""));
 
   // If the path is already relative then just return the path.
-  if(!cmSystemTools::FileIsFullPath(in_remote.c_str()))
-    {
+  if (!cmSystemTools::FileIsFullPath(in_remote.c_str())) {
     return in_remote;
-    }
+  }
 
-  if(!force)
-    {
+  if (!force) {
     // Skip conversion if the path and local are not both in the source
     // or both in the binary tree.
     std::string local_path = cmSystemTools::JoinPath(local);
-    if(!((cmOutputConverterNotAbove(local_path.c_str(),
-              this->StateSnapshot.GetDirectory().GetRelativePathTopBinary())
-          && cmOutputConverterNotAbove(in_remote.c_str(),
-              this->StateSnapshot.GetDirectory().GetRelativePathTopBinary()))
-         || (cmOutputConverterNotAbove(local_path.c_str(),
-              this->StateSnapshot.GetDirectory().GetRelativePathTopSource())
-             && cmOutputConverterNotAbove(in_remote.c_str(),
-              this->StateSnapshot.GetDirectory().GetRelativePathTopSource()))))
-      {
+    if (!((cmOutputConverterNotAbove(
+             local_path.c_str(),
+             this->StateSnapshot.GetDirectory().GetRelativePathTopBinary()) &&
+           cmOutputConverterNotAbove(
+             in_remote.c_str(),
+             this->StateSnapshot.GetDirectory().GetRelativePathTopBinary())) ||
+          (cmOutputConverterNotAbove(
+             local_path.c_str(),
+             this->StateSnapshot.GetDirectory().GetRelativePathTopSource()) &&
+           cmOutputConverterNotAbove(in_remote.c_str(),
+                                     this->StateSnapshot.GetDirectory()
+                                       .GetRelativePathTopSource())))) {
       return in_remote;
-      }
     }
+  }
 
   // Identify the longest shared path component between the remote
   // path and the local path.
   std::vector<std::string> remote;
   cmSystemTools::SplitPath(in_remote, remote);
-  unsigned int common=0;
-  while(common < remote.size() &&
-        common < local.size() &&
-        cmSystemTools::ComparePath(remote[common],
-                                   local[common]))
-    {
+  unsigned int common = 0;
+  while (common < remote.size() && common < local.size() &&
+         cmSystemTools::ComparePath(remote[common], local[common])) {
     ++common;
-    }
+  }
 
   // If no part of the path is in common then return the full path.
-  if(common == 0)
-    {
+  if (common == 0) {
     return in_remote;
-    }
+  }
 
   // If the entire path is in common then just return a ".".
-  if(common == remote.size() &&
-     common == local.size())
-    {
+  if (common == remote.size() && common == local.size()) {
     return ".";
-    }
+  }
 
   // If the entire path is in common except for a trailing slash then
   // just return a "./".
-  if(common+1 == remote.size() &&
-     remote[common].empty() &&
-     common == local.size())
-    {
+  if (common + 1 == remote.size() && remote[common].empty() &&
+      common == local.size()) {
     return "./";
-    }
+  }
 
   // Construct the relative path.
   std::string relative;
@@ -282,14 +250,12 @@ cmOutputConverter::ConvertToRelativePath(const std::vector<std::string>& local,
   // of the path.  Leave off the trailing slash.  Note that the last
   // component of local will never be empty because local should never
   // have a trailing slash.
-  for(unsigned int i=common; i < local.size(); ++i)
-    {
+  for (unsigned int i = common; i < local.size(); ++i) {
     relative += "..";
-    if(i < local.size()-1)
-      {
+    if (i < local.size() - 1) {
       relative += "/";
-      }
     }
+  }
 
   // Now add the portion of the destination path that is not included
   // in the shared portion of the path.  Add a slash the first time
@@ -298,22 +264,19 @@ cmOutputConverter::ConvertToRelativePath(const std::vector<std::string>& local,
   // will add a slash followed by an empty string which will preserve
   // the trailing slash in the output.
 
-  if(!relative.empty() && !remote.empty())
-    {
+  if (!relative.empty() && !remote.empty()) {
     relative += "/";
-    }
+  }
   relative += cmJoin(cmMakeRange(remote).advance(common), "/");
 
   // Finally return the path.
   return relative;
 }
 
-//----------------------------------------------------------------------------
 static bool cmOutputConverterIsShellOperator(const std::string& str)
 {
   static std::set<std::string> shellOperators;
-  if(shellOperators.empty())
-    {
+  if (shellOperators.empty()) {
     shellOperators.insert("<");
     shellOperators.insert(">");
     shellOperators.insert("<<");
@@ -326,149 +289,117 @@ static bool cmOutputConverterIsShellOperator(const std::string& str)
     shellOperators.insert("2>");
     shellOperators.insert("2>&1");
     shellOperators.insert("1>&2");
-    }
+  }
   return shellOperators.count(str) > 0;
 }
 
-//----------------------------------------------------------------------------
 std::string cmOutputConverter::EscapeForShell(const std::string& str,
-                                             bool makeVars,
-                                             bool forEcho,
-                                             bool useWatcomQuote) const
+                                              bool makeVars, bool forEcho,
+                                              bool useWatcomQuote) const
 {
   // Do not escape shell operators.
-  if(cmOutputConverterIsShellOperator(str))
-    {
+  if (cmOutputConverterIsShellOperator(str)) {
     return str;
-    }
+  }
 
   // Compute the flags for the target shell environment.
   int flags = 0;
-  if(this->GetState()->UseWindowsVSIDE())
-    {
+  if (this->GetState()->UseWindowsVSIDE()) {
     flags |= Shell_Flag_VSIDE;
-    }
-  else if(!this->LinkScriptShell)
-    {
+  } else if (!this->LinkScriptShell) {
     flags |= Shell_Flag_Make;
-    }
-  if(makeVars)
-    {
+  }
+  if (makeVars) {
     flags |= Shell_Flag_AllowMakeVariables;
-    }
-  if(forEcho)
-    {
+  }
+  if (forEcho) {
     flags |= Shell_Flag_EchoWindows;
-    }
-  if(useWatcomQuote)
-    {
+  }
+  if (useWatcomQuote) {
     flags |= Shell_Flag_WatcomQuote;
-    }
-  if(this->GetState()->UseWatcomWMake())
-    {
+  }
+  if (this->GetState()->UseWatcomWMake()) {
     flags |= Shell_Flag_WatcomWMake;
-    }
-  if(this->GetState()->UseMinGWMake())
-    {
+  }
+  if (this->GetState()->UseMinGWMake()) {
     flags |= Shell_Flag_MinGWMake;
-    }
-  if(this->GetState()->UseNMake())
-    {
+  }
+  if (this->GetState()->UseNMake()) {
     flags |= Shell_Flag_NMake;
-    }
+  }
 
   // Compute the buffer size needed.
-  int size = (this->GetState()->UseWindowsShell() ?
-              Shell_GetArgumentSizeForWindows(str.c_str(), flags) :
-              Shell_GetArgumentSizeForUnix(str.c_str(), flags));
+  int size = (this->GetState()->UseWindowsShell()
+                ? Shell_GetArgumentSizeForWindows(str.c_str(), flags)
+                : Shell_GetArgumentSizeForUnix(str.c_str(), flags));
 
   // Compute the shell argument itself.
   std::vector<char> arg(size);
-  if(this->GetState()->UseWindowsShell())
-    {
+  if (this->GetState()->UseWindowsShell()) {
     Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags);
-    }
-  else
-    {
+  } else {
     Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags);
-    }
+  }
   return std::string(&arg[0]);
 }
 
-//----------------------------------------------------------------------------
 std::string cmOutputConverter::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_str(); *c; ++c)
-    {
-    if(*c == '"')
-      {
+  for (const char* c = str.c_str(); *c; ++c) {
+    if (*c == '"') {
       // Escape the double quote to avoid ending the argument.
       result += "\\\"";
-      }
-    else if(*c == '$')
-      {
+    } else if (*c == '$') {
       // Escape the dollar to avoid expanding variables.
       result += "\\$";
-      }
-    else if(*c == '\\')
-      {
+    } else if (*c == '\\') {
       // Escape the backslash to avoid other escapes.
       result += "\\\\";
-      }
-    else
-      {
+    } else {
       // Other characters will be parsed correctly.
       result += *c;
-      }
     }
+  }
   result += "\"";
   return result;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmOutputConverter::EscapeWindowsShellArgument(const char* arg, int shell_flags)
+std::string cmOutputConverter::EscapeWindowsShellArgument(const char* arg,
+                                                          int shell_flags)
 {
   char local_buffer[1024];
   char* buffer = local_buffer;
   int size = Shell_GetArgumentSizeForWindows(arg, shell_flags);
-  if(size > 1024)
-    {
+  if (size > 1024) {
     buffer = new char[size];
-    }
+  }
   Shell_GetArgumentForWindows(arg, buffer, shell_flags);
   std::string result(buffer);
-  if(buffer != local_buffer)
-    {
-    delete [] buffer;
-    }
+  if (buffer != local_buffer) {
+    delete[] buffer;
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
-cmOutputConverter::FortranFormat
-cmOutputConverter::GetFortranFormat(const char* value)
+cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat(
+  const char* value)
 {
   FortranFormat format = FortranFormatNone;
-  if(value && *value)
-    {
+  if (value && *value) {
     std::vector<std::string> fmt;
     cmSystemTools::ExpandListArgument(value, fmt);
-    for(std::vector<std::string>::iterator fi = fmt.begin();
-        fi != fmt.end(); ++fi)
-      {
-      if(*fi == "FIXED")
-        {
+    for (std::vector<std::string>::iterator fi = fmt.begin(); fi != fmt.end();
+         ++fi) {
+      if (*fi == "FIXED") {
         format = FortranFormatFixed;
-        }
-      if(*fi == "FREE")
-        {
+      }
+      if (*fi == "FREE") {
         format = FortranFormatFree;
-        }
       }
     }
+  }
   return format;
 }
 
@@ -482,7 +413,6 @@ cmState* cmOutputConverter::GetState() const
   return this->StateSnapshot.GetState();
 }
 
-//----------------------------------------------------------------------------
 /*
 
 Notes:
@@ -517,87 +447,69 @@ redirection character (for example, ^>, ^<, or ^| ). If you need to
 use the caret character itself (^), use two in a row (^^).
 */
 
-/*--------------------------------------------------------------------------*/
 int cmOutputConverter::Shell__CharIsWhitespace(char c)
 {
   return ((c == ' ') || (c == '\t'));
 }
 
-/*--------------------------------------------------------------------------*/
 int cmOutputConverter::Shell__CharNeedsQuotesOnUnix(char c)
 {
   return ((c == '\'') || (c == '`') || (c == ';') || (c == '#') ||
-          (c == '&') || (c == '$') || (c == '(') || (c == ')') ||
-          (c == '~') || (c == '<') || (c == '>') || (c == '|') ||
-          (c == '*') || (c == '^') || (c == '\\'));
+          (c == '&') || (c == '$') || (c == '(') || (c == ')') || (c == '~') ||
+          (c == '<') || (c == '>') || (c == '|') || (c == '*') || (c == '^') ||
+          (c == '\\'));
 }
 
-/*--------------------------------------------------------------------------*/
 int cmOutputConverter::Shell__CharNeedsQuotesOnWindows(char c)
 {
-  return ((c == '\'') || (c == '#') || (c == '&') ||
-          (c == '<') || (c == '>') || (c == '|') || (c == '^'));
+  return ((c == '\'') || (c == '#') || (c == '&') || (c == '<') ||
+          (c == '>') || (c == '|') || (c == '^'));
 }
 
-/*--------------------------------------------------------------------------*/
 int cmOutputConverter::Shell__CharNeedsQuotes(char c, int isUnix, int flags)
 {
   /* On Windows the built-in command shell echo never needs quotes.  */
-  if(!isUnix && (flags & Shell_Flag_EchoWindows))
-    {
+  if (!isUnix && (flags & Shell_Flag_EchoWindows)) {
     return 0;
-    }
+  }
 
   /* On all platforms quotes are needed to preserve whitespace.  */
-  if(Shell__CharIsWhitespace(c))
-    {
+  if (Shell__CharIsWhitespace(c)) {
     return 1;
-    }
+  }
 
-  if(isUnix)
-    {
+  if (isUnix) {
     /* On UNIX several special characters need quotes to preserve them.  */
-    if(Shell__CharNeedsQuotesOnUnix(c))
-      {
+    if (Shell__CharNeedsQuotesOnUnix(c)) {
       return 1;
-      }
     }
-  else
-    {
+  } else {
     /* On Windows several special characters need quotes to preserve them.  */
-    if(Shell__CharNeedsQuotesOnWindows(c))
-      {
+    if (Shell__CharNeedsQuotesOnWindows(c)) {
       return 1;
-      }
     }
+  }
   return 0;
 }
 
-/*--------------------------------------------------------------------------*/
 int cmOutputConverter::Shell__CharIsMakeVariableName(char c)
 {
   return c && (c == '_' || isalpha(((int)c)));
 }
 
-/*--------------------------------------------------------------------------*/
 const char* cmOutputConverter::Shell__SkipMakeVariables(const char* c)
 {
-  while(*c == '$' && *(c+1) == '(')
-    {
-    const char* skip = c+2;
-    while(Shell__CharIsMakeVariableName(*skip))
-      {
+  while (*c == '$' && *(c + 1) == '(') {
+    const char* skip = c + 2;
+    while (Shell__CharIsMakeVariableName(*skip)) {
       ++skip;
-      }
-    if(*skip == ')')
-      {
-      c = skip+1;
-      }
-    else
-      {
+    }
+    if (*skip == ')') {
+      c = skip + 1;
+    } else {
       break;
-      }
     }
+  }
   return c;
 }
 
@@ -624,68 +536,58 @@ flag later when we understand applications of this better.
 */
 #define KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES 0
 
-/*--------------------------------------------------------------------------*/
-int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in,
-                                                  int isUnix, int flags)
+int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix,
+                                                  int flags)
 {
   /* The empty string needs quotes.  */
-  if(!*in)
-    {
+  if (!*in) {
     return 1;
-    }
+  }
 
   /* Scan the string for characters that require quoting.  */
   {
-  const char* c;
-  for(c=in; *c; ++c)
-    {
-    /* Look for $(MAKEVAR) syntax if requested.  */
-    if(flags & Shell_Flag_AllowMakeVariables)
-      {
+    const char* c;
+    for (c = in; *c; ++c) {
+      /* Look for $(MAKEVAR) syntax if requested.  */
+      if (flags & Shell_Flag_AllowMakeVariables) {
 #if KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES
-      const char* skip = Shell__SkipMakeVariables(c);
-      if(skip != c)
-        {
-        /* We need to quote make variable references to preserve the
-           string with contents substituted in its place.  */
-        return 1;
+        const char* skip = Shell__SkipMakeVariables(c);
+        if (skip != c) {
+          /* We need to quote make variable references to preserve the
+             string with contents substituted in its place.  */
+          return 1;
         }
 #else
-      /* Skip over the make variable references if any are present.  */
-      c = Shell__SkipMakeVariables(c);
+        /* Skip over the make variable references if any are present.  */
+        c = Shell__SkipMakeVariables(c);
 
-      /* Stop if we have reached the end of the string.  */
-      if(!*c)
-        {
-        break;
+        /* Stop if we have reached the end of the string.  */
+        if (!*c) {
+          break;
         }
 #endif
       }
 
-    /* Check whether this character needs quotes.  */
-    if(Shell__CharNeedsQuotes(*c, isUnix, flags))
-      {
-      return 1;
+      /* Check whether this character needs quotes.  */
+      if (Shell__CharNeedsQuotes(*c, isUnix, flags)) {
+        return 1;
       }
     }
   }
 
   /* On Windows some single character arguments need quotes.  */
-  if(!isUnix && *in && !*(in+1))
-    {
+  if (!isUnix && *in && !*(in + 1)) {
     char c = *in;
-    if((c == '?') || (c == '&') || (c == '^') || (c == '|') || (c == '#'))
-      {
+    if ((c == '?') || (c == '&') || (c == '^') || (c == '|') || (c == '#')) {
       return 1;
-      }
     }
+  }
 
   return 0;
 }
 
-/*--------------------------------------------------------------------------*/
-int cmOutputConverter::Shell__GetArgumentSize(const char* in,
-                                              int isUnix, int flags)
+int cmOutputConverter::Shell__GetArgumentSize(const char* in, int isUnix,
+                                              int flags)
 {
   /* Start with the length of the original argument, plus one for
      either a terminating null or a separating space.  */
@@ -698,127 +600,95 @@ int cmOutputConverter::Shell__GetArgumentSize(const char* in,
   int windows_backslashes = 0;
 
   /* Scan the string for characters that require escaping or quoting.  */
-  for(c=in; *c; ++c)
-    {
+  for (c = in; *c; ++c) {
     /* Look for $(MAKEVAR) syntax if requested.  */
-    if(flags & Shell_Flag_AllowMakeVariables)
-      {
+    if (flags & Shell_Flag_AllowMakeVariables) {
       /* Skip over the make variable references if any are present.  */
       c = Shell__SkipMakeVariables(c);
 
       /* Stop if we have reached the end of the string.  */
-      if(!*c)
-        {
+      if (!*c) {
         break;
-        }
       }
+    }
 
     /* Check whether this character needs escaping for the shell.  */
-    if(isUnix)
-      {
+    if (isUnix) {
       /* On Unix a few special characters need escaping even inside a
          quoted argument.  */
-      if(*c == '\\' || *c == '"' || *c == '`' || *c == '$')
-        {
+      if (*c == '\\' || *c == '"' || *c == '`' || *c == '$') {
         /* This character needs a backslash to escape it.  */
         ++size;
-        }
       }
-    else if(flags & Shell_Flag_EchoWindows)
-      {
+    } else if (flags & Shell_Flag_EchoWindows) {
       /* On Windows the built-in command shell echo never needs escaping.  */
-      }
-    else
-      {
+    } else {
       /* On Windows only backslashes and double-quotes need escaping.  */
-      if(*c == '\\')
-        {
+      if (*c == '\\') {
         /* Found a backslash.  It may need to be escaped later.  */
         ++windows_backslashes;
-        }
-      else if(*c == '"')
-        {
+      } else if (*c == '"') {
         /* Found a double-quote.  We need to escape it and all
            immediately preceding backslashes.  */
         size += windows_backslashes + 1;
         windows_backslashes = 0;
-        }
-      else
-        {
+      } else {
         /* Found another character.  This eliminates the possibility
            that any immediately preceding backslashes will be
            escaped.  */
         windows_backslashes = 0;
-        }
       }
+    }
 
     /* Check whether this character needs escaping for a make tool.  */
-    if(*c == '$')
-      {
-      if(flags & Shell_Flag_Make)
-        {
+    if (*c == '$') {
+      if (flags & Shell_Flag_Make) {
         /* In Makefiles a dollar is written $$ so we need one extra
            character.  */
         ++size;
-        }
-      else if(flags & Shell_Flag_VSIDE)
-        {
+      } else if (flags & Shell_Flag_VSIDE) {
         /* In a VS IDE a dollar is written "$" so we need two extra
            characters.  */
         size += 2;
-        }
       }
-    else if(*c == '#')
-      {
-      if((flags & Shell_Flag_Make) &&
-         (flags & Shell_Flag_WatcomWMake))
-        {
+    } else if (*c == '#') {
+      if ((flags & Shell_Flag_Make) && (flags & Shell_Flag_WatcomWMake)) {
         /* In Watcom WMake makefiles a pound is written $# so we need
            one extra character.  */
         ++size;
-        }
       }
-    else if(*c == '%')
-      {
-      if((flags & Shell_Flag_VSIDE) ||
-         ((flags & Shell_Flag_Make) &&
-          ((flags & Shell_Flag_MinGWMake) ||
-           (flags & Shell_Flag_NMake))))
-        {
+    } else if (*c == '%') {
+      if ((flags & Shell_Flag_VSIDE) ||
+          ((flags & Shell_Flag_Make) &&
+           ((flags & Shell_Flag_MinGWMake) || (flags & Shell_Flag_NMake)))) {
         /* In the VS IDE, NMake, or MinGW make a percent is written %%
            so we need one extra characters.  */
         size += 1;
-        }
       }
-    else if(*c == ';')
-      {
-      if(flags & Shell_Flag_VSIDE)
-        {
+    } else if (*c == ';') {
+      if (flags & Shell_Flag_VSIDE) {
         /* In a VS IDE a semicolon is written ";" so we need two extra
            characters.  */
         size += 2;
-        }
       }
     }
+  }
 
   /* Check whether the argument needs surrounding quotes.  */
-  if(Shell__ArgumentNeedsQuotes(in, isUnix, flags))
-    {
+  if (Shell__ArgumentNeedsQuotes(in, isUnix, flags)) {
     /* Surrounding quotes are needed.  Allocate space for them.  */
-    if((flags & Shell_Flag_WatcomQuote) && (isUnix))
-      {
-        size += 2;
-      }
+    if ((flags & Shell_Flag_WatcomQuote) && (isUnix)) {
+      size += 2;
+    }
     size += 2;
 
     /* We must escape all ending backslashes when quoting on windows.  */
     size += windows_backslashes;
-    }
+  }
 
   return size;
 }
 
-/*--------------------------------------------------------------------------*/
 char* cmOutputConverter::Shell__GetArgument(const char* in, char* out,
                                             int isUnix, int flags)
 {
@@ -830,106 +700,80 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out,
 
   /* Whether the argument must be quoted.  */
   int needQuotes = Shell__ArgumentNeedsQuotes(in, isUnix, flags);
-  if(needQuotes)
-    {
+  if (needQuotes) {
     /* Add the opening quote for this argument.  */
-    if(flags & Shell_Flag_WatcomQuote)
-      {
-      if(isUnix)
-        {
+    if (flags & Shell_Flag_WatcomQuote) {
+      if (isUnix) {
         *out++ = '"';
-        }
-      *out++ = '\'';
       }
-    else
-      {
+      *out++ = '\'';
+    } else {
       *out++ = '"';
-      }
     }
+  }
 
   /* Scan the string for characters that require escaping or quoting.  */
-  for(c=in; *c; ++c)
-    {
+  for (c = in; *c; ++c) {
     /* Look for $(MAKEVAR) syntax if requested.  */
-    if(flags & Shell_Flag_AllowMakeVariables)
-      {
+    if (flags & Shell_Flag_AllowMakeVariables) {
       const char* skip = Shell__SkipMakeVariables(c);
-      if(skip != c)
-        {
+      if (skip != c) {
         /* Copy to the end of the make variable references.  */
-        while(c != skip)
-          {
+        while (c != skip) {
           *out++ = *c++;
-          }
+        }
 
         /* The make variable reference eliminates any escaping needed
            for preceding backslashes.  */
         windows_backslashes = 0;
 
         /* Stop if we have reached the end of the string.  */
-        if(!*c)
-          {
+        if (!*c) {
           break;
-          }
         }
       }
+    }
 
     /* Check whether this character needs escaping for the shell.  */
-    if(isUnix)
-      {
+    if (isUnix) {
       /* On Unix a few special characters need escaping even inside a
          quoted argument.  */
-      if(*c == '\\' || *c == '"' || *c == '`' || *c == '$')
-        {
+      if (*c == '\\' || *c == '"' || *c == '`' || *c == '$') {
         /* This character needs a backslash to escape it.  */
         *out++ = '\\';
-        }
       }
-    else if(flags & Shell_Flag_EchoWindows)
-      {
+    } else if (flags & Shell_Flag_EchoWindows) {
       /* On Windows the built-in command shell echo never needs escaping.  */
-      }
-    else
-      {
+    } else {
       /* On Windows only backslashes and double-quotes need escaping.  */
-      if(*c == '\\')
-        {
+      if (*c == '\\') {
         /* Found a backslash.  It may need to be escaped later.  */
         ++windows_backslashes;
-        }
-      else if(*c == '"')
-        {
+      } else if (*c == '"') {
         /* Found a double-quote.  Escape all immediately preceding
            backslashes.  */
-        while(windows_backslashes > 0)
-          {
+        while (windows_backslashes > 0) {
           --windows_backslashes;
           *out++ = '\\';
-          }
+        }
 
         /* Add the backslash to escape the double-quote.  */
         *out++ = '\\';
-        }
-      else
-        {
+      } else {
         /* We encountered a normal character.  This eliminates any
            escaping needed for preceding backslashes.  */
         windows_backslashes = 0;
-        }
       }
+    }
 
     /* Check whether this character needs escaping for a make tool.  */
-    if(*c == '$')
-      {
-      if(flags & Shell_Flag_Make)
-        {
+    if (*c == '$') {
+      if (flags & Shell_Flag_Make) {
         /* In Makefiles a dollar is written $$.  The make tool will
            replace it with just $ before passing it to the shell.  */
         *out++ = '$';
         *out++ = '$';
-        }
-      else if(flags & Shell_Flag_VSIDE)
-        {
+      } else if (flags & Shell_Flag_VSIDE) {
         /* In a VS IDE a dollar is written "$".  If this is written in
            an un-quoted argument it starts a quoted segment, inserts
            the $ and ends the segment.  If it is written in a quoted
@@ -939,51 +783,34 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out,
         *out++ = '"';
         *out++ = '$';
         *out++ = '"';
-        }
-      else
-        {
+      } else {
         /* Otherwise a dollar is written just $. */
         *out++ = '$';
-        }
       }
-    else if(*c == '#')
-      {
-      if((flags & Shell_Flag_Make) &&
-         (flags & Shell_Flag_WatcomWMake))
-        {
+    } else if (*c == '#') {
+      if ((flags & Shell_Flag_Make) && (flags & Shell_Flag_WatcomWMake)) {
         /* In Watcom WMake makefiles a pound is written $#.  The make
            tool will replace it with just # before passing it to the
            shell.  */
         *out++ = '$';
         *out++ = '#';
-        }
-      else
-        {
+      } else {
         /* Otherwise a pound is written just #. */
         *out++ = '#';
-        }
       }
-    else if(*c == '%')
-      {
-      if((flags & Shell_Flag_VSIDE) ||
-         ((flags & Shell_Flag_Make) &&
-          ((flags & Shell_Flag_MinGWMake) ||
-           (flags & Shell_Flag_NMake))))
-        {
+    } else if (*c == '%') {
+      if ((flags & Shell_Flag_VSIDE) ||
+          ((flags & Shell_Flag_Make) &&
+           ((flags & Shell_Flag_MinGWMake) || (flags & Shell_Flag_NMake)))) {
         /* In the VS IDE, NMake, or MinGW make a percent is written %%.  */
         *out++ = '%';
         *out++ = '%';
-        }
-      else
-        {
+      } else {
         /* Otherwise a percent is written just %. */
         *out++ = '%';
-        }
       }
-    else if(*c == ';')
-      {
-      if(flags & Shell_Flag_VSIDE)
-        {
+    } else if (*c == ';') {
+      if (flags & Shell_Flag_VSIDE) {
         /* In a VS IDE a semicolon is written ";".  If this is written
            in an un-quoted argument it starts a quoted segment,
            inserts the ; and ends the segment.  If it is written in a
@@ -992,43 +819,33 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out,
         *out++ = '"';
         *out++ = ';';
         *out++ = '"';
-        }
-      else
-        {
+      } else {
         /* Otherwise a semicolon is written just ;. */
         *out++ = ';';
-        }
       }
-    else
-      {
+    } else {
       /* Store this character.  */
       *out++ = *c;
-      }
     }
+  }
 
-  if(needQuotes)
-    {
+  if (needQuotes) {
     /* Add enough backslashes to escape any trailing ones.  */
-    while(windows_backslashes > 0)
-      {
+    while (windows_backslashes > 0) {
       --windows_backslashes;
       *out++ = '\\';
-      }
+    }
 
     /* Add the closing quote for this argument.  */
-    if(flags & Shell_Flag_WatcomQuote)
-      {
+    if (flags & Shell_Flag_WatcomQuote) {
       *out++ = '\'';
-      if(isUnix)
-        {
+      if (isUnix) {
         *out++ = '"';
-        }
       }
-    else
-      {
+    } else {
       *out++ = '"';
-      }
     }
+  }
 
   /* Store a terminating null without incrementing.  */
   *out = 0;
@@ -1036,30 +853,25 @@ char* cmOutputConverter::Shell__GetArgument(const char* in, char* out,
   return out;
 }
 
-/*--------------------------------------------------------------------------*/
-char* cmOutputConverter::Shell_GetArgumentForWindows(const char* in,
-                                                     char* out, int flags)
+char* cmOutputConverter::Shell_GetArgumentForWindows(const char* in, char* out,
+                                                     int flags)
 {
   return Shell__GetArgument(in, out, 0, flags);
 }
 
-/*--------------------------------------------------------------------------*/
-char* cmOutputConverter::Shell_GetArgumentForUnix(const char* in,
-                                                  char* out, int flags)
+char* cmOutputConverter::Shell_GetArgumentForUnix(const char* in, char* out,
+                                                  int flags)
 {
   return Shell__GetArgument(in, out, 1, flags);
 }
 
-/*--------------------------------------------------------------------------*/
 int cmOutputConverter::Shell_GetArgumentSizeForWindows(const char* in,
                                                        int flags)
 {
   return Shell__GetArgumentSize(in, 0, flags);
 }
 
-/*--------------------------------------------------------------------------*/
-int cmOutputConverter::Shell_GetArgumentSizeForUnix(const char* in,
-                                                    int flags)
+int cmOutputConverter::Shell_GetArgumentSizeForUnix(const char* in, int flags)
 {
   return Shell__GetArgumentSize(in, 1, flags);
 }
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index 852df5d..75d6326 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -36,8 +36,23 @@ public:
    * optional: should any relative path operation be controlled by the rel
    * path setting
    */
-  enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT };
-  enum OutputFormat { UNCHANGED, MAKERULE, SHELL, WATCOMQUOTE, RESPONSE };
+  enum RelativeRoot
+  {
+    NONE,
+    FULL,
+    HOME,
+    START,
+    HOME_OUTPUT,
+    START_OUTPUT
+  };
+  enum OutputFormat
+  {
+    UNCHANGED,
+    MAKERULE,
+    SHELL,
+    WATCOMQUOTE,
+    RESPONSE
+  };
   std::string ConvertToOutputFormat(const std::string& source,
                                     OutputFormat output) const;
   std::string Convert(const std::string& remote, RelativeRoot local,
@@ -46,7 +61,7 @@ public:
                       OutputFormat output = UNCHANGED,
                       bool optional = false) const;
   std::string ConvertDirectorySeparatorsForShell(
-                                             const std::string& source) const;
+    const std::string& source) const;
 
   /**
     * Get path for the specified relative root.
@@ -75,33 +90,33 @@ public:
   enum Shell_Flag_e
   {
     /** The target shell is in a makefile.  */
-    Shell_Flag_Make               = (1<<0),
+    Shell_Flag_Make = (1 << 0),
 
     /** The target shell is in a VS project file.  Do not use with
         Shell_Flag_Make.  */
-    Shell_Flag_VSIDE              = (1<<1),
+    Shell_Flag_VSIDE = (1 << 1),
 
     /** In a windows shell the argument is being passed to "echo".  */
-    Shell_Flag_EchoWindows        = (1<<2),
+    Shell_Flag_EchoWindows = (1 << 2),
 
     /** The target shell is in a Watcom WMake makefile.  */
-    Shell_Flag_WatcomWMake        = (1<<3),
+    Shell_Flag_WatcomWMake = (1 << 3),
 
     /** The target shell is in a MinGW Make makefile.  */
-    Shell_Flag_MinGWMake          = (1<<4),
+    Shell_Flag_MinGWMake = (1 << 4),
 
     /** The target shell is in a NMake makefile.  */
-    Shell_Flag_NMake              = (1<<5),
+    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.  */
-    Shell_Flag_AllowMakeVariables = (1<<6),
+    Shell_Flag_AllowMakeVariables = (1 << 6),
 
     /** The target shell quoting uses extra single Quotes for Watcom tools.  */
-    Shell_Flag_WatcomQuote        = (1<<7)
+    Shell_Flag_WatcomQuote = (1 << 7)
   };
 
   /**
@@ -123,10 +138,9 @@ public:
   static int Shell_GetArgumentSizeForWindows(const char* in, int flags);
   static int Shell_GetArgumentSizeForUnix(const char* in, int flags);
 
-  std::string EscapeForShell(const std::string& str,
-                                    bool makeVars = false,
-                                    bool forEcho = false,
-                                    bool useWatcomQuote = false) const;
+  std::string EscapeForShell(const std::string& str, bool makeVars = false,
+                             bool forEcho = false,
+                             bool useWatcomQuote = false) const;
 
   static std::string EscapeForCMake(const std::string& str);
 
@@ -136,11 +150,11 @@ public:
                                                 int shell_flags);
 
   enum FortranFormat
-    {
+  {
     FortranFormatNone,
     FortranFormatFixed,
     FortranFormatFree
-    };
+  };
   static FortranFormat GetFortranFormat(const char* value);
 
   /**
@@ -167,12 +181,10 @@ private:
   static int Shell__CharNeedsQuotes(char c, int isUnix, int flags);
   static int Shell__CharIsMakeVariableName(char c);
   static const char* Shell__SkipMakeVariables(const char* c);
-  static int Shell__ArgumentNeedsQuotes(const char* in,
-                                        int isUnix, int flags);
-  static int Shell__GetArgumentSize(const char* in,
-                                    int isUnix, int flags);
-  static char* Shell__GetArgument(const char* in, char* out,
-                                  int isUnix, int flags);
+  static int Shell__ArgumentNeedsQuotes(const char* in, int isUnix, int flags);
+  static int Shell__GetArgumentSize(const char* in, int isUnix, int flags);
+  static char* Shell__GetArgument(const char* in, char* out, int isUnix,
+                                  int flags);
 
 private:
   cmState::Snapshot StateSnapshot;
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 54208ac..29f1acc 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmOutputRequiredFilesCommand.h"
+
 #include "cmAlgorithms.h"
 #include <cmsys/FStream.hxx>
 
@@ -25,7 +26,11 @@ public:
    * Construct with dependency generation marked not done; instance
    * not placed in cmMakefile's list.
    */
-  cmDependInformation(): DependDone(false), SourceFile(0) {}
+  cmDependInformation()
+    : DependDone(false)
+    , SourceFile(0)
+  {
+  }
 
   /**
    * The set of files on which this one depends.
@@ -43,7 +48,7 @@ public:
    * If this object corresponds to a cmSourceFile instance, this points
    * to it.
    */
-  const cmSourceFile *SourceFile;
+  const cmSourceFile* SourceFile;
 
   /**
    * Full path to this file.
@@ -65,9 +70,8 @@ public:
    */
   void AddDependencies(cmDependInformation* info)
   {
-  if(this != info)
-    {
-    this->DependencySet.insert(info);
+    if (this != info) {
+      this->DependencySet.insert(info);
     }
   }
 };
@@ -88,10 +92,7 @@ public:
   /**
    * Destructor.
    */
-  ~cmLBDepend()
-  {
-    cmDeleteAll(this->DependInformationMap);
-  }
+  ~cmLBDepend() { cmDeleteAll(this->DependInformationMap); }
 
   /**
    * Set the makefile that is used as a source of classes.
@@ -102,49 +103,41 @@ public:
 
     // Now extract the include file regular expression from the makefile.
     this->IncludeFileRegularExpression.compile(
-          this->Makefile->GetIncludeRegularExpression());
+      this->Makefile->GetIncludeRegularExpression());
     this->ComplainFileRegularExpression.compile(
-          this->Makefile->GetComplainRegularExpression());
+      this->Makefile->GetComplainRegularExpression());
 
     // Now extract any include paths from the targets
     std::set<std::string> uniqueIncludes;
     std::vector<std::string> orderedAndUniqueIncludes;
-    cmTargets &targets = this->Makefile->GetTargets();
-    for (cmTargets::iterator l = targets.begin();
-         l != targets.end(); ++l)
-      {
-      const char *incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
-      if (!incDirProp)
-        {
+    cmTargets& targets = this->Makefile->GetTargets();
+    for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) {
+      const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
+      if (!incDirProp) {
         continue;
-        }
+      }
 
-      std::string incDirs =
-          cmGeneratorExpression::Preprocess(incDirProp,
-              cmGeneratorExpression::StripAllGeneratorExpressions);
+      std::string incDirs = cmGeneratorExpression::Preprocess(
+        incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions);
 
       std::vector<std::string> includes;
       cmSystemTools::ExpandListArgument(incDirs, includes);
 
-      for(std::vector<std::string>::const_iterator j = includes.begin();
-          j != includes.end(); ++j)
-        {
+      for (std::vector<std::string>::const_iterator j = includes.begin();
+           j != includes.end(); ++j) {
         std::string path = *j;
         this->Makefile->ExpandVariablesInString(path);
-        if(uniqueIncludes.insert(path).second)
-          {
+        if (uniqueIncludes.insert(path).second) {
           orderedAndUniqueIncludes.push_back(path);
-          }
         }
       }
+    }
 
-    for(std::vector<std::string>::const_iterator
-        it = orderedAndUniqueIncludes.begin();
-        it != orderedAndUniqueIncludes.end();
-        ++it)
-      {
+    for (std::vector<std::string>::const_iterator it =
+           orderedAndUniqueIncludes.begin();
+         it != orderedAndUniqueIncludes.end(); ++it) {
       this->AddSearchPath(*it);
-      }
+    }
   }
 
   /**
@@ -161,7 +154,7 @@ public:
    */
   const cmDependInformation* FindDependencies(const char* file)
   {
-    cmDependInformation* info = this->GetDependInformation(file,0);
+    cmDependInformation* info = this->GetDependInformation(file, 0);
     this->GenerateDependInformation(info);
     return info;
   }
@@ -174,152 +167,124 @@ protected:
   void DependWalk(cmDependInformation* info)
   {
     cmsys::ifstream fin(info->FullPath.c_str());
-    if(!fin)
-      {
+    if (!fin) {
       cmSystemTools::Error("error can not open ", info->FullPath.c_str());
       return;
-      }
+    }
 
     std::string line;
-    while(cmSystemTools::GetLineFromStream(fin, line))
-      {
-      if(cmHasLiteralPrefix(line.c_str(), "#include"))
-        {
+    while (cmSystemTools::GetLineFromStream(fin, line)) {
+      if (cmHasLiteralPrefix(line.c_str(), "#include")) {
         // if it is an include line then create a string class
         std::string currentline = line;
         size_t qstart = currentline.find('\"', 8);
         size_t qend;
         // if a quote is not found look for a <
-        if(qstart == std::string::npos)
-          {
+        if (qstart == std::string::npos) {
           qstart = currentline.find('<', 8);
           // if a < is not found then move on
-          if(qstart == std::string::npos)
-            {
+          if (qstart == std::string::npos) {
             cmSystemTools::Error("unknown include directive ",
-                                 currentline.c_str() );
+                                 currentline.c_str());
             continue;
-            }
-          else
-            {
-            qend = currentline.find('>', qstart+1);
-            }
-          }
-        else
-          {
-          qend = currentline.find('\"', qstart+1);
+          } else {
+            qend = currentline.find('>', qstart + 1);
           }
+        } else {
+          qend = currentline.find('\"', qstart + 1);
+        }
         // extract the file being included
         std::string includeFile =
-          currentline.substr(qstart+1, qend - qstart-1);
+          currentline.substr(qstart + 1, qend - qstart - 1);
         // see if the include matches the regular expression
-        if(!this->IncludeFileRegularExpression.find(includeFile))
-          {
-          if(this->Verbose)
-            {
+        if (!this->IncludeFileRegularExpression.find(includeFile)) {
+          if (this->Verbose) {
             std::string message = "Skipping ";
             message += includeFile;
             message += " for file ";
             message += info->FullPath.c_str();
             cmSystemTools::Error(message.c_str(), 0);
-            }
-          continue;
           }
+          continue;
+        }
 
         // Add this file and all its dependencies.
         this->AddDependency(info, includeFile.c_str());
         /// add the cxx file if it exists
         std::string cxxFile = includeFile;
         std::string::size_type pos = cxxFile.rfind('.');
-        if(pos != std::string::npos)
-          {
+        if (pos != std::string::npos) {
           std::string root = cxxFile.substr(0, pos);
           cxxFile = root + ".cxx";
           bool found = false;
           // try jumping to .cxx .cpp and .c in order
-          if(cmSystemTools::FileExists(cxxFile.c_str()))
-            {
+          if (cmSystemTools::FileExists(cxxFile.c_str())) {
             found = true;
-            }
-          for(std::vector<std::string>::iterator i =
-              this->IncludeDirectories.begin();
-              i != this->IncludeDirectories.end(); ++i)
-            {
+          }
+          for (std::vector<std::string>::iterator i =
+                 this->IncludeDirectories.begin();
+               i != this->IncludeDirectories.end(); ++i) {
             std::string path = *i;
             path = path + "/";
             path = path + cxxFile;
-            if(cmSystemTools::FileExists(path.c_str()))
-              {
+            if (cmSystemTools::FileExists(path.c_str())) {
               found = true;
-              }
             }
-          if (!found)
-            {
+          }
+          if (!found) {
             cxxFile = root + ".cpp";
-            if(cmSystemTools::FileExists(cxxFile.c_str()))
-              {
+            if (cmSystemTools::FileExists(cxxFile.c_str())) {
               found = true;
-              }
-            for(std::vector<std::string>::iterator i =
-                this->IncludeDirectories.begin();
-                i != this->IncludeDirectories.end(); ++i)
-              {
+            }
+            for (std::vector<std::string>::iterator i =
+                   this->IncludeDirectories.begin();
+                 i != this->IncludeDirectories.end(); ++i) {
               std::string path = *i;
               path = path + "/";
               path = path + cxxFile;
-              if(cmSystemTools::FileExists(path.c_str()))
-                {
+              if (cmSystemTools::FileExists(path.c_str())) {
                 found = true;
-                }
               }
             }
-          if (!found)
-            {
+          }
+          if (!found) {
             cxxFile = root + ".c";
-            if(cmSystemTools::FileExists(cxxFile.c_str()))
-              {
+            if (cmSystemTools::FileExists(cxxFile.c_str())) {
               found = true;
-              }
-            for(std::vector<std::string>::iterator i =
-                this->IncludeDirectories.begin();
-                i != this->IncludeDirectories.end(); ++i)
-              {
+            }
+            for (std::vector<std::string>::iterator i =
+                   this->IncludeDirectories.begin();
+                 i != this->IncludeDirectories.end(); ++i) {
               std::string path = *i;
               path = path + "/";
               path = path + cxxFile;
-              if(cmSystemTools::FileExists(path.c_str()))
-                {
+              if (cmSystemTools::FileExists(path.c_str())) {
                 found = true;
-                }
               }
             }
-          if (!found)
-            {
+          }
+          if (!found) {
             cxxFile = root + ".txx";
-            if(cmSystemTools::FileExists(cxxFile.c_str()))
-              {
+            if (cmSystemTools::FileExists(cxxFile.c_str())) {
               found = true;
-              }
-            for(std::vector<std::string>::iterator i =
-                this->IncludeDirectories.begin();
-                i != this->IncludeDirectories.end(); ++i)
-              {
+            }
+            for (std::vector<std::string>::iterator i =
+                   this->IncludeDirectories.begin();
+                 i != this->IncludeDirectories.end(); ++i) {
               std::string path = *i;
               path = path + "/";
               path = path + cxxFile;
-              if(cmSystemTools::FileExists(path.c_str()))
-                {
+              if (cmSystemTools::FileExists(path.c_str())) {
                 found = true;
-                }
               }
             }
-          if (found)
-            {
+          }
+          if (found) {
             this->AddDependency(info, cxxFile.c_str());
-            }
           }
         }
       }
+    }
   }
 
   /**
@@ -328,7 +293,7 @@ protected:
   void AddDependency(cmDependInformation* info, const char* file)
   {
     cmDependInformation* dependInfo =
-        this->GetDependInformation(file, info->PathOnly.c_str());
+      this->GetDependInformation(file, info->PathOnly.c_str());
     this->GenerateDependInformation(dependInfo);
     info->AddDependencies(dependInfo);
   }
@@ -340,108 +305,88 @@ protected:
   void GenerateDependInformation(cmDependInformation* info)
   {
     // If dependencies are already done, stop now.
-    if(info->DependDone)
-      {
+    if (info->DependDone) {
       return;
-      }
-    else
-      {
+    } else {
       // Make sure we don't visit the same file more than once.
       info->DependDone = true;
-      }
+    }
     const char* path = info->FullPath.c_str();
-    if(!path)
-      {
+    if (!path) {
       cmSystemTools::Error(
-            "Attempt to find dependencies for file without path!");
+        "Attempt to find dependencies for file without path!");
       return;
-      }
+    }
 
     bool found = false;
 
     // If the file exists, use it to find dependency information.
-    if(cmSystemTools::FileExists(path, true))
-      {
+    if (cmSystemTools::FileExists(path, true)) {
       // Use the real file to find its dependencies.
       this->DependWalk(info);
       found = true;
-      }
-
+    }
 
     // See if the cmSourceFile for it has any files specified as
     // dependency hints.
-    if(info->SourceFile != 0)
-      {
+    if (info->SourceFile != 0) {
 
       // Get the cmSourceFile corresponding to this.
       const cmSourceFile& cFile = *(info->SourceFile);
       // See if there are any hints for finding dependencies for the missing
       // file.
-      if(!cFile.GetDepends().empty())
-        {
+      if (!cFile.GetDepends().empty()) {
         // Dependency hints have been given.  Use them to begin the
         // recursion.
-        for(std::vector<std::string>::const_iterator file =
-            cFile.GetDepends().begin(); file != cFile.GetDepends().end();
-            ++file)
-          {
+        for (std::vector<std::string>::const_iterator file =
+               cFile.GetDepends().begin();
+             file != cFile.GetDepends().end(); ++file) {
           this->AddDependency(info, file->c_str());
-          }
+        }
 
         // Found dependency information.  We are done.
         found = true;
-        }
       }
+    }
 
-    if(!found)
-      {
+    if (!found) {
       // Try to find the file amongst the sources
-      cmSourceFile *srcFile = this->Makefile->GetSource
-          (cmSystemTools::GetFilenameWithoutExtension(path));
-      if (srcFile)
-        {
-        if (srcFile->GetFullPath() == path)
-          {
-          found=true;
-          }
-        else
-          {
-          //try to guess which include path to use
-          for(std::vector<std::string>::iterator t =
-              this->IncludeDirectories.begin();
-              t != this->IncludeDirectories.end(); ++t)
-            {
+      cmSourceFile* srcFile = this->Makefile->GetSource(
+        cmSystemTools::GetFilenameWithoutExtension(path));
+      if (srcFile) {
+        if (srcFile->GetFullPath() == path) {
+          found = true;
+        } else {
+          // try to guess which include path to use
+          for (std::vector<std::string>::iterator t =
+                 this->IncludeDirectories.begin();
+               t != this->IncludeDirectories.end(); ++t) {
             std::string incpath = *t;
-            if (!incpath.empty() && incpath[incpath.size() - 1] != '/')
-              {
+            if (!incpath.empty() && incpath[incpath.size() - 1] != '/') {
               incpath = incpath + "/";
-              }
+            }
             incpath = incpath + path;
-            if (srcFile->GetFullPath() == incpath)
-              {
+            if (srcFile->GetFullPath() == incpath) {
               // set the path to the guessed path
               info->FullPath = incpath;
-              found=true;
-              }
+              found = true;
             }
           }
         }
       }
+    }
 
-    if(!found)
-      {
+    if (!found) {
       // Couldn't find any dependency information.
-      if(this->ComplainFileRegularExpression.find(info->IncludeName.c_str()))
-        {
+      if (this->ComplainFileRegularExpression.find(
+            info->IncludeName.c_str())) {
         cmSystemTools::Error("error cannot find dependencies for ", path);
-        }
-      else
-        {
+      } else {
         // Destroy the name of the file so that it won't be output as a
         // dependency.
         info->FullPath = "";
-        }
       }
+    }
   }
 
   /**
@@ -449,21 +394,18 @@ protected:
    * name.
    */
   cmDependInformation* GetDependInformation(const char* file,
-                                            const char *extraPath)
+                                            const char* extraPath)
   {
     // Get the full path for the file so that lookup is unambiguous.
     std::string fullPath = this->FullPath(file, extraPath);
 
     // Try to find the file's instance of cmDependInformation.
     DependInformationMapType::const_iterator result =
-        this->DependInformationMap.find(fullPath);
-    if(result != this->DependInformationMap.end())
-      {
+      this->DependInformationMap.find(fullPath);
+    if (result != this->DependInformationMap.end()) {
       // Found an instance, return it.
       return result->second;
-      }
-    else
-      {
+    } else {
       // Didn't find an instance.  Create a new one and save it.
       cmDependInformation* info = new cmDependInformation;
       info->FullPath = fullPath;
@@ -471,7 +413,7 @@ protected:
       info->IncludeName = file;
       this->DependInformationMap[fullPath] = info;
       return info;
-      }
+    }
   }
 
   /**
@@ -479,70 +421,58 @@ protected:
    * This uses the include directories.
    * TODO: Cache path conversions to reduce FileExists calls.
    */
-  std::string FullPath(const char *fname, const char *extraPath)
+  std::string FullPath(const char* fname, const char* extraPath)
   {
     DirectoryToFileToPathMapType::iterator m;
-    if(extraPath)
-      {
+    if (extraPath) {
       m = this->DirectoryToFileToPathMap.find(extraPath);
-      }
-    else
-      {
+    } else {
       m = this->DirectoryToFileToPathMap.find("");
-      }
+    }
 
-    if(m != this->DirectoryToFileToPathMap.end())
-      {
+    if (m != this->DirectoryToFileToPathMap.end()) {
       FileToPathMapType& map = m->second;
       FileToPathMapType::iterator p = map.find(fname);
-      if(p != map.end())
-        {
+      if (p != map.end()) {
         return p->second;
-        }
       }
+    }
 
-    if(cmSystemTools::FileExists(fname, true))
-      {
+    if (cmSystemTools::FileExists(fname, true)) {
       std::string fp = cmSystemTools::CollapseFullPath(fname);
-      this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp;
+      this->DirectoryToFileToPathMap[extraPath ? extraPath : ""][fname] = fp;
       return fp;
-      }
+    }
 
-    for(std::vector<std::string>::iterator i =
-        this->IncludeDirectories.begin();
-        i != this->IncludeDirectories.end(); ++i)
-      {
+    for (std::vector<std::string>::iterator i =
+           this->IncludeDirectories.begin();
+         i != this->IncludeDirectories.end(); ++i) {
       std::string path = *i;
-      if (!path.empty() && path[path.size() - 1] != '/')
-        {
+      if (!path.empty() && path[path.size() - 1] != '/') {
         path = path + "/";
-        }
+      }
       path = path + fname;
-      if(cmSystemTools::FileExists(path.c_str(), true)
-         && !cmSystemTools::FileIsDirectory(path))
-        {
+      if (cmSystemTools::FileExists(path.c_str(), true) &&
+          !cmSystemTools::FileIsDirectory(path)) {
         std::string fp = cmSystemTools::CollapseFullPath(path);
-        this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp;
+        this->DirectoryToFileToPathMap[extraPath ? extraPath : ""][fname] = fp;
         return fp;
-        }
       }
+    }
 
-    if (extraPath)
-      {
+    if (extraPath) {
       std::string path = extraPath;
-      if (!path.empty() && path[path.size() - 1] != '/')
-        {
+      if (!path.empty() && path[path.size() - 1] != '/') {
         path = path + "/";
-        }
+      }
       path = path + fname;
-      if(cmSystemTools::FileExists(path.c_str(), true)
-         && !cmSystemTools::FileIsDirectory(path))
-        {
+      if (cmSystemTools::FileExists(path.c_str(), true) &&
+          !cmSystemTools::FileIsDirectory(path)) {
         std::string fp = cmSystemTools::CollapseFullPath(path);
         this->DirectoryToFileToPathMap[extraPath][fname] = fp;
         return fp;
-        }
       }
+    }
 
     // Couldn't find the file.
     return std::string(fname);
@@ -555,25 +485,25 @@ protected:
   std::vector<std::string> IncludeDirectories;
   typedef std::map<std::string, std::string> FileToPathMapType;
   typedef std::map<std::string, FileToPathMapType>
-  DirectoryToFileToPathMapType;
-  typedef std::map<std::string, cmDependInformation*>
-  DependInformationMapType;
+    DirectoryToFileToPathMapType;
+  typedef std::map<std::string, cmDependInformation*> DependInformationMapType;
   DependInformationMapType DependInformationMap;
   DirectoryToFileToPathMapType DirectoryToFileToPathMap;
 };
 
 // cmOutputRequiredFilesCommand
-bool cmOutputRequiredFilesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmOutputRequiredFilesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0032,
-      "The output_required_files command should not be called; see CMP0032."))
-    { return true; }
-  if(args.size() != 2 )
-    {
+  if (this->Disallowed(cmPolicies::CMP0032, "The output_required_files "
+                                            "command should not be called; "
+                                            "see CMP0032.")) {
+    return true;
+  }
+  if (args.size() != 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // store the arg for final pass
   this->File = args[0];
@@ -584,52 +514,44 @@ bool cmOutputRequiredFilesCommand
   md.SetMakefile(this->Makefile);
   md.AddSearchPath(this->Makefile->GetCurrentSourceDirectory());
   // find the depends for a file
-  const cmDependInformation *info = md.FindDependencies(this->File.c_str());
-  if (info)
-    {
+  const cmDependInformation* info = md.FindDependencies(this->File.c_str());
+  if (info) {
     // write them out
-    FILE *fout = cmsys::SystemTools::Fopen(this->OutputFile.c_str(),"w");
-    if(!fout)
-      {
+    FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile.c_str(), "w");
+    if (!fout) {
       std::string err = "Can not open output file: ";
       err += this->OutputFile;
       this->SetError(err);
       return false;
-      }
+    }
     std::set<cmDependInformation const*> visited;
-    this->ListDependencies(info,fout, &visited);
+    this->ListDependencies(info, fout, &visited);
     fclose(fout);
-    }
+  }
 
   return true;
 }
 
-void cmOutputRequiredFilesCommand::
-ListDependencies(cmDependInformation const *info,
-                 FILE *fout,
-                 std::set<cmDependInformation const*> *visited)
+void cmOutputRequiredFilesCommand::ListDependencies(
+  cmDependInformation const* info, FILE* fout,
+  std::set<cmDependInformation const*>* visited)
 {
   // add info to the visited set
   visited->insert(info);
   // now recurse with info's dependencies
-  for(cmDependInformation::DependencySetType::const_iterator d =
-        info->DependencySet.begin();
-      d != info->DependencySet.end(); ++d)
-    {
-    if (visited->find(*d) == visited->end())
-      {
-      if(info->FullPath != "")
-        {
+  for (cmDependInformation::DependencySetType::const_iterator d =
+         info->DependencySet.begin();
+       d != info->DependencySet.end(); ++d) {
+    if (visited->find(*d) == visited->end()) {
+      if (info->FullPath != "") {
         std::string tmp = (*d)->FullPath;
         std::string::size_type pos = tmp.rfind('.');
-        if(pos != std::string::npos && (tmp.substr(pos) != ".h"))
-          {
+        if (pos != std::string::npos && (tmp.substr(pos) != ".h")) {
           tmp = tmp.substr(0, pos);
-          fprintf(fout,"%s\n",(*d)->FullPath.c_str());
-          }
+          fprintf(fout, "%s\n", (*d)->FullPath.c_str());
         }
-      this->ListDependencies(*d,fout,visited);
       }
+      this->ListDependencies(*d, fout, visited);
     }
+  }
 }
-
diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h
index b5eb932..7a6f5a6 100644
--- a/Source/cmOutputRequiredFilesCommand.h
+++ b/Source/cmOutputRequiredFilesCommand.h
@@ -22,17 +22,15 @@ public:
   cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand);
   virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const { return "output_required_files";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "output_required_files"; }
+
+  void ListDependencies(cmDependInformation const* info, FILE* fout,
+                        std::set<cmDependInformation const*>* visited);
 
-  void ListDependencies(cmDependInformation const *info,
-                        FILE *fout,
-                        std::set<cmDependInformation const*> *visited);
 private:
   std::string File;
   std::string OutputFile;
 };
 
-
-
 #endif
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index ca76c88..8f524ec 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -12,22 +12,21 @@
 ============================================================================*/
 
 #include "cmParseArgumentsCommand.h"
+
 #include "cmAlgorithms.h"
 
-//----------------------------------------------------------------------------
-bool cmParseArgumentsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
   // cmake_parse_arguments(prefix options single multi <ARGN>)
   //                         1       2      3      4
-  if (args.size() < 4)
-    {
+  if (args.size() < 4) {
     this->SetError("must be called with at least 4 arguments.");
     return false;
-    }
+  }
 
   std::vector<std::string>::const_iterator argIter = args.begin(),
-                                           argEnd  = args.end();
+                                           argEnd = args.end();
   // the first argument is the prefix
   const std::string prefix = (*argIter++) + "_";
 
@@ -50,44 +49,38 @@ bool cmParseArgumentsCommand
   // the second argument is a (cmake) list of options without argument
   std::vector<std::string> list;
   cmSystemTools::ExpandListArgument(*argIter++, list);
-  for (std::vector<std::string>::const_iterator iter  = list.begin(),
-                                                end   = list.end();
-                                                iter != end; ++iter)
-    {
-    if (!used_keywords.insert(*iter).second)
-      {
+  for (std::vector<std::string>::const_iterator iter = list.begin(),
+                                                end = list.end();
+       iter != end; ++iter) {
+    if (!used_keywords.insert(*iter).second) {
       this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
-      }
-    options[*iter]; // default initialize
     }
+    options[*iter]; // default initialize
+  }
 
   // the third argument is a (cmake) list of single argument options
   list.clear();
   cmSystemTools::ExpandListArgument(*argIter++, list);
-  for (std::vector<std::string>::const_iterator iter  = list.begin(),
-                                                end   = list.end();
-                                                iter != end; ++iter)
-    {
-    if (!used_keywords.insert(*iter).second)
-      {
+  for (std::vector<std::string>::const_iterator iter = list.begin(),
+                                                end = list.end();
+       iter != end; ++iter) {
+    if (!used_keywords.insert(*iter).second) {
       this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
-      }
-    single[*iter]; // default initialize
     }
+    single[*iter]; // default initialize
+  }
 
   // the fourth argument is a (cmake) list of multi argument options
   list.clear();
   cmSystemTools::ExpandListArgument(*argIter++, list);
-  for (std::vector<std::string>::const_iterator iter  = list.begin(),
-                                                end   = list.end();
-                                                iter != end; ++iter)
-    {
-    if (!used_keywords.insert(*iter).second)
-      {
+  for (std::vector<std::string>::const_iterator iter = list.begin(),
+                                                end = list.end();
+       iter != end; ++iter) {
+    if (!used_keywords.insert(*iter).second) {
       this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
-      }
-    multi[*iter]; // default initialize
     }
+    multi[*iter]; // default initialize
+  }
 
   enum insideValues
   {
@@ -100,41 +93,35 @@ bool cmParseArgumentsCommand
   // Flatten ;-lists in the arguments into a single list as was done
   // by the original function(CMAKE_PARSE_ARGUMENTS).
   list.clear();
-  for(; argIter != argEnd; ++argIter)
-    {
+  for (; argIter != argEnd; ++argIter) {
     cmSystemTools::ExpandListArgument(*argIter, list);
-    }
+  }
 
   // iterate over the arguments list and fill in the values where applicable
-  for (argIter = list.begin(), argEnd = list.end();
-       argIter != argEnd; ++argIter)
-    {
+  for (argIter = list.begin(), argEnd = list.end(); argIter != argEnd;
+       ++argIter) {
     const options_map::iterator optIter = options.find(*argIter);
-    if (optIter != options.end())
-      {
+    if (optIter != options.end()) {
       insideValues = NONE;
       optIter->second = true;
       continue;
-      }
+    }
 
     const single_map::iterator singleIter = single.find(*argIter);
-    if (singleIter != single.end())
-      {
+    if (singleIter != single.end()) {
       insideValues = SINGLE;
       currentArgName = *argIter;
       continue;
-      }
+    }
 
     const multi_map::iterator multiIter = multi.find(*argIter);
-    if (multiIter != multi.end())
-      {
+    if (multiIter != multi.end()) {
       insideValues = MULTI;
       currentArgName = *argIter;
       continue;
-      }
+    }
 
-    switch(insideValues)
-      {
+    switch (insideValues) {
       case SINGLE:
         single[currentArgName] = *argIter;
         insideValues = NONE;
@@ -145,56 +132,43 @@ bool cmParseArgumentsCommand
       default:
         unparsed.push_back(*argIter);
         break;
-      }
     }
+  }
 
   // now iterate over the collected values and update their definition
   // within the current scope. undefine if necessary.
 
   for (options_map::const_iterator iter = options.begin(), end = options.end();
-                                   iter != end; ++iter)
-    {
+       iter != end; ++iter) {
     this->Makefile->AddDefinition(prefix + iter->first,
-                                  iter->second? "TRUE": "FALSE");
-    }
+                                  iter->second ? "TRUE" : "FALSE");
+  }
   for (single_map::const_iterator iter = single.begin(), end = single.end();
-                                  iter != end; ++iter)
-    {
-    if (!iter->second.empty())
-      {
+       iter != end; ++iter) {
+    if (!iter->second.empty()) {
       this->Makefile->AddDefinition(prefix + iter->first,
                                     iter->second.c_str());
-      }
-    else
-      {
+    } else {
       this->Makefile->RemoveDefinition(prefix + iter->first);
-      }
     }
+  }
 
   for (multi_map::const_iterator iter = multi.begin(), end = multi.end();
-                                  iter != end; ++iter)
-    {
-    if (!iter->second.empty())
-      {
-      this->Makefile->AddDefinition(prefix + iter->first,
-                                    cmJoin(cmMakeRange(iter->second), ";")
-                                      .c_str());
-      }
-    else
-      {
+       iter != end; ++iter) {
+    if (!iter->second.empty()) {
+      this->Makefile->AddDefinition(
+        prefix + iter->first, cmJoin(cmMakeRange(iter->second), ";").c_str());
+    } else {
       this->Makefile->RemoveDefinition(prefix + iter->first);
-      }
     }
+  }
 
-  if (!unparsed.empty())
-    {
+  if (!unparsed.empty()) {
     this->Makefile->AddDefinition(prefix + "UNPARSED_ARGUMENTS",
                                   cmJoin(cmMakeRange(unparsed), ";").c_str());
-    }
-  else
-    {
+  } else {
     this->Makefile->RemoveDefinition(prefix + "UNPARSED_ARGUMENTS");
-    }
+  }
 
   return true;
 }
diff --git a/Source/cmParseArgumentsCommand.h b/Source/cmParseArgumentsCommand.h
index 7fbf642..46d9daa 100644
--- a/Source/cmParseArgumentsCommand.h
+++ b/Source/cmParseArgumentsCommand.h
@@ -24,17 +24,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmParseArgumentsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmParseArgumentsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -44,11 +41,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "cmake_parse_arguments";}
+  virtual std::string GetName() const { return "cmake_parse_arguments"; }
 
   cmTypeMacro(cmParseArgumentsCommand, cmCommand);
-
 };
 
-
 #endif
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
index 67d56e1..491d2f0 100644
--- a/Source/cmPathLabel.cxx
+++ b/Source/cmPathLabel.cxx
@@ -12,30 +12,27 @@
 
 #include "cmPathLabel.h"
 
-//----------------------------------------------------------------------------
 cmPathLabel::cmPathLabel(const std::string& label)
-: Label(label), Hash(0)
+  : Label(label)
+  , Hash(0)
 {
   // Use a Jenkins one-at-a-time hash with under/over-flow protection
-  for(size_t i = 0; i < this->Label.size(); ++i)
-    {
+  for (size_t i = 0; i < this->Label.size(); ++i) {
     this->Hash += this->Label[i];
     this->Hash += ((this->Hash & 0x003FFFFF) << 10);
     this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6);
-    }
+  }
   this->Hash += ((this->Hash & 0x1FFFFFFF) << 3);
   this->Hash ^= ((this->Hash & 0xFFFFF800) >> 11);
   this->Hash += ((this->Hash & 0x0001FFFF) << 15);
 }
 
-//----------------------------------------------------------------------------
-bool cmPathLabel::operator < (const cmPathLabel& l) const
+bool cmPathLabel::operator<(const cmPathLabel& l) const
 {
   return this->Hash < l.Hash;
 }
 
-//----------------------------------------------------------------------------
-bool cmPathLabel::operator == (const cmPathLabel& l) const
+bool cmPathLabel::operator==(const cmPathLabel& l) const
 {
   return this->Hash == l.Hash;
 }
diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h
index 02d5261..39fbec3 100644
--- a/Source/cmPathLabel.h
+++ b/Source/cmPathLabel.h
@@ -28,8 +28,8 @@ public:
 
   // The comparison operators are only for quick sorting and searching and
   // in no way imply any lexicographical order of the label
-  bool operator < (const cmPathLabel& l) const;
-  bool operator == (const cmPathLabel& l) const;
+  bool operator<(const cmPathLabel& l) const;
+  bool operator==(const cmPathLabel& l) const;
 
   const std::string& GetLabel() const { return this->Label; }
   const unsigned int& GetHash() const { return this->Hash; }
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 3eb19bb..85f0fa3 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -1,143 +1,124 @@
 #include "cmPolicies.h"
-#include "cmake.h"
+
+#include "cmAlgorithms.h"
 #include "cmMakefile.h"
 #include "cmVersion.h"
 #include "cmVersionMacros.h"
-#include "cmAlgorithms.h"
+#include "cmake.h"
+#include <assert.h>
+#include <ctype.h>
 #include <map>
-#include <set>
 #include <queue>
-#include <assert.h>
+#include <set>
 
 static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
 {
   assert(input);
-  if (strlen(input) != 7)
-    {
+  if (strlen(input) != 7) {
     return false;
-    }
-  if (!cmHasLiteralPrefix(input, "CMP"))
-    {
+  }
+  if (!cmHasLiteralPrefix(input, "CMP")) {
     return false;
-    }
-  if (cmHasLiteralSuffix(input, "0000"))
-    {
+  }
+  if (cmHasLiteralSuffix(input, "0000")) {
     pid = cmPolicies::CMP0000;
     return true;
-    }
-  for (int i = 3; i < 7; ++i)
-    {
-    if (!isdigit(*(input + i)))
-      {
+  }
+  for (int i = 3; i < 7; ++i) {
+    if (!isdigit(*(input + i))) {
       return false;
-      }
     }
+  }
   long id;
-  if (!cmSystemTools::StringToLong(input + 3, &id))
-    {
+  if (!cmSystemTools::StringToLong(input + 3, &id)) {
     return false;
-    }
-  if (id >= cmPolicies::CMPCOUNT)
-    {
+  }
+  if (id >= cmPolicies::CMPCOUNT) {
     return false;
-    }
+  }
   pid = cmPolicies::PolicyID(id);
   return true;
 }
 
 #define CM_SELECT_ID_VERSION(F, A1, A2, A3, A4, A5, A6) F(A1, A3, A4, A5)
-#define CM_FOR_EACH_POLICY_ID_VERSION(POLICY) \
+#define CM_FOR_EACH_POLICY_ID_VERSION(POLICY)                                 \
   CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID_VERSION)
 
 #define CM_SELECT_ID_DOC(F, A1, A2, A3, A4, A5, A6) F(A1, A2)
-#define CM_FOR_EACH_POLICY_ID_DOC(POLICY) \
+#define CM_FOR_EACH_POLICY_ID_DOC(POLICY)                                     \
   CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID_DOC)
 
 static const char* idToString(cmPolicies::PolicyID id)
 {
-  switch(id)
-    {
-#define POLICY_CASE(ID) \
-    case cmPolicies::ID: \
-      return #ID;
-  CM_FOR_EACH_POLICY_ID(POLICY_CASE)
+  switch (id) {
+#define POLICY_CASE(ID)                                                       \
+  case cmPolicies::ID:                                                        \
+    return #ID;
+    CM_FOR_EACH_POLICY_ID(POLICY_CASE)
 #undef POLICY_CASE
     case cmPolicies::CMPCOUNT:
       return 0;
-    }
+  }
   return 0;
 }
 
 static const char* idToVersion(cmPolicies::PolicyID id)
 {
-  switch(id)
-    {
-#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
-    case cmPolicies::ID: \
-      return #V_MAJOR "." #V_MINOR "." #V_PATCH;
-  CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
+  switch (id) {
+#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH)                            \
+  case cmPolicies::ID:                                                        \
+    return #V_MAJOR "." #V_MINOR "." #V_PATCH;
+    CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
 #undef POLICY_CASE
     case cmPolicies::CMPCOUNT:
       return 0;
-    }
+  }
   return 0;
 }
 
-static bool isPolicyNewerThan(cmPolicies::PolicyID id,
-                       unsigned int majorV,
-                       unsigned int minorV,
-                       unsigned int patchV)
+static bool isPolicyNewerThan(cmPolicies::PolicyID id, unsigned int majorV,
+                              unsigned int minorV, unsigned int patchV)
 {
-  switch(id)
-    {
-#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
-    case cmPolicies::ID: \
-      return (majorV < V_MAJOR || \
-             (majorV == V_MAJOR && \
-              minorV + 1 < V_MINOR + 1) || \
-             (majorV == V_MAJOR && \
-              minorV == V_MINOR && \
-              patchV + 1 < V_PATCH + 1));
-  CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
+  switch (id) {
+#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH)                            \
+  case cmPolicies::ID:                                                        \
+    return (                                                                  \
+      majorV < V_MAJOR || (majorV == V_MAJOR && minorV + 1 < V_MINOR + 1) ||  \
+      (majorV == V_MAJOR && minorV == V_MINOR && patchV + 1 < V_PATCH + 1));
+    CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
 #undef POLICY_CASE
     case cmPolicies::CMPCOUNT:
       return false;
-    }
+  }
   return false;
 }
 
 const char* idToShortDescription(cmPolicies::PolicyID id)
 {
-  switch(id)
-    {
-#define POLICY_CASE(ID, SHORT_DESCRIPTION) \
-    case cmPolicies::ID: \
-      return SHORT_DESCRIPTION;
-  CM_FOR_EACH_POLICY_ID_DOC(POLICY_CASE)
+  switch (id) {
+#define POLICY_CASE(ID, SHORT_DESCRIPTION)                                    \
+  case cmPolicies::ID:                                                        \
+    return SHORT_DESCRIPTION;
+    CM_FOR_EACH_POLICY_ID_DOC(POLICY_CASE)
 #undef POLICY_CASE
     case cmPolicies::CMPCOUNT:
       return 0;
-    }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
 static void DiagnoseAncientPolicies(
-    std::vector<cmPolicies::PolicyID> const& ancient,
-    unsigned int majorVer,
-    unsigned int minorVer,
-    unsigned int patchVer,
-    cmMakefile* mf)
+  std::vector<cmPolicies::PolicyID> const& ancient, unsigned int majorVer,
+  unsigned int minorVer, unsigned int patchVer, cmMakefile* mf)
 {
   std::ostringstream e;
   e << "The project requests behavior compatible with CMake version \""
     << majorVer << "." << minorVer << "." << patchVer
     << "\", which requires the OLD behavior for some policies:\n";
-  for(std::vector<cmPolicies::PolicyID>::const_iterator
-        i = ancient.begin(); i != ancient.end(); ++i)
-    {
+  for (std::vector<cmPolicies::PolicyID>::const_iterator i = ancient.begin();
+       i != ancient.end(); ++i) {
     e << "  " << idToString(*i) << ": " << idToShortDescription(*i) << "\n";
-    }
+  }
   e << "However, this version of CMake no longer supports the OLD "
     << "behavior for these policies.  "
     << "Please either update your CMakeLists.txt files to conform to "
@@ -146,46 +127,35 @@ static void DiagnoseAncientPolicies(
   mf->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
 static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
                              cmPolicies::PolicyStatus* defaultSetting)
 {
   std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
   std::string defaultValue = mf->GetSafeDefinition(defaultVar);
-  if(defaultValue == "NEW")
-    {
+  if (defaultValue == "NEW") {
     *defaultSetting = cmPolicies::NEW;
-    }
-  else if(defaultValue == "OLD")
-    {
+  } else if (defaultValue == "OLD") {
     *defaultSetting = cmPolicies::OLD;
-    }
-  else if(defaultValue == "")
-    {
+  } else if (defaultValue == "") {
     *defaultSetting = cmPolicies::WARN;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << defaultVar << " has value \"" << defaultValue
       << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
-                                    const char *version)
+bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, const char* version)
 {
   std::string ver = "2.4.0";
 
-  if (version && strlen(version) > 0)
-    {
+  if (version && strlen(version) > 0) {
     ver = version;
-    }
+  }
 
   unsigned int majorVer = 2;
   unsigned int minorVer = 0;
@@ -193,25 +163,24 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
   unsigned int tweakVer = 0;
 
   // parse the string
-  if(sscanf(ver.c_str(), "%u.%u.%u.%u",
-            &majorVer, &minorVer, &patchVer, &tweakVer) < 2)
-    {
+  if (sscanf(ver.c_str(), "%u.%u.%u.%u", &majorVer, &minorVer, &patchVer,
+             &tweakVer) < 2) {
     std::ostringstream e;
     e << "Invalid policy version value \"" << ver << "\".  "
       << "A numeric major.minor[.patch[.tweak]] must be given.";
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
 
   // it is an error if the policy version is less than 2.4
-  if (majorVer < 2 || (majorVer == 2 && minorVer < 4))
-    {
-    mf->IssueMessage(cmake::FATAL_ERROR,
+  if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) {
+    mf->IssueMessage(
+      cmake::FATAL_ERROR,
       "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.  "
       "For compatibility with older versions please use any CMake 2.8.x "
       "release or lower.");
     return false;
-    }
+  }
 
   // It is an error if the policy version is greater than the running
   // CMake.
@@ -224,8 +193,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
       (majorVer == cmVersion::GetMajorVersion() &&
        minorVer == cmVersion::GetMinorVersion() &&
        patchVer == cmVersion::GetPatchVersion() &&
-       tweakVer > cmVersion::GetTweakVersion()))
-    {
+       tweakVer > cmVersion::GetTweakVersion())) {
     std::ostringstream e;
     e << "An attempt was made to set the policy version of CMake to \""
       << version << "\" which is greater than this version of CMake.  "
@@ -234,67 +202,54 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
       << "You may need a newer CMake version to build this project.";
     mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
-    }
+  }
 
   // now loop over all the policies and set them as appropriate
   std::vector<cmPolicies::PolicyID> ancientPolicies;
-  for(PolicyID pid = cmPolicies::CMP0000;
-      pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid+1))
-    {
-    if (isPolicyNewerThan(pid, majorVer, minorVer, patchVer))
-      {
-      if(cmPolicies::GetPolicyStatus(pid) == cmPolicies::REQUIRED_ALWAYS)
-        {
+  for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
+       pid = PolicyID(pid + 1)) {
+    if (isPolicyNewerThan(pid, majorVer, minorVer, patchVer)) {
+      if (cmPolicies::GetPolicyStatus(pid) == cmPolicies::REQUIRED_ALWAYS) {
         ancientPolicies.push_back(pid);
-        }
-      else
-        {
+      } else {
         cmPolicies::PolicyStatus status = cmPolicies::WARN;
-        if(!GetPolicyDefault(mf, idToString(pid), &status) ||
-           !mf->SetPolicy(pid, status))
-          {
+        if (!GetPolicyDefault(mf, idToString(pid), &status) ||
+            !mf->SetPolicy(pid, status)) {
           return false;
-          }
-        if(pid == cmPolicies::CMP0001 &&
-           (status == cmPolicies::WARN || status == cmPolicies::OLD))
-          {
-          if(!(mf->GetState()
-               ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
-            {
+        }
+        if (pid == cmPolicies::CMP0001 &&
+            (status == cmPolicies::WARN || status == cmPolicies::OLD)) {
+          if (!(mf->GetState()->GetInitializedCacheValue(
+                "CMAKE_BACKWARDS_COMPATIBILITY"))) {
             // Set it to 2.4 because that is the last version where the
             // variable had meaning.
-            mf->AddCacheDefinition
-              ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
-               "For backwards compatibility, what version of CMake "
-               "commands and "
-               "syntax should this version of CMake try to support.",
-               cmState::STRING);
-            }
+            mf->AddCacheDefinition(
+              "CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
+              "For backwards compatibility, what version of CMake "
+              "commands and "
+              "syntax should this version of CMake try to support.",
+              cmState::STRING);
           }
         }
       }
-    else
-      {
-      if (!mf->SetPolicy(pid, cmPolicies::NEW))
-        {
+    } else {
+      if (!mf->SetPolicy(pid, cmPolicies::NEW)) {
         return false;
-        }
       }
     }
+  }
 
   // Make sure the project does not use any ancient policies.
-  if(!ancientPolicies.empty())
-    {
-    DiagnoseAncientPolicies(ancientPolicies,
-                            majorVer, minorVer, patchVer, mf);
+  if (!ancientPolicies.empty()) {
+    DiagnoseAncientPolicies(ancientPolicies, majorVer, minorVer, patchVer, mf);
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
 
   return true;
 }
 
-bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
+bool cmPolicies::GetPolicyID(const char* id, cmPolicies::PolicyID& pid)
 {
   return stringToId(id, pid);
 }
@@ -303,46 +258,47 @@ bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
 std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
 {
   std::ostringstream msg;
-  msg <<
-    "Policy " << idToString(id) << " is not set: "
-    "" << idToShortDescription(id) << "  "
-    "Run \"cmake --help-policy " << idToString(id) << "\" for "
-    "policy details.  "
-    "Use the cmake_policy command to set the policy "
-    "and suppress this warning.";
+  msg << "Policy " << idToString(id) << " is not set: "
+                                        ""
+      << idToShortDescription(id) << "  "
+                                     "Run \"cmake --help-policy "
+      << idToString(id) << "\" for "
+                           "policy details.  "
+                           "Use the cmake_policy command to set the policy "
+                           "and suppress this warning.";
   return msg.str();
 }
 
-
 ///! return an error string for when a required policy is unspecified
 std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
 {
   std::ostringstream error;
-  error <<
-    "Policy " << idToString(id) << " is not set to NEW: "
-    "" << idToShortDescription(id) << "  "
-    "Run \"cmake --help-policy " << idToString(id) << "\" for "
-    "policy details.  "
-    "CMake now requires this policy to be set to NEW by the project.  "
-    "The policy may be set explicitly using the code\n"
-    "  cmake_policy(SET " << idToString(id) << " NEW)\n"
-    "or by upgrading all policies with the code\n"
-    "  cmake_policy(VERSION " << idToVersion(id) <<
-    ") # or later\n"
-    "Run \"cmake --help-command cmake_policy\" for more information.";
+  error << "Policy " << idToString(id) << " is not set to NEW: "
+                                          ""
+        << idToShortDescription(id) << "  "
+                                       "Run \"cmake --help-policy "
+        << idToString(id)
+        << "\" for "
+           "policy details.  "
+           "CMake now requires this policy to be set to NEW by the project.  "
+           "The policy may be set explicitly using the code\n"
+           "  cmake_policy(SET "
+        << idToString(id) << " NEW)\n"
+                             "or by upgrading all policies with the code\n"
+                             "  cmake_policy(VERSION "
+        << idToVersion(id)
+        << ") # or later\n"
+           "Run \"cmake --help-command cmake_policy\" for more information.";
   return error.str();
 }
 
 ///! Get the default status for a policy
-cmPolicies::PolicyStatus
-cmPolicies::GetPolicyStatus(cmPolicies::PolicyID)
+cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus(cmPolicies::PolicyID)
 {
   return cmPolicies::WARN;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
+std::string cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
 {
   std::string pid = idToString(id);
   std::ostringstream e;
@@ -359,19 +315,16 @@ cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
   return e.str();
 }
 
-cmPolicies::PolicyStatus
-cmPolicies::PolicyMap::Get(cmPolicies::PolicyID id) const
+cmPolicies::PolicyStatus cmPolicies::PolicyMap::Get(
+  cmPolicies::PolicyID id) const
 {
   PolicyStatus status = cmPolicies::WARN;
 
-  if (this->Status[(POLICY_STATUS_COUNT * id) + OLD])
-    {
+  if (this->Status[(POLICY_STATUS_COUNT * id) + OLD]) {
     status = cmPolicies::OLD;
-    }
-  else if (this->Status[(POLICY_STATUS_COUNT * id) + NEW])
-    {
+  } else if (this->Status[(POLICY_STATUS_COUNT * id) + NEW]) {
     status = cmPolicies::NEW;
-    }
+  }
   return status;
 }
 
@@ -385,9 +338,9 @@ void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id,
 
 bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const
 {
-  return this->Status[(POLICY_STATUS_COUNT * id) + OLD]
-      || this->Status[(POLICY_STATUS_COUNT * id) + WARN]
-      || this->Status[(POLICY_STATUS_COUNT * id) + NEW];
+  return this->Status[(POLICY_STATUS_COUNT * id) + OLD] ||
+    this->Status[(POLICY_STATUS_COUNT * id) + WARN] ||
+    this->Status[(POLICY_STATUS_COUNT * id) + NEW];
 }
 
 bool cmPolicies::PolicyMap::IsEmpty() const
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 5023055..ff49e31 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -19,235 +19,213 @@
 class cmMakefile;
 class cmPolicy;
 
-#define CM_FOR_EACH_POLICY_TABLE(POLICY, SELECT) \
-  SELECT(POLICY, CMP0000, \
-    "A minimum required CMake version must be specified.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0001, \
-    "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0002, \
-  "Logical target names must be globally unique.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0003, \
-    "Libraries linked via full path no longer produce linker search paths.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0004, \
-    "Libraries linked may not have leading or trailing whitespace.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0005, \
-    "Preprocessor definition values are now escaped automatically.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0006, \
-    "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0007, \
-    "list command no longer ignores empty elements.", \
-    2, 6, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0008, \
-    "Libraries linked by full-path must have a valid library file name.", \
-    2, 6, 1, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0009, \
-    "FILE GLOB_RECURSE calls should not follow symlinks by default.", \
-    2, 6, 2, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0010, \
-    "Bad variable reference syntax is an error.", \
-    2, 6, 3, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0011, \
-    "Included scripts do automatic cmake_policy PUSH and POP.", \
-    2, 6, 3, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0012, \
-    "if() recognizes numbers and boolean constants.", \
-    2, 8, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0013, \
-    "Duplicate binary directories are not allowed.", \
-    2, 8, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0014, \
-    "Input directories must have CMakeLists.txt.", \
-    2, 8, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0015, \
-    "link_directories() treats paths relative to the source dir.", \
-    2, 8, 1, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0016, \
-    "target_link_libraries() reports error if its only argument " \
-    "is not a target.", \
-    2, 8, 3, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0017, \
-    "Prefer files from the CMake module directory when including from " \
-    "there.", \
-    2, 8, 4, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0018, \
-    "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", \
-    2, 8, 9, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0019, \
-    "Do not re-expand variables in include and link information.", \
-    2, 8, 11, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0020, \
-    "Automatically link Qt executables to qtmain target on Windows.", \
-    2, 8, 11, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0021, \
-    "Fatal error on relative paths in INCLUDE_DIRECTORIES target property.", \
-    2, 8, 12, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0022, \
-    "INTERFACE_LINK_LIBRARIES defines the link interface.", \
-    2, 8, 12, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0023, \
-    "Plain and keyword target_link_libraries signatures cannot be mixed.", \
-    2, 8, 12, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0024, \
-    "Disallow include export result.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0025, \
-    "Compiler id for Apple Clang is now AppleClang.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0026, \
-    "Disallow use of the LOCATION target property.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0027, \
-    "Conditionally linked imported targets with missing include " \
-    "directories.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0028, \
-    "Double colon in target name means ALIAS or IMPORTED target.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0029, \
-    "The subdir_depends command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0030, \
-    "The use_mangled_mesa command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0031, \
-    "The load_command command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0032, \
-    "The output_required_files command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0033, \
-    "The export_library_dependencies command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0034, \
-    "The utility_source command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0035, \
-    "The variable_requires command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0036, \
-    "The build_name command should not be called.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0037, \
-    "Target names should not be reserved and should match a validity " \
-    "pattern.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0038, \
-    "Targets may not link directly to themselves.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0039, \
-    "Utility targets may not have link dependencies.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0040, \
-    "The target in the TARGET signature of add_custom_command() must " \
-    "exist.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0041, \
-    "Error on relative include with generator expression.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0042, \
-    "MACOSX_RPATH is enabled by default.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0043, \
-    "Ignore COMPILE_DEFINITIONS_<Config> properties.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0044, \
-    "Case sensitive <LANG>_COMPILER_ID generator expressions.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0045, \
-    "Error on non-existent target in get_target_property.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0046, \
-    "Error on non-existent dependency in add_dependencies.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0047, \
-    "Use QCC compiler id for the qcc drivers on QNX.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0048, \
-    "project() command manages VERSION variables.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0049, \
-    "Do not expand variables in target source entries.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0050, \
-    "Disallow add_custom_command SOURCE signatures.", \
-    3, 0, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0051, \
-    "List TARGET_OBJECTS in SOURCES target property.", \
-    3, 1, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0052, \
-    "Reject source and build dirs in installed " \
-    "INTERFACE_INCLUDE_DIRECTORIES.", \
-    3, 1, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0053, \
-    "Simplify variable reference and escape sequence evaluation.", \
-    3, 1, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0054, \
-    "Only interpret if() arguments as variables or keywords when unquoted.", \
-    3, 1, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0055, \
-    "Strict checking for break() command.", \
-    3, 2, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0056, \
-    "Honor link flags in try_compile() source-file signature.", \
-    3, 2, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0057, \
-    "Support new IN_LIST if() operator.", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0058, \
-    "Ninja requires custom command byproducts to be explicit.", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0059, \
-    "Do no treat DEFINITIONS as a built-in directory property.", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0060, \
-    "Link libraries by full path even in implicit directories.", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0061, \
-    "CTest does not by default tell make to ignore errors (-i).", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0062, \
-    "Disallow install() of export() result.", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0063, \
-    "Honor visibility properties for all target types.", \
-    3, 3, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0064, \
-    "Support new TEST if() operator.", \
-    3, 4, 0, cmPolicies::WARN) \
-  SELECT(POLICY, CMP0065, \
-    "Do not add flags to export symbols from executables without " \
-    "the ENABLE_EXPORTS target property.", \
-    3, 4, 0, cmPolicies::WARN)
+#define CM_FOR_EACH_POLICY_TABLE(POLICY, SELECT)                              \
+  SELECT(POLICY, CMP0000,                                                     \
+         "A minimum required CMake version must be specified.", 2, 6, 0,      \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0001,                                                     \
+         "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", 2, 6, 0,  \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0002, "Logical target names must be globally unique.", 2, \
+         6, 0, cmPolicies::WARN)                                              \
+  SELECT(                                                                     \
+    POLICY, CMP0003,                                                          \
+    "Libraries linked via full path no longer produce linker search paths.",  \
+    2, 6, 0, cmPolicies::WARN)                                                \
+  SELECT(POLICY, CMP0004,                                                     \
+         "Libraries linked may not have leading or trailing whitespace.", 2,  \
+         6, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0005,                                                     \
+         "Preprocessor definition values are now escaped automatically.", 2,  \
+         6, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0006,                                                     \
+         "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",   \
+         2, 6, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0007, "list command no longer ignores empty elements.",   \
+         2, 6, 0, cmPolicies::WARN)                                           \
+  SELECT(                                                                     \
+    POLICY, CMP0008,                                                          \
+    "Libraries linked by full-path must have a valid library file name.", 2,  \
+    6, 1, cmPolicies::WARN)                                                   \
+  SELECT(POLICY, CMP0009,                                                     \
+         "FILE GLOB_RECURSE calls should not follow symlinks by default.", 2, \
+         6, 2, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0010, "Bad variable reference syntax is an error.", 2, 6, \
+         3, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0011,                                                     \
+         "Included scripts do automatic cmake_policy PUSH and POP.", 2, 6, 3, \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0012, "if() recognizes numbers and boolean constants.",   \
+         2, 8, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0013, "Duplicate binary directories are not allowed.", 2, \
+         8, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0014, "Input directories must have CMakeLists.txt.", 2,   \
+         8, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0015,                                                     \
+         "link_directories() treats paths relative to the source dir.", 2, 8, \
+         1, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0016,                                                     \
+         "target_link_libraries() reports error if its only argument "        \
+         "is not a target.",                                                  \
+         2, 8, 3, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0017,                                                     \
+         "Prefer files from the CMake module directory when including from "  \
+         "there.",                                                            \
+         2, 8, 4, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0018,                                                     \
+         "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", 2, 8, 9,       \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0019,                                                     \
+         "Do not re-expand variables in include and link information.", 2, 8, \
+         11, cmPolicies::WARN)                                                \
+  SELECT(POLICY, CMP0020,                                                     \
+         "Automatically link Qt executables to qtmain target on Windows.", 2, \
+         8, 11, cmPolicies::WARN)                                             \
+  SELECT(                                                                     \
+    POLICY, CMP0021,                                                          \
+    "Fatal error on relative paths in INCLUDE_DIRECTORIES target property.",  \
+    2, 8, 12, cmPolicies::WARN)                                               \
+  SELECT(POLICY, CMP0022,                                                     \
+         "INTERFACE_LINK_LIBRARIES defines the link interface.", 2, 8, 12,    \
+         cmPolicies::WARN)                                                    \
+  SELECT(                                                                     \
+    POLICY, CMP0023,                                                          \
+    "Plain and keyword target_link_libraries signatures cannot be mixed.", 2, \
+    8, 12, cmPolicies::WARN)                                                  \
+  SELECT(POLICY, CMP0024, "Disallow include export result.", 3, 0, 0,         \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.",   \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0026, "Disallow use of the LOCATION target property.", 3, \
+         0, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0027,                                                     \
+         "Conditionally linked imported targets with missing include "        \
+         "directories.",                                                      \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0028,                                                     \
+         "Double colon in target name means ALIAS or IMPORTED target.", 3, 0, \
+         0, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0029, "The subdir_depends command should not be called.", \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0030,                                                     \
+         "The use_mangled_mesa command should not be called.", 3, 0, 0,       \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0031, "The load_command command should not be called.",   \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0032,                                                     \
+         "The output_required_files command should not be called.", 3, 0, 0,  \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0033,                                                     \
+         "The export_library_dependencies command should not be called.", 3,  \
+         0, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0034, "The utility_source command should not be called.", \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0035,                                                     \
+         "The variable_requires command should not be called.", 3, 0, 0,      \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0036, "The build_name command should not be called.", 3,  \
+         0, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0037,                                                     \
+         "Target names should not be reserved and should match a validity "   \
+         "pattern.",                                                          \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3,  \
+         0, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.",  \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0040,                                                     \
+         "The target in the TARGET signature of add_custom_command() must "   \
+         "exist.",                                                            \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0041,                                                     \
+         "Error on relative include with generator expression.", 3, 0, 0,     \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0042, "MACOSX_RPATH is enabled by default.", 3, 0, 0,     \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0043, "Ignore COMPILE_DEFINITIONS_<Config> properties.",  \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0044,                                                     \
+         "Case sensitive <LANG>_COMPILER_ID generator expressions.", 3, 0, 0, \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0045,                                                     \
+         "Error on non-existent target in get_target_property.", 3, 0, 0,     \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0046,                                                     \
+         "Error on non-existent dependency in add_dependencies.", 3, 0, 0,    \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0047, "Use QCC compiler id for the qcc drivers on QNX.",  \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3,  \
+         0, 0, cmPolicies::WARN)                                              \
+  SELECT(POLICY, CMP0049,                                                     \
+         "Do not expand variables in target source entries.", 3, 0, 0,        \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.",   \
+         3, 0, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.",  \
+         3, 1, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0052, "Reject source and build dirs in installed "        \
+                          "INTERFACE_INCLUDE_DIRECTORIES.",                   \
+         3, 1, 0, cmPolicies::WARN)                                           \
+  SELECT(POLICY, CMP0053,                                                     \
+         "Simplify variable reference and escape sequence evaluation.", 3, 1, \
+         0, cmPolicies::WARN)                                                 \
+  SELECT(                                                                     \
+    POLICY, CMP0054,                                                          \
+    "Only interpret if() arguments as variables or keywords when unquoted.",  \
+    3, 1, 0, cmPolicies::WARN)                                                \
+  SELECT(POLICY, CMP0055, "Strict checking for break() command.", 3, 2, 0,    \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0056,                                                     \
+         "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0,      \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0058,                                                     \
+         "Ninja requires custom command byproducts to be explicit.", 3, 3, 0, \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0059,                                                     \
+         "Do not treat DEFINITIONS as a built-in directory property.", 3, 3,  \
+         0, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0060,                                                     \
+         "Link libraries by full path even in implicit directories.", 3, 3,   \
+         0, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0061,                                                     \
+         "CTest does not by default tell make to ignore errors (-i).", 3, 3,  \
+         0, cmPolicies::WARN)                                                 \
+  SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0,  \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0063,                                                     \
+         "Honor visibility properties for all target types.", 3, 3, 0,        \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0,         \
+         cmPolicies::WARN)                                                    \
+  SELECT(POLICY, CMP0065,                                                     \
+         "Do not add flags to export symbols from executables without "       \
+         "the ENABLE_EXPORTS target property.",                               \
+         3, 4, 0, cmPolicies::WARN)
 
 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
-#define CM_FOR_EACH_POLICY_ID(POLICY) \
+#define CM_FOR_EACH_POLICY_ID(POLICY)                                         \
   CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID)
 
-#define CM_FOR_EACH_TARGET_POLICY(F) \
-  F(CMP0003) \
-  F(CMP0004) \
-  F(CMP0008) \
-  F(CMP0020) \
-  F(CMP0021) \
-  F(CMP0022) \
-  F(CMP0027) \
-  F(CMP0038) \
-  F(CMP0041) \
-  F(CMP0042) \
-  F(CMP0046) \
-  F(CMP0052) \
-  F(CMP0060) \
-  F(CMP0063) \
+#define CM_FOR_EACH_TARGET_POLICY(F)                                          \
+  F(CMP0003)                                                                  \
+  F(CMP0004)                                                                  \
+  F(CMP0008)                                                                  \
+  F(CMP0020)                                                                  \
+  F(CMP0021)                                                                  \
+  F(CMP0022)                                                                  \
+  F(CMP0027)                                                                  \
+  F(CMP0038)                                                                  \
+  F(CMP0041)                                                                  \
+  F(CMP0042)                                                                  \
+  F(CMP0046)                                                                  \
+  F(CMP0052)                                                                  \
+  F(CMP0060)                                                                  \
+  F(CMP0063)                                                                  \
   F(CMP0065)
 
-
 /** \class cmPolicies
  * \brief Handles changes in CMake behavior and policies
  *
@@ -259,10 +237,11 @@ class cmPolicies
 {
 public:
   /// Status of a policy
-  enum PolicyStatus {
-    OLD, ///< Use old behavior
+  enum PolicyStatus
+  {
+    OLD,  ///< Use old behavior
     WARN, ///< Use old behavior but issue a warning
-    NEW, ///< Use new behavior
+    NEW,  ///< Use new behavior
     /// Issue an error if user doesn't set policy status to NEW and hits the
     /// check
     REQUIRED_IF_USED,
@@ -285,13 +264,13 @@ public:
   };
 
   ///! convert a string policy ID into a number
-  static bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid);
+  static bool GetPolicyID(const char* id, /* out */ cmPolicies::PolicyID& pid);
 
   ///! Get the default status for a policy
   static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
 
   ///! Set a policy level for this listfile
-  static bool ApplyPolicyVersion(cmMakefile *mf, const char *version);
+  static bool ApplyPolicyVersion(cmMakefile* mf, const char* version);
 
   ///! return a warning string for a given policy
   static std::string GetPolicyWarning(cmPolicies::PolicyID id);
diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx
index 15d9ed0..446752e 100644
--- a/Source/cmProcessTools.cxx
+++ b/Source/cmProcessTools.cxx
@@ -13,78 +13,66 @@
 
 #include <cmsys/Process.h>
 
-//----------------------------------------------------------------------------
-void cmProcessTools::RunProcess(struct cmsysProcess_s* cp,
-                                OutputParser* out, OutputParser* err)
+void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
+                                OutputParser* err)
 {
   cmsysProcess_Execute(cp);
   char* data = 0;
   int length = 0;
   int p;
-  while((out||err) && (p=cmsysProcess_WaitForData(cp, &data, &length, 0), p))
-    {
-    if(out && p == cmsysProcess_Pipe_STDOUT)
-      {
-      if(!out->Process(data, length))
-        {
+  while ((out || err) &&
+         (p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) {
+    if (out && p == cmsysProcess_Pipe_STDOUT) {
+      if (!out->Process(data, length)) {
         out = 0;
-        }
       }
-    else if(err && p == cmsysProcess_Pipe_STDERR)
-      {
-      if(!err->Process(data, length))
-        {
+    } else if (err && p == cmsysProcess_Pipe_STDERR) {
+      if (!err->Process(data, length)) {
         err = 0;
-        }
       }
     }
+  }
   cmsysProcess_WaitForExit(cp, 0);
 }
 
-
-//----------------------------------------------------------------------------
-cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR):
-   Log(0), Prefix(0), Separator(sep), LineEnd('\0'), IgnoreCR(ignoreCR)
+cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR)
+  : Log(0)
+  , Prefix(0)
+  , Separator(sep)
+  , LineEnd('\0')
+  , IgnoreCR(ignoreCR)
 {
 }
 
-//----------------------------------------------------------------------------
 void cmProcessTools::LineParser::SetLog(std::ostream* log, const char* prefix)
 {
   this->Log = log;
-  this->Prefix = prefix? prefix : "";
+  this->Prefix = prefix ? prefix : "";
 }
 
-//----------------------------------------------------------------------------
 bool cmProcessTools::LineParser::ProcessChunk(const char* first, int length)
 {
   const char* last = first + length;
-  for(const char* c = first; c != last; ++c)
-    {
-    if(*c == this->Separator || *c == '\0')
-      {
+  for (const char* c = first; c != last; ++c) {
+    if (*c == this->Separator || *c == '\0') {
       this->LineEnd = *c;
 
       // Log this line.
-      if(this->Log && this->Prefix)
-        {
+      if (this->Log && this->Prefix) {
         *this->Log << this->Prefix << this->Line << "\n";
-        }
+      }
 
       // Hand this line to the subclass implementation.
-      if(!this->ProcessLine())
-        {
+      if (!this->ProcessLine()) {
         this->Line = "";
         return false;
-        }
+      }
 
       this->Line = "";
-      }
-    else if(*c != '\r' || !this->IgnoreCR)
-      {
+    } else if (*c != '\r' || !this->IgnoreCR) {
       // Append this character to the line under construction.
       this->Line.append(1, *c);
-      }
     }
+  }
   return true;
 }
diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h
index 23833ca..a48e52b 100644
--- a/Source/cmProcessTools.h
+++ b/Source/cmProcessTools.h
@@ -29,9 +29,13 @@ public:
         done incrementally.  Returns true if the parser is interested
         in any more data and false if it is done.  */
     bool Process(const char* data, int length)
-      { return this->ProcessChunk(data, length); }
+    {
+      return this->ProcessChunk(data, length);
+    }
     bool Process(const char* data)
-      { return this->Process(data, static_cast<int>(strlen(data))); }
+    {
+      return this->Process(data, static_cast<int>(strlen(data)));
+    }
 
     virtual ~OutputParser() {}
   protected:
@@ -41,7 +45,7 @@ public:
   };
 
   /** Process output parser that extracts one line at a time.  */
-  class LineParser: public OutputParser
+  class LineParser : public OutputParser
   {
   public:
     /** Construct with line separation character and choose whether to
@@ -50,6 +54,7 @@ public:
 
     /** Configure logging of lines as they are extracted.  */
     void SetLog(std::ostream* log, const char* prefix);
+
   protected:
     std::ostream* Log;
     const char* Prefix;
@@ -65,18 +70,21 @@ public:
   };
 
   /** Trivial line handler for simple logging.  */
-  class OutputLogger: public LineParser
+  class OutputLogger : public LineParser
   {
   public:
     OutputLogger(std::ostream& log, const char* prefix = 0)
-      { this->SetLog(&log, prefix); }
+    {
+      this->SetLog(&log, prefix);
+    }
+
   private:
     virtual bool ProcessLine() { return true; }
   };
 
   /** Run a process and send output to given parsers.  */
-  static void RunProcess(struct cmsysProcess_s* cp,
-                         OutputParser* out, OutputParser* err = 0);
+  static void RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
+                         OutputParser* err = 0);
 };
 
 #endif
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 7123125..139303b 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -12,14 +12,13 @@
 #include "cmProjectCommand.h"
 
 // cmProjectCommand
-bool cmProjectCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
+                                   cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("PROJECT called with incorrect number of arguments");
     return false;
-    }
+  }
   this->Makefile->SetProjectName(args[0]);
 
   std::string bindir = args[0];
@@ -27,22 +26,20 @@ bool cmProjectCommand
   std::string srcdir = args[0];
   srcdir += "_SOURCE_DIR";
 
-  this->Makefile->AddCacheDefinition
-    (bindir,
-     this->Makefile->GetCurrentBinaryDirectory(),
-     "Value Computed by CMake", cmState::STATIC);
-  this->Makefile->AddCacheDefinition
-    (srcdir,
-     this->Makefile->GetCurrentSourceDirectory(),
-     "Value Computed by CMake", cmState::STATIC);
+  this->Makefile->AddCacheDefinition(
+    bindir, this->Makefile->GetCurrentBinaryDirectory(),
+    "Value Computed by CMake", cmState::STATIC);
+  this->Makefile->AddCacheDefinition(
+    srcdir, this->Makefile->GetCurrentSourceDirectory(),
+    "Value Computed by CMake", cmState::STATIC);
 
   bindir = "PROJECT_BINARY_DIR";
   srcdir = "PROJECT_SOURCE_DIR";
 
   this->Makefile->AddDefinition(bindir,
-          this->Makefile->GetCurrentBinaryDirectory());
+                                this->Makefile->GetCurrentBinaryDirectory());
   this->Makefile->AddDefinition(srcdir,
-          this->Makefile->GetCurrentSourceDirectory());
+                                this->Makefile->GetCurrentSourceDirectory());
 
   this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
 
@@ -52,117 +49,100 @@ bool cmProjectCommand
   // CMakeLists.txt file, then go with the last one, so that
   // CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
   // will work.
-  if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")
-     || (this->Makefile->IsRootMakefile()))
-    {
+  if (!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") ||
+      (this->Makefile->IsRootMakefile())) {
     this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
-    this->Makefile->AddCacheDefinition
-      ("CMAKE_PROJECT_NAME",
-       args[0].c_str(),
-       "Value Computed by CMake", cmState::STATIC);
-    }
+    this->Makefile->AddCacheDefinition("CMAKE_PROJECT_NAME", args[0].c_str(),
+                                       "Value Computed by CMake",
+                                       cmState::STATIC);
+  }
 
   bool haveVersion = false;
   bool haveLanguages = false;
   std::string version;
   std::vector<std::string> languages;
-  enum Doing { DoingLanguages, DoingVersion };
+  enum Doing
+  {
+    DoingLanguages,
+    DoingVersion
+  };
   Doing doing = DoingLanguages;
-  for(size_t i = 1; i < args.size(); ++i)
-    {
-    if(args[i] == "LANGUAGES")
-      {
-      if(haveLanguages)
-        {
-        this->Makefile->IssueMessage
-          (cmake::FATAL_ERROR, "LANGUAGES may be specified at most once.");
+  for (size_t i = 1; i < args.size(); ++i) {
+    if (args[i] == "LANGUAGES") {
+      if (haveLanguages) {
+        this->Makefile->IssueMessage(
+          cmake::FATAL_ERROR, "LANGUAGES may be specified at most once.");
         cmSystemTools::SetFatalErrorOccured();
         return true;
-        }
+      }
       haveLanguages = true;
       doing = DoingLanguages;
-      }
-    else if (args[i] == "VERSION")
-      {
-      if(haveVersion)
-        {
-        this->Makefile->IssueMessage
-          (cmake::FATAL_ERROR, "VERSION may be specified at most once.");
+    } else if (args[i] == "VERSION") {
+      if (haveVersion) {
+        this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+                                     "VERSION may be specified at most once.");
         cmSystemTools::SetFatalErrorOccured();
         return true;
-        }
+      }
       haveVersion = true;
       doing = DoingVersion;
-      }
-    else if(doing == DoingVersion)
-      {
+    } else if (doing == DoingVersion) {
       doing = DoingLanguages;
       version = args[i];
-      }
-    else // doing == DoingLanguages
-      {
+    } else // doing == DoingLanguages
+    {
       languages.push_back(args[i]);
-      }
     }
+  }
 
-  if (haveVersion && !haveLanguages && !languages.empty())
-    {
-    this->Makefile->IssueMessage
-      (cmake::FATAL_ERROR,
-       "project with VERSION must use LANGUAGES before language names.");
+  if (haveVersion && !haveLanguages && !languages.empty()) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
+      "project with VERSION must use LANGUAGES before language names.");
     cmSystemTools::SetFatalErrorOccured();
     return true;
-    }
-  if (haveLanguages && languages.empty())
-    {
+  }
+  if (haveLanguages && languages.empty()) {
     languages.push_back("NONE");
-    }
+  }
 
   cmPolicies::PolicyStatus cmp0048 =
     this->Makefile->GetPolicyStatus(cmPolicies::CMP0048);
-  if (haveVersion)
-    {
+  if (haveVersion) {
     // Set project VERSION variables to given values
-    if (cmp0048 == cmPolicies::OLD ||
-        cmp0048 == cmPolicies::WARN)
-      {
-      this->Makefile->IssueMessage
-        (cmake::FATAL_ERROR,
-         "VERSION not allowed unless CMP0048 is set to NEW");
+    if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) {
+      this->Makefile->IssueMessage(
+        cmake::FATAL_ERROR,
+        "VERSION not allowed unless CMP0048 is set to NEW");
       cmSystemTools::SetFatalErrorOccured();
       return true;
-      }
+    }
 
-    cmsys::RegularExpression
-      vx("^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$");
-    if(!vx.find(version))
-      {
+    cmsys::RegularExpression vx(
+      "^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$");
+    if (!vx.find(version)) {
       std::string e = "VERSION \"" + version + "\" format invalid.";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
       cmSystemTools::SetFatalErrorOccured();
       return true;
-      }
+    }
 
     std::string vs;
     const char* sep = "";
     char vb[4][64];
-    unsigned int v[4] = {0,0,0,0};
-    int vc = sscanf(version.c_str(), "%u.%u.%u.%u",
-                    &v[0], &v[1], &v[2], &v[3]);
-    for(int i=0; i < 4; ++i)
-      {
-      if(i < vc)
-        {
+    unsigned int v[4] = { 0, 0, 0, 0 };
+    int vc =
+      sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1], &v[2], &v[3]);
+    for (int i = 0; i < 4; ++i) {
+      if (i < vc) {
         sprintf(vb[i], "%u", v[i]);
         vs += sep;
         vs += vb[i];
         sep = ".";
-        }
-      else
-        {
+      } else {
         vb[i][0] = 0;
-        }
       }
+    }
 
     std::string vv;
     vv = args[0] + "_VERSION";
@@ -180,9 +160,7 @@ bool cmProjectCommand
     vv = args[0] + "_VERSION_TWEAK";
     this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]);
     this->Makefile->AddDefinition(vv, vb[3]);
-    }
-  else if(cmp0048 != cmPolicies::OLD)
-    {
+  } else if (cmp0048 != cmPolicies::OLD) {
     // Set project VERSION variables to empty
     std::vector<std::string> vv;
     vv.push_back("PROJECT_VERSION");
@@ -196,55 +174,43 @@ bool cmProjectCommand
     vv.push_back(args[0] + "_VERSION_PATCH");
     vv.push_back(args[0] + "_VERSION_TWEAK");
     std::string vw;
-    for(std::vector<std::string>::iterator i = vv.begin();
-        i != vv.end(); ++i)
-      {
+    for (std::vector<std::string>::iterator i = vv.begin(); i != vv.end();
+         ++i) {
       const char* v = this->Makefile->GetDefinition(*i);
-      if(v && *v)
-        {
-        if(cmp0048 == cmPolicies::WARN)
-          {
+      if (v && *v) {
+        if (cmp0048 == cmPolicies::WARN) {
           vw += "\n  ";
           vw += *i;
-          }
-        else
-          {
+        } else {
           this->Makefile->AddDefinition(*i, "");
-          }
         }
       }
-    if(!vw.empty())
-      {
+    }
+    if (!vw.empty()) {
       std::ostringstream w;
       w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048)
         << "\nThe following variable(s) would be set to empty:" << vw;
       this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
-      }
     }
+  }
 
-  if (languages.empty())
-    {
+  if (languages.empty()) {
     // if no language is specified do c and c++
     languages.push_back("C");
     languages.push_back("CXX");
-    }
+  }
   this->Makefile->EnableLanguage(languages, false);
   std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE";
   const char* include = this->Makefile->GetDefinition(extraInclude);
-  if(include)
-    {
-    bool readit =
-      this->Makefile->ReadDependentFile(include);
-    if(!readit && !cmSystemTools::GetFatalErrorOccured())
-      {
-      std::string m =
-        "could not find file:\n"
-        "  ";
+  if (include) {
+    bool readit = this->Makefile->ReadDependentFile(include);
+    if (!readit && !cmSystemTools::GetFatalErrorOccured()) {
+      std::string m = "could not find file:\n"
+                      "  ";
       m += include;
       this->SetError(m);
       return false;
-      }
     }
+  }
   return true;
 }
-
diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h
index 7aacb55..a4e6367 100644
--- a/Source/cmProjectCommand.h
+++ b/Source/cmProjectCommand.h
@@ -28,26 +28,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmProjectCommand;
-    }
+  virtual cmCommand* Clone() { return new cmProjectCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "project";}
+  virtual std::string GetName() const { return "project"; }
 
   cmTypeMacro(cmProjectCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx
index ef57068..4910616 100644
--- a/Source/cmProperty.cxx
+++ b/Source/cmProperty.cxx
@@ -10,29 +10,28 @@
   See the License for more information.
 ============================================================================*/
 #include "cmProperty.h"
+
 #include "cmSystemTools.h"
 
-void cmProperty::Set(const char *value)
+void cmProperty::Set(const char* value)
 {
   this->Value = value;
   this->ValueHasBeenSet = true;
 }
 
-void cmProperty::Append(const char *value, bool asString)
+void cmProperty::Append(const char* value, bool asString)
 {
-  if(!this->Value.empty() && *value && !asString)
-    {
+  if (!this->Value.empty() && *value && !asString) {
     this->Value += ";";
-    }
+  }
   this->Value += value;
   this->ValueHasBeenSet = true;
 }
 
-const char *cmProperty::GetValue() const
+const char* cmProperty::GetValue() const
 {
-  if (this->ValueHasBeenSet)
-    {
+  if (this->ValueHasBeenSet) {
     return this->Value.c_str();
-    }
+  }
   return 0;
 }
diff --git a/Source/cmProperty.h b/Source/cmProperty.h
index e026372..1736136 100644
--- a/Source/cmProperty.h
+++ b/Source/cmProperty.h
@@ -17,17 +17,27 @@
 class cmProperty
 {
 public:
-  enum ScopeType { TARGET, SOURCE_FILE, DIRECTORY, GLOBAL, CACHE,
-                   TEST, VARIABLE, CACHED_VARIABLE, INSTALL };
+  enum ScopeType
+  {
+    TARGET,
+    SOURCE_FILE,
+    DIRECTORY,
+    GLOBAL,
+    CACHE,
+    TEST,
+    VARIABLE,
+    CACHED_VARIABLE,
+    INSTALL
+  };
 
   // set this property
-  void Set(const char *value);
+  void Set(const char* value);
 
   // append to this property
-  void Append(const char *value, bool asString = false);
+  void Append(const char* value, bool asString = false);
 
   // get the value
-  const char *GetValue() const;
+  const char* GetValue() const;
 
   // construct with the value not set
   cmProperty() { this->ValueHasBeenSet = false; }
diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx
index 1af967c..546146b 100644
--- a/Source/cmPropertyDefinition.cxx
+++ b/Source/cmPropertyDefinition.cxx
@@ -10,24 +10,22 @@
   See the License for more information.
 ============================================================================*/
 #include "cmPropertyDefinition.h"
+
 #include "cmSystemTools.h"
 
-void cmPropertyDefinition
-::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
-                 const char *shortDescription,
-                 const char *fullDescription,
-                 bool chain)
+void cmPropertyDefinition::DefineProperty(const std::string& name,
+                                          cmProperty::ScopeType scope,
+                                          const char* shortDescription,
+                                          const char* fullDescription,
+                                          bool chain)
 {
   this->Name = name;
   this->Scope = scope;
   this->Chained = chain;
-  if (shortDescription)
-    {
+  if (shortDescription) {
     this->ShortDescription = shortDescription;
-    }
-  if (fullDescription)
-    {
+  }
+  if (fullDescription) {
     this->FullDescription = fullDescription;
-    }
+  }
 }
-
diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h
index 098fadb..5733917 100644
--- a/Source/cmPropertyDefinition.h
+++ b/Source/cmPropertyDefinition.h
@@ -28,9 +28,8 @@ class cmPropertyDefinition
 public:
   /// Define this property
   void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
-                      const char *ShortDescription,
-                      const char *FullDescription,
-                      bool chained);
+                      const char* ShortDescription,
+                      const char* FullDescription, bool chained);
 
   /// Default constructor
   cmPropertyDefinition() { this->Chained = false; }
@@ -39,16 +38,19 @@ public:
   bool IsChained() const { return this->Chained; }
 
   /// Get the scope
-  cmProperty::ScopeType GetScope() const {
-    return this->Scope; }
+  cmProperty::ScopeType GetScope() const { return this->Scope; }
 
   /// Get the documentation (short version)
-  const std::string &GetShortDescription() const {
-    return this->ShortDescription; }
+  const std::string& GetShortDescription() const
+  {
+    return this->ShortDescription;
+  }
 
   /// Get the documentation (full version)
-  const std::string &GetFullDescription() const {
-    return this->FullDescription; }
+  const std::string& GetFullDescription() const
+  {
+    return this->FullDescription;
+  }
 
 protected:
   std::string Name;
diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx
index 776fad1..ebc2caa 100644
--- a/Source/cmPropertyDefinitionMap.cxx
+++ b/Source/cmPropertyDefinitionMap.cxx
@@ -10,32 +10,31 @@
   See the License for more information.
 ============================================================================*/
 #include "cmPropertyDefinitionMap.h"
-#include "cmSystemTools.h"
+
 #include "cmDocumentationSection.h"
+#include "cmSystemTools.h"
 
-void cmPropertyDefinitionMap
-::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
-                 const char *ShortDescription,
-                 const char *FullDescription,
-                 bool chain)
+void cmPropertyDefinitionMap::DefineProperty(const std::string& name,
+                                             cmProperty::ScopeType scope,
+                                             const char* ShortDescription,
+                                             const char* FullDescription,
+                                             bool chain)
 {
   cmPropertyDefinitionMap::iterator it = this->find(name);
-  cmPropertyDefinition *prop;
-  if (it == this->end())
-    {
+  cmPropertyDefinition* prop;
+  if (it == this->end()) {
     prop = &(*this)[name];
-    prop->DefineProperty(name,scope,ShortDescription, FullDescription,
+    prop->DefineProperty(name, scope, ShortDescription, FullDescription,
                          chain);
-    }
+  }
 }
 
 bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const
 {
   cmPropertyDefinitionMap::const_iterator it = this->find(name);
-  if (it == this->end())
-    {
+  if (it == this->end()) {
     return false;
-    }
+  }
 
   return true;
 }
@@ -43,10 +42,9 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const
 bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) const
 {
   cmPropertyDefinitionMap::const_iterator it = this->find(name);
-  if (it == this->end())
-    {
+  if (it == this->end()) {
     return false;
-    }
+  }
 
   return it->second.IsChained();
 }
diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h
index f95c721..fbc9a18 100644
--- a/Source/cmPropertyDefinitionMap.h
+++ b/Source/cmPropertyDefinitionMap.h
@@ -16,15 +16,14 @@
 
 class cmDocumentationSection;
 
-class cmPropertyDefinitionMap :
-public std::map<std::string,cmPropertyDefinition>
+class cmPropertyDefinitionMap
+  : public std::map<std::string, cmPropertyDefinition>
 {
 public:
   // define the property
   void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
-                      const char *ShortDescription,
-                      const char *FullDescription,
-                      bool chain);
+                      const char* ShortDescription,
+                      const char* FullDescription, bool chain);
 
   // has a named property been defined
   bool IsPropertyDefined(const std::string& name) const;
@@ -34,4 +33,3 @@ public:
 };
 
 #endif
-
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index ef09dbc..74e04da 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -10,36 +10,33 @@
   See the License for more information.
 ============================================================================*/
 #include "cmPropertyMap.h"
+
+#include "cmState.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
-#include "cmState.h"
 
 #include <assert.h>
 
-cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
+cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
 {
   cmPropertyMap::iterator it = this->find(name);
-  cmProperty *prop;
-  if (it == this->end())
-    {
+  cmProperty* prop;
+  if (it == this->end()) {
     prop = &(*this)[name];
-    }
-  else
-    {
+  } else {
     prop = &(it->second);
-    }
+  }
   return prop;
 }
 
-void cmPropertyMap::SetProperty(const std::string& name, const char *value)
+void cmPropertyMap::SetProperty(const std::string& name, const char* value)
 {
-  if(!value)
-    {
+  if (!value) {
     this->erase(name);
     return;
-    }
+  }
 
-  cmProperty *prop = this->GetOrCreateProperty(name);
+  cmProperty* prop = this->GetOrCreateProperty(name);
   prop->Set(value);
 }
 
@@ -47,25 +44,21 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
                                    bool asString)
 {
   // Skip if nothing to append.
-  if(!value || !*value)
-    {
+  if (!value || !*value) {
     return;
-    }
+  }
 
-  cmProperty *prop = this->GetOrCreateProperty(name);
-  prop->Append(value,asString);
+  cmProperty* prop = this->GetOrCreateProperty(name);
+  prop->Append(value, asString);
 }
 
-const char *cmPropertyMap
-::GetPropertyValue(const std::string& name) const
+const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
 {
   assert(!name.empty());
 
   cmPropertyMap::const_iterator it = this->find(name);
-  if (it == this->end())
-    {
+  if (it == this->end()) {
     return 0;
-    }
+  }
   return it->second.GetValue();
 }
-
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index a9062db..4e98750 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -14,18 +14,17 @@
 
 #include "cmProperty.h"
 
-class cmPropertyMap : public std::map<std::string,cmProperty>
+class cmPropertyMap : public std::map<std::string, cmProperty>
 {
 public:
-  cmProperty *GetOrCreateProperty(const std::string& name);
+  cmProperty* GetOrCreateProperty(const std::string& name);
 
-  void SetProperty(const std::string& name, const char *value);
+  void SetProperty(const std::string& name, const char* value);
 
   void AppendProperty(const std::string& name, const char* value,
-                      bool asString=false);
+                      bool asString = false);
 
-  const char *GetPropertyValue(const std::string& name) const;
+  const char* GetPropertyValue(const std::string& name) const;
 };
 
 #endif
-
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index aae1bb9..f63672b 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -13,13 +13,12 @@
 
 // cmQTWrapCPPCommand
 bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
-                                     cmExecutionStatus &)
+                                     cmExecutionStatus&)
 {
-  if(args.size() < 3 )
-    {
+  if (args.size() < 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Get the moc executable to run in the custom command.
   const char* moc_exe =
@@ -27,56 +26,43 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
 
   // Get the variable holding the list of sources.
   std::string const& sourceList = args[1];
-  std::string sourceListValue =
-    this->Makefile->GetSafeDefinition(sourceList);
+  std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
 
   // Create a rule for all sources listed.
-  for(std::vector<std::string>::const_iterator j = (args.begin() + 2);
-      j != args.end(); ++j)
-    {
-    cmSourceFile *curr = this->Makefile->GetSource(*j);
+  for (std::vector<std::string>::const_iterator j = (args.begin() + 2);
+       j != args.end(); ++j) {
+    cmSourceFile* curr = this->Makefile->GetSource(*j);
     // if we should wrap the class
-    if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
-      {
+    if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
       // Compute the name of the file to generate.
-      std::string srcName =
-        cmSystemTools::GetFilenameWithoutLastExtension(*j);
+      std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
       std::string newName = this->Makefile->GetCurrentBinaryDirectory();
       newName += "/moc_";
       newName += srcName;
       newName += ".cxx";
-      cmSourceFile* sf =
-        this->Makefile->GetOrCreateSource(newName, true);
-      if (curr)
-        {
+      cmSourceFile* sf = this->Makefile->GetOrCreateSource(newName, true);
+      if (curr) {
         sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
-        }
+      }
 
       // Compute the name of the header from which to generate the file.
       std::string hname;
-      if(cmSystemTools::FileIsFullPath(j->c_str()))
-        {
+      if (cmSystemTools::FileIsFullPath(j->c_str())) {
         hname = *j;
-        }
-      else
-        {
-        if(curr && curr->GetPropertyAsBool("GENERATED"))
-          {
+      } else {
+        if (curr && curr->GetPropertyAsBool("GENERATED")) {
           hname = this->Makefile->GetCurrentBinaryDirectory();
-          }
-        else
-          {
+        } else {
           hname = this->Makefile->GetCurrentSourceDirectory();
-          }
+        }
         hname += "/";
         hname += *j;
-        }
+      }
 
       // Append the generated source file to the list.
-      if(!sourceListValue.empty())
-        {
+      if (!sourceListValue.empty()) {
         sourceListValue += ";";
-        }
+      }
       sourceListValue += newName;
 
       // Create the custom command to generate the file.
@@ -95,17 +81,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
 
       std::string no_main_dependency = "";
       const char* no_working_dir = 0;
-      this->Makefile->AddCustomCommandToOutput(newName,
-                                               depends,
-                                               no_main_dependency,
-                                               commandLines,
-                                               "Qt Wrapped File",
-                                               no_working_dir);
-      }
+      this->Makefile->AddCustomCommandToOutput(
+        newName, depends, no_main_dependency, commandLines, "Qt Wrapped File",
+        no_working_dir);
     }
+  }
 
   // Store the final list of source files.
-  this->Makefile->AddDefinition(sourceList,
-                                sourceListValue.c_str());
+  this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
   return true;
 }
diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h
index 85729dd..2014828 100644
--- a/Source/cmQTWrapCPPCommand.h
+++ b/Source/cmQTWrapCPPCommand.h
@@ -30,24 +30,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmQTWrapCPPCommand;
-    }
+  virtual cmCommand* Clone() { return new cmQTWrapCPPCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "qt_wrap_cpp";}
+  virtual std::string GetName() const { return "qt_wrap_cpp"; }
 };
 
-
-
 #endif
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index 3adea29..4c1da36 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -13,13 +13,12 @@
 
 // cmQTWrapUICommand
 bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
-                                    cmExecutionStatus &)
+                                    cmExecutionStatus&)
 {
-  if(args.size() < 4 )
-    {
+  if (args.size() < 4) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Get the uic and moc executables to run in the custom commands.
   const char* uic_exe =
@@ -30,22 +29,17 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
   // Get the variable holding the list of sources.
   std::string const& headerList = args[1];
   std::string const& sourceList = args[2];
-  std::string headerListValue =
-    this->Makefile->GetSafeDefinition(headerList);
-  std::string sourceListValue =
-    this->Makefile->GetSafeDefinition(sourceList);
+  std::string headerListValue = this->Makefile->GetSafeDefinition(headerList);
+  std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
 
   // Create rules for all sources listed.
-  for(std::vector<std::string>::const_iterator j = (args.begin() + 3);
-      j != args.end(); ++j)
-    {
-    cmSourceFile *curr = this->Makefile->GetSource(*j);
+  for (std::vector<std::string>::const_iterator j = (args.begin() + 3);
+       j != args.end(); ++j) {
+    cmSourceFile* curr = this->Makefile->GetSource(*j);
     // if we should wrap the class
-    if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
-      {
+    if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
       // Compute the name of the files to generate.
-      std::string srcName =
-        cmSystemTools::GetFilenameWithoutLastExtension(*j);
+      std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
       std::string hName = this->Makefile->GetCurrentBinaryDirectory();
       hName += "/";
       hName += srcName;
@@ -61,36 +55,28 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
 
       // Compute the name of the ui file from which to generate others.
       std::string uiName;
-      if(cmSystemTools::FileIsFullPath(j->c_str()))
-        {
+      if (cmSystemTools::FileIsFullPath(j->c_str())) {
         uiName = *j;
-        }
-      else
-        {
-        if(curr && curr->GetPropertyAsBool("GENERATED"))
-          {
+      } else {
+        if (curr && curr->GetPropertyAsBool("GENERATED")) {
           uiName = this->Makefile->GetCurrentBinaryDirectory();
-          }
-        else
-          {
+        } else {
           uiName = this->Makefile->GetCurrentSourceDirectory();
-          }
+        }
         uiName += "/";
         uiName += *j;
-        }
+      }
 
       // create the list of headers
-      if(!headerListValue.empty())
-        {
+      if (!headerListValue.empty()) {
         headerListValue += ";";
-        }
+      }
       headerListValue += hName;
 
       // create the list of sources
-      if(!sourceListValue.empty())
-        {
+      if (!sourceListValue.empty()) {
         sourceListValue += ";";
-        }
+      }
       sourceListValue += cxxName;
       sourceListValue += ";";
       sourceListValue += mocName;
@@ -127,36 +113,25 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
       std::string no_main_dependency = "";
       const char* no_comment = 0;
       const char* no_working_dir = 0;
-      this->Makefile->AddCustomCommandToOutput(hName,
-                                               depends,
-                                               no_main_dependency,
-                                               hCommandLines,
-                                               no_comment,
-                                               no_working_dir);
+      this->Makefile->AddCustomCommandToOutput(
+        hName, depends, no_main_dependency, hCommandLines, no_comment,
+        no_working_dir);
 
       depends.push_back(hName);
-      this->Makefile->AddCustomCommandToOutput(cxxName,
-                                               depends,
-                                               no_main_dependency,
-                                               cxxCommandLines,
-                                               no_comment,
-                                               no_working_dir);
+      this->Makefile->AddCustomCommandToOutput(
+        cxxName, depends, no_main_dependency, cxxCommandLines, no_comment,
+        no_working_dir);
 
       depends.clear();
       depends.push_back(hName);
-      this->Makefile->AddCustomCommandToOutput(mocName,
-                                               depends,
-                                               no_main_dependency,
-                                               mocCommandLines,
-                                               no_comment,
-                                               no_working_dir);
-      }
+      this->Makefile->AddCustomCommandToOutput(
+        mocName, depends, no_main_dependency, mocCommandLines, no_comment,
+        no_working_dir);
     }
+  }
 
   // Store the final list of source files and headers.
-  this->Makefile->AddDefinition(sourceList,
-                                sourceListValue.c_str());
-  this->Makefile->AddDefinition(headerList,
-                                headerListValue.c_str());
+  this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
+  this->Makefile->AddDefinition(headerList, headerListValue.c_str());
   return true;
 }
diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h
index 4aa9a61..48cfc77 100644
--- a/Source/cmQTWrapUICommand.h
+++ b/Source/cmQTWrapUICommand.h
@@ -28,24 +28,19 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmQTWrapUICommand;
-    }
+  virtual cmCommand* Clone() { return new cmQTWrapUICommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "qt_wrap_ui";}
+  virtual std::string GetName() const { return "qt_wrap_ui"; }
 };
 
-
-
 #endif
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 08caea3..dd19760 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -22,14 +22,87 @@
 #include <cmsys/FStream.hxx>
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-# include "cmGlobalVisualStudioGenerator.h"
+#include "cmGlobalVisualStudioGenerator.h"
 #endif
 
+static std::string GetAutogenTargetName(cmGeneratorTarget const* target)
+{
+  std::string autogenTargetName = target->GetName();
+  autogenTargetName += "_automoc";
+  return autogenTargetName;
+}
+
+static std::string GetAutogenTargetDir(cmGeneratorTarget const* target)
+{
+  cmMakefile* makefile = target->Target->GetMakefile();
+  std::string targetDir = makefile->GetCurrentBinaryDirectory();
+  targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
+  targetDir += "/";
+  targetDir += GetAutogenTargetName(target);
+  targetDir += ".dir/";
+  return targetDir;
+}
+
+static std::string GetAutogenTargetBuildDir(cmGeneratorTarget const* target)
+{
+  cmMakefile* makefile = target->Target->GetMakefile();
+  std::string targetDir = makefile->GetCurrentBinaryDirectory();
+  targetDir += "/";
+  targetDir += GetAutogenTargetName(target);
+  targetDir += ".dir/";
+  return targetDir;
+}
+
+static std::string GetSourceRelativePath(cmGeneratorTarget const* target,
+                                         const std::string& fileName)
+{
+  std::string pathRel;
+  // Test if the file is child to any of the known directories
+  {
+    const std::string fileNameReal = cmsys::SystemTools::GetRealPath(fileName);
+    std::string parentDirectory;
+    bool match(false);
+    {
+      std::string testDirs[4];
+      {
+        cmMakefile* makefile = target->Target->GetMakefile();
+        testDirs[0] = makefile->GetCurrentSourceDirectory();
+        testDirs[1] = makefile->GetCurrentBinaryDirectory();
+        testDirs[2] = makefile->GetHomeDirectory();
+        testDirs[3] = makefile->GetHomeOutputDirectory();
+      }
+      for (int ii = 0; ii != sizeof(testDirs) / sizeof(std::string); ++ii) {
+        const ::std::string testDir =
+          cmsys::SystemTools::GetRealPath(testDirs[ii]);
+        if (!testDir.empty() &&
+            cmsys::SystemTools::IsSubDirectory(fileNameReal, testDir)) {
+          parentDirectory = testDir;
+          match = true;
+          break;
+        }
+      }
+    }
+    // Use root as fallback parent directory
+    if (!match) {
+      cmsys::SystemTools::SplitPathRootComponent(fileNameReal,
+                                                 &parentDirectory);
+    }
+    pathRel = cmsys::SystemTools::RelativePath(
+      parentDirectory, cmsys::SystemTools::GetParentDirectory(fileNameReal));
+  }
+  // Sanitize relative path
+  if (!pathRel.empty()) {
+    pathRel += '/';
+    cmSystemTools::ReplaceString(pathRel, "..", "__");
+  }
+  return pathRel;
+}
+
 static void SetupSourceFiles(cmGeneratorTarget const* target,
-                                   std::vector<std::string>& skipMoc,
-                                   std::vector<std::string>& mocSources,
-                                   std::vector<std::string>& mocHeaders,
-                                   std::vector<std::string>& skipUic)
+                             std::vector<std::string>& skipMoc,
+                             std::vector<std::string>& mocSources,
+                             std::vector<std::string>& mocHeaders,
+                             std::vector<std::string>& skipUic)
 {
   cmMakefile* makefile = target->Target->GetMakefile();
 
@@ -38,81 +111,67 @@ static void SetupSourceFiles(cmGeneratorTarget const* target,
 
   std::vector<std::string> newRccFiles;
 
-  for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
-      fileIt != srcFiles.end();
-      ++fileIt)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+       fileIt != srcFiles.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;
-    std::string absFile = cmsys::SystemTools::GetRealPath(
-                                                    sf->GetFullPath());
+    std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
     bool skipFileForMoc =
-        cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
+      cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
     bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"));
 
-    if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")))
-      {
+    if (cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) {
       skipUic.push_back(absFile);
-      }
+    }
 
     std::string ext = sf->GetExtension();
 
-    if (target->GetPropertyAsBool("AUTORCC"))
-      {
-      if (ext == "qrc"
-          && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
-        {
-        std::string basename = cmsys::SystemTools::
-                                      GetFilenameWithoutLastExtension(absFile);
+    if (target->GetPropertyAsBool("AUTORCC")) {
+      if (ext == "qrc" &&
+          !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) {
 
-        std::string rcc_output_dir = target->GetSupportDirectory();
+        std::string rcc_output_dir = GetAutogenTargetBuildDir(target);
+        rcc_output_dir += GetSourceRelativePath(target, absFile);
         cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+
+        std::string basename =
+          cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
+
         std::string rcc_output_file = rcc_output_dir;
-        rcc_output_file += "/qrc_" + basename + ".cpp";
+        rcc_output_file += "qrc_" + basename + ".cpp";
         makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
-                                rcc_output_file.c_str(), false);
+                                 rcc_output_file.c_str(), false);
         makefile->GetOrCreateSource(rcc_output_file, true);
         newRccFiles.push_back(rcc_output_file);
-        }
       }
+    }
 
-    if (!generated)
-      {
-      if (skipFileForMoc)
-        {
+    if (!generated) {
+      if (skipFileForMoc) {
         skipMoc.push_back(absFile);
-        }
-      else
-        {
-        cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(
-                                                                ext.c_str());
-        if (fileType == cmSystemTools::CXX_FILE_FORMAT)
-          {
+      } else {
+        cmSystemTools::FileFormat fileType =
+          cmSystemTools::GetFileFormat(ext.c_str());
+        if (fileType == cmSystemTools::CXX_FILE_FORMAT) {
           mocSources.push_back(absFile);
-          }
-        else if (fileType == cmSystemTools::HEADER_FILE_FORMAT)
-          {
+        } else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) {
           mocHeaders.push_back(absFile);
-          }
         }
       }
     }
+  }
 
-  for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin();
-      fileIt != newRccFiles.end();
-      ++fileIt)
-    {
+  for (std::vector<std::string>::const_iterator fileIt = newRccFiles.begin();
+       fileIt != newRccFiles.end(); ++fileIt) {
     const_cast<cmGeneratorTarget*>(target)->AddSource(*fileIt);
-    }
+  }
 }
 
 static void GetCompileDefinitionsAndDirectories(
-  cmGeneratorTarget const* target,
-  const std::string& config,
-  std::string &incs,
-  std::string &defs)
+  cmGeneratorTarget const* target, const std::string& config,
+  std::string& incs, std::string& defs)
 {
   std::vector<std::string> includeDirs;
-  cmLocalGenerator *localGen = target->GetLocalGenerator();
+  cmLocalGenerator* localGen = target->GetLocalGenerator();
   // Get the include dirs for this target, without stripping the implicit
   // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
   localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false);
@@ -125,24 +184,26 @@ static void GetCompileDefinitionsAndDirectories(
   defs += cmJoin(defines, ";");
 }
 
-static void SetupAutoMocTarget(cmGeneratorTarget const* target,
-                          const std::string &autogenTargetName,
-                          std::vector<std::string> const& skipMoc,
-                          std::vector<std::string> const& mocHeaders,
-                          std::map<std::string, std::string> &configIncludes,
-                          std::map<std::string, std::string> &configDefines)
+static void SetupAutoMocTarget(
+  cmGeneratorTarget const* target, const std::string& autogenTargetName,
+  std::vector<std::string> const& skipMoc,
+  std::vector<std::string> const& mocHeaders,
+  std::map<std::string, std::string>& configIncludes,
+  std::map<std::string, std::string>& configDefines)
 {
   cmLocalGenerator* lg = target->GetLocalGenerator();
   cmMakefile* makefile = target->Target->GetMakefile();
 
   const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
-  std::string _moc_options = (tmp!=0 ? tmp : "");
-  makefile->AddDefinition("_moc_options",
-          cmOutputConverter::EscapeForCMake(_moc_options).c_str());
-  makefile->AddDefinition("_skip_moc",
-          cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str());
-  makefile->AddDefinition("_moc_headers",
-          cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str());
+  std::string _moc_options = (tmp != 0 ? tmp : "");
+  makefile->AddDefinition(
+    "_moc_options", cmOutputConverter::EscapeForCMake(_moc_options).c_str());
+  makefile->AddDefinition(
+    "_skip_moc",
+    cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str());
+  makefile->AddDefinition(
+    "_moc_headers",
+    cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str());
   bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
   makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
 
@@ -150,146 +211,124 @@ static void SetupAutoMocTarget(cmGeneratorTarget const* target,
   std::string _moc_compile_defs;
   std::vector<std::string> configs;
   const std::string& config = makefile->GetConfigurations(configs);
-  GetCompileDefinitionsAndDirectories(target, config,
-                                      _moc_incs, _moc_compile_defs);
+  GetCompileDefinitionsAndDirectories(target, config, _moc_incs,
+                                      _moc_compile_defs);
 
-  makefile->AddDefinition("_moc_incs",
-          cmOutputConverter::EscapeForCMake(_moc_incs).c_str());
-  makefile->AddDefinition("_moc_compile_defs",
-          cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str());
+  makefile->AddDefinition(
+    "_moc_incs", cmOutputConverter::EscapeForCMake(_moc_incs).c_str());
+  makefile->AddDefinition(
+    "_moc_compile_defs",
+    cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str());
 
   for (std::vector<std::string>::const_iterator li = configs.begin();
-       li != configs.end(); ++li)
-    {
+       li != configs.end(); ++li) {
     std::string config_moc_incs;
     std::string config_moc_compile_defs;
-    GetCompileDefinitionsAndDirectories(target, *li,
-                                        config_moc_incs,
+    GetCompileDefinitionsAndDirectories(target, *li, config_moc_incs,
                                         config_moc_compile_defs);
-    if (config_moc_incs != _moc_incs)
-      {
-      configIncludes[*li] =
-                    cmOutputConverter::EscapeForCMake(config_moc_incs);
-      if(_moc_incs.empty())
-        {
+    if (config_moc_incs != _moc_incs) {
+      configIncludes[*li] = cmOutputConverter::EscapeForCMake(config_moc_incs);
+      if (_moc_incs.empty()) {
         _moc_incs = config_moc_incs;
-        }
       }
-    if (config_moc_compile_defs != _moc_compile_defs)
-      {
+    }
+    if (config_moc_compile_defs != _moc_compile_defs) {
       configDefines[*li] =
-            cmOutputConverter::EscapeForCMake(config_moc_compile_defs);
-      if(_moc_compile_defs.empty())
-        {
+        cmOutputConverter::EscapeForCMake(config_moc_compile_defs);
+      if (_moc_compile_defs.empty()) {
         _moc_compile_defs = config_moc_compile_defs;
-        }
       }
     }
+  }
 
-  const char *qtVersion = makefile->GetDefinition("_target_qt_version");
-  if (strcmp(qtVersion, "5") == 0)
-    {
-    cmGeneratorTarget *qt5Moc =
-        lg->FindGeneratorTargetToUse("Qt5::moc");
-    if (!qt5Moc)
-      {
+  const char* qtVersion = makefile->GetDefinition("_target_qt_version");
+  if (strcmp(qtVersion, "5") == 0) {
+    cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc");
+    if (!qt5Moc) {
       cmSystemTools::Error("Qt5::moc target not found ",
-                          autogenTargetName.c_str());
+                           autogenTargetName.c_str());
       return;
-      }
+    }
     makefile->AddDefinition("_qt_moc_executable",
                             qt5Moc->ImportedGetLocation(""));
-    }
-  else if (strcmp(qtVersion, "4") == 0)
-    {
-    cmGeneratorTarget *qt4Moc =
-        lg->FindGeneratorTargetToUse("Qt4::moc");
-    if (!qt4Moc)
-      {
+  } else if (strcmp(qtVersion, "4") == 0) {
+    cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc");
+    if (!qt4Moc) {
       cmSystemTools::Error("Qt4::moc target not found ",
-                          autogenTargetName.c_str());
+                           autogenTargetName.c_str());
       return;
-      }
+    }
     makefile->AddDefinition("_qt_moc_executable",
                             qt4Moc->ImportedGetLocation(""));
-    }
-  else
-    {
+  } else {
     cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
-                        "Qt 5 ", autogenTargetName.c_str());
-    }
+                         "Qt 5 ",
+                         autogenTargetName.c_str());
+  }
 }
 
 static void GetUicOpts(cmGeneratorTarget const* target,
-                       const std::string& config,
-                       std::string &optString)
+                       const std::string& config, std::string& optString)
 {
   std::vector<std::string> opts;
   target->GetAutoUicOptions(opts, config);
   optString = cmJoin(opts, ";");
 }
 
-static void SetupAutoUicTarget(cmGeneratorTarget const* target,
-                          std::vector<std::string> const& skipUic,
-                          std::map<std::string, std::string> &configUicOptions)
+static void SetupAutoUicTarget(
+  cmGeneratorTarget const* target, std::vector<std::string> const& skipUic,
+  std::map<std::string, std::string>& configUicOptions)
 {
   cmLocalGenerator* lg = target->GetLocalGenerator();
-  cmMakefile *makefile = target->Target->GetMakefile();
+  cmMakefile* makefile = target->Target->GetMakefile();
 
   std::set<std::string> skipped;
   skipped.insert(skipUic.begin(), skipUic.end());
 
-  makefile->AddDefinition("_skip_uic",
-          cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str());
+  makefile->AddDefinition(
+    "_skip_uic",
+    cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str());
 
-  std::vector<cmSourceFile*> uiFilesWithOptions
-                                        = makefile->GetQtUiFilesWithOptions();
+  std::vector<cmSourceFile*> uiFilesWithOptions =
+    makefile->GetQtUiFilesWithOptions();
 
-  const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+  const char* qtVersion = makefile->GetDefinition("_target_qt_version");
 
   std::string _uic_opts;
   std::vector<std::string> configs;
   const std::string& config = makefile->GetConfigurations(configs);
   GetUicOpts(target, config, _uic_opts);
 
-  if (!_uic_opts.empty())
-    {
+  if (!_uic_opts.empty()) {
     _uic_opts = cmOutputConverter::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)
-    {
+       li != configs.end(); ++li) {
     std::string config_uic_opts;
     GetUicOpts(target, *li, config_uic_opts);
-    if (config_uic_opts != _uic_opts)
-      {
+    if (config_uic_opts != _uic_opts) {
       configUicOptions[*li] =
-                    cmOutputConverter::EscapeForCMake(config_uic_opts);
-      if(_uic_opts.empty())
-        {
+        cmOutputConverter::EscapeForCMake(config_uic_opts);
+      if (_uic_opts.empty()) {
         _uic_opts = config_uic_opts;
-        }
       }
     }
+  }
 
   std::string uiFileFiles;
   std::string uiFileOptions;
   const char* sep = "";
 
-  for(std::vector<cmSourceFile*>::const_iterator fileIt =
-      uiFilesWithOptions.begin();
-      fileIt != uiFilesWithOptions.end();
-      ++fileIt)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator fileIt =
+         uiFilesWithOptions.begin();
+       fileIt != uiFilesWithOptions.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;
-    std::string absFile = cmsys::SystemTools::GetRealPath(
-                                                    sf->GetFullPath());
+    std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
 
-    if (!skipped.insert(absFile).second)
-      {
+    if (!skipped.insert(absFile).second) {
       continue;
-      }
+    }
     uiFileFiles += sep;
     uiFileFiles += absFile;
     uiFileOptions += sep;
@@ -297,181 +336,128 @@ static void SetupAutoUicTarget(cmGeneratorTarget const* target,
     cmSystemTools::ReplaceString(opts, ";", "@list_sep@");
     uiFileOptions += opts;
     sep = ";";
-    }
+  }
 
-  makefile->AddDefinition("_qt_uic_options_files",
-              cmOutputConverter::EscapeForCMake(uiFileFiles).c_str());
-  makefile->AddDefinition("_qt_uic_options_options",
-            cmOutputConverter::EscapeForCMake(uiFileOptions).c_str());
+  makefile->AddDefinition(
+    "_qt_uic_options_files",
+    cmOutputConverter::EscapeForCMake(uiFileFiles).c_str());
+  makefile->AddDefinition(
+    "_qt_uic_options_options",
+    cmOutputConverter::EscapeForCMake(uiFileOptions).c_str());
 
   std::string targetName = target->GetName();
-  if (strcmp(qtVersion, "5") == 0)
-    {
-    cmGeneratorTarget *qt5Uic =
-        lg->FindGeneratorTargetToUse("Qt5::uic");
-    if (!qt5Uic)
-      {
+  if (strcmp(qtVersion, "5") == 0) {
+    cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic");
+    if (!qt5Uic) {
       // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
-      }
-    else
-      {
+    } else {
       makefile->AddDefinition("_qt_uic_executable",
                               qt5Uic->ImportedGetLocation(""));
-      }
     }
-  else if (strcmp(qtVersion, "4") == 0)
-    {
-    cmGeneratorTarget *qt4Uic =
-        lg->FindGeneratorTargetToUse("Qt4::uic");
-    if (!qt4Uic)
-      {
-      cmSystemTools::Error("Qt4::uic target not found ",
-                          targetName.c_str());
+  } else if (strcmp(qtVersion, "4") == 0) {
+    cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic");
+    if (!qt4Uic) {
+      cmSystemTools::Error("Qt4::uic target not found ", targetName.c_str());
       return;
-      }
+    }
     makefile->AddDefinition("_qt_uic_executable",
                             qt4Uic->ImportedGetLocation(""));
-    }
-  else
-    {
+  } else {
     cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
-                        "Qt 5 ", targetName.c_str());
-    }
+                         "Qt 5 ",
+                         targetName.c_str());
+  }
 }
 
 static std::string GetRccExecutable(cmGeneratorTarget const* target)
 {
   cmLocalGenerator* lg = target->GetLocalGenerator();
-  cmMakefile *makefile = target->Target->GetMakefile();
-  const char *qtVersion = makefile->GetDefinition("_target_qt_version");
-  if (!qtVersion)
-    {
+  cmMakefile* makefile = target->Target->GetMakefile();
+  const char* qtVersion = makefile->GetDefinition("_target_qt_version");
+  if (!qtVersion) {
     qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
-    if (!qtVersion)
-      {
+    if (!qtVersion) {
       qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
-      }
-    if (const char *targetQtVersion =
-        target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION",
-                                                        ""))
-      {
+    }
+    if (const char* targetQtVersion =
+          target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION",
+                                                          "")) {
       qtVersion = targetQtVersion;
-      }
     }
+  }
 
   std::string targetName = target->GetName();
-  if (strcmp(qtVersion, "5") == 0)
-    {
-    cmGeneratorTarget *qt5Rcc =
-        lg->FindGeneratorTargetToUse("Qt5::rcc");
-    if (!qt5Rcc)
-      {
-      cmSystemTools::Error("Qt5::rcc target not found ",
-                          targetName.c_str());
+  if (strcmp(qtVersion, "5") == 0) {
+    cmGeneratorTarget* qt5Rcc = lg->FindGeneratorTargetToUse("Qt5::rcc");
+    if (!qt5Rcc) {
+      cmSystemTools::Error("Qt5::rcc target not found ", targetName.c_str());
       return std::string();
-      }
-    return qt5Rcc->ImportedGetLocation("");
     }
-  else if (strcmp(qtVersion, "4") == 0)
-    {
-    cmGeneratorTarget *qt4Rcc =
-        lg->FindGeneratorTargetToUse("Qt4::rcc");
-    if (!qt4Rcc)
-      {
-      cmSystemTools::Error("Qt4::rcc target not found ",
-                          targetName.c_str());
+    return qt5Rcc->ImportedGetLocation("");
+  } else if (strcmp(qtVersion, "4") == 0) {
+    cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc");
+    if (!qt4Rcc) {
+      cmSystemTools::Error("Qt4::rcc target not found ", targetName.c_str());
       return std::string();
-      }
-    return qt4Rcc->ImportedGetLocation("");
     }
+    return qt4Rcc->ImportedGetLocation("");
+  }
 
   cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
-                      "Qt 5 ", targetName.c_str());
+                       "Qt 5 ",
+                       targetName.c_str());
   return std::string();
 }
 
-static void MergeRccOptions(std::vector<std::string> &opts,
-                         const std::vector<std::string> &fileOpts,
-                         bool isQt5)
+static void MergeRccOptions(std::vector<std::string>& opts,
+                            const std::vector<std::string>& fileOpts,
+                            bool isQt5)
 {
-  static const char* valueOptions[] = {
-    "name",
-    "root",
-    "compress",
-    "threshold"
-  };
+  static const char* valueOptions[] = { "name", "root", "compress",
+                                        "threshold" };
   std::vector<std::string> extraOpts;
-  for(std::vector<std::string>::const_iterator it = fileOpts.begin();
-      it != fileOpts.end(); ++it)
-    {
-    std::vector<std::string>::iterator existingIt
-                                  = std::find(opts.begin(), opts.end(), *it);
-    if (existingIt != opts.end())
-      {
-      const char *o = it->c_str();
-      if (*o == '-')
-        {
+  for (std::vector<std::string>::const_iterator it = fileOpts.begin();
+       it != fileOpts.end(); ++it) {
+    std::vector<std::string>::iterator existingIt =
+      std::find(opts.begin(), opts.end(), *it);
+    if (existingIt != opts.end()) {
+      const char* o = it->c_str();
+      if (*o == '-') {
         ++o;
-        }
-      if (isQt5 && *o == '-')
-        {
+      }
+      if (isQt5 && *o == '-') {
         ++o;
-        }
+      }
       if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
-                  cmStrCmp(*it)) != cmArrayEnd(valueOptions))
-        {
+                       cmStrCmp(*it)) != cmArrayEnd(valueOptions)) {
         assert(existingIt + 1 != opts.end());
         *(existingIt + 1) = *(it + 1);
         ++it;
-        }
       }
-    else
-      {
+    } else {
       extraOpts.push_back(*it);
-      }
     }
+  }
   opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
 }
 
-std::string GetAutogenTargetName(
-    cmGeneratorTarget const* target)
-{
-  std::string autogenTargetName = target->GetName();
-  autogenTargetName += "_automoc";
-  return autogenTargetName;
-}
-
-std::string GetAutogenTargetDir(
-    cmGeneratorTarget const* target)
-{
-  cmMakefile* makefile = target->Target->GetMakefile();
-  std::string targetDir = makefile->GetCurrentBinaryDirectory();
-  targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
-  targetDir += "/";
-  targetDir += GetAutogenTargetName(target);
-  targetDir += ".dir/";
-  return targetDir;
-}
-
 static void copyTargetProperty(cmTarget* destinationTarget,
                                cmTarget* sourceTarget,
                                const std::string& propertyName)
 {
   const char* propertyValue = sourceTarget->GetProperty(propertyName);
-  if (propertyValue)
-    {
+  if (propertyValue) {
     destinationTarget->SetProperty(propertyName, propertyValue);
-    }
+  }
 }
 
 static std::string cmQtAutoGeneratorsStripCR(std::string const& line)
 {
   // Strip CR characters rcc may have printed (possibly more than one!).
   std::string::size_type cr = line.find('\r');
-  if (cr != line.npos)
-    {
+  if (cr != line.npos) {
     return line.substr(0, cr);
-    }
+  }
   return line;
 }
 
@@ -485,27 +471,24 @@ static std::string ReadAll(const std::string& filename)
 }
 
 static std::string ListQt5RccInputs(cmSourceFile* sf,
-                                            cmGeneratorTarget const* target,
-                                            std::vector<std::string>& depends)
+                                    cmGeneratorTarget const* target,
+                                    std::vector<std::string>& depends)
 {
-  std::string rccCommand
-      = GetRccExecutable(target);
+  std::string rccCommand = GetRccExecutable(target);
 
   bool hasDashDashList = false;
   {
-  std::vector<std::string> command;
-  command.push_back(rccCommand);
-  command.push_back("--help");
-  std::string rccStdOut;
-  std::string rccStdErr;
-  int retVal = 0;
-  bool result = cmSystemTools::RunSingleCommand(
-    command, &rccStdOut, &rccStdErr,
-    &retVal, 0, cmSystemTools::OUTPUT_NONE);
-  if (result && retVal == 0 &&
-      rccStdOut.find("--list") != std::string::npos)
-    {
-    hasDashDashList = true;
+    std::vector<std::string> command;
+    command.push_back(rccCommand);
+    command.push_back("--help");
+    std::string rccStdOut;
+    std::string rccStdErr;
+    int retVal = 0;
+    bool result = cmSystemTools::RunSingleCommand(
+      command, &rccStdOut, &rccStdErr, &retVal, 0, cmSystemTools::OUTPUT_NONE);
+    if (result && retVal == 0 &&
+        rccStdOut.find("--list") != std::string::npos) {
+      hasDashDashList = true;
     }
   }
 
@@ -513,10 +496,9 @@ static std::string ListQt5RccInputs(cmSourceFile* sf,
 
   std::vector<std::string> command;
   command.push_back(rccCommand);
-  command.push_back(hasDashDashList? "--list" : "-list");
+  command.push_back(hasDashDashList ? "--list" : "-list");
 
-  std::string absFile = cmsys::SystemTools::GetRealPath(
-                                              sf->GetFullPath());
+  std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
 
   command.push_back(absFile);
 
@@ -524,48 +506,47 @@ static std::string ListQt5RccInputs(cmSourceFile* sf,
   std::string rccStdErr;
   int retVal = 0;
   bool result = cmSystemTools::RunSingleCommand(
-    command, &rccStdOut, &rccStdErr,
-    &retVal, 0, cmSystemTools::OUTPUT_NONE);
-  if (!result || retVal)
-    {
-    std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
-              << " failed:\n" << rccStdOut << "\n" << rccStdErr << std::endl;
+    command, &rccStdOut, &rccStdErr, &retVal, 0, cmSystemTools::OUTPUT_NONE);
+  if (!result || retVal) {
+    std::stringstream err;
+    err << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
+        << " failed:\n"
+        << rccStdOut << "\n"
+        << rccStdErr << std::endl;
+    std::cerr << err.str();
     return std::string();
-    }
+  }
 
   {
-  std::istringstream ostr(rccStdOut);
-  std::string oline;
-  while(std::getline(ostr, oline))
-    {
-    oline = cmQtAutoGeneratorsStripCR(oline);
-    if(!oline.empty())
-      {
-      qrcEntries.push_back(oline);
+    std::istringstream ostr(rccStdOut);
+    std::string oline;
+    while (std::getline(ostr, oline)) {
+      oline = cmQtAutoGeneratorsStripCR(oline);
+      if (!oline.empty()) {
+        qrcEntries.push_back(oline);
       }
     }
   }
 
   {
-  std::istringstream estr(rccStdErr);
-  std::string eline;
-  while(std::getline(estr, eline))
-    {
-    eline = cmQtAutoGeneratorsStripCR(eline);
-    if (cmHasLiteralPrefix(eline, "RCC: Error in"))
-      {
-      static std::string searchString = "Cannot find file '";
-
-      std::string::size_type pos = eline.find(searchString);
-      if (pos == std::string::npos)
-        {
-        std::cerr << "AUTOGEN: error: Rcc lists unparsable output "
-                  << eline << std::endl;
-        return std::string();
+    std::istringstream estr(rccStdErr);
+    std::string eline;
+    while (std::getline(estr, eline)) {
+      eline = cmQtAutoGeneratorsStripCR(eline);
+      if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
+        static std::string searchString = "Cannot find file '";
+
+        std::string::size_type pos = eline.find(searchString);
+        if (pos == std::string::npos) {
+          std::stringstream err;
+          err << "AUTOGEN: error: Rcc lists unparsable output " << eline
+              << std::endl;
+          std::cerr << err.str();
+          return std::string();
         }
-      pos += searchString.length();
-      std::string::size_type sz = eline.size() - pos - 1;
-      qrcEntries.push_back(eline.substr(pos, sz));
+        pos += searchString.length();
+        std::string::size_type sz = eline.size() - pos - 1;
+        qrcEntries.push_back(eline.substr(pos, sz));
       }
     }
   }
@@ -575,7 +556,7 @@ static std::string ListQt5RccInputs(cmSourceFile* sf,
 }
 
 static std::string ListQt4RccInputs(cmSourceFile* sf,
-                                            std::vector<std::string>& depends)
+                                    std::vector<std::string>& depends)
 {
   const std::string qrcContents = ReadAll(sf->GetFullPath());
 
@@ -585,8 +566,7 @@ static std::string ListQt4RccInputs(cmSourceFile* sf,
   const char* sep = "";
 
   size_t offset = 0;
-  while (fileMatchRegex.find(qrcContents.c_str() + offset))
-    {
+  while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
     std::string qrcEntry = fileMatchRegex.match(1);
 
     offset += qrcEntry.size();
@@ -597,16 +577,15 @@ static std::string ListQt4RccInputs(cmSourceFile* sf,
 
     qrcEntry = qrcEntry.substr(tag.size());
 
-    if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str()))
-      {
+    if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
       qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry;
-      }
+    }
 
     entriesList += sep;
     entriesList += qrcEntry;
     sep = "@list_sep@";
     depends.push_back(qrcEntry);
-    }
+  }
   return entriesList;
 }
 
@@ -614,7 +593,7 @@ static void SetupAutoRccTarget(cmGeneratorTarget const* target)
 {
   std::string _rcc_files;
   const char* sepRccFiles = "";
-  cmMakefile *makefile = target->Target->GetMakefile();
+  cmMakefile* makefile = target->Target->GetMakefile();
 
   std::vector<cmSourceFile*> srcFiles;
   target->GetConfigCommonSourceFiles(srcFiles);
@@ -624,134 +603,117 @@ static void SetupAutoRccTarget(cmGeneratorTarget const* target)
 
   std::string rccFileFiles;
   std::string rccFileOptions;
-  const char *optionSep = "";
+  const char* optionSep = "";
 
-  const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+  const char* qtVersion = makefile->GetDefinition("_target_qt_version");
 
   std::vector<std::string> rccOptions;
-  if (const char* opts = target->GetProperty("AUTORCC_OPTIONS"))
-    {
+  if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) {
     cmSystemTools::ExpandListArgument(opts, rccOptions);
-    }
+  }
   std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
-  if (qtMajorVersion == "")
-    {
+  if (qtMajorVersion == "") {
     qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
-    }
+  }
 
-  for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
-      fileIt != srcFiles.end();
-      ++fileIt)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+       fileIt != srcFiles.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;
     std::string ext = sf->GetExtension();
-    if (ext == "qrc")
-      {
-      std::string absFile = cmsys::SystemTools::GetRealPath(
-                                                  sf->GetFullPath());
+    if (ext == "qrc") {
+      std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
       bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
 
-      if (!skip)
-        {
+      if (!skip) {
         _rcc_files += sepRccFiles;
         _rcc_files += absFile;
         sepRccFiles = ";";
 
-        if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS"))
-          {
+        if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
           std::vector<std::string> optsVec;
           cmSystemTools::ExpandListArgument(prop, optsVec);
-          MergeRccOptions(rccOptions, optsVec,
-                                strcmp(qtVersion, "5") == 0);
-          }
+          MergeRccOptions(rccOptions, optsVec, strcmp(qtVersion, "5") == 0);
+        }
 
-        if (!rccOptions.empty())
-          {
+        if (!rccOptions.empty()) {
           rccFileFiles += optionSep;
           rccFileFiles += absFile;
           rccFileOptions += optionSep;
-          }
-        const char *listSep = "";
-        for(std::vector<std::string>::const_iterator it = rccOptions.begin();
-            it != rccOptions.end();
-            ++it)
-          {
+        }
+        const char* listSep = "";
+        for (std::vector<std::string>::const_iterator it = rccOptions.begin();
+             it != rccOptions.end(); ++it) {
           rccFileOptions += listSep;
           rccFileOptions += *it;
           listSep = "@list_sep@";
-          }
+        }
         optionSep = ";";
 
         std::vector<std::string> depends;
 
         std::string entriesList;
-        if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
-          {
-          if (qtMajorVersion == "5")
-            {
+        if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
+          if (qtMajorVersion == "5") {
             entriesList = ListQt5RccInputs(sf, target, depends);
-            }
-          else
-            {
+          } else {
             entriesList = ListQt4RccInputs(sf, depends);
-            }
-          if (entriesList.empty())
-            {
+          }
+          if (entriesList.empty()) {
             return;
-            }
           }
+        }
         qrcInputs += qrcInputsSep;
         qrcInputs += entriesList;
         qrcInputsSep = ";";
-        }
       }
     }
-  makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(),
-                      cmOutputConverter::EscapeForCMake(qrcInputs).c_str());
+  }
+  makefile->AddDefinition(
+    "_qt_rcc_inputs_" + target->GetName(),
+    cmOutputConverter::EscapeForCMake(qrcInputs).c_str());
 
-  makefile->AddDefinition("_rcc_files",
-          cmOutputConverter::EscapeForCMake(_rcc_files).c_str());
+  makefile->AddDefinition(
+    "_rcc_files", cmOutputConverter::EscapeForCMake(_rcc_files).c_str());
 
-  makefile->AddDefinition("_qt_rcc_options_files",
-              cmOutputConverter::EscapeForCMake(rccFileFiles).c_str());
-  makefile->AddDefinition("_qt_rcc_options_options",
-            cmOutputConverter::EscapeForCMake(rccFileOptions).c_str());
+  makefile->AddDefinition(
+    "_qt_rcc_options_files",
+    cmOutputConverter::EscapeForCMake(rccFileFiles).c_str());
+  makefile->AddDefinition(
+    "_qt_rcc_options_options",
+    cmOutputConverter::EscapeForCMake(rccFileOptions).c_str());
 
   makefile->AddDefinition("_qt_rcc_executable",
-              GetRccExecutable(target).c_str());
+                          GetRccExecutable(target).c_str());
 }
 
 void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
-    cmGeneratorTarget* target)
+  cmGeneratorTarget* target)
 {
   cmMakefile* makefile = target->Target->GetMakefile();
 
-  if (target->GetPropertyAsBool("AUTOMOC"))
-    {
+  if (target->GetPropertyAsBool("AUTOMOC")) {
     std::string automocTargetName = GetAutogenTargetName(target);
     std::string mocCppFile = makefile->GetCurrentBinaryDirectory();
     mocCppFile += "/";
     mocCppFile += automocTargetName;
     mocCppFile += ".cpp";
     makefile->GetOrCreateSource(mocCppFile, true);
-    makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
-                            mocCppFile.c_str(), false);
+    makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(),
+                             false);
 
     target->AddSource(mocCppFile);
-    }
+  }
 }
 
 void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
-                                                 cmLocalGenerator* lg,
-                                                 cmGeneratorTarget* target)
+  cmLocalGenerator* lg, cmGeneratorTarget* target)
 {
   cmMakefile* makefile = target->Target->GetMakefile();
 
   std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
-  if (qtMajorVersion == "")
-    {
+  if (qtMajorVersion == "") {
     qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
-    }
+  }
 
   // create a custom target for running generators at buildtime:
   std::string autogenTargetName = GetAutogenTargetName(target);
@@ -768,48 +730,41 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   cmCustomCommandLines commandLines;
   commandLines.push_back(currentLine);
 
-  std::string workingDirectory = cmSystemTools::CollapseFullPath(
-                                    "", makefile->GetCurrentBinaryDirectory());
+  std::string workingDirectory =
+    cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
 
   std::vector<std::string> depends;
-  if (const char *autogenDepends =
-                                target->GetProperty("AUTOGEN_TARGET_DEPENDS"))
-    {
+  if (const char* autogenDepends =
+        target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
     cmSystemTools::ExpandListArgument(autogenDepends, depends);
-    }
+  }
   std::vector<std::string> toolNames;
-  if (target->GetPropertyAsBool("AUTOMOC"))
-    {
+  if (target->GetPropertyAsBool("AUTOMOC")) {
     toolNames.push_back("moc");
-    }
-  if (target->GetPropertyAsBool("AUTOUIC"))
-    {
+  }
+  if (target->GetPropertyAsBool("AUTOUIC")) {
     toolNames.push_back("uic");
-    }
-  if (target->GetPropertyAsBool("AUTORCC"))
-    {
+  }
+  if (target->GetPropertyAsBool("AUTORCC")) {
     toolNames.push_back("rcc");
-    }
+  }
 
   std::string tools = toolNames[0];
   toolNames.erase(toolNames.begin());
-  while (toolNames.size() > 1)
-    {
+  while (toolNames.size() > 1) {
     tools += ", " + toolNames[0];
     toolNames.erase(toolNames.begin());
-    }
-  if (toolNames.size() == 1)
-    {
+  }
+  if (toolNames.size() == 1) {
     tools += " and " + toolNames[0];
-    }
+  }
   std::string autogenComment = "Automatic " + tools + " for target ";
   autogenComment += target->GetName();
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
   bool usePRE_BUILD = false;
   cmGlobalGenerator* gg = lg->GetGlobalGenerator();
-  if(gg->GetName().find("Visual Studio") != std::string::npos)
-    {
+  if (gg->GetName().find("Visual Studio") != std::string::npos) {
     cmGlobalVisualStudioGenerator* vsgg =
       static_cast<cmGlobalVisualStudioGenerator*>(gg);
     // Under VS >= 7 use a PRE_BUILD event instead of a separate target to
@@ -817,81 +772,70 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
     // This also works around a VS 11 bug that may skip updating the target:
     //  https://connect.microsoft.com/VisualStudio/feedback/details/769495
     usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
-    if(usePRE_BUILD)
-      {
+    if (usePRE_BUILD) {
       for (std::vector<std::string>::iterator it = depends.begin();
-            it != depends.end(); ++it)
-        {
-        if(!makefile->FindTargetToUse(it->c_str()))
-          {
+           it != depends.end(); ++it) {
+        if (!makefile->FindTargetToUse(it->c_str())) {
           usePRE_BUILD = false;
           break;
-          }
         }
       }
     }
+  }
 #endif
 
   std::vector<std::string> rcc_output;
-  bool const isNinja =
-    lg->GetGlobalGenerator()->GetName() == "Ninja";
-  if(isNinja
+  bool const isNinja = lg->GetGlobalGenerator()->GetName() == "Ninja";
+  if (isNinja
 #if defined(_WIN32) && !defined(__CYGWIN__)
-        || usePRE_BUILD
+      || usePRE_BUILD
 #endif
-        )
-    {
+      ) {
     std::vector<cmSourceFile*> srcFiles;
     target->GetConfigCommonSourceFiles(srcFiles);
-    for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
-        fileIt != srcFiles.end();
-        ++fileIt)
-      {
+    for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+         fileIt != srcFiles.end(); ++fileIt) {
       cmSourceFile* sf = *fileIt;
-      std::string absFile = cmsys::SystemTools::GetRealPath(
-                                                sf->GetFullPath());
+      std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
 
       std::string ext = sf->GetExtension();
 
-      if (target->GetPropertyAsBool("AUTORCC"))
-        {
-        if (ext == "qrc"
-            && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
+      if (target->GetPropertyAsBool("AUTORCC")) {
+        if (ext == "qrc" &&
+            !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) {
+
           {
-          std::string basename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(absFile);
-
-          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";
-          rcc_output.push_back(rcc_output_file);
-
-          if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
-            {
-            if (qtMajorVersion == "5")
-              {
+            std::string rcc_output_dir = GetAutogenTargetBuildDir(target);
+            rcc_output_dir += GetSourceRelativePath(target, absFile);
+            cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+
+            std::string basename =
+              cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
+            std::string rcc_output_file = rcc_output_dir;
+            rcc_output_file += "qrc_" + basename + ".cpp";
+            rcc_output.push_back(rcc_output_file);
+          }
+
+          if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
+            if (qtMajorVersion == "5") {
               ListQt5RccInputs(sf, target, depends);
-              }
-            else
-              {
+            } else {
               ListQt4RccInputs(sf, depends);
-              }
+            }
 #if defined(_WIN32) && !defined(__CYGWIN__)
             // Cannot use PRE_BUILD because the resource files themselves
             // may not be sources within the target so VS may not know the
             // target needs to re-build at all.
             usePRE_BUILD = false;
 #endif
-            }
           }
         }
       }
     }
+  }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  if(usePRE_BUILD)
-    {
+  if (usePRE_BUILD) {
     // Add the pre-build command directly to bypass the OBJECT_LIBRARY
     // rejection in cmMakefile::AddCustomCommandToTarget because we know
     // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
@@ -903,43 +847,37 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
     cc.SetEscapeOldStyle(false);
     cc.SetEscapeAllowMakeVars(true);
     target->Target->AddPreBuildCommand(cc);
-    }
-  else
+  } else
 #endif
-    {
+  {
     cmTarget* autogenTarget = makefile->AddUtilityCommand(
-                                autogenTargetName, true,
-                                workingDirectory.c_str(),
-                                /*byproducts=*/rcc_output, depends,
-                                commandLines, false, autogenComment.c_str());
+      autogenTargetName, true, workingDirectory.c_str(),
+      /*byproducts=*/rcc_output, depends, commandLines, false,
+      autogenComment.c_str());
 
     cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
     lg->AddGeneratorTarget(gt);
 
     // Set target folder
-    const char* autogenFolder = makefile->GetState()
-                                ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
-    if (!autogenFolder)
-      {
-      autogenFolder = makefile->GetState()
-                                ->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
-      }
-    if (autogenFolder && *autogenFolder)
-      {
+    const char* autogenFolder =
+      makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
+    if (!autogenFolder) {
+      autogenFolder =
+        makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
+    }
+    if (autogenFolder && *autogenFolder) {
       autogenTarget->SetProperty("FOLDER", autogenFolder);
-      }
-    else
-      {
+    } else {
       // inherit FOLDER property from target (#13688)
       copyTargetProperty(gt->Target, target->Target, "FOLDER");
-      }
+    }
 
     target->Target->AddUtility(autogenTargetName);
-    }
+  }
 }
 
 void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
-    cmGeneratorTarget const* target)
+  cmGeneratorTarget const* target)
 {
   cmMakefile* makefile = target->Target->GetMakefile();
 
@@ -950,27 +888,27 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
   // create a custom target for running generators at buildtime:
   std::string autogenTargetName = GetAutogenTargetName(target);
 
-  makefile->AddDefinition("_moc_target_name",
-          cmOutputConverter::EscapeForCMake(autogenTargetName).c_str());
-  makefile->AddDefinition("_origin_target_name",
-          cmOutputConverter::EscapeForCMake(target->GetName()).c_str());
+  makefile->AddDefinition(
+    "_moc_target_name",
+    cmOutputConverter::EscapeForCMake(autogenTargetName).c_str());
+  makefile->AddDefinition(
+    "_origin_target_name",
+    cmOutputConverter::EscapeForCMake(target->GetName()).c_str());
 
   std::string targetDir = GetAutogenTargetDir(target);
 
-  const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
-  if (!qtVersion)
-    {
+  const char* qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+  if (!qtVersion) {
     qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
-    }
-  if (const char *targetQtVersion =
-      target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
-    {
+  }
+  if (const char* targetQtVersion =
+        target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION",
+                                                        "")) {
     qtVersion = targetQtVersion;
-    }
-  if (qtVersion)
-    {
+  }
+  if (qtVersion) {
     makefile->AddDefinition("_target_qt_version", qtVersion);
-    }
+  }
 
   std::vector<std::string> skipUic;
   std::vector<std::string> skipMoc;
@@ -980,38 +918,34 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
   std::map<std::string, std::string> configDefines;
   std::map<std::string, std::string> configUicOptions;
 
-  if (target->GetPropertyAsBool("AUTOMOC")
-      || target->GetPropertyAsBool("AUTOUIC")
-      || target->GetPropertyAsBool("AUTORCC"))
-    {
+  if (target->GetPropertyAsBool("AUTOMOC") ||
+      target->GetPropertyAsBool("AUTOUIC") ||
+      target->GetPropertyAsBool("AUTORCC")) {
     SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic);
-    }
-  makefile->AddDefinition("_cpp_files",
-          cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
-  if (target->GetPropertyAsBool("AUTOMOC"))
-    {
-    SetupAutoMocTarget(target, autogenTargetName,
-                             skipMoc, mocHeaders,
-                             configIncludes, configDefines);
-    }
-  if (target->GetPropertyAsBool("AUTOUIC"))
-    {
+  }
+  makefile->AddDefinition(
+    "_cpp_files",
+    cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
+  if (target->GetPropertyAsBool("AUTOMOC")) {
+    SetupAutoMocTarget(target, autogenTargetName, skipMoc, mocHeaders,
+                       configIncludes, configDefines);
+  }
+  if (target->GetPropertyAsBool("AUTOUIC")) {
     SetupAutoUicTarget(target, skipUic, configUicOptions);
-    }
-  if (target->GetPropertyAsBool("AUTORCC"))
-    {
+  }
+  if (target->GetPropertyAsBool("AUTORCC")) {
     SetupAutoRccTarget(target);
-    }
+  }
 
-  const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
-  std::string inputFile = cmakeRoot;
+  std::string inputFile = cmSystemTools::GetCMakeRoot();
   inputFile += "/Modules/AutogenInfo.cmake.in";
   std::string outputFile = targetDir;
   outputFile += "/AutogenInfo.cmake";
-  makefile->AddDefinition("_qt_rcc_inputs",
-              makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName()));
-  makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
-                          false, true, false);
+  makefile->AddDefinition(
+    "_qt_rcc_inputs",
+    makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName()));
+  makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), false, true,
+                          false);
 
   // Ensure we have write permission in case .in was read-only.
   mode_t perm = 0;
@@ -1021,52 +955,45 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
   mode_t mode_write = S_IWUSR;
 #endif
   cmSystemTools::GetPermissions(outputFile, perm);
-  if (!(perm & mode_write))
-    {
+  if (!(perm & mode_write)) {
     cmSystemTools::SetPermissions(outputFile, perm | mode_write);
-    }
-  if (!configDefines.empty()
-      || !configIncludes.empty()
-      || !configUicOptions.empty())
-    {
+  }
+  if (!configDefines.empty() || !configIncludes.empty() ||
+      !configUicOptions.empty()) {
     cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app);
-    if ( !infoFile )
-      {
+    if (!infoFile) {
       std::string error = "Internal CMake error when trying to open file: ";
-      error += outputFile.c_str();
+      error += outputFile;
       error += " for writing.";
       cmSystemTools::Error(error.c_str());
       return;
-      }
-    if (!configDefines.empty())
-      {
+    }
+    if (!configDefines.empty()) {
       for (std::map<std::string, std::string>::iterator
-            it = configDefines.begin(), end = configDefines.end();
-            it != end; ++it)
-        {
-        infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first <<
-          " " << it->second << ")\n";
-        }
+             it = configDefines.begin(),
+             end = configDefines.end();
+           it != end; ++it) {
+        infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << " "
+                 << it->second << ")\n";
       }
-    if (!configIncludes.empty())
-      {
+    }
+    if (!configIncludes.empty()) {
       for (std::map<std::string, std::string>::iterator
-            it = configIncludes.begin(), end = configIncludes.end();
-            it != end; ++it)
-        {
-        infoFile << "set(AM_MOC_INCLUDES_" << it->first <<
-          " " << it->second << ")\n";
-        }
+             it = configIncludes.begin(),
+             end = configIncludes.end();
+           it != end; ++it) {
+        infoFile << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second
+                 << ")\n";
       }
-    if (!configUicOptions.empty())
-      {
+    }
+    if (!configUicOptions.empty()) {
       for (std::map<std::string, std::string>::iterator
-            it = configUicOptions.begin(), end = configUicOptions.end();
-            it != end; ++it)
-        {
-        infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first <<
-          " " << it->second << ")\n";
-        }
+             it = configUicOptions.begin(),
+             end = configUicOptions.end();
+           it != end; ++it) {
+        infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " "
+                 << it->second << ")\n";
       }
     }
+  }
 }
diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h
index eaf140d..b411597 100644
--- a/Source/cmQtAutoGeneratorInitializer.h
+++ b/Source/cmQtAutoGeneratorInitializer.h
@@ -16,9 +16,9 @@
 
 #include "cmStandardIncludes.h"
 
+#include <map>
 #include <string>
 #include <vector>
-#include <map>
 
 class cmSourceFile;
 class cmGeneratorTarget;
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index b16eccd..ac64397 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -11,160 +11,133 @@
   See the License for more information.
 ============================================================================*/
 
+#include "cmQtAutoGenerators.h"
+
+#include "cmAlgorithms.h"
 #include "cmGlobalGenerator.h"
-#include "cmOutputConverter.h"
 #include "cmMakefile.h"
-#include "cmSystemTools.h"
+#include "cmOutputConverter.h"
 #include "cmState.h"
-#include "cmAlgorithms.h"
+#include "cmSystemTools.h"
 
 #include <sys/stat.h>
 
-#include <cmsys/Terminal.h>
-#include <cmsys/FStream.hxx>
 #include <assert.h>
+#include <cmsys/FStream.hxx>
+#include <cmsys/Terminal.h>
 
 #include <string.h>
 #if defined(__APPLE__)
 #include <unistd.h>
 #endif
 
-#include "cmQtAutoGenerators.h"
-
-static bool requiresMocing(const std::string& text, std::string &macroName)
+static bool requiresMocing(const std::string& text, std::string& macroName)
 {
   // this simple check is much much faster than the regexp
-  if (strstr(text.c_str(), "Q_OBJECT") == NULL
-      && strstr(text.c_str(), "Q_GADGET") == NULL)
-    {
+  if (strstr(text.c_str(), "Q_OBJECT") == NULL &&
+      strstr(text.c_str(), "Q_GADGET") == NULL) {
     return false;
-    }
+  }
 
   cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
-  if (qObjectRegExp.find(text))
-    {
+  if (qObjectRegExp.find(text)) {
     macroName = "Q_OBJECT";
     return true;
-    }
+  }
   cmsys::RegularExpression qGadgetRegExp("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]");
-  if (qGadgetRegExp.find(text))
-    {
+  if (qGadgetRegExp.find(text)) {
     macroName = "Q_GADGET";
     return true;
-    }
+  }
   return false;
 }
 
-
-static std::string findMatchingHeader(const std::string& absPath,
-                                      const std::string& mocSubDir,
-                                      const std::string& basename,
-                              const std::vector<std::string>& headerExtensions)
+static std::string findMatchingHeader(
+  const std::string& absPath, const std::string& mocSubDir,
+  const std::string& basename,
+  const std::vector<std::string>& headerExtensions)
 {
   std::string header;
-  for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
-      ext != headerExtensions.end();
-      ++ext)
-    {
+  for (std::vector<std::string>::const_iterator ext = headerExtensions.begin();
+       ext != headerExtensions.end(); ++ext) {
     std::string sourceFilePath = absPath + basename + "." + (*ext);
-    if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
-      {
+    if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) {
       header = sourceFilePath;
       break;
-      }
-    if (!mocSubDir.empty())
-      {
+    }
+    if (!mocSubDir.empty()) {
       sourceFilePath = mocSubDir + basename + "." + (*ext);
-      if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
-        {
+      if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) {
         header = sourceFilePath;
         break;
-        }
       }
     }
+  }
 
   return header;
 }
 
-
 static std::string extractSubDir(const std::string& absPath,
                                  const std::string& currentMoc)
 {
   std::string subDir;
-  if (currentMoc.find_first_of('/') != std::string::npos)
-    {
-    subDir = absPath
-                  + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
-    }
+  if (currentMoc.find_first_of('/') != std::string::npos) {
+    subDir = absPath + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
+  }
   return subDir;
 }
 
 cmQtAutoGenerators::cmQtAutoGenerators()
-:Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
-,ColorOutput(true)
-,RunMocFailed(false)
-,RunUicFailed(false)
-,RunRccFailed(false)
-,GenerateAll(false)
+  : Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
+  , ColorOutput(true)
+  , RunMocFailed(false)
+  , RunUicFailed(false)
+  , RunRccFailed(false)
+  , GenerateAll(false)
 {
 
   std::string colorEnv = "";
   cmsys::SystemTools::GetEnv("COLOR", colorEnv);
-  if(!colorEnv.empty())
-    {
-    if(cmSystemTools::IsOn(colorEnv.c_str()))
-      {
+  if (!colorEnv.empty()) {
+    if (cmSystemTools::IsOn(colorEnv.c_str())) {
       this->ColorOutput = true;
-      }
-    else
-      {
+    } else {
       this->ColorOutput = false;
-      }
     }
+  }
 }
 
-void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts,
-                         const std::vector<std::string> &fileOpts,
-                         bool isQt5)
+void cmQtAutoGenerators::MergeUicOptions(
+  std::vector<std::string>& opts, const std::vector<std::string>& fileOpts,
+  bool isQt5)
 {
-  static const char* valueOptions[] = {
-    "tr",
-    "translate",
-    "postfix",
-    "generator",
-    "include", // Since Qt 5.3
-    "g"
-  };
+  static const char* valueOptions[] = { "tr",      "translate",
+                                        "postfix", "generator",
+                                        "include", // Since Qt 5.3
+                                        "g" };
   std::vector<std::string> extraOpts;
-  for(std::vector<std::string>::const_iterator it = fileOpts.begin();
-      it != fileOpts.end(); ++it)
-    {
-    std::vector<std::string>::iterator existingIt
-                                  = std::find(opts.begin(), opts.end(), *it);
-    if (existingIt != opts.end())
-      {
-      const char *o = it->c_str();
-      if (*o == '-')
-        {
+  for (std::vector<std::string>::const_iterator it = fileOpts.begin();
+       it != fileOpts.end(); ++it) {
+    std::vector<std::string>::iterator existingIt =
+      std::find(opts.begin(), opts.end(), *it);
+    if (existingIt != opts.end()) {
+      const char* o = it->c_str();
+      if (*o == '-') {
         ++o;
-        }
-      if (isQt5 && *o == '-')
-        {
+      }
+      if (isQt5 && *o == '-') {
         ++o;
-        }
+      }
       if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
-                  cmStrCmp(*it)) != cmArrayEnd(valueOptions))
-        {
+                       cmStrCmp(*it)) != cmArrayEnd(valueOptions)) {
         assert(existingIt + 1 != opts.end());
         *(existingIt + 1) = *(it + 1);
         ++it;
-        }
       }
-    else
-      {
+    } else {
       extraOpts.push_back(*it);
-      }
     }
+  }
   opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
 }
 
@@ -190,160 +163,144 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
 
   this->Init();
 
-  if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
-    {
+  if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") {
     success = this->RunAutogen(mf.get());
-    }
+  }
 
   this->WriteOldMocDefinitionsFile(targetDirectory);
 
   return success;
 }
 
-bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
-                                      const std::string& targetDirectory,
-                                      const std::string& config)
+bool cmQtAutoGenerators::ReadAutogenInfoFile(
+  cmMakefile* makefile, const std::string& targetDirectory,
+  const std::string& config)
 {
-  std::string filename(
-      cmSystemTools::CollapseFullPath(targetDirectory));
+  std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
   cmSystemTools::ConvertToUnixSlashes(filename);
   filename += "/AutogenInfo.cmake";
 
-  if (!makefile->ReadListFile(filename.c_str()))
-    {
+  if (!makefile->ReadListFile(filename.c_str())) {
     cmSystemTools::Error("Error processing file: ", filename.c_str());
     return false;
-    }
+  }
 
   this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR");
-  if (this->QtMajorVersion == "")
-    {
-    this->QtMajorVersion = makefile->GetSafeDefinition(
-                                     "AM_Qt5Core_VERSION_MAJOR");
-    }
+  if (this->QtMajorVersion == "") {
+    this->QtMajorVersion =
+      makefile->GetSafeDefinition("AM_Qt5Core_VERSION_MAJOR");
+  }
   this->Sources = makefile->GetSafeDefinition("AM_SOURCES");
   {
-  std::string rccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES");
-  cmSystemTools::ExpandListArgument(rccSources, this->RccSources);
+    std::string rccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES");
+    cmSystemTools::ExpandListArgument(rccSources, this->RccSources);
   }
   this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC");
   this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC");
   this->Headers = makefile->GetSafeDefinition("AM_HEADERS");
-  this->IncludeProjectDirsBefore = makefile->IsOn(
-                                "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
+  this->IncludeProjectDirsBefore =
+    makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
   this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR");
   this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR");
   this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE");
   this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE");
   this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE");
   {
-  std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS";
-  std::string compileDefsProp = compileDefsPropOrig;
-  if(!config.empty())
-    {
-    compileDefsProp += "_";
-    compileDefsProp += config;
+    std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS";
+    std::string compileDefsProp = compileDefsPropOrig;
+    if (!config.empty()) {
+      compileDefsProp += "_";
+      compileDefsProp += config;
     }
-  const char *compileDefs = makefile->GetDefinition(compileDefsProp);
-  this->MocCompileDefinitionsStr = compileDefs ? compileDefs
-                  : makefile->GetSafeDefinition(compileDefsPropOrig);
+    const char* compileDefs = makefile->GetDefinition(compileDefsProp);
+    this->MocCompileDefinitionsStr = compileDefs
+      ? compileDefs
+      : makefile->GetSafeDefinition(compileDefsPropOrig);
   }
   {
-  std::string includesPropOrig = "AM_MOC_INCLUDES";
-  std::string includesProp = includesPropOrig;
-  if(!config.empty())
-    {
-    includesProp += "_";
-    includesProp += config;
+    std::string includesPropOrig = "AM_MOC_INCLUDES";
+    std::string includesProp = includesPropOrig;
+    if (!config.empty()) {
+      includesProp += "_";
+      includesProp += config;
     }
-  const char *includes = makefile->GetDefinition(includesProp);
-  this->MocIncludesStr = includes ? includes
-                      : makefile->GetSafeDefinition(includesPropOrig);
+    const char* includes = makefile->GetDefinition(includesProp);
+    this->MocIncludesStr =
+      includes ? includes : 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");
+  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.empty())
-    {
-    uicOptionsProp += "_";
-    uicOptionsProp += config;
+    const char* uicOptionsFiles =
+      makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES");
+    std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS";
+    std::string uicOptionsProp = uicOptionsPropOrig;
+    if (!config.empty()) {
+      uicOptionsProp += "_";
+      uicOptionsProp += config;
     }
-  const char *uicTargetOptions
-                        = makefile->GetSafeDefinition(uicOptionsProp);
-  cmSystemTools::ExpandListArgument(
+    const char* uicTargetOptions = makefile->GetSafeDefinition(uicOptionsProp);
+    cmSystemTools::ExpandListArgument(
       uicTargetOptions ? uicTargetOptions
-                    : makefile->GetSafeDefinition(uicOptionsPropOrig),
-    this->UicTargetOptions);
-  const char *uicOptionsOptions
-                      = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS");
-  std::vector<std::string> uicFilesVec;
-  cmSystemTools::ExpandListArgument(uicOptionsFiles, uicFilesVec);
-  std::vector<std::string> uicOptionsVec;
-  cmSystemTools::ExpandListArgument(uicOptionsOptions, uicOptionsVec);
-  if (uicFilesVec.size() != uicOptionsVec.size())
-    {
-    return false;
+                       : makefile->GetSafeDefinition(uicOptionsPropOrig),
+      this->UicTargetOptions);
+    const char* uicOptionsOptions =
+      makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS");
+    std::vector<std::string> uicFilesVec;
+    cmSystemTools::ExpandListArgument(uicOptionsFiles, uicFilesVec);
+    std::vector<std::string> uicOptionsVec;
+    cmSystemTools::ExpandListArgument(uicOptionsOptions, uicOptionsVec);
+    if (uicFilesVec.size() != uicOptionsVec.size()) {
+      return false;
     }
-  for (std::vector<std::string>::iterator fileIt = uicFilesVec.begin(),
+    for (std::vector<std::string>::iterator fileIt = uicFilesVec.begin(),
                                             optionIt = uicOptionsVec.begin();
-                                            fileIt != uicFilesVec.end();
-                                            ++fileIt, ++optionIt)
-    {
-    cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
-    this->UicOptions[*fileIt] = *optionIt;
+         fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) {
+      cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
+      this->UicOptions[*fileIt] = *optionIt;
     }
   }
   {
-  const char *rccOptionsFiles
-                        = makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES");
-  const char *rccOptionsOptions
-                      = makefile->GetSafeDefinition("AM_RCC_OPTIONS_OPTIONS");
-  std::vector<std::string> rccFilesVec;
-  cmSystemTools::ExpandListArgument(rccOptionsFiles, rccFilesVec);
-  std::vector<std::string> rccOptionsVec;
-  cmSystemTools::ExpandListArgument(rccOptionsOptions, rccOptionsVec);
-  if (rccFilesVec.size() != rccOptionsVec.size())
-    {
-    return false;
+    const char* rccOptionsFiles =
+      makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES");
+    const char* rccOptionsOptions =
+      makefile->GetSafeDefinition("AM_RCC_OPTIONS_OPTIONS");
+    std::vector<std::string> rccFilesVec;
+    cmSystemTools::ExpandListArgument(rccOptionsFiles, rccFilesVec);
+    std::vector<std::string> rccOptionsVec;
+    cmSystemTools::ExpandListArgument(rccOptionsOptions, rccOptionsVec);
+    if (rccFilesVec.size() != rccOptionsVec.size()) {
+      return false;
     }
-  for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(),
+    for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(),
                                             optionIt = rccOptionsVec.begin();
-                                            fileIt != rccFilesVec.end();
-                                            ++fileIt, ++optionIt)
-    {
-    cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
-    this->RccOptions[*fileIt] = *optionIt;
+         fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
+      cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
+      this->RccOptions[*fileIt] = *optionIt;
     }
 
-  const char *rccInputs = makefile->GetSafeDefinition("AM_RCC_INPUTS");
-  std::vector<std::string> rccInputLists;
-  cmSystemTools::ExpandListArgument(rccInputs, rccInputLists);
+    const char* rccInputs = makefile->GetSafeDefinition("AM_RCC_INPUTS");
+    std::vector<std::string> rccInputLists;
+    cmSystemTools::ExpandListArgument(rccInputs, rccInputLists);
 
-  if (this->RccSources.size() != rccInputLists.size())
-    {
-    cmSystemTools::Error("Error processing file: ", filename.c_str());
-    return false;
+    if (this->RccSources.size() != rccInputLists.size()) {
+      cmSystemTools::Error("Error processing file: ", filename.c_str());
+      return false;
     }
 
-  for (std::vector<std::string>::iterator fileIt = this->RccSources.begin(),
+    for (std::vector<std::string>::iterator fileIt = this->RccSources.begin(),
                                             inputIt = rccInputLists.begin();
-                                            fileIt != this->RccSources.end();
-                                            ++fileIt, ++inputIt)
-    {
-    cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";");
-    std::vector<std::string> rccInputFiles;
-    cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
+         fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
+      cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";");
+      std::vector<std::string> rccInputFiles;
+      cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
 
-    this->RccInputs[*fileIt] = rccInputFiles;
+      this->RccInputs[*fileIt] = rccInputFiles;
     }
   }
   this->CurrentCompileSettingsStr = this->MakeCompileSettingsString(makefile);
@@ -353,7 +310,6 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
   return true;
 }
 
-
 std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile)
 {
   std::string s;
@@ -370,58 +326,51 @@ std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile)
   return s;
 }
 
-
-bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile,
-                                            const std::string& targetDirectory)
+bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(
+  cmMakefile* makefile, const std::string& targetDirectory)
 {
-  std::string filename(
-      cmSystemTools::CollapseFullPath(targetDirectory));
+  std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
   cmSystemTools::ConvertToUnixSlashes(filename);
   filename += "/AutomocOldMocDefinitions.cmake";
 
-  if (makefile->ReadListFile(filename.c_str()))
-    {
+  if (makefile->ReadListFile(filename.c_str())) {
     this->OldCompileSettingsStr =
-                        makefile->GetSafeDefinition("AM_OLD_COMPILE_SETTINGS");
-    }
+      makefile->GetSafeDefinition("AM_OLD_COMPILE_SETTINGS");
+  }
   return true;
 }
 
-
-void
-cmQtAutoGenerators::WriteOldMocDefinitionsFile(
-                                            const std::string& targetDirectory)
+void cmQtAutoGenerators::WriteOldMocDefinitionsFile(
+  const std::string& targetDirectory)
 {
-  std::string filename(
-      cmSystemTools::CollapseFullPath(targetDirectory));
+  std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
   cmSystemTools::ConvertToUnixSlashes(filename);
   filename += "/AutomocOldMocDefinitions.cmake";
 
   cmsys::ofstream outfile;
-  outfile.open(filename.c_str(),
-               std::ios::trunc);
+  outfile.open(filename.c_str(), std::ios::trunc);
   outfile << "set(AM_OLD_COMPILE_SETTINGS "
-              << cmOutputConverter::EscapeForCMake(
-                 this->CurrentCompileSettingsStr) << ")\n";
+          << cmOutputConverter::EscapeForCMake(this->CurrentCompileSettingsStr)
+          << ")\n";
 
   outfile.close();
 }
 
-
 void cmQtAutoGenerators::Init()
 {
-  this->OutMocCppFilename = this->Builddir;
-  this->OutMocCppFilename += this->TargetName;
-  this->OutMocCppFilename += ".cpp";
+  this->TargetBuildSubDir = this->TargetName;
+  this->TargetBuildSubDir += ".dir/";
+
+  this->OutMocCppFilenameRel = this->TargetName;
+  this->OutMocCppFilenameRel += ".cpp";
+  this->OutMocCppFilenameAbs = this->Builddir + this->OutMocCppFilenameRel;
 
   std::vector<std::string> cdefList;
   cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
-  for(std::vector<std::string>::const_iterator it = cdefList.begin();
-      it != cdefList.end();
-      ++it)
-    {
+  for (std::vector<std::string>::const_iterator it = cdefList.begin();
+       it != cdefList.end(); ++it) {
     this->MocDefinitions.push_back("-D" + (*it));
-    }
+  }
 
   cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions);
 
@@ -429,69 +378,55 @@ void cmQtAutoGenerators::Init()
   cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths);
 
   std::set<std::string> frameworkPaths;
-  for(std::vector<std::string>::const_iterator it = incPaths.begin();
-      it != incPaths.end();
-      ++it)
-    {
-    const std::string &path = *it;
+  for (std::vector<std::string>::const_iterator it = incPaths.begin();
+       it != incPaths.end(); ++it) {
+    const std::string& path = *it;
     this->MocIncludes.push_back("-I" + path);
-    if (cmHasLiteralSuffix(path, ".framework/Headers"))
-      {
+    if (cmHasLiteralSuffix(path, ".framework/Headers")) {
       // Go up twice to get to the framework root
       std::vector<std::string> pathComponents;
       cmsys::SystemTools::SplitPath(path, pathComponents);
-      std::string frameworkPath =cmsys::SystemTools::JoinPath(
-                             pathComponents.begin(), pathComponents.end() - 2);
+      std::string frameworkPath = cmsys::SystemTools::JoinPath(
+        pathComponents.begin(), pathComponents.end() - 2);
       frameworkPaths.insert(frameworkPath);
-      }
     }
+  }
 
   for (std::set<std::string>::const_iterator it = frameworkPaths.begin();
-         it != frameworkPaths.end(); ++it)
-    {
+       it != frameworkPaths.end(); ++it) {
     this->MocIncludes.push_back("-F");
     this->MocIncludes.push_back(*it);
-    }
-
+  }
 
-    if (this->IncludeProjectDirsBefore)
-      {
-      const std::string binDir = "-I" + this->ProjectBinaryDir;
+  if (this->IncludeProjectDirsBefore) {
+    const std::string binDir = "-I" + this->ProjectBinaryDir;
 
-      const std::string srcDir = "-I" + this->ProjectSourceDir;
+    const std::string srcDir = "-I" + this->ProjectSourceDir;
 
-      std::list<std::string> sortedMocIncludes;
-      std::list<std::string>::iterator it = this->MocIncludes.begin();
-      while (it != this->MocIncludes.end())
-        {
-        if (this->StartsWith(*it, binDir))
-          {
-          sortedMocIncludes.push_back(*it);
-          it = this->MocIncludes.erase(it);
-          }
-        else
-          {
-          ++it;
-          }
-        }
-      it = this->MocIncludes.begin();
-      while (it != this->MocIncludes.end())
-        {
-        if (this->StartsWith(*it, srcDir))
-          {
-          sortedMocIncludes.push_back(*it);
-          it = this->MocIncludes.erase(it);
-          }
-        else
-          {
-          ++it;
-          }
-        }
-      sortedMocIncludes.insert(sortedMocIncludes.end(),
-                           this->MocIncludes.begin(), this->MocIncludes.end());
-      this->MocIncludes = sortedMocIncludes;
+    std::list<std::string> sortedMocIncludes;
+    std::list<std::string>::iterator it = this->MocIncludes.begin();
+    while (it != this->MocIncludes.end()) {
+      if (cmsys::SystemTools::StringStartsWith(*it, binDir.c_str())) {
+        sortedMocIncludes.push_back(*it);
+        it = this->MocIncludes.erase(it);
+      } else {
+        ++it;
+      }
     }
-
+    it = this->MocIncludes.begin();
+    while (it != this->MocIncludes.end()) {
+      if (cmsys::SystemTools::StringStartsWith(*it, srcDir.c_str())) {
+        sortedMocIncludes.push_back(*it);
+        it = this->MocIncludes.erase(it);
+      } else {
+        ++it;
+      }
+    }
+    sortedMocIncludes.insert(sortedMocIncludes.end(),
+                             this->MocIncludes.begin(),
+                             this->MocIncludes.end());
+    this->MocIncludes = sortedMocIncludes;
+  }
 }
 
 static std::string ReadAll(const std::string& filename)
@@ -505,11 +440,10 @@ static std::string ReadAll(const std::string& filename)
 
 bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
 {
-  if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str())
-    || (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr))
-    {
+  if (!cmsys::SystemTools::FileExists(this->OutMocCppFilenameAbs.c_str()) ||
+      (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr)) {
     this->GenerateAll = true;
-    }
+  }
 
   // the program goes through all .cpp files to see which moc files are
   // included. It is not really interesting how the moc file is named, but
@@ -528,7 +462,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
   cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
 
   const std::vector<std::string>& headerExtensions =
-      makefile->GetCMakeInstance()->GetHeaderExtensions();
+    makefile->GetCMakeInstance()->GetHeaderExtensions();
 
   std::map<std::string, std::vector<std::string> > includedUis;
   std::map<std::string, std::vector<std::string> > skippedUis;
@@ -536,47 +470,40 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
   cmSystemTools::ExpandListArgument(this->SkipUic, uicSkipped);
 
   for (std::vector<std::string>::const_iterator it = sourceFiles.begin();
-       it != sourceFiles.end();
-       ++it)
-    {
-    const bool skipUic = std::find(uicSkipped.begin(), uicSkipped.end(), *it)
-        != uicSkipped.end();
-    std::map<std::string, std::vector<std::string> >& uiFiles
-                                          = skipUic ? skippedUis : includedUis;
-    const std::string &absFilename = *it;
-    if (this->Verbose)
-      {
-      std::cout << "AUTOGEN: Checking " << absFilename << std::endl;
-      }
-    if (this->RelaxedMode)
-      {
-      this->ParseCppFile(absFilename, headerExtensions, includedMocs,
-                         uiFiles);
-      }
-    else
-      {
+       it != sourceFiles.end(); ++it) {
+    const bool skipUic =
+      std::find(uicSkipped.begin(), uicSkipped.end(), *it) != uicSkipped.end();
+    std::map<std::string, std::vector<std::string> >& uiFiles =
+      skipUic ? skippedUis : includedUis;
+    const std::string& absFilename = *it;
+    if (this->Verbose) {
+      std::stringstream err;
+      err << "AUTOGEN: Checking " << absFilename << std::endl;
+      this->LogInfo(err.str());
+    }
+    if (this->RelaxedMode) {
+      this->ParseCppFile(absFilename, headerExtensions, includedMocs, uiFiles);
+    } else {
       this->StrictParseCppFile(absFilename, headerExtensions, includedMocs,
                                uiFiles);
-      }
-    this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
     }
+    this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
+  }
 
   {
-  std::vector<std::string> mocSkipped;
-  cmSystemTools::ExpandListArgument(this->SkipMoc, mocSkipped);
-  for (std::vector<std::string>::const_iterator it = mocSkipped.begin();
-       it != mocSkipped.end();
-       ++it)
-    {
-    if (std::find(uicSkipped.begin(), uicSkipped.end(), *it)
-        != uicSkipped.end())
-      {
-      const std::string &absFilename = *it;
-      if (this->Verbose)
-        {
-        std::cout << "AUTOGEN: Checking " << absFilename << std::endl;
+    std::vector<std::string> mocSkipped;
+    cmSystemTools::ExpandListArgument(this->SkipMoc, mocSkipped);
+    for (std::vector<std::string>::const_iterator it = mocSkipped.begin();
+         it != mocSkipped.end(); ++it) {
+      if (std::find(uicSkipped.begin(), uicSkipped.end(), *it) !=
+          uicSkipped.end()) {
+        const std::string& absFilename = *it;
+        if (this->Verbose) {
+          std::stringstream err;
+          err << "AUTOGEN: Checking " << absFilename << std::endl;
+          this->LogInfo(err.str());
         }
-      this->ParseForUic(absFilename, includedUis);
+        this->ParseForUic(absFilename, includedUis);
       }
     }
   }
@@ -589,124 +516,66 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
   std::map<std::string, std::string> notIncludedMocs;
   this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis);
 
-  // run moc on all the moc's that are #included in source files
-  for(std::map<std::string, std::string>::const_iterator
-                                                     it = includedMocs.begin();
-      it != includedMocs.end();
-      ++it)
-    {
-    this->GenerateMoc(it->first, it->second);
-    }
-  for(std::map<std::string, std::vector<std::string> >::const_iterator
-      it = includedUis.begin();
-      it != includedUis.end();
-      ++it)
-    {
-    for (std::vector<std::string>::const_iterator nit = it->second.begin();
-        nit != it->second.end();
-        ++nit)
-      {
-      this->GenerateUi(it->first, *nit);
-      }
-    }
-
-  if(!this->RccExecutable.empty())
-    {
-    this->GenerateQrc();
-    }
-
-  std::stringstream outStream;
-  outStream << "/* This file is autogenerated, do not edit*/\n";
-
-  bool automocCppChanged = false;
-  if (notIncludedMocs.empty())
-    {
-    outStream << "enum some_compilers { need_more_than_nothing };\n";
-    }
-  else
-    {
-    // run moc on the remaining headers and include them in
-    // the _automoc.cpp file
-    for(std::map<std::string, std::string>::const_iterator
-                                                  it = notIncludedMocs.begin();
-        it != notIncludedMocs.end();
-        ++it)
-      {
-      bool mocSuccess = this->GenerateMoc(it->first, it->second);
-      if (mocSuccess)
-        {
-        automocCppChanged = true;
-        }
-      outStream << "#include \"" << it->second << "\"\n";
-      }
-    }
+  if (!this->MocExecutable.empty()) {
+    this->GenerateMocFiles(includedMocs, notIncludedMocs);
+  }
+  if (!this->UicExecutable.empty()) {
+    this->GenerateUiFiles(includedUis);
+  }
+  if (!this->RccExecutable.empty()) {
+    this->GenerateQrcFiles();
+  }
 
-  if (this->RunMocFailed)
-    {
-    std::cerr << "moc failed..." << std::endl;
+  if (this->RunMocFailed) {
+    std::stringstream err;
+    err << "moc failed..." << std::endl;
+    this->LogError(err.str());
     return false;
-    }
-
-  if (this->RunUicFailed)
-    {
-    std::cerr << "uic failed..." << std::endl;
+  }
+  if (this->RunUicFailed) {
+    std::stringstream err;
+    err << "uic failed..." << std::endl;
+    this->LogError(err.str());
     return false;
-    }
-  if (this->RunRccFailed)
-    {
-    std::cerr << "rcc failed..." << std::endl;
+  }
+  if (this->RunRccFailed) {
+    std::stringstream err;
+    err << "rcc failed..." << std::endl;
+    this->LogError(err.str());
     return false;
-    }
-  outStream.flush();
-  std::string automocSource = outStream.str();
-  if (!automocCppChanged)
-    {
-    // compare contents of the _automoc.cpp file
-    const std::string oldContents = ReadAll(this->OutMocCppFilename);
-    if (oldContents == automocSource)
-      {
-      // nothing changed: don't touch the _automoc.cpp file
-      return true;
-      }
-    }
-
-  // source file that includes all remaining moc files (_automoc.cpp file)
-  cmsys::ofstream outfile;
-  outfile.open(this->OutMocCppFilename.c_str(),
-               std::ios::trunc);
-  outfile << automocSource;
-  outfile.close();
+  }
 
   return true;
 }
 
-
-void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
-                const std::vector<std::string>& headerExtensions,
-                std::map<std::string, std::string>& includedMocs,
-                std::map<std::string, std::vector<std::string> > &includedUis)
+void cmQtAutoGenerators::ParseCppFile(
+  const std::string& absFilename,
+  const std::vector<std::string>& headerExtensions,
+  std::map<std::string, std::string>& includedMocs,
+  std::map<std::string, std::vector<std::string> >& includedUis)
 {
   cmsys::RegularExpression mocIncludeRegExp(
-              "[\n][ \t]*#[ \t]*include[ \t]+"
-              "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
+    "[\n][ \t]*#[ \t]*include[ \t]+"
+    "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
 
   const std::string contentsString = ReadAll(absFilename);
-  if (contentsString.empty())
-    {
-    std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
-              << std::endl;
+  if (contentsString.empty()) {
+    std::stringstream err;
+    err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
+        << std::endl;
+    this->LogError(err.str());
     return;
-    }
+  }
   this->ParseForUic(absFilename, contentsString, includedUis);
-  if (this->MocExecutable.empty())
-    {
+  if (this->MocExecutable.empty()) {
     return;
-    }
+  }
 
   const std::string absPath = cmsys::SystemTools::GetFilenamePath(
-                   cmsys::SystemTools::GetRealPath(absFilename)) + '/';
-  const std::string scannedFileBasename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(absFilename);
+                                cmsys::SystemTools::GetRealPath(absFilename)) +
+    '/';
+  const std::string scannedFileBasename =
+    cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
   std::string macroName;
   const bool requiresMoc = requiresMocing(contentsString, macroName);
   bool dotMocIncluded = false;
@@ -719,17 +588,14 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
   // first a simple string check for "moc" is *much* faster than the regexp,
   // and if the string search already fails, we don't have to try the
   // expensive regexp
-  if ((strstr(contentsString.c_str(), "moc") != NULL)
-                                    && (mocIncludeRegExp.find(contentsString)))
-    {
+  if ((strstr(contentsString.c_str(), "moc") != NULL) &&
+      (mocIncludeRegExp.find(contentsString))) {
     // for every moc include in the file
-    do
-      {
+    do {
       const std::string currentMoc = mocIncludeRegExp.match(1);
-      //std::cout << "found moc include: " << currentMoc << std::endl;
 
-      std::string basename = cmsys::SystemTools::
-                                   GetFilenameWithoutLastExtension(currentMoc);
+      std::string basename =
+        cmsys::SystemTools::GetFilenameWithoutLastExtension(currentMoc);
       const bool moc_style = cmHasLiteralPrefix(basename, "moc_");
 
       // If the moc include is of the moc_foo.cpp style we expect
@@ -738,163 +604,160 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
       // a Q_OBJECT macro in the current source file, if it contains the
       // macro we generate the moc file from the source file.
       // Q_OBJECT
-      if (moc_style)
-        {
+      if (moc_style) {
         // basename should be the part of the moc filename used for
         // finding the correct header, so we need to remove the moc_ part
         basename = basename.substr(4);
         std::string mocSubDir = extractSubDir(absPath, currentMoc);
-        std::string headerToMoc = findMatchingHeader(
-                               absPath, mocSubDir, basename, headerExtensions);
+        std::string headerToMoc =
+          findMatchingHeader(absPath, mocSubDir, basename, headerExtensions);
 
-        if (!headerToMoc.empty())
-          {
+        if (!headerToMoc.empty()) {
           includedMocs[headerToMoc] = currentMoc;
-          if (basename == scannedFileBasename)
-            {
+          if (basename == scannedFileBasename) {
             mocUnderscoreIncluded = true;
             ownMocUnderscoreFile = currentMoc;
             ownMocHeaderFile = headerToMoc;
-            }
           }
-        else
-          {
-          std::cerr << "AUTOGEN: error: " << absFilename << ": The file "
-                    << "includes the moc file \"" << currentMoc << "\", "
-                    << "but could not find header \"" << basename
-                    << '{' << this->Join(headerExtensions, ',') << "}\" ";
-          if (mocSubDir.empty())
-            {
-            std::cerr << "in " << absPath << "\n" << std::endl;
-            }
-          else
-            {
-            std::cerr << "neither in " << absPath
-                      << " nor in " << mocSubDir << "\n" << std::endl;
-            }
-
-          ::exit(EXIT_FAILURE);
+        } else {
+          std::stringstream err;
+          err << "AUTOGEN: error: " << absFilename << ": The file "
+              << "includes the moc file \"" << currentMoc << "\", "
+              << "but could not find header \"" << basename << '{'
+              << this->JoinExts(headerExtensions) << "}\" ";
+          if (mocSubDir.empty()) {
+            err << "in " << absPath << "\n" << std::endl;
+          } else {
+            err << "neither in " << absPath << " nor in " << mocSubDir << "\n"
+                << std::endl;
           }
+          this->LogError(err.str());
+          ::exit(EXIT_FAILURE);
         }
-      else
-        {
+      } else {
         std::string fileToMoc = absFilename;
-        if ((basename != scannedFileBasename) || (requiresMoc==false))
-          {
+        if ((basename != scannedFileBasename) || (requiresMoc == false)) {
           std::string mocSubDir = extractSubDir(absPath, currentMoc);
-          std::string headerToMoc = findMatchingHeader(
-                              absPath, mocSubDir, basename, headerExtensions);
-          if (!headerToMoc.empty())
-            {
+          std::string headerToMoc =
+            findMatchingHeader(absPath, mocSubDir, basename, headerExtensions);
+          if (!headerToMoc.empty()) {
             // this is for KDE4 compatibility:
             fileToMoc = headerToMoc;
-            if ((requiresMoc==false) &&(basename==scannedFileBasename))
-              {
-              std::cerr << "AUTOGEN: warning: " << absFilename << ": The file "
-                            "includes the moc file \"" << currentMoc <<
-                            "\", but does not contain a " << macroName
-                            << " macro. Running moc on "
-                        << "\"" << headerToMoc << "\" ! Include \"moc_"
-                        << basename << ".cpp\" for a compatiblity with "
-                           "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
-                        << std::endl;
-              }
-            else
-              {
-              std::cerr << "AUTOGEN: warning: " << absFilename << ": The file "
-                            "includes the moc file \"" << currentMoc <<
-                            "\" instead of \"moc_" << basename << ".cpp\". "
-                            "Running moc on "
-                        << "\"" << headerToMoc << "\" ! Include \"moc_"
-                        << basename << ".cpp\" for compatiblity with "
-                           "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
-                        << std::endl;
-              }
+            if ((requiresMoc == false) && (basename == scannedFileBasename)) {
+              std::stringstream err;
+              err << "AUTOGEN: warning: " << absFilename
+                  << ": The file "
+                     "includes the moc file \""
+                  << currentMoc << "\", but does not contain a " << macroName
+                  << " macro. Running moc on "
+                  << "\"" << headerToMoc << "\" ! Include \"moc_" << basename
+                  << ".cpp\" for a compatibility with "
+                     "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
+                  << std::endl;
+              this->LogError(err.str());
+            } else {
+              std::stringstream err;
+              err << "AUTOGEN: warning: " << absFilename
+                  << ": The file "
+                     "includes the moc file \""
+                  << currentMoc << "\" instead of \"moc_" << basename
+                  << ".cpp\". "
+                     "Running moc on "
+                  << "\"" << headerToMoc << "\" ! Include \"moc_" << basename
+                  << ".cpp\" for compatibility with "
+                     "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
+                  << std::endl;
+              this->LogError(err.str());
             }
-          else
-            {
-            std::cerr <<"AUTOGEN: error: " << absFilename << ": The file "
-                        "includes the moc file \"" << currentMoc <<
-                        "\", which seems to be the moc file from a different "
-                        "source file. CMake also could not find a matching "
-                        "header.\n" << std::endl;
+          } else {
+            std::stringstream err;
+            err << "AUTOGEN: error: " << absFilename
+                << ": The file "
+                   "includes the moc file \""
+                << currentMoc
+                << "\", which seems to be the moc file from a different "
+                   "source file. CMake also could not find a matching "
+                   "header.\n"
+                << std::endl;
+            this->LogError(err.str());
             ::exit(EXIT_FAILURE);
-            }
           }
-        else
-          {
+        } else {
           dotMocIncluded = true;
           ownDotMocFile = currentMoc;
-          }
-        includedMocs[fileToMoc] = currentMoc;
         }
+        includedMocs[fileToMoc] = currentMoc;
+      }
       matchOffset += mocIncludeRegExp.end();
-      } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
-    }
+    } while (mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
+  }
 
   // In this case, check whether the scanned file itself contains a Q_OBJECT.
   // If this is the case, the moc_foo.cpp should probably be generated from
   // foo.cpp instead of foo.h, because otherwise it won't build.
   // But warn, since this is not how it is supposed to be used.
-  if ((dotMocIncluded == false) && (requiresMoc == true))
-    {
-    if (mocUnderscoreIncluded == true)
-      {
+  if ((dotMocIncluded == false) && (requiresMoc == true)) {
+    if (mocUnderscoreIncluded == true) {
       // this is for KDE4 compatibility:
-      std::cerr << "AUTOGEN: warning: " << absFilename << ": The file "
-                << "contains a " << macroName << " macro, but does not "
-                "include "
-                << "\"" << scannedFileBasename << ".moc\", but instead "
-                   "includes "
-                << "\"" << ownMocUnderscoreFile  << "\". Running moc on "
-                << "\"" << absFilename << "\" ! Better include \""
-                << scannedFileBasename << ".moc\" for compatiblity with "
-                   "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
-                << std::endl;
+      std::stringstream err;
+      err << "AUTOGEN: warning: " << absFilename << ": The file "
+          << "contains a " << macroName << " macro, but does not "
+                                           "include "
+          << "\"" << scannedFileBasename << ".moc\", but instead "
+                                            "includes "
+          << "\"" << ownMocUnderscoreFile << "\". Running moc on "
+          << "\"" << absFilename << "\" ! Better include \""
+          << scannedFileBasename
+          << ".moc\" for compatibility with "
+             "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
+          << std::endl;
+      this->LogError(err.str());
+
       includedMocs[absFilename] = ownMocUnderscoreFile;
       includedMocs.erase(ownMocHeaderFile);
-      }
-    else
-      {
+    } else {
       // otherwise always error out since it will not compile:
-      std::cerr << "AUTOGEN: error: " << absFilename << ": The file "
-                << "contains a " << macroName << " macro, but does not "
-                "include "
-                << "\"" << scannedFileBasename << ".moc\" !\n"
-                << std::endl;
+      std::stringstream err;
+      err << "AUTOGEN: error: " << absFilename << ": The file "
+          << "contains a " << macroName << " macro, but does not "
+                                           "include "
+          << "\"" << scannedFileBasename << ".moc\" !\n"
+          << std::endl;
+      this->LogError(err.str());
+
       ::exit(EXIT_FAILURE);
-      }
     }
-
+  }
 }
 
-
-void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
-                const std::vector<std::string>& headerExtensions,
-                std::map<std::string, std::string>& includedMocs,
-                std::map<std::string, std::vector<std::string> >& includedUis)
+void cmQtAutoGenerators::StrictParseCppFile(
+  const std::string& absFilename,
+  const std::vector<std::string>& headerExtensions,
+  std::map<std::string, std::string>& includedMocs,
+  std::map<std::string, std::vector<std::string> >& includedUis)
 {
   cmsys::RegularExpression mocIncludeRegExp(
-              "[\n][ \t]*#[ \t]*include[ \t]+"
-              "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
+    "[\n][ \t]*#[ \t]*include[ \t]+"
+    "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
 
   const std::string contentsString = ReadAll(absFilename);
-  if (contentsString.empty())
-    {
-    std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
-              << std::endl;
+  if (contentsString.empty()) {
+    std::stringstream err;
+    err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
+        << std::endl;
+    this->LogError(err.str());
     return;
-    }
+  }
   this->ParseForUic(absFilename, contentsString, includedUis);
-  if (this->MocExecutable.empty())
-    {
+  if (this->MocExecutable.empty()) {
     return;
-    }
+  }
 
   const std::string absPath = cmsys::SystemTools::GetFilenamePath(
-                   cmsys::SystemTools::GetRealPath(absFilename)) + '/';
-  const std::string scannedFileBasename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(absFilename);
+                                cmsys::SystemTools::GetRealPath(absFilename)) +
+    '/';
+  const std::string scannedFileBasename =
+    cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
 
   bool dotMocIncluded = false;
 
@@ -902,16 +765,14 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
   // first a simple string check for "moc" is *much* faster than the regexp,
   // and if the string search already fails, we don't have to try the
   // expensive regexp
-  if ((strstr(contentsString.c_str(), "moc") != NULL)
-                                    && (mocIncludeRegExp.find(contentsString)))
-    {
+  if ((strstr(contentsString.c_str(), "moc") != NULL) &&
+      (mocIncludeRegExp.find(contentsString))) {
     // for every moc include in the file
-    do
-      {
+    do {
       const std::string currentMoc = mocIncludeRegExp.match(1);
 
-      std::string basename = cmsys::SystemTools::
-                                   GetFilenameWithoutLastExtension(currentMoc);
+      std::string basename =
+        cmsys::SystemTools::GetFilenameWithoutLastExtension(currentMoc);
       const bool mocUnderscoreStyle = cmHasLiteralPrefix(basename, "moc_");
 
       // If the moc include is of the moc_foo.cpp style we expect
@@ -919,121 +780,113 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
       // If the moc include is of the foo.moc style we need to look for
       // a Q_OBJECT macro in the current source file, if it contains the
       // macro we generate the moc file from the source file.
-      if (mocUnderscoreStyle)
-        {
+      if (mocUnderscoreStyle) {
         // basename should be the part of the moc filename used for
         // finding the correct header, so we need to remove the moc_ part
         basename = basename.substr(4);
         std::string mocSubDir = extractSubDir(absPath, currentMoc);
-        std::string headerToMoc = findMatchingHeader(
-                               absPath, mocSubDir, basename, headerExtensions);
+        std::string headerToMoc =
+          findMatchingHeader(absPath, mocSubDir, basename, headerExtensions);
 
-        if (!headerToMoc.empty())
-          {
+        if (!headerToMoc.empty()) {
           includedMocs[headerToMoc] = currentMoc;
+        } else {
+          std::stringstream err;
+          err << "AUTOGEN: error: " << absFilename << " The file "
+              << "includes the moc file \"" << currentMoc << "\", "
+              << "but could not find header \"" << basename << '{'
+              << this->JoinExts(headerExtensions) << "}\" ";
+          if (mocSubDir.empty()) {
+            err << "in " << absPath << "\n" << std::endl;
+          } else {
+            err << "neither in " << absPath << " nor in " << mocSubDir << "\n"
+                << std::endl;
           }
-        else
-          {
-          std::cerr << "AUTOGEN: error: " << absFilename << " The file "
-                    << "includes the moc file \"" << currentMoc << "\", "
-                    << "but could not find header \"" << basename
-                    << '{' << this->Join(headerExtensions, ',') << "}\" ";
-          if (mocSubDir.empty())
-            {
-            std::cerr << "in " << absPath << "\n" << std::endl;
-            }
-          else
-            {
-            std::cerr << "neither in " << absPath
-                      << " nor in " << mocSubDir << "\n" << std::endl;
-            }
-
+          this->LogError(err.str());
           ::exit(EXIT_FAILURE);
-          }
         }
-      else
-        {
-        if (basename != scannedFileBasename)
-          {
-          std::cerr <<"AUTOGEN: error: " << absFilename << ": The file "
-                      "includes the moc file \"" << currentMoc <<
-                      "\", which seems to be the moc file from a different "
-                      "source file. This is not supported. "
-                      "Include \"" << scannedFileBasename << ".moc\" to run "
-                      "moc on this source file.\n" << std::endl;
+      } else {
+        if (basename != scannedFileBasename) {
+          std::stringstream err;
+          err << "AUTOGEN: error: " << absFilename
+              << ": The file "
+                 "includes the moc file \""
+              << currentMoc
+              << "\", which seems to be the moc file from a different "
+                 "source file. This is not supported. "
+                 "Include \""
+              << scannedFileBasename << ".moc\" to run "
+                                        "moc on this source file.\n"
+              << std::endl;
+          this->LogError(err.str());
           ::exit(EXIT_FAILURE);
-          }
+        }
         dotMocIncluded = true;
         includedMocs[absFilename] = currentMoc;
-        }
+      }
       matchOffset += mocIncludeRegExp.end();
-      } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
-    }
+    } while (mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
+  }
 
   // In this case, check whether the scanned file itself contains a Q_OBJECT.
   // If this is the case, the moc_foo.cpp should probably be generated from
   // foo.cpp instead of foo.h, because otherwise it won't build.
   // But warn, since this is not how it is supposed to be used.
   std::string macroName;
-  if ((dotMocIncluded == false) && (requiresMocing(contentsString,
-                                                     macroName)))
-    {
+  if ((dotMocIncluded == false) &&
+      (requiresMocing(contentsString, macroName))) {
     // otherwise always error out since it will not compile:
-    std::cerr << "AUTOGEN: error: " << absFilename << ": The file "
-              << "contains a " << macroName << " macro, but does not include "
-              << "\"" << scannedFileBasename << ".moc\" !\n"
-              << std::endl;
+    std::stringstream err;
+    err << "AUTOGEN: error: " << absFilename << ": The file "
+        << "contains a " << macroName << " macro, but does not include "
+        << "\"" << scannedFileBasename << ".moc\" !\n"
+        << std::endl;
+    this->LogError(err.str());
     ::exit(EXIT_FAILURE);
-    }
-
+  }
 }
 
-
-void cmQtAutoGenerators::ParseForUic(const std::string& absFilename,
-                std::map<std::string, std::vector<std::string> >& includedUis)
+void cmQtAutoGenerators::ParseForUic(
+  const std::string& absFilename,
+  std::map<std::string, std::vector<std::string> >& includedUis)
 {
-  if (this->UicExecutable.empty())
-    {
+  if (this->UicExecutable.empty()) {
     return;
-    }
+  }
   const std::string contentsString = ReadAll(absFilename);
-  if (contentsString.empty())
-    {
-    std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
-              << std::endl;
+  if (contentsString.empty()) {
+    std::stringstream err;
+    err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
+        << std::endl;
+    this->LogError(err.str());
     return;
-    }
+  }
   this->ParseForUic(absFilename, contentsString, includedUis);
 }
 
-
-void cmQtAutoGenerators::ParseForUic(const std::string& absFilename,
-                const std::string& contentsString,
-                std::map<std::string, std::vector<std::string> >& includedUis)
+void cmQtAutoGenerators::ParseForUic(
+  const std::string& absFilename, const std::string& contentsString,
+  std::map<std::string, std::vector<std::string> >& includedUis)
 {
-  if (this->UicExecutable.empty())
-    {
+  if (this->UicExecutable.empty()) {
     return;
-    }
+  }
   cmsys::RegularExpression uiIncludeRegExp(
-              "[\n][ \t]*#[ \t]*include[ \t]+"
-              "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
+    "[\n][ \t]*#[ \t]*include[ \t]+"
+    "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
 
   std::string::size_type matchOffset = 0;
 
-  const std::string realName =
-                   cmsys::SystemTools::GetRealPath(absFilename);
+  const std::string realName = cmsys::SystemTools::GetRealPath(absFilename);
 
   matchOffset = 0;
-  if ((strstr(contentsString.c_str(), "ui_") != NULL)
-                                    && (uiIncludeRegExp.find(contentsString)))
-    {
-    do
-      {
+  if ((strstr(contentsString.c_str(), "ui_") != NULL) &&
+      (uiIncludeRegExp.find(contentsString))) {
+    do {
       const std::string currentUi = uiIncludeRegExp.match(1);
 
-      std::string basename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(currentUi);
+      std::string basename =
+        cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi);
 
       // basename should be the part of the ui filename used for
       // finding the correct header, so we need to remove the ui_ part
@@ -1042,114 +895,202 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename,
       includedUis[realName].push_back(basename);
 
       matchOffset += uiIncludeRegExp.end();
-      } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset));
-    }
+    } while (uiIncludeRegExp.find(contentsString.c_str() + matchOffset));
+  }
 }
 
-
-void
-cmQtAutoGenerators::SearchHeadersForCppFile(const std::string& absFilename,
-                              const std::vector<std::string>& headerExtensions,
-                              std::set<std::string>& absHeaders)
+void cmQtAutoGenerators::SearchHeadersForCppFile(
+  const std::string& absFilename,
+  const std::vector<std::string>& headerExtensions,
+  std::set<std::string>& absHeaders)
 {
   // search for header files and private header files we may need to moc:
   const std::string basename =
-              cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
+    cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
   const std::string absPath = cmsys::SystemTools::GetFilenamePath(
-                   cmsys::SystemTools::GetRealPath(absFilename)) + '/';
+                                cmsys::SystemTools::GetRealPath(absFilename)) +
+    '/';
 
-  for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
-      ext != headerExtensions.end();
-      ++ext)
-    {
+  for (std::vector<std::string>::const_iterator ext = headerExtensions.begin();
+       ext != headerExtensions.end(); ++ext) {
     const std::string headerName = absPath + basename + "." + (*ext);
-    if (cmsys::SystemTools::FileExists(headerName.c_str()))
-      {
+    if (cmsys::SystemTools::FileExists(headerName.c_str())) {
       absHeaders.insert(headerName);
       break;
-      }
     }
-  for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
-      ext != headerExtensions.end();
-      ++ext)
-    {
-    const std::string privateHeaderName = absPath+basename+"_p."+(*ext);
-    if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()))
-      {
+  }
+  for (std::vector<std::string>::const_iterator ext = headerExtensions.begin();
+       ext != headerExtensions.end(); ++ext) {
+    const std::string privateHeaderName = absPath + basename + "_p." + (*ext);
+    if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) {
       absHeaders.insert(privateHeaderName);
       break;
-      }
     }
-
+  }
 }
 
-
-void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
-                const std::map<std::string, std::string>& includedMocs,
-                std::map<std::string, std::string>& notIncludedMocs,
-                std::map<std::string, std::vector<std::string> >& includedUis)
+void cmQtAutoGenerators::ParseHeaders(
+  const std::set<std::string>& absHeaders,
+  const std::map<std::string, std::string>& includedMocs,
+  std::map<std::string, std::string>& notIncludedMocs,
+  std::map<std::string, std::vector<std::string> >& includedUis)
 {
-  for(std::set<std::string>::const_iterator hIt=absHeaders.begin();
-      hIt!=absHeaders.end();
-      ++hIt)
-    {
+  for (std::set<std::string>::const_iterator hIt = absHeaders.begin();
+       hIt != absHeaders.end(); ++hIt) {
     const std::string& headerName = *hIt;
     const std::string contents = ReadAll(headerName);
 
-    if (!this->MocExecutable.empty()
-        && includedMocs.find(headerName) == includedMocs.end())
-      {
-      if (this->Verbose)
-        {
-        std::cout << "AUTOGEN: Checking " << headerName << std::endl;
-        }
-
-      const std::string basename = cmsys::SystemTools::
-                                   GetFilenameWithoutLastExtension(headerName);
+    if (!this->MocExecutable.empty() &&
+        includedMocs.find(headerName) == includedMocs.end()) {
+      if (this->Verbose) {
+        std::stringstream err;
+        err << "AUTOGEN: Checking " << headerName << std::endl;
+        this->LogInfo(err.str());
+      }
 
-      const std::string currentMoc = "moc_" + basename + ".cpp";
       std::string macroName;
-      if (requiresMocing(contents, macroName))
-        {
-        //std::cout << "header contains Q_OBJECT macro";
+      if (requiresMocing(contents, macroName)) {
+        const std::string parentDir =
+          this->TargetBuildSubDir + this->SourceRelativePath(headerName);
+        const std::string basename =
+          cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName);
+        const std::string currentMoc = parentDir + "moc_" + basename + ".cpp";
         notIncludedMocs[headerName] = currentMoc;
-        }
       }
+    }
     this->ParseForUic(headerName, contents, includedUis);
+  }
+}
+
+bool cmQtAutoGenerators::GenerateMocFiles(
+  const std::map<std::string, std::string>& includedMocs,
+  const std::map<std::string, std::string>& notIncludedMocs)
+{
+  // look for name collisions
+  {
+    std::multimap<std::string, std::string> collisions;
+    // Test merged map of included and notIncluded
+    std::map<std::string, std::string> mergedMocs(includedMocs);
+    mergedMocs.insert(notIncludedMocs.begin(), notIncludedMocs.end());
+    if (this->NameCollisionTest(mergedMocs, collisions)) {
+      std::stringstream err;
+      err << "AUTOGEN: error: "
+             "The same moc file will be generated "
+             "from different sources."
+          << std::endl
+          << "To avoid this error either" << std::endl
+          << "- rename the source files or" << std::endl
+          << "- do not include the (moc_NAME.cpp|NAME.moc) file" << std::endl;
+      this->NameCollisionLog(err.str(), collisions);
+      ::exit(EXIT_FAILURE);
+    }
+  }
+
+  // generate moc files that are included by source files.
+  for (std::map<std::string, std::string>::const_iterator it =
+         includedMocs.begin();
+       it != includedMocs.end(); ++it) {
+    if (!this->GenerateMoc(it->first, it->second)) {
+      if (this->RunMocFailed) {
+        return false;
+      }
+    }
+  }
+
+  // generate moc files that are _not_ included by source files.
+  bool automocCppChanged = false;
+  for (std::map<std::string, std::string>::const_iterator it =
+         notIncludedMocs.begin();
+       it != notIncludedMocs.end(); ++it) {
+    if (this->GenerateMoc(it->first, it->second)) {
+      automocCppChanged = true;
+    } else {
+      if (this->RunMocFailed) {
+        return false;
+      }
+    }
+  }
+
+  // compose _automoc.cpp content
+  std::string automocSource;
+  {
+    std::stringstream outStream;
+    outStream << "/* This file is autogenerated, do not edit*/\n";
+    if (notIncludedMocs.empty()) {
+      outStream << "enum some_compilers { need_more_than_nothing };\n";
+    } else {
+      for (std::map<std::string, std::string>::const_iterator it =
+             notIncludedMocs.begin();
+           it != notIncludedMocs.end(); ++it) {
+        outStream << "#include \"" << it->second << "\"\n";
+      }
+    }
+    outStream.flush();
+    automocSource = outStream.str();
+  }
+
+  // check if we even need to update _automoc.cpp
+  if (!automocCppChanged) {
+    // compare contents of the _automoc.cpp file
+    const std::string oldContents = ReadAll(this->OutMocCppFilenameAbs);
+    if (oldContents == automocSource) {
+      // nothing changed: don't touch the _automoc.cpp file
+      if (this->Verbose) {
+        std::stringstream err;
+        err << "AUTOGEN: " << this->OutMocCppFilenameRel << " still up to date"
+            << std::endl;
+        this->LogInfo(err.str());
+      }
+      return true;
     }
+  }
+
+  // actually write _automoc.cpp
+  {
+    std::string msg = "Generating moc compilation ";
+    msg += this->OutMocCppFilenameRel;
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
+                                       cmsysTerminal_Color_ForegroundBold,
+                                     msg.c_str(), true, this->ColorOutput);
+  }
+  {
+    cmsys::ofstream outfile;
+    outfile.open(this->OutMocCppFilenameAbs.c_str(), std::ios::trunc);
+    outfile << automocSource;
+    outfile.close();
+  }
+
+  return true;
 }
 
 bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
-                              const std::string& mocFileName)
+                                     const std::string& mocFileName)
 {
   const std::string mocFilePath = this->Builddir + mocFileName;
   int sourceNewerThanMoc = 0;
-  bool success = cmsys::SystemTools::FileTimeCompare(sourceFile,
-                                                     mocFilePath,
+  bool success = cmsys::SystemTools::FileTimeCompare(sourceFile, mocFilePath,
                                                      &sourceNewerThanMoc);
-  if (this->GenerateAll || !success || sourceNewerThanMoc >= 0)
-    {
+  if (this->GenerateAll || !success || sourceNewerThanMoc >= 0) {
     // make sure the directory for the resulting moc file exists
     std::string mocDir = mocFilePath.substr(0, mocFilePath.rfind('/'));
-    if (!cmsys::SystemTools::FileExists(mocDir.c_str(), false))
-      {
+    if (!cmsys::SystemTools::FileExists(mocDir.c_str(), false)) {
       cmsys::SystemTools::MakeDirectory(mocDir.c_str());
-      }
+    }
 
-    std::string msg = "Generating ";
+    std::string msg = "Generating moc source ";
     msg += mocFileName;
-    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
-                                           |cmsysTerminal_Color_ForegroundBold,
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
+                                       cmsysTerminal_Color_ForegroundBold,
                                      msg.c_str(), true, this->ColorOutput);
 
     std::vector<std::string> command;
     command.push_back(this->MocExecutable);
-    command.insert(command.end(),
-                   this->MocIncludes.begin(), this->MocIncludes.end());
-    command.insert(command.end(),
-                   this->MocDefinitions.begin(), this->MocDefinitions.end());
-    command.insert(command.end(),
-                   this->MocOptions.begin(), this->MocOptions.end());
+    command.insert(command.end(), this->MocIncludes.begin(),
+                   this->MocIncludes.end());
+    command.insert(command.end(), this->MocDefinitions.begin(),
+                   this->MocDefinitions.end());
+    command.insert(command.end(), this->MocOptions.begin(),
+                   this->MocOptions.end());
 #ifdef _WIN32
     command.push_back("-DWIN32");
 #endif
@@ -1157,103 +1098,143 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
     command.push_back(mocFilePath);
     command.push_back(sourceFile);
 
-    if (this->Verbose)
-      {
-      for(std::vector<std::string>::const_iterator cmdIt = command.begin();
-          cmdIt != command.end();
-          ++cmdIt)
-        {
-        std::cout << *cmdIt << " ";
-        }
-      std::cout << std::endl;
-      }
+    if (this->Verbose) {
+      this->LogCommand(command);
+    }
 
     std::string output;
     int retVal = 0;
-    bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
-                                                  &retVal);
-    if (!result || retVal)
-      {
-      std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n"
-                << output << std::endl;
+    bool result =
+      cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
+    if (!result || retVal) {
+      std::stringstream err;
+      err << "AUTOGEN: error: process for " << mocFilePath << " failed:\n"
+          << output << std::endl;
+      this->LogError(err.str());
       this->RunMocFailed = true;
       cmSystemTools::RemoveFile(mocFilePath);
-      }
-    return true;
     }
+    return true;
+  }
   return false;
 }
 
-bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
-                                    const std::string& uiFileName)
+bool cmQtAutoGenerators::GenerateUiFiles(
+  const std::map<std::string, std::vector<std::string> >& includedUis)
 {
-  if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false))
-    {
-    cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
+  // single map with input / output names
+  std::map<std::string, std::map<std::string, std::string> > uiGenMap;
+  std::map<std::string, std::string> testMap;
+  for (std::map<std::string, std::vector<std::string> >::const_iterator it =
+         includedUis.begin();
+       it != includedUis.end(); ++it) {
+    // source file path
+    std::string sourcePath = cmsys::SystemTools::GetFilenamePath(it->first);
+    sourcePath += '/';
+    // insert new map for source file an use new reference
+    uiGenMap[it->first] = std::map<std::string, std::string>();
+    std::map<std::string, std::string>& sourceMap = uiGenMap[it->first];
+    for (std::vector<std::string>::const_iterator sit = it->second.begin();
+         sit != it->second.end(); ++sit) {
+      const std::string& uiFileName = *sit;
+      const std::string uiInputFile = sourcePath + uiFileName + ".ui";
+      const std::string uiOutputFile = "ui_" + uiFileName + ".h";
+      sourceMap[uiInputFile] = uiOutputFile;
+      testMap[uiInputFile] = uiOutputFile;
     }
+  }
 
-  const std::string path = cmsys::SystemTools::GetFilenamePath(
-                                                      realName) + '/';
+  // look for name collisions
+  {
+    std::multimap<std::string, std::string> collisions;
+    if (this->NameCollisionTest(testMap, collisions)) {
+      std::stringstream err;
+      err << "AUTOGEN: error: The same ui_NAME.h file will be generated "
+             "from different sources."
+          << std::endl
+          << "To avoid this error rename the source files." << std::endl;
+      this->NameCollisionLog(err.str(), collisions);
+      ::exit(EXIT_FAILURE);
+    }
+  }
+  testMap.clear();
+
+  // generate ui files
+  for (std::map<std::string,
+                std::map<std::string, std::string> >::const_iterator it =
+         uiGenMap.begin();
+       it != uiGenMap.end(); ++it) {
+    for (std::map<std::string, std::string>::const_iterator sit =
+           it->second.begin();
+         sit != it->second.end(); ++sit) {
+      if (!this->GenerateUi(it->first, sit->first, sit->second)) {
+        if (this->RunUicFailed) {
+          return false;
+        }
+      }
+    }
+  }
 
-  std::string ui_output_file = "ui_" + uiFileName + ".h";
-  std::string ui_input_file = path + uiFileName + ".ui";
+  return true;
+}
+
+bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
+                                    const std::string& uiInputFile,
+                                    const std::string& uiOutputFile)
+{
+  if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) {
+    cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
+  }
+
+  const ::std::string uiBuildFile = this->Builddir + uiOutputFile;
 
   int sourceNewerThanUi = 0;
-  bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file,
-                                    this->Builddir + ui_output_file,
+  bool success = cmsys::SystemTools::FileTimeCompare(uiInputFile, uiBuildFile,
                                                      &sourceNewerThanUi);
-  if (this->GenerateAll || !success || sourceNewerThanUi >= 0)
-    {
-    std::string msg = "Generating ";
-    msg += ui_output_file;
-    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
-                                          |cmsysTerminal_Color_ForegroundBold,
-                                      msg.c_str(), true, this->ColorOutput);
+  if (this->GenerateAll || !success || sourceNewerThanUi >= 0) {
+    std::string msg = "Generating ui header ";
+    msg += uiOutputFile;
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
+                                       cmsysTerminal_Color_ForegroundBold,
+                                     msg.c_str(), true, this->ColorOutput);
 
     std::vector<std::string> command;
     command.push_back(this->UicExecutable);
 
     std::vector<std::string> opts = this->UicTargetOptions;
-    std::map<std::string, std::string>::const_iterator optionIt
-            = this->UicOptions.find(ui_input_file);
-    if (optionIt != this->UicOptions.end())
-      {
+    std::map<std::string, std::string>::const_iterator optionIt =
+      this->UicOptions.find(uiInputFile);
+    if (optionIt != this->UicOptions.end()) {
       std::vector<std::string> fileOpts;
       cmSystemTools::ExpandListArgument(optionIt->second, fileOpts);
       cmQtAutoGenerators::MergeUicOptions(opts, fileOpts,
                                           this->QtMajorVersion == "5");
-      }
+    }
     command.insert(command.end(), opts.begin(), opts.end());
 
     command.push_back("-o");
-    command.push_back(this->Builddir + ui_output_file);
-    command.push_back(ui_input_file);
-
-    if (this->Verbose)
-      {
-      for(std::vector<std::string>::const_iterator cmdIt = command.begin();
-          cmdIt != command.end();
-          ++cmdIt)
-        {
-        std::cout << *cmdIt << " ";
-        }
-      std::cout << std::endl;
-      }
+    command.push_back(uiBuildFile);
+    command.push_back(uiInputFile);
+
+    if (this->Verbose) {
+      this->LogCommand(command);
+    }
     std::string output;
     int retVal = 0;
-    bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
-                                                  &retVal);
-    if (!result || retVal)
-      {
-      std::cerr << "AUTOUIC: error: process for " << ui_output_file <<
-                " needed by\n \"" << realName << "\"\nfailed:\n" << output
-                << std::endl;
+    bool result =
+      cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
+    if (!result || retVal) {
+      std::stringstream err;
+      err << "AUTOUIC: error: process for " << uiOutputFile
+          << " needed by\n \"" << realName << "\"\nfailed:\n"
+          << output << std::endl;
+      this->LogError(err.str());
       this->RunUicFailed = true;
-      cmSystemTools::RemoveFile(ui_output_file);
+      cmSystemTools::RemoveFile(uiOutputFile);
       return false;
-      }
-    return true;
     }
+    return true;
+  }
   return false;
 }
 
@@ -1262,124 +1243,250 @@ bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile,
 {
   std::vector<std::string> const& files = this->RccInputs[qrcFile];
   for (std::vector<std::string>::const_iterator it = files.begin();
-       it != files.end(); ++it)
-    {
+       it != files.end(); ++it) {
     int inputNewerThanQrc = 0;
-    bool success = cmsys::SystemTools::FileTimeCompare(*it,
-                                                      rccOutput,
-                                                      &inputNewerThanQrc);
-    if (!success || inputNewerThanQrc >= 0)
-      {
+    bool success =
+      cmsys::SystemTools::FileTimeCompare(*it, rccOutput, &inputNewerThanQrc);
+    if (!success || inputNewerThanQrc >= 0) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-bool cmQtAutoGenerators::GenerateQrc()
+bool cmQtAutoGenerators::GenerateQrcFiles()
 {
-  for(std::vector<std::string>::const_iterator si = this->RccSources.begin();
-      si != this->RccSources.end(); ++si)
-    {
-    std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
+  // generate single map with input / output names
+  std::map<std::string, std::string> qrcGenMap;
+  for (std::vector<std::string>::const_iterator si = this->RccSources.begin();
+       si != this->RccSources.end(); ++si) {
+    const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
+    if (ext == ".qrc") {
+      std::string basename =
+        cmsys::SystemTools::GetFilenameWithoutLastExtension(*si);
+      std::string qrcOutputFile = this->TargetBuildSubDir +
+        this->SourceRelativePath(*si) + "qrc_" + basename + ".cpp";
+      // std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
+      //                         + ".dir/qrc_" + basename + ".cpp";
+      qrcGenMap[*si] = qrcOutputFile;
+    }
+  }
 
-    if (ext != ".qrc")
-      {
-      continue;
+  // look for name collisions
+  {
+    std::multimap<std::string, std::string> collisions;
+    if (this->NameCollisionTest(qrcGenMap, collisions)) {
+      std::stringstream err;
+      err << "AUTOGEN: error: The same qrc_NAME.cpp file"
+             " will be generated from different sources."
+          << std::endl
+          << "To avoid this error rename the source .qrc files." << std::endl;
+      this->NameCollisionLog(err.str(), collisions);
+      ::exit(EXIT_FAILURE);
+    }
+  }
+
+  // generate qrc files
+  for (std::map<std::string, std::string>::const_iterator si =
+         qrcGenMap.begin();
+       si != qrcGenMap.end(); ++si) {
+    if (!this->GenerateQrc(si->first, si->second)) {
+      if (this->RunRccFailed) {
+        return false;
       }
+    }
+  }
+  return true;
+}
+
+bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
+                                     const std::string& qrcOutputFile)
+{
+  std::string relName = this->SourceRelativePath(qrcInputFile);
+  std::replace(relName.begin(), relName.end(), '/', '_');
+  relName += cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
+
+  const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
+
+  int sourceNewerThanQrc = 0;
+  bool generateQrc = !cmsys::SystemTools::FileTimeCompare(
+    qrcInputFile, qrcBuildFile, &sourceNewerThanQrc);
+  generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
+  generateQrc =
+    generateQrc || this->InputFilesNewerThanQrc(qrcInputFile, qrcBuildFile);
+
+  if (this->GenerateAll || generateQrc) {
+    std::string msg = "Generating qrc source ";
+    msg += qrcOutputFile;
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
+                                       cmsysTerminal_Color_ForegroundBold,
+                                     msg.c_str(), true, this->ColorOutput);
+
     std::vector<std::string> command;
     command.push_back(this->RccExecutable);
 
-    std::string basename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(*si);
-
-    std::string rcc_output_file = this->Builddir
-                                + "CMakeFiles/" + this->OriginTargetName
-                                + ".dir/qrc_" + basename + ".cpp";
-
-    int sourceNewerThanQrc = 0;
-    bool generateQrc = !cmsys::SystemTools::FileTimeCompare(*si,
-                                                      rcc_output_file,
-                                                      &sourceNewerThanQrc);
-    generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
-    generateQrc = generateQrc || this->InputFilesNewerThanQrc(*si,
-                                                          rcc_output_file);
-
-    if (this->GenerateAll || generateQrc)
-      {
-      std::map<std::string, std::string>::const_iterator optionIt
-              = this->RccOptions.find(*si);
-      if (optionIt != this->RccOptions.end())
-        {
-        cmSystemTools::ExpandListArgument(optionIt->second, command);
-        }
+    std::map<std::string, std::string>::const_iterator optionIt =
+      this->RccOptions.find(qrcInputFile);
+    if (optionIt != this->RccOptions.end()) {
+      cmSystemTools::ExpandListArgument(optionIt->second, command);
+    }
 
-      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<std::string>::const_iterator cmdIt = command.begin();
-            cmdIt != command.end();
-            ++cmdIt)
-          {
-          std::cout << *cmdIt << " ";
-          }
-        std::cout << std::endl;
-        }
-      std::string output;
-      int retVal = 0;
-      bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
-                                                    &retVal);
-      if (!result || retVal)
-        {
-        std::cerr << "AUTORCC: error: process for " << rcc_output_file <<
-                  " failed:\n" << output << std::endl;
-        this->RunRccFailed = true;
-        cmSystemTools::RemoveFile(rcc_output_file);
-        return false;
-        }
-      }
+    command.push_back("-name");
+    command.push_back(relName);
+    command.push_back("-o");
+    command.push_back(qrcBuildFile);
+    command.push_back(qrcInputFile);
+
+    if (this->Verbose) {
+      this->LogCommand(command);
+    }
+    std::string output;
+    int retVal = 0;
+    bool result =
+      cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
+    if (!result || retVal) {
+      std::stringstream err;
+      err << "AUTORCC: error: process for " << qrcOutputFile << " failed:\n"
+          << output << std::endl;
+      this->LogError(err.str());
+      this->RunRccFailed = true;
+      cmSystemTools::RemoveFile(qrcBuildFile);
+      return false;
     }
+  }
   return true;
 }
 
-std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst,
-                              char separator)
+std::string cmQtAutoGenerators::SourceRelativePath(const std::string& filename)
 {
-    if (lst.empty())
-      {
-      return "";
+  std::string pathRel;
+
+  // Test if the file is child to any of the known directories
+  {
+    std::string fileNameReal = cmsys::SystemTools::GetRealPath(filename);
+    std::string parentDirectory;
+    bool match(false);
+    {
+      const ::std::string* testDirs[4];
+      testDirs[0] = &(this->Srcdir);
+      testDirs[1] = &(this->Builddir);
+      testDirs[2] = &(this->ProjectSourceDir);
+      testDirs[3] = &(this->ProjectBinaryDir);
+      for (int ii = 0; ii != sizeof(testDirs) / sizeof(const ::std::string*);
+           ++ii) {
+        const ::std::string testDir =
+          cmsys::SystemTools::GetRealPath(*(testDirs[ii]));
+        if (cmsys::SystemTools::IsSubDirectory(fileNameReal, testDir)) {
+          parentDirectory = testDir;
+          match = true;
+          break;
+        }
       }
+    }
+    // Use root as fallback parent directory
+    if (!match) {
+      cmsys::SystemTools::SplitPathRootComponent(fileNameReal,
+                                                 &parentDirectory);
+    }
+    pathRel = cmsys::SystemTools::RelativePath(
+      parentDirectory, cmsys::SystemTools::GetParentDirectory(fileNameReal));
+  }
+
+  // Sanitize relative path
+  if (!pathRel.empty()) {
+    pathRel += '/';
+    cmSystemTools::ReplaceString(pathRel, "..", "__");
+  }
+  return pathRel;
+}
 
-    std::string result;
-    for (std::vector<std::string>::const_iterator it = lst.begin();
-         it != lst.end();
-         ++it)
-      {
-      result += "." + (*it) + separator;
+/**
+ * @brief Collects name collisions as output/input pairs
+ * @return True if there were collisions
+ */
+bool cmQtAutoGenerators::NameCollisionTest(
+  const std::map<std::string, std::string>& genFiles,
+  std::multimap<std::string, std::string>& collisions)
+{
+  typedef std::map<std::string, std::string>::const_iterator Iter;
+  typedef std::map<std::string, std::string>::value_type VType;
+  for (Iter ait = genFiles.begin(); ait != genFiles.end(); ++ait) {
+    bool first_match(true);
+    for (Iter bit = (++Iter(ait)); bit != genFiles.end(); ++bit) {
+      if (ait->second == bit->second) {
+        if (first_match) {
+          if (collisions.find(ait->second) != collisions.end()) {
+            // We already know of this collision from before
+            break;
+          }
+          collisions.insert(VType(ait->second, ait->first));
+          first_match = false;
+        }
+        collisions.insert(VType(bit->second, bit->first));
       }
-    result.erase(result.end() - 1);
-    return result;
+    }
+  }
+
+  return !collisions.empty();
+}
+
+void cmQtAutoGenerators::NameCollisionLog(
+  const std::string& message,
+  const std::multimap<std::string, std::string>& collisions)
+{
+  typedef std::multimap<std::string, std::string>::const_iterator Iter;
+
+  std::stringstream err;
+  // Add message
+  err << message;
+  // Append collision list
+  for (Iter it = collisions.begin(); it != collisions.end(); ++it) {
+    err << it->first << " : " << it->second << std::endl;
+  }
+  this->LogError(err.str());
 }
 
+void cmQtAutoGenerators::LogInfo(const std::string& message)
+{
+  std::cout << message;
+}
 
-bool cmQtAutoGenerators::StartsWith(const std::string& str,
-                                    const std::string& with)
+void cmQtAutoGenerators::LogError(const std::string& message)
 {
-  return (str.substr(0, with.length()) == with);
+  std::cerr << message;
 }
 
+void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)
+{
+  std::stringstream sbuf;
+  for (std::vector<std::string>::const_iterator cmdIt = command.begin();
+       cmdIt != command.end(); ++cmdIt) {
+    if (cmdIt != command.begin()) {
+      sbuf << " ";
+    }
+    sbuf << *cmdIt;
+  }
+  if (!sbuf.str().empty()) {
+    sbuf << std::endl;
+    this->LogInfo(sbuf.str());
+  }
+}
 
-bool cmQtAutoGenerators::EndsWith(const std::string& str,
-                                  const std::string& with)
+std::string cmQtAutoGenerators::JoinExts(const std::vector<std::string>& lst)
 {
-  if (with.length() > (str.length()))
-    {
-    return false;
+  if (lst.empty()) {
+    return "";
+  }
+
+  std::string result;
+  std::string separator = ",";
+  for (std::vector<std::string>::const_iterator it = lst.begin();
+       it != lst.end(); ++it) {
+    if (it != lst.begin()) {
+      result += separator;
     }
-  return (str.substr(str.length() - with.length(), with.length()) == with);
+    result += '.' + (*it);
+  }
+  result.erase(result.end() - 1);
+  return result;
 }
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index ab7b6ed..5e7fab5 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -14,10 +14,12 @@
 #ifndef cmQtAutoGenerators_h
 #define cmQtAutoGenerators_h
 
+#include "cmStandardIncludes.h"
+
 #include <list>
-#include <vector>
-#include <string>
 #include <map>
+#include <string>
+#include <vector>
 
 class cmMakefile;
 
@@ -28,7 +30,6 @@ public:
   bool Run(const std::string& targetDirectory, const std::string& config);
 
 private:
-
   bool ReadAutogenInfoFile(cmMakefile* makefile,
                            const std::string& targetDirectory,
                            const std::string& config);
@@ -39,42 +40,65 @@ private:
   std::string MakeCompileSettingsString(cmMakefile* makefile);
 
   bool RunAutogen(cmMakefile* makefile);
+  bool GenerateMocFiles(
+    const std::map<std::string, std::string>& includedMocs,
+    const std::map<std::string, std::string>& notIncludedMocs);
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
-  bool GenerateUi(const std::string& realName, const std::string& uiFileName);
-  bool GenerateQrc();
-  void ParseCppFile(const std::string& absFilename,
-              const std::vector<std::string>& headerExtensions,
-              std::map<std::string, std::string>& includedMocs,
-              std::map<std::string, std::vector<std::string> >& includedUis);
-  void StrictParseCppFile(const std::string& absFilename,
-              const std::vector<std::string>& headerExtensions,
-              std::map<std::string, std::string>& includedMocs,
-              std::map<std::string, std::vector<std::string> >& includedUis);
-  void SearchHeadersForCppFile(const std::string& absFilename,
-                              const std::vector<std::string>& headerExtensions,
-                              std::set<std::string>& absHeaders);
-
-  void ParseHeaders(const std::set<std::string>& absHeaders,
-              const std::map<std::string, std::string>& includedMocs,
-              std::map<std::string, std::string>& notIncludedMocs,
-              std::map<std::string, std::vector<std::string> >& includedUis);
-
-  void ParseForUic(const std::string& fileName,
-              const std::string& contentsString,
-              std::map<std::string, std::vector<std::string> >& includedUis);
-
-  void ParseForUic(const std::string& fileName,
-              std::map<std::string, std::vector<std::string> >& includedUis);
+  bool GenerateUiFiles(
+    const std::map<std::string, std::vector<std::string> >& includedUis);
+  bool GenerateUi(const std::string& realName, const std::string& uiInputFile,
+                  const std::string& uiOutputFile);
+  bool GenerateQrcFiles();
+  bool GenerateQrc(const std::string& qrcInputFile,
+                   const std::string& qrcOutputFile);
+  void ParseCppFile(
+    const std::string& absFilename,
+    const std::vector<std::string>& headerExtensions,
+    std::map<std::string, std::string>& includedMocs,
+    std::map<std::string, std::vector<std::string> >& includedUis);
+  void StrictParseCppFile(
+    const std::string& absFilename,
+    const std::vector<std::string>& headerExtensions,
+    std::map<std::string, std::string>& includedMocs,
+    std::map<std::string, std::vector<std::string> >& includedUis);
+  void SearchHeadersForCppFile(
+    const std::string& absFilename,
+    const std::vector<std::string>& headerExtensions,
+    std::set<std::string>& absHeaders);
+
+  void ParseHeaders(
+    const std::set<std::string>& absHeaders,
+    const std::map<std::string, std::string>& includedMocs,
+    std::map<std::string, std::string>& notIncludedMocs,
+    std::map<std::string, std::vector<std::string> >& includedUis);
+
+  void ParseForUic(
+    const std::string& fileName, const std::string& contentsString,
+    std::map<std::string, std::vector<std::string> >& includedUis);
+
+  void ParseForUic(
+    const std::string& fileName,
+    std::map<std::string, std::vector<std::string> >& includedUis);
 
   void Init();
 
-  std::string Join(const std::vector<std::string>& lst, char separator);
-  bool EndsWith(const std::string& str, const std::string& with);
-  bool StartsWith(const std::string& str, const std::string& with);
+  std::string SourceRelativePath(const std::string& filename);
+
+  bool NameCollisionTest(const std::map<std::string, std::string>& genFiles,
+                         std::multimap<std::string, std::string>& collisions);
+  void NameCollisionLog(
+    const std::string& message,
+    const std::multimap<std::string, std::string>& collisions);
+
+  void LogInfo(const std::string& message);
+  void LogError(const std::string& message);
+  void LogCommand(const std::vector<std::string>& command);
+  std::string JoinExts(const std::vector<std::string>& lst);
 
-  static void MergeUicOptions(std::vector<std::string> &opts,
-                       const std::vector<std::string> &fileOpts, bool isQt5);
+  static void MergeUicOptions(std::vector<std::string>& opts,
+                              const std::vector<std::string>& fileOpts,
+                              bool isQt5);
 
   bool InputFilesNewerThanQrc(const std::string& qrcFile,
                               const std::string& rccOutput);
@@ -101,7 +125,9 @@ private:
   std::string CurrentCompileSettingsStr;
   std::string OldCompileSettingsStr;
 
-  std::string OutMocCppFilename;
+  std::string TargetBuildSubDir;
+  std::string OutMocCppFilenameRel;
+  std::string OutMocCppFilenameAbs;
   std::list<std::string> MocIncludes;
   std::list<std::string> MocDefinitions;
   std::vector<std::string> MocOptions;
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index cb61ed9..10d1cda 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -11,409 +11,341 @@
 ============================================================================*/
 #include "cmRST.h"
 
-#include "cmSystemTools.h"
 #include "cmAlgorithms.h"
+#include "cmSystemTools.h"
 #include "cmVersion.h"
 #include <cmsys/FStream.hxx>
 #include <ctype.h>
 
-//----------------------------------------------------------------------------
-cmRST::cmRST(std::ostream& os, std::string const& docroot):
-  OS(os),
-  DocRoot(docroot),
-  IncludeDepth(0),
-  OutputLinePending(false),
-  LastLineEndedInColonColon(false),
-  Markup(MarkupNone),
-  Directive(DirectiveNone),
-  CMakeDirective("^.. (cmake:)?("
-                 "command|variable"
-                 ")::[ \t]+([^ \t\n]+)$"),
-  CMakeModuleDirective("^.. cmake-module::[ \t]+([^ \t\n]+)$"),
-  ParsedLiteralDirective("^.. parsed-literal::[ \t]*(.*)$"),
-  CodeBlockDirective("^.. code-block::[ \t]*(.*)$"),
-  ReplaceDirective("^.. (\\|[^|]+\\|) replace::[ \t]*(.*)$"),
-  IncludeDirective("^.. include::[ \t]+([^ \t\n]+)$"),
-  TocTreeDirective("^.. toctree::[ \t]*(.*)$"),
-  ProductionListDirective("^.. productionlist::[ \t]*(.*)$"),
-  NoteDirective("^.. note::[ \t]*(.*)$"),
-  ModuleRST("^#\\[(=*)\\[\\.rst:$"),
-  CMakeRole("(:cmake)?:("
-            "command|generator|variable|module|policy|"
-            "prop_cache|prop_dir|prop_gbl|prop_inst|prop_sf|"
-            "prop_test|prop_tgt|"
-            "manual"
-            "):`(<*([^`<]|[^` \t]<)*)([ \t]+<[^`]*>)?`"),
-  Substitution("(^|[^A-Za-z0-9_])"
-               "((\\|[^| \t\r\n]([^|\r\n]*[^| \t\r\n])?\\|)(__|_|))"
-               "([^A-Za-z0-9_]|$)")
+cmRST::cmRST(std::ostream& os, std::string const& docroot)
+  : OS(os)
+  , DocRoot(docroot)
+  , IncludeDepth(0)
+  , OutputLinePending(false)
+  , LastLineEndedInColonColon(false)
+  , Markup(MarkupNone)
+  , Directive(DirectiveNone)
+  , CMakeDirective("^.. (cmake:)?("
+                   "command|variable"
+                   ")::[ \t]+([^ \t\n]+)$")
+  , CMakeModuleDirective("^.. cmake-module::[ \t]+([^ \t\n]+)$")
+  , ParsedLiteralDirective("^.. parsed-literal::[ \t]*(.*)$")
+  , CodeBlockDirective("^.. code-block::[ \t]*(.*)$")
+  , ReplaceDirective("^.. (\\|[^|]+\\|) replace::[ \t]*(.*)$")
+  , IncludeDirective("^.. include::[ \t]+([^ \t\n]+)$")
+  , TocTreeDirective("^.. toctree::[ \t]*(.*)$")
+  , ProductionListDirective("^.. productionlist::[ \t]*(.*)$")
+  , NoteDirective("^.. note::[ \t]*(.*)$")
+  , ModuleRST("^#\\[(=*)\\[\\.rst:$")
+  , CMakeRole("(:cmake)?:("
+              "command|generator|variable|module|policy|"
+              "prop_cache|prop_dir|prop_gbl|prop_inst|prop_sf|"
+              "prop_test|prop_tgt|"
+              "manual"
+              "):`(<*([^`<]|[^` \t]<)*)([ \t]+<[^`]*>)?`")
+  , Substitution("(^|[^A-Za-z0-9_])"
+                 "((\\|[^| \t\r\n]([^|\r\n]*[^| \t\r\n])?\\|)(__|_|))"
+                 "([^A-Za-z0-9_]|$)")
+  , TocTreeLink("^.*[ \t]+<([^>]+)>$")
 {
   this->Replace["|release|"] = cmVersion::GetCMakeVersion();
 }
 
-//----------------------------------------------------------------------------
 bool cmRST::ProcessFile(std::string const& fname, bool isModule)
 {
   cmsys::ifstream fin(fname.c_str());
-  if(fin)
-    {
+  if (fin) {
     this->DocDir = cmSystemTools::GetFilenamePath(fname);
-    if(isModule)
-      {
+    if (isModule) {
       this->ProcessModule(fin);
-      }
-    else
-      {
+    } else {
       this->ProcessRST(fin);
-      }
+    }
     this->OutputLinePending = true;
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessRST(std::istream& is)
 {
   std::string line;
-  while(cmSystemTools::GetLineFromStream(is, line))
-    {
+  while (cmSystemTools::GetLineFromStream(is, line)) {
     this->ProcessLine(line);
-    }
+  }
   this->Reset();
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessModule(std::istream& is)
 {
   std::string line;
   std::string rst;
-  while(cmSystemTools::GetLineFromStream(is, line))
-    {
-    if(!rst.empty() && rst != "#")
-      {
+  while (cmSystemTools::GetLineFromStream(is, line)) {
+    if (!rst.empty() && rst != "#") {
       // Bracket mode: check for end bracket
       std::string::size_type pos = line.find(rst);
-      if(pos == line.npos)
-        {
+      if (pos == line.npos) {
         this->ProcessLine(line);
-        }
-      else
-        {
-        if(line[0] != '#')
-          {
+      } else {
+        if (line[0] != '#') {
           this->ProcessLine(line.substr(0, pos));
-          }
+        }
         rst = "";
         this->Reset();
         this->OutputLinePending = true;
-        }
       }
-    else
-      {
+    } else {
       // Line mode: check for .rst start (bracket or line)
-      if(rst == "#")
-        {
-        if(line == "#")
-          {
+      if (rst == "#") {
+        if (line == "#") {
           this->ProcessLine("");
           continue;
-          }
-        else if(line.substr(0, 2) == "# ")
-          {
+        } else if (line.substr(0, 2) == "# ") {
           this->ProcessLine(line.substr(2, line.npos));
           continue;
-          }
-        else
-          {
+        } else {
           rst = "";
           this->Reset();
           this->OutputLinePending = true;
-          }
         }
-      if(line == "#.rst:")
-        {
+      }
+      if (line == "#.rst:") {
         rst = "#";
-        }
-      else if(this->ModuleRST.find(line))
-        {
+      } else if (this->ModuleRST.find(line)) {
         rst = "]" + this->ModuleRST.match(1) + "]";
-        }
       }
     }
-  if(rst == "#")
-    {
+  }
+  if (rst == "#") {
     this->Reset();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmRST::Reset()
 {
-  if(!this->MarkupLines.empty())
-    {
+  if (!this->MarkupLines.empty()) {
     this->UnindentLines(this->MarkupLines);
-    }
-  switch(this->Directive)
-    {
-    case DirectiveNone: break;
-    case DirectiveParsedLiteral: this->ProcessDirectiveParsedLiteral(); break;
-    case DirectiveLiteralBlock: this->ProcessDirectiveLiteralBlock(); break;
-    case DirectiveCodeBlock: this->ProcessDirectiveCodeBlock(); break;
-    case DirectiveReplace: this->ProcessDirectiveReplace(); break;
-    case DirectiveTocTree: this->ProcessDirectiveTocTree(); break;
-    }
+  }
+  switch (this->Directive) {
+    case DirectiveNone:
+      break;
+    case DirectiveParsedLiteral:
+      this->ProcessDirectiveParsedLiteral();
+      break;
+    case DirectiveLiteralBlock:
+      this->ProcessDirectiveLiteralBlock();
+      break;
+    case DirectiveCodeBlock:
+      this->ProcessDirectiveCodeBlock();
+      break;
+    case DirectiveReplace:
+      this->ProcessDirectiveReplace();
+      break;
+    case DirectiveTocTree:
+      this->ProcessDirectiveTocTree();
+      break;
+  }
   this->Markup = MarkupNone;
   this->Directive = DirectiveNone;
   this->MarkupLines.clear();
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessLine(std::string const& line)
 {
   bool lastLineEndedInColonColon = this->LastLineEndedInColonColon;
   this->LastLineEndedInColonColon = false;
 
   // A line starting in .. is an explicit markup start.
-  if(line == ".." || (line.size() >= 3 && line[0] == '.' &&
-                      line[1] == '.' && isspace(line[2])))
-    {
+  if (line == ".." || (line.size() >= 3 && line[0] == '.' && line[1] == '.' &&
+                       isspace(line[2]))) {
     this->Reset();
-    this->Markup = (line.find_first_not_of(" \t", 2) == line.npos ?
-                    MarkupEmpty : MarkupNormal);
-    if(this->CMakeDirective.find(line))
-      {
+    this->Markup =
+      (line.find_first_not_of(" \t", 2) == line.npos ? MarkupEmpty
+                                                     : MarkupNormal);
+    if (this->CMakeDirective.find(line)) {
       // Output cmake domain directives and their content normally.
       this->NormalLine(line);
-      }
-    else if(this->CMakeModuleDirective.find(line))
-      {
+    } else if (this->CMakeModuleDirective.find(line)) {
       // Process cmake-module directive: scan .cmake file comments.
       std::string file = this->CMakeModuleDirective.match(1);
-      if(file.empty() || !this->ProcessInclude(file, IncludeModule))
-        {
+      if (file.empty() || !this->ProcessInclude(file, IncludeModule)) {
         this->NormalLine(line);
-        }
       }
-    else if(this->ParsedLiteralDirective.find(line))
-      {
+    } else if (this->ParsedLiteralDirective.find(line)) {
       // Record the literal lines to output after whole block.
       this->Directive = DirectiveParsedLiteral;
       this->MarkupLines.push_back(this->ParsedLiteralDirective.match(1));
-      }
-    else if(this->CodeBlockDirective.find(line))
-      {
+    } else if (this->CodeBlockDirective.find(line)) {
       // Record the literal lines to output after whole block.
       // Ignore the language spec and record the opening line as blank.
       this->Directive = DirectiveCodeBlock;
       this->MarkupLines.push_back("");
-      }
-    else if(this->ReplaceDirective.find(line))
-      {
+    } else if (this->ReplaceDirective.find(line)) {
       // Record the replace directive content.
       this->Directive = DirectiveReplace;
       this->ReplaceName = this->ReplaceDirective.match(1);
       this->MarkupLines.push_back(this->ReplaceDirective.match(2));
-      }
-    else if(this->IncludeDirective.find(line))
-      {
+    } else if (this->IncludeDirective.find(line)) {
       // Process the include directive or output the directive and its
       // content normally if it fails.
       std::string file = this->IncludeDirective.match(1);
-      if(file.empty() || !this->ProcessInclude(file, IncludeNormal))
-        {
+      if (file.empty() || !this->ProcessInclude(file, IncludeNormal)) {
         this->NormalLine(line);
-        }
       }
-    else if(this->TocTreeDirective.find(line))
-      {
+    } else if (this->TocTreeDirective.find(line)) {
       // Record the toctree entries to process after whole block.
       this->Directive = DirectiveTocTree;
       this->MarkupLines.push_back(this->TocTreeDirective.match(1));
-      }
-    else if(this->ProductionListDirective.find(line))
-      {
+    } else if (this->ProductionListDirective.find(line)) {
       // Output productionlist directives and their content normally.
       this->NormalLine(line);
-      }
-    else if(this->NoteDirective.find(line))
-      {
+    } else if (this->NoteDirective.find(line)) {
       // Output note directives and their content normally.
       this->NormalLine(line);
-      }
     }
+  }
   // An explicit markup start followed nothing but whitespace and a
   // blank line does not consume any indented text following.
-  else if(this->Markup == MarkupEmpty && line.empty())
-    {
+  else if (this->Markup == MarkupEmpty && line.empty()) {
     this->NormalLine(line);
-    }
+  }
   // Indented lines following an explicit markup start are explicit markup.
-  else if(this->Markup && (line.empty() || isspace(line[0])))
-    {
+  else if (this->Markup && (line.empty() || isspace(line[0]))) {
     this->Markup = MarkupNormal;
     // Record markup lines if the start line was recorded.
-    if(!this->MarkupLines.empty())
-      {
+    if (!this->MarkupLines.empty()) {
       this->MarkupLines.push_back(line);
-      }
     }
+  }
   // A blank line following a paragraph ending in "::" starts a literal block.
-  else if(lastLineEndedInColonColon && line.empty())
-    {
+  else if (lastLineEndedInColonColon && line.empty()) {
     // Record the literal lines to output after whole block.
     this->Markup = MarkupNormal;
     this->Directive = DirectiveLiteralBlock;
     this->MarkupLines.push_back("");
     this->OutputLine("", false);
-    }
+  }
   // Print non-markup lines.
-  else
-    {
+  else {
     this->NormalLine(line);
-    this->LastLineEndedInColonColon = (line.size() >= 2
-      && line[line.size()-2] == ':' && line[line.size()-1] == ':');
-    }
+    this->LastLineEndedInColonColon =
+      (line.size() >= 2 && line[line.size() - 2] == ':' &&
+       line[line.size() - 1] == ':');
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmRST::NormalLine(std::string const& line)
 {
   this->Reset();
   this->OutputLine(line, true);
 }
 
-//----------------------------------------------------------------------------
 void cmRST::OutputLine(std::string const& line_in, bool inlineMarkup)
 {
-  if(this->OutputLinePending)
-    {
+  if (this->OutputLinePending) {
     this->OS << "\n";
     this->OutputLinePending = false;
-    }
-  if(inlineMarkup)
-    {
+  }
+  if (inlineMarkup) {
     std::string line = this->ReplaceSubstitutions(line_in);
     std::string::size_type pos = 0;
-    while(this->CMakeRole.find(line.c_str()+pos))
-      {
+    while (this->CMakeRole.find(line.c_str() + pos)) {
       this->OS << line.substr(pos, this->CMakeRole.start());
       std::string text = this->CMakeRole.match(3);
       // If a command reference has no explicit target and
       // no explicit "(...)" then add "()" to the text.
-      if(this->CMakeRole.match(2) == "command" &&
-         this->CMakeRole.match(5).empty() &&
-         text.find_first_of("()") == text.npos)
-        {
+      if (this->CMakeRole.match(2) == "command" &&
+          this->CMakeRole.match(5).empty() &&
+          text.find_first_of("()") == text.npos) {
         text += "()";
-        }
+      }
       this->OS << "``" << text << "``";
       pos += this->CMakeRole.end();
-      }
-    this->OS << line.substr(pos) << "\n";
     }
-  else
-    {
+    this->OS << line.substr(pos) << "\n";
+  } else {
     this->OS << line_in << "\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmRST::ReplaceSubstitutions(std::string const& line)
 {
   std::string out;
   std::string::size_type pos = 0;
-  while(this->Substitution.find(line.c_str()+pos))
-    {
+  while (this->Substitution.find(line.c_str() + pos)) {
     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<std::string, std::string>::iterator
-      replace = this->Replace.find(substitute);
-    if(replace != this->Replace.end())
-      {
+    std::map<std::string, std::string>::iterator replace =
+      this->Replace.find(substitute);
+    if (replace != this->Replace.end()) {
       std::pair<std::set<std::string>::iterator, bool> replaced =
         this->Replaced.insert(substitute);
-      if(replaced.second)
-        {
+      if (replaced.second) {
         substitute = this->ReplaceSubstitutions(replace->second);
         this->Replaced.erase(replaced.first);
-        }
       }
+    }
     out += line.substr(pos, start);
     out += substitute;
     pos += end;
-    }
+  }
   out += line.substr(pos);
   return out;
 }
 
-//----------------------------------------------------------------------------
 void cmRST::OutputMarkupLines(bool inlineMarkup)
 {
-  for(std::vector<std::string>::iterator i = this->MarkupLines.begin();
-      i != this->MarkupLines.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = this->MarkupLines.begin();
+       i != this->MarkupLines.end(); ++i) {
     std::string line = *i;
-    if(!line.empty())
-      {
+    if (!line.empty()) {
       line = " " + line;
-      }
-    this->OutputLine(line, inlineMarkup);
     }
+    this->OutputLine(line, inlineMarkup);
+  }
   this->OutputLinePending = true;
 }
 
-//----------------------------------------------------------------------------
 bool cmRST::ProcessInclude(std::string file, IncludeType type)
 {
   bool found = false;
-  if(this->IncludeDepth < 10)
-    {
+  if (this->IncludeDepth < 10) {
     cmRST r(this->OS, this->DocRoot);
     r.IncludeDepth = this->IncludeDepth + 1;
     r.OutputLinePending = this->OutputLinePending;
-    if(type != IncludeTocTree)
-      {
+    if (type != IncludeTocTree) {
       r.Replace = this->Replace;
-      }
-    if(file[0] == '/')
-      {
+    }
+    if (file[0] == '/') {
       file = this->DocRoot + file;
-      }
-    else
-      {
+    } else {
       file = this->DocDir + "/" + file;
-      }
+    }
     found = r.ProcessFile(file, type == IncludeModule);
-    if(type != IncludeTocTree)
-      {
+    if (type != IncludeTocTree) {
       this->Replace = r.Replace;
-      }
-    this->OutputLinePending = r.OutputLinePending;
     }
+    this->OutputLinePending = r.OutputLinePending;
+  }
   return found;
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveParsedLiteral()
 {
   this->OutputMarkupLines(true);
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveLiteralBlock()
 {
   this->OutputMarkupLines(false);
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveCodeBlock()
 {
   this->OutputMarkupLines(false);
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveReplace()
 {
   // Record markup lines as replacement text.
@@ -422,78 +354,71 @@ void cmRST::ProcessDirectiveReplace()
   this->ReplaceName = "";
 }
 
-//----------------------------------------------------------------------------
 void cmRST::ProcessDirectiveTocTree()
 {
   // Process documents referenced by toctree directive.
-  for(std::vector<std::string>::iterator i = this->MarkupLines.begin();
-      i != this->MarkupLines.end(); ++i)
-    {
-    if(!i->empty() && i->find_first_of(":") == i->npos)
-      {
-      this->ProcessInclude(*i + ".rst", IncludeTocTree);
+  for (std::vector<std::string>::iterator i = this->MarkupLines.begin();
+       i != this->MarkupLines.end(); ++i) {
+    std::string const& line = *i;
+    if (!line.empty() && line[0] != ':') {
+      if (this->TocTreeLink.find(line)) {
+        std::string const& link = this->TocTreeLink.match(1);
+        this->ProcessInclude(link + ".rst", IncludeTocTree);
+      } else {
+        this->ProcessInclude(line + ".rst", IncludeTocTree);
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmRST::UnindentLines(std::vector<std::string>& lines)
 {
   // Remove the common indentation from the second and later lines.
   std::string indentText;
   std::string::size_type indentEnd = 0;
   bool first = true;
-  for(size_t i = 1; i < lines.size(); ++i)
-    {
+  for (size_t i = 1; i < lines.size(); ++i) {
     std::string const& line = lines[i];
 
     // Do not consider empty lines.
-    if(line.empty())
-      {
+    if (line.empty()) {
       continue;
-      }
+    }
 
     // Record indentation on first non-empty line.
-    if(first)
-      {
+    if (first) {
       first = false;
       indentEnd = line.find_first_not_of(" \t");
       indentText = line.substr(0, indentEnd);
       continue;
-      }
+    }
 
     // Truncate indentation to match that on this line.
     indentEnd = std::min(indentEnd, line.size());
-    for(std::string::size_type j = 0; j != indentEnd; ++j)
-      {
-      if(line[j] != indentText[j])
-        {
+    for (std::string::size_type j = 0; j != indentEnd; ++j) {
+      if (line[j] != indentText[j]) {
         indentEnd = j;
         break;
-        }
       }
     }
+  }
 
   // Update second and later lines.
-  for(size_t i = 1; i < lines.size(); ++i)
-    {
+  for (size_t i = 1; i < lines.size(); ++i) {
     std::string& line = lines[i];
-    if(!line.empty())
-      {
+    if (!line.empty()) {
       line = line.substr(indentEnd);
-      }
     }
+  }
 
   std::vector<std::string>::const_iterator it = lines.begin();
   size_t leadingEmpty = std::distance(it, cmFindNot(lines, std::string()));
 
   std::vector<std::string>::const_reverse_iterator rit = lines.rbegin();
-  size_t trailingEmpty = std::distance(rit,
-                            cmFindNot(cmReverseRange(lines), std::string()));
+  size_t trailingEmpty =
+    std::distance(rit, cmFindNot(cmReverseRange(lines), std::string()));
 
-  std::vector<std::string>::iterator contentEnd
-      = cmRotate(lines.begin(),
-                 lines.begin() + leadingEmpty,
-                 lines.end() - trailingEmpty);
+  std::vector<std::string>::iterator contentEnd = cmRotate(
+    lines.begin(), lines.begin() + leadingEmpty, lines.end() - trailingEmpty);
   lines.erase(contentEnd, lines.end());
 }
diff --git a/Source/cmRST.h b/Source/cmRST.h
index b9b2366..0e379b6 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -31,6 +31,7 @@ class cmRST
 public:
   cmRST(std::ostream& os, std::string const& docroot);
   bool ProcessFile(std::string const& fname, bool isModule = false);
+
 private:
   enum IncludeType
   {
@@ -89,6 +90,7 @@ private:
   cmsys::RegularExpression ModuleRST;
   cmsys::RegularExpression CMakeRole;
   cmsys::RegularExpression Substitution;
+  cmsys::RegularExpression TocTreeLink;
 
   std::vector<std::string> MarkupLines;
   std::string DocDir;
diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx
index bad38be..955f712 100644
--- a/Source/cmRemoveCommand.cxx
+++ b/Source/cmRemoveCommand.cxx
@@ -12,24 +12,21 @@
 #include "cmRemoveCommand.h"
 
 // cmRemoveCommand
-bool cmRemoveCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
+                                  cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
 
   const char* variable = args[0].c_str(); // VAR is always first
   // get the old value
-  const char* cacheValue
-    = this->Makefile->GetDefinition(variable);
+  const char* cacheValue = this->Makefile->GetDefinition(variable);
 
   // if there is no old value then return
-  if (!cacheValue)
-    {
+  if (!cacheValue) {
     return true;
-    }
+  }
 
   // expand the variable
   std::vector<std::string> varArgsExpanded;
@@ -44,30 +41,24 @@ bool cmRemoveCommand
 
   // now create the new value
   std::string value;
-  for(unsigned int j = 0; j < varArgsExpanded.size(); ++j)
-    {
+  for (unsigned int j = 0; j < varArgsExpanded.size(); ++j) {
     int found = 0;
-    for(unsigned int k = 0; k < argsExpanded.size(); ++k)
-      {
-      if (varArgsExpanded[j] == argsExpanded[k])
-        {
+    for (unsigned int k = 0; k < argsExpanded.size(); ++k) {
+      if (varArgsExpanded[j] == argsExpanded[k]) {
         found = 1;
         break;
-        }
       }
-    if (!found)
-      {
-      if (!value.empty())
-        {
+    }
+    if (!found) {
+      if (!value.empty()) {
         value += ";";
-        }
-      value += varArgsExpanded[j];
       }
+      value += varArgsExpanded[j];
     }
+  }
 
   // add the definition
   this->Makefile->AddDefinition(variable, value.c_str());
 
   return true;
 }
-
diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h
index 410b370..c226a54 100644
--- a/Source/cmRemoveCommand.h
+++ b/Source/cmRemoveCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmRemoveCommand;
-    }
+  virtual cmCommand* Clone() { return new cmRemoveCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "remove";}
+  virtual std::string GetName() const { return "remove"; }
 
   cmTypeMacro(cmRemoveCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmRemoveDefinitionsCommand.cxx b/Source/cmRemoveDefinitionsCommand.cxx
index b4be0f5..638eda6 100644
--- a/Source/cmRemoveDefinitionsCommand.cxx
+++ b/Source/cmRemoveDefinitionsCommand.cxx
@@ -12,20 +12,17 @@
 #include "cmRemoveDefinitionsCommand.h"
 
 // cmRemoveDefinitionsCommand
-bool cmRemoveDefinitionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmRemoveDefinitionsCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   // it is OK to have no arguments
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     return true;
-    }
+  }
 
-  for(std::vector<std::string>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
     this->Makefile->RemoveDefineFlag(i->c_str());
-    }
+  }
   return true;
 }
-
diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h
index cac94be..b440307 100644
--- a/Source/cmRemoveDefinitionsCommand.h
+++ b/Source/cmRemoveDefinitionsCommand.h
@@ -27,26 +27,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmRemoveDefinitionsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmRemoveDefinitionsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "remove_definitions";}
+  virtual std::string GetName() const { return "remove_definitions"; }
 
   cmTypeMacro(cmRemoveDefinitionsCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmReturnCommand.cxx b/Source/cmReturnCommand.cxx
index 51cc83f..1de649f 100644
--- a/Source/cmReturnCommand.cxx
+++ b/Source/cmReturnCommand.cxx
@@ -13,9 +13,8 @@
 
 // cmReturnCommand
 bool cmReturnCommand::InitialPass(std::vector<std::string> const&,
-                                  cmExecutionStatus &status)
+                                  cmExecutionStatus& status)
 {
   status.SetReturnInvoked(true);
   return true;
 }
-
diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h
index 4ff81ef..44cd4c8 100644
--- a/Source/cmReturnCommand.h
+++ b/Source/cmReturnCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmReturnCommand;
-    }
+  virtual cmCommand* Clone() { return new cmReturnCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "return";}
+  virtual std::string GetName() const { return "return"; }
 
   cmTypeMacro(cmReturnCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index e44b236..5fed107 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -13,29 +13,24 @@
 
 #include "cmSystemTools.h"
 
-//----------------------------------------------------------------------------
-cmScriptGenerator
-::cmScriptGenerator(const std::string& config_var,
-                    std::vector<std::string> const& configurations):
-  RuntimeConfigVariable(config_var),
-  Configurations(configurations),
-  ConfigurationName(""),
-  ConfigurationTypes(0),
-  ActionsPerConfig(false)
+cmScriptGenerator::cmScriptGenerator(
+  const std::string& config_var,
+  std::vector<std::string> const& configurations)
+  : RuntimeConfigVariable(config_var)
+  , Configurations(configurations)
+  , ConfigurationName("")
+  , ConfigurationTypes(0)
+  , ActionsPerConfig(false)
 {
 }
 
-//----------------------------------------------------------------------------
-cmScriptGenerator
-::~cmScriptGenerator()
+cmScriptGenerator::~cmScriptGenerator()
 {
 }
 
-//----------------------------------------------------------------------------
-void
-cmScriptGenerator
-::Generate(std::ostream& os, const std::string& config,
-           std::vector<std::string> const& configurationTypes)
+void cmScriptGenerator::Generate(
+  std::ostream& os, const std::string& config,
+  std::vector<std::string> const& configurationTypes)
 {
   this->ConfigurationName = config;
   this->ConfigurationTypes = &configurationTypes;
@@ -44,68 +39,55 @@ cmScriptGenerator
   this->ConfigurationTypes = 0;
 }
 
-//----------------------------------------------------------------------------
 static void cmScriptGeneratorEncodeConfig(const std::string& config,
                                           std::string& result)
 {
-  for(const char* c = config.c_str(); *c; ++c)
-    {
-    if(*c >= 'a' && *c <= 'z')
-      {
+  for (const char* c = config.c_str(); *c; ++c) {
+    if (*c >= 'a' && *c <= 'z') {
       result += "[";
       result += static_cast<char>(*c + 'A' - 'a');
       result += *c;
       result += "]";
-      }
-    else if(*c >= 'A' && *c <= 'Z')
-      {
+    } else if (*c >= 'A' && *c <= 'Z') {
       result += "[";
       result += *c;
       result += static_cast<char>(*c + 'a' - 'A');
       result += "]";
-      }
-    else
-      {
+    } else {
       result += *c;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmScriptGenerator::CreateConfigTest(const std::string& config)
+std::string cmScriptGenerator::CreateConfigTest(const std::string& config)
 {
   std::string result = "\"${";
   result += this->RuntimeConfigVariable;
   result += "}\" MATCHES \"^(";
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     cmScriptGeneratorEncodeConfig(config, result);
-    }
+  }
   result += ")$\"";
   return result;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmScriptGenerator::CreateConfigTest(std::vector<std::string> const& configs)
+std::string cmScriptGenerator::CreateConfigTest(
+  std::vector<std::string> const& configs)
 {
   std::string result = "\"${";
   result += this->RuntimeConfigVariable;
   result += "}\" MATCHES \"^(";
   const char* sep = "";
-  for(std::vector<std::string>::const_iterator ci = configs.begin();
-      ci != configs.end(); ++ci)
-    {
+  for (std::vector<std::string>::const_iterator ci = configs.begin();
+       ci != configs.end(); ++ci) {
     result += sep;
     sep = "|";
     cmScriptGeneratorEncodeConfig(*ci, result);
-    }
+  }
   result += ")$\"";
   return result;
 }
 
-//----------------------------------------------------------------------------
 void cmScriptGenerator::GenerateScript(std::ostream& os)
 {
   // Track indentation.
@@ -115,33 +97,26 @@ void cmScriptGenerator::GenerateScript(std::ostream& os)
   this->GenerateScriptConfigs(os, indent);
 }
 
-//----------------------------------------------------------------------------
 void cmScriptGenerator::GenerateScriptConfigs(std::ostream& os,
                                               Indent const& indent)
 {
-  if(this->ActionsPerConfig)
-    {
+  if (this->ActionsPerConfig) {
     this->GenerateScriptActionsPerConfig(os, indent);
-    }
-  else
-    {
+  } else {
     this->GenerateScriptActionsOnce(os, indent);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmScriptGenerator::GenerateScriptActions(std::ostream& os,
                                               Indent const& indent)
 {
-  if(this->ActionsPerConfig)
-    {
+  if (this->ActionsPerConfig) {
     // This is reached for single-configuration build generators in a
     // per-config script generator.
     this->GenerateScriptForConfig(os, this->ConfigurationName, indent);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmScriptGenerator::GenerateScriptForConfig(std::ostream&,
                                                 const std::string&,
                                                 Indent const&)
@@ -149,90 +124,74 @@ void cmScriptGenerator::GenerateScriptForConfig(std::ostream&,
   // No actions for this generator.
 }
 
-//----------------------------------------------------------------------------
 bool cmScriptGenerator::GeneratesForConfig(const std::string& config)
 {
   // If this is not a configuration-specific rule then we install.
-  if(this->Configurations.empty())
-    {
+  if (this->Configurations.empty()) {
     return true;
-    }
+  }
 
   // This is a configuration-specific rule.  Check if the config
   // matches this rule.
   std::string config_upper = cmSystemTools::UpperCase(config);
-  for(std::vector<std::string>::const_iterator i =
-        this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
-    if(cmSystemTools::UpperCase(*i) == config_upper)
-      {
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
+    if (cmSystemTools::UpperCase(*i) == config_upper) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmScriptGenerator::GenerateScriptActionsOnce(std::ostream& os,
                                                   Indent const& indent)
 {
-  if(this->Configurations.empty())
-    {
+  if (this->Configurations.empty()) {
     // This rule is for all configurations.
     this->GenerateScriptActions(os, indent);
-    }
-  else
-    {
+  } else {
     // Generate a per-configuration block.
     std::string config_test = this->CreateConfigTest(this->Configurations);
     os << indent << "if(" << config_test << ")\n";
     this->GenerateScriptActions(os, indent.Next());
     os << indent << "endif(" << config_test << ")\n";
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os,
                                                        Indent const& indent)
 {
-  if(this->ConfigurationTypes->empty())
-    {
+  if (this->ConfigurationTypes->empty()) {
     // In a single-configuration generator there is only one action
     // and it applies if the runtime-requested configuration is among
     // the rule's allowed configurations.  The configuration built in
     // the tree does not matter for this decision but will be used to
     // generate proper target file names into the code.
     this->GenerateScriptActionsOnce(os, indent);
-    }
-  else
-    {
+  } else {
     // In a multi-configuration generator we produce a separate rule
     // in a block for each configuration that is built.  We restrict
     // the list of configurations to those to which this rule applies.
     bool first = true;
-    for(std::vector<std::string>::const_iterator i =
-          this->ConfigurationTypes->begin();
-        i != this->ConfigurationTypes->end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i =
+           this->ConfigurationTypes->begin();
+         i != this->ConfigurationTypes->end(); ++i) {
       const char* config = i->c_str();
-      if(this->GeneratesForConfig(config))
-        {
+      if (this->GeneratesForConfig(config)) {
         // Generate a per-configuration block.
         std::string config_test = this->CreateConfigTest(config);
-        os << indent << (first? "if(" : "elseif(") << config_test << ")\n";
+        os << indent << (first ? "if(" : "elseif(") << config_test << ")\n";
         this->GenerateScriptForConfig(os, config, indent.Next());
         first = false;
-        }
       }
-    if(!first)
-      {
-      if(this->NeedsScriptNoConfig())
-        {
+    }
+    if (!first) {
+      if (this->NeedsScriptNoConfig()) {
         os << indent << "else()\n";
         this->GenerateScriptNoConfig(os, indent.Next());
-        }
-      os << indent << "endif()\n";
       }
+      os << indent << "endif()\n";
     }
+  }
 }
diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h
index bc9372f..ef0766f 100644
--- a/Source/cmScriptGenerator.h
+++ b/Source/cmScriptGenerator.h
@@ -17,19 +17,25 @@
 class cmScriptGeneratorIndent
 {
 public:
-  cmScriptGeneratorIndent(): Level(0) {}
-  cmScriptGeneratorIndent(int level): Level(level) {}
+  cmScriptGeneratorIndent()
+    : Level(0)
+  {
+  }
+  cmScriptGeneratorIndent(int level)
+    : Level(level)
+  {
+  }
   void Write(std::ostream& os) const
-    {
-    for(int i=0; i < this->Level; ++i)
-      {
+  {
+    for (int i = 0; i < this->Level; ++i) {
       os << " ";
-      }
     }
+  }
   cmScriptGeneratorIndent Next(int step = 2) const
-    {
+  {
     return cmScriptGeneratorIndent(this->Level + step);
-    }
+  }
+
 private:
   int Level;
 };
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
index c9cc817..a0cce12 100644
--- a/Source/cmSearchPath.cxx
+++ b/Source/cmSearchPath.cxx
@@ -9,49 +9,40 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-
 #include "cmSearchPath.h"
-#include "cmFindCommon.h"
+
 #include "cmAlgorithms.h"
+#include "cmFindCommon.h"
 
-//----------------------------------------------------------------------------
 cmSearchPath::cmSearchPath(cmFindCommon* findCmd)
-: FC(findCmd)
+  : FC(findCmd)
 {
 }
 
-//----------------------------------------------------------------------------
 cmSearchPath::~cmSearchPath()
 {
 }
 
-//----------------------------------------------------------------------------
-
 void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore,
                                   std::vector<std::string>& outPaths,
                                   bool clear) const
 {
-  if(clear)
-    {
+  if (clear) {
     outPaths.clear();
-    }
-  for(std::vector<std::string>::const_iterator p = this->Paths.begin();
-      p != this->Paths.end(); ++p)
-    {
-    if(ignore.count(*p) == 0)
-      {
+  }
+  for (std::vector<std::string>::const_iterator p = this->Paths.begin();
+       p != this->Paths.end(); ++p) {
+    if (ignore.count(*p) == 0) {
       outPaths.push_back(*p);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddPath(const std::string& path)
 {
   this->AddPathInternal(path);
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddUserPath(const std::string& path)
 {
   assert(this->FC != NULL);
@@ -62,11 +53,10 @@ void cmSearchPath::AddUserPath(const std::string& path)
   // it.
   cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
   cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
-  if(this->FC->Makefile->PlatformIs64Bit())
-    {
+  if (this->FC->Makefile->PlatformIs64Bit()) {
     view = cmSystemTools::KeyWOW64_64;
     other_view = cmSystemTools::KeyWOW64_32;
-    }
+  }
 
   // Expand using the view of the target application.
   std::string expanded = path;
@@ -75,200 +65,164 @@ void cmSearchPath::AddUserPath(const std::string& path)
 
   // Executables can be either 32-bit or 64-bit, so expand using the
   // alternative view.
-  if(expanded != path && this->FC->CMakePathName == "PROGRAM")
-    {
+  if (expanded != path && this->FC->CMakePathName == "PROGRAM") {
     expanded = path;
     cmSystemTools::ExpandRegistryValues(expanded, other_view);
     cmSystemTools::GlobDirs(expanded, outPaths);
-    }
+  }
 
   // Process them all from the current directory
-  for(std::vector<std::string>::const_iterator p = outPaths.begin();
-      p != outPaths.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p = outPaths.begin();
+       p != outPaths.end(); ++p) {
     this->AddPathInternal(*p, this->FC->Makefile->GetCurrentSourceDirectory());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddCMakePath(const std::string& variable)
 {
   assert(this->FC != NULL);
 
   // Get a path from a CMake variable.
-  if(const char* value = this->FC->Makefile->GetDefinition(variable))
-    {
+  if (const char* value = this->FC->Makefile->GetDefinition(variable)) {
     std::vector<std::string> expanded;
     cmSystemTools::ExpandListArgument(value, expanded);
 
-    for(std::vector<std::string>::const_iterator p = expanded.begin();
-        p!= expanded.end(); ++p)
-      {
+    for (std::vector<std::string>::const_iterator p = expanded.begin();
+         p != expanded.end(); ++p) {
       this->AddPathInternal(*p,
                             this->FC->Makefile->GetCurrentSourceDirectory());
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddEnvPath(const std::string& variable)
 {
   std::vector<std::string> expanded;
   cmSystemTools::GetPath(expanded, variable.c_str());
-  for(std::vector<std::string>::const_iterator p = expanded.begin();
-      p!= expanded.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p = expanded.begin();
+       p != expanded.end(); ++p) {
     this->AddPathInternal(*p);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddCMakePrefixPath(const std::string& variable)
 {
   assert(this->FC != NULL);
 
   // Get a path from a CMake variable.
-  if(const char* value = this->FC->Makefile->GetDefinition(variable))
-    {
+  if (const char* value = this->FC->Makefile->GetDefinition(variable)) {
     std::vector<std::string> expanded;
     cmSystemTools::ExpandListArgument(value, expanded);
 
     this->AddPrefixPaths(expanded,
                          this->FC->Makefile->GetCurrentSourceDirectory());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 static std::string cmSearchPathStripBin(std::string const& s)
 {
   // If the path is a PREFIX/bin case then add its parent instead.
-  if((cmHasLiteralSuffix(s, "/bin")) ||
-     (cmHasLiteralSuffix(s, "/sbin")))
-    {
+  if ((cmHasLiteralSuffix(s, "/bin")) || (cmHasLiteralSuffix(s, "/sbin"))) {
     return cmSystemTools::GetFilenamePath(s);
-    }
-  else
-    {
+  } else {
     return s;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddEnvPrefixPath(const std::string& variable, bool stripBin)
 {
   std::vector<std::string> expanded;
   cmSystemTools::GetPath(expanded, variable.c_str());
-  if (stripBin)
-    {
+  if (stripBin) {
     std::transform(expanded.begin(), expanded.end(), expanded.begin(),
                    cmSearchPathStripBin);
-    }
+  }
   this->AddPrefixPaths(expanded);
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
 {
   std::vector<std::string> inPaths;
   inPaths.swap(this->Paths);
-  this->Paths.reserve(inPaths.size()*(suffixes.size()+1));
+  this->Paths.reserve(inPaths.size() * (suffixes.size() + 1));
 
-  for(std::vector<std::string>::iterator ip = inPaths.begin();
-      ip != inPaths.end(); ++ip)
-    {
+  for (std::vector<std::string>::iterator ip = inPaths.begin();
+       ip != inPaths.end(); ++ip) {
     cmSystemTools::ConvertToUnixSlashes(*ip);
 
     // if *i is only / then do not add a //
     // this will get incorrectly considered a network
     // path on windows and cause huge delays.
     std::string p = *ip;
-    if(!p.empty() && *p.rbegin() != '/')
-      {
+    if (!p.empty() && *p.rbegin() != '/') {
       p += "/";
-      }
+    }
 
     // Combine with all the suffixes
-    for(std::vector<std::string>::const_iterator s = suffixes.begin();
-        s != suffixes.end(); ++s)
-      {
-      this->Paths.push_back(p+*s);
-      }
+    for (std::vector<std::string>::const_iterator s = suffixes.begin();
+         s != suffixes.end(); ++s) {
+      this->Paths.push_back(p + *s);
+    }
 
     // And now the original w/o any suffix
     this->Paths.push_back(*ip);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
-                                  const char *base)
+                                  const char* base)
 {
   assert(this->FC != NULL);
 
   // default for programs
   std::string subdir = "bin";
 
-  if (this->FC->CMakePathName == "INCLUDE")
-    {
+  if (this->FC->CMakePathName == "INCLUDE") {
     subdir = "include";
-    }
-  else if (this->FC->CMakePathName == "LIBRARY")
-    {
+  } else if (this->FC->CMakePathName == "LIBRARY") {
     subdir = "lib";
-    }
-  else if (this->FC->CMakePathName == "FRAMEWORK")
-    {
-    subdir = "";  // ? what to do for frameworks ?
-    }
+  } else if (this->FC->CMakePathName == "FRAMEWORK") {
+    subdir = ""; // ? what to do for frameworks ?
+  }
 
-  for(std::vector<std::string>::const_iterator p = paths.begin();
-      p != paths.end(); ++p)
-    {
+  for (std::vector<std::string>::const_iterator p = paths.begin();
+       p != paths.end(); ++p) {
     std::string dir = *p;
-    if(!subdir.empty() && !dir.empty() && *dir.rbegin() != '/')
-      {
+    if (!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') {
       dir += "/";
-      }
-    if(subdir == "include" || subdir == "lib")
-      {
+    }
+    if (subdir == "include" || subdir == "lib") {
       const char* arch =
         this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE");
-      if(arch && *arch)
-        {
-        this->AddPathInternal(dir+subdir+"/"+arch, base);
-        }
+      if (arch && *arch) {
+        this->AddPathInternal(dir + subdir + "/" + arch, base);
       }
+    }
     std::string add = dir + subdir;
-    if(add != "/")
-      {
+    if (add != "/") {
       this->AddPathInternal(add, base);
-      }
-    if (subdir == "bin")
-      {
-      this->AddPathInternal(dir+"sbin", base);
-      }
-    if(!subdir.empty() && *p != "/")
-      {
+    }
+    if (subdir == "bin") {
+      this->AddPathInternal(dir + "sbin", base);
+    }
+    if (!subdir.empty() && *p != "/") {
       this->AddPathInternal(*p, base);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmSearchPath::AddPathInternal(const std::string& path, const char *base)
+void cmSearchPath::AddPathInternal(const std::string& path, const char* base)
 {
   assert(this->FC != NULL);
 
   std::string collapsed = cmSystemTools::CollapseFullPath(path, base);
 
-   if(collapsed.empty())
-    {
+  if (collapsed.empty()) {
     return;
-    }
+  }
 
   // Insert the path if has not already been emitted.
-  if(this->FC->SearchPathsEmitted.insert(collapsed).second)
-    {
+  if (this->FC->SearchPathsEmitted.insert(collapsed).second) {
     this->Paths.push_back(collapsed);
-    }
+  }
 }
diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h
index 41c680d..835196f 100644
--- a/Source/cmSearchPath.h
+++ b/Source/cmSearchPath.h
@@ -26,7 +26,7 @@ class cmSearchPath
 {
 public:
   // cmSearchPath must be initialized from a valid pointer.  The only reason
-  // for teh default is to allow it to be easily used in stl containers.
+  // for the default is to allow it to be easily used in stl containers.
   // Attempting to initialize with a NULL value will fail an assertion
   cmSearchPath(cmFindCommon* findCmd = 0);
   ~cmSearchPath();
@@ -47,10 +47,10 @@ public:
 
 protected:
   void AddPrefixPaths(const std::vector<std::string>& paths,
-                      const char *base = 0);
-  void AddPathInternal(const std::string& path, const char *base = 0);
+                      const char* base = 0);
+  void AddPathInternal(const std::string& path, const char* base = 0);
 
-  cmFindCommon *FC;
+  cmFindCommon* FC;
   std::vector<std::string> Paths;
 };
 
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 8e6c311..440b635 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -12,98 +12,89 @@
 #include "cmSeparateArgumentsCommand.h"
 
 // cmSeparateArgumentsCommand
-bool cmSeparateArgumentsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSeparateArgumentsCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.empty())
-    {
+  if (args.empty()) {
     this->SetError("must be given at least one argument.");
     return false;
-    }
+  }
 
   std::string var;
   std::string command;
-  enum Mode { ModeOld, ModeUnix, ModeWindows };
+  enum Mode
+  {
+    ModeOld,
+    ModeUnix,
+    ModeWindows
+  };
   Mode mode = ModeOld;
-  enum Doing { DoingNone, DoingVariable, DoingMode, DoingCommand };
+  enum Doing
+  {
+    DoingNone,
+    DoingVariable,
+    DoingMode,
+    DoingCommand
+  };
   Doing doing = DoingVariable;
-  for(unsigned int i=0; i < args.size(); ++i)
-    {
-    if(doing == DoingVariable)
-      {
+  for (unsigned int i = 0; i < args.size(); ++i) {
+    if (doing == DoingVariable) {
       var = args[i];
       doing = DoingMode;
-      }
-    else if(doing == DoingMode && args[i] == "UNIX_COMMAND")
-      {
+    } else if (doing == DoingMode && args[i] == "UNIX_COMMAND") {
       mode = ModeUnix;
       doing = DoingCommand;
-      }
-    else if(doing == DoingMode && args[i] == "WINDOWS_COMMAND")
-      {
+    } else if (doing == DoingMode && args[i] == "WINDOWS_COMMAND") {
       mode = ModeWindows;
       doing = DoingCommand;
-      }
-    else if(doing == DoingCommand)
-      {
+    } else if (doing == DoingCommand) {
       command = args[i];
       doing = DoingNone;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "given unknown argument " << args[i];
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
-  if(mode == ModeOld)
-    {
+  if (mode == ModeOld) {
     // Original space-replacement version of command.
-    if(const char* def = this->Makefile->GetDefinition(var))
-      {
+    if (const char* def = this->Makefile->GetDefinition(var)) {
       std::string value = def;
-      cmSystemTools::ReplaceString(value, " ", ";");
+      std::replace(value.begin(), value.end(), ' ', ';');
       this->Makefile->AddDefinition(var, value.c_str());
-      }
     }
-  else
-    {
+  } else {
     // Parse the command line.
     std::vector<std::string> vec;
-    if(mode == ModeUnix)
-      {
+    if (mode == ModeUnix) {
       cmSystemTools::ParseUnixCommandLine(command.c_str(), vec);
-      }
-    else // if(mode == ModeWindows)
-      {
+    } else // if(mode == ModeWindows)
+    {
       cmSystemTools::ParseWindowsCommandLine(command.c_str(), vec);
-      }
+    }
 
     // Construct the result list value.
     std::string value;
     const char* sep = "";
-    for(std::vector<std::string>::const_iterator vi = vec.begin();
-        vi != vec.end(); ++vi)
-      {
+    for (std::vector<std::string>::const_iterator vi = vec.begin();
+         vi != vec.end(); ++vi) {
       // Separate from the previous argument.
       value += sep;
       sep = ";";
 
       // Preserve semicolons.
-      for(std::string::const_iterator si = vi->begin();
-          si != vi->end(); ++si)
-        {
-        if(*si == ';')
-          {
+      for (std::string::const_iterator si = vi->begin(); si != vi->end();
+           ++si) {
+        if (*si == ';') {
           value += '\\';
-          }
-        value += *si;
         }
+        value += *si;
       }
-    this->Makefile->AddDefinition(var, value.c_str());
     }
+    this->Makefile->AddDefinition(var, value.c_str());
+  }
 
   return true;
 }
diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h
index a527ae7..47246c9 100644
--- a/Source/cmSeparateArgumentsCommand.h
+++ b/Source/cmSeparateArgumentsCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmSeparateArgumentsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSeparateArgumentsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "separate_arguments";}
+  virtual std::string GetName() const { return "separate_arguments"; }
 
   cmTypeMacro(cmSeparateArgumentsCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 1d70ad6..5f4cfee 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -12,63 +12,56 @@
 #include "cmSetCommand.h"
 
 // cmSetCommand
-bool cmSetCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
+                               cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // watch for ENV signatures
   const char* variable = args[0].c_str(); // VAR is always first
-  if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5)
-    {
+  if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) {
     // what is the variable name
-    char *varName = new char [strlen(variable)];
-    strncpy(varName,variable+4,strlen(variable)-5);
-    varName[strlen(variable)-5] = '\0';
+    char* varName = new char[strlen(variable)];
+    strncpy(varName, variable + 4, strlen(variable) - 5);
+    varName[strlen(variable) - 5] = '\0';
     std::string putEnvArg = varName;
     putEnvArg += "=";
 
     // what is the current value if any
-    const char *currValue = getenv(varName);
-    delete [] varName;
+    const char* currValue = getenv(varName);
+    delete[] varName;
 
     // will it be set to something, then set it
-    if (args.size() > 1 && !args[1].empty())
-      {
+    if (args.size() > 1 && !args[1].empty()) {
       // but only if it is different from current value
-      if (!currValue || strcmp(currValue,args[1].c_str()))
-        {
+      if (!currValue || strcmp(currValue, args[1].c_str())) {
         putEnvArg += args[1];
         cmSystemTools::PutEnv(putEnvArg);
-        }
-      return true;
       }
+      return true;
+    }
 
     // if it will be cleared, then clear it if it isn't already clear
-    if (currValue)
-      {
+    if (currValue) {
       cmSystemTools::PutEnv(putEnvArg);
-      }
-    return true;
     }
+    return true;
+  }
 
   // SET (VAR) // Removes the definition of VAR.
-  if (args.size() == 1)
-    {
+  if (args.size() == 1) {
     this->Makefile->RemoveDefinition(variable);
     return true;
-    }
+  }
   // SET (VAR PARENT_SCOPE) // Removes the definition of VAR
-                            // in the parent scope.
-  else if (args.size() == 2 && args[args.size()-1] == "PARENT_SCOPE")
-    {
+  // in the parent scope.
+  else if (args.size() == 2 && args[args.size() - 1] == "PARENT_SCOPE") {
     this->Makefile->RaiseScope(variable, 0);
     return true;
-    }
+  }
 
   // here are the remaining options
   //  SET (VAR value )
@@ -79,91 +72,74 @@ bool cmSetCommand
   bool cache = false; // optional
   bool force = false; // optional
   bool parentScope = false;
-  cmState::CacheEntryType type
-    = cmState::STRING; // required if cache
-  const char* docstring = 0; // required if cache
+  cmState::CacheEntryType type = cmState::STRING; // required if cache
+  const char* docstring = 0;                      // required if cache
 
   unsigned int ignoreLastArgs = 0;
   // look for PARENT_SCOPE argument
-  if (args.size() > 1 && args[args.size()-1] == "PARENT_SCOPE")
-    {
+  if (args.size() > 1 && args[args.size() - 1] == "PARENT_SCOPE") {
     parentScope = true;
     ignoreLastArgs++;
-    }
-  else
-    {
+  } else {
     // look for FORCE argument
-    if (args.size() > 4 && args[args.size()-1] == "FORCE")
-      {
+    if (args.size() > 4 && args[args.size() - 1] == "FORCE") {
       force = true;
       ignoreLastArgs++;
-      }
+    }
 
     // check for cache signature
-    if (args.size() > 3 && args[args.size() - 3 - (force ? 1 : 0)] == "CACHE")
-      {
+    if (args.size() > 3 &&
+        args[args.size() - 3 - (force ? 1 : 0)] == "CACHE") {
       cache = true;
-      ignoreLastArgs+=3;
-      }
+      ignoreLastArgs += 3;
     }
+  }
 
   // collect any values into a single semi-colon separated value list
   value = cmJoin(cmMakeRange(args).advance(1).retreat(ignoreLastArgs), ";");
 
-  if (parentScope)
-    {
+  if (parentScope) {
     this->Makefile->RaiseScope(variable, value.c_str());
     return true;
-    }
-
+  }
 
   // we should be nice and try to catch some simple screwups if the last or
   // next to last args are CACHE then they screwed up.  If they used FORCE
   // without CACHE they screwed up
   if ((args[args.size() - 1] == "CACHE") ||
       (args.size() > 1 && args[args.size() - 2] == "CACHE") ||
-      (force && !cache))
-    {
+      (force && !cache)) {
     this->SetError("given invalid arguments for CACHE mode.");
     return false;
-    }
+  }
 
-  if(cache)
-    {
+  if (cache) {
     std::string::size_type cacheStart = args.size() - 3 - (force ? 1 : 0);
-    type = cmState::StringToCacheEntryType(args[cacheStart+1].c_str());
-    docstring = args[cacheStart+2].c_str();
-    }
+    type = cmState::StringToCacheEntryType(args[cacheStart + 1].c_str());
+    docstring = args[cacheStart + 2].c_str();
+  }
 
   // see if this is already in the cache
   cmState* state = this->Makefile->GetState();
   const char* existingValue = state->GetCacheEntryValue(variable);
-  if(existingValue &&
-      (state->GetCacheEntryType(variable) != cmState::UNINITIALIZED))
-    {
+  if (existingValue &&
+      (state->GetCacheEntryType(variable) != cmState::UNINITIALIZED)) {
     // if the set is trying to CACHE the value but the value
     // is already in the cache and the type is not internal
     // then leave now without setting any definitions in the cache
     // or the makefile
-    if(cache && type != cmState::INTERNAL && !force)
-      {
+    if (cache && type != cmState::INTERNAL && !force) {
       return true;
-      }
     }
+  }
 
   // if it is meant to be in the cache then define it in the cache
-  if(cache)
-    {
-    this->Makefile->AddCacheDefinition(variable,
-                                   value.c_str(),
-                                   docstring,
-                                   type, force);
-    }
-  else
-    {
+  if (cache) {
+    this->Makefile->AddCacheDefinition(variable, value.c_str(), docstring,
+                                       type, force);
+  } else {
     // add the definition
     this->Makefile->AddDefinition(variable, value.c_str());
-    }
+  }
   return true;
 }
-
diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h
index 4adc2d9..65af8ac 100644
--- a/Source/cmSetCommand.h
+++ b/Source/cmSetCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmSetCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSetCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "set";}
+  virtual std::string GetName() const { return "set"; }
 
   cmTypeMacro(cmSetCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx
index 3d4b7a9..ca758da 100644
--- a/Source/cmSetDirectoryPropertiesCommand.cxx
+++ b/Source/cmSetDirectoryPropertiesCommand.cxx
@@ -14,57 +14,43 @@
 #include "cmake.h"
 
 // cmSetDirectoryPropertiesCommand
-bool cmSetDirectoryPropertiesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSetDirectoryPropertiesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string errors;
-  bool ret =
-    cmSetDirectoryPropertiesCommand::RunCommand(this->Makefile,
-                                                args.begin() + 1,
-                                                args.end(), errors);
-  if (!ret)
-    {
+  bool ret = cmSetDirectoryPropertiesCommand::RunCommand(
+    this->Makefile, args.begin() + 1, args.end(), errors);
+  if (!ret) {
     this->SetError(errors);
-    }
+  }
   return ret;
 }
 
-bool cmSetDirectoryPropertiesCommand
-::RunCommand(cmMakefile *mf,
-             std::vector<std::string>::const_iterator ait,
-             std::vector<std::string>::const_iterator aitend,
-             std::string &errors)
+bool cmSetDirectoryPropertiesCommand::RunCommand(
+  cmMakefile* mf, std::vector<std::string>::const_iterator ait,
+  std::vector<std::string>::const_iterator aitend, std::string& errors)
 {
-  for (; ait != aitend; ait += 2 )
-    {
-    if ( ait +1 == aitend)
-      {
+  for (; ait != aitend; ait += 2) {
+    if (ait + 1 == aitend) {
       errors = "Wrong number of arguments";
       return false;
-      }
+    }
     const std::string& prop = *ait;
-    const std::string& value = *(ait+1);
-    if ( prop == "VARIABLES" )
-      {
-      errors =
-        "Variables and cache variables should be set using SET command";
+    const std::string& value = *(ait + 1);
+    if (prop == "VARIABLES") {
+      errors = "Variables and cache variables should be set using SET command";
       return false;
-      }
-    else if ( prop == "MACROS" )
-      {
-      errors =
-        "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
+    } else if (prop == "MACROS") {
+      errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
       return false;
-      }
-    mf->SetProperty(prop, value.c_str());
     }
+    mf->SetProperty(prop, value.c_str());
+  }
 
   return true;
 }
-
diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h
index f444a1b..a393eee 100644
--- a/Source/cmSetDirectoryPropertiesCommand.h
+++ b/Source/cmSetDirectoryPropertiesCommand.h
@@ -17,17 +17,14 @@
 class cmSetDirectoryPropertiesCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmSetDirectoryPropertiesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSetDirectoryPropertiesCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -37,19 +34,17 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "set_directory_properties";}
+  virtual std::string GetName() const { return "set_directory_properties"; }
 
   /**
    * Static entry point for use by other commands
    */
-  static bool RunCommand(cmMakefile *mf,
+  static bool RunCommand(cmMakefile* mf,
                          std::vector<std::string>::const_iterator ait,
                          std::vector<std::string>::const_iterator aitend,
-                         std::string &errors);
+                         std::string& errors);
 
   cmTypeMacro(cmSetDirectoryPropertiesCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 17ad475..73f7437 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -10,12 +10,11 @@
   See the License for more information.
 ============================================================================*/
 #include "cmSetPropertyCommand.h"
+
+#include "cmSetSourceFilesPropertiesCommand.h"
 #include "cmSetTargetPropertiesCommand.h"
 #include "cmSetTestsPropertiesCommand.h"
-#include "cmSetSourceFilesPropertiesCommand.h"
 
-
-//----------------------------------------------------------------------------
 cmSetPropertyCommand::cmSetPropertyCommand()
 {
   this->AppendMode = false;
@@ -23,268 +22,221 @@ cmSetPropertyCommand::cmSetPropertyCommand()
   this->Remove = true;
 }
 
-//----------------------------------------------------------------------------
-bool cmSetPropertyCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Get the scope on which to set the property.
   std::vector<std::string>::const_iterator arg = args.begin();
   cmProperty::ScopeType scope;
-  if(*arg == "GLOBAL")
-    {
+  if (*arg == "GLOBAL") {
     scope = cmProperty::GLOBAL;
-    }
-  else if(*arg == "DIRECTORY")
-    {
+  } else if (*arg == "DIRECTORY") {
     scope = cmProperty::DIRECTORY;
-    }
-  else if(*arg == "TARGET")
-    {
+  } else if (*arg == "TARGET") {
     scope = cmProperty::TARGET;
-    }
-  else if(*arg == "SOURCE")
-    {
+  } else if (*arg == "SOURCE") {
     scope = cmProperty::SOURCE_FILE;
-    }
-  else if(*arg == "TEST")
-    {
+  } else if (*arg == "TEST") {
     scope = cmProperty::TEST;
-    }
-  else if(*arg == "CACHE")
-    {
+  } else if (*arg == "CACHE") {
     scope = cmProperty::CACHE;
-    }
-  else if(*arg == "INSTALL")
-    {
+  } else if (*arg == "INSTALL") {
     scope = cmProperty::INSTALL;
-    }
-  else
-    {
+  } else {
     std::ostringstream e;
     e << "given invalid scope " << *arg << ".  "
       << "Valid scopes are GLOBAL, DIRECTORY, "
-        "TARGET, SOURCE, TEST, CACHE, INSTALL.";
+         "TARGET, SOURCE, TEST, CACHE, INSTALL.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   // Parse the rest of the arguments up to the values.
-  enum Doing { DoingNone, DoingNames, DoingProperty, DoingValues };
+  enum Doing
+  {
+    DoingNone,
+    DoingNames,
+    DoingProperty,
+    DoingValues
+  };
   Doing doing = DoingNames;
   const char* sep = "";
-  for(++arg; arg != args.end(); ++arg)
-    {
-    if(*arg == "PROPERTY")
-      {
+  for (++arg; arg != args.end(); ++arg) {
+    if (*arg == "PROPERTY") {
       doing = DoingProperty;
-      }
-    else if(*arg == "APPEND")
-      {
+    } else if (*arg == "APPEND") {
       doing = DoingNone;
       this->AppendMode = true;
       this->Remove = false;
       this->AppendAsString = false;
-      }
-    else if(*arg == "APPEND_STRING")
-      {
+    } else if (*arg == "APPEND_STRING") {
       doing = DoingNone;
       this->AppendMode = true;
       this->Remove = false;
       this->AppendAsString = true;
-      }
-    else if(doing == DoingNames)
-      {
+    } else if (doing == DoingNames) {
       this->Names.insert(*arg);
-      }
-    else if(doing == DoingProperty)
-      {
+    } else if (doing == DoingProperty) {
       this->PropertyName = *arg;
       doing = DoingValues;
-      }
-    else if(doing == DoingValues)
-      {
+    } else if (doing == DoingValues) {
       this->PropertyValue += sep;
       sep = ";";
       this->PropertyValue += *arg;
       this->Remove = false;
-      }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "given invalid argument \"" << *arg << "\".";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
 
   // Make sure a property name was found.
-  if(this->PropertyName.empty())
-    {
+  if (this->PropertyName.empty()) {
     this->SetError("not given a PROPERTY <name> argument.");
     return false;
-    }
+  }
 
   // Dispatch property setting.
-  switch(scope)
-    {
-    case cmProperty::GLOBAL:      return this->HandleGlobalMode();
-    case cmProperty::DIRECTORY:   return this->HandleDirectoryMode();
-    case cmProperty::TARGET:      return this->HandleTargetMode();
-    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();
+  switch (scope) {
+    case cmProperty::GLOBAL:
+      return this->HandleGlobalMode();
+    case cmProperty::DIRECTORY:
+      return this->HandleDirectoryMode();
+    case cmProperty::TARGET:
+      return this->HandleTargetMode();
+    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:
       break; // should never happen
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleGlobalMode()
 {
-  if(!this->Names.empty())
-    {
+  if (!this->Names.empty()) {
     this->SetError("given names for GLOBAL scope.");
     return false;
-    }
+  }
 
   // Set or append the property.
   cmake* cm = this->Makefile->GetCMakeInstance();
   const char* name = this->PropertyName.c_str();
-  const char *value = this->PropertyValue.c_str();
-  if (this->Remove)
-    {
+  const char* value = this->PropertyValue.c_str();
+  if (this->Remove) {
     value = 0;
-    }
-  if(this->AppendMode)
-    {
+  }
+  if (this->AppendMode) {
     cm->AppendProperty(name, value ? value : "", this->AppendAsString);
-    }
-  else
-    {
+  } else {
     cm->SetProperty(name, value);
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleDirectoryMode()
 {
-  if(this->Names.size() > 1)
-    {
+  if (this->Names.size() > 1) {
     this->SetError("allows at most one name for DIRECTORY scope.");
     return false;
-    }
+  }
 
   // Default to the current directory.
   cmMakefile* mf = this->Makefile;
 
   // Lookup the directory if given.
-  if(!this->Names.empty())
-    {
+  if (!this->Names.empty()) {
     // Construct the directory name.  Interpret relative paths with
     // respect to the current directory.
     std::string dir = *this->Names.begin();
-    if(!cmSystemTools::FileIsFullPath(dir.c_str()))
-      {
+    if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
       dir = this->Makefile->GetCurrentSourceDirectory();
       dir += "/";
       dir += *this->Names.begin();
-      }
+    }
 
     // The local generators are associated with collapsed paths.
     dir = cmSystemTools::CollapseFullPath(dir);
 
     mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
-    if (!mf)
-      {
+    if (!mf) {
       // Could not find the directory.
-      this->SetError
-        ("DIRECTORY scope provided but requested directory was not found. "
-         "This could be because the directory argument was invalid or, "
-         "it is valid but has not been processed yet.");
+      this->SetError(
+        "DIRECTORY scope provided but requested directory was not found. "
+        "This could be because the directory argument was invalid or, "
+        "it is valid but has not been processed yet.");
       return false;
-      }
     }
+  }
 
   // Set or append the property.
   const char* name = this->PropertyName.c_str();
-  const char *value = this->PropertyValue.c_str();
-  if (this->Remove)
-    {
+  const char* value = this->PropertyValue.c_str();
+  if (this->Remove) {
     value = 0;
-    }
-  if(this->AppendMode)
-    {
+  }
+  if (this->AppendMode) {
     mf->AppendProperty(name, value ? value : "", this->AppendAsString);
-    }
-  else
-    {
+  } else {
     mf->SetProperty(name, value);
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleTargetMode()
 {
-  for(std::set<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end(); ++ni)
-    {
-    if (this->Makefile->IsAlias(*ni))
-      {
+  for (std::set<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
+    if (this->Makefile->IsAlias(*ni)) {
       this->SetError("can not be used on an ALIAS target.");
       return false;
-      }
-    if(cmTarget* target = this->Makefile->FindTargetToUse(*ni))
-      {
+    }
+    if (cmTarget* target = this->Makefile->FindTargetToUse(*ni)) {
       // Handle the current target.
-      if(!this->HandleTarget(target))
-        {
+      if (!this->HandleTarget(target)) {
         return false;
-        }
       }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "could not find TARGET " << *ni
         << ".  Perhaps it has not yet been created.";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
 {
   // Set or append the property.
   const char* name = this->PropertyName.c_str();
-  const char *value = this->PropertyValue.c_str();
-  if (this->Remove)
-    {
+  const char* value = this->PropertyValue.c_str();
+  if (this->Remove) {
     value = 0;
-    }
-  if(this->AppendMode)
-    {
+  }
+  if (this->AppendMode) {
     target->AppendProperty(name, value, this->AppendAsString);
-    }
-  else
-    {
+  } else {
     target->SetProperty(name, value);
-    }
+  }
 
   // Check the resulting value.
   target->CheckProperty(name, this->Makefile);
@@ -292,231 +244,180 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleSourceMode()
 {
-  for(std::set<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end(); ++ni)
-    {
+  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))
-      {
-      if(!this->HandleSource(sf))
-        {
+    if (cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni)) {
+      if (!this->HandleSource(sf)) {
         return false;
-        }
       }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "given SOURCE name that could not be found or created: " << *ni;
       this->SetError(e.str());
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf)
 {
   // Set or append the property.
   const char* name = this->PropertyName.c_str();
-  const char *value = this->PropertyValue.c_str();
-  if (this->Remove)
-    {
+  const char* value = this->PropertyValue.c_str();
+  if (this->Remove) {
     value = 0;
-    }
+  }
 
-  if(this->AppendMode)
-    {
+  if (this->AppendMode) {
     sf->AppendProperty(name, value, this->AppendAsString);
-    }
-  else
-    {
+  } else {
     sf->SetProperty(name, value);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleTestMode()
 {
   // Look for tests with all names given.
   std::set<std::string>::iterator next;
-  for(std::set<std::string>::iterator ni = this->Names.begin();
-      ni != this->Names.end(); ni = 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))
-      {
-      if(this->HandleTest(test))
-        {
+    if (cmTest* test = this->Makefile->GetTest(*ni)) {
+      if (this->HandleTest(test)) {
         this->Names.erase(ni);
-        }
-      else
-        {
+      } else {
         return false;
-        }
       }
     }
+  }
 
   // Names that are still left were not found.
-  if(!this->Names.empty())
-    {
+  if (!this->Names.empty()) {
     std::ostringstream e;
     e << "given TEST names that do not exist:\n";
-    for(std::set<std::string>::const_iterator ni = this->Names.begin();
-        ni != this->Names.end(); ++ni)
-      {
+    for (std::set<std::string>::const_iterator ni = this->Names.begin();
+         ni != this->Names.end(); ++ni) {
       e << "  " << *ni << "\n";
-      }
+    }
     this->SetError(e.str());
     return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleTest(cmTest* test)
 {
   // Set or append the property.
   const char* name = this->PropertyName.c_str();
-  const char *value = this->PropertyValue.c_str();
-  if (this->Remove)
-    {
+  const char* value = this->PropertyValue.c_str();
+  if (this->Remove) {
     value = 0;
-    }
-  if(this->AppendMode)
-    {
+  }
+  if (this->AppendMode) {
     test->AppendProperty(name, value, this->AppendAsString);
-    }
-  else
-    {
+  } else {
     test->SetProperty(name, value);
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleCacheMode()
 {
-  if(this->PropertyName == "ADVANCED")
-    {
-    if(!this->Remove &&
-       !cmSystemTools::IsOn(this->PropertyValue.c_str()) &&
-       !cmSystemTools::IsOff(this->PropertyValue.c_str()))
-      {
+  if (this->PropertyName == "ADVANCED") {
+    if (!this->Remove && !cmSystemTools::IsOn(this->PropertyValue.c_str()) &&
+        !cmSystemTools::IsOff(this->PropertyValue.c_str())) {
       std::ostringstream e;
       e << "given non-boolean value \"" << this->PropertyValue
         << "\" for CACHE property \"ADVANCED\".  ";
       this->SetError(e.str());
       return false;
-      }
     }
-  else if(this->PropertyName == "TYPE")
-    {
-    if(!cmState::IsCacheEntryType(this->PropertyValue.c_str()))
-      {
+  } else if (this->PropertyName == "TYPE") {
+    if (!cmState::IsCacheEntryType(this->PropertyValue.c_str())) {
       std::ostringstream e;
       e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
       this->SetError(e.str());
       return false;
-      }
     }
-  else if(this->PropertyName != "HELPSTRING" &&
-          this->PropertyName != "STRINGS" &&
-          this->PropertyName != "VALUE")
-    {
+  } else if (this->PropertyName != "HELPSTRING" &&
+             this->PropertyName != "STRINGS" &&
+             this->PropertyName != "VALUE") {
     std::ostringstream e;
     e << "given invalid CACHE property " << this->PropertyName << ".  "
       << "Settable CACHE properties are: "
       << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
     this->SetError(e.str());
     return false;
-    }
+  }
 
-  for(std::set<std::string>::const_iterator ni = this->Names.begin();
-      ni != this->Names.end(); ++ni)
-    {
+  for (std::set<std::string>::const_iterator ni = this->Names.begin();
+       ni != this->Names.end(); ++ni) {
     // Get the source file.
     cmMakefile* mf = this->GetMakefile();
     cmake* cm = mf->GetCMakeInstance();
-    const char* existingValue
-                          = cm->GetState()->GetCacheEntryValue(*ni);
-    if(existingValue)
-      {
-      if(!this->HandleCacheEntry(*ni))
-        {
+    const char* existingValue = cm->GetState()->GetCacheEntryValue(*ni);
+    if (existingValue) {
+      if (!this->HandleCacheEntry(*ni)) {
         return false;
-        }
       }
-    else
-      {
+    } else {
       std::ostringstream e;
       e << "could not find CACHE variable " << *ni
         << ".  Perhaps it has not yet been created.";
       this->SetError(e.str());
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleCacheEntry(std::string const& cacheKey)
 {
   // Set or append the property.
   const char* name = this->PropertyName.c_str();
   const char* value = this->PropertyValue.c_str();
   cmState* state = this->Makefile->GetState();
-  if (this->Remove)
-    {
+  if (this->Remove) {
     state->RemoveCacheEntryProperty(cacheKey, name);
-    }
-  if(this->AppendMode)
-    {
+  }
+  if (this->AppendMode) {
     state->AppendCacheEntryProperty(cacheKey, name, value,
-                                     this->AppendAsString);
-    }
-  else
-    {
+                                    this->AppendAsString);
+  } else {
     state->SetCacheEntryProperty(cacheKey, name, value);
-    }
+  }
 
   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))
-        {
+  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
-      {
+    } else {
       std::ostringstream 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.
@@ -524,18 +425,13 @@ bool cmSetPropertyCommand::HandleInstall(cmInstalledFile* file)
 
   cmMakefile* mf = this->Makefile;
 
-  const char *value = this->PropertyValue.c_str();
-  if (this->Remove)
-    {
+  const char* value = this->PropertyValue.c_str();
+  if (this->Remove) {
     file->RemoveProperty(name);
-    }
-  else if(this->AppendMode)
-    {
+  } else if (this->AppendMode) {
     file->AppendProperty(mf, name, value, this->AppendAsString);
-    }
-  else
-    {
+  } else {
     file->SetProperty(mf, name, value);
-    }
+  }
   return true;
 }
diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h
index 3285e60..a85d652 100644
--- a/Source/cmSetPropertyCommand.h
+++ b/Source/cmSetPropertyCommand.h
@@ -19,22 +19,19 @@ class cmSetPropertyCommand : public cmCommand
 public:
   cmSetPropertyCommand();
 
-  virtual cmCommand* Clone()
-    {
-      return new cmSetPropertyCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSetPropertyCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "set_property";}
+  virtual std::string GetName() const { return "set_property"; }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -66,6 +63,4 @@ private:
   bool HandleInstall(cmInstalledFile* file);
 };
 
-
-
 #endif
diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx
index 19c6819..976f3c8 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.cxx
+++ b/Source/cmSetSourceFilesPropertiesCommand.cxx
@@ -14,157 +14,117 @@
 #include "cmSourceFile.h"
 
 // cmSetSourceFilesPropertiesCommand
-bool cmSetSourceFilesPropertiesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSetSourceFilesPropertiesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // break the arguments into source file names and properties
   int numFiles = 0;
   std::vector<std::string>::const_iterator j;
   j = args.begin();
   // old style allows for specifier before PROPERTIES keyword
-  while (j != args.end() &&
-         *j != "ABSTRACT" &&
-         *j != "WRAP_EXCLUDE" &&
-         *j != "GENERATED" &&
-         *j != "COMPILE_FLAGS" &&
-         *j != "OBJECT_DEPENDS" &&
-         *j != "PROPERTIES")
-    {
+  while (j != args.end() && *j != "ABSTRACT" && *j != "WRAP_EXCLUDE" &&
+         *j != "GENERATED" && *j != "COMPILE_FLAGS" &&
+         *j != "OBJECT_DEPENDS" && *j != "PROPERTIES") {
     numFiles++;
     ++j;
-    }
+  }
 
   // now call the worker function
   std::string errors;
-  bool ret =
-    cmSetSourceFilesPropertiesCommand
-    ::RunCommand(this->Makefile,
-                 args.begin(),
-                 args.begin() + numFiles,
-                 args.begin() + numFiles,
-                 args.end(), errors);
-  if (!ret)
-    {
+  bool ret = cmSetSourceFilesPropertiesCommand::RunCommand(
+    this->Makefile, args.begin(), args.begin() + numFiles,
+    args.begin() + numFiles, args.end(), errors);
+  if (!ret) {
     this->SetError(errors);
-    }
+  }
   return ret;
 }
 
-bool cmSetSourceFilesPropertiesCommand
-::RunCommand(cmMakefile *mf,
-             std::vector<std::string>::const_iterator filebeg,
-             std::vector<std::string>::const_iterator fileend,
-             std::vector<std::string>::const_iterator propbeg,
-             std::vector<std::string>::const_iterator propend,
-             std::string &errors)
+bool cmSetSourceFilesPropertiesCommand::RunCommand(
+  cmMakefile* mf, std::vector<std::string>::const_iterator filebeg,
+  std::vector<std::string>::const_iterator fileend,
+  std::vector<std::string>::const_iterator propbeg,
+  std::vector<std::string>::const_iterator propend, std::string& errors)
 {
   std::vector<std::string> propertyPairs;
   bool generated = false;
   std::vector<std::string>::const_iterator j;
   // build the property pairs
-  for(j= propbeg; j != propend;++j)
-    {
+  for (j = propbeg; j != propend; ++j) {
     // old style allows for specifier before PROPERTIES keyword
-    if(*j == "ABSTRACT")
-      {
+    if (*j == "ABSTRACT") {
       propertyPairs.push_back("ABSTRACT");
       propertyPairs.push_back("1");
-      }
-    else if(*j == "WRAP_EXCLUDE")
-      {
+    } else if (*j == "WRAP_EXCLUDE") {
       propertyPairs.push_back("WRAP_EXCLUDE");
       propertyPairs.push_back("1");
-      }
-    else if(*j == "GENERATED")
-      {
+    } else if (*j == "GENERATED") {
       generated = true;
       propertyPairs.push_back("GENERATED");
       propertyPairs.push_back("1");
-      }
-    else if(*j == "COMPILE_FLAGS")
-      {
+    } else if (*j == "COMPILE_FLAGS") {
       propertyPairs.push_back("COMPILE_FLAGS");
       ++j;
-      if(j == propend)
-        {
+      if (j == propend) {
         errors = "called with incorrect number of arguments "
-          "COMPILE_FLAGS with no flags";
+                 "COMPILE_FLAGS with no flags";
         return false;
-        }
-      propertyPairs.push_back(*j);
       }
-    else if(*j == "OBJECT_DEPENDS")
-      {
+      propertyPairs.push_back(*j);
+    } else if (*j == "OBJECT_DEPENDS") {
       propertyPairs.push_back("OBJECT_DEPENDS");
       ++j;
-      if(j == propend)
-        {
+      if (j == propend) {
         errors = "called with incorrect number of arguments "
-          "OBJECT_DEPENDS with no dependencies";
+                 "OBJECT_DEPENDS with no dependencies";
         return false;
-        }
-      propertyPairs.push_back(*j);
       }
-    else if(*j == "PROPERTIES")
-      {
+      propertyPairs.push_back(*j);
+    } else if (*j == "PROPERTIES") {
       // now loop through the rest of the arguments, new style
       ++j;
-      while (j != propend)
-        {
+      while (j != propend) {
         propertyPairs.push_back(*j);
-        if(*j == "GENERATED")
-          {
+        if (*j == "GENERATED") {
           ++j;
-          if(j != propend && cmSystemTools::IsOn(j->c_str()))
-            {
+          if (j != propend && cmSystemTools::IsOn(j->c_str())) {
             generated = true;
-            }
           }
-        else
-          {
+        } else {
           ++j;
-          }
-        if(j == propend)
-          {
+        }
+        if (j == propend) {
           errors = "called with incorrect number of arguments.";
           return false;
-          }
+        }
         propertyPairs.push_back(*j);
         ++j;
-        }
+      }
       // break out of the loop because j is already == end
       break;
-      }
-    else
-      {
+    } else {
       errors = "called with illegal arguments, maybe missing a "
-        "PROPERTIES specifier?";
+               "PROPERTIES specifier?";
       return false;
-      }
     }
+  }
 
   // now loop over all the files
-  for(j= filebeg; j != fileend;++j)
-    {
+  for (j = filebeg; j != fileend; ++j) {
     // get the source file
-    cmSourceFile* sf =
-      mf->GetOrCreateSource(*j, generated);
-    if(sf)
-      {
+    cmSourceFile* sf = 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],propertyPairs[k+1].c_str());
-        }
+      for (k = 0; k < propertyPairs.size(); k = k + 2) {
+        sf->SetProperty(propertyPairs[k], propertyPairs[k + 1].c_str());
       }
     }
+  }
   return true;
 }
-
diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h
index 5fa5a3a..20e6b93 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.h
+++ b/Source/cmSetSourceFilesPropertiesCommand.h
@@ -17,33 +17,28 @@
 class cmSetSourceFilesPropertiesCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmSetSourceFilesPropertiesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSetSourceFilesPropertiesCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "set_source_files_properties";}
+  virtual std::string GetName() const { return "set_source_files_properties"; }
 
   cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand);
 
-  static bool RunCommand(cmMakefile *mf,
+  static bool RunCommand(cmMakefile* mf,
                          std::vector<std::string>::const_iterator filebeg,
                          std::vector<std::string>::const_iterator fileend,
                          std::vector<std::string>::const_iterator propbeg,
                          std::vector<std::string>::const_iterator propend,
-                         std::string &errors);
+                         std::string& errors);
 };
 
-
-
 #endif
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index b1c13ac..86c8016 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -10,90 +10,76 @@
   See the License for more information.
 ============================================================================*/
 #include "cmSetTargetPropertiesCommand.h"
+
 #include "cmGlobalGenerator.h"
 
 // cmSetTargetPropertiesCommand
-bool cmSetTargetPropertiesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSetTargetPropertiesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // first collect up the list of files
   std::vector<std::string> propertyPairs;
   int numFiles = 0;
   std::vector<std::string>::const_iterator j;
-  for(j= args.begin(); j != args.end();++j)
-    {
-    if(*j == "PROPERTIES")
-      {
+  for (j = args.begin(); j != args.end(); ++j) {
+    if (*j == "PROPERTIES") {
       // now loop through the rest of the arguments, new style
       ++j;
-      if (std::distance(j, args.end()) % 2 != 0)
-        {
+      if (std::distance(j, args.end()) % 2 != 0) {
         this->SetError("called with incorrect number of arguments.");
         return false;
-        }
+      }
       propertyPairs.insert(propertyPairs.end(), j, args.end());
       break;
-      }
-    else
-      {
+    } else {
       numFiles++;
-      }
-    }
-  if(propertyPairs.empty())
-    {
-     this->SetError("called with illegal arguments, maybe missing "
-                    "a PROPERTIES specifier?");
-     return false;
     }
+  }
+  if (propertyPairs.empty()) {
+    this->SetError("called with illegal arguments, maybe missing "
+                   "a PROPERTIES specifier?");
+    return false;
+  }
 
   // now loop over all the targets
   int i;
-  for(i = 0; i < numFiles; ++i)
-    {
-    if (this->Makefile->IsAlias(args[i]))
-      {
+  for (i = 0; i < numFiles; ++i) {
+    if (this->Makefile->IsAlias(args[i])) {
       this->SetError("can not be used on an ALIAS target.");
       return false;
-      }
-    bool ret = cmSetTargetPropertiesCommand::SetOneTarget
-      (args[i],propertyPairs,this->Makefile);
-    if (!ret)
-      {
+    }
+    bool ret = cmSetTargetPropertiesCommand::SetOneTarget(
+      args[i], propertyPairs, this->Makefile);
+    if (!ret) {
       std::string message = "Can not find target to add properties to: ";
       message += args[i];
       this->SetError(message);
       return false;
-      }
     }
+  }
   return true;
 }
 
-bool cmSetTargetPropertiesCommand
-::SetOneTarget(const std::string& tname,
-               std::vector<std::string> &propertyPairs,
-               cmMakefile *mf)
+bool cmSetTargetPropertiesCommand::SetOneTarget(
+  const std::string& tname, std::vector<std::string>& propertyPairs,
+  cmMakefile* mf)
 {
-  if(cmTarget* target = mf->FindTargetToUse(tname))
-    {
+  if (cmTarget* target = mf->FindTargetToUse(tname)) {
     // now loop through all the props and set them
     unsigned int k;
-    for (k = 0; k < propertyPairs.size(); k = k + 2)
-      {
-      target->SetProperty(propertyPairs[k],
-                          propertyPairs[k+1].c_str());
+    for (k = 0; k < propertyPairs.size(); k = k + 2) {
+      target->SetProperty(propertyPairs[k], propertyPairs[k + 1].c_str());
       target->CheckProperty(propertyPairs[k], mf);
-      }
     }
+  }
   // if file is not already in the makefile, then add it
-  else
-    {
+  else {
     return false;
-    }
+  }
   return true;
 }
diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h
index 3981ef3..122c15e 100644
--- a/Source/cmSetTargetPropertiesCommand.h
+++ b/Source/cmSetTargetPropertiesCommand.h
@@ -17,33 +17,28 @@
 class cmSetTargetPropertiesCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-      return new cmSetTargetPropertiesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSetTargetPropertiesCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string 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 std::string& tname,
-                           std::vector<std::string> &propertyPairs,
-                           cmMakefile *mf);
+                           std::vector<std::string>& propertyPairs,
+                           cmMakefile* mf);
 
   cmTypeMacro(cmSetTargetPropertiesCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index 53dc5a8..2fb137f 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -11,93 +11,74 @@
 ============================================================================*/
 #include "cmSetTestsPropertiesCommand.h"
 
-#include "cmake.h"
 #include "cmTest.h"
+#include "cmake.h"
 
 // cmSetTestsPropertiesCommand
-bool cmSetTestsPropertiesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSetTestsPropertiesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // first collect up the list of files
   std::vector<std::string> propertyPairs;
   int numFiles = 0;
   std::vector<std::string>::const_iterator j;
-  for(j= args.begin(); j != args.end();++j)
-    {
-    if(*j == "PROPERTIES")
-      {
+  for (j = args.begin(); j != args.end(); ++j) {
+    if (*j == "PROPERTIES") {
       // now loop through the rest of the arguments, new style
       ++j;
-      if (std::distance(j, args.end()) % 2 != 0)
-        {
+      if (std::distance(j, args.end()) % 2 != 0) {
         this->SetError("called with incorrect number of arguments.");
         return false;
-        }
+      }
       propertyPairs.insert(propertyPairs.end(), j, args.end());
       break;
-      }
-    else
-      {
+    } else {
       numFiles++;
-      }
     }
-  if(propertyPairs.empty())
-    {
+  }
+  if (propertyPairs.empty()) {
     this->SetError("called with illegal arguments, maybe "
                    "missing a PROPERTIES specifier?");
     return false;
-    }
+  }
 
   // now loop over all the targets
   int i;
-  for(i = 0; i < numFiles; ++i)
-    {
+  for (i = 0; i < numFiles; ++i) {
     std::string errors;
-    bool ret =
-      cmSetTestsPropertiesCommand::SetOneTest(args[i],
-                                              propertyPairs,
-                                              this->Makefile, errors);
-    if (!ret)
-      {
+    bool ret = cmSetTestsPropertiesCommand::SetOneTest(args[i], propertyPairs,
+                                                       this->Makefile, errors);
+    if (!ret) {
       this->SetError(errors);
       return ret;
-      }
     }
+  }
 
   return true;
 }
 
-
-bool cmSetTestsPropertiesCommand
-::SetOneTest(const std::string& tname,
-             std::vector<std::string> &propertyPairs,
-             cmMakefile *mf, std::string &errors)
+bool cmSetTestsPropertiesCommand::SetOneTest(
+  const std::string& tname, std::vector<std::string>& propertyPairs,
+  cmMakefile* mf, std::string& errors)
 {
-  if(cmTest* test = mf->GetTest(tname))
-    {
+  if (cmTest* test = mf->GetTest(tname)) {
     // now loop through all the props and set them
     unsigned int k;
-    for (k = 0; k < propertyPairs.size(); k = k + 2)
-      {
-      if (!propertyPairs[k].empty())
-        {
-        test->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str());
-        }
+    for (k = 0; k < propertyPairs.size(); k = k + 2) {
+      if (!propertyPairs[k].empty()) {
+        test->SetProperty(propertyPairs[k], propertyPairs[k + 1].c_str());
       }
     }
-  else
-    {
+  } else {
     errors = "Can not find test to add properties to: ";
     errors += tname;
     return false;
-    }
+  }
 
   return true;
 }
-
diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h
index dabe944..e469b2a 100644
--- a/Source/cmSetTestsPropertiesCommand.h
+++ b/Source/cmSetTestsPropertiesCommand.h
@@ -17,31 +17,25 @@
 class cmSetTestsPropertiesCommand : public cmCommand
 {
 public:
-  virtual cmCommand* Clone()
-    {
-    return new cmSetTestsPropertiesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSetTestsPropertiesCommand; }
 
   /**
    * This is called when the command is first encountered in
    * the input file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "set_tests_properties";}
+  virtual std::string GetName() const { return "set_tests_properties"; }
 
   cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
 
   static bool SetOneTest(const std::string& tname,
-                         std::vector<std::string> &propertyPairs,
-                         cmMakefile *mf,
-                         std::string &errors);
+                         std::vector<std::string>& propertyPairs,
+                         cmMakefile* mf, std::string& errors);
 };
 
-
-
 #endif
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index e2970e5..702af4d 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -14,14 +14,13 @@
 #include <cmsys/RegularExpression.hxx>
 
 // cmSiteNameCommand
-bool cmSiteNameCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
+                                    cmExecutionStatus&)
 {
-  if(args.size() != 1 )
-    {
+  if (args.size() != 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::vector<std::string> paths;
   paths.push_back("/usr/bsd");
   paths.push_back("/usr/sbin");
@@ -30,66 +29,54 @@ bool cmSiteNameCommand
   paths.push_back("/sbin");
   paths.push_back("/usr/local/bin");
 
-  const char* cacheValue
-    = this->Makefile->GetDefinition(args[0]);
-  if(cacheValue)
-    {
+  const char* cacheValue = this->Makefile->GetDefinition(args[0]);
+  if (cacheValue) {
     return true;
-    }
+  }
 
-  const char *temp = this->Makefile->GetDefinition("HOSTNAME");
+  const char* temp = this->Makefile->GetDefinition("HOSTNAME");
   std::string hostname_cmd;
-  if(temp)
-    {
+  if (temp) {
     hostname_cmd = temp;
-    }
-  else
-    {
+  } else {
     hostname_cmd = cmSystemTools::FindProgram("hostname", paths);
-    }
+  }
 
   std::string siteName = "unknown";
 #if defined(_WIN32) && !defined(__CYGWIN__)
   std::string host;
-  if(cmSystemTools::ReadRegistryValue
-     ("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\"
-      "Control\\ComputerName\\ComputerName;ComputerName", host))
-    {
+  if (cmSystemTools::ReadRegistryValue(
+        "HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\"
+        "Control\\ComputerName\\ComputerName;ComputerName",
+        host)) {
     siteName = host;
-    }
+  }
 #else
   // try to find the hostname for this computer
-  if (!cmSystemTools::IsOff(hostname_cmd.c_str()))
-    {
+  if (!cmSystemTools::IsOff(hostname_cmd.c_str())) {
     std::string host;
-    cmSystemTools::RunSingleCommand(hostname_cmd.c_str(),
-      &host, 0, 0, 0, cmSystemTools::OUTPUT_NONE);
+    cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, 0, 0, 0,
+                                    cmSystemTools::OUTPUT_NONE);
 
     // got the hostname
-    if (!host.empty())
-      {
+    if (!host.empty()) {
       // remove any white space from the host name
       std::string hostRegExp = "[ \t\n\r]*([^\t\n\r ]*)[ \t\n\r]*";
-      cmsys::RegularExpression hostReg (hostRegExp.c_str());
-      if (hostReg.find(host.c_str()))
-        {
+      cmsys::RegularExpression hostReg(hostRegExp.c_str());
+      if (hostReg.find(host.c_str())) {
         // strip whitespace
         host = hostReg.match(1);
-        }
+      }
 
-      if(!host.empty())
-        {
+      if (!host.empty()) {
         siteName = host;
-        }
       }
     }
+  }
 #endif
-  this->Makefile->
-    AddCacheDefinition(args[0],
-                       siteName.c_str(),
-                       "Name of the computer/site where compile is being run",
-                       cmState::STRING);
+  this->Makefile->AddCacheDefinition(
+    args[0], siteName.c_str(),
+    "Name of the computer/site where compile is being run", cmState::STRING);
 
   return true;
 }
-
diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h
index ec63ef8..a4812f7 100644
--- a/Source/cmSiteNameCommand.h
+++ b/Source/cmSiteNameCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmSiteNameCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSiteNameCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "site_name";}
+  virtual std::string GetName() const { return "site_name"; }
 
   cmTypeMacro(cmSiteNameCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index a9ac549..5b0acee 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -16,23 +16,20 @@
 #include "cmSystemTools.h"
 #include "cmake.h"
 
-//----------------------------------------------------------------------------
-cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name):
-  Location(mf, name)
+cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name)
+  : Location(mf, name)
 {
   this->CustomCommand = 0;
   this->FindFullPathFailed = false;
-  this->IsUiFile = (".ui" ==
-          cmSystemTools::GetFilenameLastExtension(this->Location.GetName()));
+  this->IsUiFile = (".ui" == cmSystemTools::GetFilenameLastExtension(
+                               this->Location.GetName()));
 }
 
-//----------------------------------------------------------------------------
 cmSourceFile::~cmSourceFile()
 {
   this->SetCustomCommand(0);
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSourceFile::GetExtension() const
 {
   return this->Extension;
@@ -40,112 +37,93 @@ std::string const& cmSourceFile::GetExtension() const
 
 const std::string cmSourceFile::propLANGUAGE = "LANGUAGE";
 
-//----------------------------------------------------------------------------
 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(propLANGUAGE))
-    {
+  if (const char* lang = this->GetProperty(propLANGUAGE)) {
     return lang;
-    }
+  }
 
   // Perform computation needed to get the language if necessary.
-  if(this->FullPath.empty() && this->Language.empty())
-    {
+  if (this->FullPath.empty() && this->Language.empty()) {
     // If a known extension is given or a known full path is given
     // then trust that the current extension is sufficient to
     // determine the language.  This will fail only if the user
     // specifies a full path to the source but leaves off the
     // extension, which is kind of weird.
-    if(this->Location.ExtensionIsAmbiguous() &&
-       this->Location.DirectoryIsAmbiguous())
-      {
+    if (this->Location.ExtensionIsAmbiguous() &&
+        this->Location.DirectoryIsAmbiguous()) {
       // Finalize the file location to get the extension and set the
       // language.
       this->GetFullPath();
-      }
-    else
-      {
+    } else {
       // Use the known extension to get the language if possible.
       std::string ext =
         cmSystemTools::GetFilenameLastExtension(this->Location.GetName());
       this->CheckLanguage(ext);
-      }
     }
+  }
 
   // Now try to determine the language.
   return static_cast<cmSourceFile const*>(this)->GetLanguage();
 }
 
-//----------------------------------------------------------------------------
 std::string cmSourceFile::GetLanguage() const
 {
   // If the language was set explicitly by the user then use it.
-  if(const char* lang = this->GetProperty(propLANGUAGE))
-    {
+  if (const char* lang = this->GetProperty(propLANGUAGE)) {
     return lang;
-    }
+  }
 
   // If the language was determined from the source file extension use it.
-  if(!this->Language.empty())
-    {
+  if (!this->Language.empty()) {
     return this->Language;
-    }
+  }
 
   // The language is not known.
   return "";
 }
 
-//----------------------------------------------------------------------------
 cmSourceFileLocation const& cmSourceFile::GetLocation() const
 {
-    return this->Location;
+  return this->Location;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSourceFile::GetFullPath(std::string* error)
 {
-  if(this->FullPath.empty())
-    {
-    if(this->FindFullPath(error))
-      {
+  if (this->FullPath.empty()) {
+    if (this->FindFullPath(error)) {
       this->CheckExtension();
-      }
     }
+  }
   return this->FullPath;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSourceFile::GetFullPath() const
 {
   return this->FullPath;
 }
 
-//----------------------------------------------------------------------------
 bool cmSourceFile::FindFullPath(std::string* error)
 {
   // If thie method has already failed once do not try again.
-  if(this->FindFullPathFailed)
-    {
+  if (this->FindFullPathFailed) {
     return false;
-    }
+  }
 
   // If the file is generated compute the location without checking on
   // disk.
-  if(this->GetPropertyAsBool("GENERATED"))
-    {
+  if (this->GetPropertyAsBool("GENERATED")) {
     // The file is either already a full path or is relative to the
     // build directory for the target.
     this->Location.DirectoryUseBinary();
@@ -153,172 +131,139 @@ bool cmSourceFile::FindFullPath(std::string* error)
     this->FullPath += "/";
     this->FullPath += this->Location.GetName();
     return true;
-    }
+  }
 
   // The file is not generated.  It must exist on disk.
   cmMakefile const* mf = this->Location.GetMakefile();
-  const char* tryDirs[3] = {0, 0, 0};
-  if(this->Location.DirectoryIsAmbiguous())
-    {
+  const char* tryDirs[3] = { 0, 0, 0 };
+  if (this->Location.DirectoryIsAmbiguous()) {
     tryDirs[0] = mf->GetCurrentSourceDirectory();
     tryDirs[1] = mf->GetCurrentBinaryDirectory();
-    }
-  else
-    {
+  } else {
     tryDirs[0] = "";
-    }
+  }
   const std::vector<std::string>& srcExts =
-      mf->GetCMakeInstance()->GetSourceExtensions();
+    mf->GetCMakeInstance()->GetSourceExtensions();
   std::vector<std::string> hdrExts =
-      mf->GetCMakeInstance()->GetHeaderExtensions();
-  for(const char* const* di = tryDirs; *di; ++di)
-    {
+    mf->GetCMakeInstance()->GetHeaderExtensions();
+  for (const char* const* di = tryDirs; *di; ++di) {
     std::string tryPath = this->Location.GetDirectory();
-    if(!tryPath.empty())
-      {
+    if (!tryPath.empty()) {
       tryPath += "/";
-      }
+    }
     tryPath += this->Location.GetName();
     tryPath = cmSystemTools::CollapseFullPath(tryPath, *di);
-    if(this->TryFullPath(tryPath, ""))
-      {
+    if (this->TryFullPath(tryPath, "")) {
       return true;
-      }
-    for(std::vector<std::string>::const_iterator ei = srcExts.begin();
-        ei != srcExts.end(); ++ei)
-      {
-      if(this->TryFullPath(tryPath, *ei))
-        {
+    }
+    for (std::vector<std::string>::const_iterator ei = srcExts.begin();
+         ei != srcExts.end(); ++ei) {
+      if (this->TryFullPath(tryPath, *ei)) {
         return true;
-        }
       }
-    for(std::vector<std::string>::const_iterator ei = hdrExts.begin();
-        ei != hdrExts.end(); ++ei)
-      {
-      if(this->TryFullPath(tryPath, *ei))
-        {
+    }
+    for (std::vector<std::string>::const_iterator ei = hdrExts.begin();
+         ei != hdrExts.end(); ++ei) {
+      if (this->TryFullPath(tryPath, *ei)) {
         return true;
-        }
       }
     }
+  }
 
   std::ostringstream e;
   std::string missing = this->Location.GetDirectory();
-  if(!missing.empty())
-    {
+  if (!missing.empty()) {
     missing += "/";
-    }
+  }
   missing += this->Location.GetName();
   e << "Cannot find source file:\n  " << missing << "\nTried extensions";
-  for(std::vector<std::string>::const_iterator ext = srcExts.begin();
-      ext != srcExts.end(); ++ext)
-    {
+  for (std::vector<std::string>::const_iterator ext = srcExts.begin();
+       ext != srcExts.end(); ++ext) {
     e << " ." << *ext;
-    }
-  for(std::vector<std::string>::const_iterator ext = hdrExts.begin();
-      ext != hdrExts.end(); ++ext)
-    {
+  }
+  for (std::vector<std::string>::const_iterator ext = hdrExts.begin();
+       ext != hdrExts.end(); ++ext) {
     e << " ." << *ext;
-    }
-  if(error)
-    {
+  }
+  if (error) {
     *error = e.str();
-    }
-  else
-    {
+  } else {
     this->Location.GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
+  }
   this->FindFullPathFailed = true;
   return false;
 }
 
-//----------------------------------------------------------------------------
-bool cmSourceFile::TryFullPath(const std::string& path,
-                               const std::string& ext)
+bool cmSourceFile::TryFullPath(const std::string& path, const std::string& ext)
 {
   std::string tryPath = path;
-  if(!ext.empty())
-    {
+  if (!ext.empty()) {
     tryPath += ".";
     tryPath += ext;
-    }
-  if(cmSystemTools::FileExists(tryPath.c_str()))
-    {
+  }
+  if (cmSystemTools::FileExists(tryPath.c_str())) {
     this->FullPath = tryPath;
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFile::CheckExtension()
 {
   // Compute the extension.
   std::string realExt =
     cmSystemTools::GetFilenameLastExtension(this->FullPath);
-  if(!realExt.empty())
-    {
+  if (!realExt.empty()) {
     // Store the extension without the leading '.'.
     this->Extension = realExt.substr(1);
-    }
+  }
 
   // Look for object files.
-  if(this->Extension == "obj" ||
-     this->Extension == "o" ||
-     this->Extension == "lo")
-    {
+  if (this->Extension == "obj" || this->Extension == "o" ||
+      this->Extension == "lo") {
     this->SetProperty("EXTERNAL_OBJECT", "1");
-    }
+  }
 
   // Try to identify the source file language from the extension.
-  if(this->Language.empty())
-    {
+  if (this->Language.empty()) {
     this->CheckLanguage(this->Extension);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFile::CheckLanguage(std::string const& ext)
 {
   // Try to identify the source file language from the extension.
   cmMakefile const* mf = this->Location.GetMakefile();
   cmGlobalGenerator* gg = mf->GetGlobalGenerator();
   std::string l = gg->GetLanguageFromExtension(ext.c_str());
-  if(!l.empty())
-    {
+  if (!l.empty()) {
     this->Language = l;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
 {
   return this->Location.Matches(loc);
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFile::SetProperty(const std::string& prop, const char* value)
 {
   this->Properties.SetProperty(prop, value);
 
-  if (this->IsUiFile)
-    {
+  if (this->IsUiFile) {
     cmMakefile const* mf = this->Location.GetMakefile();
-    if (prop == "AUTOUIC_OPTIONS")
-      {
+    if (prop == "AUTOUIC_OPTIONS") {
       const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
                                   bool asString)
 {
   this->Properties.AppendProperty(prop, value, asString);
 }
 
-//----------------------------------------------------------------------------
 const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
 {
   // This method is a consequence of design history and backwards
@@ -335,66 +280,54 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
   // 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(prop == "LOCATION")
-    {
+  if (prop == "LOCATION") {
     // Commit to a location.
     this->GetFullPath();
-    }
+  }
 
   // Perform the normal property lookup.
   return this->GetProperty(prop);
 }
 
-//----------------------------------------------------------------------------
 const char* cmSourceFile::GetProperty(const std::string& prop) const
 {
   // Check for computed properties.
-  if(prop == "LOCATION")
-    {
-    if(this->FullPath.empty())
-      {
+  if (prop == "LOCATION") {
+    if (this->FullPath.empty()) {
       return 0;
-      }
-    else
-      {
+    } else {
       return this->FullPath.c_str();
-      }
     }
+  }
 
-  const char *retVal = this->Properties.GetPropertyValue(prop);
-  if (!retVal)
-    {
+  const char* retVal = this->Properties.GetPropertyValue(prop);
+  if (!retVal) {
     cmMakefile const* mf = this->Location.GetMakefile();
-    const bool chain = mf->GetState()->
-                      IsPropertyChained(prop, cmProperty::SOURCE_FILE);
-    if (chain)
-      {
+    const bool chain =
+      mf->GetState()->IsPropertyChained(prop, cmProperty::SOURCE_FILE);
+    if (chain) {
       return mf->GetProperty(prop, chain);
-      }
     }
+  }
 
   return retVal;
 }
 
-//----------------------------------------------------------------------------
 bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
-//----------------------------------------------------------------------------
 cmCustomCommand* cmSourceFile::GetCustomCommand()
 {
   return this->CustomCommand;
 }
 
-//----------------------------------------------------------------------------
 cmCustomCommand const* cmSourceFile::GetCustomCommand() const
 {
   return this->CustomCommand;
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
 {
   cmCustomCommand* old = this->CustomCommand;
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 1433b54..b1623bd 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -13,6 +13,7 @@
 #define cmSourceFile_h
 
 #include "cmSourceFileLocation.h"
+
 #include "cmCustomCommand.h"
 #include "cmPropertyMap.h"
 
@@ -40,13 +41,13 @@ public:
    */
   cmCustomCommand* GetCustomCommand();
   cmCustomCommand const* GetCustomCommand() const;
-  void SetCustomCommand(cmCustomCommand *cc);
+  void SetCustomCommand(cmCustomCommand* cc);
 
   ///! Set/Get a property of this source file
-  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;
+  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
@@ -85,11 +86,11 @@ public:
   /**
    * Return the vector that holds the list of dependencies
    */
-  const std::vector<std::string> &GetDepends() const {return this->Depends;}
+  const std::vector<std::string>& GetDepends() const { return this->Depends; }
   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
@@ -117,7 +118,6 @@ private:
   void CheckExtension();
   void CheckLanguage(std::string const& ext);
 
-
   static const std::string propLANGUAGE;
 };
 
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 00d5d6a..3219f36 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -11,21 +11,20 @@
 ============================================================================*/
 #include "cmSourceFileLocation.h"
 
-#include "cmMakefile.h"
+#include "cmAlgorithms.h"
 #include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
 #include "cmSystemTools.h"
-#include "cmAlgorithms.h"
 
 #include "assert.h"
 
-//----------------------------------------------------------------------------
 cmSourceFileLocation::cmSourceFileLocation()
-  : Makefile(0), AmbiguousDirectory(true), AmbiguousExtension(true)
+  : Makefile(0)
+  , AmbiguousDirectory(true)
+  , AmbiguousExtension(true)
 {
-
 }
 
-//----------------------------------------------------------------------------
 cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
   : Makefile(loc.Makefile)
 {
@@ -35,14 +34,12 @@ cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
   this->Name = loc.Name;
 }
 
-//----------------------------------------------------------------------------
-cmSourceFileLocation&
-cmSourceFileLocation::operator=(const cmSourceFileLocation& loc)
+cmSourceFileLocation& cmSourceFileLocation::operator=(
+  const cmSourceFileLocation& loc)
 {
-  if(this == &loc)
-    {
+  if (this == &loc) {
     return *this;
-    }
+  }
   this->Makefile = loc.Makefile;
   this->AmbiguousDirectory = loc.AmbiguousDirectory;
   this->AmbiguousExtension = loc.AmbiguousExtension;
@@ -52,221 +49,180 @@ cmSourceFileLocation::operator=(const cmSourceFileLocation& loc)
   return *this;
 }
 
-//----------------------------------------------------------------------------
-cmSourceFileLocation
-::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
+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->Directory
-                  = cmSystemTools::CollapseFullPath(this->Directory);
-    }
+  if (cmSystemTools::FileIsFullPath(this->Directory.c_str())) {
+    this->Directory = cmSystemTools::CollapseFullPath(this->Directory);
+  }
   this->Name = cmSystemTools::GetFilenameName(name);
   this->UpdateExtension(name);
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
 {
-  if(this->AmbiguousDirectory && !loc.AmbiguousDirectory)
-    {
+  if (this->AmbiguousDirectory && !loc.AmbiguousDirectory) {
     this->Directory = loc.Directory;
     this->AmbiguousDirectory = false;
-    }
-  if(this->AmbiguousExtension && !loc.AmbiguousExtension)
-    {
+  }
+  if (this->AmbiguousExtension && !loc.AmbiguousExtension) {
     this->Name = loc.Name;
     this->AmbiguousExtension = false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFileLocation::DirectoryUseSource()
 {
   assert(this->Makefile);
-  if(this->AmbiguousDirectory)
-    {
-    this->Directory =
-      cmSystemTools::CollapseFullPath(
-        this->Directory, this->Makefile->GetCurrentSourceDirectory());
+  if (this->AmbiguousDirectory) {
+    this->Directory = cmSystemTools::CollapseFullPath(
+      this->Directory, this->Makefile->GetCurrentSourceDirectory());
     this->AmbiguousDirectory = false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSourceFileLocation::DirectoryUseBinary()
 {
   assert(this->Makefile);
-  if(this->AmbiguousDirectory)
-    {
-    this->Directory =
-      cmSystemTools::CollapseFullPath(
-        this->Directory, this->Makefile->GetCurrentBinaryDirectory());
+  if (this->AmbiguousDirectory) {
+    this->Directory = cmSystemTools::CollapseFullPath(
+      this->Directory, this->Makefile->GetCurrentBinaryDirectory());
     this->AmbiguousDirectory = false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 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); }
+  if (!ext.empty()) {
+    ext = ext.substr(1);
+  }
 
   // The global generator checks extensions of enabled languages.
   cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
   cmMakefile const* mf = this->Makefile;
   const std::vector<std::string>& srcExts =
-      mf->GetCMakeInstance()->GetSourceExtensions();
+    mf->GetCMakeInstance()->GetSourceExtensions();
   const std::vector<std::string>& hdrExts =
-      mf->GetCMakeInstance()->GetHeaderExtensions();
-  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())
-    {
+    mf->GetCMakeInstance()->GetHeaderExtensions();
+  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()) {
     // This is a known extension.  Use the given filename with extension.
     this->Name = cmSystemTools::GetFilenameName(name);
     this->AmbiguousExtension = false;
-    }
-  else
-    {
+  } else {
     // This is not a known extension.  See if the file exists on disk as
     // named.
     std::string tryPath;
-    if(this->AmbiguousDirectory)
-      {
+    if (this->AmbiguousDirectory) {
       // Check the source tree only because a file in the build tree should
       // be specified by full path at least once.  We do not want this
       // detection to depend on whether the project has already been built.
       tryPath = this->Makefile->GetCurrentSourceDirectory();
       tryPath += "/";
-      }
-    if(!this->Directory.empty())
-      {
+    }
+    if (!this->Directory.empty()) {
       tryPath += this->Directory;
       tryPath += "/";
-      }
+    }
     tryPath += this->Name;
-    if(cmSystemTools::FileExists(tryPath.c_str(), true))
-      {
+    if (cmSystemTools::FileExists(tryPath.c_str(), true)) {
       // We found a source file named by the user on disk.  Trust it's
       // extension.
       this->Name = cmSystemTools::GetFilenameName(name);
       this->AmbiguousExtension = false;
 
       // If the directory was ambiguous, it isn't anymore.
-      if(this->AmbiguousDirectory)
-        {
+      if (this->AmbiguousDirectory) {
         this->DirectoryUseSource();
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool
-cmSourceFileLocation
-::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const
+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)
-    {
+  if (this->Name == loc.Name) {
     return true;
-    }
+  }
 
   // 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[loc.Name.size()] == '.' &&
-       cmHasLiteralPrefixImpl(this->Name.c_str(),
-                              loc.Name.c_str(), loc.Name.size())))
-    {
+  if (!(this->Name.size() > 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 const& 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->GetCMakeInstance()->GetSourceExtensions();
-  if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
-    {
+    mf->GetCMakeInstance()->GetSourceExtensions();
+  if (std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) {
     return true;
-    }
+  }
   std::vector<std::string> hdrExts =
-      mf->GetCMakeInstance()->GetHeaderExtensions();
-  if(std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
-    {
+    mf->GetCMakeInstance()->GetHeaderExtensions();
+  if (std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) {
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
 {
   assert(this->Makefile);
-  if(this->AmbiguousExtension == loc.AmbiguousExtension)
-    {
+  if (this->AmbiguousExtension == loc.AmbiguousExtension) {
     // 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() ||
-      !cmSystemTools::ComparePath(this->Name, loc.Name))
-      {
+    if (this->Name.size() != loc.Name.size() ||
+        !cmSystemTools::ComparePath(this->Name, loc.Name)) {
       return false;
-      }
     }
-  else
-    {
+  } else {
     const cmSourceFileLocation* loc1;
     const cmSourceFileLocation* loc2;
-    if(this->AmbiguousExtension)
-      {
+    if (this->AmbiguousExtension) {
       // Only "this" extension is ambiguous.
       loc1 = &loc;
       loc2 = this;
-      }
-    else
-      {
+    } else {
       // Only "loc" extension is ambiguous.
       loc1 = this;
       loc2 = &loc;
-      }
-    if(!loc1->MatchesAmbiguousExtension(*loc2))
-      {
+    }
+    if (!loc1->MatchesAmbiguousExtension(*loc2)) {
       return false;
-      }
     }
+  }
 
-  if(!this->AmbiguousDirectory && !loc.AmbiguousDirectory)
-    {
+  if (!this->AmbiguousDirectory && !loc.AmbiguousDirectory) {
     // Both sides have absolute directories.
-    if(this->Directory != loc.Directory)
-      {
+    if (this->Directory != loc.Directory) {
       return false;
-      }
     }
-  else if(this->AmbiguousDirectory && loc.AmbiguousDirectory)
-    {
-    if (this->Makefile == loc.Makefile)
-      {
+  } else if (this->AmbiguousDirectory && loc.AmbiguousDirectory) {
+    if (this->Makefile == loc.Makefile) {
       // Both sides have directories relative to the same location.
-      if(this->Directory != loc.Directory)
-        {
+      if (this->Directory != loc.Directory) {
         return false;
-        }
       }
-    else
-      {
+    } 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.
@@ -274,41 +230,28 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
         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."
-        );
+        "different directory.  This is not yet allowed.");
       return false;
-      }
     }
-  else if(this->AmbiguousDirectory)
-    {
+  } else if (this->AmbiguousDirectory) {
     // Compare possible directory combinations.
-    std::string const& srcDir =
-      cmSystemTools::CollapseFullPath(
-        this->Directory, this->Makefile->GetCurrentSourceDirectory());
-    std::string const& binDir =
-      cmSystemTools::CollapseFullPath(
-        this->Directory, this->Makefile->GetCurrentBinaryDirectory());
-    if(srcDir != loc.Directory &&
-       binDir != loc.Directory)
-      {
+    std::string const& srcDir = cmSystemTools::CollapseFullPath(
+      this->Directory, this->Makefile->GetCurrentSourceDirectory());
+    std::string const& binDir = cmSystemTools::CollapseFullPath(
+      this->Directory, this->Makefile->GetCurrentBinaryDirectory());
+    if (srcDir != loc.Directory && binDir != loc.Directory) {
       return false;
-      }
     }
-  else if(loc.AmbiguousDirectory)
-    {
+  } else if (loc.AmbiguousDirectory) {
     // Compare possible directory combinations.
-    std::string const& srcDir =
-      cmSystemTools::CollapseFullPath(
-        loc.Directory, loc.Makefile->GetCurrentSourceDirectory());
-    std::string const& binDir =
-      cmSystemTools::CollapseFullPath(
-        loc.Directory, loc.Makefile->GetCurrentBinaryDirectory());
-    if(srcDir != this->Directory &&
-       binDir != this->Directory)
-      {
+    std::string const& srcDir = cmSystemTools::CollapseFullPath(
+      loc.Directory, loc.Makefile->GetCurrentSourceDirectory());
+    std::string const& binDir = cmSystemTools::CollapseFullPath(
+      loc.Directory, loc.Makefile->GetCurrentBinaryDirectory());
+    if (srcDir != this->Directory && binDir != this->Directory) {
       return false;
-      }
     }
+  }
 
   // File locations match.
   this->Update(loc);
diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h
index af3651a..7989173 100644
--- a/Source/cmSourceFileLocation.h
+++ b/Source/cmSourceFileLocation.h
@@ -39,7 +39,7 @@ public:
   cmSourceFileLocation& operator=(const cmSourceFileLocation& loc);
 
   /**
-   * Return whether the givne source file location could refers to the
+   * Return whether the given source file location could refers to the
    * same source file as this location given the level of ambiguity in
    * each location.
    */
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index 8fed95e..394b33a 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -17,27 +17,24 @@ public:
   std::vector<cmSourceGroup> GroupChildren;
 };
 
-//----------------------------------------------------------------------------
 cmSourceGroup::cmSourceGroup(const char* name, const char* regex,
-                             const char* parentName): Name(name)
+                             const char* parentName)
+  : Name(name)
 {
   this->Internal = new cmSourceGroupInternals;
   this->SetGroupRegex(regex);
-  if(parentName)
-    {
+  if (parentName) {
     this->FullName = parentName;
     this->FullName += "\\";
-    }
+  }
   this->FullName += this->Name;
 }
 
-//----------------------------------------------------------------------------
 cmSourceGroup::~cmSourceGroup()
 {
   delete this->Internal;
 }
 
-//----------------------------------------------------------------------------
 cmSourceGroup::cmSourceGroup(cmSourceGroup const& r)
 {
   this->Name = r.Name;
@@ -48,7 +45,6 @@ cmSourceGroup::cmSourceGroup(cmSourceGroup const& r)
   this->Internal = new cmSourceGroupInternals(*r.Internal);
 }
 
-//----------------------------------------------------------------------------
 cmSourceGroup& cmSourceGroup::operator=(cmSourceGroup const& r)
 {
   this->Name = r.Name;
@@ -59,74 +55,60 @@ cmSourceGroup& cmSourceGroup::operator=(cmSourceGroup const& r)
   return *this;
 }
 
-//----------------------------------------------------------------------------
 void cmSourceGroup::SetGroupRegex(const char* regex)
 {
-  if(regex)
-    {
+  if (regex) {
     this->GroupRegex.compile(regex);
-    }
-  else
-    {
+  } else {
     this->GroupRegex.compile("^$");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmSourceGroup::AddGroupFile(const std::string& name)
 {
   this->GroupFiles.insert(name);
 }
 
-//----------------------------------------------------------------------------
 const char* cmSourceGroup::GetName() const
 {
   return this->Name.c_str();
 }
 
-//----------------------------------------------------------------------------
 const char* cmSourceGroup::GetFullName() const
 {
   return this->FullName.c_str();
 }
 
-//----------------------------------------------------------------------------
 bool cmSourceGroup::MatchesRegex(const char* name)
 {
   return this->GroupRegex.find(name);
 }
 
-//----------------------------------------------------------------------------
 bool cmSourceGroup::MatchesFiles(const char* name)
 {
   std::set<std::string>::const_iterator i = this->GroupFiles.find(name);
-  if(i != this->GroupFiles.end())
-    {
+  if (i != this->GroupFiles.end()) {
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmSourceGroup::AssignSource(const cmSourceFile* sf)
 {
   this->SourceFiles.push_back(sf);
 }
 
-//----------------------------------------------------------------------------
 const std::vector<const cmSourceFile*>& cmSourceGroup::GetSourceFiles() const
 {
   return this->SourceFiles;
 }
 
-//----------------------------------------------------------------------------
-void cmSourceGroup::AddChild(cmSourceGroup child)
+void cmSourceGroup::AddChild(cmSourceGroup const& child)
 {
   this->Internal->GroupChildren.push_back(child);
 }
 
-//----------------------------------------------------------------------------
-cmSourceGroup *cmSourceGroup::LookupChild(const char* name) const
+cmSourceGroup* cmSourceGroup::LookupChild(const char* name) const
 {
   // initializing iterators
   std::vector<cmSourceGroup>::const_iterator iter =
@@ -135,22 +117,20 @@ cmSourceGroup *cmSourceGroup::LookupChild(const char* name) const
     this->Internal->GroupChildren.end();
 
   // st
-  for(;iter!=end; ++iter)
-    {
+  for (; iter != end; ++iter) {
     std::string sgName = iter->GetName();
 
     // look if descenened is the one were looking for
-    if(sgName == name)
-      {
+    if (sgName == name) {
       return const_cast<cmSourceGroup*>(&(*iter)); // if it so return it
-      }
     }
+  }
 
   // if no child with this name was found return NULL
   return NULL;
 }
 
-cmSourceGroup *cmSourceGroup::MatchChildrenFiles(const char *name)
+cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const char* name)
 {
   // initializing iterators
   std::vector<cmSourceGroup>::iterator iter =
@@ -158,23 +138,19 @@ cmSourceGroup *cmSourceGroup::MatchChildrenFiles(const char *name)
   std::vector<cmSourceGroup>::iterator end =
     this->Internal->GroupChildren.end();
 
-  if(this->MatchesFiles(name))
-    {
+  if (this->MatchesFiles(name)) {
     return this;
-    }
-  for(;iter!=end;++iter)
-    {
-    cmSourceGroup *result = iter->MatchChildrenFiles(name);
-    if(result)
-      {
+  }
+  for (; iter != end; ++iter) {
+    cmSourceGroup* result = iter->MatchChildrenFiles(name);
+    if (result) {
       return result;
-      }
     }
+  }
   return 0;
 }
 
-
-cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name)
+cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const char* name)
 {
   // initializing iterators
   std::vector<cmSourceGroup>::iterator iter =
@@ -182,24 +158,20 @@ cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name)
   std::vector<cmSourceGroup>::iterator end =
     this->Internal->GroupChildren.end();
 
-  for(;iter!=end; ++iter)
-    {
-    cmSourceGroup *result = iter->MatchChildrenRegex(name);
-    if(result)
-      {
+  for (; iter != end; ++iter) {
+    cmSourceGroup* result = iter->MatchChildrenRegex(name);
+    if (result) {
       return result;
-      }
     }
-  if(this->MatchesRegex(name))
-    {
+  }
+  if (this->MatchesRegex(name)) {
     return this;
-    }
+  }
 
   return 0;
 }
 
-std::vector<cmSourceGroup> const&
-cmSourceGroup::GetGroupChildren() const
+std::vector<cmSourceGroup> const& cmSourceGroup::GetGroupChildren() const
 {
   return this->Internal->GroupChildren;
 }
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index e8cf519..8603e95 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -13,6 +13,7 @@
 #define cmSourceGroup_h
 
 #include "cmStandardIncludes.h"
+
 #include <cmsys/RegularExpression.hxx>
 
 class cmSourceFile;
@@ -33,7 +34,7 @@ class cmSourceGroup
 {
 public:
   cmSourceGroup(const char* name, const char* regex,
-                const char* parentName=0);
+                const char* parentName = 0);
   cmSourceGroup(cmSourceGroup const& r);
   ~cmSourceGroup();
   cmSourceGroup& operator=(cmSourceGroup const&);
@@ -51,12 +52,12 @@ public:
   /**
    * Add child to this sourcegroup
    */
-  void AddChild(cmSourceGroup child);
+  void AddChild(cmSourceGroup const& child);
 
   /**
    * Looks up child and returns it
    */
-  cmSourceGroup *LookupChild(const char *name) const;
+  cmSourceGroup* LookupChild(const char* name) const;
 
   /**
    * Get the name of this group.
@@ -82,12 +83,12 @@ public:
    * Check if the given name matches this group's explicit file list
    * in children.
    */
-  cmSourceGroup *MatchChildrenFiles(const char *name);
+  cmSourceGroup* MatchChildrenFiles(const char* name);
 
   /**
    * Check if the given name matches this group's regex in children.
    */
-  cmSourceGroup *MatchChildrenRegex(const char *name);
+  cmSourceGroup* MatchChildrenRegex(const char* name);
 
   /**
    * Assign the given source file to this group.  Used only by
@@ -102,6 +103,7 @@ public:
   const std::vector<const cmSourceFile*>& GetSourceFiles() const;
 
   std::vector<cmSourceGroup> const& GetGroupChildren() const;
+
 private:
   /**
    * The name of the source group.
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index fadb172..252819c 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -12,91 +12,74 @@
 #include "cmSourceGroupCommand.h"
 
 // cmSourceGroupCommand
-bool cmSourceGroupCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args,
+                                       cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string delimiter = "\\";
-  if(this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"))
-    {
+  if (this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER")) {
     delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
-    }
+  }
 
   std::vector<std::string> folders =
     cmSystemTools::tokenize(args[0], delimiter);
 
   cmSourceGroup* sg = 0;
   sg = this->Makefile->GetSourceGroup(folders);
-  if(!sg)
-    {
+  if (!sg) {
     this->Makefile->AddSourceGroup(folders);
     sg = this->Makefile->GetSourceGroup(folders);
-    }
+  }
 
-  if(!sg)
-    {
+  if (!sg) {
     this->SetError("Could not create or find source group");
     return false;
-    }
+  }
   // If only two arguments are given, the pre-1.8 version of the
   // command is being invoked.
-  if(args.size() == 2  && args[1] != "FILES")
-    {
+  if (args.size() == 2 && args[1] != "FILES") {
     sg->SetGroupRegex(args[1].c_str());
     return true;
-    }
+  }
 
   // Process arguments.
   bool doingFiles = false;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "REGULAR_EXPRESSION")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "REGULAR_EXPRESSION") {
       // Next argument must specify the regex.
-      if(i+1 < args.size())
-        {
+      if (i + 1 < args.size()) {
         ++i;
         sg->SetGroupRegex(args[i].c_str());
-        }
-      else
-        {
+      } else {
         this->SetError("REGULAR_EXPRESSION argument given without a regex.");
         return false;
-        }
-      doingFiles = false;
       }
-    else if(args[i] == "FILES")
-      {
+      doingFiles = false;
+    } else if (args[i] == "FILES") {
       // Next arguments will specify files.
       doingFiles = true;
-      }
-    else if(doingFiles)
-      {
+    } else if (doingFiles) {
       // Convert name to full path and add to the group's list.
       std::string src = args[i];
-      if(!cmSystemTools::FileIsFullPath(src.c_str()))
-        {
+      if (!cmSystemTools::FileIsFullPath(src.c_str())) {
         src = this->Makefile->GetCurrentSourceDirectory();
         src += "/";
         src += args[i];
-        }
+      }
       src = cmSystemTools::CollapseFullPath(src.c_str());
       sg->AddGroupFile(src);
-      }
-    else
-      {
+    } else {
       std::ostringstream err;
       err << "Unknown argument \"" << args[i] << "\".  "
           << "Perhaps the FILES keyword is missing.\n";
       this->SetError(err.str());
       return false;
-      }
     }
+  }
 
   return true;
 }
diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h
index 410411b..0458656 100644
--- a/Source/cmSourceGroupCommand.h
+++ b/Source/cmSourceGroupCommand.h
@@ -26,26 +26,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmSourceGroupCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSourceGroupCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "source_group";}
+  virtual std::string GetName() const { return "source_group"; }
 
   cmTypeMacro(cmSourceGroupCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index 272c136..6669e5c 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -17,71 +17,80 @@
 #define cmStandardIncludes_h
 
 #include <cmConfigure.h>
+
 #include <cmsys/Configure.hxx>
 
 #ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#pragma warning ( disable : 4503 )
+#pragma warning(disable : 4786)
+#pragma warning(disable : 4503)
 #endif
 
-
 #ifdef __ICL
-#pragma warning ( disable : 985 )
-#pragma warning ( disable : 1572 ) /* floating-point equality test */
+#pragma warning(disable : 985)
+#pragma warning(disable : 1572) /* floating-point equality test */
 #endif
 
 // Provide fixed-size integer types.
 #include <cm_kwiml.h>
 
 #include <fstream>
-#include <iostream>
 #include <iomanip>
+#include <iostream>
 #include <sstream>
 
 // we must have stl with the standard include style
-#include <vector>
-#include <string>
-#include <iterator>
 #include <algorithm>
 #include <functional>
+#include <iterator>
 #include <map>
 #include <set>
+#include <string>
+#include <vector>
 
 // include the "c" string header
-#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
-#if defined( _MSC_VER )
+#if defined(_MSC_VER)
 typedef unsigned short mode_t;
 #else
-# include <sys/types.h>
+#include <sys/types.h>
 #endif
 
 // use this class to shrink the size of symbols in .o files
 // 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 std::string;
+// typedef cmsys::String std::string;
 
 /* Poison this operator to avoid common mistakes.  */
-extern void operator << (std::ostream&, const std::ostringstream&);
+extern void operator<<(std::ostream&, const std::ostringstream&);
 
 /** Standard documentation entry for cmDocumentation's formatting.  */
 struct cmDocumentationEntry
 {
   std::string Name;
   std::string Brief;
-  cmDocumentationEntry(){}
-  cmDocumentationEntry(const char *doc[2])
-  { if (doc[0]) this->Name = doc[0];
-  if (doc[1]) this->Brief = doc[1];}
-  cmDocumentationEntry(const char *n, const char *b)
-  { if (n) this->Name = n; if (b) this->Brief = b; }
+  cmDocumentationEntry() {}
+  cmDocumentationEntry(const char* doc[2])
+  {
+    if (doc[0])
+      this->Name = doc[0];
+    if (doc[1])
+      this->Brief = doc[1];
+  }
+  cmDocumentationEntry(const char* n, const char* b)
+  {
+    if (n)
+      this->Name = n;
+    if (b)
+      this->Brief = b;
+  }
 };
 
 /** Data structure to represent a single command line.  */
-class cmCustomCommandLine: public std::vector<std::string>
+class cmCustomCommandLine : public std::vector<std::string>
 {
 public:
   typedef std::vector<std::string> Superclass;
@@ -90,7 +99,7 @@ public:
 };
 
 /** Data structure to represent a list of command lines.  */
-class cmCustomCommandLines: public std::vector<cmCustomCommandLine>
+class cmCustomCommandLines : public std::vector<cmCustomCommandLine>
 {
 public:
   typedef std::vector<cmCustomCommandLine> Superclass;
@@ -100,32 +109,28 @@ public:
 
 // All subclasses of cmCommand or cmCTestGenericHandler should
 // invoke this macro.
-#define cmTypeMacro(thisClass,superclass) \
-virtual const char* GetNameOfClass() { return #thisClass; } \
-typedef superclass Superclass; \
-static bool IsTypeOf(const char *type) \
-{ \
-  if ( !strcmp(#thisClass,type) ) \
-    { \
-    return true; \
-    } \
-  return Superclass::IsTypeOf(type); \
-} \
-virtual bool IsA(const char *type) \
-{ \
-  return thisClass::IsTypeOf(type); \
-} \
-static thisClass* SafeDownCast(cmObject *c) \
-{ \
-  if ( c && c->IsA(#thisClass) ) \
-    { \
-    return static_cast<thisClass *>(c); \
-    } \
-  return 0;\
-} \
-class cmTypeMacro_UseTrailingSemicolon
-
-enum cmTargetLinkLibraryType {
+#define cmTypeMacro(thisClass, superclass)                                    \
+  virtual const char* GetNameOfClass() { return #thisClass; }                 \
+  typedef superclass Superclass;                                              \
+  static bool IsTypeOf(const char* type)                                      \
+  {                                                                           \
+    if (!strcmp(#thisClass, type)) {                                          \
+      return true;                                                            \
+    }                                                                         \
+    return Superclass::IsTypeOf(type);                                        \
+  }                                                                           \
+  virtual bool IsA(const char* type) { return thisClass::IsTypeOf(type); }    \
+  static thisClass* SafeDownCast(cmObject* c)                                 \
+  {                                                                           \
+    if (c && c->IsA(#thisClass)) {                                            \
+      return static_cast<thisClass*>(c);                                      \
+    }                                                                         \
+    return 0;                                                                 \
+  }                                                                           \
+  class cmTypeMacro_UseTrailingSemicolon
+
+enum cmTargetLinkLibraryType
+{
   GENERAL_LibraryType,
   DEBUG_LibraryType,
   OPTIMIZED_LibraryType
diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h
index bd08ac7..94ed276 100644
--- a/Source/cmStandardLexer.h
+++ b/Source/cmStandardLexer.h
@@ -14,29 +14,29 @@
 
 /* Disable some warnings.  */
 #if defined(_MSC_VER)
-# pragma warning ( disable : 4127 )
-# pragma warning ( disable : 4131 )
-# pragma warning ( disable : 4244 )
-# pragma warning ( disable : 4251 )
-# pragma warning ( disable : 4267 )
-# pragma warning ( disable : 4305 )
-# pragma warning ( disable : 4309 )
-# pragma warning ( disable : 4706 )
-# pragma warning ( disable : 4786 )
+#pragma warning(disable : 4127)
+#pragma warning(disable : 4131)
+#pragma warning(disable : 4244)
+#pragma warning(disable : 4251)
+#pragma warning(disable : 4267)
+#pragma warning(disable : 4305)
+#pragma warning(disable : 4309)
+#pragma warning(disable : 4706)
+#pragma warning(disable : 4786)
 #endif
 
 /* Define isatty on windows.  */
 #if defined(_WIN32) && !defined(__CYGWIN__)
-# include <io.h>
-# if defined( _MSC_VER )
-#  define isatty _isatty
-# endif
-# define YY_NO_UNISTD_H 1
+#include <io.h>
+#if defined(_MSC_VER)
+#define isatty _isatty
+#endif
+#define YY_NO_UNISTD_H 1
 #endif
 
 /* Make sure malloc and free are available on QNX.  */
 #ifdef __QNX__
-# include <malloc.h>
+#include <malloc.h>
 #endif
 
 /* Disable features we do not need. */
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index b8e604b..04f07ce 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -11,12 +11,12 @@
 ============================================================================*/
 #include "cmState.h"
 
-#include "cmake.h"
-#include "cmVersion.h"
+#include "cmAlgorithms.h"
 #include "cmCacheManager.h"
 #include "cmCommand.h"
-#include "cmAlgorithms.h"
 #include "cmDefinitions.h"
+#include "cmVersion.h"
+#include "cmake.h"
 
 #include <assert.h>
 
@@ -31,23 +31,33 @@ struct cmState::SnapshotDataType
   bool Keep;
   cmLinkedTree<std::string>::iterator ExecutionListFile;
   cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator
-                                                          BuildSystemDirectory;
+    BuildSystemDirectory;
   cmLinkedTree<cmDefinitions>::iterator Vars;
   cmLinkedTree<cmDefinitions>::iterator Root;
   cmLinkedTree<cmDefinitions>::iterator Parent;
-  std::string EntryPointCommand;
-  long EntryPointLine;
   std::vector<std::string>::size_type IncludeDirectoryPosition;
   std::vector<std::string>::size_type CompileDefinitionsPosition;
   std::vector<std::string>::size_type CompileOptionsPosition;
 };
 
-struct cmState::PolicyStackEntry: public cmPolicies::PolicyMap
+struct cmState::PolicyStackEntry : public cmPolicies::PolicyMap
 {
   typedef cmPolicies::PolicyMap derived;
-  PolicyStackEntry(bool w = false): derived(), Weak(w) {}
-  PolicyStackEntry(derived const& d, bool w): derived(d), Weak(w) {}
-  PolicyStackEntry(PolicyStackEntry const& r): derived(r), Weak(r.Weak) {}
+  PolicyStackEntry(bool w = false)
+    : derived()
+    , Weak(w)
+  {
+  }
+  PolicyStackEntry(derived const& d, bool w)
+    : derived(d)
+    , Weak(w)
+  {
+  }
+  PolicyStackEntry(PolicyStackEntry const& r)
+    : derived(r)
+    , Weak(r.Weak)
+  {
+  }
   bool Weak;
 };
 
@@ -85,13 +95,13 @@ struct cmState::BuildsystemDirectoryStateType
 };
 
 cmState::cmState()
-  : IsInTryCompile(false),
-    WindowsShell(false),
-    WindowsVSIDE(false),
-    WatcomWMake(false),
-    MinGWMake(false),
-    NMake(false),
-    MSYSShell(false)
+  : IsInTryCompile(false)
+  , WindowsShell(false)
+  , WindowsVSIDE(false)
+  , WatcomWMake(false)
+  , MinGWMake(false)
+  , NMake(false)
+  , MSYSShell(false)
 {
   this->CacheManager = new cmCacheManager;
 }
@@ -104,76 +114,61 @@ cmState::~cmState()
 
 const char* cmState::GetTargetTypeName(cmState::TargetType targetType)
 {
-  switch( targetType )
-    {
-      case cmState::STATIC_LIBRARY:
-        return "STATIC_LIBRARY";
-      case cmState::MODULE_LIBRARY:
-        return "MODULE_LIBRARY";
-      case cmState::SHARED_LIBRARY:
-        return "SHARED_LIBRARY";
-      case cmState::OBJECT_LIBRARY:
-        return "OBJECT_LIBRARY";
-      case cmState::EXECUTABLE:
-        return "EXECUTABLE";
-      case cmState::UTILITY:
-        return "UTILITY";
-      case cmState::GLOBAL_TARGET:
-        return "GLOBAL_TARGET";
-      case cmState::INTERFACE_LIBRARY:
-        return "INTERFACE_LIBRARY";
-      case cmState::UNKNOWN_LIBRARY:
-        return "UNKNOWN_LIBRARY";
-    }
+  switch (targetType) {
+    case cmState::STATIC_LIBRARY:
+      return "STATIC_LIBRARY";
+    case cmState::MODULE_LIBRARY:
+      return "MODULE_LIBRARY";
+    case cmState::SHARED_LIBRARY:
+      return "SHARED_LIBRARY";
+    case cmState::OBJECT_LIBRARY:
+      return "OBJECT_LIBRARY";
+    case cmState::EXECUTABLE:
+      return "EXECUTABLE";
+    case cmState::UTILITY:
+      return "UTILITY";
+    case cmState::GLOBAL_TARGET:
+      return "GLOBAL_TARGET";
+    case cmState::INTERFACE_LIBRARY:
+      return "INTERFACE_LIBRARY";
+    case cmState::UNKNOWN_LIBRARY:
+      return "UNKNOWN_LIBRARY";
+  }
   assert(0 && "Unexpected target type");
   return 0;
 }
 
-const char* cmCacheEntryTypes[] =
-{ "BOOL",
-  "PATH",
-  "FILEPATH",
-  "STRING",
-  "INTERNAL",
-  "STATIC",
-  "UNINITIALIZED",
-  0
-};
+const char* cmCacheEntryTypes[] = { "BOOL",          "PATH",     "FILEPATH",
+                                    "STRING",        "INTERNAL", "STATIC",
+                                    "UNINITIALIZED", 0 };
 
-const char*
-cmState::CacheEntryTypeToString(cmState::CacheEntryType type)
+const char* cmState::CacheEntryTypeToString(cmState::CacheEntryType type)
 {
-  if ( type > 6 )
-    {
+  if (type > 6) {
     return cmCacheEntryTypes[6];
-    }
+  }
   return cmCacheEntryTypes[type];
 }
 
-cmState::CacheEntryType
-cmState::StringToCacheEntryType(const char* s)
+cmState::CacheEntryType cmState::StringToCacheEntryType(const char* s)
 {
   int i = 0;
-  while(cmCacheEntryTypes[i])
-    {
-    if(strcmp(s, cmCacheEntryTypes[i]) == 0)
-      {
+  while (cmCacheEntryTypes[i]) {
+    if (strcmp(s, cmCacheEntryTypes[i]) == 0) {
       return static_cast<cmState::CacheEntryType>(i);
-      }
-    ++i;
     }
+    ++i;
+  }
   return STRING;
 }
 
 bool cmState::IsCacheEntryType(std::string const& key)
 {
-  for(int i=0; cmCacheEntryTypes[i]; ++i)
-    {
-    if(strcmp(key.c_str(), cmCacheEntryTypes[i]) == 0)
-      {
+  for (int i = 0; cmCacheEntryTypes[i]; ++i) {
+    if (strcmp(key.c_str(), cmCacheEntryTypes[i]) == 0) {
       return true;
-      }
     }
+  }
   return false;
 }
 
@@ -181,8 +176,7 @@ bool cmState::LoadCache(const std::string& path, bool internal,
                         std::set<std::string>& excludes,
                         std::set<std::string>& includes)
 {
-  return this->CacheManager->LoadCache(path, internal,
-                                       excludes, includes);
+  return this->CacheManager->LoadCache(path, internal, excludes, includes);
 }
 
 bool cmState::SaveCache(const std::string& path)
@@ -199,89 +193,82 @@ std::vector<std::string> cmState::GetCacheEntryKeys() const
 {
   std::vector<std::string> definitions;
   definitions.reserve(this->CacheManager->GetSize());
-  cmCacheManager::CacheIterator cit =
-    this->CacheManager->GetCacheIterator();
-  for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
-    {
+  cmCacheManager::CacheIterator cit = this->CacheManager->GetCacheIterator();
+  for (cit.Begin(); !cit.IsAtEnd(); cit.Next()) {
     definitions.push_back(cit.GetName());
-    }
+  }
   return definitions;
 }
 
 const char* cmState::GetCacheEntryValue(std::string const& key) const
 {
-  cmCacheManager::CacheEntry* e = this->CacheManager
-             ->GetCacheEntry(key);
-  if (!e)
-    {
+  cmCacheManager::CacheEntry* e = this->CacheManager->GetCacheEntry(key);
+  if (!e) {
     return 0;
-    }
+  }
   return e->Value.c_str();
 }
 
-const char*
-cmState::GetInitializedCacheValue(std::string const& key) const
+const char* cmState::GetInitializedCacheValue(std::string const& key) const
 {
   return this->CacheManager->GetInitializedCacheValue(key);
 }
 
-cmState::CacheEntryType
-cmState::GetCacheEntryType(std::string const& key) const
+cmState::CacheEntryType cmState::GetCacheEntryType(
+  std::string const& key) const
 {
   cmCacheManager::CacheIterator it =
-      this->CacheManager->GetCacheIterator(key.c_str());
+    this->CacheManager->GetCacheIterator(key.c_str());
   return it.GetType();
 }
 
 void cmState::SetCacheEntryValue(std::string const& key,
-                                         std::string const& value)
+                                 std::string const& value)
 {
   this->CacheManager->SetCacheEntryValue(key, value);
 }
 
 void cmState::SetCacheEntryProperty(std::string const& key,
-                            std::string const& propertyName,
-                            std::string const& value)
+                                    std::string const& propertyName,
+                                    std::string const& value)
 {
   cmCacheManager::CacheIterator it =
-      this->CacheManager->GetCacheIterator(key.c_str());
+    this->CacheManager->GetCacheIterator(key.c_str());
   it.SetProperty(propertyName, value.c_str());
 }
 
 void cmState::SetCacheEntryBoolProperty(std::string const& key,
-                            std::string const& propertyName,
-                            bool value)
+                                        std::string const& propertyName,
+                                        bool value)
 {
   cmCacheManager::CacheIterator it =
-      this->CacheManager->GetCacheIterator(key.c_str());
+    this->CacheManager->GetCacheIterator(key.c_str());
   it.SetProperty(propertyName, value);
 }
 
 const char* cmState::GetCacheEntryProperty(std::string const& key,
-                                              std::string const& propertyName)
+                                           std::string const& propertyName)
 {
-  cmCacheManager::CacheIterator it = this->CacheManager
-             ->GetCacheIterator(key.c_str());
-  if (!it.PropertyExists(propertyName))
-    {
+  cmCacheManager::CacheIterator it =
+    this->CacheManager->GetCacheIterator(key.c_str());
+  if (!it.PropertyExists(propertyName)) {
     return 0;
-    }
+  }
   return it.GetProperty(propertyName);
 }
 
 bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
-                                              std::string const& propertyName)
+                                          std::string const& propertyName)
 {
-  return this->CacheManager
-             ->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName);
+  return this->CacheManager->GetCacheIterator(key.c_str())
+    .GetPropertyAsBool(propertyName);
 }
 
 void cmState::AddCacheEntry(const std::string& key, const char* value,
-                                    const char* helpString,
-                                    cmState::CacheEntryType type)
+                            const char* helpString,
+                            cmState::CacheEntryType type)
 {
-  this->CacheManager->AddCacheEntry(key, value,
-                                                        helpString, type);
+  this->CacheManager->AddCacheEntry(key, value, helpString, type);
 }
 
 void cmState::RemoveCacheEntry(std::string const& key)
@@ -290,21 +277,18 @@ void cmState::RemoveCacheEntry(std::string const& key)
 }
 
 void cmState::AppendCacheEntryProperty(const std::string& key,
-                                               const std::string& property,
-                                               const std::string& value,
-                                               bool asString)
+                                       const std::string& property,
+                                       const std::string& value, bool asString)
 {
-  this->CacheManager
-       ->GetCacheIterator(key.c_str()).AppendProperty(property,
-                                                       value.c_str(),
-                                                       asString);
+  this->CacheManager->GetCacheIterator(key.c_str())
+    .AppendProperty(property, value.c_str(), asString);
 }
 
 void cmState::RemoveCacheEntryProperty(std::string const& key,
-                                              std::string const& propertyName)
+                                       std::string const& propertyName)
 {
-  this->CacheManager
-       ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0);
+  this->CacheManager->GetCacheIterator(key.c_str())
+    .SetProperty(propertyName, (void*)0);
 }
 
 cmState::Snapshot cmState::Reset()
@@ -316,17 +300,17 @@ cmState::Snapshot cmState::Reset()
   this->ExecutionListFiles.Truncate();
 
   {
-  cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
+    cmLinkedTree<BuildsystemDirectoryStateType>::iterator it =
       this->BuildsystemDirectory.Truncate();
-  it->IncludeDirectories.clear();
-  it->IncludeDirectoryBacktraces.clear();
-  it->CompileDefinitions.clear();
-  it->CompileDefinitionsBacktraces.clear();
-  it->CompileOptions.clear();
-  it->CompileOptionsBacktraces.clear();
-  it->DirectoryEnd = pos;
-  it->Properties.clear();
-  it->Children.clear();
+    it->IncludeDirectories.clear();
+    it->IncludeDirectoryBacktraces.clear();
+    it->CompileDefinitions.clear();
+    it->CompileDefinitionsBacktraces.clear();
+    it->CompileOptions.clear();
+    it->CompileOptionsBacktraces.clear();
+    it->DirectoryEnd = pos;
+    it->Properties.clear();
+    it->Children.clear();
   }
 
   this->PolicyStack.Clear();
@@ -337,99 +321,83 @@ cmState::Snapshot cmState::Reset()
   assert(pos->PolicyRoot.IsValid());
 
   {
-  std::string srcDir =
+    std::string srcDir =
       cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root);
-  std::string binDir =
+    std::string binDir =
       cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root);
-  this->VarTree.Clear();
-  pos->Vars = this->VarTree.Push(this->VarTree.Root());
-  pos->Parent = this->VarTree.Root();
-  pos->Root = this->VarTree.Root();
+    this->VarTree.Clear();
+    pos->Vars = this->VarTree.Push(this->VarTree.Root());
+    pos->Parent = this->VarTree.Root();
+    pos->Root = this->VarTree.Root();
 
-  pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
-  pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
+    pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
+    pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
   }
 
-  this->DefineProperty
-    ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
-     "", "", true);
-  this->DefineProperty
-    ("RULE_LAUNCH_LINK", cmProperty::DIRECTORY,
-     "", "", true);
-  this->DefineProperty
-    ("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY,
-     "", "", true);
-
-  this->DefineProperty
-    ("RULE_LAUNCH_COMPILE", cmProperty::TARGET,
-     "", "", true);
-  this->DefineProperty
-    ("RULE_LAUNCH_LINK", cmProperty::TARGET,
-     "", "", true);
-  this->DefineProperty
-    ("RULE_LAUNCH_CUSTOM", cmProperty::TARGET,
-     "", "", true);
+  this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "",
+                       true);
+  this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::DIRECTORY, "", "",
+                       true);
+  this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY, "", "",
+                       true);
+
+  this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::TARGET, "", "",
+                       true);
+  this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::TARGET, "", "", true);
+  this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, "", "", true);
 
   return Snapshot(this, pos);
 }
 
 void cmState::DefineProperty(const std::string& name,
-                           cmProperty::ScopeType scope,
-                           const char *ShortDescription,
-                           const char *FullDescription,
-                           bool chained)
+                             cmProperty::ScopeType scope,
+                             const char* ShortDescription,
+                             const char* FullDescription, bool chained)
 {
-  this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription,
-                                                  FullDescription,
-                                                  chained);
+  this->PropertyDefinitions[scope].DefineProperty(
+    name, scope, ShortDescription, FullDescription, chained);
 }
 
-cmPropertyDefinition const* cmState
-::GetPropertyDefinition(const std::string& name,
-                        cmProperty::ScopeType scope) const
+cmPropertyDefinition const* cmState::GetPropertyDefinition(
+  const std::string& name, cmProperty::ScopeType scope) const
 {
-  if (this->IsPropertyDefined(name,scope))
-    {
+  if (this->IsPropertyDefined(name, scope)) {
     cmPropertyDefinitionMap const& defs =
-        this->PropertyDefinitions.find(scope)->second;
+      this->PropertyDefinitions.find(scope)->second;
     return &defs.find(name)->second;
-    }
+  }
   return 0;
 }
 
 bool cmState::IsPropertyDefined(const std::string& name,
                                 cmProperty::ScopeType scope) const
 {
-  std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it
-      = this->PropertyDefinitions.find(scope);
-  if (it == this->PropertyDefinitions.end())
-    {
+  std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it =
+    this->PropertyDefinitions.find(scope);
+  if (it == this->PropertyDefinitions.end()) {
     return false;
-    }
+  }
   return it->second.IsPropertyDefined(name);
 }
 
 bool cmState::IsPropertyChained(const std::string& name,
                                 cmProperty::ScopeType scope) const
 {
-  std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it
-      = this->PropertyDefinitions.find(scope);
-  if (it == this->PropertyDefinitions.end())
-    {
+  std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it =
+    this->PropertyDefinitions.find(scope);
+  if (it == this->PropertyDefinitions.end()) {
     return false;
-    }
+  }
   return it->second.IsPropertyChained(name);
 }
 
 void cmState::SetLanguageEnabled(std::string const& l)
 {
-  std::vector<std::string>::iterator it =
-      std::lower_bound(this->EnabledLanguages.begin(),
-                       this->EnabledLanguages.end(), l);
-  if (it == this->EnabledLanguages.end() || *it != l)
-    {
+  std::vector<std::string>::iterator it = std::lower_bound(
+    this->EnabledLanguages.begin(), this->EnabledLanguages.end(), l);
+  if (it == this->EnabledLanguages.end() || *it != l) {
     this->EnabledLanguages.insert(it, l);
-    }
+  }
 }
 
 bool cmState::GetLanguageEnabled(std::string const& l) const
@@ -470,19 +438,17 @@ void cmState::RenameCommand(std::string const& oldName,
   std::string sOldName = cmSystemTools::LowerCase(oldName);
   std::string sNewName = cmSystemTools::LowerCase(newName);
   std::map<std::string, cmCommand*>::iterator pos =
-      this->Commands.find(sOldName);
-  if ( pos == this->Commands.end() )
-    {
+    this->Commands.find(sOldName);
+  if (pos == this->Commands.end()) {
     return;
-    }
+  }
   cmCommand* cmd = pos->second;
 
   pos = this->Commands.find(sNewName);
-  if (pos != this->Commands.end())
-    {
+  if (pos != this->Commands.end()) {
     delete pos->second;
     this->Commands.erase(pos);
-    }
+  }
   this->Commands.insert(std::make_pair(sNewName, cmd));
   pos = this->Commands.find(sOldName);
   this->Commands.erase(pos);
@@ -493,31 +459,26 @@ void cmState::AddCommand(cmCommand* command)
   std::string name = cmSystemTools::LowerCase(command->GetName());
   // if the command already exists, free the old one
   std::map<std::string, cmCommand*>::iterator pos = this->Commands.find(name);
-  if (pos != this->Commands.end())
-    {
+  if (pos != this->Commands.end()) {
     delete pos->second;
     this->Commands.erase(pos);
-    }
+  }
   this->Commands.insert(std::make_pair(name, command));
 }
 
 void cmState::RemoveUnscriptableCommands()
 {
   std::vector<std::string> unscriptableCommands;
-  for (std::map<std::string, cmCommand*>::iterator
-       pos = this->Commands.begin();
-       pos != this->Commands.end(); )
-    {
-    if (!pos->second->IsScriptable())
-      {
+  for (std::map<std::string, cmCommand*>::iterator pos =
+         this->Commands.begin();
+       pos != this->Commands.end();) {
+    if (!pos->second->IsScriptable()) {
       delete pos->second;
       this->Commands.erase(pos++);
-      }
-    else
-      {
+    } else {
       ++pos;
-      }
     }
+  }
 }
 
 cmCommand* cmState::GetCommand(std::string const& name) const
@@ -525,11 +486,10 @@ cmCommand* cmState::GetCommand(std::string const& name) const
   cmCommand* command = 0;
   std::string sName = cmSystemTools::LowerCase(name);
   std::map<std::string, cmCommand*>::const_iterator pos =
-      this->Commands.find(sName);
-  if (pos != this->Commands.end())
-    {
+    this->Commands.find(sName);
+  if (pos != this->Commands.end()) {
     command = (*pos).second;
-    }
+  }
   return command;
 }
 
@@ -537,42 +497,34 @@ std::vector<std::string> cmState::GetCommandNames() const
 {
   std::vector<std::string> commandNames;
   commandNames.reserve(this->Commands.size());
-  std::map<std::string, cmCommand*>::const_iterator cmds
-      = this->Commands.begin();
-  for ( ; cmds != this->Commands.end(); ++ cmds )
-    {
+  std::map<std::string, cmCommand*>::const_iterator cmds =
+    this->Commands.begin();
+  for (; cmds != this->Commands.end(); ++cmds) {
     commandNames.push_back(cmds->first);
-    }
+  }
   return commandNames;
 }
 
 void cmState::RemoveUserDefinedCommands()
 {
   std::vector<cmCommand*> renamedCommands;
-  for(std::map<std::string, cmCommand*>::iterator j = this->Commands.begin();
-      j != this->Commands.end(); )
-    {
+  for (std::map<std::string, cmCommand*>::iterator j = this->Commands.begin();
+       j != this->Commands.end();) {
     if (j->second->IsA("cmMacroHelperCommand") ||
-        j->second->IsA("cmFunctionHelperCommand"))
-      {
+        j->second->IsA("cmFunctionHelperCommand")) {
       delete j->second;
       this->Commands.erase(j++);
-      }
-    else if (j->first != j->second->GetName())
-      {
+    } else if (j->first != j->second->GetName()) {
       renamedCommands.push_back(j->second);
       this->Commands.erase(j++);
-      }
-    else
-      {
+    } else {
       ++j;
-      }
     }
+  }
   for (std::vector<cmCommand*>::const_iterator it = renamedCommands.begin();
-       it != renamedCommands.end(); ++it)
-    {
+       it != renamedCommands.end(); ++it) {
     this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it;
-    }
+  }
 }
 
 void cmState::SetGlobalProperty(const std::string& prop, const char* value)
@@ -580,44 +532,35 @@ void cmState::SetGlobalProperty(const std::string& prop, const char* value)
   this->GlobalProperties.SetProperty(prop, value);
 }
 
-void cmState::AppendGlobalProperty(const std::string& prop,
-                                   const char* value, bool asString)
+void cmState::AppendGlobalProperty(const std::string& prop, const char* value,
+                                   bool asString)
 {
   this->GlobalProperties.AppendProperty(prop, value, asString);
 }
 
-const char *cmState::GetGlobalProperty(const std::string& prop)
+const char* cmState::GetGlobalProperty(const std::string& prop)
 {
-  if ( prop == "CACHE_VARIABLES" )
-    {
+  if (prop == "CACHE_VARIABLES") {
     std::vector<std::string> cacheKeys = this->GetCacheEntryKeys();
     this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str());
-    }
-  else if ( prop == "COMMANDS" )
-    {
+  } else if (prop == "COMMANDS") {
     std::vector<std::string> commands = this->GetCommandNames();
     this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str());
-    }
-  else if ( prop == "IN_TRY_COMPILE" )
-    {
+  } else if (prop == "IN_TRY_COMPILE") {
     this->SetGlobalProperty("IN_TRY_COMPILE",
-                      this->IsInTryCompile ? "1" : "0");
-    }
-  else if ( prop == "ENABLED_LANGUAGES" )
-    {
+                            this->IsInTryCompile ? "1" : "0");
+  } else if (prop == "ENABLED_LANGUAGES") {
     std::string langs;
     langs = cmJoin(this->EnabledLanguages, ";");
     this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str());
-    }
+  }
 #define STRING_LIST_ELEMENT(F) ";" #F
-  if (prop == "CMAKE_C_KNOWN_FEATURES")
-    {
+  if (prop == "CMAKE_C_KNOWN_FEATURES") {
     return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
-    }
-  if (prop == "CMAKE_CXX_KNOWN_FEATURES")
-    {
+  }
+  if (prop == "CMAKE_CXX_KNOWN_FEATURES") {
     return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
-    }
+  }
 #undef STRING_LIST_ELEMENT
   return this->GlobalProperties.GetPropertyValue(prop);
 }
@@ -633,8 +576,8 @@ void cmState::SetSourceDirectory(std::string const& sourceDirectory)
   cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
 
   cmSystemTools::SplitPath(
-      cmSystemTools::CollapseFullPath(this->SourceDirectory),
-        this->SourceDirectoryComponents);
+    cmSystemTools::CollapseFullPath(this->SourceDirectory),
+    this->SourceDirectoryComponents);
 }
 
 const char* cmState::GetSourceDirectory() const
@@ -653,8 +596,8 @@ void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
   cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
 
   cmSystemTools::SplitPath(
-      cmSystemTools::CollapseFullPath(this->BinaryDirectory),
-        this->BinaryDirectoryComponents);
+    cmSystemTools::CollapseFullPath(this->BinaryDirectory),
+    this->BinaryDirectoryComponents);
 }
 
 void cmState::SetWindowsShell(bool windowsShell)
@@ -746,30 +689,25 @@ void cmState::Directory::ComputeRelativePathTopSource()
   cmState::Snapshot snapshot = this->Snapshot_;
   std::vector<cmState::Snapshot> snapshots;
   snapshots.push_back(snapshot);
-  while (true)
-    {
+  while (true) {
     snapshot = snapshot.GetBuildsystemDirectoryParent();
-    if (snapshot.IsValid())
-      {
+    if (snapshot.IsValid()) {
       snapshots.push_back(snapshot);
-      }
-    else
-      {
+    } else {
       break;
-      }
     }
+  }
 
   std::string result = snapshots.front().GetDirectory().GetCurrentSource();
 
   for (std::vector<cmState::Snapshot>::const_iterator it =
-       snapshots.begin() + 1; it != snapshots.end(); ++it)
-    {
+         snapshots.begin() + 1;
+       it != snapshots.end(); ++it) {
     std::string currentSource = it->GetDirectory().GetCurrentSource();
-    if(cmSystemTools::IsSubDirectory(result, currentSource))
-      {
+    if (cmSystemTools::IsSubDirectory(result, currentSource)) {
       result = currentSource;
-      }
     }
+  }
   this->DirectoryState->RelativePathTopSource = result;
 }
 
@@ -778,43 +716,34 @@ void cmState::Directory::ComputeRelativePathTopBinary()
   cmState::Snapshot snapshot = this->Snapshot_;
   std::vector<cmState::Snapshot> snapshots;
   snapshots.push_back(snapshot);
-  while (true)
-    {
+  while (true) {
     snapshot = snapshot.GetBuildsystemDirectoryParent();
-    if (snapshot.IsValid())
-      {
+    if (snapshot.IsValid()) {
       snapshots.push_back(snapshot);
-      }
-    else
-      {
+    } else {
       break;
-      }
     }
+  }
 
-  std::string result =
-      snapshots.front().GetDirectory().GetCurrentBinary();
+  std::string result = snapshots.front().GetDirectory().GetCurrentBinary();
 
   for (std::vector<cmState::Snapshot>::const_iterator it =
-       snapshots.begin() + 1; it != snapshots.end(); ++it)
-    {
+         snapshots.begin() + 1;
+       it != snapshots.end(); ++it) {
     std::string currentBinary = it->GetDirectory().GetCurrentBinary();
-    if(cmSystemTools::IsSubDirectory(result, currentBinary))
-      {
+    if (cmSystemTools::IsSubDirectory(result, currentBinary)) {
       result = currentBinary;
-      }
     }
+  }
 
   // The current working directory on Windows cannot be a network
   // path.  Therefore relative paths cannot work when the binary tree
   // is a network path.
-  if(result.size() < 2 || result.substr(0, 2) != "//")
-    {
+  if (result.size() < 2 || result.substr(0, 2) != "//") {
     this->DirectoryState->RelativePathTopBinary = result;
-    }
-  else
-    {
+  } else {
     this->DirectoryState->RelativePathTopBinary = "";
-    }
+  }
 }
 
 cmState::Snapshot cmState::CreateBaseSnapshot()
@@ -825,9 +754,9 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
   pos->SnapshotType = BaseType;
   pos->Keep = true;
   pos->BuildSystemDirectory =
-      this->BuildsystemDirectory.Push(this->BuildsystemDirectory.Root());
+    this->BuildsystemDirectory.Push(this->BuildsystemDirectory.Root());
   pos->ExecutionListFile =
-      this->ExecutionListFiles.Push(this->ExecutionListFiles.Root());
+    this->ExecutionListFiles.Push(this->ExecutionListFiles.Root());
   pos->IncludeDirectoryPosition = 0;
   pos->CompileDefinitionsPosition = 0;
   pos->CompileOptionsPosition = 0;
@@ -844,25 +773,19 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
   return cmState::Snapshot(this, pos);
 }
 
-cmState::Snapshot
-cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
-                                    std::string const& entryPointCommand,
-                                    long entryPointLine)
+cmState::Snapshot cmState::CreateBuildsystemDirectorySnapshot(
+  Snapshot originSnapshot)
 {
   assert(originSnapshot.IsValid());
   PositionType pos = this->SnapshotData.Push(originSnapshot.Position);
-  pos->EntryPointLine = entryPointLine;
-  pos->EntryPointCommand = entryPointCommand;
   pos->DirectoryParent = originSnapshot.Position;
   pos->ScopeParent = originSnapshot.Position;
   pos->SnapshotType = BuildsystemDirectoryType;
   pos->Keep = true;
-  pos->BuildSystemDirectory =
-      this->BuildsystemDirectory.Push(
-        originSnapshot.Position->BuildSystemDirectory);
+  pos->BuildSystemDirectory = this->BuildsystemDirectory.Push(
+    originSnapshot.Position->BuildSystemDirectory);
   pos->ExecutionListFile =
-      this->ExecutionListFiles.Push(
-        originSnapshot.Position->ExecutionListFile);
+    this->ExecutionListFiles.Push(originSnapshot.Position->ExecutionListFile);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
   pos->Policies = originSnapshot.Position->Policies;
   pos->PolicyRoot = originSnapshot.Position->Policies;
@@ -870,8 +793,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
   assert(pos->Policies.IsValid());
   assert(pos->PolicyRoot.IsValid());
 
-  cmLinkedTree<cmDefinitions>::iterator origin =
-      originSnapshot.Position->Vars;
+  cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
   pos->Parent = origin;
   pos->Root = origin;
   pos->Vars = this->VarTree.Push(origin);
@@ -884,119 +806,92 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
   return snapshot;
 }
 
-cmState::Snapshot
-cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
-                                    std::string const& entryPointCommand,
-                                    long entryPointLine,
-                                    std::string const& fileName)
+cmState::Snapshot cmState::CreateFunctionCallSnapshot(
+  cmState::Snapshot originSnapshot, std::string const& fileName)
 {
-  PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
-                                             *originSnapshot.Position);
+  PositionType pos =
+    this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
   pos->ScopeParent = originSnapshot.Position;
-  pos->EntryPointLine = entryPointLine;
-  pos->EntryPointCommand = entryPointCommand;
   pos->SnapshotType = FunctionCallType;
   pos->Keep = false;
   pos->ExecutionListFile = this->ExecutionListFiles.Push(
-        originSnapshot.Position->ExecutionListFile, fileName);
+    originSnapshot.Position->ExecutionListFile, fileName);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
   pos->PolicyScope = originSnapshot.Position->Policies;
   assert(originSnapshot.Position->Vars.IsValid());
-  cmLinkedTree<cmDefinitions>::iterator origin =
-      originSnapshot.Position->Vars;
+  cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
   pos->Parent = origin;
   pos->Vars = this->VarTree.Push(origin);
   return cmState::Snapshot(this, pos);
 }
 
-
-cmState::Snapshot
-cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
-                                    std::string const& entryPointCommand,
-                                    long entryPointLine,
-                                    std::string const& fileName)
+cmState::Snapshot cmState::CreateMacroCallSnapshot(
+  cmState::Snapshot originSnapshot, std::string const& fileName)
 {
-  PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
-                                             *originSnapshot.Position);
-  pos->EntryPointLine = entryPointLine;
-  pos->EntryPointCommand = entryPointCommand;
+  PositionType pos =
+    this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
   pos->SnapshotType = MacroCallType;
   pos->Keep = false;
   pos->ExecutionListFile = this->ExecutionListFiles.Push(
-        originSnapshot.Position->ExecutionListFile, fileName);
+    originSnapshot.Position->ExecutionListFile, fileName);
   assert(originSnapshot.Position->Vars.IsValid());
   pos->BuildSystemDirectory->DirectoryEnd = pos;
   pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
-cmState::Snapshot
-cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot,
-                                 const std::string& entryPointCommand,
-                                 long entryPointLine,
-                                 const std::string& fileName)
+cmState::Snapshot cmState::CreateIncludeFileSnapshot(
+  cmState::Snapshot originSnapshot, const std::string& fileName)
 {
-  PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
-                                             *originSnapshot.Position);
-  pos->EntryPointLine = entryPointLine;
-  pos->EntryPointCommand = entryPointCommand;
-  pos->SnapshotType = CallStackType;
+  PositionType pos =
+    this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
+  pos->SnapshotType = IncludeFileType;
   pos->Keep = true;
   pos->ExecutionListFile = this->ExecutionListFiles.Push(
-        originSnapshot.Position->ExecutionListFile, fileName);
+    originSnapshot.Position->ExecutionListFile, fileName);
   assert(originSnapshot.Position->Vars.IsValid());
   pos->BuildSystemDirectory->DirectoryEnd = pos;
   pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
-cmState::Snapshot
-cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot,
-                                     std::string const& entryPointCommand,
-                                     long entryPointLine)
+cmState::Snapshot cmState::CreateVariableScopeSnapshot(
+  cmState::Snapshot originSnapshot)
 {
-  PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
-                                             *originSnapshot.Position);
+  PositionType pos =
+    this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
   pos->ScopeParent = originSnapshot.Position;
-  pos->EntryPointLine = entryPointLine;
-  pos->EntryPointCommand = entryPointCommand;
   pos->SnapshotType = VariableScopeType;
   pos->Keep = false;
   pos->PolicyScope = originSnapshot.Position->Policies;
   assert(originSnapshot.Position->Vars.IsValid());
 
-  cmLinkedTree<cmDefinitions>::iterator origin =
-      originSnapshot.Position->Vars;
+  cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
   pos->Parent = origin;
   pos->Vars = this->VarTree.Push(origin);
   assert(pos->Vars.IsValid());
   return cmState::Snapshot(this, pos);
 }
 
-cmState::Snapshot
-cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
-                                      const std::string& entryPointCommand,
-                                      long entryPointLine,
-                                      const std::string& fileName)
+cmState::Snapshot cmState::CreateInlineListFileSnapshot(
+  cmState::Snapshot originSnapshot, const std::string& fileName)
 {
-  PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
-                                             *originSnapshot.Position);
-  pos->EntryPointLine = entryPointLine;
-  pos->EntryPointCommand = entryPointCommand;
+  PositionType pos =
+    this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
   pos->SnapshotType = InlineListFileType;
   pos->Keep = true;
   pos->ExecutionListFile = this->ExecutionListFiles.Push(
-        originSnapshot.Position->ExecutionListFile, fileName);
+    originSnapshot.Position->ExecutionListFile, fileName);
   pos->BuildSystemDirectory->DirectoryEnd = pos;
   pos->PolicyScope = originSnapshot.Position->Policies;
   return cmState::Snapshot(this, pos);
 }
 
-cmState::Snapshot
-cmState::CreatePolicyScopeSnapshot(cmState::Snapshot originSnapshot)
+cmState::Snapshot cmState::CreatePolicyScopeSnapshot(
+  cmState::Snapshot originSnapshot)
 {
-  PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
-                                             *originSnapshot.Position);
+  PositionType pos =
+    this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position);
   pos->SnapshotType = PolicyScopeType;
   pos->Keep = false;
   pos->BuildSystemDirectory->DirectoryEnd = pos;
@@ -1010,27 +905,24 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot)
   PositionType prevPos = pos;
   ++prevPos;
   prevPos->IncludeDirectoryPosition =
-      prevPos->BuildSystemDirectory->IncludeDirectories.size();
+    prevPos->BuildSystemDirectory->IncludeDirectories.size();
   prevPos->CompileDefinitionsPosition =
-      prevPos->BuildSystemDirectory->CompileDefinitions.size();
+    prevPos->BuildSystemDirectory->CompileDefinitions.size();
   prevPos->CompileOptionsPosition =
-      prevPos->BuildSystemDirectory->CompileOptions.size();
+    prevPos->BuildSystemDirectory->CompileOptions.size();
   prevPos->BuildSystemDirectory->DirectoryEnd = prevPos;
 
-  if (!pos->Keep && this->SnapshotData.IsLast(pos))
-    {
-    if (pos->Vars != prevPos->Vars)
-      {
+  if (!pos->Keep && this->SnapshotData.IsLast(pos)) {
+    if (pos->Vars != prevPos->Vars) {
       assert(this->VarTree.IsLast(pos->Vars));
       this->VarTree.Pop(pos->Vars);
-      }
-    if (pos->ExecutionListFile != prevPos->ExecutionListFile)
-      {
+    }
+    if (pos->ExecutionListFile != prevPos->ExecutionListFile) {
       assert(this->ExecutionListFiles.IsLast(pos->ExecutionListFile));
       this->ExecutionListFiles.Pop(pos->ExecutionListFile);
-      }
-    this->SnapshotData.Pop(pos);
     }
+    this->SnapshotData.Pop(pos);
+  }
 
   return Snapshot(this, prevPos);
 }
@@ -1047,10 +939,9 @@ std::vector<cmState::Snapshot> cmState::Snapshot::GetChildren()
 }
 
 cmState::Snapshot::Snapshot(cmState* state, PositionType position)
-  : State(state),
-  Position(position)
+  : State(state)
+  , Position(position)
 {
-
 }
 
 cmState::SnapshotType cmState::Snapshot::GetType() const
@@ -1071,11 +962,10 @@ void cmState::Directory::SetCurrentSource(std::string const& dir)
   loc = cmSystemTools::CollapseFullPath(loc);
 
   cmSystemTools::SplitPath(
-      loc,
-      this->DirectoryState->CurrentSourceDirectoryComponents);
+    loc, this->DirectoryState->CurrentSourceDirectoryComponents);
   this->ComputeRelativePathTopSource();
 
-  this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc.c_str());
+  this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc);
 }
 
 const char* cmState::Directory::GetCurrentBinary() const
@@ -1091,16 +981,10 @@ void cmState::Directory::SetCurrentBinary(std::string const& dir)
   loc = cmSystemTools::CollapseFullPath(loc);
 
   cmSystemTools::SplitPath(
-      loc,
-      this->DirectoryState->CurrentBinaryDirectoryComponents);
+    loc, this->DirectoryState->CurrentBinaryDirectoryComponents);
   this->ComputeRelativePathTopBinary();
 
-  this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
-}
-
-void cmState::Snapshot::Keep()
-{
-  this->Position->Keep = true;
+  this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc);
 }
 
 void cmState::Snapshot::SetListFile(const std::string& listfile)
@@ -1145,36 +1029,24 @@ std::string cmState::Snapshot::GetExecutionListFile() const
   return *this->Position->ExecutionListFile;
 }
 
-std::string cmState::Snapshot::GetEntryPointCommand() const
-{
-  return this->Position->EntryPointCommand;
-}
-
-long cmState::Snapshot::GetEntryPointLine() const
-{
-  return this->Position->EntryPointLine;
-}
-
 bool cmState::Snapshot::IsValid() const
 {
   return this->State && this->Position.IsValid()
-      ? this->Position != this->State->SnapshotData.Root()
-      : false;
+    ? this->Position != this->State->SnapshotData.Root()
+    : false;
 }
 
 cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const
 {
   Snapshot snapshot;
-  if (!this->State || this->Position == this->State->SnapshotData.Root())
-    {
+  if (!this->State || this->Position == this->State->SnapshotData.Root()) {
     return snapshot;
-    }
+  }
   PositionType parentPos = this->Position->DirectoryParent;
-  if (parentPos != this->State->SnapshotData.Root())
-    {
-    snapshot = Snapshot(this->State,
-                        parentPos->BuildSystemDirectory->DirectoryEnd);
-    }
+  if (parentPos != this->State->SnapshotData.Root()) {
+    snapshot =
+      Snapshot(this->State, parentPos->BuildSystemDirectory->DirectoryEnd);
+  }
 
   return snapshot;
 }
@@ -1187,47 +1059,55 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
   Snapshot snapshot;
   PositionType parentPos = this->Position;
   while (parentPos->SnapshotType == cmState::PolicyScopeType ||
-         parentPos->SnapshotType == cmState::VariableScopeType)
-    {
+         parentPos->SnapshotType == cmState::VariableScopeType) {
     ++parentPos;
-    }
-  if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType
-      || parentPos->SnapshotType == cmState::BaseType)
-    {
+  }
+  if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType ||
+      parentPos->SnapshotType == cmState::BaseType) {
     return snapshot;
-    }
+  }
 
   ++parentPos;
   while (parentPos->SnapshotType == cmState::PolicyScopeType ||
-         parentPos->SnapshotType == cmState::VariableScopeType)
-    {
+         parentPos->SnapshotType == cmState::VariableScopeType) {
     ++parentPos;
-    }
+  }
 
-  if (parentPos == this->State->SnapshotData.Root())
-    {
+  if (parentPos == this->State->SnapshotData.Root()) {
     return snapshot;
-    }
+  }
 
   snapshot = Snapshot(this->State, parentPos);
   return snapshot;
 }
 
+cmState::Snapshot cmState::Snapshot::GetCallStackBottom() const
+{
+  assert(this->State);
+  assert(this->Position != this->State->SnapshotData.Root());
+
+  PositionType pos = this->Position;
+  while (pos->SnapshotType != cmState::BaseType &&
+         pos->SnapshotType != cmState::BuildsystemDirectoryType &&
+         pos != this->State->SnapshotData.Root()) {
+    ++pos;
+  }
+  return Snapshot(this->State, pos);
+}
+
 void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak)
 {
   PositionType pos = this->Position;
-  pos->Policies =
-    this->State->PolicyStack.Push(pos->Policies,
-                                  PolicyStackEntry(entry, weak));
+  pos->Policies = this->State->PolicyStack.Push(pos->Policies,
+                                                PolicyStackEntry(entry, weak));
 }
 
 bool cmState::Snapshot::PopPolicy()
 {
   PositionType pos = this->Position;
-  if (pos->Policies == pos->PolicyScope)
-    {
+  if (pos->Policies == pos->PolicyScope) {
     return false;
-    }
+  }
   pos->Policies = this->State->PolicyStack.Pop(pos->Policies);
   return true;
 }
@@ -1242,51 +1122,45 @@ void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id,
 {
   // Update the policy stack from the top to the top-most strong entry.
   bool previous_was_weak = true;
-  for(cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies;
-      previous_was_weak && psi != this->Position->PolicyRoot; ++psi)
-    {
+  for (cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies;
+       previous_was_weak && psi != this->Position->PolicyRoot; ++psi) {
     psi->Set(id, status);
     previous_was_weak = psi->Weak;
-    }
+  }
 }
 
-cmPolicies::PolicyStatus
-cmState::Snapshot::GetPolicy(cmPolicies::PolicyID id) const
+cmPolicies::PolicyStatus cmState::Snapshot::GetPolicy(
+  cmPolicies::PolicyID id) const
 {
   cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
 
-  if(status == cmPolicies::REQUIRED_ALWAYS ||
-     status == cmPolicies::REQUIRED_IF_USED)
-    {
+  if (status == cmPolicies::REQUIRED_ALWAYS ||
+      status == cmPolicies::REQUIRED_IF_USED) {
     return status;
-    }
+  }
 
   cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir =
-      this->Position->BuildSystemDirectory;
+    this->Position->BuildSystemDirectory;
 
-  while (true)
-    {
+  while (true) {
     assert(dir.IsValid());
     cmLinkedTree<PolicyStackEntry>::iterator leaf =
-        dir->DirectoryEnd->Policies;
+      dir->DirectoryEnd->Policies;
     cmLinkedTree<PolicyStackEntry>::iterator root =
-        dir->DirectoryEnd->PolicyRoot;
-    for( ; leaf != root; ++leaf)
-      {
-      if(leaf->IsDefined(id))
-        {
+      dir->DirectoryEnd->PolicyRoot;
+    for (; leaf != root; ++leaf) {
+      if (leaf->IsDefined(id)) {
         status = leaf->Get(id);
         return status;
-        }
       }
+    }
     cmState::PositionType e = dir->DirectoryEnd;
     cmState::PositionType p = e->DirectoryParent;
-    if (p == this->State->SnapshotData.Root())
-      {
+    if (p == this->State->SnapshotData.Root()) {
       break;
-      }
-    dir = p->BuildSystemDirectory;
     }
+    dir = p->BuildSystemDirectory;
+  }
   return status;
 }
 
@@ -1298,8 +1172,7 @@ bool cmState::Snapshot::HasDefinedPolicyCMP0011()
 const char* cmState::Snapshot::GetDefinition(std::string const& name) const
 {
   assert(this->Position->Vars.IsValid());
-  return cmDefinitions::Get(name, this->Position->Vars,
-                    this->Position->Root);
+  return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root);
 }
 
 bool cmState::Snapshot::IsInitialized(std::string const& name) const
@@ -1332,29 +1205,23 @@ std::vector<std::string> cmState::Snapshot::ClosureKeys() const
 
 bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef)
 {
-  if(this->Position->ScopeParent == this->Position->DirectoryParent)
-    {
+  if (this->Position->ScopeParent == this->Position->DirectoryParent) {
     Snapshot parentDir = this->GetBuildsystemDirectoryParent();
-    if(!parentDir.IsValid())
-      {
+    if (!parentDir.IsValid()) {
       return false;
-      }
+    }
     // Update the definition in the parent directory top scope.  This
     // directory's scope was initialized by the closure of the parent
     // scope, so we do not need to localize the definition first.
-    if (varDef)
-      {
+    if (varDef) {
       parentDir.SetDefinition(var, varDef);
-      }
-    else
-      {
+    } else {
       parentDir.RemoveDefinition(var);
-      }
-    return true;
     }
+    return true;
+  }
   // First localize the definition in the current scope.
-  cmDefinitions::Raise(var, this->Position->Vars,
-                       this->Position->Root);
+  cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root);
 
   // Now update the definition in the parent scope.
   this->Position->Parent->Set(var, varDef);
@@ -1363,31 +1230,27 @@ bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef)
 
 static const std::string cmPropertySentinal = std::string();
 
-template<typename T, typename U, typename V>
-void InitializeContentFromParent(T& parentContent,
-                          T& thisContent,
-                          U& parentBacktraces,
-                          U& thisBacktraces,
-                          V& contentEndPosition)
+template <typename T, typename U, typename V>
+void InitializeContentFromParent(T& parentContent, T& thisContent,
+                                 U& parentBacktraces, U& thisBacktraces,
+                                 V& contentEndPosition)
 {
-  std::vector<std::string>::const_iterator parentBegin =
-      parentContent.begin();
-  std::vector<std::string>::const_iterator parentEnd =
-      parentContent.end();
+  std::vector<std::string>::const_iterator parentBegin = parentContent.begin();
+  std::vector<std::string>::const_iterator parentEnd = parentContent.end();
 
   std::vector<std::string>::const_reverse_iterator parentRbegin =
-      cmMakeReverseIterator(parentEnd);
+    cmMakeReverseIterator(parentEnd);
   std::vector<std::string>::const_reverse_iterator parentRend =
-      parentContent.rend();
+    parentContent.rend();
   parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal);
   std::vector<std::string>::const_iterator parentIt = parentRbegin.base();
 
   thisContent = std::vector<std::string>(parentIt, parentEnd);
 
   std::vector<cmListFileBacktrace>::const_iterator btIt =
-      parentBacktraces.begin() + std::distance(parentBegin, parentIt);
+    parentBacktraces.begin() + std::distance(parentBegin, parentIt);
   std::vector<cmListFileBacktrace>::const_iterator btEnd =
-      parentBacktraces.end();
+    parentBacktraces.end();
 
   thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd);
 
@@ -1396,64 +1259,64 @@ void InitializeContentFromParent(T& parentContent,
 
 void cmState::Snapshot::SetDefaultDefinitions()
 {
-  /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set.
-    With CMake must separate between target and host platform. In most cases
-    the tests for WIN32, UNIX and APPLE will be for the target system, so an
-    additional set of variables for the host system is required ->
-    CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE.
-    WIN32, UNIX and APPLE are now set in the platform files in
-    Modules/Platforms/.
-    To keep cmake scripts (-P) and custom language and compiler modules
-    working, these variables are still also set here in this place, but they
-    will be reset in CMakeSystemSpecificInformation.cmake before the platform
-    files are executed. */
-  #if defined(_WIN32)
+/* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set.
+  With CMake must separate between target and host platform. In most cases
+  the tests for WIN32, UNIX and APPLE will be for the target system, so an
+  additional set of variables for the host system is required ->
+  CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE.
+  WIN32, UNIX and APPLE are now set in the platform files in
+  Modules/Platforms/.
+  To keep cmake scripts (-P) and custom language and compiler modules
+  working, these variables are still also set here in this place, but they
+  will be reset in CMakeSystemSpecificInformation.cmake before the platform
+  files are executed. */
+#if defined(_WIN32)
+  this->SetDefinition("WIN32", "1");
+  this->SetDefinition("CMAKE_HOST_WIN32", "1");
+#else
+  this->SetDefinition("UNIX", "1");
+  this->SetDefinition("CMAKE_HOST_UNIX", "1");
+#endif
+#if defined(__CYGWIN__)
+  if (cmSystemTools::IsOn(
+        cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32"))) {
     this->SetDefinition("WIN32", "1");
     this->SetDefinition("CMAKE_HOST_WIN32", "1");
-  #else
-    this->SetDefinition("UNIX", "1");
-    this->SetDefinition("CMAKE_HOST_UNIX", "1");
-  #endif
-  #if defined(__CYGWIN__)
-    if(cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32")))
-      {
-      this->SetDefinition("WIN32", "1");
-      this->SetDefinition("CMAKE_HOST_WIN32", "1");
-      }
-  #endif
-  #if defined(__APPLE__)
-    this->SetDefinition("APPLE", "1");
-    this->SetDefinition("CMAKE_HOST_APPLE", "1");
-  #endif
-
-    char temp[1024];
-    sprintf(temp, "%d", cmVersion::GetMinorVersion());
-    this->SetDefinition("CMAKE_MINOR_VERSION", temp);
-    sprintf(temp, "%d", cmVersion::GetMajorVersion());
-    this->SetDefinition("CMAKE_MAJOR_VERSION", temp);
-    sprintf(temp, "%d", cmVersion::GetPatchVersion());
-    this->SetDefinition("CMAKE_PATCH_VERSION", temp);
-    sprintf(temp, "%d", cmVersion::GetTweakVersion());
-    this->SetDefinition("CMAKE_TWEAK_VERSION", temp);
-    this->SetDefinition("CMAKE_VERSION",
-                                      cmVersion::GetCMakeVersion());
-
-    this->SetDefinition("CMAKE_FILES_DIRECTORY",
-                        cmake::GetCMakeFilesDirectory());
+  }
+#endif
+#if defined(__APPLE__)
+  this->SetDefinition("APPLE", "1");
+  this->SetDefinition("CMAKE_HOST_APPLE", "1");
+#endif
+#if defined(__sun__)
+  this->SetDefinition("CMAKE_HOST_SOLARIS", "1");
+#endif
+
+  char temp[1024];
+  sprintf(temp, "%d", cmVersion::GetMinorVersion());
+  this->SetDefinition("CMAKE_MINOR_VERSION", temp);
+  sprintf(temp, "%d", cmVersion::GetMajorVersion());
+  this->SetDefinition("CMAKE_MAJOR_VERSION", temp);
+  sprintf(temp, "%d", cmVersion::GetPatchVersion());
+  this->SetDefinition("CMAKE_PATCH_VERSION", temp);
+  sprintf(temp, "%d", cmVersion::GetTweakVersion());
+  this->SetDefinition("CMAKE_TWEAK_VERSION", temp);
+  this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion());
+
+  this->SetDefinition("CMAKE_FILES_DIRECTORY",
+                      cmake::GetCMakeFilesDirectory());
 
   // Setup the default include file regular expression (match everything).
-  this->Position->BuildSystemDirectory
-      ->Properties.SetProperty("INCLUDE_REGULAR_EXPRESSION", "^.*$");
+  this->Position->BuildSystemDirectory->Properties.SetProperty(
+    "INCLUDE_REGULAR_EXPRESSION", "^.*$");
 }
 
 void cmState::Snapshot::SetDirectoryDefinitions()
 {
-  this->SetDefinition("CMAKE_SOURCE_DIR",
-                      this->State->GetSourceDirectory());
+  this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory());
   this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR",
                       this->State->GetSourceDirectory());
-  this->SetDefinition("CMAKE_BINARY_DIR",
-                      this->State->GetBinaryDirectory());
+  this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory());
   this->SetDefinition("CMAKE_CURRENT_BINARY_DIR",
                       this->State->GetBinaryDirectory());
 }
@@ -1465,25 +1328,28 @@ void cmState::Snapshot::InitializeFromParent()
   assert(parent->Vars.IsValid());
 
   *this->Position->Vars =
-      cmDefinitions::MakeClosure(parent->Vars, parent->Root);
-
-  InitializeContentFromParent(parent->BuildSystemDirectory->IncludeDirectories,
-              this->Position->BuildSystemDirectory->IncludeDirectories,
-              parent->BuildSystemDirectory->IncludeDirectoryBacktraces,
-              this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces,
-              this->Position->IncludeDirectoryPosition);
-
-  InitializeContentFromParent(parent->BuildSystemDirectory->CompileDefinitions,
-            this->Position->BuildSystemDirectory->CompileDefinitions,
-            parent->BuildSystemDirectory->CompileDefinitionsBacktraces,
-            this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces,
-            this->Position->CompileDefinitionsPosition);
-
-  InitializeContentFromParent(parent->BuildSystemDirectory->CompileOptions,
-                this->Position->BuildSystemDirectory->CompileOptions,
-                parent->BuildSystemDirectory->CompileOptionsBacktraces,
-                this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
-                this->Position->CompileOptionsPosition);
+    cmDefinitions::MakeClosure(parent->Vars, parent->Root);
+
+  InitializeContentFromParent(
+    parent->BuildSystemDirectory->IncludeDirectories,
+    this->Position->BuildSystemDirectory->IncludeDirectories,
+    parent->BuildSystemDirectory->IncludeDirectoryBacktraces,
+    this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces,
+    this->Position->IncludeDirectoryPosition);
+
+  InitializeContentFromParent(
+    parent->BuildSystemDirectory->CompileDefinitions,
+    this->Position->BuildSystemDirectory->CompileDefinitions,
+    parent->BuildSystemDirectory->CompileDefinitionsBacktraces,
+    this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces,
+    this->Position->CompileDefinitionsPosition);
+
+  InitializeContentFromParent(
+    parent->BuildSystemDirectory->CompileOptions,
+    this->Position->BuildSystemDirectory->CompileOptions,
+    parent->BuildSystemDirectory->CompileOptionsBacktraces,
+    this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
+    this->Position->CompileOptionsPosition);
 }
 
 cmState* cmState::Snapshot::GetState() const
@@ -1511,50 +1377,47 @@ void cmState::Snapshot::InitializeFromParent_ForSubdirsCommand()
   std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR");
   std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR");
   this->InitializeFromParent();
-  this->SetDefinition("CMAKE_SOURCE_DIR",
-                      this->State->GetSourceDirectory());
-  this->SetDefinition("CMAKE_BINARY_DIR",
-                      this->State->GetBinaryDirectory());
+  this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory());
+  this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory());
 
-  this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir.c_str());
-  this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir.c_str());
+  this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir);
+  this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir);
 }
 
 cmState::Directory::Directory(
-    cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
-    const cmState::Snapshot& snapshot)
-  : DirectoryState(iter), Snapshot_(snapshot)
+  cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
+  const cmState::Snapshot& snapshot)
+  : DirectoryState(iter)
+  , Snapshot_(snapshot)
 {
-
 }
 
 template <typename T, typename U>
 cmStringRange GetPropertyContent(T const& content, U contentEndPosition)
 {
   std::vector<std::string>::const_iterator end =
-      content.begin() + contentEndPosition;
+    content.begin() + contentEndPosition;
 
   std::vector<std::string>::const_reverse_iterator rbegin =
-      cmMakeReverseIterator(end);
+    cmMakeReverseIterator(end);
   rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
 
   return cmMakeRange(rbegin.base(), end);
 }
 
 template <typename T, typename U, typename V>
-cmBacktraceRange GetPropertyBacktraces(T const& content,
-                                    U const& backtraces,
-                                    V contentEndPosition)
+cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces,
+                                       V contentEndPosition)
 {
   std::vector<std::string>::const_iterator entryEnd =
-      content.begin() + contentEndPosition;
+    content.begin() + contentEndPosition;
 
   std::vector<std::string>::const_reverse_iterator rbegin =
-      cmMakeReverseIterator(entryEnd);
+    cmMakeReverseIterator(entryEnd);
   rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
 
   std::vector<cmListFileBacktrace>::const_iterator it =
-      backtraces.begin() + std::distance(content.begin(), rbegin.base());
+    backtraces.begin() + std::distance(content.begin(), rbegin.base());
 
   std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end();
   return cmMakeRange(it, end);
@@ -1562,12 +1425,11 @@ cmBacktraceRange GetPropertyBacktraces(T const& content,
 
 template <typename T, typename U, typename V>
 void AppendEntry(T& content, U& backtraces, V& endContentPosition,
-    const std::string& value, const cmListFileBacktrace& lfbt)
+                 const std::string& value, const cmListFileBacktrace& lfbt)
 {
-  if (value.empty())
-    {
+  if (value.empty()) {
     return;
-    }
+  }
 
   assert(endContentPosition == content.size());
 
@@ -1603,65 +1465,64 @@ void ClearContent(T& content, U& backtraces, V& endContentPosition)
   endContentPosition = content.size();
 }
 
-cmStringRange
-cmState::Directory::GetIncludeDirectoriesEntries() const
+cmStringRange cmState::Directory::GetIncludeDirectoriesEntries() const
 {
-  return GetPropertyContent(this->DirectoryState->IncludeDirectories,
-                       this->Snapshot_.Position->IncludeDirectoryPosition);
+  return GetPropertyContent(
+    this->DirectoryState->IncludeDirectories,
+    this->Snapshot_.Position->IncludeDirectoryPosition);
 }
 
-cmBacktraceRange
-cmState::Directory::GetIncludeDirectoriesEntryBacktraces() const
+cmBacktraceRange cmState::Directory::GetIncludeDirectoriesEntryBacktraces()
+  const
 {
-  return GetPropertyBacktraces(this->DirectoryState->IncludeDirectories,
-                       this->DirectoryState->IncludeDirectoryBacktraces,
-                       this->Snapshot_.Position->IncludeDirectoryPosition);
+  return GetPropertyBacktraces(
+    this->DirectoryState->IncludeDirectories,
+    this->DirectoryState->IncludeDirectoryBacktraces,
+    this->Snapshot_.Position->IncludeDirectoryPosition);
 }
 
 void cmState::Directory::AppendIncludeDirectoriesEntry(
-    const std::string& vec, const cmListFileBacktrace& lfbt)
+  const std::string& vec, const cmListFileBacktrace& lfbt)
 {
   AppendEntry(this->DirectoryState->IncludeDirectories,
               this->DirectoryState->IncludeDirectoryBacktraces,
-              this->Snapshot_.Position->IncludeDirectoryPosition,
-              vec, lfbt);
+              this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt);
 }
 
 void cmState::Directory::PrependIncludeDirectoriesEntry(
-    const std::string& vec, const cmListFileBacktrace& lfbt)
+  const std::string& vec, const cmListFileBacktrace& lfbt)
 {
   std::vector<std::string>::iterator entryEnd =
-      this->DirectoryState->IncludeDirectories.begin()
-      + this->Snapshot_.Position->IncludeDirectoryPosition;
+    this->DirectoryState->IncludeDirectories.begin() +
+    this->Snapshot_.Position->IncludeDirectoryPosition;
 
   std::vector<std::string>::reverse_iterator rend =
-      this->DirectoryState->IncludeDirectories.rend();
+    this->DirectoryState->IncludeDirectories.rend();
   std::vector<std::string>::reverse_iterator rbegin =
-      cmMakeReverseIterator(entryEnd);
+    cmMakeReverseIterator(entryEnd);
   rbegin = std::find(rbegin, rend, cmPropertySentinal);
 
   std::vector<std::string>::iterator entryIt = rbegin.base();
   std::vector<std::string>::iterator entryBegin =
-      this->DirectoryState->IncludeDirectories.begin();
+    this->DirectoryState->IncludeDirectories.begin();
 
   std::vector<cmListFileBacktrace>::iterator btIt =
-      this->DirectoryState->IncludeDirectoryBacktraces.begin()
-      + std::distance(entryBegin, entryIt);
+    this->DirectoryState->IncludeDirectoryBacktraces.begin() +
+    std::distance(entryBegin, entryIt);
 
   this->DirectoryState->IncludeDirectories.insert(entryIt, vec);
   this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt);
 
   this->Snapshot_.Position->IncludeDirectoryPosition =
-      this->DirectoryState->IncludeDirectories.size();
+    this->DirectoryState->IncludeDirectories.size();
 }
 
-void cmState::Directory::SetIncludeDirectories(
-    const std::string& vec, const cmListFileBacktrace& lfbt)
+void cmState::Directory::SetIncludeDirectories(const std::string& vec,
+                                               const cmListFileBacktrace& lfbt)
 {
   SetContent(this->DirectoryState->IncludeDirectories,
              this->DirectoryState->IncludeDirectoryBacktraces,
-             this->Snapshot_.Position->IncludeDirectoryPosition,
-             vec, lfbt);
+             this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt);
 }
 
 void cmState::Directory::ClearIncludeDirectories()
@@ -1673,25 +1534,26 @@ void cmState::Directory::ClearIncludeDirectories()
 
 cmStringRange cmState::Directory::GetCompileDefinitionsEntries() const
 {
-  return GetPropertyContent(this->DirectoryState->CompileDefinitions,
-                     this->Snapshot_.Position->CompileDefinitionsPosition);
+  return GetPropertyContent(
+    this->DirectoryState->CompileDefinitions,
+    this->Snapshot_.Position->CompileDefinitionsPosition);
 }
 
-cmBacktraceRange
-cmState::Directory::GetCompileDefinitionsEntryBacktraces() const
+cmBacktraceRange cmState::Directory::GetCompileDefinitionsEntryBacktraces()
+  const
 {
-  return GetPropertyBacktraces(this->DirectoryState->CompileDefinitions,
-                     this->DirectoryState->CompileDefinitionsBacktraces,
-                     this->Snapshot_.Position->CompileDefinitionsPosition);
+  return GetPropertyBacktraces(
+    this->DirectoryState->CompileDefinitions,
+    this->DirectoryState->CompileDefinitionsBacktraces,
+    this->Snapshot_.Position->CompileDefinitionsPosition);
 }
 
-void cmState::Directory::AppendCompileDefinitionsEntry(const std::string& vec,
-                                               const cmListFileBacktrace& lfbt)
+void cmState::Directory::AppendCompileDefinitionsEntry(
+  const std::string& vec, const cmListFileBacktrace& lfbt)
 {
   AppendEntry(this->DirectoryState->CompileDefinitions,
               this->DirectoryState->CompileDefinitionsBacktraces,
-              this->Snapshot_.Position->CompileDefinitionsPosition,
-              vec, lfbt);
+              this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt);
 }
 
 void cmState::Directory::SetCompileDefinitions(const std::string& vec,
@@ -1699,8 +1561,7 @@ void cmState::Directory::SetCompileDefinitions(const std::string& vec,
 {
   SetContent(this->DirectoryState->CompileDefinitions,
              this->DirectoryState->CompileDefinitionsBacktraces,
-             this->Snapshot_.Position->CompileDefinitionsPosition,
-             vec, lfbt);
+             this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt);
 }
 
 void cmState::Directory::ClearCompileDefinitions()
@@ -1713,24 +1574,23 @@ void cmState::Directory::ClearCompileDefinitions()
 cmStringRange cmState::Directory::GetCompileOptionsEntries() const
 {
   return GetPropertyContent(this->DirectoryState->CompileOptions,
-                         this->Snapshot_.Position->CompileOptionsPosition);
+                            this->Snapshot_.Position->CompileOptionsPosition);
 }
 
 cmBacktraceRange cmState::Directory::GetCompileOptionsEntryBacktraces() const
 {
-  return GetPropertyBacktraces(this->DirectoryState->CompileOptions,
-                         this->DirectoryState->CompileOptionsBacktraces,
-                         this->Snapshot_.Position->CompileOptionsPosition);
+  return GetPropertyBacktraces(
+    this->DirectoryState->CompileOptions,
+    this->DirectoryState->CompileOptionsBacktraces,
+    this->Snapshot_.Position->CompileOptionsPosition);
 }
 
-void
-cmState::Directory::AppendCompileOptionsEntry(const std::string& vec,
-                                              const cmListFileBacktrace& lfbt)
+void cmState::Directory::AppendCompileOptionsEntry(
+  const std::string& vec, const cmListFileBacktrace& lfbt)
 {
   AppendEntry(this->DirectoryState->CompileOptions,
               this->DirectoryState->CompileOptionsBacktraces,
-              this->Snapshot_.Position->CompileOptionsPosition,
-              vec, lfbt);
+              this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt);
 }
 
 void cmState::Directory::SetCompileOptions(const std::string& vec,
@@ -1738,8 +1598,7 @@ void cmState::Directory::SetCompileOptions(const std::string& vec,
 {
   SetContent(this->DirectoryState->CompileOptions,
              this->DirectoryState->CompileOptionsBacktraces,
-             this->Snapshot_.Position->CompileOptionsPosition,
-             vec, lfbt);
+             this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt);
 }
 
 void cmState::Directory::ClearCompileOptions()
@@ -1750,149 +1609,121 @@ void cmState::Directory::ClearCompileOptions()
 }
 
 bool cmState::Snapshot::StrictWeakOrder::operator()(
-    const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const
+  const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const
 {
   return lhs.Position.StrictWeakOrdered(rhs.Position);
 }
 
 void cmState::Directory::SetProperty(const std::string& prop,
                                      const char* value,
-                                     cmListFileBacktrace lfbt)
+                                     cmListFileBacktrace const& lfbt)
 {
-  if (prop == "INCLUDE_DIRECTORIES")
-    {
-    if (!value)
-      {
+  if (prop == "INCLUDE_DIRECTORIES") {
+    if (!value) {
       this->ClearIncludeDirectories();
       return;
-      }
+    }
     this->SetIncludeDirectories(value, lfbt);
     return;
-    }
-  if (prop == "COMPILE_OPTIONS")
-    {
-    if (!value)
-      {
+  }
+  if (prop == "COMPILE_OPTIONS") {
+    if (!value) {
       this->ClearCompileOptions();
       return;
-      }
+    }
     this->SetCompileOptions(value, lfbt);
     return;
-    }
-  if (prop == "COMPILE_DEFINITIONS")
-    {
-    if (!value)
-      {
+  }
+  if (prop == "COMPILE_DEFINITIONS") {
+    if (!value) {
       this->ClearCompileDefinitions();
       return;
-      }
+    }
     this->SetCompileDefinitions(value, lfbt);
     return;
-    }
+  }
 
   this->DirectoryState->Properties.SetProperty(prop, value);
 }
 
 void cmState::Directory::AppendProperty(const std::string& prop,
-                                        const char* value,
-                                        bool asString,
-                                        cmListFileBacktrace lfbt)
+                                        const char* value, bool asString,
+                                        cmListFileBacktrace const& lfbt)
 {
-  if (prop == "INCLUDE_DIRECTORIES")
-    {
+  if (prop == "INCLUDE_DIRECTORIES") {
     this->AppendIncludeDirectoriesEntry(value, lfbt);
     return;
-    }
-  if (prop == "COMPILE_OPTIONS")
-    {
+  }
+  if (prop == "COMPILE_OPTIONS") {
     this->AppendCompileOptionsEntry(value, lfbt);
     return;
-    }
-  if (prop == "COMPILE_DEFINITIONS")
-    {
+  }
+  if (prop == "COMPILE_DEFINITIONS") {
     this->AppendCompileDefinitionsEntry(value, lfbt);
     return;
-    }
+  }
 
   this->DirectoryState->Properties.AppendProperty(prop, value, asString);
 }
 
-const char*cmState::Directory::GetProperty(const std::string& prop) const
+const char* cmState::Directory::GetProperty(const std::string& prop) const
 {
-  const bool chain = this->Snapshot_.State->
-      IsPropertyChained(prop, cmProperty::DIRECTORY);
+  const bool chain =
+    this->Snapshot_.State->IsPropertyChained(prop, cmProperty::DIRECTORY);
   return this->GetProperty(prop, chain);
 }
 
-const char*
-cmState::Directory::GetProperty(const std::string& prop, bool chain) const
+const char* cmState::Directory::GetProperty(const std::string& prop,
+                                            bool chain) const
 {
   static std::string output;
   output = "";
-  if (prop == "PARENT_DIRECTORY")
-    {
-    cmState::Snapshot parent =
-        this->Snapshot_.GetBuildsystemDirectoryParent();
-    if(parent.IsValid())
-      {
+  if (prop == "PARENT_DIRECTORY") {
+    cmState::Snapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
+    if (parent.IsValid()) {
       return parent.GetDirectory().GetCurrentSource();
-      }
-    return "";
     }
-  else if (prop == "LISTFILE_STACK")
-    {
+    return "";
+  } else if (prop == "LISTFILE_STACK") {
     std::vector<std::string> listFiles;
     cmState::Snapshot snp = this->Snapshot_;
-    while (snp.IsValid())
-      {
+    while (snp.IsValid()) {
       listFiles.push_back(snp.GetExecutionListFile());
       snp = snp.GetCallStackParent();
-      }
+    }
     std::reverse(listFiles.begin(), listFiles.end());
     output = cmJoin(listFiles, ";");
     return output.c_str();
-    }
-  else if ( prop == "CACHE_VARIABLES" )
-    {
+  } else if (prop == "CACHE_VARIABLES") {
     output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
     return output.c_str();
-    }
-  else if (prop == "VARIABLES")
-    {
+  } else if (prop == "VARIABLES") {
     std::vector<std::string> res = this->Snapshot_.ClosureKeys();
     std::vector<std::string> cacheKeys =
-        this->Snapshot_.State->GetCacheEntryKeys();
+      this->Snapshot_.State->GetCacheEntryKeys();
     res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
     std::sort(res.begin(), res.end());
     output = cmJoin(res, ";");
     return output.c_str();
-    }
-  else if (prop == "INCLUDE_DIRECTORIES")
-    {
+  } else if (prop == "INCLUDE_DIRECTORIES") {
     output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
     return output.c_str();
-    }
-  else if (prop == "COMPILE_OPTIONS")
-    {
+  } else if (prop == "COMPILE_OPTIONS") {
     output = cmJoin(this->GetCompileOptionsEntries(), ";");
     return output.c_str();
-    }
-  else if (prop == "COMPILE_DEFINITIONS")
-    {
+  } else if (prop == "COMPILE_DEFINITIONS") {
     output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
     return output.c_str();
-    }
+  }
 
-  const char *retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
-  if (!retVal && chain)
-    {
+  const char* retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
+  if (!retVal && chain) {
     Snapshot parentSnapshot = this->Snapshot_.GetBuildsystemDirectoryParent();
-    if (parentSnapshot.IsValid())
-      {
+    if (parentSnapshot.IsValid()) {
       return parentSnapshot.GetDirectory().GetProperty(prop, chain);
-      }
-    return this->Snapshot_.State->GetGlobalProperty(prop);
     }
+    return this->Snapshot_.State->GetGlobalProperty(prop);
+  }
 
   return retVal;
 }
@@ -1906,12 +1737,11 @@ std::vector<std::string> cmState::Directory::GetPropertyKeys() const
 {
   std::vector<std::string> keys;
   keys.reserve(this->DirectoryState->Properties.size());
-  for(cmPropertyMap::const_iterator it =
-      this->DirectoryState->Properties.begin();
-      it != this->DirectoryState->Properties.end(); ++it)
-    {
+  for (cmPropertyMap::const_iterator it =
+         this->DirectoryState->Properties.begin();
+       it != this->DirectoryState->Properties.end(); ++it) {
     keys.push_back(it->first);
-    }
+  }
   return keys;
 }
 
@@ -1925,8 +1755,7 @@ bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
   return lhs.Position != rhs.Position;
 }
 
-static bool ParseEntryWithoutType(const std::string& entry,
-                                  std::string& var,
+static bool ParseEntryWithoutType(const std::string& entry, std::string& var,
                                   std::string& value)
 {
   // input line is:         key=value
@@ -1936,37 +1765,28 @@ static bool ParseEntryWithoutType(const std::string& entry,
   static cmsys::RegularExpression regQuoted(
     "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   bool flag = false;
-  if(regQuoted.find(entry))
-    {
+  if (regQuoted.find(entry)) {
     var = regQuoted.match(1);
     value = regQuoted.match(2);
     flag = true;
-    }
-  else if (reg.find(entry))
-    {
+  } else if (reg.find(entry)) {
     var = reg.match(1);
     value = reg.match(2);
     flag = true;
-    }
+  }
 
   // if value is enclosed in single quotes ('foo') then remove them
   // it is used to enclose trailing space or tab
-  if (flag &&
-      value.size() >= 2 &&
-      value[0] == '\'' &&
-      value[value.size() - 1] == '\'')
-    {
-    value = value.substr(1,
-                         value.size() - 2);
-    }
+  if (flag && value.size() >= 2 && value[0] == '\'' &&
+      value[value.size() - 1] == '\'') {
+    value = value.substr(1, value.size() - 2);
+  }
 
   return flag;
 }
 
-bool cmState::ParseCacheEntry(const std::string& entry,
-                                std::string& var,
-                                std::string& value,
-                                CacheEntryType& type)
+bool cmState::ParseCacheEntry(const std::string& entry, std::string& var,
+                              std::string& value, CacheEntryType& type)
 {
   // input line is:         key:type=value
   static cmsys::RegularExpression reg(
@@ -1975,36 +1795,28 @@ bool cmState::ParseCacheEntry(const std::string& entry,
   static cmsys::RegularExpression regQuoted(
     "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
   bool flag = false;
-  if(regQuoted.find(entry))
-    {
+  if (regQuoted.find(entry)) {
     var = regQuoted.match(1);
     type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str());
     value = regQuoted.match(3);
     flag = true;
-    }
-  else if (reg.find(entry))
-    {
+  } else if (reg.find(entry)) {
     var = reg.match(1);
     type = cmState::StringToCacheEntryType(reg.match(2).c_str());
     value = reg.match(3);
     flag = true;
-    }
+  }
 
   // if value is enclosed in single quotes ('foo') then remove them
   // it is used to enclose trailing space or tab
-  if (flag &&
-      value.size() >= 2 &&
-      value[0] == '\'' &&
-      value[value.size() - 1] == '\'')
-    {
-    value = value.substr(1,
-                         value.size() - 2);
-    }
+  if (flag && value.size() >= 2 && value[0] == '\'' &&
+      value[value.size() - 1] == '\'') {
+    value = value.substr(1, value.size() - 2);
+  }
 
-  if (!flag)
-    {
+  if (!flag) {
     return ParseEntryWithoutType(entry, var, value);
-    }
+  }
 
   return flag;
 }
diff --git a/Source/cmState.h b/Source/cmState.h
index 6717481..18c45b8 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -13,11 +13,12 @@
 #define cmState_h
 
 #include "cmStandardIncludes.h"
-#include "cmPropertyDefinitionMap.h"
-#include "cmPropertyMap.h"
-#include "cmLinkedTree.h"
+
 #include "cmAlgorithms.h"
+#include "cmLinkedTree.h"
 #include "cmPolicies.h"
+#include "cmPropertyDefinitionMap.h"
+#include "cmPropertyMap.h"
 
 class cmake;
 class cmCommand;
@@ -32,6 +33,7 @@ class cmState
   struct BuildsystemDirectoryStateType;
   typedef cmLinkedTree<SnapshotDataType>::iterator PositionType;
   friend class Snapshot;
+
 public:
   cmState();
   ~cmState();
@@ -42,7 +44,7 @@ public:
     BuildsystemDirectoryType,
     FunctionCallType,
     MacroCallType,
-    CallStackType,
+    IncludeFileType,
     InlineListFileType,
     PolicyScopeType,
     VariableScopeType
@@ -50,7 +52,8 @@ public:
 
   class Directory;
 
-  class Snapshot {
+  class Snapshot
+  {
   public:
     Snapshot(cmState* state = 0);
     Snapshot(cmState* state, PositionType position);
@@ -63,18 +66,16 @@ public:
     std::vector<std::string> ClosureKeys() const;
     bool RaiseScope(std::string const& var, const char* varDef);
 
-    void Keep();
     void SetListFile(std::string const& listfile);
 
     std::string GetExecutionListFile() const;
 
     std::vector<Snapshot> GetChildren();
-    std::string GetEntryPointCommand() const;
-    long GetEntryPointLine() const;
 
     bool IsValid() const;
     Snapshot GetBuildsystemDirectoryParent() const;
     Snapshot GetCallStackParent() const;
+    Snapshot GetCallStackBottom() const;
     SnapshotType GetType() const;
 
     void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
@@ -121,16 +122,15 @@ public:
   {
     Directory(cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
               Snapshot const& snapshot);
+
   public:
     const char* GetCurrentSource() const;
     void SetCurrentSource(std::string const& dir);
     const char* GetCurrentBinary() const;
     void SetCurrentBinary(std::string const& dir);
 
-    std::vector<std::string> const&
-    GetCurrentSourceComponents() const;
-    std::vector<std::string> const&
-    GetCurrentBinaryComponents() const;
+    std::vector<std::string> const& GetCurrentSourceComponents() const;
+    std::vector<std::string> const& GetCurrentBinaryComponents() const;
 
     const char* GetRelativePathTopSource() const;
     const char* GetRelativePathTopBinary() const;
@@ -158,17 +158,17 @@ public:
     cmStringRange GetCompileOptionsEntries() const;
     cmBacktraceRange GetCompileOptionsEntryBacktraces() const;
     void AppendCompileOptionsEntry(std::string const& vec,
-                                       cmListFileBacktrace const& lfbt);
+                                   cmListFileBacktrace const& lfbt);
     void SetCompileOptions(std::string const& vec,
-                               cmListFileBacktrace const& lfbt);
+                           cmListFileBacktrace const& lfbt);
     void ClearCompileOptions();
 
-    void SetProperty(const std::string& prop, const char *value,
-                     cmListFileBacktrace lfbt);
-    void AppendProperty(const std::string& prop, const char *value,
-                        bool asString, cmListFileBacktrace lfbt);
-    const char *GetProperty(const std::string& prop) const;
-    const char *GetProperty(const std::string& prop, bool chain) const;
+    void SetProperty(const std::string& prop, const char* value,
+                     cmListFileBacktrace const& lfbt);
+    void AppendProperty(const std::string& prop, const char* value,
+                        bool asString, cmListFileBacktrace const& lfbt);
+    const char* GetProperty(const std::string& prop) const;
+    const char* GetProperty(const std::string& prop, bool chain) const;
     bool GetPropertyAsBool(const std::string& prop) const;
     std::vector<std::string> GetPropertyKeys() const;
 
@@ -182,43 +182,45 @@ public:
     friend class Snapshot;
   };
 
-  enum TargetType { EXECUTABLE, STATIC_LIBRARY,
-                    SHARED_LIBRARY, MODULE_LIBRARY,
-                    OBJECT_LIBRARY, UTILITY, GLOBAL_TARGET,
-                    INTERFACE_LIBRARY,
-                    UNKNOWN_LIBRARY};
+  enum TargetType
+  {
+    EXECUTABLE,
+    STATIC_LIBRARY,
+    SHARED_LIBRARY,
+    MODULE_LIBRARY,
+    OBJECT_LIBRARY,
+    UTILITY,
+    GLOBAL_TARGET,
+    INTERFACE_LIBRARY,
+    UNKNOWN_LIBRARY
+  };
 
   static const char* GetTargetTypeName(cmState::TargetType targetType);
 
   Snapshot CreateBaseSnapshot();
-  Snapshot
-  CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
-                                     std::string const& entryPointCommand,
-                                     long entryPointLine);
+  Snapshot CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot);
   Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot,
-                                      std::string const& entryPointCommand,
-                                      long entryPointLine,
                                       std::string const& fileName);
   Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot,
-                                   std::string const& entryPointCommand,
-                                   long entryPointLine,
-                                   std::string const& fileName);
-  Snapshot CreateCallStackSnapshot(Snapshot originSnapshot,
-                                   std::string const& entryPointCommand,
-                                   long entryPointLine,
                                    std::string const& fileName);
-  Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot,
-                                       std::string const& entryPointCommand,
-                                       long entryPointLine);
+  Snapshot CreateIncludeFileSnapshot(Snapshot originSnapshot,
+                                     std::string const& fileName);
+  Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot);
   Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot,
-                                        const std::string& entryPointCommand,
-                                        long entryPointLine,
                                         std::string const& fileName);
   Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot);
   Snapshot Pop(Snapshot originSnapshot);
 
-  enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,
-                       UNINITIALIZED };
+  enum CacheEntryType
+  {
+    BOOL = 0,
+    PATH,
+    FILEPATH,
+    STRING,
+    INTERNAL,
+    STATIC,
+    UNINITIALIZED
+  };
   static CacheEntryType StringToCacheEntryType(const char*);
   static const char* CacheEntryTypeToString(CacheEntryType);
   static bool IsCacheEntryType(std::string const& key);
@@ -227,7 +229,7 @@ public:
                  std::set<std::string>& excludes,
                  std::set<std::string>& includes);
 
-  bool SaveCache(const std::string& path) ;
+  bool SaveCache(const std::string& path);
 
   bool DeleteCache(const std::string& path);
 
@@ -244,8 +246,7 @@ public:
                              std::string const& propertyName,
                              std::string const& value);
   void SetCacheEntryBoolProperty(std::string const& key,
-                                 std::string const& propertyName,
-                                 bool value);
+                                 std::string const& propertyName, bool value);
   const char* GetCacheEntryProperty(std::string const& key,
                                     std::string const& propertyName);
   bool GetCacheEntryPropertyAsBool(std::string const& key,
@@ -258,21 +259,18 @@ public:
                                 std::string const& propertyName);
 
   ///! Break up a line like VAR:type="value" into var, type and value
-  static bool ParseCacheEntry(const std::string& entry,
-                              std::string& var,
-                              std::string& value,
-                              CacheEntryType& type);
+  static bool ParseCacheEntry(const std::string& entry, std::string& var,
+                              std::string& value, CacheEntryType& type);
 
   Snapshot Reset();
   // Define a property
   void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
-                      const char *ShortDescription,
-                      const char *FullDescription,
-                      bool chain = false);
+                      const char* ShortDescription,
+                      const char* FullDescription, bool chain = false);
 
   // get property definition
-  cmPropertyDefinition const* GetPropertyDefinition
-  (const std::string& name, cmProperty::ScopeType scope) const;
+  cmPropertyDefinition const* GetPropertyDefinition(
+    const std::string& name, cmProperty::ScopeType scope) const;
 
   // Is a property defined?
   bool IsPropertyDefined(const std::string& name,
@@ -296,10 +294,10 @@ public:
   void RemoveUserDefinedCommands();
   std::vector<std::string> GetCommandNames() const;
 
-  void SetGlobalProperty(const std::string& prop, const char *value);
-  void AppendGlobalProperty(const std::string& prop,
-                      const char *value,bool asString=false);
-  const char *GetGlobalProperty(const std::string& prop);
+  void SetGlobalProperty(const std::string& prop, const char* value);
+  void AppendGlobalProperty(const std::string& prop, const char* value,
+                            bool asString = false);
+  const char* GetGlobalProperty(const std::string& prop);
   bool GetGlobalPropertyAsBool(const std::string& prop);
 
   const char* GetSourceDirectory() const;
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 649fb39..a348aef 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -10,135 +10,91 @@
   See the License for more information.
 ============================================================================*/
 #include "cmStringCommand.h"
+
 #include "cmCryptoHash.h"
 
 #include <cmsys/RegularExpression.hxx>
 #include <cmsys/SystemTools.hxx>
 
-#include <stdlib.h> // required for atoi
 #include <ctype.h>
+#include <stdlib.h> // required for atoi
 #include <time.h>
 
 #include <cmTimestamp.h>
 #include <cmUuid.h>
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmStringCommand::InitialPass(std::vector<std::string> const& args,
+                                  cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("must be called with at least one argument.");
     return false;
-    }
+  }
 
-  const std::string &subCommand = args[0];
-  if(subCommand == "REGEX")
-    {
+  const std::string& subCommand = args[0];
+  if (subCommand == "REGEX") {
     return this->HandleRegexCommand(args);
-    }
-  else if(subCommand == "REPLACE")
-    {
+  } else if (subCommand == "REPLACE") {
     return this->HandleReplaceCommand(args);
-    }
-  else if ( subCommand == "MD5" ||
-            subCommand == "SHA1" ||
-            subCommand == "SHA224" ||
-            subCommand == "SHA256" ||
-            subCommand == "SHA384" ||
-            subCommand == "SHA512" )
-    {
+  } else if (subCommand == "MD5" || subCommand == "SHA1" ||
+             subCommand == "SHA224" || subCommand == "SHA256" ||
+             subCommand == "SHA384" || subCommand == "SHA512") {
     return this->HandleHashCommand(args);
-    }
-  else if(subCommand == "TOLOWER")
-    {
+  } else if (subCommand == "TOLOWER") {
     return this->HandleToUpperLowerCommand(args, false);
-    }
-  else if(subCommand == "TOUPPER")
-    {
+  } else if (subCommand == "TOUPPER") {
     return this->HandleToUpperLowerCommand(args, true);
-    }
-  else if(subCommand == "COMPARE")
-    {
+  } else if (subCommand == "COMPARE") {
     return this->HandleCompareCommand(args);
-    }
-  else if(subCommand == "ASCII")
-    {
+  } else if (subCommand == "ASCII") {
     return this->HandleAsciiCommand(args);
-    }
-  else if(subCommand == "CONFIGURE")
-    {
+  } else if (subCommand == "CONFIGURE") {
     return this->HandleConfigureCommand(args);
-    }
-  else if(subCommand == "LENGTH")
-    {
+  } else if (subCommand == "LENGTH") {
     return this->HandleLengthCommand(args);
-    }
-  else if(subCommand == "APPEND")
-    {
+  } else if (subCommand == "APPEND") {
     return this->HandleAppendCommand(args);
-    }
-  else if(subCommand == "CONCAT")
-    {
+  } else if (subCommand == "CONCAT") {
     return this->HandleConcatCommand(args);
-    }
-  else if(subCommand == "SUBSTRING")
-    {
+  } else if (subCommand == "SUBSTRING") {
     return this->HandleSubstringCommand(args);
-    }
-  else if(subCommand == "STRIP")
-    {
+  } else if (subCommand == "STRIP") {
     return this->HandleStripCommand(args);
-    }
-  else if(subCommand == "RANDOM")
-    {
+  } else if (subCommand == "RANDOM") {
     return this->HandleRandomCommand(args);
-    }
-  else if(subCommand == "FIND")
-    {
+  } else if (subCommand == "FIND") {
     return this->HandleFindCommand(args);
-    }
-  else if(subCommand == "TIMESTAMP")
-    {
+  } else if (subCommand == "TIMESTAMP") {
     return this->HandleTimestampCommand(args);
-    }
-  else if(subCommand == "MAKE_C_IDENTIFIER")
-    {
+  } else if (subCommand == "MAKE_C_IDENTIFIER") {
     return this->HandleMakeCIdentifierCommand(args);
-    }
-  else if(subCommand == "GENEX_STRIP")
-    {
+  } else if (subCommand == "GENEX_STRIP") {
     return this->HandleGenexStripCommand(args);
-    }
-  else if(subCommand == "UUID")
-    {
+  } else if (subCommand == "UUID") {
     return this->HandleUuidCommand(args);
-    }
+  }
 
-  std::string e = "does not recognize sub-command "+subCommand;
+  std::string e = "does not recognize sub-command " + subCommand;
   this->SetError(e);
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     std::ostringstream e;
     e << args[0] << " requires an output variable and an input string";
     this->SetError(e.str());
     return false;
-    }
+  }
 
   cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
-  if(hash.get())
-    {
+  if (hash.get()) {
     std::string out = hash->HashString(args[2]);
     this->Makefile->AddDefinition(args[1], out.c_str());
     return true;
-    }
+  }
   return false;
 #else
   std::ostringstream e;
@@ -148,101 +104,80 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleToUpperLowerCommand(
   std::vector<std::string> const& args, bool toUpper)
 {
-  if ( args.size() < 3 )
-    {
+  if (args.size() < 3) {
     this->SetError("no output variable specified");
     return false;
-    }
+  }
 
   std::string outvar = args[2];
   std::string output;
 
-  if (toUpper)
-    {
+  if (toUpper) {
     output = cmSystemTools::UpperCase(args[1]);
-    }
-  else
-    {
+  } else {
     output = cmSystemTools::LowerCase(args[1]);
-    }
+  }
 
   // Store the output in the provided variable.
   this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args)
 {
-  if ( args.size() < 3 )
-    {
+  if (args.size() < 3) {
     this->SetError("No output variable specified");
     return false;
-    }
+  }
   std::string::size_type cc;
-  std::string outvar = args[args.size()-1];
+  std::string outvar = args[args.size() - 1];
   std::string output = "";
-  for ( cc = 1; cc < args.size()-1; cc ++ )
-    {
+  for (cc = 1; cc < args.size() - 1; cc++) {
     int ch = atoi(args[cc].c_str());
-    if ( ch > 0 && ch < 256 )
-      {
+    if (ch > 0 && ch < 256) {
       output += static_cast<char>(ch);
-      }
-    else
-      {
+    } else {
       std::string error = "Character with code ";
       error += args[cc];
       error += " does not exist.";
       this->SetError(error);
       return false;
-      }
     }
+  }
   // Store the output in the provided variable.
   this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleConfigureCommand(
   std::vector<std::string> const& args)
 {
-  if ( args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("No input string specified.");
     return false;
-    }
-  else if ( args.size() < 3 )
-    {
+  } else if (args.size() < 3) {
     this->SetError("No output variable specified.");
     return false;
-    }
+  }
 
   // Parse options.
   bool escapeQuotes = false;
   bool atOnly = false;
-  for(unsigned int i = 3; i < args.size(); ++i)
-    {
-    if(args[i] == "@ONLY")
-      {
+  for (unsigned int i = 3; i < args.size(); ++i) {
+    if (args[i] == "@ONLY") {
       atOnly = true;
-      }
-    else if(args[i] == "ESCAPE_QUOTES")
-      {
+    } else if (args[i] == "ESCAPE_QUOTES") {
       escapeQuotes = true;
-      }
-    else
-      {
+    } else {
       std::ostringstream err;
       err << "Unrecognized argument \"" << args[i] << "\"";
       this->SetError(err.str());
       return false;
-      }
     }
+  }
 
   // Configure the string.
   std::string output;
@@ -254,52 +189,41 @@ bool cmStringCommand::HandleConfigureCommand(
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleRegexCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("sub-command REGEX requires a mode to be specified.");
     return false;
-    }
+  }
   std::string mode = args[1];
-  if(mode == "MATCH")
-    {
-    if(args.size() < 5)
-      {
+  if (mode == "MATCH") {
+    if (args.size() < 5) {
       this->SetError("sub-command REGEX, mode MATCH needs "
                      "at least 5 arguments total to command.");
       return false;
-      }
-    return this->RegexMatch(args);
     }
-  else if(mode == "MATCHALL")
-    {
-    if(args.size() < 5)
-      {
+    return this->RegexMatch(args);
+  } else if (mode == "MATCHALL") {
+    if (args.size() < 5) {
       this->SetError("sub-command REGEX, mode MATCHALL needs "
                      "at least 5 arguments total to command.");
       return false;
-      }
-    return this->RegexMatchAll(args);
     }
-  else if(mode == "REPLACE")
-    {
-    if(args.size() < 6)
-      {
+    return this->RegexMatchAll(args);
+  } else if (mode == "REPLACE") {
+    if (args.size() < 6) {
       this->SetError("sub-command REGEX, mode REPLACE needs "
                      "at least 6 arguments total to command.");
       return false;
-      }
-    return this->RegexReplace(args);
     }
+    return this->RegexReplace(args);
+  }
 
-  std::string e = "sub-command REGEX does not recognize mode "+mode;
+  std::string e = "sub-command REGEX does not recognize mode " + mode;
   this->SetError(e);
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
 {
   //"STRING(REGEX MATCH <regular_expression> <output variable>
@@ -310,41 +234,37 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
-  if(!re.compile(regex.c_str()))
-    {
+  if (!re.compile(regex.c_str())) {
     std::string e =
-      "sub-command REGEX, mode MATCH failed to compile regex \""+regex+"\".";
+      "sub-command REGEX, mode MATCH failed to compile regex \"" + regex +
+      "\".";
     this->SetError(e);
     return false;
-    }
+  }
 
   // Concatenate all the last arguments together.
   std::string input = cmJoin(cmMakeRange(args).advance(4), std::string());
 
   // Scan through the input for all matches.
   std::string output;
-  if(re.find(input.c_str()))
-    {
+  if (re.find(input.c_str())) {
     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 MATCH regex \""+regex+
+    if (r - l == 0) {
+      std::string e = "sub-command REGEX, mode MATCH regex \"" + regex +
         "\" matched an empty string.";
       this->SetError(e);
       return false;
-      }
-    output = input.substr(l, r-l);
     }
+    output = input.substr(l, r - l);
+  }
 
   // Store the output in the provided variable.
   this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
 {
   //"STRING(REGEX MATCHALL <regular_expression> <output variable> <input>
@@ -355,14 +275,13 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
-  if(!re.compile(regex.c_str()))
-    {
+  if (!re.compile(regex.c_str())) {
     std::string e =
-      "sub-command REGEX, mode MATCHALL failed to compile regex \""+
-      regex+"\".";
+      "sub-command REGEX, mode MATCHALL failed to compile regex \"" + regex +
+      "\".";
     this->SetError(e);
     return false;
-    }
+  }
 
   // Concatenate all the last arguments together.
   std::string input = cmJoin(cmMakeRange(args).advance(4), std::string());
@@ -370,32 +289,28 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
   // Scan through the input for all matches.
   std::string output;
   const char* p = input.c_str();
-  while(re.find(p))
-    {
+  while (re.find(p)) {
     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.";
+    if (r - l == 0) {
+      std::string e = "sub-command REGEX, mode MATCHALL regex \"" + regex +
+        "\" matched an empty string.";
       this->SetError(e);
       return false;
-      }
-    if(!output.empty())
-      {
+    }
+    if (!output.empty()) {
       output += ";";
-      }
-    output += std::string(p+l, r-l);
-    p += r;
     }
+    output += std::string(p + l, r - l);
+    p += r;
+  }
 
   // Store the output in the provided variable.
   this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
 {
   //"STRING(REGEX REPLACE <regular_expression> <replace_expression>
@@ -407,62 +322,48 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
   // Pull apart the replace expression to find the escaped [0-9] values.
   std::vector<RegexReplacement> replacement;
   std::string::size_type l = 0;
-  while(l < replace.length())
-    {
+  while (l < replace.length()) {
     std::string::size_type r = replace.find("\\", l);
-    if(r == std::string::npos)
-      {
+    if (r == std::string::npos) {
       r = replace.length();
-      replacement.push_back(replace.substr(l, r-l));
+      replacement.push_back(replace.substr(l, r - l));
+    } else {
+      if (r - l > 0) {
+        replacement.push_back(replace.substr(l, r - l));
       }
-    else
-      {
-      if(r-l > 0)
-        {
-        replacement.push_back(replace.substr(l, r-l));
-        }
-      if(r == (replace.length()-1))
-        {
+      if (r == (replace.length() - 1)) {
         this->SetError("sub-command REGEX, mode REPLACE: "
                        "replace-expression ends in a backslash.");
         return false;
-        }
-      if((replace[r+1] >= '0') && (replace[r+1] <= '9'))
-        {
-        replacement.push_back(replace[r+1]-'0');
-        }
-      else if(replace[r+1] == 'n')
-        {
+      }
+      if ((replace[r + 1] >= '0') && (replace[r + 1] <= '9')) {
+        replacement.push_back(replace[r + 1] - '0');
+      } else if (replace[r + 1] == 'n') {
         replacement.push_back("\n");
-        }
-      else if(replace[r+1] == '\\')
-        {
+      } else if (replace[r + 1] == '\\') {
         replacement.push_back("\\");
-        }
-      else
-        {
+      } else {
         std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \"";
         e += replace.substr(r, 2);
         e += "\" in replace-expression.";
         this->SetError(e);
         return false;
-        }
-      r += 2;
       }
-    l = r;
+      r += 2;
     }
+    l = r;
+  }
 
   this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
-  if(!re.compile(regex.c_str()))
-    {
+  if (!re.compile(regex.c_str())) {
     std::string e =
-      "sub-command REGEX, mode REPLACE failed to compile regex \""+
-      regex+"\".";
+      "sub-command REGEX, mode REPLACE failed to compile regex \"" + regex +
+      "\".";
     this->SetError(e);
     return false;
-    }
+  }
 
   // Concatenate all the last arguments together.
   std::string input = cmJoin(cmMakeRange(args).advance(5), std::string());
@@ -470,8 +371,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
   // Scan through the input for all matches.
   std::string output;
   std::string::size_type base = 0;
-  while(re.find(input.c_str()+base))
-    {
+  while (re.find(input.c_str() + base)) {
     this->Makefile->StoreMatches(re);
     std::string::size_type l2 = re.start();
     std::string::size_type r = re.end();
@@ -480,82 +380,69 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
     output += input.substr(base, l2);
 
     // Make sure the match had some text.
-    if(r-l2 == 0)
-      {
-      std::string e = "sub-command REGEX, mode REPLACE regex \""+
-        regex+"\" matched an empty string.";
+    if (r - l2 == 0) {
+      std::string e = "sub-command REGEX, mode REPLACE regex \"" + regex +
+        "\" matched an empty string.";
       this->SetError(e);
       return false;
-      }
+    }
 
     // Concatenate the replacement for the match.
-    for(unsigned int i=0; i < replacement.size(); ++i)
-      {
-      if(replacement[i].number < 0)
-        {
+    for (unsigned int i = 0; i < replacement.size(); ++i) {
+      if (replacement[i].number < 0) {
         // This is just a plain-text part of the replacement.
         output += replacement[i].value;
-        }
-      else
-        {
+      } else {
         // Replace with part of the match.
         int n = replacement[i].number;
         std::string::size_type start = re.start(n);
         std::string::size_type end = re.end(n);
-        std::string::size_type len = input.length()-base;
-        if((start != std::string::npos) && (end != std::string::npos) &&
-           (start <= len) && (end <= len))
-          {
-          output += input.substr(base+start, end-start);
-          }
-        else
-          {
+        std::string::size_type len = input.length() - base;
+        if ((start != std::string::npos) && (end != std::string::npos) &&
+            (start <= len) && (end <= len)) {
+          output += input.substr(base + start, end - start);
+        } else {
           std::string e =
-            "sub-command REGEX, mode REPLACE: replace expression \""+
-            replace+"\" contains an out-of-range escape for regex \""+
-            regex+"\".";
+            "sub-command REGEX, mode REPLACE: replace expression \"" +
+            replace + "\" contains an out-of-range escape for regex \"" +
+            regex + "\".";
           this->SetError(e);
           return false;
-          }
         }
       }
+    }
 
     // Move past the match.
     base += r;
-    }
+  }
 
   // Concatenate the text after the last match.
-  output += input.substr(base, input.length()-base);
+  output += input.substr(base, input.length() - base);
 
   // Store the output in the provided variable.
   this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
-                                           args)
+bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args)
 {
   // check if all required parameters were passed
-  if(args.size() < 4 || args.size() > 5)
-    {
+  if (args.size() < 4 || args.size() > 5) {
     this->SetError("sub-command FIND requires 3 or 4 parameters.");
     return false;
-    }
+  }
 
   // check if the reverse flag was set or not
   bool reverseMode = false;
-  if(args.size() == 5 && args[4] == "REVERSE")
-    {
+  if (args.size() == 5 && args[4] == "REVERSE") {
     reverseMode = true;
-    }
+  }
 
   // if we have 5 arguments the last one must be REVERSE
-  if(args.size() == 5 && args[4] != "REVERSE")
-    {
+  if (args.size() == 5 && args[4] != "REVERSE") {
     this->SetError("sub-command FIND: unknown last parameter");
     return false;
-    }
+  }
 
   // local parameter names.
   const std::string& sstring = args[1];
@@ -563,103 +450,83 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
   const std::string& outvar = args[3];
 
   // ensure that the user cannot accidentally specify REVERSE as a variable
-  if(outvar == "REVERSE")
-    {
-    this->SetError("sub-command FIND does not allow to select REVERSE as "
+  if (outvar == "REVERSE") {
+    this->SetError("sub-command FIND does not allow one to select REVERSE as "
                    "the output variable.  "
                    "Maybe you missed the actual output variable?");
     return false;
-    }
+  }
 
   // try to find the character and return its position
   size_t pos;
-  if(!reverseMode)
-    {
+  if (!reverseMode) {
     pos = sstring.find(schar);
-    }
-  else
-    {
+  } else {
     pos = sstring.rfind(schar);
-    }
-  if(std::string::npos != pos)
-    {
+  }
+  if (std::string::npos != pos) {
     std::ostringstream s;
     s << pos;
     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, "-1");
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand::HandleCompareCommand(std::vector<std::string> const&
-                                           args)
+bool cmStringCommand::HandleCompareCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("sub-command COMPARE requires a mode to be specified.");
     return false;
-    }
+  }
   std::string mode = args[1];
-  if((mode == "EQUAL") || (mode == "NOTEQUAL") ||
-     (mode == "LESS") || (mode == "GREATER"))
-    {
-    if(args.size() < 5)
-      {
+  if ((mode == "EQUAL") || (mode == "NOTEQUAL") || (mode == "LESS") ||
+      (mode == "GREATER")) {
+    if (args.size() < 5) {
       std::string e = "sub-command COMPARE, mode ";
       e += mode;
       e += " needs at least 5 arguments total to command.";
       this->SetError(e);
       return false;
-      }
+    }
 
     const std::string& left = args[2];
     const std::string& right = args[3];
     const std::string& outvar = args[4];
     bool result;
-    if(mode == "LESS")
-      {
+    if (mode == "LESS") {
       result = (left < right);
-      }
-    else if(mode == "GREATER")
-      {
+    } else if (mode == "GREATER") {
       result = (left > right);
-      }
-    else if(mode == "EQUAL")
-      {
+    } else if (mode == "EQUAL") {
       result = (left == right);
-      }
-    else // if(mode == "NOTEQUAL")
-      {
+    } else // if(mode == "NOTEQUAL")
+    {
       result = !(left == right);
-      }
-    if(result)
-      {
+    }
+    if (result) {
       this->Makefile->AddDefinition(outvar, "1");
-      }
-    else
-      {
+    } else {
       this->Makefile->AddDefinition(outvar, "0");
-      }
-    return true;
     }
-  std::string e = "sub-command COMPARE does not recognize mode "+mode;
+    return true;
+  }
+  std::string e = "sub-command COMPARE does not recognize mode " + mode;
   this->SetError(e);
   return false;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
-                                           args)
+bool cmStringCommand::HandleReplaceCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() < 5)
-    {
+  if (args.size() < 5) {
     this->SetError("sub-command REPLACE requires at least four arguments.");
     return false;
-    }
+  }
 
   const std::string& matchExpression = args[1];
   const std::string& replaceExpression = args[2];
@@ -674,15 +541,13 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
-                                             args)
+bool cmStringCommand::HandleSubstringCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() != 5)
-    {
+  if (args.size() != 5) {
     this->SetError("sub-command SUBSTRING requires four arguments.");
     return false;
-    }
+  }
 
   const std::string& stringValue = args[1];
   int begin = atoi(args[2].c_str());
@@ -691,36 +556,31 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
 
   size_t stringLength = stringValue.size();
   int intStringLength = static_cast<int>(stringLength);
-  if ( begin < 0 || begin > intStringLength )
-    {
+  if (begin < 0 || begin > intStringLength) {
     std::ostringstream ostr;
     ostr << "begin index: " << begin << " is out of range 0 - "
          << stringLength;
     this->SetError(ostr.str());
     return false;
-    }
-  if ( end < -1 )
-    {
+  }
+  if (end < -1) {
     std::ostringstream ostr;
     ostr << "end index: " << end << " should be -1 or greater";
     this->SetError(ostr.str());
     return false;
-    }
+  }
 
   this->Makefile->AddDefinition(variableName,
                                 stringValue.substr(begin, end).c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::HandleLengthCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleLengthCommand(std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("sub-command LENGTH requires two arguments.");
     return false;
-    }
+  }
 
   const std::string& stringValue = args[1];
   const std::string& variableName = args[2];
@@ -733,43 +593,36 @@ bool cmStringCommand
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("sub-command APPEND requires at least one argument.");
     return false;
-    }
+  }
 
   // Skip if nothing to append.
-  if(args.size() < 3)
-    {
+  if (args.size() < 3) {
     return true;
-    }
+  }
 
   const std::string& variable = args[1];
 
   std::string value;
   const char* oldValue = this->Makefile->GetDefinition(variable);
-  if(oldValue)
-    {
+  if (oldValue) {
     value = oldValue;
-    }
+  }
   value += cmJoin(cmMakeRange(args).advance(2), std::string());
   this->Makefile->AddDefinition(variable, value.c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::HandleConcatCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleConcatCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("sub-command CONCAT requires at least one argument.");
     return false;
-    }
+  }
 
   std::string const& variableName = args[1];
   std::string value = cmJoin(cmMakeRange(args).advance(2), std::string());
@@ -778,38 +631,34 @@ bool cmStringCommand
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::HandleMakeCIdentifierCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleMakeCIdentifierCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("sub-command MAKE_C_IDENTIFIER requires two arguments.");
     return false;
-    }
+  }
 
   const std::string& input = args[1];
   const std::string& variableName = args[2];
 
   this->Makefile->AddDefinition(variableName,
-                      cmSystemTools::MakeCidentifier(input).c_str());
+                                cmSystemTools::MakeCidentifier(input).c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::HandleGenexStripCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleGenexStripCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() != 3)
-    {
+  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);
+  std::string result = cmGeneratorExpression::Preprocess(
+    input, cmGeneratorExpression::StripAllGeneratorExpressions);
 
   const std::string& variableName = args[2];
 
@@ -817,15 +666,12 @@ bool cmStringCommand
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand::HandleStripCommand(
-  std::vector<std::string> const& args)
+bool cmStringCommand::HandleStripCommand(std::vector<std::string> const& args)
 {
- if(args.size() != 3)
-    {
+  if (args.size() != 3) {
     this->SetError("sub-command STRIP requires two arguments.");
     return false;
-    }
+  }
 
   const std::string& stringValue = args[1];
   const std::string& variableName = args[2];
@@ -834,161 +680,131 @@ bool cmStringCommand::HandleStripCommand(
   size_t endPos = 0;
   const char* ptr = stringValue.c_str();
   size_t cc;
-  for ( cc = 0; cc < inStringLength; ++ cc )
-    {
-    if ( !isspace(*ptr) )
-      {
-      if ( startPos > inStringLength )
-        {
+  for (cc = 0; cc < inStringLength; ++cc) {
+    if (!isspace(*ptr)) {
+      if (startPos > inStringLength) {
         startPos = cc;
-        }
-      endPos = cc;
       }
-    ++ ptr;
+      endPos = cc;
     }
+    ++ptr;
+  }
 
   size_t outLength = 0;
 
   // if the input string didn't contain any non-space characters, return
   // an empty string
-  if (startPos > inStringLength)
-    {
+  if (startPos > inStringLength) {
     outLength = 0;
     startPos = 0;
-    }
-  else
-    {
-    outLength=endPos - startPos + 1;
-    }
+  } else {
+    outLength = endPos - startPos + 1;
+  }
 
-  this->Makefile->AddDefinition(variableName,
-    stringValue.substr(startPos, outLength).c_str());
+  this->Makefile->AddDefinition(
+    variableName, stringValue.substr(startPos, outLength).c_str());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::HandleRandomCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
 {
-  if(args.size() < 2 || args.size() == 3 || args.size() == 5)
-    {
+  if (args.size() < 2 || args.size() == 3 || args.size() == 5) {
     this->SetError("sub-command RANDOM requires at least one argument.");
     return false;
-    }
+  }
 
   static bool seeded = false;
   bool force_seed = false;
   unsigned int seed = 0;
   int length = 5;
   const char cmStringCommandDefaultAlphabet[] = "qwertyuiopasdfghjklzxcvbnm"
-    "QWERTYUIOPASDFGHJKLZXCVBNM"
-    "0123456789";
+                                                "QWERTYUIOPASDFGHJKLZXCVBNM"
+                                                "0123456789";
   std::string alphabet;
 
-  if ( args.size() > 3 )
-    {
+  if (args.size() > 3) {
     size_t i = 1;
     size_t stopAt = args.size() - 2;
 
-    for ( ; i < stopAt; ++i )
-      {
-      if ( args[i] == "LENGTH" )
-        {
+    for (; i < stopAt; ++i) {
+      if (args[i] == "LENGTH") {
         ++i;
         length = atoi(args[i].c_str());
-        }
-      else if ( args[i] == "ALPHABET" )
-        {
+      } else if (args[i] == "ALPHABET") {
         ++i;
         alphabet = args[i];
-        }
-      else if ( args[i] == "RANDOM_SEED" )
-        {
+      } else if (args[i] == "RANDOM_SEED") {
         ++i;
         seed = static_cast<unsigned int>(atoi(args[i].c_str()));
         force_seed = true;
-        }
       }
     }
-  if (alphabet.empty())
-    {
+  }
+  if (alphabet.empty()) {
     alphabet = cmStringCommandDefaultAlphabet;
-    }
+  }
 
   double sizeofAlphabet = static_cast<double>(alphabet.size());
-  if ( sizeofAlphabet < 1 )
-    {
+  if (sizeofAlphabet < 1) {
     this->SetError("sub-command RANDOM invoked with bad alphabet.");
     return false;
-    }
-  if ( length < 1 )
-    {
+  }
+  if (length < 1) {
     this->SetError("sub-command RANDOM invoked with bad length.");
     return false;
-    }
-  const std::string& variableName = args[args.size()-1];
+  }
+  const std::string& variableName = args[args.size() - 1];
 
   std::vector<char> result;
 
-  if (!seeded || force_seed)
-    {
+  if (!seeded || force_seed) {
     seeded = true;
-    srand(force_seed? seed : cmSystemTools::RandomSeed());
-    }
+    srand(force_seed ? seed : cmSystemTools::RandomSeed());
+  }
 
   const char* alphaPtr = alphabet.c_str();
   int cc;
-  for ( cc = 0; cc < length; cc ++ )
-    {
-    int idx=(int) (sizeofAlphabet* rand()/(RAND_MAX+1.0));
+  for (cc = 0; cc < length; cc++) {
+    int idx = (int)(sizeofAlphabet * rand() / (RAND_MAX + 1.0));
     result.push_back(*(alphaPtr + idx));
-    }
+  }
   result.push_back(0);
 
   this->Makefile->AddDefinition(variableName, &*result.begin());
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmStringCommand
-::HandleTimestampCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleTimestampCommand(
+  std::vector<std::string> const& args)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("sub-command TIMESTAMP requires at least one argument.");
     return false;
-    }
-  else if(args.size() > 4)
-    {
+  } else if (args.size() > 4) {
     this->SetError("sub-command TIMESTAMP takes at most three arguments.");
     return false;
-    }
+  }
 
   unsigned int argsIndex = 1;
 
-  const std::string &outputVariable = args[argsIndex++];
+  const std::string& outputVariable = args[argsIndex++];
 
   std::string formatString;
-  if(args.size() > argsIndex && args[argsIndex] != "UTC")
-    {
+  if (args.size() > argsIndex && args[argsIndex] != "UTC") {
     formatString = args[argsIndex++];
-    }
+  }
 
   bool utcFlag = false;
-  if(args.size() > argsIndex)
-    {
-    if(args[argsIndex] == "UTC")
-      {
+  if (args.size() > argsIndex) {
+    if (args[argsIndex] == "UTC") {
       utcFlag = true;
-      }
-    else
-      {
+    } else {
       std::string e = " TIMESTAMP sub-command does not recognize option " +
-          args[argsIndex] + ".";
+        args[argsIndex] + ".";
       this->SetError(e);
       return false;
-      }
     }
+  }
 
   cmTimestamp timestamp;
   std::string result = timestamp.CurrentTime(formatString, utcFlag);
@@ -997,106 +813,83 @@ bool cmStringCommand
   return true;
 }
 
-bool cmStringCommand
-::HandleUuidCommand(std::vector<std::string> const& args)
+bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   unsigned int argsIndex = 1;
 
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("UUID sub-command requires an output variable.");
     return false;
-    }
+  }
 
-  const std::string &outputVariable = args[argsIndex++];
+  const std::string& outputVariable = args[argsIndex++];
 
   std::string uuidNamespaceString;
   std::string uuidName;
   std::string uuidType;
   bool uuidUpperCase = false;
 
-  while(args.size() > argsIndex)
-    {
-    if(args[argsIndex] == "NAMESPACE")
-      {
+  while (args.size() > argsIndex) {
+    if (args[argsIndex] == "NAMESPACE") {
       ++argsIndex;
-      if(argsIndex >= args.size())
-        {
+      if (argsIndex >= args.size()) {
         this->SetError("UUID sub-command, NAMESPACE requires a value.");
         return false;
-        }
-      uuidNamespaceString = args[argsIndex++];
       }
-    else if(args[argsIndex] == "NAME")
-      {
+      uuidNamespaceString = args[argsIndex++];
+    } else if (args[argsIndex] == "NAME") {
       ++argsIndex;
-      if(argsIndex >= args.size())
-        {
+      if (argsIndex >= args.size()) {
         this->SetError("UUID sub-command, NAME requires a value.");
         return false;
-        }
-      uuidName = args[argsIndex++];
       }
-    else if(args[argsIndex] == "TYPE")
-      {
+      uuidName = args[argsIndex++];
+    } else if (args[argsIndex] == "TYPE") {
       ++argsIndex;
-      if(argsIndex >= args.size())
-        {
+      if (argsIndex >= args.size()) {
         this->SetError("UUID sub-command, TYPE requires a value.");
         return false;
-        }
-      uuidType = args[argsIndex++];
       }
-    else if(args[argsIndex] == "UPPER")
-      {
+      uuidType = args[argsIndex++];
+    } else if (args[argsIndex] == "UPPER") {
       ++argsIndex;
       uuidUpperCase = true;
-      }
-    else
-      {
-      std::string e = "UUID sub-command does not recognize option " +
-          args[argsIndex] + ".";
+    } else {
+      std::string e =
+        "UUID sub-command does not recognize option " + args[argsIndex] + ".";
       this->SetError(e);
       return false;
-      }
     }
+  }
 
   std::string uuid;
   cmUuid uuidGenerator;
 
   std::vector<unsigned char> uuidNamespace;
-  if(!uuidGenerator.StringToBinary(uuidNamespaceString, uuidNamespace))
-    {
+  if (!uuidGenerator.StringToBinary(uuidNamespaceString, uuidNamespace)) {
     this->SetError("UUID sub-command, malformed NAMESPACE UUID.");
     return false;
-    }
+  }
 
-  if(uuidType == "MD5")
-    {
+  if (uuidType == "MD5") {
     uuid = uuidGenerator.FromMd5(uuidNamespace, uuidName);
-    }
-  else if(uuidType == "SHA1")
-    {
+  } else if (uuidType == "SHA1") {
     uuid = uuidGenerator.FromSha1(uuidNamespace, uuidName);
-    }
-  else
-    {
+  } else {
     std::string e = "UUID sub-command, unknown TYPE '" + uuidType + "'.";
     this->SetError(e);
     return false;
-    }
+  }
 
-  if(uuid.empty())
-    {
+  if (uuid.empty()) {
     this->SetError("UUID sub-command, generation failed.");
     return false;
-    }
+  }
 
-  if(uuidUpperCase)
-    {
+  if (uuidUpperCase) {
     uuid = cmSystemTools::UpperCase(uuid);
-    }
+  }
 
   this->Makefile->AddDefinition(outputVariable, uuid.c_str());
   return true;
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 3ed17eb..23d482c 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -15,9 +15,8 @@
 #include "cmCommand.h"
 
 class cmMakefile;
-namespace cmsys
-{
-  class RegularExpression;
+namespace cmsys {
+class RegularExpression;
 }
 
 /** \class cmStringCommand
@@ -30,17 +29,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmStringCommand;
-    }
+  virtual cmCommand* Clone() { return new cmStringCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -50,9 +46,10 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "string";}
+  virtual std::string GetName() const { return "string"; }
 
   cmTypeMacro(cmStringCommand, cmCommand);
+
 protected:
   bool HandleConfigureCommand(std::vector<std::string> const& args);
   bool HandleAsciiCommand(std::vector<std::string> const& args);
@@ -80,14 +77,25 @@ protected:
   class RegexReplacement
   {
   public:
-    RegexReplacement(const char* s): number(-1), value(s) {}
-    RegexReplacement(const std::string& s): number(-1), value(s) {}
-    RegexReplacement(int n): number(n), value() {}
+    RegexReplacement(const char* s)
+      : number(-1)
+      , value(s)
+    {
+    }
+    RegexReplacement(const std::string& s)
+      : number(-1)
+      , value(s)
+    {
+    }
+    RegexReplacement(int n)
+      : number(n)
+      , value()
+    {
+    }
     RegexReplacement() {}
     int number;
     std::string value;
   };
 };
 
-
 #endif
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index 6a4a835..401f588 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -12,62 +12,51 @@
 #include "cmSubdirCommand.h"
 
 // cmSubdirCommand
-bool cmSubdirCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
+                                  cmExecutionStatus&)
 {
-  if(args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   bool res = true;
   bool excludeFromAll = false;
 
-  for(std::vector<std::string>::const_iterator i = args.begin();
-      i != args.end(); ++i)
-    {
-    if(*i == "EXCLUDE_FROM_ALL")
-      {
+  for (std::vector<std::string>::const_iterator i = args.begin();
+       i != args.end(); ++i) {
+    if (*i == "EXCLUDE_FROM_ALL") {
       excludeFromAll = true;
       continue;
-      }
-    if(*i == "PREORDER")
-      {
+    }
+    if (*i == "PREORDER") {
       // Ignored
       continue;
-      }
+    }
 
     // if they specified a relative path then compute the full
     std::string srcPath =
-      std::string(this->Makefile->GetCurrentSourceDirectory()) +
-        "/" + i->c_str();
-    if (cmSystemTools::FileIsDirectory(srcPath))
-      {
+      std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" +
+      i->c_str();
+    if (cmSystemTools::FileIsDirectory(srcPath)) {
       std::string binPath =
-        std::string(this->Makefile->GetCurrentBinaryDirectory()) +
-        "/" + i->c_str();
-      this->Makefile->AddSubDirectory(srcPath, binPath,
-                                  excludeFromAll, false);
-      }
+        std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" +
+        i->c_str();
+      this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
+    }
     // otherwise it is a full path
-    else if ( cmSystemTools::FileIsDirectory(*i) )
-      {
+    else if (cmSystemTools::FileIsDirectory(*i)) {
       // we must compute the binPath from the srcPath, we just take the last
       // element from the source path and use that
       std::string binPath =
-        std::string(this->Makefile->GetCurrentBinaryDirectory()) +
-        "/" + cmSystemTools::GetFilenameName(*i);
-      this->Makefile->AddSubDirectory(*i, binPath,
-                                  excludeFromAll, false);
-      }
-    else
-      {
+        std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" +
+        cmSystemTools::GetFilenameName(*i);
+      this->Makefile->AddSubDirectory(*i, binPath, excludeFromAll, false);
+    } else {
       std::string error = "Incorrect SUBDIRS command. Directory: ";
       error += *i + " does not exist.";
       this->SetError(error);
       res = false;
-      }
     }
+  }
   return res;
 }
-
diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h
index bcefd2c..9da91c4 100644
--- a/Source/cmSubdirCommand.h
+++ b/Source/cmSubdirCommand.h
@@ -27,26 +27,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmSubdirCommand;
-    }
+  virtual cmCommand* Clone() { return new cmSubdirCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "subdirs";}
+  virtual std::string GetName() const { return "subdirs"; }
 
   cmTypeMacro(cmSubdirCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx
index 9381983..c80fb94 100644
--- a/Source/cmSubdirDependsCommand.cxx
+++ b/Source/cmSubdirDependsCommand.cxx
@@ -11,10 +11,11 @@
 ============================================================================*/
 #include "cmSubdirDependsCommand.h"
 
-bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const& ,
-                                         cmExecutionStatus &)
+bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const&,
+                                         cmExecutionStatus&)
 {
-  this->Disallowed(cmPolicies::CMP0029,
+  this->Disallowed(
+    cmPolicies::CMP0029,
     "The subdir_depends command should not be called; see CMP0029.");
   return true;
 }
diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h
index 3f3507e..a15ee3e 100644
--- a/Source/cmSubdirDependsCommand.h
+++ b/Source/cmSubdirDependsCommand.h
@@ -19,8 +19,8 @@ class cmSubdirDependsCommand : public cmCommand
 public:
   virtual cmCommand* Clone() { return new cmSubdirDependsCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const { return "subdir_depends";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "subdir_depends"; }
   cmTypeMacro(cmSubdirDependsCommand, cmCommand);
 };
 
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 3ba7287..7dece47 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -9,67 +9,67 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-
 #include "cmSystemTools.h"
+
 #include "cmAlgorithms.h"
+#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
-#include <time.h>
-#include <string.h>
 #include <stdlib.h>
-#include <assert.h>
+#include <string.h>
+#include <time.h>
 #ifdef __QNX__
-# include <malloc.h> /* for malloc/free on QNX */
+#include <malloc.h> /* for malloc/free on QNX */
 #endif
+#include <cmsys/Directory.hxx>
+#include <cmsys/Encoding.hxx>
 #include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
-#include <cmsys/Directory.hxx>
 #include <cmsys/System.h>
-#include <cmsys/Encoding.hxx>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include "cmArchiveWrite.h"
-# include "cmLocale.h"
-# include <cm_libarchive.h>
-# ifndef __LA_INT64_T
-#  define __LA_INT64_T la_int64_t
-# endif
+#include "cmArchiveWrite.h"
+#include "cmLocale.h"
+#include <cm_libarchive.h>
+#ifndef __LA_INT64_T
+#define __LA_INT64_T la_int64_t
+#endif
 #endif
 #include <cmsys/FStream.hxx>
 #include <cmsys/Terminal.h>
 
 #if defined(_WIN32)
-# include <windows.h>
-# include <wincrypt.h>
+#include <windows.h>
+// include wincrypt.h after windows.h
+#include <wincrypt.h>
 #else
-# include <sys/time.h>
-# include <sys/types.h>
-# include <unistd.h>
-# include <utime.h>
-# include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <utime.h>
 #endif
 
 #if defined(__APPLE__)
-# include <mach-o/dyld.h>
+#include <mach-o/dyld.h>
 #endif
 
 #include <sys/stat.h>
 
-#if defined(_WIN32) && \
-   (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__))
-# include <io.h>
+#if defined(_WIN32) &&                                                        \
+  (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__))
+#include <io.h>
 #endif
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-#  include <fcntl.h>
-#  include "cmCryptoHash.h"
+#include "cmCryptoHash.h"
 #endif
 
 #if defined(CMAKE_USE_ELF_PARSER)
-# include "cmELF.h"
+#include "cmELF.h"
 #endif
 
 #if defined(CMAKE_USE_MACH_PARSER)
-# include "cmMachO.h"
+#include "cmMachO.h"
 #endif
 
 static bool cm_isspace(char c)
@@ -91,27 +91,24 @@ public:
 
 #if !defined(HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
 // For GetEnvironmentVariables
-# if defined(_WIN32)
-extern __declspec( dllimport ) char** environ;
-# else
+#if defined(_WIN32)
+extern __declspec(dllimport) char** environ;
+#else
 extern char** environ;
-# endif
+#endif
 #endif
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-static std::string
-cm_archive_entry_pathname(struct archive_entry *entry)
+static std::string cm_archive_entry_pathname(struct archive_entry* entry)
 {
 #if cmsys_STL_HAS_WSTRING
-  return cmsys::Encoding::ToNarrow(
-    archive_entry_pathname_w(entry));
+  return cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry));
 #else
   return archive_entry_pathname(entry);
 #endif
 }
 
-static int cm_archive_read_open_file(struct archive* a,
-                                     const char* file,
+static int cm_archive_read_open_file(struct archive* a, const char* file,
                                      int block_size)
 {
 #if cmsys_STL_HAS_WSTRING
@@ -127,16 +124,18 @@ static int cm_archive_read_open_file(struct archive* a,
 class cmSystemToolsWindowsHandle
 {
 public:
-  cmSystemToolsWindowsHandle(HANDLE h): handle_(h) {}
+  cmSystemToolsWindowsHandle(HANDLE h)
+    : handle_(h)
+  {
+  }
   ~cmSystemToolsWindowsHandle()
-    {
-    if(this->handle_ != INVALID_HANDLE_VALUE)
-      {
+  {
+    if (this->handle_ != INVALID_HANDLE_VALUE) {
       CloseHandle(this->handle_);
-      }
     }
+  }
   operator bool() const { return this->handle_ != INVALID_HANDLE_VALUE; }
-  bool operator !() const { return this->handle_ == INVALID_HANDLE_VALUE; }
+  bool operator!() const { return this->handle_ == INVALID_HANDLE_VALUE; }
   operator HANDLE() const { return this->handle_; }
 private:
   HANDLE handle_;
@@ -176,39 +175,33 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64 view)
   cmsys::RegularExpression regEntry("\\[(HKEY[^]]*)\\]");
 
   // check for black line or comment
-  while (regEntry.find(source))
-    {
+  while (regEntry.find(source)) {
     // the arguments are the second match
     std::string key = regEntry.match(1);
     std::string val;
-    if (ReadRegistryValue(key.c_str(), val, view))
-      {
+    if (ReadRegistryValue(key.c_str(), val, view)) {
       std::string reg = "[";
       reg += key + "]";
       cmSystemTools::ReplaceString(source, reg.c_str(), val.c_str());
-      }
-    else
-      {
+    } else {
       std::string reg = "[";
       reg += key + "]";
       cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
-      }
     }
+  }
 }
 #else
 void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64)
 {
   cmsys::RegularExpression regEntry("\\[(HKEY[^]]*)\\]");
-  while (regEntry.find(source))
-    {
+  while (regEntry.find(source)) {
     // the arguments are the second match
     std::string key = regEntry.match(1);
     std::string val;
     std::string reg = "[";
     reg += key + "]";
     cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
-    }
-
+  }
 }
 #endif
 
@@ -216,14 +209,12 @@ std::string cmSystemTools::EscapeQuotes(const std::string& str)
 {
   std::string result;
   result.reserve(str.size());
-  for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
-    {
-    if(*ch == '"')
-      {
+  for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
+    if (*ch == '"') {
       result += '\\';
-      }
-    result += *ch;
     }
+    result += *ch;
+  }
   return result;
 }
 
@@ -242,34 +233,30 @@ std::string cmSystemTools::TrimWhitespace(const std::string& s)
   if (start == s.end())
     return "";
 
-  std::string::const_iterator stop = s.end()-1;
+  std::string::const_iterator stop = s.end() - 1;
   while (cm_isspace(*stop))
     --stop;
-  return std::string(start, stop+1);
+  return std::string(start, stop + 1);
 }
 
-void cmSystemTools::Error(const char* m1, const char* m2,
-                          const char* m3, const char* m4)
+void cmSystemTools::Error(const char* m1, const char* m2, const char* m3,
+                          const char* m4)
 {
   std::string message = "CMake Error: ";
-  if(m1)
-    {
+  if (m1) {
     message += m1;
-    }
-  if(m2)
-    {
+  }
+  if (m2) {
     message += m2;
-    }
-  if(m3)
-    {
+  }
+  if (m3) {
     message += m3;
-    }
-  if(m4)
-    {
+  }
+  if (m4) {
     message += m4;
-    }
+  }
   cmSystemTools::s_ErrorOccured = true;
-  cmSystemTools::Message(message.c_str(),"Error");
+  cmSystemTools::Message(message.c_str(), "Error");
 }
 
 void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData)
@@ -280,10 +267,9 @@ void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData)
 
 bool cmSystemTools::GetInterruptFlag()
 {
-  if(s_InterruptCallback)
-    {
+  if (s_InterruptCallback) {
     return (*s_InterruptCallback)(s_InterruptCallbackClientData);
-    }
+  }
   return false;
 }
 
@@ -317,50 +303,38 @@ void cmSystemTools::Stderr(const char* s)
 
 void cmSystemTools::Stderr(const char* s, size_t length)
 {
-  if(s_StderrCallback)
-    {
+  if (s_StderrCallback) {
     (*s_StderrCallback)(s, length, s_StderrCallbackClientData);
-    }
-  else
-    {
+  } else {
     std::cerr.write(s, length);
     std::cerr.flush();
-    }
+  }
 }
 
 void cmSystemTools::Stdout(const char* s, size_t length)
 {
-  if(s_StdoutCallback)
-    {
+  if (s_StdoutCallback) {
     (*s_StdoutCallback)(s, length, s_StdoutCallbackClientData);
-    }
-  else
-    {
+  } else {
     std::cout.write(s, length);
     std::cout.flush();
-    }
+  }
 }
 
-void cmSystemTools::Message(const char* m1, const char *title)
+void cmSystemTools::Message(const char* m1, const char* title)
 {
-  if(s_DisableMessages)
-    {
+  if (s_DisableMessages) {
     return;
-    }
-  if(s_MessageCallback)
-    {
+  }
+  if (s_MessageCallback) {
     (*s_MessageCallback)(m1, title, s_DisableMessages,
                          s_MessageCallbackClientData);
     return;
-    }
-  else
-    {
+  } else {
     std::cerr << m1 << std::endl << std::flush;
-    }
-
+  }
 }
 
-
 void cmSystemTools::ReportLastSystemError(const char* msg)
 {
   std::string m = msg;
@@ -371,98 +345,81 @@ void cmSystemTools::ReportLastSystemError(const char* msg)
 
 bool cmSystemTools::IsInternallyOn(const char* val)
 {
-  if (!val)
-    {
+  if (!val) {
     return false;
-    }
+  }
   std::basic_string<char> v = val;
-  if (v.size() > 4)
-    {
+  if (v.size() > 4) {
     return false;
-    }
+  }
 
-  for(std::basic_string<char>::iterator c = v.begin();
-      c != v.end(); c++)
-    {
+  for (std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) {
     *c = static_cast<char>(toupper(*c));
-    }
+  }
   return v == "I_ON";
 }
 
 bool cmSystemTools::IsOn(const char* val)
 {
-  if (!val)
-    {
+  if (!val) {
     return false;
-    }
+  }
   size_t len = strlen(val);
-  if (len > 4)
-    {
+  if (len > 4) {
     return false;
-    }
+  }
   std::basic_string<char> v(val, len);
 
   static std::set<std::string> onValues;
-  if(onValues.empty())
-    {
+  if (onValues.empty()) {
     onValues.insert("ON");
     onValues.insert("1");
     onValues.insert("YES");
     onValues.insert("TRUE");
     onValues.insert("Y");
-    }
-  for(std::basic_string<char>::iterator c = v.begin();
-      c != v.end(); c++)
-    {
+  }
+  for (std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) {
     *c = static_cast<char>(toupper(*c));
-    }
+  }
   return (onValues.count(v) > 0);
 }
 
 bool cmSystemTools::IsNOTFOUND(const char* val)
 {
-  if(strcmp(val, "NOTFOUND") == 0)
-    {
+  if (strcmp(val, "NOTFOUND") == 0) {
     return true;
-    }
+  }
   return cmHasLiteralSuffix(val, "-NOTFOUND");
 }
 
-
 bool cmSystemTools::IsOff(const char* val)
 {
-  if (!val || !*val)
-    {
+  if (!val || !*val) {
     return true;
-    }
+  }
   size_t len = strlen(val);
   // Try and avoid toupper() for large strings.
-  if (len > 6)
-    {
+  if (len > 6) {
     return cmSystemTools::IsNOTFOUND(val);
-    }
+  }
 
   static std::set<std::string> offValues;
-  if(offValues.empty())
-    {
+  if (offValues.empty()) {
     offValues.insert("OFF");
     offValues.insert("0");
     offValues.insert("NO");
     offValues.insert("FALSE");
     offValues.insert("N");
     offValues.insert("IGNORE");
-    }
+  }
   // Try and avoid toupper().
   std::basic_string<char> v(val, len);
-  for(std::basic_string<char>::iterator c = v.begin();
-      c != v.end(); c++)
-    {
+  for (std::basic_string<char>::iterator c = v.begin(); c != v.end(); c++) {
     *c = static_cast<char>(toupper(*c));
-    }
+  }
   return (offValues.count(v) > 0);
 }
 
-//----------------------------------------------------------------------------
 void cmSystemTools::ParseWindowsCommandLine(const char* command,
                                             std::vector<std::string>& args)
 {
@@ -474,88 +431,72 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command,
   bool in_quotes = false;
   int backslashes = 0;
   std::string arg;
-  for(const char* c = command;*c; ++c)
-    {
-    if(*c == '\\')
-      {
+  for (const char* c = command; *c; ++c) {
+    if (*c == '\\') {
       ++backslashes;
       in_argument = true;
-      }
-    else if(*c == '"')
-      {
-      int backslash_pairs  = backslashes >> 1;
+    } else if (*c == '"') {
+      int backslash_pairs = backslashes >> 1;
       int backslash_escaped = backslashes & 1;
       arg.append(backslash_pairs, '\\');
       backslashes = 0;
-      if(backslash_escaped)
-        {
+      if (backslash_escaped) {
         /* An odd number of backslashes precede this quote.
            It is escaped.  */
         arg.append(1, '"');
-        }
-      else
-        {
+      } else {
         /* An even number of backslashes precede this quote.
            It is not escaped.  */
         in_quotes = !in_quotes;
-        }
-      in_argument = true;
       }
-    else
-      {
+      in_argument = true;
+    } else {
       arg.append(backslashes, '\\');
       backslashes = 0;
-      if (cm_isspace(*c))
-        {
-        if(in_quotes)
-          {
+      if (cm_isspace(*c)) {
+        if (in_quotes) {
           arg.append(1, *c);
-          }
-        else if(in_argument)
-          {
+        } else if (in_argument) {
           args.push_back(arg);
           arg = "";
           in_argument = false;
-          }
         }
-      else
-        {
+      } else {
         in_argument = true;
         arg.append(1, *c);
-        }
       }
     }
+  }
   arg.append(backslashes, '\\');
-  if(in_argument)
-    {
+  if (in_argument) {
     args.push_back(arg);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 class cmSystemToolsArgV
 {
   char** ArgV;
+
 public:
-  cmSystemToolsArgV(char** argv): ArgV(argv) {}
+  cmSystemToolsArgV(char** argv)
+    : ArgV(argv)
+  {
+  }
   ~cmSystemToolsArgV()
-    {
-    for(char** arg = this->ArgV; arg && *arg; ++arg)
-      {
+  {
+    for (char** arg = this->ArgV; arg && *arg; ++arg) {
       free(*arg);
-      }
-    free(this->ArgV);
     }
+    free(this->ArgV);
+  }
   void Store(std::vector<std::string>& args) const
-    {
-    for(char** arg = this->ArgV; arg && *arg; ++arg)
-      {
+  {
+    for (char** arg = this->ArgV; arg && *arg; ++arg) {
       args.push_back(*arg);
-      }
     }
+  }
 };
 
-//----------------------------------------------------------------------------
 void cmSystemTools::ParseUnixCommandLine(const char* command,
                                          std::vector<std::string>& args)
 {
@@ -572,117 +513,93 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
   bool win_path = false;
 
   if ((command[0] != '/' && command[1] == ':' && command[2] == '\\') ||
-      (command[0] == '\"' && command[1] != '/' && command[2] == ':'
-       && command[3] == '\\') ||
-      (command[0] == '\'' && command[1] != '/' && command[2] == ':'
-       && command[3] == '\\') ||
-      (command[0] == '\\' && command[1] == '\\'))
-    {
+      (command[0] == '\"' && command[1] != '/' && command[2] == ':' &&
+       command[3] == '\\') ||
+      (command[0] == '\'' && command[1] != '/' && command[2] == ':' &&
+       command[3] == '\\') ||
+      (command[0] == '\\' && command[1] == '\\')) {
     win_path = true;
-    }
+  }
   // Split the command into an argv array.
-  for(const char* c = command; *c;)
-    {
+  for (const char* c = command; *c;) {
     // Skip over whitespace.
-    while(*c == ' ' || *c == '\t')
-      {
+    while (*c == ' ' || *c == '\t') {
       ++c;
-      }
+    }
     arg = "";
-    if(*c == '"')
-      {
+    if (*c == '"') {
       // Parse a quoted argument.
       ++c;
-      while(*c && *c != '"')
-        {
+      while (*c && *c != '"') {
         arg.append(1, *c);
         ++c;
-        }
-      if(*c)
-        {
+      }
+      if (*c) {
         ++c;
-        }
-      args.push_back(arg);
       }
-    else if(*c == '\'')
-      {
+      args.push_back(arg);
+    } else if (*c == '\'') {
       // Parse a quoted argument.
       ++c;
-      while(*c && *c != '\'')
-        {
+      while (*c && *c != '\'') {
         arg.append(1, *c);
         ++c;
-        }
-      if(*c)
-        {
+      }
+      if (*c) {
         ++c;
-        }
-      args.push_back(arg);
       }
-    else if(*c)
-      {
+      args.push_back(arg);
+    } else if (*c) {
       // Parse an unquoted argument.
-      while(*c && *c != ' ' && *c != '\t')
-        {
-        if(*c == '\\' && !win_path)
-          {
+      while (*c && *c != ' ' && *c != '\t') {
+        if (*c == '\\' && !win_path) {
           ++c;
-          if(*c)
-            {
+          if (*c) {
             arg.append(1, *c);
             ++c;
-            }
           }
-        else
-          {
+        } else {
           arg.append(1, *c);
           ++c;
-          }
         }
-      args.push_back(arg);
       }
+      args.push_back(arg);
     }
+  }
 
   return args;
 }
 
-
-bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
+bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
                                      std::string* captureStdOut,
-                                     std::string* captureStdErr,
-                                     int* retVal , const char* dir ,
-                                     OutputOption outputflag ,
-                                     double timeout )
+                                     std::string* captureStdErr, int* retVal,
+                                     const char* dir, OutputOption outputflag,
+                                     double timeout)
 {
   std::vector<const char*> argv;
-  for(std::vector<std::string>::const_iterator a = command.begin();
-      a != command.end(); ++a)
-    {
+  for (std::vector<std::string>::const_iterator a = command.begin();
+       a != command.end(); ++a) {
     argv.push_back(a->c_str());
-    }
+  }
   argv.push_back(0);
 
   cmsysProcess* cp = cmsysProcess_New();
   cmsysProcess_SetCommand(cp, &*argv.begin());
   cmsysProcess_SetWorkingDirectory(cp, dir);
-  if(cmSystemTools::GetRunCommandHideConsole())
-    {
+  if (cmSystemTools::GetRunCommandHideConsole()) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
-    }
+  }
 
-  if (outputflag == OUTPUT_PASSTHROUGH)
-    {
+  if (outputflag == OUTPUT_PASSTHROUGH) {
     cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
     cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
     captureStdOut = 0;
     captureStdErr = 0;
-    }
-  else if (outputflag == OUTPUT_MERGE ||
-           (captureStdErr && captureStdErr == captureStdOut))
-    {
+  } else if (outputflag == OUTPUT_MERGE ||
+             (captureStdErr && captureStdErr == captureStdOut)) {
     cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
     captureStdErr = 0;
-    }
+  }
   assert(!captureStdErr || captureStdErr != captureStdOut);
 
   cmsysProcess_SetTimeout(cp, timeout);
@@ -693,193 +610,152 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
   char* data;
   int length;
   int pipe;
-  if(outputflag != OUTPUT_PASSTHROUGH &&
-     (captureStdOut || captureStdErr || outputflag != OUTPUT_NONE))
-    {
-    while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0)
-      {
+  if (outputflag != OUTPUT_PASSTHROUGH &&
+      (captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)) {
+    while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0) {
       // Translate NULL characters in the output into valid text.
       // Visual Studio 7 puts these characters in the output of its
       // build process.
-      for(int i=0; i < length; ++i)
-        {
-        if(data[i] == '\0')
-          {
+      for (int i = 0; i < length; ++i) {
+        if (data[i] == '\0') {
           data[i] = ' ';
-          }
         }
+      }
 
-      if (pipe == cmsysProcess_Pipe_STDOUT)
-        {
-        if (outputflag != OUTPUT_NONE)
-          {
+      if (pipe == cmsysProcess_Pipe_STDOUT) {
+        if (outputflag != OUTPUT_NONE) {
           cmSystemTools::Stdout(data, length);
-          }
-        if (captureStdOut)
-          {
-          tempStdOut.insert(tempStdOut.end(), data, data+length);
-          }
         }
-      else if (pipe == cmsysProcess_Pipe_STDERR)
-        {
-        if (outputflag != OUTPUT_NONE)
-          {
+        if (captureStdOut) {
+          tempStdOut.insert(tempStdOut.end(), data, data + length);
+        }
+      } else if (pipe == cmsysProcess_Pipe_STDERR) {
+        if (outputflag != OUTPUT_NONE) {
           cmSystemTools::Stderr(data, length);
-          }
-        if (captureStdErr)
-          {
-          tempStdErr.insert(tempStdErr.end(), data, data+length);
-          }
+        }
+        if (captureStdErr) {
+          tempStdErr.insert(tempStdErr.end(), data, data + length);
         }
       }
     }
+  }
 
   cmsysProcess_WaitForExit(cp, 0);
-  if (captureStdOut)
-    {
+  if (captureStdOut) {
     captureStdOut->assign(tempStdOut.begin(), tempStdOut.end());
-    }
-  if (captureStdErr)
-    {
+  }
+  if (captureStdErr) {
     captureStdErr->assign(tempStdErr.begin(), tempStdErr.end());
-    }
+  }
 
   bool result = true;
-  if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
-    {
-    if ( retVal )
-      {
+  if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
+    if (retVal) {
       *retVal = cmsysProcess_GetExitValue(cp);
-      }
-    else
-      {
-      if ( cmsysProcess_GetExitValue(cp) !=  0 )
-        {
+    } else {
+      if (cmsysProcess_GetExitValue(cp) != 0) {
         result = false;
-        }
       }
     }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
-    {
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
     const char* exception_str = cmsysProcess_GetExceptionString(cp);
-    if ( outputflag != OUTPUT_NONE )
-      {
+    if (outputflag != OUTPUT_NONE) {
       std::cerr << exception_str << std::endl;
-      }
-    if ( captureStdErr )
-      {
+    }
+    if (captureStdErr) {
       captureStdErr->append(exception_str, strlen(exception_str));
-      }
-    result = false;
     }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
-    {
+    result = false;
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
     const char* error_str = cmsysProcess_GetErrorString(cp);
-    if ( outputflag != OUTPUT_NONE )
-      {
+    if (outputflag != OUTPUT_NONE) {
       std::cerr << error_str << std::endl;
-      }
-    if ( captureStdErr )
-      {
+    }
+    if (captureStdErr) {
       captureStdErr->append(error_str, strlen(error_str));
-      }
-    result = false;
     }
-  else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
-    {
+    result = false;
+  } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
     const char* error_str = "Process terminated due to timeout\n";
-    if ( outputflag != OUTPUT_NONE )
-      {
+    if (outputflag != OUTPUT_NONE) {
       std::cerr << error_str << std::endl;
-      }
-    if ( captureStdErr )
-      {
+    }
+    if (captureStdErr) {
       captureStdErr->append(error_str, strlen(error_str));
-      }
-    result = false;
     }
+    result = false;
+  }
 
   cmsysProcess_Delete(cp);
   return result;
 }
 
-bool cmSystemTools::RunSingleCommand(
-  const char* command,
-  std::string* captureStdOut,
-  std::string* captureStdErr,
-  int *retVal,
-  const char* dir,
-  OutputOption outputflag,
-  double timeout)
+bool cmSystemTools::RunSingleCommand(const char* command,
+                                     std::string* captureStdOut,
+                                     std::string* captureStdErr, int* retVal,
+                                     const char* dir, OutputOption outputflag,
+                                     double timeout)
 {
-  if(s_DisableRunCommandOutput)
-    {
+  if (s_DisableRunCommandOutput) {
     outputflag = OUTPUT_NONE;
-    }
+  }
 
   std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     return false;
-    }
+  }
   return cmSystemTools::RunSingleCommand(args, captureStdOut, captureStdErr,
                                          retVal, dir, outputflag, timeout);
 }
 
-std::string
-cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command)
+std::string cmSystemTools::PrintSingleCommand(
+  std::vector<std::string> const& command)
 {
-  if (command.empty())
-    {
+  if (command.empty()) {
     return std::string();
-    }
+  }
 
   return cmWrap('"', command, '"', " ");
 }
 
 bool cmSystemTools::DoesFileExistWithExtensions(
-  const char* name,
-  const std::vector<std::string>& headerExts)
+  const char* name, const std::vector<std::string>& headerExts)
 {
   std::string hname;
 
-  for( std::vector<std::string>::const_iterator ext = headerExts.begin();
-       ext != headerExts.end(); ++ext )
-    {
+  for (std::vector<std::string>::const_iterator ext = headerExts.begin();
+       ext != headerExts.end(); ++ext) {
     hname = name;
     hname += ".";
     hname += *ext;
-    if(cmSystemTools::FileExists(hname.c_str()))
-      {
+    if (cmSystemTools::FileExists(hname.c_str())) {
       return true;
-      }
     }
+  }
   return false;
 }
 
 std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
-  const char* directory, const char* toplevel)
+                                                         const char* directory,
+                                                         const char* toplevel)
 {
   std::string file = fname;
   cmSystemTools::ConvertToUnixSlashes(file);
   std::string dir = directory;
   cmSystemTools::ConvertToUnixSlashes(dir);
   std::string prevDir;
-  while(dir != prevDir)
-    {
+  while (dir != prevDir) {
     std::string path = dir + "/" + file;
-    if ( cmSystemTools::FileExists(path.c_str()) )
-      {
+    if (cmSystemTools::FileExists(path.c_str())) {
       return path;
-      }
-    if ( dir.size() < strlen(toplevel) )
-      {
+    }
+    if (dir.size() < strlen(toplevel)) {
       break;
-      }
+    }
     prevDir = dir;
     dir = cmSystemTools::GetParentDirectory(dir);
-    }
+  }
   return "";
 }
 
@@ -889,90 +765,78 @@ bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
 }
 
 bool cmSystemTools::CopyFileIfDifferent(const char* source,
-  const char* destination)
+                                        const char* destination)
 {
   return Superclass::CopyFileIfDifferent(source, destination);
 }
 
-//----------------------------------------------------------------------------
 #ifdef _WIN32
 cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
 {
-  static WindowsFileRetry retry = {0,0};
-  if(!retry.Count)
-    {
-    unsigned int data[2] = {0,0};
-    HKEY const keys[2] = {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE};
-    wchar_t const* const values[2] = {L"FilesystemRetryCount",
-                                      L"FilesystemRetryDelay"};
-    for(int k=0; k < 2; ++k)
-      {
+  static WindowsFileRetry retry = { 0, 0 };
+  if (!retry.Count) {
+    unsigned int data[2] = { 0, 0 };
+    HKEY const keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
+    wchar_t const* const values[2] = { L"FilesystemRetryCount",
+                                       L"FilesystemRetryDelay" };
+    for (int k = 0; k < 2; ++k) {
       HKEY hKey;
-      if(RegOpenKeyExW(keys[k], L"Software\\Kitware\\CMake\\Config",
-                       0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
-        {
-        for(int v=0; v < 2; ++v)
-          {
+      if (RegOpenKeyExW(keys[k], L"Software\\Kitware\\CMake\\Config", 0,
+                        KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
+        for (int v = 0; v < 2; ++v) {
           DWORD dwData, dwType, dwSize = 4;
-          if(!data[v] &&
-             RegQueryValueExW(hKey, values[v], 0, &dwType, (BYTE *)&dwData,
-                              &dwSize) == ERROR_SUCCESS &&
-             dwType == REG_DWORD && dwSize == 4)
-            {
+          if (!data[v] &&
+              RegQueryValueExW(hKey, values[v], 0, &dwType, (BYTE*)&dwData,
+                               &dwSize) == ERROR_SUCCESS &&
+              dwType == REG_DWORD && dwSize == 4) {
             data[v] = static_cast<unsigned int>(dwData);
-            }
           }
-        RegCloseKey(hKey);
         }
+        RegCloseKey(hKey);
       }
-    retry.Count = data[0]? data[0] : 5;
-    retry.Delay = data[1]? data[1] : 500;
     }
+    retry.Count = data[0] ? data[0] : 5;
+    retry.Delay = data[1] ? data[1] : 500;
+  }
   return retry;
 }
 #endif
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
 {
 #ifdef _WIN32
-# ifndef INVALID_FILE_ATTRIBUTES
-#  define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
-# endif
+#ifndef INVALID_FILE_ATTRIBUTES
+#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+#endif
   /* Windows MoveFileEx may not replace read-only or in-use files.  If it
      fails then remove the read-only attribute from any existing destination.
      Try multiple times since we may be racing against another process
      creating/opening the destination file just before our MoveFileEx.  */
   WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry();
-  while(!MoveFileExW(
-      SystemTools::ConvertToWindowsExtendedPath(oldname).c_str(),
-      SystemTools::ConvertToWindowsExtendedPath(newname).c_str(),
-                     MOVEFILE_REPLACE_EXISTING) && --retry.Count)
-    {
+  while (
+    !MoveFileExW(SystemTools::ConvertToWindowsExtendedPath(oldname).c_str(),
+                 SystemTools::ConvertToWindowsExtendedPath(newname).c_str(),
+                 MOVEFILE_REPLACE_EXISTING) &&
+    --retry.Count) {
     DWORD last_error = GetLastError();
     // Try again only if failure was due to access/sharing permissions.
-    if(last_error != ERROR_ACCESS_DENIED &&
-       last_error != ERROR_SHARING_VIOLATION)
-      {
+    if (last_error != ERROR_ACCESS_DENIED &&
+        last_error != ERROR_SHARING_VIOLATION) {
       return false;
-      }
-    DWORD attrs =
-      GetFileAttributesW(
-        SystemTools::ConvertToWindowsExtendedPath(newname).c_str());
-    if((attrs != INVALID_FILE_ATTRIBUTES) &&
-       (attrs & FILE_ATTRIBUTE_READONLY))
-      {
+    }
+    DWORD attrs = GetFileAttributesW(
+      SystemTools::ConvertToWindowsExtendedPath(newname).c_str());
+    if ((attrs != INVALID_FILE_ATTRIBUTES) &&
+        (attrs & FILE_ATTRIBUTE_READONLY)) {
       // Remove the read-only attribute from the destination file.
       SetFileAttributesW(
         SystemTools::ConvertToWindowsExtendedPath(newname).c_str(),
-                         attrs & ~FILE_ATTRIBUTE_READONLY);
-      }
-    else
-      {
+        attrs & ~FILE_ATTRIBUTE_READONLY);
+    } else {
       // The file may be temporarily in use so wait a bit.
       cmSystemTools::Delay(retry.Delay);
-      }
     }
+  }
   return retry.Count > 0;
 #else
   /* On UNIX we have an OS-provided call to do this atomically.  */
@@ -990,7 +854,8 @@ bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out)
 #else
   (void)source;
   (void)md5out;
-  cmSystemTools::Message("md5sum not supported in bootstrapping mode","Error");
+  cmSystemTools::Message("md5sum not supported in bootstrapping mode",
+                         "Error");
   return false;
 #endif
 }
@@ -1002,12 +867,12 @@ std::string cmSystemTools::ComputeStringMD5(const std::string& input)
   return md5.HashString(input);
 #else
   (void)input;
-  cmSystemTools::Message("md5sum not supported in bootstrapping mode","Error");
+  cmSystemTools::Message("md5sum not supported in bootstrapping mode",
+                         "Error");
   return "";
 #endif
 }
 
-//----------------------------------------------------------------------------
 std::string cmSystemTools::ComputeCertificateThumbprint(
   const std::string& source)
 {
@@ -1019,42 +884,29 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
   HCERTSTORE certStore = NULL;
   PCCERT_CONTEXT certContext = NULL;
 
-  HANDLE certFile =
-    CreateFileW(cmsys::Encoding::ToWide(source.c_str()).c_str(),
-                GENERIC_READ,
-                FILE_SHARE_READ,
-                NULL,
-                OPEN_EXISTING,
-                FILE_ATTRIBUTE_NORMAL,
-                NULL);
-
-  if (certFile != INVALID_HANDLE_VALUE && certFile != NULL)
-    {
+  HANDLE certFile = CreateFileW(
+    cmsys::Encoding::ToWide(source.c_str()).c_str(), GENERIC_READ,
+    FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+  if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) {
     DWORD fileSize = GetFileSize(certFile, NULL);
-    if (fileSize != INVALID_FILE_SIZE)
-      {
+    if (fileSize != INVALID_FILE_SIZE) {
       certData = new BYTE[fileSize];
-      if (certData != NULL)
-        {
+      if (certData != NULL) {
         DWORD dwRead = 0;
-        if (ReadFile(certFile, certData, fileSize, &dwRead, NULL))
-          {
+        if (ReadFile(certFile, certData, fileSize, &dwRead, NULL)) {
           cryptBlob.cbData = fileSize;
           cryptBlob.pbData = certData;
 
           // Verify that this is a valid cert
-          if (PFXIsPFXBlob(&cryptBlob))
-            {
+          if (PFXIsPFXBlob(&cryptBlob)) {
             // Open the certificate as a store
-            certStore = PFXImportCertStore(
-              &cryptBlob, NULL, CRYPT_EXPORTABLE);
-            if (certStore != NULL)
-              {
+            certStore = PFXImportCertStore(&cryptBlob, NULL, CRYPT_EXPORTABLE);
+            if (certStore != NULL) {
               // There should only be 1 cert.
-              certContext = CertEnumCertificatesInStore(certStore,
-                certContext);
-              if (certContext != NULL)
-                {
+              certContext =
+                CertEnumCertificatesInStore(certStore, certContext);
+              if (certContext != NULL) {
                 // The hash is 20 bytes
                 BYTE hashData[20];
                 DWORD hashLength = 20;
@@ -1062,35 +914,33 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
                 // Buffer to print the hash. Each byte takes 2 chars +
                 // terminating character
                 char hashPrint[41];
-                char *pHashPrint = hashPrint;
+                char* pHashPrint = hashPrint;
                 // Get the hash property from the certificate
-                if (CertGetCertificateContextProperty(certContext,
-                  CERT_HASH_PROP_ID, hashData, &hashLength))
-                  {
-                  for (DWORD i = 0; i < hashLength; i++)
-                    {
+                if (CertGetCertificateContextProperty(
+                      certContext, CERT_HASH_PROP_ID, hashData, &hashLength)) {
+                  for (DWORD i = 0; i < hashLength; i++) {
                     // Convert each byte to hexadecimal
                     sprintf(pHashPrint, "%02X", hashData[i]);
                     pHashPrint += 2;
-                    }
+                  }
                   *pHashPrint = '\0';
                   thumbprint = hashPrint;
-                  }
-                CertFreeCertificateContext(certContext);
                 }
-              CertCloseStore(certStore, 0);
+                CertFreeCertificateContext(certContext);
               }
+              CertCloseStore(certStore, 0);
             }
           }
-        delete[] certData;
         }
+        delete[] certData;
       }
-    CloseHandle(certFile);
     }
+    CloseHandle(certFile);
+  }
 #else
   (void)source;
   cmSystemTools::Message("ComputeCertificateThumbprint is not implemented",
-    "Error");
+                         "Error");
 #endif
 
   return thumbprint;
@@ -1103,65 +953,54 @@ void cmSystemTools::Glob(const std::string& directory,
   cmsys::Directory d;
   cmsys::RegularExpression reg(regexp.c_str());
 
-  if (d.Load(directory))
-    {
+  if (d.Load(directory)) {
     size_t numf;
-        unsigned int i;
+    unsigned int i;
     numf = d.GetNumberOfFiles();
-    for (i = 0; i < numf; i++)
-      {
+    for (i = 0; i < numf; i++) {
       std::string fname = d.GetFile(i);
-      if (reg.find(fname))
-        {
+      if (reg.find(fname)) {
         files.push_back(fname);
-        }
       }
     }
+  }
 }
 
-
 void cmSystemTools::GlobDirs(const std::string& path,
                              std::vector<std::string>& files)
 {
   std::string::size_type pos = path.find("/*");
-  if(pos == std::string::npos)
-    {
+  if (pos == std::string::npos) {
     files.push_back(path);
     return;
-    }
+  }
   std::string startPath = path.substr(0, pos);
-  std::string finishPath = path.substr(pos+2);
+  std::string finishPath = path.substr(pos + 2);
 
   cmsys::Directory d;
-  if (d.Load(startPath))
-    {
-    for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i)
-      {
-      if((std::string(d.GetFile(i)) != ".")
-         && (std::string(d.GetFile(i)) != ".."))
-        {
+  if (d.Load(startPath)) {
+    for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i) {
+      if ((std::string(d.GetFile(i)) != ".") &&
+          (std::string(d.GetFile(i)) != "..")) {
         std::string fname = startPath;
-        fname +="/";
+        fname += "/";
         fname += d.GetFile(i);
-        if(cmSystemTools::FileIsDirectory(fname))
-          {
+        if (cmSystemTools::FileIsDirectory(fname)) {
           fname += finishPath;
           cmSystemTools::GlobDirs(fname, files);
-          }
         }
       }
     }
+  }
 }
 
-
 void cmSystemTools::ExpandList(std::vector<std::string> const& arguments,
                                std::vector<std::string>& newargs)
 {
   std::vector<std::string>::const_iterator i;
-  for(i = arguments.begin();i != arguments.end(); ++i)
-    {
+  for (i = arguments.begin(); i != arguments.end(); ++i) {
     cmSystemTools::ExpandListArgument(*i, newargs);
-    }
+  }
 }
 
 void cmSystemTools::ExpandListArgument(const std::string& arg,
@@ -1169,73 +1008,60 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
                                        bool emptyArgs)
 {
   // If argument is empty, it is an empty list.
-  if(!emptyArgs && arg.empty())
-    {
+  if (!emptyArgs && arg.empty()) {
     return;
-    }
+  }
   // if there are no ; in the name then just copy the current string
-  if(arg.find(';') == std::string::npos)
-    {
+  if (arg.find(';') == std::string::npos) {
     newargs.push_back(arg);
     return;
-    }
+  }
   std::string newArg;
-  const char *last = arg.c_str();
+  const char* last = arg.c_str();
   // Break the string at non-escaped semicolons not nested in [].
   int squareNesting = 0;
-  for(const char* c = last; *c; ++c)
-    {
-    switch(*c)
-      {
-      case '\\':
-        {
+  for (const char* c = last; *c; ++c) {
+    switch (*c) {
+      case '\\': {
         // We only want to allow escaping of semicolons.  Other
         // escapes should not be processed here.
         const char* next = c + 1;
-        if(*next == ';')
-          {
+        if (*next == ';') {
           newArg.append(last, c - last);
           // Skip over the escape character
           last = c = next;
-          }
-        } break;
-      case '[':
-        {
+        }
+      } break;
+      case '[': {
         ++squareNesting;
-        } break;
-      case ']':
-        {
+      } break;
+      case ']': {
         --squareNesting;
-        } break;
-      case ';':
-        {
+      } break;
+      case ';': {
         // Break the string here if we are not nested inside square
         // brackets.
-        if(squareNesting == 0)
-          {
+        if (squareNesting == 0) {
           newArg.append(last, c - last);
           // Skip over the semicolon
           last = c + 1;
-          if ( !newArg.empty() || emptyArgs )
-            {
+          if (!newArg.empty() || emptyArgs) {
             // Add the last argument if the string is not empty.
             newargs.push_back(newArg);
             newArg = "";
-            }
           }
-        } break;
-      default:
-        {
+        }
+      } break;
+      default: {
         // Just append this character.
-        } break;
-      }
+      } break;
     }
+  }
   newArg.append(last);
-  if ( !newArg.empty() || emptyArgs )
-    {
+  if (!newArg.empty() || emptyArgs) {
     // Add the last argument if the string is not empty.
     newargs.push_back(newArg);
-    }
+  }
 }
 
 bool cmSystemTools::SimpleGlob(const std::string& glob,
@@ -1243,116 +1069,99 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
                                int type /* = 0 */)
 {
   files.clear();
-  if ( glob[glob.size()-1] != '*' )
-    {
+  if (glob[glob.size() - 1] != '*') {
     return false;
-    }
+  }
   std::string path = cmSystemTools::GetFilenamePath(glob);
   std::string ppath = cmSystemTools::GetFilenameName(glob);
-  ppath = ppath.substr(0, ppath.size()-1);
-  if (path.empty())
-    {
+  ppath = ppath.substr(0, ppath.size() - 1);
+  if (path.empty()) {
     path = "/";
-    }
+  }
 
   bool res = false;
   cmsys::Directory d;
-  if (d.Load(path))
-    {
-    for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i)
-      {
-      if((std::string(d.GetFile(i)) != ".")
-         && (std::string(d.GetFile(i)) != ".."))
-        {
+  if (d.Load(path)) {
+    for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i) {
+      if ((std::string(d.GetFile(i)) != ".") &&
+          (std::string(d.GetFile(i)) != "..")) {
         std::string fname = path;
-        if ( path[path.size()-1] != '/' )
-          {
-          fname +="/";
-          }
+        if (path[path.size() - 1] != '/') {
+          fname += "/";
+        }
         fname += d.GetFile(i);
         std::string sfname = d.GetFile(i);
-        if ( type > 0 && cmSystemTools::FileIsDirectory(fname) )
-          {
+        if (type > 0 && cmSystemTools::FileIsDirectory(fname)) {
           continue;
-          }
-        if ( type < 0 && !cmSystemTools::FileIsDirectory(fname) )
-          {
+        }
+        if (type < 0 && !cmSystemTools::FileIsDirectory(fname)) {
           continue;
-          }
-        if ( sfname.size() >= ppath.size() &&
-             sfname.substr(0, ppath.size()) ==
-             ppath )
-          {
+        }
+        if (sfname.size() >= ppath.size() &&
+            sfname.substr(0, ppath.size()) == ppath) {
           files.push_back(fname);
           res = true;
-          }
         }
       }
     }
+  }
   return res;
 }
 
 cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
 {
-  if ( ! cext || *cext == 0 )
-    {
+  if (!cext || *cext == 0) {
     return cmSystemTools::NO_FILE_FORMAT;
-    }
-  //std::string ext = cmSystemTools::LowerCase(cext);
+  }
+  // std::string ext = cmSystemTools::LowerCase(cext);
   std::string ext = cext;
-  if ( ext == "c" || ext == ".c" ||
-       ext == "m" || ext == ".m"
-    ) { return cmSystemTools::C_FILE_FORMAT; }
-  if (
-    ext == "C" || ext == ".C" ||
-    ext == "M" || ext == ".M" ||
-    ext == "c++" || ext == ".c++" ||
-    ext == "cc" || ext == ".cc" ||
-    ext == "cpp" || ext == ".cpp" ||
-    ext == "cxx" || ext == ".cxx" ||
-    ext == "mm" || ext == ".mm"
-    ) { return cmSystemTools::CXX_FILE_FORMAT; }
-  if (
-    ext == "f" || ext == ".f" ||
-    ext == "F" || ext == ".F" ||
-    ext == "f77" || ext == ".f77" ||
-    ext == "f90" || ext == ".f90" ||
-    ext == "for" || ext == ".for" ||
-    ext == "f95" || ext == ".f95"
-    ) { return cmSystemTools::FORTRAN_FILE_FORMAT; }
-  if ( ext == "java" || ext == ".java" )
-    { return cmSystemTools::JAVA_FILE_FORMAT; }
-  if (
-    ext == "H" || ext == ".H" ||
-    ext == "h" || ext == ".h" ||
-    ext == "h++" || ext == ".h++" ||
-    ext == "hm" || ext == ".hm" ||
-    ext == "hpp" || ext == ".hpp" ||
-    ext == "hxx" || ext == ".hxx" ||
-    ext == "in" || ext == ".in" ||
-    ext == "txx" || ext == ".txx"
-    ) { return cmSystemTools::HEADER_FILE_FORMAT; }
-  if ( ext == "rc" || ext == ".rc" )
-    { return cmSystemTools::RESOURCE_FILE_FORMAT; }
-  if ( ext == "def" || ext == ".def" )
-    { return cmSystemTools::DEFINITION_FILE_FORMAT; }
-  if ( ext == "lib" || ext == ".lib" ||
-       ext == "a" || ext == ".a")
-    { return cmSystemTools::STATIC_LIBRARY_FILE_FORMAT; }
-  if ( ext == "o" || ext == ".o" ||
-       ext == "obj" || ext == ".obj")
-    { return cmSystemTools::OBJECT_FILE_FORMAT; }
+  if (ext == "c" || ext == ".c" || ext == "m" || ext == ".m") {
+    return cmSystemTools::C_FILE_FORMAT;
+  }
+  if (ext == "C" || ext == ".C" || ext == "M" || ext == ".M" || ext == "c++" ||
+      ext == ".c++" || ext == "cc" || ext == ".cc" || ext == "cpp" ||
+      ext == ".cpp" || ext == "cxx" || ext == ".cxx" || ext == "mm" ||
+      ext == ".mm") {
+    return cmSystemTools::CXX_FILE_FORMAT;
+  }
+  if (ext == "f" || ext == ".f" || ext == "F" || ext == ".F" || ext == "f77" ||
+      ext == ".f77" || ext == "f90" || ext == ".f90" || ext == "for" ||
+      ext == ".for" || ext == "f95" || ext == ".f95") {
+    return cmSystemTools::FORTRAN_FILE_FORMAT;
+  }
+  if (ext == "java" || ext == ".java") {
+    return cmSystemTools::JAVA_FILE_FORMAT;
+  }
+  if (ext == "H" || ext == ".H" || ext == "h" || ext == ".h" || ext == "h++" ||
+      ext == ".h++" || ext == "hm" || ext == ".hm" || ext == "hpp" ||
+      ext == ".hpp" || ext == "hxx" || ext == ".hxx" || ext == "in" ||
+      ext == ".in" || ext == "txx" || ext == ".txx") {
+    return cmSystemTools::HEADER_FILE_FORMAT;
+  }
+  if (ext == "rc" || ext == ".rc") {
+    return cmSystemTools::RESOURCE_FILE_FORMAT;
+  }
+  if (ext == "def" || ext == ".def") {
+    return cmSystemTools::DEFINITION_FILE_FORMAT;
+  }
+  if (ext == "lib" || ext == ".lib" || ext == "a" || ext == ".a") {
+    return cmSystemTools::STATIC_LIBRARY_FILE_FORMAT;
+  }
+  if (ext == "o" || ext == ".o" || ext == "obj" || ext == ".obj") {
+    return cmSystemTools::OBJECT_FILE_FORMAT;
+  }
 #ifdef __APPLE__
-  if ( ext == "dylib" || ext == ".dylib" )
-    { return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; }
-  if ( ext == "so" || ext == ".so" ||
-       ext == "bundle" || ext == ".bundle" )
-    { return cmSystemTools::MODULE_FILE_FORMAT; }
-#else // __APPLE__
-  if ( ext == "so" || ext == ".so" ||
-       ext == "sl" || ext == ".sl" ||
-       ext == "dll" || ext == ".dll" )
-    { return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; }
+  if (ext == "dylib" || ext == ".dylib") {
+    return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT;
+  }
+  if (ext == "so" || ext == ".so" || ext == "bundle" || ext == ".bundle") {
+    return cmSystemTools::MODULE_FILE_FORMAT;
+  }
+#else  // __APPLE__
+  if (ext == "so" || ext == ".so" || ext == "sl" || ext == ".sl" ||
+      ext == "dll" || ext == ".dll") {
+    return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT;
+  }
 #endif // __APPLE__
   return cmSystemTools::UNKNOWN_FILE_FORMAT;
 }
@@ -1368,10 +1177,9 @@ bool cmSystemTools::Split(const char* s, std::vector<std::string>& l)
 std::string cmSystemTools::ConvertToOutputPath(const char* path)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  if(s_ForceUnixPaths)
-    {
+  if (s_ForceUnixPaths) {
     return cmSystemTools::ConvertToUnixOutputPath(path);
-    }
+  }
   return cmSystemTools::ConvertToWindowsOutputPath(path);
 #else
   return cmSystemTools::ConvertToUnixOutputPath(path);
@@ -1381,15 +1189,13 @@ std::string cmSystemTools::ConvertToOutputPath(const char* path)
 void cmSystemTools::ConvertToOutputSlashes(std::string& path)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  if(!s_ForceUnixPaths)
-    {
+  if (!s_ForceUnixPaths) {
     // Convert to windows slashes.
     std::string::size_type pos = 0;
-    while((pos = path.find('/', pos)) != std::string::npos)
-      {
+    while ((pos = path.find('/', pos)) != std::string::npos) {
       path[pos++] = '\\';
-      }
     }
+  }
 #else
   static_cast<void>(path);
 #endif
@@ -1407,55 +1213,48 @@ std::string cmSystemTools::ConvertToRunCommandPath(const char* path)
 // compute the relative path from here to there
 std::string cmSystemTools::RelativePath(const char* local, const char* remote)
 {
-  if(!cmSystemTools::FileIsFullPath(local))
-    {
+  if (!cmSystemTools::FileIsFullPath(local)) {
     cmSystemTools::Error("RelativePath must be passed a full path to local: ",
                          local);
-    }
-  if(!cmSystemTools::FileIsFullPath(remote))
-    {
-    cmSystemTools::Error
-      ("RelativePath must be passed a full path to remote: ", remote);
-    }
+  }
+  if (!cmSystemTools::FileIsFullPath(remote)) {
+    cmSystemTools::Error("RelativePath must be passed a full path to remote: ",
+                         remote);
+  }
   return cmsys::SystemTools::RelativePath(local, remote);
 }
 
 std::string cmSystemTools::CollapseCombinedPath(std::string const& dir,
                                                 std::string const& file)
 {
-  if(dir.empty() || dir == ".")
-    {
+  if (dir.empty() || dir == ".") {
     return file;
-    }
+  }
 
   std::vector<std::string> dirComponents;
   std::vector<std::string> fileComponents;
   cmSystemTools::SplitPath(dir, dirComponents);
   cmSystemTools::SplitPath(file, fileComponents);
 
-  if(fileComponents.empty())
-    {
+  if (fileComponents.empty()) {
     return dir;
-    }
-  if(fileComponents[0] != "")
-    {
+  }
+  if (fileComponents[0] != "") {
     // File is not a relative path.
     return file;
-    }
+  }
 
-  std::vector<std::string>::iterator i = fileComponents.begin()+1;
-  while(i != fileComponents.end() && *i == ".." && dirComponents.size() > 1)
-    {
-    ++i; // Remove ".." file component.
+  std::vector<std::string>::iterator i = fileComponents.begin() + 1;
+  while (i != fileComponents.end() && *i == ".." && dirComponents.size() > 1) {
+    ++i;                      // Remove ".." file component.
     dirComponents.pop_back(); // Remove last dir component.
-    }
+  }
 
   dirComponents.insert(dirComponents.end(), i, fileComponents.end());
   return cmSystemTools::JoinPath(dirComponents);
 }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
-//----------------------------------------------------------------------
 bool cmSystemTools::UnsetEnv(const char* value)
 {
 #if !defined(HAVE_UNSETENV)
@@ -1468,52 +1267,44 @@ bool cmSystemTools::UnsetEnv(const char* value)
 #endif
 }
 
-//----------------------------------------------------------------------
 std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
 {
   std::vector<std::string> env;
   int cc;
-  for ( cc = 0; environ[cc]; ++ cc )
-    {
+  for (cc = 0; environ[cc]; ++cc) {
     env.push_back(environ[cc]);
-    }
+  }
   return env;
 }
 
-//----------------------------------------------------------------------
 void cmSystemTools::AppendEnv(std::vector<std::string> const& env)
 {
-  for(std::vector<std::string>::const_iterator eit = env.begin();
-      eit != env.end(); ++eit)
-    {
+  for (std::vector<std::string>::const_iterator eit = env.begin();
+       eit != env.end(); ++eit) {
     cmSystemTools::PutEnv(*eit);
-    }
+  }
 }
 
-//----------------------------------------------------------------------
 cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment()
 {
   this->Env = cmSystemTools::GetEnvironmentVariables();
 }
 
-//----------------------------------------------------------------------
 cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
 {
   // First clear everything in the current environment:
   std::vector<std::string> currentEnv = GetEnvironmentVariables();
-  for(std::vector<std::string>::const_iterator
-        eit = currentEnv.begin(); eit != currentEnv.end(); ++eit)
-    {
+  for (std::vector<std::string>::const_iterator eit = currentEnv.begin();
+       eit != currentEnv.end(); ++eit) {
     std::string var(*eit);
 
-    std::string::size_type pos = var.find("=");
-    if (pos != std::string::npos)
-      {
+    std::string::size_type pos = var.find('=');
+    if (pos != std::string::npos) {
       var = var.substr(0, pos);
-      }
+    }
 
     cmSystemTools::UnsetEnv(var.c_str());
-    }
+  }
 
   // Then put back each entry from the original environment:
   cmSystemTools::AppendEnv(this->Env);
@@ -1532,13 +1323,13 @@ void cmSystemTools::EnableVSConsoleOutput()
   // output and allow it to be captured on the fly.
   cmSystemTools::PutEnv("vsconsoleoutput=1");
 
-# ifdef CMAKE_BUILD_WITH_CMAKE
+#ifdef CMAKE_BUILD_WITH_CMAKE
   // VS sets an environment variable to tell MS tools like "cl" to report
   // output through a backdoor pipe instead of stdout/stderr.  Unset the
   // environment variable to close this backdoor for any path of process
   // invocations that passes through CMake so we can capture the output.
   cmSystemTools::UnsetEnv("VS_UNICODE_OUTPUT");
-# endif
+#endif
 #endif
 }
 
@@ -1550,25 +1341,23 @@ bool cmSystemTools::IsPathToFramework(const char* path)
 
 bool cmSystemTools::CreateTar(const char* outFileName,
                               const std::vector<std::string>& files,
-                              cmTarCompression compressType,
-                              bool verbose, std::string const& mtime,
+                              cmTarCompression compressType, bool verbose,
+                              std::string const& mtime,
                               std::string const& format)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
   cmsys::ofstream fout(outFileName, std::ios::out | std::ios::binary);
-  if(!fout)
-    {
+  if (!fout) {
     std::string e = "Cannot open output file \"";
     e += outFileName;
     e += "\": ";
     e += cmSystemTools::GetLastSystemError();
     cmSystemTools::Error(e.c_str());
     return false;
-    }
+  }
   cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone;
-  switch (compressType)
-    {
+  switch (compressType) {
     case TarCompressGZip:
       compress = cmArchiveWrite::CompressGZip;
       break;
@@ -1581,32 +1370,27 @@ bool cmSystemTools::CreateTar(const char* outFileName,
     case TarCompressNone:
       compress = cmArchiveWrite::CompressNone;
       break;
-    }
+  }
 
-  cmArchiveWrite a(fout, compress,
-    format.empty() ? "paxr" : format);
+  cmArchiveWrite a(fout, compress, format.empty() ? "paxr" : format);
 
   a.SetMTime(mtime);
   a.SetVerbose(verbose);
-  for(std::vector<std::string>::const_iterator i = files.begin();
-      i != files.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = files.begin();
+       i != files.end(); ++i) {
     std::string path = *i;
-    if(cmSystemTools::FileIsFullPath(path.c_str()))
-      {
+    if (cmSystemTools::FileIsFullPath(path.c_str())) {
       // Get the relative path to the file.
       path = cmSystemTools::RelativePath(cwd.c_str(), path.c_str());
-      }
-    if(!a.Add(path))
-      {
+    }
+    if (!a.Add(path)) {
       break;
-      }
     }
-  if(!a)
-    {
+  }
+  if (!a) {
     cmSystemTools::Error(a.GetError().c_str());
     return false;
-    }
+  }
   return true;
 #else
   (void)outFileName;
@@ -1617,18 +1401,17 @@ bool cmSystemTools::CreateTar(const char* outFileName,
 }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-namespace{
-#define BSDTAR_FILESIZE_PRINTF  "%lu"
-#define BSDTAR_FILESIZE_TYPE    unsigned long
-  void
-    list_item_verbose(FILE *out, struct archive_entry *entry)
-{
-  char                   tmp[100];
-  size_t                         w;
-  const char            *p;
-  const char            *fmt;
-  time_t                         tim;
-  static time_t          now;
+namespace {
+#define BSDTAR_FILESIZE_PRINTF "%lu"
+#define BSDTAR_FILESIZE_TYPE unsigned long
+void list_item_verbose(FILE* out, struct archive_entry* entry)
+{
+  char tmp[100];
+  size_t w;
+  const char* p;
+  const char* fmt;
+  time_t tim;
+  static time_t now;
   size_t u_width = 6;
   size_t gs_width = 13;
 
@@ -1639,57 +1422,44 @@ namespace{
    * and just widen them as necessary.  These numbers are completely
    * arbitrary.
    */
-  if (!now)
-    {
+  if (!now) {
     time(&now);
-    }
-  fprintf(out, "%s %d ",
-          archive_entry_strmode(entry),
+  }
+  fprintf(out, "%s %d ", archive_entry_strmode(entry),
           archive_entry_nlink(entry));
 
   /* Use uname if it's present, else uid. */
   p = archive_entry_uname(entry);
-  if ((p == NULL) || (*p == '\0'))
-    {
-    sprintf(tmp, "%lu ",
-            (unsigned long)archive_entry_uid(entry));
+  if ((p == NULL) || (*p == '\0')) {
+    sprintf(tmp, "%lu ", (unsigned long)archive_entry_uid(entry));
     p = tmp;
-    }
+  }
   w = strlen(p);
-  if (w > u_width)
-    {
+  if (w > u_width) {
     u_width = w;
-    }
+  }
   fprintf(out, "%-*s ", (int)u_width, p);
   /* Use gname if it's present, else gid. */
   p = archive_entry_gname(entry);
-  if (p != NULL && p[0] != '\0')
-    {
+  if (p != NULL && p[0] != '\0') {
     fprintf(out, "%s", p);
     w = strlen(p);
-    }
-  else
-    {
-    sprintf(tmp, "%lu",
-            (unsigned long)archive_entry_gid(entry));
+  } else {
+    sprintf(tmp, "%lu", (unsigned long)archive_entry_gid(entry));
     w = strlen(tmp);
     fprintf(out, "%s", tmp);
-    }
+  }
 
   /*
    * Print device number or file size, right-aligned so as to make
    * total width of group and devnum/filesize fields be gs_width.
    * If gs_width is too small, grow it.
    */
-  if (archive_entry_filetype(entry) == AE_IFCHR
-      || archive_entry_filetype(entry) == AE_IFBLK)
-    {
-    sprintf(tmp, "%lu,%lu",
-            (unsigned long)archive_entry_rdevmajor(entry),
+  if (archive_entry_filetype(entry) == AE_IFCHR ||
+      archive_entry_filetype(entry) == AE_IFBLK) {
+    sprintf(tmp, "%lu,%lu", (unsigned long)archive_entry_rdevmajor(entry),
             (unsigned long)archive_entry_rdevminor(entry));
-    }
-  else
-    {
+  } else {
     /*
      * Note the use of platform-dependent macros to format
      * the filesize here.  We need the format string and the
@@ -1697,50 +1467,44 @@ namespace{
      */
     sprintf(tmp, BSDTAR_FILESIZE_PRINTF,
             (BSDTAR_FILESIZE_TYPE)archive_entry_size(entry));
-    }
-  if (w + strlen(tmp) >= gs_width)
-    {
-    gs_width = w+strlen(tmp)+1;
-    }
+  }
+  if (w + strlen(tmp) >= gs_width) {
+    gs_width = w + strlen(tmp) + 1;
+  }
   fprintf(out, "%*s", (int)(gs_width - w), tmp);
 
   /* Format the time using 'ls -l' conventions. */
   tim = archive_entry_mtime(entry);
 #define HALF_YEAR (time_t)365 * 86400 / 2
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  /* Windows' strftime function does not support %e format. */
-#define DAY_FMT  "%d"
+/* Windows' strftime function does not support %e format. */
+#define DAY_FMT "%d"
 #else
-#define DAY_FMT  "%e"  /* Day number without leading zeros */
+#define DAY_FMT "%e" /* Day number without leading zeros */
 #endif
-  if (tim < now - HALF_YEAR || tim > now + HALF_YEAR)
-    {
+  if (tim < now - HALF_YEAR || tim > now + HALF_YEAR) {
     fmt = DAY_FMT " %b  %Y";
-    }
-  else
-    {
+  } else {
     fmt = DAY_FMT " %b %H:%M";
-    }
+  }
   strftime(tmp, sizeof(tmp), fmt, localtime(&tim));
   fprintf(out, " %s ", tmp);
   fprintf(out, "%s", cm_archive_entry_pathname(entry).c_str());
 
   /* Extra information for links. */
   if (archive_entry_hardlink(entry)) /* Hard link */
-    {
-    fprintf(out, " link to %s",
-            archive_entry_hardlink(entry));
-    }
-  else if (archive_entry_symlink(entry)) /* Symbolic link */
-    {
+  {
+    fprintf(out, " link to %s", archive_entry_hardlink(entry));
+  } else if (archive_entry_symlink(entry)) /* Symbolic link */
+  {
     fprintf(out, " -> %s", archive_entry_symlink(entry));
-    }
+  }
 }
 
-long copy_data(struct archive *ar, struct archive *aw)
+long copy_data(struct archive* ar, struct archive* aw)
 {
   long r;
-  const void *buff;
+  const void* buff;
   size_t size;
 #if defined(ARCHIVE_VERSION_NUMBER) && ARCHIVE_VERSION_NUMBER >= 3000000
   __LA_INT64_T offset;
@@ -1748,122 +1512,99 @@ long copy_data(struct archive *ar, struct archive *aw)
   off_t offset;
 #endif
 
-  for (;;)
-    {
+  for (;;) {
     r = archive_read_data_block(ar, &buff, &size, &offset);
-    if (r == ARCHIVE_EOF)
-      {
+    if (r == ARCHIVE_EOF) {
       return (ARCHIVE_OK);
-      }
-    if (r != ARCHIVE_OK)
-      {
+    }
+    if (r != ARCHIVE_OK) {
       return (r);
-      }
+    }
     r = archive_write_data_block(aw, buff, size, offset);
-    if (r != ARCHIVE_OK)
-      {
+    if (r != ARCHIVE_OK) {
       cmSystemTools::Message("archive_write_data_block()",
                              archive_error_string(aw));
       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,
-                 bool extract)
+bool extract_tar(const char* outFileName, bool verbose, bool extract)
 {
   cmLocaleRAII localeRAII;
   static_cast<void>(localeRAII);
   struct archive* a = archive_read_new();
-  struct archive *ext = archive_write_disk_new();
+  struct archive* ext = archive_write_disk_new();
   archive_read_support_filter_all(a);
   archive_read_support_format_all(a);
-  struct archive_entry *entry;
+  struct archive_entry* entry;
   int r = cm_archive_read_open_file(a, outFileName, 10240);
-  if(r)
-    {
+  if (r) {
     cmSystemTools::Error("Problem with archive_read_open_file(): ",
                          archive_error_string(a));
     archive_write_free(ext);
     archive_read_close(a);
     return false;
-    }
-  for (;;)
-    {
+  }
+  for (;;) {
     r = archive_read_next_header(a, &entry);
-    if (r == ARCHIVE_EOF)
-      {
+    if (r == ARCHIVE_EOF) {
       break;
-      }
-    if (r != ARCHIVE_OK)
-      {
+    }
+    if (r != ARCHIVE_OK) {
       cmSystemTools::Error("Problem with archive_read_next_header(): ",
                            archive_error_string(a));
       break;
-      }
-    if(verbose)
-      {
-      if(extract)
-        {
+    }
+    if (verbose) {
+      if (extract) {
         cmSystemTools::Stdout("x ");
         cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
-        }
-      else
-        {
+      } else {
         list_item_verbose(stdout, entry);
-        }
-      cmSystemTools::Stdout("\n");
       }
-    else if(!extract)
-      {
+      cmSystemTools::Stdout("\n");
+    } else if (!extract) {
       cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
       cmSystemTools::Stdout("\n");
-      }
-    if(extract)
-      {
+    }
+    if (extract) {
       r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME);
-      if (r != ARCHIVE_OK)
-        {
-        cmSystemTools::Error(
-          "Problem with archive_write_disk_set_options(): ",
-          archive_error_string(ext));
+      if (r != ARCHIVE_OK) {
+        cmSystemTools::Error("Problem with archive_write_disk_set_options(): ",
+                             archive_error_string(ext));
         break;
-        }
+      }
 
       r = archive_write_header(ext, entry);
-      if (r == ARCHIVE_OK)
-        {
+      if (r == ARCHIVE_OK) {
         copy_data(a, ext);
         r = archive_write_finish_entry(ext);
-        if (r != ARCHIVE_OK)
-          {
+        if (r != ARCHIVE_OK) {
           cmSystemTools::Error("Problem with archive_write_finish_entry(): ",
                                archive_error_string(ext));
           break;
-          }
         }
+      }
 #ifdef _WIN32
-      else if(const char* linktext = archive_entry_symlink(entry))
-        {
+      else if (const char* linktext = archive_entry_symlink(entry)) {
         std::cerr << "cmake -E tar: warning: skipping symbolic link \""
-                  << cm_archive_entry_pathname(entry)
-                  << "\" -> \""
-                  << linktext << "\"." << std::endl;
-        }
+                  << cm_archive_entry_pathname(entry) << "\" -> \"" << linktext
+                  << "\"." << std::endl;
+      }
 #endif
-      else
-        {
+      else {
         cmSystemTools::Error("Problem with archive_write_header(): ",
                              archive_error_string(ext));
         cmSystemTools::Error("Current file: ",
                              cm_archive_entry_pathname(entry).c_str());
         break;
-        }
       }
     }
+  }
   archive_write_free(ext);
   archive_read_close(a);
   archive_read_free(a);
@@ -1872,8 +1613,7 @@ bool extract_tar(const char* outFileName, bool verbose,
 }
 #endif
 
-bool cmSystemTools::ExtractTar(const char* outFileName,
-                               bool verbose)
+bool cmSystemTools::ExtractTar(const char* outFileName, bool verbose)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   return extract_tar(outFileName, verbose, true);
@@ -1884,8 +1624,7 @@ bool cmSystemTools::ExtractTar(const char* outFileName,
 #endif
 }
 
-bool cmSystemTools::ListTar(const char* outFileName,
-                            bool verbose)
+bool cmSystemTools::ListTar(const char* outFileName, bool verbose)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   return extract_tar(outFileName, verbose, false);
@@ -1897,105 +1636,79 @@ bool cmSystemTools::ListTar(const char* outFileName,
 }
 
 int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
-                               double timeout,
-                               std::vector<char>& out,
+                               double timeout, std::vector<char>& out,
                                std::vector<char>& err)
 {
   line = "";
   std::vector<char>::iterator outiter = out.begin();
   std::vector<char>::iterator erriter = err.begin();
-  while(1)
-    {
+  while (1) {
     // Check for a newline in stdout.
-    for(;outiter != out.end(); ++outiter)
-      {
-      if((*outiter == '\r') && ((outiter+1) == out.end()))
-        {
+    for (; outiter != out.end(); ++outiter) {
+      if ((*outiter == '\r') && ((outiter + 1) == out.end())) {
         break;
-        }
-      else if(*outiter == '\n' || *outiter == '\0')
-        {
-        std::vector<char>::size_type length = outiter-out.begin();
-        if(length > 1 && *(outiter-1) == '\r')
-          {
+      } else if (*outiter == '\n' || *outiter == '\0') {
+        std::vector<char>::size_type length = outiter - out.begin();
+        if (length > 1 && *(outiter - 1) == '\r') {
           --length;
-          }
-        if(length > 0)
-          {
+        }
+        if (length > 0) {
           line.append(&out[0], length);
-          }
-        out.erase(out.begin(), outiter+1);
-        return cmsysProcess_Pipe_STDOUT;
         }
+        out.erase(out.begin(), outiter + 1);
+        return cmsysProcess_Pipe_STDOUT;
       }
+    }
 
     // Check for a newline in stderr.
-    for(;erriter != err.end(); ++erriter)
-      {
-      if((*erriter == '\r') && ((erriter+1) == err.end()))
-        {
+    for (; erriter != err.end(); ++erriter) {
+      if ((*erriter == '\r') && ((erriter + 1) == err.end())) {
         break;
-        }
-      else if(*erriter == '\n' || *erriter == '\0')
-        {
-        std::vector<char>::size_type length = erriter-err.begin();
-        if(length > 1 && *(erriter-1) == '\r')
-          {
+      } else if (*erriter == '\n' || *erriter == '\0') {
+        std::vector<char>::size_type length = erriter - err.begin();
+        if (length > 1 && *(erriter - 1) == '\r') {
           --length;
-          }
-        if(length > 0)
-          {
+        }
+        if (length > 0) {
           line.append(&err[0], length);
-          }
-        err.erase(err.begin(), erriter+1);
-        return cmsysProcess_Pipe_STDERR;
         }
+        err.erase(err.begin(), erriter + 1);
+        return cmsysProcess_Pipe_STDERR;
       }
+    }
 
     // No newlines found.  Wait for more data from the process.
     int length;
     char* data;
     int pipe = cmsysProcess_WaitForData(process, &data, &length, &timeout);
-    if(pipe == cmsysProcess_Pipe_Timeout)
-      {
+    if (pipe == cmsysProcess_Pipe_Timeout) {
       // Timeout has been exceeded.
       return pipe;
-      }
-    else if(pipe == cmsysProcess_Pipe_STDOUT)
-      {
+    } else if (pipe == cmsysProcess_Pipe_STDOUT) {
       // Append to the stdout buffer.
       std::vector<char>::size_type size = out.size();
-      out.insert(out.end(), data, data+length);
-      outiter = out.begin()+size;
-      }
-    else if(pipe == cmsysProcess_Pipe_STDERR)
-      {
+      out.insert(out.end(), data, data + length);
+      outiter = out.begin() + size;
+    } else if (pipe == cmsysProcess_Pipe_STDERR) {
       // Append to the stderr buffer.
       std::vector<char>::size_type size = err.size();
-      err.insert(err.end(), data, data+length);
-      erriter = err.begin()+size;
-      }
-    else if(pipe == cmsysProcess_Pipe_None)
-      {
+      err.insert(err.end(), data, data + length);
+      erriter = err.begin() + size;
+    } else if (pipe == cmsysProcess_Pipe_None) {
       // Both stdout and stderr pipes have broken.  Return leftover data.
-      if(!out.empty())
-        {
-        line.append(&out[0], outiter-out.begin());
+      if (!out.empty()) {
+        line.append(&out[0], outiter - out.begin());
         out.erase(out.begin(), out.end());
         return cmsysProcess_Pipe_STDOUT;
-        }
-      else if(!err.empty())
-        {
-        line.append(&err[0], erriter-err.begin());
+      } else if (!err.empty()) {
+        line.append(&err[0], erriter - err.begin());
         err.erase(err.begin(), err.end());
         return cmsysProcess_Pipe_STDERR;
-        }
-      else
-        {
+      } else {
         return cmsysProcess_Pipe_None;
-        }
       }
     }
+  }
 }
 
 void cmSystemTools::DoNotInheritStdPipes()
@@ -2007,167 +1720,142 @@ void cmSystemTools::DoNotInheritStdPipes()
   // shell windows
   CONSOLE_SCREEN_BUFFER_INFO hOutInfo;
   HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
-  if(GetConsoleScreenBufferInfo(hOut, &hOutInfo))
-    {
+  if (GetConsoleScreenBufferInfo(hOut, &hOutInfo)) {
     return;
-    }
+  }
   {
-  HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
-  DuplicateHandle(GetCurrentProcess(), out,
-                  GetCurrentProcess(), &out, 0, FALSE,
-                  DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-  SetStdHandle(STD_OUTPUT_HANDLE, out);
+    HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
+    DuplicateHandle(GetCurrentProcess(), out, GetCurrentProcess(), &out, 0,
+                    FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+    SetStdHandle(STD_OUTPUT_HANDLE, out);
   }
   {
-  HANDLE out = GetStdHandle(STD_ERROR_HANDLE);
-  DuplicateHandle(GetCurrentProcess(), out,
-                  GetCurrentProcess(), &out, 0, FALSE,
-                  DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
-  SetStdHandle(STD_ERROR_HANDLE, out);
+    HANDLE out = GetStdHandle(STD_ERROR_HANDLE);
+    DuplicateHandle(GetCurrentProcess(), out, GetCurrentProcess(), &out, 0,
+                    FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+    SetStdHandle(STD_ERROR_HANDLE, out);
   }
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  cmSystemToolsWindowsHandle hFrom =
-    CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fromFile).c_str(),
-                GENERIC_READ, FILE_SHARE_READ, 0,
-                OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
-  cmSystemToolsWindowsHandle hTo =
-    CreateFileW(SystemTools::ConvertToWindowsExtendedPath(toFile).c_str(),
-                FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING,
-                FILE_FLAG_BACKUP_SEMANTICS, 0);
-  if(!hFrom || !hTo)
-    {
+  cmSystemToolsWindowsHandle hFrom = CreateFileW(
+    SystemTools::ConvertToWindowsExtendedPath(fromFile).c_str(), GENERIC_READ,
+    FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+  cmSystemToolsWindowsHandle hTo = CreateFileW(
+    SystemTools::ConvertToWindowsExtendedPath(toFile).c_str(),
+    FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+  if (!hFrom || !hTo) {
     return false;
-    }
+  }
   FILETIME timeCreation;
   FILETIME timeLastAccess;
   FILETIME timeLastWrite;
-  if(!GetFileTime(hFrom, &timeCreation, &timeLastAccess, &timeLastWrite))
-    {
+  if (!GetFileTime(hFrom, &timeCreation, &timeLastAccess, &timeLastWrite)) {
     return false;
-    }
-  if(!SetFileTime(hTo, &timeCreation, &timeLastAccess, &timeLastWrite))
-    {
+  }
+  if (!SetFileTime(hTo, &timeCreation, &timeLastAccess, &timeLastWrite)) {
     return false;
-    }
+  }
 #else
   struct stat fromStat;
-  if(stat(fromFile, &fromStat) < 0)
-    {
+  if (stat(fromFile, &fromStat) < 0) {
     return false;
-    }
+  }
 
   struct utimbuf buf;
   buf.actime = fromStat.st_atime;
   buf.modtime = fromStat.st_mtime;
-  if(utime(toFile, &buf) < 0)
-    {
+  if (utime(toFile, &buf) < 0) {
     return false;
-    }
+  }
 #endif
   return true;
 }
 
-//----------------------------------------------------------------------------
 cmSystemToolsFileTime* cmSystemTools::FileTimeNew()
 {
   return new cmSystemToolsFileTime;
 }
 
-//----------------------------------------------------------------------------
 void cmSystemTools::FileTimeDelete(cmSystemToolsFileTime* t)
 {
   delete t;
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  cmSystemToolsWindowsHandle h =
-    CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(),
-                GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING,
-                FILE_FLAG_BACKUP_SEMANTICS, 0);
-  if(!h)
-    {
+  cmSystemToolsWindowsHandle h = CreateFileW(
+    SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), GENERIC_READ,
+    FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+  if (!h) {
     return false;
-    }
-  if(!GetFileTime(h, &t->timeCreation, &t->timeLastAccess, &t->timeLastWrite))
-    {
+  }
+  if (!GetFileTime(h, &t->timeCreation, &t->timeLastAccess,
+                   &t->timeLastWrite)) {
     return false;
-    }
+  }
 #else
   struct stat st;
-  if(stat(fname, &st) < 0)
-    {
+  if (stat(fname, &st) < 0) {
     return false;
-    }
+  }
   t->timeBuf.actime = st.st_atime;
   t->timeBuf.modtime = st.st_mtime;
 #endif
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  cmSystemToolsWindowsHandle h =
-    CreateFileW(SystemTools::ConvertToWindowsExtendedPath(fname).c_str(),
-                FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING,
-                FILE_FLAG_BACKUP_SEMANTICS, 0);
-  if(!h)
-    {
+  cmSystemToolsWindowsHandle h = CreateFileW(
+    SystemTools::ConvertToWindowsExtendedPath(fname).c_str(),
+    FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+  if (!h) {
     return false;
-    }
-  if(!SetFileTime(h, &t->timeCreation, &t->timeLastAccess, &t->timeLastWrite))
-    {
+  }
+  if (!SetFileTime(h, &t->timeCreation, &t->timeLastAccess,
+                   &t->timeLastWrite)) {
     return false;
-    }
+  }
 #else
-  if(utime(fname, &t->timeBuf) < 0)
-    {
+  if (utime(fname, &t->timeBuf) < 0) {
     return false;
-    }
+  }
 #endif
   return true;
 }
 
-//----------------------------------------------------------------------------
 #ifdef _WIN32
-# ifndef CRYPT_SILENT
-#  define CRYPT_SILENT 0x40 /* Not defined by VS 6 version of header.  */
-# endif
+#ifndef CRYPT_SILENT
+#define CRYPT_SILENT 0x40 /* Not defined by VS 6 version of header.  */
+#endif
 static int WinCryptRandom(void* data, size_t size)
 {
   int result = 0;
   HCRYPTPROV hProvider = 0;
-  if(CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL,
-                          CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
-    {
-    result = CryptGenRandom(hProvider, (DWORD)size, (BYTE*)data)? 1:0;
+  if (CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL,
+                           CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
+    result = CryptGenRandom(hProvider, (DWORD)size, (BYTE*)data) ? 1 : 0;
     CryptReleaseContext(hProvider, 0);
-    }
+  }
   return result;
 }
 #endif
 
-//----------------------------------------------------------------------------
 unsigned int cmSystemTools::RandomSeed()
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
   unsigned int seed = 0;
 
   // Try using a real random source.
-  if(WinCryptRandom(&seed, sizeof(seed)))
-    {
+  if (WinCryptRandom(&seed, sizeof(seed))) {
     return seed;
-    }
+  }
 
   // Fall back to the time and pid.
   FILETIME ft;
@@ -2184,12 +1872,13 @@ unsigned int cmSystemTools::RandomSeed()
   } seed;
 
   // Try using a real random source.
-  cmsys::ifstream fin("/dev/urandom");
-  if(fin && fin.read(seed.bytes, sizeof(seed)) &&
-     fin.gcount() == sizeof(seed))
-    {
+  cmsys::ifstream fin;
+  fin.rdbuf()->pubsetbuf(0, 0); // Unbuffered read.
+  fin.open("/dev/urandom");
+  if (fin.good() && fin.read(seed.bytes, sizeof(seed)) &&
+      fin.gcount() == sizeof(seed)) {
     return seed.integer;
-    }
+  }
 
   // Fall back to the time and pid.
   struct timeval t;
@@ -2203,7 +1892,6 @@ unsigned int cmSystemTools::RandomSeed()
 #endif
 }
 
-//----------------------------------------------------------------------------
 static std::string cmSystemToolsCMakeCommand;
 static std::string cmSystemToolsCTestCommand;
 static std::string cmSystemToolsCPackCommand;
@@ -2222,57 +1910,46 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
     cmSystemTools::GetFilenamePath(cmsys::Encoding::ToNarrow(modulepath));
 #elif defined(__APPLE__)
   (void)argv0; // ignore this on OS X
-# define CM_EXE_PATH_LOCAL_SIZE 16384
+#define CM_EXE_PATH_LOCAL_SIZE 16384
   char exe_path_local[CM_EXE_PATH_LOCAL_SIZE];
-# if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4)
+#if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4)
   unsigned long exe_path_size = CM_EXE_PATH_LOCAL_SIZE;
-# else
+#else
   uint32_t exe_path_size = CM_EXE_PATH_LOCAL_SIZE;
-# endif
-# undef CM_EXE_PATH_LOCAL_SIZE
+#endif
+#undef CM_EXE_PATH_LOCAL_SIZE
   char* exe_path = exe_path_local;
-  if(_NSGetExecutablePath(exe_path, &exe_path_size) < 0)
-    {
+  if (_NSGetExecutablePath(exe_path, &exe_path_size) < 0) {
     exe_path = (char*)malloc(exe_path_size);
     _NSGetExecutablePath(exe_path, &exe_path_size);
-    }
+  }
   exe_dir =
-    cmSystemTools::GetFilenamePath(
-      cmSystemTools::GetRealPath(exe_path));
-  if(exe_path != exe_path_local)
-    {
+    cmSystemTools::GetFilenamePath(cmSystemTools::GetRealPath(exe_path));
+  if (exe_path != exe_path_local) {
     free(exe_path);
-    }
-  if(cmSystemTools::GetFilenameName(exe_dir) == "MacOS")
-    {
+  }
+  if (cmSystemTools::GetFilenameName(exe_dir) == "MacOS") {
     // The executable is inside an application bundle.
     // Look for ../bin (install tree) and then fall back to
     // ../../../bin (build tree).
     exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
-    if(cmSystemTools::FileExists((exe_dir+"/bin/cmake").c_str()))
-      {
+    if (cmSystemTools::FileExists((exe_dir + "/bin/cmake").c_str())) {
       exe_dir += "/bin";
-      }
-    else
-      {
+    } else {
       exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
       exe_dir = cmSystemTools::GetFilenamePath(exe_dir);
-      }
     }
+  }
 #else
   std::string errorMsg;
   std::string exe;
-  if(cmSystemTools::FindProgramPath(argv0, exe, errorMsg))
-    {
+  if (cmSystemTools::FindProgramPath(argv0, exe, errorMsg)) {
     // remove symlinks
     exe = cmSystemTools::GetRealPath(exe);
-    exe_dir =
-      cmSystemTools::GetFilenamePath(exe);
-    }
-  else
-    {
+    exe_dir = cmSystemTools::GetFilenamePath(exe);
+  } else {
     // ???
-    }
+  }
 #endif
   cmSystemToolsCMakeCommand = exe_dir;
   cmSystemToolsCMakeCommand += "/cmake";
@@ -2291,103 +1968,87 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
   cmSystemToolsCMakeGUICommand = exe_dir;
   cmSystemToolsCMakeGUICommand += "/cmake-gui";
   cmSystemToolsCMakeGUICommand += cmSystemTools::GetExecutableExtension();
-  if(!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str()))
-    {
+  if (!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str())) {
     cmSystemToolsCMakeGUICommand = "";
-    }
+  }
   cmSystemToolsCMakeCursesCommand = exe_dir;
   cmSystemToolsCMakeCursesCommand += "/ccmake";
   cmSystemToolsCMakeCursesCommand += cmSystemTools::GetExecutableExtension();
-  if(!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str()))
-    {
+  if (!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str())) {
     cmSystemToolsCMakeCursesCommand = "";
-    }
+  }
   cmSystemToolsCMClDepsCommand = exe_dir;
   cmSystemToolsCMClDepsCommand += "/cmcldeps";
   cmSystemToolsCMClDepsCommand += cmSystemTools::GetExecutableExtension();
-  if(!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand.c_str()))
-    {
+  if (!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand.c_str())) {
     cmSystemToolsCMClDepsCommand = "";
-    }
+  }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>".
   std::string dir = cmSystemTools::GetFilenamePath(exe_dir);
   cmSystemToolsCMakeRoot = dir + CMAKE_DATA_DIR;
-  if(!cmSystemTools::FileExists(
-       (cmSystemToolsCMakeRoot+"/Modules/CMake.cmake").c_str()))
-    {
+  if (!cmSystemTools::FileExists(
+        (cmSystemToolsCMakeRoot + "/Modules/CMake.cmake").c_str())) {
     // Build tree has "<build>/bin[/<config>]/cmake" and
     // "<build>/CMakeFiles/CMakeSourceDir.txt".
     std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
     cmsys::ifstream fin(src_dir_txt.c_str());
     std::string src_dir;
-    if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) &&
-       cmSystemTools::FileIsDirectory(src_dir))
-      {
+    if (fin && cmSystemTools::GetLineFromStream(fin, src_dir) &&
+        cmSystemTools::FileIsDirectory(src_dir)) {
       cmSystemToolsCMakeRoot = src_dir;
-      }
-    else
-      {
+    } else {
       dir = cmSystemTools::GetFilenamePath(dir);
       src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
       cmsys::ifstream fin2(src_dir_txt.c_str());
-      if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) &&
-         cmSystemTools::FileIsDirectory(src_dir))
-        {
+      if (fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) &&
+          cmSystemTools::FileIsDirectory(src_dir)) {
         cmSystemToolsCMakeRoot = src_dir;
-        }
       }
     }
+  }
 #else
   // Bootstrap build knows its source.
   cmSystemToolsCMakeRoot = CMAKE_BOOTSTRAP_SOURCE_DIR;
 #endif
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCMakeCommand()
 {
   return cmSystemToolsCMakeCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCTestCommand()
 {
   return cmSystemToolsCTestCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCPackCommand()
 {
   return cmSystemToolsCPackCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCMakeCursesCommand()
 {
   return cmSystemToolsCMakeCursesCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCMakeGUICommand()
 {
   return cmSystemToolsCMakeGUICommand;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCMClDepsCommand()
 {
   return cmSystemToolsCMClDepsCommand;
 }
 
-//----------------------------------------------------------------------------
 std::string const& cmSystemTools::GetCMakeRoot()
 {
   return cmSystemToolsCMakeRoot;
 }
 
-//----------------------------------------------------------------------------
 void cmSystemTools::MakefileColorEcho(int color, const char* message,
                                       bool newline, bool enabled)
 {
@@ -2398,83 +2059,70 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message,
   // However, we can test for some situations when the answer is most
   // likely no.
   int assumeTTY = cmsysTerminal_Color_AssumeTTY;
-  if(cmSystemTools::GetEnv("DART_TEST_FROM_DART") ||
-     cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST") ||
-     cmSystemTools::GetEnv("CTEST_INTERACTIVE_DEBUG_MODE"))
-    {
+  if (cmSystemTools::GetEnv("DART_TEST_FROM_DART") ||
+      cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST") ||
+      cmSystemTools::GetEnv("CTEST_INTERACTIVE_DEBUG_MODE")) {
     // Avoid printing color escapes during dashboard builds.
     assumeTTY = 0;
-    }
+  }
 
-  if(enabled && color != cmsysTerminal_Color_Normal)
-    {
+  if (enabled && color != cmsysTerminal_Color_Normal) {
     // Print with color.  Delay the newline until later so that
     // all color restore sequences appear before it.
     cmsysTerminal_cfprintf(color | assumeTTY, stdout, "%s", message);
-    }
-  else
-    {
+  } else {
     // Color is disabled.  Print without color.
     fprintf(stdout, "%s", message);
-    }
+  }
 
-  if(newline)
-    {
+  if (newline) {
     fprintf(stdout, "\n");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
                                        std::string& soname)
 {
-  // For ELF shared libraries use a real parser to get the correct
-  // soname.
+// For ELF shared libraries use a real parser to get the correct
+// soname.
 #if defined(CMAKE_USE_ELF_PARSER)
   cmELF elf(fullPath.c_str());
-  if(elf)
-    {
+  if (elf) {
     return elf.GetSOName(soname);
-    }
+  }
 #endif
 
   // If the file is not a symlink we have no guess for its soname.
-  if(!cmSystemTools::FileIsSymlink(fullPath))
-    {
+  if (!cmSystemTools::FileIsSymlink(fullPath)) {
     return false;
-    }
-  if(!cmSystemTools::ReadSymlink(fullPath, soname))
-    {
+  }
+  if (!cmSystemTools::ReadSymlink(fullPath, soname)) {
     return false;
-    }
+  }
 
   // If the symlink has a path component we have no guess for the soname.
-  if(!cmSystemTools::GetFilenamePath(soname).empty())
-    {
+  if (!cmSystemTools::GetFilenamePath(soname).empty()) {
     return false;
-    }
+  }
 
   // If the symlink points at an extended version of the same name
   // assume it is the soname.
   std::string name = cmSystemTools::GetFilenameName(fullPath);
-  if(soname.length() > name.length() &&
-     soname.substr(0, name.length()) == name)
-    {
+  if (soname.length() > name.length() &&
+      soname.substr(0, name.length()) == name) {
     return true;
-    }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
-                                       std::string& soname)
+                                            std::string& soname)
 {
 #if defined(CMAKE_USE_MACH_PARSER)
   cmMachO macho(fullPath.c_str());
-  if(macho)
-    {
+  if (macho) {
     return macho.GetInstallName(soname);
-    }
+  }
 #else
   (void)fullPath;
   (void)soname;
@@ -2483,49 +2131,37 @@ bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
   return false;
 }
 
-//----------------------------------------------------------------------------
 #if defined(CMAKE_USE_ELF_PARSER)
 std::string::size_type cmSystemToolsFindRPath(std::string const& have,
                                               std::string const& want)
 {
-  // Search for the desired rpath.
-  std::string::size_type pos = have.find(want);
-
-  // If the path is not present we are done.
-  if(pos == std::string::npos)
-    {
-    return pos;
-    }
-
-  // Build a regex to match a properly separated path instance.
-  std::string regex_str = "(^|:)(";
-  for(std::string::const_iterator i = want.begin(); i != want.end(); ++i)
-    {
-    int ch = *i;
-    if(!(('a' <= ch && ch <= 'z') ||
-         ('A' <= ch && ch <= 'Z') ||
-         ('0' <= ch && ch <= '9')))
-      {
-      // Escape the non-alphanumeric character.
-      regex_str += "\\";
-      }
-    // Store the character.
-    regex_str.append(1, static_cast<char>(ch));
+  std::string::size_type pos = 0;
+  while (pos < have.size()) {
+    // Look for an occurrence of the string.
+    std::string::size_type const beg = have.find(want, pos);
+    if (beg == std::string::npos) {
+      return std::string::npos;
     }
-  regex_str += ")(:|$)";
 
-  // Look for the separated path.
-  cmsys::RegularExpression regex(regex_str.c_str());
-  if(regex.find(have))
-    {
-    // Return the position of the path portion.
-    return regex.start(2);
+    // Make sure it is separated from preceding entries.
+    if (beg > 0 && have[beg - 1] != ':') {
+      pos = beg + 1;
+      continue;
     }
-  else
-    {
-    // The desired rpath was not found.
-    return std::string::npos;
+
+    // Make sure it is separated from following entries.
+    std::string::size_type const end = beg + want.size();
+    if (end < have.size() && have[end] != ':') {
+      pos = beg + 1;
+      continue;
     }
+
+    // Return the position of the path portion.
+    return beg;
+  }
+
+  // The desired rpath was not found.
+  return std::string::npos;
 }
 #endif
 
@@ -2539,207 +2175,178 @@ struct cmSystemToolsRPathInfo
 };
 #endif
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::ChangeRPath(std::string const& file,
                                 std::string const& oldRPath,
-                                std::string const& newRPath,
-                                std::string* emsg,
+                                std::string const& newRPath, std::string* emsg,
                                 bool* changed)
 {
 #if defined(CMAKE_USE_ELF_PARSER)
-  if(changed)
-    {
+  if (changed) {
     *changed = false;
-    }
+  }
   int rp_count = 0;
   bool remove_rpath = true;
   cmSystemToolsRPathInfo rp[2];
   {
-  // Parse the ELF binary.
-  cmELF elf(file.c_str());
-
-  // Get the RPATH and RUNPATH entries from it.
-  int se_count = 0;
-  cmELF::StringEntry const* se[2] = {0, 0};
-  const char* se_name[2] = {0, 0};
-  if(cmELF::StringEntry const* se_rpath = elf.GetRPath())
-    {
-    se[se_count] = se_rpath;
-    se_name[se_count] = "RPATH";
-    ++se_count;
-    }
-  if(cmELF::StringEntry const* se_runpath = elf.GetRunPath())
-    {
-    se[se_count] = se_runpath;
-    se_name[se_count] = "RUNPATH";
-    ++se_count;
-    }
-  if(se_count == 0)
-    {
-    if(newRPath.empty())
-      {
-      // The new rpath is empty and there is no rpath anyway so it is
-      // okay.
-      return true;
-      }
-    else
-      {
-      if(emsg)
-        {
-        *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; ";
-        *emsg += elf.GetErrorMessage();
+    // Parse the ELF binary.
+    cmELF elf(file.c_str());
+
+    // Get the RPATH and RUNPATH entries from it.
+    int se_count = 0;
+    cmELF::StringEntry const* se[2] = { 0, 0 };
+    const char* se_name[2] = { 0, 0 };
+    if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) {
+      se[se_count] = se_rpath;
+      se_name[se_count] = "RPATH";
+      ++se_count;
+    }
+    if (cmELF::StringEntry const* se_runpath = elf.GetRunPath()) {
+      se[se_count] = se_runpath;
+      se_name[se_count] = "RUNPATH";
+      ++se_count;
+    }
+    if (se_count == 0) {
+      if (newRPath.empty()) {
+        // The new rpath is empty and there is no rpath anyway so it is
+        // okay.
+        return true;
+      } else {
+        if (emsg) {
+          *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; ";
+          *emsg += elf.GetErrorMessage();
         }
-      return false;
+        return false;
       }
     }
 
-  for(int i=0; i < se_count; ++i)
-    {
-    // If both RPATH and RUNPATH refer to the same string literal it
-    // needs to be changed only once.
-    if(rp_count && rp[0].Position == se[i]->Position)
-      {
-      continue;
+    for (int i = 0; i < se_count; ++i) {
+      // If both RPATH and RUNPATH refer to the same string literal it
+      // needs to be changed only once.
+      if (rp_count && rp[0].Position == se[i]->Position) {
+        continue;
       }
 
-    // Make sure the current rpath contains the old rpath.
-    std::string::size_type pos =
-      cmSystemToolsFindRPath(se[i]->Value, oldRPath);
-    if(pos == std::string::npos)
-      {
-      // If it contains the new rpath instead then it is okay.
-      if(cmSystemToolsFindRPath(se[i]->Value, newRPath) != std::string::npos)
-        {
-        remove_rpath = false;
-        continue;
+      // Make sure the current rpath contains the old rpath.
+      std::string::size_type pos =
+        cmSystemToolsFindRPath(se[i]->Value, oldRPath);
+      if (pos == std::string::npos) {
+        // If it contains the new rpath instead then it is okay.
+        if (cmSystemToolsFindRPath(se[i]->Value, newRPath) !=
+            std::string::npos) {
+          remove_rpath = false;
+          continue;
         }
-      if(emsg)
-        {
-        std::ostringstream e;
+        if (emsg) {
+          std::ostringstream e;
+          /* clang-format off */
         e << "The current " << se_name[i] << " is:\n"
           << "  " << se[i]->Value << "\n"
           << "which does not contain:\n"
           << "  " << oldRPath << "\n"
           << "as was expected.";
-        *emsg = e.str();
+          /* clang-format on */
+          *emsg = e.str();
         }
-      return false;
+        return false;
       }
 
-    // Store information about the entry in the file.
-    rp[rp_count].Position = se[i]->Position;
-    rp[rp_count].Size = se[i]->Size;
-    rp[rp_count].Name = se_name[i];
-
-    std::string::size_type prefix_len = pos;
-
-    // If oldRPath was at the end of the file's RPath, and newRPath is empty,
-    // we should remove the unnecessary ':' at the end.
-    if (newRPath.empty() &&
-        pos > 0 &&
-        se[i]->Value[pos - 1] == ':' &&
-        pos + oldRPath.length() == se[i]->Value.length())
-      {
-      prefix_len--;
+      // Store information about the entry in the file.
+      rp[rp_count].Position = se[i]->Position;
+      rp[rp_count].Size = se[i]->Size;
+      rp[rp_count].Name = se_name[i];
+
+      std::string::size_type prefix_len = pos;
+
+      // If oldRPath was at the end of the file's RPath, and newRPath is empty,
+      // we should remove the unnecessary ':' at the end.
+      if (newRPath.empty() && pos > 0 && se[i]->Value[pos - 1] == ':' &&
+          pos + oldRPath.length() == se[i]->Value.length()) {
+        prefix_len--;
       }
 
-    // Construct the new value which preserves the part of the path
-    // not being changed.
-    rp[rp_count].Value = se[i]->Value.substr(0, prefix_len);
-    rp[rp_count].Value += newRPath;
-    rp[rp_count].Value += se[i]->Value.substr(pos+oldRPath.length(),
-                                              oldRPath.npos);
+      // Construct the new value which preserves the part of the path
+      // not being changed.
+      rp[rp_count].Value = se[i]->Value.substr(0, prefix_len);
+      rp[rp_count].Value += newRPath;
+      rp[rp_count].Value +=
+        se[i]->Value.substr(pos + oldRPath.length(), oldRPath.npos);
 
-    if (!rp[rp_count].Value.empty())
-      {
-      remove_rpath = false;
+      if (!rp[rp_count].Value.empty()) {
+        remove_rpath = false;
       }
 
-    // Make sure there is enough room to store the new rpath and at
-    // least one null terminator.
-    if(rp[rp_count].Size < rp[rp_count].Value.length()+1)
-      {
-      if(emsg)
-        {
-        *emsg = "The replacement path is too long for the ";
-        *emsg += se_name[i];
-        *emsg += " entry.";
+      // Make sure there is enough room to store the new rpath and at
+      // least one null terminator.
+      if (rp[rp_count].Size < rp[rp_count].Value.length() + 1) {
+        if (emsg) {
+          *emsg = "The replacement path is too long for the ";
+          *emsg += se_name[i];
+          *emsg += " entry.";
         }
-      return false;
+        return false;
       }
 
-    // This entry is ready for update.
-    ++rp_count;
+      // This entry is ready for update.
+      ++rp_count;
     }
   }
 
   // If no runtime path needs to be changed, we are done.
-  if(rp_count == 0)
-    {
+  if (rp_count == 0) {
     return true;
-    }
+  }
 
   // If the resulting rpath is empty, just remove the entire entry instead.
-  if (remove_rpath)
-    {
+  if (remove_rpath) {
     return cmSystemTools::RemoveRPath(file, emsg, changed);
-    }
+  }
 
   {
-  // Open the file for update.
-  cmsys::ofstream f(file.c_str(),
-                  std::ios::in | std::ios::out | std::ios::binary);
-  if(!f)
-    {
-    if(emsg)
-      {
-      *emsg = "Error opening file for update.";
+    // Open the file for update.
+    cmsys::ofstream f(file.c_str(),
+                      std::ios::in | std::ios::out | std::ios::binary);
+    if (!f) {
+      if (emsg) {
+        *emsg = "Error opening file for update.";
       }
-    return false;
+      return false;
     }
 
-  // Store the new RPATH and RUNPATH strings.
-  for(int i=0; i < rp_count; ++i)
-    {
-    // Seek to the RPATH position.
-    if(!f.seekp(rp[i].Position))
-      {
-      if(emsg)
-        {
-        *emsg = "Error seeking to ";
-        *emsg += rp[i].Name;
-        *emsg += " position.";
+    // Store the new RPATH and RUNPATH strings.
+    for (int i = 0; i < rp_count; ++i) {
+      // Seek to the RPATH position.
+      if (!f.seekp(rp[i].Position)) {
+        if (emsg) {
+          *emsg = "Error seeking to ";
+          *emsg += rp[i].Name;
+          *emsg += " position.";
         }
-      return false;
+        return false;
       }
 
-    // Write the new rpath.  Follow it with enough null terminators to
-    // fill the string table entry.
-    f << rp[i].Value;
-    for(unsigned long j=rp[i].Value.length(); j < rp[i].Size; ++j)
-      {
-      f << '\0';
+      // Write the new rpath.  Follow it with enough null terminators to
+      // fill the string table entry.
+      f << rp[i].Value;
+      for (unsigned long j = rp[i].Value.length(); j < rp[i].Size; ++j) {
+        f << '\0';
       }
 
-    // Make sure it wrote correctly.
-    if(!f)
-      {
-      if(emsg)
-        {
-        *emsg = "Error writing the new ";
-        *emsg += rp[i].Name;
-        *emsg += " string to the file.";
+      // Make sure it wrote correctly.
+      if (!f) {
+        if (emsg) {
+          *emsg = "Error writing the new ";
+          *emsg += rp[i].Name;
+          *emsg += " string to the file.";
         }
-      return false;
+        return false;
       }
     }
   }
 
   // Everything was updated successfully.
-  if(changed)
-    {
+  if (changed) {
     *changed = true;
-    }
+  }
   return true;
 #else
   (void)file;
@@ -2751,223 +2358,188 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
                                    const char* lhss, const char* rhss)
 {
-  const char *endl = lhss;
-  const char *endr = rhss;
+  const char* endl = lhss;
+  const char* endr = rhss;
   unsigned long lhs, rhs;
 
   while (((*endl >= '0') && (*endl <= '9')) ||
-         ((*endr >= '0') && (*endr <= '9')))
-    {
+         ((*endr >= '0') && (*endr <= '9'))) {
     // Do component-wise comparison.
     lhs = strtoul(endl, const_cast<char**>(&endl), 10);
     rhs = strtoul(endr, const_cast<char**>(&endr), 10);
 
-    if(lhs < rhs)
-      {
+    if (lhs < rhs) {
       // lhs < rhs, so true if operation is LESS
       return op == cmSystemTools::OP_LESS;
-      }
-    else if(lhs > rhs)
-      {
+    } else if (lhs > rhs) {
       // lhs > rhs, so true if operation is GREATER
       return op == cmSystemTools::OP_GREATER;
-      }
+    }
 
-    if (*endr == '.')
-      {
+    if (*endr == '.') {
       endr++;
-      }
+    }
 
-    if (*endl == '.')
-      {
+    if (*endl == '.') {
       endl++;
-      }
     }
+  }
   // lhs == rhs, so true if operation is EQUAL
   return op == cmSystemTools::OP_EQUAL;
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::VersionCompareEqual(std::string const& lhs,
                                         std::string const& rhs)
 {
-  return cmSystemTools::VersionCompare(
-    cmSystemTools::OP_EQUAL, lhs.c_str(), rhs.c_str());
+  return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, lhs.c_str(),
+                                       rhs.c_str());
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::VersionCompareGreater(std::string const& lhs,
                                           std::string const& rhs)
 {
-  return cmSystemTools::VersionCompare(
-    cmSystemTools::OP_GREATER, lhs.c_str(), rhs.c_str());
+  return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER, lhs.c_str(),
+                                       rhs.c_str());
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
                                 bool* removed)
 {
 #if defined(CMAKE_USE_ELF_PARSER)
-  if(removed)
-    {
+  if (removed) {
     *removed = false;
-    }
+  }
   int zeroCount = 0;
-  unsigned long zeroPosition[2] = {0,0};
-  unsigned long zeroSize[2] = {0,0};
+  unsigned long zeroPosition[2] = { 0, 0 };
+  unsigned long zeroSize[2] = { 0, 0 };
   unsigned long bytesBegin = 0;
   std::vector<char> bytes;
   {
-  // Parse the ELF binary.
-  cmELF elf(file.c_str());
+    // Parse the ELF binary.
+    cmELF elf(file.c_str());
 
-  // Get the RPATH and RUNPATH entries from it and sort them by index
-  // in the dynamic section header.
-  int se_count = 0;
-  cmELF::StringEntry const* se[2] = {0, 0};
-  if(cmELF::StringEntry const* se_rpath = elf.GetRPath())
-    {
-    se[se_count++] = se_rpath;
-    }
-  if(cmELF::StringEntry const* se_runpath = elf.GetRunPath())
-    {
-    se[se_count++] = se_runpath;
-    }
-  if(se_count == 0)
-    {
-    // There is no RPATH or RUNPATH anyway.
-    return true;
+    // Get the RPATH and RUNPATH entries from it and sort them by index
+    // in the dynamic section header.
+    int se_count = 0;
+    cmELF::StringEntry const* se[2] = { 0, 0 };
+    if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) {
+      se[se_count++] = se_rpath;
+    }
+    if (cmELF::StringEntry const* se_runpath = elf.GetRunPath()) {
+      se[se_count++] = se_runpath;
     }
-  if(se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection)
-    {
-    std::swap(se[0], se[1]);
+    if (se_count == 0) {
+      // There is no RPATH or RUNPATH anyway.
+      return true;
+    }
+    if (se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection) {
+      std::swap(se[0], se[1]);
     }
 
-  // Get the size of the dynamic section header.
-  unsigned int count = elf.GetDynamicEntryCount();
-  if(count == 0)
-    {
-    // This should happen only for invalid ELF files where a DT_NULL
-    // appears before the end of the table.
-    if(emsg)
-      {
-      *emsg = "DYNAMIC section contains a DT_NULL before the end.";
+    // Get the size of the dynamic section header.
+    unsigned int count = elf.GetDynamicEntryCount();
+    if (count == 0) {
+      // This should happen only for invalid ELF files where a DT_NULL
+      // appears before the end of the table.
+      if (emsg) {
+        *emsg = "DYNAMIC section contains a DT_NULL before the end.";
       }
-    return false;
+      return false;
     }
 
-  // Save information about the string entries to be zeroed.
-  zeroCount = se_count;
-  for(int i=0; i < se_count; ++i)
-    {
-    zeroPosition[i] = se[i]->Position;
-    zeroSize[i] = se[i]->Size;
-    }
-
-  // Get the range of file positions corresponding to each entry and
-  // the rest of the table after them.
-  unsigned long entryBegin[3] = {0,0,0};
-  unsigned long entryEnd[2] = {0,0};
-  for(int i=0; i < se_count; ++i)
-    {
-    entryBegin[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection);
-    entryEnd[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection+1);
-    }
-  entryBegin[se_count] = elf.GetDynamicEntryPosition(count);
-
-  // The data are to be written over the old table entries starting at
-  // the first one being removed.
-  bytesBegin = entryBegin[0];
-  unsigned long bytesEnd = entryBegin[se_count];
-
-  // Allocate a buffer to hold the part of the file to be written.
-  // Initialize it with zeros.
-  bytes.resize(bytesEnd - bytesBegin, 0);
-
-  // Read the part of the DYNAMIC section header that will move.
-  // The remainder of the buffer will be left with zeros which
-  // represent a DT_NULL entry.
-  char* data = &bytes[0];
-  for(int i=0; i < se_count; ++i)
-    {
-    // Read data between the entries being removed.
-    unsigned long sz = entryBegin[i+1] - entryEnd[i];
-    if(sz > 0 && !elf.ReadBytes(entryEnd[i], sz, data))
-      {
-      if(emsg)
-        {
-        *emsg = "Failed to read DYNAMIC section header.";
+    // Save information about the string entries to be zeroed.
+    zeroCount = se_count;
+    for (int i = 0; i < se_count; ++i) {
+      zeroPosition[i] = se[i]->Position;
+      zeroSize[i] = se[i]->Size;
+    }
+
+    // Get the range of file positions corresponding to each entry and
+    // the rest of the table after them.
+    unsigned long entryBegin[3] = { 0, 0, 0 };
+    unsigned long entryEnd[2] = { 0, 0 };
+    for (int i = 0; i < se_count; ++i) {
+      entryBegin[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection);
+      entryEnd[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection + 1);
+    }
+    entryBegin[se_count] = elf.GetDynamicEntryPosition(count);
+
+    // The data are to be written over the old table entries starting at
+    // the first one being removed.
+    bytesBegin = entryBegin[0];
+    unsigned long bytesEnd = entryBegin[se_count];
+
+    // Allocate a buffer to hold the part of the file to be written.
+    // Initialize it with zeros.
+    bytes.resize(bytesEnd - bytesBegin, 0);
+
+    // Read the part of the DYNAMIC section header that will move.
+    // The remainder of the buffer will be left with zeros which
+    // represent a DT_NULL entry.
+    char* data = &bytes[0];
+    for (int i = 0; i < se_count; ++i) {
+      // Read data between the entries being removed.
+      unsigned long sz = entryBegin[i + 1] - entryEnd[i];
+      if (sz > 0 && !elf.ReadBytes(entryEnd[i], sz, data)) {
+        if (emsg) {
+          *emsg = "Failed to read DYNAMIC section header.";
         }
-      return false;
+        return false;
       }
-    data += sz;
+      data += sz;
     }
   }
 
   // Open the file for update.
   cmsys::ofstream f(file.c_str(),
-                  std::ios::in | std::ios::out | std::ios::binary);
-  if(!f)
-    {
-    if(emsg)
-      {
+                    std::ios::in | std::ios::out | std::ios::binary);
+  if (!f) {
+    if (emsg) {
       *emsg = "Error opening file for update.";
-      }
-    return false;
     }
+    return false;
+  }
 
   // Write the new DYNAMIC table header.
-  if(!f.seekp(bytesBegin))
-    {
-    if(emsg)
-      {
+  if (!f.seekp(bytesBegin)) {
+    if (emsg) {
       *emsg = "Error seeking to DYNAMIC table header for RPATH.";
-      }
-    return false;
     }
-  if(!f.write(&bytes[0], bytes.size()))
-    {
-    if(emsg)
-      {
-      *emsg = "Error replacing DYNAMIC table header.";
-      }
     return false;
+  }
+  if (!f.write(&bytes[0], bytes.size())) {
+    if (emsg) {
+      *emsg = "Error replacing DYNAMIC table header.";
     }
+    return false;
+  }
 
   // Fill the RPATH and RUNPATH strings with zero bytes.
-  for(int i=0; i < zeroCount; ++i)
-    {
-    if(!f.seekp(zeroPosition[i]))
-      {
-      if(emsg)
-        {
+  for (int i = 0; i < zeroCount; ++i) {
+    if (!f.seekp(zeroPosition[i])) {
+      if (emsg) {
         *emsg = "Error seeking to RPATH position.";
-        }
-      return false;
       }
-    for(unsigned long j=0; j < zeroSize[i]; ++j)
-      {
+      return false;
+    }
+    for (unsigned long j = 0; j < zeroSize[i]; ++j) {
       f << '\0';
-      }
-    if(!f)
-      {
-      if(emsg)
-        {
+    }
+    if (!f) {
+      if (emsg) {
         *emsg = "Error writing the empty rpath string to the file.";
-        }
-      return false;
       }
+      return false;
     }
+  }
 
   // Everything was updated successfully.
-  if(removed)
-    {
+  if (removed) {
     *removed = true;
-    }
+  }
   return true;
 #else
   (void)file;
@@ -2977,7 +2549,6 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::CheckRPath(std::string const& file,
                                std::string const& newRPath)
 {
@@ -2987,27 +2558,21 @@ bool cmSystemTools::CheckRPath(std::string const& file,
 
   // Get the RPATH or RUNPATH entry from it.
   cmELF::StringEntry const* se = elf.GetRPath();
-  if(!se)
-    {
+  if (!se) {
     se = elf.GetRunPath();
-    }
+  }
 
   // Make sure the current rpath contains the new rpath.
-  if(newRPath.empty())
-    {
-    if(!se)
-      {
+  if (newRPath.empty()) {
+    if (!se) {
       return true;
-      }
     }
-  else
-    {
-    if(se &&
-       cmSystemToolsFindRPath(se->Value, newRPath) != std::string::npos)
-      {
+  } else {
+    if (se &&
+        cmSystemToolsFindRPath(se->Value, newRPath) != std::string::npos) {
       return true;
-      }
     }
+  }
   return false;
 #else
   (void)file;
@@ -3016,67 +2581,55 @@ bool cmSystemTools::CheckRPath(std::string const& file,
 #endif
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::RepeatedRemoveDirectory(const char* dir)
 {
   // Windows sometimes locks files temporarily so try a few times.
-  for(int i = 0; i < 10; ++i)
-    {
-    if(cmSystemTools::RemoveADirectory(dir))
-      {
+  for (int i = 0; i < 10; ++i) {
+    if (cmSystemTools::RemoveADirectory(dir)) {
       return true;
-      }
-    cmSystemTools::Delay(100);
     }
+    cmSystemTools::Delay(100);
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
-                                  const std::string& sep)
+                                                 const std::string& sep)
 {
   std::vector<std::string> tokens;
   std::string::size_type tokend = 0;
 
-  do
-    {
-    std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
-    if (tokstart==std::string::npos)
-      {
-      break;    // no more tokens
-      }
-    tokend=str.find_first_of(sep,tokstart);
-    if (tokend==std::string::npos)
-      {
+  do {
+    std::string::size_type tokstart = str.find_first_not_of(sep, tokend);
+    if (tokstart == std::string::npos) {
+      break; // no more tokens
+    }
+    tokend = str.find_first_of(sep, tokstart);
+    if (tokend == std::string::npos) {
       tokens.push_back(str.substr(tokstart));
-      }
-    else
-      {
-      tokens.push_back(str.substr(tokstart,tokend-tokstart));
-      }
-    } while (tokend!=std::string::npos);
+    } else {
+      tokens.push_back(str.substr(tokstart, tokend - tokstart));
+    }
+  } while (tokend != std::string::npos);
 
-  if (tokens.empty())
-    {
+  if (tokens.empty()) {
     tokens.push_back("");
-    }
+  }
   return tokens;
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::StringToLong(const char* str, long* value)
 {
   errno = 0;
-  char *endp;
+  char* endp;
   *value = strtol(str, &endp, 10);
   return (*endp == '\0') && (endp != str) && (errno == 0);
 }
 
-//----------------------------------------------------------------------------
 bool cmSystemTools::StringToULong(const char* str, unsigned long* value)
 {
   errno = 0;
-  char *endp;
+  char* endp;
   *value = strtoul(str, &endp, 10);
   return (*endp == '\0') && (endp != str) && (errno == 0);
 }
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index f511ae4..df2c1f7 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -14,8 +14,8 @@
 
 #include "cmStandardIncludes.h"
 
-#include <cmsys/SystemTools.hxx>
 #include <cmsys/Process.h>
+#include <cmsys/SystemTools.hxx>
 
 class cmSystemToolsFileTime;
 
@@ -25,7 +25,7 @@ class cmSystemToolsFileTime;
  * cmSystemTools is a class that provides helper functions
  * for the CMake build system.
  */
-class cmSystemTools: public cmsys::SystemTools
+class cmSystemTools : public cmsys::SystemTools
 {
 public:
   typedef cmsys::SystemTools Superclass;
@@ -38,7 +38,7 @@ public:
                          std::vector<std::string>& argsOut);
   static void ExpandListArgument(const std::string& arg,
                                  std::vector<std::string>& argsOut,
-                                 bool emptyArgs=false);
+                                 bool emptyArgs = false);
 
   /**
    * Look for and replace registry values in a string
@@ -64,64 +64,59 @@ public:
    *  title as a const char*, and a reference to bool that when
    *  set to false, will disable furthur messages (cancel).
    */
-  static void SetMessageCallback(MessageCallback f, void* clientData=0);
+  static void SetMessageCallback(MessageCallback f, void* clientData = 0);
 
   /**
    * Display an error message.
    */
-  static void Error(const char* m, const char* m2=0,
-                    const char* m3=0, const char* m4=0);
+  static void Error(const char* m, const char* m2 = 0, const char* m3 = 0,
+                    const char* m4 = 0);
 
   /**
    * Display a message.
    */
-  static void Message(const char* m, const char* title=0);
+  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, size_t length);
-  static void SetStdoutCallback(OutputCallback, void* clientData=0);
+  static void SetStdoutCallback(OutputCallback, void* clientData = 0);
 
   ///! 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);
-
+  static void SetStderrCallback(OutputCallback, void* clientData = 0);
 
   typedef bool (*InterruptCallback)(void*);
-  static void SetInterruptCallback(InterruptCallback f, void* clientData=0);
+  static void SetInterruptCallback(InterruptCallback f, void* clientData = 0);
   static bool GetInterruptFlag();
 
   ///! Return true if there was an error at any point.
   static bool GetErrorOccuredFlag()
-    {
-      return cmSystemTools::s_ErrorOccured ||
-        cmSystemTools::s_FatalErrorOccured ||
-        GetInterruptFlag();
-    }
+  {
+    return cmSystemTools::s_ErrorOccured ||
+      cmSystemTools::s_FatalErrorOccured || GetInterruptFlag();
+  }
   ///! If this is set to true, cmake stops processing commands.
   static void SetFatalErrorOccured()
-    {
-      cmSystemTools::s_FatalErrorOccured = true;
-    }
-  static void SetErrorOccured()
-    {
-      cmSystemTools::s_ErrorOccured = true;
-    }
- ///! Return true if there was an error at any point.
+  {
+    cmSystemTools::s_FatalErrorOccured = true;
+  }
+  static void SetErrorOccured() { cmSystemTools::s_ErrorOccured = true; }
+  ///! Return true if there was an error at any point.
   static bool GetFatalErrorOccured()
-    {
-      return cmSystemTools::s_FatalErrorOccured || GetInterruptFlag();
-    }
+  {
+    return cmSystemTools::s_FatalErrorOccured || GetInterruptFlag();
+  }
 
-  ///! Set the error occured flag and fatal error back to false
+  ///! Set the error occurred flag and fatal error back to false
   static void ResetErrorOccuredFlag()
-    {
-      cmSystemTools::s_FatalErrorOccured = false;
-      cmSystemTools::s_ErrorOccured = false;
-    }
+  {
+    cmSystemTools::s_FatalErrorOccured = false;
+    cmSystemTools::s_ErrorOccured = false;
+  }
 
   /**
    * Does a string indicates that CMake/CPack/CTest internally
@@ -150,8 +145,7 @@ public:
   static bool IsPathToFramework(const char* value);
 
   static bool DoesFileExistWithExtensions(
-    const char *name,
-    const std::vector<std::string>& sourceExts);
+    const char* name, const std::vector<std::string>& sourceExts);
 
   /**
    * Check if the given file exists in one of the parent directory of the
@@ -159,7 +153,8 @@ public:
    * Toplevel specifies the top-most directory to where it will look.
    */
   static std::string FileExistsInParentDirectories(const char* fname,
-    const char* directory, const char* toplevel);
+                                                   const char* directory,
+                                                   const char* toplevel);
 
   static void Glob(const std::string& directory, const std::string& regexp,
                    std::vector<std::string>& files);
@@ -176,13 +171,11 @@ public:
    * files only. This method returns true if search was succesfull.
    */
   static bool SimpleGlob(const std::string& glob,
-                         std::vector<std::string>& files,
-                         int type = 0);
+                         std::vector<std::string>& files, int type = 0);
 
   ///! Copy a file.
   static bool cmCopyFile(const char* source, const char* destination);
-  static bool CopyFileIfDifferent(const char* source,
-    const char* destination);
+  static bool CopyFileIfDifferent(const char* source, const char* destination);
 
   /** Rename a file or directory within a single disk volume (atomic
       if possible).  */
@@ -219,17 +212,17 @@ public:
    * it into this function or it will not work.  The command must be correctly
    * escaped for this to with spaces.
    */
-   enum OutputOption
-   {
-     OUTPUT_NONE = 0,
-     OUTPUT_MERGE,
-     OUTPUT_FORWARD,
-     OUTPUT_PASSTHROUGH
-   };
+  enum OutputOption
+  {
+    OUTPUT_NONE = 0,
+    OUTPUT_MERGE,
+    OUTPUT_FORWARD,
+    OUTPUT_PASSTHROUGH
+  };
   static bool RunSingleCommand(const char* command,
                                std::string* captureStdOut = 0,
-                               std::string* captureStdErr = 0,
-                               int* retVal = 0, const char* dir = 0,
+                               std::string* captureStdErr = 0, int* retVal = 0,
+                               const char* dir = 0,
                                OutputOption outputflag = OUTPUT_MERGE,
                                double timeout = 0.0);
   /**
@@ -239,8 +232,8 @@ public:
    */
   static bool RunSingleCommand(std::vector<std::string> const& command,
                                std::string* captureStdOut = 0,
-                               std::string* captureStdErr = 0,
-                               int* retVal = 0, const char* dir = 0,
+                               std::string* captureStdErr = 0, int* retVal = 0,
+                               const char* dir = 0,
                                OutputOption outputflag = OUTPUT_MERGE,
                                double timeout = 0.0);
 
@@ -261,14 +254,15 @@ public:
 
   static void EnableMessages() { s_DisableMessages = false; }
   static void DisableMessages() { s_DisableMessages = true; }
-  static void DisableRunCommandOutput() {s_DisableRunCommandOutput = true; }
-  static void EnableRunCommandOutput() {s_DisableRunCommandOutput = false; }
+  static void DisableRunCommandOutput() { s_DisableRunCommandOutput = true; }
+  static void EnableRunCommandOutput() { s_DisableRunCommandOutput = false; }
   static bool GetRunCommandOutput() { return s_DisableRunCommandOutput; }
 
   /**
    * Some constants for different file formats.
    */
-  enum FileFormat {
+  enum FileFormat
+  {
     NO_FILE_FORMAT = 0,
     C_FILE_FORMAT,
     CXX_FILE_FORMAT,
@@ -284,7 +278,8 @@ public:
     UNKNOWN_FILE_FORMAT
   };
 
-  enum CompareOp {
+  enum CompareOp
+  {
     OP_LESS,
     OP_GREATER,
     OP_EQUAL
@@ -307,8 +302,8 @@ public:
   /** Windows if this is true, the CreateProcess in RunCommand will
    *  not show new consol windows when running programs.
    */
-  static void SetRunCommandHideConsole(bool v){s_RunCommandHideConsole = v;}
-  static bool GetRunCommandHideConsole(){ return s_RunCommandHideConsole;}
+  static void SetRunCommandHideConsole(bool v) { s_RunCommandHideConsole = v; }
+  static bool GetRunCommandHideConsole() { return s_RunCommandHideConsole; }
   /** Call cmSystemTools::Error with the message m, plus the
    * result of strerror(errno)
    */
@@ -316,21 +311,14 @@ public:
 
   /** a general output handler for cmsysProcess  */
   static int WaitForLine(cmsysProcess* process, std::string& line,
-                         double timeout,
-                         std::vector<char>& out,
+                         double timeout, std::vector<char>& out,
                          std::vector<char>& err);
 
   /** 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<std::string>& l);
-  static void SetForceUnixPaths(bool v)
-    {
-      s_ForceUnixPaths = v;
-    }
-  static bool GetForceUnixPaths()
-    {
-      return s_ForceUnixPaths;
-    }
+  static void SetForceUnixPaths(bool v) { s_ForceUnixPaths = v; }
+  static bool GetForceUnixPaths() { return s_ForceUnixPaths; }
 
   // ConvertToOutputPath use s_ForceUnixPaths
   static std::string ConvertToOutputPath(const char* path);
@@ -377,6 +365,7 @@ public:
   public:
     SaveRestoreEnvironment();
     virtual ~SaveRestoreEnvironment();
+
   private:
     std::vector<std::string> Env;
   };
@@ -393,8 +382,7 @@ public:
     TarCompressXZ,
     TarCompressNone
   };
-  static bool ListTar(const char* outFileName,
-                      bool verbose);
+  static bool ListTar(const char* outFileName, bool verbose);
   static bool CreateTar(const char* outFileName,
                         const std::vector<std::string>& files,
                         cmTarCompression compressType, bool verbose,
@@ -434,8 +422,8 @@ public:
   static std::string const& GetCMakeRoot();
 
   /** Echo a message in color using KWSys's Terminal cprintf.  */
-  static void MakefileColorEcho(int color, const char* message,
-                                bool newLine, bool enabled);
+  static void MakefileColorEcho(int color, const char* message, bool newLine,
+                                bool enabled);
 
   /** Try to guess the soname of a shared library.  */
   static bool GuessLibrarySOName(std::string const& fullPath,
@@ -443,13 +431,11 @@ public:
 
   /** Try to guess the install name of a shared library.  */
   static bool GuessLibraryInstallName(std::string const& fullPath,
-                                 std::string& soname);
+                                      std::string& soname);
 
   /** Try to set the RPATH in an ELF binary.  */
-  static bool ChangeRPath(std::string const& file,
-                          std::string const& oldRPath,
-                          std::string const& newRPath,
-                          std::string* emsg = 0,
+  static bool ChangeRPath(std::string const& file, std::string const& oldRPath,
+                          std::string const& newRPath, std::string* emsg = 0,
                           bool* changed = 0);
 
   /** Try to remove the RPATH from an ELF binary.  */
@@ -458,8 +444,7 @@ public:
 
   /** Check whether the RPATH in an ELF binary contains the path
       given.  */
-  static bool CheckRPath(std::string const& file,
-                         std::string const& newRPath);
+  static bool CheckRPath(std::string const& file, std::string const& newRPath);
 
   /** Remove a directory; repeat a few times in case of locked files.  */
   static bool RepeatedRemoveDirectory(const char* dir);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1986e5f..f435a1d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -10,22 +10,23 @@
   See the License for more information.
 ============================================================================*/
 #include "cmTarget.h"
-#include "cmake.h"
-#include "cmMakefile.h"
-#include "cmSourceFile.h"
-#include "cmOutputConverter.h"
-#include "cmGlobalGenerator.h"
+
+#include "cmAlgorithms.h"
 #include "cmComputeLinkInformation.h"
-#include "cmListFileCache.h"
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorExpressionDAGChecker.h"
-#include "cmAlgorithms.h"
+#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
+#include "cmMakefile.h"
+#include "cmOutputConverter.h"
+#include "cmSourceFile.h"
+#include "cmake.h"
+#include <assert.h>
 #include <cmsys/RegularExpression.hxx>
+#include <errno.h>
 #include <map>
 #include <set>
 #include <stdlib.h> // required for atof
-#include <assert.h>
-#include <errno.h>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include <cmsys/hash_set.hxx>
 #define UNORDERED_SET cmsys::hash_set
@@ -33,7 +34,6 @@
 #define UNORDERED_SET std::set
 #endif
 
-//----------------------------------------------------------------------------
 class cmTargetInternals
 {
 public:
@@ -51,13 +51,9 @@ public:
   std::vector<cmListFileBacktrace> LinkImplementationPropertyBacktraces;
 };
 
-//----------------------------------------------------------------------------
 cmTarget::cmTarget()
 {
   this->Makefile = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  this->LinkLibrariesForVS6Analyzed = false;
-#endif
   this->HaveInstallRule = false;
   this->DLLPlatform = false;
   this->IsAndroid = false;
@@ -71,27 +67,23 @@ void cmTarget::SetType(cmState::TargetType type, const std::string& name)
   this->Name = name;
   // only add dependency information for library targets
   this->TargetTypeValue = type;
-  if(this->TargetTypeValue >= cmState::STATIC_LIBRARY
-     && this->TargetTypeValue <= cmState::MODULE_LIBRARY)
-    {
+  if (this->TargetTypeValue >= cmState::STATIC_LIBRARY &&
+      this->TargetTypeValue <= cmState::MODULE_LIBRARY) {
     this->RecordDependencies = true;
-    }
-  else
-    {
+  } else {
     this->RecordDependencies = false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::SetMakefile(cmMakefile* mf)
 {
   // Set our makefile.
   this->Makefile = mf;
 
   // Check whether this is a DLL platform.
-  this->DLLPlatform = (this->Makefile->IsOn("WIN32") ||
-                       this->Makefile->IsOn("CYGWIN") ||
-                       this->Makefile->IsOn("MINGW"));
+  this->DLLPlatform =
+    (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
+     this->Makefile->IsOn("MINGW"));
 
   // Check whether we are targeting an Android platform.
   this->IsAndroid =
@@ -99,9 +91,8 @@ void cmTarget::SetMakefile(cmMakefile* mf)
            "Android") == 0;
 
   // Setup default property values.
-  if (this->GetType() != cmState::INTERFACE_LIBRARY
-      && this->GetType() != cmState::UTILITY)
-    {
+  if (this->GetType() != cmState::INTERFACE_LIBRARY &&
+      this->GetType() != cmState::UTILITY) {
     this->SetPropertyDefault("ANDROID_API", 0);
     this->SetPropertyDefault("ANDROID_API_MIN", 0);
     this->SetPropertyDefault("ANDROID_ARCH", 0);
@@ -145,11 +136,13 @@ void cmTarget::SetMakefile(cmMakefile* mf)
     this->SetPropertyDefault("MACOSX_BUNDLE", 0);
     this->SetPropertyDefault("MACOSX_RPATH", 0);
     this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
+    this->SetPropertyDefault("C_CLANG_TIDY", 0);
     this->SetPropertyDefault("C_COMPILER_LAUNCHER", 0);
     this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", 0);
     this->SetPropertyDefault("C_STANDARD", 0);
     this->SetPropertyDefault("C_STANDARD_REQUIRED", 0);
     this->SetPropertyDefault("C_EXTENSIONS", 0);
+    this->SetPropertyDefault("CXX_CLANG_TIDY", 0);
     this->SetPropertyDefault("CXX_COMPILER_LAUNCHER", 0);
     this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", 0);
     this->SetPropertyDefault("CXX_STANDARD", 0);
@@ -157,184 +150,166 @@ void cmTarget::SetMakefile(cmMakefile* mf)
     this->SetPropertyDefault("CXX_EXTENSIONS", 0);
     this->SetPropertyDefault("LINK_SEARCH_START_STATIC", 0);
     this->SetPropertyDefault("LINK_SEARCH_END_STATIC", 0);
-    }
+  }
 
   // Collect the set of configuration types.
   std::vector<std::string> configNames;
   mf->GetConfigurations(configNames);
 
   // Setup per-configuration property default values.
-  if (this->GetType() != cmState::UTILITY)
-    {
+  if (this->GetType() != cmState::UTILITY) {
     const char* configProps[] = {
+      /* clang-format needs this comment to break after the opening brace */
       "ARCHIVE_OUTPUT_DIRECTORY_",
       "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();
-        ci != configNames.end(); ++ci)
-      {
+      0
+    };
+    for (std::vector<std::string>::iterator ci = configNames.begin();
+         ci != configNames.end(); ++ci) {
       std::string configUpper = cmSystemTools::UpperCase(*ci);
-      for(const char** p = configProps; *p; ++p)
-        {
-        if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY
-            && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0)
-          {
+      for (const char** p = configProps; *p; ++p) {
+        if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY &&
+            strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) {
           continue;
-          }
+        }
         std::string property = *p;
         property += configUpper;
         this->SetPropertyDefault(property, 0);
-        }
+      }
 
       // Initialize per-configuration name postfix property from the
       // variable only for non-executable targets.  This preserves
       // compatibility with previous CMake versions in which executables
       // did not support this variable.  Projects may still specify the
       // property directly.
-      if(this->TargetTypeValue != cmState::EXECUTABLE
-          && this->TargetTypeValue != cmState::INTERFACE_LIBRARY)
-        {
+      if (this->TargetTypeValue != cmState::EXECUTABLE &&
+          this->TargetTypeValue != cmState::INTERFACE_LIBRARY) {
         std::string property = cmSystemTools::UpperCase(*ci);
         property += "_POSTFIX";
         this->SetPropertyDefault(property, 0);
-        }
       }
     }
+  }
 
   // Save the backtrace of target construction.
   this->Backtrace = this->Makefile->GetBacktrace();
 
-  if (!this->IsImported())
-    {
+  if (!this->IsImported()) {
     // Initialize the INCLUDE_DIRECTORIES property based on the current value
     // of the same directory property:
     const cmStringRange parentIncludes =
-        this->Makefile->GetIncludeDirectoriesEntries();
+      this->Makefile->GetIncludeDirectoriesEntries();
     const cmBacktraceRange parentIncludesBts =
-        this->Makefile->GetIncludeDirectoriesBacktraces();
+      this->Makefile->GetIncludeDirectoriesBacktraces();
 
     this->Internal->IncludeDirectoriesEntries.insert(
-          this->Internal->IncludeDirectoriesEntries.end(),
-          parentIncludes.begin(), parentIncludes.end());
+      this->Internal->IncludeDirectoriesEntries.end(), parentIncludes.begin(),
+      parentIncludes.end());
     this->Internal->IncludeDirectoriesBacktraces.insert(
-          this->Internal->IncludeDirectoriesBacktraces.end(),
-          parentIncludesBts.begin(), parentIncludesBts.end());
+      this->Internal->IncludeDirectoriesBacktraces.end(),
+      parentIncludesBts.begin(), parentIncludesBts.end());
 
     const std::set<std::string> parentSystemIncludes =
-                                this->Makefile->GetSystemIncludeDirectories();
+      this->Makefile->GetSystemIncludeDirectories();
 
     this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(),
                                           parentSystemIncludes.end());
 
     const cmStringRange parentOptions =
-                                this->Makefile->GetCompileOptionsEntries();
+      this->Makefile->GetCompileOptionsEntries();
     const cmBacktraceRange parentOptionsBts =
-                                this->Makefile->GetCompileOptionsBacktraces();
+      this->Makefile->GetCompileOptionsBacktraces();
 
     this->Internal->CompileOptionsEntries.insert(
-          this->Internal->CompileOptionsEntries.end(),
-          parentOptions.begin(), parentOptions.end());
+      this->Internal->CompileOptionsEntries.end(), parentOptions.begin(),
+      parentOptions.end());
     this->Internal->CompileOptionsBacktraces.insert(
-          this->Internal->CompileOptionsBacktraces.end(),
-          parentOptionsBts.begin(), parentOptionsBts.end());
-    }
+      this->Internal->CompileOptionsBacktraces.end(), parentOptionsBts.begin(),
+      parentOptionsBts.end());
+  }
 
-  if (this->GetType() != cmState::INTERFACE_LIBRARY
-      && this->GetType() != cmState::UTILITY)
-    {
+  if (this->GetType() != cmState::INTERFACE_LIBRARY &&
+      this->GetType() != cmState::UTILITY) {
     this->SetPropertyDefault("C_VISIBILITY_PRESET", 0);
     this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0);
     this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0);
-    }
+  }
 
-  if(this->TargetTypeValue == cmState::EXECUTABLE)
-    {
+  if (this->TargetTypeValue == cmState::EXECUTABLE) {
     this->SetPropertyDefault("ANDROID_GUI", 0);
     this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", 0);
     this->SetPropertyDefault("ENABLE_EXPORTS", 0);
-    }
-  if(this->TargetTypeValue == cmState::SHARED_LIBRARY
-      || this->TargetTypeValue == cmState::MODULE_LIBRARY)
-    {
+  }
+  if (this->TargetTypeValue == cmState::SHARED_LIBRARY ||
+      this->TargetTypeValue == cmState::MODULE_LIBRARY) {
     this->SetProperty("POSITION_INDEPENDENT_CODE", "True");
-    }
-  if(this->TargetTypeValue == cmState::SHARED_LIBRARY)
-    {
+  }
+  if (this->TargetTypeValue == cmState::SHARED_LIBRARY) {
     this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", 0);
-    }
+  }
 
-  if (this->GetType() != cmState::INTERFACE_LIBRARY
-      && this->GetType() != cmState::UTILITY)
-    {
+  if (this->GetType() != cmState::INTERFACE_LIBRARY &&
+      this->GetType() != cmState::UTILITY) {
     this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0);
-    }
+  }
 
   // Record current policies for later use.
   this->Makefile->RecordPolicies(this->PolicyMap);
 
-  if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY) {
     // This policy is checked in a few conditions. The properties relevant
     // to the policy are always ignored for cmState::INTERFACE_LIBRARY targets,
     // so ensure that the conditions don't lead to nonsense.
     this->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW);
-    }
+  }
 
-  if (this->GetType() != cmState::INTERFACE_LIBRARY
-      && this->GetType() != cmState::UTILITY)
-    {
+  if (this->GetType() != cmState::INTERFACE_LIBRARY &&
+      this->GetType() != cmState::UTILITY) {
     this->SetPropertyDefault("JOB_POOL_COMPILE", 0);
     this->SetPropertyDefault("JOB_POOL_LINK", 0);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
+void cmTarget::AddUtility(const std::string& u, cmMakefile* makefile)
 {
-  if(this->Utilities.insert(u).second && makefile)
-    {
+  if (this->Utilities.insert(u).second && makefile) {
     this->UtilityBacktraces.insert(
-            std::make_pair(u, makefile->GetBacktrace()));
-    }
+      std::make_pair(u, makefile->GetBacktrace()));
+  }
 }
 
-//----------------------------------------------------------------------------
 cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
-    const std::string& u) const
+  const std::string& u) const
 {
   std::map<std::string, cmListFileBacktrace>::const_iterator i =
     this->UtilityBacktraces.find(u);
-  if(i == this->UtilityBacktraces.end()) return 0;
+  if (i == this->UtilityBacktraces.end())
+    return 0;
 
   return &i->second;
 }
 
-//----------------------------------------------------------------------------
 cmListFileBacktrace const& cmTarget::GetBacktrace() const
 {
   return this->Backtrace;
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::IsExecutableWithExports() const
 {
   return (this->GetType() == cmState::EXECUTABLE &&
           this->GetPropertyAsBool("ENABLE_EXPORTS"));
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::HasImportLibrary() const
 {
-  return (this->DLLPlatform &&
-          (this->GetType() == cmState::SHARED_LIBRARY ||
-           this->IsExecutableWithExports()));
+  return (this->DLLPlatform && (this->GetType() == cmState::SHARED_LIBRARY ||
+                                this->IsExecutableWithExports()));
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::IsFrameworkOnApple() const
 {
   return (this->GetType() == cmState::SHARED_LIBRARY &&
@@ -342,7 +317,6 @@ bool cmTarget::IsFrameworkOnApple() const
           this->GetPropertyAsBool("FRAMEWORK"));
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::IsAppBundleOnApple() const
 {
   return (this->GetType() == cmState::EXECUTABLE &&
@@ -350,53 +324,44 @@ bool cmTarget::IsAppBundleOnApple() const
           this->GetPropertyAsBool("MACOSX_BUNDLE"));
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
 {
-  if (!srcs.empty())
-    {
+  if (!srcs.empty()) {
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     this->Internal->SourceEntries.push_back(cmJoin(srcs, ";"));
     this->Internal->SourceBacktraces.push_back(lfbt);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 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)
-    {
+  for (std::vector<std::string>::const_iterator i = srcs.begin();
+       i != srcs.end(); ++i) {
     std::string filename = *i;
     const char* src = filename.c_str();
 
-    if(!(src[0] == '$' && src[1] == '<'))
-      {
-      if(!filename.empty())
-        {
+    if (!(src[0] == '$' && src[1] == '<')) {
+      if (!filename.empty()) {
         filename = this->ProcessSourceItemCMP0049(filename);
-        if(filename.empty())
-          {
+        if (filename.empty()) {
           return;
-          }
         }
-      this->Makefile->GetOrCreateSource(filename);
       }
+      this->Makefile->GetOrCreateSource(filename);
+    }
     srcFiles += sep;
     srcFiles += filename;
     sep = ";";
-    }
-  if (!srcFiles.empty())
-    {
+  }
+  if (!srcFiles.empty()) {
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     this->Internal->SourceEntries.push_back(srcFiles);
     this->Internal->SourceBacktraces.push_back(lfbt);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
 {
   std::string src = s;
@@ -404,13 +369,11 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
   // For backwards compatibility replace varibles in source names.
   // This should eventually be removed.
   this->Makefile->ExpandVariablesInString(src);
-  if (src != s)
-    {
+  if (src != s) {
     std::ostringstream e;
     bool noMessage = false;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0049) << "\n";
         break;
@@ -421,35 +384,30 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::NEW:
         messageType = cmake::FATAL_ERROR;
-      }
-    if (!noMessage)
-      {
-      e << "Legacy variable expansion in source file \""
-        << s << "\" expanded to \"" << src << "\" in target \""
-        << this->GetName() << "\".  This behavior will be removed in a "
-        "future version of CMake.";
+    }
+    if (!noMessage) {
+      e << "Legacy variable expansion in source file \"" << 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());
-      if (messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return "";
-        }
       }
     }
+  }
   return src;
 }
 
-//----------------------------------------------------------------------------
 cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
 {
   std::string src = this->ProcessSourceItemCMP0049(s);
-  if(!s.empty() && src.empty())
-    {
+  if (!s.empty() && src.empty()) {
     return 0;
-    }
+  }
   return this->AddSource(src);
 }
 
-//----------------------------------------------------------------------------
 struct CreateLocation
 {
   cmMakefile const* Makefile;
@@ -457,7 +415,6 @@ struct CreateLocation
   CreateLocation(cmMakefile const* mf)
     : Makefile(mf)
   {
-
   }
 
   cmSourceFileLocation operator()(const std::string& filename)
@@ -466,7 +423,6 @@ struct CreateLocation
   }
 };
 
-//----------------------------------------------------------------------------
 struct LocationMatcher
 {
   const cmSourceFileLocation& Needle;
@@ -474,26 +430,23 @@ struct LocationMatcher
   LocationMatcher(const cmSourceFileLocation& needle)
     : Needle(needle)
   {
-
   }
 
-  bool operator()(cmSourceFileLocation &loc)
+  bool operator()(cmSourceFileLocation& loc)
   {
     return loc.Matches(this->Needle);
   }
 };
 
-
-//----------------------------------------------------------------------------
 struct TargetPropertyEntryFinder
 {
 private:
   const cmSourceFileLocation& Needle;
+
 public:
   TargetPropertyEntryFinder(const cmSourceFileLocation& needle)
     : Needle(needle)
   {
-
   }
 
   bool operator()(std::string const& entry)
@@ -505,203 +458,172 @@ public:
                    CreateLocation(this->Needle.GetMakefile()));
 
     return std::find_if(locations.begin(), locations.end(),
-        LocationMatcher(this->Needle)) != 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())
-    {
+                   TargetPropertyEntryFinder(sfl)) ==
+      this->Internal->SourceEntries.end()) {
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     this->Internal->SourceEntries.push_back(src);
     this->Internal->SourceBacktraces.push_back(lfbt);
-    }
-  if (cmGeneratorExpression::Find(src) != std::string::npos)
-    {
+  }
+  if (cmGeneratorExpression::Find(src) != std::string::npos) {
     return 0;
-    }
+  }
   return this->Makefile->GetOrCreateSource(src);
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::MergeLinkLibraries( cmMakefile& mf,
-                                   const std::string& selfname,
-                                   const LinkLibraryVectorType& libs )
+void cmTarget::MergeLinkLibraries(cmMakefile& mf, const std::string& selfname,
+                                  const LinkLibraryVectorType& libs)
 {
   // Only add on libraries we haven't added on before.
   // Assumption: the global link libraries could only grow, never shrink
   LinkLibraryVectorType::const_iterator i = libs.begin();
   i += this->PrevLinkedLibraries.size();
-  for( ; i != libs.end(); ++i )
-    {
+  for (; i != libs.end(); ++i) {
     // This is equivalent to the target_link_libraries plain signature.
-    this->AddLinkLibrary( mf, selfname, i->first, i->second );
-    this->AppendProperty("INTERFACE_LINK_LIBRARIES",
+    this->AddLinkLibrary(mf, selfname, i->first, i->second);
+    this->AppendProperty(
+      "INTERFACE_LINK_LIBRARIES",
       this->GetDebugGeneratorExpressions(i->first, i->second).c_str());
-    }
+  }
   this->PrevLinkedLibraries = libs;
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::AddLinkDirectory(const std::string& d)
 {
   // Make sure we don't add unnecessary search directories.
-  if(this->LinkDirectoriesEmmitted.insert(d).second)
-    {
+  if (this->LinkDirectoriesEmmitted.insert(d).second) {
     this->LinkDirectories.push_back(d);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 const std::vector<std::string>& cmTarget::GetLinkDirectories() const
 {
   return this->LinkDirectories;
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::ClearDependencyInformation( cmMakefile& mf,
-                                           const std::string& target )
+void cmTarget::ClearDependencyInformation(cmMakefile& mf,
+                                          const std::string& target)
 {
   // Clear the dependencies. The cache variable must exist iff we are
   // recording dependency information for this target.
   std::string depname = target;
   depname += "_LIB_DEPENDS";
-  if (this->RecordDependencies)
-    {
-    mf.AddCacheDefinition(depname, "",
-                          "Dependencies for target", cmState::STATIC);
-    }
-  else
-    {
-    if (mf.GetDefinition( depname ))
-      {
+  if (this->RecordDependencies) {
+    mf.AddCacheDefinition(depname, "", "Dependencies for target",
+                          cmState::STATIC);
+  } else {
+    if (mf.GetDefinition(depname)) {
       std::string message = "Target ";
       message += target;
       message += " has dependency information when it shouldn't.\n";
       message += "Your cache is probably stale. Please remove the entry\n  ";
       message += depname;
       message += "\nfrom the cache.";
-      cmSystemTools::Error( message.c_str() );
-      }
+      cmSystemTools::Error(message.c_str());
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
-                                  cmTargetLinkLibraryType llt) const
+std::string cmTarget::GetDebugGeneratorExpressions(
+  const std::string& value, cmTargetLinkLibraryType llt) const
 {
-  if (llt == GENERAL_LibraryType)
-    {
+  if (llt == GENERAL_LibraryType) {
     return value;
-    }
+  }
 
   // Get the list of configurations considered to be DEBUG.
   std::vector<std::string> debugConfigs =
-                      this->Makefile->GetCMakeInstance()->GetDebugConfigs();
+    this->Makefile->GetCMakeInstance()->GetDebugConfigs();
 
   std::string configString = "$<CONFIG:" + debugConfigs[0] + ">";
 
-  if (debugConfigs.size() > 1)
-    {
-    for(std::vector<std::string>::const_iterator
-          li = debugConfigs.begin() + 1; li != debugConfigs.end(); ++li)
-      {
+  if (debugConfigs.size() > 1) {
+    for (std::vector<std::string>::const_iterator li =
+           debugConfigs.begin() + 1;
+         li != debugConfigs.end(); ++li) {
       configString += ",$<CONFIG:" + *li + ">";
-      }
-    configString = "$<OR:" + configString + ">";
     }
+    configString = "$<OR:" + configString + ">";
+  }
 
-  if (llt == OPTIMIZED_LibraryType)
-    {
+  if (llt == OPTIMIZED_LibraryType) {
     configString = "$<NOT:" + configString + ">";
-    }
+  }
   return "$<" + configString + ":" + value + ">";
 }
 
-//----------------------------------------------------------------------------
 static std::string targetNameGenex(const std::string& lib)
 {
   return "$<TARGET_NAME:" + lib + ">";
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::PushTLLCommandTrace(TLLSignature signature,
                                    cmListFileContext const& lfc)
 {
   bool ret = true;
-  if (!this->TLLCommands.empty())
-    {
-    if (this->TLLCommands.back().first != signature)
-      {
+  if (!this->TLLCommands.empty()) {
+    if (this->TLLCommands.back().first != signature) {
       ret = false;
-      }
     }
-  if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc)
-    {
+  }
+  if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc) {
     this->TLLCommands.push_back(std::make_pair(signature, lfc));
-    }
+  }
   return ret;
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::GetTllSignatureTraces(std::ostringstream &s,
+void cmTarget::GetTllSignatureTraces(std::ostringstream& s,
                                      TLLSignature sig) const
 {
-  const char *sigString = (sig == cmTarget::KeywordTLLSignature ? "keyword"
-                                                                : "plain");
+  const char* sigString =
+    (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain");
   s << "The uses of the " << sigString << " signature are here:\n";
   typedef std::vector<std::pair<TLLSignature, cmListFileContext> > Container;
   cmOutputConverter converter(this->GetMakefile()->GetStateSnapshot());
-  for(Container::const_iterator it = this->TLLCommands.begin();
-      it != this->TLLCommands.end(); ++it)
-    {
-    if (it->first == sig)
-      {
+  for (Container::const_iterator it = this->TLLCommands.begin();
+       it != this->TLLCommands.end(); ++it) {
+    if (it->first == sig) {
       cmListFileContext lfc = it->second;
       lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
       s << " * " << lfc << std::endl;
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmTarget::AddLinkLibrary(cmMakefile& mf,
-                              const std::string& target,
+void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& target,
                               const std::string& lib,
                               cmTargetLinkLibraryType llt)
 {
-  cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
+  cmTarget* tgt = this->Makefile->FindTargetToUse(lib);
   {
-  const bool isNonImportedTarget = tgt && !tgt->IsImported();
+    const bool isNonImportedTarget = tgt && !tgt->IsImported();
 
-  const std::string libName =
+    const std::string libName =
       (isNonImportedTarget && llt != GENERAL_LibraryType)
       ? targetNameGenex(lib)
       : lib;
-  this->AppendProperty("LINK_LIBRARIES",
-                       this->GetDebugGeneratorExpressions(libName,
-                                                          llt).c_str());
+    this->AppendProperty(
+      "LINK_LIBRARIES",
+      this->GetDebugGeneratorExpressions(libName, llt).c_str());
   }
 
-  if (cmGeneratorExpression::Find(lib) != std::string::npos
-      || (tgt && tgt->GetType() == cmState::INTERFACE_LIBRARY)
-      || (target == lib ))
-    {
+  if (cmGeneratorExpression::Find(lib) != std::string::npos ||
+      (tgt && tgt->GetType() == cmState::INTERFACE_LIBRARY) ||
+      (target == lib)) {
     return;
-    }
+  }
 
   cmTarget::LibraryID tmp;
   tmp.first = lib;
   tmp.second = llt;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  this->LinkLibrariesForVS6.push_back( tmp );
-#endif
   this->OriginalLinkLibraries.push_back(tmp);
 
   // Add the explicit dependency information for this target. This is
@@ -712,18 +634,15 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
   // may be purposefully duplicated to handle recursive dependencies,
   // and we removing one instance will break the link line. Duplicates
   // will be appropriately eliminated at emit time.
-  if(this->RecordDependencies)
-    {
+  if (this->RecordDependencies) {
     std::string targetEntry = target;
     targetEntry += "_LIB_DEPENDS";
     std::string dependencies;
-    const char* old_val = mf.GetDefinition( targetEntry );
-    if( old_val )
-      {
+    const char* old_val = mf.GetDefinition(targetEntry);
+    if (old_val) {
       dependencies += old_val;
-      }
-    switch (llt)
-      {
+    }
+    switch (llt) {
       case GENERAL_LibraryType:
         dependencies += "general";
         break;
@@ -733,20 +652,16 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
       case OPTIMIZED_LibraryType:
         dependencies += "optimized";
         break;
-      }
+    }
     dependencies += ";";
     dependencies += lib;
     dependencies += ";";
-    mf.AddCacheDefinition( targetEntry, dependencies.c_str(),
-                           "Dependencies for the target",
-                           cmState::STATIC );
-    }
-
+    mf.AddCacheDefinition(targetEntry, dependencies.c_str(),
+                          "Dependencies for the target", cmState::STATIC);
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs)
+void cmTarget::AddSystemIncludeDirectories(const std::set<std::string>& incs)
 {
   this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
 }
@@ -811,308 +726,13 @@ cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const
   return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces);
 }
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-//----------------------------------------------------------------------------
-void
-cmTarget::AnalyzeLibDependenciesForVS6( const cmMakefile& mf )
-{
-  // There are two key parts of the dependency analysis: (1)
-  // determining the libraries in the link line, and (2) constructing
-  // the dependency graph for those libraries.
-  //
-  // The latter is done using the cache entries that record the
-  // dependencies of each library.
-  //
-  // The former is a more thorny issue, since it is not clear how to
-  // determine if two libraries listed on the link line refer to the a
-  // single library or not. For example, consider the link "libraries"
-  //    /usr/lib/libtiff.so -ltiff
-  // Is this one library or two? The solution implemented here is the
-  // simplest (and probably the only practical) one: two libraries are
-  // the same if their "link strings" are identical. Thus, the two
-  // libraries above are considered distinct. This also means that for
-  // dependency analysis to be effective, the CMake user must specify
-  // libraries build by his project without using any linker flags or
-  // file extensions. That is,
-  //    LINK_LIBRARIES( One Two )
-  // instead of
-  //    LINK_LIBRARIES( -lOne ${binarypath}/libTwo.a )
-  // The former is probably what most users would do, but it never
-  // hurts to document the assumptions. :-) Therefore, in the analysis
-  // code, the "canonical name" of a library is simply its name as
-  // given to a LINK_LIBRARIES command.
-  //
-  // Also, we will leave the original link line intact; we will just add any
-  // dependencies that were missing.
-  //
-  // There is a problem with recursive external libraries
-  // (i.e. libraries with no dependency information that are
-  // recursively dependent). We must make sure that the we emit one of
-  // the libraries twice to satisfy the recursion, but we shouldn't
-  // emit it more times than necessary. In particular, we must make
-  // sure that handling this improbable case doesn't cost us when
-  // dealing with the common case of non-recursive libraries. The
-  // solution is to assume that the recursion is satisfied at one node
-  // of the dependency tree. To illustrate, assume libA and libB are
-  // extrenal and mutually dependent. Suppose libX depends on
-  // libA, and libY on libA and libX. Then
-  //   TARGET_LINK_LIBRARIES( Y X A B A )
-  //   TARGET_LINK_LIBRARIES( X A B A )
-  //   TARGET_LINK_LIBRARIES( Exec Y )
-  // would result in "-lY -lX -lA -lB -lA". This is the correct way to
-  // specify the dependencies, since the mutual dependency of A and B
-  // is resolved *every time libA is specified*.
-  //
-  // Something like
-  //   TARGET_LINK_LIBRARIES( Y X A B A )
-  //   TARGET_LINK_LIBRARIES( X A B )
-  //   TARGET_LINK_LIBRARIES( Exec Y )
-  // would result in "-lY -lX -lA -lB", and the mutual dependency
-  // information is lost. This is because in some case (Y), the mutual
-  // dependency of A and B is listed, while in another other case (X),
-  // it is not. Depending on which line actually emits A, the mutual
-  // dependency may or may not be on the final link line.  We can't
-  // handle this pathalogical case cleanly without emitting extra
-  // libraries for the normal cases. Besides, the dependency
-  // information for X is wrong anyway: if we build an executable
-  // depending on X alone, we would not have the mutual dependency on
-  // A and B resolved.
-  //
-  // IMPROVEMENTS:
-  // -- The current algorithm will not always pick the "optimal" link line
-  //    when recursive dependencies are present. It will instead break the
-  //    cycles at an aribtrary point. The majority of projects won't have
-  //    cyclic dependencies, so this is probably not a big deal. Note that
-  //    the link line is always correct, just not necessary optimal.
-
- {
- // Expand variables in link library names.  This is for backwards
- // compatibility with very early CMake versions and should
- // eventually be removed.  This code was moved here from the end of
- // old source list processing code which was called just before this
- // method.
- for(LinkLibraryVectorType::iterator p = this->LinkLibrariesForVS6.begin();
-     p != this->LinkLibrariesForVS6.end(); ++p)
-   {
-   this->Makefile->ExpandVariablesInString(p->first, true, true);
-   }
- }
-
- // The dependency map.
- DependencyMap dep_map;
-
- // 1. Build the dependency graph
- //
- for(LinkLibraryVectorType::reverse_iterator lib
-       = this->LinkLibrariesForVS6.rbegin();
-     lib != this->LinkLibrariesForVS6.rend(); ++lib)
-   {
-   this->GatherDependenciesForVS6( mf, *lib, dep_map);
-   }
-
- // 2. Remove any dependencies that are already satisfied in the original
- // link line.
- //
- for(LinkLibraryVectorType::iterator lib = this->LinkLibrariesForVS6.begin();
-     lib != this->LinkLibrariesForVS6.end(); ++lib)
-   {
-   for( LinkLibraryVectorType::iterator lib2 = lib;
-        lib2 != this->LinkLibrariesForVS6.end(); ++lib2)
-     {
-     this->DeleteDependencyForVS6( dep_map, *lib, *lib2);
-     }
-   }
-
-
- // 3. Create the new link line by simply emitting any dependencies that are
- // missing.  Start from the back and keep adding.
- //
- std::set<DependencyMap::key_type> done, visited;
- std::vector<DependencyMap::key_type> newLinkLibrariesForVS6;
- for(LinkLibraryVectorType::reverse_iterator lib =
-       this->LinkLibrariesForVS6.rbegin();
-     lib != this->LinkLibrariesForVS6.rend(); ++lib)
-   {
-   // skip zero size library entries, this may happen
-   // if a variable expands to nothing.
-   if (!lib->first.empty())
-     {
-     this->EmitForVS6( *lib, dep_map, done, visited, newLinkLibrariesForVS6 );
-     }
-   }
-
- // 4. Add the new libraries to the link line.
- //
- for( std::vector<DependencyMap::key_type>::reverse_iterator k =
-        newLinkLibrariesForVS6.rbegin();
-      k != newLinkLibrariesForVS6.rend(); ++k )
-   {
-   // get the llt from the dep_map
-   this->LinkLibrariesForVS6.push_back( std::make_pair(k->first,k->second) );
-   }
- this->LinkLibrariesForVS6Analyzed = true;
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::InsertDependencyForVS6( DependencyMap& depMap,
-                                       const LibraryID& lib,
-                                       const LibraryID& dep)
-{
-  depMap[lib].push_back(dep);
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::DeleteDependencyForVS6( DependencyMap& depMap,
-                                       const LibraryID& lib,
-                                       const LibraryID& dep)
-{
-  // Make sure there is an entry in the map for lib. If so, delete all
-  // dependencies to dep. There may be repeated entries because of
-  // external libraries that are specified multiple times.
-  DependencyMap::iterator map_itr = depMap.find( lib );
-  if( map_itr != depMap.end() )
-    {
-    DependencyList& depList = map_itr->second;
-    DependencyList::iterator begin =
-        std::remove(depList.begin(), depList.end(), dep);
-    depList.erase(begin, depList.end());
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::EmitForVS6(const LibraryID lib,
-                          const DependencyMap& dep_map,
-                          std::set<LibraryID>& emitted,
-                          std::set<LibraryID>& visited,
-                          DependencyList& link_line )
-{
-  // It's already been emitted
-  if( emitted.find(lib) != emitted.end() )
-    {
-    return;
-    }
-
-  // Emit the dependencies only if this library node hasn't been
-  // visited before. If it has, then we have a cycle. The recursion
-  // that got us here should take care of everything.
-
-  if( visited.insert(lib).second )
-    {
-    if( dep_map.find(lib) != dep_map.end() ) // does it have dependencies?
-      {
-      const DependencyList& dep_on = dep_map.find( lib )->second;
-      DependencyList::const_reverse_iterator i;
-
-      // To cater for recursive external libraries, we must emit
-      // duplicates on this link line *unless* they were emitted by
-      // some other node, in which case we assume that the recursion
-      // was resolved then. We making the simplifying assumption that
-      // any duplicates on a single link line are on purpose, and must
-      // be preserved.
-
-      // This variable will keep track of the libraries that were
-      // emitted directly from the current node, and not from a
-      // recursive call. This way, if we come across a library that
-      // has already been emitted, we repeat it iff it has been
-      // emitted here.
-      std::set<DependencyMap::key_type> emitted_here;
-      for( i = dep_on.rbegin(); i != dep_on.rend(); ++i )
-        {
-        if( emitted_here.find(*i) != emitted_here.end() )
-          {
-          // a repeat. Must emit.
-          emitted.insert(*i);
-          link_line.push_back( *i );
-          }
-        else
-          {
-          // Emit only if no-one else has
-          if( emitted.find(*i) == emitted.end() )
-            {
-            // emit dependencies
-            this->EmitForVS6( *i, dep_map, emitted, visited, link_line );
-            // emit self
-            emitted.insert(*i);
-            emitted_here.insert(*i);
-            link_line.push_back( *i );
-            }
-          }
-        }
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf,
-                                         const LibraryID& lib,
-                                         DependencyMap& dep_map)
-{
-  // If the library is already in the dependency map, then it has
-  // already been fully processed.
-  if( dep_map.find(lib) != dep_map.end() )
-    {
-    return;
-    }
-
-  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
-    // set of dependencies. This distinguishes the case of explicitly
-    // no dependencies with that of unspecified dependencies.
-    dep_map[lib];
-
-    // Parse the dependency information, which is a set of
-    // type, library pairs separated by ";". There is always a trailing ";".
-    cmTargetLinkLibraryType llt = GENERAL_LibraryType;
-    std::string depline = deps;
-    std::string::size_type start = 0;
-    std::string::size_type end;
-    end = depline.find( ";", start );
-    while( end != std::string::npos )
-      {
-      std::string l = depline.substr( start, end-start );
-      if(!l.empty())
-        {
-        if (l == "debug")
-          {
-          llt = DEBUG_LibraryType;
-          }
-        else if (l == "optimized")
-          {
-          llt = OPTIMIZED_LibraryType;
-          }
-        else if (l == "general")
-          {
-          llt = GENERAL_LibraryType;
-          }
-        else
-          {
-          LibraryID lib2(l,llt);
-          this->InsertDependencyForVS6( dep_map, lib, lib2);
-          this->GatherDependenciesForVS6( mf, lib2, dep_map);
-          llt = GENERAL_LibraryType;
-          }
-        }
-      start = end+1; // skip the ;
-      end = depline.find( ";", start );
-      }
-    // cannot depend on itself
-    this->DeleteDependencyForVS6( dep_map, lib, lib);
-    }
-}
-#endif
-
-//----------------------------------------------------------------------------
 static bool whiteListedInterfaceProperty(const std::string& prop)
 {
-  if(cmHasLiteralPrefix(prop, "INTERFACE_"))
-    {
+  if (cmHasLiteralPrefix(prop, "INTERFACE_")) {
     return true;
-    }
+  }
   static UNORDERED_SET<std::string> builtIns;
-  if (builtIns.empty())
-    {
+  if (builtIns.empty()) {
     builtIns.insert("COMPATIBLE_INTERFACE_BOOL");
     builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX");
     builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MIN");
@@ -1121,287 +741,223 @@ static bool whiteListedInterfaceProperty(const std::string& prop)
     builtIns.insert("IMPORTED");
     builtIns.insert("NAME");
     builtIns.insert("TYPE");
-    }
+  }
 
-  if (builtIns.count(prop))
-    {
+  if (builtIns.count(prop)) {
     return true;
-    }
+  }
 
-  if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_"))
-    {
+  if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
     return true;
-    }
+  }
 
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::SetProperty(const std::string& prop, const char* value)
 {
-  if (this->GetType() == cmState::INTERFACE_LIBRARY
-      && !whiteListedInterfaceProperty(prop))
-    {
+  if (this->GetType() == cmState::INTERFACE_LIBRARY &&
+      !whiteListedInterfaceProperty(prop)) {
     std::ostringstream e;
     e << "INTERFACE_LIBRARY targets may only have whitelisted properties.  "
-         "The property \"" << prop << "\" is not allowed.";
+         "The property \""
+      << prop << "\" is not allowed.";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
-  else if (prop == "NAME")
-    {
+  } else if (prop == "NAME") {
     std::ostringstream e;
     e << "NAME property is read-only\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
-  else if(prop == "INCLUDE_DIRECTORIES")
-    {
+  } else if (prop == "INCLUDE_DIRECTORIES") {
     this->Internal->IncludeDirectoriesEntries.clear();
     this->Internal->IncludeDirectoriesBacktraces.clear();
-    if (value)
-      {
+    if (value) {
       this->Internal->IncludeDirectoriesEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "COMPILE_OPTIONS")
-    {
+  } else if (prop == "COMPILE_OPTIONS") {
     this->Internal->CompileOptionsEntries.clear();
     this->Internal->CompileOptionsBacktraces.clear();
-    if (value)
-      {
+    if (value) {
       this->Internal->CompileOptionsEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->CompileOptionsBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "COMPILE_FEATURES")
-    {
+  } else if (prop == "COMPILE_FEATURES") {
     this->Internal->CompileFeaturesEntries.clear();
     this->Internal->CompileFeaturesBacktraces.clear();
-    if (value)
-      {
+    if (value) {
       this->Internal->CompileFeaturesEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "COMPILE_DEFINITIONS")
-    {
+  } else if (prop == "COMPILE_DEFINITIONS") {
     this->Internal->CompileDefinitionsEntries.clear();
     this->Internal->CompileDefinitionsBacktraces.clear();
-    if (value)
-      {
+    if (value) {
       this->Internal->CompileDefinitionsEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "EXPORT_NAME" && this->IsImported())
-    {
+  } else if (prop == "EXPORT_NAME" && this->IsImported()) {
     std::ostringstream e;
     e << "EXPORT_NAME property can't be set on imported targets (\""
-          << this->Name << "\")\n";
+      << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
-  else if (prop == "LINK_LIBRARIES")
-    {
+  } else if (prop == "LINK_LIBRARIES") {
     this->Internal->LinkImplementationPropertyEntries.clear();
     this->Internal->LinkImplementationPropertyBacktraces.clear();
-    if (value)
-      {
+    if (value) {
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->LinkImplementationPropertyEntries.push_back(value);
       this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt);
-      }
     }
-  else if (prop == "SOURCES")
-    {
-    if(this->IsImported())
-      {
+  } else if (prop == "SOURCES") {
+    if (this->IsImported()) {
       std::ostringstream e;
       e << "SOURCES property can't be set on imported targets (\""
-            << this->Name << "\")\n";
+        << this->Name << "\")\n";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
+    }
 
     this->Internal->SourceEntries.clear();
     this->Internal->SourceBacktraces.clear();
-    if (value)
-      {
+    if (value) {
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->SourceEntries.push_back(value);
       this->Internal->SourceBacktraces.push_back(lfbt);
-      }
     }
-  else
-    {
+  } else {
     this->Properties.SetProperty(prop, value);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::AppendProperty(const std::string& prop, const char* value,
                               bool asString)
 {
-  if (this->GetType() == cmState::INTERFACE_LIBRARY
-      && !whiteListedInterfaceProperty(prop))
-    {
+  if (this->GetType() == cmState::INTERFACE_LIBRARY &&
+      !whiteListedInterfaceProperty(prop)) {
     std::ostringstream e;
     e << "INTERFACE_LIBRARY targets may only have whitelisted properties.  "
-         "The property \"" << prop << "\" is not allowed.";
+         "The property \""
+      << prop << "\" is not allowed.";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
-  else if (prop == "NAME")
-    {
+  } else if (prop == "NAME") {
     std::ostringstream e;
     e << "NAME property is read-only\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
-    }
-  else if(prop == "INCLUDE_DIRECTORIES")
-    {
-    if (value && *value)
-      {
+  } else if (prop == "INCLUDE_DIRECTORIES") {
+    if (value && *value) {
       this->Internal->IncludeDirectoriesEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "COMPILE_OPTIONS")
-    {
-    if (value && *value)
-      {
+  } else if (prop == "COMPILE_OPTIONS") {
+    if (value && *value) {
       this->Internal->CompileOptionsEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->CompileOptionsBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "COMPILE_FEATURES")
-    {
-    if (value && *value)
-      {
+  } else if (prop == "COMPILE_FEATURES") {
+    if (value && *value) {
       this->Internal->CompileFeaturesEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "COMPILE_DEFINITIONS")
-    {
-    if (value && *value)
-      {
+  } else if (prop == "COMPILE_DEFINITIONS") {
+    if (value && *value) {
       this->Internal->CompileDefinitionsEntries.push_back(value);
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
-      }
     }
-  else if(prop == "EXPORT_NAME" && this->IsImported())
-    {
+  } else if (prop == "EXPORT_NAME" && this->IsImported()) {
     std::ostringstream e;
     e << "EXPORT_NAME property can't be set on imported targets (\""
-          << this->Name << "\")\n";
+      << this->Name << "\")\n";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
-  else if (prop == "LINK_LIBRARIES")
-    {
-    if (value && *value)
-      {
+  } else if (prop == "LINK_LIBRARIES") {
+    if (value && *value) {
       cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
       this->Internal->LinkImplementationPropertyEntries.push_back(value);
       this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt);
-      }
     }
-  else if (prop == "SOURCES")
-    {
-    if(this->IsImported())
-      {
+  } else if (prop == "SOURCES") {
+    if (this->IsImported()) {
       std::ostringstream e;
       e << "SOURCES property can't be set on imported targets (\""
-            << this->Name << "\")\n";
+        << this->Name << "\")\n";
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
-      }
+    }
     cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     this->Internal->SourceEntries.push_back(value);
     this->Internal->SourceBacktraces.push_back(lfbt);
-    }
-  else
-    {
+  } else {
     this->Properties.AppendProperty(prop, value, asString);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::AppendBuildInterfaceIncludes()
 {
-  if(this->GetType() != cmState::SHARED_LIBRARY &&
-     this->GetType() != cmState::STATIC_LIBRARY &&
-     this->GetType() != cmState::MODULE_LIBRARY &&
-     this->GetType() != cmState::INTERFACE_LIBRARY &&
-     !this->IsExecutableWithExports())
-    {
+  if (this->GetType() != cmState::SHARED_LIBRARY &&
+      this->GetType() != cmState::STATIC_LIBRARY &&
+      this->GetType() != cmState::MODULE_LIBRARY &&
+      this->GetType() != cmState::INTERFACE_LIBRARY &&
+      !this->IsExecutableWithExports()) {
     return;
-    }
-  if (this->BuildInterfaceIncludesAppended)
-    {
+  }
+  if (this->BuildInterfaceIncludesAppended) {
     return;
-    }
+  }
   this->BuildInterfaceIncludesAppended = true;
 
-  if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE"))
-    {
-    const char *binDir = this->Makefile->GetCurrentBinaryDirectory();
-    const char *srcDir = this->Makefile->GetCurrentSourceDirectory();
-    const std::string dirs = std::string(binDir ? binDir : "")
-                            + std::string(binDir ? ";" : "")
-                            + std::string(srcDir ? srcDir : "");
-    if (!dirs.empty())
-      {
+  if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) {
+    const char* binDir = this->Makefile->GetCurrentBinaryDirectory();
+    const char* srcDir = this->Makefile->GetCurrentSourceDirectory();
+    const std::string dirs = std::string(binDir ? binDir : "") +
+      std::string(binDir ? ";" : "") + std::string(srcDir ? srcDir : "");
+    if (!dirs.empty()) {
       this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES",
-                            ("$<BUILD_INTERFACE:" + dirs + ">").c_str());
-      }
+                           ("$<BUILD_INTERFACE:" + dirs + ">").c_str());
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::InsertInclude(std::string const& entry,
-                             cmListFileBacktrace const& bt,
-                             bool before)
+                             cmListFileBacktrace const& bt, bool before)
 {
-  std::vector<std::string>::iterator position =
-      before ? this->Internal->IncludeDirectoriesEntries.begin()
-             : this->Internal->IncludeDirectoriesEntries.end();
+  std::vector<std::string>::iterator position = before
+    ? this->Internal->IncludeDirectoriesEntries.begin()
+    : this->Internal->IncludeDirectoriesEntries.end();
 
-  std::vector<cmListFileBacktrace>::iterator btPosition =
-      before ? this->Internal->IncludeDirectoriesBacktraces.begin()
-             : this->Internal->IncludeDirectoriesBacktraces.end();
+  std::vector<cmListFileBacktrace>::iterator btPosition = before
+    ? this->Internal->IncludeDirectoriesBacktraces.begin()
+    : this->Internal->IncludeDirectoriesBacktraces.end();
 
   this->Internal->IncludeDirectoriesEntries.insert(position, entry);
   this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt);
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::InsertCompileOption(std::string const& entry,
-                                   cmListFileBacktrace const& bt,
-                                   bool before)
+                                   cmListFileBacktrace const& bt, bool before)
 {
-  std::vector<std::string>::iterator position =
-      before ? this->Internal->CompileOptionsEntries.begin()
-             : this->Internal->CompileOptionsEntries.end();
+  std::vector<std::string>::iterator position = before
+    ? this->Internal->CompileOptionsEntries.begin()
+    : this->Internal->CompileOptionsEntries.end();
 
-  std::vector<cmListFileBacktrace>::iterator btPosition =
-      before ? this->Internal->CompileOptionsBacktraces.begin()
-             : this->Internal->CompileOptionsBacktraces.end();
+  std::vector<cmListFileBacktrace>::iterator btPosition = before
+    ? this->Internal->CompileOptionsBacktraces.begin()
+    : this->Internal->CompileOptionsBacktraces.end();
 
   this->Internal->CompileOptionsEntries.insert(position, entry);
   this->Internal->CompileOptionsBacktraces.insert(btPosition, bt);
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::InsertCompileDefinition(std::string const& entry,
                                        cmListFileBacktrace const& bt)
 {
@@ -1409,23 +965,20 @@ void cmTarget::InsertCompileDefinition(std::string const& entry,
   this->Internal->CompileDefinitionsBacktraces.push_back(bt);
 }
 
-//----------------------------------------------------------------------------
-static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
-  const std::string& prop, const char* value, cmMakefile* context,
-  bool imported)
+static void cmTargetCheckLINK_INTERFACE_LIBRARIES(const std::string& prop,
+                                                  const char* value,
+                                                  cmMakefile* context,
+                                                  bool imported)
 {
   // Look for link-type keywords in the value.
-  static cmsys::RegularExpression
-    keys("(^|;)(debug|optimized|general)(;|$)");
-  if(!keys.find(value))
-    {
+  static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)");
+  if (!keys.find(value)) {
     return;
-    }
+  }
 
   // Support imported and non-imported versions of the property.
-  const char* base = (imported?
-                      "IMPORTED_LINK_INTERFACE_LIBRARIES" :
-                      "LINK_INTERFACE_LIBRARIES");
+  const char* base = (imported ? "IMPORTED_LINK_INTERFACE_LIBRARIES"
+                               : "LINK_INTERFACE_LIBRARIES");
 
   // Report an error.
   std::ostringstream e;
@@ -1434,8 +987,7 @@ static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
     << "The " << base << " property has a per-configuration "
     << "version called " << base << "_<CONFIG> which may be "
     << "used to specify per-configuration rules.";
-  if(!imported)
-    {
+  if (!imported) {
     e << "  "
       << "Alternatively, an IMPORTED library may be created, configured "
       << "with a per-configuration location, and then named in the "
@@ -1448,80 +1000,68 @@ static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
       << "The command automatically recognizes link-type keywords and sets "
       << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG "
       << "properties accordingly.";
-    }
+  }
   context->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
 static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
                                                   cmMakefile* context)
 {
   // Look for link-type keywords in the value.
-  static cmsys::RegularExpression
-    keys("(^|;)(debug|optimized|general)(;|$)");
-  if(!keys.find(value))
-    {
+  static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)");
+  if (!keys.find(value)) {
     return;
-    }
+  }
 
   // Report an error.
   std::ostringstream e;
 
   e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type "
-    "keyword \"" << keys.match(2) << "\".  The INTERFACE_LINK_LIBRARIES "
-    "property may contain configuration-sensitive generator-expressions "
-    "which may be used to specify per-configuration rules.";
+       "keyword \""
+    << keys.match(2)
+    << "\".  The INTERFACE_LINK_LIBRARIES "
+       "property may contain configuration-sensitive generator-expressions "
+       "which may be used to specify per-configuration rules.";
 
   context->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::CheckProperty(const std::string& prop,
                              cmMakefile* context) const
 {
   // Certain properties need checking.
-  if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES"))
-    {
-    if(const char* value = this->GetProperty(prop))
-      {
+  if (cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) {
+    if (const char* value = this->GetProperty(prop)) {
       cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false);
-      }
     }
-  if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES"))
-    {
-    if(const char* value = this->GetProperty(prop))
-      {
+  }
+  if (cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) {
+    if (const char* value = this->GetProperty(prop)) {
       cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true);
-      }
     }
-  if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES"))
-    {
-    if(const char* value = this->GetProperty(prop))
-      {
+  }
+  if (cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) {
+    if (const char* value = this->GetProperty(prop)) {
       cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::MarkAsImported(bool global)
 {
   this->IsImportedTarget = true;
   this->ImportedGloballyVisible = global;
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
 {
-  if (this->IsImported())
-    {
+  if (this->IsImported()) {
     return true;
-    }
+  }
   std::ostringstream e;
-  const char *modal = 0;
+  const char* modal = 0;
   cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-  switch (context->GetPolicyStatus(cmPolicies::CMP0026))
-    {
+  switch (context->GetPolicyStatus(cmPolicies::CMP0026)) {
     case cmPolicies::WARN:
       e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0026) << "\n";
       modal = "should";
@@ -1532,133 +1072,118 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
     case cmPolicies::NEW:
       modal = "may";
       messageType = cmake::FATAL_ERROR;
-    }
+  }
 
-  if (modal)
-    {
+  if (modal) {
     e << "The LOCATION property " << modal << " not be read from target \""
-      << this->GetName() << "\".  Use the target name directly with "
-      "add_custom_command, or use the generator expression $<TARGET_FILE>, "
-      "as appropriate.\n";
+      << 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());
-    }
+  }
 
   return messageType != cmake::FATAL_ERROR;
 }
 
-//----------------------------------------------------------------------------
-const char *cmTarget::GetProperty(const std::string& prop) const
+const char* cmTarget::GetProperty(const std::string& prop) const
 {
   return this->GetProperty(prop, this->Makefile);
 }
 
-//----------------------------------------------------------------------------
-const char *cmTarget::GetProperty(const std::string& prop,
+const char* cmTarget::GetProperty(const std::string& prop,
                                   cmMakefile* context) const
 {
-  if (this->GetType() == cmState::INTERFACE_LIBRARY
-      && !whiteListedInterfaceProperty(prop))
-    {
+  if (this->GetType() == cmState::INTERFACE_LIBRARY &&
+      !whiteListedInterfaceProperty(prop)) {
     std::ostringstream e;
     e << "INTERFACE_LIBRARY targets may only have whitelisted properties.  "
-         "The property \"" << prop << "\" is not allowed.";
+         "The property \""
+      << prop << "\" is not allowed.";
     context->IssueMessage(cmake::FATAL_ERROR, e.str());
     return 0;
-    }
+  }
 
   // Watch for special "computed" properties that are dependent on
   // other properties or variables.  Always recompute them.
-  if(this->GetType() == cmState::EXECUTABLE ||
-     this->GetType() == cmState::STATIC_LIBRARY ||
-     this->GetType() == cmState::SHARED_LIBRARY ||
-     this->GetType() == cmState::MODULE_LIBRARY ||
-     this->GetType() == cmState::UNKNOWN_LIBRARY)
-    {
+  if (this->GetType() == cmState::EXECUTABLE ||
+      this->GetType() == cmState::STATIC_LIBRARY ||
+      this->GetType() == cmState::SHARED_LIBRARY ||
+      this->GetType() == cmState::MODULE_LIBRARY ||
+      this->GetType() == cmState::UNKNOWN_LIBRARY) {
     static const std::string propLOCATION = "LOCATION";
-    if(prop == propLOCATION)
-      {
-      if (!this->HandleLocationPropertyPolicy(context))
-        {
+    if (prop == propLOCATION) {
+      if (!this->HandleLocationPropertyPolicy(context)) {
         return 0;
-        }
+      }
 
       // Set the LOCATION property of the target.
       //
       // For an imported target this is the location of an arbitrary
       // available configuration.
       //
-      if(this->IsImported())
-        {
+      if (this->IsImported()) {
         this->Properties.SetProperty(
-                propLOCATION, this->ImportedGetFullPath("", false).c_str());
-        }
-      else
-        {
+          propLOCATION, this->ImportedGetFullPath("", false).c_str());
+      } else {
         // For a non-imported target this is deprecated because it
         // cannot take into account the per-configuration name of the
         // target because the configuration type may not be known at
         // CMake time.
         cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
-        gg->CreateGenerationObjects();
-        cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
-        this->Properties.SetProperty(propLOCATION,
-                                     gt->GetLocationForBuild());
+        if (!gg->GetConfigureDoneCMP0026()) {
+          gg->CreateGenerationObjects();
         }
-
+        cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
+        this->Properties.SetProperty(propLOCATION, gt->GetLocationForBuild());
       }
 
+    }
+
     // Support "LOCATION_<CONFIG>".
-    else if(cmHasLiteralPrefix(prop, "LOCATION_"))
-      {
-      if (!this->HandleLocationPropertyPolicy(context))
-        {
+    else if (cmHasLiteralPrefix(prop, "LOCATION_")) {
+      if (!this->HandleLocationPropertyPolicy(context)) {
         return 0;
-        }
+      }
       const char* configName = prop.c_str() + 9;
 
-      if (this->IsImported())
-        {
+      if (this->IsImported()) {
         this->Properties.SetProperty(
-                prop, this->ImportedGetFullPath(configName, false).c_str());
-        }
-      else
-        {
+          prop, this->ImportedGetFullPath(configName, false).c_str());
+      } else {
         cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
-        gg->CreateGenerationObjects();
+        if (!gg->GetConfigureDoneCMP0026()) {
+          gg->CreateGenerationObjects();
+        }
         cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
         this->Properties.SetProperty(
-                prop, gt->GetFullPath(configName, false).c_str());
-        }
+          prop, gt->GetFullPath(configName, false).c_str());
       }
+    }
     // Support "<CONFIG>_LOCATION".
-    else if(cmHasLiteralSuffix(prop, "_LOCATION"))
-      {
+    else if (cmHasLiteralSuffix(prop, "_LOCATION")) {
       std::string configName(prop.c_str(), prop.size() - 9);
-      if(configName != "IMPORTED")
-        {
-        if (!this->HandleLocationPropertyPolicy(context))
-          {
+      if (configName != "IMPORTED") {
+        if (!this->HandleLocationPropertyPolicy(context)) {
           return 0;
-          }
-        if (this->IsImported())
-          {
+        }
+        if (this->IsImported()) {
           this->Properties.SetProperty(
-                  prop, this->ImportedGetFullPath(configName, false).c_str());
-          }
-        else
-          {
+            prop, this->ImportedGetFullPath(configName, false).c_str());
+        } else {
           cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
-          gg->CreateGenerationObjects();
+          if (!gg->GetConfigureDoneCMP0026()) {
+            gg->CreateGenerationObjects();
+          }
           cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
           this->Properties.SetProperty(
-                  prop, gt->GetFullPath(configName, false).c_str());
-          }
+            prop, gt->GetFullPath(configName, false).c_str());
         }
       }
     }
+  }
   static UNORDERED_SET<std::string> specialProps;
-#define MAKE_STATIC_PROP(PROP) \
-  static const std::string prop##PROP = #PROP
+#define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP
   MAKE_STATIC_PROP(LINK_LIBRARIES);
   MAKE_STATIC_PROP(TYPE);
   MAKE_STATIC_PROP(INCLUDE_DIRECTORIES);
@@ -1671,8 +1196,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
   MAKE_STATIC_PROP(SOURCE_DIR);
   MAKE_STATIC_PROP(SOURCES);
 #undef MAKE_STATIC_PROP
-  if(specialProps.empty())
-    {
+  if (specialProps.empty()) {
     specialProps.insert(propLINK_LIBRARIES);
     specialProps.insert(propTYPE);
     specialProps.insert(propINCLUDE_DIRECTORIES);
@@ -1684,124 +1208,92 @@ const char *cmTarget::GetProperty(const std::string& prop,
     specialProps.insert(propBINARY_DIR);
     specialProps.insert(propSOURCE_DIR);
     specialProps.insert(propSOURCES);
-    }
-  if(specialProps.count(prop))
-    {
-    if(prop == propLINK_LIBRARIES)
-      {
-      if (this->Internal->LinkImplementationPropertyEntries.empty())
-        {
+  }
+  if (specialProps.count(prop)) {
+    if (prop == propLINK_LIBRARIES) {
+      if (this->Internal->LinkImplementationPropertyEntries.empty()) {
         return 0;
-        }
+      }
 
       static std::string output;
       output = cmJoin(this->Internal->LinkImplementationPropertyEntries, ";");
       return output.c_str();
-      }
+    }
     // the type property returns what type the target is
-    else if (prop == propTYPE)
-      {
+    else if (prop == propTYPE) {
       return cmState::GetTargetTypeName(this->GetType());
-      }
-    else if(prop == propINCLUDE_DIRECTORIES)
-      {
-      if (this->Internal->IncludeDirectoriesEntries.empty())
-        {
+    } else if (prop == propINCLUDE_DIRECTORIES) {
+      if (this->Internal->IncludeDirectoriesEntries.empty()) {
         return 0;
-        }
+      }
 
       static std::string output;
       output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";");
       return output.c_str();
-      }
-    else if(prop == propCOMPILE_FEATURES)
-      {
-      if (this->Internal->CompileFeaturesEntries.empty())
-        {
+    } else if (prop == propCOMPILE_FEATURES) {
+      if (this->Internal->CompileFeaturesEntries.empty()) {
         return 0;
-        }
+      }
 
       static std::string output;
       output = cmJoin(this->Internal->CompileFeaturesEntries, ";");
       return output.c_str();
-      }
-    else if(prop == propCOMPILE_OPTIONS)
-      {
-      if (this->Internal->CompileOptionsEntries.empty())
-        {
+    } else if (prop == propCOMPILE_OPTIONS) {
+      if (this->Internal->CompileOptionsEntries.empty()) {
         return 0;
-        }
+      }
 
       static std::string output;
       output = cmJoin(this->Internal->CompileOptionsEntries, ";");
       return output.c_str();
-      }
-    else if(prop == propCOMPILE_DEFINITIONS)
-      {
-      if (this->Internal->CompileDefinitionsEntries.empty())
-        {
+    } else if (prop == propCOMPILE_DEFINITIONS) {
+      if (this->Internal->CompileDefinitionsEntries.empty()) {
         return 0;
-        }
+      }
 
       static std::string output;
       output = cmJoin(this->Internal->CompileDefinitionsEntries, ";");
       return output.c_str();
-      }
-    else if (prop == propIMPORTED)
-      {
-      return this->IsImported()?"TRUE":"FALSE";
-      }
-    else if (prop == propNAME)
-      {
+    } else if (prop == propIMPORTED) {
+      return this->IsImported() ? "TRUE" : "FALSE";
+    } else if (prop == propNAME) {
       return this->GetName().c_str();
-      }
-    else if (prop == propBINARY_DIR)
-      {
+    } else if (prop == propBINARY_DIR) {
       return this->GetMakefile()->GetCurrentBinaryDirectory();
-      }
-    else if (prop == propSOURCE_DIR)
-      {
+    } else if (prop == propSOURCE_DIR) {
       return this->GetMakefile()->GetCurrentSourceDirectory();
-      }
-    else if(prop == propSOURCES)
-      {
-      if (this->Internal->SourceEntries.empty())
-        {
+    } else if (prop == propSOURCES) {
+      if (this->Internal->SourceEntries.empty()) {
         return 0;
-        }
+      }
 
       std::ostringstream ss;
       const char* sep = "";
-      for(std::vector<std::string>::const_iterator
-            i = this->Internal->SourceEntries.begin();
-          i != this->Internal->SourceEntries.end(); ++i)
-        {
+      for (std::vector<std::string>::const_iterator i =
+             this->Internal->SourceEntries.begin();
+           i != this->Internal->SourceEntries.end(); ++i) {
         std::string const& entry = *i;
 
         std::vector<std::string> files;
         cmSystemTools::ExpandListArgument(entry, files);
-        for (std::vector<std::string>::const_iterator
-            li = files.begin(); li != files.end(); ++li)
-          {
-          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)
-              {
+        for (std::vector<std::string>::const_iterator li = files.begin();
+             li != files.end(); ++li) {
+          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) {
               ss << sep;
               sep = ";";
               ss << *li;
               continue;
-              }
+            }
 
             bool addContent = false;
             bool noMessage = true;
             std::ostringstream e;
             cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-            switch(context->GetPolicyStatus(cmPolicies::CMP0051))
-              {
+            switch (context->GetPolicyStatus(cmPolicies::CMP0051)) {
               case cmPolicies::WARN:
                 e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0051) << "\n";
                 noMessage = false;
@@ -1811,146 +1303,129 @@ const char *cmTarget::GetProperty(const std::string& prop,
               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.";
+            }
+            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)
-              {
+            }
+            if (addContent) {
               ss << sep;
               sep = ";";
               ss << *li;
-              }
             }
-          else if (cmGeneratorExpression::Find(*li) == std::string::npos)
-            {
+          } else if (cmGeneratorExpression::Find(*li) == std::string::npos) {
             ss << sep;
             sep = ";";
             ss << *li;
-            }
-          else
-            {
-            cmSourceFile *sf = this->Makefile->GetOrCreateSource(*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())
-              {
+            if (!sname.empty()) {
               sname += "/";
-              }
+            }
             sname += location.GetName();
 
             ss << sep;
             sep = ";";
             // Append this list entry.
             ss << sname;
-            }
           }
         }
-      this->Properties.SetProperty("SOURCES", ss.str().c_str());
       }
+      this->Properties.SetProperty("SOURCES", ss.str().c_str());
     }
+  }
 
-  const char *retVal = this->Properties.GetPropertyValue(prop);
-  if (!retVal)
-    {
-    const bool chain = this->GetMakefile()->GetState()->
-                      IsPropertyChained(prop, cmProperty::TARGET);
-    if (chain)
-      {
+  const char* retVal = this->Properties.GetPropertyValue(prop);
+  if (!retVal) {
+    const bool chain = this->GetMakefile()->GetState()->IsPropertyChained(
+      prop, cmProperty::TARGET);
+    if (chain) {
       return this->Makefile->GetProperty(prop, chain);
-      }
     }
+  }
   return retVal;
 }
 
-//----------------------------------------------------------------------------
 bool cmTarget::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
-//----------------------------------------------------------------------------
 const char* cmTarget::GetSuffixVariableInternal(bool implib) const
 {
-  switch(this->GetType())
-    {
+  switch (this->GetType()) {
     case cmState::STATIC_LIBRARY:
       return "CMAKE_STATIC_LIBRARY_SUFFIX";
     case cmState::SHARED_LIBRARY:
-      return (implib
-              ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
-              : "CMAKE_SHARED_LIBRARY_SUFFIX");
+      return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
+                     : "CMAKE_SHARED_LIBRARY_SUFFIX");
     case cmState::MODULE_LIBRARY:
-      return (implib
-              ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
-              : "CMAKE_SHARED_MODULE_SUFFIX");
+      return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
+                     : "CMAKE_SHARED_MODULE_SUFFIX");
     case cmState::EXECUTABLE:
       return (implib
-              ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
+                ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
                 // Android GUI application packages store the native
                 // binary as a shared library.
-              : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")?
-                 "CMAKE_SHARED_LIBRARY_SUFFIX" : "CMAKE_EXECUTABLE_SUFFIX"));
+                : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
+                     ? "CMAKE_SHARED_LIBRARY_SUFFIX"
+                     : "CMAKE_EXECUTABLE_SUFFIX"));
     default:
       break;
-    }
+  }
   return "";
 }
 
-
-//----------------------------------------------------------------------------
 const char* cmTarget::GetPrefixVariableInternal(bool implib) const
 {
-  switch(this->GetType())
-    {
+  switch (this->GetType()) {
     case cmState::STATIC_LIBRARY:
       return "CMAKE_STATIC_LIBRARY_PREFIX";
     case cmState::SHARED_LIBRARY:
-      return (implib
-              ? "CMAKE_IMPORT_LIBRARY_PREFIX"
-              : "CMAKE_SHARED_LIBRARY_PREFIX");
+      return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX"
+                     : "CMAKE_SHARED_LIBRARY_PREFIX");
     case cmState::MODULE_LIBRARY:
-      return (implib
-              ? "CMAKE_IMPORT_LIBRARY_PREFIX"
-              : "CMAKE_SHARED_MODULE_PREFIX");
+      return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX"
+                     : "CMAKE_SHARED_MODULE_PREFIX");
     case cmState::EXECUTABLE:
       return (implib
-              ? "CMAKE_IMPORT_LIBRARY_PREFIX"
+                ? "CMAKE_IMPORT_LIBRARY_PREFIX"
                 // Android GUI application packages store the native
                 // binary as a shared library.
-              : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")?
-                 "CMAKE_SHARED_LIBRARY_PREFIX" : ""));
+                : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
+                     ? "CMAKE_SHARED_LIBRARY_PREFIX"
+                     : ""));
     default:
       break;
-    }
+  }
   return "";
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmTarget::ImportedGetFullPath(const std::string& config, bool pimplib) const
+std::string cmTarget::ImportedGetFullPath(const std::string& config,
+                                          bool pimplib) const
 {
   assert(this->IsImported());
 
   // Lookup/compute/cache the import information for this
   // configuration.
   std::string config_upper;
-  if(!config.empty())
-    {
+  if (!config.empty()) {
     config_upper = cmSystemTools::UpperCase(config);
-    }
-  else
-    {
+  } else {
     config_upper = "NOCONFIG";
-    }
+  }
 
   std::string result;
 
@@ -1958,62 +1433,44 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool pimplib) const
   const char* imp = 0;
   std::string suffix;
 
-  if(this->GetType() != cmState::INTERFACE_LIBRARY
-     && this->GetMappedConfig(config_upper, &loc, &imp, suffix))
-    {
-    if (!pimplib)
-      {
-      if(loc)
-        {
+  if (this->GetType() != cmState::INTERFACE_LIBRARY &&
+      this->GetMappedConfig(config_upper, &loc, &imp, suffix)) {
+    if (!pimplib) {
+      if (loc) {
         result = loc;
-        }
-      else
-        {
+      } else {
         std::string impProp = "IMPORTED_LOCATION";
         impProp += suffix;
-        if(const char* config_location = this->GetProperty(impProp))
-          {
+        if (const char* config_location = this->GetProperty(impProp)) {
           result = config_location;
-          }
-        else if(const char* location =
-                this->GetProperty("IMPORTED_LOCATION"))
-          {
+        } else if (const char* location =
+                     this->GetProperty("IMPORTED_LOCATION")) {
           result = location;
-          }
         }
       }
-    else
-      {
-      if(imp)
-        {
+    } else {
+      if (imp) {
         result = imp;
-        }
-      else if(this->GetType() == cmState::SHARED_LIBRARY ||
-              this->IsExecutableWithExports())
-        {
+      } else if (this->GetType() == cmState::SHARED_LIBRARY ||
+                 this->IsExecutableWithExports()) {
         std::string impProp = "IMPORTED_IMPLIB";
         impProp += suffix;
-        if(const char* config_implib = this->GetProperty(impProp))
-          {
+        if (const char* config_implib = this->GetProperty(impProp)) {
           result = config_implib;
-          }
-        else if(const char* implib = this->GetProperty("IMPORTED_IMPLIB"))
-          {
+        } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
           result = implib;
-          }
         }
       }
     }
+  }
 
-  if(result.empty())
-    {
+  if (result.empty()) {
     result = this->GetName();
     result += "-NOTFOUND";
-    }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 void cmTarget::SetPropertyDefault(const std::string& property,
                                   const char* default_value)
 {
@@ -2021,29 +1478,24 @@ void cmTarget::SetPropertyDefault(const std::string& property,
   std::string var = "CMAKE_";
   var += property;
 
-  if(const char* value = this->Makefile->GetDefinition(var))
-    {
+  if (const char* value = this->Makefile->GetDefinition(var)) {
     this->SetProperty(property, value);
-    }
-  else if(default_value)
-    {
+  } else if (default_value) {
     this->SetProperty(property, default_value);
-    }
+  }
 }
 
 bool cmTarget::GetMappedConfig(std::string const& desired_config,
-                               const char** loc,
-                               const char** imp,
+                               const char** loc, const char** imp,
                                std::string& suffix) const
 {
-  if (this->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->GetType() == cmState::INTERFACE_LIBRARY) {
     // This method attempts to find a config-specific LOCATION for the
     // IMPORTED library. In the case of cmState::INTERFACE_LIBRARY, there is no
     // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate
     // and valid response.
     return true;
-    }
+  }
 
   // Track the configuration-specific property suffix.
   suffix = "_";
@@ -2051,11 +1503,10 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
 
   std::vector<std::string> mappedConfigs;
   {
-  std::string mapProp = "MAP_IMPORTED_CONFIG_";
-  mapProp += desired_config;
-  if(const char* mapValue = this->GetProperty(mapProp))
-    {
-    cmSystemTools::ExpandListArgument(mapValue, mappedConfigs);
+    std::string mapProp = "MAP_IMPORTED_CONFIG_";
+    mapProp += desired_config;
+    if (const char* mapValue = this->GetProperty(mapProp)) {
+      cmSystemTools::ExpandListArgument(mapValue, mappedConfigs);
     }
   }
 
@@ -2065,112 +1516,97 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
   bool allowImp = this->HasImportLibrary();
 
   // If a mapping was found, check its configurations.
-  for(std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
-      !*loc && !*imp && mci != mappedConfigs.end(); ++mci)
-    {
+  for (std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
+       !*loc && !*imp && mci != mappedConfigs.end(); ++mci) {
     // Look for this configuration.
     std::string mcUpper = cmSystemTools::UpperCase(*mci);
     std::string locProp = "IMPORTED_LOCATION_";
     locProp += mcUpper;
     *loc = this->GetProperty(locProp);
-    if(allowImp)
-      {
+    if (allowImp) {
       std::string impProp = "IMPORTED_IMPLIB_";
       impProp += mcUpper;
       *imp = this->GetProperty(impProp);
-      }
+    }
 
     // If it was found, use it for all properties below.
-    if(*loc || *imp)
-      {
+    if (*loc || *imp) {
       suffix = "_";
       suffix += mcUpper;
-      }
     }
+  }
 
   // If we needed to find one of the mapped configurations but did not
   // then the target is not found.  The project does not want any
   // other configuration.
-  if(!mappedConfigs.empty() && !*loc && !*imp)
-    {
+  if (!mappedConfigs.empty() && !*loc && !*imp) {
     return false;
-    }
+  }
 
   // If we have not yet found it then there are no mapped
   // configurations.  Look for an exact-match.
-  if(!*loc && !*imp)
-    {
+  if (!*loc && !*imp) {
     std::string locProp = "IMPORTED_LOCATION";
     locProp += suffix;
     *loc = this->GetProperty(locProp);
-    if(allowImp)
-      {
+    if (allowImp) {
       std::string impProp = "IMPORTED_IMPLIB";
       impProp += suffix;
       *imp = this->GetProperty(impProp);
-      }
     }
+  }
 
   // If we have not yet found it then there are no mapped
   // configurations and no exact match.
-  if(!*loc && !*imp)
-    {
+  if (!*loc && !*imp) {
     // The suffix computed above is not useful.
     suffix = "";
 
     // Look for a configuration-less location.  This may be set by
     // manually-written code.
     *loc = this->GetProperty("IMPORTED_LOCATION");
-    if(allowImp)
-      {
+    if (allowImp) {
       *imp = this->GetProperty("IMPORTED_IMPLIB");
-      }
     }
+  }
 
   // If we have not yet found it then the project is willing to try
   // any available configuration.
-  if(!*loc && !*imp)
-    {
+  if (!*loc && !*imp) {
     std::vector<std::string> availableConfigs;
-    if(const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS"))
-      {
+    if (const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
       cmSystemTools::ExpandListArgument(iconfigs, availableConfigs);
-      }
-    for(std::vector<std::string>::const_iterator
-          aci = availableConfigs.begin();
-        !*loc && !*imp && aci != availableConfigs.end(); ++aci)
-      {
+    }
+    for (std::vector<std::string>::const_iterator aci =
+           availableConfigs.begin();
+         !*loc && !*imp && aci != availableConfigs.end(); ++aci) {
       suffix = "_";
       suffix += cmSystemTools::UpperCase(*aci);
       std::string locProp = "IMPORTED_LOCATION";
       locProp += suffix;
       *loc = this->GetProperty(locProp);
-      if(allowImp)
-        {
+      if (allowImp) {
         std::string impProp = "IMPORTED_IMPLIB";
         impProp += suffix;
         *imp = this->GetProperty(impProp);
-        }
       }
     }
+  }
   // If we have not yet found it then the target is not available.
-  if(!*loc && !*imp)
-    {
+  if (!*loc && !*imp) {
     return false;
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
 cmTargetInternalPointer::cmTargetInternalPointer()
 {
   this->Pointer = new cmTargetInternals;
 }
 
-//----------------------------------------------------------------------------
-cmTargetInternalPointer
-::cmTargetInternalPointer(cmTargetInternalPointer const& r)
+cmTargetInternalPointer::cmTargetInternalPointer(
+  cmTargetInternalPointer const& r)
 {
   // Ideally cmTarget instances should never be copied.  However until
   // we can make a sweep to remove that, this copy constructor avoids
@@ -2178,17 +1614,17 @@ cmTargetInternalPointer
   this->Pointer = new cmTargetInternals(*r.Pointer);
 }
 
-//----------------------------------------------------------------------------
 cmTargetInternalPointer::~cmTargetInternalPointer()
 {
   delete this->Pointer;
 }
 
-//----------------------------------------------------------------------------
-cmTargetInternalPointer&
-cmTargetInternalPointer::operator=(cmTargetInternalPointer const& r)
+cmTargetInternalPointer& cmTargetInternalPointer::operator=(
+  cmTargetInternalPointer const& r)
 {
-  if(this == &r) { return *this; } // avoid warning on HP about self check
+  if (this == &r) {
+    return *this;
+  } // avoid warning on HP about self check
   // Ideally cmTarget instances should never be copied.  However until
   // we can make a sweep to remove that, this copy constructor avoids
   // allowing the resources (Internals) to be copied.
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 97b0871..71ba0cd 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -12,18 +12,20 @@
 #ifndef cmTarget_h
 #define cmTarget_h
 
+#include "cmStandardIncludes.h"
+
 #include "cmCustomCommand.h"
-#include "cmPropertyMap.h"
-#include "cmPolicies.h"
 #include "cmListFileCache.h"
+#include "cmPolicies.h"
+#include "cmPropertyMap.h"
 
 #include <cmsys/auto_ptr.hxx>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# ifdef CMake_HAVE_CXX11_UNORDERED_MAP
-#  include <unordered_map>
-# else
-#  include <cmsys/hash_map.hxx>
-# endif
+#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
+#include <unordered_map>
+#else
+#include <cmsys/hash_map.hxx>
+#endif
 #endif
 
 class cmake;
@@ -59,15 +61,17 @@ class cmTarget
 {
 public:
   cmTarget();
-  enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };
+  enum CustomCommandType
+  {
+    PRE_BUILD,
+    PRE_LINK,
+    POST_BUILD
+  };
 
   /**
    * Return the type of target.
    */
-  cmState::TargetType GetType() const
-    {
-    return this->TargetTypeValue;
-    }
+  cmState::TargetType GetType() const { return this->TargetTypeValue; }
 
   /**
    * Set the target type
@@ -77,15 +81,17 @@ public:
   void MarkAsImported(bool global = false);
 
   ///! Set/Get the name of the target
-  const std::string& GetName() const {return this->Name;}
+  const std::string& GetName() const { return this->Name; }
 
   ///! Set the cmMakefile that owns this target
-  void SetMakefile(cmMakefile *mf);
-  cmMakefile *GetMakefile() const { return this->Makefile;}
+  void SetMakefile(cmMakefile* mf);
+  cmMakefile* GetMakefile() const { return this->Makefile; }
 
-#define DECLARE_TARGET_POLICY(POLICY) \
-  cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
-    { return this->PolicyMap.Get(cmPolicies::POLICY); }
+#define DECLARE_TARGET_POLICY(POLICY)                                         \
+  cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const                    \
+  {                                                                           \
+    return this->PolicyMap.Get(cmPolicies::POLICY);                           \
+  }
 
   CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
 
@@ -94,18 +100,30 @@ public:
   /**
    * Get the list of the custom commands for this target
    */
-  std::vector<cmCustomCommand> const &GetPreBuildCommands() const
-    {return this->PreBuildCommands;}
-  std::vector<cmCustomCommand> const &GetPreLinkCommands() const
-    {return this->PreLinkCommands;}
-  std::vector<cmCustomCommand> const &GetPostBuildCommands() const
-    {return this->PostBuildCommands;}
-  void AddPreBuildCommand(cmCustomCommand const &cmd)
-    {this->PreBuildCommands.push_back(cmd);}
-  void AddPreLinkCommand(cmCustomCommand const &cmd)
-    {this->PreLinkCommands.push_back(cmd);}
-  void AddPostBuildCommand(cmCustomCommand const &cmd)
-    {this->PostBuildCommands.push_back(cmd);}
+  std::vector<cmCustomCommand> const& GetPreBuildCommands() const
+  {
+    return this->PreBuildCommands;
+  }
+  std::vector<cmCustomCommand> const& GetPreLinkCommands() const
+  {
+    return this->PreLinkCommands;
+  }
+  std::vector<cmCustomCommand> const& GetPostBuildCommands() const
+  {
+    return this->PostBuildCommands;
+  }
+  void AddPreBuildCommand(cmCustomCommand const& cmd)
+  {
+    this->PreBuildCommands.push_back(cmd);
+  }
+  void AddPreLinkCommand(cmCustomCommand const& cmd)
+  {
+    this->PreLinkCommands.push_back(cmd);
+  }
+  void AddPostBuildCommand(cmCustomCommand const& cmd)
+  {
+    this->PostBuildCommands.push_back(cmd);
+  }
 
   /**
    * Add sources to the target.
@@ -118,28 +136,30 @@ public:
   //* how we identify a library, by name and type
   typedef std::pair<std::string, cmTargetLinkLibraryType> LibraryID;
 
-  typedef std::vector<LibraryID > LinkLibraryVectorType;
-  const LinkLibraryVectorType &GetOriginalLinkLibraries() const
-    {return this->OriginalLinkLibraries;}
+  typedef std::vector<LibraryID> LinkLibraryVectorType;
+  const LinkLibraryVectorType& GetOriginalLinkLibraries() const
+  {
+    return this->OriginalLinkLibraries;
+  }
 
   /**
    * Clear the dependency information recorded for this target, if any.
    */
   void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
 
-  void AddLinkLibrary(cmMakefile& mf,
-                      const std::string& target, const std::string& lib,
-                      cmTargetLinkLibraryType llt);
-  enum TLLSignature {
+  void AddLinkLibrary(cmMakefile& mf, const std::string& target,
+                      const std::string& lib, cmTargetLinkLibraryType llt);
+  enum TLLSignature
+  {
     KeywordTLLSignature,
     PlainTLLSignature
   };
   bool PushTLLCommandTrace(TLLSignature signature,
                            cmListFileContext const& lfc);
-  void GetTllSignatureTraces(std::ostringstream &s, TLLSignature sig) const;
+  void GetTllSignatureTraces(std::ostringstream& s, TLLSignature sig) const;
 
-  void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
-                           const LinkLibraryVectorType& libs );
+  void MergeLinkLibraries(cmMakefile& mf, const std::string& selfname,
+                          const LinkLibraryVectorType& libs);
 
   const std::vector<std::string>& GetLinkDirectories() const;
 
@@ -149,16 +169,21 @@ public:
    * Set the path where this target should be installed. This is relative to
    * INSTALL_PREFIX
    */
-  std::string GetInstallPath() const {return this->InstallPath;}
-  void SetInstallPath(const char *name) {this->InstallPath = name;}
+  std::string GetInstallPath() const { return this->InstallPath; }
+  void SetInstallPath(const char* name) { this->InstallPath = name; }
 
   /**
    * Set the path where this target (if it has a runtime part) should be
    * installed. This is relative to INSTALL_PREFIX
    */
-  std::string GetRuntimeInstallPath() const {return this->RuntimeInstallPath;}
-  void SetRuntimeInstallPath(const char *name) {
-    this->RuntimeInstallPath = name; }
+  std::string GetRuntimeInstallPath() const
+  {
+    return this->RuntimeInstallPath;
+  }
+  void SetRuntimeInstallPath(const char* name)
+  {
+    this->RuntimeInstallPath = name;
+  }
 
   /**
    * Get/Set whether there is an install rule for this target.
@@ -170,31 +195,31 @@ public:
    * 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 std::string& u, cmMakefile *makefile = 0);
+  void AddUtility(const std::string& u, cmMakefile* makefile = 0);
   ///! Get the utilities used by this target
-  std::set<std::string>const& GetUtilities() const { return this->Utilities; }
+  std::set<std::string> const& GetUtilities() const { return this->Utilities; }
   cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
   ///! Set/Get a property of this target file
-  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;
+  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;
 
-  bool IsImported() const {return this->IsImportedTarget;}
+  bool IsImported() const { return this->IsImportedTarget; }
   bool IsImportedGloballyVisible() const
-  { return this->ImportedGloballyVisible; }
+  {
+    return this->ImportedGloballyVisible;
+  }
 
   // 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,
-                       const char** imp,
-                       std::string& suffix) const;
+  bool GetMappedConfig(std::string const& desired_config, const char** loc,
+                       const char** imp, std::string& suffix) const;
 
   /** Return whether this target is an executable with symbol exports
       enabled.  */
@@ -210,23 +235,23 @@ public:
   /** Get a backtrace from the creation of the target.  */
   cmListFileBacktrace const& GetBacktrace() const;
 
-  void InsertInclude(std::string const& entry,
-                     cmListFileBacktrace const& bt,
+  void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt,
                      bool before = false);
   void InsertCompileOption(std::string const& entry,
-                           cmListFileBacktrace const& bt,
-                           bool before = false);
+                           cmListFileBacktrace const& bt, bool before = false);
   void InsertCompileDefinition(std::string const& entry,
                                cmListFileBacktrace const& bt);
 
   void AppendBuildInterfaceIncludes();
 
-  std::string GetDebugGeneratorExpressions(const std::string &value,
-                                  cmTargetLinkLibraryType llt) const;
+  std::string GetDebugGeneratorExpressions(const std::string& value,
+                                           cmTargetLinkLibraryType llt) const;
 
-  void AddSystemIncludeDirectories(const std::set<std::string> &incs);
-  std::set<std::string> const & GetSystemIncludeDirectories() const
-    { return this->SystemIncludeDirectories; }
+  void AddSystemIncludeDirectories(const std::set<std::string>& incs);
+  std::set<std::string> const& GetSystemIncludeDirectories() const
+  {
+    return this->SystemIncludeDirectories;
+  }
 
   cmStringRange GetIncludeDirectoriesEntries() const;
   cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
@@ -245,71 +270,14 @@ public:
   cmStringRange GetLinkImplementationEntries() const;
   cmBacktraceRange GetLinkImplementationBacktraces() const;
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  const LinkLibraryVectorType &GetLinkLibrariesForVS6() const {
-  return this->LinkLibrariesForVS6;}
-
-  void AnalyzeLibDependenciesForVS6( const cmMakefile& mf );
-#endif
-
-  struct StrictTargetComparison {
+  struct StrictTargetComparison
+  {
     bool operator()(cmTarget const* t1, cmTarget const* t2) const;
   };
 
 private:
   bool HandleLocationPropertyPolicy(cmMakefile* context) const;
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  /**
-   * A list of direct dependencies. Use in conjunction with DependencyMap.
-   */
-  typedef std::vector< LibraryID > DependencyList;
-
-  /**
-   * This map holds the dependency graph. map[x] returns a set of
-   * direct dependencies of x. Note that the direct depenencies are
-   * ordered. This is necessary to handle direct dependencies that
-   * themselves have no dependency information.
-   */
-  typedef std::map< LibraryID, DependencyList > DependencyMap;
-
-  /**
-   * Inserts \a dep at the end of the dependency list of \a lib.
-   */
-  void InsertDependencyForVS6( DependencyMap& depMap,
-                               const LibraryID& lib,
-                               const LibraryID& dep);
-
-  /*
-   * Deletes \a dep from the dependency list of \a lib.
-   */
-  void DeleteDependencyForVS6( DependencyMap& depMap,
-                               const LibraryID& lib,
-                               const LibraryID& dep);
-
-  /**
-   * Emits the library \a lib and all its dependencies into link_line.
-   * \a emitted keeps track of the libraries that have been emitted to
-   * avoid duplicates--it is more efficient than searching
-   * link_line. \a visited is used detect cycles. Note that \a
-   * link_line is in reverse order, in that the dependencies of a
-   * library are listed before the library itself.
-   */
-  void EmitForVS6( const LibraryID lib,
-                   const DependencyMap& dep_map,
-                   std::set<LibraryID>& emitted,
-                   std::set<LibraryID>& visited,
-                   DependencyList& link_line);
-
-  /**
-   * Finds the dependencies for \a lib and inserts them into \a
-   * dep_map.
-   */
-  void GatherDependenciesForVS6( const cmMakefile& mf,
-                                 const LibraryID& lib,
-                                 DependencyMap& dep_map);
-#endif
-
   const char* GetSuffixVariableInternal(bool implib) const;
   const char* GetPrefixVariableInternal(bool implib) const;
 
@@ -338,9 +306,6 @@ private:
   std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands;
   LinkLibraryVectorType PrevLinkedLibraries;
   LinkLibraryVectorType OriginalLinkLibraries;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  LinkLibraryVectorType LinkLibrariesForVS6;
-#endif
   cmMakefile* Makefile;
   cmTargetInternalPointer Internal;
   cmState::TargetType TargetTypeValue;
@@ -351,9 +316,6 @@ private:
   bool IsImportedTarget;
   bool ImportedGloballyVisible;
   bool BuildInterfaceIncludesAppended;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  bool LinkLibrariesForVS6Analyzed;
-#endif
 
   std::string ProcessSourceItemCMP0049(const std::string& s);
 
@@ -375,10 +337,14 @@ typedef std::unordered_map<std::string, cmTarget> cmTargets;
 typedef cmsys::hash_map<std::string, cmTarget> cmTargets;
 #endif
 #else
-typedef std::map<std::string,cmTarget> cmTargets;
+typedef std::map<std::string, cmTarget> cmTargets;
 #endif
 
-class cmTargetSet: public std::set<std::string> {};
-class cmTargetManifest: public std::map<std::string, 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 394a166..0711a5c 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -13,56 +13,50 @@
 
 #include "cmAlgorithms.h"
 
-bool cmTargetCompileDefinitionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmTargetCompileDefinitionsCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   return this->HandleArguments(args, "COMPILE_DEFINITIONS");
 }
 
-void cmTargetCompileDefinitionsCommand
-::HandleImportedTarget(const std::string &tgt)
+void cmTargetCompileDefinitionsCommand::HandleImportedTarget(
+  const std::string& tgt)
 {
   std::ostringstream e;
-  e << "Cannot specify compile definitions for imported target \""
-    << tgt << "\".";
+  e << "Cannot specify compile definitions for imported target \"" << tgt
+    << "\".";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-void cmTargetCompileDefinitionsCommand
-::HandleMissingTarget(const std::string &name)
+void cmTargetCompileDefinitionsCommand::HandleMissingTarget(
+  const std::string& name)
 {
   std::ostringstream e;
-  e << "Cannot specify compile definitions for target \"" << name << "\" "
+  e << "Cannot specify compile definitions for target \"" << name
+    << "\" "
        "which is not built by this project.";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
-std::string cmTargetCompileDefinitionsCommand
-::Join(const std::vector<std::string> &content)
+std::string cmTargetCompileDefinitionsCommand::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)
-    {
-    if (cmHasLiteralPrefix(it->c_str(), "-D"))
-      {
+  for (std::vector<std::string>::const_iterator it = content.begin();
+       it != content.end(); ++it) {
+    if (cmHasLiteralPrefix(it->c_str(), "-D")) {
       defs += sep + it->substr(2);
-      }
-    else
-      {
+    } else {
       defs += sep + *it;
-      }
-    sep = ";";
     }
+    sep = ";";
+  }
   return defs;
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetCompileDefinitionsCommand
-::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
-                                   bool, bool)
+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 b548c70..29d86c5 100644
--- a/Source/cmTargetCompileDefinitionsCommand.h
+++ b/Source/cmTargetCompileDefinitionsCommand.h
@@ -21,33 +21,30 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTargetCompileDefinitionsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTargetCompileDefinitionsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "target_compile_definitions";}
+  virtual std::string GetName() const { return "target_compile_definitions"; }
 
   cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase);
 
 private:
-  virtual void HandleImportedTarget(const std::string &tgt);
-  virtual void HandleMissingTarget(const std::string &name);
+  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,
+  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);
+  virtual std::string Join(const std::vector<std::string>& content);
 };
 
 #endif
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 823afa1..3ac791a 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -14,51 +14,46 @@
 #include "cmAlgorithms.h"
 
 bool cmTargetCompileFeaturesCommand::InitialPass(
-  std::vector<std::string> const& args,
-  cmExecutionStatus &)
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
 }
 
-void cmTargetCompileFeaturesCommand
-::HandleImportedTarget(const std::string &tgt)
+void cmTargetCompileFeaturesCommand::HandleImportedTarget(
+  const std::string& tgt)
 {
   std::ostringstream e;
-  e << "Cannot specify compile features for imported target \""
-    << tgt << "\".";
+  e << "Cannot specify compile features for imported target \"" << tgt
+    << "\".";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-void cmTargetCompileFeaturesCommand
-::HandleMissingTarget(const std::string &name)
+void cmTargetCompileFeaturesCommand::HandleMissingTarget(
+  const std::string& name)
 {
   std::ostringstream e;
-  e << "Cannot specify compile features for target \"" << name << "\" "
+  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 cmTargetCompileFeaturesCommand::Join(
+  const std::vector<std::string>& content)
 {
   return cmJoin(content, ";");
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetCompileFeaturesCommand
-::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
-                                   bool, bool)
+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)
-    {
+  for (std::vector<std::string>::const_iterator it = content.begin();
+       it != content.end(); ++it) {
     std::string error;
-    if(!this->Makefile->AddRequiredTargetFeature(tgt, *it, &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
index fa7ae8d..3d883e9 100644
--- a/Source/cmTargetCompileFeaturesCommand.h
+++ b/Source/cmTargetCompileFeaturesCommand.h
@@ -16,26 +16,23 @@
 
 class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase
 {
-  virtual cmCommand* Clone()
-    {
-    return new cmTargetCompileFeaturesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTargetCompileFeaturesCommand; }
 
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
-  virtual std::string GetName() const { return "target_compile_features";}
+  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 void HandleImportedTarget(const std::string& tgt);
+  virtual void HandleMissingTarget(const std::string& name);
 
-  virtual bool HandleDirectContent(cmTarget *tgt,
-                                   const std::vector<std::string> &content,
+  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);
+  virtual std::string Join(const std::vector<std::string>& content);
 };
 
 #endif
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 8e86f0f..065f618 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -13,41 +13,38 @@
 
 #include "cmAlgorithms.h"
 
-bool cmTargetCompileOptionsCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmTargetCompileOptionsCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE);
 }
 
-void cmTargetCompileOptionsCommand
-::HandleImportedTarget(const std::string &tgt)
+void cmTargetCompileOptionsCommand::HandleImportedTarget(
+  const std::string& tgt)
 {
   std::ostringstream e;
-  e << "Cannot specify compile options for imported target \""
-    << tgt << "\".";
+  e << "Cannot specify compile options for imported target \"" << tgt << "\".";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-void cmTargetCompileOptionsCommand
-::HandleMissingTarget(const std::string &name)
+void cmTargetCompileOptionsCommand::HandleMissingTarget(
+  const std::string& name)
 {
   std::ostringstream e;
-  e << "Cannot specify compile options for target \"" << name << "\" "
+  e << "Cannot specify compile options for target \"" << name
+    << "\" "
        "which is not built by this project.";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
-std::string cmTargetCompileOptionsCommand
-::Join(const std::vector<std::string> &content)
+std::string cmTargetCompileOptionsCommand::Join(
+  const std::vector<std::string>& content)
 {
   return cmJoin(content, ";");
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetCompileOptionsCommand
-::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
-                                   bool, bool)
+bool cmTargetCompileOptionsCommand::HandleDirectContent(
+  cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
 {
   cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
   tgt->InsertCompileOption(this->Join(content), lfbt);
diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h
index d43534d..231448b 100644
--- a/Source/cmTargetCompileOptionsCommand.h
+++ b/Source/cmTargetCompileOptionsCommand.h
@@ -21,33 +21,30 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTargetCompileOptionsCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTargetCompileOptionsCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "target_compile_options";}
+  virtual std::string GetName() const { return "target_compile_options"; }
 
   cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase);
 
 private:
-  virtual void HandleImportedTarget(const std::string &tgt);
-  virtual void HandleMissingTarget(const std::string &name);
+  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,
+  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);
+  virtual std::string Join(const std::vector<std::string>& content);
 };
 
 #endif
diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h
index c5059ee..954d8f6 100644
--- a/Source/cmTargetDepend.h
+++ b/Source/cmTargetDepend.h
@@ -26,24 +26,36 @@ class cmTargetDepend
   // mutable members to acheive a map with set syntax.
   mutable bool Link;
   mutable bool Util;
+
 public:
   cmTargetDepend(cmGeneratorTarget const* t)
-    : Target(t), Link(false), Util(false) {}
+    : Target(t)
+    , Link(false)
+    , Util(false)
+  {
+  }
   operator cmGeneratorTarget const*() const { return this->Target; }
   cmGeneratorTarget const* operator->() const { return this->Target; }
   cmGeneratorTarget const& operator*() const { return *this->Target; }
-  friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r)
-    { return l.Target < r.Target; }
+  friend bool operator<(cmTargetDepend const& l, cmTargetDepend const& r)
+  {
+    return l.Target < r.Target;
+  }
   void SetType(bool strong) const
-    {
-    if(strong) { this->Util = true; }
-    else { this->Link = true; }
+  {
+    if (strong) {
+      this->Util = true;
+    } else {
+      this->Link = true;
     }
+  }
   bool IsLink() const { return this->Link; }
   bool IsUtil() const { return this->Util; }
 };
 
 /** Unordered set of (direct) dependencies of a target. */
-class cmTargetDependSet: public std::set<cmTargetDepend> {};
+class cmTargetDependSet : public std::set<cmTargetDepend>
+{
+};
 
 #endif
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index 7dfe9ca..4486b0e 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -13,102 +13,86 @@
 
 #include "cmGeneratorExpression.h"
 
-//----------------------------------------------------------------------------
-bool cmTargetIncludeDirectoriesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmTargetIncludeDirectoriesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   return this->HandleArguments(args, "INCLUDE_DIRECTORIES",
                                ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM));
 }
 
-//----------------------------------------------------------------------------
-void cmTargetIncludeDirectoriesCommand
-::HandleImportedTarget(const std::string &tgt)
+void cmTargetIncludeDirectoriesCommand::HandleImportedTarget(
+  const std::string& tgt)
 {
   std::ostringstream e;
-  e << "Cannot specify include directories for imported target \""
-    << tgt << "\".";
+  e << "Cannot specify include directories for imported target \"" << tgt
+    << "\".";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
-void cmTargetIncludeDirectoriesCommand
-::HandleMissingTarget(const std::string &name)
+void cmTargetIncludeDirectoriesCommand::HandleMissingTarget(
+  const std::string& name)
 {
   std::ostringstream e;
-  e << "Cannot specify include directories for target \"" << name << "\" "
+  e << "Cannot specify include directories for target \"" << name
+    << "\" "
        "which is not built by this project.";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
-std::string cmTargetIncludeDirectoriesCommand
-::Join(const std::vector<std::string> &content)
+std::string cmTargetIncludeDirectoriesCommand::Join(
+  const std::vector<std::string>& content)
 {
   std::string dirs;
   std::string sep;
   std::string prefix =
-      this->Makefile->GetCurrentSourceDirectory() + std::string("/");
-  for(std::vector<std::string>::const_iterator it = content.begin();
-    it != content.end(); ++it)
-    {
-    if (cmSystemTools::FileIsFullPath(it->c_str())
-        || cmGeneratorExpression::Find(*it) == 0)
-      {
+    this->Makefile->GetCurrentSourceDirectory() + std::string("/");
+  for (std::vector<std::string>::const_iterator it = content.begin();
+       it != content.end(); ++it) {
+    if (cmSystemTools::FileIsFullPath(it->c_str()) ||
+        cmGeneratorExpression::Find(*it) == 0) {
       dirs += sep + *it;
-      }
-    else
-      {
+    } else {
       dirs += sep + prefix + *it;
-      }
-    sep = ";";
     }
+    sep = ";";
+  }
   return dirs;
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetIncludeDirectoriesCommand
-::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
-                      bool prepend, bool system)
+bool cmTargetIncludeDirectoriesCommand::HandleDirectContent(
+  cmTarget* tgt, const std::vector<std::string>& content, bool prepend,
+  bool system)
 {
   cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
   tgt->InsertInclude(this->Join(content), lfbt, prepend);
-  if (system)
-    {
+  if (system) {
     std::string prefix =
       this->Makefile->GetCurrentSourceDirectory() + std::string("/");
     std::set<std::string> sdirs;
     for (std::vector<std::string>::const_iterator it = content.begin();
-      it != content.end(); ++it)
-      {
-      if (cmSystemTools::FileIsFullPath(it->c_str())
-          || cmGeneratorExpression::Find(*it) == 0)
-        {
+         it != content.end(); ++it) {
+      if (cmSystemTools::FileIsFullPath(it->c_str()) ||
+          cmGeneratorExpression::Find(*it) == 0) {
         sdirs.insert(*it);
-        }
-      else
-        {
+      } else {
         sdirs.insert(prefix + *it);
-        }
       }
-    tgt->AddSystemIncludeDirectories(sdirs);
     }
+    tgt->AddSystemIncludeDirectories(sdirs);
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-void cmTargetIncludeDirectoriesCommand
-::HandleInterfaceContent(cmTarget *tgt,
-                         const std::vector<std::string> &content,
-                         bool prepend, bool system)
+void cmTargetIncludeDirectoriesCommand::HandleInterfaceContent(
+  cmTarget* tgt, const std::vector<std::string>& content, bool prepend,
+  bool system)
 {
-  cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
-                                                  prepend, system);
+  cmTargetPropCommandBase::HandleInterfaceContent(tgt, content, prepend,
+                                                  system);
 
-  if (system)
-    {
+  if (system) {
     std::string joined = this->Join(content);
     tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
                         joined.c_str());
-    }
+  }
 }
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index 2a7814e..4c907bd 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -15,44 +15,40 @@
 
 #include "cmTargetPropCommandBase.h"
 
-//----------------------------------------------------------------------------
 class cmTargetIncludeDirectoriesCommand : public cmTargetPropCommandBase
 {
 public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTargetIncludeDirectoriesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTargetIncludeDirectoriesCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "target_include_directories";}
+  virtual std::string GetName() const { return "target_include_directories"; }
 
   cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase);
 
 private:
-  virtual void HandleImportedTarget(const std::string &tgt);
-  virtual void HandleMissingTarget(const std::string &name);
+  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 void HandleInterfaceContent(cmTarget *tgt,
-                                   const std::vector<std::string> &content,
+  virtual bool HandleDirectContent(cmTarget* tgt,
+                                   const std::vector<std::string>& content,
                                    bool prepend, bool system);
+  virtual void HandleInterfaceContent(cmTarget* tgt,
+                                      const std::vector<std::string>& content,
+                                      bool prepend, bool system);
 
-  virtual std::string Join(const std::vector<std::string> &content);
+  virtual std::string Join(const std::vector<std::string>& content);
 };
 
 #endif
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 435346a..774577a 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -13,68 +13,60 @@
 
 #include "cmGeneratorExpression.h"
 
-const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] =
-{
-  "general",
-  "debug",
-  "optimized"
+const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] = {
+  "general", "debug", "optimized"
 };
 
 // cmTargetLinkLibrariesCommand
-bool cmTargetLinkLibrariesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmTargetLinkLibrariesCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
   // must have one argument
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
-  if (this->Makefile->IsAlias(args[0]))
-    {
+  if (this->Makefile->IsAlias(args[0])) {
     this->SetError("can not be used on an ALIAS target.");
     return false;
-    }
+  }
   // Lookup the target for which libraries are specified.
   this->Target =
-    this->Makefile->GetCMakeInstance()
-    ->GetGlobalGenerator()->FindTarget(args[0]);
-  if(!this->Target)
-    {
-    cmake::MessageType t = cmake::FATAL_ERROR;  // fail by default
+    this->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
+      args[0]);
+  if (!this->Target) {
+    cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
     std::ostringstream e;
     e << "Cannot specify link libraries for target \"" << args[0] << "\" "
       << "which is not built by this project.";
     // The bad target is the only argument. Check how policy CMP0016 is set,
     // and accept, warn or fail respectively:
-    if (args.size() < 2)
-      {
-      switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016))
-        {
+    if (args.size() < 2) {
+      switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016)) {
         case cmPolicies::WARN:
           t = cmake::AUTHOR_WARNING;
           // Print the warning.
           e << "\n"
             << "CMake does not support this but it used to work accidentally "
             << "and is being allowed for compatibility."
-            << "\n" << cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
-           break;
-        case cmPolicies::OLD:          // OLD behavior does not warn.
+            << "\n"
+            << cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
+          break;
+        case cmPolicies::OLD: // OLD behavior does not warn.
           t = cmake::MESSAGE;
           break;
         case cmPolicies::REQUIRED_IF_USED:
         case cmPolicies::REQUIRED_ALWAYS:
           e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0016);
           break;
-        case cmPolicies::NEW:  // NEW behavior prints the error.
+        case cmPolicies::NEW: // NEW behavior prints the error.
           break;
-        }
       }
+    }
 
     // now actually print the message
-    switch(t)
-      {
+    switch (t) {
       case cmake::AUTHOR_WARNING:
         this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
         break;
@@ -84,27 +76,24 @@ bool cmTargetLinkLibrariesCommand
         break;
       default:
         break;
-      }
-    return true;
     }
+    return true;
+  }
 
-  if(this->Target->GetType() == cmState::OBJECT_LIBRARY)
-    {
+  if (this->Target->GetType() == cmState::OBJECT_LIBRARY) {
     std::ostringstream e;
     e << "Object library target \"" << args[0] << "\" "
       << "may not link to anything.";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     cmSystemTools::SetFatalErrorOccured();
     return true;
-    }
+  }
 
-  if (this->Target->GetType() == cmState::UTILITY)
-    {
+  if (this->Target->GetType() == cmState::UTILITY) {
     std::ostringstream e;
-    const char *modal = 0;
+    const char* modal = 0;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n";
         modal = "should";
@@ -115,25 +104,21 @@ bool cmTargetLinkLibrariesCommand
       case cmPolicies::NEW:
         modal = "must";
         messageType = cmake::FATAL_ERROR;
-      }
-    if (modal)
-      {
-      e <<
-        "Utility target \"" << this->Target->GetName() << "\" " << modal
+    }
+    if (modal) {
+      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());
-      if(messageType == cmake::FATAL_ERROR)
-        {
+      if (messageType == cmake::FATAL_ERROR) {
         return false;
-        }
       }
     }
+  }
 
   // but we might not have any libs after variable expansion
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     return true;
-    }
+  }
 
   // Keep track of link configuration specifiers.
   cmTargetLinkLibraryType llt = GENERAL_LibraryType;
@@ -145,137 +130,98 @@ bool cmTargetLinkLibrariesCommand
 
   // add libraries, note that there is an optional prefix
   // of debug and optimized that can be used
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
-    if(args[i] == "LINK_INTERFACE_LIBRARIES")
-      {
+  for (unsigned int i = 1; i < args.size(); ++i) {
+    if (args[i] == "LINK_INTERFACE_LIBRARIES") {
       this->CurrentProcessingState = ProcessingPlainLinkInterface;
-      if(i != 1)
-        {
+      if (i != 1) {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
           "The LINK_INTERFACE_LIBRARIES option must appear as the second "
-          "argument, just after the target name."
-          );
+          "argument, just after the target name.");
         return true;
-        }
       }
-    else if(args[i] == "INTERFACE")
-      {
-      if(i != 1
-          && this->CurrentProcessingState != ProcessingKeywordPrivateInterface
-          && this->CurrentProcessingState != ProcessingKeywordPublicInterface
-          && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
-        {
+    } else if (args[i] == "INTERFACE") {
+      if (i != 1 &&
+          this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
+          this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
+          this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
         this->Makefile->IssueMessage(
-          cmake::FATAL_ERROR,
-          "The INTERFACE option must appear as the second "
-          "argument, just after the target name."
-          );
+          cmake::FATAL_ERROR, "The INTERFACE option must appear as the second "
+                              "argument, just after the target name.");
         return true;
-        }
-      this->CurrentProcessingState = ProcessingKeywordLinkInterface;
       }
-    else if(args[i] == "LINK_PUBLIC")
-      {
-      if(i != 1
-          && this->CurrentProcessingState != ProcessingPlainPrivateInterface
-          && this->CurrentProcessingState != ProcessingPlainPublicInterface)
-        {
+      this->CurrentProcessingState = ProcessingKeywordLinkInterface;
+    } else if (args[i] == "LINK_PUBLIC") {
+      if (i != 1 &&
+          this->CurrentProcessingState != ProcessingPlainPrivateInterface &&
+          this->CurrentProcessingState != ProcessingPlainPublicInterface) {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
           "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
-          "argument, just after the target name."
-          );
+          "argument, just after the target name.");
         return true;
-        }
-      this->CurrentProcessingState = ProcessingPlainPublicInterface;
       }
-    else if(args[i] == "PUBLIC")
-      {
-      if(i != 1
-          && this->CurrentProcessingState != ProcessingKeywordPrivateInterface
-          && this->CurrentProcessingState != ProcessingKeywordPublicInterface
-          && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
-        {
+      this->CurrentProcessingState = ProcessingPlainPublicInterface;
+    } else if (args[i] == "PUBLIC") {
+      if (i != 1 &&
+          this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
+          this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
+          this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
           "The PUBLIC or PRIVATE option must appear as the second "
-          "argument, just after the target name."
-          );
+          "argument, just after the target name.");
         return true;
-        }
-      this->CurrentProcessingState = ProcessingKeywordPublicInterface;
       }
-    else if(args[i] == "LINK_PRIVATE")
-      {
-      if(i != 1
-          && this->CurrentProcessingState != ProcessingPlainPublicInterface
-          && this->CurrentProcessingState != ProcessingPlainPrivateInterface)
-        {
+      this->CurrentProcessingState = ProcessingKeywordPublicInterface;
+    } else if (args[i] == "LINK_PRIVATE") {
+      if (i != 1 &&
+          this->CurrentProcessingState != ProcessingPlainPublicInterface &&
+          this->CurrentProcessingState != ProcessingPlainPrivateInterface) {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
           "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
-          "argument, just after the target name."
-          );
+          "argument, just after the target name.");
         return true;
-        }
-      this->CurrentProcessingState = ProcessingPlainPrivateInterface;
       }
-    else if(args[i] == "PRIVATE")
-      {
-      if(i != 1
-          && this->CurrentProcessingState != ProcessingKeywordPrivateInterface
-          && this->CurrentProcessingState != ProcessingKeywordPublicInterface
-          && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
-        {
+      this->CurrentProcessingState = ProcessingPlainPrivateInterface;
+    } else if (args[i] == "PRIVATE") {
+      if (i != 1 &&
+          this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
+          this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
+          this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
         this->Makefile->IssueMessage(
           cmake::FATAL_ERROR,
           "The PUBLIC or PRIVATE option must appear as the second "
-          "argument, just after the target name."
-          );
+          "argument, just after the target name.");
         return true;
-        }
-      this->CurrentProcessingState = ProcessingKeywordPrivateInterface;
       }
-    else if(args[i] == "debug")
-      {
-      if(haveLLT)
-        {
+      this->CurrentProcessingState = ProcessingKeywordPrivateInterface;
+    } else if (args[i] == "debug") {
+      if (haveLLT) {
         this->LinkLibraryTypeSpecifierWarning(llt, DEBUG_LibraryType);
-        }
+      }
       llt = DEBUG_LibraryType;
       haveLLT = true;
-      }
-    else if(args[i] == "optimized")
-      {
-      if(haveLLT)
-        {
+    } else if (args[i] == "optimized") {
+      if (haveLLT) {
         this->LinkLibraryTypeSpecifierWarning(llt, OPTIMIZED_LibraryType);
-        }
+      }
       llt = OPTIMIZED_LibraryType;
       haveLLT = true;
-      }
-    else if(args[i] == "general")
-      {
-      if(haveLLT)
-        {
+    } else if (args[i] == "general") {
+      if (haveLLT) {
         this->LinkLibraryTypeSpecifierWarning(llt, GENERAL_LibraryType);
-        }
+      }
       llt = GENERAL_LibraryType;
       haveLLT = true;
-      }
-    else if(haveLLT)
-      {
+    } else if (haveLLT) {
       // The link type was specified by the previous argument.
       haveLLT = false;
-      if (!this->HandleLibrary(args[i], llt))
-        {
+      if (!this->HandleLibrary(args[i], llt)) {
         return false;
-        }
       }
-    else
-      {
+    } else {
       // Lookup old-style cache entry if type is unspecified.  So if you
       // do a target_link_libraries(foo optimized bar) it will stay optimized
       // and not use the lookup.  As there maybe the case where someone has
@@ -285,97 +231,85 @@ bool cmTargetLinkLibrariesCommand
       llt = GENERAL_LibraryType;
       std::string linkType = args[0];
       linkType += "_LINK_TYPE";
-      const char* linkTypeString =
-        this->Makefile->GetDefinition( linkType );
-      if(linkTypeString)
-        {
-        if(strcmp(linkTypeString, "debug") == 0)
-          {
+      const char* linkTypeString = this->Makefile->GetDefinition(linkType);
+      if (linkTypeString) {
+        if (strcmp(linkTypeString, "debug") == 0) {
           llt = DEBUG_LibraryType;
-          }
-        if(strcmp(linkTypeString, "optimized") == 0)
-          {
+        }
+        if (strcmp(linkTypeString, "optimized") == 0) {
           llt = OPTIMIZED_LibraryType;
-          }
         }
-      if (!this->HandleLibrary(args[i], llt))
-        {
+      }
+      if (!this->HandleLibrary(args[i], llt)) {
         return false;
-        }
       }
     }
+  }
 
   // Make sure the last argument was not a library type specifier.
-  if(haveLLT)
-    {
+  if (haveLLT) {
     std::ostringstream e;
     e << "The \"" << this->LinkLibraryTypeNames[llt]
       << "\" argument must be followed by a library.";
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     cmSystemTools::SetFatalErrorOccured();
-    }
+  }
 
-  const cmPolicies::PolicyStatus policy22Status
-                      = this->Target->GetPolicyStatusCMP0022();
+  const cmPolicies::PolicyStatus policy22Status =
+    this->Target->GetPolicyStatusCMP0022();
 
   // If any of the LINK_ options were given, make sure the
   // LINK_INTERFACE_LIBRARIES target property exists.
   // Use of any of the new keywords implies awareness of
   // this property. And if no libraries are named, it should
   // result in an empty link interface.
-  if((policy22Status == cmPolicies::OLD ||
-      policy22Status == cmPolicies::WARN) &&
+  if ((policy22Status == cmPolicies::OLD ||
+       policy22Status == cmPolicies::WARN) &&
       this->CurrentProcessingState != ProcessingLinkLibraries &&
-     !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES"))
-    {
+      !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
     this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
-    }
+  }
 
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmTargetLinkLibrariesCommand
-::LinkLibraryTypeSpecifierWarning(int left, int right)
+void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left,
+                                                                   int right)
 {
   std::ostringstream w;
-  w << "Link library type specifier \""
-    << this->LinkLibraryTypeNames[left] << "\" is followed by specifier \""
-    << this->LinkLibraryTypeNames[right] << "\" instead of a library name.  "
+  w << "Link library type specifier \"" << this->LinkLibraryTypeNames[left]
+    << "\" is followed by specifier \"" << this->LinkLibraryTypeNames[right]
+    << "\" instead of a library name.  "
     << "The first specifier will be ignored.";
   this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
 }
 
-//----------------------------------------------------------------------------
-bool
-cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
-                                            cmTargetLinkLibraryType llt)
+bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
+                                                 cmTargetLinkLibraryType llt)
 {
-  if(this->Target->GetType() == cmState::INTERFACE_LIBRARY
-      && this->CurrentProcessingState != ProcessingKeywordLinkInterface)
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+  if (this->Target->GetType() == cmState::INTERFACE_LIBRARY &&
+      this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
       "INTERFACE library can only be used with the INTERFACE keyword of "
       "target_link_libraries");
     return false;
-    }
+  }
 
   cmTarget::TLLSignature sig =
-        (this->CurrentProcessingState == ProcessingPlainPrivateInterface
-      || this->CurrentProcessingState == ProcessingPlainPublicInterface
-      || this->CurrentProcessingState == ProcessingKeywordPrivateInterface
-      || this->CurrentProcessingState == ProcessingKeywordPublicInterface
-      || this->CurrentProcessingState == ProcessingKeywordLinkInterface)
-        ? cmTarget::KeywordTLLSignature : cmTarget::PlainTLLSignature;
+    (this->CurrentProcessingState == ProcessingPlainPrivateInterface ||
+     this->CurrentProcessingState == ProcessingPlainPublicInterface ||
+     this->CurrentProcessingState == ProcessingKeywordPrivateInterface ||
+     this->CurrentProcessingState == ProcessingKeywordPublicInterface ||
+     this->CurrentProcessingState == ProcessingKeywordLinkInterface)
+    ? cmTarget::KeywordTLLSignature
+    : cmTarget::PlainTLLSignature;
   if (!this->Target->PushTLLCommandTrace(
-        sig, this->Makefile->GetExecutionContext()))
-    {
+        sig, this->Makefile->GetExecutionContext())) {
     std::ostringstream e;
-    const char *modal = 0;
+    const char* modal = 0;
     cmake::MessageType messageType = cmake::AUTHOR_WARNING;
-    switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0023))
-      {
+    switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0023)) {
       case cmPolicies::WARN:
         e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n";
         modal = "should";
@@ -386,82 +320,74 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
       case cmPolicies::NEW:
         modal = "must";
         messageType = cmake::FATAL_ERROR;
-      }
+    }
 
-      if(modal)
-        {
-        // If the sig is a keyword form and there is a conflict, the existing
-        // form must be the plain form.
-        const char *existingSig
-                    = (sig == cmTarget::KeywordTLLSignature ? "plain"
-                                                            : "keyword");
-          e <<
-            "The " << existingSig << " signature for target_link_libraries "
-            "has already been used with the target \""
-          << this->Target->GetName() << "\".  All uses of "
-             "target_link_libraries with a target " << modal << " be either "
-             "all-keyword or all-plain.\n";
-        this->Target->GetTllSignatureTraces(e,
+    if (modal) {
+      // If the sig is a keyword form and there is a conflict, the existing
+      // form must be the plain form.
+      const char* existingSig =
+        (sig == cmTarget::KeywordTLLSignature ? "plain" : "keyword");
+      e << "The " << existingSig << " signature for target_link_libraries "
+                                    "has already been used with the target \""
+        << this->Target->GetName() << "\".  All uses of "
+                                      "target_link_libraries with a target "
+        << modal << " be either "
+                    "all-keyword or all-plain.\n";
+      this->Target->GetTllSignatureTraces(e,
                                           sig == cmTarget::KeywordTLLSignature
                                             ? cmTarget::PlainTLLSignature
                                             : cmTarget::KeywordTLLSignature);
-        this->Makefile->IssueMessage(messageType, e.str());
-        if(messageType == cmake::FATAL_ERROR)
-          {
-          return false;
-          }
-        }
+      this->Makefile->IssueMessage(messageType, e.str());
+      if (messageType == cmake::FATAL_ERROR) {
+        return false;
+      }
     }
+  }
 
   // Handle normal case first.
-  if(this->CurrentProcessingState != ProcessingKeywordLinkInterface
-      && this->CurrentProcessingState != ProcessingPlainLinkInterface)
-    {
-    this->Makefile
-      ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
-    if(this->CurrentProcessingState == ProcessingLinkLibraries)
-      {
-      this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
+  if (this->CurrentProcessingState != ProcessingKeywordLinkInterface &&
+      this->CurrentProcessingState != ProcessingPlainLinkInterface) {
+    this->Makefile->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
+    if (this->CurrentProcessingState == ProcessingLinkLibraries) {
+      this->Target->AppendProperty(
+        "INTERFACE_LINK_LIBRARIES",
         this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
       return true;
-      }
-    else if(this->CurrentProcessingState != ProcessingKeywordPublicInterface
-            && this->CurrentProcessingState != ProcessingPlainPublicInterface)
-      {
-      if (this->Target->GetType() == cmState::STATIC_LIBRARY)
-        {
-        std::string configLib = this->Target
-                                     ->GetDebugGeneratorExpressions(lib, llt);
-        if (cmGeneratorExpression::IsValidTargetName(lib)
-            || cmGeneratorExpression::Find(lib) != std::string::npos)
-          {
+    } else if (this->CurrentProcessingState !=
+                 ProcessingKeywordPublicInterface &&
+               this->CurrentProcessingState !=
+                 ProcessingPlainPublicInterface) {
+      if (this->Target->GetType() == cmState::STATIC_LIBRARY) {
+        std::string configLib =
+          this->Target->GetDebugGeneratorExpressions(lib, llt);
+        if (cmGeneratorExpression::IsValidTargetName(lib) ||
+            cmGeneratorExpression::Find(lib) != std::string::npos) {
           configLib = "$<LINK_ONLY:" + configLib + ">";
-          }
+        }
         this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
                                      configLib.c_str());
-        }
+      }
       // Not a 'public' or 'interface' library. Do not add to interface
       // property.
       return true;
-      }
     }
+  }
 
-  this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
-              this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
+  this->Target->AppendProperty(
+    "INTERFACE_LINK_LIBRARIES",
+    this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
 
-  const cmPolicies::PolicyStatus policy22Status
-                      = this->Target->GetPolicyStatusCMP0022();
+  const cmPolicies::PolicyStatus policy22Status =
+    this->Target->GetPolicyStatusCMP0022();
 
-  if (policy22Status != cmPolicies::OLD
-      && policy22Status != cmPolicies::WARN)
-    {
+  if (policy22Status != cmPolicies::OLD &&
+      policy22Status != cmPolicies::WARN) {
     return true;
-    }
+  }
 
-  if (this->Target->GetType() == cmState::INTERFACE_LIBRARY)
-    {
+  if (this->Target->GetType() == cmState::INTERFACE_LIBRARY) {
     return true;
-    }
+  }
 
   // Get the list of configurations considered to be DEBUG.
   std::vector<std::string> debugConfigs =
@@ -469,34 +395,29 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
   std::string prop;
 
   // Include this library in the link interface for the target.
-  if(llt == DEBUG_LibraryType || llt == GENERAL_LibraryType)
-    {
+  if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
     // Put in the DEBUG configuration interfaces.
-    for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
-        i != debugConfigs.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
+         i != debugConfigs.end(); ++i) {
       prop = "LINK_INTERFACE_LIBRARIES_";
       prop += *i;
       this->Target->AppendProperty(prop, lib.c_str());
-      }
     }
-  if(llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType)
-    {
+  }
+  if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
     // Put in the non-DEBUG configuration interfaces.
     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.
-    for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
-        i != debugConfigs.end(); ++i)
-      {
+    for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
+         i != debugConfigs.end(); ++i) {
       prop = "LINK_INTERFACE_LIBRARIES_";
       prop += *i;
-      if(!this->Target->GetProperty(prop))
-        {
+      if (!this->Target->GetProperty(prop)) {
         this->Target->SetProperty(prop, "");
-        }
       }
     }
+  }
   return true;
 }
diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h
index f061e6d..016993d 100644
--- a/Source/cmTargetLinkLibrariesCommand.h
+++ b/Source/cmTargetLinkLibrariesCommand.h
@@ -27,30 +27,29 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTargetLinkLibrariesCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTargetLinkLibrariesCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "target_link_libraries";}
+  virtual std::string GetName() const { return "target_link_libraries"; }
 
   cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand);
+
 private:
   void LinkLibraryTypeSpecifierWarning(int left, int right);
   static const char* LinkLibraryTypeNames[3];
 
   cmTarget* Target;
-  enum ProcessingState {
+  enum ProcessingState
+  {
     ProcessingLinkLibraries,
     ProcessingPlainLinkInterface,
     ProcessingKeywordLinkInterface,
@@ -65,6 +64,4 @@ private:
   bool HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt);
 };
 
-
-
 #endif
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index bfc19a4..487074f 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -14,168 +14,135 @@
 
 #include "cmGlobalGenerator.h"
 
-//----------------------------------------------------------------------------
-bool cmTargetPropCommandBase
-::HandleArguments(std::vector<std::string> const& args,
-                  const std::string& prop,
-                  ArgumentFlags flags)
+bool cmTargetPropCommandBase::HandleArguments(
+  std::vector<std::string> const& args, const std::string& prop,
+  ArgumentFlags flags)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // Lookup the target for which libraries are specified.
-  if (this->Makefile->IsAlias(args[0]))
-    {
+  if (this->Makefile->IsAlias(args[0])) {
     this->SetError("can not be used on an ALIAS target.");
     return false;
-    }
+  }
   this->Target =
-    this->Makefile->GetCMakeInstance()
-    ->GetGlobalGenerator()->FindTarget(args[0]);
-  if(!this->Target)
-    {
+    this->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
+      args[0]);
+  if (!this->Target) {
     this->Target = this->Makefile->FindTargetToUse(args[0]);
-    }
-  if(!this->Target)
-    {
+  }
+  if (!this->Target) {
     this->HandleMissingTarget(args[0]);
     return false;
-    }
-  if ((this->Target->GetType() != cmState::SHARED_LIBRARY)
-    && (this->Target->GetType() != cmState::STATIC_LIBRARY)
-    && (this->Target->GetType() != cmState::OBJECT_LIBRARY)
-    && (this->Target->GetType() != cmState::MODULE_LIBRARY)
-    && (this->Target->GetType() != cmState::INTERFACE_LIBRARY)
-    && (this->Target->GetType() != cmState::EXECUTABLE))
-    {
+  }
+  if ((this->Target->GetType() != cmState::SHARED_LIBRARY) &&
+      (this->Target->GetType() != cmState::STATIC_LIBRARY) &&
+      (this->Target->GetType() != cmState::OBJECT_LIBRARY) &&
+      (this->Target->GetType() != cmState::MODULE_LIBRARY) &&
+      (this->Target->GetType() != cmState::INTERFACE_LIBRARY) &&
+      (this->Target->GetType() != cmState::EXECUTABLE)) {
     this->SetError("called with non-compilable target type");
     return false;
-    }
+  }
 
   bool system = false;
   unsigned int argIndex = 1;
 
-  if ((flags & PROCESS_SYSTEM) && args[argIndex] == "SYSTEM")
-    {
-    if (args.size() < 3)
-      {
+  if ((flags & PROCESS_SYSTEM) && args[argIndex] == "SYSTEM") {
+    if (args.size() < 3) {
       this->SetError("called with incorrect number of arguments");
       return false;
-      }
+    }
     system = true;
     ++argIndex;
-    }
+  }
 
   bool prepend = false;
-  if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE")
-    {
-    if (args.size() < 3)
-      {
+  if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE") {
+    if (args.size() < 3) {
       this->SetError("called with incorrect number of arguments");
       return false;
-      }
+    }
     prepend = true;
     ++argIndex;
-    }
+  }
 
   this->Property = prop;
 
-  while (argIndex < args.size())
-    {
-    if (!this->ProcessContentArgs(args, argIndex, prepend, system))
-      {
+  while (argIndex < args.size()) {
+    if (!this->ProcessContentArgs(args, argIndex, prepend, system)) {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetPropCommandBase
-::ProcessContentArgs(std::vector<std::string> const& args,
-                     unsigned int &argIndex, bool prepend, bool system)
+bool cmTargetPropCommandBase::ProcessContentArgs(
+  std::vector<std::string> const& args, unsigned int& argIndex, bool prepend,
+  bool system)
 {
   const std::string scope = args[argIndex];
 
-  if(scope != "PUBLIC"
-      && scope != "PRIVATE"
-      && scope != "INTERFACE" )
-    {
+  if (scope != "PUBLIC" && scope != "PRIVATE" && scope != "INTERFACE") {
     this->SetError("called with invalid arguments");
     return false;
-    }
+  }
 
-  if(this->Target->IsImported())
-    {
+  if (this->Target->IsImported()) {
     this->HandleImportedTarget(args[0]);
     return false;
-    }
+  }
 
-  if (this->Target->GetType() == cmState::INTERFACE_LIBRARY
-      && scope != "INTERFACE")
-    {
+  if (this->Target->GetType() == cmState::INTERFACE_LIBRARY &&
+      scope != "INTERFACE") {
     this->SetError("may only be set INTERFACE properties on INTERFACE "
-      "targets");
+                   "targets");
     return false;
-    }
+  }
 
   ++argIndex;
 
   std::vector<std::string> content;
 
-  for(unsigned int i=argIndex; i < args.size(); ++i, ++argIndex)
-    {
-    if(args[i] == "PUBLIC"
-        || args[i] == "PRIVATE"
-        || args[i] == "INTERFACE" )
-      {
+  for (unsigned int i = argIndex; i < args.size(); ++i, ++argIndex) {
+    if (args[i] == "PUBLIC" || args[i] == "PRIVATE" ||
+        args[i] == "INTERFACE") {
       return this->PopulateTargetProperies(scope, content, prepend, system);
-      }
-    content.push_back(args[i]);
     }
+    content.push_back(args[i]);
+  }
   return this->PopulateTargetProperies(scope, content, prepend, system);
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetPropCommandBase
-::PopulateTargetProperies(const std::string &scope,
-                          const std::vector<std::string> &content,
-                          bool prepend, bool system)
+bool cmTargetPropCommandBase::PopulateTargetProperies(
+  const std::string& scope, const std::vector<std::string>& content,
+  bool prepend, bool system)
 {
-  if (scope == "PRIVATE" || scope == "PUBLIC")
-    {
-    if (!this->HandleDirectContent(this->Target, content, prepend, system))
-      {
+  if (scope == "PRIVATE" || scope == "PUBLIC") {
+    if (!this->HandleDirectContent(this->Target, content, prepend, system)) {
       return false;
-      }
     }
-  if (scope == "INTERFACE" || scope == "PUBLIC")
-    {
+  }
+  if (scope == "INTERFACE" || scope == "PUBLIC") {
     this->HandleInterfaceContent(this->Target, content, prepend, system);
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt,
-                                  const std::vector<std::string> &content,
-                                  bool prepend, bool)
+void cmTargetPropCommandBase::HandleInterfaceContent(
+  cmTarget* tgt, const std::vector<std::string>& content, bool prepend, bool)
 {
-  if (prepend)
-    {
+  if (prepend) {
     const std::string propName = std::string("INTERFACE_") + this->Property;
-    const char *propValue = tgt->GetProperty(propName);
-    const std::string totalContent = this->Join(content) + (propValue
-                                              ? std::string(";") + propValue
-                                              : std::string());
+    const char* propValue = tgt->GetProperty(propName);
+    const std::string totalContent = this->Join(content) +
+      (propValue ? std::string(";") + propValue : std::string());
     tgt->SetProperty(propName, totalContent.c_str());
-    }
-  else
-    {
+  } else {
     tgt->AppendProperty("INTERFACE_" + this->Property,
-                          this->Join(content).c_str());
-    }
+                        this->Join(content).c_str());
+  }
 }
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index d42b588..88591dc 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -17,12 +17,11 @@
 
 class cmTarget;
 
-//----------------------------------------------------------------------------
 class cmTargetPropCommandBase : public cmCommand
 {
 public:
-
-  enum ArgumentFlags {
+  enum ArgumentFlags
+  {
     NO_FLAGS = 0,
     PROCESS_BEFORE = 1,
     PROCESS_SYSTEM = 2
@@ -33,27 +32,29 @@ public:
                        ArgumentFlags flags = NO_FLAGS);
 
   cmTypeMacro(cmTargetPropCommandBase, cmCommand);
+
 protected:
   std::string Property;
-  cmTarget *Target;
+  cmTarget* Target;
+
+  virtual void HandleInterfaceContent(cmTarget* tgt,
+                                      const std::vector<std::string>& content,
+                                      bool prepend, bool system);
 
-  virtual void HandleInterfaceContent(cmTarget *tgt,
-                                   const std::vector<std::string> &content,
-                                   bool prepend, bool system);
 private:
-  virtual void HandleImportedTarget(const std::string &tgt) = 0;
-  virtual void HandleMissingTarget(const std::string &name) = 0;
+  virtual void HandleImportedTarget(const std::string& tgt) = 0;
+  virtual void HandleMissingTarget(const std::string& name) = 0;
 
-  virtual bool HandleDirectContent(cmTarget *tgt,
-                                   const std::vector<std::string> &content,
+  virtual bool HandleDirectContent(cmTarget* tgt,
+                                   const std::vector<std::string>& content,
                                    bool prepend, bool system) = 0;
 
-  virtual std::string Join(const std::vector<std::string> &content) = 0;
+  virtual std::string Join(const std::vector<std::string>& content) = 0;
 
   bool ProcessContentArgs(std::vector<std::string> const& args,
-                          unsigned int &argIndex, bool prepend, bool system);
-  bool PopulateTargetProperies(const std::string &scope,
-                               const std::vector<std::string> &content,
+                          unsigned int& argIndex, bool prepend, bool system);
+  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
index 0a44d6f..64372dc 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -13,44 +13,36 @@
 
 #include "cmGeneratorExpression.h"
 
-//----------------------------------------------------------------------------
-bool cmTargetSourcesCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmTargetSourcesCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
   return this->HandleArguments(args, "SOURCES");
 }
 
-//----------------------------------------------------------------------------
-void cmTargetSourcesCommand
-::HandleImportedTarget(const std::string &tgt)
+void cmTargetSourcesCommand::HandleImportedTarget(const std::string& tgt)
 {
   std::ostringstream e;
-  e << "Cannot specify sources for imported target \""
-    << tgt << "\".";
+  e << "Cannot specify sources for imported target \"" << tgt << "\".";
   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
 
-//----------------------------------------------------------------------------
-void cmTargetSourcesCommand
-::HandleMissingTarget(const std::string &name)
+void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name)
 {
   std::ostringstream e;
-  e << "Cannot specify sources for target \"" << name << "\" "
+  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 cmTargetSourcesCommand::Join(
+  const std::vector<std::string>& content)
 {
   return cmJoin(content, ";");
 }
 
-//----------------------------------------------------------------------------
-bool cmTargetSourcesCommand
-::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
-                      bool, bool)
+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
index a170e36..304e176 100644
--- a/Source/cmTargetSourcesCommand.h
+++ b/Source/cmTargetSourcesCommand.h
@@ -15,41 +15,37 @@
 
 #include "cmTargetPropCommandBase.h"
 
-//----------------------------------------------------------------------------
 class cmTargetSourcesCommand : public cmTargetPropCommandBase
 {
 public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTargetSourcesCommand;
-    }
+  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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "target_sources";}
+  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 void HandleImportedTarget(const std::string& tgt);
+  virtual void HandleMissingTarget(const std::string& name);
 
-  virtual bool HandleDirectContent(cmTarget *tgt,
-                                   const std::vector<std::string> &content,
+  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);
+  virtual std::string Join(const std::vector<std::string>& content);
 };
 
 #endif
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 6fcd0dc..0658e95 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -10,12 +10,12 @@
   See the License for more information.
 ============================================================================*/
 #include "cmTest.h"
+
 #include "cmSystemTools.h"
 
-#include "cmake.h"
 #include "cmMakefile.h"
+#include "cmake.h"
 
-//----------------------------------------------------------------------------
 cmTest::cmTest(cmMakefile* mf)
   : Backtrace(mf->GetBacktrace())
 {
@@ -23,60 +23,50 @@ cmTest::cmTest(cmMakefile* mf)
   this->OldStyle = true;
 }
 
-//----------------------------------------------------------------------------
 cmTest::~cmTest()
 {
 }
 
-//----------------------------------------------------------------------------
 cmListFileBacktrace const& cmTest::GetBacktrace() const
 {
   return this->Backtrace;
 }
 
-//----------------------------------------------------------------------------
 void cmTest::SetName(const std::string& name)
 {
   this->Name = name;
 }
 
-//----------------------------------------------------------------------------
 void cmTest::SetCommand(std::vector<std::string> const& command)
 {
   this->Command = command;
 }
 
-//----------------------------------------------------------------------------
-const char *cmTest::GetProperty(const std::string& prop) const
+const char* cmTest::GetProperty(const std::string& prop) const
 {
-  const char *retVal = this->Properties.GetPropertyValue(prop);
-  if (!retVal)
-    {
-    const bool chain = this->Makefile->GetState()->
-          IsPropertyChained(prop, cmProperty::TEST);
-    if (chain)
-      {
+  const char* retVal = this->Properties.GetPropertyValue(prop);
+  if (!retVal) {
+    const bool chain =
+      this->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TEST);
+    if (chain) {
       return this->Makefile->GetProperty(prop, chain);
-      }
     }
+  }
   return retVal;
 }
 
-//----------------------------------------------------------------------------
 bool cmTest::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
-//----------------------------------------------------------------------------
 void cmTest::SetProperty(const std::string& prop, const char* value)
 {
   this->Properties.SetProperty(prop, value);
 }
 
-//----------------------------------------------------------------------------
-void cmTest::AppendProperty(const std::string& prop,
-                            const char* value, bool asString)
+void cmTest::AppendProperty(const std::string& prop, const char* value,
+                            bool asString)
 {
   this->Properties.AppendProperty(prop, value, asString);
 }
diff --git a/Source/cmTest.h b/Source/cmTest.h
index ca88afe..db68008 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -12,9 +12,11 @@
 #ifndef cmTest_h
 #define cmTest_h
 
+#include "cmStandardIncludes.h"
+
 #include "cmCustomCommand.h"
-#include "cmPropertyMap.h"
 #include "cmListFileCache.h"
+#include "cmPropertyMap.h"
 class cmMakefile;
 
 /** \class cmTest
@@ -35,21 +37,18 @@ public:
   std::string GetName() const { return this->Name; }
 
   void SetCommand(std::vector<std::string> const& command);
-  std::vector<std::string> const& GetCommand() const
-    {
-    return this->Command;
-    }
+  std::vector<std::string> const& GetCommand() const { return this->Command; }
 
   ///! Set/Get a property of this source file
-  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;
+  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; }
+  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;
@@ -70,4 +69,3 @@ private:
 };
 
 #endif
-
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index b411f15..e599825 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -12,26 +12,22 @@
 #include "cmTestGenerator.h"
 
 #include "cmGeneratorExpression.h"
-#include "cmOutputConverter.h"
 #include "cmLocalGenerator.h"
+#include "cmOutputConverter.h"
 #include "cmSystemTools.h"
 #include "cmTest.h"
 
-//----------------------------------------------------------------------------
-cmTestGenerator
-::cmTestGenerator(cmTest* test,
-                  std::vector<std::string> const& configurations):
-  cmScriptGenerator("CTEST_CONFIGURATION_TYPE", configurations),
-  Test(test)
+cmTestGenerator::cmTestGenerator(
+  cmTest* test, std::vector<std::string> const& configurations)
+  : cmScriptGenerator("CTEST_CONFIGURATION_TYPE", configurations)
+  , Test(test)
 {
   this->ActionsPerConfig = !test->GetOldStyle();
   this->TestGenerated = false;
   this->LG = 0;
 }
 
-//----------------------------------------------------------------------------
-cmTestGenerator
-::~cmTestGenerator()
+cmTestGenerator::~cmTestGenerator()
 {
 }
 
@@ -40,7 +36,6 @@ void cmTestGenerator::Compute(cmLocalGenerator* lg)
   this->LG = lg;
 }
 
-//----------------------------------------------------------------------------
 void cmTestGenerator::GenerateScriptConfigs(std::ostream& os,
                                             Indent const& indent)
 {
@@ -48,26 +43,21 @@ void cmTestGenerator::GenerateScriptConfigs(std::ostream& os,
   this->cmScriptGenerator::GenerateScriptConfigs(os, indent);
 }
 
-//----------------------------------------------------------------------------
 void cmTestGenerator::GenerateScriptActions(std::ostream& os,
                                             Indent const& indent)
 {
-  if(this->ActionsPerConfig)
-    {
+  if (this->ActionsPerConfig) {
     // This is the per-config generation in a single-configuration
     // build generator case.  The superclass will call our per-config
     // method.
     this->cmScriptGenerator::GenerateScriptActions(os, indent);
-    }
-  else
-    {
+  } else {
     // This is an old-style test, so there is only one config.
-    //assert(this->Test->GetOldStyle());
+    // assert(this->Test->GetOldStyle());
     this->GenerateOldStyle(os, indent);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
                                               const std::string& config,
                                               Indent const& indent)
@@ -86,87 +76,70 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
   // Check whether the command executable is a target whose name is to
   // be translated.
   std::string exe = command[0];
-  cmGeneratorTarget* target =
-      this->LG->FindGeneratorTargetToUse(exe);
-  if(target && target->GetType() == cmState::EXECUTABLE)
-    {
+  cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(exe);
+  if (target && target->GetType() == cmState::EXECUTABLE) {
     // Use the target file on disk.
     exe = target->GetFullPath(config);
 
     // Prepend with the emulator when cross compiling if required.
-    const char * emulator =
-      target->GetProperty("CROSSCOMPILING_EMULATOR");
-    if (emulator != 0)
-      {
+    const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
+    if (emulator != 0) {
       std::vector<std::string> emulatorWithArgs;
       cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
       std::string emulatorExe(emulatorWithArgs[0]);
       cmSystemTools::ConvertToUnixSlashes(emulatorExe);
       os << cmOutputConverter::EscapeForCMake(emulatorExe) << " ";
-      for(std::vector<std::string>::const_iterator ei =
-          emulatorWithArgs.begin()+1;
-          ei != emulatorWithArgs.end();
-          ++ei)
-        {
+      for (std::vector<std::string>::const_iterator ei =
+             emulatorWithArgs.begin() + 1;
+           ei != emulatorWithArgs.end(); ++ei) {
         os << cmOutputConverter::EscapeForCMake(*ei) << " ";
-        }
       }
     }
-  else
-    {
+  } else {
     // Use the command name given.
     exe = ge.Parse(exe.c_str())->Evaluate(this->LG, config);
     cmSystemTools::ConvertToUnixSlashes(exe);
-    }
+  }
 
   // Generate the command line with full escapes.
   os << cmOutputConverter::EscapeForCMake(exe);
-  for(std::vector<std::string>::const_iterator ci = command.begin()+1;
-      ci != command.end(); ++ci)
-    {
+  for (std::vector<std::string>::const_iterator ci = command.begin() + 1;
+       ci != command.end(); ++ci) {
     os << " " << cmOutputConverter::EscapeForCMake(
-                                         ge.Parse(*ci)->Evaluate(
-                                            this->LG, config));
-    }
+                   ge.Parse(*ci)->Evaluate(this->LG, config));
+  }
 
   // Finish the test command.
   os << ")\n";
 
   // Output properties for the test.
   cmPropertyMap& pm = this->Test->GetProperties();
-  if(!pm.empty())
-    {
+  if (!pm.empty()) {
     os << indent << "set_tests_properties(" << this->Test->GetName()
        << " PROPERTIES ";
-    for(cmPropertyMap::const_iterator i = pm.begin();
-        i != pm.end(); ++i)
-      {
-      os << " " << i->first
-         << " " << cmOutputConverter::EscapeForCMake(
-           ge.Parse(i->second.GetValue())->Evaluate(this->LG,
-                                                    config));
-      }
-    os << ")" << std::endl;
+    for (cmPropertyMap::const_iterator i = pm.begin(); i != pm.end(); ++i) {
+      os << " " << i->first << " "
+         << cmOutputConverter::EscapeForCMake(
+              ge.Parse(i->second.GetValue())->Evaluate(this->LG, config));
     }
+    os << ")" << std::endl;
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os,
                                              Indent const& indent)
 {
   os << indent << "add_test(" << this->Test->GetName() << " NOT_AVAILABLE)\n";
 }
 
-//----------------------------------------------------------------------------
 bool cmTestGenerator::NeedsScriptNoConfig() const
 {
-  return (this->TestGenerated && // test generated for at least one config
+  return (this->TestGenerated &&    // test generated for at least one config
           this->ActionsPerConfig && // test is config-aware
-          this->Configurations.empty() && // test runs in all configs
+          this->Configurations.empty() &&      // test runs in all configs
           !this->ConfigurationTypes->empty()); // config-dependent command
 }
 
-//----------------------------------------------------------------------------
 void cmTestGenerator::GenerateOldStyle(std::ostream& fout,
                                        Indent const& indent)
 {
@@ -181,40 +154,34 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout,
   fout << "add_test(";
   fout << this->Test->GetName() << " \"" << exe << "\"";
 
-  for(std::vector<std::string>::const_iterator argit = command.begin()+1;
-      argit != command.end(); ++argit)
-    {
+  for (std::vector<std::string>::const_iterator argit = command.begin() + 1;
+       argit != command.end(); ++argit) {
     // Just double-quote all arguments so they are re-parsed
     // correctly by the test system.
     fout << " \"";
-    for(std::string::const_iterator c = argit->begin();
-        c != argit->end(); ++c)
-      {
+    for (std::string::const_iterator c = argit->begin(); c != argit->end();
+         ++c) {
       // Escape quotes within arguments.  We should escape
       // backslashes too but we cannot because it makes the result
       // inconsistent with previous behavior of this command.
-      if((*c == '"'))
-        {
+      if ((*c == '"')) {
         fout << '\\';
-        }
-      fout << *c;
       }
-    fout << "\"";
+      fout << *c;
     }
+    fout << "\"";
+  }
   fout << ")" << std::endl;
 
   // Output properties for the test.
   cmPropertyMap& pm = this->Test->GetProperties();
-  if(!pm.empty())
-    {
+  if (!pm.empty()) {
     fout << indent << "set_tests_properties(" << this->Test->GetName()
          << " PROPERTIES ";
-    for(cmPropertyMap::const_iterator i = pm.begin();
-        i != pm.end(); ++i)
-      {
-      fout << " " << i->first
-           << " " << cmOutputConverter::EscapeForCMake(i->second.GetValue());
-      }
-    fout << ")" << std::endl;
+    for (cmPropertyMap::const_iterator i = pm.begin(); i != pm.end(); ++i) {
+      fout << " " << i->first << " "
+           << cmOutputConverter::EscapeForCMake(i->second.GetValue());
     }
+    fout << ")" << std::endl;
+  }
 }
diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h
index de8ab78..f946a1c 100644
--- a/Source/cmTestGenerator.h
+++ b/Source/cmTestGenerator.h
@@ -21,12 +21,12 @@ class cmLocalGenerator;
  * \brief Support class for generating install scripts.
  *
  */
-class cmTestGenerator: public cmScriptGenerator
+class cmTestGenerator : public cmScriptGenerator
 {
 public:
   cmTestGenerator(cmTest* test,
-                  std::vector<std::string> const&
-                  configurations = std::vector<std::string>());
+                  std::vector<std::string> const& configurations =
+                    std::vector<std::string>());
   virtual ~cmTestGenerator();
 
   void Compute(cmLocalGenerator* lg);
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 6fd6ab7..c624d0f 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -11,100 +11,119 @@
 ============================================================================*/
 #include "cmTimestamp.h"
 
+#include <cstdlib>
 #include <cstring>
+#include <sstream>
 
 #include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h>
 
-//----------------------------------------------------------------------------
-std::string cmTimestamp::CurrentTime(
-  const std::string& formatString, bool utcFlag)
+std::string cmTimestamp::CurrentTime(const std::string& formatString,
+                                     bool utcFlag)
 {
   time_t currentTimeT = time(0);
-  if(currentTimeT == time_t(-1))
-    {
+  if (currentTimeT == time_t(-1)) {
     return std::string();
-    }
+  }
 
   return CreateTimestampFromTimeT(currentTimeT, formatString, utcFlag);
 }
 
-//----------------------------------------------------------------------------
 std::string cmTimestamp::FileModificationTime(const char* path,
-  const std::string& formatString, bool utcFlag)
+                                              const std::string& formatString,
+                                              bool utcFlag)
 {
-  if(!cmsys::SystemTools::FileExists(path))
-    {
+  if (!cmsys::SystemTools::FileExists(path)) {
     return std::string();
-    }
+  }
 
   time_t mtime = cmsys::SystemTools::ModifiedTime(path);
   return CreateTimestampFromTimeT(mtime, formatString, utcFlag);
 }
 
-//----------------------------------------------------------------------------
 std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT,
-    std::string formatString, bool utcFlag)
+                                                  std::string formatString,
+                                                  bool utcFlag) const
 {
-  if(formatString.empty())
-    {
+  if (formatString.empty()) {
     formatString = "%Y-%m-%dT%H:%M:%S";
-    if(utcFlag)
-      {
+    if (utcFlag) {
       formatString += "Z";
-      }
     }
+  }
 
   struct tm timeStruct;
   memset(&timeStruct, 0, sizeof(timeStruct));
 
-  struct tm* ptr = (struct tm*) 0;
-  if(utcFlag)
-    {
+  struct tm* ptr = (struct tm*)0;
+  if (utcFlag) {
     ptr = gmtime(&timeT);
-    }
-  else
-    {
+  } else {
     ptr = localtime(&timeT);
-    }
+  }
 
-  if(ptr == 0)
-    {
+  if (ptr == 0) {
     return std::string();
-    }
+  }
 
   timeStruct = *ptr;
 
   std::string result;
-  for(std::string::size_type i = 0; i < formatString.size(); ++i)
-    {
+  for (std::string::size_type i = 0; i < formatString.size(); ++i) {
     char c1 = formatString[i];
-    char c2 = (i+1 < formatString.size()) ?
-      formatString[i+1] : static_cast<char>(0);
+    char c2 = (i + 1 < formatString.size()) ? formatString[i + 1]
+                                            : static_cast<char>(0);
 
-    if(c1 == '%' && c2 != 0)
-      {
-      result += AddTimestampComponent(c2, timeStruct);
+    if (c1 == '%' && c2 != 0) {
+      result += AddTimestampComponent(c2, timeStruct, timeT);
       ++i;
-      }
-    else
-      {
+    } else {
       result += c1;
-      }
     }
+  }
 
   return result;
 }
 
-//----------------------------------------------------------------------------
-std::string cmTimestamp::AddTimestampComponent(
-  char flag, struct tm& timeStruct)
+time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
+{
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+  return _mkgmtime(&tm);
+#else
+  // From Linux timegm() manpage.
+
+  std::string tz_old = "TZ=";
+  if (const char* tz = cmSystemTools::GetEnv("TZ")) {
+    tz_old += tz;
+  }
+
+  // The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC.
+  // It seems that "TZ=" does NOT work, at least under Windows
+  // with neither MSVC nor MinGW, so let's use explicit "TZ=UTC"
+
+  cmSystemTools::PutEnv("TZ=UTC");
+
+  tzset();
+
+  time_t result = mktime(&tm);
+
+  cmSystemTools::PutEnv(tz_old);
+
+  tzset();
+
+  return result;
+#endif
+}
+
+std::string cmTimestamp::AddTimestampComponent(char flag,
+                                               struct tm& timeStruct,
+                                               const time_t timeT) const
 {
   std::string formatString = "%";
   formatString += flag;
 
-  switch(flag)
-    {
+  switch (flag) {
     case 'd':
     case 'H':
     case 'I':
@@ -117,16 +136,35 @@ std::string cmTimestamp::AddTimestampComponent(
     case 'y':
     case 'Y':
       break;
-    default:
-      {
-      return formatString;
+    case 's': // Seconds since UNIX epoch (midnight 1-jan-1970)
+    {
+      // Build a time_t for UNIX epoch and substract from the input "timeT":
+      struct tm tmUnixEpoch;
+      memset(&tmUnixEpoch, 0, sizeof(tmUnixEpoch));
+      tmUnixEpoch.tm_mday = 1;
+      tmUnixEpoch.tm_year = 1970 - 1900;
+
+      const time_t unixEpoch = this->CreateUtcTimeTFromTm(tmUnixEpoch);
+      if (unixEpoch == -1) {
+        cmSystemTools::Error(
+          "Error generating UNIX epoch in "
+          "STRING(TIMESTAMP ...). Please, file a bug report aginst CMake");
+        return std::string();
       }
+
+      std::stringstream ss;
+      ss << static_cast<long int>(difftime(timeT, unixEpoch));
+      return ss.str();
+    }
+    default: {
+      return formatString;
     }
+  }
 
   char buffer[16];
 
-  size_t size = strftime(buffer, sizeof(buffer),
-    formatString.c_str(), &timeStruct);
+  size_t size =
+    strftime(buffer, sizeof(buffer), formatString.c_str(), &timeStruct);
 
   return std::string(buffer, size);
 }
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index 24c1869..77e1f7a 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -12,11 +12,13 @@
 #ifndef cmTimestamp_h
 #define cmTimestamp_h
 
+#include "cmStandardIncludes.h"
+
 #include <string>
 #include <time.h>
 
 /** \class cmTimestamp
- * \brief Utility class to generate sting representation of a timestamp
+ * \brief Utility class to generate string representation of a timestamp
  *
  */
 class cmTimestamp
@@ -27,14 +29,17 @@ public:
   std::string CurrentTime(const std::string& formatString, bool utcFlag);
 
   std::string FileModificationTime(const char* path,
-    const std::string& formatString, bool utcFlag);
+                                   const std::string& formatString,
+                                   bool utcFlag);
 
 private:
-  std::string CreateTimestampFromTimeT(time_t timeT,
-      std::string formatString, bool utcFlag);
+  time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
 
-  std::string AddTimestampComponent(char flag, struct tm& timeStruct);
-};
+  std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
+                                       bool utcFlag) const;
 
+  std::string AddTimestampComponent(char flag, struct tm& timeStruct,
+                                    time_t timeT) const;
+};
 
 #endif
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index 12ce015..7930d23 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -12,31 +12,28 @@
 #include "cmTryCompileCommand.h"
 
 // cmTryCompileCommand
-bool cmTryCompileCommand
-::InitialPass(std::vector<std::string> const& argv, cmExecutionStatus &)
+bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv,
+                                      cmExecutionStatus&)
 {
-  if(argv.size() < 3)
-    {
+  if (argv.size() < 3) {
     return false;
-    }
+  }
 
-  if(this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
-                                                      cmake::FIND_PACKAGE_MODE)
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
-         "The TRY_COMPILE() command is not supported in --find-package mode.");
+  if (this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
+      cmake::FIND_PACKAGE_MODE) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
+      "The TRY_COMPILE() command is not supported in --find-package mode.");
     return false;
-    }
+  }
 
-  this->TryCompileCode(argv);
+  this->TryCompileCode(argv, false);
 
   // if They specified clean then we clean up what we can
-  if (this->SrcFileSignature)
-    {
-    if(!this->Makefile->GetCMakeInstance()->GetDebugTryCompile())
-      {
+  if (this->SrcFileSignature) {
+    if (!this->Makefile->GetCMakeInstance()->GetDebugTryCompile()) {
       this->CleanupFiles(this->BinaryDirectory.c_str());
-      }
     }
+  }
   return true;
 }
diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h
index a09c47f..e50d54c 100644
--- a/Source/cmTryCompileCommand.h
+++ b/Source/cmTryCompileCommand.h
@@ -25,26 +25,21 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTryCompileCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTryCompileCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "try_compile";}
+  virtual std::string GetName() const { return "try_compile"; }
 
   cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile);
-
 };
 
-
 #endif
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index b9ffe5e..19837a7 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -10,25 +10,25 @@
   See the License for more information.
 ============================================================================*/
 #include "cmTryRunCommand.h"
+
 #include "cmTryCompileCommand.h"
 #include <cmsys/FStream.hxx>
 
 // cmTryRunCommand
-bool cmTryRunCommand
-::InitialPass(std::vector<std::string> const& argv, cmExecutionStatus &)
+bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
+                                  cmExecutionStatus&)
 {
-  if(argv.size() < 4)
-    {
+  if (argv.size() < 4) {
     return false;
-    }
+  }
 
-  if(this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
-                                                      cmake::FIND_PACKAGE_MODE)
-    {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR,
-            "The TRY_RUN() command is not supported in --find-package mode.");
+  if (this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
+      cmake::FIND_PACKAGE_MODE) {
+    this->Makefile->IssueMessage(
+      cmake::FATAL_ERROR,
+      "The TRY_RUN() command is not supported in --find-package mode.");
     return false;
-    }
+  }
 
   // build an arg list for TryCompile and extract the runArgs,
   std::vector<std::string> tryCompile;
@@ -41,153 +41,119 @@ bool cmTryRunCommand
 
   std::string runArgs;
   unsigned int i;
-  for (i = 1; i < argv.size(); ++i)
-    {
-    if (argv[i] == "ARGS")
-      {
+  for (i = 1; i < argv.size(); ++i) {
+    if (argv[i] == "ARGS") {
       ++i;
       while (i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
-             argv[i] != "CMAKE_FLAGS" &&
-             argv[i] != "LINK_LIBRARIES")
-        {
+             argv[i] != "CMAKE_FLAGS" && argv[i] != "LINK_LIBRARIES") {
         runArgs += " ";
         runArgs += argv[i];
         ++i;
-        }
-      if (i < argv.size())
-        {
+      }
+      if (i < argv.size()) {
         tryCompile.push_back(argv[i]);
-        }
       }
-    else
-      {
-      if (argv[i] == "OUTPUT_VARIABLE")
-        {
-        if ( argv.size() <= (i+1) )
-          {
+    } else {
+      if (argv[i] == "OUTPUT_VARIABLE") {
+        if (argv.size() <= (i + 1)) {
           cmSystemTools::Error(
             "OUTPUT_VARIABLE specified but there is no variable");
           return false;
-          }
+        }
         i++;
         this->OutputVariable = argv[i];
-        }
-      else if (argv[i] == "RUN_OUTPUT_VARIABLE")
-        {
-        if (argv.size() <= (i + 1))
-          {
+      } else if (argv[i] == "RUN_OUTPUT_VARIABLE") {
+        if (argv.size() <= (i + 1)) {
           cmSystemTools::Error(
             "RUN_OUTPUT_VARIABLE specified but there is no variable");
           return false;
-          }
+        }
         i++;
         this->RunOutputVariable = argv[i];
-        }
-      else if (argv[i] == "COMPILE_OUTPUT_VARIABLE")
-        {
-        if (argv.size() <= (i + 1))
-          {
+      } else if (argv[i] == "COMPILE_OUTPUT_VARIABLE") {
+        if (argv.size() <= (i + 1)) {
           cmSystemTools::Error(
             "COMPILE_OUTPUT_VARIABLE specified but there is no variable");
           return false;
-          }
+        }
         i++;
         this->CompileOutputVariable = argv[i];
-        }
-      else
-        {
+      } else {
         tryCompile.push_back(argv[i]);
-        }
       }
     }
+  }
 
   // although they could be used together, don't allow it, because
   // using OUTPUT_VARIABLE makes crosscompiling harder
-  if (this->OutputVariable.size()
-      && (!this->RunOutputVariable.empty()
-       || !this->CompileOutputVariable.empty()))
-    {
+  if (this->OutputVariable.size() && (!this->RunOutputVariable.empty() ||
+                                      !this->CompileOutputVariable.empty())) {
     cmSystemTools::Error(
       "You cannot use OUTPUT_VARIABLE together with COMPILE_OUTPUT_VARIABLE "
       "or RUN_OUTPUT_VARIABLE. Please use only COMPILE_OUTPUT_VARIABLE and/or "
       "RUN_OUTPUT_VARIABLE.");
     return false;
-    }
+  }
 
   bool captureRunOutput = false;
-  if (!this->OutputVariable.empty())
-    {
+  if (!this->OutputVariable.empty()) {
     captureRunOutput = true;
     tryCompile.push_back("OUTPUT_VARIABLE");
     tryCompile.push_back(this->OutputVariable);
-    }
-  if (!this->CompileOutputVariable.empty())
-    {
+  }
+  if (!this->CompileOutputVariable.empty()) {
     tryCompile.push_back("OUTPUT_VARIABLE");
     tryCompile.push_back(this->CompileOutputVariable);
-    }
-  if (!this->RunOutputVariable.empty())
-    {
+  }
+  if (!this->RunOutputVariable.empty()) {
     captureRunOutput = true;
-    }
+  }
 
   this->RunResultVariable = argv[0];
   this->CompileResultVariable = argv[1];
 
   // do the try compile
-  int res = this->TryCompileCode(tryCompile);
+  int res = this->TryCompileCode(tryCompile, true);
 
   // now try running the command if it compiled
-  if (!res)
-    {
-    if (this->OutputFile.empty())
-      {
+  if (!res) {
+    if (this->OutputFile.empty()) {
       cmSystemTools::Error(this->FindErrorMessage.c_str());
-      }
-    else
-      {
+    } else {
       // "run" it and capture the output
       std::string runOutputContents;
       if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") &&
-          !this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR"))
-        {
-        this->DoNotRunExecutable(runArgs,
-                                 argv[3],
+          !this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR")) {
+        this->DoNotRunExecutable(runArgs, argv[3],
                                  captureRunOutput ? &runOutputContents : 0);
-        }
-      else
-        {
+      } else {
         this->RunExecutable(runArgs, &runOutputContents);
-        }
+      }
 
       // now put the output into the variables
-      if(!this->RunOutputVariable.empty())
-        {
+      if (!this->RunOutputVariable.empty()) {
         this->Makefile->AddDefinition(this->RunOutputVariable,
                                       runOutputContents.c_str());
-        }
+      }
 
-      if(!this->OutputVariable.empty())
-        {
+      if (!this->OutputVariable.empty()) {
         // if the TryCompileCore saved output in this outputVariable then
         // prepend that output to this output
-        const char* compileOutput
-                 = this->Makefile->GetDefinition(this->OutputVariable);
-        if (compileOutput)
-          {
+        const char* compileOutput =
+          this->Makefile->GetDefinition(this->OutputVariable);
+        if (compileOutput) {
           runOutputContents = std::string(compileOutput) + runOutputContents;
-          }
+        }
         this->Makefile->AddDefinition(this->OutputVariable,
                                       runOutputContents.c_str());
-        }
       }
     }
+  }
 
   // if we created a directory etc, then cleanup after ourselves
-  if(!this->Makefile->GetCMakeInstance()->GetDebugTryCompile())
-    {
+  if (!this->Makefile->GetCMakeInstance()->GetDebugTryCompile()) {
     this->CleanupFiles(this->BinaryDirectory.c_str());
-    }
+  }
   return true;
 }
 
@@ -198,47 +164,40 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
 
   std::string finalCommand;
   const std::string emulator =
-  this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR");
-  if (!emulator.empty())
-    {
+    this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR");
+  if (!emulator.empty()) {
     std::vector<std::string> emulatorWithArgs;
     cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
-    finalCommand += cmSystemTools::ConvertToRunCommandPath(
-                                 emulatorWithArgs[0].c_str());
+    finalCommand +=
+      cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0].c_str());
     finalCommand += " ";
     for (std::vector<std::string>::const_iterator ei =
-         emulatorWithArgs.begin()+1;
-         ei != emulatorWithArgs.end(); ++ei)
-      {
+           emulatorWithArgs.begin() + 1;
+         ei != emulatorWithArgs.end(); ++ei) {
       finalCommand += "\"";
       finalCommand += *ei;
       finalCommand += "\"";
       finalCommand += " ";
-      }
     }
-  finalCommand += cmSystemTools::ConvertToRunCommandPath(
-                               this->OutputFile.c_str());
-  if (!runArgs.empty())
-    {
+  }
+  finalCommand +=
+    cmSystemTools::ConvertToRunCommandPath(this->OutputFile.c_str());
+  if (!runArgs.empty()) {
     finalCommand += runArgs;
-    }
+  }
   int timeout = 0;
-  bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(),
-                out, out, &retVal,
-                0, cmSystemTools::OUTPUT_NONE, timeout);
+  bool worked =
+    cmSystemTools::RunSingleCommand(finalCommand.c_str(), out, out, &retVal, 0,
+                                    cmSystemTools::OUTPUT_NONE, timeout);
   // set the run var
   char retChar[1000];
-  if (worked)
-    {
+  if (worked) {
     sprintf(retChar, "%i", retVal);
-    }
-  else
-    {
+  } else {
     strcpy(retChar, "FAILED_TO_RUN");
-    }
+  }
   this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar,
-                                     "Result of TRY_RUN",
-                                     cmState::INTERNAL);
+                                     "Result of TRY_RUN", cmState::INTERNAL);
 }
 
 /* This is only used when cross compiling. Instead of running the
@@ -246,34 +205,32 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
  the executable would have produced.
 */
 void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
-                                    const std::string& srcFile,
-                                    std::string* out
-                                    )
+                                         const std::string& srcFile,
+                                         std::string* out)
 {
   // copy the executable out of the CMakeFiles/ directory, so it is not
   // removed at the end of TRY_RUN and the user can run it manually
   // on the target platform.
-  std::string copyDest =  this->Makefile->GetHomeOutputDirectory();
+  std::string copyDest = this->Makefile->GetHomeOutputDirectory();
   copyDest += cmake::GetCMakeFilesDirectory();
   copyDest += "/";
-  copyDest += cmSystemTools::GetFilenameWithoutExtension(
-                                                     this->OutputFile);
+  copyDest += cmSystemTools::GetFilenameWithoutExtension(this->OutputFile);
   copyDest += "-";
   copyDest += this->RunResultVariable;
   copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile);
   cmSystemTools::CopyFileAlways(this->OutputFile, copyDest);
 
-  std::string resultFileName =  this->Makefile->GetHomeOutputDirectory();
+  std::string resultFileName = this->Makefile->GetHomeOutputDirectory();
   resultFileName += "/TryRunResults.cmake";
 
   std::string detailsString = "For details see ";
   detailsString += resultFileName;
 
-  std::string internalRunOutputName=this->RunResultVariable+"__TRYRUN_OUTPUT";
+  std::string internalRunOutputName =
+    this->RunResultVariable + "__TRYRUN_OUTPUT";
   bool error = false;
 
-  if (this->Makefile->GetDefinition(this->RunResultVariable) == 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
     std::string comment;
@@ -282,58 +239,49 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
     comment += detailsString;
     this->Makefile->AddCacheDefinition(this->RunResultVariable,
                                        "PLEASE_FILL_OUT-FAILED_TO_RUN",
-                                       comment.c_str(),
-                                       cmState::STRING);
+                                       comment.c_str(), cmState::STRING);
 
     cmState* state = this->Makefile->GetState();
-    const char* existingValue
-                        = state->GetCacheEntryValue(this->RunResultVariable);
-    if (existingValue)
-      {
+    const char* existingValue =
+      state->GetCacheEntryValue(this->RunResultVariable);
+    if (existingValue) {
       state->SetCacheEntryProperty(this->RunResultVariable, "ADVANCED", "1");
-      }
+    }
 
     error = true;
-    }
+  }
 
   // is the output from the executable used ?
-  if (out!=0)
-    {
-    if (this->Makefile->GetDefinition(internalRunOutputName) == 0)
-      {
+  if (out != 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
       std::string comment;
-      comment+="Output of TRY_RUN(), contains the text, which the executable "
-           "would have printed on stdout and stderr on its target platform.\n";
+      comment +=
+        "Output of TRY_RUN(), contains the text, which the executable "
+        "would have printed on stdout and stderr on its target platform.\n";
       comment += detailsString;
 
       this->Makefile->AddCacheDefinition(internalRunOutputName,
                                          "PLEASE_FILL_OUT-NOTFOUND",
-                                         comment.c_str(),
-                                         cmState::STRING);
+                                         comment.c_str(), cmState::STRING);
       cmState* state = this->Makefile->GetState();
-      const char* existing =
-          state->GetCacheEntryValue(internalRunOutputName);
-      if (existing)
-        {
-        state->SetCacheEntryProperty(internalRunOutputName,
-                                      "ADVANCED", "1");
-        }
+      const char* existing = state->GetCacheEntryValue(internalRunOutputName);
+      if (existing) {
+        state->SetCacheEntryProperty(internalRunOutputName, "ADVANCED", "1");
+      }
 
       error = true;
-      }
     }
+  }
 
-  if (error)
-    {
+  if (error) {
     static bool firstTryRun = true;
     cmsys::ofstream file(resultFileName.c_str(),
-                                  firstTryRun ? std::ios::out : std::ios::app);
-    if ( file )
-      {
-      if (firstTryRun)
-        {
+                         firstTryRun ? std::ios::out : std::ios::app);
+    if (file) {
+      if (firstTryRun) {
+        /* clang-format off */
         file << "# This file was generated by CMake because it detected "
                 "TRY_RUN() commands\n"
                 "# in crosscompiling mode. It will be overwritten by the next "
@@ -341,9 +289,10 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
                 "# Copy it to a safe location, set the variables to "
                 "appropriate values\n"
                 "# and use it then to preset the CMake cache (using -C).\n\n";
-        }
+        /* clang-format on */
+      }
 
-      std::string comment ="\n";
+      std::string comment = "\n";
       comment += this->RunResultVariable;
       comment += "\n   indicates whether the executable would have been able "
                  "to run on its\n"
@@ -352,19 +301,19 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
       comment += " to\n"
                  "   the exit code (in many cases 0 for success), otherwise "
                  "enter \"FAILED_TO_RUN\".\n";
-      if (out!=0)
-        {
+      if (out != 0) {
         comment += internalRunOutputName;
-        comment += "\n   contains the text the executable "
-                   "would have printed on stdout and stderr.\n"
-                  "   If the executable would not have been able to run, set ";
+        comment +=
+          "\n   contains the text the executable "
+          "would have printed on stdout and stderr.\n"
+          "   If the executable would not have been able to run, set ";
         comment += internalRunOutputName;
         comment += " empty.\n"
                    "   Otherwise check if the output is evaluated by the "
                    "calling CMake code. If so,\n"
                    "   check what the source file would have printed when "
                    "called with the given arguments.\n";
-        }
+      }
       comment += "The ";
       comment += this->CompileResultVariable;
       comment += " variable holds the build result for this TRY_RUN().\n\n"
@@ -383,31 +332,28 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
            << this->Makefile->GetDefinition(this->RunResultVariable)
            << "\"\n     CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n";
 
-      if (out!=0)
-        {
+      if (out != 0) {
         file << "set( " << internalRunOutputName << " \n     \""
              << this->Makefile->GetDefinition(internalRunOutputName)
              << "\"\n     CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n";
-        }
-      file.close();
       }
+      file.close();
+    }
     firstTryRun = false;
 
     std::string errorMessage = "TRY_RUN() invoked in cross-compiling mode, "
                                "please set the following cache variables "
                                "appropriately:\n";
     errorMessage += "   " + this->RunResultVariable + " (advanced)\n";
-    if (out!=0)
-      {
+    if (out != 0) {
       errorMessage += "   " + internalRunOutputName + " (advanced)\n";
-      }
+    }
     errorMessage += detailsString;
     cmSystemTools::Error(errorMessage.c_str());
     return;
-    }
+  }
 
-  if (out!=0)
-    {
+  if (out != 0) {
     (*out) = this->Makefile->GetDefinition(internalRunOutputName);
-    }
+  }
 }
diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h
index 9b97b16..26c0777 100644
--- a/Source/cmTryRunCommand.h
+++ b/Source/cmTryRunCommand.h
@@ -25,24 +25,22 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmTryRunCommand;
-    }
+  virtual cmCommand* Clone() { return new cmTryRunCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "try_run";}
+  virtual std::string GetName() const { return "try_run"; }
 
   cmTypeMacro(cmTryRunCommand, cmCoreTryCompile);
+
 private:
   void RunExecutable(const std::string& runArgs,
                      std::string* runOutputContents);
@@ -57,5 +55,4 @@ private:
   std::string CompileOutputVariable;
 };
 
-
 #endif
diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx
index 053cdfc..c04c44a 100644
--- a/Source/cmUnsetCommand.cxx
+++ b/Source/cmUnsetCommand.cxx
@@ -13,53 +13,46 @@
 
 // cmUnsetCommand
 bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
-                                 cmExecutionStatus &)
+                                 cmExecutionStatus&)
 {
-  if(args.size() < 1 || args.size() > 2)
-    {
+  if (args.size() < 1 || args.size() > 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   const char* variable = args[0].c_str();
 
   // unset(ENV{VAR})
-  if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5)
-    {
+  if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) {
     // what is the variable name
-    char *envVarName = new char [strlen(variable)];
-    strncpy(envVarName,variable+4,strlen(variable)-5);
-    envVarName[strlen(variable)-5] = '\0';
+    char* envVarName = new char[strlen(variable)];
+    strncpy(envVarName, variable + 4, strlen(variable) - 5);
+    envVarName[strlen(variable) - 5] = '\0';
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
     cmSystemTools::UnsetEnv(envVarName);
 #endif
     delete[] envVarName;
     return true;
-    }
+  }
   // unset(VAR)
-  else if (args.size() == 1)
-    {
+  else if (args.size() == 1) {
     this->Makefile->RemoveDefinition(variable);
     return true;
-    }
+  }
   // unset(VAR CACHE)
-  else if ((args.size() == 2) && (args[1] == "CACHE"))
-    {
+  else if ((args.size() == 2) && (args[1] == "CACHE")) {
     this->Makefile->RemoveCacheDefinition(variable);
     return true;
-    }
+  }
   // unset(VAR PARENT_SCOPE)
-  else if ((args.size() == 2) && (args[1] == "PARENT_SCOPE"))
-    {
+  else if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) {
     this->Makefile->RaiseScope(variable, 0);
     return true;
-    }
+  }
   // ERROR: second argument isn't CACHE or PARENT_SCOPE
-  else
-    {
+  else {
     this->SetError("called with an invalid second argument");
     return false;
-    }
+  }
 }
-
diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h
index 62c2bd3..faa8f9b 100644
--- a/Source/cmUnsetCommand.h
+++ b/Source/cmUnsetCommand.h
@@ -25,17 +25,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmUnsetCommand;
-    }
+  virtual cmCommand* Clone() { return new cmUnsetCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -45,11 +42,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const {return "unset";}
+  virtual std::string GetName() const { return "unset"; }
 
   cmTypeMacro(cmUnsetCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 2ee664f..1eb493a 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -10,62 +10,59 @@
   See the License for more information.
 ============================================================================*/
 #include "cmUseMangledMesaCommand.h"
+
 #include "cmSystemTools.h"
 
-#include <cmsys/RegularExpression.hxx>
 #include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
 
-bool cmUseMangledMesaCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
+                                          cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0030,
-      "The use_mangled_mesa command should not be called; see CMP0030."))
-    { return true; }
+  if (this->Disallowed(
+        cmPolicies::CMP0030,
+        "The use_mangled_mesa command should not be called; see CMP0030.")) {
+    return true;
+  }
   // expected two arguments:
   // arguement one: the full path to gl_mangle.h
   // arguement two : directory for output of edited headers
-  if(args.size() != 2)
-    {
+  if (args.size() != 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   const char* inputDir = args[0].c_str();
   std::string glh = inputDir;
   glh += "/";
   glh += "gl.h";
-  if(!cmSystemTools::FileExists(glh.c_str()))
-    {
+  if (!cmSystemTools::FileExists(glh.c_str())) {
     std::string e = "Bad path to Mesa, could not find: ";
     e += glh;
     e += " ";
     this->SetError(e);
     return false;
-    }
+  }
   const char* destDir = args[1].c_str();
   std::vector<std::string> files;
   cmSystemTools::Glob(inputDir, "\\.h$", files);
-  if(files.empty())
-    {
+  if (files.empty()) {
     cmSystemTools::Error("Could not open Mesa Directory ", inputDir);
     return false;
-    }
+  }
   cmSystemTools::MakeDirectory(destDir);
-  for(std::vector<std::string>::iterator i = files.begin();
-      i != files.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = files.begin(); i != files.end();
+       ++i) {
     std::string path = inputDir;
     path += "/";
     path += *i;
     this->CopyAndFullPathMesaHeader(path.c_str(), destDir);
-    }
+  }
 
   return true;
 }
 
-void
-cmUseMangledMesaCommand::
-CopyAndFullPathMesaHeader(const char* source,
-                          const char* outdir)
+void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
+                                                        const char* outdir)
 {
   std::string dir, file;
   cmSystemTools::SplitProgramPath(source, dir, file);
@@ -75,20 +72,18 @@ CopyAndFullPathMesaHeader(const char* source,
   std::string tempOutputFile = outFile;
   tempOutputFile += ".tmp";
   cmsys::ofstream fout(tempOutputFile.c_str());
-  if(!fout)
-    {
+  if (!fout) {
     cmSystemTools::Error("Could not open file for write in copy operation: ",
                          tempOutputFile.c_str(), outdir);
     cmSystemTools::ReportLastSystemError("");
     return;
-    }
+  }
   cmsys::ifstream fin(source);
-  if(!fin)
-    {
+  if (!fin) {
     cmSystemTools::Error("Could not open file for read in copy operation",
                          source);
     return;
-    }
+  }
   // now copy input to output and expand variables in the
   // input file at the same time
   std::string inLine;
@@ -99,36 +94,25 @@ CopyAndFullPathMesaHeader(const char* source,
   cmsys::RegularExpression glDirLine("(gl|GL)(/|\\\\)([^<\"]+)");
   // regular expression for gl GL or xmesa in a file (match(1) of above)
   cmsys::RegularExpression glLine("(gl|GL|xmesa)");
-  while(cmSystemTools::GetLineFromStream(fin,inLine))
-    {
-    if(includeLine.find(inLine.c_str()))
-      {
+  while (cmSystemTools::GetLineFromStream(fin, inLine)) {
+    if (includeLine.find(inLine.c_str())) {
       std::string includeFile = includeLine.match(1);
-      if(glDirLine.find(includeFile.c_str()))
-        {
+      if (glDirLine.find(includeFile.c_str())) {
         std::string gfile = glDirLine.match(3);
         fout << "#include \"" << outdir << "/" << gfile << "\"\n";
-        }
-      else if(glLine.find(includeFile.c_str()))
-        {
-        fout << "#include \"" << outdir << "/" <<
-          includeLine.match(1) << "\"\n";
-        }
-      else
-        {
+      } else if (glLine.find(includeFile.c_str())) {
+        fout << "#include \"" << outdir << "/" << includeLine.match(1)
+             << "\"\n";
+      } else {
         fout << inLine << "\n";
-        }
       }
-    else
-      {
+    } else {
       fout << inLine << "\n";
-      }
     }
+  }
   // close the files before attempting to copy
   fin.close();
   fout.close();
-  cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
-                                     outFile.c_str());
+  cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str());
   cmSystemTools::RemoveFile(tempOutputFile.c_str());
 }
-
diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h
index 1af2bfe..5a97a61 100644
--- a/Source/cmUseMangledMesaCommand.h
+++ b/Source/cmUseMangledMesaCommand.h
@@ -20,12 +20,11 @@ public:
   cmTypeMacro(cmUseMangledMesaCommand, cmCommand);
   virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const { return "use_mangled_mesa";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "use_mangled_mesa"; }
   virtual bool IsScriptable() const { return true; }
 protected:
-  void CopyAndFullPathMesaHeader(const char* source,
-                                 const char* outdir);
+  void CopyAndFullPathMesaHeader(const char* source, const char* outdir);
 };
 
 #endif
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 3f1e333..f7d766e 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -12,24 +12,24 @@
 #include "cmUtilitySourceCommand.h"
 
 // cmUtilitySourceCommand
-bool cmUtilitySourceCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0034,
-      "The utility_source command should not be called; see CMP0034."))
-    { return true; }
-  if(args.size() < 3)
-    {
+  if (this->Disallowed(
+        cmPolicies::CMP0034,
+        "The utility_source command should not be called; see CMP0034.")) {
+    return true;
+  }
+  if (args.size() < 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::vector<std::string>::const_iterator arg = args.begin();
 
   // The first argument is the cache entry name.
   std::string cacheEntry = *arg++;
-  const char* cacheValue =
-    this->Makefile->GetDefinition(cacheEntry);
+  const char* cacheValue = 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.
@@ -37,34 +37,28 @@ bool cmUtilitySourceCommand
     this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
 
   bool haveCacheValue = false;
-  if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))
-    {
+  if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
     haveCacheValue = (cacheValue != 0);
-    if (!haveCacheValue)
-      {
+    if (!haveCacheValue) {
       std::string msg = "UTILITY_SOURCE is used in cross compiling mode for ";
       msg += cacheEntry;
       msg += ". If your intention is to run this executable, you need to "
-            "preload the cache with the full path to a version of that "
-            "program, which runs on this build machine.";
-      cmSystemTools::Message(msg.c_str() ,"Warning");
-      }
-    }
-  else
-    {
-    cmState *state =
-        this->Makefile->GetState();
-    haveCacheValue = (cacheValue &&
-     (strstr(cacheValue, "(IntDir)") == 0 ||
-      (intDir && strcmp(intDir, "$(IntDir)") == 0)) &&
-     (state->GetCacheMajorVersion() != 0 &&
-      state->GetCacheMinorVersion() != 0 ));
+             "preload the cache with the full path to a version of that "
+             "program, which runs on this build machine.";
+      cmSystemTools::Message(msg.c_str(), "Warning");
     }
-
-  if(haveCacheValue)
-    {
+  } else {
+    cmState* state = this->Makefile->GetState();
+    haveCacheValue =
+      (cacheValue && (strstr(cacheValue, "(IntDir)") == 0 ||
+                      (intDir && strcmp(intDir, "$(IntDir)") == 0)) &&
+       (state->GetCacheMajorVersion() != 0 &&
+        state->GetCacheMinorVersion() != 0));
+  }
+
+  if (haveCacheValue) {
     return true;
-    }
+  }
 
   // The second argument is the utility's executable name, which will be
   // needed later.
@@ -74,59 +68,52 @@ bool cmUtilitySourceCommand
   // of the utility.
   std::string relativeSource = *arg++;
   std::string utilitySource = this->Makefile->GetCurrentSourceDirectory();
-  utilitySource = utilitySource+"/"+relativeSource;
+  utilitySource = utilitySource + "/" + relativeSource;
 
   // If the directory doesn't exist, the source has not been included.
-  if(!cmSystemTools::FileExists(utilitySource.c_str()))
-    { return true; }
+  if (!cmSystemTools::FileExists(utilitySource.c_str())) {
+    return true;
+  }
 
   // Make sure all the files exist in the source directory.
-  while(arg != args.end())
-    {
-    std::string file = utilitySource+"/"+*arg++;
-    if(!cmSystemTools::FileExists(file.c_str()))
-      { return true; }
+  while (arg != args.end()) {
+    std::string file = utilitySource + "/" + *arg++;
+    if (!cmSystemTools::FileExists(file.c_str())) {
+      return true;
     }
+  }
 
   // The source exists.
   std::string cmakeCFGout =
     this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
   std::string utilityDirectory = this->Makefile->GetCurrentBinaryDirectory();
   std::string exePath;
-  if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
-    {
+  if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
     exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
-    }
-  if(!exePath.empty())
-    {
+  }
+  if (!exePath.empty()) {
     utilityDirectory = exePath;
-    }
-  else
-    {
-    utilityDirectory += "/"+relativeSource;
-    }
+  } else {
+    utilityDirectory += "/" + relativeSource;
+  }
 
   // Construct the cache entry for the executable's location.
-  std::string utilityExecutable =
-    utilityDirectory+"/"+cmakeCFGout+"/"
-    +utilityName+this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
+  std::string utilityExecutable = utilityDirectory + "/" + cmakeCFGout + "/" +
+    utilityName + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
 
   // make sure we remove any /./ in the name
   cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
 
   // Enter the value into the cache.
-  this->Makefile->AddCacheDefinition(cacheEntry,
-                                 utilityExecutable.c_str(),
-                                 "Path to an internal program.",
-                                 cmState::FILEPATH);
+  this->Makefile->AddCacheDefinition(cacheEntry, utilityExecutable.c_str(),
+                                     "Path to an internal program.",
+                                     cmState::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,
-                                 utilityName.c_str(),
-                                 "Executable to project name.",
-                                 cmState::INTERNAL);
+  this->Makefile->AddCacheDefinition(utilityExecutable, utilityName.c_str(),
+                                     "Executable to project name.",
+                                     cmState::INTERNAL);
 
   return true;
 }
-
diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h
index 8863ff5..a709de1 100644
--- a/Source/cmUtilitySourceCommand.h
+++ b/Source/cmUtilitySourceCommand.h
@@ -20,8 +20,8 @@ public:
   cmTypeMacro(cmUtilitySourceCommand, cmCommand);
   virtual cmCommand* Clone() { return new cmUtilitySourceCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const { return "utility_source";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "utility_source"; }
 };
 
 #endif
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index e2d0049..6d09bdf 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -13,8 +13,8 @@
 
 #include <string.h>
 
-#include <cmsys/MD5.h>
 #include "cm_sha2.h"
+#include <cmsys/MD5.h>
 
 cmUuid::cmUuid()
 {
@@ -26,16 +26,16 @@ cmUuid::cmUuid()
 }
 
 std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace,
-  std::string const& name) const
+                            std::string const& name) const
 {
   std::vector<unsigned char> hashInput;
   this->CreateHashInput(uuidNamespace, name, hashInput);
 
-  cmsysMD5_s *md5 = cmsysMD5_New();
+  cmsysMD5_s* md5 = cmsysMD5_New();
   cmsysMD5_Initialize(md5);
   cmsysMD5_Append(md5, &hashInput[0], int(hashInput.size()));
 
-  unsigned char digest[16] = {0};
+  unsigned char digest[16] = { 0 };
   cmsysMD5_Finalize(md5, digest);
 
   cmsysMD5_Delete(md5);
@@ -44,16 +44,16 @@ std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace,
 }
 
 std::string cmUuid::FromSha1(std::vector<unsigned char> const& uuidNamespace,
-    std::string const& name) const
+                             std::string const& name) const
 {
   std::vector<unsigned char> hashInput;
   this->CreateHashInput(uuidNamespace, name, hashInput);
 
-  SHA_CTX *sha = new SHA_CTX;
+  SHA_CTX* sha = new SHA_CTX;
   SHA1_Init(sha);
   SHA1_Update(sha, &hashInput[0], hashInput.size());
 
-  unsigned char digest[SHA1_DIGEST_LENGTH] = {0};
+  unsigned char digest[SHA1_DIGEST_LENGTH] = { 0 };
   SHA1_Final(digest, sha);
 
   delete sha;
@@ -62,25 +62,24 @@ std::string cmUuid::FromSha1(std::vector<unsigned char> const& uuidNamespace,
 }
 
 void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace,
-  std::string const& name, std::vector<unsigned char> &output) const
+                             std::string const& name,
+                             std::vector<unsigned char>& output) const
 {
   output = uuidNamespace;
 
-  if(!name.empty())
-    {
+  if (!name.empty()) {
     output.resize(output.size() + name.size());
 
-    memcpy(&output[0] + uuidNamespace.size(),
-      name.c_str(), name.size());
-    }
+    memcpy(&output[0] + uuidNamespace.size(), name.c_str(), name.size());
+  }
 }
 
-std::string cmUuid::FromDigest(
-  const unsigned char* digest, unsigned char version) const
+std::string cmUuid::FromDigest(const unsigned char* digest,
+                               unsigned char version) const
 {
   typedef unsigned char byte_t;
 
-  byte_t uuid[16] = {0};
+  byte_t uuid[16] = { 0 };
   memcpy(uuid, digest, 16);
 
   uuid[6] &= 0xF;
@@ -93,30 +92,26 @@ std::string cmUuid::FromDigest(
 }
 
 bool cmUuid::StringToBinary(std::string const& input,
-  std::vector<unsigned char> &output) const
+                            std::vector<unsigned char>& output) const
 {
   output.clear();
   output.reserve(16);
 
-  if(input.length() != 36)
-    {
+  if (input.length() != 36) {
     return false;
-    }
+  }
   size_t index = 0;
-  for(size_t i = 0; i < this->Groups.size(); ++i)
-    {
-    if(i != 0 && input[index++] != '-')
-      {
+  for (size_t i = 0; i < this->Groups.size(); ++i) {
+    if (i != 0 && input[index++] != '-') {
       return false;
-      }
+    }
     size_t digits = this->Groups[i] * 2;
-    if(!StringToBinaryImpl(input.substr(index, digits), output))
-      {
+    if (!StringToBinaryImpl(input.substr(index, digits), output)) {
       return false;
-      }
+    }
 
     index += digits;
-    }
+  }
 
   return true;
 }
@@ -126,20 +121,17 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const
   std::string output;
 
   size_t inputIndex = 0;
-  for(size_t i = 0; i < this->Groups.size(); ++i)
-    {
-    if(i != 0)
-      {
+  for (size_t i = 0; i < this->Groups.size(); ++i) {
+    if (i != 0) {
       output += '-';
-      }
+    }
 
     size_t bytes = this->Groups[i];
-    for(size_t j = 0; j < bytes; ++j)
-      {
+    for (size_t j = 0; j < bytes; ++j) {
       unsigned char byte = input[inputIndex++];
       output += this->ByteToHex(byte);
-      }
     }
+  }
 
   return output;
 }
@@ -147,68 +139,54 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const
 std::string cmUuid::ByteToHex(unsigned char byte) const
 {
   std::string result;
-  for(int i = 0; i < 2; ++i)
-    {
+  for (int i = 0; i < 2; ++i) {
     unsigned char rest = byte % 16;
     byte /= 16;
 
-    char c = (rest < 0xA) ?
-      char('0' + rest) :
-      char('a' + (rest - 0xA));
+    char c = (rest < 0xA) ? char('0' + rest) : char('a' + (rest - 0xA));
 
     result = c + result;
-    }
+  }
 
   return result;
 }
 
 bool cmUuid::StringToBinaryImpl(std::string const& input,
-  std::vector<unsigned char> &output) const
+                                std::vector<unsigned char>& output) const
 {
-  if(input.size()%2)
-    {
+  if (input.size() % 2) {
     return false;
-    }
+  }
 
-  for(size_t i = 0; i < input.size(); i +=2)
-    {
+  for (size_t i = 0; i < input.size(); i += 2) {
     char c1 = 0;
-    if(!IntFromHexDigit(input[i], c1))
-      {
+    if (!IntFromHexDigit(input[i], c1)) {
       return false;
-      }
+    }
 
     char c2 = 0;
-    if(!IntFromHexDigit(input[i + 1], c2))
-      {
+    if (!IntFromHexDigit(input[i + 1], c2)) {
       return false;
-      }
+    }
 
     output.push_back(char(c1 << 4 | c2));
-    }
+  }
 
   return true;
 }
 
 bool cmUuid::IntFromHexDigit(char input, char& output) const
 {
-  if(input >= '0' && input <= '9')
-    {
+  if (input >= '0' && input <= '9') {
     output = char(input - '0');
     return true;
-    }
-  else if(input >= 'a' && input <= 'f')
-    {
+  } else if (input >= 'a' && input <= 'f') {
     output = char(input - 'a' + 0xA);
     return true;
-    }
-  else if(input >= 'A' && input <= 'F')
-    {
+  } else if (input >= 'A' && input <= 'F') {
     output = char(input - 'A' + 0xA);
     return true;
-    }
-  else
-    {
+  } else {
     return false;
-    }
+  }
 }
diff --git a/Source/cmUuid.h b/Source/cmUuid.h
index 0dda357..2bd7ec5 100644
--- a/Source/cmUuid.h
+++ b/Source/cmUuid.h
@@ -24,25 +24,26 @@ public:
   cmUuid();
 
   std::string FromMd5(std::vector<unsigned char> const& uuidNamespace,
-    std::string const& name) const;
+                      std::string const& name) const;
 
   std::string FromSha1(std::vector<unsigned char> const& uuidNamespace,
-    std::string const& name) const;
+                       std::string const& name) const;
 
   bool StringToBinary(std::string const& input,
-    std::vector<unsigned char> &output) const;
+                      std::vector<unsigned char>& output) const;
 
 private:
   std::string ByteToHex(unsigned char byte) const;
 
   void CreateHashInput(std::vector<unsigned char> const& uuidNamespace,
-    std::string const& name, std::vector<unsigned char> &output) const;
+                       std::string const& name,
+                       std::vector<unsigned char>& output) const;
 
   std::string FromDigest(const unsigned char* digest,
-    unsigned char version) const;
+                         unsigned char version) const;
 
   bool StringToBinaryImpl(std::string const& input,
-    std::vector<unsigned char> &output) const;
+                          std::vector<unsigned char>& output) const;
 
   std::string BinaryToString(const unsigned char* input) const;
 
@@ -51,5 +52,4 @@ private:
   std::vector<int> Groups;
 };
 
-
 #endif
diff --git a/Source/cmVS10CLFlagTable.h b/Source/cmVS10CLFlagTable.h
index a7b1b36..dbd760e 100644
--- a/Source/cmVS10CLFlagTable.h
+++ b/Source/cmVS10CLFlagTable.h
@@ -1,270 +1,204 @@
-static cmVS7FlagTable cmVS10CLFlagTable[] =
-{
-
-  //Enum Properties
-  {"DebugInformationFormat", "Z7",
-   "C7 compatible", "OldStyle", 0},
-  {"DebugInformationFormat", "Zi",
-   "Program Database", "ProgramDatabase", 0},
-  {"DebugInformationFormat", "ZI",
-   "Program Database for Edit And Continue", "EditAndContinue", 0},
-
-  {"WarningLevel", "W0",
-   "Turn Off All Warnings", "TurnOffAllWarnings", 0},
-  {"WarningLevel", "W1",
-   "Level1", "Level1", 0},
-  {"WarningLevel", "W2",
-   "Level2", "Level2", 0},
-  {"WarningLevel", "W3",
-   "Level3", "Level3", 0},
-  {"WarningLevel", "W4",
-   "Level4", "Level4", 0},
-  {"WarningLevel", "Wall",
-   "EnableAllWarnings", "EnableAllWarnings", 0},
-
-  {"Optimization", "Od",
-   "Disabled", "Disabled", 0},
-  {"Optimization", "O1",
-   "Minimize Size", "MinSpace", 0},
-  {"Optimization", "O2",
-   "Maximize Speed", "MaxSpeed", 0},
-  {"Optimization", "Ox",
-   "Full Optimization", "Full", 0},
-
-  {"InlineFunctionExpansion", "",
-   "Default", "Default", 0},
-  {"InlineFunctionExpansion", "Ob0",
-   "Disabled", "Disabled", 0},
-  {"InlineFunctionExpansion", "Ob1",
-   "Only __inline", "OnlyExplicitInline", 0},
-  {"InlineFunctionExpansion", "Ob2",
-   "Any Suitable", "AnySuitable", 0},
-
-  {"FavorSizeOrSpeed", "Os",
-   "Favor small code", "Size", 0},
-  {"FavorSizeOrSpeed", "Ot",
-   "Favor fast code", "Speed", 0},
-  {"FavorSizeOrSpeed", "",
-   "Neither", "Neither", 0},
-
-  {"ExceptionHandling", "EHa",
-   "Yes with SEH Exceptions", "Async", 0},
-  {"ExceptionHandling", "EHsc",
-   "Yes", "Sync", 0},
-  {"ExceptionHandling", "EHs",
-   "Yes with Extern C functions", "SyncCThrow", 0},
-  {"ExceptionHandling", "",
-   "No", "false", 0},
-
-  {"BasicRuntimeChecks", "RTCs",
-   "Stack Frames", "StackFrameRuntimeCheck", 0},
-  {"BasicRuntimeChecks", "RTCu",
-   "Uninitialized variables", "UninitializedLocalUsageCheck", 0},
-  {"BasicRuntimeChecks", "RTC1",
-   "Both (/RTC1, equiv. to /RTCsu)", "EnableFastChecks", 0},
-  {"BasicRuntimeChecks", "",
-   "Default", "Default", 0},
-
-  {"RuntimeLibrary", "MT",
-   "Multi-threaded", "MultiThreaded", 0},
-  {"RuntimeLibrary", "MTd",
-   "Multi-threaded Debug", "MultiThreadedDebug", 0},
-  {"RuntimeLibrary", "MD",
-   "Multi-threaded DLL", "MultiThreadedDLL", 0},
-  {"RuntimeLibrary", "MDd",
-   "Multi-threaded Debug DLL", "MultiThreadedDebugDLL", 0},
-
-  {"StructMemberAlignment", "Zp1",
-   "1 Byte", "1Byte", 0},
-  {"StructMemberAlignment", "Zp2",
-   "2 Bytes", "2Bytes", 0},
-  {"StructMemberAlignment", "Zp4",
-   "4 Byte", "4Bytes", 0},
-  {"StructMemberAlignment", "Zp8",
-   "8 Bytes", "8Bytes", 0},
-  {"StructMemberAlignment", "Zp16",
-   "16 Bytes", "16Bytes", 0},
-  {"StructMemberAlignment", "",
-   "Default", "Default", 0},
-
-  {"EnableEnhancedInstructionSet", "arch:SSE",
-   "Streaming SIMD Extensions (/arch:SSE)", "StreamingSIMDExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:SSE2",
-   "Streaming SIMD Extensions 2 (/arch:SSE2)", "StreamingSIMDExtensions2", 0},
-  {"EnableEnhancedInstructionSet", "",
-   "Not Set", "NotSet", 0},
-
-  {"FloatingPointModel", "fp:precise",
-   "Precise", "Precise", 0},
-  {"FloatingPointModel", "fp:strict",
-   "Strict", "Strict", 0},
-  {"FloatingPointModel", "fp:fast",
-   "Fast", "Fast", 0},
-
-  {"PrecompiledHeader", "Yc",
-   "Create", "Create",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "Yu",
-   "Use", "Use",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "",
-   "Not Using Precompiled Headers", "NotUsing", 0},
-
-  {"AssemblerOutput", "",
-   "No Listing", "NoListing", 0},
-  {"AssemblerOutput", "FA",
-   "Assembly-Only Listing", "AssemblyCode", 0},
-  {"AssemblerOutput", "FAc",
-   "Assembly With Machine Code", "AssemblyAndMachineCode", 0},
-  {"AssemblerOutput", "FAs",
-   "Assembly With Source Code", "AssemblyAndSourceCode", 0},
-  {"AssemblerOutput", "FAcs",
-   "Assembly, Machine Code and Source", "All", 0},
-
-  {"CallingConvention", "Gd",
-   "__cdecl", "Cdecl", 0},
-  {"CallingConvention", "Gr",
-   "__fastcall", "FastCall", 0},
-  {"CallingConvention", "Gz",
-   "__stdcall", "StdCall", 0},
-
-  {"CompileAs", "",
-   "Default", "Default", 0},
-  {"CompileAs", "TC",
-   "Compile as C Code", "CompileAsC", 0},
-  {"CompileAs", "TP",
-   "Compile as C++ Code", "CompileAsCpp", 0},
-
-  {"ErrorReporting", "errorReport:none",
-   "Do Not Send Report", "None", 0},
-  {"ErrorReporting", "errorReport:prompt",
-   "Prompt Immediately", "Prompt", 0},
-  {"ErrorReporting", "errorReport:queue",
-   "Queue For Next Login", "Queue", 0},
-  {"ErrorReporting", "errorReport:send",
-   "Send Automatically", "Send", 0},
-
-  {"CompileAsManaged", "",
-   "No Common Language RunTime Support", "false", 0},
-  {"CompileAsManaged", "clr",
-   "Common Language RunTime Support", "true", 0},
-  {"CompileAsManaged", "clr:pure",
-   "Pure MSIL Common Language RunTime Support", "Pure", 0},
-  {"CompileAsManaged", "clr:safe",
-   "Safe MSIL Common Language RunTime Support", "Safe", 0},
-  {"CompileAsManaged", "clr:oldSyntax",
-   "Common Language RunTime Support, Old Syntax", "OldSyntax", 0},
-
-
-  //Bool Properties
-  {"SuppressStartupBanner", "nologo-", "", "false", 0},
-  {"SuppressStartupBanner", "nologo", "", "true", 0},
-  {"TreatWarningAsError", "WX-", "", "false", 0},
-  {"TreatWarningAsError", "WX", "", "true", 0},
-  {"IntrinsicFunctions", "Oi", "", "true", 0},
-  {"OmitFramePointers", "Oy-", "", "false", 0},
-  {"OmitFramePointers", "Oy", "", "true", 0},
-  {"EnableFiberSafeOptimizations", "GT", "", "true", 0},
-  {"WholeProgramOptimization", "GL", "", "true", 0},
-  {"UndefineAllPreprocessorDefinitions", "u", "", "true", 0},
-  {"IgnoreStandardIncludePath", "X", "", "true", 0},
-  {"PreprocessToFile", "P", "", "true", 0},
-  {"PreprocessSuppressLineNumbers", "EP", "", "true", 0},
-  {"PreprocessKeepComments", "C", "", "true", 0},
-  {"StringPooling", "GF-", "", "false", 0},
-  {"StringPooling", "GF", "", "true", 0},
-  {"MinimalRebuild", "Gm-", "", "false", 0},
-  {"MinimalRebuild", "Gm", "", "true", 0},
-  {"SmallerTypeCheck", "RTCc", "", "true", 0},
-  {"BufferSecurityCheck", "GS-", "", "false", 0},
-  {"BufferSecurityCheck", "GS", "", "true", 0},
-  {"FunctionLevelLinking", "Gy-", "", "false", 0},
-  {"FunctionLevelLinking", "Gy", "", "true", 0},
-  {"FloatingPointExceptions", "fp:except-", "", "false", 0},
-  {"FloatingPointExceptions", "fp:except", "", "true", 0},
-  {"CreateHotpatchableImage", "hotpatch", "", "true", 0},
-  {"DisableLanguageExtensions", "Za", "", "true", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0},
-  {"RuntimeTypeInfo", "GR-", "", "false", 0},
-  {"RuntimeTypeInfo", "GR", "", "true", 0},
-  {"OpenMPSupport", "openmp-", "", "false", 0},
-  {"OpenMPSupport", "openmp", "", "true", 0},
-  {"ExpandAttributedSource", "Fx", "", "true", 0},
-  {"ShowIncludes", "showIncludes", "", "true", 0},
-  {"EnablePREfast", "analyze-", "", "false", 0},
-  {"EnablePREfast", "analyze", "", "true", 0},
-  {"UseFullPaths", "FC", "", "true", 0},
-  {"OmitDefaultLibName", "Zl", "", "true", 0},
-  {"UseUnicodeForAssemblerListing", "FAu", "", "true", 0},
-
-  //Bool Properties With Argument
-  {"MultiProcessorCompilation", "MP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"ProcessorNumber", "MP", "Multi-processor Compilation", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateXMLDocumentationFiles", "doc", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"BrowseInformation", "FR", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"BrowseInformationFile", "FR", "Enable Browse Information", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalIncludeDirectories", "I",
-   "Additional Include Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalUsingDirectories", "AI",
-   "Resolve #using References",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PreprocessorDefinitions", "D ",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"UndefinePreprocessorDefinitions", "U",
-   "Undefine Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DisableSpecificWarnings", "wd",
-   "Disable Specific Warnings",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedIncludeFiles", "FI",
-   "Forced Include File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedUsingFiles", "FU",
-   "Forced #using File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"TreatSpecificWarningsAsErrors", "we",
-   "Treat Specific Warnings As Errors",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-
-  //String Properties
+static cmVS7FlagTable cmVS10CLFlagTable[] = {
+
+  // Enum Properties
+  { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
+  { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
+  { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
+    "EditAndContinue", 0 },
+
+  { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
+  { "WarningLevel", "W1", "Level1", "Level1", 0 },
+  { "WarningLevel", "W2", "Level2", "Level2", 0 },
+  { "WarningLevel", "W3", "Level3", "Level3", 0 },
+  { "WarningLevel", "W4", "Level4", "Level4", 0 },
+  { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
+
+  { "Optimization", "Od", "Disabled", "Disabled", 0 },
+  { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
+  { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
+  { "Optimization", "Ox", "Full Optimization", "Full", 0 },
+
+  { "InlineFunctionExpansion", "", "Default", "Default", 0 },
+  { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
+  { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
+    0 },
+  { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
+
+  { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
+  { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
+  { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
+
+  { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
+  { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
+  { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
+    0 },
+  { "ExceptionHandling", "", "No", "false", 0 },
+
+  { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
+    0 },
+  { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
+    "UninitializedLocalUsageCheck", 0 },
+  { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
+    "EnableFastChecks", 0 },
+  { "BasicRuntimeChecks", "", "Default", "Default", 0 },
+
+  { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
+  { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
+  { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
+  { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
+    "MultiThreadedDebugDLL", 0 },
+
+  { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
+  { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
+  { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
+  { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
+  { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
+  { "StructMemberAlignment", "", "Default", "Default", 0 },
+
+  { "EnableEnhancedInstructionSet", "arch:SSE",
+    "Streaming SIMD Extensions (/arch:SSE)", "StreamingSIMDExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:SSE2",
+    "Streaming SIMD Extensions 2 (/arch:SSE2)", "StreamingSIMDExtensions2",
+    0 },
+  { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
+
+  { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
+  { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
+  { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
+
+  { "PrecompiledHeader", "Yc", "Create", "Create",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "Yu", "Use", "Use",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
+
+  { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
+  { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
+  { "AssemblerOutput", "FAc", "Assembly With Machine Code",
+    "AssemblyAndMachineCode", 0 },
+  { "AssemblerOutput", "FAs", "Assembly With Source Code",
+    "AssemblyAndSourceCode", 0 },
+  { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
+
+  { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
+  { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
+  { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
+
+  { "CompileAs", "", "Default", "Default", 0 },
+  { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
+  { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
+
+  { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
+  { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
+    0 },
+  { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
+    0 },
+  { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
+
+  { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
+  { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
+  { "CompileAsManaged", "clr:pure",
+    "Pure MSIL Common Language RunTime Support", "Pure", 0 },
+  { "CompileAsManaged", "clr:safe",
+    "Safe MSIL Common Language RunTime Support", "Safe", 0 },
+  { "CompileAsManaged", "clr:oldSyntax",
+    "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
+
+  // Bool Properties
+  { "SuppressStartupBanner", "nologo-", "", "false", 0 },
+  { "SuppressStartupBanner", "nologo", "", "true", 0 },
+  { "TreatWarningAsError", "WX-", "", "false", 0 },
+  { "TreatWarningAsError", "WX", "", "true", 0 },
+  { "IntrinsicFunctions", "Oi", "", "true", 0 },
+  { "OmitFramePointers", "Oy-", "", "false", 0 },
+  { "OmitFramePointers", "Oy", "", "true", 0 },
+  { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
+  { "WholeProgramOptimization", "GL", "", "true", 0 },
+  { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
+  { "IgnoreStandardIncludePath", "X", "", "true", 0 },
+  { "PreprocessToFile", "P", "", "true", 0 },
+  { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
+  { "PreprocessKeepComments", "C", "", "true", 0 },
+  { "StringPooling", "GF-", "", "false", 0 },
+  { "StringPooling", "GF", "", "true", 0 },
+  { "MinimalRebuild", "Gm-", "", "false", 0 },
+  { "MinimalRebuild", "Gm", "", "true", 0 },
+  { "SmallerTypeCheck", "RTCc", "", "true", 0 },
+  { "BufferSecurityCheck", "GS-", "", "false", 0 },
+  { "BufferSecurityCheck", "GS", "", "true", 0 },
+  { "FunctionLevelLinking", "Gy-", "", "false", 0 },
+  { "FunctionLevelLinking", "Gy", "", "true", 0 },
+  { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
+  { "FloatingPointExceptions", "fp:except", "", "true", 0 },
+  { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
+  { "DisableLanguageExtensions", "Za", "", "true", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
+  { "RuntimeTypeInfo", "GR-", "", "false", 0 },
+  { "RuntimeTypeInfo", "GR", "", "true", 0 },
+  { "OpenMPSupport", "openmp-", "", "false", 0 },
+  { "OpenMPSupport", "openmp", "", "true", 0 },
+  { "ExpandAttributedSource", "Fx", "", "true", 0 },
+  { "ShowIncludes", "showIncludes", "", "true", 0 },
+  { "EnablePREfast", "analyze-", "", "false", 0 },
+  { "EnablePREfast", "analyze", "", "true", 0 },
+  { "UseFullPaths", "FC", "", "true", 0 },
+  { "OmitDefaultLibName", "Zl", "", "true", 0 },
+  { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
+
+  // Bool Properties With Argument
+  { "MultiProcessorCompilation", "MP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateXMLDocumentationFiles", "doc", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "BrowseInformation", "FR", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "BrowseInformationFile", "FR", "Enable Browse Information", "",
+    cmVS7FlagTable::UserValueRequired },
+
+  // String List Properties
+  { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalUsingDirectories", "AI", "Resolve #using References", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "UndefinePreprocessorDefinitions", "U",
+    "Undefine Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedIncludeFiles", "FI", "Forced Include File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedUsingFiles", "FU", "Forced #using File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+
+  // String Properties
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"PreprocessOutputPath", "Fi",
-   "Preprocess Output Path",
-   "", cmVS7FlagTable::UserValue},
-  {"PrecompiledHeaderFile", "Yc",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderFile", "Yu",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderOutputFile", "Fp",
-   "Precompiled Header Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"AssemblerListingLocation", "Fa",
-   "ASM List Location",
-   "", cmVS7FlagTable::UserValue},
-  {"ObjectFileName", "Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDataBaseFileName", "Fd",
-   "Program Database File Name",
-   "", cmVS7FlagTable::UserValue},
+  { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
+    cmVS7FlagTable::UserValue },
+  { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
+    cmVS7FlagTable::UserValue },
+  { "AssemblerListingLocation", "Fa", "ASM List Location", "",
+    cmVS7FlagTable::UserValue },
+  { "ObjectFileName", "Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [XMLDocumentationFileName] - no command line Switch.
   // Skip [BrowseInformationFile] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS10LibFlagTable.h b/Source/cmVS10LibFlagTable.h
index 79aeeff..65f28ef 100644
--- a/Source/cmVS10LibFlagTable.h
+++ b/Source/cmVS10LibFlagTable.h
@@ -1,102 +1,76 @@
-static cmVS7FlagTable cmVS10LibFlagTable[] =
-{
+static cmVS7FlagTable cmVS10LibFlagTable[] = {
 
-  //Enum Properties
-  {"ErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"ErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"ErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"ErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  // Enum Properties
+  { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
+    0 },
 
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWSCE",
-   "WindowsCE", "WindowsCE", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
+  // Bool Properties
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
+  { "Verbose", "VERBOSE", "", "true", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
 
-  //Bool Properties
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"TreatLibWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLibWarningAsErrors", "WX", "", "true", 0},
-  {"Verbose", "VERBOSE", "", "true", 0},
-  {"LinkTimeCodeGeneration", "LTCG", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
+  // String List Properties
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ExportNamedFunctions", "EXPORT:",
-   "Export Named Functions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"RemoveObjects", "REMOVE:",
-   "Remove Objects",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "RemoveObjects", "REMOVE:", "Remove Objects", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue},
-  {"DisplayLibrary", "LIST:",
-   "Display Library to standard output",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue },
+  { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"Name", "NAME:",
-   "Name",
-   "", cmVS7FlagTable::UserValue},
+  { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
   // Skip [TrackerLogDirectory] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h
index dd92329..c30ea9a 100644
--- a/Source/cmVS10LinkFlagTable.h
+++ b/Source/cmVS10LinkFlagTable.h
@@ -1,303 +1,244 @@
-static cmVS7FlagTable cmVS10LinkFlagTable[] =
-{
-
-  //Enum Properties
-  {"ShowProgress", "",
-   "Not Set", "NotSet", 0},
-  {"ShowProgress", "VERBOSE",
-   "Display all progress messages", "LinkVerbose", 0},
-  {"ShowProgress", "VERBOSE:Lib",
-   "For Libraries Searched", "LinkVerboseLib", 0},
-  {"ShowProgress", "VERBOSE:ICF",
-   "About COMDAT folding during optimized linking", "LinkVerboseICF", 0},
-  {"ShowProgress", "VERBOSE:REF",
-   "About data removed during optimized linking", "LinkVerboseREF", 0},
-  {"ShowProgress", "VERBOSE:SAFESEH",
-   "About Modules incompatible with SEH", "LinkVerboseSAFESEH", 0},
-  {"ShowProgress", "VERBOSE:CLR",
-   "About linker activity related to managed code", "LinkVerboseCLR", 0},
-
-  {"ForceFileOutput", "FORCE",
-   "Enabled", "Enabled", 0},
-  {"ForceFileOutput", "FORCE:MULTIPLE",
-   "Multiply Defined Symbol Only", "MultiplyDefinedSymbolOnly", 0},
-  {"ForceFileOutput", "FORCE:UNRESOLVED",
-   "Undefined Symbol Only", "UndefinedSymbolOnly", 0},
-
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN",
-   "Enabled", "Enabled", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:5",
-   "X86 Image Only", "X86Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:6",
-   "X64 Image Only", "X64Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:16",
-   "Itanium Image Only", "ItaniumImage", 0},
-
-  {"UACExecutionLevel", "level='asInvoker'",
-   "asInvoker", "AsInvoker", 0},
-  {"UACExecutionLevel", "level='highestAvailable'",
-   "highestAvailable", "HighestAvailable", 0},
-  {"UACExecutionLevel", "level='requireAdministrator'",
-   "requireAdministrator", "RequireAdministrator", 0},
-
-  {"SubSystem", "",
-   "Not Set", "NotSet", 0},
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWSCE",
-   "WindowsCE", "WindowsCE", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
-
-  {"Driver", "",
-   "Not Set", "NotSet", 0},
-  {"Driver", "Driver",
-   "Driver", "Driver", 0},
-  {"Driver", "DRIVER:UPONLY",
-   "UP Only", "UpOnly", 0},
-  {"Driver", "DRIVER:WDM",
-   "WDM", "WDM", 0},
-
-  {"LinkTimeCodeGeneration", "",
-   "Default", "Default", 0},
-  {"LinkTimeCodeGeneration", "LTCG",
-   "Use Link Time Code Generation", "UseLinkTimeCodeGeneration", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGInstrument",
-   "Profile Guided Optimization - Instrument", "PGInstrument", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGOptimize",
-   "Profile Guided Optimization - Optimization", "PGOptimization", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGUpdate",
-   "Profile Guided Optimization - Update", "PGUpdate", 0},
-
-  {"TargetMachine", "",
-   "Not Set", "NotSet", 0},
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
-
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA",
-   "MTA threading attribute", "MTAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA",
-   "STA threading attribute", "STAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
-   "Default threading attribute", "DefaultThreadingAttribute", 0},
-
-  {"CLRImageType", "CLRIMAGETYPE:IJW",
-   "Force IJW image", "ForceIJWImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:PURE",
-   "Force Pure IL Image", "ForcePureILImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:SAFE",
-   "Force Safe IL Image", "ForceSafeILImage", 0},
-  {"CLRImageType", "",
-   "Default image type", "Default", 0},
-
-  {"LinkErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"LinkErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"LinkErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"LinkErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
-
-  {"CLRSupportLastError", "CLRSupportLastError",
-   "Enabled", "Enabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:NO",
-   "Disabled", "Disabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL",
-   "System Dlls Only", "SystemDlls", 0},
-
-
-  //Bool Properties
-  {"LinkIncremental", "INCREMENTAL:NO", "", "false", 0},
-  {"LinkIncremental", "INCREMENTAL", "", "true", 0},
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"LinkStatus", "LTCG:NOSTATUS", "", "false", 0},
-  {"LinkStatus", "LTCG:STATUS", "", "true", 0},
-  {"PreventDllBinding", "ALLOWBIND:NO", "", "false", 0},
-  {"PreventDllBinding", "ALLOWBIND", "", "true", 0},
-  {"TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLinkerWarningAsErrors", "WX", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"GenerateManifest", "MANIFEST:NO", "", "false", 0},
-  {"GenerateManifest", "MANIFEST", "", "true", 0},
-  {"AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0},
-  {"UACUIAccess", "uiAccess='false'", "", "false", 0},
-  {"UACUIAccess", "uiAccess='true'", "", "true", 0},
-  {"GenerateDebugInformation", "DEBUG", "", "true",
-   cmVS7FlagTable::CaseInsensitive},
-  {"MapExports", "MAPINFO:EXPORTS", "", "true", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0},
-  {"TerminalServerAware", "TSAWARE:NO", "", "false", 0},
-  {"TerminalServerAware", "TSAWARE", "", "true", 0},
-  {"SwapRunFromCD", "SWAPRUN:CD", "", "true", 0},
-  {"SwapRunFromNET", "SWAPRUN:NET", "", "true", 0},
-  {"OptimizeReferences", "OPT:NOREF", "", "false", 0},
-  {"OptimizeReferences", "OPT:REF", "", "true", 0},
-  {"EnableCOMDATFolding", "OPT:NOICF", "", "false", 0},
-  {"EnableCOMDATFolding", "OPT:ICF", "", "true", 0},
-  {"IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0},
-  {"NoEntryPoint", "NOENTRY", "", "true", 0},
-  {"SetChecksum", "RELEASE", "", "true", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0},
-  {"FixedBaseAddress", "FIXED:NO", "", "false", 0},
-  {"FixedBaseAddress", "FIXED", "", "true", 0},
-  {"DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0},
-  {"DataExecutionPrevention", "NXCOMPAT", "", "true", 0},
-  {"TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0},
-  {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
-  {"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0},
-  {"Profile", "PROFILE", "", "true", 0},
-  {"LinkDelaySign", "DELAYSIGN:NO", "", "false", 0},
-  {"LinkDelaySign", "DELAYSIGN", "", "true", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0},
-  {"LinkDLL", "DLL", "", "true", 0},
-
-  //Bool Properties With Argument
-  {"EnableUAC", "MANIFESTUAC:NO", "", "false", 0},
-  {"EnableUAC", "MANIFESTUAC:", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateMapFile", "MAP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"MapFileName", "MAP:", "Generate Map File", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+static cmVS7FlagTable cmVS10LinkFlagTable[] = {
+
+  // Enum Properties
+  { "ShowProgress", "", "Not Set", "NotSet", 0 },
+  { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
+    0 },
+  { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
+    0 },
+  { "ShowProgress", "VERBOSE:ICF",
+    "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
+  { "ShowProgress", "VERBOSE:REF",
+    "About data removed during optimized linking", "LinkVerboseREF", 0 },
+  { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
+    "LinkVerboseSAFESEH", 0 },
+  { "ShowProgress", "VERBOSE:CLR",
+    "About linker activity related to managed code", "LinkVerboseCLR", 0 },
+
+  { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
+  { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
+    "MultiplyDefinedSymbolOnly", 0 },
+  { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
+    "UndefinedSymbolOnly", 0 },
+
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
+    "X86Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
+    "X64Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
+    "ItaniumImage", 0 },
+
+  { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
+  { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
+    "HighestAvailable", 0 },
+  { "UACExecutionLevel", "level='requireAdministrator'",
+    "requireAdministrator", "RequireAdministrator", 0 },
+
+  { "SubSystem", "", "Not Set", "NotSet", 0 },
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
+
+  { "Driver", "", "Not Set", "NotSet", 0 },
+  { "Driver", "Driver", "Driver", "Driver", 0 },
+  { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
+  { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
+
+  { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
+    "UseLinkTimeCodeGeneration", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
+    "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
+    "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
+    "Profile Guided Optimization - Update", "PGUpdate", 0 },
+
+  { "TargetMachine", "", "Not Set", "NotSet", 0 },
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
+
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
+    "MTAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
+    "STAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
+    "Default threading attribute", "DefaultThreadingAttribute", 0 },
+
+  { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
+    0 },
+  { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
+    "ForcePureILImage", 0 },
+  { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
+    "ForceSafeILImage", 0 },
+  { "CLRImageType", "", "Default image type", "Default", 0 },
+
+  { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
+    "NoErrorReport", 0 },
+
+  { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
+  { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
+    0 },
+  { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
+    "SystemDlls", 0 },
+
+  // Bool Properties
+  { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
+  { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
+  { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
+  { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
+  { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
+  { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
+  { "GenerateManifest", "MANIFEST", "", "true", 0 },
+  { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
+  { "GenerateDebugInformation", "DEBUG", "", "true",
+    cmVS7FlagTable::CaseInsensitive },
+  { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
+  { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
+  { "TerminalServerAware", "TSAWARE", "", "true", 0 },
+  { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
+  { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
+  { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
+  { "OptimizeReferences", "OPT:REF", "", "true", 0 },
+  { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
+  { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
+  { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
+  { "NoEntryPoint", "NOENTRY", "", "true", 0 },
+  { "SetChecksum", "RELEASE", "", "true", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
+  { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
+  { "FixedBaseAddress", "FIXED", "", "true", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
+  { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
+  { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
+  { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
+  { "Profile", "PROFILE", "", "true", 0 },
+  { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
+  { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
+  { "LinkDLL", "DLL", "", "true", 0 },
+
+  // Bool Properties With Argument
+  { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
+  { "EnableUAC", "MANIFESTUAC:", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateMapFile", "MAP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "MapFileName", "MAP:", "Generate Map File", "",
+    cmVS7FlagTable::UserValueRequired },
+
+  // String List Properties
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AddModuleNamesToAssembly", "ASSEMBLYMODULE:",
-   "Add Module to Assembly",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
-   "Embed Managed Resource File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DelayLoadDLLs", "DELAYLOAD:",
-   "Delay Loaded Dlls",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:",
-   "Assembly Link Resource",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
-   "Additional Manifest Dependencies",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"Version", "VERSION:",
-   "Version",
-   "", cmVS7FlagTable::UserValue},
-  {"SpecifySectionAttributes", "SECTION:",
-   "Specify Section Attributes",
-   "", cmVS7FlagTable::UserValue},
-  {"MSDOSStubFileName", "STUB:",
-   "MS-DOS Stub File Name",
-   "", cmVS7FlagTable::UserValue},
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
+    "Embed Managed Resource File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
+    "Additional Manifest Dependencies", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
+  { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
+    cmVS7FlagTable::UserValue },
+  { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File",
-   "", cmVS7FlagTable::UserValue},
-  {"ManifestFile", "ManifestFile:",
-   "Manifest File",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDatabaseFile", "PDB:",
-   "Generate Program Database File",
-   "", cmVS7FlagTable::UserValue},
-  {"StripPrivateSymbols", "PDBSTRIPPED:",
-   "Strip Private Symbols",
-   "", cmVS7FlagTable::UserValue},
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
+    cmVS7FlagTable::UserValue },
+  { "ManifestFile", "ManifestFile:", "Manifest File", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
+    cmVS7FlagTable::UserValue },
+  { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MapFileName] - no command line Switch.
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"HeapReserveSize", "HEAP:",
-   "Heap Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [HeapCommitSize] - no command line Switch.
-  {"StackReserveSize", "STACK:",
-   "Stack Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [StackCommitSize] - no command line Switch.
-  {"FunctionOrder", "ORDER:@",
-   "Function Order",
-   "", cmVS7FlagTable::UserValue},
-  {"ProfileGuidedDatabase", "PGD:",
-   "Profile Guided Database",
-   "", cmVS7FlagTable::UserValue},
-  {"MidlCommandFile", "MIDL:@",
-   "MIDL Commands",
-   "", cmVS7FlagTable::UserValue},
-  {"MergedIDLBaseFileName", "IDLOUT:",
-   "Merged IDL Base File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"TypeLibraryFile", "TLBOUT:",
-   "Type Library",
-   "", cmVS7FlagTable::UserValue},
-  {"EntryPointSymbol", "ENTRY:",
-   "Entry Point",
-   "", cmVS7FlagTable::UserValue},
-  {"BaseAddress", "BASE:",
-   "Base Address",
-   "", cmVS7FlagTable::UserValue},
-  {"ImportLibrary", "IMPLIB:",
-   "Import Library",
-   "", cmVS7FlagTable::UserValue},
-  {"MergeSections", "MERGE:",
-   "Merge Sections",
-   "", cmVS7FlagTable::UserValue},
-  {"LinkKeyFile", "KEYFILE:",
-   "Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"KeyContainer", "KEYCONTAINER:",
-   "Key Container",
-   "", cmVS7FlagTable::UserValue},
+  { "FunctionOrder", "ORDER:@", "Function Order", "",
+    cmVS7FlagTable::UserValue },
+  { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
+    cmVS7FlagTable::UserValue },
+  { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
+    cmVS7FlagTable::UserValue },
+  { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
+    cmVS7FlagTable::UserValue },
+  { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
+    cmVS7FlagTable::UserValue },
+  { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
+  { "ImportLibrary", "IMPLIB:", "Import Library", "",
+    cmVS7FlagTable::UserValue },
+  { "MergeSections", "MERGE:", "Merge Sections", "",
+    cmVS7FlagTable::UserValue },
+  { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
+  { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
+    cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS10MASMFlagTable.h b/Source/cmVS10MASMFlagTable.h
index 8fb6f33..82e5270 100644
--- a/Source/cmVS10MASMFlagTable.h
+++ b/Source/cmVS10MASMFlagTable.h
@@ -1,96 +1,78 @@
-static cmVS7FlagTable cmVS10MASMFlagTable[] =
-{
+static cmVS7FlagTable cmVS10MASMFlagTable[] = {
 
-  //Enum Properties
-  {"PreserveIdentifierCase", "",
-   "Default", "0", 0},
-  {"PreserveIdentifierCase", "/Cp",
-   "Preserves Identifier Case (/Cp)", "1", 0},
-  {"PreserveIdentifierCase", "/Cu",
-   "Maps all identifiers to upper case. (/Cu)", "2", 0},
-  {"PreserveIdentifierCase", "/Cx",
-   "Preserves case in public and extern symbols. (/Cx)", "3", 0},
+  // Enum Properties
+  { "PreserveIdentifierCase", "", "Default", "0", 0 },
+  { "PreserveIdentifierCase", "/Cp", "Preserves Identifier Case (/Cp)", "1",
+    0 },
+  { "PreserveIdentifierCase", "/Cu",
+    "Maps all identifiers to upper case. (/Cu)", "2", 0 },
+  { "PreserveIdentifierCase", "/Cx",
+    "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
 
-  {"WarningLevel", "/W0",
-   "Warning Level 0 (/W0)", "0", 0},
-  {"WarningLevel", "/W1",
-   "Warning Level 1 (/W1)", "1", 0},
-  {"WarningLevel", "/W2",
-   "Warning Level 2 (/W2)", "2", 0},
-  {"WarningLevel", "/W3",
-   "Warning Level 3 (/W3)", "3", 0},
+  { "WarningLevel", "/W0", "Warning Level 0 (/W0)", "0", 0 },
+  { "WarningLevel", "/W1", "Warning Level 1 (/W1)", "1", 0 },
+  { "WarningLevel", "/W2", "Warning Level 2 (/W2)", "2", 0 },
+  { "WarningLevel", "/W3", "Warning Level 3 (/W3)", "3", 0 },
 
-  {"PackAlignmentBoundary", "",
-   "Default", "0", 0},
-  {"PackAlignmentBoundary", "/Zp1",
-   "One Byte Boundary (/Zp1)", "1", 0},
-  {"PackAlignmentBoundary", "/Zp2",
-   "Two Byte Boundary (/Zp2)", "2", 0},
-  {"PackAlignmentBoundary", "/Zp4",
-   "Four Byte Boundary (/Zp4)", "3", 0},
-  {"PackAlignmentBoundary", "/Zp8",
-   "Eight Byte Boundary (/Zp8)", "4", 0},
-  {"PackAlignmentBoundary", "/Zp16",
-   "Sixteen Byte Boundary (/Zp16)", "5", 0},
+  { "PackAlignmentBoundary", "", "Default", "0", 0 },
+  { "PackAlignmentBoundary", "/Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
+  { "PackAlignmentBoundary", "/Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
+  { "PackAlignmentBoundary", "/Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
+  { "PackAlignmentBoundary", "/Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
+  { "PackAlignmentBoundary", "/Zp16", "Sixteen Byte Boundary (/Zp16)", "5",
+    0 },
 
-  {"CallingConvention", "",
-   "Default", "0", 0},
-  {"CallingConvention", "/Gd",
-   "Use C-style Calling Convention (/Gd)", "1", 0},
-  {"CallingConvention", "/Gz",
-   "Use stdcall Calling Convention (/Gz)", "2", 0},
-  {"CallingConvention", "/Gc",
-   "Use Pascal Calling Convention (/Gc)", "3", 0},
+  { "CallingConvention", "", "Default", "0", 0 },
+  { "CallingConvention", "/Gd", "Use C-style Calling Convention (/Gd)", "1",
+    0 },
+  { "CallingConvention", "/Gz", "Use stdcall Calling Convention (/Gz)", "2",
+    0 },
+  { "CallingConvention", "/Gc", "Use Pascal Calling Convention (/Gc)", "3",
+    0 },
 
-  {"ErrorReporting", "/errorReport:prompt",
-   "Prompt to send report immediately (/errorReport:prompt)", "0", 0},
-  {"ErrorReporting", "/errorReport:queue",
-   "Prompt to send report at the next logon (/errorReport:queue)", "1", 0},
-  {"ErrorReporting", "/errorReport:send",
-   "Automatically send report (/errorReport:send)", "2", 0},
-  {"ErrorReporting", "/errorReport:none",
-   "Do not send report (/errorReport:none)", "3", 0},
+  { "ErrorReporting", "/errorReport:prompt",
+    "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
+  { "ErrorReporting", "/errorReport:queue",
+    "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
+  { "ErrorReporting", "/errorReport:send",
+    "Automatically send report (/errorReport:send)", "2", 0 },
+  { "ErrorReporting", "/errorReport:none",
+    "Do not send report (/errorReport:none)", "3", 0 },
 
+  // Bool Properties
+  { "NoLogo", "/nologo", "", "true", 0 },
+  { "GeneratePreprocessedSourceListing", "/EP", "", "true", 0 },
+  { "ListAllAvailableInformation", "/Sa", "", "true", 0 },
+  { "UseSafeExceptionHandlers", "/safeseh", "", "true", 0 },
+  { "AddFirstPassListing", "/Sf", "", "true", 0 },
+  { "EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0 },
+  { "DisableSymbolTable", "/Sn", "", "true", 0 },
+  { "EnableFalseConditionalsInListing", "/Sx", "", "true", 0 },
+  { "TreatWarningsAsErrors", "/WX", "", "true", 0 },
+  { "MakeAllSymbolsPublic", "/Zf", "", "true", 0 },
+  { "GenerateDebugInformation", "/Zi", "", "true", 0 },
+  { "EnableMASM51Compatibility", "/Zm", "", "true", 0 },
+  { "PerformSyntaxCheckOnly", "/Zs", "", "true", 0 },
 
-  //Bool Properties
-  {"NoLogo", "/nologo", "", "true", 0},
-  {"GeneratePreprocessedSourceListing", "/EP", "", "true", 0},
-  {"ListAllAvailableInformation", "/Sa", "", "true", 0},
-  {"UseSafeExceptionHandlers", "/safeseh", "", "true", 0},
-  {"AddFirstPassListing", "/Sf", "", "true", 0},
-  {"EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0},
-  {"DisableSymbolTable", "/Sn", "", "true", 0},
-  {"EnableFalseConditionalsInListing", "/Sx", "", "true", 0},
-  {"TreatWarningsAsErrors", "/WX", "", "true", 0},
-  {"MakeAllSymbolsPublic", "/Zf", "", "true", 0},
-  {"GenerateDebugInformation", "/Zi", "", "true", 0},
-  {"EnableMASM51Compatibility", "/Zm", "", "true", 0},
-  {"PerformSyntaxCheckOnly", "/Zs", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
-  {"PreprocessorDefinitions", "/D",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IncludePaths", "/I",
-   "Include Paths",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"BrowseFile", "/FR",
-   "Generate Browse Information File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "PreprocessorDefinitions", "/D", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IncludePaths", "/I", "Include Paths", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "BrowseFile", "/FR", "Generate Browse Information File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
 
-  //String Properties
+  // String Properties
   // Skip [Inputs] - no command line Switch.
-  {"ObjectFileName", "/Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"AssembledCodeListingFile", "/Fl",
-   "Assembled Code Listing File",
-   "", cmVS7FlagTable::UserValue},
+  { "ObjectFileName", "/Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "AssembledCodeListingFile", "/Fl", "Assembled Code Listing File", "",
+    cmVS7FlagTable::UserValue },
   // Skip [CommandLineTemplate] - no command line Switch.
   // Skip [ExecutionDescription] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS10RCFlagTable.h b/Source/cmVS10RCFlagTable.h
index 9049986..32f35e5 100644
--- a/Source/cmVS10RCFlagTable.h
+++ b/Source/cmVS10RCFlagTable.h
@@ -1,7 +1,6 @@
-static cmVS7FlagTable cmVS10RCFlagTable[] =
-{
-  //Bool Properties
-  {"NullTerminateStrings", "n", "", "true", 0},
+static cmVS7FlagTable cmVS10RCFlagTable[] = {
+  // Bool Properties
+  { "NullTerminateStrings", "n", "", "true", 0 },
 
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h
index a61ab16..7531709 100644
--- a/Source/cmVS11CLFlagTable.h
+++ b/Source/cmVS11CLFlagTable.h
@@ -1,288 +1,219 @@
-static cmVS7FlagTable cmVS11CLFlagTable[] =
-{
-
-  //Enum Properties
-  {"DebugInformationFormat", "",
-   "None", "None", 0},
-  {"DebugInformationFormat", "Z7",
-   "C7 compatible", "OldStyle", 0},
-  {"DebugInformationFormat", "Zi",
-   "Program Database", "ProgramDatabase", 0},
-  {"DebugInformationFormat", "ZI",
-   "Program Database for Edit And Continue", "EditAndContinue", 0},
-
-  {"WarningLevel", "W0",
-   "Turn Off All Warnings", "TurnOffAllWarnings", 0},
-  {"WarningLevel", "W1",
-   "Level1", "Level1", 0},
-  {"WarningLevel", "W2",
-   "Level2", "Level2", 0},
-  {"WarningLevel", "W3",
-   "Level3", "Level3", 0},
-  {"WarningLevel", "W4",
-   "Level4", "Level4", 0},
-  {"WarningLevel", "Wall",
-   "EnableAllWarnings", "EnableAllWarnings", 0},
-
-  {"Optimization", "Od",
-   "Disabled", "Disabled", 0},
-  {"Optimization", "O1",
-   "Minimize Size", "MinSpace", 0},
-  {"Optimization", "O2",
-   "Maximize Speed", "MaxSpeed", 0},
-  {"Optimization", "Ox",
-   "Full Optimization", "Full", 0},
-
-  {"InlineFunctionExpansion", "",
-   "Default", "Default", 0},
-  {"InlineFunctionExpansion", "Ob0",
-   "Disabled", "Disabled", 0},
-  {"InlineFunctionExpansion", "Ob1",
-   "Only __inline", "OnlyExplicitInline", 0},
-  {"InlineFunctionExpansion", "Ob2",
-   "Any Suitable", "AnySuitable", 0},
-
-  {"FavorSizeOrSpeed", "Os",
-   "Favor small code", "Size", 0},
-  {"FavorSizeOrSpeed", "Ot",
-   "Favor fast code", "Speed", 0},
-  {"FavorSizeOrSpeed", "",
-   "Neither", "Neither", 0},
-
-  {"ExceptionHandling", "EHa",
-   "Yes with SEH Exceptions", "Async", 0},
-  {"ExceptionHandling", "EHsc",
-   "Yes", "Sync", 0},
-  {"ExceptionHandling", "EHs",
-   "Yes with Extern C functions", "SyncCThrow", 0},
-  {"ExceptionHandling", "",
-   "No", "false", 0},
-
-  {"BasicRuntimeChecks", "RTCs",
-   "Stack Frames", "StackFrameRuntimeCheck", 0},
-  {"BasicRuntimeChecks", "RTCu",
-   "Uninitialized variables", "UninitializedLocalUsageCheck", 0},
-  {"BasicRuntimeChecks", "RTC1",
-   "Both (/RTC1, equiv. to /RTCsu)", "EnableFastChecks", 0},
-  {"BasicRuntimeChecks", "",
-   "Default", "Default", 0},
-
-  {"RuntimeLibrary", "MT",
-   "Multi-threaded", "MultiThreaded", 0},
-  {"RuntimeLibrary", "MTd",
-   "Multi-threaded Debug", "MultiThreadedDebug", 0},
-  {"RuntimeLibrary", "MD",
-   "Multi-threaded DLL", "MultiThreadedDLL", 0},
-  {"RuntimeLibrary", "MDd",
-   "Multi-threaded Debug DLL", "MultiThreadedDebugDLL", 0},
-
-  {"StructMemberAlignment", "Zp1",
-   "1 Byte", "1Byte", 0},
-  {"StructMemberAlignment", "Zp2",
-   "2 Bytes", "2Bytes", 0},
-  {"StructMemberAlignment", "Zp4",
-   "4 Byte", "4Bytes", 0},
-  {"StructMemberAlignment", "Zp8",
-   "8 Bytes", "8Bytes", 0},
-  {"StructMemberAlignment", "Zp16",
-   "16 Bytes", "16Bytes", 0},
-  {"StructMemberAlignment", "",
-   "Default", "Default", 0},
-
-  {"EnableEnhancedInstructionSet", "arch:SSE",
-   "Streaming SIMD Extensions", "StreamingSIMDExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:SSE2",
-   "Streaming SIMD Extensions 2", "StreamingSIMDExtensions2", 0},
-  {"EnableEnhancedInstructionSet", "arch:AVX",
-   "Advanced Vector Extensions", "AdvancedVectorExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:IA32",
-   "No Enhanced Instructions", "NoExtensions", 0},
-  {"EnableEnhancedInstructionSet", "",
-   "Not Set", "NotSet", 0},
-
-  {"FloatingPointModel", "fp:precise",
-   "Precise", "Precise", 0},
-  {"FloatingPointModel", "fp:strict",
-   "Strict", "Strict", 0},
-  {"FloatingPointModel", "fp:fast",
-   "Fast", "Fast", 0},
-
-  {"PrecompiledHeader", "Yc",
-   "Create", "Create",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "Yu",
-   "Use", "Use",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "",
-   "Not Using Precompiled Headers", "NotUsing", 0},
-
-  {"AssemblerOutput", "",
-   "No Listing", "NoListing", 0},
-  {"AssemblerOutput", "FA",
-   "Assembly-Only Listing", "AssemblyCode", 0},
-  {"AssemblerOutput", "FAc",
-   "Assembly With Machine Code", "AssemblyAndMachineCode", 0},
-  {"AssemblerOutput", "FAs",
-   "Assembly With Source Code", "AssemblyAndSourceCode", 0},
-  {"AssemblerOutput", "FAcs",
-   "Assembly, Machine Code and Source", "All", 0},
-
-  {"CallingConvention", "Gd",
-   "__cdecl", "Cdecl", 0},
-  {"CallingConvention", "Gr",
-   "__fastcall", "FastCall", 0},
-  {"CallingConvention", "Gz",
-   "__stdcall", "StdCall", 0},
-
-  {"CompileAs", "",
-   "Default", "Default", 0},
-  {"CompileAs", "TC",
-   "Compile as C Code", "CompileAsC", 0},
-  {"CompileAs", "TP",
-   "Compile as C++ Code", "CompileAsCpp", 0},
-
-  {"ErrorReporting", "errorReport:none",
-   "Do Not Send Report", "None", 0},
-  {"ErrorReporting", "errorReport:prompt",
-   "Prompt Immediately", "Prompt", 0},
-  {"ErrorReporting", "errorReport:queue",
-   "Queue For Next Login", "Queue", 0},
-  {"ErrorReporting", "errorReport:send",
-   "Send Automatically", "Send", 0},
-
-  {"CompileAsManaged", "",
-   "No Common Language RunTime Support", "false", 0},
-  {"CompileAsManaged", "clr",
-   "Common Language RunTime Support", "true", 0},
-  {"CompileAsManaged", "clr:pure",
-   "Pure MSIL Common Language RunTime Support", "Pure", 0},
-  {"CompileAsManaged", "clr:safe",
-   "Safe MSIL Common Language RunTime Support", "Safe", 0},
-  {"CompileAsManaged", "clr:oldSyntax",
-   "Common Language RunTime Support, Old Syntax", "OldSyntax", 0},
-
-
-  //Bool Properties
-  {"CompileAsWinRT", "ZW", "", "true", 0},
-  {"WinRTNoStdLib", "ZW:nostdlib", "", "true", 0},
-  {"SuppressStartupBanner", "nologo-", "", "false", 0},
-  {"SuppressStartupBanner", "nologo", "", "true", 0},
-  {"TreatWarningAsError", "WX-", "", "false", 0},
-  {"TreatWarningAsError", "WX", "", "true", 0},
-  {"SDLCheck", "sdl-", "", "false", 0},
-  {"SDLCheck", "sdl", "", "true", 0},
-  {"IntrinsicFunctions", "Oi", "", "true", 0},
-  {"OmitFramePointers", "Oy-", "", "false", 0},
-  {"OmitFramePointers", "Oy", "", "true", 0},
-  {"EnableFiberSafeOptimizations", "GT", "", "true", 0},
-  {"WholeProgramOptimization", "GL", "", "true", 0},
-  {"UndefineAllPreprocessorDefinitions", "u", "", "true", 0},
-  {"IgnoreStandardIncludePath", "X", "", "true", 0},
-  {"PreprocessToFile", "P", "", "true", 0},
-  {"PreprocessSuppressLineNumbers", "EP", "", "true", 0},
-  {"PreprocessKeepComments", "C", "", "true", 0},
-  {"StringPooling", "GF-", "", "false", 0},
-  {"StringPooling", "GF", "", "true", 0},
-  {"MinimalRebuild", "Gm-", "", "false", 0},
-  {"MinimalRebuild", "Gm", "", "true", 0},
-  {"SmallerTypeCheck", "RTCc", "", "true", 0},
-  {"BufferSecurityCheck", "GS-", "", "false", 0},
-  {"BufferSecurityCheck", "GS", "", "true", 0},
-  {"FunctionLevelLinking", "Gy-", "", "false", 0},
-  {"FunctionLevelLinking", "Gy", "", "true", 0},
-  {"EnableParallelCodeGeneration", "Qpar-", "", "false", 0},
-  {"EnableParallelCodeGeneration", "Qpar", "", "true", 0},
-  {"FloatingPointExceptions", "fp:except-", "", "false", 0},
-  {"FloatingPointExceptions", "fp:except", "", "true", 0},
-  {"CreateHotpatchableImage", "hotpatch", "", "true", 0},
-  {"DisableLanguageExtensions", "Za", "", "true", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0},
-  {"RuntimeTypeInfo", "GR-", "", "false", 0},
-  {"RuntimeTypeInfo", "GR", "", "true", 0},
-  {"OpenMPSupport", "openmp-", "", "false", 0},
-  {"OpenMPSupport", "openmp", "", "true", 0},
-  {"ExpandAttributedSource", "Fx", "", "true", 0},
-  {"UseUnicodeForAssemblerListing", "FAu", "", "true", 0},
-  {"ShowIncludes", "showIncludes", "", "true", 0},
-  {"EnablePREfast", "analyze-", "", "false", 0},
-  {"EnablePREfast", "analyze", "", "true", 0},
-  {"UseFullPaths", "FC", "", "true", 0},
-  {"OmitDefaultLibName", "Zl", "", "true", 0},
-
-  //Bool Properties With Argument
-  {"MultiProcessorCompilation", "MP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"ProcessorNumber", "MP", "Multi-processor Compilation", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateXMLDocumentationFiles", "doc", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"BrowseInformation", "FR", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"BrowseInformationFile", "FR", "Enable Browse Information", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalIncludeDirectories", "I",
-   "Additional Include Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalUsingDirectories", "AI",
-   "Additional #using Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PreprocessorDefinitions", "D ",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"UndefinePreprocessorDefinitions", "U",
-   "Undefine Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DisableSpecificWarnings", "wd",
-   "Disable Specific Warnings",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedIncludeFiles", "FI",
-   "Forced Include File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedUsingFiles", "FU",
-   "Forced #using File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PREfastLog", "analyze:log",
-   "Code Analysis Log",
-   "", cmVS7FlagTable::UserFollowing},
-  {"PREfastAdditionalPlugins", "analyze:plugin",
-   "Additional Code Analysis Native plugins",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"TreatSpecificWarningsAsErrors", "we",
-   "Treat Specific Warnings As Errors",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-
-  //String Properties
+static cmVS7FlagTable cmVS11CLFlagTable[] = {
+
+  // Enum Properties
+  { "DebugInformationFormat", "", "None", "None", 0 },
+  { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
+  { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
+  { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
+    "EditAndContinue", 0 },
+
+  { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
+  { "WarningLevel", "W1", "Level1", "Level1", 0 },
+  { "WarningLevel", "W2", "Level2", "Level2", 0 },
+  { "WarningLevel", "W3", "Level3", "Level3", 0 },
+  { "WarningLevel", "W4", "Level4", "Level4", 0 },
+  { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
+
+  { "Optimization", "Od", "Disabled", "Disabled", 0 },
+  { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
+  { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
+  { "Optimization", "Ox", "Full Optimization", "Full", 0 },
+
+  { "InlineFunctionExpansion", "", "Default", "Default", 0 },
+  { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
+  { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
+    0 },
+  { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
+
+  { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
+  { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
+  { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
+
+  { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
+  { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
+  { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
+    0 },
+  { "ExceptionHandling", "", "No", "false", 0 },
+
+  { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
+    0 },
+  { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
+    "UninitializedLocalUsageCheck", 0 },
+  { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
+    "EnableFastChecks", 0 },
+  { "BasicRuntimeChecks", "", "Default", "Default", 0 },
+
+  { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
+  { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
+  { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
+  { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
+    "MultiThreadedDebugDLL", 0 },
+
+  { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
+  { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
+  { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
+  { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
+  { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
+  { "StructMemberAlignment", "", "Default", "Default", 0 },
+
+  { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
+    "StreamingSIMDExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
+    "StreamingSIMDExtensions2", 0 },
+  { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
+    "AdvancedVectorExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
+    "NoExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
+
+  { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
+  { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
+  { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
+
+  { "PrecompiledHeader", "Yc", "Create", "Create",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "Yu", "Use", "Use",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
+
+  { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
+  { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
+  { "AssemblerOutput", "FAc", "Assembly With Machine Code",
+    "AssemblyAndMachineCode", 0 },
+  { "AssemblerOutput", "FAs", "Assembly With Source Code",
+    "AssemblyAndSourceCode", 0 },
+  { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
+
+  { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
+  { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
+  { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
+
+  { "CompileAs", "", "Default", "Default", 0 },
+  { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
+  { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
+
+  { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
+  { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
+    0 },
+  { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
+    0 },
+  { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
+
+  { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
+  { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
+  { "CompileAsManaged", "clr:pure",
+    "Pure MSIL Common Language RunTime Support", "Pure", 0 },
+  { "CompileAsManaged", "clr:safe",
+    "Safe MSIL Common Language RunTime Support", "Safe", 0 },
+  { "CompileAsManaged", "clr:oldSyntax",
+    "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
+
+  // Bool Properties
+  { "CompileAsWinRT", "ZW", "", "true", 0 },
+  { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
+  { "SuppressStartupBanner", "nologo-", "", "false", 0 },
+  { "SuppressStartupBanner", "nologo", "", "true", 0 },
+  { "TreatWarningAsError", "WX-", "", "false", 0 },
+  { "TreatWarningAsError", "WX", "", "true", 0 },
+  { "SDLCheck", "sdl-", "", "false", 0 },
+  { "SDLCheck", "sdl", "", "true", 0 },
+  { "IntrinsicFunctions", "Oi", "", "true", 0 },
+  { "OmitFramePointers", "Oy-", "", "false", 0 },
+  { "OmitFramePointers", "Oy", "", "true", 0 },
+  { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
+  { "WholeProgramOptimization", "GL", "", "true", 0 },
+  { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
+  { "IgnoreStandardIncludePath", "X", "", "true", 0 },
+  { "PreprocessToFile", "P", "", "true", 0 },
+  { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
+  { "PreprocessKeepComments", "C", "", "true", 0 },
+  { "StringPooling", "GF-", "", "false", 0 },
+  { "StringPooling", "GF", "", "true", 0 },
+  { "MinimalRebuild", "Gm-", "", "false", 0 },
+  { "MinimalRebuild", "Gm", "", "true", 0 },
+  { "SmallerTypeCheck", "RTCc", "", "true", 0 },
+  { "BufferSecurityCheck", "GS-", "", "false", 0 },
+  { "BufferSecurityCheck", "GS", "", "true", 0 },
+  { "FunctionLevelLinking", "Gy-", "", "false", 0 },
+  { "FunctionLevelLinking", "Gy", "", "true", 0 },
+  { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
+  { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
+  { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
+  { "FloatingPointExceptions", "fp:except", "", "true", 0 },
+  { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
+  { "DisableLanguageExtensions", "Za", "", "true", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
+  { "RuntimeTypeInfo", "GR-", "", "false", 0 },
+  { "RuntimeTypeInfo", "GR", "", "true", 0 },
+  { "OpenMPSupport", "openmp-", "", "false", 0 },
+  { "OpenMPSupport", "openmp", "", "true", 0 },
+  { "ExpandAttributedSource", "Fx", "", "true", 0 },
+  { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
+  { "ShowIncludes", "showIncludes", "", "true", 0 },
+  { "EnablePREfast", "analyze-", "", "false", 0 },
+  { "EnablePREfast", "analyze", "", "true", 0 },
+  { "UseFullPaths", "FC", "", "true", 0 },
+  { "OmitDefaultLibName", "Zl", "", "true", 0 },
+
+  // Bool Properties With Argument
+  { "MultiProcessorCompilation", "MP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateXMLDocumentationFiles", "doc", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "BrowseInformation", "FR", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "BrowseInformationFile", "FR", "Enable Browse Information", "",
+    cmVS7FlagTable::UserValueRequired },
+
+  // String List Properties
+  { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "UndefinePreprocessorDefinitions", "U",
+    "Undefine Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedIncludeFiles", "FI", "Forced Include File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedUsingFiles", "FU", "Forced #using File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PREfastLog", "analyze:log", "Code Analysis Log", "",
+    cmVS7FlagTable::UserFollowing },
+  { "PREfastAdditionalPlugins", "analyze:plugin",
+    "Additional Code Analysis Native plugins", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+
+  // String Properties
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"PreprocessOutputPath", "Fi",
-   "Preprocess Output Path",
-   "", cmVS7FlagTable::UserValue},
-  {"PrecompiledHeaderFile", "Yc",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderFile", "Yu",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderOutputFile", "Fp",
-   "Precompiled Header Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"AssemblerListingLocation", "Fa",
-   "ASM List Location",
-   "", cmVS7FlagTable::UserValue},
-  {"ObjectFileName", "Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDataBaseFileName", "Fd",
-   "Program Database File Name",
-   "", cmVS7FlagTable::UserValue},
+  { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
+    cmVS7FlagTable::UserValue },
+  { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
+    cmVS7FlagTable::UserValue },
+  { "AssemblerListingLocation", "Fa", "ASM List Location", "",
+    cmVS7FlagTable::UserValue },
+  { "ObjectFileName", "Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [XMLDocumentationFileName] - no command line Switch.
   // Skip [BrowseInformationFile] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS11LibFlagTable.h b/Source/cmVS11LibFlagTable.h
index 9429442..8aacaac 100644
--- a/Source/cmVS11LibFlagTable.h
+++ b/Source/cmVS11LibFlagTable.h
@@ -1,102 +1,76 @@
-static cmVS7FlagTable cmVS11LibFlagTable[] =
-{
+static cmVS7FlagTable cmVS11LibFlagTable[] = {
 
-  //Enum Properties
-  {"ErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"ErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"ErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"ErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  // Enum Properties
+  { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
+    0 },
 
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWSCE",
-   "WindowsCE", "WindowsCE", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
+  // Bool Properties
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
+  { "Verbose", "VERBOSE", "", "true", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
 
-  //Bool Properties
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"TreatLibWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLibWarningAsErrors", "WX", "", "true", 0},
-  {"Verbose", "VERBOSE", "", "true", 0},
-  {"LinkTimeCodeGeneration", "LTCG", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
+  // String List Properties
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ExportNamedFunctions", "EXPORT:",
-   "Export Named Functions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"RemoveObjects", "REMOVE:",
-   "Remove Objects",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "RemoveObjects", "REMOVE:", "Remove Objects", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue},
-  {"DisplayLibrary", "LIST:",
-   "Display Library to standard output",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue },
+  { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"Name", "NAME:",
-   "Name",
-   "", cmVS7FlagTable::UserValue},
+  { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h
index 2d6f6c0..1b3a046 100644
--- a/Source/cmVS11LinkFlagTable.h
+++ b/Source/cmVS11LinkFlagTable.h
@@ -1,341 +1,269 @@
-static cmVS7FlagTable cmVS11LinkFlagTable[] =
-{
+static cmVS7FlagTable cmVS11LinkFlagTable[] = {
 
-  //Enum Properties
-  {"ShowProgress", "",
-   "Not Set", "NotSet", 0},
-  {"ShowProgress", "VERBOSE",
-   "Display all progress messages", "LinkVerbose", 0},
-  {"ShowProgress", "VERBOSE:Lib",
-   "For Libraries Searched", "LinkVerboseLib", 0},
-  {"ShowProgress", "VERBOSE:ICF",
-   "About COMDAT folding during optimized linking", "LinkVerboseICF", 0},
-  {"ShowProgress", "VERBOSE:REF",
-   "About data removed during optimized linking", "LinkVerboseREF", 0},
-  {"ShowProgress", "VERBOSE:SAFESEH",
-   "About Modules incompatible with SEH", "LinkVerboseSAFESEH", 0},
-  {"ShowProgress", "VERBOSE:CLR",
-   "About linker activity related to managed code", "LinkVerboseCLR", 0},
+  // Enum Properties
+  { "ShowProgress", "", "Not Set", "NotSet", 0 },
+  { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
+    0 },
+  { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
+    0 },
+  { "ShowProgress", "VERBOSE:ICF",
+    "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
+  { "ShowProgress", "VERBOSE:REF",
+    "About data removed during optimized linking", "LinkVerboseREF", 0 },
+  { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
+    "LinkVerboseSAFESEH", 0 },
+  { "ShowProgress", "VERBOSE:CLR",
+    "About linker activity related to managed code", "LinkVerboseCLR", 0 },
 
-  {"ForceFileOutput", "FORCE",
-   "Enabled", "Enabled", 0},
-  {"ForceFileOutput", "FORCE:MULTIPLE",
-   "Multiply Defined Symbol Only", "MultiplyDefinedSymbolOnly", 0},
-  {"ForceFileOutput", "FORCE:UNRESOLVED",
-   "Undefined Symbol Only", "UndefinedSymbolOnly", 0},
+  { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
+  { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
+    "MultiplyDefinedSymbolOnly", 0 },
+  { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
+    "UndefinedSymbolOnly", 0 },
 
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN",
-   "Enabled", "Enabled", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:5",
-   "X86 Image Only", "X86Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:6",
-   "X64 Image Only", "X64Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:16",
-   "Itanium Image Only", "ItaniumImage", 0},
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
+    "X86Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
+    "X64Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
+    "ItaniumImage", 0 },
 
-  {"UACExecutionLevel", "level='asInvoker'",
-   "asInvoker", "AsInvoker", 0},
-  {"UACExecutionLevel", "level='highestAvailable'",
-   "highestAvailable", "HighestAvailable", 0},
-  {"UACExecutionLevel", "level='requireAdministrator'",
-   "requireAdministrator", "RequireAdministrator", 0},
+  { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
+  { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
+    "HighestAvailable", 0 },
+  { "UACExecutionLevel", "level='requireAdministrator'",
+    "requireAdministrator", "RequireAdministrator", 0 },
 
-  {"SubSystem", "",
-   "Not Set", "NotSet", 0},
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "", "Not Set", "NotSet", 0 },
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
-  {"Driver", "",
-   "Not Set", "NotSet", 0},
-  {"Driver", "Driver",
-   "Driver", "Driver", 0},
-  {"Driver", "DRIVER:UPONLY",
-   "UP Only", "UpOnly", 0},
-  {"Driver", "DRIVER:WDM",
-   "WDM", "WDM", 0},
+  { "Driver", "", "Not Set", "NotSet", 0 },
+  { "Driver", "Driver", "Driver", "Driver", 0 },
+  { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
+  { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
 
-  {"LinkTimeCodeGeneration", "",
-   "Default", "Default", 0},
-  {"LinkTimeCodeGeneration", "LTCG",
-   "Use Link Time Code Generation", "UseLinkTimeCodeGeneration", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGInstrument",
-   "Profile Guided Optimization - Instrument", "PGInstrument", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGOptimize",
-   "Profile Guided Optimization - Optimization", "PGOptimization", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGUpdate",
-   "Profile Guided Optimization - Update", "PGUpdate", 0},
+  { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
+    "UseLinkTimeCodeGeneration", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
+    "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
+    "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
+    "Profile Guided Optimization - Update", "PGUpdate", 0 },
 
-  {"GenerateWindowsMetadata", "WINMD",
-   "Yes", "true", 0},
-  {"GenerateWindowsMetadata", "WINMD:NO",
-   "No", "false", 0},
+  { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
+  { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
 
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1",
-   "SHA1", "SHA1", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256",
-   "SHA256", "SHA256", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384",
-   "SHA384", "SHA384", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512",
-   "SHA512", "SHA512", 0},
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
 
-  {"TargetMachine", "",
-   "Not Set", "NotSet", 0},
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "", "Not Set", "NotSet", 0 },
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA",
-   "MTA threading attribute", "MTAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA",
-   "STA threading attribute", "STAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
-   "Default threading attribute", "DefaultThreadingAttribute", 0},
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
+    "MTAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
+    "STAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
+    "Default threading attribute", "DefaultThreadingAttribute", 0 },
 
-  {"CLRImageType", "CLRIMAGETYPE:IJW",
-   "Force IJW image", "ForceIJWImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:PURE",
-   "Force Pure IL Image", "ForcePureILImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:SAFE",
-   "Force Safe IL Image", "ForceSafeILImage", 0},
-  {"CLRImageType", "",
-   "Default image type", "Default", 0},
+  { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
+    0 },
+  { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
+    "ForcePureILImage", 0 },
+  { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
+    "ForceSafeILImage", 0 },
+  { "CLRImageType", "", "Default image type", "Default", 0 },
 
-  {"SignHash", "CLRSIGNHASH:SHA1",
-   "SHA1", "SHA1", 0},
-  {"SignHash", "CLRSIGNHASH:SHA256",
-   "SHA256", "SHA256", 0},
-  {"SignHash", "CLRSIGNHASH:SHA384",
-   "SHA384", "SHA384", 0},
-  {"SignHash", "CLRSIGNHASH:SHA512",
-   "SHA512", "SHA512", 0},
+  { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
 
-  {"LinkErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"LinkErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"LinkErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"LinkErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
+    "NoErrorReport", 0 },
 
-  {"CLRSupportLastError", "CLRSupportLastError",
-   "Enabled", "Enabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:NO",
-   "Disabled", "Disabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL",
-   "System Dlls Only", "SystemDlls", 0},
+  { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
+  { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
+    0 },
+  { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
+    "SystemDlls", 0 },
 
+  // Bool Properties
+  { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
+  { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
+  { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
+  { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
+  { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
+  { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
+  { "GenerateManifest", "MANIFEST", "", "true", 0 },
+  { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
+  { "ManifestEmbed", "manifest:embed", "", "true", 0 },
+  { "GenerateDebugInformation", "DEBUG", "", "true",
+    cmVS7FlagTable::CaseInsensitive },
+  { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
+  { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
+  { "TerminalServerAware", "TSAWARE", "", "true", 0 },
+  { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
+  { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
+  { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
+  { "OptimizeReferences", "OPT:REF", "", "true", 0 },
+  { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
+  { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
+  { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
+  { "AppContainer", "APPCONTAINER", "", "true", 0 },
+  { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
+  { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
+  { "NoEntryPoint", "NOENTRY", "", "true", 0 },
+  { "SetChecksum", "RELEASE", "", "true", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
+  { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
+  { "FixedBaseAddress", "FIXED", "", "true", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
+  { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
+  { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
+  { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
+  { "Profile", "PROFILE", "", "true", 0 },
+  { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
+  { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
+  { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
+  { "LinkDLL", "DLL", "", "true", 0 },
 
-  //Bool Properties
-  {"LinkIncremental", "INCREMENTAL:NO", "", "false", 0},
-  {"LinkIncremental", "INCREMENTAL", "", "true", 0},
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"LinkStatus", "LTCG:NOSTATUS", "", "false", 0},
-  {"LinkStatus", "LTCG:STATUS", "", "true", 0},
-  {"PreventDllBinding", "ALLOWBIND:NO", "", "false", 0},
-  {"PreventDllBinding", "ALLOWBIND", "", "true", 0},
-  {"TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLinkerWarningAsErrors", "WX", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"GenerateManifest", "MANIFEST:NO", "", "false", 0},
-  {"GenerateManifest", "MANIFEST", "", "true", 0},
-  {"AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0},
-  {"UACUIAccess", "uiAccess='false'", "", "false", 0},
-  {"UACUIAccess", "uiAccess='true'", "", "true", 0},
-  {"ManifestEmbed", "manifest:embed", "", "true", 0},
-  {"GenerateDebugInformation", "DEBUG", "", "true",
-   cmVS7FlagTable::CaseInsensitive},
-  {"MapExports", "MAPINFO:EXPORTS", "", "true", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0},
-  {"TerminalServerAware", "TSAWARE:NO", "", "false", 0},
-  {"TerminalServerAware", "TSAWARE", "", "true", 0},
-  {"SwapRunFromCD", "SWAPRUN:CD", "", "true", 0},
-  {"SwapRunFromNET", "SWAPRUN:NET", "", "true", 0},
-  {"OptimizeReferences", "OPT:NOREF", "", "false", 0},
-  {"OptimizeReferences", "OPT:REF", "", "true", 0},
-  {"EnableCOMDATFolding", "OPT:NOICF", "", "false", 0},
-  {"EnableCOMDATFolding", "OPT:ICF", "", "true", 0},
-  {"IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0},
-  {"AppContainer", "APPCONTAINER", "", "true", 0},
-  {"WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0},
-  {"WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0},
-  {"NoEntryPoint", "NOENTRY", "", "true", 0},
-  {"SetChecksum", "RELEASE", "", "true", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0},
-  {"FixedBaseAddress", "FIXED:NO", "", "false", 0},
-  {"FixedBaseAddress", "FIXED", "", "true", 0},
-  {"DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0},
-  {"DataExecutionPrevention", "NXCOMPAT", "", "true", 0},
-  {"TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0},
-  {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
-  {"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0},
-  {"Profile", "PROFILE", "", "true", 0},
-  {"LinkDelaySign", "DELAYSIGN:NO", "", "false", 0},
-  {"LinkDelaySign", "DELAYSIGN", "", "true", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
-  {"DetectOneDefinitionRule", "ODR", "", "true", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0},
-  {"LinkDLL", "DLL", "", "true", 0},
+  // Bool Properties With Argument
+  { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
+  { "EnableUAC", "MANIFESTUAC:", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateMapFile", "MAP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "MapFileName", "MAP:", "Generate Map File", "",
+    cmVS7FlagTable::UserValueRequired },
 
-  //Bool Properties With Argument
-  {"EnableUAC", "MANIFESTUAC:NO", "", "false", 0},
-  {"EnableUAC", "MANIFESTUAC:", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateMapFile", "MAP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"MapFileName", "MAP:", "Generate Map File", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AddModuleNamesToAssembly", "ASSEMBLYMODULE:",
-   "Add Module to Assembly",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
-   "Embed Managed Resource File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DelayLoadDLLs", "DELAYLOAD:",
-   "Delay Loaded Dlls",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:",
-   "Assembly Link Resource",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
-   "Additional Manifest Dependencies",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ManifestInput", "manifestinput:",
-   "Manifest Input",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
+    "Embed Managed Resource File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
+    "Additional Manifest Dependencies", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ManifestInput", "manifestinput:", "Manifest Input", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"Version", "VERSION:",
-   "Version",
-   "", cmVS7FlagTable::UserValue},
-  {"SpecifySectionAttributes", "SECTION:",
-   "Specify Section Attributes",
-   "", cmVS7FlagTable::UserValue},
-  {"MSDOSStubFileName", "STUB:",
-   "MS-DOS Stub File Name",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
+  { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
+    cmVS7FlagTable::UserValue },
+  { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File",
-   "", cmVS7FlagTable::UserValue},
-  {"ManifestFile", "ManifestFile:",
-   "Manifest File",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDatabaseFile", "PDB:",
-   "Generate Program Database File",
-   "", cmVS7FlagTable::UserValue},
-  {"StripPrivateSymbols", "PDBSTRIPPED:",
-   "Strip Private Symbols",
-   "", cmVS7FlagTable::UserValue},
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
+    cmVS7FlagTable::UserValue },
+  { "ManifestFile", "ManifestFile:", "Manifest File", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
+    cmVS7FlagTable::UserValue },
+  { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MapFileName] - no command line Switch.
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"HeapReserveSize", "HEAP:",
-   "Heap Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [HeapCommitSize] - no command line Switch.
-  {"StackReserveSize", "STACK:",
-   "Stack Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [StackCommitSize] - no command line Switch.
-  {"FunctionOrder", "ORDER:@",
-   "Function Order",
-   "", cmVS7FlagTable::UserValue},
-  {"ProfileGuidedDatabase", "PGD:",
-   "Profile Guided Database",
-   "", cmVS7FlagTable::UserValue},
-  {"MidlCommandFile", "MIDL:@",
-   "MIDL Commands",
-   "", cmVS7FlagTable::UserValue},
-  {"MergedIDLBaseFileName", "IDLOUT:",
-   "Merged IDL Base File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"TypeLibraryFile", "TLBOUT:",
-   "Type Library",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataFile", "WINMDFILE:",
-   "Windows Metadata File",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataLinkKeyFile", "WINMDKEYFILE:",
-   "Windows Metadata Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
-   "Windows Metadata Key Container",
-   "", cmVS7FlagTable::UserValue},
-  {"EntryPointSymbol", "ENTRY:",
-   "Entry Point",
-   "", cmVS7FlagTable::UserValue},
-  {"BaseAddress", "BASE:",
-   "Base Address",
-   "", cmVS7FlagTable::UserValue},
-  {"ImportLibrary", "IMPLIB:",
-   "Import Library",
-   "", cmVS7FlagTable::UserValue},
-  {"MergeSections", "MERGE:",
-   "Merge Sections",
-   "", cmVS7FlagTable::UserValue},
-  {"LinkKeyFile", "KEYFILE:",
-   "Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"KeyContainer", "KEYCONTAINER:",
-   "Key Container",
-   "", cmVS7FlagTable::UserValue},
+  { "FunctionOrder", "ORDER:@", "Function Order", "",
+    cmVS7FlagTable::UserValue },
+  { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
+    cmVS7FlagTable::UserValue },
+  { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
+    cmVS7FlagTable::UserValue },
+  { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
+    cmVS7FlagTable::UserValue },
+  { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
+    cmVS7FlagTable::UserValue },
+  { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
+    "", cmVS7FlagTable::UserValue },
+  { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
+    "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
+  { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
+    cmVS7FlagTable::UserValue },
+  { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
+  { "ImportLibrary", "IMPLIB:", "Import Library", "",
+    cmVS7FlagTable::UserValue },
+  { "MergeSections", "MERGE:", "Merge Sections", "",
+    cmVS7FlagTable::UserValue },
+  { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
+  { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
+    cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS11MASMFlagTable.h b/Source/cmVS11MASMFlagTable.h
index 2ff95ad..1aca169 100644
--- a/Source/cmVS11MASMFlagTable.h
+++ b/Source/cmVS11MASMFlagTable.h
@@ -1,96 +1,78 @@
-static cmVS7FlagTable cmVS11MASMFlagTable[] =
-{
+static cmVS7FlagTable cmVS11MASMFlagTable[] = {
 
-  //Enum Properties
-  {"PreserveIdentifierCase", "",
-   "Default", "0", 0},
-  {"PreserveIdentifierCase", "/Cp",
-   "Preserves Identifier Case (/Cp)", "1", 0},
-  {"PreserveIdentifierCase", "/Cu",
-   "Maps all identifiers to upper case. (/Cu)", "2", 0},
-  {"PreserveIdentifierCase", "/Cx",
-   "Preserves case in public and extern symbols. (/Cx)", "3", 0},
+  // Enum Properties
+  { "PreserveIdentifierCase", "", "Default", "0", 0 },
+  { "PreserveIdentifierCase", "/Cp", "Preserves Identifier Case (/Cp)", "1",
+    0 },
+  { "PreserveIdentifierCase", "/Cu",
+    "Maps all identifiers to upper case. (/Cu)", "2", 0 },
+  { "PreserveIdentifierCase", "/Cx",
+    "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
 
-  {"WarningLevel", "/W0",
-   "Warning Level 0 (/W0)", "0", 0},
-  {"WarningLevel", "/W1",
-   "Warning Level 1 (/W1)", "1", 0},
-  {"WarningLevel", "/W2",
-   "Warning Level 2 (/W2)", "2", 0},
-  {"WarningLevel", "/W3",
-   "Warning Level 3 (/W3)", "3", 0},
+  { "WarningLevel", "/W0", "Warning Level 0 (/W0)", "0", 0 },
+  { "WarningLevel", "/W1", "Warning Level 1 (/W1)", "1", 0 },
+  { "WarningLevel", "/W2", "Warning Level 2 (/W2)", "2", 0 },
+  { "WarningLevel", "/W3", "Warning Level 3 (/W3)", "3", 0 },
 
-  {"PackAlignmentBoundary", "",
-   "Default", "0", 0},
-  {"PackAlignmentBoundary", "/Zp1",
-   "One Byte Boundary (/Zp1)", "1", 0},
-  {"PackAlignmentBoundary", "/Zp2",
-   "Two Byte Boundary (/Zp2)", "2", 0},
-  {"PackAlignmentBoundary", "/Zp4",
-   "Four Byte Boundary (/Zp4)", "3", 0},
-  {"PackAlignmentBoundary", "/Zp8",
-   "Eight Byte Boundary (/Zp8)", "4", 0},
-  {"PackAlignmentBoundary", "/Zp16",
-   "Sixteen Byte Boundary (/Zp16)", "5", 0},
+  { "PackAlignmentBoundary", "", "Default", "0", 0 },
+  { "PackAlignmentBoundary", "/Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
+  { "PackAlignmentBoundary", "/Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
+  { "PackAlignmentBoundary", "/Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
+  { "PackAlignmentBoundary", "/Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
+  { "PackAlignmentBoundary", "/Zp16", "Sixteen Byte Boundary (/Zp16)", "5",
+    0 },
 
-  {"CallingConvention", "",
-   "Default", "0", 0},
-  {"CallingConvention", "/Gd",
-   "Use C-style Calling Convention (/Gd)", "1", 0},
-  {"CallingConvention", "/Gz",
-   "Use stdcall Calling Convention (/Gz)", "2", 0},
-  {"CallingConvention", "/Gc",
-   "Use Pascal Calling Convention (/Gc)", "3", 0},
+  { "CallingConvention", "", "Default", "0", 0 },
+  { "CallingConvention", "/Gd", "Use C-style Calling Convention (/Gd)", "1",
+    0 },
+  { "CallingConvention", "/Gz", "Use stdcall Calling Convention (/Gz)", "2",
+    0 },
+  { "CallingConvention", "/Gc", "Use Pascal Calling Convention (/Gc)", "3",
+    0 },
 
-  {"ErrorReporting", "/errorReport:prompt",
-   "Prompt to send report immediately (/errorReport:prompt)", "0", 0},
-  {"ErrorReporting", "/errorReport:queue",
-   "Prompt to send report at the next logon (/errorReport:queue)", "1", 0},
-  {"ErrorReporting", "/errorReport:send",
-   "Automatically send report (/errorReport:send)", "2", 0},
-  {"ErrorReporting", "/errorReport:none",
-   "Do not send report (/errorReport:none)", "3", 0},
+  { "ErrorReporting", "/errorReport:prompt",
+    "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
+  { "ErrorReporting", "/errorReport:queue",
+    "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
+  { "ErrorReporting", "/errorReport:send",
+    "Automatically send report (/errorReport:send)", "2", 0 },
+  { "ErrorReporting", "/errorReport:none",
+    "Do not send report (/errorReport:none)", "3", 0 },
 
+  // Bool Properties
+  { "NoLogo", "/nologo", "", "true", 0 },
+  { "GeneratePreprocessedSourceListing", "/EP", "", "true", 0 },
+  { "ListAllAvailableInformation", "/Sa", "", "true", 0 },
+  { "UseSafeExceptionHandlers", "/safeseh", "", "true", 0 },
+  { "AddFirstPassListing", "/Sf", "", "true", 0 },
+  { "EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0 },
+  { "DisableSymbolTable", "/Sn", "", "true", 0 },
+  { "EnableFalseConditionalsInListing", "/Sx", "", "true", 0 },
+  { "TreatWarningsAsErrors", "/WX", "", "true", 0 },
+  { "MakeAllSymbolsPublic", "/Zf", "", "true", 0 },
+  { "GenerateDebugInformation", "/Zi", "", "true", 0 },
+  { "EnableMASM51Compatibility", "/Zm", "", "true", 0 },
+  { "PerformSyntaxCheckOnly", "/Zs", "", "true", 0 },
 
-  //Bool Properties
-  {"NoLogo", "/nologo", "", "true", 0},
-  {"GeneratePreprocessedSourceListing", "/EP", "", "true", 0},
-  {"ListAllAvailableInformation", "/Sa", "", "true", 0},
-  {"UseSafeExceptionHandlers", "/safeseh", "", "true", 0},
-  {"AddFirstPassListing", "/Sf", "", "true", 0},
-  {"EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0},
-  {"DisableSymbolTable", "/Sn", "", "true", 0},
-  {"EnableFalseConditionalsInListing", "/Sx", "", "true", 0},
-  {"TreatWarningsAsErrors", "/WX", "", "true", 0},
-  {"MakeAllSymbolsPublic", "/Zf", "", "true", 0},
-  {"GenerateDebugInformation", "/Zi", "", "true", 0},
-  {"EnableMASM51Compatibility", "/Zm", "", "true", 0},
-  {"PerformSyntaxCheckOnly", "/Zs", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
-  {"PreprocessorDefinitions", "/D",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IncludePaths", "/I",
-   "Include Paths",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"BrowseFile", "/FR",
-   "Generate Browse Information File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "PreprocessorDefinitions", "/D", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IncludePaths", "/I", "Include Paths", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "BrowseFile", "/FR", "Generate Browse Information File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
 
-  //String Properties
+  // String Properties
   // Skip [Inputs] - no command line Switch.
-  {"ObjectFileName", "/Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"AssembledCodeListingFile", "/Fl",
-   "Assembled Code Listing File",
-   "", cmVS7FlagTable::UserValue},
+  { "ObjectFileName", "/Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "AssembledCodeListingFile", "/Fl", "Assembled Code Listing File", "",
+    cmVS7FlagTable::UserValue },
   // Skip [CommandLineTemplate] - no command line Switch.
   // Skip [ExecutionDescription] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS11RCFlagTable.h b/Source/cmVS11RCFlagTable.h
index a7d2de1..666e434 100644
--- a/Source/cmVS11RCFlagTable.h
+++ b/Source/cmVS11RCFlagTable.h
@@ -1,7 +1,6 @@
-static cmVS7FlagTable cmVS11RCFlagTable[] =
-{
-  //Bool Properties
-  {"NullTerminateStrings", "n", "", "true", 0},
+static cmVS7FlagTable cmVS11RCFlagTable[] = {
+  // Bool Properties
+  { "NullTerminateStrings", "n", "", "true", 0 },
 
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h
index 0a7916f..9515c91 100644
--- a/Source/cmVS12CLFlagTable.h
+++ b/Source/cmVS12CLFlagTable.h
@@ -1,294 +1,221 @@
-static cmVS7FlagTable cmVS12CLFlagTable[] =
-{
-
-  //Enum Properties
-  {"DebugInformationFormat", "",
-   "None", "None", 0},
-  {"DebugInformationFormat", "Z7",
-   "C7 compatible", "OldStyle", 0},
-  {"DebugInformationFormat", "Zi",
-   "Program Database", "ProgramDatabase", 0},
-  {"DebugInformationFormat", "ZI",
-   "Program Database for Edit And Continue", "EditAndContinue", 0},
-
-  {"WarningLevel", "W0",
-   "Turn Off All Warnings", "TurnOffAllWarnings", 0},
-  {"WarningLevel", "W1",
-   "Level1", "Level1", 0},
-  {"WarningLevel", "W2",
-   "Level2", "Level2", 0},
-  {"WarningLevel", "W3",
-   "Level3", "Level3", 0},
-  {"WarningLevel", "W4",
-   "Level4", "Level4", 0},
-  {"WarningLevel", "Wall",
-   "EnableAllWarnings", "EnableAllWarnings", 0},
-
-  {"Optimization", "",
-   "Custom", "Custom", 0},
-  {"Optimization", "Od",
-   "Disabled", "Disabled", 0},
-  {"Optimization", "O1",
-   "Minimize Size", "MinSpace", 0},
-  {"Optimization", "O2",
-   "Maximize Speed", "MaxSpeed", 0},
-  {"Optimization", "Ox",
-   "Full Optimization", "Full", 0},
-
-  {"InlineFunctionExpansion", "",
-   "Default", "Default", 0},
-  {"InlineFunctionExpansion", "Ob0",
-   "Disabled", "Disabled", 0},
-  {"InlineFunctionExpansion", "Ob1",
-   "Only __inline", "OnlyExplicitInline", 0},
-  {"InlineFunctionExpansion", "Ob2",
-   "Any Suitable", "AnySuitable", 0},
-
-  {"FavorSizeOrSpeed", "Os",
-   "Favor small code", "Size", 0},
-  {"FavorSizeOrSpeed", "Ot",
-   "Favor fast code", "Speed", 0},
-  {"FavorSizeOrSpeed", "",
-   "Neither", "Neither", 0},
-
-  {"ExceptionHandling", "EHa",
-   "Yes with SEH Exceptions", "Async", 0},
-  {"ExceptionHandling", "EHsc",
-   "Yes", "Sync", 0},
-  {"ExceptionHandling", "EHs",
-   "Yes with Extern C functions", "SyncCThrow", 0},
-  {"ExceptionHandling", "",
-   "No", "false", 0},
-
-  {"BasicRuntimeChecks", "RTCs",
-   "Stack Frames", "StackFrameRuntimeCheck", 0},
-  {"BasicRuntimeChecks", "RTCu",
-   "Uninitialized variables", "UninitializedLocalUsageCheck", 0},
-  {"BasicRuntimeChecks", "RTC1",
-   "Both (/RTC1, equiv. to /RTCsu)", "EnableFastChecks", 0},
-  {"BasicRuntimeChecks", "",
-   "Default", "Default", 0},
-
-  {"RuntimeLibrary", "MT",
-   "Multi-threaded", "MultiThreaded", 0},
-  {"RuntimeLibrary", "MTd",
-   "Multi-threaded Debug", "MultiThreadedDebug", 0},
-  {"RuntimeLibrary", "MD",
-   "Multi-threaded DLL", "MultiThreadedDLL", 0},
-  {"RuntimeLibrary", "MDd",
-   "Multi-threaded Debug DLL", "MultiThreadedDebugDLL", 0},
-
-  {"StructMemberAlignment", "Zp1",
-   "1 Byte", "1Byte", 0},
-  {"StructMemberAlignment", "Zp2",
-   "2 Bytes", "2Bytes", 0},
-  {"StructMemberAlignment", "Zp4",
-   "4 Byte", "4Bytes", 0},
-  {"StructMemberAlignment", "Zp8",
-   "8 Bytes", "8Bytes", 0},
-  {"StructMemberAlignment", "Zp16",
-   "16 Bytes", "16Bytes", 0},
-  {"StructMemberAlignment", "",
-   "Default", "Default", 0},
-
-  {"BufferSecurityCheck", "GS-",
-   "Disable Security Check", "false", 0},
-  {"BufferSecurityCheck", "GS",
-   "Enable Security Check", "true", 0},
-
-  {"EnableEnhancedInstructionSet", "arch:SSE",
-   "Streaming SIMD Extensions", "StreamingSIMDExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:SSE2",
-   "Streaming SIMD Extensions 2", "StreamingSIMDExtensions2", 0},
-  {"EnableEnhancedInstructionSet", "arch:AVX",
-   "Advanced Vector Extensions", "AdvancedVectorExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:IA32",
-   "No Enhanced Instructions", "NoExtensions", 0},
-  {"EnableEnhancedInstructionSet", "",
-   "Not Set", "NotSet", 0},
-
-  {"FloatingPointModel", "fp:precise",
-   "Precise", "Precise", 0},
-  {"FloatingPointModel", "fp:strict",
-   "Strict", "Strict", 0},
-  {"FloatingPointModel", "fp:fast",
-   "Fast", "Fast", 0},
-
-  {"PrecompiledHeader", "Yc",
-   "Create", "Create",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "Yu",
-   "Use", "Use",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "",
-   "Not Using Precompiled Headers", "NotUsing", 0},
-
-  {"AssemblerOutput", "",
-   "No Listing", "NoListing", 0},
-  {"AssemblerOutput", "FA",
-   "Assembly-Only Listing", "AssemblyCode", 0},
-  {"AssemblerOutput", "FAc",
-   "Assembly With Machine Code", "AssemblyAndMachineCode", 0},
-  {"AssemblerOutput", "FAs",
-   "Assembly With Source Code", "AssemblyAndSourceCode", 0},
-  {"AssemblerOutput", "FAcs",
-   "Assembly, Machine Code and Source", "All", 0},
-
-  {"CallingConvention", "Gd",
-   "__cdecl", "Cdecl", 0},
-  {"CallingConvention", "Gr",
-   "__fastcall", "FastCall", 0},
-  {"CallingConvention", "Gz",
-   "__stdcall", "StdCall", 0},
-  {"CallingConvention", "Gv",
-   "__vectorcall", "VectorCall", 0},
-
-  {"CompileAs", "",
-   "Default", "Default", 0},
-  {"CompileAs", "TC",
-   "Compile as C Code", "CompileAsC", 0},
-  {"CompileAs", "TP",
-   "Compile as C++ Code", "CompileAsCpp", 0},
-
-  {"ErrorReporting", "errorReport:none",
-   "Do Not Send Report", "None", 0},
-  {"ErrorReporting", "errorReport:prompt",
-   "Prompt Immediately", "Prompt", 0},
-  {"ErrorReporting", "errorReport:queue",
-   "Queue For Next Login", "Queue", 0},
-  {"ErrorReporting", "errorReport:send",
-   "Send Automatically", "Send", 0},
-
-  {"CompileAsManaged", "",
-   "No Common Language RunTime Support", "false", 0},
-  {"CompileAsManaged", "clr",
-   "Common Language RunTime Support", "true", 0},
-  {"CompileAsManaged", "clr:pure",
-   "Pure MSIL Common Language RunTime Support", "Pure", 0},
-  {"CompileAsManaged", "clr:safe",
-   "Safe MSIL Common Language RunTime Support", "Safe", 0},
-  {"CompileAsManaged", "clr:oldSyntax",
-   "Common Language RunTime Support, Old Syntax", "OldSyntax", 0},
-
-
-  //Bool Properties
-  {"CompileAsWinRT", "ZW", "", "true", 0},
-  {"WinRTNoStdLib", "ZW:nostdlib", "", "true", 0},
-  {"SuppressStartupBanner", "nologo", "", "true", 0},
-  {"TreatWarningAsError", "WX-", "", "false", 0},
-  {"TreatWarningAsError", "WX", "", "true", 0},
-  {"SDLCheck", "sdl-", "", "false", 0},
-  {"SDLCheck", "sdl", "", "true", 0},
-  {"IntrinsicFunctions", "Oi", "", "true", 0},
-  {"OmitFramePointers", "Oy-", "", "false", 0},
-  {"OmitFramePointers", "Oy", "", "true", 0},
-  {"EnableFiberSafeOptimizations", "GT", "", "true", 0},
-  {"WholeProgramOptimization", "GL", "", "true", 0},
-  {"UndefineAllPreprocessorDefinitions", "u", "", "true", 0},
-  {"IgnoreStandardIncludePath", "X", "", "true", 0},
-  {"PreprocessToFile", "P", "", "true", 0},
-  {"PreprocessSuppressLineNumbers", "EP", "", "true", 0},
-  {"PreprocessKeepComments", "C", "", "true", 0},
-  {"StringPooling", "GF-", "", "false", 0},
-  {"StringPooling", "GF", "", "true", 0},
-  {"MinimalRebuild", "Gm-", "", "false", 0},
-  {"MinimalRebuild", "Gm", "", "true", 0},
-  {"SmallerTypeCheck", "RTCc", "", "true", 0},
-  {"FunctionLevelLinking", "Gy-", "", "false", 0},
-  {"FunctionLevelLinking", "Gy", "", "true", 0},
-  {"EnableParallelCodeGeneration", "Qpar-", "", "false", 0},
-  {"EnableParallelCodeGeneration", "Qpar", "", "true", 0},
-  {"FloatingPointExceptions", "fp:except-", "", "false", 0},
-  {"FloatingPointExceptions", "fp:except", "", "true", 0},
-  {"CreateHotpatchableImage", "hotpatch", "", "true", 0},
-  {"DisableLanguageExtensions", "Za", "", "true", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0},
-  {"RuntimeTypeInfo", "GR-", "", "false", 0},
-  {"RuntimeTypeInfo", "GR", "", "true", 0},
-  {"OpenMPSupport", "openmp-", "", "false", 0},
-  {"OpenMPSupport", "openmp", "", "true", 0},
-  {"ExpandAttributedSource", "Fx", "", "true", 0},
-  {"UseUnicodeForAssemblerListing", "FAu", "", "true", 0},
-  {"ShowIncludes", "showIncludes", "", "true", 0},
-  {"EnablePREfast", "analyze-", "", "false", 0},
-  {"EnablePREfast", "analyze", "", "true", 0},
-  {"UseFullPaths", "FC", "", "true", 0},
-  {"OmitDefaultLibName", "Zl", "", "true", 0},
-
-  //Bool Properties With Argument
-  {"MultiProcessorCompilation", "MP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"ProcessorNumber", "MP", "Multi-processor Compilation", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateXMLDocumentationFiles", "doc", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"BrowseInformation", "FR", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"BrowseInformationFile", "FR", "Enable Browse Information", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalIncludeDirectories", "I",
-   "Additional Include Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalUsingDirectories", "AI",
-   "Additional #using Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PreprocessorDefinitions", "D ",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"UndefinePreprocessorDefinitions", "U",
-   "Undefine Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DisableSpecificWarnings", "wd",
-   "Disable Specific Warnings",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedIncludeFiles", "FI",
-   "Forced Include File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedUsingFiles", "FU",
-   "Forced #using File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PREfastLog", "analyze:log",
-   "Code Analysis Log",
-   "", cmVS7FlagTable::UserFollowing},
-  {"PREfastAdditionalPlugins", "analyze:plugin",
-   "Additional Code Analysis Native plugins",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"TreatSpecificWarningsAsErrors", "we",
-   "Treat Specific Warnings As Errors",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-
-  //String Properties
+static cmVS7FlagTable cmVS12CLFlagTable[] = {
+
+  // Enum Properties
+  { "DebugInformationFormat", "", "None", "None", 0 },
+  { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
+  { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
+  { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
+    "EditAndContinue", 0 },
+
+  { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
+  { "WarningLevel", "W1", "Level1", "Level1", 0 },
+  { "WarningLevel", "W2", "Level2", "Level2", 0 },
+  { "WarningLevel", "W3", "Level3", "Level3", 0 },
+  { "WarningLevel", "W4", "Level4", "Level4", 0 },
+  { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
+
+  { "Optimization", "", "Custom", "Custom", 0 },
+  { "Optimization", "Od", "Disabled", "Disabled", 0 },
+  { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
+  { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
+  { "Optimization", "Ox", "Full Optimization", "Full", 0 },
+
+  { "InlineFunctionExpansion", "", "Default", "Default", 0 },
+  { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
+  { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
+    0 },
+  { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
+
+  { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
+  { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
+  { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
+
+  { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
+  { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
+  { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
+    0 },
+  { "ExceptionHandling", "", "No", "false", 0 },
+
+  { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
+    0 },
+  { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
+    "UninitializedLocalUsageCheck", 0 },
+  { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
+    "EnableFastChecks", 0 },
+  { "BasicRuntimeChecks", "", "Default", "Default", 0 },
+
+  { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
+  { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
+  { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
+  { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
+    "MultiThreadedDebugDLL", 0 },
+
+  { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
+  { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
+  { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
+  { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
+  { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
+  { "StructMemberAlignment", "", "Default", "Default", 0 },
+
+  { "BufferSecurityCheck", "GS-", "Disable Security Check", "false", 0 },
+  { "BufferSecurityCheck", "GS", "Enable Security Check", "true", 0 },
+
+  { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
+    "StreamingSIMDExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
+    "StreamingSIMDExtensions2", 0 },
+  { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
+    "AdvancedVectorExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
+    "NoExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
+
+  { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
+  { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
+  { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
+
+  { "PrecompiledHeader", "Yc", "Create", "Create",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "Yu", "Use", "Use",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
+
+  { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
+  { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
+  { "AssemblerOutput", "FAc", "Assembly With Machine Code",
+    "AssemblyAndMachineCode", 0 },
+  { "AssemblerOutput", "FAs", "Assembly With Source Code",
+    "AssemblyAndSourceCode", 0 },
+  { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
+
+  { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
+  { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
+  { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
+  { "CallingConvention", "Gv", "__vectorcall", "VectorCall", 0 },
+
+  { "CompileAs", "", "Default", "Default", 0 },
+  { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
+  { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
+
+  { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
+  { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
+    0 },
+  { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
+    0 },
+  { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
+
+  { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
+  { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
+  { "CompileAsManaged", "clr:pure",
+    "Pure MSIL Common Language RunTime Support", "Pure", 0 },
+  { "CompileAsManaged", "clr:safe",
+    "Safe MSIL Common Language RunTime Support", "Safe", 0 },
+  { "CompileAsManaged", "clr:oldSyntax",
+    "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
+
+  // Bool Properties
+  { "CompileAsWinRT", "ZW", "", "true", 0 },
+  { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
+  { "SuppressStartupBanner", "nologo", "", "true", 0 },
+  { "TreatWarningAsError", "WX-", "", "false", 0 },
+  { "TreatWarningAsError", "WX", "", "true", 0 },
+  { "SDLCheck", "sdl-", "", "false", 0 },
+  { "SDLCheck", "sdl", "", "true", 0 },
+  { "IntrinsicFunctions", "Oi", "", "true", 0 },
+  { "OmitFramePointers", "Oy-", "", "false", 0 },
+  { "OmitFramePointers", "Oy", "", "true", 0 },
+  { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
+  { "WholeProgramOptimization", "GL", "", "true", 0 },
+  { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
+  { "IgnoreStandardIncludePath", "X", "", "true", 0 },
+  { "PreprocessToFile", "P", "", "true", 0 },
+  { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
+  { "PreprocessKeepComments", "C", "", "true", 0 },
+  { "StringPooling", "GF-", "", "false", 0 },
+  { "StringPooling", "GF", "", "true", 0 },
+  { "MinimalRebuild", "Gm-", "", "false", 0 },
+  { "MinimalRebuild", "Gm", "", "true", 0 },
+  { "SmallerTypeCheck", "RTCc", "", "true", 0 },
+  { "FunctionLevelLinking", "Gy-", "", "false", 0 },
+  { "FunctionLevelLinking", "Gy", "", "true", 0 },
+  { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
+  { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
+  { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
+  { "FloatingPointExceptions", "fp:except", "", "true", 0 },
+  { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
+  { "DisableLanguageExtensions", "Za", "", "true", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
+  { "RuntimeTypeInfo", "GR-", "", "false", 0 },
+  { "RuntimeTypeInfo", "GR", "", "true", 0 },
+  { "OpenMPSupport", "openmp-", "", "false", 0 },
+  { "OpenMPSupport", "openmp", "", "true", 0 },
+  { "ExpandAttributedSource", "Fx", "", "true", 0 },
+  { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
+  { "ShowIncludes", "showIncludes", "", "true", 0 },
+  { "EnablePREfast", "analyze-", "", "false", 0 },
+  { "EnablePREfast", "analyze", "", "true", 0 },
+  { "UseFullPaths", "FC", "", "true", 0 },
+  { "OmitDefaultLibName", "Zl", "", "true", 0 },
+
+  // Bool Properties With Argument
+  { "MultiProcessorCompilation", "MP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateXMLDocumentationFiles", "doc", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "BrowseInformation", "FR", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "BrowseInformationFile", "FR", "Enable Browse Information", "",
+    cmVS7FlagTable::UserValueRequired },
+
+  // String List Properties
+  { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "UndefinePreprocessorDefinitions", "U",
+    "Undefine Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedIncludeFiles", "FI", "Forced Include File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedUsingFiles", "FU", "Forced #using File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PREfastLog", "analyze:log", "Code Analysis Log", "",
+    cmVS7FlagTable::UserFollowing },
+  { "PREfastAdditionalPlugins", "analyze:plugin",
+    "Additional Code Analysis Native plugins", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+
+  // String Properties
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"PreprocessOutputPath", "Fi",
-   "Preprocess Output Path",
-   "", cmVS7FlagTable::UserValue},
-  {"PrecompiledHeaderFile", "Yc",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderFile", "Yu",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderOutputFile", "Fp",
-   "Precompiled Header Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"AssemblerListingLocation", "Fa",
-   "ASM List Location",
-   "", cmVS7FlagTable::UserValue},
-  {"ObjectFileName", "Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDataBaseFileName", "Fd",
-   "Program Database File Name",
-   "", cmVS7FlagTable::UserValue},
+  { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
+    cmVS7FlagTable::UserValue },
+  { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
+    cmVS7FlagTable::UserValue },
+  { "AssemblerListingLocation", "Fa", "ASM List Location", "",
+    cmVS7FlagTable::UserValue },
+  { "ObjectFileName", "Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [XMLDocumentationFileName] - no command line Switch.
   // Skip [BrowseInformationFile] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS12LibFlagTable.h b/Source/cmVS12LibFlagTable.h
index 10bb805..0f7a259 100644
--- a/Source/cmVS12LibFlagTable.h
+++ b/Source/cmVS12LibFlagTable.h
@@ -1,102 +1,76 @@
-static cmVS7FlagTable cmVS12LibFlagTable[] =
-{
+static cmVS7FlagTable cmVS12LibFlagTable[] = {
 
-  //Enum Properties
-  {"ErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"ErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"ErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"ErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  // Enum Properties
+  { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
+    0 },
 
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWSCE",
-   "WindowsCE", "WindowsCE", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
+  // Bool Properties
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
+  { "Verbose", "VERBOSE", "", "true", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
 
-  //Bool Properties
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"TreatLibWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLibWarningAsErrors", "WX", "", "true", 0},
-  {"Verbose", "VERBOSE", "", "true", 0},
-  {"LinkTimeCodeGeneration", "LTCG", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
+  // String List Properties
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ExportNamedFunctions", "EXPORT:",
-   "Export Named Functions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"RemoveObjects", "REMOVE:",
-   "Remove Objects",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "RemoveObjects", "REMOVE:", "Remove Objects", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue},
-  {"DisplayLibrary", "LIST:",
-   "Display Library to standard output",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue },
+  { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"Name", "NAME:",
-   "Name",
-   "", cmVS7FlagTable::UserValue},
+  { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h
index 0be5e34..168c34c 100644
--- a/Source/cmVS12LinkFlagTable.h
+++ b/Source/cmVS12LinkFlagTable.h
@@ -1,341 +1,269 @@
-static cmVS7FlagTable cmVS12LinkFlagTable[] =
-{
+static cmVS7FlagTable cmVS12LinkFlagTable[] = {
 
-  //Enum Properties
-  {"ShowProgress", "",
-   "Not Set", "NotSet", 0},
-  {"ShowProgress", "VERBOSE",
-   "Display all progress messages", "LinkVerbose", 0},
-  {"ShowProgress", "VERBOSE:Lib",
-   "For Libraries Searched", "LinkVerboseLib", 0},
-  {"ShowProgress", "VERBOSE:ICF",
-   "About COMDAT folding during optimized linking", "LinkVerboseICF", 0},
-  {"ShowProgress", "VERBOSE:REF",
-   "About data removed during optimized linking", "LinkVerboseREF", 0},
-  {"ShowProgress", "VERBOSE:SAFESEH",
-   "About Modules incompatible with SEH", "LinkVerboseSAFESEH", 0},
-  {"ShowProgress", "VERBOSE:CLR",
-   "About linker activity related to managed code", "LinkVerboseCLR", 0},
+  // Enum Properties
+  { "ShowProgress", "", "Not Set", "NotSet", 0 },
+  { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
+    0 },
+  { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
+    0 },
+  { "ShowProgress", "VERBOSE:ICF",
+    "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
+  { "ShowProgress", "VERBOSE:REF",
+    "About data removed during optimized linking", "LinkVerboseREF", 0 },
+  { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
+    "LinkVerboseSAFESEH", 0 },
+  { "ShowProgress", "VERBOSE:CLR",
+    "About linker activity related to managed code", "LinkVerboseCLR", 0 },
 
-  {"ForceFileOutput", "FORCE",
-   "Enabled", "Enabled", 0},
-  {"ForceFileOutput", "FORCE:MULTIPLE",
-   "Multiply Defined Symbol Only", "MultiplyDefinedSymbolOnly", 0},
-  {"ForceFileOutput", "FORCE:UNRESOLVED",
-   "Undefined Symbol Only", "UndefinedSymbolOnly", 0},
+  { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
+  { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
+    "MultiplyDefinedSymbolOnly", 0 },
+  { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
+    "UndefinedSymbolOnly", 0 },
 
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN",
-   "Enabled", "Enabled", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:5",
-   "X86 Image Only", "X86Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:6",
-   "X64 Image Only", "X64Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:16",
-   "Itanium Image Only", "ItaniumImage", 0},
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
+    "X86Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
+    "X64Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
+    "ItaniumImage", 0 },
 
-  {"UACExecutionLevel", "level='asInvoker'",
-   "asInvoker", "AsInvoker", 0},
-  {"UACExecutionLevel", "level='highestAvailable'",
-   "highestAvailable", "HighestAvailable", 0},
-  {"UACExecutionLevel", "level='requireAdministrator'",
-   "requireAdministrator", "RequireAdministrator", 0},
+  { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
+  { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
+    "HighestAvailable", 0 },
+  { "UACExecutionLevel", "level='requireAdministrator'",
+    "requireAdministrator", "RequireAdministrator", 0 },
 
-  {"SubSystem", "",
-   "Not Set", "NotSet", 0},
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "", "Not Set", "NotSet", 0 },
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
-  {"Driver", "",
-   "Not Set", "NotSet", 0},
-  {"Driver", "Driver",
-   "Driver", "Driver", 0},
-  {"Driver", "DRIVER:UPONLY",
-   "UP Only", "UpOnly", 0},
-  {"Driver", "DRIVER:WDM",
-   "WDM", "WDM", 0},
+  { "Driver", "", "Not Set", "NotSet", 0 },
+  { "Driver", "Driver", "Driver", "Driver", 0 },
+  { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
+  { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
 
-  {"LinkTimeCodeGeneration", "",
-   "Default", "Default", 0},
-  {"LinkTimeCodeGeneration", "LTCG",
-   "Use Link Time Code Generation", "UseLinkTimeCodeGeneration", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGInstrument",
-   "Profile Guided Optimization - Instrument", "PGInstrument", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGOptimize",
-   "Profile Guided Optimization - Optimization", "PGOptimization", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGUpdate",
-   "Profile Guided Optimization - Update", "PGUpdate", 0},
+  { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
+    "UseLinkTimeCodeGeneration", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
+    "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
+    "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
+    "Profile Guided Optimization - Update", "PGUpdate", 0 },
 
-  {"GenerateWindowsMetadata", "WINMD",
-   "Yes", "true", 0},
-  {"GenerateWindowsMetadata", "WINMD:NO",
-   "No", "false", 0},
+  { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
+  { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
 
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1",
-   "SHA1", "SHA1", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256",
-   "SHA256", "SHA256", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384",
-   "SHA384", "SHA384", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512",
-   "SHA512", "SHA512", 0},
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
 
-  {"TargetMachine", "",
-   "Not Set", "NotSet", 0},
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "", "Not Set", "NotSet", 0 },
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA",
-   "MTA threading attribute", "MTAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA",
-   "STA threading attribute", "STAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
-   "Default threading attribute", "DefaultThreadingAttribute", 0},
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
+    "MTAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
+    "STAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
+    "Default threading attribute", "DefaultThreadingAttribute", 0 },
 
-  {"CLRImageType", "CLRIMAGETYPE:IJW",
-   "Force IJW image", "ForceIJWImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:PURE",
-   "Force Pure IL Image", "ForcePureILImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:SAFE",
-   "Force Safe IL Image", "ForceSafeILImage", 0},
-  {"CLRImageType", "",
-   "Default image type", "Default", 0},
+  { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
+    0 },
+  { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
+    "ForcePureILImage", 0 },
+  { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
+    "ForceSafeILImage", 0 },
+  { "CLRImageType", "", "Default image type", "Default", 0 },
 
-  {"SignHash", "CLRSIGNHASH:SHA1",
-   "SHA1", "SHA1", 0},
-  {"SignHash", "CLRSIGNHASH:SHA256",
-   "SHA256", "SHA256", 0},
-  {"SignHash", "CLRSIGNHASH:SHA384",
-   "SHA384", "SHA384", 0},
-  {"SignHash", "CLRSIGNHASH:SHA512",
-   "SHA512", "SHA512", 0},
+  { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
 
-  {"LinkErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"LinkErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"LinkErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"LinkErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
+    "NoErrorReport", 0 },
 
-  {"CLRSupportLastError", "CLRSupportLastError",
-   "Enabled", "Enabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:NO",
-   "Disabled", "Disabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL",
-   "System Dlls Only", "SystemDlls", 0},
+  { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
+  { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
+    0 },
+  { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
+    "SystemDlls", 0 },
 
+  // Bool Properties
+  { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
+  { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
+  { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
+  { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
+  { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
+  { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
+  { "GenerateManifest", "MANIFEST", "", "true", 0 },
+  { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
+  { "ManifestEmbed", "manifest:embed", "", "true", 0 },
+  { "GenerateDebugInformation", "DEBUG", "", "true",
+    cmVS7FlagTable::CaseInsensitive },
+  { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
+  { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
+  { "TerminalServerAware", "TSAWARE", "", "true", 0 },
+  { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
+  { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
+  { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
+  { "OptimizeReferences", "OPT:REF", "", "true", 0 },
+  { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
+  { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
+  { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
+  { "AppContainer", "APPCONTAINER", "", "true", 0 },
+  { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
+  { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
+  { "NoEntryPoint", "NOENTRY", "", "true", 0 },
+  { "SetChecksum", "RELEASE", "", "true", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
+  { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
+  { "FixedBaseAddress", "FIXED", "", "true", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
+  { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
+  { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
+  { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
+  { "Profile", "PROFILE", "", "true", 0 },
+  { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
+  { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
+  { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
+  { "LinkDLL", "DLL", "", "true", 0 },
 
-  //Bool Properties
-  {"LinkIncremental", "INCREMENTAL:NO", "", "false", 0},
-  {"LinkIncremental", "INCREMENTAL", "", "true", 0},
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"LinkStatus", "LTCG:NOSTATUS", "", "false", 0},
-  {"LinkStatus", "LTCG:STATUS", "", "true", 0},
-  {"PreventDllBinding", "ALLOWBIND:NO", "", "false", 0},
-  {"PreventDllBinding", "ALLOWBIND", "", "true", 0},
-  {"TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLinkerWarningAsErrors", "WX", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"GenerateManifest", "MANIFEST:NO", "", "false", 0},
-  {"GenerateManifest", "MANIFEST", "", "true", 0},
-  {"AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0},
-  {"UACUIAccess", "uiAccess='false'", "", "false", 0},
-  {"UACUIAccess", "uiAccess='true'", "", "true", 0},
-  {"ManifestEmbed", "manifest:embed", "", "true", 0},
-  {"GenerateDebugInformation", "DEBUG", "", "true",
-   cmVS7FlagTable::CaseInsensitive},
-  {"MapExports", "MAPINFO:EXPORTS", "", "true", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0},
-  {"TerminalServerAware", "TSAWARE:NO", "", "false", 0},
-  {"TerminalServerAware", "TSAWARE", "", "true", 0},
-  {"SwapRunFromCD", "SWAPRUN:CD", "", "true", 0},
-  {"SwapRunFromNET", "SWAPRUN:NET", "", "true", 0},
-  {"OptimizeReferences", "OPT:NOREF", "", "false", 0},
-  {"OptimizeReferences", "OPT:REF", "", "true", 0},
-  {"EnableCOMDATFolding", "OPT:NOICF", "", "false", 0},
-  {"EnableCOMDATFolding", "OPT:ICF", "", "true", 0},
-  {"IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0},
-  {"AppContainer", "APPCONTAINER", "", "true", 0},
-  {"WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0},
-  {"WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0},
-  {"NoEntryPoint", "NOENTRY", "", "true", 0},
-  {"SetChecksum", "RELEASE", "", "true", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0},
-  {"FixedBaseAddress", "FIXED:NO", "", "false", 0},
-  {"FixedBaseAddress", "FIXED", "", "true", 0},
-  {"DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0},
-  {"DataExecutionPrevention", "NXCOMPAT", "", "true", 0},
-  {"TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0},
-  {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
-  {"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0},
-  {"Profile", "PROFILE", "", "true", 0},
-  {"LinkDelaySign", "DELAYSIGN:NO", "", "false", 0},
-  {"LinkDelaySign", "DELAYSIGN", "", "true", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
-  {"DetectOneDefinitionRule", "ODR", "", "true", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0},
-  {"LinkDLL", "DLL", "", "true", 0},
+  // Bool Properties With Argument
+  { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
+  { "EnableUAC", "MANIFESTUAC:", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateMapFile", "MAP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "MapFileName", "MAP:", "Generate Map File", "",
+    cmVS7FlagTable::UserValueRequired },
 
-  //Bool Properties With Argument
-  {"EnableUAC", "MANIFESTUAC:NO", "", "false", 0},
-  {"EnableUAC", "MANIFESTUAC:", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateMapFile", "MAP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"MapFileName", "MAP:", "Generate Map File", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AddModuleNamesToAssembly", "ASSEMBLYMODULE:",
-   "Add Module to Assembly",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
-   "Embed Managed Resource File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DelayLoadDLLs", "DELAYLOAD:",
-   "Delay Loaded Dlls",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:",
-   "Assembly Link Resource",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
-   "Additional Manifest Dependencies",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ManifestInput", "manifestinput:",
-   "Manifest Input",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
+    "Embed Managed Resource File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
+    "Additional Manifest Dependencies", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ManifestInput", "manifestinput:", "Manifest Input", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"Version", "VERSION:",
-   "Version",
-   "", cmVS7FlagTable::UserValue},
-  {"SpecifySectionAttributes", "SECTION:",
-   "Specify Section Attributes",
-   "", cmVS7FlagTable::UserValue},
-  {"MSDOSStubFileName", "STUB:",
-   "MS-DOS Stub File Name",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
+  { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
+    cmVS7FlagTable::UserValue },
+  { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File",
-   "", cmVS7FlagTable::UserValue},
-  {"ManifestFile", "ManifestFile:",
-   "Manifest File",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDatabaseFile", "PDB:",
-   "Generate Program Database File",
-   "", cmVS7FlagTable::UserValue},
-  {"StripPrivateSymbols", "PDBSTRIPPED:",
-   "Strip Private Symbols",
-   "", cmVS7FlagTable::UserValue},
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
+    cmVS7FlagTable::UserValue },
+  { "ManifestFile", "ManifestFile:", "Manifest File", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
+    cmVS7FlagTable::UserValue },
+  { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MapFileName] - no command line Switch.
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"HeapReserveSize", "HEAP:",
-   "Heap Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [HeapCommitSize] - no command line Switch.
-  {"StackReserveSize", "STACK:",
-   "Stack Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [StackCommitSize] - no command line Switch.
-  {"FunctionOrder", "ORDER:@",
-   "Function Order",
-   "", cmVS7FlagTable::UserValue},
-  {"ProfileGuidedDatabase", "PGD:",
-   "Profile Guided Database",
-   "", cmVS7FlagTable::UserValue},
-  {"MidlCommandFile", "MIDL:@",
-   "MIDL Commands",
-   "", cmVS7FlagTable::UserValue},
-  {"MergedIDLBaseFileName", "IDLOUT:",
-   "Merged IDL Base File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"TypeLibraryFile", "TLBOUT:",
-   "Type Library",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataFile", "WINMDFILE:",
-   "Windows Metadata File",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataLinkKeyFile", "WINMDKEYFILE:",
-   "Windows Metadata Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
-   "Windows Metadata Key Container",
-   "", cmVS7FlagTable::UserValue},
-  {"EntryPointSymbol", "ENTRY:",
-   "Entry Point",
-   "", cmVS7FlagTable::UserValue},
-  {"BaseAddress", "BASE:",
-   "Base Address",
-   "", cmVS7FlagTable::UserValue},
-  {"ImportLibrary", "IMPLIB:",
-   "Import Library",
-   "", cmVS7FlagTable::UserValue},
-  {"MergeSections", "MERGE:",
-   "Merge Sections",
-   "", cmVS7FlagTable::UserValue},
-  {"LinkKeyFile", "KEYFILE:",
-   "Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"KeyContainer", "KEYCONTAINER:",
-   "Key Container",
-   "", cmVS7FlagTable::UserValue},
+  { "FunctionOrder", "ORDER:@", "Function Order", "",
+    cmVS7FlagTable::UserValue },
+  { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
+    cmVS7FlagTable::UserValue },
+  { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
+    cmVS7FlagTable::UserValue },
+  { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
+    cmVS7FlagTable::UserValue },
+  { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
+    cmVS7FlagTable::UserValue },
+  { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
+    "", cmVS7FlagTable::UserValue },
+  { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
+    "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
+  { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
+    cmVS7FlagTable::UserValue },
+  { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
+  { "ImportLibrary", "IMPLIB:", "Import Library", "",
+    cmVS7FlagTable::UserValue },
+  { "MergeSections", "MERGE:", "Merge Sections", "",
+    cmVS7FlagTable::UserValue },
+  { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
+  { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
+    cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS12MASMFlagTable.h b/Source/cmVS12MASMFlagTable.h
index 74d529c..a7e4a80 100644
--- a/Source/cmVS12MASMFlagTable.h
+++ b/Source/cmVS12MASMFlagTable.h
@@ -1,96 +1,78 @@
-static cmVS7FlagTable cmVS12MASMFlagTable[] =
-{
+static cmVS7FlagTable cmVS12MASMFlagTable[] = {
 
-  //Enum Properties
-  {"PreserveIdentifierCase", "",
-   "Default", "0", 0},
-  {"PreserveIdentifierCase", "/Cp",
-   "Preserves Identifier Case (/Cp)", "1", 0},
-  {"PreserveIdentifierCase", "/Cu",
-   "Maps all identifiers to upper case. (/Cu)", "2", 0},
-  {"PreserveIdentifierCase", "/Cx",
-   "Preserves case in public and extern symbols. (/Cx)", "3", 0},
+  // Enum Properties
+  { "PreserveIdentifierCase", "", "Default", "0", 0 },
+  { "PreserveIdentifierCase", "/Cp", "Preserves Identifier Case (/Cp)", "1",
+    0 },
+  { "PreserveIdentifierCase", "/Cu",
+    "Maps all identifiers to upper case. (/Cu)", "2", 0 },
+  { "PreserveIdentifierCase", "/Cx",
+    "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
 
-  {"WarningLevel", "/W0",
-   "Warning Level 0 (/W0)", "0", 0},
-  {"WarningLevel", "/W1",
-   "Warning Level 1 (/W1)", "1", 0},
-  {"WarningLevel", "/W2",
-   "Warning Level 2 (/W2)", "2", 0},
-  {"WarningLevel", "/W3",
-   "Warning Level 3 (/W3)", "3", 0},
+  { "WarningLevel", "/W0", "Warning Level 0 (/W0)", "0", 0 },
+  { "WarningLevel", "/W1", "Warning Level 1 (/W1)", "1", 0 },
+  { "WarningLevel", "/W2", "Warning Level 2 (/W2)", "2", 0 },
+  { "WarningLevel", "/W3", "Warning Level 3 (/W3)", "3", 0 },
 
-  {"PackAlignmentBoundary", "",
-   "Default", "0", 0},
-  {"PackAlignmentBoundary", "/Zp1",
-   "One Byte Boundary (/Zp1)", "1", 0},
-  {"PackAlignmentBoundary", "/Zp2",
-   "Two Byte Boundary (/Zp2)", "2", 0},
-  {"PackAlignmentBoundary", "/Zp4",
-   "Four Byte Boundary (/Zp4)", "3", 0},
-  {"PackAlignmentBoundary", "/Zp8",
-   "Eight Byte Boundary (/Zp8)", "4", 0},
-  {"PackAlignmentBoundary", "/Zp16",
-   "Sixteen Byte Boundary (/Zp16)", "5", 0},
+  { "PackAlignmentBoundary", "", "Default", "0", 0 },
+  { "PackAlignmentBoundary", "/Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
+  { "PackAlignmentBoundary", "/Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
+  { "PackAlignmentBoundary", "/Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
+  { "PackAlignmentBoundary", "/Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
+  { "PackAlignmentBoundary", "/Zp16", "Sixteen Byte Boundary (/Zp16)", "5",
+    0 },
 
-  {"CallingConvention", "",
-   "Default", "0", 0},
-  {"CallingConvention", "/Gd",
-   "Use C-style Calling Convention (/Gd)", "1", 0},
-  {"CallingConvention", "/Gz",
-   "Use stdcall Calling Convention (/Gz)", "2", 0},
-  {"CallingConvention", "/Gc",
-   "Use Pascal Calling Convention (/Gc)", "3", 0},
+  { "CallingConvention", "", "Default", "0", 0 },
+  { "CallingConvention", "/Gd", "Use C-style Calling Convention (/Gd)", "1",
+    0 },
+  { "CallingConvention", "/Gz", "Use stdcall Calling Convention (/Gz)", "2",
+    0 },
+  { "CallingConvention", "/Gc", "Use Pascal Calling Convention (/Gc)", "3",
+    0 },
 
-  {"ErrorReporting", "/errorReport:prompt",
-   "Prompt to send report immediately (/errorReport:prompt)", "0", 0},
-  {"ErrorReporting", "/errorReport:queue",
-   "Prompt to send report at the next logon (/errorReport:queue)", "1", 0},
-  {"ErrorReporting", "/errorReport:send",
-   "Automatically send report (/errorReport:send)", "2", 0},
-  {"ErrorReporting", "/errorReport:none",
-   "Do not send report (/errorReport:none)", "3", 0},
+  { "ErrorReporting", "/errorReport:prompt",
+    "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
+  { "ErrorReporting", "/errorReport:queue",
+    "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
+  { "ErrorReporting", "/errorReport:send",
+    "Automatically send report (/errorReport:send)", "2", 0 },
+  { "ErrorReporting", "/errorReport:none",
+    "Do not send report (/errorReport:none)", "3", 0 },
 
+  // Bool Properties
+  { "NoLogo", "/nologo", "", "true", 0 },
+  { "GeneratePreprocessedSourceListing", "/EP", "", "true", 0 },
+  { "ListAllAvailableInformation", "/Sa", "", "true", 0 },
+  { "UseSafeExceptionHandlers", "/safeseh", "", "true", 0 },
+  { "AddFirstPassListing", "/Sf", "", "true", 0 },
+  { "EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0 },
+  { "DisableSymbolTable", "/Sn", "", "true", 0 },
+  { "EnableFalseConditionalsInListing", "/Sx", "", "true", 0 },
+  { "TreatWarningsAsErrors", "/WX", "", "true", 0 },
+  { "MakeAllSymbolsPublic", "/Zf", "", "true", 0 },
+  { "GenerateDebugInformation", "/Zi", "", "true", 0 },
+  { "EnableMASM51Compatibility", "/Zm", "", "true", 0 },
+  { "PerformSyntaxCheckOnly", "/Zs", "", "true", 0 },
 
-  //Bool Properties
-  {"NoLogo", "/nologo", "", "true", 0},
-  {"GeneratePreprocessedSourceListing", "/EP", "", "true", 0},
-  {"ListAllAvailableInformation", "/Sa", "", "true", 0},
-  {"UseSafeExceptionHandlers", "/safeseh", "", "true", 0},
-  {"AddFirstPassListing", "/Sf", "", "true", 0},
-  {"EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0},
-  {"DisableSymbolTable", "/Sn", "", "true", 0},
-  {"EnableFalseConditionalsInListing", "/Sx", "", "true", 0},
-  {"TreatWarningsAsErrors", "/WX", "", "true", 0},
-  {"MakeAllSymbolsPublic", "/Zf", "", "true", 0},
-  {"GenerateDebugInformation", "/Zi", "", "true", 0},
-  {"EnableMASM51Compatibility", "/Zm", "", "true", 0},
-  {"PerformSyntaxCheckOnly", "/Zs", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
-  {"PreprocessorDefinitions", "/D",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IncludePaths", "/I",
-   "Include Paths",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"BrowseFile", "/FR",
-   "Generate Browse Information File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "PreprocessorDefinitions", "/D", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IncludePaths", "/I", "Include Paths", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "BrowseFile", "/FR", "Generate Browse Information File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
 
-  //String Properties
+  // String Properties
   // Skip [Inputs] - no command line Switch.
-  {"ObjectFileName", "/Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"AssembledCodeListingFile", "/Fl",
-   "Assembled Code Listing File",
-   "", cmVS7FlagTable::UserValue},
+  { "ObjectFileName", "/Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "AssembledCodeListingFile", "/Fl", "Assembled Code Listing File", "",
+    cmVS7FlagTable::UserValue },
   // Skip [CommandLineTemplate] - no command line Switch.
   // Skip [ExecutionDescription] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS12RCFlagTable.h b/Source/cmVS12RCFlagTable.h
index 1551c66..d047f82 100644
--- a/Source/cmVS12RCFlagTable.h
+++ b/Source/cmVS12RCFlagTable.h
@@ -1,7 +1,6 @@
-static cmVS7FlagTable cmVS12RCFlagTable[] =
-{
-  //Bool Properties
-  {"NullTerminateStrings", "n", "", "true", 0},
+static cmVS7FlagTable cmVS12RCFlagTable[] = {
+  // Bool Properties
+  { "NullTerminateStrings", "n", "", "true", 0 },
 
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS14CLFlagTable.h b/Source/cmVS14CLFlagTable.h
index 422f47b..5812e79 100644
--- a/Source/cmVS14CLFlagTable.h
+++ b/Source/cmVS14CLFlagTable.h
@@ -1,296 +1,237 @@
-static cmVS7FlagTable cmVS14CLFlagTable[] =
-{
-
-  //Enum Properties
-  {"DebugInformationFormat", "",
-   "None", "None", 0},
-  {"DebugInformationFormat", "Z7",
-   "C7 compatible", "OldStyle", 0},
-  {"DebugInformationFormat", "Zi",
-   "Program Database", "ProgramDatabase", 0},
-  {"DebugInformationFormat", "ZI",
-   "Program Database for Edit And Continue", "EditAndContinue", 0},
-
-  {"WarningLevel", "W0",
-   "Turn Off All Warnings", "TurnOffAllWarnings", 0},
-  {"WarningLevel", "W1",
-   "Level1", "Level1", 0},
-  {"WarningLevel", "W2",
-   "Level2", "Level2", 0},
-  {"WarningLevel", "W3",
-   "Level3", "Level3", 0},
-  {"WarningLevel", "W4",
-   "Level4", "Level4", 0},
-  {"WarningLevel", "Wall",
-   "EnableAllWarnings", "EnableAllWarnings", 0},
-
-  {"Optimization", "",
-   "Custom", "Custom", 0},
-  {"Optimization", "Od",
-   "Disabled", "Disabled", 0},
-  {"Optimization", "O1",
-   "Minimize Size", "MinSpace", 0},
-  {"Optimization", "O2",
-   "Maximize Speed", "MaxSpeed", 0},
-  {"Optimization", "Ox",
-   "Full Optimization", "Full", 0},
-
-  {"InlineFunctionExpansion", "",
-   "Default", "Default", 0},
-  {"InlineFunctionExpansion", "Ob0",
-   "Disabled", "Disabled", 0},
-  {"InlineFunctionExpansion", "Ob1",
-   "Only __inline", "OnlyExplicitInline", 0},
-  {"InlineFunctionExpansion", "Ob2",
-   "Any Suitable", "AnySuitable", 0},
-
-  {"FavorSizeOrSpeed", "Os",
-   "Favor small code", "Size", 0},
-  {"FavorSizeOrSpeed", "Ot",
-   "Favor fast code", "Speed", 0},
-  {"FavorSizeOrSpeed", "",
-   "Neither", "Neither", 0},
-
-  {"ExceptionHandling", "EHa",
-   "Yes with SEH Exceptions", "Async", 0},
-  {"ExceptionHandling", "EHsc",
-   "Yes", "Sync", 0},
-  {"ExceptionHandling", "EHs",
-   "Yes with Extern C functions", "SyncCThrow", 0},
-  {"ExceptionHandling", "",
-   "No", "false", 0},
-
-  {"BasicRuntimeChecks", "RTCs",
-   "Stack Frames", "StackFrameRuntimeCheck", 0},
-  {"BasicRuntimeChecks", "RTCu",
-   "Uninitialized variables", "UninitializedLocalUsageCheck", 0},
-  {"BasicRuntimeChecks", "RTC1",
-   "Both (/RTC1, equiv. to /RTCsu)", "EnableFastChecks", 0},
-  {"BasicRuntimeChecks", "",
-   "Default", "Default", 0},
-
-  {"RuntimeLibrary", "MT",
-   "Multi-threaded", "MultiThreaded", 0},
-  {"RuntimeLibrary", "MTd",
-   "Multi-threaded Debug", "MultiThreadedDebug", 0},
-  {"RuntimeLibrary", "MD",
-   "Multi-threaded DLL", "MultiThreadedDLL", 0},
-  {"RuntimeLibrary", "MDd",
-   "Multi-threaded Debug DLL", "MultiThreadedDebugDLL", 0},
-
-  {"StructMemberAlignment", "Zp1",
-   "1 Byte", "1Byte", 0},
-  {"StructMemberAlignment", "Zp2",
-   "2 Bytes", "2Bytes", 0},
-  {"StructMemberAlignment", "Zp4",
-   "4 Byte", "4Bytes", 0},
-  {"StructMemberAlignment", "Zp8",
-   "8 Bytes", "8Bytes", 0},
-  {"StructMemberAlignment", "Zp16",
-   "16 Bytes", "16Bytes", 0},
-  {"StructMemberAlignment", "",
-   "Default", "Default", 0},
-
-  {"BufferSecurityCheck", "GS-",
-   "Disable Security Check", "false", 0},
-  {"BufferSecurityCheck", "GS",
-   "Enable Security Check", "true", 0},
-
-  {"EnableEnhancedInstructionSet", "arch:SSE",
-   "Streaming SIMD Extensions", "StreamingSIMDExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:SSE2",
-   "Streaming SIMD Extensions 2", "StreamingSIMDExtensions2", 0},
-  {"EnableEnhancedInstructionSet", "arch:AVX",
-   "Advanced Vector Extensions", "AdvancedVectorExtensions", 0},
-  {"EnableEnhancedInstructionSet", "arch:AVX2",
-   "Advanced Vector Extensions 2", "AdvancedVectorExtensions2", 0},
-  {"EnableEnhancedInstructionSet", "arch:IA32",
-   "No Enhanced Instructions", "NoExtensions", 0},
-  {"EnableEnhancedInstructionSet", "",
-   "Not Set", "NotSet", 0},
-
-  {"FloatingPointModel", "fp:precise",
-   "Precise", "Precise", 0},
-  {"FloatingPointModel", "fp:strict",
-   "Strict", "Strict", 0},
-  {"FloatingPointModel", "fp:fast",
-   "Fast", "Fast", 0},
-
-  {"PrecompiledHeader", "Yc",
-   "Create", "Create",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "Yu",
-   "Use", "Use",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"PrecompiledHeader", "",
-   "Not Using Precompiled Headers", "NotUsing", 0},
-
-  {"AssemblerOutput", "",
-   "No Listing", "NoListing", 0},
-  {"AssemblerOutput", "FA",
-   "Assembly-Only Listing", "AssemblyCode", 0},
-  {"AssemblerOutput", "FAc",
-   "Assembly With Machine Code", "AssemblyAndMachineCode", 0},
-  {"AssemblerOutput", "FAs",
-   "Assembly With Source Code", "AssemblyAndSourceCode", 0},
-  {"AssemblerOutput", "FAcs",
-   "Assembly, Machine Code and Source", "All", 0},
-
-  {"CallingConvention", "Gd",
-   "__cdecl", "Cdecl", 0},
-  {"CallingConvention", "Gr",
-   "__fastcall", "FastCall", 0},
-  {"CallingConvention", "Gz",
-   "__stdcall", "StdCall", 0},
-  {"CallingConvention", "Gv",
-   "__vectorcall", "VectorCall", 0},
-
-  {"CompileAs", "",
-   "Default", "Default", 0},
-  {"CompileAs", "TC",
-   "Compile as C Code", "CompileAsC", 0},
-  {"CompileAs", "TP",
-   "Compile as C++ Code", "CompileAsCpp", 0},
-
-  {"ErrorReporting", "errorReport:none",
-   "Do Not Send Report", "None", 0},
-  {"ErrorReporting", "errorReport:prompt",
-   "Prompt Immediately", "Prompt", 0},
-  {"ErrorReporting", "errorReport:queue",
-   "Queue For Next Login", "Queue", 0},
-  {"ErrorReporting", "errorReport:send",
-   "Send Automatically", "Send", 0},
-
-  {"CompileAsManaged", "",
-   "No Common Language RunTime Support", "false", 0},
-  {"CompileAsManaged", "clr",
-   "Common Language RunTime Support", "true", 0},
-  {"CompileAsManaged", "clr:pure",
-   "Pure MSIL Common Language RunTime Support", "Pure", 0},
-  {"CompileAsManaged", "clr:safe",
-   "Safe MSIL Common Language RunTime Support", "Safe", 0},
-  {"CompileAsManaged", "clr:oldSyntax",
-   "Common Language RunTime Support, Old Syntax", "OldSyntax", 0},
-
-
-  //Bool Properties
-  {"CompileAsWinRT", "ZW", "", "true", 0},
-  {"WinRTNoStdLib", "ZW:nostdlib", "", "true", 0},
-  {"SuppressStartupBanner", "nologo", "", "true", 0},
-  {"TreatWarningAsError", "WX-", "", "false", 0},
-  {"TreatWarningAsError", "WX", "", "true", 0},
-  {"SDLCheck", "sdl-", "", "false", 0},
-  {"SDLCheck", "sdl", "", "true", 0},
-  {"IntrinsicFunctions", "Oi", "", "true", 0},
-  {"OmitFramePointers", "Oy-", "", "false", 0},
-  {"OmitFramePointers", "Oy", "", "true", 0},
-  {"EnableFiberSafeOptimizations", "GT", "", "true", 0},
-  {"WholeProgramOptimization", "GL", "", "true", 0},
-  {"UndefineAllPreprocessorDefinitions", "u", "", "true", 0},
-  {"IgnoreStandardIncludePath", "X", "", "true", 0},
-  {"PreprocessToFile", "P", "", "true", 0},
-  {"PreprocessSuppressLineNumbers", "EP", "", "true", 0},
-  {"PreprocessKeepComments", "C", "", "true", 0},
-  {"StringPooling", "GF-", "", "false", 0},
-  {"StringPooling", "GF", "", "true", 0},
-  {"MinimalRebuild", "Gm-", "", "false", 0},
-  {"MinimalRebuild", "Gm", "", "true", 0},
-  {"SmallerTypeCheck", "RTCc", "", "true", 0},
-  {"FunctionLevelLinking", "Gy-", "", "false", 0},
-  {"FunctionLevelLinking", "Gy", "", "true", 0},
-  {"EnableParallelCodeGeneration", "Qpar-", "", "false", 0},
-  {"EnableParallelCodeGeneration", "Qpar", "", "true", 0},
-  {"FloatingPointExceptions", "fp:except-", "", "false", 0},
-  {"FloatingPointExceptions", "fp:except", "", "true", 0},
-  {"CreateHotpatchableImage", "hotpatch", "", "true", 0},
-  {"DisableLanguageExtensions", "Za", "", "true", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0},
-  {"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0},
-  {"ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0},
-  {"RuntimeTypeInfo", "GR-", "", "false", 0},
-  {"RuntimeTypeInfo", "GR", "", "true", 0},
-  {"OpenMPSupport", "openmp-", "", "false", 0},
-  {"OpenMPSupport", "openmp", "", "true", 0},
-  {"ExpandAttributedSource", "Fx", "", "true", 0},
-  {"UseUnicodeForAssemblerListing", "FAu", "", "true", 0},
-  {"ShowIncludes", "showIncludes", "", "true", 0},
-  {"EnablePREfast", "analyze-", "", "false", 0},
-  {"EnablePREfast", "analyze", "", "true", 0},
-  {"UseFullPaths", "FC", "", "true", 0},
-  {"OmitDefaultLibName", "Zl", "", "true", 0},
-
-  //Bool Properties With Argument
-  {"MultiProcessorCompilation", "MP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"ProcessorNumber", "MP", "Multi-processor Compilation", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateXMLDocumentationFiles", "doc", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"BrowseInformation", "FR", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"BrowseInformationFile", "FR", "Enable Browse Information", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalIncludeDirectories", "I",
-   "Additional Include Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalUsingDirectories", "AI",
-   "Additional #using Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PreprocessorDefinitions", "D ",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"UndefinePreprocessorDefinitions", "U",
-   "Undefine Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DisableSpecificWarnings", "wd",
-   "Disable Specific Warnings",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedIncludeFiles", "FI",
-   "Forced Include File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForcedUsingFiles", "FU",
-   "Forced #using File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PREfastLog", "analyze:log",
-   "Code Analysis Log",
-   "", cmVS7FlagTable::UserFollowing},
-  {"PREfastAdditionalPlugins", "analyze:plugin",
-   "Additional Code Analysis Native plugins",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"TreatSpecificWarningsAsErrors", "we",
-   "Treat Specific Warnings As Errors",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-
-  //String Properties
+static cmVS7FlagTable cmVS14CLFlagTable[] = {
+
+  // Enum Properties
+  { "DebugInformationFormat", "", "None", "None", 0 },
+  { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
+  { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
+  { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
+    "EditAndContinue", 0 },
+
+  { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
+  { "WarningLevel", "W1", "Level1", "Level1", 0 },
+  { "WarningLevel", "W2", "Level2", "Level2", 0 },
+  { "WarningLevel", "W3", "Level3", "Level3", 0 },
+  { "WarningLevel", "W4", "Level4", "Level4", 0 },
+  { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
+
+  { "Optimization", "", "Custom", "Custom", 0 },
+  { "Optimization", "Od", "Disabled", "Disabled", 0 },
+  { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
+  { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
+  { "Optimization", "Ox", "Full Optimization", "Full", 0 },
+
+  { "InlineFunctionExpansion", "", "Default", "Default", 0 },
+  { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
+  { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
+    0 },
+  { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
+
+  { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
+  { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
+  { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
+
+  { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
+  { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
+  { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
+    0 },
+  { "ExceptionHandling", "", "No", "false", 0 },
+
+  { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
+    0 },
+  { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
+    "UninitializedLocalUsageCheck", 0 },
+  { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
+    "EnableFastChecks", 0 },
+  { "BasicRuntimeChecks", "", "Default", "Default", 0 },
+
+  { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
+  { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
+  { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
+  { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
+    "MultiThreadedDebugDLL", 0 },
+
+  { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
+  { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
+  { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
+  { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
+  { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
+  { "StructMemberAlignment", "", "Default", "Default", 0 },
+
+  { "BufferSecurityCheck", "GS-", "Disable Security Check", "false", 0 },
+  { "BufferSecurityCheck", "GS", "Enable Security Check", "true", 0 },
+
+  { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
+    "StreamingSIMDExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
+    "StreamingSIMDExtensions2", 0 },
+  { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
+    "AdvancedVectorExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "arch:AVX2",
+    "Advanced Vector Extensions 2", "AdvancedVectorExtensions2", 0 },
+  { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
+    "NoExtensions", 0 },
+  { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
+
+  { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
+  { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
+  { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
+
+  { "PrecompiledHeader", "Yc", "Create", "Create",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "Yu", "Use", "Use",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
+
+  { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
+  { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
+  { "AssemblerOutput", "FAc", "Assembly With Machine Code",
+    "AssemblyAndMachineCode", 0 },
+  { "AssemblerOutput", "FAs", "Assembly With Source Code",
+    "AssemblyAndSourceCode", 0 },
+  { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
+
+  { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
+  { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
+  { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
+  { "CallingConvention", "Gv", "__vectorcall", "VectorCall", 0 },
+
+  { "CompileAs", "", "Default", "Default", 0 },
+  { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
+  { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
+
+  { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
+  { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
+    0 },
+  { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
+    0 },
+  { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
+
+  { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
+  { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
+  { "CompileAsManaged", "clr:pure",
+    "Pure MSIL Common Language RunTime Support", "Pure", 0 },
+  { "CompileAsManaged", "clr:safe",
+    "Safe MSIL Common Language RunTime Support", "Safe", 0 },
+  { "CompileAsManaged", "clr:oldSyntax",
+    "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
+
+  { "CppLanguageStandard", "", "Default", "Default", 0 },
+  { "CppLanguageStandard", "std=c++98", "C++03", "c++98", 0 },
+  { "CppLanguageStandard", "std=c++11", "C++11", "c++11", 0 },
+  { "CppLanguageStandard", "std=c++1y", "C++14", "c++1y", 0 },
+  { "CppLanguageStandard", "std=c++14", "C++14", "c++1y", 0 },
+  { "CppLanguageStandard", "std=gnu++98", "C++03 (GNU Dialect)", "gnu++98",
+    0 },
+  { "CppLanguageStandard", "std=gnu++11", "C++11 (GNU Dialect)", "gnu++11",
+    0 },
+  { "CppLanguageStandard", "std=gnu++1y", "C++14 (GNU Dialect)", "gnu++1y",
+    0 },
+  { "CppLanguageStandard", "std=gnu++14", "C++14 (GNU Dialect)", "gnu++1y",
+    0 },
+
+  // Bool Properties
+  { "CompileAsWinRT", "ZW", "", "true", 0 },
+  { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
+  { "SuppressStartupBanner", "nologo", "", "true", 0 },
+  { "TreatWarningAsError", "WX-", "", "false", 0 },
+  { "TreatWarningAsError", "WX", "", "true", 0 },
+  { "SDLCheck", "sdl-", "", "false", 0 },
+  { "SDLCheck", "sdl", "", "true", 0 },
+  { "IntrinsicFunctions", "Oi", "", "true", 0 },
+  { "OmitFramePointers", "Oy-", "", "false", 0 },
+  { "OmitFramePointers", "Oy", "", "true", 0 },
+  { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
+  { "WholeProgramOptimization", "GL", "", "true", 0 },
+  { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
+  { "IgnoreStandardIncludePath", "X", "", "true", 0 },
+  { "PreprocessToFile", "P", "", "true", 0 },
+  { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
+  { "PreprocessKeepComments", "C", "", "true", 0 },
+  { "StringPooling", "GF-", "", "false", 0 },
+  { "StringPooling", "GF", "", "true", 0 },
+  { "MinimalRebuild", "Gm-", "", "false", 0 },
+  { "MinimalRebuild", "Gm", "", "true", 0 },
+  { "SmallerTypeCheck", "RTCc", "", "true", 0 },
+  { "FunctionLevelLinking", "Gy-", "", "false", 0 },
+  { "FunctionLevelLinking", "Gy", "", "true", 0 },
+  { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
+  { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
+  { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
+  { "FloatingPointExceptions", "fp:except", "", "true", 0 },
+  { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
+  { "DisableLanguageExtensions", "Za", "", "true", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
+  { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
+  { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
+  { "RuntimeTypeInfo", "GR-", "", "false", 0 },
+  { "RuntimeTypeInfo", "GR", "", "true", 0 },
+  { "OpenMPSupport", "openmp-", "", "false", 0 },
+  { "OpenMPSupport", "openmp", "", "true", 0 },
+  { "ExpandAttributedSource", "Fx", "", "true", 0 },
+  { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
+  { "ShowIncludes", "showIncludes", "", "true", 0 },
+  { "EnablePREfast", "analyze-", "", "false", 0 },
+  { "EnablePREfast", "analyze", "", "true", 0 },
+  { "UseFullPaths", "FC", "", "true", 0 },
+  { "OmitDefaultLibName", "Zl", "", "true", 0 },
+
+  // Bool Properties With Argument
+  { "MultiProcessorCompilation", "MP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateXMLDocumentationFiles", "doc", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "BrowseInformation", "FR", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "BrowseInformationFile", "FR", "Enable Browse Information", "",
+    cmVS7FlagTable::UserValueRequired },
+
+  // String List Properties
+  { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "UndefinePreprocessorDefinitions", "U",
+    "Undefine Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedIncludeFiles", "FI", "Forced Include File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForcedUsingFiles", "FU", "Forced #using File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "PREfastLog", "analyze:log", "Code Analysis Log", "",
+    cmVS7FlagTable::UserFollowing },
+  { "PREfastAdditionalPlugins", "analyze:plugin",
+    "Additional Code Analysis Native plugins", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+
+  // String Properties
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"PreprocessOutputPath", "Fi",
-   "Preprocess Output Path",
-   "", cmVS7FlagTable::UserValue},
-  {"PrecompiledHeaderFile", "Yc",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderFile", "Yu",
-   "Precompiled Header Name",
-   "", cmVS7FlagTable::UserValueRequired},
-  {"PrecompiledHeaderOutputFile", "Fp",
-   "Precompiled Header Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"AssemblerListingLocation", "Fa",
-   "ASM List Location",
-   "", cmVS7FlagTable::UserValue},
-  {"ObjectFileName", "Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDataBaseFileName", "Fd",
-   "Program Database File Name",
-   "", cmVS7FlagTable::UserValue},
+  { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
+    cmVS7FlagTable::UserValue },
+  { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
+    cmVS7FlagTable::UserValue },
+  { "AssemblerListingLocation", "Fa", "ASM List Location", "",
+    cmVS7FlagTable::UserValue },
+  { "ObjectFileName", "Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [XMLDocumentationFileName] - no command line Switch.
   // Skip [BrowseInformationFile] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS14LibFlagTable.h b/Source/cmVS14LibFlagTable.h
index a33f273..7fa7138 100644
--- a/Source/cmVS14LibFlagTable.h
+++ b/Source/cmVS14LibFlagTable.h
@@ -1,102 +1,76 @@
-static cmVS7FlagTable cmVS14LibFlagTable[] =
-{
+static cmVS7FlagTable cmVS14LibFlagTable[] = {
 
-  //Enum Properties
-  {"ErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"ErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"ErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"ErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  // Enum Properties
+  { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
+    0 },
 
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWSCE",
-   "WindowsCE", "WindowsCE", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
+  // Bool Properties
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
+  { "Verbose", "VERBOSE", "", "true", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
 
-  //Bool Properties
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"TreatLibWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLibWarningAsErrors", "WX", "", "true", 0},
-  {"Verbose", "VERBOSE", "", "true", 0},
-  {"LinkTimeCodeGeneration", "LTCG", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
+  // String List Properties
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ExportNamedFunctions", "EXPORT:",
-   "Export Named Functions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"RemoveObjects", "REMOVE:",
-   "Remove Objects",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "RemoveObjects", "REMOVE:", "Remove Objects", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue},
-  {"DisplayLibrary", "LIST:",
-   "Display Library to standard output",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue },
+  { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"Name", "NAME:",
-   "Name",
-   "", cmVS7FlagTable::UserValue},
+  { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS14LinkFlagTable.h b/Source/cmVS14LinkFlagTable.h
index 29e3d86..6e56422 100644
--- a/Source/cmVS14LinkFlagTable.h
+++ b/Source/cmVS14LinkFlagTable.h
@@ -1,343 +1,271 @@
-static cmVS7FlagTable cmVS14LinkFlagTable[] =
-{
+static cmVS7FlagTable cmVS14LinkFlagTable[] = {
 
-  //Enum Properties
-  {"ShowProgress", "",
-   "Not Set", "NotSet", 0},
-  {"ShowProgress", "VERBOSE",
-   "Display all progress messages", "LinkVerbose", 0},
-  {"ShowProgress", "VERBOSE:Lib",
-   "For Libraries Searched", "LinkVerboseLib", 0},
-  {"ShowProgress", "VERBOSE:ICF",
-   "About COMDAT folding during optimized linking", "LinkVerboseICF", 0},
-  {"ShowProgress", "VERBOSE:REF",
-   "About data removed during optimized linking", "LinkVerboseREF", 0},
-  {"ShowProgress", "VERBOSE:SAFESEH",
-   "About Modules incompatible with SEH", "LinkVerboseSAFESEH", 0},
-  {"ShowProgress", "VERBOSE:CLR",
-   "About linker activity related to managed code", "LinkVerboseCLR", 0},
+  // Enum Properties
+  { "ShowProgress", "", "Not Set", "NotSet", 0 },
+  { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
+    0 },
+  { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
+    0 },
+  { "ShowProgress", "VERBOSE:ICF",
+    "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
+  { "ShowProgress", "VERBOSE:REF",
+    "About data removed during optimized linking", "LinkVerboseREF", 0 },
+  { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
+    "LinkVerboseSAFESEH", 0 },
+  { "ShowProgress", "VERBOSE:CLR",
+    "About linker activity related to managed code", "LinkVerboseCLR", 0 },
 
-  {"ForceFileOutput", "FORCE",
-   "Enabled", "Enabled", 0},
-  {"ForceFileOutput", "FORCE:MULTIPLE",
-   "Multiply Defined Symbol Only", "MultiplyDefinedSymbolOnly", 0},
-  {"ForceFileOutput", "FORCE:UNRESOLVED",
-   "Undefined Symbol Only", "UndefinedSymbolOnly", 0},
+  { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
+  { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
+    "MultiplyDefinedSymbolOnly", 0 },
+  { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
+    "UndefinedSymbolOnly", 0 },
 
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN",
-   "Enabled", "Enabled", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:5",
-   "X86 Image Only", "X86Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:6",
-   "X64 Image Only", "X64Image", 0},
-  {"CreateHotPatchableImage", "FUNCTIONPADMIN:16",
-   "Itanium Image Only", "ItaniumImage", 0},
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
+    "X86Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
+    "X64Image", 0 },
+  { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
+    "ItaniumImage", 0 },
 
-  {"UACExecutionLevel", "level='asInvoker'",
-   "asInvoker", "AsInvoker", 0},
-  {"UACExecutionLevel", "level='highestAvailable'",
-   "highestAvailable", "HighestAvailable", 0},
-  {"UACExecutionLevel", "level='requireAdministrator'",
-   "requireAdministrator", "RequireAdministrator", 0},
+  { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
+  { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
+    "HighestAvailable", 0 },
+  { "UACExecutionLevel", "level='requireAdministrator'",
+    "requireAdministrator", "RequireAdministrator", 0 },
 
-  {"SubSystem", "",
-   "Not Set", "NotSet", 0},
-  {"SubSystem", "SUBSYSTEM:CONSOLE",
-   "Console", "Console", 0},
-  {"SubSystem", "SUBSYSTEM:WINDOWS",
-   "Windows", "Windows", 0},
-  {"SubSystem", "SUBSYSTEM:NATIVE",
-   "Native", "Native", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_APPLICATION",
-   "EFI Application", "EFI Application", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
-   "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_ROM",
-   "EFI ROM", "EFI ROM", 0},
-  {"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER",
-   "EFI Runtime", "EFI Runtime", 0},
-  {"SubSystem", "SUBSYSTEM:POSIX",
-   "POSIX", "POSIX", 0},
+  { "SubSystem", "", "Not Set", "NotSet", 0 },
+  { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
+  { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
+  { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
+    "EFI Application", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+    "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
+  { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
+    0 },
+  { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
 
-  {"Driver", "",
-   "Not Set", "NotSet", 0},
-  {"Driver", "Driver",
-   "Driver", "Driver", 0},
-  {"Driver", "DRIVER:UPONLY",
-   "UP Only", "UpOnly", 0},
-  {"Driver", "DRIVER:WDM",
-   "WDM", "WDM", 0},
+  { "Driver", "", "Not Set", "NotSet", 0 },
+  { "Driver", "Driver", "Driver", "Driver", 0 },
+  { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
+  { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
 
-  {"LinkTimeCodeGeneration", "",
-   "Default", "Default", 0},
-  {"LinkTimeCodeGeneration", "LTCG",
-   "Use Link Time Code Generation", "UseLinkTimeCodeGeneration", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGInstrument",
-   "Profile Guided Optimization - Instrument", "PGInstrument", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGOptimize",
-   "Profile Guided Optimization - Optimization", "PGOptimization", 0},
-  {"LinkTimeCodeGeneration", "LTCG:PGUpdate",
-   "Profile Guided Optimization - Update", "PGUpdate", 0},
+  { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
+  { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
+    "UseLinkTimeCodeGeneration", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
+    "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
+    "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
+  { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
+    "Profile Guided Optimization - Update", "PGUpdate", 0 },
 
-  {"GenerateWindowsMetadata", "WINMD",
-   "Yes", "true", 0},
-  {"GenerateWindowsMetadata", "WINMD:NO",
-   "No", "false", 0},
+  { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
+  { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
 
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1",
-   "SHA1", "SHA1", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256",
-   "SHA256", "SHA256", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384",
-   "SHA384", "SHA384", 0},
-  {"WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512",
-   "SHA512", "SHA512", 0},
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
+  { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
 
-  {"TargetMachine", "",
-   "Not Set", "NotSet", 0},
-  {"TargetMachine", "MACHINE:ARM",
-   "MachineARM", "MachineARM", 0},
-  {"TargetMachine", "MACHINE:EBC",
-   "MachineEBC", "MachineEBC", 0},
-  {"TargetMachine", "MACHINE:IA64",
-   "MachineIA64", "MachineIA64", 0},
-  {"TargetMachine", "MACHINE:MIPS",
-   "MachineMIPS", "MachineMIPS", 0},
-  {"TargetMachine", "MACHINE:MIPS16",
-   "MachineMIPS16", "MachineMIPS16", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU",
-   "MachineMIPSFPU", "MachineMIPSFPU", 0},
-  {"TargetMachine", "MACHINE:MIPSFPU16",
-   "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
-  {"TargetMachine", "MACHINE:SH4",
-   "MachineSH4", "MachineSH4", 0},
-  {"TargetMachine", "MACHINE:THUMB",
-   "MachineTHUMB", "MachineTHUMB", 0},
-  {"TargetMachine", "MACHINE:X64",
-   "MachineX64", "MachineX64", 0},
-  {"TargetMachine", "MACHINE:X86",
-   "MachineX86", "MachineX86", 0},
+  { "TargetMachine", "", "Not Set", "NotSet", 0 },
+  { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
+  { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
+  { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
+  { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
+  { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
+  { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
+    0 },
+  { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
+    "MachineMIPSFPU16", 0 },
+  { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
+  { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
+  { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
+  { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
 
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA",
-   "MTA threading attribute", "MTAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA",
-   "STA threading attribute", "STAThreadingAttribute", 0},
-  {"CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
-   "Default threading attribute", "DefaultThreadingAttribute", 0},
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
+    "MTAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
+    "STAThreadingAttribute", 0 },
+  { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
+    "Default threading attribute", "DefaultThreadingAttribute", 0 },
 
-  {"CLRImageType", "CLRIMAGETYPE:IJW",
-   "Force IJW image", "ForceIJWImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:PURE",
-   "Force Pure IL Image", "ForcePureILImage", 0},
-  {"CLRImageType", "CLRIMAGETYPE:SAFE",
-   "Force Safe IL Image", "ForceSafeILImage", 0},
-  {"CLRImageType", "",
-   "Default image type", "Default", 0},
+  { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
+    0 },
+  { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
+    "ForcePureILImage", 0 },
+  { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
+    "ForceSafeILImage", 0 },
+  { "CLRImageType", "", "Default image type", "Default", 0 },
 
-  {"SignHash", "CLRSIGNHASH:SHA1",
-   "SHA1", "SHA1", 0},
-  {"SignHash", "CLRSIGNHASH:SHA256",
-   "SHA256", "SHA256", 0},
-  {"SignHash", "CLRSIGNHASH:SHA384",
-   "SHA384", "SHA384", 0},
-  {"SignHash", "CLRSIGNHASH:SHA512",
-   "SHA512", "SHA512", 0},
+  { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
+  { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
 
-  {"LinkErrorReporting", "ERRORREPORT:PROMPT",
-   "PromptImmediately", "PromptImmediately", 0},
-  {"LinkErrorReporting", "ERRORREPORT:QUEUE",
-   "Queue For Next Login", "QueueForNextLogin", 0},
-  {"LinkErrorReporting", "ERRORREPORT:SEND",
-   "Send Error Report", "SendErrorReport", 0},
-  {"LinkErrorReporting", "ERRORREPORT:NONE",
-   "No Error Report", "NoErrorReport", 0},
+  { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
+    "PromptImmediately", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
+    "QueueForNextLogin", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
+    "SendErrorReport", 0 },
+  { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
+    "NoErrorReport", 0 },
 
-  {"CLRSupportLastError", "CLRSupportLastError",
-   "Enabled", "Enabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:NO",
-   "Disabled", "Disabled", 0},
-  {"CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL",
-   "System Dlls Only", "SystemDlls", 0},
+  { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
+  { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
+    0 },
+  { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
+    "SystemDlls", 0 },
 
+  // Bool Properties
+  { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
+  { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
+  { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
+  { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
+  { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
+  { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
+  { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
+  { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
+  { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
+  { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
+  { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
+  { "GenerateManifest", "MANIFEST", "", "true", 0 },
+  { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
+  { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
+  { "ManifestEmbed", "manifest:embed", "", "true", 0 },
+  { "GenerateDebugInformation", "DEBUG:FASTLINK", "", "DebugFastLink",
+    cmVS7FlagTable::CaseInsensitive },
+  { "GenerateDebugInformation", "DEBUG", "", "Debug",
+    cmVS7FlagTable::CaseInsensitive },
+  { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
+  { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
+  { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
+  { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
+  { "TerminalServerAware", "TSAWARE", "", "true", 0 },
+  { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
+  { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
+  { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
+  { "OptimizeReferences", "OPT:REF", "", "true", 0 },
+  { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
+  { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
+  { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
+  { "AppContainer", "APPCONTAINER", "", "true", 0 },
+  { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
+  { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
+  { "NoEntryPoint", "NOENTRY", "", "true", 0 },
+  { "SetChecksum", "RELEASE", "", "true", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
+  { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
+  { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
+  { "FixedBaseAddress", "FIXED", "", "true", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
+  { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
+  { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
+  { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
+  { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
+  { "Profile", "PROFILE", "", "true", 0 },
+  { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
+  { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
+  { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
+  { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
+  { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
+  { "LinkDLL", "DLL", "", "true", 0 },
 
-  //Bool Properties
-  {"LinkIncremental", "INCREMENTAL:NO", "", "false", 0},
-  {"LinkIncremental", "INCREMENTAL", "", "true", 0},
-  {"SuppressStartupBanner", "NOLOGO", "", "true", 0},
-  {"LinkStatus", "LTCG:NOSTATUS", "", "false", 0},
-  {"LinkStatus", "LTCG:STATUS", "", "true", 0},
-  {"PreventDllBinding", "ALLOWBIND:NO", "", "false", 0},
-  {"PreventDllBinding", "ALLOWBIND", "", "true", 0},
-  {"TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0},
-  {"TreatLinkerWarningAsErrors", "WX", "", "true", 0},
-  {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
-  {"GenerateManifest", "MANIFEST:NO", "", "false", 0},
-  {"GenerateManifest", "MANIFEST", "", "true", 0},
-  {"AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0},
-  {"UACUIAccess", "uiAccess='false'", "", "false", 0},
-  {"UACUIAccess", "uiAccess='true'", "", "true", 0},
-  {"ManifestEmbed", "manifest:embed", "", "true", 0},
-  {"GenerateDebugInformation", "DEBUG:FASTLINK", "", "DebugFastLink",
-   cmVS7FlagTable::CaseInsensitive},
-  {"GenerateDebugInformation", "DEBUG", "", "Debug",
-   cmVS7FlagTable::CaseInsensitive},
-  {"MapExports", "MAPINFO:EXPORTS", "", "true", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0},
-  {"AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0},
-  {"LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0},
-  {"TerminalServerAware", "TSAWARE:NO", "", "false", 0},
-  {"TerminalServerAware", "TSAWARE", "", "true", 0},
-  {"SwapRunFromCD", "SWAPRUN:CD", "", "true", 0},
-  {"SwapRunFromNET", "SWAPRUN:NET", "", "true", 0},
-  {"OptimizeReferences", "OPT:NOREF", "", "false", 0},
-  {"OptimizeReferences", "OPT:REF", "", "true", 0},
-  {"EnableCOMDATFolding", "OPT:NOICF", "", "false", 0},
-  {"EnableCOMDATFolding", "OPT:ICF", "", "true", 0},
-  {"IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0},
-  {"AppContainer", "APPCONTAINER", "", "true", 0},
-  {"WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0},
-  {"WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0},
-  {"NoEntryPoint", "NOENTRY", "", "true", 0},
-  {"SetChecksum", "RELEASE", "", "true", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0},
-  {"RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0},
-  {"FixedBaseAddress", "FIXED:NO", "", "false", 0},
-  {"FixedBaseAddress", "FIXED", "", "true", 0},
-  {"DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0},
-  {"DataExecutionPrevention", "NXCOMPAT", "", "true", 0},
-  {"TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0},
-  {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
-  {"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0},
-  {"Profile", "PROFILE", "", "true", 0},
-  {"LinkDelaySign", "DELAYSIGN:NO", "", "false", 0},
-  {"LinkDelaySign", "DELAYSIGN", "", "true", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
-  {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
-  {"DetectOneDefinitionRule", "ODR", "", "true", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0},
-  {"ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0},
-  {"LinkDLL", "DLL", "", "true", 0},
+  // Bool Properties With Argument
+  { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
+  { "EnableUAC", "MANIFESTUAC:", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
+    cmVS7FlagTable::UserValueRequired },
+  { "GenerateMapFile", "MAP", "", "true",
+    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
+  { "MapFileName", "MAP:", "Generate Map File", "",
+    cmVS7FlagTable::UserValueRequired },
 
-  //Bool Properties With Argument
-  {"EnableUAC", "MANIFESTUAC:NO", "", "false", 0},
-  {"EnableUAC", "MANIFESTUAC:", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
-   cmVS7FlagTable::UserValueRequired},
-  {"GenerateMapFile", "MAP", "", "true",
-   cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
-  {"MapFileName", "MAP:", "Generate Map File", "",
-   cmVS7FlagTable::UserValueRequired},
-
-  //String List Properties
-  {"AdditionalLibraryDirectories", "LIBPATH:",
-   "Additional Library Directories",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "AdditionalLibraryDirectories", "LIBPATH:",
+    "Additional Library Directories", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
-  {"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
-   "Ignore Specific Default Libraries",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AddModuleNamesToAssembly", "ASSEMBLYMODULE:",
-   "Add Module to Assembly",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
-   "Embed Managed Resource File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ForceSymbolReferences", "INCLUDE:",
-   "Force Symbol References",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"DelayLoadDLLs", "DELAYLOAD:",
-   "Delay Loaded Dlls",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:",
-   "Assembly Link Resource",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
-   "Additional Manifest Dependencies",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"ManifestInput", "manifestinput:",
-   "Manifest Input",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
+    "Ignore Specific Default Libraries", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
+    "Embed Managed Resource File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
+    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
+    "Additional Manifest Dependencies", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "ManifestInput", "manifestinput:", "Manifest Input", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
 
-  //String Properties
-  {"OutputFile", "OUT:",
-   "Output File",
-   "", cmVS7FlagTable::UserValue},
-  {"Version", "VERSION:",
-   "Version",
-   "", cmVS7FlagTable::UserValue},
-  {"SpecifySectionAttributes", "SECTION:",
-   "Specify Section Attributes",
-   "", cmVS7FlagTable::UserValue},
-  {"MSDOSStubFileName", "STUB:",
-   "MS-DOS Stub File Name",
-   "", cmVS7FlagTable::UserValue},
+  // String Properties
+  { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
+  { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
+  { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
+    cmVS7FlagTable::UserValue },
+  { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
+    cmVS7FlagTable::UserValue },
   // Skip [TrackerLogDirectory] - no command line Switch.
-  {"ModuleDefinitionFile", "DEF:",
-   "Module Definition File",
-   "", cmVS7FlagTable::UserValue},
-  {"ManifestFile", "ManifestFile:",
-   "Manifest File",
-   "", cmVS7FlagTable::UserValue},
-  {"ProgramDatabaseFile", "PDB:",
-   "Generate Program Database File",
-   "", cmVS7FlagTable::UserValue},
-  {"StripPrivateSymbols", "PDBSTRIPPED:",
-   "Strip Private Symbols",
-   "", cmVS7FlagTable::UserValue},
+  { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
+    cmVS7FlagTable::UserValue },
+  { "ManifestFile", "ManifestFile:", "Manifest File", "",
+    cmVS7FlagTable::UserValue },
+  { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
+    cmVS7FlagTable::UserValue },
+  { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
+    cmVS7FlagTable::UserValue },
   // Skip [MapFileName] - no command line Switch.
   // Skip [MinimumRequiredVersion] - no command line Switch.
-  {"HeapReserveSize", "HEAP:",
-   "Heap Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [HeapCommitSize] - no command line Switch.
-  {"StackReserveSize", "STACK:",
-   "Stack Reserve Size",
-   "", cmVS7FlagTable::UserValue},
+  { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
+    cmVS7FlagTable::UserValue },
   // Skip [StackCommitSize] - no command line Switch.
-  {"FunctionOrder", "ORDER:@",
-   "Function Order",
-   "", cmVS7FlagTable::UserValue},
-  {"ProfileGuidedDatabase", "PGD:",
-   "Profile Guided Database",
-   "", cmVS7FlagTable::UserValue},
-  {"MidlCommandFile", "MIDL:@",
-   "MIDL Commands",
-   "", cmVS7FlagTable::UserValue},
-  {"MergedIDLBaseFileName", "IDLOUT:",
-   "Merged IDL Base File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"TypeLibraryFile", "TLBOUT:",
-   "Type Library",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataFile", "WINMDFILE:",
-   "Windows Metadata File",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataLinkKeyFile", "WINMDKEYFILE:",
-   "Windows Metadata Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
-   "Windows Metadata Key Container",
-   "", cmVS7FlagTable::UserValue},
-  {"EntryPointSymbol", "ENTRY:",
-   "Entry Point",
-   "", cmVS7FlagTable::UserValue},
-  {"BaseAddress", "BASE:",
-   "Base Address",
-   "", cmVS7FlagTable::UserValue},
-  {"ImportLibrary", "IMPLIB:",
-   "Import Library",
-   "", cmVS7FlagTable::UserValue},
-  {"MergeSections", "MERGE:",
-   "Merge Sections",
-   "", cmVS7FlagTable::UserValue},
-  {"LinkKeyFile", "KEYFILE:",
-   "Key File",
-   "", cmVS7FlagTable::UserValue},
-  {"KeyContainer", "KEYCONTAINER:",
-   "Key Container",
-   "", cmVS7FlagTable::UserValue},
+  { "FunctionOrder", "ORDER:@", "Function Order", "",
+    cmVS7FlagTable::UserValue },
+  { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
+    cmVS7FlagTable::UserValue },
+  { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
+    cmVS7FlagTable::UserValue },
+  { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
+    cmVS7FlagTable::UserValue },
+  { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
+    cmVS7FlagTable::UserValue },
+  { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
+    "", cmVS7FlagTable::UserValue },
+  { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
+    "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
+  { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
+    cmVS7FlagTable::UserValue },
+  { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
+  { "ImportLibrary", "IMPLIB:", "Import Library", "",
+    cmVS7FlagTable::UserValue },
+  { "MergeSections", "MERGE:", "Merge Sections", "",
+    cmVS7FlagTable::UserValue },
+  { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
+  { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
+    cmVS7FlagTable::UserValue },
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS14MASMFlagTable.h b/Source/cmVS14MASMFlagTable.h
index dce846f..c4e5e1e 100644
--- a/Source/cmVS14MASMFlagTable.h
+++ b/Source/cmVS14MASMFlagTable.h
@@ -1,96 +1,78 @@
-static cmVS7FlagTable cmVS14MASMFlagTable[] =
-{
+static cmVS7FlagTable cmVS14MASMFlagTable[] = {
 
-  //Enum Properties
-  {"PreserveIdentifierCase", "",
-   "Default", "0", 0},
-  {"PreserveIdentifierCase", "/Cp",
-   "Preserves Identifier Case (/Cp)", "1", 0},
-  {"PreserveIdentifierCase", "/Cu",
-   "Maps all identifiers to upper case. (/Cu)", "2", 0},
-  {"PreserveIdentifierCase", "/Cx",
-   "Preserves case in public and extern symbols. (/Cx)", "3", 0},
+  // Enum Properties
+  { "PreserveIdentifierCase", "", "Default", "0", 0 },
+  { "PreserveIdentifierCase", "/Cp", "Preserves Identifier Case (/Cp)", "1",
+    0 },
+  { "PreserveIdentifierCase", "/Cu",
+    "Maps all identifiers to upper case. (/Cu)", "2", 0 },
+  { "PreserveIdentifierCase", "/Cx",
+    "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
 
-  {"WarningLevel", "/W0",
-   "Warning Level 0 (/W0)", "0", 0},
-  {"WarningLevel", "/W1",
-   "Warning Level 1 (/W1)", "1", 0},
-  {"WarningLevel", "/W2",
-   "Warning Level 2 (/W2)", "2", 0},
-  {"WarningLevel", "/W3",
-   "Warning Level 3 (/W3)", "3", 0},
+  { "WarningLevel", "/W0", "Warning Level 0 (/W0)", "0", 0 },
+  { "WarningLevel", "/W1", "Warning Level 1 (/W1)", "1", 0 },
+  { "WarningLevel", "/W2", "Warning Level 2 (/W2)", "2", 0 },
+  { "WarningLevel", "/W3", "Warning Level 3 (/W3)", "3", 0 },
 
-  {"PackAlignmentBoundary", "",
-   "Default", "0", 0},
-  {"PackAlignmentBoundary", "/Zp1",
-   "One Byte Boundary (/Zp1)", "1", 0},
-  {"PackAlignmentBoundary", "/Zp2",
-   "Two Byte Boundary (/Zp2)", "2", 0},
-  {"PackAlignmentBoundary", "/Zp4",
-   "Four Byte Boundary (/Zp4)", "3", 0},
-  {"PackAlignmentBoundary", "/Zp8",
-   "Eight Byte Boundary (/Zp8)", "4", 0},
-  {"PackAlignmentBoundary", "/Zp16",
-   "Sixteen Byte Boundary (/Zp16)", "5", 0},
+  { "PackAlignmentBoundary", "", "Default", "0", 0 },
+  { "PackAlignmentBoundary", "/Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
+  { "PackAlignmentBoundary", "/Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
+  { "PackAlignmentBoundary", "/Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
+  { "PackAlignmentBoundary", "/Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
+  { "PackAlignmentBoundary", "/Zp16", "Sixteen Byte Boundary (/Zp16)", "5",
+    0 },
 
-  {"CallingConvention", "",
-   "Default", "0", 0},
-  {"CallingConvention", "/Gd",
-   "Use C-style Calling Convention (/Gd)", "1", 0},
-  {"CallingConvention", "/Gz",
-   "Use stdcall Calling Convention (/Gz)", "2", 0},
-  {"CallingConvention", "/Gc",
-   "Use Pascal Calling Convention (/Gc)", "3", 0},
+  { "CallingConvention", "", "Default", "0", 0 },
+  { "CallingConvention", "/Gd", "Use C-style Calling Convention (/Gd)", "1",
+    0 },
+  { "CallingConvention", "/Gz", "Use stdcall Calling Convention (/Gz)", "2",
+    0 },
+  { "CallingConvention", "/Gc", "Use Pascal Calling Convention (/Gc)", "3",
+    0 },
 
-  {"ErrorReporting", "/errorReport:prompt",
-   "Prompt to send report immediately (/errorReport:prompt)", "0", 0},
-  {"ErrorReporting", "/errorReport:queue",
-   "Prompt to send report at the next logon (/errorReport:queue)", "1", 0},
-  {"ErrorReporting", "/errorReport:send",
-   "Automatically send report (/errorReport:send)", "2", 0},
-  {"ErrorReporting", "/errorReport:none",
-   "Do not send report (/errorReport:none)", "3", 0},
+  { "ErrorReporting", "/errorReport:prompt",
+    "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
+  { "ErrorReporting", "/errorReport:queue",
+    "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
+  { "ErrorReporting", "/errorReport:send",
+    "Automatically send report (/errorReport:send)", "2", 0 },
+  { "ErrorReporting", "/errorReport:none",
+    "Do not send report (/errorReport:none)", "3", 0 },
 
+  // Bool Properties
+  { "NoLogo", "/nologo", "", "true", 0 },
+  { "GeneratePreprocessedSourceListing", "/EP", "", "true", 0 },
+  { "ListAllAvailableInformation", "/Sa", "", "true", 0 },
+  { "UseSafeExceptionHandlers", "/safeseh", "", "true", 0 },
+  { "AddFirstPassListing", "/Sf", "", "true", 0 },
+  { "EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0 },
+  { "DisableSymbolTable", "/Sn", "", "true", 0 },
+  { "EnableFalseConditionalsInListing", "/Sx", "", "true", 0 },
+  { "TreatWarningsAsErrors", "/WX", "", "true", 0 },
+  { "MakeAllSymbolsPublic", "/Zf", "", "true", 0 },
+  { "GenerateDebugInformation", "/Zi", "", "true", 0 },
+  { "EnableMASM51Compatibility", "/Zm", "", "true", 0 },
+  { "PerformSyntaxCheckOnly", "/Zs", "", "true", 0 },
 
-  //Bool Properties
-  {"NoLogo", "/nologo", "", "true", 0},
-  {"GeneratePreprocessedSourceListing", "/EP", "", "true", 0},
-  {"ListAllAvailableInformation", "/Sa", "", "true", 0},
-  {"UseSafeExceptionHandlers", "/safeseh", "", "true", 0},
-  {"AddFirstPassListing", "/Sf", "", "true", 0},
-  {"EnableAssemblyGeneratedCodeListing", "/Sg", "", "true", 0},
-  {"DisableSymbolTable", "/Sn", "", "true", 0},
-  {"EnableFalseConditionalsInListing", "/Sx", "", "true", 0},
-  {"TreatWarningsAsErrors", "/WX", "", "true", 0},
-  {"MakeAllSymbolsPublic", "/Zf", "", "true", 0},
-  {"GenerateDebugInformation", "/Zi", "", "true", 0},
-  {"EnableMASM51Compatibility", "/Zm", "", "true", 0},
-  {"PerformSyntaxCheckOnly", "/Zs", "", "true", 0},
+  // Bool Properties With Argument
 
-  //Bool Properties With Argument
-
-  //String List Properties
-  {"PreprocessorDefinitions", "/D",
-   "Preprocessor Definitions",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"IncludePaths", "/I",
-   "Include Paths",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"BrowseFile", "/FR",
-   "Generate Browse Information File",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  // String List Properties
+  { "PreprocessorDefinitions", "/D", "Preprocessor Definitions", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "IncludePaths", "/I", "Include Paths", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+  { "BrowseFile", "/FR", "Generate Browse Information File", "",
+    cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
   // Skip [AdditionalDependencies] - no command line Switch.
 
-  //String Properties
+  // String Properties
   // Skip [Inputs] - no command line Switch.
-  {"ObjectFileName", "/Fo",
-   "Object File Name",
-   "", cmVS7FlagTable::UserValue},
-  {"AssembledCodeListingFile", "/Fl",
-   "Assembled Code Listing File",
-   "", cmVS7FlagTable::UserValue},
+  { "ObjectFileName", "/Fo", "Object File Name", "",
+    cmVS7FlagTable::UserValue },
+  { "AssembledCodeListingFile", "/Fl", "Assembled Code Listing File", "",
+    cmVS7FlagTable::UserValue },
   // Skip [CommandLineTemplate] - no command line Switch.
   // Skip [ExecutionDescription] - no command line Switch.
   // Skip [AdditionalOptions] - no command line Switch.
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVS14RCFlagTable.h b/Source/cmVS14RCFlagTable.h
index ebd8d65..11e00d5 100644
--- a/Source/cmVS14RCFlagTable.h
+++ b/Source/cmVS14RCFlagTable.h
@@ -1,7 +1,6 @@
-static cmVS7FlagTable cmVS14RCFlagTable[] =
-{
-  //Bool Properties
-  {"NullTerminateStrings", "n", "", "true", 0},
+static cmVS7FlagTable cmVS14RCFlagTable[] = {
+  // Bool Properties
+  { "NullTerminateStrings", "n", "", "true", 0 },
 
-  {0,0,0,0,0}
+  { 0, 0, 0, 0, 0 }
 };
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index 1d33db1..8d55b0e 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -10,70 +10,65 @@
   See the License for more information.
 ============================================================================*/
 #include "cmVariableRequiresCommand.h"
+
 #include "cmState.h"
 
 // cmLibraryCommand
-bool cmVariableRequiresCommand
-::InitialPass(std::vector<std::string>const& args, cmExecutionStatus &)
+bool cmVariableRequiresCommand::InitialPass(
+  std::vector<std::string> const& args, cmExecutionStatus&)
 {
-  if(this->Disallowed(cmPolicies::CMP0035,
-      "The variable_requires command should not be called; see CMP0035."))
-    { return true; }
-  if(args.size() < 3 )
-    {
+  if (this->Disallowed(
+        cmPolicies::CMP0035,
+        "The variable_requires command should not be called; see CMP0035.")) {
+    return true;
+  }
+  if (args.size() < 3) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   std::string testVariable = args[0];
-  if(!this->Makefile->IsOn(testVariable))
-    {
+  if (!this->Makefile->IsOn(testVariable)) {
     return true;
-    }
+  }
   std::string resultVariable = args[1];
   bool requirementsMet = true;
   std::string notSet;
   bool hasAdvanced = false;
   cmState* state = this->Makefile->GetState();
-  for(unsigned int i = 2; i < args.size(); ++i)
-    {
-    if(!this->Makefile->IsOn(args[i]))
-      {
+  for (unsigned int i = 2; i < args.size(); ++i) {
+    if (!this->Makefile->IsOn(args[i])) {
       requirementsMet = false;
       notSet += args[i];
       notSet += "\n";
-      if(state->GetCacheEntryValue(args[i]) &&
-          state->GetCacheEntryPropertyAsBool(args[i], "ADVANCED"))
-        {
+      if (state->GetCacheEntryValue(args[i]) &&
+          state->GetCacheEntryPropertyAsBool(args[i], "ADVANCED")) {
         hasAdvanced = true;
-        }
       }
     }
+  }
   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)))
-    {
+  if (!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) {
     this->Makefile->AddDefinition(resultVariable, requirementsMet);
-    }
+  }
 
-  if(!requirementsMet)
-    {
+  if (!requirementsMet) {
     std::string message = "Variable assertion failed:\n";
-    message += testVariable +
-      " Requires that the following unset variables are set:\n";
+    message +=
+      testVariable + " Requires that the following unset variables are set:\n";
     message += notSet;
     message += "\nPlease set them, or set ";
     message += testVariable + " to false, and re-configure.\n";
-    if(hasAdvanced)
-      {
+    if (hasAdvanced) {
       message +=
         "One or more of the required variables is advanced."
         "  To set the variable, you must turn on advanced mode in cmake.";
-      }
-    cmSystemTools::Error(message.c_str());
     }
+    cmSystemTools::Error(message.c_str());
+  }
 
   return true;
 }
diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h
index 5b0477f..b83f615 100644
--- a/Source/cmVariableRequiresCommand.h
+++ b/Source/cmVariableRequiresCommand.h
@@ -20,9 +20,8 @@ public:
   cmTypeMacro(cmVariableRequiresCommand, cmCommand);
   virtual cmCommand* Clone() { return new cmVariableRequiresCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
-  virtual std::string GetName() const { return "variable_requires";}
+                           cmExecutionStatus& status);
+  virtual std::string GetName() const { return "variable_requires"; }
 };
 
-
 #endif
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index a200718..11eaa93 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -13,22 +13,18 @@
 
 #include "cmAlgorithms.h"
 
-static const char* const cmVariableWatchAccessStrings[] =
-{
-    "READ_ACCESS",
-    "UNKNOWN_READ_ACCESS",
-    "UNKNOWN_DEFINED_ACCESS",
-    "MODIFIED_ACCESS",
-    "REMOVED_ACCESS",
-    "NO_ACCESS"
+#include <cmsys/auto_ptr.hxx>
+
+static const char* const cmVariableWatchAccessStrings[] = {
+  "READ_ACCESS",     "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
+  "MODIFIED_ACCESS", "REMOVED_ACCESS",      "NO_ACCESS"
 };
 
 const char* cmVariableWatch::GetAccessAsString(int access_type)
 {
-  if ( access_type < 0 || access_type >= cmVariableWatch::NO_ACCESS )
-    {
+  if (access_type < 0 || access_type >= cmVariableWatch::NO_ACCESS) {
     return "NO_ACCESS";
-    }
+  }
   return cmVariableWatchAccessStrings[access_type];
 }
 
@@ -36,7 +32,7 @@ cmVariableWatch::cmVariableWatch()
 {
 }
 
-template<typename C>
+template <typename C>
 void deleteAllSecond(typename C::value_type it)
 {
   cmDeleteAll(it.second);
@@ -48,71 +44,61 @@ cmVariableWatch::~cmVariableWatch()
                 deleteAllSecond<cmVariableWatch::StringToVectorOfPairs>);
 }
 
-bool cmVariableWatch::AddWatch(const std::string& variable,
-                               WatchMethod method, void* client_data /*=0*/,
+bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
+                               void* client_data /*=0*/,
                                DeleteData delete_data /*=0*/)
 {
-  cmVariableWatch::Pair* p = new cmVariableWatch::Pair;
+  cmsys::auto_ptr<cmVariableWatch::Pair> p(new cmVariableWatch::Pair);
   p->Method = method;
   p->ClientData = client_data;
   p->DeleteDataCall = delete_data;
   cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
   cmVariableWatch::VectorOfPairs::size_type cc;
-  for ( cc = 0; cc < vp->size(); cc ++ )
-    {
+  for (cc = 0; cc < vp->size(); cc++) {
     cmVariableWatch::Pair* pair = (*vp)[cc];
-    if ( pair->Method == method &&
-         client_data && client_data == pair->ClientData)
-      {
+    if (pair->Method == method && client_data &&
+        client_data == pair->ClientData) {
       // Callback already exists
       return false;
-      }
     }
-  vp->push_back(p);
+  }
+  vp->push_back(p.release());
   return true;
 }
 
 void cmVariableWatch::RemoveWatch(const std::string& variable,
-                                  WatchMethod method,
-                                  void* client_data /*=0*/)
+                                  WatchMethod method, void* client_data /*=0*/)
 {
-  if ( !this->WatchMap.count(variable) )
-    {
+  if (!this->WatchMap.count(variable)) {
     return;
-    }
+  }
   cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
   cmVariableWatch::VectorOfPairs::iterator it;
-  for ( it = vp->begin(); it != vp->end(); ++it )
-    {
-    if ( (*it)->Method == method &&
-         // If client_data is NULL, we want to disconnect all watches against
-         // the given method; otherwise match ClientData as well.
-         (!client_data || (client_data == (*it)->ClientData)))
-      {
+  for (it = vp->begin(); it != vp->end(); ++it) {
+    if ((*it)->Method == method &&
+        // If client_data is NULL, we want to disconnect all watches against
+        // the given method; otherwise match ClientData as well.
+        (!client_data || (client_data == (*it)->ClientData))) {
       delete *it;
       vp->erase(it);
       return;
-      }
     }
+  }
 }
 
-bool  cmVariableWatch::VariableAccessed(const std::string& variable,
-                                        int access_type,
-                                        const char* newValue,
-                                        const cmMakefile* mf) const
+bool cmVariableWatch::VariableAccessed(const std::string& variable,
+                                       int access_type, const char* newValue,
+                                       const cmMakefile* mf) const
 {
   cmVariableWatch::StringToVectorOfPairs::const_iterator mit =
     this->WatchMap.find(variable);
-  if ( mit  != this->WatchMap.end() )
-    {
+  if (mit != this->WatchMap.end()) {
     const cmVariableWatch::VectorOfPairs* vp = &mit->second;
     cmVariableWatch::VectorOfPairs::const_iterator it;
-    for ( it = vp->begin(); it != vp->end(); it ++ )
-      {
-      (*it)->Method(variable, access_type, (*it)->ClientData,
-        newValue, mf);
-      }
-    return true;
+    for (it = vp->begin(); it != vp->end(); it++) {
+      (*it)->Method(variable, access_type, (*it)->ClientData, newValue, mf);
     }
+    return true;
+  }
   return false;
 }
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 2f082af..be8f72f 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -25,7 +25,8 @@ class cmVariableWatch
 {
 public:
   typedef void (*WatchMethod)(const std::string& variable, int access_type,
-    void* client_data, const char* newValue, const cmMakefile* mf);
+                              void* client_data, const char* newValue,
+                              const cmMakefile* mf);
   typedef void (*DeleteData)(void* client_data);
 
   cmVariableWatch();
@@ -35,28 +36,28 @@ public:
    * Add watch to the variable
    */
   bool AddWatch(const std::string& variable, WatchMethod method,
-                void* client_data=0, DeleteData delete_data=0);
+                void* client_data = 0, DeleteData delete_data = 0);
   void RemoveWatch(const std::string& variable, WatchMethod method,
-                   void* client_data=0);
+                   void* client_data = 0);
 
   /**
    * This method is called when variable is accessed
    */
   bool VariableAccessed(const std::string& variable, int access_type,
-    const char* newValue, const cmMakefile* mf) const;
+                        const char* newValue, const cmMakefile* mf) const;
 
   /**
    * Different access types.
    */
   enum
-    {
+  {
     VARIABLE_READ_ACCESS = 0,
     UNKNOWN_VARIABLE_READ_ACCESS,
     UNKNOWN_VARIABLE_DEFINED_ACCESS,
     VARIABLE_MODIFIED_ACCESS,
     VARIABLE_REMOVED_ACCESS,
     NO_ACCESS
-    };
+  };
 
   /**
    * Return the access as string
@@ -67,23 +68,26 @@ protected:
   struct Pair
   {
     WatchMethod Method;
-    void*        ClientData;
-    DeleteData   DeleteDataCall;
-    Pair() : Method(0), ClientData(0), DeleteDataCall(0) {}
+    void* ClientData;
+    DeleteData DeleteDataCall;
+    Pair()
+      : Method(0)
+      , ClientData(0)
+      , DeleteDataCall(0)
+    {
+    }
     ~Pair()
-      {
-      if (this->DeleteDataCall && this->ClientData)
-        {
+    {
+      if (this->DeleteDataCall && this->ClientData) {
         this->DeleteDataCall(this->ClientData);
-        }
       }
+    }
   };
 
-  typedef std::vector< Pair* > VectorOfPairs;
-  typedef std::map<std::string, VectorOfPairs > StringToVectorOfPairs;
+  typedef std::vector<Pair*> VectorOfPairs;
+  typedef std::map<std::string, VectorOfPairs> StringToVectorOfPairs;
 
   StringToVectorOfPairs WatchMap;
 };
 
-
 #endif
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 98a397c..f30ffe8 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -13,25 +13,24 @@
 
 #include "cmVariableWatch.h"
 
-//----------------------------------------------------------------------------
 struct cmVariableWatchCallbackData
 {
   bool InCallback;
   std::string Command;
 };
 
-//----------------------------------------------------------------------------
-static void cmVariableWatchCommandVariableAccessed(
-  const std::string& variable, int access_type, void* client_data,
-  const char* newValue, const cmMakefile* mf)
+static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
+                                                   int access_type,
+                                                   void* client_data,
+                                                   const char* newValue,
+                                                   const cmMakefile* mf)
 {
-  cmVariableWatchCallbackData* data
-    = static_cast<cmVariableWatchCallbackData*>(client_data);
+  cmVariableWatchCallbackData* data =
+    static_cast<cmVariableWatchCallbackData*>(client_data);
 
-  if ( data->InCallback )
-    {
+  if (data->InCallback) {
     return;
-    }
+  }
   data->InCallback = true;
 
   cmListFileFunction newLFF;
@@ -44,98 +43,82 @@ static void cmVariableWatchCommandVariableAccessed(
   cmMakefile* makefile = const_cast<cmMakefile*>(mf);
 
   std::string stack = makefile->GetProperty("LISTFILE_STACK");
-  if ( !data->Command.empty() )
-    {
+  if (!data->Command.empty()) {
     newLFF.Arguments.clear();
     newLFF.Arguments.push_back(
-      cmListFileArgument(variable, cmListFileArgument::Quoted,
-                         9999));
-    newLFF.Arguments.push_back(
-      cmListFileArgument(accessString, cmListFileArgument::Quoted,
-                         9999));
+      cmListFileArgument(variable, cmListFileArgument::Quoted, 9999));
     newLFF.Arguments.push_back(
-      cmListFileArgument(newValue?newValue:"", cmListFileArgument::Quoted,
-                         9999));
+      cmListFileArgument(accessString, cmListFileArgument::Quoted, 9999));
+    newLFF.Arguments.push_back(cmListFileArgument(
+      newValue ? newValue : "", cmListFileArgument::Quoted, 9999));
     newLFF.Arguments.push_back(
-      cmListFileArgument(currentListFile, cmListFileArgument::Quoted,
-                         9999));
+      cmListFileArgument(currentListFile, cmListFileArgument::Quoted, 9999));
     newLFF.Arguments.push_back(
-      cmListFileArgument(stack, cmListFileArgument::Quoted,
-                         9999));
+      cmListFileArgument(stack, cmListFileArgument::Quoted, 9999));
     newLFF.Name = data->Command;
     newLFF.Line = 9999;
     cmExecutionStatus status;
-    if(!makefile->ExecuteCommand(newLFF,status))
-      {
+    if (!makefile->ExecuteCommand(newLFF, status)) {
       std::ostringstream error;
       error << "Error in cmake code at\nUnknown:0:\n"
-        << "A command failed during the invocation of callback \""
-        << data->Command << "\".";
+            << "A command failed during the invocation of callback \""
+            << data->Command << "\".";
       cmSystemTools::Error(error.str().c_str());
       data->InCallback = false;
       return;
-      }
-    processed = true;
     }
-  if ( !processed )
-    {
+    processed = true;
+  }
+  if (!processed) {
     std::ostringstream msg;
     msg << "Variable \"" << variable << "\" was accessed using "
-        << accessString << " with value \"" << (newValue?newValue:"") << "\".";
+        << accessString << " with value \"" << (newValue ? newValue : "")
+        << "\".";
     makefile->IssueMessage(cmake::LOG, msg.str());
-    }
+  }
 
   data->InCallback = false;
 }
 
-//----------------------------------------------------------------------------
 static void deleteVariableWatchCallbackData(void* client_data)
 {
-  cmVariableWatchCallbackData* data
-    = static_cast<cmVariableWatchCallbackData*>(client_data);
+  cmVariableWatchCallbackData* data =
+    static_cast<cmVariableWatchCallbackData*>(client_data);
   delete data;
 }
 
-//----------------------------------------------------------------------------
 cmVariableWatchCommand::cmVariableWatchCommand()
 {
 }
 
-//----------------------------------------------------------------------------
 cmVariableWatchCommand::~cmVariableWatchCommand()
 {
   std::set<std::string>::const_iterator it;
-  for ( it = this->WatchedVariables.begin();
-        it != this->WatchedVariables.end();
-        ++it )
-    {
+  for (it = this->WatchedVariables.begin(); it != this->WatchedVariables.end();
+       ++it) {
     this->Makefile->GetCMakeInstance()->GetVariableWatch()->RemoveWatch(
       *it, cmVariableWatchCommandVariableAccessed);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-bool cmVariableWatchCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args,
+                                         cmExecutionStatus&)
 {
-  if ( args.size() < 1 )
-    {
+  if (args.size() < 1) {
     this->SetError("must be called with at least one argument.");
     return false;
-    }
+  }
   std::string variable = args[0];
   std::string command;
-  if ( args.size() > 1 )
-    {
+  if (args.size() > 1) {
     command = args[1];
-    }
-  if ( variable == "CMAKE_CURRENT_LIST_FILE" )
-    {
+  }
+  if (variable == "CMAKE_CURRENT_LIST_FILE") {
     std::ostringstream ostr;
     ostr << "cannot be set on the variable: " << variable;
     this->SetError(ostr.str());
     return false;
-    }
+  }
 
   cmVariableWatchCallbackData* data = new cmVariableWatchCallbackData;
 
@@ -143,13 +126,12 @@ bool cmVariableWatchCommand
   data->Command = command;
 
   this->WatchedVariables.insert(variable);
-  if ( !this->Makefile->GetCMakeInstance()->GetVariableWatch()->AddWatch(
-          variable, cmVariableWatchCommandVariableAccessed,
-          data, deleteVariableWatchCallbackData) )
-    {
+  if (!this->Makefile->GetCMakeInstance()->GetVariableWatch()->AddWatch(
+        variable, cmVariableWatchCommandVariableAccessed, data,
+        deleteVariableWatchCallbackData)) {
     deleteVariableWatchCallbackData(data);
     return false;
-    }
+  }
 
   return true;
 }
diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h
index c1ee9b1..aad53cb 100644
--- a/Source/cmVariableWatchCommand.h
+++ b/Source/cmVariableWatchCommand.h
@@ -24,10 +24,7 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmVariableWatchCommand;
-    }
+  virtual cmCommand* Clone() { return new cmVariableWatchCommand; }
 
   //! Default constructor
   cmVariableWatchCommand();
@@ -40,7 +37,7 @@ public:
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const& args,
-                           cmExecutionStatus &status);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -54,7 +51,7 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "variable_watch";}
+  virtual std::string GetName() const { return "variable_watch"; }
 
   cmTypeMacro(cmVariableWatchCommand, cmCommand);
 
@@ -62,7 +59,4 @@ protected:
   std::set<std::string> WatchedVariables;
 };
 
-
 #endif
-
-
diff --git a/Source/cmVersion.cxx b/Source/cmVersion.cxx
index 9cb0cd6..4c2e4ce 100644
--- a/Source/cmVersion.cxx
+++ b/Source/cmVersion.cxx
@@ -13,10 +13,22 @@
 
 #include "cmVersionMacros.h"
 
-unsigned int cmVersion::GetMajorVersion() { return CMake_VERSION_MAJOR; }
-unsigned int cmVersion::GetMinorVersion() { return CMake_VERSION_MINOR; }
-unsigned int cmVersion::GetPatchVersion() { return CMake_VERSION_PATCH; }
-unsigned int cmVersion::GetTweakVersion() { return 0; }
+unsigned int cmVersion::GetMajorVersion()
+{
+  return CMake_VERSION_MAJOR;
+}
+unsigned int cmVersion::GetMinorVersion()
+{
+  return CMake_VERSION_MINOR;
+}
+unsigned int cmVersion::GetPatchVersion()
+{
+  return CMake_VERSION_PATCH;
+}
+unsigned int cmVersion::GetTweakVersion()
+{
+  return 0;
+}
 
 const char* cmVersion::GetCMakeVersion()
 {
diff --git a/Source/cmVersion.h b/Source/cmVersion.h
index 84f750f..46fd5a6 100644
--- a/Source/cmVersion.h
+++ b/Source/cmVersion.h
@@ -35,10 +35,9 @@ public:
 /* Encode with room for up to 1000 minor releases between major releases
    and to encode dates until the year 10000 in the patch level.  */
 #define CMake_VERSION_ENCODE__BASE KWIML_INT_UINT64_C(100000000)
-#define CMake_VERSION_ENCODE(major, minor, patch) \
-  ((((major) * 1000u) * CMake_VERSION_ENCODE__BASE) + \
-   (((minor) % 1000u) * CMake_VERSION_ENCODE__BASE) + \
-   (((patch)          % CMake_VERSION_ENCODE__BASE)))
+#define CMake_VERSION_ENCODE(major, minor, patch)                             \
+  ((((major)*1000u) * CMake_VERSION_ENCODE__BASE) +                           \
+   (((minor) % 1000u) * CMake_VERSION_ENCODE__BASE) +                         \
+   (((patch) % CMake_VERSION_ENCODE__BASE)))
 
 #endif
-
diff --git a/Source/cmVersionMacros.h b/Source/cmVersionMacros.h
index cf7f678..a2dcce4 100644
--- a/Source/cmVersionMacros.h
+++ b/Source/cmVersionMacros.h
@@ -16,7 +16,7 @@
 
 #define CMake_VERSION_PATCH_IS_RELEASE(patch) ((patch) < 20000000)
 #if CMake_VERSION_PATCH_IS_RELEASE(CMake_VERSION_PATCH)
-# define CMake_VERSION_IS_RELEASE 1
+#define CMake_VERSION_IS_RELEASE 1
 #endif
 
 #endif
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index da950be..3b1cddb 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -9,127 +9,128 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include "windows.h"
 #include "cmVisualStudio10TargetGenerator.h"
-#include "cmGlobalVisualStudio10Generator.h"
-#include "cmGeneratorTarget.h"
+
 #include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalVisualStudio10Generator.h"
+#include "cmLocalVisualStudio7Generator.h"
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
-#include "cmVisualStudioGeneratorOptions.h"
-#include "cmLocalVisualStudio7Generator.h"
-#include "cmCustomCommandGenerator.h"
 #include "cmVS10CLFlagTable.h"
-#include "cmVS10RCFlagTable.h"
-#include "cmVS10LinkFlagTable.h"
 #include "cmVS10LibFlagTable.h"
+#include "cmVS10LinkFlagTable.h"
 #include "cmVS10MASMFlagTable.h"
+#include "cmVS10RCFlagTable.h"
 #include "cmVS11CLFlagTable.h"
-#include "cmVS11RCFlagTable.h"
-#include "cmVS11LinkFlagTable.h"
 #include "cmVS11LibFlagTable.h"
+#include "cmVS11LinkFlagTable.h"
 #include "cmVS11MASMFlagTable.h"
+#include "cmVS11RCFlagTable.h"
 #include "cmVS12CLFlagTable.h"
-#include "cmVS12RCFlagTable.h"
-#include "cmVS12LinkFlagTable.h"
 #include "cmVS12LibFlagTable.h"
+#include "cmVS12LinkFlagTable.h"
 #include "cmVS12MASMFlagTable.h"
+#include "cmVS12RCFlagTable.h"
 #include "cmVS14CLFlagTable.h"
-#include "cmVS14RCFlagTable.h"
-#include "cmVS14LinkFlagTable.h"
 #include "cmVS14LibFlagTable.h"
+#include "cmVS14LinkFlagTable.h"
 #include "cmVS14MASMFlagTable.h"
+#include "cmVS14RCFlagTable.h"
+#include "cmVisualStudioGeneratorOptions.h"
+#include "windows.h"
 
 #include <cmsys/auto_ptr.hxx>
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
 {
-  if(this->MSTools)
-    {
-    cmGlobalVisualStudioGenerator::VSVersion
-      v = this->LocalGenerator->GetVersion();
-    if(v >= cmGlobalVisualStudioGenerator::VS14)
-      { return cmVS14CLFlagTable; }
-    else if(v >= cmGlobalVisualStudioGenerator::VS12)
-      { return cmVS12CLFlagTable; }
-    else if(v == cmGlobalVisualStudioGenerator::VS11)
-      { return cmVS11CLFlagTable; }
-    else
-      { return cmVS10CLFlagTable; }
+  if (this->MSTools) {
+    cmGlobalVisualStudioGenerator::VSVersion v =
+      this->LocalGenerator->GetVersion();
+    if (v >= cmGlobalVisualStudioGenerator::VS14) {
+      return cmVS14CLFlagTable;
+    } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
+      return cmVS12CLFlagTable;
+    } else if (v == cmGlobalVisualStudioGenerator::VS11) {
+      return cmVS11CLFlagTable;
+    } else {
+      return cmVS10CLFlagTable;
     }
+  }
   return 0;
 }
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const
 {
-  if(this->MSTools)
-    {
-    cmGlobalVisualStudioGenerator::VSVersion
-      v = this->LocalGenerator->GetVersion();
-    if(v >= cmGlobalVisualStudioGenerator::VS14)
-      { return cmVS14RCFlagTable; }
-    else if(v >= cmGlobalVisualStudioGenerator::VS12)
-      { return cmVS12RCFlagTable; }
-    else if(v == cmGlobalVisualStudioGenerator::VS11)
-      { return cmVS11RCFlagTable; }
-    else
-      { return cmVS10RCFlagTable; }
+  if (this->MSTools) {
+    cmGlobalVisualStudioGenerator::VSVersion v =
+      this->LocalGenerator->GetVersion();
+    if (v >= cmGlobalVisualStudioGenerator::VS14) {
+      return cmVS14RCFlagTable;
+    } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
+      return cmVS12RCFlagTable;
+    } else if (v == cmGlobalVisualStudioGenerator::VS11) {
+      return cmVS11RCFlagTable;
+    } else {
+      return cmVS10RCFlagTable;
     }
+  }
   return 0;
 }
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
 {
-  if(this->MSTools)
-    {
-    cmGlobalVisualStudioGenerator::VSVersion
-      v = this->LocalGenerator->GetVersion();
-    if(v >= cmGlobalVisualStudioGenerator::VS14)
-      { return cmVS14LibFlagTable; }
-    else if(v >= cmGlobalVisualStudioGenerator::VS12)
-      { return cmVS12LibFlagTable; }
-    else if(v == cmGlobalVisualStudioGenerator::VS11)
-      { return cmVS11LibFlagTable; }
-    else
-      { return cmVS10LibFlagTable; }
+  if (this->MSTools) {
+    cmGlobalVisualStudioGenerator::VSVersion v =
+      this->LocalGenerator->GetVersion();
+    if (v >= cmGlobalVisualStudioGenerator::VS14) {
+      return cmVS14LibFlagTable;
+    } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
+      return cmVS12LibFlagTable;
+    } else if (v == cmGlobalVisualStudioGenerator::VS11) {
+      return cmVS11LibFlagTable;
+    } else {
+      return cmVS10LibFlagTable;
     }
+  }
   return 0;
 }
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
 {
-  if(this->MSTools)
-    {
-    cmGlobalVisualStudioGenerator::VSVersion
-      v = this->LocalGenerator->GetVersion();
-    if(v >= cmGlobalVisualStudioGenerator::VS14)
-      { return cmVS14LinkFlagTable; }
-    else if(v >= cmGlobalVisualStudioGenerator::VS12)
-      { return cmVS12LinkFlagTable; }
-    else if(v == cmGlobalVisualStudioGenerator::VS11)
-      { return cmVS11LinkFlagTable; }
-    else
-      { return cmVS10LinkFlagTable; }
+  if (this->MSTools) {
+    cmGlobalVisualStudioGenerator::VSVersion v =
+      this->LocalGenerator->GetVersion();
+    if (v >= cmGlobalVisualStudioGenerator::VS14) {
+      return cmVS14LinkFlagTable;
+    } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
+      return cmVS12LinkFlagTable;
+    } else if (v == cmGlobalVisualStudioGenerator::VS11) {
+      return cmVS11LinkFlagTable;
+    } else {
+      return cmVS10LinkFlagTable;
     }
+  }
   return 0;
 }
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const
 {
-  if(this->MSTools)
-    {
-    cmGlobalVisualStudioGenerator::VSVersion
-      v = this->LocalGenerator->GetVersion();
-    if(v >= cmGlobalVisualStudioGenerator::VS14)
-      { return cmVS14MASMFlagTable; }
-    else if(v >= cmGlobalVisualStudioGenerator::VS12)
-      { return cmVS12MASMFlagTable; }
-    else if(v == cmGlobalVisualStudioGenerator::VS11)
-      { return cmVS11MASMFlagTable; }
-    else
-      { return cmVS10MASMFlagTable; }
+  if (this->MSTools) {
+    cmGlobalVisualStudioGenerator::VSVersion v =
+      this->LocalGenerator->GetVersion();
+    if (v >= cmGlobalVisualStudioGenerator::VS14) {
+      return cmVS14MASMFlagTable;
+    } else if (v >= cmGlobalVisualStudioGenerator::VS12) {
+      return cmVS12MASMFlagTable;
+    } else if (v == cmGlobalVisualStudioGenerator::VS11) {
+      return cmVS11MASMFlagTable;
+    } else {
+      return cmVS10MASMFlagTable;
     }
+  }
   return 0;
 }
 
@@ -147,47 +148,48 @@ static std::string cmVS10EscapeComment(std::string comment)
   // does "echo $CDATA" with no escapes.  We must encode the string.
   // http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx
   std::string echoable;
-  for(std::string::iterator c = comment.begin(); c != comment.end(); ++c)
-    {
-    switch (*c)
-      {
-      case '\r': break;
-      case '\n': echoable += '\t'; break;
+  for (std::string::iterator c = comment.begin(); c != comment.end(); ++c) {
+    switch (*c) {
+      case '\r':
+        break;
+      case '\n':
+        echoable += '\t';
+        break;
       case '"': /* no break */
       case '|': /* no break */
       case '&': /* no break */
       case '<': /* no break */
       case '>': /* no break */
-      case '^': echoable += '^'; /* no break */
-      default:  echoable += *c; break;
-      }
+      case '^':
+        echoable += '^'; /* no break */
+      default:
+        echoable += *c;
+        break;
     }
+  }
   return echoable;
 }
 
-cmVisualStudio10TargetGenerator::
-cmVisualStudio10TargetGenerator(cmGeneratorTarget* target,
-                                cmGlobalVisualStudio10Generator* gg)
+cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
+  cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg)
 {
   this->GlobalGenerator = gg;
   this->GeneratorTarget = target;
   this->Makefile = target->Target->GetMakefile();
   this->Makefile->GetConfigurations(this->Configurations);
   this->LocalGenerator =
-    (cmLocalVisualStudio7Generator*)
-    this->GeneratorTarget->GetLocalGenerator();
+    (cmLocalVisualStudio7Generator*)this->GeneratorTarget->GetLocalGenerator();
   this->Name = this->GeneratorTarget->GetName();
   this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
   this->Platform = gg->GetPlatformName();
   this->NsightTegra = gg->IsNsightTegra();
-  for(int i =
-        sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
-               &this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
-               &this->NsightTegraVersion[2], &this->NsightTegraVersion[3]);
-      i < 4; ++i)
-    {
+  for (int i =
+         sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
+                &this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
+                &this->NsightTegraVersion[2], &this->NsightTegraVersion[3]);
+       i < 4; ++i) {
     this->NsightTegraVersion[i] = 0;
-    }
+  }
   this->MSTools = !this->NsightTegra;
   this->TargetCompileAsWinRT = false;
   this->BuildFileStream = 0;
@@ -199,67 +201,54 @@ cmVisualStudio10TargetGenerator(cmGeneratorTarget* target,
 
 cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
 {
-  for(OptionsMap::iterator i = this->ClOptions.begin();
-      i != this->ClOptions.end(); ++i)
-    {
+  for (OptionsMap::iterator i = this->ClOptions.begin();
+       i != this->ClOptions.end(); ++i) {
     delete i->second;
-    }
-  for(OptionsMap::iterator i = this->LinkOptions.begin();
-      i != this->LinkOptions.end(); ++i)
-    {
+  }
+  for (OptionsMap::iterator i = this->LinkOptions.begin();
+       i != this->LinkOptions.end(); ++i) {
     delete i->second;
-    }
-  if(!this->BuildFileStream)
-    {
+  }
+  if (!this->BuildFileStream) {
     return;
-    }
-  if (this->BuildFileStream->Close())
-    {
-    this->GlobalGenerator
-      ->FileReplacedDuringGenerate(this->PathToVcxproj);
-    }
+  }
+  if (this->BuildFileStream->Close()) {
+    this->GlobalGenerator->FileReplacedDuringGenerate(this->PathToVcxproj);
+  }
   delete this->BuildFileStream;
 }
 
 void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
-  const char* tag,
-  const std::string& config,
-  int indentLevel,
-  const char* attribute,
-  const char* end,
-  std::ostream* stream)
+  const char* tag, const std::string& config, int indentLevel,
+  const char* attribute, const char* end, std::ostream* stream)
 
 {
-  if(!stream)
-    {
+  if (!stream) {
     stream = this->BuildFileStream;
-    }
+  }
   stream->fill(' ');
-  stream->width(indentLevel*2 );
-  (*stream ) << "";
-  (*stream ) << "<" << tag
-             << " Condition=\"'$(Configuration)|$(Platform)'=='";
-  (*stream ) << config << "|" << this->Platform << "'\"";
-  if(attribute)
-    {
-    (*stream ) << attribute;
-    }
+  stream->width(indentLevel * 2);
+  (*stream) << "";
+  (*stream) << "<" << tag << " Condition=\"'$(Configuration)|$(Platform)'=='";
+  (*stream) << config << "|" << this->Platform << "'\"";
+  if (attribute) {
+    (*stream) << attribute;
+  }
   // close the tag
-  (*stream ) << ">";
-  if(end)
-    {
-    (*stream ) << end;
-    }
+  (*stream) << ">";
+  if (end) {
+    (*stream) << end;
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteString(const char* line,
                                                   int indentLevel)
 {
   this->BuildFileStream->fill(' ');
-  this->BuildFileStream->width(indentLevel*2 );
+  this->BuildFileStream->width(indentLevel * 2);
   // write an empty string to get the fill level indent to print
-  (*this->BuildFileStream ) << "";
-  (*this->BuildFileStream ) << line;
+  (*this->BuildFileStream) << "";
+  (*this->BuildFileStream) << line;
 }
 
 #define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
@@ -267,212 +256,183 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
 void cmVisualStudio10TargetGenerator::Generate()
 {
   // do not generate external ms projects
-  if(this->GeneratorTarget->GetType() == cmState::INTERFACE_LIBRARY
-      || this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT"))
-    {
+  if (this->GeneratorTarget->GetType() == cmState::INTERFACE_LIBRARY ||
+      this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) {
     return;
-    }
+  }
   // Tell the global generator the name of the project file
-  this->GeneratorTarget->Target
-      ->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
+  this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
+                                             this->Name.c_str());
   this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
-                            ".vcxproj");
-  if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
-    {
-    if(!this->ComputeClOptions())
-      {
+                                             ".vcxproj");
+  if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
+    if (!this->ComputeClOptions()) {
       return;
-      }
-    if(!this->ComputeRcOptions())
-      {
+    }
+    if (!this->ComputeRcOptions()) {
       return;
-      }
-    if(!this->ComputeMasmOptions())
-      {
+    }
+    if (!this->ComputeMasmOptions()) {
       return;
-      }
-    if(!this->ComputeLinkOptions())
-      {
+    }
+    if (!this->ComputeLinkOptions()) {
       return;
-      }
     }
-  std::string path =  this->LocalGenerator->GetCurrentBinaryDirectory();
+  }
+  std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
   path += "/";
   path += this->Name;
   path += ".vcxproj";
-  this->BuildFileStream =
-    new cmGeneratedFileStream(path.c_str());
+  this->BuildFileStream = new cmGeneratedFileStream(path.c_str());
   this->PathToVcxproj = path;
   this->BuildFileStream->SetCopyIfDifferent(true);
 
   // Write the encoding header into the file
-  char magic[] = {char(0xEF), char(0xBB), char(0xBF)};
+  char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
   this->BuildFileStream->write(magic, 3);
 
-  //get the tools version to use
+  // get the tools version to use
   const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
-  std::string project_defaults=
-    "<?xml version=\"1.0\" encoding=\"" +
+  std::string project_defaults = "<?xml version=\"1.0\" encoding=\"" +
     this->GlobalGenerator->Encoding() + "\"?>\n";
   project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
-  project_defaults.append(toolsVer +"\" ");
+  project_defaults.append(toolsVer + "\" ");
   project_defaults.append(
-          "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
-  this->WriteString(project_defaults.c_str(),0);
+    "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
+  this->WriteString(project_defaults.c_str(), 0);
 
-  if(this->NsightTegra)
-    {
+  if (this->NsightTegra) {
     this->WriteString("<PropertyGroup Label=\"NsightTegraProject\">\n", 1);
     const int nsightTegraMajorVersion = this->NsightTegraVersion[0];
     const int nsightTegraMinorVersion = this->NsightTegraVersion[1];
-    if (nsightTegraMajorVersion >= 2)
-      {
+    if (nsightTegraMajorVersion >= 2) {
       this->WriteString("<NsightTegraProjectRevisionNumber>", 2);
       if (nsightTegraMajorVersion > 3 ||
-          (nsightTegraMajorVersion == 3 && nsightTegraMinorVersion >= 1))
-        {
+          (nsightTegraMajorVersion == 3 && nsightTegraMinorVersion >= 1)) {
         (*this->BuildFileStream) << "11";
-        }
-      else
-        {
+      } else {
         // Nsight Tegra 2.0 uses project revision 9.
         (*this->BuildFileStream) << "9";
-        }
+      }
       (*this->BuildFileStream) << "</NsightTegraProjectRevisionNumber>\n";
       // Tell newer versions to upgrade silently when loading.
       this->WriteString("<NsightTegraUpgradeOnceWithoutPrompt>"
                         "true"
-                        "</NsightTegraUpgradeOnceWithoutPrompt>\n", 2);
-      }
-    else
-      {
+                        "</NsightTegraUpgradeOnceWithoutPrompt>\n",
+                        2);
+    } else {
       // Require Nsight Tegra 1.6 for JCompile support.
       this->WriteString("<NsightTegraProjectRevisionNumber>"
                         "7"
-                        "</NsightTegraProjectRevisionNumber>\n", 2);
-      }
-    this->WriteString("</PropertyGroup>\n", 1);
+                        "</NsightTegraProjectRevisionNumber>\n",
+                        2);
     }
+    this->WriteString("</PropertyGroup>\n", 1);
+  }
 
   this->WriteProjectConfigurations();
   this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
   this->WriteString("<ProjectGUID>", 2);
-  (*this->BuildFileStream) <<  "{" << this->GUID << "}</ProjectGUID>\n";
+  (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n";
 
-  if(this->MSTools
-     && this->GeneratorTarget->GetType() <= cmState::GLOBAL_TARGET)
-    {
+  if (this->MSTools &&
+      this->GeneratorTarget->GetType() <= cmState::GLOBAL_TARGET) {
     this->WriteApplicationTypeSettings();
     this->VerifyNecessaryFiles();
-    }
+  }
 
   const char* vsProjectTypes =
     this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES");
-  if(vsProjectTypes)
-    {
+  if (vsProjectTypes) {
     this->WriteString("<ProjectTypes>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) <<
-      "</ProjectTypes>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes)
+                             << "</ProjectTypes>\n";
+  }
 
   const char* vsProjectName =
-      this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME");
+    this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME");
   const char* vsLocalPath =
-      this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH");
+    this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH");
   const char* vsProvider =
-      this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER");
+    this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER");
 
-  if( vsProjectName && vsLocalPath && vsProvider )
-    {
+  if (vsProjectName && vsLocalPath && vsProvider) {
     this->WriteString("<SccProjectName>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) <<
-      "</SccProjectName>\n";
+    (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName)
+                             << "</SccProjectName>\n";
     this->WriteString("<SccLocalPath>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath) <<
-      "</SccLocalPath>\n";
+    (*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath)
+                             << "</SccLocalPath>\n";
     this->WriteString("<SccProvider>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) <<
-      "</SccProvider>\n";
+    (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider)
+                             << "</SccProvider>\n";
 
     const char* vsAuxPath =
-        this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH");
-    if( vsAuxPath )
-      {
+      this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH");
+    if (vsAuxPath) {
       this->WriteString("<SccAuxPath>", 2);
-       (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath) <<
-         "</SccAuxPath>\n";
-      }
+      (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath)
+                               << "</SccAuxPath>\n";
     }
+  }
 
-  if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT"))
-    {
+  if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
     this->WriteString("<WinMDAssembly>true</WinMDAssembly>\n", 2);
-    }
+  }
 
   const char* vsGlobalKeyword =
     this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD");
-  if(!vsGlobalKeyword)
-    {
+  if (!vsGlobalKeyword) {
     this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
-    }
-  else
-    {
+  } else {
     this->WriteString("<Keyword>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) <<
-      "</Keyword>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword)
+                             << "</Keyword>\n";
+  }
 
   const char* vsGlobalRootNamespace =
     this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
-  if(vsGlobalRootNamespace)
-    {
+  if (vsGlobalRootNamespace) {
     this->WriteString("<RootNamespace>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace) <<
-      "</RootNamespace>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace)
+                             << "</RootNamespace>\n";
+  }
 
   this->WriteString("<Platform>", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
                            << "</Platform>\n";
   const char* projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL");
-  if(!projLabel)
-    {
+  if (!projLabel) {
     projLabel = this->Name.c_str();
-    }
+  }
   this->WriteString("<ProjectName>", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n";
-  if(const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty(
-       "VS_DOTNET_TARGET_FRAMEWORK_VERSION"))
-    {
+  if (const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty(
+        "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
     this->WriteString("<TargetFrameworkVersion>", 2);
     (*this->BuildFileStream) << cmVS10EscapeXML(targetFrameworkVersion)
                              << "</TargetFrameworkVersion>\n";
-    }
+  }
 
   std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys();
-  for(std::vector<std::string>::const_iterator keyIt = keys.begin();
-      keyIt != keys.end(); ++keyIt)
-    {
+  for (std::vector<std::string>::const_iterator keyIt = keys.begin();
+       keyIt != keys.end(); ++keyIt) {
     static const char* prefix = "VS_GLOBAL_";
-    if(keyIt->find(prefix) != 0)
+    if (keyIt->find(prefix) != 0)
       continue;
     std::string globalKey = keyIt->substr(strlen(prefix));
     // Skip invalid or separately-handled properties.
-    if(globalKey == "" ||
-       globalKey == "PROJECT_TYPES" ||
-       globalKey == "ROOTNAMESPACE" ||
-       globalKey == "KEYWORD")
-      {
+    if (globalKey == "" || globalKey == "PROJECT_TYPES" ||
+        globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
       continue;
-      }
+    }
     const char* value = this->GeneratorTarget->GetProperty(keyIt->c_str());
     if (!value)
       continue;
     this->WriteString("<", 2);
-    (*this->BuildFileStream) << globalKey << ">"
-                             << cmVS10EscapeXML(value)
+    (*this->BuildFileStream) << globalKey << ">" << cmVS10EscapeXML(value)
                              << "</" << globalKey << ">\n";
-    }
+  }
 
   this->WriteString("</PropertyGroup>\n", 1);
   this->WriteString("<Import Project="
@@ -482,16 +442,17 @@ void cmVisualStudio10TargetGenerator::Generate()
   this->WriteString(
     "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
   this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
-  if (this->GlobalGenerator->IsMasmEnabled())
-    {
+  if (this->GlobalGenerator->IsMasmEnabled()) {
     this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
-                      "BuildCustomizations\\masm.props\" />\n", 2);
-    }
+                      "BuildCustomizations\\masm.props\" />\n",
+                      2);
+  }
   this->WriteString("</ImportGroup>\n", 1);
   this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
   this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
                     " Condition=\"exists('" VS10_USER_PROPS "')\""
-                    " Label=\"LocalAppDataPlatform\" />\n", 2);
+                    " Label=\"LocalAppDataPlatform\" />\n",
+                    2);
   this->WritePlatformExtensions();
   this->WriteString("</ImportGroup>\n", 1);
   this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
@@ -508,14 +469,15 @@ void cmVisualStudio10TargetGenerator::Generate()
   this->WriteSDKReferences();
   this->WriteString(
     "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
-    " />\n", 1);
+    " />\n",
+    1);
   this->WriteTargetSpecificReferences();
   this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
-  if (this->GlobalGenerator->IsMasmEnabled())
-    {
+  if (this->GlobalGenerator->IsMasmEnabled()) {
     this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
-                      "BuildCustomizations\\masm.targets\" />\n", 2);
-    }
+                      "BuildCustomizations\\masm.targets\" />\n",
+                      2);
+  }
   this->WriteString("</ImportGroup>\n", 1);
   this->WriteString("</Project>", 0);
   // The groups are stored in a separate file for VS 10
@@ -525,144 +487,129 @@ void cmVisualStudio10TargetGenerator::Generate()
 void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
 {
   std::vector<std::string> references;
-  if(const char* vsDotNetReferences =
-     this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES"))
-    {
+  if (const char* vsDotNetReferences =
+        this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) {
     cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
-    }
-  if(!references.empty())
-    {
+  }
+  if (!references.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<std::string>::iterator ri = references.begin();
-        ri != references.end(); ++ri)
-      {
+    for (std::vector<std::string>::iterator ri = references.begin();
+         ri != references.end(); ++ri) {
       this->WriteString("<Reference Include=\"", 2);
       (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
       this->WriteString("<CopyLocalSatelliteAssemblies>true"
-                        "</CopyLocalSatelliteAssemblies>\n", 3);
+                        "</CopyLocalSatelliteAssemblies>\n",
+                        3);
       this->WriteString("<ReferenceOutputAssembly>true"
-                        "</ReferenceOutputAssembly>\n", 3);
+                        "</ReferenceOutputAssembly>\n",
+                        3);
       this->WriteString("</Reference>\n", 2);
-      }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
 {
   std::vector<cmSourceFile const*> resxObjs;
-    this->GeneratorTarget->GetResxSources(resxObjs, "");
-  if(!resxObjs.empty())
-    {
+  this->GeneratorTarget->GetResxSources(resxObjs, "");
+  if (!resxObjs.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
-        oi != resxObjs.end(); ++oi)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator oi =
+           resxObjs.begin();
+         oi != resxObjs.end(); ++oi) {
       std::string obj = (*oi)->GetFullPath();
       this->WriteString("<EmbeddedResource Include=\"", 2);
       this->ConvertToWindowsSlash(obj);
-      (*this->BuildFileStream ) << obj << "\">\n";
+      (*this->BuildFileStream) << obj << "\">\n";
 
       this->WriteString("<DependentUpon>", 3);
       std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
       (*this->BuildFileStream) << hFileName << "</DependentUpon>\n";
 
-      for(std::vector<std::string>::const_iterator
-            i = this->Configurations.begin();
-          i != this->Configurations.end(); ++i)
-        {
+      for (std::vector<std::string>::const_iterator i =
+             this->Configurations.begin();
+           i != this->Configurations.end(); ++i) {
         this->WritePlatformConfigTag("LogicalName", i->c_str(), 3);
-        if(this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE"))
-          {
-          (*this->BuildFileStream ) << "$(RootNamespace).";
-          }
-        (*this->BuildFileStream ) << "%(Filename)";
-        (*this->BuildFileStream ) << ".resources";
-        (*this->BuildFileStream ) << "</LogicalName>\n";
+        if (this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE")) {
+          (*this->BuildFileStream) << "$(RootNamespace).";
         }
+        (*this->BuildFileStream) << "%(Filename)";
+        (*this->BuildFileStream) << ".resources";
+        (*this->BuildFileStream) << "</LogicalName>\n";
+      }
 
       this->WriteString("</EmbeddedResource>\n", 2);
-      }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup()
 {
   std::vector<cmSourceFile const*> xamlObjs;
   this->GeneratorTarget->GetXamlSources(xamlObjs, "");
-  if (!xamlObjs.empty())
-    {
+  if (!xamlObjs.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for (std::vector<cmSourceFile const*>::const_iterator
-           oi = xamlObjs.begin(); oi != xamlObjs.end(); ++oi)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator oi =
+           xamlObjs.begin();
+         oi != xamlObjs.end(); ++oi) {
       std::string obj = (*oi)->GetFullPath();
       std::string xamlType;
-      const char * xamlTypeProperty = (*oi)->GetProperty("VS_XAML_TYPE");
-      if (xamlTypeProperty)
-        {
+      const char* xamlTypeProperty = (*oi)->GetProperty("VS_XAML_TYPE");
+      if (xamlTypeProperty) {
         xamlType = xamlTypeProperty;
-        }
-      else
-        {
+      } else {
         xamlType = "Page";
-        }
+      }
 
       this->WriteSource(xamlType, *oi, ">\n");
       this->WriteString("<SubType>Designer</SubType>\n", 3);
       this->WriteString("</", 2);
       (*this->BuildFileStream) << xamlType << ">\n";
-
-      }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences()
 {
-  if(this->MSTools)
-    {
-    if(this->GlobalGenerator->TargetsWindowsPhone() &&
-       this->GlobalGenerator->GetSystemVersion() == "8.0")
-      {
-      this->WriteString(
-        "<Import Project=\""
-        "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v"
-        "$(TargetPlatformVersion)\\Microsoft.Cpp.WindowsPhone."
-        "$(TargetPlatformVersion).targets\" />\n", 1);
-      }
+  if (this->MSTools) {
+    if (this->GlobalGenerator->TargetsWindowsPhone() &&
+        this->GlobalGenerator->GetSystemVersion() == "8.0") {
+      this->WriteString("<Import Project=\""
+                        "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v"
+                        "$(TargetPlatformVersion)\\Microsoft.Cpp.WindowsPhone."
+                        "$(TargetPlatformVersion).targets\" />\n",
+                        1);
     }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
 {
   std::vector<std::string> references;
-  if(const char* vsWinRTReferences =
-     this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES"))
-    {
+  if (const char* vsWinRTReferences =
+        this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) {
     cmSystemTools::ExpandListArgument(vsWinRTReferences, references);
-    }
+  }
 
-  if(this->GlobalGenerator->TargetsWindowsPhone() &&
-     this->GlobalGenerator->GetSystemVersion() == "8.0" &&
-     references.empty())
-    {
+  if (this->GlobalGenerator->TargetsWindowsPhone() &&
+      this->GlobalGenerator->GetSystemVersion() == "8.0" &&
+      references.empty()) {
     references.push_back("platform.winmd");
-    }
-  if(!references.empty())
-    {
+  }
+  if (!references.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<std::string>::iterator ri = references.begin();
-        ri != references.end(); ++ri)
-      {
+    for (std::vector<std::string>::iterator ri = references.begin();
+         ri != references.end(); ++ri) {
       this->WriteString("<Reference Include=\"", 2);
       (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
       this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
       this->WriteString("</Reference>\n", 2);
-      }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 }
 
 // ConfigurationType Application, Utility StaticLibrary DynamicLibrary
@@ -670,185 +617,161 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
 void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
 {
   this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
     this->WriteString("<ProjectConfiguration Include=\"", 2);
-    (*this->BuildFileStream ) <<  *i << "|" << this->Platform << "\">\n";
+    (*this->BuildFileStream) << *i << "|" << this->Platform << "\">\n";
     this->WriteString("<Configuration>", 3);
-    (*this->BuildFileStream ) <<  *i << "</Configuration>\n";
+    (*this->BuildFileStream) << *i << "</Configuration>\n";
     this->WriteString("<Platform>", 3);
     (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
                              << "</Platform>\n";
     this->WriteString("</ProjectConfiguration>\n", 2);
-    }
+  }
   this->WriteString("</ItemGroup>\n", 1);
 }
 
 void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
 {
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
-    this->WritePlatformConfigTag("PropertyGroup",
-                                 i->c_str(),
-                                 1, " Label=\"Configuration\"", "\n");
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
+    this->WritePlatformConfigTag("PropertyGroup", i->c_str(), 1,
+                                 " Label=\"Configuration\"", "\n");
     std::string configType = "<ConfigurationType>";
-    switch(this->GeneratorTarget->GetType())
-      {
-      case cmState::SHARED_LIBRARY:
-      case cmState::MODULE_LIBRARY:
-        configType += "DynamicLibrary";
-        break;
-      case cmState::OBJECT_LIBRARY:
-      case cmState::STATIC_LIBRARY:
-        configType += "StaticLibrary";
-        break;
-      case cmState::EXECUTABLE:
-        if(this->NsightTegra &&
-           !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI"))
-          {
-          // Android executables are .so too.
+    if (const char* vsConfigurationType =
+          this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) {
+      configType += cmVS10EscapeXML(vsConfigurationType);
+    } else {
+      switch (this->GeneratorTarget->GetType()) {
+        case cmState::SHARED_LIBRARY:
+        case cmState::MODULE_LIBRARY:
           configType += "DynamicLibrary";
-          }
-        else
-          {
-          configType += "Application";
-          }
-        break;
-      case cmState::UTILITY:
-      case cmState::GLOBAL_TARGET:
-        if(this->NsightTegra)
-          {
-          // Tegra-Android platform does not understand "Utility".
+          break;
+        case cmState::OBJECT_LIBRARY:
+        case cmState::STATIC_LIBRARY:
           configType += "StaticLibrary";
+          break;
+        case cmState::EXECUTABLE:
+          if (this->NsightTegra &&
+              !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
+            // Android executables are .so too.
+            configType += "DynamicLibrary";
+          } else {
+            configType += "Application";
           }
-        else
-          {
-          configType += "Utility";
+          break;
+        case cmState::UTILITY:
+        case cmState::GLOBAL_TARGET:
+          if (this->NsightTegra) {
+            // Tegra-Android platform does not understand "Utility".
+            configType += "StaticLibrary";
+          } else {
+            configType += "Utility";
           }
-        break;
-      case cmState::UNKNOWN_LIBRARY:
-      case cmState::INTERFACE_LIBRARY:
-        break;
+          break;
+        case cmState::UNKNOWN_LIBRARY:
+        case cmState::INTERFACE_LIBRARY:
+          break;
       }
+    }
     configType += "</ConfigurationType>\n";
     this->WriteString(configType.c_str(), 2);
 
-    if(this->MSTools)
-      {
+    if (this->MSTools) {
       this->WriteMSToolConfigurationValues(*i);
-      }
-    else if(this->NsightTegra)
-      {
+    } else if (this->NsightTegra) {
       this->WriteNsightTegraConfigurationValues(*i);
-      }
+    }
 
     this->WriteString("</PropertyGroup>\n", 1);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmVisualStudio10TargetGenerator
-::WriteMSToolConfigurationValues(std::string const& config)
+void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
+  std::string const& config)
 {
   cmGlobalVisualStudio10Generator* gg =
     static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
   const char* mfcFlag =
-    this->GeneratorTarget->
-      Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG");
+    this->GeneratorTarget->Target->GetMakefile()->GetDefinition(
+      "CMAKE_MFC_FLAG");
   std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
 
   std::string useOfMfcValue = "false";
-  if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
-    {
-    if(mfcFlagValue == "1")
-      {
+  if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
+    if (mfcFlagValue == "1") {
       useOfMfcValue = "Static";
-      }
-    else if(mfcFlagValue == "2")
-      {
+    } else if (mfcFlagValue == "2") {
       useOfMfcValue = "Dynamic";
-      }
     }
+  }
   std::string mfcLine = "<UseOfMfc>";
   mfcLine += useOfMfcValue + "</UseOfMfc>\n";
   this->WriteString(mfcLine.c_str(), 2);
 
-  if((this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY &&
-      this->ClOptions[config]->UsingUnicode()) ||
-     this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
-     this->GlobalGenerator->TargetsWindowsPhone() ||
-     this->GlobalGenerator->TargetsWindowsStore() ||
-     this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
-    {
+  if ((this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY &&
+       this->ClOptions[config]->UsingUnicode()) ||
+      this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
+      this->GlobalGenerator->TargetsWindowsPhone() ||
+      this->GlobalGenerator->TargetsWindowsStore() ||
+      this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
     this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
-    }
-  else if (this->GeneratorTarget->GetType() <= cmState::MODULE_LIBRARY &&
-           this->ClOptions[config]->UsingSBCS())
-    {
+  } else if (this->GeneratorTarget->GetType() <= cmState::MODULE_LIBRARY &&
+             this->ClOptions[config]->UsingSBCS()) {
     this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
-    }
-  else
-    {
+  } else {
     this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
-    }
-  if(const char* toolset = gg->GetPlatformToolset())
-    {
+  }
+  if (const char* toolset = gg->GetPlatformToolset()) {
     std::string pts = "<PlatformToolset>";
     pts += toolset;
     pts += "</PlatformToolset>\n";
     this->WriteString(pts.c_str(), 2);
-    }
-  if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
-     this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
-    {
+  }
+  if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
+      this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
     this->WriteString("<WindowsAppContainer>true"
-                      "</WindowsAppContainer>\n", 2);
-    }
+                      "</WindowsAppContainer>\n",
+                      2);
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmVisualStudio10TargetGenerator
-::WriteNsightTegraConfigurationValues(std::string const&)
+void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
+  std::string const&)
 {
   cmGlobalVisualStudio10Generator* gg =
     static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
   const char* toolset = gg->GetPlatformToolset();
   std::string ntv = "<NdkToolchainVersion>";
-  ntv += toolset? toolset : "Default";
+  ntv += toolset ? toolset : "Default";
   ntv += "</NdkToolchainVersion>\n";
   this->WriteString(ntv.c_str(), 2);
-  if(const char* minApi =
-     this->GeneratorTarget->GetProperty("ANDROID_API_MIN"))
-    {
+  if (const char* minApi =
+        this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) {
     this->WriteString("<AndroidMinAPI>", 2);
-    (*this->BuildFileStream ) <<
-      "android-" << cmVS10EscapeXML(minApi) << "</AndroidMinAPI>\n";
-    }
-  if(const char* api = this->GeneratorTarget->GetProperty("ANDROID_API"))
-    {
+    (*this->BuildFileStream) << "android-" << cmVS10EscapeXML(minApi)
+                             << "</AndroidMinAPI>\n";
+  }
+  if (const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) {
     this->WriteString("<AndroidTargetAPI>", 2);
-    (*this->BuildFileStream ) <<
-      "android-" << cmVS10EscapeXML(api) << "</AndroidTargetAPI>\n";
-    }
+    (*this->BuildFileStream) << "android-" << cmVS10EscapeXML(api)
+                             << "</AndroidTargetAPI>\n";
+  }
 
-  if(const char* cpuArch = this->GeneratorTarget->GetProperty("ANDROID_ARCH"))
-    {
+  if (const char* cpuArch =
+        this->GeneratorTarget->GetProperty("ANDROID_ARCH")) {
     this->WriteString("<AndroidArch>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(cpuArch) <<
-      "</AndroidArch>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(cpuArch) << "</AndroidArch>\n";
+  }
 
-  if(const char* stlType =
-     this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE"))
-    {
+  if (const char* stlType =
+        this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) {
     this->WriteString("<AndroidStlType>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(stlType) <<
-      "</AndroidStlType>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(stlType)
+                             << "</AndroidStlType>\n";
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteCustomCommands()
@@ -856,137 +779,114 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands()
   this->SourcesVisited.clear();
   std::vector<cmSourceFile const*> customCommands;
   this->GeneratorTarget->GetCustomCommands(customCommands, "");
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = customCommands.begin();
-      si != customCommands.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         customCommands.begin();
+       si != customCommands.end(); ++si) {
     this->WriteCustomCommand(*si);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void cmVisualStudio10TargetGenerator
-::WriteCustomCommand(cmSourceFile const* sf)
+void cmVisualStudio10TargetGenerator::WriteCustomCommand(
+  cmSourceFile const* sf)
 {
-  if(this->SourcesVisited.insert(sf).second)
-    {
-    if(std::vector<cmSourceFile*> const* depends =
-       this->GeneratorTarget->GetSourceDepends(sf))
-      {
-      for(std::vector<cmSourceFile*>::const_iterator di = depends->begin();
-          di != depends->end(); ++di)
-        {
+  if (this->SourcesVisited.insert(sf).second) {
+    if (std::vector<cmSourceFile*> const* depends =
+          this->GeneratorTarget->GetSourceDepends(sf)) {
+      for (std::vector<cmSourceFile*>::const_iterator di = depends->begin();
+           di != depends->end(); ++di) {
         this->WriteCustomCommand(*di);
-        }
       }
-    if(cmCustomCommand const* command = sf->GetCustomCommand())
-      {
+    }
+    if (cmCustomCommand const* command = sf->GetCustomCommand()) {
       this->WriteString("<ItemGroup>\n", 1);
       this->WriteCustomRule(sf, *command);
       this->WriteString("</ItemGroup>\n", 1);
-      }
     }
+  }
 }
 
-void
-cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
-                                                 cmCustomCommand const &
-                                                 command)
+void cmVisualStudio10TargetGenerator::WriteCustomRule(
+  cmSourceFile const* source, cmCustomCommand const& command)
 {
   std::string sourcePath = source->GetFullPath();
   // VS 10 will always rebuild a custom command attached to a .rule
   // file that doesn't exist so create the file explicitly.
-  if (source->GetPropertyAsBool("__CMAKE_RULE"))
-    {
-    if(!cmSystemTools::FileExists(sourcePath.c_str()))
-      {
+  if (source->GetPropertyAsBool("__CMAKE_RULE")) {
+    if (!cmSystemTools::FileExists(sourcePath.c_str())) {
       // Make sure the path exists for the file
       std::string path = cmSystemTools::GetFilenamePath(sourcePath);
       cmSystemTools::MakeDirectory(path.c_str());
       cmsys::ofstream fout(sourcePath.c_str());
-      if(fout)
-        {
+      if (fout) {
         fout << "# generated from CMake\n";
         fout.flush();
         fout.close();
         // Force given file to have a very old timestamp, thus
         // preventing dependent rebuilds.
         this->ForceOld(sourcePath);
-        }
-      else
-        {
+      } else {
         std::string error = "Could not create file: [";
-        error +=  sourcePath;
+        error += sourcePath;
         error += "]  ";
-        cmSystemTools::Error
-          (error.c_str(), cmSystemTools::GetLastSystemError().c_str());
-        }
+        cmSystemTools::Error(error.c_str(),
+                             cmSystemTools::GetLastSystemError().c_str());
       }
     }
+  }
   cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
 
   this->WriteSource("CustomBuild", source, ">\n");
 
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
     cmCustomCommandGenerator ccg(command, *i, this->LocalGenerator);
     std::string comment = lg->ConstructComment(ccg);
     comment = cmVS10EscapeComment(comment);
-    std::string script =
-      cmVS10EscapeXML(lg->ConstructScript(ccg));
-    this->WritePlatformConfigTag("Message",i->c_str(), 3);
-    (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
+    std::string script = cmVS10EscapeXML(lg->ConstructScript(ccg));
+    this->WritePlatformConfigTag("Message", i->c_str(), 3);
+    (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
     this->WritePlatformConfigTag("Command", i->c_str(), 3);
-    (*this->BuildFileStream ) << script << "</Command>\n";
+    (*this->BuildFileStream) << script << "</Command>\n";
     this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
 
-    (*this->BuildFileStream ) << cmVS10EscapeXML(source->GetFullPath());
-    for(std::vector<std::string>::const_iterator d =
-          ccg.GetDepends().begin();
-        d != ccg.GetDepends().end();
-        ++d)
-      {
+    (*this->BuildFileStream) << cmVS10EscapeXML(source->GetFullPath());
+    for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
+         d != ccg.GetDepends().end(); ++d) {
       std::string dep;
-      if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
-        {
+      if (this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(),
+                                                  dep)) {
         this->ConvertToWindowsSlash(dep);
-        (*this->BuildFileStream ) << ";" << cmVS10EscapeXML(dep);
-        }
+        (*this->BuildFileStream) << ";" << cmVS10EscapeXML(dep);
       }
-    (*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
+    }
+    (*this->BuildFileStream) << ";%(AdditionalInputs)</AdditionalInputs>\n";
     this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
     const char* sep = "";
-    for(std::vector<std::string>::const_iterator o =
-          ccg.GetOutputs().begin();
-        o != ccg.GetOutputs().end();
-        ++o)
-      {
+    for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
+         o != ccg.GetOutputs().end(); ++o) {
       std::string out = *o;
       this->ConvertToWindowsSlash(out);
-      (*this->BuildFileStream ) << sep << cmVS10EscapeXML(out);
+      (*this->BuildFileStream) << sep << cmVS10EscapeXML(out);
       sep = ";";
-      }
-    (*this->BuildFileStream ) << "</Outputs>\n";
-    if(this->LocalGenerator->GetVersion()
-                                        > cmGlobalVisualStudioGenerator::VS10)
-      {
+    }
+    (*this->BuildFileStream) << "</Outputs>\n";
+    if (this->LocalGenerator->GetVersion() >
+        cmGlobalVisualStudioGenerator::VS10) {
       // VS >= 11 let us turn off linking of custom command outputs.
       this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3);
-      (*this->BuildFileStream ) << "false</LinkObjects>\n";
-      }
+      (*this->BuildFileStream) << "false</LinkObjects>\n";
     }
+  }
   this->WriteString("</CustomBuild>\n", 2);
 }
 
-std::string
-cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path,
-                                             bool forceRelative)
+std::string cmVisualStudio10TargetGenerator::ConvertPath(
+  std::string const& path, bool forceRelative)
 {
   return forceRelative
     ? cmSystemTools::RelativePath(
-      this->LocalGenerator->GetCurrentBinaryDirectory(), path.c_str())
+        this->LocalGenerator->GetCurrentBinaryDirectory(), path.c_str())
     : path.c_str();
 }
 
@@ -994,186 +894,159 @@ void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
 {
   // first convert all of the slashes
   std::string::size_type pos = 0;
-  while((pos = s.find('/', pos)) != std::string::npos)
-    {
+  while ((pos = s.find('/', pos)) != std::string::npos) {
     s[pos] = '\\';
     pos++;
-    }
+  }
 }
 void cmVisualStudio10TargetGenerator::WriteGroups()
 {
   // collect up group information
-  std::vector<cmSourceGroup> sourceGroups =
-    this->Makefile->GetSourceGroups();
+  std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
   std::vector<cmSourceFile*> classes;
-  if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes))
-    {
+  if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes)) {
     return;
-    }
+  }
 
   std::set<cmSourceGroup*> groupsUsed;
-  for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
-      s != classes.end(); s++)
-    {
+  for (std::vector<cmSourceFile*>::const_iterator s = classes.begin();
+       s != classes.end(); s++) {
     cmSourceFile* sf = *s;
     std::string const& source = sf->GetFullPath();
     cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
     groupsUsed.insert(sourceGroup);
-    }
+  }
 
   this->AddMissingSourceGroups(groupsUsed, sourceGroups);
 
   // Write out group file
-  std::string path =  this->LocalGenerator->GetCurrentBinaryDirectory();
+  std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
   path += "/";
   path += this->Name;
   path += ".vcxproj.filters";
   cmGeneratedFileStream fout(path.c_str());
   fout.SetCopyIfDifferent(true);
-  char magic[] = {char(0xEF), char(0xBB), char(0xBF)};
+  char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
   fout.write(magic, 3);
   cmGeneratedFileStream* save = this->BuildFileStream;
-  this->BuildFileStream = & fout;
+  this->BuildFileStream = &fout;
 
-  //get the tools version to use
+  // get the tools version to use
   const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
-  std::string project_defaults=
-    "<?xml version=\"1.0\" encoding=\"" +
+  std::string project_defaults = "<?xml version=\"1.0\" encoding=\"" +
     this->GlobalGenerator->Encoding() + "\"?>\n";
   project_defaults.append("<Project ToolsVersion=\"");
-  project_defaults.append(toolsVer +"\" ");
+  project_defaults.append(toolsVer + "\" ");
   project_defaults.append(
-        "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
-  this->WriteString(project_defaults.c_str(),0);
+    "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
+  this->WriteString(project_defaults.c_str(), 0);
 
-  for(ToolSourceMap::const_iterator ti = this->Tools.begin();
-      ti != this->Tools.end(); ++ti)
-    {
+  for (ToolSourceMap::const_iterator ti = this->Tools.begin();
+       ti != this->Tools.end(); ++ti) {
     this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
-    }
+  }
 
   // Added files are images and the manifest.
-  if (!this->AddedFiles.empty())
-    {
+  if (!this->AddedFiles.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<std::string>::const_iterator
-          oi = this->AddedFiles.begin(); oi != this->AddedFiles.end(); ++oi)
-      {
-      std::string fileName = cmSystemTools::LowerCase(
-        cmSystemTools::GetFilenameName(*oi));
-      if (fileName == "wmappmanifest.xml")
-        {
+    for (std::vector<std::string>::const_iterator oi =
+           this->AddedFiles.begin();
+         oi != this->AddedFiles.end(); ++oi) {
+      std::string fileName =
+        cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(*oi));
+      if (fileName == "wmappmanifest.xml") {
         this->WriteString("<XML Include=\"", 2);
         (*this->BuildFileStream) << *oi << "\">\n";
         this->WriteString("<Filter>Resource Files</Filter>\n", 3);
         this->WriteString("</XML>\n", 2);
-        }
-      else if(cmSystemTools::GetFilenameExtension(fileName) ==
-              ".appxmanifest")
-        {
+      } else if (cmSystemTools::GetFilenameExtension(fileName) ==
+                 ".appxmanifest") {
         this->WriteString("<AppxManifest Include=\"", 2);
         (*this->BuildFileStream) << *oi << "\">\n";
         this->WriteString("<Filter>Resource Files</Filter>\n", 3);
         this->WriteString("</AppxManifest>\n", 2);
-        }
-      else if(cmSystemTools::GetFilenameExtension(fileName) ==
-              ".pfx")
-        {
+      } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") {
         this->WriteString("<None Include=\"", 2);
         (*this->BuildFileStream) << *oi << "\">\n";
         this->WriteString("<Filter>Resource Files</Filter>\n", 3);
         this->WriteString("</None>\n", 2);
-        }
-      else
-        {
+      } else {
         this->WriteString("<Image Include=\"", 2);
         (*this->BuildFileStream) << *oi << "\">\n";
         this->WriteString("<Filter>Resource Files</Filter>\n", 3);
         this->WriteString("</Image>\n", 2);
-        }
       }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 
   std::vector<cmSourceFile const*> resxObjs;
-    this->GeneratorTarget->GetResxSources(resxObjs, "");
-  if(!resxObjs.empty())
-    {
+  this->GeneratorTarget->GetResxSources(resxObjs, "");
+  if (!resxObjs.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
-        oi != resxObjs.end(); ++oi)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator oi =
+           resxObjs.begin();
+         oi != resxObjs.end(); ++oi) {
       std::string obj = (*oi)->GetFullPath();
       this->WriteString("<EmbeddedResource Include=\"", 2);
       this->ConvertToWindowsSlash(obj);
-      (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n";
+      (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n";
       this->WriteString("<Filter>Resource Files</Filter>\n", 3);
       this->WriteString("</EmbeddedResource>\n", 2);
-      }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 
   // Add object library contents as external objects.
   std::vector<std::string> objs;
   this->GeneratorTarget->UseObjectLibraries(objs, "");
-  if(!objs.empty())
-    {
+  if (!objs.empty()) {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<std::string>::const_iterator
-          oi = objs.begin(); oi != objs.end(); ++oi)
-      {
+    for (std::vector<std::string>::const_iterator oi = objs.begin();
+         oi != objs.end(); ++oi) {
       std::string obj = *oi;
       this->WriteString("<Object Include=\"", 2);
       this->ConvertToWindowsSlash(obj);
-      (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n";
+      (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n";
       this->WriteString("<Filter>Object Libraries</Filter>\n", 3);
       this->WriteString("</Object>\n", 2);
-      }
-    this->WriteString("</ItemGroup>\n", 1);
     }
+    this->WriteString("</ItemGroup>\n", 1);
+  }
 
   this->WriteString("<ItemGroup>\n", 1);
-  for(std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
-      g != groupsUsed.end(); ++g)
-    {
+  for (std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
+       g != groupsUsed.end(); ++g) {
     cmSourceGroup* sg = *g;
     const char* name = sg->GetFullName();
-    if(strlen(name) != 0)
-      {
+    if (strlen(name) != 0) {
       this->WriteString("<Filter Include=\"", 2);
       (*this->BuildFileStream) << name << "\">\n";
       std::string guidName = "SG_Filter_";
       guidName += name;
       this->WriteString("<UniqueIdentifier>", 3);
-      std::string guid
-        = this->GlobalGenerator->GetGUID(guidName.c_str());
-      (*this->BuildFileStream)
-        << "{"
-        << guid << "}"
-        << "</UniqueIdentifier>\n";
+      std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str());
+      (*this->BuildFileStream) << "{" << guid << "}"
+                               << "</UniqueIdentifier>\n";
       this->WriteString("</Filter>\n", 2);
-      }
     }
-  if(!objs.empty())
-    {
+  }
+  if (!objs.empty()) {
     this->WriteString("<Filter Include=\"Object Libraries\">\n", 2);
     std::string guidName = "SG_Filter_Object Libraries";
     this->WriteString("<UniqueIdentifier>", 3);
-    std::string guid =
-      this->GlobalGenerator->GetGUID(guidName.c_str());
+    std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str());
     (*this->BuildFileStream) << "{" << guid << "}"
                              << "</UniqueIdentifier>\n";
     this->WriteString("</Filter>\n", 2);
-    }
+  }
 
-  if(!resxObjs.empty() || !this->AddedFiles.empty())
-    {
+  if (!resxObjs.empty() || !this->AddedFiles.empty()) {
     this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
     std::string guidName = "SG_Filter_Resource Files";
     this->WriteString("<UniqueIdentifier>", 3);
-    std::string guid =
-      this->GlobalGenerator->GetGUID(guidName.c_str());
+    std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str());
     (*this->BuildFileStream) << "{" << guid << "}"
                              << "</UniqueIdentifier>\n";
     this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3);
@@ -1187,68 +1060,56 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
   // restore stream pointer
   this->BuildFileStream = save;
 
-  if (fout.Close())
-    {
+  if (fout.Close()) {
     this->GlobalGenerator->FileReplacedDuringGenerate(path);
-    }
+  }
 }
 
 // Add to groupsUsed empty source groups that have non-empty children.
-void
-cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
+void cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
   std::set<cmSourceGroup*>& groupsUsed,
-  const std::vector<cmSourceGroup>& allGroups
-  )
+  const std::vector<cmSourceGroup>& allGroups)
 {
-  for(std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
-      current != allGroups.end(); ++current)
-    {
+  for (std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
+       current != allGroups.end(); ++current) {
     std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
-    if(children.empty())
-      {
+    if (children.empty()) {
       continue; // the group is really empty
-      }
+    }
 
     this->AddMissingSourceGroups(groupsUsed, children);
 
     cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
-    if(groupsUsed.find(current_ptr) != groupsUsed.end())
-      {
+    if (groupsUsed.find(current_ptr) != groupsUsed.end()) {
       continue; // group has already been added to set
-      }
+    }
 
     // check if it least one of the group's descendants is not empty
     // (at least one child must already have been added)
     std::vector<cmSourceGroup>::const_iterator child_it = children.begin();
-    while(child_it != children.end())
-      {
+    while (child_it != children.end()) {
       cmSourceGroup* child_ptr = const_cast<cmSourceGroup*>(&(*child_it));
-      if(groupsUsed.find(child_ptr) != groupsUsed.end())
-        {
+      if (groupsUsed.find(child_ptr) != groupsUsed.end()) {
         break; // found a child that was already added => add current group too
-        }
-      child_it++;
       }
+      child_it++;
+    }
 
-    if(child_it == children.end())
-      {
+    if (child_it == children.end()) {
       continue; // no descendants have source files => ignore this group
-      }
+    }
 
     groupsUsed.insert(current_ptr);
-    }
+  }
 }
 
-void
-cmVisualStudio10TargetGenerator::
-WriteGroupSources(const char* name,
-                  ToolSources const& sources,
-                  std::vector<cmSourceGroup>& sourceGroups)
+void cmVisualStudio10TargetGenerator::WriteGroupSources(
+  const char* name, ToolSources const& sources,
+  std::vector<cmSourceGroup>& sourceGroups)
 {
   this->WriteString("<ItemGroup>\n", 1);
-  for(ToolSources::const_iterator s = sources.begin();
-      s != sources.end(); ++s)
-    {
+  for (ToolSources::const_iterator s = sources.begin(); s != sources.end();
+       ++s) {
     cmSourceFile const* sf = s->SourceFile;
     std::string const& source = sf->GetFullPath();
     cmSourceGroup* sourceGroup =
@@ -1257,45 +1118,36 @@ WriteGroupSources(const char* name,
     this->WriteString("<", 2);
     std::string path = this->ConvertPath(source, s->RelativePath);
     this->ConvertToWindowsSlash(path);
-    (*this->BuildFileStream) << name << " Include=\""
-                             << cmVS10EscapeXML(path);
-    if(strlen(filter))
-      {
+    (*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path);
+    if (strlen(filter)) {
       (*this->BuildFileStream) << "\">\n";
       this->WriteString("<Filter>", 3);
       (*this->BuildFileStream) << filter << "</Filter>\n";
       this->WriteString("</", 2);
       (*this->BuildFileStream) << name << ">\n";
-      }
-    else
-      {
+    } else {
       (*this->BuildFileStream) << "\" />\n";
-      }
     }
+  }
   this->WriteString("</ItemGroup>\n", 1);
 }
 
 void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf)
 {
   std::string const& fileName = sf->GetFullPath();
-  if (this->IsResxHeader(fileName))
-    {
+  if (this->IsResxHeader(fileName)) {
     this->WriteSource("ClInclude", sf, ">\n");
     this->WriteString("<FileType>CppForm</FileType>\n", 3);
     this->WriteString("</ClInclude>\n", 2);
-    }
-  else if (this->IsXamlHeader(fileName))
-    {
+  } else if (this->IsXamlHeader(fileName)) {
     this->WriteSource("ClInclude", sf, ">\n");
     this->WriteString("<DependentUpon>", 3);
     std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
     (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n";
     this->WriteString("</ClInclude>\n", 2);
-    }
-  else
-    {
+  } else {
     this->WriteSource("ClInclude", sf);
-    }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
@@ -1307,163 +1159,130 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
   std::string shaderModel;
   std::string shaderAdditionalFlags;
   std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
-  if(ext == "hlsl")
-    {
+  if (ext == "hlsl") {
     tool = "FXCompile";
     // Figure out the type of shader compiler to use.
-    if(const char* st = sf->GetProperty("VS_SHADER_TYPE"))
-      {
+    if (const char* st = sf->GetProperty("VS_SHADER_TYPE")) {
       shaderType = st;
       toolHasSettings = true;
-      }
+    }
     // Figure out which entry point to use if any
-    if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT"))
-      {
+    if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) {
       shaderEntryPoint = se;
       toolHasSettings = true;
-      }
+    }
     // Figure out which shader model to use if any
-    if (const char* sm = sf->GetProperty("VS_SHADER_MODEL"))
-      {
+    if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) {
       shaderModel = sm;
       toolHasSettings = true;
-      }
+    }
     // Figure out if there's any additional flags to use
-    if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS"))
-      {
+    if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) {
       shaderAdditionalFlags = saf;
       toolHasSettings = true;
-      }
     }
-  else if(ext == "jpg" ||
-          ext == "png")
-    {
+  } else if (ext == "jpg" || ext == "png") {
     tool = "Image";
-    }
-  else if(ext == "resw")
-    {
+  } else if (ext == "resw") {
     tool = "PRIResource";
-    }
-  else if(ext == "xml")
-    {
+  } else if (ext == "xml") {
     tool = "XML";
-    }
+  }
 
-  if(this->NsightTegra)
-    {
+  if (this->NsightTegra) {
     // Nsight Tegra needs specific file types to check up-to-dateness.
-    std::string name =
-      cmSystemTools::LowerCase(sf->GetLocation().GetName());
-    if(name == "androidmanifest.xml" ||
-       name == "build.xml" ||
-       name == "proguard.cfg" ||
-       name == "proguard-project.txt" ||
-       ext == "properties")
-      {
+    std::string name = cmSystemTools::LowerCase(sf->GetLocation().GetName());
+    if (name == "androidmanifest.xml" || name == "build.xml" ||
+        name == "proguard.cfg" || name == "proguard-project.txt" ||
+        ext == "properties") {
       tool = "AndroidBuild";
-      }
-    else if(ext == "java")
-      {
+    } else if (ext == "java") {
       tool = "JCompile";
-      }
-    else if(ext == "asm" || ext == "s")
-      {
+    } else if (ext == "asm" || ext == "s") {
       tool = "ClCompile";
-      }
     }
+  }
 
   std::string deployContent;
   std::string deployLocation;
-  if(this->GlobalGenerator->TargetsWindowsPhone() ||
-     this->GlobalGenerator->TargetsWindowsStore())
-    {
+  if (this->GlobalGenerator->TargetsWindowsPhone() ||
+      this->GlobalGenerator->TargetsWindowsStore()) {
     const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT");
-    if(content && *content)
-      {
+    if (content && *content) {
       toolHasSettings = true;
       deployContent = content;
 
       const char* location = sf->GetProperty("VS_DEPLOYMENT_LOCATION");
-      if(location && *location)
-        {
+      if (location && *location) {
         deployLocation = location;
-        }
       }
     }
+  }
 
-  if(toolHasSettings)
-    {
+  if (toolHasSettings) {
     this->WriteSource(tool, sf, ">\n");
 
-    if(!deployContent.empty())
-      {
+    if (!deployContent.empty()) {
       cmGeneratorExpression ge;
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
         ge.Parse(deployContent);
       // Deployment location cannot be set on a configuration basis
-      if(!deployLocation.empty())
-        {
+      if (!deployLocation.empty()) {
         this->WriteString("<Link>", 3);
         (*this->BuildFileStream) << deployLocation
                                  << "\\%(FileName)%(Extension)";
         this->WriteString("</Link>\n", 0);
-        }
-      for(size_t i = 0; i != this->Configurations.size(); ++i)
-        {
-        if(0 == strcmp(cge->Evaluate(this->LocalGenerator,
-                                     this->Configurations[i]), "1"))
-          {
+      }
+      for (size_t i = 0; i != this->Configurations.size(); ++i) {
+        if (0 == strcmp(cge->Evaluate(this->LocalGenerator,
+                                      this->Configurations[i]),
+                        "1")) {
           this->WriteString("<DeploymentContent Condition=\""
-                            "'$(Configuration)|$(Platform)'=='", 3);
+                            "'$(Configuration)|$(Platform)'=='",
+                            3);
           (*this->BuildFileStream) << this->Configurations[i] << "|"
                                    << this->Platform << "'\">true";
           this->WriteString("</DeploymentContent>\n", 0);
-          }
-        else
-          {
+        } else {
           this->WriteString("<ExcludedFromBuild Condition=\""
-                            "'$(Configuration)|$(Platform)'=='", 3);
+                            "'$(Configuration)|$(Platform)'=='",
+                            3);
           (*this->BuildFileStream) << this->Configurations[i] << "|"
                                    << this->Platform << "'\">true";
           this->WriteString("</ExcludedFromBuild>\n", 0);
-          }
         }
       }
-    if(!shaderType.empty())
-      {
+    }
+    if (!shaderType.empty()) {
       this->WriteString("<ShaderType>", 3);
       (*this->BuildFileStream) << cmVS10EscapeXML(shaderType)
                                << "</ShaderType>\n";
-      }
-    if(!shaderEntryPoint.empty())
-      {
+    }
+    if (!shaderEntryPoint.empty()) {
       this->WriteString("<EntryPointName>", 3);
       (*this->BuildFileStream) << cmVS10EscapeXML(shaderEntryPoint)
                                << "</EntryPointName>\n";
-      }
-    if(!shaderModel.empty())
-      {
+    }
+    if (!shaderModel.empty()) {
       this->WriteString("<ShaderModel>", 3);
       (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
                                << "</ShaderModel>\n";
-      }
-    if(!shaderAdditionalFlags.empty())
-      {
+    }
+    if (!shaderAdditionalFlags.empty()) {
       this->WriteString("<AdditionalOptions>", 3);
       (*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
                                << "</AdditionalOptions>\n";
-      }
+    }
     this->WriteString("</", 2);
     (*this->BuildFileStream) << tool << ">\n";
-    }
-  else
-    {
+  } else {
     this->WriteSource(tool, sf);
-    }
+  }
 }
 
-void cmVisualStudio10TargetGenerator::WriteSource(
-  std::string const& tool, cmSourceFile const* sf, const char* end)
+void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool,
+                                                  cmSourceFile const* sf,
+                                                  const char* end)
 {
   // Visual Studio tools append relative paths to the current dir, as in:
   //
@@ -1473,9 +1292,9 @@ void cmVisualStudio10TargetGenerator::WriteSource(
   // 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() == cmGlobalVisualStudioGenerator::VS10
-     && cmSystemTools::FileIsFullPath(sourceFile.c_str()))
-    {
+  if (this->LocalGenerator->GetVersion() ==
+        cmGlobalVisualStudioGenerator::VS10 &&
+      cmSystemTools::FileIsFullPath(sourceFile.c_str())) {
     // Normal path conversion resulted in a full path.  VS 10 (but not 11)
     // refuses to show the property page in the IDE for a source file with a
     // full path (not starting in a '.' or '/' AFAICT).  CMake <= 2.8.4 used a
@@ -1486,98 +1305,79 @@ void cmVisualStudio10TargetGenerator::WriteSource(
     // when the combined path will not be too long so property pages appear.
     std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true);
     size_t const maxLen = 250;
-    if(sf->GetCustomCommand() ||
-       ((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 +
-         sourceRel.length()) <= maxLen))
-      {
+    if (sf->GetCustomCommand() ||
+        ((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 +
+          sourceRel.length()) <= maxLen)) {
       forceRelative = true;
       sourceFile = sourceRel;
-      }
-    else
-      {
-      this->GlobalGenerator->PathTooLong(this->GeneratorTarget,
-                                         sf, sourceRel);
-      }
+    } else {
+      this->GlobalGenerator->PathTooLong(this->GeneratorTarget, sf, sourceRel);
     }
+  }
   this->ConvertToWindowsSlash(sourceFile);
   this->WriteString("<", 2);
-  (*this->BuildFileStream ) << tool << " Include=\""
-                            << cmVS10EscapeXML(sourceFile) << "\""
-                            << (end? end : " />\n");
+  (*this->BuildFileStream) << tool << " Include=\""
+                           << cmVS10EscapeXML(sourceFile) << "\""
+                           << (end ? end : " />\n");
 
-  ToolSource toolSource = {sf, forceRelative};
+  ToolSource toolSource = { sf, forceRelative };
   this->Tools[tool].push_back(toolSource);
 }
 
 void cmVisualStudio10TargetGenerator::WriteSources(
   std::string const& tool, std::vector<cmSourceFile const*> const& sources)
 {
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = sources.begin(); si != sources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin();
+       si != sources.end(); ++si) {
     this->WriteSource(tool, *si);
-    }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteAllSources()
 {
-  if(this->GeneratorTarget->GetType() > cmState::UTILITY)
-    {
+  if (this->GeneratorTarget->GetType() > cmState::UTILITY) {
     return;
-    }
+  }
   this->WriteString("<ItemGroup>\n", 1);
 
   std::vector<cmSourceFile const*> headerSources;
   this->GeneratorTarget->GetHeaderSources(headerSources, "");
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = headerSources.begin(); si != headerSources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         headerSources.begin();
+       si != headerSources.end(); ++si) {
     this->WriteHeaderSource(*si);
-    }
+  }
   std::vector<cmSourceFile const*> idlSources;
   this->GeneratorTarget->GetIDLSources(idlSources, "");
   this->WriteSources("Midl", idlSources);
 
   std::vector<cmSourceFile const*> objectSources;
   this->GeneratorTarget->GetObjectSources(objectSources, "");
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         objectSources.begin();
+       si != objectSources.end(); ++si) {
     const std::string& lang = (*si)->GetLanguage();
     std::string tool;
-    if (lang == "C"|| lang == "CXX")
-      {
+    if (lang == "C" || lang == "CXX") {
       tool = "ClCompile";
-      }
-    else if (lang == "ASM_MASM" &&
-             this->GlobalGenerator->IsMasmEnabled())
-      {
+    } else if (lang == "ASM_MASM" && this->GlobalGenerator->IsMasmEnabled()) {
       tool = "MASM";
-      }
-    else if (lang == "RC")
-      {
+    } else if (lang == "RC") {
       tool = "ResourceCompile";
-      }
+    }
 
-    if (!tool.empty())
-      {
+    if (!tool.empty()) {
       this->WriteSource(tool, *si, " ");
-      if (this->OutputSourceSpecificFlags(*si))
-        {
+      if (this->OutputSourceSpecificFlags(*si)) {
         this->WriteString("</", 2);
-        (*this->BuildFileStream ) << tool << ">\n";
-        }
-      else
-        {
-        (*this->BuildFileStream ) << " />\n";
-        }
+        (*this->BuildFileStream) << tool << ">\n";
+      } else {
+        (*this->BuildFileStream) << " />\n";
       }
-    else
-      {
+    } else {
       this->WriteSource("None", *si);
-      }
     }
+  }
 
   std::vector<cmSourceFile const*> manifestSources;
   this->GeneratorTarget->GetAppManifest(manifestSources, "");
@@ -1589,69 +1389,58 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
 
   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())
-      {
+  for (std::vector<cmSourceFile const*>::iterator si = externalObjects.begin();
+       si != externalObjects.end();) {
+    if (!(*si)->GetObjectLibrary().empty()) {
       si = externalObjects.erase(si);
-      }
-    else
-      {
+    } else {
       ++si;
-      }
     }
-  if(this->LocalGenerator->GetVersion() > cmGlobalVisualStudioGenerator::VS10)
-    {
+  }
+  if (this->LocalGenerator->GetVersion() >
+      cmGlobalVisualStudioGenerator::VS10) {
     // For VS >= 11 we use LinkObjects to avoid linking custom command
     // outputs.  Use Object for all external objects, generated or not.
     this->WriteSources("Object", externalObjects);
-    }
-  else
-    {
+  } else {
     // 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*>::const_iterator
-          si = externalObjects.begin();
-        si != externalObjects.end(); ++si)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator si =
+           externalObjects.begin();
+         si != externalObjects.end(); ++si) {
       std::vector<cmSourceFile*> const* d =
-                                this->GeneratorTarget->GetSourceDepends(*si);
-      this->WriteSource((d && !d->empty())? "None":"Object", *si);
-      }
+        this->GeneratorTarget->GetSourceDepends(*si);
+      this->WriteSource((d && !d->empty()) ? "None" : "Object", *si);
     }
+  }
 
   std::vector<cmSourceFile const*> extraSources;
   this->GeneratorTarget->GetExtraSources(extraSources, "");
-  for(std::vector<cmSourceFile const*>::const_iterator
-        si = extraSources.begin(); si != extraSources.end(); ++si)
-    {
+  for (std::vector<cmSourceFile const*>::const_iterator si =
+         extraSources.begin();
+       si != extraSources.end(); ++si) {
     this->WriteExtraSource(*si);
-    }
+  }
 
   // Add object library contents as external objects.
   std::vector<std::string> objs;
   this->GeneratorTarget->UseObjectLibraries(objs, "");
-  for(std::vector<std::string>::const_iterator
-        oi = objs.begin(); oi != objs.end(); ++oi)
-    {
+  for (std::vector<std::string>::const_iterator oi = objs.begin();
+       oi != objs.end(); ++oi) {
     std::string obj = *oi;
     this->WriteString("<Object Include=\"", 2);
     this->ConvertToWindowsSlash(obj);
-    (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\" />\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\" />\n";
+  }
 
   if (cmSourceFile const* defsrc =
-      this->GeneratorTarget->GetModuleDefinitionFile(""))
-    {
+        this->GeneratorTarget->GetModuleDefinitionFile("")) {
     this->WriteSource("None", defsrc);
-    }
+  }
 
-  if (this->IsMissingFiles)
-    {
+  if (this->IsMissingFiles) {
     this->WriteMissingFiles();
-    }
+  }
 
   this->WriteString("</ItemGroup>\n", 1);
 }
@@ -1662,118 +1451,98 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
   cmSourceFile const& sf = *source;
 
   std::string objectName;
-  if(this->GeneratorTarget->HasExplicitObjectName(&sf))
-    {
+  if (this->GeneratorTarget->HasExplicitObjectName(&sf)) {
     objectName = this->GeneratorTarget->GetObjectName(&sf);
-    }
+  }
   std::string flags;
   std::string defines;
-  if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
-    {
+  if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
     flags += cflags;
-    }
-  if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
-    {
+  }
+  if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
     defines += cdefs;
-    }
+  }
   std::string lang =
-    this->GlobalGenerator->GetLanguageFromExtension
-    (sf.GetExtension().c_str());
+    this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
   std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
   const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage();
   bool needForceLang = false;
   // source file does not match its extension language
-  if(lang != sourceLang)
-    {
+  if (lang != sourceLang) {
     needForceLang = true;
     lang = sourceLang;
-    }
+  }
   // if the source file does not match the linker language
   // then force c or c++
   const char* compileAs = 0;
-  if(needForceLang || (linkLanguage != lang))
-    {
-    if(lang == "CXX")
-      {
+  if (needForceLang || (linkLanguage != lang)) {
+    if (lang == "CXX") {
       // force a C++ file type
       compileAs = "CompileAsCpp";
-      }
-    else if(lang == "C")
-      {
+    } else if (lang == "C") {
       // force to c
       compileAs = "CompileAsC";
-      }
     }
+  }
   bool noWinRT = this->TargetCompileAsWinRT && lang == "C";
   bool hasFlags = false;
   // for the first time we need a new line if there is something
   // produced here.
   const char* firstString = ">\n";
-  if(!objectName.empty())
-    {
-    (*this->BuildFileStream ) << firstString;
+  if (!objectName.empty()) {
+    (*this->BuildFileStream) << firstString;
     firstString = "";
     hasFlags = true;
     this->WriteString("<ObjectFileName>", 3);
-    (*this->BuildFileStream )
-      << "$(IntDir)/" << objectName << "</ObjectFileName>\n";
-    }
-  for(std::vector<std::string>::const_iterator
-        config = this->Configurations.begin();
-      config != this->Configurations.end(); ++config)
-    {
+    (*this->BuildFileStream) << "$(IntDir)/" << objectName
+                             << "</ObjectFileName>\n";
+  }
+  for (std::vector<std::string>::const_iterator config =
+         this->Configurations.begin();
+       config != this->Configurations.end(); ++config) {
     std::string configUpper = cmSystemTools::UpperCase(*config);
     std::string configDefines = defines;
     std::string defPropName = "COMPILE_DEFINITIONS_";
     defPropName += configUpper;
-    if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
-      {
-      if(!configDefines.empty())
-        {
+    if (const char* ccdefs = sf.GetProperty(defPropName.c_str())) {
+      if (!configDefines.empty()) {
         configDefines += ";";
-        }
-      configDefines += ccdefs;
       }
+      configDefines += ccdefs;
+    }
     // if we have flags or defines for this config then
     // use them
-    if(!flags.empty() || !configDefines.empty() || compileAs || noWinRT)
-      {
-      (*this->BuildFileStream ) << firstString;
+    if (!flags.empty() || !configDefines.empty() || compileAs || noWinRT) {
+      (*this->BuildFileStream) << firstString;
       firstString = ""; // only do firstString once
       hasFlags = true;
-      cmVisualStudioGeneratorOptions
-        clOptions(this->LocalGenerator,
-                  cmVisualStudioGeneratorOptions::Compiler,
-                  this->GetClFlagTable(), 0, this);
-      if(compileAs)
-        {
+      cmVisualStudioGeneratorOptions clOptions(
+        this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
+        this->GetClFlagTable(), 0, this);
+      if (compileAs) {
         clOptions.AddFlag("CompileAs", compileAs);
-        }
-      if(noWinRT)
-        {
+      }
+      if (noWinRT) {
         clOptions.AddFlag("CompileAsWinRT", "false");
-        }
+      }
       clOptions.Parse(flags.c_str());
-      if(clOptions.HasFlag("AdditionalIncludeDirectories"))
-        {
+      if (clOptions.HasFlag("AdditionalIncludeDirectories")) {
         clOptions.AppendFlag("AdditionalIncludeDirectories",
                              "%(AdditionalIncludeDirectories)");
-        }
-      if(clOptions.HasFlag("DisableSpecificWarnings"))
-        {
+      }
+      if (clOptions.HasFlag("DisableSpecificWarnings")) {
         clOptions.AppendFlag("DisableSpecificWarnings",
                              "%(DisableSpecificWarnings)");
-        }
+      }
       clOptions.AddDefines(configDefines.c_str());
       clOptions.SetConfiguration((*config).c_str());
       clOptions.OutputAdditionalOptions(*this->BuildFileStream, "      ", "");
       clOptions.OutputFlagMap(*this->BuildFileStream, "      ");
-      clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
-                                              "      ", "\n", lang);
-      }
+      clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
+                                              "\n", lang);
     }
-  if (this->IsXamlSource(source->GetFullPath()))
-    {
+  }
+  if (this->IsXamlSource(source->GetFullPath())) {
     (*this->BuildFileStream) << firstString;
     firstString = ""; // only do firstString once
     hasFlags = true;
@@ -1781,60 +1550,51 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
     const std::string& fileName = source->GetFullPath();
     std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
     (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n";
-    }
+  }
 
   return hasFlags;
 }
 
-
 void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
 {
   cmState::TargetType ttype = this->GeneratorTarget->GetType();
-  if(ttype > cmState::GLOBAL_TARGET)
-    {
+  if (ttype > cmState::GLOBAL_TARGET) {
     return;
-    }
+  }
 
   this->WriteString("<PropertyGroup>\n", 2);
   this->WriteString("<_ProjectFileVersion>10.0.20506.1"
-                    "</_ProjectFileVersion>\n", 3);
-  for(std::vector<std::string>::const_iterator
-        config = this->Configurations.begin();
-      config != this->Configurations.end(); ++config)
-    {
-    if(ttype >= cmState::UTILITY)
-      {
+                    "</_ProjectFileVersion>\n",
+                    3);
+  for (std::vector<std::string>::const_iterator config =
+         this->Configurations.begin();
+       config != this->Configurations.end(); ++config) {
+    if (ttype >= cmState::UTILITY) {
       this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
       *this->BuildFileStream
         << "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
         << "</IntDir>\n";
-      }
-    else
-      {
-      std::string intermediateDir = this->LocalGenerator->
-        GetTargetDirectory(this->GeneratorTarget);
+    } else {
+      std::string intermediateDir =
+        this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
       intermediateDir += "/";
       intermediateDir += *config;
       intermediateDir += "/";
       std::string outDir;
       std::string targetNameFull;
-      if(ttype == cmState::OBJECT_LIBRARY)
-        {
+      if (ttype == cmState::OBJECT_LIBRARY) {
         outDir = intermediateDir;
         targetNameFull = this->GeneratorTarget->GetName();
         targetNameFull += ".lib";
-        }
-      else
-        {
+      } else {
         outDir = this->GeneratorTarget->GetDirectory(config->c_str()) + "/";
         targetNameFull = this->GeneratorTarget->GetFullName(config->c_str());
-        }
+      }
       this->ConvertToWindowsSlash(intermediateDir);
       this->ConvertToWindowsSlash(outDir);
 
       this->WritePlatformConfigTag("OutDir", config->c_str(), 3);
-      *this->BuildFileStream << cmVS10EscapeXML(outDir)
-                             << "</OutDir>\n";
+      *this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n";
 
       this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
       *this->BuildFileStream << cmVS10EscapeXML(intermediateDir)
@@ -1847,86 +1607,71 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
 
       std::string ext =
         cmSystemTools::GetFilenameLastExtension(targetNameFull);
-      if(ext.empty())
-        {
+      if (ext.empty()) {
         // An empty TargetExt causes a default extension to be used.
         // A single "." appears to be treated as an empty extension.
         ext = ".";
-        }
+      }
       this->WritePlatformConfigTag("TargetExt", config->c_str(), 3);
       *this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n";
 
       this->OutputLinkIncremental(*config);
-      }
     }
+  }
   this->WriteString("</PropertyGroup>\n", 2);
 }
 
-
-
-void
-cmVisualStudio10TargetGenerator::
-OutputLinkIncremental(std::string const& configName)
+void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
+  std::string const& configName)
 {
-  if(!this->MSTools)
-    {
+  if (!this->MSTools) {
     return;
-    }
+  }
   // static libraries and things greater than modules do not need
   // to set this option
-  if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY
-     || this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
+      this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) {
     return;
-    }
+  }
   Options& linkOptions = *(this->LinkOptions[configName]);
 
   const char* incremental = linkOptions.GetFlag("LinkIncremental");
   this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3);
-  *this->BuildFileStream << (incremental?incremental:"true")
+  *this->BuildFileStream << (incremental ? incremental : "true")
                          << "</LinkIncremental>\n";
   linkOptions.RemoveFlag("LinkIncremental");
 
   const char* manifest = linkOptions.GetFlag("GenerateManifest");
   this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3);
-  *this->BuildFileStream << (manifest?manifest:"true")
+  *this->BuildFileStream << (manifest ? manifest : "true")
                          << "</GenerateManifest>\n";
   linkOptions.RemoveFlag("GenerateManifest");
 
   // Some link options belong here.  Use them now and remove them so that
   // WriteLinkOptions does not use them.
-  const char* flags[] = {
-    "LinkDelaySign",
-    "LinkKeyFile",
-    0};
-  for(const char** f = flags; *f; ++f)
-    {
+  const char* flags[] = { "LinkDelaySign", "LinkKeyFile", 0 };
+  for (const char** f = flags; *f; ++f) {
     const char* flag = *f;
-    if(const char* value = linkOptions.GetFlag(flag))
-      {
+    if (const char* value = linkOptions.GetFlag(flag)) {
       this->WritePlatformConfigTag(flag, configName.c_str(), 3);
       *this->BuildFileStream << value << "</" << flag << ">\n";
       linkOptions.RemoveFlag(flag);
-      }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeClOptions()
 {
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
-    if(!this->ComputeClOptions(*i))
-      {
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
+    if (!this->ComputeClOptions(*i)) {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeClOptions(
   std::string const& configName)
 {
@@ -1934,118 +1679,101 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
   // copied from cmLocalVisualStudio7Generator.cxx 805
   // TODO: Integrate code below with cmLocalVisualStudio7Generator.
 
-  cmsys::auto_ptr<Options> pOptions(
-    new Options(this->LocalGenerator, Options::Compiler,
-                this->GetClFlagTable()));
+  cmsys::auto_ptr<Options> pOptions(new Options(
+    this->LocalGenerator, Options::Compiler, this->GetClFlagTable()));
   Options& clOptions = *pOptions;
 
   std::string flags;
   const std::string& linkLanguage =
     this->GeneratorTarget->GetLinkerLanguage(configName.c_str());
-  if(linkLanguage.empty())
-    {
-    cmSystemTools::Error
-      ("CMake can not determine linker language for target: ",
-       this->Name.c_str());
+  if (linkLanguage.empty()) {
+    cmSystemTools::Error(
+      "CMake can not determine linker language for target: ",
+      this->Name.c_str());
     return false;
-    }
-  if(linkLanguage == "C" || linkLanguage == "CXX"
-     || linkLanguage == "Fortran")
-    {
+  }
+  if (linkLanguage == "C" || linkLanguage == "CXX" ||
+      linkLanguage == "Fortran") {
     std::string baseFlagVar = "CMAKE_";
     baseFlagVar += linkLanguage;
     baseFlagVar += "_FLAGS";
-    flags = this->GeneratorTarget->
-      Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
-    std::string flagVar = baseFlagVar + std::string("_") +
-      cmSystemTools::UpperCase(configName);
+    flags =
+      this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
+        baseFlagVar.c_str());
+    std::string flagVar =
+      baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName);
     flags += " ";
-    flags += this->GeneratorTarget->
-      Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
-    }
+    flags +=
+      this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
+        flagVar.c_str());
+  }
   // set the correct language
-  if(linkLanguage == "C")
-    {
+  if (linkLanguage == "C") {
     clOptions.AddFlag("CompileAs", "CompileAsC");
-    }
-  if(linkLanguage == "CXX")
-    {
+  }
+  if (linkLanguage == "CXX") {
     clOptions.AddFlag("CompileAs", "CompileAsCpp");
-    }
+  }
   this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
                                           linkLanguage, configName.c_str());
 
   // Get preprocessor definitions for this directory.
   std::string defineFlags =
-      this->GeneratorTarget->Target->GetMakefile()->GetDefineFlags();
-  if(this->MSTools)
-    {
+    this->GeneratorTarget->Target->GetMakefile()->GetDefineFlags();
+  if (this->MSTools) {
     clOptions.FixExceptionHandlingDefault();
     clOptions.AddFlag("PrecompiledHeader", "NotUsing");
     std::string asmLocation = configName + "/";
     clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
-    }
+  }
   clOptions.Parse(flags.c_str());
   clOptions.Parse(defineFlags.c_str());
   std::vector<std::string> targetDefines;
   this->GeneratorTarget->GetCompileDefinitions(targetDefines,
-                                      configName.c_str(), "CXX");
+                                               configName.c_str(), "CXX");
   clOptions.AddDefines(targetDefines);
-  if(this->MSTools)
-    {
+  if (this->MSTools) {
     clOptions.SetVerboseMakefile(
       this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
-    }
+  }
 
   // Add a definition for the configuration name.
   std::string configDefine = "CMAKE_INTDIR=\"";
   configDefine += configName;
   configDefine += "\"";
   clOptions.AddDefine(configDefine);
-  if(const char* exportMacro =
-          this->GeneratorTarget->GetExportMacro())
-    {
+  if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
     clOptions.AddDefine(exportMacro);
-    }
+  }
 
-  if (this->MSTools)
-    {
+  if (this->MSTools) {
     // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT.
-    if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT"))
-      {
+    if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
       clOptions.AddFlag("CompileAsWinRT", "true");
       // For WinRT components, add the _WINRT_DLL define to produce a lib
       if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
-          this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY )
-        {
+          this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
         clOptions.AddDefine("_WINRT_DLL");
-        }
       }
-    else if (this->GlobalGenerator->TargetsWindowsStore() ||
-             this->GlobalGenerator->TargetsWindowsPhone())
-      {
-      if (!clOptions.IsWinRt())
-        {
+    } else if (this->GlobalGenerator->TargetsWindowsStore() ||
+               this->GlobalGenerator->TargetsWindowsPhone()) {
+      if (!clOptions.IsWinRt()) {
         clOptions.AddFlag("CompileAsWinRT", "false");
-        }
       }
-    if(const char* winRT = clOptions.GetFlag("CompileAsWinRT"))
-      {
-      if(cmSystemTools::IsOn(winRT))
-        {
+    }
+    if (const char* winRT = clOptions.GetFlag("CompileAsWinRT")) {
+      if (cmSystemTools::IsOn(winRT)) {
         this->TargetCompileAsWinRT = true;
-        }
       }
     }
+  }
 
   this->ClOptions[configName] = pOptions.release();
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudio10TargetGenerator::WriteClOptions(
-  std::string const& configName,
-  std::vector<std::string> const& includes)
+  std::string const& configName, std::vector<std::string> const& includes)
 {
   Options& clOptions = *(this->ClOptions[configName]);
   this->WriteString("<ClCompile>\n", 2);
@@ -2057,88 +1785,86 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
   clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
                                           "\n", "CXX");
 
-  if(this->NsightTegra)
-    {
-    if(const char* processMax =
-        this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX"))
-      {
+  if (this->NsightTegra) {
+    if (const char* processMax =
+          this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) {
       this->WriteString("<ProcessMax>", 3);
-      *this->BuildFileStream << cmVS10EscapeXML(processMax) <<
-        "</ProcessMax>\n";
-      }
+      *this->BuildFileStream << cmVS10EscapeXML(processMax)
+                             << "</ProcessMax>\n";
     }
+  }
 
-  if(this->MSTools)
-    {
-    this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+  if (this->MSTools) {
+    cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
+    const char* toolset = this->GlobalGenerator->GetPlatformToolset();
+    if (toolset && clangToolset.find(toolset)) {
+      this->WriteString("<ObjectFileName>"
+                        "$(IntDir)%(filename).obj"
+                        "</ObjectFileName>\n",
+                        3);
+    } else {
+      this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+    }
 
     // If not in debug mode, write the DebugInformationFormat field
     // without value so PDBs don't get generated uselessly.
-    if(!clOptions.IsDebug())
-      {
+    if (!clOptions.IsDebug()) {
       this->WriteString("<DebugInformationFormat>"
-                        "</DebugInformationFormat>\n", 3);
-      }
+                        "</DebugInformationFormat>\n",
+                        3);
+    }
 
     // Specify the compiler program database file if configured.
     std::string pdb =
-        this->GeneratorTarget->GetCompilePDBPath(configName.c_str());
-    if(!pdb.empty())
-      {
+      this->GeneratorTarget->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);
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
 {
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
-    if(!this->ComputeRcOptions(*i))
-      {
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
+    if (!this->ComputeRcOptions(*i)) {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
   std::string const& configName)
 {
-  cmsys::auto_ptr<Options> pOptions(
-    new Options(this->LocalGenerator, Options::ResourceCompiler,
-                this->GetRcFlagTable()));
+  cmsys::auto_ptr<Options> pOptions(new Options(
+    this->LocalGenerator, Options::ResourceCompiler, this->GetRcFlagTable()));
   Options& rcOptions = *pOptions;
 
   std::string CONFIG = cmSystemTools::UpperCase(configName);
   std::string rcConfigFlagsVar = std::string("CMAKE_RC_FLAGS_") + CONFIG;
   std::string flags =
-      std::string(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS")) +
-      std::string(" ") +
-      std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
+    std::string(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS")) +
+    std::string(" ") +
+    std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
 
   rcOptions.Parse(flags.c_str());
   this->RcOptions[configName] = pOptions.release();
   return true;
 }
 
-void cmVisualStudio10TargetGenerator::
-WriteRCOptions(std::string const& configName,
-               std::vector<std::string> const & includes)
+void cmVisualStudio10TargetGenerator::WriteRCOptions(
+  std::string const& configName, std::vector<std::string> const& includes)
 {
-  if(!this->MSTools)
-    {
+  if (!this->MSTools) {
     return;
-    }
+  }
   this->WriteString("<ResourceCompile>\n", 2);
 
   // Preprocessor definitions and includes are shared with clOptions.
@@ -2156,54 +1882,46 @@ WriteRCOptions(std::string const& configName,
   this->WriteString("</ResourceCompile>\n", 2);
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
 {
-  if(!this->GlobalGenerator->IsMasmEnabled())
-    {
-    return true;
-    }
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
-    if(!this->ComputeMasmOptions(*i))
-      {
+  if (!this->GlobalGenerator->IsMasmEnabled()) {
+    return true;
+  }
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
+    if (!this->ComputeMasmOptions(*i)) {
       return false;
-      }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
   std::string const& configName)
 {
-  cmsys::auto_ptr<Options> pOptions(
-    new Options(this->LocalGenerator, Options::MasmCompiler,
-                this->GetMasmFlagTable()));
+  cmsys::auto_ptr<Options> pOptions(new Options(
+    this->LocalGenerator, Options::MasmCompiler, this->GetMasmFlagTable()));
   Options& masmOptions = *pOptions;
 
   std::string CONFIG = cmSystemTools::UpperCase(configName);
   std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG;
   std::string flags =
-      std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) +
-      std::string(" ") +
-      std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+    std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) +
+    std::string(" ") +
+    std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
 
   masmOptions.Parse(flags.c_str());
   this->MasmOptions[configName] = pOptions.release();
   return true;
 }
 
-void cmVisualStudio10TargetGenerator::
-WriteMasmOptions(std::string const& configName,
-                 std::vector<std::string> const& includes)
+void cmVisualStudio10TargetGenerator::WriteMasmOptions(
+  std::string const& configName, std::vector<std::string> const& includes)
 {
-  if(!this->MSTools || !this->GlobalGenerator->IsMasmEnabled())
-    {
+  if (!this->MSTools || !this->GlobalGenerator->IsMasmEnabled()) {
     return;
-    }
+  }
   this->WriteString("<MASM>\n", 2);
 
   // Preprocessor definitions and includes are shared with clOptions.
@@ -2220,42 +1938,38 @@ WriteMasmOptions(std::string const& configName,
   this->WriteString("</MASM>\n", 2);
 }
 
-
-void
-cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
+void cmVisualStudio10TargetGenerator::WriteLibOptions(
+  std::string const& config)
 {
-  if(this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY &&
-     this->GeneratorTarget->GetType() != cmState::OBJECT_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY &&
+      this->GeneratorTarget->GetType() != cmState::OBJECT_LIBRARY) {
     return;
-    }
+  }
   std::string libflags;
-  this->LocalGenerator->GetStaticLibraryFlags(libflags,
-    cmSystemTools::UpperCase(config), this->GeneratorTarget);
-  if(!libflags.empty())
-    {
+  this->LocalGenerator->GetStaticLibraryFlags(
+    libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget);
+  if (!libflags.empty()) {
     this->WriteString("<Lib>\n", 2);
-    cmVisualStudioGeneratorOptions
-      libOptions(this->LocalGenerator,
-                 cmVisualStudioGeneratorOptions::Linker,
-                 this->GetLibFlagTable(), 0, this);
+    cmVisualStudioGeneratorOptions libOptions(
+      this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker,
+      this->GetLibFlagTable(), 0, this);
     libOptions.Parse(libflags.c_str());
     libOptions.OutputAdditionalOptions(*this->BuildFileStream, "      ", "");
     libOptions.OutputFlagMap(*this->BuildFileStream, "      ");
     this->WriteString("</Lib>\n", 2);
-    }
+  }
 
   // We cannot generate metadata for static libraries.  WindowsPhone
   // and WindowsStore tools look at GenerateWindowsMetadata in the
   // Link tool options even for static libraries.
-  if(this->GlobalGenerator->TargetsWindowsPhone() ||
-     this->GlobalGenerator->TargetsWindowsStore())
-    {
+  if (this->GlobalGenerator->TargetsWindowsPhone() ||
+      this->GlobalGenerator->TargetsWindowsStore()) {
     this->WriteString("<Link>\n", 2);
     this->WriteString("<GenerateWindowsMetadata>false"
-                      "</GenerateWindowsMetadata>\n", 3);
+                      "</GenerateWindowsMetadata>\n",
+                      3);
     this->WriteString("</Link>\n", 2);
-    }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteManifestOptions(
@@ -2263,30 +1977,27 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
 {
   if (this->GeneratorTarget->GetType() != cmState::EXECUTABLE &&
       this->GeneratorTarget->GetType() != cmState::SHARED_LIBRARY &&
-      this->GeneratorTarget->GetType() != cmState::MODULE_LIBRARY)
-    {
+      this->GeneratorTarget->GetType() != cmState::MODULE_LIBRARY) {
     return;
-    }
+  }
 
   std::vector<cmSourceFile const*> manifest_srcs;
   this->GeneratorTarget->GetManifests(manifest_srcs, config);
-  if (!manifest_srcs.empty())
-    {
+  if (!manifest_srcs.empty()) {
     this->WriteString("<Manifest>\n", 2);
     this->WriteString("<AdditionalManifestFiles>", 3);
-    for (std::vector<cmSourceFile const*>::const_iterator
-           mi = manifest_srcs.begin(); mi != manifest_srcs.end(); ++mi)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator mi =
+           manifest_srcs.begin();
+         mi != manifest_srcs.end(); ++mi) {
       std::string m = this->ConvertPath((*mi)->GetFullPath(), false);
       this->ConvertToWindowsSlash(m);
       (*this->BuildFileStream) << m << ";";
-      }
+    }
     (*this->BuildFileStream) << "</AdditionalManifestFiles>\n";
     this->WriteString("</Manifest>\n", 2);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
   std::string const& configName)
 {
@@ -2294,246 +2005,220 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
   // its location as the root source directory.
   std::string rootDir = this->LocalGenerator->GetCurrentSourceDirectory();
   {
-  std::vector<cmSourceFile const*> extraSources;
-  this->GeneratorTarget->GetExtraSources(extraSources, "");
-  for(std::vector<cmSourceFile const*>::const_iterator si =
-        extraSources.begin(); si != extraSources.end(); ++si)
-    {
-    if("androidmanifest.xml" == cmSystemTools::LowerCase(
-         (*si)->GetLocation().GetName()))
-      {
-      rootDir = (*si)->GetLocation().GetDirectory();
-      break;
+    std::vector<cmSourceFile const*> extraSources;
+    this->GeneratorTarget->GetExtraSources(extraSources, "");
+    for (std::vector<cmSourceFile const*>::const_iterator si =
+           extraSources.begin();
+         si != extraSources.end(); ++si) {
+      if ("androidmanifest.xml" ==
+          cmSystemTools::LowerCase((*si)->GetLocation().GetName())) {
+        rootDir = (*si)->GetLocation().GetDirectory();
+        break;
       }
     }
   }
 
   // Tell MSBuild to launch Ant.
   {
-  std::string antBuildPath = rootDir;
-  this->WriteString("<AntBuild>\n", 2);
-  this->WriteString("<AntBuildPath>", 3);
-  this->ConvertToWindowsSlash(antBuildPath);
-  (*this->BuildFileStream) <<
-    cmVS10EscapeXML(antBuildPath) << "</AntBuildPath>\n";
+    std::string antBuildPath = rootDir;
+    this->WriteString("<AntBuild>\n", 2);
+    this->WriteString("<AntBuildPath>", 3);
+    this->ConvertToWindowsSlash(antBuildPath);
+    (*this->BuildFileStream) << cmVS10EscapeXML(antBuildPath)
+                             << "</AntBuildPath>\n";
   }
 
-  if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP"))
-    {
+  if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) {
     this->WriteString("<SkipAntStep>true</SkipAntStep>\n", 3);
-    }
+  }
 
-  if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD"))
-    {
+  if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD")) {
     this->WriteString("<EnableProGuard>true</EnableProGuard>\n", 3);
-    }
+  }
 
   if (const char* proGuardConfigLocation =
-      this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) {
     this->WriteString("<ProGuardConfigLocation>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(proGuardConfigLocation) <<
-      "</ProGuardConfigLocation>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(proGuardConfigLocation)
+                             << "</ProGuardConfigLocation>\n";
+  }
 
   if (const char* securePropertiesLocation =
-      this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) {
     this->WriteString("<SecurePropertiesLocation>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(securePropertiesLocation) <<
-      "</SecurePropertiesLocation>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(securePropertiesLocation)
+                             << "</SecurePropertiesLocation>\n";
+  }
 
   if (const char* nativeLibDirectoriesExpression =
-      this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) {
     cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
-        ge.Parse(nativeLibDirectoriesExpression);
-    std::string nativeLibDirs = cge->Evaluate(this->LocalGenerator,
-                                              configName);
+      ge.Parse(nativeLibDirectoriesExpression);
+    std::string nativeLibDirs =
+      cge->Evaluate(this->LocalGenerator, configName);
     this->WriteString("<NativeLibDirectories>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDirs) <<
-      "</NativeLibDirectories>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDirs)
+                             << "</NativeLibDirectories>\n";
+  }
 
   if (const char* nativeLibDependenciesExpression =
-      this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DEPENDENCIES"))
-    {
+        this->GeneratorTarget->GetProperty(
+          "ANDROID_NATIVE_LIB_DEPENDENCIES")) {
     cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
-        ge.Parse(nativeLibDependenciesExpression);
-    std::string nativeLibDeps = cge->Evaluate(this->LocalGenerator,
-                                              configName);
+      ge.Parse(nativeLibDependenciesExpression);
+    std::string nativeLibDeps =
+      cge->Evaluate(this->LocalGenerator, configName);
     this->WriteString("<NativeLibDependencies>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDeps) <<
-      "</NativeLibDependencies>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDeps)
+                             << "</NativeLibDependencies>\n";
+  }
 
   if (const char* javaSourceDir =
-      this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) {
     this->WriteString("<JavaSourceDir>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(javaSourceDir) <<
-      "</JavaSourceDir>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(javaSourceDir)
+                             << "</JavaSourceDir>\n";
+  }
 
   if (const char* jarDirectoriesExpression =
-      this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) {
     cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
       ge.Parse(jarDirectoriesExpression);
-    std::string jarDirectories = cge->Evaluate(this->LocalGenerator,
-                                               configName);
+    std::string jarDirectories =
+      cge->Evaluate(this->LocalGenerator, configName);
     this->WriteString("<JarDirectories>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(jarDirectories) <<
-      "</JarDirectories>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(jarDirectories)
+                             << "</JarDirectories>\n";
+  }
 
   if (const char* jarDeps =
-      this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) {
     this->WriteString("<JarDependencies>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(jarDeps) <<
-      "</JarDependencies>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(jarDeps)
+                             << "</JarDependencies>\n";
+  }
 
   if (const char* assetsDirectories =
-      this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) {
     this->WriteString("<AssetsDirectories>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(assetsDirectories) <<
-      "</AssetsDirectories>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(assetsDirectories)
+                             << "</AssetsDirectories>\n";
+  }
 
   {
-  std::string manifest_xml = rootDir + "/AndroidManifest.xml";
-  this->ConvertToWindowsSlash(manifest_xml);
-  this->WriteString("<AndroidManifestLocation>", 3);
-  (*this->BuildFileStream) <<
-    cmVS10EscapeXML(manifest_xml) << "</AndroidManifestLocation>\n";
+    std::string manifest_xml = rootDir + "/AndroidManifest.xml";
+    this->ConvertToWindowsSlash(manifest_xml);
+    this->WriteString("<AndroidManifestLocation>", 3);
+    (*this->BuildFileStream) << cmVS10EscapeXML(manifest_xml)
+                             << "</AndroidManifestLocation>\n";
   }
 
   if (const char* antAdditionalOptions =
-      this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS"))
-    {
+        this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) {
     this->WriteString("<AdditionalOptions>", 3);
-    (*this->BuildFileStream) << cmVS10EscapeXML(antAdditionalOptions) <<
-      " %(AdditionalOptions)</AdditionalOptions>\n";
-    }
+    (*this->BuildFileStream) << cmVS10EscapeXML(antAdditionalOptions)
+                             << " %(AdditionalOptions)</AdditionalOptions>\n";
+  }
 
   this->WriteString("</AntBuild>\n", 2);
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
 {
-  if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
-     this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
-     this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY)
-    {
-    for(std::vector<std::string>::const_iterator
-          i = this->Configurations.begin();
-        i != this->Configurations.end(); ++i)
-      {
-      if(!this->ComputeLinkOptions(*i))
-        {
+  if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE ||
+      this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY ||
+      this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
+    for (std::vector<std::string>::const_iterator i =
+           this->Configurations.begin();
+         i != this->Configurations.end(); ++i) {
+      if (!this->ComputeLinkOptions(*i)) {
         return false;
-        }
       }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
+bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
+  std::string const& config)
 {
-  cmsys::auto_ptr<Options> pOptions(
-    new Options(this->LocalGenerator, Options::Linker,
-                this->GetLinkFlagTable(), 0, this));
+  cmsys::auto_ptr<Options> pOptions(new Options(
+    this->LocalGenerator, Options::Linker, this->GetLinkFlagTable(), 0, this));
   Options& linkOptions = *pOptions;
 
   const std::string& linkLanguage =
     this->GeneratorTarget->GetLinkerLanguage(config.c_str());
-  if(linkLanguage.empty())
-    {
-    cmSystemTools::Error
-      ("CMake can not determine linker language for target: ",
-       this->Name.c_str());
+  if (linkLanguage.empty()) {
+    cmSystemTools::Error(
+      "CMake can not determine linker language for target: ",
+      this->Name.c_str());
     return false;
-    }
+  }
 
   std::string CONFIG = cmSystemTools::UpperCase(config);
 
   const char* linkType = "SHARED";
-  if(this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) {
     linkType = "MODULE";
-    }
-  if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-    {
+  }
+  if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
     linkType = "EXE";
-    }
+  }
   std::string flags;
   std::string linkFlagVarBase = "CMAKE_";
   linkFlagVarBase += linkType;
   linkFlagVarBase += "_LINKER_FLAGS";
   flags += " ";
-  flags += this->GeneratorTarget->
-    Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
+  flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
+    linkFlagVarBase.c_str());
   std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
   flags += " ";
-  flags += this->GeneratorTarget->
-    Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
+  flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
+    linkFlagVar.c_str());
   const char* targetLinkFlags =
-      this->GeneratorTarget->GetProperty("LINK_FLAGS");
-  if(targetLinkFlags)
-    {
+    this->GeneratorTarget->GetProperty("LINK_FLAGS");
+  if (targetLinkFlags) {
     flags += " ";
     flags += targetLinkFlags;
-    }
+  }
   std::string flagsProp = "LINK_FLAGS_";
   flagsProp += CONFIG;
-  if(const char* flagsConfig =
-     this->GeneratorTarget->GetProperty(flagsProp.c_str()))
-    {
+  if (const char* flagsConfig =
+        this->GeneratorTarget->GetProperty(flagsProp.c_str())) {
     flags += " ";
     flags += flagsConfig;
-    }
+  }
   std::string standardLibsVar = "CMAKE_";
   standardLibsVar += linkLanguage;
   standardLibsVar += "_STANDARD_LIBRARIES";
-  std::string
-    libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
+  std::string libs =
+    this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
   // Remove trailing spaces from libs
-  std::string::size_type pos = libs.size()-1;
-  if(!libs.empty())
-    {
-    while(libs[pos] == ' ')
-      {
+  std::string::size_type pos = libs.size() - 1;
+  if (!libs.empty()) {
+    while (libs[pos] == ' ') {
       pos--;
-      }
-    }
-  if(pos != libs.size()-1)
-    {
-    libs = libs.substr(0, pos+1);
     }
+  }
+  if (pos != libs.size() - 1) {
+    libs = libs.substr(0, pos + 1);
+  }
   // Replace spaces in libs with ;
-  cmSystemTools::ReplaceString(libs, " ", ";");
+  std::replace(libs.begin(), libs.end(), ' ', ';');
   std::vector<std::string> libVec;
   cmSystemTools::ExpandListArgument(libs, libVec);
 
   cmComputeLinkInformation* pcli =
     this->GeneratorTarget->GetLinkInformation(config.c_str());
-  if(!pcli)
-    {
-    cmSystemTools::Error
-      ("CMake can not compute cmComputeLinkInformation for target: ",
-       this->Name.c_str());
+  if (!pcli) {
+    cmSystemTools::Error(
+      "CMake can not compute cmComputeLinkInformation for target: ",
+      this->Name.c_str());
     return false;
-    }
+  }
   // add the libraries for the target to libs string
   cmComputeLinkInformation& cli = *pcli;
   this->AddLibraries(cli, libVec);
@@ -2541,14 +2226,13 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
 
   std::vector<std::string> const& ldirs = cli.GetDirectories();
   std::vector<std::string> linkDirs;
-  for(std::vector<std::string>::const_iterator d = ldirs.begin();
-      d != ldirs.end(); ++d)
-    {
+  for (std::vector<std::string>::const_iterator d = ldirs.begin();
+       d != ldirs.end(); ++d) {
     // first just full path
     linkDirs.push_back(*d);
     // next path with configuration type Debug, Release, etc
     linkDirs.push_back(*d + "/$(Configuration)");
-    }
+  }
   linkDirs.push_back("%(AdditionalLibraryDirectories)");
   linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs);
 
@@ -2557,90 +2241,64 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
   std::string targetNameFull;
   std::string targetNameImport;
   std::string targetNamePDB;
-  if(this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
     this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull,
-                                     targetNameImport, targetNamePDB,
-                                     config.c_str());
-    }
-  else
-    {
+                                              targetNameImport, targetNamePDB,
+                                              config.c_str());
+  } else {
     this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO,
-                                  targetNameFull,
-                                  targetNameImport, targetNamePDB,
-                                  config.c_str());
-    }
+                                           targetNameFull, targetNameImport,
+                                           targetNamePDB, config.c_str());
+  }
 
-  if(this->MSTools)
-    {
+  if (this->MSTools) {
     linkOptions.AddFlag("Version", "");
 
-    if ( this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE") )
-      {
-      if (this->GlobalGenerator->TargetsWindowsCE())
-        {
+    if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+      if (this->GlobalGenerator->TargetsWindowsCE()) {
         linkOptions.AddFlag("SubSystem", "WindowsCE");
-        if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-          {
-          if (this->ClOptions[config]->UsingUnicode())
-            {
+        if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+          if (this->ClOptions[config]->UsingUnicode()) {
             linkOptions.AddFlag("EntryPointSymbol", "wWinMainCRTStartup");
-            }
-          else
-            {
+          } else {
             linkOptions.AddFlag("EntryPointSymbol", "WinMainCRTStartup");
-            }
           }
         }
-      else
-        {
+      } else {
         linkOptions.AddFlag("SubSystem", "Windows");
-        }
       }
-    else
-      {
-      if (this->GlobalGenerator->TargetsWindowsCE())
-        {
+    } else {
+      if (this->GlobalGenerator->TargetsWindowsCE()) {
         linkOptions.AddFlag("SubSystem", "WindowsCE");
-        if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-          {
-          if (this->ClOptions[config]->UsingUnicode())
-            {
+        if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
+          if (this->ClOptions[config]->UsingUnicode()) {
             linkOptions.AddFlag("EntryPointSymbol", "mainWCRTStartup");
-            }
-          else
-            {
+          } else {
             linkOptions.AddFlag("EntryPointSymbol", "mainACRTStartup");
-            }
           }
         }
-      else
-        {
+      } else {
         linkOptions.AddFlag("SubSystem", "Console");
-        };
-      }
+      };
+    }
 
-    if(const char* stackVal =
-       this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE"))
-      {
+    if (const char* stackVal = this->Makefile->GetDefinition(
+          "CMAKE_" + linkLanguage + "_STACK_SIZE")) {
       linkOptions.AddFlag("StackReserveSize", stackVal);
-      }
+    }
 
     if (this->LocalGenerator->GetVersion() >=
-        cmGlobalVisualStudioGenerator::VS14)
-      {
+        cmGlobalVisualStudioGenerator::VS14) {
       linkOptions.AddFlag("GenerateDebugInformation", "No");
-      }
-    else
-      {
+    } else {
       linkOptions.AddFlag("GenerateDebugInformation", "false");
-      }
+    }
 
     std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str());
     pdb += "/";
     pdb += targetNamePDB;
     std::string imLib =
-        this->GeneratorTarget->GetDirectory(config.c_str(), true);
+      this->GeneratorTarget->GetDirectory(config.c_str(), true);
     imLib += "/";
     imLib += targetNameImport;
 
@@ -2649,96 +2307,79 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
 
     // A Windows Runtime component uses internal .NET metadata,
     // so does not have an import library.
-    if(this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") &&
-       this->GeneratorTarget->GetType() != cmState::EXECUTABLE)
-      {
+    if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") &&
+        this->GeneratorTarget->GetType() != cmState::EXECUTABLE) {
       linkOptions.AddFlag("GenerateWindowsMetadata", "true");
-      }
-    else if (this->GlobalGenerator->TargetsWindowsPhone() ||
-             this->GlobalGenerator->TargetsWindowsStore())
-      {
+    } else if (this->GlobalGenerator->TargetsWindowsPhone() ||
+               this->GlobalGenerator->TargetsWindowsStore()) {
       // WindowsPhone and WindowsStore components are in an app container
       // and produce WindowsMetadata.  If we are not producing a WINRT
       // component, then do not generate the metadata here.
       linkOptions.AddFlag("GenerateWindowsMetadata", "false");
-      }
+    }
 
     if (this->GlobalGenerator->TargetsWindowsPhone() &&
-        this->GlobalGenerator->GetSystemVersion() == "8.0")
-      {
+        this->GlobalGenerator->GetSystemVersion() == "8.0") {
       // WindowsPhone 8.0 does not have ole32.
       linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
-      }
     }
-  else if(this->NsightTegra)
-    {
+  } else if (this->NsightTegra) {
     linkOptions.AddFlag("SoName", targetNameSO.c_str());
-    }
+  }
 
   linkOptions.Parse(flags.c_str());
 
-  if(this->MSTools)
-    {
+  if (this->MSTools) {
     if (cmSourceFile const* defsrc =
-        this->GeneratorTarget->GetModuleDefinitionFile(""))
-      {
+          this->GeneratorTarget->GetModuleDefinitionFile("")) {
       linkOptions.AddFlag("ModuleDefinitionFile",
                           defsrc->GetFullPath().c_str());
-      }
+    }
     linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries",
                            "%(IgnoreSpecificDefaultLibraries)");
-    }
+  }
 
   if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY &&
-      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
-    {
-    if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
+      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+    if (this->GeneratorTarget->GetPropertyAsBool(
+          "WINDOWS_EXPORT_ALL_SYMBOLS")) {
       linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)exportall.def");
-      }
     }
+  }
 
   // Hack to fix flag version selection in a common use case.
   // FIXME: Select flag table based on toolset instead of VS version.
   if (this->LocalGenerator->GetVersion() >=
-      cmGlobalVisualStudioGenerator::VS14)
-    {
+      cmGlobalVisualStudioGenerator::VS14) {
     cmGlobalVisualStudio10Generator* gg =
       static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
     const char* toolset = gg->GetPlatformToolset();
-    if (toolset &&
-        (cmHasLiteralPrefix(toolset, "v100") ||
-         cmHasLiteralPrefix(toolset, "v110") ||
-         cmHasLiteralPrefix(toolset, "v120")))
-      {
-      if (const char* debug = linkOptions.GetFlag("GenerateDebugInformation"))
-        {
+    if (toolset && (cmHasLiteralPrefix(toolset, "v100") ||
+                    cmHasLiteralPrefix(toolset, "v110") ||
+                    cmHasLiteralPrefix(toolset, "v120"))) {
+      if (const char* debug =
+            linkOptions.GetFlag("GenerateDebugInformation")) {
         // Convert value from enumeration back to boolean for older toolsets.
-        if (strcmp(debug, "No") == 0)
-          {
+        if (strcmp(debug, "No") == 0) {
           linkOptions.AddFlag("GenerateDebugInformation", "false");
-          }
-        else if (strcmp(debug, "Debug") == 0)
-          {
+        } else if (strcmp(debug, "Debug") == 0) {
           linkOptions.AddFlag("GenerateDebugInformation", "true");
-          }
         }
       }
     }
+  }
 
   this->LinkOptions[config] = pOptions.release();
   return true;
 }
 
-//----------------------------------------------------------------------------
-void
-cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
+void cmVisualStudio10TargetGenerator::WriteLinkOptions(
+  std::string const& config)
 {
-  if(this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY
-     || this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY ||
+      this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) {
     return;
-    }
+  }
   Options& linkOptions = *(this->LinkOptions[config]);
   this->WriteString("<Link>\n", 2);
 
@@ -2746,50 +2387,40 @@ cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
   linkOptions.OutputFlagMap(*this->BuildFileStream, "      ");
 
   this->WriteString("</Link>\n", 2);
-  if(!this->GlobalGenerator->NeedLinkLibraryDependencies(
-              this->GeneratorTarget))
-    {
+  if (!this->GlobalGenerator->NeedLinkLibraryDependencies(
+        this->GeneratorTarget)) {
     this->WriteString("<ProjectReference>\n", 2);
     this->WriteString(
       "<LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 3);
     this->WriteString("</ProjectReference>\n", 2);
-    }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::AddLibraries(
-  cmComputeLinkInformation& cli,
-  std::vector<std::string>& libVec)
+  cmComputeLinkInformation& cli, std::vector<std::string>& libVec)
 {
   typedef cmComputeLinkInformation::ItemVector ItemVector;
   ItemVector libs = cli.GetItems();
-  for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
-    {
-    if(l->IsPath)
-      {
-      std::string path = this->LocalGenerator->
-        Convert(l->Value.c_str(),
-                cmLocalGenerator::START_OUTPUT,
-                cmLocalGenerator::UNCHANGED);
+  for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
+    if (l->IsPath) {
+      std::string path = this->LocalGenerator->Convert(
+        l->Value.c_str(), cmOutputConverter::START_OUTPUT,
+        cmOutputConverter::UNCHANGED);
       this->ConvertToWindowsSlash(path);
       libVec.push_back(path);
-      }
-    else if (!l->Target
-        || l->Target->GetType() != cmState::INTERFACE_LIBRARY)
-      {
+    } else if (!l->Target ||
+               l->Target->GetType() != cmState::INTERFACE_LIBRARY) {
       libVec.push_back(l->Value);
-      }
     }
+  }
 }
 
-
-void cmVisualStudio10TargetGenerator::
-WriteMidlOptions(std::string const& /*config*/,
-                 std::vector<std::string> const & includes)
+void cmVisualStudio10TargetGenerator::WriteMidlOptions(
+  std::string const& /*config*/, std::vector<std::string> const& includes)
 {
-  if(!this->MSTools)
-    {
+  if (!this->MSTools) {
     return;
-    }
+  }
 
   // This processes *any* of the .idl files specified in the project's file
   // list (and passed as the item metadata %(Filename) expressing the rule
@@ -2808,51 +2439,46 @@ WriteMidlOptions(std::string const& /*config*/,
   // on the CMake side?
   this->WriteString("<Midl>\n", 2);
   this->WriteString("<AdditionalIncludeDirectories>", 3);
-  for(std::vector<std::string>::const_iterator i =  includes.begin();
-      i != includes.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i = includes.begin();
+       i != includes.end(); ++i) {
     *this->BuildFileStream << cmVS10EscapeXML(*i) << ";";
-    }
+  }
   this->WriteString("%(AdditionalIncludeDirectories)"
-                    "</AdditionalIncludeDirectories>\n", 0);
+                    "</AdditionalIncludeDirectories>\n",
+                    0);
   this->WriteString("<OutputDirectory>$(ProjectDir)/$(IntDir)"
-                    "</OutputDirectory>\n", 3);
+                    "</OutputDirectory>\n",
+                    3);
   this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
-  this->WriteString(
-    "<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
-  this->WriteString(
-    "<InterfaceIdentifierFileName>"
-    "%(Filename)_i.c</InterfaceIdentifierFileName>\n", 3);
-  this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n",3);
+  this->WriteString("<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
+  this->WriteString("<InterfaceIdentifierFileName>"
+                    "%(Filename)_i.c</InterfaceIdentifierFileName>\n",
+                    3);
+  this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n", 3);
   this->WriteString("</Midl>\n", 2);
 }
 
-
 void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
 {
-  for(std::vector<std::string>::const_iterator
-        i = this->Configurations.begin();
-      i != this->Configurations.end(); ++i)
-    {
+  for (std::vector<std::string>::const_iterator i =
+         this->Configurations.begin();
+       i != this->Configurations.end(); ++i) {
     std::vector<std::string> includes;
-    this->LocalGenerator->GetIncludeDirectories(includes,
-                                                this->GeneratorTarget,
-                                                "C", i->c_str());
-    for(std::vector<std::string>::iterator ii = includes.begin();
-        ii != includes.end(); ++ii)
-      {
+    this->LocalGenerator->GetIncludeDirectories(
+      includes, this->GeneratorTarget, "C", i->c_str());
+    for (std::vector<std::string>::iterator ii = includes.begin();
+         ii != includes.end(); ++ii) {
       this->ConvertToWindowsSlash(*ii);
-      }
+    }
     this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
     *this->BuildFileStream << "\n";
     //    output cl compile flags <ClCompile></ClCompile>
-    if(this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY)
-      {
+    if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) {
       this->WriteClOptions(*i, includes);
       //    output rc compile flags <ResourceCompile></ResourceCompile>
       this->WriteRCOptions(*i, includes);
       this->WriteMasmOptions(*i, includes);
-      }
+    }
     //    output midl flags       <Midl></Midl>
     this->WriteMidlOptions(*i, includes);
     // write events
@@ -2863,126 +2489,113 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
     this->WriteLibOptions(*i);
     //    output manifest flags  <Manifest></Manifest>
     this->WriteManifestOptions(*i);
-    if(this->NsightTegra &&
-       this->GeneratorTarget->GetType() == cmState::EXECUTABLE &&
-       this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI"))
-      {
+    if (this->NsightTegra &&
+        this->GeneratorTarget->GetType() == cmState::EXECUTABLE &&
+        this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
       this->WriteAntBuildOptions(*i);
-      }
-    this->WriteString("</ItemDefinitionGroup>\n", 1);
     }
+    this->WriteString("</ItemDefinitionGroup>\n", 1);
+  }
 }
 
-void
-cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
+void cmVisualStudio10TargetGenerator::WriteEvents(
+  std::string const& configName)
 {
   bool addedPrelink = false;
   if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY &&
-      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
-    {
-    if (this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
-      {
+      this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+    if (this->GeneratorTarget->GetPropertyAsBool(
+          "WINDOWS_EXPORT_ALL_SYMBOLS")) {
       addedPrelink = true;
       std::vector<cmCustomCommand> commands =
         this->GeneratorTarget->GetPreLinkCommands();
-      this->GlobalGenerator->AddSymbolExportCommand(
-        this->GeneratorTarget, commands, configName);
+      this->GlobalGenerator->AddSymbolExportCommand(this->GeneratorTarget,
+                                                    commands, configName);
       this->WriteEvent("PreLinkEvent", commands, configName);
-      }
     }
-  if (!addedPrelink)
-    {
+  }
+  if (!addedPrelink) {
     this->WriteEvent("PreLinkEvent",
-        this->GeneratorTarget->GetPreLinkCommands(), configName);
-    }
+                     this->GeneratorTarget->GetPreLinkCommands(), configName);
+  }
   this->WriteEvent("PreBuildEvent",
-        this->GeneratorTarget->GetPreBuildCommands(), configName);
+                   this->GeneratorTarget->GetPreBuildCommands(), configName);
   this->WriteEvent("PostBuildEvent",
-        this->GeneratorTarget->GetPostBuildCommands(), configName);
+                   this->GeneratorTarget->GetPostBuildCommands(), configName);
 }
 
 void cmVisualStudio10TargetGenerator::WriteEvent(
-  const char* name,
-  std::vector<cmCustomCommand> const& commands,
+  const char* name, std::vector<cmCustomCommand> const& commands,
   std::string const& configName)
 {
-  if(commands.empty())
-    {
+  if (commands.empty()) {
     return;
-    }
+  }
   this->WriteString("<", 2);
-  (*this->BuildFileStream ) << name << ">\n";
+  (*this->BuildFileStream) << name << ">\n";
   cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
   std::string script;
   const char* pre = "";
   std::string comment;
-  for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
-      i != commands.end(); ++i)
-    {
+  for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
+       i != commands.end(); ++i) {
     cmCustomCommandGenerator ccg(*i, configName, this->LocalGenerator);
     comment += pre;
     comment += lg->ConstructComment(ccg);
     script += pre;
     pre = "\n";
     script += cmVS10EscapeXML(lg->ConstructScript(ccg));
-    }
+  }
   comment = cmVS10EscapeComment(comment);
-  this->WriteString("<Message>",3);
-  (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
+  this->WriteString("<Message>", 3);
+  (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
   this->WriteString("<Command>", 3);
-  (*this->BuildFileStream ) << script;
-  (*this->BuildFileStream ) << "</Command>" << "\n";
+  (*this->BuildFileStream) << script;
+  (*this->BuildFileStream) << "</Command>"
+                           << "\n";
   this->WriteString("</", 2);
-  (*this->BuildFileStream ) << name << ">\n";
+  (*this->BuildFileStream) << name << ">\n";
 }
 
-
 void cmVisualStudio10TargetGenerator::WriteProjectReferences()
 {
-  cmGlobalGenerator::TargetDependSet const& unordered
-    = this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
+  cmGlobalGenerator::TargetDependSet const& unordered =
+    this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
   typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
     OrderedTargetDependSet;
   OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET);
   this->WriteString("<ItemGroup>\n", 1);
-  for( OrderedTargetDependSet::const_iterator i = depends.begin();
-       i != depends.end(); ++i)
-    {
+  for (OrderedTargetDependSet::const_iterator i = depends.begin();
+       i != depends.end(); ++i) {
     cmGeneratorTarget const* dt = *i;
-    if(dt->GetType() == cmState::INTERFACE_LIBRARY)
-      {
+    if (dt->GetType() == cmState::INTERFACE_LIBRARY) {
       continue;
-      }
+    }
     // skip fortran targets as they can not be processed by MSBuild
     // the only reference will be in the .sln file
-    if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
-       ->TargetIsFortranOnly(dt))
-      {
+    if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
+          ->TargetIsFortranOnly(dt)) {
       continue;
-      }
+    }
     this->WriteString("<ProjectReference Include=\"", 2);
     cmLocalGenerator* lg = dt->GetLocalGenerator();
     std::string name = dt->GetName();
     std::string path;
     const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
-    if(p)
-      {
+    if (p) {
       path = p;
-      }
-    else
-      {
-      path =  lg->GetCurrentBinaryDirectory();
+    } else {
+      path = lg->GetCurrentBinaryDirectory();
       path += "/";
       path += dt->GetName();
       path += ".vcxproj";
-      }
+    }
     (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n";
     this->WriteString("<Project>", 3);
-    (*this->BuildFileStream)
-      << this->GlobalGenerator->GetGUID(name.c_str())
-      << "</Project>\n";
+    (*this->BuildFileStream) << this->GlobalGenerator->GetGUID(name.c_str())
+                             << "</Project>\n";
     this->WriteString("</ProjectReference>\n", 2);
-    }
+  }
   this->WriteString("</ItemGroup>\n", 1);
 }
 
@@ -2990,55 +2603,49 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions()
 {
   // This only applies to Windows 10 apps
   if (this->GlobalGenerator->TargetsWindowsStore() &&
-      cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0"))
-    {
+      cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) {
     const char* desktopExtensionsVersion =
       this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
-    if (desktopExtensionsVersion)
-      {
+    if (desktopExtensionsVersion) {
       this->WriteSinglePlatformExtension("WindowsDesktop",
                                          desktopExtensionsVersion);
-      }
+    }
     const char* mobileExtensionsVersion =
       this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION");
-    if (mobileExtensionsVersion)
-      {
+    if (mobileExtensionsVersion) {
       this->WriteSinglePlatformExtension("WindowsMobile",
                                          mobileExtensionsVersion);
-      }
     }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension(
-  std::string const& extension,
-  std::string const& version
-  )
+  std::string const& extension, std::string const& version)
 {
   this->WriteString("<Import Project=", 2);
   (*this->BuildFileStream)
     << "\"$([Microsoft.Build.Utilities.ToolLocationHelper]"
-    << "::GetPlatformExtensionSDKLocation(`"
-    << extension <<", Version=" << version
+    << "::GetPlatformExtensionSDKLocation(`" << extension
+    << ", Version=" << version
     << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
     << "$(ExtensionSDKDirectoryRoot), null))"
-    << "\\DesignTime\\CommonConfiguration\\Neutral\\"
-    << extension << ".props\" "
+    << "\\DesignTime\\CommonConfiguration\\Neutral\\" << extension
+    << ".props\" "
     << "Condition=\"exists('$("
     << "[Microsoft.Build.Utilities.ToolLocationHelper]"
-    << "::GetPlatformExtensionSDKLocation(`"
-    << extension << ", Version=" << version
+    << "::GetPlatformExtensionSDKLocation(`" << extension
+    << ", Version=" << version
     << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
     << "$(ExtensionSDKDirectoryRoot), null))"
-    << "\\DesignTime\\CommonConfiguration\\Neutral\\"
-    << extension << ".props')\" />\n";
+    << "\\DesignTime\\CommonConfiguration\\Neutral\\" << extension
+    << ".props')\" />\n";
 }
 
 void cmVisualStudio10TargetGenerator::WriteSDKReferences()
 {
   // This only applies to Windows 10 apps
   if (this->GlobalGenerator->TargetsWindowsStore() &&
-      cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0"))
-    {
+      cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) {
     const char* desktopExtensionsVersion =
       this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
     const char* mobileExtensionsVersion =
@@ -3046,129 +2653,115 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences()
     const char* iotExtensionsVersion =
       this->GeneratorTarget->GetProperty("VS_IOT_EXTENSIONS_VERSION");
 
-    if(desktopExtensionsVersion || mobileExtensionsVersion ||
-       iotExtensionsVersion)
-      {
+    if (desktopExtensionsVersion || mobileExtensionsVersion ||
+        iotExtensionsVersion) {
       this->WriteString("<ItemGroup>\n", 1);
-      if(desktopExtensionsVersion)
-        {
+      if (desktopExtensionsVersion) {
         this->WriteSingleSDKReference("WindowsDesktop",
                                       desktopExtensionsVersion);
-        }
-      if(mobileExtensionsVersion)
-        {
+      }
+      if (mobileExtensionsVersion) {
         this->WriteSingleSDKReference("WindowsMobile",
                                       mobileExtensionsVersion);
-        }
-      if(iotExtensionsVersion)
-        {
-        this->WriteSingleSDKReference("WindowsIoT",
-                                      iotExtensionsVersion);
-        }
-      this->WriteString("</ItemGroup>\n", 1);
       }
+      if (iotExtensionsVersion) {
+        this->WriteSingleSDKReference("WindowsIoT", iotExtensionsVersion);
+      }
+      this->WriteString("</ItemGroup>\n", 1);
     }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteSingleSDKReference(
-  std::string const& extension,
-  std::string const& version
-  )
+  std::string const& extension, std::string const& version)
 {
   this->WriteString("<SDKReference Include=\"", 2);
-  (*this->BuildFileStream) << extension
-    << ", Version=" << version << "\" />\n";
+  (*this->BuildFileStream) << extension << ", Version=" << version
+                           << "\" />\n";
 }
 
-
 void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
 {
-  if((this->GlobalGenerator->TargetsWindowsStore() ||
-      this->GlobalGenerator->TargetsWindowsPhone())
-      && (cmState::EXECUTABLE == this->GeneratorTarget->GetType()))
-    {
+  if ((this->GlobalGenerator->TargetsWindowsStore() ||
+       this->GlobalGenerator->TargetsWindowsPhone()) &&
+      (cmState::EXECUTABLE == this->GeneratorTarget->GetType())) {
     std::string pfxFile;
     std::vector<cmSourceFile const*> certificates;
     this->GeneratorTarget->GetCertificates(certificates, "");
-    for(std::vector<cmSourceFile const*>::const_iterator si =
-        certificates.begin(); si != certificates.end(); ++si)
-      {
+    for (std::vector<cmSourceFile const*>::const_iterator si =
+           certificates.begin();
+         si != certificates.end(); ++si) {
       pfxFile = this->ConvertPath((*si)->GetFullPath(), false);
       this->ConvertToWindowsSlash(pfxFile);
       break;
-      }
+    }
 
-    if(this->IsMissingFiles &&
-       !(this->GlobalGenerator->TargetsWindowsPhone() &&
-         this->GlobalGenerator->GetSystemVersion() == "8.0"))
-      {
+    if (this->IsMissingFiles &&
+        !(this->GlobalGenerator->TargetsWindowsPhone() &&
+          this->GlobalGenerator->GetSystemVersion() == "8.0")) {
       // Move the manifest to a project directory to avoid clashes
       std::string artifactDir =
         this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
       this->ConvertToWindowsSlash(artifactDir);
       this->WriteString("<PropertyGroup>\n", 1);
       this->WriteString("<AppxPackageArtifactsDir>", 2);
-      (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) <<
-        "\\</AppxPackageArtifactsDir>\n";
+      (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir)
+                               << "\\</AppxPackageArtifactsDir>\n";
       this->WriteString("<ProjectPriFullPath>"
-        "$(TargetDir)resources.pri</ProjectPriFullPath>\n", 2);
+                        "$(TargetDir)resources.pri</ProjectPriFullPath>\n",
+                        2);
 
       // If we are missing files and we don't have a certificate and
       // aren't targeting WP8.0, add a default certificate
-      if(pfxFile.empty())
-        {
-        std::string templateFolder = cmSystemTools::GetCMakeRoot() +
-                                     "/Templates/Windows";
+      if (pfxFile.empty()) {
+        std::string templateFolder =
+          cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
         pfxFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
         cmSystemTools::CopyAFile(templateFolder + "/Windows_TemporaryKey.pfx",
                                  pfxFile, false);
         this->ConvertToWindowsSlash(pfxFile);
         this->AddedFiles.push_back(pfxFile);
-        }
+      }
 
       this->WriteString("<", 2);
-      (*this->BuildFileStream) << "PackageCertificateKeyFile>"
-        << pfxFile << "</PackageCertificateKeyFile>\n";
+      (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile
+                               << "</PackageCertificateKeyFile>\n";
       std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
-      if (!thumb.empty())
-        {
+      if (!thumb.empty()) {
         this->WriteString("<PackageCertificateThumbprint>", 2);
         (*this->BuildFileStream) << thumb
-          << "</PackageCertificateThumbprint>\n";
-        }
-      this->WriteString("</PropertyGroup>\n", 1);
+                                 << "</PackageCertificateThumbprint>\n";
       }
-    else if(!pfxFile.empty())
-      {
+      this->WriteString("</PropertyGroup>\n", 1);
+    } else if (!pfxFile.empty()) {
       this->WriteString("<PropertyGroup>\n", 1);
       this->WriteString("<", 2);
-      (*this->BuildFileStream) << "PackageCertificateKeyFile>"
-        << pfxFile << "</PackageCertificateKeyFile>\n";
+      (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile
+                               << "</PackageCertificateKeyFile>\n";
       std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
-      if (!thumb.empty())
-        {
+      if (!thumb.empty()) {
         this->WriteString("<PackageCertificateThumbprint>", 2);
         (*this->BuildFileStream) << thumb
-          << "</PackageCertificateThumbprint>\n";
-        }
-      this->WriteString("</PropertyGroup>\n", 1);
+                                 << "</PackageCertificateThumbprint>\n";
       }
+      this->WriteString("</PropertyGroup>\n", 1);
     }
+  }
 }
 
-bool cmVisualStudio10TargetGenerator::
-  IsResxHeader(const std::string& headerFile)
+bool cmVisualStudio10TargetGenerator::IsResxHeader(
+  const std::string& headerFile)
 {
   std::set<std::string> expectedResxHeaders;
   this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, "");
 
   std::set<std::string>::const_iterator it =
-                                        expectedResxHeaders.find(headerFile);
+    expectedResxHeaders.find(headerFile);
   return it != expectedResxHeaders.end();
 }
 
-bool cmVisualStudio10TargetGenerator::
-IsXamlHeader(const std::string& headerFile)
+bool cmVisualStudio10TargetGenerator::IsXamlHeader(
+  const std::string& headerFile)
 {
   std::set<std::string> expectedXamlHeaders;
   this->GeneratorTarget->GetExpectedXamlHeaders(expectedXamlHeaders, "");
@@ -3178,8 +2771,8 @@ IsXamlHeader(const std::string& headerFile)
   return it != expectedXamlHeaders.end();
 }
 
-bool cmVisualStudio10TargetGenerator::
-IsXamlSource(const std::string& sourceFile)
+bool cmVisualStudio10TargetGenerator::IsXamlSource(
+  const std::string& sourceFile)
 {
   std::set<std::string> expectedXamlSources;
   this->GeneratorTarget->GetExpectedXamlSources(expectedXamlSources, "");
@@ -3197,223 +2790,185 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
   bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone();
   bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
   std::string const& v = this->GlobalGenerator->GetSystemVersion();
-  if(isWindowsPhone || isWindowsStore)
-    {
+  if (isWindowsPhone || isWindowsStore) {
     this->WriteString("<ApplicationType>", 2);
-    (*this->BuildFileStream) << (isWindowsPhone ?
-                                 "Windows Phone" : "Windows Store")
-                             << "</ApplicationType>\n";
+    (*this->BuildFileStream)
+      << (isWindowsPhone ? "Windows Phone" : "Windows Store")
+      << "</ApplicationType>\n";
     this->WriteString("<DefaultLanguage>en-US"
-                      "</DefaultLanguage>\n", 2);
-    if (cmHasLiteralPrefix(v, "10.0"))
-      {
+                      "</DefaultLanguage>\n",
+                      2);
+    if (cmHasLiteralPrefix(v, "10.0")) {
       this->WriteString("<ApplicationTypeRevision>", 2);
       (*this->BuildFileStream) << cmVS10EscapeXML("10.0")
                                << "</ApplicationTypeRevision>\n";
       // Visual Studio 14.0 is necessary for building 10.0 apps
       this->WriteString("<MinimumVisualStudioVersion>14.0"
-        "</MinimumVisualStudioVersion>\n", 2);
+                        "</MinimumVisualStudioVersion>\n",
+                        2);
 
-      if(this->GeneratorTarget->GetType() < cmState::UTILITY)
-        {
+      if (this->GeneratorTarget->GetType() < cmState::UTILITY) {
         isAppContainer = true;
-        }
       }
-    else if(v == "8.1")
-      {
+    } else if (v == "8.1") {
       this->WriteString("<ApplicationTypeRevision>", 2);
       (*this->BuildFileStream) << cmVS10EscapeXML(v)
                                << "</ApplicationTypeRevision>\n";
       // Visual Studio 12.0 is necessary for building 8.1 apps
       this->WriteString("<MinimumVisualStudioVersion>12.0"
-                        "</MinimumVisualStudioVersion>\n", 2);
+                        "</MinimumVisualStudioVersion>\n",
+                        2);
 
-      if (this->GeneratorTarget->GetType() < cmState::UTILITY)
-        {
+      if (this->GeneratorTarget->GetType() < cmState::UTILITY) {
         isAppContainer = true;
-        }
       }
-    else if (v == "8.0")
-      {
+    } else if (v == "8.0") {
       this->WriteString("<ApplicationTypeRevision>", 2);
       (*this->BuildFileStream) << cmVS10EscapeXML(v)
                                << "</ApplicationTypeRevision>\n";
       // Visual Studio 11.0 is necessary for building 8.0 apps
       this->WriteString("<MinimumVisualStudioVersion>11.0"
-                        "</MinimumVisualStudioVersion>\n", 2);
+                        "</MinimumVisualStudioVersion>\n",
+                        2);
 
-      if (isWindowsStore
-          && this->GeneratorTarget->GetType() < cmState::UTILITY)
-        {
+      if (isWindowsStore &&
+          this->GeneratorTarget->GetType() < cmState::UTILITY) {
         isAppContainer = true;
-        }
-      else if (isWindowsPhone &&
-               this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-        {
+      } else if (isWindowsPhone &&
+                 this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
         this->WriteString("<XapOutputs>true</XapOutputs>\n", 2);
         this->WriteString("<XapFilename>", 2);
-        (*this->BuildFileStream) << cmVS10EscapeXML(this->Name.c_str()) <<
-           "_$(Configuration)_$(Platform).xap</XapFilename>\n";
-        }
+        (*this->BuildFileStream)
+          << cmVS10EscapeXML(this->Name.c_str())
+          << "_$(Configuration)_$(Platform).xap</XapFilename>\n";
       }
     }
-  if(isAppContainer)
-    {
+  }
+  if (isAppContainer) {
     this->WriteString("<AppContainerApplication>true"
-                      "</AppContainerApplication>\n", 2);
-    }
-  else if (this->Platform == "ARM")
-    {
+                      "</AppContainerApplication>\n",
+                      2);
+  } else if (this->Platform == "ARM") {
     this->WriteString("<WindowsSDKDesktopARMSupport>true"
-                      "</WindowsSDKDesktopARMSupport>\n", 2);
-    }
+                      "</WindowsSDKDesktopARMSupport>\n",
+                      2);
+  }
   std::string const& targetPlatformVersion =
     gg->GetWindowsTargetPlatformVersion();
-  if (!targetPlatformVersion.empty())
-    {
+  if (!targetPlatformVersion.empty()) {
     this->WriteString("<WindowsTargetPlatformVersion>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) <<
-      "</WindowsTargetPlatformVersion>\n";
-    }
-  const char* targetPlatformMinVersion =
-      this->GeneratorTarget
-      ->GetProperty("VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
-  if(targetPlatformMinVersion)
-    {
+    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion)
+                             << "</WindowsTargetPlatformVersion>\n";
+  }
+  const char* targetPlatformMinVersion = this->GeneratorTarget->GetProperty(
+    "VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
+  if (targetPlatformMinVersion) {
     this->WriteString("<WindowsTargetPlatformMinVersion>", 2);
-    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformMinVersion) <<
-      "</WindowsTargetPlatformMinVersion>\n";
-    }
-  else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0"))
-    {
+    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformMinVersion)
+                             << "</WindowsTargetPlatformMinVersion>\n";
+  } else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0")) {
     // If the min version is not set, then use the TargetPlatformVersion
-    if (!targetPlatformVersion.empty())
-      {
+    if (!targetPlatformVersion.empty()) {
       this->WriteString("<WindowsTargetPlatformMinVersion>", 2);
-      (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) <<
-        "</WindowsTargetPlatformMinVersion>\n";
-      }
+      (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion)
+                               << "</WindowsTargetPlatformMinVersion>\n";
     }
+  }
 
   // Added IoT Startup Task support
-  if(this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK"))
-    {
+  if (this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) {
     this->WriteString("<ContainsStartupTask>true</ContainsStartupTask>\n", 2);
-    }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
 {
   // For Windows and Windows Phone executables, we will assume that if a
   // manifest is not present that we need to add all the necessary files
-  if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE)
-    {
+  if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) {
     std::vector<cmSourceFile const*> manifestSources;
     this->GeneratorTarget->GetAppManifest(manifestSources, "");
-      {
+    {
       std::string const& v = this->GlobalGenerator->GetSystemVersion();
-      if(this->GlobalGenerator->TargetsWindowsPhone())
-        {
-        if (v == "8.0")
-          {
+      if (this->GlobalGenerator->TargetsWindowsPhone()) {
+        if (v == "8.0") {
           // Look through the sources for WMAppManifest.xml
           std::vector<cmSourceFile const*> extraSources;
           this->GeneratorTarget->GetExtraSources(extraSources, "");
           bool foundManifest = false;
-          for(std::vector<cmSourceFile const*>::const_iterator si =
-            extraSources.begin(); si != extraSources.end(); ++si)
-            {
+          for (std::vector<cmSourceFile const*>::const_iterator si =
+                 extraSources.begin();
+               si != extraSources.end(); ++si) {
             // Need to do a lowercase comparison on the filename
-            if("wmappmanifest.xml" == cmSystemTools::LowerCase(
-              (*si)->GetLocation().GetName()))
-              {
+            if ("wmappmanifest.xml" ==
+                cmSystemTools::LowerCase((*si)->GetLocation().GetName())) {
               foundManifest = true;
               break;
-              }
             }
-          if (!foundManifest)
-            {
+          }
+          if (!foundManifest) {
             this->IsMissingFiles = true;
-            }
           }
-        else if (v == "8.1")
-          {
-          if(manifestSources.empty())
-            {
+        } else if (v == "8.1") {
+          if (manifestSources.empty()) {
             this->IsMissingFiles = true;
-            }
           }
         }
-      else if (this->GlobalGenerator->TargetsWindowsStore())
-        {
-        if (manifestSources.empty())
-          {
-          if (v == "8.0")
-            {
+      } else if (this->GlobalGenerator->TargetsWindowsStore()) {
+        if (manifestSources.empty()) {
+          if (v == "8.0") {
             this->IsMissingFiles = true;
-            }
-          else if (v == "8.1" || cmHasLiteralPrefix(v, "10.0"))
-            {
+          } else if (v == "8.1" || cmHasLiteralPrefix(v, "10.0")) {
             this->IsMissingFiles = true;
-            }
           }
         }
       }
     }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteMissingFiles()
 {
   std::string const& v = this->GlobalGenerator->GetSystemVersion();
-  if(this->GlobalGenerator->TargetsWindowsPhone())
-    {
-    if (v == "8.0")
-      {
+  if (this->GlobalGenerator->TargetsWindowsPhone()) {
+    if (v == "8.0") {
       this->WriteMissingFilesWP80();
-      }
-    else if (v == "8.1")
-      {
+    } else if (v == "8.1") {
       this->WriteMissingFilesWP81();
-      }
     }
-  else if (this->GlobalGenerator->TargetsWindowsStore())
-   {
-   if (v == "8.0")
-     {
-     this->WriteMissingFilesWS80();
-     }
-   else if (v == "8.1")
-     {
-     this->WriteMissingFilesWS81();
-     }
-   else if (cmHasLiteralPrefix(v, "10.0"))
-     {
-     this->WriteMissingFilesWS10_0();
-     }
-   }
+  } else if (this->GlobalGenerator->TargetsWindowsStore()) {
+    if (v == "8.0") {
+      this->WriteMissingFilesWS80();
+    } else if (v == "8.1") {
+      this->WriteMissingFilesWS81();
+    } else if (cmHasLiteralPrefix(v, "10.0")) {
+      this->WriteMissingFilesWS10_0();
+    }
+  }
 }
 
 void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
 {
-  std::string templateFolder = cmSystemTools::GetCMakeRoot() +
-                               "/Templates/Windows";
+  std::string templateFolder =
+    cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
 
   // For WP80, the manifest needs to be in the same folder as the project
   // this can cause an overwrite problem if projects aren't organized in
   // folders
   std::string manifestFile =
-      this->LocalGenerator->GetCurrentBinaryDirectory() +
-                             std::string("/WMAppManifest.xml");
+    this->LocalGenerator->GetCurrentBinaryDirectory() +
+    std::string("/WMAppManifest.xml");
   std::string artifactDir =
     this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   this->ConvertToWindowsSlash(artifactDir);
   std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
   std::string targetNameXML =
-      cmVS10EscapeXML(this->GeneratorTarget->GetName());
+    cmVS10EscapeXML(this->GeneratorTarget->GetName());
 
   cmGeneratedFileStream fout(manifestFile.c_str());
   fout.SetCopyIfDifferent(true);
 
+  /* clang-format off */
   fout <<
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
     "<Deployment"
@@ -3449,6 +3004,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
     "\t\t</ScreenResolutions>\n"
     "\t</App>\n"
     "</Deployment>\n";
+  /* clang-format on */
 
   std::string sourceFile = this->ConvertPath(manifestFile, false);
   this->ConvertToWindowsSlash(sourceFile);
@@ -3459,16 +3015,15 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
   this->AddedFiles.push_back(sourceFile);
 
   std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
-  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png",
-                           smallLogo, false);
+  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo,
+                           false);
   this->ConvertToWindowsSlash(smallLogo);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
   this->AddedFiles.push_back(smallLogo);
 
   std::string logo = this->DefaultArtifactDir + "/Logo.png";
-  cmSystemTools::CopyAFile(templateFolder + "/Logo.png",
-                           logo, false);
+  cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false);
   this->ConvertToWindowsSlash(logo);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n";
@@ -3493,11 +3048,12 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81()
   this->ConvertToWindowsSlash(artifactDir);
   std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
   std::string targetNameXML =
-      cmVS10EscapeXML(this->GeneratorTarget->GetName());
+    cmVS10EscapeXML(this->GeneratorTarget->GetName());
 
   cmGeneratedFileStream fout(manifestFile.c_str());
   fout.SetCopyIfDifferent(true);
 
+  /* clang-format off */
   fout <<
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
     "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\""
@@ -3541,6 +3097,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81()
     "\t\t</Application>\n"
     "\t</Applications>\n"
     "</Package>\n";
+  /* clang-format on */
 
   this->WriteCommonMissingFiles(manifestFile);
 }
@@ -3554,11 +3111,12 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
   this->ConvertToWindowsSlash(artifactDir);
   std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
   std::string targetNameXML =
-      cmVS10EscapeXML(this->GeneratorTarget->GetName());
+    cmVS10EscapeXML(this->GeneratorTarget->GetName());
 
   cmGeneratedFileStream fout(manifestFile.c_str());
   fout.SetCopyIfDifferent(true);
 
+  /* clang-format off */
   fout <<
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
     "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\">\n"
@@ -3594,6 +3152,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
     "\t\t</Application>\n"
     "\t</Applications>\n"
     "</Package>\n";
+  /* clang-format on */
 
   this->WriteCommonMissingFiles(manifestFile);
 }
@@ -3607,11 +3166,12 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
   this->ConvertToWindowsSlash(artifactDir);
   std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
   std::string targetNameXML =
-      cmVS10EscapeXML(this->GeneratorTarget->GetName());
+    cmVS10EscapeXML(this->GeneratorTarget->GetName());
 
   cmGeneratedFileStream fout(manifestFile.c_str());
   fout.SetCopyIfDifferent(true);
 
+  /* clang-format off */
   fout <<
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
     "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\""
@@ -3652,6 +3212,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
     "\t\t</Application>\n"
     "\t</Applications>\n"
     "</Package>\n";
+  /* clang-format on */
 
   this->WriteCommonMissingFiles(manifestFile);
 }
@@ -3665,11 +3226,12 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0()
   this->ConvertToWindowsSlash(artifactDir);
   std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
   std::string targetNameXML =
-      cmVS10EscapeXML(this->GeneratorTarget->GetName());
+    cmVS10EscapeXML(this->GeneratorTarget->GetName());
 
   cmGeneratedFileStream fout(manifestFile.c_str());
   fout.SetCopyIfDifferent(true);
 
+  /* clang-format off */
   fout <<
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
     "<Package\n\t"
@@ -3711,16 +3273,16 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0()
     "\t\t</Application>\n"
     "\t</Applications>\n"
     "</Package>\n";
+  /* clang-format on */
 
   this->WriteCommonMissingFiles(manifestFile);
 }
 
-void
-cmVisualStudio10TargetGenerator
-::WriteCommonMissingFiles(const std::string& manifestFile)
+void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles(
+  const std::string& manifestFile)
 {
-  std::string templateFolder = cmSystemTools::GetCMakeRoot() +
-                               "/Templates/Windows";
+  std::string templateFolder =
+    cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
 
   std::string sourceFile = this->ConvertPath(manifestFile, false);
   this->ConvertToWindowsSlash(sourceFile);
@@ -3731,40 +3293,39 @@ cmVisualStudio10TargetGenerator
   this->AddedFiles.push_back(sourceFile);
 
   std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
-  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png",
-                           smallLogo, false);
+  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo,
+                           false);
   this->ConvertToWindowsSlash(smallLogo);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
   this->AddedFiles.push_back(smallLogo);
 
   std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png";
-  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png",
-                           smallLogo44, false);
+  cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", smallLogo44,
+                           false);
   this->ConvertToWindowsSlash(smallLogo44);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo44) << "\" />\n";
   this->AddedFiles.push_back(smallLogo44);
 
   std::string logo = this->DefaultArtifactDir + "/Logo.png";
-  cmSystemTools::CopyAFile(templateFolder + "/Logo.png",
-                           logo, false);
+  cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false);
   this->ConvertToWindowsSlash(logo);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n";
   this->AddedFiles.push_back(logo);
 
   std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png";
-  cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png",
-                           storeLogo, false);
+  cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png", storeLogo,
+                           false);
   this->ConvertToWindowsSlash(storeLogo);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(storeLogo) << "\" />\n";
   this->AddedFiles.push_back(storeLogo);
 
   std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png";
-  cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png",
-                           splashScreen, false);
+  cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png", splashScreen,
+                           false);
   this->ConvertToWindowsSlash(splashScreen);
   this->WriteString("<Image Include=\"", 2);
   (*this->BuildFileStream) << cmVS10EscapeXML(splashScreen) << "\" />\n";
@@ -3779,22 +3340,19 @@ cmVisualStudio10TargetGenerator
 
 bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const
 {
-  HANDLE h = CreateFileW(
-    cmSystemTools::ConvertToWindowsExtendedPath(source).c_str(),
-    FILE_WRITE_ATTRIBUTES,
-    FILE_SHARE_WRITE, 0, OPEN_EXISTING,
-    FILE_FLAG_BACKUP_SEMANTICS, 0);
-  if (!h)
-    {
+  HANDLE h =
+    CreateFileW(cmSystemTools::ConvertToWindowsExtendedPath(source).c_str(),
+                FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, OPEN_EXISTING,
+                FILE_FLAG_BACKUP_SEMANTICS, 0);
+  if (!h) {
     return false;
-    }
+  }
 
   FILETIME const ftime_20010101 = { 3365781504u, 29389701u };
-  if (!SetFileTime(h, &ftime_20010101, &ftime_20010101, &ftime_20010101))
-    {
+  if (!SetFileTime(h, &ftime_20010101, &ftime_20010101, &ftime_20010101)) {
     CloseHandle(h);
     return false;
-    }
+  }
 
   CloseHandle(h);
   return true;
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 044e0dd..109a100 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -11,6 +11,7 @@
 ============================================================================*/
 #ifndef cmVisualStudioTargetGenerator_h
 #define cmVisualStudioTargetGenerator_h
+
 #include "cmStandardIncludes.h"
 
 class cmMakefile;
@@ -33,14 +34,9 @@ public:
   ~cmVisualStudio10TargetGenerator();
   void Generate();
   // used by cmVisualStudioGeneratorOptions
-  void WritePlatformConfigTag(
-    const char* tag,
-    const std::string& config,
-    int indentLevel,
-    const char* attribute = 0,
-    const char* end = 0,
-    std::ostream* strm = 0
-    );
+  void WritePlatformConfigTag(const char* tag, const std::string& config,
+                              int indentLevel, const char* attribute = 0,
+                              const char* end = 0, std::ostream* strm = 0);
 
 private:
   struct ToolSource
@@ -48,7 +44,9 @@ private:
     cmSourceFile const* SourceFile;
     bool RelativePath;
   };
-  struct ToolSources: public std::vector<ToolSource> {};
+  struct ToolSources : public std::vector<ToolSource>
+  {
+  };
 
   std::string ConvertPath(std::string const& path, bool forceRelative);
   void ConvertToWindowsSlash(std::string& s);
@@ -90,11 +88,11 @@ private:
   bool ComputeClOptions();
   bool ComputeClOptions(std::string const& configName);
   void WriteClOptions(std::string const& config,
-                      std::vector<std::string> const & includes);
+                      std::vector<std::string> const& includes);
   bool ComputeRcOptions();
   bool ComputeRcOptions(std::string const& config);
   void WriteRCOptions(std::string const& config,
-                      std::vector<std::string> const & includes);
+                      std::vector<std::string> const& includes);
   bool ComputeMasmOptions();
   bool ComputeMasmOptions(std::string const& config);
   void WriteMasmOptions(std::string const& config,
@@ -103,11 +101,11 @@ private:
   bool ComputeLinkOptions(std::string const& config);
   void WriteLinkOptions(std::string const& config);
   void WriteMidlOptions(std::string const& config,
-                        std::vector<std::string> const & includes);
+                        std::vector<std::string> const& includes);
   void WriteAntBuildOptions(std::string const& config);
   void OutputLinkIncremental(std::string const& configName);
   void WriteCustomRule(cmSourceFile const* source,
-                       cmCustomCommand const & command);
+                       cmCustomCommand const& command);
   void WriteCustomCommands();
   void WriteCustomCommand(cmSourceFile const* sf);
   void WriteGroups();
@@ -123,7 +121,7 @@ private:
                   std::vector<cmCustomCommand> const& commands,
                   std::string const& configName);
   void WriteGroupSources(const char* name, ToolSources const& sources,
-                         std::vector<cmSourceGroup>& );
+                         std::vector<cmSourceGroup>&);
   void AddMissingSourceGroups(std::set<cmSourceGroup*>& groupsUsed,
                               const std::vector<cmSourceGroup>& allGroups);
   bool IsResxHeader(const std::string& headerFile);
@@ -154,7 +152,7 @@ private:
   std::string Name;
   bool MSTools;
   bool NsightTegra;
-  int  NsightTegraVersion[4];
+  int NsightTegraVersion[4];
   bool TargetCompileAsWinRT;
   cmGlobalVisualStudio10Generator* GlobalGenerator;
   cmGeneratedFileStream* BuildFileStream;
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index bd4eb69..3b31d7b 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -1,10 +1,11 @@
 #include "cmVisualStudioGeneratorOptions.h"
+
 #include "cmOutputConverter.h"
 #include "cmSystemTools.h"
 #include "cmVisualStudio10TargetGenerator.h"
 
-static
-std::string cmVisualStudio10GeneratorOptionsEscapeForXML(std::string ret)
+static std::string cmVisualStudio10GeneratorOptionsEscapeForXML(
+  std::string ret)
 {
   cmSystemTools::ReplaceString(ret, ";", "%3B");
   cmSystemTools::ReplaceString(ret, "&", "&");
@@ -13,8 +14,7 @@ std::string cmVisualStudio10GeneratorOptionsEscapeForXML(std::string ret)
   return ret;
 }
 
-static
-std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
+static std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
 {
   cmSystemTools::ReplaceString(ret, "&", "&");
   cmSystemTools::ReplaceString(ret, "\"", """);
@@ -24,14 +24,14 @@ std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
   return ret;
 }
 
-//----------------------------------------------------------------------------
-cmVisualStudioGeneratorOptions
-::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
-                                 Tool tool,
-                                 cmVisualStudio10TargetGenerator* g):
-  cmIDEOptions(),
-  LocalGenerator(lg), Version(lg->GetVersion()), CurrentTool(tool),
-  TargetGenerator(g)
+cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
+  cmLocalVisualStudioGenerator* lg, Tool tool,
+  cmVisualStudio10TargetGenerator* g)
+  : cmIDEOptions()
+  , LocalGenerator(lg)
+  , Version(lg->GetVersion())
+  , CurrentTool(tool)
+  , TargetGenerator(g)
 {
   // Preprocessor definitions are not allowed for linker tools.
   this->AllowDefine = (tool != Linker);
@@ -44,16 +44,14 @@ cmVisualStudioGeneratorOptions
   this->FortranRuntimeMT = false;
 }
 
-//----------------------------------------------------------------------------
-cmVisualStudioGeneratorOptions
-::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
-                                 Tool tool,
-                                 cmVS7FlagTable const* table,
-                                 cmVS7FlagTable const* extraTable,
-                                 cmVisualStudio10TargetGenerator* g):
-  cmIDEOptions(),
-  LocalGenerator(lg), Version(lg->GetVersion()), CurrentTool(tool),
-  TargetGenerator(g)
+cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
+  cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table,
+  cmVS7FlagTable const* extraTable, cmVisualStudio10TargetGenerator* g)
+  : cmIDEOptions()
+  , LocalGenerator(lg)
+  , Version(lg->GetVersion())
+  , CurrentTool(tool)
+  , TargetGenerator(g)
 {
   // Store the given flag tables.
   this->AddTable(table);
@@ -70,23 +68,18 @@ cmVisualStudioGeneratorOptions
   this->FortranRuntimeMT = false;
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table)
 {
-  if(table)
-    {
-    for(int i=0; i < FlagTableCount; ++i)
-      {
-      if (!this->FlagTable[i])
-        {
+  if (table) {
+    for (int i = 0; i < FlagTableCount; ++i) {
+      if (!this->FlagTable[i]) {
         this->FlagTable[i] = table;
         break;
-        }
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
 {
   // Exception handling is on by default because the platform file has
@@ -94,8 +87,7 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
   // initialization to off, but the user has the option of removing
   // the flag to disable exception handling.  When the user does
   // remove the flag we need to override the IDE default of on.
-  switch (this->Version)
-    {
+  switch (this->Version) {
     case cmGlobalVisualStudioGenerator::VS7:
     case cmGlobalVisualStudioGenerator::VS71:
       this->FlagMap["ExceptionHandling"] = "FALSE";
@@ -112,11 +104,10 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
       break;
     default:
       this->FlagMap["ExceptionHandling"] = "0";
-    break;
-    }
+      break;
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose)
 {
   // If verbose makefiles have been requested and the /nologo option
@@ -128,12 +119,11 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose)
   // an empty string, instead of "FALSE", in order to avoid a warning:
   //   "cl ... warning D9035: option 'nologo-' has been deprecated"
   //
-  if(verbose &&
-     this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end())
-    {
+  if (verbose &&
+      this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end()) {
     this->FlagMap["SuppressStartupBanner"] =
       this->Version < cmGlobalVisualStudioGenerator::VS10 ? "FALSE" : "";
-    }
+  }
 }
 
 bool cmVisualStudioGeneratorOptions::IsDebug() const
@@ -141,42 +131,34 @@ bool cmVisualStudioGeneratorOptions::IsDebug() const
   return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end();
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioGeneratorOptions::IsWinRt() const
 {
   return this->FlagMap.find("CompileAsWinRT") != this->FlagMap.end();
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioGeneratorOptions::UsingUnicode() const
 {
   // Look for the a _UNICODE definition.
-  for(std::vector<std::string>::const_iterator di = this->Defines.begin();
-      di != this->Defines.end(); ++di)
-    {
-    if(*di == "_UNICODE")
-      {
+  for (std::vector<std::string>::const_iterator di = this->Defines.begin();
+       di != this->Defines.end(); ++di) {
+    if (*di == "_UNICODE") {
       return true;
-      }
     }
+  }
   return false;
 }
-//----------------------------------------------------------------------------
 bool cmVisualStudioGeneratorOptions::UsingSBCS() const
 {
   // Look for the a _SBCS definition.
-  for(std::vector<std::string>::const_iterator di = this->Defines.begin();
-      di != this->Defines.end(); ++di)
-    {
-    if(*di == "_SBCS")
-      {
+  for (std::vector<std::string>::const_iterator di = this->Defines.begin();
+       di != this->Defines.end(); ++di) {
+    if (*di == "_SBCS") {
       return true;
-      }
     }
+  }
   return false;
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::Parse(const char* flags)
 {
   // Parse the input string as a windows command line since the string
@@ -186,18 +168,15 @@ void cmVisualStudioGeneratorOptions::Parse(const char* flags)
 
   // Process flags that need to be represented specially in the IDE
   // project file.
-  for(std::vector<std::string>::iterator ai = args.begin();
-      ai != args.end(); ++ai)
-    {
+  for (std::vector<std::string>::iterator ai = args.begin(); ai != args.end();
+       ++ai) {
     this->HandleFlag(ai->c_str());
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::ParseFinish()
 {
-  if(this->CurrentTool == FortranCompiler)
-    {
+  if (this->CurrentTool == FortranCompiler) {
     // "RuntimeLibrary" attribute values:
     //  "rtMultiThreaded", "0", /threads /libs:static
     //  "rtMultiThreadedDLL", "2", /threads /libs:dll
@@ -209,215 +188,152 @@ void cmVisualStudioGeneratorOptions::ParseFinish()
     //  "rtSingleThreadedDebug", "5", /dbglibs /libs:static
     //  "rtSingleThreadedDebugDLL", "11", /dbglibs /libs:dll
     std::string rl = "rtMultiThreaded";
-    rl += this->FortranRuntimeDebug? "Debug" : "";
-    rl += this->FortranRuntimeDLL? "DLL" : "";
+    rl += this->FortranRuntimeDebug ? "Debug" : "";
+    rl += this->FortranRuntimeDLL ? "DLL" : "";
     this->FlagMap["RuntimeLibrary"] = rl;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
 {
   // Look for Intel Fortran flags that do not map well in the flag table.
-  if(this->CurrentTool == FortranCompiler)
-    {
-    if(strcmp(flag, "/dbglibs") == 0)
-      {
+  if (this->CurrentTool == FortranCompiler) {
+    if (strcmp(flag, "/dbglibs") == 0) {
       this->FortranRuntimeDebug = true;
       return;
-      }
-    if(strcmp(flag, "/threads") == 0)
-      {
+    }
+    if (strcmp(flag, "/threads") == 0) {
       this->FortranRuntimeMT = true;
       return;
-      }
-    if(strcmp(flag, "/libs:dll") == 0)
-      {
+    }
+    if (strcmp(flag, "/libs:dll") == 0) {
       this->FortranRuntimeDLL = true;
       return;
-      }
-    if(strcmp(flag, "/libs:static") == 0)
-      {
+    }
+    if (strcmp(flag, "/libs:static") == 0) {
       this->FortranRuntimeDLL = false;
       return;
-      }
     }
+  }
 
   // This option is not known.  Store it in the output flags.
   this->FlagString += " ";
-  this->FlagString +=
-    cmOutputConverter::EscapeWindowsShellArgument(
-      flag,
-      cmOutputConverter::Shell_Flag_AllowMakeVariables |
+  this->FlagString += cmOutputConverter::EscapeWindowsShellArgument(
+    flag, cmOutputConverter::Shell_Flag_AllowMakeVariables |
       cmOutputConverter::Shell_Flag_VSIDE);
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config)
 {
   this->Configuration = config;
 }
 
-//----------------------------------------------------------------------------
-void
-cmVisualStudioGeneratorOptions
-::OutputPreprocessorDefinitions(std::ostream& fout,
-                                const char* prefix,
-                                const char* suffix,
-                                const std::string& lang)
+void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
+  std::ostream& fout, const char* prefix, const char* suffix,
+  const std::string& lang)
 {
-  if(this->Defines.empty())
-    {
+  if (this->Defines.empty()) {
     return;
-    }
-  if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
-    {
+  }
+  if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
     // if there are configuration specific flags, then
     // use the configuration specific tag for PreprocessorDefinitions
-    if(!this->Configuration.empty())
-      {
+    if (!this->Configuration.empty()) {
       fout << prefix;
       this->TargetGenerator->WritePlatformConfigTag(
-        "PreprocessorDefinitions",
-        this->Configuration.c_str(),
-        0,
-        0, 0, &fout);
-      }
-    else
-      {
+        "PreprocessorDefinitions", this->Configuration.c_str(), 0, 0, 0,
+        &fout);
+    } else {
       fout << prefix << "<PreprocessorDefinitions>";
-      }
-    }
-  else
-    {
-    fout << prefix <<  "PreprocessorDefinitions=\"";
     }
+  } else {
+    fout << prefix << "PreprocessorDefinitions=\"";
+  }
   const char* sep = "";
-  for(std::vector<std::string>::const_iterator di = this->Defines.begin();
-      di != this->Defines.end(); ++di)
-    {
+  for (std::vector<std::string>::const_iterator di = this->Defines.begin();
+       di != this->Defines.end(); ++di) {
     // Escape the definition for the compiler.
     std::string define;
-    if(this->Version < cmGlobalVisualStudioGenerator::VS10)
-      {
-      define =
-        this->LocalGenerator->EscapeForShell(di->c_str(), true);
-      }
-    else
-      {
+    if (this->Version < cmGlobalVisualStudioGenerator::VS10) {
+      define = this->LocalGenerator->EscapeForShell(di->c_str(), true);
+    } else {
       define = *di;
-      }
+    }
     // Escape this flag for the IDE.
-    if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
-      {
+    if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
       define = cmVisualStudio10GeneratorOptionsEscapeForXML(define);
 
-      if(lang == "RC")
-        {
+      if (lang == "RC") {
         cmSystemTools::ReplaceString(define, "\"", "\\\"");
-        }
       }
-    else
-      {
+    } else {
       define = cmVisualStudioGeneratorOptionsEscapeForXML(define);
-      }
+    }
     // Store the flag in the project file.
     fout << sep << define;
     sep = ";";
-    }
-  if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
-    {
-    fout <<  ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix;
-    }
-  else
-    {
+  }
+  if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+    fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix;
+  } else {
     fout << "\"" << suffix;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmVisualStudioGeneratorOptions
-::OutputFlagMap(std::ostream& fout, const char* indent)
+void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout,
+                                                   const char* indent)
 {
-  if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
-    {
-    for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
-        m != this->FlagMap.end(); ++m)
-      {
+  if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+    for (std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
+         m != this->FlagMap.end(); ++m) {
       fout << indent;
-      if(!this->Configuration.empty())
-        {
+      if (!this->Configuration.empty()) {
         this->TargetGenerator->WritePlatformConfigTag(
-          m->first.c_str(),
-          this->Configuration.c_str(),
-          0,
-          0, 0, &fout);
-        }
-      else
-        {
+          m->first.c_str(), this->Configuration.c_str(), 0, 0, 0, &fout);
+      } else {
         fout << "<" << m->first << ">";
-        }
+      }
       const char* sep = "";
-      for(std::vector<std::string>::iterator i = m->second.begin();
-            i != m->second.end(); ++i)
-        {
+      for (std::vector<std::string>::iterator i = m->second.begin();
+           i != m->second.end(); ++i) {
         fout << sep << cmVisualStudio10GeneratorOptionsEscapeForXML(*i);
         sep = ";";
-        }
-      fout  << "</" << m->first << ">\n";
       }
+      fout << "</" << m->first << ">\n";
     }
-  else
-    {
-    for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
-        m != this->FlagMap.end(); ++m)
-      {
+  } else {
+    for (std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
+         m != this->FlagMap.end(); ++m) {
       fout << indent << m->first << "=\"";
       const char* sep = "";
-      for(std::vector<std::string>::iterator i = m->second.begin();
-            i != m->second.end(); ++i)
-        {
+      for (std::vector<std::string>::iterator i = m->second.begin();
+           i != m->second.end(); ++i) {
         fout << sep << cmVisualStudioGeneratorOptionsEscapeForXML(*i);
         sep = ";";
-        }
-      fout << "\"\n";
       }
+      fout << "\"\n";
     }
+  }
 }
 
-//----------------------------------------------------------------------------
-void
-cmVisualStudioGeneratorOptions
-::OutputAdditionalOptions(std::ostream& fout,
-                          const char* prefix,
-                          const char* suffix)
+void cmVisualStudioGeneratorOptions::OutputAdditionalOptions(
+  std::ostream& fout, const char* prefix, const char* suffix)
 {
-  if(!this->FlagString.empty())
-    {
-    if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
-      {
+  if (!this->FlagString.empty()) {
+    if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
       fout << prefix;
-      if(!this->Configuration.empty())
-        {
+      if (!this->Configuration.empty()) {
         this->TargetGenerator->WritePlatformConfigTag(
-          "AdditionalOptions",
-          this->Configuration.c_str(),
-          0,
-          0, 0, &fout);
-        }
-      else
-        {
+          "AdditionalOptions", this->Configuration.c_str(), 0, 0, 0, &fout);
+      } else {
         fout << "<AdditionalOptions>";
-        }
+      }
       fout << cmVisualStudio10GeneratorOptionsEscapeForXML(this->FlagString)
            << " %(AdditionalOptions)</AdditionalOptions>\n";
-      }
-    else
-      {
+    } else {
       fout << prefix << "AdditionalOptions=\"";
       fout << cmVisualStudioGeneratorOptionsEscapeForXML(this->FlagString);
       fout << "\"" << suffix;
-      }
     }
+  }
 }
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 0179134..219b009 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -19,8 +19,7 @@ typedef cmIDEFlagTable cmVS7FlagTable;
 
 class cmVisualStudio10TargetGenerator;
 
-//----------------------------------------------------------------------------
-class cmVisualStudioGeneratorOptions: public cmIDEOptions
+class cmVisualStudioGeneratorOptions : public cmIDEOptions
 {
 public:
   // Construct an options table for a given tool.
@@ -32,14 +31,12 @@ public:
     Linker,
     FortranCompiler
   };
-  cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
-                                 Tool tool,
+  cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
                                  cmVS7FlagTable const* table,
                                  cmVS7FlagTable const* extraTable = 0,
                                  cmVisualStudio10TargetGenerator* g = 0);
 
-  cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
-                                 Tool tool,
+  cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
                                  cmVisualStudio10TargetGenerator* g = 0);
 
   // Add a table of flags.
@@ -62,15 +59,14 @@ public:
   bool IsDebug() const;
   bool IsWinRt() const;
   // Write options to output.
-  void OutputPreprocessorDefinitions(std::ostream& fout,
-                                     const char* prefix,
+  void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix,
                                      const char* suffix,
                                      const std::string& lang);
   void OutputFlagMap(std::ostream& fout, const char* indent);
-  void OutputAdditionalOptions(std::ostream& fout,
-                               const char* prefix,
+  void OutputAdditionalOptions(std::ostream& fout, const char* prefix,
                                const char* suffix);
   void SetConfiguration(const char* config);
+
 private:
   cmLocalVisualStudioGenerator* LocalGenerator;
   cmGlobalVisualStudioGenerator::VSVersion Version;
diff --git a/Source/cmVisualStudioSlnData.cxx b/Source/cmVisualStudioSlnData.cxx
index 82b4ee8..7ffa0b5 100644
--- a/Source/cmVisualStudioSlnData.cxx
+++ b/Source/cmVisualStudioSlnData.cxx
@@ -11,9 +11,8 @@
 ============================================================================*/
 #include "cmVisualStudioSlnData.h"
 
-//----------------------------------------------------------------------------
-const cmSlnProjectEntry*
-cmSlnData::GetProjectByGUID(const std::string& projectGUID) const
+const cmSlnProjectEntry* cmSlnData::GetProjectByGUID(
+  const std::string& projectGUID) const
 {
   ProjectStorage::const_iterator it(ProjectsByGUID.find(projectGUID));
   if (it != ProjectsByGUID.end())
@@ -22,9 +21,8 @@ cmSlnData::GetProjectByGUID(const std::string& projectGUID) const
     return NULL;
 }
 
-//----------------------------------------------------------------------------
-const cmSlnProjectEntry*
-cmSlnData::GetProjectByName(const std::string& projectName) const
+const cmSlnProjectEntry* cmSlnData::GetProjectByName(
+  const std::string& projectName) const
 {
   ProjectStringIndex::const_iterator it(ProjectNameIndex.find(projectName));
   if (it != ProjectNameIndex.end())
@@ -33,30 +31,28 @@ cmSlnData::GetProjectByName(const std::string& projectName) const
     return NULL;
 }
 
-//----------------------------------------------------------------------------
 std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const
 {
   ProjectStringIndex::const_iterator it(this->ProjectNameIndex.begin()),
-                                     itEnd(this->ProjectNameIndex.end());
+    itEnd(this->ProjectNameIndex.end());
   std::vector<cmSlnProjectEntry> result;
   for (; it != itEnd; ++it)
     result.push_back(it->second->second);
   return result;
 }
 
-//----------------------------------------------------------------------------
 cmSlnProjectEntry* cmSlnData::AddProject(
-  const std::string& projectGUID,
-  const std::string& projectName,
+  const std::string& projectGUID, const std::string& projectName,
   const std::string& projectRelativePath)
 {
   ProjectStorage::iterator it(ProjectsByGUID.find(projectGUID));
   if (it != ProjectsByGUID.end())
     return NULL;
-  it = ProjectsByGUID.insert(
-    ProjectStorage::value_type(
-      projectGUID,
-      cmSlnProjectEntry(projectGUID, projectName, projectRelativePath))).first;
+  it = ProjectsByGUID
+         .insert(ProjectStorage::value_type(
+           projectGUID,
+           cmSlnProjectEntry(projectGUID, projectName, projectRelativePath)))
+         .first;
   ProjectNameIndex[projectName] = it;
   return &it->second;
 }
diff --git a/Source/cmVisualStudioSlnData.h b/Source/cmVisualStudioSlnData.h
index ec128cf..4508370 100644
--- a/Source/cmVisualStudioSlnData.h
+++ b/Source/cmVisualStudioSlnData.h
@@ -18,11 +18,13 @@ class cmSlnProjectEntry
 {
 public:
   cmSlnProjectEntry() {}
-  cmSlnProjectEntry(const std::string& guid,
-                    const std::string& name,
+  cmSlnProjectEntry(const std::string& guid, const std::string& name,
                     const std::string& relativePath)
-    : Guid(guid), Name(name), RelativePath(relativePath)
-  {}
+    : Guid(guid)
+    , Name(name)
+    , RelativePath(relativePath)
+  {
+  }
 
   std::string GetGUID() const { return Guid; }
   std::string GetName() const { return Name; }
@@ -32,15 +34,14 @@ private:
   std::string Guid, Name, RelativePath;
 };
 
-
 class cmSlnData
 {
 public:
-  const cmSlnProjectEntry*
-  GetProjectByGUID(const std::string& projectGUID) const;
+  const cmSlnProjectEntry* GetProjectByGUID(
+    const std::string& projectGUID) const;
 
-  const cmSlnProjectEntry*
-  GetProjectByName(const std::string& projectName) const;
+  const cmSlnProjectEntry* GetProjectByName(
+    const std::string& projectName) const;
 
   std::vector<cmSlnProjectEntry> GetProjects() const;
 
diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx
index d182a75..7d7bb5b 100644
--- a/Source/cmVisualStudioSlnParser.cxx
+++ b/Source/cmVisualStudioSlnParser.cxx
@@ -18,19 +18,16 @@
 #include <cassert>
 #include <stack>
 
-//----------------------------------------------------------------------------
-namespace
+namespace {
+enum LineFormat
 {
-  enum LineFormat
-  {
-    LineMultiValueTag,
-    LineSingleValueTag,
-    LineKeyValuePair,
-    LineVerbatim
-  };
+  LineMultiValueTag,
+  LineSingleValueTag,
+  LineKeyValuePair,
+  LineVerbatim
+};
 }
 
-//----------------------------------------------------------------------------
 class cmVisualStudioSlnParser::ParsedLine
 {
 public:
@@ -47,11 +44,17 @@ public:
   void SetTag(const std::string& tag) { this->Tag = tag; }
   void SetArg(const std::string& arg) { this->Arg = StringData(arg, false); }
   void SetQuotedArg(const std::string& arg)
-    { this->Arg = StringData(arg, true); }
+  {
+    this->Arg = StringData(arg, true);
+  }
   void AddValue(const std::string& value)
-    { this->Values.push_back(StringData(value, false)); }
+  {
+    this->Values.push_back(StringData(value, false));
+  }
   void AddQuotedValue(const std::string& value)
-    { this->Values.push_back(StringData(value, true)); }
+  {
+    this->Values.push_back(StringData(value, true));
+  }
 
   void CopyVerbatim(const std::string& line) { this->Tag = line; }
 
@@ -64,25 +67,21 @@ private:
   static const std::string Quote;
 };
 
-//----------------------------------------------------------------------------
 const std::string cmVisualStudioSlnParser::ParsedLine::BadString;
 const std::string cmVisualStudioSlnParser::ParsedLine::Quote("\"");
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParsedLine::IsComment() const
 {
   assert(!this->Tag.empty());
-  return (this->Tag[0]== '#');
+  return (this->Tag[0] == '#');
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParsedLine::IsKeyValuePair() const
 {
   assert(!this->Tag.empty());
   return this->Arg.first.empty() && this->Values.size() == 1;
 }
 
-//----------------------------------------------------------------------------
 std::string cmVisualStudioSlnParser::ParsedLine::GetArgVerbatim() const
 {
   if (this->Arg.second)
@@ -91,9 +90,8 @@ std::string cmVisualStudioSlnParser::ParsedLine::GetArgVerbatim() const
     return this->Arg.first;
 }
 
-//----------------------------------------------------------------------------
-const std::string&
-cmVisualStudioSlnParser::ParsedLine::GetValue(size_t idxValue) const
+const std::string& cmVisualStudioSlnParser::ParsedLine::GetValue(
+  size_t idxValue) const
 {
   if (idxValue < this->Values.size())
     return this->Values[idxValue].first;
@@ -101,23 +99,19 @@ cmVisualStudioSlnParser::ParsedLine::GetValue(size_t idxValue) const
     return BadString;
 }
 
-//----------------------------------------------------------------------------
-std::string
-cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim(size_t idxValue) const
+std::string cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim(
+  size_t idxValue) const
 {
-  if (idxValue < this->Values.size())
-    {
+  if (idxValue < this->Values.size()) {
     const StringData& data = this->Values[idxValue];
     if (data.second)
       return Quote + data.first + Quote;
     else
       return data.first;
-    }
-  else
+  } else
     return BadString;
 }
 
-//----------------------------------------------------------------------------
 class cmVisualStudioSlnParser::State
 {
 public:
@@ -129,8 +123,7 @@ public:
   LineFormat NextLineFormat() const;
 
   bool Process(const cmVisualStudioSlnParser::ParsedLine& line,
-               cmSlnData& output,
-               cmVisualStudioSlnParser::ResultData& result);
+               cmSlnData& output, cmVisualStudioSlnParser::ResultData& result);
 
   bool Finished(cmVisualStudioSlnParser::ResultData& result);
 
@@ -156,17 +149,15 @@ private:
   void IgnoreUntilTag(const std::string& endTag);
 };
 
-//----------------------------------------------------------------------------
-cmVisualStudioSlnParser::State::State(DataGroupSet requestedData) :
-  RequestedData(requestedData),
-  CurrentLine(0)
+cmVisualStudioSlnParser::State::State(DataGroupSet requestedData)
+  : RequestedData(requestedData)
+  , CurrentLine(0)
 {
   if (this->RequestedData.test(DataGroupProjectDependenciesBit))
     this->RequestedData.set(DataGroupProjectsBit);
   this->Stack.push(FileStateStart);
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::State::ReadLine(std::istream& input,
                                               std::string& line)
 {
@@ -174,96 +165,88 @@ bool cmVisualStudioSlnParser::State::ReadLine(std::istream& input,
   return !std::getline(input, line).fail();
 }
 
-//----------------------------------------------------------------------------
 LineFormat cmVisualStudioSlnParser::State::NextLineFormat() const
 {
-  switch (this->Stack.top())
-    {
-    case FileStateStart: return LineVerbatim;
-    case FileStateTopLevel: return LineMultiValueTag;
-    case FileStateProject: return LineSingleValueTag;
-    case FileStateProjectDependencies: return LineKeyValuePair;
-    case FileStateGlobal: return LineSingleValueTag;
-    case FileStateSolutionConfigurations: return LineKeyValuePair;
-    case FileStateProjectConfigurations: return LineKeyValuePair;
-    case FileStateSolutionFilters: return LineKeyValuePair;
-    case FileStateGlobalSection: return LineKeyValuePair;
-    case FileStateIgnore: return LineVerbatim;
+  switch (this->Stack.top()) {
+    case FileStateStart:
+      return LineVerbatim;
+    case FileStateTopLevel:
+      return LineMultiValueTag;
+    case FileStateProject:
+      return LineSingleValueTag;
+    case FileStateProjectDependencies:
+      return LineKeyValuePair;
+    case FileStateGlobal:
+      return LineSingleValueTag;
+    case FileStateSolutionConfigurations:
+      return LineKeyValuePair;
+    case FileStateProjectConfigurations:
+      return LineKeyValuePair;
+    case FileStateSolutionFilters:
+      return LineKeyValuePair;
+    case FileStateGlobalSection:
+      return LineKeyValuePair;
+    case FileStateIgnore:
+      return LineVerbatim;
     default:
       assert(false);
       return LineVerbatim;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::State::Process(
-  const cmVisualStudioSlnParser::ParsedLine& line,
-  cmSlnData& output, cmVisualStudioSlnParser::ResultData& result)
+  const cmVisualStudioSlnParser::ParsedLine& line, cmSlnData& output,
+  cmVisualStudioSlnParser::ResultData& result)
 {
   assert(!line.IsComment());
-  switch (this->Stack.top())
-    {
+  switch (this->Stack.top()) {
     case FileStateStart:
       if (!cmSystemTools::StringStartsWith(
-        line.GetTag().c_str(), "Microsoft Visual Studio Solution File"))
-        {
+            line.GetTag().c_str(), "Microsoft Visual Studio Solution File")) {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       this->Stack.pop();
       this->Stack.push(FileStateTopLevel);
       break;
     case FileStateTopLevel:
-      if (line.GetTag().compare("Project") == 0)
-        {
-        if (line.GetValueCount() != 3)
-          {
+      if (line.GetTag().compare("Project") == 0) {
+        if (line.GetValueCount() != 3) {
           result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
           return false;
-          }
-        if (this->RequestedData.test(DataGroupProjectsBit))
-          {
-          if (!output.AddProject(line.GetValue(2),
-                                 line.GetValue(0),
-                                 line.GetValue(1)))
-            {
+        }
+        if (this->RequestedData.test(DataGroupProjectsBit)) {
+          if (!output.AddProject(line.GetValue(2), line.GetValue(0),
+                                 line.GetValue(1))) {
             result.SetError(ResultErrorInputData, this->GetCurrentLine());
             return false;
-            }
-          this->Stack.push(FileStateProject);
           }
-        else
+          this->Stack.push(FileStateProject);
+        } else
           this->IgnoreUntilTag("EndProject");
-        }
-      else if (line.GetTag().compare("Global") == 0)
+      } else if (line.GetTag().compare("Global") == 0)
         this->Stack.push(FileStateGlobal);
-      else
-        {
+      else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateProject:
       if (line.GetTag().compare("EndProject") == 0)
         this->Stack.pop();
-      else if (line.GetTag().compare("ProjectSection") == 0)
-        {
+      else if (line.GetTag().compare("ProjectSection") == 0) {
         if (line.GetArg().compare("ProjectDependencies") == 0 &&
-            line.GetValue(0).compare("postProject") == 0)
-          {
+            line.GetValue(0).compare("postProject") == 0) {
           if (this->RequestedData.test(DataGroupProjectDependenciesBit))
             this->Stack.push(FileStateProjectDependencies);
           else
             this->IgnoreUntilTag("EndProjectSection");
-          }
-        else
+        } else
           this->IgnoreUntilTag("EndProjectSection");
-        }
-      else
-        {
+      } else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateProjectDependencies:
       if (line.GetTag().compare("EndProjectSection") == 0)
@@ -271,51 +254,42 @@ bool cmVisualStudioSlnParser::State::Process(
       else if (line.IsKeyValuePair())
         // implement dependency storing here, once needed
         ;
-      else
-        {
+      else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateGlobal:
       if (line.GetTag().compare("EndGlobal") == 0)
         this->Stack.pop();
-      else if (line.GetTag().compare("GlobalSection") == 0)
-        {
+      else if (line.GetTag().compare("GlobalSection") == 0) {
         if (line.GetArg().compare("SolutionConfigurationPlatforms") == 0 &&
-            line.GetValue(0).compare("preSolution") == 0)
-          {
+            line.GetValue(0).compare("preSolution") == 0) {
           if (this->RequestedData.test(DataGroupSolutionConfigurationsBit))
             this->Stack.push(FileStateSolutionConfigurations);
           else
             this->IgnoreUntilTag("EndGlobalSection");
-          }
-        else if (line.GetArg().compare("ProjectConfigurationPlatforms") == 0 &&
-                 line.GetValue(0).compare("postSolution") == 0)
-          {
+        } else if (line.GetArg().compare("ProjectConfigurationPlatforms") ==
+                     0 &&
+                   line.GetValue(0).compare("postSolution") == 0) {
           if (this->RequestedData.test(DataGroupProjectConfigurationsBit))
             this->Stack.push(FileStateProjectConfigurations);
           else
             this->IgnoreUntilTag("EndGlobalSection");
-          }
-        else if (line.GetArg().compare("NestedProjects") == 0 &&
-                 line.GetValue(0).compare("preSolution") == 0)
-          {
+        } else if (line.GetArg().compare("NestedProjects") == 0 &&
+                   line.GetValue(0).compare("preSolution") == 0) {
           if (this->RequestedData.test(DataGroupSolutionFiltersBit))
             this->Stack.push(FileStateSolutionFilters);
           else
             this->IgnoreUntilTag("EndGlobalSection");
-          }
-        else if (this->RequestedData.test(DataGroupGenericGlobalSectionsBit))
+        } else if (this->RequestedData.test(DataGroupGenericGlobalSectionsBit))
           this->Stack.push(FileStateGlobalSection);
         else
           this->IgnoreUntilTag("EndGlobalSection");
-        }
-      else
-        {
+      } else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateSolutionConfigurations:
       if (line.GetTag().compare("EndGlobalSection") == 0)
@@ -323,11 +297,10 @@ bool cmVisualStudioSlnParser::State::Process(
       else if (line.IsKeyValuePair())
         // implement configuration storing here, once needed
         ;
-      else
-        {
+      else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateProjectConfigurations:
       if (line.GetTag().compare("EndGlobalSection") == 0)
@@ -335,11 +308,10 @@ bool cmVisualStudioSlnParser::State::Process(
       else if (line.IsKeyValuePair())
         // implement configuration storing here, once needed
         ;
-      else
-        {
+      else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateSolutionFilters:
       if (line.GetTag().compare("EndGlobalSection") == 0)
@@ -347,11 +319,10 @@ bool cmVisualStudioSlnParser::State::Process(
       else if (line.IsKeyValuePair())
         // implement filter storing here, once needed
         ;
-      else
-        {
+      else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateGlobalSection:
       if (line.GetTag().compare("EndGlobalSection") == 0)
@@ -359,59 +330,52 @@ bool cmVisualStudioSlnParser::State::Process(
       else if (line.IsKeyValuePair())
         // implement section storing here, once needed
         ;
-      else
-        {
+      else {
         result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
         return false;
-        }
+      }
       break;
     case FileStateIgnore:
-      if (line.GetTag() == this->EndIgnoreTag)
-        {
+      if (line.GetTag() == this->EndIgnoreTag) {
         this->Stack.pop();
         this->EndIgnoreTag = "";
-        }
+      }
       break;
     default:
       result.SetError(ResultErrorBadInternalState, this->GetCurrentLine());
       return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::State::Finished(
   cmVisualStudioSlnParser::ResultData& result)
 {
-  if (this->Stack.top() != FileStateTopLevel)
-    {
+  if (this->Stack.top() != FileStateTopLevel) {
     result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
     return false;
-    }
+  }
   result.Result = ResultOK;
   return true;
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioSlnParser::State::IgnoreUntilTag(const std::string& endTag)
 {
   this->Stack.push(FileStateIgnore);
   this->EndIgnoreTag = endTag;
 }
 
-//----------------------------------------------------------------------------
 cmVisualStudioSlnParser::ResultData::ResultData()
   : Result(ResultOK)
   , ResultLine(0)
-{}
+{
+}
 
-//----------------------------------------------------------------------------
 void cmVisualStudioSlnParser::ResultData::Clear()
 {
   *this = ResultData();
 }
 
-//----------------------------------------------------------------------------
 void cmVisualStudioSlnParser::ResultData::SetError(ParseResult error,
                                                    size_t line)
 {
@@ -419,114 +383,99 @@ void cmVisualStudioSlnParser::ResultData::SetError(ParseResult error,
   this->ResultLine = line;
 }
 
-//----------------------------------------------------------------------------
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupProjects(
-  1 << cmVisualStudioSlnParser::DataGroupProjectsBit);
+  cmVisualStudioSlnParser::DataGroupProjects(
+    1 << cmVisualStudioSlnParser::DataGroupProjectsBit);
 
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupProjectDependencies(
-  1 << cmVisualStudioSlnParser::DataGroupProjectDependenciesBit);
+  cmVisualStudioSlnParser::DataGroupProjectDependencies(
+    1 << cmVisualStudioSlnParser::DataGroupProjectDependenciesBit);
 
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupSolutionConfigurations(
-  1 << cmVisualStudioSlnParser::DataGroupSolutionConfigurationsBit);
+  cmVisualStudioSlnParser::DataGroupSolutionConfigurations(
+    1 << cmVisualStudioSlnParser::DataGroupSolutionConfigurationsBit);
 
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupProjectConfigurations(
-  1 << cmVisualStudioSlnParser::DataGroupProjectConfigurationsBit);
+  cmVisualStudioSlnParser::DataGroupProjectConfigurations(
+    1 << cmVisualStudioSlnParser::DataGroupProjectConfigurationsBit);
 
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupSolutionFilters(
-  1 << cmVisualStudioSlnParser::DataGroupSolutionFiltersBit);
+  cmVisualStudioSlnParser::DataGroupSolutionFilters(
+    1 << cmVisualStudioSlnParser::DataGroupSolutionFiltersBit);
 
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupGenericGlobalSections(
-  1 << cmVisualStudioSlnParser::DataGroupGenericGlobalSectionsBit);
+  cmVisualStudioSlnParser::DataGroupGenericGlobalSections(
+    1 << cmVisualStudioSlnParser::DataGroupGenericGlobalSectionsBit);
 
 const cmVisualStudioSlnParser::DataGroupSet
-cmVisualStudioSlnParser::DataGroupAll(~0);
+  cmVisualStudioSlnParser::DataGroupAll(~0);
 
-//----------------------------------------------------------------------------
-bool cmVisualStudioSlnParser::Parse(std::istream& input,
-                                    cmSlnData& output,
+bool cmVisualStudioSlnParser::Parse(std::istream& input, cmSlnData& output,
                                     DataGroupSet dataGroups)
 {
   this->LastResult.Clear();
-  if (!this->IsDataGroupSetSupported(dataGroups))
-    {
+  if (!this->IsDataGroupSetSupported(dataGroups)) {
     this->LastResult.SetError(ResultErrorUnsupportedDataGroup, 0);
     return false;
-    }
+  }
   State state(dataGroups);
   return this->ParseImpl(input, output, state);
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParseFile(const std::string& file,
                                         cmSlnData& output,
                                         DataGroupSet dataGroups)
 {
   this->LastResult.Clear();
-  if (!this->IsDataGroupSetSupported(dataGroups))
-    {
+  if (!this->IsDataGroupSetSupported(dataGroups)) {
     this->LastResult.SetError(ResultErrorUnsupportedDataGroup, 0);
     return false;
-    }
+  }
   cmsys::ifstream f(file.c_str());
-  if (!f)
-    {
+  if (!f) {
     this->LastResult.SetError(ResultErrorOpeningInput, 0);
     return false;
-    }
+  }
   State state(dataGroups);
   return this->ParseImpl(f, output, state);
 }
 
-//----------------------------------------------------------------------------
-cmVisualStudioSlnParser::ParseResult
-cmVisualStudioSlnParser::GetParseResult() const
+cmVisualStudioSlnParser::ParseResult cmVisualStudioSlnParser::GetParseResult()
+  const
 {
   return this->LastResult.Result;
 }
 
-//----------------------------------------------------------------------------
 size_t cmVisualStudioSlnParser::GetParseResultLine() const
 {
   return this->LastResult.ResultLine;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::GetParseHadBOM() const
 {
   return this->LastResult.HadBOM;
 }
 
-//----------------------------------------------------------------------------
-bool
-cmVisualStudioSlnParser::IsDataGroupSetSupported(DataGroupSet dataGroups) const
+bool cmVisualStudioSlnParser::IsDataGroupSetSupported(
+  DataGroupSet dataGroups) const
 {
   return (dataGroups & DataGroupProjects) == dataGroups;
-    //only supporting DataGroupProjects for now
+  // only supporting DataGroupProjects for now
 }
 
-//----------------------------------------------------------------------------
-bool cmVisualStudioSlnParser::ParseImpl(std::istream& input,
-                                        cmSlnData& output,
+bool cmVisualStudioSlnParser::ParseImpl(std::istream& input, cmSlnData& output,
                                         State& state)
 {
   std::string line;
   // Does the .sln start with a Byte Order Mark?
   if (!this->ParseBOM(input, line, state))
     return false;
-  do
-    {
+  do {
     line = cmSystemTools::TrimWhitespace(line);
     if (line.empty())
       continue;
     ParsedLine parsedLine;
-    switch (state.NextLineFormat())
-      {
+    switch (state.NextLineFormat()) {
       case LineMultiValueTag:
         if (!this->ParseMultiValueTag(line, parsedLine, state))
           return false;
@@ -542,40 +491,34 @@ bool cmVisualStudioSlnParser::ParseImpl(std::istream& input,
       case LineVerbatim:
         parsedLine.CopyVerbatim(line);
         break;
-      }
+    }
     if (parsedLine.IsComment())
       continue;
     if (!state.Process(parsedLine, output, this->LastResult))
       return false;
-    }
-    while (state.ReadLine(input, line));
+  } while (state.ReadLine(input, line));
   return state.Finished(this->LastResult);
 }
 
-//----------------------------------------------------------------------------
-bool cmVisualStudioSlnParser::ParseBOM(std::istream& input,
-                                       std::string& line,
+bool cmVisualStudioSlnParser::ParseBOM(std::istream& input, std::string& line,
                                        State& state)
 {
   char bom[4];
-  if (!input.get(bom, 4))
-    {
+  if (!input.get(bom, 4)) {
     this->LastResult.SetError(ResultErrorReadingInput, 1);
     return false;
-    }
+  }
   this->LastResult.HadBOM =
     (bom[0] == char(0xEF) && bom[1] == char(0xBB) && bom[2] == char(0xBF));
-  if (!state.ReadLine(input, line))
-    {
+  if (!state.ReadLine(input, line)) {
     this->LastResult.SetError(ResultErrorReadingInput, 1);
     return false;
-    }
+  }
   if (!this->LastResult.HadBOM)
-    line = bom + line;  // it wasn't a BOM, prepend it to first line
+    line = bom + line; // it wasn't a BOM, prepend it to first line
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParseMultiValueTag(const std::string& line,
                                                  ParsedLine& parsedLine,
                                                  State& state)
@@ -584,49 +527,41 @@ bool cmVisualStudioSlnParser::ParseMultiValueTag(const std::string& line,
   const std::string& fullTag = line.substr(0, idxEqualSign);
   if (!this->ParseTag(fullTag, parsedLine, state))
     return false;
-  if (idxEqualSign != line.npos)
-    {
+  if (idxEqualSign != line.npos) {
     size_t idxFieldStart = idxEqualSign + 1;
-    if (idxFieldStart < line.size())
-      {
+    if (idxFieldStart < line.size()) {
       size_t idxParsing = idxFieldStart;
       bool inQuotes = false;
-      for (;;)
-        {
+      for (;;) {
         idxParsing = line.find_first_of(",\"", idxParsing);
         bool fieldOver = false;
-        if (idxParsing == line.npos)
-          {
+        if (idxParsing == line.npos) {
           fieldOver = true;
-          if (inQuotes)
-            {
+          if (inQuotes) {
             this->LastResult.SetError(ResultErrorInputStructure,
                                       state.GetCurrentLine());
             return false;
-            }
           }
-        else if (line[idxParsing] == ',' && !inQuotes)
+        } else if (line[idxParsing] == ',' && !inQuotes)
           fieldOver = true;
         else if (line[idxParsing] == '"')
           inQuotes = !inQuotes;
-        if (fieldOver)
-          {
-          if (!this->ParseValue(line.substr(idxFieldStart,
-                                            idxParsing - idxFieldStart),
-                                parsedLine))
+        if (fieldOver) {
+          if (!this->ParseValue(
+                line.substr(idxFieldStart, idxParsing - idxFieldStart),
+                parsedLine))
             return false;
           if (idxParsing == line.npos)
-            break;  //end of last field
+            break; // end of last field
           idxFieldStart = idxParsing + 1;
-          }
-        ++idxParsing;
         }
+        ++idxParsing;
       }
     }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParseSingleValueTag(const std::string& line,
                                                   ParsedLine& parsedLine,
                                                   State& state)
@@ -635,25 +570,22 @@ bool cmVisualStudioSlnParser::ParseSingleValueTag(const std::string& line,
   const std::string& fullTag = line.substr(0, idxEqualSign);
   if (!this->ParseTag(fullTag, parsedLine, state))
     return false;
-  if (idxEqualSign != line.npos)
-    {
+  if (idxEqualSign != line.npos) {
     if (!this->ParseValue(line.substr(idxEqualSign + 1), parsedLine))
       return false;
-    }
+  }
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParseKeyValuePair(const std::string& line,
                                                 ParsedLine& parsedLine,
                                                 State& /*state*/)
 {
   size_t idxEqualSign = line.find('=');
-  if (idxEqualSign == line.npos)
-    {
+  if (idxEqualSign == line.npos) {
     parsedLine.CopyVerbatim(line);
     return true;
-    }
+  }
   const std::string& key = line.substr(0, idxEqualSign);
   parsedLine.SetTag(cmSystemTools::TrimWhitespace(key));
   const std::string& value = line.substr(idxEqualSign + 1);
@@ -661,44 +593,36 @@ bool cmVisualStudioSlnParser::ParseKeyValuePair(const std::string& line,
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag,
-                                       ParsedLine& parsedLine,
-                                       State& state)
+                                       ParsedLine& parsedLine, State& state)
 {
   size_t idxLeftParen = fullTag.find('(');
-  if (idxLeftParen == fullTag.npos)
-    {
+  if (idxLeftParen == fullTag.npos) {
     parsedLine.SetTag(cmSystemTools::TrimWhitespace(fullTag));
     return true;
-    }
+  }
   parsedLine.SetTag(
     cmSystemTools::TrimWhitespace(fullTag.substr(0, idxLeftParen)));
   size_t idxRightParen = fullTag.rfind(')');
-  if (idxRightParen == fullTag.npos)
-    {
+  if (idxRightParen == fullTag.npos) {
     this->LastResult.SetError(ResultErrorInputStructure,
                               state.GetCurrentLine());
     return false;
-    }
+  }
   const std::string& arg = cmSystemTools::TrimWhitespace(
     fullTag.substr(idxLeftParen + 1, idxRightParen - idxLeftParen - 1));
-  if (arg[0] == '"')
-    {
-    if (arg[arg.size() - 1] != '"')
-      {
+  if (arg[0] == '"') {
+    if (arg[arg.size() - 1] != '"') {
       this->LastResult.SetError(ResultErrorInputStructure,
                                 state.GetCurrentLine());
       return false;
-      }
-      parsedLine.SetQuotedArg(arg.substr(1, arg.size() - 2));
     }
-  else
+    parsedLine.SetQuotedArg(arg.substr(1, arg.size() - 2));
+  } else
     parsedLine.SetArg(arg);
   return true;
 }
 
-//----------------------------------------------------------------------------
 bool cmVisualStudioSlnParser::ParseValue(const std::string& value,
                                          ParsedLine& parsedLine)
 {
diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h
index bee70cc..b9f8a92 100644
--- a/Source/cmVisualStudioSlnParser.h
+++ b/Source/cmVisualStudioSlnParser.h
@@ -16,10 +16,8 @@
 
 #include <bitset>
 
-
 class cmSlnData;
 
-
 class cmVisualStudioSlnParser
 {
 public:
@@ -60,12 +58,10 @@ public:
   static const DataGroupSet DataGroupGenericGlobalSections;
   static const DataGroupSet DataGroupAll;
 
-  bool Parse(std::istream& input,
-             cmSlnData& output,
+  bool Parse(std::istream& input, cmSlnData& output,
              DataGroupSet dataGroups = DataGroupAll);
 
-  bool ParseFile(const std::string& file,
-                 cmSlnData& output,
+  bool ParseFile(const std::string& file, cmSlnData& output,
                  DataGroupSet dataGroups = DataGroupAll);
 
   ParseResult GetParseResult() const;
@@ -96,20 +92,16 @@ protected:
 
   bool ParseBOM(std::istream& input, std::string& line, State& state);
 
-  bool ParseMultiValueTag(const std::string& line,
-                          ParsedLine& parsedLine,
+  bool ParseMultiValueTag(const std::string& line, ParsedLine& parsedLine,
                           State& state);
 
-  bool ParseSingleValueTag(const std::string& line,
-                           ParsedLine& parsedLine,
+  bool ParseSingleValueTag(const std::string& line, ParsedLine& parsedLine,
                            State& state);
 
-  bool ParseKeyValuePair(const std::string& line,
-                         ParsedLine& parsedLine,
+  bool ParseKeyValuePair(const std::string& line, ParsedLine& parsedLine,
                          State& state);
 
-  bool ParseTag(const std::string& fullTag,
-                ParsedLine& parsedLine,
+  bool ParseTag(const std::string& fullTag, ParsedLine& parsedLine,
                 State& state);
 
   bool ParseValue(const std::string& value, ParsedLine& parsedLine);
diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx
index ca226fb..bc6b0bf 100644
--- a/Source/cmVisualStudioWCEPlatformParser.cxx
+++ b/Source/cmVisualStudioWCEPlatformParser.cxx
@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmVisualStudioWCEPlatformParser.h"
+
 #include "cmGlobalVisualStudioGenerator.h"
 #include "cmXMLParser.h"
 
@@ -20,15 +21,12 @@ int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
   const std::string vckey = registryBase + "\\Setup\\VC;ProductDir";
   const std::string vskey = registryBase + "\\Setup\\VS;ProductDir";
 
-  if(!cmSystemTools::ReadRegistryValue(vckey.c_str(),
-                                       this->VcInstallDir,
-                                       cmSystemTools::KeyWOW64_32) ||
-     !cmSystemTools::ReadRegistryValue(vskey.c_str(),
-                                       this->VsInstallDir,
-                                       cmSystemTools::KeyWOW64_32))
-    {
+  if (!cmSystemTools::ReadRegistryValue(vckey.c_str(), this->VcInstallDir,
+                                        cmSystemTools::KeyWOW64_32) ||
+      !cmSystemTools::ReadRegistryValue(vskey.c_str(), this->VsInstallDir,
+                                        cmSystemTools::KeyWOW64_32)) {
     return 0;
-    }
+  }
   cmSystemTools::ConvertToUnixSlashes(this->VcInstallDir);
   cmSystemTools::ConvertToUnixSlashes(this->VsInstallDir);
   this->VcInstallDir.append("/");
@@ -42,10 +40,9 @@ int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
 
 std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
 {
-  if (this->OSMinorVersion.empty())
-    {
+  if (this->OSMinorVersion.empty()) {
     return OSMajorVersion;
-    }
+  }
 
   return OSMajorVersion + "." + OSMinorVersion;
 }
@@ -54,10 +51,9 @@ const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
 {
   std::map<std::string, std::string>::const_iterator it =
     this->Macros.find("ARCHFAM");
-  if (it != this->Macros.end())
-    {
+  if (it != this->Macros.end()) {
     return it->second.c_str();
-    }
+  }
 
   return 0;
 }
@@ -65,98 +61,71 @@ const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
 void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
                                                    const char** attributes)
 {
-  if(this->FoundRequiredName)
-    {
+  if (this->FoundRequiredName) {
     return;
-    }
+  }
 
   this->CharacterData = "";
 
-  if(name == "PlatformData")
-    {
+  if (name == "PlatformData") {
     this->PlatformName = "";
     this->OSMajorVersion = "";
     this->OSMinorVersion = "";
     this->Macros.clear();
-    }
+  }
 
-  if(name == "Macro")
-    {
+  if (name == "Macro") {
     std::string macroName;
     std::string macroValue;
 
-    for(const char** attr = attributes; *attr; attr += 2)
-      {
-      if(strcmp(attr[0], "Name") == 0)
-        {
+    for (const char** attr = attributes; *attr; attr += 2) {
+      if (strcmp(attr[0], "Name") == 0) {
         macroName = attr[1];
-        }
-      else if(strcmp(attr[0], "Value") == 0)
-        {
+      } else if (strcmp(attr[0], "Value") == 0) {
         macroValue = attr[1];
-        }
       }
+    }
 
-    if(!macroName.empty())
-      {
+    if (!macroName.empty()) {
       this->Macros[macroName] = macroValue;
-      }
     }
-  else if(name == "Directories")
-    {
-    for(const char** attr = attributes; *attr; attr += 2)
-      {
-      if(strcmp(attr[0], "Include") == 0)
-        {
+  } else if (name == "Directories") {
+    for (const char** attr = attributes; *attr; attr += 2) {
+      if (strcmp(attr[0], "Include") == 0) {
         this->Include = attr[1];
-        }
-      else if(strcmp(attr[0], "Library") == 0)
-        {
+      } else if (strcmp(attr[0], "Library") == 0) {
         this->Library = attr[1];
-        }
-      else if(strcmp(attr[0], "Path") == 0)
-        {
+      } else if (strcmp(attr[0], "Path") == 0) {
         this->Path = attr[1];
-        }
       }
     }
+  }
 }
 
 void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
 {
-  if(!this->RequiredName)
-    {
-    if(name == "PlatformName")
-      {
+  if (!this->RequiredName) {
+    if (name == "PlatformName") {
       this->AvailablePlatforms.push_back(this->CharacterData);
-      }
-    return;
     }
+    return;
+  }
 
-  if(this->FoundRequiredName)
-    {
+  if (this->FoundRequiredName) {
     return;
-    }
+  }
 
-  if(name == "PlatformName")
-    {
+  if (name == "PlatformName") {
     this->PlatformName = this->CharacterData;
-    }
-  else if(name == "OSMajorVersion")
-    {
+  } else if (name == "OSMajorVersion") {
     this->OSMajorVersion = this->CharacterData;
-    }
-  else if(name == "OSMinorVersion")
-   {
-   this->OSMinorVersion = this->CharacterData;
-   }
-  else if(name == "Platform")
-    {
-    if(this->PlatformName == this->RequiredName)
-      {
+  } else if (name == "OSMinorVersion") {
+    this->OSMinorVersion = this->CharacterData;
+  } else if (name == "Platform") {
+    if (this->PlatformName == this->RequiredName) {
       this->FoundRequiredName = true;
-      }
     }
+  }
 }
 
 void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
@@ -166,14 +135,14 @@ void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
 }
 
 std::string cmVisualStudioWCEPlatformParser::FixPaths(
-    const std::string& paths) const
+  const std::string& paths) const
 {
   std::string ret = paths;
   cmSystemTools::ReplaceString(ret, "$(PATH)", "%PATH%");
   cmSystemTools::ReplaceString(ret, "$(VCInstallDir)", VcInstallDir.c_str());
   cmSystemTools::ReplaceString(ret, "$(VSInstallDir)", VsInstallDir.c_str());
-  cmSystemTools::ReplaceString(ret, "\\", "/");
+  std::replace(ret.begin(), ret.end(), '\\', '/');
   cmSystemTools::ReplaceString(ret, "//", "/");
-  cmSystemTools::ReplaceString(ret, "/", "\\");
+  std::replace(ret.begin(), ret.end(), '/', '\\');
   return ret;
 }
diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h
index 042df01..2b20eba 100644
--- a/Source/cmVisualStudioWCEPlatformParser.h
+++ b/Source/cmVisualStudioWCEPlatformParser.h
@@ -11,6 +11,7 @@
 ============================================================================*/
 #ifndef cmVisualStudioWCEPlatformParser_h
 #define cmVisualStudioWCEPlatformParser_h
+
 #include "cmStandardIncludes.h"
 
 #include "cmXMLParser.h"
@@ -21,24 +22,29 @@ class cmVisualStudioWCEPlatformParser : public cmXMLParser
 {
 public:
   cmVisualStudioWCEPlatformParser(const char* name = NULL)
-      : RequiredName(name)
-      , FoundRequiredName(false)
-    {
-    }
+    : RequiredName(name)
+    , FoundRequiredName(false)
+  {
+  }
 
   int ParseVersion(const char* version);
 
-  bool Found() const {return this->FoundRequiredName;}
+  bool Found() const { return this->FoundRequiredName; }
   const char* GetArchitectureFamily() const;
   std::string GetOSVersion() const;
-  std::string GetIncludeDirectories() const {
-    return this->FixPaths(this->Include); }
-  std::string GetLibraryDirectories() const {
-    return this->FixPaths(this->Library); }
-  std::string GetPathDirectories() const {
-    return this->FixPaths(this->Path); }
-  const std::vector<std::string>& GetAvailablePlatforms() const {
-    return this->AvailablePlatforms; }
+  std::string GetIncludeDirectories() const
+  {
+    return this->FixPaths(this->Include);
+  }
+  std::string GetLibraryDirectories() const
+  {
+    return this->FixPaths(this->Library);
+  }
+  std::string GetPathDirectories() const { return this->FixPaths(this->Path); }
+  const std::vector<std::string>& GetAvailablePlatforms() const
+  {
+    return this->AvailablePlatforms;
+  }
 
 protected:
   virtual void StartElement(const std::string& name, const char** attributes);
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 4b7afd8..bec2861 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -10,10 +10,12 @@
   See the License for more information.
 ============================================================================*/
 #include "cmWhileCommand.h"
+
 #include "cmConditionEvaluator.h"
 
-cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf):
-  Makefile(mf), Depth(0)
+cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
+  : Makefile(mf)
+  , Depth(0)
 {
   this->Makefile->PushLoopBlock();
 }
@@ -23,25 +25,23 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
   this->Makefile->PopLoopBlock();
 }
 
-bool cmWhileFunctionBlocker::
-IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
-                  cmExecutionStatus &inStatus)
+bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
+                                               cmMakefile& mf,
+                                               cmExecutionStatus& inStatus)
 {
   // at end of for each execute recorded commands
-  if (!cmSystemTools::Strucmp(lff.Name.c_str(),"while"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "while")) {
     // record the number of while commands past this one
     this->Depth++;
-    }
-  else if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endwhile"))
-    {
+  } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) {
     // if this is the endwhile for this while loop then execute
-    if (!this->Depth)
-      {
+    if (!this->Depth) {
       // Remove the function blocker for this scope or bail.
-      cmsys::auto_ptr<cmFunctionBlocker>
-        fb(mf.RemoveFunctionBlocker(this, lff));
-      if(!fb.get()) { return false; }
+      cmsys::auto_ptr<cmFunctionBlocker> fb(
+        mf.RemoveFunctionBlocker(this, lff));
+      if (!fb.get()) {
+        return false;
+      }
 
       std::string errorString;
 
@@ -55,78 +55,61 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
       commandContext.Line = execContext.Line;
       commandContext.Name = execContext.Name;
 
-      cmListFileContext conditionContext =
-          cmConditionEvaluator::GetConditionContext(
-            &mf, commandContext,
-            this->GetStartingContext().FilePath);
+      cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(),
+                                              mf.GetBacktrace(commandContext));
 
-      cmConditionEvaluator conditionEvaluator(
-            mf, conditionContext,
-            mf.GetBacktrace(commandContext));
+      bool isTrue =
+        conditionEvaluator.IsTrue(expandedArguments, errorString, messageType);
 
-      bool isTrue = conditionEvaluator.IsTrue(
-        expandedArguments, errorString, messageType);
-
-      while (isTrue)
-        {
-        if (!errorString.empty())
-          {
+      while (isTrue) {
+        if (!errorString.empty()) {
           std::string err = "had incorrect arguments: ";
           unsigned int i;
-          for(i =0; i < this->Args.size(); ++i)
-            {
-            err += (this->Args[i].Delim?"\"":"");
+          for (i = 0; i < this->Args.size(); ++i) {
+            err += (this->Args[i].Delim ? "\"" : "");
             err += this->Args[i].Value;
-            err += (this->Args[i].Delim?"\"":"");
+            err += (this->Args[i].Delim ? "\"" : "");
             err += " ";
-            }
+          }
           err += "(";
           err += errorString;
           err += ").";
           mf.IssueMessage(messageType, err);
-          if (messageType == cmake::FATAL_ERROR)
-            {
+          if (messageType == cmake::FATAL_ERROR) {
             cmSystemTools::SetFatalErrorOccured();
             return true;
-            }
           }
+        }
 
         // Invoke all the functions that were collected in the block.
-        for(unsigned int c = 0; c < this->Functions.size(); ++c)
-          {
+        for (unsigned int c = 0; c < this->Functions.size(); ++c) {
           cmExecutionStatus status;
-          mf.ExecuteCommand(this->Functions[c],status);
-          if (status.GetReturnInvoked())
-            {
+          mf.ExecuteCommand(this->Functions[c], status);
+          if (status.GetReturnInvoked()) {
             inStatus.SetReturnInvoked(true);
             return true;
-            }
-          if (status.GetBreakInvoked())
-            {
+          }
+          if (status.GetBreakInvoked()) {
             return true;
-            }
-          if (status.GetContinueInvoked())
-            {
+          }
+          if (status.GetContinueInvoked()) {
             break;
-            }
-          if(cmSystemTools::GetFatalErrorOccured() )
-            {
+          }
+          if (cmSystemTools::GetFatalErrorOccured()) {
             return true;
-            }
           }
+        }
         expandedArguments.clear();
         mf.ExpandArguments(this->Args, expandedArguments);
-        isTrue = conditionEvaluator.IsTrue(
-          expandedArguments, errorString, messageType);
-        }
-      return true;
+        isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString,
+                                           messageType);
       }
-    else
-      {
+      return true;
+    } else {
       // decrement for each nested while that ends
       this->Depth--;
-      }
     }
+  }
 
   // record the command
   this->Functions.push_back(lff);
@@ -135,37 +118,31 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
   return true;
 }
 
-bool cmWhileFunctionBlocker::
-ShouldRemove(const cmListFileFunction& lff, cmMakefile& )
+bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
+                                          cmMakefile&)
 {
-  if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endwhile"))
-    {
+  if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) {
     // if the endwhile has arguments, then make sure
     // they match the arguments of the matching while
-    if (lff.Arguments.empty() ||
-        lff.Arguments == this->Args)
-      {
+    if (lff.Arguments.empty() || lff.Arguments == this->Args) {
       return true;
-      }
     }
+  }
   return false;
 }
 
-bool cmWhileCommand
-::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                    cmExecutionStatus &)
+bool cmWhileCommand::InvokeInitialPass(
+  const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
 {
-  if(args.size() < 1)
-    {
+  if (args.size() < 1) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
 
   // create a function blocker
-  cmWhileFunctionBlocker *f = new cmWhileFunctionBlocker(this->Makefile);
+  cmWhileFunctionBlocker* f = new cmWhileFunctionBlocker(this->Makefile);
   f->Args = args;
   this->Makefile->AddFunctionBlocker(f);
 
   return true;
 }
-
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index 85a0bd3..0f35be8 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -13,6 +13,7 @@
 #define cmWhileCommand_h
 
 #include "cmCommand.h"
+
 #include "cmFunctionBlocker.h"
 #include "cmListFileCache.h"
 
@@ -21,13 +22,13 @@ class cmWhileFunctionBlocker : public cmFunctionBlocker
 public:
   cmWhileFunctionBlocker(cmMakefile* mf);
   ~cmWhileFunctionBlocker();
-  virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
-                                 cmMakefile &mf,
-                                 cmExecutionStatus &);
-  virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
+  virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
+                                 cmExecutionStatus&);
+  virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf);
 
   std::vector<cmListFileArgument> Args;
   std::vector<cmListFileFunction> Functions;
+
 private:
   cmMakefile* Makefile;
   int Depth;
@@ -40,24 +41,23 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmWhileCommand;
-    }
+  virtual cmCommand* Clone() { return new cmWhileCommand; }
 
   /**
    * This overrides the default InvokeInitialPass implementation.
    * It records the arguments before expansion.
    */
   virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
-                                 cmExecutionStatus &);
+                                 cmExecutionStatus&);
 
   /**
    * This is called when the command is first encountered in
    * the CMakeLists.txt file.
    */
-  virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false; }
+  virtual bool InitialPass(std::vector<std::string> const&, cmExecutionStatus&)
+  {
+    return false;
+  }
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -67,10 +67,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "while";}
+  virtual std::string GetName() const { return "while"; }
 
   cmTypeMacro(cmWhileCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index cc9f220..3966d38 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -10,20 +10,21 @@
   See the License for more information.
 ============================================================================*/
 #include "cmWriteFileCommand.h"
+
 #include <cmsys/FStream.hxx>
 
 #include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h>
 
 // cmLibraryCommand
-bool cmWriteFileCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
+                                     cmExecutionStatus&)
 {
-  if(args.size() < 2 )
-    {
+  if (args.size() < 2) {
     this->SetError("called with incorrect number of arguments");
     return false;
-    }
+  }
   std::string message;
   std::vector<std::string>::const_iterator i = args.begin();
 
@@ -31,26 +32,21 @@ bool cmWriteFileCommand
   bool overwrite = true;
   i++;
 
-  for(;i != args.end(); ++i)
-    {
-    if ( *i == "APPEND" )
-      {
+  for (; i != args.end(); ++i) {
+    if (*i == "APPEND") {
       overwrite = false;
-      }
-    else
-      {
+    } else {
       message += *i;
-      }
     }
+  }
 
-  if ( !this->Makefile->CanIWriteThisFile(fileName.c_str()) )
-    {
-    std::string e = "attempted to write a file: " + fileName
-      + " into a source directory.";
+  if (!this->Makefile->CanIWriteThisFile(fileName.c_str())) {
+    std::string e =
+      "attempted to write a file: " + fileName + " into a source directory.";
     this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
-    }
+  }
 
   std::string dir = cmSystemTools::GetFilenamePath(fileName);
   cmSystemTools::MakeDirectory(dir.c_str());
@@ -58,35 +54,31 @@ bool cmWriteFileCommand
   mode_t mode = 0;
 
   // Set permissions to writable
-  if ( cmSystemTools::GetPermissions(fileName.c_str(), mode) )
-    {
+  if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) {
     cmSystemTools::SetPermissions(fileName.c_str(),
-#if defined( _MSC_VER ) || defined( __MINGW32__ )
-      mode | S_IWRITE
+#if defined(_MSC_VER) || defined(__MINGW32__)
+                                  mode | S_IWRITE
 #else
-      mode | S_IWUSR | S_IWGRP
+                                  mode | S_IWUSR | S_IWGRP
 #endif
-    );
-    }
+                                  );
+  }
   // If GetPermissions fails, pretend like it is ok. File open will fail if
   // the file is not writable
   cmsys::ofstream file(fileName.c_str(),
-                     overwrite?std::ios::out : std::ios::app);
-  if ( !file )
-    {
+                       overwrite ? std::ios::out : std::ios::app);
+  if (!file) {
     std::string error = "Internal CMake error when trying to open file: ";
     error += fileName.c_str();
     error += " for writing.";
     this->SetError(error);
     return false;
-    }
+  }
   file << message << std::endl;
   file.close();
-  if(mode)
-    {
+  if (mode) {
     cmSystemTools::SetPermissions(fileName.c_str(), mode);
-    }
+  }
 
   return true;
 }
-
diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h
index 89dc9ff..b0eef9c 100644
--- a/Source/cmWriteFileCommand.h
+++ b/Source/cmWriteFileCommand.h
@@ -24,17 +24,14 @@ public:
   /**
    * This is a virtual constructor for the command.
    */
-  virtual cmCommand* Clone()
-    {
-    return new cmWriteFileCommand;
-    }
+  virtual cmCommand* Clone() { return new cmWriteFileCommand; }
 
   /**
    * 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);
+                           cmExecutionStatus& status);
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -44,10 +41,9 @@ public:
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual std::string GetName() const { return "write_file";}
+  virtual std::string GetName() const { return "write_file"; }
 
   cmTypeMacro(cmWriteFileCommand, cmCommand);
 };
 
-
 #endif
diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx
index 3973540..1abdf66 100644
--- a/Source/cmXCode21Object.cxx
+++ b/Source/cmXCode21Object.cxx
@@ -10,69 +10,58 @@
   See the License for more information.
 ============================================================================*/
 #include "cmXCode21Object.h"
+
 #include "cmSystemTools.h"
 
-//----------------------------------------------------------------------------
 cmXCode21Object::cmXCode21Object(PBXType ptype, Type type)
-  :cmXCodeObject(ptype, type)
+  : cmXCodeObject(ptype, type)
 {
   this->Version = 21;
 }
 
-//----------------------------------------------------------------------------
 void cmXCode21Object::PrintComment(std::ostream& out)
 {
-  if(this->Comment.empty())
-    {
+  if (this->Comment.empty()) {
     cmXCodeObject* n = this->GetObject("name");
-    if(n)
-      {
+    if (n) {
       this->Comment = n->GetString();
       cmSystemTools::ReplaceString(this->Comment, "\"", "");
-      }
     }
-  if(this->Comment.empty())
-    {
+  }
+  if (this->Comment.empty()) {
     return;
-    }
+  }
   out << " /* ";
   out << this->Comment;
   out << " */";
 }
 
-//----------------------------------------------------------------------------
 void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
                                 std::ostream& out, PBXType t)
 {
   bool hasOne = false;
-  for(std::vector<cmXCodeObject*>::const_iterator i = v.begin();
-      i != v.end(); ++i)
-    {
+  for (std::vector<cmXCodeObject*>::const_iterator i = v.begin(); i != v.end();
+       ++i) {
     cmXCodeObject* obj = *i;
-    if(obj->GetType() == OBJECT && obj->GetIsA() == t)
-      {
+    if (obj->GetType() == OBJECT && obj->GetIsA() == t) {
       hasOne = true;
       break;
-      }
     }
-  if(!hasOne)
-    {
+  }
+  if (!hasOne) {
     return;
-    }
-  out << "\n/* Begin " <<  PBXTypeNames[t] << " section */\n";
-  for(std::vector<cmXCodeObject*>::const_iterator i = v.begin();
-      i != v.end(); ++i)
-    {
+  }
+  out << "\n/* Begin " << PBXTypeNames[t] << " section */\n";
+  for (std::vector<cmXCodeObject*>::const_iterator i = v.begin(); i != v.end();
+       ++i) {
     cmXCodeObject* obj = *i;
-    if(obj->GetType() == OBJECT && obj->GetIsA() == t)
-      {
-        obj->Print(out);
-      }
+    if (obj->GetType() == OBJECT && obj->GetIsA() == t) {
+      obj->Print(out);
     }
-  out << "/* End " <<  PBXTypeNames[t] << " section */\n";
+  }
+  out << "/* End " << PBXTypeNames[t] << " section */\n";
 }
 
-//----------------------------------------------------------------------------
 void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
                                 std::ostream& out)
 {
@@ -83,8 +72,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXBuildStyle);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXContainerItemProxy);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXFileReference);
-  cmXCode21Object::PrintList(v, out,
-                             cmXCode21Object::PBXFrameworksBuildPhase);
+  cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXFrameworksBuildPhase);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXGroup);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXHeadersBuildPhase);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXNativeTarget);
@@ -94,8 +82,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXResourcesBuildPhase);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXSourcesBuildPhase);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXCopyFilesBuildPhase);
-  cmXCode21Object::PrintList(v, out,
-                             cmXCode21Object::PBXApplicationReference);
+  cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXApplicationReference);
   cmXCode21Object::PrintList(v, out,
                              cmXCode21Object::PBXExecutableFileReference);
   cmXCode21Object::PrintList(v, out, cmXCode21Object::PBXLibraryReference);
diff --git a/Source/cmXCode21Object.h b/Source/cmXCode21Object.h
index cc3ab04..9e51e0d 100644
--- a/Source/cmXCode21Object.h
+++ b/Source/cmXCode21Object.h
@@ -19,10 +19,8 @@ class cmXCode21Object : public cmXCodeObject
 public:
   cmXCode21Object(PBXType ptype, Type type);
   virtual void PrintComment(std::ostream&);
-  static void PrintList(std::vector<cmXCodeObject*> const&,
-                        std::ostream& out,
+  static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out,
                         PBXType t);
-  static void PrintList(std::vector<cmXCodeObject*> const&,
-                        std::ostream& out);
+  static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out);
 };
 #endif
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 5bc34c1..3d31343 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -10,223 +10,200 @@
   See the License for more information.
 ============================================================================*/
 #include "cmXCodeObject.h"
+
 #include "cmSystemTools.h"
 
 #include <CoreFoundation/CoreFoundation.h> // CFUUIDCreate
 
-//----------------------------------------------------------------------------
 const char* cmXCodeObject::PBXTypeNames[] = {
-    "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase",
-    "PBXSourcesBuildPhase", "PBXFrameworksBuildPhase", "PBXNativeTarget",
-    "PBXFileReference", "PBXBuildFile", "PBXContainerItemProxy",
-    "PBXTargetDependency", "PBXShellScriptBuildPhase",
-    "PBXResourcesBuildPhase", "PBXApplicationReference",
-    "PBXExecutableFileReference", "PBXLibraryReference", "PBXToolTarget",
-    "PBXLibraryTarget", "PBXAggregateTarget", "XCBuildConfiguration",
-    "XCConfigurationList",
-    "PBXCopyFilesBuildPhase",
-    "None"
-  };
+  /* clang-format needs this comment to break after the opening brace */
+  "PBXGroup",
+  "PBXBuildStyle",
+  "PBXProject",
+  "PBXHeadersBuildPhase",
+  "PBXSourcesBuildPhase",
+  "PBXFrameworksBuildPhase",
+  "PBXNativeTarget",
+  "PBXFileReference",
+  "PBXBuildFile",
+  "PBXContainerItemProxy",
+  "PBXTargetDependency",
+  "PBXShellScriptBuildPhase",
+  "PBXResourcesBuildPhase",
+  "PBXApplicationReference",
+  "PBXExecutableFileReference",
+  "PBXLibraryReference",
+  "PBXToolTarget",
+  "PBXLibraryTarget",
+  "PBXAggregateTarget",
+  "XCBuildConfiguration",
+  "XCConfigurationList",
+  "PBXCopyFilesBuildPhase",
+  "None"
+};
 
-//----------------------------------------------------------------------------
 cmXCodeObject::~cmXCodeObject()
 {
   this->Version = 15;
 }
 
-//----------------------------------------------------------------------------
 cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
 {
   this->Version = 15;
   this->Target = 0;
-  this->Object =0;
+  this->Object = 0;
 
   this->IsA = ptype;
 
-  if(type == OBJECT)
-    {
+  if (type == OBJECT) {
     // Set the Id of an Xcode object to a unique string for each instance.
     // However the Xcode user file references certain Ids: for those cases,
     // override the generated Id using SetId().
     //
-    char cUuid[40] = {0};
+    char cUuid[40] = { 0 };
     CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
     CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid);
     CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8);
     this->Id = cUuid;
     CFRelease(s);
     CFRelease(uuid);
-    }
-  else
-    {
+  } else {
     this->Id =
       "Temporary cmake object, should not be referred to in Xcode file";
-    }
+  }
 
   cmSystemTools::ReplaceString(this->Id, "-", "");
-  if(this->Id.size() > 24)
-    {
+  if (this->Id.size() > 24) {
     this->Id = this->Id.substr(0, 24);
-    }
+  }
 
   this->TypeValue = type;
-  if(this->TypeValue == OBJECT)
-    {
+  if (this->TypeValue == OBJECT) {
     this->AddAttribute("isa", 0);
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmXCodeObject::Indent(int level, std::ostream& out)
 {
-  while(level)
-    {
+  while (level) {
     out << "\t";
     level--;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmXCodeObject::Print(std::ostream& out)
 {
   std::string separator = "\n";
   int indentFactor = 1;
-  cmXCodeObject::Indent(2*indentFactor, out);
-  if(this->Version > 15
-     && (this->IsA == PBXFileReference || this->IsA == PBXBuildFile))
-    {
+  cmXCodeObject::Indent(2 * indentFactor, out);
+  if (this->Version > 15 &&
+      (this->IsA == PBXFileReference || this->IsA == PBXBuildFile)) {
     separator = " ";
     indentFactor = 0;
-    }
+  }
   out << this->Id;
   this->PrintComment(out);
   out << " = {";
-  if(separator == "\n")
-    {
+  if (separator == "\n") {
     out << separator;
-    }
+  }
   std::map<std::string, cmXCodeObject*>::iterator i;
-  cmXCodeObject::Indent(3*indentFactor, out);
-  out << "isa = " << PBXTypeNames[this->IsA]  << ";" << separator;
-  for(i = this->ObjectAttributes.begin();
-      i != this->ObjectAttributes.end(); ++i)
-    {
-    cmXCodeObject* object = i->second;
-    if(i->first != "isa")
-      {
-      cmXCodeObject::Indent(3*indentFactor, out);
-      }
-    else
-      {
+  cmXCodeObject::Indent(3 * indentFactor, out);
+  out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator;
+  for (i = this->ObjectAttributes.begin(); i != this->ObjectAttributes.end();
+       ++i) {
+    if (i->first == "isa")
       continue;
+
+    PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this);
+  }
+  cmXCodeObject::Indent(2 * indentFactor, out);
+  out << "};\n";
+}
+
+void cmXCodeObject::PrintAttribute(std::ostream& out, const int level,
+                                   const std::string separator,
+                                   const int factor, const std::string& name,
+                                   const cmXCodeObject* object,
+                                   const cmXCodeObject* parent)
+{
+  cmXCodeObject::Indent(level * factor, out);
+  switch (object->TypeValue) {
+    case OBJECT_LIST: {
+      out << name << " = (";
+      if (parent->TypeValue != ATTRIBUTE_GROUP) {
+        out << separator;
       }
-    if(object->TypeValue == OBJECT_LIST)
-      {
-      out << i->first << " = (" << separator;
-      for(unsigned int k = 0; k < i->second->List.size(); k++)
-        {
-        cmXCodeObject::Indent(4*indentFactor, out);
-        out << i->second->List[k]->Id;
-        i->second->List[k]->PrintComment(out);
-        out << "," << separator;
+      for (unsigned int i = 0; i < object->List.size(); ++i) {
+        if (object->List[i]->TypeValue == STRING) {
+          object->List[i]->PrintString(out);
+          if (i + 1 < object->List.size()) {
+            out << ",";
+          }
+        } else {
+          cmXCodeObject::Indent((level + 1) * factor, out);
+          out << object->List[i]->Id;
+          object->List[i]->PrintComment(out);
+          out << "," << separator;
         }
-      cmXCodeObject::Indent(3*indentFactor, out);
-      out << ");" << separator;
       }
-    else if(object->TypeValue == ATTRIBUTE_GROUP)
-      {
-      std::map<std::string, cmXCodeObject*>::iterator j;
-      out << i->first << " = {";
-      if(separator == "\n")
-        {
-        out << separator;
-        }
-      for(j = object->ObjectAttributes.begin(); j !=
-            object->ObjectAttributes.end(); ++j)
-        {
-        cmXCodeObject::Indent(4 *indentFactor, out);
-
-        if(j->second->TypeValue == STRING)
-          {
-          cmXCodeObject::PrintString(out,j->first);
-          out << " = ";
-          j->second->PrintString(out);
-          out << ";";
-          }
-        else if(j->second->TypeValue == OBJECT_LIST)
-          {
-          cmXCodeObject::PrintString(out,j->first);
-          out << " = (";
-          for(unsigned int k = 0; k < j->second->List.size(); k++)
-            {
-            if(j->second->List[k]->TypeValue == STRING)
-              {
-              j->second->List[k]->PrintString(out);
-              out << ", ";
-              }
-            else
-              {
-              out << "List_" << k << "_TypeValue_IS_NOT_STRING, ";
-              }
-            }
-          out << ");";
-          }
-        else
-          {
-          cmXCodeObject::PrintString(out,j->first);
-          out << " = error_unexpected_TypeValue_" <<
-            j->second->TypeValue << ";";
-          }
+      if (parent->TypeValue != ATTRIBUTE_GROUP) {
+        cmXCodeObject::Indent(level * factor, out);
+      }
+      out << ");" << separator;
+    } break;
 
+    case ATTRIBUTE_GROUP: {
+      out << name << " = {";
+      if (separator == "\n") {
         out << separator;
-        }
-      cmXCodeObject::Indent(3 *indentFactor, out);
-      out << "};" << separator;
       }
-    else if(object->TypeValue == OBJECT_REF)
-      {
-      cmXCodeObject::PrintString(out,i->first);
+      std::map<std::string, cmXCodeObject*>::const_iterator i;
+      for (i = object->ObjectAttributes.begin();
+           i != object->ObjectAttributes.end(); ++i) {
+        PrintAttribute(out, (level + 1) * factor, separator, factor, i->first,
+                       i->second, object);
+      }
+      cmXCodeObject::Indent(level * factor, out);
+      out << "};" << separator;
+    } break;
+
+    case OBJECT_REF: {
+      cmXCodeObject::PrintString(out, name);
       out << " = " << object->Object->Id;
-      if(object->Object->HasComment() && i->first != "remoteGlobalIDString")
-        {
+      if (object->Object->HasComment() && name != "remoteGlobalIDString") {
         object->Object->PrintComment(out);
-        }
-      out << ";" << separator;
       }
-    else if(object->TypeValue == STRING)
-      {
-      cmXCodeObject::PrintString(out,i->first);
+      out << ";" << separator;
+    } break;
+
+    case STRING: {
+      cmXCodeObject::PrintString(out, name);
       out << " = ";
       object->PrintString(out);
       out << ";" << separator;
-      }
-    else
-      {
-      out << "what is this?? " << i->first << "\n";
-      }
+    } break;
+
+    default: {
+      break;
     }
-  cmXCodeObject::Indent(2*indentFactor, out);
-  out << "};\n";
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
                               std::ostream& out)
 {
   cmXCodeObject::Indent(1, out);
   out << "objects = {\n";
-  for(unsigned int i = 0; i < objs.size(); ++i)
-    {
-    if(objs[i]->TypeValue == OBJECT)
-      {
+  for (unsigned int i = 0; i < objs.size(); ++i) {
+    if (objs[i]->TypeValue == OBJECT) {
       objs[i]->Print(out);
-      }
     }
+  }
   cmXCodeObject::Indent(1, out);
   out << "};\n";
 }
 
-//----------------------------------------------------------------------------
 void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
 {
   this->ObjectAttributes = copy->ObjectAttributes;
@@ -235,42 +212,35 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
   this->Object = copy->Object;
 }
 
-//----------------------------------------------------------------------------
-void cmXCodeObject::PrintString(std::ostream& os,std::string 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.
-  bool needQuote =
-    (String.empty() ||
-     String.find("//") != String.npos ||
-     String.find_first_not_of(
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz"
-       "0123456789"
-       "$_./") != String.npos);
-  const char* quote = needQuote? "\"" : "";
+  bool needQuote = (String.empty() || String.find("//") != String.npos ||
+                    String.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                             "abcdefghijklmnopqrstuvwxyz"
+                                             "0123456789"
+                                             "$_./") != String.npos);
+  const char* quote = needQuote ? "\"" : "";
 
   // Print the string, quoted and escaped as necessary.
   os << quote;
-  for(std::string::const_iterator i = String.begin();
-      i != String.end(); ++i)
-    {
-    if(*i == '"' || *i == '\\')
-      {
+  for (std::string::const_iterator i = String.begin(); i != String.end();
+       ++i) {
+    if (*i == '"' || *i == '\\') {
       // Escape double-quotes and backslashes.
       os << '\\';
-      }
-    os << *i;
     }
+    os << *i;
+  }
   os << quote;
 }
 
 void cmXCodeObject::PrintString(std::ostream& os) const
 {
-  cmXCodeObject::PrintString(os,this->String);
+  cmXCodeObject::PrintString(os, this->String);
 }
 
-//----------------------------------------------------------------------------
 void cmXCodeObject::SetString(const std::string& s)
 {
   this->String = s;
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index bd0f43f..d2f7cb7 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -13,136 +13,135 @@
 #define cmXCodeObject_h
 
 #include "cmStandardIncludes.h"
+
 class cmGeneratorTarget;
 
 class cmXCodeObject
 {
 public:
-  enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT };
-  enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase,
-                 PBXSourcesBuildPhase, PBXFrameworksBuildPhase,
-                 PBXNativeTarget, PBXFileReference, PBXBuildFile,
-                 PBXContainerItemProxy, PBXTargetDependency,
-                 PBXShellScriptBuildPhase, PBXResourcesBuildPhase,
-                 PBXApplicationReference, PBXExecutableFileReference,
-                 PBXLibraryReference, PBXToolTarget, PBXLibraryTarget,
-                 PBXAggregateTarget,XCBuildConfiguration,XCConfigurationList,
-                 PBXCopyFilesBuildPhase,
-                 None
+  enum Type
+  {
+    OBJECT_LIST,
+    STRING,
+    ATTRIBUTE_GROUP,
+    OBJECT_REF,
+    OBJECT
+  };
+  enum PBXType
+  {
+    PBXGroup,
+    PBXBuildStyle,
+    PBXProject,
+    PBXHeadersBuildPhase,
+    PBXSourcesBuildPhase,
+    PBXFrameworksBuildPhase,
+    PBXNativeTarget,
+    PBXFileReference,
+    PBXBuildFile,
+    PBXContainerItemProxy,
+    PBXTargetDependency,
+    PBXShellScriptBuildPhase,
+    PBXResourcesBuildPhase,
+    PBXApplicationReference,
+    PBXExecutableFileReference,
+    PBXLibraryReference,
+    PBXToolTarget,
+    PBXLibraryTarget,
+    PBXAggregateTarget,
+    XCBuildConfiguration,
+    XCConfigurationList,
+    PBXCopyFilesBuildPhase,
+    None
+  };
+  class StringVec : public std::vector<std::string>
+  {
   };
-  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;}
+  Type GetType() { return this->TypeValue; }
+  PBXType GetIsA() { return this->IsA; }
 
   void SetString(const std::string& s);
-  const std::string& GetString()
-    {
-      return this->String;
-    }
+  const std::string& GetString() { return this->String; }
 
   void AddAttribute(const std::string& name, cmXCodeObject* value)
-    {
-      this->ObjectAttributes[name] = value;
-    }
+  {
+    this->ObjectAttributes[name] = value;
+  }
 
-  void SetObject(cmXCodeObject* value)
-    {
-      this->Object = value;
-    }
-  cmXCodeObject* GetObject()
-    {
-      return this->Object;
-    }
-  void AddObject(cmXCodeObject* value)
-    {
-      this->List.push_back(value);
-    }
+  void SetObject(cmXCodeObject* value) { this->Object = value; }
+  cmXCodeObject* GetObject() { return this->Object; }
+  void AddObject(cmXCodeObject* value) { this->List.push_back(value); }
   bool HasObject(cmXCodeObject* o)
   {
-    return !(std::find(this->List.begin(), this->List.end(), o)
-             == this->List.end());
+    return !(std::find(this->List.begin(), this->List.end(), o) ==
+             this->List.end());
   }
   void AddUniqueObject(cmXCodeObject* value)
   {
-    if(std::find(this->List.begin(), this->List.end(), value)
-       == this->List.end())
-      {
+    if (std::find(this->List.begin(), this->List.end(), value) ==
+        this->List.end()) {
       this->List.push_back(value);
-      }
+    }
   }
   static void Indent(int level, std::ostream& out);
   void Print(std::ostream& out);
+  void PrintAttribute(std::ostream& out, const int level,
+                      const std::string separator, const int factor,
+                      const std::string& name, const cmXCodeObject* object,
+                      const cmXCodeObject* parent);
   virtual void PrintComment(std::ostream&) {}
 
-  static void PrintList(std::vector<cmXCodeObject*> const&,
-                        std::ostream& out);
-  const std::string& GetId()
-    {
-      return this->Id;
-    }
-  void SetId(const std::string& id)
-    {
-      this->Id = id;
-    }
-  cmGeneratorTarget* GetTarget()
-    {
-      return this->Target;
-    }
-  void SetTarget(cmGeneratorTarget* t)
-    {
-      this->Target = t;
-    }
-  const std::string& GetComment() {return this->Comment;}
-  bool HasComment() { return (!this->Comment.empty());}
+  static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out);
+  const std::string& GetId() { return this->Id; }
+  void SetId(const std::string& id) { this->Id = id; }
+  cmGeneratorTarget* GetTarget() { return this->Target; }
+  void SetTarget(cmGeneratorTarget* t) { this->Target = t; }
+  const std::string& GetComment() { return this->Comment; }
+  bool HasComment() { return (!this->Comment.empty()); }
   cmXCodeObject* GetObject(const char* name)
-    {
-      if(this->ObjectAttributes.count(name))
-        {
-        return this->ObjectAttributes[name];
-        }
-      return 0;
+  {
+    if (this->ObjectAttributes.count(name)) {
+      return this->ObjectAttributes[name];
     }
+    return 0;
+  }
   // search the attribute list for an object of the specified type
   cmXCodeObject* GetObject(cmXCodeObject::PBXType t)
-    {
-      for(std::vector<cmXCodeObject*>::iterator i = this->List.begin();
-          i != this->List.end(); ++i)
-        {
-        cmXCodeObject* o = *i;
-        if(o->IsA == t)
-          {
-          return o;
-          }
-        }
-      return 0;
+  {
+    for (std::vector<cmXCodeObject*>::iterator i = this->List.begin();
+         i != this->List.end(); ++i) {
+      cmXCodeObject* o = *i;
+      if (o->IsA == t) {
+        return o;
+      }
     }
+    return 0;
+  }
 
-  void CopyAttributes(cmXCodeObject* );
+  void CopyAttributes(cmXCodeObject*);
 
-  void AddDependLibrary(const std::string& configName,
-                        const std::string& l)
-    {
-      this->DependLibraries[configName].push_back(l);
-    }
+  void AddDependLibrary(const std::string& configName, const std::string& l)
+  {
+    this->DependLibraries[configName].push_back(l);
+  }
   std::map<std::string, StringVec> const& GetDependLibraries()
-    {
-      return this->DependLibraries;
-    }
-  void AddDependTarget(const std::string& configName,
-                       const std::string& tName)
-    {
-      this->DependTargets[configName].push_back(tName);
-    }
+  {
+    return this->DependLibraries;
+  }
+  void AddDependTarget(const std::string& configName, const std::string& tName)
+  {
+    this->DependTargets[configName].push_back(tName);
+  }
   std::map<std::string, StringVec> const& GetDependTargets()
-    {
+  {
     return this->DependTargets;
-    }
-  std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
-  void SetComment(const std::string& c) { this->Comment = c;}
-  static void PrintString(std::ostream& os,std::string String);
+  }
+  std::vector<cmXCodeObject*> const& GetObjectList() { return this->List; }
+  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;
 
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index 1d3e0e9..5e06d36 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -10,12 +10,12 @@
   See the License for more information.
 ============================================================================*/
 #include "cmXMLParser.h"
+
 #include <cmsys/FStream.hxx>
 
 #include <cm_expat.h>
 #include <ctype.h>
 
-//----------------------------------------------------------------------------
 cmXMLParser::cmXMLParser()
 {
   this->Parser = 0;
@@ -24,56 +24,47 @@ cmXMLParser::cmXMLParser()
   this->ReportCallbackData = 0;
 }
 
-//----------------------------------------------------------------------------
 cmXMLParser::~cmXMLParser()
 {
-  if ( this->Parser )
-    {
+  if (this->Parser) {
     this->CleanupParser();
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::Parse(const char* string)
 {
   return (int)this->InitializeParser() &&
-    this->ParseChunk(string, strlen(string)) &&
-    this->CleanupParser();
+    this->ParseChunk(string, strlen(string)) && this->CleanupParser();
 }
 
 int cmXMLParser::ParseFile(const char* file)
 {
-  if ( !file )
-    {
+  if (!file) {
     return 0;
-    }
+  }
 
   cmsys::ifstream ifs(file);
-  if ( !ifs )
-    {
+  if (!ifs) {
     return 0;
-    }
+  }
 
   std::ostringstream str;
   str << ifs.rdbuf();
   return this->Parse(str.str().c_str());
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::InitializeParser()
 {
-  if ( this->Parser )
-    {
+  if (this->Parser) {
     std::cerr << "Parser already initialized" << std::endl;
     this->ParseError = 1;
     return 0;
-    }
+  }
 
   // Create the expat XML parser.
   this->Parser = XML_ParserCreate(0);
   XML_SetElementHandler(static_cast<XML_Parser>(this->Parser),
-                        &cmXMLParserStartElement,
-                        &cmXMLParserEndElement);
+                        &cmXMLParserStartElement, &cmXMLParserEndElement);
   XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
                               &cmXMLParserCharacterDataHandler);
   XML_SetUserData(static_cast<XML_Parser>(this->Parser), this);
@@ -81,44 +72,37 @@ int cmXMLParser::InitializeParser()
   return 1;
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::ParseChunk(const char* inputString,
                             std::string::size_type length)
 {
-  if ( !this->Parser )
-    {
+  if (!this->Parser) {
     std::cerr << "Parser not initialized" << std::endl;
     this->ParseError = 1;
     return 0;
-    }
+  }
   int res;
   res = this->ParseBuffer(inputString, length);
-  if ( res == 0 )
-    {
+  if (res == 0) {
     this->ParseError = 1;
-    }
+  }
   return res;
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::CleanupParser()
 {
-  if ( !this->Parser )
-    {
+  if (!this->Parser) {
     std::cerr << "Parser not initialized" << std::endl;
     this->ParseError = 1;
     return 0;
-    }
+  }
   int result = !this->ParseError;
-  if(result)
-    {
+  if (result) {
     // Tell the expat XML parser about the end-of-input.
-    if(!XML_Parse(static_cast<XML_Parser>(this->Parser), "", 0, 1))
-      {
+    if (!XML_Parse(static_cast<XML_Parser>(this->Parser), "", 0, 1)) {
       this->ReportXmlParseError();
       result = 0;
-      }
     }
+  }
 
   // Clean up the parser.
   XML_ParserFree(static_cast<XML_Parser>(this->Parser));
@@ -127,77 +111,62 @@ int cmXMLParser::CleanupParser()
   return result;
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::ParseBuffer(const char* buffer, std::string::size_type count)
 {
   // Pass the buffer to the expat XML parser.
-  if(!XML_Parse(static_cast<XML_Parser>(this->Parser), buffer,
-                static_cast<int>(count), 0))
-    {
+  if (!XML_Parse(static_cast<XML_Parser>(this->Parser), buffer,
+                 static_cast<int>(count), 0)) {
     this->ReportXmlParseError();
     return 0;
-    }
+  }
   return 1;
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::ParseBuffer(const char* buffer)
 {
   return this->ParseBuffer(buffer, static_cast<int>(strlen(buffer)));
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::ParsingComplete()
 {
   // Default behavior is to parse to end of stream.
   return 0;
 }
 
-//----------------------------------------------------------------------------
-void cmXMLParser::StartElement(const std::string& name,
-  const char ** /*atts*/)
+void cmXMLParser::StartElement(const std::string& name, const char** /*atts*/)
 {
   std::cout << "Start element: " << name << std::endl;
 }
 
-//----------------------------------------------------------------------------
 void cmXMLParser::EndElement(const std::string& name)
 {
   std::cout << "End element: " << name << std::endl;
 }
 
-//----------------------------------------------------------------------------
 void cmXMLParser::CharacterDataHandler(const char* /*inData*/,
-  int /*inLength*/)
+                                       int /*inLength*/)
 {
 }
 
-//----------------------------------------------------------------------------
 int cmXMLParser::IsSpace(char c)
 {
   return isspace(c);
 }
 
-//----------------------------------------------------------------------------
 const char* cmXMLParser::FindAttribute(const char** atts,
                                        const char* attribute)
 {
-  if(atts && attribute)
-    {
-    for(const char** a = atts; *a && *(a+1); a += 2)
-      {
-      if(strcmp(*a, attribute) == 0)
-        {
-        return *(a+1);
-        }
+  if (atts && attribute) {
+    for (const char** a = atts; *a && *(a + 1); a += 2) {
+      if (strcmp(*a, attribute) == 0) {
+        return *(a + 1);
       }
     }
+  }
   return 0;
 }
 
-//----------------------------------------------------------------------------
-void cmXMLParserStartElement(void* parser, const char *name,
-                              const char **atts)
+void cmXMLParserStartElement(void* parser, const char* name, const char** atts)
 {
   // Begin element handler that is registered with the XML_Parser.
   // This just casts the user data to a cmXMLParser and calls
@@ -205,17 +174,15 @@ void cmXMLParserStartElement(void* parser, const char *name,
   static_cast<cmXMLParser*>(parser)->StartElement(name, atts);
 }
 
-//----------------------------------------------------------------------------
-void cmXMLParserEndElement(void* parser, const char *name)
+void cmXMLParserEndElement(void* parser, const char* name)
 {
   // End element handler that is registered with the XML_Parser.  This
   // just casts the user data to a cmXMLParser and calls EndElement.
   static_cast<cmXMLParser*>(parser)->EndElement(name);
 }
 
-//----------------------------------------------------------------------------
 void cmXMLParserCharacterDataHandler(void* parser, const char* data,
-                                      int length)
+                                     int length)
 {
   // Character data handler that is registered with the XML_Parser.
   // This just casts the user data to a cmXMLParser and calls
@@ -223,7 +190,6 @@ void cmXMLParserCharacterDataHandler(void* parser, const char* data,
   static_cast<cmXMLParser*>(parser)->CharacterDataHandler(data, length);
 }
 
-//----------------------------------------------------------------------------
 void cmXMLParser::ReportXmlParseError()
 {
   XML_Parser parser = static_cast<XML_Parser>(this->Parser);
@@ -232,16 +198,12 @@ void cmXMLParser::ReportXmlParseError()
                     XML_ErrorString(XML_GetErrorCode(parser)));
 }
 
-//----------------------------------------------------------------------------
 void cmXMLParser::ReportError(int line, int, const char* msg)
 {
-  if(this->ReportCallback)
-    {
+  if (this->ReportCallback) {
     this->ReportCallback(line, msg, this->ReportCallbackData);
-    }
-  else
-    {
-    std::cerr << "Error parsing XML in stream at line "
-              << line << ": " << msg << std::endl;
-    }
+  } else {
+    std::cerr << "Error parsing XML in stream at line " << line << ": " << msg
+              << std::endl;
+  }
 }
diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h
index e72da66..6aae81d 100644
--- a/Source/cmXMLParser.h
+++ b/Source/cmXMLParser.h
@@ -14,11 +14,10 @@
 
 #include "cmStandardIncludes.h"
 
-extern "C"
-{
-  void cmXMLParserStartElement(void*, const char*, const char**);
-  void cmXMLParserEndElement(void*, const char*);
-  void cmXMLParserCharacterDataHandler(void*, const char*, int);
+extern "C" {
+void cmXMLParserStartElement(void*, const char*, const char**);
+void cmXMLParserEndElement(void*, const char*);
+void cmXMLParserCharacterDataHandler(void*, const char*, int);
 }
 
 /** \class cmXMLParser
@@ -52,18 +51,19 @@ public:
   virtual int CleanupParser();
   typedef void (*ReportFunction)(int, const char*, void*);
   void SetErrorCallback(ReportFunction f, void* d)
-    {
-      this->ReportCallback = f;
-      this->ReportCallbackData = d;
-    }
+  {
+    this->ReportCallback = f;
+    this->ReportCallbackData = d;
+  }
+
 protected:
   //! This variable is true if there was a parse error while parsing in
-  //chunks.
+  // chunks.
   int ParseError;
   ReportFunction ReportCallback;
   void* ReportCallbackData;
 
-  //1 Expat parser structure.  Exists only during call to Parse().
+  // 1 Expat parser structure.  Exists only during call to Parse().
   void* Parser;
 
   /**
@@ -84,7 +84,7 @@ protected:
   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.
+  // StartElement was called.
   virtual void EndElement(const std::string& name);
 
   //! Called when there is character data to handle.
@@ -101,8 +101,7 @@ protected:
   static int IsSpace(char c);
 
   //! Send the given buffer to the XML parser.
-  virtual int ParseBuffer(const char* buffer,
-                          std::string::size_type length);
+  virtual int ParseBuffer(const char* buffer, std::string::size_type length);
 
   //! Send the given c-style string to the XML parser.
   int ParseBuffer(const char* buffer);
diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx
index 4ad05ca..f899f57 100644
--- a/Source/cmXMLSafe.cxx
+++ b/Source/cmXMLSafe.cxx
@@ -16,33 +16,29 @@
 #include <iostream>
 #include <sstream>
 
-#include <string.h>
 #include <stdio.h>
+#include <string.h>
 
-//----------------------------------------------------------------------------
-cmXMLSafe::cmXMLSafe(const char* s):
-  Data(s),
-  Size(static_cast<unsigned long>(strlen(s))),
-  DoQuotes(true)
+cmXMLSafe::cmXMLSafe(const char* s)
+  : Data(s)
+  , Size(static_cast<unsigned long>(strlen(s)))
+  , DoQuotes(true)
 {
 }
 
-//----------------------------------------------------------------------------
-cmXMLSafe::cmXMLSafe(std::string const& s):
-    Data(s.c_str()),
-    Size(static_cast<unsigned long>(s.length())),
-    DoQuotes(true)
+cmXMLSafe::cmXMLSafe(std::string const& s)
+  : Data(s.c_str())
+  , Size(static_cast<unsigned long>(s.length()))
+  , DoQuotes(true)
 {
 }
 
-//----------------------------------------------------------------------------
 cmXMLSafe& cmXMLSafe::Quotes(bool b)
 {
   this->DoQuotes = b;
   return *this;
 }
 
-//----------------------------------------------------------------------------
 std::string cmXMLSafe::str()
 {
   std::ostringstream ss;
@@ -50,53 +46,56 @@ std::string cmXMLSafe::str()
   return ss.str();
 }
 
-//----------------------------------------------------------------------------
 std::ostream& operator<<(std::ostream& os, cmXMLSafe const& self)
 {
   char const* first = self.Data;
   char const* last = self.Data + self.Size;
-  while(first != last)
-    {
+  while (first != last) {
     unsigned int ch;
-    if(const char* next = cm_utf8_decode_character(first, last, &ch))
-      {
+    if (const char* next = cm_utf8_decode_character(first, last, &ch)) {
       // http://www.w3.org/TR/REC-xml/#NT-Char
-      if((ch >= 0x20 && ch <= 0xD7FF) ||
-         (ch >= 0xE000 && ch <= 0xFFFD) ||
-         (ch >= 0x10000 && ch <= 0x10FFFF) ||
-          ch == 0x9 || ch == 0xA || ch == 0xD)
-        {
-        switch(ch)
-          {
+      if ((ch >= 0x20 && ch <= 0xD7FF) || (ch >= 0xE000 && ch <= 0xFFFD) ||
+          (ch >= 0x10000 && ch <= 0x10FFFF) || ch == 0x9 || ch == 0xA ||
+          ch == 0xD) {
+        switch (ch) {
           // Escape XML control characters.
-          case '&': os << "&"; break;
-          case '<': os << "<"; break;
-          case '>': os << ">"; break;
-          case '"': os << (self.DoQuotes? """ : "\""); break;
-          case '\'': os << (self.DoQuotes? "'" : "'"); break;
-          case '\r': break; // Ignore CR
+          case '&':
+            os << "&";
+            break;
+          case '<':
+            os << "<";
+            break;
+          case '>':
+            os << ">";
+            break;
+          case '"':
+            os << (self.DoQuotes ? """ : "\"");
+            break;
+          case '\'':
+            os << (self.DoQuotes ? "'" : "'");
+            break;
+          case '\r':
+            break; // Ignore CR
           // Print the UTF-8 character.
-          default: os.write(first, next-first); break;
-          }
+          default:
+            os.write(first, next - first);
+            break;
         }
-      else
-        {
+      } else {
         // Use a human-readable hex value for this invalid character.
         char buf[16];
         sprintf(buf, "%X", ch);
         os << "[NON-XML-CHAR-0x" << buf << "]";
-        }
+      }
 
       first = next;
-      }
-    else
-      {
+    } else {
       ch = static_cast<unsigned char>(*first++);
       // Use a human-readable hex value for this invalid byte.
       char buf[16];
       sprintf(buf, "%X", ch);
       os << "[NON-UTF-8-BYTE-0x" << buf << "]";
-      }
     }
+  }
   return os;
 }
diff --git a/Source/cmXMLSafe.h b/Source/cmXMLSafe.h
index ead2e01..11ced13 100644
--- a/Source/cmXMLSafe.h
+++ b/Source/cmXMLSafe.h
@@ -13,8 +13,9 @@
 #define cmXMLSafe_h
 
 #include <cmsys/Configure.hxx>
-#include <string>
+
 #include <iosfwd>
+#include <string>
 
 /** \class cmXMLSafe
  * \brief Write strings to XML with proper escapes
@@ -34,6 +35,7 @@ public:
 
   /** Get the escaped data as a string.  */
   std::string str();
+
 private:
   char const* Data;
   unsigned long Size;
diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx
index f9b3b49..98c2680 100644
--- a/Source/cmXMLWriter.cxx
+++ b/Source/cmXMLWriter.cxx
@@ -10,17 +10,18 @@
   See the License for more information.
 ============================================================================*/
 #include "cmXMLWriter.h"
+
 #include "cmXMLSafe.h"
 
 #include <cassert>
 #include <fstream>
 
 cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level)
-: Output(output)
-, Level(level)
-, ElementOpen(false)
-, BreakAttrib(false)
-, IsContent(false)
+  : Output(output)
+  , Level(level)
+  , ElementOpen(false)
+  , BreakAttrib(false)
+  , IsContent(false)
 {
 }
 
@@ -53,20 +54,24 @@ void cmXMLWriter::StartElement(std::string const& name)
 void cmXMLWriter::EndElement()
 {
   assert(!this->Elements.empty());
-  if (this->ElementOpen)
-    {
+  if (this->ElementOpen) {
     this->Output << "/>";
-    }
-  else
-    {
+  } else {
     this->ConditionalLineBreak(!this->IsContent, this->Elements.size() - 1);
     this->IsContent = false;
     this->Output << "</" << this->Elements.top() << '>';
-    }
+  }
   this->Elements.pop();
   this->ElementOpen = false;
 }
 
+void cmXMLWriter::Element(const char* name)
+{
+  this->CloseStartElement();
+  this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+  this->Output << '<' << name << "/>";
+}
+
 void cmXMLWriter::BreakAttributes()
 {
   this->BreakAttrib = true;
@@ -85,6 +90,13 @@ void cmXMLWriter::CData(std::string const& data)
   this->Output << "<![CDATA[" << data << "]]>";
 }
 
+void cmXMLWriter::Doctype(const char* doctype)
+{
+  this->CloseStartElement();
+  this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+  this->Output << "<!DOCTYPE " << doctype << ">";
+}
+
 void cmXMLWriter::ProcessingInstruction(const char* target, const char* data)
 {
   this->CloseStartElement();
@@ -101,20 +113,18 @@ void cmXMLWriter::FragmentFile(const char* fname)
 
 void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent)
 {
-  if (condition)
-    {
+  if (condition) {
     this->Output << '\n' << std::string(indent + this->Level, '\t');
-    }
+  }
 }
 
 void cmXMLWriter::PreAttribute()
 {
   assert(this->ElementOpen);
   this->ConditionalLineBreak(this->BreakAttrib, this->Elements.size());
-  if (!this->BreakAttrib)
-    {
+  if (!this->BreakAttrib) {
     this->Output << ' ';
-    }
+  }
 }
 
 void cmXMLWriter::PreContent()
@@ -125,10 +135,9 @@ void cmXMLWriter::PreContent()
 
 void cmXMLWriter::CloseStartElement()
 {
-  if (this->ElementOpen)
-    {
+  if (this->ElementOpen) {
     this->ConditionalLineBreak(this->BreakAttrib, this->Elements.size());
     this->Output << '>';
     this->ElementOpen = false;
-    }
+  }
 }
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index c38c0de..8a88dd4 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -13,6 +13,7 @@
 #define cmXMLWiter_h
 
 #include "cmStandardIncludes.h"
+
 #include "cmXMLSafe.h"
 
 #include <ostream>
@@ -36,30 +37,34 @@ public:
 
   template <typename T>
   void Attribute(const char* name, T const& value)
-    {
+  {
     this->PreAttribute();
     this->Output << name << "=\"" << SafeAttribute(value) << '"';
-    }
+  }
+
+  void Element(const char* name);
 
   template <typename T>
   void Element(std::string const& name, T const& value)
-    {
+  {
     this->StartElement(name);
     this->Content(value);
     this->EndElement();
-    }
+  }
 
   template <typename T>
   void Content(T const& content)
-    {
+  {
     this->PreContent();
     this->Output << SafeContent(content);
-    }
+  }
 
   void Comment(const char* comment);
 
   void CData(std::string const& data);
 
+  void Doctype(const char* doctype);
+
   void ProcessingInstruction(const char* target, const char* data);
 
   void FragmentFile(const char* fname);
@@ -77,36 +82,36 @@ private:
 
 private:
   static cmXMLSafe SafeAttribute(const char* value)
-    {
+  {
     return cmXMLSafe(value);
-    }
+  }
 
   static cmXMLSafe SafeAttribute(std::string const& value)
-    {
+  {
     return cmXMLSafe(value);
-    }
+  }
 
   template <typename T>
   static T SafeAttribute(T value)
-    {
+  {
     return value;
-    }
+  }
 
   static cmXMLSafe SafeContent(const char* value)
-    {
+  {
     return cmXMLSafe(value).Quotes(false);
-    }
+  }
 
   static cmXMLSafe SafeContent(std::string const& value)
-    {
+  {
     return cmXMLSafe(value).Quotes(false);
-    }
+  }
 
   template <typename T>
   static T SafeContent(T value)
-    {
+  {
     return value;
-    }
+  }
 
 private:
   std::ostream& Output;
diff --git a/Source/cm_get_date.h b/Source/cm_get_date.h
index d5f6d3e..3045775 100644
--- a/Source/cm_get_date.h
+++ b/Source/cm_get_date.h
@@ -19,7 +19,7 @@ extern "C" {
 #endif
 
 /** Parse a date/time string.  Treat relative times with respect to 'now'. */
-time_t cm_get_date(time_t now, const char *str);
+time_t cm_get_date(time_t now, const char* str);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c
index c9bf259..2352507 100644
--- a/Source/cm_utf8.c
+++ b/Source/cm_utf8.c
@@ -25,60 +25,62 @@
 
 /* Number of leading ones before a zero in the byte.  */
 static unsigned char const cm_utf8_ones[256] = {
-  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
-  3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+  3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8
 };
 
 /* Mask away control bits from bytes with n leading ones.  */
-static unsigned char const cm_utf8_mask[7] = {
-  0xEF, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01
-};
+static unsigned char const cm_utf8_mask[7] = { 0xEF, 0x3F, 0x1F, 0x0F,
+                                               0x07, 0x03, 0x01 };
 
 /* Minimum allowed value when first byte has n leading ones.  */
 static unsigned int const cm_utf8_min[7] = {
-  0, 0, 1u<<7, 1u<<11, 1u<<16, 1u<<21, 1u<<26 /*, 1u<<31 */
+  0, 0, 1u << 7, 1u << 11, 1u << 16, 1u << 21, 1u << 26 /*, 1u<<31 */
 };
 
-/*--------------------------------------------------------------------------*/
 const char* cm_utf8_decode_character(const char* first, const char* last,
                                      unsigned int* pc)
 {
   /* Count leading ones in the first byte.  */
   unsigned char c = (unsigned char)*first++;
   unsigned char const ones = cm_utf8_ones[c];
-  switch(ones)
-    {
-    case 0: *pc = c; return first;    /* One-byte character.  */
-    case 1: case 7: case 8: return 0; /* Invalid leading byte.  */
-    default: break;
-    }
+  switch (ones) {
+    case 0:
+      *pc = c;
+      return first; /* One-byte character.  */
+    case 1:
+    case 7:
+    case 8:
+      return 0; /* Invalid leading byte.  */
+    default:
+      break;
+  }
 
   /* Extract bits from this multi-byte character.  */
   {
-  unsigned int uc = c & cm_utf8_mask[ones];
-  int left;
-  for(left = ones-1; left && first != last; --left)
-    {
-    c = (unsigned char)*first++;
-    if(cm_utf8_ones[c] != 1)
-      {
-      return 0;
+    unsigned int uc = c & cm_utf8_mask[ones];
+    int left;
+    for (left = ones - 1; left && first != last; --left) {
+      c = (unsigned char)*first++;
+      if (cm_utf8_ones[c] != 1) {
+        return 0;
       }
-    uc = (uc << 6) | (c & cm_utf8_mask[1]);
+      uc = (uc << 6) | (c & cm_utf8_mask[1]);
     }
 
-  if(left > 0 || uc < cm_utf8_min[ones])
-    {
-    return 0;
+    if (left > 0 || uc < cm_utf8_min[ones]) {
+      return 0;
     }
 
-  *pc = uc;
-  return first;
+    *pc = uc;
+    return first;
   }
 }
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8f6b952..89ea955 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -10,101 +10,101 @@
   See the License for more information.
 ============================================================================*/
 #include "cmake.h"
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
-#include "cmExternalMakefileProjectGenerator.h"
-#include "cmCommands.h"
+
+#include "cmAlgorithms.h"
 #include "cmCommand.h"
+#include "cmCommands.h"
+#include "cmDocumentationFormatter.h"
+#include "cmExternalMakefileProjectGenerator.h"
 #include "cmFileTimeComparison.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
 #include "cmSourceFile.h"
-#include "cmTest.h"
-#include "cmDocumentationFormatter.h"
-#include "cmAlgorithms.h"
 #include "cmState.h"
+#include "cmTest.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include "cmGraphVizWriter.h"
-# include "cmVariableWatch.h"
-# include <cmsys/SystemInformation.hxx>
+#include "cmGraphVizWriter.h"
+#include "cmVariableWatch.h"
+#include <cmsys/SystemInformation.hxx>
 #endif
 
+#include <cmsys/FStream.hxx>
 #include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
-#include <cmsys/FStream.hxx>
 
 // only build kdevelop generator on non-windows platforms
 // when not bootstrapping cmake
 #if !defined(_WIN32)
-# if defined(CMAKE_BUILD_WITH_CMAKE)
-#   define CMAKE_USE_KDEVELOP
-# endif
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+#define CMAKE_USE_KDEVELOP
+#endif
 #endif
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-#  define CMAKE_USE_ECLIPSE
+#define CMAKE_USE_ECLIPSE
 #endif
 
 #if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE)
-# define CMAKE_BOOT_MINGW
+#define CMAKE_BOOT_MINGW
 #endif
 
 // include the generator
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#  if !defined(CMAKE_BOOT_MINGW)
-#    include "cmGlobalVisualStudio6Generator.h"
-#    include "cmGlobalVisualStudio7Generator.h"
-#    include "cmGlobalVisualStudio71Generator.h"
-#    include "cmGlobalVisualStudio8Generator.h"
-#    include "cmGlobalVisualStudio9Generator.h"
-#    include "cmGlobalVisualStudio10Generator.h"
-#    include "cmGlobalVisualStudio11Generator.h"
-#    include "cmGlobalVisualStudio12Generator.h"
-#    include "cmGlobalVisualStudio14Generator.h"
-#    include "cmGlobalBorlandMakefileGenerator.h"
-#    include "cmGlobalNMakeMakefileGenerator.h"
-#    include "cmGlobalJOMMakefileGenerator.h"
-#    include "cmGlobalGhsMultiGenerator.h"
-#    define CMAKE_HAVE_VS_GENERATORS
-#  endif
-#  include "cmGlobalMSYSMakefileGenerator.h"
-#  include "cmGlobalMinGWMakefileGenerator.h"
+#if !defined(CMAKE_BOOT_MINGW)
+#include "cmGlobalBorlandMakefileGenerator.h"
+#include "cmGlobalGhsMultiGenerator.h"
+#include "cmGlobalJOMMakefileGenerator.h"
+#include "cmGlobalNMakeMakefileGenerator.h"
+#include "cmGlobalVisualStudio10Generator.h"
+#include "cmGlobalVisualStudio11Generator.h"
+#include "cmGlobalVisualStudio12Generator.h"
+#include "cmGlobalVisualStudio14Generator.h"
+#include "cmGlobalVisualStudio71Generator.h"
+#include "cmGlobalVisualStudio8Generator.h"
+#include "cmGlobalVisualStudio9Generator.h"
+#define CMAKE_HAVE_VS_GENERATORS
+#endif
+#include "cmGlobalMSYSMakefileGenerator.h"
+#include "cmGlobalMinGWMakefileGenerator.h"
 #else
 #endif
 #if defined(CMAKE_USE_WMAKE)
-# include "cmGlobalWatcomWMakeGenerator.h"
+#include "cmGlobalWatcomWMakeGenerator.h"
 #endif
 #include "cmGlobalUnixMakefileGenerator3.h"
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include "cmGlobalNinjaGenerator.h"
+#include "cmGlobalNinjaGenerator.h"
 #endif
 #include "cmExtraCodeLiteGenerator.h"
 
 #if !defined(CMAKE_BOOT_MINGW)
-# include "cmExtraCodeBlocksGenerator.h"
+#include "cmExtraCodeBlocksGenerator.h"
 #endif
-#include "cmExtraSublimeTextGenerator.h"
 #include "cmExtraKateGenerator.h"
+#include "cmExtraSublimeTextGenerator.h"
 
 #ifdef CMAKE_USE_KDEVELOP
-# include "cmGlobalKdevelopGenerator.h"
+#include "cmGlobalKdevelopGenerator.h"
 #endif
 
 #ifdef CMAKE_USE_ECLIPSE
-# include "cmExtraEclipseCDT4Generator.h"
+#include "cmExtraEclipseCDT4Generator.h"
 #endif
 
 #include <stdlib.h> // required for atoi
 
-#if defined( __APPLE__ )
-#  if defined(CMAKE_BUILD_WITH_CMAKE)
-#    include "cmGlobalXCodeGenerator.h"
-#    define CMAKE_USE_XCODE 1
-#  endif
-#  include <sys/types.h>
-#  include <sys/time.h>
-#  include <sys/resource.h>
+#if defined(__APPLE__)
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+#include "cmGlobalXCodeGenerator.h"
+#define CMAKE_USE_XCODE 1
+#endif
+#include <sys/resource.h>
+#include <sys/time.h>
 #endif
 
+#include <sys/types.h>
+// include sys/stat.h after sys/types.h
 #include <sys/stat.h> // struct stat
 
 #include <list>
@@ -112,8 +112,8 @@
 static bool cmakeCheckStampFile(const char* stampName);
 static bool cmakeCheckStampList(const char* stampName);
 
-void cmWarnUnusedCliWarning(const std::string& variable,
-  int, void* ctx, const char*, const cmMakefile*)
+void cmWarnUnusedCliWarning(const std::string& variable, int, void* ctx,
+                            const char*, const cmMakefile*)
 {
   cmake* cm = reinterpret_cast<cmake*>(ctx);
   cm->MarkCliAsUsed(variable);
@@ -137,14 +137,12 @@ cmake::cmake()
 
 #ifdef __APPLE__
   struct rlimit rlp;
-  if(!getrlimit(RLIMIT_STACK, &rlp))
-    {
-    if(rlp.rlim_cur != rlp.rlim_max)
-      {
-        rlp.rlim_cur = rlp.rlim_max;
-         setrlimit(RLIMIT_STACK, &rlp);
-      }
+  if (!getrlimit(RLIMIT_STACK, &rlp)) {
+    if (rlp.rlim_cur != rlp.rlim_max) {
+      rlp.rlim_cur = rlp.rlim_max;
+      setrlimit(RLIMIT_STACK, &rlp);
     }
+  }
 #endif
 
   this->Verbose = false;
@@ -168,35 +166,34 @@ cmake::cmake()
   // these are used to find files when the extension
   // is not given
   // The "c" extension MUST precede the "C" extension.
-  this->SourceFileExtensions.push_back( "c" );
-  this->SourceFileExtensions.push_back( "C" );
-
-  this->SourceFileExtensions.push_back( "c++" );
-  this->SourceFileExtensions.push_back( "cc" );
-  this->SourceFileExtensions.push_back( "cpp" );
-  this->SourceFileExtensions.push_back( "cxx" );
-  this->SourceFileExtensions.push_back( "m" );
-  this->SourceFileExtensions.push_back( "M" );
-  this->SourceFileExtensions.push_back( "mm" );
-
-  this->HeaderFileExtensions.push_back( "h" );
-  this->HeaderFileExtensions.push_back( "hh" );
-  this->HeaderFileExtensions.push_back( "h++" );
-  this->HeaderFileExtensions.push_back( "hm" );
-  this->HeaderFileExtensions.push_back( "hpp" );
-  this->HeaderFileExtensions.push_back( "hxx" );
-  this->HeaderFileExtensions.push_back( "in" );
-  this->HeaderFileExtensions.push_back( "txx" );
+  this->SourceFileExtensions.push_back("c");
+  this->SourceFileExtensions.push_back("C");
+
+  this->SourceFileExtensions.push_back("c++");
+  this->SourceFileExtensions.push_back("cc");
+  this->SourceFileExtensions.push_back("cpp");
+  this->SourceFileExtensions.push_back("cxx");
+  this->SourceFileExtensions.push_back("m");
+  this->SourceFileExtensions.push_back("M");
+  this->SourceFileExtensions.push_back("mm");
+
+  this->HeaderFileExtensions.push_back("h");
+  this->HeaderFileExtensions.push_back("hh");
+  this->HeaderFileExtensions.push_back("h++");
+  this->HeaderFileExtensions.push_back("hm");
+  this->HeaderFileExtensions.push_back("hpp");
+  this->HeaderFileExtensions.push_back("hxx");
+  this->HeaderFileExtensions.push_back("in");
+  this->HeaderFileExtensions.push_back("txx");
 }
 
 cmake::~cmake()
 {
   delete this->State;
-  if (this->GlobalGenerator)
-    {
+  if (this->GlobalGenerator) {
     delete this->GlobalGenerator;
     this->GlobalGenerator = 0;
-    }
+  }
   cmDeleteAll(this->Generators);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   delete this->VariableWatch;
@@ -215,288 +212,227 @@ void cmake::CleanupCommandsAndMacros()
 bool cmake::SetCacheArgs(const std::vector<std::string>& args)
 {
   bool findPackageMode = false;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
+  for (unsigned int i = 1; i < args.size(); ++i) {
     std::string arg = args[i];
-    if(arg.find("-D",0) == 0)
-      {
+    if (arg.find("-D", 0) == 0) {
       std::string entry = arg.substr(2);
-      if(entry.empty())
-        {
+      if (entry.empty()) {
         ++i;
-        if(i < args.size())
-          {
+        if (i < args.size()) {
           entry = args[i];
-          }
-        else
-          {
+        } else {
           cmSystemTools::Error("-D must be followed with VAR=VALUE.");
           return false;
-          }
         }
+      }
       std::string var, value;
       cmState::CacheEntryType type = cmState::UNINITIALIZED;
-      if(cmState::ParseCacheEntry(entry, var, value, type))
-        {
+      if (cmState::ParseCacheEntry(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.
         bool haveValue = false;
         std::string cachedValue;
-        if(this->WarnUnusedCli)
-          {
-          if(const char *v = this->State->GetInitializedCacheValue(var))
-            {
+        if (this->WarnUnusedCli) {
+          if (const char* v = this->State->GetInitializedCacheValue(var)) {
             haveValue = true;
             cachedValue = v;
-            }
           }
+        }
 
         this->AddCacheEntry(var, value.c_str(),
-          "No help, variable specified on the command line.", type);
+                            "No help, variable specified on the command line.",
+                            type);
 
-        if(this->WarnUnusedCli)
-          {
+        if (this->WarnUnusedCli) {
           if (!haveValue ||
-              cachedValue != this->State->GetInitializedCacheValue(var))
-            {
+              cachedValue != this->State->GetInitializedCacheValue(var)) {
             this->WatchUnusedCli(var);
-            }
           }
         }
-      else
-        {
+      } else {
         std::cerr << "Parse error in command line argument: " << arg << "\n"
                   << "Should be: VAR:type=value\n";
         cmSystemTools::Error("No cmake script provided.");
         return false;
-        }
       }
-    else if(cmHasLiteralPrefix(arg, "-W"))
-      {
+    } else if (cmHasLiteralPrefix(arg, "-W")) {
       std::string entry = arg.substr(2);
-      if (entry.empty())
-        {
+      if (entry.empty()) {
         ++i;
-        if (i < args.size())
-          {
+        if (i < args.size()) {
           entry = args[i];
-          }
-        else
-          {
+        } else {
           cmSystemTools::Error("-W must be followed with [no-]<name>.");
           return false;
-          }
         }
+      }
 
       std::string name;
       bool foundNo = false;
       bool foundError = false;
       unsigned int nameStartPosition = 0;
 
-      if (entry.find("no-", nameStartPosition) == 0)
-        {
+      if (entry.find("no-", nameStartPosition) == 0) {
         foundNo = true;
         nameStartPosition += 3;
-        }
+      }
 
-      if (entry.find("error=", nameStartPosition) == 0)
-        {
+      if (entry.find("error=", nameStartPosition) == 0) {
         foundError = true;
         nameStartPosition += 6;
-        }
+      }
 
       name = entry.substr(nameStartPosition);
-      if (name.empty())
-        {
+      if (name.empty()) {
         cmSystemTools::Error("No warning name provided.");
         return false;
-        }
+      }
 
-      if (!foundNo && !foundError)
-        {
+      if (!foundNo && !foundError) {
         // -W<name>
-        this->DiagLevels[name] = std::max(this->DiagLevels[name],
-                                          DIAG_WARN);
-        }
-      else if (foundNo && !foundError)
-        {
-         // -Wno<name>
-         this->DiagLevels[name] = DIAG_IGNORE;
-        }
-      else if (!foundNo && foundError)
-        {
+        this->DiagLevels[name] = std::max(this->DiagLevels[name], DIAG_WARN);
+      } else if (foundNo && !foundError) {
+        // -Wno<name>
+        this->DiagLevels[name] = DIAG_IGNORE;
+      } else if (!foundNo && foundError) {
         // -Werror=<name>
         this->DiagLevels[name] = DIAG_ERROR;
-        }
-      else
-        {
+      } else {
         // -Wno-error=<name>
-        this->DiagLevels[name] = std::min(this->DiagLevels[name],
-                                          DIAG_WARN);
-        }
+        this->DiagLevels[name] = std::min(this->DiagLevels[name], DIAG_WARN);
       }
-    else if(arg.find("-U",0) == 0)
-      {
+    } else if (arg.find("-U", 0) == 0) {
       std::string entryPattern = arg.substr(2);
-      if(entryPattern.empty())
-        {
+      if (entryPattern.empty()) {
         ++i;
-        if(i < args.size())
-          {
+        if (i < args.size()) {
           entryPattern = args[i];
-          }
-        else
-          {
+        } else {
           cmSystemTools::Error("-U must be followed with VAR.");
           return false;
-          }
         }
+      }
       cmsys::RegularExpression regex(
         cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str());
-      //go through all cache entries and collect the vars which will be removed
+      // go through all cache entries and collect the vars which will be
+      // removed
       std::vector<std::string> entriesToDelete;
       std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
       for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
-            it != cacheKeys.end(); ++it)
-        {
+           it != cacheKeys.end(); ++it) {
         cmState::CacheEntryType t = this->State->GetCacheEntryType(*it);
-        if(t != cmState::STATIC)
-          {
-          if (regex.find(it->c_str()))
-            {
+        if (t != cmState::STATIC) {
+          if (regex.find(it->c_str())) {
             entriesToDelete.push_back(*it);
-            }
           }
         }
+      }
 
       // now remove them from the cache
-      for(std::vector<std::string>::const_iterator currentEntry =
-          entriesToDelete.begin();
-          currentEntry != entriesToDelete.end();
-          ++currentEntry)
-        {
+      for (std::vector<std::string>::const_iterator currentEntry =
+             entriesToDelete.begin();
+           currentEntry != entriesToDelete.end(); ++currentEntry) {
         this->State->RemoveCacheEntry(*currentEntry);
-        }
       }
-    else if(arg.find("-C",0) == 0)
-      {
+    } else if (arg.find("-C", 0) == 0) {
       std::string path = arg.substr(2);
-      if (path.empty())
-        {
+      if (path.empty()) {
         ++i;
-        if(i < args.size())
-          {
+        if (i < args.size()) {
           path = args[i];
-          }
-        else
-          {
+        } else {
           cmSystemTools::Error("-C must be followed by a file name.");
           return false;
-          }
         }
+      }
       std::cout << "loading initial cache file " << path << "\n";
       this->ReadListFile(args, path.c_str());
-      }
-    else if(arg.find("-P",0) == 0)
-      {
+    } else if (arg.find("-P", 0) == 0) {
       i++;
-      if(i >= args.size())
-        {
+      if (i >= args.size()) {
         cmSystemTools::Error("-P must be followed by a file name.");
         return false;
-        }
+      }
       std::string path = args[i];
-      if (path.empty())
-        {
+      if (path.empty()) {
         cmSystemTools::Error("No cmake script provided.");
         return false;
-        }
-      this->ReadListFile(args, path.c_str());
       }
-    else if (arg.find("--find-package",0) == 0)
-      {
+      this->ReadListFile(args, path.c_str());
+    } else if (arg.find("--find-package", 0) == 0) {
       findPackageMode = true;
-      }
     }
+  }
 
-  if (findPackageMode)
-    {
+  if (findPackageMode) {
     return this->FindPackage(args);
-    }
+  }
 
   return true;
 }
 
 void cmake::ReadListFile(const std::vector<std::string>& args,
-                         const char *path)
+                         const char* path)
 {
   // if a generator was not yet created, temporarily create one
-  cmGlobalGenerator *gg = this->GetGlobalGenerator();
+  cmGlobalGenerator* gg = this->GetGlobalGenerator();
   bool created = false;
 
   // if a generator was not specified use a generic one
-  if (!gg)
-    {
+  if (!gg) {
     gg = new cmGlobalGenerator(this);
     created = true;
-    }
+  }
 
   // read in the list file to fill the cache
-  if(path)
-    {
+  if (path) {
     this->CurrentSnapshot = this->State->Reset();
     std::string homeDir = this->GetHomeDirectory();
     std::string homeOutputDir = this->GetHomeOutputDirectory();
     this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
     this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
     cmState::Snapshot snapshot = this->GetCurrentSnapshot();
-    snapshot.GetDirectory().SetCurrentBinary
-      (cmSystemTools::GetCurrentWorkingDirectory());
-    snapshot.GetDirectory().SetCurrentSource
-      (cmSystemTools::GetCurrentWorkingDirectory());
+    snapshot.GetDirectory().SetCurrentBinary(
+      cmSystemTools::GetCurrentWorkingDirectory());
+    snapshot.GetDirectory().SetCurrentSource(
+      cmSystemTools::GetCurrentWorkingDirectory());
     snapshot.SetDefaultDefinitions();
     cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
-    if (this->GetWorkingMode() != NORMAL_MODE)
-      {
+    if (this->GetWorkingMode() != NORMAL_MODE) {
       std::string file(cmSystemTools::CollapseFullPath(path));
       cmSystemTools::ConvertToUnixSlashes(file);
       mf->SetScriptModeFile(file.c_str());
 
       mf->SetArgcArgv(args);
-      }
-    if (!mf->ReadListFile(path))
-      {
+    }
+    if (!mf->ReadListFile(path)) {
       cmSystemTools::Error("Error processing file: ", path);
-      }
+    }
     this->SetHomeDirectory(homeDir);
     this->SetHomeOutputDirectory(homeOutputDir);
-    }
+  }
 
   // free generic one if generated
-  if (created)
-    {
+  if (created) {
     delete gg;
-    }
+  }
 }
 
-
 bool cmake::FindPackage(const std::vector<std::string>& args)
 {
-  this->SetHomeDirectory
-    (cmSystemTools::GetCurrentWorkingDirectory());
-  this->SetHomeOutputDirectory
-    (cmSystemTools::GetCurrentWorkingDirectory());
+  this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+  this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
 
   // if a generator was not yet created, temporarily create one
-  cmGlobalGenerator *gg = new cmGlobalGenerator(this);
+  cmGlobalGenerator* gg = new cmGlobalGenerator(this);
   this->SetGlobalGenerator(gg);
 
   cmState::Snapshot snapshot = this->GetCurrentSnapshot();
-  snapshot.GetDirectory().SetCurrentBinary
-    (cmSystemTools::GetCurrentWorkingDirectory());
-  snapshot.GetDirectory().SetCurrentSource
-    (cmSystemTools::GetCurrentWorkingDirectory());
+  snapshot.GetDirectory().SetCurrentBinary(
+    cmSystemTools::GetCurrentWorkingDirectory());
+  snapshot.GetDirectory().SetCurrentSource(
+    cmSystemTools::GetCurrentWorkingDirectory());
   // read in the list file to fill the cache
   snapshot.SetDefaultDefinitions();
   cmMakefile* mf = new cmMakefile(gg, snapshot);
@@ -513,22 +449,15 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
   bool packageFound = mf->IsOn("PACKAGE_FOUND");
   bool quiet = mf->IsOn("PACKAGE_QUIET");
 
-  if (!packageFound)
-    {
-    if (!quiet)
-      {
+  if (!packageFound) {
+    if (!quiet) {
       printf("%s not found.\n", packageName.c_str());
-      }
     }
-  else if (mode == "EXIST")
-    {
-    if (!quiet)
-      {
+  } else if (mode == "EXIST") {
+    if (!quiet) {
       printf("%s found.\n", packageName.c_str());
-      }
     }
-  else if (mode == "COMPILE")
-    {
+  } else if (mode == "COMPILE") {
     std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS");
     std::vector<std::string> includeDirs;
     cmSystemTools::ExpandListArgument(includes, includeDirs);
@@ -539,9 +468,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
 
     std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
     printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
-    }
-  else if (mode == "LINK")
-    {
+  } else if (mode == "LINK") {
     const char* targetName = "dummy";
     std::vector<std::string> srcs;
     cmTarget* tgt = mf->AddExecutable(targetName, srcs, true);
@@ -550,14 +477,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES");
     std::vector<std::string> libList;
     cmSystemTools::ExpandListArgument(libs, libList);
-    for(std::vector<std::string>::const_iterator libIt=libList.begin();
-            libIt != libList.end();
-            ++libIt)
-      {
-      mf->AddLinkLibraryForTarget(targetName, *libIt,
-                                  GENERAL_LibraryType);
-      }
-
+    for (std::vector<std::string>::const_iterator libIt = libList.begin();
+         libIt != libList.end(); ++libIt) {
+      mf->AddLinkLibraryForTarget(targetName, *libIt, GENERAL_LibraryType);
+    }
 
     std::string linkLibs;
     std::string frameworkPath;
@@ -565,32 +488,31 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     std::string flags;
     std::string linkFlags;
     gg->CreateGenerationObjects();
-    cmGeneratorTarget *gtgt = gg->FindGeneratorTarget(tgt->GetName());
+    cmGeneratorTarget* gtgt = gg->FindGeneratorTarget(tgt->GetName());
     cmLocalGenerator* lg = gtgt->GetLocalGenerator();
     lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
                        gtgt, false);
     linkLibs = frameworkPath + linkPath + linkLibs;
 
-    printf("%s\n", linkLibs.c_str() );
+    printf("%s\n", linkLibs.c_str());
 
-/*    if ( use_win32 )
-      {
-      tgt->SetProperty("WIN32_EXECUTABLE", "ON");
-      }
-    if ( use_macbundle)
-      {
-      tgt->SetProperty("MACOSX_BUNDLE", "ON");
-      }*/
-    }
+    /*    if ( use_win32 )
+          {
+          tgt->SetProperty("WIN32_EXECUTABLE", "ON");
+          }
+        if ( use_macbundle)
+          {
+          tgt->SetProperty("MACOSX_BUNDLE", "ON");
+          }*/
+  }
 
   // free generic one if generated
-//  this->SetGlobalGenerator(0); // setting 0-pointer is not possible
-//  delete gg; // this crashes inside the cmake instance
+  //  this->SetGlobalGenerator(0); // setting 0-pointer is not possible
+  //  delete gg; // this crashes inside the cmake instance
 
   return packageFound;
 }
 
-
 // Parse the args
 void cmake::SetArgs(const std::vector<std::string>& args,
                     bool directoriesSetBefore)
@@ -598,223 +520,157 @@ void cmake::SetArgs(const std::vector<std::string>& args,
   bool directoriesSet = directoriesSetBefore;
   bool haveToolset = false;
   bool havePlatform = false;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
+  for (unsigned int i = 1; i < args.size(); ++i) {
     std::string arg = args[i];
-    if(arg.find("-H",0) == 0)
-      {
+    if (arg.find("-H", 0) == 0) {
       directoriesSet = true;
       std::string path = arg.substr(2);
       path = cmSystemTools::CollapseFullPath(path);
       cmSystemTools::ConvertToUnixSlashes(path);
       this->SetHomeDirectory(path);
-      }
-    else if(arg.find("-S",0) == 0)
-      {
+    } else if (arg.find("-S", 0) == 0) {
       // There is no local generate anymore.  Ignore -S option.
-      }
-    else if(arg.find("-O",0) == 0)
-      {
+    } else if (arg.find("-O", 0) == 0) {
       // There is no local generate anymore.  Ignore -O option.
-      }
-    else if(arg.find("-B",0) == 0)
-      {
+    } else if (arg.find("-B", 0) == 0) {
       directoriesSet = true;
       std::string path = arg.substr(2);
       path = cmSystemTools::CollapseFullPath(path);
       cmSystemTools::ConvertToUnixSlashes(path);
       this->SetHomeOutputDirectory(path);
-      }
-    else if((i < args.size()-2) && (arg.find("--check-build-system",0) == 0))
-      {
+    } else if ((i < args.size() - 2) &&
+               (arg.find("--check-build-system", 0) == 0)) {
       this->CheckBuildSystemArgument = args[++i];
       this->ClearBuildSystem = (atoi(args[++i].c_str()) > 0);
-      }
-    else if((i < args.size()-1) && (arg.find("--check-stamp-file",0) == 0))
-      {
+    } else if ((i < args.size() - 1) &&
+               (arg.find("--check-stamp-file", 0) == 0)) {
       this->CheckStampFile = args[++i];
-      }
-    else if((i < args.size()-1) && (arg.find("--check-stamp-list",0) == 0))
-      {
+    } else if ((i < args.size() - 1) &&
+               (arg.find("--check-stamp-list", 0) == 0)) {
       this->CheckStampList = args[++i];
-      }
+    }
 #if defined(CMAKE_HAVE_VS_GENERATORS)
-    else if((i < args.size()-1) && (arg.find("--vs-solution-file",0) == 0))
-      {
+    else if ((i < args.size() - 1) &&
+             (arg.find("--vs-solution-file", 0) == 0)) {
       this->VSSolutionFile = args[++i];
-      }
+    }
 #endif
-    else if(arg.find("-V",0) == 0)
-      {
-        this->Verbose = true;
-      }
-    else if(arg.find("-D",0) == 0)
-      {
+    else if (arg.find("-V", 0) == 0) {
+      this->Verbose = true;
+    } else if (arg.find("-D", 0) == 0) {
       // skip for now
-      }
-    else if(arg.find("-U",0) == 0)
-      {
+    } else if (arg.find("-U", 0) == 0) {
       // skip for now
-      }
-    else if(arg.find("-C",0) == 0)
-      {
+    } else if (arg.find("-C", 0) == 0) {
       // skip for now
-      }
-    else if(arg.find("-P",0) == 0)
-      {
+    } else if (arg.find("-P", 0) == 0) {
       // skip for now
       i++;
-      }
-    else if(arg.find("--find-package",0) == 0)
-      {
+    } else if (arg.find("--find-package", 0) == 0) {
       // skip for now
       i++;
-      }
-    else if(arg.find("-W",0) == 0)
-      {
+    } else if (arg.find("-W", 0) == 0) {
       // skip for now
-      }
-    else if(arg.find("--graphviz=",0) == 0)
-      {
+    } else if (arg.find("--graphviz=", 0) == 0) {
       std::string path = arg.substr(strlen("--graphviz="));
       path = cmSystemTools::CollapseFullPath(path);
       cmSystemTools::ConvertToUnixSlashes(path);
       this->GraphVizFile = path;
-      if ( this->GraphVizFile.empty() )
-        {
+      if (this->GraphVizFile.empty()) {
         cmSystemTools::Error("No file specified for --graphviz");
-        }
       }
-    else if(arg.find("--debug-trycompile",0) == 0)
-      {
+    } else if (arg.find("--debug-trycompile", 0) == 0) {
       std::cout << "debug trycompile on\n";
       this->DebugTryCompileOn();
-      }
-    else if(arg.find("--debug-output",0) == 0)
-      {
+    } else if (arg.find("--debug-output", 0) == 0) {
       std::cout << "Running with debug output on.\n";
       this->SetDebugOutputOn(true);
-      }
-    else if(arg.find("--trace-expand",0) == 0)
-      {
+    } else if (arg.find("--trace-expand", 0) == 0) {
       std::cout << "Running with expanded trace output on.\n";
       this->SetTrace(true);
       this->SetTraceExpand(true);
-      }
-    else if(arg.find("--trace",0) == 0)
-      {
+    } else if (arg.find("--trace", 0) == 0) {
       std::cout << "Running with trace output on.\n";
       this->SetTrace(true);
       this->SetTraceExpand(false);
-      }
-    else if(arg.find("--warn-uninitialized",0) == 0)
-      {
+    } else if (arg.find("--warn-uninitialized", 0) == 0) {
       std::cout << "Warn about uninitialized values.\n";
       this->SetWarnUninitialized(true);
-      }
-    else if(arg.find("--warn-unused-vars",0) == 0)
-      {
+    } else if (arg.find("--warn-unused-vars", 0) == 0) {
       std::cout << "Finding unused variables.\n";
       this->SetWarnUnused(true);
-      }
-    else if(arg.find("--no-warn-unused-cli",0) == 0)
-      {
-      std::cout << "Not searching for unused variables given on the " <<
-                   "command line.\n";
+    } else if (arg.find("--no-warn-unused-cli", 0) == 0) {
+      std::cout << "Not searching for unused variables given on the "
+                << "command line.\n";
       this->SetWarnUnusedCli(false);
-      }
-    else if(arg.find("--check-system-vars",0) == 0)
-      {
-      std::cout << "Also check system files when warning about unused and " <<
-                   "uninitialized variables.\n";
+    } else if (arg.find("--check-system-vars", 0) == 0) {
+      std::cout << "Also check system files when warning about unused and "
+                << "uninitialized variables.\n";
       this->SetCheckSystemVars(true);
-      }
-    else if(arg.find("-A",0) == 0)
-      {
+    } else if (arg.find("-A", 0) == 0) {
       std::string value = arg.substr(2);
-      if(value.empty())
-        {
+      if (value.empty()) {
         ++i;
-        if(i >= args.size())
-          {
+        if (i >= args.size()) {
           cmSystemTools::Error("No platform specified for -A");
           return;
-          }
-        value = args[i];
         }
-      if(havePlatform)
-        {
+        value = args[i];
+      }
+      if (havePlatform) {
         cmSystemTools::Error("Multiple -A options not allowed");
         return;
-        }
+      }
       this->GeneratorPlatform = value;
       havePlatform = true;
-      }
-    else if(arg.find("-T",0) == 0)
-      {
+    } else if (arg.find("-T", 0) == 0) {
       std::string value = arg.substr(2);
-      if(value.empty())
-        {
+      if (value.empty()) {
         ++i;
-        if(i >= args.size())
-          {
+        if (i >= args.size()) {
           cmSystemTools::Error("No toolset specified for -T");
           return;
-          }
-        value = args[i];
         }
-      if(haveToolset)
-        {
+        value = args[i];
+      }
+      if (haveToolset) {
         cmSystemTools::Error("Multiple -T options not allowed");
         return;
-        }
+      }
       this->GeneratorToolset = value;
       haveToolset = true;
-      }
-    else if(arg.find("-G",0) == 0)
-      {
+    } else if (arg.find("-G", 0) == 0) {
       std::string value = arg.substr(2);
-      if(value.empty())
-        {
+      if (value.empty()) {
         ++i;
-        if(i >= args.size())
-          {
+        if (i >= args.size()) {
           cmSystemTools::Error("No generator specified for -G");
           this->PrintGeneratorList();
           return;
-          }
-        value = args[i];
         }
-      cmGlobalGenerator* gen =
-        this->CreateGlobalGenerator(value);
-      if(!gen)
-        {
+        value = args[i];
+      }
+      cmGlobalGenerator* gen = this->CreateGlobalGenerator(value);
+      if (!gen) {
         cmSystemTools::Error("Could not create named generator ",
                              value.c_str());
         this->PrintGeneratorList();
-        }
-      else
-        {
+      } else {
         this->SetGlobalGenerator(gen);
-        }
       }
+    }
     // no option assume it is the path to the source
-    else
-      {
+    else {
       directoriesSet = true;
       this->SetDirectoriesFromFile(arg.c_str());
-      }
-    }
-  if(!directoriesSet)
-    {
-    this->SetHomeOutputDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory());
-    this->SetHomeDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory());
     }
+  }
+  if (!directoriesSet) {
+    this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+    this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmake::SetDirectoriesFromFile(const char* arg)
 {
   // Check if the argument refers to a CMakeCache.txt or
@@ -822,92 +678,72 @@ void cmake::SetDirectoriesFromFile(const char* arg)
   std::string listPath;
   std::string cachePath;
   bool argIsFile = false;
-  if(cmSystemTools::FileIsDirectory(arg))
-    {
+  if (cmSystemTools::FileIsDirectory(arg)) {
     std::string path = cmSystemTools::CollapseFullPath(arg);
     cmSystemTools::ConvertToUnixSlashes(path);
     std::string cacheFile = path;
     cacheFile += "/CMakeCache.txt";
     std::string listFile = path;
     listFile += "/CMakeLists.txt";
-    if(cmSystemTools::FileExists(cacheFile.c_str()))
-      {
+    if (cmSystemTools::FileExists(cacheFile.c_str())) {
       cachePath = path;
-      }
-    if(cmSystemTools::FileExists(listFile.c_str()))
-      {
+    }
+    if (cmSystemTools::FileExists(listFile.c_str())) {
       listPath = path;
-      }
     }
-  else if(cmSystemTools::FileExists(arg))
-    {
+  } else if (cmSystemTools::FileExists(arg)) {
     argIsFile = true;
     std::string fullPath = cmSystemTools::CollapseFullPath(arg);
     std::string name = cmSystemTools::GetFilenameName(fullPath);
     name = cmSystemTools::LowerCase(name);
-    if(name == "cmakecache.txt")
-      {
+    if (name == "cmakecache.txt") {
       cachePath = cmSystemTools::GetFilenamePath(fullPath);
-      }
-    else if(name == "cmakelists.txt")
-      {
+    } else if (name == "cmakelists.txt") {
       listPath = cmSystemTools::GetFilenamePath(fullPath);
-      }
     }
-  else
-    {
+  } else {
     // 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);
     name = cmSystemTools::LowerCase(name);
-    if(name == "cmakecache.txt" || name == "cmakelists.txt")
-      {
+    if (name == "cmakecache.txt" || name == "cmakelists.txt") {
       argIsFile = true;
       listPath = cmSystemTools::GetFilenamePath(fullPath);
-      }
-    else
-      {
+    } else {
       listPath = fullPath;
-      }
     }
+  }
 
   // If there is a CMakeCache.txt file, use its settings.
-  if(!cachePath.empty())
-    {
-    if(this->LoadCache(cachePath))
-      {
+  if (!cachePath.empty()) {
+    if (this->LoadCache(cachePath)) {
       const char* existingValue =
-          this->State->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
-      if (existingValue)
-        {
+        this->State->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
+      if (existingValue) {
         this->SetHomeOutputDirectory(cachePath);
         this->SetHomeDirectory(existingValue);
         return;
-        }
       }
     }
+  }
 
   // If there is a CMakeLists.txt file, use it as the source tree.
-  if(!listPath.empty())
-    {
+  if (!listPath.empty()) {
     this->SetHomeDirectory(listPath);
 
-    if(argIsFile)
-      {
+    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);
-      }
-    else
-      {
+    } else {
       // Source directory given on command line.  Use current working
       // directory as build tree.
       std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
       this->SetHomeOutputDirectory(cwd);
-      }
-    return;
     }
+    return;
+  }
 
   // We didn't find a CMakeLists.txt or CMakeCache.txt file from the
   // argument.  Assume it is the path to the source tree, and use the
@@ -923,30 +759,29 @@ void cmake::SetDirectoriesFromFile(const char* arg)
 int cmake::AddCMakePaths()
 {
   // Save the value in the cache
-  this->AddCacheEntry
-    ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(),
-     "Path to CMake executable.", cmState::INTERNAL);
+  this->AddCacheEntry("CMAKE_COMMAND",
+                      cmSystemTools::GetCMakeCommand().c_str(),
+                      "Path to CMake executable.", cmState::INTERNAL);
 #ifdef CMAKE_BUILD_WITH_CMAKE
-  this->AddCacheEntry
-    ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(),
-     "Path to ctest program executable.", cmState::INTERNAL);
-  this->AddCacheEntry
-    ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(),
-     "Path to cpack program executable.", cmState::INTERNAL);
+  this->AddCacheEntry("CMAKE_CTEST_COMMAND",
+                      cmSystemTools::GetCTestCommand().c_str(),
+                      "Path to ctest program executable.", cmState::INTERNAL);
+  this->AddCacheEntry("CMAKE_CPACK_COMMAND",
+                      cmSystemTools::GetCPackCommand().c_str(),
+                      "Path to cpack program executable.", cmState::INTERNAL);
 #endif
-  if(!cmSystemTools::FileExists(
-       (cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str()))
-    {
+  if (!cmSystemTools::FileExists(
+        (cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake").c_str())) {
     // couldn't find modules
-    cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n"
+    cmSystemTools::Error(
+      "Could not find CMAKE_ROOT !!!\n"
       "CMake has most likely not been installed correctly.\n"
       "Modules directory not found in\n",
       cmSystemTools::GetCMakeRoot().c_str());
     return 0;
-    }
-  this->AddCacheEntry
-    ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
-     "Path to CMake installation.", cmState::INTERNAL);
+  }
+  this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
+                      "Path to CMake installation.", cmState::INTERNAL);
 
   return 1;
 }
@@ -956,17 +791,15 @@ void cmake::AddExtraGenerator(const std::string& name,
 {
   cmExternalMakefileProjectGenerator* extraGenerator = newFunction();
   const std::vector<std::string>& supportedGlobalGenerators =
-                                extraGenerator->GetSupportedGlobalGenerators();
-
-  for(std::vector<std::string>::const_iterator
-      it = supportedGlobalGenerators.begin();
-      it != supportedGlobalGenerators.end();
-      ++it )
-    {
-    std::string fullName = cmExternalMakefileProjectGenerator::
-                                    CreateFullGeneratorName(*it, name);
+    extraGenerator->GetSupportedGlobalGenerators();
+
+  for (std::vector<std::string>::const_iterator it =
+         supportedGlobalGenerators.begin();
+       it != supportedGlobalGenerators.end(); ++it) {
+    std::string fullName =
+      cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*it, name);
     this->ExtraGenerators[fullName] = newFunction;
-    }
+  }
   delete extraGenerator;
 }
 
@@ -974,7 +807,7 @@ void cmake::AddDefaultExtraGenerators()
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  // e.g. kdevelop4 ?
+// e.g. kdevelop4 ?
 #endif
 
   this->AddExtraGenerator(cmExtraCodeBlocksGenerator::GetActualName(),
@@ -996,42 +829,38 @@ void cmake::AddDefaultExtraGenerators()
                           &cmGlobalKdevelopGenerator::New);
   // for kdevelop also add the generator with just the name of the
   // extra generator, since it was this way since cmake 2.2
-  this->ExtraGenerators[cmGlobalKdevelopGenerator::GetActualName()]
-                                             = &cmGlobalKdevelopGenerator::New;
+  this->ExtraGenerators[cmGlobalKdevelopGenerator::GetActualName()] =
+    &cmGlobalKdevelopGenerator::New;
 #endif
 
 #endif
 }
 
-
-//----------------------------------------------------------------------------
 void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators)
 {
-  for (RegisteredGeneratorsVector::const_iterator
-       i = this->Generators.begin(), e = this->Generators.end();
-       i != e; ++i)
-    {
+  for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(),
+                                                  e = this->Generators.end();
+       i != e; ++i) {
     std::vector<std::string> names;
     (*i)->GetGenerators(names);
 
-    for (size_t j = 0; j < names.size(); ++j)
-      {
+    for (size_t j = 0; j < names.size(); ++j) {
       GeneratorInfo info;
       info.supportsToolset = (*i)->SupportsToolset();
       info.name = names[j];
       generators.push_back(info);
-      }
     }
+  }
 
   for (RegisteredExtraGeneratorsMap::const_iterator
-       i = this->ExtraGenerators.begin(), e = this->ExtraGenerators.end();
-       i != e; ++i)
-    {
+         i = this->ExtraGenerators.begin(),
+         e = this->ExtraGenerators.end();
+       i != e; ++i) {
     GeneratorInfo info;
     info.name = i->first;
     info.supportsToolset = false;
     generators.push_back(info);
-    }
+  }
 }
 
 cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
@@ -1039,32 +868,26 @@ 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())
-    {
+    this->ExtraGenerators.find(name);
+  if (extraGenIt != this->ExtraGenerators.end()) {
     extraGenerator = (extraGenIt->second)();
     name = extraGenerator->GetGlobalGeneratorName(name);
-    }
+  }
 
   cmGlobalGenerator* generator = 0;
-  for (RegisteredGeneratorsVector::const_iterator i =
-    this->Generators.begin(); i != this->Generators.end(); ++i)
-    {
+  for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
+       i != this->Generators.end(); ++i) {
     generator = (*i)->CreateGlobalGenerator(name, this);
-    if (generator)
-      {
+    if (generator) {
       break;
-      }
     }
+  }
 
-  if (generator)
-    {
+  if (generator) {
     generator->SetExternalMakefileProjectGenerator(extraGenerator);
-    }
-  else
-    {
+  } else {
     delete extraGenerator;
-    }
+  }
 
   return generator;
 }
@@ -1072,10 +895,9 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
 void cmake::SetHomeDirectory(const std::string& dir)
 {
   this->State->SetSourceDirectory(dir);
-  if (this->CurrentSnapshot.IsValid())
-    {
+  if (this->CurrentSnapshot.IsValid()) {
     this->CurrentSnapshot.SetDefinition("CMAKE_SOURCE_DIR", dir);
-    }
+  }
 }
 
 const char* cmake::GetHomeDirectory() const
@@ -1086,10 +908,9 @@ const char* cmake::GetHomeDirectory() const
 void cmake::SetHomeOutputDirectory(const std::string& dir)
 {
   this->State->SetBinaryDirectory(dir);
-  if (this->CurrentSnapshot.IsValid())
-    {
+  if (this->CurrentSnapshot.IsValid()) {
     this->CurrentSnapshot.SetDefinition("CMAKE_BINARY_DIR", dir);
-    }
+  }
 }
 
 const char* cmake::GetHomeOutputDirectory() const
@@ -1097,60 +918,49 @@ const char* cmake::GetHomeOutputDirectory() const
   return this->State->GetBinaryDirectory();
 }
 
-void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
+void cmake::SetGlobalGenerator(cmGlobalGenerator* gg)
 {
-  if(!gg)
-    {
+  if (!gg) {
     cmSystemTools::Error("Error SetGlobalGenerator called with null");
     return;
-    }
+  }
   // delete the old generator
-  if (this->GlobalGenerator)
-    {
+  if (this->GlobalGenerator) {
     delete this->GlobalGenerator;
     // restore the original environment variables CXX and CC
     // Restore CC
     std::string env = "CC=";
-    if(!this->CCEnvironment.empty())
-      {
+    if (!this->CCEnvironment.empty()) {
       env += this->CCEnvironment;
-      }
+    }
     cmSystemTools::PutEnv(env);
     env = "CXX=";
-    if(!this->CXXEnvironment.empty())
-      {
+    if (!this->CXXEnvironment.empty()) {
       env += this->CXXEnvironment;
-      }
-    cmSystemTools::PutEnv(env);
     }
+    cmSystemTools::PutEnv(env);
+  }
 
   // set the new
   this->GlobalGenerator = gg;
 
   // set the global flag for unix style paths on cmSystemTools as soon as
   // the generator is set.  This allows gmake to be used on windows.
-  cmSystemTools::SetForceUnixPaths
-    (this->GlobalGenerator->GetForceUnixPaths());
+  cmSystemTools::SetForceUnixPaths(this->GlobalGenerator->GetForceUnixPaths());
 
   // Save the environment variables CXX and CC
   const char* cxx = getenv("CXX");
   const char* cc = getenv("CC");
-  if(cxx)
-    {
+  if (cxx) {
     this->CXXEnvironment = cxx;
-    }
-  else
-    {
+  } else {
     this->CXXEnvironment = "";
-    }
-  if(cc)
-    {
+  }
+  if (cc) {
     this->CCEnvironment = cc;
-    }
-  else
-    {
+  } else {
     this->CCEnvironment = "";
-    }
+  }
 }
 
 int cmake::DoPreConfigureChecks()
@@ -1158,40 +968,32 @@ int cmake::DoPreConfigureChecks()
   // Make sure the Source directory contains a CMakeLists.txt file.
   std::string srcList = this->GetHomeDirectory();
   srcList += "/CMakeLists.txt";
-  if(!cmSystemTools::FileExists(srcList.c_str()))
-    {
+  if (!cmSystemTools::FileExists(srcList.c_str())) {
     std::ostringstream err;
-    if(cmSystemTools::FileIsDirectory(this->GetHomeDirectory()))
-      {
+    if (cmSystemTools::FileIsDirectory(this->GetHomeDirectory())) {
       err << "The source directory \"" << this->GetHomeDirectory()
           << "\" does not appear to contain CMakeLists.txt.\n";
-      }
-    else if(cmSystemTools::FileExists(this->GetHomeDirectory()))
-      {
+    } else if (cmSystemTools::FileExists(this->GetHomeDirectory())) {
       err << "The source directory \"" << this->GetHomeDirectory()
           << "\" is a file, not a directory.\n";
-      }
-    else
-      {
+    } else {
       err << "The source directory \"" << this->GetHomeDirectory()
           << "\" does not exist.\n";
-      }
+    }
     err << "Specify --help for usage, or press the help button on the CMake "
-      "GUI.";
+           "GUI.";
     cmSystemTools::Error(err.str().c_str());
     return -2;
-    }
+  }
 
   // do a sanity check on some values
-  if(this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"))
-    {
+  if (this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) {
     std::string cacheStart =
       this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
     cacheStart += "/CMakeLists.txt";
     std::string currentStart = this->GetHomeDirectory();
     currentStart += "/CMakeLists.txt";
-    if(!cmSystemTools::SameFile(cacheStart, currentStart))
-      {
+    if (!cmSystemTools::SameFile(cacheStart, currentStart)) {
       std::string message = "The source \"";
       message += currentStart;
       message += "\" does not match the source \"";
@@ -1200,12 +1002,10 @@ int cmake::DoPreConfigureChecks()
       message += "Re-run cmake with a different source directory.";
       cmSystemTools::Error(message.c_str());
       return -2;
-      }
     }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
   return 1;
 }
 struct SaveCacheEntry
@@ -1221,59 +1021,52 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
   std::vector<std::string> argsSplit;
   cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
   // erase the property to avoid infinite recursion
-  this->State
-      ->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", "");
-  if(this->State->GetIsInTryCompile())
-    {
+  this->State->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", "");
+  if (this->State->GetIsInTryCompile()) {
     return 0;
-    }
+  }
   std::vector<SaveCacheEntry> saved;
   std::ostringstream warning;
+  /* clang-format off */
   warning
     << "You have changed variables that require your cache to be deleted.\n"
     << "Configure will be re-run and you may have to reset some variables.\n"
     << "The following variables have changed:\n";
-  for(std::vector<std::string>::iterator i = argsSplit.begin();
-      i != argsSplit.end(); ++i)
-    {
+  /* clang-format on */
+  for (std::vector<std::string>::iterator i = argsSplit.begin();
+       i != argsSplit.end(); ++i) {
     SaveCacheEntry save;
     save.key = *i;
     warning << *i << "= ";
     i++;
     save.value = *i;
     warning << *i << "\n";
-    const char* existingValue =
-        this->State->GetCacheEntryValue(save.key);
-    if(existingValue)
-      {
+    const char* existingValue = this->State->GetCacheEntryValue(save.key);
+    if (existingValue) {
       save.type = this->State->GetCacheEntryType(save.key);
-      if(const char* help =
-            this->State->GetCacheEntryProperty(save.key, "HELPSTRING"))
-        {
+      if (const char* help =
+            this->State->GetCacheEntryProperty(save.key, "HELPSTRING")) {
         save.help = help;
-        }
       }
-    saved.push_back(save);
     }
+    saved.push_back(save);
+  }
 
   // remove the cache
   this->DeleteCache(this->GetHomeOutputDirectory());
   // load the empty cache
   this->LoadCache();
   // restore the changed compilers
-  for(std::vector<SaveCacheEntry>::iterator i = saved.begin();
-      i != saved.end(); ++i)
-    {
-    this->AddCacheEntry(i->key, i->value.c_str(),
-                        i->help.c_str(), i->type);
-    }
+  for (std::vector<SaveCacheEntry>::iterator i = saved.begin();
+       i != saved.end(); ++i) {
+    this->AddCacheEntry(i->key, i->value.c_str(), i->help.c_str(), i->type);
+  }
   cmSystemTools::Message(warning.str().c_str());
   // avoid reconfigure if there were errors
-  if(!cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (!cmSystemTools::GetErrorOccuredFlag()) {
     // re-run configure
     return this->Configure();
-    }
+  }
   return 0;
 }
 
@@ -1281,87 +1074,69 @@ int cmake::Configure()
 {
   DiagLevel diagLevel;
 
-  if (this->DiagLevels.count("deprecated") == 1)
-    {
+  if (this->DiagLevels.count("deprecated") == 1) {
 
     diagLevel = this->DiagLevels["deprecated"];
-    if (diagLevel == DIAG_IGNORE)
-      {
+    if (diagLevel == DIAG_IGNORE) {
       this->SetSuppressDeprecatedWarnings(true);
       this->SetDeprecatedWarningsAsErrors(false);
-      }
-    else if (diagLevel == DIAG_WARN)
-      {
+    } else if (diagLevel == DIAG_WARN) {
       this->SetSuppressDeprecatedWarnings(false);
       this->SetDeprecatedWarningsAsErrors(false);
-      }
-    else if (diagLevel == DIAG_ERROR)
-      {
+    } else if (diagLevel == DIAG_ERROR) {
       this->SetSuppressDeprecatedWarnings(false);
       this->SetDeprecatedWarningsAsErrors(true);
-      }
     }
+  }
 
-  if (this->DiagLevels.count("dev") == 1)
-    {
+  if (this->DiagLevels.count("dev") == 1) {
     bool setDeprecatedVariables = false;
 
     const char* cachedWarnDeprecated =
-           this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
+      this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
     const char* cachedErrorDeprecated =
-           this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
+      this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
 
     // don't overwrite deprecated warning setting from a previous invocation
-    if (!cachedWarnDeprecated && !cachedErrorDeprecated)
-      {
+    if (!cachedWarnDeprecated && !cachedErrorDeprecated) {
       setDeprecatedVariables = true;
-      }
+    }
 
     diagLevel = this->DiagLevels["dev"];
-    if (diagLevel == DIAG_IGNORE)
-      {
+    if (diagLevel == DIAG_IGNORE) {
       this->SetSuppressDevWarnings(true);
       this->SetDevWarningsAsErrors(false);
 
-      if (setDeprecatedVariables)
-        {
+      if (setDeprecatedVariables) {
         this->SetSuppressDeprecatedWarnings(true);
         this->SetDeprecatedWarningsAsErrors(false);
-        }
       }
-    else if (diagLevel == DIAG_WARN)
-      {
+    } else if (diagLevel == DIAG_WARN) {
       this->SetSuppressDevWarnings(false);
       this->SetDevWarningsAsErrors(false);
 
-      if (setDeprecatedVariables)
-        {
+      if (setDeprecatedVariables) {
         this->SetSuppressDeprecatedWarnings(false);
         this->SetDeprecatedWarningsAsErrors(false);
-        }
       }
-    else if (diagLevel == DIAG_ERROR)
-      {
+    } else if (diagLevel == DIAG_ERROR) {
       this->SetSuppressDevWarnings(false);
       this->SetDevWarningsAsErrors(true);
 
-      if (setDeprecatedVariables)
-        {
+      if (setDeprecatedVariables) {
         this->SetSuppressDeprecatedWarnings(false);
         this->SetDeprecatedWarningsAsErrors(true);
-        }
       }
     }
+  }
 
   int ret = this->ActualConfigure();
-  const char* delCacheVars = this->State
-                    ->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
-  if(delCacheVars && delCacheVars[0] != 0)
-    {
+  const char* delCacheVars =
+    this->State->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
+  if (delCacheVars && delCacheVars[0] != 0) {
     return this->HandleDeleteCacheVariables(delCacheVars);
-    }
+  }
   return ret;
-
 }
 
 int cmake::ActualConfigure()
@@ -1371,48 +1146,39 @@ int cmake::ActualConfigure()
   this->CleanupCommandsAndMacros();
 
   int res = 0;
-  if ( this->GetWorkingMode() == NORMAL_MODE )
-    {
+  if (this->GetWorkingMode() == NORMAL_MODE) {
     res = this->DoPreConfigureChecks();
-    }
-  if ( res < 0 )
-    {
+  }
+  if (res < 0) {
     return -2;
-    }
-  if ( !res )
-    {
-    this->AddCacheEntry
-      ("CMAKE_HOME_DIRECTORY",
-       this->GetHomeDirectory(),
-       "Source directory with the top level CMakeLists.txt file for this "
-       "project",
-       cmState::INTERNAL);
-    }
+  }
+  if (!res) {
+    this->AddCacheEntry(
+      "CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(),
+      "Source directory with the top level CMakeLists.txt file for this "
+      "project",
+      cmState::INTERNAL);
+  }
 
   // no generator specified on the command line
-  if(!this->GlobalGenerator)
-    {
+  if (!this->GlobalGenerator) {
     const char* genName =
       this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
     const char* extraGenName =
       this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
-    if(genName)
-      {
-      std::string fullName = cmExternalMakefileProjectGenerator::
-                                CreateFullGeneratorName(genName,
-                                    extraGenName ? extraGenName : "");
+    if (genName) {
+      std::string fullName =
+        cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
+          genName, extraGenName ? extraGenName : "");
       this->GlobalGenerator = this->CreateGlobalGenerator(fullName);
-      }
-    if(this->GlobalGenerator)
-      {
+    }
+    if (this->GlobalGenerator) {
       // set the global flag for unix style paths on cmSystemTools as
       // soon as the generator is set.  This allows gmake to be used
       // on windows.
-      cmSystemTools::SetForceUnixPaths
-        (this->GlobalGenerator->GetForceUnixPaths());
-      }
-    else
-      {
+      cmSystemTools::SetForceUnixPaths(
+        this->GlobalGenerator->GetForceUnixPaths());
+    } else {
 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
       std::string installedCompiler;
       // Try to find the newest VS installed on the computer and
@@ -1429,145 +1195,117 @@ int cmake::ActualConfigure()
         const char* GeneratorName;
       };
       VSRegistryEntryName version[] = {
-        {"6.0", "Visual Studio 6"},
-        {"7.0", "Visual Studio 7"},
-        {"7.1", "Visual Studio 7 .NET 2003"},
-        {"8.0", "Visual Studio 8 2005"},
-        {"9.0", "Visual Studio 9 2008"},
-        {"10.0", "Visual Studio 10 2010"},
-        {"11.0", "Visual Studio 11 2012"},
-        {"12.0", "Visual Studio 12 2013"},
-        {"14.0", "Visual Studio 14 2015"},
-        {0, 0}};
-      for(int i=0; version[i].MSVersion != 0; i++)
-        {
-        for(size_t b=0; b < vsVerions.size(); b++)
-          {
+        /* clang-format needs this comment to break after the opening brace */
+        { "7.1", "Visual Studio 7 .NET 2003" },
+        { "8.0", "Visual Studio 8 2005" },
+        { "9.0", "Visual Studio 9 2008" },
+        { "10.0", "Visual Studio 10 2010" },
+        { "11.0", "Visual Studio 11 2012" },
+        { "12.0", "Visual Studio 12 2013" },
+        { "14.0", "Visual Studio 14 2015" },
+        { 0, 0 }
+      };
+      for (int i = 0; version[i].MSVersion != 0; i++) {
+        for (size_t b = 0; b < vsVerions.size(); b++) {
           std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion;
           reg += ";InstallDir]";
-          cmSystemTools::ExpandRegistryValues(reg,
-                                              cmSystemTools::KeyWOW64_32);
-          if (!(reg == "/registry"))
-            {
+          cmSystemTools::ExpandRegistryValues(reg, cmSystemTools::KeyWOW64_32);
+          if (!(reg == "/registry")) {
             installedCompiler = version[i].GeneratorName;
             break;
-            }
           }
         }
-      cmGlobalGenerator* gen
-        = this->CreateGlobalGenerator(installedCompiler.c_str());
-      if(!gen)
-        {
+      }
+      cmGlobalGenerator* gen =
+        this->CreateGlobalGenerator(installedCompiler.c_str());
+      if (!gen) {
         gen = new cmGlobalNMakeMakefileGenerator(this);
-        }
+      }
       this->SetGlobalGenerator(gen);
       std::cout << "-- Building for: " << gen->GetName() << "\n";
 #else
       this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this));
 #endif
-      }
-    if(!this->GlobalGenerator)
-      {
+    }
+    if (!this->GlobalGenerator) {
       cmSystemTools::Error("Could not create generator");
       return -1;
-      }
     }
+  }
 
-  const char* genName = this->State
-                            ->GetInitializedCacheValue("CMAKE_GENERATOR");
-  if(genName)
-    {
-    if(!this->GlobalGenerator->MatchesGeneratorName(genName))
-      {
+  const char* genName =
+    this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
+  if (genName) {
+    if (!this->GlobalGenerator->MatchesGeneratorName(genName)) {
       std::string message = "Error: generator : ";
       message += this->GlobalGenerator->GetName();
       message += "\nDoes not match the generator used previously: ";
       message += genName;
-      message +=
-        "\nEither remove the CMakeCache.txt file and CMakeFiles "
-        "directory or choose a different binary directory.";
+      message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
+                 "directory or choose a different binary directory.";
       cmSystemTools::Error(message.c_str());
       return -2;
-      }
     }
-  if(!this->State->GetInitializedCacheValue("CMAKE_GENERATOR"))
-    {
+  }
+  if (!this->State->GetInitializedCacheValue("CMAKE_GENERATOR")) {
     this->AddCacheEntry("CMAKE_GENERATOR",
-                                      this->GlobalGenerator->GetName().c_str(),
-                                      "Name of generator.",
-                                      cmState::INTERNAL);
+                        this->GlobalGenerator->GetName().c_str(),
+                        "Name of generator.", cmState::INTERNAL);
     this->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
                         this->GlobalGenerator->GetExtraGeneratorName().c_str(),
                         "Name of external makefile project generator.",
                         cmState::INTERNAL);
-    }
+  }
 
-  if(const char* platformName =
-     this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM"))
-    {
-    if(this->GeneratorPlatform.empty())
-      {
+  if (const char* platformName =
+        this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) {
+    if (this->GeneratorPlatform.empty()) {
       this->GeneratorPlatform = platformName;
-      }
-    else if(this->GeneratorPlatform != platformName)
-      {
+    } else if (this->GeneratorPlatform != platformName) {
       std::string message = "Error: generator platform: ";
       message += this->GeneratorPlatform;
       message += "\nDoes not match the platform used previously: ";
       message += platformName;
-      message +=
-        "\nEither remove the CMakeCache.txt file and CMakeFiles "
-        "directory or choose a different binary directory.";
+      message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
+                 "directory or choose a different binary directory.";
       cmSystemTools::Error(message.c_str());
       return -2;
-      }
     }
-  else
-    {
+  } else {
     this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM",
-                                      this->GeneratorPlatform.c_str(),
-                                      "Name of generator platform.",
-                                      cmState::INTERNAL);
-    }
+                        this->GeneratorPlatform.c_str(),
+                        "Name of generator platform.", cmState::INTERNAL);
+  }
 
-  if(const char* tsName =
-     this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET"))
-    {
-    if(this->GeneratorToolset.empty())
-      {
+  if (const char* tsName =
+        this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) {
+    if (this->GeneratorToolset.empty()) {
       this->GeneratorToolset = tsName;
-      }
-    else if(this->GeneratorToolset != tsName)
-      {
+    } else if (this->GeneratorToolset != tsName) {
       std::string message = "Error: generator toolset: ";
       message += this->GeneratorToolset;
       message += "\nDoes not match the toolset used previously: ";
       message += tsName;
-      message +=
-        "\nEither remove the CMakeCache.txt file and CMakeFiles "
-        "directory or choose a different binary directory.";
+      message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
+                 "directory or choose a different binary directory.";
       cmSystemTools::Error(message.c_str());
       return -2;
-      }
     }
-  else
-    {
+  } else {
     this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
-                                      this->GeneratorToolset.c_str(),
-                                      "Name of generator toolset.",
-                                      cmState::INTERNAL);
-    }
+                        this->GeneratorToolset.c_str(),
+                        "Name of generator toolset.", cmState::INTERNAL);
+  }
 
   // reset any system configuration information, except for when we are
   // InTryCompile. With TryCompile the system info is taken from the parent's
   // info to save time
-  if (!this->State->GetIsInTryCompile())
-    {
+  if (!this->State->GetIsInTryCompile()) {
     this->GlobalGenerator->ClearEnabledLanguages();
 
     this->TruncateOutputLog("CMakeOutput.log");
     this->TruncateOutputLog("CMakeError.log");
-    }
+  }
 
   // actually do the configure
   this->GlobalGenerator->Configure();
@@ -1581,45 +1319,37 @@ int cmake::ActualConfigure()
   // project requires compatibility with CMake 2.4.  We detect this
   // here by looking for the old CMAKE_BACKWARDS_COMPATIBILITY
   // variable created when CMP0001 is not set to NEW.
-  if(this->State
-         ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
-    {
-    if(!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH"))
-      {
-      this->AddCacheEntry
-        ("LIBRARY_OUTPUT_PATH", "",
-         "Single output directory for building all libraries.",
-         cmState::PATH);
-      }
-    if(!this->State
-            ->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH"))
-      {
-      this->AddCacheEntry
-        ("EXECUTABLE_OUTPUT_PATH", "",
-         "Single output directory for building all executables.",
-         cmState::PATH);
-      }
+  if (this->State->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) {
+    if (!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) {
+      this->AddCacheEntry(
+        "LIBRARY_OUTPUT_PATH", "",
+        "Single output directory for building all libraries.", cmState::PATH);
+    }
+    if (!this->State->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) {
+      this->AddCacheEntry(
+        "EXECUTABLE_OUTPUT_PATH", "",
+        "Single output directory for building all executables.",
+        cmState::PATH);
     }
+  }
 
-  cmMakefile* mf=this->GlobalGenerator->GetMakefiles()[0];
-  if (mf->IsOn("CTEST_USE_LAUNCHERS")
-              && !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE"))
-    {
-    cmSystemTools::Error("CTEST_USE_LAUNCHERS is enabled, but the "
-                        "RULE_LAUNCH_COMPILE global property is not defined.\n"
-                        "Did you forget to include(CTest) in the toplevel "
-                         "CMakeLists.txt ?");
-    }
+  cmMakefile* mf = this->GlobalGenerator->GetMakefiles()[0];
+  if (mf->IsOn("CTEST_USE_LAUNCHERS") &&
+      !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) {
+    cmSystemTools::Error(
+      "CTEST_USE_LAUNCHERS is enabled, but the "
+      "RULE_LAUNCH_COMPILE global property is not defined.\n"
+      "Did you forget to include(CTest) in the toplevel "
+      "CMakeLists.txt ?");
+  }
 
   // only save the cache if there were no fatal errors
-  if ( this->GetWorkingMode() == NORMAL_MODE )
-    {
+  if (this->GetWorkingMode() == NORMAL_MODE) {
     this->SaveCache(this->GetHomeOutputDirectory());
-    }
-  if(cmSystemTools::GetErrorOccuredFlag())
-    {
+  }
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return -1;
-    }
+  }
   return 0;
 }
 
@@ -1627,23 +1357,19 @@ void cmake::PreLoadCMakeFiles()
 {
   std::vector<std::string> args;
   std::string pre_load = this->GetHomeDirectory();
-  if (!pre_load.empty())
-    {
+  if (!pre_load.empty()) {
     pre_load += "/PreLoad.cmake";
-    if ( cmSystemTools::FileExists(pre_load.c_str()) )
-      {
+    if (cmSystemTools::FileExists(pre_load.c_str())) {
       this->ReadListFile(args, pre_load.c_str());
-      }
     }
+  }
   pre_load = this->GetHomeOutputDirectory();
-  if (!pre_load.empty())
-    {
+  if (!pre_load.empty()) {
     pre_load += "/PreLoad.cmake";
-    if ( cmSystemTools::FileExists(pre_load.c_str()) )
-      {
+    if (cmSystemTools::FileExists(pre_load.c_str())) {
       this->ReadListFile(args, pre_load.c_str());
-      }
     }
+  }
 }
 
 // handle a command line invocation
@@ -1651,104 +1377,86 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
 {
   // Process the arguments
   this->SetArgs(args);
-  if(cmSystemTools::GetErrorOccuredFlag())
-    {
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return -1;
-    }
+  }
 
   // If we are given a stamp list file check if it is really out of date.
-  if(!this->CheckStampList.empty() &&
-     cmakeCheckStampList(this->CheckStampList.c_str()))
-    {
+  if (!this->CheckStampList.empty() &&
+      cmakeCheckStampList(this->CheckStampList.c_str())) {
     return 0;
-    }
+  }
 
   // If we are given a stamp file check if it is really out of date.
-  if(!this->CheckStampFile.empty() &&
-     cmakeCheckStampFile(this->CheckStampFile.c_str()))
-    {
+  if (!this->CheckStampFile.empty() &&
+      cmakeCheckStampFile(this->CheckStampFile.c_str())) {
     return 0;
-    }
+  }
 
-  if ( this->GetWorkingMode() == NORMAL_MODE )
-    {
+  if (this->GetWorkingMode() == NORMAL_MODE) {
     // load the cache
-    if(this->LoadCache() < 0)
-      {
+    if (this->LoadCache() < 0) {
       cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n");
       return -1;
-      }
     }
-  else
-    {
+  } else {
     this->AddCMakePaths();
-    }
+  }
 
   // Add any cache args
-  if ( !this->SetCacheArgs(args) )
-    {
+  if (!this->SetCacheArgs(args)) {
     cmSystemTools::Error("Problem processing arguments. Aborting.\n");
     return -1;
-    }
+  }
 
   // In script mode we terminate after running the script.
-  if(this->GetWorkingMode() != NORMAL_MODE)
-    {
-    if(cmSystemTools::GetErrorOccuredFlag())
-      {
+  if (this->GetWorkingMode() != NORMAL_MODE) {
+    if (cmSystemTools::GetErrorOccuredFlag()) {
       return -1;
-      }
-    else
-      {
+    } else {
       return 0;
-      }
     }
+  }
 
   // If MAKEFLAGS are given in the environment, remove the environment
   // variable.  This will prevent try-compile from succeeding when it
   // should fail (if "-i" is an option).  We cannot simply test
   // whether "-i" is given and remove it because some make programs
   // encode the MAKEFLAGS variable in a strange way.
-  if(getenv("MAKEFLAGS"))
-    {
+  if (getenv("MAKEFLAGS")) {
     cmSystemTools::PutEnv("MAKEFLAGS=");
-    }
+  }
 
   this->PreLoadCMakeFiles();
 
-  if ( noconfigure )
-    {
+  if (noconfigure) {
     return 0;
-    }
+  }
 
   // now run the global generate
   // Check the state of the build system to see if we need to regenerate.
-  if(!this->CheckBuildSystem())
-    {
+  if (!this->CheckBuildSystem()) {
     return 0;
-    }
+  }
 
   int ret = this->Configure();
-  if (ret || this->GetWorkingMode() != NORMAL_MODE)
-    {
+  if (ret || this->GetWorkingMode() != NORMAL_MODE) {
 #if defined(CMAKE_HAVE_VS_GENERATORS)
-    if(!this->VSSolutionFile.empty() && this->GlobalGenerator)
-      {
+    if (!this->VSSolutionFile.empty() && this->GlobalGenerator) {
       // CMake is running to regenerate a Visual Studio build tree
       // during a build from the VS IDE.  The build files cannot be
       // regenerated, so we should stop the build.
-      cmSystemTools::Message(
-        "CMake Configure step failed.  "
-        "Build files cannot be regenerated correctly.  "
-        "Attempting to stop IDE build.");
+      cmSystemTools::Message("CMake Configure step failed.  "
+                             "Build files cannot be regenerated correctly.  "
+                             "Attempting to stop IDE build.");
       cmGlobalVisualStudioGenerator* gg =
         static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
       gg->CallVisualStudioMacro(cmGlobalVisualStudioGenerator::MacroStop,
                                 this->VSSolutionFile.c_str());
-      }
+    }
 #endif
     return ret;
-    }
+  }
   ret = this->Generate();
   std::string message = "Build files have been written to: ";
   message += this->GetHomeOutputDirectory();
@@ -1758,45 +1466,37 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
 
 int cmake::Generate()
 {
-  if(!this->GlobalGenerator)
-    {
+  if (!this->GlobalGenerator) {
     return -1;
-    }
-  if (!this->GlobalGenerator->Compute())
-    {
+  }
+  if (!this->GlobalGenerator->Compute()) {
     return -1;
-    }
+  }
   this->GlobalGenerator->Generate();
-  if ( !this->GraphVizFile.empty() )
-    {
+  if (!this->GraphVizFile.empty()) {
     std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl;
     this->GenerateGraphViz(this->GraphVizFile.c_str());
-    }
-  if(this->WarnUnusedCli)
-    {
+  }
+  if (this->WarnUnusedCli) {
     this->RunCheckForUnusedVariables();
-    }
-  if(cmSystemTools::GetErrorOccuredFlag())
-    {
+  }
+  if (cmSystemTools::GetErrorOccuredFlag()) {
     return -1;
-    }
+  }
   // Save the cache again after a successful Generate so that any internal
   // variables created during Generate are saved. (Specifically target GUIDs
   // for the Visual Studio and Xcode generators.)
-  if ( this->GetWorkingMode() == NORMAL_MODE )
-    {
+  if (this->GetWorkingMode() == NORMAL_MODE) {
     this->SaveCache(this->GetHomeOutputDirectory());
-    }
+  }
   return 0;
 }
 
 void cmake::AddCacheEntry(const std::string& key, const char* value,
-                          const char* helpString,
-                          int type)
+                          const char* helpString, int type)
 {
-  this->State->AddCacheEntry(key, value,
-                                    helpString,
-                                    cmState::CacheEntryType(type));
+  this->State->AddCacheEntry(key, value, helpString,
+                             cmState::CacheEntryType(type));
   this->UnwatchUnusedCli(key);
 }
 
@@ -1811,69 +1511,45 @@ void cmake::AddDefaultCommands()
   GetBootstrapCommands1(commands);
   GetBootstrapCommands2(commands);
   GetPredefinedCommands(commands);
-  for(std::vector<cmCommand*>::iterator i = commands.begin();
-      i != commands.end(); ++i)
-    {
+  for (std::vector<cmCommand*>::iterator i = commands.begin();
+       i != commands.end(); ++i) {
     this->State->AddCommand(*i);
-    }
+  }
 }
 
 void cmake::AddDefaultGenerators()
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-# if !defined(CMAKE_BOOT_MINGW)
-  this->Generators.push_back(
-    cmGlobalVisualStudio14Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio12Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio11Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio10Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio9Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio8Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio71Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio7Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalVisualStudio6Generator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalBorlandMakefileGenerator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalNMakeMakefileGenerator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalJOMMakefileGenerator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalGhsMultiGenerator::NewFactory());
-# endif
-  this->Generators.push_back(
-    cmGlobalMSYSMakefileGenerator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalMinGWMakefileGenerator::NewFactory());
+#if !defined(CMAKE_BOOT_MINGW)
+  this->Generators.push_back(cmGlobalVisualStudio14Generator::NewFactory());
+  this->Generators.push_back(cmGlobalVisualStudio12Generator::NewFactory());
+  this->Generators.push_back(cmGlobalVisualStudio11Generator::NewFactory());
+  this->Generators.push_back(cmGlobalVisualStudio10Generator::NewFactory());
+  this->Generators.push_back(cmGlobalVisualStudio9Generator::NewFactory());
+  this->Generators.push_back(cmGlobalVisualStudio8Generator::NewFactory());
+  this->Generators.push_back(cmGlobalVisualStudio71Generator::NewFactory());
+  this->Generators.push_back(cmGlobalBorlandMakefileGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalNMakeMakefileGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalJOMMakefileGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory());
+#endif
+  this->Generators.push_back(cmGlobalMSYSMakefileGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory());
 #endif
-  this->Generators.push_back(
-    cmGlobalUnixMakefileGenerator3::NewFactory());
+  this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory());
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-  this->Generators.push_back(
-    cmGlobalNinjaGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory());
 #endif
 #if defined(CMAKE_USE_WMAKE)
-  this->Generators.push_back(
-    cmGlobalWatcomWMakeGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalWatcomWMakeGenerator::NewFactory());
 #endif
 #ifdef CMAKE_USE_XCODE
-  this->Generators.push_back(
-    cmGlobalXCodeGenerator::NewFactory());
+  this->Generators.push_back(cmGlobalXCodeGenerator::NewFactory());
 #endif
 }
 
-bool cmake::ParseCacheEntry(const std::string& entry,
-                            std::string& var,
-                            std::string& value,
-                            cmState::CacheEntryType& type)
+bool cmake::ParseCacheEntry(const std::string& entry, std::string& var,
+                            std::string& value, cmState::CacheEntryType& type)
 {
   return cmState::ParseCacheEntry(entry, var, value, type);
 }
@@ -1881,26 +1557,23 @@ bool cmake::ParseCacheEntry(const std::string& entry,
 int cmake::LoadCache()
 {
   // could we not read the cache
-  if (!this->LoadCache(this->GetHomeOutputDirectory()))
-    {
+  if (!this->LoadCache(this->GetHomeOutputDirectory())) {
     // if it does exist, but isn't readable then warn the user
     std::string cacheFile = this->GetHomeOutputDirectory();
     cacheFile += "/CMakeCache.txt";
-    if(cmSystemTools::FileExists(cacheFile.c_str()))
-      {
+    if (cmSystemTools::FileExists(cacheFile.c_str())) {
       cmSystemTools::Error(
         "There is a CMakeCache.txt file for the current binary tree but "
         "cmake does not have permission to read it. Please check the "
         "permissions of the directory you are trying to run CMake on.");
       return -1;
-      }
     }
+  }
 
   // setup CMAKE_ROOT and CMAKE_COMMAND
-  if(!this->AddCMakePaths())
-    {
+  if (!this->AddCMakePaths()) {
     return -3;
-    }
+  }
   return 0;
 }
 
@@ -1911,32 +1584,30 @@ bool cmake::LoadCache(const std::string& path)
 }
 
 bool cmake::LoadCache(const std::string& path, bool internal,
-                std::set<std::string>& excludes,
-                std::set<std::string>& includes)
+                      std::set<std::string>& excludes,
+                      std::set<std::string>& includes)
 {
   bool result = this->State->LoadCache(path, internal, excludes, includes);
-  static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION",
-                                  "CMAKE_CACHE_MINOR_VERSION"};
+  static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
+                                   "CMAKE_CACHE_MINOR_VERSION" };
   for (const char* const* nameIt = cmArrayBegin(entries);
-       nameIt != cmArrayEnd(entries); ++nameIt)
-    {
+       nameIt != cmArrayEnd(entries); ++nameIt) {
     this->UnwatchUnusedCli(*nameIt);
-    }
+  }
   return result;
 }
 
 bool cmake::SaveCache(const std::string& path)
 {
   bool result = this->State->SaveCache(path);
-  static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION",
-                                  "CMAKE_CACHE_MINOR_VERSION",
-                                  "CMAKE_CACHE_PATCH_VERSION",
-                                  "CMAKE_CACHEFILE_DIR"};
+  static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
+                                   "CMAKE_CACHE_MINOR_VERSION",
+                                   "CMAKE_CACHE_PATCH_VERSION",
+                                   "CMAKE_CACHEFILE_DIR" };
   for (const char* const* nameIt = cmArrayBegin(entries);
-       nameIt != cmArrayEnd(entries); ++nameIt)
-    {
+       nameIt != cmArrayEnd(entries); ++nameIt) {
     this->UnwatchUnusedCli(*nameIt);
-    }
+  }
   return result;
 }
 
@@ -1945,19 +1616,18 @@ bool cmake::DeleteCache(const std::string& path)
   return this->State->DeleteCache(path);
 }
 
-void cmake::SetProgressCallback(ProgressCallbackType f, void *cd)
+void cmake::SetProgressCallback(ProgressCallbackType f, void* cd)
 {
   this->ProgressCallback = f;
   this->ProgressCallbackClientData = cd;
 }
 
-void cmake::UpdateProgress(const char *msg, float prog)
+void cmake::UpdateProgress(const char* msg, float prog)
 {
-  if(this->ProgressCallback && !this->State->GetIsInTryCompile())
-    {
+  if (this->ProgressCallback && !this->State->GetIsInTryCompile()) {
     (*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData);
     return;
-    }
+  }
 }
 
 bool cmake::GetIsInTryCompile() const
@@ -1972,23 +1642,22 @@ void cmake::SetIsInTryCompile(bool b)
 
 void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
 {
-  for(RegisteredGeneratorsVector::const_iterator i =
-      this->Generators.begin(); i != this->Generators.end(); ++i)
-    {
+  for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
+       i != this->Generators.end(); ++i) {
     cmDocumentationEntry e;
     (*i)->GetDocumentation(e);
     v.push_back(e);
-    }
-  for(RegisteredExtraGeneratorsMap::const_iterator i =
-      this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i)
-    {
+  }
+  for (RegisteredExtraGeneratorsMap::const_iterator i =
+         this->ExtraGenerators.begin();
+       i != this->ExtraGenerators.end(); ++i) {
     cmDocumentationEntry e;
     cmExternalMakefileProjectGenerator* generator = (i->second)();
     generator->GetDocumentation(e, i->first);
     e.Name = i->first;
     delete generator;
     v.push_back(e);
-    }
+  }
 }
 
 void cmake::PrintGeneratorList()
@@ -1997,7 +1666,7 @@ void cmake::PrintGeneratorList()
   cmDocumentation doc;
   std::vector<cmDocumentationEntry> generators;
   this->GetGeneratorDocumentation(generators);
-  doc.AppendSection("Generators",generators);
+  doc.AppendSection("Generators", generators);
   std::cerr << "\n";
   doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr);
 #endif
@@ -2007,69 +1676,59 @@ void cmake::UpdateConversionPathTable()
 {
   // Update the path conversion table with any specified file:
   const char* tablepath =
-    this->State
-        ->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE");
+    this->State->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE");
 
-  if(tablepath)
-    {
-    cmsys::ifstream table( tablepath );
-    if(!table)
-      {
+  if (tablepath) {
+    cmsys::ifstream table(tablepath);
+    if (!table) {
       cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath,
-        ". CMake can not open file.");
+                           ". CMake can not open file.");
       cmSystemTools::ReportLastSystemError("CMake can not open file.");
-      }
-    else
-      {
+    } else {
       std::string a, b;
-      while(!table.eof())
-        {
+      while (!table.eof()) {
         // two entries per line
-        table >> a; table >> b;
-        cmSystemTools::AddTranslationPath( a, b);
-        }
+        table >> a;
+        table >> b;
+        cmSystemTools::AddTranslationPath(a, b);
       }
     }
+  }
 }
 
-//----------------------------------------------------------------------------
 int cmake::CheckBuildSystem()
 {
   // We do not need to rerun CMake.  Check dependency integrity.  Use
   // the make system's VERBOSE environment variable to enable verbose
   // output. This can be skipped by setting CMAKE_NO_VERBOSE (which is set
   // by the Eclipse and KDevelop generators).
-  bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0)
-                   && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0));
+  bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) &&
+                  (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0));
 
   // This method will check the integrity of the build system if the
   // option was given on the command line.  It reads the given file to
   // determine whether CMake should rerun.
 
   // If no file is provided for the check, we have to rerun.
-  if(this->CheckBuildSystemArgument.empty())
-    {
-    if(verbose)
-      {
+  if (this->CheckBuildSystemArgument.empty()) {
+    if (verbose) {
       std::ostringstream msg;
       msg << "Re-run cmake no build system arguments\n";
       cmSystemTools::Stdout(msg.str().c_str());
-      }
-    return 1;
     }
+    return 1;
+  }
 
   // If the file provided does not exist, we have to rerun.
-  if(!cmSystemTools::FileExists(this->CheckBuildSystemArgument.c_str()))
-    {
-    if(verbose)
-      {
+  if (!cmSystemTools::FileExists(this->CheckBuildSystemArgument.c_str())) {
+    if (verbose) {
       std::ostringstream msg;
-      msg << "Re-run cmake missing file: "
-          << this->CheckBuildSystemArgument << "\n";
+      msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument
+          << "\n";
       cmSystemTools::Stdout(msg.str().c_str());
-      }
-    return 1;
     }
+    return 1;
+  }
 
   // Read the rerun check file and use it to decide whether to do the
   // global generate.
@@ -2079,156 +1738,129 @@ int cmake::CheckBuildSystem()
   cm.GetCurrentSnapshot().SetDefaultDefinitions();
   cmGlobalGenerator gg(&cm);
   cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
-  if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
-     cmSystemTools::GetErrorOccuredFlag())
-    {
-    if(verbose)
-      {
+  if (!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
+      cmSystemTools::GetErrorOccuredFlag()) {
+    if (verbose) {
       std::ostringstream msg;
-      msg << "Re-run cmake error reading : "
-          << this->CheckBuildSystemArgument << "\n";
+      msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument
+          << "\n";
       cmSystemTools::Stdout(msg.str().c_str());
-      }
+    }
     // There was an error reading the file.  Just rerun.
     return 1;
-    }
+  }
 
-  if(this->ClearBuildSystem)
-    {
+  if (this->ClearBuildSystem) {
     // Get the generator used for this build system.
     const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
-    if(!genName || genName[0] == '\0')
-      {
+    if (!genName || genName[0] == '\0') {
       genName = "Unix Makefiles";
-      }
+    }
 
     // Create the generator and use it to clear the dependencies.
-    cmsys::auto_ptr<cmGlobalGenerator>
-      ggd(this->CreateGlobalGenerator(genName));
-    if(ggd.get())
-      {
+    cmsys::auto_ptr<cmGlobalGenerator> ggd(
+      this->CreateGlobalGenerator(genName));
+    if (ggd.get()) {
       cm.GetCurrentSnapshot().SetDefaultDefinitions();
-      cmsys::auto_ptr<cmMakefile> mfd(new cmMakefile(ggd.get(),
-                                                    cm.GetCurrentSnapshot()));
+      cmsys::auto_ptr<cmMakefile> mfd(
+        new cmMakefile(ggd.get(), cm.GetCurrentSnapshot()));
       cmsys::auto_ptr<cmLocalGenerator> lgd(
-            ggd->CreateLocalGenerator(mfd.get()));
+        ggd->CreateLocalGenerator(mfd.get()));
       lgd->ClearDependencies(mfd.get(), verbose);
-      }
     }
+  }
 
   // If any byproduct of makefile generation is missing we must re-run.
   std::vector<std::string> products;
-  if(const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS"))
-    {
+  if (const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
     cmSystemTools::ExpandListArgument(productStr, products);
-    }
-  for(std::vector<std::string>::const_iterator pi = products.begin();
-      pi != products.end(); ++pi)
-    {
-    if(!(cmSystemTools::FileExists(pi->c_str()) ||
-         cmSystemTools::FileIsSymlink(*pi)))
-      {
-      if(verbose)
-        {
+  }
+  for (std::vector<std::string>::const_iterator pi = products.begin();
+       pi != products.end(); ++pi) {
+    if (!(cmSystemTools::FileExists(pi->c_str()) ||
+          cmSystemTools::FileIsSymlink(*pi))) {
+      if (verbose) {
         std::ostringstream msg;
         msg << "Re-run cmake, missing byproduct: " << *pi << "\n";
         cmSystemTools::Stdout(msg.str().c_str());
-        }
-      return 1;
       }
+      return 1;
     }
+  }
 
   // Get the set of dependencies and outputs.
   std::vector<std::string> depends;
   std::vector<std::string> outputs;
   const char* dependsStr = mf->GetDefinition("CMAKE_MAKEFILE_DEPENDS");
   const char* outputsStr = mf->GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
-  if(dependsStr && outputsStr)
-    {
+  if (dependsStr && outputsStr) {
     cmSystemTools::ExpandListArgument(dependsStr, depends);
     cmSystemTools::ExpandListArgument(outputsStr, outputs);
-    }
-  if(depends.empty() || outputs.empty())
-    {
+  }
+  if (depends.empty() || outputs.empty()) {
     // Not enough information was provided to do the test.  Just rerun.
-    if(verbose)
-      {
+    if (verbose) {
       std::ostringstream msg;
       msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
-        "or CMAKE_MAKEFILE_OUTPUTS :\n";
+             "or CMAKE_MAKEFILE_OUTPUTS :\n";
       cmSystemTools::Stdout(msg.str().c_str());
-      }
-    return 1;
     }
+    return 1;
+  }
 
   // Find the newest dependency.
   std::vector<std::string>::iterator dep = depends.begin();
   std::string dep_newest = *dep++;
-  for(;dep != depends.end(); ++dep)
-    {
+  for (; dep != depends.end(); ++dep) {
     int result = 0;
-    if(this->FileComparison->FileTimeCompare(dep_newest.c_str(),
-                                             dep->c_str(), &result))
-      {
-      if(result < 0)
-        {
+    if (this->FileComparison->FileTimeCompare(dep_newest.c_str(), dep->c_str(),
+                                              &result)) {
+      if (result < 0) {
         dep_newest = *dep;
-        }
       }
-    else
-      {
-      if(verbose)
-        {
+    } else {
+      if (verbose) {
         std::ostringstream msg;
         msg << "Re-run cmake: build system dependency is missing\n";
         cmSystemTools::Stdout(msg.str().c_str());
-        }
-      return 1;
       }
+      return 1;
     }
+  }
 
   // Find the oldest output.
   std::vector<std::string>::iterator out = outputs.begin();
   std::string out_oldest = *out++;
-  for(;out != outputs.end(); ++out)
-    {
+  for (; out != outputs.end(); ++out) {
     int result = 0;
-    if(this->FileComparison->FileTimeCompare(out_oldest.c_str(),
-                                             out->c_str(), &result))
-      {
-      if(result > 0)
-        {
+    if (this->FileComparison->FileTimeCompare(out_oldest.c_str(), out->c_str(),
+                                              &result)) {
+      if (result > 0) {
         out_oldest = *out;
-        }
       }
-    else
-      {
-      if(verbose)
-        {
+    } else {
+      if (verbose) {
         std::ostringstream msg;
         msg << "Re-run cmake: build system output is missing\n";
         cmSystemTools::Stdout(msg.str().c_str());
-        }
-      return 1;
       }
+      return 1;
     }
+  }
 
   // If any output is older than any dependency then rerun.
   {
-  int result = 0;
-  if(!this->FileComparison->FileTimeCompare(out_oldest.c_str(),
-                                            dep_newest.c_str(),
-                                            &result) ||
-     result < 0)
-    {
-    if(verbose)
-      {
-      std::ostringstream msg;
-      msg << "Re-run cmake file: " << out_oldest
-          << " older than: " << dep_newest << "\n";
-      cmSystemTools::Stdout(msg.str().c_str());
+    int result = 0;
+    if (!this->FileComparison->FileTimeCompare(out_oldest.c_str(),
+                                               dep_newest.c_str(), &result) ||
+        result < 0) {
+      if (verbose) {
+        std::ostringstream msg;
+        msg << "Re-run cmake file: " << out_oldest
+            << " older than: " << dep_newest << "\n";
+        cmSystemTools::Stdout(msg.str().c_str());
       }
-    return 1;
+      return 1;
     }
   }
 
@@ -2236,37 +1868,32 @@ int cmake::CheckBuildSystem()
   return 0;
 }
 
-//----------------------------------------------------------------------------
 void cmake::TruncateOutputLog(const char* fname)
 {
   std::string fullPath = this->GetHomeOutputDirectory();
   fullPath += "/";
   fullPath += fname;
   struct stat st;
-  if ( ::stat(fullPath.c_str(), &st) )
-    {
+  if (::stat(fullPath.c_str(), &st)) {
     return;
-    }
-  if (!this->State->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"))
-    {
+  }
+  if (!this->State->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) {
     cmSystemTools::RemoveFile(fullPath);
     return;
-    }
+  }
   off_t fsize = st.st_size;
   const off_t maxFileSize = 50 * 1024;
-  if ( fsize < maxFileSize )
-    {
-    //TODO: truncate file
+  if (fsize < maxFileSize) {
+    // TODO: truncate file
     return;
-    }
+  }
 }
 
 inline std::string removeQuotes(const std::string& s)
 {
-  if(s[0] == '\"' && s[s.size()-1] == '\"')
-    {
-    return s.substr(1, s.size()-2);
-    }
+  if (s[0] == '\"' && s[s.size() - 1] == '\"') {
+    return s.substr(1, s.size() - 2);
+  }
   return s;
 }
 
@@ -2279,7 +1906,7 @@ void cmake::GenerateGraphViz(const char* fileName) const
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmsys::auto_ptr<cmGraphVizWriter> gvWriter(
-       new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators()));
+    new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators()));
 
   std::string settingsFile = this->GetHomeOutputDirectory();
   settingsFile += "/CMakeGraphVizOptions.cmake";
@@ -2300,13 +1927,13 @@ void cmake::SetProperty(const std::string& prop, const char* value)
   this->State->SetGlobalProperty(prop, value);
 }
 
-void cmake::AppendProperty(const std::string& prop,
-                           const char* value, bool asString)
+void cmake::AppendProperty(const std::string& prop, const char* value,
+                           bool asString)
 {
   this->State->AppendGlobalProperty(prop, value, asString);
 }
 
-const char *cmake::GetProperty(const std::string& prop)
+const char* cmake::GetProperty(const std::string& prop)
 {
   return this->State->GetGlobalProperty(prop);
 }
@@ -2316,23 +1943,20 @@ bool cmake::GetPropertyAsBool(const std::string& prop)
   return this->State->GetGlobalPropertyAsBool(prop);
 }
 
-cmInstalledFile *cmake::GetOrCreateInstalledFile(
-  cmMakefile* mf, const std::string& name)
+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;
+  if (i != this->InstalledFiles.end()) {
+    cmInstalledFile& file = i->second;
     return &file;
-    }
-  else
-    {
-    cmInstalledFile &file = this->InstalledFiles[name];
+  } else {
+    cmInstalledFile& file = this->InstalledFiles[name];
     file.SetName(mf, name);
     return &file;
-    }
+  }
 }
 
 cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const
@@ -2340,15 +1964,12 @@ 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())
-    {
+  if (i != this->InstalledFiles.end()) {
     cmInstalledFile const& file = i->second;
     return &file;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
 int cmake::GetSystemInformation(std::vector<std::string>& args)
@@ -2358,67 +1979,52 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
   std::string destPath = cwd + "/__cmake_systeminformation";
   cmSystemTools::RemoveADirectory(destPath);
-  if (!cmSystemTools::MakeDirectory(destPath.c_str()))
-    {
+  if (!cmSystemTools::MakeDirectory(destPath.c_str())) {
     std::cerr << "Error: --system-information must be run from a "
-      "writable directory!\n";
+                 "writable directory!\n";
     return 1;
-    }
+  }
 
   // process the arguments
   bool writeToStdout = true;
-  for(unsigned int i=1; i < args.size(); ++i)
-    {
+  for (unsigned int i = 1; i < args.size(); ++i) {
     std::string arg = args[i];
-    if(arg.find("-V",0) == 0)
-      {
+    if (arg.find("-V", 0) == 0) {
       this->Verbose = true;
-      }
-    else if(arg.find("-G",0) == 0)
-      {
+    } else if (arg.find("-G", 0) == 0) {
       std::string value = arg.substr(2);
-      if(value.empty())
-        {
+      if (value.empty()) {
         ++i;
-        if(i >= args.size())
-          {
+        if (i >= args.size()) {
           cmSystemTools::Error("No generator specified for -G");
           this->PrintGeneratorList();
           return -1;
-          }
-        value = args[i];
         }
-      cmGlobalGenerator* gen =
-        this->CreateGlobalGenerator(value);
-      if(!gen)
-        {
+        value = args[i];
+      }
+      cmGlobalGenerator* gen = this->CreateGlobalGenerator(value);
+      if (!gen) {
         cmSystemTools::Error("Could not create named generator ",
                              value.c_str());
         this->PrintGeneratorList();
-        }
-      else
-        {
+      } else {
         this->SetGlobalGenerator(gen);
-        }
       }
+    }
     // no option assume it is the output file
-    else
-      {
-      if (!cmSystemTools::FileIsFullPath(arg.c_str()))
-        {
+    else {
+      if (!cmSystemTools::FileIsFullPath(arg.c_str())) {
         resultFile = cwd;
         resultFile += "/";
-        }
+      }
       resultFile += arg;
       writeToStdout = false;
-      }
     }
-
+  }
 
   // we have to find the module directory, so we can copy the files
   this->AddCMakePaths();
-  std::string modulesPath =
-    this->State->GetInitializedCacheValue("CMAKE_ROOT");
+  std::string modulesPath = cmSystemTools::GetCMakeRoot();
   modulesPath += "/Modules";
   std::string inFile = modulesPath;
   inFile += "/SystemInformation.cmake";
@@ -2426,19 +2032,17 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
   outFile += "/CMakeLists.txt";
 
   // Copy file
-  if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str()))
-    {
-    std::cerr << "Error copying file \"" << inFile
-              << "\" to \"" << outFile << "\".\n";
+  if (!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) {
+    std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile
+              << "\".\n";
     return 1;
-    }
+  }
 
   // do we write to a file or to stdout?
-  if (resultFile.empty())
-    {
+  if (resultFile.empty()) {
     resultFile = cwd;
     resultFile += "/__cmake_systeminformation/results.txt";
-    }
+  }
 
   // now run cmake on the CMakeLists file
   cmSystemTools::ChangeDirectory(destPath);
@@ -2450,42 +2054,36 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
   args2.push_back(resultArg);
   int res = this->Run(args2, false);
 
-  if (res != 0)
-    {
+  if (res != 0) {
     std::cerr << "Error: --system-information failed on internal CMake!\n";
     return res;
-    }
+  }
 
   // change back to the original directory
   cmSystemTools::ChangeDirectory(cwd);
 
   // echo results to stdout if needed
-  if (writeToStdout)
-    {
+  if (writeToStdout) {
     FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r");
-    if(fin)
-      {
+    if (fin) {
       const int bufferSize = 4096;
       char buffer[bufferSize];
       size_t n;
-      while((n = fread(buffer, 1, bufferSize, fin)) > 0)
-        {
-        for(char* c = buffer; c < buffer+n; ++c)
-          {
+      while ((n = fread(buffer, 1, bufferSize, fin)) > 0) {
+        for (char* c = buffer; c < buffer + n; ++c) {
           putc(*c, stdout);
-          }
-        fflush(stdout);
         }
-      fclose(fin);
+        fflush(stdout);
       }
+      fclose(fin);
     }
+  }
 
   // clean up the directory
   cmSystemTools::RemoveADirectory(destPath);
   return 0;
 }
 
-//----------------------------------------------------------------------------
 static bool cmakeCheckStampFile(const char* stampName)
 {
   // The stamp file does not exist.  Use the stamp dependencies to
@@ -2500,25 +2098,22 @@ static bool cmakeCheckStampFile(const char* stampName)
 #else
   cmsys::ifstream fin(stampDepends.c_str(), std::ios::in);
 #endif
-  if(!fin)
-    {
+  if (!fin) {
     // The stamp dependencies file cannot be read.  Just assume the
     // build system is really out of date.
     std::cout << "CMake is re-running because " << stampName
               << " dependency file is missing.\n";
     return false;
-    }
+  }
 
   // Compare the stamp dependencies against the dependency file itself.
   cmFileTimeComparison ftc;
   std::string dep;
-  while(cmSystemTools::GetLineFromStream(fin, dep))
-    {
+  while (cmSystemTools::GetLineFromStream(fin, dep)) {
     int result;
-    if(!dep.empty() && dep[0] != '#' &&
-       (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result)
-        || result < 0))
-      {
+    if (!dep.empty() && dep[0] != '#' &&
+        (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result) ||
+         result < 0)) {
       // The stamp depends file is older than this dependency.  The
       // build system is really out of date.
       std::cout << "CMake is re-running because " << stampName
@@ -2527,8 +2122,8 @@ static bool cmakeCheckStampFile(const char* stampName)
       std::cout << "  is newer than '" << stampDepends << "'\n";
       std::cout << "  result='" << result << "'\n";
       return false;
-      }
     }
+  }
 
   // The build system is up to date.  The stamp file has been removed
   // by the VS IDE due to a "rebuild" request.  Restore it atomically.
@@ -2537,55 +2132,47 @@ static bool cmakeCheckStampFile(const char* stampName)
   std::string stampTempString = stampTempStream.str();
   const char* stampTemp = stampTempString.c_str();
   {
-  // TODO: Teach cmGeneratedFileStream to use a random temp file (with
-  // multiple tries in unlikely case of conflict) and use that here.
-  cmsys::ofstream stamp(stampTemp);
-  stamp << "# CMake generation timestamp file for this directory.\n";
+    // TODO: Teach cmGeneratedFileStream to use a random temp file (with
+    // multiple tries in unlikely case of conflict) and use that here.
+    cmsys::ofstream stamp(stampTemp);
+    stamp << "# CMake generation timestamp file for this directory.\n";
   }
-  if(cmSystemTools::RenameFile(stampTemp, stampName))
-    {
+  if (cmSystemTools::RenameFile(stampTemp, stampName)) {
     // Notify the user why CMake is not re-running.  It is safe to
     // just print to stdout here because this code is only reachable
     // through an undocumented flag used by the VS generator.
-    std::cout << "CMake does not need to re-run because "
-              << stampName << " is up-to-date.\n";
+    std::cout << "CMake does not need to re-run because " << stampName
+              << " is up-to-date.\n";
     return true;
-    }
-  else
-    {
+  } else {
     cmSystemTools::RemoveFile(stampTemp);
     cmSystemTools::Error("Cannot restore timestamp ", stampName);
     return false;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 static bool cmakeCheckStampList(const char* stampList)
 {
   // If the stamp list does not exist CMake must rerun to generate it.
-  if(!cmSystemTools::FileExists(stampList))
-    {
+  if (!cmSystemTools::FileExists(stampList)) {
     std::cout << "CMake is re-running because generate.stamp.list "
               << "is missing.\n";
     return false;
-    }
+  }
   cmsys::ifstream fin(stampList);
-  if(!fin)
-    {
+  if (!fin) {
     std::cout << "CMake is re-running because generate.stamp.list "
               << "could not be read.\n";
     return false;
-    }
+  }
 
   // Check each stamp.
   std::string stampName;
-  while(cmSystemTools::GetLineFromStream(fin, stampName))
-    {
-    if(!cmakeCheckStampFile(stampName.c_str()))
-      {
+  while (cmSystemTools::GetLineFromStream(fin, stampName)) {
+    if (!cmakeCheckStampFile(stampName.c_str())) {
       return false;
-      }
     }
+  }
   return true;
 }
 
@@ -2593,30 +2180,22 @@ cmake::MessageType cmake::ConvertMessageType(cmake::MessageType t)
 {
   bool warningsAsErrors;
 
-  if (t == cmake::AUTHOR_WARNING || t == cmake::AUTHOR_ERROR)
-    {
+  if (t == cmake::AUTHOR_WARNING || t == cmake::AUTHOR_ERROR) {
     warningsAsErrors = this->GetDevWarningsAsErrors();
-    if (warningsAsErrors && t == cmake::AUTHOR_WARNING)
-      {
+    if (warningsAsErrors && t == cmake::AUTHOR_WARNING) {
       t = cmake::AUTHOR_ERROR;
-      }
-    else if (!warningsAsErrors && t == cmake::AUTHOR_ERROR)
-      {
+    } else if (!warningsAsErrors && t == cmake::AUTHOR_ERROR) {
       t = cmake::AUTHOR_WARNING;
-      }
     }
-  else if (t == cmake::DEPRECATION_WARNING || t == cmake::DEPRECATION_ERROR)
-    {
+  } else if (t == cmake::DEPRECATION_WARNING ||
+             t == cmake::DEPRECATION_ERROR) {
     warningsAsErrors = this->GetDeprecatedWarningsAsErrors();
-    if (warningsAsErrors && t == cmake::DEPRECATION_WARNING)
-      {
+    if (warningsAsErrors && t == cmake::DEPRECATION_WARNING) {
       t = cmake::DEPRECATION_ERROR;
-      }
-    else if (!warningsAsErrors && t == cmake::DEPRECATION_ERROR)
-      {
+    } else if (!warningsAsErrors && t == cmake::DEPRECATION_ERROR) {
       t = cmake::DEPRECATION_WARNING;
-      }
     }
+  }
 
   return t;
 }
@@ -2625,34 +2204,23 @@ bool cmake::IsMessageTypeVisible(cmake::MessageType t)
 {
   bool isVisible = true;
 
-  if(t == cmake::DEPRECATION_ERROR)
-    {
-    if(!this->GetDeprecatedWarningsAsErrors())
-      {
+  if (t == cmake::DEPRECATION_ERROR) {
+    if (!this->GetDeprecatedWarningsAsErrors()) {
       isVisible = false;
-      }
     }
-  else if (t == cmake::DEPRECATION_WARNING)
-    {
-    if (this->GetSuppressDeprecatedWarnings())
-      {
+  } else if (t == cmake::DEPRECATION_WARNING) {
+    if (this->GetSuppressDeprecatedWarnings()) {
       isVisible = false;
-      }
     }
-  else if (t == cmake::AUTHOR_ERROR)
-    {
-    if (!this->GetDevWarningsAsErrors())
-      {
+  } else if (t == cmake::AUTHOR_ERROR) {
+    if (!this->GetDevWarningsAsErrors()) {
       isVisible = false;
-      }
     }
-  else if (t == cmake::AUTHOR_WARNING)
-    {
-    if (this->GetSuppressDevWarnings())
-      {
+  } else if (t == cmake::AUTHOR_WARNING) {
+    if (this->GetSuppressDevWarnings()) {
       isVisible = false;
-      }
     }
+  }
 
   return isVisible;
 }
@@ -2660,127 +2228,93 @@ bool cmake::IsMessageTypeVisible(cmake::MessageType t)
 bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg)
 {
   // Construct the message header.
-  if(t == cmake::FATAL_ERROR)
-    {
+  if (t == cmake::FATAL_ERROR) {
     msg << "CMake Error";
-    }
-  else if(t == cmake::INTERNAL_ERROR)
-    {
+  } else if (t == cmake::INTERNAL_ERROR) {
     msg << "CMake Internal Error (please report a bug)";
-    }
-  else if(t == cmake::LOG)
-    {
+  } else if (t == cmake::LOG) {
     msg << "CMake Debug Log";
-    }
-  else if(t == cmake::DEPRECATION_ERROR)
-    {
+  } else if (t == cmake::DEPRECATION_ERROR) {
     msg << "CMake Deprecation Error";
-    }
-  else if (t == cmake::DEPRECATION_WARNING)
-    {
+  } else if (t == cmake::DEPRECATION_WARNING) {
     msg << "CMake Deprecation Warning";
-    }
-  else if (t == cmake::AUTHOR_WARNING)
-    {
+  } else if (t == cmake::AUTHOR_WARNING) {
     msg << "CMake Warning (dev)";
-    }
-  else if (t == cmake::AUTHOR_ERROR)
-    {
+  } else if (t == cmake::AUTHOR_ERROR) {
     msg << "CMake Error (dev)";
-    }
-  else
-    {
+  } else {
     msg << "CMake Warning";
-    }
+  }
   return true;
 }
 
 void printMessageText(std::ostream& msg, std::string const& text)
 {
-   msg << ":\n";
-   cmDocumentationFormatter formatter;
-   formatter.SetIndent("  ");
-   formatter.PrintFormatted(msg, text.c_str());
+  msg << ":\n";
+  cmDocumentationFormatter formatter;
+  formatter.SetIndent("  ");
+  formatter.PrintFormatted(msg, text.c_str());
 }
 
 void displayMessage(cmake::MessageType t, std::ostringstream& msg)
 {
 
   // Add a note about warning suppression.
-  if(t == cmake::AUTHOR_WARNING)
-    {
-    msg <<
-      "This warning is for project developers.  Use -Wno-dev to suppress it.";
-    }
-  else if (t == cmake::AUTHOR_ERROR)
-    {
-    msg <<
-      "This error is for project developers. Use -Wno-error=dev to suppress "
-      "it.";
-    }
+  if (t == cmake::AUTHOR_WARNING) {
+    msg << "This warning is for project developers.  Use -Wno-dev to suppress "
+           "it.";
+  } else if (t == cmake::AUTHOR_ERROR) {
+    msg << "This error is for project developers. Use -Wno-error=dev to "
+           "suppress "
+           "it.";
+  }
 
   // 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:"))
-        {
+  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";
       }
+      msg << stack << "\n";
     }
+  }
 #endif
 
   // Output the message.
-  if(t == cmake::FATAL_ERROR
-     || t == cmake::INTERNAL_ERROR
-     || t == cmake::DEPRECATION_ERROR
-     || t == cmake::AUTHOR_ERROR)
-    {
+  if (t == cmake::FATAL_ERROR || t == cmake::INTERNAL_ERROR ||
+      t == cmake::DEPRECATION_ERROR || t == cmake::AUTHOR_ERROR) {
     cmSystemTools::SetErrorOccured();
     cmSystemTools::Message(msg.str().c_str(), "Error");
-    }
-  else
-    {
+  } else {
     cmSystemTools::Message(msg.str().c_str(), "Warning");
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
-                         cmListFileBacktrace const& bt,
-                         bool force)
+                         cmListFileBacktrace const& backtrace, bool force)
 {
-  cmListFileBacktrace backtrace = bt;
-
-  if (!force)
-    {
+  if (!force) {
     // override the message type, if needed, for warnings and errors
     cmake::MessageType override = this->ConvertMessageType(t);
-    if (override != t)
-      {
+    if (override != t) {
       t = override;
       force = true;
-      }
     }
+  }
 
-  if (!force && !this->IsMessageTypeVisible(t))
-    {
+  if (!force && !this->IsMessageTypeVisible(t)) {
     return;
-    }
+  }
 
   std::ostringstream msg;
-  if (!this->PrintMessagePreamble(t, msg))
-    {
+  if (!this->PrintMessagePreamble(t, msg)) {
     return;
-    }
+  }
 
   // Add the immediate context.
   backtrace.PrintTitle(msg);
@@ -2793,142 +2327,86 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
   displayMessage(t, msg);
 }
 
-//----------------------------------------------------------------------------
-void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
-                         cmListFileContext const& lfc,
-                         bool force)
-{
-  if (!force)
-    {
-    // override the message type, if needed, for warnings and errors
-    cmake::MessageType override = this->ConvertMessageType(t);
-    if (override != t)
-      {
-      t = override;
-      force = true;
-      }
-    }
-
-  if (!force && !this->IsMessageTypeVisible(t))
-    {
-    return;
-    }
-
-  std::ostringstream msg;
-  if (!this->PrintMessagePreamble(t, msg))
-    {
-    return;
-    }
-
-  // Add the immediate context.
-  msg << (lfc.Line ? " at " : " in ") << lfc;
-
-  printMessageText(msg, text);
-
-  displayMessage(t, msg);
-}
-
-//----------------------------------------------------------------------------
 std::vector<std::string> cmake::GetDebugConfigs()
 {
   std::vector<std::string> configs;
-  if(const char* config_list =
-                      this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS"))
-    {
+  if (const char* config_list =
+        this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) {
     // Expand the specified list and convert to upper-case.
     cmSystemTools::ExpandListArgument(config_list, configs);
-    std::transform(configs.begin(),
-                   configs.end(),
-                   configs.begin(),
+    std::transform(configs.begin(), configs.end(), configs.begin(),
                    cmSystemTools::UpperCase);
-    }
+  }
   // If no configurations were specified, use a default list.
-  if(configs.empty())
-    {
+  if (configs.empty()) {
     configs.push_back("DEBUG");
-    }
+  }
   return configs;
 }
 
-
-int cmake::Build(const std::string& dir,
-                 const std::string& target,
+int cmake::Build(const std::string& dir, const std::string& target,
                  const std::string& config,
-                 const std::vector<std::string>& nativeOptions,
-                 bool clean)
+                 const std::vector<std::string>& nativeOptions, bool clean)
 {
 
   this->SetHomeDirectory("");
   this->SetHomeOutputDirectory("");
-  if(!cmSystemTools::FileIsDirectory(dir))
-    {
+  if (!cmSystemTools::FileIsDirectory(dir)) {
     std::cerr << "Error: " << dir << " is not a directory\n";
     return 1;
-    }
+  }
   std::string cachePath = dir;
   cmSystemTools::ConvertToUnixSlashes(cachePath);
   std::string cacheFile = cachePath;
   cacheFile += "/CMakeCache.txt";
-  if(!cmSystemTools::FileExists(cacheFile.c_str()))
-    {
+  if (!cmSystemTools::FileExists(cacheFile.c_str())) {
     // search in parent directories for cache
     std::string cmakeFiles = cachePath;
     cmakeFiles += "/CMakeFiles";
-    if(cmSystemTools::FileExists(cmakeFiles.c_str()))
-      {
+    if (cmSystemTools::FileExists(cmakeFiles.c_str())) {
       std::string cachePathFound =
-        cmSystemTools::FileExistsInParentDirectories(
-          "CMakeCache.txt", cachePath.c_str(), "/");
-      if(!cachePathFound.empty())
-        {
+        cmSystemTools::FileExistsInParentDirectories("CMakeCache.txt",
+                                                     cachePath.c_str(), "/");
+      if (!cachePathFound.empty()) {
         cachePath = cmSystemTools::GetFilenamePath(cachePathFound);
-        }
       }
     }
+  }
 
-  if(!this->LoadCache(cachePath))
-    {
+  if (!this->LoadCache(cachePath)) {
     std::cerr << "Error: could not load cache\n";
     return 1;
-    }
+  }
   const char* cachedGenerator =
-      this->State->GetCacheEntryValue("CMAKE_GENERATOR");
-  if(!cachedGenerator)
-    {
+    this->State->GetCacheEntryValue("CMAKE_GENERATOR");
+  if (!cachedGenerator) {
     std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
     return 1;
-    }
+  }
   cmsys::auto_ptr<cmGlobalGenerator> gen(
     this->CreateGlobalGenerator(cachedGenerator));
-  if(!gen.get())
-    {
-    std::cerr << "Error: could create CMAKE_GENERATOR \""
-              << cachedGenerator << "\"\n";
+  if (!gen.get()) {
+    std::cerr << "Error: could create CMAKE_GENERATOR \"" << cachedGenerator
+              << "\"\n";
     return 1;
-    }
+  }
   std::string output;
   std::string projName;
   const char* cachedProjectName =
-      this->State->GetCacheEntryValue("CMAKE_PROJECT_NAME");
-  if(!cachedProjectName)
-    {
+    this->State->GetCacheEntryValue("CMAKE_PROJECT_NAME");
+  if (!cachedProjectName) {
     std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n";
     return 1;
-    }
+  }
   projName = cachedProjectName;
   bool verbose = false;
   const char* cachedVerbose =
-      this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
-  if(cachedVerbose)
-    {
+    this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
+  if (cachedVerbose) {
     verbose = cmSystemTools::IsOn(cachedVerbose);
-    }
-  return gen->Build("", dir,
-                    projName, target,
-                    output,
-                    "",
-                    config, clean, false, verbose, 0,
-                    cmSystemTools::OUTPUT_PASSTHROUGH,
+  }
+  return gen->Build("", dir, projName, target, output, "", config, clean,
+                    false, verbose, 0, cmSystemTools::OUTPUT_PASSTHROUGH,
                     nativeOptions);
 }
 
@@ -2936,10 +2414,9 @@ void cmake::WatchUnusedCli(const std::string& var)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
-  if(this->UsedCliVariables.find(var) == this->UsedCliVariables.end())
-    {
+  if (this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) {
     this->UsedCliVariables[var] = false;
-    }
+  }
 #endif
 }
 
@@ -2957,20 +2434,17 @@ void cmake::RunCheckForUnusedVariables()
   bool haveUnused = false;
   std::ostringstream msg;
   msg << "Manually-specified variables were not used by the project:";
-  for(std::map<std::string, bool>::const_iterator
-        it = this->UsedCliVariables.begin();
-      it != this->UsedCliVariables.end(); ++it)
-    {
-    if(!it->second)
-      {
+  for (std::map<std::string, bool>::const_iterator it =
+         this->UsedCliVariables.begin();
+       it != this->UsedCliVariables.end(); ++it) {
+    if (!it->second) {
       haveUnused = true;
       msg << "\n  " << it->first;
-      }
     }
-  if(haveUnused)
-    {
+  }
+  if (haveUnused) {
     this->IssueMessage(cmake::WARNING, msg.str());
-    }
+  }
 #endif
 }
 
@@ -2980,16 +2454,13 @@ bool cmake::GetSuppressDevWarnings(cmMakefile const* mf)
    * The suppression CMake variable may be set in the CMake configuration file
    * itself, so we have to check what its set to in the makefile if we can.
    */
-  if (mf)
-    {
+  if (mf) {
     return mf->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
-    }
-  else
-    {
-    const char* cacheEntryValue = this->State->GetCacheEntryValue(
-      "CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
+  } else {
+    const char* cacheEntryValue =
+      this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
     return cmSystemTools::IsOn(cacheEntryValue);
-    }
+  }
 }
 
 void cmake::SetSuppressDevWarnings(bool b)
@@ -2997,15 +2468,13 @@ void cmake::SetSuppressDevWarnings(bool b)
   std::string value;
 
   // equivalent to -Wno-dev
-  if (b)
-    {
+  if (b) {
     value = "TRUE";
-    }
+  }
   // equivalent to -Wdev
-  else
-    {
+  else {
     value = "FALSE";
-    }
+  }
 
   this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", value.c_str(),
                       "Suppress Warnings that are meant for"
@@ -3019,17 +2488,14 @@ bool cmake::GetSuppressDeprecatedWarnings(cmMakefile const* mf)
    * The suppression CMake variable may be set in the CMake configuration file
    * itself, so we have to check what its set to in the makefile if we can.
    */
-  if (mf)
-    {
+  if (mf) {
     return (mf->IsSet("CMAKE_WARN_DEPRECATED") &&
             !mf->IsOn("CMAKE_WARN_DEPRECATED"));
-    }
-  else
-    {
-    const char* cacheEntryValue = this->State->GetCacheEntryValue(
-      "CMAKE_WARN_DEPRECATED");
+  } else {
+    const char* cacheEntryValue =
+      this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
     return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
-    }
+  }
 }
 
 void cmake::SetSuppressDeprecatedWarnings(bool b)
@@ -3037,15 +2503,13 @@ void cmake::SetSuppressDeprecatedWarnings(bool b)
   std::string value;
 
   // equivalent to -Wno-deprecated
-  if (b)
-    {
+  if (b) {
     value = "FALSE";
-    }
+  }
   // equivalent to -Wdeprecated
-  else
-    {
+  else {
     value = "TRUE";
-    }
+  }
 
   this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value.c_str(),
                       "Whether to issue warnings for deprecated "
@@ -3055,17 +2519,14 @@ void cmake::SetSuppressDeprecatedWarnings(bool b)
 
 bool cmake::GetDevWarningsAsErrors(cmMakefile const* mf)
 {
-  if (mf)
-    {
+  if (mf) {
     return (mf->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
             !mf->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS"));
-    }
-  else
-    {
-    const char* cacheEntryValue = this->State->GetCacheEntryValue(
-      "CMAKE_SUPPRESS_DEVELOPER_ERRORS");
+  } else {
+    const char* cacheEntryValue =
+      this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS");
     return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
-    }
+  }
 }
 
 void cmake::SetDevWarningsAsErrors(bool b)
@@ -3073,15 +2534,13 @@ void cmake::SetDevWarningsAsErrors(bool b)
   std::string value;
 
   // equivalent to -Werror=dev
-  if (b)
-    {
+  if (b) {
     value = "FALSE";
-    }
+  }
   // equivalent to -Wno-error=dev
-  else
-    {
+  else {
     value = "TRUE";
-    }
+  }
 
   this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", value.c_str(),
                       "Suppress errors that are meant for"
@@ -3091,16 +2550,13 @@ void cmake::SetDevWarningsAsErrors(bool b)
 
 bool cmake::GetDeprecatedWarningsAsErrors(cmMakefile const* mf)
 {
-  if (mf)
-    {
+  if (mf) {
     return mf->IsOn("CMAKE_ERROR_DEPRECATED");
-    }
-  else
-    {
-    const char* cacheEntryValue = this->State->GetCacheEntryValue(
-      "CMAKE_ERROR_DEPRECATED");
+  } else {
+    const char* cacheEntryValue =
+      this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
     return cmSystemTools::IsOn(cacheEntryValue);
-    }
+  }
 }
 
 void cmake::SetDeprecatedWarningsAsErrors(bool b)
@@ -3108,15 +2564,13 @@ void cmake::SetDeprecatedWarningsAsErrors(bool b)
   std::string value;
 
   // equivalent to -Werror=deprecated
-  if (b)
-    {
+  if (b) {
     value = "TRUE";
-    }
+  }
   // equivalent to -Wno-error=deprecated
-  else
-    {
+  else {
     value = "FALSE";
-    }
+  }
 
   this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value.c_str(),
                       "Whether to issue deprecation errors for macros"
diff --git a/Source/cmake.h b/Source/cmake.h
index 8496705..266c33d 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -13,11 +13,13 @@
 #ifndef cmake_h
 #define cmake_h
 
-#include "cmListFileCache.h"
-#include "cmSystemTools.h"
-#include "cmInstalledFile.h"
+#include "cmStandardIncludes.h"
+
 #include "cmCacheManager.h"
+#include "cmInstalledFile.h"
+#include "cmListFileCache.h"
 #include "cmState.h"
+#include "cmSystemTools.h"
 
 class cmGlobalGeneratorFactory;
 class cmGlobalGenerator;
@@ -56,9 +58,10 @@ class cmGeneratedFileStream;
 
 class cmake
 {
- public:
+public:
   enum MessageType
-  { AUTHOR_WARNING,
+  {
+    AUTHOR_WARNING,
     AUTHOR_ERROR,
     FATAL_ERROR,
     INTERNAL_ERROR,
@@ -80,12 +83,12 @@ class cmake
   enum WorkingMode
   {
     NORMAL_MODE, ///< Cmake runs to create project files
-    /** \brief Script mode (started by using -P).
-     *
-     * In script mode there is no generator and no cache. Also,
-     * languages are not enabled, so add_executable and things do
-     * nothing.
-     */
+                 /** \brief Script mode (started by using -P).
+                  *
+                  * In script mode there is no generator and no cache. Also,
+                  * languages are not enabled, so add_executable and things do
+                  * nothing.
+                  */
     SCRIPT_MODE,
     /** \brief A pkg-config like mode
      *
@@ -98,10 +101,10 @@ class cmake
   };
 
   struct GeneratorInfo
-    {
+  {
     std::string name;
     bool supportsToolset;
-    };
+  };
 
   typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;
 
@@ -110,9 +113,11 @@ class cmake
   /// Destructor
   ~cmake();
 
-  static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";}
-  static const char *GetCMakeFilesDirectoryPostSlash() {
-    return "CMakeFiles/";}
+  static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; }
+  static const char* GetCMakeFilesDirectoryPostSlash()
+  {
+    return "CMakeFiles/";
+  }
 
   //@{
   /**
@@ -129,9 +134,11 @@ class cmake
   /**
    * Handle a command line invocation of cmake.
    */
-  int Run(const std::vector<std::string>&args)
-    { return this->Run(args, false); }
-  int Run(const std::vector<std::string>&args, bool noconfigure);
+  int Run(const std::vector<std::string>& args)
+  {
+    return this->Run(args, false);
+  }
+  int Run(const std::vector<std::string>& args, bool noconfigure);
 
   /**
    * Run the global generator Generate step.
@@ -148,10 +155,9 @@ class cmake
   int ActualConfigure();
 
   ///! Break up a line like VAR:type="value" into var, type and value
-  static bool ParseCacheEntry(const std::string& entry,
-                         std::string& var,
-                         std::string& value,
-                         cmState::CacheEntryType& type);
+  static bool ParseCacheEntry(const std::string& entry, std::string& var,
+                              std::string& value,
+                              cmState::CacheEntryType& type);
 
   int LoadCache();
   bool LoadCache(const std::string& path);
@@ -166,40 +172,54 @@ class cmake
   cmGlobalGenerator* CreateGlobalGenerator(const std::string& name);
 
   ///! Return the global generator assigned to this instance of cmake
-  cmGlobalGenerator* GetGlobalGenerator()     { return this->GlobalGenerator; }
+  cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
   ///! Return the global generator assigned to this instance of cmake, const
   const cmGlobalGenerator* GetGlobalGenerator() const
-                                              { return this->GlobalGenerator; }
+  {
+    return this->GlobalGenerator;
+  }
 
   ///! Return the global generator assigned to this instance of cmake
-  void SetGlobalGenerator(cmGlobalGenerator *);
+  void SetGlobalGenerator(cmGlobalGenerator*);
 
   ///! Get the names of the current registered generators
   void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators);
 
   ///! Set the name of the selected generator-specific platform.
   void SetGeneratorPlatform(std::string const& ts)
-    { this->GeneratorPlatform = ts; }
+  {
+    this->GeneratorPlatform = ts;
+  }
 
   ///! Get the name of the selected generator-specific platform.
   std::string const& GetGeneratorPlatform() const
-    { return this->GeneratorPlatform; }
+  {
+    return this->GeneratorPlatform;
+  }
 
   ///! Set the name of the selected generator-specific toolset.
   void SetGeneratorToolset(std::string const& ts)
-    { this->GeneratorToolset = ts; }
+  {
+    this->GeneratorToolset = ts;
+  }
 
   ///! Get the name of the selected generator-specific toolset.
   std::string const& GetGeneratorToolset() const
-    { return this->GeneratorToolset; }
+  {
+    return this->GeneratorToolset;
+  }
 
   ///! get the cmCachemManager used by this invocation of cmake
-  cmCacheManager *GetCacheManager() { return this->CacheManager; }
+  cmCacheManager* GetCacheManager() { return this->CacheManager; }
 
   const std::vector<std::string>& GetSourceExtensions() const
-    {return this->SourceFileExtensions;}
+  {
+    return this->SourceFileExtensions;
+  }
   const std::vector<std::string>& GetHeaderExtensions() const
-    {return this->HeaderFileExtensions;}
+  {
+    return this->HeaderFileExtensions;
+  }
 
   /**
    * Given a variable name, return its value (as a string).
@@ -207,8 +227,7 @@ class cmake
   const char* GetCacheDefinition(const std::string&) const;
   ///! Add an entry into the cache
   void AddCacheEntry(const std::string& key, const char* value,
-                     const char* helpString,
-                     int type);
+                     const char* helpString, int type);
 
   /**
    * Get the system information and write it to the file specified
@@ -226,8 +245,7 @@ class cmake
   ///! Parse command line arguments that might set cache values
   bool SetCacheArgs(const std::vector<std::string>&);
 
-  typedef  void (*ProgressCallbackType)
-    (const char*msg, float progress, void *);
+  typedef void (*ProgressCallbackType)(const char* msg, float progress, void*);
   /**
    *  Set the function used by GUIs to receive progress updates
    *  Function gets passed: message as a const char*, a progress
@@ -235,10 +253,10 @@ class cmake
    *  number provided may be negative in cases where a message is
    *  to be displayed without any progress percentage.
    */
-  void SetProgressCallback(ProgressCallbackType f, void* clientData=0);
+  void SetProgressCallback(ProgressCallbackType f, void* clientData = 0);
 
   ///! this is called by generators to update the progress
-  void UpdateProgress(const char *msg, float prog);
+  void UpdateProgress(const char* msg, float prog);
 
   ///! Get the variable watch object
   cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
@@ -246,20 +264,22 @@ class cmake
   void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
 
   ///! Set/Get a property of this target file
-  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);
+  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);
   bool GetPropertyAsBool(const std::string& prop);
 
   ///! Get or create an cmInstalledFile instance and return a pointer to it
-  cmInstalledFile *GetOrCreateInstalledFile(
-    cmMakefile* mf, const std::string& name);
+  cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf,
+                                            const std::string& name);
 
   cmInstalledFile const* GetInstalledFile(const std::string& name) const;
 
   InstalledFilesMap const& GetInstalledFiles() const
-    { return this->InstalledFiles; }
+  {
+    return this->InstalledFiles;
+  }
 
   ///! Do all the checks before running configure
   int DoPreConfigureChecks();
@@ -268,8 +288,8 @@ class cmake
   WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
 
   ///! Debug the try compile stuff by not deleting the files
-  bool GetDebugTryCompile(){return this->DebugTryCompile;}
-  void DebugTryCompileOn(){this->DebugTryCompile = true;}
+  bool GetDebugTryCompile() { return this->DebugTryCompile; }
+  void DebugTryCompileOn() { this->DebugTryCompile = true; }
 
   /**
    * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
@@ -283,21 +303,21 @@ class cmake
 
   // Do we want debug output during the cmake run.
   bool GetDebugOutput() { return this->DebugOutput; }
-  void SetDebugOutputOn(bool b) { this->DebugOutput = b;}
+  void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
 
   // Do we want trace output during the cmake run.
-  bool GetTrace() { return this->Trace;}
-  void SetTrace(bool b) {  this->Trace = b;}
-  bool GetTraceExpand() { return this->TraceExpand;}
-  void SetTraceExpand(bool b) {  this->TraceExpand = b;}
-  bool GetWarnUninitialized() { return this->WarnUninitialized;}
-  void SetWarnUninitialized(bool b) {  this->WarnUninitialized = b;}
-  bool GetWarnUnused() { return this->WarnUnused;}
-  void SetWarnUnused(bool b) {  this->WarnUnused = b;}
-  bool GetWarnUnusedCli() { return this->WarnUnusedCli;}
-  void SetWarnUnusedCli(bool b) {  this->WarnUnusedCli = b;}
-  bool GetCheckSystemVars() { return this->CheckSystemVars;}
-  void SetCheckSystemVars(bool b) {  this->CheckSystemVars = b;}
+  bool GetTrace() { return this->Trace; }
+  void SetTrace(bool b) { this->Trace = b; }
+  bool GetTraceExpand() { return this->TraceExpand; }
+  void SetTraceExpand(bool b) { this->TraceExpand = b; }
+  bool GetWarnUninitialized() { return this->WarnUninitialized; }
+  void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
+  bool GetWarnUnused() { return this->WarnUnused; }
+  void SetWarnUnused(bool b) { this->WarnUnused = b; }
+  bool GetWarnUnusedCli() { return this->WarnUnusedCli; }
+  void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
+  bool GetCheckSystemVars() { return this->CheckSystemVars; }
+  void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
 
   void MarkCliAsUsed(const std::string& variable);
 
@@ -306,9 +326,13 @@ class cmake
   std::vector<std::string> GetDebugConfigs();
 
   void SetCMakeEditCommand(std::string const& s)
-    { this->CMakeEditCommand = s; }
+  {
+    this->CMakeEditCommand = s;
+  }
   std::string const& GetCMakeEditCommand() const
-    { return this->CMakeEditCommand; }
+  {
+    return this->CMakeEditCommand;
+  }
 
   /*
    * Get the state of the suppression of developer (author) warnings.
@@ -355,38 +379,38 @@ class cmake
   void SetDeprecatedWarningsAsErrors(bool v);
 
   /** Display a message to the user.  */
-  void IssueMessage(cmake::MessageType t, std::string const& text,
-        cmListFileBacktrace const& backtrace = cmListFileBacktrace(),
-        bool force = false);
-  void IssueMessage(cmake::MessageType t, std::string const& text,
-        cmListFileContext const& lfc,
-        bool force = false);
+  void IssueMessage(
+    cmake::MessageType t, std::string const& text,
+    cmListFileBacktrace const& backtrace = cmListFileBacktrace(),
+    bool force = false);
 
   ///! run the --build option
-  int Build(const std::string& dir,
-            const std::string& target,
+  int Build(const std::string& dir, const std::string& target,
             const std::string& config,
-            const std::vector<std::string>& nativeOptions,
-            bool clean);
+            const std::vector<std::string>& nativeOptions, bool clean);
 
   void UnwatchUnusedCli(const std::string& var);
   void WatchUnusedCli(const std::string& var);
 
   cmState* GetState() const { return this->State; }
   void SetCurrentSnapshot(cmState::Snapshot snapshot)
-  { this->CurrentSnapshot = snapshot; }
+  {
+    this->CurrentSnapshot = snapshot;
+  }
   cmState::Snapshot GetCurrentSnapshot() const
-  { return this->CurrentSnapshot; }
+  {
+    return this->CurrentSnapshot;
+  }
 
 protected:
   void RunCheckForUnusedVariables();
   void InitializeProperties();
   int HandleDeleteCacheVariables(const std::string& var);
 
-  typedef
-     cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
-  typedef std::map<std::string,
-                CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
+  typedef cmExternalMakefileProjectGenerator* (
+    *CreateExtraGeneratorFunctionType)();
+  typedef std::map<std::string, CreateExtraGeneratorFunctionType>
+    RegisteredExtraGeneratorsMap;
   typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
   RegisteredGeneratorsVector Generators;
   RegisteredExtraGeneratorsMap ExtraGenerators;
@@ -396,14 +420,14 @@ protected:
   void AddExtraGenerator(const std::string& name,
                          CreateExtraGeneratorFunctionType newFunction);
 
-  cmGlobalGenerator *GlobalGenerator;
-  cmCacheManager *CacheManager;
+  cmGlobalGenerator* GlobalGenerator;
+  cmCacheManager* CacheManager;
   std::map<std::string, DiagLevel> DiagLevels;
   std::string GeneratorPlatform;
   std::string GeneratorToolset;
 
   ///! read in a cmake list file to initialize the cache
-  void ReadListFile(const std::vector<std::string>& args, const char *path);
+  void ReadListFile(const std::vector<std::string>& args, const char* path);
   bool FindPackage(const std::vector<std::string>& args);
 
   ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
@@ -427,8 +451,8 @@ protected:
   cmVariableWatch* VariableWatch;
 
 private:
-  cmake(const cmake&);  // Not implemented.
-  void operator=(const cmake&);  // Not implemented.
+  cmake(const cmake&);          // Not implemented.
+  void operator=(const cmake&); // Not implemented.
   ProgressCallbackType ProgressCallback;
   void* ProgressCallbackClientData;
   bool Verbose;
@@ -480,87 +504,91 @@ private:
   bool PrintMessagePreamble(cmake::MessageType t, std::ostream& msg);
 };
 
-#define CMAKE_STANDARD_OPTIONS_TABLE \
-  {"-C <initial-cache>", "Pre-load a script to populate the cache."}, \
-  {"-D <var>[:<type>]=<value>", "Create a cmake cache entry."}, \
-  {"-U <globbing_expr>", "Remove matching entries from CMake cache."}, \
-  {"-G <generator-name>", "Specify a build system generator."},\
-  {"-T <toolset-name>", "Specify toolset name if supported by generator."}, \
-  {"-A <platform-name>", "Specify platform name if supported by generator."}, \
-  {"-Wdev", "Enable developer warnings."},\
-  {"-Wno-dev", "Suppress developer warnings."},\
-  {"-Werror=dev", "Make developer warnings errors."},\
-  {"-Wno-error=dev", "Make developer warnings not errors."},\
-  {"-Wdeprecated", "Enable deprecation warnings."},\
-  {"-Wno-deprecated", "Suppress deprecation warnings."},\
-  {"-Werror=deprecated", "Make deprecated macro and function warnings " \
-                         "errors."},\
-  {"-Wno-error=deprecated", "Make deprecated macro and function warnings " \
-                            "not errors."}
-
-#define FOR_EACH_C_FEATURE(F) \
-  F(c_function_prototypes) \
-  F(c_restrict) \
-  F(c_static_assert) \
+#define CMAKE_STANDARD_OPTIONS_TABLE                                          \
+  { "-C <initial-cache>", "Pre-load a script to populate the cache." },       \
+    { "-D <var>[:<type>]=<value>", "Create a cmake cache entry." },           \
+    { "-U <globbing_expr>", "Remove matching entries from CMake cache." },    \
+    { "-G <generator-name>", "Specify a build system generator." },           \
+    { "-T <toolset-name>",                                                    \
+      "Specify toolset name if supported by generator." },                    \
+    { "-A <platform-name>",                                                   \
+      "Specify platform name if supported by generator." },                   \
+    { "-Wdev", "Enable developer warnings." },                                \
+    { "-Wno-dev", "Suppress developer warnings." },                           \
+    { "-Werror=dev", "Make developer warnings errors." },                     \
+    { "-Wno-error=dev", "Make developer warnings not errors." },              \
+    { "-Wdeprecated", "Enable deprecation warnings." },                       \
+    { "-Wno-deprecated", "Suppress deprecation warnings." },                  \
+    { "-Werror=deprecated", "Make deprecated macro and function warnings "    \
+                            "errors." },                                      \
+  {                                                                           \
+    "-Wno-error=deprecated", "Make deprecated macro and function warnings "   \
+                             "not errors."                                    \
+  }
+
+#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) \
+#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 a06b26f..056671a 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -12,84 +12,73 @@
 // include these first, otherwise there will be problems on Windows
 // with GetCurrentDirectory() being redefined
 #ifdef CMAKE_BUILD_WITH_CMAKE
-#include "cmDynamicLoader.h"
 #include "cmDocumentation.h"
+#include "cmDynamicLoader.h"
 #endif
 
-#include "cmake.h"
-#include "cmcmd.h"
-#include "cmState.h"
-#include "cmListFileCache.h"
-#include "cmSourceFile.h"
+#include "cmAlgorithms.h"
 #include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
-#include "cmAlgorithms.h"
+#include "cmSourceFile.h"
+#include "cmState.h"
+#include "cmake.h"
+#include "cmcmd.h"
 #include <cmsys/Encoding.hxx>
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
-//----------------------------------------------------------------------------
-static const char * cmDocumentationName[][2] =
-{
-  {0,
-   "  cmake - Cross-Platform Makefile Generator."},
-  {0,0}
+static const char* cmDocumentationName[][2] = {
+  { 0, "  cmake - Cross-Platform Makefile Generator." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsage[][2] =
-{
-  {0,
-   "  cmake [options] <path-to-source>\n"
-   "  cmake [options] <path-to-existing-build>"},
-  {0,
-   "Specify a source directory to (re-)generate a build system for "
-   "it in the current working directory.  Specify an existing build "
-   "directory to re-generate its build system."},
-  {0,0}
+static const char* cmDocumentationUsage[][2] = {
+  { 0, "  cmake [options] <path-to-source>\n"
+       "  cmake [options] <path-to-existing-build>" },
+  { 0, "Specify a source directory to (re-)generate a build system for "
+       "it in the current working directory.  Specify an existing build "
+       "directory to re-generate its build system." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsageNote[][2] =
-{
-  {0,
-   "Run 'cmake --help' for more information."},
-  {0,0}
+static const char* cmDocumentationUsageNote[][2] = {
+  { 0, "Run 'cmake --help' for more information." },
+  { 0, 0 }
 };
 
-#define CMAKE_BUILD_OPTIONS                                             \
-  "  <dir>          = Project binary directory to be built.\n"          \
-  "  --target <tgt> = Build <tgt> instead of default targets.\n"        \
-  "  --config <cfg> = For multi-configuration tools, choose <cfg>.\n"   \
-  "  --clean-first  = Build target 'clean' first, then build.\n"        \
-  "                   (To clean only, use --target 'clean'.)\n"         \
-  "  --use-stderr   = Ignored.  Behavior is default in CMake >= 3.0.\n" \
+#define CMAKE_BUILD_OPTIONS                                                   \
+  "  <dir>          = Project binary directory to be built.\n"                \
+  "  --target <tgt> = Build <tgt> instead of default targets.\n"              \
+  "                   May only be specified once.\n"                          \
+  "  --config <cfg> = For multi-configuration tools, choose <cfg>.\n"         \
+  "  --clean-first  = Build target 'clean' first, then build.\n"              \
+  "                   (To clean only, use --target 'clean'.)\n"               \
+  "  --use-stderr   = Ignored.  Behavior is default in CMake >= 3.0.\n"       \
   "  --             = Pass remaining options to the native tool.\n"
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationOptions[][2] =
-{
+static const char* cmDocumentationOptions[][2] = {
   CMAKE_STANDARD_OPTIONS_TABLE,
-  {"-E", "CMake command mode."},
-  {"-L[A][H]", "List non-advanced cached variables."},
-  {"--build <dir>", "Build a CMake-generated project binary tree."},
-  {"-N", "View mode only."},
-  {"-P <file>", "Process script mode."},
-  {"--find-package", "Run in pkg-config like mode."},
-  {"--graphviz=[file]", "Generate graphviz of dependencies, see "
-   "CMakeGraphVizOptions.cmake for more."},
-  {"--system-information [file]", "Dump information about this system."},
-  {"--debug-trycompile", "Do not delete the try_compile build tree. Only "
-   "useful on one try_compile at a time."},
-  {"--debug-output", "Put cmake in a debug mode."},
-  {"--trace", "Put cmake in trace mode."},
-  {"--trace-expand", "Put cmake in trace mode with variable expansion."},
-  {"--warn-uninitialized", "Warn about uninitialized values."},
-  {"--warn-unused-vars", "Warn about unused variables."},
-  {"--no-warn-unused-cli", "Don't warn about command line options."},
-  {"--check-system-vars", "Find problems with variable usage in system "
-   "files."},
-  {0,0}
+  { "-E", "CMake command mode." },
+  { "-L[A][H]", "List non-advanced cached variables." },
+  { "--build <dir>", "Build a CMake-generated project binary tree." },
+  { "-N", "View mode only." },
+  { "-P <file>", "Process script mode." },
+  { "--find-package", "Run in pkg-config like mode." },
+  { "--graphviz=[file]", "Generate graphviz of dependencies, see "
+                         "CMakeGraphVizOptions.cmake for more." },
+  { "--system-information [file]", "Dump information about this system." },
+  { "--debug-trycompile", "Do not delete the try_compile build tree. Only "
+                          "useful on one try_compile at a time." },
+  { "--debug-output", "Put cmake in a debug mode." },
+  { "--trace", "Put cmake in trace mode." },
+  { "--trace-expand", "Put cmake in trace mode with variable expansion." },
+  { "--warn-uninitialized", "Warn about uninitialized values." },
+  { "--warn-unused-vars", "Warn about unused variables." },
+  { "--no-warn-unused-cli", "Don't warn about command line options." },
+  { "--check-system-vars", "Find problems with variable usage in system "
+                           "files." },
+  { 0, 0 }
 };
 
 #endif
@@ -106,67 +95,59 @@ static int do_command(int ac, char const* const* av)
 int do_cmake(int ac, char const* const* av);
 static int do_build(int ac, char const* const* av);
 
-static cmMakefile* cmakemainGetMakefile(void *clientdata)
+static cmMakefile* cmakemainGetMakefile(void* clientdata)
 {
-  cmake* cm = (cmake *)clientdata;
-  if(cm && cm->GetDebugOutput())
-    {
-    cmGlobalGenerator* gg=cm->GetGlobalGenerator();
-    if (gg)
-      {
+  cmake* cm = (cmake*)clientdata;
+  if (cm && cm->GetDebugOutput()) {
+    cmGlobalGenerator* gg = cm->GetGlobalGenerator();
+    if (gg) {
       return gg->GetCurrentMakefile();
-      }
     }
+  }
   return 0;
 }
 
-static std::string cmakemainGetStack(void *clientdata)
+static std::string cmakemainGetStack(void* clientdata)
 {
   std::string msg;
-  cmMakefile* mf=cmakemainGetMakefile(clientdata);
-  if (mf)
-    {
+  cmMakefile* mf = cmakemainGetMakefile(clientdata);
+  if (mf) {
     msg = mf->FormatListFileStack();
-    if (!msg.empty())
-      {
+    if (!msg.empty()) {
       msg = "\n   Called from: " + msg;
-      }
     }
+  }
 
   return msg;
 }
 
 static void cmakemainMessageCallback(const char* m, const char*, bool&,
-                                     void *clientdata)
+                                     void* clientdata)
 {
   std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
 }
 
-static void cmakemainProgressCallback(const char *m, float prog,
+static void cmakemainProgressCallback(const char* m, float prog,
                                       void* clientdata)
 {
   cmMakefile* mf = cmakemainGetMakefile(clientdata);
   std::string dir;
-  if ((mf) && (strstr(m, "Configuring")==m) && (prog<0))
-    {
+  if ((mf) && (strstr(m, "Configuring") == m) && (prog < 0)) {
     dir = " ";
     dir += mf->GetCurrentSourceDirectory();
-    }
-  else if ((mf) && (strstr(m, "Generating")==m))
-    {
+  } else if ((mf) && (strstr(m, "Generating") == m)) {
     dir = " ";
     dir += mf->GetCurrentBinaryDirectory();
-    }
+  }
 
-  if ((prog < 0) || (!dir.empty()))
-    {
-    std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)<<std::endl;
-    }
+  if ((prog < 0) || (!dir.empty())) {
+    std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)
+              << std::endl;
+  }
 
   std::cout.flush();
 }
 
-
 int main(int ac, char const* const* av)
 {
   cmsys::Encoding::CommandLineArguments args =
@@ -176,17 +157,13 @@ int main(int ac, char const* const* av)
 
   cmSystemTools::EnableMSVCDebugHook();
   cmSystemTools::FindCMakeResources(av[0]);
-  if(ac > 1)
-    {
-    if(strcmp(av[1], "--build") == 0)
-      {
+  if (ac > 1) {
+    if (strcmp(av[1], "--build") == 0) {
       return do_build(ac, av);
-      }
-    else if(strcmp(av[1], "-E") == 0)
-      {
+    } else if (strcmp(av[1], "-E") == 0) {
       return do_command(ac, av);
-      }
     }
+  }
   int ret = do_cmake(ac, av);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmDynamicLoader::FlushCache();
@@ -196,18 +173,16 @@ int main(int ac, char const* const* av)
 
 int do_cmake(int ac, char const* const* av)
 {
-  if (cmSystemTools::GetCurrentWorkingDirectory().empty())
-    {
+  if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
     std::cerr << "Current working directory cannot be established."
               << std::endl;
     return 1;
-    }
+  }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmDocumentation doc;
   doc.addCMakeStandardDocSections();
-  if(doc.CheckOptions(ac, av))
-    {
+  if (doc.CheckOptions(ac, av)) {
     // Construct and print requested documentation.
     cmake hcm;
     hcm.SetHomeDirectory("");
@@ -224,25 +199,23 @@ int do_cmake(int ac, char const* const* av)
     hcm.GetGeneratorDocumentation(generators);
 
     doc.SetName("cmake");
-    doc.SetSection("Name",cmDocumentationName);
-    doc.SetSection("Usage",cmDocumentationUsage);
-    if ( ac == 1 )
-      {
-      doc.AppendSection("Usage",cmDocumentationUsageNote);
-      }
-    doc.AppendSection("Generators",generators);
-    doc.PrependSection("Options",cmDocumentationOptions);
-
-    return doc.PrintRequestedDocumentation(std::cout)? 0:1;
+    doc.SetSection("Name", cmDocumentationName);
+    doc.SetSection("Usage", cmDocumentationUsage);
+    if (ac == 1) {
+      doc.AppendSection("Usage", cmDocumentationUsageNote);
     }
+    doc.AppendSection("Generators", generators);
+    doc.PrependSection("Options", cmDocumentationOptions);
+
+    return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
+  }
 #else
-  if ( ac == 1 )
-    {
-    std::cout <<
-      "Bootstrap CMake should not be used outside CMake build process."
-              << std::endl;
+  if (ac == 1) {
+    std::cout
+      << "Bootstrap CMake should not be used outside CMake build process."
+      << std::endl;
     return 0;
-    }
+  }
 #endif
 
   bool sysinfo = false;
@@ -252,129 +225,96 @@ int do_cmake(int ac, char const* const* av)
   bool view_only = false;
   cmake::WorkingMode workingMode = cmake::NORMAL_MODE;
   std::vector<std::string> args;
-  for(int i =0; i < ac; ++i)
-    {
-    if(strcmp(av[i], "-i") == 0)
-      {
+  for (int i = 0; i < ac; ++i) {
+    if (strcmp(av[i], "-i") == 0) {
+      /* clang-format off */
       std::cerr <<
         "The \"cmake -i\" wizard mode is no longer supported.\n"
         "Use the -D option to set cache values on the command line.\n"
         "Use cmake-gui or ccmake for an interactive dialog.\n";
+      /* clang-format on */
       return 1;
-      }
-    else if(strcmp(av[i], "--system-information") == 0)
-      {
+    } else if (strcmp(av[i], "--system-information") == 0) {
       sysinfo = true;
-      }
-    else if (strcmp(av[i], "-N") == 0)
-      {
+    } else if (strcmp(av[i], "-N") == 0) {
       view_only = true;
-      }
-    else if (strcmp(av[i], "-L") == 0)
-      {
+    } else if (strcmp(av[i], "-L") == 0) {
       list_cached = true;
-      }
-    else if (strcmp(av[i], "-LA") == 0)
-      {
+    } else if (strcmp(av[i], "-LA") == 0) {
       list_all_cached = true;
-      }
-    else if (strcmp(av[i], "-LH") == 0)
-      {
+    } else if (strcmp(av[i], "-LH") == 0) {
       list_cached = true;
       list_help = true;
-      }
-    else if (strcmp(av[i], "-LAH") == 0)
-      {
+    } else if (strcmp(av[i], "-LAH") == 0) {
       list_all_cached = true;
       list_help = true;
-      }
-    else if (cmHasLiteralPrefix(av[i], "-P"))
-      {
-      if ( i == ac -1 )
-        {
+    } else if (cmHasLiteralPrefix(av[i], "-P")) {
+      if (i == ac - 1) {
         cmSystemTools::Error("No script specified for argument -P");
-        }
-      else
-        {
+      } else {
         workingMode = cmake::SCRIPT_MODE;
         args.push_back(av[i]);
         i++;
         args.push_back(av[i]);
-        }
       }
-    else if (cmHasLiteralPrefix(av[i], "--find-package"))
-      {
+    } else if (cmHasLiteralPrefix(av[i], "--find-package")) {
       workingMode = cmake::FIND_PACKAGE_MODE;
       args.push_back(av[i]);
-      }
-    else
-      {
+    } else {
       args.push_back(av[i]);
-      }
     }
-  if (sysinfo)
-    {
+  }
+  if (sysinfo) {
     cmake cm;
     cm.SetHomeDirectory("");
     cm.SetHomeOutputDirectory("");
     int ret = cm.GetSystemInformation(args);
     return ret;
-    }
+  }
   cmake cm;
   cm.SetHomeDirectory("");
   cm.SetHomeOutputDirectory("");
-  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
-  cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
+  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
+  cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
   cm.SetWorkingMode(workingMode);
 
   int res = cm.Run(args, view_only);
-  if ( list_cached || list_all_cached )
-    {
+  if (list_cached || list_all_cached) {
     std::cout << "-- Cache values" << std::endl;
     std::vector<std::string> keys = cm.GetState()->GetCacheEntryKeys();
     for (std::vector<std::string>::const_iterator it = keys.begin();
-        it != keys.end(); ++it)
-      {
+         it != keys.end(); ++it) {
       cmState::CacheEntryType t = cm.GetState()->GetCacheEntryType(*it);
       if (t != cmState::INTERNAL && t != cmState::STATIC &&
-          t != cmState::UNINITIALIZED)
-        {
+          t != cmState::UNINITIALIZED) {
         const char* advancedProp =
-            cm.GetState()->GetCacheEntryProperty(*it, "ADVANCED");
-        if ( list_all_cached || !advancedProp)
-          {
-          if ( list_help )
-            {
+          cm.GetState()->GetCacheEntryProperty(*it, "ADVANCED");
+        if (list_all_cached || !advancedProp) {
+          if (list_help) {
             std::cout << "// "
                       << cm.GetState()->GetCacheEntryProperty(*it,
-                                                   "HELPSTRING") << std::endl;
-            }
-          std::cout << *it << ":" <<
-            cmState::CacheEntryTypeToString(t)
-            << "=" << cm.GetState()->GetCacheEntryValue(*it)
-            << std::endl;
-          if ( list_help )
-            {
+                                                              "HELPSTRING")
+                      << std::endl;
+          }
+          std::cout << *it << ":" << cmState::CacheEntryTypeToString(t) << "="
+                    << cm.GetState()->GetCacheEntryValue(*it) << std::endl;
+          if (list_help) {
             std::cout << std::endl;
-            }
           }
         }
       }
     }
+  }
 
   // Always return a non-negative value.  Windows tools do not always
   // interpret negative return values as errors.
-  if(res != 0)
-    {
+  if (res != 0) {
     return 1;
-    }
-  else
-    {
+  } else {
     return 0;
-    }
+  }
 }
 
-//----------------------------------------------------------------------------
 static int do_build(int ac, char const* const* av)
 {
 #ifndef CMAKE_BUILD_WITH_CMAKE
@@ -386,40 +326,40 @@ static int do_build(int ac, char const* const* av)
   std::string dir;
   std::vector<std::string> nativeOptions;
   bool clean = false;
-
-  enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
+  bool hasTarget = false;
+
+  enum Doing
+  {
+    DoingNone,
+    DoingDir,
+    DoingTarget,
+    DoingConfig,
+    DoingNative
+  };
   Doing doing = DoingDir;
-  for(int i=2; i < ac; ++i)
-    {
-    if(doing == DoingNative)
-      {
+  for (int i = 2; i < ac; ++i) {
+    if (doing == DoingNative) {
       nativeOptions.push_back(av[i]);
+    } else if (strcmp(av[i], "--target") == 0) {
+      if (!hasTarget) {
+        doing = DoingTarget;
+        hasTarget = true;
+      } else {
+        std::cerr << "'--target' may not be specified more than once.\n\n";
+        dir = "";
+        break;
       }
-    else if(strcmp(av[i], "--target") == 0)
-      {
-      doing = DoingTarget;
-      }
-    else if(strcmp(av[i], "--config") == 0)
-      {
+    } else if (strcmp(av[i], "--config") == 0) {
       doing = DoingConfig;
-      }
-    else if(strcmp(av[i], "--clean-first") == 0)
-      {
+    } else if (strcmp(av[i], "--clean-first") == 0) {
       clean = true;
       doing = DoingNone;
-      }
-    else if(strcmp(av[i], "--use-stderr") == 0)
-      {
+    } else if (strcmp(av[i], "--use-stderr") == 0) {
       /* tolerate legacy option */
-      }
-    else if(strcmp(av[i], "--") == 0)
-      {
+    } else if (strcmp(av[i], "--") == 0) {
       doing = DoingNative;
-      }
-    else
-      {
-      switch (doing)
-        {
+    } else {
+      switch (doing) {
         case DoingDir:
           dir = cmSystemTools::CollapseFullPath(av[i]);
           doing = DoingNone;
@@ -436,25 +376,19 @@ static int do_build(int ac, char const* const* av)
           std::cerr << "Unknown argument " << av[i] << std::endl;
           dir = "";
           break;
-        }
       }
     }
-  if(dir.empty())
-    {
+  }
+  if (dir.empty()) {
+    /* clang-format off */
     std::cerr <<
       "Usage: cmake --build <dir> [options] [-- [native-options]]\n"
       "Options:\n"
       CMAKE_BUILD_OPTIONS
       ;
+    /* clang-format on */
     return 1;
-    }
-
-  // Hack for vs6 that passes ".\Debug" as "$(IntDir)" value:
-  //
-  if (cmSystemTools::StringStartsWith(config.c_str(), ".\\"))
-    {
-    config = config.substr(2);
-    }
+  }
 
   cmake cm;
   return cm.Build(dir, target, config, nativeOptions, clean);
diff --git a/Source/cmakexbuild.cxx b/Source/cmakexbuild.cxx
index 9aaeeaa..bdbc4da 100644
--- a/Source/cmakexbuild.cxx
+++ b/Source/cmakexbuild.cxx
@@ -9,9 +9,10 @@
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the License for more information.
 ============================================================================*/
-#include <cmsys/Process.h>
 #include "cmStandardIncludes.h"
+
 #include "cmSystemTools.h"
+#include <cmsys/Process.h>
 
 // This is a wrapper program for xcodebuild
 // it calls xcodebuild, and does two things
@@ -31,62 +32,49 @@ int RunXCode(std::vector<const char*>& argv, bool& hitbug)
   std::vector<char> err;
   std::string line;
   int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
-  while(pipe != cmsysProcess_Pipe_None)
-    {
-    if(line.find("/bin/sh: bad interpreter: Text file busy")
-       != line.npos)
-      {
+  while (pipe != cmsysProcess_Pipe_None) {
+    if (line.find("/bin/sh: bad interpreter: Text file busy") != line.npos) {
       hitbug = true;
       std::cerr << "Hit xcodebuild bug : " << line << "\n";
-      }
+    }
     // if the bug is hit, no more output should be generated
     // because it may contain bogus errors
     // also remove all output with setenv in it to tone down
     // the verbosity of xcodebuild
-    if(!hitbug && (line.find("setenv") == line.npos))
-      {
-      if(pipe == cmsysProcess_Pipe_STDERR)
-        {
+    if (!hitbug && (line.find("setenv") == line.npos)) {
+      if (pipe == cmsysProcess_Pipe_STDERR) {
         std::cerr << line << "\n";
-        }
-      else if(pipe == cmsysProcess_Pipe_STDOUT)
-        {
+      } else if (pipe == cmsysProcess_Pipe_STDOUT) {
         std::cout << line << "\n";
-        }
       }
-    pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
     }
+    pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
+  }
   cmsysProcess_WaitForExit(cp, 0);
-  if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited)
-    {
+  if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
     return cmsysProcess_GetExitValue(cp);
-    }
-  if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
-    {
+  }
+  if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
     return -1;
-    }
+  }
   return -1;
 }
 
-int main(int ac, char*av[])
+int main(int ac, char* av[])
 {
   std::vector<const char*> argv;
   argv.push_back("xcodebuild");
-  for(int i =1; i < ac; i++)
-    {
+  for (int i = 1; i < ac; i++) {
     argv.push_back(av[i]);
-    }
+  }
   argv.push_back(0);
   bool hitbug = true;
   int ret = 0;
-  while(hitbug)
-    {
+  while (hitbug) {
     ret = RunXCode(argv, hitbug);
-    }
-  if(ret < 0)
-    {
+  }
+  if (ret < 0) {
     return 255;
-    }
+  }
   return ret;
 }
-
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index f3c6059..8b0cede 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -12,24 +12,26 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-
 // Wrapper around cl that adds /showIncludes to command line, and uses that to
 // generate .d files that match the style from gcc -MD.
 //
 // /showIncludes is equivalent to -MD, not -MMD, that is, system headers are
 // included.
 
-
-#include <windows.h>
-#include <sstream>
 #include <cmSystemTools.h>
 #include <cmsys/Encoding.hxx>
 
+#include <sstream>
+#include <windows.h>
+
 // We don't want any wildcard expansion.
 // See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx
-void _setargv() {}
+void _setargv()
+{
+}
 
-static void Fatal(const char* msg, ...) {
+static void Fatal(const char* msg, ...)
+{
   va_list ap;
   fprintf(stderr, "ninja: FATAL: ");
   va_start(ap, msg);
@@ -43,20 +45,23 @@ static void Fatal(const char* msg, ...) {
   ExitProcess(1);
 }
 
-static void usage(const char* msg) {
+static void usage(const char* msg)
+{
   Fatal("%s\n\nusage:\n    "
-          "cmcldeps "
-          "<language C, CXX or RC>  "
-          "<source file path>  "
-          "<output path for *.d file>  "
-          "<output path for *.obj file>  "
-          "<prefix of /showIncludes>  "
-          "<path to cl.exe>  "
-          "<path to tool (cl or rc)>  "
-          "<rest of command ...>\n", msg);
+        "cmcldeps "
+        "<language C, CXX or RC>  "
+        "<source file path>  "
+        "<output path for *.d file>  "
+        "<output path for *.obj file>  "
+        "<prefix of /showIncludes>  "
+        "<path to cl.exe>  "
+        "<path to tool (cl or rc)>  "
+        "<rest of command ...>\n",
+        msg);
 }
 
-static std::string trimLeadingSpace(const std::string& cmdline) {
+static std::string trimLeadingSpace(const std::string& cmdline)
+{
   int i = 0;
   for (; cmdline[i] == ' '; ++i)
     ;
@@ -64,7 +69,8 @@ static std::string trimLeadingSpace(const std::string& cmdline) {
 }
 
 static void replaceAll(std::string& str, const std::string& search,
-                                         const std::string& repl) {
+                       const std::string& repl)
+{
   std::string::size_type pos = 0;
   while ((pos = str.find(search, pos)) != std::string::npos) {
     str.replace(pos, search.size(), repl);
@@ -72,13 +78,15 @@ static void replaceAll(std::string& str, const std::string& search,
   }
 }
 
-bool startsWith(const std::string& str, const std::string& what) {
+bool startsWith(const std::string& str, const std::string& what)
+{
   return str.compare(0, what.size(), what) == 0;
 }
 
 // Strips one argument from the cmdline and returns it. "surrounding quotes"
 // are removed from the argument if there were any.
-static std::string getArg(std::string& cmdline) {
+static std::string getArg(std::string& cmdline)
+{
   std::string ret;
   bool in_quoted = false;
   unsigned int i = 0;
@@ -101,15 +109,12 @@ static std::string getArg(std::string& cmdline) {
   return ret;
 }
 
-static void parseCommandLine(LPWSTR wincmdline,
-                             std::string& lang,
-                             std::string& srcfile,
-                             std::string& dfile,
-                             std::string& objfile,
-                             std::string& prefix,
-                             std::string& clpath,
-                             std::string& binpath,
-                             std::string& rest) {
+static void parseCommandLine(LPWSTR wincmdline, std::string& lang,
+                             std::string& srcfile, std::string& dfile,
+                             std::string& objfile, std::string& prefix,
+                             std::string& clpath, std::string& binpath,
+                             std::string& rest)
+{
   std::string cmdline = cmsys::Encoding::ToNarrow(wincmdline);
   /* self */ getArg(cmdline);
   lang = getArg(cmdline);
@@ -124,13 +129,15 @@ static void parseCommandLine(LPWSTR wincmdline,
 
 // Not all backslashes need to be escaped in a depfile, but it's easier that
 // way.  See the re2c grammar in ninja's source code for more info.
-static void escapePath(std::string &path) {
+static void escapePath(std::string& path)
+{
   replaceAll(path, "\\", "\\\\");
   replaceAll(path, " ", "\\ ");
 }
 
 static void outputDepFile(const std::string& dfile, const std::string& objfile,
-        std::vector<std::string>& incs) {
+                          std::vector<std::string>& incs)
+{
 
   if (dfile.empty())
     return;
@@ -169,13 +176,14 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile,
   fclose(out);
 }
 
-
-bool contains(const std::string& str, const std::string& what) {
+bool contains(const std::string& str, const std::string& what)
+{
   return str.find(what) != std::string::npos;
 }
 
 std::string replace(const std::string& str, const std::string& what,
-                    const std::string& replacement) {
+                    const std::string& replacement)
+{
   size_t pos = str.find(what);
   if (pos == std::string::npos)
     return str;
@@ -183,15 +191,10 @@ std::string replace(const std::string& str, const std::string& what,
   return replaced.replace(pos, what.size(), replacement);
 }
 
-
-
-static int process( const std::string& srcfilename,
-                    const std::string& dfile,
-                    const std::string& objfile,
-                    const std::string& prefix,
-                    const std::string& cmd,
-                    const std::string& dir = "",
-                    bool quiet = false)
+static int process(const std::string& srcfilename, const std::string& dfile,
+                   const std::string& objfile, const std::string& prefix,
+                   const std::string& cmd, const std::string& dir = "",
+                   bool quiet = false)
 {
   std::string output;
   // break up command line into a vector
@@ -199,16 +202,15 @@ static int process( const std::string& srcfilename,
   cmSystemTools::ParseWindowsCommandLine(cmd.c_str(), args);
   // convert to correct vector type for RunSingleCommand
   std::vector<std::string> command;
-  for(std::vector<std::string>::iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
+       ++i) {
     command.push_back(i->c_str());
-    }
+  }
   // run the command
   int exit_code = 0;
-  bool run = cmSystemTools::RunSingleCommand(command, &output, &output,
-                                             &exit_code, dir.c_str(),
-                                             cmSystemTools::OUTPUT_NONE);
+  bool run =
+    cmSystemTools::RunSingleCommand(command, &output, &output, &exit_code,
+                                    dir.c_str(), cmSystemTools::OUTPUT_NONE);
 
   // process the include directives and output everything else
   std::stringstream ss(output);
@@ -239,8 +241,8 @@ static int process( const std::string& srcfilename,
   return exit_code;
 }
 
-
-int main() {
+int main()
+{
 
   // Use the Win32 API instead of argc/argv so we can avoid interpreting the
   // rest of command line after the .d and .obj. Custom parsing seemed
@@ -249,18 +251,18 @@ int main() {
   // the same command line verbatim.
 
   std::string lang, srcfile, dfile, objfile, prefix, cl, binpath, rest;
-  parseCommandLine(GetCommandLineW(), lang, srcfile, dfile, objfile,
-                                     prefix, cl, binpath, rest);
+  parseCommandLine(GetCommandLineW(), lang, srcfile, dfile, objfile, prefix,
+                   cl, binpath, rest);
 
   // needed to suppress filename output of msvc tools
   std::string srcfilename;
   {
-  std::string::size_type pos = srcfile.rfind("\\");
-  if (pos == std::string::npos) {
-    srcfilename = srcfile;
-  } else {
-    srcfilename = srcfile.substr(pos + 1);
-  }
+    std::string::size_type pos = srcfile.rfind("\\");
+    if (pos == std::string::npos) {
+      srcfilename = srcfile;
+    } else {
+      srcfilename = srcfile.substr(pos + 1);
+    }
   }
 
   std::string nol = " /nologo ";
@@ -286,21 +288,21 @@ int main() {
     // call cl in object dir so the .i is generated there
     std::string objdir;
     {
-    std::string::size_type pos = objfile.rfind("\\");
-    if (pos != std::string::npos) {
-      objdir = objfile.substr(0, pos);
-    }
+      std::string::size_type pos = objfile.rfind("\\");
+      if (pos != std::string::npos) {
+        objdir = objfile.substr(0, pos);
+      }
     }
 
     // extract dependencies with cl.exe
-    int exit_code = process(srcfilename, dfile, objfile,
-                            prefix, cl + nol + show + clrest, objdir, true);
+    int exit_code = process(srcfilename, dfile, objfile, prefix,
+                            cl + nol + show + clrest, objdir, true);
 
     if (exit_code != 0)
       return exit_code;
 
     // compile rc file with rc.exe
-    return process(srcfilename, "" , objfile, prefix, binpath + " " + rest);
+    return process(srcfilename, "", objfile, prefix, binpath + " " + rest);
   }
 
   usage("Invalid language specified.");
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index e9d77b2..471028a 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -10,20 +10,21 @@
   See the License for more information.
 ============================================================================*/
 #include "cmcmd.h"
-#include "cmMakefile.h"
-#include "cmLocalGenerator.h"
+
+#include "cmAlgorithms.h"
 #include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
 #include "cmQtAutoGenerators.h"
 #include "cmVersion.h"
-#include "cmAlgorithms.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
+#include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
 #endif
 
 #include <cmsys/Directory.hxx>
-#include <cmsys/Process.h>
 #include <cmsys/FStream.hxx>
+#include <cmsys/Process.h>
 #include <cmsys/Terminal.h>
 
 #if defined(CMAKE_HAVE_VS_GENERATORS)
@@ -43,14 +44,19 @@ void CMakeCommandUsage(const char* program)
   std::ostringstream errorStream;
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
+  /* clang-format off */
   errorStream
     << "cmake version " << cmVersion::GetCMakeVersion() << "\n";
+/* clang-format on */
 #else
+  /* clang-format off */
   errorStream
     << "cmake bootstrap\n";
+/* clang-format on */
 #endif
   // If you add new commands, change here,
   // and in cmakemain.cxx in the options table
+  /* clang-format off */
   errorStream
     << "Usage: " << program << " -E <command> [arguments...]\n"
     << "Available commands: \n"
@@ -69,7 +75,7 @@ void CMakeCommandUsage(const char* program)
     << "                            - run command in a modified environment\n"
     << "  environment               - display the current environment\n"
     << "  make_directory <dir>...   - create parent and <dir> directories\n"
-    << "  md5sum <file>...          - compute md5sum of files\n"
+    << "  md5sum <file>...          - create MD5 checksum of files\n"
     << "  remove [-f] <file>...     - remove the file(s), use -f to force "
        "it\n"
     << "  remove_directory dir      - remove a directory and its contents\n"
@@ -94,6 +100,7 @@ void CMakeCommandUsage(const char* program)
     << "  create_symlink old new    - create a symbolic link new -> old\n"
 #endif
     ;
+  /* clang-format on */
 
   cmSystemTools::Error(errorStream.str().c_str());
 }
@@ -101,467 +108,408 @@ void CMakeCommandUsage(const char* program)
 static bool cmTarFilesFrom(std::string const& file,
                            std::vector<std::string>& files)
 {
-  if (cmSystemTools::FileIsDirectory(file))
-    {
+  if (cmSystemTools::FileIsDirectory(file)) {
     std::ostringstream e;
     e << "-E tar --files-from= file '" << file << "' is a directory";
     cmSystemTools::Error(e.str().c_str());
     return false;
-    }
+  }
   cmsys::ifstream fin(file.c_str());
-  if (!fin)
-    {
+  if (!fin) {
     std::ostringstream e;
     e << "-E tar --files-from= file '" << file << "' not found";
     cmSystemTools::Error(e.str().c_str());
     return false;
-    }
+  }
   std::string line;
-  while (cmSystemTools::GetLineFromStream(fin, line))
-    {
-    if (line.empty())
-      {
+  while (cmSystemTools::GetLineFromStream(fin, line)) {
+    if (line.empty()) {
       continue;
-      }
-    if (cmHasLiteralPrefix(line, "--add-file="))
-      {
+    }
+    if (cmHasLiteralPrefix(line, "--add-file=")) {
       files.push_back(line.substr(11));
-      }
-    else if (cmHasLiteralPrefix(line, "-"))
-      {
+    } else if (cmHasLiteralPrefix(line, "-")) {
       std::ostringstream e;
       e << "-E tar --files-from='" << file << "' file invalid line:\n"
         << line << "\n";
       cmSystemTools::Error(e.str().c_str());
       return false;
-      }
-    else
-      {
+    } else {
       files.push_back(line);
-      }
     }
+  }
   return true;
 }
 
 int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
 {
   // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
-  if (args.size() > 1)
-    {
+  if (args.size() > 1) {
     // Copy file
-    if (args[1] == "copy" && args.size() > 3)
-      {
+    if (args[1] == "copy" && args.size() > 3) {
       // If multiple source files specified,
       // then destination must be directory
       if ((args.size() > 4) &&
-          (!cmSystemTools::FileIsDirectory(args[args.size() - 1])))
-        {
+          (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) {
         std::cerr << "Error: Target (for copy command) \""
-                  << args[args.size() - 1]
-                  << "\" is not a directory.\n";
+                  << args[args.size() - 1] << "\" is not a directory.\n";
         return 1;
-        }
+      }
       // If error occurs we want to continue copying next files.
       bool return_value = 0;
-      for (std::string::size_type cc = 2; cc < args.size() - 1; cc ++)
-        {
-        if(!cmSystemTools::cmCopyFile(args[cc].c_str(),
-            args[args.size() - 1].c_str()))
-          {
-          std::cerr << "Error copying file \"" << args[cc]
-                    << "\" to \"" << args[args.size() - 1] << "\".\n";
+      for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
+        if (!cmSystemTools::cmCopyFile(args[cc].c_str(),
+                                       args[args.size() - 1].c_str())) {
+          std::cerr << "Error copying file \"" << args[cc] << "\" to \""
+                    << args[args.size() - 1] << "\".\n";
           return_value = 1;
-          }
         }
-      return return_value;
       }
+      return return_value;
+    }
 
     // Copy file if different.
-    if (args[1] == "copy_if_different" && args.size() > 3)
-      {
+    if (args[1] == "copy_if_different" && args.size() > 3) {
       // If multiple source files specified,
       // then destination must be directory
       if ((args.size() > 4) &&
-          (!cmSystemTools::FileIsDirectory(args[args.size() - 1])))
-        {
+          (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) {
         std::cerr << "Error: Target (for copy_if_different command) \""
-                  << args[args.size() - 1]
-                  << "\" is not a directory.\n";
+                  << args[args.size() - 1] << "\" is not a directory.\n";
         return 1;
-        }
+      }
       // If error occurs we want to continue copying next files.
       bool return_value = 0;
-      for (std::string::size_type cc = 2; cc < args.size() - 1; cc ++)
-        {
-        if(!cmSystemTools::CopyFileIfDifferent(args[cc].c_str(),
-            args[args.size() - 1].c_str()))
-          {
-          std::cerr << "Error copying file (if different) from \""
-                    << args[cc] << "\" to \"" << args[args.size() - 1]
-                    << "\".\n";
+      for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
+        if (!cmSystemTools::CopyFileIfDifferent(
+              args[cc].c_str(), args[args.size() - 1].c_str())) {
+          std::cerr << "Error copying file (if different) from \"" << args[cc]
+                    << "\" to \"" << args[args.size() - 1] << "\".\n";
           return_value = 1;
-          }
         }
-      return return_value;
       }
+      return return_value;
+    }
 
     // Copy directory content
-    if (args[1] == "copy_directory" && args.size() > 3)
-      {
+    if (args[1] == "copy_directory" && args.size() > 3) {
       // If error occurs we want to continue copying next files.
       bool return_value = 0;
-      for (std::string::size_type cc = 2; cc < args.size() - 1; cc ++)
-        {
-        if(!cmSystemTools::CopyADirectory(args[cc].c_str(),
-            args[args.size() - 1].c_str()))
-          {
-          std::cerr << "Error copying directory from \""
-                    << args[cc] << "\" to \"" << args[args.size() - 1]
-                    << "\".\n";
+      for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
+        if (!cmSystemTools::CopyADirectory(args[cc], args[args.size() - 1])) {
+          std::cerr << "Error copying directory from \"" << args[cc]
+                    << "\" to \"" << args[args.size() - 1] << "\".\n";
           return_value = 1;
-          }
         }
-      return return_value;
       }
+      return return_value;
+    }
 
     // Rename a file or directory
-    if (args[1] == "rename" && args.size() == 4)
-      {
-      if(!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str()))
-        {
+    if (args[1] == "rename" && args.size() == 4) {
+      if (!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) {
         std::string e = cmSystemTools::GetLastSystemError();
-        std::cerr << "Error renaming from \""
-                  << args[2] << "\" to \"" << args[3]
-                  << "\": " << e << "\n";
+        std::cerr << "Error renaming from \"" << args[2] << "\" to \""
+                  << args[3] << "\": " << e << "\n";
         return 1;
-        }
-      return 0;
       }
+      return 0;
+    }
 
     // Compare files
-    if (args[1] == "compare_files" && args.size() == 4)
-      {
-      if(cmSystemTools::FilesDiffer(args[2], args[3]))
-        {
-        std::cerr << "Files \""
-                  << args[2] << "\" to \"" << args[3]
+    if (args[1] == "compare_files" && args.size() == 4) {
+      if (cmSystemTools::FilesDiffer(args[2], args[3])) {
+        std::cerr << "Files \"" << args[2] << "\" to \"" << args[3]
                   << "\" are different.\n";
         return 1;
-        }
-      return 0;
       }
+      return 0;
+    }
 
 #if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
-    else if(args[1] == "__create_def")
-      {
-      if(args.size() < 4)
-        {
-        std::cerr <<
-          "__create_def Usage: -E __create_def outfile.def objlistfile\n";
+    else if (args[1] == "__create_def") {
+      if (args.size() < 4) {
+        std::cerr
+          << "__create_def Usage: -E __create_def outfile.def objlistfile\n";
         return 1;
-        }
+      }
       FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+");
-      if(!fout)
-        {
+      if (!fout) {
         std::cerr << "could not open output .def file: " << args[2].c_str()
                   << "\n";
         return 1;
-        }
-      cmsys::ifstream fin(args[3].c_str(),
-                          std::ios::in | std::ios::binary);
-      if(!fin)
-        {
+      }
+      cmsys::ifstream fin(args[3].c_str(), std::ios::in | std::ios::binary);
+      if (!fin) {
         std::cerr << "could not open object list file: " << args[3].c_str()
                   << "\n";
         return 1;
-        }
+      }
       std::string objfile;
       bindexplib deffile;
-      while(cmSystemTools::GetLineFromStream(fin, objfile))
-        {
-        if( !deffile.AddObjectFile(objfile.c_str()))
-          {
+      while (cmSystemTools::GetLineFromStream(fin, objfile)) {
+        if (!deffile.AddObjectFile(objfile.c_str())) {
           return 1;
-          }
         }
+      }
       deffile.WriteFile(fout);
       fclose(fout);
       return 0;
-      }
+    }
 #endif
     // run include what you use command and then run the compile
     // command. This is an internal undocumented option and should
     // only be used by CMake itself when running iwyu.
-    else if (args[1] == "__run_iwyu")
-      {
-      if (args.size() < 3)
-        {
+    else if (args[1] == "__run_iwyu") {
+      if (args.size() < 3) {
         std::cerr << "__run_iwyu Usage: -E __run_iwyu [--iwyu=/path/iwyu]"
-          " -- compile command\n";
+                     " [--tidy=/path/tidy] -- compile command\n";
         return 1;
-        }
+      }
       bool doing_options = true;
       std::vector<std::string> orig_cmd;
       std::string iwyu;
-      for (std::string::size_type cc = 2; cc < args.size(); cc ++)
-        {
+      std::string tidy;
+      std::string sourceFile;
+      for (std::string::size_type cc = 2; cc < args.size(); cc++) {
         std::string const& arg = args[cc];
-        if (arg == "--")
-          {
+        if (arg == "--") {
           doing_options = false;
-          }
-        else if (doing_options && cmHasLiteralPrefix(arg, "--iwyu="))
-          {
+        } else if (doing_options && cmHasLiteralPrefix(arg, "--iwyu=")) {
           iwyu = arg.substr(7);
-          }
-        else if (doing_options)
-          {
+        } else if (doing_options && cmHasLiteralPrefix(arg, "--tidy=")) {
+          tidy = arg.substr(7);
+        } else if (doing_options && cmHasLiteralPrefix(arg, "--source=")) {
+          sourceFile = arg.substr(9);
+        } else if (doing_options) {
           std::cerr << "__run_iwyu given unknown argument: " << arg << "\n";
           return 1;
-          }
-        else
-          {
+        } else {
           orig_cmd.push_back(arg);
-          }
         }
-      if (iwyu.empty())
-        {
-        std::cerr << "__run_iwyu missing --iwyu=\n";
+      }
+      if (tidy.empty() && iwyu.empty()) {
+        std::cerr << "__run_iwyu missing --tidy= or --iwyu=\n";
         return 1;
-        }
-      if (orig_cmd.empty())
-        {
+      }
+      if (!tidy.empty() && sourceFile.empty()) {
+        std::cerr << "__run_iwyu --tidy= requires --source=\n";
+        return 1;
+      }
+      if (orig_cmd.empty()) {
         std::cerr << "__run_iwyu missing compile command after --\n";
         return 1;
-        }
-
-      // Construct the iwyu command line by taking what was given
-      // and adding all the arguments we give to the compiler.
-      std::vector<std::string> iwyu_cmd;
-      cmSystemTools::ExpandListArgument(iwyu, iwyu_cmd, true);
-      iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin()+1, orig_cmd.end());
+      }
 
-      // Run the iwyu command line.  Capture its stderr and hide its stdout.
       int ret = 0;
-      std::string stdErr;
-      if(!cmSystemTools::RunSingleCommand(iwyu_cmd, 0, &stdErr, &ret,
-                                          0, cmSystemTools::OUTPUT_NONE))
-        {
-        std::cerr << "Error running '" << iwyu_cmd[0] << "': "
-                  << stdErr << "\n";
-        return 1;
+
+      if (!iwyu.empty()) {
+        // Construct the iwyu command line by taking what was given
+        // and adding all the arguments we give to the compiler.
+        std::vector<std::string> iwyu_cmd;
+        cmSystemTools::ExpandListArgument(iwyu, iwyu_cmd, true);
+        iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin() + 1, orig_cmd.end());
+
+        // Run the iwyu command line.  Capture its stderr and hide its stdout.
+        std::string stdErr;
+        if (!cmSystemTools::RunSingleCommand(iwyu_cmd, 0, &stdErr, &ret, 0,
+                                             cmSystemTools::OUTPUT_NONE)) {
+          std::cerr << "Error running '" << iwyu_cmd[0] << "': " << stdErr
+                    << "\n";
+          return 1;
         }
 
-      // Warn if iwyu reported anything.
-      if(stdErr.find("should remove these lines:") != stdErr.npos
-         || stdErr.find("should add these lines:") != stdErr.npos)
-        {
-        std::cerr << "Warning: include-what-you-use reported diagnostics:\n"
-                  << stdErr << "\n";
+        // Warn if iwyu reported anything.
+        if (stdErr.find("should remove these lines:") != stdErr.npos ||
+            stdErr.find("should add these lines:") != stdErr.npos) {
+          std::cerr << "Warning: include-what-you-use reported diagnostics:\n"
+                    << stdErr << "\n";
         }
+      }
+
+      if (!tidy.empty()) {
+        // Construct the clang-tidy command line by taking what was given
+        // and adding our compiler command line.  The clang-tidy tool will
+        // automatically skip over the compiler itself and extract the
+        // options.
+        std::vector<std::string> tidy_cmd;
+        cmSystemTools::ExpandListArgument(tidy, tidy_cmd, true);
+        tidy_cmd.push_back(sourceFile);
+        tidy_cmd.push_back("--");
+        tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end());
+
+        // Run the tidy command line.  Capture its stdout and hide its stderr.
+        std::string stdOut;
+        if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, 0, &ret, 0,
+                                             cmSystemTools::OUTPUT_NONE)) {
+          std::cerr << "Error running '" << tidy_cmd[0] << "'\n";
+          return 1;
+        }
+
+        // Output the stdout from clang-tidy to stderr
+        std::cerr << stdOut;
+      }
 
       // Now run the real compiler command and return its result value.
-      if(!cmSystemTools::RunSingleCommand(orig_cmd, 0, 0, &ret, 0,
-                                          cmSystemTools::OUTPUT_PASSTHROUGH))
-        {
+      if (!cmSystemTools::RunSingleCommand(
+            orig_cmd, 0, 0, &ret, 0, cmSystemTools::OUTPUT_PASSTHROUGH)) {
         std::cerr << "Error running '" << orig_cmd[0] << "'\n";
         return 1;
-        }
-      return ret;
       }
+      return ret;
+    }
 
     // Echo string
-    else if (args[1] == "echo" )
-      {
+    else if (args[1] == "echo") {
       std::cout << cmJoin(cmMakeRange(args).advance(2), " ") << std::endl;
       return 0;
-      }
+    }
 
     // Echo string no new line
-    else if (args[1] == "echo_append" )
-      {
+    else if (args[1] == "echo_append") {
       std::cout << cmJoin(cmMakeRange(args).advance(2), " ");
       return 0;
-      }
+    }
 
-    else if (args[1] == "env" )
-      {
+    else if (args[1] == "env") {
       std::vector<std::string>::const_iterator ai = args.begin() + 2;
       std::vector<std::string>::const_iterator ae = args.end();
-      for(; ai != ae; ++ai)
-        {
+      for (; ai != ae; ++ai) {
         std::string const& a = *ai;
-        if(cmHasLiteralPrefix(a, "--unset="))
-          {
+        if (cmHasLiteralPrefix(a, "--unset=")) {
           // Unset environment variable.
           cmSystemTools::UnPutEnv(a.c_str() + 8);
-          }
-        else if(!a.empty() && a[0] == '-')
-          {
+        } else if (!a.empty() && a[0] == '-') {
           // Environment variable and command names cannot start in '-',
           // so this must be an unknown option.
           std::cerr << "cmake -E env: unknown option '" << a << "'"
                     << std::endl;
           return 1;
-          }
-        else if(a.find("=") != a.npos)
-          {
+        } else if (a.find('=') != a.npos) {
           // Set environment variable.
           cmSystemTools::PutEnv(a);
-          }
-        else
-          {
+        } else {
           // This is the beginning of the command.
           break;
-          }
         }
+      }
 
-      if(ai == ae)
-        {
+      if (ai == ae) {
         std::cerr << "cmake -E env: no command given" << std::endl;
         return 1;
-        }
+      }
 
       // Execute command from remaining arguments.
       std::vector<std::string> cmd(ai, ae);
       int retval;
-      if(cmSystemTools::RunSingleCommand(
-           cmd, 0, 0, &retval, NULL, cmSystemTools::OUTPUT_PASSTHROUGH))
-        {
+      if (cmSystemTools::RunSingleCommand(cmd, 0, 0, &retval, NULL,
+                                          cmSystemTools::OUTPUT_PASSTHROUGH)) {
         return retval;
-        }
-      return 1;
       }
+      return 1;
+    }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-    else if (args[1] == "environment" )
-      {
+    else if (args[1] == "environment") {
       std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables();
       std::vector<std::string>::iterator it;
-      for ( it = env.begin(); it != env.end(); ++ it )
-        {
+      for (it = env.begin(); it != env.end(); ++it) {
         std::cout << *it << std::endl;
-        }
-      return 0;
       }
+      return 0;
+    }
 #endif
 
-    else if (args[1] == "make_directory" && args.size() > 2)
-      {
+    else if (args[1] == "make_directory" && args.size() > 2) {
       // If error occurs we want to continue copying next files.
       bool return_value = 0;
-      for (std::string::size_type cc = 2; cc < args.size(); cc ++)
-        {
-        if(!cmSystemTools::MakeDirectory(args[cc].c_str()))
-          {
-          std::cerr << "Error creating directory \""
-                    << args[cc] << "\".\n";
+      for (std::string::size_type cc = 2; cc < args.size(); cc++) {
+        if (!cmSystemTools::MakeDirectory(args[cc].c_str())) {
+          std::cerr << "Error creating directory \"" << args[cc] << "\".\n";
           return_value = 1;
-          }
         }
-      return return_value;
       }
+      return return_value;
+    }
 
-    else if (args[1] == "remove_directory" && args.size() == 3)
-      {
-      if(cmSystemTools::FileIsDirectory(args[2]) &&
-         !cmSystemTools::RemoveADirectory(args[2]))
-        {
-        std::cerr << "Error removing directory \"" << args[2]
-                  << "\".\n";
+    else if (args[1] == "remove_directory" && args.size() == 3) {
+      if (cmSystemTools::FileIsDirectory(args[2]) &&
+          !cmSystemTools::RemoveADirectory(args[2])) {
+        std::cerr << "Error removing directory \"" << args[2] << "\".\n";
         return 1;
-        }
-      return 0;
       }
+      return 0;
+    }
 
     // Remove file
-    else if (args[1] == "remove" && args.size() > 2)
-      {
+    else if (args[1] == "remove" && args.size() > 2) {
       bool force = false;
-      for (std::string::size_type cc = 2; cc < args.size(); cc ++)
-        {
-        if(args[cc] == "\\-f" || args[cc] == "-f")
-          {
+      for (std::string::size_type cc = 2; cc < args.size(); cc++) {
+        if (args[cc] == "\\-f" || args[cc] == "-f") {
           force = true;
-          }
-        else
-          {
+        } else {
           // Complain if the file could not be removed, still exists,
           // and the -f option was not given.
-          if(!cmSystemTools::RemoveFile(args[cc]) && !force &&
-             cmSystemTools::FileExists(args[cc].c_str()))
-            {
+          if (!cmSystemTools::RemoveFile(args[cc]) && !force &&
+              cmSystemTools::FileExists(args[cc].c_str())) {
             return 1;
-            }
           }
         }
-      return 0;
       }
+      return 0;
+    }
     // Touch file
-    else if (args[1] == "touch" && args.size() > 2)
-      {
-      for (std::string::size_type cc = 2; cc < args.size(); cc ++)
-        {
-        if(!cmSystemTools::Touch(args[cc], true))
-          {
+    else if (args[1] == "touch" && args.size() > 2) {
+      for (std::string::size_type cc = 2; cc < args.size(); cc++) {
+        if (!cmSystemTools::Touch(args[cc], true)) {
           return 1;
-          }
         }
-      return 0;
       }
+      return 0;
+    }
     // Touch file
-    else if (args[1] == "touch_nocreate" && args.size() > 2)
-      {
-      for (std::string::size_type cc = 2; cc < args.size(); cc ++)
-        {
+    else if (args[1] == "touch_nocreate" && args.size() > 2) {
+      for (std::string::size_type cc = 2; cc < args.size(); cc++) {
         // Complain if the file could not be removed, still exists,
         // and the -f option was not given.
-        if(!cmSystemTools::Touch(args[cc], false))
-          {
+        if (!cmSystemTools::Touch(args[cc], false)) {
           return 1;
-          }
         }
-      return 0;
       }
+      return 0;
+    }
 
     // Sleep command
-    else if (args[1] == "sleep" && args.size() > 2)
-      {
+    else if (args[1] == "sleep" && args.size() > 2) {
       double total = 0;
-      for(size_t i = 2; i < args.size(); ++i)
-        {
+      for (size_t i = 2; i < args.size(); ++i) {
         double num = 0.0;
         char unit;
         char extra;
         int n = sscanf(args[i].c_str(), "%lg%c%c", &num, &unit, &extra);
-        if((n == 1 || (n == 2 && unit == 's')) && num >= 0)
-          {
+        if ((n == 1 || (n == 2 && unit == 's')) && num >= 0) {
           total += num;
-          }
-        else
-          {
+        } else {
           std::cerr << "Unknown sleep time format \"" << args[i] << "\".\n";
           return 1;
-          }
-        }
-      if(total > 0)
-        {
-        cmSystemTools::Delay(static_cast<unsigned int>(total*1000));
         }
-      return 0;
       }
+      if (total > 0) {
+        cmSystemTools::Delay(static_cast<unsigned int>(total * 1000));
+      }
+      return 0;
+    }
 
     // Clock command
-    else if (args[1] == "time" && args.size() > 2)
-      {
-      std::vector<std::string> command(args.begin()+2, args.end());
+    else if (args[1] == "time" && args.size() > 2) {
+      std::vector<std::string> command(args.begin() + 2, args.end());
 
       clock_t clock_start, clock_finish;
       time_t time_start, time_finish;
 
       time(&time_start);
       clock_start = clock();
-      int ret =0;
+      int ret = 0;
       cmSystemTools::RunSingleCommand(command, 0, 0, &ret);
 
       clock_finish = clock();
@@ -569,184 +517,159 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
 
       double clocks_per_sec = static_cast<double>(CLOCKS_PER_SEC);
       std::cout << "Elapsed time: "
-        << static_cast<long>(time_finish - time_start) << " s. (time)"
-        << ", "
-        << static_cast<double>(clock_finish - clock_start) / clocks_per_sec
-        << " s. (clock)"
-        << "\n";
+                << static_cast<long>(time_finish - time_start) << " s. (time)"
+                << ", "
+                << static_cast<double>(clock_finish - clock_start) /
+          clocks_per_sec
+                << " s. (clock)"
+                << "\n";
       return ret;
-      }
+    }
     // Command to calculate the md5sum of a file
-    else if (args[1] == "md5sum" && args.size() >= 3)
-      {
+    else if (args[1] == "md5sum" && args.size() >= 3) {
       char md5out[32];
       int retval = 0;
-      for (std::string::size_type cc = 2; cc < args.size(); cc ++)
-        {
-        const char *filename = args[cc].c_str();
+      for (std::string::size_type cc = 2; cc < args.size(); cc++) {
+        const char* filename = args[cc].c_str();
         // Cannot compute md5sum of a directory
-        if(cmSystemTools::FileIsDirectory(filename))
-          {
+        if (cmSystemTools::FileIsDirectory(filename)) {
           std::cerr << "Error: " << filename << " is a directory" << std::endl;
           retval++;
-          }
-        else if(!cmSystemTools::ComputeFileMD5(filename, md5out))
-          {
+        } else if (!cmSystemTools::ComputeFileMD5(filename, md5out)) {
           // To mimic md5sum behavior in a shell:
           std::cerr << filename << ": No such file or directory" << std::endl;
           retval++;
-          }
-        else
-          {
-          std::cout << std::string(md5out,32) << "  " << filename << std::endl;
-          }
+        } else {
+          std::cout << std::string(md5out, 32) << "  " << filename
+                    << std::endl;
         }
-      return retval;
       }
+      return retval;
+    }
 
     // Command to change directory and run a program.
-    else if (args[1] == "chdir" && args.size() >= 4)
-      {
+    else if (args[1] == "chdir" && args.size() >= 4) {
       std::string directory = args[2];
-      if(!cmSystemTools::FileExists(directory.c_str()))
-        {
+      if (!cmSystemTools::FileExists(directory.c_str())) {
         cmSystemTools::Error("Directory does not exist for chdir command: ",
                              args[2].c_str());
         return 1;
-        }
+      }
 
       std::string command =
         cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
       int retval = 0;
       int timeout = 0;
-      if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval,
-             directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, timeout) )
-        {
+      if (cmSystemTools::RunSingleCommand(
+            command.c_str(), 0, 0, &retval, directory.c_str(),
+            cmSystemTools::OUTPUT_PASSTHROUGH, timeout)) {
         return retval;
-        }
+      }
 
       return 1;
-      }
+    }
 
     // Command to start progress for a build
-    else if (args[1] == "cmake_progress_start" && args.size() == 4)
-      {
+    else if (args[1] == "cmake_progress_start" && args.size() == 4) {
       // basically remove the directory
       std::string dirName = args[2];
       dirName += "/Progress";
       cmSystemTools::RemoveADirectory(dirName);
 
       // is the last argument a filename that exists?
-      FILE *countFile = cmsys::SystemTools::Fopen(args[3],"r");
+      FILE* countFile = cmsys::SystemTools::Fopen(args[3], "r");
       int count;
-      if (countFile)
-        {
-        if (1!=fscanf(countFile,"%i",&count))
-          {
+      if (countFile) {
+        if (1 != fscanf(countFile, "%i", &count)) {
           cmSystemTools::Message("Could not read from count file.");
-          }
-        fclose(countFile);
         }
-      else
-        {
+        fclose(countFile);
+      } else {
         count = atoi(args[3].c_str());
-        }
-      if (count)
-        {
+      }
+      if (count) {
         cmSystemTools::MakeDirectory(dirName.c_str());
         // write the count into the directory
         std::string fName = dirName;
         fName += "/count.txt";
-        FILE *progFile = cmsys::SystemTools::Fopen(fName,"w");
-        if (progFile)
-          {
-          fprintf(progFile,"%i\n",count);
+        FILE* progFile = cmsys::SystemTools::Fopen(fName, "w");
+        if (progFile) {
+          fprintf(progFile, "%i\n", count);
           fclose(progFile);
-          }
         }
-      return 0;
       }
+      return 0;
+    }
 
     // Command to report progress for a build
-    else if (args[1] == "cmake_progress_report" && args.size() >= 3)
-      {
+    else if (args[1] == "cmake_progress_report" && args.size() >= 3) {
       // This has been superseded by cmake_echo_color --progress-*
       // options.  We leave it here to avoid errors if somehow this
       // is invoked by an existing makefile without regenerating.
       return 0;
-      }
+    }
 
     // Command to create a symbolic link.  Fails on platforms not
     // supporting them.
-    else if (args[1] == "create_symlink" && args.size() == 4)
-      {
+    else if (args[1] == "create_symlink" && args.size() == 4) {
       const char* destinationFileName = args[3].c_str();
-      if((cmSystemTools::FileExists(destinationFileName) ||
-          cmSystemTools::FileIsSymlink(destinationFileName)) &&
-         !cmSystemTools::RemoveFile(destinationFileName))
-        {
+      if ((cmSystemTools::FileExists(destinationFileName) ||
+           cmSystemTools::FileIsSymlink(destinationFileName)) &&
+          !cmSystemTools::RemoveFile(destinationFileName)) {
         std::string emsg = cmSystemTools::GetLastSystemError();
-        std::cerr <<
-          "failed to create symbolic link '" << destinationFileName <<
-          "' because existing path cannot be removed: " << emsg << "\n";
+        std::cerr << "failed to create symbolic link '" << destinationFileName
+                  << "' because existing path cannot be removed: " << emsg
+                  << "\n";
         return 1;
-        }
-      if(!cmSystemTools::CreateSymlink(args[2], args[3]))
-        {
+      }
+      if (!cmSystemTools::CreateSymlink(args[2], args[3])) {
         std::string emsg = cmSystemTools::GetLastSystemError();
-        std::cerr <<
-          "failed to create symbolic link '" << destinationFileName <<
-          "': " << emsg << "\n";
+        std::cerr << "failed to create symbolic link '" << destinationFileName
+                  << "': " << emsg << "\n";
         return 1;
-        }
-      return 0;
       }
+      return 0;
+    }
 
     // Internal CMake shared library support.
-    else if (args[1] == "cmake_symlink_library" && args.size() == 5)
-      {
+    else if (args[1] == "cmake_symlink_library" && args.size() == 5) {
       return cmcmd::SymlinkLibrary(args);
-      }
+    }
     // Internal CMake versioned executable support.
-    else if (args[1] == "cmake_symlink_executable" && args.size() == 4)
-      {
+    else if (args[1] == "cmake_symlink_executable" && args.size() == 4) {
       return cmcmd::SymlinkExecutable(args);
-      }
+    }
 
 #if defined(CMAKE_HAVE_VS_GENERATORS)
     // Internal CMake support for calling Visual Studio macros.
-    else if (args[1] == "cmake_call_visual_studio_macro" && args.size() >= 4)
-      {
+    else if (args[1] == "cmake_call_visual_studio_macro" && args.size() >= 4) {
       // args[2] = full path to .sln file or "ALL"
       // args[3] = name of Visual Studio macro to call
       // args[4..args.size()-1] = [optional] args for Visual Studio macro
 
       std::string macroArgs;
 
-      if (args.size() > 4)
-        {
+      if (args.size() > 4) {
         macroArgs = args[4];
 
-        for (size_t i = 5; i < args.size(); ++i)
-          {
+        for (size_t i = 5; i < args.size(); ++i) {
           macroArgs += " ";
           macroArgs += args[i];
-          }
         }
-
-      return cmCallVisualStudioMacro::CallMacro(args[2], args[3],
-        macroArgs, true);
       }
+
+      return cmCallVisualStudioMacro::CallMacro(args[2], args[3], macroArgs,
+                                                true);
+    }
 #endif
 
     // Internal CMake dependency scanning support.
-    else if (args[1] == "cmake_depends" && args.size() >= 6)
-      {
+    else if (args[1] == "cmake_depends" && args.size() >= 6) {
       // Use the make system's VERBOSE environment variable to enable
       // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE
       // (which is set by the Eclipse and KDevelop generators).
-      bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0)
-                       && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0));
+      bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) &&
+                      (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0));
 
       // Create a cmake object instance to process dependencies.
       cmake cm;
@@ -757,8 +680,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       std::string startOutDir;
       std::string depInfo;
       bool color = false;
-      if(args.size() >= 8)
-        {
+      if (args.size() >= 8) {
         // Full signature:
         //
         //   -E cmake_depends <generator>
@@ -773,17 +695,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
         homeOutDir = args[5];
         startOutDir = args[6];
         depInfo = args[7];
-        if(args.size() >= 9 &&
-           args[8].length() >= 8 &&
-           args[8].substr(0, 8) == "--color=")
-          {
+        if (args.size() >= 9 && args[8].length() >= 8 &&
+            args[8].substr(0, 8) == "--color=") {
           // Enable or disable color based on the switch value.
           color = (args[8].size() == 8 ||
                    cmSystemTools::IsOn(args[8].substr(8).c_str()));
-          }
         }
-      else
-        {
+      } else {
         // Support older signature for existing makefiles:
         //
         //   -E cmake_depends <generator>
@@ -798,7 +716,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
         homeOutDir = args[3];
         startOutDir = args[3];
         depInfo = args[5];
-        }
+      }
 
       // Create a local generator configured for the directory in
       // which dependencies will be scanned.
@@ -809,74 +727,56 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       cm.SetHomeDirectory(homeDir);
       cm.SetHomeOutputDirectory(homeOutDir);
       cm.GetCurrentSnapshot().SetDefaultDefinitions();
-      if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
-        {
+      if (cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) {
         cm.SetGlobalGenerator(ggd);
         cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
         snapshot.GetDirectory().SetCurrentBinary(startOutDir);
         snapshot.GetDirectory().SetCurrentSource(startDir);
         cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
         cmsys::auto_ptr<cmLocalGenerator> lgd(
-              ggd->CreateLocalGenerator(mf.get()));
+          ggd->CreateLocalGenerator(mf.get()));
 
         // Actually scan dependencies.
-        return lgd->UpdateDependencies(depInfo.c_str(),
-                                       verbose, color)? 0 : 2;
-        }
-      return 1;
+        return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0
+                                                                        : 2;
       }
+      return 1;
+    }
 
     // Internal CMake link script support.
-    else if (args[1] == "cmake_link_script" && args.size() >= 3)
-      {
+    else if (args[1] == "cmake_link_script" && args.size() >= 3) {
       return cmcmd::ExecuteLinkScript(args);
-      }
+    }
 
     // Internal CMake unimplemented feature notification.
-    else if (args[1] == "cmake_unimplemented_variable")
-      {
+    else if (args[1] == "cmake_unimplemented_variable") {
       std::cerr << "Feature not implemented for this platform.";
-      if(args.size() == 3)
-        {
+      if (args.size() == 3) {
         std::cerr << "  Variable " << args[2] << " is not set.";
-        }
+      }
       std::cerr << std::endl;
       return 1;
-      }
-    else if (args[1] == "vs_link_exe")
-      {
+    } else if (args[1] == "vs_link_exe") {
       return cmcmd::VisualStudioLink(args, 1);
-      }
-    else if (args[1] == "vs_link_dll")
-      {
+    } else if (args[1] == "vs_link_dll") {
       return cmcmd::VisualStudioLink(args, 2);
-      }
+    }
     // Internal CMake color makefile support.
-    else if (args[1] == "cmake_echo_color")
-      {
+    else if (args[1] == "cmake_echo_color") {
       return cmcmd::ExecuteEchoColor(args);
-      }
+    }
 #ifdef CMAKE_BUILD_WITH_CMAKE
-    else if (args[1] == "cmake_autogen" && args.size() >= 4)
-      {
-        cmQtAutoGenerators autogen;
-        std::string const& config = args[3];
-        bool autogenSuccess = autogen.Run(args[2], config);
-        return autogenSuccess ? 0 : 1;
-      }
+    else if (args[1] == "cmake_autogen" && args.size() >= 4) {
+      cmQtAutoGenerators autogen;
+      std::string const& config = args[3];
+      bool autogenSuccess = autogen.Run(args[2], config);
+      return autogenSuccess ? 0 : 1;
+    }
 #endif
 
     // Tar files
-    else if (args[1] == "tar" && args.size() > 3)
-      {
-      const char* knownFormats[] =
-        {
-        "7zip",
-        "gnutar",
-        "pax",
-        "paxr",
-        "zip"
-        };
+    else if (args[1] == "tar" && args.size() > 3) {
+      const char* knownFormats[] = { "7zip", "gnutar", "pax", "paxr", "zip" };
 
       std::string flags = args[2];
       std::string outFile = args[3];
@@ -884,112 +784,82 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       std::string mtime;
       std::string format;
       bool doing_options = true;
-      for (std::string::size_type cc = 4; cc < args.size(); cc ++)
-        {
+      for (std::string::size_type cc = 4; cc < args.size(); cc++) {
         std::string const& arg = args[cc];
-        if (doing_options && cmHasLiteralPrefix(arg, "--"))
-          {
-          if (arg == "--")
-            {
+        if (doing_options && cmHasLiteralPrefix(arg, "--")) {
+          if (arg == "--") {
             doing_options = false;
-            }
-          else if (cmHasLiteralPrefix(arg, "--mtime="))
-            {
+          } else if (cmHasLiteralPrefix(arg, "--mtime=")) {
             mtime = arg.substr(8);
-            }
-          else if (cmHasLiteralPrefix(arg, "--files-from="))
-            {
+          } else if (cmHasLiteralPrefix(arg, "--files-from=")) {
             std::string const& files_from = arg.substr(13);
-            if (!cmTarFilesFrom(files_from, files))
-              {
+            if (!cmTarFilesFrom(files_from, files)) {
               return 1;
-              }
             }
-          else if (cmHasLiteralPrefix(arg, "--format="))
-            {
+          } else if (cmHasLiteralPrefix(arg, "--format=")) {
             format = arg.substr(9);
-            bool isKnown = std::find(cmArrayBegin(knownFormats),
-              cmArrayEnd(knownFormats), format) != cmArrayEnd(knownFormats);
+            bool isKnown =
+              std::find(cmArrayBegin(knownFormats), cmArrayEnd(knownFormats),
+                        format) != cmArrayEnd(knownFormats);
 
-            if(!isKnown)
-              {
+            if (!isKnown) {
               cmSystemTools::Error("Unknown -E tar --format= argument: ",
-                format.c_str());
+                                   format.c_str());
               return 1;
-              }
             }
-          else
-            {
+          } else {
             cmSystemTools::Error("Unknown option to -E tar: ", arg.c_str());
             return 1;
-            }
           }
-        else
-          {
+        } else {
           files.push_back(arg);
-          }
         }
+      }
       cmSystemTools::cmTarCompression compress =
         cmSystemTools::TarCompressNone;
       bool verbose = false;
       int nCompress = 0;
-      if ( flags.find_first_of('j') != flags.npos )
-        {
+      if (flags.find_first_of('j') != flags.npos) {
         compress = cmSystemTools::TarCompressBZip2;
         ++nCompress;
-        }
-      if ( flags.find_first_of('J') != flags.npos )
-        {
+      }
+      if (flags.find_first_of('J') != flags.npos) {
         compress = cmSystemTools::TarCompressXZ;
         ++nCompress;
-        }
-      if ( flags.find_first_of('z') != flags.npos )
-        {
+      }
+      if (flags.find_first_of('z') != flags.npos) {
         compress = cmSystemTools::TarCompressGZip;
         ++nCompress;
-        }
-      if ( (format == "7zip" || format == "zip") && nCompress > 0 )
-        {
+      }
+      if ((format == "7zip" || format == "zip") && nCompress > 0) {
         cmSystemTools::Error("Can not use compression flags with format: ",
-          format.c_str());
+                             format.c_str());
         return 1;
-        }
-      else if ( nCompress > 1 )
-        {
+      } else if (nCompress > 1) {
         cmSystemTools::Error("Can only compress a tar file one way; "
                              "at most one flag of z, j, or J may be used");
         return 1;
-        }
-      if ( flags.find_first_of('v') != flags.npos )
-        {
+      }
+      if (flags.find_first_of('v') != flags.npos) {
         verbose = true;
-        }
+      }
 
-      if ( flags.find_first_of('t') != flags.npos )
-        {
-        if ( !cmSystemTools::ListTar(outFile.c_str(), verbose) )
-          {
+      if (flags.find_first_of('t') != flags.npos) {
+        if (!cmSystemTools::ListTar(outFile.c_str(), verbose)) {
           cmSystemTools::Error("Problem listing tar: ", outFile.c_str());
           return 1;
-          }
         }
-      else if ( flags.find_first_of('c') != flags.npos )
-        {
-        if ( !cmSystemTools::CreateTar(
-               outFile.c_str(), files, compress, verbose, mtime, format) )
-          {
+      } else if (flags.find_first_of('c') != flags.npos) {
+        if (!cmSystemTools::CreateTar(outFile.c_str(), files, compress,
+                                      verbose, mtime, format)) {
           cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
           return 1;
-          }
         }
-      else if ( flags.find_first_of('x') != flags.npos )
-        {
-        if ( !cmSystemTools::ExtractTar(
-            outFile.c_str(), verbose) )
-          {
+      } else if (flags.find_first_of('x') != flags.npos) {
+        if (!cmSystemTools::ExtractTar(outFile.c_str(), verbose)) {
           cmSystemTools::Error("Problem extracting tar: ", outFile.c_str());
           return 1;
-          }
+        }
 #ifdef WIN32
         // OK, on windows 7 after we untar some files,
         // sometimes we can not rename the directory after
@@ -999,112 +869,94 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
         // is set in the env, its value will be used instead of 100.
         int delay = 100;
         const char* delayVar = cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY");
-        if(delayVar)
-          {
+        if (delayVar) {
           delay = atoi(delayVar);
-          }
-        if(delay)
-          {
+        }
+        if (delay) {
           cmSystemTools::Delay(delay);
-          }
-#endif
         }
-      return 0;
+#endif
       }
+      return 0;
+    }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
     // Internal CMake Fortran module support.
-    else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4)
-      {
-      return cmDependsFortran::CopyModule(args)? 0 : 1;
-      }
+    else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) {
+      return cmDependsFortran::CopyModule(args) ? 0 : 1;
+    }
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
     // Write registry value
-    else if (args[1] == "write_regv" && args.size() > 3)
-      {
+    else if (args[1] == "write_regv" && args.size() > 3) {
       return cmSystemTools::WriteRegistryValue(args[2].c_str(),
-                                               args[3].c_str()) ? 0 : 1;
-      }
+                                               args[3].c_str())
+        ? 0
+        : 1;
+    }
 
     // Delete registry value
-    else if (args[1] == "delete_regv" && args.size() > 2)
-      {
+    else if (args[1] == "delete_regv" && args.size() > 2) {
       return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1;
-      }
+    }
     // Remove file
-    else if (args[1] == "comspec" && args.size() > 2)
-      {
+    else if (args[1] == "comspec" && args.size() > 2) {
       std::cerr << "Win9x helper \"cmake -E comspec\" no longer supported\n";
       return 1;
-      }
-    else if (args[1] == "env_vs8_wince" && args.size() == 3)
-      {
+    } else if (args[1] == "env_vs8_wince" && args.size() == 3) {
       return cmcmd::WindowsCEEnvironment("8.0", args[2]);
-      }
-    else if (args[1] == "env_vs9_wince" && args.size() == 3)
-      {
+    } else if (args[1] == "env_vs9_wince" && args.size() == 3) {
       return cmcmd::WindowsCEEnvironment("9.0", args[2]);
-      }
-#endif
     }
+#endif
+  }
 
   ::CMakeCommandUsage(args[0].c_str());
   return 1;
 }
 
-//----------------------------------------------------------------------------
 int cmcmd::SymlinkLibrary(std::vector<std::string>& args)
 {
   int result = 0;
   std::string realName = args[2];
   std::string soName = args[3];
   std::string name = args[4];
-  if(soName != realName)
-    {
-    if(!cmcmd::SymlinkInternal(realName, soName))
-      {
+  if (soName != realName) {
+    if (!cmcmd::SymlinkInternal(realName, soName)) {
       cmSystemTools::ReportLastSystemError("cmake_symlink_library");
       result = 1;
-      }
     }
-  if(name != soName)
-    {
-    if(!cmcmd::SymlinkInternal(soName, name))
-      {
+  }
+  if (name != soName) {
+    if (!cmcmd::SymlinkInternal(soName, name)) {
       cmSystemTools::ReportLastSystemError("cmake_symlink_library");
       result = 1;
-      }
     }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 int cmcmd::SymlinkExecutable(std::vector<std::string>& args)
 {
   int result = 0;
   std::string realName = args[2];
   std::string name = args[3];
-  if(name != realName)
-    {
-    if(!cmcmd::SymlinkInternal(realName, name))
-      {
+  if (name != realName) {
+    if (!cmcmd::SymlinkInternal(realName, name)) {
       cmSystemTools::ReportLastSystemError("cmake_symlink_executable");
       result = 1;
-      }
     }
+  }
   return result;
 }
 
-//----------------------------------------------------------------------------
 bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
 {
-  if(cmSystemTools::FileExists(link.c_str()) ||
-     cmSystemTools::FileIsSymlink(link))
-    {
+  if (cmSystemTools::FileExists(link.c_str()) ||
+      cmSystemTools::FileIsSymlink(link)) {
     cmSystemTools::RemoveFile(link);
-    }
+  }
 #if defined(_WIN32) && !defined(__CYGWIN__)
   return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str());
 #else
@@ -1113,66 +965,53 @@ bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
 #endif
 }
 
-//----------------------------------------------------------------------------
-static void cmcmdProgressReport(std::string const& dir,
-                                std::string const& num)
+static void cmcmdProgressReport(std::string const& dir, std::string const& num)
 {
   std::string dirName = dir;
   dirName += "/Progress";
   std::string fName;
-  FILE *progFile;
+  FILE* progFile;
 
   // read the count
   fName = dirName;
   fName += "/count.txt";
-  progFile = cmsys::SystemTools::Fopen(fName,"r");
+  progFile = cmsys::SystemTools::Fopen(fName, "r");
   int count = 0;
-  if (!progFile)
-    {
+  if (!progFile) {
     return;
-    }
-  else
-    {
-    if (1!=fscanf(progFile,"%i",&count))
-      {
+  } else {
+    if (1 != fscanf(progFile, "%i", &count)) {
       cmSystemTools::Message("Could not read from progress file.");
-      }
-    fclose(progFile);
     }
+    fclose(progFile);
+  }
   const char* last = num.c_str();
-  for(const char* c = last;; ++c)
-    {
-    if (*c == ',' || *c == '\0')
-      {
-      if (c != last)
-        {
+  for (const char* c = last;; ++c) {
+    if (*c == ',' || *c == '\0') {
+      if (c != last) {
         fName = dirName;
         fName += "/";
-        fName.append(last, c-last);
-        progFile = cmsys::SystemTools::Fopen(fName,"w");
-        if (progFile)
-          {
-          fprintf(progFile,"empty");
+        fName.append(last, c - last);
+        progFile = cmsys::SystemTools::Fopen(fName, "w");
+        if (progFile) {
+          fprintf(progFile, "empty");
           fclose(progFile);
-          }
         }
-      if(*c == '\0')
-        {
+      }
+      if (*c == '\0') {
         break;
-        }
-      last = c + 1;
       }
+      last = c + 1;
     }
-  int fileNum = static_cast<int>
-    (cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
-  if (count > 0)
-    {
+  }
+  int fileNum =
+    static_cast<int>(cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
+  if (count > 0) {
     // print the progress
-    fprintf(stdout,"[%3i%%] ",((fileNum-3)*100)/count);
-    }
+    fprintf(stdout, "[%3i%%] ", ((fileNum - 3) * 100) / count);
+  }
 }
 
-//----------------------------------------------------------------------------
 int cmcmd::ExecuteEchoColor(std::vector<std::string>& args)
 {
   // The arguments are
@@ -1183,96 +1022,58 @@ int cmcmd::ExecuteEchoColor(std::vector<std::string>& args)
   int color = cmsysTerminal_Color_Normal;
   bool newline = true;
   std::string progressDir;
-  for(unsigned int i=2; i < args.size(); ++i)
-    {
-    if(args[i].find("--switch=") == 0)
-      {
+  for (unsigned int i = 2; i < args.size(); ++i) {
+    if (args[i].find("--switch=") == 0) {
       // Enable or disable color based on the switch value.
       std::string value = args[i].substr(9);
-      if(!value.empty())
-        {
-        if(cmSystemTools::IsOn(value.c_str()))
-          {
+      if (!value.empty()) {
+        if (cmSystemTools::IsOn(value.c_str())) {
           enabled = true;
-          }
-        else
-          {
+        } else {
           enabled = false;
-          }
         }
       }
-    else if(cmHasLiteralPrefix(args[i], "--progress-dir="))
-      {
+    } else if (cmHasLiteralPrefix(args[i], "--progress-dir=")) {
       progressDir = args[i].substr(15);
-      }
-    else if(cmHasLiteralPrefix(args[i], "--progress-num="))
-      {
-      if (!progressDir.empty())
-        {
+    } else if (cmHasLiteralPrefix(args[i], "--progress-num=")) {
+      if (!progressDir.empty()) {
         std::string const& progressNum = args[i].substr(15);
         cmcmdProgressReport(progressDir, progressNum);
-        }
       }
-    else if(args[i] == "--normal")
-      {
+    } else if (args[i] == "--normal") {
       color = cmsysTerminal_Color_Normal;
-      }
-    else if(args[i] == "--black")
-      {
+    } else if (args[i] == "--black") {
       color = cmsysTerminal_Color_ForegroundBlack;
-      }
-    else if(args[i] == "--red")
-      {
+    } else if (args[i] == "--red") {
       color = cmsysTerminal_Color_ForegroundRed;
-      }
-    else if(args[i] == "--green")
-      {
+    } else if (args[i] == "--green") {
       color = cmsysTerminal_Color_ForegroundGreen;
-      }
-    else if(args[i] == "--yellow")
-      {
+    } else if (args[i] == "--yellow") {
       color = cmsysTerminal_Color_ForegroundYellow;
-      }
-    else if(args[i] == "--blue")
-      {
+    } else if (args[i] == "--blue") {
       color = cmsysTerminal_Color_ForegroundBlue;
-      }
-    else if(args[i] == "--magenta")
-      {
+    } else if (args[i] == "--magenta") {
       color = cmsysTerminal_Color_ForegroundMagenta;
-      }
-    else if(args[i] == "--cyan")
-      {
+    } else if (args[i] == "--cyan") {
       color = cmsysTerminal_Color_ForegroundCyan;
-      }
-    else if(args[i] == "--white")
-      {
+    } else if (args[i] == "--white") {
       color = cmsysTerminal_Color_ForegroundWhite;
-      }
-    else if(args[i] == "--bold")
-      {
+    } else if (args[i] == "--bold") {
       color |= cmsysTerminal_Color_ForegroundBold;
-      }
-    else if(args[i] == "--no-newline")
-      {
+    } else if (args[i] == "--no-newline") {
       newline = false;
-      }
-    else if(args[i] == "--newline")
-      {
+    } else if (args[i] == "--newline") {
       newline = true;
-      }
-    else
-      {
+    } else {
       // Color is enabled.  Print with the current color.
-      cmSystemTools::MakefileColorEcho(color, args[i].c_str(),
-                                       newline, enabled);
-      }
+      cmSystemTools::MakefileColorEcho(color, args[i].c_str(), newline,
+                                       enabled);
     }
+  }
 
   return 0;
 }
 
-//----------------------------------------------------------------------------
 int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
 {
   // The arguments are
@@ -1281,25 +1082,21 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
   //   argv[2] == <link-script-name>
   //   argv[3] == --verbose=?
   bool verbose = false;
-  if(args.size() >= 4)
-    {
-    if(args[3].find("--verbose=") == 0)
-      {
-      if(!cmSystemTools::IsOff(args[3].substr(10).c_str()))
-        {
+  if (args.size() >= 4) {
+    if (args[3].find("--verbose=") == 0) {
+      if (!cmSystemTools::IsOff(args[3].substr(10).c_str())) {
         verbose = true;
-        }
       }
     }
+  }
 
   // Allocate a process instance.
   cmsysProcess* cp = cmsysProcess_New();
-  if(!cp)
-    {
+  if (!cp) {
     std::cerr << "Error allocating process instance in link script."
               << std::endl;
     return 1;
-    }
+  }
 
   // Children should share stdout and stderr with this process.
   cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
@@ -1310,50 +1107,42 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
 
   // Read command lines from the script.
   cmsys::ifstream fin(args[2].c_str());
-  if(!fin)
-    {
-    std::cerr << "Error opening link script \""
-              << args[2] << "\"" << std::endl;
+  if (!fin) {
+    std::cerr << "Error opening link script \"" << args[2] << "\""
+              << std::endl;
     return 1;
-    }
+  }
 
   // Run one command at a time.
   std::string command;
   int result = 0;
-  while(result == 0 && cmSystemTools::GetLineFromStream(fin, command))
-    {
+  while (result == 0 && cmSystemTools::GetLineFromStream(fin, command)) {
     // Skip empty command lines.
-    if(command.find_first_not_of(" \t") == command.npos)
-      {
+    if (command.find_first_not_of(" \t") == command.npos) {
       continue;
-      }
+    }
 
     // Setup this command line.
-    const char* cmd[2] = {command.c_str(), 0};
+    const char* cmd[2] = { command.c_str(), 0 };
     cmsysProcess_SetCommand(cp, cmd);
 
     // Report the command if verbose output is enabled.
-    if(verbose)
-      {
+    if (verbose) {
       std::cout << command << std::endl;
-      }
+    }
 
     // Run the command and wait for it to exit.
     cmsysProcess_Execute(cp);
     cmsysProcess_WaitForExit(cp, 0);
 
     // Report failure if any.
-    switch(cmsysProcess_GetState(cp))
-      {
-      case cmsysProcess_State_Exited:
-        {
+    switch (cmsysProcess_GetState(cp)) {
+      case cmsysProcess_State_Exited: {
         int value = cmsysProcess_GetExitValue(cp);
-        if(value != 0)
-          {
+        if (value != 0) {
           result = value;
-          }
         }
-        break;
+      } break;
       case cmsysProcess_State_Exception:
         std::cerr << "Error running link command: "
                   << cmsysProcess_GetExceptionString(cp) << std::endl;
@@ -1366,8 +1155,8 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
         break;
       default:
         break;
-      };
-    }
+    };
+  }
 
   // Free the process instance.
   cmsysProcess_Delete(cp);
@@ -1376,21 +1165,19 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
   return result;
 }
 
-//----------------------------------------------------------------------------
 int cmcmd::WindowsCEEnvironment(const char* version, const std::string& name)
 {
 #if defined(CMAKE_HAVE_VS_GENERATORS)
   cmVisualStudioWCEPlatformParser parser(name.c_str());
   parser.ParseVersion(version);
-  if (parser.Found())
-    {
+  if (parser.Found()) {
     std::cout << "@echo off" << std::endl;
     std::cout << "echo Environment Selection: " << name << std::endl;
     std::cout << "set PATH=" << parser.GetPathDirectories() << std::endl;
-    std::cout << "set INCLUDE=" << parser.GetIncludeDirectories() <<std::endl;
-    std::cout << "set LIB=" << parser.GetLibraryDirectories() <<std::endl;
+    std::cout << "set INCLUDE=" << parser.GetIncludeDirectories() << std::endl;
+    std::cout << "set LIB=" << parser.GetLibraryDirectories() << std::endl;
     return 0;
-    }
+  }
 #else
   (void)version;
 #endif
@@ -1412,16 +1199,19 @@ class cmVSLink
   std::string ManifestFileRC;
   std::string ManifestFileRes;
   std::string TargetFile;
+
 public:
   cmVSLink(int type, bool verbose)
     : Type(type)
     , Verbose(verbose)
     , Incremental(false)
     , LinkGeneratesManifest(true)
-    {}
+  {
+  }
   bool Parse(std::vector<std::string>::const_iterator argBeg,
              std::vector<std::string>::const_iterator argEnd);
   int Link();
+
 private:
   int LinkIncremental();
   int LinkNonIncremental();
@@ -1433,82 +1223,65 @@ private:
 // still works.
 int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
 {
-  if(args.size() < 2)
-    {
+  if (args.size() < 2) {
     return -1;
-    }
-  bool verbose = cmSystemTools::GetEnv("VERBOSE")? true:false;
+  }
+  bool verbose = cmSystemTools::GetEnv("VERBOSE") ? true : false;
   std::vector<std::string> expandedArgs;
-  for(std::vector<std::string>::iterator i = args.begin();
-      i != args.end(); ++i)
-    {
+  for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
+       ++i) {
     // check for nmake temporary files
-    if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 )
-      {
+    if ((*i)[0] == '@' && i->find("@CMakeFiles") != 0) {
       cmsys::ifstream fin(i->substr(1).c_str());
       std::string line;
-      while(cmSystemTools::GetLineFromStream(fin,
-                                             line))
-        {
+      while (cmSystemTools::GetLineFromStream(fin, line)) {
         cmSystemTools::ParseWindowsCommandLine(line.c_str(), expandedArgs);
-        }
       }
-    else
-      {
+    } else {
       expandedArgs.push_back(*i);
-      }
     }
+  }
 
   cmVSLink vsLink(type, verbose);
-  if (!vsLink.Parse(expandedArgs.begin()+2, expandedArgs.end()))
-    {
+  if (!vsLink.Parse(expandedArgs.begin() + 2, expandedArgs.end())) {
     return -1;
-    }
+  }
   return vsLink.Link();
 }
 
-static bool RunCommand(const char* comment,
-                       std::vector<std::string>& command,
-                       bool verbose,
-                       int* retCodeOut = 0)
+static bool RunCommand(const char* comment, std::vector<std::string>& command,
+                       bool verbose, int* retCodeOut = 0)
 {
-  if(verbose)
-    {
+  if (verbose) {
     std::cout << comment << ":\n";
     std::cout << cmJoin(command, " ") << "\n";
-    }
+  }
   std::string output;
-  int retCode =0;
+  int retCode = 0;
   // use rc command to create .res file
-  bool res = cmSystemTools::RunSingleCommand(command,
-                                             &output, &output,
-                                             &retCode, 0,
-                                             cmSystemTools::OUTPUT_NONE);
+  bool res = cmSystemTools::RunSingleCommand(
+    command, &output, &output, &retCode, 0, cmSystemTools::OUTPUT_NONE);
   // always print the output of the command, unless
   // it is the dumb rc command banner, but if the command
   // returned an error code then print the output anyway as
   // the banner may be mixed with some other important information.
-  if(output.find("Resource Compiler Version") == output.npos
-     || !res || retCode)
-    {
+  if (output.find("Resource Compiler Version") == output.npos || !res ||
+      retCode) {
     std::cout << output;
-    }
-  if (!res)
-    {
+  }
+  if (!res) {
     std::cout << comment << " failed to run." << std::endl;
     return false;
-    }
+  }
   // if retCodeOut is requested then always return true
   // and set the retCodeOut to retCode
-  if(retCodeOut)
-    {
+  if (retCodeOut) {
     *retCodeOut = retCode;
     return true;
-    }
-  if(retCode != 0)
-    {
+  }
+  if (retCode != 0) {
     std::cout << comment << " failed. with " << retCode << "\n";
-    }
+  }
   return retCode == 0;
 }
 
@@ -1518,97 +1291,71 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
   // Parse our own arguments.
   std::string intDir;
   std::vector<std::string>::const_iterator arg = argBeg;
-  while (arg != argEnd && cmHasLiteralPrefix(*arg, "-"))
-    {
-    if (*arg == "--")
-      {
+  while (arg != argEnd && cmHasLiteralPrefix(*arg, "-")) {
+    if (*arg == "--") {
       ++arg;
       break;
-      }
-    else if (*arg == "--manifests")
-      {
-      for (++arg; arg != argEnd && !cmHasLiteralPrefix(*arg, "-"); ++arg)
-        {
+    } else if (*arg == "--manifests") {
+      for (++arg; arg != argEnd && !cmHasLiteralPrefix(*arg, "-"); ++arg) {
         this->UserManifests.push_back(*arg);
-        }
       }
-    else if (cmHasLiteralPrefix(*arg, "--intdir="))
-      {
+    } else if (cmHasLiteralPrefix(*arg, "--intdir=")) {
       intDir = arg->substr(9);
       ++arg;
-      }
-    else
-      {
+    } else {
       std::cerr << "unknown argument '" << *arg << "'\n";
       return false;
-      }
     }
-  if (intDir.empty())
-    {
+  }
+  if (intDir.empty()) {
     return false;
-    }
+  }
 
   // The rest of the arguments form the link command.
-  if (arg == argEnd)
-    {
+  if (arg == argEnd) {
     return false;
-    }
+  }
   this->LinkCommand.insert(this->LinkCommand.begin(), arg, argEnd);
 
   // Parse the link command to extract information we need.
-  for (; arg != argEnd; ++arg)
-    {
-    if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0)
-      {
+  for (; arg != argEnd; ++arg) {
+    if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0) {
       this->Incremental = true;
-      }
-    else if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0)
-      {
+    } else if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0) {
       this->Incremental = true;
-      }
-    else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0)
-      {
+    } else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0) {
       this->LinkGeneratesManifest = false;
-      }
-    else if (cmHasLiteralPrefix(*arg, "/Fe"))
-      {
+    } else if (cmHasLiteralPrefix(*arg, "/Fe")) {
       this->TargetFile = arg->substr(3);
-      }
-    else if (cmHasLiteralPrefix(*arg, "/out:"))
-      {
+    } else if (cmHasLiteralPrefix(*arg, "/out:")) {
       this->TargetFile = arg->substr(5);
-      }
     }
+  }
 
-  if (this->TargetFile.empty())
-    {
+  if (this->TargetFile.empty()) {
     return false;
-    }
+  }
 
   this->ManifestFile = intDir + "/embed.manifest";
   this->LinkerManifestFile = intDir + "/intermediate.manifest";
 
-  if (this->Incremental)
-    {
+  if (this->Incremental) {
     // We will compile a resource containing the manifest and
     // pass it to the link command.
     this->ManifestFileRC = intDir + "/manifest.rc";
     this->ManifestFileRes = intDir + "/manifest.res";
-    }
-  else if (this->UserManifests.empty())
-    {
+  } else if (this->UserManifests.empty()) {
     // Prior to support for user-specified manifests CMake placed the
     // linker-generated manifest next to the binary (as if it were not to be
     // embedded) when not linking incrementally.  Preserve this behavior.
     this->ManifestFile = this->TargetFile + ".manifest";
     this->LinkerManifestFile = this->ManifestFile;
-    }
+  }
 
-  if (this->LinkGeneratesManifest)
-    {
+  if (this->LinkGeneratesManifest) {
     this->LinkCommand.push_back("/MANIFEST");
     this->LinkCommand.push_back("/MANIFESTFILE:" + this->LinkerManifestFile);
-    }
+  }
 
   return true;
 }
@@ -1616,25 +1363,19 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
 int cmVSLink::Link()
 {
   if (this->Incremental &&
-      (this->LinkGeneratesManifest || !this->UserManifests.empty()))
-    {
-    if (this->Verbose)
-      {
+      (this->LinkGeneratesManifest || !this->UserManifests.empty())) {
+    if (this->Verbose) {
       std::cout << "Visual Studio Incremental Link with embedded manifests\n";
-      }
-    return LinkIncremental();
     }
-  if (this->Verbose)
-    {
-    if (!this->Incremental)
-      {
+    return LinkIncremental();
+  }
+  if (this->Verbose) {
+    if (!this->Incremental) {
       std::cout << "Visual Studio Non-Incremental Link\n";
-      }
-    else
-      {
+    } else {
       std::cout << "Visual Studio Incremental Link without manifests\n";
-      }
     }
+  }
   return LinkNonIncremental();
 }
 
@@ -1666,91 +1407,81 @@ int cmVSLink::LinkIncremental()
   // Create a resource file referencing the manifest.
   std::string absManifestFile =
     cmSystemTools::CollapseFullPath(this->ManifestFile);
-  if (this->Verbose)
-    {
+  if (this->Verbose) {
     std::cout << "Create " << this->ManifestFileRC << "\n";
-    }
+  }
   {
-  cmsys::ofstream fout(this->ManifestFileRC.c_str());
-  if (!fout)
-    {
-    return -1;
+    cmsys::ofstream fout(this->ManifestFileRC.c_str());
+    if (!fout) {
+      return -1;
     }
-  fout << this->Type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ "
-    "24 /* RT_MANIFEST */ \"" << absManifestFile << "\"";
+    fout << this->Type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ "
+                          "24 /* RT_MANIFEST */ \""
+         << absManifestFile << "\"";
   }
 
   // If we have not previously generated a manifest file,
   // generate an empty one so the resource compiler succeeds.
-  if (!cmSystemTools::FileExists(this->ManifestFile))
-    {
-    if (this->Verbose)
-      {
+  if (!cmSystemTools::FileExists(this->ManifestFile)) {
+    if (this->Verbose) {
       std::cout << "Create empty: " << this->ManifestFile << "\n";
-      }
-    cmsys::ofstream foutTmp(this->ManifestFile.c_str());
     }
+    cmsys::ofstream foutTmp(this->ManifestFile.c_str());
+  }
 
   // Compile the resource file.
   std::vector<std::string> rcCommand;
   rcCommand.push_back(cmSystemTools::FindProgram("rc.exe"));
   rcCommand.push_back("/fo" + this->ManifestFileRes);
   rcCommand.push_back(this->ManifestFileRC);
-  if (!RunCommand("RC Pass 1", rcCommand, this->Verbose))
-    {
+  if (!RunCommand("RC Pass 1", rcCommand, this->Verbose)) {
     return -1;
-    }
+  }
 
   // Tell the linker to use our manifest compiled into a resource.
   this->LinkCommand.push_back(this->ManifestFileRes);
 
   // Run the link command (possibly generates intermediate manifest).
-  if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose))
-    {
+  if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose)) {
     return -1;
-    }
+  }
 
   // Run the manifest tool to create the final manifest.
   int mtRet = this->RunMT("/out:" + this->ManifestFile, true);
 
   // If mt returns 1090650113 (or 187 on a posix host) then it updated the
   // manifest file so we need to embed it again.  Otherwise we are done.
-  if (mtRet != 1090650113 && mtRet != 187)
-    {
+  if (mtRet != 1090650113 && mtRet != 187) {
     return mtRet;
-    }
+  }
 
   // Compile the resource file again.
-  if (!RunCommand("RC Pass 2", rcCommand, this->Verbose))
-    {
+  if (!RunCommand("RC Pass 2", rcCommand, this->Verbose)) {
     return -1;
-    }
+  }
 
   // Link incrementally again to use the updated resource.
-  if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose))
-    {
+  if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose)) {
     return -1;
-    }
+  }
   return 0;
 }
 
 int cmVSLink::LinkNonIncremental()
 {
   // Run the link command (possibly generates intermediate manifest).
-  if (!RunCommand("LINK", this->LinkCommand, this->Verbose))
-    {
+  if (!RunCommand("LINK", this->LinkCommand, this->Verbose)) {
     return -1;
-    }
+  }
 
   // If we have no manifest files we are done.
-  if (!this->LinkGeneratesManifest && this->UserManifests.empty())
-    {
+  if (!this->LinkGeneratesManifest && this->UserManifests.empty()) {
     return 0;
-    }
+  }
 
   // Run the manifest tool to embed the final manifest in the binary.
   std::string mtOut =
-    "/outputresource:" + this->TargetFile + (this->Type == 1? ";#1" : ";#2");
+    "/outputresource:" + this->TargetFile + (this->Type == 1 ? ";#1" : ";#2");
   return this->RunMT(mtOut, false);
 }
 
@@ -1760,23 +1491,20 @@ int cmVSLink::RunMT(std::string const& out, bool notify)
   mtCommand.push_back(cmSystemTools::FindProgram("mt.exe"));
   mtCommand.push_back("/nologo");
   mtCommand.push_back("/manifest");
-  if (this->LinkGeneratesManifest)
-    {
+  if (this->LinkGeneratesManifest) {
     mtCommand.push_back(this->LinkerManifestFile);
-    }
-  mtCommand.insert(mtCommand.end(),
-                   this->UserManifests.begin(), this->UserManifests.end());
+  }
+  mtCommand.insert(mtCommand.end(), this->UserManifests.begin(),
+                   this->UserManifests.end());
   mtCommand.push_back(out);
-  if (notify)
-    {
+  if (notify) {
     // Add an undocumented option that enables a special return
     // code to notify us when the manifest is modified.
     mtCommand.push_back("/notify_update");
-    }
+  }
   int mtRet = 0;
-  if (!RunCommand("MT", mtCommand, this->Verbose, &mtRet))
-    {
+  if (!RunCommand("MT", mtCommand, this->Verbose, &mtRet)) {
     return -1;
-    }
+  }
   return mtRet;
 }
diff --git a/Source/cmcmd.h b/Source/cmcmd.h
index 64b2406..8da2103 100644
--- a/Source/cmcmd.h
+++ b/Source/cmcmd.h
@@ -18,14 +18,13 @@
 class cmcmd
 {
 public:
-
   /**
    * Execute commands during the build process. Supports options such
    * as echo, remove file etc.
    */
   static int ExecuteCMakeCommand(std::vector<std::string>&);
-protected:
 
+protected:
   static int SymlinkLibrary(std::vector<std::string>& args);
   static int SymlinkExecutable(std::vector<std::string>& args);
   static bool SymlinkInternal(std::string const& file,
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 7fa6aed..4edd62e 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -13,115 +13,106 @@
 #include "cmSystemTools.h"
 
 // Need these for documentation support.
-#include "cmake.h"
 #include "cmDocumentation.h"
+#include "cmake.h"
 
-#include "CTest/cmCTestScriptHandler.h"
 #include "CTest/cmCTestLaunch.h"
+#include "CTest/cmCTestScriptHandler.h"
 #include "cmsys/Encoding.hxx"
 
-//----------------------------------------------------------------------------
-static const char * cmDocumentationName[][2] =
-{
-  {0,
-   "  ctest - Testing driver provided by CMake."},
-  {0,0}
-};
-
-//----------------------------------------------------------------------------
-static const char * cmDocumentationUsage[][2] =
-{
-  {0,
-   "  ctest [options]"},
-  {0,0}
+static const char* cmDocumentationName[][2] = {
+  { 0, "  ctest - Testing driver provided by CMake." },
+  { 0, 0 }
 };
 
-//----------------------------------------------------------------------------
-//----------------------------------------------------------------------------
-static const char * cmDocumentationOptions[][2] =
-{
-  {"-C <cfg>, --build-config <cfg>", "Choose configuration to test."},
-  {"-V,--verbose", "Enable verbose output from tests."},
-  {"-VV,--extra-verbose", "Enable more verbose output from tests."},
-  {"--debug", "Displaying more verbose internals of CTest."},
-  {"--output-on-failure", "Output anything outputted by the test program "
-    "if the test should fail."},
-  {"--test-output-size-passed <size>", "Limit the output for passed tests "
-    "to <size> bytes"},
-  {"--test-output-size-failed <size>", "Limit the output for failed tests "
-    "to <size> bytes"},
-  {"-F", "Enable failover."},
-  {"-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the "
-   "given number of jobs."},
-  {"-Q,--quiet", "Make ctest quiet."},
-  {"-O <file>, --output-log <file>", "Output to log file"},
-  {"-N,--show-only", "Disable actual execution of tests."},
-  {"-L <regex>, --label-regex <regex>", "Run tests with labels matching "
-   "regular expression."},
-  {"-R <regex>, --tests-regex <regex>", "Run tests matching regular "
-   "expression."},
-  {"-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular "
-   "expression."},
-  {"-LE <regex>, --label-exclude <regex>", "Exclude tests with labels "
-   "matching regular expression."},
-  {"-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test"},
-  {"-D <var>:<type>=<value>", "Define a variable for script mode"},
-  {"-M <model>, --test-model <model>", "Sets the model for a dashboard"},
-  {"-T <action>, --test-action <action>", "Sets the dashboard action to "
-   "perform"},
-  {"--track <track>", "Specify the track to submit dashboard to"},
-  {"-S <script>, --script <script>", "Execute a dashboard for a "
-   "configuration"},
-  {"-SP <script>, --script-new-process <script>", "Execute a dashboard for a "
-   "configuration"},
-  {"-A <file>, --add-notes <file>", "Add a notes file with submission"},
-  {"-I [Start,End,Stride,test#,test#|Test file], --tests-information",
-   "Run a specific number of tests by number."},
-  {"-U, --union", "Take the Union of -I and -R"},
-  {"--rerun-failed", "Run only the tests that failed previously"},
-  {"--repeat-until-fail <n>", "Require each test to run <n> "
-   "times without failing in order to pass"},
-  {"--max-width <width>", "Set the max width for a test name to output"},
-  {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1."},
-  {"--no-label-summary", "Disable timing summary information for labels."},
-  {"--build-and-test", "Configure, build and run a test."},
-  {"--build-target", "Specify a specific target to build."},
-  {"--build-nocmake", "Run the build without running cmake first."},
-  {"--build-run-dir", "Specify directory to run programs from."},
-  {"--build-two-config", "Run CMake twice"},
-  {"--build-exe-dir", "Specify the directory for the executable."},
-  {"--build-generator", "Specify the generator to use."},
-  {"--build-generator-platform", "Specify the generator-specific platform."},
-  {"--build-generator-toolset", "Specify the generator-specific toolset."},
-  {"--build-project", "Specify the name of the project to build."},
-  {"--build-makeprogram", "Specify the make program to use."},
-  {"--build-noclean", "Skip the make clean step."},
-  {"--build-config-sample",
-   "A sample executable to use to determine the configuration"},
-  {"--build-options", "Add extra options to the build step."},
-
-  {"--test-command", "The test to run with the --build-and-test option."},
-  {"--test-timeout", "The time limit in seconds, internal use only."},
-  {"--test-load", "CPU load threshold for starting new parallel tests."},
-  {"--tomorrow-tag", "Nightly or experimental starts with next day tag."},
-  {"--ctest-config", "The configuration file used to initialize CTest state "
-   "when submitting dashboards."},
-  {"--overwrite", "Overwrite CTest configuration option."},
-  {"--extra-submit <file>[;<file>]", "Submit extra files to the dashboard."},
-  {"--force-new-ctest-process", "Run child CTest instances as new processes"},
-  {"--schedule-random", "Use a random order for scheduling tests"},
-  {"--submit-index", "Submit individual dashboard tests with specific index"},
-  {"--timeout <seconds>", "Set a global timeout on all tests."},
-  {"--stop-time <time>",
-   "Set a time at which all tests should stop running."},
-  {"--http1.0", "Submit using HTTP 1.0."},
-  {"--no-compress-output", "Do not compress test output when submitting."},
-  {"--print-labels", "Print all available test labels."},
-  {0,0}
+static const char* cmDocumentationUsage[][2] = { { 0, "  ctest [options]" },
+                                                 { 0, 0 } };
+
+static const char* cmDocumentationOptions[][2] = {
+  { "-C <cfg>, --build-config <cfg>", "Choose configuration to test." },
+  { "-V,--verbose", "Enable verbose output from tests." },
+  { "-VV,--extra-verbose", "Enable more verbose output from tests." },
+  { "--debug", "Displaying more verbose internals of CTest." },
+  { "--output-on-failure", "Output anything outputted by the test program "
+                           "if the test should fail." },
+  { "--test-output-size-passed <size>", "Limit the output for passed tests "
+                                        "to <size> bytes" },
+  { "--test-output-size-failed <size>", "Limit the output for failed tests "
+                                        "to <size> bytes" },
+  { "-F", "Enable failover." },
+  { "-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the "
+                                    "given number of jobs." },
+  { "-Q,--quiet", "Make ctest quiet." },
+  { "-O <file>, --output-log <file>", "Output to log file" },
+  { "-N,--show-only", "Disable actual execution of tests." },
+  { "-L <regex>, --label-regex <regex>", "Run tests with labels matching "
+                                         "regular expression." },
+  { "-R <regex>, --tests-regex <regex>", "Run tests matching regular "
+                                         "expression." },
+  { "-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular "
+                                           "expression." },
+  { "-LE <regex>, --label-exclude <regex>", "Exclude tests with labels "
+                                            "matching regular expression." },
+  { "-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test" },
+  { "-D <var>:<type>=<value>", "Define a variable for script mode" },
+  { "-M <model>, --test-model <model>", "Sets the model for a dashboard" },
+  { "-T <action>, --test-action <action>", "Sets the dashboard action to "
+                                           "perform" },
+  { "--track <track>", "Specify the track to submit dashboard to" },
+  { "-S <script>, --script <script>", "Execute a dashboard for a "
+                                      "configuration" },
+  { "-SP <script>, --script-new-process <script>", "Execute a dashboard for a "
+                                                   "configuration" },
+  { "-A <file>, --add-notes <file>", "Add a notes file with submission" },
+  { "-I [Start,End,Stride,test#,test#|Test file], --tests-information",
+    "Run a specific number of tests by number." },
+  { "-U, --union", "Take the Union of -I and -R" },
+  { "--rerun-failed", "Run only the tests that failed previously" },
+  { "--repeat-until-fail <n>", "Require each test to run <n> "
+                               "times without failing in order to pass" },
+  { "--max-width <width>", "Set the max width for a test name to output" },
+  { "--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1." },
+  { "--no-label-summary", "Disable timing summary information for labels." },
+  { "--build-and-test", "Configure, build and run a test." },
+  { "--build-target", "Specify a specific target to build." },
+  { "--build-nocmake", "Run the build without running cmake first." },
+  { "--build-run-dir", "Specify directory to run programs from." },
+  { "--build-two-config", "Run CMake twice" },
+  { "--build-exe-dir", "Specify the directory for the executable." },
+  { "--build-generator", "Specify the generator to use." },
+  { "--build-generator-platform", "Specify the generator-specific platform." },
+  { "--build-generator-toolset", "Specify the generator-specific toolset." },
+  { "--build-project", "Specify the name of the project to build." },
+  { "--build-makeprogram", "Specify the make program to use." },
+  { "--build-noclean", "Skip the make clean step." },
+  { "--build-config-sample",
+    "A sample executable to use to determine the configuration" },
+  { "--build-options", "Add extra options to the build step." },
+
+  { "--test-command", "The test to run with the --build-and-test option." },
+  { "--test-timeout", "The time limit in seconds, internal use only." },
+  { "--test-load", "CPU load threshold for starting new parallel tests." },
+  { "--tomorrow-tag", "Nightly or experimental starts with next day tag." },
+  { "--ctest-config", "The configuration file used to initialize CTest state "
+                      "when submitting dashboards." },
+  { "--overwrite", "Overwrite CTest configuration option." },
+  { "--extra-submit <file>[;<file>]", "Submit extra files to the dashboard." },
+  { "--force-new-ctest-process",
+    "Run child CTest instances as new processes" },
+  { "--schedule-random", "Use a random order for scheduling tests" },
+  { "--submit-index",
+    "Submit individual dashboard tests with specific index" },
+  { "--timeout <seconds>", "Set a global timeout on all tests." },
+  { "--stop-time <time>",
+    "Set a time at which all tests should stop running." },
+  { "--http1.0", "Submit using HTTP 1.0." },
+  { "--no-compress-output", "Do not compress test output when submitting." },
+  { "--print-labels", "Print all available test labels." },
+  { 0, 0 }
 };
 
 // this is a test driver program for cmCTest.
-int main (int argc, char const* const* argv)
+int main(int argc, char const* const* argv)
 {
   cmsys::Encoding::CommandLineArguments encoding_args =
     cmsys::Encoding::CommandLineArguments::Main(argc, argv);
@@ -133,37 +124,34 @@ int main (int argc, char const* const* argv)
   cmSystemTools::FindCMakeResources(argv[0]);
 
   // Dispatch 'ctest --launch' mode directly.
-  if(argc >= 2 && strcmp(argv[1], "--launch") == 0)
-    {
+  if (argc >= 2 && strcmp(argv[1], "--launch") == 0) {
     return cmCTestLaunch::Main(argc, argv);
-    }
+  }
 
   cmCTest inst;
 
-  if (cmSystemTools::GetCurrentWorkingDirectory().empty())
-    {
+  if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
     cmCTestLog(&inst, ERROR_MESSAGE,
-      "Current working directory cannot be established." << std::endl);
+               "Current working directory cannot be established."
+                 << std::endl);
     return 1;
-    }
+  }
 
   // If there is a testing input file, check for documentation options
   // only if there are actually arguments.  We want running without
   // arguments to run tests.
-  if(argc > 1 || !(cmSystemTools::FileExists("CTestTestfile.cmake") ||
-                   cmSystemTools::FileExists("DartTestfile.txt")))
-    {
-    if(argc == 1)
-      {
+  if (argc > 1 ||
+      !(cmSystemTools::FileExists("CTestTestfile.cmake") ||
+        cmSystemTools::FileExists("DartTestfile.txt"))) {
+    if (argc == 1) {
       cmCTestLog(&inst, ERROR_MESSAGE, "*********************************"
-        << std::endl
-        << "No test configuration file found!" << std::endl
-        << "*********************************" << std::endl);
-      }
+                   << std::endl
+                   << "No test configuration file found!" << std::endl
+                   << "*********************************" << std::endl);
+    }
     cmDocumentation doc;
     doc.addCTestStandardDocSections();
-    if(doc.CheckOptions(argc, argv))
-      {
+    if (doc.CheckOptions(argc, argv)) {
       cmake hcm;
       hcm.SetHomeDirectory("");
       hcm.SetHomeOutputDirectory("");
@@ -171,33 +159,31 @@ int main (int argc, char const* const* argv)
 
       // Construct and print requested documentation.
       cmCTestScriptHandler* ch =
-                 static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
+        static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
       ch->CreateCMake();
 
       doc.SetShowGenerators(false);
       doc.SetName("ctest");
-      doc.SetSection("Name",cmDocumentationName);
-      doc.SetSection("Usage",cmDocumentationUsage);
-      doc.PrependSection("Options",cmDocumentationOptions);
+      doc.SetSection("Name", cmDocumentationName);
+      doc.SetSection("Usage", cmDocumentationUsage);
+      doc.PrependSection("Options", cmDocumentationOptions);
 #ifdef cout
-#  undef cout
+#undef cout
 #endif
-      return doc.PrintRequestedDocumentation(std::cout)? 0:1;
+      return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
 #define cout no_cout_use_cmCTestLog
-      }
     }
+  }
 
   // copy the args to a vector
   std::vector<std::string> args;
-  for(int i =0; i < argc; ++i)
-    {
+  for (int i = 0; i < argc; ++i) {
     args.push_back(argv[i]);
-    }
+  }
   // run ctest
   std::string output;
-  int res = inst.Run(args,&output);
+  int res = inst.Run(args, &output);
   cmCTestLog(&inst, OUTPUT, output);
 
   return res;
 }
-
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index 3636836..f713294 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -20,6 +20,7 @@
 #if 0
 # include "CommandLineArguments.hxx.in"
 # include "Configure.hxx.in"
+# include "String.hxx.in"
 #endif
 
 #include <vector>
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index b9d25a8..b75acb2 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -254,7 +254,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
        a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
 #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
 #define SET(a, b, c, d, k, s, Ti)\
-  t = a + F(b,c,d) + X[k] + Ti;\
+  t = a + F(b,c,d) + X[k] + (Ti);\
   a = ROTATE_LEFT(t, s) + b
     /* Do the following 16 operations. */
     SET(a, b, c, d,  0,  7,  T1);
@@ -280,7 +280,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
           a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
 #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
 #define SET(a, b, c, d, k, s, Ti)\
-  t = a + G(b,c,d) + X[k] + Ti;\
+  t = a + G(b,c,d) + X[k] + (Ti);\
   a = ROTATE_LEFT(t, s) + b
      /* Do the following 16 operations. */
     SET(a, b, c, d,  1,  5, T17);
@@ -306,7 +306,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
           a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
 #define H(x, y, z) ((x) ^ (y) ^ (z))
 #define SET(a, b, c, d, k, s, Ti)\
-  t = a + H(b,c,d) + X[k] + Ti;\
+  t = a + H(b,c,d) + X[k] + (Ti);\
   a = ROTATE_LEFT(t, s) + b
      /* Do the following 16 operations. */
     SET(a, b, c, d,  5,  4, T33);
@@ -332,7 +332,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
           a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
 #define I(x, y, z) ((y) ^ ((x) | ~(z)))
 #define SET(a, b, c, d, k, s, Ti)\
-  t = a + I(b,c,d) + X[k] + Ti;\
+  t = a + I(b,c,d) + X[k] + (Ti);\
   a = ROTATE_LEFT(t, s) + b
      /* Do the following 16 operations. */
     SET(a, b, c, d,  0,  6, T49);
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in
index c5ebc97..96563a2 100644
--- a/Source/kwsys/Process.h.in
+++ b/Source/kwsys/Process.h.in
@@ -77,6 +77,7 @@
 # define kwsysProcess_WaitForExit               kwsys_ns(Process_WaitForExit)
 # define kwsysProcess_Interrupt                 kwsys_ns(Process_Interrupt)
 # define kwsysProcess_Kill                      kwsys_ns(Process_Kill)
+# define kwsysProcess_ResetStartTime            kwsys_ns(Process_ResetStartTime)
 #endif
 
 #if defined(__cplusplus)
@@ -392,6 +393,11 @@ kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp);
  */
 kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
 
+/**
+ * Reset the start time of the child process to the current time.
+ */
+kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp);
+
 #if defined(__cplusplus)
 } /* extern "C" */
 #endif
@@ -456,6 +462,7 @@ kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
 #  undef kwsysProcess_WaitForExit
 #  undef kwsysProcess_Interrupt
 #  undef kwsysProcess_Kill
+#  undef kwsysProcess_ResetStartTime
 # endif
 #endif
 
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 07c644b..b577982 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -505,6 +505,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
     {
     cp->Timeout = 0;
     }
+  // Force recomputation of TimeoutTime.
+  cp->TimeoutTime.tv_sec = -1;
 }
 
 /*--------------------------------------------------------------------------*/
@@ -3056,3 +3058,14 @@ static void kwsysProcessesSignalHandler(int signum
 
   errno = old_errno;
 }
+
+/*--------------------------------------------------------------------------*/
+void kwsysProcess_ResetStartTime(kwsysProcess* cp)
+{
+  if(!cp)
+    {
+    return;
+    }
+  /* Reset start time. */
+  cp->StartTime = kwsysProcessTimeGetCurrent();
+}
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 1f8749f..2b93e69 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -17,7 +17,7 @@
    duplicate the above list of headers.  */
 #if 0
 # include "Process.h.in"
-# include "Encoding_c.h.in"
+# include "Encoding.h.in"
 #endif
 
 /*
@@ -698,6 +698,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
     {
     cp->Timeout = 0;
     }
+  // Force recomputation of TimeoutTime.
+  cp->TimeoutTime.QuadPart = -1;
 }
 
 /*--------------------------------------------------------------------------*/
@@ -3015,3 +3017,14 @@ static BOOL WINAPI kwsysCtrlHandler(DWORD dwCtrlType)
   /* Continue on to default Ctrl handler (which calls ExitProcess).  */
   return FALSE;
 }
+
+/*--------------------------------------------------------------------------*/
+void kwsysProcess_ResetStartTime(kwsysProcess* cp)
+{
+  if(!cp)
+    {
+    return;
+    }
+  /* Reset start time. */
+  cp->StartTime = kwsysProcessTimeGetCurrent();
+}
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index 598e7ca..22593b4 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -376,7 +376,7 @@ bool RegularExpression::compile (const char* exp) {
     }
 
     // Allocate space.
-//#ifndef WIN32
+//#ifndef _WIN32
     if (this->program != 0) delete [] this->program;
 //#endif
     this->program = new char[regsize];
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index d0235d8..0bb700f 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -333,7 +333,7 @@ inline RegularExpression::RegularExpression (const std::string& s)
  */
 inline RegularExpression::~RegularExpression () 
 {
-//#ifndef WIN32
+//#ifndef _WIN32
   delete [] this->program;
 //#endif
 }
@@ -396,7 +396,7 @@ inline bool RegularExpression::is_valid () const
 
 inline void RegularExpression::set_invalid () 
 {
-//#ifndef WIN32
+//#ifndef _WIN32
   delete [] this->program;
 //#endif
   this->program = 0;
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index cddcc8d..81fb2f9 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -43,7 +43,6 @@
 #if 0
 # include "SystemInformation.hxx.in"
 # include "Process.h.in"
-# include "Configure.hxx.in"
 #endif
 
 #include <iostream>
@@ -177,13 +176,13 @@ typedef struct rlimit ResourceLimitType;
 # if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
 #  define iostreamLongLong(x) (x)
 # else
-#  define iostreamLongLong(x) ((long)x)
+#  define iostreamLongLong(x) ((long)(x))
 # endif
 #elif defined(KWSYS_USE___INT64)
 # if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
 #  define iostreamLongLong(x) (x)
 # else
-#  define iostreamLongLong(x) ((long)x)
+#  define iostreamLongLong(x) ((long)(x))
 # endif
 #else
 # error "No Long Long"
@@ -201,13 +200,13 @@ typedef struct rlimit ResourceLimitType;
 # endif
 #endif
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64)
+#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && !defined(__clang__)
 #define USE_ASM_INSTRUCTIONS 1
 #else
 #define USE_ASM_INSTRUCTIONS 0
 #endif
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__)
 #include <intrin.h>
 #define USE_CPUID_INTRINSICS 1
 #else
@@ -861,7 +860,7 @@ void SystemInformation::RunMemoryCheck()
 // --------------------------------------------------------------
 // SystemInformationImplementation starts here
 
-#define STORE_TLBCACHE_INFO(x,y)  x = (x < y) ? y : x
+#define STORE_TLBCACHE_INFO(x,y)  x = (x < (y)) ? (y) : x
 #define TLBCACHE_INFO_UNITS      (15)
 #define CLASSICAL_CPU_FREQ_LOOP    10000000
 #define RDTSC_INSTRUCTION      _asm _emit 0x0f _asm _emit 0x31
@@ -1584,7 +1583,7 @@ SystemInformationImplementation::~SystemInformationImplementation()
 
 void SystemInformationImplementation::RunCPUCheck()
 {
-#ifdef WIN32
+#ifdef _WIN32
   // Check to see if this processor supports CPUID.
   bool supportsCPUID = DoesCPUSupportCPUID();
 
@@ -2057,7 +2056,7 @@ bool SystemInformationImplementation::DoesCPUSupportFeature(long int dwFeature)
 
 void SystemInformationImplementation::Delay(unsigned int uiMS)
 {
-#ifdef WIN32
+#ifdef _WIN32
   LARGE_INTEGER Frequency, StartCounter, EndCounter;
   __int64 x;
 
@@ -2340,7 +2339,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails()
         case 13: TLBCacheUnit = ((TLBCacheData[3] & 0x00FF0000) >> 16); break;
         case 14: TLBCacheUnit = ((TLBCacheData[3] & 0xFF000000) >> 24); break;
 
-        // Default case - an error has occured.
+        // Default case - an error has occurred.
         default: return false;
         }
 
@@ -2402,7 +2401,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails()
         case 0x96: STORE_TLBCACHE_INFO (TLBCode, 262144); break;  // <-- FIXME: IA-64 Only
         case 0x9b: STORE_TLBCACHE_INFO (TLBCode, 262144); break;  // <-- FIXME: IA-64 Only
 
-        // Default case - an error has occured.
+        // Default case - an error has occurred.
         default: return false;
         }
       }
@@ -3570,33 +3569,44 @@ SystemInformationImplementation::GetHostMemoryUsed()
   return (statex.ullTotalPhys - statex.ullAvailPhys)/1024;
 # endif
 #elif defined(__linux)
-  const char *names[3]={"MemTotal:","MemFree:",NULL};
-  SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)};
-  int ierr=GetFieldsFromFile("/proc/meminfo",names,values);
+  // First try to use MemAvailable, but it only works on newer kernels
+  const char *names2[3]={"MemTotal:","MemAvailable:",NULL};
+  SystemInformation::LongLong values2[2]={SystemInformation::LongLong(0)};
+  int ierr=GetFieldsFromFile("/proc/meminfo",names2,values2);
   if (ierr)
     {
-    return ierr;
-    }
-  SystemInformation::LongLong &memTotal=values[0];
-  SystemInformation::LongLong &memFree=values[1];
-  return memTotal - memFree;
+    const char *names4[5]={"MemTotal:","MemFree:","Buffers:","Cached:",NULL};
+    SystemInformation::LongLong values4[4]={SystemInformation::LongLong(0)};
+    ierr=GetFieldsFromFile("/proc/meminfo",names4,values4);
+    if(ierr)
+      {
+      return ierr;
+      }
+    SystemInformation::LongLong &memTotal=values4[0];
+    SystemInformation::LongLong &memFree=values4[1];
+    SystemInformation::LongLong &memBuffers=values4[2];
+    SystemInformation::LongLong &memCached=values4[3];
+    return memTotal - memFree - memBuffers - memCached;
+    }
+  SystemInformation::LongLong &memTotal=values2[0];
+  SystemInformation::LongLong &memAvail=values2[1];
+  return memTotal - memAvail;
 #elif defined(__APPLE__)
   SystemInformation::LongLong psz=getpagesize();
   if (psz<1)
     {
     return -1;
     }
-  const char *names[4]={"Pages active:","Pages inactive:","Pages wired down:",NULL};
-  SystemInformation::LongLong values[3]={SystemInformation::LongLong(0)};
+  const char *names[3]={"Pages wired down:","Pages active:",NULL};
+  SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)};
   int ierr=GetFieldsFromCommand("vm_stat", names, values);
   if (ierr)
     {
     return -1;
     }
-  SystemInformation::LongLong &vmActive=values[0];
-  SystemInformation::LongLong &vmInactive=values[1];
-  SystemInformation::LongLong &vmWired=values[2];
-  return ((vmActive+vmInactive+vmWired)*psz)/1024;
+  SystemInformation::LongLong &vmWired=values[0];
+  SystemInformation::LongLong &vmActive=values[1];
+  return ((vmActive+vmWired)*psz)/1024;
 #else
   return 0;
 #endif
@@ -4622,7 +4632,7 @@ std::string SystemInformationImplementation::RunProcess(std::vector<const char*>
   double timeout = 255;
   int pipe; // pipe id as returned by kwsysProcess_WaitForData()
 
-  while( ( pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout),
+  while( ( static_cast<void>(pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout)),
            (pipe == kwsysProcess_Pipe_STDOUT || pipe == kwsysProcess_Pipe_STDERR) ) ) // wait for 1s
     {
       buffer.append(data, length);
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index e3428f8..c6e668d 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -35,10 +35,12 @@
 #include <fstream>
 #include <sstream>
 #include <set>
+#include <vector>
 
 // Work-around CMake dependency scanning limitation.  This must
 // duplicate the above list of headers.
 #if 0
+# include "RegularExpression.hxx.in"
 # include "SystemTools.hxx.in"
 # include "Directory.hxx.in"
 # include "FStream.hxx.in"
@@ -87,6 +89,7 @@
 // Windows API.
 #if defined(_WIN32)
 # include <windows.h>
+# include <winioctl.h>
 # ifndef INVALID_FILE_ATTRIBUTES
 #  define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
 # endif
@@ -2754,6 +2757,107 @@ std::string SystemTools::GetLastSystemError()
   return strerror(e);
 }
 
+#ifdef _WIN32
+
+static bool IsJunction(const std::wstring& source)
+{
+#ifdef FSCTL_GET_REPARSE_POINT
+  const DWORD JUNCTION_ATTRS = FILE_ATTRIBUTE_DIRECTORY |
+                               FILE_ATTRIBUTE_REPARSE_POINT;
+  DWORD attrs = GetFileAttributesW(source.c_str());
+  if (attrs == INVALID_FILE_ATTRIBUTES)
+    {
+    return false;
+    }
+  if ((attrs & JUNCTION_ATTRS) != JUNCTION_ATTRS)
+    {
+    return false;
+    }
+
+  // Adjust privileges so that we can succefully open junction points.
+  HANDLE token;
+  TOKEN_PRIVILEGES privs;
+  OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
+  LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &privs.Privileges[0].Luid);
+  privs.PrivilegeCount = 1;
+  privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+  AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
+  CloseHandle(token);
+
+  HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ,
+                           0, NULL, OPEN_EXISTING,
+                           FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+  if (dir == INVALID_HANDLE_VALUE)
+    {
+    return false;
+    }
+
+  // Query whether this is a reparse point or not.
+  BYTE buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+  REPARSE_GUID_DATA_BUFFER *reparse_buffer =
+    (REPARSE_GUID_DATA_BUFFER*) buffer;
+  DWORD sentinel;
+
+  BOOL success = DeviceIoControl(
+    dir, FSCTL_GET_REPARSE_POINT,
+    NULL, 0,
+    reparse_buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE,
+    &sentinel, NULL);
+
+  CloseHandle(dir);
+
+  return (success && (reparse_buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT));
+#else
+  return false;
+#endif
+}
+
+static bool DeleteJunction(const std::wstring& source)
+{
+#ifdef FSCTL_DELETE_REPARSE_POINT
+  // Adjust privileges so that we can succefully open junction points as
+  // read/write.
+  HANDLE token;
+  TOKEN_PRIVILEGES privs;
+  OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
+  LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &privs.Privileges[0].Luid);
+  privs.PrivilegeCount = 1;
+  privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+  AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
+  CloseHandle(token);
+
+  HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ | GENERIC_WRITE,
+                           0, NULL, OPEN_EXISTING,
+                           FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+  if (dir == INVALID_HANDLE_VALUE)
+    {
+    return false;
+    }
+
+  // Set up the structure so that we can delete the junction.
+  std::vector<BYTE> buffer(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0);
+  REPARSE_GUID_DATA_BUFFER *reparse_buffer =
+    (REPARSE_GUID_DATA_BUFFER*) &buffer[0];
+  DWORD sentinel;
+
+  reparse_buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
+
+  BOOL success = DeviceIoControl(
+    dir, FSCTL_DELETE_REPARSE_POINT,
+    reparse_buffer, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE,
+    NULL, 0,
+    &sentinel, NULL);
+
+  CloseHandle(dir);
+
+  return !!success;
+#else
+  return false;
+#endif
+}
+
+#endif
+
 bool SystemTools::RemoveFile(const std::string& source)
 {
 #ifdef _WIN32
@@ -2781,6 +2885,10 @@ bool SystemTools::RemoveFile(const std::string& source)
     SetLastError(err);
     return false;
     }
+  if (IsJunction(ws) && DeleteJunction(ws))
+    {
+    return true;
+    }
   if (DeleteFileW(ws.c_str()) ||
       GetLastError() == ERROR_FILE_NOT_FOUND ||
       GetLastError() == ERROR_PATH_NOT_FOUND)
@@ -4651,8 +4759,9 @@ bool SystemTools::GetLineFromStream(std::istream& is,
   // been reached.  Clear the fail bit just before reading.
   while(!haveNewline &&
         leftToRead != 0 &&
-        (is.clear(is.rdstate() & ~std::ios::failbit),
-         is.getline(buffer, bufferSize), is.gcount() > 0))
+        (static_cast<void>(is.clear(is.rdstate() & ~std::ios::failbit)),
+         static_cast<void>(is.getline(buffer, bufferSize)),
+         is.gcount() > 0))
     {
     // We have read at least one byte.
     haveData = true;
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index 695a134..7c58769 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -53,7 +53,7 @@ static std::string GetLibName(const char* lname)
  * r2: should GetSymbolAddress succeed ?
  * r3: should CloseLibrary succeed ?
  */
-int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, int r3)
+static int TestDynamicLoader(const char* libname, const char* symbol, int r1, int r2, int r3)
 {
   std::cerr << "Testing: " << libname << std::endl;
   kwsys::DynamicLoader::LibraryHandle l
diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx
index 842b17d..80ec040 100644
--- a/Source/kwsys/testEncoding.cxx
+++ b/Source/kwsys/testEncoding.cxx
@@ -120,7 +120,7 @@ static int testRobustEncoding()
     ret++;
     }
 
-#ifdef WIN32
+#ifdef _WIN32
   // 16 bit wchar_t - we make an invalid surrogate pair
   wchar_t cwstr[] = {0xD801, 0xDA00, 0};
   // this conversion could fail
diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx
index ab1f83e..ae66ceb 100644
--- a/Source/kwsys/testHashSTL.cxx
+++ b/Source/kwsys/testHashSTL.cxx
@@ -18,7 +18,6 @@
 #if 0
 # include "hash_map.hxx.in"
 # include "hash_set.hxx.in"
-# include "hashtable.hxx.in"
 #endif
 
 #include <iostream>
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx
index 396a09d..5ff7955 100644
--- a/Source/kwsys/testIOS.cxx
+++ b/Source/kwsys/testIOS.cxx
@@ -18,6 +18,12 @@
 #include <vector>
 #include <string.h> /* strlen */
 
+// Work-around CMake dependency scanning limitation.  This must
+// duplicate the above list of headers.
+#if 0
+# include "Configure.hxx.in"
+#endif
+
 int testIOS(int, char*[])
 {
   std::ostringstream ostr;
diff --git a/Templates/AppleInfo.plist b/Templates/AppleInfo.plist
index 1f68ccf..3445e53 100644
--- a/Templates/AppleInfo.plist
+++ b/Templates/AppleInfo.plist
@@ -28,8 +28,6 @@
 	<string>${APPLE_GUI_BUNDLE_VERSION}</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
-	<key>LSRequiresCarbon</key>
-	<true/>
 	<key>NSHumanReadableCopyright</key>
 	<string>${APPLE_GUI_COPYRIGHT}</string>
 </dict>
diff --git a/Templates/CMakeVisualStudio6Configurations.cmake b/Templates/CMakeVisualStudio6Configurations.cmake
deleted file mode 100644
index 6355969..0000000
--- a/Templates/CMakeVisualStudio6Configurations.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-# When the dll templates are changed, this list should be
-# updated with the list of possible configurations.
-set(CMAKE_CONFIGURATION_TYPES Debug Release MinSizeRel RelWithDebInfo)
diff --git a/Templates/DLLFooter.dsptemplate b/Templates/DLLFooter.dsptemplate
deleted file mode 100644
index 0d0682a..0000000
--- a/Templates/DLLFooter.dsptemplate
+++ /dev/null
@@ -1,4 +0,0 @@
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/Templates/DLLHeader.dsptemplate b/Templates/DLLHeader.dsptemplate
deleted file mode 100644
index d9bccaf..0000000
--- a/Templates/DLLHeader.dsptemplate
+++ /dev/null
@@ -1,192 +0,0 @@
-# Microsoft Developer Studio Project File - Name="OUTPUT_LIBNAME" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=OUTPUT_LIBNAME - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak" CFG="OUTPUT_LIBNAME - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OUTPUT_LIBNAME - Win32 MinSizeRel" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "OUTPUT_LIBNAME - Win32 RelWithDebInfo" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# ITK DSP Header file
-# This file is read by the build system of itk, and is used as the top part of
-# a microsoft project dsp header file
-# IF this is in a dsp file, then it is not the header, but has
-# already been used, so do not edit here...
-
-# variables to REPLACE
-# 
-# BUILD_INCLUDES == include path
-# EXTRA_DEFINES == compiler defines
-# OUTPUT_DIRECTORY == override in output directory
-# OUTPUT_LIBNAME  == name of output library
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-        
-!IF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Release"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" OUTPUT_LIBNAME_EXPORTS /FD /c
-# ADD CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL"  /FD /c
-# ADD CPP BUILD_INCLUDES_RELEASE EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELEASE
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELEASE /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELEASE
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /machine:I386 /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
-CM_MULTILINE_OPTIONS_RELEASE
-
-CMAKE_CUSTOM_RULE_CODE_RELEASE
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Debug"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" OUTPUT_LIBNAME_EXPORTS /FD /c
-# ADD CPP /nologo /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL"  /FD /c
-# ADD CPP BUILD_INCLUDES_DEBUG EXTRA_DEFINES  OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_DEBUG
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC BUILD_INCLUDES_DEBUG /l 0x409 /d "_DEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_DEBUG
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /debug /machine:I386 /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" /pdbtype:sept TARGET_IMPLIB_FLAG_DEBUG
-CM_MULTILINE_OPTIONS_DEBUG
-
-CMAKE_CUSTOM_RULE_CODE_DEBUG
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 MinSizeRel"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "MinSizeRel"
-# PROP BASE Intermediate_Dir "MinSizeRel"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
-# PROP Intermediate_Dir "MinSizeRel"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32"  /D "_WINDOWS" /D "_USRDLL" /FD /c  OUTPUT_LIBNAME_EXPORTS
-# SUBTRACT BASE CPP /YX
-# ADD CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL"  /FD /c
-# ADD CPP BUILD_INCLUDES_MINSIZEREL EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_MINSIZEREL /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_MINSIZEREL
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32  /nologo /dll /machine:I386 
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /machine:I386 /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
-CM_MULTILINE_OPTIONS_MINSIZEREL
-
-CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "RelWithDebInfo"
-# PROP BASE Intermediate_Dir "RelWithDebInfo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG         
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
-# PROP Intermediate_Dir "RelWithDebInfo"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" OUTPUT_LIBNAME_EXPORTS /FD /c
-# ADD CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL"  /FD /c
-# ADD CPP BUILD_INCLUDES_RELWITHDEBINFO EXTRA_DEFINES  OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELWITHDEBINFO /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELWITHDEBINFO
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /dll /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll TARGET_VERSION_FLAG /debug /machine:I386 /pdbtype:sept /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
-CM_MULTILINE_OPTIONS_RELWITHDEBINFO
-
-CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OUTPUT_LIBNAME - Win32 Release"
-# Name "OUTPUT_LIBNAME - Win32 Debug"
-# Name "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# Name "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
diff --git a/Templates/EXEFooter.dsptemplate b/Templates/EXEFooter.dsptemplate
deleted file mode 100644
index 0d0682a..0000000
--- a/Templates/EXEFooter.dsptemplate
+++ /dev/null
@@ -1,4 +0,0 @@
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/Templates/EXEHeader.dsptemplate b/Templates/EXEHeader.dsptemplate
deleted file mode 100644
index 3a6d2fe..0000000
--- a/Templates/EXEHeader.dsptemplate
+++ /dev/null
@@ -1,183 +0,0 @@
-# Microsoft Developer Studio Project File - Name="pcbuilder" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# CM DSP Header file
-# This file is read by the build system of cm, and is used as the top part of
-# a microsoft project dsp header file
-# IF this is in a dsp file, then it is not the header, but has
-# already been used, so do not edit here...
-
-# variables to REPLACE
-# 
-# BUILD_INCLUDES == include path
-# OUTPUT_DIRECTORY == override in output directory
-# EXTRA_DEFINES == compiler defines
-# OUTPUT_LIBNAME  == name of output library
-# CM_LIBRARIES == libraries linked in 
-# TARGTYPE "Win32 (x86) Application" 0x0103
-
-CFG=OUTPUT_LIBNAME - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak" CFG="OUTPUT_LIBNAME - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OUTPUT_LIBNAME - Win32 MinSizeRel" (based on "Win32 (x86) Application")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "OUTPUT_LIBNAME - Win32 RelWithDebInfo" (based on "Win32 (x86) Application")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Release"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo  /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c
-# ADD CPP /nologo  /D "WIN32"  /D "NDEBUG" /D "_CONSOLE" /FD /c
-# ADD CPP BUILD_INCLUDES_RELEASE EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELEASE
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELEASE /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELEASE
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32  /nologo /subsystem:console /machine:I386 /IGNORE:4089
-# ADD LINK32  /nologo /subsystem:console /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELEASE\OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
-CM_MULTILINE_OPTIONS_RELEASE
-
-CMAKE_CUSTOM_RULE_CODE_RELEASE
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Debug"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP   /D "WIN32" /D "_DEBUG" /D "_CONSOLE"  /FD /GZ /c
-# ADD CPP /nologo  /D "WIN32"  /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c
-# ADD CPP BUILD_INCLUDES_DEBUG EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_DEBUG
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC BUILD_INCLUDES_DEBUG /l 0x409 /d "_DEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_DEBUG
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32  /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /IGNORE:4089
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_DEBUG\OUTPUT_NAME_DEBUG" TARGET_IMPLIB_FLAG_DEBUG
-CM_MULTILINE_OPTIONS_DEBUG
-
-CMAKE_CUSTOM_RULE_CODE_DEBUG
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "MinSizeRel"
-# PROP BASE Intermediate_Dir "MinSizeRel"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
-# PROP Intermediate_Dir "MinSizeRel"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo  /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c
-# ADD CPP /nologo  /D "WIN32" BUILD_INCLUDES_MINSIZEREL EXTRA_DEFINES /D "NDEBUG" /D "_CONSOLE"  /FD /c
-# ADD CPP BUILD_INCLUDES_MINSIZEREL EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_MINSIZEREL /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_MINSIZEREL
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 /IGNORE:4089
-# ADD LINK32 /nologo /subsystem:console /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_MINSIZEREL\OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
-CM_MULTILINE_OPTIONS_MINSIZEREL
-
-CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "RelWithDebInfo"
-# PROP BASE Intermediate_Dir "RelWithDebInfo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
-# PROP Intermediate_Dir "RelWithDebInfo"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo  /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c
-# ADD CPP /nologo  /D "WIN32"  /D "NDEBUG" /D "_CONSOLE" /FD /c
-# ADD CPP BUILD_INCLUDES_RELWITHDEBINFO EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELWITHDEBINFO /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELWITHDEBINFO
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /IGNORE:4089
-# ADD LINK32  /nologo /subsystem:console /debug /machine:I386 /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO\OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
-CM_MULTILINE_OPTIONS_RELWITHDEBINFO
-
-CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OUTPUT_LIBNAME - Win32 Release"
-# Name "OUTPUT_LIBNAME - Win32 Debug"
-# Name "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# Name "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
diff --git a/Templates/EXEWinHeader.dsptemplate b/Templates/EXEWinHeader.dsptemplate
deleted file mode 100644
index 350e3ea..0000000
--- a/Templates/EXEWinHeader.dsptemplate
+++ /dev/null
@@ -1,187 +0,0 @@
-# Microsoft Developer Studio Project File - Name="pcbuilder" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# CM DSP Header file
-# This file is read by the build system of cm, and is used as the top part of
-# a microsoft project dsp header file
-# IF this is in a dsp file, then it is not the header, but has
-# already been used, so do not edit here...
-
-# variables to REPLACE
-# 
-# BUILD_INCLUDES == include path
-# OUTPUT_DIRECTORY == override in output directory
-# EXTRA_DEFINES == compiler defines
-# OUTPUT_LIBNAME  == name of output library
-# CM_LIBRARIES == libraries linked in 
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=OUTPUT_LIBNAME - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak" CFG="OUTPUT_LIBNAME - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OUTPUT_LIBNAME - Win32 MinSizeRel" (based on "Win32 (x86) Application")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "OUTPUT_LIBNAME - Win32 RelWithDebInfo" (based on "Win32 (x86) Application")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Release"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP BUILD_INCLUDES_RELEASE EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELEASE
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELEASE /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELEASE
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386  /IGNORE:4089
-# ADD LINK32  /nologo /subsystem:windows /machine:I386  /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELEASE\OUTPUT_NAME_RELEASE" TARGET_IMPLIB_FLAG_RELEASE
-CM_MULTILINE_OPTIONS_RELEASE
-
-CMAKE_CUSTOM_RULE_CODE_RELEASE
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Debug"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP  /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo  /D "WIN32"  /D "_DEBUG" /D "_WINDOWS" /FD /GZ /c
-# ADD CPP BUILD_INCLUDES_DEBUG EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_DEBUG
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC BUILD_INCLUDES_DEBUG /l 0x409 /d "_DEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_DEBUG
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /IGNORE:4089
-# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_DEBUG\OUTPUT_NAME_DEBUG" TARGET_IMPLIB_FLAG_DEBUG
-CM_MULTILINE_OPTIONS_DEBUG
-
-CMAKE_CUSTOM_RULE_CODE_DEBUG
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "MinSizeRel"
-# PROP BASE Intermediate_Dir "MinSizeRel"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
-# PROP Intermediate_Dir "MinSizeRel"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo  /D "WIN32"  /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP BUILD_INCLUDES_MINSIZEREL EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_MINSIZEREL /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_MINSIZEREL
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 /pdbtype:sept /IGNORE:4089
-# ADD LINK32 /nologo /subsystem:windows  /machine:I386 /pdbtype:sept /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_MINSIZEREL\OUTPUT_NAME_MINSIZEREL" TARGET_IMPLIB_FLAG_MINSIZEREL
-CM_MULTILINE_OPTIONS_MINSIZEREL
-
-CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "RelWithDebInfo"
-# PROP BASE Intermediate_Dir "RelWithDebInfo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
-# PROP Intermediate_Dir "RelWithDebInfo"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
-# ADD CPP BUILD_INCLUDES_RELWITHDEBINFO EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELWITHDEBINFO /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELWITHDEBINFO
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386  /IGNORE:4089
-# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386  /IGNORE:4089 TARGET_VERSION_FLAG
-# ADD LINK32 /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO\OUTPUT_NAME_RELWITHDEBINFO" TARGET_IMPLIB_FLAG_RELWITHDEBINFO
-CM_MULTILINE_OPTIONS_RELWITHDEBINFO
-
-CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OUTPUT_LIBNAME - Win32 Release"
-# Name "OUTPUT_LIBNAME - Win32 Debug"
-# Name "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# Name "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
diff --git a/Templates/UtilityFooter.dsptemplate b/Templates/UtilityFooter.dsptemplate
deleted file mode 100644
index 941fb44..0000000
--- a/Templates/UtilityFooter.dsptemplate
+++ /dev/null
@@ -1,2 +0,0 @@
-# End Target
-# End Project
diff --git a/Templates/UtilityHeader.dsptemplate b/Templates/UtilityHeader.dsptemplate
deleted file mode 100644
index 509f597..0000000
--- a/Templates/UtilityHeader.dsptemplate
+++ /dev/null
@@ -1,95 +0,0 @@
-# Microsoft Developer Studio Project File - Name="OUTPUT_LIBNAME" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Generic Project" 0x010a
-
-CFG=OUTPUT_LIBNAME - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak" CFG="OUTPUT_LIBNAME - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OUTPUT_LIBNAME - Win32 MinSizeRel" (based on "Win32 (x86) Generic Project")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Release" (based on "Win32 (x86) Generic Project")
-!MESSAGE "OUTPUT_LIBNAME - Win32 RelWithDebInfo" (based on "Win32 (x86) Generic Project")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Debug" (based on "Win32 (x86) Generic Project")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-MTL=midl.exe
-
-!IF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-
-CMAKE_CUSTOM_RULE_CODE_RELEASE
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-
-CMAKE_CUSTOM_RULE_CODE_DEBUG
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 MinSizeRel"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "MinSizeRel"
-# PROP BASE Intermediate_Dir "MinSizeRel"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Intermediate_Dir "MinSizeRel"
-# PROP Target_Dir ""
-
-CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "RelWithDebInfo"
-# PROP BASE Intermediate_Dir "RelWithDebInfo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Intermediate_Dir "RelWithDebInfo"
-# PROP Target_Dir ""
-
-CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OUTPUT_LIBNAME - Win32 Release"
-# Name "OUTPUT_LIBNAME - Win32 Debug"
-# Name "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# Name "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
diff --git a/Templates/staticLibFooter.dsptemplate b/Templates/staticLibFooter.dsptemplate
deleted file mode 100644
index 0d0682a..0000000
--- a/Templates/staticLibFooter.dsptemplate
+++ /dev/null
@@ -1,4 +0,0 @@
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/Templates/staticLibHeader.dsptemplate b/Templates/staticLibHeader.dsptemplate
deleted file mode 100644
index a8892e1..0000000
--- a/Templates/staticLibHeader.dsptemplate
+++ /dev/null
@@ -1,173 +0,0 @@
-# Microsoft Developer Studio Project File - Name="OUTPUT_LIBNAME" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# CMAKE DSP Header file
-# This file is read by the CMAKE, and is used as the top part of
-# a microsoft project dsp header file
-# IF this is in a dsp file, then it is not the header, but has
-# already been used, so do not edit in that case.
-
-# variables to REPLACE
-# 
-# BUILD_INCLUDES == include path
-# EXTRA_DEFINES == compiler defines
-# OUTPUT_DIRECTORY == override in output directory
-# OUTPUT_LIBNAME  == name of output library
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=OUTPUT_LIBNAME - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "OUTPUT_LIBNAME.mak" CFG="OUTPUT_LIBNAME - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "OUTPUT_LIBNAME - Win32 MinSizeRel" (based on "Win32 (x86) Static Library")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "OUTPUT_LIBNAME - Win32 RelWithDebInfo" (based on "Win32 (x86) Static Library")
-!MESSAGE "OUTPUT_LIBNAME - Win32 Debug" (based on "Win32 (x86) Static Library")
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Release"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELEASE"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_LIB"  /FD /c
-# ADD CPP /nologo /D "NDEBUG" /D "WIN32" /D "_LIB"  /FD /c
-# ADD CPP BUILD_INCLUDES_RELEASE EXTRA_DEFINES
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELEASE
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELEASE /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELEASE
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELEASE/OUTPUT_NAME_RELEASE" CM_STATIC_LIB_ARGS_RELEASE
-
-CMAKE_CUSTOM_RULE_CODE_RELEASE
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 Debug"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "OUTPUT_DIRECTORY_DEBUG"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "_DEBUG" /D "_LIB"  /FD /c
-# ADD CPP /nologo /D "_DEBUG" /D "WIN32" /D "_LIB"  /FD /GZ /c
-# ADD CPP BUILD_INCLUDES_DEBUG EXTRA_DEFINES
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_DEBUG
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC BUILD_INCLUDES_DEBUG /l 0x409 /d "_DEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_DEBUG
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_DEBUG/OUTPUT_NAME_DEBUG" CM_STATIC_LIB_ARGS_DEBUG
-
-CMAKE_CUSTOM_RULE_CODE_DEBUG
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 MinSizeRel"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "MinSizeRel"
-# PROP BASE Intermediate_Dir "MinSizeRel"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_MINSIZEREL"
-# PROP Intermediate_Dir "MinSizeRel"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_ATL_DLL" /FD /c
-# ADD CPP /nologo /D "NDEBUG" /D "_ATL_DLL"  /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
-# ADD CPP BUILD_INCLUDES_MINSIZEREL EXTRA_DEFINES
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_MINSIZEREL /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_MINSIZEREL
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_MINSIZEREL/OUTPUT_NAME_MINSIZEREL" CM_STATIC_LIB_ARGS_MINSIZEREL
-
-CMAKE_CUSTOM_RULE_CODE_MINSIZEREL
-
-!ELSEIF  "$(CFG)" == "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
-
-# PROP BASE Use_MFC CMAKE_MFC_FLAG
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "RelWithDebInfo"
-# PROP BASE Intermediate_Dir "RelWithDebInfo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC CMAKE_MFC_FLAG
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "OUTPUT_DIRECTORY_RELWITHDEBINFO"
-# PROP Intermediate_Dir "RelWithDebInfo"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_LIB"  /FD /c
-# ADD CPP /nologo /D "NDEBUG" /D "WIN32" /D "_LIB"  /FD /c
-# ADD CPP BUILD_INCLUDES_RELWITHDEBINFO EXTRA_DEFINES
-# ADD CPP CMAKE_CXX_FLAGS
-# ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC BUILD_INCLUDES_RELWITHDEBINFO /l 0x409 /d "NDEBUG"
-# ADD RSC COMPILE_DEFINITIONS
-# ADD RSC COMPILE_DEFINITIONS_RELWITHDEBINFO
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"OUTPUT_DIRECTORY_RELWITHDEBINFO/OUTPUT_NAME_RELWITHDEBINFO" CM_STATIC_LIB_ARGS_RELWITHDEBINFO
-
-CMAKE_CUSTOM_RULE_CODE_RELWITHDEBINFO
-
-!ENDIF 
-
-# Begin Target
-
-# Name "OUTPUT_LIBNAME - Win32 Release"
-# Name "OUTPUT_LIBNAME - Win32 Debug"
-# Name "OUTPUT_LIBNAME - Win32 MinSizeRel"
-# Name "OUTPUT_LIBNAME - Win32 RelWithDebInfo"
-
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index e1d8966..47ccbdc 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 2.8.11)
+cmake_policy(SET CMP0054 NEW)
 project(AliasTarget)
 
 set(CMAKE_CXX_STANDARD 98)
@@ -10,6 +11,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
 endif ()
 
+# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+  set(CMAKE_CXX_STANDARD 11)
+endif()
+
 add_library(foo SHARED empty.cpp)
 add_library(PREFIX::Foo ALIAS foo)
 add_library(Another::Alias ALIAS foo)
diff --git a/Tests/AliasTarget/bat.cpp b/Tests/AliasTarget/bat.cpp
index 1063c21..cb76bfe 100644
--- a/Tests/AliasTarget/bat.cpp
+++ b/Tests/AliasTarget/bat.cpp
@@ -22,7 +22,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int bar()
+  int bar()
 {
   return 0;
 }
diff --git a/Tests/AliasTarget/commandgenerator.cpp b/Tests/AliasTarget/commandgenerator.cpp
index 23560a4..aaab014 100644
--- a/Tests/AliasTarget/commandgenerator.cpp
+++ b/Tests/AliasTarget/commandgenerator.cpp
@@ -3,7 +3,7 @@
 
 #include "object.h"
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   std::fstream fout;
   fout.open("commandoutput.h", std::ios::out);
diff --git a/Tests/AliasTarget/empty.cpp b/Tests/AliasTarget/empty.cpp
index b19427a..15f9ff5 100644
--- a/Tests/AliasTarget/empty.cpp
+++ b/Tests/AliasTarget/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int main(void)
+  int main(void)
 {
   return 0;
 }
diff --git a/Tests/AliasTarget/object.h b/Tests/AliasTarget/object.h
index e935f14..d33551c 100644
--- a/Tests/AliasTarget/object.h
+++ b/Tests/AliasTarget/object.h
@@ -1,4 +1,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int object(void);
+  int object(void);
diff --git a/Tests/AliasTarget/subdir/empty.cpp b/Tests/AliasTarget/subdir/empty.cpp
index b19427a..15f9ff5 100644
--- a/Tests/AliasTarget/subdir/empty.cpp
+++ b/Tests/AliasTarget/subdir/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int main(void)
+  int main(void)
 {
   return 0;
 }
diff --git a/Tests/AliasTarget/targetgenerator.cpp b/Tests/AliasTarget/targetgenerator.cpp
index 3362414..b3e6ee2 100644
--- a/Tests/AliasTarget/targetgenerator.cpp
+++ b/Tests/AliasTarget/targetgenerator.cpp
@@ -1,7 +1,7 @@
 
 #include <fstream>
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   std::fstream fout;
   fout.open("targetoutput.h", std::ios::out);
diff --git a/Tests/Architecture/bar.c b/Tests/Architecture/bar.c
index 923c89c..37946c7 100644
--- a/Tests/Architecture/bar.c
+++ b/Tests/Architecture/bar.c
@@ -1,2 +1,5 @@
 extern int foo(void);
-int main() { return foo(); }
+int main()
+{
+  return foo();
+}
diff --git a/Tests/Architecture/foo.c b/Tests/Architecture/foo.c
index e35694b..c83d856 100644
--- a/Tests/Architecture/foo.c
+++ b/Tests/Architecture/foo.c
@@ -1 +1,4 @@
-int foo(void) { return 0; }
+int foo(void)
+{
+  return 0;
+}
diff --git a/Tests/Assembler/main.c b/Tests/Assembler/main.c
index 95de0b5..84a54d6 100644
--- a/Tests/Assembler/main.c
+++ b/Tests/Assembler/main.c
@@ -1,11 +1,13 @@
 #include <stdio.h>
 
 #ifdef __CLASSIC_C__
-int main(){
+int main()
+{
   int argc;
-  char*argv[];
+  char* argv[];
 #else
-int main(int argc, char*argv[]){
+int main(int argc, char* argv[])
+{
 #endif
   printf("hello assembler world, %d arguments  given\n", argc);
   return 0;
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 36987de..9b48b14 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -42,7 +42,7 @@ list(APPEND _cmake_options "-DTEST_LINK_DEPENDS=${TEST_LINK_DEPENDS}")
 
 list(APPEND _cmake_options "-DCMAKE_FORCE_DEPFILES=1")
 
-if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^6789]|[6789][0-9])")
+if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^789]|[789][0-9])")
   set(TEST_MULTI3 1)
   list(APPEND _cmake_options "-DTEST_MULTI3=1")
 endif()
@@ -304,9 +304,6 @@ message("Run result: ${runResult} Output: \"${out}\"")
 
 if("${out}" STREQUAL "HEADER_STRING: ninja changed ")
   message("Worked!")
-elseif(CMAKE_GENERATOR STREQUAL "Visual Studio 6")
-  # Tolerate failure because VS 6 does not seem to recompile ninjadep.cpp
-  # when the "dir/header.h" it includes changes.
 else()
   message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n"
     " expected [HEADER_STRING: ninja changed]")
diff --git a/Tests/BuildDepends/Project/bar.cxx b/Tests/BuildDepends/Project/bar.cxx
index dadf93d..ec7aa65 100644
--- a/Tests/BuildDepends/Project/bar.cxx
+++ b/Tests/BuildDepends/Project/bar.cxx
@@ -1,16 +1,15 @@
+#include <noregen.h>
+#include <regen.h>
 #include <stdio.h>
 #include <string.h>
-#include <regen.h>
-#include <noregen.h>
 
 int main(int argc, char** argv)
 {
   /* Make sure the noregen header was not regenerated.  */
-  if(strcmp("foo", noregen_string) != 0)
-    {
+  if (strcmp("foo", noregen_string) != 0) {
     printf("FAILED: noregen.h was regenerated!\n");
     return 1;
-    }
+  }
 
   /* Print out the string that should have been regenerated.  */
   printf("%s\n", regen_string);
diff --git a/Tests/BuildDepends/Project/generator.cxx b/Tests/BuildDepends/Project/generator.cxx
index 92a122d..5a83a7f 100644
--- a/Tests/BuildDepends/Project/generator.cxx
+++ b/Tests/BuildDepends/Project/generator.cxx
@@ -4,21 +4,16 @@ extern const char* foo();
 
 int main(int argc, const char* argv[])
 {
-  if(argc < 3)
-    {
+  if (argc < 3) {
     fprintf(stderr, "Must specify output file and symbol prefix!");
     return 1;
-    }
-  if(FILE* fout = fopen(argv[1], "w"))
-    {
-    fprintf(fout, "static const char* %s_string = \"%s\";\n", argv[2],
-            foo());
+  }
+  if (FILE* fout = fopen(argv[1], "w")) {
+    fprintf(fout, "static const char* %s_string = \"%s\";\n", argv[2], foo());
     fclose(fout);
-    }
-  else
-    {
+  } else {
     fprintf(stderr, "Could not open output file \"%s\"", argv[1]);
     return 1;
-    }
+  }
   return 0;
 }
diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_exe.c b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c
index e9113a2..cfaf051 100644
--- a/Tests/BuildDepends/Project/link_depends_no_shared_exe.c
+++ b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c
@@ -2,7 +2,7 @@
 #ifdef _WIN32
 __declspec(dllimport)
 #endif
-int link_depends_no_shared_lib(void);
+  int link_depends_no_shared_lib(void);
 int main()
 {
   return link_depends_no_shared_lib() + link_depends_no_shared_exe_value;
diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_lib.c b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c
index d226289..d66c636 100644
--- a/Tests/BuildDepends/Project/link_depends_no_shared_lib.c
+++ b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c
@@ -2,7 +2,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int link_depends_no_shared_lib(void)
+  int link_depends_no_shared_lib(void)
 {
   return link_depends_no_shared_lib_value;
 }
diff --git a/Tests/BuildDepends/Project/ninjadep.cpp b/Tests/BuildDepends/Project/ninjadep.cpp
index 8d61336..e794448 100644
--- a/Tests/BuildDepends/Project/ninjadep.cpp
+++ b/Tests/BuildDepends/Project/ninjadep.cpp
@@ -1,6 +1,7 @@
-#include <stdio.h>
 #include "dir/header.h"
+#include <stdio.h>
 
-int main() {
+int main()
+{
   printf("HEADER_STRING: %s\n", HEADER_STRING);
 }
diff --git a/Tests/BuildDepends/Project/object_depends.cxx b/Tests/BuildDepends/Project/object_depends.cxx
index 76e8197..f8b643a 100644
--- a/Tests/BuildDepends/Project/object_depends.cxx
+++ b/Tests/BuildDepends/Project/object_depends.cxx
@@ -1 +1,4 @@
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/BuildDepends/Project/zot.cxx b/Tests/BuildDepends/Project/zot.cxx
index 775fd3b..faee7d3 100644
--- a/Tests/BuildDepends/Project/zot.cxx
+++ b/Tests/BuildDepends/Project/zot.cxx
@@ -1,14 +1,14 @@
+#include <stdio.h>
 #include <zot.hxx>
 #include <zot_custom.hxx>
-#include <stdio.h>
 
 const char* zot_macro_dir_f();
 const char* zot_macro_tgt_f();
 
 int main()
 {
-  printf("[%s] [%s] [%s] [%s]\n", zot, zot_custom,
-         zot_macro_dir_f(), zot_macro_tgt_f());
+  printf("[%s] [%s] [%s] [%s]\n", zot, zot_custom, zot_macro_dir_f(),
+         zot_macro_tgt_f());
   fflush(stdout);
   return 0;
 }
diff --git a/Tests/BundleGeneratorTest/Executable.cxx b/Tests/BundleGeneratorTest/Executable.cxx
index 8107f78..3d7e0d7 100644
--- a/Tests/BundleGeneratorTest/Executable.cxx
+++ b/Tests/BundleGeneratorTest/Executable.cxx
@@ -5,4 +5,3 @@ int main(int argc, char* argv[])
   print_message("Howdy, World!\n");
   return 0;
 }
-
diff --git a/Tests/BundleGeneratorTest/Library.cxx b/Tests/BundleGeneratorTest/Library.cxx
index 1403c68..c4f40c4 100644
--- a/Tests/BundleGeneratorTest/Library.cxx
+++ b/Tests/BundleGeneratorTest/Library.cxx
@@ -4,4 +4,3 @@ void print_message(const char* const Message)
 {
   std::cout << Message;
 }
-
diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx
index 37bc178..9ae802f 100644
--- a/Tests/BundleTest/BundleLib.cxx
+++ b/Tests/BundleTest/BundleLib.cxx
@@ -1,6 +1,6 @@
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <CoreFoundation/CoreFoundation.h>
@@ -8,13 +8,12 @@
 int fileExists(char* filename)
 {
 #ifndef R_OK
-# define R_OK 04
+#define R_OK 04
 #endif
-  if ( access(filename, R_OK) != 0 )
-    {
+  if (access(filename, R_OK) != 0) {
     printf("Cannot find file: %s\n", filename);
     return 0;
-    }
+  }
   return 1;
 }
 
@@ -28,18 +27,15 @@ int findBundleFile(char* exec, const char* file)
   printf("Process executable name: %s\n", exec);
 
   // Remove the executable name and directory name
-  for ( cc = strlen(nexec)-1; cc > 0; cc -- )
-    {
-    if ( nexec[cc] == '/' )
-      {
+  for (cc = strlen(nexec) - 1; cc > 0; cc--) {
+    if (nexec[cc] == '/') {
       nexec[cc] = 0;
-      if ( cnt == 1 )
-        {
+      if (cnt == 1) {
         break;
-        }
-      cnt ++;
       }
+      cnt++;
     }
+  }
   printf("Process executable path: %s\n", nexec);
   sprintf(fpath, "%s/%s", nexec, file);
   printf("Check for file: %s\n", fpath);
@@ -49,22 +45,19 @@ int findBundleFile(char* exec, const char* file)
   return res;
 }
 
-int foo(char *exec)
+int foo(char* exec)
 {
   // Call a CoreFoundation function...
   //
   CFBundleRef br = CFBundleGetMainBundle();
-  (void) br;
+  (void)br;
 
   int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist");
   int res2 = findBundleFile(exec, "MacOS/SomeRandomFile.txt");
   int res3 = findBundleFile(exec, "MacOS/README.rst");
-  if ( !res1 ||
-    !res2 ||
-    !res3 )
-    {
+  if (!res1 || !res2 || !res3) {
     return 1;
-    }
+  }
 
   return 0;
 }
diff --git a/Tests/BundleTest/BundleTest.cxx b/Tests/BundleTest/BundleTest.cxx
index a66d601..a5e8f59 100644
--- a/Tests/BundleTest/BundleTest.cxx
+++ b/Tests/BundleTest/BundleTest.cxx
@@ -8,13 +8,15 @@ int main(int argc, char* argv[])
 {
   printf("Started with: %d arguments\n", argc);
 
-  // Call a CoreFoundation function... but pull in the link dependency on "-framework
-  // CoreFoundation" via CMake's dependency chaining mechanism. This code exists to
+  // Call a CoreFoundation function... but pull in the link dependency on
+  // "-framework
+  // CoreFoundation" via CMake's dependency chaining mechanism. This code
+  // exists to
   // verify that the chaining mechanism works with "-framework blah" style
   // link dependencies.
   //
   CFBundleRef br = CFBundleGetMainBundle();
-  (void) br;
+  (void)br;
 
   return foo(argv[0]);
 }
diff --git a/Tests/BundleUtilities/framework.h b/Tests/BundleUtilities/framework.h
index bdd10f0..343317c 100644
--- a/Tests/BundleUtilities/framework.h
+++ b/Tests/BundleUtilities/framework.h
@@ -3,13 +3,13 @@
 #define framework_h
 
 #ifdef WIN32
-# ifdef framework_EXPORTS
-#  define FRAMEWORK_EXPORT __declspec(dllexport)
-# else
-#  define FRAMEWORK_EXPORT __declspec(dllimport)
-# endif
+#ifdef framework_EXPORTS
+#define FRAMEWORK_EXPORT __declspec(dllexport)
 #else
-# define FRAMEWORK_EXPORT
+#define FRAMEWORK_EXPORT __declspec(dllimport)
+#endif
+#else
+#define FRAMEWORK_EXPORT
 #endif
 
 void FRAMEWORK_EXPORT framework();
diff --git a/Tests/BundleUtilities/module.cpp b/Tests/BundleUtilities/module.cpp
index ee1b542..51730d9 100644
--- a/Tests/BundleUtilities/module.cpp
+++ b/Tests/BundleUtilities/module.cpp
@@ -1,7 +1,7 @@
 
 #include "module.h"
-#include "stdio.h"
 #include "shared2.h"
+#include "stdio.h"
 
 void module()
 {
diff --git a/Tests/BundleUtilities/shared.h b/Tests/BundleUtilities/shared.h
index 3588fb8..28904fd 100644
--- a/Tests/BundleUtilities/shared.h
+++ b/Tests/BundleUtilities/shared.h
@@ -3,13 +3,13 @@
 #define shared_h
 
 #ifdef WIN32
-# ifdef shared_EXPORTS
-#  define SHARED_EXPORT __declspec(dllexport)
-# else
-#  define SHARED_EXPORT __declspec(dllimport)
-# endif
+#ifdef shared_EXPORTS
+#define SHARED_EXPORT __declspec(dllexport)
 #else
-# define SHARED_EXPORT
+#define SHARED_EXPORT __declspec(dllimport)
+#endif
+#else
+#define SHARED_EXPORT
 #endif
 
 void SHARED_EXPORT shared();
diff --git a/Tests/BundleUtilities/shared2.h b/Tests/BundleUtilities/shared2.h
index d53546c..3f0015c 100644
--- a/Tests/BundleUtilities/shared2.h
+++ b/Tests/BundleUtilities/shared2.h
@@ -3,13 +3,13 @@
 #define shared2_h
 
 #ifdef WIN32
-# ifdef shared2_EXPORTS
-#  define SHARED2_EXPORT __declspec(dllexport)
-# else
-#  define SHARED2_EXPORT __declspec(dllimport)
-# endif
+#ifdef shared2_EXPORTS
+#define SHARED2_EXPORT __declspec(dllexport)
 #else
-# define SHARED2_EXPORT
+#define SHARED2_EXPORT __declspec(dllimport)
+#endif
+#else
+#define SHARED2_EXPORT
 #endif
 
 void SHARED2_EXPORT shared2();
diff --git a/Tests/BundleUtilities/testbundleutils1.cpp b/Tests/BundleUtilities/testbundleutils1.cpp
index 23d3cbd..3eb6a44 100644
--- a/Tests/BundleUtilities/testbundleutils1.cpp
+++ b/Tests/BundleUtilities/testbundleutils1.cpp
@@ -16,18 +16,15 @@ int main(int, char**)
 
 #if defined(WIN32)
   HANDLE lib = LoadLibraryA("module1.dll");
-  if(!lib)
-  {
+  if (!lib) {
     printf("Failed to open module1\n");
   }
 #else
   void* lib = dlopen("module1.so", RTLD_LAZY);
-  if(!lib)
-  {
+  if (!lib) {
     printf("Failed to open module1\n%s\n", dlerror());
   }
 #endif
 
-
   return lib == 0 ? 1 : 0;
 }
diff --git a/Tests/BundleUtilities/testbundleutils2.cpp b/Tests/BundleUtilities/testbundleutils2.cpp
index 319be89..c39eb52 100644
--- a/Tests/BundleUtilities/testbundleutils2.cpp
+++ b/Tests/BundleUtilities/testbundleutils2.cpp
@@ -16,18 +16,15 @@ int main(int, char**)
 
 #if defined(WIN32)
   HANDLE lib = LoadLibraryA("module2.dll");
-  if(!lib)
-  {
+  if (!lib) {
     printf("Failed to open module2\n");
   }
 #else
   void* lib = dlopen("module2.so", RTLD_LAZY);
-  if(!lib)
-  {
+  if (!lib) {
     printf("Failed to open module2\n%s\n", dlerror());
   }
 #endif
 
-
   return lib == 0 ? 1 : 0;
 }
diff --git a/Tests/BundleUtilities/testbundleutils3.cpp b/Tests/BundleUtilities/testbundleutils3.cpp
index 9df13e9..3bc8a83 100644
--- a/Tests/BundleUtilities/testbundleutils3.cpp
+++ b/Tests/BundleUtilities/testbundleutils3.cpp
@@ -16,18 +16,15 @@ int main(int, char**)
 
 #if defined(WIN32)
   HANDLE lib = LoadLibraryA("module3.dll");
-  if(!lib)
-  {
+  if (!lib) {
     printf("Failed to open module3\n");
   }
 #else
   void* lib = dlopen("module3.so", RTLD_LAZY);
-  if(!lib)
-  {
+  if (!lib) {
     printf("Failed to open module3\n%s\n", dlerror());
   }
 #endif
 
-
   return lib == 0 ? 1 : 0;
 }
diff --git a/Tests/CFBundleTest/Localized.rsrc b/Tests/CFBundleTest/Localized.rsrc
index cbf3523..7973c1f 100644
Binary files a/Tests/CFBundleTest/Localized.rsrc and b/Tests/CFBundleTest/Localized.rsrc differ
diff --git a/Tests/CFBundleTest/np_macmain.cpp b/Tests/CFBundleTest/np_macmain.cpp
index 78004d0..b5a4226 100644
--- a/Tests/CFBundleTest/np_macmain.cpp
+++ b/Tests/CFBundleTest/np_macmain.cpp
@@ -8,7 +8,6 @@
   doing anything useful.
 \***********************************************************/
 
-
 #include <stdio.h>
 
 typedef void (*NPP_ShutdownProcPtr)(void);
@@ -20,9 +19,9 @@ struct NPNetscapeFuncs;
 struct NPPluginFuncs;
 
 extern "C" {
-    NPError NP_Initialize(NPNetscapeFuncs *browserFuncs);
-    NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs);
-    NPError NP_Shutdown(void);
+NPError NP_Initialize(NPNetscapeFuncs* browserFuncs);
+NPError NP_GetEntryPoints(NPPluginFuncs* pluginFuncs);
+NPError NP_Shutdown(void);
 }
 
 #pragma GCC visibility pop
@@ -33,17 +32,17 @@ void initPluginModule()
 
 NPError NP_GetEntryPoints(NPPluginFuncs* pFuncs)
 {
-    printf("NP_GetEntryPoints()\n");
-    return 0;
+  printf("NP_GetEntryPoints()\n");
+  return 0;
 }
 
 NPError NP_Initialize(NPNetscapeFuncs* pFuncs)
 {
-    printf("NP_Initialize()\n");
-    return 0;
+  printf("NP_Initialize()\n");
+  return 0;
 }
 
 NPError NP_Shutdown()
 {
-    return 0;
+  return 0;
 }
diff --git a/Tests/CMakeCommands/add_compile_options/main.cpp b/Tests/CMakeCommands/add_compile_options/main.cpp
index 2bb20ac..1d57021 100644
--- a/Tests/CMakeCommands/add_compile_options/main.cpp
+++ b/Tests/CMakeCommands/add_compile_options/main.cpp
@@ -1,8 +1,8 @@
 
 #ifdef DO_GNU_TESTS
-#  ifndef TEST_OPTION
-#  error Expected TEST_OPTION
-#  endif
+#ifndef TEST_OPTION
+#error Expected TEST_OPTION
+#endif
 #endif
 
 int main(void)
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.c b/Tests/CMakeCommands/target_compile_definitions/consumer.c
index 5796d96..7931a6f 100644
--- a/Tests/CMakeCommands/target_compile_definitions/consumer.c
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.c
@@ -1,23 +1,22 @@
 
 #ifdef TEST_LANG_DEFINES
-  #ifdef CONSUMER_LANG_CXX
-  #error Unexpected CONSUMER_LANG_CXX
-  #endif
+#ifdef CONSUMER_LANG_CXX
+#error Unexpected CONSUMER_LANG_CXX
+#endif
 
-  #ifndef CONSUMER_LANG_C
-  #error Expected CONSUMER_LANG_C
-  #endif
+#ifndef CONSUMER_LANG_C
+#error Expected CONSUMER_LANG_C
+#endif
 
-  #if !LANG_IS_C
-  #error Expected LANG_IS_C
-  #endif
+#if !LANG_IS_C
+#error Expected LANG_IS_C
+#endif
 
-  #if LANG_IS_CXX
-  #error Unexpected LANG_IS_CXX
-  #endif
+#if LANG_IS_CXX
+#error Unexpected LANG_IS_CXX
+#endif
 #endif
 
 void consumer_c()
 {
-
 }
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
index 778f57e..0202c17 100644
--- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
@@ -16,21 +16,24 @@
 #endif
 
 #ifdef TEST_LANG_DEFINES
-  #ifndef CONSUMER_LANG_CXX
-  #error Expected CONSUMER_LANG_CXX
-  #endif
+#ifndef CONSUMER_LANG_CXX
+#error Expected CONSUMER_LANG_CXX
+#endif
 
-  #ifdef CONSUMER_LANG_C
-  #error Unexpected CONSUMER_LANG_C
-  #endif
+#ifdef CONSUMER_LANG_C
+#error Unexpected CONSUMER_LANG_C
+#endif
 
-  #if !LANG_IS_CXX
-  #error Expected LANG_IS_CXX
-  #endif
+#if !LANG_IS_CXX
+#error Expected LANG_IS_CXX
+#endif
 
-  #if LANG_IS_C
-  #error Unexpected LANG_IS_C
-  #endif
+#if LANG_IS_C
+#error Unexpected LANG_IS_C
+#endif
 #endif
 
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_definitions/main.cpp b/Tests/CMakeCommands/target_compile_definitions/main.cpp
index addb33c..bf08b45 100644
--- a/Tests/CMakeCommands/target_compile_definitions/main.cpp
+++ b/Tests/CMakeCommands/target_compile_definitions/main.cpp
@@ -11,4 +11,7 @@
 #error Unexpected MY_INTERFACE_DEFINE
 #endif
 
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/dummy.cpp b/Tests/CMakeCommands/target_compile_features/dummy.cpp
index 341aaaf..e9ad257 100644
--- a/Tests/CMakeCommands/target_compile_features/dummy.cpp
+++ b/Tests/CMakeCommands/target_compile_features/dummy.cpp
@@ -1,5 +1,5 @@
 
-int main(int, char **)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/CMakeCommands/target_compile_features/lib_restrict.c b/Tests/CMakeCommands/target_compile_features/lib_restrict.c
index 049c1b0..2ceec97 100644
--- a/Tests/CMakeCommands/target_compile_features/lib_restrict.c
+++ b/Tests/CMakeCommands/target_compile_features/lib_restrict.c
@@ -1,7 +1,7 @@
 
 #include "lib_restrict.h"
 
-int foo(int * restrict a, int * restrict b)
+int foo(int* restrict a, int* restrict b)
 {
   (void)a;
   (void)b;
diff --git a/Tests/CMakeCommands/target_compile_features/lib_restrict.h b/Tests/CMakeCommands/target_compile_features/lib_restrict.h
index eca22be..2e528b6 100644
--- a/Tests/CMakeCommands/target_compile_features/lib_restrict.h
+++ b/Tests/CMakeCommands/target_compile_features/lib_restrict.h
@@ -2,6 +2,6 @@
 #ifndef LIB_RESTRICT_H
 #define LIB_RESTRICT_H
 
-int foo(int * restrict a, int * restrict b);
+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
index 976068a..541e528 100644
--- a/Tests/CMakeCommands/target_compile_features/lib_user.cpp
+++ b/Tests/CMakeCommands/target_compile_features/lib_user.cpp
@@ -1,7 +1,7 @@
 
 #include "lib_auto_type.h"
 
-int main(int argc, char **argv)
+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
index 831c5eb..76e98c4 100644
--- a/Tests/CMakeCommands/target_compile_features/main.c
+++ b/Tests/CMakeCommands/target_compile_features/main.c
@@ -1,5 +1,5 @@
 
-int foo(int * restrict a, int * restrict b)
+int foo(int* restrict a, int* restrict b)
 {
   (void)a;
   (void)b;
diff --git a/Tests/CMakeCommands/target_compile_features/main.cpp b/Tests/CMakeCommands/target_compile_features/main.cpp
index fe29b04..6f5daee 100644
--- a/Tests/CMakeCommands/target_compile_features/main.cpp
+++ b/Tests/CMakeCommands/target_compile_features/main.cpp
@@ -1,5 +1,5 @@
 
-int main(int, char **)
+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
index d47b847..76c956f 100644
--- a/Tests/CMakeCommands/target_compile_features/restrict_user.c
+++ b/Tests/CMakeCommands/target_compile_features/restrict_user.c
@@ -1,7 +1,7 @@
 
 #include "lib_restrict.h"
 
-int bar(int * restrict a, int * restrict b)
+int bar(int* restrict a, int* restrict b)
 {
   (void)a;
   (void)b;
diff --git a/Tests/CMakeCommands/target_compile_options/consumer.c b/Tests/CMakeCommands/target_compile_options/consumer.c
index 5796d96..7931a6f 100644
--- a/Tests/CMakeCommands/target_compile_options/consumer.c
+++ b/Tests/CMakeCommands/target_compile_options/consumer.c
@@ -1,23 +1,22 @@
 
 #ifdef TEST_LANG_DEFINES
-  #ifdef CONSUMER_LANG_CXX
-  #error Unexpected CONSUMER_LANG_CXX
-  #endif
+#ifdef CONSUMER_LANG_CXX
+#error Unexpected CONSUMER_LANG_CXX
+#endif
 
-  #ifndef CONSUMER_LANG_C
-  #error Expected CONSUMER_LANG_C
-  #endif
+#ifndef CONSUMER_LANG_C
+#error Expected CONSUMER_LANG_C
+#endif
 
-  #if !LANG_IS_C
-  #error Expected LANG_IS_C
-  #endif
+#if !LANG_IS_C
+#error Expected LANG_IS_C
+#endif
 
-  #if LANG_IS_CXX
-  #error Unexpected LANG_IS_CXX
-  #endif
+#if LANG_IS_CXX
+#error Unexpected LANG_IS_CXX
+#endif
 #endif
 
 void consumer_c()
 {
-
 }
diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp
index c5882a5..71a6098 100644
--- a/Tests/CMakeCommands/target_compile_options/consumer.cpp
+++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp
@@ -1,36 +1,39 @@
 
 #ifdef DO_GNU_TESTS
 
-#  ifdef MY_PRIVATE_DEFINE
-#  error Unexpected MY_PRIVATE_DEFINE
-#  endif
+#ifdef MY_PRIVATE_DEFINE
+#error Unexpected MY_PRIVATE_DEFINE
+#endif
 
-#  ifndef MY_PUBLIC_DEFINE
-#  error Expected MY_PUBLIC_DEFINE
-#  endif
+#ifndef MY_PUBLIC_DEFINE
+#error Expected MY_PUBLIC_DEFINE
+#endif
 
-#  ifndef MY_INTERFACE_DEFINE
-#  error Expected MY_INTERFACE_DEFINE
-#  endif
+#ifndef MY_INTERFACE_DEFINE
+#error Expected MY_INTERFACE_DEFINE
+#endif
 
 #endif
 
 #ifdef TEST_LANG_DEFINES
-  #ifndef CONSUMER_LANG_CXX
-  #error Expected CONSUMER_LANG_CXX
-  #endif
+#ifndef CONSUMER_LANG_CXX
+#error Expected CONSUMER_LANG_CXX
+#endif
 
-  #ifdef CONSUMER_LANG_C
-  #error Unexpected CONSUMER_LANG_C
-  #endif
+#ifdef CONSUMER_LANG_C
+#error Unexpected CONSUMER_LANG_C
+#endif
 
-  #if !LANG_IS_CXX
-  #error Expected LANG_IS_CXX
-  #endif
+#if !LANG_IS_CXX
+#error Expected LANG_IS_CXX
+#endif
 
-  #if LANG_IS_C
-  #error Unexpected LANG_IS_C
-  #endif
+#if LANG_IS_C
+#error Unexpected LANG_IS_C
+#endif
 #endif
 
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp
index 961c06d..ac472ae 100644
--- a/Tests/CMakeCommands/target_compile_options/main.cpp
+++ b/Tests/CMakeCommands/target_compile_options/main.cpp
@@ -1,18 +1,21 @@
 
 #ifdef DO_GNU_TESTS
 
-#  ifndef MY_PRIVATE_DEFINE
-#  error Expected MY_PRIVATE_DEFINE
-#  endif
+#ifndef MY_PRIVATE_DEFINE
+#error Expected MY_PRIVATE_DEFINE
+#endif
 
-#  ifndef MY_PUBLIC_DEFINE
-#  error Expected MY_PUBLIC_DEFINE
-#  endif
+#ifndef MY_PUBLIC_DEFINE
+#error Expected MY_PUBLIC_DEFINE
+#endif
 
-#  ifdef MY_INTERFACE_DEFINE
-#  error Unexpected MY_INTERFACE_DEFINE
-#  endif
+#ifdef MY_INTERFACE_DEFINE
+#error Unexpected MY_INTERFACE_DEFINE
+#endif
 
 #endif
 
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_include_directories/consumer.c b/Tests/CMakeCommands/target_include_directories/consumer.c
index 8821f5b..ae88f92 100644
--- a/Tests/CMakeCommands/target_include_directories/consumer.c
+++ b/Tests/CMakeCommands/target_include_directories/consumer.c
@@ -1,10 +1,13 @@
 
 #ifdef TEST_LANG_DEFINES
-  #include "c_only.h"
+#include "c_only.h"
 
-  #ifndef C_ONLY_DEFINE
-  #error Expected C_ONLY_DEFINE
-  #endif
+#ifndef C_ONLY_DEFINE
+#error Expected C_ONLY_DEFINE
+#endif
 #endif
 
-int consumer_c() { return 0; }
+int consumer_c()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp
index 649510c..0f8153b 100644
--- a/Tests/CMakeCommands/target_include_directories/consumer.cpp
+++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp
@@ -1,11 +1,11 @@
 
+#include "consumer.h"
 #include "common.h"
-#include "publicinclude.h"
 #include "interfaceinclude.h"
+#include "publicinclude.h"
 #include "relative_dir.h"
-#include "consumer.h"
 #ifdef TEST_LANG_DEFINES
-  #include "cxx_only.h"
+#include "cxx_only.h"
 #endif
 
 #ifdef PRIVATEINCLUDE_DEFINE
@@ -33,9 +33,12 @@
 #endif
 
 #ifdef TEST_LANG_DEFINES
-  #ifndef CXX_ONLY_DEFINE
-  #error Expected CXX_ONLY_DEFINE
-  #endif
+#ifndef CXX_ONLY_DEFINE
+#error Expected CXX_ONLY_DEFINE
+#endif
 #endif
 
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_include_directories/main.cpp b/Tests/CMakeCommands/target_include_directories/main.cpp
index 8434b97..71298ce 100644
--- a/Tests/CMakeCommands/target_include_directories/main.cpp
+++ b/Tests/CMakeCommands/target_include_directories/main.cpp
@@ -19,4 +19,7 @@
 #error Expected CURE_DEFINE
 #endif
 
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp
index 41dc3ce..80b3c08 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.cpp
@@ -4,7 +4,6 @@
 OnlyPlainLib1::OnlyPlainLib1()
   : result(0)
 {
-
 }
 
 int OnlyPlainLib1::GetResult()
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h
index c0373ce..2bc04ee 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib1.h
@@ -1,9 +1,9 @@
 
 struct
 #ifdef _WIN32
-__declspec(dllexport)
+  __declspec(dllexport)
 #endif
-OnlyPlainLib1
+    OnlyPlainLib1
 {
   OnlyPlainLib1();
 
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h
index 74b18a0..6f18d20 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib2.h
@@ -4,4 +4,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-OnlyPlainLib1 onlyPlainLib2();
+  OnlyPlainLib1 onlyPlainLib2();
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp
index 0fb7b0a..02e9415 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/onlyplainlib_user.cpp
@@ -1,7 +1,7 @@
 
 #include "onlyplainlib2.h"
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   return onlyPlainLib2().GetResult();
 }
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp
index a253c46..d6b3986 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp
@@ -1,2 +1,5 @@
 
-int staticlib1() { return 0; }
+int staticlib1()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h
index 4bbf23f..7d58b10 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h
@@ -1,4 +1,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int staticlib1();
+  int staticlib1();
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp
index 4e38063..bd1a901 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp
@@ -1,2 +1,5 @@
 
-int staticlib2() { return 0; }
+int staticlib2()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h
index a4e07b6..bbfdaa3 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h
@@ -1,4 +1,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int staticlib2();
+  int staticlib2();
diff --git a/Tests/CMakeCommands/target_link_libraries/depC.h b/Tests/CMakeCommands/target_link_libraries/depC.h
index 4d65c9e..01c9e06 100644
--- a/Tests/CMakeCommands/target_link_libraries/depC.h
+++ b/Tests/CMakeCommands/target_link_libraries/depC.h
@@ -8,5 +8,4 @@ struct DEPC_EXPORT DepC
   int foo();
 
   DepA getA();
-
 };
diff --git a/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
index d1321a1..1caa516 100644
--- a/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
@@ -5,7 +5,7 @@
 
 #include "subdirlib.h"
 
-int main(int, char **)
+int main(int, char**)
 {
   DepA a;
   DepB b;
diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp
index d1321a1..1caa516 100644
--- a/Tests/CMakeCommands/target_link_libraries/targetA.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp
@@ -5,7 +5,7 @@
 
 #include "subdirlib.h"
 
-int main(int, char **)
+int main(int, char**)
 {
   DepA a;
   DepB b;
diff --git a/Tests/CMakeCommands/target_link_libraries/targetB.cpp b/Tests/CMakeCommands/target_link_libraries/targetB.cpp
index 0913a57..a08c79a 100644
--- a/Tests/CMakeCommands/target_link_libraries/targetB.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/targetB.cpp
@@ -1,7 +1,7 @@
 
 #include "depD.h"
 
-int main(int, char **)
+int main(int, char**)
 {
   DepD d;
   DepA a = d.getA();
diff --git a/Tests/CMakeCommands/target_link_libraries/targetC.cpp b/Tests/CMakeCommands/target_link_libraries/targetC.cpp
index a4ef636..7c5c9e4 100644
--- a/Tests/CMakeCommands/target_link_libraries/targetC.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/targetC.cpp
@@ -1,14 +1,14 @@
 
 #include "depG.h"
 
-#include "foo.h"
 #include "bar.h"
+#include "foo.h"
 
 #ifndef TEST_DEF
 #error Expected TEST_DEF definition
 #endif
 
-int main(int, char **)
+int main(int, char**)
 {
   DepG g;
 
diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
index c018e08..b141942 100644
--- a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
+++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
@@ -51,7 +51,7 @@ main(int ac, char **av)
       }
 
     if (!logfile.empty())
-      cmSystemTools::Touch(logfile.c_str(), true);
+      cmSystemTools::Touch(logfile, true);
   }
 
   return RETVAL;
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index 26ab223..1cfd381 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -1,24 +1,24 @@
 #include "cmSystemTools.h"
 
-class CompileCommandParser {
+class CompileCommandParser
+{
 public:
-  class CommandType: public std::map<std::string, std::string>
+  class CommandType : public std::map<std::string, std::string>
   {
   public:
     std::string const& at(std::string const& k) const
-      {
+    {
       const_iterator i = this->find(k);
-      if(i != this->end()) { return i->second; }
+      if (i != this->end()) {
+        return i->second;
+      }
       static std::string emptyString;
       return emptyString;
-      }
+    }
   };
   typedef std::vector<CommandType> TranslationUnitsType;
 
-  CompileCommandParser(std::ifstream *input)
-  {
-    this->Input = input;
-  }
+  CompileCommandParser(std::ifstream* input) { this->Input = input; }
 
   void Parse()
   {
@@ -36,54 +36,53 @@ private:
   {
     this->TranslationUnits = TranslationUnitsType();
     ExpectOrDie('[', "at start of compile command file\n");
-    do
-      {
+    do {
       ParseTranslationUnit();
       this->TranslationUnits.push_back(this->Command);
-      } while(Expect(','));
+    } while (Expect(','));
     ExpectOrDie(']', "at end of array");
   }
 
   void ParseTranslationUnit()
   {
     this->Command = CommandType();
-    if(!Expect('{')) return;
-    if(Expect('}')) return;
-    do
-      {
+    if (!Expect('{'))
+      return;
+    if (Expect('}'))
+      return;
+    do {
       ParseString();
       std::string name = this->String;
       ExpectOrDie(':', "between name and value");
       ParseString();
       std::string value = this->String;
       this->Command[name] = value;
-      } while(Expect(','));
+    } while (Expect(','));
     ExpectOrDie('}', "at end of object");
   }
 
   void ParseString()
   {
     this->String = "";
-    if(!Expect('"')) return;
-    while (!Expect('"'))
-      {
+    if (!Expect('"'))
+      return;
+    while (!Expect('"')) {
       Expect('\\');
-      this->String.append(1,C);
+      this->String.append(1, C);
       Next();
-      }
+    }
   }
 
   bool Expect(char c)
   {
-    if(this->C == c)
-      {
+    if (this->C == c) {
       NextNonWhitespace();
       return true;
-      }
+    }
     return false;
   }
 
-  void ExpectOrDie(char c, const std::string & message)
+  void ExpectOrDie(char c, const std::string& message)
   {
     if (!Expect(c))
       ErrorExit(std::string("'") + c + "' expected " + message + ".");
@@ -91,51 +90,54 @@ private:
 
   void NextNonWhitespace()
   {
-    do { Next(); } while (IsWhitespace());
+    do {
+      Next();
+    } while (IsWhitespace());
   }
 
   void Next()
   {
     this->C = char(Input->get());
-    if (this->Input->bad()) ErrorExit("Unexpected end of file.");
+    if (this->Input->bad())
+      ErrorExit("Unexpected end of file.");
   }
 
-  void ErrorExit(const std::string &message) {
+  void ErrorExit(const std::string& message)
+  {
     std::cout << "ERROR: " << message;
     exit(1);
   }
 
   bool IsWhitespace()
   {
-    return (this->C == ' ' || this->C == '\t' ||
-            this->C == '\n' || this->C == '\r');
+    return (this->C == ' ' || this->C == '\t' || this->C == '\n' ||
+            this->C == '\r');
   }
 
   char C;
   TranslationUnitsType TranslationUnits;
   CommandType Command;
   std::string String;
-  std::ifstream *Input;
+  std::ifstream* Input;
 };
 
-int main ()
+int main()
 {
   std::ifstream file("compile_commands.json");
   CompileCommandParser parser(&file);
   parser.Parse();
-  for(CompileCommandParser::TranslationUnitsType::const_iterator
-      it = parser.GetTranslationUnits().begin(),
-      end = parser.GetTranslationUnits().end(); it != end; ++it)
-    {
+  for (CompileCommandParser::TranslationUnitsType::const_iterator
+         it = parser.GetTranslationUnits().begin(),
+         end = parser.GetTranslationUnits().end();
+       it != end; ++it) {
     std::vector<std::string> command;
     cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
-    if (!cmSystemTools::RunSingleCommand(
-            command, 0, 0, 0, it->at("directory").c_str()))
-      {
-      std::cout << "ERROR: Failed to run command \""
-                << command[0] << "\"" << std::endl;
+    if (!cmSystemTools::RunSingleCommand(command, 0, 0, 0,
+                                         it->at("directory").c_str())) {
+      std::cout << "ERROR: Failed to run command \"" << command[0] << "\""
+                << std::endl;
       exit(1);
-      }
     }
+  }
   return 0;
 }
diff --git a/Tests/CMakeLib/testGeneratedFileStream.cxx b/Tests/CMakeLib/testGeneratedFileStream.cxx
index f8ca4af..67dd69a 100644
--- a/Tests/CMakeLib/testGeneratedFileStream.cxx
+++ b/Tests/CMakeLib/testGeneratedFileStream.cxx
@@ -12,10 +12,11 @@
 #include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
 
-#define cmFailed(m1, m2) \
-  std::cout << "FAILED: " << m1 << m2 << "\n"; failed=1
+#define cmFailed(m1, m2)                                                      \
+  std::cout << "FAILED: " << m1 << m2 << "\n";                                \
+  failed = 1
 
-int testGeneratedFileStream(int, char*[])
+int testGeneratedFileStream(int, char* [])
 {
   int failed = 0;
   cmGeneratedFileStream gm;
@@ -39,62 +40,55 @@ int testGeneratedFileStream(int, char*[])
   gm.Open(file4.c_str());
   gm << "This is generated file 4";
   gm.Close();
-  if ( cmSystemTools::FileExists(file1.c_str()) )
-    {
-    if ( cmSystemTools::FileExists(file2.c_str()) )
-      {
-      if ( cmSystemTools::FileExists(file3.c_str()) )
-        {
-        if ( cmSystemTools::FileExists(file4.c_str()) )
-          {
-          if ( cmSystemTools::FileExists(file1tmp.c_str()) )
-            {
-            cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file1tmp.c_str());
-            }
-          else if ( cmSystemTools::FileExists(file2tmp.c_str()) )
-            {
-            cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file2tmp.c_str());
-            }
-          else if ( cmSystemTools::FileExists(file3tmp.c_str()) )
-            {
-            cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file3tmp.c_str());
-            }
-          else if ( cmSystemTools::FileExists(file4tmp.c_str()) )
-            {
-            cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file4tmp.c_str());
-            }
-          else
-            {
+  if (cmSystemTools::FileExists(file1.c_str())) {
+    if (cmSystemTools::FileExists(file2.c_str())) {
+      if (cmSystemTools::FileExists(file3.c_str())) {
+        if (cmSystemTools::FileExists(file4.c_str())) {
+          if (cmSystemTools::FileExists(file1tmp.c_str())) {
+            cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+                     "file is still here: ",
+                     file1tmp.c_str());
+          } else if (cmSystemTools::FileExists(file2tmp.c_str())) {
+            cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+                     "file is still here: ",
+                     file2tmp.c_str());
+          } else if (cmSystemTools::FileExists(file3tmp.c_str())) {
+            cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+                     "file is still here: ",
+                     file3tmp.c_str());
+          } else if (cmSystemTools::FileExists(file4tmp.c_str())) {
+            cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+                     "file is still here: ",
+                     file4tmp.c_str());
+          } else {
             std::cout << "cmGeneratedFileStream works\n";
-            }
           }
-        else
-          {
-          cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file4.c_str());
-          }
-        }
-      else
-        {
-        cmFailed("Something wrong with cmGeneratedFileStream. Found file: ", file3.c_str());
+        } else {
+          cmFailed(
+            "Something wrong with cmGeneratedFileStream. Cannot find file: ",
+            file4.c_str());
         }
+      } else {
+        cmFailed("Something wrong with cmGeneratedFileStream. Found file: ",
+                 file3.c_str());
       }
-    else
-      {
-      cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file2.c_str());
-      }
-    }
-  else
-    {
-    cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file1.c_str());
+    } else {
+      cmFailed(
+        "Something wrong with cmGeneratedFileStream. Cannot find file: ",
+        file2.c_str());
     }
-  cmSystemTools::RemoveFile(file1.c_str());
-  cmSystemTools::RemoveFile(file2.c_str());
-  cmSystemTools::RemoveFile(file3.c_str());
-  cmSystemTools::RemoveFile(file4.c_str());
-  cmSystemTools::RemoveFile(file1tmp.c_str());
-  cmSystemTools::RemoveFile(file2tmp.c_str());
-  cmSystemTools::RemoveFile(file3tmp.c_str());
-  cmSystemTools::RemoveFile(file4tmp.c_str());
+  } else {
+    cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ",
+             file1.c_str());
+  }
+  cmSystemTools::RemoveFile(file1);
+  cmSystemTools::RemoveFile(file2);
+  cmSystemTools::RemoveFile(file3);
+  cmSystemTools::RemoveFile(file4);
+  cmSystemTools::RemoveFile(file1tmp);
+  cmSystemTools::RemoveFile(file2tmp);
+  cmSystemTools::RemoveFile(file3tmp);
+  cmSystemTools::RemoveFile(file4tmp);
 
   return failed;
 }
diff --git a/Tests/CMakeLib/testRST.cxx b/Tests/CMakeLib/testRST.cxx
index 37cb3fa..e5a96c2 100644
--- a/Tests/CMakeLib/testRST.cxx
+++ b/Tests/CMakeLib/testRST.cxx
@@ -13,69 +13,59 @@
 
 #include "cmSystemTools.h"
 
-void reportLine(std::ostream& os, bool ret, std::string line, bool eol)
+void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol)
 {
-  if(ret)
-    {
-    os << "\"" << line << "\" (" << (eol?"with EOL":"without EOL") << ")";
-    }
-  else
-    {
+  if (ret) {
+    os << "\"" << line << "\" (" << (eol ? "with EOL" : "without EOL") << ")";
+  } else {
     os << "EOF";
-    }
+  }
 }
 
 int testRST(int argc, char* argv[])
 {
-  if(argc != 2)
-    {
+  if (argc != 2) {
     std::cerr << "Usage: testRST <dir>" << std::endl;
     return 1;
-    }
+  }
   std::string dir = argv[1];
-  if(dir.empty())
-    {
+  if (dir.empty()) {
     dir = ".";
-    }
+  }
   std::string a_name = "testRST.actual";
   std::string e_name = dir + "/testRST.expect";
 
   // Process the test RST file.
   {
-  std::string fname = dir + "/testRST.rst";
-  std::ofstream fout(a_name.c_str());
-  if(!fout)
-    {
-    std::cerr << "Could not open output " << a_name << std::endl;
-    return 1;
+    std::string fname = dir + "/testRST.rst";
+    std::ofstream fout(a_name.c_str());
+    if (!fout) {
+      std::cerr << "Could not open output " << a_name << std::endl;
+      return 1;
     }
 
-  cmRST r(fout, dir);
-  if(!r.ProcessFile(fname))
-    {
-    std::cerr << "Could not open input " << fname << std::endl;
-    return 1;
+    cmRST r(fout, dir);
+    if (!r.ProcessFile(fname)) {
+      std::cerr << "Could not open input " << fname << std::endl;
+      return 1;
     }
   }
 
   // Compare expected and actual outputs.
   std::ifstream e_fin(e_name.c_str());
   std::ifstream a_fin(a_name.c_str());
-  if(!e_fin)
-    {
+  if (!e_fin) {
     std::cerr << "Could not open input " << e_name << std::endl;
     return 1;
-    }
-  if(!a_fin)
-    {
+  }
+  if (!a_fin) {
     std::cerr << "Could not open input " << a_name << std::endl;
     return 1;
-    }
+  }
   int lineno = 0;
   bool e_ret;
   bool a_ret;
-  do
-    {
+  do {
     std::string e_line;
     std::string a_line;
     bool e_eol;
@@ -83,11 +73,11 @@ int testRST(int argc, char* argv[])
     e_ret = cmSystemTools::GetLineFromStream(e_fin, e_line, &e_eol);
     a_ret = cmSystemTools::GetLineFromStream(a_fin, a_line, &a_eol);
     ++lineno;
-    if(e_ret != a_ret || e_line != a_line || e_eol != a_eol)
-      {
+    if (e_ret != a_ret || e_line != a_line || e_eol != a_eol) {
       a_fin.seekg(0, std::ios::beg);
       std::cerr << "Actual output does not match that expected on line "
-                << lineno << "." << std::endl << "Expected ";
+                << lineno << "." << std::endl
+                << "Expected ";
       reportLine(std::cerr, e_ret, e_line, e_eol);
       std::cerr << " but got ";
       reportLine(std::cerr, a_ret, a_line, a_eol);
@@ -95,7 +85,7 @@ int testRST(int argc, char* argv[])
                 << "Actual output:" << std::endl
                 << a_fin.rdbuf();
       return 1;
-      }
-    } while(e_ret && a_ret);
+    }
+  } while (e_ret && a_ret);
   return 0;
 }
diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx
index 9309ae3..a3846c0 100644
--- a/Tests/CMakeLib/testSystemTools.cxx
+++ b/Tests/CMakeLib/testSystemTools.cxx
@@ -12,22 +12,21 @@
 #include "cmSystemTools.h"
 
 #define cmPassed(m) std::cout << "Passed: " << m << "\n"
-#define cmFailed(m) std::cout << "FAILED: " << m << "\n"; failed=1
+#define cmFailed(m)                                                           \
+  std::cout << "FAILED: " << m << "\n";                                       \
+  failed = 1
 
-int testSystemTools(int, char*[])
+int testSystemTools(int, char* [])
 {
   int failed = 0;
   // ----------------------------------------------------------------------
   // Test cmSystemTools::UpperCase
   std::string str = "abc";
   std::string strupper = "ABC";
-  if(cmSystemTools::UpperCase(str) == strupper)
-    {
+  if (cmSystemTools::UpperCase(str) == strupper) {
     cmPassed("cmSystemTools::UpperCase is working");
-    }
-  else
-    {
+  } else {
     cmFailed("cmSystemTools::UpperCase is working");
-    }
+  }
   return failed;
 }
diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx
index 4ab96cf..1da23fe 100644
--- a/Tests/CMakeLib/testUTF8.cxx
+++ b/Tests/CMakeLib/testUTF8.cxx
@@ -11,16 +11,16 @@
 ============================================================================*/
 #include <cm_utf8.h>
 
-#include <string.h>
 #include <stdio.h>
+#include <string.h>
 
 typedef char test_utf8_char[5];
 
 static void test_utf8_char_print(test_utf8_char const c)
 {
   unsigned char const* d = reinterpret_cast<unsigned char const*>(c);
-  printf("[0x%02X,0x%02X,0x%02X,0x%02X]",
-         (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
+  printf("[0x%02X,0x%02X,0x%02X,0x%02X]", (int)d[0], (int)d[1], (int)d[2],
+         (int)d[3]);
 }
 
 struct test_utf8_entry
@@ -31,33 +31,29 @@ struct test_utf8_entry
 };
 
 static test_utf8_entry const good_entry[] = {
-  {1, "\x20\x00\x00\x00", 0x0020},  /* Space.  */
-  {2, "\xC2\xA9\x00\x00", 0x00A9},  /* Copyright.  */
-  {3, "\xE2\x80\x98\x00", 0x2018},  /* Open-single-quote.  */
-  {3, "\xE2\x80\x99\x00", 0x2019},  /* Close-single-quote.  */
-  {4, "\xF0\xA3\x8E\xB4", 0x233B4}, /* Example from RFC 3629.  */
-  {0, {0,0,0,0,0}, 0}
+  { 1, "\x20\x00\x00\x00", 0x0020 },  /* Space.  */
+  { 2, "\xC2\xA9\x00\x00", 0x00A9 },  /* Copyright.  */
+  { 3, "\xE2\x80\x98\x00", 0x2018 },  /* Open-single-quote.  */
+  { 3, "\xE2\x80\x99\x00", 0x2019 },  /* Close-single-quote.  */
+  { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629.  */
+  { 0, { 0, 0, 0, 0, 0 }, 0 }
 };
 
 static test_utf8_char const bad_chars[] = {
-  "\x80\x00\x00\x00",
-  "\xC0\x00\x00\x00",
-  "\xE0\x00\x00\x00",
-  "\xE0\x80\x80\x00",
-  "\xF0\x80\x80\x80",
-  {0,0,0,0,0}
+  "\x80\x00\x00\x00", "\xC0\x00\x00\x00", "\xE0\x00\x00\x00",
+  "\xE0\x80\x80\x00", "\xF0\x80\x80\x80", { 0, 0, 0, 0, 0 }
 };
 
 static void report_good(bool passed, test_utf8_char const c)
 {
-  printf("%s: decoding good ", passed?"pass":"FAIL");
+  printf("%s: decoding good ", passed ? "pass" : "FAIL");
   test_utf8_char_print(c);
   printf(" (%s) ", c);
 }
 
 static void report_bad(bool passed, test_utf8_char const c)
 {
-  printf("%s: decoding bad  ", passed?"pass":"FAIL");
+  printf("%s: decoding bad  ", passed ? "pass" : "FAIL");
   test_utf8_char_print(c);
   printf(" ");
 }
@@ -65,25 +61,23 @@ static void report_bad(bool passed, test_utf8_char const c)
 static bool decode_good(test_utf8_entry const entry)
 {
   unsigned int uc;
-  if(const char* e = cm_utf8_decode_character(entry.str, entry.str+4, &uc))
-    {
-    int used = static_cast<int>(e-entry.str);
-    if(uc != entry.chr)
-      {
+  if (const char* e =
+        cm_utf8_decode_character(entry.str, entry.str + 4, &uc)) {
+    int used = static_cast<int>(e - entry.str);
+    if (uc != entry.chr) {
       report_good(false, entry.str);
       printf("expected 0x%04X, got 0x%04X\n", entry.chr, uc);
       return false;
-      }
-    if(used != entry.n)
-      {
+    }
+    if (used != entry.n) {
       report_good(false, entry.str);
       printf("had %d bytes, used %d\n", entry.n, used);
       return false;
-      }
+    }
     report_good(true, entry.str);
     printf("got 0x%04X\n", uc);
     return true;
-    }
+  }
   report_good(false, entry.str);
   printf("failed\n");
   return false;
@@ -92,34 +86,29 @@ static bool decode_good(test_utf8_entry const entry)
 static bool decode_bad(test_utf8_char const s)
 {
   unsigned int uc = 0xFFFFu;
-  const char* e = cm_utf8_decode_character(s, s+4, &uc);
-  if(e)
-    {
+  const char* e = cm_utf8_decode_character(s, s + 4, &uc);
+  if (e) {
     report_bad(false, s);
     printf("expected failure, got 0x%04X\n", uc);
     return false;
-    }
+  }
   report_bad(true, s);
   printf("failed as expected\n");
   return true;
 }
 
-int testUTF8(int, char*[])
+int testUTF8(int, char* [])
 {
   int result = 0;
-  for(test_utf8_entry const* e = good_entry; e->n; ++e)
-    {
-    if(!decode_good(*e))
-      {
+  for (test_utf8_entry const* e = good_entry; e->n; ++e) {
+    if (!decode_good(*e)) {
       result = 1;
-      }
     }
-  for(test_utf8_char const* c = bad_chars; (*c)[0]; ++c)
-    {
-    if(!decode_bad(*c))
-      {
+  }
+  for (test_utf8_char const* c = bad_chars; (*c)[0]; ++c) {
+    if (!decode_bad(*c)) {
       result = 1;
-      }
     }
+  }
   return result;
 }
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.cxx b/Tests/CMakeLib/testVisualStudioSlnParser.cxx
index 5007ab8..f8bcfae 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser.cxx
+++ b/Tests/CMakeLib/testVisualStudioSlnParser.cxx
@@ -5,180 +5,152 @@
 
 #include <iostream>
 
-//----------------------------------------------------------------------------
 static bool parsedRight(cmVisualStudioSlnParser& parser,
                         const std::string& file, cmSlnData& data,
                         cmVisualStudioSlnParser::ParseResult expected =
-                        cmVisualStudioSlnParser::ResultOK)
+                          cmVisualStudioSlnParser::ResultOK)
 {
-  if (parser.ParseFile(SOURCE_DIR "/testVisualStudioSlnParser_data/" + file
-                        + "." SLN_EXTENSION,
-                        data, cmVisualStudioSlnParser::DataGroupProjects))
-    {
-    if (expected == cmVisualStudioSlnParser::ResultOK)
-      {
+  if (parser.ParseFile(SOURCE_DIR "/testVisualStudioSlnParser_data/" + file +
+                         "." SLN_EXTENSION,
+                       data, cmVisualStudioSlnParser::DataGroupProjects)) {
+    if (expected == cmVisualStudioSlnParser::ResultOK) {
       return true;
-      }
     }
-  else
-    {
-    if (parser.GetParseResult() == expected)
-      {
+  } else {
+    if (parser.GetParseResult() == expected) {
       return true;
-      }
     }
+  }
   std::cerr << "cmVisualStudioSlnParser mis-parsed " << file
             << "." SLN_EXTENSION << "; expected result " << expected
-            << ", got " << parser.GetParseResult()
-            << std::endl;
+            << ", got " << parser.GetParseResult() << std::endl;
   return false;
 }
 
-//----------------------------------------------------------------------------
-int testVisualStudioSlnParser(int, char*[])
+int testVisualStudioSlnParser(int, char* [])
 {
   cmVisualStudioSlnParser parser;
 
   // Test clean parser
-  if (parser.GetParseResult() != cmVisualStudioSlnParser::ResultOK)
-    {
-    std::cerr << "cmVisualStudioSlnParser initialisation failed"
-              << std::endl;
+  if (parser.GetParseResult() != cmVisualStudioSlnParser::ResultOK) {
+    std::cerr << "cmVisualStudioSlnParser initialisation failed" << std::endl;
     return 1;
-    }
+  }
 
   // Test parsing valid sln
   {
-  cmSlnData data;
-  if (!parsedRight(parser, "valid", data))
-    {
-    return 1;
+    cmSlnData data;
+    if (!parsedRight(parser, "valid", data)) {
+      return 1;
     }
-  const std::vector<cmSlnProjectEntry>& projects = data.GetProjects();
-  const char * const names[] =
-    {
-    "3rdParty", "ALL_BUILD", "CMakeLib", "CMakeLibTests",
-    "CMakePredefinedTargets", "CPackLib", "CTestDashboardTargets", "CTestLib",
-    "Continuous", "Documentation",
-    "Experimental", "INSTALL", "KWSys", "LIBCURL", "Nightly",
-    "NightlyMemoryCheck", "PACKAGE", "RUN_TESTS", "Tests", "Utilities",
-    "Win9xCompat", "ZERO_CHECK", "cmIML_test", "cmake", "cmbzip2", "cmcldeps",
-    "cmcompress", "cmcurl", "cmexpat", "cmlibarchive", "cmsys",
-    "cmsysEncodeExecutable", "cmsysProcessFwd9x", "cmsysTestDynload",
-    "cmsysTestProcess", "cmsysTestSharedForward", "cmsysTestsC",
-    "cmsysTestsCxx", "cmsys_c", "cmw9xcom", "cmzlib", "cpack", "ctest",
-    "documentation", "memcheck_fail", "pseudo_BC", "pseudo_purify",
-    "pseudo_valgrind", "test_clean", "uninstall"
+    const std::vector<cmSlnProjectEntry>& projects = data.GetProjects();
+    const char* const names[] = {
+      "3rdParty", "ALL_BUILD", "CMakeLib", "CMakeLibTests",
+      "CMakePredefinedTargets", "CPackLib", "CTestDashboardTargets",
+      "CTestLib", "Continuous", "Documentation", "Experimental", "INSTALL",
+      "KWSys", "LIBCURL", "Nightly", "NightlyMemoryCheck", "PACKAGE",
+      "RUN_TESTS", "Tests", "Utilities", "Win9xCompat", "ZERO_CHECK",
+      "cmIML_test", "cmake", "cmbzip2", "cmcldeps", "cmcompress", "cmcurl",
+      "cmexpat", "cmlibarchive", "cmsys", "cmsysEncodeExecutable",
+      "cmsysProcessFwd9x", "cmsysTestDynload", "cmsysTestProcess",
+      "cmsysTestSharedForward", "cmsysTestsC", "cmsysTestsCxx", "cmsys_c",
+      "cmw9xcom", "cmzlib", "cpack", "ctest", "documentation", "memcheck_fail",
+      "pseudo_BC", "pseudo_purify", "pseudo_valgrind", "test_clean",
+      "uninstall"
+      /* clang-format needs this comment to break after the opening brace */
     };
-  const size_t expectedProjectCount = sizeof(names) / sizeof(*names);
-  if (projects.size() != expectedProjectCount)
-    {
-    std::cerr << "cmVisualStudioSlnParser returned bad number of "
-              << "projects (" << projects.size() << " instead of "
-              << expectedProjectCount << ')'
-              << std::endl;
-    return 1;
-    }
-  for (size_t idx = 0; idx < expectedProjectCount; ++idx)
-    {
-    if (projects[idx].GetName() != names[idx])
-      {
-      std::cerr << "cmVisualStudioSlnParser returned bad project #"
-                << idx << "; expected \"" << names[idx] << "\", got \""
-                << projects[idx].GetName() << '"'
-                << std::endl;
+    const size_t expectedProjectCount = sizeof(names) / sizeof(*names);
+    if (projects.size() != expectedProjectCount) {
+      std::cerr << "cmVisualStudioSlnParser returned bad number of "
+                << "projects (" << projects.size() << " instead of "
+                << expectedProjectCount << ')' << std::endl;
       return 1;
+    }
+    for (size_t idx = 0; idx < expectedProjectCount; ++idx) {
+      if (projects[idx].GetName() != names[idx]) {
+        std::cerr << "cmVisualStudioSlnParser returned bad project #" << idx
+                  << "; expected \"" << names[idx] << "\", got \""
+                  << projects[idx].GetName() << '"' << std::endl;
+        return 1;
       }
     }
-  if (projects[0].GetRelativePath() != "Utilities\\3rdParty")
-    {
-    std::cerr << "cmVisualStudioSlnParser returned bad relative path of "
-              << "project 3rdParty; expected \"Utilities\\3rdParty\", "
-              << "got \"" << projects[0].GetRelativePath() << '"'
-              << std::endl;
-    return 1;
+    if (projects[0].GetRelativePath() != "Utilities\\3rdParty") {
+      std::cerr << "cmVisualStudioSlnParser returned bad relative path of "
+                << "project 3rdParty; expected \"Utilities\\3rdParty\", "
+                << "got \"" << projects[0].GetRelativePath() << '"'
+                << std::endl;
+      return 1;
     }
-  if (projects[2].GetGUID() != "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}")
-    {
-    std::cerr << "cmVisualStudioSlnParser returned bad relative path of "
-              << "project CMakeLib; expected "
-              << "\"{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}\", "
-              << "got \"" << projects[2].GetGUID() << '"'
-              << std::endl;
-    return 1;
+    if (projects[2].GetGUID() != "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}") {
+      std::cerr << "cmVisualStudioSlnParser returned bad relative path of "
+                << "project CMakeLib; expected "
+                << "\"{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}\", "
+                << "got \"" << projects[2].GetGUID() << '"' << std::endl;
+      return 1;
     }
   }
 
   // Test BOM parsing
   {
-  cmSlnData data;
+    cmSlnData data;
 
-  if (!parsedRight(parser, "bom", data))
-    {
-    return 1;
+    if (!parsedRight(parser, "bom", data)) {
+      return 1;
     }
-  if (!parser.GetParseHadBOM())
-    {
-    std::cerr << "cmVisualStudioSlnParser didn't find BOM in bom."
-              << SLN_EXTENSION
-              << std::endl;
-    return 1;
+    if (!parser.GetParseHadBOM()) {
+      std::cerr << "cmVisualStudioSlnParser didn't find BOM in bom."
+                << SLN_EXTENSION << std::endl;
+      return 1;
     }
 
-  if (!parsedRight(parser, "nobom", data))
-    {
-    return 1;
+    if (!parsedRight(parser, "nobom", data)) {
+      return 1;
     }
-  if (parser.GetParseHadBOM())
-    {
-    std::cerr << "cmVisualStudioSlnParser found BOM in nobom."
-              << SLN_EXTENSION
-              << std::endl;
-    return 1;
+    if (parser.GetParseHadBOM()) {
+      std::cerr << "cmVisualStudioSlnParser found BOM in nobom."
+                << SLN_EXTENSION << std::endl;
+      return 1;
     }
   }
 
   // Test invalid sln
   {
-  {
-  cmSlnData data;
-  if (!parsedRight(parser, "err-nonexistent", data,
-                   cmVisualStudioSlnParser::ResultErrorOpeningInput))
     {
-    return 1;
+      cmSlnData data;
+      if (!parsedRight(parser, "err-nonexistent", data,
+                       cmVisualStudioSlnParser::ResultErrorOpeningInput)) {
+        return 1;
+      }
     }
-  }
-  {
-  cmSlnData data;
-  if (!parsedRight(parser, "err-empty", data,
-                   cmVisualStudioSlnParser::ResultErrorReadingInput))
     {
-    return 1;
+      cmSlnData data;
+      if (!parsedRight(parser, "err-empty", data,
+                       cmVisualStudioSlnParser::ResultErrorReadingInput)) {
+        return 1;
+      }
     }
-  }
-  const char * const files[] =
-    {
-    "header", "projectArgs", "topLevel", "projectContents", "projectSection",
-    "global", "unclosed", "strayQuote", "strayParen", "strayQuote2"
+    const char* const files[] = {
+      "header",         "projectArgs", "topLevel", "projectContents",
+      "projectSection", "global",      "unclosed", "strayQuote",
+      "strayParen",     "strayQuote2"
+      /* clang-format needs this comment to break after the opening brace */
     };
-  for (size_t idx = 0; idx < sizeof(files) / sizeof(files[0]); ++idx)
-    {
-    cmSlnData data;
-    if (!parsedRight(parser, std::string("err-structure-") + files[idx], data,
-                     cmVisualStudioSlnParser::ResultErrorInputStructure))
-      {
-      return 1;
+    for (size_t idx = 0; idx < sizeof(files) / sizeof(files[0]); ++idx) {
+      cmSlnData data;
+      if (!parsedRight(parser, std::string("err-structure-") + files[idx],
+                       data,
+                       cmVisualStudioSlnParser::ResultErrorInputStructure)) {
+        return 1;
       }
     }
-  {
-  cmSlnData data;
-  if (!parsedRight(parser, "err-data", data,
-                   cmVisualStudioSlnParser::ResultErrorInputData))
     {
-    return 1;
+      cmSlnData data;
+      if (!parsedRight(parser, "err-data", data,
+                       cmVisualStudioSlnParser::ResultErrorInputData)) {
+        return 1;
+      }
     }
   }
-  }
 
   // All is well
   return 0;
diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx
index b5219e2..1fd5113 100644
--- a/Tests/CMakeLib/testXMLParser.cxx
+++ b/Tests/CMakeLib/testXMLParser.cxx
@@ -4,14 +4,13 @@
 
 #include <iostream>
 
-int testXMLParser(int, char*[])
+int testXMLParser(int, char* [])
 {
   // TODO: Derive from parser and check attributes.
   cmXMLParser parser;
-  if(!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml"))
-    {
+  if (!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml")) {
     std::cerr << "cmXMLParser failed!" << std::endl;
     return 1;
-    }
+  }
   return 0;
 }
diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx
index 9e4960c..34c38fb 100644
--- a/Tests/CMakeLib/testXMLSafe.cxx
+++ b/Tests/CMakeLib/testXMLSafe.cxx
@@ -20,28 +20,26 @@ struct test_pair
 };
 
 static test_pair const pairs[] = {
-  {"copyright \xC2\xA9", "copyright \xC2\xA9"},
-  {"form-feed \f", "form-feed [NON-XML-CHAR-0xC]"},
-  {"angles <>", "angles <>"},
-  {"ampersand &", "ampersand &"},
-  {"bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]"},
-  {0,0}
+  { "copyright \xC2\xA9", "copyright \xC2\xA9" },
+  { "form-feed \f", "form-feed [NON-XML-CHAR-0xC]" },
+  { "angles <>", "angles <>" },
+  { "ampersand &", "ampersand &" },
+  { "bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]" },
+  { 0, 0 }
 };
 
-int testXMLSafe(int, char*[])
+int testXMLSafe(int, char* [])
 {
   int result = 0;
-  for(test_pair const* p = pairs; p->in; ++p)
-    {
+  for (test_pair const* p = pairs; p->in; ++p) {
     cmXMLSafe xs(p->in);
     std::ostringstream oss;
     oss << xs;
     std::string out = oss.str();
-    if(out != p->out)
-      {
+    if (out != p->out) {
       printf("expected [%s], got [%s]\n", p->out, out.c_str());
       result = 1;
-      }
     }
+  }
   return result;
 }
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 7bb0721..f21e430 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -274,6 +274,9 @@ if(BUILD_TESTING)
   endif()
   if(TEST_RESOURCES)
     ADD_TEST_MACRO(VSResource VSResource)
+    if (CMAKE_GENERATOR MATCHES "Ninja")
+      add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP)
+    endif ()
   endif()
   ADD_TEST_MACRO(MSManifest MSManifest)
   ADD_TEST_MACRO(Simple Simple)
@@ -624,8 +627,8 @@ if(BUILD_TESTING)
   endif()
 
   # test for correct sub-project generation
-  # not implemented in VS 6, VS 7.0, Xcode, or Ninja
-  if(NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
+  # not implemented in VS 7.0, Xcode, or Ninja
+  if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 7$|Xcode|Ninja")
     # run cmake and configure all of SubProject
     # but only build the independent executable car
     add_test(SubProject ${CMAKE_CTEST_COMMAND}
@@ -684,14 +687,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     endif()
   endmacro()
   if(CMAKE_BUILD_NIGHTLY_RELEASES)
-    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWindows
-      dash3win7_release.cmake)
+    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32
+      win32_release.cmake)
+    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64
+      win64_release.cmake)
     ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX
-      dashmacmini5_release.cmake)
+      osx_release.cmake)
     ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux32
-      magrathea_release.cmake)
+      linux32_release.cmake)
     ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux64
       linux64_release.cmake)
+    set_property(TEST CMakeNightlyWin64 PROPERTY DEPENDS CMakeNightlyWin32)
   endif()
 
   # add tests with more complex invocations
@@ -1371,6 +1377,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     add_subdirectory(FindJsonCpp)
   endif()
 
+  if(CMake_TEST_FindLTTngUST)
+    add_subdirectory(FindLTTngUST)
+  endif()
+
   if(CMake_TEST_FindOpenSSL)
     add_subdirectory(FindOpenSSL)
   endif()
@@ -1644,7 +1654,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
 
   if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5
      AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)")
-    set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1})
+    set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx)
     ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -V)
   endif()
 
@@ -1740,7 +1750,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
   if(MSVC)
     ADD_TEST_MACRO(ForceInclude foo)
     ADD_TEST_MACRO(PDBDirectoryAndName myexe)
-    ADD_TEST_MACRO(PrecompiledHeader foo)
+    if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
+      ADD_TEST_MACRO(PrecompiledHeader foo)
+    endif()
   endif()
   if(MSVC OR
       "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
@@ -1869,7 +1881,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
   endif()
 
   if(MSVC AND NOT MSVC_VERSION LESS 1310
-     AND NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]( |$)"
+     AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7( |$)"
      AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio [89]( |$)"
           OR CMAKE_SIZEOF_VOID_P EQUAL 4)
       )
@@ -1881,7 +1893,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
       ADD_TEST_MACRO(SBCS SBCS)
     endif()
 
-    if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
+    if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [789]( |$)"
         AND NOT CMAKE_GENERATOR_TOOLSET)
       ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
     endif()
@@ -1910,7 +1922,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
 
     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
       set(_last_test "")
       foreach(config ${CMAKE_CONFIGURATION_TYPES})
@@ -2095,6 +2106,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     endmacro ()
     add_test_GhsMulti("arm_integrity_simarm" "arm_integrity.tgt" "simarm")
     add_test_GhsMulti("arm64_integrity_simarm" "arm64_integrity.tgt" "simarm")
+    add_test(NAME GhsMulti.duplicate_source_filenames
+        COMMAND ${CMAKE_CTEST_COMMAND}
+        --build-and-test
+        "${CMake_SOURCE_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
+        "${CMake_BINARY_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
+        --build-generator "Green Hills MULTI"
+        --build-project ReturnNum
+        --build-config $<CONFIGURATION>
+        --build-options -DGHS_PRIMARY_TARGET="arm_integrity.tgt"
+        -DGHS_BSP_NAME="simarm"
+        )
   endif ()
 
   if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ")
diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
index bdc2563..8f842d6 100644
--- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
+++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
@@ -81,13 +81,13 @@ endmacro()
 # reported.
 
 foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG
-        HSPELL ICOTOOL JASPER LIBLZMA LIBXML2 LIBXSLT PERL PKG_CONFIG
+        HSPELL ICOTOOL JASPER LIBLZMA LIBXML2 LIBXSLT LTTNGUST PERL PKG_CONFIG
         PostgreSQL TIFF ZLIB)
     check_version_string(${VTEST} ${VTEST}_VERSION_STRING)
 endforeach()
 
 foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2
-        HDF5 LibArchive OPENSCENEGRAPH RUBY SWIG)
+        HDF5 LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf)
     check_version_string(${VTEST} ${VTEST}_VERSION)
 endforeach()
 
diff --git a/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.h b/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.h
index 82bb049..ad21c13 100644
--- a/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.h
+++ b/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.h
@@ -2,8 +2,9 @@
 #define _CSHM_DUMMY_H
 
 struct non_existent_struct;
-struct struct_with_member{
-    int member;
+struct struct_with_member
+{
+  int member;
 };
 
 #endif
diff --git a/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.hxx b/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.hxx
index 458a99b..f3e9326 100644
--- a/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.hxx
+++ b/Tests/CMakeOnly/CheckStructHasMember/cm_cshm.hxx
@@ -4,13 +4,14 @@
 namespace ns {
 
 class non_existent_class;
-class class_with_non_existent_members {
+class class_with_non_existent_members
+{
 };
-class class_with_member {
+class class_with_member
+{
 public:
-    int foo;
+  int foo;
 };
-
 }
 
 #endif
diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/lib.c b/Tests/CMakeOnly/LinkInterfaceLoop/lib.c
index fede1d6..abe3b78 100644
--- a/Tests/CMakeOnly/LinkInterfaceLoop/lib.c
+++ b/Tests/CMakeOnly/LinkInterfaceLoop/lib.c
@@ -1 +1,4 @@
-int lib(void) { return 0; }
+int lib(void)
+{
+  return 0;
+}
diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/main.c b/Tests/CMakeOnly/LinkInterfaceLoop/main.c
index 78f2de1..8488f4e 100644
--- a/Tests/CMakeOnly/LinkInterfaceLoop/main.c
+++ b/Tests/CMakeOnly/LinkInterfaceLoop/main.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in
index e707b9a..b4c48f4 100644
--- a/Tests/CMakeTests/PushCheckStateTest.cmake.in
+++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in
@@ -1,29 +1,68 @@
 include(CMakePushCheckState)
 
+set(CMAKE_EXTRA_INCLUDE_FILES file1)
+set(CMAKE_REQUIRED_INCLUDES dir1)
 set(CMAKE_REQUIRED_DEFINITIONS defs1 )
+set(CMAKE_REQUIRED_LIBRARIES lib1)
+set(CMAKE_REQUIRED_FLAGS flag1)
+set(CMAKE_REQUIRED_QUIET 1)
 
 cmake_push_check_state()
 
+set(CMAKE_EXTRA_INCLUDE_FILES file2)
+set(CMAKE_REQUIRED_INCLUDES dir2)
 set(CMAKE_REQUIRED_DEFINITIONS defs2)
+set(CMAKE_REQUIRED_LIBRARIES lib2)
+set(CMAKE_REQUIRED_FLAGS flag2)
+set(CMAKE_REQUIRED_QUIET 2)
 
 cmake_push_check_state()
 
+set(CMAKE_EXTRA_INCLUDE_FILES file3)
 set(CMAKE_REQUIRED_DEFINITIONS defs3)
+set(CMAKE_REQUIRED_INCLUDES dir3)
+set(CMAKE_REQUIRED_DEFINITIONS defs3)
+set(CMAKE_REQUIRED_LIBRARIES lib3)
+set(CMAKE_REQUIRED_FLAGS flag3)
+set(CMAKE_REQUIRED_QUIET 3)
 
 cmake_pop_check_state()
 
-if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs2")
-  set(fatal TRUE)
-  message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs2\")" )
-endif()
+foreach(pair IN ITEMS
+  EXTRA_INCLUDE_FILES|file2
+  REQUIRED_INCLUDES|dir2
+  REQUIRED_DEFINITIONS|defs2
+  REQUIRED_LIBRARIES|lib2
+  REQUIRED_FLAGS|flag2
+  REQUIRED_QUIET|2
+  )
+  string(REPLACE "|" ";" pair "${pair}")
+  list(GET pair 0 var)
+  list(GET pair 1 expected)
+  if (NOT "${CMAKE_${var}}" STREQUAL "${expected}")
+    set(fatal TRUE)
+    message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" )
+  endif()
+endforeach()
 
 cmake_pop_check_state()
 
-if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs1")
-  set(fatal TRUE)
-  message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs1\")" )
-endif()
-
+foreach(pair IN ITEMS
+  EXTRA_INCLUDE_FILES|file1
+  REQUIRED_INCLUDES|dir1
+  REQUIRED_DEFINITIONS|defs1
+  REQUIRED_LIBRARIES|lib1
+  REQUIRED_FLAGS|flag1
+  REQUIRED_QUIET|1
+  )
+  string(REPLACE "|" ";" pair "${pair}")
+  list(GET pair 0 var)
+  list(GET pair 1 expected)
+  if (NOT "${CMAKE_${var}}" STREQUAL "${expected}")
+    set(fatal TRUE)
+    message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" )
+  endif()
+endforeach()
 
 if(fatal)
   message(FATAL_ERROR "cmake_push_check_state() test failed")
diff --git a/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake
new file mode 100644
index 0000000..a93e7f5
--- /dev/null
+++ b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake
@@ -0,0 +1,22 @@
+string(TIMESTAMP timestamp "[%Y-%m-%d %H:%M:%S] %s" UTC)
+
+string(TIMESTAMP unix_time "%s")
+
+string(TIMESTAMP year "%Y" UTC)
+string(TIMESTAMP days "%j" UTC)
+
+# Doing proper date calculations here to verify unix timestamps
+# could be error prone.
+# At the very least use some safe lower and upper bounds to
+# see if we are somewhere in the right region.
+
+math(EXPR years_since_epoch "${year} - 1970")
+math(EXPR lower_bound "((${years_since_epoch} * 365) + ${days}) * 86400")
+math(EXPR upper_bound "((${years_since_epoch} * 366) + ${days}) * 86400")
+
+
+if(unix_time GREATER lower_bound AND unix_time LESS upper_bound)
+  message("~${unix_time}~")
+else()
+  message(FATAL_ERROR "${timestamp} unix time not in expected range [${lower_bound}, ${upper_bound}]")
+endif()
diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in
index 92e70c3..aba35fe 100644
--- a/Tests/CMakeTests/StringTest.cmake.in
+++ b/Tests/CMakeTests/StringTest.cmake.in
@@ -36,6 +36,8 @@ set(TIMESTAMP-IncompleteSpecifier-RESULT 0)
 set(TIMESTAMP-IncompleteSpecifier-STDERR "~foobar%~")
 set(TIMESTAMP-AllSpecifiers-RESULT 0)
 set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~")
+set(TIMESTAMP-UnixTime-RESULT 0)
+set(TIMESTAMP-UnixTime-STDERR "~[1-9][0-9]+~")
 
 include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake")
 check_cmake_test(String
@@ -58,6 +60,7 @@ check_cmake_test(String
   TIMESTAMP-UnknownSpecifier
   TIMESTAMP-IncompleteSpecifier
   TIMESTAMP-AllSpecifiers
+  TIMESTAMP-UnixTime
   )
 
 # Execute each test listed in StringTestScript.cmake:
@@ -68,9 +71,12 @@ set(number_of_tests_expected 70)
 include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake")
 execute_all_script_tests(${scriptname} number_of_tests_executed)
 
+string(TIMESTAMP timestamp "[%Y-%m-%d %H:%M:%S] UTC %s" UTC)
+
 # And verify that number_of_tests_executed is at least as many as we know
 # about as of this writing...
 #
+message(STATUS "timestamp='${timestamp}'")
 message(STATUS "scriptname='${scriptname}'")
 message(STATUS "number_of_tests_executed='${number_of_tests_executed}'")
 message(STATUS "number_of_tests_expected='${number_of_tests_expected}'")
diff --git a/Tests/COnly/conly.c b/Tests/COnly/conly.c
index 7214fe1..7bd8e8e 100644
--- a/Tests/COnly/conly.c
+++ b/Tests/COnly/conly.c
@@ -5,19 +5,17 @@
 
 #include <stdio.h>
 
-int main ()
+int main()
 {
   int class = 0;
-  if ( LibC1Func() != 2.0 )
-    {
+  if (LibC1Func() != 2.0) {
     printf("Problem with libc1\n");
     return 1;
-    }
-  if ( LibC2Func() != 1.0 )
-    {
+  }
+  if (LibC2Func() != 1.0) {
     printf("Problem with libc2\n");
     return 1;
-    }
+  }
   printf("Foo: %s %d\n", foo, class);
   return 0;
 }
diff --git a/Tests/COnly/libc2.h b/Tests/COnly/libc2.h
index 2713d71..7bc4fb1 100644
--- a/Tests/COnly/libc2.h
+++ b/Tests/COnly/libc2.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef testc2_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef testc2_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float LibC2Func();
diff --git a/Tests/COnly/testCModule.c b/Tests/COnly/testCModule.c
index 1a89292..4381bd7 100644
--- a/Tests/COnly/testCModule.c
+++ b/Tests/COnly/testCModule.c
@@ -1,6 +1,9 @@
 #ifdef _WIN32
-# define TEST_EXPORT __declspec(dllexport)
+#define TEST_EXPORT __declspec(dllexport)
 #else
-# define TEST_EXPORT
+#define TEST_EXPORT
 #endif
-TEST_EXPORT int testCModule(void) { return 0; }
+TEST_EXPORT int testCModule(void)
+{
+  return 0;
+}
diff --git a/Tests/CPackComponentsDEB/CMakeLists.txt b/Tests/CPackComponentsDEB/CMakeLists.txt
index 093b23f..9d4b5e9 100644
--- a/Tests/CPackComponentsDEB/CMakeLists.txt
+++ b/Tests/CPackComponentsDEB/CMakeLists.txt
@@ -130,6 +130,8 @@ configure_file(${CPackComponentsDEB_SOURCE_DIR}/MyLibCPackConfig-${CPackDEBConfi
                @ONLY)
 set(CPACK_PROJECT_CONFIG_FILE ${CPackComponentsDEB_BINARY_DIR}/MyLibCPackConfig-${CPackDEBConfiguration}.cmake)
 
+# set CPACK_DEBIAN_FILE_NAME to use default package name format
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
 
 # Include CPack to introduce the appropriate targets
 include(CPack)
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend1.cmake.in
index d207bcc..dc038fa 100644
--- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend1.cmake.in
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend1.cmake.in
@@ -4,6 +4,7 @@
 
 if(CPACK_GENERATOR MATCHES "DEB")
    set(CPACK_DEB_COMPONENT_INSTALL "ON")
+   set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS "ON")
 endif()
 
 #
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend2.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend2.cmake.in
index 803720a..1aa7d01 100644
--- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend2.cmake.in
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-depend2.cmake.in
@@ -4,6 +4,7 @@
 
 if(CPACK_GENERATOR MATCHES "DEB")
    set(CPACK_DEB_COMPONENT_INSTALL "ON")
+   set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS "ON")
 endif()
 
 #
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake
index 26ab19e..70d6edf 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 
 # expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 
@@ -60,9 +60,9 @@ if(DPKGDEB_EXECUTABLE)
                                       "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-application'\n")
       endif()
     elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
-      if(NOT "${dpkg_depends}" STREQUAL "depend-headers")
+      if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
         set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
-                                      "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n")
+                                      "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
       endif()
     elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
       if(NOT "${dpkg_depends}" STREQUAL "depend-default")
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake
index 79e5df2..415d536 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 
 # expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 set(config_verbose -V)
@@ -73,9 +73,9 @@ if(DPKGDEB_EXECUTABLE)
                                       "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n")
       endif()
     elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
-      if(NOT "${dpkg_depends}" STREQUAL "depend-headers")
+      if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
         set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
-                                      "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n")
+                                      "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
       endif()
     elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
       if(NOT "${dpkg_depends}" STREQUAL "depend-default")
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake
index 6335029..337cc16 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 
 # expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake
index 3d09296..35ca74c 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake
@@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 
 # expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
index ff22f8f..d51650c 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
@@ -5,7 +5,7 @@ endif()
 include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 # TODO: currently debian doens't produce lower cased names
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake
index 79d8f0d..fcfc7ea 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake
@@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 # requirements
 
 # debian now produces lower case names
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake
index 51fa3ad..351bf21 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 
 # expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
 set(expected_count 3)
 
 set(config_verbose -V)
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake
index 2175ada..c97ecb0 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake
@@ -5,7 +5,7 @@ endif()
 include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
 
 # TODO: currently debian doens't produce lower cased names
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb")
 set(expected_count 1)
 
 set(actual_output)
diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt
index 823f6db..3440843 100644
--- a/Tests/CPackComponentsForAll/CMakeLists.txt
+++ b/Tests/CPackComponentsForAll/CMakeLists.txt
@@ -92,6 +92,9 @@ if("${CPACK_GENERATOR}" MATCHES "RPM")
   # test symbolic link to location outside package
   execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ./outside_package symlink_outside_package)
   install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_outside_package DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries)
+  # test symbolic link to location outside wdr (packaging directory)
+  execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink /outside_package_wdr symlink_outside_wdr)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_outside_wdr DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two COMPONENT libraries)
 endif()
 
 # CPack boilerplate for this project
@@ -162,6 +165,9 @@ set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}"
   "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_INSTALL_BINDIR}" "other_relocatable"
   "${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two/different_relocatable")
 
+# set CPACK_DEBIAN_FILE_NAME to use default package name format
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
+
 # We may use the CPack specific config file in order
 # to tailor CPack behavior on a CPack generator specific way
 # (Behavior would be different for RPM or TGZ or DEB ...)
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
index ac9b552..0ffe44d 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
@@ -14,24 +14,38 @@ if(CPACK_GENERATOR MATCHES "RPM")
   set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/foo/bar")
 
   # test requires
-  set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries")
+  set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "mylib-libraries")
 
   # test a "noarch" rpm
-  set(CPACK_RPM_headers_PACKAGE_ARCHITECTURE "noarch")
+  set(CPACK_RPM_HEADERS_PACKAGE_ARCHITECTURE "noarch")
 
   # test cross-built rpm
-  set(CPACK_RPM_applications_PACKAGE_ARCHITECTURE "armv7hf")
+  set(CPACK_RPM_APPLICATIONS_PACKAGE_ARCHITECTURE "armv7hf")
 
   # test package summary override - headers rpm is generated in the middle
   set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
-  set(CPACK_RPM_headers_PACKAGE_SUMMARY "headers summary")
+  set(CPACK_RPM_HEADERS_PACKAGE_SUMMARY "headers summary")
 
   # test package description override - headers rpm is generated in the middle
-  set(CPACK_RPM_headers_PACKAGE_DESCRIPTION "headers description")
+  set(CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION "headers description")
 
   # test package do not use CPACK_PACKAGING_INSTALL_PREFIX
   # as relocation path
-  set(CPACK_RPM_NO_libraries_INSTALL_PREFIX_RELOCATION true)
+  set(CPACK_RPM_NO_LIBRARIES_INSTALL_PREFIX_RELOCATION true)
+
+  # test default permissions
+  set(CPACK_RPM_DEFAULT_USER defusr)
+  set(CPACK_RPM_DEFAULT_GROUP defgrp)
+  set(CPACK_RPM_DEFAULT_FILE_PERMISSIONS
+      OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ)
+  set(CPACK_RPM_DEFAULT_DIR_PERMISSIONS
+      OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ)
+  set(CPACK_RPM_LIBRARIES_DEFAULT_USER user)
+  set(CPACK_RPM_APPLICATIONS_DEFAULT_GROUP group)
+  set(CPACK_RPM_LIBRARIES_DEFAULT_FILE_PERMISSIONS
+      OWNER_READ OWNER_WRITE OWNER_EXECUTE)
+  set(CPACK_RPM_APPLICATIONS_DEFAULT_DIR_PERMISSIONS
+      OWNER_READ GROUP_READ WORLD_READ)
 endif()
 
 if(CPACK_GENERATOR MATCHES "DEB")
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in
index 60bdd06..ac65dc9 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in
@@ -7,7 +7,7 @@ endif()
 
 if(CPACK_GENERATOR MATCHES "RPM")
    set(CPACK_RPM_COMPONENT_INSTALL "ON")
-   set(CPACK_RPM_Development_PACKAGE_REQUIRES "mylib-Runtime")
+   set(CPACK_RPM_DEVELOPMENT_PACKAGE_REQUIRES "mylib-Runtime")
 endif()
 
 if(CPACK_GENERATOR MATCHES "DEB")
diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
index d94a477..fc90d09 100644
--- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
@@ -60,7 +60,7 @@ elseif (CPackGen MATCHES "RPM")
         set(expected_count 1)
     endif ()
 elseif (CPackGen MATCHES "DEB")
-    set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb")
+    set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb")
     if (${CPackComponentWay} STREQUAL "default")
         set(expected_count 1)
     elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
@@ -118,7 +118,7 @@ if(expected_file_mask)
   message(STATUS "expected_file_mask='${expected_file_mask}'")
 
   if(NOT expected_file)
-    message(FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
+    message(FATAL_ERROR "error: expected_file does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
   endif()
 
   list(LENGTH expected_file actual_count)
@@ -136,8 +136,8 @@ if(CPackGen MATCHES "RPM")
   endif()
 
   set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
-  set(CPACK_RPM_headers_PACKAGE_SUMMARY "headers summary")
-  set(CPACK_RPM_headers_PACKAGE_DESCRIPTION "headers description")
+  set(CPACK_RPM_HEADERS_PACKAGE_SUMMARY "headers summary")
+  set(CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION "headers description")
   set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
     "An extremely useful application that makes use of MyLib")
   set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
@@ -188,6 +188,7 @@ if(CPackGen MATCHES "RPM")
 /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/depth_three
 /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/depth_three/symlink_parentdir_path
 /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_outside_package
+/usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_outside_wdr
 /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_relocatable_subpath
 /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path
 /usr/foo/bar/lib${LIB_SUFFIX}/inside_relocatable_one/depth_two/symlink_samedir_path_current_dir
@@ -206,8 +207,8 @@ if(CPackGen MATCHES "RPM")
 /usr/foo/bar/other_relocatable
 /usr/foo/bar/other_relocatable/depth_two$")
       elseif(check_file_headers_match)
-        set(check_file_match_expected_summary ".*${CPACK_RPM_headers_PACKAGE_SUMMARY}.*")
-        set(check_file_match_expected_description ".*${CPACK_RPM_headers_PACKAGE_DESCRIPTION}.*")
+        set(check_file_match_expected_summary ".*${CPACK_RPM_HEADERS_PACKAGE_SUMMARY}.*")
+        set(check_file_match_expected_description ".*${CPACK_RPM_HEADERS_PACKAGE_DESCRIPTION}.*")
         set(check_file_match_expected_relocation_path "Relocations${whitespaces}:${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
         set(check_file_match_expected_architecture "noarch")
         set(spec_regex "*headers*")
@@ -304,6 +305,30 @@ if(CPackGen MATCHES "RPM")
 
         message(FATAL_ERROR "error: '${check_file}' rpm package content does not match expected value - regex '${check_content_list}'; RPM output: '${check_package_content}'; generated spec file: '${spec_file_content}'")
       endif()
+
+      # validate permissions user and group
+      execute_process(COMMAND ${RPM_EXECUTABLE} -pqlv ${check_file}
+          OUTPUT_VARIABLE check_file_content
+          ERROR_QUIET
+          OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+      if(check_file_libraries_match)
+        set(check_file_match_expected_permissions ".*-rwx------.*user.*defgrp.*")
+      elseif(check_file_headers_match)
+        set(check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*defgrp.*")
+      elseif(check_file_applications_match)
+        set(check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*group.*")
+      elseif(check_file_Unspecified_match)
+        set(check_file_match_expected_permissions ".*-rwxr--r--.*defusr.*defgrp.*")
+      else()
+        message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
+      endif()
+
+      string(REGEX MATCH "${check_file_match_expected_permissions}" check_file_match_permissions "${check_file_content}")
+
+      if(NOT check_file_match_permissions)
+          message(FATAL_ERROR "error: '${check_file}' rpm package permissions do not match expected value - regex '${check_file_match_expected_permissions}'")
+      endif()
     endforeach()
 
     #######################
@@ -330,6 +355,8 @@ if(CPackGen MATCHES "RPM")
         string(REGEX MATCH "^.*${whitespaces}->${whitespaces}${CPACK_PACKAGING_INSTALL_PREFIX}/non_relocatable/depth_two$" check_symlink "${SYMLINK_POINT_}")
       elseif("${symlink_name}" STREQUAL "symlink_outside_package")
         string(REGEX MATCH "^.*${whitespaces}->${whitespaces}outside_package$" check_symlink "${SYMLINK_POINT_}")
+      elseif("${symlink_name}" STREQUAL "symlink_outside_wdr")
+        string(REGEX MATCH "^.*${whitespaces}->${whitespaces}/outside_package_wdr$" check_symlink "${SYMLINK_POINT_}")
       elseif("${symlink_name}" STREQUAL "symlink_other_relocatable_path"
           OR "${symlink_name}" STREQUAL "symlink_from_non_relocatable_path"
           OR "${symlink_name}" STREQUAL "symlink_relocatable_subpath")
diff --git a/Tests/CPackWiXGenerator/myotherapp.cpp b/Tests/CPackWiXGenerator/myotherapp.cpp
index c272dab..0eefc1c 100644
--- a/Tests/CPackWiXGenerator/myotherapp.cpp
+++ b/Tests/CPackWiXGenerator/myotherapp.cpp
@@ -1 +1,3 @@
-int main() {}
\ No newline at end of file
+int main()
+{
+}
\ No newline at end of file
diff --git a/Tests/CTestConfig/CTestConfig.cxx b/Tests/CTestConfig/CTestConfig.cxx
index 49c5324..45c6c06 100644
--- a/Tests/CTestConfig/CTestConfig.cxx
+++ b/Tests/CTestConfig/CTestConfig.cxx
@@ -3,8 +3,7 @@
 int main(int argc, const char* argv[])
 {
   int i = 0;
-  for (; i<argc; ++i)
-  {
+  for (; i < argc; ++i) {
     fprintf(stdout, "%s\n", argv[i]);
   }
 
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp
index 85e6cd8..3695dc9 100644
--- a/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/3rdparty/foo.cpp
@@ -1 +1,3 @@
-void foo() {}
+void foo()
+{
+}
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp
index c3a2c12..89c1a66 100644
--- a/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/extra/extra.cpp
@@ -1 +1,3 @@
-void extra() {}
+void extra()
+{
+}
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/CTestCoverageCollectGCOV/TestProject/extra/uncovered1.cpp
similarity index 100%
copy from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake
copy to Tests/CTestCoverageCollectGCOV/TestProject/extra/uncovered1.cpp
diff --git a/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp b/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp
index 237c8ce..5047a34 100644
--- a/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp
+++ b/Tests/CTestCoverageCollectGCOV/TestProject/main.cpp
@@ -1 +1,3 @@
-int main() {}
+int main()
+{
+}
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON.cmake b/Tests/CTestCoverageCollectGCOV/TestProject/uncovered2.cpp
similarity index 100%
rename from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON.cmake
rename to Tests/CTestCoverageCollectGCOV/TestProject/uncovered2.cpp
diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in
index b2e6d6d..d48ef61 100644
--- a/Tests/CTestCoverageCollectGCOV/test.cmake.in
+++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in
@@ -15,7 +15,9 @@ list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
   "/foo/something"
   "/3rdparty/"
   "/bar/somethingelse"
+  "/CMakeFiles/"
 )
+list(APPEND CTEST_EXTRA_COVERAGE_GLOB "*.cpp")
 
 include(CTestCoverageCollectGCOV)
 set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tar)
@@ -41,6 +43,8 @@ set(expected_out
   Testing/CoverageInfo/data.json
   Testing/CoverageInfo/extra.cpp.gcov
   Testing/CoverageInfo/main.cpp.gcov
+  uncovered/extra/uncovered1.cpp
+  uncovered/uncovered2.cpp
 )
 
 if("${out}" STREQUAL "${expected_out}")
diff --git a/Tests/CTestTest/SmallAndFast/echoargs.c b/Tests/CTestTest/SmallAndFast/echoargs.c
index 6e17464..19063b4 100644
--- a/Tests/CTestTest/SmallAndFast/echoargs.c
+++ b/Tests/CTestTest/SmallAndFast/echoargs.c
@@ -3,8 +3,7 @@
 int main(int argc, const char* argv[])
 {
   int i = 0;
-  for (; i<argc; ++i)
-  {
+  for (; i < argc; ++i) {
     fprintf(stdout, "%s\n", argv[i]);
   }
   return 0;
diff --git a/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx b/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx
index 8ea5e40..d2396b7 100644
--- a/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx
+++ b/Tests/CTestTest/SmallAndFast/intentional_compile_warning.cxx
@@ -2,9 +2,9 @@
 
 int main(int argc, const char* argv[])
 {
-  unsigned int i = 0; // "i<argc" should produce a "signed/unsigned comparison" warning
-  for (; i<argc; ++i)
-  {
+  unsigned int i =
+    0; // "i<argc" should produce a "signed/unsigned comparison" warning
+  for (; i < argc; ++i) {
     fprintf(stdout, "%s\n", argv[i]);
   }
   return 0;
diff --git a/Tests/CTestTestCostSerial/sleep.c b/Tests/CTestTestCostSerial/sleep.c
index cb9f87a..b7abe94 100644
--- a/Tests/CTestTestCostSerial/sleep.c
+++ b/Tests/CTestTestCostSerial/sleep.c
@@ -1,7 +1,7 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 /* sleeps for 1 second */
diff --git a/Tests/CTestTestCrash/crash.cxx b/Tests/CTestTestCrash/crash.cxx
index bc9e096..370c3fb 100644
--- a/Tests/CTestTestCrash/crash.cxx
+++ b/Tests/CTestTestCrash/crash.cxx
@@ -1,4 +1,4 @@
-//causes a segfault
+// causes a segfault
 int main()
 {
   int* ptr = 0;
diff --git a/Tests/CTestTestFailure/badCode.cxx b/Tests/CTestTestFailure/badCode.cxx
index b410f0a..8102883 100644
--- a/Tests/CTestTestFailure/badCode.cxx
+++ b/Tests/CTestTestFailure/badCode.cxx
@@ -1,4 +1,4 @@
 int main()
 {
-this code will not compile
+  this code will not compile
 }
diff --git a/Tests/CTestTestFdSetSize/sleep.c b/Tests/CTestTestFdSetSize/sleep.c
index b2e6a87..6676488 100644
--- a/Tests/CTestTestFdSetSize/sleep.c
+++ b/Tests/CTestTestFdSetSize/sleep.c
@@ -1,7 +1,7 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 /* sleeps for 0.1 second */
diff --git a/Tests/CTestTestParallel/lockFile.c b/Tests/CTestTestParallel/lockFile.c
index 6a6a889..a515107 100644
--- a/Tests/CTestTestParallel/lockFile.c
+++ b/Tests/CTestTestParallel/lockFile.c
@@ -10,11 +10,10 @@ int main(void)
   const char* fname = "lockedFile.txt";
   file = fopen(fname, "w");
 
-  for(i = 0; i < 10000; i++)
-    {
+  for (i = 0; i < 10000; i++) {
     fprintf(file, "%s", "x");
     fflush(file);
-    }
+  }
   fclose(file);
   return remove(fname);
 }
diff --git a/Tests/CTestTestResourceLock/lockFile.c b/Tests/CTestTestResourceLock/lockFile.c
index a6a4dc0..8c023ef 100644
--- a/Tests/CTestTestResourceLock/lockFile.c
+++ b/Tests/CTestTestResourceLock/lockFile.c
@@ -1,7 +1,7 @@
 #include <stdio.h>
 
 /* Disable deprecation warning for fopen */
-#pragma warning(disable: 4996)
+#pragma warning(disable : 4996)
 
 /*if run serially, works fine.
   If run in parallel, someone will attempt to delete
@@ -11,21 +11,17 @@ int main(int argc, char** argv)
   FILE* file;
   int i;
   const char* fname;
-  if(argc >= 2)
-    {
+  if (argc >= 2) {
     fname = argv[1];
-    }
-  else
-    {
+  } else {
     fname = "lockedFile.txt";
-    }
+  }
   file = fopen(fname, "w");
 
-  for(i = 0; i < 10000; i++)
-    {
+  for (i = 0; i < 10000; i++) {
     fprintf(file, "%s", "x");
     fflush(file);
-    }
+  }
   fclose(file);
   return remove(fname);
 }
diff --git a/Tests/CTestTestScheduler/sleep.c b/Tests/CTestTestScheduler/sleep.c
index 9631a68..41a5d45 100644
--- a/Tests/CTestTestScheduler/sleep.c
+++ b/Tests/CTestTestScheduler/sleep.c
@@ -1,17 +1,16 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 /* sleeps for 4n seconds, where n is the argument to the program */
 int main(int argc, char** argv)
 {
   int time;
-  if(argc > 1)
-    {
+  if (argc > 1) {
     time = 4 * atoi(argv[1]);
-    }
+  }
 #if defined(_WIN32)
   Sleep(time * 1000);
 #else
diff --git a/Tests/CTestTestStopTime/sleep.c b/Tests/CTestTestStopTime/sleep.c
index b589647..3baad9e 100644
--- a/Tests/CTestTestStopTime/sleep.c
+++ b/Tests/CTestTestStopTime/sleep.c
@@ -1,17 +1,16 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 /* sleeps for n seconds, where n is the argument to the program */
 int main(int argc, char** argv)
 {
   int time;
-  if(argc > 1)
-    {
+  if (argc > 1) {
     time = atoi(argv[1]);
-    }
+  }
 #if defined(_WIN32)
   Sleep(time * 1000);
 #else
diff --git a/Tests/CTestTestTimeout/sleep.c b/Tests/CTestTestTimeout/sleep.c
index 33ce307..a4872b5 100644
--- a/Tests/CTestTestTimeout/sleep.c
+++ b/Tests/CTestTestTimeout/sleep.c
@@ -1,7 +1,7 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 #include <stdio.h>
@@ -11,9 +11,9 @@ 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);
+  Sleep((TIMEOUT + 4) * 1000);
 #else
-  sleep((TIMEOUT+4));
+  sleep((TIMEOUT + 4));
 #endif
   fprintf(stderr, "after sleep\n");
   fflush(stderr); /* should not be needed, but just in case */
diff --git a/Tests/CTestTestUpload/sleep.c b/Tests/CTestTestUpload/sleep.c
index b589647..3baad9e 100644
--- a/Tests/CTestTestUpload/sleep.c
+++ b/Tests/CTestTestUpload/sleep.c
@@ -1,17 +1,16 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 /* sleeps for n seconds, where n is the argument to the program */
 int main(int argc, char** argv)
 {
   int time;
-  if(argc > 1)
-    {
+  if (argc > 1) {
     time = atoi(argv[1]);
-    }
+  }
 #if defined(_WIN32)
   Sleep(time * 1000);
 #else
diff --git a/Tests/CTestTestZeroTimeout/sleep.c b/Tests/CTestTestZeroTimeout/sleep.c
index d40d59d..0be7bbc 100644
--- a/Tests/CTestTestZeroTimeout/sleep.c
+++ b/Tests/CTestTestZeroTimeout/sleep.c
@@ -1,7 +1,7 @@
 #if defined(_WIN32)
-# include <windows.h>
+#include <windows.h>
 #else
-# include <unistd.h>
+#include <unistd.h>
 #endif
 
 /* sleeps for 5 seconds */
diff --git a/Tests/CompatibleInterface/bar.cpp b/Tests/CompatibleInterface/bar.cpp
index 2e09900..69b16c3 100644
--- a/Tests/CompatibleInterface/bar.cpp
+++ b/Tests/CompatibleInterface/bar.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int bar()
+  int bar()
 {
   return 0;
 }
diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp
index d20b64b..93723af 100644
--- a/Tests/CompatibleInterface/main.cpp
+++ b/Tests/CompatibleInterface/main.cpp
@@ -23,13 +23,16 @@
 #error Expected STRING_PROP3
 #endif
 
-template<bool test>
+template <bool test>
 struct CMakeStaticAssert;
 
-template<>
-struct CMakeStaticAssert<true> {};
+template <>
+struct CMakeStaticAssert<true>
+{
+};
 
-enum {
+enum
+{
   NumericMaxTest1 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP1 == 100>),
   NumericMaxTest2 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP2 == 250>),
   NumericMinTest1 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP1 == 50>),
@@ -44,9 +47,9 @@ int foo();
 #ifdef _WIN32
 __declspec(dllimport)
 #endif
-int bar();
+  int bar();
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   Iface2 if2;
   return if2.foo() + foo() + bar();
diff --git a/Tests/CompileCommandOutput/compile_command_output.cxx b/Tests/CompileCommandOutput/compile_command_output.cxx
index 145a064..25795a0 100644
--- a/Tests/CompileCommandOutput/compile_command_output.cxx
+++ b/Tests/CompileCommandOutput/compile_command_output.cxx
@@ -1,7 +1,7 @@
 #include "file_with_underscores.h"
 #include "relative.h"
 
-int main (int argc, char** argv)
+int main(int argc, char** argv)
 {
   file_with_underscores();
   relative();
diff --git a/Tests/CompileCommandOutput/file_with_underscores.cxx b/Tests/CompileCommandOutput/file_with_underscores.cxx
index 4f42ccf..d45c3e0 100644
--- a/Tests/CompileCommandOutput/file_with_underscores.cxx
+++ b/Tests/CompileCommandOutput/file_with_underscores.cxx
@@ -1,3 +1,5 @@
 #include "file_with_underscores.h"
 
-void file_with_underscores() {}
+void file_with_underscores()
+{
+}
diff --git a/Tests/CompileCommandOutput/relative.cxx b/Tests/CompileCommandOutput/relative.cxx
index eae11e2..cd1d9b6 100644
--- a/Tests/CompileCommandOutput/relative.cxx
+++ b/Tests/CompileCommandOutput/relative.cxx
@@ -1,3 +1,5 @@
 #include "relative.h"
 
-void relative() {}
+void relative()
+{
+}
diff --git a/Tests/CompileCommandOutput/relative.h b/Tests/CompileCommandOutput/relative.h
index ddfe551..221e354 100644
--- a/Tests/CompileCommandOutput/relative.h
+++ b/Tests/CompileCommandOutput/relative.h
@@ -1,11 +1,11 @@
 #if defined(_WIN32)
-# ifdef test2_EXPORTS
-#  define TEST2_EXPORT __declspec(dllexport)
-# else
-#  define TEST2_EXPORT __declspec(dllimport)
-# endif
+#ifdef test2_EXPORTS
+#define TEST2_EXPORT __declspec(dllexport)
 #else
-# define TEST2_EXPORT
+#define TEST2_EXPORT __declspec(dllimport)
+#endif
+#else
+#define TEST2_EXPORT
 #endif
 
 TEST2_EXPORT void relative();
diff --git a/Tests/CompileDefinitions/CMakeLists.txt b/Tests/CompileDefinitions/CMakeLists.txt
index 13d1b01..1d8afbf 100644
--- a/Tests/CompileDefinitions/CMakeLists.txt
+++ b/Tests/CompileDefinitions/CMakeLists.txt
@@ -1,11 +1,6 @@
 cmake_minimum_required(VERSION 2.8)
 project(CompileDefinitions)
 
-if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 6")
-    add_definitions(-DNO_SPACES_IN_DEFINE_VALUES)
-    set(NO_SPACES_IN_DEFINE_VALUES 1)
-endif()
-
 # Use compile flags to tell executables which config is built
 # without depending on the compile definitions functionality.
 foreach(c DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
diff --git a/Tests/CompileDefinitions/compiletest.cpp b/Tests/CompileDefinitions/compiletest.cpp
index 7df09df..640e7cf 100644
--- a/Tests/CompileDefinitions/compiletest.cpp
+++ b/Tests/CompileDefinitions/compiletest.cpp
@@ -7,29 +7,38 @@
 #error Expect CMAKE_IS=Fun definition
 #endif
 
-
-template<bool test>
+template <bool test>
 struct CMakeStaticAssert;
 
-template<>
-struct CMakeStaticAssert<true> {};
+template <>
+struct CMakeStaticAssert<true>
+{
+};
 
 static const char fun_string[] = CMAKE_IS_;
 #ifndef NO_SPACES_IN_DEFINE_VALUES
 static const char very_fun_string[] = CMAKE_IS_REALLY;
 #endif
 
-enum {
-  StringLiteralTest1 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>),
+enum
+{
+  StringLiteralTest1 =
+    sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>),
 #ifndef NO_SPACES_IN_DEFINE_VALUES
-  StringLiteralTest2 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>),
+  StringLiteralTest2 =
+    sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>),
 #endif
 #ifdef TEST_GENERATOR_EXPRESSIONS
-  StringLiteralTest3 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST1) == sizeof("A,B,C,D")>),
-  StringLiteralTest4 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST2) == sizeof("A,,B,,C,,D")>),
-  StringLiteralTest5 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST3) == sizeof("A,-B,-C,-D")>),
-  StringLiteralTest6 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST4) == sizeof("A-,-B-,-C-,-D")>),
-  StringLiteralTest7 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST5) == sizeof("A-,B-,C-,D")>)
+  StringLiteralTest3 =
+    sizeof(CMakeStaticAssert<sizeof(LETTER_LIST1) == sizeof("A,B,C,D")>),
+  StringLiteralTest4 =
+    sizeof(CMakeStaticAssert<sizeof(LETTER_LIST2) == sizeof("A,,B,,C,,D")>),
+  StringLiteralTest5 =
+    sizeof(CMakeStaticAssert<sizeof(LETTER_LIST3) == sizeof("A,-B,-C,-D")>),
+  StringLiteralTest6 =
+    sizeof(CMakeStaticAssert<sizeof(LETTER_LIST4) == sizeof("A-,-B-,-C-,-D")>),
+  StringLiteralTest7 =
+    sizeof(CMakeStaticAssert<sizeof(LETTER_LIST5) == sizeof("A-,B-,C-,D")>)
 #endif
 };
 
@@ -70,35 +79,34 @@ enum {
 #error Unexpected LINK_LANGUAGE_IS_C
 #endif
 
-
 // TEST_GENERATOR_EXPRESSIONS
 #endif
 
 #ifndef BUILD_IS_DEBUG
-# error "BUILD_IS_DEBUG not defined!"
+#error "BUILD_IS_DEBUG not defined!"
 #endif
 #ifndef BUILD_IS_NOT_DEBUG
-# error "BUILD_IS_NOT_DEBUG not defined!"
+#error "BUILD_IS_NOT_DEBUG not defined!"
 #endif
 
 // Check per-config definitions.
 #ifdef TEST_CONFIG_DEBUG
-# if !BUILD_IS_DEBUG
-#  error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
-# endif
-# if BUILD_IS_NOT_DEBUG
-#  error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
-# endif
+#if !BUILD_IS_DEBUG
+#error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
+#endif
+#if BUILD_IS_NOT_DEBUG
+#error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
+#endif
 #else
-# if BUILD_IS_DEBUG
-#  error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
-# endif
-# if !BUILD_IS_NOT_DEBUG
-#  error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
-# endif
+#if BUILD_IS_DEBUG
+#error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
+#endif
+#if !BUILD_IS_NOT_DEBUG
+#error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
+#endif
 #endif
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   return 0;
 }
diff --git a/Tests/CompileDefinitions/compiletest_mixed_c.c b/Tests/CompileDefinitions/compiletest_mixed_c.c
index a270b2b..5fbe45f 100644
--- a/Tests/CompileDefinitions/compiletest_mixed_c.c
+++ b/Tests/CompileDefinitions/compiletest_mixed_c.c
@@ -19,5 +19,4 @@
 
 void someFunc(void)
 {
-
 }
diff --git a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
index ae6befc..4eab099 100644
--- a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
+++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
@@ -17,7 +17,7 @@
 #error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
 #endif
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   return 0;
 }
diff --git a/Tests/CompileDefinitions/runtest.c b/Tests/CompileDefinitions/runtest.c
index 02d2cad..7c28ab9 100644
--- a/Tests/CompileDefinitions/runtest.c
+++ b/Tests/CompileDefinitions/runtest.c
@@ -1,47 +1,42 @@
-#include <string.h>
-#include <stdio.h>
 #include <ctype.h>
+#include <stdio.h>
+#include <string.h>
 
 #ifndef BUILD_CONFIG_NAME
-# error "BUILD_CONFIG_NAME not defined!"
+#error "BUILD_CONFIG_NAME not defined!"
 #endif
 
 int main()
 {
   char build_config_name[] = BUILD_CONFIG_NAME;
   char* c;
-  for(c = build_config_name; *c; ++c)
-    {
+  for (c = build_config_name; *c; ++c) {
     *c = (char)tolower((int)*c);
-    }
+  }
   fprintf(stderr, "build_config_name=\"%s\"\n", build_config_name);
 #ifdef TEST_CONFIG_DEBUG
-  if(strcmp(build_config_name, "debug") != 0)
-    {
+  if (strcmp(build_config_name, "debug") != 0) {
     fprintf(stderr, "build_config_name is not \"debug\"\n");
     return 1;
-    }
+  }
 #endif
 #ifdef TEST_CONFIG_RELEASE
-  if(strcmp(build_config_name, "release") != 0)
-    {
+  if (strcmp(build_config_name, "release") != 0) {
     fprintf(stderr, "build_config_name is not \"release\"\n");
     return 1;
-    }
+  }
 #endif
 #ifdef TEST_CONFIG_MINSIZEREL
-  if(strcmp(build_config_name, "minsizerel") != 0)
-    {
+  if (strcmp(build_config_name, "minsizerel") != 0) {
     fprintf(stderr, "build_config_name is not \"minsizerel\"\n");
     return 1;
-    }
+  }
 #endif
 #ifdef TEST_CONFIG_RELWITHDEBINFO
-  if(strcmp(build_config_name, "relwithdebinfo") != 0)
-    {
+  if (strcmp(build_config_name, "relwithdebinfo") != 0) {
     fprintf(stderr, "build_config_name is not \"relwithdebinfo\"\n");
     return 1;
-    }
+  }
 #endif
   return 0;
 }
diff --git a/Tests/CompileDefinitions/target_prop/usetgt.c b/Tests/CompileDefinitions/target_prop/usetgt.c
index 6672a3e..8408a90 100644
--- a/Tests/CompileDefinitions/target_prop/usetgt.c
+++ b/Tests/CompileDefinitions/target_prop/usetgt.c
@@ -1,10 +1,13 @@
 #ifndef TGT_DEF
-# error TGT_DEF incorrectly not defined
+#error TGT_DEF incorrectly not defined
 #endif
 #ifndef TGT_TYPE_STATIC_LIBRARY
-# error TGT_TYPE_STATIC_LIBRARY incorrectly not defined
+#error TGT_TYPE_STATIC_LIBRARY incorrectly not defined
 #endif
 #ifdef TGT_TYPE_EXECUTABLE
-# error TGT_TYPE_EXECUTABLE incorrectly defined
+#error TGT_TYPE_EXECUTABLE incorrectly defined
 #endif
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index a32138d..9f08523 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -119,6 +119,55 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
   endif()
 endif()
 
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+  if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0)
+    if (CMAKE_CXX_COMIPLER_VERSION VERSION_EQUAL 15.0)
+      list(REMOVE_ITEM CXX_non_features
+        # The cxx_contextual_conversions feature happens to work
+        # (for *this* testcase) with Intel 13/14/15, but they do not
+        # document support until 16.
+        cxx_contextual_conversions
+        )
+
+    elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0)
+      list(REMOVE_ITEM CXX_non_features
+        cxx_alignof
+
+        # not supposed to work until 15
+        cxx_attribute_deprecated
+
+        # The cxx_contextual_conversions feature happens to work
+        # (for *this* testcase) with Intel 13/14/15, but they do not
+        # document support until 16.
+        cxx_contextual_conversions
+        )
+
+    elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
+      list(REMOVE_ITEM CXX_non_features
+        # These features happen to work but aren't documented to
+        # do so until 14.0
+        cxx_constexpr
+        cxx_enum_forward_declarations
+        cxx_sizeof_member
+        cxx_strong_enums
+        cxx_unicode_literals
+
+        # not supposed to work until 15
+        cxx_attribute_deprecated
+        cxx_nonstatic_member_init
+
+        # The cxx_contextual_conversions feature happens to work
+        # (for *this* testcase) with Intel 13/14/15, but they do not
+        # document support until 16.
+        cxx_contextual_conversions
+
+        # This is an undocumented feature; it does not work in future versions
+        cxx_aggregate_default_initializers
+        )
+    endif()
+  endif()
+endif()
+
 set(C_ext c)
 set(C_standard_flag 11)
 set(CXX_ext cpp)
@@ -177,6 +226,16 @@ if (CMAKE_C_COMPILE_FEATURES)
     list(APPEND expected_defs
       EXPECT_C_STATIC_ASSERT=1
     )
+  elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel")
+    if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15)
+      list(APPEND expected_defs
+        EXPECT_C_STATIC_ASSERT=1
+        )
+    else()
+      list(APPEND expected_defs
+        EXPECT_C_STATIC_ASSERT=0
+        )
+    endif()
   endif()
 
   list(APPEND expected_defs
@@ -301,6 +360,29 @@ if (CMAKE_CXX_COMPILE_FEATURES)
       -DEXPECT_FINAL=1
       -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
     )
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+    if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
+      add_definitions(
+        -DEXPECT_OVERRIDE_CONTROL=1
+        -DEXPECT_INHERITING_CONSTRUCTORS=1
+        -DEXPECT_FINAL=1
+        -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
+      )
+    elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
+      add_definitions(
+        -DEXPECT_OVERRIDE_CONTROL=1
+        -DEXPECT_INHERITING_CONSTRUCTORS=0
+        -DEXPECT_FINAL=1
+        -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
+      )
+    else()
+      add_definitions(
+        -DEXPECT_OVERRIDE_CONTROL=0
+        -DEXPECT_INHERITING_CONSTRUCTORS=0
+        -DEXPECT_FINAL=0
+        -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
+      )
+    endif()
   endif()
 
   add_executable(CompileFeaturesGenex genex_test.cpp)
diff --git a/Tests/CompileFeatures/c_restrict.c b/Tests/CompileFeatures/c_restrict.c
index 7bc7566..5082da8 100644
--- a/Tests/CompileFeatures/c_restrict.c
+++ b/Tests/CompileFeatures/c_restrict.c
@@ -1,5 +1,5 @@
 
-int f (int * restrict a, int * restrict b)
+int f(int* restrict a, int* restrict b)
 {
   (void)a;
   (void)b;
diff --git a/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp b/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp
index 63a3713..3d1076f 100644
--- a/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp
+++ b/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp
@@ -1,5 +1,8 @@
 
-struct X { int i, j, k = 42; };
+struct X
+{
+  int i, j, k = 42;
+};
 
 int someFunc()
 {
diff --git a/Tests/CompileFeatures/cxx_alias_templates.cpp b/Tests/CompileFeatures/cxx_alias_templates.cpp
index a47e27d..0859692 100644
--- a/Tests/CompileFeatures/cxx_alias_templates.cpp
+++ b/Tests/CompileFeatures/cxx_alias_templates.cpp
@@ -7,5 +7,5 @@ struct A
 };
 
 using B = A<int, char>;
-template<typename T>
+template <typename T>
 using C = A<int, T>;
diff --git a/Tests/CompileFeatures/cxx_alignas.cpp b/Tests/CompileFeatures/cxx_alignas.cpp
index 35b7c82..9fc2c2a 100644
--- a/Tests/CompileFeatures/cxx_alignas.cpp
+++ b/Tests/CompileFeatures/cxx_alignas.cpp
@@ -1,4 +1,5 @@
 
-struct S1 {
+struct S1
+{
   alignas(8) int n;
 };
diff --git a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
index b6f307d..5482db8 100644
--- a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
+++ b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
@@ -1,6 +1,5 @@
 
-[[deprecated]]
-int foo()
+[[deprecated]] int foo()
 {
   return 0;
 }
diff --git a/Tests/CompileFeatures/cxx_attributes.cpp b/Tests/CompileFeatures/cxx_attributes.cpp
index a3c89ea..1434317 100644
--- a/Tests/CompileFeatures/cxx_attributes.cpp
+++ b/Tests/CompileFeatures/cxx_attributes.cpp
@@ -1,2 +1,5 @@
 
-void unusedFunc [[noreturn]] () { throw 1; }
+void unusedFunc[[noreturn]]()
+{
+  throw 1;
+}
diff --git a/Tests/CompileFeatures/cxx_contextual_conversions.cpp b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
index 3438624..cbc7304 100644
--- a/Tests/CompileFeatures/cxx_contextual_conversions.cpp
+++ b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
@@ -1,33 +1,42 @@
 
-#define assert(E) if(!(E)) return 1;
+#define assert(E)                                                             \
+  if (!(E))                                                                   \
+    return 1;
 
-template<class T>
+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; }
+  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 );
+  zero_init<int*> p;
+  assert(p == 0);
   p = new int(7);
-  assert( *p == 7 );
+  assert(*p == 7);
   delete p;
 
-  zero_init<int> i; assert( i == 0 );
+  zero_init<int> i;
+  assert(i == 0);
   i = 7;
-  assert( i == 7 );
-  switch( i ) {  }
+  assert(i == 7);
+  switch (i) {
+  }
 
-  int *vp = new int[i];
+  int* vp = new int[i];
 
   return 0;
 }
diff --git a/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
index 109d038..74bcbe1 100644
--- a/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
+++ b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
@@ -1,14 +1,19 @@
 
-template<class T>
+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 {
+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
index 3d14c52..bcca6aa 100644
--- a/Tests/CompileFeatures/cxx_default_function_template_args.cpp
+++ b/Tests/CompileFeatures/cxx_default_function_template_args.cpp
@@ -1,5 +1,5 @@
 
-template<typename T = int>
+template <typename T = int>
 int someFunc()
 {
   T t = 0;
diff --git a/Tests/CompileFeatures/cxx_defaulted_functions.cpp b/Tests/CompileFeatures/cxx_defaulted_functions.cpp
index b679a92..3b15adc 100644
--- a/Tests/CompileFeatures/cxx_defaulted_functions.cpp
+++ b/Tests/CompileFeatures/cxx_defaulted_functions.cpp
@@ -1,5 +1,6 @@
 
-struct A {
+struct A
+{
   A() = default;
 };
 
diff --git a/Tests/CompileFeatures/cxx_delegating_constructors.cpp b/Tests/CompileFeatures/cxx_delegating_constructors.cpp
index 4b41615..7e04939 100644
--- a/Tests/CompileFeatures/cxx_delegating_constructors.cpp
+++ b/Tests/CompileFeatures/cxx_delegating_constructors.cpp
@@ -7,7 +7,6 @@ public:
   Foo(double d)
     : Foo(static_cast<int>(d))
   {
-
   }
 
 private:
diff --git a/Tests/CompileFeatures/cxx_digit_separators.cpp b/Tests/CompileFeatures/cxx_digit_separators.cpp
index abcd1c8..a40ac0a 100644
--- a/Tests/CompileFeatures/cxx_digit_separators.cpp
+++ b/Tests/CompileFeatures/cxx_digit_separators.cpp
@@ -1,6 +1,5 @@
 
 int someFunc()
 {
-  int one_thousand = 1'000;
-  return one_thousand - 1000;
+  int one_thousand = 1'000; return one_thousand - 1000;
 }
diff --git a/Tests/CompileFeatures/cxx_explicit_conversions.cpp b/Tests/CompileFeatures/cxx_explicit_conversions.cpp
index 0decdcd..a34128f 100644
--- a/Tests/CompileFeatures/cxx_explicit_conversions.cpp
+++ b/Tests/CompileFeatures/cxx_explicit_conversions.cpp
@@ -2,9 +2,7 @@
 class A
 {
   int m_i;
+
 public:
-  explicit operator bool()
-  {
-    return m_i != 0;
-  }
+  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
index 631c699..bde94d2 100644
--- a/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
+++ b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
@@ -2,7 +2,11 @@
 template <typename T>
 struct B
 {
-  B() : m_i(42) {}
+  B()
+    : m_i(42)
+  {
+  }
+
 private:
   int m_i;
   friend T;
@@ -10,7 +14,7 @@ private:
 
 struct A
 {
-  template<typename T>
+  template <typename T>
   int getBValue(B<T> b)
   {
     return b.m_i;
diff --git a/Tests/CompileFeatures/cxx_extern_templates.cpp b/Tests/CompileFeatures/cxx_extern_templates.cpp
index 9fa4aa4..01f300a 100644
--- a/Tests/CompileFeatures/cxx_extern_templates.cpp
+++ b/Tests/CompileFeatures/cxx_extern_templates.cpp
@@ -1,5 +1,5 @@
 
-template<typename T>
+template <typename T>
 void someFunc()
 {
 }
diff --git a/Tests/CompileFeatures/cxx_final.cpp b/Tests/CompileFeatures/cxx_final.cpp
index 598cb94..9d5d5c4 100644
--- a/Tests/CompileFeatures/cxx_final.cpp
+++ b/Tests/CompileFeatures/cxx_final.cpp
@@ -1,2 +1,4 @@
 
-struct A final {};
+struct A final
+{
+};
diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
index ad05f12..cfe9d98 100644
--- a/Tests/CompileFeatures/cxx_generalized_initializers.cpp
+++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
@@ -1,19 +1,22 @@
 #if defined(_MSC_VER) && _MSC_VER == 1800 && _MSC_FULL_VER < 180030723
-# error "VS 2013 safely supports this only with Update 3 or greater"
+#error "VS 2013 safely supports this only with Update 3 or greater"
 #endif
 
 // Dummy implementation. Test only the compiler feature.
 namespace std {
-  typedef decltype(sizeof(int)) size_t;
-  template <class _E>
-  class initializer_list
+typedef decltype(sizeof(int)) size_t;
+template <class _E>
+class initializer_list
+{
+  const _E* __begin_;
+  size_t __size_;
+
+public:
+  template <typename T1, typename T2>
+  initializer_list(T1, T2)
   {
-    const _E* __begin_;
-    size_t    __size_;
-  public:
-    template <typename T1, typename T2>
-    initializer_list(T1, T2) {}
-  };
+  }
+};
 }
 
 template <typename T>
diff --git a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
index cfce880..51400ce 100644
--- a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
+++ b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
@@ -3,7 +3,10 @@ struct A
 {
   int m_i;
 
-  A(int i) : m_i(i) {}
+  A(int i)
+    : m_i(i)
+  {
+  }
 };
 
 struct B : public A
diff --git a/Tests/CompileFeatures/cxx_inline_namespaces.cpp b/Tests/CompileFeatures/cxx_inline_namespaces.cpp
index 59fa9c8..77f99e8 100644
--- a/Tests/CompileFeatures/cxx_inline_namespaces.cpp
+++ b/Tests/CompileFeatures/cxx_inline_namespaces.cpp
@@ -1,26 +1,25 @@
-namespace Lib
-{
-inline namespace Lib_1
-{
-  template <typename T> class A;
+namespace Lib {
+inline namespace Lib_1 {
+template <typename T>
+class A;
 }
 
-template <typename T> void g(T);
+template <typename T>
+void g(T);
 }
 
-struct MyClass {
-
+struct MyClass
+{
 };
-namespace Lib
+namespace Lib {
+template <>
+class A<MyClass>
 {
-template<>
-class A<MyClass> {
-
 };
 }
 
 void someFunc()
 {
   Lib::A<MyClass> a;
-  g(a);  // ok, Lib is an associated namespace of 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
index 7e337fa..46f22cb 100644
--- a/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
+++ b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
@@ -2,5 +2,6 @@
 int someFunc()
 {
   int a = 0;
-  return [b = static_cast<int&&>(a)]() { return b; }();
+  return [b = static_cast<int&&>(a)]() { return b; }
+  ();
 }
diff --git a/Tests/CompileFeatures/cxx_lambdas.cpp b/Tests/CompileFeatures/cxx_lambdas.cpp
index eecaa23..7cd1fab 100644
--- a/Tests/CompileFeatures/cxx_lambdas.cpp
+++ b/Tests/CompileFeatures/cxx_lambdas.cpp
@@ -1,5 +1,5 @@
 
 void someFunc()
 {
-  [](){}();
+  []() {}();
 }
diff --git a/Tests/CompileFeatures/cxx_local_type_template_args.cpp b/Tests/CompileFeatures/cxx_local_type_template_args.cpp
index 802ea7a..00565e6 100644
--- a/Tests/CompileFeatures/cxx_local_type_template_args.cpp
+++ b/Tests/CompileFeatures/cxx_local_type_template_args.cpp
@@ -1,13 +1,27 @@
 
 template <typename T>
-class X { };
+class X
+{
+};
 template <typename T>
-void f(T t) { }
-struct {} unnamed_obj;
-void f() {
-  struct A { };
-  enum { e1 };
-  typedef struct {} B;
+void f(T t)
+{
+}
+struct
+{
+} unnamed_obj;
+void f()
+{
+  struct A
+  {
+  };
+  enum
+  {
+    e1
+  };
+  typedef struct
+  {
+  } B;
   B b;
   X<A> x1;
   X<A*> x2;
diff --git a/Tests/CompileFeatures/cxx_noexcept.cpp b/Tests/CompileFeatures/cxx_noexcept.cpp
index a3c05b8..535e5db 100644
--- a/Tests/CompileFeatures/cxx_noexcept.cpp
+++ b/Tests/CompileFeatures/cxx_noexcept.cpp
@@ -1,5 +1,4 @@
 
 void someFunc() noexcept
 {
-
 }
diff --git a/Tests/CompileFeatures/cxx_nullptr.cpp b/Tests/CompileFeatures/cxx_nullptr.cpp
index 96307df..a31422d 100644
--- a/Tests/CompileFeatures/cxx_nullptr.cpp
+++ b/Tests/CompileFeatures/cxx_nullptr.cpp
@@ -1,7 +1,6 @@
 
 void someFunc(int*)
 {
-
 }
 
 void otherFunc()
diff --git a/Tests/CompileFeatures/cxx_override.cpp b/Tests/CompileFeatures/cxx_override.cpp
index 55bec13..3283f2f 100644
--- a/Tests/CompileFeatures/cxx_override.cpp
+++ b/Tests/CompileFeatures/cxx_override.cpp
@@ -1,7 +1,9 @@
 
-struct A {
+struct A
+{
   virtual void doNothing() {}
 };
-struct B : A {
+struct B : A
+{
   void doNothing() override {}
 };
diff --git a/Tests/CompileFeatures/cxx_range_for.cpp b/Tests/CompileFeatures/cxx_range_for.cpp
index 892109e..e3b5724 100644
--- a/Tests/CompileFeatures/cxx_range_for.cpp
+++ b/Tests/CompileFeatures/cxx_range_for.cpp
@@ -3,8 +3,7 @@ void someFunc()
 {
   int accumulated = 0;
   int numbers[] = { 1, 2, 5 };
-  for (int i : numbers)
-    {
+  for (int i : numbers) {
     accumulated += i;
-    }
+  }
 }
diff --git a/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
index 83a2361..2fd36e0 100644
--- a/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
+++ b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
@@ -1,11 +1,13 @@
 
-struct test{
-  void f() & { }
-  void f() && { }
+struct test
+{
+  void f() & {}
+  void f() && {}
 };
 
-void someFunc(){
+void someFunc()
+{
   test t;
-  t.f(); // lvalue
+  t.f();      // lvalue
   test().f(); // rvalue
 }
diff --git a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
index bce82e3..7b3602c 100644
--- a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
+++ b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
@@ -1,12 +1,16 @@
 
-struct X {
-  constexpr X() : n(5) {
+struct X
+{
+  constexpr X()
+    : n(5)
+  {
     n *= 2;
   }
   int n;
 };
 
-constexpr int g(const int (&is)[4]) {
+constexpr int g(const int (&is)[4])
+{
   X x;
   int r = x.n;
   for (int i = 0; i < 5; ++i)
diff --git a/Tests/CompileFeatures/cxx_return_type_deduction.cpp b/Tests/CompileFeatures/cxx_return_type_deduction.cpp
index 009e919..a3108df 100644
--- a/Tests/CompileFeatures/cxx_return_type_deduction.cpp
+++ b/Tests/CompileFeatures/cxx_return_type_deduction.cpp
@@ -1,7 +1,7 @@
 
 auto sum(int a, int b)
 {
-  return a+b;
+  return a + b;
 }
 
 int someFunc()
diff --git a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
index 2713fd8..8f1b0ee 100644
--- a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
+++ b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
@@ -1,5 +1,5 @@
 
-template<typename T>
+template <typename T>
 struct A
 {
   typedef T Result;
@@ -7,6 +7,6 @@ struct A
 
 void someFunc()
 {
-  A<A<int>> object;
+  A<A<int> > object;
   (void)object;
 }
diff --git a/Tests/CompileFeatures/cxx_rvalue_references.cpp b/Tests/CompileFeatures/cxx_rvalue_references.cpp
index 787026a..3b85ab6 100644
--- a/Tests/CompileFeatures/cxx_rvalue_references.cpp
+++ b/Tests/CompileFeatures/cxx_rvalue_references.cpp
@@ -1,5 +1,4 @@
 
 void someFunc(int&&)
 {
-
 }
diff --git a/Tests/CompileFeatures/cxx_template_template_parameters.cpp b/Tests/CompileFeatures/cxx_template_template_parameters.cpp
index 0fdd18d..d57dd36 100644
--- a/Tests/CompileFeatures/cxx_template_template_parameters.cpp
+++ b/Tests/CompileFeatures/cxx_template_template_parameters.cpp
@@ -1,14 +1,12 @@
 
-template<template <typename> class T, typename U>
+template <template <typename> class T, typename U>
 void someFunc(T<U>)
 {
-
 }
 
-template<typename T>
+template <typename T>
 struct A
 {
-
 };
 
 void otherFunc()
diff --git a/Tests/CompileFeatures/cxx_unicode_literals.cpp b/Tests/CompileFeatures/cxx_unicode_literals.cpp
index a7b7df0..7794c11 100644
--- a/Tests/CompileFeatures/cxx_unicode_literals.cpp
+++ b/Tests/CompileFeatures/cxx_unicode_literals.cpp
@@ -1,3 +1,5 @@
 
+/* clang-format off */
 const char16_t lit_16[] = u"\u00DA";
 const char32_t lit_32[] = U"\u00DA";
+/* clang-format on */
diff --git a/Tests/CompileFeatures/cxx_uniform_initialization.cpp b/Tests/CompileFeatures/cxx_uniform_initialization.cpp
index 82c76e2..e5048d1 100644
--- a/Tests/CompileFeatures/cxx_uniform_initialization.cpp
+++ b/Tests/CompileFeatures/cxx_uniform_initialization.cpp
@@ -1,9 +1,12 @@
-struct A {};
-struct B {
+struct A
+{
+};
+struct B
+{
   B(A) {}
 };
 
 void Func()
 {
-  B b{A{}};
+  B b{ A{} };
 }
diff --git a/Tests/CompileFeatures/cxx_unrestricted_unions.cpp b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
index 698fd61..f6d64f6 100644
--- a/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
+++ b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
@@ -1,10 +1,16 @@
 
-struct point {
+struct point
+{
   point() {}
-  point(int x, int y) : x_(x), y_(y) {}
+  point(int x, int y)
+    : x_(x)
+    , y_(y)
+  {
+  }
   int x_, y_;
 };
-union u {
+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
index 9e5a588..5144204 100644
--- a/Tests/CompileFeatures/cxx_user_literals.cpp
+++ b/Tests/CompileFeatures/cxx_user_literals.cpp
@@ -1,5 +1,5 @@
 
-long double operator "" _meters(long double);
+long double operator"" _meters(long double);
 
 void someFunc()
 {
diff --git a/Tests/CompileFeatures/cxx_variable_templates.cpp b/Tests/CompileFeatures/cxx_variable_templates.cpp
index 5d4bdbc..8e6fc99 100644
--- a/Tests/CompileFeatures/cxx_variable_templates.cpp
+++ b/Tests/CompileFeatures/cxx_variable_templates.cpp
@@ -1,5 +1,5 @@
 
-template<typename T>
+template <typename T>
 constexpr T pi = T(3.1415926535897932385);
 
 int someFunc()
diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp
index e1f641b..3dc2570 100644
--- a/Tests/CompileFeatures/cxx_variadic_templates.cpp
+++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp
@@ -3,63 +3,61 @@
 #endif
 
 #ifdef OLD_GNU
-template<int... Is>
+template <int... Is>
 struct Interface;
 #endif
 
-template<int I, int... Is>
+template <int I, int... Is>
 struct Interface
 #ifdef OLD_GNU
-                <I, Is...>
+  <I, Is...>
 #endif
 {
-  static int accumulate()
-  {
-    return I + Interface<Is...>::accumulate();
-  }
+  static int accumulate() { return I + Interface<Is...>::accumulate(); }
 };
 
-template<int I>
+template <int I>
 struct Interface<I>
 {
-  static int accumulate()
-  {
-    return I;
-  }
+  static int accumulate() { return I; }
 };
 
 // Note: split this into a separate test if a
 // cxx_variadic_template_template_parameters feature is added.
 
-template<typename T>
-struct eval {
-  enum {
+template <typename T>
+struct eval
+{
+  enum
+  {
     Matched = 0
   };
 };
 
-template<template<typename...> class T, typename... U>
-struct eval<T<U...> > {
-  enum {
+template <template <typename...> class T, typename... U>
+struct eval<T<U...> >
+{
+  enum
+  {
     Matched = 1
   };
 };
 
-template<typename...>
-struct A {
-
+template <typename...>
+struct A
+{
 };
-template<typename T>
-struct B {
-
+template <typename T>
+struct B
+{
 };
-template<typename T, typename U>
-struct C {
-
+template <typename T, typename U>
+struct C
+{
 };
-template<typename T, typename U, typename...>
-struct D {
-
+template <typename T, typename U, typename...>
+struct D
+{
 };
 
 // Note: This test assumes that a compiler supporting this feature
diff --git a/Tests/CompileFeatures/default_dialect.c b/Tests/CompileFeatures/default_dialect.c
index 1b39dec..0e67095 100644
--- a/Tests/CompileFeatures/default_dialect.c
+++ b/Tests/CompileFeatures/default_dialect.c
@@ -1,19 +1,19 @@
 
 #if DEFAULT_C11
-#  if __STDC_VERSION__ != 201112L
-#    error Unexpected value for __STDC_VERSION__.
-#  endif
+#if __STDC_VERSION__ != 201112L
+#error Unexpected value for __STDC_VERSION__.
+#endif
 #elif DEFAULT_C99
-#  if __STDC_VERSION__ != 199901L
-#    error Unexpected value for __STDC_VERSION__.
-#  endif
+#if __STDC_VERSION__ != 199901L
+#error Unexpected value for __STDC_VERSION__.
+#endif
 #else
-#  if !DEFAULT_C90
-#    error Buildsystem error
-#  endif
-#  if defined(__STDC_VERSION__)
-#    error Unexpected __STDC_VERSION__ definition
-#  endif
+#if !DEFAULT_C90
+#error Buildsystem error
+#endif
+#if defined(__STDC_VERSION__)
+#error Unexpected __STDC_VERSION__ definition
+#endif
 #endif
 
 int main()
diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp
index a2ca268..0efaefa 100644
--- a/Tests/CompileFeatures/default_dialect.cpp
+++ b/Tests/CompileFeatures/default_dialect.cpp
@@ -1,22 +1,23 @@
 
-template<long l>
+template <long l>
 struct Outputter;
 
 #if DEFAULT_CXX14
-#  if __cplusplus != 201402L
+#if __cplusplus != 201402L
 Outputter<__cplusplus> o;
-#  endif
+#endif
 #elif DEFAULT_CXX11
-#  if __cplusplus != 201103L
+#if __cplusplus != 201103L
 Outputter<__cplusplus> o;
-#  endif
+#endif
 #else
-#  if !DEFAULT_CXX98
-#    error Buildsystem error
-#  endif
-#  if __cplusplus != 199711L && __cplusplus != 1 && !defined(__GXX_EXPERIMENTAL_CXX0X__)
+#if !DEFAULT_CXX98
+#error Buildsystem error
+#endif
+#if __cplusplus != 199711L && __cplusplus != 1 &&                             \
+  !defined(__GXX_EXPERIMENTAL_CXX0X__)
 Outputter<__cplusplus> o;
-#  endif
+#endif
 #endif
 
 int main()
diff --git a/Tests/CompileFeatures/genex_test.c b/Tests/CompileFeatures/genex_test.c
index b1215bd..1d54840 100644
--- a/Tests/CompileFeatures/genex_test.c
+++ b/Tests/CompileFeatures/genex_test.c
@@ -1,11 +1,11 @@
 #ifndef EXPECT_C_STATIC_ASSERT
-# error EXPECT_C_STATIC_ASSERT not defined
+#error EXPECT_C_STATIC_ASSERT not defined
 #endif
 #ifndef EXPECT_C_FUNCTION_PROTOTYPES
-# error EXPECT_C_FUNCTION_PROTOTYPES not defined
+#error EXPECT_C_FUNCTION_PROTOTYPES not defined
 #endif
 #ifndef EXPECT_C_RESTRICT
-# error EXPECT_C_RESTRICT not defined
+#error EXPECT_C_RESTRICT not defined
 #endif
 
 #if !EXPECT_C_STATIC_ASSERT
@@ -19,20 +19,19 @@
 #endif
 
 #if !EXPECT_C_FUNCTION_PROTOTYPES
-#  error Expect c_function_prototypes support
+#error Expect c_function_prototypes support
 #endif
 
 #if !EXPECT_C_RESTRICT
-#  if EXPECT_C_RESTRICT
-#    error Expect c_restrict support
-#  endif
+#if EXPECT_C_RESTRICT
+#error Expect c_restrict support
+#endif
 #else
-#  if !EXPECT_C_RESTRICT
-#    error Expect no c_restrict support
-#  endif
+#if !EXPECT_C_RESTRICT
+#error Expect no c_restrict support
+#endif
 #endif
 
 int main()
 {
-
 }
diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp
index 2161bca..5ae8a78 100644
--- a/Tests/CompileFeatures/genex_test.cpp
+++ b/Tests/CompileFeatures/genex_test.cpp
@@ -1,14 +1,14 @@
 #ifndef EXPECT_FINAL
-# error EXPECT_FINAL not defined
+#error EXPECT_FINAL not defined
 #endif
 #ifndef EXPECT_INHERITING_CONSTRUCTORS
-# error EXPECT_INHERITING_CONSTRUCTORS not defined
+#error EXPECT_INHERITING_CONSTRUCTORS not defined
 #endif
 #ifndef EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
-# error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined
+#error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined
 #endif
 #ifndef EXPECT_OVERRIDE_CONTROL
-# error EXPECT_OVERRIDE_CONTROL not defined
+#error EXPECT_OVERRIDE_CONTROL not defined
 #endif
 
 #if !HAVE_OVERRIDE_CONTROL
@@ -33,40 +33,39 @@ struct B final : A
 #endif
 
 #if !HAVE_AUTO_TYPE
-#  error Expect cxx_auto_type support
+#error Expect cxx_auto_type support
 #endif
 
 #if !HAVE_INHERITING_CONSTRUCTORS
-#  if EXPECT_INHERITING_CONSTRUCTORS
-#    error Expect cxx_inheriting_constructors support
-#  endif
+#if EXPECT_INHERITING_CONSTRUCTORS
+#error Expect cxx_inheriting_constructors support
+#endif
 #else
-#  if !EXPECT_INHERITING_CONSTRUCTORS
-#    error Expect no cxx_inheriting_constructors support
-#  endif
+#if !EXPECT_INHERITING_CONSTRUCTORS
+#error Expect no cxx_inheriting_constructors support
+#endif
 #endif
 
 #if !HAVE_FINAL
-#  if EXPECT_FINAL
-#    error Expect cxx_final support
-#  endif
+#if EXPECT_FINAL
+#error Expect cxx_final support
+#endif
 #else
-#  if !EXPECT_FINAL
-#    error Expect no cxx_final support
-#  endif
+#if !EXPECT_FINAL
+#error Expect no cxx_final support
+#endif
 #endif
 
 #if !HAVE_INHERITING_CONSTRUCTORS_AND_FINAL
-#  if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
-#    error Expect cxx_inheriting_constructors and cxx_final support
-#  endif
+#if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
+#error Expect cxx_inheriting_constructors and cxx_final support
+#endif
 #else
-#  if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
-#    error Expect no combined cxx_inheriting_constructors and cxx_final support
-#  endif
+#if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
+#error Expect no combined cxx_inheriting_constructors and cxx_final support
+#endif
 #endif
 
 int main()
 {
-
 }
diff --git a/Tests/CompileFeatures/main.cpp b/Tests/CompileFeatures/main.cpp
index 3a8e0fc..c5a7a46 100644
--- a/Tests/CompileFeatures/main.cpp
+++ b/Tests/CompileFeatures/main.cpp
@@ -1,5 +1,5 @@
 
-int main(int,char**)
+int main(int, char**)
 {
   auto value = 0;
   return value;
diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp
index f3c1355..63a0480 100644
--- a/Tests/CompileOptions/main.cpp
+++ b/Tests/CompileOptions/main.cpp
@@ -1,15 +1,15 @@
 #ifndef TEST_DEFINE
-# error Expected definition TEST_DEFINE
+#error Expected definition TEST_DEFINE
 #endif
 
 #ifndef NEEDS_ESCAPE
-# error Expected definition NEEDS_ESCAPE
+#error Expected definition NEEDS_ESCAPE
 #endif
 
 #ifdef DO_GNU_TESTS
-# ifndef TEST_DEFINE_GNU
-#  error Expected definition TEST_DEFINE_GNU
-# endif
+#ifndef TEST_DEFINE_GNU
+#error Expected definition TEST_DEFINE_GNU
+#endif
 #endif
 
 #include <string.h>
@@ -18,10 +18,14 @@ int main()
 {
   return (strcmp(NEEDS_ESCAPE, "E$CAPE") == 0
 #ifdef TEST_OCTOTHORPE
-      && strcmp(TEST_OCTOTHORPE, "#") == 0
+          && strcmp(TEST_OCTOTHORPE, "#") == 0
 #endif
-      && strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0
-      && strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0
-      && TEST_C_COMPILER_VERSION_EQUALITY == 1
-      && TEST_CXX_COMPILER_VERSION_EQUALITY == 1) ? 0 : 1;
+          &&
+          strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0 &&
+          strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) ==
+            0 &&
+          TEST_C_COMPILER_VERSION_EQUALITY == 1 &&
+          TEST_CXX_COMPILER_VERSION_EQUALITY == 1)
+    ? 0
+    : 1;
 }
diff --git a/Tests/CompileOptions/other.cpp b/Tests/CompileOptions/other.cpp
index 0e34375..7d75e37 100644
--- a/Tests/CompileOptions/other.cpp
+++ b/Tests/CompileOptions/other.cpp
@@ -1,5 +1,4 @@
 
 void foo(void)
 {
-
 }
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 9251ff3..83ca7f4 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -2,6 +2,7 @@
 # A more complex test case
 #
 cmake_minimum_required(VERSION 2.4)
+cmake_policy(SET CMP0054 NEW)
 project (Complex)
 
 # Test that renaming a built-in works when configured multiple times.
@@ -438,6 +439,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
 endif ()
 
+# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+  set(CMAKE_CXX_STANDARD 11)
+endif()
+
 #
 # Create the libs and the main exe
 #
diff --git a/Tests/Complex/Executable/A.h b/Tests/Complex/Executable/A.h
index 25c45fc..3503719 100644
--- a/Tests/Complex/Executable/A.h
+++ b/Tests/Complex/Executable/A.h
@@ -1,4 +1,7 @@
 // This header should not be compiled directly but through inclusion
 // in A.cxx through A.hh.
 extern int A();
-int A() { return 10; }
+int A()
+{
+  return 10;
+}
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
index a1f8e68..c30dcbc 100644
--- a/Tests/Complex/Executable/CMakeLists.txt
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -146,7 +146,8 @@ add_dependencies(notInAllCustom notInAllExe)
 #
 add_subdirectory(Temp)
 
-if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
+if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX
+   AND NOT XCODE) # XCODE is excluded due to #15687
   add_executable(testSystemDir testSystemDir.cxx)
   set_target_properties(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror")
 endif()
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index ec222a5..5f79ac0 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -1,29 +1,28 @@
+#include "Aout.h"
+#include "ExtraSources/file1.h"
 #include "cmTestConfigure.h"
 #include "cmTestConfigureEscape.h"
 #include "cmTestGeneratedHeader.h"
 #include "cmVersion.h"
-#include "ExtraSources/file1.h"
-#include "Aout.h"
 #include "file2.h"
 #include "sharedFile.h"
 extern "C" {
 #include "testConly.h"
 }
-#include <vector>
-#include <string>
 #include <iostream>
 #include <string.h>
+#include <string>
+#include <vector>
 
 #include <stdio.h>
 #include <sys/stat.h>
 #if !defined(S_ISDIR)
-# define S_ISDIR(mode) ((mode) & _S_IFDIR)
+#define S_ISDIR(mode) ((mode)&_S_IFDIR)
 #endif
 
 #ifdef COMPLEX_TEST_LINK_STATIC
-extern "C"
-{
-  int TestLinkGetType();
+extern "C" {
+int TestLinkGetType();
 }
 #endif
 
@@ -31,7 +30,7 @@ int cm_passed = 0;
 int cm_failed = 0;
 // ======================================================================
 
-void cmFailed(const char* Message, const char* m2= "", const char* m3 = "")
+void cmFailed(const char* Message, const char* m2 = "", const char* m3 = "")
 {
   std::cout << "FAILED: " << Message << m2 << m3 << "\n";
   cm_failed++;
@@ -39,30 +38,30 @@ void cmFailed(const char* Message, const char* m2= "", const char* m3 = "")
 
 // ======================================================================
 
-void cmPassed(const char* Message, const char* m2="")
+void cmPassed(const char* Message, const char* m2 = "")
 {
   std::cout << "Passed: " << Message << m2 << "\n";
   cm_passed++;
 }
 
 #ifndef COMPLEX_DEFINED_PRE
-# error "COMPLEX_DEFINED_PRE not defined!"
+#error "COMPLEX_DEFINED_PRE not defined!"
 #endif
 
 #ifdef COMPLEX_DEFINED
-# error "COMPLEX_DEFINED is defined but it should not!"
+#error "COMPLEX_DEFINED is defined but it should not!"
 #endif
 
 #ifndef COMPLEX_DEFINED_POST
-# error "COMPLEX_DEFINED_POST not defined!"
+#error "COMPLEX_DEFINED_POST not defined!"
 #endif
 
 #ifndef CMAKE_IS_REALLY_FUN
-# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
+#error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
 #endif
 
 #if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE)
-# error Per-configuration directory-level definition not inherited.
+#error Per-configuration directory-level definition not inherited.
 #endif
 
 // ======================================================================
@@ -70,21 +69,18 @@ void cmPassed(const char* Message, const char* m2="")
 void TestAndRemoveFile(const char* filename)
 {
   struct stat st;
-  if(stat(filename, &st) < 0)
-    {
+  if (stat(filename, &st) < 0) {
     cmFailed("Could not find file: ", filename);
-    }
-  else
-    {
-    if (remove(filename) < 0)
-      {
-      cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
-      }
-    else
-      {
+  } else {
+    if (remove(filename) < 0) {
+      cmFailed("Unable to remove file. It does not imply that this test "
+               "failed, but it *will* be corrupted thereafter if this file is "
+               "not removed: ",
+               filename);
+    } else {
       cmPassed("Find and remove file: ", filename);
-      }
     }
+  }
 }
 
 // ======================================================================
@@ -92,14 +88,11 @@ void TestAndRemoveFile(const char* filename)
 void TestDir(const char* filename)
 {
   struct stat st;
-  if(stat(filename, &st) < 0 || !S_ISDIR(st.st_mode))
-    {
+  if (stat(filename, &st) < 0 || !S_ISDIR(st.st_mode)) {
     cmFailed("Could not find dir: ", filename);
-    }
-  else
-    {
+  } else {
     cmPassed("Find dir: ", filename);
-    }
+  }
 }
 
 // Here is a stupid function that tries to use std::string methods
@@ -113,7 +106,7 @@ void ForceStringUse()
   std::string cachetest = CACHE_TEST_VAR_INTERNAL;
   v.push_back(cachetest);
   v2 = v;
-  std::string x(5,'x');
+  std::string x(5, 'x');
   char buff[5];
   x.copy(buff, 1, 0);
   x[0] = 'a';
@@ -126,7 +119,6 @@ void ForceStringUse()
   copy = cachetest.substr(0, cachetest.size());
 }
 
-
 // defined in testcflags.c
 extern "C" int TestCFlags(char* m);
 extern "C" int TestTargetCompileFlags(char* m);
@@ -152,14 +144,11 @@ int main()
     cmFailed("Sub dir with same named source fails");
     }
 #endif
-  if(file1() != 1)
-    {
+  if (file1() != 1) {
     cmFailed("Call to file1 function from library failed.");
-    }
-  else
-    {
+  } else {
     cmPassed("Call to file1 function returned 1.");
-    }
+  }
 #ifndef COMPLEX_TARGET_FLAG
   cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES");
 #else
@@ -178,14 +167,11 @@ int main()
   cmFailed("CONDITIONAL_PARENTHESES did not work");
 #endif
 
-  if(file2() != 1)
-    {
+  if (file2() != 1) {
     cmFailed("Call to file2 function from library failed.");
-    }
-  else
-    {
+  } else {
     cmPassed("Call to file2 function returned 1.");
-    }
+  }
 #ifndef TEST_CXX_FLAGS
   cmFailed("CMake CMAKE_CXX_FLAGS is not being passed to the compiler!");
 #else
@@ -194,34 +180,28 @@ int main()
   std::string gen = CMAKE_GENERATOR;
   // visual studio is currently broken for c flags
   char msg[1024];
-  if(gen.find("Visual") == gen.npos)
-    {
+  if (gen.find("Visual") == gen.npos) {
 #ifdef TEST_C_FLAGS
-    cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
+    cmFailed(
+      "CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
 #else
     cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
 #endif
-    if(TestCFlags(msg))
-      {
-      cmPassed(
-        "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
-      }
-    else
-      {
+    if (TestCFlags(msg)) {
+      cmPassed("CMake CMAKE_C_FLAGS are being passed to c files and CXX flags "
+               "are not.");
+    } else {
       cmFailed(msg);
-      }
     }
-  if(TestTargetCompileFlags(msg))
-    {
+  }
+  if (TestTargetCompileFlags(msg)) {
     cmPassed(msg);
-    }
-  else
-    {
+  } else {
     cmFailed(msg);
-    }
+  }
 
-  // ----------------------------------------------------------------------
-  // Test ADD_DEFINITIONS
+// ----------------------------------------------------------------------
+// Test ADD_DEFINITIONS
 
 #ifndef CMAKE_IS_FUN
   cmFailed("CMake is not fun, so it is broken and should be fixed.");
@@ -229,38 +209,39 @@ int main()
   cmPassed("CMAKE_IS_FUN is defined.");
 #endif
 
-#if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4)
+#if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) &&   \
+  defined(CMAKE_ARGV4)
   cmPassed("Variable args for MACROs are working.");
 #else
   cmFailed("Variable args for MACROs are failing.");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test GET_SOURCE_FILE_PROPERTY for location
+// ----------------------------------------------------------------------
+// Test GET_SOURCE_FILE_PROPERTY for location
 #ifndef CMAKE_FOUND_ACXX
   cmFailed("CMake did not get the location of A.cxx correctly");
 #else
   cmPassed("CMake found A.cxx properly");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test GET_DIRECTORY_PROPERTY for parent
+// ----------------------------------------------------------------------
+// Test GET_DIRECTORY_PROPERTY for parent
 #ifndef CMAKE_FOUND_PARENT
   cmFailed("CMake did not get the location of the parent directory properly");
 #else
   cmPassed("CMake found the parent directory properly");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test GET_DIRECTORY_PROPERTY for listfiles
+// ----------------------------------------------------------------------
+// Test GET_DIRECTORY_PROPERTY for listfiles
 #ifndef CMAKE_FOUND_LISTFILE_STACK
   cmFailed("CMake did not get the listfile stack properly");
 #else
   cmPassed("CMake found the listfile stack properly");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test SET, VARIABLE_REQUIRES
+// ----------------------------------------------------------------------
+// Test SET, VARIABLE_REQUIRES
 
 #ifdef SHOULD_NOT_BE_DEFINED
   cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
@@ -282,7 +263,7 @@ int main()
 
 #ifndef ONE_VAR_IS_DEFINED
   cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
-         "ONE_VAR_IS_DEFINED is not defined.");
+           "ONE_VAR_IS_DEFINED is not defined.");
 #else
   cmPassed("ONE_VAR_IS_DEFINED is defined.");
 #endif
@@ -296,19 +277,16 @@ int main()
 #ifndef STRING_VAR
   cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
 #else
-  if(strcmp(STRING_VAR, "CMake is great") != 0)
-    {
+  if (strcmp(STRING_VAR, "CMake is great") != 0) {
     cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
-           STRING_VAR);
-    }
-  else
-    {
+             STRING_VAR);
+  } else {
     cmPassed("STRING_VAR == ", STRING_VAR);
-    }
+  }
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test various IF/ELSE combinations
+// ----------------------------------------------------------------------
+// Test various IF/ELSE combinations
 
 #ifdef SHOULD_NOT_BE_DEFINED_NOT
   cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined.");
@@ -401,7 +379,8 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_MATCHES2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_MATCHES2 is defined.");
 #endif
@@ -425,7 +404,8 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_COMMAND2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_COMMAND2 is defined.");
 #endif
@@ -455,13 +435,15 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_IS_DIRECTORY
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY is defined.");
 #endif
 
 #ifndef SHOULD_BE_DEFINED_IS_DIRECTORY2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY2 is defined.");
 #endif
@@ -521,7 +503,8 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_GREATER2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined.");
 #endif
@@ -545,164 +528,153 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_STRLESS2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined.");
 #endif
 
 #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER
-  cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined.");
+  cmFailed(
+    "IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined.");
 #else
   cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER is not defined.");
 #endif
 
 #ifndef SHOULD_BE_DEFINED_STRGREATER
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined.");
 #endif
 
 #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2
-  cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined.");
+  cmFailed(
+    "IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined.");
 #else
   cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined.");
 #endif
 
 #ifndef SHOULD_BE_DEFINED_STRGREATER2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined.");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test FOREACH
+// ----------------------------------------------------------------------
+// Test FOREACH
 
 #ifndef FOREACH_VAR1
   cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-         "FOREACH_VAR1 is not defined.");
+           "FOREACH_VAR1 is not defined.");
 #else
-  if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
-    {
+  if (strcmp(FOREACH_VAR1, "VALUE1") != 0) {
     cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-           "FOREACH_VAR1 == ", FOREACH_VAR1);
-    }
-  else
-    {
+             "FOREACH_VAR1 == ",
+             FOREACH_VAR1);
+  } else {
     cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
-    }
+  }
 #endif
 
 #ifndef FOREACH_VAR2
   cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-         "FOREACH_VAR2 is not defined.");
+           "FOREACH_VAR2 is not defined.");
 #else
-  if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
-    {
+  if (strcmp(FOREACH_VAR2, "VALUE2") != 0) {
     cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-           "FOREACH_VAR2 == ", FOREACH_VAR2);
-    }
-  else
-    {
+             "FOREACH_VAR2 == ",
+             FOREACH_VAR2);
+  } else {
     cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
-    }
+  }
 #endif
 
 #ifndef FOREACH_CONCAT
   cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-         "FOREACH_CONCAT is not defined.");
+           "FOREACH_CONCAT is not defined.");
 #else
-  if(strcmp(FOREACH_CONCAT, "abcdefg") != 0)
-    {
+  if (strcmp(FOREACH_CONCAT, "abcdefg") != 0) {
     cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-           "FOREACH_CONCAT == ", FOREACH_CONCAT);
-    }
-  else
-    {
+             "FOREACH_CONCAT == ",
+             FOREACH_CONCAT);
+  } else {
     cmPassed("FOREACH_CONCAT == ", FOREACH_CONCAT);
-    }
+  }
 #endif
 
   // ----------------------------------------------------------------------
   // Test WHILE
 
-  if(WHILE_VALUE != 1000)
-    {
+  if (WHILE_VALUE != 1000) {
     cmFailed("WHILE command is not working");
-    }
-  else
-    {
+  } else {
     cmPassed("WHILE command is working");
-    }
+  }
 
-  // ----------------------------------------------------------------------
-  // Test LOAD_CACHE
+// ----------------------------------------------------------------------
+// Test LOAD_CACHE
 
 #ifndef CACHE_TEST_VAR1
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR1 is not defined.");
+           "CACHE_TEST_VAR1 is not defined.");
 #else
-  if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
-    {
+  if (strcmp(CACHE_TEST_VAR1, "foo") != 0) {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
-    }
-  else
-    {
+             "CACHE_TEST_VAR1 == ",
+             CACHE_TEST_VAR1);
+  } else {
     cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
-    }
+  }
 #endif
 
 #ifndef CACHE_TEST_VAR2
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR2 is not defined.");
+           "CACHE_TEST_VAR2 is not defined.");
 #else
-  if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
-    {
+  if (strcmp(CACHE_TEST_VAR2, "bar") != 0) {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
-    }
-  else
-    {
+             "CACHE_TEST_VAR2 == ",
+             CACHE_TEST_VAR2);
+  } else {
     cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
-    }
+  }
 #endif
 
 #ifndef CACHE_TEST_VAR3
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR3 is not defined.");
+           "CACHE_TEST_VAR3 is not defined.");
 #else
-  if(strcmp(CACHE_TEST_VAR3, "1") != 0)
-    {
+  if (strcmp(CACHE_TEST_VAR3, "1") != 0) {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
-    }
-  else
-    {
+             "CACHE_TEST_VAR3 == ",
+             CACHE_TEST_VAR3);
+  } else {
     cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
-    }
+  }
 #endif
 
 #ifdef CACHE_TEST_VAR_EXCLUDED
-  cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
-         "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
+  cmFailed(
+    "the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
+    "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
 #else
   cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
 #endif
 
 #ifndef CACHE_TEST_VAR_INTERNAL
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR_INTERNAL is not defined.");
+           "CACHE_TEST_VAR_INTERNAL is not defined.");
 #else
   std::string cachetest = CACHE_TEST_VAR_INTERNAL;
-  if(cachetest != "bar")
-    {
+  if (cachetest != "bar") {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
-    }
-  else
-    {
+             "CACHE_TEST_VAR_INTERNAL == ",
+             CACHE_TEST_VAR_INTERNAL);
+  } else {
     cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
-    }
+  }
 #endif
 
   // ----------------------------------------------------------------------
@@ -751,34 +723,34 @@ int main()
 
   TestAndRemoveFile("Executable/Temp/complex-required.txt");
 
-  // ----------------------------------------------------------------------
-  // Test FIND_LIBRARY
+// ----------------------------------------------------------------------
+// Test FIND_LIBRARY
 
 #ifndef FIND_DUMMY_LIB
   cmFailed("the CONFIGURE_FILE command is broken, "
-         "FIND_DUMMY_LIB is not defined.");
+           "FIND_DUMMY_LIB is not defined.");
 #else
-  if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL)
-    {
+  if (strstr(FIND_DUMMY_LIB, "dummylib") == NULL) {
     cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, "
-           "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
-    }
-  else
-    {
+             "FIND_DUMMY_LIB == ",
+             FIND_DUMMY_LIB);
+  } else {
     cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
-    }
+  }
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test SET_SOURCE_FILES_PROPERTIES
+// ----------------------------------------------------------------------
+// Test SET_SOURCE_FILES_PROPERTIES
 
 #ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
-  cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
+  cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting "
+           "FILE_HAS_EXTRA_COMPILE_FLAGS flag");
 #else
-  cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
+  cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting "
+           "FILE_HAS_EXTRA_COMPILE_FLAGS flag");
 #endif
 
-#if 0  // Disable until implemented everywhere.
+#if 0 // Disable until implemented everywhere.
 #ifndef FILE_DEFINE_STRING
   cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
 #else
@@ -806,84 +778,72 @@ int main()
 #endif
 
 #ifndef FILE_COMPILE_FLAGS
-  cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined.");
+  cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not "
+           "defined.");
 #else
-  if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0)
-    {
-    cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ",
+  if (strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) {
+    cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is "
+             "broken. FILE_COMPILE_FLAGS == ",
              FILE_COMPILE_FLAGS);
-    }
-  else
-    {
-    cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS);
-    }
+  } else {
+    cmPassed(
+      "SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ",
+      FILE_COMPILE_FLAGS);
+  }
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test registry (win32)
+// ----------------------------------------------------------------------
+// Test registry (win32)
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #ifndef REGISTRY_TEST_PATH
-  cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
+  cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not "
+           "defined.");
 #else
   std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n";
-  if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
-    {
-    cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
+  if (stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) {
+    cmFailed("the 'read registry value' function or CONFIGURE_FILE command is "
+             "broken. REGISTRY_TEST_PATH == ",
              REGISTRY_TEST_PATH, " is not " BINARY_DIR "/registry_dir");
-    }
-  else
-    {
+  } else {
     cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
-    }
+  }
 #endif
 #endif // defined(_WIN32) && !defined(__CYGWIN__)
 
-  if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0)
-    {
+  if (strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) {
     cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 2.4");
-    }
-  else
-    {
+  } else {
     cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 2.4");
-    }
+  }
 
   // ----------------------------------------------------------------------
   // Test REMOVE command
-  if (strcmp("a;b;d",REMOVE_STRING) == 0)
-    {
+  if (strcmp("a;b;d", REMOVE_STRING) == 0) {
     cmPassed("REMOVE is working");
-    }
-  else
-    {
+  } else {
     cmFailed("REMOVE is not working");
-    }
+  }
 
   // ----------------------------------------------------------------------
   // Test SEPARATE_ARGUMENTS
-  if(strcmp("a;b;c", TEST_SEP) == 0)
-    {
+  if (strcmp("a;b;c", TEST_SEP) == 0) {
     cmPassed("SEPARATE_ARGUMENTS is working");
-    }
-  else
-    {
+  } else {
     cmFailed("SEPARATE_ARGUMENTS is not working");
-    }
+  }
 
   // ----------------------------------------------------------------------
   // Test Escape Quotes
-  if(strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0)
-    {
+  if (strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0) {
     cmPassed("ESCAPE_QUOTES is working");
-    }
-  else
-    {
+  } else {
     cmFailed("ESCAPE_QUOTES is not working");
-    }
-
+  }
 
-  // ----------------------------------------------------------------------
-  // Test if IF command inside a FOREACH works.
-#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
+// ----------------------------------------------------------------------
+// Test if IF command inside a FOREACH works.
+#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) &&                               \
+  !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
   cmPassed("IF inside a FOREACH block works");
 #else
   cmFailed("IF inside a FOREACH block is broken");
@@ -894,22 +854,16 @@ int main()
 #else
   cmFailed("Generated header included by non-generated source failed.");
 #endif
-  if(SHOULD_BE_ZERO == 0)
-    {
+  if (SHOULD_BE_ZERO == 0) {
     cmPassed("cmakedefine01 is working for 0");
-    }
-  else
-    {
+  } else {
     cmFailed("cmakedefine01 is not working for 0");
-    }
-  if(SHOULD_BE_ONE == 1)
-    {
+  }
+  if (SHOULD_BE_ONE == 1) {
     cmPassed("cmakedefine01 is working for 1");
-    }
-  else
-    {
+  } else {
     cmFailed("cmakedefine01 is not working for 1");
-    }
+  }
 #ifdef FORCE_TEST
   cmFailed("CMake SET CACHE FORCE");
 #else
@@ -917,14 +871,11 @@ int main()
 #endif
 
 #ifdef COMPLEX_TEST_LINK_STATIC
-  if(TestLinkGetType())
-    {
+  if (TestLinkGetType()) {
     cmPassed("Link to static over shared worked.");
-    }
-  else
-    {
+  } else {
     cmFailed("Link to static over shared failed.");
-    }
+  }
 #endif
 
 #if defined(A_VALUE) && A_VALUE == 10
@@ -937,10 +888,9 @@ int main()
   // Summary
 
   std::cout << "Passed: " << cm_passed << "\n";
-  if(cm_failed)
-    {
+  if (cm_failed) {
     std::cout << "Failed: " << cm_failed << "\n";
     return cm_failed;
-    }
+  }
   return 0;
 }
diff --git a/Tests/Complex/Executable/complex.file.cxx b/Tests/Complex/Executable/complex.file.cxx
index e873fa6..cfba9ed 100644
--- a/Tests/Complex/Executable/complex.file.cxx
+++ b/Tests/Complex/Executable/complex.file.cxx
@@ -2,7 +2,7 @@
 #include "cmMissingHeader.h"
 #endif
 
-int main(int , char**)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/Complex/Executable/notInAllExe.cxx b/Tests/Complex/Executable/notInAllExe.cxx
index 70275cd..2685073 100644
--- a/Tests/Complex/Executable/notInAllExe.cxx
+++ b/Tests/Complex/Executable/notInAllExe.cxx
@@ -6,5 +6,5 @@ int main()
 }
 
 #if 1
-# error "This target should not be compiled by ALL."
+#error "This target should not be compiled by ALL."
 #endif
diff --git a/Tests/Complex/Executable/testSystemDir.cxx b/Tests/Complex/Executable/testSystemDir.cxx
index e4815c6..4bb2db4 100644
--- a/Tests/Complex/Executable/testSystemDir.cxx
+++ b/Tests/Complex/Executable/testSystemDir.cxx
@@ -1,3 +1,6 @@
 #include <testSystemDir.h>
 
-int main() { return foo(); }
+int main()
+{
+  return foo();
+}
diff --git a/Tests/Complex/Executable/testcflags.c b/Tests/Complex/Executable/testcflags.c
index 6c2dd5d..e452b06 100644
--- a/Tests/Complex/Executable/testcflags.c
+++ b/Tests/Complex/Executable/testcflags.c
@@ -12,12 +12,12 @@ int TestTargetCompileFlags(char* m)
 
 int TestCFlags(char* m)
 {
-  /* TEST_CXX_FLAGS should not be defined in a c file */
+/* TEST_CXX_FLAGS should not be defined in a c file */
 #ifdef TEST_CXX_FLAGS
   strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file.");
   return 0;
 #endif
-  /* TEST_C_FLAGS should be defined in a c file */
+/* TEST_C_FLAGS should be defined in a c file */
 #ifndef TEST_C_FLAGS
   strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file.");
   return 0;
diff --git a/Tests/Complex/Library/SystemDir/testSystemDir.h b/Tests/Complex/Library/SystemDir/testSystemDir.h
index 73be353..074ff75 100644
--- a/Tests/Complex/Library/SystemDir/testSystemDir.h
+++ b/Tests/Complex/Library/SystemDir/testSystemDir.h
@@ -1,2 +1,5 @@
 // Purposely leave off the return type to create a warning.
-foo() { return 0; }
+foo()
+{
+  return 0;
+}
diff --git a/Tests/Complex/Library/create_file.cxx b/Tests/Complex/Library/create_file.cxx
index 050ed0b..62a1975 100644
--- a/Tests/Complex/Library/create_file.cxx
+++ b/Tests/Complex/Library/create_file.cxx
@@ -1,26 +1,23 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
+  if (argc < 2) {
     fprintf(stderr, "Missing name of file to create.\n");
     return EXIT_FAILURE;
-    }
+  }
 
-  FILE *stream = fopen(argv[1], "w");
-  if(stream == NULL)
-    {
+  FILE* stream = fopen(argv[1], "w");
+  if (stream == NULL) {
     fprintf(stderr, "Unable to open %s for writing!\n", argv[1]);
     return EXIT_FAILURE;
-    }
+  }
 
-  if(fclose(stream))
-    {
+  if (fclose(stream)) {
     fprintf(stderr, "Unable to close %s!\n", argv[1]);
     return EXIT_FAILURE;
-    }
+  }
 
   fprintf(stdout, ">> Creating %s!\n", argv[1]);
 
diff --git a/Tests/Complex/Library/notInAllLib.cxx b/Tests/Complex/Library/notInAllLib.cxx
index 5d928f4..e66ea05 100644
--- a/Tests/Complex/Library/notInAllLib.cxx
+++ b/Tests/Complex/Library/notInAllLib.cxx
@@ -1,5 +1,8 @@
-int notInAllLibFunc() { return 0; }
+int notInAllLibFunc()
+{
+  return 0;
+}
 
 #if 1
-# error "This target should not be compiled by ALL."
+#error "This target should not be compiled by ALL."
 #endif
diff --git a/Tests/Complex/Library/sharedFile.h b/Tests/Complex/Library/sharedFile.h
index 65ac2e2..e32fcb7 100644
--- a/Tests/Complex/Library/sharedFile.h
+++ b/Tests/Complex/Library/sharedFile.h
@@ -1,8 +1,8 @@
 #if defined(_WIN32) || defined(WIN32) /* Win32 version */
 #ifdef CMakeTestLibraryShared_EXPORTS
-#  define CMakeTest_EXPORT __declspec(dllexport)
+#define CMakeTest_EXPORT __declspec(dllexport)
 #else
-#  define CMakeTest_EXPORT __declspec(dllimport)
+#define CMakeTest_EXPORT __declspec(dllimport)
 #endif
 #else
 /* unix needs nothing */
diff --git a/Tests/Complex/Library/testConly.h b/Tests/Complex/Library/testConly.h
index ba84589..9b0fb73 100644
--- a/Tests/Complex/Library/testConly.h
+++ b/Tests/Complex/Library/testConly.h
@@ -1,8 +1,8 @@
 #if defined(_WIN32) || defined(WIN32) /* Win32 version */
 #ifdef CMakeTestCLibraryShared_EXPORTS
-#  define CMakeTest_EXPORT __declspec(dllexport)
+#define CMakeTest_EXPORT __declspec(dllexport)
 #else
-#  define CMakeTest_EXPORT __declspec(dllimport)
+#define CMakeTest_EXPORT __declspec(dllimport)
 #endif
 #else
 /* unix needs nothing */
@@ -10,4 +10,3 @@
 #endif
 
 CMakeTest_EXPORT int CsharedFunction();
-
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index 3b73e70..2d92809 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -2,6 +2,7 @@
 # A more complex test case
 #
 cmake_minimum_required(VERSION 2.4)
+cmake_policy(SET CMP0054 NEW)
 project (Complex)
 
 # Try setting a new policy.  The IF test is for coverage.
@@ -401,6 +402,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
 endif ()
 
+# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+  set(CMAKE_CXX_STANDARD 11)
+endif()
+
 #
 # Create the libs and the main exe
 #
diff --git a/Tests/ComplexOneConfig/Executable/A.h b/Tests/ComplexOneConfig/Executable/A.h
index 25c45fc..3503719 100644
--- a/Tests/ComplexOneConfig/Executable/A.h
+++ b/Tests/ComplexOneConfig/Executable/A.h
@@ -1,4 +1,7 @@
 // This header should not be compiled directly but through inclusion
 // in A.cxx through A.hh.
 extern int A();
-int A() { return 10; }
+int A()
+{
+  return 10;
+}
diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
index b2307b2..4897b48 100644
--- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
@@ -146,7 +146,8 @@ add_dependencies(notInAllCustom notInAllExe)
 #
 add_subdirectory(Temp)
 
-if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
+if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX
+   AND NOT XCODE) # XCODE is excluded due to #15687
   add_executable(testSystemDir testSystemDir.cxx)
   set_target_properties(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror")
 endif()
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index ec222a5..5f79ac0 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -1,29 +1,28 @@
+#include "Aout.h"
+#include "ExtraSources/file1.h"
 #include "cmTestConfigure.h"
 #include "cmTestConfigureEscape.h"
 #include "cmTestGeneratedHeader.h"
 #include "cmVersion.h"
-#include "ExtraSources/file1.h"
-#include "Aout.h"
 #include "file2.h"
 #include "sharedFile.h"
 extern "C" {
 #include "testConly.h"
 }
-#include <vector>
-#include <string>
 #include <iostream>
 #include <string.h>
+#include <string>
+#include <vector>
 
 #include <stdio.h>
 #include <sys/stat.h>
 #if !defined(S_ISDIR)
-# define S_ISDIR(mode) ((mode) & _S_IFDIR)
+#define S_ISDIR(mode) ((mode)&_S_IFDIR)
 #endif
 
 #ifdef COMPLEX_TEST_LINK_STATIC
-extern "C"
-{
-  int TestLinkGetType();
+extern "C" {
+int TestLinkGetType();
 }
 #endif
 
@@ -31,7 +30,7 @@ int cm_passed = 0;
 int cm_failed = 0;
 // ======================================================================
 
-void cmFailed(const char* Message, const char* m2= "", const char* m3 = "")
+void cmFailed(const char* Message, const char* m2 = "", const char* m3 = "")
 {
   std::cout << "FAILED: " << Message << m2 << m3 << "\n";
   cm_failed++;
@@ -39,30 +38,30 @@ void cmFailed(const char* Message, const char* m2= "", const char* m3 = "")
 
 // ======================================================================
 
-void cmPassed(const char* Message, const char* m2="")
+void cmPassed(const char* Message, const char* m2 = "")
 {
   std::cout << "Passed: " << Message << m2 << "\n";
   cm_passed++;
 }
 
 #ifndef COMPLEX_DEFINED_PRE
-# error "COMPLEX_DEFINED_PRE not defined!"
+#error "COMPLEX_DEFINED_PRE not defined!"
 #endif
 
 #ifdef COMPLEX_DEFINED
-# error "COMPLEX_DEFINED is defined but it should not!"
+#error "COMPLEX_DEFINED is defined but it should not!"
 #endif
 
 #ifndef COMPLEX_DEFINED_POST
-# error "COMPLEX_DEFINED_POST not defined!"
+#error "COMPLEX_DEFINED_POST not defined!"
 #endif
 
 #ifndef CMAKE_IS_REALLY_FUN
-# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
+#error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
 #endif
 
 #if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE)
-# error Per-configuration directory-level definition not inherited.
+#error Per-configuration directory-level definition not inherited.
 #endif
 
 // ======================================================================
@@ -70,21 +69,18 @@ void cmPassed(const char* Message, const char* m2="")
 void TestAndRemoveFile(const char* filename)
 {
   struct stat st;
-  if(stat(filename, &st) < 0)
-    {
+  if (stat(filename, &st) < 0) {
     cmFailed("Could not find file: ", filename);
-    }
-  else
-    {
-    if (remove(filename) < 0)
-      {
-      cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
-      }
-    else
-      {
+  } else {
+    if (remove(filename) < 0) {
+      cmFailed("Unable to remove file. It does not imply that this test "
+               "failed, but it *will* be corrupted thereafter if this file is "
+               "not removed: ",
+               filename);
+    } else {
       cmPassed("Find and remove file: ", filename);
-      }
     }
+  }
 }
 
 // ======================================================================
@@ -92,14 +88,11 @@ void TestAndRemoveFile(const char* filename)
 void TestDir(const char* filename)
 {
   struct stat st;
-  if(stat(filename, &st) < 0 || !S_ISDIR(st.st_mode))
-    {
+  if (stat(filename, &st) < 0 || !S_ISDIR(st.st_mode)) {
     cmFailed("Could not find dir: ", filename);
-    }
-  else
-    {
+  } else {
     cmPassed("Find dir: ", filename);
-    }
+  }
 }
 
 // Here is a stupid function that tries to use std::string methods
@@ -113,7 +106,7 @@ void ForceStringUse()
   std::string cachetest = CACHE_TEST_VAR_INTERNAL;
   v.push_back(cachetest);
   v2 = v;
-  std::string x(5,'x');
+  std::string x(5, 'x');
   char buff[5];
   x.copy(buff, 1, 0);
   x[0] = 'a';
@@ -126,7 +119,6 @@ void ForceStringUse()
   copy = cachetest.substr(0, cachetest.size());
 }
 
-
 // defined in testcflags.c
 extern "C" int TestCFlags(char* m);
 extern "C" int TestTargetCompileFlags(char* m);
@@ -152,14 +144,11 @@ int main()
     cmFailed("Sub dir with same named source fails");
     }
 #endif
-  if(file1() != 1)
-    {
+  if (file1() != 1) {
     cmFailed("Call to file1 function from library failed.");
-    }
-  else
-    {
+  } else {
     cmPassed("Call to file1 function returned 1.");
-    }
+  }
 #ifndef COMPLEX_TARGET_FLAG
   cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES");
 #else
@@ -178,14 +167,11 @@ int main()
   cmFailed("CONDITIONAL_PARENTHESES did not work");
 #endif
 
-  if(file2() != 1)
-    {
+  if (file2() != 1) {
     cmFailed("Call to file2 function from library failed.");
-    }
-  else
-    {
+  } else {
     cmPassed("Call to file2 function returned 1.");
-    }
+  }
 #ifndef TEST_CXX_FLAGS
   cmFailed("CMake CMAKE_CXX_FLAGS is not being passed to the compiler!");
 #else
@@ -194,34 +180,28 @@ int main()
   std::string gen = CMAKE_GENERATOR;
   // visual studio is currently broken for c flags
   char msg[1024];
-  if(gen.find("Visual") == gen.npos)
-    {
+  if (gen.find("Visual") == gen.npos) {
 #ifdef TEST_C_FLAGS
-    cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
+    cmFailed(
+      "CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
 #else
     cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
 #endif
-    if(TestCFlags(msg))
-      {
-      cmPassed(
-        "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
-      }
-    else
-      {
+    if (TestCFlags(msg)) {
+      cmPassed("CMake CMAKE_C_FLAGS are being passed to c files and CXX flags "
+               "are not.");
+    } else {
       cmFailed(msg);
-      }
     }
-  if(TestTargetCompileFlags(msg))
-    {
+  }
+  if (TestTargetCompileFlags(msg)) {
     cmPassed(msg);
-    }
-  else
-    {
+  } else {
     cmFailed(msg);
-    }
+  }
 
-  // ----------------------------------------------------------------------
-  // Test ADD_DEFINITIONS
+// ----------------------------------------------------------------------
+// Test ADD_DEFINITIONS
 
 #ifndef CMAKE_IS_FUN
   cmFailed("CMake is not fun, so it is broken and should be fixed.");
@@ -229,38 +209,39 @@ int main()
   cmPassed("CMAKE_IS_FUN is defined.");
 #endif
 
-#if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) && defined(CMAKE_ARGV4)
+#if defined(CMAKE_ARGV1) && defined(CMAKE_ARGV2) && defined(CMAKE_ARGV3) &&   \
+  defined(CMAKE_ARGV4)
   cmPassed("Variable args for MACROs are working.");
 #else
   cmFailed("Variable args for MACROs are failing.");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test GET_SOURCE_FILE_PROPERTY for location
+// ----------------------------------------------------------------------
+// Test GET_SOURCE_FILE_PROPERTY for location
 #ifndef CMAKE_FOUND_ACXX
   cmFailed("CMake did not get the location of A.cxx correctly");
 #else
   cmPassed("CMake found A.cxx properly");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test GET_DIRECTORY_PROPERTY for parent
+// ----------------------------------------------------------------------
+// Test GET_DIRECTORY_PROPERTY for parent
 #ifndef CMAKE_FOUND_PARENT
   cmFailed("CMake did not get the location of the parent directory properly");
 #else
   cmPassed("CMake found the parent directory properly");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test GET_DIRECTORY_PROPERTY for listfiles
+// ----------------------------------------------------------------------
+// Test GET_DIRECTORY_PROPERTY for listfiles
 #ifndef CMAKE_FOUND_LISTFILE_STACK
   cmFailed("CMake did not get the listfile stack properly");
 #else
   cmPassed("CMake found the listfile stack properly");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test SET, VARIABLE_REQUIRES
+// ----------------------------------------------------------------------
+// Test SET, VARIABLE_REQUIRES
 
 #ifdef SHOULD_NOT_BE_DEFINED
   cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
@@ -282,7 +263,7 @@ int main()
 
 #ifndef ONE_VAR_IS_DEFINED
   cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
-         "ONE_VAR_IS_DEFINED is not defined.");
+           "ONE_VAR_IS_DEFINED is not defined.");
 #else
   cmPassed("ONE_VAR_IS_DEFINED is defined.");
 #endif
@@ -296,19 +277,16 @@ int main()
 #ifndef STRING_VAR
   cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
 #else
-  if(strcmp(STRING_VAR, "CMake is great") != 0)
-    {
+  if (strcmp(STRING_VAR, "CMake is great") != 0) {
     cmFailed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
-           STRING_VAR);
-    }
-  else
-    {
+             STRING_VAR);
+  } else {
     cmPassed("STRING_VAR == ", STRING_VAR);
-    }
+  }
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test various IF/ELSE combinations
+// ----------------------------------------------------------------------
+// Test various IF/ELSE combinations
 
 #ifdef SHOULD_NOT_BE_DEFINED_NOT
   cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined.");
@@ -401,7 +379,8 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_MATCHES2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_MATCHES2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_MATCHES2 is defined.");
 #endif
@@ -425,7 +404,8 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_COMMAND2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_COMMAND2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_COMMAND2 is defined.");
 #endif
@@ -455,13 +435,15 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_IS_DIRECTORY
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY is defined.");
 #endif
 
 #ifndef SHOULD_BE_DEFINED_IS_DIRECTORY2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_IS_DIRECTORY2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_IS_DIRECTORY2 is defined.");
 #endif
@@ -521,7 +503,8 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_GREATER2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_GREATER2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_GREATER2 is defined.");
 #endif
@@ -545,164 +528,153 @@ int main()
 #endif
 
 #ifndef SHOULD_BE_DEFINED_STRLESS2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_STRLESS2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_STRLESS2 is defined.");
 #endif
 
 #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER
-  cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined.");
+  cmFailed(
+    "IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER is defined.");
 #else
   cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER is not defined.");
 #endif
 
 #ifndef SHOULD_BE_DEFINED_STRGREATER
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_STRGREATER is defined.");
 #endif
 
 #ifdef SHOULD_NOT_BE_DEFINED_STRGREATER2
-  cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined.");
+  cmFailed(
+    "IF or SET is broken, SHOULD_NOT_BE_DEFINED_STRGREATER2 is defined.");
 #else
   cmPassed("SHOULD_NOT_BE_DEFINED_STRGREATER2 is not defined.");
 #endif
 
 #ifndef SHOULD_BE_DEFINED_STRGREATER2
-  cmFailed("IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n");
+  cmFailed(
+    "IF or SET is broken, SHOULD_BE_DEFINED_STRGREATER2 is not defined.\n");
 #else
   cmPassed("SHOULD_BE_DEFINED_STRGREATER2 is defined.");
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test FOREACH
+// ----------------------------------------------------------------------
+// Test FOREACH
 
 #ifndef FOREACH_VAR1
   cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-         "FOREACH_VAR1 is not defined.");
+           "FOREACH_VAR1 is not defined.");
 #else
-  if(strcmp(FOREACH_VAR1, "VALUE1") != 0)
-    {
+  if (strcmp(FOREACH_VAR1, "VALUE1") != 0) {
     cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-           "FOREACH_VAR1 == ", FOREACH_VAR1);
-    }
-  else
-    {
+             "FOREACH_VAR1 == ",
+             FOREACH_VAR1);
+  } else {
     cmPassed("FOREACH_VAR1 == ", FOREACH_VAR1);
-    }
+  }
 #endif
 
 #ifndef FOREACH_VAR2
   cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-         "FOREACH_VAR2 is not defined.");
+           "FOREACH_VAR2 is not defined.");
 #else
-  if(strcmp(FOREACH_VAR2, "VALUE2") != 0)
-    {
+  if (strcmp(FOREACH_VAR2, "VALUE2") != 0) {
     cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-           "FOREACH_VAR2 == ", FOREACH_VAR2);
-    }
-  else
-    {
+             "FOREACH_VAR2 == ",
+             FOREACH_VAR2);
+  } else {
     cmPassed("FOREACH_VAR2 == ", FOREACH_VAR2);
-    }
+  }
 #endif
 
 #ifndef FOREACH_CONCAT
   cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-         "FOREACH_CONCAT is not defined.");
+           "FOREACH_CONCAT is not defined.");
 #else
-  if(strcmp(FOREACH_CONCAT, "abcdefg") != 0)
-    {
+  if (strcmp(FOREACH_CONCAT, "abcdefg") != 0) {
     cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
-           "FOREACH_CONCAT == ", FOREACH_CONCAT);
-    }
-  else
-    {
+             "FOREACH_CONCAT == ",
+             FOREACH_CONCAT);
+  } else {
     cmPassed("FOREACH_CONCAT == ", FOREACH_CONCAT);
-    }
+  }
 #endif
 
   // ----------------------------------------------------------------------
   // Test WHILE
 
-  if(WHILE_VALUE != 1000)
-    {
+  if (WHILE_VALUE != 1000) {
     cmFailed("WHILE command is not working");
-    }
-  else
-    {
+  } else {
     cmPassed("WHILE command is working");
-    }
+  }
 
-  // ----------------------------------------------------------------------
-  // Test LOAD_CACHE
+// ----------------------------------------------------------------------
+// Test LOAD_CACHE
 
 #ifndef CACHE_TEST_VAR1
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR1 is not defined.");
+           "CACHE_TEST_VAR1 is not defined.");
 #else
-  if(strcmp(CACHE_TEST_VAR1, "foo") != 0)
-    {
+  if (strcmp(CACHE_TEST_VAR1, "foo") != 0) {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
-    }
-  else
-    {
+             "CACHE_TEST_VAR1 == ",
+             CACHE_TEST_VAR1);
+  } else {
     cmPassed("CACHE_TEST_VAR1 == ", CACHE_TEST_VAR1);
-    }
+  }
 #endif
 
 #ifndef CACHE_TEST_VAR2
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR2 is not defined.");
+           "CACHE_TEST_VAR2 is not defined.");
 #else
-  if(strcmp(CACHE_TEST_VAR2, "bar") != 0)
-    {
+  if (strcmp(CACHE_TEST_VAR2, "bar") != 0) {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
-    }
-  else
-    {
+             "CACHE_TEST_VAR2 == ",
+             CACHE_TEST_VAR2);
+  } else {
     cmPassed("CACHE_TEST_VAR2 == ", CACHE_TEST_VAR2);
-    }
+  }
 #endif
 
 #ifndef CACHE_TEST_VAR3
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR3 is not defined.");
+           "CACHE_TEST_VAR3 is not defined.");
 #else
-  if(strcmp(CACHE_TEST_VAR3, "1") != 0)
-    {
+  if (strcmp(CACHE_TEST_VAR3, "1") != 0) {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
-    }
-  else
-    {
+             "CACHE_TEST_VAR3 == ",
+             CACHE_TEST_VAR3);
+  } else {
     cmPassed("CACHE_TEST_VAR3 == ", CACHE_TEST_VAR3);
-    }
+  }
 #endif
 
 #ifdef CACHE_TEST_VAR_EXCLUDED
-  cmFailed("the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
-         "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
+  cmFailed(
+    "the LOAD_CACHE or CONFIGURE_FILE command or cmakedefine is broken, "
+    "CACHE_TEST_VAR_EXCLUDED is defined (should not have been loaded).");
 #else
   cmPassed("CACHE_TEST_VAR_EXCLUDED is not defined.");
 #endif
 
 #ifndef CACHE_TEST_VAR_INTERNAL
   cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-         "CACHE_TEST_VAR_INTERNAL is not defined.");
+           "CACHE_TEST_VAR_INTERNAL is not defined.");
 #else
   std::string cachetest = CACHE_TEST_VAR_INTERNAL;
-  if(cachetest != "bar")
-    {
+  if (cachetest != "bar") {
     cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
-           "CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
-    }
-  else
-    {
+             "CACHE_TEST_VAR_INTERNAL == ",
+             CACHE_TEST_VAR_INTERNAL);
+  } else {
     cmPassed("CACHE_TEST_VAR_INTERNAL == ", CACHE_TEST_VAR_INTERNAL);
-    }
+  }
 #endif
 
   // ----------------------------------------------------------------------
@@ -751,34 +723,34 @@ int main()
 
   TestAndRemoveFile("Executable/Temp/complex-required.txt");
 
-  // ----------------------------------------------------------------------
-  // Test FIND_LIBRARY
+// ----------------------------------------------------------------------
+// Test FIND_LIBRARY
 
 #ifndef FIND_DUMMY_LIB
   cmFailed("the CONFIGURE_FILE command is broken, "
-         "FIND_DUMMY_LIB is not defined.");
+           "FIND_DUMMY_LIB is not defined.");
 #else
-  if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL)
-    {
+  if (strstr(FIND_DUMMY_LIB, "dummylib") == NULL) {
     cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, "
-           "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
-    }
-  else
-    {
+             "FIND_DUMMY_LIB == ",
+             FIND_DUMMY_LIB);
+  } else {
     cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB);
-    }
+  }
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test SET_SOURCE_FILES_PROPERTIES
+// ----------------------------------------------------------------------
+// Test SET_SOURCE_FILES_PROPERTIES
 
 #ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
-  cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
+  cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting "
+           "FILE_HAS_EXTRA_COMPILE_FLAGS flag");
 #else
-  cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag");
+  cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting "
+           "FILE_HAS_EXTRA_COMPILE_FLAGS flag");
 #endif
 
-#if 0  // Disable until implemented everywhere.
+#if 0 // Disable until implemented everywhere.
 #ifndef FILE_DEFINE_STRING
   cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
 #else
@@ -806,84 +778,72 @@ int main()
 #endif
 
 #ifndef FILE_COMPILE_FLAGS
-  cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined.");
+  cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not "
+           "defined.");
 #else
-  if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0)
-    {
-    cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ",
+  if (strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) {
+    cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is "
+             "broken. FILE_COMPILE_FLAGS == ",
              FILE_COMPILE_FLAGS);
-    }
-  else
-    {
-    cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS);
-    }
+  } else {
+    cmPassed(
+      "SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ",
+      FILE_COMPILE_FLAGS);
+  }
 #endif
 
-  // ----------------------------------------------------------------------
-  // Test registry (win32)
+// ----------------------------------------------------------------------
+// Test registry (win32)
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #ifndef REGISTRY_TEST_PATH
-  cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined.");
+  cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not "
+           "defined.");
 #else
   std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n";
-  if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0)
-    {
-    cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ",
+  if (stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) {
+    cmFailed("the 'read registry value' function or CONFIGURE_FILE command is "
+             "broken. REGISTRY_TEST_PATH == ",
              REGISTRY_TEST_PATH, " is not " BINARY_DIR "/registry_dir");
-    }
-  else
-    {
+  } else {
     cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
-    }
+  }
 #endif
 #endif // defined(_WIN32) && !defined(__CYGWIN__)
 
-  if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0)
-    {
+  if (strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) {
     cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 2.4");
-    }
-  else
-    {
+  } else {
     cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 2.4");
-    }
+  }
 
   // ----------------------------------------------------------------------
   // Test REMOVE command
-  if (strcmp("a;b;d",REMOVE_STRING) == 0)
-    {
+  if (strcmp("a;b;d", REMOVE_STRING) == 0) {
     cmPassed("REMOVE is working");
-    }
-  else
-    {
+  } else {
     cmFailed("REMOVE is not working");
-    }
+  }
 
   // ----------------------------------------------------------------------
   // Test SEPARATE_ARGUMENTS
-  if(strcmp("a;b;c", TEST_SEP) == 0)
-    {
+  if (strcmp("a;b;c", TEST_SEP) == 0) {
     cmPassed("SEPARATE_ARGUMENTS is working");
-    }
-  else
-    {
+  } else {
     cmFailed("SEPARATE_ARGUMENTS is not working");
-    }
+  }
 
   // ----------------------------------------------------------------------
   // Test Escape Quotes
-  if(strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0)
-    {
+  if (strcmp("\"hello world\"", STRING_WITH_QUOTES) == 0) {
     cmPassed("ESCAPE_QUOTES is working");
-    }
-  else
-    {
+  } else {
     cmFailed("ESCAPE_QUOTES is not working");
-    }
-
+  }
 
-  // ----------------------------------------------------------------------
-  // Test if IF command inside a FOREACH works.
-#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) && !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
+// ----------------------------------------------------------------------
+// Test if IF command inside a FOREACH works.
+#if defined(IF_INSIDE_FOREACH_THEN_EXECUTED) &&                               \
+  !defined(IF_INSIDE_FOREACH_ELSE_EXECUTED)
   cmPassed("IF inside a FOREACH block works");
 #else
   cmFailed("IF inside a FOREACH block is broken");
@@ -894,22 +854,16 @@ int main()
 #else
   cmFailed("Generated header included by non-generated source failed.");
 #endif
-  if(SHOULD_BE_ZERO == 0)
-    {
+  if (SHOULD_BE_ZERO == 0) {
     cmPassed("cmakedefine01 is working for 0");
-    }
-  else
-    {
+  } else {
     cmFailed("cmakedefine01 is not working for 0");
-    }
-  if(SHOULD_BE_ONE == 1)
-    {
+  }
+  if (SHOULD_BE_ONE == 1) {
     cmPassed("cmakedefine01 is working for 1");
-    }
-  else
-    {
+  } else {
     cmFailed("cmakedefine01 is not working for 1");
-    }
+  }
 #ifdef FORCE_TEST
   cmFailed("CMake SET CACHE FORCE");
 #else
@@ -917,14 +871,11 @@ int main()
 #endif
 
 #ifdef COMPLEX_TEST_LINK_STATIC
-  if(TestLinkGetType())
-    {
+  if (TestLinkGetType()) {
     cmPassed("Link to static over shared worked.");
-    }
-  else
-    {
+  } else {
     cmFailed("Link to static over shared failed.");
-    }
+  }
 #endif
 
 #if defined(A_VALUE) && A_VALUE == 10
@@ -937,10 +888,9 @@ int main()
   // Summary
 
   std::cout << "Passed: " << cm_passed << "\n";
-  if(cm_failed)
-    {
+  if (cm_failed) {
     std::cout << "Failed: " << cm_failed << "\n";
     return cm_failed;
-    }
+  }
   return 0;
 }
diff --git a/Tests/ComplexOneConfig/Executable/complex.file.cxx b/Tests/ComplexOneConfig/Executable/complex.file.cxx
index e873fa6..cfba9ed 100644
--- a/Tests/ComplexOneConfig/Executable/complex.file.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.file.cxx
@@ -2,7 +2,7 @@
 #include "cmMissingHeader.h"
 #endif
 
-int main(int , char**)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx
index 70275cd..2685073 100644
--- a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx
+++ b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx
@@ -6,5 +6,5 @@ int main()
 }
 
 #if 1
-# error "This target should not be compiled by ALL."
+#error "This target should not be compiled by ALL."
 #endif
diff --git a/Tests/ComplexOneConfig/Executable/testSystemDir.cxx b/Tests/ComplexOneConfig/Executable/testSystemDir.cxx
index e4815c6..4bb2db4 100644
--- a/Tests/ComplexOneConfig/Executable/testSystemDir.cxx
+++ b/Tests/ComplexOneConfig/Executable/testSystemDir.cxx
@@ -1,3 +1,6 @@
 #include <testSystemDir.h>
 
-int main() { return foo(); }
+int main()
+{
+  return foo();
+}
diff --git a/Tests/ComplexOneConfig/Executable/testcflags.c b/Tests/ComplexOneConfig/Executable/testcflags.c
index 6c2dd5d..e452b06 100644
--- a/Tests/ComplexOneConfig/Executable/testcflags.c
+++ b/Tests/ComplexOneConfig/Executable/testcflags.c
@@ -12,12 +12,12 @@ int TestTargetCompileFlags(char* m)
 
 int TestCFlags(char* m)
 {
-  /* TEST_CXX_FLAGS should not be defined in a c file */
+/* TEST_CXX_FLAGS should not be defined in a c file */
 #ifdef TEST_CXX_FLAGS
   strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file.");
   return 0;
 #endif
-  /* TEST_C_FLAGS should be defined in a c file */
+/* TEST_C_FLAGS should be defined in a c file */
 #ifndef TEST_C_FLAGS
   strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file.");
   return 0;
diff --git a/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h b/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h
index 73be353..074ff75 100644
--- a/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h
+++ b/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h
@@ -1,2 +1,5 @@
 // Purposely leave off the return type to create a warning.
-foo() { return 0; }
+foo()
+{
+  return 0;
+}
diff --git a/Tests/ComplexOneConfig/Library/create_file.cxx b/Tests/ComplexOneConfig/Library/create_file.cxx
index 050ed0b..62a1975 100644
--- a/Tests/ComplexOneConfig/Library/create_file.cxx
+++ b/Tests/ComplexOneConfig/Library/create_file.cxx
@@ -1,26 +1,23 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
+  if (argc < 2) {
     fprintf(stderr, "Missing name of file to create.\n");
     return EXIT_FAILURE;
-    }
+  }
 
-  FILE *stream = fopen(argv[1], "w");
-  if(stream == NULL)
-    {
+  FILE* stream = fopen(argv[1], "w");
+  if (stream == NULL) {
     fprintf(stderr, "Unable to open %s for writing!\n", argv[1]);
     return EXIT_FAILURE;
-    }
+  }
 
-  if(fclose(stream))
-    {
+  if (fclose(stream)) {
     fprintf(stderr, "Unable to close %s!\n", argv[1]);
     return EXIT_FAILURE;
-    }
+  }
 
   fprintf(stdout, ">> Creating %s!\n", argv[1]);
 
diff --git a/Tests/ComplexOneConfig/Library/notInAllLib.cxx b/Tests/ComplexOneConfig/Library/notInAllLib.cxx
index 5d928f4..e66ea05 100644
--- a/Tests/ComplexOneConfig/Library/notInAllLib.cxx
+++ b/Tests/ComplexOneConfig/Library/notInAllLib.cxx
@@ -1,5 +1,8 @@
-int notInAllLibFunc() { return 0; }
+int notInAllLibFunc()
+{
+  return 0;
+}
 
 #if 1
-# error "This target should not be compiled by ALL."
+#error "This target should not be compiled by ALL."
 #endif
diff --git a/Tests/ComplexOneConfig/Library/sharedFile.h b/Tests/ComplexOneConfig/Library/sharedFile.h
index 65ac2e2..e32fcb7 100644
--- a/Tests/ComplexOneConfig/Library/sharedFile.h
+++ b/Tests/ComplexOneConfig/Library/sharedFile.h
@@ -1,8 +1,8 @@
 #if defined(_WIN32) || defined(WIN32) /* Win32 version */
 #ifdef CMakeTestLibraryShared_EXPORTS
-#  define CMakeTest_EXPORT __declspec(dllexport)
+#define CMakeTest_EXPORT __declspec(dllexport)
 #else
-#  define CMakeTest_EXPORT __declspec(dllimport)
+#define CMakeTest_EXPORT __declspec(dllimport)
 #endif
 #else
 /* unix needs nothing */
diff --git a/Tests/ComplexOneConfig/Library/testConly.h b/Tests/ComplexOneConfig/Library/testConly.h
index ba84589..9b0fb73 100644
--- a/Tests/ComplexOneConfig/Library/testConly.h
+++ b/Tests/ComplexOneConfig/Library/testConly.h
@@ -1,8 +1,8 @@
 #if defined(_WIN32) || defined(WIN32) /* Win32 version */
 #ifdef CMakeTestCLibraryShared_EXPORTS
-#  define CMakeTest_EXPORT __declspec(dllexport)
+#define CMakeTest_EXPORT __declspec(dllexport)
 #else
-#  define CMakeTest_EXPORT __declspec(dllimport)
+#define CMakeTest_EXPORT __declspec(dllimport)
 #endif
 #else
 /* unix needs nothing */
@@ -10,4 +10,3 @@
 #endif
 
 CMakeTest_EXPORT int CsharedFunction();
-
diff --git a/Tests/CustComDepend/bar.h b/Tests/CustComDepend/bar.h
index d179464..c072b81 100644
--- a/Tests/CustComDepend/bar.h
+++ b/Tests/CustComDepend/bar.h
@@ -1,9 +1,9 @@
 #ifdef _WIN32
-#  ifdef bar_EXPORTS
-#    define BAR_EXPORT  __declspec( dllexport )
-#  else
-#    define BAR_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef bar_EXPORTS
+#define BAR_EXPORT __declspec(dllexport)
 #else
-#  define BAR_EXPORT
+#define BAR_EXPORT __declspec(dllimport)
+#endif
+#else
+#define BAR_EXPORT
 #endif
diff --git a/Tests/CustComDepend/foo.cxx b/Tests/CustComDepend/foo.cxx
index 19dfcb1..2705b66 100644
--- a/Tests/CustComDepend/foo.cxx
+++ b/Tests/CustComDepend/foo.cxx
@@ -4,12 +4,10 @@ int main(int ac, char** av)
 {
   FILE* fout = fopen(av[1], "w");
   printf("create %s\n", av[1]);
-  if(!fout)
-    {
+  if (!fout) {
     return -1;
-    }
+  }
   fprintf(fout, "#include <bar.h>\nBAR_EXPORT int bar(){ return 10;}\n");
   fclose(fout);
   return 0;
 }
-
diff --git a/Tests/CustomCommand/gen_redirect_in.c b/Tests/CustomCommand/gen_redirect_in.c
index 8dd8f43..6af364b 100644
--- a/Tests/CustomCommand/gen_redirect_in.c
+++ b/Tests/CustomCommand/gen_redirect_in.c
@@ -1,5 +1,8 @@
 #if 1
 
-int gen_redirect() { return 3; }
+int gen_redirect()
+{
+  return 3;
+}
 
 /* endif should be concatenated to generated file */
diff --git a/Tests/CustomCommand/generator.cxx b/Tests/CustomCommand/generator.cxx
index cceac07..8281713 100644
--- a/Tests/CustomCommand/generator.cxx
+++ b/Tests/CustomCommand/generator.cxx
@@ -1,18 +1,17 @@
 #include <stdio.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if ( argc < 2 )
-    {
+  if (argc < 2) {
     fprintf(stderr, "Usage: %s <file>\n", argv[0]);
     return 1;
-    }
-  FILE *fp = fopen(argv[1],"w");
+  }
+  FILE* fp = fopen(argv[1], "w");
 #ifdef GENERATOR_EXTERN
-  fprintf(fp,"int generated() { return 3; }\n");
+  fprintf(fp, "int generated() { return 3; }\n");
 #else
-  fprintf(fp,"extern int gen_redirect(void);\n");
-  fprintf(fp,"int generated() { return gen_redirect(); }\n");
+  fprintf(fp, "extern int gen_redirect(void);\n");
+  fprintf(fp, "int generated() { return gen_redirect(); }\n");
 #endif
   fclose(fp);
   return 0;
diff --git a/Tests/CustomCommand/tcat.cxx b/Tests/CustomCommand/tcat.cxx
index 89e3cb0..d010d14 100644
--- a/Tests/CustomCommand/tcat.cxx
+++ b/Tests/CustomCommand/tcat.cxx
@@ -3,9 +3,8 @@
 int main()
 {
   int c;
-  while((c = getc(stdin), c != EOF))
-    {
+  while ((c = getc(stdin), c != EOF)) {
     putc(c, stdout);
-    }
+  }
   return 0;
 }
diff --git a/Tests/CustomCommand/wrapper.cxx b/Tests/CustomCommand/wrapper.cxx
index 93cb079..c380938 100644
--- a/Tests/CustomCommand/wrapper.cxx
+++ b/Tests/CustomCommand/wrapper.cxx
@@ -1,36 +1,28 @@
 #include <stdio.h>
 #include <string.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if ( argc < 3 )
-    {
+  if (argc < 3) {
     fprintf(stderr, "Usage: %s <file1> <file2>\n", argv[0]);
     return 1;
-    }
-  FILE *fp = fopen(argv[1],"w");
-  fprintf(fp,"extern int wrapped_help();\n");
-  fprintf(fp,"int wrapped() { return wrapped_help(); }\n");
+  }
+  FILE* fp = fopen(argv[1], "w");
+  fprintf(fp, "extern int wrapped_help();\n");
+  fprintf(fp, "int wrapped() { return wrapped_help(); }\n");
   fclose(fp);
-  fp = fopen(argv[2],"w");
-  fprintf(fp,"int wrapped_help() { return 5; }\n");
+  fp = fopen(argv[2], "w");
+  fprintf(fp, "int wrapped_help() { return 5; }\n");
   fclose(fp);
 #ifdef CMAKE_INTDIR
-  /* The VS6 IDE passes a leading ".\\" in its variable expansion.  */
-# if defined(_MSC_VER) && _MSC_VER == 1200
-#  define CFG_DIR ".\\" CMAKE_INTDIR
-# else
-#  define CFG_DIR CMAKE_INTDIR
-# endif
-  const char* cfg = (argc >= 4)? argv[3] : "";
-  if(strcmp(cfg, CFG_DIR) != 0)
-    {
-    fprintf(stderr,
-            "Did not receive expected configuration argument:\n"
-            "  expected [" CFG_DIR "]\n"
-            "  received [%s]\n", cfg);
+  const char* cfg = (argc >= 4) ? argv[3] : "";
+  if (strcmp(cfg, CMAKE_INTDIR) != 0) {
+    fprintf(stderr, "Did not receive expected configuration argument:\n"
+                    "  expected [" CMAKE_INTDIR "]\n"
+                    "  received [%s]\n",
+            cfg);
     return 1;
-    }
+  }
 #endif
   return 0;
 }
diff --git a/Tests/CustomCommandByproducts/CustomCommandByproducts.c b/Tests/CustomCommandByproducts/CustomCommandByproducts.c
index 1916427..02ad7ea 100644
--- a/Tests/CustomCommandByproducts/CustomCommandByproducts.c
+++ b/Tests/CustomCommandByproducts/CustomCommandByproducts.c
@@ -9,15 +9,7 @@ extern int byproduct8(void);
 extern int ExternalLibrary(void);
 int main(void)
 {
-  return (
-    byproduct1() +
-    byproduct2() +
-    byproduct3() +
-    byproduct4() +
-    byproduct5() +
-    byproduct6() +
-    byproduct7() +
-    byproduct8() +
-    ExternalLibrary() +
-    0);
+  return (byproduct1() + byproduct2() + byproduct3() + byproduct4() +
+          byproduct5() + byproduct6() + byproduct7() + byproduct8() +
+          ExternalLibrary() + 0);
 }
diff --git a/Tests/CustomCommandByproducts/External/ExternalLibrary.c b/Tests/CustomCommandByproducts/External/ExternalLibrary.c
index a1dacf0..554f611 100644
--- a/Tests/CustomCommandByproducts/External/ExternalLibrary.c
+++ b/Tests/CustomCommandByproducts/External/ExternalLibrary.c
@@ -1 +1,4 @@
-int ExternalLibrary(void) { return 0; }
+int ExternalLibrary(void)
+{
+  return 0;
+}
diff --git a/Tests/CustomCommandByproducts/ProducerExe.c b/Tests/CustomCommandByproducts/ProducerExe.c
index 78f2de1..8488f4e 100644
--- a/Tests/CustomCommandByproducts/ProducerExe.c
+++ b/Tests/CustomCommandByproducts/ProducerExe.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx
index 9cf6f2d..0911a07 100644
--- a/Tests/CxxOnly/cxxonly.cxx
+++ b/Tests/CxxOnly/cxxonly.cxx
@@ -6,20 +6,18 @@ extern int testCPP;
 
 #include <stdio.h>
 
-int main ()
+int main()
 {
 #ifdef _MSC_VER
   testCPP = 1;
 #endif
-  if ( LibCxx1Class::Method() != 2.0 )
-    {
+  if (LibCxx1Class::Method() != 2.0) {
     printf("Problem with libcxx1\n");
     return 1;
-    }
-  if ( LibCxx2Class::Method() != 1.0 )
-    {
+  }
+  if (LibCxx2Class::Method() != 1.0) {
     printf("Problem with libcxx2\n");
     return 1;
-    }
+  }
   return 0;
 }
diff --git a/Tests/CxxOnly/libcxx2.h b/Tests/CxxOnly/libcxx2.h
index 5dd84f6..1d97fa0 100644
--- a/Tests/CxxOnly/libcxx2.h
+++ b/Tests/CxxOnly/libcxx2.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef testcxx2_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef testcxx2_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 class CM_TEST_LIB_EXPORT LibCxx2Class
diff --git a/Tests/CxxOnly/testCxxModule.cxx b/Tests/CxxOnly/testCxxModule.cxx
index dd16d2b..039e8bb 100644
--- a/Tests/CxxOnly/testCxxModule.cxx
+++ b/Tests/CxxOnly/testCxxModule.cxx
@@ -1,6 +1,9 @@
 #ifdef _WIN32
-# define TEST_EXPORT __declspec(dllexport)
+#define TEST_EXPORT __declspec(dllexport)
 #else
-# define TEST_EXPORT
+#define TEST_EXPORT
 #endif
-TEST_EXPORT int testCxxModule(void) { return 0; }
+TEST_EXPORT int testCxxModule(void)
+{
+  return 0;
+}
diff --git a/Tests/CxxSubdirC/Cdir/Cobj.c b/Tests/CxxSubdirC/Cdir/Cobj.c
index 75a0045..a593e07 100644
--- a/Tests/CxxSubdirC/Cdir/Cobj.c
+++ b/Tests/CxxSubdirC/Cdir/Cobj.c
@@ -1 +1,4 @@
-int Cobj(void) { return 0; }
+int Cobj(void)
+{
+  return 0;
+}
diff --git a/Tests/CxxSubdirC/main.cxx b/Tests/CxxSubdirC/main.cxx
index 049220f..c4cebc4 100644
--- a/Tests/CxxSubdirC/main.cxx
+++ b/Tests/CxxSubdirC/main.cxx
@@ -1,2 +1,5 @@
 extern "C" int Cobj(void);
-int main() { return Cobj(); }
+int main()
+{
+  return Cobj();
+}
diff --git a/Tests/Dependency/Case1/a.c b/Tests/Dependency/Case1/a.c
index d702db1..262f523 100644
--- a/Tests/Dependency/Case1/a.c
+++ b/Tests/Dependency/Case1/a.c
@@ -1,5 +1,4 @@
 int a()
 {
-   return 5;
+  return 5;
 }
-
diff --git a/Tests/Dependency/Case1/b.c b/Tests/Dependency/Case1/b.c
index 6bdfafa..deda685 100644
--- a/Tests/Dependency/Case1/b.c
+++ b/Tests/Dependency/Case1/b.c
@@ -2,5 +2,5 @@ extern int a();
 
 int b()
 {
-   return a()+17;
+  return a() + 17;
 }
diff --git a/Tests/Dependency/Case1/b2.c b/Tests/Dependency/Case1/b2.c
index f37e1bb..f341da7 100644
--- a/Tests/Dependency/Case1/b2.c
+++ b/Tests/Dependency/Case1/b2.c
@@ -1,4 +1,4 @@
 int b2()
 {
-   return 3;
+  return 3;
 }
diff --git a/Tests/Dependency/Case1/c.c b/Tests/Dependency/Case1/c.c
index c180a59..a3ec162 100644
--- a/Tests/Dependency/Case1/c.c
+++ b/Tests/Dependency/Case1/c.c
@@ -2,5 +2,5 @@ extern int b();
 
 int c()
 {
-   return b()+42;
+  return b() + 42;
 }
diff --git a/Tests/Dependency/Case1/c2.c b/Tests/Dependency/Case1/c2.c
index 4cf4426..317bb0f 100644
--- a/Tests/Dependency/Case1/c2.c
+++ b/Tests/Dependency/Case1/c2.c
@@ -2,5 +2,5 @@ extern int b2();
 
 int c2()
 {
-  return b2()+1;
+  return b2() + 1;
 }
diff --git a/Tests/Dependency/Case1/d.c b/Tests/Dependency/Case1/d.c
index ea5457d..f67aef7 100644
--- a/Tests/Dependency/Case1/d.c
+++ b/Tests/Dependency/Case1/d.c
@@ -2,6 +2,5 @@ extern int c2();
 
 int d()
 {
-   return c2()+2;
+  return c2() + 2;
 }
-
diff --git a/Tests/Dependency/Case1/main.c b/Tests/Dependency/Case1/main.c
index 1e5f6d4..07191cc 100644
--- a/Tests/Dependency/Case1/main.c
+++ b/Tests/Dependency/Case1/main.c
@@ -4,7 +4,7 @@ extern int d();
 
 int main()
 {
-   c();
-   b();
-   d();
+  c();
+  b();
+  d();
 }
diff --git a/Tests/Dependency/Case2/bar1.c b/Tests/Dependency/Case2/bar1.c
index 6108fba..6da9077 100644
--- a/Tests/Dependency/Case2/bar1.c
+++ b/Tests/Dependency/Case2/bar1.c
@@ -1,4 +1,10 @@
 extern int foo1();
 extern int bar2(void);
-int bar1(void) { return bar2(); }
-int bar1_from_bar3(void) { return foo1(); }
+int bar1(void)
+{
+  return bar2();
+}
+int bar1_from_bar3(void)
+{
+  return foo1();
+}
diff --git a/Tests/Dependency/Case2/bar2.c b/Tests/Dependency/Case2/bar2.c
index b9a2360..00ed483 100644
--- a/Tests/Dependency/Case2/bar2.c
+++ b/Tests/Dependency/Case2/bar2.c
@@ -1,2 +1,5 @@
 extern int bar3(void);
-int bar2(void) { return bar3(); }
+int bar2(void)
+{
+  return bar3();
+}
diff --git a/Tests/Dependency/Case2/bar3.c b/Tests/Dependency/Case2/bar3.c
index 73e8556..a950899 100644
--- a/Tests/Dependency/Case2/bar3.c
+++ b/Tests/Dependency/Case2/bar3.c
@@ -1,2 +1,5 @@
 extern int bar1_from_bar3(void);
-int bar3(void) { return bar1_from_bar3(); }
+int bar3(void)
+{
+  return bar1_from_bar3();
+}
diff --git a/Tests/Dependency/Case2/foo1.c b/Tests/Dependency/Case2/foo1.c
index 5f1f8ac..d476f2c 100644
--- a/Tests/Dependency/Case2/foo1.c
+++ b/Tests/Dependency/Case2/foo1.c
@@ -1,2 +1,5 @@
 extern int foo2(void);
-int foo1(void) { return foo2(); }
+int foo1(void)
+{
+  return foo2();
+}
diff --git a/Tests/Dependency/Case2/foo1b.c b/Tests/Dependency/Case2/foo1b.c
index e2b6dc3..e437014 100644
--- a/Tests/Dependency/Case2/foo1b.c
+++ b/Tests/Dependency/Case2/foo1b.c
@@ -1,2 +1,5 @@
 extern int foo2b(void);
-int foo1b(void) { return foo2b(); }
+int foo1b(void)
+{
+  return foo2b();
+}
diff --git a/Tests/Dependency/Case2/foo1c.c b/Tests/Dependency/Case2/foo1c.c
index 1dcca58..af03dec 100644
--- a/Tests/Dependency/Case2/foo1c.c
+++ b/Tests/Dependency/Case2/foo1c.c
@@ -1,2 +1,5 @@
 extern int foo2c(void);
-int foo1c(void) { return foo2c(); }
+int foo1c(void)
+{
+  return foo2c();
+}
diff --git a/Tests/Dependency/Case2/foo2.c b/Tests/Dependency/Case2/foo2.c
index 6019236..587c77a 100644
--- a/Tests/Dependency/Case2/foo2.c
+++ b/Tests/Dependency/Case2/foo2.c
@@ -1,2 +1,5 @@
 extern int foo3(void);
-int foo2(void) { return foo3(); }
+int foo2(void)
+{
+  return foo3();
+}
diff --git a/Tests/Dependency/Case2/foo2b.c b/Tests/Dependency/Case2/foo2b.c
index 34d6944..6959e63 100644
--- a/Tests/Dependency/Case2/foo2b.c
+++ b/Tests/Dependency/Case2/foo2b.c
@@ -1,2 +1,5 @@
 extern int foo3b(void);
-int foo2b(void) { return foo3b(); }
+int foo2b(void)
+{
+  return foo3b();
+}
diff --git a/Tests/Dependency/Case2/foo2c.c b/Tests/Dependency/Case2/foo2c.c
index dbc54de..aedb61c 100644
--- a/Tests/Dependency/Case2/foo2c.c
+++ b/Tests/Dependency/Case2/foo2c.c
@@ -1,2 +1,5 @@
 extern int foo3c(void);
-int foo2c(void) { return foo3c(); }
+int foo2c(void)
+{
+  return foo3c();
+}
diff --git a/Tests/Dependency/Case2/foo3.c b/Tests/Dependency/Case2/foo3.c
index dacef6a..cab9535 100644
--- a/Tests/Dependency/Case2/foo3.c
+++ b/Tests/Dependency/Case2/foo3.c
@@ -1,2 +1,5 @@
 extern int foo1b(void);
-int foo3(void) { return foo1b(); }
+int foo3(void)
+{
+  return foo1b();
+}
diff --git a/Tests/Dependency/Case2/foo3b.c b/Tests/Dependency/Case2/foo3b.c
index ca25fd8..69d2c8c 100644
--- a/Tests/Dependency/Case2/foo3b.c
+++ b/Tests/Dependency/Case2/foo3b.c
@@ -1,2 +1,5 @@
 extern int foo1c(void);
-int foo3b(void) { return foo1c(); }
+int foo3b(void)
+{
+  return foo1c();
+}
diff --git a/Tests/Dependency/Case2/foo3c.c b/Tests/Dependency/Case2/foo3c.c
index 0ad65fe..e774495 100644
--- a/Tests/Dependency/Case2/foo3c.c
+++ b/Tests/Dependency/Case2/foo3c.c
@@ -1 +1,4 @@
-int foo3c(void) { return 0; }
+int foo3c(void)
+{
+  return 0;
+}
diff --git a/Tests/Dependency/Case3/foo1.c b/Tests/Dependency/Case3/foo1.c
index 5f1f8ac..d476f2c 100644
--- a/Tests/Dependency/Case3/foo1.c
+++ b/Tests/Dependency/Case3/foo1.c
@@ -1,2 +1,5 @@
 extern int foo2(void);
-int foo1(void) { return foo2(); }
+int foo1(void)
+{
+  return foo2();
+}
diff --git a/Tests/Dependency/Case3/foo1b.c b/Tests/Dependency/Case3/foo1b.c
index 6ae3bab..84933af 100644
--- a/Tests/Dependency/Case3/foo1b.c
+++ b/Tests/Dependency/Case3/foo1b.c
@@ -1 +1,4 @@
-int foo1b(void) { return 0; }
+int foo1b(void)
+{
+  return 0;
+}
diff --git a/Tests/Dependency/Case3/foo2.c b/Tests/Dependency/Case3/foo2.c
index 33dbbfc..9bbb5d7 100644
--- a/Tests/Dependency/Case3/foo2.c
+++ b/Tests/Dependency/Case3/foo2.c
@@ -1,2 +1,5 @@
 extern int foo1b(void);
-int foo2(void) { return foo1b(); }
+int foo2(void)
+{
+  return foo1b();
+}
diff --git a/Tests/Dependency/Case4/bar.c b/Tests/Dependency/Case4/bar.c
index d0bb0c4..08092f9 100644
--- a/Tests/Dependency/Case4/bar.c
+++ b/Tests/Dependency/Case4/bar.c
@@ -1,2 +1,5 @@
 extern int foo();
-int main() { return foo(); }
+int main()
+{
+  return foo();
+}
diff --git a/Tests/Dependency/Case4/foo.c b/Tests/Dependency/Case4/foo.c
index 9fe07f8..e05eb7e 100644
--- a/Tests/Dependency/Case4/foo.c
+++ b/Tests/Dependency/Case4/foo.c
@@ -1 +1,4 @@
-int foo() { return 0; }
+int foo()
+{
+  return 0;
+}
diff --git a/Tests/Dependency/Case5/bar.c b/Tests/Dependency/Case5/bar.c
index 4cb1b1b..fcbd135 100644
--- a/Tests/Dependency/Case5/bar.c
+++ b/Tests/Dependency/Case5/bar.c
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllimport)
 #endif
-void foo(void);
+  void foo(void);
 
 #include <stdio.h>
 
diff --git a/Tests/Dependency/Case5/foo.c b/Tests/Dependency/Case5/foo.c
index 794833d..b82b7c2 100644
--- a/Tests/Dependency/Case5/foo.c
+++ b/Tests/Dependency/Case5/foo.c
@@ -3,7 +3,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-void foo(void)
+  void foo(void)
 {
   printf("foo()\n");
 }
diff --git a/Tests/Dependency/Case5/main.c b/Tests/Dependency/Case5/main.c
index ae3dc95..a967944 100644
--- a/Tests/Dependency/Case5/main.c
+++ b/Tests/Dependency/Case5/main.c
@@ -1,6 +1,6 @@
 void bar(void);
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
   bar();
   return 0;
diff --git a/Tests/Dependency/Exec/ExecMain.c b/Tests/Dependency/Exec/ExecMain.c
index d2f551c..9572afd 100644
--- a/Tests/Dependency/Exec/ExecMain.c
+++ b/Tests/Dependency/Exec/ExecMain.c
@@ -5,7 +5,7 @@ void NoDepCFunction();
 void SixAFunction();
 void SixBFunction();
 
-int main( )
+int main()
 {
   SixAFunction();
   SixBFunction();
diff --git a/Tests/Dependency/Exec2/ExecMain.c b/Tests/Dependency/Exec2/ExecMain.c
index d08a796..385cce1 100644
--- a/Tests/Dependency/Exec2/ExecMain.c
+++ b/Tests/Dependency/Exec2/ExecMain.c
@@ -3,7 +3,7 @@
 void FiveFunction();
 void EightFunction();
 
-int main( )
+int main()
 {
   FiveFunction();
   EightFunction();
diff --git a/Tests/Dependency/Exec3/ExecMain.c b/Tests/Dependency/Exec3/ExecMain.c
index d08a796..385cce1 100644
--- a/Tests/Dependency/Exec3/ExecMain.c
+++ b/Tests/Dependency/Exec3/ExecMain.c
@@ -3,7 +3,7 @@
 void FiveFunction();
 void EightFunction();
 
-int main( )
+int main()
 {
   FiveFunction();
   EightFunction();
diff --git a/Tests/Dependency/Exec4/ExecMain.c b/Tests/Dependency/Exec4/ExecMain.c
index 3f53573..0cfcce9 100644
--- a/Tests/Dependency/Exec4/ExecMain.c
+++ b/Tests/Dependency/Exec4/ExecMain.c
@@ -3,7 +3,7 @@
 void FiveFunction();
 void TwoFunction();
 
-int main( )
+int main()
 {
   FiveFunction();
   TwoFunction();
diff --git a/Tests/Dependency/Four/FourSrc.c b/Tests/Dependency/Four/FourSrc.c
index 23a66a4..4ea996d 100644
--- a/Tests/Dependency/Four/FourSrc.c
+++ b/Tests/Dependency/Four/FourSrc.c
@@ -6,7 +6,7 @@ void TwoFunction();
 void FourFunction()
 {
   static int count = 0;
-  if( count == 0 ) {
+  if (count == 0) {
     ++count;
     TwoFunction();
   }
diff --git a/Tests/Dependency/Three/ThreeSrc.c b/Tests/Dependency/Three/ThreeSrc.c
index 9c77f17..3e814f3 100644
--- a/Tests/Dependency/Three/ThreeSrc.c
+++ b/Tests/Dependency/Three/ThreeSrc.c
@@ -4,7 +4,7 @@ void FourFunction();
 void ThreeFunction()
 {
   static int count = 0;
-  if( count == 0 ) {
+  if (count == 0) {
     ++count;
     FourFunction();
   }
diff --git a/Tests/Dependency/Two/TwoSrc.c b/Tests/Dependency/Two/TwoSrc.c
index 0b3366b..dbdf524 100644
--- a/Tests/Dependency/Two/TwoSrc.c
+++ b/Tests/Dependency/Two/TwoSrc.c
@@ -3,7 +3,7 @@
 void TwoFunction()
 {
   static int count = 0;
-  if( count == 0 ) {
+  if (count == 0) {
     ++count;
     ThreeFunction();
   }
diff --git a/Tests/EmptyProperty/EmptyProperty.cxx b/Tests/EmptyProperty/EmptyProperty.cxx
index 78f2de1..8488f4e 100644
--- a/Tests/EmptyProperty/EmptyProperty.cxx
+++ b/Tests/EmptyProperty/EmptyProperty.cxx
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/Environment/main.cxx b/Tests/Environment/main.cxx
index 2e1bf4c..55bc77f 100644
--- a/Tests/Environment/main.cxx
+++ b/Tests/Environment/main.cxx
@@ -1,13 +1,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
   char* var = getenv("CMAKE_ENVIRONMENT_TEST_VAR");
-  if (!var)
-    {
+  if (!var) {
     var = "(null)";
-    }
+  }
 
   fprintf(stdout, "Environment:\n");
   fprintf(stdout, "  CMAKE_ENVIRONMENT_TEST_VAR='%s'\n", var);
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index c2ecb0b..f504c7b 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -79,12 +79,6 @@ set_property(TARGET testLib7 PROPERTY OUTPUT_NAME_DEBUG testLib7D-$<CONFIG>)
 set_property(TARGET testLib7 PROPERTY OUTPUT_NAME_RELEASE testLib7R-$<CONFIG>)
 set_property(TARGET testLib7 PROPERTY OUTPUT_NAME testLib7-$<CONFIG>)
 
-# Work-around: Visual Studio 6 does not support per-target object files.
-set(VS6)
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
-  set(VS6 1)
-endif()
-
 # Test using the target_link_libraries command to set the
 # LINK_INTERFACE_LIBRARIES* properties.  We construct two libraries
 # providing the same two symbols.  In each library one of the symbols
@@ -93,8 +87,8 @@ endif()
 # configuration in which it is built.  If the proper library is not
 # used via the link interface the import test will fail to link.
 add_library(testLib4lib STATIC testLib4lib.c)
-add_library(testLib4libdbg STATIC testLib4libopt.c testLib4libdbg${VS6}.c)
-add_library(testLib4libopt STATIC testLib4libdbg.c testLib4libopt${VS6}.c)
+add_library(testLib4libdbg STATIC testLib4libopt.c testLib4libdbg.c)
+add_library(testLib4libopt STATIC testLib4libdbg.c testLib4libopt.c)
 set_property(TARGET testLib4libdbg PROPERTY COMPILE_DEFINITIONS LIB_DBG)
 set_property(TARGET testLib4libopt PROPERTY COMPILE_DEFINITIONS LIB_OPT)
 target_link_libraries(testLib4
diff --git a/Tests/ExportImport/Export/Interface/headeronly/headeronly.h b/Tests/ExportImport/Export/Interface/headeronly/headeronly.h
index 3673c21..92bfecd 100644
--- a/Tests/ExportImport/Export/Interface/headeronly/headeronly.h
+++ b/Tests/ExportImport/Export/Interface/headeronly/headeronly.h
@@ -1,5 +1,8 @@
 
-enum { one };
+enum
+{
+  one
+};
 
 struct HeaderOnly
 {
diff --git a/Tests/ExportImport/Export/empty.cpp b/Tests/ExportImport/Export/empty.cpp
index 1787013..11ec041 100644
--- a/Tests/ExportImport/Export/empty.cpp
+++ b/Tests/ExportImport/Export/empty.cpp
@@ -1,4 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty() { return 0; }
+  int empty()
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/systemlib.cpp b/Tests/ExportImport/Export/systemlib.cpp
index ec45148..a9e6179 100644
--- a/Tests/ExportImport/Export/systemlib.cpp
+++ b/Tests/ExportImport/Export/systemlib.cpp
@@ -3,5 +3,4 @@
 
 SystemStruct::SystemStruct()
 {
-
 }
diff --git a/Tests/ExportImport/Export/systemlib.h b/Tests/ExportImport/Export/systemlib.h
index f7900c0..6fd00d5 100644
--- a/Tests/ExportImport/Export/systemlib.h
+++ b/Tests/ExportImport/Export/systemlib.h
@@ -3,9 +3,9 @@
 #define SYSTEMLIB_H
 
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define systemlib_EXPORT __declspec(dllexport)
+#define systemlib_EXPORT __declspec(dllexport)
 #else
-# define systemlib_EXPORT
+#define systemlib_EXPORT
 #endif
 
 struct systemlib_EXPORT SystemStruct
diff --git a/Tests/ExportImport/Export/testExe1.c b/Tests/ExportImport/Export/testExe1.c
index e00fac7..5fbb892 100644
--- a/Tests/ExportImport/Export/testExe1.c
+++ b/Tests/ExportImport/Export/testExe1.c
@@ -4,22 +4,18 @@ extern int testExe1lib(void);
 
 int main(int argc, const char* argv[])
 {
-  if(argc < 2)
-    {
+  if (argc < 2) {
     fprintf(stderr, "Must specify output file.\n");
     return 1;
-    }
+  }
   {
-  FILE* f = fopen(argv[1], "w");
-  if(f)
-    {
-    fprintf(f, "int generated_by_testExe1() { return 0; }\n");
-    fclose(f);
-    }
-  else
-    {
-    fprintf(stderr, "Error writing to %s\n", argv[1]);
-    return 1;
+    FILE* f = fopen(argv[1], "w");
+    if (f) {
+      fprintf(f, "int generated_by_testExe1() { return 0; }\n");
+      fclose(f);
+    } else {
+      fprintf(stderr, "Error writing to %s\n", argv[1]);
+      return 1;
     }
   }
   return testExe1lib();
diff --git a/Tests/ExportImport/Export/testExe1lib.c b/Tests/ExportImport/Export/testExe1lib.c
index 7ad48a3..4bb3325 100644
--- a/Tests/ExportImport/Export/testExe1lib.c
+++ b/Tests/ExportImport/Export/testExe1lib.c
@@ -1 +1,4 @@
-int testExe1lib(void) { return 0; }
+int testExe1lib(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testExe2.c b/Tests/ExportImport/Export/testExe2.c
index f7d9345..f8976c4 100644
--- a/Tests/ExportImport/Export/testExe2.c
+++ b/Tests/ExportImport/Export/testExe2.c
@@ -1,10 +1,13 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testExe2_EXPORT __declspec(dllexport)
+#define testExe2_EXPORT __declspec(dllexport)
 #else
-# define testExe2_EXPORT
+#define testExe2_EXPORT
 #endif
 
-testExe2_EXPORT int testExe2Func(void) { return 123; }
+testExe2_EXPORT int testExe2Func(void)
+{
+  return 123;
+}
 
 int main()
 {
diff --git a/Tests/ExportImport/Export/testExe2lib.c b/Tests/ExportImport/Export/testExe2lib.c
index 1991439..2a5a77b 100644
--- a/Tests/ExportImport/Export/testExe2lib.c
+++ b/Tests/ExportImport/Export/testExe2lib.c
@@ -1,10 +1,13 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testExe2lib_EXPORT __declspec(dllexport)
-# define testExe2libImp_IMPORT __declspec(dllimport)
+#define testExe2lib_EXPORT __declspec(dllexport)
+#define testExe2libImp_IMPORT __declspec(dllimport)
 #else
-# define testExe2lib_EXPORT
-# define testExe2libImp_IMPORT
+#define testExe2lib_EXPORT
+#define testExe2libImp_IMPORT
 #endif
 
 testExe2libImp_IMPORT int testExe2libImp(void);
-testExe2lib_EXPORT int testExe2lib(void) { return testExe2libImp(); }
+testExe2lib_EXPORT int testExe2lib(void)
+{
+  return testExe2libImp();
+}
diff --git a/Tests/ExportImport/Export/testExe2libImp.c b/Tests/ExportImport/Export/testExe2libImp.c
index f5a23af..aba914b 100644
--- a/Tests/ExportImport/Export/testExe2libImp.c
+++ b/Tests/ExportImport/Export/testExe2libImp.c
@@ -1,7 +1,10 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testExe2libImp_EXPORT __declspec(dllexport)
+#define testExe2libImp_EXPORT __declspec(dllexport)
 #else
-# define testExe2libImp_EXPORT
+#define testExe2libImp_EXPORT
 #endif
 
-testExe2libImp_EXPORT int testExe2libImp(void) { return 0; }
+testExe2libImp_EXPORT int testExe2libImp(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testExe3.c b/Tests/ExportImport/Export/testExe3.c
index 895e2fc..2b07576 100644
--- a/Tests/ExportImport/Export/testExe3.c
+++ b/Tests/ExportImport/Export/testExe3.c
@@ -2,22 +2,18 @@
 
 int main(int argc, const char* argv[])
 {
-  if(argc < 2)
-    {
+  if (argc < 2) {
     fprintf(stderr, "Must specify output file.\n");
     return 1;
-    }
+  }
   {
-  FILE* f = fopen(argv[1], "w");
-  if(f)
-    {
-    fprintf(f, "int generated_by_testExe3() { return 0; }\n");
-    fclose(f);
-    }
-  else
-    {
-    fprintf(stderr, "Error writing to %s\n", argv[1]);
-    return 1;
+    FILE* f = fopen(argv[1], "w");
+    if (f) {
+      fprintf(f, "int generated_by_testExe3() { return 0; }\n");
+      fclose(f);
+    } else {
+      fprintf(stderr, "Error writing to %s\n", argv[1]);
+      return 1;
     }
   }
   return 0;
diff --git a/Tests/ExportImport/Export/testExe4.c b/Tests/ExportImport/Export/testExe4.c
index 731057e..422ab3d 100644
--- a/Tests/ExportImport/Export/testExe4.c
+++ b/Tests/ExportImport/Export/testExe4.c
@@ -2,22 +2,18 @@
 
 int main(int argc, const char* argv[])
 {
-  if(argc < 2)
-    {
+  if (argc < 2) {
     fprintf(stderr, "Must specify output file.\n");
     return 1;
-    }
+  }
   {
-  FILE* f = fopen(argv[1], "w");
-  if(f)
-    {
-    fprintf(f, "int generated_by_testExe4() { return 0; }\n");
-    fclose(f);
-    }
-  else
-    {
-    fprintf(stderr, "Error writing to %s\n", argv[1]);
-    return 1;
+    FILE* f = fopen(argv[1], "w");
+    if (f) {
+      fprintf(f, "int generated_by_testExe4() { return 0; }\n");
+      fclose(f);
+    } else {
+      fprintf(stderr, "Error writing to %s\n", argv[1]);
+      return 1;
     }
   }
   return 0;
diff --git a/Tests/ExportImport/Export/testLib1.c b/Tests/ExportImport/Export/testLib1.c
index 35bb1e5..5002963 100644
--- a/Tests/ExportImport/Export/testLib1.c
+++ b/Tests/ExportImport/Export/testLib1.c
@@ -1 +1,4 @@
-int testLib1(void) { return 0; }
+int testLib1(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib2.c b/Tests/ExportImport/Export/testLib2.c
index aabc0d3..7a5206f 100644
--- a/Tests/ExportImport/Export/testLib2.c
+++ b/Tests/ExportImport/Export/testLib2.c
@@ -1,4 +1,7 @@
 
 extern int testLib1(void);
 
-int testLib2(void) { return testLib1(); }
+int testLib2(void)
+{
+  return testLib1();
+}
diff --git a/Tests/ExportImport/Export/testLib3.c b/Tests/ExportImport/Export/testLib3.c
index 31cec94..cacac81 100644
--- a/Tests/ExportImport/Export/testLib3.c
+++ b/Tests/ExportImport/Export/testLib3.c
@@ -1,10 +1,13 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testLib3_EXPORT __declspec(dllexport)
-# define testLib3Imp_IMPORT __declspec(dllimport)
+#define testLib3_EXPORT __declspec(dllexport)
+#define testLib3Imp_IMPORT __declspec(dllimport)
 #else
-# define testLib3_EXPORT
-# define testLib3Imp_IMPORT
+#define testLib3_EXPORT
+#define testLib3Imp_IMPORT
 #endif
 
 testLib3Imp_IMPORT int testLib3Imp(void);
-testLib3_EXPORT int testLib3(void) { return testLib3Imp(); }
+testLib3_EXPORT int testLib3(void)
+{
+  return testLib3Imp();
+}
diff --git a/Tests/ExportImport/Export/testLib3Imp.c b/Tests/ExportImport/Export/testLib3Imp.c
index c27bccd..3d836da 100644
--- a/Tests/ExportImport/Export/testLib3Imp.c
+++ b/Tests/ExportImport/Export/testLib3Imp.c
@@ -1,10 +1,13 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testLib3Imp_EXPORT __declspec(dllexport)
-# define testLib3ImpDep_IMPORT __declspec(dllimport)
+#define testLib3Imp_EXPORT __declspec(dllexport)
+#define testLib3ImpDep_IMPORT __declspec(dllimport)
 #else
-# define testLib3Imp_EXPORT
-# define testLib3ImpDep_IMPORT
+#define testLib3Imp_EXPORT
+#define testLib3ImpDep_IMPORT
 #endif
 
 testLib3ImpDep_IMPORT int testLib3ImpDep(void);
-testLib3Imp_EXPORT int testLib3Imp(void) { return testLib3ImpDep(); }
+testLib3Imp_EXPORT int testLib3Imp(void)
+{
+  return testLib3ImpDep();
+}
diff --git a/Tests/ExportImport/Export/testLib3ImpDep.c b/Tests/ExportImport/Export/testLib3ImpDep.c
index 578ac30..b824e03 100644
--- a/Tests/ExportImport/Export/testLib3ImpDep.c
+++ b/Tests/ExportImport/Export/testLib3ImpDep.c
@@ -1,7 +1,10 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testLib3ImpDep_EXPORT __declspec(dllexport)
+#define testLib3ImpDep_EXPORT __declspec(dllexport)
 #else
-# define testLib3ImpDep_EXPORT
+#define testLib3ImpDep_EXPORT
 #endif
 
-testLib3ImpDep_EXPORT int testLib3ImpDep(void) { return 0; }
+testLib3ImpDep_EXPORT int testLib3ImpDep(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib4.c b/Tests/ExportImport/Export/testLib4.c
index 846b438..0e583b1 100644
--- a/Tests/ExportImport/Export/testLib4.c
+++ b/Tests/ExportImport/Export/testLib4.c
@@ -1,7 +1,10 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testLib4_EXPORT __declspec(dllexport)
+#define testLib4_EXPORT __declspec(dllexport)
 #else
-# define testLib4_EXPORT
+#define testLib4_EXPORT
 #endif
 
-testLib4_EXPORT int testLib4(void) { return 0; }
+testLib4_EXPORT int testLib4(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib4libdbg1.c b/Tests/ExportImport/Export/testLib4libdbg1.c
deleted file mode 100644
index cc56cf9..0000000
--- a/Tests/ExportImport/Export/testLib4libdbg1.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testLib4libdbg.c"
diff --git a/Tests/ExportImport/Export/testLib4libopt1.c b/Tests/ExportImport/Export/testLib4libopt1.c
deleted file mode 100644
index d9b5587..0000000
--- a/Tests/ExportImport/Export/testLib4libopt1.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testLib4libopt.c"
diff --git a/Tests/ExportImport/Export/testLib5.c b/Tests/ExportImport/Export/testLib5.c
index 20a8215..7c61fc0 100644
--- a/Tests/ExportImport/Export/testLib5.c
+++ b/Tests/ExportImport/Export/testLib5.c
@@ -1,7 +1,10 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testLib5_EXPORT __declspec(dllexport)
+#define testLib5_EXPORT __declspec(dllexport)
 #else
-# define testLib5_EXPORT
+#define testLib5_EXPORT
 #endif
 
-testLib5_EXPORT int testLib5(void) { return 0; }
+testLib5_EXPORT int testLib5(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib7.c b/Tests/ExportImport/Export/testLib7.c
index 7acae9e..de85c1a 100644
--- a/Tests/ExportImport/Export/testLib7.c
+++ b/Tests/ExportImport/Export/testLib7.c
@@ -1 +1,4 @@
-int testLib7(void) { return 0; }
+int testLib7(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLibAbs1.c b/Tests/ExportImport/Export/testLibAbs1.c
index 34aec75..c214b62 100644
--- a/Tests/ExportImport/Export/testLibAbs1.c
+++ b/Tests/ExportImport/Export/testLibAbs1.c
@@ -1 +1,4 @@
-int testLibAbs1(void) { return 0; }
+int testLibAbs1(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLibCycleA1.c b/Tests/ExportImport/Export/testLibCycleA1.c
index 3db9e53..cfbf0e1 100644
--- a/Tests/ExportImport/Export/testLibCycleA1.c
+++ b/Tests/ExportImport/Export/testLibCycleA1.c
@@ -1,2 +1,5 @@
 extern int testLibCycleB1(void);
-int testLibCycleA1(void) { return testLibCycleB1(); }
+int testLibCycleA1(void)
+{
+  return testLibCycleB1();
+}
diff --git a/Tests/ExportImport/Export/testLibCycleA2.c b/Tests/ExportImport/Export/testLibCycleA2.c
index 29ad46d..93c9fb6 100644
--- a/Tests/ExportImport/Export/testLibCycleA2.c
+++ b/Tests/ExportImport/Export/testLibCycleA2.c
@@ -1,2 +1,5 @@
 extern int testLibCycleB2(void);
-int testLibCycleA2(void) { return testLibCycleB2(); }
+int testLibCycleA2(void)
+{
+  return testLibCycleB2();
+}
diff --git a/Tests/ExportImport/Export/testLibCycleA3.c b/Tests/ExportImport/Export/testLibCycleA3.c
index 565447b..468c044 100644
--- a/Tests/ExportImport/Export/testLibCycleA3.c
+++ b/Tests/ExportImport/Export/testLibCycleA3.c
@@ -1,2 +1,5 @@
 extern int testLibCycleB3(void);
-int testLibCycleA3(void) { return testLibCycleB3(); }
+int testLibCycleA3(void)
+{
+  return testLibCycleB3();
+}
diff --git a/Tests/ExportImport/Export/testLibCycleB1.c b/Tests/ExportImport/Export/testLibCycleB1.c
index 36cb7b0..d152857 100644
--- a/Tests/ExportImport/Export/testLibCycleB1.c
+++ b/Tests/ExportImport/Export/testLibCycleB1.c
@@ -1,2 +1,5 @@
 extern int testLibCycleA2(void);
-int testLibCycleB1(void) { return testLibCycleA2(); }
+int testLibCycleB1(void)
+{
+  return testLibCycleA2();
+}
diff --git a/Tests/ExportImport/Export/testLibCycleB2.c b/Tests/ExportImport/Export/testLibCycleB2.c
index ff12093..18cd4f6 100644
--- a/Tests/ExportImport/Export/testLibCycleB2.c
+++ b/Tests/ExportImport/Export/testLibCycleB2.c
@@ -1,2 +1,5 @@
 extern int testLibCycleA3(void);
-int testLibCycleB2(void) { return testLibCycleA3(); }
+int testLibCycleB2(void)
+{
+  return testLibCycleA3();
+}
diff --git a/Tests/ExportImport/Export/testLibCycleB3.c b/Tests/ExportImport/Export/testLibCycleB3.c
index ca8d470..a281c69 100644
--- a/Tests/ExportImport/Export/testLibCycleB3.c
+++ b/Tests/ExportImport/Export/testLibCycleB3.c
@@ -1 +1,4 @@
-int testLibCycleB3(void) { return 0; }
+int testLibCycleB3(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
index 3c7774e..c896c10 100644
--- a/Tests/ExportImport/Export/testLibDepends.c
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -18,8 +18,7 @@
 extern int testLibRequired(void);
 extern int testStaticLibRequiredPrivate(void);
 
-int testLibDepends(void) {
-  return testLibRequired()
-    + testStaticLibRequiredPrivate()
-    ;
+int testLibDepends(void)
+{
+  return testLibRequired() + testStaticLibRequiredPrivate();
 }
diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c
index 2193e1f..30acc83 100644
--- a/Tests/ExportImport/Export/testLibNoSONAME.c
+++ b/Tests/ExportImport/Export/testLibNoSONAME.c
@@ -1,7 +1,10 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testLibNoSONAME_EXPORT __declspec(dllexport)
+#define testLibNoSONAME_EXPORT __declspec(dllexport)
 #else
-# define testLibNoSONAME_EXPORT
+#define testLibNoSONAME_EXPORT
 #endif
 
-testLibNoSONAME_EXPORT int testLibNoSONAME(void) { return 0; }
+testLibNoSONAME_EXPORT int testLibNoSONAME(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLibPerConfigDest.c b/Tests/ExportImport/Export/testLibPerConfigDest.c
index c7113fc..903e040 100644
--- a/Tests/ExportImport/Export/testLibPerConfigDest.c
+++ b/Tests/ExportImport/Export/testLibPerConfigDest.c
@@ -1 +1,4 @@
-int testLibPerConfigDest(void) { return 0; }
+int testLibPerConfigDest(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testLibRequired.c b/Tests/ExportImport/Export/testLibRequired.c
index e126d44..24f320c 100644
--- a/Tests/ExportImport/Export/testLibRequired.c
+++ b/Tests/ExportImport/Export/testLibRequired.c
@@ -1 +1,4 @@
-int testLibRequired(void) { return 0; }
+int testLibRequired(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Export/testSharedLibDepends.h b/Tests/ExportImport/Export/testSharedLibDepends.h
index 8b2f84e..e84fb54 100644
--- a/Tests/ExportImport/Export/testSharedLibDepends.h
+++ b/Tests/ExportImport/Export/testSharedLibDepends.h
@@ -4,8 +4,8 @@
 
 #include "testsharedlibdepends_export.h"
 
-#include "testSharedLibRequired.h"
 #include "renamed.h"
+#include "testSharedLibRequired.h"
 
 struct TESTSHAREDLIBDEPENDS_EXPORT TestSharedLibDepends
 {
diff --git a/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c b/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
index 28a2675..5597fb4 100644
--- a/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
+++ b/Tests/ExportImport/Export/testStaticLibRequiredPrivate.c
@@ -1 +1,4 @@
-int testStaticLibRequiredPrivate(void) { return 0; }
+int testStaticLibRequiredPrivate(void)
+{
+  return 0;
+}
diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c
index 953d0ad..1539bcb 100644
--- a/Tests/ExportImport/Import/A/deps_iface.c
+++ b/Tests/ExportImport/Import/A/deps_iface.c
@@ -27,7 +27,6 @@
 
 extern int testLibDepends(void);
 
-
 int main()
 {
   return testLibDepends();
diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp
index d5e4de3..3658ab5 100644
--- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp
+++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp
@@ -21,8 +21,8 @@
 #endif
 
 #ifdef TEST_SUBDIR_LIB
-#include "subdir.h"
 #include "renamed.h"
+#include "subdir.h"
 #endif
 
 #ifdef DO_GNU_TESTS
@@ -31,7 +31,7 @@
 #endif
 #endif
 
-int main(int,char **)
+int main(int, char**)
 {
   TestSharedLibDepends dep;
   TestSharedLibRequired req;
@@ -43,7 +43,7 @@ int main(int,char **)
 
   return dep.foo() + req.foo()
 #ifdef TEST_SUBDIR_LIB
-                   + sdo.foo() + ren.foo()
+    + sdo.foo() + ren.foo()
 #endif
-                              ;
+    ;
 }
diff --git a/Tests/ExportImport/Import/A/imp_mod1.c b/Tests/ExportImport/Import/A/imp_mod1.c
index 579d949..89d7545 100644
--- a/Tests/ExportImport/Import/A/imp_mod1.c
+++ b/Tests/ExportImport/Import/A/imp_mod1.c
@@ -1,7 +1,7 @@
 #if defined(_WIN32) || defined(__CYGWIN__)
-# define testExe2_IMPORT __declspec(dllimport)
+#define testExe2_IMPORT __declspec(dllimport)
 #else
-# define testExe2_IMPORT
+#define testExe2_IMPORT
 #endif
 
 testExe2_IMPORT int testExe2Func(void);
diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c
index 0a74309..83a9bb5 100644
--- a/Tests/ExportImport/Import/A/imp_testExe1.c
+++ b/Tests/ExportImport/Import/A/imp_testExe1.c
@@ -14,16 +14,16 @@ extern int testLibPerConfigDest();
 /* Switch a symbol between debug and optimized builds to make sure the
    proper library is found from the testLib4 link interface.  */
 #ifdef EXE_DBG
-# define testLib4libcfg testLib4libdbg
+#define testLib4libcfg testLib4libdbg
 #else
-# define testLib4libcfg testLib4libopt
+#define testLib4libcfg testLib4libopt
 #endif
 extern testLib4libcfg(void);
 
 int main()
 {
-  return (testLib2() + generated_by_testExe1() + testLib3() + testLib4()
-          + testLib5() + testLib6() + testLib7() + testLibCycleA1()
-          + testLibPerConfigDest()
-          + generated_by_testExe3() + generated_by_testExe4() + testLib4lib() + testLib4libcfg());
+  return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() +
+          testLib5() + testLib6() + testLib7() + testLibCycleA1() +
+          testLibPerConfigDest() + generated_by_testExe3() +
+          generated_by_testExe4() + testLib4lib() + testLib4libcfg());
 }
diff --git a/Tests/ExportImport/Import/A/imp_testExeAbs1.c b/Tests/ExportImport/Import/A/imp_testExeAbs1.c
index 069c3f0..629b891 100644
--- a/Tests/ExportImport/Import/A/imp_testExeAbs1.c
+++ b/Tests/ExportImport/Import/A/imp_testExeAbs1.c
@@ -2,14 +2,12 @@
 #include "testLibAbs1a.h"
 #include "testLibAbs1b.h"
 #ifndef testLibAbs1a
-# error "testLibAbs1a not defined"
+#error "testLibAbs1a not defined"
 #endif
 #ifndef testLibAbs1b
-# error "testLibAbs1b not defined"
+#error "testLibAbs1b not defined"
 #endif
 int main()
 {
-  return 0
-    + testLibAbs1()
-    ;
+  return 0 + testLibAbs1();
 }
diff --git a/Tests/ExportImport/Import/A/renamed_test.cpp b/Tests/ExportImport/Import/A/renamed_test.cpp
index e2ee126..60d6cf9 100644
--- a/Tests/ExportImport/Import/A/renamed_test.cpp
+++ b/Tests/ExportImport/Import/A/renamed_test.cpp
@@ -1,7 +1,7 @@
 
 #include "renamed.h"
 
-int main(int, char **)
+int main(int, char**)
 {
   Renamed ren;
   return ren.foo();
diff --git a/Tests/ExportImport/Import/Interface/headeronlytest.cpp b/Tests/ExportImport/Import/Interface/headeronlytest.cpp
index 20674a7..0e754e9 100644
--- a/Tests/ExportImport/Import/Interface/headeronlytest.cpp
+++ b/Tests/ExportImport/Import/Interface/headeronlytest.cpp
@@ -9,8 +9,7 @@
 #error Unexpected SHAREDLIB_DEFINE
 #endif
 
-
-int main(int,char**)
+int main(int, char**)
 {
   HeaderOnly ho;
   return ho.foo();
diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp
index 786458d..7be8162 100644
--- a/Tests/ExportImport/Import/Interface/interfacetest.cpp
+++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp
@@ -13,7 +13,7 @@
 #error Expected DEFINE_IFACE_DEFINE
 #endif
 
-int main(int,char**)
+int main(int, char**)
 {
   SharedLibObject slo;
   return slo.foo();
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index b5041c7..ca6462d 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -349,6 +349,20 @@ if(do_git_tests)
   )
   set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
 
+  # Live git / master (no GIT_TAG), but shallow
+  #
+  set(proj TutorialStep1-GIT-shallow-master)
+  ExternalProject_Add(${proj}
+    GIT_REPOSITORY "${local_git_repo}"
+    GIT_SHALLOW 1
+    CMAKE_GENERATOR "${CMAKE_GENERATOR}"
+    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+    INSTALL_COMMAND ""
+    DEPENDS "SetupLocalGITRepository"
+    LOG_UPDATE 1
+  )
+  set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
+
   # git by explicit branch/tag with empty submodule list
   #
   set(proj TutorialStep1-GIT-bytag-withsubmodules)
@@ -543,6 +557,9 @@ if(do_git_tests)
   add_test(TutorialStep1-GIT-bytag
     "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99)
 
+  add_test(TutorialStep1-GIT-shallow-master
+    "${binary_base}/TutorialStep1-GIT-shallow-master/Tutorial" 98)
+
   add_test(TutorialStep1-GIT-master
     "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98)
 endif()
diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt
index e1a67db..17f1630 100644
--- a/Tests/ExternalProjectLocal/CMakeLists.txt
+++ b/Tests/ExternalProjectLocal/CMakeLists.txt
@@ -23,18 +23,6 @@ set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
 if(NOT DEFINED can_build_tutorial_step5)
   set(can_build_tutorial_step5 1)
 
-  # Tutorial Step5 cannot build correctly using Visual Studio 6
-  # on Windows 98 if the path of its build tree exceeds 72
-  # characters in length... So don't attempt to build it
-  # in a long path on Win98:
-  #
-  if(CMAKE_SYSTEM STREQUAL "Windows-4.10")
-    string(LENGTH "${binary_base}/TutorialStep5-Local" n)
-    if(n GREATER 72)
-      set(can_build_tutorial_step5 0)
-    endif()
-  endif()
-
   # The ExternalProject builds of Tutorial Step5 cannot be built
   # correctly 2nd and later times in an in-source build...
   # (because the CMakeCache.txt from the real in-source build of
diff --git a/Tests/ExternalProjectSubdir/CMakeLists.txt b/Tests/ExternalProjectSubdir/CMakeLists.txt
index e65087a..3a67ea0 100644
--- a/Tests/ExternalProjectSubdir/CMakeLists.txt
+++ b/Tests/ExternalProjectSubdir/CMakeLists.txt
@@ -3,11 +3,8 @@ project(ExternalProjectSubdir NONE)
 include(ExternalProject)
 
 # Remove the custom target output to be sure it runs in an
-# incremental test.  Skip this on VS 6 because it sometimes
-# re-runs CMake after the custom command runs.
-if(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 6")
-  file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/PreSubdir1.txt)
-endif()
+# incremental test.
+file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/PreSubdir1.txt)
 
 add_custom_target(PreSubdir1
   COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/PreSubdir1.txt
diff --git a/Tests/ExternalProjectUpdate/CMakeLists.txt b/Tests/ExternalProjectUpdate/CMakeLists.txt
index fbb3388..dbf26c8 100644
--- a/Tests/ExternalProjectUpdate/CMakeLists.txt
+++ b/Tests/ExternalProjectUpdate/CMakeLists.txt
@@ -21,6 +21,18 @@ set_property(DIRECTORY PROPERTY EP_BASE ${base})
 set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
 set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update)
 
+ExternalProject_Add(TestUpdateCommand
+  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+  UPDATE_COMMAND ${CMAKE_COMMAND} -E echo update
+  UPDATE_DISCONNECTED 1
+  CONFIGURE_COMMAND ""
+  BUILD_COMMAND ""
+  INSTALL_COMMAND ""
+  INDEPENDENT_STEP_TARGETS update
+  )
+add_custom_target(TestUpdateCommandDriver ALL)
+add_dependencies(TestUpdateCommandDriver TestUpdateCommand-update)
+
 set(do_git_tests 0)
 
 if(GIT_EXECUTABLE)
diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
index 7065f36..8ea4452 100644
--- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
+++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
@@ -99,7 +99,7 @@ was expected."
   endif()
 
   if( EXISTS ${FETCH_HEAD_file} )
-    message( FATAL_ERROR "Fetch occured when it was not expected.")
+    message( FATAL_ERROR "Fetch occurred when it was not expected.")
   endif()
 
   # Check the resulting SHA
diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt
index 259ee26..0e9527d 100644
--- a/Tests/FindBoost/CMakeLists.txt
+++ b/Tests/FindBoost/CMakeLists.txt
@@ -8,3 +8,14 @@ add_test(NAME FindBoost.Test COMMAND
   --build-options ${build_options}
   --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
   )
+
+add_test(NAME FindBoost.TestHeaders COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/FindBoost/TestHeaders"
+  "${CMake_BINARY_DIR}/Tests/FindBoost/TestHeaders"
+  ${build_generator_args}
+  --build-project TestFindBoostHeaders
+  --build-options ${build_options}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/FindBoost/Test/main.cxx b/Tests/FindBoost/Test/main.cxx
index 0f44f30..6e8b5da 100644
--- a/Tests/FindBoost/Test/main.cxx
+++ b/Tests/FindBoost/Test/main.cxx
@@ -1,24 +1,22 @@
 #include <boost/filesystem.hpp>
 #include <boost/thread.hpp>
 
-namespace
-{
-
-  boost::mutex m1;
-  boost::recursive_mutex m2;
+namespace {
 
-  void
-  threadmain()
-  {
-    boost::lock_guard<boost::mutex> lock1(m1);
-    boost::lock_guard<boost::recursive_mutex> lock2(m2);
+boost::mutex m1;
+boost::recursive_mutex m2;
 
-    boost::filesystem::path p(boost::filesystem::current_path());
-  }
+void threadmain()
+{
+  boost::lock_guard<boost::mutex> lock1(m1);
+  boost::lock_guard<boost::recursive_mutex> lock2(m2);
 
+  boost::filesystem::path p(boost::filesystem::current_path());
+}
 }
 
-int main() {
+int main()
+{
   boost::thread foo(threadmain);
   foo.join();
 
diff --git a/Tests/FindBoost/TestHeaders/CMakeLists.txt b/Tests/FindBoost/TestHeaders/CMakeLists.txt
new file mode 100644
index 0000000..d7be327
--- /dev/null
+++ b/Tests/FindBoost/TestHeaders/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindBoostHeaders CXX)
+include(CTest)
+
+find_package(Boost REQUIRED)
+
+add_executable(test_boost_headers_tgt main.cxx)
+target_link_libraries(test_boost_headers_tgt
+                      Boost::boost)
+add_test(NAME test_boost_headers_tgt COMMAND test_boost_headers_tgt)
diff --git a/Tests/FindBoost/TestHeaders/main.cxx b/Tests/FindBoost/TestHeaders/main.cxx
new file mode 100644
index 0000000..7844de4
--- /dev/null
+++ b/Tests/FindBoost/TestHeaders/main.cxx
@@ -0,0 +1,10 @@
+#include <boost/any.hpp>
+
+int main()
+{
+  boost::any a;
+  a = 5;
+  a = std::string("A string");
+
+  return 0;
+}
diff --git a/Tests/FindGSL/rng/main.cc b/Tests/FindGSL/rng/main.cc
index 72543be..af13125 100644
--- a/Tests/FindGSL/rng/main.cc
+++ b/Tests/FindGSL/rng/main.cc
@@ -1,5 +1,5 @@
-#include <math.h>
 #include "gsl/gsl_rng.h"
+#include <math.h>
 
 int main()
 {
@@ -7,15 +7,15 @@ int main()
   int retval = 1;
 
   // create a generator
-  gsl_rng *generator;
+  gsl_rng* generator;
   generator = gsl_rng_alloc(gsl_rng_mt19937);
 
   // Read a value.
   double const Result = gsl_rng_uniform(generator);
 
   // Check value
-  double const expectedResult( 0.999741748906672 );
-  if( fabs( expectedResult - Result ) < 1.0e-6 )
+  double const expectedResult(0.999741748906672);
+  if (fabs(expectedResult - Result) < 1.0e-6)
     retval = 0;
 
   // free allocated memory
diff --git a/Tests/FindGTK2/atk/main.c b/Tests/FindGTK2/atk/main.c
index e25030e..4dc8d4d 100644
--- a/Tests/FindGTK2/atk/main.c
+++ b/Tests/FindGTK2/atk/main.c
@@ -1,7 +1,7 @@
 #include <atk/atk.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    const gchar *name = atk_get_toolkit_name();
-    return 0;
+  const gchar* name = atk_get_toolkit_name();
+  return 0;
 }
diff --git a/Tests/FindGTK2/atkmm/main.cpp b/Tests/FindGTK2/atkmm/main.cpp
index f455c7a..89a97f7 100644
--- a/Tests/FindGTK2/atkmm/main.cpp
+++ b/Tests/FindGTK2/atkmm/main.cpp
@@ -1,8 +1,8 @@
 #include <atkmm.h>
 #include <atkmm/init.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    Atk::init();
-    return 0;
+  Atk::init();
+  return 0;
 }
diff --git a/Tests/FindGTK2/cairo/main.c b/Tests/FindGTK2/cairo/main.c
index 1b61001..e2be60c 100644
--- a/Tests/FindGTK2/cairo/main.c
+++ b/Tests/FindGTK2/cairo/main.c
@@ -1,52 +1,50 @@
 /* Taken from http://cairographics.org/samples/ */
 
-
 #include <cairo.h>
 #include <math.h>
 #include <stdio.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    char *filename;
-    if (argc != 2)
-    {
-        fprintf (stderr, "Usage: %s OUTPUT_FILENAME\n", argv[0]);
-        return 1;
-    }
-    filename = argv[1];
-    double xc = 128.0;
-    double yc = 128.0;
-    double radius = 100.0;
-    double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
-    double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
-
-    cairo_surface_t *im = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, xc * 2, yc * 2);
-    cairo_t *cr = cairo_create(im);
-
-
-    cairo_set_line_width (cr, 10.0);
-    cairo_arc (cr, xc, yc, radius, angle1, angle2);
-    cairo_stroke (cr);
-
-    /* draw helping lines */
-    cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
-    cairo_set_line_width (cr, 6.0);
-
-    cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI);
-    cairo_fill (cr);
-
-    cairo_arc (cr, xc, yc, radius, angle1, angle1);
-    cairo_line_to (cr, xc, yc);
-    cairo_arc (cr, xc, yc, radius, angle2, angle2);
-    cairo_line_to (cr, xc, yc);
-    cairo_stroke (cr);
-
-    cairo_status_t status = cairo_surface_write_to_png (im, filename);
-    cairo_surface_destroy (im);
-    if (status != CAIRO_STATUS_SUCCESS) {
-        fprintf(stderr, "Could not save png to '%s'\n", filename);
-    }
-
-    cairo_destroy(cr);
-    return 0;
+  char* filename;
+  if (argc != 2) {
+    fprintf(stderr, "Usage: %s OUTPUT_FILENAME\n", argv[0]);
+    return 1;
+  }
+  filename = argv[1];
+  double xc = 128.0;
+  double yc = 128.0;
+  double radius = 100.0;
+  double angle1 = 45.0 * (M_PI / 180.0);  /* angles are specified */
+  double angle2 = 180.0 * (M_PI / 180.0); /* in radians           */
+
+  cairo_surface_t* im =
+    cairo_image_surface_create(CAIRO_FORMAT_ARGB32, xc * 2, yc * 2);
+  cairo_t* cr = cairo_create(im);
+
+  cairo_set_line_width(cr, 10.0);
+  cairo_arc(cr, xc, yc, radius, angle1, angle2);
+  cairo_stroke(cr);
+
+  /* draw helping lines */
+  cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.6);
+  cairo_set_line_width(cr, 6.0);
+
+  cairo_arc(cr, xc, yc, 10.0, 0, 2 * M_PI);
+  cairo_fill(cr);
+
+  cairo_arc(cr, xc, yc, radius, angle1, angle1);
+  cairo_line_to(cr, xc, yc);
+  cairo_arc(cr, xc, yc, radius, angle2, angle2);
+  cairo_line_to(cr, xc, yc);
+  cairo_stroke(cr);
+
+  cairo_status_t status = cairo_surface_write_to_png(im, filename);
+  cairo_surface_destroy(im);
+  if (status != CAIRO_STATUS_SUCCESS) {
+    fprintf(stderr, "Could not save png to '%s'\n", filename);
+  }
+
+  cairo_destroy(cr);
+  return 0;
 }
diff --git a/Tests/FindGTK2/cairomm/main.cpp b/Tests/FindGTK2/cairomm/main.cpp
index ea8f106..1a669c3 100644
--- a/Tests/FindGTK2/cairomm/main.cpp
+++ b/Tests/FindGTK2/cairomm/main.cpp
@@ -1,5 +1,5 @@
-// Taken from http://cgit.freedesktop.org/cairomm/plain/examples/surfaces/image-surface.cc
-
+// Taken from
+// http://cgit.freedesktop.org/cairomm/plain/examples/surfaces/image-surface.cc
 
 /* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris,
  * et. al.
@@ -8,55 +8,57 @@
 #define _USE_MATH_DEFINES
 #endif
 
-#include <string>
-#include <iostream>
-#include <cairommconfig.h>
 #include <cairomm/context.h>
 #include <cairomm/surface.h>
+#include <cairommconfig.h>
+#include <iostream>
+#include <string>
 
 #include <cmath>
 
 int main()
 {
-    Cairo::RefPtr<Cairo::ImageSurface> surface =
-        Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400);
-
-    Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
-
-    cr->save(); // save the state of the context
-    cr->set_source_rgb(0.86, 0.85, 0.47);
-    cr->paint();    // fill image with the color
-    cr->restore();  // color is back to black now
-
-    cr->save();
-    // draw a border around the image
-    cr->set_line_width(20.0);    // make the line wider
-    cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height());
-    cr->stroke();
-
-    cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
-    // draw a circle in the center of the image
-    cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0,
-            surface->get_height() / 4.0, 0.0, 2.0 * M_PI);
-    cr->stroke();
-
-    // draw a diagonal line
-    cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0);
-    cr->line_to(surface->get_width() * 3.0 / 4.0, surface->get_height() * 3.0 / 4.0);
-    cr->stroke();
-    cr->restore();
+  Cairo::RefPtr<Cairo::ImageSurface> surface =
+    Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400);
+
+  Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
+
+  cr->save(); // save the state of the context
+  cr->set_source_rgb(0.86, 0.85, 0.47);
+  cr->paint();   // fill image with the color
+  cr->restore(); // color is back to black now
+
+  cr->save();
+  // draw a border around the image
+  cr->set_line_width(20.0); // make the line wider
+  cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height());
+  cr->stroke();
+
+  cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
+  // draw a circle in the center of the image
+  cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0,
+          surface->get_height() / 4.0, 0.0, 2.0 * M_PI);
+  cr->stroke();
+
+  // draw a diagonal line
+  cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0);
+  cr->line_to(surface->get_width() * 3.0 / 4.0,
+              surface->get_height() * 3.0 / 4.0);
+  cr->stroke();
+  cr->restore();
 
 #ifdef CAIRO_HAS_PNG_FUNCTIONS
 
-    std::string filename = "image.png";
-    surface->write_to_png(filename);
+  std::string filename = "image.png";
+  surface->write_to_png(filename);
 
-    std::cout << "Wrote png file \"" << filename << "\"" << std::endl;
+  std::cout << "Wrote png file \"" << filename << "\"" << std::endl;
 
 #else
 
-    std::cout << "You must compile cairo with PNG support for this example to work."
-        << std::endl;
+  std::cout
+    << "You must compile cairo with PNG support for this example to work."
+    << std::endl;
 
 #endif
 }
diff --git a/Tests/FindGTK2/gdk/main.c b/Tests/FindGTK2/gdk/main.c
index ac1bd4b..71f523b 100644
--- a/Tests/FindGTK2/gdk/main.c
+++ b/Tests/FindGTK2/gdk/main.c
@@ -1,7 +1,7 @@
 #include <gdk/gdk.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    gdk_init(argc, argv);
-    return 0;
+  gdk_init(argc, argv);
+  return 0;
 }
diff --git a/Tests/FindGTK2/gdk_pixbuf/main.c b/Tests/FindGTK2/gdk_pixbuf/main.c
index e42b83e..ed9f564 100644
--- a/Tests/FindGTK2/gdk_pixbuf/main.c
+++ b/Tests/FindGTK2/gdk_pixbuf/main.c
@@ -1,10 +1,10 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    const char *version = gdk_pixbuf_version;
-    const guint major = gdk_pixbuf_major_version;
-    const guint minor = gdk_pixbuf_minor_version;
-    const guint micro = gdk_pixbuf_micro_version;
-    return 0;
+  const char* version = gdk_pixbuf_version;
+  const guint major = gdk_pixbuf_major_version;
+  const guint minor = gdk_pixbuf_minor_version;
+  const guint micro = gdk_pixbuf_micro_version;
+  return 0;
 }
diff --git a/Tests/FindGTK2/gdkmm/main.cpp b/Tests/FindGTK2/gdkmm/main.cpp
index 935bcc4..639e261 100644
--- a/Tests/FindGTK2/gdkmm/main.cpp
+++ b/Tests/FindGTK2/gdkmm/main.cpp
@@ -1,7 +1,7 @@
 #include <gdkmm.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    Gdk::Color red = Gdk::Color("red");
-    return 0;
+  Gdk::Color red = Gdk::Color("red");
+  return 0;
 }
diff --git a/Tests/FindGTK2/gio/main.c b/Tests/FindGTK2/gio/main.c
index 13f4304..ebed1fc 100644
--- a/Tests/FindGTK2/gio/main.c
+++ b/Tests/FindGTK2/gio/main.c
@@ -1,8 +1,8 @@
 #include <gio/gio.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    GFile *file = g_file_new_for_path("path");
-    g_object_unref(file);
-    return 0;
+  GFile* file = g_file_new_for_path("path");
+  g_object_unref(file);
+  return 0;
 }
diff --git a/Tests/FindGTK2/giomm/main.cpp b/Tests/FindGTK2/giomm/main.cpp
index 8303ba9..c0d5975 100644
--- a/Tests/FindGTK2/giomm/main.cpp
+++ b/Tests/FindGTK2/giomm/main.cpp
@@ -1,7 +1,7 @@
 #include <giomm.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    Glib::RefPtr<Gio::File> f = Gio::File::create_for_path("path");
-    return 0;
+  Glib::RefPtr<Gio::File> f = Gio::File::create_for_path("path");
+  return 0;
 }
diff --git a/Tests/FindGTK2/glib/main.c b/Tests/FindGTK2/glib/main.c
index 80d0554..cf5e458 100644
--- a/Tests/FindGTK2/glib/main.c
+++ b/Tests/FindGTK2/glib/main.c
@@ -1,11 +1,11 @@
 #include <glib.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    if (!g_file_test("file", G_FILE_TEST_EXISTS)) {
-        g_print("File not found. \n");
-    } else {
-        g_print("File found. \n");
-    }
-    return 0;
+  if (!g_file_test("file", G_FILE_TEST_EXISTS)) {
+    g_print("File not found. \n");
+  } else {
+    g_print("File found. \n");
+  }
+  return 0;
 }
diff --git a/Tests/FindGTK2/glibmm/main.cpp b/Tests/FindGTK2/glibmm/main.cpp
index 0e8cdae..3cdc0bd 100644
--- a/Tests/FindGTK2/glibmm/main.cpp
+++ b/Tests/FindGTK2/glibmm/main.cpp
@@ -2,6 +2,6 @@
 
 int main(int, char**)
 {
-    Glib::init();
-    return 0;
+  Glib::init();
+  return 0;
 }
diff --git a/Tests/FindGTK2/gmodule/main.c b/Tests/FindGTK2/gmodule/main.c
index 5c85a6f..1ac5c1d 100644
--- a/Tests/FindGTK2/gmodule/main.c
+++ b/Tests/FindGTK2/gmodule/main.c
@@ -1,7 +1,7 @@
 #include <gmodule.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    gboolean b = g_module_supported();
-    return 0;
+  gboolean b = g_module_supported();
+  return 0;
 }
diff --git a/Tests/FindGTK2/gobject/main.c b/Tests/FindGTK2/gobject/main.c
index d3e13f9..46e2127 100644
--- a/Tests/FindGTK2/gobject/main.c
+++ b/Tests/FindGTK2/gobject/main.c
@@ -1,18 +1,21 @@
-/* Taken from https://developer.gnome.org/gobject/stable/chapter-gobject.html */
-
+/* Taken from https://developer.gnome.org/gobject/stable/chapter-gobject.html
+ */
 
 #include <glib-object.h>
 
+#define MAMAN_TYPE_BAR (maman_bar_get_type())
+#define MAMAN_BAR(obj)                                                        \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj), MAMAN_TYPE_BAR, MamanBar))
+#define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MAMAN_TYPE_BAR))
+#define MAMAN_BAR_CLASS(klass)                                                \
+  (G_TYPE_CHECK_CLASS_CAST((klass), MAMAN_TYPE_BAR, MamanBarClass))
+#define MAMAN_IS_BAR_CLASS(klass)                                             \
+  (G_TYPE_CHECK_CLASS_TYPE((klass), MAMAN_TYPE_BAR))
+#define MAMAN_BAR_GET_CLASS(obj)                                              \
+  (G_TYPE_INSTANCE_GET_CLASS((obj), MAMAN_TYPE_BAR, MamanBarClass))
 
-#define MAMAN_TYPE_BAR                  (maman_bar_get_type ())
-#define MAMAN_BAR(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_BAR, MamanBar))
-#define MAMAN_IS_BAR(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_BAR))
-#define MAMAN_BAR_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), MAMAN_TYPE_BAR, MamanBarClass))
-#define MAMAN_IS_BAR_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), MAMAN_TYPE_BAR))
-#define MAMAN_BAR_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), MAMAN_TYPE_BAR, MamanBarClass))
-
-typedef struct _MamanBar        MamanBar;
-typedef struct _MamanBarClass   MamanBarClass;
+typedef struct _MamanBar MamanBar;
+typedef struct _MamanBarClass MamanBarClass;
 
 struct _MamanBar
 {
@@ -29,18 +32,17 @@ struct _MamanBarClass
 };
 
 /* will create maman_bar_get_type and set maman_bar_parent_class */
-G_DEFINE_TYPE (MamanBar, maman_bar, G_TYPE_OBJECT);
+G_DEFINE_TYPE(MamanBar, maman_bar, G_TYPE_OBJECT);
 
-static GObject *
-maman_bar_constructor (GType                  gtype,
-                       guint                  n_properties,
-                       GObjectConstructParam *properties)
+static GObject* maman_bar_constructor(GType gtype, guint n_properties,
+                                      GObjectConstructParam* properties)
 {
-  GObject *obj;
+  GObject* obj;
 
   {
     /* Always chain up to the parent constructor */
-    obj = G_OBJECT_CLASS (maman_bar_parent_class)->constructor (gtype, n_properties, properties);
+    obj = G_OBJECT_CLASS(maman_bar_parent_class)
+            ->constructor(gtype, n_properties, properties);
   }
 
   /* update the object state depending on constructor properties */
@@ -48,25 +50,21 @@ maman_bar_constructor (GType                  gtype,
   return obj;
 }
 
-static void
-maman_bar_class_init (MamanBarClass *klass)
+static void maman_bar_class_init(MamanBarClass* klass)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
 
   gobject_class->constructor = maman_bar_constructor;
 }
 
-static void
-maman_bar_init (MamanBar *self)
+static void maman_bar_init(MamanBar* self)
 {
   /* initialize the object */
 }
 
-
-int
-main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    MamanBar *bar = g_object_new (MAMAN_TYPE_BAR, NULL);
-    g_object_unref(bar);
-    return 0;
+  MamanBar* bar = g_object_new(MAMAN_TYPE_BAR, NULL);
+  g_object_unref(bar);
+  return 0;
 }
diff --git a/Tests/FindGTK2/gthread/main.c b/Tests/FindGTK2/gthread/main.c
index ce68cbd..9606401 100644
--- a/Tests/FindGTK2/gthread/main.c
+++ b/Tests/FindGTK2/gthread/main.c
@@ -1,7 +1,7 @@
 #include <glib.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    g_thread_init(NULL);
-    return 0;
+  g_thread_init(NULL);
+  return 0;
 }
diff --git a/Tests/FindGTK2/gtk/main.c b/Tests/FindGTK2/gtk/main.c
index 309c328..010830a 100644
--- a/Tests/FindGTK2/gtk/main.c
+++ b/Tests/FindGTK2/gtk/main.c
@@ -1,15 +1,15 @@
 #include <gtk/gtk.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    GtkWidget *window;
+  GtkWidget* window;
 
-    gtk_init (&argc, &argv);
+  gtk_init(&argc, &argv);
 
-    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-    gtk_widget_show  (window);
+  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+  gtk_widget_show(window);
 
-    gtk_main ();
+  gtk_main();
 
-    return 0;
+  return 0;
 }
diff --git a/Tests/FindGTK2/gtkmm/CMakeLists.txt b/Tests/FindGTK2/gtkmm/CMakeLists.txt
index 32aafe2..eb0b7aa 100644
--- a/Tests/FindGTK2/gtkmm/CMakeLists.txt
+++ b/Tests/FindGTK2/gtkmm/CMakeLists.txt
@@ -12,3 +12,8 @@ target_link_libraries(gtkmm-target GTK2::gtkmm)
 add_executable(gtkmm-all-libs WIN32 main.cpp helloworld.cpp helloworld.h)
 target_link_libraries(gtkmm-all-libs ${GTK2_LIBRARIES})
 target_include_directories(gtkmm-all-libs PRIVATE ${GTK2_INCLUDE_DIRS})
+
+# Linking via the library variables does not cause compile feature
+# requirements to propagate.  Do it manually for purposes of this test.
+get_property(features TARGET GTK2::sigc++ PROPERTY INTERFACE_COMPILE_FEATURES)
+set_property(TARGET gtkmm-all-libs PROPERTY COMPILE_FEATURES ${features})
diff --git a/Tests/FindGTK2/gtkmm/helloworld.cpp b/Tests/FindGTK2/gtkmm/helloworld.cpp
index 535f44a..5f4e0ae 100644
--- a/Tests/FindGTK2/gtkmm/helloworld.cpp
+++ b/Tests/FindGTK2/gtkmm/helloworld.cpp
@@ -2,21 +2,21 @@
 #include <iostream>
 
 HelloWorld::HelloWorld()
-    : m_button("Hello World")   // creates a new button with label "Hello World".
+  : m_button("Hello World") // creates a new button with label "Hello World".
 {
-    // Sets the border width of the window.
-    set_border_width(10);
+  // Sets the border width of the window.
+  set_border_width(10);
 
-    // When the button receives the "clicked" signal, it will call the
-    // on_button_clicked() method defined below.
-    m_button.signal_clicked().connect(sigc::mem_fun(*this,
-                                      &HelloWorld::on_button_clicked));
+  // When the button receives the "clicked" signal, it will call the
+  // on_button_clicked() method defined below.
+  m_button.signal_clicked().connect(
+    sigc::mem_fun(*this, &HelloWorld::on_button_clicked));
 
-    // This packs the button into the Window (a container).
-    add(m_button);
+  // This packs the button into the Window (a container).
+  add(m_button);
 
-    // The final step is to display this newly created widget...
-    m_button.show();
+  // The final step is to display this newly created widget...
+  m_button.show();
 }
 
 HelloWorld::~HelloWorld()
@@ -25,5 +25,5 @@ HelloWorld::~HelloWorld()
 
 void HelloWorld::on_button_clicked()
 {
-    std::cout << "Hello World" << std::endl;
+  std::cout << "Hello World" << std::endl;
 }
diff --git a/Tests/FindGTK2/gtkmm/helloworld.h b/Tests/FindGTK2/gtkmm/helloworld.h
index ab9a076..ae9af17 100644
--- a/Tests/FindGTK2/gtkmm/helloworld.h
+++ b/Tests/FindGTK2/gtkmm/helloworld.h
@@ -6,15 +6,15 @@
 class HelloWorld : public Gtk::Window
 {
 public:
-    HelloWorld();
-    virtual ~HelloWorld();
+  HelloWorld();
+  virtual ~HelloWorld();
 
 protected:
-    //Signal handlers:
-    void on_button_clicked();
+  // Signal handlers:
+  void on_button_clicked();
 
-    //Member widgets:
-    Gtk::Button m_button;
+  // Member widgets:
+  Gtk::Button m_button;
 };
 
 #endif // GTKMM_EXAMPLE_HELLOWORLD_H
diff --git a/Tests/FindGTK2/gtkmm/main.cpp b/Tests/FindGTK2/gtkmm/main.cpp
index 5ff64d1..1637da2 100644
--- a/Tests/FindGTK2/gtkmm/main.cpp
+++ b/Tests/FindGTK2/gtkmm/main.cpp
@@ -1,13 +1,13 @@
-#include <gtkmm.h>
 #include "helloworld.h"
+#include <gtkmm.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    Gtk::Main kit(argc, argv);
+  Gtk::Main kit(argc, argv);
 
-    HelloWorld helloworld;
-    //Shows the window and returns when it is closed.
-    Gtk::Main::run(helloworld);
+  HelloWorld helloworld;
+  // Shows the window and returns when it is closed.
+  Gtk::Main::run(helloworld);
 
-    return 0;
+  return 0;
 }
diff --git a/Tests/FindGTK2/pango/main.c b/Tests/FindGTK2/pango/main.c
index ef87ce4..aa6ea92 100644
--- a/Tests/FindGTK2/pango/main.c
+++ b/Tests/FindGTK2/pango/main.c
@@ -1,7 +1,7 @@
 #include <pango/pango.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    gboolean ret = pango_color_parse(NULL, "#ffffff");
-    return 0;
+  gboolean ret = pango_color_parse(NULL, "#ffffff");
+  return 0;
 }
diff --git a/Tests/FindGTK2/pangocairo/main.c b/Tests/FindGTK2/pangocairo/main.c
index 78268d6..15db513 100644
--- a/Tests/FindGTK2/pangocairo/main.c
+++ b/Tests/FindGTK2/pangocairo/main.c
@@ -1,72 +1,68 @@
-/* Taken from https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html */
-
+/* Taken from
+ * https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html */
 
 #include <math.h>
 #include <pango/pangocairo.h>
-static void
-draw_text (cairo_t *cr)
+static void draw_text(cairo_t* cr)
 {
 #define RADIUS 150
 #define N_WORDS 10
 #define FONT "Sans Bold 27"
-  PangoLayout *layout;
-  PangoFontDescription *desc;
+  PangoLayout* layout;
+  PangoFontDescription* desc;
   int i;
   /* Center coordinates on the middle of the region we are drawing
    */
-  cairo_translate (cr, RADIUS, RADIUS);
+  cairo_translate(cr, RADIUS, RADIUS);
   /* Create a PangoLayout, set the font and text */
-  layout = pango_cairo_create_layout (cr);
-  pango_layout_set_text (layout, "Text", -1);
-  desc = pango_font_description_from_string (FONT);
-  pango_layout_set_font_description (layout, desc);
-  pango_font_description_free (desc);
+  layout = pango_cairo_create_layout(cr);
+  pango_layout_set_text(layout, "Text", -1);
+  desc = pango_font_description_from_string(FONT);
+  pango_layout_set_font_description(layout, desc);
+  pango_font_description_free(desc);
   /* Draw the layout N_WORDS times in a circle */
-  for (i = 0; i < N_WORDS; i++)
-    {
-      int width, height;
-      double angle = (360. * i) / N_WORDS;
-      double red;
-      cairo_save (cr);
-      /* Gradient from red at angle == 60 to blue at angle == 240 */
-      red   = (1 + cos ((angle - 60) * G_PI / 180.)) / 2;
-      cairo_set_source_rgb (cr, red, 0, 1.0 - red);
-      cairo_rotate (cr, angle * G_PI / 180.);
-      /* Inform Pango to re-layout the text with the new transformation */
-      pango_cairo_update_layout (cr, layout);
-      pango_layout_get_size (layout, &width, &height);
-      cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
-      pango_cairo_show_layout (cr, layout);
-      cairo_restore (cr);
-    }
+  for (i = 0; i < N_WORDS; i++) {
+    int width, height;
+    double angle = (360. * i) / N_WORDS;
+    double red;
+    cairo_save(cr);
+    /* Gradient from red at angle == 60 to blue at angle == 240 */
+    red = (1 + cos((angle - 60) * G_PI / 180.)) / 2;
+    cairo_set_source_rgb(cr, red, 0, 1.0 - red);
+    cairo_rotate(cr, angle * G_PI / 180.);
+    /* Inform Pango to re-layout the text with the new transformation */
+    pango_cairo_update_layout(cr, layout);
+    pango_layout_get_size(layout, &width, &height);
+    cairo_move_to(cr, -((double)width / PANGO_SCALE) / 2, -RADIUS);
+    pango_cairo_show_layout(cr, layout);
+    cairo_restore(cr);
+  }
   /* free the layout object */
-  g_object_unref (layout);
+  g_object_unref(layout);
 }
-int main (int argc, char **argv)
+int main(int argc, char** argv)
 {
-  cairo_t *cr;
-  char *filename;
+  cairo_t* cr;
+  char* filename;
   cairo_status_t status;
-  cairo_surface_t *surface;
-  if (argc != 2)
-    {
-      g_printerr ("Usage: cairosimple OUTPUT_FILENAME\n");
-      return 1;
-    }
+  cairo_surface_t* surface;
+  if (argc != 2) {
+    g_printerr("Usage: cairosimple OUTPUT_FILENAME\n");
+    return 1;
+  }
   filename = argv[1];
-  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                    2 * RADIUS, 2 * RADIUS);
-  cr = cairo_create (surface);
-  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
-  cairo_paint (cr);
-  draw_text (cr);
-  cairo_destroy (cr);
-  status = cairo_surface_write_to_png (surface, filename);
-  cairo_surface_destroy (surface);
-  if (status != CAIRO_STATUS_SUCCESS)
-    {
-      g_printerr ("Could not save png to '%s'\n", filename);
-      return 1;
-    }
+  surface =
+    cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 2 * RADIUS, 2 * RADIUS);
+  cr = cairo_create(surface);
+  cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+  cairo_paint(cr);
+  draw_text(cr);
+  cairo_destroy(cr);
+  status = cairo_surface_write_to_png(surface, filename);
+  cairo_surface_destroy(surface);
+  if (status != CAIRO_STATUS_SUCCESS) {
+    g_printerr("Could not save png to '%s'\n", filename);
+    return 1;
+  }
   return 0;
 }
diff --git a/Tests/FindGTK2/pangoft2/main.c b/Tests/FindGTK2/pangoft2/main.c
index cf3459e..317f7ec 100644
--- a/Tests/FindGTK2/pangoft2/main.c
+++ b/Tests/FindGTK2/pangoft2/main.c
@@ -1,8 +1,8 @@
 #include <pango/pangoft2.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    PangoFontMap* pfm = pango_ft2_font_map_new();
-    g_object_unref(pfm);
-    return 0;
+  PangoFontMap* pfm = pango_ft2_font_map_new();
+  g_object_unref(pfm);
+  return 0;
 }
diff --git a/Tests/FindGTK2/pangomm/main.cpp b/Tests/FindGTK2/pangomm/main.cpp
index 32ec914..47bf490 100644
--- a/Tests/FindGTK2/pangomm/main.cpp
+++ b/Tests/FindGTK2/pangomm/main.cpp
@@ -1,8 +1,8 @@
 #include <pangomm.h>
 #include <pangomm/init.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    Pango::init();
-    return 0;
+  Pango::init();
+  return 0;
 }
diff --git a/Tests/FindGTK2/pangoxft/main.c b/Tests/FindGTK2/pangoxft/main.c
index cb04f61..181ba27 100644
--- a/Tests/FindGTK2/pangoxft/main.c
+++ b/Tests/FindGTK2/pangoxft/main.c
@@ -1,7 +1,7 @@
 #include <pango/pangoxft.h>
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-    pango_xft_get_context(NULL, 0);
-    return 0;
+  pango_xft_get_context(NULL, 0);
+  return 0;
 }
diff --git a/Tests/FindGTK2/sigc++/main.cpp b/Tests/FindGTK2/sigc++/main.cpp
index 78428e7..e56b910 100644
--- a/Tests/FindGTK2/sigc++/main.cpp
+++ b/Tests/FindGTK2/sigc++/main.cpp
@@ -1,30 +1,29 @@
 // Taken from https://developer.gnome.org/libsigc++-tutorial/stable/ch02.html
 
-
-#include <sigc++/sigc++.h>
 #include <iostream>
+#include <sigc++/sigc++.h>
 
 class AlienDetector
 {
 public:
-    AlienDetector() {}
+  AlienDetector() {}
 
-    void run() {}
+  void run() {}
 
-    sigc::signal<void> signal_detected;
+  sigc::signal<void> signal_detected;
 };
 
 void warn_people()
 {
-    std::cout << "There are aliens in the carpark!" << std::endl;
+  std::cout << "There are aliens in the carpark!" << std::endl;
 }
 
 int main()
 {
-    AlienDetector mydetector;
-    mydetector.signal_detected.connect( sigc::ptr_fun(warn_people) );
+  AlienDetector mydetector;
+  mydetector.signal_detected.connect(sigc::ptr_fun(warn_people));
 
-    mydetector.run();
+  mydetector.run();
 
-    return 0;
+  return 0;
 }
diff --git a/Tests/FindLTTngUST/CMakeLists.txt b/Tests/FindLTTngUST/CMakeLists.txt
new file mode 100644
index 0000000..c9c471d
--- /dev/null
+++ b/Tests/FindLTTngUST/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindLTTngUST.Test COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/FindLTTngUST/Test"
+  "${CMake_BINARY_DIR}/Tests/FindLTTngUST/Test"
+  ${build_generator_args}
+  --build-project TestFindLTTngUST
+  --build-options ${build_options}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/FindLTTngUST/Test/CMakeLists.txt b/Tests/FindLTTngUST/Test/CMakeLists.txt
new file mode 100644
index 0000000..e5bd9f3
--- /dev/null
+++ b/Tests/FindLTTngUST/Test/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.5)
+project(TestFindLTTngUST C)
+include(CTest)
+
+find_package(LTTngUST REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_LTTNGUST_VERSION="${LTTNGUST_VERSION_STRING}")
+add_definitions(-DCMAKE_LTTNGUST_HAS_TRACEF="${LTTNGUST_HAS_TRACEF}")
+add_definitions(-DCMAKE_LTTNGUST_HAS_TRACELOG="${LTTNGUST_HAS_TRACELOG}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt LTTng::UST)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${LTTNGUST_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${LTTNGUST_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindLTTngUST/Test/main.c b/Tests/FindLTTngUST/Test/main.c
new file mode 100644
index 0000000..1f313c1
--- /dev/null
+++ b/Tests/FindLTTngUST/Test/main.c
@@ -0,0 +1,31 @@
+#include <assert.h>
+#include <lttng/ust-version.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef CMAKE_LTTNGUST_HAS_TRACEF
+#include <lttng/tracef.h>
+#endif
+
+#ifdef CMAKE_LTTNGUST_HAS_TRACELOG
+#include <lttng/tracelog.h>
+#endif
+
+int main(void)
+{
+  char lttng_version_string[16];
+
+  snprintf(lttng_version_string, 16, "%u.%u.%u", LTTNG_UST_MAJOR_VERSION,
+           LTTNG_UST_MINOR_VERSION, LTTNG_UST_PATCHLEVEL_VERSION);
+  assert(!strcmp(lttng_version_string, CMAKE_EXPECTED_LTTNGUST_VERSION));
+
+#ifdef CMAKE_LTTNGUST_HAS_TRACEF
+  tracef("calling tracef()! %d %s", -23, CMAKE_EXPECTED_LTTNGUST_VERSION);
+#endif
+
+#ifdef CMAKE_LTTNGUST_HAS_TRACELOG
+  tracelog(TRACE_WARNING, "calling tracelog()! %d", 17);
+#endif
+
+  return 0;
+}
diff --git a/Tests/FindMatlab/matlab_wrapper1.cpp b/Tests/FindMatlab/matlab_wrapper1.cpp
index 4149bb9..ebf1b87 100644
--- a/Tests/FindMatlab/matlab_wrapper1.cpp
+++ b/Tests/FindMatlab/matlab_wrapper1.cpp
@@ -1,24 +1,25 @@
 
 // simple workaround to some compiler specific problems
-// see http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
+// see
+// http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
 #include <algorithm>
 
 #include "mex.h"
 
-// this test should return a matrix of 10 x 10 and should check some of the arguments
+// this test should return a matrix of 10 x 10 and should check some of the
+// arguments
 
-void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[])
+void mexFunction(const int nlhs, mxArray* plhs[], const int nrhs,
+                 const mxArray* prhs[])
 {
-  if(nrhs != 1)
-  {
+  if (nrhs != 1) {
     mexErrMsgTxt("Incorrect arguments");
   }
 
   size_t dim1 = mxGetM(prhs[0]);
   size_t dim2 = mxGetN(prhs[0]);
 
-  if(dim1 == 1 || dim2 == 1)
-  {
+  if (dim1 == 1 || dim2 == 1) {
     mexErrMsgIdAndTxt("cmake_matlab:configuration", "Incorrect arguments");
   }
 
diff --git a/Tests/FindModulesExecuteAll/main.c b/Tests/FindModulesExecuteAll/main.c
index c13815c..f8b643a 100644
--- a/Tests/FindModulesExecuteAll/main.c
+++ b/Tests/FindModulesExecuteAll/main.c
@@ -1,4 +1,4 @@
 int main()
 {
-   return 0;
+  return 0;
 }
diff --git a/Tests/FindOpenSSL/rand/main.cc b/Tests/FindOpenSSL/rand/main.cc
index a5d1ac0..d81b318 100644
--- a/Tests/FindOpenSSL/rand/main.cc
+++ b/Tests/FindOpenSSL/rand/main.cc
@@ -12,8 +12,7 @@ int main()
   int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 succes, 0 otherwise */
 
   // check result
-  if(rezval == 1)
-  {
+  if (rezval == 1) {
     retval = 0;
   }
 
diff --git a/Tests/FindPNG/Test/main.c b/Tests/FindPNG/Test/main.c
index 27e1478..b33b28e 100644
--- a/Tests/FindPNG/Test/main.c
+++ b/Tests/FindPNG/Test/main.c
@@ -1,20 +1,18 @@
 #include <assert.h>
-#include <string.h>
 #include <png.h>
+#include <string.h>
 
 int main()
 {
   png_uint_32 png_version;
   char png_version_string[16];
 
-  png_version = png_access_version_number ();
+  png_version = png_access_version_number();
 
-  snprintf (png_version_string, 16, "%i.%i.%i",
-            png_version / 10000,
-            (png_version % 10000) / 100,
-            png_version % 100);
+  snprintf(png_version_string, 16, "%i.%i.%i", png_version / 10000,
+           (png_version % 10000) / 100, png_version % 100);
 
-  assert (strcmp(png_version_string, CMAKE_EXPECTED_PNG_VERSION) == 0);
+  assert(strcmp(png_version_string, CMAKE_EXPECTED_PNG_VERSION) == 0);
 
   return 0;
 }
diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
index 8e21c32..56fcc5d 100644
--- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt
+++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
@@ -1,6 +1,7 @@
 
 
-if(UNIX  AND  "${CMAKE_GENERATOR}" MATCHES "Makefile")
+if(UNIX  AND  "${CMAKE_GENERATOR}" MATCHES "Makefile" AND
+    NOT CMake_TEST_NO_FindPackageModeMakefileTest)
 
   # Test whether the make is GNU make, and only add the test in this case,
   # since the configured makefile in this test uses $(shell ...), which
diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp
index e5f9134..9def3fb 100644
--- a/Tests/FindPackageModeMakefileTest/main.cpp
+++ b/Tests/FindPackageModeMakefileTest/main.cpp
@@ -1,8 +1,8 @@
-#include <stdio.h>
 #include <foo.h>
+#include <stdio.h>
 
 int main()
 {
- printf("foo is: %d\n", foo());
- return 0;
+  printf("foo is: %d\n", foo());
+  return 0;
 }
diff --git a/Tests/FindPackageTest/Exporter/dummy.c b/Tests/FindPackageTest/Exporter/dummy.c
index 76e8197..f8b643a 100644
--- a/Tests/FindPackageTest/Exporter/dummy.c
+++ b/Tests/FindPackageTest/Exporter/dummy.c
@@ -1 +1,4 @@
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/FindTIFF/Test/main.c b/Tests/FindTIFF/Test/main.c
index fc4f337..9182652 100644
--- a/Tests/FindTIFF/Test/main.c
+++ b/Tests/FindTIFF/Test/main.c
@@ -5,7 +5,7 @@ int main()
 {
   /* Without any TIFF file to open, test that the call fails as
      expected.  This tests that linking worked. */
-  TIFF *tiff = TIFFOpen("invalid.tiff", "r");
+  TIFF* tiff = TIFFOpen("invalid.tiff", "r");
   assert(!tiff);
 
   return 0;
diff --git a/Tests/FindXalanC/Test/main.cxx b/Tests/FindXalanC/Test/main.cxx
index 3b4a2df..7d0f42c 100644
--- a/Tests/FindXalanC/Test/main.cxx
+++ b/Tests/FindXalanC/Test/main.cxx
@@ -1,5 +1,5 @@
-#include <xercesc/util/PlatformUtils.hpp>
 #include <xalanc/XalanTransformer/XalanTransformer.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 
 int main()
 {
diff --git a/Tests/ForceInclude/foo.c b/Tests/ForceInclude/foo.c
index af898f4..7f550d0 100644
--- a/Tests/ForceInclude/foo.c
+++ b/Tests/ForceInclude/foo.c
@@ -1,7 +1,10 @@
 #ifndef FOO_1
-# error "foo1.h not included by /FI"
+#error "foo1.h not included by /FI"
 #endif
 #ifndef FOO_2
-# error "foo2.h not included by /FI"
+#error "foo2.h not included by /FI"
 #endif
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index ecf38a6..1268982 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.0)
+cmake_minimum_required (VERSION 3.1)
 project(testf C CXX Fortran)
 if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
   set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
@@ -119,7 +119,7 @@ endfunction()
 # call the test_fortran_c_interface_module function
 if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES
     "(Intel:MSVC|Absoft:GNU)"
-    OR (CMAKE_Fortran_COMPILER_ID MATCHES CMAKE_C_COMPILER_ID ))
+    OR ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_C_COMPILER_ID}" ))
   test_fortran_c_interface_module()
 else()
   message("Fortran does not match c compiler")
diff --git a/Tests/Fortran/include/test_preprocess.h b/Tests/Fortran/include/test_preprocess.h
index 29ac4b6..f4a00a9 100644
--- a/Tests/Fortran/include/test_preprocess.h
+++ b/Tests/Fortran/include/test_preprocess.h
@@ -1,5 +1,5 @@
 #ifdef BAR
-  PRINT * , 'BAR was defined via ADD_DEFINITIONS'
+PRINT*, 'BAR was defined via ADD_DEFINITIONS'
 #else
-  PRINT *, 'If you can read this something went wrong'
+PRINT*, 'If you can read this something went wrong'
 #endif
diff --git a/Tests/Framework/foo.cxx b/Tests/Framework/foo.cxx
index e5c1973..c3520c1 100644
--- a/Tests/Framework/foo.cxx
+++ b/Tests/Framework/foo.cxx
@@ -1,8 +1,8 @@
 #include <stdio.h>
 #if defined(_WIN32) && defined(foo_EXPORTS)
-#  define CM_TEST_LIB_EXPORT  __declspec( dllexport )
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT
 #endif
 CM_TEST_LIB_EXPORT void foo()
 {
diff --git a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
index 2356bc4..233eb57 100644
--- a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
+++ b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
@@ -1,20 +1,20 @@
 
 #ifdef Type_Is_
-#  if !Result
-#    error Result should be 1 in WARN mode
-#  endif
+#if !Result
+#error Result should be 1 in WARN mode
+#endif
 #endif
 
 #ifdef Type_Is_NEW
-#  if Result
-#    error Result should be 0 in NEW mode
-#  endif
+#if Result
+#error Result should be 0 in NEW mode
+#endif
 #endif
 
 #ifdef Type_Is_OLD
-#  if !Result
-#    error Result should be 1 in OLD mode
-#  endif
+#if !Result
+#error Result should be 1 in OLD mode
+#endif
 #endif
 
 #if !defined(Type_Is_) && !defined(Type_Is_OLD) && !defined(Type_Is_NEW)
diff --git a/Tests/GeneratorExpression/empty.cpp b/Tests/GeneratorExpression/empty.cpp
index f8732a4..7be1ca5 100644
--- a/Tests/GeneratorExpression/empty.cpp
+++ b/Tests/GeneratorExpression/empty.cpp
@@ -1,4 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int main() { return 0; }
+  int main()
+{
+  return 0;
+}
diff --git a/Tests/GeneratorExpression/pwd.c b/Tests/GeneratorExpression/pwd.c
index 054b1af..ed23043 100644
--- a/Tests/GeneratorExpression/pwd.c
+++ b/Tests/GeneratorExpression/pwd.c
@@ -15,19 +15,17 @@ int main(int argc, char* argv[])
 #define BUFSZ 20000
   char buf[BUFSZ + 1];
 #ifdef _WIN32
-  char *pos;
+  char* pos;
 #endif
   getcurdir(buf, BUFSZ);
 #ifdef _WIN32
   pos = buf;
-  while (*pos)
-    {
-    if (*pos == '\\')
-      {
+  while (*pos) {
+    if (*pos == '\\') {
       *pos = '/';
-      }
-    ++pos;
     }
+    ++pos;
+  }
 #endif
   printf("%s\n", buf);
   return EXIT_SUCCESS;
diff --git a/Tests/GhsMulti/ReturnNum/App/Main.c b/Tests/GhsMulti/ReturnNum/App/Main.c
index 1133834..db8d658 100644
--- a/Tests/GhsMulti/ReturnNum/App/Main.c
+++ b/Tests/GhsMulti/ReturnNum/App/Main.c
@@ -2,7 +2,7 @@
 
 int main(int argc, const char* argv[])
 {
-    int out;
-    out = giveNum();
-    return out;
+  int out;
+  out = giveNum();
+  return out;
 }
diff --git a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c b/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c
index d7515d7..61922bb 100644
--- a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c
+++ b/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c
@@ -1,4 +1,4 @@
 int giveNum(void)
 {
-    return 1;
+  return 1;
 }
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt b/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt
new file mode 100644
index 0000000..82a014b
--- /dev/null
+++ b/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.5)
+project(demo C)
+
+add_library(libdemo
+  test.c
+  subfolder_test.c
+  subfolder_test_0.c
+  "subfolder/test.c"
+)
+
+add_executable(demo main.c)
+target_link_libraries(demo libdemo)
+if(GHSMULTI)
+    target_compile_options(demo PUBLIC "-non_shared")
+endif()
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/main.c b/Tests/GhsMultiDuplicateSourceFilenames/main.c
new file mode 100644
index 0000000..d5b7914
--- /dev/null
+++ b/Tests/GhsMultiDuplicateSourceFilenames/main.c
@@ -0,0 +1,13 @@
+int test_a(void);
+int test_b(void);
+int test_c(void);
+int test_d(void);
+
+int main(int argc, char* argv[])
+{
+  test_a();
+  test_b();
+  test_c();
+  test_d();
+  return 0;
+}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c b/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c
new file mode 100644
index 0000000..e1e1759
--- /dev/null
+++ b/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c
@@ -0,0 +1,5 @@
+
+int test_b()
+{
+  return 2;
+}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c b/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c
new file mode 100644
index 0000000..c552e6a
--- /dev/null
+++ b/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c
@@ -0,0 +1,5 @@
+
+int test_c()
+{
+  return 1;
+}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c b/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c
new file mode 100644
index 0000000..170b33d
--- /dev/null
+++ b/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c
@@ -0,0 +1,5 @@
+
+int test_d()
+{
+  return 1;
+}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/test.c b/Tests/GhsMultiDuplicateSourceFilenames/test.c
new file mode 100644
index 0000000..5ffcbdf
--- /dev/null
+++ b/Tests/GhsMultiDuplicateSourceFilenames/test.c
@@ -0,0 +1,5 @@
+
+int test_a()
+{
+  return 1;
+}
diff --git a/Tests/IncludeDirectories/CMP0021/main.cpp b/Tests/IncludeDirectories/CMP0021/main.cpp
index f886c46..f638ed1 100644
--- a/Tests/IncludeDirectories/CMP0021/main.cpp
+++ b/Tests/IncludeDirectories/CMP0021/main.cpp
@@ -5,7 +5,7 @@
 #error Expected CMP0021_DEFINE
 #endif
 
-int main(int, char **)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index 9ee1957..523c4f7 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -63,6 +63,7 @@ else()
     PROPERTIES COMPILE_FLAGS "-ITarProp")
 endif()
 
+add_subdirectory(StandardIncludeDirectories)
 add_subdirectory(TargetIncludeDirectories)
 
 set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}")
diff --git a/Tests/IncludeDirectories/StandardIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/StandardIncludeDirectories/CMakeLists.txt
new file mode 100644
index 0000000..dcbc566
--- /dev/null
+++ b/Tests/IncludeDirectories/StandardIncludeDirectories/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Normally this variable should be set by a platform information module or
+# a toolchain file, but for purposes of this test we simply set it here.
+set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/StdDir)
+
+add_executable(StandardIncludeDirectories main.c)
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS70-WARN-OFF.cmake b/Tests/IncludeDirectories/StandardIncludeDirectories/StdDir/StdIncDir.h
similarity index 100%
rename from Tests/RunCMake/CommandLine/DeprecateVS70-WARN-OFF.cmake
rename to Tests/IncludeDirectories/StandardIncludeDirectories/StdDir/StdIncDir.h
diff --git a/Tests/IncludeDirectories/StandardIncludeDirectories/main.c b/Tests/IncludeDirectories/StandardIncludeDirectories/main.c
new file mode 100644
index 0000000..edfe9ce
--- /dev/null
+++ b/Tests/IncludeDirectories/StandardIncludeDirectories/main.c
@@ -0,0 +1,5 @@
+#include "StdIncDir.h"
+int main()
+{
+  return 0;
+}
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/config_specific/config_iface.h b/Tests/IncludeDirectories/SystemIncludeDirectories/config_specific/config_iface.h
index 05d3604..02e28b3 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/config_specific/config_iface.h
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/config_specific/config_iface.h
@@ -5,7 +5,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int configUnusedFunc()
+  int configUnusedFunc()
 {
   int unused;
   return 0;
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp
index f111bfa..5516b62 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp
@@ -1,4 +1,7 @@
 
 #include "systemlib.h"
 
-int systemlib() { return 0; }
+int systemlib()
+{
+  return 0;
+}
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h
index c84de6a..1cb7eed 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h
@@ -5,12 +5,12 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int systemlib();
+  int systemlib();
 
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int unusedFunc()
+  int unusedFunc()
 {
   int unused;
   return systemlib();
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp
index f716b99..c569307 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp
@@ -1,4 +1,7 @@
 
 #include "upstream.h"
 
-int upstream() { return systemlib(); }
+int upstream()
+{
+  return systemlib();
+}
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h
index 3628568..a670c2a 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h
@@ -7,6 +7,6 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int upstream();
+  int upstream();
 
 #endif
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/empty.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/empty.cpp
index 7279c5e..8d91e77 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/empty.cpp
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty(void)
+  int empty(void)
 {
   return 0;
 }
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
index aed0bde..2ee05e2 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
@@ -1,17 +1,17 @@
 
+#include "arguments.h"
+#include "bang.h"
 #include "bar.h"
 #include "bat.h"
-#include "foo.h"
 #include "baz.h"
-#include "bang.h"
 #include "bing.h"
 #include "bung.h"
-#include "ting.h"
-#include "arguments.h"
+#include "common.h"
+#include "foo.h"
 #include "list.h"
-#include "target.h"
 #include "prefix_foo_bar_bat.h"
-#include "common.h"
+#include "target.h"
+#include "ting.h"
 
 int main(int, char**)
 {
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/other.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/other.cpp
index 6673471..9f961ac 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/other.cpp
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/other.cpp
@@ -1,6 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int other() {
+  int other()
+{
   return 0;
 }
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/sing/ting/ting.h b/Tests/IncludeDirectories/TargetIncludeDirectories/sing/ting/ting.h
index 4fe01dd..9b816b6 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/sing/ting/ting.h
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/sing/ting/ting.h
@@ -1 +1 @@
-//ting.h
+// ting.h
diff --git a/Tests/IncludeDirectories/empty.cpp b/Tests/IncludeDirectories/empty.cpp
index 1787013..11ec041 100644
--- a/Tests/IncludeDirectories/empty.cpp
+++ b/Tests/IncludeDirectories/empty.cpp
@@ -1,4 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty() { return 0; }
+  int empty()
+{
+  return 0;
+}
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
index 9044076..a6b5592 100644
--- a/Tests/InterfaceLibrary/definetestexe.cpp
+++ b/Tests/InterfaceLibrary/definetestexe.cpp
@@ -18,7 +18,7 @@
 extern int obj();
 extern int sub();
 
-int main(int,char**)
+int main(int, char**)
 {
   return obj() + sub();
 }
diff --git a/Tests/InterfaceLibrary/dummy.cpp b/Tests/InterfaceLibrary/dummy.cpp
index 341aaaf..e9ad257 100644
--- a/Tests/InterfaceLibrary/dummy.cpp
+++ b/Tests/InterfaceLibrary/dummy.cpp
@@ -1,5 +1,5 @@
 
-int main(int, char **)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/InterfaceLibrary/ifacedir/sub.cpp b/Tests/InterfaceLibrary/ifacedir/sub.cpp
index 165a66a..cda7e4f 100644
--- a/Tests/InterfaceLibrary/ifacedir/sub.cpp
+++ b/Tests/InterfaceLibrary/ifacedir/sub.cpp
@@ -1 +1,4 @@
-int sub() { return 0; }
+int sub()
+{
+  return 0;
+}
diff --git a/Tests/InterfaceLibrary/map_config.cpp b/Tests/InterfaceLibrary/map_config.cpp
index 81bb666..232a18e 100644
--- a/Tests/InterfaceLibrary/map_config.cpp
+++ b/Tests/InterfaceLibrary/map_config.cpp
@@ -9,7 +9,7 @@
 #endif
 #endif
 
-int main(int,char**)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/InterfaceLibrary/obj.cpp b/Tests/InterfaceLibrary/obj.cpp
index ee6f5fe..475800d 100644
--- a/Tests/InterfaceLibrary/obj.cpp
+++ b/Tests/InterfaceLibrary/obj.cpp
@@ -1 +1,4 @@
-int obj() { return 0; }
+int obj()
+{
+  return 0;
+}
diff --git a/Tests/InterfaceLibrary/sharedlibtestexe.cpp b/Tests/InterfaceLibrary/sharedlibtestexe.cpp
index c677f70..44f160d 100644
--- a/Tests/InterfaceLibrary/sharedlibtestexe.cpp
+++ b/Tests/InterfaceLibrary/sharedlibtestexe.cpp
@@ -10,7 +10,7 @@
 #include "sharedlib.h"
 #include "shareddependlib.h"
 
-int main(int,char**)
+int main(int, char**)
 {
   SharedLibObject sl;
   SharedDependLibObject sdl = sl.object();
diff --git a/Tests/InterfaceLinkLibraries/bang.h b/Tests/InterfaceLinkLibraries/bang.h
index acffb39..908f20c 100644
--- a/Tests/InterfaceLinkLibraries/bang.h
+++ b/Tests/InterfaceLinkLibraries/bang.h
@@ -1,4 +1,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int bang();
+  int bang();
diff --git a/Tests/InterfaceLinkLibraries/bar.cpp b/Tests/InterfaceLinkLibraries/bar.cpp
index f39bfa5..228ed80 100644
--- a/Tests/InterfaceLinkLibraries/bar.cpp
+++ b/Tests/InterfaceLinkLibraries/bar.cpp
@@ -4,14 +4,14 @@
 #endif
 
 #ifdef BAR_USE_BANG
-#  ifndef BANG_LIBRARY
-#    error Expected BANG_LIBRARY
-#  endif
-#  include "bang.h"
+#ifndef BANG_LIBRARY
+#error Expected BANG_LIBRARY
+#endif
+#include "bang.h"
 #else
-#  ifdef BANG_LIBRARY
-#    error Unexpected BANG_LIBRARY
-#  endif
+#ifdef BANG_LIBRARY
+#error Unexpected BANG_LIBRARY
+#endif
 #endif
 
 #include "bar.h"
diff --git a/Tests/InterfaceLinkLibraries/bar.h b/Tests/InterfaceLinkLibraries/bar.h
index f83b37e..f31a25f 100644
--- a/Tests/InterfaceLinkLibraries/bar.h
+++ b/Tests/InterfaceLinkLibraries/bar.h
@@ -4,4 +4,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int bar();
+  int bar();
diff --git a/Tests/InterfaceLinkLibraries/foo.h b/Tests/InterfaceLinkLibraries/foo.h
index e12e23c..9b73885 100644
--- a/Tests/InterfaceLinkLibraries/foo.h
+++ b/Tests/InterfaceLinkLibraries/foo.h
@@ -1,4 +1,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int foo();
+  int foo();
diff --git a/Tests/InterfaceLinkLibraries/zot.h b/Tests/InterfaceLinkLibraries/zot.h
index 5e4fb1e..e80328b 100644
--- a/Tests/InterfaceLinkLibraries/zot.h
+++ b/Tests/InterfaceLinkLibraries/zot.h
@@ -4,4 +4,4 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int zot();
+  int zot();
diff --git a/Tests/JCTest/TestTime.cxx b/Tests/JCTest/TestTime.cxx
index 5768ab5..b98e1d3 100644
--- a/Tests/JCTest/TestTime.cxx
+++ b/Tests/JCTest/TestTime.cxx
@@ -4,9 +4,8 @@
 int main(int ac, char** av)
 {
   float d = 10.0;
-  for(int i =0; i < atoi(av[1]); i++)
-    {
+  for (int i = 0; i < atoi(av[1]); i++) {
     d *= .2;
-    }
+  }
   printf("%f", d);
 }
diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp
index 2666757..491107e 100644
--- a/Tests/JavaJavah/B.cpp
+++ b/Tests/JavaJavah/B.cpp
@@ -4,7 +4,7 @@
 
 #include "B.h"
 
-JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject)
+JNIEXPORT void JNICALL Java_B_printName(JNIEnv*, jobject)
 {
   printf("B\n");
 }
diff --git a/Tests/JavaJavah/C.cpp b/Tests/JavaJavah/C.cpp
index ec75f42..0a3178f 100644
--- a/Tests/JavaJavah/C.cpp
+++ b/Tests/JavaJavah/C.cpp
@@ -4,7 +4,7 @@
 
 #include "C.h"
 
-JNIEXPORT void JNICALL Java_C_printName(JNIEnv *, jobject)
+JNIEXPORT void JNICALL Java_C_printName(JNIEnv*, jobject)
 {
   printf("C\n");
 }
diff --git a/Tests/Jump/Executable/jumpExecutable.cxx b/Tests/Jump/Executable/jumpExecutable.cxx
index 7a050c7..6fa2683 100644
--- a/Tests/Jump/Executable/jumpExecutable.cxx
+++ b/Tests/Jump/Executable/jumpExecutable.cxx
@@ -1,7 +1,7 @@
 #ifdef _WIN32
-# define JUMP_IMPORT __declspec(dllimport)
+#define JUMP_IMPORT __declspec(dllimport)
 #else
-# define JUMP_IMPORT extern
+#define JUMP_IMPORT extern
 #endif
 
 extern int jumpStatic();
diff --git a/Tests/Jump/Library/Shared/jumpShared.cxx b/Tests/Jump/Library/Shared/jumpShared.cxx
index f500058..7c4dee9 100644
--- a/Tests/Jump/Library/Shared/jumpShared.cxx
+++ b/Tests/Jump/Library/Shared/jumpShared.cxx
@@ -1,7 +1,10 @@
 #ifdef _WIN32
-# define JUMP_EXPORT __declspec(dllexport)
+#define JUMP_EXPORT __declspec(dllexport)
 #else
-# define JUMP_EXPORT
+#define JUMP_EXPORT
 #endif
 
-JUMP_EXPORT int jumpShared() { return 0; }
+JUMP_EXPORT int jumpShared()
+{
+  return 0;
+}
diff --git a/Tests/Jump/Library/Static/jumpStatic.cxx b/Tests/Jump/Library/Static/jumpStatic.cxx
index 1f92eb9..9b169cf 100644
--- a/Tests/Jump/Library/Static/jumpStatic.cxx
+++ b/Tests/Jump/Library/Static/jumpStatic.cxx
@@ -1 +1,4 @@
-int jumpStatic() { return 0; }
+int jumpStatic()
+{
+  return 0;
+}
diff --git a/Tests/LibName/bar.c b/Tests/LibName/bar.c
index f82aa28..c6c1e66 100644
--- a/Tests/LibName/bar.c
+++ b/Tests/LibName/bar.c
@@ -2,6 +2,6 @@
 __declspec(dllexport)
 #endif
 
-extern  void foo()
+  extern void foo()
 {
 }
diff --git a/Tests/LibName/foo.c b/Tests/LibName/foo.c
index 6d258e0..52e8d89 100644
--- a/Tests/LibName/foo.c
+++ b/Tests/LibName/foo.c
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllimport)
 #endif
-extern  void foo();
+  extern void foo();
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
diff --git a/Tests/LibName/foobar.c b/Tests/LibName/foobar.c
index 2f8a3ff..2f28d30 100644
--- a/Tests/LibName/foobar.c
+++ b/Tests/LibName/foobar.c
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllimport)
 #endif
-extern  void bar();
+  extern void bar();
 
 int main()
 {
diff --git a/Tests/LinkDirectory/External/myexe.c b/Tests/LinkDirectory/External/myexe.c
index 6ef1ebe..57d361d 100644
--- a/Tests/LinkDirectory/External/myexe.c
+++ b/Tests/LinkDirectory/External/myexe.c
@@ -1,3 +1,6 @@
 extern int mylibA(void);
 extern int mylibB(void);
-int main(void) { return mylibA() + mylibB(); }
+int main(void)
+{
+  return mylibA() + mylibB();
+}
diff --git a/Tests/LinkDirectory/mylibA.c b/Tests/LinkDirectory/mylibA.c
index 890a089..dd9838f 100644
--- a/Tests/LinkDirectory/mylibA.c
+++ b/Tests/LinkDirectory/mylibA.c
@@ -1 +1,4 @@
-int mylibA(void) { return 0; }
+int mylibA(void)
+{
+  return 0;
+}
diff --git a/Tests/LinkDirectory/mylibB.c b/Tests/LinkDirectory/mylibB.c
index 090cc6c..87cebdf 100644
--- a/Tests/LinkDirectory/mylibB.c
+++ b/Tests/LinkDirectory/mylibB.c
@@ -1 +1,4 @@
-int mylibB(void) { return 0; }
+int mylibB(void)
+{
+  return 0;
+}
diff --git a/Tests/LinkFlags/LinkFlags.c b/Tests/LinkFlags/LinkFlags.c
index 78f2de1..8488f4e 100644
--- a/Tests/LinkFlags/LinkFlags.c
+++ b/Tests/LinkFlags/LinkFlags.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/LinkFlags/LinkFlagsExe.c b/Tests/LinkFlags/LinkFlagsExe.c
index 123587a..4d44146 100644
--- a/Tests/LinkFlags/LinkFlagsExe.c
+++ b/Tests/LinkFlags/LinkFlagsExe.c
@@ -1,6 +1,9 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
 
 /* Intel compiler does not reject bad flags or objects!  */
 #if defined(__INTEL_COMPILER)
-# error BADFLAG
+#error BADFLAG
 #endif
diff --git a/Tests/LinkFlags/LinkFlagsLib.c b/Tests/LinkFlags/LinkFlagsLib.c
index 9d8d088..f354206 100644
--- a/Tests/LinkFlags/LinkFlagsLib.c
+++ b/Tests/LinkFlags/LinkFlagsLib.c
@@ -1,6 +1,9 @@
-int flags_lib(void) { return 0; }
+int flags_lib(void)
+{
+  return 0;
+}
 
 /* Intel compiler does not reject bad flags or objects!  */
 #if defined(__INTEL_COMPILER)
-# error BADFLAG
+#error BADFLAG
 #endif
diff --git a/Tests/LinkLanguage/LinkLanguage.c b/Tests/LinkLanguage/LinkLanguage.c
index cf1557c..37946c7 100644
--- a/Tests/LinkLanguage/LinkLanguage.c
+++ b/Tests/LinkLanguage/LinkLanguage.c
@@ -3,4 +3,3 @@ int main()
 {
   return foo();
 }
-
diff --git a/Tests/LinkLine/One.c b/Tests/LinkLine/One.c
index 167f07d..856d0d1 100644
--- a/Tests/LinkLine/One.c
+++ b/Tests/LinkLine/One.c
@@ -4,7 +4,7 @@ void OneFunc()
 {
   static int i = 0;
   ++i;
-  if( i==1 ) {
+  if (i == 1) {
     TwoFunc();
   }
 }
diff --git a/Tests/LinkLine/Two.c b/Tests/LinkLine/Two.c
index 0db73a8..5fc212e 100644
--- a/Tests/LinkLine/Two.c
+++ b/Tests/LinkLine/Two.c
@@ -4,7 +4,7 @@ void TwoFunc()
 {
   static int i = 0;
   ++i;
-  if( i==1 ) {
+  if (i == 1) {
     OneFunc();
   }
 }
diff --git a/Tests/LinkLineOrder/NoDepE.c b/Tests/LinkLineOrder/NoDepE.c
index e1ba749..c47bb85 100644
--- a/Tests/LinkLineOrder/NoDepE.c
+++ b/Tests/LinkLineOrder/NoDepE.c
@@ -4,7 +4,7 @@ void NoDepF_func();
 void NoDepE_func()
 {
   static int firstcall = 1;
-  if( firstcall ) {
+  if (firstcall) {
     firstcall = 0;
     NoDepF_func();
   }
diff --git a/Tests/LinkLineOrder/NoDepF.c b/Tests/LinkLineOrder/NoDepF.c
index 8311cb8..a814310 100644
--- a/Tests/LinkLineOrder/NoDepF.c
+++ b/Tests/LinkLineOrder/NoDepF.c
@@ -4,7 +4,7 @@ void NoDepE_func();
 void NoDepF_func()
 {
   static int firstcall = 1;
-  if( firstcall ) {
+  if (firstcall) {
     firstcall = 0;
     NoDepE_func();
   }
diff --git a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
index fc04934..3558f89 100644
--- a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
+++ b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
@@ -1,67 +1,59 @@
 #include "cmCPluginAPI.h"
-#include <string.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 typedef struct
 {
-  char *LibraryName;
+  char* LibraryName;
   int Argc;
   char** Argv;
 } cmVTKWrapTclData;
 
 /* do almost everything in the initial pass */
-static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
+static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
 {
   char* file;
   char* str;
-  char *srcs;
+  char* srcs;
   const char* cstr;
   char buffer[1024];
-  void *source_file;
-  char *args[2];
-  char *ccArgs[4];
-  char *ccDep[1];
-  char *ccOut[1];
-  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
-
-  cmVTKWrapTclData *cdata =
-    (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData));
+  void* source_file;
+  char* args[2];
+  char* ccArgs[4];
+  char* ccDep[1];
+  char* ccOut[1];
+  cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
+
+  cmVTKWrapTclData* cdata =
+    (cmVTKWrapTclData*)malloc(sizeof(cmVTKWrapTclData));
   cdata->LibraryName = "BOO";
   cdata->Argc = argc;
   cdata->Argv = argv;
-  info->CAPI->SetClientData(info,cdata);
+  info->CAPI->SetClientData(info, cdata);
 
   /* Now check and see if the value has been stored in the cache */
   /* already, if so use that value and don't look for the program */
-  if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1"))
-    {
+  if (!info->CAPI->IsOn(mf, "TEST_COMMAND_TEST1")) {
     info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
     return 1;
-    }
+  }
 
   info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
   cdata->LibraryName = "HOO";
 
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE", "ON",
-    "Test cache variable",
-    CM_CACHE_BOOL);
+                                 "Test cache variable", CM_CACHE_BOOL);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE1", "",
-    "Test cache variable 1",
-    CM_CACHE_PATH);
+                                 "Test cache variable 1", CM_CACHE_PATH);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE2", "",
-    "Test cache variable 2",
-    CM_CACHE_FILEPATH);
+                                 "Test cache variable 2", CM_CACHE_FILEPATH);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE3", "",
-    "Test cache variable 3",
-    CM_CACHE_STRING);
+                                 "Test cache variable 3", CM_CACHE_STRING);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE4", "",
-    "Test cache variable 4",
-    CM_CACHE_INTERNAL);
+                                 "Test cache variable 4", CM_CACHE_INTERNAL);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE5", "",
-    "Test cache variable 5",
-    CM_CACHE_STATIC);
-
+                                 "Test cache variable 5", CM_CACHE_STATIC);
 
   file = info->CAPI->ExpandVariablesInString(mf, "${CMAKE_COMMAND}", 0, 0);
 
@@ -83,20 +75,17 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf));
   info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf));
   sprintf(buffer, "Cache version: %d.%d, CMake version: %d.%d",
-    info->CAPI->GetCacheMajorVersion(mf),
-    info->CAPI->GetCacheMinorVersion(mf),
-    info->CAPI->GetMajorVersion(mf),
-    info->CAPI->GetMinorVersion(mf));
+          info->CAPI->GetCacheMajorVersion(mf),
+          info->CAPI->GetCacheMinorVersion(mf),
+          info->CAPI->GetMajorVersion(mf), info->CAPI->GetMinorVersion(mf));
   info->CAPI->DisplaySatus(mf, buffer);
-  if ( info->CAPI->CommandExists(mf, "SET") )
-    {
+  if (info->CAPI->CommandExists(mf, "SET")) {
     info->CAPI->DisplaySatus(mf, "Command SET exists");
-    }
-  if ( info->CAPI->CommandExists(mf, "SET_FOO_BAR") )
-    {
+  }
+  if (info->CAPI->CommandExists(mf, "SET_FOO_BAR")) {
     info->CAPI->SetError(mf, "Command SET_FOO_BAR should not exists");
     return 0;
-    }
+  }
   info->CAPI->AddDefineFlag(mf, "-DADDED_DEFINITION");
 
   source_file = info->CAPI->CreateNewSourceFile(mf);
@@ -106,17 +95,14 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   cstr = info->CAPI->SourceFileGetFullPath(source_file);
   sprintf(buffer, "Should be empty (source file full path): [%s]", cstr);
   info->CAPI->DisplaySatus(mf, buffer);
-  info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY","unused old prop",
-                                       "This property is no longer used",
-                                       0);
-  if ( info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY") )
-    {
+  info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY", "unused old prop",
+                                       "This property is no longer used", 0);
+  if (info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY")) {
     info->CAPI->SetError(mf, "Property SOME_PROPERTY should not be defined");
     return 0;
-    }
-  info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY2","nice prop",
-                                       "This property is for testing.",
-                                       0);
+  }
+  info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY2", "nice prop",
+                                       "This property is for testing.", 0);
   info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE");
   cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT");
   sprintf(buffer, "Should be 0 (source file abstract property): [%p]", cstr);
@@ -124,8 +110,8 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
 
   info->CAPI->DestroySourceFile(source_file);
 
-  srcs =  argv[2];
-  info->CAPI->AddExecutable(mf,"LoadedCommand",1, &srcs, 0);
+  srcs = argv[2];
+  info->CAPI->AddExecutable(mf, "LoadedCommand", 1, &srcs, 0);
 
   /* add customs commands to generate the source file */
   ccArgs[0] = "-E";
@@ -134,30 +120,19 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   ccArgs[3] = argv[1];
   ccDep[0] = ccArgs[2];
   ccOut[0] = ccArgs[3];
-  info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in",
-                               file,
-                               4, ccArgs,
-                               1, ccDep,
-                               1, ccOut,
-                               "LoadedCommand");
-
+  info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in", file, 4, ccArgs, 1,
+                               ccDep, 1, ccOut, "LoadedCommand");
 
   ccArgs[2] = argv[1];
   ccArgs[3] = argv[2];
   ccDep[0] = ccArgs[2];
   ccOut[0] = ccArgs[3];
-  info->CAPI->AddCustomCommandToOutput(mf, ccOut[0],
-                                       file,
-                                       4, ccArgs,
-                                       ccDep[0],
+  info->CAPI->AddCustomCommandToOutput(mf, ccOut[0], file, 4, ccArgs, ccDep[0],
                                        0, 0);
 
-
   ccArgs[1] = "echo";
   ccArgs[2] = "Build has finished";
-  info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand",
-                                       file,
-                                       3, ccArgs,
+  info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand", file, 3, ccArgs,
                                        CM_POST_BUILD);
 
   info->CAPI->Free(file);
@@ -166,45 +141,40 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   args[1] = "TRUE";
 
   /* code coverage */
-  if (info->CAPI->GetTotalArgumentSize(2,args) != 13)
-    {
+  if (info->CAPI->GetTotalArgumentSize(2, args) != 13) {
     return 0;
-    }
-  info->CAPI->ExecuteCommand(mf,"SET",2,args);
+  }
+  info->CAPI->ExecuteCommand(mf, "SET", 2, args);
 
   /* make sure we can find the source file */
-  if (!info->CAPI->GetSource(mf,argv[1]))
-    {
+  if (!info->CAPI->GetSource(mf, argv[1])) {
     info->CAPI->SetError(mf, "Source file could not be found!");
     return 0;
-    }
+  }
 
   return 1;
 }
 
-static void  CCONV FinalPass(void *inf, void *mf)
+static void CCONV FinalPass(void* inf, void* mf)
 {
-  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+  cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
   /* get our client data from initial pass */
-  cmVTKWrapTclData *cdata =
-    (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
-  if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") ||
-      strcmp(cdata->LibraryName,"HOO"))
-    {
-    fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n");
-    }
+  cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
+  if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"), "HOO") ||
+      strcmp(cdata->LibraryName, "HOO")) {
+    fprintf(stderr, "*** Failed LOADED COMMAND Final Pass\n");
+  }
 }
-static void CCONV Destructor(void *inf)
+static void CCONV Destructor(void* inf)
 {
-  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+  cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
   /* get our client data from initial pass */
-  cmVTKWrapTclData *cdata =
-    (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
+  cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
   free(cdata);
 }
 
 #ifdef MUCHO_MUDSLIDE
-void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info)
+void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo* info)
 {
   info->InitialPass = InitialPass;
   info->FinalPass = FinalPass;
@@ -213,7 +183,3 @@ void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info)
   info->Name = "CMAKE_TEST_COMMAND";
 }
 #endif
-
-
-
-
diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
index fc04934..3558f89 100644
--- a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
+++ b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
@@ -1,67 +1,59 @@
 #include "cmCPluginAPI.h"
-#include <string.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 typedef struct
 {
-  char *LibraryName;
+  char* LibraryName;
   int Argc;
   char** Argv;
 } cmVTKWrapTclData;
 
 /* do almost everything in the initial pass */
-static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
+static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
 {
   char* file;
   char* str;
-  char *srcs;
+  char* srcs;
   const char* cstr;
   char buffer[1024];
-  void *source_file;
-  char *args[2];
-  char *ccArgs[4];
-  char *ccDep[1];
-  char *ccOut[1];
-  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
-
-  cmVTKWrapTclData *cdata =
-    (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData));
+  void* source_file;
+  char* args[2];
+  char* ccArgs[4];
+  char* ccDep[1];
+  char* ccOut[1];
+  cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
+
+  cmVTKWrapTclData* cdata =
+    (cmVTKWrapTclData*)malloc(sizeof(cmVTKWrapTclData));
   cdata->LibraryName = "BOO";
   cdata->Argc = argc;
   cdata->Argv = argv;
-  info->CAPI->SetClientData(info,cdata);
+  info->CAPI->SetClientData(info, cdata);
 
   /* Now check and see if the value has been stored in the cache */
   /* already, if so use that value and don't look for the program */
-  if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1"))
-    {
+  if (!info->CAPI->IsOn(mf, "TEST_COMMAND_TEST1")) {
     info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
     return 1;
-    }
+  }
 
   info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
   cdata->LibraryName = "HOO";
 
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE", "ON",
-    "Test cache variable",
-    CM_CACHE_BOOL);
+                                 "Test cache variable", CM_CACHE_BOOL);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE1", "",
-    "Test cache variable 1",
-    CM_CACHE_PATH);
+                                 "Test cache variable 1", CM_CACHE_PATH);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE2", "",
-    "Test cache variable 2",
-    CM_CACHE_FILEPATH);
+                                 "Test cache variable 2", CM_CACHE_FILEPATH);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE3", "",
-    "Test cache variable 3",
-    CM_CACHE_STRING);
+                                 "Test cache variable 3", CM_CACHE_STRING);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE4", "",
-    "Test cache variable 4",
-    CM_CACHE_INTERNAL);
+                                 "Test cache variable 4", CM_CACHE_INTERNAL);
   info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE5", "",
-    "Test cache variable 5",
-    CM_CACHE_STATIC);
-
+                                 "Test cache variable 5", CM_CACHE_STATIC);
 
   file = info->CAPI->ExpandVariablesInString(mf, "${CMAKE_COMMAND}", 0, 0);
 
@@ -83,20 +75,17 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf));
   info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf));
   sprintf(buffer, "Cache version: %d.%d, CMake version: %d.%d",
-    info->CAPI->GetCacheMajorVersion(mf),
-    info->CAPI->GetCacheMinorVersion(mf),
-    info->CAPI->GetMajorVersion(mf),
-    info->CAPI->GetMinorVersion(mf));
+          info->CAPI->GetCacheMajorVersion(mf),
+          info->CAPI->GetCacheMinorVersion(mf),
+          info->CAPI->GetMajorVersion(mf), info->CAPI->GetMinorVersion(mf));
   info->CAPI->DisplaySatus(mf, buffer);
-  if ( info->CAPI->CommandExists(mf, "SET") )
-    {
+  if (info->CAPI->CommandExists(mf, "SET")) {
     info->CAPI->DisplaySatus(mf, "Command SET exists");
-    }
-  if ( info->CAPI->CommandExists(mf, "SET_FOO_BAR") )
-    {
+  }
+  if (info->CAPI->CommandExists(mf, "SET_FOO_BAR")) {
     info->CAPI->SetError(mf, "Command SET_FOO_BAR should not exists");
     return 0;
-    }
+  }
   info->CAPI->AddDefineFlag(mf, "-DADDED_DEFINITION");
 
   source_file = info->CAPI->CreateNewSourceFile(mf);
@@ -106,17 +95,14 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   cstr = info->CAPI->SourceFileGetFullPath(source_file);
   sprintf(buffer, "Should be empty (source file full path): [%s]", cstr);
   info->CAPI->DisplaySatus(mf, buffer);
-  info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY","unused old prop",
-                                       "This property is no longer used",
-                                       0);
-  if ( info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY") )
-    {
+  info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY", "unused old prop",
+                                       "This property is no longer used", 0);
+  if (info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY")) {
     info->CAPI->SetError(mf, "Property SOME_PROPERTY should not be defined");
     return 0;
-    }
-  info->CAPI->DefineSourceFileProperty(mf,"SOME_PROPERTY2","nice prop",
-                                       "This property is for testing.",
-                                       0);
+  }
+  info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY2", "nice prop",
+                                       "This property is for testing.", 0);
   info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE");
   cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT");
   sprintf(buffer, "Should be 0 (source file abstract property): [%p]", cstr);
@@ -124,8 +110,8 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
 
   info->CAPI->DestroySourceFile(source_file);
 
-  srcs =  argv[2];
-  info->CAPI->AddExecutable(mf,"LoadedCommand",1, &srcs, 0);
+  srcs = argv[2];
+  info->CAPI->AddExecutable(mf, "LoadedCommand", 1, &srcs, 0);
 
   /* add customs commands to generate the source file */
   ccArgs[0] = "-E";
@@ -134,30 +120,19 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   ccArgs[3] = argv[1];
   ccDep[0] = ccArgs[2];
   ccOut[0] = ccArgs[3];
-  info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in",
-                               file,
-                               4, ccArgs,
-                               1, ccDep,
-                               1, ccOut,
-                               "LoadedCommand");
-
+  info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in", file, 4, ccArgs, 1,
+                               ccDep, 1, ccOut, "LoadedCommand");
 
   ccArgs[2] = argv[1];
   ccArgs[3] = argv[2];
   ccDep[0] = ccArgs[2];
   ccOut[0] = ccArgs[3];
-  info->CAPI->AddCustomCommandToOutput(mf, ccOut[0],
-                                       file,
-                                       4, ccArgs,
-                                       ccDep[0],
+  info->CAPI->AddCustomCommandToOutput(mf, ccOut[0], file, 4, ccArgs, ccDep[0],
                                        0, 0);
 
-
   ccArgs[1] = "echo";
   ccArgs[2] = "Build has finished";
-  info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand",
-                                       file,
-                                       3, ccArgs,
+  info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand", file, 3, ccArgs,
                                        CM_POST_BUILD);
 
   info->CAPI->Free(file);
@@ -166,45 +141,40 @@ static int CCONV InitialPass(void *inf, void *mf, int argc, char *argv[])
   args[1] = "TRUE";
 
   /* code coverage */
-  if (info->CAPI->GetTotalArgumentSize(2,args) != 13)
-    {
+  if (info->CAPI->GetTotalArgumentSize(2, args) != 13) {
     return 0;
-    }
-  info->CAPI->ExecuteCommand(mf,"SET",2,args);
+  }
+  info->CAPI->ExecuteCommand(mf, "SET", 2, args);
 
   /* make sure we can find the source file */
-  if (!info->CAPI->GetSource(mf,argv[1]))
-    {
+  if (!info->CAPI->GetSource(mf, argv[1])) {
     info->CAPI->SetError(mf, "Source file could not be found!");
     return 0;
-    }
+  }
 
   return 1;
 }
 
-static void  CCONV FinalPass(void *inf, void *mf)
+static void CCONV FinalPass(void* inf, void* mf)
 {
-  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+  cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
   /* get our client data from initial pass */
-  cmVTKWrapTclData *cdata =
-    (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
-  if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") ||
-      strcmp(cdata->LibraryName,"HOO"))
-    {
-    fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n");
-    }
+  cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
+  if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"), "HOO") ||
+      strcmp(cdata->LibraryName, "HOO")) {
+    fprintf(stderr, "*** Failed LOADED COMMAND Final Pass\n");
+  }
 }
-static void CCONV Destructor(void *inf)
+static void CCONV Destructor(void* inf)
 {
-  cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+  cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
   /* get our client data from initial pass */
-  cmVTKWrapTclData *cdata =
-    (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
+  cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
   free(cdata);
 }
 
 #ifdef MUCHO_MUDSLIDE
-void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info)
+void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo* info)
 {
   info->InitialPass = InitialPass;
   info->FinalPass = FinalPass;
@@ -213,7 +183,3 @@ void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo *info)
   info->Name = "CMAKE_TEST_COMMAND";
 }
 #endif
-
-
-
-
diff --git a/Tests/MFC/mfc1/ChildFrm.cpp b/Tests/MFC/mfc1/ChildFrm.cpp
index b04c4f2..ddb19c6 100644
--- a/Tests/MFC/mfc1/ChildFrm.cpp
+++ b/Tests/MFC/mfc1/ChildFrm.cpp
@@ -1,6 +1,8 @@
 // ChildFrm.cpp : implementation of the CChildFrame class
 //
+
 #include "stdafx.h"
+
 #include "mfc1.h"
 
 #include "ChildFrm.h"
@@ -9,7 +11,6 @@
 #define new DEBUG_NEW
 #endif
 
-
 // CChildFrame
 
 IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
@@ -17,43 +18,40 @@ IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
 BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
 END_MESSAGE_MAP()
 
-
 // CChildFrame construction/destruction
 
 CChildFrame::CChildFrame()
 {
-	// TODO: add member initialization code here
+  // TODO: add member initialization code here
 }
 
 CChildFrame::~CChildFrame()
 {
 }
 
-
 BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
 {
-	// TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
-	if( !CMDIChildWnd::PreCreateWindow(cs) )
-		return FALSE;
+  // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT
+  // cs
+  if (!CMDIChildWnd::PreCreateWindow(cs))
+    return FALSE;
 
-	return TRUE;
+  return TRUE;
 }
 
-
 // CChildFrame diagnostics
 
 #ifdef _DEBUG
 void CChildFrame::AssertValid() const
 {
-	CMDIChildWnd::AssertValid();
+  CMDIChildWnd::AssertValid();
 }
 
 void CChildFrame::Dump(CDumpContext& dc) const
 {
-	CMDIChildWnd::Dump(dc);
+  CMDIChildWnd::Dump(dc);
 }
 
 #endif //_DEBUG
 
-
 // CChildFrame message handlers
diff --git a/Tests/MFC/mfc1/ChildFrm.h b/Tests/MFC/mfc1/ChildFrm.h
index 34b80f1..eedf4d1 100644
--- a/Tests/MFC/mfc1/ChildFrm.h
+++ b/Tests/MFC/mfc1/ChildFrm.h
@@ -1,34 +1,30 @@
 // ChildFrm.h : interface of the CChildFrame class
 //
 
-
 #pragma once
 
-
 class CChildFrame : public CMDIChildWnd
 {
-	DECLARE_DYNCREATE(CChildFrame)
+  DECLARE_DYNCREATE(CChildFrame)
 public:
-	CChildFrame();
+  CChildFrame();
 
-// Attributes
+  // Attributes
 public:
-
-// Operations
+  // Operations
 public:
+  // Overrides
+  virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 
-// Overrides
-	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
-
-// Implementation
+  // Implementation
 public:
-	virtual ~CChildFrame();
+  virtual ~CChildFrame();
 #ifdef _DEBUG
-	virtual void AssertValid() const;
-	virtual void Dump(CDumpContext& dc) const;
+  virtual void AssertValid() const;
+  virtual void Dump(CDumpContext& dc) const;
 #endif
 
-// Generated message map functions
+  // Generated message map functions
 protected:
-	DECLARE_MESSAGE_MAP()
+  DECLARE_MESSAGE_MAP()
 };
diff --git a/Tests/MFC/mfc1/MainFrm.cpp b/Tests/MFC/mfc1/MainFrm.cpp
index 44554bf..c551065 100644
--- a/Tests/MFC/mfc1/MainFrm.cpp
+++ b/Tests/MFC/mfc1/MainFrm.cpp
@@ -2,6 +2,7 @@
 //
 
 #include "stdafx.h"
+
 #include "mfc1.h"
 
 #include "MainFrm.h"
@@ -10,89 +11,81 @@
 #define new DEBUG_NEW
 #endif
 
-
 // CMainFrame
 
 IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
 
 BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
-	ON_WM_CREATE()
+ON_WM_CREATE()
 END_MESSAGE_MAP()
 
-static UINT indicators[] =
-{
-	ID_SEPARATOR,           // status line indicator
-	ID_INDICATOR_CAPS,
-	ID_INDICATOR_NUM,
-	ID_INDICATOR_SCRL,
+static UINT indicators[] = {
+  ID_SEPARATOR, // status line indicator
+  ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL,
 };
 
-
 // CMainFrame construction/destruction
 
 CMainFrame::CMainFrame()
 {
-	// TODO: add member initialization code here
+  // TODO: add member initialization code here
 }
 
 CMainFrame::~CMainFrame()
 {
 }
 
-
 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
 {
-	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
-		return -1;
-
-	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
-		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
-		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
-	{
-		TRACE0("Failed to create toolbar\n");
-		return -1;      // fail to create
-	}
-
-	if (!m_wndStatusBar.Create(this) ||
-		!m_wndStatusBar.SetIndicators(indicators,
-		  sizeof(indicators)/sizeof(UINT)))
-	{
-		TRACE0("Failed to create status bar\n");
-		return -1;      // fail to create
-	}
-	// TODO: Delete these three lines if you don't want the toolbar to be dockable
-	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
-	EnableDocking(CBRS_ALIGN_ANY);
-	DockControlBar(&m_wndToolBar);
-
-	return 0;
+  if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
+    return -1;
+
+  if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |
+                               CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |
+                               CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
+      !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
+    TRACE0("Failed to create toolbar\n");
+    return -1; // fail to create
+  }
+
+  if (!m_wndStatusBar.Create(this) ||
+      !m_wndStatusBar.SetIndicators(indicators,
+                                    sizeof(indicators) / sizeof(UINT))) {
+    TRACE0("Failed to create status bar\n");
+    return -1; // fail to create
+  }
+  // TODO: Delete these three lines if you don't want the toolbar to be
+  // dockable
+  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
+  EnableDocking(CBRS_ALIGN_ANY);
+  DockControlBar(&m_wndToolBar);
+
+  return 0;
 }
 
 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
 {
-	if( !CMDIFrameWnd::PreCreateWindow(cs) )
-		return FALSE;
-	// TODO: Modify the Window class or styles here by modifying
-	//  the CREATESTRUCT cs
+  if (!CMDIFrameWnd::PreCreateWindow(cs))
+    return FALSE;
+  // TODO: Modify the Window class or styles here by modifying
+  //  the CREATESTRUCT cs
 
-	return TRUE;
+  return TRUE;
 }
 
-
 // CMainFrame diagnostics
 
 #ifdef _DEBUG
 void CMainFrame::AssertValid() const
 {
-	CMDIFrameWnd::AssertValid();
+  CMDIFrameWnd::AssertValid();
 }
 
 void CMainFrame::Dump(CDumpContext& dc) const
 {
-	CMDIFrameWnd::Dump(dc);
+  CMDIFrameWnd::Dump(dc);
 }
 
 #endif //_DEBUG
 
-
 // CMainFrame message handlers
diff --git a/Tests/MFC/mfc1/MainFrm.h b/Tests/MFC/mfc1/MainFrm.h
index 1039ac5..3b965c9 100644
--- a/Tests/MFC/mfc1/MainFrm.h
+++ b/Tests/MFC/mfc1/MainFrm.h
@@ -1,38 +1,35 @@
 // MainFrm.h : interface of the CMainFrame class
 //
 
-
 #pragma once
 class CMainFrame : public CMDIFrameWnd
 {
-	DECLARE_DYNAMIC(CMainFrame)
+  DECLARE_DYNAMIC(CMainFrame)
 public:
-	CMainFrame();
+  CMainFrame();
 
-// Attributes
+  // Attributes
 public:
-
-// Operations
+  // Operations
 public:
-
-// Overrides
+  // Overrides
 public:
-	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+  virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 
-// Implementation
+  // Implementation
 public:
-	virtual ~CMainFrame();
+  virtual ~CMainFrame();
 #ifdef _DEBUG
-	virtual void AssertValid() const;
-	virtual void Dump(CDumpContext& dc) const;
+  virtual void AssertValid() const;
+  virtual void Dump(CDumpContext& dc) const;
 #endif
 
-protected:  // control bar embedded members
-	CStatusBar  m_wndStatusBar;
-	CToolBar    m_wndToolBar;
+protected: // control bar embedded members
+  CStatusBar m_wndStatusBar;
+  CToolBar m_wndToolBar;
 
-// Generated message map functions
+  // Generated message map functions
 protected:
-	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
-	DECLARE_MESSAGE_MAP()
+  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+  DECLARE_MESSAGE_MAP()
 };
diff --git a/Tests/MFC/mfc1/Resource.h b/Tests/MFC/mfc1/Resource.h
index 0a9c13f..7184e30 100644
--- a/Tests/MFC/mfc1/Resource.h
+++ b/Tests/MFC/mfc1/Resource.h
@@ -2,19 +2,19 @@
 // Microsoft Visual C++ generated include file.
 // Used by mfc1.rc
 //
-#define IDD_ABOUTBOX				100
-#define IDP_OLE_INIT_FAILED			100
-#define IDR_MAINFRAME				128
-#define IDR_mfc1TYPE				129
-#define IDR_MANIFEST				CREATEPROCESS_MANIFEST_RESOURCE_ID
+#define IDD_ABOUTBOX 100
+#define IDP_OLE_INIT_FAILED 100
+#define IDR_MAINFRAME 128
+#define IDR_mfc1TYPE 129
+#define IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID
 
 // Next default values for new objects
 //
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE	130
-#define _APS_NEXT_CONTROL_VALUE		1000
-#define _APS_NEXT_SYMED_VALUE		101
-#define _APS_NEXT_COMMAND_VALUE		32771
+#define _APS_NEXT_RESOURCE_VALUE 130
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 32771
 #endif
 #endif
diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp
index 9530cd2..664c6c4 100644
--- a/Tests/MFC/mfc1/mfc1.cpp
+++ b/Tests/MFC/mfc1/mfc1.cpp
@@ -2,8 +2,9 @@
 //
 
 #include "stdafx.h"
-#include "mfc1.h"
+
 #include "MainFrm.h"
+#include "mfc1.h"
 
 #include "ChildFrm.h"
 #include "mfc1Doc.h"
@@ -13,28 +14,25 @@
 #define new DEBUG_NEW
 #endif
 
-
 // Cmfc1App
 
 BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp)
-	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
-	// Standard file based document commands
-	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
-	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
-	// Standard print setup command
-	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
+ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
+// Standard file based document commands
+ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
+ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
+// Standard print setup command
+ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
 END_MESSAGE_MAP()
 
-
 // Cmfc1App construction
 
 Cmfc1App::Cmfc1App()
 {
-	// TODO: add construction code here,
-	// Place all significant initialization in InitInstance
+  // TODO: add construction code here,
+  // Place all significant initialization in InitInstance
 }
 
-
 // The one and only Cmfc1App object
 
 Cmfc1App theApp;
@@ -43,91 +41,92 @@ Cmfc1App theApp;
 
 BOOL Cmfc1App::InitInstance()
 {
-	// InitCommonControls() is required on Windows XP if an application
-	// manifest specifies use of ComCtl32.dll version 6 or later to enable
-	// visual styles.  Otherwise, any window creation will fail.
-	InitCommonControls();
-
-	CWinApp::InitInstance();
-
-	// Initialize OLE libraries
-	if (!AfxOleInit())
-	{
-		AfxMessageBox(IDP_OLE_INIT_FAILED);
-		return FALSE;
-	}
-	AfxEnableControlContainer();
-	// Standard initialization
-	// If you are not using these features and wish to reduce the size
-	// of your final executable, you should remove from the following
-	// the specific initialization routines you do not need
-	// Change the registry key under which our settings are stored
-	// TODO: You should modify this string to be something appropriate
-	// such as the name of your company or organization
-	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
-	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
-	// Register the application's document templates.  Document templates
-	//  serve as the connection between documents, frame windows and views
-	CMultiDocTemplate* pDocTemplate;
-	pDocTemplate = new CMultiDocTemplate(IDR_mfc1TYPE,
-		RUNTIME_CLASS(Cmfc1Doc),
-		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
-		RUNTIME_CLASS(Cmfc1View));
-	if (!pDocTemplate)
-		return FALSE;
-	AddDocTemplate(pDocTemplate);
-	// create main MDI Frame window
-	CMainFrame* pMainFrame = new CMainFrame;
-	if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
-		return FALSE;
-	m_pMainWnd = pMainFrame;
-	// call DragAcceptFiles only if there's a suffix
-	//  In an MDI app, this should occur immediately after setting m_pMainWnd
-	// Enable drag/drop open
-	m_pMainWnd->DragAcceptFiles();
-	// Enable DDE Execute open
-	EnableShellOpen();
-	RegisterShellFileTypes(TRUE);
-	// Parse command line for standard shell commands, DDE, file open
-	CCommandLineInfo cmdInfo;
-	ParseCommandLine(cmdInfo);
-	// Dispatch commands specified on the command line.  Will return FALSE if
-	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
-	if (!ProcessShellCommand(cmdInfo))
-		return FALSE;
-	// The main window has been initialized, so show and update it
-	pMainFrame->ShowWindow(m_nCmdShow);
-	pMainFrame->UpdateWindow();
-	return TRUE;
+  // InitCommonControls() is required on Windows XP if an application
+  // manifest specifies use of ComCtl32.dll version 6 or later to enable
+  // visual styles.  Otherwise, any window creation will fail.
+  InitCommonControls();
+
+  CWinApp::InitInstance();
+
+  // Initialize OLE libraries
+  if (!AfxOleInit()) {
+    AfxMessageBox(IDP_OLE_INIT_FAILED);
+    return FALSE;
+  }
+  AfxEnableControlContainer();
+  // Standard initialization
+  // If you are not using these features and wish to reduce the size
+  // of your final executable, you should remove from the following
+  // the specific initialization routines you do not need
+  // Change the registry key under which our settings are stored
+  // TODO: You should modify this string to be something appropriate
+  // such as the name of your company or organization
+  SetRegistryKey(_T("Local AppWizard-Generated Applications"));
+  LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
+  // Register the application's document templates.  Document templates
+  //  serve as the connection between documents, frame windows and views
+  CMultiDocTemplate* pDocTemplate;
+  pDocTemplate =
+    new CMultiDocTemplate(IDR_mfc1TYPE, RUNTIME_CLASS(Cmfc1Doc),
+                          RUNTIME_CLASS(CChildFrame), // custom MDI child frame
+                          RUNTIME_CLASS(Cmfc1View));
+  if (!pDocTemplate)
+    return FALSE;
+  AddDocTemplate(pDocTemplate);
+  // create main MDI Frame window
+  CMainFrame* pMainFrame = new CMainFrame;
+  if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
+    return FALSE;
+  m_pMainWnd = pMainFrame;
+  // call DragAcceptFiles only if there's a suffix
+  //  In an MDI app, this should occur immediately after setting m_pMainWnd
+  // Enable drag/drop open
+  m_pMainWnd->DragAcceptFiles();
+  // Enable DDE Execute open
+  EnableShellOpen();
+  RegisterShellFileTypes(TRUE);
+  // Parse command line for standard shell commands, DDE, file open
+  CCommandLineInfo cmdInfo;
+  ParseCommandLine(cmdInfo);
+  // Dispatch commands specified on the command line.  Will return FALSE if
+  // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
+  if (!ProcessShellCommand(cmdInfo))
+    return FALSE;
+  // The main window has been initialized, so show and update it
+  pMainFrame->ShowWindow(m_nCmdShow);
+  pMainFrame->UpdateWindow();
+  return TRUE;
 }
 
-
-
 // CAboutDlg dialog used for App About
 
 class CAboutDlg : public CDialog
 {
 public:
-	CAboutDlg();
+  CAboutDlg();
 
-// Dialog Data
-	enum { IDD = IDD_ABOUTBOX };
+  // Dialog Data
+  enum
+  {
+    IDD = IDD_ABOUTBOX
+  };
 
 protected:
-	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+  virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
 
-// Implementation
+  // Implementation
 protected:
-	DECLARE_MESSAGE_MAP()
+  DECLARE_MESSAGE_MAP()
 };
 
-CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+CAboutDlg::CAboutDlg()
+  : CDialog(CAboutDlg::IDD)
 {
 }
 
 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
 {
-	CDialog::DoDataExchange(pDX);
+  CDialog::DoDataExchange(pDX);
 }
 
 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
@@ -136,9 +135,8 @@ END_MESSAGE_MAP()
 // App command to run the dialog
 void Cmfc1App::OnAppAbout()
 {
-	CAboutDlg aboutDlg;
-	aboutDlg.DoModal();
+  CAboutDlg aboutDlg;
+  aboutDlg.DoModal();
 }
 
-
 // Cmfc1App message handlers
diff --git a/Tests/MFC/mfc1/mfc1.h b/Tests/MFC/mfc1/mfc1.h
index c273601..15e970b 100644
--- a/Tests/MFC/mfc1/mfc1.h
+++ b/Tests/MFC/mfc1/mfc1.h
@@ -3,11 +3,10 @@
 #pragma once
 
 #ifndef __AFXWIN_H__
-	#error include 'stdafx.h' before including this file for PCH
+#error include 'stdafx.h' before including this file for PCH
 #endif
 
-#include "resource.h"       // main symbols
-
+#include "resource.h" // main symbols
 
 // Cmfc1App:
 // See mfc1.cpp for the implementation of this class
@@ -16,16 +15,15 @@
 class Cmfc1App : public CWinApp
 {
 public:
-	Cmfc1App();
-
+  Cmfc1App();
 
-// Overrides
+  // Overrides
 public:
-	virtual BOOL InitInstance();
+  virtual BOOL InitInstance();
 
-// Implementation
-	afx_msg void OnAppAbout();
-	DECLARE_MESSAGE_MAP()
+  // Implementation
+  afx_msg void OnAppAbout();
+  DECLARE_MESSAGE_MAP()
 };
 
 extern Cmfc1App theApp;
diff --git a/Tests/MFC/mfc1/mfc1Doc.cpp b/Tests/MFC/mfc1/mfc1Doc.cpp
index 8767052..08ab158 100644
--- a/Tests/MFC/mfc1/mfc1Doc.cpp
+++ b/Tests/MFC/mfc1/mfc1Doc.cpp
@@ -2,6 +2,7 @@
 //
 
 #include "stdafx.h"
+
 #include "mfc1.h"
 
 #include "mfc1Doc.h"
@@ -10,7 +11,6 @@
 #define new DEBUG_NEW
 #endif
 
-
 // Cmfc1Doc
 
 IMPLEMENT_DYNCREATE(Cmfc1Doc, CDocument)
@@ -18,13 +18,11 @@ IMPLEMENT_DYNCREATE(Cmfc1Doc, CDocument)
 BEGIN_MESSAGE_MAP(Cmfc1Doc, CDocument)
 END_MESSAGE_MAP()
 
-
 // Cmfc1Doc construction/destruction
 
 Cmfc1Doc::Cmfc1Doc()
 {
-	// TODO: add one-time construction code here
-
+  // TODO: add one-time construction code here
 }
 
 Cmfc1Doc::~Cmfc1Doc()
@@ -33,46 +31,38 @@ Cmfc1Doc::~Cmfc1Doc()
 
 BOOL Cmfc1Doc::OnNewDocument()
 {
-	if (!CDocument::OnNewDocument())
-		return FALSE;
+  if (!CDocument::OnNewDocument())
+    return FALSE;
 
-	// TODO: add reinitialization code here
-	// (SDI documents will reuse this document)
+  // TODO: add reinitialization code here
+  // (SDI documents will reuse this document)
 
-	return TRUE;
+  return TRUE;
 }
 
-
-
-
 // Cmfc1Doc serialization
 
 void Cmfc1Doc::Serialize(CArchive& ar)
 {
-	if (ar.IsStoring())
-	{
-		// TODO: add storing code here
-	}
-	else
-	{
-		// TODO: add loading code here
-	}
+  if (ar.IsStoring()) {
+    // TODO: add storing code here
+  } else {
+    // TODO: add loading code here
+  }
 }
 
-
 // Cmfc1Doc diagnostics
 
 #ifdef _DEBUG
 void Cmfc1Doc::AssertValid() const
 {
-	CDocument::AssertValid();
+  CDocument::AssertValid();
 }
 
 void Cmfc1Doc::Dump(CDumpContext& dc) const
 {
-	CDocument::Dump(dc);
+  CDocument::Dump(dc);
 }
 #endif //_DEBUG
 
-
 // Cmfc1Doc commands
diff --git a/Tests/MFC/mfc1/mfc1Doc.h b/Tests/MFC/mfc1/mfc1Doc.h
index 92d8e35..fb43cba 100644
--- a/Tests/MFC/mfc1/mfc1Doc.h
+++ b/Tests/MFC/mfc1/mfc1Doc.h
@@ -1,37 +1,33 @@
 // mfc1Doc.h : interface of the Cmfc1Doc class
 //
 
-
 #pragma once
 
 class Cmfc1Doc : public CDocument
 {
 protected: // create from serialization only
-	Cmfc1Doc();
-	DECLARE_DYNCREATE(Cmfc1Doc)
+  Cmfc1Doc();
+  DECLARE_DYNCREATE(Cmfc1Doc)
 
-// Attributes
+  // Attributes
 public:
-
-// Operations
+  // Operations
 public:
+  // Overrides
+public:
+  virtual BOOL OnNewDocument();
+  virtual void Serialize(CArchive& ar);
 
-// Overrides
-	public:
-	virtual BOOL OnNewDocument();
-	virtual void Serialize(CArchive& ar);
-
-// Implementation
+  // Implementation
 public:
-	virtual ~Cmfc1Doc();
+  virtual ~Cmfc1Doc();
 #ifdef _DEBUG
-	virtual void AssertValid() const;
-	virtual void Dump(CDumpContext& dc) const;
+  virtual void AssertValid() const;
+  virtual void Dump(CDumpContext& dc) const;
 #endif
 
 protected:
-
-// Generated message map functions
+  // Generated message map functions
 protected:
-	DECLARE_MESSAGE_MAP()
+  DECLARE_MESSAGE_MAP()
 };
diff --git a/Tests/MFC/mfc1/mfc1View.cpp b/Tests/MFC/mfc1/mfc1View.cpp
index 06c7652..6169ce5 100644
--- a/Tests/MFC/mfc1/mfc1View.cpp
+++ b/Tests/MFC/mfc1/mfc1View.cpp
@@ -2,6 +2,7 @@
 //
 
 #include "stdafx.h"
+
 #include "mfc1.h"
 
 #include "mfc1Doc.h"
@@ -11,24 +12,22 @@
 #define new DEBUG_NEW
 #endif
 
-
 // Cmfc1View
 
 IMPLEMENT_DYNCREATE(Cmfc1View, CView)
 
 BEGIN_MESSAGE_MAP(Cmfc1View, CView)
-	// Standard printing commands
-	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
-	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
-	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
+// Standard printing commands
+ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
+ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
+ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
 END_MESSAGE_MAP()
 
 // Cmfc1View construction/destruction
 
 Cmfc1View::Cmfc1View()
 {
-	// TODO: add construction code here
-
+  // TODO: add construction code here
 }
 
 Cmfc1View::~Cmfc1View()
@@ -37,63 +36,60 @@ Cmfc1View::~Cmfc1View()
 
 BOOL Cmfc1View::PreCreateWindow(CREATESTRUCT& cs)
 {
-	// TODO: Modify the Window class or styles here by modifying
-	//  the CREATESTRUCT cs
+  // TODO: Modify the Window class or styles here by modifying
+  //  the CREATESTRUCT cs
 
-	return CView::PreCreateWindow(cs);
+  return CView::PreCreateWindow(cs);
 }
 
 // Cmfc1View drawing
 
 void Cmfc1View::OnDraw(CDC* /*pDC*/)
 {
-	Cmfc1Doc* pDoc = GetDocument();
-	ASSERT_VALID(pDoc);
-	if (!pDoc)
-		return;
+  Cmfc1Doc* pDoc = GetDocument();
+  ASSERT_VALID(pDoc);
+  if (!pDoc)
+    return;
 
-	// TODO: add draw code for native data here
+  // TODO: add draw code for native data here
 }
 
-
 // Cmfc1View printing
 
 BOOL Cmfc1View::OnPreparePrinting(CPrintInfo* pInfo)
 {
-	// default preparation
-	return DoPreparePrinting(pInfo);
+  // default preparation
+  return DoPreparePrinting(pInfo);
 }
 
 void Cmfc1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
 {
-	// TODO: add extra initialization before printing
+  // TODO: add extra initialization before printing
 }
 
 void Cmfc1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
 {
-	// TODO: add cleanup after printing
+  // TODO: add cleanup after printing
 }
 
-
 // Cmfc1View diagnostics
 
 #ifdef _DEBUG
 void Cmfc1View::AssertValid() const
 {
-	CView::AssertValid();
+  CView::AssertValid();
 }
 
 void Cmfc1View::Dump(CDumpContext& dc) const
 {
-	CView::Dump(dc);
+  CView::Dump(dc);
 }
 
 Cmfc1Doc* Cmfc1View::GetDocument() const // non-debug version is inline
 {
-	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cmfc1Doc)));
-	return (Cmfc1Doc*)m_pDocument;
+  ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cmfc1Doc)));
+  return (Cmfc1Doc*)m_pDocument;
 }
 #endif //_DEBUG
 
-
 // Cmfc1View message handlers
diff --git a/Tests/MFC/mfc1/mfc1View.h b/Tests/MFC/mfc1/mfc1View.h
index 4244653..8c827bb 100644
--- a/Tests/MFC/mfc1/mfc1View.h
+++ b/Tests/MFC/mfc1/mfc1View.h
@@ -1,48 +1,47 @@
 // mfc1View.h : interface of the Cmfc1View class
 //
 
-
 #pragma once
 
-
 class Cmfc1View : public CView
 {
 protected: // create from serialization only
-	Cmfc1View();
-	DECLARE_DYNCREATE(Cmfc1View)
+  Cmfc1View();
+  DECLARE_DYNCREATE(Cmfc1View)
 
-// Attributes
+  // Attributes
 public:
-	Cmfc1Doc* GetDocument() const;
+  Cmfc1Doc* GetDocument() const;
 
-// Operations
+  // Operations
+public:
+  // Overrides
 public:
+  virtual void OnDraw(CDC* pDC); // overridden to draw this view
+  virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 
-// Overrides
-	public:
-	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
-virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 protected:
-	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
-	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
-	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
+  virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
+  virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
+  virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
 
-// Implementation
+  // Implementation
 public:
-	virtual ~Cmfc1View();
+  virtual ~Cmfc1View();
 #ifdef _DEBUG
-	virtual void AssertValid() const;
-	virtual void Dump(CDumpContext& dc) const;
+  virtual void AssertValid() const;
+  virtual void Dump(CDumpContext& dc) const;
 #endif
 
 protected:
-
-// Generated message map functions
+  // Generated message map functions
 protected:
-	DECLARE_MESSAGE_MAP()
+  DECLARE_MESSAGE_MAP()
 };
 
-#ifndef _DEBUG  // debug version in mfc1View.cpp
+#ifndef _DEBUG // debug version in mfc1View.cpp
 inline Cmfc1Doc* Cmfc1View::GetDocument() const
-   { return reinterpret_cast<Cmfc1Doc*>(m_pDocument); }
+{
+  return reinterpret_cast<Cmfc1Doc*>(m_pDocument);
+}
 #endif
diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h
index 35a678d..56f8a6a 100644
--- a/Tests/MFC/mfc1/stdafx.h
+++ b/Tests/MFC/mfc1/stdafx.h
@@ -5,52 +5,65 @@
 #pragma once
 
 #ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
 #endif
 
 // See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info
 // on WINVER and _WIN32_WINNT
 
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
+// Modify the following defines if you have to target a platform prior to the
+// ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different
+// platforms.
+#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4
+               // or later.
 #if _MSC_VER < 1600
-#define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#define WINVER                                                                \
+  0x0400 // Change this to the appropriate value to target Windows 98 and
+         // Windows 2000 or later.
 #else
-#define WINVER 0x0501		// Target Windows XP and later with VS 10 and later
+#define WINVER 0x0501 // Target Windows XP and later with VS 10 and later
 #endif
 #endif
 
-#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or
+                     // later.
 #if _MSC_VER < 1600
-#define _WIN32_WINNT 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
+#define _WIN32_WINNT                                                          \
+  0x0400 // Change this to the appropriate value to target Windows 98 and
+         // Windows 2000 or later.
 #else
-#define _WIN32_WINNT 0x0501		// Target Windows XP and later with VS 10 and later
+#define _WIN32_WINNT 0x0501 // Target Windows XP and later with VS 10 and later
 #endif
 #endif
 
-#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or
+                       // later.
 #if _MSC_VER < 1600
-#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#define _WIN32_WINDOWS                                                        \
+  0x0410 // Change this to the appropriate value to target Windows Me or later.
 #endif
 #endif
 
-#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
+#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
 #if _MSC_VER < 1600
-#define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
+#define _WIN32_IE                                                             \
+  0x0400 // Change this to the appropriate value to target IE 5.0 or later.
 #endif
 #endif
 
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be
+                                           // explicit
 
-// turns off MFC's hiding of some common and often safely ignored warning messages
+// turns off MFC's hiding of some common and often safely ignored warning
+// messages
 #define _AFX_ALL_WARNINGS
 
-#include <afxwin.h>         // MFC core and standard components
-#include <afxext.h>         // MFC extensions
-#include <afxdisp.h>        // MFC Automation classes
+#include <afxdisp.h> // MFC Automation classes
+#include <afxext.h>  // MFC extensions
+#include <afxwin.h>  // MFC core and standard components
 
-#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
 #ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h>			// MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h> // MFC support for Windows Common Controls
+#endif              // _AFX_NO_AFXCMN_SUPPORT
diff --git a/Tests/MSManifest/Subdir/main.c b/Tests/MSManifest/Subdir/main.c
index 78f2de1..8488f4e 100644
--- a/Tests/MSManifest/Subdir/main.c
+++ b/Tests/MSManifest/Subdir/main.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/MacRuntimePath/A/framework.h b/Tests/MacRuntimePath/A/framework.h
index bdd10f0..343317c 100644
--- a/Tests/MacRuntimePath/A/framework.h
+++ b/Tests/MacRuntimePath/A/framework.h
@@ -3,13 +3,13 @@
 #define framework_h
 
 #ifdef WIN32
-# ifdef framework_EXPORTS
-#  define FRAMEWORK_EXPORT __declspec(dllexport)
-# else
-#  define FRAMEWORK_EXPORT __declspec(dllimport)
-# endif
+#ifdef framework_EXPORTS
+#define FRAMEWORK_EXPORT __declspec(dllexport)
 #else
-# define FRAMEWORK_EXPORT
+#define FRAMEWORK_EXPORT __declspec(dllimport)
+#endif
+#else
+#define FRAMEWORK_EXPORT
 #endif
 
 void FRAMEWORK_EXPORT framework();
diff --git a/Tests/MacRuntimePath/A/framework2.h b/Tests/MacRuntimePath/A/framework2.h
index 4576d12..7f45f4d 100644
--- a/Tests/MacRuntimePath/A/framework2.h
+++ b/Tests/MacRuntimePath/A/framework2.h
@@ -3,13 +3,13 @@
 #define framework2_h
 
 #ifdef WIN32
-# ifdef framework2_EXPORTS
-#  define FRAMEWORK2_EXPORT __declspec(dllexport)
-# else
-#  define FRAMEWORK2_EXPORT __declspec(dllimport)
-# endif
+#ifdef framework2_EXPORTS
+#define FRAMEWORK2_EXPORT __declspec(dllexport)
 #else
-# define FRAMEWORK2_EXPORT
+#define FRAMEWORK2_EXPORT __declspec(dllimport)
+#endif
+#else
+#define FRAMEWORK2_EXPORT
 #endif
 
 void FRAMEWORK2_EXPORT framework2();
diff --git a/Tests/MacRuntimePath/A/shared.h b/Tests/MacRuntimePath/A/shared.h
index 3588fb8..28904fd 100644
--- a/Tests/MacRuntimePath/A/shared.h
+++ b/Tests/MacRuntimePath/A/shared.h
@@ -3,13 +3,13 @@
 #define shared_h
 
 #ifdef WIN32
-# ifdef shared_EXPORTS
-#  define SHARED_EXPORT __declspec(dllexport)
-# else
-#  define SHARED_EXPORT __declspec(dllimport)
-# endif
+#ifdef shared_EXPORTS
+#define SHARED_EXPORT __declspec(dllexport)
 #else
-# define SHARED_EXPORT
+#define SHARED_EXPORT __declspec(dllimport)
+#endif
+#else
+#define SHARED_EXPORT
 #endif
 
 void SHARED_EXPORT shared();
diff --git a/Tests/MathTest/MathTestExec.cxx b/Tests/MathTest/MathTestExec.cxx
index 5b94602..124eba4 100644
--- a/Tests/MathTest/MathTestExec.cxx
+++ b/Tests/MathTest/MathTestExec.cxx
@@ -1,26 +1,24 @@
 #include <stdio.h>
 
-#define TEST_EXPRESSION(x, y) \
-  if ( (x) != (y) ) \
-    { \
-    printf("Problem with EXPR: Expression: \"%s\" in C returns %d while in CMake returns: %d\n", \
-      #x, (x), (y)); \
-    res ++; \
-    }
+#define TEST_EXPRESSION(x, y)                                                 \
+  if ((x) != (y)) {                                                           \
+    printf("Problem with EXPR: Expression: \"%s\" in C returns %d while in "  \
+           "CMake returns: %d\n",                                             \
+           #x, (x), (y));                                                     \
+    res++;                                                                    \
+  }
 
 int main(int argc, char* argv[])
 {
-  if ( argc > 1 )
-    {
+  if (argc > 1) {
     printf("Usage: %s\n", argv[0]);
     return 1;
-    }
+  }
   int res = 0;
 #include "MathTestTests.h"
-  if ( res != 0 )
-    {
+  if (res != 0) {
     printf("%s: %d math tests failed\n", argv[0], res);
     return 1;
-    }
+  }
   return 0;
 }
diff --git a/Tests/MissingInstall/mybin.cpp b/Tests/MissingInstall/mybin.cpp
index 237c8ce..5047a34 100644
--- a/Tests/MissingInstall/mybin.cpp
+++ b/Tests/MissingInstall/mybin.cpp
@@ -1 +1,3 @@
-int main() {}
+int main()
+{
+}
diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.c b/Tests/Module/CheckTypeSize/CheckTypeSize.c
index 32e395c..05c798b 100644
--- a/Tests/Module/CheckTypeSize/CheckTypeSize.c
+++ b/Tests/Module/CheckTypeSize/CheckTypeSize.c
@@ -2,37 +2,38 @@
 #include "somestruct.h"
 
 #ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
+#include <sys/types.h>
 #endif
 #ifdef HAVE_STDINT_H
-# include <stdint.h>
+#include <stdint.h>
 #endif
 #ifdef HAVE_STDDEF_H
-# include <stddef.h>
+#include <stddef.h>
 #endif
 
 #include <stdio.h>
 
-#define CHECK(t,m) do {                                                 \
-  if(sizeof(t) != m)                                                    \
-    {                                                                   \
-    printf(#m ": expected %d, got %d (line %d)\n",                      \
-           (int)sizeof(t), (int)m, __LINE__);                           \
-    result = 1;                                                         \
-    }                                                                   \
-  } while(0)
-
-#define NODEF(m) do {                                                   \
-  printf(#m": not defined (line %d)\n", __LINE__);                      \
-  result = 1;                                                           \
-  } while(0)
+#define CHECK(t, m)                                                           \
+  do {                                                                        \
+    if (sizeof(t) != m) {                                                     \
+      printf(#m ": expected %d, got %d (line %d)\n", (int)sizeof(t), (int)m,  \
+             __LINE__);                                                       \
+      result = 1;                                                             \
+    }                                                                         \
+  } while (0)
+
+#define NODEF(m)                                                              \
+  do {                                                                        \
+    printf(#m ": not defined (line %d)\n", __LINE__);                         \
+    result = 1;                                                               \
+  } while (0)
 
 int main()
 {
   int result = 0;
   struct somestruct x;
 
-  /* void* */
+/* void* */
 #if !defined(HAVE_SIZEOF_DATA_PTR)
   NODEF(HAVE_SIZEOF_DATA_PTR);
 #endif
@@ -42,7 +43,7 @@ int main()
   NODEF(SIZEOF_DATA_PTR);
 #endif
 
-  /* char */
+/* char */
 #if !defined(HAVE_SIZEOF_CHAR)
   NODEF(HAVE_SIZEOF_CHAR);
 #endif
@@ -52,7 +53,7 @@ int main()
   NODEF(SIZEOF_CHAR);
 #endif
 
-  /* short */
+/* short */
 #if !defined(HAVE_SIZEOF_SHORT)
   NODEF(HAVE_SIZEOF_SHORT);
 #endif
@@ -62,7 +63,7 @@ int main()
   NODEF(SIZEOF_SHORT);
 #endif
 
-  /* int */
+/* int */
 #if !defined(HAVE_SIZEOF_INT)
   NODEF(HAVE_SIZEOF_INT);
 #endif
@@ -72,7 +73,7 @@ int main()
   NODEF(SIZEOF_INT);
 #endif
 
-  /* long */
+/* long */
 #if !defined(HAVE_SIZEOF_LONG)
   NODEF(HAVE_SIZEOF_LONG);
 #endif
@@ -82,25 +83,25 @@ int main()
   NODEF(SIZEOF_LONG);
 #endif
 
-  /* long long */
+/* long long */
 #if defined(SIZEOF_LONG_LONG)
   CHECK(long long, SIZEOF_LONG_LONG);
-# if !defined(HAVE_SIZEOF_LONG_LONG)
+#if !defined(HAVE_SIZEOF_LONG_LONG)
   NODEF(HAVE_SIZEOF_LONG_LONG);
-# endif
+#endif
 #endif
 
-  /* __int64 */
+/* __int64 */
 #if defined(SIZEOF___INT64)
   CHECK(__int64, SIZEOF___INT64);
-# if !defined(HAVE_SIZEOF___INT64)
+#if !defined(HAVE_SIZEOF___INT64)
   NODEF(HAVE_SIZEOF___INT64);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF___INT64)
   NODEF(SIZEOF___INT64);
 #endif
 
-  /* size_t */
+/* size_t */
 #if !defined(HAVE_SIZEOF_SIZE_T)
   NODEF(HAVE_SIZEOF_SIZE_T);
 #endif
@@ -110,45 +111,45 @@ int main()
   NODEF(SIZEOF_SIZE_T);
 #endif
 
-  /* ssize_t */
+/* ssize_t */
 #if defined(SIZEOF_SSIZE_T)
   CHECK(ssize_t, SIZEOF_SSIZE_T);
-# if !defined(HAVE_SIZEOF_SSIZE_T)
+#if !defined(HAVE_SIZEOF_SSIZE_T)
   NODEF(HAVE_SIZEOF_SSIZE_T);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_SSIZE_T)
   NODEF(SIZEOF_SSIZE_T);
 #endif
 
-  /* struct somestruct::someint */
+/* struct somestruct::someint */
 #if defined(SIZEOF_STRUCTMEMBER_INT)
   CHECK(x.someint, SIZEOF_STRUCTMEMBER_INT);
   CHECK(x.someint, SIZEOF_INT);
-# if !defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
+#if !defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
   NODEF(HAVE_SIZEOF_STRUCTMEMBER_INT);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
   NODEF(SIZEOF_STRUCTMEMBER_INT);
 #endif
 
-  /* struct somestruct::someptr */
+/* struct somestruct::someptr */
 #if defined(SIZEOF_STRUCTMEMBER_PTR)
   CHECK(x.someptr, SIZEOF_STRUCTMEMBER_PTR);
   CHECK(x.someptr, SIZEOF_DATA_PTR);
-# if !defined(HAVE_SIZEOF_STRUCTMEMBER_PTR)
+#if !defined(HAVE_SIZEOF_STRUCTMEMBER_PTR)
   NODEF(HAVE_SIZEOF_STRUCTMEMBER_PTR);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_STRUCTMEMBER_PTR)
   NODEF(SIZEOF_STRUCTMEMBER_PTR);
 #endif
 
-  /* struct somestruct::someint */
+/* struct somestruct::someint */
 #if defined(SIZEOF_STRUCTMEMBER_CHAR)
   CHECK(x.somechar, SIZEOF_STRUCTMEMBER_CHAR);
   CHECK(x.somechar, SIZEOF_CHAR);
-# if !defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR)
+#if !defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR)
   NODEF(HAVE_SIZEOF_STRUCTMEMBER_CHAR);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR)
   NODEF(SIZEOF_STRUCTMEMBER_CHAR);
 #endif
diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx
index b5692cd..2ae84a3 100644
--- a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx
+++ b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx
@@ -3,37 +3,38 @@
 #include "someclass.hxx"
 
 #ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
+#include <sys/types.h>
 #endif
 #ifdef HAVE_STDINT_H
-# include <stdint.h>
+#include <stdint.h>
 #endif
 #ifdef HAVE_STDDEF_H
-# include <stddef.h>
+#include <stddef.h>
 #endif
 
 #include <stdio.h>
 
-#define CHECK(t,m) do {                                                 \
-  if(sizeof(t) != m)                                                    \
-    {                                                                   \
-    printf(#m ": expected %d, got %d (line %d)\n",                      \
-           (int)sizeof(t), (int)m, __LINE__);                           \
-    result = 1;                                                         \
-    }                                                                   \
-  } while(0)
-
-#define NODEF(m) do {                                                   \
-  printf(#m": not defined (line %d)\n", __LINE__);                      \
-  result = 1;                                                           \
-  } while(0)
+#define CHECK(t, m)                                                           \
+  do {                                                                        \
+    if (sizeof(t) != m) {                                                     \
+      printf(#m ": expected %d, got %d (line %d)\n", (int)sizeof(t), (int)m,  \
+             __LINE__);                                                       \
+      result = 1;                                                             \
+    }                                                                         \
+  } while (0)
+
+#define NODEF(m)                                                              \
+  do {                                                                        \
+    printf(#m ": not defined (line %d)\n", __LINE__);                         \
+    result = 1;                                                               \
+  } while (0)
 
 int main()
 {
   int result = 0;
   ns::someclass y;
 
-  /* void* */
+/* void* */
 #if !defined(HAVE_SIZEOF_DATA_PTR)
   NODEF(HAVE_SIZEOF_DATA_PTR);
 #endif
@@ -43,7 +44,7 @@ int main()
   NODEF(SIZEOF_DATA_PTR);
 #endif
 
-  /* char */
+/* char */
 #if !defined(HAVE_SIZEOF_CHAR)
   NODEF(HAVE_SIZEOF_CHAR);
 #endif
@@ -53,7 +54,7 @@ int main()
   NODEF(SIZEOF_CHAR);
 #endif
 
-  /* short */
+/* short */
 #if !defined(HAVE_SIZEOF_SHORT)
   NODEF(HAVE_SIZEOF_SHORT);
 #endif
@@ -63,7 +64,7 @@ int main()
   NODEF(SIZEOF_SHORT);
 #endif
 
-  /* int */
+/* int */
 #if !defined(HAVE_SIZEOF_INT)
   NODEF(HAVE_SIZEOF_INT);
 #endif
@@ -73,7 +74,7 @@ int main()
   NODEF(SIZEOF_INT);
 #endif
 
-  /* long */
+/* long */
 #if !defined(HAVE_SIZEOF_LONG)
   NODEF(HAVE_SIZEOF_LONG);
 #endif
@@ -83,25 +84,25 @@ int main()
   NODEF(SIZEOF_LONG);
 #endif
 
-  /* long long */
+/* long long */
 #if defined(SIZEOF_LONG_LONG)
   CHECK(long long, SIZEOF_LONG_LONG);
-# if !defined(HAVE_SIZEOF_LONG_LONG)
+#if !defined(HAVE_SIZEOF_LONG_LONG)
   NODEF(HAVE_SIZEOF_LONG_LONG);
-# endif
+#endif
 #endif
 
-  /* __int64 */
+/* __int64 */
 #if defined(SIZEOF___INT64)
   CHECK(__int64, SIZEOF___INT64);
-# if !defined(HAVE_SIZEOF___INT64)
+#if !defined(HAVE_SIZEOF___INT64)
   NODEF(HAVE_SIZEOF___INT64);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF___INT64)
   NODEF(SIZEOF___INT64);
 #endif
 
-  /* size_t */
+/* size_t */
 #if !defined(HAVE_SIZEOF_SIZE_T)
   NODEF(HAVE_SIZEOF_SIZE_T);
 #endif
@@ -111,56 +112,56 @@ int main()
   NODEF(SIZEOF_SIZE_T);
 #endif
 
-  /* ssize_t */
+/* ssize_t */
 #if defined(SIZEOF_SSIZE_T)
   CHECK(ssize_t, SIZEOF_SSIZE_T);
-# if !defined(HAVE_SIZEOF_SSIZE_T)
+#if !defined(HAVE_SIZEOF_SSIZE_T)
   NODEF(HAVE_SIZEOF_SSIZE_T);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_SSIZE_T)
   NODEF(SIZEOF_SSIZE_T);
 #endif
 
-  /* ns::someclass::someint */
+/* ns::someclass::someint */
 #if defined(SIZEOF_NS_CLASSMEMBER_INT)
   CHECK(y.someint, SIZEOF_NS_CLASSMEMBER_INT);
   CHECK(y.someint, SIZEOF_INT);
-# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_INT)
+#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_INT)
   NODEF(HAVE_SIZEOF_STRUCTMEMBER_INT);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
   NODEF(SIZEOF_STRUCTMEMBER_INT);
 #endif
 
-  /* ns::someclass::someptr */
+/* ns::someclass::someptr */
 #if defined(SIZEOF_NS_CLASSMEMBER_PTR)
   CHECK(y.someptr, SIZEOF_NS_CLASSMEMBER_PTR);
   CHECK(y.someptr, SIZEOF_DATA_PTR);
-# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR)
+#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR)
   NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_PTR);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR)
   NODEF(SIZEOF_NS_CLASSMEMBER_PTR);
 #endif
 
-  /* ns::someclass::somechar */
+/* ns::someclass::somechar */
 #if defined(SIZEOF_NS_CLASSMEMBER_CHAR)
   CHECK(y.somechar, SIZEOF_NS_CLASSMEMBER_CHAR);
   CHECK(y.somechar, SIZEOF_CHAR);
-# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR)
+#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR)
   NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR)
   NODEF(SIZEOF_NS_CLASSMEMBER_CHAR);
 #endif
 
-  /* ns::someclass::somebool */
+/* ns::someclass::somebool */
 #if defined(SIZEOF_NS_CLASSMEMBER_BOOL)
   CHECK(y.somechar, SIZEOF_NS_CLASSMEMBER_BOOL);
   CHECK(y.somechar, SIZEOF_BOOL);
-# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL)
+#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL)
   NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL);
-# endif
+#endif
 #elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL)
   NODEF(SIZEOF_NS_CLASSMEMBER_BOOL);
 #endif
diff --git a/Tests/Module/CheckTypeSize/someclass.hxx b/Tests/Module/CheckTypeSize/someclass.hxx
index 76c07ec..60d90db 100644
--- a/Tests/Module/CheckTypeSize/someclass.hxx
+++ b/Tests/Module/CheckTypeSize/someclass.hxx
@@ -2,12 +2,13 @@
 #define _CMAKE_SOMECLASS_HXX
 
 namespace ns {
-class someclass {
+class someclass
+{
 public:
-    int someint;
-    void *someptr;
-    char somechar;
-    bool somebool;
+  int someint;
+  void* someptr;
+  char somechar;
+  bool somebool;
 };
 }
 
diff --git a/Tests/Module/CheckTypeSize/somestruct.h b/Tests/Module/CheckTypeSize/somestruct.h
index e08efc4..ffff34f 100644
--- a/Tests/Module/CheckTypeSize/somestruct.h
+++ b/Tests/Module/CheckTypeSize/somestruct.h
@@ -1,10 +1,11 @@
 #ifndef _CMAKE_SOMESTRUCT_H
 #define _CMAKE_SOMESTRUCT_H
 
-struct somestruct {
-    int someint;
-    void *someptr;
-    char somechar;
+struct somestruct
+{
+  int someint;
+  void* someptr;
+  char somechar;
 };
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
index 8cd25a4..8b94ca7 100644
--- a/Tests/Module/GenerateExportHeader/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
+cmake_policy(SET CMP0054 NEW)
 
 project(GenerateExportHeader)
 
@@ -66,6 +67,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
 endif ()
 
+# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+  set(CMAKE_CXX_STANDARD 11)
+endif()
+
 add_subdirectory(lib_shared_and_static)
 
 add_compiler_export_flags()
@@ -107,7 +114,10 @@ add_executable(GenerateExportHeader exportheader_test.cpp)
 
 target_link_libraries(GenerateExportHeader ${link_libraries})
 if (WIN32 OR CYGWIN)
-  if(MSVC AND COMPILER_HAS_DEPRECATED)
+  if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+    set(_platform Win32-Clang)
+  elseif(MSVC AND COMPILER_HAS_DEPRECATED)
     set(_platform Win32)
   elseif((MINGW OR CYGWIN) AND COMPILER_HAS_DEPRECATED)
     set(_platform MinGW)
@@ -124,6 +134,6 @@ endif()
 message("#### Testing reference: ${_platform}")
 target_compile_definitions(GenerateExportHeader
   PRIVATE
-    "SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}"
-    "BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}"
+    "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}\""
+    "BIN_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\""
 )
diff --git a/Tests/Module/GenerateExportHeader/c_identifier/main.cpp b/Tests/Module/GenerateExportHeader/c_identifier/main.cpp
index 68beebb..891bc42 100644
--- a/Tests/Module/GenerateExportHeader/c_identifier/main.cpp
+++ b/Tests/Module/GenerateExportHeader/c_identifier/main.cpp
@@ -1,7 +1,7 @@
 
 #include "c_identifier_class.h"
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   CIdentifierClass cic;
   return cic.someMethod();
diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
index 4f45f37..26bea7e 100644
--- a/Tests/Module/GenerateExportHeader/exportheader_test.cpp
+++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
@@ -20,21 +20,18 @@ void compare(const char* refName, const char* testName)
 {
   std::ifstream ref;
   ref.open(refName);
-  if (!ref.is_open())
-    {
+  if (!ref.is_open()) {
     std::cout << "Could not open \"" << refName << "\"." << std::endl;
     exit(1);
-    }
+  }
   std::ifstream test;
   test.open(testName);
-  if (!test.is_open())
-    {
+  if (!test.is_open()) {
     std::cout << "Could not open \"" << testName << "\"." << std::endl;
     exit(1);
-    }
+  }
 
-  while (!ref.eof() && !test.eof())
-    {
+  while (!ref.eof() && !test.eof()) {
     std::string refLine;
     std::string testLine;
     std::getline(ref, refLine);
@@ -42,31 +39,26 @@ void compare(const char* refName, const char* testName)
     // Some very old Borland runtimes (C++ Builder 5 WITHOUT Update 1) add a
     // trailing null to the string that we need to strip before testing for a
     // trailing space.
-    if (refLine.size() && refLine[refLine.size()-1] == 0)
-      {
+    if (refLine.size() && refLine[refLine.size() - 1] == 0) {
       refLine = refLine.substr(0, refLine.size() - 1);
-      }
-    if (testLine.size() && testLine[testLine.size()-1] == 0)
-      {
+    }
+    if (testLine.size() && testLine[testLine.size() - 1] == 0) {
       testLine = testLine.substr(0, testLine.size() - 1);
-      }
+    }
     // The reference files never have trailing spaces:
-    if (testLine.size() && testLine[testLine.size()-1] == ' ')
-      {
+    if (testLine.size() && testLine[testLine.size() - 1] == ' ') {
       testLine = testLine.substr(0, testLine.size() - 1);
-      }
-    if (refLine != testLine)
-      {
-      std::cout << "Ref and test are not the same:\n  Ref:  \""
-                          << refLine << "\"\n  Test: \"" << testLine << "\"\n";
+    }
+    if (refLine != testLine) {
+      std::cout << "Ref and test are not the same:\n  Ref:  \"" << refLine
+                << "\"\n  Test: \"" << testLine << "\"\n";
       exit(1);
-      }
     }
-  if (!ref.eof() || !test.eof())
-    {
+  }
+  if (!ref.eof() || !test.eof()) {
     std::cout << "Ref and test have differing numbers of lines.";
     exit(1);
-    }
+  }
 }
 
 int main()
@@ -136,13 +128,10 @@ int main()
   libstatic_not_exported();
   libstatic_excluded();
 
-#define STRINGIFY_IMPL(A) #A
-#define STRINGIFY(A) STRINGIFY_IMPL(A)
-
-  compare(STRINGIFY(SRC_DIR) "/libshared_export.h",
-          STRINGIFY(BIN_DIR) "/libshared/libshared_export.h");
-  compare(STRINGIFY(SRC_DIR) "/libstatic_export.h",
-          STRINGIFY(BIN_DIR) "/libstatic/libstatic_export.h");
+  compare(SRC_DIR "/libshared_export.h",
+          BIN_DIR "/libshared/libshared_export.h");
+  compare(SRC_DIR "/libstatic_export.h",
+          BIN_DIR "/libstatic/libstatic_export.h");
 
   return 0;
 }
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
index 1e07273..2764905 100644
--- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
@@ -16,11 +16,13 @@ int LibsharedAndStatic::libshared_and_static_deprecated() const
   return 0;
 }
 
-int LibsharedAndStatic::libshared_and_static_not_exported() const {
+int LibsharedAndStatic::libshared_and_static_not_exported() const
+{
   return 0;
 }
 
-int LibsharedAndStatic::libshared_and_static_excluded() const {
+int LibsharedAndStatic::libshared_and_static_excluded() const
+{
   return 0;
 }
 
@@ -39,11 +41,13 @@ int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const
   return 0;
 }
 
-int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const {
+int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const
+{
   return 0;
 }
 
-int LibsharedAndStaticNotExported::libshared_and_static_excluded() const {
+int LibsharedAndStaticNotExported::libshared_and_static_excluded() const
+{
   return 0;
 }
 
@@ -62,30 +66,37 @@ int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const
   return 0;
 }
 
-int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const {
+int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const
+{
   return 0;
 }
 
-int LibsharedAndStaticExcluded::libshared_and_static_excluded() const {
+int LibsharedAndStaticExcluded::libshared_and_static_excluded() const
+{
   return 0;
 }
 
-int libshared_and_static() {
+int libshared_and_static()
+{
   return 0;
 }
 
-int libshared_and_static_exported() {
+int libshared_and_static_exported()
+{
   return 0;
 }
 
-int libshared_and_static_deprecated() {
+int libshared_and_static_deprecated()
+{
   return 0;
 }
 
-int libshared_and_static_not_exported() {
+int libshared_and_static_not_exported()
+{
   return 0;
 }
 
-int libshared_and_static_excluded() {
+int libshared_and_static_excluded()
+{
   return 0;
 }
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
index 5ad77f4..ea672fe 100644
--- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
@@ -4,48 +4,60 @@
 
 #include "libshared_and_static_export.h"
 
-class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic {
+class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic
+{
 public:
   int libshared_and_static() const;
 
   int libshared_and_static_exported() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED
+  libshared_and_static_deprecated() const;
 
   int libshared_and_static_not_exported() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT
+  libshared_and_static_excluded() const;
 };
 
-class LibsharedAndStaticNotExported {
+class LibsharedAndStaticNotExported
+{
 public:
   int libshared_and_static() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT
+  libshared_and_static_exported() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED
+  libshared_and_static_deprecated() const;
 
   int libshared_and_static_not_exported() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT
+  libshared_and_static_excluded() const;
 };
 
-class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded {
+class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded
+{
 public:
   int libshared_and_static() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT
+  libshared_and_static_exported() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED
+  libshared_and_static_deprecated() const;
 
   int libshared_and_static_not_exported() const;
 
-  int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+  int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT
+  libshared_and_static_excluded() const;
 };
 
 MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
 
-MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated();
+MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int
+libshared_and_static_deprecated();
 
 int libshared_and_static_not_exported();
 
diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp
index d4041b3..ad6d356 100644
--- a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp
+++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp
@@ -16,11 +16,13 @@ int Libshared::libshared_deprecated() const
   return 0;
 }
 
-int Libshared::libshared_not_exported() const {
+int Libshared::libshared_not_exported() const
+{
   return 0;
 }
 
-int Libshared::libshared_excluded() const {
+int Libshared::libshared_excluded() const
+{
   return 0;
 }
 
@@ -39,11 +41,13 @@ int LibsharedNotExported::libshared_deprecated() const
   return 0;
 }
 
-int LibsharedNotExported::libshared_not_exported() const {
+int LibsharedNotExported::libshared_not_exported() const
+{
   return 0;
 }
 
-int LibsharedNotExported::libshared_excluded() const {
+int LibsharedNotExported::libshared_excluded() const
+{
   return 0;
 }
 
@@ -62,30 +66,37 @@ int LibsharedExcluded::libshared_deprecated() const
   return 0;
 }
 
-int LibsharedExcluded::libshared_not_exported() const {
+int LibsharedExcluded::libshared_not_exported() const
+{
   return 0;
 }
 
-int LibsharedExcluded::libshared_excluded() const {
+int LibsharedExcluded::libshared_excluded() const
+{
   return 0;
 }
 
-int libshared() {
+int libshared()
+{
   return 0;
 }
 
-int libshared_exported() {
+int libshared_exported()
+{
   return 0;
 }
 
-int libshared_deprecated() {
+int libshared_deprecated()
+{
   return 0;
 }
 
-int libshared_not_exported() {
+int libshared_not_exported()
+{
   return 0;
 }
 
-int libshared_excluded() {
+int libshared_excluded()
+{
   return 0;
 }
diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h
index 3d9bbff..bd9f2e3 100644
--- a/Tests/Module/GenerateExportHeader/libshared/libshared.h
+++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h
@@ -4,7 +4,8 @@
 
 #include "libshared_export.h"
 
-class LIBSHARED_EXPORT Libshared {
+class LIBSHARED_EXPORT Libshared
+{
 public:
   int libshared() const;
 
@@ -17,7 +18,8 @@ public:
   int LIBSHARED_NO_EXPORT libshared_excluded() const;
 };
 
-class LibsharedNotExported {
+class LibsharedNotExported
+{
 public:
   int libshared() const;
 
@@ -30,7 +32,8 @@ public:
   int LIBSHARED_NO_EXPORT libshared_excluded() const;
 };
 
-class LIBSHARED_NO_EXPORT LibsharedExcluded {
+class LIBSHARED_NO_EXPORT LibsharedExcluded
+{
 public:
   int libshared() const;
 
diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp
index 0710c3e..89381af 100644
--- a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp
+++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp
@@ -16,11 +16,13 @@ int Libstatic::libstatic_deprecated() const
   return 0;
 }
 
-int Libstatic::libstatic_not_exported() const {
+int Libstatic::libstatic_not_exported() const
+{
   return 0;
 }
 
-int Libstatic::libstatic_excluded() const {
+int Libstatic::libstatic_excluded() const
+{
   return 0;
 }
 
@@ -39,11 +41,13 @@ int LibstaticNotExported::libstatic_deprecated() const
   return 0;
 }
 
-int LibstaticNotExported::libstatic_not_exported() const {
+int LibstaticNotExported::libstatic_not_exported() const
+{
   return 0;
 }
 
-int LibstaticNotExported::libstatic_excluded() const {
+int LibstaticNotExported::libstatic_excluded() const
+{
   return 0;
 }
 
@@ -62,26 +66,32 @@ int LibstaticExcluded::libstatic_deprecated() const
   return 0;
 }
 
-int LibstaticExcluded::libstatic_not_exported() const {
+int LibstaticExcluded::libstatic_not_exported() const
+{
   return 0;
 }
 
-int LibstaticExcluded::libstatic_excluded() const {
+int LibstaticExcluded::libstatic_excluded() const
+{
   return 0;
 }
 
-int libstatic_exported() {
+int libstatic_exported()
+{
   return 0;
 }
 
-int libstatic_deprecated() {
+int libstatic_deprecated()
+{
   return 0;
 }
 
-int libstatic_not_exported() {
+int libstatic_not_exported()
+{
   return 0;
 }
 
-int libstatic_excluded() {
+int libstatic_excluded()
+{
   return 0;
 }
diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h
index cc7a35b..6072d9b 100644
--- a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h
+++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h
@@ -4,7 +4,8 @@
 
 #include "libstatic_export.h"
 
-class LIBSTATIC_EXPORT Libstatic {
+class LIBSTATIC_EXPORT Libstatic
+{
 public:
   int libstatic() const;
 
@@ -17,7 +18,8 @@ public:
   int LIBSTATIC_NO_EXPORT libstatic_excluded() const;
 };
 
-class LibstaticNotExported {
+class LibstaticNotExported
+{
 public:
   int libstatic() const;
 
@@ -30,7 +32,8 @@ public:
   int LIBSTATIC_NO_EXPORT libstatic_excluded() const;
 };
 
-class LIBSTATIC_NO_EXPORT LibstaticExcluded {
+class LIBSTATIC_NO_EXPORT LibstaticExcluded
+{
 public:
   int libstatic() const;
 
diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp
index a3f4111..81dce62 100644
--- a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp
+++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp
@@ -4,6 +4,5 @@
 #ifndef NODEPRECATEDLIB_NO_DEPRECATED
 void SomeClass::someMethod() const
 {
-
 }
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h
index b6749b2..e8af0a5 100644
--- a/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h
@@ -33,9 +33,10 @@
 #  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSHARED_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h
index e8000e2..598bd71 100644
--- a/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h
@@ -33,9 +33,10 @@
 #  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSTATIC_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h
index d376631..cc20e09 100644
--- a/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h
@@ -33,9 +33,10 @@
 #  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSHARED_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h
index fd021e9..4aaa848 100644
--- a/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h
@@ -33,9 +33,10 @@
 #  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSTATIC_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h
index 7d8087f..053ad18 100644
--- a/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h
@@ -33,9 +33,10 @@
 #  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSHARED_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h
index fd021e9..4aaa848 100644
--- a/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h
@@ -33,9 +33,10 @@
 #  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSTATIC_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
index 5681f58..808ff01 100644
--- a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
@@ -33,9 +33,10 @@
 #  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSHARED_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
index fd021e9..4aaa848 100644
--- a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
@@ -33,9 +33,10 @@
 #  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSTATIC_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Win32-Clang/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
new file mode 100644
index 0000000..cc20e09
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
@@ -0,0 +1,42 @@
+
+#ifndef LIBSHARED_EXPORT_H
+#define LIBSHARED_EXPORT_H
+
+#ifdef LIBSHARED_STATIC_DEFINE
+#  define LIBSHARED_EXPORT
+#  define LIBSHARED_NO_EXPORT
+#else
+#  ifndef LIBSHARED_EXPORT
+#    ifdef libshared_EXPORTS
+        /* We are building this library */
+#      define LIBSHARED_EXPORT __declspec(dllexport)
+#    else
+        /* We are using this library */
+#      define LIBSHARED_EXPORT __declspec(dllimport)
+#    endif
+#  endif
+
+#  ifndef LIBSHARED_NO_EXPORT
+#    define LIBSHARED_NO_EXPORT
+#  endif
+#endif
+
+#ifndef LIBSHARED_DEPRECATED
+#  define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_EXPORT
+#  define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
+#  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
+#endif
+
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
new file mode 100644
index 0000000..4aaa848
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
@@ -0,0 +1,42 @@
+
+#ifndef LIBSTATIC_EXPORT_H
+#define LIBSTATIC_EXPORT_H
+
+#ifdef LIBSTATIC_STATIC_DEFINE
+#  define LIBSTATIC_EXPORT
+#  define LIBSTATIC_NO_EXPORT
+#else
+#  ifndef LIBSTATIC_EXPORT
+#    ifdef libstatic_EXPORTS
+        /* We are building this library */
+#      define LIBSTATIC_EXPORT
+#    else
+        /* We are using this library */
+#      define LIBSTATIC_EXPORT
+#    endif
+#  endif
+
+#  ifndef LIBSTATIC_NO_EXPORT
+#    define LIBSTATIC_NO_EXPORT
+#  endif
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED
+#  define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_EXPORT
+#  define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
+#  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
+#endif
+
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
+#endif
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h
index 976c92e..4e675af 100644
--- a/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h
@@ -33,9 +33,10 @@
 #  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSHARED_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h
index db4df61..4d5ed4e 100644
--- a/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h
@@ -33,9 +33,10 @@
 #  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSTATIC_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h
index 2dc41d4..84340e3 100644
--- a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h
@@ -33,9 +33,10 @@
 #  define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSHARED_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSHARED_NO_DEPRECATED
+#    define LIBSHARED_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
index e8000e2..598bd71 100644
--- a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
+++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
@@ -33,9 +33,10 @@
 #  define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
 #endif
 
-#define DEFINE_NO_DEPRECATED 0
-#if DEFINE_NO_DEPRECATED
-# define LIBSTATIC_NO_DEPRECATED
+#if 0 /* DEFINE_NO_DEPRECATED */
+#  ifndef LIBSTATIC_NO_DEPRECATED
+#    define LIBSTATIC_NO_DEPRECATED
+#  endif
 #endif
 
 #endif
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index c538280..8b251d7 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -11,7 +11,7 @@ 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 AppleClang MSVC SunPro
+  COMPILERS GNU Clang AppleClang MSVC SunPro Intel
   VERSION 3.1
   PROLOG "// something"
   EPILOG "// more"
@@ -61,7 +61,8 @@ endmacro()
 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
     OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
     OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
-    OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
+    OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro"
+    OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
   # False for C++98 mode.
   list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
   list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
@@ -80,7 +81,9 @@ endif()
 
 if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
     OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
-    OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+    OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
+    OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
+
   add_executable(C_undefined c_undefined.c)
   set_property(TARGET C_undefined PROPERTY C_STANDARD 90)
   target_compile_options(C_undefined PRIVATE -Werror=undef)
@@ -104,7 +107,7 @@ write_compiler_detection_header(
   PREFIX MULTI
   OUTPUT_FILES_VAR multi_files
   OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/compiler_support"
-  COMPILERS GNU Clang AppleClang MSVC SunPro
+  COMPILERS GNU Clang AppleClang MSVC SunPro Intel
   VERSION 3.1
   FEATURES
     ${cxx_known_features} ${c_known_features}
@@ -142,7 +145,8 @@ set_defines(multi_files_11 "${true_defs}" "${false_defs}")
 
 if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
     OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
-    OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+    OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
+    OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
   add_executable(WriteCompilerDetectionHeader_C11 main.c)
   set_property(TARGET WriteCompilerDetectionHeader_C11 PROPERTY C_STANDARD 11)
   set_defines(WriteCompilerDetectionHeader_C11 "EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES;EXPECTED_COMPILER_C_RESTRICT" "")
diff --git a/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h b/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h
index 8b547d8..d3c2a2d 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h
+++ b/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h
@@ -1,8 +1,10 @@
 
-#define JOIN_IMPL(A, B) A ## B
+#define JOIN_IMPL(A, B) A##B
 #define JOIN(A, B) JOIN_IMPL(A, B)
 
-#define CHECK(FEATURE) (JOIN(PREFIX, JOIN(_COMPILER_, FEATURE)) == JOIN(EXPECTED_COMPILER_, FEATURE))
+#define CHECK(FEATURE)                                                        \
+  (JOIN(PREFIX, JOIN(_COMPILER_, FEATURE)) ==                                 \
+   JOIN(EXPECTED_COMPILER_, FEATURE))
 
 #if !CHECK(CXX_DELEGATING_CONSTRUCTORS)
 #error cxx_delegating_constructors expected availability did not match.
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main.c b/Tests/Module/WriteCompilerDetectionHeader/main.c
index 9023b0f..ee6abdb 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/main.c
+++ b/Tests/Module/WriteCompilerDetectionHeader/main.c
@@ -1,22 +1,23 @@
 
 #include "test_compiler_detection.h"
 
-#if !defined(TEST_COMPILER_C_FUNCTION_PROTOTYPES) || !TEST_COMPILER_C_FUNCTION_PROTOTYPES
-#  error Expected TEST_COMPILER_C_FUNCTION_PROTOTYPES
+#if !defined(TEST_COMPILER_C_FUNCTION_PROTOTYPES) ||                          \
+  !TEST_COMPILER_C_FUNCTION_PROTOTYPES
+#error Expected TEST_COMPILER_C_FUNCTION_PROTOTYPES
 #endif
 
 #if !EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
-#  error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
+#error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
 #endif
 
 #if !defined(TEST_COMPILER_C_RESTRICT) || !TEST_COMPILER_C_RESTRICT
-#  if EXPECTED_COMPILER_C_RESTRICT
-#    error Expected TEST_COMPILER_C_RESTRICT
-#  endif
+#if EXPECTED_COMPILER_C_RESTRICT
+#error Expected TEST_COMPILER_C_RESTRICT
+#endif
 #else
-#  if !EXPECTED_COMPILER_C_RESTRICT
-#    error Expect no TEST_COMPILER_C_RESTRICT
-#  endif
+#if !EXPECTED_COMPILER_C_RESTRICT
+#error Expect no TEST_COMPILER_C_RESTRICT
+#endif
 #endif
 
 #ifdef TEST_COMPILER_CXX_STATIC_ASSERT
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main_multi.c b/Tests/Module/WriteCompilerDetectionHeader/main_multi.c
index 6f4573f..6e13fd7 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/main_multi.c
+++ b/Tests/Module/WriteCompilerDetectionHeader/main_multi.c
@@ -1,22 +1,23 @@
 
 #include "multi_file_compiler_detection.h"
 
-#if !defined(MULTI_COMPILER_C_FUNCTION_PROTOTYPES) || !MULTI_COMPILER_C_FUNCTION_PROTOTYPES
-#  error Expected MULTI_COMPILER_C_FUNCTION_PROTOTYPES
+#if !defined(MULTI_COMPILER_C_FUNCTION_PROTOTYPES) ||                         \
+  !MULTI_COMPILER_C_FUNCTION_PROTOTYPES
+#error Expected MULTI_COMPILER_C_FUNCTION_PROTOTYPES
 #endif
 
 #if !EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
-#  error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
+#error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
 #endif
 
 #if !defined(MULTI_COMPILER_C_RESTRICT) || !MULTI_COMPILER_C_RESTRICT
-#  if EXPECTED_COMPILER_C_RESTRICT
-#    error Expected MULTI_COMPILER_C_RESTRICT
-#  endif
+#if EXPECTED_COMPILER_C_RESTRICT
+#error Expected MULTI_COMPILER_C_RESTRICT
+#endif
 #else
-#  if !EXPECTED_COMPILER_C_RESTRICT
-#    error Expect no MULTI_COMPILER_C_RESTRICT
-#  endif
+#if !EXPECTED_COMPILER_C_RESTRICT
+#error Expect no MULTI_COMPILER_C_RESTRICT
+#endif
 #endif
 
 #ifdef MULTI_COMPILER_CXX_STATIC_ASSERT
diff --git a/Tests/ModuleDefinition/example_dll.c b/Tests/ModuleDefinition/example_dll.c
index 88b3904..3d57b9a 100644
--- a/Tests/ModuleDefinition/example_dll.c
+++ b/Tests/ModuleDefinition/example_dll.c
@@ -1 +1,4 @@
-int example_dll_function(void) { return 0; }
+int example_dll_function(void)
+{
+  return 0;
+}
diff --git a/Tests/ModuleDefinition/example_dll_2.c b/Tests/ModuleDefinition/example_dll_2.c
index 9d79acd..6f33867 100644
--- a/Tests/ModuleDefinition/example_dll_2.c
+++ b/Tests/ModuleDefinition/example_dll_2.c
@@ -1 +1,4 @@
-int example_dll_2_function(void) { return 0; }
+int example_dll_2_function(void)
+{
+  return 0;
+}
diff --git a/Tests/ModuleDefinition/example_dll_gen.c b/Tests/ModuleDefinition/example_dll_gen.c
index be5d1ee..ac0a88b 100644
--- a/Tests/ModuleDefinition/example_dll_gen.c
+++ b/Tests/ModuleDefinition/example_dll_gen.c
@@ -1 +1,4 @@
-int example_dll_gen_function(void) { return 0; }
+int example_dll_gen_function(void)
+{
+  return 0;
+}
diff --git a/Tests/ModuleDefinition/example_exe.c b/Tests/ModuleDefinition/example_exe.c
index 253ae8b..dff566f 100644
--- a/Tests/ModuleDefinition/example_exe.c
+++ b/Tests/ModuleDefinition/example_exe.c
@@ -3,12 +3,13 @@ extern int __declspec(dllimport) example_dll_gen_function(void);
 #ifdef EXAMPLE_DLL_2
 extern int __declspec(dllimport) example_dll_2_function(void);
 #endif
-int example_exe_function(void) { return 0; }
+int example_exe_function(void)
+{
+  return 0;
+}
 int main(void)
 {
-  return
-    example_dll_function() +
-    example_dll_gen_function() +
+  return example_dll_function() + example_dll_gen_function() +
 #ifdef EXAMPLE_DLL_2
     example_dll_2_function() +
 #endif
diff --git a/Tests/ModuleDefinition/example_mod_1.c b/Tests/ModuleDefinition/example_mod_1.c
index 4e2f9ba..6b355cf 100644
--- a/Tests/ModuleDefinition/example_mod_1.c
+++ b/Tests/ModuleDefinition/example_mod_1.c
@@ -1,7 +1,7 @@
 #ifdef __WATCOMC__
-# define MODULE_CCONV __cdecl
+#define MODULE_CCONV __cdecl
 #else
-# define MODULE_CCONV
+#define MODULE_CCONV
 #endif
 
 int __declspec(dllimport) example_exe_function(void);
@@ -12,8 +12,7 @@ int __declspec(dllimport) example_dll_2_function(void);
 
 __declspec(dllexport) int MODULE_CCONV example_mod_1_function(int n)
 {
-  return
-    example_dll_function() +
+  return example_dll_function() +
 #ifdef EXAMPLE_DLL_2
     example_dll_2_function() +
 #endif
diff --git a/Tests/NewlineArgs/cxxonly.cxx b/Tests/NewlineArgs/cxxonly.cxx
index 05d55e4..9e6f918 100644
--- a/Tests/NewlineArgs/cxxonly.cxx
+++ b/Tests/NewlineArgs/cxxonly.cxx
@@ -3,13 +3,12 @@
 
 #include <stdio.h>
 
-int main ()
+int main()
 {
-  if ( LibCxx1Class::Method() != 2.0 )
-    {
+  if (LibCxx1Class::Method() != 2.0) {
     printf("Problem with libcxx1\n");
     return 1;
-    }
+  }
 #ifdef TEST_FLAG_3
   return 0;
 #else
diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt
index c24c5ed..188fd64 100644
--- a/Tests/ObjectLibrary/A/CMakeLists.txt
+++ b/Tests/ObjectLibrary/A/CMakeLists.txt
@@ -12,11 +12,8 @@ add_custom_command(
   )
 
 # Remove the custom command output to be sure it runs in an
-# incremental test.  Skip this on VS 6 because it sometimes
-# re-runs CMake after the custom command runs.
-if(NOT CMAKE_GENERATOR STREQUAL "Visual Studio 6")
-  file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/a.cmake)
-endif()
+# incremental test.
+file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/a.cmake)
 add_custom_command(
   OUTPUT a.cmake
   COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/a.cmake
diff --git a/Tests/ObjectLibrary/A/a.h b/Tests/ObjectLibrary/A/a.h
index 7259f98..b1fd42f 100644
--- a/Tests/ObjectLibrary/A/a.h
+++ b/Tests/ObjectLibrary/A/a.h
@@ -1,6 +1,6 @@
 #ifndef A_DEF
-# error "A_DEF not defined"
+#error "A_DEF not defined"
 #endif
 #ifdef B_DEF
-# error "B_DEF must not be defined"
+#error "B_DEF must not be defined"
 #endif
diff --git a/Tests/ObjectLibrary/A/a2.c b/Tests/ObjectLibrary/A/a2.c
index d8f225e..fbb0c02 100644
--- a/Tests/ObjectLibrary/A/a2.c
+++ b/Tests/ObjectLibrary/A/a2.c
@@ -1,2 +1,5 @@
 #include "a.h"
-int a2(void) { return 0; }
+int a2(void)
+{
+  return 0;
+}
diff --git a/Tests/ObjectLibrary/B/CMakeLists.txt b/Tests/ObjectLibrary/B/CMakeLists.txt
index 2158084..ecace4f 100644
--- a/Tests/ObjectLibrary/B/CMakeLists.txt
+++ b/Tests/ObjectLibrary/B/CMakeLists.txt
@@ -1,8 +1,4 @@
 project(ObjectLibraryB C)
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
-  # VS 6 generator does not use per-target object locations.
-  set(vs6 _vs6)
-endif()
 
 # Add -fPIC so objects can be used in shared libraries.
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -11,7 +7,7 @@ add_library(B OBJECT b1.c b2.c)
 target_include_directories(B PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
 target_compile_definitions(B PUBLIC B_DEF)
 
-add_library(Bexport OBJECT b1${vs6}.c b2${vs6}.c)
+add_library(Bexport OBJECT b1.c b2.c)
 set_property(TARGET Bexport PROPERTY COMPILE_DEFINITIONS Bexport)
 target_include_directories(Bexport PRIVATE $<TARGET_PROPERTY:B,INTERFACE_INCLUDE_DIRECTORIES>)
 target_compile_definitions(Bexport PRIVATE $<TARGET_PROPERTY:B,INTERFACE_COMPILE_DEFINITIONS>)
diff --git a/Tests/ObjectLibrary/B/b.h b/Tests/ObjectLibrary/B/b.h
index 3489c71..a7bd352 100644
--- a/Tests/ObjectLibrary/B/b.h
+++ b/Tests/ObjectLibrary/B/b.h
@@ -1,18 +1,18 @@
 #ifdef A_DEF
-# error "A_DEF must not be defined"
+#error "A_DEF must not be defined"
 #endif
 #ifndef B_DEF
-# error "B_DEF not defined"
+#error "B_DEF not defined"
 #endif
 
 #if defined(_WIN32) && defined(Bexport)
-# define EXPORT_B __declspec(dllexport)
+#define EXPORT_B __declspec(dllexport)
 #else
-# define EXPORT_B
+#define EXPORT_B
 #endif
 
 #if defined(_WIN32) && defined(SHARED_B)
-# define IMPORT_B __declspec(dllimport)
+#define IMPORT_B __declspec(dllimport)
 #else
-# define IMPORT_B
+#define IMPORT_B
 #endif
diff --git a/Tests/ObjectLibrary/B/b1.c b/Tests/ObjectLibrary/B/b1.c
index fdeffe4..d804d43 100644
--- a/Tests/ObjectLibrary/B/b1.c
+++ b/Tests/ObjectLibrary/B/b1.c
@@ -1,2 +1,5 @@
 #include "b.h"
-EXPORT_B int b1(void) { return 0; }
+EXPORT_B int b1(void)
+{
+  return 0;
+}
diff --git a/Tests/ObjectLibrary/B/b1_vs6.c b/Tests/ObjectLibrary/B/b1_vs6.c
deleted file mode 100644
index b606e10..0000000
--- a/Tests/ObjectLibrary/B/b1_vs6.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "b1.c"
diff --git a/Tests/ObjectLibrary/B/b2.c b/Tests/ObjectLibrary/B/b2.c
index 6e0d17c..4615b54 100644
--- a/Tests/ObjectLibrary/B/b2.c
+++ b/Tests/ObjectLibrary/B/b2.c
@@ -1,2 +1,5 @@
 #include "b.h"
-EXPORT_B int b2(void) { return 0; }
+EXPORT_B int b2(void)
+{
+  return 0;
+}
diff --git a/Tests/ObjectLibrary/B/b2_vs6.c b/Tests/ObjectLibrary/B/b2_vs6.c
deleted file mode 100644
index d96a43e..0000000
--- a/Tests/ObjectLibrary/B/b2_vs6.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "b2.c"
diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt
index e9f553e..e3476df 100644
--- a/Tests/ObjectLibrary/CMakeLists.txt
+++ b/Tests/ObjectLibrary/CMakeLists.txt
@@ -16,8 +16,8 @@ add_custom_command(TARGET UseCshared POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CM
 
 add_executable(UseCinternal main.c c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>)
 
-if("${CMAKE_GENERATOR}" MATCHES "^Visual Studio (6|7|7 .NET 2003)$")
-  # VS 6 and 7 generators do not add objects as sources so we need a
+if("${CMAKE_GENERATOR}" MATCHES "^Visual Studio (7|7 .NET 2003)$")
+  # VS 7 generators do not add objects as sources so we need a
   # dummy object to convince the IDE to build the targets below.
   set(dummy dummy.obj) # In MinGW: gcc -c dummy.c -o dummy.obj
 elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
diff --git a/Tests/ObjectLibrary/ExportLanguages/a.c b/Tests/ObjectLibrary/ExportLanguages/a.c
index af20d3f..1636303 100644
--- a/Tests/ObjectLibrary/ExportLanguages/a.c
+++ b/Tests/ObjectLibrary/ExportLanguages/a.c
@@ -1 +1,4 @@
-int a(void) { return 0; }
+int a(void)
+{
+  return 0;
+}
diff --git a/Tests/ObjectLibrary/ExportLanguages/a.cxx b/Tests/ObjectLibrary/ExportLanguages/a.cxx
index ae9c87c..c661b94 100644
--- a/Tests/ObjectLibrary/ExportLanguages/a.cxx
+++ b/Tests/ObjectLibrary/ExportLanguages/a.cxx
@@ -1 +1,4 @@
-extern "C" int acxx(void) { return 0; }
+extern "C" int acxx(void)
+{
+  return 0;
+}
diff --git a/Tests/ObjectLibrary/c.c b/Tests/ObjectLibrary/c.c
index 968095b..4c37e38 100644
--- a/Tests/ObjectLibrary/c.c
+++ b/Tests/ObjectLibrary/c.c
@@ -1,7 +1,7 @@
 #if defined(_WIN32) && defined(Cshared_EXPORTS)
-# define EXPORT_C __declspec(dllexport)
+#define EXPORT_C __declspec(dllexport)
 #else
-# define EXPORT_C
+#define EXPORT_C
 #endif
 
 extern int a1(void);
@@ -10,10 +10,5 @@ extern int b1(void);
 extern int b2(void);
 EXPORT_C int c(void)
 {
-  return 0
-    + a1()
-    + a2()
-    + b1()
-    + b2()
-    ;
+  return 0 + a1() + a2() + b1() + b2();
 }
diff --git a/Tests/ObjectLibrary/dummy.c b/Tests/ObjectLibrary/dummy.c
index 2b17d81..3983c6a 100644
--- a/Tests/ObjectLibrary/dummy.c
+++ b/Tests/ObjectLibrary/dummy.c
@@ -1 +1,4 @@
-int dummy(void) {return 0;}
+int dummy(void)
+{
+  return 0;
+}
diff --git a/Tests/ObjectLibrary/main.c b/Tests/ObjectLibrary/main.c
index 6819f1c..b2f1d44 100644
--- a/Tests/ObjectLibrary/main.c
+++ b/Tests/ObjectLibrary/main.c
@@ -1,16 +1,12 @@
 #if defined(_WIN32) && defined(SHARED_C)
-# define IMPORT_C __declspec(dllimport)
+#define IMPORT_C __declspec(dllimport)
 #else
-# define IMPORT_C
+#define IMPORT_C
 #endif
 extern IMPORT_C int b1(void);
 extern IMPORT_C int b2(void);
 extern IMPORT_C int c(void);
 int main(void)
 {
-  return 0
-    + c()
-    + b1()
-    + b2()
-    ;
+  return 0 + c() + b1() + b2();
 }
diff --git a/Tests/ObjectLibrary/mainAB.c b/Tests/ObjectLibrary/mainAB.c
index 38db205..a7aa393 100644
--- a/Tests/ObjectLibrary/mainAB.c
+++ b/Tests/ObjectLibrary/mainAB.c
@@ -11,10 +11,7 @@ int main(void)
 {
   return 0
 #ifndef NO_A
-    + a1()
-    + a2()
+    + a1() + a2()
 #endif
-    + b1()
-    + b2()
-    ;
+    + b1() + b2();
 }
diff --git a/Tests/OutDir/OutDir.c b/Tests/OutDir/OutDir.c
index 53f9259..4f6ae87 100644
--- a/Tests/OutDir/OutDir.c
+++ b/Tests/OutDir/OutDir.c
@@ -3,22 +3,18 @@
 
 int main(void)
 {
-  const char* files[] = {TESTC1_LIB, TESTC2_LIB, CONLY_EXE, 0};
+  const char* files[] = { TESTC1_LIB, TESTC2_LIB, CONLY_EXE, 0 };
   int result = 0;
   const char** fname = files;
-  for(;*fname;++fname)
-    {
+  for (; *fname; ++fname) {
     FILE* f = fopen(*fname, "rb");
-    if(f)
-      {
+    if (f) {
       printf("found: [%s]\n", *fname);
       fclose(f);
-      }
-    else
-      {
+    } else {
       printf("error: [%s]\n", *fname);
       result = 1;
-      }
     }
+  }
   return result;
 }
diff --git a/Tests/OutOfBinary/outexe.c b/Tests/OutOfBinary/outexe.c
index 6f14043..4170d97 100644
--- a/Tests/OutOfBinary/outexe.c
+++ b/Tests/OutOfBinary/outexe.c
@@ -1,2 +1,5 @@
 extern int subdir(void);
-int main(void) { return subdir(); }
+int main(void)
+{
+  return subdir();
+}
diff --git a/Tests/OutOfBinary/outlib.c b/Tests/OutOfBinary/outlib.c
index 9ea579b..d309ebe 100644
--- a/Tests/OutOfBinary/outlib.c
+++ b/Tests/OutOfBinary/outlib.c
@@ -1,2 +1,4 @@
-int outlib() { return 456; }
-
+int outlib()
+{
+  return 456;
+}
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx
index d88c311..12cbd1a 100644
--- a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx
+++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx
@@ -1,8 +1,8 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "testlib.h"
 #include "testdp.h"
+#include "testlib.h"
 
 extern int simple();
 #ifndef NO_DEEPSRC
@@ -10,30 +10,25 @@ extern int simple2();
 #endif
 extern "C" int outlib();
 
-int main ()
+int main()
 {
-  if(simple() != 123)
-    {
+  if (simple() != 123) {
     return -3;
-    }
-  if (strcmp(animal,"SIZZLING"))
-    {
-    fprintf(stderr,"Get definitions from a subdir did not work\n");
+  }
+  if (strcmp(animal, "SIZZLING")) {
+    fprintf(stderr, "Get definitions from a subdir did not work\n");
     return -2;
-    }
-  if(TestLib() != 1.0)
-    {
+  }
+  if (TestLib() != 1.0) {
     return -1;
-    }
-  if(outlib() != 456)
-    {
+  }
+  if (outlib() != 456) {
     return -4;
-    }
+  }
 #ifndef NO_DEEPSRC
-  if(simple2() != 789)
-    {
+  if (simple2() != 789) {
     return -5;
-    }
+  }
 #endif
   return 0;
 }
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
index 75c2d84..bacf5a1 100644
--- a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
+++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef testlib_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef testlib_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float TestLib();
diff --git a/Tests/OutOfSource/SubDir/subdir.c b/Tests/OutOfSource/SubDir/subdir.c
index 0d0d827..abf4e18 100644
--- a/Tests/OutOfSource/SubDir/subdir.c
+++ b/Tests/OutOfSource/SubDir/subdir.c
@@ -1 +1,4 @@
-int subdir(void) { return 0; }
+int subdir(void)
+{
+  return 0;
+}
diff --git a/Tests/OutOfSource/simple.cxx b/Tests/OutOfSource/simple.cxx
index 27e79f4..ffe0db9 100644
--- a/Tests/OutOfSource/simple.cxx
+++ b/Tests/OutOfSource/simple.cxx
@@ -1 +1,4 @@
-int simple() { return 123; }
+int simple()
+{
+  return 123;
+}
diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt
index 180f9fe..2fb894e 100644
--- a/Tests/PDBDirectoryAndName/CMakeLists.txt
+++ b/Tests/PDBDirectoryAndName/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 2.8)
+cmake_policy(SET CMP0054 NEW)
 project(PDBDirectoryAndName C)
 
 # Make sure the proper compiler is in use.
@@ -62,14 +63,17 @@ list(APPEND my_targets myexe2)
 
 target_link_libraries(myexe2 mylibA mylibD)
 
-#-----------------------------------------------------------------------------
-# Check that PDB files actually appear where expected.
 
-# The PDB_NAME and PDB_OUTPUT_DIRECTORY options do not work in VS 6.
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
-  return()
+# Clang/C2 does not produce pdb files for static libraries
+if (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
+  list(REMOVE_ITEM my_targets mylibB mylibD)
 endif()
 
+
+#-----------------------------------------------------------------------------
+# Check that PDB files actually appear where expected.
+
 set(pdbs "")
 foreach(t ${my_targets})
   get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME)
diff --git a/Tests/PDBDirectoryAndName/myexe.c b/Tests/PDBDirectoryAndName/myexe.c
index c6d9065..fdb8b09 100644
--- a/Tests/PDBDirectoryAndName/myexe.c
+++ b/Tests/PDBDirectoryAndName/myexe.c
@@ -2,4 +2,7 @@ extern int mylibA();
 extern int mylibB();
 extern int mylibC();
 extern int mylibD();
-int main() { return mylibA() + mylibB() + mylibC() + mylibD(); }
+int main()
+{
+  return mylibA() + mylibB() + mylibC() + mylibD();
+}
diff --git a/Tests/PDBDirectoryAndName/myexe2.c b/Tests/PDBDirectoryAndName/myexe2.c
index 75b39cd..250d651 100644
--- a/Tests/PDBDirectoryAndName/myexe2.c
+++ b/Tests/PDBDirectoryAndName/myexe2.c
@@ -1,3 +1,6 @@
 extern int mylibA();
 extern int mylibD();
-int main() { return mylibA() + mylibD(); }
+int main()
+{
+  return mylibA() + mylibD();
+}
diff --git a/Tests/PDBDirectoryAndName/mylibA.c b/Tests/PDBDirectoryAndName/mylibA.c
index f4c553f..5bc279b 100644
--- a/Tests/PDBDirectoryAndName/mylibA.c
+++ b/Tests/PDBDirectoryAndName/mylibA.c
@@ -1 +1,4 @@
-__declspec(dllexport) int mylibA() { return 1; }
+__declspec(dllexport) int mylibA()
+{
+  return 1;
+}
diff --git a/Tests/PDBDirectoryAndName/mylibB.c b/Tests/PDBDirectoryAndName/mylibB.c
index 2040c67..3a95845 100644
--- a/Tests/PDBDirectoryAndName/mylibB.c
+++ b/Tests/PDBDirectoryAndName/mylibB.c
@@ -1 +1,4 @@
-int mylibB() { return -1; }
+int mylibB()
+{
+  return -1;
+}
diff --git a/Tests/PDBDirectoryAndName/mylibC.c b/Tests/PDBDirectoryAndName/mylibC.c
index adf7c70..8982849 100644
--- a/Tests/PDBDirectoryAndName/mylibC.c
+++ b/Tests/PDBDirectoryAndName/mylibC.c
@@ -1 +1,4 @@
-__declspec(dllexport) int mylibC() { return 1; }
+__declspec(dllexport) int mylibC()
+{
+  return 1;
+}
diff --git a/Tests/PDBDirectoryAndName/mylibD.c b/Tests/PDBDirectoryAndName/mylibD.c
index efa8a82..a53b7a2 100644
--- a/Tests/PDBDirectoryAndName/mylibD.c
+++ b/Tests/PDBDirectoryAndName/mylibD.c
@@ -1 +1,4 @@
-int mylibD() { return -1; }
+int mylibD()
+{
+  return -1;
+}
diff --git a/Tests/PerConfig/pcShared.h b/Tests/PerConfig/pcShared.h
index 59a6ef4..031cd79 100644
--- a/Tests/PerConfig/pcShared.h
+++ b/Tests/PerConfig/pcShared.h
@@ -2,13 +2,13 @@
 #define pcShared_h
 
 #ifdef _WIN32
-# ifdef pcShared_EXPORTS
-#  define PC_EXPORT __declspec(dllexport)
-# else
-#  define PC_EXPORT __declspec(dllimport)
-# endif
+#ifdef pcShared_EXPORTS
+#define PC_EXPORT __declspec(dllexport)
 #else
-# define PC_EXPORT
+#define PC_EXPORT __declspec(dllimport)
+#endif
+#else
+#define PC_EXPORT
 #endif
 
 PC_EXPORT const char* pcShared(void);
diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt
index 2b7bac1..49ff317 100644
--- a/Tests/Plugin/CMakeLists.txt
+++ b/Tests/Plugin/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required (VERSION 2.6)
+cmake_policy(SET CMP0054 NEW)
 project(Plugin)
 
 # Test per-target output directory properties.
@@ -34,6 +35,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
 endif ()
 
+# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
+    CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+  set(CMAKE_CXX_STANDARD 11)
+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/Plugin/include/example.h b/Tests/Plugin/include/example.h
index 1d7e8c0..87d992e 100644
--- a/Tests/Plugin/include/example.h
+++ b/Tests/Plugin/include/example.h
@@ -2,18 +2,17 @@
 #define example_h
 
 #if defined(_WIN32) || defined(__CYGWIN__)
-# if defined(example_exe_EXPORTS)
-#  define EXAMPLE_EXPORT __declspec(dllexport)
-# else
-#  define EXAMPLE_EXPORT __declspec(dllimport)
-# endif
+#if defined(example_exe_EXPORTS)
+#define EXAMPLE_EXPORT __declspec(dllexport)
 #else
-# define EXAMPLE_EXPORT
+#define EXAMPLE_EXPORT __declspec(dllimport)
+#endif
+#else
+#define EXAMPLE_EXPORT
 #endif
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
 EXAMPLE_EXPORT int example_exe_function(void);
diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx
index 12d9204..857ad54 100644
--- a/Tests/Plugin/src/example_exe.cxx
+++ b/Tests/Plugin/src/example_exe.cxx
@@ -1,8 +1,9 @@
+#include <kwsys/DynamicLoader.hxx>
+
 #include <example.h>
 
 #include <example_exe.h>
 
-#include <kwsys/DynamicLoader.hxx>
 #include <iostream>
 #include <string>
 
@@ -16,9 +17,9 @@ extern "C" int example_exe_function()
 }
 
 #ifdef CMAKE_INTDIR
-# define CONFIG_DIR "/" CMAKE_INTDIR
+#define CONFIG_DIR "/" CMAKE_INTDIR
 #else
-# define CONFIG_DIR ""
+#define CONFIG_DIR ""
 #endif
 
 int main()
@@ -29,32 +30,27 @@ int main()
   libName += kwsys::DynamicLoader::LibExtension();
   kwsys::DynamicLoader::LibraryHandle handle =
     kwsys::DynamicLoader::OpenLibrary(libName.c_str());
-  if(!handle)
-    {
-    std::cerr << "Could not open plugin \""
-              << libName.c_str() << "\"!" << std::endl;
+  if (!handle) {
+    std::cerr << "Could not open plugin \"" << libName.c_str() << "\"!"
+              << std::endl;
     return 1;
-    }
+  }
   kwsys::DynamicLoader::SymbolPointer sym =
     kwsys::DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function");
-  if(!sym)
-    {
-    std::cerr
-      << "Could not get plugin symbol \"example_mod_1_function\"!"
-      << std::endl;
+  if (!sym) {
+    std::cerr << "Could not get plugin symbol \"example_mod_1_function\"!"
+              << std::endl;
     return 1;
-    }
+  }
 #ifdef __WATCOMC__
-  int(__cdecl *f)(int) = (int(__cdecl *)(int))(sym);
+  int(__cdecl * f)(int) = (int(__cdecl*)(int))(sym);
 #else
-  int(*f)(int) = reinterpret_cast<int(*)(int)>(sym);
+  int (*f)(int) = reinterpret_cast<int (*)(int)>(sym);
 #endif
-  if(f(456) != (123+456))
-    {
-    std::cerr << "Incorrect return value from plugin!"
-              << std::endl;
+  if (f(456) != (123 + 456)) {
+    std::cerr << "Incorrect return value from plugin!" << std::endl;
     return 1;
-    }
+  }
   kwsys::DynamicLoader::CloseLibrary(handle);
   return 0;
 }
diff --git a/Tests/Plugin/src/example_mod_1.c b/Tests/Plugin/src/example_mod_1.c
index 1fc7338..a5dd984 100644
--- a/Tests/Plugin/src/example_mod_1.c
+++ b/Tests/Plugin/src/example_mod_1.c
@@ -3,15 +3,15 @@
 #include <stdio.h>
 
 #if defined(_WIN32)
-# define MODULE_EXPORT __declspec(dllexport)
+#define MODULE_EXPORT __declspec(dllexport)
 #else
-# define MODULE_EXPORT
+#define MODULE_EXPORT
 #endif
 
 #ifdef __WATCOMC__
-# define MODULE_CCONV __cdecl
+#define MODULE_CCONV __cdecl
 #else
-# define MODULE_CCONV
+#define MODULE_CCONV
 #endif
 
 MODULE_EXPORT int MODULE_CCONV example_mod_1_function(int n)
diff --git a/Tests/PositionIndependentTargets/main.cpp b/Tests/PositionIndependentTargets/main.cpp
index e72cef7..e9ad257 100644
--- a/Tests/PositionIndependentTargets/main.cpp
+++ b/Tests/PositionIndependentTargets/main.cpp
@@ -1,2 +1,5 @@
 
-int main(int,char**) { return 0; }
+int main(int, char**)
+{
+  return 0;
+}
diff --git a/Tests/PositionIndependentTargets/pic_main.cpp b/Tests/PositionIndependentTargets/pic_main.cpp
index 6a41a7a..3246eee 100644
--- a/Tests/PositionIndependentTargets/pic_main.cpp
+++ b/Tests/PositionIndependentTargets/pic_main.cpp
@@ -1,4 +1,7 @@
 
 #include "pic_test.h"
 
-int main(int,char**) { return 0; }
+int main(int, char**)
+{
+  return 0;
+}
diff --git a/Tests/PreOrder/simple.cxx b/Tests/PreOrder/simple.cxx
index ef26e79..7f99579 100644
--- a/Tests/PreOrder/simple.cxx
+++ b/Tests/PreOrder/simple.cxx
@@ -1,5 +1,5 @@
 extern void simpleLib();
-int main ()
+int main()
 {
   simpleLib();
   return 0;
diff --git a/Tests/PrecompiledHeader/CMakeLists.txt b/Tests/PrecompiledHeader/CMakeLists.txt
index 98bdd88..a804538 100644
--- a/Tests/PrecompiledHeader/CMakeLists.txt
+++ b/Tests/PrecompiledHeader/CMakeLists.txt
@@ -17,14 +17,8 @@ else()
   file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PCH)
 endif()
 
-# The VS6 IDE does not support renaming .pch files with /Fp.
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
-  set(PCH_USE_INCLUDE_DIR 1)
-  set(PCH_FILE)
-else()
-  set(PCH_USE_INCLUDE_DIR 0)
-  set(PCH_FILE "\"/Fp${PCH_DIR}/foo_precompiled.pch\"")
-endif()
+set(PCH_USE_INCLUDE_DIR 0)
+set(PCH_FILE "\"/Fp${PCH_DIR}/foo_precompiled.pch\"")
 
 # Choose between an explicit include path and using /I during
 # precompilation.  The /I form is used to test that the PCH is
diff --git a/Tests/PrecompiledHeader/foo1.c b/Tests/PrecompiledHeader/foo1.c
index b10eba7..77172ba 100644
--- a/Tests/PrecompiledHeader/foo1.c
+++ b/Tests/PrecompiledHeader/foo1.c
@@ -1,5 +1,5 @@
 #ifndef foo_h
-# error "Precompiled header foo_precompiled.h has not been loaded."
+#error "Precompiled header foo_precompiled.h has not been loaded."
 #endif
 
 int main()
diff --git a/Tests/PrecompiledHeader/foo2.c b/Tests/PrecompiledHeader/foo2.c
index 2845cdb..f192e16 100644
--- a/Tests/PrecompiledHeader/foo2.c
+++ b/Tests/PrecompiledHeader/foo2.c
@@ -1,6 +1,6 @@
 #ifndef foo_h
-# include "foo.h"
-# error "Precompiled header foo_precompiled.h has not been loaded."
+#include "foo.h"
+#error "Precompiled header foo_precompiled.h has not been loaded."
 #endif
 
 int foo()
diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt
index 15e2aca..b930f56 100644
--- a/Tests/Preprocess/CMakeLists.txt
+++ b/Tests/Preprocess/CMakeLists.txt
@@ -10,9 +10,6 @@ project(Preprocess)
 if("${CMAKE_GENERATOR}" MATCHES "Xcode")
   set(PP_XCODE 1)
 endif()
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
-  set(PP_VS6 1)
-endif()
 if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
   set(PP_UMAKE 1)
 endif()
@@ -60,20 +57,15 @@ if(NOT BORLAND AND NOT PP_VS70)
   set(SEMICOLON "\;")
 endif()
 
-if(NOT PP_VS6)
-  # VS 6 IDE: spaces and '"', '$', or ';'
-  # The project parser cannot handle spaces if there are quotes.
-  # Since we test passing in a quoted string, we cannot have spaces.
-  set(STRING_EXTRA "${STRING_EXTRA} ")
+set(STRING_EXTRA "${STRING_EXTRA} ")
 
-  if(NOT PP_BORLAND AND NOT PP_WATCOM)
-    # Borland, WMake: multiple spaces
-    # The make tool seems to remove extra whitespace from inside
-    # quoted strings when passing to the compiler.  It does not have
-    # trouble passing to other tools, and the compiler may be directly
-    # invoked from the command line.
-    set(STRING_EXTRA "${STRING_EXTRA} ")
-  endif()
+if(NOT PP_BORLAND AND NOT PP_WATCOM)
+  # Borland, WMake: multiple spaces
+  # The make tool seems to remove extra whitespace from inside
+  # quoted strings when passing to the compiler.  It does not have
+  # trouble passing to other tools, and the compiler may be directly
+  # invoked from the command line.
+  set(STRING_EXTRA "${STRING_EXTRA} ")
 endif()
 
 if(NOT PP_VS)
@@ -201,14 +193,10 @@ endif()
 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DPREPROCESS_DEBUG")
 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DPREPROCESS_DEBUG")
 
-# Inform the test if it built from Xcode or VS6 IDE.
+# Inform the test if it built from Xcode.
 if(PP_XCODE)
   set(PREPROCESS_XCODE 1)
 endif()
-if(PP_VS6)
-  set(PREPROCESS_VS6 1)
-  set(VS6 _vs6)
-endif()
 
 # Test old-style definitions.
 add_definitions(-DOLD_DEF -DOLD_EXPR=2)
@@ -220,7 +208,7 @@ if(NOT "${OLD_DEFS}" STREQUAL "${OLD_DEFS_EXPECTED}")
   message(SEND_ERROR "add_definitions not converted to directory property!")
 endif()
 
-add_executable(Preprocess preprocess.c preprocess${VS6}.cxx)
+add_executable(Preprocess preprocess.c preprocess.cxx)
 
 set(FILE_PATH "${Preprocess_SOURCE_DIR}/file_def.h")
 set(TARGET_PATH "${Preprocess_SOURCE_DIR}/target_def.h")
@@ -236,17 +224,14 @@ foreach(c "" "_DEBUG" "_RELEASE")
     PROPERTY COMPILE_DEFINITIONS${c} "TARGET_DEF${c}"
     )
   set_property(
-    SOURCE preprocess.c preprocess${VS6}.cxx
+    SOURCE preprocess.c preprocess.cxx
     PROPERTY COMPILE_DEFINITIONS${c} "FILE_DEF${c}"
     )
 endforeach()
 
 # Add definitions with values.
-if(NOT PREPROCESS_VS6)
-  # The path might have spaces, which VS6 does not support.
-  set(DEF_TARGET_PATH "TARGET_PATH=\"${TARGET_PATH}\"")
-  set(DEF_FILE_PATH "FILE_PATH=\"${FILE_PATH}\"")
-endif()
+set(DEF_TARGET_PATH "TARGET_PATH=\"${TARGET_PATH}\"")
+set(DEF_FILE_PATH "FILE_PATH=\"${FILE_PATH}\"")
 set_property(
   TARGET Preprocess
   APPEND PROPERTY COMPILE_DEFINITIONS
@@ -255,7 +240,7 @@ set_property(
   ${DEF_TARGET_PATH}
   )
 set_property(
-  SOURCE preprocess.c preprocess${VS6}.cxx
+  SOURCE preprocess.c preprocess.cxx
   APPEND PROPERTY COMPILE_DEFINITIONS
   "FILE_STRING=\"${STRING_VALUE}${SEMICOLON}\""
   "FILE_EXPR=${EXPR}"
diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c
index 16209ac..1b038b0 100644
--- a/Tests/Preprocess/preprocess.c
+++ b/Tests/Preprocess/preprocess.c
@@ -3,195 +3,188 @@
 #include FILE_PATH
 #include TARGET_PATH
 
-#include <string.h>
 #include <stdio.h>
+#include <string.h>
 
 int check_defines_C(void)
 {
   int result = 1;
-  if(strcmp(FILE_STRING, STRING_VALUE) != 0)
-    {
-    fprintf(stderr,
-            "FILE_STRING has wrong value in C [%s]\n", FILE_STRING);
+  if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
+    fprintf(stderr, "FILE_STRING has wrong value in C [%s]\n", FILE_STRING);
     result = 0;
-    }
-  if(strcmp(TARGET_STRING, STRING_VALUE) != 0)
-    {
-    fprintf(stderr,
-            "TARGET_STRING has wrong value in C [%s]\n", TARGET_STRING);
+  }
+  if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
+    fprintf(stderr, "TARGET_STRING has wrong value in C [%s]\n",
+            TARGET_STRING);
     result = 0;
-    }
+  }
   {
-  int x = 2;
-  int y = 3;
-  if((FILE_EXPR) != (EXPR))
-    {
-    fprintf(stderr, "FILE_EXPR did not work in C [%s]\n",
-            TO_STRING(FILE_EXPR));
-    result = 0;
+    int x = 2;
+    int y = 3;
+    if ((FILE_EXPR) != (EXPR)) {
+      fprintf(stderr, "FILE_EXPR did not work in C [%s]\n",
+              TO_STRING(FILE_EXPR));
+      result = 0;
     }
-  if((TARGET_EXPR) != (EXPR))
-    {
-    fprintf(stderr, "TARGET_EXPR did not work in C [%s]\n",
-            TO_STRING(FILE_EXPR));
-    result = 0;
+    if ((TARGET_EXPR) != (EXPR)) {
+      fprintf(stderr, "TARGET_EXPR did not work in C [%s]\n",
+              TO_STRING(FILE_EXPR));
+      result = 0;
     }
   }
 #ifdef NDEBUG
-# ifdef FILE_DEF_DEBUG
+#ifdef FILE_DEF_DEBUG
   {
-  fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n");
+    result = 0;
   }
-# endif
-# ifdef TARGET_DEF_DEBUG
+#endif
+#ifdef TARGET_DEF_DEBUG
   {
-  fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n");
+    result = 0;
   }
-# endif
-# ifdef DIRECTORY_DEF_DEBUG
+#endif
+#ifdef DIRECTORY_DEF_DEBUG
   {
-  fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n");
+    result = 0;
   }
-# endif
-# ifndef FILE_DEF_RELEASE
-#  ifndef PREPROCESS_XCODE
+#endif
+#ifndef FILE_DEF_RELEASE
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n");
+    result = 0;
   }
-#  endif
-# endif
-# ifndef TARGET_DEF_RELEASE
+#endif
+#endif
+#ifndef TARGET_DEF_RELEASE
   {
-  fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n");
+    result = 0;
   }
-# endif
-# ifndef DIRECTORY_DEF_RELEASE
+#endif
+#ifndef DIRECTORY_DEF_RELEASE
   {
-  fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #ifdef PREPROCESS_DEBUG
-# ifndef FILE_DEF_DEBUG
-#  ifndef PREPROCESS_XCODE
+#ifndef FILE_DEF_DEBUG
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n");
+    result = 0;
   }
-#  endif
-# endif
-# ifndef TARGET_DEF_DEBUG
+#endif
+#endif
+#ifndef TARGET_DEF_DEBUG
   {
-  fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n");
+    result = 0;
   }
-# endif
-# ifndef DIRECTORY_DEF_DEBUG
+#endif
+#ifndef DIRECTORY_DEF_DEBUG
   {
-  fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n");
+    result = 0;
   }
-# endif
-# ifdef FILE_DEF_RELEASE
+#endif
+#ifdef FILE_DEF_RELEASE
   {
-  fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n");
+    result = 0;
   }
-# endif
-# ifdef TARGET_DEF_RELEASE
+#endif
+#ifdef TARGET_DEF_RELEASE
   {
-  fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n");
+    result = 0;
   }
-# endif
-# ifdef DIRECTORY_DEF_RELEASE
+#endif
+#ifdef DIRECTORY_DEF_RELEASE
   {
-  fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
-# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
-#  ifndef PREPROCESS_XCODE
+#if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr,
-          "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n");
+    result = 0;
   }
-#  endif
-# endif
-# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
+#endif
+#endif
+#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
   {
-  fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n");
-  result = 0;
+    fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
-# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
-#  ifndef PREPROCESS_XCODE
+#if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr,
-          "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n");
-  result = 0;
+    fprintf(stderr,
+            "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n");
+    result = 0;
   }
-#  endif
-# endif
-# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
+#endif
+#endif
+#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
   {
-  fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n");
-  result = 0;
+    fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #ifndef FILE_PATH_DEF
   {
-  fprintf(stderr, "FILE_PATH_DEF not defined in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_PATH_DEF not defined in C\n");
+    result = 0;
   }
 #endif
 #ifndef TARGET_PATH_DEF
   {
-  fprintf(stderr, "TARGET_PATH_DEF not defined in C\n");
-  result = 0;
+    fprintf(stderr, "TARGET_PATH_DEF not defined in C\n");
+    result = 0;
   }
 #endif
 #ifndef FILE_DEF
   {
-  fprintf(stderr, "FILE_DEF not defined in C\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF not defined in C\n");
+    result = 0;
   }
 #endif
 #ifndef TARGET_DEF
   {
-  fprintf(stderr, "TARGET_DEF not defined in C\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF not defined in C\n");
+    result = 0;
   }
 #endif
 #ifndef DIRECTORY_DEF
   {
-  fprintf(stderr, "DIRECTORY_DEF not defined in C\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF not defined in C\n");
+    result = 0;
   }
 #endif
 #ifndef OLD_DEF
   {
-  fprintf(stderr, "OLD_DEF not defined in C\n");
-  result = 0;
+    fprintf(stderr, "OLD_DEF not defined in C\n");
+    result = 0;
   }
 #endif
 #if !defined(OLD_EXPR) || OLD_EXPR != 2
   {
-  fprintf(stderr, "OLD_EXPR id not work in C [%s]\n",
-          TO_STRING(OLD_EXPR));
-  result = 0;
+    fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", TO_STRING(OLD_EXPR));
+    result = 0;
   }
 #endif
   return result;
diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx
index 27b6ac8..0fab785 100644
--- a/Tests/Preprocess/preprocess.cxx
+++ b/Tests/Preprocess/preprocess.cxx
@@ -3,197 +3,191 @@
 #include FILE_PATH
 #include TARGET_PATH
 
-#include <string.h>
 #include <stdio.h>
+#include <string.h>
 
 extern "C" int check_defines_C(void);
 
 int check_defines_CXX()
 {
   int result = 1;
-  if(strcmp(FILE_STRING, STRING_VALUE) != 0)
-    {
-    fprintf(stderr,
-            "FILE_STRING has wrong value in CXX [%s]\n", FILE_STRING);
+  if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
+    fprintf(stderr, "FILE_STRING has wrong value in CXX [%s]\n", FILE_STRING);
     result = 0;
-    }
-  if(strcmp(TARGET_STRING, STRING_VALUE) != 0)
-    {
-    fprintf(stderr,
-            "TARGET_STRING has wrong value in CXX [%s]\n", TARGET_STRING);
+  }
+  if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
+    fprintf(stderr, "TARGET_STRING has wrong value in CXX [%s]\n",
+            TARGET_STRING);
     result = 0;
-    }
+  }
   {
-  int x = 2;
-  int y = 3;
-  if((FILE_EXPR) != (EXPR))
-    {
-    fprintf(stderr, "FILE_EXPR did not work in CXX [%s]\n",
-            TO_STRING(FILE_EXPR));
-    result = 0;
+    int x = 2;
+    int y = 3;
+    if ((FILE_EXPR) != (EXPR)) {
+      fprintf(stderr, "FILE_EXPR did not work in CXX [%s]\n",
+              TO_STRING(FILE_EXPR));
+      result = 0;
     }
-  if((TARGET_EXPR) != (EXPR))
-    {
-    fprintf(stderr, "TARGET_EXPR did not work in CXX [%s]\n",
-            TO_STRING(FILE_EXPR));
-    result = 0;
+    if ((TARGET_EXPR) != (EXPR)) {
+      fprintf(stderr, "TARGET_EXPR did not work in CXX [%s]\n",
+              TO_STRING(FILE_EXPR));
+      result = 0;
     }
   }
 #ifdef NDEBUG
-# ifdef FILE_DEF_DEBUG
+#ifdef FILE_DEF_DEBUG
   {
-  fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifdef TARGET_DEF_DEBUG
+#endif
+#ifdef TARGET_DEF_DEBUG
   {
-  fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifdef DIRECTORY_DEF_DEBUG
+#endif
+#ifdef DIRECTORY_DEF_DEBUG
   {
-  fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifndef FILE_DEF_RELEASE
-#  ifndef PREPROCESS_XCODE
+#endif
+#ifndef FILE_DEF_RELEASE
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n");
+    result = 0;
   }
-#  endif
-# endif
-# ifndef TARGET_DEF_RELEASE
+#endif
+#endif
+#ifndef TARGET_DEF_RELEASE
   {
-  fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifndef DIRECTORY_DEF_RELEASE
+#endif
+#ifndef DIRECTORY_DEF_RELEASE
   {
-  fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #ifdef PREPROCESS_DEBUG
-# ifndef FILE_DEF_DEBUG
-#  ifndef PREPROCESS_XCODE
+#ifndef FILE_DEF_DEBUG
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n");
+    result = 0;
   }
-#  endif
-# endif
-# ifndef TARGET_DEF_DEBUG
+#endif
+#endif
+#ifndef TARGET_DEF_DEBUG
   {
-  fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifndef DIRECTORY_DEF_DEBUG
+#endif
+#ifndef DIRECTORY_DEF_DEBUG
   {
-  fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifdef FILE_DEF_RELEASE
+#endif
+#ifdef FILE_DEF_RELEASE
   {
-  fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifdef TARGET_DEF_RELEASE
+#endif
+#ifdef TARGET_DEF_RELEASE
   {
-  fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n");
+    result = 0;
   }
-# endif
-# ifdef DIRECTORY_DEF_RELEASE
+#endif
+#ifdef DIRECTORY_DEF_RELEASE
   {
-  fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
-# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
-#  ifndef PREPROCESS_XCODE
+#if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr,
-          "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n");
-  result = 0;
+    fprintf(stderr,
+            "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n");
+    result = 0;
   }
-#  endif
-# endif
-# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
+#endif
+#endif
+#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
   {
-  fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n");
-  result = 0;
+    fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
-# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
-#  ifndef PREPROCESS_XCODE
+#if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
+#ifndef PREPROCESS_XCODE
   {
-  fprintf(stderr,
-          "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n");
-  result = 0;
+    fprintf(stderr,
+            "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n");
+    result = 0;
   }
-#  endif
-# endif
-# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
+#endif
+#endif
+#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
   {
-  fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n");
-  result = 0;
+    fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n");
+    result = 0;
   }
-# endif
+#endif
 #endif
 #ifndef FILE_PATH_DEF
   {
-  fprintf(stderr, "FILE_PATH_DEF not defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "FILE_PATH_DEF not defined in CXX\n");
+    result = 0;
   }
 #endif
 #ifndef TARGET_PATH_DEF
   {
-  fprintf(stderr, "TARGET_PATH_DEF not defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "TARGET_PATH_DEF not defined in CXX\n");
+    result = 0;
   }
 #endif
 #ifndef FILE_DEF
   {
-  fprintf(stderr, "FILE_DEF not defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "FILE_DEF not defined in CXX\n");
+    result = 0;
   }
 #endif
 #ifndef TARGET_DEF
   {
-  fprintf(stderr, "TARGET_DEF not defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "TARGET_DEF not defined in CXX\n");
+    result = 0;
   }
 #endif
 #ifndef DIRECTORY_DEF
   {
-  fprintf(stderr, "DIRECTORY_DEF not defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "DIRECTORY_DEF not defined in CXX\n");
+    result = 0;
   }
 #endif
 #ifndef OLD_DEF
   {
-  fprintf(stderr, "OLD_DEF not defined in CXX\n");
-  result = 0;
+    fprintf(stderr, "OLD_DEF not defined in CXX\n");
+    result = 0;
   }
 #endif
 #if !defined(OLD_EXPR) || OLD_EXPR != 2
   {
-  fprintf(stderr, "OLD_EXPR id not work in C [%s]\n",
-          TO_STRING(OLD_EXPR));
-  result = 0;
+    fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", TO_STRING(OLD_EXPR));
+    result = 0;
   }
 #endif
   return result;
@@ -203,23 +197,18 @@ int main()
 {
   int result = 1;
 
-  if(!check_defines_C())
-    {
+  if (!check_defines_C()) {
     result = 0;
-    }
+  }
 
-  if(!check_defines_CXX())
-    {
+  if (!check_defines_CXX()) {
     result = 0;
-    }
+  }
 
-  if(result)
-    {
+  if (result) {
     printf("All preprocessor definitions are correct.\n");
     return 0;
-    }
-  else
-    {
+  } else {
     return 1;
-    }
+  }
 }
diff --git a/Tests/Preprocess/preprocess.h.in b/Tests/Preprocess/preprocess.h.in
index 3e1c7a0..e058a58 100644
--- a/Tests/Preprocess/preprocess.h.in
+++ b/Tests/Preprocess/preprocess.h.in
@@ -2,12 +2,6 @@
 #define STRING_VALUE "@STRING_VALUE@"
 #define EXPR @EXPR@
 #cmakedefine PREPROCESS_XCODE
-#cmakedefine PREPROCESS_VS6
-
-#ifdef PREPROCESS_VS6
-# define FILE_PATH "@FILE_PATH@"
-# define TARGET_PATH "@TARGET_PATH@"
-#endif
 
 /* Declarations and macros shared by all sources.  */
 #define TO_STRING(x) TO_STRING0(x)
diff --git a/Tests/Preprocess/preprocess_vs6.cxx b/Tests/Preprocess/preprocess_vs6.cxx
deleted file mode 100644
index 9df89f6..0000000
--- a/Tests/Preprocess/preprocess_vs6.cxx
+++ /dev/null
@@ -1,3 +0,0 @@
-// The VS6 IDE does not support object name configuration so we need a
-// source file with a different name.  Include the real source file.
-#include "preprocess.cxx"
diff --git a/Tests/Properties/SubDir/properties3.cxx b/Tests/Properties/SubDir/properties3.cxx
index 1a27a04..6d24fbb 100644
--- a/Tests/Properties/SubDir/properties3.cxx
+++ b/Tests/Properties/SubDir/properties3.cxx
@@ -2,7 +2,7 @@
 #include "properties2.h"
 
 #if defined HAVE_PROPERTIES_H && defined HAVE_PROPERTIES2_H
-int main ()
+int main()
 {
   return 0;
 }
diff --git a/Tests/Qt4Deploy/testdeploy.cpp b/Tests/Qt4Deploy/testdeploy.cpp
index 8b9c8d6..33c0bb3 100644
--- a/Tests/Qt4Deploy/testdeploy.cpp
+++ b/Tests/Qt4Deploy/testdeploy.cpp
@@ -1,7 +1,7 @@
 #include <QCoreApplication>
-#include <QSqlDatabase>
-#include <QLibraryInfo>
 #include <QDebug>
+#include <QLibraryInfo>
+#include <QSqlDatabase>
 #include <QStringList>
 
 int main(int argc, char** argv)
@@ -9,19 +9,19 @@ int main(int argc, char** argv)
   QCoreApplication app(argc, argv);
 
   qDebug() << "App path:" << app.applicationDirPath();
-  qDebug() << "Plugin path:" << QLibraryInfo::location(QLibraryInfo::PluginsPath);
+  qDebug() << "Plugin path:"
+           << QLibraryInfo::location(QLibraryInfo::PluginsPath);
 
   bool foundSqlite = false;
 
   qDebug() << "Supported Database Drivers:";
-  foreach(const QString &sqlDriver, QSqlDatabase::drivers())
-  {
+  foreach (const QString& sqlDriver, QSqlDatabase::drivers()) {
     qDebug() << " " << sqlDriver;
-    if(sqlDriver == "QSQLITE")
+    if (sqlDriver == "QSQLITE")
       foundSqlite = true;
   }
 
-  if(foundSqlite)
+  if (foundSqlite)
     qDebug() << "Found sqlite support from plugin.";
   else
     qDebug() << "Could not find sqlite support from plugin.";
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.cpp b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
index e924f7e..00685d0 100644
--- a/Tests/Qt4Targets/IncrementalMoc/foo.cpp
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
@@ -4,5 +4,4 @@
 Foo::Foo()
   : QObject(0)
 {
-
 }
diff --git a/Tests/Qt4Targets/activeqtexe.cpp b/Tests/Qt4Targets/activeqtexe.cpp
index d4a9121..f17b0a6 100644
--- a/Tests/Qt4Targets/activeqtexe.cpp
+++ b/Tests/Qt4Targets/activeqtexe.cpp
@@ -9,22 +9,21 @@
 
 class MyObject : public QObject
 {
- Q_OBJECT
+  Q_OBJECT
 public:
- MyObject(QObject *parent = 0)
-     : QObject(parent)
- {
- }
+  MyObject(QObject* parent = 0)
+    : QObject(parent)
+  {
+  }
 };
 
-QAXFACTORY_DEFAULT(MyObject,
-                    "{4dc3f340-a6f7-44e4-a79b-3e9217685fbd}",
-                    "{9ee49617-7d5c-441a-b833-4b068d41d751}",
-                    "{13eca64b-ee2a-4f3c-aa04-5d9d975779a7}",
-                    "{ce947ee3-0403-4fdc-895a-4fe779344b46}",
-                    "{8de435ce-8d2a-46ac-b3b3-cb800d0547c7}");
+QAXFACTORY_DEFAULT(MyObject, "{4dc3f340-a6f7-44e4-a79b-3e9217685fbd}",
+                   "{9ee49617-7d5c-441a-b833-4b068d41d751}",
+                   "{13eca64b-ee2a-4f3c-aa04-5d9d975779a7}",
+                   "{ce947ee3-0403-4fdc-895a-4fe779344b46}",
+                   "{8de435ce-8d2a-46ac-b3b3-cb800d0547c7}");
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   QApplication app(argc, argv);
 
diff --git a/Tests/Qt4Targets/interface/myinterface.h b/Tests/Qt4Targets/interface/myinterface.h
index 59b43ad..5cc3b27 100644
--- a/Tests/Qt4Targets/interface/myinterface.h
+++ b/Tests/Qt4Targets/interface/myinterface.h
@@ -4,7 +4,6 @@
 
 class MyInterface
 {
-
 };
 
 Q_DECLARE_INTERFACE(MyInterface, "org.cmake.example.MyInterface")
diff --git a/Tests/Qt4Targets/main.cpp b/Tests/Qt4Targets/main.cpp
index 3c98c99..07443b0 100644
--- a/Tests/Qt4Targets/main.cpp
+++ b/Tests/Qt4Targets/main.cpp
@@ -12,7 +12,7 @@
 #error Expected QT_GUI_LIB
 #endif
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   QApplication app(argc, argv);
 
diff --git a/Tests/Qt4Targets/main_gen_test.cpp b/Tests/Qt4Targets/main_gen_test.cpp
index 984424b..1ea390b 100644
--- a/Tests/Qt4Targets/main_gen_test.cpp
+++ b/Tests/Qt4Targets/main_gen_test.cpp
@@ -8,10 +8,13 @@ class MyObject : public QObject, MyInterface
   Q_OBJECT
   Q_INTERFACES(MyInterface)
 public:
-  explicit MyObject(QObject *parent = 0) : QObject(parent) { }
+  explicit MyObject(QObject* parent = 0)
+    : QObject(parent)
+  {
+  }
 };
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   MyObject mo;
   mo.objectName();
diff --git a/Tests/Qt4Targets/main_wrap_test.cpp b/Tests/Qt4Targets/main_wrap_test.cpp
index 21edc7b..7b74849 100644
--- a/Tests/Qt4Targets/main_wrap_test.cpp
+++ b/Tests/Qt4Targets/main_wrap_test.cpp
@@ -3,7 +3,7 @@
 
 #include "mywrapobject.h"
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   MyWrapObject mwo;
   mwo.objectName();
diff --git a/Tests/Qt4Targets/mywrapobject.h b/Tests/Qt4Targets/mywrapobject.h
index de23540..5d4e52a 100644
--- a/Tests/Qt4Targets/mywrapobject.h
+++ b/Tests/Qt4Targets/mywrapobject.h
@@ -11,7 +11,10 @@ class MyWrapObject : public QObject, MyInterface
   Q_OBJECT
   Q_INTERFACES(MyInterface)
 public:
-  explicit MyWrapObject(QObject *parent = 0) : QObject(parent) { }
+  explicit MyWrapObject(QObject* parent = 0)
+    : QObject(parent)
+  {
+  }
 };
 
 #endif
diff --git a/Tests/QtAutoUicInterface/klocalizedstring.cpp b/Tests/QtAutoUicInterface/klocalizedstring.cpp
index f2324bb..b629cd1 100644
--- a/Tests/QtAutoUicInterface/klocalizedstring.cpp
+++ b/Tests/QtAutoUicInterface/klocalizedstring.cpp
@@ -1,12 +1,12 @@
 
 #include "klocalizedstring.h"
 
-QString tr2xi18n(const char *text, const char *)
+QString tr2xi18n(const char* text, const char*)
 {
   return QLatin1String("TranslatedX") + QString::fromLatin1(text);
 }
 
-QString tr2i18n(const char *text, const char *)
+QString tr2i18n(const char* text, const char*)
 {
   return QLatin1String("Translated") + QString::fromLatin1(text);
 }
diff --git a/Tests/QtAutoUicInterface/klocalizedstring.h b/Tests/QtAutoUicInterface/klocalizedstring.h
index 559058f..6129599 100644
--- a/Tests/QtAutoUicInterface/klocalizedstring.h
+++ b/Tests/QtAutoUicInterface/klocalizedstring.h
@@ -7,11 +7,11 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-QString tr2xi18n(const char *text, const char *comment = 0);
+  QString tr2xi18n(const char* text, const char* comment = 0);
 
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-QString tr2i18n(const char *text, const char *comment = 0);
+  QString tr2i18n(const char* text, const char* comment = 0);
 
 #endif
diff --git a/Tests/QtAutoUicInterface/libwidget.cpp b/Tests/QtAutoUicInterface/libwidget.cpp
index 8a921b3..b25f3d7 100644
--- a/Tests/QtAutoUicInterface/libwidget.cpp
+++ b/Tests/QtAutoUicInterface/libwidget.cpp
@@ -1,9 +1,9 @@
 
 #include "libwidget.h"
 
-LibWidget::LibWidget(QWidget *parent)
-  : QWidget(parent),
-    ui(new Ui::LibWidget)
+LibWidget::LibWidget(QWidget* parent)
+  : QWidget(parent)
+  , ui(new Ui::LibWidget)
 {
   ui->setupUi(this);
 }
diff --git a/Tests/QtAutoUicInterface/libwidget.h b/Tests/QtAutoUicInterface/libwidget.h
index 8b592ec..a4400d2 100644
--- a/Tests/QtAutoUicInterface/libwidget.h
+++ b/Tests/QtAutoUicInterface/libwidget.h
@@ -15,7 +15,7 @@ class LibWidget : public QWidget
 {
   Q_OBJECT
 public:
-  explicit LibWidget(QWidget *parent = 0);
+  explicit LibWidget(QWidget* parent = 0);
 
 private:
   const std::auto_ptr<Ui::LibWidget> ui;
diff --git a/Tests/QtAutoUicInterface/main.cpp b/Tests/QtAutoUicInterface/main.cpp
index 42d5958..68bd843 100644
--- a/Tests/QtAutoUicInterface/main.cpp
+++ b/Tests/QtAutoUicInterface/main.cpp
@@ -3,70 +3,62 @@
 #include <iostream>
 #include <string>
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   std::ifstream f;
   f.open(UI_LIBWIDGET_H);
-  if (!f.is_open())
-    {
+  if (!f.is_open()) {
     std::cout << "Could not open \"" UI_LIBWIDGET_H "\"." << std::endl;
     return -1;
-    }
+  }
 
   {
-  bool gotTr2i18n = false;
+    bool gotTr2i18n = false;
 
-  while (!f.eof())
-    {
-    std::string output;
-    getline(f, output);
-    if (!gotTr2i18n)
-      {
-      gotTr2i18n = output.find("tr2i18n") != std::string::npos;
+    while (!f.eof()) {
+      std::string output;
+      getline(f, output);
+      if (!gotTr2i18n) {
+        gotTr2i18n = output.find("tr2i18n") != std::string::npos;
       }
-    if (output.find("tr2xi18n") != std::string::npos)
-      {
-      std::cout << "ui_libwidget,h uses tr2xi18n, though it should not." << std::endl;
-      return -1;
+      if (output.find("tr2xi18n") != std::string::npos) {
+        std::cout << "ui_libwidget,h uses tr2xi18n, though it should not."
+                  << std::endl;
+        return -1;
       }
     }
 
-  if (!gotTr2i18n)
-    {
-    std::cout << "Did not find tr2i18n in ui_libwidget.h" << std::endl;
-    return -1;
+    if (!gotTr2i18n) {
+      std::cout << "Did not find tr2i18n in ui_libwidget.h" << std::endl;
+      return -1;
     }
   }
 
   f.close();
   f.open(UI_MYWIDGET_H);
-  if (!f.is_open())
-    {
+  if (!f.is_open()) {
     std::cout << "Could not open \"" UI_MYWIDGET_H "\"." << std::endl;
     return -1;
-    }
+  }
 
   {
-  bool gotTr2xi18n = false;
+    bool gotTr2xi18n = false;
 
-  while (!f.eof())
-    {
-    std::string output;
-    getline(f, output);
-    if (!gotTr2xi18n)
-      {
-      gotTr2xi18n = output.find("tr2xi18n") != std::string::npos;
+    while (!f.eof()) {
+      std::string output;
+      getline(f, output);
+      if (!gotTr2xi18n) {
+        gotTr2xi18n = output.find("tr2xi18n") != std::string::npos;
       }
-    if (output.find("tr2i18n") != std::string::npos)
-      {
-      std::cout << "ui_mywidget,h uses tr2i18n, though it should not." << std::endl;
-      return -1;
+      if (output.find("tr2i18n") != std::string::npos) {
+        std::cout << "ui_mywidget,h uses tr2i18n, though it should not."
+                  << std::endl;
+        return -1;
       }
     }
-  if (!gotTr2xi18n)
-    {
-    std::cout << "Did not find tr2xi18n in ui_mywidget.h" << std::endl;
-    return -1;
+    if (!gotTr2xi18n) {
+      std::cout << "Did not find tr2xi18n in ui_mywidget.h" << std::endl;
+      return -1;
     }
   }
   f.close();
diff --git a/Tests/QtAutoUicInterface/mywidget.cpp b/Tests/QtAutoUicInterface/mywidget.cpp
index b528b1a..885165b 100644
--- a/Tests/QtAutoUicInterface/mywidget.cpp
+++ b/Tests/QtAutoUicInterface/mywidget.cpp
@@ -1,9 +1,9 @@
 
 #include "mywidget.h"
 
-MyWidget::MyWidget(QWidget *parent)
-  : QWidget(parent),
-    ui(new Ui::MyWidget)
+MyWidget::MyWidget(QWidget* parent)
+  : QWidget(parent)
+  , ui(new Ui::MyWidget)
 {
   ui->setupUi(this);
 }
diff --git a/Tests/QtAutoUicInterface/mywidget.h b/Tests/QtAutoUicInterface/mywidget.h
index c96fb98..fc49e80 100644
--- a/Tests/QtAutoUicInterface/mywidget.h
+++ b/Tests/QtAutoUicInterface/mywidget.h
@@ -15,7 +15,7 @@ class MyWidget : public QWidget
 {
   Q_OBJECT
 public:
-  explicit MyWidget(QWidget *parent = 0);
+  explicit MyWidget(QWidget* parent = 0);
 
 private:
   const std::auto_ptr<Ui::MyWidget> ui;
diff --git a/Tests/QtAutogen/Adir/libA.cpp b/Tests/QtAutogen/Adir/libA.cpp
index 3968c44..f79f24a 100644
--- a/Tests/QtAutogen/Adir/libA.cpp
+++ b/Tests/QtAutogen/Adir/libA.cpp
@@ -1,10 +1,9 @@
 
 #include "libA.h"
 
-LibA::LibA(QObject *parent)
+LibA::LibA(QObject* parent)
   : QObject(parent)
 {
-
 }
 
 int LibA::foo()
diff --git a/Tests/QtAutogen/Adir/libA.h b/Tests/QtAutogen/Adir/libA.h
index 03ad1e0..c4eb9f7 100644
--- a/Tests/QtAutogen/Adir/libA.h
+++ b/Tests/QtAutogen/Adir/libA.h
@@ -10,7 +10,7 @@ class LIBA_EXPORT LibA : public QObject
 {
   Q_OBJECT
 public:
-  explicit LibA(QObject *parent = 0);
+  explicit LibA(QObject* parent = 0);
 
   int foo();
 };
diff --git a/Tests/QtAutogen/Bdir/libB.cpp b/Tests/QtAutogen/Bdir/libB.cpp
index 72f2cfa..d3b6753 100644
--- a/Tests/QtAutogen/Bdir/libB.cpp
+++ b/Tests/QtAutogen/Bdir/libB.cpp
@@ -1,10 +1,9 @@
 
 #include "libB.h"
 
-LibB::LibB(QObject *parent)
+LibB::LibB(QObject* parent)
   : QObject(parent)
 {
-
 }
 
 int LibB::foo()
diff --git a/Tests/QtAutogen/Bdir/libB.h b/Tests/QtAutogen/Bdir/libB.h
index 510c17f..e4ab788 100644
--- a/Tests/QtAutogen/Bdir/libB.h
+++ b/Tests/QtAutogen/Bdir/libB.h
@@ -4,16 +4,17 @@
 
 #include "libb_export.h"
 
-#include <QObject>
 #include "libA.h"
+#include <QObject>
 
 class LIBB_EXPORT LibB : public QObject
 {
   Q_OBJECT
 public:
-  explicit LibB(QObject *parent = 0);
+  explicit LibB(QObject* parent = 0);
 
   int foo();
+
 private:
   LibA a;
 };
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index d5aca55..4875165 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -110,6 +110,10 @@ set_target_properties(
   AUTOMOC TRUE
 )
 
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+add_subdirectory(same_name)
+
 include(GenerateExportHeader)
 # The order is relevant here. B depends on A, and B headers depend on A
 # headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
diff --git a/Tests/QtAutogen/abc.cpp b/Tests/QtAutogen/abc.cpp
index 4bbc769..b19c2a1 100644
--- a/Tests/QtAutogen/abc.cpp
+++ b/Tests/QtAutogen/abc.cpp
@@ -11,7 +11,6 @@
   See the License for more information.
 ============================================================================*/
 
-
 #include "abc.h"
 #include "abc_p.h"
 
@@ -20,18 +19,20 @@
 class PrintAbc : public QObject
 {
   Q_OBJECT
-  public:
-    PrintAbc():QObject() {}
-  public slots:
-    void print() const { printf("abc\n"); }
+public:
+  PrintAbc()
+    : QObject()
+  {
+  }
+public slots:
+  void print() const { printf("abc\n"); }
 };
 
 Abc::Abc()
-:QObject()
+  : QObject()
 {
 }
 
-
 void Abc::doAbc()
 {
   PrintAbc pa;
diff --git a/Tests/QtAutogen/abc.h b/Tests/QtAutogen/abc.h
index d1924b0..dc085b1 100644
--- a/Tests/QtAutogen/abc.h
+++ b/Tests/QtAutogen/abc.h
@@ -19,10 +19,10 @@
 class Abc : public QObject
 {
   Q_OBJECT
-  public:
-    Abc();
-  public slots:
-    void doAbc();
+public:
+  Abc();
+public slots:
+  void doAbc();
 };
 
 #endif
diff --git a/Tests/QtAutogen/abc_p.h b/Tests/QtAutogen/abc_p.h
index 952fff3..c9139b7 100644
--- a/Tests/QtAutogen/abc_p.h
+++ b/Tests/QtAutogen/abc_p.h
@@ -21,10 +21,10 @@
 class AbcP : public QObject
 {
   Q_OBJECT
-  public:
-    AbcP() {}
-  public slots:
-    void doAbcP() { printf("I am private abc !\n"); }
+public:
+  AbcP() {}
+public slots:
+  void doAbcP() { printf("I am private abc !\n"); }
 };
 
 #endif
diff --git a/Tests/QtAutogen/bar.cpp b/Tests/QtAutogen/bar.cpp
index 8be4815..2eefd08 100644
--- a/Tests/QtAutogen/bar.cpp
+++ b/Tests/QtAutogen/bar.cpp
@@ -16,7 +16,7 @@
 #include <stdio.h>
 
 Bar::Bar()
-:QObject()
+  : QObject()
 {
 }
 
diff --git a/Tests/QtAutogen/blub.cpp b/Tests/QtAutogen/blub.cpp
index bd53972..bbebf08 100644
--- a/Tests/QtAutogen/blub.cpp
+++ b/Tests/QtAutogen/blub.cpp
@@ -18,17 +18,19 @@
 class BlubBlub : public QObject
 {
   Q_OBJECT
-  public:
-    BlubBlub():QObject() {}
-  public slots:
-    int getValue() const { return 13; }
+public:
+  BlubBlub()
+    : QObject()
+  {
+  }
+public slots:
+  int getValue() const { return 13; }
 };
 
 Blub::Blub()
 {
 }
 
-
 void Blub::blubber()
 {
   BlubBlub bb;
diff --git a/Tests/QtAutogen/blub.h b/Tests/QtAutogen/blub.h
index 1967bc1..7097b67 100644
--- a/Tests/QtAutogen/blub.h
+++ b/Tests/QtAutogen/blub.h
@@ -18,9 +18,9 @@
 
 class Blub
 {
-  public:
-    Blub();
-    void blubber();
+public:
+  Blub();
+  void blubber();
 };
 
 #endif
diff --git a/Tests/QtAutogen/calwidget.cpp b/Tests/QtAutogen/calwidget.cpp
index 5f59994..380e982 100644
--- a/Tests/QtAutogen/calwidget.cpp
+++ b/Tests/QtAutogen/calwidget.cpp
@@ -38,400 +38,399 @@
  **
  ****************************************************************************/
 
- #include <QComboBox>
- #include <QGridLayout>
- #include <QLabel>
- #include <QGroupBox>
- #include <QCheckBox>
- #include <QDateEdit>
- #include <QCalendarWidget>
- #include <QTextCharFormat>
-
- #include "calwidget.h"
-
- #include "ui_calwidget.h"
- #ifdef UI_CALWIDGET_H
- #error Definition of UI_CALWIDGET_H should be disabled by file option.
- #endif
-
- Window::Window()
+#include <QCalendarWidget>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDateEdit>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QLabel>
+#include <QTextCharFormat>
+
+#include "calwidget.h"
+
+#include "ui_calwidget.h"
+#ifdef UI_CALWIDGET_H
+#error Definition of UI_CALWIDGET_H should be disabled by file option.
+#endif
+
+Window::Window()
   : ui(new Ui::Window)
- {
-     createPreviewGroupBox();
-     createGeneralOptionsGroupBox();
-     createDatesGroupBox();
-     createTextFormatsGroupBox();
-
-     QGridLayout *layout = new QGridLayout;
-     layout->addWidget(previewGroupBox, 0, 0);
-     layout->addWidget(generalOptionsGroupBox, 0, 1);
-     layout->addWidget(datesGroupBox, 1, 0);
-     layout->addWidget(textFormatsGroupBox, 1, 1);
-     layout->setSizeConstraint(QLayout::SetFixedSize);
-     setLayout(layout);
-
-     previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height());
-     previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width());
-
-     setWindowTitle(tr("Calendar Widget"));
- }
-
- void Window::localeChanged(int index)
- {
-     calendar->setLocale(localeCombo->itemData(index).toLocale());
- }
-
- void Window::firstDayChanged(int index)
- {
-     calendar->setFirstDayOfWeek(Qt::DayOfWeek(
-                                 firstDayCombo->itemData(index).toInt()));
- }
-
- void Window::selectionModeChanged(int index)
- {
-     calendar->setSelectionMode(QCalendarWidget::SelectionMode(
-                                selectionModeCombo->itemData(index).toInt()));
- }
-
- void Window::horizontalHeaderChanged(int index)
- {
-     calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat(
-         horizontalHeaderCombo->itemData(index).toInt()));
- }
-
- void Window::verticalHeaderChanged(int index)
- {
-     calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat(
-         verticalHeaderCombo->itemData(index).toInt()));
- }
-
- void Window::selectedDateChanged()
- {
-     currentDateEdit->setDate(calendar->selectedDate());
- }
-
- void Window::minimumDateChanged(const QDate &date)
- {
-     calendar->setMinimumDate(date);
-     maximumDateEdit->setDate(calendar->maximumDate());
- }
-
- void Window::maximumDateChanged(const QDate &date)
- {
-     calendar->setMaximumDate(date);
-     minimumDateEdit->setDate(calendar->minimumDate());
- }
-
- void Window::weekdayFormatChanged()
- {
-     QTextCharFormat format;
-
-     format.setForeground(qvariant_cast<QColor>(
-         weekdayColorCombo->itemData(weekdayColorCombo->currentIndex())));
-     calendar->setWeekdayTextFormat(Qt::Monday, format);
-     calendar->setWeekdayTextFormat(Qt::Tuesday, format);
-     calendar->setWeekdayTextFormat(Qt::Wednesday, format);
-     calendar->setWeekdayTextFormat(Qt::Thursday, format);
-     calendar->setWeekdayTextFormat(Qt::Friday, format);
- }
-
- void Window::weekendFormatChanged()
- {
-     QTextCharFormat format;
-
-     format.setForeground(qvariant_cast<QColor>(
-         weekendColorCombo->itemData(weekendColorCombo->currentIndex())));
-     calendar->setWeekdayTextFormat(Qt::Saturday, format);
-     calendar->setWeekdayTextFormat(Qt::Sunday, format);
- }
-
- void Window::reformatHeaders()
- {
-     QString text = headerTextFormatCombo->currentText();
-     QTextCharFormat format;
-
-     if (text == tr("Bold")) {
-         format.setFontWeight(QFont::Bold);
-     } else if (text == tr("Italic")) {
-         format.setFontItalic(true);
-     } else if (text == tr("Green")) {
-         format.setForeground(Qt::green);
-     }
-     calendar->setHeaderTextFormat(format);
- }
-
- void Window::reformatCalendarPage()
- {
-     if (firstFridayCheckBox->isChecked()) {
-         QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1);
-         while (firstFriday.dayOfWeek() != Qt::Friday)
-             firstFriday = firstFriday.addDays(1);
-         QTextCharFormat firstFridayFormat;
-         firstFridayFormat.setForeground(Qt::blue);
-         calendar->setDateTextFormat(firstFriday, firstFridayFormat);
-     }
-
-     //May First in Red takes precedence
-     if (mayFirstCheckBox->isChecked()) {
-         const QDate mayFirst(calendar->yearShown(), 5, 1);
-         QTextCharFormat mayFirstFormat;
-         mayFirstFormat.setForeground(Qt::red);
-         calendar->setDateTextFormat(mayFirst, mayFirstFormat);
-     }
- }
-
- void Window::createPreviewGroupBox()
- {
-     previewGroupBox = new QGroupBox(tr("Preview"));
-
-     calendar = new QCalendarWidget;
-     calendar->setMinimumDate(QDate(1900, 1, 1));
-     calendar->setMaximumDate(QDate(3000, 1, 1));
-     calendar->setGridVisible(true);
-
-     connect(calendar, SIGNAL(currentPageChanged(int,int)),
-             this, SLOT(reformatCalendarPage()));
-
-     previewLayout = new QGridLayout;
-     previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter);
-     previewGroupBox->setLayout(previewLayout);
- }
-
- void Window::createGeneralOptionsGroupBox()
- {
-     generalOptionsGroupBox = new QGroupBox(tr("General Options"));
-
-     localeCombo = new QComboBox;
-     int curLocaleIndex = -1;
-     int index = 0;
-     for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
-         QLocale::Language lang = static_cast<QLocale::Language>(_lang);
-         QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
-         for (int i = 0; i < countries.count(); ++i) {
-             QLocale::Country country = countries.at(i);
-             QString label = QLocale::languageToString(lang);
-             label += QLatin1Char('/');
-             label += QLocale::countryToString(country);
-             QLocale locale(lang, country);
-             if (this->locale().language() == lang && this->locale().country() == country)
-                 curLocaleIndex = index;
-             localeCombo->addItem(label, locale);
-             ++index;
-         }
-     }
-     if (curLocaleIndex != -1)
-         localeCombo->setCurrentIndex(curLocaleIndex);
-     localeLabel = new QLabel(tr("&Locale"));
-     localeLabel->setBuddy(localeCombo);
-
-     firstDayCombo = new QComboBox;
-     firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);
-     firstDayCombo->addItem(tr("Monday"), Qt::Monday);
-     firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
-     firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
-     firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
-     firstDayCombo->addItem(tr("Friday"), Qt::Friday);
-     firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);
-
-     firstDayLabel = new QLabel(tr("Wee&k starts on:"));
-     firstDayLabel->setBuddy(firstDayCombo);
-
-     selectionModeCombo = new QComboBox;
-     selectionModeCombo->addItem(tr("Single selection"),
-                                 QCalendarWidget::SingleSelection);
-     selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);
-
-     selectionModeLabel = new QLabel(tr("&Selection mode:"));
-     selectionModeLabel->setBuddy(selectionModeCombo);
-
-     gridCheckBox = new QCheckBox(tr("&Grid"));
-     gridCheckBox->setChecked(calendar->isGridVisible());
-
-     navigationCheckBox = new QCheckBox(tr("&Navigation bar"));
-     navigationCheckBox->setChecked(true);
-
-     horizontalHeaderCombo = new QComboBox;
-     horizontalHeaderCombo->addItem(tr("Single letter day names"),
-                                    QCalendarWidget::SingleLetterDayNames);
-     horizontalHeaderCombo->addItem(tr("Short day names"),
-                                    QCalendarWidget::ShortDayNames);
-     horizontalHeaderCombo->addItem(tr("None"),
-                                    QCalendarWidget::NoHorizontalHeader);
-     horizontalHeaderCombo->setCurrentIndex(1);
-
-     horizontalHeaderLabel = new QLabel(tr("&Horizontal header:"));
-     horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);
-
-     verticalHeaderCombo = new QComboBox;
-     verticalHeaderCombo->addItem(tr("ISO week numbers"),
-                                  QCalendarWidget::ISOWeekNumbers);
-     verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);
-
-     verticalHeaderLabel = new QLabel(tr("&Vertical header:"));
-     verticalHeaderLabel->setBuddy(verticalHeaderCombo);
-
-     connect(localeCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(localeChanged(int)));
-     connect(firstDayCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(firstDayChanged(int)));
-     connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(selectionModeChanged(int)));
-     connect(gridCheckBox, SIGNAL(toggled(bool)),
-             calendar, SLOT(setGridVisible(bool)));
-     connect(navigationCheckBox, SIGNAL(toggled(bool)),
-             calendar, SLOT(setNavigationBarVisible(bool)));
-     connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(horizontalHeaderChanged(int)));
-     connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(verticalHeaderChanged(int)));
-
-     QHBoxLayout *checkBoxLayout = new QHBoxLayout;
-     checkBoxLayout->addWidget(gridCheckBox);
-     checkBoxLayout->addStretch();
-     checkBoxLayout->addWidget(navigationCheckBox);
-
-     QGridLayout *outerLayout = new QGridLayout;
-     outerLayout->addWidget(localeLabel, 0, 0);
-     outerLayout->addWidget(localeCombo, 0, 1);
-     outerLayout->addWidget(firstDayLabel, 1, 0);
-     outerLayout->addWidget(firstDayCombo, 1, 1);
-     outerLayout->addWidget(selectionModeLabel, 2, 0);
-     outerLayout->addWidget(selectionModeCombo, 2, 1);
-     outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
-     outerLayout->addWidget(horizontalHeaderLabel, 4, 0);
-     outerLayout->addWidget(horizontalHeaderCombo, 4, 1);
-     outerLayout->addWidget(verticalHeaderLabel, 5, 0);
-     outerLayout->addWidget(verticalHeaderCombo, 5, 1);
-     generalOptionsGroupBox->setLayout(outerLayout);
-
-     firstDayChanged(firstDayCombo->currentIndex());
-     selectionModeChanged(selectionModeCombo->currentIndex());
-     horizontalHeaderChanged(horizontalHeaderCombo->currentIndex());
-     verticalHeaderChanged(verticalHeaderCombo->currentIndex());
- }
-
- void Window::createDatesGroupBox()
- {
-     datesGroupBox = new QGroupBox(tr("Dates"));
-
-     minimumDateEdit = new QDateEdit;
-     minimumDateEdit->setDisplayFormat("MMM d yyyy");
-     minimumDateEdit->setDateRange(calendar->minimumDate(),
-                                   calendar->maximumDate());
-     minimumDateEdit->setDate(calendar->minimumDate());
-
-     minimumDateLabel = new QLabel(tr("&Minimum Date:"));
-     minimumDateLabel->setBuddy(minimumDateEdit);
-
-     currentDateEdit = new QDateEdit;
-     currentDateEdit->setDisplayFormat("MMM d yyyy");
-     currentDateEdit->setDate(calendar->selectedDate());
-     currentDateEdit->setDateRange(calendar->minimumDate(),
-                                   calendar->maximumDate());
-
-     currentDateLabel = new QLabel(tr("&Current Date:"));
-     currentDateLabel->setBuddy(currentDateEdit);
-
-     maximumDateEdit = new QDateEdit;
-     maximumDateEdit->setDisplayFormat("MMM d yyyy");
-     maximumDateEdit->setDateRange(calendar->minimumDate(),
-                                   calendar->maximumDate());
-     maximumDateEdit->setDate(calendar->maximumDate());
-
-     maximumDateLabel = new QLabel(tr("Ma&ximum Date:"));
-     maximumDateLabel->setBuddy(maximumDateEdit);
-
-     connect(currentDateEdit, SIGNAL(dateChanged(QDate)),
-             calendar, SLOT(setSelectedDate(QDate)));
-     connect(calendar, SIGNAL(selectionChanged()),
-             this, SLOT(selectedDateChanged()));
-     connect(minimumDateEdit, SIGNAL(dateChanged(QDate)),
-             this, SLOT(minimumDateChanged(QDate)));
-     connect(maximumDateEdit, SIGNAL(dateChanged(QDate)),
-             this, SLOT(maximumDateChanged(QDate)));
-
-     QGridLayout *dateBoxLayout = new QGridLayout;
-     dateBoxLayout->addWidget(currentDateLabel, 1, 0);
-     dateBoxLayout->addWidget(currentDateEdit, 1, 1);
-     dateBoxLayout->addWidget(minimumDateLabel, 0, 0);
-     dateBoxLayout->addWidget(minimumDateEdit, 0, 1);
-     dateBoxLayout->addWidget(maximumDateLabel, 2, 0);
-     dateBoxLayout->addWidget(maximumDateEdit, 2, 1);
-     dateBoxLayout->setRowStretch(3, 1);
-
-     datesGroupBox->setLayout(dateBoxLayout);
- }
-
- void Window::createTextFormatsGroupBox()
- {
-     textFormatsGroupBox = new QGroupBox(tr("Text Formats"));
-
-     weekdayColorCombo = createColorComboBox();
-     weekdayColorCombo->setCurrentIndex(
-             weekdayColorCombo->findText(tr("Black")));
-
-     weekdayColorLabel = new QLabel(tr("&Weekday color:"));
-     weekdayColorLabel->setBuddy(weekdayColorCombo);
-
-     weekendColorCombo = createColorComboBox();
-     weekendColorCombo->setCurrentIndex(
-             weekendColorCombo->findText(tr("Red")));
-
-     weekendColorLabel = new QLabel(tr("Week&end color:"));
-     weekendColorLabel->setBuddy(weekendColorCombo);
-
-     headerTextFormatCombo = new QComboBox;
-     headerTextFormatCombo->addItem(tr("Bold"));
-     headerTextFormatCombo->addItem(tr("Italic"));
-     headerTextFormatCombo->addItem(tr("Plain"));
-
-     headerTextFormatLabel = new QLabel(tr("&Header text:"));
-     headerTextFormatLabel->setBuddy(headerTextFormatCombo);
-
-     firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue"));
-
-     mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));
-
-     connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(weekdayFormatChanged()));
-     connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)),
-             this, SLOT(weekendFormatChanged()));
-     connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)),
-             this, SLOT(reformatHeaders()));
-     connect(firstFridayCheckBox, SIGNAL(toggled(bool)),
-             this, SLOT(reformatCalendarPage()));
-     connect(mayFirstCheckBox, SIGNAL(toggled(bool)),
-             this, SLOT(reformatCalendarPage()));
-
-     QHBoxLayout *checkBoxLayout = new QHBoxLayout;
-     checkBoxLayout->addWidget(firstFridayCheckBox);
-     checkBoxLayout->addStretch();
-     checkBoxLayout->addWidget(mayFirstCheckBox);
-
-     QGridLayout *outerLayout = new QGridLayout;
-     outerLayout->addWidget(weekdayColorLabel, 0, 0);
-     outerLayout->addWidget(weekdayColorCombo, 0, 1);
-     outerLayout->addWidget(weekendColorLabel, 1, 0);
-     outerLayout->addWidget(weekendColorCombo, 1, 1);
-     outerLayout->addWidget(headerTextFormatLabel, 2, 0);
-     outerLayout->addWidget(headerTextFormatCombo, 2, 1);
-     outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
-     textFormatsGroupBox->setLayout(outerLayout);
-
-     weekdayFormatChanged();
-     weekendFormatChanged();
-     reformatHeaders();
-     reformatCalendarPage();
- }
-
-QComboBox *Window::createColorComboBox()
- {
-     QComboBox *comboBox = new QComboBox;
-     comboBox->addItem(tr("Red"), QColor(Qt::red));
-     comboBox->addItem(tr("Blue"), QColor(Qt::blue));
-     comboBox->addItem(tr("Black"), QColor(Qt::black));
-     comboBox->addItem(tr("Magenta"), QColor(Qt::magenta));
-     return comboBox;
- }
+{
+  createPreviewGroupBox();
+  createGeneralOptionsGroupBox();
+  createDatesGroupBox();
+  createTextFormatsGroupBox();
+
+  QGridLayout* layout = new QGridLayout;
+  layout->addWidget(previewGroupBox, 0, 0);
+  layout->addWidget(generalOptionsGroupBox, 0, 1);
+  layout->addWidget(datesGroupBox, 1, 0);
+  layout->addWidget(textFormatsGroupBox, 1, 1);
+  layout->setSizeConstraint(QLayout::SetFixedSize);
+  setLayout(layout);
+
+  previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height());
+  previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width());
+
+  setWindowTitle(tr("Calendar Widget"));
+}
+
+void Window::localeChanged(int index)
+{
+  calendar->setLocale(localeCombo->itemData(index).toLocale());
+}
+
+void Window::firstDayChanged(int index)
+{
+  calendar->setFirstDayOfWeek(
+    Qt::DayOfWeek(firstDayCombo->itemData(index).toInt()));
+}
+
+void Window::selectionModeChanged(int index)
+{
+  calendar->setSelectionMode(QCalendarWidget::SelectionMode(
+    selectionModeCombo->itemData(index).toInt()));
+}
+
+void Window::horizontalHeaderChanged(int index)
+{
+  calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat(
+    horizontalHeaderCombo->itemData(index).toInt()));
+}
+
+void Window::verticalHeaderChanged(int index)
+{
+  calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat(
+    verticalHeaderCombo->itemData(index).toInt()));
+}
+
+void Window::selectedDateChanged()
+{
+  currentDateEdit->setDate(calendar->selectedDate());
+}
+
+void Window::minimumDateChanged(const QDate& date)
+{
+  calendar->setMinimumDate(date);
+  maximumDateEdit->setDate(calendar->maximumDate());
+}
+
+void Window::maximumDateChanged(const QDate& date)
+{
+  calendar->setMaximumDate(date);
+  minimumDateEdit->setDate(calendar->minimumDate());
+}
+
+void Window::weekdayFormatChanged()
+{
+  QTextCharFormat format;
+
+  format.setForeground(qvariant_cast<QColor>(
+    weekdayColorCombo->itemData(weekdayColorCombo->currentIndex())));
+  calendar->setWeekdayTextFormat(Qt::Monday, format);
+  calendar->setWeekdayTextFormat(Qt::Tuesday, format);
+  calendar->setWeekdayTextFormat(Qt::Wednesday, format);
+  calendar->setWeekdayTextFormat(Qt::Thursday, format);
+  calendar->setWeekdayTextFormat(Qt::Friday, format);
+}
+
+void Window::weekendFormatChanged()
+{
+  QTextCharFormat format;
+
+  format.setForeground(qvariant_cast<QColor>(
+    weekendColorCombo->itemData(weekendColorCombo->currentIndex())));
+  calendar->setWeekdayTextFormat(Qt::Saturday, format);
+  calendar->setWeekdayTextFormat(Qt::Sunday, format);
+}
+
+void Window::reformatHeaders()
+{
+  QString text = headerTextFormatCombo->currentText();
+  QTextCharFormat format;
+
+  if (text == tr("Bold")) {
+    format.setFontWeight(QFont::Bold);
+  } else if (text == tr("Italic")) {
+    format.setFontItalic(true);
+  } else if (text == tr("Green")) {
+    format.setForeground(Qt::green);
+  }
+  calendar->setHeaderTextFormat(format);
+}
+
+void Window::reformatCalendarPage()
+{
+  if (firstFridayCheckBox->isChecked()) {
+    QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1);
+    while (firstFriday.dayOfWeek() != Qt::Friday)
+      firstFriday = firstFriday.addDays(1);
+    QTextCharFormat firstFridayFormat;
+    firstFridayFormat.setForeground(Qt::blue);
+    calendar->setDateTextFormat(firstFriday, firstFridayFormat);
+  }
+
+  // May First in Red takes precedence
+  if (mayFirstCheckBox->isChecked()) {
+    const QDate mayFirst(calendar->yearShown(), 5, 1);
+    QTextCharFormat mayFirstFormat;
+    mayFirstFormat.setForeground(Qt::red);
+    calendar->setDateTextFormat(mayFirst, mayFirstFormat);
+  }
+}
+
+void Window::createPreviewGroupBox()
+{
+  previewGroupBox = new QGroupBox(tr("Preview"));
+
+  calendar = new QCalendarWidget;
+  calendar->setMinimumDate(QDate(1900, 1, 1));
+  calendar->setMaximumDate(QDate(3000, 1, 1));
+  calendar->setGridVisible(true);
+
+  connect(calendar, SIGNAL(currentPageChanged(int, int)), this,
+          SLOT(reformatCalendarPage()));
+
+  previewLayout = new QGridLayout;
+  previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter);
+  previewGroupBox->setLayout(previewLayout);
+}
+
+void Window::createGeneralOptionsGroupBox()
+{
+  generalOptionsGroupBox = new QGroupBox(tr("General Options"));
+
+  localeCombo = new QComboBox;
+  int curLocaleIndex = -1;
+  int index = 0;
+  for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
+    QLocale::Language lang = static_cast<QLocale::Language>(_lang);
+    QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
+    for (int i = 0; i < countries.count(); ++i) {
+      QLocale::Country country = countries.at(i);
+      QString label = QLocale::languageToString(lang);
+      label += QLatin1Char('/');
+      label += QLocale::countryToString(country);
+      QLocale locale(lang, country);
+      if (this->locale().language() == lang &&
+          this->locale().country() == country)
+        curLocaleIndex = index;
+      localeCombo->addItem(label, locale);
+      ++index;
+    }
+  }
+  if (curLocaleIndex != -1)
+    localeCombo->setCurrentIndex(curLocaleIndex);
+  localeLabel = new QLabel(tr("&Locale"));
+  localeLabel->setBuddy(localeCombo);
+
+  firstDayCombo = new QComboBox;
+  firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);
+  firstDayCombo->addItem(tr("Monday"), Qt::Monday);
+  firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
+  firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
+  firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
+  firstDayCombo->addItem(tr("Friday"), Qt::Friday);
+  firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);
+
+  firstDayLabel = new QLabel(tr("Wee&k starts on:"));
+  firstDayLabel->setBuddy(firstDayCombo);
+
+  selectionModeCombo = new QComboBox;
+  selectionModeCombo->addItem(tr("Single selection"),
+                              QCalendarWidget::SingleSelection);
+  selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);
+
+  selectionModeLabel = new QLabel(tr("&Selection mode:"));
+  selectionModeLabel->setBuddy(selectionModeCombo);
+
+  gridCheckBox = new QCheckBox(tr("&Grid"));
+  gridCheckBox->setChecked(calendar->isGridVisible());
+
+  navigationCheckBox = new QCheckBox(tr("&Navigation bar"));
+  navigationCheckBox->setChecked(true);
+
+  horizontalHeaderCombo = new QComboBox;
+  horizontalHeaderCombo->addItem(tr("Single letter day names"),
+                                 QCalendarWidget::SingleLetterDayNames);
+  horizontalHeaderCombo->addItem(tr("Short day names"),
+                                 QCalendarWidget::ShortDayNames);
+  horizontalHeaderCombo->addItem(tr("None"),
+                                 QCalendarWidget::NoHorizontalHeader);
+  horizontalHeaderCombo->setCurrentIndex(1);
+
+  horizontalHeaderLabel = new QLabel(tr("&Horizontal header:"));
+  horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);
+
+  verticalHeaderCombo = new QComboBox;
+  verticalHeaderCombo->addItem(tr("ISO week numbers"),
+                               QCalendarWidget::ISOWeekNumbers);
+  verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);
+
+  verticalHeaderLabel = new QLabel(tr("&Vertical header:"));
+  verticalHeaderLabel->setBuddy(verticalHeaderCombo);
+
+  connect(localeCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(localeChanged(int)));
+  connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(firstDayChanged(int)));
+  connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(selectionModeChanged(int)));
+  connect(gridCheckBox, SIGNAL(toggled(bool)), calendar,
+          SLOT(setGridVisible(bool)));
+  connect(navigationCheckBox, SIGNAL(toggled(bool)), calendar,
+          SLOT(setNavigationBarVisible(bool)));
+  connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(horizontalHeaderChanged(int)));
+  connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(verticalHeaderChanged(int)));
+
+  QHBoxLayout* checkBoxLayout = new QHBoxLayout;
+  checkBoxLayout->addWidget(gridCheckBox);
+  checkBoxLayout->addStretch();
+  checkBoxLayout->addWidget(navigationCheckBox);
+
+  QGridLayout* outerLayout = new QGridLayout;
+  outerLayout->addWidget(localeLabel, 0, 0);
+  outerLayout->addWidget(localeCombo, 0, 1);
+  outerLayout->addWidget(firstDayLabel, 1, 0);
+  outerLayout->addWidget(firstDayCombo, 1, 1);
+  outerLayout->addWidget(selectionModeLabel, 2, 0);
+  outerLayout->addWidget(selectionModeCombo, 2, 1);
+  outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
+  outerLayout->addWidget(horizontalHeaderLabel, 4, 0);
+  outerLayout->addWidget(horizontalHeaderCombo, 4, 1);
+  outerLayout->addWidget(verticalHeaderLabel, 5, 0);
+  outerLayout->addWidget(verticalHeaderCombo, 5, 1);
+  generalOptionsGroupBox->setLayout(outerLayout);
+
+  firstDayChanged(firstDayCombo->currentIndex());
+  selectionModeChanged(selectionModeCombo->currentIndex());
+  horizontalHeaderChanged(horizontalHeaderCombo->currentIndex());
+  verticalHeaderChanged(verticalHeaderCombo->currentIndex());
+}
+
+void Window::createDatesGroupBox()
+{
+  datesGroupBox = new QGroupBox(tr("Dates"));
+
+  minimumDateEdit = new QDateEdit;
+  minimumDateEdit->setDisplayFormat("MMM d yyyy");
+  minimumDateEdit->setDateRange(calendar->minimumDate(),
+                                calendar->maximumDate());
+  minimumDateEdit->setDate(calendar->minimumDate());
+
+  minimumDateLabel = new QLabel(tr("&Minimum Date:"));
+  minimumDateLabel->setBuddy(minimumDateEdit);
+
+  currentDateEdit = new QDateEdit;
+  currentDateEdit->setDisplayFormat("MMM d yyyy");
+  currentDateEdit->setDate(calendar->selectedDate());
+  currentDateEdit->setDateRange(calendar->minimumDate(),
+                                calendar->maximumDate());
+
+  currentDateLabel = new QLabel(tr("&Current Date:"));
+  currentDateLabel->setBuddy(currentDateEdit);
+
+  maximumDateEdit = new QDateEdit;
+  maximumDateEdit->setDisplayFormat("MMM d yyyy");
+  maximumDateEdit->setDateRange(calendar->minimumDate(),
+                                calendar->maximumDate());
+  maximumDateEdit->setDate(calendar->maximumDate());
+
+  maximumDateLabel = new QLabel(tr("Ma&ximum Date:"));
+  maximumDateLabel->setBuddy(maximumDateEdit);
+
+  connect(currentDateEdit, SIGNAL(dateChanged(QDate)), calendar,
+          SLOT(setSelectedDate(QDate)));
+  connect(calendar, SIGNAL(selectionChanged()), this,
+          SLOT(selectedDateChanged()));
+  connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), this,
+          SLOT(minimumDateChanged(QDate)));
+  connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), this,
+          SLOT(maximumDateChanged(QDate)));
+
+  QGridLayout* dateBoxLayout = new QGridLayout;
+  dateBoxLayout->addWidget(currentDateLabel, 1, 0);
+  dateBoxLayout->addWidget(currentDateEdit, 1, 1);
+  dateBoxLayout->addWidget(minimumDateLabel, 0, 0);
+  dateBoxLayout->addWidget(minimumDateEdit, 0, 1);
+  dateBoxLayout->addWidget(maximumDateLabel, 2, 0);
+  dateBoxLayout->addWidget(maximumDateEdit, 2, 1);
+  dateBoxLayout->setRowStretch(3, 1);
+
+  datesGroupBox->setLayout(dateBoxLayout);
+}
+
+void Window::createTextFormatsGroupBox()
+{
+  textFormatsGroupBox = new QGroupBox(tr("Text Formats"));
+
+  weekdayColorCombo = createColorComboBox();
+  weekdayColorCombo->setCurrentIndex(weekdayColorCombo->findText(tr("Black")));
+
+  weekdayColorLabel = new QLabel(tr("&Weekday color:"));
+  weekdayColorLabel->setBuddy(weekdayColorCombo);
+
+  weekendColorCombo = createColorComboBox();
+  weekendColorCombo->setCurrentIndex(weekendColorCombo->findText(tr("Red")));
+
+  weekendColorLabel = new QLabel(tr("Week&end color:"));
+  weekendColorLabel->setBuddy(weekendColorCombo);
+
+  headerTextFormatCombo = new QComboBox;
+  headerTextFormatCombo->addItem(tr("Bold"));
+  headerTextFormatCombo->addItem(tr("Italic"));
+  headerTextFormatCombo->addItem(tr("Plain"));
+
+  headerTextFormatLabel = new QLabel(tr("&Header text:"));
+  headerTextFormatLabel->setBuddy(headerTextFormatCombo);
+
+  firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue"));
+
+  mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));
+
+  connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(weekdayFormatChanged()));
+  connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(weekendFormatChanged()));
+  connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), this,
+          SLOT(reformatHeaders()));
+  connect(firstFridayCheckBox, SIGNAL(toggled(bool)), this,
+          SLOT(reformatCalendarPage()));
+  connect(mayFirstCheckBox, SIGNAL(toggled(bool)), this,
+          SLOT(reformatCalendarPage()));
+
+  QHBoxLayout* checkBoxLayout = new QHBoxLayout;
+  checkBoxLayout->addWidget(firstFridayCheckBox);
+  checkBoxLayout->addStretch();
+  checkBoxLayout->addWidget(mayFirstCheckBox);
+
+  QGridLayout* outerLayout = new QGridLayout;
+  outerLayout->addWidget(weekdayColorLabel, 0, 0);
+  outerLayout->addWidget(weekdayColorCombo, 0, 1);
+  outerLayout->addWidget(weekendColorLabel, 1, 0);
+  outerLayout->addWidget(weekendColorCombo, 1, 1);
+  outerLayout->addWidget(headerTextFormatLabel, 2, 0);
+  outerLayout->addWidget(headerTextFormatCombo, 2, 1);
+  outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
+  textFormatsGroupBox->setLayout(outerLayout);
+
+  weekdayFormatChanged();
+  weekendFormatChanged();
+  reformatHeaders();
+  reformatCalendarPage();
+}
+
+QComboBox* Window::createColorComboBox()
+{
+  QComboBox* comboBox = new QComboBox;
+  comboBox->addItem(tr("Red"), QColor(Qt::red));
+  comboBox->addItem(tr("Blue"), QColor(Qt::blue));
+  comboBox->addItem(tr("Black"), QColor(Qt::black));
+  comboBox->addItem(tr("Magenta"), QColor(Qt::magenta));
+  return comboBox;
+}
 
 //#include "moc_calwidget.cpp"
diff --git a/Tests/QtAutogen/calwidget.h b/Tests/QtAutogen/calwidget.h
index d21a473..084d959 100644
--- a/Tests/QtAutogen/calwidget.h
+++ b/Tests/QtAutogen/calwidget.h
@@ -1,128 +1,127 @@
- /****************************************************************************
- **
- ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info at nokia.com)
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- **   * Redistributions of source code must retain the above copyright
- **     notice, this list of conditions and the following disclaimer.
- **   * 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.
- **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
- **     the names of its contributors may be used to endorse or promote
- **     products derived from this software without specific prior written
- **     permission.
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
- ** OWNER 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."
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info at nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * 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.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+** OWNER 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
 
 #ifndef WINDOW_H
 #define WINDOW_H
 
 #include <QWidget>
 
- class QCalendarWidget;
- class QCheckBox;
- class QComboBox;
- class QDate;
- class QDateEdit;
- class QGridLayout;
- class QGroupBox;
- class QLabel;
+class QCalendarWidget;
+class QCheckBox;
+class QComboBox;
+class QDate;
+class QDateEdit;
+class QGridLayout;
+class QGroupBox;
+class QLabel;
 
- namespace Ui
- {
- class Window;
- }
+namespace Ui {
+class Window;
+}
 
- class Window : public QWidget
- {
-     Q_OBJECT
+class Window : public QWidget
+{
+  Q_OBJECT
 
- public:
-     Window();
+public:
+  Window();
 
- private slots:
-     void localeChanged(int index);
-     void firstDayChanged(int index);
-     void selectionModeChanged(int index);
-     void horizontalHeaderChanged(int index);
-     void verticalHeaderChanged(int index);
-     void selectedDateChanged();
-     void minimumDateChanged(const QDate &date);
-     void maximumDateChanged(const QDate &date);
-     void weekdayFormatChanged();
-     void weekendFormatChanged();
-     void reformatHeaders();
-     void reformatCalendarPage();
+private slots:
+  void localeChanged(int index);
+  void firstDayChanged(int index);
+  void selectionModeChanged(int index);
+  void horizontalHeaderChanged(int index);
+  void verticalHeaderChanged(int index);
+  void selectedDateChanged();
+  void minimumDateChanged(const QDate& date);
+  void maximumDateChanged(const QDate& date);
+  void weekdayFormatChanged();
+  void weekendFormatChanged();
+  void reformatHeaders();
+  void reformatCalendarPage();
 
- private:
-     void createPreviewGroupBox();
-     void createGeneralOptionsGroupBox();
-     void createDatesGroupBox();
-     void createTextFormatsGroupBox();
-     QComboBox *createColorComboBox();
+private:
+  void createPreviewGroupBox();
+  void createGeneralOptionsGroupBox();
+  void createDatesGroupBox();
+  void createTextFormatsGroupBox();
+  QComboBox* createColorComboBox();
 
-     QGroupBox *previewGroupBox;
-     QGridLayout *previewLayout;
-     QCalendarWidget *calendar;
+  QGroupBox* previewGroupBox;
+  QGridLayout* previewLayout;
+  QCalendarWidget* calendar;
 
-     QGroupBox *generalOptionsGroupBox;
-     QLabel *localeLabel;
-     QLabel *firstDayLabel;
-     QLabel *selectionModeLabel;
-     QLabel *horizontalHeaderLabel;
-     QLabel *verticalHeaderLabel;
-     QComboBox *localeCombo;
-     QComboBox *firstDayCombo;
-     QComboBox *selectionModeCombo;
-     QCheckBox *gridCheckBox;
-     QCheckBox *navigationCheckBox;
-     QComboBox *horizontalHeaderCombo;
-     QComboBox *verticalHeaderCombo;
+  QGroupBox* generalOptionsGroupBox;
+  QLabel* localeLabel;
+  QLabel* firstDayLabel;
+  QLabel* selectionModeLabel;
+  QLabel* horizontalHeaderLabel;
+  QLabel* verticalHeaderLabel;
+  QComboBox* localeCombo;
+  QComboBox* firstDayCombo;
+  QComboBox* selectionModeCombo;
+  QCheckBox* gridCheckBox;
+  QCheckBox* navigationCheckBox;
+  QComboBox* horizontalHeaderCombo;
+  QComboBox* verticalHeaderCombo;
 
-     QGroupBox *datesGroupBox;
-     QLabel *currentDateLabel;
-     QLabel *minimumDateLabel;
-     QLabel *maximumDateLabel;
-     QDateEdit *currentDateEdit;
-     QDateEdit *minimumDateEdit;
-     QDateEdit *maximumDateEdit;
+  QGroupBox* datesGroupBox;
+  QLabel* currentDateLabel;
+  QLabel* minimumDateLabel;
+  QLabel* maximumDateLabel;
+  QDateEdit* currentDateEdit;
+  QDateEdit* minimumDateEdit;
+  QDateEdit* maximumDateEdit;
 
-     QGroupBox *textFormatsGroupBox;
-     QLabel *weekdayColorLabel;
-     QLabel *weekendColorLabel;
-     QLabel *headerTextFormatLabel;
-     QComboBox *weekdayColorCombo;
-     QComboBox *weekendColorCombo;
-     QComboBox *headerTextFormatCombo;
+  QGroupBox* textFormatsGroupBox;
+  QLabel* weekdayColorLabel;
+  QLabel* weekendColorLabel;
+  QLabel* headerTextFormatLabel;
+  QComboBox* weekdayColorCombo;
+  QComboBox* weekendColorCombo;
+  QComboBox* headerTextFormatCombo;
 
-     QCheckBox *firstFridayCheckBox;
-     QCheckBox *mayFirstCheckBox;
+  QCheckBox* firstFridayCheckBox;
+  QCheckBox* mayFirstCheckBox;
 
-     Ui::Window *ui;
- };
+  Ui::Window* ui;
+};
 
- #endif
+#endif
diff --git a/Tests/QtAutogen/codeeditor.cpp b/Tests/QtAutogen/codeeditor.cpp
index 01da062..0caf8a7 100644
--- a/Tests/QtAutogen/codeeditor.cpp
+++ b/Tests/QtAutogen/codeeditor.cpp
@@ -38,116 +38,109 @@
  **
  ****************************************************************************/
 
- #include <QtGui>
-
- #include "codeeditor.h"
-
-
- CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
- {
-     lineNumberArea = new LineNumberArea(this);
-
-     connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
-     connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
-     connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
-
-     updateLineNumberAreaWidth(0);
-     highlightCurrentLine();
- }
-
-
-
- int CodeEditor::lineNumberAreaWidth()
- {
-     int digits = 1;
-     int max = qMax(1, blockCount());
-     while (max >= 10) {
-         max /= 10;
-         ++digits;
-     }
-
-     int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
-
-     return space;
- }
-
-
-
- void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
- {
-     setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
- }
-
-
-
- void CodeEditor::updateLineNumberArea(const QRect &rect, int dy)
- {
-     if (dy)
-         lineNumberArea->scroll(0, dy);
-     else
-         lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
-
-     if (rect.contains(viewport()->rect()))
-         updateLineNumberAreaWidth(0);
- }
-
-
-
- void CodeEditor::resizeEvent(QResizeEvent *e)
- {
-     QPlainTextEdit::resizeEvent(e);
-
-     QRect cr = contentsRect();
-     lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
- }
-
-
-
- void CodeEditor::highlightCurrentLine()
- {
-     QList<QTextEdit::ExtraSelection> extraSelections;
-
-     if (!isReadOnly()) {
-         QTextEdit::ExtraSelection selection;
-
-         QColor lineColor = QColor(Qt::yellow).lighter(160);
-
-         selection.format.setBackground(lineColor);
-         selection.format.setProperty(QTextFormat::FullWidthSelection, true);
-         selection.cursor = textCursor();
-         selection.cursor.clearSelection();
-         extraSelections.append(selection);
-     }
-
-     setExtraSelections(extraSelections);
- }
-
-
-
- void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
- {
-     QPainter painter(lineNumberArea);
-     painter.fillRect(event->rect(), Qt::lightGray);
-
-
-     QTextBlock block = firstVisibleBlock();
-     int blockNumber = block.blockNumber();
-     int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
-     int bottom = top + (int) blockBoundingRect(block).height();
-
-     while (block.isValid() && top <= event->rect().bottom()) {
-         if (block.isVisible() && bottom >= event->rect().top()) {
-             QString number = QString::number(blockNumber + 1);
-             painter.setPen(Qt::black);
-             painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
-                              Qt::AlignRight, number);
-         }
-
-         block = block.next();
-         top = bottom;
-         bottom = top + (int) blockBoundingRect(block).height();
-         ++blockNumber;
-     }
- }
+#include <QtGui>
+
+#include "codeeditor.h"
+
+CodeEditor::CodeEditor(QWidget* parent)
+  : QPlainTextEdit(parent)
+{
+  lineNumberArea = new LineNumberArea(this);
+
+  connect(this, SIGNAL(blockCountChanged(int)), this,
+          SLOT(updateLineNumberAreaWidth(int)));
+  connect(this, SIGNAL(updateRequest(QRect, int)), this,
+          SLOT(updateLineNumberArea(QRect, int)));
+  connect(this, SIGNAL(cursorPositionChanged()), this,
+          SLOT(highlightCurrentLine()));
+
+  updateLineNumberAreaWidth(0);
+  highlightCurrentLine();
+}
+
+int CodeEditor::lineNumberAreaWidth()
+{
+  int digits = 1;
+  int max = qMax(1, blockCount());
+  while (max >= 10) {
+    max /= 10;
+    ++digits;
+  }
+
+  int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
+
+  return space;
+}
+
+void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
+{
+  setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
+}
+
+void CodeEditor::updateLineNumberArea(const QRect& rect, int dy)
+{
+  if (dy)
+    lineNumberArea->scroll(0, dy);
+  else
+    lineNumberArea->update(0, rect.y(), lineNumberArea->width(),
+                           rect.height());
+
+  if (rect.contains(viewport()->rect()))
+    updateLineNumberAreaWidth(0);
+}
+
+void CodeEditor::resizeEvent(QResizeEvent* e)
+{
+  QPlainTextEdit::resizeEvent(e);
+
+  QRect cr = contentsRect();
+  lineNumberArea->setGeometry(
+    QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
+}
+
+void CodeEditor::highlightCurrentLine()
+{
+  QList<QTextEdit::ExtraSelection> extraSelections;
+
+  if (!isReadOnly()) {
+    QTextEdit::ExtraSelection selection;
+
+    QColor lineColor = QColor(Qt::yellow).lighter(160);
+
+    selection.format.setBackground(lineColor);
+    selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+    selection.cursor = textCursor();
+    selection.cursor.clearSelection();
+    extraSelections.append(selection);
+  }
+
+  setExtraSelections(extraSelections);
+}
+
+void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event)
+{
+  QPainter painter(lineNumberArea);
+  painter.fillRect(event->rect(), Qt::lightGray);
+
+  QTextBlock block = firstVisibleBlock();
+  int blockNumber = block.blockNumber();
+  int top =
+    (int)blockBoundingGeometry(block).translated(contentOffset()).top();
+  int bottom = top + (int)blockBoundingRect(block).height();
+
+  while (block.isValid() && top <= event->rect().bottom()) {
+    if (block.isVisible() && bottom >= event->rect().top()) {
+      QString number = QString::number(blockNumber + 1);
+      painter.setPen(Qt::black);
+      painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
+                       Qt::AlignRight, number);
+    }
+
+    block = block.next();
+    top = bottom;
+    bottom = top + (int)blockBoundingRect(block).height();
+    ++blockNumber;
+  }
+}
 
 #include "codeeditor.moc"
diff --git a/Tests/QtAutogen/codeeditor.h b/Tests/QtAutogen/codeeditor.h
index 56e9e79..b410bd4 100644
--- a/Tests/QtAutogen/codeeditor.h
+++ b/Tests/QtAutogen/codeeditor.h
@@ -1,99 +1,100 @@
- /****************************************************************************
- **
- ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info at nokia.com)
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- **   * Redistributions of source code must retain the above copyright
- **     notice, this list of conditions and the following disclaimer.
- **   * 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.
- **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
- **     the names of its contributors may be used to endorse or promote
- **     products derived from this software without specific prior written
- **     permission.
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
- ** OWNER 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."
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
- #ifndef CODEEDITOR_H
- #define CODEEDITOR_H
-
- #include <QPlainTextEdit>
- #include <QObject>
-
- class QPaintEvent;
- class QResizeEvent;
- class QSize;
- class QWidget;
-
- class LineNumberArea;
-
-
- class CodeEditor : public QPlainTextEdit
- {
-     Q_OBJECT
-
- public:
-     CodeEditor(QWidget *parent = 0);
-
-     void lineNumberAreaPaintEvent(QPaintEvent *event);
-     int lineNumberAreaWidth();
-
- protected:
-     void resizeEvent(QResizeEvent *event);
-
- private slots:
-     void updateLineNumberAreaWidth(int newBlockCount);
-     void highlightCurrentLine();
-     void updateLineNumberArea(const QRect &, int);
-
- private:
-     QWidget *lineNumberArea;
- };
-
-
- class LineNumberArea : public QWidget
- {
- public:
-     LineNumberArea(CodeEditor *editor) : QWidget(editor) {
-         codeEditor = editor;
-     }
-
-     QSize sizeHint() const {
-         return QSize(codeEditor->lineNumberAreaWidth(), 0);
-     }
-
- protected:
-     void paintEvent(QPaintEvent *event) {
-         codeEditor->lineNumberAreaPaintEvent(event);
-     }
-
- private:
-     CodeEditor *codeEditor;
- };
-
-
- #endif
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info at nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * 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.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+** OWNER 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CODEEDITOR_H
+#define CODEEDITOR_H
+
+#include <QObject>
+#include <QPlainTextEdit>
+
+class QPaintEvent;
+class QResizeEvent;
+class QSize;
+class QWidget;
+
+class LineNumberArea;
+
+class CodeEditor : public QPlainTextEdit
+{
+  Q_OBJECT
+
+public:
+  CodeEditor(QWidget* parent = 0);
+
+  void lineNumberAreaPaintEvent(QPaintEvent* event);
+  int lineNumberAreaWidth();
+
+protected:
+  void resizeEvent(QResizeEvent* event);
+
+private slots:
+  void updateLineNumberAreaWidth(int newBlockCount);
+  void highlightCurrentLine();
+  void updateLineNumberArea(const QRect&, int);
+
+private:
+  QWidget* lineNumberArea;
+};
+
+class LineNumberArea : public QWidget
+{
+public:
+  LineNumberArea(CodeEditor* editor)
+    : QWidget(editor)
+  {
+    codeEditor = editor;
+  }
+
+  QSize sizeHint() const
+  {
+    return QSize(codeEditor->lineNumberAreaWidth(), 0);
+  }
+
+protected:
+  void paintEvent(QPaintEvent* event)
+  {
+    codeEditor->lineNumberAreaPaintEvent(event);
+  }
+
+private:
+  CodeEditor* codeEditor;
+};
+
+#endif
diff --git a/Tests/QtAutogen/debug_class.cpp b/Tests/QtAutogen/debug_class.cpp
index 58e72e4..46b09e7 100644
--- a/Tests/QtAutogen/debug_class.cpp
+++ b/Tests/QtAutogen/debug_class.cpp
@@ -2,8 +2,9 @@
 #include "debug_class.h"
 #include "ui_debug_class.h"
 
-DebugClass::DebugClass(QWidget *parent)
-  : QWidget(parent), ui(new Ui::DebugClass)
+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
index 71bc104..c02f0ed 100644
--- a/Tests/QtAutogen/debug_class.h
+++ b/Tests/QtAutogen/debug_class.h
@@ -1,8 +1,7 @@
 
 #include <QWidget>
 
-namespace Ui
-{
+namespace Ui {
 class DebugClass;
 }
 
@@ -10,11 +9,11 @@ class DebugClass : public QWidget
 {
   Q_OBJECT
 public:
-  explicit DebugClass(QWidget *parent = 0);
+  explicit DebugClass(QWidget* parent = 0);
 
 signals:
   void someSignal();
 
 private:
-  Ui::DebugClass *ui;
+  Ui::DebugClass* ui;
 };
diff --git a/Tests/QtAutogen/defines_test/defines_test.cpp b/Tests/QtAutogen/defines_test/defines_test.cpp
index 2836d35..cf4e9cb 100644
--- a/Tests/QtAutogen/defines_test/defines_test.cpp
+++ b/Tests/QtAutogen/defines_test/defines_test.cpp
@@ -23,7 +23,7 @@ Q_SIGNALS:
 };
 #endif
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
 #ifdef QT_CORE_LIB
   QMetaObject sosmo = SomeObject::staticMetaObject;
diff --git a/Tests/QtAutogen/empty.h b/Tests/QtAutogen/empty.h
index 4566142..6bdd2ac 100644
--- a/Tests/QtAutogen/empty.h
+++ b/Tests/QtAutogen/empty.h
@@ -5,5 +5,5 @@ class Empty : public QObject
 {
   Q_OBJECT
 public:
-  explicit Empty(QObject *parent = 0) {}
+  explicit Empty(QObject* parent = 0) {}
 };
diff --git a/Tests/QtAutogen/foo.cpp b/Tests/QtAutogen/foo.cpp
index 699ba09..23ecc30 100644
--- a/Tests/QtAutogen/foo.cpp
+++ b/Tests/QtAutogen/foo.cpp
@@ -18,18 +18,20 @@
 class FooFoo : public QObject
 {
   Q_OBJECT
-  public:
-    FooFoo():QObject() {}
-  public slots:
-    int getValue() const { return 12; }
+public:
+  FooFoo()
+    : QObject()
+  {
+  }
+public slots:
+  int getValue() const { return 12; }
 };
 
 Foo::Foo()
-:QObject()
+  : QObject()
 {
 }
 
-
 void Foo::doFoo()
 {
   FooFoo ff;
diff --git a/Tests/QtAutogen/foo.h b/Tests/QtAutogen/foo.h
index f23ec07..98f6292 100644
--- a/Tests/QtAutogen/foo.h
+++ b/Tests/QtAutogen/foo.h
@@ -18,14 +18,14 @@
 
 class Foo
 #ifdef FOO
-          : public QObject
+  : public QObject
 #endif
 {
   Q_OBJECT
-  public:
-    Foo();
-  public slots:
-    void doFoo();
+public:
+  Foo();
+public slots:
+  void doFoo();
 };
 
 #endif
diff --git a/Tests/QtAutogen/gadget.h b/Tests/QtAutogen/gadget.h
index 7c688ee..3253e31 100644
--- a/Tests/QtAutogen/gadget.h
+++ b/Tests/QtAutogen/gadget.h
@@ -9,7 +9,8 @@ class Gadget
   Q_GADGET
   Q_ENUMS(Type)
 public:
-  enum Type {
+  enum Type
+  {
     Type0,
     Type1
   };
diff --git a/Tests/QtAutogen/generated.cpp b/Tests/QtAutogen/generated.cpp
index f53bf53..d514c61 100644
--- a/Tests/QtAutogen/generated.cpp
+++ b/Tests/QtAutogen/generated.cpp
@@ -1,10 +1,9 @@
 
 #include "generated.h"
 
-Generated::Generated(QObject *parent)
+Generated::Generated(QObject* parent)
   : QObject(parent)
 {
-
 }
 
 #include "moc_generated.cpp"
diff --git a/Tests/QtAutogen/generated.h b/Tests/QtAutogen/generated.h
index b6c2711..62e1607 100644
--- a/Tests/QtAutogen/generated.h
+++ b/Tests/QtAutogen/generated.h
@@ -12,7 +12,7 @@ class Generated : public QObject, MyInterface, MyOtherInterface
   Q_OBJECT
   Q_INTERFACES(MyInterface MyOtherInterface)
 public:
-  explicit Generated(QObject *parent = 0);
+  explicit Generated(QObject* parent = 0);
 };
 
 #endif
diff --git a/Tests/QtAutogen/libC.cpp b/Tests/QtAutogen/libC.cpp
index 8d61cb1..a3acff1 100644
--- a/Tests/QtAutogen/libC.cpp
+++ b/Tests/QtAutogen/libC.cpp
@@ -1,10 +1,9 @@
 
 #include "libC.h"
 
-LibC::LibC(QObject *parent)
+LibC::LibC(QObject* parent)
   : QObject(parent)
 {
-
 }
 
 int LibC::foo()
diff --git a/Tests/QtAutogen/libC.h b/Tests/QtAutogen/libC.h
index 4fb4a2c..3bc2bad 100644
--- a/Tests/QtAutogen/libC.h
+++ b/Tests/QtAutogen/libC.h
@@ -4,17 +4,17 @@
 
 #include "libc_export.h"
 
-#include <QObject>
 #include "libB.h"
+#include <QObject>
 
 class LIBC_EXPORT LibC : public QObject
 {
   Q_OBJECT
 public:
-  explicit LibC(QObject *parent = 0);
-
+  explicit LibC(QObject* parent = 0);
 
   int foo();
+
 private:
   LibB b;
 };
diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/main.cpp
index eb59665..d557c70 100644
--- a/Tests/QtAutogen/main.cpp
+++ b/Tests/QtAutogen/main.cpp
@@ -41,23 +41,22 @@
 #include <QCoreApplication>
 #include <QTimer>
 
-#include "codeeditor.h"
+#include "abc.h"
+#include "blub.h"
 #include "calwidget.h"
+#include "codeeditor.h"
 #include "foo.h"
-#include "blub.h"
+#include "libC.h"
+#include "resourcetester.h"
 #include "sub/bar.h"
-#include "abc.h"
 #include "xyz.h"
 #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)
+int main(int argv, char** args)
 {
   QCoreApplication app(argv, args);
 
diff --git a/Tests/QtAutogen/multiplewidgets.cpp b/Tests/QtAutogen/multiplewidgets.cpp
index f143875..fda36ea 100644
--- a/Tests/QtAutogen/multiplewidgets.cpp
+++ b/Tests/QtAutogen/multiplewidgets.cpp
@@ -4,16 +4,16 @@
 #include "ui_widget1.h"
 #include "ui_widget2.h"
 
-Widget1::Widget1(QWidget *parent)
-  : QWidget(parent),
-    ui(new Ui::Widget1)
+Widget1::Widget1(QWidget* parent)
+  : QWidget(parent)
+  , ui(new Ui::Widget1)
 {
   ui->setupUi(this);
 }
 
-Widget2::Widget2(QWidget *parent)
-  : QWidget(parent),
-    ui(new Ui::Widget2)
+Widget2::Widget2(QWidget* parent)
+  : QWidget(parent)
+  , ui(new Ui::Widget2)
 {
   ui->setupUi(this);
 }
diff --git a/Tests/QtAutogen/multiplewidgets.h b/Tests/QtAutogen/multiplewidgets.h
index 6ae6ad1..a4d0a50 100644
--- a/Tests/QtAutogen/multiplewidgets.h
+++ b/Tests/QtAutogen/multiplewidgets.h
@@ -12,9 +12,10 @@ class Widget1 : public QWidget
 {
   Q_OBJECT
 public:
-  Widget1(QWidget *parent = 0);
+  Widget1(QWidget* parent = 0);
+
 private:
-  Ui::Widget1 *ui;
+  Ui::Widget1* ui;
 };
 
 namespace Ui {
@@ -25,9 +26,10 @@ class Widget2 : public QWidget
 {
   Q_OBJECT
 public:
-  Widget2(QWidget *parent = 0);
+  Widget2(QWidget* parent = 0);
+
 private:
-  Ui::Widget2 *ui;
+  Ui::Widget2* ui;
 };
 
 #endif
diff --git a/Tests/QtAutogen/private_slot.cpp b/Tests/QtAutogen/private_slot.cpp
index 1387a70..ab1682a 100644
--- a/Tests/QtAutogen/private_slot.cpp
+++ b/Tests/QtAutogen/private_slot.cpp
@@ -4,18 +4,13 @@
 class PrivateSlotPrivate
 {
 public:
-
-  void privateSlot()
-  {
-
-  }
+  void privateSlot() {}
 };
 
-PrivateSlot::PrivateSlot(QObject *parent)
-  : QObject(parent),
-  d(new PrivateSlotPrivate)
+PrivateSlot::PrivateSlot(QObject* parent)
+  : QObject(parent)
+  , d(new PrivateSlotPrivate)
 {
-
 }
 
 #include "private_slot.moc"
diff --git a/Tests/QtAutogen/private_slot.h b/Tests/QtAutogen/private_slot.h
index 28e5448..8041eb2 100644
--- a/Tests/QtAutogen/private_slot.h
+++ b/Tests/QtAutogen/private_slot.h
@@ -10,10 +10,10 @@ class PrivateSlot : public QObject
 {
   Q_OBJECT
 public:
-  PrivateSlot(QObject *parent = 0);
+  PrivateSlot(QObject* parent = 0);
 
 private:
-  PrivateSlotPrivate * const d;
+  PrivateSlotPrivate* const d;
   Q_PRIVATE_SLOT(d, void privateSlot())
 };
 
diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp
index 043ec75..4ecb6b4 100644
--- a/Tests/QtAutogen/resourcetester.cpp
+++ b/Tests/QtAutogen/resourcetester.cpp
@@ -1,26 +1,25 @@
 
 #include "resourcetester.h"
 
-#include <QDebug>
 #include <QApplication>
+#include <QDebug>
 #include <QFile>
 #include <QTimer>
 
-ResourceTester::ResourceTester(QObject *parent)
+ResourceTester::ResourceTester(QObject* parent)
   : QObject(parent)
 {
-
 }
 
 void ResourceTester::doTest()
 {
   if (!QFile::exists(":/CMakeLists.txt"))
-      qApp->exit(EXIT_FAILURE);
+    qApp->exit(EXIT_FAILURE);
   if (!QFile::exists(":/main.cpp"))
-      qApp->exit(EXIT_FAILURE);
+    qApp->exit(EXIT_FAILURE);
 #ifdef TEST_DEBUG_CLASS
   if (!QFile::exists(":/debug_class.ui"))
-      qApp->exit(EXIT_FAILURE);
+    qApp->exit(EXIT_FAILURE);
 #endif
 
   QTimer::singleShot(0, qApp, SLOT(quit()));
diff --git a/Tests/QtAutogen/resourcetester.h b/Tests/QtAutogen/resourcetester.h
index b02cb4e..dbdb3ad 100644
--- a/Tests/QtAutogen/resourcetester.h
+++ b/Tests/QtAutogen/resourcetester.h
@@ -8,7 +8,7 @@ class ResourceTester : public QObject
 {
   Q_OBJECT
 public:
-  explicit ResourceTester(QObject *parent = 0);
+  explicit ResourceTester(QObject* parent = 0);
 
 private slots:
   void doTest();
diff --git a/Tests/QtAutogen/same_name/CMakeLists.txt b/Tests/QtAutogen/same_name/CMakeLists.txt
new file mode 100644
index 0000000..54bf048
--- /dev/null
+++ b/Tests/QtAutogen/same_name/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+
+add_executable(same_name
+  aaa/bbb/item.cpp
+  aaa/bbb/data.qrc
+  aaa/item.cpp
+  aaa/data.qrc
+  bbb/aaa/item.cpp
+  bbb/aaa/data.qrc
+  bbb/item.cpp
+  bbb/data.qrc
+  ccc/item.cpp
+  ccc/data.qrc
+  main.cpp
+  data.qrc
+)
+target_include_directories(same_name PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(same_name ${QT_LIBRARIES})
+set_target_properties( same_name PROPERTIES AUTOMOC TRUE AUTORCC TRUE )
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/data.qrc b/Tests/QtAutogen/same_name/aaa/bbb/data.qrc
new file mode 100644
index 0000000..0ea3537
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/bbb">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.cpp b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp
new file mode 100644
index 0000000..20d0044
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+namespace aaa {
+namespace bbb {
+
+void Item::go()
+{
+}
+}
+}
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.hpp b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp
new file mode 100644
index 0000000..87ac6ea
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp
@@ -0,0 +1,18 @@
+#ifndef SDA_SDB_ITEM_HPP
+#define SDA_SDB_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+namespace bbb {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go();
+};
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/aaa/data.qrc b/Tests/QtAutogen/same_name/aaa/data.qrc
new file mode 100644
index 0000000..379af60
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/aaa/item.cpp b/Tests/QtAutogen/same_name/aaa/item.cpp
new file mode 100644
index 0000000..95dd3b6
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/item.cpp
@@ -0,0 +1,8 @@
+#include "item.hpp"
+
+namespace aaa {
+
+void Item::go()
+{
+}
+}
diff --git a/Tests/QtAutogen/same_name/aaa/item.hpp b/Tests/QtAutogen/same_name/aaa/item.hpp
new file mode 100644
index 0000000..68476ce
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/item.hpp
@@ -0,0 +1,16 @@
+#ifndef SDA_ITEM_HPP
+#define SDA_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/data.qrc b/Tests/QtAutogen/same_name/bbb/aaa/data.qrc
new file mode 100644
index 0000000..da98009
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/aaa/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.cpp b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp
new file mode 100644
index 0000000..ac4b2c2
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+namespace bbb {
+namespace aaa {
+
+void Item::go()
+{
+}
+}
+}
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.hpp b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp
new file mode 100644
index 0000000..0a8e024
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp
@@ -0,0 +1,18 @@
+#ifndef SDB_SDA_ITEM_HPP
+#define SDB_SDA_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+namespace aaa {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go();
+};
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/bbb/data.qrc b/Tests/QtAutogen/same_name/bbb/data.qrc
new file mode 100644
index 0000000..5b080f5
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/bbb/item.cpp b/Tests/QtAutogen/same_name/bbb/item.cpp
new file mode 100644
index 0000000..f97a143
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/item.cpp
@@ -0,0 +1,8 @@
+#include "item.hpp"
+
+namespace bbb {
+
+void Item::go()
+{
+}
+}
diff --git a/Tests/QtAutogen/same_name/bbb/item.hpp b/Tests/QtAutogen/same_name/bbb/item.hpp
new file mode 100644
index 0000000..3da5837
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/item.hpp
@@ -0,0 +1,16 @@
+#ifndef SDB_ITEM_HPP
+#define SDB_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/ccc/data.qrc b/Tests/QtAutogen/same_name/ccc/data.qrc
new file mode 100644
index 0000000..f934c39
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="ccc/">
+  <file>item.hpp</file>
+  <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/ccc/item.cpp b/Tests/QtAutogen/same_name/ccc/item.cpp
new file mode 100644
index 0000000..d90b2b8
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/item.cpp
@@ -0,0 +1,23 @@
+#include "item.hpp"
+
+namespace ccc {
+
+void Item::go()
+{
+}
+
+class MocTest : public QObject
+{
+  Q_OBJECT;
+  Q_SLOT
+  void go();
+};
+
+void MocTest::go()
+{
+}
+}
+
+// Include own moc files
+#include "item.moc"
+#include "moc_item.cpp"
diff --git a/Tests/QtAutogen/same_name/ccc/item.hpp b/Tests/QtAutogen/same_name/ccc/item.hpp
new file mode 100644
index 0000000..c855936
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/item.hpp
@@ -0,0 +1,16 @@
+#ifndef SDC_ITEM_HPP
+#define SDC_ITEM_HPP
+
+#include <QObject>
+
+namespace ccc {
+
+class Item : public QObject
+{
+  Q_OBJECT
+  Q_SLOT
+  void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/data.qrc b/Tests/QtAutogen/same_name/data.qrc
new file mode 100644
index 0000000..4ce0b4e
--- /dev/null
+++ b/Tests/QtAutogen/same_name/data.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+  <file>main.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/main.cpp b/Tests/QtAutogen/same_name/main.cpp
new file mode 100644
index 0000000..a4ffcb3
--- /dev/null
+++ b/Tests/QtAutogen/same_name/main.cpp
@@ -0,0 +1,16 @@
+#include "aaa/bbb/item.hpp"
+#include "aaa/item.hpp"
+#include "bbb/aaa/item.hpp"
+#include "bbb/item.hpp"
+#include "ccc/item.hpp"
+
+int main(int argv, char** args)
+{
+  // Object instances
+  ::aaa::Item aaa_item;
+  ::aaa::bbb::Item aaa_bbb_item;
+  ::bbb::Item bbb_item;
+  ::bbb::aaa::Item bbb_aaa_item;
+  ::ccc::Item ccc_item;
+  return 0;
+}
diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/second_widget.cpp
index 65ba962..c575f10 100644
--- a/Tests/QtAutogen/second_widget.cpp
+++ b/Tests/QtAutogen/second_widget.cpp
@@ -2,8 +2,9 @@
 #include "second_widget.h"
 #include "ui_second_widget.h"
 
-SecondWidget::SecondWidget(QWidget *parent)
-  : QWidget(parent), ui(new Ui::SecondWidget)
+SecondWidget::SecondWidget(QWidget* parent)
+  : QWidget(parent)
+  , ui(new Ui::SecondWidget)
 {
   ui->setupUi(this);
 }
diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/second_widget.h
index fe4d175..c7929c4 100644
--- a/Tests/QtAutogen/second_widget.h
+++ b/Tests/QtAutogen/second_widget.h
@@ -1,8 +1,7 @@
 
 #include <QWidget>
 
-namespace Ui
-{
+namespace Ui {
 class SecondWidget;
 }
 
@@ -10,7 +9,7 @@ class SecondWidget : public QWidget
 {
   Q_OBJECT
 public:
-  explicit SecondWidget(QWidget *parent = 0);
+  explicit SecondWidget(QWidget* parent = 0);
 
   ~SecondWidget();
 
diff --git a/Tests/QtAutogen/sub/bar.h b/Tests/QtAutogen/sub/bar.h
index db56b8e..c96e123 100644
--- a/Tests/QtAutogen/sub/bar.h
+++ b/Tests/QtAutogen/sub/bar.h
@@ -19,10 +19,10 @@
 class Bar : public QObject
 {
   Q_OBJECT
-  public:
-    Bar();
-  public slots:
-    void doBar();
+public:
+  Bar();
+public slots:
+  void doBar();
 };
 
 #endif
diff --git a/Tests/QtAutogen/sub/uiconly.cpp b/Tests/QtAutogen/sub/uiconly.cpp
index cdb3318..ac22789 100644
--- a/Tests/QtAutogen/sub/uiconly.cpp
+++ b/Tests/QtAutogen/sub/uiconly.cpp
@@ -1,10 +1,10 @@
 
 #include "uiconly.h"
 
-UicOnly::UicOnly(QWidget *parent)
-  : QWidget(parent), ui(new Ui::UicOnly)
+UicOnly::UicOnly(QWidget* parent)
+  : QWidget(parent)
+  , ui(new Ui::UicOnly)
 {
-
 }
 
 int main()
diff --git a/Tests/QtAutogen/sub/uiconly.h b/Tests/QtAutogen/sub/uiconly.h
index 9e21f82..9b0b1b4 100644
--- a/Tests/QtAutogen/sub/uiconly.h
+++ b/Tests/QtAutogen/sub/uiconly.h
@@ -11,7 +11,7 @@ class UicOnly : public QWidget
 {
   Q_OBJECT
 public:
-  explicit UicOnly(QWidget *parent = 0);
+  explicit UicOnly(QWidget* parent = 0);
 
 private:
   const std::auto_ptr<Ui::UicOnly> ui;
diff --git a/Tests/QtAutogen/xyz.cpp b/Tests/QtAutogen/xyz.cpp
index a3562a3..c3c598e 100644
--- a/Tests/QtAutogen/xyz.cpp
+++ b/Tests/QtAutogen/xyz.cpp
@@ -11,17 +11,15 @@
   See the License for more information.
 ============================================================================*/
 
-
 #include "xyz.h"
 
 #include <stdio.h>
 
 Xyz::Xyz()
-:QObject()
+  : QObject()
 {
 }
 
-
 void Xyz::doXyz()
 {
   printf("This is xyz !\n");
diff --git a/Tests/QtAutogen/xyz.h b/Tests/QtAutogen/xyz.h
index 8175d37..1ba09a3 100644
--- a/Tests/QtAutogen/xyz.h
+++ b/Tests/QtAutogen/xyz.h
@@ -19,10 +19,10 @@
 class Xyz : public QObject
 {
   Q_OBJECT
-  public:
-    Xyz();
-  public slots:
-    void doXyz();
+public:
+  Xyz();
+public slots:
+  void doXyz();
 };
 
 #endif
diff --git a/Tests/QtAutogen/yaf.cpp b/Tests/QtAutogen/yaf.cpp
index d278ab4..09335a9 100644
--- a/Tests/QtAutogen/yaf.cpp
+++ b/Tests/QtAutogen/yaf.cpp
@@ -11,7 +11,6 @@
   See the License for more information.
 ============================================================================*/
 
-
 #include "yaf.h"
 #include "yaf_p.h"
 
@@ -21,7 +20,6 @@ Yaf::Yaf()
 {
 }
 
-
 void Yaf::doYaf()
 {
   YafP yafP;
diff --git a/Tests/QtAutogen/yaf.h b/Tests/QtAutogen/yaf.h
index 8689f83..9755ca0 100644
--- a/Tests/QtAutogen/yaf.h
+++ b/Tests/QtAutogen/yaf.h
@@ -16,10 +16,11 @@
 
 class Yaf
 {
-  public:
-    Yaf();
-  public:
-    void doYaf();
+public:
+  Yaf();
+
+public:
+  void doYaf();
 };
 
 #endif
diff --git a/Tests/QtAutogen/yaf_p.h b/Tests/QtAutogen/yaf_p.h
index f0368ad..cf317b8 100644
--- a/Tests/QtAutogen/yaf_p.h
+++ b/Tests/QtAutogen/yaf_p.h
@@ -21,10 +21,10 @@
 class YafP : public QObject
 {
   Q_OBJECT
-  public:
-    YafP() {}
-  public slots:
-    void doYafP() { printf("I am yet another file !\n"); }
+public:
+  YafP() {}
+public slots:
+  void doYafP() { printf("I am yet another file !\n"); }
 };
 
 #endif
diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
index 3784a6a..f268de7 100644
--- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
+++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
@@ -6,8 +6,8 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
 # configure the AutoExport test
 run_cmake(AutoExport)
 unset(RunCMake_TEST_OPTIONS)
-# don't run this test on VS 6 as it is not supported
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 6|Watcom WMake|Borland Makefiles")
+# don't run this test on Watcom or Borland make as it is not supported
+if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles")
   return()
 endif()
 # we build debug so the say.exe will be found in Debug/say.exe for
diff --git a/Tests/RunCMake/AutoExportDll/hello.cxx b/Tests/RunCMake/AutoExportDll/hello.cxx
index 3933fc1..533fd3e 100644
--- a/Tests/RunCMake/AutoExportDll/hello.cxx
+++ b/Tests/RunCMake/AutoExportDll/hello.cxx
@@ -1,5 +1,5 @@
-#include <stdio.h>
 #include "hello.h"
+#include <stdio.h>
 int Hello::Data = 0;
 void Hello::real()
 {
@@ -9,5 +9,5 @@ void hello()
 {
   printf("hello");
 }
-void Hello::operator delete[](void*) {};
-void Hello::operator delete(void*) {};
+void Hello::operator delete[](void*){};
+void Hello::operator delete(void*){};
diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx
index 655b3c2..0178688 100644
--- a/Tests/RunCMake/AutoExportDll/say.cxx
+++ b/Tests/RunCMake/AutoExportDll/say.cxx
@@ -1,17 +1,16 @@
-#include <stdio.h>
 #include "hello.h"
+#include <stdio.h>
 #ifdef _MSC_VER
 #include "windows.h"
 #else
 #define WINAPI
 #endif
 
-extern "C"
-{
+extern "C" {
 // test __cdecl stuff
-  int WINAPI foo();
+int WINAPI foo();
 // test regular C
-  int bar();
+int bar();
 }
 
 // test c++ functions
diff --git a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake
index 6948c35..687c827 100644
--- a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake
+++ b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake
@@ -10,6 +10,7 @@ add_custom_target(produce DEPENDS gen-byproduct)
 add_custom_command(
   OUTPUT use-byproduct
   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/byproduct
+  COMMAND ${CMAKE_COMMAND} -E sleep 1.125 # workaround buggy filesystem timestamps
   COMMAND ${CMAKE_COMMAND} -E touch use-byproduct
   )
 add_custom_target(drive ALL DEPENDS use-byproduct)
diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c
new file mode 100644
index 0000000..0795aaa
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c
@@ -0,0 +1,5 @@
+#include <MakeInProjectOnly.h>
+int main()
+{
+  return MakeInProjectOnly();
+}
diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake
new file mode 100644
index 0000000..add9aeb
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake
@@ -0,0 +1,16 @@
+enable_language(C)
+get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH)
+include_directories("${include_dir}")
+add_executable(MakeInProjectOnly MakeInProjectOnly.c)
+set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1)
+file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+if (check_step EQUAL 1)
+  set(check_pairs
+    \"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\"
+    )
+else()
+  set(check_pairs
+    \"${include_dir}/MakeInProjectOnly.h|\$<TARGET_FILE:MakeInProjectOnly>\"
+    )
+endif()
+")
diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake
new file mode 100644
index 0000000..d6551ab
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake
@@ -0,0 +1,3 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[
+int MakeInProjectOnly(void) { return 0; }
+]])
diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake
new file mode 100644
index 0000000..145605b
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake
@@ -0,0 +1,3 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[
+int MakeInProjectOnly(void) { return 1; }
+]])
diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
index 0dd27d4..ffd3ae1 100644
--- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
+++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
@@ -1,6 +1,7 @@
 include(RunCMake)
 
-if(RunCMake_GENERATOR STREQUAL "Borland Makefiles")
+if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR
+   RunCMake_GENERATOR STREQUAL "Watcom WMake")
   set(fs_delay 3)
 else()
   set(fs_delay 1.125)
@@ -30,7 +31,7 @@ function(run_BuildDepends CASE)
 endfunction()
 
 run_BuildDepends(C-Exe)
-if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode")
+if(NOT RunCMake_GENERATOR MATCHES "Visual Studio 7|Xcode")
   if(RunCMake_GENERATOR MATCHES "Visual Studio 10")
     # VS 10 forgets to re-link when a manifest changes
     set(run_BuildDepends_skip_step_2 1)
@@ -41,3 +42,47 @@ endif()
 
 run_BuildDepends(Custom-Symbolic-and-Byproduct)
 run_BuildDepends(Custom-Always)
+
+if(RunCMake_GENERATOR MATCHES "Make" AND
+   NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}")
+  run_BuildDepends(MakeInProjectOnly)
+endif()
+
+function(run_ReGeneration)
+  # test re-generation of project even if CMakeLists.txt files disappeared
+
+  # Use a single build tree for a few tests without cleaning.
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/regenerate-project-build)
+  set(RunCMake_TEST_SOURCE_DIR ${RunCMake_BINARY_DIR}/regenerate-project-source)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
+  set(ProjectHeader [=[
+    cmake_minimum_required(VERSION 3.5)
+    project(Regenerate-Project NONE)
+  ]=])
+
+  # create project with subdirectory
+  file(WRITE "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" "${ProjectHeader}"
+    "add_subdirectory(mysubdir)")
+  file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/mysubdir")
+  file(WRITE "${RunCMake_TEST_SOURCE_DIR}/mysubdir/CMakeLists.txt" "# empty")
+
+  run_cmake(Regenerate-Project)
+  execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay})
+
+  # now we delete the subdirectory and adjust the CMakeLists.txt
+  file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}/mysubdir")
+  file(WRITE "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" "${ProjectHeader}")
+
+  run_cmake_command(Regenerate-Project-Directory-Removed
+    ${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}")
+
+  unset(RunCMake_TEST_BINARY_DIR)
+  unset(RunCMake_TEST_SOURCE_DIR)
+  unset(RunCMake_TEST_NO_CLEAN)
+endfunction()
+
+if(RunCMake_GENERATOR STREQUAL "Xcode")
+  run_ReGeneration(regenerate-project)
+endif()
diff --git a/Tests/RunCMake/BuildDepends/main.c b/Tests/RunCMake/BuildDepends/main.c
index 78f2de1..8488f4e 100644
--- a/Tests/RunCMake/BuildDepends/main.c
+++ b/Tests/RunCMake/BuildDepends/main.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/CMP0022/empty.cpp b/Tests/RunCMake/CMP0022/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0022/empty.cpp
+++ b/Tests/RunCMake/CMP0022/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0026/empty.cpp b/Tests/RunCMake/CMP0026/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0026/empty.cpp
+++ b/Tests/RunCMake/CMP0026/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0037/empty.cpp b/Tests/RunCMake/CMP0037/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0037/empty.cpp
+++ b/Tests/RunCMake/CMP0037/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0038/empty.cpp b/Tests/RunCMake/CMP0038/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0038/empty.cpp
+++ b/Tests/RunCMake/CMP0038/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0040/empty.cpp b/Tests/RunCMake/CMP0040/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0040/empty.cpp
+++ b/Tests/RunCMake/CMP0040/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0041/empty.cpp b/Tests/RunCMake/CMP0041/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0041/empty.cpp
+++ b/Tests/RunCMake/CMP0041/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0042/empty.cpp b/Tests/RunCMake/CMP0042/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0042/empty.cpp
+++ b/Tests/RunCMake/CMP0042/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0043/empty.cpp b/Tests/RunCMake/CMP0043/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0043/empty.cpp
+++ b/Tests/RunCMake/CMP0043/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0045/empty.cpp b/Tests/RunCMake/CMP0045/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0045/empty.cpp
+++ b/Tests/RunCMake/CMP0045/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0046/empty.cpp b/Tests/RunCMake/CMP0046/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0046/empty.cpp
+++ b/Tests/RunCMake/CMP0046/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0049/empty.cpp b/Tests/RunCMake/CMP0049/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0049/empty.cpp
+++ b/Tests/RunCMake/CMP0049/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0050/empty.cpp b/Tests/RunCMake/CMP0050/empty.cpp
index 182ea29..bf7d5c9 100644
--- a/Tests/RunCMake/CMP0050/empty.cpp
+++ b/Tests/RunCMake/CMP0050/empty.cpp
@@ -4,7 +4,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0051/empty.cpp b/Tests/RunCMake/CMP0051/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CMP0051/empty.cpp
+++ b/Tests/RunCMake/CMP0051/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt b/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt
index 4e04d15..06c7be3 100644
--- a/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0059/CMP0059-WARN-stderr.txt
@@ -1,5 +1,5 @@
 CMake Warning \(dev\) at CMP0059-WARN.cmake:6 \(get_property\):
-  Policy CMP0059 is not set: Do no treat DEFINITIONS as a built-in directory
+  Policy CMP0059 is not set: Do not treat DEFINITIONS as a built-in directory
   property.  Run "cmake --help-policy CMP0059" for policy details.  Use the
   cmake_policy command to set the policy and suppress this warning.
 Call Stack \(most recent call first\):
@@ -8,7 +8,7 @@ This warning is for project developers.  Use -Wno-dev to suppress it.
 
 DEFS: -DSOME_DEF
 CMake Warning \(dev\) at CMP0059-WARN.cmake:14 \(get_property\):
-  Policy CMP0059 is not set: Do no treat DEFINITIONS as a built-in directory
+  Policy CMP0059 is not set: Do not treat DEFINITIONS as a built-in directory
   property.  Run "cmake --help-policy CMP0059" for policy details.  Use the
   cmake_policy command to set the policy and suppress this warning.
 Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/CMP0065/subproject/main.c b/Tests/RunCMake/CMP0065/subproject/main.c
index 98725db..2adf396 100644
--- a/Tests/RunCMake/CMP0065/subproject/main.c
+++ b/Tests/RunCMake/CMP0065/subproject/main.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   printf("Hello World\n");
   return 0;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 0a388c5..d16e5e7 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -152,6 +152,7 @@ add_RunCMake_test(ObjectLibrary)
 add_RunCMake_test(Swift)
 add_RunCMake_test(TargetObjects)
 add_RunCMake_test(TargetSources)
+add_RunCMake_test(ToolchainFile)
 add_RunCMake_test(find_dependency)
 add_RunCMake_test(CompileDefinitions)
 add_RunCMake_test(CompileFeatures)
@@ -216,6 +217,7 @@ add_RunCMake_test(alias_targets)
 add_RunCMake_test(interface_library)
 add_RunCMake_test(no_install_prefix)
 add_RunCMake_test(configure_file)
+add_RunCMake_test(CTestTimeoutAfterMatch)
 
 find_package(Qt4 QUIET)
 find_package(Qt5Core QUIET)
@@ -231,9 +233,16 @@ if(PKG_CONFIG_FOUND)
   add_RunCMake_test(FindPkgConfig)
 endif()
 
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]")
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
   add_RunCMake_test(include_external_msproject)
-  add_RunCMake_test(SolutionGlobalSections)
+  if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND)
+    set(NO_USE_FOLDERS 1)
+  endif()
+  add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS})
+endif()
+
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^789]|[789][0-9])")
+  add_RunCMake_test(VS10Project)
 endif()
 
 if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
@@ -280,8 +289,10 @@ if(CMake_TEST_FindMatlab)
 endif()
 
 add_executable(pseudo_emulator pseudo_emulator.c)
+add_executable(pseudo_emulator_custom_command pseudo_emulator_custom_command.c)
 add_RunCMake_test(CrosscompilingEmulator
- -DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator>)
+ -DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator>
+ -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command>)
 # 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]")
@@ -289,10 +300,16 @@ if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]"
     TARGET pseudo_emulator
     PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
     )
+  add_custom_command(
+    TARGET pseudo_emulator_custom_command
+    PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
+    )
 endif()
 
 if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
+  add_executable(pseudo_tidy pseudo_tidy.c)
   add_executable(pseudo_iwyu pseudo_iwyu.c)
+  add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>)
   add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>)
   add_RunCMake_test(CompilerLauncher)
 endif()
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp b/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
index 31a1337..766b775 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
+++ b/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
@@ -1,5 +1,5 @@
 
 int main()
 {
-    return 0;
+  return 0;
 }
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
index aef1086..7bf42f9 100644
--- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -9,6 +9,20 @@ function(run_cpack_test TEST_NAME types build)
     file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
     file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
 
+    if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
+      include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
+
+      set(FOUND_PREREQUIREMENTS false)
+      get_test_prerequirements("FOUND_PREREQUIREMENTS"
+          "${TEST_CONFIG_DIR}/${type}_config.cmake")
+
+      # skip the test if prerequirements are not met
+      if(NOT FOUND_PREREQUIREMENTS)
+        message(STATUS "${TEST_NAME} - SKIPPED")
+        return()
+      endif()
+    endif()
+
     # execute cmake
     set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}")
     run_cmake(${TEST_NAME})
diff --git a/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake b/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake
new file mode 100644
index 0000000..c89df89
--- /dev/null
+++ b/Tests/RunCMake/CPack/CUSTOM_NAMES.cmake
@@ -0,0 +1,7 @@
+set(CPACK_RPM_COMPONENT_INSTALL "ON")
+
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1)
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2)
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3)
+
+set(CPACK_PACKAGE_NAME "custom_names")
diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake
index 5adca68..62f2f9c 100644
--- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake
@@ -1,5 +1,5 @@
 set(whitespaces_ "[\t\n\r ]*")
 
 set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_1 "components_empty_dir*.deb")
+set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")
diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake
index 2720fe9..4b4ac8d 100644
--- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake
+++ b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-specifics.cmake
@@ -1,2 +1,3 @@
 set(CPACK_PACKAGE_CONTACT "someone")
 set(CPACK_DEB_COMPONENT_INSTALL "ON")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
diff --git a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake
new file mode 100644
index 0000000..2acf45b
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-ExpectedFiles.cmake
@@ -0,0 +1,9 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "3")
+set(EXPECTED_FILE_1 "custom_names-pkg_1_0.1.1-1_*.deb")
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
+set(EXPECTED_FILE_2 "second*.deb")
+set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
+set(EXPECTED_FILE_3 "pkg_3_abc.deb")
+set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake
new file mode 100644
index 0000000..c64f161
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/CUSTOM_NAMES-specifics.cmake
@@ -0,0 +1,6 @@
+set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEB_COMPONENT_INSTALL "ON")
+
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
+set(CPACK_DEBIAN_PKG_2_PACKAGE_NAME "second")
+set(CPACK_DEBIAN_PKG_3_FILE_NAME "pkg_3_abc.deb")
diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake
index 2ff679a..4531a34 100644
--- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake
@@ -1,9 +1,9 @@
 set(whitespaces_ "[\t\n\r ]*")
 
 set(EXPECTED_FILES_COUNT "3")
-set(EXPECTED_FILE_1 "deb_extra-*-foo.deb")
+set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")
-set(EXPECTED_FILE_2 "deb_extra-*-bar.deb")
+set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$")
-set(EXPECTED_FILE_3 "deb_extra-*-bas.deb")
+set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake
index 5f929ff..85e137f 100644
--- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake
@@ -1,17 +1,18 @@
 set(foo_preinst "^echo default_preinst$")
-set(foo_preinst_permissions_regex "-rwxr-xr-x .*")
+# NOTE: optional dot at the end of permissions regex is for SELinux enabled systems
+set(foo_preinst_permissions_regex "-rwxr-xr-x\.? .*")
 set(foo_prerm "^echo default_prerm$")
-set(foo_prerm_permissions_regex "-rwxr-xr-x .*")
+set(foo_prerm_permissions_regex "-rwxr-xr-x\.? .*")
 verifyDebControl("${FOUND_FILE_1}" "foo" "preinst;prerm")
 
 set(bar_preinst "^echo bar_preinst$")
-set(bar_prerm_permissions_regex "-rwx------ .*")
+set(bar_preinst_permissions_regex "-rwx------\.? .*")
 set(bar_prerm "^echo bar_prerm$")
-set(bar_prerm_permissions_regex "-rwx------ .*")
+set(bar_prerm_permissions_regex "-rwx------\.? .*")
 verifyDebControl("${FOUND_FILE_2}" "bar" "preinst;prerm")
 
 set(bas_preinst "^echo default_preinst$")
-set(bas_prerm_permissions_regex "-rwxr-xr-x .*")
+set(bas_preinst_permissions_regex "-rwxr-xr-x\.? .*")
 set(bas_prerm "^echo default_prerm$")
-set(bas_prerm_permissions_regex "-rwxr-xr-x .*")
+set(bas_prerm_permissions_regex "-rwxr-xr-x\.? .*")
 verifyDebControl("${FOUND_FILE_3}" "bas" "preinst;prerm")
diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake
new file mode 100644
index 0000000..a8efb61
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake
@@ -0,0 +1,6 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb")
+# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$")
diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake
new file mode 100644
index 0000000..b98065a
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake
@@ -0,0 +1,7 @@
+function(get_test_prerequirements found_var)
+  find_program(READELF_EXECUTABLE NAMES readelf)
+
+  if(READELF_EXECUTABLE)
+    set(${found_var} true PARENT_SCOPE)
+  endif()
+endfunction()
diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake
new file mode 100644
index 0000000..b1952ef
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake
@@ -0,0 +1,4 @@
+set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$")
+# optional dot at the end of permissions regex is for SELinux enabled systems
+set(shlibs_shlibs_permissions_regex "-rw-r--r--\.? .*")
+verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs")
diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake
new file mode 100644
index 0000000..9a9dee3
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake
@@ -0,0 +1,6 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb")
+# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$")
diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake
new file mode 100644
index 0000000..b98065a
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake
@@ -0,0 +1,7 @@
+function(get_test_prerequirements found_var)
+  find_program(READELF_EXECUTABLE NAMES readelf)
+
+  if(READELF_EXECUTABLE)
+    set(${found_var} true PARENT_SCOPE)
+  endif()
+endfunction()
diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake
new file mode 100644
index 0000000..422cfbe
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake
@@ -0,0 +1,8 @@
+set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$")
+# NOTE: optional dot at the end of permissions regex is for SELinux enabled systems
+set(shlibs_shlibs_permissions_regex "-rw-r--r--\.? .*")
+set(shlibs_postinst ".*ldconfig.*")
+set(shlibs_postinst_permissions_regex "-rwxr-xr-x\.? .*")
+set(shlibs_postrm ".*ldconfig.*")
+set(shlibs_postrm_permissions_regex "-rwxr-xr-x\.? .*")
+verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs;postinst;postrm")
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
index c56c670..a6f08fe 100644
--- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
@@ -1,14 +1,14 @@
 set(whitespaces_ "[\t\n\r ]*")
 
 set(EXPECTED_FILES_COUNT "5")
-set(EXPECTED_FILE_1 "dependencies*-applications.deb")
+set(EXPECTED_FILE_1 "dependencies-0.1.1-*-applications.deb")
 set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$")
-set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb")
+set(EXPECTED_FILE_2 "dependencies-0.1.1-*-applications_auto.deb")
 set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$")
-set(EXPECTED_FILE_3 "dependencies*-headers.deb")
+set(EXPECTED_FILE_3 "dependencies-0.1.1-*-headers.deb")
 set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$")
-set(EXPECTED_FILE_4 "dependencies*-libs.deb")
+set(EXPECTED_FILE_4 "dependencies-0.1.1-*-libs.deb")
 # dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
 set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$")
-set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb")
+set(EXPECTED_FILE_5 "dependencies-0.1.1-*-libs_auto.deb")
 set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$")
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
index 96a9f14..5f82cc6 100644
--- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
@@ -1,5 +1,7 @@
 set(CPACK_PACKAGE_CONTACT "someone")
 set(CPACK_DEB_COMPONENT_INSTALL "ON")
+#intentionaly commented out to test old file naming
+#set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
 
 # false by default
 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE)
diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake
index 1552a36..6dc5906 100644
--- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake
@@ -1,5 +1,5 @@
 set(whitespaces_ "[\t\n\r ]*")
 
 set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_1 "empty_dir*.deb")
+set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")
diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake
index 8821ab9..4e9a2e7 100644
--- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake
+++ b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-specifics.cmake
@@ -1 +1,2 @@
 set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake
index f490130..d05f115 100644
--- a/Tests/RunCMake/CPack/DEB/Helpers.cmake
+++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake
@@ -1,7 +1,7 @@
 set(ALL_FILES_GLOB "*.deb")
 
 function(getPackageContent FILE RESULT_VAR)
-  execute_process(COMMAND ${DPKG_EXECUTABLE} -c ${FILE}
+  execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}"
           OUTPUT_VARIABLE package_content_
           ERROR_QUIET
           OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -9,8 +9,73 @@ function(getPackageContent FILE RESULT_VAR)
   set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
 endfunction()
 
+function(getMissingShlibsErrorExtra FILE RESULT_VAR)
+    execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX}
+            ERROR_VARIABLE err_)
+
+    if(err_)
+      set(error_extra " Extra: Could not unpack package content: '${err}'")
+    else()
+      cmake_policy(PUSH)
+        # Tell file(GLOB_RECURSE) not to follow directory symlinks
+        # even if the project does not set this policy to NEW.
+        cmake_policy(SET CMP0009 NEW)
+        file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*")
+      cmake_policy(POP)
+
+      # get file info so that we can determine if file is executable or not
+      foreach(FILE_ IN LISTS FILE_PATHS_)
+        execute_process(COMMAND file "${FILE_}"
+          WORKING_DIRECTORY "${WDIR}"
+          OUTPUT_VARIABLE INSTALL_FILE_
+          ERROR_VARIABLE err_)
+
+        if(NOT err_)
+          list(APPEND deb_install_files "${INSTALL_FILE_}")
+        else()
+          list(APPEND deb_install_files_errors "'${FILE_}': '${err_}'\n")
+        endif()
+      endforeach()
+
+      set(error_extra " Extra: install files '${deb_install_files}'")
+
+      if(deb_install_files_errors)
+        set(error_extra "${error_extra}; errors \"${deb_install_files_errors}\"")
+      endif()
+
+      find_program(READELF_EXECUTABLE NAMES readelf)
+
+      if(READELF_EXECUTABLE)
+        set(error_extra "${error_extra}; readelf \"\n")
+
+        # Only dynamically linked ELF files are included
+        # Extract only file name infront of ":"
+        foreach(_FILE IN LISTS deb_install_files)
+          if(_FILE MATCHES "ELF.*shared object")
+            string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
+
+            execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}"
+              WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+              RESULT_VARIABLE result
+              OUTPUT_VARIABLE output
+              ERROR_VARIABLE err_
+              OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+            set(error_extra "${error_extra} name '${CMAKE_MATCH_1}'\n result '${result}'\n output '${output}'\n error '${err_}'\n")
+          endif()
+        endforeach()
+
+        set(error_extra "${error_extra}\"")
+      else()
+        set(error_extra "${error_extra}; error readelf missing")
+      endif()
+    endif()
+
+    set(${RESULT_VAR} "${error_extra}" PARENT_SCOPE)
+endfunction()
+
 function(verifyDebControl FILE PREFIX VERIFY_FILES)
-  execute_process(COMMAND ${DPKG_EXECUTABLE} --control ${FILE} control_${PREFIX}
+  execute_process(COMMAND ${DPKG_EXECUTABLE} --control "${FILE}" control_${PREFIX}
           ERROR_VARIABLE err_)
 
   if(err_)
@@ -19,6 +84,14 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES)
   endif()
 
   foreach(FILE_ IN LISTS VERIFY_FILES)
+    if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}")
+      if(FILE_ STREQUAL "shlibs")
+        getMissingShlibsErrorExtra("${FILE}" error_extra)
+      endif()
+
+      message(FATAL_ERROR "Expected Debian control file does not exist: '${FILE_}'${error_extra}")
+    endif()
+
     file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_)
     if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}")
       message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!"
diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake
index 9e4aa7c..648c866 100644
--- a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake
@@ -1,5 +1,5 @@
 set(whitespaces_ "[\t\n\r ]*")
 
 set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_1 "minimal*.deb")
+set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake
index 8821ab9..4e9a2e7 100644
--- a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake
+++ b/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake
@@ -1 +1,2 @@
 set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake
index 1f6c11b..40f6730 100644
--- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake
@@ -1,9 +1,9 @@
 set(whitespaces_ "[\t\n\r ]*")
 
 set(EXPECTED_FILES_COUNT "3")
-set(EXPECTED_FILE_1 "per_component*-pkg_1.deb")
+set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
-set(EXPECTED_FILE_2 "per_component*-pkg_2.deb")
+set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
-set(EXPECTED_FILE_3 "per_component*-pkg_3.deb")
+set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb")
 set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake
index a1da1a3..25bd2e7 100644
--- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake
+++ b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-specifics.cmake
@@ -1,5 +1,6 @@
 set(CPACK_PACKAGE_CONTACT "someone")
 set(CPACK_DEB_COMPONENT_INSTALL "ON")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
 
 set(CPACK_DEBIAN_PACKAGE_SECTION "default")
 set(CPACK_DEBIAN_PKG_2_PACKAGE_NAME "second")
diff --git a/Tests/RunCMake/CPack/DEB_EXTRA.cmake b/Tests/RunCMake/CPack/DEB_EXTRA.cmake
index 3c291d5..189d123 100644
--- a/Tests/RunCMake/CPack/DEB_EXTRA.cmake
+++ b/Tests/RunCMake/CPack/DEB_EXTRA.cmake
@@ -34,5 +34,6 @@ set(CPACK_DEBIAN_BAR_PACKAGE_CONTROL_EXTRA
 
 set(CPACK_PACKAGE_NAME "deb_extra")
 set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
 
 set(CPACK_DEB_COMPONENT_INSTALL ON)
diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake
new file mode 100644
index 0000000..1aeb06f
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake
@@ -0,0 +1,18 @@
+set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEB_COMPONENT_INSTALL "ON")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
+
+set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON")
+
+set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
+    "int test_lib();\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
+    "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
+add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
+set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
+
+install(TARGETS test_lib DESTINATION foo COMPONENT libs)
+
+set(CPACK_PACKAGE_NAME "generate_shlibs")
diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake
new file mode 100644
index 0000000..f58c876
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake
@@ -0,0 +1,19 @@
+set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEB_COMPONENT_INSTALL "ON")
+set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
+
+set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON")
+set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=")
+
+set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
+    "int test_lib();\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
+    "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
+add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
+set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
+
+install(TARGETS test_lib LIBRARY DESTINATION lib COMPONENT libs NAMELINK_SKIP)
+
+set(CPACK_PACKAGE_NAME "generate_shlibs_ldconfig")
diff --git a/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake b/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake
new file mode 100644
index 0000000..13aa77b
--- /dev/null
+++ b/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake
@@ -0,0 +1,26 @@
+set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+
+# default
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh"
+    "echo \"pre install\"\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh"
+    "echo \"post install\"\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh"
+    "echo \"pre uninstall\"\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh"
+    "echo \"post uninstall\"\n")
+
+# specific
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh"
+    "echo \"pre install foo\"\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh"
+    "echo \"post install foo\"\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh"
+    "echo \"pre uninstall foo\"\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh"
+    "echo \"post uninstall foo\"\n")
+
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo)
+install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar)
+
+set(CPACK_PACKAGE_NAME "install_scripts")
diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt
index ea68304..5c86880 100644
--- a/Tests/RunCMake/CPack/README.txt
+++ b/Tests/RunCMake/CPack/README.txt
@@ -1,6 +1,9 @@
 RunCMake.CPack is a test module that is intended for testing of package
 generators that can be validated from command line.
 
+TODO: all tests should cover all packaging types (single package, grouped and
+      component packaging)
+
 -------------
 Adding a test
 -------------
@@ -19,10 +22,29 @@ run_cpack_test(<test_name> "<generator_name>")
 will be run for all listed generators.
 
 Test consists of
+- test prerequirements phase (optional)
 - CMake execution phase
 - CPack execution phase
 - verification of generated files
 
+test prerequirements phase (optional):
+--------------------------------------
+
+In some cases individual tests for certain generator need additional
+prerequirements met.
+
+In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file
+containing 'function(get_test_prerequirements found_var)' should be created.
+Function should return true if all prerequirements are met.
+
+If prerequirements are not met test will be skipped outputting
+'<test_name> - SKIPPED' string. Note that this doesn't fail the entire test
+group.
+
+TODO: skipped tests should provide expected error string so test should fail
+      if error string is not found in the output of run test (this would add
+      'EXPECTED FAIL' string on success and 'ERROR' on failure).
+
 CMake execution phase:
 ----------------------
 
diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake
new file mode 100644
index 0000000..780e57e
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-ExpectedFiles.cmake
@@ -0,0 +1,9 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "3")
+set(EXPECTED_FILE_1 "custom_names-pkg_1*.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
+set(EXPECTED_FILE_2 "second*.rpm")
+set(EXPECTED_FILE_CONTENT_2 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
+set(EXPECTED_FILE_3 "pkg_3_abc.rpm")
+set(EXPECTED_FILE_CONTENT_3 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake
new file mode 100644
index 0000000..575aa01
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-specifics.cmake
@@ -0,0 +1,5 @@
+set(CPACK_RPM_COMPONENT_INSTALL "ON")
+
+set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
+set(CPACK_RPM_PKG_2_PACKAGE_NAME "second")
+set(CPACK_RPM_PKG_3_FILE_NAME "pkg_3_abc.rpm")
diff --git a/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt
new file mode 100644
index 0000000..9bfba7e
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/CUSTOM_NAMES-stderr.txt
@@ -0,0 +1,3 @@
+^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_1.spec
+CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/second.spec
+CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_3.spec$
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
index 2cdfece..8b7fb1e 100644
--- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
@@ -4,19 +4,19 @@ set(CPACK_RPM_COMPONENT_INSTALL "ON")
 # does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755
 set(CPACK_RPM_PACKAGE_AUTOREQ "no")
 set(CPACK_RPM_PACKAGE_AUTOPROV "no")
-set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes")
-set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes")
+set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes")
+set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes")
 
 set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b")
-set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b")
-set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b")
-set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers")
+set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b")
+set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b")
+set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers")
 
 set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b")
-set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
-set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
-set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers")
+set(CPACK_RPM_APPLICATIONS_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
+set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
+set(CPACK_RPM_HEADERS_PACKAGE_CONFLICTS "conflict-headers")
 
 set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b")
-set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib")
-set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b")
+set(CPACK_RPM_LIBS_PACKAGE_PROVIDES "provided-lib")
+set(CPACK_RPM_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b")
diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake
new file mode 100644
index 0000000..033a45d
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake
@@ -0,0 +1,7 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "2")
+set(EXPECTED_FILE_1 "install_scripts*-foo.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
+set(EXPECTED_FILE_2 "install_scripts*-bar.rpm")
+set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake
new file mode 100644
index 0000000..d7d82f2
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake
@@ -0,0 +1,29 @@
+function(checkScripts_ FILE COMPARE_LIST)
+  set(whitespaces_ "[\t\n\r ]*")
+
+  execute_process(COMMAND ${RPM_EXECUTABLE} -qp --scripts ${FILE}
+          WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+          OUTPUT_VARIABLE FILE_SCRIPTS_
+          ERROR_QUIET
+          OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}")
+
+  foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST)
+    unset(FOUND_)
+
+    foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_)
+      if(COMPARE_ MATCHES "${COMPARE_REGEX_}")
+        set(FOUND_ true)
+        break()
+      endif()
+    endforeach()
+
+    if(NOT FOUND_)
+      message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'")
+    endif()
+  endforeach()
+endfunction()
+
+checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\"")
+checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\"")
diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake
new file mode 100644
index 0000000..4eb53c3
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake
@@ -0,0 +1,19 @@
+set(CPACK_RPM_COMPONENT_INSTALL "ON")
+
+set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh")
+set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh")
+set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh")
+set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh")
+
+set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh")
+set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh")
+set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh")
+set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE
+  "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh")
diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake
index d398168..524ef0c 100644
--- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake
+++ b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake
@@ -1,5 +1,5 @@
 set(CPACK_RPM_COMPONENT_INSTALL "ON")
 
 set(CPACK_RPM_PACKAGE_GROUP "default")
-set(CPACK_RPM_pkg_2_PACKAGE_NAME "second")
-set(CPACK_RPM_pkg_2_PACKAGE_GROUP "second_group")
+set(CPACK_RPM_PKG_2_PACKAGE_NAME "second")
+set(CPACK_RPM_PKG_2_PACKAGE_GROUP "second_group")
diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake
new file mode 100644
index 0000000..3b5a347
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake
@@ -0,0 +1,5 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "rpm_dist*.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake
new file mode 100644
index 0000000..7375ecc
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake
@@ -0,0 +1,11 @@
+execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist}
+                OUTPUT_VARIABLE DIST_TAG
+                ERROR_QUIET
+                OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+set(whitespaces_ "[\t\n\r ]*")
+
+getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_")
+if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}")
+  message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'")
+endif()
diff --git a/Tests/RunCMake/CPack/RPM_DIST.cmake b/Tests/RunCMake/CPack/RPM_DIST.cmake
new file mode 100644
index 0000000..eb2a123
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM_DIST.cmake
@@ -0,0 +1,4 @@
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+
+set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
+set(CPACK_PACKAGE_NAME "rpm_dist")
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index fe2b48b..59c52f8 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -10,4 +10,9 @@ run_cpack_test(DEB_EXTRA "DEB" false)
 run_cpack_test(DEPENDENCIES "RPM;DEB" true)
 run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true)
 run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true)
+run_cpack_test(CUSTOM_NAMES "RPM;DEB" true)
 run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false)
+run_cpack_test(RPM_DIST "RPM" false)
+run_cpack_test(INSTALL_SCRIPTS "RPM" false)
+run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
+run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)
diff --git a/Tests/RunCMake/CPackInstallProperties/test.cpp b/Tests/RunCMake/CPackInstallProperties/test.cpp
index 237c8ce..5047a34 100644
--- a/Tests/RunCMake/CPackInstallProperties/test.cpp
+++ b/Tests/RunCMake/CPackInstallProperties/test.cpp
@@ -1 +1,3 @@
-int main() {}
+int main()
+{
+}
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in
new file mode 100644
index 0000000..e9592f6
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.4)
+project(TimeoutAfterMatch NONE)
+include(CTest)
+add_test(NAME SleepFor1Second COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_SOURCE_DIR}/SleepFor1Second.cmake)
+set_property(TEST SleepFor1Second PROPERTY TIMEOUT 30)
+set_property(TEST SleepFor1Second PROPERTY TIMEOUT_AFTER_MATCH "${arg1}" "${arg2}")
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in
new file mode 100644
index 0000000..58b11af
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in
@@ -0,0 +1 @@
+set(CTEST_PROJECT_NAME "TimeoutAfterMatch at CASE_NAME@")
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt
new file mode 100644
index 0000000..7766c68
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt
@@ -0,0 +1 @@
+TIMEOUT_AFTER_MATCH expects two arguments, found 1
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt
new file mode 100644
index 0000000..7766c68
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt
@@ -0,0 +1 @@
+TIMEOUT_AFTER_MATCH expects two arguments, found 1
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake b/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake
new file mode 100644
index 0000000..ee4db83
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake
@@ -0,0 +1,11 @@
+include(RunCTest)
+
+function(run_ctest_TimeoutAfterMatch CASE_NAME)
+  set(CASE_PROPERTY_ARGS "${ARGN}")
+  run_ctest(${CASE_NAME})
+endfunction()
+
+run_ctest_TimeoutAfterMatch(MissingArg1 "\"-Darg2=Test started\"")
+run_ctest_TimeoutAfterMatch(MissingArg2 "\"-Darg1=2\"")
+run_ctest_TimeoutAfterMatch(ShouldTimeout "\"-Darg1=1\" \"-Darg2=Test started\"")
+run_ctest_TimeoutAfterMatch(ShouldPass "\"-Darg1=15\" \"-Darg2=Test started\"")
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt
new file mode 100644
index 0000000..89aae56
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt
@@ -0,0 +1,6 @@
+    Start 1: SleepFor1Second
+1/1 Test #1: SleepFor1Second ..................   Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec$
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt
new file mode 100644
index 0000000..c031eb0
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt
@@ -0,0 +1 @@
+1 - SleepFor1Second \(Timeout\)
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake b/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake
new file mode 100644
index 0000000..82c2a44
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake
@@ -0,0 +1,4 @@
+execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Gathering required resources")
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2)
+execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Test started")
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in
new file mode 100644
index 0000000..d049c9f
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.4)
+
+set(CTEST_SITE                          "test-site")
+set(CTEST_BUILD_NAME                    "test-build-name")
+set(CTEST_SOURCE_DIRECTORY              "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY              "@RunCMake_BINARY_DIR@/@CASE_NAME at -build")
+set(CTEST_CMAKE_GENERATOR               "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM      "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
+
+configure_file(
+  "@RunCMake_SOURCE_DIR@/SleepFor1Second.cmake"
+  "${CTEST_SOURCE_DIRECTORY}/SleepFor1Second.cmake"
+  COPYONLY)
+
+set(options @CASE_PROPERTY_ARGS@)
+
+ctest_start(Experimental)
+ctest_configure(OPTIONS "${options}")
+ctest_test()
diff --git a/Tests/RunCMake/ClangTidy/C-Build-stdout.txt b/Tests/RunCMake/ClangTidy/C-Build-stdout.txt
new file mode 100644
index 0000000..a47a2de
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.c:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt b/Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt
new file mode 100644
index 0000000..a47a2de
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.c:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/C-launch.cmake b/Tests/RunCMake/ClangTidy/C-launch.cmake
new file mode 100644
index 0000000..e66ca20
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(C.cmake)
diff --git a/Tests/RunCMake/ClangTidy/C.cmake b/Tests/RunCMake/ClangTidy/C.cmake
new file mode 100644
index 0000000..b8057b0
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/C.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/ClangTidy/CMakeLists.txt b/Tests/RunCMake/ClangTidy/CMakeLists.txt
new file mode 100644
index 0000000..93ee9df
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt b/Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt
new file mode 100644
index 0000000..47e43af
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.cxx:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt b/Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt
new file mode 100644
index 0000000..47e43af
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt
@@ -0,0 +1 @@
+Tests[/\]RunCMake[/\]ClangTidy[/\]main\.cxx:0:0: warning: message \[checker\]
diff --git a/Tests/RunCMake/ClangTidy/CXX-launch.cmake b/Tests/RunCMake/ClangTidy/CXX-launch.cmake
new file mode 100644
index 0000000..3002c9d
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(CXX.cmake)
diff --git a/Tests/RunCMake/ClangTidy/CXX.cmake b/Tests/RunCMake/ClangTidy/CXX.cmake
new file mode 100644
index 0000000..2d22325
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/CXX.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+set(CMAKE_CXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
+add_executable(main main.cxx)
diff --git a/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake
new file mode 100644
index 0000000..27cd922
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/RunCMakeTest.cmake
@@ -0,0 +1,22 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS "-DPSEUDO_TIDY=${PSEUDO_TIDY}")
+
+function(run_tidy lang)
+  # Use a single build tree for tests without cleaning.
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-build)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+  run_cmake(${lang})
+
+  set(RunCMake_TEST_OUTPUT_MERGE 1)
+  run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+run_tidy(C)
+run_tidy(CXX)
+if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
+  run_tidy(C-launch)
+  run_tidy(CXX-launch)
+endif()
diff --git a/Tests/RunCMake/ClangTidy/main.c b/Tests/RunCMake/ClangTidy/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/ClangTidy/main.cxx b/Tests/RunCMake/ClangTidy/main.cxx
new file mode 100644
index 0000000..f8b643a
--- /dev/null
+++ b/Tests/RunCMake/ClangTidy/main.cxx
@@ -0,0 +1,4 @@
+int main()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt
new file mode 100644
index 0000000..f2cbaa6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt
@@ -0,0 +1,3 @@
+^'--target' may not be specified more than once\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt b/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt
index 20df108..d2a2831 100644
--- a/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt
+++ b/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt
@@ -3,3 +3,5 @@ add_custom_command(
   COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
   )
 add_custom_target(CustomTarget ALL DEPENDS output.txt)
+add_custom_target(CustomTarget2 ALL DEPENDS output.txt)
+add_custom_target(CustomTarget3 ALL DEPENDS output.txt)
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON-stderr.txt
deleted file mode 100644
index 1b6a510..0000000
--- a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON-stderr.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-^CMake Warning:
-  The "Visual Studio 6" generator is deprecated and will be removed in a
-  future version of CMake.
-
-  Add CMAKE_WARN_VS6=OFF to the cache to disable this warning.$
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS70-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS70-WARN-ON-stderr.txt
deleted file mode 100644
index ea31ef3..0000000
--- a/Tests/RunCMake/CommandLine/DeprecateVS70-WARN-ON-stderr.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-^CMake Warning:
-  The "Visual Studio 7" generator is deprecated and will be removed in a
-  future version of CMake.
-
-  Add CMAKE_WARN_VS70=OFF to the cache to disable this warning.$
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS70-WARN-ON.cmake b/Tests/RunCMake/CommandLine/DeprecateVS71-WARN-OFF.cmake
similarity index 100%
rename from Tests/RunCMake/CommandLine/DeprecateVS70-WARN-ON.cmake
rename to Tests/RunCMake/CommandLine/DeprecateVS71-WARN-OFF.cmake
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS71-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS71-WARN-ON-stderr.txt
new file mode 100644
index 0000000..2cb01ff
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/DeprecateVS71-WARN-ON-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Warning:
+  The "Visual Studio 7 .NET 2003" generator is deprecated and will be removed
+  in a future version of CMake.
+
+  Add CMAKE_WARN_VS71=OFF to the cache to disable this warning.$
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS71-WARN-ON.cmake
similarity index 100%
copy from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake
copy to Tests/RunCMake/CommandLine/DeprecateVS71-WARN-ON.cmake
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
index 0024097..0d0d899 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
+++ b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
@@ -1 +1 @@
-^__run_iwyu missing --iwyu=$
+^__run_iwyu missing --tidy= or --iwyu=$
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index e3b73ff..f449f1d 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -51,6 +51,8 @@ function(run_BuildDir)
   run_cmake(BuildDir)
   run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir ..
     ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget)
+  run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir ..
+    ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3)
 endfunction()
 run_BuildDir()
 
@@ -70,16 +72,11 @@ if(RunCMake_GENERATOR STREQUAL "Ninja")
   unset(RunCMake_TEST_NO_CLEAN)
 endif()
 
-if(RunCMake_GENERATOR STREQUAL "Visual Studio 6")
-  set(RunCMake_WARN_VS6 1)
-  run_cmake(DeprecateVS6-WARN-ON)
-  unset(RunCMake_WARN_VS6)
-  run_cmake(DeprecateVS6-WARN-OFF)
-elseif(RunCMake_GENERATOR STREQUAL "Visual Studio 7")
-  set(RunCMake_WARN_VS70 1)
-  run_cmake(DeprecateVS70-WARN-ON)
-  unset(RunCMake_WARN_VS70)
-  run_cmake(DeprecateVS70-WARN-OFF)
+if(RunCMake_GENERATOR STREQUAL "Visual Studio 7 .NET 2003")
+  set(RunCMake_WARN_VS71 1)
+  run_cmake(DeprecateVS71-WARN-ON)
+  unset(RunCMake_WARN_VS71)
+  run_cmake(DeprecateVS71-WARN-OFF)
 endif()
 
 if(UNIX)
diff --git a/Tests/RunCMake/CommandLine/cmake_depends/test.h b/Tests/RunCMake/CommandLine/cmake_depends/test.h
index fd87388..c2db61c 100644
--- a/Tests/RunCMake/CommandLine/cmake_depends/test.h
+++ b/Tests/RunCMake/CommandLine/cmake_depends/test.h
@@ -1 +1,3 @@
-void test(void) {}
+void test(void)
+{
+}
diff --git a/Tests/RunCMake/CompatibleInterface/main.cpp b/Tests/RunCMake/CompatibleInterface/main.cpp
index 65eddcf..1c19e8d 100644
--- a/Tests/RunCMake/CompatibleInterface/main.cpp
+++ b/Tests/RunCMake/CompatibleInterface/main.cpp
@@ -1,5 +1,5 @@
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CompileFeatures/empty.c b/Tests/RunCMake/CompileFeatures/empty.c
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CompileFeatures/empty.c
+++ b/Tests/RunCMake/CompileFeatures/empty.c
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CompileFeatures/empty.cpp b/Tests/RunCMake/CompileFeatures/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/CompileFeatures/empty.cpp
+++ b/Tests/RunCMake/CompileFeatures/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/CompilerLauncher/main.c b/Tests/RunCMake/CompilerLauncher/main.c
index 03b2213..8488f4e 100644
--- a/Tests/RunCMake/CompilerLauncher/main.c
+++ b/Tests/RunCMake/CompilerLauncher/main.c
@@ -1,3 +1,4 @@
-int main(void) {
+int main(void)
+{
   return 0;
 }
diff --git a/Tests/RunCMake/CompilerLauncher/main.cxx b/Tests/RunCMake/CompilerLauncher/main.cxx
index 76e8197..f8b643a 100644
--- a/Tests/RunCMake/CompilerLauncher/main.cxx
+++ b/Tests/RunCMake/CompilerLauncher/main.cxx
@@ -1 +1,4 @@
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake
new file mode 100644
index 0000000..e10b161
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand-build-check.cmake
@@ -0,0 +1,5 @@
+foreach(output IN ITEMS output1 output2 output3 output4)
+  if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${output}")
+    message(FATAL_ERROR "Failed to create output: ${RunCMake_TEST_BINARY_DIR}/${output}")
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
new file mode 100644
index 0000000..67fa30f
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
@@ -0,0 +1,38 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+# Executable: Return error code different from 0
+add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
+
+# Executable: Return error code equal to 0
+add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx)
+
+# DoesNotUseEmulator
+add_custom_command(OUTPUT output1
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output1)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_command(OUTPUT output2
+  COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:generated_exe_emulator_unexpected>"
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output2
+  DEPENDS generated_exe_emulator_unexpected)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_command(OUTPUT output3
+  COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected>
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
+  DEPENDS generated_exe_emulator_unexpected)
+
+# UsesEmulator: The command only succeeds if the emulator is prepended
+#               to the command.
+add_custom_command(OUTPUT output4
+  COMMAND generated_exe_emulator_expected
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
+  DEPENDS generated_exe_emulator_expected)
+
+add_custom_target(ensure_build ALL
+  SOURCES
+    ${CMAKE_CURRENT_BINARY_DIR}/output1
+    ${CMAKE_CURRENT_BINARY_DIR}/output2
+    ${CMAKE_CURRENT_BINARY_DIR}/output3
+    ${CMAKE_CURRENT_BINARY_DIR}/output4
+)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake
new file mode 100644
index 0000000..c621922
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget-build-check.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/AddCustomCommand-build-check.cmake)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
new file mode 100644
index 0000000..ced569f
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTarget.cmake
@@ -0,0 +1,30 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+# Executable: Return error code different from 0
+add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
+
+# Executable: Return error code equal to 0
+add_executable(generated_exe_emulator_unexpected simple_src_exitsuccess.cxx)
+
+# DoesNotUseEmulator
+add_custom_target(generate_output1 ALL
+  ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output1)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_target(generate_output2 ALL
+  ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:generated_exe_emulator_unexpected>"
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output2
+  DEPENDS generated_exe_emulator_unexpected)
+
+# DoesNotUseEmulator: The command will fail if emulator is prepended
+add_custom_target(generate_output3 ALL
+  $<TARGET_FILE:generated_exe_emulator_unexpected>
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
+  DEPENDS generated_exe_emulator_unexpected)
+
+# UsesEmulator: The command only succeeds if the emulator is prepended
+#               to the command.
+add_custom_target(generate_output4 ALL
+  generated_exe_emulator_expected
+  COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
+  DEPENDS generated_exe_emulator_expected)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake
index 0aae06c..588b77b 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-check.cmake
@@ -4,9 +4,25 @@ if(EXISTS "${testfile}")
 else()
   message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.")
 endif()
-if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator ^(pseudo_emulator)+$")
-  message(SEND_ERROR "Used emulator when it should not be used.")
+
+set(error_details "There is a problem with generated test file: ${testfile}")
+
+if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n")
+  message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
 endif()
-if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator .+pseudo_emulator.+$")
-  message(SEND_ERROR "Did not use emulator when it should be used.")
+
+if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator [^\n]+pseudo_emulator[^\n]+\n")
+  message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}")
+endif()
+
+if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n")
+  message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
+endif()
+
+if(NOT testfile_contents MATCHES "add_test[(]UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n")
+  message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}")
+endif()
+
+if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n")
+  message(SEND_ERROR "Used emulator when it should not be used. ${error_details}")
 endif()
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake
index 41850f2..23e2e8d 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest.cmake
@@ -3,6 +3,18 @@ enable_testing()
 add_test(NAME DoesNotUseEmulator
   COMMAND ${CMAKE_COMMAND} -E echo "Hi")
 
-add_executable(generated_exe simple_src.cxx)
+add_executable(generated_exe simple_src_exiterror.cxx)
+
 add_test(NAME UsesEmulator
   COMMAND generated_exe)
+
+add_test(NAME DoesNotUseEmulatorWithGenex
+  COMMAND $<TARGET_FILE:generated_exe>)
+
+add_subdirectory(AddTest)
+
+add_test(NAME UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex
+  COMMAND generated_exe_in_subdir_added_to_test_without_genex)
+
+add_test(NAME DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex
+  COMMAND $<TARGET_FILE:generated_exe_in_subdir_added_to_test_with_genex>)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt b/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt
new file mode 100644
index 0000000..025b54c
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_executable(generated_exe_in_subdir_added_to_test_without_genex
+  ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src_exiterror.cxx)
+
+add_executable(generated_exe_in_subdir_added_to_test_with_genex
+  ${CMAKE_CURRENT_SOURCE_DIR}/../simple_src_exiterror.cxx)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
index 22d537c..1aeb510 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
@@ -3,7 +3,7 @@
 
 # -DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/pseudo_emulator is passed to this
 # test
-add_executable(target_with_emulator simple_src.cxx)
+add_executable(target_with_emulator simple_src_exiterror.cxx)
 get_property(emulator TARGET target_with_emulator
              PROPERTY CROSSCOMPILING_EMULATOR)
 if(NOT "${emulator}" MATCHES "pseudo_emulator")
@@ -20,7 +20,7 @@ if(NOT "${emulator}" MATCHES "another_emulator")
 endif()
 
 unset(CMAKE_CROSSCOMPILING_EMULATOR CACHE)
-add_executable(target_without_emulator simple_src.cxx)
+add_executable(target_without_emulator simple_src_exiterror.cxx)
 get_property(emulator TARGET target_without_emulator
              PROPERTY CROSSCOMPILING_EMULATOR)
 if(NOT "${emulator}" STREQUAL "")
diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
index 2581cfc..71aaad1 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -6,3 +6,18 @@ set(RunCMake_TEST_OPTIONS
 run_cmake(CrosscompilingEmulatorProperty)
 run_cmake(TryRun)
 run_cmake(AddTest)
+
+function(CustomCommandGenerator_run_and_build case)
+  # Use a single build tree for a few tests without cleaning.
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  set(RunCMake_TEST_OPTIONS
+    "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}")
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+  run_cmake(${case})
+  run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+CustomCommandGenerator_run_and_build(AddCustomCommand)
+CustomCommandGenerator_run_and_build(AddCustomTarget)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake
index 4851cc7..af3712c 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/TryRun.cmake
@@ -2,7 +2,7 @@ set(CMAKE_CROSSCOMPILING 1)
 
 try_run(run_result compile_result
   ${CMAKE_CURRENT_BINARY_DIR}
-  ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx
+  ${CMAKE_CURRENT_SOURCE_DIR}/simple_src_exiterror.cxx
   RUN_OUTPUT_VARIABLE run_output)
 
 message(STATUS "run_output: ${run_output}")
@@ -13,6 +13,6 @@ set(CMAKE_CROSSCOMPILING_EMULATOR ${CMAKE_CROSSCOMPILING_EMULATOR}
   "multi arg")
 try_run(run_result compile_result
   ${CMAKE_CURRENT_BINARY_DIR}
-  ${CMAKE_CURRENT_SOURCE_DIR}/simple_src.cxx
+  ${CMAKE_CURRENT_SOURCE_DIR}/simple_src_exiterror.cxx
   RUN_OUTPUT_VARIABLE run_output)
 message(STATUS "Emulator with arguments run_output: ${run_output}")
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
deleted file mode 100644
index e5e94f2..0000000
--- a/Tests/RunCMake/CrosscompilingEmulator/simple_src.cxx
+++ /dev/null
@@ -1,4 +0,0 @@
-int main(int, char **)
-{
-  return 13;
-}
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx
new file mode 100644
index 0000000..6ce7183
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exiterror.cxx
@@ -0,0 +1,4 @@
+int main(int, char**)
+{
+  return 13;
+}
diff --git a/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
new file mode 100644
index 0000000..a3dd891
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/simple_src_exitsuccess.cxx
@@ -0,0 +1,4 @@
+int main(int, char**)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/ExportWithoutLanguage/header.h b/Tests/RunCMake/ExportWithoutLanguage/header.h
index 0c803ed..5461f8a 100644
--- a/Tests/RunCMake/ExportWithoutLanguage/header.h
+++ b/Tests/RunCMake/ExportWithoutLanguage/header.h
@@ -1,2 +1,5 @@
 
-enum some_compilers { need_more_than_nothing };
+enum some_compilers
+{
+  need_more_than_nothing
+};
diff --git a/Tests/RunCMake/File_Generate/empty.c b/Tests/RunCMake/File_Generate/empty.c
index 563eef0..f097d0a 100644
--- a/Tests/RunCMake/File_Generate/empty.c
+++ b/Tests/RunCMake/File_Generate/empty.c
@@ -2,7 +2,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty_c()
+  int empty_c()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/File_Generate/empty.cpp b/Tests/RunCMake/File_Generate/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/File_Generate/empty.cpp
+++ b/Tests/RunCMake/File_Generate/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp b/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp
index 4149bb9..ebf1b87 100644
--- a/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp
+++ b/Tests/RunCMake/FindMatlab/matlab_wrapper1.cpp
@@ -1,24 +1,25 @@
 
 // simple workaround to some compiler specific problems
-// see http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
+// see
+// http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
 #include <algorithm>
 
 #include "mex.h"
 
-// this test should return a matrix of 10 x 10 and should check some of the arguments
+// this test should return a matrix of 10 x 10 and should check some of the
+// arguments
 
-void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[])
+void mexFunction(const int nlhs, mxArray* plhs[], const int nrhs,
+                 const mxArray* prhs[])
 {
-  if(nrhs != 1)
-  {
+  if (nrhs != 1) {
     mexErrMsgTxt("Incorrect arguments");
   }
 
   size_t dim1 = mxGetM(prhs[0]);
   size_t dim2 = mxGetN(prhs[0]);
 
-  if(dim1 == 1 || dim2 == 1)
-  {
+  if (dim1 == 1 || dim2 == 1) {
     mexErrMsgIdAndTxt("cmake_matlab:configuration", "Incorrect arguments");
   }
 
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
new file mode 100644
index 0000000..00cbb7b
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(FindPkgConfig_IMPORTED_TARGET C)
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses)
+
+if (NCURSES_FOUND)
+  set(tgt PkgConfig::NCURSES)
+  if (NOT TARGET ${tgt})
+    message(FATAL_ERROR "FindPkgConfig found ncurses, but did not create an imported target for it")
+  endif ()
+  set(prop_found FALSE)
+  foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_COMPILE_OPTIONS)
+    get_target_property(value ${tgt} ${prop})
+    if (value)
+      message(STATUS "Found property ${prop} on target: ${value}")
+      set(prop_found TRUE)
+    endif ()
+  endforeach ()
+  if (NOT prop_found)
+    message(FATAL_ERROR "target ${tgt} found, but it has no properties")
+  endif ()
+else ()
+  message(STATUS "skipping test; ncurses not found")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 24089e0..e12b52f 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -15,4 +15,5 @@ find_package(PkgConfig)
 if (PKG_CONFIG_FOUND)
   run_cmake(FindPkgConfig_GET_VARIABLE)
   run_cmake(FindPkgConfig_cache_variables)
+  run_cmake(FindPkgConfig_IMPORTED_TARGET)
 endif ()
diff --git a/Tests/RunCMake/Framework/foo.c b/Tests/RunCMake/Framework/foo.c
index bf7759e..b85b60d 100644
--- a/Tests/RunCMake/Framework/foo.c
+++ b/Tests/RunCMake/Framework/foo.c
@@ -1 +1,4 @@
-int foo() { return 42; }
+int foo()
+{
+  return 42;
+}
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
index 45175d8..625bab2 100644
--- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
@@ -28,6 +28,7 @@ run_cmake(COMPILE_LANGUAGE-add_test)
 run_cmake(COMPILE_LANGUAGE-unknown-lang)
 run_cmake(TARGET_FILE-recursion)
 run_cmake(OUTPUT_NAME-recursion)
+run_cmake(TARGET_PROPERTY-LOCATION)
 
 run_cmake(ImportedTarget-TARGET_PDB_FILE)
 if(LINKER_SUPPORTS_PDB)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt
new file mode 100644
index 0000000..e4dbb71
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+  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 "foo".  Use the target
+  name directly with add_custom_command, or use the generator expression
+  \$<TARGET_FILE>, as appropriate.
+
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION.cmake
new file mode 100644
index 0000000..8929cdb
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-LOCATION.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+add_library(foo empty.c)
+add_custom_target(drive COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,LOCATION>)
diff --git a/Tests/RunCMake/IncludeWhatYouUse/main.c b/Tests/RunCMake/IncludeWhatYouUse/main.c
index 78f2de1..8488f4e 100644
--- a/Tests/RunCMake/IncludeWhatYouUse/main.c
+++ b/Tests/RunCMake/IncludeWhatYouUse/main.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/IncludeWhatYouUse/main.cxx b/Tests/RunCMake/IncludeWhatYouUse/main.cxx
index 76e8197..f8b643a 100644
--- a/Tests/RunCMake/IncludeWhatYouUse/main.cxx
+++ b/Tests/RunCMake/IncludeWhatYouUse/main.cxx
@@ -1 +1,4 @@
-int main() { return 0; }
+int main()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/IncompatibleQt/main.cpp b/Tests/RunCMake/IncompatibleQt/main.cpp
index 140a7c1..410e13c 100644
--- a/Tests/RunCMake/IncompatibleQt/main.cpp
+++ b/Tests/RunCMake/IncompatibleQt/main.cpp
@@ -1,7 +1,7 @@
 
 #include <QCoreApplication>
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   QCoreApplication app(argc, argv);
   return app.exec();
diff --git a/Tests/RunCMake/Languages/empty.cpp b/Tests/RunCMake/Languages/empty.cpp
index 7279c5e..8d91e77 100644
--- a/Tests/RunCMake/Languages/empty.cpp
+++ b/Tests/RunCMake/Languages/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty(void)
+  int empty(void)
 {
   return 0;
 }
diff --git a/Tests/RunCMake/Ninja/CheckNoPrefixSubDir.cmake b/Tests/RunCMake/Ninja/CheckNoPrefixSubDir.cmake
new file mode 100644
index 0000000..b845f2f
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CheckNoPrefixSubDir.cmake
@@ -0,0 +1,7 @@
+add_custom_target(check_no_prefix_sub_dir ALL
+  COMMAND "${CMAKE_COMMAND}"
+          "-DNINJA_OUTPUT_PATH_PREFIX=${CMAKE_NINJA_OUTPUT_PATH_PREFIX}"
+          "-DCUR_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}"
+          -P "${CMAKE_CURRENT_SOURCE_DIR}/CheckNoPrefixSubDirScript.cmake"
+  VERBATIM
+  )
diff --git a/Tests/RunCMake/Ninja/CheckNoPrefixSubDirScript.cmake b/Tests/RunCMake/Ninja/CheckNoPrefixSubDirScript.cmake
new file mode 100644
index 0000000..5a03fcb
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CheckNoPrefixSubDirScript.cmake
@@ -0,0 +1,8 @@
+# Check that the prefix sub-directory is not repeated.
+
+if(EXISTS "${CUR_BIN_DIR}/${NINJA_OUTPUT_PATH_PREFIX}")
+  message(FATAL_ERROR
+    "no sub directory named after the CMAKE_NINJA_OUTPUT_PATH_PREFIX "
+    "should be in the binary directory."
+    )
+endif()
diff --git a/Tests/RunCMake/Ninja/CheckOutput.cmake b/Tests/RunCMake/Ninja/CheckOutput.cmake
new file mode 100644
index 0000000..ddb35a7
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CheckOutput.cmake
@@ -0,0 +1,23 @@
+# Add rules to check the generated executable works.
+
+set(hello_output "${CMAKE_CURRENT_BINARY_DIR}/hello.output")
+add_custom_command(
+  OUTPUT "${hello_output}"
+  COMMAND "$<TARGET_FILE:hello>" > "${hello_output}"
+  DEPENDS hello
+  VERBATIM
+  )
+
+if(NOT DEFINED HELLO_OUTPUT_STRING)
+  set(HELLO_OUTPUT_STRING "Hello world!\n")
+endif()
+
+set(hello_output_ref "${CMAKE_CURRENT_BINARY_DIR}/hello.output.ref")
+file(WRITE "${hello_output_ref}" "${HELLO_OUTPUT_STRING}")
+
+add_custom_target(check_output ALL
+  COMMAND "${CMAKE_COMMAND}" -E compare_files
+          "${hello_output}" "${hello_output_ref}"
+  DEPENDS "${hello_output}" "${hello_output_ref}"
+  VERBATIM
+  )
diff --git a/Tests/RunCMake/Ninja/CustomCommandWorkingDirectory.cmake b/Tests/RunCMake/Ninja/CustomCommandWorkingDirectory.cmake
new file mode 100644
index 0000000..8e01c8c
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CustomCommandWorkingDirectory.cmake
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.5)
+project(hello NONE)
+
+add_custom_command(
+  OUTPUT hello.copy.c
+  COMMAND "${CMAKE_COMMAND}" -E copy
+          "${CMAKE_CURRENT_SOURCE_DIR}/hello.c"
+          hello.copy.c
+  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+  )
+add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hello.copy.c")
+
+include(CheckNoPrefixSubDir.cmake)
diff --git a/Tests/RunCMake/Ninja/Executable.cmake b/Tests/RunCMake/Ninja/Executable.cmake
new file mode 100644
index 0000000..4e17d68
--- /dev/null
+++ b/Tests/RunCMake/Ninja/Executable.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.5)
+project(hello C)
+add_executable(hello hello.c)
+include(CheckOutput.cmake)
+include(CheckNoPrefixSubDir.cmake)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 64f97bc..c73f852 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -1,5 +1,20 @@
 include(RunCMake)
 
+# Detect ninja version so we know what tests can be supported.
+execute_process(
+  COMMAND "${RunCMake_MAKE_PROGRAM}" --version
+  OUTPUT_VARIABLE ninja_out
+  ERROR_VARIABLE ninja_out
+  RESULT_VARIABLE ninja_res
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+")
+  set(ninja_version "${ninja_out}")
+  message(STATUS "ninja version: ${ninja_version}")
+else()
+  message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}")
+endif()
+
 function(run_CMP0058 case)
   # Use a single build tree for a few tests without cleaning.
   set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build)
@@ -16,3 +31,169 @@ run_CMP0058(WARN-no)
 run_CMP0058(WARN-by)
 run_CMP0058(NEW-no)
 run_CMP0058(NEW-by)
+
+function(run_SubDir)
+  # Use a single build tree for a few tests without cleaning.
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SubDir-build)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+  run_cmake(SubDir)
+  if(WIN32)
+    set(SubDir_all [[SubDir\all]])
+  else()
+    set(SubDir_all [[SubDir/all]])
+  endif()
+  run_cmake_command(SubDir-build ${CMAKE_COMMAND} --build . --target ${SubDir_all})
+endfunction()
+run_SubDir()
+
+function(run_ninja dir)
+  execute_process(
+    COMMAND "${RunCMake_MAKE_PROGRAM}"
+    WORKING_DIRECTORY "${dir}"
+    OUTPUT_VARIABLE ninja_stdout
+    ERROR_VARIABLE ninja_stderr
+    RESULT_VARIABLE ninja_result
+    )
+  if(NOT ninja_result EQUAL 0)
+    message(STATUS "
+============ beginning of ninja's stdout ============
+${ninja_stdout}
+=============== end of ninja's stdout ===============
+")
+    message(STATUS "
+============ beginning of ninja's stderr ============
+${ninja_stderr}
+=============== end of ninja's stderr ===============
+")
+    message(FATAL_ERROR
+      "top ninja build failed exited with status ${ninja_result}")
+  endif()
+endfunction(run_ninja)
+
+function(sleep delay)
+  execute_process(
+    COMMAND ${CMAKE_COMMAND} -E sleep ${delay}
+    RESULT_VARIABLE result
+    )
+  if(NOT result EQUAL 0)
+    message(FATAL_ERROR "failed to sleep for ${delay} second.")
+  endif()
+endfunction(sleep)
+
+function(touch path)
+  execute_process(
+    COMMAND ${CMAKE_COMMAND} -E touch ${path}
+    RESULT_VARIABLE result
+    )
+  if(NOT result EQUAL 0)
+    message(FATAL_ERROR "failed to touch main ${path} file.")
+  endif()
+endfunction(touch)
+
+macro(ninja_escape_path path out)
+  string(REPLACE "\$ " "\$\$" "${out}" "${path}")
+  string(REPLACE " " "\$ " "${out}" "${${out}}")
+  string(REPLACE ":" "\$:" "${out}" "${${out}}")
+endmacro(ninja_escape_path)
+
+macro(shell_escape string out)
+  string(REPLACE "\"" "\\\"" "${out}" "${string}")
+endmacro(shell_escape)
+
+function(run_sub_cmake test ninja_output_path_prefix)
+  set(top_build_dir "${RunCMake_BINARY_DIR}/${test}-build/")
+  file(REMOVE_RECURSE "${top_build_dir}")
+  file(MAKE_DIRECTORY "${top_build_dir}")
+
+  ninja_escape_path("${ninja_output_path_prefix}"
+    escaped_ninja_output_path_prefix)
+
+  # Generate top build ninja file.
+  set(top_build_ninja "${top_build_dir}/build.ninja")
+  shell_escape("${top_build_ninja}" escaped_top_build_ninja)
+  set(build_ninja_dep "${top_build_dir}/build_ninja_dep")
+  ninja_escape_path("${build_ninja_dep}" escaped_build_ninja_dep)
+  shell_escape("${CMAKE_COMMAND}" escaped_CMAKE_COMMAND)
+  file(WRITE "${build_ninja_dep}" "fake dependency of top build.ninja file\n")
+  if(WIN32)
+    set(cmd_prefix "cmd.exe /C \"")
+    set(cmd_suffix "\"")
+  else()
+    set(cmd_prefix "")
+    set(cmd_suffix "")
+  endif()
+  file(WRITE "${top_build_ninja}" "\
+subninja ${escaped_ninja_output_path_prefix}/build.ninja
+default ${escaped_ninja_output_path_prefix}/all
+
+# Sleep for 1 second before to regenerate to make sure the timestamp of
+# the top build.ninja will be strictly greater than the timestamp of the
+# sub/build.ninja file. We assume the system as 1 sec timestamp resolution.
+rule RERUN
+  command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep 1 && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix}
+  description = Testing regeneration
+  generator = 1
+
+build build.ninja: RERUN ${escaped_build_ninja_dep} || ${escaped_ninja_output_path_prefix}/build.ninja
+  pool = console
+")
+
+  # Run sub cmake project.
+  set(RunCMake_TEST_OPTIONS "-DCMAKE_NINJA_OUTPUT_PATH_PREFIX=${ninja_output_path_prefix}")
+  set(RunCMake_TEST_BINARY_DIR "${top_build_dir}/${ninja_output_path_prefix}")
+  run_cmake(${test})
+
+  # Check there is no 'default' statement in Ninja file generated by CMake.
+  set(sub_build_ninja "${RunCMake_TEST_BINARY_DIR}/build.ninja")
+  file(READ "${sub_build_ninja}" sub_build_ninja_file)
+  if(sub_build_ninja_file MATCHES "\ndefault [^\n][^\n]*all\n")
+    message(FATAL_ERROR
+      "unexpected 'default' statement found in '${sub_build_ninja}'")
+  endif()
+
+  # Run ninja from the top build directory.
+  run_ninja("${top_build_dir}")
+
+  # Test regeneration rules run in order.
+  set(main_cmakelists "${RunCMake_SOURCE_DIR}/CMakeLists.txt")
+  sleep(1) # Assume the system as 1 sec timestamp resolution.
+  touch("${main_cmakelists}")
+  touch("${build_ninja_dep}")
+  run_ninja("${top_build_dir}")
+  file(TIMESTAMP "${main_cmakelists}" mtime_main_cmakelists UTC)
+  file(TIMESTAMP "${sub_build_ninja}" mtime_sub_build_ninja UTC)
+  file(TIMESTAMP "${top_build_ninja}" mtime_top_build_ninja UTC)
+
+  # Check sub build.ninja is regenerated.
+  if(mtime_main_cmakelists STRGREATER mtime_sub_build_ninja)
+    message(FATAL_ERROR
+      "sub build.ninja not regenerated:
+  CMakeLists.txt  = ${mtime_main_cmakelists}
+  sub/build.ninja = ${mtime_sub_build_ninja}")
+  endif()
+
+  # Check top build.ninja is regenerated after sub build.ninja.
+  if(NOT mtime_top_build_ninja STRGREATER mtime_sub_build_ninja)
+    message(FATAL_ERROR
+      "top build.ninja not regenerated strictly after sub build.ninja:
+  sub/build.ninja = ${mtime_sub_build_ninja}
+  build.ninja     = ${mtime_top_build_ninja}")
+  endif()
+
+endfunction(run_sub_cmake)
+
+if("${ninja_version}" VERSION_LESS 1.6)
+  message(WARNING "Ninja is too old; skipping rest of test.")
+  return()
+endif()
+
+foreach(ninja_output_path_prefix "sub space" "sub")
+  run_sub_cmake(Executable "${ninja_output_path_prefix}")
+  run_sub_cmake(StaticLib  "${ninja_output_path_prefix}")
+  run_sub_cmake(SharedLib "${ninja_output_path_prefix}")
+  run_sub_cmake(TwoLibs "${ninja_output_path_prefix}")
+  run_sub_cmake(SubDirPrefix "${ninja_output_path_prefix}")
+  run_sub_cmake(CustomCommandWorkingDirectory "${ninja_output_path_prefix}")
+endforeach(ninja_output_path_prefix)
diff --git a/Tests/RunCMake/Ninja/SharedLib.cmake b/Tests/RunCMake/Ninja/SharedLib.cmake
new file mode 100644
index 0000000..1a78390
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SharedLib.cmake
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.5)
+project(hello C)
+add_library(greeting SHARED greeting.c)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_executable(hello hello_with_greeting.c)
+target_link_libraries(hello greeting)
+include(CheckOutput.cmake)
+include(CheckNoPrefixSubDir.cmake)
diff --git a/Tests/RunCMake/Ninja/StaticLib.cmake b/Tests/RunCMake/Ninja/StaticLib.cmake
new file mode 100644
index 0000000..0f815ae
--- /dev/null
+++ b/Tests/RunCMake/Ninja/StaticLib.cmake
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.5)
+project(hello C)
+add_definitions(-DGREETING_STATIC)
+add_library(greeting STATIC greeting.c)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_executable(hello hello_with_greeting.c)
+target_link_libraries(hello greeting)
+include(CheckOutput.cmake)
+include(CheckNoPrefixSubDir.cmake)
diff --git a/Tests/RunCMake/Ninja/SubDir-build-stdout.txt b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt
new file mode 100644
index 0000000..e4b4662
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt
@@ -0,0 +1 @@
+Building InAll
diff --git a/Tests/RunCMake/Ninja/SubDir.cmake b/Tests/RunCMake/Ninja/SubDir.cmake
new file mode 100644
index 0000000..7224ec3
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDir.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(SubDir)
+add_custom_target(TopFail ALL COMMAND does_not_exist)
diff --git a/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt
new file mode 100644
index 0000000..73ae431
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_custom_target(SubFail COMMAND does_not_exist)
+add_custom_target(InAll ALL COMMAND ${CMAKE_COMMAND} -E echo "Building InAll")
diff --git a/Tests/RunCMake/Ninja/SubDirPrefix.cmake b/Tests/RunCMake/Ninja/SubDirPrefix.cmake
new file mode 100644
index 0000000..30ad1e6
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirPrefix.cmake
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.5)
+project(hello C)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+add_subdirectory(SubDirPrefix)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_executable(hello hello_sub_greeting.c)
+target_link_libraries(hello greeting)
+include(CheckOutput.cmake)
diff --git a/Tests/RunCMake/Ninja/SubDirPrefix/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDirPrefix/CMakeLists.txt
new file mode 100644
index 0000000..575597d
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirPrefix/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(greeting SHARED greeting.c)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/Tests/RunCMake/Ninja/SubDirPrefix/greeting.c b/Tests/RunCMake/Ninja/SubDirPrefix/greeting.c
new file mode 100644
index 0000000..ba3e55b
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirPrefix/greeting.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#if defined(_WIN32) && !defined(GREETING_STATIC)
+__declspec(dllexport)
+#endif
+  void greeting(void)
+{
+  printf("Hello world!\n");
+}
diff --git a/Tests/RunCMake/Ninja/SubDirPrefix/greeting.h b/Tests/RunCMake/Ninja/SubDirPrefix/greeting.h
new file mode 100644
index 0000000..ee4053e
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirPrefix/greeting.h
@@ -0,0 +1,4 @@
+#if defined(_WIN32) && !defined(GREETING_STATIC)
+__declspec(dllimport)
+#endif
+  void greeting(void);
diff --git a/Tests/RunCMake/Ninja/TwoLibs.cmake b/Tests/RunCMake/Ninja/TwoLibs.cmake
new file mode 100644
index 0000000..666452f
--- /dev/null
+++ b/Tests/RunCMake/Ninja/TwoLibs.cmake
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.5)
+project(hello C)
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib-static")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+
+add_library(greeting SHARED greeting.c)
+add_library(greeting2 STATIC greeting2.c)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+add_executable(hello hello_with_two_greetings.c)
+target_link_libraries(hello greeting greeting2)
+
+set(HELLO_OUTPUT_STRING "Hello world!\nHello world 2!\n")
+include(CheckOutput.cmake)
+
+include(CheckNoPrefixSubDir.cmake)
diff --git a/Tests/RunCMake/Ninja/greeting.c b/Tests/RunCMake/Ninja/greeting.c
new file mode 100644
index 0000000..ba3e55b
--- /dev/null
+++ b/Tests/RunCMake/Ninja/greeting.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#if defined(_WIN32) && !defined(GREETING_STATIC)
+__declspec(dllexport)
+#endif
+  void greeting(void)
+{
+  printf("Hello world!\n");
+}
diff --git a/Tests/RunCMake/Ninja/greeting.h b/Tests/RunCMake/Ninja/greeting.h
new file mode 100644
index 0000000..ee4053e
--- /dev/null
+++ b/Tests/RunCMake/Ninja/greeting.h
@@ -0,0 +1,4 @@
+#if defined(_WIN32) && !defined(GREETING_STATIC)
+__declspec(dllimport)
+#endif
+  void greeting(void);
diff --git a/Tests/RunCMake/Ninja/greeting2.c b/Tests/RunCMake/Ninja/greeting2.c
new file mode 100644
index 0000000..c6ed87d
--- /dev/null
+++ b/Tests/RunCMake/Ninja/greeting2.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void greeting2(void)
+{
+  printf("Hello world 2!\n");
+}
diff --git a/Tests/RunCMake/Ninja/greeting2.h b/Tests/RunCMake/Ninja/greeting2.h
new file mode 100644
index 0000000..c4d8f9b
--- /dev/null
+++ b/Tests/RunCMake/Ninja/greeting2.h
@@ -0,0 +1 @@
+void greeting2(void);
diff --git a/Tests/RunCMake/Ninja/hello.c b/Tests/RunCMake/Ninja/hello.c
new file mode 100644
index 0000000..aac8b4e
--- /dev/null
+++ b/Tests/RunCMake/Ninja/hello.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+  printf("Hello world!\n");
+  return 0;
+}
diff --git a/Tests/RunCMake/Ninja/hello_sub_greeting.c b/Tests/RunCMake/Ninja/hello_sub_greeting.c
new file mode 100644
index 0000000..fc4bd60
--- /dev/null
+++ b/Tests/RunCMake/Ninja/hello_sub_greeting.c
@@ -0,0 +1,7 @@
+#include <SubDirPrefix/greeting.h>
+
+int main(void)
+{
+  greeting();
+  return 0;
+}
diff --git a/Tests/RunCMake/Ninja/hello_with_greeting.c b/Tests/RunCMake/Ninja/hello_with_greeting.c
new file mode 100644
index 0000000..dbf90e3
--- /dev/null
+++ b/Tests/RunCMake/Ninja/hello_with_greeting.c
@@ -0,0 +1,7 @@
+#include <greeting.h>
+
+int main(void)
+{
+  greeting();
+  return 0;
+}
diff --git a/Tests/RunCMake/Ninja/hello_with_two_greetings.c b/Tests/RunCMake/Ninja/hello_with_two_greetings.c
new file mode 100644
index 0000000..cbbdaad
--- /dev/null
+++ b/Tests/RunCMake/Ninja/hello_with_two_greetings.c
@@ -0,0 +1,9 @@
+#include <greeting.h>
+#include <greeting2.h>
+
+int main(void)
+{
+  greeting();
+  greeting2();
+  return 0;
+}
diff --git a/Tests/RunCMake/ObjectLibrary/a.c b/Tests/RunCMake/ObjectLibrary/a.c
index af20d3f..1636303 100644
--- a/Tests/RunCMake/ObjectLibrary/a.c
+++ b/Tests/RunCMake/ObjectLibrary/a.c
@@ -1 +1,4 @@
-int a(void) { return 0; }
+int a(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/ObsoleteQtMacros/empty.cpp b/Tests/RunCMake/ObsoleteQtMacros/empty.cpp
index 7279c5e..8d91e77 100644
--- a/Tests/RunCMake/ObsoleteQtMacros/empty.cpp
+++ b/Tests/RunCMake/ObsoleteQtMacros/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty(void)
+  int empty(void)
 {
   return 0;
 }
diff --git a/Tests/RunCMake/PolicyScope/NotClosed-stderr.txt b/Tests/RunCMake/PolicyScope/NotClosed-stderr.txt
index 293d161..08c42a0 100644
--- a/Tests/RunCMake/PolicyScope/NotClosed-stderr.txt
+++ b/Tests/RunCMake/PolicyScope/NotClosed-stderr.txt
@@ -1,4 +1,4 @@
-^CMake Error at NotClosed.cmake:[0-9]+ \(include\):
+^CMake Error in NotClosed.cmake:
   cmake_policy PUSH without matching POP
 Call Stack \(most recent call first\):
   CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/PositionIndependentCode/main.cpp b/Tests/RunCMake/PositionIndependentCode/main.cpp
index 31ba482..e9ad257 100644
--- a/Tests/RunCMake/PositionIndependentCode/main.cpp
+++ b/Tests/RunCMake/PositionIndependentCode/main.cpp
@@ -1,5 +1,5 @@
 
-int main(int,char**)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index db9911d..fa0c980 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -51,11 +51,8 @@ function(run_cmake test)
   if(APPLE)
     list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
   endif()
-  if(RunCMake_GENERATOR STREQUAL "Visual Studio 6" AND NOT RunCMake_WARN_VS6)
-    list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS6=OFF)
-  endif()
-  if(RunCMake_GENERATOR STREQUAL "Visual Studio 7" AND NOT RunCMake_WARN_VS70)
-    list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS70=OFF)
+  if(RunCMake_GENERATOR STREQUAL "Visual Studio 7 .NET 2003" AND NOT RunCMake_WARN_VS71)
+    list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS71=OFF)
   endif()
   if(RunCMake_MAKE_PROGRAM)
     list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
diff --git a/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake b/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake
deleted file mode 100644
index 6ae158d..0000000
--- a/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-include(RunCMake)
-include(${CMAKE_CURRENT_LIST_DIR}/solution_parsing.cmake)
-
-run_cmake(OnePre)
-run_cmake(OnePost)
-run_cmake(MorePre)
-run_cmake(MorePost)
-run_cmake(PrePost)
-run_cmake(Override1)
-run_cmake(Override2)
diff --git a/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake b/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake
deleted file mode 100644
index dd158ef..0000000
--- a/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake
+++ /dev/null
@@ -1,60 +0,0 @@
-macro(error text)
-  set(RunCMake_TEST_FAILED "${text}")
-  return()
-endmacro()
-
-
-macro(parseGlobalSections arg_out_pre arg_out_post testName)
-  set(out_pre ${arg_out_pre})
-  set(out_post ${arg_out_post})
-  set(sln "${RunCMake_TEST_BINARY_DIR}/${testName}.sln")
-  if(NOT EXISTS "${sln}")
-    error("Expected solution file ${sln} does not exist")
-  endif()
-  file(STRINGS "${sln}" lines)
-  set(sectionLines "")
-  set(store FALSE)
-  foreach(line IN LISTS lines)
-    if(line MATCHES "^\t*Global\n?$")
-      set(store TRUE)
-    elseif(line MATCHES "^\t*EndGlobal\n?$")
-      set(store FALSE)
-    elseif(store)
-      list(APPEND sectionLines "${line}")
-    endif()
-  endforeach()
-  set(sectionName "")
-  set(sectionType "")
-  foreach(line IN LISTS sectionLines)
-    if(line MATCHES "^\t*GlobalSection\\((.*)\\) *= *(pre|post)Solution\n?$")
-      set(sectionName "${CMAKE_MATCH_1}")
-      set(sectionType ${CMAKE_MATCH_2})
-      list(APPEND ${out_${sectionType}} "${sectionName}")
-      if(DEFINED ${out_${sectionType}}_${sectionName})
-        error("Section ${sectionName} defined twice")
-      endif()
-      set(${out_${sectionType}}_${sectionName} "")
-    elseif(line MATCHES "\t*EndGlobalSection\n?$")
-      set(sectionName "")
-      set(sectionType "")
-    elseif(sectionName)
-      string(REGEX MATCH "^\t*([^=]*)=([^\n]*)\n?$" matches "${line}")
-      if(NOT matches)
-        error("Bad syntax in solution file: '${line}'")
-      endif()
-      string(STRIP "${CMAKE_MATCH_1}" key)
-      string(STRIP "${CMAKE_MATCH_2}" value)
-      list(APPEND ${out_${sectionType}}_${sectionName} "${key}=${value}")
-    endif()
-  endforeach()
-endmacro()
-
-
-macro(testGlobalSection prefix sectionName)
-  if(NOT DEFINED ${prefix}_${sectionName})
-    error("Section ${sectionName} does not exist")
-  endif()
-  if(NOT "${${prefix}_${sectionName}}" STREQUAL "${ARGN}")
-    error("Section ${sectionName} content mismatch\n  expected: ${ARGN}\n  actual: ${${prefix}_${sectionName}}")
-  endif()
-endmacro()
diff --git a/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt b/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
index 776a8f2..306c255 100644
--- a/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
+++ b/Tests/RunCMake/Syntax/FunctionUnmatched-stderr.txt
@@ -1,6 +1,8 @@
-^CMake Error at CMakeLists.txt:[0-9]+ \(include\):
+^CMake Error in FunctionUnmatched.cmake:
   A logical block opening on the line
 
     .*/Tests/RunCMake/Syntax/FunctionUnmatched.cmake:[0-9]+ \(function\)
 
-  is not closed.$
+  is not closed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt b/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
index 1699c43..440d863 100644
--- a/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
+++ b/Tests/RunCMake/Syntax/MacroUnmatched-stderr.txt
@@ -1,6 +1,8 @@
-^CMake Error at CMakeLists.txt:[0-9]+ \(include\):
+^CMake Error in MacroUnmatched.cmake:
   A logical block opening on the line
 
     .*/Tests/RunCMake/Syntax/MacroUnmatched.cmake:[0-9]+ \(macro\)
 
-  is not closed.$
+  is not closed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/TargetPolicies/empty.cpp b/Tests/RunCMake/TargetPolicies/empty.cpp
index 7279c5e..8d91e77 100644
--- a/Tests/RunCMake/TargetPolicies/empty.cpp
+++ b/Tests/RunCMake/TargetPolicies/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty(void)
+  int empty(void)
 {
   return 0;
 }
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
index fad7073..6fdcce7 100644
--- a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
@@ -25,7 +25,7 @@ Call Stack \(most recent call first\):
   OriginDebugIDE.cmake:4 \(include\)
   CMakeLists.txt:3 \(include\)
 +
-CMake Debug Log:
+CMake Debug Log in CMakeLists.txt:
   Used sources for target OriginDebug:
 
    * .*CMakeLists.txt
diff --git a/Tests/RunCMake/TargetSources/empty_1.cpp b/Tests/RunCMake/TargetSources/empty_1.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/TargetSources/empty_1.cpp
+++ b/Tests/RunCMake/TargetSources/empty_1.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/TargetSources/empty_2.cpp b/Tests/RunCMake/TargetSources/empty_2.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/TargetSources/empty_2.cpp
+++ b/Tests/RunCMake/TargetSources/empty_2.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/TargetSources/empty_3.cpp b/Tests/RunCMake/TargetSources/empty_3.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/TargetSources/empty_3.cpp
+++ b/Tests/RunCMake/TargetSources/empty_3.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/TargetSources/empty_4.cpp b/Tests/RunCMake/TargetSources/empty_4.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/TargetSources/empty_4.cpp
+++ b/Tests/RunCMake/TargetSources/empty_4.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/ToolchainFile/CMakeLists.txt b/Tests/RunCMake/ToolchainFile/CMakeLists.txt
new file mode 100644
index 0000000..93ee9df
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt
new file mode 100644
index 0000000..0de51c6
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at CallEnableLanguage-toolchain.cmake:[0-9]+ \(enable_language\):
+  Language 'NONE' is currently being enabled.  Recursive call not allowed.
+Call Stack \(most recent call first\):
+  .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+  CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake
new file mode 100644
index 0000000..8145101
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake
@@ -0,0 +1 @@
+enable_language(NONE)
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake
similarity index 100%
copy from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake
copy to Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake
diff --git a/Tests/RunCMake/ToolchainFile/CallProject-result.txt b/Tests/RunCMake/ToolchainFile/CallProject-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt
new file mode 100644
index 0000000..e2b9f1b
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at CallProject-toolchain.cmake:[0-9]+ \(project\):
+  Language 'NONE' is currently being enabled.  Recursive call not allowed.
+Call Stack \(most recent call first\):
+  .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+  CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake
new file mode 100644
index 0000000..b113c13
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake
@@ -0,0 +1 @@
+project(Bad NONE)
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/RunCMake/ToolchainFile/CallProject.cmake
similarity index 100%
copy from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake
copy to Tests/RunCMake/ToolchainFile/CallProject.cmake
diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
new file mode 100644
index 0000000..75293e7
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCMake)
+
+function(run_cmake_toolchain t)
+  set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${t}-toolchain.cmake)
+  run_cmake(${t})
+endfunction()
+
+run_cmake_toolchain(CallEnableLanguage)
+run_cmake_toolchain(CallProject)
diff --git a/Tests/RunCMake/VS10Project/CMakeLists.txt b/Tests/RunCMake/VS10Project/CMakeLists.txt
new file mode 100644
index 0000000..91baae7
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
new file mode 100644
index 0000000..cc2cc2e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -0,0 +1,2 @@
+include(RunCMake)
+run_cmake(VsConfigurationType)
diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
new file mode 100644
index 0000000..4690970
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
@@ -0,0 +1,24 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+  set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+  return()
+endif()
+
+set(propertyFound FALSE)
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+  if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$")
+    set(propertyFound TRUE)
+    set(expectedValue "MyValue")
+    set(actualValue ${CMAKE_MATCH_1})
+    if(NOT (${actualValue} STREQUAL ${expectedValue}))
+      set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".")
+      return()
+    endif()
+  endif()
+endforeach()
+
+if(NOT propertyFound)
+  set(RunCMake_TEST_FAILED "Property ConfigurationType not found in project file.")
+  return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
new file mode 100644
index 0000000..a73dfe8
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue")
diff --git a/Tests/RunCMake/VS10Project/foo.cpp b/Tests/RunCMake/VS10Project/foo.cpp
new file mode 100644
index 0000000..3695dc9
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/foo.cpp
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt b/Tests/RunCMake/VSSolution/CMakeLists.txt
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt
rename to Tests/RunCMake/VSSolution/CMakeLists.txt
diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake b/Tests/RunCMake/VSSolution/MorePost-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake
rename to Tests/RunCMake/VSSolution/MorePost-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePost.cmake b/Tests/RunCMake/VSSolution/MorePost.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/MorePost.cmake
rename to Tests/RunCMake/VSSolution/MorePost.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake b/Tests/RunCMake/VSSolution/MorePre-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake
rename to Tests/RunCMake/VSSolution/MorePre-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePre.cmake b/Tests/RunCMake/VSSolution/MorePre.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/MorePre.cmake
rename to Tests/RunCMake/VSSolution/MorePre.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake b/Tests/RunCMake/VSSolution/OnePost-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake
rename to Tests/RunCMake/VSSolution/OnePost-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePost.cmake b/Tests/RunCMake/VSSolution/OnePost.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/OnePost.cmake
rename to Tests/RunCMake/VSSolution/OnePost.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake b/Tests/RunCMake/VSSolution/OnePre-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake
rename to Tests/RunCMake/VSSolution/OnePre-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePre.cmake b/Tests/RunCMake/VSSolution/OnePre.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/OnePre.cmake
rename to Tests/RunCMake/VSSolution/OnePre.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake b/Tests/RunCMake/VSSolution/Override1-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake
rename to Tests/RunCMake/VSSolution/Override1-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/Override1.cmake b/Tests/RunCMake/VSSolution/Override1.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/Override1.cmake
rename to Tests/RunCMake/VSSolution/Override1.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake b/Tests/RunCMake/VSSolution/Override2-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake
rename to Tests/RunCMake/VSSolution/Override2-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/Override2.cmake b/Tests/RunCMake/VSSolution/Override2.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/Override2.cmake
rename to Tests/RunCMake/VSSolution/Override2.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake b/Tests/RunCMake/VSSolution/PrePost-check.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake
rename to Tests/RunCMake/VSSolution/PrePost-check.cmake
diff --git a/Tests/RunCMake/SolutionGlobalSections/PrePost.cmake b/Tests/RunCMake/VSSolution/PrePost.cmake
similarity index 100%
rename from Tests/RunCMake/SolutionGlobalSections/PrePost.cmake
rename to Tests/RunCMake/VSSolution/PrePost.cmake
diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake
new file mode 100644
index 0000000..afd74a1
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake
@@ -0,0 +1,16 @@
+include(RunCMake)
+include(${CMAKE_CURRENT_LIST_DIR}/solution_parsing.cmake)
+
+run_cmake(OnePre)
+run_cmake(OnePost)
+run_cmake(MorePre)
+run_cmake(MorePost)
+run_cmake(PrePost)
+run_cmake(Override1)
+run_cmake(Override2)
+run_cmake(StartupProject)
+run_cmake(StartupProjectMissing)
+
+if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS)
+  run_cmake(StartupProjectUseFolders)
+endif()
diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake
new file mode 100644
index 0000000..f36aab2
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake
@@ -0,0 +1,5 @@
+getProjectNames(projects)
+list(GET projects 0 first_project)
+if(NOT first_project STREQUAL "TestStartup")
+  error("TestStartup is not the startup project")
+endif()
diff --git a/Tests/RunCMake/VSSolution/StartupProject.cmake b/Tests/RunCMake/VSSolution/StartupProject.cmake
new file mode 100644
index 0000000..7192f3d
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProject.cmake
@@ -0,0 +1,2 @@
+add_custom_target(TestStartup)
+set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup")
diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake
new file mode 100644
index 0000000..b1017dd
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake
@@ -0,0 +1,5 @@
+getProjectNames(projects)
+list(GET projects 0 first_project)
+if(NOT first_project STREQUAL "ALL_BUILD")
+  error("ALL_BUILD is not the startup project")
+endif()
diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt
new file mode 100644
index 0000000..da92c6d
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+  Directory property VS_STARTUP_PROJECT specifies target 'DoesNotExist' that
+  does not exist.  Ignoring.
+This warning is for project developers.  Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake
new file mode 100644
index 0000000..907a877
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake
@@ -0,0 +1 @@
+set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "DoesNotExist")
diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake
new file mode 100644
index 0000000..c0a545a
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake
@@ -0,0 +1,9 @@
+getProjectNames(projects)
+list(GET projects 0 first_project)
+if(NOT first_project STREQUAL "CMakePredefinedTargets")
+  error("CMakePredefinedTargets is not the first project")
+endif()
+list(GET projects 1 second_project)
+if(NOT second_project STREQUAL "TestStartup")
+  error("TestStartup does not immediately follow the CMakePredefinedTargets project")
+endif()
diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake
new file mode 100644
index 0000000..8e422a4
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake
@@ -0,0 +1,3 @@
+add_custom_target(TestStartup)
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup")
diff --git a/Tests/RunCMake/VSSolution/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake
new file mode 100644
index 0000000..4e5bb59
--- /dev/null
+++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake
@@ -0,0 +1,75 @@
+macro(error text)
+  set(RunCMake_TEST_FAILED "${text}")
+  return()
+endmacro()
+
+
+macro(parseGlobalSections arg_out_pre arg_out_post testName)
+  set(out_pre ${arg_out_pre})
+  set(out_post ${arg_out_post})
+  set(sln "${RunCMake_TEST_BINARY_DIR}/${testName}.sln")
+  if(NOT EXISTS "${sln}")
+    error("Expected solution file ${sln} does not exist")
+  endif()
+  file(STRINGS "${sln}" lines)
+  set(sectionLines "")
+  set(store FALSE)
+  foreach(line IN LISTS lines)
+    if(line MATCHES "^\t*Global\n?$")
+      set(store TRUE)
+    elseif(line MATCHES "^\t*EndGlobal\n?$")
+      set(store FALSE)
+    elseif(store)
+      list(APPEND sectionLines "${line}")
+    endif()
+  endforeach()
+  set(sectionName "")
+  set(sectionType "")
+  foreach(line IN LISTS sectionLines)
+    if(line MATCHES "^\t*GlobalSection\\((.*)\\) *= *(pre|post)Solution\n?$")
+      set(sectionName "${CMAKE_MATCH_1}")
+      set(sectionType ${CMAKE_MATCH_2})
+      list(APPEND ${out_${sectionType}} "${sectionName}")
+      if(DEFINED ${out_${sectionType}}_${sectionName})
+        error("Section ${sectionName} defined twice")
+      endif()
+      set(${out_${sectionType}}_${sectionName} "")
+    elseif(line MATCHES "\t*EndGlobalSection\n?$")
+      set(sectionName "")
+      set(sectionType "")
+    elseif(sectionName)
+      string(REGEX MATCH "^\t*([^=]*)=([^\n]*)\n?$" matches "${line}")
+      if(NOT matches)
+        error("Bad syntax in solution file: '${line}'")
+      endif()
+      string(STRIP "${CMAKE_MATCH_1}" key)
+      string(STRIP "${CMAKE_MATCH_2}" value)
+      list(APPEND ${out_${sectionType}}_${sectionName} "${key}=${value}")
+    endif()
+  endforeach()
+endmacro()
+
+
+macro(getProjectNames arg_out_projects)
+  set(${arg_out_projects} "")
+  set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln")
+  if(NOT EXISTS "${sln}")
+    error("Expected solution file ${sln} does not exist")
+  endif()
+  file(STRINGS "${sln}" project_lines REGEX "^Project\\(")
+  foreach(project_line IN LISTS project_lines)
+    string(REGEX REPLACE ".* = \"" "" project_line "${project_line}")
+    string(REGEX REPLACE "\", .*"  "" project_line "${project_line}")
+    list(APPEND ${arg_out_projects} "${project_line}")
+  endforeach()
+endmacro()
+
+
+macro(testGlobalSection prefix sectionName)
+  if(NOT DEFINED ${prefix}_${sectionName})
+    error("Section ${sectionName} does not exist")
+  endif()
+  if(NOT "${${prefix}_${sectionName}}" STREQUAL "${ARGN}")
+    error("Section ${sectionName} content mismatch\n  expected: ${ARGN}\n  actual: ${${prefix}_${sectionName}}")
+  endif()
+endmacro()
diff --git a/Tests/RunCMake/XcodeProject/foo.cpp b/Tests/RunCMake/XcodeProject/foo.cpp
index 2fb55ee..3695dc9 100644
--- a/Tests/RunCMake/XcodeProject/foo.cpp
+++ b/Tests/RunCMake/XcodeProject/foo.cpp
@@ -1 +1,3 @@
-void foo() { }
+void foo()
+{
+}
diff --git a/Tests/RunCMake/XcodeProject/main.cpp b/Tests/RunCMake/XcodeProject/main.cpp
index 1695921..c94753f 100644
--- a/Tests/RunCMake/XcodeProject/main.cpp
+++ b/Tests/RunCMake/XcodeProject/main.cpp
@@ -1,3 +1,4 @@
-int main(int argc, const char * argv[]) {
-    return 0;
+int main(int argc, const char* argv[])
+{
+  return 0;
 }
diff --git a/Tests/RunCMake/alias_targets/empty.cpp b/Tests/RunCMake/alias_targets/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/alias_targets/empty.cpp
+++ b/Tests/RunCMake/alias_targets/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake
index 72c82ab..028bfaf 100644
--- a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake
@@ -29,6 +29,26 @@ macro(foo)
 endmacro()
 
 foo(FOO foo)
+TEST(_FOO1_FOO foo)
+TEST(_FOO2_FOO foo)
 
+# Make sure a list is split
+foo(FOO "foo;bar")
 TEST(_FOO1_FOO foo)
+TEST(_FOO1_UNPARSED_ARGUMENTS "bar")
 TEST(_FOO2_FOO foo)
+TEST(_FOO2_UNPARSED_ARGUMENTS "bar")
+
+# Do not split if argn is quoted
+foo(FOO "foo\\;bar")
+TEST(_FOO1_FOO foo)
+TEST(_FOO1_UNPARSED_ARGUMENTS "bar")
+TEST(_FOO2_FOO foo;bar)
+TEST(_FOO2_UNPARSED_ARGUMENTS "UNDEFINED")
+
+# Do not split if argn is quoted
+foo(FOO "foo\\\\;bar")
+TEST(_FOO1_FOO foo)
+TEST(_FOO1_UNPARSED_ARGUMENTS "bar")
+TEST(_FOO2_FOO foo;bar)
+TEST(_FOO2_UNPARSED_ARGUMENTS "UNDEFINED")
diff --git a/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake b/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake
index 462f923..b4199ea 100644
--- a/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake
@@ -25,6 +25,9 @@ TEST(pref_OPT1 TRUE)
 cmake_parse_arguments(pref "OPT1;OPT2" "" "" OPT1 OPT2)
 TEST(pref_OPT1 TRUE)
 TEST(pref_OPT2 TRUE)
+cmake_parse_arguments(pref "OPT1;OPT2" "" "" "OPT1;OPT2")
+TEST(pref_OPT1 TRUE)
+TEST(pref_OPT2 TRUE)
 cmake_parse_arguments(pref "OPT1;OPT2" "" "")
 TEST(pref_OPT1 FALSE)
 TEST(pref_OPT2 FALSE)
@@ -44,6 +47,9 @@ TEST(pref_SINGLE1 foo)
 cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "" SINGLE1 foo SINGLE2 bar)
 TEST(pref_SINGLE1 foo)
 TEST(pref_SINGLE2 bar)
+cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "" "SINGLE1;foo;SINGLE2;bar")
+TEST(pref_SINGLE1 foo)
+TEST(pref_SINGLE2 bar)
 cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "")
 TEST(pref_SINGLE1 UNDEFINED)
 TEST(pref_SINGLE2 UNDEFINED)
@@ -63,6 +69,9 @@ TEST(pref_MULTI1 foo)
 cmake_parse_arguments(pref "" "" "MULTI1;MULTI2" MULTI1 foo bar MULTI2 bar foo)
 TEST(pref_MULTI1 foo bar)
 TEST(pref_MULTI2 bar foo)
+cmake_parse_arguments(pref "" "" "MULTI1;MULTI2" "MULTI1;foo;bar;MULTI2;bar;foo")
+TEST(pref_MULTI1 foo bar)
+TEST(pref_MULTI2 bar foo)
 cmake_parse_arguments(pref "" "" "MULTI1;MULTI2")
 TEST(pref_MULTI1 UNDEFINED)
 TEST(pref_MULTI2 UNDEFINED)
diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt
new file mode 100644
index 0000000..406e315
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at DOWNLOAD-hash-mismatch.cmake:[0-9]+ \(file\):
+  file DOWNLOAD HASH mismatch
+
+    for file: \[.*/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-build/hash-mismatch.txt\]
+      expected hash: \[0123456789abcdef0123456789abcdef01234567\]
+        actual hash: \[da39a3ee5e6b4b0d3255bfef95601890afd80709\]
+             status: \[0;"No error"\]
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)
++
+status='1;HASH mismatch: expected: 0123456789abcdef0123456789abcdef01234567 actual: da39a3ee5e6b4b0d3255bfef95601890afd80709'$
diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake
new file mode 100644
index 0000000..ca72692
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake
@@ -0,0 +1,7 @@
+file(DOWNLOAD
+  "file://${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-hash-mismatch.txt"
+  ${CMAKE_CURRENT_BINARY_DIR}/hash-mismatch.txt
+  EXPECTED_HASH SHA1=0123456789abcdef0123456789abcdef01234567
+  STATUS status
+  )
+message("status='${status}'")
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt
similarity index 100%
copy from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake
copy to Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt
diff --git a/Tests/RunCMake/file/GLOB.cmake b/Tests/RunCMake/file/GLOB.cmake
index 3d577e3..c524e42 100644
--- a/Tests/RunCMake/file/GLOB.cmake
+++ b/Tests/RunCMake/file/GLOB.cmake
@@ -12,17 +12,14 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir fi
 file(GLOB CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
 
 file(GLOB CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
 
 file(GLOB CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
index a8c6784..fb8be42 100644
--- a/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
+++ b/Tests/RunCMake/file/GLOB_RECURSE-cyclic-recursion.cmake
@@ -7,17 +7,14 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINA
 file(GLOB_RECURSE CONTENT_LIST FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
 
 file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
 
 file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true FOLLOW_SYMLINKS "${CMAKE_CURRENT_BINARY_DIR}/test/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB_RECURSE.cmake b/Tests/RunCMake/file/GLOB_RECURSE.cmake
index 6db377b..530930f 100644
--- a/Tests/RunCMake/file/GLOB_RECURSE.cmake
+++ b/Tests/RunCMake/file/GLOB_RECURSE.cmake
@@ -12,17 +12,14 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/dir 2/non_empty_dir/dir 2 subdir fi
 file(GLOB_RECURSE CONTENT_LIST "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
 
 file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
 
 file(GLOB_RECURSE CONTENT_LIST LIST_DIRECTORIES true "${CMAKE_CURRENT_BINARY_DIR}/test/*/*")
 list(LENGTH CONTENT_LIST CONTENT_COUNT)
 message("content: ${CONTENT_COUNT} ")
-list(SORT CONTENT_LIST)
 message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index d3dfb1b..5f85bba 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -1,5 +1,6 @@
 include(RunCMake)
 
+run_cmake(DOWNLOAD-hash-mismatch)
 run_cmake(INSTALL-DIRECTORY)
 run_cmake(INSTALL-MESSAGE-bad)
 run_cmake(FileOpenFailRead)
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index 014f397..5ce96e0 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -1,3 +1,5 @@
 include(RunCMake)
 
-run_cmake(PrefixInPATH)
+if(WIN32 OR CYGWIN)
+  run_cmake(PrefixInPATH)
+endif()
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
index 136031c..5733965 100644
--- a/Tests/RunCMake/find_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -1,4 +1,6 @@
 include(RunCMake)
 
 run_cmake(Created)
-run_cmake(PrefixInPATH)
+if(WIN32 OR CYGWIN)
+  run_cmake(PrefixInPATH)
+endif()
diff --git a/Tests/RunCMake/find_package/PolicyPush-stderr.txt b/Tests/RunCMake/find_package/PolicyPush-stderr.txt
index 1afcb16..73cf2e6 100644
--- a/Tests/RunCMake/find_package/PolicyPush-stderr.txt
+++ b/Tests/RunCMake/find_package/PolicyPush-stderr.txt
@@ -1,4 +1,4 @@
-^CMake Error at PolicyPush/PolicyPushConfigVersion.cmake:1 \(find_package\):
+^CMake Error in PolicyPush/PolicyPushConfigVersion.cmake:
   cmake_policy PUSH without matching POP
 Call Stack \(most recent call first\):
   PolicyPush.cmake:1 \(find_package\)
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake
index 014f397..5ce96e0 100644
--- a/Tests/RunCMake/find_path/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake
@@ -1,3 +1,5 @@
 include(RunCMake)
 
-run_cmake(PrefixInPATH)
+if(WIN32 OR CYGWIN)
+  run_cmake(PrefixInPATH)
+endif()
diff --git a/Tests/RunCMake/include/empty.cpp b/Tests/RunCMake/include/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/include/empty.cpp
+++ b/Tests/RunCMake/include/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake
new file mode 100644
index 0000000..0368df1
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src-all;src-all/main\.c$]])
diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake
new file mode 100644
index 0000000..41a816f
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src-exc;src-exc/main\.c$]])
diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake
new file mode 100644
index 0000000..68a1378
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src-all;src-all/main\.c;src-uns;src-uns/main\.c$]])
diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake
new file mode 100644
index 0000000..720299b
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake
@@ -0,0 +1,3 @@
+install(FILES main.c DESTINATION src-all)
+install(FILES main.c DESTINATION src-uns EXCLUDE_FROM_ALL)
+install(FILES main.c DESTINATION src-exc EXCLUDE_FROM_ALL COMPONENT exc)
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index c2347d8..45693b5 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -1,4 +1,46 @@
+cmake_minimum_required(VERSION 3.4)
 include(RunCMake)
+
+# Function to build and install a project.  The latter step *-check.cmake
+# scripts can check installed files using the check_installed function.
+function(run_install_test case)
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+  run_cmake(${case})
+  run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug)
+  # Check "all" components.
+  set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-all)
+  run_cmake_command(${case}-all ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -P cmake_install.cmake)
+  # Check unspecified component.
+  set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-uns)
+  run_cmake_command(${case}-uns ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=Unspecified -P cmake_install.cmake)
+  # Check explicit component.
+  set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-exc)
+  run_cmake_command(${case}-exc ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=exc -P cmake_install.cmake)
+endfunction()
+
+# Function called in *-check.cmake scripts to check installed files.
+function(check_installed expect)
+  file(GLOB_RECURSE actual
+    LIST_DIRECTORIES TRUE
+    RELATIVE ${CMAKE_INSTALL_PREFIX}
+    ${CMAKE_INSTALL_PREFIX}/*
+    )
+  if(actual)
+    list(SORT actual)
+  endif()
+  if(NOT "${actual}" MATCHES "${expect}")
+    set(RunCMake_TEST_FAILED "Installed files:
+  ${actual}
+do not match what we expected:
+  ${expect}
+in directory:
+  ${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE)
+  endif()
+endfunction()
+
 run_cmake(DIRECTORY-MESSAGE_NEVER)
 run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER)
 run_cmake(DIRECTORY-message)
@@ -14,3 +56,6 @@ run_cmake(EXPORT-OldIFace)
 run_cmake(CMP0062-OLD)
 run_cmake(CMP0062-NEW)
 run_cmake(CMP0062-WARN)
+
+run_install_test(FILES-EXCLUDE_FROM_ALL)
+run_install_test(TARGETS-EXCLUDE_FROM_ALL)
diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake
new file mode 100644
index 0000000..9b538bb
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin-all;bin-all/myexe(\.exe)?$]])
diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake
new file mode 100644
index 0000000..aef0d27
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin-exc;bin-exc/myexe(\.exe)?$]])
diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake
new file mode 100644
index 0000000..56fd264
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin-all;bin-all/myexe(\.exe)?;bin-uns;bin-uns/myexe(\.exe)?$]])
diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake
new file mode 100644
index 0000000..6fb2036
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+add_executable(myexe main.c)
+install(TARGETS myexe DESTINATION bin-all)
+install(TARGETS myexe DESTINATION bin-uns EXCLUDE_FROM_ALL)
+install(TARGETS myexe DESTINATION bin-exc EXCLUDE_FROM_ALL COMPONENT exc)
diff --git a/Tests/RunCMake/install/main.c b/Tests/RunCMake/install/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/install/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/list/EmptyFilterRegex-result.txt b/Tests/RunCMake/list/EmptyFilterRegex-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/list/EmptyFilterRegex-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/RunCMake/list/EmptyFilterRegex-stderr.txt
similarity index 100%
rename from Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake
rename to Tests/RunCMake/list/EmptyFilterRegex-stderr.txt
diff --git a/Tests/RunCMake/list/EmptyFilterRegex.cmake b/Tests/RunCMake/list/EmptyFilterRegex.cmake
new file mode 100644
index 0000000..33849cd
--- /dev/null
+++ b/Tests/RunCMake/list/EmptyFilterRegex.cmake
@@ -0,0 +1,2 @@
+set(mylist "")
+list(FILTER mylist INCLUDE REGEX "^FILTER_THIS_.+")
diff --git a/Tests/RunCMake/list/FILTER-NotList-result.txt b/Tests/RunCMake/list/FILTER-NotList-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-NotList-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/FILTER-NotList-stderr.txt b/Tests/RunCMake/list/FILTER-NotList-stderr.txt
new file mode 100644
index 0000000..159c28d
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-NotList-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at FILTER-NotList.cmake:2 \(list\):
+  list sub-command FILTER requires list to be present.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-NotList.cmake b/Tests/RunCMake/list/FILTER-NotList.cmake
new file mode 100644
index 0000000..1e15635
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-NotList.cmake
@@ -0,0 +1,2 @@
+unset(nosuchlist)
+list(FILTER nosuchlist EXCLUDE REGEX "^FILTER_THIS_.+")
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-result.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-stderr.txt
new file mode 100644
index 0000000..7f783fa
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at FILTER-REGEX-InvalidMode.cmake:2 \(list\):
+  list sub-command FILTER does not recognize mode NOOP
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake
new file mode 100644
index 0000000..e02b929
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake
@@ -0,0 +1,2 @@
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+list(FILTER mylist EXCLUDE NOOP "^FILTER_THIS_.+")
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-result.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-stderr.txt
new file mode 100644
index 0000000..94f2427
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at FILTER-REGEX-InvalidOperator.cmake:2 \(list\):
+  list sub-command FILTER does not recognize operator RM
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator.cmake b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator.cmake
new file mode 100644
index 0000000..9624622
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator.cmake
@@ -0,0 +1,2 @@
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+list(FILTER mylist RM REGEX "^FILTER_THIS_.+")
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-result.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-stderr.txt
new file mode 100644
index 0000000..9e98cbf
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at FILTER-REGEX-InvalidRegex.cmake:2 \(list\):
+  list sub-command FILTER, mode REGEX failed to compile regex "UHOH!\)\(".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex.cmake b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex.cmake
new file mode 100644
index 0000000..0641062
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex.cmake
@@ -0,0 +1,2 @@
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+list(FILTER mylist EXCLUDE REGEX "UHOH!)(")
diff --git a/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-result.txt b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-stderr.txt
new file mode 100644
index 0000000..ec7f41c
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at FILTER-REGEX-TooManyArguments.cmake:2 \(list\):
+  list sub-command FILTER, mode REGEX requires five arguments.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments.cmake b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments.cmake
new file mode 100644
index 0000000..d9cd8eb
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+list(FILTER mylist EXCLUDE REGEX "^FILTER_THIS_.+" one_too_many)
diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt
new file mode 100644
index 0000000..d9ba38d
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt
@@ -0,0 +1,2 @@
+^mylist was: FILTER_THIS_BIT;DO_NOT_FILTER_THIS;thisisanitem;FILTER_THIS_THING
+mylist is: DO_NOT_FILTER_THIS;thisisanitem$
diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake b/Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake
new file mode 100644
index 0000000..f395e61
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake
@@ -0,0 +1,4 @@
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+message("mylist was: ${mylist}")
+list(FILTER mylist EXCLUDE REGEX "^FILTER_THIS_.+")
+message("mylist is: ${mylist}")
diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt
new file mode 100644
index 0000000..5e5280d
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt
@@ -0,0 +1,2 @@
+^mylist was: FILTER_THIS_BIT;DO_NOT_FILTER_THIS;thisisanitem;FILTER_THIS_THING
+mylist is: FILTER_THIS_BIT;FILTER_THIS_THING$
diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake b/Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake
new file mode 100644
index 0000000..e659281
--- /dev/null
+++ b/Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake
@@ -0,0 +1,4 @@
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+message("mylist was: ${mylist}")
+list(FILTER mylist INCLUDE REGEX "^FILTER_THIS_.+")
+message("mylist is: ${mylist}")
diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake
index 25d6a03..b002ab3 100644
--- a/Tests/RunCMake/list/RunCMakeTest.cmake
+++ b/Tests/RunCMake/list/RunCMakeTest.cmake
@@ -1,5 +1,6 @@
 include(RunCMake)
 
+run_cmake(EmptyFilterRegex)
 run_cmake(EmptyGet0)
 run_cmake(EmptyRemoveAt0)
 run_cmake(EmptyInsert-1)
@@ -8,17 +9,25 @@ run_cmake(NoArguments)
 run_cmake(InvalidSubcommand)
 run_cmake(GET-CMP0007-WARN)
 
+run_cmake(FILTER-REGEX-InvalidRegex)
 run_cmake(GET-InvalidIndex)
 run_cmake(INSERT-InvalidIndex)
 run_cmake(REMOVE_AT-InvalidIndex)
 
+run_cmake(FILTER-REGEX-TooManyArguments)
 run_cmake(LENGTH-TooManyArguments)
 run_cmake(REMOVE_DUPLICATES-TooManyArguments)
 run_cmake(REVERSE-TooManyArguments)
 run_cmake(SORT-TooManyArguments)
 
+run_cmake(FILTER-NotList)
 run_cmake(REMOVE_AT-NotList)
 run_cmake(REMOVE_DUPLICATES-NotList)
 run_cmake(REMOVE_ITEM-NotList)
 run_cmake(REVERSE-NotList)
 run_cmake(SORT-NotList)
+
+run_cmake(FILTER-REGEX-InvalidMode)
+run_cmake(FILTER-REGEX-InvalidOperator)
+run_cmake(FILTER-REGEX-Valid0)
+run_cmake(FILTER-REGEX-Valid1)
diff --git a/Tests/RunCMake/pseudo_emulator.c b/Tests/RunCMake/pseudo_emulator.c
index 9308f75..15f64dc 100644
--- a/Tests/RunCMake/pseudo_emulator.c
+++ b/Tests/RunCMake/pseudo_emulator.c
@@ -1,15 +1,14 @@
 #include <stdio.h>
 
-int main(int argc, char * argv[] )
+int main(int argc, char* argv[])
 {
- int ii;
+  int ii;
 
- printf("Command:");
- for(ii = 1; ii < argc; ++ii)
- {
- printf(" \"%s\"", argv[ii]);
- }
- printf("\n");
+  printf("Command:");
+  for (ii = 1; ii < argc; ++ii) {
+    printf(" \"%s\"", argv[ii]);
+  }
+  printf("\n");
 
- return 42;
+  return 42;
 }
diff --git a/Tests/RunCMake/pseudo_emulator_custom_command.c b/Tests/RunCMake/pseudo_emulator_custom_command.c
new file mode 100644
index 0000000..760e83c
--- /dev/null
+++ b/Tests/RunCMake/pseudo_emulator_custom_command.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Usage:
+//
+//  /path/to/program arg1 [arg2 [...]]
+//
+// Return EXIT_SUCCESS if 'generated_exe_emulator_expected'
+// string was found in <arg1>.
+// Return EXIT_FAILURE if 'generated_exe_emulator_unexpected'
+// string was found in <arg1>.
+
+int main(int argc, const char* argv[])
+{
+  const char* substring_failure = "generated_exe_emulator_unexpected";
+  const char* substring_success = "generated_exe_emulator_expected";
+  const char* str = argv[1];
+  if (argc < 2) {
+    return EXIT_FAILURE;
+  }
+  if (strstr(str, substring_success) != 0) {
+    return EXIT_SUCCESS;
+  }
+  if (strstr(str, substring_failure) != 0) {
+    return EXIT_FAILURE;
+  }
+  fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success,
+          str);
+  return EXIT_FAILURE;
+}
diff --git a/Tests/RunCMake/pseudo_tidy.c b/Tests/RunCMake/pseudo_tidy.c
new file mode 100644
index 0000000..c950d03
--- /dev/null
+++ b/Tests/RunCMake/pseudo_tidy.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main(int argc, char* argv[])
+{
+  int i;
+  for (i = 1; i < argc; ++i) {
+    if (argv[i][0] != '-') {
+      fprintf(stdout, "%s:0:0: warning: message [checker]\n", argv[i]);
+      break;
+    }
+  }
+  fprintf(stderr, "1 warning generated.\n");
+  return 0;
+}
diff --git a/Tests/RunCMake/target_compile_features/empty.c b/Tests/RunCMake/target_compile_features/empty.c
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/target_compile_features/empty.c
+++ b/Tests/RunCMake/target_compile_features/empty.c
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/target_compile_features/empty.cpp b/Tests/RunCMake/target_compile_features/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/target_compile_features/empty.cpp
+++ b/Tests/RunCMake/target_compile_features/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/target_link_libraries/empty.cpp b/Tests/RunCMake/target_link_libraries/empty.cpp
index bfbbdde..11ec041 100644
--- a/Tests/RunCMake/target_link_libraries/empty.cpp
+++ b/Tests/RunCMake/target_link_libraries/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty()
+  int empty()
 {
   return 0;
 }
diff --git a/Tests/RunCMake/try_compile/PlatformVariables.cmake b/Tests/RunCMake/try_compile/PlatformVariables.cmake
new file mode 100644
index 0000000..54da645
--- /dev/null
+++ b/Tests/RunCMake/try_compile/PlatformVariables.cmake
@@ -0,0 +1,23 @@
+enable_language(C)
+
+# Normally this variable should be set by a platform information module or
+# a toolchain file, but for purposes of this test we simply set it here.
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES MY_CUSTOM_VARIABLE)
+
+set(MY_CUSTOM_VARIABLE SOME_VALUE)
+
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+  SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+  OUTPUT_VARIABLE out
+  )
+if(NOT result)
+  message(FATAL_ERROR "try_compile failed:\n${out}")
+endif()
+
+# Check that the cache was populated with our custom variable.
+file(STRINGS ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeCache.txt entries
+  REGEX MY_CUSTOM_VARIABLE:UNINITIALIZED=${MY_CUSTOM_VARIABLE}
+  )
+if(NOT entries)
+  message(FATAL_ERROR "try_compile did not populate cache as expected")
+endif()
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index 6cdbafa..4f30f1d 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -16,6 +16,14 @@ run_cmake(BadSources2)
 run_cmake(NonSourceCopyFile)
 run_cmake(NonSourceCompileDefinitions)
 
+set(RunCMake_TEST_OPTIONS --debug-trycompile)
+run_cmake(PlatformVariables)
+unset(RunCMake_TEST_OPTIONS)
+
+run_cmake(TargetTypeExe)
+run_cmake(TargetTypeInvalid)
+run_cmake(TargetTypeStatic)
+
 run_cmake(CMP0056)
 
 if(RunCMake_GENERATOR MATCHES "Make|Ninja")
diff --git a/Tests/RunCMake/try_compile/TargetTypeExe.cmake b/Tests/RunCMake/try_compile/TargetTypeExe.cmake
new file mode 100644
index 0000000..9b6e727
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeExe.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+  SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+  OUTPUT_VARIABLE out
+  COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy
+  COPY_FILE_ERROR copy_err
+  )
+if(NOT result)
+  message(FATAL_ERROR "try_compile failed:\n${out}")
+endif()
+if(copy_err)
+  message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}")
+endif()
diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt
new file mode 100644
index 0000000..08b281a
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TargetTypeInvalid.cmake:2 \(try_compile\):
+  Invalid value 'INVALID' for CMAKE_TRY_COMPILE_TARGET_TYPE.  Only
+  'EXECUTABLE' and 'STATIC_LIBRARY' are allowed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake
new file mode 100644
index 0000000..0bbc4ac
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_TRY_COMPILE_TARGET_TYPE INVALID)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c)
diff --git a/Tests/RunCMake/try_compile/TargetTypeStatic.cmake b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake
new file mode 100644
index 0000000..006b8b8
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+  SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/other.c
+  OUTPUT_VARIABLE out
+  COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy
+  COPY_FILE_ERROR copy_err
+  )
+if(NOT result)
+  message(FATAL_ERROR "try_compile failed:\n${out}")
+endif()
+if(copy_err)
+  message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}")
+endif()
diff --git a/Tests/RunCMake/try_compile/other.c b/Tests/RunCMake/try_compile/other.c
new file mode 100644
index 0000000..85c4ef8
--- /dev/null
+++ b/Tests/RunCMake/try_compile/other.c
@@ -0,0 +1,4 @@
+int other(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/try_compile/src.c b/Tests/RunCMake/try_compile/src.c
index 78f2de1..8488f4e 100644
--- a/Tests/RunCMake/try_compile/src.c
+++ b/Tests/RunCMake/try_compile/src.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/try_run/src.c b/Tests/RunCMake/try_run/src.c
index 78f2de1..8488f4e 100644
--- a/Tests/RunCMake/try_run/src.c
+++ b/Tests/RunCMake/try_run/src.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/while/EndMismatch-stderr.txt b/Tests/RunCMake/while/EndMismatch-stderr.txt
index d7439e8..54d299f 100644
--- a/Tests/RunCMake/while/EndMismatch-stderr.txt
+++ b/Tests/RunCMake/while/EndMismatch-stderr.txt
@@ -1,4 +1,4 @@
-^CMake Warning \(dev\) at EndMismatch.cmake:3 \(include\):
+^CMake Warning \(dev\) in EndMismatch.cmake:
   A logical block opening on the line
 
     .*/Tests/RunCMake/while/EndMismatch.cmake:1 \(while\)
diff --git a/Tests/RunCMake/while/EndMissing-stderr.txt b/Tests/RunCMake/while/EndMissing-stderr.txt
index 099a8b2..964792f 100644
--- a/Tests/RunCMake/while/EndMissing-stderr.txt
+++ b/Tests/RunCMake/while/EndMissing-stderr.txt
@@ -1,6 +1,8 @@
-^CMake Error at CMakeLists.txt:3 \(include\):
+^CMake Error in EndMissing.cmake:
   A logical block opening on the line
 
     .*/Tests/RunCMake/while/EndMissing.cmake:1 \(while\)
 
-  is not closed.$
+  is not closed.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RuntimePath/bar1.c b/Tests/RuntimePath/bar1.c
index ebad8d2..5dc5ec9 100644
--- a/Tests/RuntimePath/bar1.c
+++ b/Tests/RuntimePath/bar1.c
@@ -1,2 +1,5 @@
 extern int foo1();
-int bar1() { return foo1(); }
+int bar1()
+{
+  return foo1();
+}
diff --git a/Tests/RuntimePath/bar2.c b/Tests/RuntimePath/bar2.c
index 60d5e68..9035489 100644
--- a/Tests/RuntimePath/bar2.c
+++ b/Tests/RuntimePath/bar2.c
@@ -1,2 +1,5 @@
 extern int foo2();
-int bar2() { return foo2(); }
+int bar2()
+{
+  return foo2();
+}
diff --git a/Tests/RuntimePath/foo1.c b/Tests/RuntimePath/foo1.c
index 27cd912..dfcb0b7 100644
--- a/Tests/RuntimePath/foo1.c
+++ b/Tests/RuntimePath/foo1.c
@@ -1 +1,4 @@
-int foo1() { return 0; }
+int foo1()
+{
+  return 0;
+}
diff --git a/Tests/RuntimePath/foo2.c b/Tests/RuntimePath/foo2.c
index 40b4f56..12a3e77 100644
--- a/Tests/RuntimePath/foo2.c
+++ b/Tests/RuntimePath/foo2.c
@@ -1 +1,4 @@
-int foo2() { return 0; }
+int foo2()
+{
+  return 0;
+}
diff --git a/Tests/SBCS/SBCS.cxx b/Tests/SBCS/SBCS.cxx
index 6ce2c9f..68c2283 100644
--- a/Tests/SBCS/SBCS.cxx
+++ b/Tests/SBCS/SBCS.cxx
@@ -1,21 +1,22 @@
-// Test to verify that _SBCS being defined causes CharacterSet to be set to 0 (Single Byte Character Set)
+// Test to verify that _SBCS being defined causes CharacterSet to be set to 0
+// (Single Byte Character Set)
 
-int main ()
+int main()
 {
 #ifdef _UNICODE
-  bool UnicodeSet=true;
+  bool UnicodeSet = true;
 #else
-  bool UnicodeSet=false;
+  bool UnicodeSet = false;
 #endif
 
 #ifdef _MBCS
-  bool MBCSSet=true;
+  bool MBCSSet = true;
 #else
-  bool MBCSSet=false;
+  bool MBCSSet = false;
 #endif
 
   // if neither _UNICODE nor _MBCS is set, CharacterSet must be set to SBCS.
-  bool SBCSSet=(!UnicodeSet && !MBCSSet);
+  bool SBCSSet = (!UnicodeSet && !MBCSSet);
 
   // Reverse boolean to indicate error case correctly
   return !SBCSSet;
diff --git a/Tests/SameName/Exe1/conly.c b/Tests/SameName/Exe1/conly.c
index eb62c30..8f2ce05 100644
--- a/Tests/SameName/Exe1/conly.c
+++ b/Tests/SameName/Exe1/conly.c
@@ -1,12 +1,11 @@
 #include "libc1.h"
 #include <stdio.h>
 
-int main ()
+int main()
 {
-  if ( LibC1Func() != 2.0 )
-    {
+  if (LibC1Func() != 2.0) {
     printf("Problem with libc1\n");
     return 1;
-    }
+  }
   return 0;
 }
diff --git a/Tests/SetLang/bar.c b/Tests/SetLang/bar.c
index f59c318..b934356 100644
--- a/Tests/SetLang/bar.c
+++ b/Tests/SetLang/bar.c
@@ -4,18 +4,17 @@ int foo();
 class A
 {
 public:
-  A() {this->i = foo();}
+  A() { this->i = foo(); }
   int i;
 };
 
 int main()
 {
   A a;
-  if(a.i == 21)
-    {
+  if (a.i == 21) {
     printf("passed foo is 21\n");
     return 0;
-    }
+  }
   printf("Failed foo is not 21\n");
   return -1;
 }
diff --git a/Tests/SetLang/foo.c b/Tests/SetLang/foo.c
index e7918af..551dd1b 100644
--- a/Tests/SetLang/foo.c
+++ b/Tests/SetLang/foo.c
@@ -2,6 +2,6 @@ int foo()
 {
   int r = 10;
   r++;
-  int ret = r+10;
+  int ret = r + 10;
   return ret;
 }
diff --git a/Tests/Simple/simple.cxx b/Tests/Simple/simple.cxx
index 7bee7c0..5aa689b 100644
--- a/Tests/Simple/simple.cxx
+++ b/Tests/Simple/simple.cxx
@@ -2,7 +2,7 @@ extern void simpleLib();
 extern "C" int FooBar();
 extern int bar();
 extern int bar1();
-int main ()
+int main()
 {
   FooBar();
   bar();
diff --git a/Tests/Simple/simpleCLib.c b/Tests/Simple/simpleCLib.c
index 88fc33e..6509865 100644
--- a/Tests/Simple/simpleCLib.c
+++ b/Tests/Simple/simpleCLib.c
@@ -4,9 +4,8 @@ int FooBar()
 {
   int class;
   int private = 10;
-  for ( class = 0; class < private; class ++ )
-    {
+  for (class = 0; class < private; class ++) {
     printf("Count: %d/%d\n", class, private);
-    }
+  }
   return 0;
 }
diff --git a/Tests/Simple/simpleWe.cpp b/Tests/Simple/simpleWe.cpp
index e0f22ef..5211c91 100644
--- a/Tests/Simple/simpleWe.cpp
+++ b/Tests/Simple/simpleWe.cpp
@@ -3,10 +3,7 @@
 class Foo
 {
 public:
-  Foo()
-    {
-      printf("This one has nonstandard extension\n");
-    }
+  Foo() { printf("This one has nonstandard extension\n"); }
   int getnum() { return 0; }
 };
 
diff --git a/Tests/SimpleCOnly/bar.c b/Tests/SimpleCOnly/bar.c
index 5d8eac0..570fee9 100644
--- a/Tests/SimpleCOnly/bar.c
+++ b/Tests/SimpleCOnly/bar.c
@@ -1 +1,4 @@
-int bar() {return 5;}
+int bar()
+{
+  return 5;
+}
diff --git a/Tests/SimpleCOnly/foo.c b/Tests/SimpleCOnly/foo.c
index b8cdea4..c61d212 100644
--- a/Tests/SimpleCOnly/foo.c
+++ b/Tests/SimpleCOnly/foo.c
@@ -1 +1,4 @@
-int foo() { return 12;}
+int foo()
+{
+  return 12;
+}
diff --git a/Tests/SimpleCOnly/main.c b/Tests/SimpleCOnly/main.c
index 022a8e8..54a7312 100644
--- a/Tests/SimpleCOnly/main.c
+++ b/Tests/SimpleCOnly/main.c
@@ -5,8 +5,8 @@ extern int bar();
 
 int main()
 {
-   int i=foo();
-   int k=bar();
-   i=i*k;
-   return i;
+  int i = foo();
+  int k = bar();
+  i = i * k;
+  return i;
 }
diff --git a/Tests/SimpleExclude/dirC/dirA/t4.c b/Tests/SimpleExclude/dirC/dirA/t4.c
index 7c36ca9..b0e4000 100644
--- a/Tests/SimpleExclude/dirC/dirA/t4.c
+++ b/Tests/SimpleExclude/dirC/dirA/t4.c
@@ -4,14 +4,14 @@
 int main()
 {
   int ac;
-  char*av[];
+  char* av[];
 #else
-  int main(int ac, char*av[])
-    {
+int main(int ac, char* av[])
+{
 #endif
-    if(ac > 1000){return *av[0];}
-    printf("This is T4. This one should work.\n");
-    return 0;
-    }
-
-
+  if (ac > 1000) {
+    return *av[0];
+  }
+  printf("This is T4. This one should work.\n");
+  return 0;
+}
diff --git a/Tests/SimpleExclude/dirC/dirB/t7.c b/Tests/SimpleExclude/dirC/dirB/t7.c
index b95d3ec..b613e91 100644
--- a/Tests/SimpleExclude/dirC/dirB/t7.c
+++ b/Tests/SimpleExclude/dirC/dirB/t7.c
@@ -6,11 +6,10 @@ int tlib7func()
 {
   printf("This is T7\n");
 
-  if ( tlib2func() != 2 )
-    {
+  if (tlib2func() != 2) {
     fprintf(stderr, "Something wrong with T2\n");
     return 1;
-    }
+  }
 
   return 7;
 }
diff --git a/Tests/SimpleExclude/dirD/t9.c b/Tests/SimpleExclude/dirD/t9.c
index 321014b..9954ea5 100644
--- a/Tests/SimpleExclude/dirD/t9.c
+++ b/Tests/SimpleExclude/dirD/t9.c
@@ -6,19 +6,19 @@ extern int tlib7func();
 int main()
 {
   int ac;
-  char*av[];
+  char* av[];
 #else
-  int main(int ac, char*av[])
-    {
+int main(int ac, char* av[])
+{
 #endif
-    if(ac > 1000){return *av[0];}
-    printf("This is T9. This one should work.\n");
-
-    if ( tlib7func() != 7 )
-      {
-      fprintf(stderr, "Something wrong with T7\n");
-      return 1;
-      }
-    return 0;
-    }
+  if (ac > 1000) {
+    return *av[0];
+  }
+  printf("This is T9. This one should work.\n");
 
+  if (tlib7func() != 7) {
+    fprintf(stderr, "Something wrong with T7\n");
+    return 1;
+  }
+  return 0;
+}
diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt
index 2737f18..aee92f6 100644
--- a/Tests/SimpleInstall/CMakeLists.txt
+++ b/Tests/SimpleInstall/CMakeLists.txt
@@ -364,6 +364,7 @@ endif()
 set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install")
 set(CMAKE_INSTALL_MFC_LIBRARIES 1)
 set(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
+set(CMAKE_INSTALL_UCRT_LIBRARIES 1)
 include(InstallRequiredSystemLibraries)
 
 if(CTEST_TEST_CPACK)
diff --git a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx
index 0277f05..0f32894 100644
--- a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx
+++ b/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx
@@ -2,9 +2,8 @@
 
 int TSD(const char* foo)
 {
-  if ( strcmp(foo, "TEST") == 0 )
-    {
+  if (strcmp(foo, "TEST") == 0) {
     return 0;
-    }
+  }
   return 1;
 }
diff --git a/Tests/SimpleInstall/foo.h b/Tests/SimpleInstall/foo.h
index 2708baf..216cdf6 100644
--- a/Tests/SimpleInstall/foo.h
+++ b/Tests/SimpleInstall/foo.h
@@ -8,4 +8,3 @@ extern int SomeFunctionInFoo();
 #ifdef __cplusplus
 }
 #endif
-
diff --git a/Tests/SimpleInstall/inst.cxx b/Tests/SimpleInstall/inst.cxx
index 7f2962d..ecf061c 100644
--- a/Tests/SimpleInstall/inst.cxx
+++ b/Tests/SimpleInstall/inst.cxx
@@ -1,37 +1,34 @@
 #include "foo.h"
 
 #ifdef STAGE_2
-# include <foo/lib1.h>
-# include <foo/lib2renamed.h>
-# include <lib3.h>
-# include <old/lib2.h>
-# include <old/lib3.h>
+#include <foo/lib1.h>
+#include <foo/lib2renamed.h>
+#include <lib3.h>
+#include <old/lib2.h>
+#include <old/lib3.h>
 #else
-# include "lib1.h"
-# include "lib2.h"
+#include "lib1.h"
+#include "lib2.h"
 #endif
 
 #include "lib4.h"
 
 #include <stdio.h>
 
-int main ()
+int main()
 {
-  if ( Lib1Func() != 2.0 )
-    {
+  if (Lib1Func() != 2.0) {
     printf("Problem with lib1\n");
     return 1;
-    }
-  if ( Lib2Func() != 1.0 )
-    {
+  }
+  if (Lib2Func() != 1.0) {
     printf("Problem with lib2\n");
     return 1;
-    }
-  if ( Lib4Func() != 4.0 )
-    {
+  }
+  if (Lib4Func() != 4.0) {
     printf("Problem with lib4\n");
     return 1;
-    }
+  }
   printf("The value of Foo: %s\n", foo);
-  return SomeFunctionInFoo()-5;
+  return SomeFunctionInFoo() - 5;
 }
diff --git a/Tests/SimpleInstall/lib2.h b/Tests/SimpleInstall/lib2.h
index d69b786..a3ed758 100644
--- a/Tests/SimpleInstall/lib2.h
+++ b/Tests/SimpleInstall/lib2.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef test2_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef test2_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float Lib2Func();
diff --git a/Tests/SimpleInstall/lib3.h b/Tests/SimpleInstall/lib3.h
index 66bc52a..df11327 100644
--- a/Tests/SimpleInstall/lib3.h
+++ b/Tests/SimpleInstall/lib3.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef test3_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef test3_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float Lib3Func();
diff --git a/Tests/SimpleInstall/lib4.cxx b/Tests/SimpleInstall/lib4.cxx
index fbfa23a..fbede5c 100644
--- a/Tests/SimpleInstall/lib4.cxx
+++ b/Tests/SimpleInstall/lib4.cxx
@@ -4,4 +4,3 @@ float Lib4Func()
 {
   return 4.0;
 }
-
diff --git a/Tests/SimpleInstall/lib4.h b/Tests/SimpleInstall/lib4.h
index 11c1272..71425a5 100644
--- a/Tests/SimpleInstall/lib4.h
+++ b/Tests/SimpleInstall/lib4.h
@@ -1,12 +1,11 @@
 #ifdef _WIN32
-#  ifdef test4_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef test4_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float Lib4Func();
-
diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt
index 2737f18..aee92f6 100644
--- a/Tests/SimpleInstallS2/CMakeLists.txt
+++ b/Tests/SimpleInstallS2/CMakeLists.txt
@@ -364,6 +364,7 @@ endif()
 set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install")
 set(CMAKE_INSTALL_MFC_LIBRARIES 1)
 set(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
+set(CMAKE_INSTALL_UCRT_LIBRARIES 1)
 include(InstallRequiredSystemLibraries)
 
 if(CTEST_TEST_CPACK)
diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx
index 0277f05..0f32894 100644
--- a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx
+++ b/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx
@@ -2,9 +2,8 @@
 
 int TSD(const char* foo)
 {
-  if ( strcmp(foo, "TEST") == 0 )
-    {
+  if (strcmp(foo, "TEST") == 0) {
     return 0;
-    }
+  }
   return 1;
 }
diff --git a/Tests/SimpleInstallS2/foo.h b/Tests/SimpleInstallS2/foo.h
index 2708baf..216cdf6 100644
--- a/Tests/SimpleInstallS2/foo.h
+++ b/Tests/SimpleInstallS2/foo.h
@@ -8,4 +8,3 @@ extern int SomeFunctionInFoo();
 #ifdef __cplusplus
 }
 #endif
-
diff --git a/Tests/SimpleInstallS2/inst.cxx b/Tests/SimpleInstallS2/inst.cxx
index 7f2962d..ecf061c 100644
--- a/Tests/SimpleInstallS2/inst.cxx
+++ b/Tests/SimpleInstallS2/inst.cxx
@@ -1,37 +1,34 @@
 #include "foo.h"
 
 #ifdef STAGE_2
-# include <foo/lib1.h>
-# include <foo/lib2renamed.h>
-# include <lib3.h>
-# include <old/lib2.h>
-# include <old/lib3.h>
+#include <foo/lib1.h>
+#include <foo/lib2renamed.h>
+#include <lib3.h>
+#include <old/lib2.h>
+#include <old/lib3.h>
 #else
-# include "lib1.h"
-# include "lib2.h"
+#include "lib1.h"
+#include "lib2.h"
 #endif
 
 #include "lib4.h"
 
 #include <stdio.h>
 
-int main ()
+int main()
 {
-  if ( Lib1Func() != 2.0 )
-    {
+  if (Lib1Func() != 2.0) {
     printf("Problem with lib1\n");
     return 1;
-    }
-  if ( Lib2Func() != 1.0 )
-    {
+  }
+  if (Lib2Func() != 1.0) {
     printf("Problem with lib2\n");
     return 1;
-    }
-  if ( Lib4Func() != 4.0 )
-    {
+  }
+  if (Lib4Func() != 4.0) {
     printf("Problem with lib4\n");
     return 1;
-    }
+  }
   printf("The value of Foo: %s\n", foo);
-  return SomeFunctionInFoo()-5;
+  return SomeFunctionInFoo() - 5;
 }
diff --git a/Tests/SimpleInstallS2/lib2.h b/Tests/SimpleInstallS2/lib2.h
index d69b786..a3ed758 100644
--- a/Tests/SimpleInstallS2/lib2.h
+++ b/Tests/SimpleInstallS2/lib2.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef test2_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef test2_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float Lib2Func();
diff --git a/Tests/SimpleInstallS2/lib3.h b/Tests/SimpleInstallS2/lib3.h
index 66bc52a..df11327 100644
--- a/Tests/SimpleInstallS2/lib3.h
+++ b/Tests/SimpleInstallS2/lib3.h
@@ -1,11 +1,11 @@
 #ifdef _WIN32
-#  ifdef test3_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef test3_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float Lib3Func();
diff --git a/Tests/SimpleInstallS2/lib4.cxx b/Tests/SimpleInstallS2/lib4.cxx
index fbfa23a..fbede5c 100644
--- a/Tests/SimpleInstallS2/lib4.cxx
+++ b/Tests/SimpleInstallS2/lib4.cxx
@@ -4,4 +4,3 @@ float Lib4Func()
 {
   return 4.0;
 }
-
diff --git a/Tests/SimpleInstallS2/lib4.h b/Tests/SimpleInstallS2/lib4.h
index 11c1272..71425a5 100644
--- a/Tests/SimpleInstallS2/lib4.h
+++ b/Tests/SimpleInstallS2/lib4.h
@@ -1,12 +1,11 @@
 #ifdef _WIN32
-#  ifdef test4_EXPORTS
-#    define CM_TEST_LIB_EXPORT  __declspec( dllexport )
-#  else
-#    define CM_TEST_LIB_EXPORT  __declspec( dllimport )
-#  endif
+#ifdef test4_EXPORTS
+#define CM_TEST_LIB_EXPORT __declspec(dllexport)
 #else
-#  define CM_TEST_LIB_EXPORT
+#define CM_TEST_LIB_EXPORT __declspec(dllimport)
+#endif
+#else
+#define CM_TEST_LIB_EXPORT
 #endif
 
 CM_TEST_LIB_EXPORT float Lib4Func();
-
diff --git a/Tests/SourceGroups/main.c b/Tests/SourceGroups/main.c
index 212e64b..f259f98 100644
--- a/Tests/SourceGroups/main.c
+++ b/Tests/SourceGroups/main.c
@@ -8,6 +8,7 @@ extern int baz(void);
 
 int main()
 {
-   printf("foo: %d bar: %d foobar: %d barbar: %d baz: %d\n", foo(), bar(), foobar(), barbar(), baz());
-   return 0;
+  printf("foo: %d bar: %d foobar: %d barbar: %d baz: %d\n", foo(), bar(),
+         foobar(), barbar(), baz());
+  return 0;
 }
diff --git a/Tests/StagingPrefix/Consumer/main.cpp b/Tests/StagingPrefix/Consumer/main.cpp
index 612ee05..d4a02bf 100644
--- a/Tests/StagingPrefix/Consumer/main.cpp
+++ b/Tests/StagingPrefix/Consumer/main.cpp
@@ -1,8 +1,8 @@
 
-#include "foo.h"
 #include "bar.h"
+#include "foo.h"
 
-int main(int, char **)
+int main(int, char**)
 {
   Foo f;
   Bar b;
diff --git a/Tests/StagingPrefix/Producer/bar.h b/Tests/StagingPrefix/Producer/bar.h
index acd1fae..a56bd5d 100644
--- a/Tests/StagingPrefix/Producer/bar.h
+++ b/Tests/StagingPrefix/Producer/bar.h
@@ -1,9 +1,9 @@
 
 class
 #ifdef _WIN32
-__declspec(dllexport)
+  __declspec(dllexport)
 #endif
-Bar
+    Bar
 {
 public:
   int bar();
diff --git a/Tests/StagingPrefix/Producer/foo.h b/Tests/StagingPrefix/Producer/foo.h
index 614093d..17b4f77 100644
--- a/Tests/StagingPrefix/Producer/foo.h
+++ b/Tests/StagingPrefix/Producer/foo.h
@@ -1,9 +1,9 @@
 
 class
 #ifdef _WIN32
-__declspec(dllexport)
+  __declspec(dllexport)
 #endif
-Foo
+    Foo
 {
 public:
   int foo();
diff --git a/Tests/StagingPrefix/main.cpp b/Tests/StagingPrefix/main.cpp
index 341aaaf..e9ad257 100644
--- a/Tests/StagingPrefix/main.cpp
+++ b/Tests/StagingPrefix/main.cpp
@@ -1,5 +1,5 @@
 
-int main(int, char **)
+int main(int, char**)
 {
   return 0;
 }
diff --git a/Tests/StringFileTest/StringFile.cxx b/Tests/StringFileTest/StringFile.cxx
index 9eba6bf..c890e8e 100644
--- a/Tests/StringFileTest/StringFile.cxx
+++ b/Tests/StringFileTest/StringFile.cxx
@@ -1,8 +1,9 @@
 #include <stdio.h>
 #include <string.h>
+
 #include "OutputFile.h"
 
-int main(int, char*[])
+int main(int, char* [])
 {
   int res = 0;
 
diff --git a/Tests/SubDir/Executable/test.cxx b/Tests/SubDir/Executable/test.cxx
index c528fb1..06aed01 100644
--- a/Tests/SubDir/Executable/test.cxx
+++ b/Tests/SubDir/Executable/test.cxx
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include  <stdlib.h>
+#include <stdlib.h>
 #ifdef _WIN32
 #include <io.h>
 #else
@@ -10,39 +10,32 @@
 int FileExists(const char* filename)
 {
 #ifdef _MSC_VER
-# define access _access
+#define access _access
 #endif
 #ifndef F_OK
 #define F_OK 0
 #endif
-  if ( access(filename, F_OK) != 0 )
-    {
+  if (access(filename, F_OK) != 0) {
     return false;
-    }
-  else
-    {
+  } else {
     return true;
-    }
+  }
 }
 
-
 int main(int ac, char** av)
 {
-  if(ac <= 1)
-    {
+  if (ac <= 1) {
     printf("Usage: %s <file>\n", av[0]);
     return 1;
-    }
-  if(!FileExists(av[1]))
-    {
+  }
+  if (!FileExists(av[1])) {
     printf("Missing file %s\n", av[1]);
     return 1;
-    }
-  if(FileExists(av[2]))
-    {
+  }
+  if (FileExists(av[2])) {
     printf("File %s should be in subdirectory\n", av[2]);
     return 1;
-    }
+  }
   printf("%s is not there! Good.", av[2]);
   printf("%s is there! Good.", av[1]);
   return 0;
diff --git a/Tests/SubDirSpaces/Executable Sources/test.cxx b/Tests/SubDirSpaces/Executable Sources/test.cxx
index c528fb1..06aed01 100644
--- a/Tests/SubDirSpaces/Executable Sources/test.cxx	
+++ b/Tests/SubDirSpaces/Executable Sources/test.cxx	
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include  <stdlib.h>
+#include <stdlib.h>
 #ifdef _WIN32
 #include <io.h>
 #else
@@ -10,39 +10,32 @@
 int FileExists(const char* filename)
 {
 #ifdef _MSC_VER
-# define access _access
+#define access _access
 #endif
 #ifndef F_OK
 #define F_OK 0
 #endif
-  if ( access(filename, F_OK) != 0 )
-    {
+  if (access(filename, F_OK) != 0) {
     return false;
-    }
-  else
-    {
+  } else {
     return true;
-    }
+  }
 }
 
-
 int main(int ac, char** av)
 {
-  if(ac <= 1)
-    {
+  if (ac <= 1) {
     printf("Usage: %s <file>\n", av[0]);
     return 1;
-    }
-  if(!FileExists(av[1]))
-    {
+  }
+  if (!FileExists(av[1])) {
     printf("Missing file %s\n", av[1]);
     return 1;
-    }
-  if(FileExists(av[2]))
-    {
+  }
+  if (FileExists(av[2])) {
     printf("File %s should be in subdirectory\n", av[2]);
     return 1;
-    }
+  }
   printf("%s is not there! Good.", av[2]);
   printf("%s is there! Good.", av[1]);
   return 0;
diff --git a/Tests/SubDirSpaces/Executable/test.cxx b/Tests/SubDirSpaces/Executable/test.cxx
index c528fb1..06aed01 100644
--- a/Tests/SubDirSpaces/Executable/test.cxx
+++ b/Tests/SubDirSpaces/Executable/test.cxx
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include  <stdlib.h>
+#include <stdlib.h>
 #ifdef _WIN32
 #include <io.h>
 #else
@@ -10,39 +10,32 @@
 int FileExists(const char* filename)
 {
 #ifdef _MSC_VER
-# define access _access
+#define access _access
 #endif
 #ifndef F_OK
 #define F_OK 0
 #endif
-  if ( access(filename, F_OK) != 0 )
-    {
+  if (access(filename, F_OK) != 0) {
     return false;
-    }
-  else
-    {
+  } else {
     return true;
-    }
+  }
 }
 
-
 int main(int ac, char** av)
 {
-  if(ac <= 1)
-    {
+  if (ac <= 1) {
     printf("Usage: %s <file>\n", av[0]);
     return 1;
-    }
-  if(!FileExists(av[1]))
-    {
+  }
+  if (!FileExists(av[1])) {
     printf("Missing file %s\n", av[1]);
     return 1;
-    }
-  if(FileExists(av[2]))
-    {
+  }
+  if (FileExists(av[2])) {
     printf("File %s should be in subdirectory\n", av[2]);
     return 1;
-    }
+  }
   printf("%s is not there! Good.", av[2]);
   printf("%s is there! Good.", av[1]);
   return 0;
diff --git a/Tests/SubProject/car.cxx b/Tests/SubProject/car.cxx
index 95de4a3..cc3a4e0 100644
--- a/Tests/SubProject/car.cxx
+++ b/Tests/SubProject/car.cxx
@@ -1,6 +1,6 @@
 int main(int ac, char** av)
 {
-  (void) ac;
-  (void) av;
+  (void)ac;
+  (void)av;
   return 0;
 }
diff --git a/Tests/SubProject/foo/foo.cxx b/Tests/SubProject/foo/foo.cxx
index 68fa363..50cd9e4 100644
--- a/Tests/SubProject/foo/foo.cxx
+++ b/Tests/SubProject/foo/foo.cxx
@@ -7,9 +7,8 @@ int main(int ac, char** av)
   (void)av;
   int ret = bar();
   printf("bar = %d\n", ret);
-  if(ret == 10)
-    {
+  if (ret == 10) {
     return 0;
-    }
+  }
   return -1;
 }
diff --git a/Tests/SwiftMix/CMain.c b/Tests/SwiftMix/CMain.c
index 13e2f8c..8877da4 100644
--- a/Tests/SwiftMix/CMain.c
+++ b/Tests/SwiftMix/CMain.c
@@ -1,4 +1,5 @@
 extern int ObjCMain(int argc, char const* const argv[]);
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[])
+{
   return ObjCMain(argc, argv);
 }
diff --git a/Tests/SwigTest/example.cxx b/Tests/SwigTest/example.cxx
index 1e8e203..961d6dd 100644
--- a/Tests/SwigTest/example.cxx
+++ b/Tests/SwigTest/example.cxx
@@ -4,25 +4,30 @@
 #define M_PI 3.14159265358979323846
 
 /* Move the shape to a new location */
-void Shape::move(double dx, double dy) {
+void Shape::move(double dx, double dy)
+{
   x += dx;
   y += dy;
 }
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
-  return M_PI*radius*radius;
+double Circle::area(void)
+{
+  return M_PI * radius * radius;
 }
 
-double Circle::perimeter(void) {
-  return 2*M_PI*radius;
+double Circle::perimeter(void)
+{
+  return 2 * M_PI * radius;
 }
 
-double Square::area(void) {
-  return width*width;
+double Square::area(void)
+{
+  return width * width;
 }
 
-double Square::perimeter(void) {
-  return 4*width;
+double Square::perimeter(void)
+{
+  return 4 * width;
 }
diff --git a/Tests/SwigTest/example.h b/Tests/SwigTest/example.h
index c9d59f2..366deb0 100644
--- a/Tests/SwigTest/example.h
+++ b/Tests/SwigTest/example.h
@@ -1,39 +1,37 @@
 /* File : example.h */
 
-class Shape {
+class Shape
+{
 public:
-  Shape() {
-    nshapes++;
-  }
-  virtual ~Shape() {
-    nshapes--;
-  };
-  double  x, y;
-  void    move(double dx, double dy);
+  Shape() { nshapes++; }
+  virtual ~Shape() { nshapes--; };
+  double x, y;
+  void move(double dx, double dy);
   virtual double area(void) = 0;
   virtual double perimeter(void) = 0;
-  static  int nshapes;
+  static int nshapes;
 };
 
-class Circle : public Shape {
+class Circle : public Shape
+{
 private:
   double radius;
+
 public:
-  Circle(double r) : radius(r) { };
+  Circle(double r)
+    : radius(r){};
   virtual double area(void);
   virtual double perimeter(void);
 };
 
-class Square : public Shape {
+class Square : public Shape
+{
 private:
   double width;
+
 public:
-  Square(double w) : width(w) { };
+  Square(double w)
+    : width(w){};
   virtual double area(void);
   virtual double perimeter(void);
 };
-
-
-
-
-
diff --git a/Tests/SystemInformation/DumpInformation.cxx b/Tests/SystemInformation/DumpInformation.cxx
index acafa87..e0cc0ce 100644
--- a/Tests/SystemInformation/DumpInformation.cxx
+++ b/Tests/SystemInformation/DumpInformation.cxx
@@ -4,77 +4,77 @@
 
 void cmDumpInformationPrintFile(const char* name, FILE* fout)
 {
-  fprintf(fout,
-          "Avoid ctest truncation of output: CTEST_FULL_OUTPUT\n");
-  fprintf(fout,
-          "================================================================\n");
+  fprintf(fout, "Avoid ctest truncation of output: CTEST_FULL_OUTPUT\n");
+  fprintf(
+    fout,
+    "================================================================\n");
   struct stat fs;
-  if(stat(name, &fs) != 0)
-    {
+  if (stat(name, &fs) != 0) {
     fprintf(fout, "The file \"%s\" does not exist.\n", name);
     fflush(fout);
     return;
-    }
+  }
 
   FILE* fin = fopen(name, "r");
-  if(fin)
-    {
-    fprintf(fout,
-            "Contents of \"%s\":\n"
-            "----------------------------------------------------------------\n",
-            name);
+  if (fin) {
+    fprintf(
+      fout,
+      "Contents of \"%s\":\n"
+      "----------------------------------------------------------------\n",
+      name);
     const int bufferSize = 4096;
     char buffer[bufferSize];
     int n;
-    while((n = fread(buffer, 1, bufferSize, fin)) > 0)
-      {
-      for(char* c = buffer; c < buffer+n; ++c)
-        {
-        switch(*c)
-          {
-          case '<': fprintf(fout, "<"); break;
-          case '>': fprintf(fout, ">"); break;
-          case '&': fprintf(fout, "&"); break;
-          default: putc(*c, fout); break;
-          }
+    while ((n = fread(buffer, 1, bufferSize, fin)) > 0) {
+      for (char* c = buffer; c < buffer + n; ++c) {
+        switch (*c) {
+          case '<':
+            fprintf(fout, "<");
+            break;
+          case '>':
+            fprintf(fout, ">");
+            break;
+          case '&':
+            fprintf(fout, "&");
+            break;
+          default:
+            putc(*c, fout);
+            break;
         }
-      fflush(fout);
       }
-    fclose(fin);
+      fflush(fout);
     }
-  else
-    {
+    fclose(fin);
+  } else {
     fprintf(fout, "Error opening \"%s\" for reading.\n", name);
     fflush(fout);
-    }
+  }
 }
 
-int main(int,char *[])
+int main(int, char* [])
 {
-  const char* files[] =
-    {
-      DumpInformation_BINARY_DIR "/SystemInformation.out",
-      DumpInformation_BINARY_DIR "/AllVariables.txt",
-      DumpInformation_BINARY_DIR "/AllCommands.txt",
-      DumpInformation_BINARY_DIR "/AllMacros.txt",
-      DumpInformation_BINARY_DIR "/OtherProperties.txt",
-      DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
-      DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
-      DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeOutput.log",
-      DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeError.log",
-      DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
-      DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.hxx",
-      DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.h",
-      DumpInformation_BINARY_DIR "/CMakeFiles/CMakeOutput.log",
-      DumpInformation_BINARY_DIR "/CMakeFiles/CMakeError.log",
-      0
-    };
+  const char* files[] = {
+    DumpInformation_BINARY_DIR "/SystemInformation.out",
+    DumpInformation_BINARY_DIR "/AllVariables.txt",
+    DumpInformation_BINARY_DIR "/AllCommands.txt",
+    DumpInformation_BINARY_DIR "/AllMacros.txt",
+    DumpInformation_BINARY_DIR "/OtherProperties.txt",
+    DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
+    DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
+    DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeOutput.log",
+    DumpInformation_BINARY_DIR "/../../CMakeFiles/CMakeError.log",
+    DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
+    DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.hxx",
+    DumpInformation_BINARY_DIR "/../../Source/cmsys/Configure.h",
+    DumpInformation_BINARY_DIR "/CMakeFiles/CMakeOutput.log",
+    DumpInformation_BINARY_DIR "/CMakeFiles/CMakeError.log",
+    0
+  };
 
   const char** f;
-  for(f = files; *f; ++f)
-    {
+  for (f = files; *f; ++f) {
     cmDumpInformationPrintFile(*f, stdout);
-    }
+  }
 
   return 0;
 }
diff --git a/Tests/TargetName/executables/hello_world.c b/Tests/TargetName/executables/hello_world.c
index 539d867..5b6eaf8 100644
--- a/Tests/TargetName/executables/hello_world.c
+++ b/Tests/TargetName/executables/hello_world.c
@@ -1,5 +1,5 @@
 #include <stdio.h>
 main()
 {
-   printf("hello, world\n");
+  printf("hello, world\n");
 }
diff --git a/Tests/TestDriver/subdir/test3.cxx b/Tests/TestDriver/subdir/test3.cxx
index 976d6eb..c5a83de 100644
--- a/Tests/TestDriver/subdir/test3.cxx
+++ b/Tests/TestDriver/subdir/test3.cxx
@@ -1,8 +1,8 @@
 #include <stdio.h>
-int subdir_test3(int ac, char*av[])
+int subdir_test3(int ac, char* av[])
 {
   printf("test3\n");
-  for(int i =0; i < ac; i++)
+  for (int i = 0; i < ac; i++)
     printf("arg %d is %s\n", ac, av[i]);
   return 0;
 }
diff --git a/Tests/TestDriver/test1.cxx b/Tests/TestDriver/test1.cxx
index b998fda..59a6fce 100644
--- a/Tests/TestDriver/test1.cxx
+++ b/Tests/TestDriver/test1.cxx
@@ -5,21 +5,18 @@ int testExtraStuff2();
 
 int test1(int ac, char* av[])
 {
-  if(!testExtraStuff2())
-    {
+  if (!testExtraStuff2()) {
     return -1;
-    }
-  if(!testExtraStuff())
-    {
+  }
+  if (!testExtraStuff()) {
     return -1;
-    }
-  if(!testExtraStuff3())
-    {
+  }
+  if (!testExtraStuff3()) {
     return -1;
-    }
+  }
 
   printf("test1\n");
-  for(int i =0; i < ac; i++)
+  for (int i = 0; i < ac; i++)
     printf("arg %d is %s\n", ac, av[i]);
   return 0;
 }
diff --git a/Tests/TestDriver/test2.cxx b/Tests/TestDriver/test2.cxx
index 69f0fff..08d1e6f 100644
--- a/Tests/TestDriver/test2.cxx
+++ b/Tests/TestDriver/test2.cxx
@@ -1,8 +1,8 @@
 #include <stdio.h>
-int test2(int ac, char*av[])
+int test2(int ac, char* av[])
 {
   printf("test2\n");
-  for(int i =0; i < ac; i++)
+  for (int i = 0; i < ac; i++)
     printf("arg %d is %s\n", ac, av[i]);
   return 0;
 }
diff --git a/Tests/TestDriver/testArgs.h b/Tests/TestDriver/testArgs.h
index 0489366..0f1b879 100644
--- a/Tests/TestDriver/testArgs.h
+++ b/Tests/TestDriver/testArgs.h
@@ -1,20 +1,16 @@
-void testProccessArgs(int* ac, char***av)
+void testProccessArgs(int* ac, char*** av)
 {
   char** argv = *av;
-  if(*ac < 2)
-    {
+  if (*ac < 2) {
     return;
-    }
-  if(strcmp(argv[1], "--with-threads") == 0)
-    {
+  }
+  if (strcmp(argv[1], "--with-threads") == 0) {
     printf("number of threads is %s\n", argv[2]);
-    *av +=2;
-    *ac -=2;
-    }
-  else if (strcmp(argv[1], "--without-threads") == 0)
-    {
+    *av += 2;
+    *ac -= 2;
+  } else if (strcmp(argv[1], "--without-threads") == 0) {
     printf("no threads\n");
     *av += 1;
     *ac -= 1;
-    }
+  }
 }
diff --git a/Tests/Testing/Sub/Sub2/testing2.cxx b/Tests/Testing/Sub/Sub2/testing2.cxx
index 1482f27..f8b643a 100644
--- a/Tests/Testing/Sub/Sub2/testing2.cxx
+++ b/Tests/Testing/Sub/Sub2/testing2.cxx
@@ -1,4 +1,4 @@
-int main ()
+int main()
 {
   return 0;
 }
diff --git a/Tests/Testing/testing.cxx b/Tests/Testing/testing.cxx
index 1482f27..f8b643a 100644
--- a/Tests/Testing/testing.cxx
+++ b/Tests/Testing/testing.cxx
@@ -1,4 +1,4 @@
-int main ()
+int main()
 {
   return 0;
 }
diff --git a/Tests/TestsWorkingDirectory/main.c b/Tests/TestsWorkingDirectory/main.c
index 19f2f14..11dd4ff 100644
--- a/Tests/TestsWorkingDirectory/main.c
+++ b/Tests/TestsWorkingDirectory/main.c
@@ -3,10 +3,11 @@
 #include <stdlib.h>
 #include <string.h>
 
-#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
+#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) ||          \
+                        defined(__BORLANDC__) || defined(__MINGW32__))
 
-#include <io.h>
 #include <direct.h>
+#include <io.h>
 
 #if defined(__WATCOMC__)
 #include <direct.h>
@@ -17,48 +18,43 @@ static const char* Getcwd(char* buf, unsigned int len)
 {
   const char* ret = _getcwd(buf, len);
   char* p = NULL;
-  if(!ret)
-    {
+  if (!ret) {
     fprintf(stderr, "No current working directory.\n");
     abort();
-    }
+  }
   // make sure the drive letter is capital
-  if(strlen(buf) > 1 && buf[1] == ':')
-    {
+  if (strlen(buf) > 1 && buf[1] == ':') {
     buf[0] = toupper(buf[0]);
-    }
-  for(p = buf; *p; ++p)
-    {
-    if(*p == '\\')
-      {
+  }
+  for (p = buf; *p; ++p) {
+    if (*p == '\\') {
       *p = '/';
-      }
     }
+  }
   return ret;
 }
 
 #else
-#include <sys/types.h>
 #include <fcntl.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 static const char* Getcwd(char* buf, unsigned int len)
 {
   const char* ret = getcwd(buf, len);
-  if(!ret)
-    {
+  if (!ret) {
     fprintf(stderr, "No current working directory\n");
     abort();
-    }
+  }
   return ret;
 }
 
 #endif
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
   char buf[2048];
-  const char *cwd = Getcwd(buf, sizeof(buf));
+  const char* cwd = Getcwd(buf, sizeof(buf));
 
   return strcmp(cwd, argv[1]);
 }
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index e497503..d11cfc5 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -108,9 +108,7 @@ endif()
 
 # try to compile a file that should compile
 set(_c_flags "${CMAKE_C_FLAGS}")
-if(CMAKE_GENERATOR STREQUAL "Visual Studio 6")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D \"TESTDEF\"")
-elseif(WATCOM)
+if(WATCOM)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -dTESTDEF")
 else()
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \"-DTESTDEF\"")
diff --git a/Tests/TryCompile/Inner/innerexe.c b/Tests/TryCompile/Inner/innerexe.c
index 9b121a1..e329c5f 100644
--- a/Tests/TryCompile/Inner/innerexe.c
+++ b/Tests/TryCompile/Inner/innerexe.c
@@ -1,2 +1,5 @@
 extern int innerlib(void);
-int main() { return innerlib(); }
+int main()
+{
+  return innerlib();
+}
diff --git a/Tests/TryCompile/Inner/innerlib.c b/Tests/TryCompile/Inner/innerlib.c
index 0ce1179..69653ad 100644
--- a/Tests/TryCompile/Inner/innerlib.c
+++ b/Tests/TryCompile/Inner/innerlib.c
@@ -1 +1,4 @@
-int innerlib(void) { return 0; }
+int innerlib(void)
+{
+  return 0;
+}
diff --git a/Tests/TryCompile/expect_arg.c b/Tests/TryCompile/expect_arg.c
index f18e03f..267b587 100644
--- a/Tests/TryCompile/expect_arg.c
+++ b/Tests/TryCompile/expect_arg.c
@@ -1,22 +1,18 @@
 #include <stdio.h>
 #include <string.h>
-int main(int ac, char*av[])
+int main(int ac, char* av[])
 {
   int i;
   printf("ac = [%d]\n", ac);
-  for(i =0; i < ac; i++)
-    {
+  for (i = 0; i < ac; i++) {
     printf("arg[%d] = %s\n", i, av[i]);
-    }
-  if(ac == 3)
-    {
-    if(strcmp(av[1], "arg1") ==0
-       && strcmp(av[2], "arg2") ==0)
-      {
+  }
+  if (ac == 3) {
+    if (strcmp(av[1], "arg1") == 0 && strcmp(av[2], "arg2") == 0) {
       printf("arg1 and arg2 present and accounted for!\n");
       return 0;
-      }
     }
+  }
   printf("arg1 and arg2 missing!\n");
   return -1;
 }
diff --git a/Tests/TryCompile/fail2a.c b/Tests/TryCompile/fail2a.c
index 78f2de1..8488f4e 100644
--- a/Tests/TryCompile/fail2a.c
+++ b/Tests/TryCompile/fail2a.c
@@ -1 +1,4 @@
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/TryCompile/pass.c b/Tests/TryCompile/pass.c
index 43e8a7e..f8b643a 100644
--- a/Tests/TryCompile/pass.c
+++ b/Tests/TryCompile/pass.c
@@ -2,5 +2,3 @@ int main()
 {
   return 0;
 }
-
-
diff --git a/Tests/TryCompile/pass2a.c b/Tests/TryCompile/pass2a.c
index bbfe6d5..27c377b 100644
--- a/Tests/TryCompile/pass2a.c
+++ b/Tests/TryCompile/pass2a.c
@@ -1,2 +1,5 @@
 extern int pass2b(void);
-int main() { return pass2b(); }
+int main()
+{
+  return pass2b();
+}
diff --git a/Tests/TryCompile/pass2b.cxx b/Tests/TryCompile/pass2b.cxx
index 4c539e2..438e9e5 100644
--- a/Tests/TryCompile/pass2b.cxx
+++ b/Tests/TryCompile/pass2b.cxx
@@ -1 +1,4 @@
-extern "C" int pass2b(void) { return 0; }
+extern "C" int pass2b(void)
+{
+  return 0;
+}
diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c
index 5401e71..b05f070 100644
--- a/Tests/TryCompile/testdef.c
+++ b/Tests/TryCompile/testdef.c
@@ -1,4 +1,7 @@
 #ifndef TESTDEF
-# error "TESTDEF should be defined!"
+#error "TESTDEF should be defined!"
 #endif
-int main(void) { return 0; }
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/Tutorial/Step1/tutorial.cxx b/Tests/Tutorial/Step1/tutorial.cxx
index 8ab6dc3..7a13376 100644
--- a/Tests/Tutorial/Step1/tutorial.cxx
+++ b/Tests/Tutorial/Step1/tutorial.cxx
@@ -1,23 +1,19 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
   double inputValue = atof(argv[1]);
   double outputValue = sqrt(inputValue);
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx
index 62523f6..2710f92 100644
--- a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx
+++ b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx
@@ -1,13 +1,12 @@
-#include <stdio.h>
 #include "MathFunctions.h"
+#include <stdio.h>
 
 // a hack square root calculation using simple operations
 double mysqrt(double x)
 {
-  if (x <= 0)
-    {
+  if (x <= 0) {
     return 0;
-    }
+  }
 
   double result;
   double delta;
@@ -15,15 +14,13 @@ double mysqrt(double x)
 
   // do ten iterations
   int i;
-  for (i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
-      }
-    delta = x - (result*result);
-    result = result + 0.5*delta/result;
-    fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result);
     }
+    delta = x - (result * result);
+    result = result + 0.5 * delta / result;
+    fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+  }
   return result;
 }
diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx
index c27da0b..2fae364 100644
--- a/Tests/Tutorial/Step2/tutorial.cxx
+++ b/Tests/Tutorial/Step2/tutorial.cxx
@@ -1,38 +1,33 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
 #ifdef USE_MYMATH
 #include "MathFunctions.h"
 #endif
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
 
   double inputValue = atof(argv[1]);
   double outputValue = 0;
 
-  if(inputValue >= 0)
-    {
+  if (inputValue >= 0) {
 #ifdef USE_MYMATH
     outputValue = mysqrt(inputValue);
 #else
     outputValue = sqrt(inputValue);
 #endif
-    }
+  }
 
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx
index 62523f6..2710f92 100644
--- a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx
+++ b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx
@@ -1,13 +1,12 @@
-#include <stdio.h>
 #include "MathFunctions.h"
+#include <stdio.h>
 
 // a hack square root calculation using simple operations
 double mysqrt(double x)
 {
-  if (x <= 0)
-    {
+  if (x <= 0) {
     return 0;
-    }
+  }
 
   double result;
   double delta;
@@ -15,15 +14,13 @@ double mysqrt(double x)
 
   // do ten iterations
   int i;
-  for (i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
-      }
-    delta = x - (result*result);
-    result = result + 0.5*delta/result;
-    fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result);
     }
+    delta = x - (result * result);
+    result = result + 0.5 * delta / result;
+    fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+  }
   return result;
 }
diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx
index c27da0b..2fae364 100644
--- a/Tests/Tutorial/Step3/tutorial.cxx
+++ b/Tests/Tutorial/Step3/tutorial.cxx
@@ -1,38 +1,33 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
 #ifdef USE_MYMATH
 #include "MathFunctions.h"
 #endif
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
 
   double inputValue = atof(argv[1]);
   double outputValue = 0;
 
-  if(inputValue >= 0)
-    {
+  if (inputValue >= 0) {
 #ifdef USE_MYMATH
     outputValue = mysqrt(inputValue);
 #else
     outputValue = sqrt(inputValue);
 #endif
-    }
+  }
 
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx
index d081d11..6ca264f 100644
--- a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx
+++ b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx
@@ -1,39 +1,36 @@
-#include <stdio.h>
 #include "MathFunctions.h"
 #include "TutorialConfig.h"
+#include <stdio.h>
 
 #include <math.h>
 
 // a hack square root calculation using simple operations
 double mysqrt(double x)
 {
-  if (x <= 0)
-    {
+  if (x <= 0) {
     return 0;
-    }
+  }
 
   double result;
 
-  // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined (HAVE_EXP)
-  result = exp(log(x)*0.5);
-  fprintf(stdout,"Computing sqrt of %g to be %g using log\n",x,result);
+// if we have both log and exp then use them
+#if defined(HAVE_LOG) && defined(HAVE_EXP)
+  result = exp(log(x) * 0.5);
+  fprintf(stdout, "Computing sqrt of %g to be %g using log\n", x, result);
 #else
   double delta;
   result = x;
 
   // do ten iterations
   int i;
-  for (i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
-      }
-    delta = x - (result*result);
-    result = result + 0.5*delta/result;
-    fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result);
     }
+    delta = x - (result * result);
+    result = result + 0.5 * delta / result;
+    fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+  }
 #endif
   return result;
 }
diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx
index c27da0b..2fae364 100644
--- a/Tests/Tutorial/Step4/tutorial.cxx
+++ b/Tests/Tutorial/Step4/tutorial.cxx
@@ -1,38 +1,33 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
 #ifdef USE_MYMATH
 #include "MathFunctions.h"
 #endif
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
 
   double inputValue = atof(argv[1]);
   double outputValue = 0;
 
-  if(inputValue >= 0)
-    {
+  if (inputValue >= 0) {
 #ifdef USE_MYMATH
     outputValue = mysqrt(inputValue);
 #else
     outputValue = sqrt(inputValue);
 #endif
-    }
+  }
 
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
index ef98d5f..cebd50f 100644
--- a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
+++ b/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
@@ -1,35 +1,32 @@
 // A simple program that builds a sqrt table
-#include <stdio.h>
 #include <math.h>
+#include <stdio.h>
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
   int i;
   double result;
 
   // make sure we have enough arguments
-  if (argc < 2)
-    {
+  if (argc < 2) {
     return 1;
-    }
+  }
 
   // open the output file
-  FILE *fout = fopen(argv[1],"w");
-  if (!fout)
-    {
+  FILE* fout = fopen(argv[1], "w");
+  if (!fout) {
     return 1;
-    }
+  }
 
   // create a source file with a table of square roots
-  fprintf(fout,"double sqrtTable[] = {\n");
-  for (i = 0; i < 10; ++i)
-    {
+  fprintf(fout, "double sqrtTable[] = {\n");
+  for (i = 0; i < 10; ++i) {
     result = sqrt(static_cast<double>(i));
-    fprintf(fout,"%g,\n",result);
-    }
+    fprintf(fout, "%g,\n", result);
+  }
 
   // close the table with a zero
-  fprintf(fout,"0};\n");
+  fprintf(fout, "0};\n");
   fclose(fout);
   return 0;
 }
diff --git a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx
index 1f9b887..458ed63 100644
--- a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx
+++ b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx
@@ -1,6 +1,6 @@
-#include <stdio.h>
 #include "MathFunctions.h"
 #include "TutorialConfig.h"
+#include <stdio.h>
 
 // include the generated table
 #include "Table.h"
@@ -10,10 +10,9 @@
 // a hack square root calculation using simple operations
 double mysqrt(double x)
 {
-  if (x <= 0)
-    {
+  if (x <= 0) {
     return 0;
-    }
+  }
 
   double result;
 
@@ -22,23 +21,20 @@ double mysqrt(double x)
 
   // use the table to help find an initial value
   result = x;
-  if (x >= 1 && x < 10)
-    {
+  if (x >= 1 && x < 10) {
     result = sqrtTable[static_cast<int>(x)];
-    }
+  }
 
   // do ten iterations
   int i;
-  for (i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
-      }
-    delta = x - (result*result);
-    result = result + 0.5*delta/result;
-    fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result);
     }
+    delta = x - (result * result);
+    result = result + 0.5 * delta / result;
+    fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+  }
 
   return result;
 }
diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx
index c27da0b..2fae364 100644
--- a/Tests/Tutorial/Step5/tutorial.cxx
+++ b/Tests/Tutorial/Step5/tutorial.cxx
@@ -1,38 +1,33 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
 #ifdef USE_MYMATH
 #include "MathFunctions.h"
 #endif
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
 
   double inputValue = atof(argv[1]);
   double outputValue = 0;
 
-  if(inputValue >= 0)
-    {
+  if (inputValue >= 0) {
 #ifdef USE_MYMATH
     outputValue = mysqrt(inputValue);
 #else
     outputValue = sqrt(inputValue);
 #endif
-    }
+  }
 
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
index ef98d5f..cebd50f 100644
--- a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
+++ b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
@@ -1,35 +1,32 @@
 // A simple program that builds a sqrt table
-#include <stdio.h>
 #include <math.h>
+#include <stdio.h>
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
   int i;
   double result;
 
   // make sure we have enough arguments
-  if (argc < 2)
-    {
+  if (argc < 2) {
     return 1;
-    }
+  }
 
   // open the output file
-  FILE *fout = fopen(argv[1],"w");
-  if (!fout)
-    {
+  FILE* fout = fopen(argv[1], "w");
+  if (!fout) {
     return 1;
-    }
+  }
 
   // create a source file with a table of square roots
-  fprintf(fout,"double sqrtTable[] = {\n");
-  for (i = 0; i < 10; ++i)
-    {
+  fprintf(fout, "double sqrtTable[] = {\n");
+  for (i = 0; i < 10; ++i) {
     result = sqrt(static_cast<double>(i));
-    fprintf(fout,"%g,\n",result);
-    }
+    fprintf(fout, "%g,\n", result);
+  }
 
   // close the table with a zero
-  fprintf(fout,"0};\n");
+  fprintf(fout, "0};\n");
   fclose(fout);
   return 0;
 }
diff --git a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx
index 1f9b887..458ed63 100644
--- a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx
+++ b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx
@@ -1,6 +1,6 @@
-#include <stdio.h>
 #include "MathFunctions.h"
 #include "TutorialConfig.h"
+#include <stdio.h>
 
 // include the generated table
 #include "Table.h"
@@ -10,10 +10,9 @@
 // a hack square root calculation using simple operations
 double mysqrt(double x)
 {
-  if (x <= 0)
-    {
+  if (x <= 0) {
     return 0;
-    }
+  }
 
   double result;
 
@@ -22,23 +21,20 @@ double mysqrt(double x)
 
   // use the table to help find an initial value
   result = x;
-  if (x >= 1 && x < 10)
-    {
+  if (x >= 1 && x < 10) {
     result = sqrtTable[static_cast<int>(x)];
-    }
+  }
 
   // do ten iterations
   int i;
-  for (i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
-      }
-    delta = x - (result*result);
-    result = result + 0.5*delta/result;
-    fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result);
     }
+    delta = x - (result * result);
+    result = result + 0.5 * delta / result;
+    fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+  }
 
   return result;
 }
diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx
index c27da0b..2fae364 100644
--- a/Tests/Tutorial/Step6/tutorial.cxx
+++ b/Tests/Tutorial/Step6/tutorial.cxx
@@ -1,38 +1,33 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
 #ifdef USE_MYMATH
 #include "MathFunctions.h"
 #endif
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
 
   double inputValue = atof(argv[1]);
   double outputValue = 0;
 
-  if(inputValue >= 0)
-    {
+  if (inputValue >= 0) {
 #ifdef USE_MYMATH
     outputValue = mysqrt(inputValue);
 #else
     outputValue = sqrt(inputValue);
 #endif
-    }
+  }
 
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx
index ef98d5f..cebd50f 100644
--- a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx
+++ b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx
@@ -1,35 +1,32 @@
 // A simple program that builds a sqrt table
-#include <stdio.h>
 #include <math.h>
+#include <stdio.h>
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
   int i;
   double result;
 
   // make sure we have enough arguments
-  if (argc < 2)
-    {
+  if (argc < 2) {
     return 1;
-    }
+  }
 
   // open the output file
-  FILE *fout = fopen(argv[1],"w");
-  if (!fout)
-    {
+  FILE* fout = fopen(argv[1], "w");
+  if (!fout) {
     return 1;
-    }
+  }
 
   // create a source file with a table of square roots
-  fprintf(fout,"double sqrtTable[] = {\n");
-  for (i = 0; i < 10; ++i)
-    {
+  fprintf(fout, "double sqrtTable[] = {\n");
+  for (i = 0; i < 10; ++i) {
     result = sqrt(static_cast<double>(i));
-    fprintf(fout,"%g,\n",result);
-    }
+    fprintf(fout, "%g,\n", result);
+  }
 
   // close the table with a zero
-  fprintf(fout,"0};\n");
+  fprintf(fout, "0};\n");
   fclose(fout);
   return 0;
 }
diff --git a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx
index 1f9b887..458ed63 100644
--- a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx
+++ b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx
@@ -1,6 +1,6 @@
-#include <stdio.h>
 #include "MathFunctions.h"
 #include "TutorialConfig.h"
+#include <stdio.h>
 
 // include the generated table
 #include "Table.h"
@@ -10,10 +10,9 @@
 // a hack square root calculation using simple operations
 double mysqrt(double x)
 {
-  if (x <= 0)
-    {
+  if (x <= 0) {
     return 0;
-    }
+  }
 
   double result;
 
@@ -22,23 +21,20 @@ double mysqrt(double x)
 
   // use the table to help find an initial value
   result = x;
-  if (x >= 1 && x < 10)
-    {
+  if (x >= 1 && x < 10) {
     result = sqrtTable[static_cast<int>(x)];
-    }
+  }
 
   // do ten iterations
   int i;
-  for (i = 0; i < 10; ++i)
-    {
-    if (result <= 0)
-      {
+  for (i = 0; i < 10; ++i) {
+    if (result <= 0) {
       result = 0.1;
-      }
-    delta = x - (result*result);
-    result = result + 0.5*delta/result;
-    fprintf(stdout,"Computing sqrt of %g to be %g\n",x,result);
     }
+    delta = x - (result * result);
+    result = result + 0.5 * delta / result;
+    fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+  }
 
   return result;
 }
diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx
index c27da0b..2fae364 100644
--- a/Tests/Tutorial/Step7/tutorial.cxx
+++ b/Tests/Tutorial/Step7/tutorial.cxx
@@ -1,38 +1,33 @@
 // A simple program that computes the square root of a number
+#include "TutorialConfig.h"
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include "TutorialConfig.h"
 
 #ifdef USE_MYMATH
 #include "MathFunctions.h"
 #endif
 
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
 {
-  if (argc < 2)
-    {
-    fprintf(stdout,"%s Version %d.%d\n",
-            argv[0],
-            Tutorial_VERSION_MAJOR,
+  if (argc < 2) {
+    fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
             Tutorial_VERSION_MINOR);
-    fprintf(stdout,"Usage: %s number\n",argv[0]);
+    fprintf(stdout, "Usage: %s number\n", argv[0]);
     return 1;
-    }
+  }
 
   double inputValue = atof(argv[1]);
   double outputValue = 0;
 
-  if(inputValue >= 0)
-    {
+  if (inputValue >= 0) {
 #ifdef USE_MYMATH
     outputValue = mysqrt(inputValue);
 #else
     outputValue = sqrt(inputValue);
 #endif
-    }
+  }
 
-  fprintf(stdout,"The square root of %g is %g\n",
-          inputValue, outputValue);
+  fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
   return 0;
 }
diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt
index 73ea05a..20301c2 100644
--- a/Tests/VSExternalInclude/CMakeLists.txt
+++ b/Tests/VSExternalInclude/CMakeLists.txt
@@ -1,13 +1,10 @@
 cmake_minimum_required (VERSION 2.6)
 project(VSExternalInclude)
 
-if(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
-  set(PROJECT_EXT dsp)
-else()
-  set(PROJECT_EXT vcproj)
-endif()
 if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124]")
   set(PROJECT_EXT vcxproj)
+else()
+  set(PROJECT_EXT vcproj)
 endif()
 
 # make sure directories exists
diff --git a/Tests/VSExternalInclude/Lib1/lib1.h b/Tests/VSExternalInclude/Lib1/lib1.h
index 543e71e..178365a 100644
--- a/Tests/VSExternalInclude/Lib1/lib1.h
+++ b/Tests/VSExternalInclude/Lib1/lib1.h
@@ -4,5 +4,4 @@
 
 int add1(int num);
 
-
 #endif
diff --git a/Tests/VSGNUFortran/c_code/main.c b/Tests/VSGNUFortran/c_code/main.c
index 9157cc5..60c1120 100644
--- a/Tests/VSGNUFortran/c_code/main.c
+++ b/Tests/VSGNUFortran/c_code/main.c
@@ -2,6 +2,6 @@
 extern void FC_hello(void);
 int main()
 {
- FC_hello();
- return 0;
+  FC_hello();
+  return 0;
 }
diff --git a/Tests/VSMASM/main.c b/Tests/VSMASM/main.c
index 570ba16..18ddb78 100644
--- a/Tests/VSMASM/main.c
+++ b/Tests/VSMASM/main.c
@@ -1,2 +1,5 @@
 extern int foo(void);
-int main(void) { return foo(); }
+int main(void)
+{
+  return foo();
+}
diff --git a/Tests/VSMidl/src/CMakeLists.txt b/Tests/VSMidl/src/CMakeLists.txt
index 86c04ed..e745fdd 100644
--- a/Tests/VSMidl/src/CMakeLists.txt
+++ b/Tests/VSMidl/src/CMakeLists.txt
@@ -1,12 +1,6 @@
 cmake_minimum_required(VERSION 2.8)
 project(VSMidl)
 
-if(MSVC_VERSION GREATER 1200)
-  include_directories("${CMAKE_CURRENT_BINARY_DIR}/\$(IntDir)")
-else()
-  # midl generated headers end up directly in CMAKE_CURRENT_BINARY_DIR with
-  # VS6 builds.
-  include_directories("${CMAKE_CURRENT_BINARY_DIR}")
-endif()
+include_directories("${CMAKE_CURRENT_BINARY_DIR}/\$(IntDir)")
 
 add_executable(VSMidl main.cpp test.idl)
diff --git a/Tests/VSMidl/src/main.cpp b/Tests/VSMidl/src/main.cpp
index 6b78fcc..68089ad 100644
--- a/Tests/VSMidl/src/main.cpp
+++ b/Tests/VSMidl/src/main.cpp
@@ -9,9 +9,9 @@ int main(int argc, char** argv)
   IID iid = IID_ICMakeMidlTest;
 
   printf("Running '%s'\n", argv[0]);
-  printf("  libid starts with '0x%08lx'\n", (long) libid.Data1);
-  printf("  clsid starts with '0x%08lx'\n", (long) clsid.Data1);
-  printf("    iid starts with '0x%08lx'\n", (long) iid.Data1);
+  printf("  libid starts with '0x%08lx'\n", (long)libid.Data1);
+  printf("  clsid starts with '0x%08lx'\n", (long)clsid.Data1);
+  printf("    iid starts with '0x%08lx'\n", (long)iid.Data1);
 
   return 0;
 }
diff --git a/Tests/VSNsightTegra/jni/first.c b/Tests/VSNsightTegra/jni/first.c
index f09e376..b9dee27 100644
--- a/Tests/VSNsightTegra/jni/first.c
+++ b/Tests/VSNsightTegra/jni/first.c
@@ -16,7 +16,7 @@
  */
 #include "first.h"
 
-int  first(int  x, int  y)
+int first(int x, int y)
 {
-    return x + y;
+  return x + y;
 }
diff --git a/Tests/VSNsightTegra/jni/first.h b/Tests/VSNsightTegra/jni/first.h
index d893480..9dfd8b8 100644
--- a/Tests/VSNsightTegra/jni/first.h
+++ b/Tests/VSNsightTegra/jni/first.h
@@ -17,6 +17,6 @@
 #ifndef FIRST_H
 #define FIRST_H
 
-extern int first(int  x, int  y);
+extern int first(int x, int y);
 
 #endif /* FIRST_H */
diff --git a/Tests/VSNsightTegra/jni/second.c b/Tests/VSNsightTegra/jni/second.c
index 4631848..12fcdb6 100644
--- a/Tests/VSNsightTegra/jni/second.c
+++ b/Tests/VSNsightTegra/jni/second.c
@@ -17,11 +17,8 @@
 #include "first.h"
 #include <jni.h>
 
-jint
-Java_com_example_twolibs_TwoLibs_add( JNIEnv*  env,
-                                      jobject  this,
-                                      jint     x,
-                                      jint     y )
+jint Java_com_example_twolibs_TwoLibs_add(JNIEnv* env, jobject this, jint x,
+                                          jint y)
 {
-    return first(x, y);
+  return first(x, y);
 }
diff --git a/Tests/VSResource/lib.cpp b/Tests/VSResource/lib.cpp
index 006e3e4..c912397 100644
--- a/Tests/VSResource/lib.cpp
+++ b/Tests/VSResource/lib.cpp
@@ -1 +1,4 @@
-int lib() { return 0; }
+int lib()
+{
+  return 0;
+}
diff --git a/Tests/VSResource/main.cpp b/Tests/VSResource/main.cpp
index ccf700c..b2b5ac9 100644
--- a/Tests/VSResource/main.cpp
+++ b/Tests/VSResource/main.cpp
@@ -1,11 +1,11 @@
-#include <windows.h>
 #include <stdio.h>
+#include <windows.h>
 
 extern int lib();
 
 struct x
 {
-  const char *txt;
+  const char* txt;
 };
 
 int main(int argc, char** argv)
@@ -24,35 +24,31 @@ int main(int argc, char** argv)
   test.txt = "*exactly* test.txt";
   fprintf(stdout, "CMAKE_RCDEFINE_NO_QUOTED_STRINGS defined\n");
   fprintf(stdout, "CMAKE_RCDEFINE is %s, and is *not* a string constant\n",
-    CMAKE_RCDEFINE);
+          CMAKE_RCDEFINE);
 #else
   // Expect CMAKE_RCDEFINE to be a string:
   fprintf(stdout, "CMAKE_RCDEFINE='%s', and is a string constant\n",
-    CMAKE_RCDEFINE);
+          CMAKE_RCDEFINE);
 #endif
 
   HRSRC hello = ::FindResource(NULL, MAKEINTRESOURCE(1025), "TEXTFILE");
-  if(hello)
-    {
+  if (hello) {
     fprintf(stdout, "FindResource worked\n");
     HGLOBAL hgbl = ::LoadResource(NULL, hello);
-    int datasize = (int) ::SizeofResource(NULL, hello);
-    if(hgbl && datasize>0)
-      {
+    int datasize = (int)::SizeofResource(NULL, hello);
+    if (hgbl && datasize > 0) {
       fprintf(stdout, "LoadResource worked\n");
       fprintf(stdout, "SizeofResource returned datasize='%d'\n", datasize);
-      void *data = ::LockResource(hgbl);
-      if (data)
-        {
+      void* data = ::LockResource(hgbl);
+      if (data) {
         fprintf(stdout, "LockResource worked\n");
-        char *str = (char *) malloc(datasize+4);
-        if (str)
-          {
+        char* str = (char*)malloc(datasize + 4);
+        if (str) {
           memcpy(str, data, datasize);
           str[datasize] = 'E';
-          str[datasize+1] = 'O';
-          str[datasize+2] = 'R';
-          str[datasize+3] = 0;
+          str[datasize + 1] = 'O';
+          str[datasize + 2] = 'R';
+          str[datasize + 3] = 0;
           fprintf(stdout, "str='%s'\n", str);
           free(str);
 
@@ -62,21 +58,18 @@ int main(int argc, char** argv)
           fprintf(stdout, "LoadString skipped\n");
 #else
           char buf[256];
-          if (::LoadString(NULL, 1026, buf, sizeof(buf)) > 0)
-            {
+          if (::LoadString(NULL, 1026, buf, sizeof(buf)) > 0) {
             fprintf(stdout, "LoadString worked\n");
             fprintf(stdout, "buf='%s'\n", buf);
-            }
-          else
-            {
+          } else {
             fprintf(stdout, "LoadString failed\n");
             ret = 1;
-            }
-#endif
           }
+#endif
         }
       }
     }
+  }
 
   return ret + lib();
 }
diff --git a/Tests/VSResourceNinjaForceRSP/CMakeLists.txt b/Tests/VSResourceNinjaForceRSP/CMakeLists.txt
new file mode 100644
index 0000000..29ba0ce
--- /dev/null
+++ b/Tests/VSResourceNinjaForceRSP/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(VSResourceNinjaForceRSP)
+
+set(CMAKE_NINJA_FORCE_RESPONSE_FILE TRUE)
+
+add_library(ResourceLib lib.cpp test.rc)
+add_executable(VSResourceNinjaForceRSP main.cpp test.rc)
diff --git a/Tests/VSResourceNinjaForceRSP/lib.cpp b/Tests/VSResourceNinjaForceRSP/lib.cpp
new file mode 100644
index 0000000..c912397
--- /dev/null
+++ b/Tests/VSResourceNinjaForceRSP/lib.cpp
@@ -0,0 +1,4 @@
+int lib()
+{
+  return 0;
+}
diff --git a/Tests/VSResourceNinjaForceRSP/main.cpp b/Tests/VSResourceNinjaForceRSP/main.cpp
new file mode 100644
index 0000000..247411d
--- /dev/null
+++ b/Tests/VSResourceNinjaForceRSP/main.cpp
@@ -0,0 +1,6 @@
+int main(int argc, char** argv)
+{
+  (void)argc;
+  (void)argv;
+  return 0;
+}
diff --git a/Tests/VSResourceNinjaForceRSP/test.rc b/Tests/VSResourceNinjaForceRSP/test.rc
new file mode 100644
index 0000000..1ffade6
--- /dev/null
+++ b/Tests/VSResourceNinjaForceRSP/test.rc
@@ -0,0 +1,4 @@
+STRINGTABLE
+BEGIN
+  1234 "5"
+END
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h b/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h
index b58c77d..56bd398 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h
@@ -9,8 +9,7 @@ public:
   // Initializes internal timer values.
   BasicTimer()
   {
-    if (!QueryPerformanceFrequency(&m_frequency))
-    {
+    if (!QueryPerformanceFrequency(&m_frequency)) {
       throw ref new Platform::FailureException();
     }
     Reset();
@@ -28,33 +27,29 @@ public:
   // Update the timer's internal values.
   void Update()
   {
-    if (!QueryPerformanceCounter(&m_currentTime))
-    {
+    if (!QueryPerformanceCounter(&m_currentTime)) {
       throw ref new Platform::FailureException();
     }
 
     m_total = static_cast<float>(
       static_cast<double>(m_currentTime.QuadPart - m_startTime.QuadPart) /
-      static_cast<double>(m_frequency.QuadPart)
-      );
+      static_cast<double>(m_frequency.QuadPart));
 
-    if (m_lastTime.QuadPart == m_startTime.QuadPart)
-    {
-      // If the timer was just reset, report a time delta equivalent to 60Hz frame time.
+    if (m_lastTime.QuadPart == m_startTime.QuadPart) {
+      // If the timer was just reset, report a time delta equivalent to 60Hz
+      // frame time.
       m_delta = 1.0f / 60.0f;
-    }
-    else
-    {
+    } else {
       m_delta = static_cast<float>(
         static_cast<double>(m_currentTime.QuadPart - m_lastTime.QuadPart) /
-        static_cast<double>(m_frequency.QuadPart)
-        );
+        static_cast<double>(m_frequency.QuadPart));
     }
 
     m_lastTime = m_currentTime;
   }
 
-  // Duration in seconds between the last call to Reset() and the last call to Update().
+  // Duration in seconds between the last call to Reset() and the last call to
+  // Update().
   property float Total
   {
     float get() { return m_total; }
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
index f4827f2..1c969cd 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
+++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
@@ -1,4 +1,5 @@
 #include "pch.h"
+
 #include "CubeRenderer.h"
 
 using namespace DirectX;
@@ -6,9 +7,9 @@ using namespace Microsoft::WRL;
 using namespace Windows::Foundation;
 using namespace Windows::UI::Core;
 
-CubeRenderer::CubeRenderer() :
-  m_loadingComplete(false),
-  m_indexCount(0)
+CubeRenderer::CubeRenderer()
+  : m_loadingComplete(false)
+  , m_indexCount(0)
 {
 }
 
@@ -19,119 +20,88 @@ void CubeRenderer::CreateDeviceResources()
   auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
   auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso");
 
-  auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
-    DX::ThrowIfFailed(
-      m_d3dDevice->CreateVertexShader(
-        fileData->Data,
-        fileData->Length,
-        nullptr,
-        &m_vertexShader
-        )
-      );
-
-    const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
-    {
-      { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
-      { "COLOR",    0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
-    };
-
-    DX::ThrowIfFailed(
-      m_d3dDevice->CreateInputLayout(
-        vertexDesc,
-        ARRAYSIZE(vertexDesc),
-        fileData->Data,
-        fileData->Length,
-        &m_inputLayout
-        )
-      );
-  });
-
-  auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
-    DX::ThrowIfFailed(
-      m_d3dDevice->CreatePixelShader(
-        fileData->Data,
-        fileData->Length,
-        nullptr,
-        &m_pixelShader
-        )
-      );
-
-    CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
-    DX::ThrowIfFailed(
-      m_d3dDevice->CreateBuffer(
-        &constantBufferDesc,
-        nullptr,
-        &m_constantBuffer
-        )
-      );
-  });
-
-  auto createCubeTask = (createPSTask && createVSTask).then([this] () {
-    VertexPositionColor cubeVertices[] =
-    {
-      {XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f)},
-      {XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f)},
-      {XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f)},
-      {XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f)},
-      {XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f)},
-      {XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f)},
-      {XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f)},
-      {XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f)},
+  auto createVSTask =
+    loadVSTask.then([this](Platform::Array<byte> ^ fileData) {
+      DX::ThrowIfFailed(m_d3dDevice->CreateVertexShader(
+        fileData->Data, fileData->Length, nullptr, &m_vertexShader));
+
+      const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
+        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,
+          D3D11_INPUT_PER_VERTEX_DATA, 0 },
+        { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12,
+          D3D11_INPUT_PER_VERTEX_DATA, 0 },
+      };
+
+      DX::ThrowIfFailed(m_d3dDevice->CreateInputLayout(
+        vertexDesc, ARRAYSIZE(vertexDesc), fileData->Data, fileData->Length,
+        &m_inputLayout));
+    });
+
+  auto createPSTask =
+    loadPSTask.then([this](Platform::Array<byte> ^ fileData) {
+      DX::ThrowIfFailed(m_d3dDevice->CreatePixelShader(
+        fileData->Data, fileData->Length, nullptr, &m_pixelShader));
+
+      CD3D11_BUFFER_DESC constantBufferDesc(
+        sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
+      DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(&constantBufferDesc, nullptr,
+                                                  &m_constantBuffer));
+    });
+
+  auto createCubeTask = (createPSTask && createVSTask).then([this]() {
+    VertexPositionColor cubeVertices[] = {
+      { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) },
+      { XMFLOAT3(-0.5f, -0.5f, 0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) },
+      { XMFLOAT3(-0.5f, 0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) },
+      { XMFLOAT3(-0.5f, 0.5f, 0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) },
+      { XMFLOAT3(0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) },
+      { XMFLOAT3(0.5f, -0.5f, 0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) },
+      { XMFLOAT3(0.5f, 0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) },
+      { XMFLOAT3(0.5f, 0.5f, 0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) },
     };
 
-    D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
+    D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 };
     vertexBufferData.pSysMem = cubeVertices;
     vertexBufferData.SysMemPitch = 0;
     vertexBufferData.SysMemSlicePitch = 0;
-    CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(cubeVertices), D3D11_BIND_VERTEX_BUFFER);
-    DX::ThrowIfFailed(
-      m_d3dDevice->CreateBuffer(
-        &vertexBufferDesc,
-        &vertexBufferData,
-        &m_vertexBuffer
-        )
-      );
-
-    unsigned short cubeIndices[] =
-    {
-      0,2,1, // -x
-      1,2,3,
-
-      4,5,6, // +x
-      5,7,6,
-
-      0,1,5, // -y
-      0,5,4,
-
-      2,6,7, // +y
-      2,7,3,
-
-      0,4,6, // -z
-      0,6,2,
-
-      1,3,7, // +z
-      1,7,5,
+    CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(cubeVertices),
+                                        D3D11_BIND_VERTEX_BUFFER);
+    DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(
+      &vertexBufferDesc, &vertexBufferData, &m_vertexBuffer));
+
+    unsigned short cubeIndices[] = {
+      0, 2, 1, // -x
+      1, 2, 3,
+
+      4, 5, 6, // +x
+      5, 7, 6,
+
+      0, 1, 5, // -y
+      0, 5, 4,
+
+      2, 6, 7, // +y
+      2, 7, 3,
+
+      0, 4, 6, // -z
+      0, 6, 2,
+
+      1, 3, 7, // +z
+      1, 7, 5,
     };
 
     m_indexCount = ARRAYSIZE(cubeIndices);
 
-    D3D11_SUBRESOURCE_DATA indexBufferData = {0};
+    D3D11_SUBRESOURCE_DATA indexBufferData = { 0 };
     indexBufferData.pSysMem = cubeIndices;
     indexBufferData.SysMemPitch = 0;
     indexBufferData.SysMemSlicePitch = 0;
-    CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices), D3D11_BIND_INDEX_BUFFER);
-    DX::ThrowIfFailed(
-      m_d3dDevice->CreateBuffer(
-        &indexBufferDesc,
-        &indexBufferData,
-        &m_indexBuffer
-        )
-      );
+    CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices),
+                                       D3D11_BIND_INDEX_BUFFER);
+    DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(
+      &indexBufferDesc, &indexBufferData, &m_indexBuffer));
   });
 
-  createCubeTask.then([this] () {
-    m_loadingComplete = true;
-  });
+  createCubeTask.then([this]() { m_loadingComplete = true; });
 }
 
 void CubeRenderer::CreateWindowSizeDependentResources()
@@ -140,8 +110,7 @@ void CubeRenderer::CreateWindowSizeDependentResources()
 
   float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
   float fovAngleY = 70.0f * XM_PI / 180.0f;
-  if (aspectRatio < 1.0f)
-  {
+  if (aspectRatio < 1.0f) {
     fovAngleY /= aspectRatio;
   }
 
@@ -152,109 +121,60 @@ void CubeRenderer::CreateWindowSizeDependentResources()
   // this transform should not be applied.
   XMStoreFloat4x4(
     &m_constantBufferData.projection,
-    XMMatrixTranspose(
-      XMMatrixMultiply(
-        XMMatrixPerspectiveFovRH(
-          fovAngleY,
-          aspectRatio,
-          0.01f,
-          100.0f
-          ),
-        XMLoadFloat4x4(&m_orientationTransform3D)
-        )
-      )
-    );
+    XMMatrixTranspose(XMMatrixMultiply(
+      XMMatrixPerspectiveFovRH(fovAngleY, aspectRatio, 0.01f, 100.0f),
+      XMLoadFloat4x4(&m_orientationTransform3D))));
 }
 
 void CubeRenderer::Update(float timeTotal, float timeDelta)
 {
-  (void) timeDelta; // Unused parameter.
+  (void)timeDelta; // Unused parameter.
 
   XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f);
   XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f);
   XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
 
-  XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
-  XMStoreFloat4x4(&m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
+  XMStoreFloat4x4(&m_constantBufferData.view,
+                  XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
+  XMStoreFloat4x4(&m_constantBufferData.model,
+                  XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
 }
 
 void CubeRenderer::Render()
 {
   const float midnightBlue[] = { 0.098f, 0.098f, 0.439f, 1.000f };
-  m_d3dContext->ClearRenderTargetView(
-    m_renderTargetView.Get(),
-    midnightBlue
-    );
-
-  m_d3dContext->ClearDepthStencilView(
-    m_depthStencilView.Get(),
-    D3D11_CLEAR_DEPTH,
-    1.0f,
-    0
-    );
+  m_d3dContext->ClearRenderTargetView(m_renderTargetView.Get(), midnightBlue);
+
+  m_d3dContext->ClearDepthStencilView(m_depthStencilView.Get(),
+                                      D3D11_CLEAR_DEPTH, 1.0f, 0);
 
   // Only draw the cube once it is loaded (loading is asynchronous).
-  if (!m_loadingComplete)
-  {
+  if (!m_loadingComplete) {
     return;
   }
 
-  m_d3dContext->OMSetRenderTargets(
-    1,
-    m_renderTargetView.GetAddressOf(),
-    m_depthStencilView.Get()
-    );
-
-  m_d3dContext->UpdateSubresource(
-    m_constantBuffer.Get(),
-    0,
-    NULL,
-    &m_constantBufferData,
-    0,
-    0
-    );
+  m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(),
+                                   m_depthStencilView.Get());
+
+  m_d3dContext->UpdateSubresource(m_constantBuffer.Get(), 0, NULL,
+                                  &m_constantBufferData, 0, 0);
 
   UINT stride = sizeof(VertexPositionColor);
   UINT offset = 0;
-  m_d3dContext->IASetVertexBuffers(
-    0,
-    1,
-    m_vertexBuffer.GetAddressOf(),
-    &stride,
-    &offset
-    );
-
-  m_d3dContext->IASetIndexBuffer(
-    m_indexBuffer.Get(),
-    DXGI_FORMAT_R16_UINT,
-    0
-    );
+  m_d3dContext->IASetVertexBuffers(0, 1, m_vertexBuffer.GetAddressOf(),
+                                   &stride, &offset);
+
+  m_d3dContext->IASetIndexBuffer(m_indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
 
   m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
 
   m_d3dContext->IASetInputLayout(m_inputLayout.Get());
 
-  m_d3dContext->VSSetShader(
-    m_vertexShader.Get(),
-    nullptr,
-    0
-    );
-
-  m_d3dContext->VSSetConstantBuffers(
-    0,
-    1,
-    m_constantBuffer.GetAddressOf()
-    );
-
-  m_d3dContext->PSSetShader(
-    m_pixelShader.Get(),
-    nullptr,
-    0
-    );
-
-  m_d3dContext->DrawIndexed(
-    m_indexCount,
-    0,
-    0
-    );
+  m_d3dContext->VSSetShader(m_vertexShader.Get(), nullptr, 0);
+
+  m_d3dContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf());
+
+  m_d3dContext->PSSetShader(m_pixelShader.Get(), nullptr, 0);
+
+  m_d3dContext->DrawIndexed(m_indexCount, 0, 0);
 }
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp
index 3dbb97f..ddcd8bd 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.cpp
@@ -1,6 +1,7 @@
 #include "pch.h"
-#include "Direct3DApp1.h"
+
 #include "BasicTimer.h"
+#include "Direct3DApp1.h"
 
 using namespace Windows::ApplicationModel;
 using namespace Windows::ApplicationModel::Core;
@@ -11,71 +12,76 @@ using namespace Windows::Foundation;
 using namespace Windows::Graphics::Display;
 using namespace concurrency;
 
-Direct3DApp1::Direct3DApp1() :
-  m_windowClosed(false),
-  m_windowVisible(true)
+Direct3DApp1::Direct3DApp1()
+  : m_windowClosed(false)
+  , m_windowVisible(true)
 {
 }
 
-void Direct3DApp1::Initialize(CoreApplicationView^ applicationView)
+void Direct3DApp1::Initialize(CoreApplicationView ^ applicationView)
 {
   applicationView->Activated +=
-        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &Direct3DApp1::OnActivated);
+    ref new TypedEventHandler<CoreApplicationView ^, IActivatedEventArgs ^>(
+      this, &Direct3DApp1::OnActivated);
 
-  CoreApplication::Suspending +=
-        ref new EventHandler<SuspendingEventArgs^>(this, &Direct3DApp1::OnSuspending);
+  CoreApplication::Suspending += ref new EventHandler<SuspendingEventArgs ^>(
+    this, &Direct3DApp1::OnSuspending);
 
   CoreApplication::Resuming +=
-        ref new EventHandler<Platform::Object^>(this, &Direct3DApp1::OnResuming);
+    ref new EventHandler<Platform::Object ^>(this, &Direct3DApp1::OnResuming);
 
   m_renderer = ref new CubeRenderer();
 }
 
-void Direct3DApp1::SetWindow(CoreWindow^ window)
+void Direct3DApp1::SetWindow(CoreWindow ^ window)
 {
   window->SizeChanged +=
-        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &Direct3DApp1::OnWindowSizeChanged);
+    ref new TypedEventHandler<CoreWindow ^, WindowSizeChangedEventArgs ^>(
+      this, &Direct3DApp1::OnWindowSizeChanged);
 
   window->VisibilityChanged +=
-    ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &Direct3DApp1::OnVisibilityChanged);
+    ref new TypedEventHandler<CoreWindow ^, VisibilityChangedEventArgs ^>(
+      this, &Direct3DApp1::OnVisibilityChanged);
 
   window->Closed +=
-        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &Direct3DApp1::OnWindowClosed);
+    ref new TypedEventHandler<CoreWindow ^, CoreWindowEventArgs ^>(
+      this, &Direct3DApp1::OnWindowClosed);
 
 #ifndef PHONE
   window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
 #endif
 
   window->PointerPressed +=
-    ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &Direct3DApp1::OnPointerPressed);
+    ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(
+      this, &Direct3DApp1::OnPointerPressed);
 
   window->PointerMoved +=
-    ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &Direct3DApp1::OnPointerMoved);
+    ref new TypedEventHandler<CoreWindow ^, PointerEventArgs ^>(
+      this, &Direct3DApp1::OnPointerMoved);
 
   m_renderer->Initialize(CoreWindow::GetForCurrentThread());
 }
 
-void Direct3DApp1::Load(Platform::String^ entryPoint)
+void Direct3DApp1::Load(Platform::String ^ entryPoint)
 {
 }
 
 void Direct3DApp1::Run()
 {
-  BasicTimer^ timer = ref new BasicTimer();
+  BasicTimer ^ timer = ref new BasicTimer();
 
-  while (!m_windowClosed)
-  {
-    if (m_windowVisible)
-    {
+  while (!m_windowClosed) {
+    if (m_windowVisible) {
       timer->Update();
-      CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
+      CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(
+        CoreProcessEventsOption::ProcessAllIfPresent);
       m_renderer->Update(timer->Total, timer->Delta);
       m_renderer->Render();
-      m_renderer->Present(); // This call is synchronized to the display frame rate.
-    }
-    else
-    {
-      CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
+      m_renderer
+        ->Present(); // This call is synchronized to the display frame rate.
+    } else {
+      CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(
+        CoreProcessEventsOption::ProcessOneAndAllPending);
     }
   }
 }
@@ -84,54 +90,63 @@ void Direct3DApp1::Uninitialize()
 {
 }
 
-void Direct3DApp1::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
+void Direct3DApp1::OnWindowSizeChanged(CoreWindow ^ sender,
+                                       WindowSizeChangedEventArgs ^ args)
 {
   m_renderer->UpdateForWindowSizeChange();
 }
 
-void Direct3DApp1::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
+void Direct3DApp1::OnVisibilityChanged(CoreWindow ^ sender,
+                                       VisibilityChangedEventArgs ^ args)
 {
   m_windowVisible = args->Visible;
 }
 
-void Direct3DApp1::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
+void Direct3DApp1::OnWindowClosed(CoreWindow ^ sender,
+                                  CoreWindowEventArgs ^ args)
 {
   m_windowClosed = true;
 }
 
-void Direct3DApp1::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
+void Direct3DApp1::OnPointerPressed(CoreWindow ^ sender,
+                                    PointerEventArgs ^ args)
 {
   // Insert your code here.
 }
 
-void Direct3DApp1::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
+void Direct3DApp1::OnPointerMoved(CoreWindow ^ sender, PointerEventArgs ^ args)
 {
   // Insert your code here.
 }
 
-void Direct3DApp1::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
+void Direct3DApp1::OnActivated(CoreApplicationView ^ applicationView,
+                               IActivatedEventArgs ^ args)
 {
   CoreWindow::GetForCurrentThread()->Activate();
 }
 
-void Direct3DApp1::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
+void Direct3DApp1::OnSuspending(Platform::Object ^ sender,
+                                SuspendingEventArgs ^ args)
 {
-  // Save app state asynchronously after requesting a deferral. Holding a deferral
-  // indicates that the application is busy performing suspending operations. Be
-  // aware that a deferral may not be held indefinitely. After about five seconds,
+  // Save app state asynchronously after requesting a deferral. Holding a
+  // deferral
+  // indicates that the application is busy performing suspending operations.
+  // Be
+  // aware that a deferral may not be held indefinitely. After about five
+  // seconds,
   // the app will be forced to exit.
-  SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
+  SuspendingDeferral ^ deferral = args->SuspendingOperation->GetDeferral();
   m_renderer->ReleaseResourcesForSuspending();
 
-  create_task([this, deferral]()
-  {
+  create_task([this, deferral]() {
     // Insert your code here.
 
     deferral->Complete();
   });
 }
 
-void Direct3DApp1::OnResuming(Platform::Object^ sender, Platform::Object^ args)
+void Direct3DApp1::OnResuming(Platform::Object ^ sender,
+                              Platform::Object ^ args)
 {
   // Restore any data or state that was unloaded on suspend. By default, data
   // and state are persisted when resuming from suspend. Note that this event
@@ -139,13 +154,12 @@ void Direct3DApp1::OnResuming(Platform::Object^ sender, Platform::Object^ args)
   m_renderer->CreateWindowSizeDependentResources();
 }
 
-IFrameworkView^ Direct3DApplicationSource::CreateView()
+IFrameworkView ^ Direct3DApplicationSource::CreateView()
 {
-    return ref new Direct3DApp1();
+  return ref new Direct3DApp1();
 }
 
-[Platform::MTAThread]
-int main(Platform::Array<Platform::String^>^)
+[Platform::MTAThread] int main(Platform::Array<Platform::String ^> ^)
 {
   auto direct3DApplicationSource = ref new Direct3DApplicationSource();
   CoreApplication::Run(direct3DApplicationSource);
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
index 40b69a1..c3499c7 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
@@ -1,40 +1,55 @@
 #pragma once
 
 #include "pch.h"
+
 #include "CubeRenderer.h"
 
-ref class Direct3DApp1 sealed : public Windows::ApplicationModel::Core::IFrameworkView
+ref class Direct3DApp1 sealed
+  : public Windows::ApplicationModel::Core::IFrameworkView
 {
 public:
   Direct3DApp1();
 
   // IFrameworkView Methods.
-  virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
-  virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
-  virtual void Load(Platform::String^ entryPoint);
+  virtual void Initialize(
+    Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView);
+  virtual void SetWindow(Windows::UI::Core::CoreWindow ^ window);
+  virtual void Load(Platform::String ^ entryPoint);
   virtual void Run();
   virtual void Uninitialize();
 
 protected:
   // Event Handlers.
-  void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
-  void OnLogicalDpiChanged(Platform::Object^ sender);
-  void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
-  void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
-  void OnResuming(Platform::Object^ sender, Platform::Object^ args);
-  void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
-  void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
-  void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
-  void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+  void OnWindowSizeChanged(Windows::UI::Core::CoreWindow ^ sender,
+                           Windows::UI::Core::WindowSizeChangedEventArgs ^
+                             args);
+  void OnLogicalDpiChanged(Platform::Object ^ sender);
+  void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView ^
+                     applicationView,
+                   Windows::ApplicationModel::Activation::IActivatedEventArgs ^
+                     args);
+  void OnSuspending(Platform::Object ^ sender,
+                    Windows::ApplicationModel::SuspendingEventArgs ^ args);
+  void OnResuming(Platform::Object ^ sender, Platform::Object ^ args);
+  void OnWindowClosed(Windows::UI::Core::CoreWindow ^ sender,
+                      Windows::UI::Core::CoreWindowEventArgs ^ args);
+  void OnVisibilityChanged(Windows::UI::Core::CoreWindow ^ sender,
+                           Windows::UI::Core::VisibilityChangedEventArgs ^
+                             args);
+  void OnPointerPressed(Windows::UI::Core::CoreWindow ^ sender,
+                        Windows::UI::Core::PointerEventArgs ^ args);
+  void OnPointerMoved(Windows::UI::Core::CoreWindow ^ sender,
+                      Windows::UI::Core::PointerEventArgs ^ args);
 
 private:
-  CubeRenderer^ m_renderer;
+  CubeRenderer ^ m_renderer;
   bool m_windowClosed;
   bool m_windowVisible;
 };
 
-ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
+ref class Direct3DApplicationSource sealed
+  : Windows::ApplicationModel::Core::IFrameworkViewSource
 {
 public:
-  virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
+  virtual Windows::ApplicationModel::Core::IFrameworkView ^ CreateView();
 };
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
index 46727b5..8f3452c 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
@@ -1,4 +1,5 @@
 #include "pch.h"
+
 #include "Direct3DBase.h"
 
 using namespace DirectX;
@@ -13,7 +14,7 @@ Direct3DBase::Direct3DBase()
 }
 
 // Initialize the Direct3D resources required to run.
-void Direct3DBase::Initialize(CoreWindow^ window)
+void Direct3DBase::Initialize(CoreWindow ^ window)
 {
   m_window = window;
 
@@ -24,7 +25,8 @@ void Direct3DBase::Initialize(CoreWindow^ window)
 // Recreate all device resources and set them back to the current state.
 void Direct3DBase::HandleDeviceLost()
 {
-  // Reset these member variables to ensure that UpdateForWindowSizeChange recreates all resources.
+  // Reset these member variables to ensure that UpdateForWindowSizeChange
+  // recreates all resources.
   m_windowBounds.Width = 0;
   m_windowBounds.Height = 0;
   m_swapChain = nullptr;
@@ -36,56 +38,50 @@ void Direct3DBase::HandleDeviceLost()
 // These are the resources that depend on the device.
 void Direct3DBase::CreateDeviceResources()
 {
-  // This flag adds support for surfaces with a different color channel ordering
+  // This flag adds support for surfaces with a different color channel
+  // ordering
   // than the API default. It is required for compatibility with Direct2D.
   UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
 
 #if defined(_DEBUG)
-  // If the project is in a debug build, enable debugging via SDK Layers with this flag.
+  // If the project is in a debug build, enable debugging via SDK Layers with
+  // this flag.
   creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
 #endif
 
-  // This array defines the set of DirectX hardware feature levels this app will support.
+  // This array defines the set of DirectX hardware feature levels this app
+  // will support.
   // Note the ordering should be preserved.
-  // Don't forget to declare your application's minimum required feature level in its
-  // description.  All applications are assumed to support 9.1 unless otherwise stated.
-  D3D_FEATURE_LEVEL featureLevels[] =
-  {
-    D3D_FEATURE_LEVEL_11_1,
-    D3D_FEATURE_LEVEL_11_0,
-    D3D_FEATURE_LEVEL_10_1,
-    D3D_FEATURE_LEVEL_10_0,
-    D3D_FEATURE_LEVEL_9_3,
-    D3D_FEATURE_LEVEL_9_2,
+  // Don't forget to declare your application's minimum required feature level
+  // in its
+  // description.  All applications are assumed to support 9.1 unless otherwise
+  // stated.
+  D3D_FEATURE_LEVEL featureLevels[] = {
+    D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1,
+    D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_9_3,  D3D_FEATURE_LEVEL_9_2,
     D3D_FEATURE_LEVEL_9_1
   };
 
   // Create the Direct3D 11 API device object and a corresponding context.
   ComPtr<ID3D11Device> device;
   ComPtr<ID3D11DeviceContext> context;
-  DX::ThrowIfFailed(
-    D3D11CreateDevice(
-      nullptr, // Specify nullptr to use the default adapter.
-      D3D_DRIVER_TYPE_HARDWARE,
-      nullptr,
-      creationFlags, // Set set debug and Direct2D compatibility flags.
-      featureLevels, // List of feature levels this app can support.
-      ARRAYSIZE(featureLevels),
-      D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
-      &device, // Returns the Direct3D device created.
-      &m_featureLevel, // Returns feature level of device created.
-      &context // Returns the device immediate context.
-      )
-    );
+  DX::ThrowIfFailed(D3D11CreateDevice(
+    nullptr, // Specify nullptr to use the default adapter.
+    D3D_DRIVER_TYPE_HARDWARE, nullptr,
+    creationFlags, // Set set debug and Direct2D compatibility flags.
+    featureLevels, // List of feature levels this app can support.
+    ARRAYSIZE(featureLevels),
+    D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows
+                       // Store apps.
+    &device,           // Returns the Direct3D device created.
+    &m_featureLevel,   // Returns feature level of device created.
+    &context           // Returns the device immediate context.
+    ));
 
   // Get the Direct3D 11.1 API device and context interfaces.
-  DX::ThrowIfFailed(
-    device.As(&m_d3dDevice)
-    );
+  DX::ThrowIfFailed(device.As(&m_d3dDevice));
 
-  DX::ThrowIfFailed(
-    context.As(&m_d3dContext)
-    );
+  DX::ThrowIfFailed(context.As(&m_d3dContext));
 }
 
 // Allocate all memory resources that change on a window SizeChanged event.
@@ -99,9 +95,9 @@ void Direct3DBase::CreateWindowSizeDependentResources()
   float windowWidth = ConvertDipsToPixels(m_windowBounds.Width);
   float windowHeight = ConvertDipsToPixels(m_windowBounds.Height);
 
-  // The width and height of the swap chain must be based on the window's
-  // landscape-oriented width and height. If the window is in a portrait
-  // orientation, the dimensions must be reversed.
+// The width and height of the swap chain must be based on the window's
+// landscape-oriented width and height. If the window is in a portrait
+// orientation, the dimensions must be reversed.
 #if WINVER > 0x0602
   m_orientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
 #else
@@ -112,126 +108,100 @@ void Direct3DBase::CreateWindowSizeDependentResources()
   m_orientation = DisplayProperties::CurrentOrientation;
 #endif
 #endif
-  bool swapDimensions =
-    m_orientation == DisplayOrientations::Portrait ||
+  bool swapDimensions = m_orientation == DisplayOrientations::Portrait ||
     m_orientation == DisplayOrientations::PortraitFlipped;
   m_renderTargetSize.Width = swapDimensions ? windowHeight : windowWidth;
   m_renderTargetSize.Height = swapDimensions ? windowWidth : windowHeight;
 
-  if(m_swapChain != nullptr)
-  {
+  if (m_swapChain != nullptr) {
     // If the swap chain already exists, resize it.
     DX::ThrowIfFailed(
-      m_swapChain->ResizeBuffers(
-        2, // Double-buffered swap chain.
-        static_cast<UINT>(m_renderTargetSize.Width),
-        static_cast<UINT>(m_renderTargetSize.Height),
-        DXGI_FORMAT_B8G8R8A8_UNORM,
-        0
-        )
-      );
-  }
-  else
-  {
-    // Otherwise, create a new one using the same adapter as the existing Direct3D device.
-    DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
-    swapChainDesc.Width = static_cast<UINT>(m_renderTargetSize.Width); // Match the size of the window.
+      m_swapChain->ResizeBuffers(2, // Double-buffered swap chain.
+                                 static_cast<UINT>(m_renderTargetSize.Width),
+                                 static_cast<UINT>(m_renderTargetSize.Height),
+                                 DXGI_FORMAT_B8G8R8A8_UNORM, 0));
+  } else {
+    // Otherwise, create a new one using the same adapter as the existing
+    // Direct3D device.
+    DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
+    swapChainDesc.Width = static_cast<UINT>(
+      m_renderTargetSize.Width); // Match the size of the window.
     swapChainDesc.Height = static_cast<UINT>(m_renderTargetSize.Height);
-    swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
+    swapChainDesc.Format =
+      DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format.
     swapChainDesc.Stereo = false;
     swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling.
     swapChainDesc.SampleDesc.Quality = 0;
     swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
 #if PHONE && WINVER <= 0x0602
     swapChainDesc.BufferCount = 1; // Use double-buffering to minimize latency.
-    swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // On phone, only stretch and aspect-ratio stretch scaling are allowed.
-    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // On phone, no swap effects are supported.
+    swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // On phone, only stretch and
+                                                  // aspect-ratio stretch
+                                                  // scaling are allowed.
+    swapChainDesc.SwapEffect =
+      DXGI_SWAP_EFFECT_DISCARD; // On phone, no swap effects are supported.
 #else
     swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency.
     swapChainDesc.Scaling = DXGI_SCALING_NONE;
-    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect.
+    swapChainDesc.SwapEffect =
+      DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this
+                                        // SwapEffect.
 #endif
     swapChainDesc.Flags = 0;
 
-    ComPtr<IDXGIDevice1>  dxgiDevice;
-    DX::ThrowIfFailed(
-      m_d3dDevice.As(&dxgiDevice)
-      );
+    ComPtr<IDXGIDevice1> dxgiDevice;
+    DX::ThrowIfFailed(m_d3dDevice.As(&dxgiDevice));
 
     ComPtr<IDXGIAdapter> dxgiAdapter;
-    DX::ThrowIfFailed(
-      dxgiDevice->GetAdapter(&dxgiAdapter)
-      );
+    DX::ThrowIfFailed(dxgiDevice->GetAdapter(&dxgiAdapter));
 
     ComPtr<IDXGIFactory2> dxgiFactory;
     DX::ThrowIfFailed(
-      dxgiAdapter->GetParent(
-        __uuidof(IDXGIFactory2),
-        &dxgiFactory
-        )
-      );
-
-    Windows::UI::Core::CoreWindow^ window = m_window.Get();
-    DX::ThrowIfFailed(
-      dxgiFactory->CreateSwapChainForCoreWindow(
-        m_d3dDevice.Get(),
-        reinterpret_cast<IUnknown*>(window),
-        &swapChainDesc,
-        nullptr, // Allow on all displays.
-        &m_swapChain
-        )
-      );
-
-    // Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
-    // ensures that the application will only render after each VSync, minimizing power consumption.
-    DX::ThrowIfFailed(
-      dxgiDevice->SetMaximumFrameLatency(1)
-      );
+      dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory));
+
+    Windows::UI::Core::CoreWindow ^ window = m_window.Get();
+    DX::ThrowIfFailed(dxgiFactory->CreateSwapChainForCoreWindow(
+      m_d3dDevice.Get(), reinterpret_cast<IUnknown*>(window), &swapChainDesc,
+      nullptr, // Allow on all displays.
+      &m_swapChain));
+
+    // Ensure that DXGI does not queue more than one frame at a time. This both
+    // reduces latency and
+    // ensures that the application will only render after each VSync,
+    // minimizing power consumption.
+    DX::ThrowIfFailed(dxgiDevice->SetMaximumFrameLatency(1));
   }
 
   // Set the proper orientation for the swap chain, and generate the
   // 3D matrix transformation for rendering to the rotated swap chain.
   DXGI_MODE_ROTATION rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
-  switch (m_orientation)
-  {
+  switch (m_orientation) {
     case DisplayOrientations::Landscape:
       rotation = DXGI_MODE_ROTATION_IDENTITY;
       m_orientationTransform3D = XMFLOAT4X4( // 0-degree Z-rotation
-        1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 1.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 1.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
-        );
+        1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
+        0.0f, 0.0f, 0.0f, 1.0f);
       break;
 
     case DisplayOrientations::Portrait:
       rotation = DXGI_MODE_ROTATION_ROTATE270;
       m_orientationTransform3D = XMFLOAT4X4( // 90-degree Z-rotation
-        0.0f, 1.0f, 0.0f, 0.0f,
-        -1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 1.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
-        );
+        0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+        0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
       break;
 
     case DisplayOrientations::LandscapeFlipped:
       rotation = DXGI_MODE_ROTATION_ROTATE180;
       m_orientationTransform3D = XMFLOAT4X4( // 180-degree Z-rotation
-        -1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, -1.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 1.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
-        );
+        -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+        0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
       break;
 
     case DisplayOrientations::PortraitFlipped:
       rotation = DXGI_MODE_ROTATION_ROTATE90;
       m_orientationTransform3D = XMFLOAT4X4( // 270-degree Z-rotation
-        0.0f, -1.0f, 0.0f, 0.0f,
-        1.0f, 0.0f, 0.0f, 0.0f,
-        0.0f, 0.0f, 1.0f, 0.0f,
-        0.0f, 0.0f, 0.0f, 1.0f
-        );
+        0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
+        0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
       break;
 
     default:
@@ -239,64 +209,35 @@ void Direct3DBase::CreateWindowSizeDependentResources()
   }
 
 #if !PHONE || WINVER > 0x0602
-  DX::ThrowIfFailed(
-    m_swapChain->SetRotation(rotation)
-    );
+  DX::ThrowIfFailed(m_swapChain->SetRotation(rotation));
 #endif // !PHONE
 
   // Create a render target view of the swap chain back buffer.
   ComPtr<ID3D11Texture2D> backBuffer;
   DX::ThrowIfFailed(
-    m_swapChain->GetBuffer(
-      0,
-      __uuidof(ID3D11Texture2D),
-      &backBuffer
-      )
-    );
+    m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &backBuffer));
 
-  DX::ThrowIfFailed(
-    m_d3dDevice->CreateRenderTargetView(
-      backBuffer.Get(),
-      nullptr,
-      &m_renderTargetView
-      )
-    );
+  DX::ThrowIfFailed(m_d3dDevice->CreateRenderTargetView(
+    backBuffer.Get(), nullptr, &m_renderTargetView));
 
   // Create a depth stencil view.
   CD3D11_TEXTURE2D_DESC depthStencilDesc(
-    DXGI_FORMAT_D24_UNORM_S8_UINT,
-    static_cast<UINT>(m_renderTargetSize.Width),
-    static_cast<UINT>(m_renderTargetSize.Height),
-    1,
-    1,
-    D3D11_BIND_DEPTH_STENCIL
-    );
+    DXGI_FORMAT_D24_UNORM_S8_UINT, static_cast<UINT>(m_renderTargetSize.Width),
+    static_cast<UINT>(m_renderTargetSize.Height), 1, 1,
+    D3D11_BIND_DEPTH_STENCIL);
 
   ComPtr<ID3D11Texture2D> depthStencil;
   DX::ThrowIfFailed(
-    m_d3dDevice->CreateTexture2D(
-      &depthStencilDesc,
-      nullptr,
-      &depthStencil
-      )
-    );
-
-  CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
-  DX::ThrowIfFailed(
-    m_d3dDevice->CreateDepthStencilView(
-      depthStencil.Get(),
-      &depthStencilViewDesc,
-      &m_depthStencilView
-      )
-    );
+    m_d3dDevice->CreateTexture2D(&depthStencilDesc, nullptr, &depthStencil));
+
+  CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(
+    D3D11_DSV_DIMENSION_TEXTURE2D);
+  DX::ThrowIfFailed(m_d3dDevice->CreateDepthStencilView(
+    depthStencil.Get(), &depthStencilViewDesc, &m_depthStencilView));
 
   // Set the rendering viewport to target the entire window.
-  CD3D11_VIEWPORT viewport(
-    0.0f,
-    0.0f,
-    m_renderTargetSize.Width,
-    m_renderTargetSize.Height
-    );
+  CD3D11_VIEWPORT viewport(0.0f, 0.0f, m_renderTargetSize.Width,
+                           m_renderTargetSize.Height);
 
   m_d3dContext->RSSetViewports(1, &viewport);
 }
@@ -305,14 +246,15 @@ void Direct3DBase::CreateWindowSizeDependentResources()
 void Direct3DBase::UpdateForWindowSizeChange()
 {
   if (m_window->Bounds.Width != m_windowBounds.Width ||
-    m_window->Bounds.Height != m_windowBounds.Height ||
+      m_window->Bounds.Height != m_windowBounds.Height ||
 #if WINVER > 0x0602
-    m_orientation != DisplayInformation::GetForCurrentView()->CurrentOrientation)
+      m_orientation !=
+        DisplayInformation::GetForCurrentView()->CurrentOrientation)
 #else
-    m_orientation != DisplayProperties::CurrentOrientation)
+      m_orientation != DisplayProperties::CurrentOrientation)
 #endif
   {
-    ID3D11RenderTargetView* nullViews[] = {nullptr};
+    ID3D11RenderTargetView* nullViews[] = { nullptr };
     m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
     m_renderTargetView = nullptr;
     m_depthStencilView = nullptr;
@@ -323,10 +265,14 @@ void Direct3DBase::UpdateForWindowSizeChange()
 
 void Direct3DBase::ReleaseResourcesForSuspending()
 {
-  // Phone applications operate in a memory-constrained environment, so when entering
-  // the background it is a good idea to free memory-intensive objects that will be
-  // easy to restore upon reactivation. The swapchain and backbuffer are good candidates
-  // here, as they consume a large amount of memory and can be reinitialized quickly.
+  // Phone applications operate in a memory-constrained environment, so when
+  // entering
+  // the background it is a good idea to free memory-intensive objects that
+  // will be
+  // easy to restore upon reactivation. The swapchain and backbuffer are good
+  // candidates
+  // here, as they consume a large amount of memory and can be reinitialized
+  // quickly.
   m_swapChain = nullptr;
   m_renderTargetView = nullptr;
   m_depthStencilView = nullptr;
@@ -335,9 +281,11 @@ void Direct3DBase::ReleaseResourcesForSuspending()
 // Method to deliver the final image to the display.
 void Direct3DBase::Present()
 {
-  // The first argument instructs DXGI to block until VSync, putting the application
-  // to sleep until the next VSync. This ensures we don't waste any cycles rendering
-  // frames that will never be displayed to the screen.
+// The first argument instructs DXGI to block until VSync, putting the
+// application
+// to sleep until the next VSync. This ensures we don't waste any cycles
+// rendering
+// frames that will never be displayed to the screen.
 #if PHONE && WINVER <= 0x0602
   HRESULT hr = m_swapChain->Present(1, 0);
 #else
@@ -349,12 +297,13 @@ void Direct3DBase::Present()
   parameters.pScrollRect = nullptr;
   parameters.pScrollOffset = nullptr;
 
-  HRESULT hr = m_swapChain->Present1(1, 0 , &parameters);
+  HRESULT hr = m_swapChain->Present1(1, 0, &parameters);
 #endif
 
   // Discard the contents of the render target.
   // This is a valid operation only when the existing contents will be entirely
-  // overwritten. If dirty or scroll rects are used, this call should be removed.
+  // overwritten. If dirty or scroll rects are used, this call should be
+  // removed.
   m_d3dContext->DiscardView(m_renderTargetView.Get());
 
   // Discard the contents of the depth stencil.
@@ -362,23 +311,24 @@ void Direct3DBase::Present()
 
   // If the device was removed either by a disconnect or a driver upgrade, we
   // must recreate all device resources.
-  if (hr == DXGI_ERROR_DEVICE_REMOVED)
-  {
+  if (hr == DXGI_ERROR_DEVICE_REMOVED) {
     HandleDeviceLost();
-  }
-  else
-  {
+  } else {
     DX::ThrowIfFailed(hr);
   }
 }
 
-// Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels.
+// Method to convert a length in device-independent pixels (DIPs) to a length
+// in physical pixels.
 float Direct3DBase::ConvertDipsToPixels(float dips)
 {
   static const float dipsPerInch = 96.0f;
 #if WINVER > 0x0602
-  return floor(dips * DisplayInformation::GetForCurrentView()->LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
+  return floor(dips * DisplayInformation::GetForCurrentView()->LogicalDpi /
+                 dipsPerInch +
+               0.5f); // Round to nearest integer.
 #else
-  return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
+  return floor(dips * DisplayProperties::LogicalDpi / dipsPerInch +
+               0.5f); // Round to nearest integer.
 #endif
 }
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h
index bba9f16..f373f00 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.h
@@ -5,11 +5,10 @@
 // Helper class that initializes DirectX APIs for 3D rendering.
 ref class Direct3DBase abstract
 {
-internal:
-  Direct3DBase();
+  internal : Direct3DBase();
 
 public:
-  virtual void Initialize(Windows::UI::Core::CoreWindow^ window);
+  virtual void Initialize(Windows::UI::Core::CoreWindow ^ window);
   virtual void HandleDeviceLost();
   virtual void CreateDeviceResources();
   virtual void CreateWindowSizeDependentResources();
@@ -19,7 +18,8 @@ public:
   virtual void Present();
   virtual float ConvertDipsToPixels(float dips);
 
-protected private:
+protected
+private:
   // Direct3D Objects.
   Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
   Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h b/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h
index d411a9b..c991dbb 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/DirectXHelper.h
@@ -1,30 +1,29 @@
 #pragma once
 
-#include <wrl/client.h>
 #include <ppl.h>
 #include <ppltasks.h>
+#include <wrl/client.h>
 
-namespace DX
+namespace DX {
+inline void ThrowIfFailed(HRESULT hr)
 {
-  inline void ThrowIfFailed(HRESULT hr)
-  {
-    if (FAILED(hr))
-    {
-      // Set a breakpoint on this line to catch Win32 API errors.
-      throw Platform::Exception::CreateException(hr);
-    }
+  if (FAILED(hr)) {
+    // Set a breakpoint on this line to catch Win32 API errors.
+    throw Platform::Exception::CreateException(hr);
   }
+}
 
-  // Function that reads from a binary file asynchronously.
-  inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
-  {
-    using namespace Windows::Storage;
-    using namespace Concurrency;
+// Function that reads from a binary file asynchronously.
+inline Concurrency::task<Platform::Array<byte> ^> ReadDataAsync(
+  Platform::String ^ filename)
+{
+  using namespace Windows::Storage;
+  using namespace Concurrency;
 
-    auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
+  auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
 
-    return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file)
-    {
+  return create_task(folder->GetFileAsync(filename))
+    .then([](StorageFile ^ file) {
 #if !PHONE
       return FileIO::ReadBufferAsync(file);
 #else
@@ -35,11 +34,11 @@ namespace DX
       auto fileBuffer = ref new Streams::Buffer(bufferSize);
       return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
 #endif
-    }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
-    {
+    })
+    .then([](Streams::IBuffer ^ fileBuffer) -> Platform::Array<byte> ^ {
       auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
       Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
       return fileData;
     });
-  }
+}
 }
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/pch.h b/Tests/VSWinStorePhone/Direct3DApp1/pch.h
index 2302e66..78ebea3 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/pch.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/pch.h
@@ -1,7 +1,7 @@
 #pragma once
 
-#include <wrl/client.h>
-#include <d3d11_1.h>
 #include <DirectXMath.h>
-#include <memory>
 #include <agile.h>
+#include <d3d11_1.h>
+#include <memory>
+#include <wrl/client.h>
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h
index 16222c5..3e8c883 100644
--- a/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/MyForm.h
@@ -2,77 +2,78 @@
 
 namespace Farrier {
 
-  using namespace System;
-  using namespace System::ComponentModel;
-  using namespace System::Collections;
-  using namespace System::Windows::Forms;
-  using namespace System::Data;
-  using namespace System::Drawing;
+using namespace System;
+using namespace System::ComponentModel;
+using namespace System::Collections;
+using namespace System::Windows::Forms;
+using namespace System::Data;
+using namespace System::Drawing;
 
+/// <summary>
+/// Summary for MyForm
+/// </summary>
+public
+ref class MyForm : public System::Windows::Forms::Form
+{
+public:
+  MyForm(void)
+  {
+    InitializeComponent();
+    //
+    // TODO: Add the constructor code here
+    //
+  }
+
+protected:
   /// <summary>
-  /// Summary for MyForm
+  /// Clean up any resources being used.
   /// </summary>
-  public ref class MyForm : public System::Windows::Forms::Form
+  ~MyForm()
   {
-  public:
-    MyForm(void)
-    {
-      InitializeComponent();
-      //
-      //TODO: Add the constructor code here
-      //
+    if (components) {
+      delete components;
     }
+  }
 
-  protected:
-    /// <summary>
-    /// Clean up any resources being used.
-    /// </summary>
-    ~MyForm()
-    {
-      if (components)
-      {
-        delete components;
-      }
-    }
-  private: System::Windows::Forms::Button^  button1;
-  protected:
+private:
+  System::Windows::Forms::Button ^ button1;
 
-  private:
-    /// <summary>
-    /// Required designer variable.
-    /// </summary>
-    System::ComponentModel::Container ^components;
+protected:
+private:
+  /// <summary>
+  /// Required designer variable.
+  /// </summary>
+  System::ComponentModel::Container ^ components;
 
 #pragma region Windows Form Designer generated code
-    /// <summary>
-    /// Required method for Designer support - do not modify
-    /// the contents of this method with the code editor.
-    /// </summary>
-    void InitializeComponent(void)
-    {
-      this->button1 = (gcnew System::Windows::Forms::Button());
-      this->SuspendLayout();
-      //
-      // button1
-      //
-      this->button1->Location = System::Drawing::Point(13, 13);
-      this->button1->Name = L"button1";
-      this->button1->Size = System::Drawing::Size(75, 23);
-      this->button1->TabIndex = 0;
-      this->button1->Text = L"button1";
-      this->button1->UseVisualStyleBackColor = true;
-      //
-      // MyForm
-      //
-      this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
-      this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
-      this->ClientSize = System::Drawing::Size(284, 261);
-      this->Controls->Add(this->button1);
-      this->Name = L"MyForm";
-      this->Text = L"MyForm";
-      this->ResumeLayout(false);
-
-    }
+  /// <summary>
+  /// Required method for Designer support - do not modify
+  /// the contents of this method with the code editor.
+  /// </summary>
+  void InitializeComponent(void)
+  {
+    this->button1 = (gcnew System::Windows::Forms::Button());
+    this->SuspendLayout();
+    //
+    // button1
+    //
+    this->button1->Location = System::Drawing::Point(13, 13);
+    this->button1->Name = L"button1";
+    this->button1->Size = System::Drawing::Size(75, 23);
+    this->button1->TabIndex = 0;
+    this->button1->Text = L"button1";
+    this->button1->UseVisualStyleBackColor = true;
+    //
+    // MyForm
+    //
+    this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
+    this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
+    this->ClientSize = System::Drawing::Size(284, 261);
+    this->Controls->Add(this->button1);
+    this->Name = L"MyForm";
+    this->Text = L"MyForm";
+    this->ResumeLayout(false);
+  }
 #pragma endregion
-  };
+};
 }
diff --git a/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp b/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp
index aee9e2e..d123e09 100644
--- a/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp
+++ b/Tests/VSWindowsFormsResx/WindowsFormsResx/Source.cpp
@@ -1,4 +1,4 @@
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
   return 0;
 }
diff --git a/Tests/VSXaml/App.xaml.cpp b/Tests/VSXaml/App.xaml.cpp
index 334dc1f..549b7ef 100644
--- a/Tests/VSXaml/App.xaml.cpp
+++ b/Tests/VSXaml/App.xaml.cpp
@@ -4,6 +4,7 @@
 //
 
 #include "pch.h"
+
 #include "MainPage.xaml.h"
 
 using namespace VSXaml;
@@ -22,96 +23,98 @@ using namespace Windows::UI::Xaml::Interop;
 using namespace Windows::UI::Xaml::Media;
 using namespace Windows::UI::Xaml::Navigation;
 
-// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
+// The Blank Application template is documented at
+// http://go.microsoft.com/fwlink/?LinkId=234227
 
 /// <summary>
-/// Initializes the singleton application object.  This is the first line of authored code
-/// executed, and as such is the logical equivalent of main() or WinMain().
+/// Initializes the singleton application object.  This is the first line of
+/// authored code executed, and as such is the logical equivalent of main()
+/// or WinMain().
 /// </summary>
 App::App()
 {
-	InitializeComponent();
-	Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
+  InitializeComponent();
+  Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
 }
 
 /// <summary>
-/// Invoked when the application is launched normally by the end user.	Other entry points
-/// will be used such as when the application is launched to open a specific file.
+/// Invoked when the application is launched normally by the end user.
+/// Other entry points will be used such as when the application is
+/// launched to open a specific file.
 /// </summary>
 /// <param name="e">Details about the launch request and process.</param>
-void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
+void App::OnLaunched(
+  Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ e)
 {
 
 #if _DEBUG
-		// Show graphics profiling information while debugging.
-		if (IsDebuggerPresent())
-		{
-			// Display the current frame rate counters
-			 DebugSettings->EnableFrameRateCounter = true;
-		}
+  // Show graphics profiling information while debugging.
+  if (IsDebuggerPresent()) {
+    // Display the current frame rate counters
+    DebugSettings->EnableFrameRateCounter = true;
+  }
 #endif
 
-	auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
-
-	// Do not repeat app initialization when the Window already has content,
-	// just ensure that the window is active
-	if (rootFrame == nullptr)
-	{
-		// Create a Frame to act as the navigation context and associate it with
-		// a SuspensionManager key
-		rootFrame = ref new Frame();
-
-		// Set the default language
-		rootFrame->Language = Windows::Globalization::ApplicationLanguages::Languages->GetAt(0);
-
-		rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
-
-		if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
-		{
-			// TODO: Restore the saved session state only when appropriate, scheduling the
-			// final launch steps after the restore is complete
-
-		}
-
-		if (rootFrame->Content == nullptr)
-		{
-			// When the navigation stack isn't restored navigate to the first page,
-			// configuring the new page by passing required information as a navigation
-			// parameter
-			rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
-		}
-		// Place the frame in the current Window
-		Window::Current->Content = rootFrame;
-		// Ensure the current window is active
-		Window::Current->Activate();
-	}
-	else
-	{
-		if (rootFrame->Content == nullptr)
-		{
-			// When the navigation stack isn't restored navigate to the first page,
-			// configuring the new page by passing required information as a navigation
-			// parameter
-			rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
-		}
-		// Ensure the current window is active
-		Window::Current->Activate();
-	}
+  auto rootFrame = dynamic_cast<Frame ^>(Window::Current->Content);
+
+  // Do not repeat app initialization when the Window already has content,
+  // just ensure that the window is active
+  if (rootFrame == nullptr) {
+    // Create a Frame to act as the navigation context and associate it with
+    // a SuspensionManager key
+    rootFrame = ref new Frame();
+
+    // Set the default language
+    rootFrame->Language =
+      Windows::Globalization::ApplicationLanguages::Languages->GetAt(0);
+
+    rootFrame->NavigationFailed +=
+      ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(
+        this, &App::OnNavigationFailed);
+
+    if (e->PreviousExecutionState == ApplicationExecutionState::Terminated) {
+      // TODO: Restore the saved session state only when appropriate,
+      // scheduling the
+      // final launch steps after the restore is complete
+    }
+
+    if (rootFrame->Content == nullptr) {
+      // When the navigation stack isn't restored navigate to the first page,
+      // configuring the new page by passing required information as a
+      // navigation
+      // parameter
+      rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
+    }
+    // Place the frame in the current Window
+    Window::Current->Content = rootFrame;
+    // Ensure the current window is active
+    Window::Current->Activate();
+  } else {
+    if (rootFrame->Content == nullptr) {
+      // When the navigation stack isn't restored navigate to the first page,
+      // configuring the new page by passing required information as a
+      // navigation
+      // parameter
+      rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
+    }
+    // Ensure the current window is active
+    Window::Current->Activate();
+  }
 }
 
 /// <summary>
-/// Invoked when application execution is being suspended.	Application state is saved
-/// without knowing whether the application will be terminated or resumed with the contents
-/// of memory still intact.
+/// Invoked when application execution is being suspended.  Application state
+/// is saved without knowing whether the application will be terminated or
+/// resumed with the contents of memory still intact.
 /// </summary>
 /// <param name="sender">The source of the suspend request.</param>
 /// <param name="e">Details about the suspend request.</param>
-void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
+void App::OnSuspending(Object ^ sender, SuspendingEventArgs ^ e)
 {
-	(void) sender;	// Unused parameter
-	(void) e;	// Unused parameter
+  (void)sender; // Unused parameter
+  (void)e;      // Unused parameter
 
-	//TODO: Save application state and stop any background activity
+  // TODO: Save application state and stop any background activity
 }
 
 /// <summary>
@@ -119,7 +122,10 @@ void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
 /// </summary>
 /// <param name="sender">The Frame which failed navigation</param>
 /// <param name="e">Details about the navigation failure</param>
-void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e)
+void App::OnNavigationFailed(
+  Platform::Object ^ sender,
+  Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^ e)
 {
-	throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name);
-}
\ No newline at end of file
+  throw ref new FailureException("Failed to load Page " +
+                                 e->SourcePageType.Name);
+}
diff --git a/Tests/VSXaml/App.xaml.h b/Tests/VSXaml/App.xaml.h
index 1f65bda..d3711d0 100644
--- a/Tests/VSXaml/App.xaml.h
+++ b/Tests/VSXaml/App.xaml.h
@@ -7,21 +7,25 @@
 
 #include "App.g.h"
 
-namespace VSXaml
+namespace VSXaml {
+/// <summary>
+/// Provides application-specific behavior to supplement the default
+/// Application class.
+/// </summary>
+ref class App sealed
 {
-    /// <summary>
-    /// Provides application-specific behavior to supplement the default Application class.
-    /// </summary>
-    ref class App sealed
-    {
-    protected:
-        virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
+protected:
+  virtual void OnLaunched(
+    Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^
+    e) override;
 
-    internal:
-        App();
+  internal : App();
 
-    private:
-        void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
-        void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e);
-    };
+private:
+  void OnSuspending(Platform::Object ^ sender,
+                    Windows::ApplicationModel::SuspendingEventArgs ^ e);
+  void OnNavigationFailed(
+    Platform::Object ^ sender,
+    Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^ e);
+};
 }
diff --git a/Tests/VSXaml/MainPage.xaml.cpp b/Tests/VSXaml/MainPage.xaml.cpp
index d0a64e8..51da237 100644
--- a/Tests/VSXaml/MainPage.xaml.cpp
+++ b/Tests/VSXaml/MainPage.xaml.cpp
@@ -4,6 +4,7 @@
 //
 
 #include "pch.h"
+
 #include "MainPage.xaml.h"
 
 using namespace VSXaml;
@@ -19,9 +20,10 @@ using namespace Windows::UI::Xaml::Input;
 using namespace Windows::UI::Xaml::Media;
 using namespace Windows::UI::Xaml::Navigation;
 
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
+// The Blank Page item template is documented at
+// http://go.microsoft.com/fwlink/?LinkId=234238
 
 MainPage::MainPage()
 {
-	InitializeComponent();
+  InitializeComponent();
 }
diff --git a/Tests/VSXaml/MainPage.xaml.h b/Tests/VSXaml/MainPage.xaml.h
index ccc781b..875d227 100644
--- a/Tests/VSXaml/MainPage.xaml.h
+++ b/Tests/VSXaml/MainPage.xaml.h
@@ -7,15 +7,14 @@
 
 #include "MainPage.g.h"
 
-namespace VSXaml
+namespace VSXaml {
+/// <summary>
+/// An empty page that can be used on its own or navigated to within a Frame.
+/// </summary>
+public
+ref class MainPage sealed
 {
-    /// <summary>
-    /// An empty page that can be used on its own or navigated to within a Frame.
-    /// </summary>
-    public ref class MainPage sealed
-    {
-    public:
-        MainPage();
-
-    };
+public:
+  MainPage();
+};
 }
diff --git a/Tests/Visibility/bar.c b/Tests/Visibility/bar.c
index e425999..b72a1a5 100644
--- a/Tests/Visibility/bar.c
+++ b/Tests/Visibility/bar.c
@@ -1 +1,3 @@
-void bar() {}
+void bar()
+{
+}
diff --git a/Tests/Visibility/foo.cpp b/Tests/Visibility/foo.cpp
index 2b66b69..8373fd2 100644
--- a/Tests/Visibility/foo.cpp
+++ b/Tests/Visibility/foo.cpp
@@ -1,11 +1,11 @@
 class Foo
 {
 public:
-    void bar() {}
+  void bar() {}
 };
 
 void baz()
 {
-	Foo foo;
-	foo.bar();
+  Foo foo;
+  foo.bar();
 }
diff --git a/Tests/Visibility/hidden.c b/Tests/Visibility/hidden.c
index 6e97343..12f071f 100644
--- a/Tests/Visibility/hidden.c
+++ b/Tests/Visibility/hidden.c
@@ -1,4 +1,9 @@
-int hidden_function(void) { return 0; }
+int hidden_function(void)
+{
+  return 0;
+}
 
-__attribute__((visibility("default")))
-int not_hidden(void) { return hidden_function(); }
+__attribute__((visibility("default"))) int not_hidden(void)
+{
+  return hidden_function();
+}
diff --git a/Tests/Visibility/shared.c b/Tests/Visibility/shared.c
index bb94976..7a07939 100644
--- a/Tests/Visibility/shared.c
+++ b/Tests/Visibility/shared.c
@@ -1,3 +1,6 @@
 extern int not_hidden(void);
 
-int shared(void) { return not_hidden(); }
+int shared(void)
+{
+  return not_hidden();
+}
diff --git a/Tests/WarnUnusedCliUnused/empty.cpp b/Tests/WarnUnusedCliUnused/empty.cpp
index 7279c5e..8d91e77 100644
--- a/Tests/WarnUnusedCliUnused/empty.cpp
+++ b/Tests/WarnUnusedCliUnused/empty.cpp
@@ -1,7 +1,7 @@
 #ifdef _WIN32
 __declspec(dllexport)
 #endif
-int empty(void)
+  int empty(void)
 {
   return 0;
 }
diff --git a/Tests/Wrapping/CMakeLists.txt b/Tests/Wrapping/CMakeLists.txt
index aca36bc..7d9a4c6 100644
--- a/Tests/Wrapping/CMakeLists.txt
+++ b/Tests/Wrapping/CMakeLists.txt
@@ -93,7 +93,7 @@ add_library(wraplibFLTK ${wraplibFLTK_FLTK_UI_SRCS})
 add_dependencies(wraplibFLTK fakefluid)
 add_dependencies(fakefluid Wrap)
 fltk_wrap_ui (wrapFLTK fltk2.fl)
-add_executable(wrapFLTK wrapFLTK.c ${wrapFLTK_FLTK_UI_SRCS})
+add_executable(wrapFLTK wrapFLTK.cxx ${wrapFLTK_FLTK_UI_SRCS})
 target_link_libraries(wrapFLTK wraplibFLTK)
 add_dependencies(wrapFLTK fakefluid)
 
diff --git a/Tests/Wrapping/Wrap.c b/Tests/Wrapping/Wrap.c
index 0a1ff50..e8fb8a5 100644
--- a/Tests/Wrapping/Wrap.c
+++ b/Tests/Wrapping/Wrap.c
@@ -1,23 +1,19 @@
 #include <stdio.h>
 
 #ifdef __CLASSIC_C__
-int main(argc, argv)
-  int argc;
-  char ** argv;
+int main(argc, argv) int argc;
+char** argv;
 #else
 int main(int argc, const char* argv[])
 #endif
 {
-  FILE* fout = fopen(argv[argc-1], "w");
-  printf("Wrap creating \"%s\"\n", argv[argc-1]);
-  if(fout)
-    {
+  FILE* fout = fopen(argv[argc - 1], "w");
+  printf("Wrap creating \"%s\"\n", argv[argc - 1]);
+  if (fout) {
     fprintf(fout, "int foo() { return 0; }\n");
     fclose(fout);
-    }
-  else
-    {
+  } else {
     return -1;
-    }
+  }
   return 0;
 }
diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx
index af44679..02c0c52 100644
--- a/Tests/Wrapping/fakefluid.cxx
+++ b/Tests/Wrapping/fakefluid.cxx
@@ -2,16 +2,13 @@
 #include <string.h>
 int main(int ac, char** av)
 {
-  for(int i =0; i < ac; ++i)
-    {
-    if(strcmp(av[i], "-o") == 0 ||
-       strcmp(av[i], "-h") == 0)
-      {
-      fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i+1]);
-      FILE* file = fopen(av[i+1], "w");
+  for (int i = 0; i < ac; ++i) {
+    if (strcmp(av[i], "-o") == 0 || strcmp(av[i], "-h") == 0) {
+      fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i + 1]);
+      FILE* file = fopen(av[i + 1], "w");
       fprintf(file, "// hello\n");
       fclose(file);
-      }
     }
+  }
   return 0;
 }
diff --git a/Tests/Wrapping/qtnoqtmain.cxx b/Tests/Wrapping/qtnoqtmain.cxx
index 92594d5..e94a125 100644
--- a/Tests/Wrapping/qtnoqtmain.cxx
+++ b/Tests/Wrapping/qtnoqtmain.cxx
@@ -2,4 +2,3 @@ int main(int ac, char** av)
 {
   return 0;
 }
-
diff --git a/Tests/Wrapping/qtwrappingmain.cxx b/Tests/Wrapping/qtwrappingmain.cxx
index fabecfc..37234d9 100644
--- a/Tests/Wrapping/qtwrappingmain.cxx
+++ b/Tests/Wrapping/qtwrappingmain.cxx
@@ -1,28 +1,26 @@
-#include <qapplication.h>
 #include "qtwrapping.h"
+#include <qapplication.h>
 
 #ifndef _WIN32
-# include <stdlib.h>
-# include <stdio.h>
+#include <stdio.h>
+#include <stdlib.h>
 #endif
 
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
 {
 #ifndef _WIN32
   const char* display = getenv("DISPLAY");
-  if ( display && strlen(display)>0 )
-    {
+  if (display && strlen(display) > 0) {
 #endif
-    QApplication app(argc,argv);
+    QApplication app(argc, argv);
 
     qtwrapping qtw;
     app.setMainWidget(&qtw);
 #ifndef _WIN32
-    }
-  else
-    {
-    printf("Environment variable DISPLAY is not set. I will pretend like the test passed, but you should really set it.\n");
-    }
+  } else {
+    printf("Environment variable DISPLAY is not set. I will pretend like the "
+           "test passed, but you should really set it.\n");
+  }
 #endif
 
   return 0;
diff --git a/Tests/Wrapping/wrapFLTK.c b/Tests/Wrapping/wrapFLTK.c
deleted file mode 100644
index 78f2de1..0000000
--- a/Tests/Wrapping/wrapFLTK.c
+++ /dev/null
@@ -1 +0,0 @@
-int main(void) { return 0; }
diff --git a/Tests/Wrapping/wrapFLTK.cxx b/Tests/Wrapping/wrapFLTK.cxx
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/Wrapping/wrapFLTK.cxx
@@ -0,0 +1,4 @@
+int main(void)
+{
+  return 0;
+}
diff --git a/Tests/Wrapping/wrapping.cxx b/Tests/Wrapping/wrapping.cxx
index 1482f27..f8b643a 100644
--- a/Tests/Wrapping/wrapping.cxx
+++ b/Tests/Wrapping/wrapping.cxx
@@ -1,4 +1,4 @@
-int main ()
+int main()
 {
   return 0;
 }
diff --git a/Tests/X11/HelloWorldX11.cxx b/Tests/X11/HelloWorldX11.cxx
index f2b8bdd..0863f7b 100644
--- a/Tests/X11/HelloWorldX11.cxx
+++ b/Tests/X11/HelloWorldX11.cxx
@@ -10,7 +10,6 @@
  *
  */
 
-
 #ifndef MAIN_H
 #define MAIN_H 1
 
@@ -19,22 +18,20 @@
 
 /* include the X library headers */
 #include <X11/Xlib.h>
-#include <X11/Xutil.h>
 #include <X11/Xos.h>
+#include <X11/Xutil.h>
 
-class Main {
+class Main
+{
 
 public:
   // constructor
-  Main(int argc, char * const argv[]);
-  //virtual ~Main();
-
+  Main(int argc, char* const argv[]);
+  // virtual ~Main();
 
 private:
-
-
   /* here are our X variables */
-  Display *dis;
+  Display* dis;
   int screen;
   Window win;
   GC gc;
@@ -44,7 +41,6 @@ private:
   void close_x();
   void redraw();
   int delay(int i);
-
 };
 
 #endif
@@ -57,90 +53,90 @@ private:
 // http://www.insanityengine.com/doc/x11/xintro.html
 // jeff louie 02.05.2004
 
-
-
-int main (int argc, char * const argv[]) {
+int main(int argc, char* const argv[])
+{
   Main m(argc, argv);
   return 0;
 }
 
-//Main::~Main() {;};
-Main::Main (int argc, char * const argv[]) {
-  XEvent event;           // XEvent declaration
-  KeySym key;             // KeyPress Events
-  char text[255];         // char buffer for KeyPress Events
+// Main::~Main() {;};
+Main::Main(int argc, char* const argv[])
+{
+  XEvent event;   // XEvent declaration
+  KeySym key;     // KeyPress Events
+  char text[255]; // char buffer for KeyPress Events
 
   init_x();
 
   // event loop
-  while(1) {
-  // get the next event and stuff it into our event variable.
-  // Note:  only events we set the mask for are detected!
-  XNextEvent(dis, &event);
-
-
-  switch (event.type) {
-  int x;
-  int y;
-  case Expose:
-    if (event.xexpose.count==0) {
-    redraw();
-    }
-    break;
-  case KeyPress:
-    if (XLookupString(&event.xkey,text,255,&key,0)==1) {
-    // use the XLookupString routine to convert the invent
-    // KeyPress data into regular text.  Weird but necessary...
-    if ((text[0]=='q') || (text[0]=='Q')) {
-    close_x();
+  while (1) {
+    // get the next event and stuff it into our event variable.
+    // Note:  only events we set the mask for are detected!
+    XNextEvent(dis, &event);
+
+    switch (event.type) {
+      int x;
+      int y;
+      case Expose:
+        if (event.xexpose.count == 0) {
+          redraw();
+        }
+        break;
+      case KeyPress:
+        if (XLookupString(&event.xkey, text, 255, &key, 0) == 1) {
+          // use the XLookupString routine to convert the invent
+          // KeyPress data into regular text.  Weird but necessary...
+          if ((text[0] == 'q') || (text[0] == 'Q')) {
+            close_x();
+          } else {
+            // echo key press
+            printf("You pressed the %c key!\n", text[0]);
+          }
+        }
+        break;
+      case ButtonPress:
+        // get cursor position
+        x = event.xbutton.x;
+        y = event.xbutton.y;
+        strcpy(text, "X is FUN!");
+        XSetForeground(dis, gc, rand() % event.xbutton.x % 255);
+        // draw text at cursor
+        XDrawString(dis, win, gc, x, y, text, strlen(text));
+        break;
+      default:
+        printf("Unhandled event.\n");
     }
-    else {
-    // echo key press
-    printf("You pressed the %c key!\n",text[0]);
-    }
-    }
-    break;
-  case ButtonPress:
-    // get cursor position
-    x= event.xbutton.x;
-    y= event.xbutton.y;
-    strcpy(text,"X is FUN!");
-    XSetForeground(dis,gc,rand()%event.xbutton.x%255);
-    // draw text at cursor
-    XDrawString(dis,win,gc,x,y, text, strlen(text));
-    break;
-  default:
-    printf("Unhandled event.\n");
-  }
   }
 }
 
-void Main::init_x() {
-  unsigned long black,white;
-
-  dis=XOpenDisplay(NULL);
-  screen=DefaultScreen(dis);
-  black=BlackPixel(dis,screen),
-    white=WhitePixel(dis, screen);
-  win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0,
-                          300, 300, 5,black, white);
-  XSetStandardProperties(dis,win,"Hello World","Hi",None,NULL,0,NULL);
-  XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask);
+void Main::init_x()
+{
+  unsigned long black, white;
+
+  dis = XOpenDisplay(NULL);
+  screen = DefaultScreen(dis);
+  black = BlackPixel(dis, screen), white = WhitePixel(dis, screen);
+  win = XCreateSimpleWindow(dis, DefaultRootWindow(dis), 0, 0, 300, 300, 5,
+                            black, white);
+  XSetStandardProperties(dis, win, "Hello World", "Hi", None, NULL, 0, NULL);
+  XSelectInput(dis, win, ExposureMask | ButtonPressMask | KeyPressMask);
   // get Graphics Context
-  gc=XCreateGC(dis, win, 0,0);
-  XSetBackground(dis,gc,white);
-  XSetForeground(dis,gc,black);
+  gc = XCreateGC(dis, win, 0, 0);
+  XSetBackground(dis, gc, white);
+  XSetForeground(dis, gc, black);
   XClearWindow(dis, win);
   XMapRaised(dis, win);
 };
 
-void Main::close_x() {
+void Main::close_x()
+{
   XFreeGC(dis, gc);
-  XDestroyWindow(dis,win);
+  XDestroyWindow(dis, win);
   XCloseDisplay(dis);
   exit(1);
 };
 
-void Main::redraw() {
+void Main::redraw()
+{
   XClearWindow(dis, win);
 };
diff --git a/Tests/XCTest/CocoaExample/AppDelegate.h b/Tests/XCTest/CocoaExample/AppDelegate.h
index 4bf4101..11b5886 100644
--- a/Tests/XCTest/CocoaExample/AppDelegate.h
+++ b/Tests/XCTest/CocoaExample/AppDelegate.h
@@ -1,6 +1,5 @@
 #import <Cocoa/Cocoa.h>
 
- at interface AppDelegate : NSObject <NSApplicationDelegate>
-
+ at interface AppDelegate : NSObject<NSApplicationDelegate>
 
 @end
diff --git a/Tests/XCTest/FrameworkExample/FrameworkExample.c b/Tests/XCTest/FrameworkExample/FrameworkExample.c
index 2da78da..77361c8 100644
--- a/Tests/XCTest/FrameworkExample/FrameworkExample.c
+++ b/Tests/XCTest/FrameworkExample/FrameworkExample.c
@@ -2,5 +2,5 @@
 
 int FourtyTwo()
 {
-    return 42;
+  return 42;
 }
diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h
index f1234fe..882003e 100644
--- a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h
+++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h
@@ -8,13 +8,14 @@
 
 #import <UIKit/UIKit.h>
 
- at interface NavApp3AppDelegate : NSObject <UIApplicationDelegate> {
+ at interface NavApp3AppDelegate : NSObject<UIApplicationDelegate> {
 
-    UIWindow *window;
-    UINavigationController *navigationController;
+  UIWindow* window;
+  UINavigationController* navigationController;
 }
 
- at property (nonatomic, retain) IBOutlet UIWindow *window;
- at property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
+ at property (nonatomic, retain) IBOutlet UIWindow* window;
+ at property (nonatomic, retain)
+  IBOutlet UINavigationController* navigationController;
 
 @end
diff --git a/Tests/iOSNavApp/TotalFunction.c b/Tests/iOSNavApp/TotalFunction.c
index 0965a88..b228a78 100644
--- a/Tests/iOSNavApp/TotalFunction.c
+++ b/Tests/iOSNavApp/TotalFunction.c
@@ -8,7 +8,7 @@
 
 #include "TotalFunction.h"
 
-int Total(const char *context)
+int Total(const char* context)
 {
   return 22;
 }
diff --git a/Tests/iOSNavApp/TotalFunction.h b/Tests/iOSNavApp/TotalFunction.h
index 1301c3d..26ff306 100644
--- a/Tests/iOSNavApp/TotalFunction.h
+++ b/Tests/iOSNavApp/TotalFunction.h
@@ -9,6 +9,6 @@
 #ifndef NavApp3_TotalFunction_h
 #define NavApp3_TotalFunction_h
 
-int Total(const char *context);
+int Total(const char* context);
 
 #endif
diff --git a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
index dad1ae5..4b17875 100644
--- a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
+++ b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
@@ -1,4 +1,5 @@
 #include <windows.h>
+
 #include <msi.h>
 #include <msiquery.h>
 
@@ -11,20 +12,17 @@ std::wstring get_property(MSIHANDLE msi_handle, std::wstring const& name)
 
   UINT status = MsiGetPropertyW(msi_handle, name.c_str(), L"", &size);
 
-  if(status == ERROR_MORE_DATA)
-    {
+  if (status == ERROR_MORE_DATA) {
     std::vector<wchar_t> buffer(size + 1);
     MsiGetPropertyW(msi_handle, name.c_str(), &buffer[0], &size);
     return std::wstring(&buffer[0]);
-    }
-  else
-    {
+  } else {
     return std::wstring();
-    }
+  }
 }
 
-void set_property(MSIHANDLE msi_handle,
-  std::wstring const& name, std::wstring const& value)
+void set_property(MSIHANDLE msi_handle, std::wstring const& name,
+                  std::wstring const& value)
 {
   MsiSetPropertyW(msi_handle, name.c_str(), value.c_str());
 }
@@ -36,10 +34,10 @@ extern "C" UINT __stdcall DetectNsisOverwrite(MSIHANDLE msi_handle)
   std::wstring uninstall_exe = install_root + L"\\uninstall.exe";
 
   bool uninstall_exe_exists =
-      GetFileAttributesW(uninstall_exe.c_str()) != INVALID_FILE_ATTRIBUTES;
+    GetFileAttributesW(uninstall_exe.c_str()) != INVALID_FILE_ATTRIBUTES;
 
   set_property(msi_handle, L"CMAKE_NSIS_OVERWRITE_DETECTED",
-    uninstall_exe_exists ? L"1" : L"0");
+               uninstall_exe_exists ? L"1" : L"0");
 
   return ERROR_SUCCESS;
 }
diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake
index d41c4ec..f8844e9 100644
--- a/Utilities/Release/create-cmake-release.cmake
+++ b/Utilities/Release/create-cmake-release.cmake
@@ -6,14 +6,15 @@ endif()
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/logs)
 
 set(RELEASE_SCRIPTS_BATCH_1
-  dash3win7_release.cmake     # Windows
-  dashmacmini5_release.cmake  # OS X x86_64
-  magrathea_release.cmake     # Linux
+  win32_release.cmake         # Windows x86
+  osx_release.cmake           # OS X x86_64
+  linux32_release.cmake       # Linux x86
   linux64_release.cmake       # Linux x86_64
 )
 
 set(RELEASE_SCRIPTS_BATCH_2
-  dash2win64_cygwin.cmake     # Cygwin
+  cygwin_release.cmake        # Cygwin x86
+  win64_release.cmake         # Windows x64
 )
 
 function(write_batch_shell_script filename)
diff --git a/Utilities/Release/cygwin_release.cmake b/Utilities/Release/cygwin_release.cmake
new file mode 100644
index 0000000..ca3e794
--- /dev/null
+++ b/Utilities/Release/cygwin_release.cmake
@@ -0,0 +1,32 @@
+set(CMAKE_RELEASE_DIRECTORY "c:/cygwin/home/dashboard/CMakeReleaseCygwin")
+set(PROCESSORS 9)
+set(BOOTSTRAP_ARGS "")
+set(MAKE_PROGRAM "make")
+set(MAKE "${MAKE_PROGRAM} -j8")
+set(HOST dash2win64)
+set(CPACK_BINARY_GENERATORS "CygwinBinary")
+set(CPACK_SOURCE_GENERATORS "CygwinSource")
+set(MAKE_PROGRAM "make")
+set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
+CMAKE_Fortran_COMPILER_FULLPATH:FILEPATH=FALSE
+CTEST_TEST_TIMEOUT:STRING=7200
+DART_TESTING_TIMEOUT:STRING=7200
+SPHINX_HTML:BOOL=ON
+SPHINX_MAN:BOOL=ON
+CMake_INSTALL_DEPENDENCIES:BOOL=ON
+")
+set(CXX g++)
+set(CC  gcc)
+set(GIT_EXTRA "git config core.autocrlf false")
+get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+# WARNING: Temporary fix!! This exclusion of the ExternalProject test
+# is temporary until we can set up a new cygwin build machine.
+# It only fails because of cygwin/non-cygwin "svn" mismatches in this
+# particular environment. This is less than ideal, but at least it
+# allows us to produce cygwin builds in the short term.
+set(EXTRA_CTEST_ARGS "-E ExternalProject")
+
+set(LOCAL_DIR cygwin)
+
+include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/dash2win64_cygwin.cmake b/Utilities/Release/dash2win64_cygwin.cmake
deleted file mode 100644
index ca590ed..0000000
--- a/Utilities/Release/dash2win64_cygwin.cmake
+++ /dev/null
@@ -1,33 +0,0 @@
-set(CMAKE_RELEASE_DIRECTORY "c:/cygwin/home/dashboard/CMakeReleaseCygwin")
-set(PROCESSORS 9)
-set(BOOTSTRAP_ARGS "")
-set(MAKE_PROGRAM "make")
-set(MAKE "${MAKE_PROGRAM} -j8")
-set(HOST dash2win64)
-set(CPACK_BINARY_GENERATORS "CygwinBinary")
-set(CPACK_SOURCE_GENERATORS "CygwinSource")
-set(MAKE_PROGRAM "make")
-set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
-CMAKE_Fortran_COMPILER_FULLPATH:FILEPATH=FALSE
-CTEST_TEST_TIMEOUT:STRING=7200
-DART_TESTING_TIMEOUT:STRING=7200
-SPHINX_HTML:BOOL=ON
-SPHINX_MAN:BOOL=ON
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-")
-set(CXX g++)
-set(CC  gcc)
-set(SCRIPT_NAME dash2win64cygwin)
-set(GIT_EXTRA "git config core.autocrlf false")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
-# WARNING: Temporary fix!! This exclusion of the ExternalProject test
-# is temporary until we can set up a new cygwin build machine.
-# It only fails because of cygwin/non-cygwin "svn" mismatches in this
-# particular environment. This is less than ideal, but at least it
-# allows us to produce cygwin builds in the short term.
-set(EXTRA_CTEST_ARGS "-E ExternalProject")
-
-set(LOCAL_DIR cygwin)
-
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/dash3win7_release.cmake b/Utilities/Release/dash3win7_release.cmake
deleted file mode 100644
index f25d638..0000000
--- a/Utilities/Release/dash3win7_release.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-set(CMAKE_RELEASE_DIRECTORY "c:/msys64/home/dashboard/CMakeReleaseDirectory")
-set(CONFIGURE_WITH_CMAKE TRUE)
-set(CMAKE_CONFIGURE_PATH "c:/Program\\ Files\\ \\(x86\\)/CMake/bin/cmake.exe")
-set(PROCESSORS 8)
-set(HOST dash3win7)
-set(RUN_LAUNCHER ~/rel/run)
-set(CPACK_BINARY_GENERATORS "WIX ZIP")
-set(CPACK_SOURCE_GENERATORS "ZIP")
-set(MAKE_PROGRAM "ninja")
-set(MAKE "${MAKE_PROGRAM} -j8")
-set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
-CMAKE_DOC_DIR:STRING=doc/cmake
-CMAKE_USE_OPENSSL:BOOL=OFF
-CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
-CMAKE_Fortran_COMPILER:FILEPATH=FALSE
-CMAKE_GENERATOR:INTERNAL=Ninja
-BUILD_QtDialog:BOOL:=TRUE
-CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x86 -subsystem:console,5.01
-")
-set(ppflags "-D_WIN32_WINNT=0x501 -D_USING_V110_SDK71_")
-set(CFLAGS "${ppflags}")
-set(CXXFLAGS "${ppflags}")
-set(ENV ". ~/rel/env")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-set(GIT_EXTRA "git config core.autocrlf true")
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake
deleted file mode 100644
index b147013..0000000
--- a/Utilities/Release/dashmacmini5_release.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-set(PROCESSORS 4)
-set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory)
-# set(USER_OVERRIDE "set(CMAKE_CXX_LINK_EXECUTABLE \\\"gcc  <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> <LINK_LIBRARIES>  -shared-libgcc -lstdc++-static\\\")")
-set(BOOTSTRAP_ARGS "--prefix=/ --docdir=doc/cmake")
-set(HOST dashmacmini5)
-set(MAKE_PROGRAM "make")
-set(MAKE "${MAKE_PROGRAM} -j5")
-set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ")
-set(CPACK_SOURCE_GENERATORS "TGZ TZ")
-set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size
-set(INITIAL_CACHE "
-CMAKE_USE_OPENSSL:BOOL=OFF
-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
-CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6
-CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
-CPACK_SYSTEM_NAME:STRING=Darwin-x86_64
-BUILD_QtDialog:BOOL=TRUE
-CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.6/install/bin/qmake
-")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/linux32_release.cmake b/Utilities/Release/linux32_release.cmake
new file mode 100644
index 0000000..6d096d1
--- /dev/null
+++ b/Utilities/Release/linux32_release.cmake
@@ -0,0 +1,25 @@
+set(PROCESSORS 1)
+set(BOOTSTRAP_ARGS "--docdir=doc/cmake")
+set(HOST magrathea)
+set(MAKE_PROGRAM "make")
+set(CC gcc332s)
+set(CXX c++332s)
+set(CFLAGS   -DDT_RUNPATH=29)
+set(CXXFLAGS -DDT_RUNPATH=29)
+set(INITIAL_CACHE "
+CMAKE_BUILD_TYPE:STRING=Release
+CURSES_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libncurses.a
+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.2h/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2h/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2h/lib/libssl.a
+CPACK_SYSTEM_NAME:STRING=Linux-i386
+BUILD_QtDialog:BOOL:=TRUE
+CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
+CMake_INSTALL_DEPENDENCIES:BOOL=ON
+QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.43-install/bin/qmake
+")
+get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
+include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake
index 81442e7..cfe370b 100644
--- a/Utilities/Release/linux64_release.cmake
+++ b/Utilities/Release/linux64_release.cmake
@@ -12,9 +12,9 @@ CURSES_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libncurses.a
 CURSES_INCLUDE_PATH:PATH=/home/kitware/ncurses-5.9/include
 FORM_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libform.a
 CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2d/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2h/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2h/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2h/lib/libssl.a
 CPACK_SYSTEM_NAME:STRING=Linux-x86_64
 BUILD_QtDialog:BOOL:=TRUE
 CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake
deleted file mode 100644
index 0634dda..0000000
--- a/Utilities/Release/magrathea_release.cmake
+++ /dev/null
@@ -1,25 +0,0 @@
-set(PROCESSORS 1)
-set(BOOTSTRAP_ARGS "--docdir=doc/cmake")
-set(HOST magrathea)
-set(MAKE_PROGRAM "make")
-set(CC gcc332s)
-set(CXX c++332s)
-set(CFLAGS   -DDT_RUNPATH=29)
-set(CXXFLAGS -DDT_RUNPATH=29)
-set(INITIAL_CACHE "
-CMAKE_BUILD_TYPE:STRING=Release
-CURSES_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libncurses.a
-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.2d/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2d/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2d/lib/libssl.a
-CPACK_SYSTEM_NAME:STRING=Linux-i386
-BUILD_QtDialog:BOOL:=TRUE
-CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-QT_QMAKE_EXECUTABLE:FILEPATH=/home/kitware/qt-4.43-install/bin/qmake
-")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/osx_release.cmake b/Utilities/Release/osx_release.cmake
new file mode 100644
index 0000000..17f7df6
--- /dev/null
+++ b/Utilities/Release/osx_release.cmake
@@ -0,0 +1,32 @@
+set(PROCESSORS 4)
+set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory)
+set(BOOTSTRAP_ARGS "--prefix=/ --docdir=doc/cmake")
+set(HOST dragnipur)
+set(MAKE_PROGRAM "make")
+set(MAKE "${MAKE_PROGRAM} -j5")
+set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ")
+set(CPACK_SOURCE_GENERATORS "TGZ TZ")
+set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size
+set(CC clang)
+set(CXX clang++)
+set(CFLAGS   "")
+set(CXXFLAGS "-stdlib=libc++")
+set(INITIAL_CACHE "
+CMAKE_BUILD_TYPE:STRING=Release
+CMAKE_OSX_ARCHITECTURES:STRING=x86_64
+CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7
+CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
+CPACK_SYSTEM_NAME:STRING=Darwin-x86_64
+BUILD_QtDialog:BOOL=TRUE
+CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
+CMake_INSTALL_DEPENDENCIES:BOOL=ON
+CMAKE_SKIP_RPATH:BOOL=TRUE
+CMake_NO_C_STANDARD:BOOL=TRUE
+CMake_NO_CXX_STANDARD:BOOL=TRUE
+CMake_TEST_NO_FindPackageModeMakefileTest:BOOL=TRUE
+")
+set(ENV [[
+export CMAKE_PREFIX_PATH='/Users/kitware/SDKs/qt-5.6.0-clang-x64'
+]])
+get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
+include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
index f5e325e..04a0cac 100644
--- a/Utilities/Release/upload_release.cmake
+++ b/Utilities/Release/upload_release.cmake
@@ -1,6 +1,6 @@
 set(CTEST_RUN_CURRENT_SCRIPT 0)
 if(NOT VERSION)
- set(VERSION 3.5)
+ set(VERSION 3.6)
 endif()
 if(NOT DEFINED PROJECT_PREFIX)
   set(PROJECT_PREFIX cmake-${VERSION})
diff --git a/Utilities/Release/win32_release.cmake b/Utilities/Release/win32_release.cmake
new file mode 100644
index 0000000..ba83b26
--- /dev/null
+++ b/Utilities/Release/win32_release.cmake
@@ -0,0 +1,32 @@
+set(CMAKE_RELEASE_DIRECTORY "c:/msys64/home/dashboard/CMakeReleaseDirectory")
+set(CONFIGURE_WITH_CMAKE TRUE)
+set(CMAKE_CONFIGURE_PATH "c:/Program\\ Files\\ \\(x86\\)/CMake/bin/cmake.exe")
+set(PROCESSORS 8)
+set(HOST dash3win7)
+set(RUN_LAUNCHER ~/rel/run)
+set(CPACK_BINARY_GENERATORS "WIX ZIP")
+set(CPACK_SOURCE_GENERATORS "ZIP")
+set(MAKE_PROGRAM "ninja")
+set(MAKE "${MAKE_PROGRAM} -j8")
+set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
+CMAKE_DOC_DIR:STRING=doc/cmake
+CMAKE_USE_OPENSSL:BOOL=OFF
+CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
+CMAKE_Fortran_COMPILER:FILEPATH=FALSE
+CMAKE_GENERATOR:INTERNAL=Ninja
+BUILD_QtDialog:BOOL:=TRUE
+CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
+CMake_INSTALL_DEPENDENCIES:BOOL=ON
+CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x86 -subsystem:console,5.01
+")
+set(ppflags "-D_WIN32_WINNT=0x501 -DNTDDI_VERSION=0x05010000 -D_USING_V110_SDK71_")
+set(CFLAGS "${ppflags}")
+set(CXXFLAGS "${ppflags}")
+set(ENV ". ~/rel/env")
+get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
+set(GIT_EXTRA "git config core.autocrlf true")
+if(CMAKE_CREATE_VERSION STREQUAL "nightly")
+  # Some tests fail spuriously too often.
+  set(EXTRA_CTEST_ARGS "-E Qt5Autogen")
+endif()
+include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/win64_release.cmake b/Utilities/Release/win64_release.cmake
new file mode 100644
index 0000000..8e207b5
--- /dev/null
+++ b/Utilities/Release/win64_release.cmake
@@ -0,0 +1,33 @@
+set(CMAKE_RELEASE_DIRECTORY "c:/msys64/home/dashboard/CMakeReleaseDirectory64")
+set(CONFIGURE_WITH_CMAKE TRUE)
+set(CMAKE_CONFIGURE_PATH "c:/Program\\ Files\\ \\(x86\\)/CMake/bin/cmake.exe")
+set(PROCESSORS 8)
+set(HOST dash3win7)
+set(SCRIPT_NAME dash3win7x64)
+set(RUN_LAUNCHER ~/rel/run)
+set(CPACK_BINARY_GENERATORS "WIX ZIP")
+set(CPACK_SOURCE_GENERATORS "")
+set(MAKE_PROGRAM "ninja")
+set(MAKE "${MAKE_PROGRAM} -j8")
+set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
+CMAKE_DOC_DIR:STRING=doc/cmake
+CMAKE_USE_OPENSSL:BOOL=OFF
+CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
+CMAKE_Fortran_COMPILER:FILEPATH=FALSE
+CMAKE_GENERATOR:INTERNAL=Ninja
+BUILD_QtDialog:BOOL:=TRUE
+CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
+CMake_INSTALL_DEPENDENCIES:BOOL=ON
+CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x64 -subsystem:console,5.02
+")
+set(ppflags "-D_WIN32_WINNT=0x502 -DNTDDI_VERSION=0x05020000 -D_USING_V110_SDK71_")
+set(CFLAGS "${ppflags}")
+set(CXXFLAGS "${ppflags}")
+set(ENV ". ~/rel/env64")
+get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
+set(GIT_EXTRA "git config core.autocrlf true")
+if(CMAKE_CREATE_VERSION STREQUAL "nightly")
+  # Some tests fail spuriously too often.
+  set(EXTRA_CTEST_ARGS "-E Qt5Autogen")
+endif()
+include(${path}/release_cmake.cmake)
diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash
new file mode 100755
index 0000000..a9ef62b
--- /dev/null
+++ b/Utilities/Scripts/clang-format.bash
@@ -0,0 +1,138 @@
+#!/usr/bin/env bash
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=============================================================================
+
+usage='usage: clang-format.bash [<options>] [--]
+
+    --help                     Print usage plus more detailed help.
+
+    --clang-format <tool>      Use given clang-format tool.
+
+    --amend                    Filter files changed by HEAD.
+    --cached                   Filter files locally staged for commit.
+    --modified                 Filter files locally modified from HEAD.
+    --tracked                  Filter files tracked by Git.
+'
+
+help="$usage"'
+Example to format locally modified files:
+
+    Utilities/Scripts/clang-format.bash --modified
+
+Example to format locally modified files staged for commit:
+
+    Utilities/Scripts/clang-format.bash --cached
+
+Example to format files modified by the most recent commit:
+
+    Utilities/Scripts/clang-format.bash --amend
+
+Example to format all files:
+
+    Utilities/Scripts/clang-format.bash --tracked
+
+Example to format the current topic:
+
+    git filter-branch \
+      --tree-filter "Utilities/Scripts/clang-format.bash --tracked" \
+      master..
+'
+
+die() {
+    echo "$@" 1>&2; exit 1
+}
+
+#-----------------------------------------------------------------------------
+
+# Parse command-line arguments.
+clang_format=''
+mode=''
+while test "$#" != 0; do
+    case "$1" in
+    --amend) mode="amend" ;;
+    --cached) mode="cached" ;;
+    --clang-format) shift; clang_format="$1" ;;
+    --help) echo "$help"; exit 0 ;;
+    --modified) mode="modified" ;;
+    --tracked) mode="tracked" ;;
+    --) shift ; break ;;
+    -*) die "$usage" ;;
+    *) break ;;
+    esac
+    shift
+done
+test "$#" = 0 || die "$usage"
+
+# Find a default tool.
+tools='
+  clang-format
+  clang-format-3.8
+'
+if test "x$clang_format" = "x"; then
+    for tool in $tools; do
+        if type -p "$tool" >/dev/null; then
+            clang_format="$tool"
+            break
+        fi
+    done
+fi
+
+# Verify that we have a tool.
+if ! type -p "$clang_format" >/dev/null; then
+    echo "Unable to locate '$clang_format'"
+    exit 1
+fi
+
+# Select listing mode.
+case "$mode" in
+    '')       echo "$usage"; exit 0 ;;
+    amend)    git_ls='git diff-tree  --diff-filter=AM --name-only HEAD -r --no-commit-id' ;;
+    cached)   git_ls='git diff-index --diff-filter=AM --name-only HEAD --cached' ;;
+    modified) git_ls='git diff-index --diff-filter=AM --name-only HEAD' ;;
+    tracked)  git_ls='git ls-files' ;;
+    *) die "invalid mode: $mode" ;;
+esac
+
+# Filter sources to which our style should apply.
+$git_ls -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
+
+  # Exclude lexer/parser generator input and output.
+  egrep -z -v '^Source/cmCommandArgumentLexer\.' |
+  egrep -z -v '^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)' |
+  egrep -z -v '^Source/cmDependsJavaLexer\.' |
+  egrep -z -v '^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)' |
+  egrep -z -v '^Source/cmExprLexer\.' |
+  egrep -z -v '^Source/cmExprParser(\.y|\.cxx|Tokens\.h)' |
+  egrep -z -v '^Source/cmFortranLexer\.' |
+  egrep -z -v '^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)' |
+  egrep -z -v '^Source/cmListFileLexer(\.in\.l|\.c)' |
+
+  # Exclude third-party sources.
+  egrep -z -v '^Source/(cm_sha2|bindexplib)' |
+  egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
+  egrep -z -v '^Utilities/(KW|cm).*/' |
+
+  # Exclude reference content.
+  egrep -z -v '^Tests/Module/GenerateExportHeader/reference/' |
+
+  # Exclude manually-formatted sources (e.g. with long lines).
+  egrep -z -v '^Tests/PositionIndependentTargets/pic_test.h' |
+
+  # Exclude sources with encoding not suported by clang-format.
+  egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
+
+  # Update sources in-place.
+  xargs -0 "$clang_format" -i
diff --git a/Utilities/Scripts/update-expat.bash b/Utilities/Scripts/update-expat.bash
new file mode 100755
index 0000000..8a2a5fe
--- /dev/null
+++ b/Utilities/Scripts/update-expat.bash
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+
+set -e
+set -x
+shopt -s dotglob
+
+readonly name="expat"
+readonly ownership="Expat Upstream <kwrobot at kitware.com>"
+readonly subtree="Utilities/cmexpat"
+readonly repo="http://git.code.sf.net/p/expat/code_git"
+readonly tag="master"
+readonly shortlog=false
+readonly paths="
+  expat/lib/asciitab.h
+  expat/lib/expat.h
+  expat/lib/xmltok.h
+  expat/lib/internal.h
+  expat/lib/xmlrole.h
+  expat/lib/iasciitab.h
+  expat/lib/latin1tab.h
+  expat/lib/xmlrole.c
+  expat/lib/utf8tab.h
+  expat/lib/nametab.h
+  expat/lib/ascii.h
+  expat/lib/xmltok_impl.h
+  expat/lib/xmltok_ns.c
+  expat/lib/winconfig.h
+  expat/lib/expat_external.h
+  expat/lib/xmltok.c
+  expat/lib/xmlparse.c
+  expat/lib/xmltok_impl.c
+  expat/README
+  expat/ConfigureChecks.cmake
+  expat/CMakeLists.txt
+  expat/expat_config.h.cmake
+  expat/COPYING
+"
+
+extract_source () {
+    git_archive
+    pushd "${extractdir}/${name}-reduced"
+    fromdos expat/ConfigureChecks.cmake expat/CMakeLists.txt expat/expat_config.h.cmake
+    chmod a-x expat/ConfigureChecks.cmake expat/CMakeLists.txt expat/expat_config.h.cmake
+    mv expat/* .
+    rmdir expat
+    popd
+}
+
+. "${BASH_SOURCE%/*}/update-third-party.bash"
diff --git a/Utilities/Scripts/update-libarchive.bash b/Utilities/Scripts/update-libarchive.bash
new file mode 100755
index 0000000..3b42269
--- /dev/null
+++ b/Utilities/Scripts/update-libarchive.bash
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+set -e
+set -x
+shopt -s dotglob
+
+readonly name="LibArchive"
+readonly ownership="LibArchive Upstream <libarchive-discuss at googlegroups.com>"
+readonly subtree="Utilities/cmlibarchive"
+readonly repo="https://github.com/libarchive/libarchive.git"
+readonly tag="master"
+readonly shortlog=false
+readonly paths="
+  CMakeLists.txt
+  COPYING
+  CTestConfig.cmake
+  build/cmake
+  build/pkgconfig
+  build/utils
+  build/version
+  libarchive/*.*
+"
+
+extract_source () {
+    git_archive
+    pushd "${extractdir}/${name}-reduced"
+    fromdos build/cmake/Find*.cmake
+    popd
+}
+
+. "${BASH_SOURCE%/*}/update-third-party.bash"
diff --git a/Utilities/Scripts/update-third-party.bash b/Utilities/Scripts/update-third-party.bash
index 8925296..6aeeccd 100644
--- a/Utilities/Scripts/update-third-party.bash
+++ b/Utilities/Scripts/update-third-party.bash
@@ -1,3 +1,19 @@
+#=============================================================================
+# Copyright 2015-2016 Kitware, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=============================================================================
+
 ########################################################################
 # Script for updating third party packages.
 #
@@ -32,7 +48,7 @@
 # Utility functions
 ########################################################################
 git_archive () {
-    git archive --prefix="$name-reduced/" HEAD -- $paths | \
+    git archive --worktree-attributes --prefix="$name-reduced/" HEAD -- $paths | \
         tar -C "$extractdir" -x
 }
 
@@ -85,6 +101,7 @@ if [ -n "$basehash" ]; then
     # Clear out the working tree
     pushd "$extractdir"
     git ls-files | xargs rm -v
+    find . -type d -empty -delete
     popd
 else
     # Create a repo to hold this package's history
diff --git a/Utilities/cm_bzlib.h b/Utilities/cm_bzlib.h
index 5678025..0eb7bd8 100644
--- a/Utilities/cm_bzlib.h
+++ b/Utilities/cm_bzlib.h
@@ -15,9 +15,9 @@
 /* Use the bzip2 library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_BZIP2
-# include <bzlib.h>
+#include <bzlib.h>
 #else
-# include <cmbzip2/bzlib.h>
+#include <cmbzip2/bzlib.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_curl.h b/Utilities/cm_curl.h
index c9835e7..bf4c63c 100644
--- a/Utilities/cm_curl.h
+++ b/Utilities/cm_curl.h
@@ -15,9 +15,9 @@
 /* Use the curl library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_CURL
-# include <curl/curl.h>
+#include <curl/curl.h>
 #else
-# include <cmcurl/include/curl/curl.h>
+#include <cmcurl/include/curl/curl.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_expat.h b/Utilities/cm_expat.h
index f361541..c6c6683 100644
--- a/Utilities/cm_expat.h
+++ b/Utilities/cm_expat.h
@@ -15,9 +15,9 @@
 /* Use the expat library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_EXPAT
-# include <expat.h>
+#include <expat.h>
 #else
-# include <cmexpat/expat.h>
+#include <cmexpat/lib/expat.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_jsoncpp_reader.h b/Utilities/cm_jsoncpp_reader.h
index 22f2d81..019044e 100644
--- a/Utilities/cm_jsoncpp_reader.h
+++ b/Utilities/cm_jsoncpp_reader.h
@@ -15,9 +15,9 @@
 /* Use the jsoncpp library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_JSONCPP
-# include <json/reader.h>
+#include <json/reader.h>
 #else
-# include <cmjsoncpp/include/json/reader.h>
+#include <cmjsoncpp/include/json/reader.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_jsoncpp_value.h b/Utilities/cm_jsoncpp_value.h
index b4cf620..81c9ae0 100644
--- a/Utilities/cm_jsoncpp_value.h
+++ b/Utilities/cm_jsoncpp_value.h
@@ -15,9 +15,9 @@
 /* Use the jsoncpp library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_JSONCPP
-# include <json/value.h>
+#include <json/value.h>
 #else
-# include <cmjsoncpp/include/json/value.h>
+#include <cmjsoncpp/include/json/value.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_jsoncpp_writer.h b/Utilities/cm_jsoncpp_writer.h
index c99a0d0..597539d 100644
--- a/Utilities/cm_jsoncpp_writer.h
+++ b/Utilities/cm_jsoncpp_writer.h
@@ -15,9 +15,9 @@
 /* Use the jsoncpp library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_JSONCPP
-# include <json/writer.h>
+#include <json/writer.h>
 #else
-# include <cmjsoncpp/include/json/writer.h>
+#include <cmjsoncpp/include/json/writer.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_kwiml.h b/Utilities/cm_kwiml.h
index ab2b80b..fce8881 100644
--- a/Utilities/cm_kwiml.h
+++ b/Utilities/cm_kwiml.h
@@ -15,11 +15,11 @@
 /* Use the KWIML library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_KWIML
-# include <kwiml/abi.h>
-# include <kwiml/int.h>
+#include <kwiml/abi.h>
+#include <kwiml/int.h>
 #else
-# include "KWIML/include/kwiml/abi.h"
-# include "KWIML/include/kwiml/int.h"
+#include "KWIML/include/kwiml/abi.h"
+#include "KWIML/include/kwiml/int.h"
 #endif
 
 #endif
diff --git a/Utilities/cm_libarchive.h b/Utilities/cm_libarchive.h
index 0f18c91..c6a8a82 100644
--- a/Utilities/cm_libarchive.h
+++ b/Utilities/cm_libarchive.h
@@ -15,11 +15,11 @@
 /* Use the libarchive configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_LIBARCHIVE
-# include <archive.h>
-# include <archive_entry.h>
+#include <archive.h>
+#include <archive_entry.h>
 #else
-# include <cmlibarchive/libarchive/archive.h>
-# include <cmlibarchive/libarchive/archive_entry.h>
+#include <cmlibarchive/libarchive/archive.h>
+#include <cmlibarchive/libarchive/archive_entry.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_lzma.h b/Utilities/cm_lzma.h
index 02d7e4f..20cf1d7 100644
--- a/Utilities/cm_lzma.h
+++ b/Utilities/cm_lzma.h
@@ -15,9 +15,9 @@
 /* Use the liblzma configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_LIBLZMA
-# include <lzma.h>
+#include <lzma.h>
 #else
-# include <cmliblzma/liblzma/api/lzma.h>
+#include <cmliblzma/liblzma/api/lzma.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_xmlrpc.h b/Utilities/cm_xmlrpc.h
index ac461f9..0bc93f4 100644
--- a/Utilities/cm_xmlrpc.h
+++ b/Utilities/cm_xmlrpc.h
@@ -15,8 +15,8 @@
 /* Use the xmlrpc library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CTEST_USE_XMLRPC
-# include <xmlrpc.h>
-# include <xmlrpc_client.h>
+#include <xmlrpc.h>
+#include <xmlrpc_client.h>
 #endif
 
 #endif
diff --git a/Utilities/cm_zlib.h b/Utilities/cm_zlib.h
index 1b5c06e..6ff8e6c 100644
--- a/Utilities/cm_zlib.h
+++ b/Utilities/cm_zlib.h
@@ -15,9 +15,9 @@
 /* Use the zlib library configured for CMake.  */
 #include "cmThirdParty.h"
 #ifdef CMAKE_USE_SYSTEM_ZLIB
-# include <zlib.h>
+#include <zlib.h>
 #else
-# include <cmzlib/zlib.h>
+#include <cmzlib/zlib.h>
 #endif
 
 #endif
diff --git a/Utilities/cmcurl/lib/curl_sasl_gssapi.c b/Utilities/cmcurl/lib/curl_sasl_gssapi.c
index 3c6f3ce..5fc0e58 100644
--- a/Utilities/cmcurl/lib/curl_sasl_gssapi.c
+++ b/Utilities/cmcurl/lib/curl_sasl_gssapi.c
@@ -70,7 +70,7 @@ char *Curl_sasl_build_gssapi_spn(const char *service, const char *host)
  * userp       [in]     - The user name.
  * passdwp     [in]     - The user's password.
  * service     [in]     - The service type such as www, smtp, pop or imap.
- * mutual_auth [in]     - Flag specifing whether or not mutual authentication
+ * mutual_auth [in]     - Flag specifying whether or not mutual authentication
  *                        is enabled.
  * chlg64      [in]     - Pointer to the optional base64 encoded challenge
  *                        message.
diff --git a/Utilities/cmcurl/lib/curl_sasl_sspi.c b/Utilities/cmcurl/lib/curl_sasl_sspi.c
index b149530..e96b55c 100644
--- a/Utilities/cmcurl/lib/curl_sasl_sspi.c
+++ b/Utilities/cmcurl/lib/curl_sasl_sspi.c
@@ -846,7 +846,7 @@ void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm)
  * userp       [in]     - The user name in the format User or Domain\User.
  * passdwp     [in]     - The user's password.
  * service     [in]     - The service type such as www, smtp, pop or imap.
- * mutual_auth [in]     - Flag specifing whether or not mutual authentication
+ * mutual_auth [in]     - Flag specifying whether or not mutual authentication
  *                        is enabled.
  * chlg64      [in]     - The optional base64 encoded challenge message.
  * krb5        [in/out] - The gssapi data struct being used and modified.
diff --git a/Utilities/cmcurl/lib/ftp.c b/Utilities/cmcurl/lib/ftp.c
index 74c4032..29c840c 100644
--- a/Utilities/cmcurl/lib/ftp.c
+++ b/Utilities/cmcurl/lib/ftp.c
@@ -3671,7 +3671,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
   }
 
   if(ftpc->state) {
-    /* already in a state so skip the intial commands.
+    /* already in a state so skip the initial commands.
        They are only done to kickstart the do_more state */
     result = ftp_multi_statemach(conn, &complete);
 
diff --git a/Utilities/cmexpat/.NoDartCoverage b/Utilities/cmexpat/.NoDartCoverage
deleted file mode 100644
index 3c99729..0000000
--- a/Utilities/cmexpat/.NoDartCoverage
+++ /dev/null
@@ -1 +0,0 @@
-# do not do coverage in this directory
diff --git a/Utilities/cmexpat/.gitattributes b/Utilities/cmexpat/.gitattributes
new file mode 100644
index 0000000..562b12e
--- /dev/null
+++ b/Utilities/cmexpat/.gitattributes
@@ -0,0 +1 @@
+* -whitespace
diff --git a/Utilities/cmexpat/CMakeLists.txt b/Utilities/cmexpat/CMakeLists.txt
index 51ba413..d294165 100644
--- a/Utilities/cmexpat/CMakeLists.txt
+++ b/Utilities/cmexpat/CMakeLists.txt
@@ -1,34 +1,25 @@
-PROJECT(CMEXPAT)
+# Disable warnings to avoid changing 3rd party code.
+IF(CMAKE_C_COMPILER_ID MATCHES
+    "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
+ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
+ENDIF()
 
-SET(expat_SRCS
-  xmlparse.c
-  xmltok.c
-  xmlrole.c
-)
+include(ConfigureChecks.cmake)
+if(WIN32)
+  add_definitions(-DCOMPILING_FOR_WINDOWS)
+endif(WIN32)
 
-INCLUDE(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
-TEST_BIG_ENDIAN(CMEXPAT_BIGENDIAN)
-
-INCLUDE_DIRECTORIES(
-  "${CMEXPAT_BINARY_DIR}/.."
+include_directories(
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/lib
   )
 
-IF(WIN32)
-  IF(NOT BUILD_SHARED_LIBS)
-    SET (CM_EXPAT_STATIC 1)
-  ENDIF(NOT BUILD_SHARED_LIBS)
-ENDIF(WIN32)
-
-CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/expatConfig.h.in
-               ${CMEXPAT_BINARY_DIR}/expatConfig.h)
-CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/expatDllConfig.h.in
-               ${CMEXPAT_BINARY_DIR}/expatDllConfig.h)
-CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/.NoDartCoverage
-               ${CMEXPAT_BINARY_DIR}/.NoDartCoverage)
-CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/cm_expat_mangle.h
-               ${CMEXPAT_BINARY_DIR}/cm_expat_mangle.h)
-CONFIGURE_FILE(${CMEXPAT_SOURCE_DIR}/expat.h
-               ${CMEXPAT_BINARY_DIR}/expat.h)
-
-ADD_LIBRARY(cmexpat ${expat_SRCS})
-INSTALL(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmexpat)
+add_library(cmexpat STATIC
+  lib/xmlparse.c
+  lib/xmlrole.c
+  lib/xmltok.c
+  lib/xmltok_impl.c
+  lib/xmltok_ns.c
+  )
diff --git a/Utilities/cmexpat/COPYING b/Utilities/cmexpat/COPYING
index fc97b02..dcb4506 100644
--- a/Utilities/cmexpat/COPYING
+++ b/Utilities/cmexpat/COPYING
@@ -1,5 +1,6 @@
 Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
                                and Clark Cooper
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
diff --git a/Utilities/cmexpat/ConfigureChecks.cmake b/Utilities/cmexpat/ConfigureChecks.cmake
new file mode 100644
index 0000000..f03faa6
--- /dev/null
+++ b/Utilities/cmexpat/ConfigureChecks.cmake
@@ -0,0 +1,44 @@
+include(CheckIncludeFile)
+include(CheckIncludeFiles)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(TestBigEndian)
+
+check_include_file("dlfcn.h" HAVE_DLFCN_H)
+check_include_file("fcntl.h" HAVE_FCNTL_H)
+check_include_file("inttypes.h" HAVE_INTTYPES_H)
+check_include_file("memory.h" HAVE_MEMORY_H)
+check_include_file("stdint.h" HAVE_STDINT_H)
+check_include_file("stdlib.h" HAVE_STDLIB_H)
+check_include_file("strings.h" HAVE_STRINGS_H)
+check_include_file("string.h" HAVE_STRING_H)
+check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
+check_include_file("unistd.h" HAVE_UNISTD_H)
+
+check_function_exists("getpagesize" HAVE_GETPAGESIZE)
+check_function_exists("bcopy" HAVE_BCOPY)
+check_symbol_exists("memmove" "string.h" HAVE_MEMMOVE)
+check_function_exists("mmap" HAVE_MMAP)
+
+#/* Define to 1 if you have the ANSI C header files. */
+check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
+
+test_big_endian(WORDS_BIGENDIAN)
+#/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
+if(WORDS_BIGENDIAN)
+    set(BYTEORDER 4321)
+else(WORDS_BIGENDIAN)
+    set(BYTEORDER 1234)
+endif(WORDS_BIGENDIAN)
+
+if(HAVE_SYS_TYPES_H)
+    check_symbol_exists("off_t" "sys/types.h" OFF_T)
+    check_symbol_exists("size_t" "sys/types.h" SIZE_T)
+else(HAVE_SYS_TYPES_H)
+    set(OFF_T "long")
+    set(SIZE_T "unsigned")
+endif(HAVE_SYS_TYPES_H)
+
+configure_file(expat_config.h.cmake expat_config.h)
+add_definitions(-DHAVE_EXPAT_CONFIG_H)
diff --git a/Utilities/cmexpat/README b/Utilities/cmexpat/README
new file mode 100644
index 0000000..9ec8d0c
--- /dev/null
+++ b/Utilities/cmexpat/README
@@ -0,0 +1,139 @@
+
+                        Expat, Release 2.1.1
+
+This is Expat, a C library for parsing XML, written by James Clark.
+Expat is a stream-oriented XML parser.  This means that you register
+handlers with the parser before starting the parse.  These handlers
+are called when the parser discovers the associated structures in the
+document being parsed.  A start tag is an example of the kind of
+structures for which you may register handlers.
+
+Windows users should use the expat_win32bin package, which includes
+both precompiled libraries and executables, and source code for
+developers.
+
+Expat is free software.  You may copy, distribute, and modify it under
+the terms of the License contained in the file COPYING distributed
+with this package.  This license is the same as the MIT/X Consortium
+license.
+
+Versions of Expat that have an odd minor version (the middle number in
+the release above), are development releases and should be considered
+as beta software.  Releases with even minor version numbers are
+intended to be production grade software.
+
+If you are building Expat from a check-out from the CVS repository,
+you need to run a script that generates the configure script using the
+GNU autoconf and libtool tools.  To do this, you need to have
+autoconf 2.58 or newer. Run the script like this:
+
+        ./buildconf.sh
+
+Once this has been done, follow the same instructions as for building
+from a source distribution.
+
+To build Expat from a source distribution, you first run the
+configuration shell script in the top level distribution directory:
+
+        ./configure
+
+There are many options which you may provide to configure (which you
+can discover by running configure with the --help option).  But the
+one of most interest is the one that sets the installation directory.
+By default, the configure script will set things up to install
+libexpat into /usr/local/lib, expat.h into /usr/local/include, and
+xmlwf into /usr/local/bin.  If, for example, you'd prefer to install
+into /home/me/mystuff/lib, /home/me/mystuff/include, and
+/home/me/mystuff/bin, you can tell configure about that with:
+
+        ./configure --prefix=/home/me/mystuff
+        
+Another interesting option is to enable 64-bit integer support for
+line and column numbers and the over-all byte index:
+
+        ./configure CPPFLAGS=-DXML_LARGE_SIZE
+        
+However, such a modification would be a breaking change to the ABI
+and is therefore not recommended for general use - e.g. as part of
+a Linux distribution - but rather for builds with special requirements.
+
+After running the configure script, the "make" command will build
+things and "make install" will install things into their proper
+location.  Have a look at the "Makefile" to learn about additional
+"make" options.  Note that you need to have write permission into
+the directories into which things will be installed.
+
+If you are interested in building Expat to provide document
+information in UTF-16 encoding rather than the default UTF-8, follow
+these instructions (after having run "make distclean"):
+
+        1. For UTF-16 output as unsigned short (and version/error
+           strings as char), run:
+
+               ./configure CPPFLAGS=-DXML_UNICODE
+
+           For UTF-16 output as wchar_t (incl. version/error strings),
+           run:
+
+               ./configure CFLAGS="-g -O2 -fshort-wchar" \
+                           CPPFLAGS=-DXML_UNICODE_WCHAR_T
+
+        2. Edit the MakeFile, changing:
+
+               LIBRARY = libexpat.la
+
+           to:
+
+               LIBRARY = libexpatw.la
+
+           (Note the additional "w" in the library name.)
+
+        3. Run "make buildlib" (which builds the library only).
+           Or, to save step 2, run "make buildlib LIBRARY=libexpatw.la".
+
+        4. Run "make installlib" (which installs the library only).
+           Or, if step 2 was omitted, run "make installlib LIBRARY=libexpatw.la".
+           
+Using DESTDIR or INSTALL_ROOT is enabled, with INSTALL_ROOT being the default
+value for DESTDIR, and the rest of the make file using only DESTDIR.
+It works as follows:
+   $ make install DESTDIR=/path/to/image
+overrides the in-makefile set DESTDIR, while both
+   $ INSTALL_ROOT=/path/to/image make install
+   $ make install INSTALL_ROOT=/path/to/image
+use DESTDIR=$(INSTALL_ROOT), even if DESTDIR eventually is defined in the
+environment, because variable-setting priority is
+1) commandline
+2) in-makefile
+3) environment  
+
+Note: This only applies to the Expat library itself, building UTF-16 versions
+of xmlwf and the tests is currently not supported.         
+
+Note for Solaris users:  The "ar" command is usually located in
+"/usr/ccs/bin", which is not in the default PATH.  You will need to
+add this to your path for the "make" command, and probably also switch
+to GNU make (the "make" found in /usr/ccs/bin does not seem to work
+properly -- appearantly it does not understand .PHONY directives).  If
+you're using ksh or bash, use this command to build:
+
+        PATH=/usr/ccs/bin:$PATH make
+
+When using Expat with a project using autoconf for configuration, you
+can use the probing macro in conftools/expat.m4 to determine how to
+include Expat.  See the comments at the top of that file for more
+information.
+
+A reference manual is available in the file doc/reference.html in this
+distribution.
+
+The homepage for this project is http://www.libexpat.org/.  There
+are links there to connect you to the bug reports page.  If you need
+to report a bug when you don't have access to a browser, you may also
+send a bug report by email to expat-bugs at mail.libexpat.org.
+
+Discussion related to the direction of future expat development takes
+place on expat-discuss at mail.libexpat.org.  Archives of this list and
+other Expat-related lists may be found at:
+
+        http://mail.libexpat.org/mailman/listinfo/
diff --git a/Utilities/cmexpat/ascii.h b/Utilities/cmexpat/ascii.h
deleted file mode 100644
index 6376b1f..0000000
--- a/Utilities/cmexpat/ascii.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#define ASCII_A 0x41
-#define ASCII_B 0x42
-#define ASCII_C 0x43
-#define ASCII_D 0x44
-#define ASCII_E 0x45
-#define ASCII_F 0x46
-#define ASCII_G 0x47
-#define ASCII_H 0x48
-#define ASCII_I 0x49
-#define ASCII_J 0x4A
-#define ASCII_K 0x4B
-#define ASCII_L 0x4C
-#define ASCII_M 0x4D
-#define ASCII_N 0x4E
-#define ASCII_O 0x4F
-#define ASCII_P 0x50
-#define ASCII_Q 0x51
-#define ASCII_R 0x52
-#define ASCII_S 0x53
-#define ASCII_T 0x54
-#define ASCII_U 0x55
-#define ASCII_V 0x56
-#define ASCII_W 0x57
-#define ASCII_X 0x58
-#define ASCII_Y 0x59
-#define ASCII_Z 0x5A
-
-#define ASCII_a 0x61
-#define ASCII_b 0x62
-#define ASCII_c 0x63
-#define ASCII_d 0x64
-#define ASCII_e 0x65
-#define ASCII_f 0x66
-#define ASCII_g 0x67
-#define ASCII_h 0x68
-#define ASCII_i 0x69
-#define ASCII_j 0x6A
-#define ASCII_k 0x6B
-#define ASCII_l 0x6C
-#define ASCII_m 0x6D
-#define ASCII_n 0x6E
-#define ASCII_o 0x6F
-#define ASCII_p 0x70
-#define ASCII_q 0x71
-#define ASCII_r 0x72
-#define ASCII_s 0x73
-#define ASCII_t 0x74
-#define ASCII_u 0x75
-#define ASCII_v 0x76
-#define ASCII_w 0x77
-#define ASCII_x 0x78
-#define ASCII_y 0x79
-#define ASCII_z 0x7A
-
-#define ASCII_0 0x30
-#define ASCII_1 0x31
-#define ASCII_2 0x32
-#define ASCII_3 0x33
-#define ASCII_4 0x34
-#define ASCII_5 0x35
-#define ASCII_6 0x36
-#define ASCII_7 0x37
-#define ASCII_8 0x38
-#define ASCII_9 0x39
-
-#define ASCII_TAB 0x09
-#define ASCII_SPACE 0x20 
-#define ASCII_EXCL 0x21
-#define ASCII_QUOT 0x22
-#define ASCII_AMP 0x26
-#define ASCII_APOS 0x27
-#define ASCII_MINUS 0x2D
-#define ASCII_PERIOD 0x2E
-#define ASCII_COLON 0x3A
-#define ASCII_SEMI 0x3B
-#define ASCII_LT 0x3C
-#define ASCII_EQUALS 0x3D
-#define ASCII_GT 0x3E
-#define ASCII_LSQB 0x5B
-#define ASCII_RSQB 0x5D
-#define ASCII_UNDERSCORE 0x5F
diff --git a/Utilities/cmexpat/asciitab.h b/Utilities/cmexpat/asciitab.h
deleted file mode 100644
index eb445cc..0000000
--- a/Utilities/cmexpat/asciitab.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
-/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
-/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
-/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
-/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
-/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
-/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
-/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
-/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
-/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
-/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/Utilities/cmexpat/cm_expat_mangle.h b/Utilities/cmexpat/cm_expat_mangle.h
deleted file mode 100644
index 82276a5..0000000
--- a/Utilities/cmexpat/cm_expat_mangle.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef cm_expat_mangle_h
-#define cm_expat_mangle_h
-
-/*
-
-This header file mangles all symbols exported from the expat library.
-It is included in all files while building the expat library.  Due to
-namespace pollution, no expat headers should be included in .h files in
-CMake.
-
-The following command was used to obtain the symbol list:
-
-nm libcmexpat.a |grep " T "
-
-*/
-
-#define XML_DefaultCurrent cm_expat_XML_DefaultCurrent
-#define XML_ErrorString cm_expat_XML_ErrorString
-#define XML_ExpatVersion cm_expat_XML_ExpatVersion
-#define XML_ExpatVersionInfo cm_expat_XML_ExpatVersionInfo
-#define XML_ExternalEntityParserCreate cm_expat_XML_ExternalEntityParserCreate
-#define XML_GetBase cm_expat_XML_GetBase
-#define XML_GetBuffer cm_expat_XML_GetBuffer
-#define XML_GetCurrentByteCount cm_expat_XML_GetCurrentByteCount
-#define XML_GetCurrentByteIndex cm_expat_XML_GetCurrentByteIndex
-#define XML_GetCurrentColumnNumber cm_expat_XML_GetCurrentColumnNumber
-#define XML_GetCurrentLineNumber cm_expat_XML_GetCurrentLineNumber
-#define XML_GetErrorCode cm_expat_XML_GetErrorCode
-#define XML_GetIdAttributeIndex cm_expat_XML_GetIdAttributeIndex
-#define XML_GetInputContext cm_expat_XML_GetInputContext
-#define XML_GetSpecifiedAttributeCount cm_expat_XML_GetSpecifiedAttributeCount
-#define XML_Parse cm_expat_XML_Parse
-#define XML_ParseBuffer cm_expat_XML_ParseBuffer
-#define XML_ParserCreate cm_expat_XML_ParserCreate
-#define XML_ParserCreateNS cm_expat_XML_ParserCreateNS
-#define XML_ParserCreate_MM cm_expat_XML_ParserCreate_MM
-#define XML_ParserFree cm_expat_XML_ParserFree
-#define XML_SetAttlistDeclHandler cm_expat_XML_SetAttlistDeclHandler
-#define XML_SetBase cm_expat_XML_SetBase
-#define XML_SetCdataSectionHandler cm_expat_XML_SetCdataSectionHandler
-#define XML_SetCharacterDataHandler cm_expat_XML_SetCharacterDataHandler
-#define XML_SetCommentHandler cm_expat_XML_SetCommentHandler
-#define XML_SetDefaultHandler cm_expat_XML_SetDefaultHandler
-#define XML_SetDefaultHandlerExpand cm_expat_XML_SetDefaultHandlerExpand
-#define XML_SetDoctypeDeclHandler cm_expat_XML_SetDoctypeDeclHandler
-#define XML_SetElementDeclHandler cm_expat_XML_SetElementDeclHandler
-#define XML_SetElementHandler cm_expat_XML_SetElementHandler
-#define XML_SetEncoding cm_expat_XML_SetEncoding
-#define XML_SetEndCdataSectionHandler cm_expat_XML_SetEndCdataSectionHandler
-#define XML_SetEndDoctypeDeclHandler cm_expat_XML_SetEndDoctypeDeclHandler
-#define XML_SetEndElementHandler cm_expat_XML_SetEndElementHandler
-#define XML_SetEndNamespaceDeclHandler cm_expat_XML_SetEndNamespaceDeclHandler
-#define XML_SetEntityDeclHandler cm_expat_XML_SetEntityDeclHandler
-#define XML_SetExternalEntityRefHandler cm_expat_XML_SetExternalEntityRefHandler
-#define XML_SetExternalEntityRefHandlerArg cm_expat_XML_SetExternalEntityRefHandlerArg
-#define XML_SetNamespaceDeclHandler cm_expat_XML_SetNamespaceDeclHandler
-#define XML_SetNotStandaloneHandler cm_expat_XML_SetNotStandaloneHandler
-#define XML_SetNotationDeclHandler cm_expat_XML_SetNotationDeclHandler
-#define XML_SetParamEntityParsing cm_expat_XML_SetParamEntityParsing
-#define XML_SetProcessingInstructionHandler cm_expat_XML_SetProcessingInstructionHandler
-#define XML_SetReturnNSTriplet cm_expat_XML_SetReturnNSTriplet
-#define XML_SetStartCdataSectionHandler cm_expat_XML_SetStartCdataSectionHandler
-#define XML_SetStartDoctypeDeclHandler cm_expat_XML_SetStartDoctypeDeclHandler
-#define XML_SetStartElementHandler cm_expat_XML_SetStartElementHandler
-#define XML_SetStartNamespaceDeclHandler cm_expat_XML_SetStartNamespaceDeclHandler
-#define XML_SetUnknownEncodingHandler cm_expat_XML_SetUnknownEncodingHandler
-#define XML_SetUnparsedEntityDeclHandler cm_expat_XML_SetUnparsedEntityDeclHandler
-#define XML_SetUserData cm_expat_XML_SetUserData
-#define XML_SetXmlDeclHandler cm_expat_XML_SetXmlDeclHandler
-#define XML_UseParserAsHandlerArg cm_expat_XML_UseParserAsHandlerArg
-#define XmlGetUtf16InternalEncoding cm_expat_XmlGetUtf16InternalEncoding
-#define XmlGetUtf16InternalEncodingNS cm_expat_XmlGetUtf16InternalEncodingNS
-#define XmlGetUtf8InternalEncoding cm_expat_XmlGetUtf8InternalEncoding
-#define XmlGetUtf8InternalEncodingNS cm_expat_XmlGetUtf8InternalEncodingNS
-#define XmlInitEncoding cm_expat_XmlInitEncoding
-#define XmlInitEncodingNS cm_expat_XmlInitEncodingNS
-#define XmlInitUnknownEncoding cm_expat_XmlInitUnknownEncoding
-#define XmlInitUnknownEncodingNS cm_expat_XmlInitUnknownEncodingNS
-#define XmlParseXmlDecl cm_expat_XmlParseXmlDecl
-#define XmlParseXmlDeclNS cm_expat_XmlParseXmlDeclNS
-#define XmlSizeOfUnknownEncoding cm_expat_XmlSizeOfUnknownEncoding
-#define XmlUtf16Encode cm_expat_XmlUtf16Encode
-#define XmlUtf8Encode cm_expat_XmlUtf8Encode
-#define XmlPrologStateInit cm_expat_XmlPrologStateInit
-#define XmlPrologStateInitExternalEntity cm_expat_XmlPrologStateInitExternalEntity
-
-#endif
diff --git a/Utilities/cmexpat/expat.h b/Utilities/cmexpat/expat.h
deleted file mode 100644
index 86e58a1..0000000
--- a/Utilities/cmexpat/expat.h
+++ /dev/null
@@ -1,740 +0,0 @@
-#include "cm_expat_mangle.h"
-/*
-Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#ifndef XmlParse_INCLUDED
-#define XmlParse_INCLUDED 1
-
-#include <stdlib.h>
-
-#include <cmexpat/expatDllConfig.h>
-
-#if defined(_WIN32) && !defined(CM_EXPAT_STATIC)
-#  if defined(cmexpat_EXPORTS)
-#    define XMLPARSEAPI(type) __declspec( dllexport ) type __cdecl
-#  else
-#    define XMLPARSEAPI(type) __declspec( dllimport ) type __cdecl
-#  endif
-#else
-#  define XMLPARSEAPI(type) type
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *XML_Parser;
-
-/* Information is UTF-8 encoded. */
-typedef char XML_Char;
-typedef char XML_LChar;
-
-enum XML_Content_Type {
-  XML_CTYPE_EMPTY = 1,
-  XML_CTYPE_ANY,
-  XML_CTYPE_MIXED,
-  XML_CTYPE_NAME,
-  XML_CTYPE_CHOICE,
-  XML_CTYPE_SEQ
-};
-
-enum XML_Content_Quant {
-  XML_CQUANT_NONE,
-  XML_CQUANT_OPT,
-  XML_CQUANT_REP,
-  XML_CQUANT_PLUS
-};
-
-/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
-   XML_CQUANT_NONE, and the other fields will be zero or NULL.
-   If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
-   numchildren will contain number of elements that may be mixed in
-   and children point to an array of XML_Content cells that will be
-   all of XML_CTYPE_NAME type with no quantification.
-
-   If type == XML_CTYPE_NAME, then the name points to the name, and
-   the numchildren field will be zero and children will be NULL. The
-   quant fields indicates any quantifiers placed on the name.
-
-   CHOICE and SEQ will have name NULL, the number of children in
-   numchildren and children will point, recursively, to an array
-   of XML_Content cells.
-
-   The EMPTY, ANY, and MIXED types will only occur at top level.
-*/
-
-typedef struct XML_cp XML_Content;
-
-struct XML_cp {
-  enum XML_Content_Type         type;
-  enum XML_Content_Quant        quant;
-  XML_Char *                    name;
-  unsigned int                  numchildren;
-  XML_Content *                 children;
-};
-
-
-/* This is called for an element declaration. See above for
-   description of the model argument. It's the caller's responsibility
-   to free model when finished with it.
-*/
-
-typedef void (*XML_ElementDeclHandler) (void *userData,
-                                        const XML_Char *name,
-                                        XML_Content *model);
-
-XMLPARSEAPI(void)
-XML_SetElementDeclHandler(XML_Parser parser,
-                          XML_ElementDeclHandler eldecl);
-
-/*
-  The Attlist declaration handler is called for *each* attribute. So
-  a single Attlist declaration with multiple attributes declared will
-  generate multiple calls to this handler. The "default" parameter
-  may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword.
-  The "isrequired" parameter will be true and the default value will
-  be NULL in the case of "#REQUIRED". If "isrequired" is true and
-  default is non-NULL, then this is a "#FIXED" default.
- */
-
-typedef void (*XML_AttlistDeclHandler) (void           *userData,
-                                        const XML_Char *elname,
-                                        const XML_Char *attname,
-                                        const XML_Char *att_type,
-                                        const XML_Char *dflt,
-                                        int             isrequired);
-
-XMLPARSEAPI(void)
-XML_SetAttlistDeclHandler(XML_Parser parser,
-                          XML_AttlistDeclHandler attdecl);
-
-
-  /* The XML declaration handler is called for *both* XML declarations and
-     text declarations. The way to distinguish is that the version parameter
-     will be null for text declarations. The encoding parameter may be null
-     for XML declarations. The standalone parameter will be -1, 0, or 1
-     indicating respectively that there was no standalone parameter in
-     the declaration, that it was given as no, or that it was given as yes.
-  */
-
-typedef void (*XML_XmlDeclHandler) (void                *userData,
-                                    const XML_Char      *version,
-                                    const XML_Char      *encoding,
-                                    int                  standalone);
-
-XMLPARSEAPI(void)
-XML_SetXmlDeclHandler(XML_Parser parser,
-                      XML_XmlDeclHandler xmldecl);
-
-
-typedef struct {
-  void *(*malloc_fcn)(size_t size);
-  void *(*realloc_fcn)(void *ptr, size_t size);
-  void (*free_fcn)(void *ptr);
-} XML_Memory_Handling_Suite;
-
-/* Constructs a new parser; encoding is the encoding specified by the
-external protocol or null if there is none specified. */
-
-XMLPARSEAPI(XML_Parser)
-XML_ParserCreate(const XML_Char *encoding);
-
-/* Constructs a new parser and namespace processor.  Element type
-names and attribute names that belong to a namespace will be expanded;
-unprefixed attribute names are never expanded; unprefixed element type
-names are expanded only if there is a default namespace. The expanded
-name is the concatenation of the namespace URI, the namespace
-separator character, and the local part of the name.  If the namespace
-separator is '\0' then the namespace URI and the local part will be
-concatenated without any separator.  When a namespace is not declared,
-the name and prefix will be passed through without expansion. */
-
-XMLPARSEAPI(XML_Parser)
-XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
-
-
-/* Constructs a new parser using the memory management suit referred to
-   by memsuite. If memsuite is NULL, then use the standard library memory
-   suite. If namespaceSeparator is non-NULL it creates a parser with
-   namespace processing as described above. The character pointed at
-   will serve as the namespace separator.
-
-   All further memory operations used for the created parser will come from
-   the given suite.
-*/
-
-XMLPARSEAPI(XML_Parser)
-XML_ParserCreate_MM(const XML_Char *encoding,
-                    const XML_Memory_Handling_Suite *memsuite,
-                    const XML_Char *namespaceSeparator);
-
-/* atts is array of name/value pairs, terminated by 0;
-   names and values are 0 terminated. */
-
-typedef void (*XML_StartElementHandler)(void *userData,
-                                        const XML_Char *name,
-                                        const XML_Char **atts);
-
-typedef void (*XML_EndElementHandler)(void *userData,
-                                      const XML_Char *name);
-
-
-/* s is not 0 terminated. */
-typedef void (*XML_CharacterDataHandler)(void *userData,
-                                         const XML_Char *s,
-                                         int len);
-
-/* target and data are 0 terminated */
-typedef void (*XML_ProcessingInstructionHandler)(void *userData,
-                                                 const XML_Char *target,
-                                                 const XML_Char *data);
-
-/* data is 0 terminated */
-typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
-
-typedef void (*XML_StartCdataSectionHandler)(void *userData);
-typedef void (*XML_EndCdataSectionHandler)(void *userData);
-
-/* This is called for any characters in the XML document for
-which there is no applicable handler.  This includes both
-characters that are part of markup which is of a kind that is
-not reported (comments, markup declarations), or characters
-that are part of a construct which could be reported but
-for which no handler has been supplied. The characters are passed
-exactly as they were in the XML document except that
-they will be encoded in UTF-8.  Line boundaries are not normalized.
-Note that a byte order mark character is not passed to the default handler.
-There are no guarantees about how characters are divided between calls
-to the default handler: for example, a comment might be split between
-multiple calls. */
-
-typedef void (*XML_DefaultHandler)(void *userData,
-                                   const XML_Char *s,
-                                   int len);
-
-/* This is called for the start of the DOCTYPE declaration, before
-   any DTD or internal subset is parsed. */
-
-typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
-                                            const XML_Char *doctypeName,
-                                            const XML_Char *sysid,
-                                            const XML_Char *pubid,
-                                            int has_internal_subset);
-
-/* This is called for the start of the DOCTYPE declaration when the
-closing > is encountered, but after processing any external subset. */
-typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
-
-/* This is called for entity declarations. The is_parameter_entity
-   argument will be non-zero if the entity is a parameter entity, zero
-   otherwise.
-
-   For internal entities (<!ENTITY foo "bar">), value will
-   be non-null and systemId, publicID, and notationName will be null.
-   The value string is NOT null terminated; the length is provided in
-   the value_length argument. Since it is legal to have zero-length
-   values, do not use this argument to test for internal entities.
-
-   For external entities, value will be null and systemId will be non-null.
-   The publicId argument will be null unless a public identifier was
-   provided. The notationName argument will have a non-null value only
-   for unparsed entity declarations.
-*/
-
-typedef void (*XML_EntityDeclHandler) (void *userData,
-                                       const XML_Char *entityName,
-                                       int is_parameter_entity,
-                                       const XML_Char *value,
-                                       int value_length,
-                                       const XML_Char *base,
-                                       const XML_Char *systemId,
-                                       const XML_Char *publicId,
-                                       const XML_Char *notationName);
-                                       
-XMLPARSEAPI(void)
-XML_SetEntityDeclHandler(XML_Parser parser,
-                         XML_EntityDeclHandler handler);
-
-/* OBSOLETE -- OBSOLETE -- OBSOLETE
-   This handler has been superceded by the EntityDeclHandler above.
-   It is provided here for backward compatibility.
-This is called for a declaration of an unparsed (NDATA)
-entity.  The base argument is whatever was set by XML_SetBase.
-The entityName, systemId and notationName arguments will never be null.
-The other arguments may be. */
-
-typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
-                                              const XML_Char *entityName,
-                                              const XML_Char *base,
-                                              const XML_Char *systemId,
-                                              const XML_Char *publicId,
-                                              const XML_Char *notationName);
-
-/* This is called for a declaration of notation.
-The base argument is whatever was set by XML_SetBase.
-The notationName will never be null.  The other arguments can be. */
-
-typedef void (*XML_NotationDeclHandler)(void *userData,
-                                        const XML_Char *notationName,
-                                        const XML_Char *base,
-                                        const XML_Char *systemId,
-                                        const XML_Char *publicId);
-
-/* When namespace processing is enabled, these are called once for
-each namespace declaration. The call to the start and end element
-handlers occur between the calls to the start and end namespace
-declaration handlers. For an xmlns attribute, prefix will be null.
-For an xmlns="" attribute, uri will be null. */
-
-typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
-                                              const XML_Char *prefix,
-                                              const XML_Char *uri);
-
-typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
-                                            const XML_Char *prefix);
-
-/* This is called if the document is not standalone (it has an
-external subset or a reference to a parameter entity, but does not
-have standalone="yes"). If this handler returns 0, then processing
-will not continue, and the parser will return a
-XML_ERROR_NOT_STANDALONE error. */
-
-typedef int (*XML_NotStandaloneHandler)(void *userData);
-
-/* This is called for a reference to an external parsed general entity.
-The referenced entity is not automatically parsed.
-The application can parse it immediately or later using
-XML_ExternalEntityParserCreate.
-The parser argument is the parser parsing the entity containing the reference;
-it can be passed as the parser argument to XML_ExternalEntityParserCreate.
-The systemId argument is the system identifier as specified in the entity
-declaration; it will not be null.
-The base argument is the system identifier that should be used as the base for
-resolving systemId if systemId was relative; this is set by XML_SetBase;
-it may be null.
-The publicId argument is the public identifier as specified in the entity
-declaration, or null if none was specified; the whitespace in the public
-identifier will have been normalized as required by the XML spec.
-The context argument specifies the parsing context in the format
-expected by the context argument to
-XML_ExternalEntityParserCreate; context is valid only until the handler
-returns, so if the referenced entity is to be parsed later, it must be copied.
-The handler should return 0 if processing should not continue because of
-a fatal error in the handling of the external entity.
-In this case the calling parser will return an
-XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
-Note that unlike other handlers the first argument is the parser, not
-userData. */
-
-typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
-                                            const XML_Char *context,
-                                            const XML_Char *base,
-                                            const XML_Char *systemId,
-                                            const XML_Char *publicId);
-
-/* This structure is filled in by the XML_UnknownEncodingHandler
-to provide information to the parser about encodings that are unknown
-to the parser.
-The map[b] member gives information about byte sequences
-whose first byte is b.
-If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar
-value c.
-If map[b] is -1, then the byte sequence is malformed.
-If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
-sequence that encodes a single Unicode scalar value.
-The data member will be passed as the first argument to the convert function.
-The convert function is used to convert multibyte sequences;
-s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
-The convert function must return the Unicode scalar value
-represented by this byte sequence or -1 if the byte sequence is malformed.
-The convert function may be null if the encoding is a single-byte encoding,
-that is if map[b] >= -1 for all bytes b.
-When the parser is finished with the encoding, then if release is not null,
-it will call release passing it the data member;
-once release has been called, the convert function will not be called again.
-
-Expat places certain restrictions on the encodings that are supported
-using this mechanism.
-
-1. Every ASCII character that can appear in a well-formed XML document,
-other than the characters
-
-  $@\^`{}~
-
-must be represented by a single byte, and that byte must be the
-same byte that represents that character in ASCII.
-
-2. No character may require more than 4 bytes to encode.
-
-3. All characters encoded must have Unicode scalar values <= 0xFFFF, (i.e.,
-characters that would be encoded by surrogates in UTF-16 are  not
-allowed).  Note that this restriction doesn't apply to the built-in
-support for UTF-8 and UTF-16.
-
-4. No Unicode character may be encoded by more than one distinct sequence
-of bytes. */
-
-typedef struct {
-  int map[256];
-  void *data;
-  int (*convert)(void *data, const char *s);
-  void (*release)(void *data);
-} XML_Encoding;
-
-/* This is called for an encoding that is unknown to the parser.
-The encodingHandlerData argument is that which was passed as the
-second argument to XML_SetUnknownEncodingHandler.
-The name argument gives the name of the encoding as specified in
-the encoding declaration.
-If the callback can provide information about the encoding,
-it must fill in the XML_Encoding structure, and return 1.
-Otherwise it must return 0.
-If info does not describe a suitable encoding,
-then the parser will return an XML_UNKNOWN_ENCODING error. */
-
-typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
-                                          const XML_Char *name,
-                                          XML_Encoding *info);
-
-XMLPARSEAPI(void)
-XML_SetElementHandler(XML_Parser parser,
-                      XML_StartElementHandler start,
-                      XML_EndElementHandler end);
-
-XMLPARSEAPI(void)
-XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
-
-XMLPARSEAPI(void)
-XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
-
-XMLPARSEAPI(void)
-XML_SetCharacterDataHandler(XML_Parser parser,
-                            XML_CharacterDataHandler handler);
-
-XMLPARSEAPI(void)
-XML_SetProcessingInstructionHandler(XML_Parser parser,
-                                    XML_ProcessingInstructionHandler handler);
-XMLPARSEAPI(void)
-XML_SetCommentHandler(XML_Parser parser,
-                      XML_CommentHandler handler);
-
-XMLPARSEAPI(void)
-XML_SetCdataSectionHandler(XML_Parser parser,
-                           XML_StartCdataSectionHandler start,
-                           XML_EndCdataSectionHandler end);
-
-XMLPARSEAPI(void)
-XML_SetStartCdataSectionHandler(XML_Parser parser,
-                                XML_StartCdataSectionHandler start);
-
-XMLPARSEAPI(void)
-XML_SetEndCdataSectionHandler(XML_Parser parser,
-                              XML_EndCdataSectionHandler end);
-
-/* This sets the default handler and also inhibits expansion of
-internal entities.  The entity reference will be passed to the default
-handler. */
-
-XMLPARSEAPI(void)
-XML_SetDefaultHandler(XML_Parser parser,
-                      XML_DefaultHandler handler);
-
-/* This sets the default handler but does not inhibit expansion of
-internal entities.  The entity reference will not be passed to the
-default handler. */
-
-XMLPARSEAPI(void)
-XML_SetDefaultHandlerExpand(XML_Parser parser,
-                            XML_DefaultHandler handler);
-
-XMLPARSEAPI(void)
-XML_SetDoctypeDeclHandler(XML_Parser parser,
-                          XML_StartDoctypeDeclHandler start,
-                          XML_EndDoctypeDeclHandler end);
-
-XMLPARSEAPI(void)
-XML_SetStartDoctypeDeclHandler(XML_Parser parser,
-                               XML_StartDoctypeDeclHandler start);
-
-XMLPARSEAPI(void)
-XML_SetEndDoctypeDeclHandler(XML_Parser parser,
-                             XML_EndDoctypeDeclHandler end);
-
-XMLPARSEAPI(void)
-XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
-                                 XML_UnparsedEntityDeclHandler handler);
-
-XMLPARSEAPI(void)
-XML_SetNotationDeclHandler(XML_Parser parser,
-                           XML_NotationDeclHandler handler);
-
-XMLPARSEAPI(void)
-XML_SetNamespaceDeclHandler(XML_Parser parser,
-                            XML_StartNamespaceDeclHandler start,
-                            XML_EndNamespaceDeclHandler end);
-
-XMLPARSEAPI(void)
-XML_SetStartNamespaceDeclHandler(XML_Parser parser,
-                                 XML_StartNamespaceDeclHandler start);
-
-XMLPARSEAPI(void)
-XML_SetEndNamespaceDeclHandler(XML_Parser parser,
-                               XML_EndNamespaceDeclHandler end);
-
-XMLPARSEAPI(void)
-XML_SetNotStandaloneHandler(XML_Parser parser,
-                            XML_NotStandaloneHandler handler);
-
-XMLPARSEAPI(void)
-XML_SetExternalEntityRefHandler(XML_Parser parser,
-                                XML_ExternalEntityRefHandler handler);
-
-/* If a non-null value for arg is specified here, then it will be passed
-as the first argument to the external entity ref handler instead
-of the parser object. */
-XMLPARSEAPI(void)
-XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
-
-XMLPARSEAPI(void)
-XML_SetUnknownEncodingHandler(XML_Parser parser,
-                              XML_UnknownEncodingHandler handler,
-                              void *encodingHandlerData);
-
-/* This can be called within a handler for a start element, end element,
-processing instruction or character data.  It causes the corresponding
-markup to be passed to the default handler. */
-XMLPARSEAPI(void)
-XML_DefaultCurrent(XML_Parser parser);
-
-/* If do_nst is non-zero, and namespace processing is in effect, and
-   a name has a prefix (i.e. an explicit namespace qualifier) then
-   that name is returned as a triplet in a single
-   string separated by the separator character specified when the parser
-   was created: URI + sep + local_name + sep + prefix.
-
-   If do_nst is zero, then namespace information is returned in the
-   default manner (URI + sep + local_name) whether or not the names
-   has a prefix.
-*/
-
-XMLPARSEAPI(void)
-XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
-
-/* This value is passed as the userData argument to callbacks. */
-XMLPARSEAPI(void)
-XML_SetUserData(XML_Parser parser, void *userData);
-
-/* Returns the last value set by XML_SetUserData or null. */
-#define XML_GetUserData(parser) (*(void **)(parser))
-
-/* This is equivalent to supplying an encoding argument
-to XML_ParserCreate. It must not be called after XML_Parse
-or XML_ParseBuffer. */
-
-XMLPARSEAPI(int)
-XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
-
-/* If this function is called, then the parser will be passed
-as the first argument to callbacks instead of userData.
-The userData will still be accessible using XML_GetUserData. */
-
-XMLPARSEAPI(void)
-XML_UseParserAsHandlerArg(XML_Parser parser);
-
-/* Sets the base to be used for resolving relative URIs in system
-identifiers in declarations.  Resolving relative identifiers is left
-to the application: this value will be passed through as the base
-argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler
-and XML_UnparsedEntityDeclHandler. The base argument will be copied.
-Returns zero if out of memory, non-zero otherwise. */
-
-XMLPARSEAPI(int)
-XML_SetBase(XML_Parser parser, const XML_Char *base);
-
-XMLPARSEAPI(const XML_Char *)
-XML_GetBase(XML_Parser parser);
-
-/* Returns the number of the attribute/value pairs passed in last call
-to the XML_StartElementHandler that were specified in the start-tag
-rather than defaulted. Each attribute/value pair counts as 2; thus
-this correspondds to an index into the atts array passed to the
-XML_StartElementHandler. */
-
-XMLPARSEAPI(int)
-XML_GetSpecifiedAttributeCount(XML_Parser parser);
-
-/* Returns the index of the ID attribute passed in the last call to
-XML_StartElementHandler, or -1 if there is no ID attribute.  Each
-attribute/value pair counts as 2; thus this correspondds to an index
-into the atts array passed to the XML_StartElementHandler. */
-
-XMLPARSEAPI(int)
-XML_GetIdAttributeIndex(XML_Parser parser);
-
-/* Parses some input. Returns 0 if a fatal error is detected.
-The last call to XML_Parse must have isFinal true;
-len may be zero for this call (or any other). */
-XMLPARSEAPI(int)
-XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
-
-XMLPARSEAPI(void *)
-XML_GetBuffer(XML_Parser parser, int len);
-
-XMLPARSEAPI(int)
-XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
-
-/* Creates an XML_Parser object that can parse an external general
-entity; context is a '\0'-terminated string specifying the parse
-context; encoding is a '\0'-terminated string giving the name of the
-externally specified encoding, or null if there is no externally
-specified encoding.  The context string consists of a sequence of
-tokens separated by formfeeds (\f); a token consisting of a name
-specifies that the general entity of the name is open; a token of the
-form prefix=uri specifies the namespace for a particular prefix; a
-token of the form =uri specifies the default namespace.  This can be
-called at any point after the first call to an
-ExternalEntityRefHandler so longer as the parser has not yet been
-freed.  The new parser is completely independent and may safely be
-used in a separate thread.  The handlers and userData are initialized
-from the parser argument.  Returns 0 if out of memory.  Otherwise
-returns a new XML_Parser object. */
-XMLPARSEAPI(XML_Parser)
-XML_ExternalEntityParserCreate(XML_Parser parser,
-                               const XML_Char *context,
-                               const XML_Char *encoding);
-
-enum XML_ParamEntityParsing {
-  XML_PARAM_ENTITY_PARSING_NEVER,
-  XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
-  XML_PARAM_ENTITY_PARSING_ALWAYS
-};
-
-/* Controls parsing of parameter entities (including the external DTD
-subset). If parsing of parameter entities is enabled, then references
-to external parameter entities (including the external DTD subset)
-will be passed to the handler set with
-XML_SetExternalEntityRefHandler.  The context passed will be 0.
-Unlike external general entities, external parameter entities can only
-be parsed synchronously.  If the external parameter entity is to be
-parsed, it must be parsed during the call to the external entity ref
-handler: the complete sequence of XML_ExternalEntityParserCreate,
-XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
-this call.  After XML_ExternalEntityParserCreate has been called to
-create the parser for the external parameter entity (context must be 0
-for this call), it is illegal to make any calls on the old parser
-until XML_ParserFree has been called on the newly created parser.  If
-the library has been compiled without support for parameter entity
-parsing (ie without XML_DTD being defined), then
-XML_SetParamEntityParsing will return 0 if parsing of parameter
-entities is requested; otherwise it will return non-zero. */
-
-XMLPARSEAPI(int)
-XML_SetParamEntityParsing(XML_Parser parser,
-                          enum XML_ParamEntityParsing parsing);
-
-enum XML_Error {
-  XML_ERROR_NONE,
-  XML_ERROR_NO_MEMORY,
-  XML_ERROR_SYNTAX,
-  XML_ERROR_NO_ELEMENTS,
-  XML_ERROR_INVALID_TOKEN,
-  XML_ERROR_UNCLOSED_TOKEN,
-  XML_ERROR_PARTIAL_CHAR,
-  XML_ERROR_TAG_MISMATCH,
-  XML_ERROR_DUPLICATE_ATTRIBUTE,
-  XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
-  XML_ERROR_PARAM_ENTITY_REF,
-  XML_ERROR_UNDEFINED_ENTITY,
-  XML_ERROR_RECURSIVE_ENTITY_REF,
-  XML_ERROR_ASYNC_ENTITY,
-  XML_ERROR_BAD_CHAR_REF,
-  XML_ERROR_BINARY_ENTITY_REF,
-  XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
-  XML_ERROR_MISPLACED_XML_PI,
-  XML_ERROR_UNKNOWN_ENCODING,
-  XML_ERROR_INCORRECT_ENCODING,
-  XML_ERROR_UNCLOSED_CDATA_SECTION,
-  XML_ERROR_EXTERNAL_ENTITY_HANDLING,
-  XML_ERROR_NOT_STANDALONE,
-  XML_ERROR_UNEXPECTED_STATE
-};
-
-/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
-returns information about the error. */
-
-XMLPARSEAPI(enum XML_Error)
-XML_GetErrorCode(XML_Parser parser);
-
-/* These functions return information about the current parse location.
-They may be called when XML_Parse or XML_ParseBuffer return 0;
-in this case the location is the location of the character at which
-the error was detected.
-They may also be called from any other callback called to report
-some parse event; in this the location is the location of the first
-of the sequence of characters that generated the event. */
-
-XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
-XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
-XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
-
-/* Return the number of bytes in the current event.
-Returns 0 if the event is in an internal entity. */
-
-XMLPARSEAPI(int)
-XML_GetCurrentByteCount(XML_Parser parser);
-
-/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
-   the integer pointed to by offset to the offset within this buffer
-   of the current parse position, and sets the integer pointed to by size
-   to the size of this buffer (the number of input bytes). Otherwise
-   returns a null pointer. Also returns a null pointer if a parse isn't
-   active.
-
-   NOTE: The character pointer returned should not be used outside
-   the handler that makes the call. */
-
-XMLPARSEAPI(const char *)
-XML_GetInputContext(XML_Parser parser,
-                    int *offset,
-                    int *size);
-
-/* For backwards compatibility with previous versions. */
-#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
-#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
-#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
-
-/* Frees memory used by the parser. */
-XMLPARSEAPI(void)
-XML_ParserFree(XML_Parser parser);
-
-/* Returns a string describing the error. */
-XMLPARSEAPI(const XML_LChar *)
-XML_ErrorString(int code);
-
-/* Return a string containing the version number of this expat */
-XMLPARSEAPI(const XML_LChar *)
-XML_ExpatVersion(void);
-
-typedef struct {
-  int major;
-  int minor;
-  int micro;
-} XML_Expat_Version;
-
-/* Return an XML_Expat_Version structure containing numeric version
-   number information for this version of expat */
-
-XMLPARSEAPI(XML_Expat_Version)
-XML_ExpatVersionInfo(void);
-
-#define XML_MAJOR_VERSION 1
-#define XML_MINOR_VERSION 95
-#define XML_MICRO_VERSION 2
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not XmlParse_INCLUDED */
diff --git a/Utilities/cmexpat/expatConfig.h.in b/Utilities/cmexpat/expatConfig.h.in
deleted file mode 100644
index 8f9669a..0000000
--- a/Utilities/cmexpat/expatConfig.h.in
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "cm_expat_mangle.h"
-#if defined(_WIN32) || defined(WIN32)
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#undef WIN32_LEAN_AND_MEAN
-#include <memory.h>
-#include <string.h>
-#define XML_BYTE_ORDER 12
-
-#else
-
-#cmakedefine CMEXPAT_BIGENDIAN
-#ifdef CMEXPAT_BIGENDIAN
-#  define XML_BYTE_ORDER 21
-#else
-#  define XML_BYTE_ORDER 12
-#endif
-
-#endif
-
-#define XML_NS
-#define XML_DTD
-#define XML_CONTEXT_BYTES 1024
-
-#if defined ( _MSC_VER )
-#pragma warning ( disable : 4100 )
-#pragma warning ( disable : 4127 )
-#pragma warning ( disable : 4244 )
-#pragma warning ( disable : 4251 )
-#pragma warning ( disable : 4305 )
-#pragma warning ( disable : 4309 )
-#pragma warning ( disable : 4702 )
-#pragma warning ( disable : 4706 )
-#pragma warning ( disable : 4786 )
-#pragma warning ( disable : 4057 )
-#pragma warning ( disable : 4189 )
-#pragma warning ( disable : 4505 )
-#endif
-
-#define VERSION "1.95.2"
-
-#define cmExpatUnused(x) (void)x
diff --git a/Utilities/cmexpat/expatDllConfig.h.in b/Utilities/cmexpat/expatDllConfig.h.in
deleted file mode 100644
index eaaf4b0..0000000
--- a/Utilities/cmexpat/expatDllConfig.h.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _expatDllConfig_h
-#define _expatDllConfig_h
-
-#cmakedefine CM_EXPAT_STATIC
-
-#endif
diff --git a/Utilities/cmexpat/expat_config.h.cmake b/Utilities/cmexpat/expat_config.h.cmake
new file mode 100644
index 0000000..ad540d6
--- /dev/null
+++ b/Utilities/cmexpat/expat_config.h.cmake
@@ -0,0 +1,76 @@
+/* expat_config.h.in.  Generated from configure.in by autoheader.  */
+
+/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
+#cmakedefine BYTEORDER @BYTEORDER@
+
+/* Define to 1 if you have the `bcopy' function. */
+#cmakedefine HAVE_BCOPY
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#cmakedefine HAVE_DLFCN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#cmakedefine HAVE_FCNTL_H
+
+/* Define to 1 if you have the `getpagesize' function. */
+#cmakedefine HAVE_GETPAGESIZE
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `memmove' function. */
+#cmakedefine HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#cmakedefine HAVE_MEMORY_H
+
+/* Define to 1 if you have a working `mmap' system call. */
+#cmakedefine HAVE_MMAP
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#cmakedefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#cmakedefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#cmakedefine HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#cmakedefine HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H
+
+/* Define to 1 if you have the ANSI C header files. */
+#cmakedefine STDC_HEADERS
+
+/* whether byteorder is bigendian */
+#cmakedefine WORDS_BIGENDIAN
+
+/* Define to specify how much context to retain around the current parse
+   point. */
+#define XML_CONTEXT_BYTES 1024
+
+/* Define to make parameter entity parsing functionality available. */
+/* #undef XML_DTD */
+
+/* Define to make XML Namespaces functionality available. */
+/* #undef XML_NS */
+
+/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */
+#ifdef _MSC_VER
+# define __func__ __FUNCTION__
+#endif
+
+/* Define to `long' if <sys/types.h> does not define. */
+#cmakedefine off_t @OFF_T@
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+#cmakedefine size_t @SIZE_T@
diff --git a/Utilities/cmexpat/iasciitab.h b/Utilities/cmexpat/iasciitab.h
deleted file mode 100644
index 55dbc39..0000000
--- a/Utilities/cmexpat/iasciitab.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
-/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
-/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
-/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
-/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
-/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
-/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
-/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
-/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
-/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
-/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
-/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/Utilities/cmexpat/latin1tab.h b/Utilities/cmexpat/latin1tab.h
deleted file mode 100644
index 178b1d1..0000000
--- a/Utilities/cmexpat/latin1tab.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
-/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
-/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
-/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
diff --git a/Utilities/cmexpat/lib/ascii.h b/Utilities/cmexpat/lib/ascii.h
new file mode 100644
index 0000000..d10530b
--- /dev/null
+++ b/Utilities/cmexpat/lib/ascii.h
@@ -0,0 +1,92 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#define ASCII_A 0x41
+#define ASCII_B 0x42
+#define ASCII_C 0x43
+#define ASCII_D 0x44
+#define ASCII_E 0x45
+#define ASCII_F 0x46
+#define ASCII_G 0x47
+#define ASCII_H 0x48
+#define ASCII_I 0x49
+#define ASCII_J 0x4A
+#define ASCII_K 0x4B
+#define ASCII_L 0x4C
+#define ASCII_M 0x4D
+#define ASCII_N 0x4E
+#define ASCII_O 0x4F
+#define ASCII_P 0x50
+#define ASCII_Q 0x51
+#define ASCII_R 0x52
+#define ASCII_S 0x53
+#define ASCII_T 0x54
+#define ASCII_U 0x55
+#define ASCII_V 0x56
+#define ASCII_W 0x57
+#define ASCII_X 0x58
+#define ASCII_Y 0x59
+#define ASCII_Z 0x5A
+
+#define ASCII_a 0x61
+#define ASCII_b 0x62
+#define ASCII_c 0x63
+#define ASCII_d 0x64
+#define ASCII_e 0x65
+#define ASCII_f 0x66
+#define ASCII_g 0x67
+#define ASCII_h 0x68
+#define ASCII_i 0x69
+#define ASCII_j 0x6A
+#define ASCII_k 0x6B
+#define ASCII_l 0x6C
+#define ASCII_m 0x6D
+#define ASCII_n 0x6E
+#define ASCII_o 0x6F
+#define ASCII_p 0x70
+#define ASCII_q 0x71
+#define ASCII_r 0x72
+#define ASCII_s 0x73
+#define ASCII_t 0x74
+#define ASCII_u 0x75
+#define ASCII_v 0x76
+#define ASCII_w 0x77
+#define ASCII_x 0x78
+#define ASCII_y 0x79
+#define ASCII_z 0x7A
+
+#define ASCII_0 0x30
+#define ASCII_1 0x31
+#define ASCII_2 0x32
+#define ASCII_3 0x33
+#define ASCII_4 0x34
+#define ASCII_5 0x35
+#define ASCII_6 0x36
+#define ASCII_7 0x37
+#define ASCII_8 0x38
+#define ASCII_9 0x39
+
+#define ASCII_TAB 0x09
+#define ASCII_SPACE 0x20
+#define ASCII_EXCL 0x21
+#define ASCII_QUOT 0x22
+#define ASCII_AMP 0x26
+#define ASCII_APOS 0x27
+#define ASCII_MINUS 0x2D
+#define ASCII_PERIOD 0x2E
+#define ASCII_COLON 0x3A
+#define ASCII_SEMI 0x3B
+#define ASCII_LT 0x3C
+#define ASCII_EQUALS 0x3D
+#define ASCII_GT 0x3E
+#define ASCII_LSQB 0x5B
+#define ASCII_RSQB 0x5D
+#define ASCII_UNDERSCORE 0x5F
+#define ASCII_LPAREN 0x28
+#define ASCII_RPAREN 0x29
+#define ASCII_FF 0x0C
+#define ASCII_SLASH 0x2F
+#define ASCII_HASH 0x23
+#define ASCII_PIPE 0x7C
+#define ASCII_COMMA 0x2C
diff --git a/Utilities/cmexpat/lib/asciitab.h b/Utilities/cmexpat/lib/asciitab.h
new file mode 100644
index 0000000..79a15c2
--- /dev/null
+++ b/Utilities/cmexpat/lib/asciitab.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
+/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
+/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
+/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
+/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
+/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
+/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
+/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
+/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
+/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
+/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/Utilities/cmexpat/lib/expat.h b/Utilities/cmexpat/lib/expat.h
new file mode 100644
index 0000000..5abcefd
--- /dev/null
+++ b/Utilities/cmexpat/lib/expat.h
@@ -0,0 +1,1050 @@
+/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#ifndef Expat_INCLUDED
+#define Expat_INCLUDED 1
+
+#ifdef __VMS
+/*      0        1         2         3      0        1         2         3
+        1234567890123456789012345678901     1234567890123456789012345678901 */
+#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
+#define XML_SetUnparsedEntityDeclHandler    XML_SetUnparsedEntDeclHandler
+#define XML_SetStartNamespaceDeclHandler    XML_SetStartNamespcDeclHandler
+#define XML_SetExternalEntityRefHandlerArg  XML_SetExternalEntRefHandlerArg
+#endif
+
+#include <stdlib.h>
+#include "expat_external.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct XML_ParserStruct;
+typedef struct XML_ParserStruct *XML_Parser;
+
+/* Should this be defined using stdbool.h when C99 is available? */
+typedef unsigned char XML_Bool;
+#define XML_TRUE   ((XML_Bool) 1)
+#define XML_FALSE  ((XML_Bool) 0)
+
+/* The XML_Status enum gives the possible return values for several
+   API functions.  The preprocessor #defines are included so this
+   stanza can be added to code that still needs to support older
+   versions of Expat 1.95.x:
+
+   #ifndef XML_STATUS_OK
+   #define XML_STATUS_OK    1
+   #define XML_STATUS_ERROR 0
+   #endif
+
+   Otherwise, the #define hackery is quite ugly and would have been
+   dropped.
+*/
+enum XML_Status {
+  XML_STATUS_ERROR = 0,
+#define XML_STATUS_ERROR XML_STATUS_ERROR
+  XML_STATUS_OK = 1,
+#define XML_STATUS_OK XML_STATUS_OK
+  XML_STATUS_SUSPENDED = 2
+#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
+};
+
+enum XML_Error {
+  XML_ERROR_NONE,
+  XML_ERROR_NO_MEMORY,
+  XML_ERROR_SYNTAX,
+  XML_ERROR_NO_ELEMENTS,
+  XML_ERROR_INVALID_TOKEN,
+  XML_ERROR_UNCLOSED_TOKEN,
+  XML_ERROR_PARTIAL_CHAR,
+  XML_ERROR_TAG_MISMATCH,
+  XML_ERROR_DUPLICATE_ATTRIBUTE,
+  XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
+  XML_ERROR_PARAM_ENTITY_REF,
+  XML_ERROR_UNDEFINED_ENTITY,
+  XML_ERROR_RECURSIVE_ENTITY_REF,
+  XML_ERROR_ASYNC_ENTITY,
+  XML_ERROR_BAD_CHAR_REF,
+  XML_ERROR_BINARY_ENTITY_REF,
+  XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
+  XML_ERROR_MISPLACED_XML_PI,
+  XML_ERROR_UNKNOWN_ENCODING,
+  XML_ERROR_INCORRECT_ENCODING,
+  XML_ERROR_UNCLOSED_CDATA_SECTION,
+  XML_ERROR_EXTERNAL_ENTITY_HANDLING,
+  XML_ERROR_NOT_STANDALONE,
+  XML_ERROR_UNEXPECTED_STATE,
+  XML_ERROR_ENTITY_DECLARED_IN_PE,
+  XML_ERROR_FEATURE_REQUIRES_XML_DTD,
+  XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
+  /* Added in 1.95.7. */
+  XML_ERROR_UNBOUND_PREFIX,
+  /* Added in 1.95.8. */
+  XML_ERROR_UNDECLARING_PREFIX,
+  XML_ERROR_INCOMPLETE_PE,
+  XML_ERROR_XML_DECL,
+  XML_ERROR_TEXT_DECL,
+  XML_ERROR_PUBLICID,
+  XML_ERROR_SUSPENDED,
+  XML_ERROR_NOT_SUSPENDED,
+  XML_ERROR_ABORTED,
+  XML_ERROR_FINISHED,
+  XML_ERROR_SUSPEND_PE,
+  /* Added in 2.0. */
+  XML_ERROR_RESERVED_PREFIX_XML,
+  XML_ERROR_RESERVED_PREFIX_XMLNS,
+  XML_ERROR_RESERVED_NAMESPACE_URI
+};
+
+enum XML_Content_Type {
+  XML_CTYPE_EMPTY = 1,
+  XML_CTYPE_ANY,
+  XML_CTYPE_MIXED,
+  XML_CTYPE_NAME,
+  XML_CTYPE_CHOICE,
+  XML_CTYPE_SEQ
+};
+
+enum XML_Content_Quant {
+  XML_CQUANT_NONE,
+  XML_CQUANT_OPT,
+  XML_CQUANT_REP,
+  XML_CQUANT_PLUS
+};
+
+/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
+   XML_CQUANT_NONE, and the other fields will be zero or NULL.
+   If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
+   numchildren will contain number of elements that may be mixed in
+   and children point to an array of XML_Content cells that will be
+   all of XML_CTYPE_NAME type with no quantification.
+
+   If type == XML_CTYPE_NAME, then the name points to the name, and
+   the numchildren field will be zero and children will be NULL. The
+   quant fields indicates any quantifiers placed on the name.
+
+   CHOICE and SEQ will have name NULL, the number of children in
+   numchildren and children will point, recursively, to an array
+   of XML_Content cells.
+
+   The EMPTY, ANY, and MIXED types will only occur at top level.
+*/
+
+typedef struct XML_cp XML_Content;
+
+struct XML_cp {
+  enum XML_Content_Type         type;
+  enum XML_Content_Quant        quant;
+  XML_Char *                    name;
+  unsigned int                  numchildren;
+  XML_Content *                 children;
+};
+
+
+/* This is called for an element declaration. See above for
+   description of the model argument. It's the caller's responsibility
+   to free model when finished with it.
+*/
+typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
+                                                const XML_Char *name,
+                                                XML_Content *model);
+
+XMLPARSEAPI(void)
+XML_SetElementDeclHandler(XML_Parser parser,
+                          XML_ElementDeclHandler eldecl);
+
+/* The Attlist declaration handler is called for *each* attribute. So
+   a single Attlist declaration with multiple attributes declared will
+   generate multiple calls to this handler. The "default" parameter
+   may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
+   keyword. The "isrequired" parameter will be true and the default
+   value will be NULL in the case of "#REQUIRED". If "isrequired" is
+   true and default is non-NULL, then this is a "#FIXED" default.
+*/
+typedef void (XMLCALL *XML_AttlistDeclHandler) (
+                                    void            *userData,
+                                    const XML_Char  *elname,
+                                    const XML_Char  *attname,
+                                    const XML_Char  *att_type,
+                                    const XML_Char  *dflt,
+                                    int              isrequired);
+
+XMLPARSEAPI(void)
+XML_SetAttlistDeclHandler(XML_Parser parser,
+                          XML_AttlistDeclHandler attdecl);
+
+/* The XML declaration handler is called for *both* XML declarations
+   and text declarations. The way to distinguish is that the version
+   parameter will be NULL for text declarations. The encoding
+   parameter may be NULL for XML declarations. The standalone
+   parameter will be -1, 0, or 1 indicating respectively that there
+   was no standalone parameter in the declaration, that it was given
+   as no, or that it was given as yes.
+*/
+typedef void (XMLCALL *XML_XmlDeclHandler) (void           *userData,
+                                            const XML_Char *version,
+                                            const XML_Char *encoding,
+                                            int             standalone);
+
+XMLPARSEAPI(void)
+XML_SetXmlDeclHandler(XML_Parser parser,
+                      XML_XmlDeclHandler xmldecl);
+
+
+typedef struct {
+  void *(*malloc_fcn)(size_t size);
+  void *(*realloc_fcn)(void *ptr, size_t size);
+  void (*free_fcn)(void *ptr);
+} XML_Memory_Handling_Suite;
+
+/* Constructs a new parser; encoding is the encoding specified by the
+   external protocol or NULL if there is none specified.
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ParserCreate(const XML_Char *encoding);
+
+/* Constructs a new parser and namespace processor.  Element type
+   names and attribute names that belong to a namespace will be
+   expanded; unprefixed attribute names are never expanded; unprefixed
+   element type names are expanded only if there is a default
+   namespace. The expanded name is the concatenation of the namespace
+   URI, the namespace separator character, and the local part of the
+   name.  If the namespace separator is '\0' then the namespace URI
+   and the local part will be concatenated without any separator.
+   It is a programming error to use the separator '\0' with namespace
+   triplets (see XML_SetReturnNSTriplet).
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
+
+
+/* Constructs a new parser using the memory management suite referred to
+   by memsuite. If memsuite is NULL, then use the standard library memory
+   suite. If namespaceSeparator is non-NULL it creates a parser with
+   namespace processing as described above. The character pointed at
+   will serve as the namespace separator.
+
+   All further memory operations used for the created parser will come from
+   the given suite.
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ParserCreate_MM(const XML_Char *encoding,
+                    const XML_Memory_Handling_Suite *memsuite,
+                    const XML_Char *namespaceSeparator);
+
+/* Prepare a parser object to be re-used.  This is particularly
+   valuable when memory allocation overhead is disproportionatly high,
+   such as when a large number of small documnents need to be parsed.
+   All handlers are cleared from the parser, except for the
+   unknownEncodingHandler. The parser's external state is re-initialized
+   except for the values of ns and ns_triplets.
+
+   Added in Expat 1.95.3.
+*/
+XMLPARSEAPI(XML_Bool)
+XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
+
+/* atts is array of name/value pairs, terminated by 0;
+   names and values are 0 terminated.
+*/
+typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
+                                                 const XML_Char *name,
+                                                 const XML_Char **atts);
+
+typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
+                                               const XML_Char *name);
+
+
+/* s is not 0 terminated. */
+typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
+                                                  const XML_Char *s,
+                                                  int len);
+
+/* target and data are 0 terminated */
+typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
+                                                void *userData,
+                                                const XML_Char *target,
+                                                const XML_Char *data);
+
+/* data is 0 terminated */
+typedef void (XMLCALL *XML_CommentHandler) (void *userData,
+                                            const XML_Char *data);
+
+typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
+typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
+
+/* This is called for any characters in the XML document for which
+   there is no applicable handler.  This includes both characters that
+   are part of markup which is of a kind that is not reported
+   (comments, markup declarations), or characters that are part of a
+   construct which could be reported but for which no handler has been
+   supplied. The characters are passed exactly as they were in the XML
+   document except that they will be encoded in UTF-8 or UTF-16.
+   Line boundaries are not normalized. Note that a byte order mark
+   character is not passed to the default handler. There are no
+   guarantees about how characters are divided between calls to the
+   default handler: for example, a comment might be split between
+   multiple calls.
+*/
+typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
+                                            const XML_Char *s,
+                                            int len);
+
+/* This is called for the start of the DOCTYPE declaration, before
+   any DTD or internal subset is parsed.
+*/
+typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
+                                            void *userData,
+                                            const XML_Char *doctypeName,
+                                            const XML_Char *sysid,
+                                            const XML_Char *pubid,
+                                            int has_internal_subset);
+
+/* This is called for the start of the DOCTYPE declaration when the
+   closing > is encountered, but after processing any external
+   subset.
+*/
+typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
+
+/* This is called for entity declarations. The is_parameter_entity
+   argument will be non-zero if the entity is a parameter entity, zero
+   otherwise.
+
+   For internal entities (<!ENTITY foo "bar">), value will
+   be non-NULL and systemId, publicID, and notationName will be NULL.
+   The value string is NOT nul-terminated; the length is provided in
+   the value_length argument. Since it is legal to have zero-length
+   values, do not use this argument to test for internal entities.
+
+   For external entities, value will be NULL and systemId will be
+   non-NULL. The publicId argument will be NULL unless a public
+   identifier was provided. The notationName argument will have a
+   non-NULL value only for unparsed entity declarations.
+
+   Note that is_parameter_entity can't be changed to XML_Bool, since
+   that would break binary compatibility.
+*/
+typedef void (XMLCALL *XML_EntityDeclHandler) (
+                              void *userData,
+                              const XML_Char *entityName,
+                              int is_parameter_entity,
+                              const XML_Char *value,
+                              int value_length,
+                              const XML_Char *base,
+                              const XML_Char *systemId,
+                              const XML_Char *publicId,
+                              const XML_Char *notationName);
+
+XMLPARSEAPI(void)
+XML_SetEntityDeclHandler(XML_Parser parser,
+                         XML_EntityDeclHandler handler);
+
+/* OBSOLETE -- OBSOLETE -- OBSOLETE
+   This handler has been superceded by the EntityDeclHandler above.
+   It is provided here for backward compatibility.
+
+   This is called for a declaration of an unparsed (NDATA) entity.
+   The base argument is whatever was set by XML_SetBase. The
+   entityName, systemId and notationName arguments will never be
+   NULL. The other arguments may be.
+*/
+typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *entityName,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId,
+                                    const XML_Char *notationName);
+
+/* This is called for a declaration of notation.  The base argument is
+   whatever was set by XML_SetBase. The notationName will never be
+   NULL.  The other arguments can be.
+*/
+typedef void (XMLCALL *XML_NotationDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *notationName,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId);
+
+/* When namespace processing is enabled, these are called once for
+   each namespace declaration. The call to the start and end element
+   handlers occur between the calls to the start and end namespace
+   declaration handlers. For an xmlns attribute, prefix will be
+   NULL.  For an xmlns="" attribute, uri will be NULL.
+*/
+typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *prefix,
+                                    const XML_Char *uri);
+
+typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *prefix);
+
+/* This is called if the document is not standalone, that is, it has an
+   external subset or a reference to a parameter entity, but does not
+   have standalone="yes". If this handler returns XML_STATUS_ERROR,
+   then processing will not continue, and the parser will return a
+   XML_ERROR_NOT_STANDALONE error.
+   If parameter entity parsing is enabled, then in addition to the
+   conditions above this handler will only be called if the referenced
+   entity was actually read.
+*/
+typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
+
+/* This is called for a reference to an external parsed general
+   entity.  The referenced entity is not automatically parsed.  The
+   application can parse it immediately or later using
+   XML_ExternalEntityParserCreate.
+
+   The parser argument is the parser parsing the entity containing the
+   reference; it can be passed as the parser argument to
+   XML_ExternalEntityParserCreate.  The systemId argument is the
+   system identifier as specified in the entity declaration; it will
+   not be NULL.
+
+   The base argument is the system identifier that should be used as
+   the base for resolving systemId if systemId was relative; this is
+   set by XML_SetBase; it may be NULL.
+
+   The publicId argument is the public identifier as specified in the
+   entity declaration, or NULL if none was specified; the whitespace
+   in the public identifier will have been normalized as required by
+   the XML spec.
+
+   The context argument specifies the parsing context in the format
+   expected by the context argument to XML_ExternalEntityParserCreate;
+   context is valid only until the handler returns, so if the
+   referenced entity is to be parsed later, it must be copied.
+   context is NULL only when the entity is a parameter entity.
+
+   The handler should return XML_STATUS_ERROR if processing should not
+   continue because of a fatal error in the handling of the external
+   entity.  In this case the calling parser will return an
+   XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
+
+   Note that unlike other handlers the first argument is the parser,
+   not userData.
+*/
+typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
+                                    XML_Parser parser,
+                                    const XML_Char *context,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId);
+
+/* This is called in two situations:
+   1) An entity reference is encountered for which no declaration
+      has been read *and* this is not an error.
+   2) An internal entity reference is read, but not expanded, because
+      XML_SetDefaultHandler has been called.
+   Note: skipped parameter entities in declarations and skipped general
+         entities in attribute values cannot be reported, because
+         the event would be out of sync with the reporting of the
+         declarations or attribute values
+*/
+typedef void (XMLCALL *XML_SkippedEntityHandler) (
+                                    void *userData,
+                                    const XML_Char *entityName,
+                                    int is_parameter_entity);
+
+/* This structure is filled in by the XML_UnknownEncodingHandler to
+   provide information to the parser about encodings that are unknown
+   to the parser.
+
+   The map[b] member gives information about byte sequences whose
+   first byte is b.
+
+   If map[b] is c where c is >= 0, then b by itself encodes the
+   Unicode scalar value c.
+
+   If map[b] is -1, then the byte sequence is malformed.
+
+   If map[b] is -n, where n >= 2, then b is the first byte of an
+   n-byte sequence that encodes a single Unicode scalar value.
+
+   The data member will be passed as the first argument to the convert
+   function.
+
+   The convert function is used to convert multibyte sequences; s will
+   point to a n-byte sequence where map[(unsigned char)*s] == -n.  The
+   convert function must return the Unicode scalar value represented
+   by this byte sequence or -1 if the byte sequence is malformed.
+
+   The convert function may be NULL if the encoding is a single-byte
+   encoding, that is if map[b] >= -1 for all bytes b.
+
+   When the parser is finished with the encoding, then if release is
+   not NULL, it will call release passing it the data member; once
+   release has been called, the convert function will not be called
+   again.
+
+   Expat places certain restrictions on the encodings that are supported
+   using this mechanism.
+
+   1. Every ASCII character that can appear in a well-formed XML document,
+      other than the characters
+
+      $@\^`{}~
+
+      must be represented by a single byte, and that byte must be the
+      same byte that represents that character in ASCII.
+
+   2. No character may require more than 4 bytes to encode.
+
+   3. All characters encoded must have Unicode scalar values <=
+      0xFFFF, (i.e., characters that would be encoded by surrogates in
+      UTF-16 are  not allowed).  Note that this restriction doesn't
+      apply to the built-in support for UTF-8 and UTF-16.
+
+   4. No Unicode character may be encoded by more than one distinct
+      sequence of bytes.
+*/
+typedef struct {
+  int map[256];
+  void *data;
+  int (XMLCALL *convert)(void *data, const char *s);
+  void (XMLCALL *release)(void *data);
+} XML_Encoding;
+
+/* This is called for an encoding that is unknown to the parser.
+
+   The encodingHandlerData argument is that which was passed as the
+   second argument to XML_SetUnknownEncodingHandler.
+
+   The name argument gives the name of the encoding as specified in
+   the encoding declaration.
+
+   If the callback can provide information about the encoding, it must
+   fill in the XML_Encoding structure, and return XML_STATUS_OK.
+   Otherwise it must return XML_STATUS_ERROR.
+
+   If info does not describe a suitable encoding, then the parser will
+   return an XML_UNKNOWN_ENCODING error.
+*/
+typedef int (XMLCALL *XML_UnknownEncodingHandler) (
+                                    void *encodingHandlerData,
+                                    const XML_Char *name,
+                                    XML_Encoding *info);
+
+XMLPARSEAPI(void)
+XML_SetElementHandler(XML_Parser parser,
+                      XML_StartElementHandler start,
+                      XML_EndElementHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartElementHandler(XML_Parser parser,
+                           XML_StartElementHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetEndElementHandler(XML_Parser parser,
+                         XML_EndElementHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetCharacterDataHandler(XML_Parser parser,
+                            XML_CharacterDataHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetProcessingInstructionHandler(XML_Parser parser,
+                                    XML_ProcessingInstructionHandler handler);
+XMLPARSEAPI(void)
+XML_SetCommentHandler(XML_Parser parser,
+                      XML_CommentHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetCdataSectionHandler(XML_Parser parser,
+                           XML_StartCdataSectionHandler start,
+                           XML_EndCdataSectionHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartCdataSectionHandler(XML_Parser parser,
+                                XML_StartCdataSectionHandler start);
+
+XMLPARSEAPI(void)
+XML_SetEndCdataSectionHandler(XML_Parser parser,
+                              XML_EndCdataSectionHandler end);
+
+/* This sets the default handler and also inhibits expansion of
+   internal entities. These entity references will be passed to the
+   default handler, or to the skipped entity handler, if one is set.
+*/
+XMLPARSEAPI(void)
+XML_SetDefaultHandler(XML_Parser parser,
+                      XML_DefaultHandler handler);
+
+/* This sets the default handler but does not inhibit expansion of
+   internal entities.  The entity reference will not be passed to the
+   default handler.
+*/
+XMLPARSEAPI(void)
+XML_SetDefaultHandlerExpand(XML_Parser parser,
+                            XML_DefaultHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetDoctypeDeclHandler(XML_Parser parser,
+                          XML_StartDoctypeDeclHandler start,
+                          XML_EndDoctypeDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartDoctypeDeclHandler(XML_Parser parser,
+                               XML_StartDoctypeDeclHandler start);
+
+XMLPARSEAPI(void)
+XML_SetEndDoctypeDeclHandler(XML_Parser parser,
+                             XML_EndDoctypeDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
+                                 XML_UnparsedEntityDeclHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetNotationDeclHandler(XML_Parser parser,
+                           XML_NotationDeclHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetNamespaceDeclHandler(XML_Parser parser,
+                            XML_StartNamespaceDeclHandler start,
+                            XML_EndNamespaceDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetStartNamespaceDeclHandler(XML_Parser parser,
+                                 XML_StartNamespaceDeclHandler start);
+
+XMLPARSEAPI(void)
+XML_SetEndNamespaceDeclHandler(XML_Parser parser,
+                               XML_EndNamespaceDeclHandler end);
+
+XMLPARSEAPI(void)
+XML_SetNotStandaloneHandler(XML_Parser parser,
+                            XML_NotStandaloneHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetExternalEntityRefHandler(XML_Parser parser,
+                                XML_ExternalEntityRefHandler handler);
+
+/* If a non-NULL value for arg is specified here, then it will be
+   passed as the first argument to the external entity ref handler
+   instead of the parser object.
+*/
+XMLPARSEAPI(void)
+XML_SetExternalEntityRefHandlerArg(XML_Parser parser,
+                                   void *arg);
+
+XMLPARSEAPI(void)
+XML_SetSkippedEntityHandler(XML_Parser parser,
+                            XML_SkippedEntityHandler handler);
+
+XMLPARSEAPI(void)
+XML_SetUnknownEncodingHandler(XML_Parser parser,
+                              XML_UnknownEncodingHandler handler,
+                              void *encodingHandlerData);
+
+/* This can be called within a handler for a start element, end
+   element, processing instruction or character data.  It causes the
+   corresponding markup to be passed to the default handler.
+*/
+XMLPARSEAPI(void)
+XML_DefaultCurrent(XML_Parser parser);
+
+/* If do_nst is non-zero, and namespace processing is in effect, and
+   a name has a prefix (i.e. an explicit namespace qualifier) then
+   that name is returned as a triplet in a single string separated by
+   the separator character specified when the parser was created: URI
+   + sep + local_name + sep + prefix.
+
+   If do_nst is zero, then namespace information is returned in the
+   default manner (URI + sep + local_name) whether or not the name
+   has a prefix.
+
+   Note: Calling XML_SetReturnNSTriplet after XML_Parse or
+     XML_ParseBuffer has no effect.
+*/
+
+XMLPARSEAPI(void)
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
+
+/* This value is passed as the userData argument to callbacks. */
+XMLPARSEAPI(void)
+XML_SetUserData(XML_Parser parser, void *userData);
+
+/* Returns the last value set by XML_SetUserData or NULL. */
+#define XML_GetUserData(parser) (*(void **)(parser))
+
+/* This is equivalent to supplying an encoding argument to
+   XML_ParserCreate. On success XML_SetEncoding returns non-zero,
+   zero otherwise.
+   Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
+     has no effect and returns XML_STATUS_ERROR.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
+
+/* If this function is called, then the parser will be passed as the
+   first argument to callbacks instead of userData.  The userData will
+   still be accessible using XML_GetUserData.
+*/
+XMLPARSEAPI(void)
+XML_UseParserAsHandlerArg(XML_Parser parser);
+
+/* If useDTD == XML_TRUE is passed to this function, then the parser
+   will assume that there is an external subset, even if none is
+   specified in the document. In such a case the parser will call the
+   externalEntityRefHandler with a value of NULL for the systemId
+   argument (the publicId and context arguments will be NULL as well).
+   Note: For the purpose of checking WFC: Entity Declared, passing
+     useDTD == XML_TRUE will make the parser behave as if the document
+     had a DTD with an external subset.
+   Note: If this function is called, then this must be done before
+     the first call to XML_Parse or XML_ParseBuffer, since it will
+     have no effect after that.  Returns
+     XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
+   Note: If the document does not have a DOCTYPE declaration at all,
+     then startDoctypeDeclHandler and endDoctypeDeclHandler will not
+     be called, despite an external subset being parsed.
+   Note: If XML_DTD is not defined when Expat is compiled, returns
+     XML_ERROR_FEATURE_REQUIRES_XML_DTD.
+*/
+XMLPARSEAPI(enum XML_Error)
+XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
+
+
+/* Sets the base to be used for resolving relative URIs in system
+   identifiers in declarations.  Resolving relative identifiers is
+   left to the application: this value will be passed through as the
+   base argument to the XML_ExternalEntityRefHandler,
+   XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
+   argument will be copied.  Returns XML_STATUS_ERROR if out of memory,
+   XML_STATUS_OK otherwise.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_SetBase(XML_Parser parser, const XML_Char *base);
+
+XMLPARSEAPI(const XML_Char *)
+XML_GetBase(XML_Parser parser);
+
+/* Returns the number of the attribute/value pairs passed in last call
+   to the XML_StartElementHandler that were specified in the start-tag
+   rather than defaulted. Each attribute/value pair counts as 2; thus
+   this correspondds to an index into the atts array passed to the
+   XML_StartElementHandler.
+*/
+XMLPARSEAPI(int)
+XML_GetSpecifiedAttributeCount(XML_Parser parser);
+
+/* Returns the index of the ID attribute passed in the last call to
+   XML_StartElementHandler, or -1 if there is no ID attribute.  Each
+   attribute/value pair counts as 2; thus this correspondds to an
+   index into the atts array passed to the XML_StartElementHandler.
+*/
+XMLPARSEAPI(int)
+XML_GetIdAttributeIndex(XML_Parser parser);
+
+#ifdef XML_ATTR_INFO
+/* Source file byte offsets for the start and end of attribute names and values.
+   The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
+   file an attribute value of "blah" will yield:
+   info->valueEnd - info->valueStart = 4 bytes.
+*/
+typedef struct {
+  XML_Index  nameStart;  /* Offset to beginning of the attribute name. */
+  XML_Index  nameEnd;    /* Offset after the attribute name's last byte. */
+  XML_Index  valueStart; /* Offset to beginning of the attribute value. */
+  XML_Index  valueEnd;   /* Offset after the attribute value's last byte. */
+} XML_AttrInfo;
+
+/* Returns an array of XML_AttrInfo structures for the attribute/value pairs
+   passed in last call to the XML_StartElementHandler that were specified
+   in the start-tag rather than defaulted. Each attribute/value pair counts
+   as 1; thus the number of entries in the array is
+   XML_GetSpecifiedAttributeCount(parser) / 2.
+*/
+XMLPARSEAPI(const XML_AttrInfo *)
+XML_GetAttributeInfo(XML_Parser parser);
+#endif
+
+/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
+   detected.  The last call to XML_Parse must have isFinal true; len
+   may be zero for this call (or any other).
+
+   Though the return values for these functions has always been
+   described as a Boolean value, the implementation, at least for the
+   1.95.x series, has always returned exactly one of the XML_Status
+   values.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
+
+XMLPARSEAPI(void *)
+XML_GetBuffer(XML_Parser parser, int len);
+
+XMLPARSEAPI(enum XML_Status)
+XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
+
+/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
+   Must be called from within a call-back handler, except when aborting
+   (resumable = 0) an already suspended parser. Some call-backs may
+   still follow because they would otherwise get lost. Examples:
+   - endElementHandler() for empty elements when stopped in
+     startElementHandler(), 
+   - endNameSpaceDeclHandler() when stopped in endElementHandler(), 
+   and possibly others.
+
+   Can be called from most handlers, including DTD related call-backs,
+   except when parsing an external parameter entity and resumable != 0.
+   Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
+   Possible error codes: 
+   - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
+   - XML_ERROR_FINISHED: when the parser has already finished.
+   - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
+
+   When resumable != 0 (true) then parsing is suspended, that is, 
+   XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 
+   Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
+   return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
+
+   *Note*:
+   This will be applied to the current parser instance only, that is, if
+   there is a parent parser then it will continue parsing when the
+   externalEntityRefHandler() returns. It is up to the implementation of
+   the externalEntityRefHandler() to call XML_StopParser() on the parent
+   parser (recursively), if one wants to stop parsing altogether.
+
+   When suspended, parsing can be resumed by calling XML_ResumeParser(). 
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_StopParser(XML_Parser parser, XML_Bool resumable);
+
+/* Resumes parsing after it has been suspended with XML_StopParser().
+   Must not be called from within a handler call-back. Returns same
+   status codes as XML_Parse() or XML_ParseBuffer().
+   Additional error code XML_ERROR_NOT_SUSPENDED possible.   
+
+   *Note*:
+   This must be called on the most deeply nested child parser instance
+   first, and on its parent parser only after the child parser has finished,
+   to be applied recursively until the document entity's parser is restarted.
+   That is, the parent parser will not resume by itself and it is up to the
+   application to call XML_ResumeParser() on it at the appropriate moment.
+*/
+XMLPARSEAPI(enum XML_Status)
+XML_ResumeParser(XML_Parser parser);
+
+enum XML_Parsing {
+  XML_INITIALIZED,
+  XML_PARSING,
+  XML_FINISHED,
+  XML_SUSPENDED
+};
+
+typedef struct {
+  enum XML_Parsing parsing;
+  XML_Bool finalBuffer;
+} XML_ParsingStatus;
+
+/* Returns status of parser with respect to being initialized, parsing,
+   finished, or suspended and processing the final buffer.
+   XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
+   XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
+*/
+XMLPARSEAPI(void)
+XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
+
+/* Creates an XML_Parser object that can parse an external general
+   entity; context is a '\0'-terminated string specifying the parse
+   context; encoding is a '\0'-terminated string giving the name of
+   the externally specified encoding, or NULL if there is no
+   externally specified encoding.  The context string consists of a
+   sequence of tokens separated by formfeeds (\f); a token consisting
+   of a name specifies that the general entity of the name is open; a
+   token of the form prefix=uri specifies the namespace for a
+   particular prefix; a token of the form =uri specifies the default
+   namespace.  This can be called at any point after the first call to
+   an ExternalEntityRefHandler so longer as the parser has not yet
+   been freed.  The new parser is completely independent and may
+   safely be used in a separate thread.  The handlers and userData are
+   initialized from the parser argument.  Returns NULL if out of memory.
+   Otherwise returns a new XML_Parser object.
+*/
+XMLPARSEAPI(XML_Parser)
+XML_ExternalEntityParserCreate(XML_Parser parser,
+                               const XML_Char *context,
+                               const XML_Char *encoding);
+
+enum XML_ParamEntityParsing {
+  XML_PARAM_ENTITY_PARSING_NEVER,
+  XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
+  XML_PARAM_ENTITY_PARSING_ALWAYS
+};
+
+/* Controls parsing of parameter entities (including the external DTD
+   subset). If parsing of parameter entities is enabled, then
+   references to external parameter entities (including the external
+   DTD subset) will be passed to the handler set with
+   XML_SetExternalEntityRefHandler.  The context passed will be 0.
+
+   Unlike external general entities, external parameter entities can
+   only be parsed synchronously.  If the external parameter entity is
+   to be parsed, it must be parsed during the call to the external
+   entity ref handler: the complete sequence of
+   XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
+   XML_ParserFree calls must be made during this call.  After
+   XML_ExternalEntityParserCreate has been called to create the parser
+   for the external parameter entity (context must be 0 for this
+   call), it is illegal to make any calls on the old parser until
+   XML_ParserFree has been called on the newly created parser.
+   If the library has been compiled without support for parameter
+   entity parsing (ie without XML_DTD being defined), then
+   XML_SetParamEntityParsing will return 0 if parsing of parameter
+   entities is requested; otherwise it will return non-zero.
+   Note: If XML_SetParamEntityParsing is called after XML_Parse or
+      XML_ParseBuffer, then it has no effect and will always return 0.
+*/
+XMLPARSEAPI(int)
+XML_SetParamEntityParsing(XML_Parser parser,
+                          enum XML_ParamEntityParsing parsing);
+
+/* Sets the hash salt to use for internal hash calculations.
+   Helps in preventing DoS attacks based on predicting hash
+   function behavior. This must be called before parsing is started.
+   Returns 1 if successful, 0 when called after parsing has started.
+*/
+XMLPARSEAPI(int)
+XML_SetHashSalt(XML_Parser parser,
+                unsigned long hash_salt);
+
+/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
+   XML_GetErrorCode returns information about the error.
+*/
+XMLPARSEAPI(enum XML_Error)
+XML_GetErrorCode(XML_Parser parser);
+
+/* These functions return information about the current parse
+   location.  They may be called from any callback called to report
+   some parse event; in this case the location is the location of the
+   first of the sequence of characters that generated the event.  When
+   called from callbacks generated by declarations in the document
+   prologue, the location identified isn't as neatly defined, but will
+   be within the relevant markup.  When called outside of the callback
+   functions, the position indicated will be just past the last parse
+   event (regardless of whether there was an associated callback).
+   
+   They may also be called after returning from a call to XML_Parse
+   or XML_ParseBuffer.  If the return value is XML_STATUS_ERROR then
+   the location is the location of the character at which the error
+   was detected; otherwise the location is the location of the last
+   parse event, as described above.
+*/
+XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
+XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
+XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
+
+/* Return the number of bytes in the current event.
+   Returns 0 if the event is in an internal entity.
+*/
+XMLPARSEAPI(int)
+XML_GetCurrentByteCount(XML_Parser parser);
+
+/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
+   the integer pointed to by offset to the offset within this buffer
+   of the current parse position, and sets the integer pointed to by size
+   to the size of this buffer (the number of input bytes). Otherwise
+   returns a NULL pointer. Also returns a NULL pointer if a parse isn't
+   active.
+
+   NOTE: The character pointer returned should not be used outside
+   the handler that makes the call.
+*/
+XMLPARSEAPI(const char *)
+XML_GetInputContext(XML_Parser parser,
+                    int *offset,
+                    int *size);
+
+/* For backwards compatibility with previous versions. */
+#define XML_GetErrorLineNumber   XML_GetCurrentLineNumber
+#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
+#define XML_GetErrorByteIndex    XML_GetCurrentByteIndex
+
+/* Frees the content model passed to the element declaration handler */
+XMLPARSEAPI(void)
+XML_FreeContentModel(XML_Parser parser, XML_Content *model);
+
+/* Exposing the memory handling functions used in Expat */
+XMLPARSEAPI(void *)
+XML_ATTR_MALLOC
+XML_ATTR_ALLOC_SIZE(2)
+XML_MemMalloc(XML_Parser parser, size_t size);
+
+XMLPARSEAPI(void *)
+XML_ATTR_ALLOC_SIZE(3)
+XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
+
+XMLPARSEAPI(void)
+XML_MemFree(XML_Parser parser, void *ptr);
+
+/* Frees memory used by the parser. */
+XMLPARSEAPI(void)
+XML_ParserFree(XML_Parser parser);
+
+/* Returns a string describing the error. */
+XMLPARSEAPI(const XML_LChar *)
+XML_ErrorString(enum XML_Error code);
+
+/* Return a string containing the version number of this expat */
+XMLPARSEAPI(const XML_LChar *)
+XML_ExpatVersion(void);
+
+typedef struct {
+  int major;
+  int minor;
+  int micro;
+} XML_Expat_Version;
+
+/* Return an XML_Expat_Version structure containing numeric version
+   number information for this version of expat.
+*/
+XMLPARSEAPI(XML_Expat_Version)
+XML_ExpatVersionInfo(void);
+
+/* Added in Expat 1.95.5. */
+enum XML_FeatureEnum {
+  XML_FEATURE_END = 0,
+  XML_FEATURE_UNICODE,
+  XML_FEATURE_UNICODE_WCHAR_T,
+  XML_FEATURE_DTD,
+  XML_FEATURE_CONTEXT_BYTES,
+  XML_FEATURE_MIN_SIZE,
+  XML_FEATURE_SIZEOF_XML_CHAR,
+  XML_FEATURE_SIZEOF_XML_LCHAR,
+  XML_FEATURE_NS,
+  XML_FEATURE_LARGE_SIZE,
+  XML_FEATURE_ATTR_INFO
+  /* Additional features must be added to the end of this enum. */
+};
+
+typedef struct {
+  enum XML_FeatureEnum  feature;
+  const XML_LChar       *name;
+  long int              value;
+} XML_Feature;
+
+XMLPARSEAPI(const XML_Feature *)
+XML_GetFeatureList(void);
+
+
+/* Expat follows the GNU/Linux convention of odd number minor version for
+   beta/development releases and even number minor version for stable
+   releases. Micro is bumped with each release, and set to 0 with each
+   change to major or minor version.
+*/
+#define XML_MAJOR_VERSION 2
+#define XML_MINOR_VERSION 1
+#define XML_MICRO_VERSION 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* not Expat_INCLUDED */
diff --git a/Utilities/cmexpat/lib/expat_external.h b/Utilities/cmexpat/lib/expat_external.h
new file mode 100644
index 0000000..07a3c5c
--- /dev/null
+++ b/Utilities/cmexpat/lib/expat_external.h
@@ -0,0 +1,131 @@
+/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#ifndef Expat_External_INCLUDED
+#define Expat_External_INCLUDED 1
+
+/* External API definitions */
+
+#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
+#define XML_USE_MSC_EXTENSIONS 1
+#endif
+
+/* Expat tries very hard to make the API boundary very specifically
+   defined.  There are two macros defined to control this boundary;
+   each of these can be defined before including this header to
+   achieve some different behavior, but doing so it not recommended or
+   tested frequently.
+
+   XMLCALL    - The calling convention to use for all calls across the
+                "library boundary."  This will default to cdecl, and
+                try really hard to tell the compiler that's what we
+                want.
+
+   XMLIMPORT  - Whatever magic is needed to note that a function is
+                to be imported from a dynamically loaded library
+                (.dll, .so, or .sl, depending on your platform).
+
+   The XMLCALL macro was added in Expat 1.95.7.  The only one which is
+   expected to be directly useful in client code is XMLCALL.
+
+   Note that on at least some Unix versions, the Expat library must be
+   compiled with the cdecl calling convention as the default since
+   system headers may assume the cdecl convention.
+*/
+#ifndef XMLCALL
+#if defined(_MSC_VER)
+#define XMLCALL __cdecl
+#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
+#define XMLCALL __attribute__((cdecl))
+#else
+/* For any platform which uses this definition and supports more than
+   one calling convention, we need to extend this definition to
+   declare the convention used on that platform, if it's possible to
+   do so.
+
+   If this is the case for your platform, please file a bug report
+   with information on how to identify your platform via the C
+   pre-processor and how to specify the same calling convention as the
+   platform's malloc() implementation.
+*/
+#define XMLCALL
+#endif
+#endif  /* not defined XMLCALL */
+
+/* Build within CMake hard-codes use of a static library.  */
+#define XML_STATIC
+
+#if !defined(XML_STATIC) && !defined(XMLIMPORT)
+#ifndef XML_BUILDING_EXPAT
+/* using Expat from an application */
+
+#ifdef XML_USE_MSC_EXTENSIONS
+#define XMLIMPORT __declspec(dllimport)
+#endif
+
+#endif
+#endif  /* not defined XML_STATIC */
+
+#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
+#define XMLIMPORT __attribute__ ((visibility ("default")))
+#endif
+
+/* If we didn't define it above, define it away: */
+#ifndef XMLIMPORT
+#define XMLIMPORT
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
+#define XML_ATTR_MALLOC __attribute__((__malloc__))
+#else
+#define XML_ATTR_MALLOC
+#endif
+
+#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+#define XML_ATTR_ALLOC_SIZE(x)  __attribute__((__alloc_size__(x)))
+#else
+#define XML_ATTR_ALLOC_SIZE(x)
+#endif
+
+#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef XML_UNICODE_WCHAR_T
+#define XML_UNICODE
+#endif
+
+#ifdef XML_UNICODE     /* Information is UTF-16 encoded. */
+#ifdef XML_UNICODE_WCHAR_T
+typedef wchar_t XML_Char;
+typedef wchar_t XML_LChar;
+#else
+typedef unsigned short XML_Char;
+typedef char XML_LChar;
+#endif /* XML_UNICODE_WCHAR_T */
+#else                  /* Information is UTF-8 encoded. */
+typedef char XML_Char;
+typedef char XML_LChar;
+#endif /* XML_UNICODE */
+
+#ifdef XML_LARGE_SIZE  /* Use large integers for file/stream positions. */
+#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
+typedef __int64 XML_Index; 
+typedef unsigned __int64 XML_Size;
+#else
+typedef long long XML_Index;
+typedef unsigned long long XML_Size;
+#endif
+#else
+typedef long XML_Index;
+typedef unsigned long XML_Size;
+#endif /* XML_LARGE_SIZE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* not Expat_External_INCLUDED */
diff --git a/Utilities/cmexpat/lib/iasciitab.h b/Utilities/cmexpat/lib/iasciitab.h
new file mode 100644
index 0000000..24a1d5c
--- /dev/null
+++ b/Utilities/cmexpat/lib/iasciitab.h
@@ -0,0 +1,37 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
+/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
+/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
+/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
+/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
+/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
+/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
+/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
+/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
+/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
+/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
+/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/Utilities/cmexpat/lib/internal.h b/Utilities/cmexpat/lib/internal.h
new file mode 100644
index 0000000..94cb98e
--- /dev/null
+++ b/Utilities/cmexpat/lib/internal.h
@@ -0,0 +1,95 @@
+/* internal.h
+
+   Internal definitions used by Expat.  This is not needed to compile
+   client code.
+
+   The following calling convention macros are defined for frequently
+   called functions:
+
+   FASTCALL    - Used for those internal functions that have a simple
+                 body and a low number of arguments and local variables.
+
+   PTRCALL     - Used for functions called though function pointers.
+
+   PTRFASTCALL - Like PTRCALL, but for low number of arguments.
+
+   inline      - Used for selected internal functions for which inlining
+                 may improve performance on some platforms.
+
+   Note: Use of these macros is based on judgement, not hard rules,
+         and therefore subject to change.
+*/
+
+#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
+/* We'll use this version by default only where we know it helps.
+
+   regparm() generates warnings on Solaris boxes.   See SF bug #692878.
+
+   Instability reported with egcs on a RedHat Linux 7.3.
+   Let's comment out:
+   #define FASTCALL __attribute__((stdcall, regparm(3)))
+   and let's try this:
+*/
+#define FASTCALL __attribute__((regparm(3)))
+#define PTRFASTCALL __attribute__((regparm(3)))
+#endif
+
+/* Using __fastcall seems to have an unexpected negative effect under
+   MS VC++, especially for function pointers, so we won't use it for
+   now on that platform. It may be reconsidered for a future release
+   if it can be made more effective.
+   Likely reason: __fastcall on Windows is like stdcall, therefore
+   the compiler cannot perform stack optimizations for call clusters.
+*/
+
+/* Make sure all of these are defined if they aren't already. */
+
+#ifndef FASTCALL
+#define FASTCALL
+#endif
+
+#ifndef PTRCALL
+#define PTRCALL
+#endif
+
+#ifndef PTRFASTCALL
+#define PTRFASTCALL
+#endif
+
+#ifndef XML_MIN_SIZE
+#if !defined(__cplusplus) && !defined(inline)
+#ifdef __GNUC__
+#define inline __inline
+#endif /* __GNUC__ */
+#endif
+#endif /* XML_MIN_SIZE */
+
+#ifdef __cplusplus
+#define inline inline
+#else
+#ifndef inline
+#define inline
+#endif
+#endif
+
+#ifndef UNUSED_P
+# ifdef __GNUC__
+#  define UNUSED_P(p) UNUSED_ ## p __attribute__((__unused__))
+# else
+#  define UNUSED_P(p) UNUSED_ ## p
+# endif
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void
+align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef);
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/Utilities/cmexpat/lib/latin1tab.h b/Utilities/cmexpat/lib/latin1tab.h
new file mode 100644
index 0000000..53c25d7
--- /dev/null
+++ b/Utilities/cmexpat/lib/latin1tab.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
+/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
+/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
+/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
diff --git a/Utilities/cmexpat/nametab.h b/Utilities/cmexpat/lib/nametab.h
similarity index 100%
rename from Utilities/cmexpat/nametab.h
rename to Utilities/cmexpat/lib/nametab.h
diff --git a/Utilities/cmexpat/lib/utf8tab.h b/Utilities/cmexpat/lib/utf8tab.h
new file mode 100644
index 0000000..7bb3e77
--- /dev/null
+++ b/Utilities/cmexpat/lib/utf8tab.h
@@ -0,0 +1,37 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+
+/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
+/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
diff --git a/Utilities/cmexpat/lib/winconfig.h b/Utilities/cmexpat/lib/winconfig.h
new file mode 100644
index 0000000..d7dad38
--- /dev/null
+++ b/Utilities/cmexpat/lib/winconfig.h
@@ -0,0 +1,27 @@
+/*================================================================
+** Copyright 2000, Clark Cooper
+** All rights reserved.
+**
+** This is free software. You are permitted to copy, distribute, or modify
+** it under the terms of the MIT/X license (contained in the COPYING file
+** with this distribution.)
+*/
+
+#ifndef WINCONFIG_H
+#define WINCONFIG_H
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+
+#include <memory.h>
+#include <string.h>
+
+#include "expat_config.h"
+
+#if defined(_MSC_VER)
+# pragma warning(push,1)
+# pragma warning(disable:4311)   /* pointer truncation */
+#endif
+
+#endif /* ndef WINCONFIG_H */
diff --git a/Utilities/cmexpat/lib/xmlparse.c b/Utilities/cmexpat/lib/xmlparse.c
new file mode 100644
index 0000000..b56b66a
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmlparse.c
@@ -0,0 +1,6466 @@
+/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#include <stddef.h>
+#include <string.h>                     /* memset(), memcpy() */
+#include <assert.h>
+#include <limits.h>                     /* UINT_MAX */
+
+#ifdef COMPILING_FOR_WINDOWS
+#define getpid GetCurrentProcessId
+#else
+#include <sys/time.h>                   /* gettimeofday() */
+#include <sys/types.h>                  /* getpid() */
+#include <unistd.h>                     /* getpid() */
+#endif
+
+#define XML_BUILDING_EXPAT 1
+
+#ifdef COMPILING_FOR_WINDOWS
+#include "winconfig.h"
+#elif defined(MACOS_CLASSIC)
+#include "macconfig.h"
+#elif defined(__amigaos__)
+#include "amigaconfig.h"
+#elif defined(__WATCOMC__)
+#include "watcomconfig.h"
+#elif defined(HAVE_EXPAT_CONFIG_H)
+#include <expat_config.h>
+#endif /* ndef COMPILING_FOR_WINDOWS */
+
+#include "ascii.h"
+#include "expat.h"
+
+#ifdef XML_UNICODE
+#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
+#define XmlConvert XmlUtf16Convert
+#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
+#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
+#define XmlEncode XmlUtf16Encode
+/* Using pointer subtraction to convert to integer type. */
+#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
+typedef unsigned short ICHAR;
+#else
+#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
+#define XmlConvert XmlUtf8Convert
+#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
+#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
+#define XmlEncode XmlUtf8Encode
+#define MUST_CONVERT(enc, s) (!(enc)->isUtf8)
+typedef char ICHAR;
+#endif
+
+
+#ifndef XML_NS
+
+#define XmlInitEncodingNS XmlInitEncoding
+#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding
+#undef XmlGetInternalEncodingNS
+#define XmlGetInternalEncodingNS XmlGetInternalEncoding
+#define XmlParseXmlDeclNS XmlParseXmlDecl
+
+#endif
+
+#ifdef XML_UNICODE
+
+#ifdef XML_UNICODE_WCHAR_T
+#define XML_T(x) (const wchar_t)x
+#define XML_L(x) L ## x
+#else
+#define XML_T(x) (const unsigned short)x
+#define XML_L(x) x
+#endif
+
+#else
+
+#define XML_T(x) x
+#define XML_L(x) x
+
+#endif
+
+/* Round up n to be a multiple of sz, where sz is a power of 2. */
+#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
+
+/* Handle the case where memmove() doesn't exist. */
+#ifndef HAVE_MEMMOVE
+#ifdef HAVE_BCOPY
+#define memmove(d,s,l) bcopy((s),(d),(l))
+#else
+#error memmove does not exist on this platform, nor is a substitute available
+#endif /* HAVE_BCOPY */
+#endif /* HAVE_MEMMOVE */
+
+#include "internal.h"
+#include "xmltok.h"
+#include "xmlrole.h"
+
+typedef const XML_Char *KEY;
+
+typedef struct {
+  KEY name;
+} NAMED;
+
+typedef struct {
+  NAMED **v;
+  unsigned char power;
+  size_t size;
+  size_t used;
+  const XML_Memory_Handling_Suite *mem;
+} HASH_TABLE;
+
+/* Basic character hash algorithm, taken from Python's string hash:
+   h = h * 1000003 ^ character, the constant being a prime number.
+
+*/
+#ifdef XML_UNICODE
+#define CHAR_HASH(h, c) \
+  (((h) * 0xF4243) ^ (unsigned short)(c))
+#else
+#define CHAR_HASH(h, c) \
+  (((h) * 0xF4243) ^ (unsigned char)(c))
+#endif
+
+/* For probing (after a collision) we need a step size relative prime
+   to the hash table size, which is a power of 2. We use double-hashing,
+   since we can calculate a second hash value cheaply by taking those bits
+   of the first hash value that were discarded (masked out) when the table
+   index was calculated: index = hash & mask, where mask = table->size - 1.
+   We limit the maximum step size to table->size / 4 (mask >> 2) and make
+   it odd, since odd numbers are always relative prime to a power of 2.
+*/
+#define SECOND_HASH(hash, mask, power) \
+  ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2))
+#define PROBE_STEP(hash, mask, power) \
+  ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1))
+
+typedef struct {
+  NAMED **p;
+  NAMED **end;
+} HASH_TABLE_ITER;
+
+#define INIT_TAG_BUF_SIZE 32  /* must be a multiple of sizeof(XML_Char) */
+#define INIT_DATA_BUF_SIZE 1024
+#define INIT_ATTS_SIZE 16
+#define INIT_ATTS_VERSION 0xFFFFFFFF
+#define INIT_BLOCK_SIZE 1024
+#define INIT_BUFFER_SIZE 1024
+
+#define EXPAND_SPARE 24
+
+typedef struct binding {
+  struct prefix *prefix;
+  struct binding *nextTagBinding;
+  struct binding *prevPrefixBinding;
+  const struct attribute_id *attId;
+  XML_Char *uri;
+  int uriLen;
+  int uriAlloc;
+} BINDING;
+
+typedef struct prefix {
+  const XML_Char *name;
+  BINDING *binding;
+} PREFIX;
+
+typedef struct {
+  const XML_Char *str;
+  const XML_Char *localPart;
+  const XML_Char *prefix;
+  int strLen;
+  int uriLen;
+  int prefixLen;
+} TAG_NAME;
+
+/* TAG represents an open element.
+   The name of the element is stored in both the document and API
+   encodings.  The memory buffer 'buf' is a separately-allocated
+   memory area which stores the name.  During the XML_Parse()/
+   XMLParseBuffer() when the element is open, the memory for the 'raw'
+   version of the name (in the document encoding) is shared with the
+   document buffer.  If the element is open across calls to
+   XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to
+   contain the 'raw' name as well.
+
+   A parser re-uses these structures, maintaining a list of allocated
+   TAG objects in a free list.
+*/
+typedef struct tag {
+  struct tag *parent;           /* parent of this element */
+  const char *rawName;          /* tagName in the original encoding */
+  int rawNameLength;
+  TAG_NAME name;                /* tagName in the API encoding */
+  char *buf;                    /* buffer for name components */
+  char *bufEnd;                 /* end of the buffer */
+  BINDING *bindings;
+} TAG;
+
+typedef struct {
+  const XML_Char *name;
+  const XML_Char *textPtr;
+  int textLen;                  /* length in XML_Chars */
+  int processed;                /* # of processed bytes - when suspended */
+  const XML_Char *systemId;
+  const XML_Char *base;
+  const XML_Char *publicId;
+  const XML_Char *notation;
+  XML_Bool open;
+  XML_Bool is_param;
+  XML_Bool is_internal; /* true if declared in internal subset outside PE */
+} ENTITY;
+
+typedef struct {
+  enum XML_Content_Type         type;
+  enum XML_Content_Quant        quant;
+  const XML_Char *              name;
+  int                           firstchild;
+  int                           lastchild;
+  int                           childcnt;
+  int                           nextsib;
+} CONTENT_SCAFFOLD;
+
+#define INIT_SCAFFOLD_ELEMENTS 32
+
+typedef struct block {
+  struct block *next;
+  int size;
+  XML_Char s[1];
+} BLOCK;
+
+typedef struct {
+  BLOCK *blocks;
+  BLOCK *freeBlocks;
+  const XML_Char *end;
+  XML_Char *ptr;
+  XML_Char *start;
+  const XML_Memory_Handling_Suite *mem;
+} STRING_POOL;
+
+/* The XML_Char before the name is used to determine whether
+   an attribute has been specified. */
+typedef struct attribute_id {
+  XML_Char *name;
+  PREFIX *prefix;
+  XML_Bool maybeTokenized;
+  XML_Bool xmlns;
+} ATTRIBUTE_ID;
+
+typedef struct {
+  const ATTRIBUTE_ID *id;
+  XML_Bool isCdata;
+  const XML_Char *value;
+} DEFAULT_ATTRIBUTE;
+
+typedef struct {
+  unsigned long version;
+  unsigned long hash;
+  const XML_Char *uriName;
+} NS_ATT;
+
+typedef struct {
+  const XML_Char *name;
+  PREFIX *prefix;
+  const ATTRIBUTE_ID *idAtt;
+  int nDefaultAtts;
+  int allocDefaultAtts;
+  DEFAULT_ATTRIBUTE *defaultAtts;
+} ELEMENT_TYPE;
+
+typedef struct {
+  HASH_TABLE generalEntities;
+  HASH_TABLE elementTypes;
+  HASH_TABLE attributeIds;
+  HASH_TABLE prefixes;
+  STRING_POOL pool;
+  STRING_POOL entityValuePool;
+  /* false once a parameter entity reference has been skipped */
+  XML_Bool keepProcessing;
+  /* true once an internal or external PE reference has been encountered;
+     this includes the reference to an external subset */
+  XML_Bool hasParamEntityRefs;
+  XML_Bool standalone;
+#ifdef XML_DTD
+  /* indicates if external PE has been read */
+  XML_Bool paramEntityRead;
+  HASH_TABLE paramEntities;
+#endif /* XML_DTD */
+  PREFIX defaultPrefix;
+  /* === scaffolding for building content model === */
+  XML_Bool in_eldecl;
+  CONTENT_SCAFFOLD *scaffold;
+  unsigned contentStringLen;
+  unsigned scaffSize;
+  unsigned scaffCount;
+  int scaffLevel;
+  int *scaffIndex;
+} DTD;
+
+typedef struct open_internal_entity {
+  const char *internalEventPtr;
+  const char *internalEventEndPtr;
+  struct open_internal_entity *next;
+  ENTITY *entity;
+  int startTagLevel;
+  XML_Bool betweenDecl; /* WFC: PE Between Declarations */
+} OPEN_INTERNAL_ENTITY;
+
+typedef enum XML_Error PTRCALL Processor(XML_Parser parser,
+                                         const char *start,
+                                         const char *end,
+                                         const char **endPtr);
+
+static Processor prologProcessor;
+static Processor prologInitProcessor;
+static Processor contentProcessor;
+static Processor cdataSectionProcessor;
+#ifdef XML_DTD
+static Processor ignoreSectionProcessor;
+static Processor externalParEntProcessor;
+static Processor externalParEntInitProcessor;
+static Processor entityValueProcessor;
+static Processor entityValueInitProcessor;
+#endif /* XML_DTD */
+static Processor epilogProcessor;
+static Processor errorProcessor;
+static Processor externalEntityInitProcessor;
+static Processor externalEntityInitProcessor2;
+static Processor externalEntityInitProcessor3;
+static Processor externalEntityContentProcessor;
+static Processor internalEntityProcessor;
+
+static enum XML_Error
+handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName);
+static enum XML_Error
+processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
+               const char *s, const char *next);
+static enum XML_Error
+initializeEncoding(XML_Parser parser);
+static enum XML_Error
+doProlog(XML_Parser parser, const ENCODING *enc, const char *s,
+         const char *end, int tok, const char *next, const char **nextPtr,
+         XML_Bool haveMore);
+static enum XML_Error
+processInternalEntity(XML_Parser parser, ENTITY *entity,
+                      XML_Bool betweenDecl);
+static enum XML_Error
+doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
+          const char *start, const char *end, const char **endPtr,
+          XML_Bool haveMore);
+static enum XML_Error
+doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr,
+               const char *end, const char **nextPtr, XML_Bool haveMore);
+#ifdef XML_DTD
+static enum XML_Error
+doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr,
+                const char *end, const char **nextPtr, XML_Bool haveMore);
+#endif /* XML_DTD */
+
+static enum XML_Error
+storeAtts(XML_Parser parser, const ENCODING *, const char *s,
+          TAG_NAME *tagNamePtr, BINDING **bindingsPtr);
+static enum XML_Error
+addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
+           const XML_Char *uri, BINDING **bindingsPtr);
+static int
+defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata,
+                XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser);
+static enum XML_Error
+storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata,
+                    const char *, const char *, STRING_POOL *);
+static enum XML_Error
+appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata,
+                     const char *, const char *, STRING_POOL *);
+static ATTRIBUTE_ID *
+getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start,
+               const char *end);
+static int
+setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *);
+static enum XML_Error
+storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start,
+                 const char *end);
+static int
+reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
+                            const char *start, const char *end);
+static int
+reportComment(XML_Parser parser, const ENCODING *enc, const char *start,
+              const char *end);
+static void
+reportDefault(XML_Parser parser, const ENCODING *enc, const char *start,
+              const char *end);
+
+static const XML_Char * getContext(XML_Parser parser);
+static XML_Bool
+setContext(XML_Parser parser, const XML_Char *context);
+
+static void FASTCALL normalizePublicId(XML_Char *s);
+
+static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms);
+/* do not call if parentParser != NULL */
+static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms);
+static void
+dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms);
+static int
+dtdCopy(XML_Parser oldParser,
+        DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms);
+static int
+copyEntityTable(XML_Parser oldParser,
+                HASH_TABLE *, STRING_POOL *, const HASH_TABLE *);
+static NAMED *
+lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize);
+static void FASTCALL
+hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms);
+static void FASTCALL hashTableClear(HASH_TABLE *);
+static void FASTCALL hashTableDestroy(HASH_TABLE *);
+static void FASTCALL
+hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
+static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *);
+
+static void FASTCALL
+poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms);
+static void FASTCALL poolClear(STRING_POOL *);
+static void FASTCALL poolDestroy(STRING_POOL *);
+static XML_Char *
+poolAppend(STRING_POOL *pool, const ENCODING *enc,
+           const char *ptr, const char *end);
+static XML_Char *
+poolStoreString(STRING_POOL *pool, const ENCODING *enc,
+                const char *ptr, const char *end);
+static XML_Bool FASTCALL poolGrow(STRING_POOL *pool);
+static const XML_Char * FASTCALL
+poolCopyString(STRING_POOL *pool, const XML_Char *s);
+static const XML_Char *
+poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n);
+static const XML_Char * FASTCALL
+poolAppendString(STRING_POOL *pool, const XML_Char *s);
+
+static int FASTCALL nextScaffoldPart(XML_Parser parser);
+static XML_Content * build_model(XML_Parser parser);
+static ELEMENT_TYPE *
+getElementType(XML_Parser parser, const ENCODING *enc,
+               const char *ptr, const char *end);
+
+static unsigned long generate_hash_secret_salt(XML_Parser parser);
+static XML_Bool startParsing(XML_Parser parser);
+
+static XML_Parser
+parserCreate(const XML_Char *encodingName,
+             const XML_Memory_Handling_Suite *memsuite,
+             const XML_Char *nameSep,
+             DTD *dtd);
+
+static void
+parserInit(XML_Parser parser, const XML_Char *encodingName);
+
+#define poolStart(pool) ((pool)->start)
+#define poolEnd(pool) ((pool)->ptr)
+#define poolLength(pool) ((pool)->ptr - (pool)->start)
+#define poolChop(pool) ((void)--(pool->ptr))
+#define poolLastChar(pool) (((pool)->ptr)[-1])
+#define poolDiscard(pool) ((pool)->ptr = (pool)->start)
+#define poolFinish(pool) ((pool)->start = (pool)->ptr)
+#define poolAppendChar(pool, c) \
+  (((pool)->ptr == (pool)->end && !poolGrow(pool)) \
+   ? 0 \
+   : ((*((pool)->ptr)++ = c), 1))
+
+struct XML_ParserStruct {
+  /* The first member must be userData so that the XML_GetUserData
+     macro works. */
+  void *m_userData;
+  void *m_handlerArg;
+  char *m_buffer;
+  const XML_Memory_Handling_Suite m_mem;
+  /* first character to be parsed */
+  const char *m_bufferPtr;
+  /* past last character to be parsed */
+  char *m_bufferEnd;
+  /* allocated end of buffer */
+  const char *m_bufferLim;
+  XML_Index m_parseEndByteIndex;
+  const char *m_parseEndPtr;
+  XML_Char *m_dataBuf;
+  XML_Char *m_dataBufEnd;
+  XML_StartElementHandler m_startElementHandler;
+  XML_EndElementHandler m_endElementHandler;
+  XML_CharacterDataHandler m_characterDataHandler;
+  XML_ProcessingInstructionHandler m_processingInstructionHandler;
+  XML_CommentHandler m_commentHandler;
+  XML_StartCdataSectionHandler m_startCdataSectionHandler;
+  XML_EndCdataSectionHandler m_endCdataSectionHandler;
+  XML_DefaultHandler m_defaultHandler;
+  XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler;
+  XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler;
+  XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler;
+  XML_NotationDeclHandler m_notationDeclHandler;
+  XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler;
+  XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler;
+  XML_NotStandaloneHandler m_notStandaloneHandler;
+  XML_ExternalEntityRefHandler m_externalEntityRefHandler;
+  XML_Parser m_externalEntityRefHandlerArg;
+  XML_SkippedEntityHandler m_skippedEntityHandler;
+  XML_UnknownEncodingHandler m_unknownEncodingHandler;
+  XML_ElementDeclHandler m_elementDeclHandler;
+  XML_AttlistDeclHandler m_attlistDeclHandler;
+  XML_EntityDeclHandler m_entityDeclHandler;
+  XML_XmlDeclHandler m_xmlDeclHandler;
+  const ENCODING *m_encoding;
+  INIT_ENCODING m_initEncoding;
+  const ENCODING *m_internalEncoding;
+  const XML_Char *m_protocolEncodingName;
+  XML_Bool m_ns;
+  XML_Bool m_ns_triplets;
+  void *m_unknownEncodingMem;
+  void *m_unknownEncodingData;
+  void *m_unknownEncodingHandlerData;
+  void (XMLCALL *m_unknownEncodingRelease)(void *);
+  PROLOG_STATE m_prologState;
+  Processor *m_processor;
+  enum XML_Error m_errorCode;
+  const char *m_eventPtr;
+  const char *m_eventEndPtr;
+  const char *m_positionPtr;
+  OPEN_INTERNAL_ENTITY *m_openInternalEntities;
+  OPEN_INTERNAL_ENTITY *m_freeInternalEntities;
+  XML_Bool m_defaultExpandInternalEntities;
+  int m_tagLevel;
+  ENTITY *m_declEntity;
+  const XML_Char *m_doctypeName;
+  const XML_Char *m_doctypeSysid;
+  const XML_Char *m_doctypePubid;
+  const XML_Char *m_declAttributeType;
+  const XML_Char *m_declNotationName;
+  const XML_Char *m_declNotationPublicId;
+  ELEMENT_TYPE *m_declElementType;
+  ATTRIBUTE_ID *m_declAttributeId;
+  XML_Bool m_declAttributeIsCdata;
+  XML_Bool m_declAttributeIsId;
+  DTD *m_dtd;
+  const XML_Char *m_curBase;
+  TAG *m_tagStack;
+  TAG *m_freeTagList;
+  BINDING *m_inheritedBindings;
+  BINDING *m_freeBindingList;
+  int m_attsSize;
+  int m_nSpecifiedAtts;
+  int m_idAttIndex;
+  ATTRIBUTE *m_atts;
+  NS_ATT *m_nsAtts;
+  unsigned long m_nsAttsVersion;
+  unsigned char m_nsAttsPower;
+#ifdef XML_ATTR_INFO
+  XML_AttrInfo *m_attInfo;
+#endif
+  POSITION m_position;
+  STRING_POOL m_tempPool;
+  STRING_POOL m_temp2Pool;
+  char *m_groupConnector;
+  unsigned int m_groupSize;
+  XML_Char m_namespaceSeparator;
+  XML_Parser m_parentParser;
+  XML_ParsingStatus m_parsingStatus;
+#ifdef XML_DTD
+  XML_Bool m_isParamEntity;
+  XML_Bool m_useForeignDTD;
+  enum XML_ParamEntityParsing m_paramEntityParsing;
+#endif
+  unsigned long m_hash_secret_salt;
+};
+
+#define MALLOC(s) (parser->m_mem.malloc_fcn((s)))
+#define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s)))
+#define FREE(p) (parser->m_mem.free_fcn((p)))
+
+#define userData (parser->m_userData)
+#define handlerArg (parser->m_handlerArg)
+#define startElementHandler (parser->m_startElementHandler)
+#define endElementHandler (parser->m_endElementHandler)
+#define characterDataHandler (parser->m_characterDataHandler)
+#define processingInstructionHandler \
+        (parser->m_processingInstructionHandler)
+#define commentHandler (parser->m_commentHandler)
+#define startCdataSectionHandler \
+        (parser->m_startCdataSectionHandler)
+#define endCdataSectionHandler (parser->m_endCdataSectionHandler)
+#define defaultHandler (parser->m_defaultHandler)
+#define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler)
+#define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler)
+#define unparsedEntityDeclHandler \
+        (parser->m_unparsedEntityDeclHandler)
+#define notationDeclHandler (parser->m_notationDeclHandler)
+#define startNamespaceDeclHandler \
+        (parser->m_startNamespaceDeclHandler)
+#define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler)
+#define notStandaloneHandler (parser->m_notStandaloneHandler)
+#define externalEntityRefHandler \
+        (parser->m_externalEntityRefHandler)
+#define externalEntityRefHandlerArg \
+        (parser->m_externalEntityRefHandlerArg)
+#define internalEntityRefHandler \
+        (parser->m_internalEntityRefHandler)
+#define skippedEntityHandler (parser->m_skippedEntityHandler)
+#define unknownEncodingHandler (parser->m_unknownEncodingHandler)
+#define elementDeclHandler (parser->m_elementDeclHandler)
+#define attlistDeclHandler (parser->m_attlistDeclHandler)
+#define entityDeclHandler (parser->m_entityDeclHandler)
+#define xmlDeclHandler (parser->m_xmlDeclHandler)
+#define encoding (parser->m_encoding)
+#define initEncoding (parser->m_initEncoding)
+#define internalEncoding (parser->m_internalEncoding)
+#define unknownEncodingMem (parser->m_unknownEncodingMem)
+#define unknownEncodingData (parser->m_unknownEncodingData)
+#define unknownEncodingHandlerData \
+  (parser->m_unknownEncodingHandlerData)
+#define unknownEncodingRelease (parser->m_unknownEncodingRelease)
+#define protocolEncodingName (parser->m_protocolEncodingName)
+#define ns (parser->m_ns)
+#define ns_triplets (parser->m_ns_triplets)
+#define prologState (parser->m_prologState)
+#define processor (parser->m_processor)
+#define errorCode (parser->m_errorCode)
+#define eventPtr (parser->m_eventPtr)
+#define eventEndPtr (parser->m_eventEndPtr)
+#define positionPtr (parser->m_positionPtr)
+#define position (parser->m_position)
+#define openInternalEntities (parser->m_openInternalEntities)
+#define freeInternalEntities (parser->m_freeInternalEntities)
+#define defaultExpandInternalEntities \
+        (parser->m_defaultExpandInternalEntities)
+#define tagLevel (parser->m_tagLevel)
+#define buffer (parser->m_buffer)
+#define bufferPtr (parser->m_bufferPtr)
+#define bufferEnd (parser->m_bufferEnd)
+#define parseEndByteIndex (parser->m_parseEndByteIndex)
+#define parseEndPtr (parser->m_parseEndPtr)
+#define bufferLim (parser->m_bufferLim)
+#define dataBuf (parser->m_dataBuf)
+#define dataBufEnd (parser->m_dataBufEnd)
+#define _dtd (parser->m_dtd)
+#define curBase (parser->m_curBase)
+#define declEntity (parser->m_declEntity)
+#define doctypeName (parser->m_doctypeName)
+#define doctypeSysid (parser->m_doctypeSysid)
+#define doctypePubid (parser->m_doctypePubid)
+#define declAttributeType (parser->m_declAttributeType)
+#define declNotationName (parser->m_declNotationName)
+#define declNotationPublicId (parser->m_declNotationPublicId)
+#define declElementType (parser->m_declElementType)
+#define declAttributeId (parser->m_declAttributeId)
+#define declAttributeIsCdata (parser->m_declAttributeIsCdata)
+#define declAttributeIsId (parser->m_declAttributeIsId)
+#define freeTagList (parser->m_freeTagList)
+#define freeBindingList (parser->m_freeBindingList)
+#define inheritedBindings (parser->m_inheritedBindings)
+#define tagStack (parser->m_tagStack)
+#define atts (parser->m_atts)
+#define attsSize (parser->m_attsSize)
+#define nSpecifiedAtts (parser->m_nSpecifiedAtts)
+#define idAttIndex (parser->m_idAttIndex)
+#define nsAtts (parser->m_nsAtts)
+#define nsAttsVersion (parser->m_nsAttsVersion)
+#define nsAttsPower (parser->m_nsAttsPower)
+#define attInfo (parser->m_attInfo)
+#define tempPool (parser->m_tempPool)
+#define temp2Pool (parser->m_temp2Pool)
+#define groupConnector (parser->m_groupConnector)
+#define groupSize (parser->m_groupSize)
+#define namespaceSeparator (parser->m_namespaceSeparator)
+#define parentParser (parser->m_parentParser)
+#define ps_parsing (parser->m_parsingStatus.parsing)
+#define ps_finalBuffer (parser->m_parsingStatus.finalBuffer)
+#ifdef XML_DTD
+#define isParamEntity (parser->m_isParamEntity)
+#define useForeignDTD (parser->m_useForeignDTD)
+#define paramEntityParsing (parser->m_paramEntityParsing)
+#endif /* XML_DTD */
+#define hash_secret_salt (parser->m_hash_secret_salt)
+
+XML_Parser XMLCALL
+XML_ParserCreate(const XML_Char *encodingName)
+{
+  return XML_ParserCreate_MM(encodingName, NULL, NULL);
+}
+
+XML_Parser XMLCALL
+XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
+{
+  XML_Char tmp[2];
+  *tmp = nsSep;
+  return XML_ParserCreate_MM(encodingName, NULL, tmp);
+}
+
+static const XML_Char implicitContext[] = {
+  ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p,
+  ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w,
+  ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g,
+  ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9,
+  ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e,
+  ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0'
+};
+
+static unsigned long
+gather_time_entropy(void)
+{
+#ifdef COMPILING_FOR_WINDOWS
+  FILETIME ft;
+  GetSystemTimeAsFileTime(&ft); /* never fails */
+  return ft.dwHighDateTime ^ ft.dwLowDateTime;
+#else
+  struct timeval tv;
+  int gettimeofday_res;
+
+  gettimeofday_res = gettimeofday(&tv, NULL);
+  assert (gettimeofday_res == 0);
+
+  /* Microseconds time is <20 bits entropy */
+  return tv.tv_usec;
+#endif
+}
+
+static unsigned long
+generate_hash_secret_salt(XML_Parser parser)
+{
+  /* Process ID is 0 bits entropy if attacker has local access
+   * XML_Parser address is few bits of entropy if attacker has local access */
+  const unsigned long entropy =
+      gather_time_entropy() ^ getpid() ^ (unsigned long)parser;
+
+  /* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
+  if (sizeof(unsigned long) == 4) {
+    return entropy * 2147483647;
+  } else {
+    return entropy * 2305843009213693951;
+  }
+}
+
+static XML_Bool  /* only valid for root parser */
+startParsing(XML_Parser parser)
+{
+    /* hash functions must be initialized before setContext() is called */
+    if (hash_secret_salt == 0)
+      hash_secret_salt = generate_hash_secret_salt(parser);
+    if (ns) {
+      /* implicit context only set for root parser, since child
+         parsers (i.e. external entity parsers) will inherit it
+      */
+      return setContext(parser, implicitContext);
+    }
+    return XML_TRUE;
+}
+
+XML_Parser XMLCALL
+XML_ParserCreate_MM(const XML_Char *encodingName,
+                    const XML_Memory_Handling_Suite *memsuite,
+                    const XML_Char *nameSep)
+{
+  return parserCreate(encodingName, memsuite, nameSep, NULL);
+}
+
+static XML_Parser
+parserCreate(const XML_Char *encodingName,
+             const XML_Memory_Handling_Suite *memsuite,
+             const XML_Char *nameSep,
+             DTD *dtd)
+{
+  XML_Parser parser;
+
+  if (memsuite) {
+    XML_Memory_Handling_Suite *mtemp;
+    parser = (XML_Parser)
+      memsuite->malloc_fcn(sizeof(struct XML_ParserStruct));
+    if (parser != NULL) {
+      mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
+      mtemp->malloc_fcn = memsuite->malloc_fcn;
+      mtemp->realloc_fcn = memsuite->realloc_fcn;
+      mtemp->free_fcn = memsuite->free_fcn;
+    }
+  }
+  else {
+    XML_Memory_Handling_Suite *mtemp;
+    parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct));
+    if (parser != NULL) {
+      mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
+      mtemp->malloc_fcn = malloc;
+      mtemp->realloc_fcn = realloc;
+      mtemp->free_fcn = free;
+    }
+  }
+
+  if (!parser)
+    return parser;
+
+  buffer = NULL;
+  bufferLim = NULL;
+
+  attsSize = INIT_ATTS_SIZE;
+  atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE));
+  if (atts == NULL) {
+    FREE(parser);
+    return NULL;
+  }
+#ifdef XML_ATTR_INFO
+  attInfo = (XML_AttrInfo*)MALLOC(attsSize * sizeof(XML_AttrInfo));
+  if (attInfo == NULL) {
+    FREE(atts);
+    FREE(parser);
+    return NULL;
+  }
+#endif
+  dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char));
+  if (dataBuf == NULL) {
+    FREE(atts);
+#ifdef XML_ATTR_INFO
+    FREE(attInfo);
+#endif
+    FREE(parser);
+    return NULL;
+  }
+  dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
+
+  if (dtd)
+    _dtd = dtd;
+  else {
+    _dtd = dtdCreate(&parser->m_mem);
+    if (_dtd == NULL) {
+      FREE(dataBuf);
+      FREE(atts);
+#ifdef XML_ATTR_INFO
+      FREE(attInfo);
+#endif
+      FREE(parser);
+      return NULL;
+    }
+  }
+
+  freeBindingList = NULL;
+  freeTagList = NULL;
+  freeInternalEntities = NULL;
+
+  groupSize = 0;
+  groupConnector = NULL;
+
+  unknownEncodingHandler = NULL;
+  unknownEncodingHandlerData = NULL;
+
+  namespaceSeparator = ASCII_EXCL;
+  ns = XML_FALSE;
+  ns_triplets = XML_FALSE;
+
+  nsAtts = NULL;
+  nsAttsVersion = 0;
+  nsAttsPower = 0;
+
+  poolInit(&tempPool, &(parser->m_mem));
+  poolInit(&temp2Pool, &(parser->m_mem));
+  parserInit(parser, encodingName);
+
+  if (encodingName && !protocolEncodingName) {
+    XML_ParserFree(parser);
+    return NULL;
+  }
+
+  if (nameSep) {
+    ns = XML_TRUE;
+    internalEncoding = XmlGetInternalEncodingNS();
+    namespaceSeparator = *nameSep;
+  }
+  else {
+    internalEncoding = XmlGetInternalEncoding();
+  }
+
+  return parser;
+}
+
+static void
+parserInit(XML_Parser parser, const XML_Char *encodingName)
+{
+  processor = prologInitProcessor;
+  XmlPrologStateInit(&prologState);
+  protocolEncodingName = (encodingName != NULL
+                          ? poolCopyString(&tempPool, encodingName)
+                          : NULL);
+  curBase = NULL;
+  XmlInitEncoding(&initEncoding, &encoding, 0);
+  userData = NULL;
+  handlerArg = NULL;
+  startElementHandler = NULL;
+  endElementHandler = NULL;
+  characterDataHandler = NULL;
+  processingInstructionHandler = NULL;
+  commentHandler = NULL;
+  startCdataSectionHandler = NULL;
+  endCdataSectionHandler = NULL;
+  defaultHandler = NULL;
+  startDoctypeDeclHandler = NULL;
+  endDoctypeDeclHandler = NULL;
+  unparsedEntityDeclHandler = NULL;
+  notationDeclHandler = NULL;
+  startNamespaceDeclHandler = NULL;
+  endNamespaceDeclHandler = NULL;
+  notStandaloneHandler = NULL;
+  externalEntityRefHandler = NULL;
+  externalEntityRefHandlerArg = parser;
+  skippedEntityHandler = NULL;
+  elementDeclHandler = NULL;
+  attlistDeclHandler = NULL;
+  entityDeclHandler = NULL;
+  xmlDeclHandler = NULL;
+  bufferPtr = buffer;
+  bufferEnd = buffer;
+  parseEndByteIndex = 0;
+  parseEndPtr = NULL;
+  declElementType = NULL;
+  declAttributeId = NULL;
+  declEntity = NULL;
+  doctypeName = NULL;
+  doctypeSysid = NULL;
+  doctypePubid = NULL;
+  declAttributeType = NULL;
+  declNotationName = NULL;
+  declNotationPublicId = NULL;
+  declAttributeIsCdata = XML_FALSE;
+  declAttributeIsId = XML_FALSE;
+  memset(&position, 0, sizeof(POSITION));
+  errorCode = XML_ERROR_NONE;
+  eventPtr = NULL;
+  eventEndPtr = NULL;
+  positionPtr = NULL;
+  openInternalEntities = NULL;
+  defaultExpandInternalEntities = XML_TRUE;
+  tagLevel = 0;
+  tagStack = NULL;
+  inheritedBindings = NULL;
+  nSpecifiedAtts = 0;
+  unknownEncodingMem = NULL;
+  unknownEncodingRelease = NULL;
+  unknownEncodingData = NULL;
+  parentParser = NULL;
+  ps_parsing = XML_INITIALIZED;
+#ifdef XML_DTD
+  isParamEntity = XML_FALSE;
+  useForeignDTD = XML_FALSE;
+  paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
+#endif
+  hash_secret_salt = 0;
+}
+
+/* moves list of bindings to freeBindingList */
+static void FASTCALL
+moveToFreeBindingList(XML_Parser parser, BINDING *bindings)
+{
+  while (bindings) {
+    BINDING *b = bindings;
+    bindings = bindings->nextTagBinding;
+    b->nextTagBinding = freeBindingList;
+    freeBindingList = b;
+  }
+}
+
+XML_Bool XMLCALL
+XML_ParserReset(XML_Parser parser, const XML_Char *encodingName)
+{
+  TAG *tStk;
+  OPEN_INTERNAL_ENTITY *openEntityList;
+  if (parentParser)
+    return XML_FALSE;
+  /* move tagStack to freeTagList */
+  tStk = tagStack;
+  while (tStk) {
+    TAG *tag = tStk;
+    tStk = tStk->parent;
+    tag->parent = freeTagList;
+    moveToFreeBindingList(parser, tag->bindings);
+    tag->bindings = NULL;
+    freeTagList = tag;
+  }
+  /* move openInternalEntities to freeInternalEntities */
+  openEntityList = openInternalEntities;
+  while (openEntityList) {
+    OPEN_INTERNAL_ENTITY *openEntity = openEntityList;
+    openEntityList = openEntity->next;
+    openEntity->next = freeInternalEntities;
+    freeInternalEntities = openEntity;
+  }
+  moveToFreeBindingList(parser, inheritedBindings);
+  FREE(unknownEncodingMem);
+  if (unknownEncodingRelease)
+    unknownEncodingRelease(unknownEncodingData);
+  poolClear(&tempPool);
+  poolClear(&temp2Pool);
+  parserInit(parser, encodingName);
+  dtdReset(_dtd, &parser->m_mem);
+  return XML_TRUE;
+}
+
+enum XML_Status XMLCALL
+XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName)
+{
+  /* Block after XML_Parse()/XML_ParseBuffer() has been called.
+     XXX There's no way for the caller to determine which of the
+     XXX possible error cases caused the XML_STATUS_ERROR return.
+  */
+  if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+    return XML_STATUS_ERROR;
+  if (encodingName == NULL)
+    protocolEncodingName = NULL;
+  else {
+    protocolEncodingName = poolCopyString(&tempPool, encodingName);
+    if (!protocolEncodingName)
+      return XML_STATUS_ERROR;
+  }
+  return XML_STATUS_OK;
+}
+
+XML_Parser XMLCALL
+XML_ExternalEntityParserCreate(XML_Parser oldParser,
+                               const XML_Char *context,
+                               const XML_Char *encodingName)
+{
+  XML_Parser parser = oldParser;
+  DTD *newDtd = NULL;
+  DTD *oldDtd = _dtd;
+  XML_StartElementHandler oldStartElementHandler = startElementHandler;
+  XML_EndElementHandler oldEndElementHandler = endElementHandler;
+  XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler;
+  XML_ProcessingInstructionHandler oldProcessingInstructionHandler
+      = processingInstructionHandler;
+  XML_CommentHandler oldCommentHandler = commentHandler;
+  XML_StartCdataSectionHandler oldStartCdataSectionHandler
+      = startCdataSectionHandler;
+  XML_EndCdataSectionHandler oldEndCdataSectionHandler
+      = endCdataSectionHandler;
+  XML_DefaultHandler oldDefaultHandler = defaultHandler;
+  XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler
+      = unparsedEntityDeclHandler;
+  XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler;
+  XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler
+      = startNamespaceDeclHandler;
+  XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler
+      = endNamespaceDeclHandler;
+  XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler;
+  XML_ExternalEntityRefHandler oldExternalEntityRefHandler
+      = externalEntityRefHandler;
+  XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler;
+  XML_UnknownEncodingHandler oldUnknownEncodingHandler
+      = unknownEncodingHandler;
+  XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler;
+  XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler;
+  XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler;
+  XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler;
+  ELEMENT_TYPE * oldDeclElementType = declElementType;
+
+  void *oldUserData = userData;
+  void *oldHandlerArg = handlerArg;
+  XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities;
+  XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg;
+#ifdef XML_DTD
+  enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing;
+  int oldInEntityValue = prologState.inEntityValue;
+#endif
+  XML_Bool oldns_triplets = ns_triplets;
+  /* Note that the new parser shares the same hash secret as the old
+     parser, so that dtdCopy and copyEntityTable can lookup values
+     from hash tables associated with either parser without us having
+     to worry which hash secrets each table has.
+  */
+  unsigned long oldhash_secret_salt = hash_secret_salt;
+
+#ifdef XML_DTD
+  if (!context)
+    newDtd = oldDtd;
+#endif /* XML_DTD */
+
+  /* Note that the magical uses of the pre-processor to make field
+     access look more like C++ require that `parser' be overwritten
+     here.  This makes this function more painful to follow than it
+     would be otherwise.
+  */
+  if (ns) {
+    XML_Char tmp[2];
+    *tmp = namespaceSeparator;
+    parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
+  }
+  else {
+    parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd);
+  }
+
+  if (!parser)
+    return NULL;
+
+  startElementHandler = oldStartElementHandler;
+  endElementHandler = oldEndElementHandler;
+  characterDataHandler = oldCharacterDataHandler;
+  processingInstructionHandler = oldProcessingInstructionHandler;
+  commentHandler = oldCommentHandler;
+  startCdataSectionHandler = oldStartCdataSectionHandler;
+  endCdataSectionHandler = oldEndCdataSectionHandler;
+  defaultHandler = oldDefaultHandler;
+  unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler;
+  notationDeclHandler = oldNotationDeclHandler;
+  startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
+  endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
+  notStandaloneHandler = oldNotStandaloneHandler;
+  externalEntityRefHandler = oldExternalEntityRefHandler;
+  skippedEntityHandler = oldSkippedEntityHandler;
+  unknownEncodingHandler = oldUnknownEncodingHandler;
+  elementDeclHandler = oldElementDeclHandler;
+  attlistDeclHandler = oldAttlistDeclHandler;
+  entityDeclHandler = oldEntityDeclHandler;
+  xmlDeclHandler = oldXmlDeclHandler;
+  declElementType = oldDeclElementType;
+  userData = oldUserData;
+  if (oldUserData == oldHandlerArg)
+    handlerArg = userData;
+  else
+    handlerArg = parser;
+  if (oldExternalEntityRefHandlerArg != oldParser)
+    externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
+  defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
+  ns_triplets = oldns_triplets;
+  hash_secret_salt = oldhash_secret_salt;
+  parentParser = oldParser;
+#ifdef XML_DTD
+  paramEntityParsing = oldParamEntityParsing;
+  prologState.inEntityValue = oldInEntityValue;
+  if (context) {
+#endif /* XML_DTD */
+    if (!dtdCopy(oldParser, _dtd, oldDtd, &parser->m_mem)
+      || !setContext(parser, context)) {
+      XML_ParserFree(parser);
+      return NULL;
+    }
+    processor = externalEntityInitProcessor;
+#ifdef XML_DTD
+  }
+  else {
+    /* The DTD instance referenced by _dtd is shared between the document's
+       root parser and external PE parsers, therefore one does not need to
+       call setContext. In addition, one also *must* not call setContext,
+       because this would overwrite existing prefix->binding pointers in
+       _dtd with ones that get destroyed with the external PE parser.
+       This would leave those prefixes with dangling pointers.
+    */
+    isParamEntity = XML_TRUE;
+    XmlPrologStateInitExternalEntity(&prologState);
+    processor = externalParEntInitProcessor;
+  }
+#endif /* XML_DTD */
+  return parser;
+}
+
+static void FASTCALL
+destroyBindings(BINDING *bindings, XML_Parser parser)
+{
+  for (;;) {
+    BINDING *b = bindings;
+    if (!b)
+      break;
+    bindings = b->nextTagBinding;
+    FREE(b->uri);
+    FREE(b);
+  }
+}
+
+void XMLCALL
+XML_ParserFree(XML_Parser parser)
+{
+  TAG *tagList;
+  OPEN_INTERNAL_ENTITY *entityList;
+  if (parser == NULL)
+    return;
+  /* free tagStack and freeTagList */
+  tagList = tagStack;
+  for (;;) {
+    TAG *p;
+    if (tagList == NULL) {
+      if (freeTagList == NULL)
+        break;
+      tagList = freeTagList;
+      freeTagList = NULL;
+    }
+    p = tagList;
+    tagList = tagList->parent;
+    FREE(p->buf);
+    destroyBindings(p->bindings, parser);
+    FREE(p);
+  }
+  /* free openInternalEntities and freeInternalEntities */
+  entityList = openInternalEntities;
+  for (;;) {
+    OPEN_INTERNAL_ENTITY *openEntity;
+    if (entityList == NULL) {
+      if (freeInternalEntities == NULL)
+        break;
+      entityList = freeInternalEntities;
+      freeInternalEntities = NULL;
+    }
+    openEntity = entityList;
+    entityList = entityList->next;
+    FREE(openEntity);
+  }
+
+  destroyBindings(freeBindingList, parser);
+  destroyBindings(inheritedBindings, parser);
+  poolDestroy(&tempPool);
+  poolDestroy(&temp2Pool);
+#ifdef XML_DTD
+  /* external parameter entity parsers share the DTD structure
+     parser->m_dtd with the root parser, so we must not destroy it
+  */
+  if (!isParamEntity && _dtd)
+#else
+  if (_dtd)
+#endif /* XML_DTD */
+    dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem);
+  FREE((void *)atts);
+#ifdef XML_ATTR_INFO
+  FREE((void *)attInfo);
+#endif
+  FREE(groupConnector);
+  FREE(buffer);
+  FREE(dataBuf);
+  FREE(nsAtts);
+  FREE(unknownEncodingMem);
+  if (unknownEncodingRelease)
+    unknownEncodingRelease(unknownEncodingData);
+  FREE(parser);
+}
+
+void XMLCALL
+XML_UseParserAsHandlerArg(XML_Parser parser)
+{
+  handlerArg = parser;
+}
+
+enum XML_Error XMLCALL
+XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
+{
+#ifdef XML_DTD
+  /* block after XML_Parse()/XML_ParseBuffer() has been called */
+  if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+    return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING;
+  useForeignDTD = useDTD;
+  return XML_ERROR_NONE;
+#else
+  return XML_ERROR_FEATURE_REQUIRES_XML_DTD;
+#endif
+}
+
+void XMLCALL
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst)
+{
+  /* block after XML_Parse()/XML_ParseBuffer() has been called */
+  if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+    return;
+  ns_triplets = do_nst ? XML_TRUE : XML_FALSE;
+}
+
+void XMLCALL
+XML_SetUserData(XML_Parser parser, void *p)
+{
+  if (handlerArg == userData)
+    handlerArg = userData = p;
+  else
+    userData = p;
+}
+
+enum XML_Status XMLCALL
+XML_SetBase(XML_Parser parser, const XML_Char *p)
+{
+  if (p) {
+    p = poolCopyString(&_dtd->pool, p);
+    if (!p)
+      return XML_STATUS_ERROR;
+    curBase = p;
+  }
+  else
+    curBase = NULL;
+  return XML_STATUS_OK;
+}
+
+const XML_Char * XMLCALL
+XML_GetBase(XML_Parser parser)
+{
+  return curBase;
+}
+
+int XMLCALL
+XML_GetSpecifiedAttributeCount(XML_Parser parser)
+{
+  return nSpecifiedAtts;
+}
+
+int XMLCALL
+XML_GetIdAttributeIndex(XML_Parser parser)
+{
+  return idAttIndex;
+}
+
+#ifdef XML_ATTR_INFO
+const XML_AttrInfo * XMLCALL
+XML_GetAttributeInfo(XML_Parser parser)
+{
+  return attInfo;
+}
+#endif
+
+void XMLCALL
+XML_SetElementHandler(XML_Parser parser,
+                      XML_StartElementHandler start,
+                      XML_EndElementHandler end)
+{
+  startElementHandler = start;
+  endElementHandler = end;
+}
+
+void XMLCALL
+XML_SetStartElementHandler(XML_Parser parser,
+                           XML_StartElementHandler start) {
+  startElementHandler = start;
+}
+
+void XMLCALL
+XML_SetEndElementHandler(XML_Parser parser,
+                         XML_EndElementHandler end) {
+  endElementHandler = end;
+}
+
+void XMLCALL
+XML_SetCharacterDataHandler(XML_Parser parser,
+                            XML_CharacterDataHandler handler)
+{
+  characterDataHandler = handler;
+}
+
+void XMLCALL
+XML_SetProcessingInstructionHandler(XML_Parser parser,
+                                    XML_ProcessingInstructionHandler handler)
+{
+  processingInstructionHandler = handler;
+}
+
+void XMLCALL
+XML_SetCommentHandler(XML_Parser parser,
+                      XML_CommentHandler handler)
+{
+  commentHandler = handler;
+}
+
+void XMLCALL
+XML_SetCdataSectionHandler(XML_Parser parser,
+                           XML_StartCdataSectionHandler start,
+                           XML_EndCdataSectionHandler end)
+{
+  startCdataSectionHandler = start;
+  endCdataSectionHandler = end;
+}
+
+void XMLCALL
+XML_SetStartCdataSectionHandler(XML_Parser parser,
+                                XML_StartCdataSectionHandler start) {
+  startCdataSectionHandler = start;
+}
+
+void XMLCALL
+XML_SetEndCdataSectionHandler(XML_Parser parser,
+                              XML_EndCdataSectionHandler end) {
+  endCdataSectionHandler = end;
+}
+
+void XMLCALL
+XML_SetDefaultHandler(XML_Parser parser,
+                      XML_DefaultHandler handler)
+{
+  defaultHandler = handler;
+  defaultExpandInternalEntities = XML_FALSE;
+}
+
+void XMLCALL
+XML_SetDefaultHandlerExpand(XML_Parser parser,
+                            XML_DefaultHandler handler)
+{
+  defaultHandler = handler;
+  defaultExpandInternalEntities = XML_TRUE;
+}
+
+void XMLCALL
+XML_SetDoctypeDeclHandler(XML_Parser parser,
+                          XML_StartDoctypeDeclHandler start,
+                          XML_EndDoctypeDeclHandler end)
+{
+  startDoctypeDeclHandler = start;
+  endDoctypeDeclHandler = end;
+}
+
+void XMLCALL
+XML_SetStartDoctypeDeclHandler(XML_Parser parser,
+                               XML_StartDoctypeDeclHandler start) {
+  startDoctypeDeclHandler = start;
+}
+
+void XMLCALL
+XML_SetEndDoctypeDeclHandler(XML_Parser parser,
+                             XML_EndDoctypeDeclHandler end) {
+  endDoctypeDeclHandler = end;
+}
+
+void XMLCALL
+XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
+                                 XML_UnparsedEntityDeclHandler handler)
+{
+  unparsedEntityDeclHandler = handler;
+}
+
+void XMLCALL
+XML_SetNotationDeclHandler(XML_Parser parser,
+                           XML_NotationDeclHandler handler)
+{
+  notationDeclHandler = handler;
+}
+
+void XMLCALL
+XML_SetNamespaceDeclHandler(XML_Parser parser,
+                            XML_StartNamespaceDeclHandler start,
+                            XML_EndNamespaceDeclHandler end)
+{
+  startNamespaceDeclHandler = start;
+  endNamespaceDeclHandler = end;
+}
+
+void XMLCALL
+XML_SetStartNamespaceDeclHandler(XML_Parser parser,
+                                 XML_StartNamespaceDeclHandler start) {
+  startNamespaceDeclHandler = start;
+}
+
+void XMLCALL
+XML_SetEndNamespaceDeclHandler(XML_Parser parser,
+                               XML_EndNamespaceDeclHandler end) {
+  endNamespaceDeclHandler = end;
+}
+
+void XMLCALL
+XML_SetNotStandaloneHandler(XML_Parser parser,
+                            XML_NotStandaloneHandler handler)
+{
+  notStandaloneHandler = handler;
+}
+
+void XMLCALL
+XML_SetExternalEntityRefHandler(XML_Parser parser,
+                                XML_ExternalEntityRefHandler handler)
+{
+  externalEntityRefHandler = handler;
+}
+
+void XMLCALL
+XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
+{
+  if (arg)
+    externalEntityRefHandlerArg = (XML_Parser)arg;
+  else
+    externalEntityRefHandlerArg = parser;
+}
+
+void XMLCALL
+XML_SetSkippedEntityHandler(XML_Parser parser,
+                            XML_SkippedEntityHandler handler)
+{
+  skippedEntityHandler = handler;
+}
+
+void XMLCALL
+XML_SetUnknownEncodingHandler(XML_Parser parser,
+                              XML_UnknownEncodingHandler handler,
+                              void *data)
+{
+  unknownEncodingHandler = handler;
+  unknownEncodingHandlerData = data;
+}
+
+void XMLCALL
+XML_SetElementDeclHandler(XML_Parser parser,
+                          XML_ElementDeclHandler eldecl)
+{
+  elementDeclHandler = eldecl;
+}
+
+void XMLCALL
+XML_SetAttlistDeclHandler(XML_Parser parser,
+                          XML_AttlistDeclHandler attdecl)
+{
+  attlistDeclHandler = attdecl;
+}
+
+void XMLCALL
+XML_SetEntityDeclHandler(XML_Parser parser,
+                         XML_EntityDeclHandler handler)
+{
+  entityDeclHandler = handler;
+}
+
+void XMLCALL
+XML_SetXmlDeclHandler(XML_Parser parser,
+                      XML_XmlDeclHandler handler) {
+  xmlDeclHandler = handler;
+}
+
+int XMLCALL
+XML_SetParamEntityParsing(XML_Parser parser,
+                          enum XML_ParamEntityParsing peParsing)
+{
+  /* block after XML_Parse()/XML_ParseBuffer() has been called */
+  if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+    return 0;
+#ifdef XML_DTD
+  paramEntityParsing = peParsing;
+  return 1;
+#else
+  return peParsing == XML_PARAM_ENTITY_PARSING_NEVER;
+#endif
+}
+
+int XMLCALL
+XML_SetHashSalt(XML_Parser parser,
+                unsigned long hash_salt)
+{
+  /* block after XML_Parse()/XML_ParseBuffer() has been called */
+  if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+    return 0;
+  hash_secret_salt = hash_salt;
+  return 1;
+}
+
+enum XML_Status XMLCALL
+XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
+{
+  switch (ps_parsing) {
+  case XML_SUSPENDED:
+    errorCode = XML_ERROR_SUSPENDED;
+    return XML_STATUS_ERROR;
+  case XML_FINISHED:
+    errorCode = XML_ERROR_FINISHED;
+    return XML_STATUS_ERROR;
+  case XML_INITIALIZED:
+    if (parentParser == NULL && !startParsing(parser)) {
+      errorCode = XML_ERROR_NO_MEMORY;
+      return XML_STATUS_ERROR;
+    }
+  default:
+    ps_parsing = XML_PARSING;
+  }
+
+  if (len == 0) {
+    ps_finalBuffer = (XML_Bool)isFinal;
+    if (!isFinal)
+      return XML_STATUS_OK;
+    positionPtr = bufferPtr;
+    parseEndPtr = bufferEnd;
+
+    /* If data are left over from last buffer, and we now know that these
+       data are the final chunk of input, then we have to check them again
+       to detect errors based on that fact.
+    */
+    errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr);
+
+    if (errorCode == XML_ERROR_NONE) {
+      switch (ps_parsing) {
+      case XML_SUSPENDED:
+        XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
+        positionPtr = bufferPtr;
+        return XML_STATUS_SUSPENDED;
+      case XML_INITIALIZED:
+      case XML_PARSING:
+        ps_parsing = XML_FINISHED;
+        /* fall through */
+      default:
+        return XML_STATUS_OK;
+      }
+    }
+    eventEndPtr = eventPtr;
+    processor = errorProcessor;
+    return XML_STATUS_ERROR;
+  }
+#ifndef XML_CONTEXT_BYTES
+  else if (bufferPtr == bufferEnd) {
+    const char *end;
+    int nLeftOver;
+    enum XML_Status result;
+    parseEndByteIndex += len;
+    positionPtr = s;
+    ps_finalBuffer = (XML_Bool)isFinal;
+
+    errorCode = processor(parser, s, parseEndPtr = s + len, &end);
+
+    if (errorCode != XML_ERROR_NONE) {
+      eventEndPtr = eventPtr;
+      processor = errorProcessor;
+      return XML_STATUS_ERROR;
+    }
+    else {
+      switch (ps_parsing) {
+      case XML_SUSPENDED:
+        result = XML_STATUS_SUSPENDED;
+        break;
+      case XML_INITIALIZED:
+      case XML_PARSING:
+        if (isFinal) {
+          ps_parsing = XML_FINISHED;
+          return XML_STATUS_OK;
+        }
+      /* fall through */
+      default:
+        result = XML_STATUS_OK;
+      }
+    }
+
+    XmlUpdatePosition(encoding, positionPtr, end, &position);
+    nLeftOver = s + len - end;
+    if (nLeftOver) {
+      if (buffer == NULL || nLeftOver > bufferLim - buffer) {
+        /* FIXME avoid integer overflow */
+        char *temp;
+        temp = (buffer == NULL
+                ? (char *)MALLOC(len * 2)
+                : (char *)REALLOC(buffer, len * 2));
+        if (temp == NULL) {
+          errorCode = XML_ERROR_NO_MEMORY;
+          eventPtr = eventEndPtr = NULL;
+          processor = errorProcessor;
+          return XML_STATUS_ERROR;
+        }
+        buffer = temp;
+        bufferLim = buffer + len * 2;
+      }
+      memcpy(buffer, end, nLeftOver);
+    }
+    bufferPtr = buffer;
+    bufferEnd = buffer + nLeftOver;
+    positionPtr = bufferPtr;
+    parseEndPtr = bufferEnd;
+    eventPtr = bufferPtr;
+    eventEndPtr = bufferPtr;
+    return result;
+  }
+#endif  /* not defined XML_CONTEXT_BYTES */
+  else {
+    void *buff = XML_GetBuffer(parser, len);
+    if (buff == NULL)
+      return XML_STATUS_ERROR;
+    else {
+      memcpy(buff, s, len);
+      return XML_ParseBuffer(parser, len, isFinal);
+    }
+  }
+}
+
+enum XML_Status XMLCALL
+XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
+{
+  const char *start;
+  enum XML_Status result = XML_STATUS_OK;
+
+  switch (ps_parsing) {
+  case XML_SUSPENDED:
+    errorCode = XML_ERROR_SUSPENDED;
+    return XML_STATUS_ERROR;
+  case XML_FINISHED:
+    errorCode = XML_ERROR_FINISHED;
+    return XML_STATUS_ERROR;
+  case XML_INITIALIZED:
+    if (parentParser == NULL && !startParsing(parser)) {
+      errorCode = XML_ERROR_NO_MEMORY;
+      return XML_STATUS_ERROR;
+    }
+  default:
+    ps_parsing = XML_PARSING;
+  }
+
+  start = bufferPtr;
+  positionPtr = start;
+  bufferEnd += len;
+  parseEndPtr = bufferEnd;
+  parseEndByteIndex += len;
+  ps_finalBuffer = (XML_Bool)isFinal;
+
+  errorCode = processor(parser, start, parseEndPtr, &bufferPtr);
+
+  if (errorCode != XML_ERROR_NONE) {
+    eventEndPtr = eventPtr;
+    processor = errorProcessor;
+    return XML_STATUS_ERROR;
+  }
+  else {
+    switch (ps_parsing) {
+    case XML_SUSPENDED:
+      result = XML_STATUS_SUSPENDED;
+      break;
+    case XML_INITIALIZED:
+    case XML_PARSING:
+      if (isFinal) {
+        ps_parsing = XML_FINISHED;
+        return result;
+      }
+    default: ;  /* should not happen */
+    }
+  }
+
+  XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
+  positionPtr = bufferPtr;
+  return result;
+}
+
+void * XMLCALL
+XML_GetBuffer(XML_Parser parser, int len)
+{
+  if (len < 0) {
+    errorCode = XML_ERROR_NO_MEMORY;
+    return NULL;
+  }
+  switch (ps_parsing) {
+  case XML_SUSPENDED:
+    errorCode = XML_ERROR_SUSPENDED;
+    return NULL;
+  case XML_FINISHED:
+    errorCode = XML_ERROR_FINISHED;
+    return NULL;
+  default: ;
+  }
+
+  if (len > bufferLim - bufferEnd) {
+#ifdef XML_CONTEXT_BYTES
+    int keep;
+#endif  /* defined XML_CONTEXT_BYTES */
+    /* Do not invoke signed arithmetic overflow: */
+    int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr));
+    if (neededSize < 0) {
+      errorCode = XML_ERROR_NO_MEMORY;
+      return NULL;
+    }
+#ifdef XML_CONTEXT_BYTES
+    keep = (int)(bufferPtr - buffer);
+    if (keep > XML_CONTEXT_BYTES)
+      keep = XML_CONTEXT_BYTES;
+    neededSize += keep;
+#endif  /* defined XML_CONTEXT_BYTES */
+    if (neededSize  <= bufferLim - buffer) {
+#ifdef XML_CONTEXT_BYTES
+      if (keep < bufferPtr - buffer) {
+        int offset = (int)(bufferPtr - buffer) - keep;
+        memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep);
+        bufferEnd -= offset;
+        bufferPtr -= offset;
+      }
+#else
+      memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
+      bufferEnd = buffer + (bufferEnd - bufferPtr);
+      bufferPtr = buffer;
+#endif  /* not defined XML_CONTEXT_BYTES */
+    }
+    else {
+      char *newBuf;
+      int bufferSize = (int)(bufferLim - bufferPtr);
+      if (bufferSize == 0)
+        bufferSize = INIT_BUFFER_SIZE;
+      do {
+        /* Do not invoke signed arithmetic overflow: */
+        bufferSize = (int) (2U * (unsigned) bufferSize);
+      } while (bufferSize < neededSize && bufferSize > 0);
+      if (bufferSize <= 0) {
+        errorCode = XML_ERROR_NO_MEMORY;
+        return NULL;
+      }
+      newBuf = (char *)MALLOC(bufferSize);
+      if (newBuf == 0) {
+        errorCode = XML_ERROR_NO_MEMORY;
+        return NULL;
+      }
+      bufferLim = newBuf + bufferSize;
+#ifdef XML_CONTEXT_BYTES
+      if (bufferPtr) {
+        int keep = (int)(bufferPtr - buffer);
+        if (keep > XML_CONTEXT_BYTES)
+          keep = XML_CONTEXT_BYTES;
+        memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep);
+        FREE(buffer);
+        buffer = newBuf;
+        bufferEnd = buffer + (bufferEnd - bufferPtr) + keep;
+        bufferPtr = buffer + keep;
+      }
+      else {
+        bufferEnd = newBuf + (bufferEnd - bufferPtr);
+        bufferPtr = buffer = newBuf;
+      }
+#else
+      if (bufferPtr) {
+        memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
+        FREE(buffer);
+      }
+      bufferEnd = newBuf + (bufferEnd - bufferPtr);
+      bufferPtr = buffer = newBuf;
+#endif  /* not defined XML_CONTEXT_BYTES */
+    }
+    eventPtr = eventEndPtr = NULL;
+    positionPtr = NULL;
+  }
+  return bufferEnd;
+}
+
+enum XML_Status XMLCALL
+XML_StopParser(XML_Parser parser, XML_Bool resumable)
+{
+  switch (ps_parsing) {
+  case XML_SUSPENDED:
+    if (resumable) {
+      errorCode = XML_ERROR_SUSPENDED;
+      return XML_STATUS_ERROR;
+    }
+    ps_parsing = XML_FINISHED;
+    break;
+  case XML_FINISHED:
+    errorCode = XML_ERROR_FINISHED;
+    return XML_STATUS_ERROR;
+  default:
+    if (resumable) {
+#ifdef XML_DTD
+      if (isParamEntity) {
+        errorCode = XML_ERROR_SUSPEND_PE;
+        return XML_STATUS_ERROR;
+      }
+#endif
+      ps_parsing = XML_SUSPENDED;
+    }
+    else
+      ps_parsing = XML_FINISHED;
+  }
+  return XML_STATUS_OK;
+}
+
+enum XML_Status XMLCALL
+XML_ResumeParser(XML_Parser parser)
+{
+  enum XML_Status result = XML_STATUS_OK;
+
+  if (ps_parsing != XML_SUSPENDED) {
+    errorCode = XML_ERROR_NOT_SUSPENDED;
+    return XML_STATUS_ERROR;
+  }
+  ps_parsing = XML_PARSING;
+
+  errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr);
+
+  if (errorCode != XML_ERROR_NONE) {
+    eventEndPtr = eventPtr;
+    processor = errorProcessor;
+    return XML_STATUS_ERROR;
+  }
+  else {
+    switch (ps_parsing) {
+    case XML_SUSPENDED:
+      result = XML_STATUS_SUSPENDED;
+      break;
+    case XML_INITIALIZED:
+    case XML_PARSING:
+      if (ps_finalBuffer) {
+        ps_parsing = XML_FINISHED;
+        return result;
+      }
+    default: ;
+    }
+  }
+
+  XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
+  positionPtr = bufferPtr;
+  return result;
+}
+
+void XMLCALL
+XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status)
+{
+  assert(status != NULL);
+  *status = parser->m_parsingStatus;
+}
+
+enum XML_Error XMLCALL
+XML_GetErrorCode(XML_Parser parser)
+{
+  return errorCode;
+}
+
+XML_Index XMLCALL
+XML_GetCurrentByteIndex(XML_Parser parser)
+{
+  if (eventPtr)
+    return parseEndByteIndex - (parseEndPtr - eventPtr);
+  return -1;
+}
+
+int XMLCALL
+XML_GetCurrentByteCount(XML_Parser parser)
+{
+  if (eventEndPtr && eventPtr)
+    return (int)(eventEndPtr - eventPtr);
+  return 0;
+}
+
+const char * XMLCALL
+XML_GetInputContext(XML_Parser parser, int *offset, int *size)
+{
+#ifdef XML_CONTEXT_BYTES
+  if (eventPtr && buffer) {
+    *offset = (int)(eventPtr - buffer);
+    *size   = (int)(bufferEnd - buffer);
+    return buffer;
+  }
+#endif /* defined XML_CONTEXT_BYTES */
+  return (char *) 0;
+}
+
+XML_Size XMLCALL
+XML_GetCurrentLineNumber(XML_Parser parser)
+{
+  if (eventPtr && eventPtr >= positionPtr) {
+    XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
+    positionPtr = eventPtr;
+  }
+  return position.lineNumber + 1;
+}
+
+XML_Size XMLCALL
+XML_GetCurrentColumnNumber(XML_Parser parser)
+{
+  if (eventPtr && eventPtr >= positionPtr) {
+    XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
+    positionPtr = eventPtr;
+  }
+  return position.columnNumber;
+}
+
+void XMLCALL
+XML_FreeContentModel(XML_Parser parser, XML_Content *model)
+{
+  FREE(model);
+}
+
+void * XMLCALL
+XML_MemMalloc(XML_Parser parser, size_t size)
+{
+  return MALLOC(size);
+}
+
+void * XMLCALL
+XML_MemRealloc(XML_Parser parser, void *ptr, size_t size)
+{
+  return REALLOC(ptr, size);
+}
+
+void XMLCALL
+XML_MemFree(XML_Parser parser, void *ptr)
+{
+  FREE(ptr);
+}
+
+void XMLCALL
+XML_DefaultCurrent(XML_Parser parser)
+{
+  if (defaultHandler) {
+    if (openInternalEntities)
+      reportDefault(parser,
+                    internalEncoding,
+                    openInternalEntities->internalEventPtr,
+                    openInternalEntities->internalEventEndPtr);
+    else
+      reportDefault(parser, encoding, eventPtr, eventEndPtr);
+  }
+}
+
+const XML_LChar * XMLCALL
+XML_ErrorString(enum XML_Error code)
+{
+  static const XML_LChar* const message[] = {
+    0,
+    XML_L("out of memory"),
+    XML_L("syntax error"),
+    XML_L("no element found"),
+    XML_L("not well-formed (invalid token)"),
+    XML_L("unclosed token"),
+    XML_L("partial character"),
+    XML_L("mismatched tag"),
+    XML_L("duplicate attribute"),
+    XML_L("junk after document element"),
+    XML_L("illegal parameter entity reference"),
+    XML_L("undefined entity"),
+    XML_L("recursive entity reference"),
+    XML_L("asynchronous entity"),
+    XML_L("reference to invalid character number"),
+    XML_L("reference to binary entity"),
+    XML_L("reference to external entity in attribute"),
+    XML_L("XML or text declaration not at start of entity"),
+    XML_L("unknown encoding"),
+    XML_L("encoding specified in XML declaration is incorrect"),
+    XML_L("unclosed CDATA section"),
+    XML_L("error in processing external entity reference"),
+    XML_L("document is not standalone"),
+    XML_L("unexpected parser state - please send a bug report"),
+    XML_L("entity declared in parameter entity"),
+    XML_L("requested feature requires XML_DTD support in Expat"),
+    XML_L("cannot change setting once parsing has begun"),
+    XML_L("unbound prefix"),
+    XML_L("must not undeclare prefix"),
+    XML_L("incomplete markup in parameter entity"),
+    XML_L("XML declaration not well-formed"),
+    XML_L("text declaration not well-formed"),
+    XML_L("illegal character(s) in public id"),
+    XML_L("parser suspended"),
+    XML_L("parser not suspended"),
+    XML_L("parsing aborted"),
+    XML_L("parsing finished"),
+    XML_L("cannot suspend in external parameter entity"),
+    XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"),
+    XML_L("reserved prefix (xmlns) must not be declared or undeclared"),
+    XML_L("prefix must not be bound to one of the reserved namespace names")
+  };
+  if (code > 0 && code < sizeof(message)/sizeof(message[0]))
+    return message[code];
+  return NULL;
+}
+
+const XML_LChar * XMLCALL
+XML_ExpatVersion(void) {
+
+  /* V1 is used to string-ize the version number. However, it would
+     string-ize the actual version macro *names* unless we get them
+     substituted before being passed to V1. CPP is defined to expand
+     a macro, then rescan for more expansions. Thus, we use V2 to expand
+     the version macros, then CPP will expand the resulting V1() macro
+     with the correct numerals. */
+  /* ### I'm assuming cpp is portable in this respect... */
+
+#define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c)
+#define V2(a,b,c) XML_L("expat_")V1(a,b,c)
+
+  return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION);
+
+#undef V1
+#undef V2
+}
+
+XML_Expat_Version XMLCALL
+XML_ExpatVersionInfo(void)
+{
+  XML_Expat_Version version;
+
+  version.major = XML_MAJOR_VERSION;
+  version.minor = XML_MINOR_VERSION;
+  version.micro = XML_MICRO_VERSION;
+
+  return version;
+}
+
+const XML_Feature * XMLCALL
+XML_GetFeatureList(void)
+{
+  static const XML_Feature features[] = {
+    {XML_FEATURE_SIZEOF_XML_CHAR,  XML_L("sizeof(XML_Char)"),
+     sizeof(XML_Char)},
+    {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"),
+     sizeof(XML_LChar)},
+#ifdef XML_UNICODE
+    {XML_FEATURE_UNICODE,          XML_L("XML_UNICODE"), 0},
+#endif
+#ifdef XML_UNICODE_WCHAR_T
+    {XML_FEATURE_UNICODE_WCHAR_T,  XML_L("XML_UNICODE_WCHAR_T"), 0},
+#endif
+#ifdef XML_DTD
+    {XML_FEATURE_DTD,              XML_L("XML_DTD"), 0},
+#endif
+#ifdef XML_CONTEXT_BYTES
+    {XML_FEATURE_CONTEXT_BYTES,    XML_L("XML_CONTEXT_BYTES"),
+     XML_CONTEXT_BYTES},
+#endif
+#ifdef XML_MIN_SIZE
+    {XML_FEATURE_MIN_SIZE,         XML_L("XML_MIN_SIZE"), 0},
+#endif
+#ifdef XML_NS
+    {XML_FEATURE_NS,               XML_L("XML_NS"), 0},
+#endif
+#ifdef XML_LARGE_SIZE
+    {XML_FEATURE_LARGE_SIZE,       XML_L("XML_LARGE_SIZE"), 0},
+#endif
+#ifdef XML_ATTR_INFO
+    {XML_FEATURE_ATTR_INFO,        XML_L("XML_ATTR_INFO"), 0},
+#endif
+    {XML_FEATURE_END,              NULL, 0}
+  };
+
+  return features;
+}
+
+/* Initially tag->rawName always points into the parse buffer;
+   for those TAG instances opened while the current parse buffer was
+   processed, and not yet closed, we need to store tag->rawName in a more
+   permanent location, since the parse buffer is about to be discarded.
+*/
+static XML_Bool
+storeRawNames(XML_Parser parser)
+{
+  TAG *tag = tagStack;
+  while (tag) {
+    int bufSize;
+    int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
+    char *rawNameBuf = tag->buf + nameLen;
+    /* Stop if already stored.  Since tagStack is a stack, we can stop
+       at the first entry that has already been copied; everything
+       below it in the stack is already been accounted for in a
+       previous call to this function.
+    */
+    if (tag->rawName == rawNameBuf)
+      break;
+    /* For re-use purposes we need to ensure that the
+       size of tag->buf is a multiple of sizeof(XML_Char).
+    */
+    bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
+    if (bufSize > tag->bufEnd - tag->buf) {
+      char *temp = (char *)REALLOC(tag->buf, bufSize);
+      if (temp == NULL)
+        return XML_FALSE;
+      /* if tag->name.str points to tag->buf (only when namespace
+         processing is off) then we have to update it
+      */
+      if (tag->name.str == (XML_Char *)tag->buf)
+        tag->name.str = (XML_Char *)temp;
+      /* if tag->name.localPart is set (when namespace processing is on)
+         then update it as well, since it will always point into tag->buf
+      */
+      if (tag->name.localPart)
+        tag->name.localPart = (XML_Char *)temp + (tag->name.localPart -
+                                                  (XML_Char *)tag->buf);
+      tag->buf = temp;
+      tag->bufEnd = temp + bufSize;
+      rawNameBuf = temp + nameLen;
+    }
+    memcpy(rawNameBuf, tag->rawName, tag->rawNameLength);
+    tag->rawName = rawNameBuf;
+    tag = tag->parent;
+  }
+  return XML_TRUE;
+}
+
+static enum XML_Error PTRCALL
+contentProcessor(XML_Parser parser,
+                 const char *start,
+                 const char *end,
+                 const char **endPtr)
+{
+  enum XML_Error result = doContent(parser, 0, encoding, start, end,
+                                    endPtr, (XML_Bool)!ps_finalBuffer);
+  if (result == XML_ERROR_NONE) {
+    if (!storeRawNames(parser))
+      return XML_ERROR_NO_MEMORY;
+  }
+  return result;
+}
+
+static enum XML_Error PTRCALL
+externalEntityInitProcessor(XML_Parser parser,
+                            const char *start,
+                            const char *end,
+                            const char **endPtr)
+{
+  enum XML_Error result = initializeEncoding(parser);
+  if (result != XML_ERROR_NONE)
+    return result;
+  processor = externalEntityInitProcessor2;
+  return externalEntityInitProcessor2(parser, start, end, endPtr);
+}
+
+static enum XML_Error PTRCALL
+externalEntityInitProcessor2(XML_Parser parser,
+                             const char *start,
+                             const char *end,
+                             const char **endPtr)
+{
+  const char *next = start; /* XmlContentTok doesn't always set the last arg */
+  int tok = XmlContentTok(encoding, start, end, &next);
+  switch (tok) {
+  case XML_TOK_BOM:
+    /* If we are at the end of the buffer, this would cause the next stage,
+       i.e. externalEntityInitProcessor3, to pass control directly to
+       doContent (by detecting XML_TOK_NONE) without processing any xml text
+       declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent.
+    */
+    if (next == end && !ps_finalBuffer) {
+      *endPtr = next;
+      return XML_ERROR_NONE;
+    }
+    start = next;
+    break;
+  case XML_TOK_PARTIAL:
+    if (!ps_finalBuffer) {
+      *endPtr = start;
+      return XML_ERROR_NONE;
+    }
+    eventPtr = start;
+    return XML_ERROR_UNCLOSED_TOKEN;
+  case XML_TOK_PARTIAL_CHAR:
+    if (!ps_finalBuffer) {
+      *endPtr = start;
+      return XML_ERROR_NONE;
+    }
+    eventPtr = start;
+    return XML_ERROR_PARTIAL_CHAR;
+  }
+  processor = externalEntityInitProcessor3;
+  return externalEntityInitProcessor3(parser, start, end, endPtr);
+}
+
+static enum XML_Error PTRCALL
+externalEntityInitProcessor3(XML_Parser parser,
+                             const char *start,
+                             const char *end,
+                             const char **endPtr)
+{
+  int tok;
+  const char *next = start; /* XmlContentTok doesn't always set the last arg */
+  eventPtr = start;
+  tok = XmlContentTok(encoding, start, end, &next);
+  eventEndPtr = next;
+
+  switch (tok) {
+  case XML_TOK_XML_DECL:
+    {
+      enum XML_Error result;
+      result = processXmlDecl(parser, 1, start, next);
+      if (result != XML_ERROR_NONE)
+        return result;
+      switch (ps_parsing) {
+      case XML_SUSPENDED:
+        *endPtr = next;
+        return XML_ERROR_NONE;
+      case XML_FINISHED:
+        return XML_ERROR_ABORTED;
+      default:
+        start = next;
+      }
+    }
+    break;
+  case XML_TOK_PARTIAL:
+    if (!ps_finalBuffer) {
+      *endPtr = start;
+      return XML_ERROR_NONE;
+    }
+    return XML_ERROR_UNCLOSED_TOKEN;
+  case XML_TOK_PARTIAL_CHAR:
+    if (!ps_finalBuffer) {
+      *endPtr = start;
+      return XML_ERROR_NONE;
+    }
+    return XML_ERROR_PARTIAL_CHAR;
+  }
+  processor = externalEntityContentProcessor;
+  tagLevel = 1;
+  return externalEntityContentProcessor(parser, start, end, endPtr);
+}
+
+static enum XML_Error PTRCALL
+externalEntityContentProcessor(XML_Parser parser,
+                               const char *start,
+                               const char *end,
+                               const char **endPtr)
+{
+  enum XML_Error result = doContent(parser, 1, encoding, start, end,
+                                    endPtr, (XML_Bool)!ps_finalBuffer);
+  if (result == XML_ERROR_NONE) {
+    if (!storeRawNames(parser))
+      return XML_ERROR_NO_MEMORY;
+  }
+  return result;
+}
+
+static enum XML_Error
+doContent(XML_Parser parser,
+          int startTagLevel,
+          const ENCODING *enc,
+          const char *s,
+          const char *end,
+          const char **nextPtr,
+          XML_Bool haveMore)
+{
+  /* save one level of indirection */
+  DTD * const dtd = _dtd;
+
+  const char **eventPP;
+  const char **eventEndPP;
+  if (enc == encoding) {
+    eventPP = &eventPtr;
+    eventEndPP = &eventEndPtr;
+  }
+  else {
+    eventPP = &(openInternalEntities->internalEventPtr);
+    eventEndPP = &(openInternalEntities->internalEventEndPtr);
+  }
+  *eventPP = s;
+
+  for (;;) {
+    const char *next = s; /* XmlContentTok doesn't always set the last arg */
+    int tok = XmlContentTok(enc, s, end, &next);
+    *eventEndPP = next;
+    switch (tok) {
+    case XML_TOK_TRAILING_CR:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      *eventEndPP = end;
+      if (characterDataHandler) {
+        XML_Char c = 0xA;
+        characterDataHandler(handlerArg, &c, 1);
+      }
+      else if (defaultHandler)
+        reportDefault(parser, enc, s, end);
+      /* We are at the end of the final buffer, should we check for
+         XML_SUSPENDED, XML_FINISHED?
+      */
+      if (startTagLevel == 0)
+        return XML_ERROR_NO_ELEMENTS;
+      if (tagLevel != startTagLevel)
+        return XML_ERROR_ASYNC_ENTITY;
+      *nextPtr = end;
+      return XML_ERROR_NONE;
+    case XML_TOK_NONE:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      if (startTagLevel > 0) {
+        if (tagLevel != startTagLevel)
+          return XML_ERROR_ASYNC_ENTITY;
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_NO_ELEMENTS;
+    case XML_TOK_INVALID:
+      *eventPP = next;
+      return XML_ERROR_INVALID_TOKEN;
+    case XML_TOK_PARTIAL:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_UNCLOSED_TOKEN;
+    case XML_TOK_PARTIAL_CHAR:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_PARTIAL_CHAR;
+    case XML_TOK_ENTITY_REF:
+      {
+        const XML_Char *name;
+        ENTITY *entity;
+        XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc,
+                                              s + enc->minBytesPerChar,
+                                              next - enc->minBytesPerChar);
+        if (ch) {
+          if (characterDataHandler)
+            characterDataHandler(handlerArg, &ch, 1);
+          else if (defaultHandler)
+            reportDefault(parser, enc, s, next);
+          break;
+        }
+        name = poolStoreString(&dtd->pool, enc,
+                                s + enc->minBytesPerChar,
+                                next - enc->minBytesPerChar);
+        if (!name)
+          return XML_ERROR_NO_MEMORY;
+        entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
+        poolDiscard(&dtd->pool);
+        /* First, determine if a check for an existing declaration is needed;
+           if yes, check that the entity exists, and that it is internal,
+           otherwise call the skipped entity or default handler.
+        */
+        if (!dtd->hasParamEntityRefs || dtd->standalone) {
+          if (!entity)
+            return XML_ERROR_UNDEFINED_ENTITY;
+          else if (!entity->is_internal)
+            return XML_ERROR_ENTITY_DECLARED_IN_PE;
+        }
+        else if (!entity) {
+          if (skippedEntityHandler)
+            skippedEntityHandler(handlerArg, name, 0);
+          else if (defaultHandler)
+            reportDefault(parser, enc, s, next);
+          break;
+        }
+        if (entity->open)
+          return XML_ERROR_RECURSIVE_ENTITY_REF;
+        if (entity->notation)
+          return XML_ERROR_BINARY_ENTITY_REF;
+        if (entity->textPtr) {
+          enum XML_Error result;
+          if (!defaultExpandInternalEntities) {
+            if (skippedEntityHandler)
+              skippedEntityHandler(handlerArg, entity->name, 0);
+            else if (defaultHandler)
+              reportDefault(parser, enc, s, next);
+            break;
+          }
+          result = processInternalEntity(parser, entity, XML_FALSE);
+          if (result != XML_ERROR_NONE)
+            return result;
+        }
+        else if (externalEntityRefHandler) {
+          const XML_Char *context;
+          entity->open = XML_TRUE;
+          context = getContext(parser);
+          entity->open = XML_FALSE;
+          if (!context)
+            return XML_ERROR_NO_MEMORY;
+          if (!externalEntityRefHandler(externalEntityRefHandlerArg,
+                                        context,
+                                        entity->base,
+                                        entity->systemId,
+                                        entity->publicId))
+            return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+          poolDiscard(&tempPool);
+        }
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+        break;
+      }
+    case XML_TOK_START_TAG_NO_ATTS:
+      /* fall through */
+    case XML_TOK_START_TAG_WITH_ATTS:
+      {
+        TAG *tag;
+        enum XML_Error result;
+        XML_Char *toPtr;
+        if (freeTagList) {
+          tag = freeTagList;
+          freeTagList = freeTagList->parent;
+        }
+        else {
+          tag = (TAG *)MALLOC(sizeof(TAG));
+          if (!tag)
+            return XML_ERROR_NO_MEMORY;
+          tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE);
+          if (!tag->buf) {
+            FREE(tag);
+            return XML_ERROR_NO_MEMORY;
+          }
+          tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE;
+        }
+        tag->bindings = NULL;
+        tag->parent = tagStack;
+        tagStack = tag;
+        tag->name.localPart = NULL;
+        tag->name.prefix = NULL;
+        tag->rawName = s + enc->minBytesPerChar;
+        tag->rawNameLength = XmlNameLength(enc, tag->rawName);
+        ++tagLevel;
+        {
+          const char *rawNameEnd = tag->rawName + tag->rawNameLength;
+          const char *fromPtr = tag->rawName;
+          toPtr = (XML_Char *)tag->buf;
+          for (;;) {
+            int bufSize;
+            int convLen;
+            const enum XML_Convert_Result convert_res = XmlConvert(enc,
+                       &fromPtr, rawNameEnd,
+                       (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1);
+            convLen = (int)(toPtr - (XML_Char *)tag->buf);
+            if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) {
+              tag->name.strLen = convLen;
+              break;
+            }
+            bufSize = (int)(tag->bufEnd - tag->buf) << 1;
+            {
+              char *temp = (char *)REALLOC(tag->buf, bufSize);
+              if (temp == NULL)
+                return XML_ERROR_NO_MEMORY;
+              tag->buf = temp;
+              tag->bufEnd = temp + bufSize;
+              toPtr = (XML_Char *)temp + convLen;
+            }
+          }
+        }
+        tag->name.str = (XML_Char *)tag->buf;
+        *toPtr = XML_T('\0');
+        result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
+        if (result)
+          return result;
+        if (startElementHandler)
+          startElementHandler(handlerArg, tag->name.str,
+                              (const XML_Char **)atts);
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+        poolClear(&tempPool);
+        break;
+      }
+    case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
+      /* fall through */
+    case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
+      {
+        const char *rawName = s + enc->minBytesPerChar;
+        enum XML_Error result;
+        BINDING *bindings = NULL;
+        XML_Bool noElmHandlers = XML_TRUE;
+        TAG_NAME name;
+        name.str = poolStoreString(&tempPool, enc, rawName,
+                                   rawName + XmlNameLength(enc, rawName));
+        if (!name.str)
+          return XML_ERROR_NO_MEMORY;
+        poolFinish(&tempPool);
+        result = storeAtts(parser, enc, s, &name, &bindings);
+        if (result)
+          return result;
+        poolFinish(&tempPool);
+        if (startElementHandler) {
+          startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
+          noElmHandlers = XML_FALSE;
+        }
+        if (endElementHandler) {
+          if (startElementHandler)
+            *eventPP = *eventEndPP;
+          endElementHandler(handlerArg, name.str);
+          noElmHandlers = XML_FALSE;
+        }
+        if (noElmHandlers && defaultHandler)
+          reportDefault(parser, enc, s, next);
+        poolClear(&tempPool);
+        while (bindings) {
+          BINDING *b = bindings;
+          if (endNamespaceDeclHandler)
+            endNamespaceDeclHandler(handlerArg, b->prefix->name);
+          bindings = bindings->nextTagBinding;
+          b->nextTagBinding = freeBindingList;
+          freeBindingList = b;
+          b->prefix->binding = b->prevPrefixBinding;
+        }
+      }
+      if (tagLevel == 0)
+        return epilogProcessor(parser, next, end, nextPtr);
+      break;
+    case XML_TOK_END_TAG:
+      if (tagLevel == startTagLevel)
+        return XML_ERROR_ASYNC_ENTITY;
+      else {
+        int len;
+        const char *rawName;
+        TAG *tag = tagStack;
+        tagStack = tag->parent;
+        tag->parent = freeTagList;
+        freeTagList = tag;
+        rawName = s + enc->minBytesPerChar*2;
+        len = XmlNameLength(enc, rawName);
+        if (len != tag->rawNameLength
+            || memcmp(tag->rawName, rawName, len) != 0) {
+          *eventPP = rawName;
+          return XML_ERROR_TAG_MISMATCH;
+        }
+        --tagLevel;
+        if (endElementHandler) {
+          const XML_Char *localPart;
+          const XML_Char *prefix;
+          XML_Char *uri;
+          localPart = tag->name.localPart;
+          if (ns && localPart) {
+            /* localPart and prefix may have been overwritten in
+               tag->name.str, since this points to the binding->uri
+               buffer which gets re-used; so we have to add them again
+            */
+            uri = (XML_Char *)tag->name.str + tag->name.uriLen;
+            /* don't need to check for space - already done in storeAtts() */
+            while (*localPart) *uri++ = *localPart++;
+            prefix = (XML_Char *)tag->name.prefix;
+            if (ns_triplets && prefix) {
+              *uri++ = namespaceSeparator;
+              while (*prefix) *uri++ = *prefix++;
+             }
+            *uri = XML_T('\0');
+          }
+          endElementHandler(handlerArg, tag->name.str);
+        }
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+        while (tag->bindings) {
+          BINDING *b = tag->bindings;
+          if (endNamespaceDeclHandler)
+            endNamespaceDeclHandler(handlerArg, b->prefix->name);
+          tag->bindings = tag->bindings->nextTagBinding;
+          b->nextTagBinding = freeBindingList;
+          freeBindingList = b;
+          b->prefix->binding = b->prevPrefixBinding;
+        }
+        if (tagLevel == 0)
+          return epilogProcessor(parser, next, end, nextPtr);
+      }
+      break;
+    case XML_TOK_CHAR_REF:
+      {
+        int n = XmlCharRefNumber(enc, s);
+        if (n < 0)
+          return XML_ERROR_BAD_CHAR_REF;
+        if (characterDataHandler) {
+          XML_Char buf[XML_ENCODE_MAX];
+          characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf));
+        }
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+      }
+      break;
+    case XML_TOK_XML_DECL:
+      return XML_ERROR_MISPLACED_XML_PI;
+    case XML_TOK_DATA_NEWLINE:
+      if (characterDataHandler) {
+        XML_Char c = 0xA;
+        characterDataHandler(handlerArg, &c, 1);
+      }
+      else if (defaultHandler)
+        reportDefault(parser, enc, s, next);
+      break;
+    case XML_TOK_CDATA_SECT_OPEN:
+      {
+        enum XML_Error result;
+        if (startCdataSectionHandler)
+          startCdataSectionHandler(handlerArg);
+#if 0
+        /* Suppose you doing a transformation on a document that involves
+           changing only the character data.  You set up a defaultHandler
+           and a characterDataHandler.  The defaultHandler simply copies
+           characters through.  The characterDataHandler does the
+           transformation and writes the characters out escaping them as
+           necessary.  This case will fail to work if we leave out the
+           following two lines (because & and < inside CDATA sections will
+           be incorrectly escaped).
+
+           However, now we have a start/endCdataSectionHandler, so it seems
+           easier to let the user deal with this.
+        */
+        else if (characterDataHandler)
+          characterDataHandler(handlerArg, dataBuf, 0);
+#endif
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+        result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore);
+        if (result != XML_ERROR_NONE)
+          return result;
+        else if (!next) {
+          processor = cdataSectionProcessor;
+          return result;
+        }
+      }
+      break;
+    case XML_TOK_TRAILING_RSQB:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      if (characterDataHandler) {
+        if (MUST_CONVERT(enc, s)) {
+          ICHAR *dataPtr = (ICHAR *)dataBuf;
+          XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
+          characterDataHandler(handlerArg, dataBuf,
+                               (int)(dataPtr - (ICHAR *)dataBuf));
+        }
+        else
+          characterDataHandler(handlerArg,
+                               (XML_Char *)s,
+                               (int)((XML_Char *)end - (XML_Char *)s));
+      }
+      else if (defaultHandler)
+        reportDefault(parser, enc, s, end);
+      /* We are at the end of the final buffer, should we check for
+         XML_SUSPENDED, XML_FINISHED?
+      */
+      if (startTagLevel == 0) {
+        *eventPP = end;
+        return XML_ERROR_NO_ELEMENTS;
+      }
+      if (tagLevel != startTagLevel) {
+        *eventPP = end;
+        return XML_ERROR_ASYNC_ENTITY;
+      }
+      *nextPtr = end;
+      return XML_ERROR_NONE;
+    case XML_TOK_DATA_CHARS:
+      {
+        XML_CharacterDataHandler charDataHandler = characterDataHandler;
+        if (charDataHandler) {
+          if (MUST_CONVERT(enc, s)) {
+            for (;;) {
+              ICHAR *dataPtr = (ICHAR *)dataBuf;
+              const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
+              *eventEndPP = s;
+              charDataHandler(handlerArg, dataBuf,
+                              (int)(dataPtr - (ICHAR *)dataBuf));
+              if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
+                break;
+              *eventPP = s;
+            }
+          }
+          else
+            charDataHandler(handlerArg,
+                            (XML_Char *)s,
+                            (int)((XML_Char *)next - (XML_Char *)s));
+        }
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+      }
+      break;
+    case XML_TOK_PI:
+      if (!reportProcessingInstruction(parser, enc, s, next))
+        return XML_ERROR_NO_MEMORY;
+      break;
+    case XML_TOK_COMMENT:
+      if (!reportComment(parser, enc, s, next))
+        return XML_ERROR_NO_MEMORY;
+      break;
+    default:
+      if (defaultHandler)
+        reportDefault(parser, enc, s, next);
+      break;
+    }
+    *eventPP = s = next;
+    switch (ps_parsing) {
+    case XML_SUSPENDED:
+      *nextPtr = next;
+      return XML_ERROR_NONE;
+    case XML_FINISHED:
+      return XML_ERROR_ABORTED;
+    default: ;
+    }
+  }
+  /* not reached */
+}
+
+/* Precondition: all arguments must be non-NULL;
+   Purpose:
+   - normalize attributes
+   - check attributes for well-formedness
+   - generate namespace aware attribute names (URI, prefix)
+   - build list of attributes for startElementHandler
+   - default attributes
+   - process namespace declarations (check and report them)
+   - generate namespace aware element name (URI, prefix)
+*/
+static enum XML_Error
+storeAtts(XML_Parser parser, const ENCODING *enc,
+          const char *attStr, TAG_NAME *tagNamePtr,
+          BINDING **bindingsPtr)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  ELEMENT_TYPE *elementType;
+  int nDefaultAtts;
+  const XML_Char **appAtts;   /* the attribute list for the application */
+  int attIndex = 0;
+  int prefixLen;
+  int i;
+  int n;
+  XML_Char *uri;
+  int nPrefixes = 0;
+  BINDING *binding;
+  const XML_Char *localPart;
+
+  /* lookup the element type name */
+  elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str,0);
+  if (!elementType) {
+    const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str);
+    if (!name)
+      return XML_ERROR_NO_MEMORY;
+    elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name,
+                                         sizeof(ELEMENT_TYPE));
+    if (!elementType)
+      return XML_ERROR_NO_MEMORY;
+    if (ns && !setElementTypePrefix(parser, elementType))
+      return XML_ERROR_NO_MEMORY;
+  }
+  nDefaultAtts = elementType->nDefaultAtts;
+
+  /* get the attributes from the tokenizer */
+  n = XmlGetAttributes(enc, attStr, attsSize, atts);
+  if (n + nDefaultAtts > attsSize) {
+    int oldAttsSize = attsSize;
+    ATTRIBUTE *temp;
+#ifdef XML_ATTR_INFO
+    XML_AttrInfo *temp2;
+#endif
+    attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
+    temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE));
+    if (temp == NULL)
+      return XML_ERROR_NO_MEMORY;
+    atts = temp;
+#ifdef XML_ATTR_INFO
+    temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo));
+    if (temp2 == NULL)
+      return XML_ERROR_NO_MEMORY;
+    attInfo = temp2;
+#endif
+    if (n > oldAttsSize)
+      XmlGetAttributes(enc, attStr, n, atts);
+  }
+
+  appAtts = (const XML_Char **)atts;
+  for (i = 0; i < n; i++) {
+    ATTRIBUTE *currAtt = &atts[i];
+#ifdef XML_ATTR_INFO
+    XML_AttrInfo *currAttInfo = &attInfo[i];
+#endif
+    /* add the name and value to the attribute list */
+    ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name,
+                                         currAtt->name
+                                         + XmlNameLength(enc, currAtt->name));
+    if (!attId)
+      return XML_ERROR_NO_MEMORY;
+#ifdef XML_ATTR_INFO
+    currAttInfo->nameStart = parseEndByteIndex - (parseEndPtr - currAtt->name);
+    currAttInfo->nameEnd = currAttInfo->nameStart +
+                           XmlNameLength(enc, currAtt->name);
+    currAttInfo->valueStart = parseEndByteIndex -
+                            (parseEndPtr - currAtt->valuePtr);
+    currAttInfo->valueEnd = parseEndByteIndex - (parseEndPtr - currAtt->valueEnd);
+#endif
+    /* Detect duplicate attributes by their QNames. This does not work when
+       namespace processing is turned on and different prefixes for the same
+       namespace are used. For this case we have a check further down.
+    */
+    if ((attId->name)[-1]) {
+      if (enc == encoding)
+        eventPtr = atts[i].name;
+      return XML_ERROR_DUPLICATE_ATTRIBUTE;
+    }
+    (attId->name)[-1] = 1;
+    appAtts[attIndex++] = attId->name;
+    if (!atts[i].normalized) {
+      enum XML_Error result;
+      XML_Bool isCdata = XML_TRUE;
+
+      /* figure out whether declared as other than CDATA */
+      if (attId->maybeTokenized) {
+        int j;
+        for (j = 0; j < nDefaultAtts; j++) {
+          if (attId == elementType->defaultAtts[j].id) {
+            isCdata = elementType->defaultAtts[j].isCdata;
+            break;
+          }
+        }
+      }
+
+      /* normalize the attribute value */
+      result = storeAttributeValue(parser, enc, isCdata,
+                                   atts[i].valuePtr, atts[i].valueEnd,
+                                   &tempPool);
+      if (result)
+        return result;
+      appAtts[attIndex] = poolStart(&tempPool);
+      poolFinish(&tempPool);
+    }
+    else {
+      /* the value did not need normalizing */
+      appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr,
+                                          atts[i].valueEnd);
+      if (appAtts[attIndex] == 0)
+        return XML_ERROR_NO_MEMORY;
+      poolFinish(&tempPool);
+    }
+    /* handle prefixed attribute names */
+    if (attId->prefix) {
+      if (attId->xmlns) {
+        /* deal with namespace declarations here */
+        enum XML_Error result = addBinding(parser, attId->prefix, attId,
+                                           appAtts[attIndex], bindingsPtr);
+        if (result)
+          return result;
+        --attIndex;
+      }
+      else {
+        /* deal with other prefixed names later */
+        attIndex++;
+        nPrefixes++;
+        (attId->name)[-1] = 2;
+      }
+    }
+    else
+      attIndex++;
+  }
+
+  /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */
+  nSpecifiedAtts = attIndex;
+  if (elementType->idAtt && (elementType->idAtt->name)[-1]) {
+    for (i = 0; i < attIndex; i += 2)
+      if (appAtts[i] == elementType->idAtt->name) {
+        idAttIndex = i;
+        break;
+      }
+  }
+  else
+    idAttIndex = -1;
+
+  /* do attribute defaulting */
+  for (i = 0; i < nDefaultAtts; i++) {
+    const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i;
+    if (!(da->id->name)[-1] && da->value) {
+      if (da->id->prefix) {
+        if (da->id->xmlns) {
+          enum XML_Error result = addBinding(parser, da->id->prefix, da->id,
+                                             da->value, bindingsPtr);
+          if (result)
+            return result;
+        }
+        else {
+          (da->id->name)[-1] = 2;
+          nPrefixes++;
+          appAtts[attIndex++] = da->id->name;
+          appAtts[attIndex++] = da->value;
+        }
+      }
+      else {
+        (da->id->name)[-1] = 1;
+        appAtts[attIndex++] = da->id->name;
+        appAtts[attIndex++] = da->value;
+      }
+    }
+  }
+  appAtts[attIndex] = 0;
+
+  /* expand prefixed attribute names, check for duplicates,
+     and clear flags that say whether attributes were specified */
+  i = 0;
+  if (nPrefixes) {
+    int j;  /* hash table index */
+    unsigned long version = nsAttsVersion;
+    int nsAttsSize = (int)1 << nsAttsPower;
+    /* size of hash table must be at least 2 * (# of prefixed attributes) */
+    if ((nPrefixes << 1) >> nsAttsPower) {  /* true for nsAttsPower = 0 */
+      NS_ATT *temp;
+      /* hash table size must also be a power of 2 and >= 8 */
+      while (nPrefixes >> nsAttsPower++);
+      if (nsAttsPower < 3)
+        nsAttsPower = 3;
+      nsAttsSize = (int)1 << nsAttsPower;
+      temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT));
+      if (!temp)
+        return XML_ERROR_NO_MEMORY;
+      nsAtts = temp;
+      version = 0;  /* force re-initialization of nsAtts hash table */
+    }
+    /* using a version flag saves us from initializing nsAtts every time */
+    if (!version) {  /* initialize version flags when version wraps around */
+      version = INIT_ATTS_VERSION;
+      for (j = nsAttsSize; j != 0; )
+        nsAtts[--j].version = version;
+    }
+    nsAttsVersion = --version;
+
+    /* expand prefixed names and check for duplicates */
+    for (; i < attIndex; i += 2) {
+      const XML_Char *s = appAtts[i];
+      if (s[-1] == 2) {  /* prefixed */
+        ATTRIBUTE_ID *id;
+        const BINDING *b;
+        unsigned long uriHash = hash_secret_salt;
+        ((XML_Char *)s)[-1] = 0;  /* clear flag */
+        id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0);
+        if (!id || !id->prefix)
+          return XML_ERROR_NO_MEMORY;
+        b = id->prefix->binding;
+        if (!b)
+          return XML_ERROR_UNBOUND_PREFIX;
+
+        /* as we expand the name we also calculate its hash value */
+        for (j = 0; j < b->uriLen; j++) {
+          const XML_Char c = b->uri[j];
+          if (!poolAppendChar(&tempPool, c))
+            return XML_ERROR_NO_MEMORY;
+          uriHash = CHAR_HASH(uriHash, c);
+        }
+        while (*s++ != XML_T(ASCII_COLON))
+          ;
+        do {  /* copies null terminator */
+          const XML_Char c = *s;
+          if (!poolAppendChar(&tempPool, *s))
+            return XML_ERROR_NO_MEMORY;
+          uriHash = CHAR_HASH(uriHash, c);
+        } while (*s++);
+
+        { /* Check hash table for duplicate of expanded name (uriName).
+             Derived from code in lookup(parser, HASH_TABLE *table, ...).
+          */
+          unsigned char step = 0;
+          unsigned long mask = nsAttsSize - 1;
+          j = uriHash & mask;  /* index into hash table */
+          while (nsAtts[j].version == version) {
+            /* for speed we compare stored hash values first */
+            if (uriHash == nsAtts[j].hash) {
+              const XML_Char *s1 = poolStart(&tempPool);
+              const XML_Char *s2 = nsAtts[j].uriName;
+              /* s1 is null terminated, but not s2 */
+              for (; *s1 == *s2 && *s1 != 0; s1++, s2++);
+              if (*s1 == 0)
+                return XML_ERROR_DUPLICATE_ATTRIBUTE;
+            }
+            if (!step)
+              step = PROBE_STEP(uriHash, mask, nsAttsPower);
+            j < step ? (j += nsAttsSize - step) : (j -= step);
+          }
+        }
+
+        if (ns_triplets) {  /* append namespace separator and prefix */
+          tempPool.ptr[-1] = namespaceSeparator;
+          s = b->prefix->name;
+          do {
+            if (!poolAppendChar(&tempPool, *s))
+              return XML_ERROR_NO_MEMORY;
+          } while (*s++);
+        }
+
+        /* store expanded name in attribute list */
+        s = poolStart(&tempPool);
+        poolFinish(&tempPool);
+        appAtts[i] = s;
+
+        /* fill empty slot with new version, uriName and hash value */
+        nsAtts[j].version = version;
+        nsAtts[j].hash = uriHash;
+        nsAtts[j].uriName = s;
+
+        if (!--nPrefixes) {
+          i += 2;
+          break;
+        }
+      }
+      else  /* not prefixed */
+        ((XML_Char *)s)[-1] = 0;  /* clear flag */
+    }
+  }
+  /* clear flags for the remaining attributes */
+  for (; i < attIndex; i += 2)
+    ((XML_Char *)(appAtts[i]))[-1] = 0;
+  for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
+    binding->attId->name[-1] = 0;
+
+  if (!ns)
+    return XML_ERROR_NONE;
+
+  /* expand the element type name */
+  if (elementType->prefix) {
+    binding = elementType->prefix->binding;
+    if (!binding)
+      return XML_ERROR_UNBOUND_PREFIX;
+    localPart = tagNamePtr->str;
+    while (*localPart++ != XML_T(ASCII_COLON))
+      ;
+  }
+  else if (dtd->defaultPrefix.binding) {
+    binding = dtd->defaultPrefix.binding;
+    localPart = tagNamePtr->str;
+  }
+  else
+    return XML_ERROR_NONE;
+  prefixLen = 0;
+  if (ns_triplets && binding->prefix->name) {
+    for (; binding->prefix->name[prefixLen++];)
+      ;  /* prefixLen includes null terminator */
+  }
+  tagNamePtr->localPart = localPart;
+  tagNamePtr->uriLen = binding->uriLen;
+  tagNamePtr->prefix = binding->prefix->name;
+  tagNamePtr->prefixLen = prefixLen;
+  for (i = 0; localPart[i++];)
+    ;  /* i includes null terminator */
+  n = i + binding->uriLen + prefixLen;
+  if (n > binding->uriAlloc) {
+    TAG *p;
+    uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char));
+    if (!uri)
+      return XML_ERROR_NO_MEMORY;
+    binding->uriAlloc = n + EXPAND_SPARE;
+    memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char));
+    for (p = tagStack; p; p = p->parent)
+      if (p->name.str == binding->uri)
+        p->name.str = uri;
+    FREE(binding->uri);
+    binding->uri = uri;
+  }
+  /* if namespaceSeparator != '\0' then uri includes it already */
+  uri = binding->uri + binding->uriLen;
+  memcpy(uri, localPart, i * sizeof(XML_Char));
+  /* we always have a namespace separator between localPart and prefix */
+  if (prefixLen) {
+    uri += i - 1;
+    *uri = namespaceSeparator;  /* replace null terminator */
+    memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char));
+  }
+  tagNamePtr->str = binding->uri;
+  return XML_ERROR_NONE;
+}
+
+/* addBinding() overwrites the value of prefix->binding without checking.
+   Therefore one must keep track of the old value outside of addBinding().
+*/
+static enum XML_Error
+addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
+           const XML_Char *uri, BINDING **bindingsPtr)
+{
+  static const XML_Char xmlNamespace[] = {
+    ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
+    ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
+    ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L,
+    ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH,
+    ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c,
+    ASCII_e, '\0'
+  };
+  static const int xmlLen =
+    (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1;
+  static const XML_Char xmlnsNamespace[] = {
+    ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
+    ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
+    ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0,
+    ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s,
+    ASCII_SLASH, '\0'
+  };
+  static const int xmlnsLen =
+    (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1;
+
+  XML_Bool mustBeXML = XML_FALSE;
+  XML_Bool isXML = XML_TRUE;
+  XML_Bool isXMLNS = XML_TRUE;
+
+  BINDING *b;
+  int len;
+
+  /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */
+  if (*uri == XML_T('\0') && prefix->name)
+    return XML_ERROR_UNDECLARING_PREFIX;
+
+  if (prefix->name
+      && prefix->name[0] == XML_T(ASCII_x)
+      && prefix->name[1] == XML_T(ASCII_m)
+      && prefix->name[2] == XML_T(ASCII_l)) {
+
+    /* Not allowed to bind xmlns */
+    if (prefix->name[3] == XML_T(ASCII_n)
+        && prefix->name[4] == XML_T(ASCII_s)
+        && prefix->name[5] == XML_T('\0'))
+      return XML_ERROR_RESERVED_PREFIX_XMLNS;
+
+    if (prefix->name[3] == XML_T('\0'))
+      mustBeXML = XML_TRUE;
+  }
+
+  for (len = 0; uri[len]; len++) {
+    if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len]))
+      isXML = XML_FALSE;
+
+    if (!mustBeXML && isXMLNS
+        && (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
+      isXMLNS = XML_FALSE;
+  }
+  isXML = isXML && len == xmlLen;
+  isXMLNS = isXMLNS && len == xmlnsLen;
+
+  if (mustBeXML != isXML)
+    return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML
+                     : XML_ERROR_RESERVED_NAMESPACE_URI;
+
+  if (isXMLNS)
+    return XML_ERROR_RESERVED_NAMESPACE_URI;
+
+  if (namespaceSeparator)
+    len++;
+  if (freeBindingList) {
+    b = freeBindingList;
+    if (len > b->uriAlloc) {
+      XML_Char *temp = (XML_Char *)REALLOC(b->uri,
+                          sizeof(XML_Char) * (len + EXPAND_SPARE));
+      if (temp == NULL)
+        return XML_ERROR_NO_MEMORY;
+      b->uri = temp;
+      b->uriAlloc = len + EXPAND_SPARE;
+    }
+    freeBindingList = b->nextTagBinding;
+  }
+  else {
+    b = (BINDING *)MALLOC(sizeof(BINDING));
+    if (!b)
+      return XML_ERROR_NO_MEMORY;
+    b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE));
+    if (!b->uri) {
+      FREE(b);
+      return XML_ERROR_NO_MEMORY;
+    }
+    b->uriAlloc = len + EXPAND_SPARE;
+  }
+  b->uriLen = len;
+  memcpy(b->uri, uri, len * sizeof(XML_Char));
+  if (namespaceSeparator)
+    b->uri[len - 1] = namespaceSeparator;
+  b->prefix = prefix;
+  b->attId = attId;
+  b->prevPrefixBinding = prefix->binding;
+  /* NULL binding when default namespace undeclared */
+  if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix)
+    prefix->binding = NULL;
+  else
+    prefix->binding = b;
+  b->nextTagBinding = *bindingsPtr;
+  *bindingsPtr = b;
+  /* if attId == NULL then we are not starting a namespace scope */
+  if (attId && startNamespaceDeclHandler)
+    startNamespaceDeclHandler(handlerArg, prefix->name,
+                              prefix->binding ? uri : 0);
+  return XML_ERROR_NONE;
+}
+
+/* The idea here is to avoid using stack for each CDATA section when
+   the whole file is parsed with one call.
+*/
+static enum XML_Error PTRCALL
+cdataSectionProcessor(XML_Parser parser,
+                      const char *start,
+                      const char *end,
+                      const char **endPtr)
+{
+  enum XML_Error result = doCdataSection(parser, encoding, &start, end,
+                                         endPtr, (XML_Bool)!ps_finalBuffer);
+  if (result != XML_ERROR_NONE)
+    return result;
+  if (start) {
+    if (parentParser) {  /* we are parsing an external entity */
+      processor = externalEntityContentProcessor;
+      return externalEntityContentProcessor(parser, start, end, endPtr);
+    }
+    else {
+      processor = contentProcessor;
+      return contentProcessor(parser, start, end, endPtr);
+    }
+  }
+  return result;
+}
+
+/* startPtr gets set to non-null if the section is closed, and to null if
+   the section is not yet closed.
+*/
+static enum XML_Error
+doCdataSection(XML_Parser parser,
+               const ENCODING *enc,
+               const char **startPtr,
+               const char *end,
+               const char **nextPtr,
+               XML_Bool haveMore)
+{
+  const char *s = *startPtr;
+  const char **eventPP;
+  const char **eventEndPP;
+  if (enc == encoding) {
+    eventPP = &eventPtr;
+    *eventPP = s;
+    eventEndPP = &eventEndPtr;
+  }
+  else {
+    eventPP = &(openInternalEntities->internalEventPtr);
+    eventEndPP = &(openInternalEntities->internalEventEndPtr);
+  }
+  *eventPP = s;
+  *startPtr = NULL;
+
+  for (;;) {
+    const char *next;
+    int tok = XmlCdataSectionTok(enc, s, end, &next);
+    *eventEndPP = next;
+    switch (tok) {
+    case XML_TOK_CDATA_SECT_CLOSE:
+      if (endCdataSectionHandler)
+        endCdataSectionHandler(handlerArg);
+#if 0
+      /* see comment under XML_TOK_CDATA_SECT_OPEN */
+      else if (characterDataHandler)
+        characterDataHandler(handlerArg, dataBuf, 0);
+#endif
+      else if (defaultHandler)
+        reportDefault(parser, enc, s, next);
+      *startPtr = next;
+      *nextPtr = next;
+      if (ps_parsing == XML_FINISHED)
+        return XML_ERROR_ABORTED;
+      else
+        return XML_ERROR_NONE;
+    case XML_TOK_DATA_NEWLINE:
+      if (characterDataHandler) {
+        XML_Char c = 0xA;
+        characterDataHandler(handlerArg, &c, 1);
+      }
+      else if (defaultHandler)
+        reportDefault(parser, enc, s, next);
+      break;
+    case XML_TOK_DATA_CHARS:
+      {
+        XML_CharacterDataHandler charDataHandler = characterDataHandler;
+        if (charDataHandler) {
+          if (MUST_CONVERT(enc, s)) {
+            for (;;) {
+              ICHAR *dataPtr = (ICHAR *)dataBuf;
+              const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
+              *eventEndPP = next;
+              charDataHandler(handlerArg, dataBuf,
+                              (int)(dataPtr - (ICHAR *)dataBuf));
+              if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
+                break;
+              *eventPP = s;
+            }
+          }
+          else
+            charDataHandler(handlerArg,
+                            (XML_Char *)s,
+                            (int)((XML_Char *)next - (XML_Char *)s));
+        }
+        else if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+      }
+      break;
+    case XML_TOK_INVALID:
+      *eventPP = next;
+      return XML_ERROR_INVALID_TOKEN;
+    case XML_TOK_PARTIAL_CHAR:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_PARTIAL_CHAR;
+    case XML_TOK_PARTIAL:
+    case XML_TOK_NONE:
+      if (haveMore) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_UNCLOSED_CDATA_SECTION;
+    default:
+      *eventPP = next;
+      return XML_ERROR_UNEXPECTED_STATE;
+    }
+
+    *eventPP = s = next;
+    switch (ps_parsing) {
+    case XML_SUSPENDED:
+      *nextPtr = next;
+      return XML_ERROR_NONE;
+    case XML_FINISHED:
+      return XML_ERROR_ABORTED;
+    default: ;
+    }
+  }
+  /* not reached */
+}
+
+#ifdef XML_DTD
+
+/* The idea here is to avoid using stack for each IGNORE section when
+   the whole file is parsed with one call.
+*/
+static enum XML_Error PTRCALL
+ignoreSectionProcessor(XML_Parser parser,
+                       const char *start,
+                       const char *end,
+                       const char **endPtr)
+{
+  enum XML_Error result = doIgnoreSection(parser, encoding, &start, end,
+                                          endPtr, (XML_Bool)!ps_finalBuffer);
+  if (result != XML_ERROR_NONE)
+    return result;
+  if (start) {
+    processor = prologProcessor;
+    return prologProcessor(parser, start, end, endPtr);
+  }
+  return result;
+}
+
+/* startPtr gets set to non-null is the section is closed, and to null
+   if the section is not yet closed.
+*/
+static enum XML_Error
+doIgnoreSection(XML_Parser parser,
+                const ENCODING *enc,
+                const char **startPtr,
+                const char *end,
+                const char **nextPtr,
+                XML_Bool haveMore)
+{
+  const char *next;
+  int tok;
+  const char *s = *startPtr;
+  const char **eventPP;
+  const char **eventEndPP;
+  if (enc == encoding) {
+    eventPP = &eventPtr;
+    *eventPP = s;
+    eventEndPP = &eventEndPtr;
+  }
+  else {
+    eventPP = &(openInternalEntities->internalEventPtr);
+    eventEndPP = &(openInternalEntities->internalEventEndPtr);
+  }
+  *eventPP = s;
+  *startPtr = NULL;
+  tok = XmlIgnoreSectionTok(enc, s, end, &next);
+  *eventEndPP = next;
+  switch (tok) {
+  case XML_TOK_IGNORE_SECT:
+    if (defaultHandler)
+      reportDefault(parser, enc, s, next);
+    *startPtr = next;
+    *nextPtr = next;
+    if (ps_parsing == XML_FINISHED)
+      return XML_ERROR_ABORTED;
+    else
+      return XML_ERROR_NONE;
+  case XML_TOK_INVALID:
+    *eventPP = next;
+    return XML_ERROR_INVALID_TOKEN;
+  case XML_TOK_PARTIAL_CHAR:
+    if (haveMore) {
+      *nextPtr = s;
+      return XML_ERROR_NONE;
+    }
+    return XML_ERROR_PARTIAL_CHAR;
+  case XML_TOK_PARTIAL:
+  case XML_TOK_NONE:
+    if (haveMore) {
+      *nextPtr = s;
+      return XML_ERROR_NONE;
+    }
+    return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */
+  default:
+    *eventPP = next;
+    return XML_ERROR_UNEXPECTED_STATE;
+  }
+  /* not reached */
+}
+
+#endif /* XML_DTD */
+
+static enum XML_Error
+initializeEncoding(XML_Parser parser)
+{
+  const char *s;
+#ifdef XML_UNICODE
+  char encodingBuf[128];
+  if (!protocolEncodingName)
+    s = NULL;
+  else {
+    int i;
+    for (i = 0; protocolEncodingName[i]; i++) {
+      if (i == sizeof(encodingBuf) - 1
+          || (protocolEncodingName[i] & ~0x7f) != 0) {
+        encodingBuf[0] = '\0';
+        break;
+      }
+      encodingBuf[i] = (char)protocolEncodingName[i];
+    }
+    encodingBuf[i] = '\0';
+    s = encodingBuf;
+  }
+#else
+  s = protocolEncodingName;
+#endif
+  if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s))
+    return XML_ERROR_NONE;
+  return handleUnknownEncoding(parser, protocolEncodingName);
+}
+
+static enum XML_Error
+processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
+               const char *s, const char *next)
+{
+  const char *encodingName = NULL;
+  const XML_Char *storedEncName = NULL;
+  const ENCODING *newEncoding = NULL;
+  const char *version = NULL;
+  const char *versionend;
+  const XML_Char *storedversion = NULL;
+  int standalone = -1;
+  if (!(ns
+        ? XmlParseXmlDeclNS
+        : XmlParseXmlDecl)(isGeneralTextEntity,
+                           encoding,
+                           s,
+                           next,
+                           &eventPtr,
+                           &version,
+                           &versionend,
+                           &encodingName,
+                           &newEncoding,
+                           &standalone)) {
+    if (isGeneralTextEntity)
+      return XML_ERROR_TEXT_DECL;
+    else
+      return XML_ERROR_XML_DECL;
+  }
+  if (!isGeneralTextEntity && standalone == 1) {
+    _dtd->standalone = XML_TRUE;
+#ifdef XML_DTD
+    if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
+      paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
+#endif /* XML_DTD */
+  }
+  if (xmlDeclHandler) {
+    if (encodingName != NULL) {
+      storedEncName = poolStoreString(&temp2Pool,
+                                      encoding,
+                                      encodingName,
+                                      encodingName
+                                      + XmlNameLength(encoding, encodingName));
+      if (!storedEncName)
+              return XML_ERROR_NO_MEMORY;
+      poolFinish(&temp2Pool);
+    }
+    if (version) {
+      storedversion = poolStoreString(&temp2Pool,
+                                      encoding,
+                                      version,
+                                      versionend - encoding->minBytesPerChar);
+      if (!storedversion)
+        return XML_ERROR_NO_MEMORY;
+    }
+    xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone);
+  }
+  else if (defaultHandler)
+    reportDefault(parser, encoding, s, next);
+  if (protocolEncodingName == NULL) {
+    if (newEncoding) {
+      if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) {
+        eventPtr = encodingName;
+        return XML_ERROR_INCORRECT_ENCODING;
+      }
+      encoding = newEncoding;
+    }
+    else if (encodingName) {
+      enum XML_Error result;
+      if (!storedEncName) {
+        storedEncName = poolStoreString(
+          &temp2Pool, encoding, encodingName,
+          encodingName + XmlNameLength(encoding, encodingName));
+        if (!storedEncName)
+          return XML_ERROR_NO_MEMORY;
+      }
+      result = handleUnknownEncoding(parser, storedEncName);
+      poolClear(&temp2Pool);
+      if (result == XML_ERROR_UNKNOWN_ENCODING)
+        eventPtr = encodingName;
+      return result;
+    }
+  }
+
+  if (storedEncName || storedversion)
+    poolClear(&temp2Pool);
+
+  return XML_ERROR_NONE;
+}
+
+static enum XML_Error
+handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
+{
+  if (unknownEncodingHandler) {
+    XML_Encoding info;
+    int i;
+    for (i = 0; i < 256; i++)
+      info.map[i] = -1;
+    info.convert = NULL;
+    info.data = NULL;
+    info.release = NULL;
+    if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName,
+                               &info)) {
+      ENCODING *enc;
+      unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding());
+      if (!unknownEncodingMem) {
+        if (info.release)
+          info.release(info.data);
+        return XML_ERROR_NO_MEMORY;
+      }
+      enc = (ns
+             ? XmlInitUnknownEncodingNS
+             : XmlInitUnknownEncoding)(unknownEncodingMem,
+                                       info.map,
+                                       info.convert,
+                                       info.data);
+      if (enc) {
+        unknownEncodingData = info.data;
+        unknownEncodingRelease = info.release;
+        encoding = enc;
+        return XML_ERROR_NONE;
+      }
+    }
+    if (info.release != NULL)
+      info.release(info.data);
+  }
+  return XML_ERROR_UNKNOWN_ENCODING;
+}
+
+static enum XML_Error PTRCALL
+prologInitProcessor(XML_Parser parser,
+                    const char *s,
+                    const char *end,
+                    const char **nextPtr)
+{
+  enum XML_Error result = initializeEncoding(parser);
+  if (result != XML_ERROR_NONE)
+    return result;
+  processor = prologProcessor;
+  return prologProcessor(parser, s, end, nextPtr);
+}
+
+#ifdef XML_DTD
+
+static enum XML_Error PTRCALL
+externalParEntInitProcessor(XML_Parser parser,
+                            const char *s,
+                            const char *end,
+                            const char **nextPtr)
+{
+  enum XML_Error result = initializeEncoding(parser);
+  if (result != XML_ERROR_NONE)
+    return result;
+
+  /* we know now that XML_Parse(Buffer) has been called,
+     so we consider the external parameter entity read */
+  _dtd->paramEntityRead = XML_TRUE;
+
+  if (prologState.inEntityValue) {
+    processor = entityValueInitProcessor;
+    return entityValueInitProcessor(parser, s, end, nextPtr);
+  }
+  else {
+    processor = externalParEntProcessor;
+    return externalParEntProcessor(parser, s, end, nextPtr);
+  }
+}
+
+static enum XML_Error PTRCALL
+entityValueInitProcessor(XML_Parser parser,
+                         const char *s,
+                         const char *end,
+                         const char **nextPtr)
+{
+  int tok;
+  const char *start = s;
+  const char *next = start;
+  eventPtr = start;
+
+  for (;;) {
+    tok = XmlPrologTok(encoding, start, end, &next);
+    eventEndPtr = next;
+    if (tok <= 0) {
+      if (!ps_finalBuffer && tok != XML_TOK_INVALID) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      switch (tok) {
+      case XML_TOK_INVALID:
+        return XML_ERROR_INVALID_TOKEN;
+      case XML_TOK_PARTIAL:
+        return XML_ERROR_UNCLOSED_TOKEN;
+      case XML_TOK_PARTIAL_CHAR:
+        return XML_ERROR_PARTIAL_CHAR;
+      case XML_TOK_NONE:   /* start == end */
+      default:
+        break;
+      }
+      /* found end of entity value - can store it now */
+      return storeEntityValue(parser, encoding, s, end);
+    }
+    else if (tok == XML_TOK_XML_DECL) {
+      enum XML_Error result;
+      result = processXmlDecl(parser, 0, start, next);
+      if (result != XML_ERROR_NONE)
+        return result;
+      switch (ps_parsing) {
+      case XML_SUSPENDED:
+        *nextPtr = next;
+        return XML_ERROR_NONE;
+      case XML_FINISHED:
+        return XML_ERROR_ABORTED;
+      default:
+        *nextPtr = next;
+      }
+      /* stop scanning for text declaration - we found one */
+      processor = entityValueProcessor;
+      return entityValueProcessor(parser, next, end, nextPtr);
+    }
+    /* If we are at the end of the buffer, this would cause XmlPrologTok to
+       return XML_TOK_NONE on the next call, which would then cause the
+       function to exit with *nextPtr set to s - that is what we want for other
+       tokens, but not for the BOM - we would rather like to skip it;
+       then, when this routine is entered the next time, XmlPrologTok will
+       return XML_TOK_INVALID, since the BOM is still in the buffer
+    */
+    else if (tok == XML_TOK_BOM && next == end && !ps_finalBuffer) {
+      *nextPtr = next;
+      return XML_ERROR_NONE;
+    }
+    start = next;
+    eventPtr = start;
+  }
+}
+
+static enum XML_Error PTRCALL
+externalParEntProcessor(XML_Parser parser,
+                        const char *s,
+                        const char *end,
+                        const char **nextPtr)
+{
+  const char *next = s;
+  int tok;
+
+  tok = XmlPrologTok(encoding, s, end, &next);
+  if (tok <= 0) {
+    if (!ps_finalBuffer && tok != XML_TOK_INVALID) {
+      *nextPtr = s;
+      return XML_ERROR_NONE;
+    }
+    switch (tok) {
+    case XML_TOK_INVALID:
+      return XML_ERROR_INVALID_TOKEN;
+    case XML_TOK_PARTIAL:
+      return XML_ERROR_UNCLOSED_TOKEN;
+    case XML_TOK_PARTIAL_CHAR:
+      return XML_ERROR_PARTIAL_CHAR;
+    case XML_TOK_NONE:   /* start == end */
+    default:
+      break;
+    }
+  }
+  /* This would cause the next stage, i.e. doProlog to be passed XML_TOK_BOM.
+     However, when parsing an external subset, doProlog will not accept a BOM
+     as valid, and report a syntax error, so we have to skip the BOM
+  */
+  else if (tok == XML_TOK_BOM) {
+    s = next;
+    tok = XmlPrologTok(encoding, s, end, &next);
+  }
+
+  processor = prologProcessor;
+  return doProlog(parser, encoding, s, end, tok, next,
+                  nextPtr, (XML_Bool)!ps_finalBuffer);
+}
+
+static enum XML_Error PTRCALL
+entityValueProcessor(XML_Parser parser,
+                     const char *s,
+                     const char *end,
+                     const char **nextPtr)
+{
+  const char *start = s;
+  const char *next = s;
+  const ENCODING *enc = encoding;
+  int tok;
+
+  for (;;) {
+    tok = XmlPrologTok(enc, start, end, &next);
+    if (tok <= 0) {
+      if (!ps_finalBuffer && tok != XML_TOK_INVALID) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      switch (tok) {
+      case XML_TOK_INVALID:
+        return XML_ERROR_INVALID_TOKEN;
+      case XML_TOK_PARTIAL:
+        return XML_ERROR_UNCLOSED_TOKEN;
+      case XML_TOK_PARTIAL_CHAR:
+        return XML_ERROR_PARTIAL_CHAR;
+      case XML_TOK_NONE:   /* start == end */
+      default:
+        break;
+      }
+      /* found end of entity value - can store it now */
+      return storeEntityValue(parser, enc, s, end);
+    }
+    start = next;
+  }
+}
+
+#endif /* XML_DTD */
+
+static enum XML_Error PTRCALL
+prologProcessor(XML_Parser parser,
+                const char *s,
+                const char *end,
+                const char **nextPtr)
+{
+  const char *next = s;
+  int tok = XmlPrologTok(encoding, s, end, &next);
+  return doProlog(parser, encoding, s, end, tok, next,
+                  nextPtr, (XML_Bool)!ps_finalBuffer);
+}
+
+static enum XML_Error
+doProlog(XML_Parser parser,
+         const ENCODING *enc,
+         const char *s,
+         const char *end,
+         int tok,
+         const char *next,
+         const char **nextPtr,
+         XML_Bool haveMore)
+{
+#ifdef XML_DTD
+  static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' };
+#endif /* XML_DTD */
+  static const XML_Char atypeCDATA[] =
+      { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
+  static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' };
+  static const XML_Char atypeIDREF[] =
+      { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
+  static const XML_Char atypeIDREFS[] =
+      { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
+  static const XML_Char atypeENTITY[] =
+      { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
+  static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N,
+      ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' };
+  static const XML_Char atypeNMTOKEN[] = {
+      ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
+  static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T,
+      ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };
+  static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T,
+      ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' };
+  static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' };
+  static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' };
+
+  /* save one level of indirection */
+  DTD * const dtd = _dtd;
+
+  const char **eventPP;
+  const char **eventEndPP;
+  enum XML_Content_Quant quant;
+
+  if (enc == encoding) {
+    eventPP = &eventPtr;
+    eventEndPP = &eventEndPtr;
+  }
+  else {
+    eventPP = &(openInternalEntities->internalEventPtr);
+    eventEndPP = &(openInternalEntities->internalEventEndPtr);
+  }
+
+  for (;;) {
+    int role;
+    XML_Bool handleDefault = XML_TRUE;
+    *eventPP = s;
+    *eventEndPP = next;
+    if (tok <= 0) {
+      if (haveMore && tok != XML_TOK_INVALID) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      switch (tok) {
+      case XML_TOK_INVALID:
+        *eventPP = next;
+        return XML_ERROR_INVALID_TOKEN;
+      case XML_TOK_PARTIAL:
+        return XML_ERROR_UNCLOSED_TOKEN;
+      case XML_TOK_PARTIAL_CHAR:
+        return XML_ERROR_PARTIAL_CHAR;
+      case -XML_TOK_PROLOG_S:
+        tok = -tok;
+        break;
+      case XML_TOK_NONE:
+#ifdef XML_DTD
+        /* for internal PE NOT referenced between declarations */
+        if (enc != encoding && !openInternalEntities->betweenDecl) {
+          *nextPtr = s;
+          return XML_ERROR_NONE;
+        }
+        /* WFC: PE Between Declarations - must check that PE contains
+           complete markup, not only for external PEs, but also for
+           internal PEs if the reference occurs between declarations.
+        */
+        if (isParamEntity || enc != encoding) {
+          if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc)
+              == XML_ROLE_ERROR)
+            return XML_ERROR_INCOMPLETE_PE;
+          *nextPtr = s;
+          return XML_ERROR_NONE;
+        }
+#endif /* XML_DTD */
+        return XML_ERROR_NO_ELEMENTS;
+      default:
+        tok = -tok;
+        next = end;
+        break;
+      }
+    }
+    role = XmlTokenRole(&prologState, tok, s, next, enc);
+    switch (role) {
+    case XML_ROLE_XML_DECL:
+      {
+        enum XML_Error result = processXmlDecl(parser, 0, s, next);
+        if (result != XML_ERROR_NONE)
+          return result;
+        enc = encoding;
+        handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_DOCTYPE_NAME:
+      if (startDoctypeDeclHandler) {
+        doctypeName = poolStoreString(&tempPool, enc, s, next);
+        if (!doctypeName)
+          return XML_ERROR_NO_MEMORY;
+        poolFinish(&tempPool);
+        doctypePubid = NULL;
+        handleDefault = XML_FALSE;
+      }
+      doctypeSysid = NULL; /* always initialize to NULL */
+      break;
+    case XML_ROLE_DOCTYPE_INTERNAL_SUBSET:
+      if (startDoctypeDeclHandler) {
+        startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid,
+                                doctypePubid, 1);
+        doctypeName = NULL;
+        poolClear(&tempPool);
+        handleDefault = XML_FALSE;
+      }
+      break;
+#ifdef XML_DTD
+    case XML_ROLE_TEXT_DECL:
+      {
+        enum XML_Error result = processXmlDecl(parser, 1, s, next);
+        if (result != XML_ERROR_NONE)
+          return result;
+        enc = encoding;
+        handleDefault = XML_FALSE;
+      }
+      break;
+#endif /* XML_DTD */
+    case XML_ROLE_DOCTYPE_PUBLIC_ID:
+#ifdef XML_DTD
+      useForeignDTD = XML_FALSE;
+      declEntity = (ENTITY *)lookup(parser,
+                                    &dtd->paramEntities,
+                                    externalSubsetName,
+                                    sizeof(ENTITY));
+      if (!declEntity)
+        return XML_ERROR_NO_MEMORY;
+#endif /* XML_DTD */
+      dtd->hasParamEntityRefs = XML_TRUE;
+      if (startDoctypeDeclHandler) {
+        XML_Char *pubId;
+        if (!XmlIsPublicId(enc, s, next, eventPP))
+          return XML_ERROR_PUBLICID;
+        pubId = poolStoreString(&tempPool, enc,
+                                s + enc->minBytesPerChar,
+                                next - enc->minBytesPerChar);
+        if (!pubId)
+          return XML_ERROR_NO_MEMORY;
+        normalizePublicId(pubId);
+        poolFinish(&tempPool);
+        doctypePubid = pubId;
+        handleDefault = XML_FALSE;
+        goto alreadyChecked;
+      }
+      /* fall through */
+    case XML_ROLE_ENTITY_PUBLIC_ID:
+      if (!XmlIsPublicId(enc, s, next, eventPP))
+        return XML_ERROR_PUBLICID;
+    alreadyChecked:
+      if (dtd->keepProcessing && declEntity) {
+        XML_Char *tem = poolStoreString(&dtd->pool,
+                                        enc,
+                                        s + enc->minBytesPerChar,
+                                        next - enc->minBytesPerChar);
+        if (!tem)
+          return XML_ERROR_NO_MEMORY;
+        normalizePublicId(tem);
+        declEntity->publicId = tem;
+        poolFinish(&dtd->pool);
+        if (entityDeclHandler)
+          handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_DOCTYPE_CLOSE:
+      if (doctypeName) {
+        startDoctypeDeclHandler(handlerArg, doctypeName,
+                                doctypeSysid, doctypePubid, 0);
+        poolClear(&tempPool);
+        handleDefault = XML_FALSE;
+      }
+      /* doctypeSysid will be non-NULL in the case of a previous
+         XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler
+         was not set, indicating an external subset
+      */
+#ifdef XML_DTD
+      if (doctypeSysid || useForeignDTD) {
+        XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs;
+        dtd->hasParamEntityRefs = XML_TRUE;
+        if (paramEntityParsing && externalEntityRefHandler) {
+          ENTITY *entity = (ENTITY *)lookup(parser,
+                                            &dtd->paramEntities,
+                                            externalSubsetName,
+                                            sizeof(ENTITY));
+          if (!entity)
+            return XML_ERROR_NO_MEMORY;
+          if (useForeignDTD)
+            entity->base = curBase;
+          dtd->paramEntityRead = XML_FALSE;
+          if (!externalEntityRefHandler(externalEntityRefHandlerArg,
+                                        0,
+                                        entity->base,
+                                        entity->systemId,
+                                        entity->publicId))
+            return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+          if (dtd->paramEntityRead) {
+            if (!dtd->standalone &&
+                notStandaloneHandler &&
+                !notStandaloneHandler(handlerArg))
+              return XML_ERROR_NOT_STANDALONE;
+          }
+          /* if we didn't read the foreign DTD then this means that there
+             is no external subset and we must reset dtd->hasParamEntityRefs
+          */
+          else if (!doctypeSysid)
+            dtd->hasParamEntityRefs = hadParamEntityRefs;
+          /* end of DTD - no need to update dtd->keepProcessing */
+        }
+        useForeignDTD = XML_FALSE;
+      }
+#endif /* XML_DTD */
+      if (endDoctypeDeclHandler) {
+        endDoctypeDeclHandler(handlerArg);
+        handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_INSTANCE_START:
+#ifdef XML_DTD
+      /* if there is no DOCTYPE declaration then now is the
+         last chance to read the foreign DTD
+      */
+      if (useForeignDTD) {
+        XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs;
+        dtd->hasParamEntityRefs = XML_TRUE;
+        if (paramEntityParsing && externalEntityRefHandler) {
+          ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities,
+                                            externalSubsetName,
+                                            sizeof(ENTITY));
+          if (!entity)
+            return XML_ERROR_NO_MEMORY;
+          entity->base = curBase;
+          dtd->paramEntityRead = XML_FALSE;
+          if (!externalEntityRefHandler(externalEntityRefHandlerArg,
+                                        0,
+                                        entity->base,
+                                        entity->systemId,
+                                        entity->publicId))
+            return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+          if (dtd->paramEntityRead) {
+            if (!dtd->standalone &&
+                notStandaloneHandler &&
+                !notStandaloneHandler(handlerArg))
+              return XML_ERROR_NOT_STANDALONE;
+          }
+          /* if we didn't read the foreign DTD then this means that there
+             is no external subset and we must reset dtd->hasParamEntityRefs
+          */
+          else
+            dtd->hasParamEntityRefs = hadParamEntityRefs;
+          /* end of DTD - no need to update dtd->keepProcessing */
+        }
+      }
+#endif /* XML_DTD */
+      processor = contentProcessor;
+      return contentProcessor(parser, s, end, nextPtr);
+    case XML_ROLE_ATTLIST_ELEMENT_NAME:
+      declElementType = getElementType(parser, enc, s, next);
+      if (!declElementType)
+        return XML_ERROR_NO_MEMORY;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_NAME:
+      declAttributeId = getAttributeId(parser, enc, s, next);
+      if (!declAttributeId)
+        return XML_ERROR_NO_MEMORY;
+      declAttributeIsCdata = XML_FALSE;
+      declAttributeType = NULL;
+      declAttributeIsId = XML_FALSE;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_CDATA:
+      declAttributeIsCdata = XML_TRUE;
+      declAttributeType = atypeCDATA;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_ID:
+      declAttributeIsId = XML_TRUE;
+      declAttributeType = atypeID;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_IDREF:
+      declAttributeType = atypeIDREF;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_IDREFS:
+      declAttributeType = atypeIDREFS;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_ENTITY:
+      declAttributeType = atypeENTITY;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES:
+      declAttributeType = atypeENTITIES;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN:
+      declAttributeType = atypeNMTOKEN;
+      goto checkAttListDeclHandler;
+    case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS:
+      declAttributeType = atypeNMTOKENS;
+    checkAttListDeclHandler:
+      if (dtd->keepProcessing && attlistDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_ATTRIBUTE_ENUM_VALUE:
+    case XML_ROLE_ATTRIBUTE_NOTATION_VALUE:
+      if (dtd->keepProcessing && attlistDeclHandler) {
+        const XML_Char *prefix;
+        if (declAttributeType) {
+          prefix = enumValueSep;
+        }
+        else {
+          prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE
+                    ? notationPrefix
+                    : enumValueStart);
+        }
+        if (!poolAppendString(&tempPool, prefix))
+          return XML_ERROR_NO_MEMORY;
+        if (!poolAppend(&tempPool, enc, s, next))
+          return XML_ERROR_NO_MEMORY;
+        declAttributeType = tempPool.start;
+        handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE:
+    case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE:
+      if (dtd->keepProcessing) {
+        if (!defineAttribute(declElementType, declAttributeId,
+                             declAttributeIsCdata, declAttributeIsId,
+                             0, parser))
+          return XML_ERROR_NO_MEMORY;
+        if (attlistDeclHandler && declAttributeType) {
+          if (*declAttributeType == XML_T(ASCII_LPAREN)
+              || (*declAttributeType == XML_T(ASCII_N)
+                  && declAttributeType[1] == XML_T(ASCII_O))) {
+            /* Enumerated or Notation type */
+            if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN))
+                || !poolAppendChar(&tempPool, XML_T('\0')))
+              return XML_ERROR_NO_MEMORY;
+            declAttributeType = tempPool.start;
+            poolFinish(&tempPool);
+          }
+          *eventEndPP = s;
+          attlistDeclHandler(handlerArg, declElementType->name,
+                             declAttributeId->name, declAttributeType,
+                             0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
+          poolClear(&tempPool);
+          handleDefault = XML_FALSE;
+        }
+      }
+      break;
+    case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
+    case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
+      if (dtd->keepProcessing) {
+        const XML_Char *attVal;
+        enum XML_Error result =
+          storeAttributeValue(parser, enc, declAttributeIsCdata,
+                              s + enc->minBytesPerChar,
+                              next - enc->minBytesPerChar,
+                              &dtd->pool);
+        if (result)
+          return result;
+        attVal = poolStart(&dtd->pool);
+        poolFinish(&dtd->pool);
+        /* ID attributes aren't allowed to have a default */
+        if (!defineAttribute(declElementType, declAttributeId,
+                             declAttributeIsCdata, XML_FALSE, attVal, parser))
+          return XML_ERROR_NO_MEMORY;
+        if (attlistDeclHandler && declAttributeType) {
+          if (*declAttributeType == XML_T(ASCII_LPAREN)
+              || (*declAttributeType == XML_T(ASCII_N)
+                  && declAttributeType[1] == XML_T(ASCII_O))) {
+            /* Enumerated or Notation type */
+            if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN))
+                || !poolAppendChar(&tempPool, XML_T('\0')))
+              return XML_ERROR_NO_MEMORY;
+            declAttributeType = tempPool.start;
+            poolFinish(&tempPool);
+          }
+          *eventEndPP = s;
+          attlistDeclHandler(handlerArg, declElementType->name,
+                             declAttributeId->name, declAttributeType,
+                             attVal,
+                             role == XML_ROLE_FIXED_ATTRIBUTE_VALUE);
+          poolClear(&tempPool);
+          handleDefault = XML_FALSE;
+        }
+      }
+      break;
+    case XML_ROLE_ENTITY_VALUE:
+      if (dtd->keepProcessing) {
+        enum XML_Error result = storeEntityValue(parser, enc,
+                                            s + enc->minBytesPerChar,
+                                            next - enc->minBytesPerChar);
+        if (declEntity) {
+          declEntity->textPtr = poolStart(&dtd->entityValuePool);
+          declEntity->textLen = (int)(poolLength(&dtd->entityValuePool));
+          poolFinish(&dtd->entityValuePool);
+          if (entityDeclHandler) {
+            *eventEndPP = s;
+            entityDeclHandler(handlerArg,
+                              declEntity->name,
+                              declEntity->is_param,
+                              declEntity->textPtr,
+                              declEntity->textLen,
+                              curBase, 0, 0, 0);
+            handleDefault = XML_FALSE;
+          }
+        }
+        else
+          poolDiscard(&dtd->entityValuePool);
+        if (result != XML_ERROR_NONE)
+          return result;
+      }
+      break;
+    case XML_ROLE_DOCTYPE_SYSTEM_ID:
+#ifdef XML_DTD
+      useForeignDTD = XML_FALSE;
+#endif /* XML_DTD */
+      dtd->hasParamEntityRefs = XML_TRUE;
+      if (startDoctypeDeclHandler) {
+        doctypeSysid = poolStoreString(&tempPool, enc,
+                                       s + enc->minBytesPerChar,
+                                       next - enc->minBytesPerChar);
+        if (doctypeSysid == NULL)
+          return XML_ERROR_NO_MEMORY;
+        poolFinish(&tempPool);
+        handleDefault = XML_FALSE;
+      }
+#ifdef XML_DTD
+      else
+        /* use externalSubsetName to make doctypeSysid non-NULL
+           for the case where no startDoctypeDeclHandler is set */
+        doctypeSysid = externalSubsetName;
+#endif /* XML_DTD */
+      if (!dtd->standalone
+#ifdef XML_DTD
+          && !paramEntityParsing
+#endif /* XML_DTD */
+          && notStandaloneHandler
+          && !notStandaloneHandler(handlerArg))
+        return XML_ERROR_NOT_STANDALONE;
+#ifndef XML_DTD
+      break;
+#else /* XML_DTD */
+      if (!declEntity) {
+        declEntity = (ENTITY *)lookup(parser,
+                                      &dtd->paramEntities,
+                                      externalSubsetName,
+                                      sizeof(ENTITY));
+        if (!declEntity)
+          return XML_ERROR_NO_MEMORY;
+        declEntity->publicId = NULL;
+      }
+      /* fall through */
+#endif /* XML_DTD */
+    case XML_ROLE_ENTITY_SYSTEM_ID:
+      if (dtd->keepProcessing && declEntity) {
+        declEntity->systemId = poolStoreString(&dtd->pool, enc,
+                                               s + enc->minBytesPerChar,
+                                               next - enc->minBytesPerChar);
+        if (!declEntity->systemId)
+          return XML_ERROR_NO_MEMORY;
+        declEntity->base = curBase;
+        poolFinish(&dtd->pool);
+        if (entityDeclHandler)
+          handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_ENTITY_COMPLETE:
+      if (dtd->keepProcessing && declEntity && entityDeclHandler) {
+        *eventEndPP = s;
+        entityDeclHandler(handlerArg,
+                          declEntity->name,
+                          declEntity->is_param,
+                          0,0,
+                          declEntity->base,
+                          declEntity->systemId,
+                          declEntity->publicId,
+                          0);
+        handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_ENTITY_NOTATION_NAME:
+      if (dtd->keepProcessing && declEntity) {
+        declEntity->notation = poolStoreString(&dtd->pool, enc, s, next);
+        if (!declEntity->notation)
+          return XML_ERROR_NO_MEMORY;
+        poolFinish(&dtd->pool);
+        if (unparsedEntityDeclHandler) {
+          *eventEndPP = s;
+          unparsedEntityDeclHandler(handlerArg,
+                                    declEntity->name,
+                                    declEntity->base,
+                                    declEntity->systemId,
+                                    declEntity->publicId,
+                                    declEntity->notation);
+          handleDefault = XML_FALSE;
+        }
+        else if (entityDeclHandler) {
+          *eventEndPP = s;
+          entityDeclHandler(handlerArg,
+                            declEntity->name,
+                            0,0,0,
+                            declEntity->base,
+                            declEntity->systemId,
+                            declEntity->publicId,
+                            declEntity->notation);
+          handleDefault = XML_FALSE;
+        }
+      }
+      break;
+    case XML_ROLE_GENERAL_ENTITY_NAME:
+      {
+        if (XmlPredefinedEntityName(enc, s, next)) {
+          declEntity = NULL;
+          break;
+        }
+        if (dtd->keepProcessing) {
+          const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next);
+          if (!name)
+            return XML_ERROR_NO_MEMORY;
+          declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name,
+                                        sizeof(ENTITY));
+          if (!declEntity)
+            return XML_ERROR_NO_MEMORY;
+          if (declEntity->name != name) {
+            poolDiscard(&dtd->pool);
+            declEntity = NULL;
+          }
+          else {
+            poolFinish(&dtd->pool);
+            declEntity->publicId = NULL;
+            declEntity->is_param = XML_FALSE;
+            /* if we have a parent parser or are reading an internal parameter
+               entity, then the entity declaration is not considered "internal"
+            */
+            declEntity->is_internal = !(parentParser || openInternalEntities);
+            if (entityDeclHandler)
+              handleDefault = XML_FALSE;
+          }
+        }
+        else {
+          poolDiscard(&dtd->pool);
+          declEntity = NULL;
+        }
+      }
+      break;
+    case XML_ROLE_PARAM_ENTITY_NAME:
+#ifdef XML_DTD
+      if (dtd->keepProcessing) {
+        const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next);
+        if (!name)
+          return XML_ERROR_NO_MEMORY;
+        declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities,
+                                           name, sizeof(ENTITY));
+        if (!declEntity)
+          return XML_ERROR_NO_MEMORY;
+        if (declEntity->name != name) {
+          poolDiscard(&dtd->pool);
+          declEntity = NULL;
+        }
+        else {
+          poolFinish(&dtd->pool);
+          declEntity->publicId = NULL;
+          declEntity->is_param = XML_TRUE;
+          /* if we have a parent parser or are reading an internal parameter
+             entity, then the entity declaration is not considered "internal"
+          */
+          declEntity->is_internal = !(parentParser || openInternalEntities);
+          if (entityDeclHandler)
+            handleDefault = XML_FALSE;
+        }
+      }
+      else {
+        poolDiscard(&dtd->pool);
+        declEntity = NULL;
+      }
+#else /* not XML_DTD */
+      declEntity = NULL;
+#endif /* XML_DTD */
+      break;
+    case XML_ROLE_NOTATION_NAME:
+      declNotationPublicId = NULL;
+      declNotationName = NULL;
+      if (notationDeclHandler) {
+        declNotationName = poolStoreString(&tempPool, enc, s, next);
+        if (!declNotationName)
+          return XML_ERROR_NO_MEMORY;
+        poolFinish(&tempPool);
+        handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_NOTATION_PUBLIC_ID:
+      if (!XmlIsPublicId(enc, s, next, eventPP))
+        return XML_ERROR_PUBLICID;
+      if (declNotationName) {  /* means notationDeclHandler != NULL */
+        XML_Char *tem = poolStoreString(&tempPool,
+                                        enc,
+                                        s + enc->minBytesPerChar,
+                                        next - enc->minBytesPerChar);
+        if (!tem)
+          return XML_ERROR_NO_MEMORY;
+        normalizePublicId(tem);
+        declNotationPublicId = tem;
+        poolFinish(&tempPool);
+        handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_NOTATION_SYSTEM_ID:
+      if (declNotationName && notationDeclHandler) {
+        const XML_Char *systemId
+          = poolStoreString(&tempPool, enc,
+                            s + enc->minBytesPerChar,
+                            next - enc->minBytesPerChar);
+        if (!systemId)
+          return XML_ERROR_NO_MEMORY;
+        *eventEndPP = s;
+        notationDeclHandler(handlerArg,
+                            declNotationName,
+                            curBase,
+                            systemId,
+                            declNotationPublicId);
+        handleDefault = XML_FALSE;
+      }
+      poolClear(&tempPool);
+      break;
+    case XML_ROLE_NOTATION_NO_SYSTEM_ID:
+      if (declNotationPublicId && notationDeclHandler) {
+        *eventEndPP = s;
+        notationDeclHandler(handlerArg,
+                            declNotationName,
+                            curBase,
+                            0,
+                            declNotationPublicId);
+        handleDefault = XML_FALSE;
+      }
+      poolClear(&tempPool);
+      break;
+    case XML_ROLE_ERROR:
+      switch (tok) {
+      case XML_TOK_PARAM_ENTITY_REF:
+        /* PE references in internal subset are
+           not allowed within declarations. */
+        return XML_ERROR_PARAM_ENTITY_REF;
+      case XML_TOK_XML_DECL:
+        return XML_ERROR_MISPLACED_XML_PI;
+      default:
+        return XML_ERROR_SYNTAX;
+      }
+#ifdef XML_DTD
+    case XML_ROLE_IGNORE_SECT:
+      {
+        enum XML_Error result;
+        if (defaultHandler)
+          reportDefault(parser, enc, s, next);
+        handleDefault = XML_FALSE;
+        result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore);
+        if (result != XML_ERROR_NONE)
+          return result;
+        else if (!next) {
+          processor = ignoreSectionProcessor;
+          return result;
+        }
+      }
+      break;
+#endif /* XML_DTD */
+    case XML_ROLE_GROUP_OPEN:
+      if (prologState.level >= groupSize) {
+        if (groupSize) {
+          char *temp = (char *)REALLOC(groupConnector, groupSize *= 2);
+          if (temp == NULL)
+            return XML_ERROR_NO_MEMORY;
+          groupConnector = temp;
+          if (dtd->scaffIndex) {
+            int *temp = (int *)REALLOC(dtd->scaffIndex,
+                          groupSize * sizeof(int));
+            if (temp == NULL)
+              return XML_ERROR_NO_MEMORY;
+            dtd->scaffIndex = temp;
+          }
+        }
+        else {
+          groupConnector = (char *)MALLOC(groupSize = 32);
+          if (!groupConnector)
+            return XML_ERROR_NO_MEMORY;
+        }
+      }
+      groupConnector[prologState.level] = 0;
+      if (dtd->in_eldecl) {
+        int myindex = nextScaffoldPart(parser);
+        if (myindex < 0)
+          return XML_ERROR_NO_MEMORY;
+        dtd->scaffIndex[dtd->scaffLevel] = myindex;
+        dtd->scaffLevel++;
+        dtd->scaffold[myindex].type = XML_CTYPE_SEQ;
+        if (elementDeclHandler)
+          handleDefault = XML_FALSE;
+      }
+      break;
+    case XML_ROLE_GROUP_SEQUENCE:
+      if (groupConnector[prologState.level] == ASCII_PIPE)
+        return XML_ERROR_SYNTAX;
+      groupConnector[prologState.level] = ASCII_COMMA;
+      if (dtd->in_eldecl && elementDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_GROUP_CHOICE:
+      if (groupConnector[prologState.level] == ASCII_COMMA)
+        return XML_ERROR_SYNTAX;
+      if (dtd->in_eldecl
+          && !groupConnector[prologState.level]
+          && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type
+              != XML_CTYPE_MIXED)
+          ) {
+        dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type
+            = XML_CTYPE_CHOICE;
+        if (elementDeclHandler)
+          handleDefault = XML_FALSE;
+      }
+      groupConnector[prologState.level] = ASCII_PIPE;
+      break;
+    case XML_ROLE_PARAM_ENTITY_REF:
+#ifdef XML_DTD
+    case XML_ROLE_INNER_PARAM_ENTITY_REF:
+      dtd->hasParamEntityRefs = XML_TRUE;
+      if (!paramEntityParsing)
+        dtd->keepProcessing = dtd->standalone;
+      else {
+        const XML_Char *name;
+        ENTITY *entity;
+        name = poolStoreString(&dtd->pool, enc,
+                                s + enc->minBytesPerChar,
+                                next - enc->minBytesPerChar);
+        if (!name)
+          return XML_ERROR_NO_MEMORY;
+        entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
+        poolDiscard(&dtd->pool);
+        /* first, determine if a check for an existing declaration is needed;
+           if yes, check that the entity exists, and that it is internal,
+           otherwise call the skipped entity handler
+        */
+        if (prologState.documentEntity &&
+            (dtd->standalone
+             ? !openInternalEntities
+             : !dtd->hasParamEntityRefs)) {
+          if (!entity)
+            return XML_ERROR_UNDEFINED_ENTITY;
+          else if (!entity->is_internal)
+            return XML_ERROR_ENTITY_DECLARED_IN_PE;
+        }
+        else if (!entity) {
+          dtd->keepProcessing = dtd->standalone;
+          /* cannot report skipped entities in declarations */
+          if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) {
+            skippedEntityHandler(handlerArg, name, 1);
+            handleDefault = XML_FALSE;
+          }
+          break;
+        }
+        if (entity->open)
+          return XML_ERROR_RECURSIVE_ENTITY_REF;
+        if (entity->textPtr) {
+          enum XML_Error result;
+          XML_Bool betweenDecl =
+            (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE);
+          result = processInternalEntity(parser, entity, betweenDecl);
+          if (result != XML_ERROR_NONE)
+            return result;
+          handleDefault = XML_FALSE;
+          break;
+        }
+        if (externalEntityRefHandler) {
+          dtd->paramEntityRead = XML_FALSE;
+          entity->open = XML_TRUE;
+          if (!externalEntityRefHandler(externalEntityRefHandlerArg,
+                                        0,
+                                        entity->base,
+                                        entity->systemId,
+                                        entity->publicId)) {
+            entity->open = XML_FALSE;
+            return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+          }
+          entity->open = XML_FALSE;
+          handleDefault = XML_FALSE;
+          if (!dtd->paramEntityRead) {
+            dtd->keepProcessing = dtd->standalone;
+            break;
+          }
+        }
+        else {
+          dtd->keepProcessing = dtd->standalone;
+          break;
+        }
+      }
+#endif /* XML_DTD */
+      if (!dtd->standalone &&
+          notStandaloneHandler &&
+          !notStandaloneHandler(handlerArg))
+        return XML_ERROR_NOT_STANDALONE;
+      break;
+
+    /* Element declaration stuff */
+
+    case XML_ROLE_ELEMENT_NAME:
+      if (elementDeclHandler) {
+        declElementType = getElementType(parser, enc, s, next);
+        if (!declElementType)
+          return XML_ERROR_NO_MEMORY;
+        dtd->scaffLevel = 0;
+        dtd->scaffCount = 0;
+        dtd->in_eldecl = XML_TRUE;
+        handleDefault = XML_FALSE;
+      }
+      break;
+
+    case XML_ROLE_CONTENT_ANY:
+    case XML_ROLE_CONTENT_EMPTY:
+      if (dtd->in_eldecl) {
+        if (elementDeclHandler) {
+          XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content));
+          if (!content)
+            return XML_ERROR_NO_MEMORY;
+          content->quant = XML_CQUANT_NONE;
+          content->name = NULL;
+          content->numchildren = 0;
+          content->children = NULL;
+          content->type = ((role == XML_ROLE_CONTENT_ANY) ?
+                           XML_CTYPE_ANY :
+                           XML_CTYPE_EMPTY);
+          *eventEndPP = s;
+          elementDeclHandler(handlerArg, declElementType->name, content);
+          handleDefault = XML_FALSE;
+        }
+        dtd->in_eldecl = XML_FALSE;
+      }
+      break;
+
+    case XML_ROLE_CONTENT_PCDATA:
+      if (dtd->in_eldecl) {
+        dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type
+            = XML_CTYPE_MIXED;
+        if (elementDeclHandler)
+          handleDefault = XML_FALSE;
+      }
+      break;
+
+    case XML_ROLE_CONTENT_ELEMENT:
+      quant = XML_CQUANT_NONE;
+      goto elementContent;
+    case XML_ROLE_CONTENT_ELEMENT_OPT:
+      quant = XML_CQUANT_OPT;
+      goto elementContent;
+    case XML_ROLE_CONTENT_ELEMENT_REP:
+      quant = XML_CQUANT_REP;
+      goto elementContent;
+    case XML_ROLE_CONTENT_ELEMENT_PLUS:
+      quant = XML_CQUANT_PLUS;
+    elementContent:
+      if (dtd->in_eldecl) {
+        ELEMENT_TYPE *el;
+        const XML_Char *name;
+        int nameLen;
+        const char *nxt = (quant == XML_CQUANT_NONE
+                           ? next
+                           : next - enc->minBytesPerChar);
+        int myindex = nextScaffoldPart(parser);
+        if (myindex < 0)
+          return XML_ERROR_NO_MEMORY;
+        dtd->scaffold[myindex].type = XML_CTYPE_NAME;
+        dtd->scaffold[myindex].quant = quant;
+        el = getElementType(parser, enc, s, nxt);
+        if (!el)
+          return XML_ERROR_NO_MEMORY;
+        name = el->name;
+        dtd->scaffold[myindex].name = name;
+        nameLen = 0;
+        for (; name[nameLen++]; );
+        dtd->contentStringLen +=  nameLen;
+        if (elementDeclHandler)
+          handleDefault = XML_FALSE;
+      }
+      break;
+
+    case XML_ROLE_GROUP_CLOSE:
+      quant = XML_CQUANT_NONE;
+      goto closeGroup;
+    case XML_ROLE_GROUP_CLOSE_OPT:
+      quant = XML_CQUANT_OPT;
+      goto closeGroup;
+    case XML_ROLE_GROUP_CLOSE_REP:
+      quant = XML_CQUANT_REP;
+      goto closeGroup;
+    case XML_ROLE_GROUP_CLOSE_PLUS:
+      quant = XML_CQUANT_PLUS;
+    closeGroup:
+      if (dtd->in_eldecl) {
+        if (elementDeclHandler)
+          handleDefault = XML_FALSE;
+        dtd->scaffLevel--;
+        dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant;
+        if (dtd->scaffLevel == 0) {
+          if (!handleDefault) {
+            XML_Content *model = build_model(parser);
+            if (!model)
+              return XML_ERROR_NO_MEMORY;
+            *eventEndPP = s;
+            elementDeclHandler(handlerArg, declElementType->name, model);
+          }
+          dtd->in_eldecl = XML_FALSE;
+          dtd->contentStringLen = 0;
+        }
+      }
+      break;
+      /* End element declaration stuff */
+
+    case XML_ROLE_PI:
+      if (!reportProcessingInstruction(parser, enc, s, next))
+        return XML_ERROR_NO_MEMORY;
+      handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_COMMENT:
+      if (!reportComment(parser, enc, s, next))
+        return XML_ERROR_NO_MEMORY;
+      handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_NONE:
+      switch (tok) {
+      case XML_TOK_BOM:
+        handleDefault = XML_FALSE;
+        break;
+      }
+      break;
+    case XML_ROLE_DOCTYPE_NONE:
+      if (startDoctypeDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_ENTITY_NONE:
+      if (dtd->keepProcessing && entityDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_NOTATION_NONE:
+      if (notationDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_ATTLIST_NONE:
+      if (dtd->keepProcessing && attlistDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    case XML_ROLE_ELEMENT_NONE:
+      if (elementDeclHandler)
+        handleDefault = XML_FALSE;
+      break;
+    } /* end of big switch */
+
+    if (handleDefault && defaultHandler)
+      reportDefault(parser, enc, s, next);
+
+    switch (ps_parsing) {
+    case XML_SUSPENDED:
+      *nextPtr = next;
+      return XML_ERROR_NONE;
+    case XML_FINISHED:
+      return XML_ERROR_ABORTED;
+    default:
+      s = next;
+      tok = XmlPrologTok(enc, s, end, &next);
+    }
+  }
+  /* not reached */
+}
+
+static enum XML_Error PTRCALL
+epilogProcessor(XML_Parser parser,
+                const char *s,
+                const char *end,
+                const char **nextPtr)
+{
+  processor = epilogProcessor;
+  eventPtr = s;
+  for (;;) {
+    const char *next = NULL;
+    int tok = XmlPrologTok(encoding, s, end, &next);
+    eventEndPtr = next;
+    switch (tok) {
+    /* report partial linebreak - it might be the last token */
+    case -XML_TOK_PROLOG_S:
+      if (defaultHandler) {
+        reportDefault(parser, encoding, s, next);
+        if (ps_parsing == XML_FINISHED)
+          return XML_ERROR_ABORTED;
+      }
+      *nextPtr = next;
+      return XML_ERROR_NONE;
+    case XML_TOK_NONE:
+      *nextPtr = s;
+      return XML_ERROR_NONE;
+    case XML_TOK_PROLOG_S:
+      if (defaultHandler)
+        reportDefault(parser, encoding, s, next);
+      break;
+    case XML_TOK_PI:
+      if (!reportProcessingInstruction(parser, encoding, s, next))
+        return XML_ERROR_NO_MEMORY;
+      break;
+    case XML_TOK_COMMENT:
+      if (!reportComment(parser, encoding, s, next))
+        return XML_ERROR_NO_MEMORY;
+      break;
+    case XML_TOK_INVALID:
+      eventPtr = next;
+      return XML_ERROR_INVALID_TOKEN;
+    case XML_TOK_PARTIAL:
+      if (!ps_finalBuffer) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_UNCLOSED_TOKEN;
+    case XML_TOK_PARTIAL_CHAR:
+      if (!ps_finalBuffer) {
+        *nextPtr = s;
+        return XML_ERROR_NONE;
+      }
+      return XML_ERROR_PARTIAL_CHAR;
+    default:
+      return XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
+    }
+    eventPtr = s = next;
+    switch (ps_parsing) {
+    case XML_SUSPENDED:
+      *nextPtr = next;
+      return XML_ERROR_NONE;
+    case XML_FINISHED:
+      return XML_ERROR_ABORTED;
+    default: ;
+    }
+  }
+}
+
+static enum XML_Error
+processInternalEntity(XML_Parser parser, ENTITY *entity,
+                      XML_Bool betweenDecl)
+{
+  const char *textStart, *textEnd;
+  const char *next;
+  enum XML_Error result;
+  OPEN_INTERNAL_ENTITY *openEntity;
+
+  if (freeInternalEntities) {
+    openEntity = freeInternalEntities;
+    freeInternalEntities = openEntity->next;
+  }
+  else {
+    openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY));
+    if (!openEntity)
+      return XML_ERROR_NO_MEMORY;
+  }
+  entity->open = XML_TRUE;
+  entity->processed = 0;
+  openEntity->next = openInternalEntities;
+  openInternalEntities = openEntity;
+  openEntity->entity = entity;
+  openEntity->startTagLevel = tagLevel;
+  openEntity->betweenDecl = betweenDecl;
+  openEntity->internalEventPtr = NULL;
+  openEntity->internalEventEndPtr = NULL;
+  textStart = (char *)entity->textPtr;
+  textEnd = (char *)(entity->textPtr + entity->textLen);
+
+#ifdef XML_DTD
+  if (entity->is_param) {
+    int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next);
+    result = doProlog(parser, internalEncoding, textStart, textEnd, tok,
+                      next, &next, XML_FALSE);
+  }
+  else
+#endif /* XML_DTD */
+    result = doContent(parser, tagLevel, internalEncoding, textStart,
+                       textEnd, &next, XML_FALSE);
+
+  if (result == XML_ERROR_NONE) {
+    if (textEnd != next && ps_parsing == XML_SUSPENDED) {
+      entity->processed = (int)(next - textStart);
+      processor = internalEntityProcessor;
+    }
+    else {
+      entity->open = XML_FALSE;
+      openInternalEntities = openEntity->next;
+      /* put openEntity back in list of free instances */
+      openEntity->next = freeInternalEntities;
+      freeInternalEntities = openEntity;
+    }
+  }
+  return result;
+}
+
+static enum XML_Error PTRCALL
+internalEntityProcessor(XML_Parser parser,
+                        const char *s,
+                        const char *end,
+                        const char **nextPtr)
+{
+  ENTITY *entity;
+  const char *textStart, *textEnd;
+  const char *next;
+  enum XML_Error result;
+  OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities;
+  if (!openEntity)
+    return XML_ERROR_UNEXPECTED_STATE;
+
+  entity = openEntity->entity;
+  textStart = ((char *)entity->textPtr) + entity->processed;
+  textEnd = (char *)(entity->textPtr + entity->textLen);
+
+#ifdef XML_DTD
+  if (entity->is_param) {
+    int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next);
+    result = doProlog(parser, internalEncoding, textStart, textEnd, tok,
+                      next, &next, XML_FALSE);
+  }
+  else
+#endif /* XML_DTD */
+    result = doContent(parser, openEntity->startTagLevel, internalEncoding,
+                       textStart, textEnd, &next, XML_FALSE);
+
+  if (result != XML_ERROR_NONE)
+    return result;
+  else if (textEnd != next && ps_parsing == XML_SUSPENDED) {
+    entity->processed = (int)(next - (char *)entity->textPtr);
+    return result;
+  }
+  else {
+    entity->open = XML_FALSE;
+    openInternalEntities = openEntity->next;
+    /* put openEntity back in list of free instances */
+    openEntity->next = freeInternalEntities;
+    freeInternalEntities = openEntity;
+  }
+
+#ifdef XML_DTD
+  if (entity->is_param) {
+    int tok;
+    processor = prologProcessor;
+    tok = XmlPrologTok(encoding, s, end, &next);
+    return doProlog(parser, encoding, s, end, tok, next, nextPtr,
+                    (XML_Bool)!ps_finalBuffer);
+  }
+  else
+#endif /* XML_DTD */
+  {
+    processor = contentProcessor;
+    /* see externalEntityContentProcessor vs contentProcessor */
+    return doContent(parser, parentParser ? 1 : 0, encoding, s, end,
+                     nextPtr, (XML_Bool)!ps_finalBuffer);
+  }
+}
+
+static enum XML_Error PTRCALL
+errorProcessor(XML_Parser parser,
+               const char *UNUSED_P(s),
+               const char *UNUSED_P(end),
+               const char **UNUSED_P(nextPtr))
+{
+  return errorCode;
+}
+
+static enum XML_Error
+storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
+                    const char *ptr, const char *end,
+                    STRING_POOL *pool)
+{
+  enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr,
+                                               end, pool);
+  if (result)
+    return result;
+  if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20)
+    poolChop(pool);
+  if (!poolAppendChar(pool, XML_T('\0')))
+    return XML_ERROR_NO_MEMORY;
+  return XML_ERROR_NONE;
+}
+
+static enum XML_Error
+appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
+                     const char *ptr, const char *end,
+                     STRING_POOL *pool)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  for (;;) {
+    const char *next;
+    int tok = XmlAttributeValueTok(enc, ptr, end, &next);
+    switch (tok) {
+    case XML_TOK_NONE:
+      return XML_ERROR_NONE;
+    case XML_TOK_INVALID:
+      if (enc == encoding)
+        eventPtr = next;
+      return XML_ERROR_INVALID_TOKEN;
+    case XML_TOK_PARTIAL:
+      if (enc == encoding)
+        eventPtr = ptr;
+      return XML_ERROR_INVALID_TOKEN;
+    case XML_TOK_CHAR_REF:
+      {
+        XML_Char buf[XML_ENCODE_MAX];
+        int i;
+        int n = XmlCharRefNumber(enc, ptr);
+        if (n < 0) {
+          if (enc == encoding)
+            eventPtr = ptr;
+          return XML_ERROR_BAD_CHAR_REF;
+        }
+        if (!isCdata
+            && n == 0x20 /* space */
+            && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
+          break;
+        n = XmlEncode(n, (ICHAR *)buf);
+        if (!n) {
+          if (enc == encoding)
+            eventPtr = ptr;
+          return XML_ERROR_BAD_CHAR_REF;
+        }
+        for (i = 0; i < n; i++) {
+          if (!poolAppendChar(pool, buf[i]))
+            return XML_ERROR_NO_MEMORY;
+        }
+      }
+      break;
+    case XML_TOK_DATA_CHARS:
+      if (!poolAppend(pool, enc, ptr, next))
+        return XML_ERROR_NO_MEMORY;
+      break;
+    case XML_TOK_TRAILING_CR:
+      next = ptr + enc->minBytesPerChar;
+      /* fall through */
+    case XML_TOK_ATTRIBUTE_VALUE_S:
+    case XML_TOK_DATA_NEWLINE:
+      if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
+        break;
+      if (!poolAppendChar(pool, 0x20))
+        return XML_ERROR_NO_MEMORY;
+      break;
+    case XML_TOK_ENTITY_REF:
+      {
+        const XML_Char *name;
+        ENTITY *entity;
+        char checkEntityDecl;
+        XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc,
+                                              ptr + enc->minBytesPerChar,
+                                              next - enc->minBytesPerChar);
+        if (ch) {
+          if (!poolAppendChar(pool, ch))
+                return XML_ERROR_NO_MEMORY;
+          break;
+        }
+        name = poolStoreString(&temp2Pool, enc,
+                               ptr + enc->minBytesPerChar,
+                               next - enc->minBytesPerChar);
+        if (!name)
+          return XML_ERROR_NO_MEMORY;
+        entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
+        poolDiscard(&temp2Pool);
+        /* First, determine if a check for an existing declaration is needed;
+           if yes, check that the entity exists, and that it is internal.
+        */
+        if (pool == &dtd->pool)  /* are we called from prolog? */
+          checkEntityDecl =
+#ifdef XML_DTD
+              prologState.documentEntity &&
+#endif /* XML_DTD */
+              (dtd->standalone
+               ? !openInternalEntities
+               : !dtd->hasParamEntityRefs);
+        else /* if (pool == &tempPool): we are called from content */
+          checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone;
+        if (checkEntityDecl) {
+          if (!entity)
+            return XML_ERROR_UNDEFINED_ENTITY;
+          else if (!entity->is_internal)
+            return XML_ERROR_ENTITY_DECLARED_IN_PE;
+        }
+        else if (!entity) {
+          /* Cannot report skipped entity here - see comments on
+             skippedEntityHandler.
+          if (skippedEntityHandler)
+            skippedEntityHandler(handlerArg, name, 0);
+          */
+          /* Cannot call the default handler because this would be
+             out of sync with the call to the startElementHandler.
+          if ((pool == &tempPool) && defaultHandler)
+            reportDefault(parser, enc, ptr, next);
+          */
+          break;
+        }
+        if (entity->open) {
+          if (enc == encoding)
+            eventPtr = ptr;
+          return XML_ERROR_RECURSIVE_ENTITY_REF;
+        }
+        if (entity->notation) {
+          if (enc == encoding)
+            eventPtr = ptr;
+          return XML_ERROR_BINARY_ENTITY_REF;
+        }
+        if (!entity->textPtr) {
+          if (enc == encoding)
+            eventPtr = ptr;
+          return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
+        }
+        else {
+          enum XML_Error result;
+          const XML_Char *textEnd = entity->textPtr + entity->textLen;
+          entity->open = XML_TRUE;
+          result = appendAttributeValue(parser, internalEncoding, isCdata,
+                                        (char *)entity->textPtr,
+                                        (char *)textEnd, pool);
+          entity->open = XML_FALSE;
+          if (result)
+            return result;
+        }
+      }
+      break;
+    default:
+      if (enc == encoding)
+        eventPtr = ptr;
+      return XML_ERROR_UNEXPECTED_STATE;
+    }
+    ptr = next;
+  }
+  /* not reached */
+}
+
+static enum XML_Error
+storeEntityValue(XML_Parser parser,
+                 const ENCODING *enc,
+                 const char *entityTextPtr,
+                 const char *entityTextEnd)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  STRING_POOL *pool = &(dtd->entityValuePool);
+  enum XML_Error result = XML_ERROR_NONE;
+#ifdef XML_DTD
+  int oldInEntityValue = prologState.inEntityValue;
+  prologState.inEntityValue = 1;
+#endif /* XML_DTD */
+  /* never return Null for the value argument in EntityDeclHandler,
+     since this would indicate an external entity; therefore we
+     have to make sure that entityValuePool.start is not null */
+  if (!pool->blocks) {
+    if (!poolGrow(pool))
+      return XML_ERROR_NO_MEMORY;
+  }
+
+  for (;;) {
+    const char *next;
+    int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next);
+    switch (tok) {
+    case XML_TOK_PARAM_ENTITY_REF:
+#ifdef XML_DTD
+      if (isParamEntity || enc != encoding) {
+        const XML_Char *name;
+        ENTITY *entity;
+        name = poolStoreString(&tempPool, enc,
+                               entityTextPtr + enc->minBytesPerChar,
+                               next - enc->minBytesPerChar);
+        if (!name) {
+          result = XML_ERROR_NO_MEMORY;
+          goto endEntityValue;
+        }
+        entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
+        poolDiscard(&tempPool);
+        if (!entity) {
+          /* not a well-formedness error - see XML 1.0: WFC Entity Declared */
+          /* cannot report skipped entity here - see comments on
+             skippedEntityHandler
+          if (skippedEntityHandler)
+            skippedEntityHandler(handlerArg, name, 0);
+          */
+          dtd->keepProcessing = dtd->standalone;
+          goto endEntityValue;
+        }
+        if (entity->open) {
+          if (enc == encoding)
+            eventPtr = entityTextPtr;
+          result = XML_ERROR_RECURSIVE_ENTITY_REF;
+          goto endEntityValue;
+        }
+        if (entity->systemId) {
+          if (externalEntityRefHandler) {
+            dtd->paramEntityRead = XML_FALSE;
+            entity->open = XML_TRUE;
+            if (!externalEntityRefHandler(externalEntityRefHandlerArg,
+                                          0,
+                                          entity->base,
+                                          entity->systemId,
+                                          entity->publicId)) {
+              entity->open = XML_FALSE;
+              result = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+              goto endEntityValue;
+            }
+            entity->open = XML_FALSE;
+            if (!dtd->paramEntityRead)
+              dtd->keepProcessing = dtd->standalone;
+          }
+          else
+            dtd->keepProcessing = dtd->standalone;
+        }
+        else {
+          entity->open = XML_TRUE;
+          result = storeEntityValue(parser,
+                                    internalEncoding,
+                                    (char *)entity->textPtr,
+                                    (char *)(entity->textPtr
+                                             + entity->textLen));
+          entity->open = XML_FALSE;
+          if (result)
+            goto endEntityValue;
+        }
+        break;
+      }
+#endif /* XML_DTD */
+      /* In the internal subset, PE references are not legal
+         within markup declarations, e.g entity values in this case. */
+      eventPtr = entityTextPtr;
+      result = XML_ERROR_PARAM_ENTITY_REF;
+      goto endEntityValue;
+    case XML_TOK_NONE:
+      result = XML_ERROR_NONE;
+      goto endEntityValue;
+    case XML_TOK_ENTITY_REF:
+    case XML_TOK_DATA_CHARS:
+      if (!poolAppend(pool, enc, entityTextPtr, next)) {
+        result = XML_ERROR_NO_MEMORY;
+        goto endEntityValue;
+      }
+      break;
+    case XML_TOK_TRAILING_CR:
+      next = entityTextPtr + enc->minBytesPerChar;
+      /* fall through */
+    case XML_TOK_DATA_NEWLINE:
+      if (pool->end == pool->ptr && !poolGrow(pool)) {
+              result = XML_ERROR_NO_MEMORY;
+        goto endEntityValue;
+      }
+      *(pool->ptr)++ = 0xA;
+      break;
+    case XML_TOK_CHAR_REF:
+      {
+        XML_Char buf[XML_ENCODE_MAX];
+        int i;
+        int n = XmlCharRefNumber(enc, entityTextPtr);
+        if (n < 0) {
+          if (enc == encoding)
+            eventPtr = entityTextPtr;
+          result = XML_ERROR_BAD_CHAR_REF;
+          goto endEntityValue;
+        }
+        n = XmlEncode(n, (ICHAR *)buf);
+        if (!n) {
+          if (enc == encoding)
+            eventPtr = entityTextPtr;
+          result = XML_ERROR_BAD_CHAR_REF;
+          goto endEntityValue;
+        }
+        for (i = 0; i < n; i++) {
+          if (pool->end == pool->ptr && !poolGrow(pool)) {
+            result = XML_ERROR_NO_MEMORY;
+            goto endEntityValue;
+          }
+          *(pool->ptr)++ = buf[i];
+        }
+      }
+      break;
+    case XML_TOK_PARTIAL:
+      if (enc == encoding)
+        eventPtr = entityTextPtr;
+      result = XML_ERROR_INVALID_TOKEN;
+      goto endEntityValue;
+    case XML_TOK_INVALID:
+      if (enc == encoding)
+        eventPtr = next;
+      result = XML_ERROR_INVALID_TOKEN;
+      goto endEntityValue;
+    default:
+      if (enc == encoding)
+        eventPtr = entityTextPtr;
+      result = XML_ERROR_UNEXPECTED_STATE;
+      goto endEntityValue;
+    }
+    entityTextPtr = next;
+  }
+endEntityValue:
+#ifdef XML_DTD
+  prologState.inEntityValue = oldInEntityValue;
+#endif /* XML_DTD */
+  return result;
+}
+
+static void FASTCALL
+normalizeLines(XML_Char *s)
+{
+  XML_Char *p;
+  for (;; s++) {
+    if (*s == XML_T('\0'))
+      return;
+    if (*s == 0xD)
+      break;
+  }
+  p = s;
+  do {
+    if (*s == 0xD) {
+      *p++ = 0xA;
+      if (*++s == 0xA)
+        s++;
+    }
+    else
+      *p++ = *s++;
+  } while (*s);
+  *p = XML_T('\0');
+}
+
+static int
+reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
+                            const char *start, const char *end)
+{
+  const XML_Char *target;
+  XML_Char *data;
+  const char *tem;
+  if (!processingInstructionHandler) {
+    if (defaultHandler)
+      reportDefault(parser, enc, start, end);
+    return 1;
+  }
+  start += enc->minBytesPerChar * 2;
+  tem = start + XmlNameLength(enc, start);
+  target = poolStoreString(&tempPool, enc, start, tem);
+  if (!target)
+    return 0;
+  poolFinish(&tempPool);
+  data = poolStoreString(&tempPool, enc,
+                        XmlSkipS(enc, tem),
+                        end - enc->minBytesPerChar*2);
+  if (!data)
+    return 0;
+  normalizeLines(data);
+  processingInstructionHandler(handlerArg, target, data);
+  poolClear(&tempPool);
+  return 1;
+}
+
+static int
+reportComment(XML_Parser parser, const ENCODING *enc,
+              const char *start, const char *end)
+{
+  XML_Char *data;
+  if (!commentHandler) {
+    if (defaultHandler)
+      reportDefault(parser, enc, start, end);
+    return 1;
+  }
+  data = poolStoreString(&tempPool,
+                         enc,
+                         start + enc->minBytesPerChar * 4,
+                         end - enc->minBytesPerChar * 3);
+  if (!data)
+    return 0;
+  normalizeLines(data);
+  commentHandler(handlerArg, data);
+  poolClear(&tempPool);
+  return 1;
+}
+
+static void
+reportDefault(XML_Parser parser, const ENCODING *enc,
+              const char *s, const char *end)
+{
+  if (MUST_CONVERT(enc, s)) {
+    enum XML_Convert_Result convert_res;
+    const char **eventPP;
+    const char **eventEndPP;
+    if (enc == encoding) {
+      eventPP = &eventPtr;
+      eventEndPP = &eventEndPtr;
+    }
+    else {
+      eventPP = &(openInternalEntities->internalEventPtr);
+      eventEndPP = &(openInternalEntities->internalEventEndPtr);
+    }
+    do {
+      ICHAR *dataPtr = (ICHAR *)dataBuf;
+      convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
+      *eventEndPP = s;
+      defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf));
+      *eventPP = s;
+    } while ((convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE));
+  }
+  else
+    defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s));
+}
+
+
+static int
+defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
+                XML_Bool isId, const XML_Char *value, XML_Parser parser)
+{
+  DEFAULT_ATTRIBUTE *att;
+  if (value || isId) {
+    /* The handling of default attributes gets messed up if we have
+       a default which duplicates a non-default. */
+    int i;
+    for (i = 0; i < type->nDefaultAtts; i++)
+      if (attId == type->defaultAtts[i].id)
+        return 1;
+    if (isId && !type->idAtt && !attId->xmlns)
+      type->idAtt = attId;
+  }
+  if (type->nDefaultAtts == type->allocDefaultAtts) {
+    if (type->allocDefaultAtts == 0) {
+      type->allocDefaultAtts = 8;
+      type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts
+                            * sizeof(DEFAULT_ATTRIBUTE));
+      if (!type->defaultAtts)
+        return 0;
+    }
+    else {
+      DEFAULT_ATTRIBUTE *temp;
+      int count = type->allocDefaultAtts * 2;
+      temp = (DEFAULT_ATTRIBUTE *)
+        REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE)));
+      if (temp == NULL)
+        return 0;
+      type->allocDefaultAtts = count;
+      type->defaultAtts = temp;
+    }
+  }
+  att = type->defaultAtts + type->nDefaultAtts;
+  att->id = attId;
+  att->value = value;
+  att->isCdata = isCdata;
+  if (!isCdata)
+    attId->maybeTokenized = XML_TRUE;
+  type->nDefaultAtts += 1;
+  return 1;
+}
+
+static int
+setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  const XML_Char *name;
+  for (name = elementType->name; *name; name++) {
+    if (*name == XML_T(ASCII_COLON)) {
+      PREFIX *prefix;
+      const XML_Char *s;
+      for (s = elementType->name; s != name; s++) {
+        if (!poolAppendChar(&dtd->pool, *s))
+          return 0;
+      }
+      if (!poolAppendChar(&dtd->pool, XML_T('\0')))
+        return 0;
+      prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
+                                sizeof(PREFIX));
+      if (!prefix)
+        return 0;
+      if (prefix->name == poolStart(&dtd->pool))
+        poolFinish(&dtd->pool);
+      else
+        poolDiscard(&dtd->pool);
+      elementType->prefix = prefix;
+
+    }
+  }
+  return 1;
+}
+
+static ATTRIBUTE_ID *
+getAttributeId(XML_Parser parser, const ENCODING *enc,
+               const char *start, const char *end)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  ATTRIBUTE_ID *id;
+  const XML_Char *name;
+  if (!poolAppendChar(&dtd->pool, XML_T('\0')))
+    return NULL;
+  name = poolStoreString(&dtd->pool, enc, start, end);
+  if (!name)
+    return NULL;
+  /* skip quotation mark - its storage will be re-used (like in name[-1]) */
+  ++name;
+  id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID));
+  if (!id)
+    return NULL;
+  if (id->name != name)
+    poolDiscard(&dtd->pool);
+  else {
+    poolFinish(&dtd->pool);
+    if (!ns)
+      ;
+    else if (name[0] == XML_T(ASCII_x)
+        && name[1] == XML_T(ASCII_m)
+        && name[2] == XML_T(ASCII_l)
+        && name[3] == XML_T(ASCII_n)
+        && name[4] == XML_T(ASCII_s)
+        && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) {
+      if (name[5] == XML_T('\0'))
+        id->prefix = &dtd->defaultPrefix;
+      else
+        id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX));
+      id->xmlns = XML_TRUE;
+    }
+    else {
+      int i;
+      for (i = 0; name[i]; i++) {
+        /* attributes without prefix are *not* in the default namespace */
+        if (name[i] == XML_T(ASCII_COLON)) {
+          int j;
+          for (j = 0; j < i; j++) {
+            if (!poolAppendChar(&dtd->pool, name[j]))
+              return NULL;
+          }
+          if (!poolAppendChar(&dtd->pool, XML_T('\0')))
+            return NULL;
+          id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
+                                        sizeof(PREFIX));
+          if (!id->prefix)
+            return NULL;
+          if (id->prefix->name == poolStart(&dtd->pool))
+            poolFinish(&dtd->pool);
+          else
+            poolDiscard(&dtd->pool);
+          break;
+        }
+      }
+    }
+  }
+  return id;
+}
+
+#define CONTEXT_SEP XML_T(ASCII_FF)
+
+static const XML_Char *
+getContext(XML_Parser parser)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  HASH_TABLE_ITER iter;
+  XML_Bool needSep = XML_FALSE;
+
+  if (dtd->defaultPrefix.binding) {
+    int i;
+    int len;
+    if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS)))
+      return NULL;
+    len = dtd->defaultPrefix.binding->uriLen;
+    if (namespaceSeparator)
+      len--;
+    for (i = 0; i < len; i++)
+      if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i]))
+        return NULL;
+    needSep = XML_TRUE;
+  }
+
+  hashTableIterInit(&iter, &(dtd->prefixes));
+  for (;;) {
+    int i;
+    int len;
+    const XML_Char *s;
+    PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter);
+    if (!prefix)
+      break;
+    if (!prefix->binding)
+      continue;
+    if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
+      return NULL;
+    for (s = prefix->name; *s; s++)
+      if (!poolAppendChar(&tempPool, *s))
+        return NULL;
+    if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS)))
+      return NULL;
+    len = prefix->binding->uriLen;
+    if (namespaceSeparator)
+      len--;
+    for (i = 0; i < len; i++)
+      if (!poolAppendChar(&tempPool, prefix->binding->uri[i]))
+        return NULL;
+    needSep = XML_TRUE;
+  }
+
+
+  hashTableIterInit(&iter, &(dtd->generalEntities));
+  for (;;) {
+    const XML_Char *s;
+    ENTITY *e = (ENTITY *)hashTableIterNext(&iter);
+    if (!e)
+      break;
+    if (!e->open)
+      continue;
+    if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
+      return NULL;
+    for (s = e->name; *s; s++)
+      if (!poolAppendChar(&tempPool, *s))
+        return 0;
+    needSep = XML_TRUE;
+  }
+
+  if (!poolAppendChar(&tempPool, XML_T('\0')))
+    return NULL;
+  return tempPool.start;
+}
+
+static XML_Bool
+setContext(XML_Parser parser, const XML_Char *context)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  const XML_Char *s = context;
+
+  while (*context != XML_T('\0')) {
+    if (*s == CONTEXT_SEP || *s == XML_T('\0')) {
+      ENTITY *e;
+      if (!poolAppendChar(&tempPool, XML_T('\0')))
+        return XML_FALSE;
+      e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0);
+      if (e)
+        e->open = XML_TRUE;
+      if (*s != XML_T('\0'))
+        s++;
+      context = s;
+      poolDiscard(&tempPool);
+    }
+    else if (*s == XML_T(ASCII_EQUALS)) {
+      PREFIX *prefix;
+      if (poolLength(&tempPool) == 0)
+        prefix = &dtd->defaultPrefix;
+      else {
+        if (!poolAppendChar(&tempPool, XML_T('\0')))
+          return XML_FALSE;
+        prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&tempPool),
+                                  sizeof(PREFIX));
+        if (!prefix)
+          return XML_FALSE;
+        if (prefix->name == poolStart(&tempPool)) {
+          prefix->name = poolCopyString(&dtd->pool, prefix->name);
+          if (!prefix->name)
+            return XML_FALSE;
+        }
+        poolDiscard(&tempPool);
+      }
+      for (context = s + 1;
+           *context != CONTEXT_SEP && *context != XML_T('\0');
+           context++)
+        if (!poolAppendChar(&tempPool, *context))
+          return XML_FALSE;
+      if (!poolAppendChar(&tempPool, XML_T('\0')))
+        return XML_FALSE;
+      if (addBinding(parser, prefix, NULL, poolStart(&tempPool),
+                     &inheritedBindings) != XML_ERROR_NONE)
+        return XML_FALSE;
+      poolDiscard(&tempPool);
+      if (*context != XML_T('\0'))
+        ++context;
+      s = context;
+    }
+    else {
+      if (!poolAppendChar(&tempPool, *s))
+        return XML_FALSE;
+      s++;
+    }
+  }
+  return XML_TRUE;
+}
+
+static void FASTCALL
+normalizePublicId(XML_Char *publicId)
+{
+  XML_Char *p = publicId;
+  XML_Char *s;
+  for (s = publicId; *s; s++) {
+    switch (*s) {
+    case 0x20:
+    case 0xD:
+    case 0xA:
+      if (p != publicId && p[-1] != 0x20)
+        *p++ = 0x20;
+      break;
+    default:
+      *p++ = *s;
+    }
+  }
+  if (p != publicId && p[-1] == 0x20)
+    --p;
+  *p = XML_T('\0');
+}
+
+static DTD *
+dtdCreate(const XML_Memory_Handling_Suite *ms)
+{
+  DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD));
+  if (p == NULL)
+    return p;
+  poolInit(&(p->pool), ms);
+  poolInit(&(p->entityValuePool), ms);
+  hashTableInit(&(p->generalEntities), ms);
+  hashTableInit(&(p->elementTypes), ms);
+  hashTableInit(&(p->attributeIds), ms);
+  hashTableInit(&(p->prefixes), ms);
+#ifdef XML_DTD
+  p->paramEntityRead = XML_FALSE;
+  hashTableInit(&(p->paramEntities), ms);
+#endif /* XML_DTD */
+  p->defaultPrefix.name = NULL;
+  p->defaultPrefix.binding = NULL;
+
+  p->in_eldecl = XML_FALSE;
+  p->scaffIndex = NULL;
+  p->scaffold = NULL;
+  p->scaffLevel = 0;
+  p->scaffSize = 0;
+  p->scaffCount = 0;
+  p->contentStringLen = 0;
+
+  p->keepProcessing = XML_TRUE;
+  p->hasParamEntityRefs = XML_FALSE;
+  p->standalone = XML_FALSE;
+  return p;
+}
+
+static void
+dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms)
+{
+  HASH_TABLE_ITER iter;
+  hashTableIterInit(&iter, &(p->elementTypes));
+  for (;;) {
+    ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);
+    if (!e)
+      break;
+    if (e->allocDefaultAtts != 0)
+      ms->free_fcn(e->defaultAtts);
+  }
+  hashTableClear(&(p->generalEntities));
+#ifdef XML_DTD
+  p->paramEntityRead = XML_FALSE;
+  hashTableClear(&(p->paramEntities));
+#endif /* XML_DTD */
+  hashTableClear(&(p->elementTypes));
+  hashTableClear(&(p->attributeIds));
+  hashTableClear(&(p->prefixes));
+  poolClear(&(p->pool));
+  poolClear(&(p->entityValuePool));
+  p->defaultPrefix.name = NULL;
+  p->defaultPrefix.binding = NULL;
+
+  p->in_eldecl = XML_FALSE;
+
+  ms->free_fcn(p->scaffIndex);
+  p->scaffIndex = NULL;
+  ms->free_fcn(p->scaffold);
+  p->scaffold = NULL;
+
+  p->scaffLevel = 0;
+  p->scaffSize = 0;
+  p->scaffCount = 0;
+  p->contentStringLen = 0;
+
+  p->keepProcessing = XML_TRUE;
+  p->hasParamEntityRefs = XML_FALSE;
+  p->standalone = XML_FALSE;
+}
+
+static void
+dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms)
+{
+  HASH_TABLE_ITER iter;
+  hashTableIterInit(&iter, &(p->elementTypes));
+  for (;;) {
+    ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);
+    if (!e)
+      break;
+    if (e->allocDefaultAtts != 0)
+      ms->free_fcn(e->defaultAtts);
+  }
+  hashTableDestroy(&(p->generalEntities));
+#ifdef XML_DTD
+  hashTableDestroy(&(p->paramEntities));
+#endif /* XML_DTD */
+  hashTableDestroy(&(p->elementTypes));
+  hashTableDestroy(&(p->attributeIds));
+  hashTableDestroy(&(p->prefixes));
+  poolDestroy(&(p->pool));
+  poolDestroy(&(p->entityValuePool));
+  if (isDocEntity) {
+    ms->free_fcn(p->scaffIndex);
+    ms->free_fcn(p->scaffold);
+  }
+  ms->free_fcn(p);
+}
+
+/* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise.
+   The new DTD has already been initialized.
+*/
+static int
+dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms)
+{
+  HASH_TABLE_ITER iter;
+
+  /* Copy the prefix table. */
+
+  hashTableIterInit(&iter, &(oldDtd->prefixes));
+  for (;;) {
+    const XML_Char *name;
+    const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter);
+    if (!oldP)
+      break;
+    name = poolCopyString(&(newDtd->pool), oldP->name);
+    if (!name)
+      return 0;
+    if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX)))
+      return 0;
+  }
+
+  hashTableIterInit(&iter, &(oldDtd->attributeIds));
+
+  /* Copy the attribute id table. */
+
+  for (;;) {
+    ATTRIBUTE_ID *newA;
+    const XML_Char *name;
+    const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter);
+
+    if (!oldA)
+      break;
+    /* Remember to allocate the scratch byte before the name. */
+    if (!poolAppendChar(&(newDtd->pool), XML_T('\0')))
+      return 0;
+    name = poolCopyString(&(newDtd->pool), oldA->name);
+    if (!name)
+      return 0;
+    ++name;
+    newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name,
+                                  sizeof(ATTRIBUTE_ID));
+    if (!newA)
+      return 0;
+    newA->maybeTokenized = oldA->maybeTokenized;
+    if (oldA->prefix) {
+      newA->xmlns = oldA->xmlns;
+      if (oldA->prefix == &oldDtd->defaultPrefix)
+        newA->prefix = &newDtd->defaultPrefix;
+      else
+        newA->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes),
+                                        oldA->prefix->name, 0);
+    }
+  }
+
+  /* Copy the element type table. */
+
+  hashTableIterInit(&iter, &(oldDtd->elementTypes));
+
+  for (;;) {
+    int i;
+    ELEMENT_TYPE *newE;
+    const XML_Char *name;
+    const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter);
+    if (!oldE)
+      break;
+    name = poolCopyString(&(newDtd->pool), oldE->name);
+    if (!name)
+      return 0;
+    newE = (ELEMENT_TYPE *)lookup(oldParser, &(newDtd->elementTypes), name,
+                                  sizeof(ELEMENT_TYPE));
+    if (!newE)
+      return 0;
+    if (oldE->nDefaultAtts) {
+      newE->defaultAtts = (DEFAULT_ATTRIBUTE *)
+          ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
+      if (!newE->defaultAtts) {
+        ms->free_fcn(newE);
+        return 0;
+      }
+    }
+    if (oldE->idAtt)
+      newE->idAtt = (ATTRIBUTE_ID *)
+          lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0);
+    newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts;
+    if (oldE->prefix)
+      newE->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes),
+                                      oldE->prefix->name, 0);
+    for (i = 0; i < newE->nDefaultAtts; i++) {
+      newE->defaultAtts[i].id = (ATTRIBUTE_ID *)
+          lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0);
+      newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata;
+      if (oldE->defaultAtts[i].value) {
+        newE->defaultAtts[i].value
+            = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value);
+        if (!newE->defaultAtts[i].value)
+          return 0;
+      }
+      else
+        newE->defaultAtts[i].value = NULL;
+    }
+  }
+
+  /* Copy the entity tables. */
+  if (!copyEntityTable(oldParser,
+                       &(newDtd->generalEntities),
+                       &(newDtd->pool),
+                       &(oldDtd->generalEntities)))
+      return 0;
+
+#ifdef XML_DTD
+  if (!copyEntityTable(oldParser,
+                       &(newDtd->paramEntities),
+                       &(newDtd->pool),
+                       &(oldDtd->paramEntities)))
+      return 0;
+  newDtd->paramEntityRead = oldDtd->paramEntityRead;
+#endif /* XML_DTD */
+
+  newDtd->keepProcessing = oldDtd->keepProcessing;
+  newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs;
+  newDtd->standalone = oldDtd->standalone;
+
+  /* Don't want deep copying for scaffolding */
+  newDtd->in_eldecl = oldDtd->in_eldecl;
+  newDtd->scaffold = oldDtd->scaffold;
+  newDtd->contentStringLen = oldDtd->contentStringLen;
+  newDtd->scaffSize = oldDtd->scaffSize;
+  newDtd->scaffLevel = oldDtd->scaffLevel;
+  newDtd->scaffIndex = oldDtd->scaffIndex;
+
+  return 1;
+}  /* End dtdCopy */
+
+static int
+copyEntityTable(XML_Parser oldParser,
+                HASH_TABLE *newTable,
+                STRING_POOL *newPool,
+                const HASH_TABLE *oldTable)
+{
+  HASH_TABLE_ITER iter;
+  const XML_Char *cachedOldBase = NULL;
+  const XML_Char *cachedNewBase = NULL;
+
+  hashTableIterInit(&iter, oldTable);
+
+  for (;;) {
+    ENTITY *newE;
+    const XML_Char *name;
+    const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter);
+    if (!oldE)
+      break;
+    name = poolCopyString(newPool, oldE->name);
+    if (!name)
+      return 0;
+    newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY));
+    if (!newE)
+      return 0;
+    if (oldE->systemId) {
+      const XML_Char *tem = poolCopyString(newPool, oldE->systemId);
+      if (!tem)
+        return 0;
+      newE->systemId = tem;
+      if (oldE->base) {
+        if (oldE->base == cachedOldBase)
+          newE->base = cachedNewBase;
+        else {
+          cachedOldBase = oldE->base;
+          tem = poolCopyString(newPool, cachedOldBase);
+          if (!tem)
+            return 0;
+          cachedNewBase = newE->base = tem;
+        }
+      }
+      if (oldE->publicId) {
+        tem = poolCopyString(newPool, oldE->publicId);
+        if (!tem)
+          return 0;
+        newE->publicId = tem;
+      }
+    }
+    else {
+      const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr,
+                                            oldE->textLen);
+      if (!tem)
+        return 0;
+      newE->textPtr = tem;
+      newE->textLen = oldE->textLen;
+    }
+    if (oldE->notation) {
+      const XML_Char *tem = poolCopyString(newPool, oldE->notation);
+      if (!tem)
+        return 0;
+      newE->notation = tem;
+    }
+    newE->is_param = oldE->is_param;
+    newE->is_internal = oldE->is_internal;
+  }
+  return 1;
+}
+
+#define INIT_POWER 6
+
+static XML_Bool FASTCALL
+keyeq(KEY s1, KEY s2)
+{
+  for (; *s1 == *s2; s1++, s2++)
+    if (*s1 == 0)
+      return XML_TRUE;
+  return XML_FALSE;
+}
+
+static unsigned long FASTCALL
+hash(XML_Parser parser, KEY s)
+{
+  unsigned long h = hash_secret_salt;
+  while (*s)
+    h = CHAR_HASH(h, *s++);
+  return h;
+}
+
+static NAMED *
+lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
+{
+  size_t i;
+  if (table->size == 0) {
+    size_t tsize;
+    if (!createSize)
+      return NULL;
+    table->power = INIT_POWER;
+    /* table->size is a power of 2 */
+    table->size = (size_t)1 << INIT_POWER;
+    tsize = table->size * sizeof(NAMED *);
+    table->v = (NAMED **)table->mem->malloc_fcn(tsize);
+    if (!table->v) {
+      table->size = 0;
+      return NULL;
+    }
+    memset(table->v, 0, tsize);
+    i = hash(parser, name) & ((unsigned long)table->size - 1);
+  }
+  else {
+    unsigned long h = hash(parser, name);
+    unsigned long mask = (unsigned long)table->size - 1;
+    unsigned char step = 0;
+    i = h & mask;
+    while (table->v[i]) {
+      if (keyeq(name, table->v[i]->name))
+        return table->v[i];
+      if (!step)
+        step = PROBE_STEP(h, mask, table->power);
+      i < step ? (i += table->size - step) : (i -= step);
+    }
+    if (!createSize)
+      return NULL;
+
+    /* check for overflow (table is half full) */
+    if (table->used >> (table->power - 1)) {
+      unsigned char newPower = table->power + 1;
+      size_t newSize = (size_t)1 << newPower;
+      unsigned long newMask = (unsigned long)newSize - 1;
+      size_t tsize = newSize * sizeof(NAMED *);
+      NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize);
+      if (!newV)
+        return NULL;
+      memset(newV, 0, tsize);
+      for (i = 0; i < table->size; i++)
+        if (table->v[i]) {
+          unsigned long newHash = hash(parser, table->v[i]->name);
+          size_t j = newHash & newMask;
+          step = 0;
+          while (newV[j]) {
+            if (!step)
+              step = PROBE_STEP(newHash, newMask, newPower);
+            j < step ? (j += newSize - step) : (j -= step);
+          }
+          newV[j] = table->v[i];
+        }
+      table->mem->free_fcn(table->v);
+      table->v = newV;
+      table->power = newPower;
+      table->size = newSize;
+      i = h & newMask;
+      step = 0;
+      while (table->v[i]) {
+        if (!step)
+          step = PROBE_STEP(h, newMask, newPower);
+        i < step ? (i += newSize - step) : (i -= step);
+      }
+    }
+  }
+  table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize);
+  if (!table->v[i])
+    return NULL;
+  memset(table->v[i], 0, createSize);
+  table->v[i]->name = name;
+  (table->used)++;
+  return table->v[i];
+}
+
+static void FASTCALL
+hashTableClear(HASH_TABLE *table)
+{
+  size_t i;
+  for (i = 0; i < table->size; i++) {
+    table->mem->free_fcn(table->v[i]);
+    table->v[i] = NULL;
+  }
+  table->used = 0;
+}
+
+static void FASTCALL
+hashTableDestroy(HASH_TABLE *table)
+{
+  size_t i;
+  for (i = 0; i < table->size; i++)
+    table->mem->free_fcn(table->v[i]);
+  table->mem->free_fcn(table->v);
+}
+
+static void FASTCALL
+hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms)
+{
+  p->power = 0;
+  p->size = 0;
+  p->used = 0;
+  p->v = NULL;
+  p->mem = ms;
+}
+
+static void FASTCALL
+hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
+{
+  iter->p = table->v;
+  iter->end = iter->p + table->size;
+}
+
+static NAMED * FASTCALL
+hashTableIterNext(HASH_TABLE_ITER *iter)
+{
+  while (iter->p != iter->end) {
+    NAMED *tem = *(iter->p)++;
+    if (tem)
+      return tem;
+  }
+  return NULL;
+}
+
+static void FASTCALL
+poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms)
+{
+  pool->blocks = NULL;
+  pool->freeBlocks = NULL;
+  pool->start = NULL;
+  pool->ptr = NULL;
+  pool->end = NULL;
+  pool->mem = ms;
+}
+
+static void FASTCALL
+poolClear(STRING_POOL *pool)
+{
+  if (!pool->freeBlocks)
+    pool->freeBlocks = pool->blocks;
+  else {
+    BLOCK *p = pool->blocks;
+    while (p) {
+      BLOCK *tem = p->next;
+      p->next = pool->freeBlocks;
+      pool->freeBlocks = p;
+      p = tem;
+    }
+  }
+  pool->blocks = NULL;
+  pool->start = NULL;
+  pool->ptr = NULL;
+  pool->end = NULL;
+}
+
+static void FASTCALL
+poolDestroy(STRING_POOL *pool)
+{
+  BLOCK *p = pool->blocks;
+  while (p) {
+    BLOCK *tem = p->next;
+    pool->mem->free_fcn(p);
+    p = tem;
+  }
+  p = pool->freeBlocks;
+  while (p) {
+    BLOCK *tem = p->next;
+    pool->mem->free_fcn(p);
+    p = tem;
+  }
+}
+
+static XML_Char *
+poolAppend(STRING_POOL *pool, const ENCODING *enc,
+           const char *ptr, const char *end)
+{
+  if (!pool->ptr && !poolGrow(pool))
+    return NULL;
+  for (;;) {
+    const enum XML_Convert_Result convert_res = XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end);
+    if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
+      break;
+    if (!poolGrow(pool))
+      return NULL;
+  }
+  return pool->start;
+}
+
+static const XML_Char * FASTCALL
+poolCopyString(STRING_POOL *pool, const XML_Char *s)
+{
+  do {
+    if (!poolAppendChar(pool, *s))
+      return NULL;
+  } while (*s++);
+  s = pool->start;
+  poolFinish(pool);
+  return s;
+}
+
+static const XML_Char *
+poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n)
+{
+  if (!pool->ptr && !poolGrow(pool))
+    return NULL;
+  for (; n > 0; --n, s++) {
+    if (!poolAppendChar(pool, *s))
+      return NULL;
+  }
+  s = pool->start;
+  poolFinish(pool);
+  return s;
+}
+
+static const XML_Char * FASTCALL
+poolAppendString(STRING_POOL *pool, const XML_Char *s)
+{
+  while (*s) {
+    if (!poolAppendChar(pool, *s))
+      return NULL;
+    s++;
+  }
+  return pool->start;
+}
+
+static XML_Char *
+poolStoreString(STRING_POOL *pool, const ENCODING *enc,
+                const char *ptr, const char *end)
+{
+  if (!poolAppend(pool, enc, ptr, end))
+    return NULL;
+  if (pool->ptr == pool->end && !poolGrow(pool))
+    return NULL;
+  *(pool->ptr)++ = 0;
+  return pool->start;
+}
+
+static XML_Bool FASTCALL
+poolGrow(STRING_POOL *pool)
+{
+  if (pool->freeBlocks) {
+    if (pool->start == 0) {
+      pool->blocks = pool->freeBlocks;
+      pool->freeBlocks = pool->freeBlocks->next;
+      pool->blocks->next = NULL;
+      pool->start = pool->blocks->s;
+      pool->end = pool->start + pool->blocks->size;
+      pool->ptr = pool->start;
+      return XML_TRUE;
+    }
+    if (pool->end - pool->start < pool->freeBlocks->size) {
+      BLOCK *tem = pool->freeBlocks->next;
+      pool->freeBlocks->next = pool->blocks;
+      pool->blocks = pool->freeBlocks;
+      pool->freeBlocks = tem;
+      memcpy(pool->blocks->s, pool->start,
+             (pool->end - pool->start) * sizeof(XML_Char));
+      pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
+      pool->start = pool->blocks->s;
+      pool->end = pool->start + pool->blocks->size;
+      return XML_TRUE;
+    }
+  }
+  if (pool->blocks && pool->start == pool->blocks->s) {
+    BLOCK *temp;
+    int blockSize = (int)((unsigned)(pool->end - pool->start)*2U);
+
+    if (blockSize < 0)
+      return XML_FALSE;
+
+    temp = (BLOCK *)
+      pool->mem->realloc_fcn(pool->blocks,
+                             (offsetof(BLOCK, s)
+                              + blockSize * sizeof(XML_Char)));
+    if (temp == NULL)
+      return XML_FALSE;
+    pool->blocks = temp;
+    pool->blocks->size = blockSize;
+    pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
+    pool->start = pool->blocks->s;
+    pool->end = pool->start + blockSize;
+  }
+  else {
+    BLOCK *tem;
+    int blockSize = (int)(pool->end - pool->start);
+
+    if (blockSize < 0)
+      return XML_FALSE;
+
+    if (blockSize < INIT_BLOCK_SIZE)
+      blockSize = INIT_BLOCK_SIZE;
+    else
+      blockSize *= 2;
+    tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s)
+                                        + blockSize * sizeof(XML_Char));
+    if (!tem)
+      return XML_FALSE;
+    tem->size = blockSize;
+    tem->next = pool->blocks;
+    pool->blocks = tem;
+    if (pool->ptr != pool->start)
+      memcpy(tem->s, pool->start,
+             (pool->ptr - pool->start) * sizeof(XML_Char));
+    pool->ptr = tem->s + (pool->ptr - pool->start);
+    pool->start = tem->s;
+    pool->end = tem->s + blockSize;
+  }
+  return XML_TRUE;
+}
+
+static int FASTCALL
+nextScaffoldPart(XML_Parser parser)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  CONTENT_SCAFFOLD * me;
+  int next;
+
+  if (!dtd->scaffIndex) {
+    dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int));
+    if (!dtd->scaffIndex)
+      return -1;
+    dtd->scaffIndex[0] = 0;
+  }
+
+  if (dtd->scaffCount >= dtd->scaffSize) {
+    CONTENT_SCAFFOLD *temp;
+    if (dtd->scaffold) {
+      temp = (CONTENT_SCAFFOLD *)
+        REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD));
+      if (temp == NULL)
+        return -1;
+      dtd->scaffSize *= 2;
+    }
+    else {
+      temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS
+                                        * sizeof(CONTENT_SCAFFOLD));
+      if (temp == NULL)
+        return -1;
+      dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS;
+    }
+    dtd->scaffold = temp;
+  }
+  next = dtd->scaffCount++;
+  me = &dtd->scaffold[next];
+  if (dtd->scaffLevel) {
+    CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]];
+    if (parent->lastchild) {
+      dtd->scaffold[parent->lastchild].nextsib = next;
+    }
+    if (!parent->childcnt)
+      parent->firstchild = next;
+    parent->lastchild = next;
+    parent->childcnt++;
+  }
+  me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0;
+  return next;
+}
+
+static void
+build_node(XML_Parser parser,
+           int src_node,
+           XML_Content *dest,
+           XML_Content **contpos,
+           XML_Char **strpos)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  dest->type = dtd->scaffold[src_node].type;
+  dest->quant = dtd->scaffold[src_node].quant;
+  if (dest->type == XML_CTYPE_NAME) {
+    const XML_Char *src;
+    dest->name = *strpos;
+    src = dtd->scaffold[src_node].name;
+    for (;;) {
+      *(*strpos)++ = *src;
+      if (!*src)
+        break;
+      src++;
+    }
+    dest->numchildren = 0;
+    dest->children = NULL;
+  }
+  else {
+    unsigned int i;
+    int cn;
+    dest->numchildren = dtd->scaffold[src_node].childcnt;
+    dest->children = *contpos;
+    *contpos += dest->numchildren;
+    for (i = 0, cn = dtd->scaffold[src_node].firstchild;
+         i < dest->numchildren;
+         i++, cn = dtd->scaffold[cn].nextsib) {
+      build_node(parser, cn, &(dest->children[i]), contpos, strpos);
+    }
+    dest->name = NULL;
+  }
+}
+
+static XML_Content *
+build_model (XML_Parser parser)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  XML_Content *ret;
+  XML_Content *cpos;
+  XML_Char * str;
+  int allocsize = (dtd->scaffCount * sizeof(XML_Content)
+                   + (dtd->contentStringLen * sizeof(XML_Char)));
+
+  ret = (XML_Content *)MALLOC(allocsize);
+  if (!ret)
+    return NULL;
+
+  str =  (XML_Char *) (&ret[dtd->scaffCount]);
+  cpos = &ret[1];
+
+  build_node(parser, 0, ret, &cpos, &str);
+  return ret;
+}
+
+static ELEMENT_TYPE *
+getElementType(XML_Parser parser,
+               const ENCODING *enc,
+               const char *ptr,
+               const char *end)
+{
+  DTD * const dtd = _dtd;  /* save one level of indirection */
+  const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end);
+  ELEMENT_TYPE *ret;
+
+  if (!name)
+    return NULL;
+  ret = (ELEMENT_TYPE *) lookup(parser, &dtd->elementTypes, name, sizeof(ELEMENT_TYPE));
+  if (!ret)
+    return NULL;
+  if (ret->name != name)
+    poolDiscard(&dtd->pool);
+  else {
+    poolFinish(&dtd->pool);
+    if (!setElementTypePrefix(parser, ret))
+      return NULL;
+  }
+  return ret;
+}
diff --git a/Utilities/cmexpat/lib/xmlrole.c b/Utilities/cmexpat/lib/xmlrole.c
new file mode 100644
index 0000000..4e79ffd
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmlrole.c
@@ -0,0 +1,1336 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#include <stddef.h>
+
+#ifdef COMPILING_FOR_WINDOWS
+#include "winconfig.h"
+#elif defined(MACOS_CLASSIC)
+#include "macconfig.h"
+#elif defined(__amigaos__)
+#include "amigaconfig.h"
+#elif defined(__WATCOMC__)
+#include "watcomconfig.h"
+#else
+#ifdef HAVE_EXPAT_CONFIG_H
+#include <expat_config.h>
+#endif
+#endif /* ndef COMPILING_FOR_WINDOWS */
+
+#include "expat_external.h"
+#include "internal.h"
+#include "xmlrole.h"
+#include "ascii.h"
+
+/* Doesn't check:
+
+ that ,| are not mixed in a model group
+ content of literals
+
+*/
+
+static const char KW_ANY[] = {
+    ASCII_A, ASCII_N, ASCII_Y, '\0' };
+static const char KW_ATTLIST[] = {
+    ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' };
+static const char KW_CDATA[] = {
+    ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
+static const char KW_DOCTYPE[] = {
+    ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' };
+static const char KW_ELEMENT[] = {
+    ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' };
+static const char KW_EMPTY[] = {
+    ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' };
+static const char KW_ENTITIES[] = {
+    ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S,
+    '\0' };
+static const char KW_ENTITY[] = {
+    ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
+static const char KW_FIXED[] = {
+    ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' };
+static const char KW_ID[] = {
+    ASCII_I, ASCII_D, '\0' };
+static const char KW_IDREF[] = {
+    ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
+static const char KW_IDREFS[] = {
+    ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
+#ifdef XML_DTD
+static const char KW_IGNORE[] = {
+    ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
+#endif
+static const char KW_IMPLIED[] = {
+    ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
+#ifdef XML_DTD
+static const char KW_INCLUDE[] = {
+    ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
+#endif
+static const char KW_NDATA[] = {
+    ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
+static const char KW_NMTOKEN[] = {
+    ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
+static const char KW_NMTOKENS[] = {
+    ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S,
+    '\0' };
+static const char KW_NOTATION[] =
+    { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N,
+      '\0' };
+static const char KW_PCDATA[] = {
+    ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
+static const char KW_PUBLIC[] = {
+    ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' };
+static const char KW_REQUIRED[] = {
+    ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D,
+    '\0' };
+static const char KW_SYSTEM[] = {
+    ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' };
+
+#ifndef MIN_BYTES_PER_CHAR
+#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
+#endif
+
+#ifdef XML_DTD
+#define setTopLevel(state) \
+  ((state)->handler = ((state)->documentEntity \
+                       ? internalSubset \
+                       : externalSubset1))
+#else /* not XML_DTD */
+#define setTopLevel(state) ((state)->handler = internalSubset)
+#endif /* not XML_DTD */
+
+typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state,
+                                   int tok,
+                                   const char *ptr,
+                                   const char *end,
+                                   const ENCODING *enc);
+
+static PROLOG_HANDLER
+  prolog0, prolog1, prolog2,
+  doctype0, doctype1, doctype2, doctype3, doctype4, doctype5,
+  internalSubset,
+  entity0, entity1, entity2, entity3, entity4, entity5, entity6,
+  entity7, entity8, entity9, entity10,
+  notation0, notation1, notation2, notation3, notation4,
+  attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6,
+  attlist7, attlist8, attlist9,
+  element0, element1, element2, element3, element4, element5, element6,
+  element7,
+#ifdef XML_DTD
+  externalSubset0, externalSubset1,
+  condSect0, condSect1, condSect2,
+#endif /* XML_DTD */
+  declClose,
+  error;
+
+static int FASTCALL common(PROLOG_STATE *state, int tok);
+
+static int PTRCALL
+prolog0(PROLOG_STATE *state,
+        int tok,
+        const char *ptr,
+        const char *end,
+        const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    state->handler = prolog1;
+    return XML_ROLE_NONE;
+  case XML_TOK_XML_DECL:
+    state->handler = prolog1;
+    return XML_ROLE_XML_DECL;
+  case XML_TOK_PI:
+    state->handler = prolog1;
+    return XML_ROLE_PI;
+  case XML_TOK_COMMENT:
+    state->handler = prolog1;
+    return XML_ROLE_COMMENT;
+  case XML_TOK_BOM:
+    return XML_ROLE_NONE;
+  case XML_TOK_DECL_OPEN:
+    if (!XmlNameMatchesAscii(enc,
+                             ptr + 2 * MIN_BYTES_PER_CHAR(enc),
+                             end,
+                             KW_DOCTYPE))
+      break;
+    state->handler = doctype0;
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_INSTANCE_START:
+    state->handler = error;
+    return XML_ROLE_INSTANCE_START;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+prolog1(PROLOG_STATE *state,
+        int tok,
+        const char *ptr,
+        const char *end,
+        const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_PI:
+    return XML_ROLE_PI;
+  case XML_TOK_COMMENT:
+    return XML_ROLE_COMMENT;
+  case XML_TOK_BOM:
+    return XML_ROLE_NONE;
+  case XML_TOK_DECL_OPEN:
+    if (!XmlNameMatchesAscii(enc,
+                             ptr + 2 * MIN_BYTES_PER_CHAR(enc),
+                             end,
+                             KW_DOCTYPE))
+      break;
+    state->handler = doctype0;
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_INSTANCE_START:
+    state->handler = error;
+    return XML_ROLE_INSTANCE_START;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+prolog2(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_PI:
+    return XML_ROLE_PI;
+  case XML_TOK_COMMENT:
+    return XML_ROLE_COMMENT;
+  case XML_TOK_INSTANCE_START:
+    state->handler = error;
+    return XML_ROLE_INSTANCE_START;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+doctype0(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = doctype1;
+    return XML_ROLE_DOCTYPE_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+doctype1(PROLOG_STATE *state,
+         int tok,
+         const char *ptr,
+         const char *end,
+         const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_OPEN_BRACKET:
+    state->handler = internalSubset;
+    return XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
+  case XML_TOK_DECL_CLOSE:
+    state->handler = prolog2;
+    return XML_ROLE_DOCTYPE_CLOSE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
+      state->handler = doctype3;
+      return XML_ROLE_DOCTYPE_NONE;
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
+      state->handler = doctype2;
+      return XML_ROLE_DOCTYPE_NONE;
+    }
+    break;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+doctype2(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = doctype3;
+    return XML_ROLE_DOCTYPE_PUBLIC_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+doctype3(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = doctype4;
+    return XML_ROLE_DOCTYPE_SYSTEM_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+doctype4(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_OPEN_BRACKET:
+    state->handler = internalSubset;
+    return XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
+  case XML_TOK_DECL_CLOSE:
+    state->handler = prolog2;
+    return XML_ROLE_DOCTYPE_CLOSE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+doctype5(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_DECL_CLOSE:
+    state->handler = prolog2;
+    return XML_ROLE_DOCTYPE_CLOSE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+internalSubset(PROLOG_STATE *state,
+               int tok,
+               const char *ptr,
+               const char *end,
+               const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_DECL_OPEN:
+    if (XmlNameMatchesAscii(enc,
+                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_ENTITY)) {
+      state->handler = entity0;
+      return XML_ROLE_ENTITY_NONE;
+    }
+    if (XmlNameMatchesAscii(enc,
+                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_ATTLIST)) {
+      state->handler = attlist0;
+      return XML_ROLE_ATTLIST_NONE;
+    }
+    if (XmlNameMatchesAscii(enc,
+                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_ELEMENT)) {
+      state->handler = element0;
+      return XML_ROLE_ELEMENT_NONE;
+    }
+    if (XmlNameMatchesAscii(enc,
+                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_NOTATION)) {
+      state->handler = notation0;
+      return XML_ROLE_NOTATION_NONE;
+    }
+    break;
+  case XML_TOK_PI:
+    return XML_ROLE_PI;
+  case XML_TOK_COMMENT:
+    return XML_ROLE_COMMENT;
+  case XML_TOK_PARAM_ENTITY_REF:
+    return XML_ROLE_PARAM_ENTITY_REF;
+  case XML_TOK_CLOSE_BRACKET:
+    state->handler = doctype5;
+    return XML_ROLE_DOCTYPE_NONE;
+  case XML_TOK_NONE:
+    return XML_ROLE_NONE;
+  }
+  return common(state, tok);
+}
+
+#ifdef XML_DTD
+
+static int PTRCALL
+externalSubset0(PROLOG_STATE *state,
+                int tok,
+                const char *ptr,
+                const char *end,
+                const ENCODING *enc)
+{
+  state->handler = externalSubset1;
+  if (tok == XML_TOK_XML_DECL)
+    return XML_ROLE_TEXT_DECL;
+  return externalSubset1(state, tok, ptr, end, enc);
+}
+
+static int PTRCALL
+externalSubset1(PROLOG_STATE *state,
+                int tok,
+                const char *ptr,
+                const char *end,
+                const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_COND_SECT_OPEN:
+    state->handler = condSect0;
+    return XML_ROLE_NONE;
+  case XML_TOK_COND_SECT_CLOSE:
+    if (state->includeLevel == 0)
+      break;
+    state->includeLevel -= 1;
+    return XML_ROLE_NONE;
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_CLOSE_BRACKET:
+    break;
+  case XML_TOK_NONE:
+    if (state->includeLevel)
+      break;
+    return XML_ROLE_NONE;
+  default:
+    return internalSubset(state, tok, ptr, end, enc);
+  }
+  return common(state, tok);
+}
+
+#endif /* XML_DTD */
+
+static int PTRCALL
+entity0(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_PERCENT:
+    state->handler = entity1;
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_NAME:
+    state->handler = entity2;
+    return XML_ROLE_GENERAL_ENTITY_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity1(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_NAME:
+    state->handler = entity7;
+    return XML_ROLE_PARAM_ENTITY_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity2(PROLOG_STATE *state,
+        int tok,
+        const char *ptr,
+        const char *end,
+        const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
+      state->handler = entity4;
+      return XML_ROLE_ENTITY_NONE;
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
+      state->handler = entity3;
+      return XML_ROLE_ENTITY_NONE;
+    }
+    break;
+  case XML_TOK_LITERAL:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_ENTITY_NONE;
+    return XML_ROLE_ENTITY_VALUE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity3(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = entity4;
+    return XML_ROLE_ENTITY_PUBLIC_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity4(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = entity5;
+    return XML_ROLE_ENTITY_SYSTEM_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity5(PROLOG_STATE *state,
+        int tok,
+        const char *ptr,
+        const char *end,
+        const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_DECL_CLOSE:
+    setTopLevel(state);
+    return XML_ROLE_ENTITY_COMPLETE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) {
+      state->handler = entity6;
+      return XML_ROLE_ENTITY_NONE;
+    }
+    break;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity6(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_NAME:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_ENTITY_NONE;
+    return XML_ROLE_ENTITY_NOTATION_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity7(PROLOG_STATE *state,
+        int tok,
+        const char *ptr,
+        const char *end,
+        const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
+      state->handler = entity9;
+      return XML_ROLE_ENTITY_NONE;
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
+      state->handler = entity8;
+      return XML_ROLE_ENTITY_NONE;
+    }
+    break;
+  case XML_TOK_LITERAL:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_ENTITY_NONE;
+    return XML_ROLE_ENTITY_VALUE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity8(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = entity9;
+    return XML_ROLE_ENTITY_PUBLIC_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity9(PROLOG_STATE *state,
+        int tok,
+        const char *UNUSED_P(ptr),
+        const char *UNUSED_P(end),
+        const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = entity10;
+    return XML_ROLE_ENTITY_SYSTEM_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+entity10(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ENTITY_NONE;
+  case XML_TOK_DECL_CLOSE:
+    setTopLevel(state);
+    return XML_ROLE_ENTITY_COMPLETE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+notation0(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NOTATION_NONE;
+  case XML_TOK_NAME:
+    state->handler = notation1;
+    return XML_ROLE_NOTATION_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+notation1(PROLOG_STATE *state,
+          int tok,
+          const char *ptr,
+          const char *end,
+          const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NOTATION_NONE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
+      state->handler = notation3;
+      return XML_ROLE_NOTATION_NONE;
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
+      state->handler = notation2;
+      return XML_ROLE_NOTATION_NONE;
+    }
+    break;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+notation2(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NOTATION_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = notation4;
+    return XML_ROLE_NOTATION_PUBLIC_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+notation3(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NOTATION_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_NOTATION_NONE;
+    return XML_ROLE_NOTATION_SYSTEM_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+notation4(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NOTATION_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_NOTATION_NONE;
+    return XML_ROLE_NOTATION_SYSTEM_ID;
+  case XML_TOK_DECL_CLOSE:
+    setTopLevel(state);
+    return XML_ROLE_NOTATION_NO_SYSTEM_ID;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist0(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = attlist1;
+    return XML_ROLE_ATTLIST_ELEMENT_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist1(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_DECL_CLOSE:
+    setTopLevel(state);
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = attlist2;
+    return XML_ROLE_ATTRIBUTE_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist2(PROLOG_STATE *state,
+         int tok,
+         const char *ptr,
+         const char *end,
+         const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_NAME:
+    {
+      static const char * const types[] = {
+        KW_CDATA,
+        KW_ID,
+        KW_IDREF,
+        KW_IDREFS,
+        KW_ENTITY,
+        KW_ENTITIES,
+        KW_NMTOKEN,
+        KW_NMTOKENS,
+      };
+      int i;
+      for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
+        if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
+          state->handler = attlist8;
+          return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
+        }
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) {
+      state->handler = attlist5;
+      return XML_ROLE_ATTLIST_NONE;
+    }
+    break;
+  case XML_TOK_OPEN_PAREN:
+    state->handler = attlist3;
+    return XML_ROLE_ATTLIST_NONE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist3(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_NMTOKEN:
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = attlist4;
+    return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist4(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_CLOSE_PAREN:
+    state->handler = attlist8;
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_OR:
+    state->handler = attlist3;
+    return XML_ROLE_ATTLIST_NONE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist5(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_OPEN_PAREN:
+    state->handler = attlist6;
+    return XML_ROLE_ATTLIST_NONE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist6(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_NAME:
+    state->handler = attlist7;
+    return XML_ROLE_ATTRIBUTE_NOTATION_VALUE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist7(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_CLOSE_PAREN:
+    state->handler = attlist8;
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_OR:
+    state->handler = attlist6;
+    return XML_ROLE_ATTLIST_NONE;
+  }
+  return common(state, tok);
+}
+
+/* default value */
+static int PTRCALL
+attlist8(PROLOG_STATE *state,
+         int tok,
+         const char *ptr,
+         const char *end,
+         const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_POUND_NAME:
+    if (XmlNameMatchesAscii(enc,
+                            ptr + MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_IMPLIED)) {
+      state->handler = attlist1;
+      return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
+    }
+    if (XmlNameMatchesAscii(enc,
+                            ptr + MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_REQUIRED)) {
+      state->handler = attlist1;
+      return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
+    }
+    if (XmlNameMatchesAscii(enc,
+                            ptr + MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_FIXED)) {
+      state->handler = attlist9;
+      return XML_ROLE_ATTLIST_NONE;
+    }
+    break;
+  case XML_TOK_LITERAL:
+    state->handler = attlist1;
+    return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+attlist9(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ATTLIST_NONE;
+  case XML_TOK_LITERAL:
+    state->handler = attlist1;
+    return XML_ROLE_FIXED_ATTRIBUTE_VALUE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element0(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = element1;
+    return XML_ROLE_ELEMENT_NAME;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element1(PROLOG_STATE *state,
+         int tok,
+         const char *ptr,
+         const char *end,
+         const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) {
+      state->handler = declClose;
+      state->role_none = XML_ROLE_ELEMENT_NONE;
+      return XML_ROLE_CONTENT_EMPTY;
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) {
+      state->handler = declClose;
+      state->role_none = XML_ROLE_ELEMENT_NONE;
+      return XML_ROLE_CONTENT_ANY;
+    }
+    break;
+  case XML_TOK_OPEN_PAREN:
+    state->handler = element2;
+    state->level = 1;
+    return XML_ROLE_GROUP_OPEN;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element2(PROLOG_STATE *state,
+         int tok,
+         const char *ptr,
+         const char *end,
+         const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_POUND_NAME:
+    if (XmlNameMatchesAscii(enc,
+                            ptr + MIN_BYTES_PER_CHAR(enc),
+                            end,
+                            KW_PCDATA)) {
+      state->handler = element3;
+      return XML_ROLE_CONTENT_PCDATA;
+    }
+    break;
+  case XML_TOK_OPEN_PAREN:
+    state->level = 2;
+    state->handler = element6;
+    return XML_ROLE_GROUP_OPEN;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT;
+  case XML_TOK_NAME_QUESTION:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT_OPT;
+  case XML_TOK_NAME_ASTERISK:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT_REP;
+  case XML_TOK_NAME_PLUS:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT_PLUS;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element3(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_CLOSE_PAREN:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_ELEMENT_NONE;
+    return XML_ROLE_GROUP_CLOSE;
+  case XML_TOK_CLOSE_PAREN_ASTERISK:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_ELEMENT_NONE;
+    return XML_ROLE_GROUP_CLOSE_REP;
+  case XML_TOK_OR:
+    state->handler = element4;
+    return XML_ROLE_ELEMENT_NONE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element4(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = element5;
+    return XML_ROLE_CONTENT_ELEMENT;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element5(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_CLOSE_PAREN_ASTERISK:
+    state->handler = declClose;
+    state->role_none = XML_ROLE_ELEMENT_NONE;
+    return XML_ROLE_GROUP_CLOSE_REP;
+  case XML_TOK_OR:
+    state->handler = element4;
+    return XML_ROLE_ELEMENT_NONE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element6(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_OPEN_PAREN:
+    state->level += 1;
+    return XML_ROLE_GROUP_OPEN;
+  case XML_TOK_NAME:
+  case XML_TOK_PREFIXED_NAME:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT;
+  case XML_TOK_NAME_QUESTION:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT_OPT;
+  case XML_TOK_NAME_ASTERISK:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT_REP;
+  case XML_TOK_NAME_PLUS:
+    state->handler = element7;
+    return XML_ROLE_CONTENT_ELEMENT_PLUS;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+element7(PROLOG_STATE *state,
+         int tok,
+         const char *UNUSED_P(ptr),
+         const char *UNUSED_P(end),
+         const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_ELEMENT_NONE;
+  case XML_TOK_CLOSE_PAREN:
+    state->level -= 1;
+    if (state->level == 0) {
+      state->handler = declClose;
+      state->role_none = XML_ROLE_ELEMENT_NONE;
+    }
+    return XML_ROLE_GROUP_CLOSE;
+  case XML_TOK_CLOSE_PAREN_ASTERISK:
+    state->level -= 1;
+    if (state->level == 0) {
+      state->handler = declClose;
+      state->role_none = XML_ROLE_ELEMENT_NONE;
+    }
+    return XML_ROLE_GROUP_CLOSE_REP;
+  case XML_TOK_CLOSE_PAREN_QUESTION:
+    state->level -= 1;
+    if (state->level == 0) {
+      state->handler = declClose;
+      state->role_none = XML_ROLE_ELEMENT_NONE;
+    }
+    return XML_ROLE_GROUP_CLOSE_OPT;
+  case XML_TOK_CLOSE_PAREN_PLUS:
+    state->level -= 1;
+    if (state->level == 0) {
+      state->handler = declClose;
+      state->role_none = XML_ROLE_ELEMENT_NONE;
+    }
+    return XML_ROLE_GROUP_CLOSE_PLUS;
+  case XML_TOK_COMMA:
+    state->handler = element6;
+    return XML_ROLE_GROUP_SEQUENCE;
+  case XML_TOK_OR:
+    state->handler = element6;
+    return XML_ROLE_GROUP_CHOICE;
+  }
+  return common(state, tok);
+}
+
+#ifdef XML_DTD
+
+static int PTRCALL
+condSect0(PROLOG_STATE *state,
+          int tok,
+          const char *ptr,
+          const char *end,
+          const ENCODING *enc)
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_NAME:
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) {
+      state->handler = condSect1;
+      return XML_ROLE_NONE;
+    }
+    if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) {
+      state->handler = condSect2;
+      return XML_ROLE_NONE;
+    }
+    break;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+condSect1(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_OPEN_BRACKET:
+    state->handler = externalSubset1;
+    state->includeLevel += 1;
+    return XML_ROLE_NONE;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+condSect2(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return XML_ROLE_NONE;
+  case XML_TOK_OPEN_BRACKET:
+    state->handler = externalSubset1;
+    return XML_ROLE_IGNORE_SECT;
+  }
+  return common(state, tok);
+}
+
+#endif /* XML_DTD */
+
+static int PTRCALL
+declClose(PROLOG_STATE *state,
+          int tok,
+          const char *UNUSED_P(ptr),
+          const char *UNUSED_P(end),
+          const ENCODING *UNUSED_P(enc))
+{
+  switch (tok) {
+  case XML_TOK_PROLOG_S:
+    return state->role_none;
+  case XML_TOK_DECL_CLOSE:
+    setTopLevel(state);
+    return state->role_none;
+  }
+  return common(state, tok);
+}
+
+static int PTRCALL
+error(PROLOG_STATE *UNUSED_P(state),
+      int UNUSED_P(tok),
+      const char *UNUSED_P(ptr),
+      const char *UNUSED_P(end),
+      const ENCODING *UNUSED_P(enc))
+{
+  return XML_ROLE_NONE;
+}
+
+static int FASTCALL
+common(PROLOG_STATE *state, int tok)
+{
+#ifdef XML_DTD
+  if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
+    return XML_ROLE_INNER_PARAM_ENTITY_REF;
+#endif
+  state->handler = error;
+  return XML_ROLE_ERROR;
+}
+
+void
+XmlPrologStateInit(PROLOG_STATE *state)
+{
+  state->handler = prolog0;
+#ifdef XML_DTD
+  state->documentEntity = 1;
+  state->includeLevel = 0;
+  state->inEntityValue = 0;
+#endif /* XML_DTD */
+}
+
+#ifdef XML_DTD
+
+void
+XmlPrologStateInitExternalEntity(PROLOG_STATE *state)
+{
+  state->handler = externalSubset0;
+  state->documentEntity = 0;
+  state->includeLevel = 0;
+}
+
+#endif /* XML_DTD */
diff --git a/Utilities/cmexpat/lib/xmlrole.h b/Utilities/cmexpat/lib/xmlrole.h
new file mode 100644
index 0000000..4dd9f06
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmlrole.h
@@ -0,0 +1,114 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#ifndef XmlRole_INCLUDED
+#define XmlRole_INCLUDED 1
+
+#ifdef __VMS
+/*      0        1         2         3      0        1         2         3
+        1234567890123456789012345678901     1234567890123456789012345678901 */
+#define XmlPrologStateInitExternalEntity    XmlPrologStateInitExternalEnt
+#endif
+
+#include "xmltok.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+  XML_ROLE_ERROR = -1,
+  XML_ROLE_NONE = 0,
+  XML_ROLE_XML_DECL,
+  XML_ROLE_INSTANCE_START,
+  XML_ROLE_DOCTYPE_NONE,
+  XML_ROLE_DOCTYPE_NAME,
+  XML_ROLE_DOCTYPE_SYSTEM_ID,
+  XML_ROLE_DOCTYPE_PUBLIC_ID,
+  XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
+  XML_ROLE_DOCTYPE_CLOSE,
+  XML_ROLE_GENERAL_ENTITY_NAME,
+  XML_ROLE_PARAM_ENTITY_NAME,
+  XML_ROLE_ENTITY_NONE,
+  XML_ROLE_ENTITY_VALUE,
+  XML_ROLE_ENTITY_SYSTEM_ID,
+  XML_ROLE_ENTITY_PUBLIC_ID,
+  XML_ROLE_ENTITY_COMPLETE,
+  XML_ROLE_ENTITY_NOTATION_NAME,
+  XML_ROLE_NOTATION_NONE,
+  XML_ROLE_NOTATION_NAME,
+  XML_ROLE_NOTATION_SYSTEM_ID,
+  XML_ROLE_NOTATION_NO_SYSTEM_ID,
+  XML_ROLE_NOTATION_PUBLIC_ID,
+  XML_ROLE_ATTRIBUTE_NAME,
+  XML_ROLE_ATTRIBUTE_TYPE_CDATA,
+  XML_ROLE_ATTRIBUTE_TYPE_ID,
+  XML_ROLE_ATTRIBUTE_TYPE_IDREF,
+  XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
+  XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
+  XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
+  XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
+  XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
+  XML_ROLE_ATTRIBUTE_ENUM_VALUE,
+  XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
+  XML_ROLE_ATTLIST_NONE,
+  XML_ROLE_ATTLIST_ELEMENT_NAME,
+  XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
+  XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
+  XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
+  XML_ROLE_FIXED_ATTRIBUTE_VALUE,
+  XML_ROLE_ELEMENT_NONE,
+  XML_ROLE_ELEMENT_NAME,
+  XML_ROLE_CONTENT_ANY,
+  XML_ROLE_CONTENT_EMPTY,
+  XML_ROLE_CONTENT_PCDATA,
+  XML_ROLE_GROUP_OPEN,
+  XML_ROLE_GROUP_CLOSE,
+  XML_ROLE_GROUP_CLOSE_REP,
+  XML_ROLE_GROUP_CLOSE_OPT,
+  XML_ROLE_GROUP_CLOSE_PLUS,
+  XML_ROLE_GROUP_CHOICE,
+  XML_ROLE_GROUP_SEQUENCE,
+  XML_ROLE_CONTENT_ELEMENT,
+  XML_ROLE_CONTENT_ELEMENT_REP,
+  XML_ROLE_CONTENT_ELEMENT_OPT,
+  XML_ROLE_CONTENT_ELEMENT_PLUS,
+  XML_ROLE_PI,
+  XML_ROLE_COMMENT,
+#ifdef XML_DTD
+  XML_ROLE_TEXT_DECL,
+  XML_ROLE_IGNORE_SECT,
+  XML_ROLE_INNER_PARAM_ENTITY_REF,
+#endif /* XML_DTD */
+  XML_ROLE_PARAM_ENTITY_REF
+};
+
+typedef struct prolog_state {
+  int (PTRCALL *handler) (struct prolog_state *state,
+                          int tok,
+                          const char *ptr,
+                          const char *end,
+                          const ENCODING *enc);
+  unsigned level;
+  int role_none;
+#ifdef XML_DTD
+  unsigned includeLevel;
+  int documentEntity;
+  int inEntityValue;
+#endif /* XML_DTD */
+} PROLOG_STATE;
+
+void XmlPrologStateInit(PROLOG_STATE *);
+#ifdef XML_DTD
+void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
+#endif /* XML_DTD */
+
+#define XmlTokenRole(state, tok, ptr, end, enc) \
+ (((state)->handler)(state, tok, ptr, end, enc))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* not XmlRole_INCLUDED */
diff --git a/Utilities/cmexpat/lib/xmltok.c b/Utilities/cmexpat/lib/xmltok.c
new file mode 100644
index 0000000..4195279
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmltok.c
@@ -0,0 +1,1751 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#include <stddef.h>
+
+#ifdef COMPILING_FOR_WINDOWS
+#include "winconfig.h"
+#elif defined(MACOS_CLASSIC)
+#include "macconfig.h"
+#elif defined(__amigaos__)
+#include "amigaconfig.h"
+#elif defined(__WATCOMC__)
+#include "watcomconfig.h"
+#else
+#ifdef HAVE_EXPAT_CONFIG_H
+#include <expat_config.h>
+#endif
+#endif /* ndef COMPILING_FOR_WINDOWS */
+
+#include "expat_external.h"
+#include "internal.h"
+#include "xmltok.h"
+#include "nametab.h"
+
+#ifdef XML_DTD
+#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
+#else
+#define IGNORE_SECTION_TOK_VTABLE /* as nothing */
+#endif
+
+#define VTABLE1 \
+  { PREFIX(prologTok), PREFIX(contentTok), \
+    PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \
+  { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
+  PREFIX(sameName), \
+  PREFIX(nameMatchesAscii), \
+  PREFIX(nameLength), \
+  PREFIX(skipS), \
+  PREFIX(getAtts), \
+  PREFIX(charRefNumber), \
+  PREFIX(predefinedEntityName), \
+  PREFIX(updatePosition), \
+  PREFIX(isPublicId)
+
+#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
+
+#define UCS2_GET_NAMING(pages, hi, lo) \
+   (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo) & 0x1F)))
+
+/* A 2 byte UTF-8 representation splits the characters 11 bits between
+   the bottom 5 and 6 bits of the bytes.  We need 8 bits to index into
+   pages, 3 bits to add to that index and 5 bits to generate the mask.
+*/
+#define UTF8_GET_NAMING2(pages, byte) \
+    (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
+                      + ((((byte)[0]) & 3) << 1) \
+                      + ((((byte)[1]) >> 5) & 1)] \
+         & (1u << (((byte)[1]) & 0x1F)))
+
+/* A 3 byte UTF-8 representation splits the characters 16 bits between
+   the bottom 4, 6 and 6 bits of the bytes.  We need 8 bits to index
+   into pages, 3 bits to add to that index and 5 bits to generate the
+   mask.
+*/
+#define UTF8_GET_NAMING3(pages, byte) \
+  (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \
+                             + ((((byte)[1]) >> 2) & 0xF)] \
+                       << 3) \
+                      + ((((byte)[1]) & 3) << 1) \
+                      + ((((byte)[2]) >> 5) & 1)] \
+         & (1u << (((byte)[2]) & 0x1F)))
+
+#define UTF8_GET_NAMING(pages, p, n) \
+  ((n) == 2 \
+  ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
+  : ((n) == 3 \
+     ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
+     : 0))
+
+/* Detection of invalid UTF-8 sequences is based on Table 3.1B
+   of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
+   with the additional restriction of not allowing the Unicode
+   code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE).
+   Implementation details:
+     (A & 0x80) == 0     means A < 0x80
+   and
+     (A & 0xC0) == 0xC0  means A > 0xBF
+*/
+
+#define UTF8_INVALID2(p) \
+  ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)
+
+#define UTF8_INVALID3(p) \
+  (((p)[2] & 0x80) == 0 \
+  || \
+  ((*p) == 0xEF && (p)[1] == 0xBF \
+    ? \
+    (p)[2] > 0xBD \
+    : \
+    ((p)[2] & 0xC0) == 0xC0) \
+  || \
+  ((*p) == 0xE0 \
+    ? \
+    (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \
+    : \
+    ((p)[1] & 0x80) == 0 \
+    || \
+    ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0)))
+
+#define UTF8_INVALID4(p) \
+  (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \
+  || \
+  ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \
+  || \
+  ((*p) == 0xF0 \
+    ? \
+    (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
+    : \
+    ((p)[1] & 0x80) == 0 \
+    || \
+    ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))
+
+static int PTRFASTCALL
+isNever(const ENCODING *UNUSED_P(enc), const char *UNUSED_P(p))
+{
+  return 0;
+}
+
+static int PTRFASTCALL
+utf8_isName2(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
+}
+
+static int PTRFASTCALL
+utf8_isName3(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
+}
+
+#define utf8_isName4 isNever
+
+static int PTRFASTCALL
+utf8_isNmstrt2(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
+}
+
+static int PTRFASTCALL
+utf8_isNmstrt3(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
+}
+
+#define utf8_isNmstrt4 isNever
+
+static int PTRFASTCALL
+utf8_isInvalid2(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_INVALID2((const unsigned char *)p);
+}
+
+static int PTRFASTCALL
+utf8_isInvalid3(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_INVALID3((const unsigned char *)p);
+}
+
+static int PTRFASTCALL
+utf8_isInvalid4(const ENCODING *UNUSED_P(enc), const char *p)
+{
+  return UTF8_INVALID4((const unsigned char *)p);
+}
+
+struct normal_encoding {
+  ENCODING enc;
+  unsigned char type[256];
+#ifdef XML_MIN_SIZE
+  int (PTRFASTCALL *byteType)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *);
+  int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *);
+  int (PTRCALL *charMatches)(const ENCODING *, const char *, int);
+#endif /* XML_MIN_SIZE */
+  int (PTRFASTCALL *isName2)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isName3)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isName4)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *);
+  int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *);
+};
+
+#define AS_NORMAL_ENCODING(enc)   ((const struct normal_encoding *) (enc))
+
+#ifdef XML_MIN_SIZE
+
+#define STANDARD_VTABLE(E) \
+ E ## byteType, \
+ E ## isNameMin, \
+ E ## isNmstrtMin, \
+ E ## byteToAscii, \
+ E ## charMatches,
+
+#else
+
+#define STANDARD_VTABLE(E) /* as nothing */
+
+#endif
+
+#define NORMAL_VTABLE(E) \
+ E ## isName2, \
+ E ## isName3, \
+ E ## isName4, \
+ E ## isNmstrt2, \
+ E ## isNmstrt3, \
+ E ## isNmstrt4, \
+ E ## isInvalid2, \
+ E ## isInvalid3, \
+ E ## isInvalid4
+
+#define NULL_VTABLE \
+ /* isName2 */ NULL, \
+ /* isName3 */ NULL, \
+ /* isName4 */ NULL, \
+ /* isNmstrt2 */ NULL, \
+ /* isNmstrt3 */ NULL, \
+ /* isNmstrt4 */ NULL, \
+ /* isInvalid2 */ NULL, \
+ /* isInvalid3 */ NULL, \
+ /* isInvalid4 */ NULL
+
+static int FASTCALL checkCharRefNumber(int);
+
+#include "xmltok_impl.h"
+#include "ascii.h"
+
+#ifdef XML_MIN_SIZE
+#define sb_isNameMin isNever
+#define sb_isNmstrtMin isNever
+#endif
+
+#ifdef XML_MIN_SIZE
+#define MINBPC(enc) ((enc)->minBytesPerChar)
+#else
+/* minimum bytes per character */
+#define MINBPC(enc) 1
+#endif
+
+#define SB_BYTE_TYPE(enc, p) \
+  (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
+
+#ifdef XML_MIN_SIZE
+static int PTRFASTCALL
+sb_byteType(const ENCODING *enc, const char *p)
+{
+  return SB_BYTE_TYPE(enc, p);
+}
+#define BYTE_TYPE(enc, p) \
+ (AS_NORMAL_ENCODING(enc)->byteType(enc, p))
+#else
+#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
+#endif
+
+#ifdef XML_MIN_SIZE
+#define BYTE_TO_ASCII(enc, p) \
+ (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p))
+static int PTRFASTCALL
+sb_byteToAscii(const ENCODING *enc, const char *p)
+{
+  return *p;
+}
+#else
+#define BYTE_TO_ASCII(enc, p) (*(p))
+#endif
+
+#define IS_NAME_CHAR(enc, p, n) \
+ (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p))
+#define IS_NMSTRT_CHAR(enc, p, n) \
+ (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p))
+#define IS_INVALID_CHAR(enc, p, n) \
+ (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p))
+
+#ifdef XML_MIN_SIZE
+#define IS_NAME_CHAR_MINBPC(enc, p) \
+ (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p))
+#define IS_NMSTRT_CHAR_MINBPC(enc, p) \
+ (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p))
+#else
+#define IS_NAME_CHAR_MINBPC(enc, p) (0)
+#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
+#endif
+
+#ifdef XML_MIN_SIZE
+#define CHAR_MATCHES(enc, p, c) \
+ (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c))
+static int PTRCALL
+sb_charMatches(const ENCODING *enc, const char *p, int c)
+{
+  return *p == c;
+}
+#else
+/* c is an ASCII character */
+#define CHAR_MATCHES(enc, p, c) (*(p) == c)
+#endif
+
+#define PREFIX(ident) normal_ ## ident
+#define XML_TOK_IMPL_C
+#include "xmltok_impl.c"
+#undef XML_TOK_IMPL_C
+
+#undef MINBPC
+#undef BYTE_TYPE
+#undef BYTE_TO_ASCII
+#undef CHAR_MATCHES
+#undef IS_NAME_CHAR
+#undef IS_NAME_CHAR_MINBPC
+#undef IS_NMSTRT_CHAR
+#undef IS_NMSTRT_CHAR_MINBPC
+#undef IS_INVALID_CHAR
+
+enum {  /* UTF8_cvalN is value of masked first byte of N byte sequence */
+  UTF8_cval1 = 0x00,
+  UTF8_cval2 = 0xc0,
+  UTF8_cval3 = 0xe0,
+  UTF8_cval4 = 0xf0
+};
+
+void
+align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef)
+{
+  const char * fromLim = *fromLimRef;
+  size_t walked = 0;
+  for (; fromLim > from; fromLim--, walked++) {
+    const unsigned char prev = (unsigned char)fromLim[-1];
+    if ((prev & 0xf8u) == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */
+      if (walked + 1 >= 4) {
+        fromLim += 4 - 1;
+        break;
+      } else {
+        walked = 0;
+      }
+    } else if ((prev & 0xf0u) == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */
+      if (walked + 1 >= 3) {
+        fromLim += 3 - 1;
+        break;
+      } else {
+        walked = 0;
+      }
+    } else if ((prev & 0xe0u) == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */
+      if (walked + 1 >= 2) {
+        fromLim += 2 - 1;
+        break;
+      } else {
+        walked = 0;
+      }
+    } else if ((prev & 0x80u) == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */
+      break;
+    }
+  }
+  *fromLimRef = fromLim;
+}
+
+static enum XML_Convert_Result PTRCALL
+utf8_toUtf8(const ENCODING *UNUSED_P(enc),
+            const char **fromP, const char *fromLim,
+            char **toP, const char *toLim)
+{
+  enum XML_Convert_Result res = XML_CONVERT_COMPLETED;
+  char *to;
+  const char *from;
+  if (fromLim - *fromP > toLim - *toP) {
+    /* Avoid copying partial characters. */
+    res = XML_CONVERT_OUTPUT_EXHAUSTED;
+    fromLim = *fromP + (toLim - *toP);
+    align_limit_to_full_utf8_characters(*fromP, &fromLim);
+  }
+  for (to = *toP, from = *fromP; (from < fromLim) && (to < toLim); from++, to++)
+    *to = *from;
+  *fromP = from;
+  *toP = to;
+
+  if ((to == toLim) && (from < fromLim))
+    return XML_CONVERT_OUTPUT_EXHAUSTED;
+  else
+    return res;
+}
+
+static enum XML_Convert_Result PTRCALL
+utf8_toUtf16(const ENCODING *enc,
+             const char **fromP, const char *fromLim,
+             unsigned short **toP, const unsigned short *toLim)
+{
+  enum XML_Convert_Result res = XML_CONVERT_COMPLETED;
+  unsigned short *to = *toP;
+  const char *from = *fromP;
+  while (from < fromLim && to < toLim) {
+    switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {
+    case BT_LEAD2:
+      if (fromLim - from < 2) {
+        res = XML_CONVERT_INPUT_INCOMPLETE;
+        break;
+      }
+      *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f));
+      from += 2;
+      break;
+    case BT_LEAD3:
+      if (fromLim - from < 3) {
+        res = XML_CONVERT_INPUT_INCOMPLETE;
+        break;
+      }
+      *to++ = (unsigned short)(((from[0] & 0xf) << 12)
+                               | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f));
+      from += 3;
+      break;
+    case BT_LEAD4:
+      {
+        unsigned long n;
+        if (toLim - to < 2) {
+          res = XML_CONVERT_OUTPUT_EXHAUSTED;
+          goto after;
+        }
+        if (fromLim - from < 4) {
+          res = XML_CONVERT_INPUT_INCOMPLETE;
+          goto after;
+        }
+        n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12)
+            | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
+        n -= 0x10000;
+        to[0] = (unsigned short)((n >> 10) | 0xD800);
+        to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
+        to += 2;
+        from += 4;
+      }
+      break;
+    default:
+      *to++ = *from++;
+      break;
+    }
+  }
+after:
+  *fromP = from;
+  *toP = to;
+  return res;
+}
+
+#ifdef XML_NS
+static const struct normal_encoding utf8_encoding_ns = {
+  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
+  {
+#include "asciitab.h"
+#include "utf8tab.h"
+  },
+  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
+};
+#endif
+
+static const struct normal_encoding utf8_encoding = {
+  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
+  {
+#define BT_COLON BT_NMSTRT
+#include "asciitab.h"
+#undef BT_COLON
+#include "utf8tab.h"
+  },
+  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
+};
+
+#ifdef XML_NS
+
+static const struct normal_encoding internal_utf8_encoding_ns = {
+  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
+  {
+#include "iasciitab.h"
+#include "utf8tab.h"
+  },
+  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
+};
+
+#endif
+
+static const struct normal_encoding internal_utf8_encoding = {
+  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
+  {
+#define BT_COLON BT_NMSTRT
+#include "iasciitab.h"
+#undef BT_COLON
+#include "utf8tab.h"
+  },
+  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
+};
+
+static enum XML_Convert_Result PTRCALL
+latin1_toUtf8(const ENCODING *UNUSED_P(enc),
+              const char **fromP, const char *fromLim,
+              char **toP, const char *toLim)
+{
+  for (;;) {
+    unsigned char c;
+    if (*fromP == fromLim)
+      return XML_CONVERT_COMPLETED;
+    c = (unsigned char)**fromP;
+    if (c & 0x80) {
+      if (toLim - *toP < 2)
+        return XML_CONVERT_OUTPUT_EXHAUSTED;
+      *(*toP)++ = (char)((c >> 6) | UTF8_cval2);
+      *(*toP)++ = (char)((c & 0x3f) | 0x80);
+      (*fromP)++;
+    }
+    else {
+      if (*toP == toLim)
+        return XML_CONVERT_OUTPUT_EXHAUSTED;
+      *(*toP)++ = *(*fromP)++;
+    }
+  }
+}
+
+static enum XML_Convert_Result PTRCALL
+latin1_toUtf16(const ENCODING *UNUSED_P(enc),
+               const char **fromP, const char *fromLim,
+               unsigned short **toP, const unsigned short *toLim)
+{
+  while (*fromP < fromLim && *toP < toLim)
+    *(*toP)++ = (unsigned char)*(*fromP)++;
+
+  if ((*toP == toLim) && (*fromP < fromLim))
+    return XML_CONVERT_OUTPUT_EXHAUSTED;
+  else
+    return XML_CONVERT_COMPLETED;
+}
+
+#ifdef XML_NS
+
+static const struct normal_encoding latin1_encoding_ns = {
+  { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
+  {
+#include "asciitab.h"
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(sb_) NULL_VTABLE
+};
+
+#endif
+
+static const struct normal_encoding latin1_encoding = {
+  { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
+  {
+#define BT_COLON BT_NMSTRT
+#include "asciitab.h"
+#undef BT_COLON
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(sb_) NULL_VTABLE
+};
+
+static enum XML_Convert_Result PTRCALL
+ascii_toUtf8(const ENCODING *UNUSED_P(enc),
+             const char **fromP, const char *fromLim,
+             char **toP, const char *toLim)
+{
+  while (*fromP < fromLim && *toP < toLim)
+    *(*toP)++ = *(*fromP)++;
+
+  if ((*toP == toLim) && (*fromP < fromLim))
+    return XML_CONVERT_OUTPUT_EXHAUSTED;
+  else
+    return XML_CONVERT_COMPLETED;
+}
+
+#ifdef XML_NS
+
+static const struct normal_encoding ascii_encoding_ns = {
+  { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
+  {
+#include "asciitab.h"
+/* BT_NONXML == 0 */
+  },
+  STANDARD_VTABLE(sb_) NULL_VTABLE
+};
+
+#endif
+
+static const struct normal_encoding ascii_encoding = {
+  { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
+  {
+#define BT_COLON BT_NMSTRT
+#include "asciitab.h"
+#undef BT_COLON
+/* BT_NONXML == 0 */
+  },
+  STANDARD_VTABLE(sb_) NULL_VTABLE
+};
+
+static int PTRFASTCALL
+unicode_byte_type(char hi, char lo)
+{
+  switch ((unsigned char)hi) {
+  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
+    return BT_LEAD4;
+  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
+    return BT_TRAIL;
+  case 0xFF:
+    switch ((unsigned char)lo) {
+    case 0xFF:
+    case 0xFE:
+      return BT_NONXML;
+    }
+    break;
+  }
+  return BT_NONASCII;
+}
+
+#define DEFINE_UTF16_TO_UTF8(E) \
+static enum XML_Convert_Result  PTRCALL \
+E ## toUtf8(const ENCODING *UNUSED_P(enc), \
+            const char **fromP, const char *fromLim, \
+            char **toP, const char *toLim) \
+{ \
+  const char *from = *fromP; \
+  fromLim = from + (((fromLim - from) >> 1) << 1);  /* shrink to even */ \
+  for (; from < fromLim; from += 2) { \
+    int plane; \
+    unsigned char lo2; \
+    unsigned char lo = GET_LO(from); \
+    unsigned char hi = GET_HI(from); \
+    switch (hi) { \
+    case 0: \
+      if (lo < 0x80) { \
+        if (*toP == toLim) { \
+          *fromP = from; \
+          return XML_CONVERT_OUTPUT_EXHAUSTED; \
+        } \
+        *(*toP)++ = lo; \
+        break; \
+      } \
+      /* fall through */ \
+    case 0x1: case 0x2: case 0x3: \
+    case 0x4: case 0x5: case 0x6: case 0x7: \
+      if (toLim -  *toP < 2) { \
+        *fromP = from; \
+        return XML_CONVERT_OUTPUT_EXHAUSTED; \
+      } \
+      *(*toP)++ = ((lo >> 6) | (hi << 2) |  UTF8_cval2); \
+      *(*toP)++ = ((lo & 0x3f) | 0x80); \
+      break; \
+    default: \
+      if (toLim -  *toP < 3)  { \
+        *fromP = from; \
+        return XML_CONVERT_OUTPUT_EXHAUSTED; \
+      } \
+      /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
+      *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
+      *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
+      *(*toP)++ = ((lo & 0x3f) | 0x80); \
+      break; \
+    case 0xD8: case 0xD9: case 0xDA: case 0xDB: \
+      if (toLim -  *toP < 4) { \
+        *fromP = from; \
+        return XML_CONVERT_OUTPUT_EXHAUSTED; \
+      } \
+      if (fromLim - from < 4) { \
+        *fromP = from; \
+        return XML_CONVERT_INPUT_INCOMPLETE; \
+      } \
+      plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
+      *(*toP)++ = ((plane >> 2) | UTF8_cval4); \
+      *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
+      from += 2; \
+      lo2 = GET_LO(from); \
+      *(*toP)++ = (((lo & 0x3) << 4) \
+                   | ((GET_HI(from) & 0x3) << 2) \
+                   | (lo2 >> 6) \
+                   | 0x80); \
+      *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
+      break; \
+    } \
+  } \
+  *fromP = from; \
+  if (from < fromLim) \
+    return XML_CONVERT_INPUT_INCOMPLETE; \
+  else \
+    return XML_CONVERT_COMPLETED; \
+}
+
+#define DEFINE_UTF16_TO_UTF16(E) \
+static enum XML_Convert_Result  PTRCALL \
+E ## toUtf16(const ENCODING *UNUSED_P(enc), \
+             const char **fromP, const char *fromLim, \
+             unsigned short **toP, const unsigned short *toLim) \
+{ \
+  enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \
+  fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1);  /* shrink to even */ \
+  /* Avoid copying first half only of surrogate */ \
+  if (fromLim - *fromP > ((toLim - *toP) << 1) \
+      && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \
+    fromLim -= 2; \
+    res = XML_CONVERT_INPUT_INCOMPLETE; \
+  } \
+  for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \
+    *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
+  if ((*toP == toLim) && (*fromP < fromLim)) \
+    return XML_CONVERT_OUTPUT_EXHAUSTED; \
+  else \
+    return res; \
+}
+
+#define SET2(ptr, ch) \
+  (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8)))
+#define GET_LO(ptr) ((unsigned char)(ptr)[0])
+#define GET_HI(ptr) ((unsigned char)(ptr)[1])
+
+DEFINE_UTF16_TO_UTF8(little2_)
+DEFINE_UTF16_TO_UTF16(little2_)
+
+#undef SET2
+#undef GET_LO
+#undef GET_HI
+
+#define SET2(ptr, ch) \
+  (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF)))
+#define GET_LO(ptr) ((unsigned char)(ptr)[1])
+#define GET_HI(ptr) ((unsigned char)(ptr)[0])
+
+DEFINE_UTF16_TO_UTF8(big2_)
+DEFINE_UTF16_TO_UTF16(big2_)
+
+#undef SET2
+#undef GET_LO
+#undef GET_HI
+
+#define LITTLE2_BYTE_TYPE(enc, p) \
+ ((p)[1] == 0 \
+  ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
+  : unicode_byte_type((p)[1], (p)[0]))
+#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1)
+#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c)
+#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \
+  UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
+#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
+  UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
+
+#ifdef XML_MIN_SIZE
+
+static int PTRFASTCALL
+little2_byteType(const ENCODING *enc, const char *p)
+{
+  return LITTLE2_BYTE_TYPE(enc, p);
+}
+
+static int PTRFASTCALL
+little2_byteToAscii(const ENCODING *enc, const char *p)
+{
+  return LITTLE2_BYTE_TO_ASCII(enc, p);
+}
+
+static int PTRCALL
+little2_charMatches(const ENCODING *enc, const char *p, int c)
+{
+  return LITTLE2_CHAR_MATCHES(enc, p, c);
+}
+
+static int PTRFASTCALL
+little2_isNameMin(const ENCODING *enc, const char *p)
+{
+  return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
+}
+
+static int PTRFASTCALL
+little2_isNmstrtMin(const ENCODING *enc, const char *p)
+{
+  return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
+}
+
+#undef VTABLE
+#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
+
+#else /* not XML_MIN_SIZE */
+
+#undef PREFIX
+#define PREFIX(ident) little2_ ## ident
+#define MINBPC(enc) 2
+/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
+#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
+#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
+#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
+#define IS_NAME_CHAR(enc, p, n) 0
+#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
+#define IS_NMSTRT_CHAR(enc, p, n) (0)
+#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
+
+#define XML_TOK_IMPL_C
+#include "xmltok_impl.c"
+#undef XML_TOK_IMPL_C
+
+#undef MINBPC
+#undef BYTE_TYPE
+#undef BYTE_TO_ASCII
+#undef CHAR_MATCHES
+#undef IS_NAME_CHAR
+#undef IS_NAME_CHAR_MINBPC
+#undef IS_NMSTRT_CHAR
+#undef IS_NMSTRT_CHAR_MINBPC
+#undef IS_INVALID_CHAR
+
+#endif /* not XML_MIN_SIZE */
+
+#ifdef XML_NS
+
+static const struct normal_encoding little2_encoding_ns = {
+  { VTABLE, 2, 0,
+#if BYTEORDER == 1234
+    1
+#else
+    0
+#endif
+  },
+  {
+#include "asciitab.h"
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(little2_) NULL_VTABLE
+};
+
+#endif
+
+static const struct normal_encoding little2_encoding = {
+  { VTABLE, 2, 0,
+#if BYTEORDER == 1234
+    1
+#else
+    0
+#endif
+  },
+  {
+#define BT_COLON BT_NMSTRT
+#include "asciitab.h"
+#undef BT_COLON
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(little2_) NULL_VTABLE
+};
+
+#if BYTEORDER != 4321
+
+#ifdef XML_NS
+
+static const struct normal_encoding internal_little2_encoding_ns = {
+  { VTABLE, 2, 0, 1 },
+  {
+#include "iasciitab.h"
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(little2_) NULL_VTABLE
+};
+
+#endif
+
+static const struct normal_encoding internal_little2_encoding = {
+  { VTABLE, 2, 0, 1 },
+  {
+#define BT_COLON BT_NMSTRT
+#include "iasciitab.h"
+#undef BT_COLON
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(little2_) NULL_VTABLE
+};
+
+#endif
+
+
+#define BIG2_BYTE_TYPE(enc, p) \
+ ((p)[0] == 0 \
+  ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
+  : unicode_byte_type((p)[0], (p)[1]))
+#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1)
+#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c)
+#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \
+  UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
+#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
+  UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
+
+#ifdef XML_MIN_SIZE
+
+static int PTRFASTCALL
+big2_byteType(const ENCODING *enc, const char *p)
+{
+  return BIG2_BYTE_TYPE(enc, p);
+}
+
+static int PTRFASTCALL
+big2_byteToAscii(const ENCODING *enc, const char *p)
+{
+  return BIG2_BYTE_TO_ASCII(enc, p);
+}
+
+static int PTRCALL
+big2_charMatches(const ENCODING *enc, const char *p, int c)
+{
+  return BIG2_CHAR_MATCHES(enc, p, c);
+}
+
+static int PTRFASTCALL
+big2_isNameMin(const ENCODING *enc, const char *p)
+{
+  return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
+}
+
+static int PTRFASTCALL
+big2_isNmstrtMin(const ENCODING *enc, const char *p)
+{
+  return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
+}
+
+#undef VTABLE
+#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
+
+#else /* not XML_MIN_SIZE */
+
+#undef PREFIX
+#define PREFIX(ident) big2_ ## ident
+#define MINBPC(enc) 2
+/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
+#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
+#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
+#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
+#define IS_NAME_CHAR(enc, p, n) 0
+#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
+#define IS_NMSTRT_CHAR(enc, p, n) (0)
+#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
+
+#define XML_TOK_IMPL_C
+#include "xmltok_impl.c"
+#undef XML_TOK_IMPL_C
+
+#undef MINBPC
+#undef BYTE_TYPE
+#undef BYTE_TO_ASCII
+#undef CHAR_MATCHES
+#undef IS_NAME_CHAR
+#undef IS_NAME_CHAR_MINBPC
+#undef IS_NMSTRT_CHAR
+#undef IS_NMSTRT_CHAR_MINBPC
+#undef IS_INVALID_CHAR
+
+#endif /* not XML_MIN_SIZE */
+
+#ifdef XML_NS
+
+static const struct normal_encoding big2_encoding_ns = {
+  { VTABLE, 2, 0,
+#if BYTEORDER == 4321
+  1
+#else
+  0
+#endif
+  },
+  {
+#include "asciitab.h"
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(big2_) NULL_VTABLE
+};
+
+#endif
+
+static const struct normal_encoding big2_encoding = {
+  { VTABLE, 2, 0,
+#if BYTEORDER == 4321
+  1
+#else
+  0
+#endif
+  },
+  {
+#define BT_COLON BT_NMSTRT
+#include "asciitab.h"
+#undef BT_COLON
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(big2_) NULL_VTABLE
+};
+
+#if BYTEORDER != 1234
+
+#ifdef XML_NS
+
+static const struct normal_encoding internal_big2_encoding_ns = {
+  { VTABLE, 2, 0, 1 },
+  {
+#include "iasciitab.h"
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(big2_) NULL_VTABLE
+};
+
+#endif
+
+static const struct normal_encoding internal_big2_encoding = {
+  { VTABLE, 2, 0, 1 },
+  {
+#define BT_COLON BT_NMSTRT
+#include "iasciitab.h"
+#undef BT_COLON
+#include "latin1tab.h"
+  },
+  STANDARD_VTABLE(big2_) NULL_VTABLE
+};
+
+#endif
+
+#undef PREFIX
+
+static int FASTCALL
+streqci(const char *s1, const char *s2)
+{
+  for (;;) {
+    char c1 = *s1++;
+    char c2 = *s2++;
+    if (ASCII_a <= c1 && c1 <= ASCII_z)
+      c1 += ASCII_A - ASCII_a;
+    if (ASCII_a <= c2 && c2 <= ASCII_z)
+      c2 += ASCII_A - ASCII_a;
+    if (c1 != c2)
+      return 0;
+    if (!c1)
+      break;
+  }
+  return 1;
+}
+
+static void PTRCALL
+initUpdatePosition(const ENCODING *UNUSED_P(enc), const char *ptr,
+                   const char *end, POSITION *pos)
+{
+  normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
+}
+
+static int
+toAscii(const ENCODING *enc, const char *ptr, const char *end)
+{
+  char buf[1];
+  char *p = buf;
+  XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
+  if (p == buf)
+    return -1;
+  else
+    return buf[0];
+}
+
+static int FASTCALL
+isSpace(int c)
+{
+  switch (c) {
+  case 0x20:
+  case 0xD:
+  case 0xA:
+  case 0x9:
+    return 1;
+  }
+  return 0;
+}
+
+/* Return 1 if there's just optional white space or there's an S
+   followed by name=val.
+*/
+static int
+parsePseudoAttribute(const ENCODING *enc,
+                     const char *ptr,
+                     const char *end,
+                     const char **namePtr,
+                     const char **nameEndPtr,
+                     const char **valPtr,
+                     const char **nextTokPtr)
+{
+  int c;
+  char open;
+  if (ptr == end) {
+    *namePtr = NULL;
+    return 1;
+  }
+  if (!isSpace(toAscii(enc, ptr, end))) {
+    *nextTokPtr = ptr;
+    return 0;
+  }
+  do {
+    ptr += enc->minBytesPerChar;
+  } while (isSpace(toAscii(enc, ptr, end)));
+  if (ptr == end) {
+    *namePtr = NULL;
+    return 1;
+  }
+  *namePtr = ptr;
+  for (;;) {
+    c = toAscii(enc, ptr, end);
+    if (c == -1) {
+      *nextTokPtr = ptr;
+      return 0;
+    }
+    if (c == ASCII_EQUALS) {
+      *nameEndPtr = ptr;
+      break;
+    }
+    if (isSpace(c)) {
+      *nameEndPtr = ptr;
+      do {
+        ptr += enc->minBytesPerChar;
+      } while (isSpace(c = toAscii(enc, ptr, end)));
+      if (c != ASCII_EQUALS) {
+        *nextTokPtr = ptr;
+        return 0;
+      }
+      break;
+    }
+    ptr += enc->minBytesPerChar;
+  }
+  if (ptr == *namePtr) {
+    *nextTokPtr = ptr;
+    return 0;
+  }
+  ptr += enc->minBytesPerChar;
+  c = toAscii(enc, ptr, end);
+  while (isSpace(c)) {
+    ptr += enc->minBytesPerChar;
+    c = toAscii(enc, ptr, end);
+  }
+  if (c != ASCII_QUOT && c != ASCII_APOS) {
+    *nextTokPtr = ptr;
+    return 0;
+  }
+  open = (char)c;
+  ptr += enc->minBytesPerChar;
+  *valPtr = ptr;
+  for (;; ptr += enc->minBytesPerChar) {
+    c = toAscii(enc, ptr, end);
+    if (c == open)
+      break;
+    if (!(ASCII_a <= c && c <= ASCII_z)
+        && !(ASCII_A <= c && c <= ASCII_Z)
+        && !(ASCII_0 <= c && c <= ASCII_9)
+        && c != ASCII_PERIOD
+        && c != ASCII_MINUS
+        && c != ASCII_UNDERSCORE) {
+      *nextTokPtr = ptr;
+      return 0;
+    }
+  }
+  *nextTokPtr = ptr + enc->minBytesPerChar;
+  return 1;
+}
+
+static const char KW_version[] = {
+  ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0'
+};
+
+static const char KW_encoding[] = {
+  ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0'
+};
+
+static const char KW_standalone[] = {
+  ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o,
+  ASCII_n, ASCII_e, '\0'
+};
+
+static const char KW_yes[] = {
+  ASCII_y, ASCII_e, ASCII_s,  '\0'
+};
+
+static const char KW_no[] = {
+  ASCII_n, ASCII_o,  '\0'
+};
+
+static int
+doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
+                                                 const char *,
+                                                 const char *),
+               int isGeneralTextEntity,
+               const ENCODING *enc,
+               const char *ptr,
+               const char *end,
+               const char **badPtr,
+               const char **versionPtr,
+               const char **versionEndPtr,
+               const char **encodingName,
+               const ENCODING **encoding,
+               int *standalone)
+{
+  const char *val = NULL;
+  const char *name = NULL;
+  const char *nameEnd = NULL;
+  ptr += 5 * enc->minBytesPerChar;
+  end -= 2 * enc->minBytesPerChar;
+  if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)
+      || !name) {
+    *badPtr = ptr;
+    return 0;
+  }
+  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
+    if (!isGeneralTextEntity) {
+      *badPtr = name;
+      return 0;
+    }
+  }
+  else {
+    if (versionPtr)
+      *versionPtr = val;
+    if (versionEndPtr)
+      *versionEndPtr = ptr;
+    if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
+      *badPtr = ptr;
+      return 0;
+    }
+    if (!name) {
+      if (isGeneralTextEntity) {
+        /* a TextDecl must have an EncodingDecl */
+        *badPtr = ptr;
+        return 0;
+      }
+      return 1;
+    }
+  }
+  if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) {
+    int c = toAscii(enc, val, end);
+    if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) {
+      *badPtr = val;
+      return 0;
+    }
+    if (encodingName)
+      *encodingName = val;
+    if (encoding)
+      *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
+    if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
+      *badPtr = ptr;
+      return 0;
+    }
+    if (!name)
+      return 1;
+  }
+  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone)
+      || isGeneralTextEntity) {
+    *badPtr = name;
+    return 0;
+  }
+  if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) {
+    if (standalone)
+      *standalone = 1;
+  }
+  else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
+    if (standalone)
+      *standalone = 0;
+  }
+  else {
+    *badPtr = val;
+    return 0;
+  }
+  while (isSpace(toAscii(enc, ptr, end)))
+    ptr += enc->minBytesPerChar;
+  if (ptr != end) {
+    *badPtr = ptr;
+    return 0;
+  }
+  return 1;
+}
+
+static int FASTCALL
+checkCharRefNumber(int result)
+{
+  switch (result >> 8) {
+  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
+  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
+    return -1;
+  case 0:
+    if (latin1_encoding.type[result] == BT_NONXML)
+      return -1;
+    break;
+  case 0xFF:
+    if (result == 0xFFFE || result == 0xFFFF)
+      return -1;
+    break;
+  }
+  return result;
+}
+
+int FASTCALL
+XmlUtf8Encode(int c, char *buf)
+{
+  enum {
+    /* minN is minimum legal resulting value for N byte sequence */
+    min2 = 0x80,
+    min3 = 0x800,
+    min4 = 0x10000
+  };
+
+  if (c < 0)
+    return 0;
+  if (c < min2) {
+    buf[0] = (char)(c | UTF8_cval1);
+    return 1;
+  }
+  if (c < min3) {
+    buf[0] = (char)((c >> 6) | UTF8_cval2);
+    buf[1] = (char)((c & 0x3f) | 0x80);
+    return 2;
+  }
+  if (c < min4) {
+    buf[0] = (char)((c >> 12) | UTF8_cval3);
+    buf[1] = (char)(((c >> 6) & 0x3f) | 0x80);
+    buf[2] = (char)((c & 0x3f) | 0x80);
+    return 3;
+  }
+  if (c < 0x110000) {
+    buf[0] = (char)((c >> 18) | UTF8_cval4);
+    buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
+    buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
+    buf[3] = (char)((c & 0x3f) | 0x80);
+    return 4;
+  }
+  return 0;
+}
+
+int FASTCALL
+XmlUtf16Encode(int charNum, unsigned short *buf)
+{
+  if (charNum < 0)
+    return 0;
+  if (charNum < 0x10000) {
+    buf[0] = (unsigned short)charNum;
+    return 1;
+  }
+  if (charNum < 0x110000) {
+    charNum -= 0x10000;
+    buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
+    buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
+    return 2;
+  }
+  return 0;
+}
+
+struct unknown_encoding {
+  struct normal_encoding normal;
+  CONVERTER convert;
+  void *userData;
+  unsigned short utf16[256];
+  char utf8[256][4];
+};
+
+#define AS_UNKNOWN_ENCODING(enc)  ((const struct unknown_encoding *) (enc))
+
+int
+XmlSizeOfUnknownEncoding(void)
+{
+  return sizeof(struct unknown_encoding);
+}
+
+static int PTRFASTCALL
+unknown_isName(const ENCODING *enc, const char *p)
+{
+  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
+  int c = uenc->convert(uenc->userData, p);
+  if (c & ~0xFFFF)
+    return 0;
+  return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
+}
+
+static int PTRFASTCALL
+unknown_isNmstrt(const ENCODING *enc, const char *p)
+{
+  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
+  int c = uenc->convert(uenc->userData, p);
+  if (c & ~0xFFFF)
+    return 0;
+  return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
+}
+
+static int PTRFASTCALL
+unknown_isInvalid(const ENCODING *enc, const char *p)
+{
+  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
+  int c = uenc->convert(uenc->userData, p);
+  return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
+}
+
+static enum XML_Convert_Result PTRCALL
+unknown_toUtf8(const ENCODING *enc,
+               const char **fromP, const char *fromLim,
+               char **toP, const char *toLim)
+{
+  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
+  char buf[XML_UTF8_ENCODE_MAX];
+  for (;;) {
+    const char *utf8;
+    int n;
+    if (*fromP == fromLim)
+      return XML_CONVERT_COMPLETED;
+    utf8 = uenc->utf8[(unsigned char)**fromP];
+    n = *utf8++;
+    if (n == 0) {
+      int c = uenc->convert(uenc->userData, *fromP);
+      n = XmlUtf8Encode(c, buf);
+      if (n > toLim - *toP)
+        return XML_CONVERT_OUTPUT_EXHAUSTED;
+      utf8 = buf;
+      *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
+                 - (BT_LEAD2 - 2));
+    }
+    else {
+      if (n > toLim - *toP)
+        return XML_CONVERT_OUTPUT_EXHAUSTED;
+      (*fromP)++;
+    }
+    do {
+      *(*toP)++ = *utf8++;
+    } while (--n != 0);
+  }
+}
+
+static enum XML_Convert_Result PTRCALL
+unknown_toUtf16(const ENCODING *enc,
+                const char **fromP, const char *fromLim,
+                unsigned short **toP, const unsigned short *toLim)
+{
+  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
+  while (*fromP < fromLim && *toP < toLim) {
+    unsigned short c = uenc->utf16[(unsigned char)**fromP];
+    if (c == 0) {
+      c = (unsigned short)
+          uenc->convert(uenc->userData, *fromP);
+      *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
+                 - (BT_LEAD2 - 2));
+    }
+    else
+      (*fromP)++;
+    *(*toP)++ = c;
+  }
+
+  if ((*toP == toLim) && (*fromP < fromLim))
+    return XML_CONVERT_OUTPUT_EXHAUSTED;
+  else
+    return XML_CONVERT_COMPLETED;
+}
+
+ENCODING *
+XmlInitUnknownEncoding(void *mem,
+                       int *table,
+                       CONVERTER convert,
+                       void *userData)
+{
+  int i;
+  struct unknown_encoding *e = (struct unknown_encoding *)mem;
+  for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
+    ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
+  for (i = 0; i < 128; i++)
+    if (latin1_encoding.type[i] != BT_OTHER
+        && latin1_encoding.type[i] != BT_NONXML
+        && table[i] != i)
+      return 0;
+  for (i = 0; i < 256; i++) {
+    int c = table[i];
+    if (c == -1) {
+      e->normal.type[i] = BT_MALFORM;
+      /* This shouldn't really get used. */
+      e->utf16[i] = 0xFFFF;
+      e->utf8[i][0] = 1;
+      e->utf8[i][1] = 0;
+    }
+    else if (c < 0) {
+      if (c < -4)
+        return 0;
+      e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
+      e->utf8[i][0] = 0;
+      e->utf16[i] = 0;
+    }
+    else if (c < 0x80) {
+      if (latin1_encoding.type[c] != BT_OTHER
+          && latin1_encoding.type[c] != BT_NONXML
+          && c != i)
+        return 0;
+      e->normal.type[i] = latin1_encoding.type[c];
+      e->utf8[i][0] = 1;
+      e->utf8[i][1] = (char)c;
+      e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
+    }
+    else if (checkCharRefNumber(c) < 0) {
+      e->normal.type[i] = BT_NONXML;
+      /* This shouldn't really get used. */
+      e->utf16[i] = 0xFFFF;
+      e->utf8[i][0] = 1;
+      e->utf8[i][1] = 0;
+    }
+    else {
+      if (c > 0xFFFF)
+        return 0;
+      if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
+        e->normal.type[i] = BT_NMSTRT;
+      else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
+        e->normal.type[i] = BT_NAME;
+      else
+        e->normal.type[i] = BT_OTHER;
+      e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
+      e->utf16[i] = (unsigned short)c;
+    }
+  }
+  e->userData = userData;
+  e->convert = convert;
+  if (convert) {
+    e->normal.isName2 = unknown_isName;
+    e->normal.isName3 = unknown_isName;
+    e->normal.isName4 = unknown_isName;
+    e->normal.isNmstrt2 = unknown_isNmstrt;
+    e->normal.isNmstrt3 = unknown_isNmstrt;
+    e->normal.isNmstrt4 = unknown_isNmstrt;
+    e->normal.isInvalid2 = unknown_isInvalid;
+    e->normal.isInvalid3 = unknown_isInvalid;
+    e->normal.isInvalid4 = unknown_isInvalid;
+  }
+  e->normal.enc.utf8Convert = unknown_toUtf8;
+  e->normal.enc.utf16Convert = unknown_toUtf16;
+  return &(e->normal.enc);
+}
+
+/* If this enumeration is changed, getEncodingIndex and encodings
+must also be changed. */
+enum {
+  UNKNOWN_ENC = -1,
+  ISO_8859_1_ENC = 0,
+  US_ASCII_ENC,
+  UTF_8_ENC,
+  UTF_16_ENC,
+  UTF_16BE_ENC,
+  UTF_16LE_ENC,
+  /* must match encodingNames up to here */
+  NO_ENC
+};
+
+static const char KW_ISO_8859_1[] = {
+  ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9,
+  ASCII_MINUS, ASCII_1, '\0'
+};
+static const char KW_US_ASCII[] = {
+  ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I,
+  '\0'
+};
+static const char KW_UTF_8[] =  {
+  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0'
+};
+static const char KW_UTF_16[] = {
+  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0'
+};
+static const char KW_UTF_16BE[] = {
+  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E,
+  '\0'
+};
+static const char KW_UTF_16LE[] = {
+  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E,
+  '\0'
+};
+
+static int FASTCALL
+getEncodingIndex(const char *name)
+{
+  static const char * const encodingNames[] = {
+    KW_ISO_8859_1,
+    KW_US_ASCII,
+    KW_UTF_8,
+    KW_UTF_16,
+    KW_UTF_16BE,
+    KW_UTF_16LE,
+  };
+  int i;
+  if (name == NULL)
+    return NO_ENC;
+  for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++)
+    if (streqci(name, encodingNames[i]))
+      return i;
+  return UNKNOWN_ENC;
+}
+
+/* For binary compatibility, we store the index of the encoding
+   specified at initialization in the isUtf16 member.
+*/
+
+#define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16)
+#define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i)
+
+/* This is what detects the encoding.  encodingTable maps from
+   encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of
+   the external (protocol) specified encoding; state is
+   XML_CONTENT_STATE if we're parsing an external text entity, and
+   XML_PROLOG_STATE otherwise.
+*/
+
+
+static int
+initScan(const ENCODING * const *encodingTable,
+         const INIT_ENCODING *enc,
+         int state,
+         const char *ptr,
+         const char *end,
+         const char **nextTokPtr)
+{
+  const ENCODING **encPtr;
+
+  if (ptr >= end)
+    return XML_TOK_NONE;
+  encPtr = enc->encPtr;
+  if (ptr + 1 == end) {
+    /* only a single byte available for auto-detection */
+#ifndef XML_DTD /* FIXME */
+    /* a well-formed document entity must have more than one byte */
+    if (state != XML_CONTENT_STATE)
+      return XML_TOK_PARTIAL;
+#endif
+    /* so we're parsing an external text entity... */
+    /* if UTF-16 was externally specified, then we need at least 2 bytes */
+    switch (INIT_ENC_INDEX(enc)) {
+    case UTF_16_ENC:
+    case UTF_16LE_ENC:
+    case UTF_16BE_ENC:
+      return XML_TOK_PARTIAL;
+    }
+    switch ((unsigned char)*ptr) {
+    case 0xFE:
+    case 0xFF:
+    case 0xEF: /* possibly first byte of UTF-8 BOM */
+      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
+          && state == XML_CONTENT_STATE)
+        break;
+      /* fall through */
+    case 0x00:
+    case 0x3C:
+      return XML_TOK_PARTIAL;
+    }
+  }
+  else {
+    switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
+    case 0xFEFF:
+      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
+          && state == XML_CONTENT_STATE)
+        break;
+      *nextTokPtr = ptr + 2;
+      *encPtr = encodingTable[UTF_16BE_ENC];
+      return XML_TOK_BOM;
+    /* 00 3C is handled in the default case */
+    case 0x3C00:
+      if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC
+           || INIT_ENC_INDEX(enc) == UTF_16_ENC)
+          && state == XML_CONTENT_STATE)
+        break;
+      *encPtr = encodingTable[UTF_16LE_ENC];
+      return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
+    case 0xFFFE:
+      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
+          && state == XML_CONTENT_STATE)
+        break;
+      *nextTokPtr = ptr + 2;
+      *encPtr = encodingTable[UTF_16LE_ENC];
+      return XML_TOK_BOM;
+    case 0xEFBB:
+      /* Maybe a UTF-8 BOM (EF BB BF) */
+      /* If there's an explicitly specified (external) encoding
+         of ISO-8859-1 or some flavour of UTF-16
+         and this is an external text entity,
+         don't look for the BOM,
+         because it might be a legal data.
+      */
+      if (state == XML_CONTENT_STATE) {
+        int e = INIT_ENC_INDEX(enc);
+        if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC
+            || e == UTF_16LE_ENC || e == UTF_16_ENC)
+          break;
+      }
+      if (ptr + 2 == end)
+        return XML_TOK_PARTIAL;
+      if ((unsigned char)ptr[2] == 0xBF) {
+        *nextTokPtr = ptr + 3;
+        *encPtr = encodingTable[UTF_8_ENC];
+        return XML_TOK_BOM;
+      }
+      break;
+    default:
+      if (ptr[0] == '\0') {
+        /* 0 isn't a legal data character. Furthermore a document
+           entity can only start with ASCII characters.  So the only
+           way this can fail to be big-endian UTF-16 if it it's an
+           external parsed general entity that's labelled as
+           UTF-16LE.
+        */
+        if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC)
+          break;
+        *encPtr = encodingTable[UTF_16BE_ENC];
+        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
+      }
+      else if (ptr[1] == '\0') {
+        /* We could recover here in the case:
+            - parsing an external entity
+            - second byte is 0
+            - no externally specified encoding
+            - no encoding declaration
+           by assuming UTF-16LE.  But we don't, because this would mean when
+           presented just with a single byte, we couldn't reliably determine
+           whether we needed further bytes.
+        */
+        if (state == XML_CONTENT_STATE)
+          break;
+        *encPtr = encodingTable[UTF_16LE_ENC];
+        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
+      }
+      break;
+    }
+  }
+  *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
+  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
+}
+
+
+#define NS(x) x
+#define ns(x) x
+#define XML_TOK_NS_C
+#include "xmltok_ns.c"
+#undef XML_TOK_NS_C
+#undef NS
+#undef ns
+
+#ifdef XML_NS
+
+#define NS(x) x ## NS
+#define ns(x) x ## _ns
+
+#define XML_TOK_NS_C
+#include "xmltok_ns.c"
+#undef XML_TOK_NS_C
+
+#undef NS
+#undef ns
+
+ENCODING *
+XmlInitUnknownEncodingNS(void *mem,
+                         int *table,
+                         CONVERTER convert,
+                         void *userData)
+{
+  ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
+  if (enc)
+    ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON;
+  return enc;
+}
+
+#endif /* XML_NS */
diff --git a/Utilities/cmexpat/lib/xmltok.h b/Utilities/cmexpat/lib/xmltok.h
new file mode 100644
index 0000000..752007e
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmltok.h
@@ -0,0 +1,322 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+#ifndef XmlTok_INCLUDED
+#define XmlTok_INCLUDED 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The following token may be returned by XmlContentTok */
+#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be
+                                    start of illegal ]]> sequence */
+/* The following tokens may be returned by both XmlPrologTok and
+   XmlContentTok.
+*/
+#define XML_TOK_NONE -4          /* The string to be scanned is empty */
+#define XML_TOK_TRAILING_CR -3   /* A CR at the end of the scan;
+                                    might be part of CRLF sequence */
+#define XML_TOK_PARTIAL_CHAR -2  /* only part of a multibyte sequence */
+#define XML_TOK_PARTIAL -1       /* only part of a token */
+#define XML_TOK_INVALID 0
+
+/* The following tokens are returned by XmlContentTok; some are also
+   returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
+*/
+#define XML_TOK_START_TAG_WITH_ATTS 1
+#define XML_TOK_START_TAG_NO_ATTS 2
+#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
+#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
+#define XML_TOK_END_TAG 5
+#define XML_TOK_DATA_CHARS 6
+#define XML_TOK_DATA_NEWLINE 7
+#define XML_TOK_CDATA_SECT_OPEN 8
+#define XML_TOK_ENTITY_REF 9
+#define XML_TOK_CHAR_REF 10               /* numeric character reference */
+
+/* The following tokens may be returned by both XmlPrologTok and
+   XmlContentTok.
+*/
+#define XML_TOK_PI 11                     /* processing instruction */
+#define XML_TOK_XML_DECL 12               /* XML decl or text decl */
+#define XML_TOK_COMMENT 13
+#define XML_TOK_BOM 14                    /* Byte order mark */
+
+/* The following tokens are returned only by XmlPrologTok */
+#define XML_TOK_PROLOG_S 15
+#define XML_TOK_DECL_OPEN 16              /* <!foo */
+#define XML_TOK_DECL_CLOSE 17             /* > */
+#define XML_TOK_NAME 18
+#define XML_TOK_NMTOKEN 19
+#define XML_TOK_POUND_NAME 20             /* #name */
+#define XML_TOK_OR 21                     /* | */
+#define XML_TOK_PERCENT 22
+#define XML_TOK_OPEN_PAREN 23
+#define XML_TOK_CLOSE_PAREN 24
+#define XML_TOK_OPEN_BRACKET 25
+#define XML_TOK_CLOSE_BRACKET 26
+#define XML_TOK_LITERAL 27
+#define XML_TOK_PARAM_ENTITY_REF 28
+#define XML_TOK_INSTANCE_START 29
+
+/* The following occur only in element type declarations */
+#define XML_TOK_NAME_QUESTION 30          /* name? */
+#define XML_TOK_NAME_ASTERISK 31          /* name* */
+#define XML_TOK_NAME_PLUS 32              /* name+ */
+#define XML_TOK_COND_SECT_OPEN 33         /* <![ */
+#define XML_TOK_COND_SECT_CLOSE 34        /* ]]> */
+#define XML_TOK_CLOSE_PAREN_QUESTION 35   /* )? */
+#define XML_TOK_CLOSE_PAREN_ASTERISK 36   /* )* */
+#define XML_TOK_CLOSE_PAREN_PLUS 37       /* )+ */
+#define XML_TOK_COMMA 38
+
+/* The following token is returned only by XmlAttributeValueTok */
+#define XML_TOK_ATTRIBUTE_VALUE_S 39
+
+/* The following token is returned only by XmlCdataSectionTok */
+#define XML_TOK_CDATA_SECT_CLOSE 40
+
+/* With namespace processing this is returned by XmlPrologTok for a
+   name with a colon.
+*/
+#define XML_TOK_PREFIXED_NAME 41
+
+#ifdef XML_DTD
+#define XML_TOK_IGNORE_SECT 42
+#endif /* XML_DTD */
+
+#ifdef XML_DTD
+#define XML_N_STATES 4
+#else /* not XML_DTD */
+#define XML_N_STATES 3
+#endif /* not XML_DTD */
+
+#define XML_PROLOG_STATE 0
+#define XML_CONTENT_STATE 1
+#define XML_CDATA_SECTION_STATE 2
+#ifdef XML_DTD
+#define XML_IGNORE_SECTION_STATE 3
+#endif /* XML_DTD */
+
+#define XML_N_LITERAL_TYPES 2
+#define XML_ATTRIBUTE_VALUE_LITERAL 0
+#define XML_ENTITY_VALUE_LITERAL 1
+
+/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
+#define XML_UTF8_ENCODE_MAX 4
+/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
+#define XML_UTF16_ENCODE_MAX 2
+
+typedef struct position {
+  /* first line and first column are 0 not 1 */
+  XML_Size lineNumber;
+  XML_Size columnNumber;
+} POSITION;
+
+typedef struct {
+  const char *name;
+  const char *valuePtr;
+  const char *valueEnd;
+  char normalized;
+} ATTRIBUTE;
+
+struct encoding;
+typedef struct encoding ENCODING;
+
+typedef int (PTRCALL *SCANNER)(const ENCODING *,
+                               const char *,
+                               const char *,
+                               const char **);
+
+enum XML_Convert_Result {
+  XML_CONVERT_COMPLETED = 0,
+  XML_CONVERT_INPUT_INCOMPLETE = 1,
+  XML_CONVERT_OUTPUT_EXHAUSTED = 2  /* and therefore potentially input remaining as well */
+};
+
+struct encoding {
+  SCANNER scanners[XML_N_STATES];
+  SCANNER literalScanners[XML_N_LITERAL_TYPES];
+  int (PTRCALL *sameName)(const ENCODING *,
+                          const char *,
+                          const char *);
+  int (PTRCALL *nameMatchesAscii)(const ENCODING *,
+                                  const char *,
+                                  const char *,
+                                  const char *);
+  int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
+  const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
+  int (PTRCALL *getAtts)(const ENCODING *enc,
+                         const char *ptr,
+                         int attsMax,
+                         ATTRIBUTE *atts);
+  int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
+  int (PTRCALL *predefinedEntityName)(const ENCODING *,
+                                      const char *,
+                                      const char *);
+  void (PTRCALL *updatePosition)(const ENCODING *,
+                                 const char *ptr,
+                                 const char *end,
+                                 POSITION *);
+  int (PTRCALL *isPublicId)(const ENCODING *enc,
+                            const char *ptr,
+                            const char *end,
+                            const char **badPtr);
+  enum XML_Convert_Result (PTRCALL *utf8Convert)(const ENCODING *enc,
+                              const char **fromP,
+                              const char *fromLim,
+                              char **toP,
+                              const char *toLim);
+  enum XML_Convert_Result (PTRCALL *utf16Convert)(const ENCODING *enc,
+                               const char **fromP,
+                               const char *fromLim,
+                               unsigned short **toP,
+                               const unsigned short *toLim);
+  int minBytesPerChar;
+  char isUtf8;
+  char isUtf16;
+};
+
+/* Scan the string starting at ptr until the end of the next complete
+   token, but do not scan past eptr.  Return an integer giving the
+   type of token.
+
+   Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
+
+   Return XML_TOK_PARTIAL when the string does not contain a complete
+   token; nextTokPtr will not be set.
+
+   Return XML_TOK_INVALID when the string does not start a valid
+   token; nextTokPtr will be set to point to the character which made
+   the token invalid.
+
+   Otherwise the string starts with a valid token; nextTokPtr will be
+   set to point to the character following the end of that token.
+
+   Each data character counts as a single token, but adjacent data
+   characters may be returned together.  Similarly for characters in
+   the prolog outside literals, comments and processing instructions.
+*/
+
+
+#define XmlTok(enc, state, ptr, end, nextTokPtr) \
+  (((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
+
+#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
+   XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
+
+#define XmlContentTok(enc, ptr, end, nextTokPtr) \
+   XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
+
+#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
+   XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
+
+#ifdef XML_DTD
+
+#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
+   XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
+
+#endif /* XML_DTD */
+
+/* This is used for performing a 2nd-level tokenization on the content
+   of a literal that has already been returned by XmlTok.
+*/
+#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
+  (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
+
+#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
+   XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
+
+#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
+   XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
+
+#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
+
+#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
+  (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
+
+#define XmlNameLength(enc, ptr) \
+  (((enc)->nameLength)(enc, ptr))
+
+#define XmlSkipS(enc, ptr) \
+  (((enc)->skipS)(enc, ptr))
+
+#define XmlGetAttributes(enc, ptr, attsMax, atts) \
+  (((enc)->getAtts)(enc, ptr, attsMax, atts))
+
+#define XmlCharRefNumber(enc, ptr) \
+  (((enc)->charRefNumber)(enc, ptr))
+
+#define XmlPredefinedEntityName(enc, ptr, end) \
+  (((enc)->predefinedEntityName)(enc, ptr, end))
+
+#define XmlUpdatePosition(enc, ptr, end, pos) \
+  (((enc)->updatePosition)(enc, ptr, end, pos))
+
+#define XmlIsPublicId(enc, ptr, end, badPtr) \
+  (((enc)->isPublicId)(enc, ptr, end, badPtr))
+
+#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
+  (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
+
+#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
+  (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
+
+typedef struct {
+  ENCODING initEnc;
+  const ENCODING **encPtr;
+} INIT_ENCODING;
+
+int XmlParseXmlDecl(int isGeneralTextEntity,
+                    const ENCODING *enc,
+                    const char *ptr,
+                    const char *end,
+                    const char **badPtr,
+                    const char **versionPtr,
+                    const char **versionEndPtr,
+                    const char **encodingNamePtr,
+                    const ENCODING **namedEncodingPtr,
+                    int *standalonePtr);
+
+int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
+const ENCODING *XmlGetUtf8InternalEncoding(void);
+const ENCODING *XmlGetUtf16InternalEncoding(void);
+int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
+int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
+int XmlSizeOfUnknownEncoding(void);
+
+
+typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
+
+ENCODING *
+XmlInitUnknownEncoding(void *mem,
+                       int *table,
+                       CONVERTER convert,
+                       void *userData);
+
+int XmlParseXmlDeclNS(int isGeneralTextEntity,
+                      const ENCODING *enc,
+                      const char *ptr,
+                      const char *end,
+                      const char **badPtr,
+                      const char **versionPtr,
+                      const char **versionEndPtr,
+                      const char **encodingNamePtr,
+                      const ENCODING **namedEncodingPtr,
+                      int *standalonePtr);
+
+int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
+const ENCODING *XmlGetUtf8InternalEncodingNS(void);
+const ENCODING *XmlGetUtf16InternalEncodingNS(void);
+ENCODING *
+XmlInitUnknownEncodingNS(void *mem,
+                         int *table,
+                         CONVERTER convert,
+                         void *userData);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* not XmlTok_INCLUDED */
diff --git a/Utilities/cmexpat/lib/xmltok_impl.c b/Utilities/cmexpat/lib/xmltok_impl.c
new file mode 100644
index 0000000..fd0ee22
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmltok_impl.c
@@ -0,0 +1,1775 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+/* This file is included! */
+#ifdef XML_TOK_IMPL_C
+
+#ifndef IS_INVALID_CHAR
+#define IS_INVALID_CHAR(enc, ptr, n) (0)
+#endif
+
+#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
+    case BT_LEAD ## n: \
+      if (end - ptr < n) \
+        return XML_TOK_PARTIAL_CHAR; \
+      if (IS_INVALID_CHAR(enc, ptr, n)) { \
+        *(nextTokPtr) = (ptr); \
+        return XML_TOK_INVALID; \
+      } \
+      ptr += n; \
+      break;
+
+#define INVALID_CASES(ptr, nextTokPtr) \
+  INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
+  INVALID_LEAD_CASE(3, ptr, nextTokPtr) \
+  INVALID_LEAD_CASE(4, ptr, nextTokPtr) \
+  case BT_NONXML: \
+  case BT_MALFORM: \
+  case BT_TRAIL: \
+    *(nextTokPtr) = (ptr); \
+    return XML_TOK_INVALID;
+
+#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \
+   case BT_LEAD ## n: \
+     if (end - ptr < n) \
+       return XML_TOK_PARTIAL_CHAR; \
+     if (!IS_NAME_CHAR(enc, ptr, n)) { \
+       *nextTokPtr = ptr; \
+       return XML_TOK_INVALID; \
+     } \
+     ptr += n; \
+     break;
+
+#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \
+  case BT_NONASCII: \
+    if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \
+      *nextTokPtr = ptr; \
+      return XML_TOK_INVALID; \
+    } \
+  case BT_NMSTRT: \
+  case BT_HEX: \
+  case BT_DIGIT: \
+  case BT_NAME: \
+  case BT_MINUS: \
+    ptr += MINBPC(enc); \
+    break; \
+  CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \
+  CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \
+  CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr)
+
+#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
+   case BT_LEAD ## n: \
+     if (end - ptr < n) \
+       return XML_TOK_PARTIAL_CHAR; \
+     if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \
+       *nextTokPtr = ptr; \
+       return XML_TOK_INVALID; \
+     } \
+     ptr += n; \
+     break;
+
+#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \
+  case BT_NONASCII: \
+    if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \
+      *nextTokPtr = ptr; \
+      return XML_TOK_INVALID; \
+    } \
+  case BT_NMSTRT: \
+  case BT_HEX: \
+    ptr += MINBPC(enc); \
+    break; \
+  CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \
+  CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \
+  CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr)
+
+#ifndef PREFIX
+#define PREFIX(ident) ident
+#endif
+
+
+#define HAS_CHARS(enc, ptr, end, count) \
+    (end - ptr >= count * MINBPC(enc))
+
+#define HAS_CHAR(enc, ptr, end) \
+    HAS_CHARS(enc, ptr, end, 1)
+
+#define REQUIRE_CHARS(enc, ptr, end, count) \
+    { \
+      if (! HAS_CHARS(enc, ptr, end, count)) { \
+        return XML_TOK_PARTIAL; \
+      } \
+    }
+
+#define REQUIRE_CHAR(enc, ptr, end) \
+    REQUIRE_CHARS(enc, ptr, end, 1)
+
+
+/* ptr points to character following "<!-" */
+
+static int PTRCALL
+PREFIX(scanComment)(const ENCODING *enc, const char *ptr,
+                    const char *end, const char **nextTokPtr)
+{
+  if (HAS_CHAR(enc, ptr, end)) {
+    if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+    ptr += MINBPC(enc);
+    while (HAS_CHAR(enc, ptr, end)) {
+      switch (BYTE_TYPE(enc, ptr)) {
+      INVALID_CASES(ptr, nextTokPtr)
+      case BT_MINUS:
+        ptr += MINBPC(enc);
+        REQUIRE_CHAR(enc, ptr, end);
+        if (CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
+          ptr += MINBPC(enc);
+          REQUIRE_CHAR(enc, ptr, end);
+          if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+            *nextTokPtr = ptr;
+            return XML_TOK_INVALID;
+          }
+          *nextTokPtr = ptr + MINBPC(enc);
+          return XML_TOK_COMMENT;
+        }
+        break;
+      default:
+        ptr += MINBPC(enc);
+        break;
+      }
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+/* ptr points to character following "<!" */
+
+static int PTRCALL
+PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
+                 const char *end, const char **nextTokPtr)
+{
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  case BT_MINUS:
+    return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_LSQB:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_COND_SECT_OPEN;
+  case BT_NMSTRT:
+  case BT_HEX:
+    ptr += MINBPC(enc);
+    break;
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_PERCNT:
+      REQUIRE_CHARS(enc, ptr, end, 2);
+      /* don't allow <!ENTITY% foo "whatever"> */
+      switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) {
+      case BT_S: case BT_CR: case BT_LF: case BT_PERCNT:
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      /* fall through */
+    case BT_S: case BT_CR: case BT_LF:
+      *nextTokPtr = ptr;
+      return XML_TOK_DECL_OPEN;
+    case BT_NMSTRT:
+    case BT_HEX:
+      ptr += MINBPC(enc);
+      break;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+static int PTRCALL
+PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr,
+                      const char *end, int *tokPtr)
+{
+  int upper = 0;
+  *tokPtr = XML_TOK_PI;
+  if (end - ptr != MINBPC(enc)*3)
+    return 1;
+  switch (BYTE_TO_ASCII(enc, ptr)) {
+  case ASCII_x:
+    break;
+  case ASCII_X:
+    upper = 1;
+    break;
+  default:
+    return 1;
+  }
+  ptr += MINBPC(enc);
+  switch (BYTE_TO_ASCII(enc, ptr)) {
+  case ASCII_m:
+    break;
+  case ASCII_M:
+    upper = 1;
+    break;
+  default:
+    return 1;
+  }
+  ptr += MINBPC(enc);
+  switch (BYTE_TO_ASCII(enc, ptr)) {
+  case ASCII_l:
+    break;
+  case ASCII_L:
+    upper = 1;
+    break;
+  default:
+    return 1;
+  }
+  if (upper)
+    return 0;
+  *tokPtr = XML_TOK_XML_DECL;
+  return 1;
+}
+
+/* ptr points to character following "<?" */
+
+static int PTRCALL
+PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
+               const char *end, const char **nextTokPtr)
+{
+  int tok;
+  const char *target = ptr;
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+    case BT_S: case BT_CR: case BT_LF:
+      if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      ptr += MINBPC(enc);
+      while (HAS_CHAR(enc, ptr, end)) {
+        switch (BYTE_TYPE(enc, ptr)) {
+        INVALID_CASES(ptr, nextTokPtr)
+        case BT_QUEST:
+          ptr += MINBPC(enc);
+          REQUIRE_CHAR(enc, ptr, end);
+          if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+            *nextTokPtr = ptr + MINBPC(enc);
+            return tok;
+          }
+          break;
+        default:
+          ptr += MINBPC(enc);
+          break;
+        }
+      }
+      return XML_TOK_PARTIAL;
+    case BT_QUEST:
+      if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+        *nextTokPtr = ptr + MINBPC(enc);
+        return tok;
+      }
+      /* fall through */
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+static int PTRCALL
+PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr,
+                         const char *end, const char **nextTokPtr)
+{
+  static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A,
+                                     ASCII_T, ASCII_A, ASCII_LSQB };
+  int i;
+  /* CDATA[ */
+  REQUIRE_CHARS(enc, ptr, end, 6);
+  for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
+    if (!CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) {
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  *nextTokPtr = ptr;
+  return XML_TOK_CDATA_SECT_OPEN;
+}
+
+static int PTRCALL
+PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
+                        const char *end, const char **nextTokPtr)
+{
+  if (ptr >= end)
+    return XML_TOK_NONE;
+  if (MINBPC(enc) > 1) {
+    size_t n = end - ptr;
+    if (n & (MINBPC(enc) - 1)) {
+      n &= ~(MINBPC(enc) - 1);
+      if (n == 0)
+        return XML_TOK_PARTIAL;
+      end = ptr + n;
+    }
+  }
+  switch (BYTE_TYPE(enc, ptr)) {
+  case BT_RSQB:
+    ptr += MINBPC(enc);
+    REQUIRE_CHAR(enc, ptr, end);
+    if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
+      break;
+    ptr += MINBPC(enc);
+    REQUIRE_CHAR(enc, ptr, end);
+    if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+      ptr -= MINBPC(enc);
+      break;
+    }
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_CDATA_SECT_CLOSE;
+  case BT_CR:
+    ptr += MINBPC(enc);
+    REQUIRE_CHAR(enc, ptr, end);
+    if (BYTE_TYPE(enc, ptr) == BT_LF)
+      ptr += MINBPC(enc);
+    *nextTokPtr = ptr;
+    return XML_TOK_DATA_NEWLINE;
+  case BT_LF:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_DATA_NEWLINE;
+  INVALID_CASES(ptr, nextTokPtr)
+  default:
+    ptr += MINBPC(enc);
+    break;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: \
+      if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
+        *nextTokPtr = ptr; \
+        return XML_TOK_DATA_CHARS; \
+      } \
+      ptr += n; \
+      break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_NONXML:
+    case BT_MALFORM:
+    case BT_TRAIL:
+    case BT_CR:
+    case BT_LF:
+    case BT_RSQB:
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+  }
+  *nextTokPtr = ptr;
+  return XML_TOK_DATA_CHARS;
+}
+
+/* ptr points to character following "</" */
+
+static int PTRCALL
+PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
+                   const char *end, const char **nextTokPtr)
+{
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+    case BT_S: case BT_CR: case BT_LF:
+      for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
+        switch (BYTE_TYPE(enc, ptr)) {
+        case BT_S: case BT_CR: case BT_LF:
+          break;
+        case BT_GT:
+          *nextTokPtr = ptr + MINBPC(enc);
+          return XML_TOK_END_TAG;
+        default:
+          *nextTokPtr = ptr;
+          return XML_TOK_INVALID;
+        }
+      }
+      return XML_TOK_PARTIAL;
+#ifdef XML_NS
+    case BT_COLON:
+      /* no need to check qname syntax here,
+         since end-tag must match exactly */
+      ptr += MINBPC(enc);
+      break;
+#endif
+    case BT_GT:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_END_TAG;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+/* ptr points to character following "&#X" */
+
+static int PTRCALL
+PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
+                       const char *end, const char **nextTokPtr)
+{
+  if (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_DIGIT:
+    case BT_HEX:
+      break;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+    for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
+      switch (BYTE_TYPE(enc, ptr)) {
+      case BT_DIGIT:
+      case BT_HEX:
+        break;
+      case BT_SEMI:
+        *nextTokPtr = ptr + MINBPC(enc);
+        return XML_TOK_CHAR_REF;
+      default:
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+/* ptr points to character following "&#" */
+
+static int PTRCALL
+PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
+                    const char *end, const char **nextTokPtr)
+{
+  if (HAS_CHAR(enc, ptr, end)) {
+    if (CHAR_MATCHES(enc, ptr, ASCII_x))
+      return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_DIGIT:
+      break;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+    for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
+      switch (BYTE_TYPE(enc, ptr)) {
+      case BT_DIGIT:
+        break;
+      case BT_SEMI:
+        *nextTokPtr = ptr + MINBPC(enc);
+        return XML_TOK_CHAR_REF;
+      default:
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+/* ptr points to character following "&" */
+
+static int PTRCALL
+PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
+                const char **nextTokPtr)
+{
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+  case BT_NUM:
+    return PREFIX(scanCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+    case BT_SEMI:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_ENTITY_REF;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+/* ptr points to character following first character of attribute name */
+
+static int PTRCALL
+PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
+                 const char **nextTokPtr)
+{
+#ifdef XML_NS
+  int hadColon = 0;
+#endif
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+#ifdef XML_NS
+    case BT_COLON:
+      if (hadColon) {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      hadColon = 1;
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      switch (BYTE_TYPE(enc, ptr)) {
+      CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+      default:
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      break;
+#endif
+    case BT_S: case BT_CR: case BT_LF:
+      for (;;) {
+        int t;
+
+        ptr += MINBPC(enc);
+        REQUIRE_CHAR(enc, ptr, end);
+        t = BYTE_TYPE(enc, ptr);
+        if (t == BT_EQUALS)
+          break;
+        switch (t) {
+        case BT_S:
+        case BT_LF:
+        case BT_CR:
+          break;
+        default:
+          *nextTokPtr = ptr;
+          return XML_TOK_INVALID;
+        }
+      }
+    /* fall through */
+    case BT_EQUALS:
+      {
+        int open;
+#ifdef XML_NS
+        hadColon = 0;
+#endif
+        for (;;) {
+          ptr += MINBPC(enc);
+          REQUIRE_CHAR(enc, ptr, end);
+          open = BYTE_TYPE(enc, ptr);
+          if (open == BT_QUOT || open == BT_APOS)
+            break;
+          switch (open) {
+          case BT_S:
+          case BT_LF:
+          case BT_CR:
+            break;
+          default:
+            *nextTokPtr = ptr;
+            return XML_TOK_INVALID;
+          }
+        }
+        ptr += MINBPC(enc);
+        /* in attribute value */
+        for (;;) {
+          int t;
+          REQUIRE_CHAR(enc, ptr, end);
+          t = BYTE_TYPE(enc, ptr);
+          if (t == open)
+            break;
+          switch (t) {
+          INVALID_CASES(ptr, nextTokPtr)
+          case BT_AMP:
+            {
+              int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr);
+              if (tok <= 0) {
+                if (tok == XML_TOK_INVALID)
+                  *nextTokPtr = ptr;
+                return tok;
+              }
+              break;
+            }
+          case BT_LT:
+            *nextTokPtr = ptr;
+            return XML_TOK_INVALID;
+          default:
+            ptr += MINBPC(enc);
+            break;
+          }
+        }
+        ptr += MINBPC(enc);
+        REQUIRE_CHAR(enc, ptr, end);
+        switch (BYTE_TYPE(enc, ptr)) {
+        case BT_S:
+        case BT_CR:
+        case BT_LF:
+          break;
+        case BT_SOL:
+          goto sol;
+        case BT_GT:
+          goto gt;
+        default:
+          *nextTokPtr = ptr;
+          return XML_TOK_INVALID;
+        }
+        /* ptr points to closing quote */
+        for (;;) {
+          ptr += MINBPC(enc);
+          REQUIRE_CHAR(enc, ptr, end);
+          switch (BYTE_TYPE(enc, ptr)) {
+          CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+          case BT_S: case BT_CR: case BT_LF:
+            continue;
+          case BT_GT:
+          gt:
+            *nextTokPtr = ptr + MINBPC(enc);
+            return XML_TOK_START_TAG_WITH_ATTS;
+          case BT_SOL:
+          sol:
+            ptr += MINBPC(enc);
+            REQUIRE_CHAR(enc, ptr, end);
+            if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+              *nextTokPtr = ptr;
+              return XML_TOK_INVALID;
+            }
+            *nextTokPtr = ptr + MINBPC(enc);
+            return XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
+          default:
+            *nextTokPtr = ptr;
+            return XML_TOK_INVALID;
+          }
+          break;
+        }
+        break;
+      }
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+/* ptr points to character following "<" */
+
+static int PTRCALL
+PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
+               const char **nextTokPtr)
+{
+#ifdef XML_NS
+  int hadColon;
+#endif
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+  case BT_EXCL:
+    ptr += MINBPC(enc);
+    REQUIRE_CHAR(enc, ptr, end);
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_MINUS:
+      return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+    case BT_LSQB:
+      return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc),
+                                      end, nextTokPtr);
+    }
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  case BT_QUEST:
+    return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_SOL:
+    return PREFIX(scanEndTag)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+#ifdef XML_NS
+  hadColon = 0;
+#endif
+  /* we have a start-tag */
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+#ifdef XML_NS
+    case BT_COLON:
+      if (hadColon) {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      hadColon = 1;
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      switch (BYTE_TYPE(enc, ptr)) {
+      CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+      default:
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      break;
+#endif
+    case BT_S: case BT_CR: case BT_LF:
+      {
+        ptr += MINBPC(enc);
+        while (HAS_CHAR(enc, ptr, end)) {
+          switch (BYTE_TYPE(enc, ptr)) {
+          CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+          case BT_GT:
+            goto gt;
+          case BT_SOL:
+            goto sol;
+          case BT_S: case BT_CR: case BT_LF:
+            ptr += MINBPC(enc);
+            continue;
+          default:
+            *nextTokPtr = ptr;
+            return XML_TOK_INVALID;
+          }
+          return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr);
+        }
+        return XML_TOK_PARTIAL;
+      }
+    case BT_GT:
+    gt:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_START_TAG_NO_ATTS;
+    case BT_SOL:
+    sol:
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_EMPTY_ELEMENT_NO_ATTS;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+static int PTRCALL
+PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
+                   const char **nextTokPtr)
+{
+  if (ptr >= end)
+    return XML_TOK_NONE;
+  if (MINBPC(enc) > 1) {
+    size_t n = end - ptr;
+    if (n & (MINBPC(enc) - 1)) {
+      n &= ~(MINBPC(enc) - 1);
+      if (n == 0)
+        return XML_TOK_PARTIAL;
+      end = ptr + n;
+    }
+  }
+  switch (BYTE_TYPE(enc, ptr)) {
+  case BT_LT:
+    return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_AMP:
+    return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_CR:
+    ptr += MINBPC(enc);
+    if (! HAS_CHAR(enc, ptr, end))
+      return XML_TOK_TRAILING_CR;
+    if (BYTE_TYPE(enc, ptr) == BT_LF)
+      ptr += MINBPC(enc);
+    *nextTokPtr = ptr;
+    return XML_TOK_DATA_NEWLINE;
+  case BT_LF:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_DATA_NEWLINE;
+  case BT_RSQB:
+    ptr += MINBPC(enc);
+    if (! HAS_CHAR(enc, ptr, end))
+      return XML_TOK_TRAILING_RSQB;
+    if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
+      break;
+    ptr += MINBPC(enc);
+    if (! HAS_CHAR(enc, ptr, end))
+      return XML_TOK_TRAILING_RSQB;
+    if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+      ptr -= MINBPC(enc);
+      break;
+    }
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  INVALID_CASES(ptr, nextTokPtr)
+  default:
+    ptr += MINBPC(enc);
+    break;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: \
+      if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
+        *nextTokPtr = ptr; \
+        return XML_TOK_DATA_CHARS; \
+      } \
+      ptr += n; \
+      break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_RSQB:
+      if (HAS_CHARS(enc, ptr, end, 2)) {
+         if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) {
+           ptr += MINBPC(enc);
+           break;
+         }
+         if (HAS_CHARS(enc, ptr, end, 3)) {
+           if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) {
+             ptr += MINBPC(enc);
+             break;
+           }
+           *nextTokPtr = ptr + 2*MINBPC(enc);
+           return XML_TOK_INVALID;
+         }
+      }
+      /* fall through */
+    case BT_AMP:
+    case BT_LT:
+    case BT_NONXML:
+    case BT_MALFORM:
+    case BT_TRAIL:
+    case BT_CR:
+    case BT_LF:
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+  }
+  *nextTokPtr = ptr;
+  return XML_TOK_DATA_CHARS;
+}
+
+/* ptr points to character following "%" */
+
+static int PTRCALL
+PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
+                    const char **nextTokPtr)
+{
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+  case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
+    *nextTokPtr = ptr;
+    return XML_TOK_PERCENT;
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+    case BT_SEMI:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_PARAM_ENTITY_REF;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+static int PTRCALL
+PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
+                      const char **nextTokPtr)
+{
+  REQUIRE_CHAR(enc, ptr, end);
+  switch (BYTE_TYPE(enc, ptr)) {
+  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+    case BT_CR: case BT_LF: case BT_S:
+    case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR:
+      *nextTokPtr = ptr;
+      return XML_TOK_POUND_NAME;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return -XML_TOK_POUND_NAME;
+}
+
+static int PTRCALL
+PREFIX(scanLit)(int open, const ENCODING *enc,
+                const char *ptr, const char *end,
+                const char **nextTokPtr)
+{
+  while (HAS_CHAR(enc, ptr, end)) {
+    int t = BYTE_TYPE(enc, ptr);
+    switch (t) {
+    INVALID_CASES(ptr, nextTokPtr)
+    case BT_QUOT:
+    case BT_APOS:
+      ptr += MINBPC(enc);
+      if (t != open)
+        break;
+      if (! HAS_CHAR(enc, ptr, end))
+        return -XML_TOK_LITERAL;
+      *nextTokPtr = ptr;
+      switch (BYTE_TYPE(enc, ptr)) {
+      case BT_S: case BT_CR: case BT_LF:
+      case BT_GT: case BT_PERCNT: case BT_LSQB:
+        return XML_TOK_LITERAL;
+      default:
+        return XML_TOK_INVALID;
+      }
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+static int PTRCALL
+PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
+                  const char **nextTokPtr)
+{
+  int tok;
+  if (ptr >= end)
+    return XML_TOK_NONE;
+  if (MINBPC(enc) > 1) {
+    size_t n = end - ptr;
+    if (n & (MINBPC(enc) - 1)) {
+      n &= ~(MINBPC(enc) - 1);
+      if (n == 0)
+        return XML_TOK_PARTIAL;
+      end = ptr + n;
+    }
+  }
+  switch (BYTE_TYPE(enc, ptr)) {
+  case BT_QUOT:
+    return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_APOS:
+    return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_LT:
+    {
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      switch (BYTE_TYPE(enc, ptr)) {
+      case BT_EXCL:
+        return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+      case BT_QUEST:
+        return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+      case BT_NMSTRT:
+      case BT_HEX:
+      case BT_NONASCII:
+      case BT_LEAD2:
+      case BT_LEAD3:
+      case BT_LEAD4:
+        *nextTokPtr = ptr - MINBPC(enc);
+        return XML_TOK_INSTANCE_START;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  case BT_CR:
+    if (ptr + MINBPC(enc) == end) {
+      *nextTokPtr = end;
+      /* indicate that this might be part of a CR/LF pair */
+      return -XML_TOK_PROLOG_S;
+    }
+    /* fall through */
+  case BT_S: case BT_LF:
+    for (;;) {
+      ptr += MINBPC(enc);
+      if (! HAS_CHAR(enc, ptr, end))
+        break;
+      switch (BYTE_TYPE(enc, ptr)) {
+      case BT_S: case BT_LF:
+        break;
+      case BT_CR:
+        /* don't split CR/LF pair */
+        if (ptr + MINBPC(enc) != end)
+          break;
+        /* fall through */
+      default:
+        *nextTokPtr = ptr;
+        return XML_TOK_PROLOG_S;
+      }
+    }
+    *nextTokPtr = ptr;
+    return XML_TOK_PROLOG_S;
+  case BT_PERCNT:
+    return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+  case BT_COMMA:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_COMMA;
+  case BT_LSQB:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_OPEN_BRACKET;
+  case BT_RSQB:
+    ptr += MINBPC(enc);
+    if (! HAS_CHAR(enc, ptr, end))
+      return -XML_TOK_CLOSE_BRACKET;
+    if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
+      REQUIRE_CHARS(enc, ptr, end, 2);
+      if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) {
+        *nextTokPtr = ptr + 2*MINBPC(enc);
+        return XML_TOK_COND_SECT_CLOSE;
+      }
+    }
+    *nextTokPtr = ptr;
+    return XML_TOK_CLOSE_BRACKET;
+  case BT_LPAR:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_OPEN_PAREN;
+  case BT_RPAR:
+    ptr += MINBPC(enc);
+    if (! HAS_CHAR(enc, ptr, end))
+      return -XML_TOK_CLOSE_PAREN;
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_AST:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_CLOSE_PAREN_ASTERISK;
+    case BT_QUEST:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_CLOSE_PAREN_QUESTION;
+    case BT_PLUS:
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_CLOSE_PAREN_PLUS;
+    case BT_CR: case BT_LF: case BT_S:
+    case BT_GT: case BT_COMMA: case BT_VERBAR:
+    case BT_RPAR:
+      *nextTokPtr = ptr;
+      return XML_TOK_CLOSE_PAREN;
+    }
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  case BT_VERBAR:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_OR;
+  case BT_GT:
+    *nextTokPtr = ptr + MINBPC(enc);
+    return XML_TOK_DECL_CLOSE;
+  case BT_NUM:
+    return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+#define LEAD_CASE(n) \
+  case BT_LEAD ## n: \
+    if (end - ptr < n) \
+      return XML_TOK_PARTIAL_CHAR; \
+    if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
+      ptr += n; \
+      tok = XML_TOK_NAME; \
+      break; \
+    } \
+    if (IS_NAME_CHAR(enc, ptr, n)) { \
+      ptr += n; \
+      tok = XML_TOK_NMTOKEN; \
+      break; \
+    } \
+    *nextTokPtr = ptr; \
+    return XML_TOK_INVALID;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+  case BT_NMSTRT:
+  case BT_HEX:
+    tok = XML_TOK_NAME;
+    ptr += MINBPC(enc);
+    break;
+  case BT_DIGIT:
+  case BT_NAME:
+  case BT_MINUS:
+#ifdef XML_NS
+  case BT_COLON:
+#endif
+    tok = XML_TOK_NMTOKEN;
+    ptr += MINBPC(enc);
+    break;
+  case BT_NONASCII:
+    if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) {
+      ptr += MINBPC(enc);
+      tok = XML_TOK_NAME;
+      break;
+    }
+    if (IS_NAME_CHAR_MINBPC(enc, ptr)) {
+      ptr += MINBPC(enc);
+      tok = XML_TOK_NMTOKEN;
+      break;
+    }
+    /* fall through */
+  default:
+    *nextTokPtr = ptr;
+    return XML_TOK_INVALID;
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+    case BT_GT: case BT_RPAR: case BT_COMMA:
+    case BT_VERBAR: case BT_LSQB: case BT_PERCNT:
+    case BT_S: case BT_CR: case BT_LF:
+      *nextTokPtr = ptr;
+      return tok;
+#ifdef XML_NS
+    case BT_COLON:
+      ptr += MINBPC(enc);
+      switch (tok) {
+      case XML_TOK_NAME:
+        REQUIRE_CHAR(enc, ptr, end);
+        tok = XML_TOK_PREFIXED_NAME;
+        switch (BYTE_TYPE(enc, ptr)) {
+        CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+        default:
+          tok = XML_TOK_NMTOKEN;
+          break;
+        }
+        break;
+      case XML_TOK_PREFIXED_NAME:
+        tok = XML_TOK_NMTOKEN;
+        break;
+      }
+      break;
+#endif
+    case BT_PLUS:
+      if (tok == XML_TOK_NMTOKEN)  {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_NAME_PLUS;
+    case BT_AST:
+      if (tok == XML_TOK_NMTOKEN)  {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_NAME_ASTERISK;
+    case BT_QUEST:
+      if (tok == XML_TOK_NMTOKEN)  {
+        *nextTokPtr = ptr;
+        return XML_TOK_INVALID;
+      }
+      *nextTokPtr = ptr + MINBPC(enc);
+      return XML_TOK_NAME_QUESTION;
+    default:
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    }
+  }
+  return -tok;
+}
+
+static int PTRCALL
+PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
+                          const char *end, const char **nextTokPtr)
+{
+  const char *start;
+  if (ptr >= end)
+    return XML_TOK_NONE;
+  start = ptr;
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: ptr += n; break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_AMP:
+      if (ptr == start)
+        return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    case BT_LT:
+      /* this is for inside entity references */
+      *nextTokPtr = ptr;
+      return XML_TOK_INVALID;
+    case BT_LF:
+      if (ptr == start) {
+        *nextTokPtr = ptr + MINBPC(enc);
+        return XML_TOK_DATA_NEWLINE;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    case BT_CR:
+      if (ptr == start) {
+        ptr += MINBPC(enc);
+        if (! HAS_CHAR(enc, ptr, end))
+          return XML_TOK_TRAILING_CR;
+        if (BYTE_TYPE(enc, ptr) == BT_LF)
+          ptr += MINBPC(enc);
+        *nextTokPtr = ptr;
+        return XML_TOK_DATA_NEWLINE;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    case BT_S:
+      if (ptr == start) {
+        *nextTokPtr = ptr + MINBPC(enc);
+        return XML_TOK_ATTRIBUTE_VALUE_S;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+  }
+  *nextTokPtr = ptr;
+  return XML_TOK_DATA_CHARS;
+}
+
+static int PTRCALL
+PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
+                       const char *end, const char **nextTokPtr)
+{
+  const char *start;
+  if (ptr >= end)
+    return XML_TOK_NONE;
+  start = ptr;
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: ptr += n; break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_AMP:
+      if (ptr == start)
+        return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    case BT_PERCNT:
+      if (ptr == start) {
+        int tok =  PREFIX(scanPercent)(enc, ptr + MINBPC(enc),
+                                       end, nextTokPtr);
+        return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    case BT_LF:
+      if (ptr == start) {
+        *nextTokPtr = ptr + MINBPC(enc);
+        return XML_TOK_DATA_NEWLINE;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    case BT_CR:
+      if (ptr == start) {
+        ptr += MINBPC(enc);
+        if (! HAS_CHAR(enc, ptr, end))
+          return XML_TOK_TRAILING_CR;
+        if (BYTE_TYPE(enc, ptr) == BT_LF)
+          ptr += MINBPC(enc);
+        *nextTokPtr = ptr;
+        return XML_TOK_DATA_NEWLINE;
+      }
+      *nextTokPtr = ptr;
+      return XML_TOK_DATA_CHARS;
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+  }
+  *nextTokPtr = ptr;
+  return XML_TOK_DATA_CHARS;
+}
+
+#ifdef XML_DTD
+
+static int PTRCALL
+PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
+                         const char *end, const char **nextTokPtr)
+{
+  int level = 0;
+  if (MINBPC(enc) > 1) {
+    size_t n = end - ptr;
+    if (n & (MINBPC(enc) - 1)) {
+      n &= ~(MINBPC(enc) - 1);
+      end = ptr + n;
+    }
+  }
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    INVALID_CASES(ptr, nextTokPtr)
+    case BT_LT:
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) {
+        ptr += MINBPC(enc);
+        REQUIRE_CHAR(enc, ptr, end);
+        if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) {
+          ++level;
+          ptr += MINBPC(enc);
+        }
+      }
+      break;
+    case BT_RSQB:
+      ptr += MINBPC(enc);
+      REQUIRE_CHAR(enc, ptr, end);
+      if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
+        ptr += MINBPC(enc);
+        REQUIRE_CHAR(enc, ptr, end);
+        if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+          ptr += MINBPC(enc);
+          if (level == 0) {
+            *nextTokPtr = ptr;
+            return XML_TOK_IGNORE_SECT;
+          }
+          --level;
+        }
+      }
+      break;
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+  }
+  return XML_TOK_PARTIAL;
+}
+
+#endif /* XML_DTD */
+
+static int PTRCALL
+PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
+                   const char **badPtr)
+{
+  ptr += MINBPC(enc);
+  end -= MINBPC(enc);
+  for (; HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_DIGIT:
+    case BT_HEX:
+    case BT_MINUS:
+    case BT_APOS:
+    case BT_LPAR:
+    case BT_RPAR:
+    case BT_PLUS:
+    case BT_COMMA:
+    case BT_SOL:
+    case BT_EQUALS:
+    case BT_QUEST:
+    case BT_CR:
+    case BT_LF:
+    case BT_SEMI:
+    case BT_EXCL:
+    case BT_AST:
+    case BT_PERCNT:
+    case BT_NUM:
+#ifdef XML_NS
+    case BT_COLON:
+#endif
+      break;
+    case BT_S:
+      if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) {
+        *badPtr = ptr;
+        return 0;
+      }
+      break;
+    case BT_NAME:
+    case BT_NMSTRT:
+      if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
+        break;
+    default:
+      switch (BYTE_TO_ASCII(enc, ptr)) {
+      case 0x24: /* $ */
+      case 0x40: /* @ */
+        break;
+      default:
+        *badPtr = ptr;
+        return 0;
+      }
+      break;
+    }
+  }
+  return 1;
+}
+
+/* This must only be called for a well-formed start-tag or empty
+   element tag.  Returns the number of attributes.  Pointers to the
+   first attsMax attributes are stored in atts.
+*/
+
+static int PTRCALL
+PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
+                int attsMax, ATTRIBUTE *atts)
+{
+  enum { other, inName, inValue } state = inName;
+  int nAtts = 0;
+  int open = 0; /* defined when state == inValue;
+                   initialization just to shut up compilers */
+
+  for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define START_NAME \
+      if (state == other) { \
+        if (nAtts < attsMax) { \
+          atts[nAtts].name = ptr; \
+          atts[nAtts].normalized = 1; \
+        } \
+        state = inName; \
+      }
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_NONASCII:
+    case BT_NMSTRT:
+    case BT_HEX:
+      START_NAME
+      break;
+#undef START_NAME
+    case BT_QUOT:
+      if (state != inValue) {
+        if (nAtts < attsMax)
+          atts[nAtts].valuePtr = ptr + MINBPC(enc);
+        state = inValue;
+        open = BT_QUOT;
+      }
+      else if (open == BT_QUOT) {
+        state = other;
+        if (nAtts < attsMax)
+          atts[nAtts].valueEnd = ptr;
+        nAtts++;
+      }
+      break;
+    case BT_APOS:
+      if (state != inValue) {
+        if (nAtts < attsMax)
+          atts[nAtts].valuePtr = ptr + MINBPC(enc);
+        state = inValue;
+        open = BT_APOS;
+      }
+      else if (open == BT_APOS) {
+        state = other;
+        if (nAtts < attsMax)
+          atts[nAtts].valueEnd = ptr;
+        nAtts++;
+      }
+      break;
+    case BT_AMP:
+      if (nAtts < attsMax)
+        atts[nAtts].normalized = 0;
+      break;
+    case BT_S:
+      if (state == inName)
+        state = other;
+      else if (state == inValue
+               && nAtts < attsMax
+               && atts[nAtts].normalized
+               && (ptr == atts[nAtts].valuePtr
+                   || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE
+                   || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE
+                   || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
+        atts[nAtts].normalized = 0;
+      break;
+    case BT_CR: case BT_LF:
+      /* This case ensures that the first attribute name is counted
+         Apart from that we could just change state on the quote. */
+      if (state == inName)
+        state = other;
+      else if (state == inValue && nAtts < attsMax)
+        atts[nAtts].normalized = 0;
+      break;
+    case BT_GT:
+    case BT_SOL:
+      if (state != inValue)
+        return nAtts;
+      break;
+    default:
+      break;
+    }
+  }
+  /* not reached */
+}
+
+static int PTRFASTCALL
+PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
+{
+  int result = 0;
+  /* skip &# */
+  ptr += 2*MINBPC(enc);
+  if (CHAR_MATCHES(enc, ptr, ASCII_x)) {
+    for (ptr += MINBPC(enc);
+         !CHAR_MATCHES(enc, ptr, ASCII_SEMI);
+         ptr += MINBPC(enc)) {
+      int c = BYTE_TO_ASCII(enc, ptr);
+      switch (c) {
+      case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4:
+      case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9:
+        result <<= 4;
+        result |= (c - ASCII_0);
+        break;
+      case ASCII_A: case ASCII_B: case ASCII_C:
+      case ASCII_D: case ASCII_E: case ASCII_F:
+        result <<= 4;
+        result += 10 + (c - ASCII_A);
+        break;
+      case ASCII_a: case ASCII_b: case ASCII_c:
+      case ASCII_d: case ASCII_e: case ASCII_f:
+        result <<= 4;
+        result += 10 + (c - ASCII_a);
+        break;
+      }
+      if (result >= 0x110000)
+        return -1;
+    }
+  }
+  else {
+    for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
+      int c = BYTE_TO_ASCII(enc, ptr);
+      result *= 10;
+      result += (c - ASCII_0);
+      if (result >= 0x110000)
+        return -1;
+    }
+  }
+  return checkCharRefNumber(result);
+}
+
+static int PTRCALL
+PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr,
+                             const char *end)
+{
+  switch ((end - ptr)/MINBPC(enc)) {
+  case 2:
+    if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) {
+      switch (BYTE_TO_ASCII(enc, ptr)) {
+      case ASCII_l:
+        return ASCII_LT;
+      case ASCII_g:
+        return ASCII_GT;
+      }
+    }
+    break;
+  case 3:
+    if (CHAR_MATCHES(enc, ptr, ASCII_a)) {
+      ptr += MINBPC(enc);
+      if (CHAR_MATCHES(enc, ptr, ASCII_m)) {
+        ptr += MINBPC(enc);
+        if (CHAR_MATCHES(enc, ptr, ASCII_p))
+          return ASCII_AMP;
+      }
+    }
+    break;
+  case 4:
+    switch (BYTE_TO_ASCII(enc, ptr)) {
+    case ASCII_q:
+      ptr += MINBPC(enc);
+      if (CHAR_MATCHES(enc, ptr, ASCII_u)) {
+        ptr += MINBPC(enc);
+        if (CHAR_MATCHES(enc, ptr, ASCII_o)) {
+          ptr += MINBPC(enc);
+          if (CHAR_MATCHES(enc, ptr, ASCII_t))
+            return ASCII_QUOT;
+        }
+      }
+      break;
+    case ASCII_a:
+      ptr += MINBPC(enc);
+      if (CHAR_MATCHES(enc, ptr, ASCII_p)) {
+        ptr += MINBPC(enc);
+        if (CHAR_MATCHES(enc, ptr, ASCII_o)) {
+          ptr += MINBPC(enc);
+          if (CHAR_MATCHES(enc, ptr, ASCII_s))
+            return ASCII_APOS;
+        }
+      }
+      break;
+    }
+  }
+  return 0;
+}
+
+static int PTRCALL
+PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
+{
+  for (;;) {
+    switch (BYTE_TYPE(enc, ptr1)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: \
+      if (*ptr1++ != *ptr2++) \
+        return 0;
+    LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
+#undef LEAD_CASE
+      /* fall through */
+      if (*ptr1++ != *ptr2++)
+        return 0;
+      break;
+    case BT_NONASCII:
+    case BT_NMSTRT:
+#ifdef XML_NS
+    case BT_COLON:
+#endif
+    case BT_HEX:
+    case BT_DIGIT:
+    case BT_NAME:
+    case BT_MINUS:
+      if (*ptr2++ != *ptr1++)
+        return 0;
+      if (MINBPC(enc) > 1) {
+        if (*ptr2++ != *ptr1++)
+          return 0;
+        if (MINBPC(enc) > 2) {
+          if (*ptr2++ != *ptr1++)
+            return 0;
+          if (MINBPC(enc) > 3) {
+            if (*ptr2++ != *ptr1++)
+              return 0;
+          }
+        }
+      }
+      break;
+    default:
+      if (MINBPC(enc) == 1 && *ptr1 == *ptr2)
+        return 1;
+      switch (BYTE_TYPE(enc, ptr2)) {
+      case BT_LEAD2:
+      case BT_LEAD3:
+      case BT_LEAD4:
+      case BT_NONASCII:
+      case BT_NMSTRT:
+#ifdef XML_NS
+      case BT_COLON:
+#endif
+      case BT_HEX:
+      case BT_DIGIT:
+      case BT_NAME:
+      case BT_MINUS:
+        return 0;
+      default:
+        return 1;
+      }
+    }
+  }
+  /* not reached */
+}
+
+static int PTRCALL
+PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
+                         const char *end1, const char *ptr2)
+{
+  for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
+    if (end1 - ptr1 < MINBPC(enc))
+      return 0;
+    if (!CHAR_MATCHES(enc, ptr1, *ptr2))
+      return 0;
+  }
+  return ptr1 == end1;
+}
+
+static int PTRFASTCALL
+PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
+{
+  const char *start = ptr;
+  for (;;) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: ptr += n; break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_NONASCII:
+    case BT_NMSTRT:
+#ifdef XML_NS
+    case BT_COLON:
+#endif
+    case BT_HEX:
+    case BT_DIGIT:
+    case BT_NAME:
+    case BT_MINUS:
+      ptr += MINBPC(enc);
+      break;
+    default:
+      return (int)(ptr - start);
+    }
+  }
+}
+
+static const char * PTRFASTCALL
+PREFIX(skipS)(const ENCODING *enc, const char *ptr)
+{
+  for (;;) {
+    switch (BYTE_TYPE(enc, ptr)) {
+    case BT_LF:
+    case BT_CR:
+    case BT_S:
+      ptr += MINBPC(enc);
+      break;
+    default:
+      return ptr;
+    }
+  }
+}
+
+static void PTRCALL
+PREFIX(updatePosition)(const ENCODING *enc,
+                       const char *ptr,
+                       const char *end,
+                       POSITION *pos)
+{
+  while (HAS_CHAR(enc, ptr, end)) {
+    switch (BYTE_TYPE(enc, ptr)) {
+#define LEAD_CASE(n) \
+    case BT_LEAD ## n: \
+      ptr += n; \
+      break;
+    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
+#undef LEAD_CASE
+    case BT_LF:
+      pos->columnNumber = (XML_Size)-1;
+      pos->lineNumber++;
+      ptr += MINBPC(enc);
+      break;
+    case BT_CR:
+      pos->lineNumber++;
+      ptr += MINBPC(enc);
+      if (HAS_CHAR(enc, ptr, end) && BYTE_TYPE(enc, ptr) == BT_LF)
+        ptr += MINBPC(enc);
+      pos->columnNumber = (XML_Size)-1;
+      break;
+    default:
+      ptr += MINBPC(enc);
+      break;
+    }
+    pos->columnNumber++;
+  }
+}
+
+#undef DO_LEAD_CASE
+#undef MULTIBYTE_CASES
+#undef INVALID_CASES
+#undef CHECK_NAME_CASE
+#undef CHECK_NAME_CASES
+#undef CHECK_NMSTRT_CASE
+#undef CHECK_NMSTRT_CASES
+
+#endif /* XML_TOK_IMPL_C */
diff --git a/Utilities/cmexpat/xmltok_impl.h b/Utilities/cmexpat/lib/xmltok_impl.h
similarity index 100%
rename from Utilities/cmexpat/xmltok_impl.h
rename to Utilities/cmexpat/lib/xmltok_impl.h
diff --git a/Utilities/cmexpat/lib/xmltok_ns.c b/Utilities/cmexpat/lib/xmltok_ns.c
new file mode 100644
index 0000000..c3b88fd
--- /dev/null
+++ b/Utilities/cmexpat/lib/xmltok_ns.c
@@ -0,0 +1,115 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+/* This file is included! */
+#ifdef XML_TOK_NS_C
+
+const ENCODING *
+NS(XmlGetUtf8InternalEncoding)(void)
+{
+  return &ns(internal_utf8_encoding).enc;
+}
+
+const ENCODING *
+NS(XmlGetUtf16InternalEncoding)(void)
+{
+#if BYTEORDER == 1234
+  return &ns(internal_little2_encoding).enc;
+#elif BYTEORDER == 4321
+  return &ns(internal_big2_encoding).enc;
+#else
+  const short n = 1;
+  return (*(const char *)&n
+          ? &ns(internal_little2_encoding).enc
+          : &ns(internal_big2_encoding).enc);
+#endif
+}
+
+static const ENCODING * const NS(encodings)[] = {
+  &ns(latin1_encoding).enc,
+  &ns(ascii_encoding).enc,
+  &ns(utf8_encoding).enc,
+  &ns(big2_encoding).enc,
+  &ns(big2_encoding).enc,
+  &ns(little2_encoding).enc,
+  &ns(utf8_encoding).enc /* NO_ENC */
+};
+
+static int PTRCALL
+NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
+                   const char **nextTokPtr)
+{
+  return initScan(NS(encodings), (const INIT_ENCODING *)enc,
+                  XML_PROLOG_STATE, ptr, end, nextTokPtr);
+}
+
+static int PTRCALL
+NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
+                    const char **nextTokPtr)
+{
+  return initScan(NS(encodings), (const INIT_ENCODING *)enc,
+                  XML_CONTENT_STATE, ptr, end, nextTokPtr);
+}
+
+int
+NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
+                    const char *name)
+{
+  int i = getEncodingIndex(name);
+  if (i == UNKNOWN_ENC)
+    return 0;
+  SET_INIT_ENC_INDEX(p, i);
+  p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
+  p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
+  p->initEnc.updatePosition = initUpdatePosition;
+  p->encPtr = encPtr;
+  *encPtr = &(p->initEnc);
+  return 1;
+}
+
+static const ENCODING *
+NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
+{
+#define ENCODING_MAX 128
+  char buf[ENCODING_MAX];
+  char *p = buf;
+  int i;
+  XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
+  if (ptr != end)
+    return 0;
+  *p = 0;
+  if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
+    return enc;
+  i = getEncodingIndex(buf);
+  if (i == UNKNOWN_ENC)
+    return 0;
+  return NS(encodings)[i];
+}
+
+int
+NS(XmlParseXmlDecl)(int isGeneralTextEntity,
+                    const ENCODING *enc,
+                    const char *ptr,
+                    const char *end,
+                    const char **badPtr,
+                    const char **versionPtr,
+                    const char **versionEndPtr,
+                    const char **encodingName,
+                    const ENCODING **encoding,
+                    int *standalone)
+{
+  return doParseXmlDecl(NS(findEncoding),
+                        isGeneralTextEntity,
+                        enc,
+                        ptr,
+                        end,
+                        badPtr,
+                        versionPtr,
+                        versionEndPtr,
+                        encodingName,
+                        encoding,
+                        standalone);
+}
+
+#endif /* XML_TOK_NS_C */
diff --git a/Utilities/cmexpat/utf8tab.h b/Utilities/cmexpat/utf8tab.h
deleted file mode 100644
index 9e3b6b8..0000000
--- a/Utilities/cmexpat/utf8tab.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-
-/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
-/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
diff --git a/Utilities/cmexpat/xmlparse.c b/Utilities/cmexpat/xmlparse.c
deleted file mode 100644
index 29ea3d3..0000000
--- a/Utilities/cmexpat/xmlparse.c
+++ /dev/null
@@ -1,4622 +0,0 @@
-/*
-Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#include <cmexpat/expatConfig.h>
-#include <cmexpat/expat.h>
-
-#include <stddef.h>
-#include <string.h>
-
-#ifdef XML_UNICODE
-#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
-#define XmlConvert XmlUtf16Convert
-#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
-#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
-#define XmlEncode XmlUtf16Encode
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1))
-typedef unsigned short ICHAR;
-#else
-#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
-#define XmlConvert XmlUtf8Convert
-#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
-#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
-#define XmlEncode XmlUtf8Encode
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf8)
-typedef char ICHAR;
-#endif
-
-
-#ifndef XML_NS
-
-#define XmlInitEncodingNS XmlInitEncoding
-#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding
-#undef XmlGetInternalEncodingNS
-#define XmlGetInternalEncodingNS XmlGetInternalEncoding
-#define XmlParseXmlDeclNS XmlParseXmlDecl
-
-#endif
-
-#ifdef XML_UNICODE_WCHAR_T
-#define XML_T(x) L ## x
-#else
-#define XML_T(x) x
-#endif
-
-/* Round up n to be a multiple of sz, where sz is a power of 2. */
-#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
-
-#include "xmltok.h"
-#include "xmlrole.h"
-
-typedef const XML_Char *KEY;
-
-typedef struct {
-  KEY name;
-} NAMED;
-
-typedef struct {
-  NAMED **v;
-  size_t size;
-  size_t used;
-  size_t usedLim;
-  XML_Memory_Handling_Suite *mem;
-} HASH_TABLE;
-
-typedef struct {
-  NAMED **p;
-  NAMED **end;
-} HASH_TABLE_ITER;
-
-#define INIT_TAG_BUF_SIZE 32  /* must be a multiple of sizeof(XML_Char) */
-#define INIT_DATA_BUF_SIZE 1024
-#define INIT_ATTS_SIZE 16
-#define INIT_BLOCK_SIZE 1024
-#define INIT_BUFFER_SIZE 1024
-
-#define EXPAND_SPARE 24
-
-typedef struct binding {
-  struct prefix *prefix;
-  struct binding *nextTagBinding;
-  struct binding *prevPrefixBinding;
-  const struct attribute_id *attId;
-  XML_Char *uri;
-  int uriLen;
-  int uriAlloc;
-} BINDING;
-
-typedef struct prefix {
-  const XML_Char *name;
-  BINDING *binding;
-} PREFIX;
-
-typedef struct {
-  const XML_Char *str;
-  const XML_Char *localPart;
-  int uriLen;
-} TAG_NAME;
-
-typedef struct tag {
-  struct tag *parent;
-  const char *rawName;
-  int rawNameLength;
-  TAG_NAME name;
-  char *buf;
-  char *bufEnd;
-  BINDING *bindings;
-} TAG;
-
-typedef struct {
-  const XML_Char *name;
-  const XML_Char *textPtr;
-  int textLen;
-  const XML_Char *systemId;
-  const XML_Char *base;
-  const XML_Char *publicId;
-  const XML_Char *notation;
-  char open;
-  char is_param;
-} ENTITY;
-
-typedef struct {
-  enum XML_Content_Type         type;
-  enum XML_Content_Quant        quant;
-  const XML_Char *              name;
-  int                           firstchild;
-  int                           lastchild;
-  int                           childcnt;
-  int                           nextsib;
-} CONTENT_SCAFFOLD;
-
-typedef struct block {
-  struct block *next;
-  int size;
-  XML_Char s[1];
-} BLOCK;
-
-typedef struct {
-  BLOCK *blocks;
-  BLOCK *freeBlocks;
-  const XML_Char *end;
-  XML_Char *ptr;
-  XML_Char *start;
-  XML_Memory_Handling_Suite *mem;
-} STRING_POOL;
-
-/* The XML_Char before the name is used to determine whether
-an attribute has been specified. */
-typedef struct attribute_id {
-  XML_Char *name;
-  PREFIX *prefix;
-  char maybeTokenized;
-  char xmlns;
-} ATTRIBUTE_ID;
-
-typedef struct {
-  const ATTRIBUTE_ID *id;
-  char isCdata;
-  const XML_Char *value;
-} DEFAULT_ATTRIBUTE;
-
-typedef struct {
-  const XML_Char *name;
-  PREFIX *prefix;
-  const ATTRIBUTE_ID *idAtt;
-  int nDefaultAtts;
-  int allocDefaultAtts;
-  DEFAULT_ATTRIBUTE *defaultAtts;
-} ELEMENT_TYPE;
-
-typedef struct {
-  HASH_TABLE generalEntities;
-  HASH_TABLE elementTypes;
-  HASH_TABLE attributeIds;
-  HASH_TABLE prefixes;
-  STRING_POOL pool;
-  int complete;
-  int standalone;
-#ifdef XML_DTD
-  HASH_TABLE paramEntities;
-#endif /* XML_DTD */
-  PREFIX defaultPrefix;
-  /* === scaffolding for building content model === */
-  int in_eldecl;
-  CONTENT_SCAFFOLD *scaffold;
-  unsigned contentStringLen;
-  unsigned scaffSize;
-  unsigned scaffCount;
-  int scaffLevel;
-  int *scaffIndex;
-} DTD;
-
-typedef struct open_internal_entity {
-  const char *internalEventPtr;
-  const char *internalEventEndPtr;
-  struct open_internal_entity *next;
-  ENTITY *entity;
-} OPEN_INTERNAL_ENTITY;
-
-typedef enum XML_Error Processor(XML_Parser parser,
-                                 const char *start,
-                                 const char *end,
-                                 const char **endPtr);
-
-static Processor prologProcessor;
-static Processor prologInitProcessor;
-static Processor contentProcessor;
-static Processor cdataSectionProcessor;
-#ifdef XML_DTD
-static Processor ignoreSectionProcessor;
-#endif /* XML_DTD */
-static Processor epilogProcessor;
-static Processor errorProcessor;
-static Processor externalEntityInitProcessor;
-static Processor externalEntityInitProcessor2;
-static Processor externalEntityInitProcessor3;
-static Processor externalEntityContentProcessor;
-
-static enum XML_Error
-handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName);
-static enum XML_Error
-processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *, const char *);
-static enum XML_Error
-initializeEncoding(XML_Parser parser);
-static enum XML_Error
-doProlog(XML_Parser parser, const ENCODING *enc, const char *s,
-         const char *end, int tok, const char *next, const char **nextPtr);
-static enum XML_Error
-processInternalParamEntity(XML_Parser parser, ENTITY *entity);
-static enum XML_Error
-doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
-          const char *start, const char *end, const char **endPtr);
-static enum XML_Error
-doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, const char *end, const char **nextPtr);
-#ifdef XML_DTD
-static enum XML_Error
-doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, const char *end, const char **nextPtr);
-#endif /* XML_DTD */
-static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *, const char *s,
-                                TAG_NAME *tagNamePtr, BINDING **bindingsPtr);
-static
-int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr);
-
-static int
-defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *,
-                int isCdata, int isId, const XML_Char *dfltValue,
-                XML_Parser parser);
-
-static enum XML_Error
-storeAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, const char *, const char *,
-                    STRING_POOL *);
-static enum XML_Error
-appendAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, const char *, const char *,
-                    STRING_POOL *);
-static ATTRIBUTE_ID *
-getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *);
-static enum XML_Error
-storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static int
-reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static int
-reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static void
-reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-
-static const XML_Char *getContext(XML_Parser parser);
-static int setContext(XML_Parser parser, const XML_Char *context);
-static void normalizePublicId(XML_Char *s);
-static int dtdInit(DTD *, XML_Parser parser);
-
-static void dtdDestroy(DTD *, XML_Parser parser);
-
-static int dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser);
-
-static int copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *,
-                           XML_Parser parser);
-
-#ifdef XML_DTD
-static void dtdSwap(DTD *, DTD *);
-#endif /* XML_DTD */
-
-static NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize);
-
-static void hashTableInit(HASH_TABLE *, XML_Memory_Handling_Suite *ms);
-
-static void hashTableDestroy(HASH_TABLE *);
-static void hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
-static NAMED *hashTableIterNext(HASH_TABLE_ITER *);
-static void poolInit(STRING_POOL *, XML_Memory_Handling_Suite *ms);
-static void poolClear(STRING_POOL *);
-static void poolDestroy(STRING_POOL *);
-static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
-                            const char *ptr, const char *end);
-static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
-                                  const char *ptr, const char *end);
-
-static int poolGrow(STRING_POOL *pool);
-
-static int nextScaffoldPart(XML_Parser parser);
-static XML_Content *build_model(XML_Parser parser);
-
-static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s);
-static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n);
-static const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s);
-static ELEMENT_TYPE * getElementType(XML_Parser Paraser,
-                                     const ENCODING *enc,
-                                     const char *ptr,
-                                     const char *end);
-
-#define poolStart(pool) ((pool)->start)
-#define poolEnd(pool) ((pool)->ptr)
-#define poolLength(pool) ((pool)->ptr - (pool)->start)
-#define poolChop(pool) ((void)--(pool->ptr))
-#define poolLastChar(pool) (((pool)->ptr)[-1])
-#define poolDiscard(pool) ((pool)->ptr = (pool)->start)
-#define poolFinish(pool) ((pool)->start = (pool)->ptr)
-#define poolAppendChar(pool, c) \
-  (((pool)->ptr == (pool)->end && !poolGrow(pool)) \
-   ? 0 \
-   : ((*((pool)->ptr)++ = c), 1))
-
-typedef struct {
-  /* The first member must be userData so that the XML_GetUserData macro works. */
-  void *m_userData;
-  void *m_handlerArg;
-  char *m_buffer;
-  XML_Memory_Handling_Suite m_mem;
-  /* first character to be parsed */
-  const char *m_bufferPtr;
-  /* past last character to be parsed */
-  char *m_bufferEnd;
-  /* allocated end of buffer */
-  const char *m_bufferLim;
-  long m_parseEndByteIndex;
-  const char *m_parseEndPtr;
-  XML_Char *m_dataBuf;
-  XML_Char *m_dataBufEnd;
-  XML_StartElementHandler m_startElementHandler;
-  XML_EndElementHandler m_endElementHandler;
-  XML_CharacterDataHandler m_characterDataHandler;
-  XML_ProcessingInstructionHandler m_processingInstructionHandler;
-  XML_CommentHandler m_commentHandler;
-  XML_StartCdataSectionHandler m_startCdataSectionHandler;
-  XML_EndCdataSectionHandler m_endCdataSectionHandler;
-  XML_DefaultHandler m_defaultHandler;
-  XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler;
-  XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler;
-  XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler;
-  XML_NotationDeclHandler m_notationDeclHandler;
-  XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler;
-  XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler;
-  XML_NotStandaloneHandler m_notStandaloneHandler;
-  XML_ExternalEntityRefHandler m_externalEntityRefHandler;
-  void *m_externalEntityRefHandlerArg;
-  XML_UnknownEncodingHandler m_unknownEncodingHandler;
-  XML_ElementDeclHandler m_elementDeclHandler;
-  XML_AttlistDeclHandler m_attlistDeclHandler;
-  XML_EntityDeclHandler m_entityDeclHandler;
-  XML_XmlDeclHandler m_xmlDeclHandler;
-  const ENCODING *m_encoding;
-  INIT_ENCODING m_initEncoding;
-  const ENCODING *m_internalEncoding;
-  const XML_Char *m_protocolEncodingName;
-  int m_ns;
-  int m_ns_triplets;
-  void *m_unknownEncodingMem;
-  void *m_unknownEncodingData;
-  void *m_unknownEncodingHandlerData;
-  void (*m_unknownEncodingRelease)(void *);
-  PROLOG_STATE m_prologState;
-  Processor *m_processor;
-  enum XML_Error m_errorCode;
-  const char *m_eventPtr;
-  const char *m_eventEndPtr;
-  const char *m_positionPtr;
-  OPEN_INTERNAL_ENTITY *m_openInternalEntities;
-  int m_defaultExpandInternalEntities;
-  int m_tagLevel;
-  ENTITY *m_declEntity;
-  const XML_Char *m_doctypeName;
-  const XML_Char *m_doctypeSysid;
-  const XML_Char *m_doctypePubid;
-  const XML_Char *m_declAttributeType;
-  const XML_Char *m_declNotationName;
-  const XML_Char *m_declNotationPublicId;
-  ELEMENT_TYPE *m_declElementType;
-  ATTRIBUTE_ID *m_declAttributeId;
-  char m_declAttributeIsCdata;
-  char m_declAttributeIsId;
-  DTD m_dtd;
-  const XML_Char *m_curBase;
-  TAG *m_tagStack;
-  TAG *m_freeTagList;
-  BINDING *m_inheritedBindings;
-  BINDING *m_freeBindingList;
-  int m_attsSize;
-  int m_nSpecifiedAtts;
-  int m_idAttIndex;
-  ATTRIBUTE *m_atts;
-  POSITION m_position;
-  STRING_POOL m_tempPool;
-  STRING_POOL m_temp2Pool;
-  char *m_groupConnector;
-  unsigned m_groupSize;
-  int m_hadExternalDoctype;
-  XML_Char m_namespaceSeparator;
-#ifdef XML_DTD
-  enum XML_ParamEntityParsing m_paramEntityParsing;
-  XML_Parser m_parentParser;
-#endif
-} Parser;
-
-#define MALLOC(s) (((Parser *)parser)->m_mem.malloc_fcn((s)))
-#define REALLOC(p,s) (((Parser *)parser)->m_mem.realloc_fcn((p),(s)))
-#define FREE(p) (((Parser *)parser)->m_mem.free_fcn((p)))
-
-#define userData (((Parser *)parser)->m_userData)
-#define handlerArg (((Parser *)parser)->m_handlerArg)
-#define startElementHandler (((Parser *)parser)->m_startElementHandler)
-#define endElementHandler (((Parser *)parser)->m_endElementHandler)
-#define characterDataHandler (((Parser *)parser)->m_characterDataHandler)
-#define processingInstructionHandler (((Parser *)parser)->m_processingInstructionHandler)
-#define commentHandler (((Parser *)parser)->m_commentHandler)
-#define startCdataSectionHandler (((Parser *)parser)->m_startCdataSectionHandler)
-#define endCdataSectionHandler (((Parser *)parser)->m_endCdataSectionHandler)
-#define defaultHandler (((Parser *)parser)->m_defaultHandler)
-#define startDoctypeDeclHandler (((Parser *)parser)->m_startDoctypeDeclHandler)
-#define endDoctypeDeclHandler (((Parser *)parser)->m_endDoctypeDeclHandler)
-#define unparsedEntityDeclHandler (((Parser *)parser)->m_unparsedEntityDeclHandler)
-#define notationDeclHandler (((Parser *)parser)->m_notationDeclHandler)
-#define startNamespaceDeclHandler (((Parser *)parser)->m_startNamespaceDeclHandler)
-#define endNamespaceDeclHandler (((Parser *)parser)->m_endNamespaceDeclHandler)
-#define notStandaloneHandler (((Parser *)parser)->m_notStandaloneHandler)
-#define externalEntityRefHandler (((Parser *)parser)->m_externalEntityRefHandler)
-#define externalEntityRefHandlerArg (((Parser *)parser)->m_externalEntityRefHandlerArg)
-#define internalEntityRefHandler (((Parser *)parser)->m_internalEntityRefHandler)
-#define unknownEncodingHandler (((Parser *)parser)->m_unknownEncodingHandler)
-#define elementDeclHandler (((Parser *)parser)->m_elementDeclHandler)
-#define attlistDeclHandler (((Parser *)parser)->m_attlistDeclHandler)
-#define entityDeclHandler (((Parser *)parser)->m_entityDeclHandler)
-#define xmlDeclHandler (((Parser *)parser)->m_xmlDeclHandler)
-#define encoding (((Parser *)parser)->m_encoding)
-#define initEncoding (((Parser *)parser)->m_initEncoding)
-#define internalEncoding (((Parser *)parser)->m_internalEncoding)
-#define unknownEncodingMem (((Parser *)parser)->m_unknownEncodingMem)
-#define unknownEncodingData (((Parser *)parser)->m_unknownEncodingData)
-#define unknownEncodingHandlerData \
-  (((Parser *)parser)->m_unknownEncodingHandlerData)
-#define unknownEncodingRelease (((Parser *)parser)->m_unknownEncodingRelease)
-#define protocolEncodingName (((Parser *)parser)->m_protocolEncodingName)
-#define ns (((Parser *)parser)->m_ns)
-#define ns_triplets (((Parser *)parser)->m_ns_triplets)
-#define prologState (((Parser *)parser)->m_prologState)
-#define processor (((Parser *)parser)->m_processor)
-#define errorCode (((Parser *)parser)->m_errorCode)
-#define eventPtr (((Parser *)parser)->m_eventPtr)
-#define eventEndPtr (((Parser *)parser)->m_eventEndPtr)
-#define positionPtr (((Parser *)parser)->m_positionPtr)
-#define position (((Parser *)parser)->m_position)
-#define openInternalEntities (((Parser *)parser)->m_openInternalEntities)
-#define defaultExpandInternalEntities (((Parser *)parser)->m_defaultExpandInternalEntities)
-#define tagLevel (((Parser *)parser)->m_tagLevel)
-#define buffer (((Parser *)parser)->m_buffer)
-#define bufferPtr (((Parser *)parser)->m_bufferPtr)
-#define bufferEnd (((Parser *)parser)->m_bufferEnd)
-#define parseEndByteIndex (((Parser *)parser)->m_parseEndByteIndex)
-#define parseEndPtr (((Parser *)parser)->m_parseEndPtr)
-#define bufferLim (((Parser *)parser)->m_bufferLim)
-#define dataBuf (((Parser *)parser)->m_dataBuf)
-#define dataBufEnd (((Parser *)parser)->m_dataBufEnd)
-#define dtd (((Parser *)parser)->m_dtd)
-#define curBase (((Parser *)parser)->m_curBase)
-#define declEntity (((Parser *)parser)->m_declEntity)
-#define doctypeName (((Parser *)parser)->m_doctypeName)
-#define doctypeSysid (((Parser *)parser)->m_doctypeSysid)
-#define doctypePubid (((Parser *)parser)->m_doctypePubid)
-#define declAttributeType (((Parser *)parser)->m_declAttributeType)
-#define declNotationName (((Parser *)parser)->m_declNotationName)
-#define declNotationPublicId (((Parser *)parser)->m_declNotationPublicId)
-#define declElementType (((Parser *)parser)->m_declElementType)
-#define declAttributeId (((Parser *)parser)->m_declAttributeId)
-#define declAttributeIsCdata (((Parser *)parser)->m_declAttributeIsCdata)
-#define declAttributeIsId (((Parser *)parser)->m_declAttributeIsId)
-#define freeTagList (((Parser *)parser)->m_freeTagList)
-#define freeBindingList (((Parser *)parser)->m_freeBindingList)
-#define inheritedBindings (((Parser *)parser)->m_inheritedBindings)
-#define tagStack (((Parser *)parser)->m_tagStack)
-#define atts (((Parser *)parser)->m_atts)
-#define attsSize (((Parser *)parser)->m_attsSize)
-#define nSpecifiedAtts (((Parser *)parser)->m_nSpecifiedAtts)
-#define idAttIndex (((Parser *)parser)->m_idAttIndex)
-#define tempPool (((Parser *)parser)->m_tempPool)
-#define temp2Pool (((Parser *)parser)->m_temp2Pool)
-#define groupConnector (((Parser *)parser)->m_groupConnector)
-#define groupSize (((Parser *)parser)->m_groupSize)
-#define hadExternalDoctype (((Parser *)parser)->m_hadExternalDoctype)
-#define namespaceSeparator (((Parser *)parser)->m_namespaceSeparator)
-#ifdef XML_DTD
-#define parentParser (((Parser *)parser)->m_parentParser)
-#define paramEntityParsing (((Parser *)parser)->m_paramEntityParsing)
-#endif /* XML_DTD */
-
-#ifdef COMPILED_FROM_DSP
-BOOL WINAPI DllMain(HINSTANCE h, DWORD r, LPVOID p) {
-  return TRUE;
-}
-#endif /* def COMPILED_FROM_DSP */
-
-#ifdef _MSC_VER
-#ifdef _DEBUG
-Parser *asParser(XML_Parser parser)
-{
-  return parser;
-}
-#endif
-#endif
-
-XML_Parser XML_ParserCreate(const XML_Char *encodingName)
-{
-  return XML_ParserCreate_MM(encodingName, NULL, NULL);
-}
-
-XML_Parser XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
-{
-  XML_Char tmp[2];
-  *tmp = nsSep;
-  return XML_ParserCreate_MM(encodingName, NULL, tmp);
-}
-
-XML_Parser
-XML_ParserCreate_MM(const XML_Char *encodingName,
-                    const XML_Memory_Handling_Suite *memsuite,
-                    const XML_Char *nameSep) {
-  
-  XML_Parser parser;
-  static
-  const XML_Char implicitContext[] = {
-    XML_T('x'), XML_T('m'), XML_T('l'), XML_T('='),
-    XML_T('h'), XML_T('t'), XML_T('t'), XML_T('p'), XML_T(':'),
-    XML_T('/'), XML_T('/'), XML_T('w'), XML_T('w'), XML_T('w'),
-    XML_T('.'), XML_T('w'), XML_T('3'),
-    XML_T('.'), XML_T('o'), XML_T('r'), XML_T('g'),
-    XML_T('/'), XML_T('X'), XML_T('M'), XML_T('L'),
-    XML_T('/'), XML_T('1'), XML_T('9'), XML_T('9'), XML_T('8'),
-    XML_T('/'), XML_T('n'), XML_T('a'), XML_T('m'), XML_T('e'),
-    XML_T('s'), XML_T('p'), XML_T('a'), XML_T('c'), XML_T('e'),
-    XML_T('\0')
-  };
-
-
-  if (memsuite) {
-    XML_Memory_Handling_Suite *mtemp;
-    parser = memsuite->malloc_fcn(sizeof(Parser));
-    mtemp = &(((Parser *) parser)->m_mem);
-    mtemp->malloc_fcn = memsuite->malloc_fcn;
-    mtemp->realloc_fcn = memsuite->realloc_fcn;
-    mtemp->free_fcn = memsuite->free_fcn;
-  }
-  else {
-    XML_Memory_Handling_Suite *mtemp;
-    parser = malloc(sizeof(Parser));
-    mtemp = &(((Parser *) parser)->m_mem);
-    mtemp->malloc_fcn = malloc;
-    mtemp->realloc_fcn = realloc;
-    mtemp->free_fcn = free;
-  }
-
-  if (!parser)
-    return parser;
-  processor = prologInitProcessor;
-  XmlPrologStateInit(&prologState);
-  userData = 0;
-  handlerArg = 0;
-  startElementHandler = 0;
-  endElementHandler = 0;
-  characterDataHandler = 0;
-  processingInstructionHandler = 0;
-  commentHandler = 0;
-  startCdataSectionHandler = 0;
-  endCdataSectionHandler = 0;
-  defaultHandler = 0;
-  startDoctypeDeclHandler = 0;
-  endDoctypeDeclHandler = 0;
-  unparsedEntityDeclHandler = 0;
-  notationDeclHandler = 0;
-  startNamespaceDeclHandler = 0;
-  endNamespaceDeclHandler = 0;
-  notStandaloneHandler = 0;
-  externalEntityRefHandler = 0;
-  externalEntityRefHandlerArg = parser;
-  unknownEncodingHandler = 0;
-  elementDeclHandler = 0;
-  attlistDeclHandler = 0;
-  entityDeclHandler = 0;
-  xmlDeclHandler = 0;
-  buffer = 0;
-  bufferPtr = 0;
-  bufferEnd = 0;
-  parseEndByteIndex = 0;
-  parseEndPtr = 0;
-  bufferLim = 0;
-  declElementType = 0;
-  declAttributeId = 0;
-  declEntity = 0;
-  doctypeName = 0;
-  doctypeSysid = 0;
-  doctypePubid = 0;
-  declAttributeType = 0;
-  declNotationName = 0;
-  declNotationPublicId = 0;
-  memset(&position, 0, sizeof(POSITION));
-  errorCode = XML_ERROR_NONE;
-  eventPtr = 0;
-  eventEndPtr = 0;
-  positionPtr = 0;
-  openInternalEntities = 0;
-  tagLevel = 0;
-  tagStack = 0;
-  freeTagList = 0;
-  freeBindingList = 0;
-  inheritedBindings = 0;
-  attsSize = INIT_ATTS_SIZE;
-  atts = MALLOC(attsSize * sizeof(ATTRIBUTE));
-  nSpecifiedAtts = 0;
-  dataBuf = MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char));
-  groupSize = 0;
-  groupConnector = 0;
-  hadExternalDoctype = 0;
-  unknownEncodingMem = 0;
-  unknownEncodingRelease = 0;
-  unknownEncodingData = 0;
-  unknownEncodingHandlerData = 0;
-  namespaceSeparator = '!';
-#ifdef XML_DTD
-  parentParser = 0;
-  paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
-#endif
-  ns = 0;
-  ns_triplets = 0;
-  poolInit(&tempPool, &(((Parser *) parser)->m_mem));
-  poolInit(&temp2Pool, &(((Parser *) parser)->m_mem));
-  protocolEncodingName = encodingName ? poolCopyString(&tempPool, encodingName) : 0;
-  curBase = 0;
-  if (!dtdInit(&dtd, parser) || !atts || !dataBuf
-      || (encodingName && !protocolEncodingName)) {
-    XML_ParserFree(parser);
-    return 0;
-  }
-  dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
-
-  if (nameSep) {
-    XmlInitEncodingNS(&initEncoding, &encoding, 0);
-    ns = 1;
-    internalEncoding = XmlGetInternalEncodingNS();
-    namespaceSeparator = *nameSep;
-
-    if (! setContext(parser, implicitContext)) {
-      XML_ParserFree(parser);
-      return 0;
-    }
-  }
-  else {
-    XmlInitEncoding(&initEncoding, &encoding, 0);
-    internalEncoding = XmlGetInternalEncoding();
-  }
-
-  return parser;
-}  /* End XML_ParserCreate_MM */
-
-int XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName)
-{
-  if (!encodingName)
-    protocolEncodingName = 0;
-  else {
-    protocolEncodingName = poolCopyString(&tempPool, encodingName);
-    if (!protocolEncodingName)
-      return 0;
-  }
-  return 1;
-}
-
-XML_Parser XML_ExternalEntityParserCreate(XML_Parser oldParser,
-                                          const XML_Char *context,
-                                          const XML_Char *encodingName)
-{
-  XML_Parser parser = oldParser;
-  DTD *oldDtd = &dtd;
-  XML_StartElementHandler oldStartElementHandler = startElementHandler;
-  XML_EndElementHandler oldEndElementHandler = endElementHandler;
-  XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler;
-  XML_ProcessingInstructionHandler oldProcessingInstructionHandler = processingInstructionHandler;
-  XML_CommentHandler oldCommentHandler = commentHandler;
-  XML_StartCdataSectionHandler oldStartCdataSectionHandler = startCdataSectionHandler;
-  XML_EndCdataSectionHandler oldEndCdataSectionHandler = endCdataSectionHandler;
-  XML_DefaultHandler oldDefaultHandler = defaultHandler;
-  XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler = unparsedEntityDeclHandler;
-  XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler;
-  XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler = startNamespaceDeclHandler;
-  XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler = endNamespaceDeclHandler;
-  XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler;
-  XML_ExternalEntityRefHandler oldExternalEntityRefHandler = externalEntityRefHandler;
-  XML_UnknownEncodingHandler oldUnknownEncodingHandler = unknownEncodingHandler;
-  XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler;
-  XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler;
-  XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler;
-  XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler;
-  ELEMENT_TYPE * oldDeclElementType = declElementType;
-
-  void *oldUserData = userData;
-  void *oldHandlerArg = handlerArg;
-  int oldDefaultExpandInternalEntities = defaultExpandInternalEntities;
-  void *oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg;
-#ifdef XML_DTD
-  enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing;
-#endif
-  int oldns_triplets = ns_triplets;
-
-  if (ns) {
-    XML_Char tmp[2];
-
-    *tmp = namespaceSeparator;
-    parser = XML_ParserCreate_MM(encodingName, &((Parser *)parser)->m_mem,
-                                 tmp);
-  }
-  else {
-    parser = XML_ParserCreate_MM(encodingName, &((Parser *)parser)->m_mem,
-                                 NULL);
-  }
-
-  if (!parser)
-    return 0;
-
-  startElementHandler = oldStartElementHandler;
-  endElementHandler = oldEndElementHandler;
-  characterDataHandler = oldCharacterDataHandler;
-  processingInstructionHandler = oldProcessingInstructionHandler;
-  commentHandler = oldCommentHandler;
-  startCdataSectionHandler = oldStartCdataSectionHandler;
-  endCdataSectionHandler = oldEndCdataSectionHandler;
-  defaultHandler = oldDefaultHandler;
-  unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler;
-  notationDeclHandler = oldNotationDeclHandler;
-  startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
-  endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
-  notStandaloneHandler = oldNotStandaloneHandler;
-  externalEntityRefHandler = oldExternalEntityRefHandler;
-  unknownEncodingHandler = oldUnknownEncodingHandler;
-  elementDeclHandler = oldElementDeclHandler;
-  attlistDeclHandler = oldAttlistDeclHandler;
-  entityDeclHandler = oldEntityDeclHandler;
-  xmlDeclHandler = oldXmlDeclHandler;
-  declElementType = oldDeclElementType;
-  userData = oldUserData;
-  if (oldUserData == oldHandlerArg)
-    handlerArg = userData;
-  else
-    handlerArg = parser;
-  if (oldExternalEntityRefHandlerArg != oldParser)
-    externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
-  defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
-  ns_triplets = oldns_triplets;
-#ifdef XML_DTD
-  paramEntityParsing = oldParamEntityParsing;
-  if (context) {
-#endif /* XML_DTD */
-    if (!dtdCopy(&dtd, oldDtd, parser) || !setContext(parser, context)) {
-      XML_ParserFree(parser);
-      return 0;
-    }
-    processor = externalEntityInitProcessor;
-#ifdef XML_DTD
-  }
-  else {
-    dtdSwap(&dtd, oldDtd);
-    parentParser = oldParser;
-    XmlPrologStateInitExternalEntity(&prologState);
-    dtd.complete = 1;
-    hadExternalDoctype = 1;
-  }
-#endif /* XML_DTD */
-  return parser;
-}
-
-static
-void destroyBindings(BINDING *bindings, XML_Parser parser)
-{
-  for (;;) {
-    BINDING *b = bindings;
-    if (!b)
-      break;
-    bindings = b->nextTagBinding;
-    FREE(b->uri);
-    FREE(b);
-  }
-}
-
-void XML_ParserFree(XML_Parser parser)
-{
-  for (;;) {
-    TAG *p;
-    if (tagStack == 0) {
-      if (freeTagList == 0)
-        break;
-      tagStack = freeTagList;
-      freeTagList = 0;
-    }
-    p = tagStack;
-    tagStack = tagStack->parent;
-    FREE(p->buf);
-    destroyBindings(p->bindings, parser);
-    FREE(p);
-  }
-  destroyBindings(freeBindingList, parser);
-  destroyBindings(inheritedBindings, parser);
-  poolDestroy(&tempPool);
-  poolDestroy(&temp2Pool);
-#ifdef XML_DTD
-  if (parentParser) {
-    if (hadExternalDoctype)
-      dtd.complete = 0;
-    dtdSwap(&dtd, &((Parser *)parentParser)->m_dtd);
-  }
-#endif /* XML_DTD */
-  dtdDestroy(&dtd, parser);
-  FREE((void *)atts);
-  if (groupConnector)
-    FREE(groupConnector);
-  if (buffer)
-    FREE(buffer);
-  FREE(dataBuf);
-  if (unknownEncodingMem)
-    FREE(unknownEncodingMem);
-  if (unknownEncodingRelease)
-    unknownEncodingRelease(unknownEncodingData);
-  FREE(parser);
-}
-
-void XML_UseParserAsHandlerArg(XML_Parser parser)
-{
-  handlerArg = parser;
-}
-
-void
-XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) {
-  ns_triplets = do_nst;
-}
-
-void XML_SetUserData(XML_Parser parser, void *p)
-{
-  if (handlerArg == userData)
-    handlerArg = userData = p;
-  else
-    userData = p;
-}
-
-int XML_SetBase(XML_Parser parser, const XML_Char *p)
-{
-  if (p) {
-    p = poolCopyString(&dtd.pool, p);
-    if (!p)
-      return 0;
-    curBase = p;
-  }
-  else
-    curBase = 0;
-  return 1;
-}
-
-const XML_Char *XML_GetBase(XML_Parser parser)
-{
-  return curBase;
-}
-
-int XML_GetSpecifiedAttributeCount(XML_Parser parser)
-{
-  return nSpecifiedAtts;
-}
-
-int XML_GetIdAttributeIndex(XML_Parser parser)
-{
-  return idAttIndex;
-}
-
-void XML_SetElementHandler(XML_Parser parser,
-                           XML_StartElementHandler start,
-                           XML_EndElementHandler end)
-{
-  startElementHandler = start;
-  endElementHandler = end;
-}
-
-void XML_SetStartElementHandler(XML_Parser parser,
-                                XML_StartElementHandler start) {
-  startElementHandler = start;
-}
-
-void XML_SetEndElementHandler(XML_Parser parser,
-                              XML_EndElementHandler end) {
-  endElementHandler = end;
-}
-
-void XML_SetCharacterDataHandler(XML_Parser parser,
-                                 XML_CharacterDataHandler handler)
-{
-  characterDataHandler = handler;
-}
-
-void XML_SetProcessingInstructionHandler(XML_Parser parser,
-                                         XML_ProcessingInstructionHandler handler)
-{
-  processingInstructionHandler = handler;
-}
-
-void XML_SetCommentHandler(XML_Parser parser,
-                           XML_CommentHandler handler)
-{
-  commentHandler = handler;
-}
-
-void XML_SetCdataSectionHandler(XML_Parser parser,
-                                XML_StartCdataSectionHandler start,
-                                XML_EndCdataSectionHandler end)
-{
-  startCdataSectionHandler = start;
-  endCdataSectionHandler = end;
-}
-
-void XML_SetStartCdataSectionHandler(XML_Parser parser,
-                                     XML_StartCdataSectionHandler start) {
-  startCdataSectionHandler = start;
-}
-
-void XML_SetEndCdataSectionHandler(XML_Parser parser,
-                                   XML_EndCdataSectionHandler end) {
-  endCdataSectionHandler = end;
-}
-
-void XML_SetDefaultHandler(XML_Parser parser,
-                           XML_DefaultHandler handler)
-{
-  defaultHandler = handler;
-  defaultExpandInternalEntities = 0;
-}
-
-void XML_SetDefaultHandlerExpand(XML_Parser parser,
-                                 XML_DefaultHandler handler)
-{
-  defaultHandler = handler;
-  defaultExpandInternalEntities = 1;
-}
-
-void XML_SetDoctypeDeclHandler(XML_Parser parser,
-                               XML_StartDoctypeDeclHandler start,
-                               XML_EndDoctypeDeclHandler end)
-{
-  startDoctypeDeclHandler = start;
-  endDoctypeDeclHandler = end;
-}
-
-void XML_SetStartDoctypeDeclHandler(XML_Parser parser,
-                                    XML_StartDoctypeDeclHandler start) {
-  startDoctypeDeclHandler = start;
-}
-
-void XML_SetEndDoctypeDeclHandler(XML_Parser parser,
-                                  XML_EndDoctypeDeclHandler end) {
-  endDoctypeDeclHandler = end;
-}
-
-void XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
-                                      XML_UnparsedEntityDeclHandler handler)
-{
-  unparsedEntityDeclHandler = handler;
-}
-
-void XML_SetNotationDeclHandler(XML_Parser parser,
-                                XML_NotationDeclHandler handler)
-{
-  notationDeclHandler = handler;
-}
-
-void XML_SetNamespaceDeclHandler(XML_Parser parser,
-                                 XML_StartNamespaceDeclHandler start,
-                                 XML_EndNamespaceDeclHandler end)
-{
-  startNamespaceDeclHandler = start;
-  endNamespaceDeclHandler = end;
-}
-
-void XML_SetStartNamespaceDeclHandler(XML_Parser parser,
-                                      XML_StartNamespaceDeclHandler start) {
-  startNamespaceDeclHandler = start;
-}
-
-void XML_SetEndNamespaceDeclHandler(XML_Parser parser,
-                                    XML_EndNamespaceDeclHandler end) {
-  endNamespaceDeclHandler = end;
-}
-
-
-void XML_SetNotStandaloneHandler(XML_Parser parser,
-                                 XML_NotStandaloneHandler handler)
-{
-  notStandaloneHandler = handler;
-}
-
-void XML_SetExternalEntityRefHandler(XML_Parser parser,
-                                     XML_ExternalEntityRefHandler handler)
-{
-  externalEntityRefHandler = handler;
-}
-
-void XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
-{
-  if (arg)
-    externalEntityRefHandlerArg = arg;
-  else
-    externalEntityRefHandlerArg = parser;
-}
-
-void XML_SetUnknownEncodingHandler(XML_Parser parser,
-                                   XML_UnknownEncodingHandler handler,
-                                   void *data)
-{
-  unknownEncodingHandler = handler;
-  unknownEncodingHandlerData = data;
-}
-
-void XML_SetElementDeclHandler(XML_Parser parser,
-                               XML_ElementDeclHandler eldecl)
-{
-  elementDeclHandler = eldecl;
-}
-
-void XML_SetAttlistDeclHandler(XML_Parser parser,
-                               XML_AttlistDeclHandler attdecl)
-{
-  attlistDeclHandler = attdecl;
-}
-
-void XML_SetEntityDeclHandler(XML_Parser parser,
-                              XML_EntityDeclHandler handler)
-{
-  entityDeclHandler = handler;
-}
-
-void XML_SetXmlDeclHandler(XML_Parser parser,
-                           XML_XmlDeclHandler handler) {
-  xmlDeclHandler = handler;
-}
-
-int XML_SetParamEntityParsing(XML_Parser parser,
-                              enum XML_ParamEntityParsing parsing)
-{
-#ifdef XML_DTD
-  paramEntityParsing = parsing;
-  return 1;
-#else
-  return parsing == XML_PARAM_ENTITY_PARSING_NEVER;
-#endif
-}
-
-int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
-{
-  if (len == 0) {
-    if (!isFinal)
-      return 1;
-    positionPtr = bufferPtr;
-    errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0);
-    if (errorCode == XML_ERROR_NONE)
-      return 1;
-    eventEndPtr = eventPtr;
-    processor = errorProcessor;
-    return 0;
-  }
-#ifndef XML_CONTEXT_BYTES
-  else if (bufferPtr == bufferEnd) {
-    const char *end;
-    int nLeftOver;
-    parseEndByteIndex += len;
-    positionPtr = s;
-    if (isFinal) {
-      errorCode = processor(parser, s, parseEndPtr = s + len, 0);
-      if (errorCode == XML_ERROR_NONE)
-        return 1;
-      eventEndPtr = eventPtr;
-      processor = errorProcessor;
-      return 0;
-    }
-    errorCode = processor(parser, s, parseEndPtr = s + len, &end);
-    if (errorCode != XML_ERROR_NONE) {
-      eventEndPtr = eventPtr;
-      processor = errorProcessor;
-      return 0;
-    }
-    XmlUpdatePosition(encoding, positionPtr, end, &position);
-    nLeftOver = s + len - end;
-    if (nLeftOver) {
-      if (buffer == 0 || nLeftOver > bufferLim - buffer) {
-        /* FIXME avoid integer overflow */
-        buffer = buffer == 0 ? MALLOC(len * 2) : REALLOC(buffer, len * 2);
-        /* FIXME storage leak if realloc fails */
-        if (!buffer) {
-          errorCode = XML_ERROR_NO_MEMORY;
-          eventPtr = eventEndPtr = 0;
-          processor = errorProcessor;
-          return 0;
-        }
-        bufferLim = buffer + len * 2;
-      }
-      memcpy(buffer, end, nLeftOver);
-      bufferPtr = buffer;
-      bufferEnd = buffer + nLeftOver;
-    }
-    return 1;
-  }
-#endif  /* not defined XML_CONTEXT_BYTES */
-  else {
-    memcpy(XML_GetBuffer(parser, len), s, len);
-    return XML_ParseBuffer(parser, len, isFinal);
-  }
-}
-
-int XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
-{
-  const char *start = bufferPtr;
-  positionPtr = start;
-  bufferEnd += len;
-  parseEndByteIndex += len;
-  errorCode = processor(parser, start, parseEndPtr = bufferEnd,
-                        isFinal ? (const char **)0 : &bufferPtr);
-  if (errorCode == XML_ERROR_NONE) {
-    if (!isFinal)
-      XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
-    return 1;
-  }
-  else {
-    eventEndPtr = eventPtr;
-    processor = errorProcessor;
-    return 0;
-  }
-}
-
-void *XML_GetBuffer(XML_Parser parser, int len)
-{
-  if (len > bufferLim - bufferEnd) {
-    /* FIXME avoid integer overflow */
-    int neededSize = len + (bufferEnd - bufferPtr);
-#ifdef XML_CONTEXT_BYTES
-    int keep = bufferPtr - buffer;
-
-    if (keep > XML_CONTEXT_BYTES)
-      keep = XML_CONTEXT_BYTES;
-    neededSize += keep;
-#endif  /* defined XML_CONTEXT_BYTES */
-    if (neededSize  <= bufferLim - buffer) {
-#ifdef XML_CONTEXT_BYTES
-      if (keep < bufferPtr - buffer) {
-        int offset = (bufferPtr - buffer) - keep;
-        memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep);
-        bufferEnd -= offset;
-        bufferPtr -= offset;
-      }
-#else
-      memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
-      bufferEnd = buffer + (bufferEnd - bufferPtr);
-      bufferPtr = buffer;
-#endif  /* not defined XML_CONTEXT_BYTES */
-    }
-    else {
-      char *newBuf;
-      int bufferSize = bufferLim - bufferPtr;
-      if (bufferSize == 0)
-        bufferSize = INIT_BUFFER_SIZE;
-      do {
-        bufferSize *= 2;
-      } while (bufferSize < neededSize);
-      newBuf = MALLOC(bufferSize);
-      if (newBuf == 0) {
-        errorCode = XML_ERROR_NO_MEMORY;
-        return 0;
-      }
-      bufferLim = newBuf + bufferSize;
-#ifdef XML_CONTEXT_BYTES
-      if (bufferPtr) {
-        int xmKeep = bufferPtr - buffer;
-        if (xmKeep > XML_CONTEXT_BYTES)
-          xmKeep = XML_CONTEXT_BYTES;
-        memcpy(newBuf, &bufferPtr[-xmKeep], bufferEnd - bufferPtr + xmKeep);
-        FREE(buffer);
-        buffer = newBuf;
-        bufferEnd = buffer + (bufferEnd - bufferPtr) + xmKeep;
-        bufferPtr = buffer + xmKeep;
-      }
-      else {
-        bufferEnd = newBuf + (bufferEnd - bufferPtr);
-        bufferPtr = buffer = newBuf;
-      }
-#else
-      if (bufferPtr) {
-        memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
-        FREE(buffer);
-      }
-      bufferEnd = newBuf + (bufferEnd - bufferPtr);
-      bufferPtr = buffer = newBuf;
-#endif  /* not defined XML_CONTEXT_BYTES */
-    }
-  }
-  return bufferEnd;
-}
-
-enum XML_Error XML_GetErrorCode(XML_Parser parser)
-{
-  return errorCode;
-}
-
-long XML_GetCurrentByteIndex(XML_Parser parser)
-{
-  if (eventPtr)
-    return parseEndByteIndex - (parseEndPtr - eventPtr);
-  return -1;
-}
-
-int XML_GetCurrentByteCount(XML_Parser parser)
-{
-  if (eventEndPtr && eventPtr)
-    return eventEndPtr - eventPtr;
-  return 0;
-}
-
-const char * XML_GetInputContext(XML_Parser parser, int *offset, int *size)
-{
-#ifdef XML_CONTEXT_BYTES
-  if (eventPtr && buffer) {
-    *offset = eventPtr - buffer;
-    *size   = bufferEnd - buffer;
-    return buffer;
-  }
-#endif /* defined XML_CONTEXT_BYTES */
-  return (char *) 0;
-}
-
-int XML_GetCurrentLineNumber(XML_Parser parser)
-{
-  if (eventPtr) {
-    XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
-    positionPtr = eventPtr;
-  }
-  return position.lineNumber + 1;
-}
-
-int XML_GetCurrentColumnNumber(XML_Parser parser)
-{
-  if (eventPtr) {
-    XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
-    positionPtr = eventPtr;
-  }
-  return position.columnNumber;
-}
-
-void XML_DefaultCurrent(XML_Parser parser)
-{
-  if (defaultHandler) {
-    if (openInternalEntities)
-      reportDefault(parser,
-                    internalEncoding,
-                    openInternalEntities->internalEventPtr,
-                    openInternalEntities->internalEventEndPtr);
-    else
-      reportDefault(parser, encoding, eventPtr, eventEndPtr);
-  }
-}
-
-const XML_LChar *XML_ErrorString(int code)
-{
-  static const XML_LChar *message[] = {
-    0,
-    XML_T("out of memory"),
-    XML_T("syntax error"),
-    XML_T("no element found"),
-    XML_T("not well-formed (invalid token)"),
-    XML_T("unclosed token"),
-    XML_T("unclosed token"),
-    XML_T("mismatched tag"),
-    XML_T("duplicate attribute"),
-    XML_T("junk after document element"),
-    XML_T("illegal parameter entity reference"),
-    XML_T("undefined entity"),
-    XML_T("recursive entity reference"),
-    XML_T("asynchronous entity"),
-    XML_T("reference to invalid character number"),
-    XML_T("reference to binary entity"),
-    XML_T("reference to external entity in attribute"),
-    XML_T("xml processing instruction not at start of external entity"),
-    XML_T("unknown encoding"),
-    XML_T("encoding specified in XML declaration is incorrect"),
-    XML_T("unclosed CDATA section"),
-    XML_T("error in processing external entity reference"),
-    XML_T("document is not standalone"),
-    XML_T("unexpected parser state - please send a bug report")
-  };
-  if (code > 0 && code < (int)(sizeof(message)/sizeof(message[0])))
-    return message[code];
-  return 0;
-}
-
-const XML_LChar *
-XML_ExpatVersion(void) {
-  return VERSION;
-}
-
-XML_Expat_Version
-XML_ExpatVersionInfo(void) {
-  XML_Expat_Version version;
-
-  version.major = XML_MAJOR_VERSION;
-  version.minor = XML_MINOR_VERSION;
-  version.micro = XML_MICRO_VERSION;
-
-  return version;
-}
-
-static
-enum XML_Error contentProcessor(XML_Parser parser,
-                                const char *start,
-                                const char *end,
-                                const char **endPtr)
-{
-  return doContent(parser, 0, encoding, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityInitProcessor(XML_Parser parser,
-                                           const char *start,
-                                           const char *end,
-                                           const char **endPtr)
-{
-  enum XML_Error result = initializeEncoding(parser);
-  if (result != XML_ERROR_NONE)
-    return result;
-  processor = externalEntityInitProcessor2;
-  return externalEntityInitProcessor2(parser, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityInitProcessor2(XML_Parser parser,
-                                            const char *start,
-                                            const char *end,
-                                            const char **endPtr)
-{
-  const char *next;
-  int tok = XmlContentTok(encoding, start, end, &next);
-  switch (tok) {
-  case XML_TOK_BOM:
-    start = next;
-    break;
-  case XML_TOK_PARTIAL:
-    if (endPtr) {
-      *endPtr = start;
-      return XML_ERROR_NONE;
-    }
-    eventPtr = start;
-    return XML_ERROR_UNCLOSED_TOKEN;
-  case XML_TOK_PARTIAL_CHAR:
-    if (endPtr) {
-      *endPtr = start;
-      return XML_ERROR_NONE;
-    }
-    eventPtr = start;
-    return XML_ERROR_PARTIAL_CHAR;
-  }
-  processor = externalEntityInitProcessor3;
-  return externalEntityInitProcessor3(parser, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityInitProcessor3(XML_Parser parser,
-                                            const char *start,
-                                            const char *end,
-                                            const char **endPtr)
-{
-  const char *next;
-  int tok = XmlContentTok(encoding, start, end, &next);
-  switch (tok) {
-  case XML_TOK_XML_DECL:
-    {
-      enum XML_Error result = processXmlDecl(parser, 1, start, next);
-      if (result != XML_ERROR_NONE)
-        return result;
-      start = next;
-    }
-    break;
-  case XML_TOK_PARTIAL:
-    if (endPtr) {
-      *endPtr = start;
-      return XML_ERROR_NONE;
-    }
-    eventPtr = start;
-    return XML_ERROR_UNCLOSED_TOKEN;
-  case XML_TOK_PARTIAL_CHAR:
-    if (endPtr) {
-      *endPtr = start;
-      return XML_ERROR_NONE;
-    }
-    eventPtr = start;
-    return XML_ERROR_PARTIAL_CHAR;
-  }
-  processor = externalEntityContentProcessor;
-  tagLevel = 1;
-  return doContent(parser, 1, encoding, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityContentProcessor(XML_Parser parser,
-                                              const char *start,
-                                              const char *end,
-                                              const char **endPtr)
-{
-  return doContent(parser, 1, encoding, start, end, endPtr);
-}
-
-static enum XML_Error
-doContent(XML_Parser parser,
-          int startTagLevel,
-          const ENCODING *enc,
-          const char *s,
-          const char *end,
-          const char **nextPtr)
-{
-  const char **eventPP;
-  const char **eventEndPP;
-  if (enc == encoding) {
-    eventPP = &eventPtr;
-    eventEndPP = &eventEndPtr;
-  }
-  else {
-    eventPP = &(openInternalEntities->internalEventPtr);
-    eventEndPP = &(openInternalEntities->internalEventEndPtr);
-  }
-  *eventPP = s;
-  for (;;) {
-    const char *next = s; /* XmlContentTok doesn't always set the last arg */
-    int tok = XmlContentTok(enc, s, end, &next);
-    *eventEndPP = next;
-    switch (tok) {
-    case XML_TOK_TRAILING_CR:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      *eventEndPP = end;
-      if (characterDataHandler) {
-        XML_Char c = 0xA;
-        characterDataHandler(handlerArg, &c, 1);
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, end);
-      if (startTagLevel == 0)
-        return XML_ERROR_NO_ELEMENTS;
-      if (tagLevel != startTagLevel)
-        return XML_ERROR_ASYNC_ENTITY;
-      return XML_ERROR_NONE;
-    case XML_TOK_NONE:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      if (startTagLevel > 0) {
-        if (tagLevel != startTagLevel)
-          return XML_ERROR_ASYNC_ENTITY;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_NO_ELEMENTS;
-    case XML_TOK_INVALID:
-      *eventPP = next;
-      return XML_ERROR_INVALID_TOKEN;
-    case XML_TOK_PARTIAL:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_UNCLOSED_TOKEN;
-    case XML_TOK_PARTIAL_CHAR:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_PARTIAL_CHAR;
-    case XML_TOK_ENTITY_REF:
-      {
-        const XML_Char *name;
-        ENTITY *entity;
-        XML_Char ch = XmlPredefinedEntityName(enc,
-                                              s + enc->minBytesPerChar,
-                                              next - enc->minBytesPerChar);
-        if (ch) {
-          if (characterDataHandler)
-            characterDataHandler(handlerArg, &ch, 1);
-          else if (defaultHandler)
-            reportDefault(parser, enc, s, next);
-          break;
-        }
-        name = poolStoreString(&dtd.pool, enc,
-                                s + enc->minBytesPerChar,
-                                next - enc->minBytesPerChar);
-        if (!name)
-          return XML_ERROR_NO_MEMORY;
-        entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0);
-        poolDiscard(&dtd.pool);
-        if (!entity) {
-          if (dtd.complete || dtd.standalone)
-            return XML_ERROR_UNDEFINED_ENTITY;
-          if (defaultHandler)
-            reportDefault(parser, enc, s, next);
-          break;
-        }
-        if (entity->open)
-          return XML_ERROR_RECURSIVE_ENTITY_REF;
-        if (entity->notation)
-          return XML_ERROR_BINARY_ENTITY_REF;
-        if (entity) {
-          if (entity->textPtr) {
-            enum XML_Error result;
-            OPEN_INTERNAL_ENTITY openEntity;
-            if (defaultHandler && !defaultExpandInternalEntities) {
-              reportDefault(parser, enc, s, next);
-              break;
-            }
-            entity->open = 1;
-            openEntity.next = openInternalEntities;
-            openInternalEntities = &openEntity;
-            openEntity.entity = entity;
-            openEntity.internalEventPtr = 0;
-            openEntity.internalEventEndPtr = 0;
-            result = doContent(parser,
-                               tagLevel,
-                               internalEncoding,
-                               (char *)entity->textPtr,
-                               (char *)(entity->textPtr + entity->textLen),
-                               0);
-            entity->open = 0;
-            openInternalEntities = openEntity.next;
-            if (result)
-              return result;
-          }
-          else if (externalEntityRefHandler) {
-            const XML_Char *context;
-            entity->open = 1;
-            context = getContext(parser);
-            entity->open = 0;
-            if (!context)
-              return XML_ERROR_NO_MEMORY;
-            if (!externalEntityRefHandler(externalEntityRefHandlerArg,
-                                          context,
-                                          entity->base,
-                                          entity->systemId,
-                                          entity->publicId))
-              return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-            poolDiscard(&tempPool);
-          }
-          else if (defaultHandler)
-            reportDefault(parser, enc, s, next);
-        }
-        break;
-      }
-    case XML_TOK_START_TAG_WITH_ATTS:
-      if (!startElementHandler) {
-        enum XML_Error result = storeAtts(parser, enc, s, 0, 0);
-        if (result)
-          return result;
-      }
-      /* fall through */
-    case XML_TOK_START_TAG_NO_ATTS:
-      {
-        TAG *tag;
-        if (freeTagList) {
-          tag = freeTagList;
-          freeTagList = freeTagList->parent;
-        }
-        else {
-          tag = MALLOC(sizeof(TAG));
-          if (!tag)
-            return XML_ERROR_NO_MEMORY;
-          tag->buf = MALLOC(INIT_TAG_BUF_SIZE);
-          if (!tag->buf)
-            return XML_ERROR_NO_MEMORY;
-          tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE;
-        }
-        tag->bindings = 0;
-        tag->parent = tagStack;
-        tagStack = tag;
-        tag->name.localPart = 0;
-        tag->rawName = s + enc->minBytesPerChar;
-        tag->rawNameLength = XmlNameLength(enc, tag->rawName);
-        if (nextPtr) {
-          /* Need to guarantee that:
-             tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)) <= tag->bufEnd - sizeof(XML_Char) */
-          if (tag->rawNameLength + (int)(sizeof(XML_Char) - 1) + (int)sizeof(XML_Char) > tag->bufEnd - tag->buf) {
-            int bufSize = tag->rawNameLength * 4;
-            bufSize = ROUND_UP(bufSize, sizeof(XML_Char));
-            tag->buf = REALLOC(tag->buf, bufSize);
-            if (!tag->buf)
-              return XML_ERROR_NO_MEMORY;
-            tag->bufEnd = tag->buf + bufSize;
-          }
-          memcpy(tag->buf, tag->rawName, tag->rawNameLength);
-          tag->rawName = tag->buf;
-        }
-        ++tagLevel;
-        if (startElementHandler) {
-          enum XML_Error result;
-          XML_Char *toPtr;
-          for (;;) {
-            const char *rawNameEnd = tag->rawName + tag->rawNameLength;
-            const char *fromPtr = tag->rawName;
-            int bufSize;
-            if (nextPtr)
-              toPtr = (XML_Char *)(tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)));
-            else
-              toPtr = (XML_Char *)tag->buf;
-            tag->name.str = toPtr;
-            XmlConvert(enc,
-                       &fromPtr, rawNameEnd,
-                       (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1);
-            if (fromPtr == rawNameEnd)
-              break;
-            bufSize = (tag->bufEnd - tag->buf) << 1;
-            tag->buf = REALLOC(tag->buf, bufSize);
-            if (!tag->buf)
-              return XML_ERROR_NO_MEMORY;
-            tag->bufEnd = tag->buf + bufSize;
-            if (nextPtr)
-              tag->rawName = tag->buf;
-          }
-          *toPtr = XML_T('\0');
-          result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
-          if (result)
-            return result;
-          startElementHandler(handlerArg, tag->name.str, (const XML_Char **)atts);
-          poolClear(&tempPool);
-        }
-        else {
-          tag->name.str = 0;
-          if (defaultHandler)
-            reportDefault(parser, enc, s, next);
-        }
-        break;
-      }
-    case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
-      if (!startElementHandler) {
-        enum XML_Error result = storeAtts(parser, enc, s, 0, 0);
-        if (result)
-          return result;
-      }
-      /* fall through */
-    case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
-      if (startElementHandler || endElementHandler) {
-        const char *rawName = s + enc->minBytesPerChar;
-        enum XML_Error result;
-        BINDING *bindings = 0;
-        TAG_NAME name;
-        name.str = poolStoreString(&tempPool, enc, rawName,
-                                   rawName + XmlNameLength(enc, rawName));
-        if (!name.str)
-          return XML_ERROR_NO_MEMORY;
-        poolFinish(&tempPool);
-        result = storeAtts(parser, enc, s, &name, &bindings);
-        if (result)
-          return result;
-        poolFinish(&tempPool);
-        if (startElementHandler)
-          startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
-        if (endElementHandler) {
-          if (startElementHandler)
-            *eventPP = *eventEndPP;
-          endElementHandler(handlerArg, name.str);
-        }
-        poolClear(&tempPool);
-        while (bindings) {
-          BINDING *b = bindings;
-          if (endNamespaceDeclHandler)
-            endNamespaceDeclHandler(handlerArg, b->prefix->name);
-          bindings = bindings->nextTagBinding;
-          b->nextTagBinding = freeBindingList;
-          freeBindingList = b;
-          b->prefix->binding = b->prevPrefixBinding;
-        }
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      if (tagLevel == 0)
-        return epilogProcessor(parser, next, end, nextPtr);
-      break;
-    case XML_TOK_END_TAG:
-      if (tagLevel == startTagLevel)
-        return XML_ERROR_ASYNC_ENTITY;
-      else {
-        int len;
-        const char *rawName;
-        TAG *tag = tagStack;
-        tagStack = tag->parent;
-        tag->parent = freeTagList;
-        freeTagList = tag;
-        rawName = s + enc->minBytesPerChar*2;
-        len = XmlNameLength(enc, rawName);
-        if (len != tag->rawNameLength
-            || memcmp(tag->rawName, rawName, len) != 0) {
-          *eventPP = rawName;
-          return XML_ERROR_TAG_MISMATCH;
-        }
-        --tagLevel;
-        if (endElementHandler && tag->name.str) {
-          if (tag->name.localPart) {
-            XML_Char *to = (XML_Char *)tag->name.str + tag->name.uriLen;
-            const XML_Char *from = tag->name.localPart;
-            while ((*to++ = *from++) != 0)
-              ;
-          }
-          endElementHandler(handlerArg, tag->name.str);
-        }
-        else if (defaultHandler)
-          reportDefault(parser, enc, s, next);
-        while (tag->bindings) {
-          BINDING *b = tag->bindings;
-          if (endNamespaceDeclHandler)
-            endNamespaceDeclHandler(handlerArg, b->prefix->name);
-          tag->bindings = tag->bindings->nextTagBinding;
-          b->nextTagBinding = freeBindingList;
-          freeBindingList = b;
-          b->prefix->binding = b->prevPrefixBinding;
-        }
-        if (tagLevel == 0)
-          return epilogProcessor(parser, next, end, nextPtr);
-      }
-      break;
-    case XML_TOK_CHAR_REF:
-      {
-        int n = XmlCharRefNumber(enc, s);
-        if (n < 0)
-          return XML_ERROR_BAD_CHAR_REF;
-        if (characterDataHandler) {
-          XML_Char buf[XML_ENCODE_MAX];
-          characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf));
-        }
-        else if (defaultHandler)
-          reportDefault(parser, enc, s, next);
-      }
-      break;
-    case XML_TOK_XML_DECL:
-      return XML_ERROR_MISPLACED_XML_PI;
-    case XML_TOK_DATA_NEWLINE:
-      if (characterDataHandler) {
-        XML_Char c = 0xA;
-        characterDataHandler(handlerArg, &c, 1);
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      break;
-    case XML_TOK_CDATA_SECT_OPEN:
-      {
-        enum XML_Error result;
-        if (startCdataSectionHandler)
-          startCdataSectionHandler(handlerArg);
-#if 0
-        /* Suppose you doing a transformation on a document that involves
-           changing only the character data.  You set up a defaultHandler
-           and a characterDataHandler.  The defaultHandler simply copies
-           characters through.  The characterDataHandler does the transformation
-           and writes the characters out escaping them as necessary.  This case
-           will fail to work if we leave out the following two lines (because &
-           and < inside CDATA sections will be incorrectly escaped).
-
-           However, now we have a start/endCdataSectionHandler, so it seems
-           easier to let the user deal with this. */
-
-        else if (characterDataHandler)
-          characterDataHandler(handlerArg, dataBuf, 0);
-#endif
-        else if (defaultHandler)
-          reportDefault(parser, enc, s, next);
-        result = doCdataSection(parser, enc, &next, end, nextPtr);
-        if (!next) {
-          processor = cdataSectionProcessor;
-          return result;
-        }
-      }
-      break;
-    case XML_TOK_TRAILING_RSQB:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      if (characterDataHandler) {
-        if (MUST_CONVERT(enc, s)) {
-          ICHAR *dataPtr = (ICHAR *)dataBuf;
-          XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
-          characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
-        }
-        else
-          characterDataHandler(handlerArg,
-                               (XML_Char *)s,
-                               (XML_Char *)end - (XML_Char *)s);
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, end);
-      if (startTagLevel == 0) {
-        *eventPP = end;
-        return XML_ERROR_NO_ELEMENTS;
-      }
-      if (tagLevel != startTagLevel) {
-        *eventPP = end;
-        return XML_ERROR_ASYNC_ENTITY;
-      }
-      return XML_ERROR_NONE;
-    case XML_TOK_DATA_CHARS:
-      if (characterDataHandler) {
-        if (MUST_CONVERT(enc, s)) {
-          for (;;) {
-            ICHAR *dataPtr = (ICHAR *)dataBuf;
-            XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
-            *eventEndPP = s;
-            characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
-            if (s == next)
-              break;
-            *eventPP = s;
-          }
-        }
-        else
-          characterDataHandler(handlerArg,
-                               (XML_Char *)s,
-                               (XML_Char *)next - (XML_Char *)s);
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      break;
-    case XML_TOK_PI:
-      if (!reportProcessingInstruction(parser, enc, s, next))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_TOK_COMMENT:
-      if (!reportComment(parser, enc, s, next))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    default:
-      if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      break;
-    }
-    *eventPP = s = next;
-  }
-  /* not reached */
-}
-
-/* If tagNamePtr is non-null, build a real list of attributes,
-otherwise just check the attributes for well-formedness. */
-
-static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc,
-                                const char *attStr, TAG_NAME *tagNamePtr,
-                                BINDING **bindingsPtr)
-{
-  ELEMENT_TYPE *elementType = 0;
-  int nDefaultAtts = 0;
-  const XML_Char **appAtts;   /* the attribute list to pass to the application */
-  int attIndex = 0;
-  int i;
-  int n;
-  int nPrefixes = 0;
-  BINDING *binding;
-  const XML_Char *localPart;
-
-  /* lookup the element type name */
-  if (tagNamePtr) {
-    elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str,0);
-    if (!elementType) {
-      tagNamePtr->str = poolCopyString(&dtd.pool, tagNamePtr->str);
-      if (!tagNamePtr->str)
-        return XML_ERROR_NO_MEMORY;
-      elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str, sizeof(ELEMENT_TYPE));
-      if (!elementType)
-        return XML_ERROR_NO_MEMORY;
-      if (ns && !setElementTypePrefix(parser, elementType))
-        return XML_ERROR_NO_MEMORY;
-    }
-    nDefaultAtts = elementType->nDefaultAtts;
-  }
-  /* get the attributes from the tokenizer */
-  n = XmlGetAttributes(enc, attStr, attsSize, atts);
-  if (n + nDefaultAtts > attsSize) {
-    int oldAttsSize = attsSize;
-    attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
-    atts = REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE));
-    if (!atts)
-      return XML_ERROR_NO_MEMORY;
-    if (n > oldAttsSize)
-      XmlGetAttributes(enc, attStr, n, atts);
-  }
-  appAtts = (const XML_Char **)atts;
-  for (i = 0; i < n; i++) {
-    /* add the name and value to the attribute list */
-    ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name,
-                                         atts[i].name
-                                         + XmlNameLength(enc, atts[i].name));
-    if (!attId)
-      return XML_ERROR_NO_MEMORY;
-    /* detect duplicate attributes */
-    if ((attId->name)[-1]) {
-      if (enc == encoding)
-        eventPtr = atts[i].name;
-      return XML_ERROR_DUPLICATE_ATTRIBUTE;
-    }
-    (attId->name)[-1] = 1;
-    appAtts[attIndex++] = attId->name;
-    if (!atts[i].normalized) {
-      enum XML_Error result;
-      int isCdata = 1;
-
-      /* figure out whether declared as other than CDATA */
-      if (attId->maybeTokenized) {
-        int j;
-        for (j = 0; j < nDefaultAtts; j++) {
-          if (attId == elementType->defaultAtts[j].id) {
-            isCdata = elementType->defaultAtts[j].isCdata;
-            break;
-          }
-        }
-      }
-
-      /* normalize the attribute value */
-      result = storeAttributeValue(parser, enc, isCdata,
-                                   atts[i].valuePtr, atts[i].valueEnd,
-                                   &tempPool);
-      if (result)
-        return result;
-      if (tagNamePtr) {
-        appAtts[attIndex] = poolStart(&tempPool);
-        poolFinish(&tempPool);
-      }
-      else
-        poolDiscard(&tempPool);
-    }
-    else if (tagNamePtr) {
-      /* the value did not need normalizing */
-      appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, atts[i].valueEnd);
-      if (appAtts[attIndex] == 0)
-        return XML_ERROR_NO_MEMORY;
-      poolFinish(&tempPool);
-    }
-    /* handle prefixed attribute names */
-    if (attId->prefix && tagNamePtr) {
-      if (attId->xmlns) {
-        /* deal with namespace declarations here */
-        if (!addBinding(parser, attId->prefix, attId, appAtts[attIndex], bindingsPtr))
-          return XML_ERROR_NO_MEMORY;
-        --attIndex;
-      }
-      else {
-        /* deal with other prefixed names later */
-        attIndex++;
-        nPrefixes++;
-        (attId->name)[-1] = 2;
-      }
-    }
-    else
-      attIndex++;
-  }
-  if (tagNamePtr) {
-    int j;
-    nSpecifiedAtts = attIndex;
-    if (elementType->idAtt && (elementType->idAtt->name)[-1]) {
-      for (i = 0; i < attIndex; i += 2)
-        if (appAtts[i] == elementType->idAtt->name) {
-          idAttIndex = i;
-          break;
-        }
-    }
-    else
-      idAttIndex = -1;
-    /* do attribute defaulting */
-    for (j = 0; j < nDefaultAtts; j++) {
-      const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + j;
-      if (!(da->id->name)[-1] && da->value) {
-        if (da->id->prefix) {
-          if (da->id->xmlns) {
-            if (!addBinding(parser, da->id->prefix, da->id, da->value, bindingsPtr))
-              return XML_ERROR_NO_MEMORY;
-          }
-          else {
-            (da->id->name)[-1] = 2;
-            nPrefixes++;
-            appAtts[attIndex++] = da->id->name;
-            appAtts[attIndex++] = da->value;
-          }
-        }
-        else {
-          (da->id->name)[-1] = 1;
-          appAtts[attIndex++] = da->id->name;
-          appAtts[attIndex++] = da->value;
-        }
-      }
-    }
-    appAtts[attIndex] = 0;
-  }
-  i = 0;
-  if (nPrefixes) {
-    /* expand prefixed attribute names */
-    for (; i < attIndex; i += 2) {
-      if (appAtts[i][-1] == 2) {
-        ATTRIBUTE_ID *id;
-        ((XML_Char *)(appAtts[i]))[-1] = 0;
-        id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, appAtts[i], 0);
-        if (id->prefix->binding) {
-          int j;
-          const BINDING *b = id->prefix->binding;
-          const XML_Char *s = appAtts[i];
-          for (j = 0; j < b->uriLen; j++) {
-            if (!poolAppendChar(&tempPool, b->uri[j]))
-              return XML_ERROR_NO_MEMORY;
-          }
-          while (*s++ != ':')
-            ;
-          do {
-            if (!poolAppendChar(&tempPool, *s))
-              return XML_ERROR_NO_MEMORY;
-          } while (*s++);
-          if (ns_triplets) {
-            tempPool.ptr[-1] = namespaceSeparator;
-            s = b->prefix->name;
-            do {
-              if (!poolAppendChar(&tempPool, *s))
-                return XML_ERROR_NO_MEMORY;
-            } while (*s++);
-          }
-
-          appAtts[i] = poolStart(&tempPool);
-          poolFinish(&tempPool);
-        }
-        if (!--nPrefixes)
-          break;
-      }
-      else
-        ((XML_Char *)(appAtts[i]))[-1] = 0;
-    }
-  }
-  /* clear the flags that say whether attributes were specified */
-  for (; i < attIndex; i += 2)
-    ((XML_Char *)(appAtts[i]))[-1] = 0;
-  if (!tagNamePtr)
-    return XML_ERROR_NONE;
-  for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
-    binding->attId->name[-1] = 0;
-  /* expand the element type name */
-  if (elementType->prefix) {
-    binding = elementType->prefix->binding;
-    if (!binding)
-      return XML_ERROR_NONE;
-    localPart = tagNamePtr->str;
-    while (*localPart++ != XML_T(':'))
-      ;
-  }
-  else if (dtd.defaultPrefix.binding) {
-    binding = dtd.defaultPrefix.binding;
-    localPart = tagNamePtr->str;
-  }
-  else
-    return XML_ERROR_NONE;
-  tagNamePtr->localPart = localPart;
-  tagNamePtr->uriLen = binding->uriLen;
-  for (i = 0; localPart[i++];)
-    ;
-  n = i + binding->uriLen;
-  if (n > binding->uriAlloc) {
-    TAG *p;
-    XML_Char *uri = MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char));
-    if (!uri)
-      return XML_ERROR_NO_MEMORY;
-    binding->uriAlloc = n + EXPAND_SPARE;
-    memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char));
-    for (p = tagStack; p; p = p->parent)
-      if (p->name.str == binding->uri)
-        p->name.str = uri;
-    FREE(binding->uri);
-    binding->uri = uri;
-  }
-  memcpy(binding->uri + binding->uriLen, localPart, i * sizeof(XML_Char));
-  tagNamePtr->str = binding->uri;
-  return XML_ERROR_NONE;
-}
-
-static
-int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr)
-{
-  BINDING *b;
-  int len;
-  for (len = 0; uri[len]; len++)
-    ;
-  if (namespaceSeparator)
-    len++;
-  if (freeBindingList) {
-    b = freeBindingList;
-    if (len > b->uriAlloc) {
-      b->uri = REALLOC(b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
-      if (!b->uri)
-        return 0;
-      b->uriAlloc = len + EXPAND_SPARE;
-    }
-    freeBindingList = b->nextTagBinding;
-  }
-  else {
-    b = MALLOC(sizeof(BINDING));
-    if (!b)
-      return 0;
-    b->uri = MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE));
-    if (!b->uri) {
-      FREE(b);
-      return 0;
-    }
-    b->uriAlloc = len + EXPAND_SPARE;
-  }
-  b->uriLen = len;
-  memcpy(b->uri, uri, len * sizeof(XML_Char));
-  if (namespaceSeparator)
-    b->uri[len - 1] = namespaceSeparator;
-  b->prefix = prefix;
-  b->attId = attId;
-  b->prevPrefixBinding = prefix->binding;
-  if (*uri == XML_T('\0') && prefix == &dtd.defaultPrefix)
-    prefix->binding = 0;
-  else
-    prefix->binding = b;
-  b->nextTagBinding = *bindingsPtr;
-  *bindingsPtr = b;
-  if (startNamespaceDeclHandler)
-    startNamespaceDeclHandler(handlerArg, prefix->name,
-                              prefix->binding ? uri : 0);
-  return 1;
-}
-
-/* The idea here is to avoid using stack for each CDATA section when
-the whole file is parsed with one call. */
-
-static
-enum XML_Error cdataSectionProcessor(XML_Parser parser,
-                                     const char *start,
-                                     const char *end,
-                                     const char **endPtr)
-{
-  enum XML_Error result = doCdataSection(parser, encoding, &start, end, endPtr);
-  if (start) {
-    processor = contentProcessor;
-    return contentProcessor(parser, start, end, endPtr);
-  }
-  return result;
-}
-
-/* startPtr gets set to non-null is the section is closed, and to null if
-the section is not yet closed. */
-
-static
-enum XML_Error doCdataSection(XML_Parser parser,
-                              const ENCODING *enc,
-                              const char **startPtr,
-                              const char *end,
-                              const char **nextPtr)
-{
-  const char *s = *startPtr;
-  const char **eventPP;
-  const char **eventEndPP;
-  if (enc == encoding) {
-    eventPP = &eventPtr;
-    *eventPP = s;
-    eventEndPP = &eventEndPtr;
-  }
-  else {
-    eventPP = &(openInternalEntities->internalEventPtr);
-    eventEndPP = &(openInternalEntities->internalEventEndPtr);
-  }
-  *eventPP = s;
-  *startPtr = 0;
-  for (;;) {
-    const char *next;
-    int tok = XmlCdataSectionTok(enc, s, end, &next);
-    *eventEndPP = next;
-    switch (tok) {
-    case XML_TOK_CDATA_SECT_CLOSE:
-      if (endCdataSectionHandler)
-        endCdataSectionHandler(handlerArg);
-#if 0
-      /* see comment under XML_TOK_CDATA_SECT_OPEN */
-      else if (characterDataHandler)
-        characterDataHandler(handlerArg, dataBuf, 0);
-#endif
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      *startPtr = next;
-      return XML_ERROR_NONE;
-    case XML_TOK_DATA_NEWLINE:
-      if (characterDataHandler) {
-        XML_Char c = 0xA;
-        characterDataHandler(handlerArg, &c, 1);
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      break;
-    case XML_TOK_DATA_CHARS:
-      if (characterDataHandler) {
-        if (MUST_CONVERT(enc, s)) {
-          for (;;) {
-            ICHAR *dataPtr = (ICHAR *)dataBuf;
-            XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
-            *eventEndPP = next;
-            characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
-            if (s == next)
-              break;
-            *eventPP = s;
-          }
-        }
-        else
-          characterDataHandler(handlerArg,
-                               (XML_Char *)s,
-                               (XML_Char *)next - (XML_Char *)s);
-      }
-      else if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      break;
-    case XML_TOK_INVALID:
-      *eventPP = next;
-      return XML_ERROR_INVALID_TOKEN;
-    case XML_TOK_PARTIAL_CHAR:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_PARTIAL_CHAR;
-    case XML_TOK_PARTIAL:
-    case XML_TOK_NONE:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_UNCLOSED_CDATA_SECTION;
-    default:
-      *eventPP = next;
-      return XML_ERROR_UNEXPECTED_STATE;
-    }
-    *eventPP = s = next;
-  }
-  /* not reached */
-}
-
-#ifdef XML_DTD
-
-/* The idea here is to avoid using stack for each IGNORE section when
-the whole file is parsed with one call. */
-
-static
-enum XML_Error ignoreSectionProcessor(XML_Parser parser,
-                                      const char *start,
-                                      const char *end,
-                                      const char **endPtr)
-{
-  enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, endPtr);
-  if (start) {
-    processor = prologProcessor;
-    return prologProcessor(parser, start, end, endPtr);
-  }
-  return result;
-}
-
-/* startPtr gets set to non-null is the section is closed, and to null if
-the section is not yet closed. */
-
-static
-enum XML_Error doIgnoreSection(XML_Parser parser,
-                               const ENCODING *enc,
-                               const char **startPtr,
-                               const char *end,
-                               const char **nextPtr)
-{
-  const char *next;
-  int tok;
-  const char *s = *startPtr;
-  const char **eventPP;
-  const char **eventEndPP;
-  if (enc == encoding) {
-    eventPP = &eventPtr;
-    *eventPP = s;
-    eventEndPP = &eventEndPtr;
-  }
-  else {
-    eventPP = &(openInternalEntities->internalEventPtr);
-    eventEndPP = &(openInternalEntities->internalEventEndPtr);
-  }
-  *eventPP = s;
-  *startPtr = 0;
-  tok = XmlIgnoreSectionTok(enc, s, end, &next);
-  *eventEndPP = next;
-  switch (tok) {
-  case XML_TOK_IGNORE_SECT:
-    if (defaultHandler)
-      reportDefault(parser, enc, s, next);
-    *startPtr = next;
-    return XML_ERROR_NONE;
-  case XML_TOK_INVALID:
-    *eventPP = next;
-    return XML_ERROR_INVALID_TOKEN;
-  case XML_TOK_PARTIAL_CHAR:
-    if (nextPtr) {
-      *nextPtr = s;
-      return XML_ERROR_NONE;
-    }
-    return XML_ERROR_PARTIAL_CHAR;
-  case XML_TOK_PARTIAL:
-  case XML_TOK_NONE:
-    if (nextPtr) {
-      *nextPtr = s;
-      return XML_ERROR_NONE;
-    }
-    return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */
-  default:
-    *eventPP = next;
-    return XML_ERROR_UNEXPECTED_STATE;
-  }
-  /* not reached */
-}
-
-#endif /* XML_DTD */
-
-static enum XML_Error
-initializeEncoding(XML_Parser parser)
-{
-  const char *s;
-#ifdef XML_UNICODE
-  char encodingBuf[128];
-  if (!protocolEncodingName)
-    s = 0;
-  else {
-    int i;
-    for (i = 0; protocolEncodingName[i]; i++) {
-      if (i == sizeof(encodingBuf) - 1
-          || (protocolEncodingName[i] & ~0x7f) != 0) {
-        encodingBuf[0] = '\0';
-        break;
-      }
-      encodingBuf[i] = (char)protocolEncodingName[i];
-    }
-    encodingBuf[i] = '\0';
-    s = encodingBuf;
-  }
-#else
-  s = protocolEncodingName;
-#endif
-  if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s))
-    return XML_ERROR_NONE;
-  return handleUnknownEncoding(parser, protocolEncodingName);
-}
-
-static enum XML_Error
-processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
-               const char *s, const char *next)
-{
-  const char *encodingName = 0;
-  const char *storedEncName = 0;
-  const ENCODING *newEncoding = 0;
-  const char *version = 0;
-  const char *versionend;
-  const char *storedversion = 0;
-  int standalone = -1;
-  if (!(ns
-        ? XmlParseXmlDeclNS
-        : XmlParseXmlDecl)(isGeneralTextEntity,
-                           encoding,
-                           s,
-                           next,
-                           &eventPtr,
-                           &version,
-                           &versionend,
-                           &encodingName,
-                           &newEncoding,
-                           &standalone))
-    return XML_ERROR_SYNTAX;
-  if (!isGeneralTextEntity && standalone == 1) {
-    dtd.standalone = 1;
-#ifdef XML_DTD
-    if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
-      paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
-#endif /* XML_DTD */
-  }
-  if (xmlDeclHandler) {
-    if (encodingName) {
-      storedEncName = poolStoreString(&temp2Pool,
-                                      encoding,
-                                      encodingName,
-                                      encodingName
-                                      + XmlNameLength(encoding, encodingName));
-      if (! storedEncName)
-        return XML_ERROR_NO_MEMORY;
-      poolFinish(&temp2Pool);
-    }
-    if (version) {
-      storedversion = poolStoreString(&temp2Pool,
-                                      encoding,
-                                      version,
-                                      versionend - encoding->minBytesPerChar);
-      if (! storedversion)
-        return XML_ERROR_NO_MEMORY;
-    }
-    xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone);
-  }
-  else if (defaultHandler)
-    reportDefault(parser, encoding, s, next);
-  if (!protocolEncodingName) {
-    if (newEncoding) {
-      if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) {
-        eventPtr = encodingName;
-        return XML_ERROR_INCORRECT_ENCODING;
-      }
-      encoding = newEncoding;
-    }
-    else if (encodingName) {
-      enum XML_Error result;
-      if (! storedEncName) {
-        storedEncName = poolStoreString(&temp2Pool,
-                                        encoding,
-                                        encodingName,
-                                        encodingName
-                                        + XmlNameLength(encoding, encodingName));
-        if (! storedEncName)
-          return XML_ERROR_NO_MEMORY;
-      }
-      result = handleUnknownEncoding(parser, storedEncName);
-      poolClear(&tempPool);
-      if (result == XML_ERROR_UNKNOWN_ENCODING)
-        eventPtr = encodingName;
-      return result;
-    }
-  }
-
-  if (storedEncName || storedversion)
-    poolClear(&temp2Pool);
-
-  return XML_ERROR_NONE;
-}
-
-static enum XML_Error
-handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
-{
-  if (unknownEncodingHandler) {
-    XML_Encoding info;
-    int i;
-    for (i = 0; i < 256; i++)
-      info.map[i] = -1;
-    info.convert = 0;
-    info.data = 0;
-    info.release = 0;
-    if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, &info)) {
-      ENCODING *enc;
-      unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding());
-      if (!unknownEncodingMem) {
-        if (info.release)
-          info.release(info.data);
-        return XML_ERROR_NO_MEMORY;
-      }
-      enc = (ns
-             ? XmlInitUnknownEncodingNS
-             : XmlInitUnknownEncoding)(unknownEncodingMem,
-                                       info.map,
-                                       info.convert,
-                                       info.data);
-      if (enc) {
-        unknownEncodingData = info.data;
-        unknownEncodingRelease = info.release;
-        encoding = enc;
-        return XML_ERROR_NONE;
-      }
-    }
-    if (info.release)
-      info.release(info.data);
-  }
-  return XML_ERROR_UNKNOWN_ENCODING;
-}
-
-static enum XML_Error
-prologInitProcessor(XML_Parser parser,
-                    const char *s,
-                    const char *end,
-                    const char **nextPtr)
-{
-  enum XML_Error result = initializeEncoding(parser);
-  if (result != XML_ERROR_NONE)
-    return result;
-  processor = prologProcessor;
-  return prologProcessor(parser, s, end, nextPtr);
-}
-
-static enum XML_Error
-prologProcessor(XML_Parser parser,
-                const char *s,
-                const char *end,
-                const char **nextPtr)
-{
-  const char *next;
-  int tok = XmlPrologTok(encoding, s, end, &next);
-  return doProlog(parser, encoding, s, end, tok, next, nextPtr);
-}
-
-static enum XML_Error
-doProlog(XML_Parser parser,
-         const ENCODING *enc,
-         const char *s,
-         const char *end,
-         int tok,
-         const char *next,
-         const char **nextPtr)
-{
-#ifdef XML_DTD
-  static const XML_Char externalSubsetName[] = { '#' , '\0' };
-#endif /* XML_DTD */
-
-  const char **eventPP;
-  const char **eventEndPP;
-  enum XML_Content_Quant quant;
-
-  if (enc == encoding) {
-    eventPP = &eventPtr;
-    eventEndPP = &eventEndPtr;
-  }
-  else {
-    eventPP = &(openInternalEntities->internalEventPtr);
-    eventEndPP = &(openInternalEntities->internalEventEndPtr);
-  }
-  for (;;) {
-    int role;
-    *eventPP = s;
-    *eventEndPP = next;
-    if (tok <= 0) {
-      if (nextPtr != 0 && tok != XML_TOK_INVALID) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      switch (tok) {
-      case XML_TOK_INVALID:
-        *eventPP = next;
-        return XML_ERROR_INVALID_TOKEN;
-      case XML_TOK_PARTIAL:
-        return XML_ERROR_UNCLOSED_TOKEN;
-      case XML_TOK_PARTIAL_CHAR:
-        return XML_ERROR_PARTIAL_CHAR;
-      case XML_TOK_NONE:
-#ifdef XML_DTD
-        if (enc != encoding)
-          return XML_ERROR_NONE;
-        if (parentParser) {
-          if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc)
-              == XML_ROLE_ERROR)
-            return XML_ERROR_SYNTAX;
-          hadExternalDoctype = 0;
-          return XML_ERROR_NONE;
-        }
-#endif /* XML_DTD */
-        return XML_ERROR_NO_ELEMENTS;
-      default:
-        tok = -tok;
-        next = end;
-        break;
-      }
-    }
-    role = XmlTokenRole(&prologState, tok, s, next, enc);
-    switch (role) {
-    case XML_ROLE_XML_DECL:
-      {
-        enum XML_Error result = processXmlDecl(parser, 0, s, next);
-        if (result != XML_ERROR_NONE)
-          return result;
-        enc = encoding;
-      }
-      break;
-    case XML_ROLE_DOCTYPE_NAME:
-      if (startDoctypeDeclHandler) {
-        doctypeName = poolStoreString(&tempPool, enc, s, next);
-        if (! doctypeName)
-          return XML_ERROR_NO_MEMORY;
-        poolFinish(&tempPool);
-        doctypeSysid = 0;
-        doctypePubid = 0;
-      }
-      break;
-    case XML_ROLE_DOCTYPE_INTERNAL_SUBSET:
-      if (startDoctypeDeclHandler) {
-        startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid,
-                                doctypePubid, 1);
-        doctypeName = 0;
-        poolClear(&tempPool);
-      }
-      break;
-#ifdef XML_DTD
-    case XML_ROLE_TEXT_DECL:
-      {
-        enum XML_Error result = processXmlDecl(parser, 1, s, next);
-        if (result != XML_ERROR_NONE)
-          return result;
-        enc = encoding;
-      }
-      break;
-#endif /* XML_DTD */
-    case XML_ROLE_DOCTYPE_PUBLIC_ID:
-      if (startDoctypeDeclHandler) {
-        doctypePubid = poolStoreString(&tempPool, enc, s + 1, next - 1);
-        if (! doctypePubid)
-          return XML_ERROR_NO_MEMORY;
-        poolFinish(&tempPool);
-      }
-#ifdef XML_DTD
-      declEntity = (ENTITY *)lookup(&dtd.paramEntities,
-                                    externalSubsetName,
-                                    sizeof(ENTITY));
-      if (!declEntity)
-        return XML_ERROR_NO_MEMORY;
-#endif /* XML_DTD */
-      /* fall through */
-    case XML_ROLE_ENTITY_PUBLIC_ID:
-      if (!XmlIsPublicId(enc, s, next, eventPP))
-        return XML_ERROR_SYNTAX;
-      if (declEntity) {
-        XML_Char *tem = poolStoreString(&dtd.pool,
-                                        enc,
-                                        s + enc->minBytesPerChar,
-                                        next - enc->minBytesPerChar);
-        if (!tem)
-          return XML_ERROR_NO_MEMORY;
-        normalizePublicId(tem);
-        declEntity->publicId = tem;
-        poolFinish(&dtd.pool);
-      }
-      break;
-    case XML_ROLE_DOCTYPE_CLOSE:
-      if (doctypeName) {
-        startDoctypeDeclHandler(handlerArg, doctypeName,
-                                doctypeSysid, doctypePubid, 0);
-        poolClear(&tempPool);
-      }
-      if (dtd.complete && hadExternalDoctype) {
-        dtd.complete = 0;
-#ifdef XML_DTD
-        if (paramEntityParsing && externalEntityRefHandler) {
-          ENTITY *entity = (ENTITY *)lookup(&dtd.paramEntities,
-                                            externalSubsetName,
-                                            0);
-          if (!externalEntityRefHandler(externalEntityRefHandlerArg,
-                                        0,
-                                        entity->base,
-                                        entity->systemId,
-                                        entity->publicId))
-           return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-        }
-#endif /* XML_DTD */
-        if (!dtd.complete
-            && !dtd.standalone
-            && notStandaloneHandler
-            && !notStandaloneHandler(handlerArg))
-          return XML_ERROR_NOT_STANDALONE;
-      }
-      if (endDoctypeDeclHandler)
-        endDoctypeDeclHandler(handlerArg);
-      break;
-    case XML_ROLE_INSTANCE_START:
-      processor = contentProcessor;
-      return contentProcessor(parser, s, end, nextPtr);
-    case XML_ROLE_ATTLIST_ELEMENT_NAME:
-      declElementType = getElementType(parser, enc, s, next);
-      if (!declElementType)
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_ROLE_ATTRIBUTE_NAME:
-      declAttributeId = getAttributeId(parser, enc, s, next);
-      if (!declAttributeId)
-        return XML_ERROR_NO_MEMORY;
-      declAttributeIsCdata = 0;
-      declAttributeType = 0;
-      declAttributeIsId = 0;
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_CDATA:
-      declAttributeIsCdata = 1;
-      declAttributeType = "CDATA";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_ID:
-      declAttributeIsId = 1;
-      declAttributeType = "ID";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_IDREF:
-      declAttributeType = "IDREF";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_IDREFS:
-      declAttributeType = "IDREFS";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_ENTITY:
-      declAttributeType = "ENTITY";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES:
-      declAttributeType = "ENTITIES";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN:
-      declAttributeType = "NMTOKEN";
-      break;
-    case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS:
-      declAttributeType = "NMTOKENS";
-      break;
-
-    case XML_ROLE_ATTRIBUTE_ENUM_VALUE:
-    case XML_ROLE_ATTRIBUTE_NOTATION_VALUE:
-      if (attlistDeclHandler)
-      {
-        char *prefix;
-        if (declAttributeType) {
-          prefix = "|";
-        }
-        else {
-          prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE
-                    ? "NOTATION("
-                    : "(");
-        }
-        if (! poolAppendString(&tempPool, prefix))
-          return XML_ERROR_NO_MEMORY;
-        if (! poolAppend(&tempPool, enc, s, next))
-          return XML_ERROR_NO_MEMORY;
-        declAttributeType = tempPool.start;
-      }
-      break;
-    case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE:
-    case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE:
-      if (dtd.complete
-          && !defineAttribute(declElementType, declAttributeId,
-                              declAttributeIsCdata, declAttributeIsId, 0,
-                              parser))
-        return XML_ERROR_NO_MEMORY;
-      if (attlistDeclHandler && declAttributeType) {
-        if (*declAttributeType == '('
-            || (*declAttributeType == 'N' && declAttributeType[1] == 'O')) {
-          /* Enumerated or Notation type */
-          if (! poolAppendChar(&tempPool, ')')
-              || ! poolAppendChar(&tempPool, '\0'))
-            return XML_ERROR_NO_MEMORY;
-          declAttributeType = tempPool.start;
-          poolFinish(&tempPool);
-        }
-        *eventEndPP = s;
-        attlistDeclHandler(handlerArg, declElementType->name,
-                           declAttributeId->name, declAttributeType,
-                           0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
-        poolClear(&tempPool);
-      }
-      break;
-    case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
-    case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
-      {
-        const XML_Char *attVal;
-        enum XML_Error result
-          = storeAttributeValue(parser, enc, declAttributeIsCdata,
-                                s + enc->minBytesPerChar,
-                                next - enc->minBytesPerChar,
-                                &dtd.pool);
-        if (result)
-          return result;
-        attVal = poolStart(&dtd.pool);
-        poolFinish(&dtd.pool);
-        if (dtd.complete
-            /* ID attributes aren't allowed to have a default */
-            && !defineAttribute(declElementType, declAttributeId, declAttributeIsCdata, 0, attVal, parser))
-          return XML_ERROR_NO_MEMORY;
-        if (attlistDeclHandler && declAttributeType) {
-          if (*declAttributeType == '('
-              || (*declAttributeType == 'N' && declAttributeType[1] == 'O')) {
-            /* Enumerated or Notation type */
-            if (! poolAppendChar(&tempPool, ')')
-                || ! poolAppendChar(&tempPool, '\0'))
-              return XML_ERROR_NO_MEMORY;
-            declAttributeType = tempPool.start;
-            poolFinish(&tempPool);
-          }
-          *eventEndPP = s;
-          attlistDeclHandler(handlerArg, declElementType->name,
-                             declAttributeId->name, declAttributeType,
-                             attVal,
-                             role == XML_ROLE_FIXED_ATTRIBUTE_VALUE);
-          poolClear(&tempPool);
-        }
-        break;
-      }
-    case XML_ROLE_ENTITY_VALUE:
-      {
-        enum XML_Error result = storeEntityValue(parser, enc,
-                                                 s + enc->minBytesPerChar,
-                                                 next - enc->minBytesPerChar);
-        if (declEntity) {
-          declEntity->textPtr = poolStart(&dtd.pool);
-          declEntity->textLen = poolLength(&dtd.pool);
-          poolFinish(&dtd.pool);
-          if (entityDeclHandler) {
-            *eventEndPP = s;
-            entityDeclHandler(handlerArg,
-                              declEntity->name,
-                              declEntity->is_param,
-                              declEntity->textPtr,
-                              declEntity->textLen,
-                              curBase, 0, 0, 0);
-          }
-        }
-        else
-          poolDiscard(&dtd.pool);
-        if (result != XML_ERROR_NONE)
-          return result;
-      }
-      break;
-    case XML_ROLE_DOCTYPE_SYSTEM_ID:
-      if (startDoctypeDeclHandler) {
-        doctypeSysid = poolStoreString(&tempPool, enc, s + 1, next - 1);
-        if (! doctypeSysid)
-          return XML_ERROR_NO_MEMORY;
-        poolFinish(&tempPool);
-      }
-      if (!dtd.standalone
-#ifdef XML_DTD
-          && !paramEntityParsing
-#endif /* XML_DTD */
-          && notStandaloneHandler
-          && !notStandaloneHandler(handlerArg))
-        return XML_ERROR_NOT_STANDALONE;
-      hadExternalDoctype = 1;
-#ifndef XML_DTD
-      break;
-#else /* XML_DTD */
-      if (!declEntity) {
-        declEntity = (ENTITY *)lookup(&dtd.paramEntities,
-                                      externalSubsetName,
-                                      sizeof(ENTITY));
-        declEntity->publicId = 0;
-        if (!declEntity)
-          return XML_ERROR_NO_MEMORY;
-      }
-      /* fall through */
-#endif /* XML_DTD */
-    case XML_ROLE_ENTITY_SYSTEM_ID:
-      if (declEntity) {
-        declEntity->systemId = poolStoreString(&dtd.pool, enc,
-                                               s + enc->minBytesPerChar,
-                                               next - enc->minBytesPerChar);
-        if (!declEntity->systemId)
-          return XML_ERROR_NO_MEMORY;
-        declEntity->base = curBase;
-        poolFinish(&dtd.pool);
-      }
-      break;
-    case XML_ROLE_ENTITY_COMPLETE:
-      if (declEntity && entityDeclHandler) {
-        *eventEndPP = s;
-        entityDeclHandler(handlerArg,
-                          declEntity->name,
-                          0,0,0,
-                          declEntity->base,
-                          declEntity->systemId,
-                          declEntity->publicId,
-                          0);
-      }
-      break;
-    case XML_ROLE_ENTITY_NOTATION_NAME:
-      if (declEntity) {
-        declEntity->notation = poolStoreString(&dtd.pool, enc, s, next);
-        if (!declEntity->notation)
-          return XML_ERROR_NO_MEMORY;
-        poolFinish(&dtd.pool);
-        if (unparsedEntityDeclHandler) {
-          *eventEndPP = s;
-          unparsedEntityDeclHandler(handlerArg,
-                                    declEntity->name,
-                                    declEntity->base,
-                                    declEntity->systemId,
-                                    declEntity->publicId,
-                                    declEntity->notation);
-        }
-        else if (entityDeclHandler) {
-          *eventEndPP = s;
-          entityDeclHandler(handlerArg,
-                            declEntity->name,
-                            0,0,0,
-                            declEntity->base,
-                            declEntity->systemId,
-                            declEntity->publicId,
-                            declEntity->notation);
-        }
-      }
-      break;
-    case XML_ROLE_GENERAL_ENTITY_NAME:
-      {
-        const XML_Char *name;
-        if (XmlPredefinedEntityName(enc, s, next)) {
-          declEntity = 0;
-          break;
-        }
-        name = poolStoreString(&dtd.pool, enc, s, next);
-        if (!name)
-          return XML_ERROR_NO_MEMORY;
-        if (dtd.complete) {
-          declEntity = (ENTITY *)lookup(&dtd.generalEntities, name, sizeof(ENTITY));
-          if (!declEntity)
-            return XML_ERROR_NO_MEMORY;
-          if (declEntity->name != name) {
-            poolDiscard(&dtd.pool);
-            declEntity = 0;
-          }
-          else {
-            poolFinish(&dtd.pool);
-            declEntity->publicId = 0;
-            declEntity->is_param = 0;
-          }
-        }
-        else {
-          poolDiscard(&dtd.pool);
-          declEntity = 0;
-        }
-      }
-      break;
-    case XML_ROLE_PARAM_ENTITY_NAME:
-#ifdef XML_DTD
-      if (dtd.complete) {
-        const XML_Char *name = poolStoreString(&dtd.pool, enc, s, next);
-        if (!name)
-          return XML_ERROR_NO_MEMORY;
-        declEntity = (ENTITY *)lookup(&dtd.paramEntities,
-                                      name, sizeof(ENTITY));
-        if (!declEntity)
-          return XML_ERROR_NO_MEMORY;
-        if (declEntity->name != name) {
-          poolDiscard(&dtd.pool);
-          declEntity = 0;
-        }
-        else {
-          poolFinish(&dtd.pool);
-          declEntity->publicId = 0;
-          declEntity->is_param = 1;
-        }
-      }
-#else /* not XML_DTD */
-      declEntity = 0;
-#endif /* not XML_DTD */
-      break;
-    case XML_ROLE_NOTATION_NAME:
-      declNotationPublicId = 0;
-      declNotationName = 0;
-      if (notationDeclHandler) {
-        declNotationName = poolStoreString(&tempPool, enc, s, next);
-        if (!declNotationName)
-          return XML_ERROR_NO_MEMORY;
-        poolFinish(&tempPool);
-      }
-      break;
-    case XML_ROLE_NOTATION_PUBLIC_ID:
-      if (!XmlIsPublicId(enc, s, next, eventPP))
-        return XML_ERROR_SYNTAX;
-      if (declNotationName) {
-        XML_Char *tem = poolStoreString(&tempPool,
-                                        enc,
-                                        s + enc->minBytesPerChar,
-                                        next - enc->minBytesPerChar);
-        if (!tem)
-          return XML_ERROR_NO_MEMORY;
-        normalizePublicId(tem);
-        declNotationPublicId = tem;
-        poolFinish(&tempPool);
-      }
-      break;
-    case XML_ROLE_NOTATION_SYSTEM_ID:
-      if (declNotationName && notationDeclHandler) {
-        const XML_Char *systemId
-          = poolStoreString(&tempPool, enc,
-                            s + enc->minBytesPerChar,
-                            next - enc->minBytesPerChar);
-        if (!systemId)
-          return XML_ERROR_NO_MEMORY;
-        *eventEndPP = s;
-        notationDeclHandler(handlerArg,
-                            declNotationName,
-                            curBase,
-                            systemId,
-                            declNotationPublicId);
-      }
-      poolClear(&tempPool);
-      break;
-    case XML_ROLE_NOTATION_NO_SYSTEM_ID:
-      if (declNotationPublicId && notationDeclHandler) {
-        *eventEndPP = s;
-        notationDeclHandler(handlerArg,
-                            declNotationName,
-                            curBase,
-                            0,
-                            declNotationPublicId);
-      }
-      poolClear(&tempPool);
-      break;
-    case XML_ROLE_ERROR:
-      switch (tok) {
-      case XML_TOK_PARAM_ENTITY_REF:
-        return XML_ERROR_PARAM_ENTITY_REF;
-      case XML_TOK_XML_DECL:
-        return XML_ERROR_MISPLACED_XML_PI;
-      default:
-        return XML_ERROR_SYNTAX;
-      }
-#ifdef XML_DTD
-    case XML_ROLE_IGNORE_SECT:
-      {
-        enum XML_Error result;
-        if (defaultHandler)
-          reportDefault(parser, enc, s, next);
-        result = doIgnoreSection(parser, enc, &next, end, nextPtr);
-        if (!next) {
-          processor = ignoreSectionProcessor;
-          return result;
-        }
-      }
-      break;
-#endif /* XML_DTD */
-    case XML_ROLE_GROUP_OPEN:
-      if (prologState.level >= groupSize) {
-        if (groupSize) {
-          groupConnector = REALLOC(groupConnector, groupSize *= 2);
-          if (dtd.scaffIndex)
-            dtd.scaffIndex = REALLOC(dtd.scaffIndex, groupSize * sizeof(int));
-        }
-        else
-          groupConnector = MALLOC(groupSize = 32);
-        if (!groupConnector)
-          return XML_ERROR_NO_MEMORY;
-      }
-      groupConnector[prologState.level] = 0;
-      if (dtd.in_eldecl) {
-        int myindex = nextScaffoldPart(parser);
-        if (myindex < 0)
-          return XML_ERROR_NO_MEMORY;
-        dtd.scaffIndex[dtd.scaffLevel] = myindex;
-        dtd.scaffLevel++;
-        dtd.scaffold[myindex].type = XML_CTYPE_SEQ;
-      }
-      break;
-    case XML_ROLE_GROUP_SEQUENCE:
-      if (groupConnector[prologState.level] == '|')
-        return XML_ERROR_SYNTAX;
-      groupConnector[prologState.level] = ',';
-      break;
-    case XML_ROLE_GROUP_CHOICE:
-      if (groupConnector[prologState.level] == ',')
-        return XML_ERROR_SYNTAX;
-      if (dtd.in_eldecl
-          && ! groupConnector[prologState.level]
-          && dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type != XML_CTYPE_MIXED
-          ) {
-        dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type = XML_CTYPE_CHOICE;
-      }
-      groupConnector[prologState.level] = '|';
-      break;
-    case XML_ROLE_PARAM_ENTITY_REF:
-#ifdef XML_DTD
-    case XML_ROLE_INNER_PARAM_ENTITY_REF:
-      if (paramEntityParsing
-          && (dtd.complete || role == XML_ROLE_INNER_PARAM_ENTITY_REF)) {
-        const XML_Char *name;
-        ENTITY *entity;
-        name = poolStoreString(&dtd.pool, enc,
-                                s + enc->minBytesPerChar,
-                                next - enc->minBytesPerChar);
-        if (!name)
-          return XML_ERROR_NO_MEMORY;
-        entity = (ENTITY *)lookup(&dtd.paramEntities, name, 0);
-        poolDiscard(&dtd.pool);
-        if (!entity) {
-          /* FIXME what to do if !dtd.complete? */
-          return XML_ERROR_UNDEFINED_ENTITY;
-        }
-        if (entity->open)
-          return XML_ERROR_RECURSIVE_ENTITY_REF;
-        if (entity->textPtr) {
-          enum XML_Error result;
-          result = processInternalParamEntity(parser, entity);
-          if (result != XML_ERROR_NONE)
-            return result;
-          break;
-        }
-        if (role == XML_ROLE_INNER_PARAM_ENTITY_REF)
-          return XML_ERROR_PARAM_ENTITY_REF;
-        if (externalEntityRefHandler) {
-          dtd.complete = 0;
-          entity->open = 1;
-          if (!externalEntityRefHandler(externalEntityRefHandlerArg,
-                                        0,
-                                        entity->base,
-                                        entity->systemId,
-                                        entity->publicId)) {
-            entity->open = 0;
-            return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-          }
-          entity->open = 0;
-          if (dtd.complete)
-            break;
-        }
-      }
-#endif /* XML_DTD */
-      if (!dtd.standalone
-          && notStandaloneHandler
-          && !notStandaloneHandler(handlerArg))
-        return XML_ERROR_NOT_STANDALONE;
-      dtd.complete = 0;
-      if (defaultHandler)
-        reportDefault(parser, enc, s, next);
-      break;
-
-      /* Element declaration stuff */
-
-    case XML_ROLE_ELEMENT_NAME:
-      if (elementDeclHandler) {
-        declElementType = getElementType(parser, enc, s, next);
-        if (! declElementType)
-          return XML_ERROR_NO_MEMORY;
-        dtd.scaffLevel = 0;
-        dtd.scaffCount = 0;
-        dtd.in_eldecl = 1;
-      }
-      break;
-
-    case XML_ROLE_CONTENT_ANY:
-    case XML_ROLE_CONTENT_EMPTY:
-      if (dtd.in_eldecl) {
-        if (elementDeclHandler) {
-          XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content));
-          if (! content)
-            return XML_ERROR_NO_MEMORY;
-          content->quant = XML_CQUANT_NONE;
-          content->name = 0;
-          content->numchildren = 0;
-          content->children = 0;
-          content->type = ((role == XML_ROLE_CONTENT_ANY) ?
-                           XML_CTYPE_ANY :
-                           XML_CTYPE_EMPTY);
-          *eventEndPP = s;
-          elementDeclHandler(handlerArg, declElementType->name, content);
-        }
-        dtd.in_eldecl = 0;
-      }
-      break;
-      
-    case XML_ROLE_CONTENT_PCDATA:
-      if (dtd.in_eldecl) {
-        dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type = XML_CTYPE_MIXED;
-      }
-      break;
-
-    case XML_ROLE_CONTENT_ELEMENT:
-      quant = XML_CQUANT_NONE;
-      goto elementContent;
-    case XML_ROLE_CONTENT_ELEMENT_OPT:
-      quant = XML_CQUANT_OPT;
-      goto elementContent;
-    case XML_ROLE_CONTENT_ELEMENT_REP:
-      quant = XML_CQUANT_REP;
-      goto elementContent;
-    case XML_ROLE_CONTENT_ELEMENT_PLUS:
-      quant = XML_CQUANT_PLUS;
-    elementContent:
-      if (dtd.in_eldecl)
-        {
-          ELEMENT_TYPE *el;
-          const char *nxt = quant == XML_CQUANT_NONE ? next : next - 1;
-          int myindex = nextScaffoldPart(parser);
-          if (myindex < 0)
-            return XML_ERROR_NO_MEMORY;
-          dtd.scaffold[myindex].type = XML_CTYPE_NAME;
-          dtd.scaffold[myindex].quant = quant;
-          el = getElementType(parser, enc, s, nxt);
-          if (! el)
-            return XML_ERROR_NO_MEMORY;
-          dtd.scaffold[myindex].name = el->name;
-          dtd.contentStringLen +=  nxt - s + 1;
-        }
-      break;
-
-    case XML_ROLE_GROUP_CLOSE:
-      quant = XML_CQUANT_NONE;
-      goto closeGroup;
-    case XML_ROLE_GROUP_CLOSE_OPT:
-      quant = XML_CQUANT_OPT;
-      goto closeGroup;
-    case XML_ROLE_GROUP_CLOSE_REP:
-      quant = XML_CQUANT_REP;
-      goto closeGroup;
-    case XML_ROLE_GROUP_CLOSE_PLUS:
-      quant = XML_CQUANT_PLUS;
-    closeGroup:
-      if (dtd.in_eldecl) {
-        dtd.scaffLevel--;
-        dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel]].quant = quant;
-        if (dtd.scaffLevel == 0) {
-          if (elementDeclHandler) {
-            XML_Content *model = build_model(parser);
-            if (! model)
-              return XML_ERROR_NO_MEMORY;
-            *eventEndPP = s;
-            elementDeclHandler(handlerArg, declElementType->name, model);
-          }
-          dtd.in_eldecl = 0;
-          dtd.contentStringLen = 0;
-        }
-      }
-      break;
-      /* End element declaration stuff */
-
-    case XML_ROLE_NONE:
-      switch (tok) {
-      case XML_TOK_PI:
-        if (!reportProcessingInstruction(parser, enc, s, next))
-          return XML_ERROR_NO_MEMORY;
-        break;
-      case XML_TOK_COMMENT:
-        if (!reportComment(parser, enc, s, next))
-          return XML_ERROR_NO_MEMORY;
-        break;
-      }
-      break;
-    }
-    if (defaultHandler) {
-      switch (tok) {
-      case XML_TOK_PI:
-      case XML_TOK_COMMENT:
-      case XML_TOK_BOM:
-      case XML_TOK_XML_DECL:
-#ifdef XML_DTD
-      case XML_TOK_IGNORE_SECT:
-#endif /* XML_DTD */
-      case XML_TOK_PARAM_ENTITY_REF:
-        break;
-      default:
-#ifdef XML_DTD
-        if (role != XML_ROLE_IGNORE_SECT)
-#endif /* XML_DTD */
-          reportDefault(parser, enc, s, next);
-      }
-    }
-    s = next;
-    tok = XmlPrologTok(enc, s, end, &next);
-  }
-  /* not reached */
-}
-
-static
-enum XML_Error epilogProcessor(XML_Parser parser,
-                               const char *s,
-                               const char *end,
-                               const char **nextPtr)
-{
-  processor = epilogProcessor;
-  eventPtr = s;
-  for (;;) {
-    const char *next;
-    int tok = XmlPrologTok(encoding, s, end, &next);
-    eventEndPtr = next;
-    switch (tok) {
-    case -XML_TOK_PROLOG_S:
-      if (defaultHandler) {
-        eventEndPtr = end;
-        reportDefault(parser, encoding, s, end);
-      }
-      /* fall through */
-    case XML_TOK_NONE:
-      if (nextPtr)
-        *nextPtr = end;
-      return XML_ERROR_NONE;
-    case XML_TOK_PROLOG_S:
-      if (defaultHandler)
-        reportDefault(parser, encoding, s, next);
-      break;
-    case XML_TOK_PI:
-      if (!reportProcessingInstruction(parser, encoding, s, next))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_TOK_COMMENT:
-      if (!reportComment(parser, encoding, s, next))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_TOK_INVALID:
-      eventPtr = next;
-      return XML_ERROR_INVALID_TOKEN;
-    case XML_TOK_PARTIAL:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_UNCLOSED_TOKEN;
-    case XML_TOK_PARTIAL_CHAR:
-      if (nextPtr) {
-        *nextPtr = s;
-        return XML_ERROR_NONE;
-      }
-      return XML_ERROR_PARTIAL_CHAR;
-    default:
-      return XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
-    }
-    eventPtr = s = next;
-  }
-}
-
-#ifdef XML_DTD
-
-static enum XML_Error
-processInternalParamEntity(XML_Parser parser, ENTITY *entity)
-{
-  const char *s, *end, *next;
-  int tok;
-  enum XML_Error result;
-  OPEN_INTERNAL_ENTITY openEntity;
-  entity->open = 1;
-  openEntity.next = openInternalEntities;
-  openInternalEntities = &openEntity;
-  openEntity.entity = entity;
-  openEntity.internalEventPtr = 0;
-  openEntity.internalEventEndPtr = 0;
-  s = (char *)entity->textPtr;
-  end = (char *)(entity->textPtr + entity->textLen);
-  tok = XmlPrologTok(internalEncoding, s, end, &next);
-  result = doProlog(parser, internalEncoding, s, end, tok, next, 0);
-  entity->open = 0;
-  openInternalEntities = openEntity.next;
-  return result;
-}
-
-#endif /* XML_DTD */
-
-static
-enum XML_Error errorProcessor(XML_Parser parser,
-                              const char *s,
-                              const char *end,
-                              const char **nextPtr)
-{
-  cmExpatUnused(s);
-  cmExpatUnused(end);
-  cmExpatUnused(nextPtr);
-  return errorCode;
-}
-
-static enum XML_Error
-storeAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata,
-                    const char *ptr, const char *end,
-                    STRING_POOL *pool)
-{
-  enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, end, pool);
-  if (result)
-    return result;
-  if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20)
-    poolChop(pool);
-  if (!poolAppendChar(pool, XML_T('\0')))
-    return XML_ERROR_NO_MEMORY;
-  return XML_ERROR_NONE;
-}
-
-static enum XML_Error
-appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata,
-                     const char *ptr, const char *end,
-                     STRING_POOL *pool)
-{
-  for (;;) {
-    const char *next;
-    int tok = XmlAttributeValueTok(enc, ptr, end, &next);
-    switch (tok) {
-    case XML_TOK_NONE:
-      return XML_ERROR_NONE;
-    case XML_TOK_INVALID:
-      if (enc == encoding)
-        eventPtr = next;
-      return XML_ERROR_INVALID_TOKEN;
-    case XML_TOK_PARTIAL:
-      if (enc == encoding)
-        eventPtr = ptr;
-      return XML_ERROR_INVALID_TOKEN;
-    case XML_TOK_CHAR_REF:
-      {
-        XML_Char buf[XML_ENCODE_MAX];
-        int i;
-        int n = XmlCharRefNumber(enc, ptr);
-        if (n < 0) {
-          if (enc == encoding)
-            eventPtr = ptr;
-          return XML_ERROR_BAD_CHAR_REF;
-        }
-        if (!isCdata
-            && n == 0x20 /* space */
-            && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
-          break;
-        n = XmlEncode(n, (ICHAR *)buf);
-        if (!n) {
-          if (enc == encoding)
-            eventPtr = ptr;
-          return XML_ERROR_BAD_CHAR_REF;
-        }
-        for (i = 0; i < n; i++) {
-          if (!poolAppendChar(pool, buf[i]))
-            return XML_ERROR_NO_MEMORY;
-        }
-      }
-      break;
-    case XML_TOK_DATA_CHARS:
-      if (!poolAppend(pool, enc, ptr, next))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_TOK_TRAILING_CR:
-      next = ptr + enc->minBytesPerChar;
-      /* fall through */
-    case XML_TOK_ATTRIBUTE_VALUE_S:
-    case XML_TOK_DATA_NEWLINE:
-      if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
-        break;
-      if (!poolAppendChar(pool, 0x20))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_TOK_ENTITY_REF:
-      {
-        const XML_Char *name;
-        ENTITY *entity;
-        XML_Char ch = XmlPredefinedEntityName(enc,
-                                              ptr + enc->minBytesPerChar,
-                                              next - enc->minBytesPerChar);
-        if (ch) {
-          if (!poolAppendChar(pool, ch))
-            return XML_ERROR_NO_MEMORY;
-          break;
-        }
-        name = poolStoreString(&temp2Pool, enc,
-                               ptr + enc->minBytesPerChar,
-                               next - enc->minBytesPerChar);
-        if (!name)
-          return XML_ERROR_NO_MEMORY;
-        entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0);
-        poolDiscard(&temp2Pool);
-        if (!entity) {
-          if (dtd.complete) {
-            if (enc == encoding)
-              eventPtr = ptr;
-            return XML_ERROR_UNDEFINED_ENTITY;
-          }
-        }
-        else if (entity->open) {
-          if (enc == encoding)
-            eventPtr = ptr;
-          return XML_ERROR_RECURSIVE_ENTITY_REF;
-        }
-        else if (entity->notation) {
-          if (enc == encoding)
-            eventPtr = ptr;
-          return XML_ERROR_BINARY_ENTITY_REF;
-        }
-        else if (!entity->textPtr) {
-          if (enc == encoding)
-            eventPtr = ptr;
-          return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
-        }
-        else {
-          enum XML_Error result;
-          const XML_Char *textEnd = entity->textPtr + entity->textLen;
-          entity->open = 1;
-          result = appendAttributeValue(parser, internalEncoding, isCdata, (char *)entity->textPtr, (char *)textEnd, pool);
-          entity->open = 0;
-          if (result)
-            return result;
-        }
-      }
-      break;
-    default:
-      if (enc == encoding)
-        eventPtr = ptr;
-      return XML_ERROR_UNEXPECTED_STATE;
-    }
-    ptr = next;
-  }
-  /* not reached */
-}
-
-static
-enum XML_Error storeEntityValue(XML_Parser parser,
-                                const ENCODING *enc,
-                                const char *entityTextPtr,
-                                const char *entityTextEnd)
-{
-  STRING_POOL *pool = &(dtd.pool);
-  for (;;) {
-    const char *next;
-    int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next);
-    switch (tok) {
-    case XML_TOK_PARAM_ENTITY_REF:
-#ifdef XML_DTD
-      if (parentParser || enc != encoding) {
-        enum XML_Error result;
-        const XML_Char *name;
-        ENTITY *entity;
-        name = poolStoreString(&tempPool, enc,
-                               entityTextPtr + enc->minBytesPerChar,
-                               next - enc->minBytesPerChar);
-        if (!name)
-          return XML_ERROR_NO_MEMORY;
-        entity = (ENTITY *)lookup(&dtd.paramEntities, name, 0);
-        poolDiscard(&tempPool);
-        if (!entity) {
-          if (enc == encoding)
-            eventPtr = entityTextPtr;
-          return XML_ERROR_UNDEFINED_ENTITY;
-        }
-        if (entity->open) {
-          if (enc == encoding)
-            eventPtr = entityTextPtr;
-          return XML_ERROR_RECURSIVE_ENTITY_REF;
-        }
-        if (entity->systemId) {
-          if (enc == encoding)
-            eventPtr = entityTextPtr;
-          return XML_ERROR_PARAM_ENTITY_REF;
-        }
-        entity->open = 1;
-        result = storeEntityValue(parser,
-                                  internalEncoding,
-                                  (char *)entity->textPtr,
-                                  (char *)(entity->textPtr + entity->textLen));
-        entity->open = 0;
-        if (result)
-          return result;
-        break;
-      }
-#endif /* XML_DTD */
-      eventPtr = entityTextPtr;
-      return XML_ERROR_SYNTAX;
-    case XML_TOK_NONE:
-      return XML_ERROR_NONE;
-    case XML_TOK_ENTITY_REF:
-    case XML_TOK_DATA_CHARS:
-      if (!poolAppend(pool, enc, entityTextPtr, next))
-        return XML_ERROR_NO_MEMORY;
-      break;
-    case XML_TOK_TRAILING_CR:
-      next = entityTextPtr + enc->minBytesPerChar;
-      /* fall through */
-    case XML_TOK_DATA_NEWLINE:
-      if (pool->end == pool->ptr && !poolGrow(pool))
-        return XML_ERROR_NO_MEMORY;
-      *(pool->ptr)++ = 0xA;
-      break;
-    case XML_TOK_CHAR_REF:
-      {
-        XML_Char buf[XML_ENCODE_MAX];
-        int i;
-        int n = XmlCharRefNumber(enc, entityTextPtr);
-        if (n < 0) {
-          if (enc == encoding)
-            eventPtr = entityTextPtr;
-          return XML_ERROR_BAD_CHAR_REF;
-        }
-        n = XmlEncode(n, (ICHAR *)buf);
-        if (!n) {
-          if (enc == encoding)
-            eventPtr = entityTextPtr;
-          return XML_ERROR_BAD_CHAR_REF;
-        }
-        for (i = 0; i < n; i++) {
-          if (pool->end == pool->ptr && !poolGrow(pool))
-            return XML_ERROR_NO_MEMORY;
-          *(pool->ptr)++ = buf[i];
-        }
-      }
-      break;
-    case XML_TOK_PARTIAL:
-      if (enc == encoding)
-        eventPtr = entityTextPtr;
-      return XML_ERROR_INVALID_TOKEN;
-    case XML_TOK_INVALID:
-      if (enc == encoding)
-        eventPtr = next;
-      return XML_ERROR_INVALID_TOKEN;
-    default:
-      if (enc == encoding)
-        eventPtr = entityTextPtr;
-      return XML_ERROR_UNEXPECTED_STATE;
-    }
-    entityTextPtr = next;
-  }
-  /* not reached */
-}
-
-static void
-normalizeLines(XML_Char *s)
-{
-  XML_Char *p;
-  for (;; s++) {
-    if (*s == XML_T('\0'))
-      return;
-    if (*s == 0xD)
-      break;
-  }
-  p = s;
-  do {
-    if (*s == 0xD) {
-      *p++ = 0xA;
-      if (*++s == 0xA)
-        s++;
-    }
-    else
-      *p++ = *s++;
-  } while (*s);
-  *p = XML_T('\0');
-}
-
-static int
-reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, const char *start, const char *end)
-{
-  const XML_Char *target;
-  XML_Char *data;
-  const char *tem;
-  if (!processingInstructionHandler) {
-    if (defaultHandler)
-      reportDefault(parser, enc, start, end);
-    return 1;
-  }
-  start += enc->minBytesPerChar * 2;
-  tem = start + XmlNameLength(enc, start);
-  target = poolStoreString(&tempPool, enc, start, tem);
-  if (!target)
-    return 0;
-  poolFinish(&tempPool);
-  data = poolStoreString(&tempPool, enc,
-                        XmlSkipS(enc, tem),
-                        end - enc->minBytesPerChar*2);
-  if (!data)
-    return 0;
-  normalizeLines(data);
-  processingInstructionHandler(handlerArg, target, data);
-  poolClear(&tempPool);
-  return 1;
-}
-
-static int
-reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end)
-{
-  XML_Char *data;
-  if (!commentHandler) {
-    if (defaultHandler)
-      reportDefault(parser, enc, start, end);
-    return 1;
-  }
-  data = poolStoreString(&tempPool,
-                         enc,
-                         start + enc->minBytesPerChar * 4, 
-                         end - enc->minBytesPerChar * 3);
-  if (!data)
-    return 0;
-  normalizeLines(data);
-  commentHandler(handlerArg, data);
-  poolClear(&tempPool);
-  return 1;
-}
-
-static void
-reportDefault(XML_Parser parser, const ENCODING *enc, const char *s, const char *end)
-{
-  if (MUST_CONVERT(enc, s)) {
-    const char **eventPP;
-    const char **eventEndPP;
-    if (enc == encoding) {
-      eventPP = &eventPtr;
-      eventEndPP = &eventEndPtr;
-    }
-    else {
-      eventPP = &(openInternalEntities->internalEventPtr);
-      eventEndPP = &(openInternalEntities->internalEventEndPtr);
-    }
-    do {
-      ICHAR *dataPtr = (ICHAR *)dataBuf;
-      XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
-      *eventEndPP = s;
-      defaultHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
-      *eventPP = s;
-    } while (s != end);
-  }
-  else
-    defaultHandler(handlerArg, (XML_Char *)s, (XML_Char *)end - (XML_Char *)s);
-}
-
-
-static int
-defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata,
-                int isId, const XML_Char *value, XML_Parser parser)
-{
-  DEFAULT_ATTRIBUTE *att;
-  if (value || isId) {
-    /* The handling of default attributes gets messed up if we have
-       a default which duplicates a non-default. */
-    int i;
-    for (i = 0; i < type->nDefaultAtts; i++)
-      if (attId == type->defaultAtts[i].id)
-        return 1;
-    if (isId && !type->idAtt && !attId->xmlns)
-      type->idAtt = attId;
-  }
-  if (type->nDefaultAtts == type->allocDefaultAtts) {
-    if (type->allocDefaultAtts == 0) {
-      type->allocDefaultAtts = 8;
-      type->defaultAtts = MALLOC(type->allocDefaultAtts*sizeof(DEFAULT_ATTRIBUTE));
-    }
-    else {
-      type->allocDefaultAtts *= 2;
-      type->defaultAtts = REALLOC(type->defaultAtts,
-                                  type->allocDefaultAtts*sizeof(DEFAULT_ATTRIBUTE));
-    }
-    if (!type->defaultAtts)
-      return 0;
-  }
-  att = type->defaultAtts + type->nDefaultAtts;
-  att->id = attId;
-  att->value = value;
-  att->isCdata = isCdata;
-  if (!isCdata)
-    attId->maybeTokenized = 1;
-  type->nDefaultAtts += 1;
-  return 1;
-}
-
-static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType)
-{
-  const XML_Char *name;
-  for (name = elementType->name; *name; name++) {
-    if (*name == XML_T(':')) {
-      PREFIX *prefix;
-      const XML_Char *s;
-      for (s = elementType->name; s != name; s++) {
-        if (!poolAppendChar(&dtd.pool, *s))
-          return 0;
-      }
-      if (!poolAppendChar(&dtd.pool, XML_T('\0')))
-        return 0;
-      prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), sizeof(PREFIX));
-      if (!prefix)
-        return 0;
-      if (prefix->name == poolStart(&dtd.pool))
-        poolFinish(&dtd.pool);
-      else
-        poolDiscard(&dtd.pool);
-      elementType->prefix = prefix;
-
-    }
-  }
-  return 1;
-}
-
-static ATTRIBUTE_ID *
-getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end)
-{
-  ATTRIBUTE_ID *id;
-  const XML_Char *name;
-  if (!poolAppendChar(&dtd.pool, XML_T('\0')))
-    return 0;
-  name = poolStoreString(&dtd.pool, enc, start, end);
-  if (!name)
-    return 0;
-  ++name;
-  id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, name, sizeof(ATTRIBUTE_ID));
-  if (!id)
-    return 0;
-  if (id->name != name)
-    poolDiscard(&dtd.pool);
-  else {
-    poolFinish(&dtd.pool);
-    if (!ns)
-      ;
-    else if (name[0] == 'x'
-        && name[1] == 'm'
-        && name[2] == 'l'
-        && name[3] == 'n'
-        && name[4] == 's'
-        && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) {
-      if (name[5] == '\0')
-        id->prefix = &dtd.defaultPrefix;
-      else
-        id->prefix = (PREFIX *)lookup(&dtd.prefixes, name + 6, sizeof(PREFIX));
-      id->xmlns = 1;
-    }
-    else {
-      int i;
-      for (i = 0; name[i]; i++) {
-        if (name[i] == XML_T(':')) {
-          int j;
-          for (j = 0; j < i; j++) {
-            if (!poolAppendChar(&dtd.pool, name[j]))
-              return 0;
-          }
-          if (!poolAppendChar(&dtd.pool, XML_T('\0')))
-            return 0;
-          id->prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), sizeof(PREFIX));
-          if (id->prefix->name == poolStart(&dtd.pool))
-            poolFinish(&dtd.pool);
-          else
-            poolDiscard(&dtd.pool);
-          break;
-        }
-      }
-    }
-  }
-  return id;
-}
-
-#define CONTEXT_SEP XML_T('\f')
-
-static
-const XML_Char *getContext(XML_Parser parser)
-{
-  HASH_TABLE_ITER iter;
-  int needSep = 0;
-
-  if (dtd.defaultPrefix.binding) {
-    int i;
-    int len;
-    if (!poolAppendChar(&tempPool, XML_T('=')))
-      return 0;
-    len = dtd.defaultPrefix.binding->uriLen;
-    if (namespaceSeparator != XML_T('\0'))
-      len--;
-    for (i = 0; i < len; i++)
-      if (!poolAppendChar(&tempPool, dtd.defaultPrefix.binding->uri[i]))
-        return 0;
-    needSep = 1;
-  }
-
-  hashTableIterInit(&iter, &(dtd.prefixes));
-  for (;;) {
-    int i;
-    int len;
-    const XML_Char *s;
-    PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter);
-    if (!prefix)
-      break;
-    if (!prefix->binding)
-      continue;
-    if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
-      return 0;
-    for (s = prefix->name; *s; s++)
-      if (!poolAppendChar(&tempPool, *s))
-        return 0;
-    if (!poolAppendChar(&tempPool, XML_T('=')))
-      return 0;
-    len = prefix->binding->uriLen;
-    if (namespaceSeparator != XML_T('\0'))
-      len--;
-    for (i = 0; i < len; i++)
-      if (!poolAppendChar(&tempPool, prefix->binding->uri[i]))
-        return 0;
-    needSep = 1;
-  }
-
-
-  hashTableIterInit(&iter, &(dtd.generalEntities));
-  for (;;) {
-    const XML_Char *s;
-    ENTITY *e = (ENTITY *)hashTableIterNext(&iter);
-    if (!e)
-      break;
-    if (!e->open)
-      continue;
-    if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
-      return 0;
-    for (s = e->name; *s; s++)
-      if (!poolAppendChar(&tempPool, *s))
-        return 0;
-    needSep = 1;
-  }
-
-  if (!poolAppendChar(&tempPool, XML_T('\0')))
-    return 0;
-  return tempPool.start;
-}
-
-static
-int setContext(XML_Parser parser, const XML_Char *context)
-{
-  const XML_Char *s = context;
-
-  while (*context != XML_T('\0')) {
-    if (*s == CONTEXT_SEP || *s == XML_T('\0')) {
-      ENTITY *e;
-      if (!poolAppendChar(&tempPool, XML_T('\0')))
-        return 0;
-      e = (ENTITY *)lookup(&dtd.generalEntities, poolStart(&tempPool), 0);
-      if (e)
-        e->open = 1;
-      if (*s != XML_T('\0'))
-        s++;
-      context = s;
-      poolDiscard(&tempPool);
-    }
-    else if (*s == '=') {
-      PREFIX *prefix;
-      if (poolLength(&tempPool) == 0)
-        prefix = &dtd.defaultPrefix;
-      else {
-        if (!poolAppendChar(&tempPool, XML_T('\0')))
-          return 0;
-        prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&tempPool), sizeof(PREFIX));
-        if (!prefix)
-          return 0;
-        if (prefix->name == poolStart(&tempPool)) {
-          prefix->name = poolCopyString(&dtd.pool, prefix->name);
-          if (!prefix->name)
-            return 0;
-        }
-        poolDiscard(&tempPool);
-      }
-      for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0'); context++)
-        if (!poolAppendChar(&tempPool, *context))
-          return 0;
-      if (!poolAppendChar(&tempPool, XML_T('\0')))
-        return 0;
-      if (!addBinding(parser, prefix, 0, poolStart(&tempPool), &inheritedBindings))
-        return 0;
-      poolDiscard(&tempPool);
-      if (*context != XML_T('\0'))
-        ++context;
-      s = context;
-    }
-    else {
-      if (!poolAppendChar(&tempPool, *s))
-        return 0;
-      s++;
-    }
-  }
-  return 1;
-}
-
-
-static
-void normalizePublicId(XML_Char *publicId)
-{
-  XML_Char *p = publicId;
-  XML_Char *s;
-  for (s = publicId; *s; s++) {
-    switch (*s) {
-    case 0x20:
-    case 0xD:
-    case 0xA:
-      if (p != publicId && p[-1] != 0x20)
-        *p++ = 0x20;
-      break;
-    default:
-      *p++ = *s;
-    }
-  }
-  if (p != publicId && p[-1] == 0x20)
-    --p;
-  *p = XML_T('\0');
-}
-
-static int dtdInit(DTD *p, XML_Parser parser)
-{
-  XML_Memory_Handling_Suite *ms = &((Parser *) parser)->m_mem; 
-  poolInit(&(p->pool), ms);
-  hashTableInit(&(p->generalEntities), ms);
-  hashTableInit(&(p->elementTypes), ms);
-  hashTableInit(&(p->attributeIds), ms);
-  hashTableInit(&(p->prefixes), ms);
-  p->complete = 1;
-  p->standalone = 0;
-#ifdef XML_DTD
-  hashTableInit(&(p->paramEntities), ms);
-#endif /* XML_DTD */
-  p->defaultPrefix.name = 0;
-  p->defaultPrefix.binding = 0;
-
-  p->in_eldecl = 0;
-  p->scaffIndex = 0;
-  p->scaffLevel = 0;
-  p->scaffold = 0;
-  p->contentStringLen = 0;
-  p->scaffSize = 0;
-  p->scaffCount = 0;
-
-  return 1;
-}
-
-#ifdef XML_DTD
-
-static void dtdSwap(DTD *p1, DTD *p2)
-{
-  DTD tem;
-  memcpy(&tem, p1, sizeof(DTD));
-  memcpy(p1, p2, sizeof(DTD));
-  memcpy(p2, &tem, sizeof(DTD));
-}
-
-#endif /* XML_DTD */
-
-static void dtdDestroy(DTD *p, XML_Parser parser)
-{
-  HASH_TABLE_ITER iter;
-  hashTableIterInit(&iter, &(p->elementTypes));
-  for (;;) {
-    ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);
-    if (!e)
-      break;
-    if (e->allocDefaultAtts != 0)
-      FREE(e->defaultAtts);
-  }
-  hashTableDestroy(&(p->generalEntities));
-#ifdef XML_DTD
-  hashTableDestroy(&(p->paramEntities));
-#endif /* XML_DTD */
-  hashTableDestroy(&(p->elementTypes));
-  hashTableDestroy(&(p->attributeIds));
-  hashTableDestroy(&(p->prefixes));
-  poolDestroy(&(p->pool));
-  if (p->scaffIndex)
-    FREE(p->scaffIndex);
-  if (p->scaffold)
-    FREE(p->scaffold);
-}
-
-/* Do a deep copy of the DTD.  Return 0 for out of memory; non-zero otherwise.
-The new DTD has already been initialized. */
-
-static int dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser)
-{
-  HASH_TABLE_ITER iter;
-
-  /* Copy the prefix table. */
-
-  hashTableIterInit(&iter, &(oldDtd->prefixes));
-  for (;;) {
-    const XML_Char *name;
-    const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter);
-    if (!oldP)
-      break;
-    name = poolCopyString(&(newDtd->pool), oldP->name);
-    if (!name)
-      return 0;
-    if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX)))
-      return 0;
-  }
-
-  hashTableIterInit(&iter, &(oldDtd->attributeIds));
-
-  /* Copy the attribute id table. */
-
-  for (;;) {
-    ATTRIBUTE_ID *newA;
-    const XML_Char *name;
-    const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter);
-
-    if (!oldA)
-      break;
-    /* Remember to allocate the scratch byte before the name. */
-    if (!poolAppendChar(&(newDtd->pool), XML_T('\0')))
-      return 0;
-    name = poolCopyString(&(newDtd->pool), oldA->name);
-    if (!name)
-      return 0;
-    ++name;
-    newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, sizeof(ATTRIBUTE_ID));
-    if (!newA)
-      return 0;
-    newA->maybeTokenized = oldA->maybeTokenized;
-    if (oldA->prefix) {
-      newA->xmlns = oldA->xmlns;
-      if (oldA->prefix == &oldDtd->defaultPrefix)
-        newA->prefix = &newDtd->defaultPrefix;
-      else
-        newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldA->prefix->name, 0);
-    }
-  }
-
-  /* Copy the element type table. */
-
-  hashTableIterInit(&iter, &(oldDtd->elementTypes));
-
-  for (;;) {
-    int i;
-    ELEMENT_TYPE *newE;
-    const XML_Char *name;
-    const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter);
-    if (!oldE)
-      break;
-    name = poolCopyString(&(newDtd->pool), oldE->name);
-    if (!name)
-      return 0;
-    newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, sizeof(ELEMENT_TYPE));
-    if (!newE)
-      return 0;
-    if (oldE->nDefaultAtts) {
-      newE->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
-      if (!newE->defaultAtts)
-        return 0;
-    }
-    if (oldE->idAtt)
-      newE->idAtt = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), oldE->idAtt->name, 0);
-    newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts;
-    if (oldE->prefix)
-      newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldE->prefix->name, 0);
-    for (i = 0; i < newE->nDefaultAtts; i++) {
-      newE->defaultAtts[i].id = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0);
-      newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata;
-      if (oldE->defaultAtts[i].value) {
-        newE->defaultAtts[i].value = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value);
-        if (!newE->defaultAtts[i].value)
-          return 0;
-      }
-      else
-        newE->defaultAtts[i].value = 0;
-    }
-  }
-
-  /* Copy the entity tables. */
-  if (!copyEntityTable(&(newDtd->generalEntities),
-                       &(newDtd->pool),
-                       &(oldDtd->generalEntities), parser))
-      return 0;
-
-#ifdef XML_DTD
-  if (!copyEntityTable(&(newDtd->paramEntities),
-                       &(newDtd->pool),
-                       &(oldDtd->paramEntities), parser))
-      return 0;
-#endif /* XML_DTD */
-
-  newDtd->complete = oldDtd->complete;
-  newDtd->standalone = oldDtd->standalone;
-
-  /* Don't want deep copying for scaffolding */
-  newDtd->in_eldecl = oldDtd->in_eldecl;
-  newDtd->scaffold = oldDtd->scaffold;
-  newDtd->contentStringLen = oldDtd->contentStringLen;
-  newDtd->scaffSize = oldDtd->scaffSize;
-  newDtd->scaffLevel = oldDtd->scaffLevel;
-  newDtd->scaffIndex = oldDtd->scaffIndex;
-
-  return 1;
-}  /* End dtdCopy */
-
-static int copyEntityTable(HASH_TABLE *newTable,
-                           STRING_POOL *newPool,
-                           const HASH_TABLE *oldTable,
-                           XML_Parser parser)
-{
-  HASH_TABLE_ITER iter;
-  const XML_Char *cachedOldBase = 0;
-  const XML_Char *cachedNewBase = 0;
-  cmExpatUnused(parser);
-
-  hashTableIterInit(&iter, oldTable);
-
-  for (;;) {
-    ENTITY *newE;
-    const XML_Char *name;
-    const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter);
-    if (!oldE)
-      break;
-    name = poolCopyString(newPool, oldE->name);
-    if (!name)
-      return 0;
-    newE = (ENTITY *)lookup(newTable, name, sizeof(ENTITY));
-    if (!newE)
-      return 0;
-    if (oldE->systemId) {
-      const XML_Char *tem = poolCopyString(newPool, oldE->systemId);
-      if (!tem)
-        return 0;
-      newE->systemId = tem;
-      if (oldE->base) {
-        if (oldE->base == cachedOldBase)
-          newE->base = cachedNewBase;
-        else {
-          cachedOldBase = oldE->base;
-          tem = poolCopyString(newPool, cachedOldBase);
-          if (!tem)
-            return 0;
-          cachedNewBase = newE->base = tem;
-        }
-      }
-    }
-    else {
-      const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, oldE->textLen);
-      if (!tem)
-        return 0;
-      newE->textPtr = tem;
-      newE->textLen = oldE->textLen;
-    }
-    if (oldE->notation) {
-      const XML_Char *tem = poolCopyString(newPool, oldE->notation);
-      if (!tem)
-        return 0;
-      newE->notation = tem;
-    }
-  }
-  return 1;
-}
-
-#define INIT_SIZE 64
-
-static
-int keyeq(KEY s1, KEY s2)
-{
-  for (; *s1 == *s2; s1++, s2++)
-    if (*s1 == 0)
-      return 1;
-  return 0;
-}
-
-static
-unsigned long hash(KEY s)
-{
-  unsigned long h = 0;
-  while (*s)
-    h = (h << 5) + h + (unsigned char)*s++;
-  return h;
-}
-
-static
-NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize)
-{
-  size_t i;
-  if (table->size == 0) {
-    size_t tsize;
-
-    if (!createSize)
-      return 0;
-    tsize = INIT_SIZE * sizeof(NAMED *);
-    table->v = table->mem->malloc_fcn(tsize);
-    if (!table->v)
-      return 0;
-    memset(table->v, 0, tsize);
-    table->size = INIT_SIZE;
-    table->usedLim = INIT_SIZE / 2;
-    i = hash(name) & (table->size - 1);
-  }
-  else {
-    unsigned long h = hash(name);
-    for (i = h & (table->size - 1);
-         table->v[i];
-         i == 0 ? i = table->size - 1 : --i) {
-      if (keyeq(name, table->v[i]->name))
-        return table->v[i];
-    }
-    if (!createSize)
-      return 0;
-    if (table->used == table->usedLim) {
-      /* check for overflow */
-      size_t newSize = table->size * 2;
-      size_t tsize = newSize * sizeof(NAMED *);
-      NAMED **newV = table->mem->malloc_fcn(tsize);
-      if (!newV)
-        return 0;
-      memset(newV, 0, tsize);
-      for (i = 0; i < table->size; i++)
-        if (table->v[i]) {
-          size_t j;
-          for (j = hash(table->v[i]->name) & (newSize - 1);
-               newV[j];
-               j == 0 ? j = newSize - 1 : --j)
-            ;
-          newV[j] = table->v[i];
-        }
-      table->mem->free_fcn(table->v);
-      table->v = newV;
-      table->size = newSize;
-      table->usedLim = newSize/2;
-      for (i = h & (table->size - 1);
-           table->v[i];
-           i == 0 ? i = table->size - 1 : --i)
-        ;
-    }
-  }
-  table->v[i] = table->mem->malloc_fcn(createSize);
-  if (!table->v[i])
-    return 0;
-  memset(table->v[i], 0, createSize);
-  table->v[i]->name = name;
-  (table->used)++;
-  return table->v[i];
-}
-
-static
-void hashTableDestroy(HASH_TABLE *table)
-{
-  size_t i;
-  for (i = 0; i < table->size; i++) {
-    NAMED *p = table->v[i];
-    if (p)
-      table->mem->free_fcn(p);
-  }
-  if (table->v)
-    table->mem->free_fcn(table->v);
-}
-
-static
-void hashTableInit(HASH_TABLE *p, XML_Memory_Handling_Suite *ms)
-{
-  p->size = 0;
-  p->usedLim = 0;
-  p->used = 0;
-  p->v = 0;
-  p->mem = ms;
-}
-
-static
-void hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
-{
-  iter->p = table->v;
-  iter->end = iter->p + table->size;
-}
-
-static
-NAMED *hashTableIterNext(HASH_TABLE_ITER *iter)
-{
-  while (iter->p != iter->end) {
-    NAMED *tem = *(iter->p)++;
-    if (tem)
-      return tem;
-  }
-  return 0;
-}
-
-
-static
-void poolInit(STRING_POOL *pool, XML_Memory_Handling_Suite *ms)
-{
-  pool->blocks = 0;
-  pool->freeBlocks = 0;
-  pool->start = 0;
-  pool->ptr = 0;
-  pool->end = 0;
-  pool->mem = ms;
-}
-
-static
-void poolClear(STRING_POOL *pool)
-{
-  if (!pool->freeBlocks)
-    pool->freeBlocks = pool->blocks;
-  else {
-    BLOCK *p = pool->blocks;
-    while (p) {
-      BLOCK *tem = p->next;
-      p->next = pool->freeBlocks;
-      pool->freeBlocks = p;
-      p = tem;
-    }
-  }
-  pool->blocks = 0;
-  pool->start = 0;
-  pool->ptr = 0;
-  pool->end = 0;
-}
-
-static
-void poolDestroy(STRING_POOL *pool)
-{
-  BLOCK *p = pool->blocks;
-  while (p) {
-    BLOCK *tem = p->next;
-    pool->mem->free_fcn(p);
-    p = tem;
-  }
-  pool->blocks = 0;
-  p = pool->freeBlocks;
-  while (p) {
-    BLOCK *tem = p->next;
-    pool->mem->free_fcn(p);
-    p = tem;
-  }
-  pool->freeBlocks = 0;
-  pool->ptr = 0;
-  pool->start = 0;
-  pool->end = 0;
-}
-
-static
-XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
-                     const char *ptr, const char *end)
-{
-  if (!pool->ptr && !poolGrow(pool))
-    return 0;
-  for (;;) {
-    XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end);
-    if (ptr == end)
-      break;
-    if (!poolGrow(pool))
-      return 0;
-  }
-  return pool->start;
-}
-
-static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s)
-{
-  do {
-    if (!poolAppendChar(pool, *s))
-      return 0;
-  } while (*s++);
-  s = pool->start;
-  poolFinish(pool);
-  return s;
-}
-
-static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n)
-{
-  if (!pool->ptr && !poolGrow(pool))
-    return 0;
-  for (; n > 0; --n, s++) {
-    if (!poolAppendChar(pool, *s))
-      return 0;
-
-  }
-  s = pool->start;
-  poolFinish(pool);
-  return s;
-}
-
-static
-const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s)
-{
-  while (*s) {
-    if (!poolAppendChar(pool, *s))
-      return 0;
-    s++;
-  } 
-  return pool->start;
-}  /* End poolAppendString */
-
-static
-XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
-                          const char *ptr, const char *end)
-{
-  if (!poolAppend(pool, enc, ptr, end))
-    return 0;
-  if (pool->ptr == pool->end && !poolGrow(pool))
-    return 0;
-  *(pool->ptr)++ = 0;
-  return pool->start;
-}
-
-static
-int poolGrow(STRING_POOL *pool)
-{
-  if (pool->freeBlocks) {
-    if (pool->start == 0) {
-      pool->blocks = pool->freeBlocks;
-      pool->freeBlocks = pool->freeBlocks->next;
-      pool->blocks->next = 0;
-      pool->start = pool->blocks->s;
-      pool->end = pool->start + pool->blocks->size;
-      pool->ptr = pool->start;
-      return 1;
-    }
-    if (pool->end - pool->start < pool->freeBlocks->size) {
-      BLOCK *tem = pool->freeBlocks->next;
-      pool->freeBlocks->next = pool->blocks;
-      pool->blocks = pool->freeBlocks;
-      pool->freeBlocks = tem;
-      memcpy(pool->blocks->s, pool->start, (pool->end - pool->start) * sizeof(XML_Char));
-      pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
-      pool->start = pool->blocks->s;
-      pool->end = pool->start + pool->blocks->size;
-      return 1;
-    }
-  }
-  if (pool->blocks && pool->start == pool->blocks->s) {
-    int blockSize = (pool->end - pool->start)*2;
-    pool->blocks = pool->mem->realloc_fcn(pool->blocks, offsetof(BLOCK, s) + blockSize * sizeof(XML_Char));
-    if (!pool->blocks)
-      return 0;
-    pool->blocks->size = blockSize;
-    pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
-    pool->start = pool->blocks->s;
-    pool->end = pool->start + blockSize;
-  }
-  else {
-    BLOCK *tem;
-    int blockSize = pool->end - pool->start;
-    if (blockSize < INIT_BLOCK_SIZE)
-      blockSize = INIT_BLOCK_SIZE;
-    else
-      blockSize *= 2;
-    tem = pool->mem->malloc_fcn(offsetof(BLOCK, s) + blockSize * sizeof(XML_Char));
-    if (!tem)
-      return 0;
-    tem->size = blockSize;
-    tem->next = pool->blocks;
-    pool->blocks = tem;
-    if (pool->ptr != pool->start)
-      memcpy(tem->s, pool->start, (pool->ptr - pool->start) * sizeof(XML_Char));
-    pool->ptr = tem->s + (pool->ptr - pool->start);
-    pool->start = tem->s;
-    pool->end = tem->s + blockSize;
-  }
-  return 1;
-}
-
-static int
-nextScaffoldPart(XML_Parser parser)
-{
-  CONTENT_SCAFFOLD * me;
-  int next;
-
-  if (! dtd.scaffIndex) {
-    dtd.scaffIndex = MALLOC(groupSize * sizeof(int));
-    if (! dtd.scaffIndex)
-      return -1;
-    dtd.scaffIndex[0] = 0;
-  }
-
-  if (dtd.scaffCount >= dtd.scaffSize) {
-    if (dtd.scaffold) {
-      dtd.scaffSize *= 2;
-      dtd.scaffold = (CONTENT_SCAFFOLD *) REALLOC(dtd.scaffold,
-                                              dtd.scaffSize * sizeof(CONTENT_SCAFFOLD));
-    }
-    else {
-      dtd.scaffSize = 32;
-      dtd.scaffold = (CONTENT_SCAFFOLD *) MALLOC(dtd.scaffSize * sizeof(CONTENT_SCAFFOLD));
-    }
-    if (! dtd.scaffold)
-      return -1;
-  }
-  next = dtd.scaffCount++;
-  me = &dtd.scaffold[next];
-  if (dtd.scaffLevel) { 
-    CONTENT_SCAFFOLD *parent = &dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]];
-    if (parent->lastchild) {
-      dtd.scaffold[parent->lastchild].nextsib = next;
-    }
-    if (! parent->childcnt)
-      parent->firstchild = next;
-    parent->lastchild = next;
-    parent->childcnt++;
-  }
-  me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0;
-  return next;
-}  /* End nextScaffoldPart */
-
-static void
-build_node (XML_Parser parser,
-            int src_node,
-            XML_Content *dest,
-            XML_Content **contpos,
-            char **strpos)
-{
-  dest->type = dtd.scaffold[src_node].type;
-  dest->quant = dtd.scaffold[src_node].quant;
-  if (dest->type == XML_CTYPE_NAME) {
-    const char *src;
-    dest->name = *strpos;
-    src = dtd.scaffold[src_node].name;
-    for (;;) {
-      *(*strpos)++ = *src;
-      if (! *src)
-        break;
-      src++;
-    }
-    dest->numchildren = 0;
-    dest->children = 0;
-  }
-  else {
-    unsigned int i;
-    int cn;
-    dest->numchildren = dtd.scaffold[src_node].childcnt;
-    dest->children = *contpos;
-    *contpos += dest->numchildren;
-    for (i = 0, cn = dtd.scaffold[src_node].firstchild;
-         i < dest->numchildren;
-         i++, cn = dtd.scaffold[cn].nextsib) {
-      build_node(parser, cn, &(dest->children[i]), contpos, strpos);
-    }
-    dest->name = 0;
-  }
-}  /* End build_node */
-
-static XML_Content *
-build_model (XML_Parser parser)
-{
-  XML_Content *ret;
-  XML_Content *cpos;
-  char * str;
-  int allocsize = dtd.scaffCount * sizeof(XML_Content) + dtd.contentStringLen;
-  
-  ret = MALLOC(allocsize);
-  if (! ret)
-    return 0;
-
-  str =  (char *) (&ret[dtd.scaffCount]);
-  cpos = &ret[1];
-
-  build_node(parser, 0, ret, &cpos, &str);
-  return ret;
-}  /* End build_model */
-
-static ELEMENT_TYPE *
-getElementType(XML_Parser parser,
-               const ENCODING *enc,
-               const char *ptr,
-               const char *end)
-{
-  const XML_Char *name = poolStoreString(&dtd.pool, enc, ptr, end);
-  ELEMENT_TYPE *ret;
-
-  if (! name)
-    return 0;
-  ret = (ELEMENT_TYPE *) lookup(&dtd.elementTypes, name, sizeof(ELEMENT_TYPE));
-  if (! ret)
-    return 0;
-  if (ret->name != name)
-    poolDiscard(&dtd.pool);
-  else {
-    poolFinish(&dtd.pool);
-    if (!setElementTypePrefix(parser, ret))
-      return 0;
-  }
-  return ret;
-}  /* End getElementType */
diff --git a/Utilities/cmexpat/xmlrole.c b/Utilities/cmexpat/xmlrole.c
deleted file mode 100644
index 289964c..0000000
--- a/Utilities/cmexpat/xmlrole.c
+++ /dev/null
@@ -1,1401 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-static char RCSId[]
-  = "$Header$";
-const char* cm_expat_GetXMLRole_RCSId()
-{
-  /* Avoid warning about unused static without removing RCSId from original. */
-  return RCSId;
-}
-
-#include <cmexpat/expatConfig.h>
-
-#include "xmlrole.h"
-#include "ascii.h"
-
-/* Doesn't check:
-
- that ,| are not mixed in a model group
- content of literals
-
-*/
-
-static const char KW_ANY[] = { ASCII_A, ASCII_N, ASCII_Y, '\0' };
-static const char KW_ATTLIST[] = { ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' };
-static const char KW_CDATA[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
-static const char KW_DOCTYPE[] = { ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' };
-static const char KW_ELEMENT[] = { ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' };
-static const char KW_EMPTY[] = { ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' };
-static const char KW_ENTITIES[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' };
-static const char KW_ENTITY[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
-static const char KW_FIXED[] = { ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' };
-static const char KW_ID[] = { ASCII_I, ASCII_D, '\0' };
-static const char KW_IDREF[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
-static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
-static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
-static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
-static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
-static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
-static const char KW_NMTOKEN[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
-static const char KW_NMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };
-static const char KW_NOTATION[] = { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, '\0' };
-static const char KW_PCDATA[] = { ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
-static const char KW_PUBLIC[] = { ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' };
-static const char KW_REQUIRED[] = { ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, '\0' };
-static const char KW_SYSTEM[] = { ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' };
-
-#ifndef MIN_BYTES_PER_CHAR
-#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
-#endif
-
-#ifdef XML_DTD
-#define setTopLevel(state) \
-  ((state)->handler = ((state)->documentEntity \
-                       ? internalSubset \
-                       : externalSubset1))
-#else /* not XML_DTD */
-#define setTopLevel(state) ((state)->handler = internalSubset)
-#endif /* not XML_DTD */
-
-typedef int PROLOG_HANDLER(PROLOG_STATE *state,
-                           int tok,
-                           const char *ptr,
-                           const char *end,
-                           const ENCODING *enc);
-
-static PROLOG_HANDLER
-  prolog0, prolog1, prolog2,
-  doctype0, doctype1, doctype2, doctype3, doctype4, doctype5,
-  internalSubset,
-  entity0, entity1, entity2, entity3, entity4, entity5, entity6,
-  entity7, entity8, entity9,
-  notation0, notation1, notation2, notation3, notation4,
-  attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6,
-  attlist7, attlist8, attlist9,
-  element0, element1, element2, element3, element4, element5, element6,
-  element7,
-#ifdef XML_DTD
-  externalSubset0, externalSubset1,
-  condSect0, condSect1, condSect2,
-#endif /* XML_DTD */
-  declClose,
-  error;
-
-static
-int common(PROLOG_STATE *state, int tok);
-
-static
-int prolog0(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    state->handler = prolog1;
-    return XML_ROLE_NONE;
-  case XML_TOK_XML_DECL:
-    state->handler = prolog1;
-    return XML_ROLE_XML_DECL;
-  case XML_TOK_PI:
-    state->handler = prolog1;
-    return XML_ROLE_NONE;
-  case XML_TOK_COMMENT:
-    state->handler = prolog1;
-  case XML_TOK_BOM:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_OPEN:
-    if (!XmlNameMatchesAscii(enc,
-                             ptr + 2 * MIN_BYTES_PER_CHAR(enc),
-                             end,
-                             KW_DOCTYPE))
-      break;
-    state->handler = doctype0;
-    return XML_ROLE_NONE;
-  case XML_TOK_INSTANCE_START:
-    state->handler = error;
-    return XML_ROLE_INSTANCE_START;
-  }
-  return common(state, tok);
-}
-
-static
-int prolog1(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_PI:
-  case XML_TOK_COMMENT:
-  case XML_TOK_BOM:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_OPEN:
-    if (!XmlNameMatchesAscii(enc,
-                             ptr + 2 * MIN_BYTES_PER_CHAR(enc),
-                             end,
-                             KW_DOCTYPE))
-      break;
-    state->handler = doctype0;
-    return XML_ROLE_NONE;
-  case XML_TOK_INSTANCE_START:
-    state->handler = error;
-    return XML_ROLE_INSTANCE_START;
-  }
-  return common(state, tok);
-}
-
-static
-int prolog2(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_PI:
-  case XML_TOK_COMMENT:
-    return XML_ROLE_NONE;
-  case XML_TOK_INSTANCE_START:
-    state->handler = error;
-    return XML_ROLE_INSTANCE_START;
-  }
-  return common(state, tok);
-}
-
-static
-int doctype0(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = doctype1;
-    return XML_ROLE_DOCTYPE_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int doctype1(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_OPEN_BRACKET:
-    state->handler = internalSubset;
-    return XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
-  case XML_TOK_DECL_CLOSE:
-    state->handler = prolog2;
-    return XML_ROLE_DOCTYPE_CLOSE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
-      state->handler = doctype3;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
-      state->handler = doctype2;
-      return XML_ROLE_NONE;
-    }
-    break;
-  }
-  return common(state, tok);
-}
-
-static
-int doctype2(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = doctype3;
-    return XML_ROLE_DOCTYPE_PUBLIC_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int doctype3(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = doctype4;
-    return XML_ROLE_DOCTYPE_SYSTEM_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int doctype4(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_OPEN_BRACKET:
-    state->handler = internalSubset;
-    return XML_ROLE_DOCTYPE_INTERNAL_SUBSET;
-  case XML_TOK_DECL_CLOSE:
-    state->handler = prolog2;
-    return XML_ROLE_DOCTYPE_CLOSE;
-  }
-  return common(state, tok);
-}
-
-static
-int doctype5(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_CLOSE:
-    state->handler = prolog2;
-    return XML_ROLE_DOCTYPE_CLOSE;
-  }
-  return common(state, tok);
-}
-
-static
-int internalSubset(PROLOG_STATE *state,
-                   int tok,
-                   const char *ptr,
-                   const char *end,
-                   const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_OPEN:
-    if (XmlNameMatchesAscii(enc,
-                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_ENTITY)) {
-      state->handler = entity0;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc,
-                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_ATTLIST)) {
-      state->handler = attlist0;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc,
-                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_ELEMENT)) {
-      state->handler = element0;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc,
-                            ptr + 2 * MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_NOTATION)) {
-      state->handler = notation0;
-      return XML_ROLE_NONE;
-    }
-    break;
-  case XML_TOK_PI:
-  case XML_TOK_COMMENT:
-    return XML_ROLE_NONE;
-  case XML_TOK_PARAM_ENTITY_REF:
-    return XML_ROLE_PARAM_ENTITY_REF;
-  case XML_TOK_CLOSE_BRACKET:
-    state->handler = doctype5;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-#ifdef XML_DTD
-
-static
-int externalSubset0(PROLOG_STATE *state,
-                    int tok,
-                    const char *ptr,
-                    const char *end,
-                    const ENCODING *enc)
-{
-  state->handler = externalSubset1;
-  if (tok == XML_TOK_XML_DECL)
-    return XML_ROLE_TEXT_DECL;
-  return externalSubset1(state, tok, ptr, end, enc);
-}
-
-static
-int externalSubset1(PROLOG_STATE *state,
-                    int tok,
-                    const char *ptr,
-                    const char *end,
-                    const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_COND_SECT_OPEN:
-    state->handler = condSect0;
-    return XML_ROLE_NONE;
-  case XML_TOK_COND_SECT_CLOSE:
-    if (state->includeLevel == 0)
-      break;
-    state->includeLevel -= 1;
-    return XML_ROLE_NONE;
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_CLOSE_BRACKET:
-    break;
-  case XML_TOK_NONE:
-    if (state->includeLevel)
-      break;
-    return XML_ROLE_NONE;
-  default:
-    return internalSubset(state, tok, ptr, end, enc);
-  }
-  return common(state, tok);
-}
-
-#endif /* XML_DTD */
-
-static
-int entity0(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_PERCENT:
-    state->handler = entity1;
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    state->handler = entity2;
-    return XML_ROLE_GENERAL_ENTITY_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int entity1(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    state->handler = entity7;
-    return XML_ROLE_PARAM_ENTITY_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int entity2(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
-      state->handler = entity4;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
-      state->handler = entity3;
-      return XML_ROLE_NONE;
-    }
-    break;
-  case XML_TOK_LITERAL:
-    state->handler = declClose;
-    return XML_ROLE_ENTITY_VALUE;
-  }
-  return common(state, tok);
-}
-
-static
-int entity3(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = entity4;
-    return XML_ROLE_ENTITY_PUBLIC_ID;
-  }
-  return common(state, tok);
-}
-
-
-static
-int entity4(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = entity5;
-    return XML_ROLE_ENTITY_SYSTEM_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int entity5(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_CLOSE:
-    setTopLevel(state);
-    return XML_ROLE_ENTITY_COMPLETE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) {
-      state->handler = entity6;
-      return XML_ROLE_NONE;
-    }
-    break;
-  }
-  return common(state, tok);
-}
-
-static
-int entity6(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    state->handler = declClose;
-    return XML_ROLE_ENTITY_NOTATION_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int entity7(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
-      state->handler = entity9;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
-      state->handler = entity8;
-      return XML_ROLE_NONE;
-    }
-    break;
-  case XML_TOK_LITERAL:
-    state->handler = declClose;
-    return XML_ROLE_ENTITY_VALUE;
-  }
-  return common(state, tok);
-}
-
-static
-int entity8(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = entity9;
-    return XML_ROLE_ENTITY_PUBLIC_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int entity9(PROLOG_STATE *state,
-            int tok,
-            const char *ptr,
-            const char *end,
-            const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = declClose;
-    return XML_ROLE_ENTITY_SYSTEM_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int notation0(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    state->handler = notation1;
-    return XML_ROLE_NOTATION_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int notation1(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
-      state->handler = notation3;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
-      state->handler = notation2;
-      return XML_ROLE_NONE;
-    }
-    break;
-  }
-  return common(state, tok);
-}
-
-static
-int notation2(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = notation4;
-    return XML_ROLE_NOTATION_PUBLIC_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int notation3(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = declClose;
-    return XML_ROLE_NOTATION_SYSTEM_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int notation4(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = declClose;
-    return XML_ROLE_NOTATION_SYSTEM_ID;
-  case XML_TOK_DECL_CLOSE:
-    setTopLevel(state);
-    return XML_ROLE_NOTATION_NO_SYSTEM_ID;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist0(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = attlist1;
-    return XML_ROLE_ATTLIST_ELEMENT_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist1(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_CLOSE:
-    setTopLevel(state);
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = attlist2;
-    return XML_ROLE_ATTRIBUTE_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist2(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    {
-      static const char *types[] = {
-        KW_CDATA,
-        KW_ID,
-        KW_IDREF,
-        KW_IDREFS,
-        KW_ENTITY,
-        KW_ENTITIES,
-        KW_NMTOKEN,
-        KW_NMTOKENS,
-      };
-      int i;
-      for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
-        if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
-          state->handler = attlist8;
-          return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
-        }
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) {
-      state->handler = attlist5;
-      return XML_ROLE_NONE;
-    }
-    break;
-  case XML_TOK_OPEN_PAREN:
-    state->handler = attlist3;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist3(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NMTOKEN:
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = attlist4;
-    return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist4(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_CLOSE_PAREN:
-    state->handler = attlist8;
-    return XML_ROLE_NONE;
-  case XML_TOK_OR:
-    state->handler = attlist3;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist5(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_OPEN_PAREN:
-    state->handler = attlist6;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-
-static
-int attlist6(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    state->handler = attlist7;
-    return XML_ROLE_ATTRIBUTE_NOTATION_VALUE;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist7(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_CLOSE_PAREN:
-    state->handler = attlist8;
-    return XML_ROLE_NONE;
-  case XML_TOK_OR:
-    state->handler = attlist6;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-/* default value */
-static
-int attlist8(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_POUND_NAME:
-    if (XmlNameMatchesAscii(enc,
-                            ptr + MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_IMPLIED)) {
-      state->handler = attlist1;
-      return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
-    }
-    if (XmlNameMatchesAscii(enc,
-                            ptr + MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_REQUIRED)) {
-      state->handler = attlist1;
-      return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
-    }
-    if (XmlNameMatchesAscii(enc,
-                            ptr + MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_FIXED)) {
-      state->handler = attlist9;
-      return XML_ROLE_NONE;
-    }
-    break;
-  case XML_TOK_LITERAL:
-    state->handler = attlist1;
-    return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
-  }
-  return common(state, tok);
-}
-
-static
-int attlist9(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_LITERAL:
-    state->handler = attlist1;
-    return XML_ROLE_FIXED_ATTRIBUTE_VALUE;
-  }
-  return common(state, tok);
-}
-
-static
-int element0(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = element1;
-    return XML_ROLE_ELEMENT_NAME;
-  }
-  return common(state, tok);
-}
-
-static
-int element1(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) {
-      state->handler = declClose;
-      return XML_ROLE_CONTENT_EMPTY;
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) {
-      state->handler = declClose;
-      return XML_ROLE_CONTENT_ANY;
-    }
-    break;
-  case XML_TOK_OPEN_PAREN:
-    state->handler = element2;
-    state->level = 1;
-    return XML_ROLE_GROUP_OPEN;
-  }
-  return common(state, tok);
-}
-
-static
-int element2(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_POUND_NAME:
-    if (XmlNameMatchesAscii(enc,
-                            ptr + MIN_BYTES_PER_CHAR(enc),
-                            end,
-                            KW_PCDATA)) {
-      state->handler = element3;
-      return XML_ROLE_CONTENT_PCDATA;
-    }
-    break;
-  case XML_TOK_OPEN_PAREN:
-    state->level = 2;
-    state->handler = element6;
-    return XML_ROLE_GROUP_OPEN;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT;
-  case XML_TOK_NAME_QUESTION:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT_OPT;
-  case XML_TOK_NAME_ASTERISK:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT_REP;
-  case XML_TOK_NAME_PLUS:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT_PLUS;
-  }
-  return common(state, tok);
-}
-
-static
-int element3(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_CLOSE_PAREN:
-    state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE;
-  case XML_TOK_CLOSE_PAREN_ASTERISK:
-    state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE_REP;
-  case XML_TOK_OR:
-    state->handler = element4;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-static
-int element4(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = element5;
-    return XML_ROLE_CONTENT_ELEMENT;
-  }
-  return common(state, tok);
-}
-
-static
-int element5(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_CLOSE_PAREN_ASTERISK:
-    state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE_REP;
-  case XML_TOK_OR:
-    state->handler = element4;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-static
-int element6(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_OPEN_PAREN:
-    state->level += 1;
-    return XML_ROLE_GROUP_OPEN;
-  case XML_TOK_NAME:
-  case XML_TOK_PREFIXED_NAME:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT;
-  case XML_TOK_NAME_QUESTION:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT_OPT;
-  case XML_TOK_NAME_ASTERISK:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT_REP;
-  case XML_TOK_NAME_PLUS:
-    state->handler = element7;
-    return XML_ROLE_CONTENT_ELEMENT_PLUS;
-  }
-  return common(state, tok);
-}
-
-static
-int element7(PROLOG_STATE *state,
-             int tok,
-             const char *ptr,
-             const char *end,
-             const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_CLOSE_PAREN:
-    state->level -= 1;
-    if (state->level == 0)
-      state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE;
-  case XML_TOK_CLOSE_PAREN_ASTERISK:
-    state->level -= 1;
-    if (state->level == 0)
-      state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE_REP;
-  case XML_TOK_CLOSE_PAREN_QUESTION:
-    state->level -= 1;
-    if (state->level == 0)
-      state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE_OPT;
-  case XML_TOK_CLOSE_PAREN_PLUS:
-    state->level -= 1;
-    if (state->level == 0)
-      state->handler = declClose;
-    return XML_ROLE_GROUP_CLOSE_PLUS;
-  case XML_TOK_COMMA:
-    state->handler = element6;
-    return XML_ROLE_GROUP_SEQUENCE;
-  case XML_TOK_OR:
-    state->handler = element6;
-    return XML_ROLE_GROUP_CHOICE;
-  }
-  return common(state, tok);
-}
-
-#ifdef XML_DTD
-
-static
-int condSect0(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_NAME:
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) {
-      state->handler = condSect1;
-      return XML_ROLE_NONE;
-    }
-    if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) {
-      state->handler = condSect2;
-      return XML_ROLE_NONE;
-    }
-    break;
-  }
-  return common(state, tok);
-}
-
-static
-int condSect1(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_OPEN_BRACKET:
-    state->handler = externalSubset1;
-    state->includeLevel += 1;
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-static
-int condSect2(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_OPEN_BRACKET:
-    state->handler = externalSubset1;
-    return XML_ROLE_IGNORE_SECT;
-  }
-  return common(state, tok);
-}
-
-#endif /* XML_DTD */
-
-static
-int declClose(PROLOG_STATE *state,
-              int tok,
-              const char *ptr,
-              const char *end,
-              const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_PROLOG_S:
-    return XML_ROLE_NONE;
-  case XML_TOK_DECL_CLOSE:
-    setTopLevel(state);
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-
-#if 0
-
-static
-int ignore(PROLOG_STATE *state,
-           int tok,
-           const char *ptr,
-           const char *end,
-           const ENCODING *enc)
-{
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  switch (tok) {
-  case XML_TOK_DECL_CLOSE:
-    state->handler = internalSubset;
-    return 0;
-  default:
-    return XML_ROLE_NONE;
-  }
-  return common(state, tok);
-}
-#endif
-
-static
-int error(PROLOG_STATE *state,
-          int tok,
-          const char *ptr,
-          const char *end,
-          const ENCODING *enc)
-{
-  cmExpatUnused(state);
-  cmExpatUnused(tok);
-  cmExpatUnused(ptr);
-  cmExpatUnused(end);
-  cmExpatUnused(enc);
-  return XML_ROLE_NONE;
-}
-
-static
-int common(PROLOG_STATE *state, int tok)
-{
-#ifdef XML_DTD
-  if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
-    return XML_ROLE_INNER_PARAM_ENTITY_REF;
-#endif
-  state->handler = error;
-  return XML_ROLE_ERROR;
-}
-
-void XmlPrologStateInit(PROLOG_STATE *state)
-{
-  state->handler = prolog0;
-#ifdef XML_DTD
-  state->documentEntity = 1;
-  state->includeLevel = 0;
-#endif /* XML_DTD */
-}
-
-#ifdef XML_DTD
-
-void XmlPrologStateInitExternalEntity(PROLOG_STATE *state)
-{
-  state->handler = externalSubset0;
-  state->documentEntity = 0;
-  state->includeLevel = 0;
-}
-
-#endif /* XML_DTD */
diff --git a/Utilities/cmexpat/xmlrole.h b/Utilities/cmexpat/xmlrole.h
deleted file mode 100644
index 6f25793..0000000
--- a/Utilities/cmexpat/xmlrole.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#ifndef XmlRole_INCLUDED
-#define XmlRole_INCLUDED 1
-
-#include "xmltok.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
-  XML_ROLE_ERROR = -1,
-  XML_ROLE_NONE = 0,
-  XML_ROLE_XML_DECL,
-  XML_ROLE_INSTANCE_START,
-  XML_ROLE_DOCTYPE_NAME,
-  XML_ROLE_DOCTYPE_SYSTEM_ID,
-  XML_ROLE_DOCTYPE_PUBLIC_ID,
-  XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
-  XML_ROLE_DOCTYPE_CLOSE,
-  XML_ROLE_GENERAL_ENTITY_NAME,
-  XML_ROLE_PARAM_ENTITY_NAME,
-  XML_ROLE_ENTITY_VALUE,
-  XML_ROLE_ENTITY_SYSTEM_ID,
-  XML_ROLE_ENTITY_PUBLIC_ID,
-  XML_ROLE_ENTITY_COMPLETE,
-  XML_ROLE_ENTITY_NOTATION_NAME,
-  XML_ROLE_NOTATION_NAME,
-  XML_ROLE_NOTATION_SYSTEM_ID,
-  XML_ROLE_NOTATION_NO_SYSTEM_ID,
-  XML_ROLE_NOTATION_PUBLIC_ID,
-  XML_ROLE_ATTRIBUTE_NAME,
-  XML_ROLE_ATTRIBUTE_TYPE_CDATA,
-  XML_ROLE_ATTRIBUTE_TYPE_ID,
-  XML_ROLE_ATTRIBUTE_TYPE_IDREF,
-  XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
-  XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
-  XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
-  XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
-  XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
-  XML_ROLE_ATTRIBUTE_ENUM_VALUE,
-  XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
-  XML_ROLE_ATTLIST_ELEMENT_NAME,
-  XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
-  XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
-  XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
-  XML_ROLE_FIXED_ATTRIBUTE_VALUE,
-  XML_ROLE_ELEMENT_NAME,
-  XML_ROLE_CONTENT_ANY,
-  XML_ROLE_CONTENT_EMPTY,
-  XML_ROLE_CONTENT_PCDATA,
-  XML_ROLE_GROUP_OPEN,
-  XML_ROLE_GROUP_CLOSE,
-  XML_ROLE_GROUP_CLOSE_REP,
-  XML_ROLE_GROUP_CLOSE_OPT,
-  XML_ROLE_GROUP_CLOSE_PLUS,
-  XML_ROLE_GROUP_CHOICE,
-  XML_ROLE_GROUP_SEQUENCE,
-  XML_ROLE_CONTENT_ELEMENT,
-  XML_ROLE_CONTENT_ELEMENT_REP,
-  XML_ROLE_CONTENT_ELEMENT_OPT,
-  XML_ROLE_CONTENT_ELEMENT_PLUS,
-#ifdef XML_DTD
-  XML_ROLE_TEXT_DECL,
-  XML_ROLE_IGNORE_SECT,
-  XML_ROLE_INNER_PARAM_ENTITY_REF,
-#endif /* XML_DTD */
-  XML_ROLE_PARAM_ENTITY_REF
-};
-
-typedef struct prolog_state {
-  int (*handler)(struct prolog_state *state,
-                 int tok,
-                 const char *ptr,
-                 const char *end,
-                 const ENCODING *enc);
-  unsigned level;
-#ifdef XML_DTD
-  unsigned includeLevel;
-  int documentEntity;
-#endif /* XML_DTD */
-} PROLOG_STATE;
-
-void XmlPrologStateInit(PROLOG_STATE *);
-#ifdef XML_DTD
-void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
-#endif /* XML_DTD */
-
-#define XmlTokenRole(state, tok, ptr, end, enc) \
- (((state)->handler)(state, tok, ptr, end, enc))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not XmlRole_INCLUDED */
diff --git a/Utilities/cmexpat/xmltok.c b/Utilities/cmexpat/xmltok.c
deleted file mode 100644
index 8ee9c75..0000000
--- a/Utilities/cmexpat/xmltok.c
+++ /dev/null
@@ -1,1584 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#include <cmexpat/expatConfig.h>
-
-#include "xmltok.h"
-#include "nametab.h"
-
-#if defined(__BORLANDC__)
-#pragma warn -8008 // Disable "condition is always true" warning.
-#pragma warn -8066 // Disable "unreachable code" warning.
-#endif
-
-#ifdef XML_DTD
-#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
-#else
-#define IGNORE_SECTION_TOK_VTABLE /* as nothing */
-#endif
-
-#define VTABLE1 \
-  { PREFIX(prologTok), PREFIX(contentTok), \
-    PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \
-  { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
-  PREFIX(sameName), \
-  PREFIX(nameMatchesAscii), \
-  PREFIX(nameLength), \
-  PREFIX(skipS), \
-  PREFIX(getAtts), \
-  PREFIX(charRefNumber), \
-  PREFIX(predefinedEntityName), \
-  PREFIX(updatePosition), \
-  PREFIX(isPublicId)
-
-#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
-
-#define UCS2_GET_NAMING(pages, hi, lo) \
-   (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F)))
-
-/* A 2 byte UTF-8 representation splits the characters 11 bits
-between the bottom 5 and 6 bits of the bytes.
-We need 8 bits to index into pages, 3 bits to add to that index and
-5 bits to generate the mask. */
-#define UTF8_GET_NAMING2(pages, byte) \
-    (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
-                      + ((((byte)[0]) & 3) << 1) \
-                      + ((((byte)[1]) >> 5) & 1)] \
-         & (1 << (((byte)[1]) & 0x1F)))
-
-/* A 3 byte UTF-8 representation splits the characters 16 bits
-between the bottom 4, 6 and 6 bits of the bytes.
-We need 8 bits to index into pages, 3 bits to add to that index and
-5 bits to generate the mask. */
-#define UTF8_GET_NAMING3(pages, byte) \
-  (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \
-                             + ((((byte)[1]) >> 2) & 0xF)] \
-                       << 3) \
-                      + ((((byte)[1]) & 3) << 1) \
-                      + ((((byte)[2]) >> 5) & 1)] \
-         & (1 << (((byte)[2]) & 0x1F)))
-
-#define UTF8_GET_NAMING(pages, p, n) \
-  ((n) == 2 \
-  ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
-  : ((n) == 3 \
-     ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
-     : 0))
-
-#define UTF8_INVALID3(p) \
-  ((*p) == 0xED \
-  ? (((p)[1] & 0x20) != 0) \
-  : ((*p) == 0xEF \
-     ? ((p)[1] == 0xBF && ((p)[2] == 0xBF || (p)[2] == 0xBE)) \
-     : 0))
-
-#define UTF8_INVALID4(p) ((*p) == 0xF4 && ((p)[1] & 0x30) != 0)
-
-static
-int isNever(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  cmExpatUnused(p);
-  return 0;
-}
-
-static
-int utf8_isName2(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
-}
-
-static
-int utf8_isName3(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
-}
-
-#define utf8_isName4 isNever
-
-static
-int utf8_isNmstrt2(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
-}
-
-static
-int utf8_isNmstrt3(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
-}
-
-#define utf8_isNmstrt4 isNever
-
-#define utf8_isInvalid2 isNever
-
-static
-int utf8_isInvalid3(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  return UTF8_INVALID3((const unsigned char *)p);
-}
-
-static
-int utf8_isInvalid4(const ENCODING *enc, const char *p)
-{
-  cmExpatUnused(enc);
-  return UTF8_INVALID4((const unsigned char *)p);
-}
-
-struct normal_encoding {
-  ENCODING enc;
-  unsigned char type[256];
-#ifdef XML_MIN_SIZE
-  int (*byteType)(const ENCODING *, const char *);
-  int (*isNameMin)(const ENCODING *, const char *);
-  int (*isNmstrtMin)(const ENCODING *, const char *);
-  int (*byteToAscii)(const ENCODING *, const char *);
-  int (*charMatches)(const ENCODING *, const char *, int);
-#endif /* XML_MIN_SIZE */
-  int (*isName2)(const ENCODING *, const char *);
-  int (*isName3)(const ENCODING *, const char *);
-  int (*isName4)(const ENCODING *, const char *);
-  int (*isNmstrt2)(const ENCODING *, const char *);
-  int (*isNmstrt3)(const ENCODING *, const char *);
-  int (*isNmstrt4)(const ENCODING *, const char *);
-  int (*isInvalid2)(const ENCODING *, const char *);
-  int (*isInvalid3)(const ENCODING *, const char *);
-  int (*isInvalid4)(const ENCODING *, const char *);
-};
-
-#ifdef XML_MIN_SIZE
-
-#define STANDARD_VTABLE(E) \
- E ## byteType, \
- E ## isNameMin, \
- E ## isNmstrtMin, \
- E ## byteToAscii, \
- E ## charMatches,
-
-#else
-
-#define STANDARD_VTABLE(E) /* as nothing */
-
-#endif
-
-#define NORMAL_VTABLE(E) \
- E ## isName2, \
- E ## isName3, \
- E ## isName4, \
- E ## isNmstrt2, \
- E ## isNmstrt3, \
- E ## isNmstrt4, \
- E ## isInvalid2, \
- E ## isInvalid3, \
- E ## isInvalid4
-
-#define EMPTY_VTABLE(E) 0, 0, 0, 0, 0, 0, 0, 0, 0
-
-static int checkCharRefNumber(int);
-
-#include "xmltok_impl.h"
-#include "ascii.h"
-
-#ifdef XML_MIN_SIZE
-#define sb_isNameMin isNever
-#define sb_isNmstrtMin isNever
-#endif
-
-#ifdef XML_MIN_SIZE
-#define MINBPC(enc) ((enc)->minBytesPerChar)
-#else
-/* minimum bytes per character */
-#define MINBPC(enc) 1
-#endif
-
-#define SB_BYTE_TYPE(enc, p) \
-  (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
-
-#ifdef XML_MIN_SIZE
-static
-int sb_byteType(const ENCODING *enc, const char *p)
-{
-  return SB_BYTE_TYPE(enc, p);
-}
-#define BYTE_TYPE(enc, p) \
- (((const struct normal_encoding *)(enc))->byteType(enc, p))
-#else
-#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
-#endif
-
-#ifdef XML_MIN_SIZE
-#define BYTE_TO_ASCII(enc, p) \
- (((const struct normal_encoding *)(enc))->byteToAscii(enc, p))
-static
-int sb_byteToAscii(const ENCODING *enc, const char *p)
-{
-  return *p;
-}
-#else
-#define BYTE_TO_ASCII(enc, p) (*(p))
-#endif
-
-#define IS_NAME_CHAR(enc, p, n) \
- (((const struct normal_encoding *)(enc))->isName ## n(enc, p))
-#define IS_NMSTRT_CHAR(enc, p, n) \
- (((const struct normal_encoding *)(enc))->isNmstrt ## n(enc, p))
-#define IS_INVALID_CHAR(enc, p, n) \
- (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p))
-
-#ifdef XML_MIN_SIZE
-#define IS_NAME_CHAR_MINBPC(enc, p) \
- (((const struct normal_encoding *)(enc))->isNameMin(enc, p))
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) \
- (((const struct normal_encoding *)(enc))->isNmstrtMin(enc, p))
-#else
-#define IS_NAME_CHAR_MINBPC(enc, p) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
-#endif
-
-#ifdef XML_MIN_SIZE
-#define CHAR_MATCHES(enc, p, c) \
- (((const struct normal_encoding *)(enc))->charMatches(enc, p, c))
-static
-int sb_charMatches(const ENCODING *enc, const char *p, int c)
-{
-  return *p == c;
-}
-#else
-/* c is an ASCII character */
-#define CHAR_MATCHES(enc, p, c) (*(p) == c)
-#endif
-
-#define PREFIX(ident) normal_ ## ident
-#include "xmltok_impl.c"
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
-
-enum {  /* UTF8_cvalN is value of masked first byte of N byte sequence */
-  UTF8_cval1 = 0x00,
-  UTF8_cval2 = 0xc0,
-  UTF8_cval3 = 0xe0,
-  UTF8_cval4 = 0xf0
-};
-
-static
-void utf8_toUtf8(const ENCODING *enc,
-                 const char **fromP, const char *fromLim,
-                 char **toP, const char *toLim)
-{
-  char *to;
-  const char *from;
-  cmExpatUnused(enc);
-  if (fromLim - *fromP > toLim - *toP) {
-    /* Avoid copying partial characters. */
-    for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
-      if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
-        break;
-  }
-  for (to = *toP, from = *fromP; from != fromLim; from++, to++)
-    *to = *from;
-  *fromP = from;
-  *toP = to;
-}
-
-static
-void utf8_toUtf16(const ENCODING *enc,
-                  const char **fromP, const char *fromLim,
-                  unsigned short **toP, const unsigned short *toLim)
-{
-  unsigned short *to = *toP;
-  const char *from = *fromP;
-  while (from != fromLim && to != toLim) {
-    switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {
-    case BT_LEAD2:
-      *to++ = ((from[0] & 0x1f) << 6) | (from[1] & 0x3f);
-      from += 2;
-      break;
-    case BT_LEAD3:
-      *to++ = ((from[0] & 0xf) << 12) | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f);
-      from += 3;
-      break;
-    case BT_LEAD4:
-      {
-        unsigned long n;
-        if (to + 1 == toLim)
-          break;
-        n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
-        n -= 0x10000;
-        to[0] = (unsigned short)((n >> 10) | 0xD800);
-        to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
-        to += 2;
-        from += 4;
-      }
-      break;
-    default:
-      *to++ = *from++;
-      break;
-    }
-  }
-  *fromP = from;
-  *toP = to;
-}
-
-#ifdef XML_NS
-static const struct normal_encoding utf8_encoding_ns = {
-  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
-  {
-#include "asciitab.h"
-#include "utf8tab.h"
-  },
-  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-#endif
-
-static const struct normal_encoding utf8_encoding = {
-  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
-  {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "utf8tab.h"
-  },
-  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-
-#ifdef XML_NS
-
-static const struct normal_encoding internal_utf8_encoding_ns = {
-  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
-  {
-#include "iasciitab.h"
-#include "utf8tab.h"
-  },
-  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-
-#endif
-
-static const struct normal_encoding internal_utf8_encoding = {
-  { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
-  {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "utf8tab.h"
-  },
-  STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-
-static
-void latin1_toUtf8(const ENCODING *enc,
-                   const char **fromP, const char *fromLim,
-                   char **toP, const char *toLim)
-{
-  cmExpatUnused(enc);
-  for (;;) {
-    unsigned char c;
-    if (*fromP == fromLim)
-      break;
-    c = (unsigned char)**fromP;
-    if (c & 0x80) {
-      if (toLim - *toP < 2)
-        break;
-      *(*toP)++ = ((c >> 6) | UTF8_cval2);
-      *(*toP)++ = ((c & 0x3f) | 0x80);
-      (*fromP)++;
-    }
-    else {
-      if (*toP == toLim)
-        break;
-      *(*toP)++ = *(*fromP)++;
-    }
-  }
-}
-
-static
-void latin1_toUtf16(const ENCODING *enc,
-                    const char **fromP, const char *fromLim,
-                    unsigned short **toP, const unsigned short *toLim)
-{
-  cmExpatUnused(enc);
-  while (*fromP != fromLim && *toP != toLim)
-    *(*toP)++ = (unsigned char)*(*fromP)++;
-}
-
-#ifdef XML_NS
-
-static const struct normal_encoding latin1_encoding_ns = {
-  { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
-  {
-#include "asciitab.h"
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(sb_) EMPTY_VTABLE(sb_)
-};
-
-#endif
-
-static const struct normal_encoding latin1_encoding = {
-  { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
-  {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(sb_) EMPTY_VTABLE(sb_)
-};
-
-static
-void ascii_toUtf8(const ENCODING *enc,
-                  const char **fromP, const char *fromLim,
-                  char **toP, const char *toLim)
-{
-  cmExpatUnused(enc);
-  while (*fromP != fromLim && *toP != toLim)
-    *(*toP)++ = *(*fromP)++;
-}
-
-#ifdef XML_NS
-
-static const struct normal_encoding ascii_encoding_ns = {
-  { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
-  {
-#include "asciitab.h"
-/* BT_NONXML == 0 */
-  },
-  STANDARD_VTABLE(sb_) EMPTY_VTABLE(sb_)
-};
-
-#endif
-
-static const struct normal_encoding ascii_encoding = {
-  { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
-  {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-/* BT_NONXML == 0 */
-  },
-  STANDARD_VTABLE(sb_) EMPTY_VTABLE(sb_)
-};
-
-static int unicode_byte_type(char hi, char lo)
-{
-  switch ((unsigned char)hi) {
-  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
-    return BT_LEAD4;
-  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
-    return BT_TRAIL;
-  case 0xFF:
-    switch ((unsigned char)lo) {
-    case 0xFF:
-    case 0xFE:
-      return BT_NONXML;
-    }
-    break;
-  }
-  return BT_NONASCII;
-}
-
-#define DEFINE_UTF16_TO_UTF8(E) \
-static \
-void E ## toUtf8(const ENCODING *enc, \
-                 const char **fromP, const char *fromLim, \
-                 char **toP, const char *toLim) \
-{ \
-  const char *from; \
-  cmExpatUnused(enc);\
-  for (from = *fromP; from != fromLim; from += 2) { \
-    int plane; \
-    unsigned char lo2; \
-    unsigned char lo = GET_LO(from); \
-    unsigned char hi = GET_HI(from); \
-    switch (hi) { \
-    case 0: \
-      if (lo < 0x80) { \
-        if (*toP == toLim) { \
-          *fromP = from; \
-          return; \
-        } \
-        *(*toP)++ = lo; \
-        break; \
-      } \
-      /* fall through */ \
-    case 0x1: case 0x2: case 0x3: \
-    case 0x4: case 0x5: case 0x6: case 0x7: \
-      if (toLim -  *toP < 2) { \
-        *fromP = from; \
-        return; \
-      } \
-      *(*toP)++ = ((lo >> 6) | (hi << 2) |  UTF8_cval2); \
-      *(*toP)++ = ((lo & 0x3f) | 0x80); \
-      break; \
-    default: \
-      if (toLim -  *toP < 3)  { \
-        *fromP = from; \
-        return; \
-      } \
-      /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
-      *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
-      *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
-      *(*toP)++ = ((lo & 0x3f) | 0x80); \
-      break; \
-    case 0xD8: case 0xD9: case 0xDA: case 0xDB: \
-      if (toLim -  *toP < 4) { \
-        *fromP = from; \
-        return; \
-      } \
-      plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
-      *(*toP)++ = ((plane >> 2) | UTF8_cval4); \
-      *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
-      from += 2; \
-      lo2 = GET_LO(from); \
-      *(*toP)++ = (((lo & 0x3) << 4) \
-                   | ((GET_HI(from) & 0x3) << 2) \
-                   | (lo2 >> 6) \
-                   | 0x80); \
-      *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
-      break; \
-    } \
-  } \
-  *fromP = from; \
-}
-
-#define DEFINE_UTF16_TO_UTF16(E) \
-static \
-void E ## toUtf16(const ENCODING *enc, \
-                  const char **fromP, const char *fromLim, \
-                  unsigned short **toP, const unsigned short *toLim) \
-{ \
-  cmExpatUnused(enc);\
-  /* Avoid copying first half only of surrogate */ \
-  if (fromLim - *fromP > ((toLim - *toP) << 1) \
-      && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \
-    fromLim -= 2; \
-  for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \
-    *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
-}
-
-#define SET2(ptr, ch) \
-  (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8)))
-#define GET_LO(ptr) ((unsigned char)(ptr)[0])
-#define GET_HI(ptr) ((unsigned char)(ptr)[1])
-
-DEFINE_UTF16_TO_UTF8(little2_)
-DEFINE_UTF16_TO_UTF16(little2_)
-
-#undef SET2
-#undef GET_LO
-#undef GET_HI
-
-#define SET2(ptr, ch) \
-  (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF)))
-#define GET_LO(ptr) ((unsigned char)(ptr)[1])
-#define GET_HI(ptr) ((unsigned char)(ptr)[0])
-
-DEFINE_UTF16_TO_UTF8(big2_)
-DEFINE_UTF16_TO_UTF16(big2_)
-
-#undef SET2
-#undef GET_LO
-#undef GET_HI
-
-#define LITTLE2_BYTE_TYPE(enc, p) \
- ((p)[1] == 0 \
-  ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
-  : unicode_byte_type((p)[1], (p)[0]))
-#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1)
-#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c)
-#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \
-  UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
-#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
-  UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
-
-#ifdef XML_MIN_SIZE
-
-static
-int little2_byteType(const ENCODING *enc, const char *p)
-{
-  return LITTLE2_BYTE_TYPE(enc, p);
-}
-
-static
-int little2_byteToAscii(const ENCODING *enc, const char *p)
-{
-  return LITTLE2_BYTE_TO_ASCII(enc, p);
-}
-
-static
-int little2_charMatches(const ENCODING *enc, const char *p, int c)
-{
-  return LITTLE2_CHAR_MATCHES(enc, p, c);
-}
-
-static
-int little2_isNameMin(const ENCODING *enc, const char *p)
-{
-  return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
-}
-
-static
-int little2_isNmstrtMin(const ENCODING *enc, const char *p)
-{
-  return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
-}
-
-#undef VTABLE
-#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
-
-#else /* not XML_MIN_SIZE */
-
-#undef PREFIX
-#define PREFIX(ident) little2_ ## ident
-#define MINBPC(enc) 2
-/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
-#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
-#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) 
-#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
-#define IS_NAME_CHAR(enc, p, n) 0
-#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
-#define IS_NMSTRT_CHAR(enc, p, n) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
-
-#include "xmltok_impl.c"
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
-
-#endif /* not XML_MIN_SIZE */
-
-#ifdef XML_NS
-
-static const struct normal_encoding little2_encoding_ns = { 
-  { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 12
-    1
-#else
-    0
-#endif
-  },
-  {
-#include "asciitab.h"
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(little2_) EMPTY_VTABLE(little2_)
-};
-
-#endif
-
-static const struct normal_encoding little2_encoding = { 
-  { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 12
-    1
-#else
-    0
-#endif
-  },
-  {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(little2_) EMPTY_VTABLE(little2_)
-};
-
-#if XML_BYTE_ORDER != 21
-
-#ifdef XML_NS
-
-static const struct normal_encoding internal_little2_encoding_ns = { 
-  { VTABLE, 2, 0, 1 },
-  {
-#include "iasciitab.h"
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(little2_) EMPTY_VTABLE(little2_)
-};
-
-#endif
-
-static const struct normal_encoding internal_little2_encoding = { 
-  { VTABLE, 2, 0, 1 },
-  {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(little2_) EMPTY_VTABLE(little2_)
-};
-
-#endif
-
-
-#define BIG2_BYTE_TYPE(enc, p) \
- ((p)[0] == 0 \
-  ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
-  : unicode_byte_type((p)[0], (p)[1]))
-#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1)
-#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c)
-#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \
-  UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
-#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
-  UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
-
-#ifdef XML_MIN_SIZE
-
-static
-int big2_byteType(const ENCODING *enc, const char *p)
-{
-  return BIG2_BYTE_TYPE(enc, p);
-}
-
-static
-int big2_byteToAscii(const ENCODING *enc, const char *p)
-{
-  return BIG2_BYTE_TO_ASCII(enc, p);
-}
-
-static
-int big2_charMatches(const ENCODING *enc, const char *p, int c)
-{
-  return BIG2_CHAR_MATCHES(enc, p, c);
-}
-
-static
-int big2_isNameMin(const ENCODING *enc, const char *p)
-{
-  return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
-}
-
-static
-int big2_isNmstrtMin(const ENCODING *enc, const char *p)
-{
-  return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
-}
-
-#undef VTABLE
-#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
-
-#else /* not XML_MIN_SIZE */
-
-#undef PREFIX
-#define PREFIX(ident) big2_ ## ident
-#define MINBPC(enc) 2
-/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
-#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
-#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) 
-#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
-#define IS_NAME_CHAR(enc, p, n) 0
-#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
-#define IS_NMSTRT_CHAR(enc, p, n) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
-
-#include "xmltok_impl.c"
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
-
-#endif /* not XML_MIN_SIZE */
-
-#ifdef XML_NS
-
-static const struct normal_encoding big2_encoding_ns = {
-  { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 21
-  1
-#else
-  0
-#endif
-  },
-  {
-#include "asciitab.h"
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(big2_) EMPTY_VTABLE(big2_)
-};
-
-#endif
-
-static const struct normal_encoding big2_encoding = {
-  { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 21
-  1
-#else
-  0
-#endif
-  },
-  {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(big2_) EMPTY_VTABLE(big2_)
-};
-
-#if XML_BYTE_ORDER != 12
-
-#ifdef XML_NS
-
-static const struct normal_encoding internal_big2_encoding_ns = {
-  { VTABLE, 2, 0, 1 },
-  {
-#include "iasciitab.h"
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(big2_) EMPTY_VTABLE(big2_)
-};
-
-#endif
-
-static const struct normal_encoding internal_big2_encoding = {
-  { VTABLE, 2, 0, 1 },
-  {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
-  },
-  STANDARD_VTABLE(big2_) EMPTY_VTABLE(big2_)
-};
-
-#endif
-
-#undef PREFIX
-
-static
-int streqci(const char *s1, const char *s2)
-{
-  for (;;) {
-    char c1 = *s1++;
-    char c2 = *s2++;
-    if (ASCII_a <= c1 && c1 <= ASCII_z)
-      c1 += ASCII_A - ASCII_a;
-    if (ASCII_a <= c2 && c2 <= ASCII_z)
-      c2 += ASCII_A - ASCII_a;
-    if (c1 != c2)
-      return 0;
-    if (!c1)
-      break;
-  }
-  return 1;
-}
-
-static
-void initUpdatePosition(const ENCODING *enc, const char *ptr,
-                        const char *end, POSITION *pos)
-{
-  cmExpatUnused(enc);
-  normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
-}
-
-static
-int toAscii(const ENCODING *enc, const char *ptr, const char *end)
-{
-  char buf[1];
-  char *p = buf;
-  XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
-  if (p == buf)
-    return -1;
-  else
-    return buf[0];
-}
-
-static
-int isSpace(int c)
-{
-  switch (c) {
-  case 0x20:
-  case 0xD:
-  case 0xA:
-  case 0x9:     
-    return 1;
-  }
-  return 0;
-}
-
-/* Return 1 if there's just optional white space
-or there's an S followed by name=val. */
-static
-int parsePseudoAttribute(const ENCODING *enc,
-                         const char *ptr,
-                         const char *end,
-                         const char **namePtr,
-                         const char **nameEndPtr,
-                         const char **valPtr,
-                         const char **nextTokPtr)
-{
-  int c;
-  char open;
-  if (ptr == end) {
-    *namePtr = 0;
-    return 1;
-  }
-  if (!isSpace(toAscii(enc, ptr, end))) {
-    *nextTokPtr = ptr;
-    return 0;
-  }
-  do {
-    ptr += enc->minBytesPerChar;
-  } while (isSpace(toAscii(enc, ptr, end)));
-  if (ptr == end) {
-    *namePtr = 0;
-    return 1;
-  }
-  *namePtr = ptr;
-  for (;;) {
-    c = toAscii(enc, ptr, end);
-    if (c == -1) {
-      *nextTokPtr = ptr;
-      return 0;
-    }
-    if (c == ASCII_EQUALS) {
-      *nameEndPtr = ptr;
-      break;
-    }
-    if (isSpace(c)) {
-      *nameEndPtr = ptr;
-      do {
-        ptr += enc->minBytesPerChar;
-      } while (isSpace(c = toAscii(enc, ptr, end)));
-      if (c != ASCII_EQUALS) {
-        *nextTokPtr = ptr;
-        return 0;
-      }
-      break;
-    }
-    ptr += enc->minBytesPerChar;
-  }
-  if (ptr == *namePtr) {
-    *nextTokPtr = ptr;
-    return 0;
-  }
-  ptr += enc->minBytesPerChar;
-  c = toAscii(enc, ptr, end);
-  while (isSpace(c)) {
-    ptr += enc->minBytesPerChar;
-    c = toAscii(enc, ptr, end);
-  }
-  if (c != ASCII_QUOT && c != ASCII_APOS) {
-    *nextTokPtr = ptr;
-    return 0;
-  }
-  open = c;
-  ptr += enc->minBytesPerChar;
-  *valPtr = ptr;
-  for (;; ptr += enc->minBytesPerChar) {
-    c = toAscii(enc, ptr, end);
-    if (c == open)
-      break;
-    if (!(ASCII_a <= c && c <= ASCII_z)
-        && !(ASCII_A <= c && c <= ASCII_Z)
-        && !(ASCII_0 <= c && c <= ASCII_9)
-        && c != ASCII_PERIOD
-        && c != ASCII_MINUS
-        && c != ASCII_UNDERSCORE) {
-      *nextTokPtr = ptr;
-      return 0;
-    }
-  }
-  *nextTokPtr = ptr + enc->minBytesPerChar;
-  return 1;
-}
-
-static const char KW_version[] = {
-  ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0'
-};
-
-static const char KW_encoding[] = {
-  ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0'
-};
-
-static const char KW_standalone[] = {
-  ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o, ASCII_n, ASCII_e, '\0'
-};
-
-static const char KW_yes[] = {
-  ASCII_y, ASCII_e, ASCII_s,  '\0'
-};
-
-static const char KW_no[] = {
-  ASCII_n, ASCII_o,  '\0'
-};
-
-static
-int doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
-                                                     const char *,
-                                                     const char *),
-                   int isGeneralTextEntity,
-                   const ENCODING *enc,
-                   const char *ptr,
-                   const char *end,
-                   const char **badPtr,
-                   const char **versionPtr,
-                   const char **versionEndPtr,
-                   const char **encodingName,
-                   const ENCODING **encoding,
-                   int *standalone)
-{
-  const char *val = 0;
-  const char *name = 0;
-  const char *nameEnd = 0;
-  ptr += 5 * enc->minBytesPerChar;
-  end -= 2 * enc->minBytesPerChar;
-  if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) || !name) {
-    *badPtr = ptr;
-    return 0;
-  }
-  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
-    if (!isGeneralTextEntity) {
-      *badPtr = name;
-      return 0;
-    }
-  }
-  else {
-    if (versionPtr)
-      *versionPtr = val;
-    if (versionEndPtr)
-      *versionEndPtr = ptr;
-    if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
-      *badPtr = ptr;
-      return 0;
-    }
-    if (!name) {
-      if (isGeneralTextEntity) {
-        /* a TextDecl must have an EncodingDecl */
-        *badPtr = ptr;
-        return 0;
-      }
-      return 1;
-    }
-  }
-  if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) {
-    int c = toAscii(enc, val, end);
-    if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) {
-      *badPtr = val;
-      return 0;
-    }
-    if (encodingName)
-      *encodingName = val;
-    if (encoding)
-      *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
-    if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
-      *badPtr = ptr;
-      return 0;
-    }
-    if (!name)
-      return 1;
-  }
-  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) || isGeneralTextEntity) {
-    *badPtr = name;
-    return 0;
-  }
-  if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) {
-    if (standalone)
-      *standalone = 1;
-  }
-  else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
-    if (standalone)
-      *standalone = 0;
-  }
-  else {
-    *badPtr = val;
-    return 0;
-  }
-  while (isSpace(toAscii(enc, ptr, end)))
-    ptr += enc->minBytesPerChar;
-  if (ptr != end) {
-    *badPtr = ptr;
-    return 0;
-  }
-  return 1;
-}
-
-static
-int checkCharRefNumber(int result)
-{
-  switch (result >> 8) {
-  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
-  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
-    return -1;
-  case 0:
-    if (latin1_encoding.type[result] == BT_NONXML)
-      return -1;
-    break;
-  case 0xFF:
-    if (result == 0xFFFE || result == 0xFFFF)
-      return -1;
-    break;
-  }
-  return result;
-}
-
-int XmlUtf8Encode(int c, char *buf)
-{
-  enum {
-    /* minN is minimum legal resulting value for N byte sequence */
-    min2 = 0x80,
-    min3 = 0x800,
-    min4 = 0x10000
-  };
-
-  if (c < 0)
-    return 0;
-  if (c < min2) {
-    buf[0] = (c | UTF8_cval1);
-    return 1;
-  }
-  if (c < min3) {
-    buf[0] = ((c >> 6) | UTF8_cval2);
-    buf[1] = ((c & 0x3f) | 0x80);
-    return 2;
-  }
-  if (c < min4) {
-    buf[0] = ((c >> 12) | UTF8_cval3);
-    buf[1] = (((c >> 6) & 0x3f) | 0x80);
-    buf[2] = ((c & 0x3f) | 0x80);
-    return 3;
-  }
-  if (c < 0x110000) {
-    buf[0] = ((c >> 18) | UTF8_cval4);
-    buf[1] = (((c >> 12) & 0x3f) | 0x80);
-    buf[2] = (((c >> 6) & 0x3f) | 0x80);
-    buf[3] = ((c & 0x3f) | 0x80);
-    return 4;
-  }
-  return 0;
-}
-
-int XmlUtf16Encode(int charNum, unsigned short *buf)
-{
-  if (charNum < 0)
-    return 0;
-  if (charNum < 0x10000) {
-    buf[0] = charNum;
-    return 1;
-  }
-  if (charNum < 0x110000) {
-    charNum -= 0x10000;
-    buf[0] = (charNum >> 10) + 0xD800;
-    buf[1] = (charNum & 0x3FF) + 0xDC00;
-    return 2;
-  }
-  return 0;
-}
-
-struct unknown_encoding {
-  struct normal_encoding normal;
-  int (*convert)(void *userData, const char *p);
-  void *userData;
-  unsigned short utf16[256];
-  char utf8[256][4];
-};
-
-int XmlSizeOfUnknownEncoding(void)
-{
-  return sizeof(struct unknown_encoding);
-}
-
-static
-int unknown_isName(const ENCODING *enc, const char *p)
-{
-  int c = ((const struct unknown_encoding *)enc)
-          ->convert(((const struct unknown_encoding *)enc)->userData, p);
-  if (c & ~0xFFFF)
-    return 0;
-  return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
-}
-
-static
-int unknown_isNmstrt(const ENCODING *enc, const char *p)
-{
-  int c = ((const struct unknown_encoding *)enc)
-          ->convert(((const struct unknown_encoding *)enc)->userData, p);
-  if (c & ~0xFFFF)
-    return 0;
-  return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
-}
-
-static
-int unknown_isInvalid(const ENCODING *enc, const char *p)
-{
-  int c = ((const struct unknown_encoding *)enc)
-           ->convert(((const struct unknown_encoding *)enc)->userData, p);
-  return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
-}
-
-static
-void unknown_toUtf8(const ENCODING *enc,
-                    const char **fromP, const char *fromLim,
-                    char **toP, const char *toLim)
-{
-  char buf[XML_UTF8_ENCODE_MAX];
-  for (;;) {
-    const char *utf8;
-    int n;
-    if (*fromP == fromLim)
-      break;
-    utf8 = ((const struct unknown_encoding *)enc)->utf8[(unsigned char)**fromP];
-    n = *utf8++;
-    if (n == 0) {
-      int c = ((const struct unknown_encoding *)enc)
-              ->convert(((const struct unknown_encoding *)enc)->userData, *fromP);
-      n = XmlUtf8Encode(c, buf);
-      if (n > toLim - *toP)
-        break;
-      utf8 = buf;
-      *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP]
-                 - (BT_LEAD2 - 2);
-    }
-    else {
-      if (n > toLim - *toP)
-        break;
-      (*fromP)++;
-    }
-    do {
-      *(*toP)++ = *utf8++;
-    } while (--n != 0);
-  }
-}
-
-static
-void unknown_toUtf16(const ENCODING *enc,
-                     const char **fromP, const char *fromLim,
-                     unsigned short **toP, const unsigned short *toLim)
-{
-  while (*fromP != fromLim && *toP != toLim) {
-    unsigned short c
-      = ((const struct unknown_encoding *)enc)->utf16[(unsigned char)**fromP];
-    if (c == 0) {
-      c = (unsigned short)((const struct unknown_encoding *)enc)
-           ->convert(((const struct unknown_encoding *)enc)->userData, *fromP);
-      *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP]
-                 - (BT_LEAD2 - 2);
-    }
-    else
-      (*fromP)++;
-    *(*toP)++ = c;
-  }
-}
-
-ENCODING *
-XmlInitUnknownEncoding(void *mem,
-                       int *table,
-                       int (*convert)(void *userData, const char *p),
-                       void *userData)
-{
-  int i;
-  struct unknown_encoding *e = mem;
-  for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
-    ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
-  for (i = 0; i < 128; i++)
-    if (latin1_encoding.type[i] != BT_OTHER
-        && latin1_encoding.type[i] != BT_NONXML
-        && table[i] != i)
-      return 0;
-  for (i = 0; i < 256; i++) {
-    int c = table[i];
-    if (c == -1) {
-      e->normal.type[i] = BT_MALFORM;
-      /* This shouldn't really get used. */
-      e->utf16[i] = 0xFFFF;
-      e->utf8[i][0] = 1;
-      e->utf8[i][1] = 0;
-    }
-    else if (c < 0) {
-      if (c < -4)
-        return 0;
-      e->normal.type[i] = BT_LEAD2 - (c + 2);
-      e->utf8[i][0] = 0;
-      e->utf16[i] = 0;
-    }
-    else if (c < 0x80) {
-      if (latin1_encoding.type[c] != BT_OTHER
-          && latin1_encoding.type[c] != BT_NONXML
-          && c != i)
-        return 0;
-      e->normal.type[i] = latin1_encoding.type[c];
-      e->utf8[i][0] = 1;
-      e->utf8[i][1] = (char)c;
-      e->utf16[i] = c == 0 ? 0xFFFF : c;
-    }
-    else if (checkCharRefNumber(c) < 0) {
-      e->normal.type[i] = BT_NONXML;
-      /* This shouldn't really get used. */
-      e->utf16[i] = 0xFFFF;
-      e->utf8[i][0] = 1;
-      e->utf8[i][1] = 0;
-    }
-    else {
-      if (c > 0xFFFF)
-        return 0;
-      if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
-        e->normal.type[i] = BT_NMSTRT;
-      else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
-        e->normal.type[i] = BT_NAME;
-      else
-        e->normal.type[i] = BT_OTHER;
-      e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
-      e->utf16[i] = c;
-    }
-  }
-  e->userData = userData;
-  e->convert = convert;
-  if (convert) {
-    e->normal.isName2 = unknown_isName;
-    e->normal.isName3 = unknown_isName;
-    e->normal.isName4 = unknown_isName;
-    e->normal.isNmstrt2 = unknown_isNmstrt;
-    e->normal.isNmstrt3 = unknown_isNmstrt;
-    e->normal.isNmstrt4 = unknown_isNmstrt;
-    e->normal.isInvalid2 = unknown_isInvalid;
-    e->normal.isInvalid3 = unknown_isInvalid;
-    e->normal.isInvalid4 = unknown_isInvalid;
-  }
-  e->normal.enc.utf8Convert = unknown_toUtf8;
-  e->normal.enc.utf16Convert = unknown_toUtf16;
-  return &(e->normal.enc);
-}
-
-/* If this enumeration is changed, getEncodingIndex and encodings
-must also be changed. */
-enum {
-  UNKNOWN_ENC = -1,
-  ISO_8859_1_ENC = 0,
-  US_ASCII_ENC,
-  UTF_8_ENC,
-  UTF_16_ENC,
-  UTF_16BE_ENC,
-  UTF_16LE_ENC,
-  /* must match encodingNames up to here */
-  NO_ENC
-};
-
-static const char KW_ISO_8859_1[] = {
-  ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9, ASCII_MINUS, ASCII_1, '\0'
-};
-static const char KW_US_ASCII[] = {
-  ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I, '\0'
-};
-static const char KW_UTF_8[] =  {
-  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0'
-};
-static const char KW_UTF_16[] = {
-  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0'
-};
-static const char KW_UTF_16BE[] = {
-  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E, '\0'
-};
-static const char KW_UTF_16LE[] = {
-  ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, '\0'
-};
-
-static
-int getEncodingIndex(const char *name)
-{
-  static const char *encodingNames[] = {
-    KW_ISO_8859_1,
-    KW_US_ASCII,
-    KW_UTF_8,
-    KW_UTF_16,
-    KW_UTF_16BE,
-    KW_UTF_16LE,
-  };
-  int i;
-  if (name == 0)
-    return NO_ENC;
-  for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++)
-    if (streqci(name, encodingNames[i]))
-      return i;
-  return UNKNOWN_ENC;
-}
-
-/* For binary compatibility, we store the index of the encoding specified
-at initialization in the isUtf16 member. */
-
-#define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16)
-#define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i)
-
-/* This is what detects the encoding.
-encodingTable maps from encoding indices to encodings;
-INIT_ENC_INDEX(enc) is the index of the external (protocol) specified encoding;
-state is XML_CONTENT_STATE if we're parsing an external text entity,
-and XML_PROLOG_STATE otherwise.
-*/
-
-
-static
-int initScan(const ENCODING **encodingTable,
-             const INIT_ENCODING *enc,
-             int state,
-             const char *ptr,
-             const char *end,
-             const char **nextTokPtr)
-{
-  const ENCODING **encPtr;
-
-  if (ptr == end)
-    return XML_TOK_NONE;
-  encPtr = enc->encPtr;
-  if (ptr + 1 == end) {
-    /* only a single byte available for auto-detection */
-#ifndef XML_DTD /* FIXME */
-    /* a well-formed document entity must have more than one byte */
-    if (state != XML_CONTENT_STATE)
-      return XML_TOK_PARTIAL;
-#endif
-    /* so we're parsing an external text entity... */
-    /* if UTF-16 was externally specified, then we need at least 2 bytes */
-    switch (INIT_ENC_INDEX(enc)) {
-    case UTF_16_ENC:
-    case UTF_16LE_ENC:
-    case UTF_16BE_ENC:
-      return XML_TOK_PARTIAL;
-    }
-    switch ((unsigned char)*ptr) {
-    case 0xFE:
-    case 0xFF:
-    case 0xEF: /* possibly first byte of UTF-8 BOM */
-      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
-          && state == XML_CONTENT_STATE)
-        break;
-      /* fall through */
-    case 0x00:
-    case 0x3C:
-      return XML_TOK_PARTIAL;
-    }
-  }
-  else {
-    switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
-    case 0xFEFF:
-      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
-          && state == XML_CONTENT_STATE)
-        break;
-      *nextTokPtr = ptr + 2;
-      *encPtr = encodingTable[UTF_16BE_ENC];
-      return XML_TOK_BOM;
-    /* 00 3C is handled in the default case */
-    case 0x3C00:
-      if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC
-           || INIT_ENC_INDEX(enc) == UTF_16_ENC)
-          && state == XML_CONTENT_STATE)
-        break;
-      *encPtr = encodingTable[UTF_16LE_ENC];
-      return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
-    case 0xFFFE:
-      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
-          && state == XML_CONTENT_STATE)
-        break;
-      *nextTokPtr = ptr + 2;
-      *encPtr = encodingTable[UTF_16LE_ENC];
-      return XML_TOK_BOM;
-    case 0xEFBB:
-      /* Maybe a UTF-8 BOM (EF BB BF) */
-      /* If there's an explicitly specified (external) encoding
-         of ISO-8859-1 or some flavour of UTF-16
-         and this is an external text entity,
-         don't look for the BOM,
-         because it might be a legal data. */
-      if (state == XML_CONTENT_STATE) {
-        int e = INIT_ENC_INDEX(enc);
-        if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC || e == UTF_16LE_ENC || e == UTF_16_ENC)
-          break;
-      }
-      if (ptr + 2 == end)
-        return XML_TOK_PARTIAL;
-      if ((unsigned char)ptr[2] == 0xBF) {
-        *nextTokPtr = ptr + 3;
-        *encPtr = encodingTable[UTF_8_ENC];
-        return XML_TOK_BOM;
-      }
-      break;
-    default:
-      if (ptr[0] == '\0') {
-        /* 0 isn't a legal data character. Furthermore a document entity can only
-           start with ASCII characters.  So the only way this can fail to be big-endian
-           UTF-16 if it it's an external parsed general entity that's labelled as
-           UTF-16LE. */
-        if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC)
-          break;
-        *encPtr = encodingTable[UTF_16BE_ENC];
-        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
-      }
-      else if (ptr[1] == '\0') {
-        /* We could recover here in the case:
-            - parsing an external entity
-            - second byte is 0
-            - no externally specified encoding
-            - no encoding declaration
-           by assuming UTF-16LE.  But we don't, because this would mean when
-           presented just with a single byte, we couldn't reliably determine
-           whether we needed further bytes. */
-        if (state == XML_CONTENT_STATE)
-          break;
-        *encPtr = encodingTable[UTF_16LE_ENC];
-        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
-      }
-      break;
-    }
-  }
-  *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
-  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
-}
-
-
-#define NS(x) x
-#define ns(x) x
-#include "xmltok_ns.c"
-#undef NS
-#undef ns
-
-#ifdef XML_NS
-
-#define NS(x) x ## NS
-#define ns(x) x ## _ns
-
-#include "xmltok_ns.c"
-
-#undef NS
-#undef ns
-
-ENCODING *
-XmlInitUnknownEncodingNS(void *mem,
-                         int *table,
-                         int (*convert)(void *userData, const char *p),
-                         void *userData)
-{
-  ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
-  if (enc)
-    ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON;
-  return enc;
-}
-
-#endif /* XML_NS */
diff --git a/Utilities/cmexpat/xmltok.h b/Utilities/cmexpat/xmltok.h
deleted file mode 100644
index cdf49b2..0000000
--- a/Utilities/cmexpat/xmltok.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#ifndef XmlTok_INCLUDED
-#define XmlTok_INCLUDED 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* The following token may be returned by XmlContentTok */
-#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
-                                    illegal ]]> sequence */
-/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
-#define XML_TOK_NONE -4    /* The string to be scanned is empty */
-#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
-                                  might be part of CRLF sequence */ 
-#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
-#define XML_TOK_PARTIAL -1 /* only part of a token */
-#define XML_TOK_INVALID 0
-
-/* The following tokens are returned by XmlContentTok; some are also
-  returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */
-
-#define XML_TOK_START_TAG_WITH_ATTS 1
-#define XML_TOK_START_TAG_NO_ATTS 2
-#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
-#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
-#define XML_TOK_END_TAG 5
-#define XML_TOK_DATA_CHARS 6
-#define XML_TOK_DATA_NEWLINE 7
-#define XML_TOK_CDATA_SECT_OPEN 8
-#define XML_TOK_ENTITY_REF 9
-#define XML_TOK_CHAR_REF 10     /* numeric character reference */
-
-/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
-#define XML_TOK_PI 11      /* processing instruction */
-#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
-#define XML_TOK_COMMENT 13
-#define XML_TOK_BOM 14     /* Byte order mark */
-
-/* The following tokens are returned only by XmlPrologTok */
-#define XML_TOK_PROLOG_S 15
-#define XML_TOK_DECL_OPEN 16 /* <!foo */
-#define XML_TOK_DECL_CLOSE 17 /* > */
-#define XML_TOK_NAME 18
-#define XML_TOK_NMTOKEN 19
-#define XML_TOK_POUND_NAME 20 /* #name */
-#define XML_TOK_OR 21 /* | */
-#define XML_TOK_PERCENT 22
-#define XML_TOK_OPEN_PAREN 23
-#define XML_TOK_CLOSE_PAREN 24
-#define XML_TOK_OPEN_BRACKET 25
-#define XML_TOK_CLOSE_BRACKET 26
-#define XML_TOK_LITERAL 27
-#define XML_TOK_PARAM_ENTITY_REF 28
-#define XML_TOK_INSTANCE_START 29
-
-/* The following occur only in element type declarations */
-#define XML_TOK_NAME_QUESTION 30 /* name? */
-#define XML_TOK_NAME_ASTERISK 31 /* name* */
-#define XML_TOK_NAME_PLUS 32 /* name+ */
-#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
-#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
-#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
-#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
-#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
-#define XML_TOK_COMMA 38
-
-/* The following token is returned only by XmlAttributeValueTok */
-#define XML_TOK_ATTRIBUTE_VALUE_S 39
-
-/* The following token is returned only by XmlCdataSectionTok */
-#define XML_TOK_CDATA_SECT_CLOSE 40
-
-/* With namespace processing this is returned by XmlPrologTok
-   for a name with a colon. */
-#define XML_TOK_PREFIXED_NAME 41
-
-#ifdef XML_DTD
-#define XML_TOK_IGNORE_SECT 42
-#endif /* XML_DTD */
-
-#ifdef XML_DTD
-#define XML_N_STATES 4
-#else /* not XML_DTD */
-#define XML_N_STATES 3
-#endif /* not XML_DTD */
-
-#define XML_PROLOG_STATE 0
-#define XML_CONTENT_STATE 1
-#define XML_CDATA_SECTION_STATE 2
-#ifdef XML_DTD
-#define XML_IGNORE_SECTION_STATE 3
-#endif /* XML_DTD */
-
-#define XML_N_LITERAL_TYPES 2
-#define XML_ATTRIBUTE_VALUE_LITERAL 0
-#define XML_ENTITY_VALUE_LITERAL 1
-
-/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
-#define XML_UTF8_ENCODE_MAX 4
-/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
-#define XML_UTF16_ENCODE_MAX 2
-
-typedef struct position {
-  /* first line and first column are 0 not 1 */
-  unsigned long lineNumber;
-  unsigned long columnNumber;
-} POSITION;
-
-typedef struct {
-  const char *name;
-  const char *valuePtr;
-  const char *valueEnd;
-  char normalized;
-} ATTRIBUTE;
-
-struct encoding;
-typedef struct encoding ENCODING;
-
-struct encoding {
-  int (*scanners[XML_N_STATES])(const ENCODING *,
-                                const char *,
-                                const char *,
-                                const char **);
-  int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
-                                              const char *,
-                                              const char *,
-                                              const char **);
-  int (*sameName)(const ENCODING *,
-                  const char *, const char *);
-  int (*nameMatchesAscii)(const ENCODING *,
-                          const char *, const char *, const char *);
-  int (*nameLength)(const ENCODING *, const char *);
-  const char *(*skipS)(const ENCODING *, const char *);
-  int (*getAtts)(const ENCODING *enc, const char *ptr,
-                 int attsMax, ATTRIBUTE *atts);
-  int (*charRefNumber)(const ENCODING *enc, const char *ptr);
-  int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
-  void (*updatePosition)(const ENCODING *,
-                         const char *ptr,
-                         const char *end,
-                         POSITION *);
-  int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
-                    const char **badPtr);
-  void (*utf8Convert)(const ENCODING *enc,
-                      const char **fromP,
-                      const char *fromLim,
-                      char **toP,
-                      const char *toLim);
-  void (*utf16Convert)(const ENCODING *enc,
-                       const char **fromP,
-                       const char *fromLim,
-                       unsigned short **toP,
-                       const unsigned short *toLim);
-  int minBytesPerChar;
-  char isUtf8;
-  char isUtf16;
-};
-
-/*
-Scan the string starting at ptr until the end of the next complete token,
-but do not scan past eptr.  Return an integer giving the type of token.
-
-Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
-
-Return XML_TOK_PARTIAL when the string does not contain a complete token;
-nextTokPtr will not be set.
-
-Return XML_TOK_INVALID when the string does not start a valid token; nextTokPtr
-will be set to point to the character which made the token invalid.
-
-Otherwise the string starts with a valid token; nextTokPtr will be set to point
-to the character following the end of that token.
-
-Each data character counts as a single token, but adjacent data characters
-may be returned together.  Similarly for characters in the prolog outside
-literals, comments and processing instructions.
-*/
-
-
-#define XmlTok(enc, state, ptr, end, nextTokPtr) \
-  (((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
-
-#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
-   XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
-
-#define XmlContentTok(enc, ptr, end, nextTokPtr) \
-   XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
-
-#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
-   XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
-
-#ifdef XML_DTD
-
-#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
-   XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
-
-#endif /* XML_DTD */
-
-/* This is used for performing a 2nd-level tokenization on
-the content of a literal that has already been returned by XmlTok. */ 
-
-#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
-  (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
-
-#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
-   XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
-
-#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
-   XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
-
-#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
-
-#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
-  (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
-
-#define XmlNameLength(enc, ptr) \
-  (((enc)->nameLength)(enc, ptr))
-
-#define XmlSkipS(enc, ptr) \
-  (((enc)->skipS)(enc, ptr))
-
-#define XmlGetAttributes(enc, ptr, attsMax, atts) \
-  (((enc)->getAtts)(enc, ptr, attsMax, atts))
-
-#define XmlCharRefNumber(enc, ptr) \
-  (((enc)->charRefNumber)(enc, ptr))
-
-#define XmlPredefinedEntityName(enc, ptr, end) \
-  (((enc)->predefinedEntityName)(enc, ptr, end))
-
-#define XmlUpdatePosition(enc, ptr, end, pos) \
-  (((enc)->updatePosition)(enc, ptr, end, pos))
-
-#define XmlIsPublicId(enc, ptr, end, badPtr) \
-  (((enc)->isPublicId)(enc, ptr, end, badPtr))
-
-#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
-  (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
-
-#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
-  (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
-
-typedef struct {
-  ENCODING initEnc;
-  const ENCODING **encPtr;
-} INIT_ENCODING;
-
-int  XmlParseXmlDecl(int isGeneralTextEntity,
-                              const ENCODING *enc,
-                              const char *ptr,
-                              const char *end,
-                              const char **badPtr,
-                              const char **versionPtr,
-                              const char **versionEndPtr,
-                              const char **encodingNamePtr,
-                              const ENCODING **namedEncodingPtr,
-                              int *standalonePtr);
-
-int  XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
-const ENCODING  *XmlGetUtf8InternalEncoding(void);
-const ENCODING  *XmlGetUtf16InternalEncoding(void);
-int  XmlUtf8Encode(int charNumber, char *buf);
-int  XmlUtf16Encode(int charNumber, unsigned short *buf);
-
-int  XmlSizeOfUnknownEncoding(void);
-ENCODING  *
-XmlInitUnknownEncoding(void *mem,
-                       int *table,
-                       int (*conv)(void *userData, const char *p),
-                       void *userData);
-
-int  XmlParseXmlDeclNS(int isGeneralTextEntity,
-                                const ENCODING *enc,
-                                const char *ptr,
-                                const char *end,
-                                const char **badPtr,
-                                const char **versionPtr,
-                                const char **versionEndPtr,
-                                const char **encodingNamePtr,
-                                const ENCODING **namedEncodingPtr,
-                                int *standalonePtr);
-int  XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
-const ENCODING  *XmlGetUtf8InternalEncodingNS(void);
-const ENCODING  *XmlGetUtf16InternalEncodingNS(void);
-ENCODING  *
-XmlInitUnknownEncodingNS(void *mem,
-                         int *table,
-                         int (*conv)(void *userData, const char *p),
-                         void *userData);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not XmlTok_INCLUDED */
diff --git a/Utilities/cmexpat/xmltok_impl.c b/Utilities/cmexpat/xmltok_impl.c
deleted file mode 100644
index 6e0be95..0000000
--- a/Utilities/cmexpat/xmltok_impl.c
+++ /dev/null
@@ -1,1775 +0,0 @@
-/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
-*/
-
-#ifndef IS_INVALID_CHAR
-#define IS_INVALID_CHAR(enc, ptr, n) (0)
-#endif
-
-#ifndef INVALID_LEAD_CASE
-#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
-    case BT_LEAD ## n: \
-      if (end - ptr < n) \
-        return XML_TOK_PARTIAL_CHAR; \
-      if (IS_INVALID_CHAR(enc, ptr, n)) { \
-        *(nextTokPtr) = (ptr); \
-        return XML_TOK_INVALID; \
-      } \
-      ptr += n; \
-      break;
-#endif
-
-#define INVALID_CASES(ptr, nextTokPtr) \
-  INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
-  INVALID_LEAD_CASE(3, ptr, nextTokPtr) \
-  INVALID_LEAD_CASE(4, ptr, nextTokPtr) \
-  case BT_NONXML: \
-  case BT_MALFORM: \
-  case BT_TRAIL: \
-    *(nextTokPtr) = (ptr); \
-    return XML_TOK_INVALID;
-
-#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \
-   case BT_LEAD ## n: \
-     if (end - ptr < n) \
-       return XML_TOK_PARTIAL_CHAR; \
-     if (!IS_NAME_CHAR(enc, ptr, n)) { \
-       *nextTokPtr = ptr; \
-       return XML_TOK_INVALID; \
-     } \
-     ptr += n; \
-     break;
-
-#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \
-  case BT_NONASCII: \
-    if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \
-      *nextTokPtr = ptr; \
-      return XML_TOK_INVALID; \
-    } \
-  case BT_NMSTRT: \
-  case BT_HEX: \
-  case BT_DIGIT: \
-  case BT_NAME: \
-  case BT_MINUS: \
-    ptr += MINBPC(enc); \
-    break; \
-  CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \
-  CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \
-  CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr)
-
-#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
-   case BT_LEAD ## n: \
-     if (end - ptr < n) \
-       return XML_TOK_PARTIAL_CHAR; \
-     if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \
-       *nextTokPtr = ptr; \
-       return XML_TOK_INVALID; \
-     } \
-     ptr += n; \
-     break;
-
-#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \
-  case BT_NONASCII: \
-    if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \
-      *nextTokPtr = ptr; \
-      return XML_TOK_INVALID; \
-    } \
-  case BT_NMSTRT: \
-  case BT_HEX: \
-    ptr += MINBPC(enc); \
-    break; \
-  CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \
-  CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \
-  CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr)
-
-#ifndef PREFIX
-#define PREFIX(ident) ident
-#endif
-
-/* ptr points to character following "<!-" */
-
-static
-int PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
-                        const char **nextTokPtr)
-{
-  if (ptr != end) {
-    if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-    ptr += MINBPC(enc);
-    while (ptr != end) {
-      switch (BYTE_TYPE(enc, ptr)) {
-      INVALID_CASES(ptr, nextTokPtr)
-      case BT_MINUS:
-        if ((ptr += MINBPC(enc)) == end)
-          return XML_TOK_PARTIAL;
-        if (CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
-          if ((ptr += MINBPC(enc)) == end)
-            return XML_TOK_PARTIAL;
-          if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-            *nextTokPtr = ptr;
-            return XML_TOK_INVALID;
-          }
-          *nextTokPtr = ptr + MINBPC(enc);
-          return XML_TOK_COMMENT;
-        }
-        break;
-      default:
-        ptr += MINBPC(enc);
-        break;
-      }
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "<!" */
-
-static
-int PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end,
-                     const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  case BT_MINUS:
-    return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_LSQB:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_COND_SECT_OPEN;
-  case BT_NMSTRT:
-  case BT_HEX:
-    ptr += MINBPC(enc);
-    break;
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_PERCNT:
-      if (ptr + MINBPC(enc) == end)
-        return XML_TOK_PARTIAL;
-      /* don't allow <!ENTITY% foo "whatever"> */
-      switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) {
-      case BT_S: case BT_CR: case BT_LF: case BT_PERCNT:
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      /* fall through */
-    case BT_S: case BT_CR: case BT_LF:
-      *nextTokPtr = ptr;
-      return XML_TOK_DECL_OPEN;
-    case BT_NMSTRT:
-    case BT_HEX:
-      ptr += MINBPC(enc);
-      break;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr)
-{
-  int upper = 0;
-  cmExpatUnused(enc);
-  *tokPtr = XML_TOK_PI;
-  if (end - ptr != MINBPC(enc)*3)
-    return 1;
-  switch (BYTE_TO_ASCII(enc, ptr)) {
-  case ASCII_x:
-    break;
-  case ASCII_X:
-    upper = 1;
-    break;
-  default:
-    return 1;
-  }
-  ptr += MINBPC(enc);
-  switch (BYTE_TO_ASCII(enc, ptr)) {
-  case ASCII_m:
-    break;
-  case ASCII_M:
-    upper = 1;
-    break;
-  default:
-    return 1;
-  }
-  ptr += MINBPC(enc);
-  switch (BYTE_TO_ASCII(enc, ptr)) {
-  case ASCII_l:
-    break;
-  case ASCII_L:
-    upper = 1;
-    break;
-  default:
-    return 1;
-  }
-  if (upper)
-    return 0;
-  *tokPtr = XML_TOK_XML_DECL;
-  return 1;
-}
-
-/* ptr points to character following "<?" */
-
-static
-int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
-                   const char **nextTokPtr)
-{
-  int tok;
-  const char *target = ptr;
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-    case BT_S: case BT_CR: case BT_LF:
-      if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      ptr += MINBPC(enc);
-      while (ptr != end) {
-        switch (BYTE_TYPE(enc, ptr)) {
-        INVALID_CASES(ptr, nextTokPtr)
-        case BT_QUEST:
-          ptr += MINBPC(enc);
-          if (ptr == end)
-            return XML_TOK_PARTIAL;
-          if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-            *nextTokPtr = ptr + MINBPC(enc);
-            return tok;
-          }
-          break;
-        default:
-          ptr += MINBPC(enc);
-          break;
-        }
-      }
-      return XML_TOK_PARTIAL;
-    case BT_QUEST:
-      if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      ptr += MINBPC(enc);
-      if (ptr == end)
-        return XML_TOK_PARTIAL;
-      if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-        *nextTokPtr = ptr + MINBPC(enc);
-        return tok;
-      }
-      /* fall through */
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-
-static
-int PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end,
-                             const char **nextTokPtr)
-{
-  static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB };
-  int i;
-  cmExpatUnused(enc);
-  /* CDATA[ */
-  if (end - ptr < 6 * MINBPC(enc))
-    return XML_TOK_PARTIAL;
-  for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
-    if (!CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) {
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  *nextTokPtr = ptr;
-  return XML_TOK_CDATA_SECT_OPEN;
-}
-
-static
-int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
-                            const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_NONE;
-  if (MINBPC(enc) > 1) {
-    size_t n = end - ptr;
-    if (n & (MINBPC(enc) - 1)) {
-      n &= ~(MINBPC(enc) - 1);
-      if (n == 0)
-        return XML_TOK_PARTIAL;
-      end = ptr + n;
-    }
-  }
-  switch (BYTE_TYPE(enc, ptr)) {
-  case BT_RSQB:
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return XML_TOK_PARTIAL;
-    if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
-      break;
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return XML_TOK_PARTIAL;
-    if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-      ptr -= MINBPC(enc);
-      break;
-    }
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_CDATA_SECT_CLOSE;
-  case BT_CR:
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return XML_TOK_PARTIAL;
-    if (BYTE_TYPE(enc, ptr) == BT_LF)
-      ptr += MINBPC(enc);
-    *nextTokPtr = ptr;
-    return XML_TOK_DATA_NEWLINE;
-  case BT_LF:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_DATA_NEWLINE;
-  INVALID_CASES(ptr, nextTokPtr)
-  default:
-    ptr += MINBPC(enc);
-    break;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: \
-      if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
-        *nextTokPtr = ptr; \
-        return XML_TOK_DATA_CHARS; \
-      } \
-      ptr += n; \
-      break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_NONXML:
-    case BT_MALFORM:
-    case BT_TRAIL:
-    case BT_CR:
-    case BT_LF:
-    case BT_RSQB:
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-  }
-  *nextTokPtr = ptr;
-  return XML_TOK_DATA_CHARS;
-}
-
-/* ptr points to character following "</" */
-
-static
-int PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
-                       const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-    case BT_S: case BT_CR: case BT_LF:
-      for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) {
-        switch (BYTE_TYPE(enc, ptr)) {
-        case BT_S: case BT_CR: case BT_LF:
-          break;
-        case BT_GT:
-          *nextTokPtr = ptr + MINBPC(enc);
-          return XML_TOK_END_TAG;
-        default:
-          *nextTokPtr = ptr;
-          return XML_TOK_INVALID;
-        }
-      }
-      return XML_TOK_PARTIAL;
-#ifdef XML_NS
-    case BT_COLON:
-      /* no need to check qname syntax here, since end-tag must match exactly */
-      ptr += MINBPC(enc);
-      break;
-#endif
-    case BT_GT:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_END_TAG;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "&#X" */
-
-static
-int PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end,
-                           const char **nextTokPtr)
-{
-  if (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_DIGIT:
-    case BT_HEX:
-      break;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-    for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) {
-      switch (BYTE_TYPE(enc, ptr)) {
-      case BT_DIGIT:
-      case BT_HEX:
-        break;
-      case BT_SEMI:
-        *nextTokPtr = ptr + MINBPC(enc);
-        return XML_TOK_CHAR_REF;
-      default:
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "&#" */
-
-static
-int PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end,
-                        const char **nextTokPtr)
-{
-  if (ptr != end) {
-    if (CHAR_MATCHES(enc, ptr, ASCII_x))
-      return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_DIGIT:
-      break;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-    for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) {
-      switch (BYTE_TYPE(enc, ptr)) {
-      case BT_DIGIT:
-        break;
-      case BT_SEMI:
-        *nextTokPtr = ptr + MINBPC(enc);
-        return XML_TOK_CHAR_REF;
-      default:
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "&" */
-
-static
-int PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
-                    const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-  case BT_NUM:
-    return PREFIX(scanCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-    case BT_SEMI:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_ENTITY_REF;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following first character of attribute name */
-
-static
-int PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
-                     const char **nextTokPtr)
-{
-#ifdef XML_NS
-  int hadColon = 0;
-#endif
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-#ifdef XML_NS
-    case BT_COLON:
-      if (hadColon) {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      hadColon = 1;
-      ptr += MINBPC(enc);
-      if (ptr == end)
-        return XML_TOK_PARTIAL;
-      switch (BYTE_TYPE(enc, ptr)) {
-      CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-      default:
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      break;
-#endif
-    case BT_S: case BT_CR: case BT_LF:
-      for (;;) {
-        int t;
-
-        ptr += MINBPC(enc);
-        if (ptr == end)
-          return XML_TOK_PARTIAL;
-        t = BYTE_TYPE(enc, ptr);
-        if (t == BT_EQUALS)
-          break;
-        switch (t) {
-        case BT_S:
-        case BT_LF:
-        case BT_CR:
-          break;
-        default:
-          *nextTokPtr = ptr;
-          return XML_TOK_INVALID;
-        }
-      }
-    /* fall through */
-    case BT_EQUALS:
-      {
-        int open;
-#ifdef XML_NS
-        hadColon = 0;
-#endif
-        for (;;) {
-          
-          ptr += MINBPC(enc);
-          if (ptr == end)
-            return XML_TOK_PARTIAL;
-          open = BYTE_TYPE(enc, ptr);
-          if (open == BT_QUOT || open == BT_APOS)
-            break;
-          switch (open) {
-          case BT_S:
-          case BT_LF:
-          case BT_CR:
-            break;
-          default:
-            *nextTokPtr = ptr;
-            return XML_TOK_INVALID;
-          }
-        }
-        ptr += MINBPC(enc);
-        /* in attribute value */
-        for (;;) {
-          int t;
-          if (ptr == end)
-            return XML_TOK_PARTIAL;
-          t = BYTE_TYPE(enc, ptr);
-          if (t == open)
-            break;
-          switch (t) {
-          INVALID_CASES(ptr, nextTokPtr)
-          case BT_AMP:
-            {
-              int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr);
-              if (tok <= 0) {
-                if (tok == XML_TOK_INVALID)
-                  *nextTokPtr = ptr;
-                return tok;
-              }
-              break;
-            }
-          case BT_LT:
-            *nextTokPtr = ptr;
-            return XML_TOK_INVALID;
-          default:
-            ptr += MINBPC(enc);
-            break;
-          }
-        }
-        ptr += MINBPC(enc);
-        if (ptr == end)
-          return XML_TOK_PARTIAL;
-        switch (BYTE_TYPE(enc, ptr)) {
-        case BT_S:
-        case BT_CR:
-        case BT_LF:
-          break;
-        case BT_SOL:
-          goto sol;
-        case BT_GT:
-          goto gt;
-        default:
-          *nextTokPtr = ptr;
-          return XML_TOK_INVALID;
-        }
-        /* ptr points to closing quote */
-        for (;;) {
-          ptr += MINBPC(enc);
-          if (ptr == end)
-            return XML_TOK_PARTIAL;
-          switch (BYTE_TYPE(enc, ptr)) {
-          CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-          case BT_S: case BT_CR: case BT_LF:
-            continue;
-          case BT_GT:
-          gt:
-            *nextTokPtr = ptr + MINBPC(enc);
-            return XML_TOK_START_TAG_WITH_ATTS;
-          case BT_SOL:
-          sol:
-            ptr += MINBPC(enc);
-            if (ptr == end)
-              return XML_TOK_PARTIAL;
-            if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-              *nextTokPtr = ptr;
-              return XML_TOK_INVALID;
-            }
-            *nextTokPtr = ptr + MINBPC(enc);
-            return XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
-          default:
-            *nextTokPtr = ptr;
-            return XML_TOK_INVALID;
-          }
-          break;
-        }
-        break;
-      }
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "<" */
-
-static
-int PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
-                   const char **nextTokPtr)
-{
-#ifdef XML_NS
-  int hadColon;
-#endif
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-  case BT_EXCL:
-    if ((ptr += MINBPC(enc)) == end)
-      return XML_TOK_PARTIAL;
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_MINUS:
-      return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-    case BT_LSQB:
-      return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-    }
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  case BT_QUEST:
-    return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_SOL:
-    return PREFIX(scanEndTag)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-#ifdef XML_NS
-  hadColon = 0;
-#endif
-  /* we have a start-tag */
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-#ifdef XML_NS
-    case BT_COLON:
-      if (hadColon) {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      hadColon = 1;
-      ptr += MINBPC(enc);
-      if (ptr == end)
-        return XML_TOK_PARTIAL;
-      switch (BYTE_TYPE(enc, ptr)) {
-      CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-      default:
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      break;
-#endif
-    case BT_S: case BT_CR: case BT_LF:
-      {
-        ptr += MINBPC(enc);
-        while (ptr != end) {
-          switch (BYTE_TYPE(enc, ptr)) {
-          CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-          case BT_GT:
-            goto gt;
-          case BT_SOL:
-            goto sol;
-          case BT_S: case BT_CR: case BT_LF:
-            ptr += MINBPC(enc);
-            continue;
-          default:
-            *nextTokPtr = ptr;
-            return XML_TOK_INVALID;
-          }
-          return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr);
-        }
-        return XML_TOK_PARTIAL;
-      }
-    case BT_GT:
-    gt:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_START_TAG_NO_ATTS;
-    case BT_SOL:
-    sol:
-      ptr += MINBPC(enc);
-      if (ptr == end)
-        return XML_TOK_PARTIAL;
-      if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_EMPTY_ELEMENT_NO_ATTS;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
-                       const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_NONE;
-  if (MINBPC(enc) > 1) {
-    size_t n = end - ptr;
-    if (n & (MINBPC(enc) - 1)) {
-      n &= ~(MINBPC(enc) - 1);
-      if (n == 0)
-        return XML_TOK_PARTIAL;
-      end = ptr + n;
-    }
-  }
-  switch (BYTE_TYPE(enc, ptr)) {
-  case BT_LT:
-    return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_AMP:
-    return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_CR:
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return XML_TOK_TRAILING_CR;
-    if (BYTE_TYPE(enc, ptr) == BT_LF)
-      ptr += MINBPC(enc);
-    *nextTokPtr = ptr;
-    return XML_TOK_DATA_NEWLINE;
-  case BT_LF:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_DATA_NEWLINE;
-  case BT_RSQB:
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return XML_TOK_TRAILING_RSQB;
-    if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
-      break;
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return XML_TOK_TRAILING_RSQB;
-    if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-      ptr -= MINBPC(enc);
-      break;
-    }
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  INVALID_CASES(ptr, nextTokPtr)
-  default:
-    ptr += MINBPC(enc);
-    break;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: \
-      if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
-        *nextTokPtr = ptr; \
-        return XML_TOK_DATA_CHARS; \
-      } \
-      ptr += n; \
-      break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_RSQB:
-      if (ptr + MINBPC(enc) != end) {
-         if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) {
-           ptr += MINBPC(enc);
-           break;
-         }
-         if (ptr + 2*MINBPC(enc) != end) {
-           if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) {
-             ptr += MINBPC(enc);
-             break;
-           }
-           *nextTokPtr = ptr + 2*MINBPC(enc);
-           return XML_TOK_INVALID;
-         }
-      }
-      /* fall through */
-    case BT_AMP:
-    case BT_LT:
-    case BT_NONXML:
-    case BT_MALFORM:
-    case BT_TRAIL:
-    case BT_CR:
-    case BT_LF:
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-  }
-  *nextTokPtr = ptr;
-  return XML_TOK_DATA_CHARS;
-}
-
-/* ptr points to character following "%" */
-
-static
-int PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
-                        const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-  case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
-    *nextTokPtr = ptr;
-    return XML_TOK_PERCENT;
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-    case BT_SEMI:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_PARAM_ENTITY_REF;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
-                          const char **nextTokPtr)
-{
-  if (ptr == end)
-    return XML_TOK_PARTIAL;
-  switch (BYTE_TYPE(enc, ptr)) {
-  CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-    case BT_CR: case BT_LF: case BT_S:
-    case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR:
-      *nextTokPtr = ptr;
-      return XML_TOK_POUND_NAME;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return -XML_TOK_POUND_NAME;
-}
-
-static
-int PREFIX(scanLit)(int open, const ENCODING *enc,
-                    const char *ptr, const char *end,
-                    const char **nextTokPtr)
-{
-  while (ptr != end) {
-    int t = BYTE_TYPE(enc, ptr);
-    switch (t) {
-    INVALID_CASES(ptr, nextTokPtr)
-    case BT_QUOT:
-    case BT_APOS:
-      ptr += MINBPC(enc);
-      if (t != open)
-        break;
-      if (ptr == end)
-        return -XML_TOK_LITERAL;
-      *nextTokPtr = ptr;
-      switch (BYTE_TYPE(enc, ptr)) {
-      case BT_S: case BT_CR: case BT_LF:
-      case BT_GT: case BT_PERCNT: case BT_LSQB:
-        return XML_TOK_LITERAL;
-      default:
-        return XML_TOK_INVALID;
-      }
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
-                      const char **nextTokPtr)
-{
-  int tok;
-  if (ptr == end)
-    return XML_TOK_NONE;
-  if (MINBPC(enc) > 1) {
-    size_t n = end - ptr;
-    if (n & (MINBPC(enc) - 1)) {
-      n &= ~(MINBPC(enc) - 1);
-      if (n == 0)
-        return XML_TOK_PARTIAL;
-      end = ptr + n;
-    }
-  }
-  switch (BYTE_TYPE(enc, ptr)) {
-  case BT_QUOT:
-    return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_APOS:
-    return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_LT:
-    {
-      ptr += MINBPC(enc);
-      if (ptr == end)
-        return XML_TOK_PARTIAL;
-      switch (BYTE_TYPE(enc, ptr)) {
-      case BT_EXCL:
-        return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-      case BT_QUEST:
-        return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-      case BT_NMSTRT:
-      case BT_HEX:
-      case BT_NONASCII:
-      case BT_LEAD2:
-      case BT_LEAD3:
-      case BT_LEAD4:
-        *nextTokPtr = ptr - MINBPC(enc);
-        return XML_TOK_INSTANCE_START;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  case BT_CR:
-    if (ptr + MINBPC(enc) == end)
-      return -XML_TOK_PROLOG_S;
-    /* fall through */
-  case BT_S: case BT_LF:
-    for (;;) {
-      ptr += MINBPC(enc);
-      if (ptr == end)
-        break;
-      switch (BYTE_TYPE(enc, ptr)) {
-      case BT_S: case BT_LF:
-        break;
-      case BT_CR:
-        /* don't split CR/LF pair */
-        if (ptr + MINBPC(enc) != end)
-          break;
-        /* fall through */
-      default:
-        *nextTokPtr = ptr;
-        return XML_TOK_PROLOG_S;
-      }
-    }
-    *nextTokPtr = ptr;
-    return XML_TOK_PROLOG_S;
-  case BT_PERCNT:
-    return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-  case BT_COMMA:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_COMMA;
-  case BT_LSQB:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_OPEN_BRACKET;
-  case BT_RSQB:
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return -XML_TOK_CLOSE_BRACKET;
-    if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
-      if (ptr + MINBPC(enc) == end)
-        return XML_TOK_PARTIAL;
-      if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) {
-        *nextTokPtr = ptr + 2*MINBPC(enc);
-        return XML_TOK_COND_SECT_CLOSE;
-      }
-    }
-    *nextTokPtr = ptr;
-    return XML_TOK_CLOSE_BRACKET;
-  case BT_LPAR:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_OPEN_PAREN;
-  case BT_RPAR:
-    ptr += MINBPC(enc);
-    if (ptr == end)
-      return -XML_TOK_CLOSE_PAREN;
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_AST:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_CLOSE_PAREN_ASTERISK;
-    case BT_QUEST:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_CLOSE_PAREN_QUESTION;
-    case BT_PLUS:
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_CLOSE_PAREN_PLUS;
-    case BT_CR: case BT_LF: case BT_S:
-    case BT_GT: case BT_COMMA: case BT_VERBAR:
-    case BT_RPAR:
-      *nextTokPtr = ptr;
-      return XML_TOK_CLOSE_PAREN;
-    }
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  case BT_VERBAR:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_OR;
-  case BT_GT:
-    *nextTokPtr = ptr + MINBPC(enc);
-    return XML_TOK_DECL_CLOSE;
-  case BT_NUM:
-    return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-#define LEAD_CASE(n) \
-  case BT_LEAD ## n: \
-    if (end - ptr < n) \
-      return XML_TOK_PARTIAL_CHAR; \
-    if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
-      ptr += n; \
-      tok = XML_TOK_NAME; \
-      break; \
-    } \
-    if (IS_NAME_CHAR(enc, ptr, n)) { \
-      ptr += n; \
-      tok = XML_TOK_NMTOKEN; \
-      break; \
-    } \
-    *nextTokPtr = ptr; \
-    return XML_TOK_INVALID;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-  case BT_NMSTRT:
-  case BT_HEX:
-    tok = XML_TOK_NAME;
-    ptr += MINBPC(enc);
-    break;
-  case BT_DIGIT:
-  case BT_NAME:
-  case BT_MINUS:
-#ifdef XML_NS
-  case BT_COLON:
-#endif
-    tok = XML_TOK_NMTOKEN;
-    ptr += MINBPC(enc);
-    break;
-  case BT_NONASCII:
-    if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) {
-      ptr += MINBPC(enc);
-      tok = XML_TOK_NAME;
-      break;
-    }
-    if (IS_NAME_CHAR_MINBPC(enc, ptr)) {
-      ptr += MINBPC(enc);
-      tok = XML_TOK_NMTOKEN;
-      break;
-    }
-    /* fall through */
-  default:
-    *nextTokPtr = ptr;
-    return XML_TOK_INVALID;
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-    case BT_GT: case BT_RPAR: case BT_COMMA:
-    case BT_VERBAR: case BT_LSQB: case BT_PERCNT:
-    case BT_S: case BT_CR: case BT_LF:
-      *nextTokPtr = ptr;
-      return tok;
-#ifdef XML_NS
-    case BT_COLON:
-      ptr += MINBPC(enc);
-      switch (tok) {
-      case XML_TOK_NAME:
-        if (ptr == end)
-          return XML_TOK_PARTIAL;
-        tok = XML_TOK_PREFIXED_NAME;
-        switch (BYTE_TYPE(enc, ptr)) {
-        CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-        default:
-          tok = XML_TOK_NMTOKEN;
-          break;
-        }
-        break;
-      case XML_TOK_PREFIXED_NAME:
-        tok = XML_TOK_NMTOKEN;
-        break;
-      }
-      break;
-#endif
-    case BT_PLUS:
-      if (tok == XML_TOK_NMTOKEN)  {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_NAME_PLUS;
-    case BT_AST:
-      if (tok == XML_TOK_NMTOKEN)  {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_NAME_ASTERISK;
-    case BT_QUEST:
-      if (tok == XML_TOK_NMTOKEN)  {
-        *nextTokPtr = ptr;
-        return XML_TOK_INVALID;
-      }
-      *nextTokPtr = ptr + MINBPC(enc);
-      return XML_TOK_NAME_QUESTION;
-    default:
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    }
-  }
-  return -tok;
-}
-
-static
-int PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
-                              const char **nextTokPtr)
-{
-  const char *start;
-  if (ptr == end)
-    return XML_TOK_NONE;
-  start = ptr;
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: ptr += n; break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_AMP:
-      if (ptr == start)
-        return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    case BT_LT:
-      /* this is for inside entity references */
-      *nextTokPtr = ptr;
-      return XML_TOK_INVALID;
-    case BT_LF:
-      if (ptr == start) {
-        *nextTokPtr = ptr + MINBPC(enc);
-        return XML_TOK_DATA_NEWLINE;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    case BT_CR:
-      if (ptr == start) {
-        ptr += MINBPC(enc);
-        if (ptr == end)
-          return XML_TOK_TRAILING_CR;
-        if (BYTE_TYPE(enc, ptr) == BT_LF)
-          ptr += MINBPC(enc);
-        *nextTokPtr = ptr;
-        return XML_TOK_DATA_NEWLINE;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    case BT_S:
-      if (ptr == start) {
-        *nextTokPtr = ptr + MINBPC(enc);
-        return XML_TOK_ATTRIBUTE_VALUE_S;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-  }
-  *nextTokPtr = ptr;
-  return XML_TOK_DATA_CHARS;
-}
-
-static
-int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
-                           const char **nextTokPtr)
-{
-  const char *start;
-  if (ptr == end)
-    return XML_TOK_NONE;
-  start = ptr;
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: ptr += n; break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_AMP:
-      if (ptr == start)
-        return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    case BT_PERCNT:
-      if (ptr == start) {
-        int tok =  PREFIX(scanPercent)(enc, ptr + MINBPC(enc),
-                                       end, nextTokPtr);
-        return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    case BT_LF:
-      if (ptr == start) {
-        *nextTokPtr = ptr + MINBPC(enc);
-        return XML_TOK_DATA_NEWLINE;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    case BT_CR:
-      if (ptr == start) {
-        ptr += MINBPC(enc);
-        if (ptr == end)
-          return XML_TOK_TRAILING_CR;
-        if (BYTE_TYPE(enc, ptr) == BT_LF)
-          ptr += MINBPC(enc);
-        *nextTokPtr = ptr;
-        return XML_TOK_DATA_NEWLINE;
-      }
-      *nextTokPtr = ptr;
-      return XML_TOK_DATA_CHARS;
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-  }
-  *nextTokPtr = ptr;
-  return XML_TOK_DATA_CHARS;
-}
-
-#ifdef XML_DTD
-
-static
-int PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
-                             const char **nextTokPtr)
-{
-  int level = 0;
-  if (MINBPC(enc) > 1) {
-    size_t n = end - ptr;
-    if (n & (MINBPC(enc) - 1)) {
-      n &= ~(MINBPC(enc) - 1);
-      end = ptr + n;
-    }
-  }
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    INVALID_CASES(ptr, nextTokPtr)
-    case BT_LT:
-      if ((ptr += MINBPC(enc)) == end)
-        return XML_TOK_PARTIAL;
-      if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) {
-        if ((ptr += MINBPC(enc)) == end)
-          return XML_TOK_PARTIAL;
-        if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) {
-          ++level;
-          ptr += MINBPC(enc);
-        }
-      }
-      break;
-    case BT_RSQB:
-      if ((ptr += MINBPC(enc)) == end)
-        return XML_TOK_PARTIAL;
-      if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
-        if ((ptr += MINBPC(enc)) == end)
-          return XML_TOK_PARTIAL;
-        if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
-          ptr += MINBPC(enc);
-          if (level == 0) {
-            *nextTokPtr = ptr;
-            return XML_TOK_IGNORE_SECT;
-          }
-          --level;
-        }
-      }
-      break;
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-  }
-  return XML_TOK_PARTIAL;
-}
-
-#endif /* XML_DTD */
-
-static
-int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
-                       const char **badPtr)
-{
-  ptr += MINBPC(enc);
-  end -= MINBPC(enc);
-  for (; ptr != end; ptr += MINBPC(enc)) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_DIGIT:
-    case BT_HEX:
-    case BT_MINUS:
-    case BT_APOS:
-    case BT_LPAR:
-    case BT_RPAR:
-    case BT_PLUS:
-    case BT_COMMA:
-    case BT_SOL:
-    case BT_EQUALS:
-    case BT_QUEST:
-    case BT_CR:
-    case BT_LF:
-    case BT_SEMI:
-    case BT_EXCL:
-    case BT_AST:
-    case BT_PERCNT:
-    case BT_NUM:
-#ifdef XML_NS
-    case BT_COLON:
-#endif
-      break;
-    case BT_S:
-      if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) {
-        *badPtr = ptr;
-        return 0;
-      }
-      break;
-    case BT_NAME:
-    case BT_NMSTRT:
-      if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
-        break;
-    default:
-      switch (BYTE_TO_ASCII(enc, ptr)) {
-      case 0x24: /* $ */
-      case 0x40: /* @ */
-        break;
-      default:
-        *badPtr = ptr;
-        return 0;
-      }
-      break;
-    }
-  }
-  return 1;
-}
-
-/* This must only be called for a well-formed start-tag or empty element tag.
-Returns the number of attributes.  Pointers to the first attsMax attributes 
-are stored in atts. */
-
-static
-int PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
-                    int attsMax, ATTRIBUTE *atts)
-{
-  enum { other, inName, inValue } state = inName;
-  int nAtts = 0;
-  int open = 0; /* defined when state == inValue;
-                   initialization just to shut up compilers */
-
-  for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define START_NAME \
-      if (state == other) { \
-        if (nAtts < attsMax) { \
-          atts[nAtts].name = ptr; \
-          atts[nAtts].normalized = 1; \
-        } \
-        state = inName; \
-      }
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_NONASCII:
-    case BT_NMSTRT:
-    case BT_HEX:
-      START_NAME
-      break;
-#undef START_NAME
-    case BT_QUOT:
-      if (state != inValue) {
-        if (nAtts < attsMax)
-          atts[nAtts].valuePtr = ptr + MINBPC(enc);
-        state = inValue;
-        open = BT_QUOT;
-      }
-      else if (open == BT_QUOT) {
-        state = other;
-        if (nAtts < attsMax)
-          atts[nAtts].valueEnd = ptr;
-        nAtts++;
-      }
-      break;
-    case BT_APOS:
-      if (state != inValue) {
-        if (nAtts < attsMax)
-          atts[nAtts].valuePtr = ptr + MINBPC(enc);
-        state = inValue;
-        open = BT_APOS;
-      }
-      else if (open == BT_APOS) {
-        state = other;
-        if (nAtts < attsMax)
-          atts[nAtts].valueEnd = ptr;
-        nAtts++;
-      }
-      break;
-    case BT_AMP:
-      if (nAtts < attsMax)
-        atts[nAtts].normalized = 0;
-      break;
-    case BT_S:
-      if (state == inName)
-        state = other;
-      else if (state == inValue
-               && nAtts < attsMax
-               && atts[nAtts].normalized
-               && (ptr == atts[nAtts].valuePtr
-                   || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE
-                   || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE
-                   || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
-        atts[nAtts].normalized = 0;
-      break;
-    case BT_CR: case BT_LF:
-      /* This case ensures that the first attribute name is counted
-         Apart from that we could just change state on the quote. */
-      if (state == inName)
-        state = other;
-      else if (state == inValue && nAtts < attsMax)
-        atts[nAtts].normalized = 0;
-      break;
-    case BT_GT:
-    case BT_SOL:
-      if (state != inValue)
-        return nAtts;
-      break;
-    default:
-      break;
-    }
-  }
-  /* not reached */
-}
-
-static
-int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
-{
-  int result = 0;
-  cmExpatUnused(enc);
-  /* skip &# */
-  ptr += 2*MINBPC(enc);
-  if (CHAR_MATCHES(enc, ptr, ASCII_x)) {
-    for (ptr += MINBPC(enc); !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
-      int c = BYTE_TO_ASCII(enc, ptr);
-      switch (c) {
-      case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4:
-      case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9:
-        result <<= 4;
-        result |= (c - ASCII_0);
-        break;
-      case ASCII_A: case ASCII_B: case ASCII_C: case ASCII_D: case ASCII_E: case ASCII_F:
-        result <<= 4;
-        result += 10 + (c - ASCII_A);
-        break;
-      case ASCII_a: case ASCII_b: case ASCII_c: case ASCII_d: case ASCII_e: case ASCII_f:
-        result <<= 4;
-        result += 10 + (c - ASCII_a);
-        break;
-      }
-      if (result >= 0x110000)
-        return -1;
-    }
-  }
-  else {
-    for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
-      int c = BYTE_TO_ASCII(enc, ptr);
-      result *= 10;
-      result += (c - ASCII_0);
-      if (result >= 0x110000)
-        return -1;
-    }
-  }
-  return checkCharRefNumber(result);
-}
-
-static
-int PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end)
-{
-  cmExpatUnused(enc);
-  switch ((end - ptr)/MINBPC(enc)) {
-  case 2:
-    if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) {
-      switch (BYTE_TO_ASCII(enc, ptr)) {
-      case ASCII_l:
-        return ASCII_LT;
-      case ASCII_g:
-        return ASCII_GT;
-      }
-    }
-    break;
-  case 3:
-    if (CHAR_MATCHES(enc, ptr, ASCII_a)) {
-      ptr += MINBPC(enc);
-      if (CHAR_MATCHES(enc, ptr, ASCII_m)) {
-        ptr += MINBPC(enc);
-        if (CHAR_MATCHES(enc, ptr, ASCII_p))
-          return ASCII_AMP;
-      }
-    }
-    break;
-  case 4:
-    switch (BYTE_TO_ASCII(enc, ptr)) {
-    case ASCII_q:
-      ptr += MINBPC(enc);
-      if (CHAR_MATCHES(enc, ptr, ASCII_u)) {
-        ptr += MINBPC(enc);
-        if (CHAR_MATCHES(enc, ptr, ASCII_o)) {
-          ptr += MINBPC(enc);
-          if (CHAR_MATCHES(enc, ptr, ASCII_t))
-            return ASCII_QUOT;
-        }
-      }
-      break;
-    case ASCII_a:
-      ptr += MINBPC(enc);
-      if (CHAR_MATCHES(enc, ptr, ASCII_p)) {
-        ptr += MINBPC(enc);
-        if (CHAR_MATCHES(enc, ptr, ASCII_o)) {
-          ptr += MINBPC(enc);
-          if (CHAR_MATCHES(enc, ptr, ASCII_s))
-            return ASCII_APOS;
-        }
-      }
-      break;
-    }
-  }
-  return 0;
-}
-
-static
-int PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
-{
-  for (;;) {
-    switch (BYTE_TYPE(enc, ptr1)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: \
-      if (*ptr1++ != *ptr2++) \
-        return 0;
-    LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
-#undef LEAD_CASE
-      /* fall through */
-      if (*ptr1++ != *ptr2++)
-        return 0;
-      break;
-    case BT_NONASCII:
-    case BT_NMSTRT:
-#ifdef XML_NS
-    case BT_COLON:
-#endif
-    case BT_HEX:
-    case BT_DIGIT:
-    case BT_NAME:
-    case BT_MINUS:
-      if (*ptr2++ != *ptr1++)
-        return 0;
-      if (MINBPC(enc) > 1) {
-        if (*ptr2++ != *ptr1++)
-          return 0;
-        if (MINBPC(enc) > 2) {
-          if (*ptr2++ != *ptr1++)
-            return 0;
-          if (MINBPC(enc) > 3) {
-            if (*ptr2++ != *ptr1++)
-              return 0;
-          }
-        }
-      }
-      break;
-    default:
-      if (MINBPC(enc) == 1 && *ptr1 == *ptr2)
-        return 1;
-      switch (BYTE_TYPE(enc, ptr2)) {
-      case BT_LEAD2:
-      case BT_LEAD3:
-      case BT_LEAD4:
-      case BT_NONASCII:
-      case BT_NMSTRT:
-#ifdef XML_NS
-      case BT_COLON:
-#endif
-      case BT_HEX:
-      case BT_DIGIT:
-      case BT_NAME:
-      case BT_MINUS:
-        return 0;
-      default:
-        return 1;
-      }
-    }
-  }
-  /* not reached */
-}
-
-static
-int PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1,
-                             const char *end1, const char *ptr2)
-{
-  cmExpatUnused(enc);
-  for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
-    if (ptr1 == end1)
-      return 0;
-    if (!CHAR_MATCHES(enc, ptr1, *ptr2))
-      return 0;
-  }
-  return ptr1 == end1;
-}
-
-static
-int PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
-{
-  const char *start = ptr;
-  for (;;) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: ptr += n; break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_NONASCII:
-    case BT_NMSTRT:
-#ifdef XML_NS
-    case BT_COLON:
-#endif
-    case BT_HEX:
-    case BT_DIGIT:
-    case BT_NAME:
-    case BT_MINUS:
-      ptr += MINBPC(enc);
-      break;
-    default:
-      return ptr - start;
-    }
-  }
-}
-
-static
-const char *PREFIX(skipS)(const ENCODING *enc, const char *ptr)
-{
-  for (;;) {
-    switch (BYTE_TYPE(enc, ptr)) {
-    case BT_LF:
-    case BT_CR:
-    case BT_S:
-      ptr += MINBPC(enc);
-      break;
-    default:
-      return ptr;
-    }
-  }
-}
-
-static
-void PREFIX(updatePosition)(const ENCODING *enc,
-                            const char *ptr,
-                            const char *end,
-                            POSITION *pos)
-{
-  while (ptr != end) {
-    switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
-    case BT_LEAD ## n: \
-      ptr += n; \
-      break;
-    LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
-    case BT_LF:
-      pos->columnNumber = (unsigned)-1;
-      pos->lineNumber++;
-      ptr += MINBPC(enc);
-      break;
-    case BT_CR:
-      pos->lineNumber++;
-      ptr += MINBPC(enc);
-      if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF)
-        ptr += MINBPC(enc);
-      pos->columnNumber = (unsigned)-1;
-      break;
-    default:
-      ptr += MINBPC(enc);
-      break;
-    }
-    pos->columnNumber++;
-  }
-}
-
-#undef DO_LEAD_CASE
-#undef MULTIBYTE_CASES
-#undef INVALID_CASES
-#undef CHECK_NAME_CASE
-#undef CHECK_NAME_CASES
-#undef CHECK_NMSTRT_CASE
-#undef CHECK_NMSTRT_CASES
diff --git a/Utilities/cmexpat/xmltok_ns.c b/Utilities/cmexpat/xmltok_ns.c
deleted file mode 100644
index fa78adf..0000000
--- a/Utilities/cmexpat/xmltok_ns.c
+++ /dev/null
@@ -1,98 +0,0 @@
-const ENCODING *NS(XmlGetUtf8InternalEncoding)(void)
-{
-  return &ns(internal_utf8_encoding).enc;
-}
-
-const ENCODING *NS(XmlGetUtf16InternalEncoding)(void)
-{
-#if XML_BYTE_ORDER == 12
-  return &ns(internal_little2_encoding).enc;
-#elif XML_BYTE_ORDER == 21
-  return &ns(internal_big2_encoding).enc;
-#else
-  const short n = 1;
-  return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
-#endif
-}
-
-static
-const ENCODING *NS(encodings)[] = {
-  &ns(latin1_encoding).enc,
-  &ns(ascii_encoding).enc,
-  &ns(utf8_encoding).enc,
-  &ns(big2_encoding).enc,
-  &ns(big2_encoding).enc,
-  &ns(little2_encoding).enc,
-  &ns(utf8_encoding).enc /* NO_ENC */
-};
-
-static
-int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
-                       const char **nextTokPtr)
-{
-  return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
-}
-
-static
-int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
-                       const char **nextTokPtr)
-{
-  return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
-}
-
-int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
-{
-  int i = getEncodingIndex(name);
-  if (i == UNKNOWN_ENC)
-    return 0;
-  SET_INIT_ENC_INDEX(p, i);
-  p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
-  p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
-  p->initEnc.updatePosition = initUpdatePosition;
-  p->encPtr = encPtr;
-  *encPtr = &(p->initEnc);
-  return 1;
-}
-
-static
-const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
-{
-#define ENCODING_MAX 128
-  char buf[ENCODING_MAX];
-  char *p = buf;
-  int i;
-  XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
-  if (ptr != end)
-    return 0;
-  *p = 0;
-  if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
-    return enc;
-  i = getEncodingIndex(buf);
-  if (i == UNKNOWN_ENC)
-    return 0;
-  return NS(encodings)[i];
-}
-
-int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
-                        const ENCODING *enc,
-                        const char *ptr,
-                        const char *end,
-                        const char **badPtr,
-                        const char **versionPtr,
-                        const char **versionEndPtr,
-                        const char **encodingName,
-                        const ENCODING **encoding,
-                        int *standalone)
-{
-  return doParseXmlDecl(NS(findEncoding),
-                        isGeneralTextEntity,
-                        enc,
-                        ptr,
-                        end,
-                        badPtr,
-                        versionPtr,
-                        versionEndPtr,
-                        encodingName,
-                        encoding,
-                        standalone);
-}
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 00550e2..09bef51 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -86,12 +86,10 @@ OPTION(ENABLE_ACL "Enable ACL support" ON)
 OPTION(ENABLE_ICONV "Enable iconv support" ON)
 
 IF(WIN32)
-  IF(MSVC60)
-    SET(WINVER 0x0400)
-  ELSE()
-    SET(WINVER 0x0500)
-  ENDIF()
-  SET(_WIN32_WINNT ${WINVER})
+  #ELSEIF(WINDOWS_VERSION STREQUAL "WINXP")
+  SET(NTDDI_VERSION 0x05010000)
+  SET(_WIN32_WINNT 0x0501)
+  SET(WINVER 0x0501)
 ENDIF(WIN32)
 
 set(HAVE_PTHREAD_H 0) # no threads in CMake
@@ -200,7 +198,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
   #   e.g.
   #     cmake -DCMAKE_PREFIX_PATH=<your-GnuWin32-path> <path-to-source>
   #
-  # If compiling error occured in zconf.h, You may need patch to zconf.h.
+  # If compiling error occurred in zconf.h, You may need patch to zconf.h.
   #--- zconf.h.orig	2005-07-21 00:40:26.000000000
   #+++ zconf.h	2009-01-19 11:39:10.093750000
   #@@ -286,7 +286,7 @@
@@ -487,12 +485,17 @@ IF(ENABLE_NETTLE)
   FIND_PACKAGE(Nettle)
   IF(NETTLE_FOUND)
     SET(HAVE_LIBNETTLE 1)
-    SET(HAVE_NETTLE_MD5_H 1)
-    SET(HAVE_NETTLE_RIPEMD160_H 1)
-    SET(HAVE_NETTLE_SHA_H 1)
-    INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR})
     LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES})
+    INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR})
+
+    LIST(APPEND CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIR})
+    LA_CHECK_INCLUDE_FILE("nettle/aes.h" HAVE_NETTLE_AES_H)
+    LA_CHECK_INCLUDE_FILE("nettle/hmac.h" HAVE_NETTLE_HMAC_H)
+    LA_CHECK_INCLUDE_FILE("nettle/md5.h" HAVE_NETTLE_MD5_H)
     LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H)
+    LA_CHECK_INCLUDE_FILE("nettle/ripemd160.h" HAVE_NETTLE_RIPEMD160_H)
+    LA_CHECK_INCLUDE_FILE("nettle/sha.h" HAVE_NETTLE_SHA_H)
+
   ENDIF(NETTLE_FOUND)
   MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR)
   MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES)
@@ -506,6 +509,7 @@ IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
   FIND_PACKAGE(OpenSSL)
   IF(OPENSSL_FOUND)
     SET(HAVE_LIBCRYPTO 1)
+    INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
   ENDIF(OPENSSL_FOUND)
 ELSE()
   SET(OPENSSL_FOUND FALSE) # Override cached value
@@ -723,6 +727,9 @@ MACRO(CHECK_ICONV LIB TRY_ICONV_CONST)
       #
       SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
     ENDIF ()
+    IF (CMAKE_C_COMPILER_ID STREQUAL "XL")
+      SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -qhalt=w -qflag=w:w")
+    ENDIF ()
     IF (MSVC)
       # NOTE: /WX option is the same as gcc's -Werror option.
       SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX")
@@ -1040,10 +1047,15 @@ ENDIF(HAVE_INTTYPES_H)
 CHECK_SYMBOL_EXISTS(EFTYPE           "errno.h"    HAVE_EFTYPE)
 CHECK_SYMBOL_EXISTS(EILSEQ           "errno.h"    HAVE_EILSEQ)
 CHECK_SYMBOL_EXISTS(D_MD_ORDER       "langinfo.h" HAVE_D_MD_ORDER)
+CHECK_SYMBOL_EXISTS(INT32_MAX        "${headers}" HAVE_DECL_INT32_MAX)
+CHECK_SYMBOL_EXISTS(INT32_MIN        "${headers}" HAVE_DECL_INT32_MIN)
 CHECK_SYMBOL_EXISTS(INT64_MAX        "${headers}" HAVE_DECL_INT64_MAX)
 CHECK_SYMBOL_EXISTS(INT64_MIN        "${headers}" HAVE_DECL_INT64_MIN)
+CHECK_SYMBOL_EXISTS(INTMAX_MAX       "${headers}" HAVE_DECL_INTMAX_MAX)
+CHECK_SYMBOL_EXISTS(INTMAX_MIN       "${headers}" HAVE_DECL_INTMAX_MIN)
 CHECK_SYMBOL_EXISTS(UINT32_MAX       "${headers}" HAVE_DECL_UINT32_MAX)
 CHECK_SYMBOL_EXISTS(UINT64_MAX       "${headers}" HAVE_DECL_UINT64_MAX)
+CHECK_SYMBOL_EXISTS(UINTMAX_MAX      "${headers}" HAVE_DECL_UINTMAX_MAX)
 CHECK_SYMBOL_EXISTS(SIZE_MAX         "${headers}" HAVE_DECL_SIZE_MAX)
 CHECK_SYMBOL_EXISTS(SSIZE_MAX        "limits.h"   HAVE_DECL_SSIZE_MAX)
 
diff --git a/Utilities/cmlibarchive/README-CMake.txt b/Utilities/cmlibarchive/README-CMake.txt
deleted file mode 100644
index 0a3e34a..0000000
--- a/Utilities/cmlibarchive/README-CMake.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-The Utilities/cmlibarchive directory contains a reduced distribution
-of the libarchive source tree with only the library source code and
-CMake build system.  It is not a submodule; the actual content is part
-of our source tree and changes can be made and committed directly.
-
-We update from upstream using Git's "subtree" merge strategy.  A
-special branch contains commits of upstream libarchive snapshots and
-nothing else.  No Git ref points explicitly to the head of this
-branch, but it is merged into our history.
-
-Update libarchive from upstream as follows.  Create a local branch to
-explicitly reference the upstream snapshot branch head:
-
- git branch libarchive-upstream 1a8c7bc2
-
-Use a temporary directory to checkout the branch:
-
- mkdir libarchive-tmp
- cd libarchive-tmp
- git init
- git pull .. libarchive-upstream
- rm -rf *
-
-Now place the (reduced) libarchive content in this directory.  See
-instructions shown by
-
- git log 1a8c7bc2
-
-for help extracting the content from the upstream svn repo.  Then run
-the following commands to commit the new version.  Substitute the
-appropriate date and version number:
-
- git add --all
-
- GIT_AUTHOR_NAME='LibArchive Upstream' \
- GIT_AUTHOR_EMAIL='libarchive-discuss at googlegroups.com' \
- GIT_AUTHOR_DATE='Wed Oct 21 01:47:34 2015 -0700' \
- git commit -m 'libarchive 3.1.2-601-g3bfe5f1 (reduced)' &&
- git commit --amend
-
-Edit the commit message to describe the procedure used to obtain the
-content.  Then push the changes back up to the main local repository:
-
- git push .. HEAD:libarchive-upstream
- cd ..
- rm -rf libarchive-tmp
-
-Create a topic in the main repository on which to perform the update:
-
- git checkout -b update-libarchive master
-
-Merge the libarchive-upstream branch as a subtree:
-
- git merge -s recursive -X subtree=Utilities/cmlibarchive \
-           libarchive-upstream
-
-If there are conflicts, resolve them and commit.  Build and test the
-tree.  Commit any additional changes needed to succeed.
-
-Finally, run
-
- git rev-parse --short=8 libarchive-upstream
-
-to get the commit from which the libarchive-upstream branch must be started
-on the next update.  Edit the "git branch libarchive-upstream" line above to
-record it, and commit this file.
diff --git a/Utilities/cmlibarchive/build/cmake/config.h.in b/Utilities/cmlibarchive/build/cmake/config.h.in
index 1abeaaa..9843875 100644
--- a/Utilities/cmlibarchive/build/cmake/config.h.in
+++ b/Utilities/cmlibarchive/build/cmake/config.h.in
@@ -173,8 +173,6 @@ typedef unsigned char uint8_t;
 /* Define intmax_t and uintmax_t if they are not already defined. */
 #if !defined(HAVE_INTMAX_T)
 typedef int64_t intmax_t;
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
 #endif
 
 #if !defined(HAVE_UINTMAX_T)
@@ -367,6 +365,14 @@ typedef uint64_t uintmax_t;
 /* Define to 1 if you have the `cygwin_conv_path' function. */
 #cmakedefine HAVE_CYGWIN_CONV_PATH 1
 
+/* Define to 1 if you have the declaration of `INT32_MAX', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL_INT32_MAX 1
+
+/* Define to 1 if you have the declaration of `INT32_MIN', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL_INT32_MIN 1
+
 /* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you
    don't. */
 #cmakedefine HAVE_DECL_INT64_MAX 1
@@ -375,6 +381,14 @@ typedef uint64_t uintmax_t;
    don't. */
 #cmakedefine HAVE_DECL_INT64_MIN 1
 
+/* Define to 1 if you have the declaration of `INTMAX_MAX', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL_INTMAX_MAX 1
+
+/* Define to 1 if you have the declaration of `INTMAX_MIN', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL_INTMAX_MIN 1
+
 /* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you
    don't. */
 #cmakedefine HAVE_DECL_SIZE_MAX 1
@@ -395,6 +409,10 @@ typedef uint64_t uintmax_t;
    don't. */
 #cmakedefine HAVE_DECL_UINT64_MAX 1
 
+/* Define to 1 if you have the declaration of `UINTMAX_MAX', and to 0 if you
+   don't. */
+#cmakedefine HAVE_DECL_UINTMAX_MAX 1
+
 /* Define to 1 if you have the <direct.h> header file. */
 #cmakedefine HAVE_DIRECT_H 1
 
@@ -739,6 +757,12 @@ typedef uint64_t uintmax_t;
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #cmakedefine HAVE_NDIR_H 1
 
+/* Define to 1 if you have the <nettle/aes.h> header file. */
+#cmakedefine HAVE_NETTLE_AES_H 1
+
+/* Define to 1 if you have the <nettle/hmac.h> header file. */
+#cmakedefine HAVE_NETTLE_HMAC_H 1
+
 /* Define to 1 if you have the <nettle/md5.h> header file. */
 #cmakedefine HAVE_NETTLE_MD5_H 1
 
@@ -1153,7 +1177,11 @@ typedef uint64_t uintmax_t;
 /* Define for large files, on AIX-style hosts. */
 #cmakedefine _LARGE_FILES ${_LARGE_FILES}
 
-/* Define for Windows to use Windows 2000+ APIs. */
+/* Define to control Windows SDK version */
+#ifndef NTDDI_VERSION
+#cmakedefine NTDDI_VERSION ${NTDDI_VERSION}
+#endif // NTDDI_VERSION
+
 #ifndef _WIN32_WINNT
 #cmakedefine _WIN32_WINNT ${_WIN32_WINNT}
 #endif // _WIN32_WINNT
diff --git a/Utilities/cmlibarchive/build/version b/Utilities/cmlibarchive/build/version
index 937b126..f293156 100644
--- a/Utilities/cmlibarchive/build/version
+++ b/Utilities/cmlibarchive/build/version
@@ -1 +1 @@
-3001002
+3002001
diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
index 891c728..4eeb5e3 100644
--- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
@@ -34,6 +34,7 @@ SET(libarchive_SOURCES
   archive_entry_strmode.c
   archive_entry_xattr.c
   archive_getdate.c
+  archive_getdate.h
   archive_hmac.c
   archive_hmac_private.h
   archive_match.c
diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h
index a8d4c6c..3b5104b 100644
--- a/Utilities/cmlibarchive/libarchive/archive.h
+++ b/Utilities/cmlibarchive/libarchive/archive.h
@@ -36,11 +36,12 @@
  * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  */
 /* Note: Compiler will complain if this does not match archive_entry.h! */
-#define	ARCHIVE_VERSION_NUMBER 3001002
+#define	ARCHIVE_VERSION_NUMBER 3002001
 
 #include <sys/stat.h>
 #include <stddef.h>  /* for wchar_t */
 #include <stdio.h> /* For FILE * */
+#include <time.h> /* For time_t */
 
 /*
  * Note: archive.h is for use outside of libarchive; the configuration
@@ -95,6 +96,11 @@ typedef ssize_t la_ssize_t;
 # endif
 #endif
 
+/* Large file support for Android */
+#ifdef __ANDROID__
+#include "android_lf.h"
+#endif
+
 /*
  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
  * .lib.  The default here assumes you're building a DLL.  Only
@@ -146,7 +152,7 @@ __LA_DECL int		archive_version_number(void);
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define	ARCHIVE_VERSION_ONLY_STRING "3.1.2"
+#define	ARCHIVE_VERSION_ONLY_STRING "3.2.1"
 #define	ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
 __LA_DECL const char *	archive_version_string(void);
 
@@ -159,6 +165,16 @@ __LA_DECL const char *	archive_version_string(void);
  */
 __LA_DECL const char *	archive_version_details(void);
 
+/*
+ * Returns NULL if libarchive was compiled without the associated library.
+ * Otherwise, returns the version number that libarchive was compiled
+ * against.
+ */
+__LA_DECL const char *  archive_zlib_version(void);
+__LA_DECL const char *  archive_liblzma_version(void);
+__LA_DECL const char *  archive_bzlib_version(void);
+__LA_DECL const char *  archive_liblz4_version(void);
+
 /* Declare our basic types. */
 struct archive;
 struct archive_entry;
diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor.c b/Utilities/cmlibarchive/libarchive/archive_cryptor.c
index efd350d..0be30c6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_cryptor.c
+++ b/Utilities/cmlibarchive/libarchive/archive_cryptor.c
@@ -31,6 +31,19 @@
 #include "archive.h"
 #include "archive_cryptor_private.h"
 
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * this file will normally define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist.  This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_cryptor_build_hack(void) {
+	return 0;
+}
+
 #ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
 
 static int
@@ -256,7 +269,7 @@ aes_ctr_release(archive_crypto_ctx *ctx)
 	return 0;
 }
 
-#elif defined(HAVE_LIBNETTLE)
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
 
 static int
 aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h
index 9a96aee..37eaad3 100644
--- a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h
@@ -30,6 +30,17 @@
 #ifndef ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
 #define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
 
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_cryptor.c file will normally define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist.  This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_cryptor_build_hack(void);
+
 #ifdef __APPLE__
 # include <AvailabilityMacros.h>
 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
@@ -72,7 +83,7 @@ typedef struct {
 	unsigned	encr_pos;
 } archive_crypto_ctx;
 
-#elif defined(HAVE_LIBNETTLE)
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
 #if defined(HAVE_NETTLE_PBKDF2_H)
 #include <nettle/pbkdf2.h>
 #endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h
index 68d8ab9..81cd425 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.h
@@ -29,7 +29,7 @@
 #define	ARCHIVE_ENTRY_H_INCLUDED
 
 /* Note: Compiler will complain if this does not match archive.h! */
-#define	ARCHIVE_VERSION_NUMBER 3001002
+#define	ARCHIVE_VERSION_NUMBER 3002001
 
 /*
  * Note: archive_entry.h is for use outside of libarchive; the
@@ -75,6 +75,11 @@ typedef int64_t la_int64_t;
 # define	__LA_MODE_T	mode_t
 #endif
 
+/* Large file support for Android */
+#ifdef __ANDROID__
+#include "android_lf.h"
+#endif
+
 /*
  * On Windows, define LIBARCHIVE_STATIC if you're building or using a
  * .lib.  The default here assumes you're building a DLL.  Only
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_copy_stat.c b/Utilities/cmlibarchive/libarchive/archive_entry_copy_stat.c
index 37d4d6e..ac83868 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_copy_stat.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_copy_stat.c
@@ -44,6 +44,10 @@ archive_entry_copy_stat(struct archive_entry *entry, const struct stat *st)
 	archive_entry_set_atime(entry, st->st_atime, st->st_atim.tv_nsec);
 	archive_entry_set_ctime(entry, st->st_ctime, st->st_ctim.tv_nsec);
 	archive_entry_set_mtime(entry, st->st_mtime, st->st_mtim.tv_nsec);
+#elif HAVE_STRUCT_STAT_ST_MTIME_NSEC
+	archive_entry_set_atime(entry, st->st_atime, st->st_atime_nsec);
+	archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_nsec);
+	archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_nsec);
 #elif HAVE_STRUCT_STAT_ST_MTIME_N
 	archive_entry_set_atime(entry, st->st_atime, st->st_atime_n);
 	archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_n);
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c b/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c
index 05eb90f..5fe726b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_xattr.c
@@ -91,16 +91,11 @@ archive_entry_xattr_add_entry(struct archive_entry *entry,
 {
 	struct ae_xattr	*xp;
 
-	for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
-		;
-
 	if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
-		/* XXX Error XXX */
-		return;
+		__archive_errx(1, "Out of memory");
 
 	if ((xp->name = strdup(name)) == NULL)
-		/* XXX Error XXX */
-		return;
+		__archive_errx(1, "Out of memory");
 
 	if ((xp->value = malloc(size)) != NULL) {
 		memcpy(xp->value, value, size);
diff --git a/Utilities/cmlibarchive/libarchive/archive_getdate.c b/Utilities/cmlibarchive/libarchive/archive_getdate.c
index f665e2d..beb0cba 100644
--- a/Utilities/cmlibarchive/libarchive/archive_getdate.c
+++ b/Utilities/cmlibarchive/libarchive/archive_getdate.c
@@ -38,8 +38,8 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 #include <time.h>
 
-/* This file defines a single public function. */
-time_t __archive_get_date(time_t now, const char *);
+#define __LIBARCHIVE_BUILD 1
+#include "archive_getdate.h"
 
 /* Basic time units. */
 #define	EPOCH		1970
diff --git a/Utilities/cmlibarchive/libarchive/archive_getdate.h b/Utilities/cmlibarchive/libarchive/archive_getdate.h
new file mode 100644
index 0000000..666ff5f
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_getdate.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2003-2015 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+#ifndef ARCHIVE_GETDATE_H_INCLUDED
+#define	ARCHIVE_GETDATE_H_INCLUDED
+
+#include <time.h>
+
+time_t __archive_get_date(time_t now, const char *);
+
+#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_hmac.c b/Utilities/cmlibarchive/libarchive/archive_hmac.c
index 36e3e1c..7857c0f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_hmac.c
+++ b/Utilities/cmlibarchive/libarchive/archive_hmac.c
@@ -31,6 +31,20 @@
 #include "archive.h"
 #include "archive_hmac_private.h"
 
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_hmac.c file is expected to define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist.  This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_hmac_build_hack(void) {
+	return 0;
+}
+
+
 #ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
 
 static int
@@ -129,7 +143,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
 	}
 }
 
-#elif defined(HAVE_LIBNETTLE)
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H)
 
 static int
 __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
diff --git a/Utilities/cmlibarchive/libarchive/archive_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_hmac_private.h
index a9fb8ec..64de743 100644
--- a/Utilities/cmlibarchive/libarchive/archive_hmac_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_hmac_private.h
@@ -30,6 +30,17 @@
 #ifndef ARCHIVE_HMAC_PRIVATE_H_INCLUDED
 #define ARCHIVE_HMAC_PRIVATE_H_INCLUDED
 
+/*
+ * On systems that do not support any recognized crypto libraries,
+ * the archive_hmac.c file is expected to define no usable symbols.
+ *
+ * But some compilers and linkers choke on empty object files, so
+ * define a public symbol that will always exist.  This could
+ * be removed someday if this file gains another always-present
+ * symbol definition.
+ */
+int __libarchive_hmac_build_hack(void);
+
 #ifdef __APPLE__
 # include <AvailabilityMacros.h>
 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
@@ -53,7 +64,7 @@ typedef struct {
 
 } archive_hmac_sha1_ctx;
 
-#elif defined(HAVE_LIBNETTLE)
+#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H)
 #include <nettle/hmac.h>
 
 typedef	struct hmac_sha1_ctx archive_hmac_sha1_ctx;
diff --git a/Utilities/cmlibarchive/libarchive/archive_match.c b/Utilities/cmlibarchive/libarchive/archive_match.c
index 74aaacb..4c41bad 100644
--- a/Utilities/cmlibarchive/libarchive/archive_match.c
+++ b/Utilities/cmlibarchive/libarchive/archive_match.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include "archive.h"
 #include "archive_private.h"
 #include "archive_entry.h"
+#include "archive_getdate.h"
 #include "archive_pathmatch.h"
 #include "archive_rb.h"
 #include "archive_string.h"
@@ -184,7 +185,6 @@ static int	time_excluded(struct archive_match *,
 		    struct archive_entry *);
 static int	validate_time_flag(struct archive *, int, const char *);
 
-time_t __archive_get_date(time_t now, const char *);
 #define get_date __archive_get_date
 
 static const struct archive_rb_tree_ops rb_ops_mbs = {
diff --git a/Utilities/cmlibarchive/libarchive/archive_options.c b/Utilities/cmlibarchive/libarchive/archive_options.c
index 220ebd4..dbf3e80 100644
--- a/Utilities/cmlibarchive/libarchive/archive_options.c
+++ b/Utilities/cmlibarchive/libarchive/archive_options.c
@@ -42,9 +42,9 @@ _archive_set_option(struct archive *a,
 
 	archive_check_magic(a, magic, ARCHIVE_STATE_NEW, fn);
 
-	mp = m != NULL && m[0] != '\0' ? m : NULL;
-	op = o != NULL && o[0] != '\0' ? o : NULL;
-	vp = v != NULL && v[0] != '\0' ? v : NULL;
+	mp = (m != NULL && m[0] != '\0') ? m : NULL;
+	op = (o != NULL && o[0] != '\0') ? o : NULL;
+	vp = (v != NULL && v[0] != '\0') ? v : NULL;
 
 	if (op == NULL && vp == NULL)
 		return (ARCHIVE_OK);
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform.h b/Utilities/cmlibarchive/libarchive/archive_platform.h
index cbe08ec..08a384c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_platform.h
+++ b/Utilities/cmlibarchive/libarchive/archive_platform.h
@@ -122,6 +122,12 @@
 #if !HAVE_DECL_UINT32_MAX
 #define	UINT32_MAX (~(uint32_t)0)
 #endif
+#if !HAVE_DECL_INT32_MAX
+#define	INT32_MAX ((int32_t)(UINT32_MAX >> 1))
+#endif
+#if !HAVE_DECL_INT32_MIN
+#define	INT32_MIN ((int32_t)(~INT32_MAX))
+#endif
 #if !HAVE_DECL_UINT64_MAX
 #define	UINT64_MAX (~(uint64_t)0)
 #endif
@@ -131,6 +137,15 @@
 #if !HAVE_DECL_INT64_MIN
 #define	INT64_MIN ((int64_t)(~INT64_MAX))
 #endif
+#if !HAVE_DECL_UINTMAX_MAX
+#define	UINTMAX_MAX (~(uintmax_t)0)
+#endif
+#if !HAVE_DECL_INTMAX_MAX
+#define	INTMAX_MAX ((intmax_t)(UINTMAX_MAX >> 1))
+#endif
+#if !HAVE_DECL_INTMAX_MIN
+#define	INTMAX_MIN ((intmax_t)(~INTMAX_MAX))
+#endif
 
 /*
  * If this platform has <sys/acl.h>, acl_create(), acl_init(),
diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd7.c b/Utilities/cmlibarchive/libarchive/archive_ppmd7.c
index fe0b031..1aed922 100644
--- a/Utilities/cmlibarchive/libarchive/archive_ppmd7.c
+++ b/Utilities/cmlibarchive/libarchive/archive_ppmd7.c
@@ -126,6 +126,11 @@ static Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc)
 {
   if (p->Base == 0 || p->Size != size)
   {
+    /* RestartModel() below assumes that p->Size >= UNIT_SIZE
+       (see the calculation of m->MinContext). */
+    if (size < UNIT_SIZE) {
+      return False;
+    }
     Ppmd7_Free(p, alloc);
     p->AlignOffset =
       #ifdef PPMD_32BIT
diff --git a/Utilities/cmlibarchive/libarchive/archive_read.c b/Utilities/cmlibarchive/libarchive/archive_read.c
index 033ed8b..0bbacc8 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read.c
@@ -547,16 +547,20 @@ archive_read_open1(struct archive *_a)
  * it wants to handle this stream.  Repeat until we've finished
  * building the pipeline.
  */
+
+/* We won't build a filter pipeline with more stages than this. */
+#define MAX_NUMBER_FILTERS 25
+
 static int
 choose_filters(struct archive_read *a)
 {
-	int number_bidders, i, bid, best_bid, n;
+	int number_bidders, i, bid, best_bid, number_filters;
 	struct archive_read_filter_bidder *bidder, *best_bidder;
 	struct archive_read_filter *filter;
 	ssize_t avail;
 	int r;
 
-	for (n = 0; n < 25; ++n) {
+	for (number_filters = 0; number_filters < MAX_NUMBER_FILTERS; ++number_filters) {
 		number_bidders = sizeof(a->bidders) / sizeof(a->bidders[0]);
 
 		best_bid = 0;
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 38303aa..74fe353 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -1046,7 +1046,7 @@ setup_sparse(struct archive_read_disk *a,
 	struct fiemap *fm;
 	struct fiemap_extent *fe;
 	int64_t size;
-	int count, do_fiemap;
+	int count, do_fiemap, iters;
 	int exit_sts = ARCHIVE_OK;
 
 	if (archive_entry_filetype(entry) != AE_IFREG
@@ -1083,7 +1083,7 @@ setup_sparse(struct archive_read_disk *a,
 	fm->fm_extent_count = count;
 	do_fiemap = 1;
 	size = archive_entry_size(entry);
-	for (;;) {
+	for (iters = 0; ; ++iters) {
 		int i, r;
 
 		r = ioctl(*fd, FS_IOC_FIEMAP, fm); 
@@ -1093,8 +1093,13 @@ setup_sparse(struct archive_read_disk *a,
 			 * version(<2.6.28) cannot perfom FS_IOC_FIEMAP. */
 			goto exit_setup_sparse;
 		}
-		if (fm->fm_mapped_extents == 0)
+		if (fm->fm_mapped_extents == 0) {
+			if (iters == 0) {
+				/* Fully sparse file; insert a zero-length "data" entry */
+				archive_entry_sparse_add_entry(entry, 0, 0);
+			}
 			break;
+		}
 		fe = fm->fm_extents;
 		for (i = 0; i < (int)fm->fm_mapped_extents; i++, fe++) {
 			if (!(fe->fe_flags & FIEMAP_EXTENT_UNWRITTEN)) {
@@ -1139,6 +1144,7 @@ setup_sparse(struct archive_read_disk *a,
 	off_t initial_off; /* FreeBSD/Solaris only, so off_t okay here */
 	off_t off_s, off_e; /* FreeBSD/Solaris only, so off_t okay here */
 	int exit_sts = ARCHIVE_OK;
+	int check_fully_sparse = 0;
 
 	if (archive_entry_filetype(entry) != AE_IFREG
 	    || archive_entry_size(entry) <= 0
@@ -1191,8 +1197,14 @@ setup_sparse(struct archive_read_disk *a,
 	while (off_s < size) {
 		off_s = lseek(*fd, off_s, SEEK_DATA);
 		if (off_s == (off_t)-1) {
-			if (errno == ENXIO)
-				break;/* no more hole */
+			if (errno == ENXIO) {
+				/* no more hole */
+				if (archive_entry_sparse_count(entry) == 0) {
+					/* Potentially a fully-sparse file. */
+					check_fully_sparse = 1;
+				}
+				break;
+			}
 			archive_set_error(&a->archive, errno,
 			    "lseek(SEEK_HOLE) failed");
 			exit_sts = ARCHIVE_FAILED;
@@ -1216,6 +1228,14 @@ setup_sparse(struct archive_read_disk *a,
 			off_e - off_s);
 		off_s = off_e;
 	}
+
+	if (check_fully_sparse) {
+		if (lseek(*fd, 0, SEEK_HOLE) == 0 &&
+			lseek(*fd, 0, SEEK_END) == size) {
+			/* Fully sparse file; insert a zero-length "data" entry */
+			archive_entry_sparse_add_entry(entry, 0, 0);
+		}
+	}
 exit_setup_sparse:
 	lseek(*fd, initial_off, SEEK_SET);
 	return (exit_sts);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
index f480539..22a1f14 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
@@ -717,6 +717,7 @@ _archive_read_data_block(struct archive *_a, const void **buff,
 	int r;
 	ssize_t bytes;
 	size_t buffbytes;
+	int empty_sparse_region = 0;
 
 	archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC, ARCHIVE_STATE_DATA,
 	    "archive_read_data_block");
@@ -798,6 +799,9 @@ _archive_read_data_block(struct archive *_a, const void **buff,
 	if ((int64_t)buffbytes > t->current_sparse->length)
 		buffbytes = t->current_sparse->length;
 
+	if (t->current_sparse->length == 0)
+		empty_sparse_region = 1;
+
 	/*
 	 * Skip hole.
 	 * TODO: Should we consider t->current_filesystem->xfer_align?
@@ -828,7 +832,11 @@ _archive_read_data_block(struct archive *_a, const void **buff,
 		}
 	} else
 		bytes = 0;
-	if (bytes == 0) {
+	/*
+	 * Return an EOF unless we've read a leading empty sparse region, which
+	 * is used to represent fully-sparse files.
+	*/
+	if (bytes == 0 && !empty_sparse_region) {
 		/* Get EOF */
 		t->entry_eof = 1;
 		r = ARCHIVE_EOF;
@@ -1576,6 +1584,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #if defined(HAVE_STRUCT_STATFS_F_NAMEMAX)
 	t->current_filesystem->name_max = sfs.f_namemax;
 #else
+# if defined(_PC_NAME_MAX)
 	/* Mac OS X does not have f_namemax in struct statfs. */
 	if (tree_current_is_symblic_link_target(t)) {
 		if (tree_enter_working_dir(t) != 0) {
@@ -1585,6 +1594,9 @@ setup_current_filesystem(struct archive_read_disk *a)
 		nm = pathconf(tree_current_access_path(t), _PC_NAME_MAX);
 	} else
 		nm = fpathconf(tree_current_dir_fd(t), _PC_NAME_MAX);
+# else
+	nm = -1;
+# endif
 	if (nm == -1)
 		t->current_filesystem->name_max = NAME_MAX;
 	else
@@ -1681,7 +1693,9 @@ setup_current_filesystem(struct archive_read_disk *a)
 {
 	struct tree *t = a->tree;
 	struct statfs sfs;
+#if defined(HAVE_STATVFS)
 	struct statvfs svfs;
+#endif
 	int r, vr = 0, xr = 0;
 
 	if (tree_current_is_symblic_link_target(t)) {
@@ -1698,7 +1712,9 @@ setup_current_filesystem(struct archive_read_disk *a)
 			    "openat failed");
 			return (ARCHIVE_FAILED);
 		}
+#if defined(HAVE_FSTATVFS)
 		vr = fstatvfs(fd, &svfs);/* for f_flag, mount flags */
+#endif
 		r = fstatfs(fd, &sfs);
 		if (r == 0)
 			xr = get_xfer_size(t, fd, NULL);
@@ -1708,14 +1724,18 @@ setup_current_filesystem(struct archive_read_disk *a)
 			archive_set_error(&a->archive, errno, "fchdir failed");
 			return (ARCHIVE_FAILED);
 		}
+#if defined(HAVE_STATVFS)
 		vr = statvfs(tree_current_access_path(t), &svfs);
+#endif
 		r = statfs(tree_current_access_path(t), &sfs);
 		if (r == 0)
 			xr = get_xfer_size(t, -1, tree_current_access_path(t));
 #endif
 	} else {
 #ifdef HAVE_FSTATFS
+#if defined(HAVE_FSTATVFS)
 		vr = fstatvfs(tree_current_dir_fd(t), &svfs);
+#endif
 		r = fstatfs(tree_current_dir_fd(t), &sfs);
 		if (r == 0)
 			xr = get_xfer_size(t, tree_current_dir_fd(t), NULL);
@@ -1724,7 +1744,9 @@ setup_current_filesystem(struct archive_read_disk *a)
 			archive_set_error(&a->archive, errno, "fchdir failed");
 			return (ARCHIVE_FAILED);
 		}
+#if defined(HAVE_STATVFS)
 		vr = statvfs(".", &svfs);
+#endif
 		r = statfs(".", &sfs);
 		if (r == 0)
 			xr = get_xfer_size(t, -1, ".");
@@ -1737,10 +1759,17 @@ setup_current_filesystem(struct archive_read_disk *a)
 		return (ARCHIVE_FAILED);
 	} else if (xr == 1) {
 		/* pathconf(_PC_REX_*) operations are not supported. */
+#if defined(HAVE_STATVFS)
 		t->current_filesystem->xfer_align = svfs.f_frsize;
 		t->current_filesystem->max_xfer_size = -1;
 		t->current_filesystem->min_xfer_size = svfs.f_bsize;
 		t->current_filesystem->incr_xfer_size = svfs.f_bsize;
+#else
+		t->current_filesystem->xfer_align = sfs.f_frsize;
+		t->current_filesystem->max_xfer_size = -1;
+		t->current_filesystem->min_xfer_size = sfs.f_bsize;
+		t->current_filesystem->incr_xfer_size = sfs.f_bsize;
+#endif
 	}
 	switch (sfs.f_type) {
 	case AFS_SUPER_MAGIC:
@@ -1765,7 +1794,11 @@ setup_current_filesystem(struct archive_read_disk *a)
 	}
 
 #if defined(ST_NOATIME)
+#if defined(HAVE_STATVFS)
 	if (svfs.f_flag & ST_NOATIME)
+#else
+	if (sfs.f_flag & ST_NOATIME)
+#endif
 		t->current_filesystem->noatime = 1;
 	else
 #endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
index 53bd4b8..566d264 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
@@ -1586,7 +1586,7 @@ tree_reopen(struct tree *t, const wchar_t *path, int restore_time)
 	t->stack->flags = needsFirstVisit;
 	/*
 	 * Debug flag for Direct IO(No buffering) or Async IO.
-	 * Those dependant on environment variable switches
+	 * Those dependent on environment variable switches
 	 * will be removed until next release.
 	 */
 	{
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_filter.3 b/Utilities/cmlibarchive/libarchive/archive_read_filter.3
index 47effac..7f020e3 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_filter.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_filter.3
@@ -53,8 +53,12 @@ Streaming Archive Library (libarchive, -larchive)
 .Ft int
 .Fn archive_read_support_filter_compress "struct archive *"
 .Ft int
+.Fn archive_read_support_filter_grzip "struct archive *"
+.Ft int
 .Fn archive_read_support_filter_gzip "struct archive *"
 .Ft int
+.Fn archive_read_support_filter_lrzip "struct archive *"
+.Ft int
 .Fn archive_read_support_filter_lz4 "struct archive *"
 .Ft int
 .Fn archive_read_support_filter_lzma "struct archive *"
@@ -86,7 +90,9 @@ Streaming Archive Library (libarchive, -larchive)
 .It Xo
 .Fn archive_read_support_filter_bzip2 ,
 .Fn archive_read_support_filter_compress ,
+.Fn archive_read_support_filter_grzip ,
 .Fn archive_read_support_filter_gzip ,
+.Fn archive_read_support_filter_lrzip ,
 .Fn archive_read_support_filter_lz4 ,
 .Fn archive_read_support_filter_lzma ,
 .Fn archive_read_support_filter_lzop ,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open_file.c b/Utilities/cmlibarchive/libarchive/archive_read_open_file.c
index 3a33c25..bfe933b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_open_file.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_open_file.c
@@ -83,8 +83,9 @@ archive_read_open_FILE(struct archive *a, FILE *f)
 	mine->f = f;
 	/*
 	 * If we can't fstat() the file, it may just be that it's not
-	 * a file.  (FILE * objects can wrap many kinds of I/O
-	 * streams, some of which don't support fileno()).)
+	 * a file.  (On some platforms, FILE * objects can wrap I/O
+	 * streams that don't support fileno()).  As a result, fileno()
+	 * should be used cautiously.)
 	 */
 	if (fstat(fileno(mine->f), &st) == 0 && S_ISREG(st.st_mode)) {
 		archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
@@ -150,7 +151,10 @@ file_skip(struct archive *a, void *client_data, int64_t request)
 			skip = max_skip;
 	}
 
-#if HAVE_FSEEKO
+#ifdef __ANDROID__
+        /* fileno() isn't safe on all platforms ... see above. */
+	if (lseek(fileno(mine->f), skip, SEEK_CUR) < 0)
+#elif HAVE_FSEEKO
 	if (fseeko(mine->f, skip, SEEK_CUR) != 0)
 #elif HAVE__FSEEKI64
 	if (_fseeki64(mine->f, skip, SEEK_CUR) != 0)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c b/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c
index 622c960..5611aa8 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_open_filename.c
@@ -178,7 +178,7 @@ archive_read_open_filename_w(struct archive *a, const wchar_t *wfilename,
 #else
 		/*
 		 * POSIX system does not support a wchar_t interface for
-		 * open() system call, so we have to translate a whcar_t
+		 * open() system call, so we have to translate a wchar_t
 		 * filename to multi-byte one and use it.
 		 */
 		struct archive_string fn;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
index db62cb3..e877917 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
@@ -580,10 +580,19 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
 				    prefix64k);
 			}
 		}
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+		uncompressed_size = LZ4_decompress_safe_usingDict(
+		    read_buf + 4,
+		    state->out_block + prefix64k, (int)compressed_size,
+		    state->flags.block_maximum_size,
+		    state->out_block,
+		    prefix64k);
+#else
 		uncompressed_size = LZ4_decompress_safe_withPrefix64k(
 		    read_buf + 4,
 		    state->out_block + prefix64k, (int)compressed_size,
 		    state->flags.block_maximum_size);
+#endif
 	}
 
 	/* Check if an error happend in decompression process. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
index f045b8f..a33ea4f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
@@ -2153,6 +2153,9 @@ read_SubStreamsInfo(struct archive_read *a, struct _7z_substream_info *ss,
 				return (-1);
 			if (UMAX_ENTRY < f[i].numUnpackStreams)
 				return (-1);
+			if (unpack_streams > SIZE_MAX - UMAX_ENTRY) {
+				return (-1);
+			}
 			unpack_streams += (size_t)f[i].numUnpackStreams;
 		}
 		if ((p = header_bytes(a, 1)) == NULL)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
index c2ca85b..b09db0e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
@@ -401,6 +401,11 @@ archive_read_format_cpio_read_header(struct archive_read *a,
 
 	/* If this is a symlink, read the link contents. */
 	if (archive_entry_filetype(entry) == AE_IFLNK) {
+		if (cpio->entry_bytes_remaining > 1024 * 1024) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Rejecting malformed cpio archive: symlink contents exceed 1 megabyte");
+			return (ARCHIVE_FATAL);
+		}
 		h = __archive_read_ahead(a,
 			(size_t)cpio->entry_bytes_remaining, NULL);
 		if (h == NULL)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
index 3628025..c19614a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
@@ -1091,7 +1091,7 @@ choose_volume(struct archive_read *a, struct iso9660 *iso9660)
 		/* This condition is unlikely; by way of caution. */
 		vd = &(iso9660->joliet);
 
-	skipsize = LOGICAL_BLOCK_SIZE * vd->location;
+	skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location;
 	skipsize = __archive_read_consume(a, skipsize);
 	if (skipsize < 0)
 		return ((int)skipsize);
@@ -1129,7 +1129,7 @@ choose_volume(struct archive_read *a, struct iso9660 *iso9660)
 	    && iso9660->seenJoliet) {
 		/* Switch reading data from primary to joliet. */
 		vd = &(iso9660->joliet);
-		skipsize = LOGICAL_BLOCK_SIZE * vd->location;
+		skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location;
 		skipsize -= iso9660->current_position;
 		skipsize = __archive_read_consume(a, skipsize);
 		if (skipsize < 0)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
index b5f8e30..8c3be9a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
@@ -148,9 +148,12 @@ get_time_t_max(void)
 		return (~(time_t)0);
 	} else {
 		/* Time_t is signed. */
-		const uintmax_t max_unsigned_time_t = (uintmax_t)(~(time_t)0);
-		const uintmax_t max_signed_time_t = max_unsigned_time_t >> 1;
-		return (time_t)max_signed_time_t;
+		/* Assume it's the same as int64_t or int32_t */
+		if (sizeof(time_t) == sizeof(int64_t)) {
+			return (time_t)INT64_MAX;
+		} else {
+			return (time_t)INT32_MAX;
+		}
 	}
 #endif
 }
@@ -166,10 +169,11 @@ get_time_t_min(void)
 		return (time_t)0;
 	} else {
 		/* Time_t is signed. */
-		const uintmax_t max_unsigned_time_t = (uintmax_t)(~(time_t)0);
-		const uintmax_t max_signed_time_t = max_unsigned_time_t >> 1;
-		const intmax_t min_signed_time_t = (intmax_t)~max_signed_time_t;
-		return (time_t)min_signed_time_t;
+		if (sizeof(time_t) == sizeof(int64_t)) {
+			return (time_t)INT64_MIN;
+		} else {
+			return (time_t)INT32_MIN;
+		}
 	}
 #endif
 }
@@ -852,8 +856,8 @@ process_add_entry(struct archive_read *a, struct mtree *mtree,
 	struct mtree_entry *entry;
 	struct mtree_option *iter;
 	const char *next, *eq, *name, *end;
-	size_t len;
-	int r;
+	size_t name_len, len;
+	int r, i;
 
 	if ((entry = malloc(sizeof(*entry))) == NULL) {
 		archive_set_error(&a->archive, errno, "Can't allocate memory");
@@ -873,43 +877,48 @@ process_add_entry(struct archive_read *a, struct mtree *mtree,
 	*last_entry = entry;
 
 	if (is_form_d) {
-		/*
-		 * This form places the file name as last parameter.
-		 */
-		name = line + line_len -1;
+		/* Filename is last item on line. */
+		/* Adjust line_len to trim trailing whitespace */
 		while (line_len > 0) {
-			if (*name != '\r' && *name != '\n' &&
-			    *name != '\t' && *name != ' ')
+			char last_character = line[line_len - 1];
+			if (last_character == '\r'
+			    || last_character == '\n'
+			    || last_character == '\t'
+			    || last_character == ' ') {
+				line_len--;
+			} else {
 				break;
-			name--;
-			line_len--;
+			}
 		}
-		len = 0;
-		while (line_len > 0) {
-			if (*name == '\r' || *name == '\n' ||
-			    *name == '\t' || *name == ' ') {
-				name++;
-				break;
+		/* Name starts after the last whitespace separator */
+		name = line;
+		for (i = 0; i < line_len; i++) {
+			if (line[i] == '\r'
+			    || line[i] == '\n'
+			    || line[i] == '\t'
+			    || line[i] == ' ') {
+				name = line + i + 1;
 			}
-			name--;
-			line_len--;
-			len++;
 		}
+		name_len = line + line_len - name;
 		end = name;
 	} else {
-		len = strcspn(line, " \t\r\n");
+		/* Filename is first item on line */
+		name_len = strcspn(line, " \t\r\n");
 		name = line;
-		line += len;
+		line += name_len;
 		end = line + line_len;
 	}
+	/* name/name_len is the name within the line. */
+	/* line..end brackets the entire line except the name */
 
-	if ((entry->name = malloc(len + 1)) == NULL) {
+	if ((entry->name = malloc(name_len + 1)) == NULL) {
 		archive_set_error(&a->archive, errno, "Can't allocate memory");
 		return (ARCHIVE_FATAL);
 	}
 
-	memcpy(entry->name, name, len);
-	entry->name[len] = '\0';
+	memcpy(entry->name, name, name_len);
+	entry->name[name_len] = '\0';
 	parse_escapes(entry->name, entry);
 
 	for (iter = *global; iter != NULL; iter = iter->next) {
@@ -1333,7 +1342,7 @@ parse_line(struct archive_read *a, struct archive_entry *entry,
 /* strsep() is not in C90, but strcspn() is. */
 /* Taken from http://unixpapa.com/incnote/string.html */
 static char *
-la_strsep(char **sp, char *sep)
+la_strsep(char **sp, const char *sep)
 {
 	char *p, *s;
 	if (sp == NULL || *sp == NULL || **sp == '\0')
@@ -1376,12 +1385,12 @@ parse_device(dev_t *pdev, struct archive *a, char *val)
 				    "Missing number");
 				return ARCHIVE_WARN;
 			}
-			numbers[argc++] = (unsigned long)mtree_atol(&p);
-			if (argc > MAX_PACK_ARGS) {
+			if (argc >= MAX_PACK_ARGS) {
 				archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
 				    "Too many arguments");
 				return ARCHIVE_WARN;
 			}
+			numbers[argc++] = (unsigned long)mtree_atol(&p);
 		}
 		if (argc < 2) {
 			archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
@@ -1561,7 +1570,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
 			int64_t m;
 			int64_t my_time_t_max = get_time_t_max();
 			int64_t my_time_t_min = get_time_t_min();
-			long ns;
+			long ns = 0;
 
 			*parsed_kws |= MTREE_HAS_MTIME;
 			m = mtree_atol10(&val);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
index 35ac7cf..fc8153f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
@@ -828,6 +828,7 @@ archive_read_format_rar_read_header(struct archive_read *a,
   char head_type;
   int ret;
   unsigned flags;
+  unsigned long crc32_expected;
 
   a->archive.archive_format = ARCHIVE_FORMAT_RAR;
   if (a->archive.archive_format_name == NULL)
@@ -940,36 +941,50 @@ archive_read_format_rar_read_header(struct archive_read *a,
       skip = archive_le16dec(p + 5);
       if (skip < 7) {
         archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-          "Invalid header size");
+          "Invalid header size too small");
         return (ARCHIVE_FATAL);
       }
-      if (skip > 7) {
-        if ((h = __archive_read_ahead(a, skip, NULL)) == NULL)
-          return (ARCHIVE_FATAL);
-        p = h;
-      }
       if (flags & HD_ADD_SIZE_PRESENT)
       {
         if (skip < 7 + 4) {
           archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-            "Invalid header size");
+            "Invalid header size too small");
           return (ARCHIVE_FATAL);
         }
-        skip += archive_le32dec(p + 7);
         if ((h = __archive_read_ahead(a, skip, NULL)) == NULL)
           return (ARCHIVE_FATAL);
         p = h;
+        skip += archive_le32dec(p + 7);
       }
 
-      crc32_val = crc32(0, (const unsigned char *)p + 2, (unsigned)skip - 2);
-      if ((crc32_val & 0xffff) != archive_le16dec(p)) {
-        archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-          "Header CRC error");
-        return (ARCHIVE_FATAL);
+      /* Skip over the 2-byte CRC at the beginning of the header. */
+      crc32_expected = archive_le16dec(p);
+      __archive_read_consume(a, 2);
+      skip -= 2;
+
+      /* Skim the entire header and compute the CRC. */
+      crc32_val = 0;
+      while (skip > 0) {
+	      size_t to_read = skip;
+	      ssize_t did_read;
+	      if (to_read > 32 * 1024) {
+		      to_read = 32 * 1024;
+	      }
+	      if ((h = __archive_read_ahead(a, to_read, &did_read)) == NULL) {
+		      return (ARCHIVE_FATAL);
+	      }
+	      p = h;
+	      crc32_val = crc32(crc32_val, (const unsigned char *)p, (unsigned)did_read);
+	      __archive_read_consume(a, did_read);
+	      skip -= did_read;
+      }
+      if ((crc32_val & 0xffff) != crc32_expected) {
+	      archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		  "Header CRC error");
+	      return (ARCHIVE_FATAL);
       }
-      __archive_read_consume(a, skip);
       if (head_type == ENDARC_HEAD)
-        return (ARCHIVE_EOF);
+	      return (ARCHIVE_EOF);
       break;
 
     case NEWSUB_HEAD:
@@ -2112,6 +2127,12 @@ parse_codes(struct archive_read *a)
       rar->range_dec.Stream = &rar->bytein;
       __archive_ppmd7_functions.Ppmd7_Construct(&rar->ppmd7_context);
 
+      if (rar->dictionary_size == 0) {
+	      archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                          "Invalid zero dictionary size");
+	      return (ARCHIVE_FATAL);
+      }
+
       if (!__archive_ppmd7_functions.Ppmd7_Alloc(&rar->ppmd7_context,
         rar->dictionary_size, &g_szalloc))
       {
@@ -2869,11 +2890,10 @@ copy_from_lzss_window(struct archive_read *a, const void **buffer,
   }
 
   windowoffs = lzss_offset_for_position(&rar->lzss, startpos);
-  if(windowoffs + length <= lzss_size(&rar->lzss))
+  if(windowoffs + length <= lzss_size(&rar->lzss)) {
     memcpy(&rar->unp_buffer[rar->unp_offset], &rar->lzss.window[windowoffs],
            length);
-  else
-  {
+  } else if (length <= lzss_size(&rar->lzss)) {
     firstpart = lzss_size(&rar->lzss) - windowoffs;
     if (firstpart < 0) {
       archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
@@ -2885,9 +2905,14 @@ copy_from_lzss_window(struct archive_read *a, const void **buffer,
              &rar->lzss.window[windowoffs], firstpart);
       memcpy(&rar->unp_buffer[rar->unp_offset + firstpart],
              &rar->lzss.window[0], length - firstpart);
-    } else
+    } else {
       memcpy(&rar->unp_buffer[rar->unp_offset],
              &rar->lzss.window[windowoffs], length);
+    }
+  } else {
+      archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                        "Bad RAR file data");
+      return (ARCHIVE_FATAL);
   }
   rar->unp_offset += length;
   if (rar->unp_offset >= rar->unp_buffer_size)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
index 01d85cf..b0521a6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
@@ -202,7 +202,7 @@ static int	archive_read_format_tar_read_header(struct archive_read *,
 		    struct archive_entry *);
 static int	checksum(struct archive_read *, const void *);
 static int 	pax_attribute(struct archive_read *, struct tar *,
-		    struct archive_entry *, char *key, char *value);
+		    struct archive_entry *, const char *key, const char *value);
 static int 	pax_header(struct archive_read *, struct tar *,
 		    struct archive_entry *, char *attr);
 static void	pax_time(const char *, int64_t *sec, long *nanos);
@@ -1664,7 +1664,7 @@ pax_header(struct archive_read *a, struct tar *tar,
 
 static int
 pax_attribute_xattr(struct archive_entry *entry,
-	char *name, char *value)
+	const char *name, const char *value)
 {
 	char *name_decoded;
 	void *value_decoded;
@@ -1710,7 +1710,7 @@ pax_attribute_xattr(struct archive_entry *entry,
  */
 static int
 pax_attribute(struct archive_read *a, struct tar *tar,
-    struct archive_entry *entry, char *key, char *value)
+    struct archive_entry *entry, const char *key, const char *value)
 {
 	int64_t s;
 	long n;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c
index 57534f3..46a59ea 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c
@@ -418,10 +418,11 @@ deconst(const void *c)
 }
 
 static char*
-xmemmem(const char *hay, const size_t hz_, const char *ndl, const size_t nz)
+xmemmem(const char *hay, const size_t haysize,
+	const char *needle, const size_t needlesize)
 {
-	const char *const eoh = hay + hz_;
-	const char *const eon = ndl + nz;
+	const char *const eoh = hay + haysize;
+	const char *const eon = needle + needlesize;
 	const char *hp;
 	const char *np;
 	const char *cand;
@@ -433,9 +434,9 @@ xmemmem(const char *hay, const size_t hz_, const char *ndl, const size_t nz)
          * a 0-sized needle is defined to be found anywhere in haystack
          * then run strchr() to find a candidate in HAYSTACK (i.e. a portion
          * that happens to begin with *NEEDLE) */
-	if (nz == 0UL) {
+	if (needlesize == 0UL) {
 		return deconst(hay);
-	} else if ((hay = memchr(hay, *ndl, hz_)) == NULL) {
+	} else if ((hay = memchr(hay, *needle, haysize)) == NULL) {
 		/* trivial */
 		return NULL;
 	}
@@ -444,11 +445,11 @@ xmemmem(const char *hay, const size_t hz_, const char *ndl, const size_t nz)
 	 * guaranteed to be at least one character long.  Now computes the sum
 	 * of characters values of needle together with the sum of the first
 	 * needle_len characters of haystack. */
-	for (hp = hay + 1U, np = ndl + 1U, hsum = *hay, nsum = *hay, eqp = 1U;
+	for (hp = hay + 1U, np = needle + 1U, hsum = *hay, nsum = *hay, eqp = 1U;
 	     hp < eoh && np < eon;
 	     hsum ^= *hp, nsum ^= *np, eqp &= *hp == *np, hp++, np++);
 
-	/* HP now references the (NZ + 1)-th character. */
+	/* HP now references the (NEEDLESIZE + 1)-th character. */
 	if (np < eon) {
 		/* haystack is smaller than needle, :O */
 		return NULL;
@@ -464,10 +465,10 @@ xmemmem(const char *hay, const size_t hz_, const char *ndl, const size_t nz)
 		hsum ^= *hp;
 
 		/* Since the sum of the characters is already known to be
-		 * equal at that point, it is enough to check just NZ - 1
+		 * equal at that point, it is enough to check just NEEDLESIZE - 1
 		 * characters for equality,
 		 * also CAND is by design < HP, so no need for range checks */
-		if (hsum == nsum && memcmp(cand, ndl, nz - 1U) == 0) {
+		if (hsum == nsum && memcmp(cand, needle, needlesize - 1U) == 0) {
 			return deconst(cand);
 		}
 	}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
index bbef99f..ec623c6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
@@ -1939,9 +1939,6 @@ unknowntag_start(struct archive_read *a, struct xar *xar, const char *name)
 {
 	struct unknown_tag *tag;
 
-#if DEBUG
-	fprintf(stderr, "unknowntag_start:%s\n", name);
-#endif
 	tag = malloc(sizeof(*tag));
 	if (tag == NULL) {
 		archive_set_error(&a->archive, ENOMEM, "Out of memory");
@@ -1951,6 +1948,9 @@ unknowntag_start(struct archive_read *a, struct xar *xar, const char *name)
 	archive_string_init(&(tag->name));
 	archive_strcpy(&(tag->name), name);
 	if (xar->unknowntags == NULL) {
+#if DEBUG
+		fprintf(stderr, "UNKNOWNTAG_START:%s\n", name);
+#endif
 		xar->xmlsts_unknown = xar->xmlsts;
 		xar->xmlsts = UNKNOWN;
 	}
@@ -1963,9 +1963,6 @@ unknowntag_end(struct xar *xar, const char *name)
 {
 	struct unknown_tag *tag;
 
-#if DEBUG
-	fprintf(stderr, "unknowntag_end:%s\n", name);
-#endif
 	tag = xar->unknowntags;
 	if (tag == NULL || name == NULL)
 		return;
@@ -1973,8 +1970,12 @@ unknowntag_end(struct xar *xar, const char *name)
 		xar->unknowntags = tag->next;
 		archive_string_free(&(tag->name));
 		free(tag);
-		if (xar->unknowntags == NULL)
+		if (xar->unknowntags == NULL) {
+#if DEBUG
+			fprintf(stderr, "UNKNOWNTAG_END:%s\n", name);
+#endif
 			xar->xmlsts = xar->xmlsts_unknown;
+		}
 	}
 }
 
@@ -2168,7 +2169,7 @@ xml_start(struct archive_read *a, const char *name, struct xmlattr_list *list)
 	case FILE_ACL:
 		if (strcmp(name, "appleextended") == 0)
 			xar->xmlsts = FILE_ACL_APPLEEXTENDED;
-		if (strcmp(name, "default") == 0)
+		else if (strcmp(name, "default") == 0)
 			xar->xmlsts = FILE_ACL_DEFAULT;
 		else if (strcmp(name, "access") == 0)
 			xar->xmlsts = FILE_ACL_ACCESS;
@@ -2690,9 +2691,9 @@ xml_data(void *userData, const char *s, int len)
 #if DEBUG
 	{
 		char buff[1024];
-		if (len > sizeof(buff)-1)
-			len = sizeof(buff)-1;
-		memcpy(buff, s, len);
+		if (len > (int)(sizeof(buff)-1))
+			len = (int)(sizeof(buff)-1);
+		strncpy(buff, s, len);
 		buff[len] = 0;
 		fprintf(stderr, "\tlen=%d:\"%s\"\n", len, buff);
 	}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
index 62bf5e3..c50ba84 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
@@ -39,7 +39,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102
  *
  * 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.
+ * added in Nov 2011.  Zip64 support (including a significant code
+ * refactoring) was added in 2014.
  */
 
 #ifdef HAVE_ERRNO_H
@@ -180,6 +181,14 @@ struct zip {
 	char			init_decryption;
 
 	/* Decryption buffer. */
+	/*
+	 * The decrypted data starts at decrypted_ptr and
+	 * extends for decrypted_bytes_remaining.  Decryption
+	 * adds new data to the end of this block, data is returned
+	 * to clients from the beginning.  When the block hits the
+	 * end of decrypted_buffer, it has to be shuffled back to
+	 * the beginning of the buffer.
+	 */
 	unsigned char 		*decrypted_buffer;
 	unsigned char 		*decrypted_ptr;
 	size_t 			decrypted_buffer_size;
@@ -419,8 +428,9 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
 		unsigned short datasize = archive_le16dec(p + offset + 2);
 
 		offset += 4;
-		if (offset + datasize > extra_length)
+		if (offset + datasize > extra_length) {
 			break;
+		}
 #ifdef DEBUG
 		fprintf(stderr, "Header id 0x%04x, length %d\n",
 		    headerid, datasize);
@@ -555,7 +565,7 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
 			 *  if bitmap & 1, 2 byte "version made by"
 			 *  if bitmap & 2, 2 byte "internal file attributes"
 			 *  if bitmap & 4, 4 byte "external file attributes"
-			 *  if bitmap * 7, 2 byte comment length + n byte comment
+			 *  if bitmap & 8, 2 byte comment length + n byte comment
 			 */
 			int bitmap, bitmap_last;
 
@@ -604,6 +614,19 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
 				if (zip_entry->system == 3) {
 					zip_entry->mode
 					    = external_attributes >> 16;
+				} else if (zip_entry->system == 0) {
+					// Interpret MSDOS directory bit
+					if (0x10 == (external_attributes & 0x10)) {
+						zip_entry->mode = AE_IFDIR | 0775;
+					} else {
+						zip_entry->mode = AE_IFREG | 0664;
+					}
+					if (0x01 == (external_attributes & 0x01)) {
+						// Read-only bit; strip write permissions
+						zip_entry->mode &= 0555;
+					}
+				} else {
+					zip_entry->mode = 0;
 				}
 				offset += 4;
 				datasize -= 4;
@@ -810,6 +833,16 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
 	}
 	__archive_read_consume(a, filename_length);
 
+	/* Read the extra data. */
+	if ((h = __archive_read_ahead(a, extra_length, NULL)) == NULL) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Truncated ZIP file header");
+		return (ARCHIVE_FATAL);
+	}
+
+	process_extra(h, extra_length, zip_entry);
+	__archive_read_consume(a, extra_length);
+
 	/* 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) {
@@ -843,16 +876,31 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
 		}
 	}
 
-	/* Read the extra data. */
-	if ((h = __archive_read_ahead(a, extra_length, NULL)) == NULL) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Truncated ZIP file header");
-		return (ARCHIVE_FATAL);
+	/* Make sure directories end in '/' */
+	if ((zip_entry->mode & AE_IFMT) == AE_IFDIR) {
+		wp = archive_entry_pathname_w(entry);
+		if (wp != NULL) {
+			len = wcslen(wp);
+			if (len > 0 && wp[len - 1] != L'/') {
+				struct archive_wstring s;
+				archive_string_init(&s);
+				archive_wstrcat(&s, wp);
+				archive_wstrappend_wchar(&s, L'/');
+				archive_entry_copy_pathname_w(entry, s.s);
+			}
+		} else {
+			cp = archive_entry_pathname(entry);
+			len = (cp != NULL)?strlen(cp):0;
+			if (len > 0 && cp[len - 1] != '/') {
+				struct archive_string s;
+				archive_string_init(&s);
+				archive_strcat(&s, cp);
+				archive_strappend_char(&s, '/');
+				archive_entry_set_pathname(entry, s.s);
+			}
+		}
 	}
 
-	process_extra(h, extra_length, zip_entry);
-	__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. */
@@ -1253,8 +1301,9 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
 
 	if (zip->tctx_valid || zip->cctx_valid) {
 		if (zip->decrypted_bytes_remaining < (size_t)bytes_avail) {
-			size_t buff_remaining = zip->decrypted_buffer_size
-			    - (zip->decrypted_ptr - zip->decrypted_buffer);
+			size_t buff_remaining =
+			    (zip->decrypted_buffer + zip->decrypted_buffer_size)
+			    - (zip->decrypted_ptr + zip->decrypted_bytes_remaining);
 
 			if (buff_remaining > (size_t)bytes_avail)
 				buff_remaining = (size_t)bytes_avail;
@@ -2614,9 +2663,21 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
 		/* 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;
+		} else if (zip_entry->system == 0) {
+			// Interpret MSDOS directory bit
+			if (0x10 == (external_attributes & 0x10)) {
+				zip_entry->mode = AE_IFDIR | 0775;
+			} else {
+				zip_entry->mode = AE_IFREG | 0664;
+			}
+			if (0x01 == (external_attributes & 0x01)) {
+				// Read-only bit; strip write permissions
+				zip_entry->mode &= 0555;
+			}
+		} else {
+			zip_entry->mode = 0;
 		}
 
 		/* We're done with the regular data; get the filename and
@@ -2726,6 +2787,11 @@ zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
 
 	switch(rsrc->compression) {
 	case 0:  /* No compression. */
+		if (rsrc->uncompressed_size != rsrc->compressed_size) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Malformed OS X metadata entry: inconsistent size");
+			return (ARCHIVE_FATAL);
+		}
 #ifdef HAVE_ZLIB_H
 	case 8: /* Deflate compression. */
 #endif
@@ -2746,6 +2812,12 @@ zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
 		    (intmax_t)rsrc->uncompressed_size);
 		return (ARCHIVE_WARN);
 	}
+	if (rsrc->compressed_size > (4 * 1024 * 1024)) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Mac metadata is too large: %jd > 4M bytes",
+		    (intmax_t)rsrc->compressed_size);
+		return (ARCHIVE_WARN);
+	}
 
 	metadata = malloc((size_t)rsrc->uncompressed_size);
 	if (metadata == NULL) {
@@ -2784,6 +2856,8 @@ zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
 			bytes_avail = remaining_bytes;
 		switch(rsrc->compression) {
 		case 0:  /* No compression. */
+			if ((size_t)bytes_avail > metadata_bytes)
+				bytes_avail = metadata_bytes;
 			memcpy(mp, p, bytes_avail);
 			bytes_used = (size_t)bytes_avail;
 			metadata_bytes -= bytes_used;
diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c
index 3d4be82..282c58e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_string.c
+++ b/Utilities/cmlibarchive/libarchive/archive_string.c
@@ -737,7 +737,8 @@ archive_string_append_from_wcs_in_codepage(struct archive_string *as,
 			}
 			if (count == 0)
 				ret = -1;
-		} while (0);
+			break;
+		} while (1);
 	}
 	as->length += count;
 	as->s[as->length] = '\0';
diff --git a/Utilities/cmlibarchive/libarchive/archive_util.c b/Utilities/cmlibarchive/libarchive/archive_util.c
index 5f31edf..f89df1d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_util.c
+++ b/Utilities/cmlibarchive/libarchive/archive_util.c
@@ -94,35 +94,81 @@ archive_version_details(void)
 {
 	static struct archive_string str;
 	static int init = 0;
+	const char *zlib = archive_zlib_version();
+	const char *liblzma = archive_liblzma_version();
+	const char *bzlib = archive_bzlib_version();
+	const char *liblz4 = archive_liblz4_version();
 
 	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();
+		if (zlib != NULL) {
+			archive_strcat(&str, " zlib/");
+			archive_strcat(&str, zlib);
+		}
+		if (liblzma) {
+			archive_strcat(&str, " liblzma/");
+			archive_strcat(&str, liblzma);
+		}
+		if (bzlib) {
+			const char *p = bzlib;
 			const char *sep = strchr(p, ',');
 			if (sep == NULL)
 				sep = p + strlen(p);
 			archive_strcat(&str, " bz2lib/");
 			archive_strncat(&str, p, sep - p);
 		}
+		if (liblz4) {
+			archive_strcat(&str, " liblz4/");
+			archive_strcat(&str, liblz4);
+		}
+	}
+	return str.s;
+}
+
+const char *
+archive_zlib_version(void)
+{
+#ifdef HAVE_ZLIB_H
+	return ZLIB_VERSION;
+#else
+	return NULL;
+#endif
+}
+
+const char *
+archive_liblzma_version(void)
+{
+#ifdef HAVE_LZMA_H
+	return LZMA_VERSION_STRING;
+#else
+	return NULL;
 #endif
+}
+
+const char *
+archive_bzlib_version(void)
+{
+#ifdef HAVE_BZLIB_H
+	return BZ2_bzlibVersion();
+#else
+	return NULL;
+#endif
+}
+
+const char *
+archive_liblz4_version(void)
+{
 #if defined(HAVE_LZ4_H) && defined(HAVE_LIBLZ4)
-		archive_string_sprintf(&str, " liblz4/%d.%d.%d",
-		    LZ4_VERSION_MAJOR, LZ4_VERSION_MINOR, LZ4_VERSION_RELEASE);
+#define str(s) #s
+#define NUMBER(x) str(x)
+	return NUMBER(LZ4_VERSION_MAJOR) "." NUMBER(LZ4_VERSION_MINOR) "." NUMBER(LZ4_VERSION_RELEASE);
+#undef NUMBER
+#undef str
+#else
+	return NULL;
 #endif
-	}
-	return str.s;
 }
 
 int
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c
index 6526f51..6bd0d1d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c
@@ -105,7 +105,7 @@ archive_write_add_filter_bzip2(struct archive *_a)
 #if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
 	return (ARCHIVE_OK);
 #else
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate("bzip2");
 	if (data->pdata == NULL) {
 		free(data);
 		archive_set_error(&a->archive, ENOMEM, "Out of memory");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_grzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_grzip.c
index 8dc287e..371102d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_grzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_grzip.c
@@ -63,7 +63,7 @@ archive_write_add_filter_grzip(struct archive *_a)
 		archive_set_error(_a, ENOMEM, "Can't allocate memory");
 		return (ARCHIVE_FATAL);
 	}
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate("grzip");
 	if (data->pdata == NULL) {
 		free(data);
 		archive_set_error(_a, ENOMEM, "Can't allocate memory");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c
index db18fd9..bbcc178 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c
@@ -119,7 +119,7 @@ archive_write_add_filter_gzip(struct archive *_a)
 	data->compression_level = Z_DEFAULT_COMPRESSION;
 	return (ARCHIVE_OK);
 #else
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate("gzip");
 	if (data->pdata == NULL) {
 		free(data);
 		archive_set_error(&a->archive, ENOMEM, "Out of memory");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
index da1cf5e..e215f89 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
@@ -69,7 +69,7 @@ archive_write_add_filter_lrzip(struct archive *_a)
 		archive_set_error(_a, ENOMEM, "Can't allocate memory");
 		return (ARCHIVE_FATAL);
 	}
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate("lrzip");
 	if (data->pdata == NULL) {
 		free(data);
 		archive_set_error(_a, ENOMEM, "Can't allocate memory");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c
index e23e5e9..1d0ab8c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c
@@ -137,7 +137,7 @@ archive_write_add_filter_lz4(struct archive *_a)
 	 * We don't have lz4 library, and execute external lz4 program
 	 * instead.
 	 */
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate("lz4");
 	if (data->pdata == NULL) {
 		free(data);
 		archive_set_error(&a->archive, ENOMEM, "Out of memory");
@@ -160,10 +160,20 @@ archive_filter_lz4_options(struct archive_write_filter *f,
 	struct private_data *data = (struct private_data *)f->data;
 
 	if (strcmp(key, "compression-level") == 0) {
-		if (value == NULL || !(value[0] >= '1' && value[0] <= '9') ||
+		int val;
+		if (value == NULL || !((val = value[0] - '0') >= 1 && val <= 9) ||
 		    value[1] != '\0')
 			return (ARCHIVE_WARN);
-		data->compression_level = value[0] - '0';
+
+#ifndef HAVE_LZ4HC_H
+		if(val >= 3)
+		{
+			archive_set_error(f->archive, ARCHIVE_ERRNO_PROGRAMMER,
+				"High compression not included in this build");
+			return (ARCHIVE_FATAL);
+		}
+#endif
+		data->compression_level = val;
 		return (ARCHIVE_OK);
 	}
 	if (strcmp(key, "stream-checksum") == 0) {
@@ -367,14 +377,20 @@ archive_filter_lz4_free(struct archive_write_filter *f)
 	struct private_data *data = (struct private_data *)f->data;
 
 	if (data->lz4_stream != NULL) {
-		if (data->compression_level < 3)
+#ifdef HAVE_LZ4HC_H
+		if (data->compression_level >= 3)
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+			LZ4_freeStreamHC(data->lz4_stream);
+#else
+			LZ4_freeHC(data->lz4_stream);
+#endif
+		else
+#endif
 #if LZ4_VERSION_MINOR >= 3
 			LZ4_freeStream(data->lz4_stream);
 #else
 			LZ4_free(data->lz4_stream);
 #endif
-		else
-			LZ4_freeHC(data->lz4_stream);
 	}
 	free(data->out_buffer);
 	free(data->in_buffer_allocated);
@@ -481,13 +497,26 @@ drive_compressor_independence(struct archive_write_filter *f, const char *p,
 	struct private_data *data = (struct private_data *)f->data;
 	unsigned int outsize;
 
-	if (data->compression_level < 4)
-		outsize = LZ4_compress_limitedOutput(p, data->out + 4,
-		    (int)length, (int)data->block_size);
-	else
+#ifdef HAVE_LZ4HC_H
+	if (data->compression_level >= 3)
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+		outsize = LZ4_compress_HC(p, data->out + 4,
+		     (int)length, (int)data->block_size,
+		    data->compression_level);
+#else
 		outsize = LZ4_compressHC2_limitedOutput(p, data->out + 4,
 		    (int)length, (int)data->block_size,
 		    data->compression_level);
+#endif
+	else
+#endif
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+		outsize = LZ4_compress_default(p, data->out + 4,
+		    (int)length, (int)data->block_size);
+#else
+		outsize = LZ4_compress_limitedOutput(p, data->out + 4,
+		    (int)length, (int)data->block_size);
+#endif
 
 	if (outsize) {
 		/* The buffer is compressed. */
@@ -518,9 +547,17 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
 	struct private_data *data = (struct private_data *)f->data;
 	int outsize;
 
-	if (data->compression_level < 3) {
+#define DICT_SIZE	(64 * 1024)
+#ifdef HAVE_LZ4HC_H
+	if (data->compression_level >= 3) {
 		if (data->lz4_stream == NULL) {
-			data->lz4_stream = LZ4_createStream();
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+			data->lz4_stream = LZ4_createStreamHC();
+			LZ4_resetStreamHC(data->lz4_stream, data->compression_level);
+#else
+			data->lz4_stream =
+			    LZ4_createHC(data->in_buffer_allocated);
+#endif
 			if (data->lz4_stream == NULL) {
 				archive_set_error(f->archive, ENOMEM,
 				    "Can't allocate data for compression"
@@ -528,13 +565,23 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
 				return (ARCHIVE_FATAL);
 			}
 		}
-		outsize = LZ4_compress_limitedOutput_continue(
+		else
+			LZ4_loadDictHC(data->lz4_stream, data->in_buffer_allocated, DICT_SIZE);
+
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+		outsize = LZ4_compress_HC_continue(
 		    data->lz4_stream, p, data->out + 4, (int)length,
 		    (int)data->block_size);
-	} else {
+#else
+		outsize = LZ4_compressHC2_limitedOutput_continue(
+		    data->lz4_stream, p, data->out + 4, (int)length,
+		    (int)data->block_size, data->compression_level);
+#endif
+	} else
+#endif
+	{
 		if (data->lz4_stream == NULL) {
-			data->lz4_stream =
-			    LZ4_createHC(data->in_buffer_allocated);
+			data->lz4_stream = LZ4_createStream();
 			if (data->lz4_stream == NULL) {
 				archive_set_error(f->archive, ENOMEM,
 				    "Can't allocate data for compression"
@@ -542,9 +589,18 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
 				return (ARCHIVE_FATAL);
 			}
 		}
-		outsize = LZ4_compressHC2_limitedOutput_continue(
+		else
+			LZ4_loadDict(data->lz4_stream, data->in_buffer_allocated, DICT_SIZE);
+
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+		outsize = LZ4_compress_fast_continue(
 		    data->lz4_stream, p, data->out + 4, (int)length,
-		    (int)data->block_size, data->compression_level);
+		    (int)data->block_size, 1);
+#else
+		outsize = LZ4_compress_limitedOutput_continue(
+		    data->lz4_stream, p, data->out + 4, (int)length,
+		    (int)data->block_size);
+#endif
 	}
 
 	if (outsize) {
@@ -568,14 +624,19 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
 	}
 
 	if (length == data->block_size) {
-#define DICT_SIZE	(64 * 1024)
-		if (data->compression_level < 3)
-			LZ4_saveDict(data->lz4_stream,
-			    data->in_buffer_allocated, DICT_SIZE);
-		else {
+#ifdef HAVE_LZ4HC_H
+		if (data->compression_level >= 3) {
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+			LZ4_saveDictHC(data->lz4_stream, data->in_buffer_allocated, DICT_SIZE);
+#else
 			LZ4_slideInputBufferHC(data->lz4_stream);
+#endif
 			data->in_buffer = data->in_buffer_allocated + DICT_SIZE;
 		}
+		else
+#endif
+			LZ4_saveDict(data->lz4_stream,
+			    data->in_buffer_allocated, DICT_SIZE);
 #undef DICT_SIZE
 	}
 	return (ARCHIVE_OK);
@@ -605,7 +666,7 @@ archive_filter_lz4_open(struct archive_write_filter *f)
 	if (data->block_checksum)
 		archive_strcat(&as, " -BX");
 	if (data->stream_checksum == 0)
-		archive_strcat(&as, " -Sx");
+		archive_strcat(&as, " --no-frame-crc");
 	if (data->block_independence == 0)
 		archive_strcat(&as, " -BD");
 
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lzop.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lzop.c
index c666551..ad705c4 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lzop.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lzop.c
@@ -173,7 +173,7 @@ archive_write_add_filter_lzop(struct archive *_a)
 	data->compression_level = 5;
 	return (ARCHIVE_OK);
 #else
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate("lzop");
 	if (data->pdata == NULL) {
 		free(data);
 		archive_set_error(_a, ENOMEM, "Can't allocate memory");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c
index fc232da..31a1b6f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c
@@ -68,6 +68,7 @@ struct archive_write_program_data {
 
 	char		*child_buf;
 	size_t		 child_buf_len, child_buf_avail;
+	char		*program_name;
 };
 
 struct private_data {
@@ -105,7 +106,7 @@ archive_write_add_filter_program(struct archive *_a, const char *cmd)
 	if (data->cmd == NULL)
 		goto memerr;
 
-	data->pdata = __archive_write_program_allocate();
+	data->pdata = __archive_write_program_allocate(cmd);
 	if (data->pdata == NULL)
 		goto memerr;
 
@@ -174,7 +175,7 @@ archive_compressor_program_free(struct archive_write_filter *f)
  * Allocate resources for executing an external program.
  */
 struct archive_write_program_data *
-__archive_write_program_allocate(void)
+__archive_write_program_allocate(const char *program)
 {
 	struct archive_write_program_data *data;
 
@@ -183,6 +184,7 @@ __archive_write_program_allocate(void)
 		return (data);
 	data->child_stdin = -1;
 	data->child_stdout = -1;
+	data->program_name = strdup(program);
 	return (data);
 }
 
@@ -231,7 +233,7 @@ __archive_write_program_open(struct archive_write_filter *f,
 		    &data->child_stdout);
 	if (child == -1) {
 		archive_set_error(f->archive, EINVAL,
-		    "Can't initialise filter");
+		    "Can't launch external program: %s", cmd);
 		return (ARCHIVE_FATAL);
 	}
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -242,7 +244,7 @@ __archive_write_program_open(struct archive_write_filter *f,
 		close(data->child_stdout);
 		data->child_stdout = -1;
 		archive_set_error(f->archive, EINVAL,
-		    "Can't initialise filter");
+		    "Can't launch external program: %s", cmd);
 		return (ARCHIVE_FATAL);
 	}
 #else
@@ -334,7 +336,7 @@ __archive_write_program_write(struct archive_write_filter *f,
 		ret = child_write(f, data, buf, length);
 		if (ret == -1 || ret == 0) {
 			archive_set_error(f->archive, EIO,
-			    "Can't write to filter");
+			    "Can't write to program: %s", data->program_name);
 			return (ARCHIVE_FATAL);
 		}
 		length -= ret;
@@ -373,7 +375,7 @@ __archive_write_program_close(struct archive_write_filter *f,
 
 		if (bytes_read == -1) {
 			archive_set_error(f->archive, errno,
-			    "Read from filter failed unexpectedly.");
+			    "Error reading from program: %s", data->program_name);
 			ret = ARCHIVE_FATAL;
 			goto cleanup;
 		}
@@ -403,7 +405,7 @@ cleanup:
 
 	if (status != 0) {
 		archive_set_error(f->archive, EIO,
-		    "Filter exited with failure.");
+		    "Error closing program: %s", data->program_name);
 		ret = ARCHIVE_FATAL;
 	}
 	r1 = __archive_write_close_filter(f->next_filter);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
index 450ac75..5946683 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
@@ -2386,6 +2386,9 @@ check_symlinks(struct archive_write_disk *a)
 		while ((*pn != '\0') && (*p == *pn))
 			++p, ++pn;
 	}
+	/* Skip the root directory if the path is absolute. */
+	if(pn == a->name && pn[0] == '/')
+		++pn;
 	c = pn[0];
 	/* Keep going until we've checked the entire name. */
 	while (pn[0] != '\0' && (pn[0] != '/' || pn[1] != '\0')) {
@@ -2447,6 +2450,9 @@ check_symlinks(struct archive_write_disk *a)
 				return (ARCHIVE_FAILED);
 			}
 		}
+		pn[0] = c;
+		if (pn[0] != '\0')
+			pn++; /* Advance to the next segment. */
 	}
 	pn[0] = c;
 	/* We've checked and/or cleaned the whole path, so remember it. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
index 800aa89..da76c54 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
@@ -468,9 +468,17 @@ permissive_name_w(struct archive_write_disk *a)
 		return (-1);
 	archive_wstring_ensure(&(a->_name_data), 4 + l + 1 + wcslen(wn) + 1);
 	a->name = a->_name_data.s;
-	/* Prepend "\\?\" and drive name. */
-	archive_wstrncpy(&(a->_name_data), L"\\\\?\\", 4);
-	archive_wstrncat(&(a->_name_data), wsp, l);
+	/* Prepend "\\?\" and drive name if not already added. */
+	if (l > 3 && wsp[0] == L'\\' && wsp[1] == L'\\' &&
+		wsp[2] == L'?' && wsp[3] == L'\\')
+	{
+		archive_wstrncpy(&(a->_name_data), wsp, l);
+	}
+	else
+	{
+		archive_wstrncpy(&(a->_name_data), L"\\\\?\\", 4);
+		archive_wstrncat(&(a->_name_data), wsp, l);
+	}
 	archive_wstrncat(&(a->_name_data), L"\\", 1);
 	archive_wstrcat(&(a->_name_data), wn);
 	a->name = a->_name_data.s;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_filter.3 b/Utilities/cmlibarchive/libarchive/archive_write_filter.3
index 83bd2c6..e1d1891 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_filter.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_filter.3
@@ -29,9 +29,12 @@
 .Os
 .Sh NAME
 .Nm archive_write_add_filter_b64encode ,
+.Nm archive_write_add_filter_by_name ,
 .Nm archive_write_add_filter_bzip2 ,
 .Nm archive_write_add_filter_compress ,
+.Nm archive_write_add_filter_grzip ,
 .Nm archive_write_add_filter_gzip ,
+.Nm archive_write_add_filter_lrzip ,
 .Nm archive_write_add_filter_lz4 ,
 .Nm archive_write_add_filter_lzip ,
 .Nm archive_write_add_filter_lzma ,
@@ -40,6 +43,7 @@
 .Nm archive_write_add_filter_program ,
 .Nm archive_write_add_filter_uuencode ,
 .Nm archive_write_add_filter_xz
+.Nd functions enabling output filters
 .Sh LIBRARY
 Streaming Archive Library (libarchive, -larchive)
 .Sh SYNOPSIS
@@ -51,8 +55,12 @@ Streaming Archive Library (libarchive, -larchive)
 .Ft int
 .Fn archive_write_add_filter_compress "struct archive *"
 .Ft int
+.Fn archive_write_add_filter_grzip "struct archive *"
+.Ft int
 .Fn archive_write_add_filter_gzip "struct archive *"
 .Ft int
+.Fn archive_write_add_filter_lrzip "struct archive *"
+.Ft int
 .Fn archive_write_add_filter_lz4 "struct archive *"
 .Ft int
 .Fn archive_write_add_filter_lzip "struct archive *"
@@ -71,19 +79,25 @@ Streaming Archive Library (libarchive, -larchive)
 .Sh DESCRIPTION
 .Bl -tag -width indent
 .It Xo
-.Fn archive_write_add_filter_b64encode ,
 .Fn archive_write_add_filter_bzip2 ,
 .Fn archive_write_add_filter_compress ,
+.Fn archive_write_add_filter_grzip ,
 .Fn archive_write_add_filter_gzip ,
+.Fn archive_write_add_filter_lrzip ,
 .Fn archive_write_add_filter_lz4 ,
 .Fn archive_write_add_filter_lzip ,
 .Fn archive_write_add_filter_lzma ,
 .Fn archive_write_add_filter_lzop ,
-.Fn archive_write_add_filter_uuencode ,
 .Fn archive_write_add_filter_xz ,
 .Xc
 The resulting archive will be compressed as specified.
 Note that the compressed output is always properly blocked.
+.It Xo
+.Fn archive_write_add_filter_b64encode ,
+.Fn archive_write_add_filter_uuencode ,
+.Xc
+The output will be encoded as specified.
+The encoded output is always properly blocked.
 .It Fn archive_write_add_filter_none
 This is never necessary.
 It is provided only for backwards compatibility.
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_format.3 b/Utilities/cmlibarchive/libarchive/archive_write_format.3
index 4bd1163..d4ba6ab 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_format.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_format.3
@@ -28,23 +28,63 @@
 .Dt ARCHIVE_WRITE_FORMAT 3
 .Os
 .Sh NAME
+.Nm archive_write_set_format ,
+.Nm archive_write_set_format_7zip ,
+.Nm archive_write_set_format_ar ,
+.Nm archive_write_set_format_ar_bsd ,
+.Nm archive_write_set_format_ar_svr4 ,
+.Nm archive_write_set_format_by_name ,
 .Nm archive_write_set_format_cpio ,
+.Nm archive_write_set_format_cpio_newc ,
+.Nm archive_write_set_format_filter_by_ext ,
+.Nm archive_write_set_format_filter_by_ext_def ,
+.Nm archive_write_set_format_gnutar ,
+.Nm archive_write_set_format_iso9660 ,
+.Nm archive_write_set_format_mtree ,
+.Nm archive_write_set_format_mtree_classic ,
+.Nm archive_write_set_format_mtree_default ,
 .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 ,
-.Nm archive_write_set_format_filter_by_ext ,
-.Nm archive_write_set_format_filter_by_ext_def
+.Nm archive_write_set_format_v7tar ,
+.Nm archive_write_set_format_warc ,
+.Nm archive_write_set_format_xar ,
+.Nm archive_write_set_format_zip ,
 .Nd functions for creating archives
 .Sh LIBRARY
 Streaming Archive Library (libarchive, -larchive)
 .Sh SYNOPSIS
 .In archive.h
 .Ft int
+.Fn archive_write_set_format "struct archive *" "int code"
+.Ft int
+.Fn archive_write_set_format_7zip "struct archive *"
+.Ft int
+.Fn archive_write_set_format_ar "struct archive *"
+.Ft int
+.Fn archive_write_set_format_ar_bsd "struct archive *"
+.Ft int
+.Fn archive_write_set_format_ar_svr4 "struct archive *"
+.Ft int
+.Fn archive_write_set_format_by_name "struct archive *" "const char *name"
+.Ft int
 .Fn archive_write_set_format_cpio "struct archive *"
 .Ft int
+.Fn archive_write_set_format_cpio_newc "struct archive *"
+.Ft int
+.Fn archive_write_set_format_filter_by_ext "struct archive *" "const char *filename"
+.Ft int
+.Fn archive_write_set_format_filter_by_ext_def "struct archive *" "const char *filename" "const char *def_ext"
+.Ft int
+.Fn archive_write_set_format_gnutar "struct archive *"
+.Ft int
+.Fn archive_write_set_format_iso9660 "struct archive *"
+.Ft int
+.Fn archive_write_set_format_mtree "struct archive *"
+.Ft int
 .Fn archive_write_set_format_pax "struct archive *"
 .Ft int
 .Fn archive_write_set_format_pax_restricted "struct archive *"
@@ -57,42 +97,60 @@ Streaming Archive Library (libarchive, -larchive)
 .Ft int
 .Fn archive_write_set_format_ustar "struct archive *"
 .Ft int
-.Fn archive_write_set_format_filter_by_ext "struct archive *" "const char *"
+.Fn archive_write_set_format_v7tar "struct archive *"
+.Ft int
+.Fn archive_write_set_format_warc "struct archive *"
 .Ft int
-.Fn archive_write_set_format_filter_by_ext_def "struct archive *" "const char *" "const char *"
+.Fn archive_write_set_format_xar "struct archive *"
+.Ft int
+.Fn archive_write_set_format_zip "struct archive *"
 .Sh DESCRIPTION
 These functions set the format that will be used for the archive.
 .Pp
-The library can write
-POSIX octet-oriented cpio format archives,
-POSIX-standard
-.Dq pax interchange
-format archives,
-traditional
-.Dq shar
-archives,
-enhanced
-.Dq dump
-shar archives that store a variety of file attributes and handle binary files,
-and
-POSIX-standard
-.Dq ustar
-archives.
-The pax interchange format is a backwards-compatible tar format that
-adds key/value attributes to each entry and supports arbitrary
-filenames, linknames, uids, sizes, etc.
-.Dq Restricted pax interchange format
-is the library default; this is the same as pax format, but suppresses
-the pax extended header for most normal files.
-In most cases, this will result in ordinary ustar archives.
+The library can write a variety of common archive formats.
+
 .Bl -tag -width indent
+.It Fn archive_write_set_format
+Sets the format based on the format code (see
+.Pa archive.h
+for the full list of format codes).
+In particular, this can be used in conjunction with
+.Fn archive_format
+to create a new archive with the same format as an existing archive.
+.It Fn archive_write_set_format_by_name
+Sets the corresponding format based on the common name.
 .It Xo
 .Fn archive_write_set_format_filter_by_ext ,
 .Fn archive_write_set_format_filter_by_ext_def
 .Xc
-Format and filter for archive can be set automatically, based on output file name extension.
-The functions are platform dependent.
+Sets both filters and format based on the output filename.
 Supported extensions: .7z, .zip, .jar, .cpio, .iso, .a, .ar, .tar, .tgz, .tar.gz, .tar.bz2, .tar.xz
+.It Xo
+.Fn archive_write_set_format_7zip
+.Fn archive_write_set_format_ar_bsd ,
+.Fn archive_write_set_format_ar_svr4 ,
+.Fn archive_write_set_format_cpio
+.Fn archive_write_set_format_cpio_newc
+.Fn archive_write_set_format_gnutar
+.Fn archive_write_set_format_iso9660
+.Fn archive_write_set_format_mtree
+.Fn archive_write_set_format_mtree_classic
+.Fn archive_write_set_format_pax
+.Fn archive_write_set_format_pax_restricted
+.Fn archive_write_set_format_raw
+.Fn archive_write_set_format_shar
+.Fn archive_write_set_format_shar_dump
+.Fn archive_write_set_format_ustar
+.Fn archive_write_set_format_v7tar
+.Fn archive_write_set_format_warc
+.Fn archive_write_set_format_xar
+.Fn archive_write_set_format_zip
+.Xc
+Set the format as specified.
+More details on the formats supported by libarchive can be found in the
+.Xr libarchive-formats 5
+manual page.
+.El
 .\"
 .Sh RETURN VALUES
 These functions return
@@ -113,5 +171,6 @@ functions.
 .Xr archive_write 3 ,
 .Xr archive_write_set_options 3 ,
 .Xr cpio 5 ,
+.Xr libarchive-formats 5 ,
 .Xr mtree 5 ,
 .Xr tar 5
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_private.h b/Utilities/cmlibarchive/libarchive/archive_write_private.h
index 0c3cc0c..0dfd1b1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_write_private.h
@@ -144,7 +144,7 @@ __archive_write_format_header_ustar(struct archive_write *, char buff[512],
     struct archive_string_conv *);
 
 struct archive_write_program_data;
-struct archive_write_program_data * __archive_write_program_allocate(void);
+struct archive_write_program_data * __archive_write_program_allocate(const char *program_name);
 int	__archive_write_program_free(struct archive_write_program_data *);
 int	__archive_write_program_open(struct archive_write_filter *,
 	    struct archive_write_program_data *, const char *);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
index 5158854..8718d25 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
@@ -1450,6 +1450,10 @@ _7z_free(struct archive_write *a)
 {
 	struct _7zip *zip = (struct _7zip *)a->format_data;
 
+	/* Close the temporary file. */
+	if (zip->temp_fd >= 0)
+		close(zip->temp_fd);
+
 	file_free_register(zip);
 	compression_end(&(a->archive), &(zip->stream));
 	free(zip->coder.props);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c
index 647079d..1d635d2 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_gnutar.c
@@ -467,7 +467,7 @@ archive_write_gnutar_header(struct archive_write *a,
 		}
 	}
 	if (gnutar->linkname_length > GNUTAR_linkname_size) {
-		size_t todo = gnutar->linkname_length;
+		size_t length = gnutar->linkname_length + 1;
 		struct archive_entry *temp = archive_entry_new2(&a->archive);
 
 		/* Uname/gname here don't really matter since no one reads them;
@@ -476,7 +476,7 @@ archive_write_gnutar_header(struct archive_write *a,
 		archive_entry_set_gname(temp, "wheel");
 
 		archive_entry_set_pathname(temp, "././@LongLink");
-		archive_entry_set_size(temp, gnutar->linkname_length + 1);
+		archive_entry_set_size(temp, length);
 		ret = archive_format_gnutar_header(a, buff, temp, 'K');
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
@@ -484,11 +484,12 @@ archive_write_gnutar_header(struct archive_write *a,
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
 		archive_entry_free(temp);
-		/* Write as many 512 bytes blocks as needed to write full name. */
-		ret = __archive_write_output(a, gnutar->linkname, todo);
+		/* Write name and trailing null byte. */
+		ret = __archive_write_output(a, gnutar->linkname, length);
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
-		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)todo));
+		/* Pad to 512 bytes */
+		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)length));
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
 	}
@@ -496,7 +497,7 @@ archive_write_gnutar_header(struct archive_write *a,
 	/* If pathname is longer than 100 chars we need to add an 'L' header. */
 	if (gnutar->pathname_length > GNUTAR_name_size) {
 		const char *pathname = gnutar->pathname;
-		size_t todo = gnutar->pathname_length;
+		size_t length = gnutar->pathname_length + 1;
 		struct archive_entry *temp = archive_entry_new2(&a->archive);
 
 		/* Uname/gname here don't really matter since no one reads them;
@@ -505,7 +506,7 @@ archive_write_gnutar_header(struct archive_write *a,
 		archive_entry_set_gname(temp, "wheel");
 
 		archive_entry_set_pathname(temp, "././@LongLink");
-		archive_entry_set_size(temp, gnutar->pathname_length + 1);
+		archive_entry_set_size(temp, length);
 		ret = archive_format_gnutar_header(a, buff, temp, 'L');
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
@@ -513,11 +514,12 @@ archive_write_gnutar_header(struct archive_write *a,
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
 		archive_entry_free(temp);
-		/* Write as many 512 bytes blocks as needed to write full name. */
-		ret = __archive_write_output(a, pathname, todo);
+		/* Write pathname + trailing null byte. */
+		ret = __archive_write_output(a, pathname, length);
 		if(ret < ARCHIVE_WARN)
 			goto exit_write_header;
-		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)todo));
+		/* Pad to multiple of 512 bytes. */
+		ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)length));
 		if (ret < ARCHIVE_WARN)
 			goto exit_write_header;
 	}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
index 576f4c2..879a776 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
@@ -6225,7 +6225,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
 	unsigned char *p;
 	size_t l;
 	int r;
-	int ffmax, parent_len;
+	size_t ffmax, parent_len;
 	static const struct archive_rb_tree_ops rb_ops = {
 		isoent_cmp_node_joliet, isoent_cmp_key_joliet
 	};
@@ -6239,7 +6239,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
 	else
 		ffmax = 128;
 
-	r = idr_start(a, idr, isoent->children.cnt, ffmax, 6, 2, &rb_ops);
+	r = idr_start(a, idr, isoent->children.cnt, (int)ffmax, 6, 2, &rb_ops);
 	if (r < 0)
 		return (r);
 
@@ -6252,7 +6252,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
 		int ext_off, noff, weight;
 		size_t lt;
 
-		if ((int)(l = np->file->basename_utf16.length) > ffmax)
+		if ((l = np->file->basename_utf16.length) > ffmax)
 			l = ffmax;
 
 		p = malloc((l+1)*2);
@@ -6285,7 +6285,7 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
 		/*
 		 * Get a length of MBS of a full-pathname.
 		 */
-		if ((int)np->file->basename_utf16.length > ffmax) {
+		if (np->file->basename_utf16.length > ffmax) {
 			if (archive_strncpy_l(&iso9660->mbs,
 			    (const char *)np->identifier, l,
 				iso9660->sconv_from_utf16be) != 0 &&
@@ -6302,7 +6302,9 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
 
 		/* If a length of full-pathname is longer than 240 bytes,
 		 * it violates Joliet extensions regulation. */
-		if (parent_len + np->mb_len > 240) {
+		if (parent_len > 240
+		    || np->mb_len > 240
+		    || parent_len + np->mb_len > 240) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "The regulation of Joliet extensions;"
 			    " A length of a full-pathname of `%s' is "
@@ -6314,11 +6316,11 @@ isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
 
 		/* Make an offset of the number which is used to be set
 		 * hexadecimal number to avoid duplicate identifier. */
-		if ((int)l == ffmax)
+		if (l == ffmax)
 			noff = ext_off - 6;
-		else if ((int)l == ffmax-2)
+		else if (l == ffmax-2)
 			noff = ext_off - 4;
-		else if ((int)l == ffmax-4)
+		else if (l == ffmax-4)
 			noff = ext_off - 2;
 		else
 			noff = ext_off;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
index 687f8e4..6f7fe78 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
@@ -1036,22 +1036,12 @@ archive_write_pax_header(struct archive_write *a,
 		need_extension = 1;
 
 	/*
-	 * The following items are handled differently in "pax
-	 * restricted" format.  In particular, in "pax restricted"
-	 * format they won't be added unless need_extension is
-	 * already set (we're already generating an extended header, so
-	 * may as well include these).
+	 * Libarchive used to include these in extended headers for
+	 * restricted pax format, but that confused people who
+	 * expected ustar-like time semantics.  So now we only include
+	 * them in full pax format.
 	 */
-	if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||
-	    need_extension) {
-
-		if (archive_entry_mtime(entry_main) < 0  ||
-		    archive_entry_mtime(entry_main) >= 0x7fffffff  ||
-		    archive_entry_mtime_nsec(entry_main) != 0)
-			add_pax_attr_time(&(pax->pax_header), "mtime",
-			    archive_entry_mtime(entry_main),
-			    archive_entry_mtime_nsec(entry_main));
-
+	if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED) {
 		if (archive_entry_ctime(entry_main) != 0  ||
 		    archive_entry_ctime_nsec(entry_main) != 0)
 			add_pax_attr_time(&(pax->pax_header), "ctime",
@@ -1072,6 +1062,23 @@ archive_write_pax_header(struct archive_write *a,
 			    "LIBARCHIVE.creationtime",
 			    archive_entry_birthtime(entry_main),
 			    archive_entry_birthtime_nsec(entry_main));
+	}
+
+	/*
+	 * The following items are handled differently in "pax
+	 * restricted" format.  In particular, in "pax restricted"
+	 * format they won't be added unless need_extension is
+	 * already set (we're already generating an extended header, so
+	 * may as well include these).
+	 */
+	if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||
+	    need_extension) {
+		if (archive_entry_mtime(entry_main) < 0  ||
+		    archive_entry_mtime(entry_main) >= 0x7fffffff  ||
+		    archive_entry_mtime_nsec(entry_main) != 0)
+			add_pax_attr_time(&(pax->pax_header), "mtime",
+			    archive_entry_mtime(entry_main),
+			    archive_entry_mtime_nsec(entry_main));
 
 		/* I use a star-compatible file flag attribute. */
 		p = archive_entry_fflags_text(entry_main);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c
index 80abc6f..ea66929 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c
@@ -186,16 +186,18 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
 
 	/* check whether warcinfo record needs outputting */
 	if (!w->omit_warcinfo) {
+		ssize_t r;
 		warc_essential_hdr_t wi = {
 			WT_INFO,
 			/*uri*/NULL,
 			/*urn*/NULL,
-			/*rtm*/w->now,
-			/*mtm*/w->now,
+			/*rtm*/0,
+			/*mtm*/0,
 			/*cty*/"application/warc-fields",
 			/*len*/sizeof(warcinfo) - 1U,
 		};
-		ssize_t r;
+		wi.rtime = w->now;
+		wi.mtime = w->now;
 
 		archive_string_init(&hdr);
 		r = _popul_ehdr(&hdr, MAX_HDR_SIZE, wi);
@@ -226,14 +228,18 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
 	if (w->typ == AE_IFREG) {
 		warc_essential_hdr_t rh = {
 			WT_RSRC,
-			/*uri*/archive_entry_pathname(entry),
+			/*uri*/NULL,
 			/*urn*/NULL,
-			/*rtm*/w->now,
-			/*mtm*/archive_entry_mtime(entry),
+			/*rtm*/0,
+			/*mtm*/0,
 			/*cty*/NULL,
-			/*len*/(size_t)archive_entry_size(entry),
+			/*len*/0,
 		};
 		ssize_t r;
+		rh.tgturi = archive_entry_pathname(entry);
+		rh.rtime = w->now;
+		rh.mtime = archive_entry_mtime(entry);
+		rh.cntlen = (size_t)archive_entry_size(entry);
 
 		archive_string_init(&hdr);
 		r = _popul_ehdr(&hdr, MAX_HDR_SIZE, rh);
@@ -325,16 +331,16 @@ xstrftime(struct archive_string *as, const char *fmt, time_t t)
 /** like strftime(3) but for time_t objects */
 	struct tm *rt;
 #if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
-	struct tm time;
+	struct tm timeHere;
 #endif
 	char strtime[100];
 	size_t len;
 
 #ifdef HAVE_GMTIME_R
-	if ((rt = gmtime_r(&t, &time)) == NULL)
+	if ((rt = gmtime_r(&t, &timeHere)) == NULL)
 		return;
 #elif defined(HAVE__GMTIME64_S)
-	_gmtime64_s(&time, &t);
+	_gmtime64_s(&timeHere, &t);
 #else
 	if ((rt = gmtime(&t)) == NULL)
 		return;
@@ -396,7 +402,7 @@ _popul_ehdr(struct archive_string *tgt, size_t tsz, warc_essential_hdr_t hdr)
 		 * handle the minimum number following '%'.
 		 * So we have to use snprintf function here instead
 		 * of archive_string_snprintf function. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !( defined(_MSC_VER) && _MSC_VER >= 1900)
 #define snprintf _snprintf
 #endif
 		snprintf(
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c
index a47c53c..58ad9e0 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c
@@ -1877,6 +1877,11 @@ xar_free(struct archive_write *a)
 	struct xar *xar;
 
 	xar = (struct xar *)a->format_data;
+
+	/* Close the temporary file. */
+	if (xar->temp_fd >= 0)
+		close(xar->temp_fd);
+
 	archive_string_free(&(xar->cur_dirstr));
 	archive_string_free(&(xar->tstr));
 	archive_string_free(&(xar->vstr));
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
index 0636f46..0b2c69b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
@@ -66,6 +66,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 20
 #define ZIP_ENTRY_FLAG_LENGTH_AT_END	(1<<3)
 #define ZIP_ENTRY_FLAG_UTF8_NAME	(1 << 11)
 
+#define ZIP_4GB_MAX ARCHIVE_LITERAL_LL(0xffffffff)
+#define ZIP_4GB_MAX_UNCOMPRESSED ARCHIVE_LITERAL_LL(0xff000000)
+
 enum compression {
 	COMPRESSION_UNSPECIFIED = -1,
 	COMPRESSION_STORE = 0,
@@ -532,14 +535,13 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
 	if (zip->flags & ZIP_FLAG_AVOID_ZIP64) {
 		/* Reject entries over 4GB. */
 		if (archive_entry_size_is_set(entry)
-		    && (archive_entry_size(entry) >
-			ARCHIVE_LITERAL_LL(0xffffffff))) {
+		    && (archive_entry_size(entry) > ZIP_4GB_MAX)) {
 			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 > ARCHIVE_LITERAL_LL(0xffffffff)) {
+		if (zip->written_bytes > ZIP_4GB_MAX) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "Archives > 4GB require Zip64 extensions");
 			return ARCHIVE_FAILED;
@@ -727,10 +729,8 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
 		 *    (compression might make file larger)
 		 */
 		if ((zip->flags & ZIP_FLAG_FORCE_ZIP64)
-		    || (zip->entry_uncompressed_size + additional_size >
-			ARCHIVE_LITERAL_LL(0xffffffff))
-		    || (zip->entry_uncompressed_size >
-			ARCHIVE_LITERAL_LL(0xff000000)
+		    || (zip->entry_uncompressed_size + additional_size > ZIP_4GB_MAX)
+		    || (zip->entry_uncompressed_size > ZIP_4GB_MAX_UNCOMPRESSED
 			&& zip->entry_compression != COMPRESSION_STORE)) {
 			zip->entry_uses_zip64 = 1;
 			version_needed = 45;
@@ -788,8 +788,8 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
 		 * 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));
+		archive_le32enc(local_header + 18, ZIP_4GB_MAX);
+		archive_le32enc(local_header + 22, ZIP_4GB_MAX);
 	} else {
 		archive_le32enc(local_header + 18, (uint32_t)zip->entry_compressed_size);
 		archive_le32enc(local_header + 22, (uint32_t)zip->entry_uncompressed_size);
@@ -1217,22 +1217,22 @@ archive_write_zip_finish_entry(struct archive_write *a)
 	}
 
 	/* 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)) {
+	if (zip->entry_compressed_written > ZIP_4GB_MAX
+	    || zip->entry_uncompressed_written > ZIP_4GB_MAX
+	    || zip->entry_offset > ZIP_4GB_MAX) {
 		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)) {
+		if (zip->entry_uncompressed_written >= ZIP_4GB_MAX) {
 			archive_le64enc(z, zip->entry_uncompressed_written);
 			z += 8;
 		}
-		if (zip->entry_compressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+		if (zip->entry_compressed_written >= ZIP_4GB_MAX) {
 			archive_le64enc(z, zip->entry_compressed_written);
 			z += 8;
 		}
-		if (zip->entry_offset >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+		if (zip->entry_offset >= ZIP_4GB_MAX) {
 			archive_le64enc(z, zip->entry_offset);
 			z += 8;
 		}
@@ -1256,15 +1256,15 @@ archive_write_zip_finish_entry(struct archive_write *a)
 		archive_le32enc(zip->file_header + 16, zip->entry_crc32);
 	archive_le32enc(zip->file_header + 20,
 		(uint32_t)zipmin(zip->entry_compressed_written,
-				 ARCHIVE_LITERAL_LL(0xffffffff)));
+				 ZIP_4GB_MAX));
 	archive_le32enc(zip->file_header + 24,
 		(uint32_t)zipmin(zip->entry_uncompressed_written,
-				 ARCHIVE_LITERAL_LL(0xffffffff)));
+				 ZIP_4GB_MAX));
 	archive_le16enc(zip->file_header + 30,
 	    (uint16_t)(zip->central_directory_bytes - zip->file_header_extra_offset));
 	archive_le32enc(zip->file_header + 42,
 		(uint32_t)zipmin(zip->entry_offset,
-				 ARCHIVE_LITERAL_LL(0xffffffff)));
+				 ZIP_4GB_MAX));
 
 	return (ARCHIVE_OK);
 }
@@ -1291,8 +1291,8 @@ archive_write_zip_close(struct archive_write *a)
 	offset_end = zip->written_bytes;
 
 	/* 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)
+	if (offset_end - offset_start > ZIP_4GB_MAX
+	    || offset_start > ZIP_4GB_MAX
 	    || zip->central_directory_entries > 0xffffUL
 	    || (zip->flags & ZIP_FLAG_FORCE_ZIP64)) {
 	  /* Zip64 end-of-cd record */
@@ -1332,11 +1332,9 @@ archive_write_zip_close(struct archive_write *a)
 	archive_le16enc(buff + 10, (uint16_t)zipmin(0xffffU,
 		zip->central_directory_entries));
 	archive_le32enc(buff + 12,
-		(uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff),
-				 (offset_end - offset_start)));
+		(uint32_t)zipmin(ZIP_4GB_MAX, (offset_end - offset_start)));
 	archive_le32enc(buff + 16,
-		(uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff),
-				 offset_start));
+		(uint32_t)zipmin(ZIP_4GB_MAX, offset_start));
 	ret = __archive_write_output(a, buff, 22);
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_options.3 b/Utilities/cmlibarchive/libarchive/archive_write_set_options.3
index a2f4b57..aeb7a18 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_options.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_options.3
@@ -32,7 +32,7 @@
 .Nm archive_write_set_format_option ,
 .Nm archive_write_set_option ,
 .Nm archive_write_set_options
-.Nd functions controlling options for reading archives
+.Nd functions controlling options for writing archives
 .Sh LIBRARY
 Streaming Archive Library (libarchive, -larchive)
 .Sh SYNOPSIS
@@ -101,7 +101,12 @@ and
 .Ar value
 will be provided to the filter or reader named
 .Ar module .
-The return value will be that of the module.
+The return value will be either
+.Cm ARCHIVE_OK
+if the option was successfully handled or
+.Cm ARCHIVE_WARN
+if the option was unrecognized by the module or could otherwise
+not be handled.
 If there is no such module,
 .Cm ARCHIVE_FAILED
 will be returned.
@@ -123,9 +128,7 @@ will be returned if any module accepts the option, and
 .Cm ARCHIVE_FAILED
 in all other cases.
 .\"
-.It Xo
-.Fn archive_write_set_option
-.Xc
+.It Fn archive_write_set_option
 Calls
 .Fn archive_write_set_format_option ,
 then
@@ -137,9 +140,7 @@ will be returned
 immediately.
 Otherwise, greater of the two values will be returned.
 .\"
-.It Xo
-.Fn archive_write_set_options
-.Xc
+.It Fn archive_write_set_options
 .Ar options
 is a comma-separated list of options.
 If
@@ -456,7 +457,7 @@ archive_write_open_filename(a, filename, blocksize);
 .Ed
 .\"
 .Sh ERRORS
-Detailed error codes and textual descriptions are available from the
+More detailed error codes and textual descriptions are available from the
 .Fn archive_errno
 and
 .Fn archive_error_string
diff --git a/Utilities/cmlibarchive/libarchive/libarchive-formats.5 b/Utilities/cmlibarchive/libarchive/libarchive-formats.5
index 4a709b3..9cec760 100644
--- a/Utilities/cmlibarchive/libarchive/libarchive-formats.5
+++ b/Utilities/cmlibarchive/libarchive/libarchive-formats.5
@@ -55,7 +55,7 @@ It can write POSIX-standard
 .Dq ustar
 and
 .Dq pax interchange
-formats and a subset of the legacy GNU tar format.
+formats as well as v7 tar format and a subset of the legacy GNU tar format.
 .Pp
 All tar formats store each entry in one or more 512-byte records.
 The first record is used for file metadata, including filename,
@@ -65,7 +65,6 @@ Later variants have extended this by either appropriating undefined
 areas of the header record, extending the header to multiple records,
 or by storing special entries that modify the interpretation of
 subsequent entries.
-.Pp
 .Bl -tag -width indent
 .It Cm gnutar
 The
@@ -150,6 +149,30 @@ Archive entries are limited to 8 gigabytes in size.
 Note that the pax interchange format has none of these restrictions.
 The ustar format is old and widely supported.
 It is recommended when compatibility is the primary concern.
+.It Cm v7
+The libarchive library can read and write the legacy v7 tar format.
+This format has the following limitations:
+.Bl -bullet -compact
+.It
+Only regular files, directories, and symbolic links can be archived.
+Block and character device nodes, FIFOs, and sockets cannot be archived.
+.It
+Path names in the archive are limited to 100 bytes.
+.It
+Symbolic links and hard links are stored in the archive with
+the name of the referenced file.
+This name is limited to 100 bytes.
+.It
+User and group information are stored as numeric IDs; there
+is no provision for storing user or group names.
+.It
+Extended attributes, file flags, and other extended
+security information cannot be stored.
+.It
+Archive entries are limited to 8 gigabytes in size.
+.El
+Generally, users should prefer the ustar format for portability
+as the v7 tar format is both less useful and less portable.
 .El
 .Pp
 The libarchive library also reads a variety of commonly-used extensions to
@@ -211,7 +234,7 @@ This format stores the header contents as octal values in ASCII.
 It is standard, portable, and immune from byte-order confusion.
 File sizes and mtime are limited to 33 bits (8GB file size),
 other fields are limited to 18 bits.
-.It Cm SVR4
+.It Cm SVR4/newc
 The libarchive library can read both CRC and non-CRC variants of
 this format.
 The SVR4 format uses eight-digit hexadecimal values for
@@ -364,8 +387,10 @@ area adjacent to the entry.
 Libarchive can read both extensions,
 including archives that may include both types of long filenames.
 Programs using libarchive can write GNU/SVR4 format
-if they provide a filename table to be written into
-the archive before any of the entries.
+if they provide an entry called
+.Pa //
+containing a filename table to be written into the archive
+before any of the entries.
 Any entries whose names are not in the filename table
 will be written using BSD-style long filenames.
 This can cause problems for programs such as
@@ -406,18 +431,29 @@ using libarchive.
 If it cannot locate and open the file on disk, libarchive
 will return an error for any attempt to read the entry
 body.
-.Ss LHA
-XXX Information about libarchive's LHA support XXX
+.Ss 7-Zip
+Libarchive can read and write 7-Zip format archives.
+TODO: Need more information
 .Ss CAB
-XXX Information about libarchive's CAB support XXX
-.Ss XAR
-XXX Information about libarchive's XAR support XXX
+Libarchive can read Microsoft Cabinet (
+.Dq CAB )
+format archives.
+TODO: Need more information.
+.Ss LHA
+TODO: Information about libarchive's LHA support
 .Ss RAR
 Libarchive has limited support for reading RAR format archives.
 Currently, libarchive can read RARv3 format archives
 which have been either created uncompressed, or compressed using
 any of the compression methods supported by the RARv3 format.
 Libarchive can also read self-extracting RAR archives.
+.Ss Warc
+Libarchive can read and write
+.Dq web archives .
+TODO: Need more information
+.Ss XAR
+Libarchive can read and write the XAR format used by many Apple tools.
+TODO: Need more information
 .Sh SEE ALSO
 .Xr ar 1 ,
 .Xr cpio 1 ,
diff --git a/Utilities/cmlibarchive/libarchive/libarchive_changes.3 b/Utilities/cmlibarchive/libarchive/libarchive_changes.3
index bacd6e1..881a67c 100644
--- a/Utilities/cmlibarchive/libarchive/libarchive_changes.3
+++ b/Utilities/cmlibarchive/libarchive/libarchive_changes.3
@@ -28,7 +28,7 @@
 .Dt LIBARCHIVE_CHANGES 3
 .Os
 .Sh NAME
-.Nm changes in libarchive interface
+.Nd changes in libarchive interface
 .\"
 .Sh CHANGES IN LIBARCHIVE 3
 This page describes user-visible changes in libarchive3, and lists
diff --git a/Utilities/cmlibarchive/libarchive/xxhash.c b/Utilities/cmlibarchive/libarchive/xxhash.c
index f7647a5..d7f8e96 100644
--- a/Utilities/cmlibarchive/libarchive/xxhash.c
+++ b/Utilities/cmlibarchive/libarchive/xxhash.c
@@ -29,8 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 You can contact the author at :
 - xxHash source repository : http://code.google.com/p/xxhash/
 */
+#include <stdlib.h>
+#include <string.h>
 
 #include "archive_platform.h"
+#include "archive_xxhash.h"
+
 #ifdef HAVE_LIBLZ4
 
 /***************************************
@@ -53,7 +57,7 @@ You can contact the author at :
 ** #define XXH_ACCEPT_NULL_INPUT_POINTER 1
 
 ** XXH_FORCE_NATIVE_FORMAT :
-** By default, xxHash library provides endian-independant Hash values, based on little-endian convention.
+** By default, xxHash library provides endian-independent Hash values, based on little-endian convention.
 ** Results are therefore identical for little-endian and big-endian CPU.
 ** This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format.
 ** Should endian-independance be of no importance for your application, you may set the #define below to 1.
@@ -83,11 +87,8 @@ You can contact the author at :
 /***************************************
 ** Includes & Memory related functions
 ****************************************/
-#include "archive_xxhash.h"
-#include <stdlib.h>
 #define XXH_malloc malloc
 #define XXH_free free
-#include <string.h>
 #define XXH_memcpy memcpy
 
 
@@ -497,4 +498,17 @@ struct archive_xxhash __archive_xxhash = {
 	XXH32_update,
 	XXH32_digest
 };
+#else
+
+/*
+ * Define an empty version of the struct if we aren't using the LZ4 library.
+ */
+const
+struct archive_xxhash __archive_xxhash = {
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
 #endif /* HAVE_LIBLZ4 */
diff --git a/Utilities/cmliblzma/liblzma/simple/x86.c b/Utilities/cmliblzma/liblzma/simple/x86.c
index 101d8ed..95858e5 100644
--- a/Utilities/cmliblzma/liblzma/simple/x86.c
+++ b/Utilities/cmliblzma/liblzma/simple/x86.c
@@ -103,7 +103,7 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
 				if (!Test86MSByte(b))
 					break;
 
-				src = dest ^ ((1 << (32 - i * 8)) - 1);
+				src = dest ^ ((1u << (32 - i * 8)) - 1);
 			}
 
 			buffer[buffer_pos + 4]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-cmake/cmake.git



More information about the Pkg-cmake-commits mailing list